Hi Rafel,

The fex file i have attached in my previous post i did not done any 
changes. 
and here my machine driver .

in device.c file just add fallowing line.
+static struct i2c_board_info __initdata aic3x_i2c_board_info[] = {
+        {
 +               .type = "tlv320aic31xx",
 +               .addr = 0x18,
+        }
+};
void __init sw_pdev_init(void)
{
        platform_add_devices(sw_pdevs, ARRAY_SIZE(sw_pdevs));
    +        i2c_register_board_info(2, aic3x_i2c_board_info,
  +                      ARRAY_SIZE(aic3x_i2c_board_info));
}

which kernel you are using?.

Regards
Punith

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
/*
 * rx51.c  --  SoC audio for Nokia RX-51
 *
 * Copyright (C) 2008 - 2009 Nokia Corporation
 *
 * Contact: Peter Ujfalusi <[email protected]>
 *          Eduardo Valentin <[email protected]>
 *          Jarkko Nikula <[email protected]>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/module.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <mach/sys_config.h>
#include <linux/io.h>
#include <sound/pcm_params.h>

#include "sun7i-i2s.h"
#include "sun7i-i2sdma.h"


static int rx51_hw_params(struct snd_pcm_substream *substream,
	struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_dai *codec_dai = rtd->codec_dai;
	//struct snd_soc_dai *codec_dai = rtd->codec_dai;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
       	printk("puneet %s \n",__func__);
	int ret = 0;

	ret = snd_soc_dai_set_sysclk(cpu_dai, 0 , 22579200, SND_SOC_CLOCK_OUT);
        if (ret < 0) {
                return ret;
        }


/***** *********************comments added by Punith************************/

	/*
	 * DAI hardware audio formats.
 	*
	* Describes the physical PCM data formating and clocking. Add new formats
	* to the end.
	 */
	//#define SND_SOC_DAIFMT_I2S		1 /* I2S mode */
	//#define SND_SOC_DAIFMT_RIGHT_J		2 /* Right Justified mode */
	//#define SND_SOC_DAIFMT_LEFT_J		3 /* Left Justified mode */
	//#define SND_SOC_DAIFMT_DSP_A		4 /* L data MSB after FRM LRC */
	//#define SND_SOC_DAIFMT_DSP_B		5 /* L data MSB during FRM LRC */
	//#define SND_SOC_DAIFMT_AC97		6 /* AC97 */
	//#define SND_SOC_DAIFMT_PDM		7 /* Pulse density modulation */

	/* left and right justified also known as MSB and LSB respectively */
	//#define SND_SOC_DAIFMT_MSB		SND_SOC_DAIFMT_LEFT_J
	//#define SND_SOC_DAIFMT_LSB		SND_SOC_DAIFMT_RIGHT_J

	/*
	 * DAI Clock gating.
	 *
	 * DAI bit clocks can be be gated (disabled) when the DAI is not
	 * sending or receiving PCM data in a frame. This can be used to save power.
	 */
	//#define SND_SOC_DAIFMT_CONT		(1 << 4) /* continuous clock */
	//#define SND_SOC_DAIFMT_GATED		(2 << 4) /* clock is gated */

	/*
	 * DAI hardware signal inversions.
	 *
	 * Specifies whether the DAI can also support inverted clocks for the specified
	 * format.
	 */
	//#define SND_SOC_DAIFMT_NB_NF		(1 << 8) /* normal bit clock + frame */
	//#define SND_SOC_DAIFMT_NB_IF		(2 << 8) /* normal BCLK + inv FRM */
	//#define SND_SOC_DAIFMT_IB_NF		(3 << 8) /* invert BCLK + nor FRM */
	//#define SND_SOC_DAIFMT_IB_IF		(4 << 8) /* invert BCLK + FRM */

	/*
	 * DAI hardware clock masters.
	 *
	 * This is wrt the codec, the inverse is true for the interface
	 * i.e. if the codec is clk and FRM master then the interface is
	 * clk and frame slave.
	 */
	//#define SND_SOC_DAIFMT_CBM_CFM		(1 << 12) /* codec clk & FRM master */
	//#define SND_SOC_DAIFMT_CBS_CFM		(2 << 12) /* codec clk slave & FRM master */
	//#define SND_SOC_DAIFMT_CBM_CFS		(3 << 12) /* codec clk master & frame slave */
	//#define SND_SOC_DAIFMT_CBS_CFS		(4 << 12) /* codec clk & FRM slave */
	/*
	 * Master Clock Directions
	 */
	//#define SND_SOC_CLOCK_IN		0
	//#define SND_SOC_CLOCK_OUT		1
