Skip to contentSkip to conversation

ASoC: add machine driver for i.mx27_visstrim_m10 board

PATCH In review javier Martin 4 participants 5 messages Aug 4, 2009 – Aug 5, 2009

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

PATCH 3/3 ASoC: add machine driver for i.mx27_visstrim_m10 board

This adds support for i.mx27_visstrim_sm10 board machine driver which uses an i.mx27 processor plus a wm8974 codec.

It has been tested on a visstrim_sm10 board.

---
 sound/soc/imx/Kconfig          |    8 +
 sound/soc/imx/Makefile         |    4 +
 sound/soc/imx/mx27vis_wm8974.c |  317 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 329 insertions(+), 0 deletions(-)
sound/soc/imx/Kconfig +8 -0
index 886dadd..2c6f568 100644
@@ -9,5 +9,13 @@ config SND_MX1_MX2_SOC
 config SND_MXC_SOC_SSI
 	tristate
 
+config SND_SOC_MX27VIS_WM8974
+	tristate "SoC Audio support for MX27 - WM8974 Visstrim_sm10 board"
+	depends on SND_MX1_MX2_SOC && MACH_MX27 && MACH_IMX27_VISSTRIM_M10
+	select SND_MXC_SOC_SSI
+	select SND_SOC_WM8974
+	help
+	  Say Y if you want to add support for SoC audio on Visstrim SM10
+	  board with WM8974.
 
 
sound/soc/imx/Makefile +4 -0
index 6552cb2..c2ffd2c 100644
@@ -4,3 +4,7 @@ snd-soc-mxc-ssi-objs := mxc-ssi.o
 
 obj-$(CONFIG_SND_MX1_MX2_SOC) += snd-soc-mx1_mx2.o
 obj-$(CONFIG_SND_MXC_SOC_SSI) += snd-soc-mxc-ssi.o
+
+# i.MX Machine Support
+snd-soc-mx27vis-wm8974-objs := mx27vis_wm8974.o
+obj-$(CONFIG_SND_SOC_MX27VIS_WM8974) += snd-soc-mx27vis-wm8974.o
sound/soc/imx/mx27vis_wm8974.c new file +317 -0

317 lines not on this page · raw message

---

Signature · 8 lines
Javier Martin
Vista Silicon S.L.
Universidad de Cantabria
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
#1 lore raw

Controling wave amplitude using alsa api !! (pcm interface ???????)

Hi all!

Mates, I am following the example PCM.C that I found at alsa web site. its a sine wave generator.
I am looking for a control that alsa provides to control the amplitude of the wave.

As I could found so for, there is just frequency control... I didn't find any amplitude control.

* I don't want to control the volume using alsamixer or even my sound... I want to generate a wave with predefined amplitude.

Does anyone could give me a little help??

Thanks a lot!

#2 lore raw

Re: Controling wave amplitude using alsa api !! (pcm interface ???????)

Quoted 9 lines · Guilherme Longo

Hi all!

Mates, I am following the example PCM.C that I found at alsa web site. its a sine wave generator.
I am looking for a control that alsa provides to control the amplitude of the wave.

As I could found so for, there is just frequency control... I didn't find any amplitude control.

This line int pcm.c is not amplitude control?

unsigned int maxval = (1 << (snd_pcm_format_width(format) - 1)) - 1;

it's an int, so you probably need to alter this a bit to allow you to have arbitrary control over the amplitude (ie: multiply by a float less than 1.0)

HTH

johnu

Quoted 12 lines

* I don't want to control the volume using alsamixer or even my sound... I want to generate a wave with predefined amplitude.

Does anyone could give me a little help??

Thanks a lot!

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw

Re: Controling wave amplitude using alsa api !! (pcm interface ???????)

In reply to Guilherme Longo

Hi again.

I've got half of my work done with it. I found the values of the samples been analyzed, **BUT* *it is given in a strange unity!

