Skip to contentSkip to conversation

ARM DaVinci: Add PCM3008 ALSA SoC driver for the Lyrtech SFFSDR board

PATCH In review Hugo Villeneuve 3 participants 4 messages Nov 18, 2008 – Nov 21, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM DaVinci: Add PCM3008 ALSA SoC driver for the Lyrtech SFFSDR board

The PCM3008 is used on the Lyrtech SFFSDR board, in conjunction with an FPGA that generates the bit clock and the master clock

---
 sound/soc/codecs/Kconfig           |    4 +
 sound/soc/codecs/Makefile          |    2 +
 sound/soc/codecs/pcm3008.c         |  223 ++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/pcm3008.h         |   25 ++++
 sound/soc/davinci/Kconfig          |    9 ++
 sound/soc/davinci/Makefile         |    2 +
 sound/soc/davinci/davinci-sffsdr.c |  145 +++++++++++++++++++++++
 7 files changed, 410 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/pcm3008.c
 create mode 100644 sound/soc/codecs/pcm3008.h
 create mode 100644 sound/soc/davinci/davinci-sffsdr.c
sound/soc/codecs/Kconfig +4 -0
index 5df7402..dc58ce2 100644
@@ -80,6 +80,10 @@ config SND_SOC_TWL4030
 	tristate
 	depends on TWL4030_CORE
 
+config SND_SOC_PCM3008
+	tristate
+	depends on SFFSDR_FPGA
+
 config SND_SOC_UDA1380
         tristate
 
sound/soc/codecs/Makefile +2 -0
index 3b9b58a..7af88e7 100644
@@ -3,6 +3,7 @@ snd-soc-ad1980-objs := ad1980.o
 snd-soc-ad73311-objs := ad73311.o
 snd-soc-ak4535-objs := ak4535.o
 snd-soc-cs4270-objs := cs4270.o
+snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-ssm2602-objs := ssm2602.o
 snd-soc-tlv320aic23-objs := tlv320aic23.o
 snd-soc-tlv320aic26-objs := tlv320aic26.o
@@ -26,6 +27,7 @@ obj-$(CONFIG_SND_SOC_AD1980)	+= snd-soc-ad1980.o
 obj-$(CONFIG_SND_SOC_AD73311) += snd-soc-ad73311.o
 obj-$(CONFIG_SND_SOC_AK4535)	+= snd-soc-ak4535.o
 obj-$(CONFIG_SND_SOC_CS4270)	+= snd-soc-cs4270.o
+obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_SSM2602)	+= snd-soc-ssm2602.o
 obj-$(CONFIG_SND_SOC_TLV320AIC23)	+= snd-soc-tlv320aic23.o
 obj-$(CONFIG_SND_SOC_TLV320AIC26)	+= snd-soc-tlv320aic26.o
sound/soc/codecs/pcm3008.c new file +223 -0

223 lines not on this page · raw message

sound/soc/codecs/pcm3008.h new file +25 -0
new file mode 100644
index 0000000..81c82c9
@@ -0,0 +1,25 @@
+/*
+ * PCM3008 ALSA SoC Layer
+ *
+ * Author:	Hugo Villeneuve
+ * Copyright (C) 2008 Lyrtech inc
+ *
+ * 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.
+ */
+
+#ifndef __LINUX_SND_SOC_PCM3008_H
+#define __LINUX_SND_SOC_PCM3008_H
+
+struct pcm3008_setup_data {
+	u8 dem0_pin;
+	u8 dem1_pin;
+	u8 pdad_pin;
+	u8 pdda_pin;
+};
+
+extern struct snd_soc_codec_device soc_codec_dev_pcm3008;
+extern struct snd_soc_dai pcm3008_dai;
+
+#endif
sound/soc/davinci/Kconfig +9 -0
index 8f7e338..7978b81 100644
@@ -17,3 +17,12 @@ config SND_DAVINCI_SOC_EVM
 	help
 	  Say Y if you want to add support for SoC audio on TI
 	  DaVinci EVM platform.
+
+config SND_DAVINCI_SOC_SFFSDR
+	tristate "SoC Audio support for SFFSDR"
+	depends on SND_DAVINCI_SOC && MACH_DAVINCI_SFFSDR
+	select SND_DAVINCI_SOC_I2S
+	select SND_SOC_PCM3008
+	help
+	  Say Y if you want to add support for SoC audio on
+	  Lyrtech SFFSDR board.
sound/soc/davinci/Makefile +2 -0
index ca772e5..ca8bae1 100644
@@ -7,5 +7,7 @@ obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o
 
 # DAVINCI Machine Support
 snd-soc-evm-objs := davinci-evm.o
