Skip to contentSkip to conversation

ASoC: msm8x60: enhance mixer interfaces

PATCH In review [email protected] 3 participants 6 messages Feb 10, 2011 – Feb 21, 2011

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

PATCH 1/1 ASoC: msm8x60: enhance mixer interfaces

From: Eero Nurkkala <[email protected]>

Currenly, a simple access to any of the interfaces fail, when accessed in the following manner:
"amixer set Volume 100%" -> no success.

Simplify the initiation and fix the interfaces so that they may be altered in a more generic ways. With the patch:

amixer set Volume 100%
Simple mixer control 'Volume',0
Capabilities: volume penum
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 16383
Front Left: 16383 [100%]
Front Right: 16383 [100%]

---
 sound/soc/msm/msm8x60.c |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)
sound/soc/msm/msm8x60.c +12 -19
index 38c56de..eb0dab2 100644
@@ -850,33 +850,26 @@ static struct snd_kcontrol_new snd_msm_secondary_controls[] = {
 			pcm_route_info, pcm_route_get_tx, pcm_route_put_tx, 0),
 };
 
-static int msm_new_mixer(struct snd_card *card)
+static int msm_new_mixer(struct snd_soc_codec *codec)
 {
 	unsigned int idx;
 	int err;
 	int dev_cnt;
 
-	strcpy(card->mixername, "MSM Mixer");
-	for (idx = 0; idx < ARRAY_SIZE(snd_msm_controls); idx++) {
-		err = snd_ctl_add(card,	snd_ctl_new1(&snd_msm_controls[idx],
-					NULL));
-		if (err < 0)
-			pr_err("%s:ERR adding ctl\n", __func__);
-	}
-
-	for (idx = 0; idx < ARRAY_SIZE(snd_msm_secondary_controls); idx++) {
-		err = snd_ctl_add(card,
-			snd_ctl_new1(&snd_msm_secondary_controls[idx],
-			NULL));
-		if (err < 0)
-			pr_err("%s:ERR adding secondary ctl\n", __func__);
-	}
+	strcpy(codec->card->mixername, "MSM Mixer");
+	if (snd_soc_add_controls(codec, snd_msm_controls,
+			ARRAY_SIZE(snd_msm_controls)))
+		pr_err("%s:ERR adding ctl\n", __func__);
 	dev_cnt = msm_snddev_devcount();
 
+	if (snd_soc_add_controls(codec, snd_msm_secondary_controls,
+			ARRAY_SIZE(snd_msm_secondary_controls)))
+		pr_err("%s:ERR adding secondary ctl\n", __func__);
+
 	for (idx = 0; idx < dev_cnt; idx++) {
 		if (!snd_dev_ctl_index(idx)) {
-			err = snd_ctl_add(card, snd_ctl_new1(
-				&snd_dev_controls[idx], NULL));
+			err = snd_ctl_add(codec->card, snd_soc_cnew(
+				&snd_dev_controls[idx], codec, NULL));
 			if (err < 0)
 				pr_err("%s:ERR adding ctl\n", __func__);
 		} else
@@ -892,7 +885,7 @@ static int msm_soc_dai_init(struct snd_soc_codec *codec)
 {
 
 	int ret = 0;
-	ret = msm_new_mixer(codec->card);
+	ret = msm_new_mixer(codec);
 	if (ret < 0)
 		pr_err("%s: ALSA MSM Mixer Fail\n", __func__);
 
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 9 lines · On Thu, Feb 10 2011, [email protected] wrote:

From: Eero Nurkkala <[email protected]>

Currenly, a simple access to any of the interfaces fail, when accessed in the following manner:
"amixer set Volume 100%" -> no success.

Simplify the initiation and fix the interfaces so that they may be altered in a more generic ways. With the patch:

Which kernel is this patch against? I can forward the change internally, but this code isn't yet in the main Linux kernel.

Thanks,
David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#2 lore raw

Quoting David Brown <[email protected]>:

Quoted 8 lines · On Thu, Feb 10 2011, [email protected] wrote:
Quoted 7 lines

From: Eero Nurkkala <[email protected]>

Currenly, a simple access to any of the interfaces fail, when accessed in the following manner:
"amixer set Volume 100%" -> no success.

Quoted 6 lines
Quoted 3 lines

Simplify the initiation and fix the interfaces so that they may be altered in a more generic ways. With the patch:

Which kernel is this patch against? I can forward the change internally, but this code isn't yet in the main Linux kernel.

It's the:
android-msm-2.6.35 branch @ git://codeaurora.org/projects/kernel/msm.git
(URL: https://www.codeaurora.org/gitweb/quic/le/?p=kernel/msm.git)

Is there a more relevant mailing list available for sending patches on that particular git tree? (eg. if I send patches in the future)

BR,
Eero

Quoted 8 lines

Thanks,
David

--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

#3 lore raw
Quoted 16 lines · On Thu, Feb 10 2011, [email protected] wrote:

Quoting David Brown <[email protected]>:

Quoted 8 lines · On Thu, Feb 10 2011, [email protected] wrote:
Quoted 7 lines

From: Eero Nurkkala <[email protected]>

Currenly, a simple access to any of the interfaces fail, when accessed in the following manner:
"amixer set Volume 100%" -> no success.

Quoted 6 lines
Quoted 3 lines

Simplify the initiation and fix the interfaces so that they may be altered in a more generic ways. With the patch:

Which kernel is this patch against? I can forward the change internally, but this code isn't yet in the main Linux kernel.

Quoted 6 lines

It's the:
android-msm-2.6.35 branch @ git://codeaurora.org/projects/kernel/msm.git
(URL: https://www.codeaurora.org/gitweb/quic/le/?p=kernel/msm.git)

Is there a more relevant mailing list available for sending patches on that particular git tree? (eg. if I send patches in the future)

No, this would be the place. It's more just that I've never gotten a patch against that branch before.

David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#4 lore raw
In reply to [email protected]

Hi,

In your patch, snd_soc_cnew() is invoked. This function sets
index of snd_kcontrol_new to 0. You must have realized by now that
MSM audio drivers are not truly ALSA compliant. List of sound devices(i.e speaker) is exposed to user-space as mixer controls. Index of control is used to propagate native ID of a particular
sound device though you can still derive native ID from value returned from control "Count". It is not as straight forward as reading the index Is it really necessary to call snd_soc_cnew()?

Quoted 83 lines · On 2/10/2011 2:49 AM, [email protected] wrote:

From: Eero Nurkkala<[email protected]>

Currenly, a simple access to any of the interfaces fail, when accessed in the following manner:
"amixer set Volume 100%" -> no success.

Simplify the initiation and fix the interfaces so that they may be altered in a more generic ways. With the patch:

amixer set Volume 100%
Simple mixer control 'Volume',0
Capabilities: volume penum
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 16383
Front Left: 16383 [100%]
Front Right: 16383 [100%]

---
  sound/soc/msm/msm8x60.c |   31 ++++++++++++-------------------
  1 files changed, 12 insertions(+), 19 deletions(-)
sound/soc/msm/msm8x60.c +11 -18
index 38c56de..eb0dab2 100644
@@ -850,33 +850,26 @@ static struct snd_kcontrol_new snd_msm_secondary_controls[] = {
  			pcm_route_info, pcm_route_get_tx, pcm_route_put_tx, 0),
  };
 
-static int msm_new_mixer(struct snd_card *card)
+static int msm_new_mixer(struct snd_soc_codec *codec)
  {
  	unsigned int idx;
  	int err;
  	int dev_cnt;
 
-	strcpy(card->mixername, "MSM Mixer");
-	for (idx = 0; idx<  ARRAY_SIZE(snd_msm_controls); idx++) {
-		err = snd_ctl_add(card,	snd_ctl_new1(&snd_msm_controls[idx],
-					NULL));
-		if (err<  0)
-			pr_err("%s:ERR adding ctl\n", __func__);
-	}
-
-	for (idx = 0; idx<  ARRAY_SIZE(snd_msm_secondary_controls); idx++) {
-		err = snd_ctl_add(card,
-			snd_ctl_new1(&snd_msm_secondary_controls[idx],
-			NULL));
-		if (err<  0)
-			pr_err("%s:ERR adding secondary ctl\n", __func__);
-	}
+	strcpy(codec->card->mixername, "MSM Mixer");
+	if (snd_soc_add_controls(codec, snd_msm_controls,
+			ARRAY_SIZE(snd_msm_controls)))
+		pr_err("%s:ERR adding ctl\n", __func__);
  	dev_cnt = msm_snddev_devcount();
 
+	if (snd_soc_add_controls(codec, snd_msm_secondary_controls,
+			ARRAY_SIZE(snd_msm_secondary_controls)))
+		pr_err("%s:ERR adding secondary ctl\n", __func__);
+
  	for (idx = 0; idx<  dev_cnt; idx++) {
  		if (!snd_dev_ctl_index(idx)) {
-			err = snd_ctl_add(card, snd_ctl_new1(
-				&snd_dev_controls[idx], NULL));
+			err = snd_ctl_add(codec->card, snd_soc_cnew(
 
+				&snd_dev_controls[idx], codec, NULL));
  			if (err<  0)
  				pr_err("%s:ERR adding ctl\n", __func__);
  		} else
sound/soc/msm/msm8x60.c +1 -1
@@ -892,7 +885,7 @@ static int msm_soc_dai_init(struct snd_soc_codec *codec)
  {
 
  	int ret = 0;
-	ret = msm_new_mixer(codec->card);
+	ret = msm_new_mixer(codec);
  	if (ret<  0)
  		pr_err("%s: ALSA MSM Mixer Fail\n", __func__);
 
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#5 lore raw

Quoting Patrick Lai <[email protected]>:

Quoted 9 lines

Hi,

In your patch, snd_soc_cnew() is invoked. This function sets
index of snd_kcontrol_new to 0. You must have realized by now that
MSM audio drivers are not truly ALSA compliant. List of sound devices(i.e speaker) is exposed to user-space as mixer controls. Index of control is used to propagate native ID of a particular
sound device though you can still derive native ID from value returned from control "Count". It is not as straight forward as reading the index Is it really necessary to call snd_soc_cnew()?

Right, this is the diff of 'amixer contents' without and with the patch:
< numid=19,iface=MIXER,name='anc_headset_stereo_rx',index=5
---

Quoted 1 line

numid=19,iface=MIXER,name='anc_headset_stereo_rx'

43c43
< numid=20,iface=MIXER,name='bt_sco_rx',index=6
---

Quoted 1 line

numid=20,iface=MIXER,name='bt_sco_rx'

46c46
< numid=21,iface=MIXER,name='bt_sco_tx',index=7
---

Quoted 1 line

numid=21,iface=MIXER,name='bt_sco_tx'

49c49
< numid=23,iface=MIXER,name='fmradio_stereo_rx',index=9
---

Quoted 1 line

numid=23,iface=MIXER,name='fmradio_stereo_rx'

52c52
< numid=22,iface=MIXER,name='fmradio_stereo_tx',index=8
---

Quoted 1 line

numid=22,iface=MIXER,name='fmradio_stereo_tx'

58c58
< numid=15,iface=MIXER,name='handset_tx',index=1
---

Quoted 1 line

numid=15,iface=MIXER,name='handset_tx'

61c61
< numid=24,iface=MIXER,name='hdmi_stereo_rx',index=10
---

Quoted 1 line

numid=24,iface=MIXER,name='hdmi_stereo_rx'

64c64
< numid=18,iface=MIXER,name='headset_mono_tx',index=4
---

Quoted 1 line

numid=18,iface=MIXER,name='headset_mono_tx'

67c67
< numid=17,iface=MIXER,name='headset_stereo_rx',index=3
---

Quoted 1 line

numid=17,iface=MIXER,name='headset_stereo_rx'

70c70
< numid=16,iface=MIXER,name='speaker_stereo_rx',index=2
---

Quoted 1 line

numid=16,iface=MIXER,name='speaker_stereo_rx'

-> so agreed it can cause headache.

- Eero

Quoted 91 lines · On 2/10/2011 2:49 AM, [email protected] wrote:
Quoted 84 lines

From: Eero Nurkkala<[email protected]>

Currenly, a simple access to any of the interfaces fail, when accessed in the following manner:
"amixer set Volume 100%" -> no success.

Simplify the initiation and fix the interfaces so that they may be altered in a more generic ways. With the patch:

amixer set Volume 100%
Simple mixer control 'Volume',0
Capabilities: volume penum
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 16383
Front Left: 16383 [100%]
Front Right: 16383 [100%]

---
 sound/soc/msm/msm8x60.c |   31 ++++++++++++-------------------
 1 files changed, 12 insertions(+), 19 deletions(-)
sound/soc/msm/msm8x60.c +11 -18
index 38c56de..eb0dab2 100644
@@ -850,33 +850,26 @@ static struct snd_kcontrol_new  
 snd_msm_secondary_controls[] = {
 			pcm_route_info, pcm_route_get_tx, pcm_route_put_tx, 0),
 };
 
-static int msm_new_mixer(struct snd_card *card)
+static int msm_new_mixer(struct snd_soc_codec *codec)
 {
 	unsigned int idx;
 	int err;
 	int dev_cnt;
 
-	strcpy(card->mixername, "MSM Mixer");
-	for (idx = 0; idx<  ARRAY_SIZE(snd_msm_controls); idx++) {
-		err = snd_ctl_add(card,	snd_ctl_new1(&snd_msm_controls[idx],
-					NULL));
-		if (err<  0)
-			pr_err("%s:ERR adding ctl\n", __func__);
-	}
-
-	for (idx = 0; idx<  ARRAY_SIZE(snd_msm_secondary_controls); idx++) {
-		err = snd_ctl_add(card,
-			snd_ctl_new1(&snd_msm_secondary_controls[idx],
-			NULL));
-		if (err<  0)
-			pr_err("%s:ERR adding secondary ctl\n", __func__);
-	}
+	strcpy(codec->card->mixername, "MSM Mixer");
+	if (snd_soc_add_controls(codec, snd_msm_controls,
+			ARRAY_SIZE(snd_msm_controls)))
+		pr_err("%s:ERR adding ctl\n", __func__);
 	dev_cnt = msm_snddev_devcount();
 
+	if (snd_soc_add_controls(codec, snd_msm_secondary_controls,
+			ARRAY_SIZE(snd_msm_secondary_controls)))
+		pr_err("%s:ERR adding secondary ctl\n", __func__);
+
 	for (idx = 0; idx<  dev_cnt; idx++) {
 		if (!snd_dev_ctl_index(idx)) {
-			err = snd_ctl_add(card, snd_ctl_new1(
-				&snd_dev_controls[idx], NULL));
+			err = snd_ctl_add(codec->card, snd_soc_cnew(
 
+				&snd_dev_controls[idx], codec, NULL));
 			if (err<  0)
sound/soc/msm/msm8x60.c +1 -1
 				pr_err("%s:ERR adding ctl\n", __func__);
 		} else
@@ -892,7 +885,7 @@ static int msm_soc_dai_init(struct snd_soc_codec *codec)
 {
 
 	int ret = 0;
-	ret = msm_new_mixer(codec->card);
+	ret = msm_new_mixer(codec);
 	if (ret<  0)
 		pr_err("%s: ALSA MSM Mixer Fail\n", __func__);
 
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.