Skip to contentSkip to conversation

McBSP: OMAP3: Add sidetone feature

PATCH Superseded Ilkka Koskinen 5 participants 16 messages Feb 18, 2010 – Feb 22, 2010

Subsystems (5)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover McBSP: OMAP3: Add sidetone feature

The first patch implements McBSP sidetone feature on OMAP3 while the second one provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel mailing list in October 2009. Channel gain control and enabling the sidetone have been moved to ALSA interface as suggested in comments.

These patches apply on top of Janusz Krzysztofik's McBSP register cache patches in linux-omap-2.6.git

Since the version 3, the buggy channel gain control has been fixed. ASoC part have been simplified resulting in removing a couple unnecessary functions. Added a comment to ASoC part explaining McBSP port number vs. index values used in OMAP McBSP implementation.

Eero Nurkkala (1):
McBSP: OMAP3: Add sidetone feature

Ilkka Koskinen (1):
ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

 arch/arm/mach-omap2/mcbsp.c             |    2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   60 +++++
 arch/arm/plat-omap/mcbsp.c              |  402 ++++++++++++++++++++++++++++++-
 sound/soc/omap/omap-mcbsp.c             |  138 +++++++++++
 sound/soc/omap/omap-mcbsp.h             |    2 +
 5 files changed, 603 insertions(+), 1 deletions(-)
#1 lore raw

PATCH v4 1/2 McBSP: OMAP3: Add sidetone feature

From: Eero Nurkkala <[email protected]>

Add sidetone feature to McBSP instances 2 and 3 on OMAP3 based devices.

---
 arch/arm/mach-omap2/mcbsp.c             |    2 +
 arch/arm/plat-omap/include/plat/mcbsp.h |   60 +++++
 arch/arm/plat-omap/mcbsp.c              |  402 ++++++++++++++++++++++++++++++-
 3 files changed, 463 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/mcbsp.c +2 -0