/**********************ended by punith******************************************************************/

	
	 /* set codec DAI configuration */
        //ret = snd_soc_dai_set_fmt(codec_dai, (1|(1<<8)|(4<<12)));
        ret = snd_soc_dai_set_fmt(codec_dai, (SND_SOC_DAIFMT_I2S|SND_SOC_DAIFMT_NB_NF|SND_SOC_DAIFMT_CBS_CFS);
        if (ret < 0)
                return ret;


	        /* set cpu DAI configuration */
        //ret = snd_soc_dai_set_fmt(cpu_dai,(1|(1<<8)|(4<<12)));
        ret = snd_soc_dai_set_fmt(cpu_dai,(SND_SOC_DAIFMT_I2S|SND_SOC_DAIFMT_NB_NF|SND_SOC_DAIFMT_CBM_CFM);
        if (ret < 0)
                return ret;

	ret = snd_soc_dai_set_clkdiv(cpu_dai, 0, 44100);  //*******set the sample rate 44100 ****/
        if (ret < 0) {
                return ret;
        }

	/* Set the codec system clock for DAC and ADC */
	return snd_soc_dai_set_sysclk(codec_dai, 0,19200000,   
				      SND_SOC_CLOCK_OUT);
}

static struct snd_soc_ops rx51_ops = {
//	.startup = rx51_startup,
	.hw_params = rx51_hw_params,
};




static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = {
/*	SND_SOC_DAPM_SPK("Ext Spk", rx51_spk_event),
	SND_SOC_DAPM_MIC("DMic", NULL),
	SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event),
	SND_SOC_DAPM_MIC("HS Mic", NULL),
	SND_SOC_DAPM_LINE("FM Transmitter", NULL),*/
	SND_SOC_DAPM_HP("Headphone Jack", NULL),
       // SND_SOC_DAPM_LINE("Line Out", NULL),
       //  SND_SOC_DAPM_MIC("Mic Jack", NULL),
	// SND_SOC_DAPM_LINE("Line In", NULL),

};


/**routing audio to HPL and HPR LINES***/

static const struct snd_soc_dapm_route audio_map[] = {
//	{"Speaker", NULL, "SPL"},
//	{"Speaker", NULL, "SPR"},
	/*{"Headphone Jack", NULL, "LLOUT"},
	{"Headphone Jack", NULL, "RLOUT"},
	{"FM Transmitter", NULL, "LLOUT"},
	{"FM Transmitter", NULL, "RLOUT"},

	{"DMic Rate 64", NULL, "Mic Bias 2V"},
	{"Mic Bias 2V", NULL, "DMic"},*/

	/* Headphone connected to HPLOUT, HPROUT */
        {"Headphone Jack", NULL, "HPL"},
        {"Headphone Jack", NULL, "HPR"},
	/* HPL path */
        {"HP Left", "Switch", "Output Left"},
        {"HPL Driver", NULL, "HP Left"},
        {"HPL", NULL, "HPL Driver"},

        /* HPR path */
        {"HP Right", "Switch", "Output Right"},
        {"HPR Driver", NULL, "HP Right"},
        {"HPR", NULL, "HPR Driver"},

        /* Line Out connected to LLOUT, RLOUT */
       // {"Line Out", NULL, "LLOUT"},
       // {"Line Out", NULL, "RLOUT"},

        /* Mic connected to (MIC3L | MIC3R) */
       // {"MIC3L", NULL, "Mic Bias 2V"},
       // {"MIC3R", NULL, "Mic Bias 2V"},
       // {"Mic Bias 2V", NULL, "Mic Jack"},

        /* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
       // {"LINE1L", NULL, "Line In"},
       // {"LINE2L", NULL, "Line In"},
       // {"LINE1R", NULL, "Line In"},
       // {"LINE2R", NULL, "Line In"},

};

static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
{
	struct snd_soc_codec *codec = rtd->codec;
	struct snd_soc_dapm_context *dapm = &codec->dapm;
	int err;

	printk("puneet %s\n", __func__);
	
	/* Add RX-51 specific widgets */
	snd_soc_dapm_new_controls(dapm, aic34_dapm_widgets,
				  ARRAY_SIZE(aic34_dapm_widgets));

	/* Set up RX-51 specific audio path audio_map */
	snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));


	snd_soc_dapm_nc_pin(dapm, "MIC3L");  // nc pin not connected
	snd_soc_dapm_nc_pin(dapm, "MIC3R");   // nc pin
	snd_soc_dapm_nc_pin(dapm, "LINE1R");  // nc pin 
	snd_soc_dapm_nc_pin(dapm, "MONO_LOUT"); //nc pin
        snd_soc_dapm_enable_pin(dapm, "HPL"); // HPL enabled
        snd_soc_dapm_enable_pin(dapm, "HPR");  //HPR enabled
       

        /* always connected */
        snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
        snd_soc_dapm_nc_pin(dapm, "Line Out");
        snd_soc_dapm_nc_pin(dapm, "Mic Jack");
        snd_soc_dapm_nc_pin(dapm, "Line In");


	return 0;
}


/* Digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link rx51_dai[] = {
	{

		.name	        = "TLV320AIC34",
		.stream_name 	= "AIC34",
		.cpu_dai_name 	= "sun7i-i2s.0",
		.codec_dai_name = "tlv320aic31xx-dai",
		.init 		= rx51_aic34_init,
		.platform_name  = "sun7i-i2s-pcm-audio.0",
		.codec_name 	= "tlv320aic31xx-codec.2-0018",
		//.dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF |
		//	   SND_SOC_DAIFMT_CBM_CFM,
		.ops = &rx51_ops,
	},
};

/* Audio card */
static struct snd_soc_card rx51_sound_card = {
	.name = "RX-51",
	.owner = THIS_MODULE,
	.dai_link = &rx51_dai,
	.num_links = 1,
	};

static struct platform_device *rx51_snd_device;

static int __init rx51_soc_init(void)
{
	int err;

	rx51_snd_device = platform_device_alloc("soc-audio", 3);
	if (!rx51_snd_device) {
		err = -ENOMEM;
		return err;
	}

	platform_set_drvdata(rx51_snd_device, &rx51_sound_card);

	err = platform_device_add(rx51_snd_device);
	if (err)
		{
		platform_device_put(rx51_snd_device);
		}
		//goto err2;

	return err;

}

static void __exit rx51_soc_exit(void)
{

	platform_device_unregister(rx51_snd_device);

}

module_init(rx51_soc_init);
module_exit(rx51_soc_exit);

MODULE_AUTHOR("Nokia Corporation");
MODULE_DESCRIPTION("ALSA SoC Nokia RX-51");
MODULE_LICENSE("GPL");

Reply via email to