ASoC: Tegra machine ASoC driver for boards using ALC5332 codec
Subsystems (3)
PATCH v2 1/1 ASoC: Tegra machine ASoC driver for boards using ALC5332 codec
At this stage only Toshiba AC100/Dynabook supported.
--
Changes since v1:
* Use module_platform_driver.
* Move controls, dapm_widgets and dapm_routes to snd_soc_card structure.
* Set dai_fmt in snd_soc_dai_link structure instead probe function.
* Remove check board in probe function
* Fix warning about unused codec_dai.
* Use devm_kzalloc to manage memory allocation.
--- sound/soc/tegra/Kconfig | 9 ++ sound/soc/tegra/Makefile | 2 + sound/soc/tegra/tegra_alc5632.c | 233 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 244 insertions(+), 0 deletions(-) create mode 100644 sound/soc/tegra/tegra_alc5632.c
sound/soc/tegra/Kconfig +9 -0
@@ -47,3 +47,12 @@ config SND_SOC_TEGRA_TRIMSLICE help Say Y or M here if you want to add support for SoC audio on the TrimSlice platform. + +config SND_SOC_TEGRA_ALC5632 + tristate "SoC Audio support for Tegra boards using an ALC5632 codec" + depends on SND_SOC_TEGRA && I2C + select SND_SOC_TEGRA_I2S + select SND_SOC_ALC5632 + help + Say Y or M here if you want to add support for SoC audio on the + Toshiba AC100 netbook.
sound/soc/tegra/Makefile +2 -0
@@ -14,6 +14,8 @@ obj-$(CONFIG_SND_SOC_TEGRA_SPDIF) += snd-soc-tegra-spdif.o # Tegra machine Support snd-soc-tegra-wm8903-objs := tegra_wm8903.o snd-soc-tegra-trimslice-objs := trimslice.o +snd-soc-tegra-alc5632-objs := tegra_alc5632.o obj-$(CONFIG_SND_SOC_TEGRA_WM8903) += snd-soc-tegra-wm8903.o obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += snd-soc-tegra-trimslice.o +obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
sound/soc/tegra/tegra_alc5632.c new file +233 -0
233 lines not on this page · raw message
Signature · 1 line
1.7.3.4
Leon Romanovsky wrote at Monday, December 12, 2011 12:46 PM:
Quoted 4 lines
At this stage only Toshiba AC100/Dynabook supported.
sound/soc/tegra/tegra_alc5632.c new file +2
-0+static int tegra_alc5632_asoc_hw_params (struct snd_pcm_substream *substream, +struct snd_pcm_hw_params *params)
...
Quoted 4 lines
sound/soc/tegra/tegra_alc5632.c new file +4
-0+ srate =params_rate (params); +switch (srate) { +case 64000 : +case 88200 :
sound/soc/tegra/tegra_alc5632.c line 65
Quoted 10 lines
sound/soc/tegra/tegra_alc5632.c new file +10
-0+case 96000 : + mclk =128 * srate; +break ; +default : + mclk =512 * srate; +break ; + } +/* FIXME: Codec only requires >= 3MHz if OSR==0 */ +while (mclk <6000000 ) + mclk *=2 ;
I think you should replace all that with:
mclk = 512 * srate;
The reason being:
* The codec only supports up to 48KHz as far as I can tell, thus making the special-case in the switch statement never fire, and irrelevant.
* The codec wants 512Fs, not min(6MHz, 512Fs) as far as I can tell, so the extra while loop at the end is going to set the wrong rate for 8KHz and 11.025KHz.
Quoted 5 lines
sound/soc/tegra/tegra_alc5632.c new file +5
-0+static struct snd_soc_jack_gpio tegra_alc5632_hs_jack_gpio = { + .name ="Headset Detect" , + .report =SND_JACK_HEADSET , + .debounce_time =150 , +};
...
Quoted 2 lines
(quoted diff) +2
-0+static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) +{
...
sound/soc/tegra/tegra_alc5632.c line 141
Quoted 2 lines
sound/soc/tegra/tegra_alc5632.c new file +2
-0+snd_soc_jack_add_gpios (&tegra_alc5632_hs_jack, +1 , &tegra_alc5632_hs_jack_gpio);
Since tegra_alc5632_hs_jack_gpio is never set, doesn't this end up using GPIO 0 as the headset detect, which most likely is something completely unrelated to audio.
Other than those two things, this looks fine to me.
Signature · 1 line
nvpublic
Quoted 25 lines · Stephen Warren
Leon Romanovsky wrote at Monday, December 12, 2011 12:46 PM:
Quoted 4 lines
At this stage only Toshiba AC100/Dynabook supported.
+static int tegra_alc5632_asoc_hw_params(struct
snd_pcm_substream*substream,
+ structsnd_pcm_hw_params*params)...
Quoted 6 lines
+ srate =
params_rate(params);
+ switch (srate) {
+ case 64000:
+ case 88200:
+ case 96000:
+ mclk = 128 * srate;Quoted 8 lines
+ break;
+ default:
+ mclk = 512 * srate;
+ break;
+ }
+ /* FIXME: Codec only requires >= 3MHz if OSR==0 */
+ while (mclk < 6000000)
+ mclk *= 2;I think you should replace all that with:
mclk = 512 * srate;
Quoted 8 lines
The reason being:
* The codec only supports up to 48KHz as far as I can tell, thus making the special-case in the switch statement never fire, and irrelevant.
* The codec wants 512Fs, not
min(6MHz, 512Fs)as far as I can tell, so the extra while loop at the end is going to set the wrong rate for 8KHz and 11.025KHz.
You are right, I'll check it at the spec.
Quoted 9 lines
Quoted 5 lines
sound/soc/tegra/tegra_alc5632.c new file +5
-0+static struct snd_soc_jack_gpio tegra_alc5632_hs_jack_gpio = { + .name = "Headset Detect", + .report = SND_JACK_HEADSET, + .debounce_time = 150, +};...
Quoted 2 lines
(quoted diff) +2
-0+static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) +{...
Quoted 6 lines
Quoted 2 lines
+ snd_soc_jack_add_gpios(&tegra_alc5632_hs_jack,
+ 1,&tegra_alc5632_hs_jack_gpio);Since
tegra_alc5632_hs_jack_gpiois never set, doesn't this end up using GPIO 0 as the headset detect, which most likely is something completely unrelated to audio.
This is initial support of board file, at the coming patch set, I'll update board-paz00-pinmux.c [1] with audio related pins and I'll add platform device support.
I think It is easy for review in this way.
Quoted 6 lines
Other than those two things, this looks fine to me.
--
nvpublic
Signature · 6 lines
Leon Romanovsky | Independent Linux Consultant www.leon.nu | [email protected] _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Leon Romanovsky wrote at Monday, December 12, 2011 11:36 PM:
Quoted 3 lines · Stephen Warren
Quoted 2 lines
Leon Romanovsky wrote at Monday, December 12, 2011 12:46 PM:
Quoted 1 line
At this stage only Toshiba AC100/Dynabook supported.
...
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines
sound/soc/tegra/tegra_alc5632.c new file +5
-0+static struct snd_soc_jack_gpio tegra_alc5632_hs_jack_gpio = { + .name = "Headset Detect", + .report = SND_JACK_HEADSET, + .debounce_time = 150, +};...
Quoted 2 lines
(quoted diff) +2
-0+static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) +{...
Quoted 2 lines
+ snd_soc_jack_add_gpios(&tegra_alc5632_hs_jack,
+ 1,&tegra_alc5632_hs_jack_gpio);
Quoted 8 lines
Quoted 3 lines
Since
tegra_alc5632_hs_jack_gpiois never set, doesn't this end up using GPIO 0 as the headset detect, which most likely is something completely unrelated to audio.This is initial support of board file, at the coming patch set, I'll update
board-paz00-pinmux.c[1] with audio related pins and I'll add platform device support.
I think It is easy for review in this way.
I'm fine adding the feature later. But, I think you shouldn't call snd_soc_jack_add_gpios() until the platform data is there, or you'll end up enabling the feature already, but using the wrong GPIO.
Signature · 6 lines
nvpublic _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 22 lines · Stephen Warren
Leon Romanovsky wrote at Monday, December 12, 2011 11:36 PM:
Quoted 3 lines · Stephen Warren
Quoted 2 lines
Leon Romanovsky wrote at Monday, December 12, 2011 12:46 PM:
Quoted 1 line
At this stage only Toshiba AC100/Dynabook supported.
...
Quoted 16 lines
Quoted 15 lines
Quoted 5 lines
sound/soc/tegra/tegra_alc5632.c new file +5
-0+static struct snd_soc_jack_gpio tegra_alc5632_hs_jack_gpio = { + .name = "Headset Detect", + .report = SND_JACK_HEADSET, + .debounce_time = 150, +};...
Quoted 2 lines
(quoted diff) +2
-0+static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) +{...
Quoted 2 lines
+ snd_soc_jack_add_gpios(&tegra_alc5632_hs_jack,
+ 1,&tegra_alc5632_hs_jack_gpio);Since
tegra_alc5632_hs_jack_gpiois never set, doesn't this end up using GPIO 0 as the headset detect, which most likely is something completely unrelated to audio.
Quoted 8 lines
Quoted 4 lines
This is initial support of board file, at the coming patch set, I'll update
board-paz00-pinmux.c[1] with audio related pins and I'll add platform device support.
I think It is easy for review in this way.I'm fine adding the feature later. But, I think you shouldn't call
snd_soc_jack_add_gpios()until the platform data is there, or you'll end up enabling the feature already, but using the wrong GPIO.
Does it matter ? Anyway, this file is useless without proper audio support, and currently only paz00 will be using this file.
--
Leon Romanovsky | Independent Linux Consultant
www.leon.nu | [email protected]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Leon Romanovsky wrote at Tuesday, December 13, 2011 11:27 AM:
Quoted 28 lines · Stephen Warren
Quoted 27 lines
Leon Romanovsky wrote at Monday, December 12, 2011 11:36 PM:
Quoted 3 lines · Stephen Warren
Quoted 2 lines
Leon Romanovsky wrote at Monday, December 12, 2011 12:46 PM:
Quoted 1 line
At this stage only Toshiba AC100/Dynabook supported.
...
Quoted 20 lines
Quoted 9 lines
Quoted 5 lines
sound/soc/tegra/tegra_alc5632.c new file +5
-0+static struct snd_soc_jack_gpio tegra_alc5632_hs_jack_gpio = { + .name = "Headset Detect", + .report = SND_JACK_HEADSET, + .debounce_time = 150, +};...
Quoted 2 lines
(quoted diff) +2
-0+static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) +{...
Quoted 6 lines
Quoted 2 lines
+ snd_soc_jack_add_gpios(&tegra_alc5632_hs_jack,
+ 1,&tegra_alc5632_hs_jack_gpio);Since
tegra_alc5632_hs_jack_gpiois never set, doesn't this end up using GPIO 0 as the headset detect, which most likely is something completely unrelated to audio.This is initial support of board file, at the coming patch set, I'll update
board-paz00-pinmux.c[1] with audio related pins and I'll add platform device support.
I think It is easy for review in this way.
Quoted 6 lines
Quoted 3 lines
I'm fine adding the feature later. But, I think you shouldn't call
snd_soc_jack_add_gpios()until the platform data is there, or you'll end up enabling the feature already, but using the wrong GPIO.Does it matter ? Anyway, this file is useless without proper audio support, and currently only paz00 will be using this file.
Yes, I think so.
The issue is that by calling snd_soc_jack_add_gpios(), ASoC will internally call gpio_request() and request_any_context_irq() for GPIO 0, which:
a) Will prevent it from being used as a GPIO by any other code.
b) Will configure the GPIO HW to make this pin an input, such that if the pin is enabled as a GPIO, might stop Tegra driving the pin if it was previously configured as an output.
c) If the GPIO is attached to some random piece of HW that toggles the line, this could cause an interrupt storm, or at least bogus jack detect events.
Just removing that one call and the unused GPIO structure would solve all this; it can easily be added back when adding the platform data support.
Signature · 6 lines
nvpublic _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 47 lines · Stephen Warren
Leon Romanovsky wrote at Tuesday, December 13, 2011 11:27 AM:
Quoted 28 lines · Stephen Warren
Quoted 27 lines
Leon Romanovsky wrote at Monday, December 12, 2011 11:36 PM:
Quoted 3 lines · Stephen Warren
Quoted 2 lines
Leon Romanovsky wrote at Monday, December 12, 2011 12:46 PM:
Quoted 1 line
At this stage only Toshiba AC100/Dynabook supported.
...
Quoted 20 lines
Quoted 9 lines
Quoted 5 lines
sound/soc/tegra/tegra_alc5632.c new file +5
-0+static struct snd_soc_jack_gpio tegra_alc5632_hs_jack_gpio = { + .name = "Headset Detect", + .report = SND_JACK_HEADSET, + .debounce_time = 150, +};...
Quoted 2 lines
(quoted diff) +2
-0+static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) +{...
Quoted 6 lines
Quoted 2 lines
+ snd_soc_jack_add_gpios(&tegra_alc5632_hs_jack,
+ 1,&tegra_alc5632_hs_jack_gpio);Since
tegra_alc5632_hs_jack_gpiois never set, doesn't this end up using GPIO 0 as the headset detect, which most likely is something completely unrelated to audio.This is initial support of board file, at the coming patch set, I'll update
board-paz00-pinmux.c[1] with audio related pins and I'll add platform device support.
I think It is easy for review in this way.Quoted 6 lines
Quoted 3 lines
I'm fine adding the feature later. But, I think you shouldn't call
snd_soc_jack_add_gpios()until the platform data is there, or you'll end up enabling the feature already, but using the wrong GPIO.Does it matter ? Anyway, this file is useless without proper audio support, and currently only paz00 will be using this file.
Yes, I think so.
The issue is that by calling
snd_soc_jack_add_gpios(), ASoC will internally callgpio_request()andrequest_any_context_irq()for GPIO 0, which:a) Will prevent it from being used as a GPIO by any other code.
b) Will configure the GPIO HW to make this pin an input, such that if the pin is enabled as a GPIO, might stop Tegra driving the pin if it was previously configured as an output.
Quoted 7 lines
c) If the GPIO is attached to some random piece of HW that toggles the line, this could cause an interrupt storm, or at least bogus jack detect events.
Just removing that one call and the unused GPIO structure would solve all this; it can easily be added back when adding the platform data support.
Thanks for explanation, I'll try to resend the patch till the weekends.
Quoted 8 lines
--
nvpublic_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Signature · 6 lines
Leon Romanovsky | Independent Linux Consultant www.leon.nu | [email protected] _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel