[alsa-devel] [PATCH 0/3] Fixes for the new generic parser
Hi Takashi,
I've run my hda-emu summary test tool to check for errors in the 110 codecs we have of certified systems (those in codecs/canonical) against the test/hda-migrate branch.
After these fixes and the one I sent yesterday, there are no remaining regressions (as seen by this test tool) compared to the current sound tree.
David Henningsson (3): ALSA: hda - Check array bounds in get_input_path ALSA: hda - fix wrong adc_idx in generic parser ALSA: hda - initialize channel counts correctly
sound/pci/hda/hda_generic.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
This gives us some additional safety.
Signed-off-by: David Henningsson david.henningsson@canonical.com --- sound/pci/hda/hda_generic.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 932e6a1..577acc4 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -2397,8 +2397,16 @@ static int create_input_ctls(struct hda_codec *codec) static struct nid_path *get_input_path(struct hda_codec *codec, int adc_idx, int imux_idx) { struct hda_gen_spec *spec = codec->spec; + if (imux_idx < 0 || imux_idx >= HDA_MAX_NUM_INPUTS) { + snd_BUG(); + return NULL; + } if (spec->dyn_adc_switch) adc_idx = spec->dyn_adc_idx[imux_idx]; + if (adc_idx < 0 || adc_idx >= AUTO_CFG_MAX_OUTS) { + snd_BUG(); + return NULL; + } return snd_hda_get_path_from_idx(codec, spec->input_paths[imux_idx][adc_idx]); }
We use knew->index for adc_idx when we create "Capture Volume" and "Capture Switch", so use the same to retrieve adc_idx.
Signed-off-by: David Henningsson david.henningsson@canonical.com --- sound/pci/hda/hda_generic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 577acc4..aac8eb9 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -2426,7 +2426,7 @@ static int mux_enum_get(struct snd_kcontrol *kcontrol, { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_gen_spec *spec = codec->spec; - unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + unsigned int adc_idx = kcontrol->id.index;
ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; return 0; @@ -2436,7 +2436,7 @@ static int mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + unsigned int adc_idx = kcontrol->id.index; return mux_select(codec, adc_idx, ucontrol->value.enumerated.item[0]); } @@ -2468,7 +2468,7 @@ static int cap_put_caller(struct snd_kcontrol *kcontrol, int i, adc_idx, err = 0;
imux = &spec->input_mux; - adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); + adc_idx = kcontrol->id.index; mutex_lock(&codec->control_mutex); /* we use the cache-only update at first since multiple input paths * may shared the same amp; by updating only caches, the redundant
Even a single DAC can output two channels, so the channel count is twice the number of DACs.
Signed-off-by: David Henningsson david.henningsson@canonical.com --- sound/pci/hda/hda_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index aac8eb9..3ef38da 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -1399,7 +1399,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec, }
spec->ext_channel_count = spec->min_channel_count = - spec->multiout.num_dacs; + spec->multiout.num_dacs * 2;
if (spec->multi_ios == 2) { for (i = 0; i < 2; i++)
At Wed, 16 Jan 2013 11:45:34 +0100, David Henningsson wrote:
Hi Takashi,
I've run my hda-emu summary test tool to check for errors in the 110 codecs we have of certified systems (those in codecs/canonical) against the test/hda-migrate branch.
After these fixes and the one I sent yesterday, there are no remaining regressions (as seen by this test tool) compared to the current sound tree.
Thanks!
I applied these to test/hda-gen-parser branch now.
I'll take some test shots today, and if everything looks OK, I'm going to merge the patches to sound git tree for-next branch tomorrow or later.
Takashi
David Henningsson (3): ALSA: hda - Check array bounds in get_input_path ALSA: hda - fix wrong adc_idx in generic parser ALSA: hda - initialize channel counts correctly
sound/pci/hda/hda_generic.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
-- 1.7.9.5
participants (2)
-
David Henningsson
-
Takashi Iwai