index d601f94..be8fce3 100644
@@ -136,6 +136,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
 	},
 	{
 		.phys_base	= OMAP34XX_MCBSP2_BASE,
+		.phys_base_st	= OMAP34XX_MCBSP2_ST_BASE,
 		.dma_rx_sync	= OMAP24XX_DMA_MCBSP2_RX,
 		.dma_tx_sync	= OMAP24XX_DMA_MCBSP2_TX,
 		.rx_irq		= INT_24XX_MCBSP2_IRQ_RX,
@@ -145,6 +146,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = {
 	},
 	{
 		.phys_base	= OMAP34XX_MCBSP3_BASE,
+		.phys_base_st	= OMAP34XX_MCBSP3_ST_BASE,
 		.dma_rx_sync	= OMAP24XX_DMA_MCBSP3_RX,
 		.dma_tx_sync	= OMAP24XX_DMA_MCBSP3_TX,
 		.rx_irq		= INT_24XX_MCBSP3_IRQ_RX,
arch/arm/plat-omap/include/plat/mcbsp.h +60 -0

98 lines not on this page · raw message

arch/arm/plat-omap/mcbsp.c +401 -1

469 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#2 lore raw

PATCH v4 2/2 ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

Add ASoC interface for OMAP McBSP2 and McBSP3 sidetones.

---
 sound/soc/omap/omap-mcbsp.c |  138 +++++++++++++++++++++++++++++++++++++++++++
 sound/soc/omap/omap-mcbsp.h |    2 +
 2 files changed, 140 insertions(+), 0 deletions(-)
sound/soc/omap/omap-mcbsp.c +138 -0
index c0039b3..503c58d 100644
@@ -39,6 +39,14 @@
 
 #define OMAP_MCBSP_RATES	(SNDRV_PCM_RATE_8000_96000)
 
+#define OMAP_MCBSP_SOC_SINGLE_S16_EXT(xname, xmin, xmax, \
+	xhandler_get, xhandler_put) \
+{	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
+	.info = omap_mcbsp_st_info_volsw, \
+	.get = xhandler_get, .put = xhandler_put, \
+	.private_value = (unsigned long) &(struct soc_mixer_control) \
+	{.min = xmin, .max = xmax} }
+
 struct omap_mcbsp_data {
 	unsigned int			bus_id;
 	struct omap_mcbsp_reg_cfg	regs;
@@ -637,6 +645,136 @@ struct snd_soc_dai omap_mcbsp_dai[] = {
 
 EXPORT_SYMBOL_GPL(omap_mcbsp_dai);
 
+int omap_mcbsp_st_info_volsw(struct snd_kcontrol *kcontrol,
+			struct snd_ctl_elem_info *uinfo)
+{
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+	int max = mc->max;
+	int min = mc->min;
+
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+	uinfo->count = 1;
+	uinfo->value.integer.min = min;
+	uinfo->value.integer.max = max;
+	return 0;
+}
+
+#define OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(id, channel)			\
+static int								\
+omap_mcbsp##id##_set_st_ch##channel##_volume(struct snd_kcontrol *kc,	\
+					struct snd_ctl_elem_value *uc)	\
+{									\
+	struct soc_mixer_control *mc =					\
+		(struct soc_mixer_control *)kc->private_value;		\
+	int max = mc->max;						\
+	int min = mc->min;						\
+	int val = uc->value.integer.value[0];				\
+									\
+	if (val < min || val > max)					\
+		return -EINVAL;						\
+									\
+	/* OMAP McBSP implementation uses index values 0..4 */		\
+	return omap_st_set_chgain((id)-1, channel, val);		\
+}
+
+#define OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(id, channel)			\
+static int								\
+omap_mcbsp##id##_get_st_ch##channel##_volume(struct snd_kcontrol *kc,	\
+					struct snd_ctl_elem_value *uc)	\
+{									\
+	s16 chgain;							\
+									\
+	if (omap_st_get_chgain((id)-1, channel, &chgain))		\
+		return -EAGAIN;						\
+									\
+	uc->value.integer.value[0] = chgain;				\
+	return 0;							\
+}
+
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_SET_CHANNEL_VOLUME(3, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(2, 1)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 0)
+OMAP_MCBSP_ST_GET_CHANNEL_VOLUME(3, 1)
+
+static int omap_mcbsp_st_put_mode(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+	u8 value = ucontrol->value.integer.value[0];
+
+	if (value == omap_st_is_enabled(mc->reg))
+		return 0;
+
+	if (value)
+		omap_st_enable(mc->reg);
+	else
+		omap_st_disable(mc->reg);
+
+	return 1;
+}
+
+static int omap_mcbsp_st_get_mode(struct snd_kcontrol *kcontrol,
+				struct snd_ctl_elem_value *ucontrol)
+{
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+
+	ucontrol->value.integer.value[0] = omap_st_is_enabled(mc->reg);
+	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_mcbsp2_get_st_ch0_volume,
+				      omap_mcbsp2_set_st_ch0_volume),
+	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume",
+				      -32768, 32767,
+				      omap_mcbsp2_get_st_ch1_volume,
+				      omap_mcbsp2_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_mcbsp3_get_st_ch0_volume,
+				      omap_mcbsp3_set_st_ch0_volume),
+	OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume",
+				      -32768, 32767,
+				      omap_mcbsp3_get_st_ch1_volume,
+				      omap_mcbsp3_set_st_ch1_volume),
+};
+
+int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id)
+{
+	if (!cpu_is_omap34xx())
+		return -ENODEV;
+
+	switch (mcbsp_id) {
+	case 2: /* McBSP 2 */
+		return snd_soc_add_controls(codec, omap_mcbsp2_st_controls,
+					ARRAY_SIZE(omap_mcbsp2_st_controls));
+	case 3: /* McBSP 3 */
+		return snd_soc_add_controls(codec, omap_mcbsp3_st_controls,
+					ARRAY_SIZE(omap_mcbsp3_st_controls));
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(omap_mcbsp_st_add_controls);
+
 static int __init snd_omap_mcbsp_init(void)
 {
 	return snd_soc_register_dais(omap_mcbsp_dai,
sound/soc/omap/omap-mcbsp.h +2 -0
index 1968d03..6c363e5 100644
@@ -57,4 +57,6 @@ enum omap_mcbsp_div {
 
 extern struct snd_soc_dai omap_mcbsp_dai[NUM_LINKS];
 
+int omap_mcbsp_st_add_controls(struct snd_soc_codec *codec, int mcbsp_id);
+
 #endif
Signature · 1 line
1.6.0.4
#3 lore raw

RE: [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

Quoted 18 lines
sound/soc/omap/omap-mcbsp.c +17 -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_mcbsp2_get_st_ch0_volume,
+                                     omap_mcbsp2_set_st_ch0_volume),
+       OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume",
+                                     -32768, 32767,
+                                     omap_mcbsp2_get_st_ch1_volume,
+                                     omap_mcbsp2_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),

sound/soc/omap/omap-mcbsp.c struct snd_soc_dai omap_mcbsp_dai[] = { · line 757

Quoted 10 lines
sound/soc/omap/omap-mcbsp.c +10 -0
+       OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume",
+                                     -32768, 32767,
+                                     omap_mcbsp3_get_st_ch0_volume,
+                                     omap_mcbsp3_set_st_ch0_volume),
+       OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume",
+                                     -32768, 32767,
+                                     omap_mcbsp3_get_st_ch1_volume,
+                                     omap_mcbsp3_set_st_ch1_volume),
+};
+

Just a short note,
"Gain values are in the interval (-2..2) in Q1.14 format, negative values are expressed in 2's complement."

So, from:
http://en.wikipedia.org/wiki/Q_(number_format)

"
The notation used is Qm.n, where:

* Q designates that the number is in Q format notation — the Texas Instruments representation for signed fixed-point numbers.
* m (optional; default=0) is the number of bits used to designate the two's complement integer portion of the number, exclusive of the sign bit.
* n is the number of bits used to designate the two's complement fractional portion of the number, i.e. the number of bits to the right of the binary point.
"

..so if you do tests, and find out the gains behave "irrationally" occasionally, you can't possibly claim it isn't working as expected ;)

- Eero--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

RE: [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

Quoted 37 lines · Nurkkala Eero.An (EXT-Offcode/Oulu)
Quoted 18 lines
sound/soc/omap/omap-mcbsp.c +17 -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_mcbsp2_get_st_ch0_volume,
+                                     omap_mcbsp2_set_st_ch0_volume),
+       OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP2 Sidetone Channel 1 Volume",
+                                     -32768, 32767,
+                                     omap_mcbsp2_get_st_ch1_volume,
+                                     omap_mcbsp2_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),

sound/soc/omap/omap-mcbsp.c struct snd_soc_dai omap_mcbsp_dai[] = { · line 757

Quoted 10 lines
sound/soc/omap/omap-mcbsp.c +10 -0
+       OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 0 Volume",
+                                     -32768, 32767,
+                                     omap_mcbsp3_get_st_ch0_volume,
+                                     omap_mcbsp3_set_st_ch0_volume),
+       OMAP_MCBSP_SOC_SINGLE_S16_EXT("McBSP3 Sidetone Channel 1 Volume",
+                                     -32768, 32767,
+                                     omap_mcbsp3_get_st_ch1_volume,
+                                     omap_mcbsp3_set_st_ch1_volume),
+};
+

Just a short note, "Gain values are in the interval (-2..2) in Q1.14 format, negative values are expressed in 2's complement."

So, from:
http://en.wikipedia.org/wiki/Q_(number_format)

"
The notation used is Qm.n, where:

Quoted 8 lines

* Q designates that the number is in Q format notation — the Texas
Instruments representation for signed fixed-point numbers.
* m (optional; default=0) is the number of bits used to designate the
two's complement integer portion of the number, exclusive of the sign bit.
* n is the number of bits used to designate the two's complement
fractional portion of the number, i.e. the number of bits to the right of the binary point. "

..so if you do tests, and find out the gains behave "irrationally" occasionally, you can't possibly claim it isn't working as expected ;)

I'm a bit confused. What do you mean by that?

AFAICS, Q1.14 defines values [-16384.0, +16383.5], which are mapped in the driver to integers [-32768, 32767], right? Moreover, those Q1.14 values in registers are mapped to [-2, 2] in HW. So is there a problem somewhere?

Cheers, Ilkka

#5 lore raw

Re: [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

Quoted 9 lines

I'm a bit confused. What do you mean by that?

AFAICS, Q1.14 defines values [-16384.0, +16383.5], which are mapped in the driver to integers [-32768, 32767], right? Moreover, those Q1.14 values in registers are mapped to [-2, 2] in HW. So is there a problem somewhere?

Cheers, Ilkka

No, don't get me wrong, not saying there's a problem with the positive gains, Q1.14: its range is [-16384.0, +16383.5] = [0x8000, 0x8001 … 0xFFFF, 0x0000, 0x0001 … 0x7FFE, 0x7FFF]
if I read this correctly, your min is 0xFFFF, but the real min maybe 0x8000? To be honest, it may be just me interpreting that incorrectly.. ...as if the value is in two's complement, it goes the opposite:
http://en.wikipedia.org/wiki/Two%27s_complement , see:
1 0 0 0 0 0 0 0 = −128
1 1 1 1 1 1 1 1 = −1
what do you think? maybe try it out to see the truth..

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

#6 lore raw

RE: [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

Quoted 16 lines

From: Nurkkala Eero.An (EXT-Offcode/Oulu)
Sent: 19 February, 2010 14:58

Quoted 3 lines

I'm a bit confused. What do you mean by that?

AFAICS, Q1.14 defines values [-16384.0, +16383.5], which are

mapped in the

Quoted 1 line

driver to integers [-32768, 32767], right? Moreover, those

Q1.14 values in

Quoted 1 line

registers are mapped to [-2, 2] in HW. So is there a problem

somewhere?

Quoted 2 lines

Cheers, Ilkka

Quoted 11 lines

No, don't get me wrong, not saying there's a problem with the positive gains,
Q1.14: its range is [-16384.0, +16383.5] = [0x8000, 0x8001 … 0xFFFF, 0x0000, 0x0001 … 0x7FFE, 0x7FFF]
if I read this correctly, your min is 0xFFFF, but the real min maybe 0x8000? To be honest, it may be just me interpreting that incorrectly.. ...as if the value is in two's complement, it goes the opposite:
http://en.wikipedia.org/wiki/Two%27s_complement , see:
1 0 0 0 0 0 0 0 = −128
1 1 1 1 1 1 1 1 = −1
what do you think? maybe try it out to see the truth..

Oops, I seemed to copy Q1.14 instead of Q14.1, but isn't it still the same. When I added some debug messages it still seemed to be corret.

Lowest number (-32768) is represented with 16th bit '1' and the rest are zeros, right? That is 0x8000.
-1 has all the bits set (0xffff) and 0 has all the bit cleared (0x0000). Highest positive value has 16th bit cleared and the rest set (0x7fff).

Or did I interpret something wrong?

Cheers, Ilkka

#7 lore raw

Re: [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

Quoted 4 lines

Oops, I seemed to copy Q1.14 instead of Q14.1, but isn't it still the same. When I added some debug messages it still seemed to be corret.

Quoted 8 lines

Lowest number (-32768) is represented with 16th bit '1' and the rest are zeros, right? That is 0x8000.
-1 has all the bits set (0xffff) and 0 has all the bit cleared (0x0000). Highest positive value has 16th bit cleared and the rest set (0x7fff).

Or did I interpret something wrong?

Cheers, Ilkka

I guess it's just fine, but let's see. Maybe I was lost in the Q1.14: m + n + 1 ~
binary: [sign bit, (m), (n)] where m is the integer portion, 0 or 1, n is 14 bits.. so if your input was [-32768... 32767] -> [-2,2] then, for example, -32768 is in hex: 0x8000, but the 2nd most significant bit is zero, which means the integer portion (m) is not 1, which makes me doubt the gain -32768 is actually -1 (or 0), not -2. But then, as it's a two's complement, it maybe just correct.

So most likely it's just fine; I just had a thinko.

- Eero

#8 lore raw

RE: [PATCHv4 2/2] ASoC: OMAP-McBSP: ASoC interface for McBSP sidetone

Quoted 33 lines

From: Nurkkala Eero.An (EXT-Offcode/Oulu)
Sent: 19 February, 2010 21:04

Quoted 1 line

Oops, I seemed to copy Q1.14 instead of Q14.1, but isn't it

still the same.

Quoted 3 lines

When I added some debug messages it still seemed to be corret.

Lowest number (-32768) is represented with 16th bit '1' and

the rest are

Quoted 2 lines

zeros, right? That is 0x8000.
-1 has all the bits set (0xffff) and 0 has all the bit

cleared (0x0000).

Quoted 1 line

Highest positive value has 16th bit cleared and the rest set

(0x7fff).

Quoted 4 lines

Or did I interpret something wrong?

Cheers, Ilkka

I guess it's just fine, but let's see. Maybe I was lost in the Q1.14: m + n + 1 ~
binary: [sign bit, (m), (n)] where m is the integer portion, 0 or 1, n is 14 bits..
so if your input was [-32768... 32767] -> [-2,2] then, for example, -32768 is in hex: 0x8000, but the 2nd most significant bit is zero, which means
the integer portion (m) is not 1, which makes me doubt the gain -32768 is
actually -1 (or 0), not -2. But then, as it's a two's complement, it maybe just correct.

Quoted 1 line

So most likely it's just fine; I just had a thinko.

Ok, now I got your point :) However, as far as I can understand the Q notation right, it basically defines how to interpret the value. That is, where is the decimal point. Thus, I would say that the code should work fine and based on quick tests, the gain control seems to behave ok too.

Cheers, Ilkka

#9 lore raw
In reply to Ilkka Koskinen
Quoted 7 lines · On Thu, 18 Feb 2010 20:42:27 +0200 Ilkka Koskinen <[email protected]>…

The first patch implements McBSP sidetone feature on OMAP3 while the second one provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel mailing list in October 2009. Channel gain control and enabling the sidetone have been moved to ALSA interface as suggested in comments.

Quoted 8 lines

These patches apply on top of Janusz Krzysztofik's McBSP register cache patches in linux-omap-2.6.git

Since the version 3, the buggy channel gain control has been fixed. ASoC part have been simplified resulting in removing a couple unnecessary functions. Added a comment to ASoC part explaining McBSP port number vs. index values used in OMAP McBSP implementation.

I still have two concern:

1. port number vs. index difference inside driver code is not enough

It's just confusing if a machine driver and internal API (mcbsp.c) has to use different indexing. See:

omap_mcbsp_st_add_controls(codec, 2);
...
*(unsigned int *)omap3beagle_dai.cpu_dai->private_data = 1; /* McBSP2 */

and mcbsp->id use in mcbsp.c.

2. I cannot change the sidetone level with alsamixer

Is this bug with the alsamixer? With amixer I'm able to set positive values but not negative

amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 32767

What I'm looking here, is that I can execute a test below with unit impulse response tap filter, hear the sound and note that the volume is changing as I'm changing the sidetone volume :-)

arecord -f dat >/dev/null |aplay -f dat /dev/zero

Signature · 1 line
Jarkko
#10 lore raw
Quoted 11 lines · On Thursday 18 February 2010 22:22:29 ext Jarkko Nikula wrote:

I still have two concern:

1. port number vs. index difference inside driver code is not enough

It's just confusing if a machine driver and internal API (mcbsp.c) has to use different indexing. See:

omap_mcbsp_st_add_controls(codec, 2);
...
*(unsigned int *)omap3beagle_dai.cpu_dai->private_data = 1; /* McBSP2 */

Agreed.

Quoted 1 line

and mcbsp->id use in mcbsp.c.

It has always bothered me, I'll take a look and check if there is a reason why it is like that, and if possible I'll change the mcbsp->id to be 0 based (thus harmonizing the internal and external interface).

Quoted 10 lines

2. I cannot change the sidetone level with alsamixer

Is this bug with the alsamixer? With amixer I'm able to set positive values but not negative

amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 32767

What I'm looking here, is that I can execute a test below with unit impulse response tap filter, hear the sound and note that the volume is changing as I'm changing the sidetone volume :-)