while (count-- > 0) {
                 res = sin(phase) * 15000;
                 ires.i = res;
                 tmp = ires.c;
               * printf("som -> %g\n", res);  // Here I get the values*
                 for (chn = 0; chn < channels; chn++) {
                        for (byte = 0; byte < (unsigned int)bps; byte++)
                                 *(samples[chn] + byte) = tmp[1];
                                  samples[chn] += steps[chn];
                 }

Now, how can I transform this samples in a more human understandable notation as in Db unity for example?
Is there any alsa api function to control it? Should I use the mixer interface somehow?

This is the output:

som -> 11976.3
som -> 11387
som -> 10752.9
som -> 10076.6
som -> 9360.7
som -> 8608.02
som -> 7821.53
som -> 7004.31
som -> 6159.56
som -> 5290.63
som -> 4400.9
som -> 3493.89
som -> 2573.15
som -> 1642.3
som -> 704.996
som -> -235.076
som -> -1174.22
som -> -2108.76
som -> -3035.01
som -> -3949.33
som -> -4848.14
som -> -5727.91

Thanks!

Quoted 18 lines · Guilherme Longo

Hi all!

Mates, I am following the example PCM.C that I found at alsa web site. its a sine wave generator.
I am looking for a control that alsa provides to control the amplitude of the wave.

As I could found so for, there is just frequency control... I didn't find any amplitude control.

* I don't want to control the volume using alsamixer or even my sound... I want to generate a wave with predefined amplitude.

Does anyone could give me a little help??

Thanks a lot!

#4 lore raw
In reply to javier Martin
Quoted 6 lines · javier Martin

This adds support for i.mx27_visstrim_sm10 board machine driver which uses an i.mx27 processor plus a wm8974 codec.

It has been tested on a visstrim_sm10 board.

Again, this all looks good with some relatively small nits.

sound/soc/imx/mx27vis_wm8974.c line 43

Quoted 8 lines
sound/soc/imx/mx27vis_wm8974.c new file +8 -0
+/**
+  * This function connects SSI1 (HPCR1) as slave to
+  * SSI1 external signals (PPCR1)
+  * As slave, HPCR1 must set TFSDIR and TCLKDIR as inputs from
+  * port 4
+  */
+void audmux_connect_1_4(void)
+{

Obviously this ought to get pulled out, either into an arch AUXMUX thing or a separate file in here. However, neither of those things exist right now. I'll just go prod the last AUXMUX thread on linux-arm-kernel.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	return;
+}

No need for the return; here.

sound/soc/imx/mx27vis_wm8974.c line 80

Quoted 6 lines
sound/soc/imx/mx27vis_wm8974.c new file +6 -0
+	/*
+	 * The WM8974 is better at generating accurate audio clocks than the
+	 * MX27 SSI controller, so we will use it as master when we can.
+	 */
+	switch (params_rate(params)) {
+	case 8000:

Unless I'm missing something the "when we can" is "in all cases" :)

sound/soc/imx/mx27vis_wm8974.c line 129

Quoted 8 lines
sound/soc/imx/mx27vis_wm8974.c new file +8 -0
+	/* set codec DAI configuration */
+	ret = codec_dai->ops->set_fmt(codec_dai,
+		SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
+		SND_SOC_DAIFMT_SYNC | fmt);
+	if (ret < 0) {
+		printk(KERN_ERR "Error from codec DAI configuration\n");
+		return ret;
+	}

Printing the value of ret would be nice.

sound/soc/imx/mx27vis_wm8974.c line 141

Quoted 2 lines
sound/soc/imx/mx27vis_wm8974.c new file +2 -0
+	/* Put DC field of STCCR to 1 (not zero) */
+	ret = cpu_dai->ops->set_tdm_slot(cpu_dai, 0, 2);

Rats, you are using the TDM slot configuration. Oh well. Should check this error.

sound/soc/imx/mx27vis_wm8974.c line 203

Quoted 9 lines
sound/soc/imx/mx27vis_wm8974.c new file +9 -0
+static int mx27vis_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	return 0;
+}
+
+static int mx27vis_resume(struct platform_device *pdev)
+{
+	return 0;
+}

These can be omitted if empty.

Quoted 8 lines
sound/soc/imx/mx27vis_wm8974.c new file +8 -0
+	unsigned int ssi1_pins[] = {
+		PC20_PF_SSI1_FS,
+		PC21_PF_SSI1_RXD,
+		PC22_PF_SSI1_TXD,
+		PC23_PF_SSI1_CLK,
+	};
+	unsigned int ssi2_pins[] = {
+		PC24_PF_SSI2_FS,

sound/soc/imx/mx27vis_wm8974.c line 276

Quoted 10 lines
sound/soc/imx/mx27vis_wm8974.c new file +10 -0
+		PC25_PF_SSI2_RXD,
+		PC26_PF_SSI2_TXD,
+		PC27_PF_SSI2_CLK,
+	};
+	if (ssi_num == 0)
+		ret = mxc_gpio_setup_multiple_pins(ssi1_pins,
+				ARRAY_SIZE(ssi1_pins), "USB OTG");
+	else
+		ret = mxc_gpio_setup_multiple_pins(ssi2_pins,
+				ARRAY_SIZE(ssi2_pins), "USB OTG");

This would normally be done under arch/arm in the board setup code.