S3C64XX I2S: Added machine driver for WM8580
PATCH 1/1 S3C64XX I2S: Added machine driver for WM8580
New machine driver for WM8580 I2S i/f on SMDK64XX.
By default SoC-Slave is set and WM8580 is configured to use it's PLLA to generate clocks from a 12MHz crystal attached to WM8580. I2S controller-0 is set as default, set S3C64XX_I2S_CNTRLR to 2 inorder to use I2S_v4 controller of S3C6410.
--- sound/soc/s3c24xx/Kconfig | 8 + sound/soc/s3c24xx/Makefile | 2 + sound/soc/s3c24xx/smdk64xx_wm8580.c | 288 +++++++++++++++++++++++++++++++++++ 3 files changed, 298 insertions(+), 0 deletions(-) create mode 100644 sound/soc/s3c24xx/smdk64xx_wm8580.c
sound/soc/s3c24xx/Kconfig +8 -0
@@ -56,6 +56,14 @@ config SND_S3C24XX_SOC_JIVE_WM8750 help Sat Y if you want to add support for SoC audio on the Jive. +config SND_S3C64XX_SOC_WM8580 + tristate "SoC I2S Audio support for WM8580 on SMDK64XX" + depends on SND_S3C24XX_SOC && (MACH_SMDK6400 || MACH_SMDK6410) + select SND_SOC_WM8580 + select SND_S3C64XX_SOC_I2S + help + Sat Y if you want to add support for SoC audio on the SMDK64XX. + config SND_S3C24XX_SOC_SMDK2443_WM9710 tristate "SoC AC97 Audio support for SMDK2443 - WM9710" depends on SND_S3C24XX_SOC && MACH_SMDK2443
sound/soc/s3c24xx/Makefile +2 -0
@@ -23,6 +23,7 @@ snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o snd-soc-s3c24xx-simtec-tlv320aic23-objs := s3c24xx_simtec_tlv320aic23.o +snd-soc-smdk64xx-wm8580-objs := smdk64xx_wm8580.o obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
@@ -33,4 +34,5 @@ obj-$(CONFIG_SND_S3C24XX_SOC_S3C24XX_UDA134X) += snd-soc-s3c24xx-uda134x.o obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC) += snd-soc-s3c24xx-simtec.o obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_HERMES) += snd-soc-s3c24xx-simtec-hermes.o obj-$(CONFIG_SND_S3C24XX_SOC_SIMTEC_TLV320AIC23) += snd-soc-s3c24xx-simtec-tlv320aic23.o +obj-$(CONFIG_SND_S3C64XX_SOC_WM8580) += snd-soc-smdk64xx-wm8580.o
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +288 -0
288 lines not on this page · raw message
+static void __exit smdk64xx_audio_exit(void)
+{
+ platform_device_unregister(smdk64xx_snd_device);
+}
+module_exit(smdk64xx_audio_exit);
+
+/* Module information */
+MODULE_DESCRIPTION("ALSA SoC SMDK64XX WM8580");
+MODULE_LICENSE("GPL");
Signature · 1 line
1.6.2.5
Quoted 3 lines · Jassi
New machine driver for WM8580 I2S i/f on SMDK64XX.
By default SoC-Slave is set and WM8580 is configured to use it's PLLA to generate clocks from a 12MHz crystal attached to WM8580.
This looks sane as a starting point and most of the driver looks OK.
Quoted 2 lines
I2S controller-0 is set as default, set
S3C64XX_I2S_CNTRLRto 2 inorder to useI2S_v4controller of S3C6410.
I'm not entirely sure what's going on in this configuration - the primary AIFs of the CODEC appear to be hard wired to the IISv4 interface in the schematics I have, IIS port 0 is only wired to the secondary AIF of the WM8580 so will need support for that implementing. The end result should be an extra set of DAI links for the secondary AIF. Could you clarify, please?
sound/soc/s3c24xx/smdk64xx_wm8580.c line 28
Quoted 2 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +2
-0+/* SMDK64XX has a 12MHZ crystal attached to WM8580 */ +#define SMDK64XX_WM8580_FREQ (12000000)
No need for the () here.
sound/soc/s3c24xx/smdk64xx_wm8580.c line 41
Quoted 3 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +3
-0+switch (params_rate (params)) { +case 8000 : + pll_out =8192000 /4 ;break ;
These are all a bit odd - you're taking two magic numbers and performing an operation on them, giving another magic number. For the most part the resulting magic number is always 256fs (I suspect the cases where they aren't should be 256fs). Probably replacing all of this with
pll_out = params_rate(params) * 256
would work.
sound/soc/s3c24xx/smdk64xx_wm8580.c line 82
Quoted 5 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +5
-0+/* We block CODCLK from MCLK of WM8580 */ + ret =snd_soc_dai_set_sysclk (cpu_dai,S3C64XX_CODCLKSRC_EXT , +0 ,SND_SOC_CLOCK_IN ); +if (ret <0 ) +return ret;
The code is OK (modulo the issues with the previous patch) but the comment is exceptionally difficult to parse.
sound/soc/s3c24xx/smdk64xx_wm8580.c line 98
Quoted 3 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +3
-0+/* Explicitly set WM8580-ADC/DAC to source from MCLK */ + ret =snd_soc_dai_set_clkdiv (codec_dai,WM8580_ADC_CLKSEL , +WM8580_CLKSRC_MCLK );
Obviously this will need updating for the actual patch for the WM8580 driver.
sound/soc/s3c24xx/smdk64xx_wm8580.c line 101
Quoted 3 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +3
-0+if (ret <0 ) +return ret; + ret = snd_soc_dai_set_clkdiv(codec_dai, WM8580_DAC_CLKSEL,
Missing blank line here.
sound/soc/s3c24xx/smdk64xx_wm8580.c line 110
Quoted 5 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +5
-0+/* Don't output to the disconnected pin */ + ret =snd_soc_dai_set_clkdiv (codec_dai,WM8580_CLKOUTSRC , +WM8580_CLKSRC_NONE ); +if (ret <0 ) +return ret;
If you're going to do this do it on init, it's nothing to do with starting the audio stream.
Quoted 4 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +4
-0+switch (params_format (params)) { +case SNDRV_PCM_FORMAT_U8 : +case SNDRV_PCM_FORMAT_S8 : + bfs =16 ;
sound/soc/s3c24xx/smdk64xx_wm8580.c line 130
Quoted 10 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +10
-0+ rfs =256 ; +break ; +case SNDRV_PCM_FORMAT_U16_LE : +case SNDRV_PCM_FORMAT_S16_LE : + bfs =32 ; + rfs =256 ; +break ; +default : +return -EINVAL ; + }
This ought to get factored out into the CPU DAI driver, at least as a library function - there's nothing board specific going on here.
sound/soc/s3c24xx/smdk64xx_wm8580.c line 209
Quoted 3 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +3
-0+/* LineIn enabled by default */ +snd_soc_dapm_disable_pin (codec,"MicIn" ); +snd_soc_dapm_enable_pin (codec,"LineIn" );
Please add a comment explaining that if this is changed it needs to be done with a resistor fit mod - this begs the question "How do I change away from the default?", especially given the many switches for things like this on the board.
For completeness if you're going to handle the mapping to the external jacks there's also the possiblity that the signals will be switched out to the PMIC card or WM9713. It's probably better to just not bother, it's not really adding anything since there's no jack detect or anything on the board. All that'll happen is that people are forced to rebuild for DIP switch changes.
The other option would be to add controls mirroring the DIP switch settings, but that'd not really cover the resistor fit stuff.
sound/soc/s3c24xx/smdk64xx_wm8580.c line 229
Quoted 4 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +4
-0+/* Stereo enabled by default */ +snd_soc_dapm_enable_pin (codec,"Front-L/R" ); +snd_soc_dapm_disable_pin (codec,"Center/Sub" ); +snd_soc_dapm_disable_pin (codec,"Rear-L/R" );
Similar issues here - putting a fixed configuration from this in the driver doesn't buy anything.
seems my original email to alsa-devel got stuck.
lemme resend the patch with some of ur suggestions incorporated and continue from there.
Quoted 109 lines · Mark Brown
Quoted 3 lines · Jassi
New machine driver for WM8580 I2S i/f on SMDK64XX.
By default SoC-Slave is set and WM8580 is configured to use it's PLLA to generate clocks from a 12MHz crystal attached to WM8580.This looks sane as a starting point and most of the driver looks OK.
Quoted 2 lines
I2S controller-0 is set as default, set
S3C64XX_I2S_CNTRLRto 2 inorder to useI2S_v4controller of S3C6410.I'm not entirely sure what's going on in this configuration - the primary AIFs of the CODEC appear to be hard wired to the IISv4 interface in the schematics I have, IIS port 0 is only wired to the secondary AIF of the WM8580 so will need support for that implementing. The end result should be an extra set of DAI links for the secondary AIF. Could you clarify, please?
sound/soc/s3c24xx/smdk64xx_wm8580.c line 28
Quoted 2 lines
sound/soc/s3c24xx/smdk64xx_wm8580.c new file +2
-0+/* SMDK64XX has a 12MHZ crystal attached to WM8580 */ +#define SMDK64XX_WM8580_FREQ (12000000)No need for the () here.
Quoted 3 lines
+ switch (
params_rate(params)) {
+ case 8000:
+pll_out= 8192000 / 4; break;These are all a bit odd - you're taking two magic numbers and performing an operation on them, giving another magic number. For the most part the resulting magic number is always 256fs (I suspect the cases where they aren't should be 256fs). Probably replacing all of this with
pll_out =
params_rate(params)* 256would work.
Quoted 5 lines
+ /* We block CODCLK from MCLK of WM8580 */
+ ret = snd_soc_dai_set_sysclk(cpu_dai,S3C64XX_CODCLKSRC_EXT,
+ 0,SND_SOC_CLOCK_IN);
+ if (ret < 0)
+ return ret;The code is OK (modulo the issues with the previous patch) but the comment is exceptionally difficult to parse.
Quoted 3 lines
+ /* Explicitly set WM8580-ADC/DAC to source from MCLK */
+ ret = snd_soc_dai_set_clkdiv(codec_dai,WM8580_ADC_CLKSEL,
+WM8580_CLKSRC_MCLK);Obviously this will need updating for the actual patch for the WM8580 driver.
Quoted 3 lines
+ if (ret < 0)
+ return ret;
+ ret = snd_soc_dai_set_clkdiv(codec_dai,WM8580_DAC_CLKSEL,Missing blank line here.
Quoted 5 lines
+ /* Don't output to the disconnected pin */
+ ret = snd_soc_dai_set_clkdiv(codec_dai,WM8580_CLKOUTSRC,
+WM8580_CLKSRC_NONE);
+ if (ret < 0)
+ return ret;If you're going to do this do it on init, it's nothing to do with starting the audio stream.
Quoted 6 lines
+ switch (
params_format(params)) {
+ caseSNDRV_PCM_FORMAT_U8:
+ caseSNDRV_PCM_FORMAT_S8:
+ bfs = 16;
+ rfs = 256;
+ break;Quoted 8 lines
+ case
SNDRV_PCM_FORMAT_U16_LE:
+ caseSNDRV_PCM_FORMAT_S16_LE:
+ bfs = 32;
+ rfs = 256;
+ break;
+ default:
+ return-EINVAL;
+ }This ought to get factored out into the CPU DAI driver, at least as a library function - there's nothing board specific going on here.
Quoted 3 lines
+ /* LineIn enabled by default */
+snd_soc_dapm_disable_pin(codec, "MicIn");
+snd_soc_dapm_enable_pin(codec, "LineIn");Please add a comment explaining that if this is changed it needs to be done with a resistor fit mod - this begs the question "How do I change away from the default?", especially given the many switches for things like this on the board.
For completeness if you're going to handle the mapping to the external jacks there's also the possiblity that the signals will be switched out to the PMIC card or WM9713. It's probably better to just not bother, it's not really adding anything since there's no jack detect or anything on the board. All that'll happen is that people are forced to rebuild for DIP switch changes.
The other option would be to add controls mirroring the DIP switch settings, but that'd not really cover the resistor fit stuff.
Quoted 4 lines
+ /* Stereo enabled by default */
+snd_soc_dapm_enable_pin(codec, "Front-L/R");
+snd_soc_dapm_disable_pin(codec, "Center/Sub");
+snd_soc_dapm_disable_pin(codec, "Rear-L/R");
Quoted 7 lines
Similar issues here - putting a fixed configuration from this in the driver doesn't buy anything.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel