[alsa-devel] Problem setting mixer switch with amixer/alsactl.

Mark Brown broonie at sirena.org.uk
Tue Oct 28 14:10:31 CET 2008


On Fri, Oct 24, 2008 at 09:09:33PM +0200, Robert Jarzmik wrote:
> Mark Brown <broonie at sirena.org.uk> writes:

> > All this patch does is change the limit, there is still a limit on the
> > length of control names in ALSA but as I say it's purely a cosmetic issue.

> I don't quite agree on the "cosmetic".

> If I recall correctly, that name is used in dapm path setup. If the name is
> incorrect (truncated), some dapm elements are not switched on. I'm speaking from
> memory, I'll try to browse my git repository to track it back. Notice that I'm
> really busy ATM, so I don't have enough manpower to test immediatly.

It looks like you might've been right after all.  I still can't see
where this makes a difference to the speaker paths but the patch below
seems to resolve the issues I'm seeing here.

Oliver, could you test the patch below please?

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 28da235..fdb4d2c 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -293,7 +293,7 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
 	struct snd_soc_dapm_widget *w)
 {
 	int i, ret = 0;
-	char name[32];
+	size_t name_len;
 	struct snd_soc_dapm_path *path;
 
 	/* add kcontrol */
@@ -307,11 +307,16 @@ static int dapm_new_mixer(struct snd_soc_codec *codec,
 				continue;
 
 			/* add dapm control with long name */
-			snprintf(name, 32, "%s %s", w->name, w->kcontrols[i].name);
-			path->long_name = kstrdup (name, GFP_KERNEL);
+			name_len = 2 + strlen(w->name)
+				+ strlen(w->kcontrols[i].name);
+			path->long_name = kmalloc(name_len, GFP_KERNEL);
 			if (path->long_name == NULL)
 				return -ENOMEM;
 
+			snprintf(path->long_name, name_len, "%s %s",
+				 w->name, w->kcontrols[i].name);
+			path->long_name[name_len - 1] = '\0';
+
 			path->kcontrol = snd_soc_cnew(&w->kcontrols[i], w,
 				path->long_name);
 			ret = snd_ctl_add(codec->card, path->kcontrol);


More information about the Alsa-devel mailing list