[alsa-devel] [PATCH 1/4] ALSA: hda - Keep autocfg.input idx value in imux table
Takashi Iwai
tiwai at suse.de
Fri Jan 18 11:24:00 CET 2013
Since the imux table entries can be a subset of autocfg.input table,
the indices of these aren't always same. For passing the proper index
value of autocfg.input at creating input ctl labels (via
snd_hda_autocfg_input_label()), keep the corresponding autocfg.input
idx value in the index field of each imux item, which isn't used in
the generic driver.
Also, this makes easier to check the invalid imux pin for stereo mix.
Signed-off-by: Takashi Iwai <tiwai at suse.de>
---
sound/pci/hda/hda_generic.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index ef4c04a..7444d2e 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -2478,7 +2478,8 @@ static int check_dyn_adc_switch(struct hda_codec *codec)
/* parse capture source paths from the given pin and create imux items */
static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin,
- int num_adcs, const char *label, int anchor)
+ int cfg_idx, int num_adcs,
+ const char *label, int anchor)
{
struct hda_gen_spec *spec = codec->spec;
struct hda_input_mux *imux = &spec->input_mux;
@@ -2501,8 +2502,7 @@ static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin,
if (!imux_added) {
spec->imux_pins[imux->num_items] = pin;
- snd_hda_add_imux_item(imux, label,
- imux->num_items, NULL);
+ snd_hda_add_imux_item(imux, label, cfg_idx, NULL);
imux_added = true;
}
}
@@ -2513,6 +2513,9 @@ static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin,
/*
* create playback/capture controls for input pins
*/
+
+#define CFG_IDX_MIX 99 /* a dummy cfg->input idx for stereo mix */
+
static int create_input_ctls(struct hda_codec *codec)
{
struct hda_gen_spec *spec = codec->spec;
@@ -2556,7 +2559,8 @@ static int create_input_ctls(struct hda_codec *codec)
}
}
- err = parse_capture_source(codec, pin, num_adcs, label, -mixer);
+ err = parse_capture_source(codec, pin, i,
+ num_adcs, label, -mixer);
if (err < 0)
return err;
@@ -2568,7 +2572,7 @@ static int create_input_ctls(struct hda_codec *codec)
}
if (mixer && spec->add_stereo_mix_input) {
- err = parse_capture_source(codec, mixer, num_adcs,
+ err = parse_capture_source(codec, mixer, CFG_IDX_MIX, num_adcs,
"Stereo Mix", 0);
if (err < 0)
return err;
@@ -2909,7 +2913,11 @@ static int create_multi_cap_vol_ctl(struct hda_codec *codec)
for (i = 0; i < imux->num_items; i++) {
const char *label;
bool inv_dmic;
- label = hda_get_autocfg_input_label(codec, &spec->autocfg, i);
+
+ if (imux->items[i].index >= spec->autocfg.num_inputs)
+ continue;
+ label = hda_get_autocfg_input_label(codec, &spec->autocfg,
+ imux->items[i].index);
if (prev_label && !strcmp(label, prev_label))
type_idx++;
else
--
1.8.1
More information about the Alsa-devel
mailing list