Skip to contentSkip to conversation

ASoC: omap-mcbsp: Sidetone related changes

PATCH Superseded Peter Ujfalusi 1 participant 5 messages Aug 21, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: omap-mcbsp: Sidetone related changes

Hello,

When we boot with DT blob the sidetone is not supported at the moment. Prepare the McBSP code for the time when we are going to be able to support ST with DT booted kernel.
Meanwhile do not block the audio card if the st_data is missing from the port, but print a warning about it. This will allow us to debug the DT booted kernels with audio.

Mark: This series as such does not depend on the McBSP DT support, but it can be attached to that branch.

Regards,
Peter
---
Peter Ujfalusi (3):
ASoC: omap-mcbsp: Check mcbsp->id instead of cpu_dai->id when adding
ST controls
ASoC: omap-mcbsp: Only print warning if the st_data is missing for
the port
ASoC: omap-mcbsp: Use macro to create the McBSP2/3 ST controls

 sound/soc/omap/omap-mcbsp.c |   47 ++++++++++++++++++------------------------
 1 files changed, 20 insertions(+), 27 deletions(-)
Signature · 1 line
1.7.8.6
#1 lore raw

PATCH 1/3 ASoC: omap-mcbsp: Check mcbsp->id instead of cpu_dai->id when adding ST controls

In ddevice tree booted kernel all device have unique name and their device id is set to 0.
Use the mcbsp->id for checking to decide which control set we should add for McBSP sidetone handling.

---
 sound/soc/omap/omap-mcbsp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/omap/omap-mcbsp.c +1 -1
index d6de066..84a3132 100644
@@ -722,7 +722,7 @@ int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd)
 	if (!mcbsp->st_data)
 		return -ENODEV;
 
-	switch (cpu_dai->id) {
+	switch (mcbsp->id) {
 	case 2: /* McBSP 2 */
 		return snd_soc_add_dai_controls(cpu_dai,
 					omap_mcbsp2_st_controls,
Signature · 1 line
1.7.8.6
#2 lore raw

PATCH 2/3 ASoC: omap-mcbsp: Only print warning if the st_data is missing for the port

In reply to Peter Ujfalusi

When asked to add the ST controls warn only if the st_data is missing. In this way we do not block the otherwise functional card to probe.

---
 sound/soc/omap/omap-mcbsp.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
sound/soc/omap/omap-mcbsp.c +4 -2
index 84a3132..c964f68 100644
@@ -719,8 +719,10 @@ int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd)
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct omap_mcbsp *mcbsp = snd_soc_dai_get_drvdata(cpu_dai);
 
-	if (!mcbsp->st_data)
-		return -ENODEV;
+	if (!mcbsp->st_data) {
+		dev_warn(mcbsp->dev, "No sidetone data for port\n");
+		return 0;
+	}
 
 	switch (mcbsp->id) {
 	case 2: /* McBSP 2 */
Signature · 1 line
1.7.8.6
#3 lore raw

PATCH 3/3 ASoC: omap-mcbsp: Use macro to create the McBSP2/3 ST controls

In reply to Peter Ujfalusi

To remove duplicated code from the driver.

---
 sound/soc/omap/omap-mcbsp.c |   39 +++++++++++++++------------------------
 1 files changed, 15 insertions(+), 24 deletions(-)
sound/soc/omap/omap-mcbsp.c +15 -24
index c964f68..be52f26 100644
@@ -688,31 +688,22 @@ static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 
-static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
-	SOC_SINGLE_EXT("McBSP2 Sidetone Switch", 1, 0, 1, 0,
-			omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 0 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch0_volume,
-				      omap_mcbsp_set_st_ch0_volume),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch1_volume,
-				      omap_mcbsp_set_st_ch1_volume),
-};
+#define OMAP_MCBSP_ST_CONTROLS(port) \
+static const struct snd_kcontrol_new omap_mcbsp##port##_st_controls[] = { \
+SOC_SINGLE_EXT("McBSP##port## Sidetone Switch", 1, 0, 1, 0,		  \
+	       omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),		  \
+OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP##port## Sidetone Channel 0 Volume",  \
+			      -32768, 32767,				  \
+			      omap_mcbsp_get_st_ch0_volume,		  \
+			      omap_mcbsp_set_st_ch0_volume),		  \
+OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP##port## Sidetone Channel 1 Volume",  \
+			      -32768, 32767,				  \
+			      omap_mcbsp_get_st_ch1_volume,		  \
+			      omap_mcbsp_set_st_ch1_volume),		  \
+}
 
