ASoC: new ADAV801/ADAV803 codec driver
Subsystems (3)
PATCH 1/2 ASoC: new ADAV801/ADAV803 codec driver
From: Yi Li <[email protected]>
--- sound/soc/codecs/Kconfig | 6 +- sound/soc/codecs/Makefile | 2 + sound/soc/codecs/adav80x.c | 631 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/adav80x.h | 93 +++++++ 4 files changed, 731 insertions(+), 1 deletions(-) create mode 100644 sound/soc/codecs/adav80x.c create mode 100644 sound/soc/codecs/adav80x.h
sound/soc/codecs/Kconfig +5 -1
@@ -15,8 +15,9 @@ config SND_SOC_ALL_CODECS select SND_SOC_AD1836 if SPI_MASTER select SND_SOC_AD193X if SND_SOC_I2C_AND_SPI select SND_SOC_AD1980 if SND_SOC_AC97_BUS - select SND_SOC_ADS117X select SND_SOC_AD73311 if I2C + select SND_SOC_ADAV80X if SND_SOC_I2C_AND_SPI + select SND_SOC_ADS117X select SND_SOC_AK4104 if SPI_MASTER select SND_SOC_AK4535 if I2C select SND_SOC_AK4642 if I2C
@@ -103,6 +104,9 @@ config SND_SOC_AD1980 config SND_SOC_AD73311 tristate +config SND_SOC_ADAV80X + tristate + config SND_SOC_ADS117X tristate
sound/soc/codecs/Makefile +2 -0
@@ -3,6 +3,7 @@ snd-soc-ad1836-objs := ad1836.o snd-soc-ad193x-objs := ad193x.o snd-soc-ad1980-objs := ad1980.o snd-soc-ad73311-objs := ad73311.o +snd-soc-adav80x-objs := adav80x.o snd-soc-ads117x-objs := ads117x.o snd-soc-ak4104-objs := ak4104.o snd-soc-ak4535-objs := ak4535.o
@@ -69,6 +70,7 @@ obj-$(CONFIG_SND_SOC_AD1836) += snd-soc-ad1836.o obj-$(CONFIG_SND_SOC_AD193X) += snd-soc-ad193x.o obj-$(CONFIG_SND_SOC_AD1980) += snd-soc-ad1980.o obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o +obj-$(CONFIG_SND_SOC_ADAV80X) += snd-soc-adav80x.o obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o
sound/soc/codecs/adav80x.c new file +631 -0
631 lines not on this page · raw message
sound/soc/codecs/adav80x.h new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
1.7.2
PATCH 2/2 ASoC: Blackfin: new machine driver for ADAV801/ADAV803 codecs
From: Yi Li <[email protected]>
--- sound/soc/blackfin/Kconfig | 8 ++ sound/soc/blackfin/Makefile | 2 + sound/soc/blackfin/bf5xx-adav80x.c | 154 ++++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 0 deletions(-) create mode 100644 sound/soc/blackfin/bf5xx-adav80x.c
sound/soc/blackfin/Kconfig +8 -0
@@ -32,6 +32,14 @@ config SND_BFIN_AD73311_SE Enter the GPIO used to control AD73311's SE pin. Acceptable values are 0 to 7 +config SND_BF5XX_SOC_ADAV80X + tristate "SoC ADAV801/3 Audio support" + depends on SND_BF5XX_I2S && (SPI_MASTER || I2C) + select SND_BF5XX_SOC_I2S + select SND_SOC_ADAV80X + help + Say Y if you want to add support for ADAV80X SoC audio. + config SND_BF5XX_TDM tristate "SoC I2S(TDM mode) Audio for the ADI BF5xx chip" depends on (BLACKFIN && SND_SOC)
sound/soc/blackfin/Makefile +2 -0
@@ -21,9 +21,11 @@ snd-ad1980-objs := bf5xx-ad1980.o snd-ssm2602-objs := bf5xx-ssm2602.o snd-ad73311-objs := bf5xx-ad73311.o snd-ad193x-objs := bf5xx-ad193x.o +snd-adav80x-objs := bf5xx-adav80x.o obj-$(CONFIG_SND_BF5XX_SOC_AD1836) += snd-ad1836.o obj-$(CONFIG_SND_BF5XX_SOC_AD1980) += snd-ad1980.o obj-$(CONFIG_SND_BF5XX_SOC_SSM2602) += snd-ssm2602.o obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o obj-$(CONFIG_SND_BF5XX_SOC_AD193X) += snd-ad193x.o +obj-$(CONFIG_SND_BF5XX_SOC_ADAV80X) += snd-adav80x.o
sound/soc/blackfin/bf5xx-adav80x.c new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
1.7.2
Re: [PATCH 2/2] ASoC: Blackfin: new machine driver for ADAV801/ADAV803 codecs
sound/soc/blackfin/Kconfig config SND_BFIN_AD73311_SE · line 41
Quoted 7 lines · Mike Frysinger
sound/soc/blackfin/Kconfig +7
-0+config SND_BF5XX_SOC_ADAV80X + tristate "SoC ADAV801/3 Audio support" + depends on SND_BF5XX_I2S && (SPI_MASTER || I2C) + select SND_BF5XX_SOC_I2S + select SND_SOC_ADAV80X + help + Say Y if you want to add support for ADAV80X SoC audio.
This help text is really not terribly descriptive - this is support for that CODEC on a particular board, not support for the CODEC itself.
As with the other Blackfin machine drivers you really should look at reporting the particular reference board this is on rather than providing a single driver which assumes a particular hookup for the system. Things like this...
sound/soc/blackfin/bf5xx-adav80x.c line 88
Quoted 4 lines
sound/soc/blackfin/bf5xx-adav80x.c new file +4
-0+/* For the ADAV80X evaluation board, use the on board crystal +as XIN, and use XIN as source for PLL1 */ + ret =snd_soc_dai_set_pll (codec_dai,ADAV80X_CLK_PLL1 , +ADAV80X_CLK_XIN ,27000000 , clk);
...aren't going to be true for every system.
sound/soc/blackfin/bf5xx-adav80x.c line 92
Quoted 3 lines
sound/soc/blackfin/bf5xx-adav80x.c new file +3
-0+/* If you want to use XIN as clock source */ +/* ret = snd_soc_dai_set_pll(codec_dai, 0, ADAV80X_CLK_XIN, +27000000, 0); */
This should probably be highlighted by an ifdef or even Kconfig option. Some sort comment explaining why people might want to choose one option or the other would also be useful.
sound/soc/codecs/Kconfig config SND_SOC_ALL_CODECS · line 20
Quoted 4 lines · Mike Frysinger
sound/soc/codecs/Kconfig +2
-1- select SND_SOC_ADS117X select SND_SOC_AD73311 if I2C + select SND_SOC_ADAV80X if SND_SOC_I2C_AND_SPI + select SND_SOC_ADS117X
The restarting should really have been done separately or flagged in the changelog - part of making things easy to review is avoiding surprises.
sound/soc/codecs/adav80x.c line 35
Quoted 4 lines
sound/soc/codecs/adav80x.c new file +4
-0+static struct snd_soc_codec *adav80x_codec; +struct snd_soc_codec_device soc_codec_dev_adav80x; +static int adav80x_register (struct adav80x_priv *adav80x,int bus_type); +static void adav80x_unregister (struct adav80x_priv *adav80x);
This also needs to be redone against multi-component as with the driver I reviewed earlier today. Please avoid posting any further drivers that haven't been done against multi-component, it'll be merged into -next pretty much as soon as the merge window closes.
sound/soc/codecs/adav80x.c line 62
Quoted 3 lines
sound/soc/codecs/adav80x.c new file +3
-0+/* DAC peak volume detect, read clears it */ +SOC_DOUBLE_R ("DAC Peak Volume" ,ADAV80X_DAC_L_PEAK_VOL , + ADAV80X_DAC_R_PEAK_VOL, 0, 0x3F, 0),
This really needs a new, read only, control type defining. I'm also not seeing these registers being marked as volatile which means that these controls will always return cached values rather than actual data read from the chip.
sound/soc/codecs/adav80x.c line 66
Quoted 3 lines
sound/soc/codecs/adav80x.c new file +3
-0+/* ADC volume control */ +SOC_DOUBLE_R ("ADC Volume" ,ADAV80X_ADC_L_VOL , + ADAV80X_ADC_R_VOL, 0, 0xFF, 0),
Use Playback and Capture instead of DAC and ADC.
sound/soc/codecs/adav80x.c line 159
Quoted 9 lines
sound/soc/codecs/adav80x.c new file +9
-0+/* ADC Modulator clock is 6.144MHz Max, +need to set devidor properly */ +if (sample_rate ==96000 ) + reg |=0x80 ; +else if (sample_rate ==48000 ) + reg &=0x7F ; +else +/* Unsupported sample rate */ +return -1 ;
A switch statement would flow better here and you should return a proper error code.
sound/soc/codecs/adav80x.c line 184
Quoted 13 lines
sound/soc/codecs/adav80x.c new file +13
-0+if (clk_id ==ADAV80X_CLK_PLL1 ) { +/* PLL1 clock rate is assumed to be 256 * Fs */ + + reg =snd_soc_read (codec,ADAV80X_DAC_CTRL2 ); +if (sample_rate ==96000 ) +/* Set the MCLK divider to be MCLK/2, +and MCLK = 128 * Fs */ + reg |=0x24 ; +else + reg &=0x11 ; + +snd_soc_write (codec,ADAV80X_DAC_CTRL2 , reg); + }
What if the clock is not PLL1?
sound/soc/codecs/adav80x.c line 244
Quoted 11 lines
sound/soc/codecs/adav80x.c new file +11
-0+#ifdef CONFIG_PM +static int adav80x_soc_suspend (struct platform_device *pdev, +pm_message_t state) +{ +return 0 ; +} + +static int adav80x_soc_resume (struct platform_device *pdev) +{ +return 0 ; +}
Remove empty functions.
sound/soc/codecs/adav80x.c line 257
Quoted 3 lines
sound/soc/codecs/adav80x.c new file +3
-0+ reg =snd_soc_read (codec,ADAV80X_DAC_CTRL1 ); + reg = (mute >0 ) ? reg & ~0x3 : reg |0x3 ; +snd_soc_write (codec,ADAV80X_DAC_CTRL1 , reg);
The ternery operator isn't great for legibility.
sound/soc/codecs/adav80x.c line 280
Quoted 7 lines
sound/soc/codecs/adav80x.c new file +7
-0+if (freq_in && freq_out) { +/* XIN - assumes 27MHz */ +if (freq_in !=27000000 ) +return -1 ; + +if (pll_id !=ADAV80X_CLK_PLL1 ) +return -1 ;
Return proper error codes.
Quoted 12 lines
sound/soc/codecs/adav80x.c new file +12
-0+ +/* freq_out = sample_rate * 256 */ +switch (freq_out) { +case 32000 : + reg =0x8 ; +break ; +case 44100 : + reg =0xC ; +break ; +case 48000 : + reg =0x0 ; +break ;
sound/soc/codecs/adav80x.c line 302
Quoted 10 lines
sound/soc/codecs/adav80x.c new file +10
-0+case 64000 : + reg =0x9 ; +break ; +case 88200 : + reg =0xD ; +break ; +case 96000 : + reg =0x1 ; +break ; + }
Looking at this the output frequencies you're handling are actually the sample rates rather than 256fs like the comment says. You also need to handle unknown frequencies here.
sound/soc/codecs/adav80x.c line 331
Quoted 11 lines
sound/soc/codecs/adav80x.c new file +11
-0+if (adav80x->clk_src ==ADAV80X_CLK_XIN ) +return 0 ; +else + adav80x->clk_src =ADAV80X_CLK_XIN ; + +/* Turn off PLL, power on XTAL */ +snd_soc_write (codec,ADAV80X_PLL_CTRL1 ,0xC ); + +/* DAC, ADC, ICLK clock source - XIN */ +snd_soc_write (codec,ADAV80X_ICLK_CTRL1 ,0x0 ); +snd_soc_write (codec,ADAV80X_ICLK_CTRL2 ,0x0 );
Normally I'd expect to see the clock source switched over to XIN before rather than after the PLL is stopped to ensure a continuity in clocking.
sound/soc/codecs/adav80x.c line 482
Quoted 6 lines
sound/soc/codecs/adav80x.c new file +5
-0+/* Power down SYSCLK output, power down S/PDIF receiver */ +snd_soc_write (codec,ADAV80X_PLL_OUTE ,0x27 ); + +/* Disable S/PDIF transmitter */ +snd_soc_write (codec,ADAV80X_TX_CTRL ,0x0 );
DAPM should be able to take care of all this automatically.
sound/soc/codecs/adav80x.c line 485
Quoted 2 lines
sound/soc/codecs/adav80x.c new file +2
-0+/* Datapath: ADC->record, AUX_IN->SRC->AUX_OUT */ +snd_soc_write (codec,ADAV80X_DPATH_CTRL1 ,0xC4 );
Remove this and pretty much all of the rest of this function - just leave the chip with the default settings and let the user configure whatever use case they want on their system. The values you set here may not be appropriate for other users.
sound/soc/codecs/adav80x.h line 15
Quoted 3 lines
sound/soc/codecs/adav80x.h new file +3
-0+#if (CONFIG_I2C ) || defined(CONFIG_I2C_MODULE ) +/* ADAV80X I2C interface requires left-shifting reg addr for 1-bit */ +#define ADAV80X_NUM_REGS (0x7E<<1)
This is all going to break if the user elects to build both I2C and SPI support into the same kernel and in any case even for a compile time selection having two totally different sets of register definitions is pretty inelegant.
ive put this feedback into a tracker item:
http://blackfin.uclinux.org/gf/tracker/6159
-mike