I'm not sure, but you might need to configure the taps as well to have the correct sidetone.
Also I have a recollection, that the McBSP sidetone requires DSP mode (TDM) in order to operate correctly, so on Beagle you might need to set up 4 channel mode. And how the channel mapping in 4 channel mode works in McBSP sidetone is another matter...

Quoted 2 lines

arecord -f dat >/dev/null |aplay -f dat /dev/zero

Signature · 5 lines
Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#11 lore raw
Quoted 7 lines · On Fri, 19 Feb 2010 10:34:32 +0200 Peter Ujfalusi <[email protected]>…

I'm not sure, but you might need to configure the taps as well to have the correct sidetone.
Also I have a recollection, that the McBSP sidetone requires DSP mode (TDM) in order to operate correctly, so on Beagle you might need to set up 4 channel mode. And how the channel mapping in 4 channel mode works in McBSP sidetone is another matter...

It seems to work with I2S too.

I think I forgot to enable control 'McBSP2 Sidetone' when I last time tried this set (v1 or v2). But now my null test below works and I can hear that the level is changing when I adjust the volumes with amixer.

echo 32767 >/sys/devices/platform/omap-mcbsp.2/st_taps

arecord -f dat >/dev/null |aplay -f dat /dev/zero

amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 32700 amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 327 amixer set -D hw:0 'McBSP2 Sidetone Channel 0' -- -32700

Signature · 1 line
Jarkko
#12 lore raw
Quoted 12 lines · ext Jarkko Nikula
Quoted 7 lines · On Fri, 19 Feb 2010 10:34:32 +0200 Peter Ujfalusi <[email protected]>…

I'm not sure, but you might need to configure the taps as well to have the correct sidetone.
Also I have a recollection, that the McBSP sidetone requires DSP mode (TDM) in order to operate correctly, so on Beagle you might need to set up 4 channel mode. And how the channel mapping in 4 channel mode works in McBSP sidetone is another matter...