+snd-soc-sffsdr-objs := davinci-sffsdr.o
 
 obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o
+obj-$(CONFIG_SND_DAVINCI_SOC_SFFSDR) += snd-soc-sffsdr.o
sound/soc/davinci/davinci-sffsdr.c new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
1.5.5
#1 lore raw
Quoted 2 lines · Hugo Villeneuve

The PCM3008 is used on the Lyrtech SFFSDR board, in conjunction with an FPGA that generates the bit clock and the master clock

Looks fairly good overall.

Quoted 1 line

Normally codec drivers and machine drivers should be submitted as separate patches, though it's not critical.

sound/soc/codecs/Kconfig config SND_SOC_TWL4030 · line 85

Quoted 10 lines

index 5df7402..dc58ce2 100644

sound/soc/codecs/Kconfig +3 -0
@@ -80,6 +80,10 @@ config SND_SOC_TWL4030
 	tristate
 	depends on TWL4030_CORE
 
+config SND_SOC_PCM3008
+	tristate
+	depends on SFFSDR_FPGA

The codec driver shouldn't depend on the FPGA driver. Once that dependency has been removed the codec should be added to SND_SOC_ALL_CODECS.

sound/soc/codecs/Kconfig config SND_SOC_TWL4030

Quoted 12 lines
sound/soc/codecs/Kconfig +12 -0
+static int pcm3008_hw_params(struct snd_pcm_substream *substream,
+			     struct snd_pcm_hw_params *params)
+{
+	int fs;
+
+	/* Fsref can be 32000, 44100 or 48000. */
+	fs = params_rate(params);
+
+	printk(KERN_INFO "pcm3008_hw_params: rate = %d Hz\n", fs);
+
+	return sffsdr_fpga_set_codec_fs(fs);
+}

This should be being done by the machine driver rather than by the codec driver - this will allow the codec driver to be used on another machine that has some other method for generating the clocks. As far as I can see that's the only dependency on the sffsdr?

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+	/* DEM1  DEM0  DE-EMPHASIS_MODE
+	 * Low   Low   De-emphasis 44.1 kHz ON
+	 * Low   High  De-emphasis OFF
+	 * High  Low   De-emphasis 48 kHz ON
+	 * High  High  De-emphasis 32 kHz ON
+	 */

Looks like this should be exported as a control? It's not important for merging but it'd be nice.

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+static int pcm3008_soc_suspend(struct platform_device *pdev, pm_message_t msg)
+{
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct pcm3008_setup_data *setup = socdev->codec_data;
+
+	printk(KERN_INFO "pcm3008_soc_suspend(): TODO\n");

This should be a comment, though it looks like you may actually have implemented this already?

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+struct pcm3008_setup_data {
+	u8 dem0_pin;
+	u8 dem1_pin;
+	u8 pdad_pin;
+	u8 pdda_pin;
+};

GPIO numbers should be unsigned to match the gpiolib API (some systems do support an awful lot of GPIOs).

Also, ideally pdad and pdad would be used to implement DAPM controls so that they can be powered down when not in use but again that's not essential for merging - so long as they're passed in someone could do that later.

sound/soc/codecs/Kconfig

Quoted 8 lines
sound/soc/codecs/Kconfig +8 -0
+config SND_DAVINCI_SOC_SFFSDR
+	tristate "SoC Audio support for SFFSDR"
+	depends on SND_DAVINCI_SOC && MACH_DAVINCI_SFFSDR
+	select SND_DAVINCI_SOC_I2S
+	select SND_SOC_PCM3008
+	help
+	  Say Y if you want to add support for SoC audio on
+	  Lyrtech SFFSDR board.

This should also select SSFDR_FPGA - select ignores dependencies so the select from the codec driver won't be picked up (though the codec driver ought not to be selecting it in the first place).

sound/soc/davinci/davinci-sffsdr.c line 5

Quoted 8 lines
sound/soc/davinci/davinci-sffsdr.c new file +5 -0
@@ -0,0 +1,145 @@
+/*
+ * ASoC driver for Lyrtech SFFSDR board.
+ *
+ * Author:      Vladimir Barinov, <[email protected]>
+ * Copyright:   (C) 2007 MontaVista Software, Inc., <[email protected]>

Are you sure? Looks like cut'n'paste - MODULE_AUTHOR() claims you wrote this driver.

#2 lore raw
Quoted 10 lines · Mark Brown
Quoted 2 lines · Hugo Villeneuve

The PCM3008 is used on the Lyrtech SFFSDR board, in conjunction with an FPGA that generates the bit clock and the master clock

Looks fairly good overall.

Quoted 1 line

Normally codec drivers and machine drivers should be submitted as separate patches, though it's not critical.

I agree. In addition, I believe the board-specific init (sound/soc/davinci/davinci-sffsdr.c) should not be under sound/*, but rather belongs in the board init code in arch/arm/mach-davinci/board*.

Kevin

Quoted 96 lines

sound/soc/codecs/Kconfig config SND_SOC_TWL4030 · line 85

Quoted 10 lines

index 5df7402..dc58ce2 100644

sound/soc/codecs/Kconfig +3 -0
@@ -80,6 +80,10 @@ config SND_SOC_TWL4030
 	tristate
 	depends on TWL4030_CORE
 
+config SND_SOC_PCM3008
+	tristate
+	depends on SFFSDR_FPGA

The codec driver shouldn't depend on the FPGA driver. Once that dependency has been removed the codec should be added to SND_SOC_ALL_CODECS.

sound/soc/codecs/Kconfig config SND_SOC_TWL4030

Quoted 12 lines
sound/soc/codecs/Kconfig +12 -0
+static int pcm3008_hw_params(struct snd_pcm_substream *substream,
+			     struct snd_pcm_hw_params *params)
+{
+	int fs;
+
+	/* Fsref can be 32000, 44100 or 48000. */
+	fs = params_rate(params);
+
+	printk(KERN_INFO "pcm3008_hw_params: rate = %d Hz\n", fs);
+
+	return sffsdr_fpga_set_codec_fs(fs);
+}

This should be being done by the machine driver rather than by the codec driver - this will allow the codec driver to be used on another machine that has some other method for generating the clocks. As far as I can see that's the only dependency on the sffsdr?

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+	/* DEM1  DEM0  DE-EMPHASIS_MODE
+	 * Low   Low   De-emphasis 44.1 kHz ON
+	 * Low   High  De-emphasis OFF
+	 * High  Low   De-emphasis 48 kHz ON
+	 * High  High  De-emphasis 32 kHz ON
+	 */

Looks like this should be exported as a control? It's not important for merging but it'd be nice.

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+static int pcm3008_soc_suspend(struct platform_device *pdev, pm_message_t msg)
+{
+	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+	struct pcm3008_setup_data *setup = socdev->codec_data;
+
+	printk(KERN_INFO "pcm3008_soc_suspend(): TODO\n");

This should be a comment, though it looks like you may actually have implemented this already?

sound/soc/codecs/Kconfig

Quoted 6 lines
sound/soc/codecs/Kconfig +6 -0
+struct pcm3008_setup_data {
+	u8 dem0_pin;
+	u8 dem1_pin;
+	u8 pdad_pin;
+	u8 pdda_pin;
+};

GPIO numbers should be unsigned to match the gpiolib API (some systems do support an awful lot of GPIOs).

Also, ideally pdad and pdad would be used to implement DAPM controls so that they can be powered down when not in use but again that's not essential for merging - so long as they're passed in someone could do that later.

sound/soc/codecs/Kconfig

Quoted 8 lines
sound/soc/codecs/Kconfig +8 -0
+config SND_DAVINCI_SOC_SFFSDR
+	tristate "SoC Audio support for SFFSDR"
+	depends on SND_DAVINCI_SOC && MACH_DAVINCI_SFFSDR
+	select SND_DAVINCI_SOC_I2S
+	select SND_SOC_PCM3008
+	help
+	  Say Y if you want to add support for SoC audio on
+	  Lyrtech SFFSDR board.

This should also select SSFDR_FPGA - select ignores dependencies so the select from the codec driver won't be picked up (though the codec driver ought not to be selecting it in the first place).

sound/soc/davinci/davinci-sffsdr.c line 5

Quoted 8 lines
sound/soc/davinci/davinci-sffsdr.c new file +5 -0
@@ -0,0 +1,145 @@
+/*
+ * ASoC driver for Lyrtech SFFSDR board.
+ *
+ * Author:      Vladimir Barinov, <[email protected]>
+ * Copyright:   (C) 2007 MontaVista Software, Inc., <[email protected]>

Are you sure? Looks like cut'n'paste - MODULE_AUTHOR() claims you wrote this driver.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw
Quoted 3 lines · Kevin Hilman

I agree. In addition, I believe the board-specific init (sound/soc/davinci/davinci-sffsdr.c) should not be under sound/*, but rather belongs in the board init code in arch/arm/mach-davinci/board*.

If you want to do that please do something like what's been done for the s3c24xx-uda134x or soc-of-simple drivers which keeps the ASoC code in sound/soc and has the per-board configuration in the platform directory.