-static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = {
-	SOC_SINGLE_EXT("McBSP3 Sidetone Switch", 2, 0, 1, 0,
-			omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch0_volume,
-				      omap_mcbsp_set_st_ch0_volume),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch1_volume,
-				      omap_mcbsp_set_st_ch1_volume),
-};
+OMAP_MCBSP_ST_CONTROLS(2);
+OMAP_MCBSP_ST_CONTROLS(3);
 
 int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd)
 {
Signature · 1 line
1.7.8.6
#4 lore raw

Re: [PATCH 3/3] ASoC: omap-mcbsp: Use macro to create the McBSP2/3 ST controls

Hi,

Quoted 30 lines · Peter Ujfalusi

To remove duplicated code from the driver.

---
 sound/soc/omap/omap-mcbsp.c |   39 +++++++++++++++------------------------
 1 files changed, 15 insertions(+), 24 deletions(-)
sound/soc/omap/omap-mcbsp.c +3 -12
index c964f68..be52f26 100644
@@ -688,31 +688,22 @@ static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
 	return 0;
 }
 
-static const struct snd_kcontrol_new omap_mcbsp2_st_controls[] = {
-	SOC_SINGLE_EXT("McBSP2 Sidetone Switch", 1, 0, 1, 0,
-			omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 0 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch0_volume,
-				      omap_mcbsp_set_st_ch0_volume),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch1_volume,
-				      omap_mcbsp_set_st_ch1_volume),
-};
+#define OMAP_MCBSP_ST_CONTROLS(port) \
+static const struct snd_kcontrol_new omap_mcbsp##port##_st_controls[] = { \
+SOC_SINGLE_EXT("McBSP##port## Sidetone Switch", 1, 0, 1, 0,		  \

sound/soc/omap/omap-mcbsp.c static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol, · line 703

Quoted 10 lines
sound/soc/omap/omap-mcbsp.c +10 -0
+	       omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),		  \
+OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP##port## Sidetone Channel 0 Volume",  \
+			      -32768, 32767,				  \
+			      omap_mcbsp_get_st_ch0_volume,		  \
+			      omap_mcbsp_set_st_ch0_volume),		  \
+OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP##port## Sidetone Channel 1 Volume",  \
+			      -32768, 32767,				  \
+			      omap_mcbsp_get_st_ch1_volume,		  \
+			      omap_mcbsp_set_st_ch1_volume),		  \
+}

This macro does not work correctly, I get this:
amixer | grep McBSP
Simple mixer control 'McBSP##port## Sidetone',0 Simple mixer control 'McBSP##port## Sidetone Channel 0',0 Simple mixer control 'McBSP##port## Sidetone Channel 1',0

as control names...

Please ignore this patch, I'll fix it or drop this.

Quoted 19 lines
sound/soc/omap/omap-mcbsp.c +2 -12
-static const struct snd_kcontrol_new omap_mcbsp3_st_controls[] = {
-	SOC_SINGLE_EXT("McBSP3 Sidetone Switch", 2, 0, 1, 0,
-			omap_mcbsp_st_get_mode, omap_mcbsp_st_put_mode),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch0_volume,
-				      omap_mcbsp_set_st_ch0_volume),
-	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume",
-				      -32768, 32767,
-				      omap_mcbsp_get_st_ch1_volume,
-				      omap_mcbsp_set_st_ch1_volume),
-};
+OMAP_MCBSP_ST_CONTROLS(2);
+OMAP_MCBSP_ST_CONTROLS(3);
 
 int omap_mcbsp_st_add_controls(struct snd_soc_pcm_runtime *rtd)
 {
 
Signature · 1 line
Péter