It seems to work with I2S too.

For both channels? I don't recall so.. and for the one channel only, the FIR doesn't behave expectedly? (maybe this works [1,0,..0], but more sophisticated ones may not..)

Quoted 13 lines

I think I forgot to enable control 'McBSP2 Sidetone' when I last time tried this set (v1 or v2). But now my null test below works and I can hear that the level is changing when I adjust the volumes with amixer.

echo 32767 >/sys/devices/platform/omap-mcbsp.2/st_taps

arecord -f dat >/dev/null |aplay -f dat /dev/zero

amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 32700 amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 327 amixer set -D hw:0 'McBSP2 Sidetone Channel 0' -- -32700

#13 lore raw
Quoted 7 lines · On Fri, 19 Feb 2010 15:37:17 +0200 Eero Nurkkala <[email protected]>…
Quoted 2 lines

It seems to work with I2S too.

For both channels? I don't recall so.. and for the one channel only, the FIR doesn't behave expectedly? (maybe this works [1,0,..0], but more sophisticated ones may not..)

Could be. At least the control 'McBSP2 Sidetone Channel 1' doesn't have any effect. But the control 0 is affecting both channels simultaneously. (I didn't check the meaning of those two controls)

Signature · 1 line
Jarkko
#14 lore raw
In reply to Jarkko Nikula
Quoted 22 lines · ext Jarkko Nikula
Quoted 7 lines · On Thu, 18 Feb 2010 20:42:27 +0200 Ilkka Koskinen <[email protected]>…

The first patch implements McBSP sidetone feature on OMAP3 while the second one provides ALSA interface for using it.

The patch set is based on the patch Eduardo Valentin sent to alsa-devel mailing list in October 2009. Channel gain control and enabling the sidetone have been moved to ALSA interface as suggested in comments.

Quoted 8 lines

These patches apply on top of Janusz Krzysztofik's McBSP register cache patches in linux-omap-2.6.git

Since the version 3, the buggy channel gain control has been fixed. ASoC part have been simplified resulting in removing a couple unnecessary functions. Added a comment to ASoC part explaining McBSP port number vs. index values used in OMAP McBSP implementation.

I still have two concern:

1. port number vs. index difference inside driver code is not enough

Quoted 8 lines

It's just confusing if a machine driver and internal API (mcbsp.c) has to use different indexing. See:

omap_mcbsp_st_add_controls(codec, 2);
...
*(unsigned int *)omap3beagle_dai.cpu_dai->private_data = 1; /* McBSP2 */

and mcbsp->id use in mcbsp.c.

Ah, that's what you meant by it. Sure, I'll change it.

Quoted 2 lines

2. I cannot change the sidetone level with alsamixer

I think with the previous patch set, it was impossible to set the other channel's gain as Peter pointed out. But at least now that I try, i can change it with alsamixer.

Quoted 4 lines

Is this bug with the alsamixer? With amixer I'm able to set positive values but not negative

amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 32767

If you try to give negative values, you need to put '--' before the value.

Such as:

# amixer -Dhw:0 -- sset 'McBSP3 Sidetone Channel 0' -10000
Simple mixer control 'McBSP3 Sidetone Channel 0',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: -32768 - 32767
  Mono: -10000 [35%]
Quoted 5 lines

What I'm looking here, is that I can execute a test below with unit impulse response tap filter, hear the sound and note that the volume is changing as I'm changing the sidetone volume :-)

arecord -f dat >/dev/null |aplay -f dat /dev/zero

As Peter said in the other mail, you need to have the taps also.

Cheers, Ilkka

#15 lore raw
Quoted 6 lines · On Fri, 19 Feb 2010 12:05:40 +0200 (EET) Ilkka Koskinen <[email protected]>…
Quoted 2 lines

2. I cannot change the sidetone level with alsamixer

I think with the previous patch set, it was impossible to set the other channel's gain as Peter pointed out. But at least now that I try, i can change it with alsamixer.

Probably there is some difference with SW? I'm using Debian and alsa-utils 1.0.21-1.

Quoted 7 lines
Quoted 4 lines

Is this bug with the alsamixer? With amixer I'm able to set positive values but not negative

amixer set -D hw:0 'McBSP2 Sidetone Channel 0' 32767

If you try to give negative values, you need to put '--' before the value.

Thanks, works fine (lazy me).

Signature · 1 line
Jarkko