Commit 65973632 authored by Matthew Ranostay's avatar Matthew Ranostay Committed by Jaroslav Kysela

ALSA: hda: SPDIF mux fixes for STAC927x

Corrected bounds-checking in stac92xx_auto_create_mux_input_ctls() and added a spec->spdif_labels
pointer for custom SPDIF mux labels for non-standard codec connections.
Signed-off-by: default avatarMatthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 2f3dfaf5
...@@ -177,6 +177,7 @@ struct sigmatel_spec { ...@@ -177,6 +177,7 @@ struct sigmatel_spec {
unsigned int num_dmuxes; unsigned int num_dmuxes;
hda_nid_t *smux_nids; hda_nid_t *smux_nids;
unsigned int num_smuxes; unsigned int num_smuxes;
const char **spdif_labels;
hda_nid_t dig_in_nid; hda_nid_t dig_in_nid;
hda_nid_t mono_nid; hda_nid_t mono_nid;
...@@ -394,6 +395,11 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = { ...@@ -394,6 +395,11 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
0x13, 0x14, 0 0x13, 0x14, 0
}; };
static const char *stac927x_spdif_labels[5] = {
"Digital Playback", "ADAT", "Analog Mux 1",
"Analog Mux 2", "Analog Mux 3"
};
static hda_nid_t stac9205_adc_nids[2] = { static hda_nid_t stac9205_adc_nids[2] = {
0x12, 0x13 0x12, 0x13
}; };
...@@ -3033,26 +3039,29 @@ static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) ...@@ -3033,26 +3039,29 @@ static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
}; };
static const char *stac92xx_spdif_labels[3] = { static const char *stac92xx_spdif_labels[3] = {
"Digital Playback", "Analog Mux 1", "Analog Mux 2" "Digital Playback", "Analog Mux 1", "Analog Mux 2",
}; };
static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
{ {
struct sigmatel_spec *spec = codec->spec; struct sigmatel_spec *spec = codec->spec;
struct hda_input_mux *spdif_mux = &spec->private_smux; struct hda_input_mux *spdif_mux = &spec->private_smux;
const char **labels = spec->spdif_labels;
int i, num_cons; int i, num_cons;
hda_nid_t con_lst[ARRAY_SIZE(stac92xx_spdif_labels)]; hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
num_cons = snd_hda_get_connections(codec, num_cons = snd_hda_get_connections(codec,
spec->smux_nids[0], spec->smux_nids[0],
con_lst, con_lst,
HDA_MAX_NUM_INPUTS); HDA_MAX_NUM_INPUTS);
if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_spdif_labels)) if (!num_cons)
return -EINVAL; return -EINVAL;
if (!labels)
labels = stac92xx_spdif_labels;
for (i = 0; i < num_cons; i++) { for (i = 0; i < num_cons; i++) {
spdif_mux->items[spdif_mux->num_items].label = spdif_mux->items[spdif_mux->num_items].label = labels[i];
stac92xx_spdif_labels[i];
spdif_mux->items[spdif_mux->num_items].index = i; spdif_mux->items[spdif_mux->num_items].index = i;
spdif_mux->num_items++; spdif_mux->num_items++;
} }
...@@ -4547,6 +4556,7 @@ static int patch_stac927x(struct hda_codec *codec) ...@@ -4547,6 +4556,7 @@ static int patch_stac927x(struct hda_codec *codec)
spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids); spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
spec->smux_nids = stac927x_smux_nids; spec->smux_nids = stac927x_smux_nids;
spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids); spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
spec->spdif_labels = stac927x_spdif_labels;
spec->dac_list = stac927x_dac_nids; spec->dac_list = stac927x_dac_nids;
spec->multiout.dac_nids = spec->dac_nids; spec->multiout.dac_nids = spec->dac_nids;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment