ASoC: add SSM2604 codec driver
Subsystems (3)
PATCH 1/1 ASoC: add SSM2604 codec driver
From: Cliff Cai <[email protected]>
--- sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ssm2604.c | 643 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/ssm2604.h | 92 +++++++ 4 files changed, 741 insertions(+), 0 deletions(-) create mode 100644 sound/soc/codecs/ssm2604.c create mode 100644 sound/soc/codecs/ssm2604.h
sound/soc/codecs/Kconfig +4 -0
@@ -28,6 +28,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_PCM3008 select SND_SOC_SPDIF select SND_SOC_SSM2602 if I2C + select SND_SOC_SSM2604 if I2C select SND_SOC_STAC9766 if SND_SOC_AC97_BUS select SND_SOC_TLV320AIC23 if I2C select SND_SOC_TLV320AIC26 if SPI_MASTER
@@ -150,6 +151,9 @@ config SND_SOC_SPDIF config SND_SOC_SSM2602 tristate +config SND_SOC_SSM2604 + tristate + config SND_SOC_STAC9766 tristate
sound/soc/codecs/Makefile +2 -0
@@ -16,6 +16,7 @@ snd-soc-l3-objs := l3.o snd-soc-pcm3008-objs := pcm3008.o snd-soc-spdif-objs := spdif_transciever.o snd-soc-ssm2602-objs := ssm2602.o +snd-soc-ssm2604-objs := ssm2604.o snd-soc-stac9766-objs := stac9766.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic26-objs := tlv320aic26.o
@@ -81,6 +82,7 @@ obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif.o obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o +obj-$(CONFIG_SND_SOC_SSM2604) += snd-soc-ssm2604.o obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o
sound/soc/codecs/ssm2604.c new file +643 -0
643 lines not on this page · raw message
sound/soc/codecs/ssm2604.h new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
1.7.2
Quoted 4 lines · Mike Frysinger
From: Cliff Cai <[email protected]>
Signed-off-by Cliff Cai <[email protected]>Signed-off-by Mike Frysinger <[email protected]>
This needs to be updated to the multi-component branch. There's a few other issues as well.
Quoted 1 line
+#define
SSM2604_VERSION"0.1"
Drop this, just track the version through git and kernel releases.
sound/soc/codecs/ssm2604.c line 55
Quoted 3 lines
sound/soc/codecs/ssm2604.c new file +3
-0+static const struct soc_enum ssm2604_enum[] = { +SOC_ENUM_SINGLE (SSM2604_APDIGI ,1 ,4 , ssm2604_deemph), +};
Use individual variables for enums rather than stuffing them all in an array. The arrays are just hard to read and error prone...
sound/soc/codecs/ssm2604.c line 67
Quoted 3 lines
sound/soc/codecs/ssm2604.c new file +3
-0+SOC_ENUM ("Capture Source" , ssm2604_enum[0 ]), + +SOC_ENUM("Playback De-emphasis", ssm2604_enum[1]),
...are you sure this code runs correctly? I see only one element in the array. It's worth checking this in your other drivers as well.
sound/soc/codecs/ssm2604.c line 232
Quoted 5 lines
sound/soc/codecs/ssm2604.c new file +5
-0+/* The DAI has shared clocks so if we already have a playback or +* capture going then constrain this substream to match it. +* TODO: the ssm2604 allows pairs of non-matching PB/REC rates +*/ +if (ssm2604->master_substream) {
Set the symmetric_rates flag on the DAI rather than open coding this.
sound/soc/codecs/ssm2604.c line 279
Quoted 3 lines
sound/soc/codecs/ssm2604.c new file +3
-0+/* deactivate */ +if (!codec->active) +snd_soc_write (codec,SSM2604_ACTIVE ,0 );
This probably wants to be managed by DAPM (possibly a supply widget for the DAC and ADC).
sound/soc/codecs/ssm2604.c line 404
Quoted 3 lines
sound/soc/codecs/ssm2604.c new file +3
-0+#define SSM2604_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_32000 |\ + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000)
SNDRV_PCM_RATE_8000_96000
sound/soc/codecs/ssm2604.c line 490
Quoted 1 line
sound/soc/codecs/ssm2604.c new file +1
-0+snd_soc_write (codec,SSM2604_APANA ,APANA_SELECT_DAC );
This could use a little explanation?
sound/soc/codecs/ssm2604.h line 87
Quoted 4 lines
sound/soc/codecs/ssm2604.h new file +4
-0+struct ssm2604_setup_data { +int i2c_bus; +unsigned short i2c_address; +};
This is definitely not needed, even with the current code.
A message that is not in the archive (sent off-list or not yet received): 20100807124416.GB11817-yzvPICuk2AATkU/[email protected]
Quoted 2 lines · Mark Brown
This needs to be updated to the multi-component branch. There's a few other issues as well.
ive logged a tracker item for this stuff
http://blackfin.uclinux.org/gf/tracker/6158
-mike
_______________________________________________
Uclinux-dist-devel mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/uclinux-dist-devel
PATCH v2 1/1 ASoC: add SSM2604 codec driver
In reply to Mike FrysingerFrom: Cliff Cai <[email protected]>
---
v2
- update to multi-component
- touch up style a bit
- drop dead structs
- drop rate and sample bits constraints
sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ssm2604.c | 524 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/ssm2604.h | 84 +++++++ 4 files changed, 614 insertions(+), 0 deletions(-) create mode 100644 sound/soc/codecs/ssm2604.c create mode 100644 sound/soc/codecs/ssm2604.h
sound/soc/codecs/Kconfig +4 -0
@@ -35,6 +35,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_PCM3008 select SND_SOC_SPDIF select SND_SOC_SSM2602 if I2C + select SND_SOC_SSM2604 if I2C select SND_SOC_STAC9766 if SND_SOC_AC97_BUS select SND_SOC_TLV320AIC23 if I2C select SND_SOC_TLV320AIC26 if SPI_MASTER
@@ -186,6 +187,9 @@ config SND_SOC_SPDIF config SND_SOC_SSM2602 tristate +config SND_SOC_SSM2604 + tristate + config SND_SOC_STAC9766 tristate
sound/soc/codecs/Makefile +2 -0
@@ -22,6 +22,7 @@ snd-soc-pcm3008-objs := pcm3008.o snd-soc-alc5623-objs := alc5623.o snd-soc-spdif-objs := spdif_transciever.o snd-soc-ssm2602-objs := ssm2602.o +snd-soc-ssm2604-objs := ssm2604.o snd-soc-stac9766-objs := stac9766.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic26-objs := tlv320aic26.o
@@ -103,6 +104,7 @@ obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif.o obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o +obj-$(CONFIG_SND_SOC_SSM2604) += snd-soc-ssm2604.o obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o
sound/soc/codecs/ssm2604.c new file +524 -0
524 lines not on this page · raw message
sound/soc/codecs/ssm2604.h new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Quoted 4 lines · Mike Frysinger
From: Cliff Cai <[email protected]>
Signed-off-by Cliff Cai <[email protected]>Signed-off-by Mike Frysinger <[email protected]>
This mostly looks pretty good, a few issues below many of which are style things - the namespacing one is the major one that's externally visible.
sound/soc/codecs/ssm2604.c line 107
Quoted 7 lines
sound/soc/codecs/ssm2604.c new file +7
-0+static int ssm2604_add_widgets (struct snd_soc_codec *codec) +{ +struct snd_soc_dapm_context *dapm = &codec->dapm; + +snd_soc_dapm_new_controls (dapm, ssm2604_dapm_widgets, +ARRAY_SIZE (ssm2604_dapm_widgets)); +snd_soc_dapm_add_routes (dapm, audio_conn,ARRAY_SIZE (audio_conn));
This should really use the driver data based initialisation that was added during the last development cycle.
sound/soc/codecs/ssm2604.c line 213
Quoted 7 lines
sound/soc/codecs/ssm2604.c new file +7
-0+static int ssm2604_pcm_prepare (struct snd_pcm_substream *substream, +struct snd_soc_dai *dai) +{ +struct snd_soc_pcm_runtime *rtd = substream->private_data; +struct snd_soc_codec *codec = rtd->codec; +/* set active */ +snd_soc_write (codec,SSM2604_ACTIVE ,ACTIVE_ACTIVATE_CODEC );
This still looks wrong - it won't handle simultaneous playback and record properly (stopping one will stop the other) for example. If you were to make this register bit a DAPM supply for the DAC and ADC then that'd do the right thing.
If the device can't support simultaneous playback and record there should be constraints set up telling the application layer about that.
sound/soc/codecs/ssm2604.c line 334
Quoted 6 lines
sound/soc/codecs/ssm2604.c new file +6
-0+case SND_SOC_BIAS_STANDBY : +/* everything off except vref/vmid, */ +snd_soc_write (codec,SSM2604_PWR , reg |PWR_CLK_OUT_PDN ); +break ; +case SND_SOC_BIAS_OFF : +/* everything off, dac mute, inactive */
These comments have been cut'n'pasted and are I suspect inaccurate.
sound/soc/codecs/ssm2604.c line 392
Quoted 3 lines
sound/soc/codecs/ssm2604.c new file +3
-0+/* Sync reg_cache with the hardware */ +for (i =0 ; i <ARRAY_SIZE (ssm2604_reg); i++) +snd_soc_write (codec, i, cache[i]);
There's snd_soc_cache_sync() which will do this for you. It'll also do additional stuff like suppress writes of default values which will speed up resume a bit.
sound/soc/codecs/ssm2604.c line 395
Quoted 2 lines
sound/soc/codecs/ssm2604.c new file +2
-0+ssm2604_set_bias_level (codec,SND_SOC_BIAS_STANDBY ); +snd_soc_write (codec,SSM2604_PWR , ssm2604->pwr_state);
I'm not sure what the pwr_state stuff is doing but shouldn't it be handled by either DAPM or the bias level functions?
sound/soc/codecs/ssm2604.c line 489
Quoted 2 lines
sound/soc/codecs/ssm2604.c new file +2
-0+/* corgi i2c codec control layer */ +static struct i2c_driver ssm2604_i2c_driver = {
Another cut'n'paste comment here.
sound/soc/codecs/ssm2604.c line 492
Quoted 3 lines
sound/soc/codecs/ssm2604.c new file +3
-0+ .driver = { + .name = "ssm2604-codec", + .owner = THIS_MODULE,
Drop the -codec from the name, it's not needed.
sound/soc/codecs/ssm2604.c line 509
Quoted 7 lines
sound/soc/codecs/ssm2604.c new file +7
-0+#if defined(CONFIG_I2C ) || defined(CONFIG_I2C_MODULE ) + ret =i2c_add_driver (&ssm2604_i2c_driver); +if (ret !=0 ) { +printk (KERN_ERR "Failed to register ssm2604 I2C driver: %d\n" , + ret); + } +#endif
If the device only supports I2C then there's no need for the ifdefs.
sound/soc/codecs/ssm2604.h line 32
Quoted 5 lines
sound/soc/codecs/ssm2604.h new file +5
-0+/* Left ADC Volume Control (SSM2604_REG_LEFT_ADC_VOL) */ +#define LINVOL_LIN_VOL 0x01F/* Left Channel PGA Volume control */ +#define LINVOL_LIN_ENABLE_MUTE 0x080/* Left Channel Input Mute */ +#define LINVOL_LRIN_BOTH 0x100/* Left Channel Line Input Volume update */ +
Namespace any constants exported in the header - either do that or move these and the similar constants into the driver code.
Quoted 10 lines · Mark Brown
sound/soc/codecs/ssm2604.c line 509
Quoted 7 lines · Mike Frysinger
sound/soc/codecs/ssm2604.c new file +7
-0+#if defined(CONFIG_I2C ) || defined(CONFIG_I2C_MODULE ) + ret = i2c_add_driver(&ssm2604_i2c_driver); + if (ret != 0) { + printk(KERN_ERR "Failed to register ssm2604 I2C driver: %d\n", + ret); + } +#endif If the device only supports I2C then there's no need for the ifdefs.
i thought in the past you wanted these things because you wanted to be able to build codecs regardless of the bus support (for testing iirc?) -mike
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 6 lines · Mike Frysinger
Quoted 1 line · Mark Brown
If the device only supports I2C then there's no need for the ifdefs.
i thought in the past you wanted these things because you wanted to be able to build codecs regardless of the bus support (for testing iirc?)
That has never been the case, SND_SOC_ALL_CODECS has always built things only if there is a bus for them. If you support mulitple busses they should be conditional so that you only need one of them to build but if there's only one supported this is not relevant.