提交 61071594 编写于 作者: T Takashi Iwai

ALSA: hda/realtek - Minor cleanup

Use an inline function for the common pattern for assigning a capsrc.
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 6759dc32
...@@ -277,6 +277,12 @@ static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur) ...@@ -277,6 +277,12 @@ static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur)
return false; return false;
} }
static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx)
{
return spec->capsrc_nids ?
spec->capsrc_nids[idx] : spec->adc_nids[idx];
}
/* select the given imux item; either unmute exclusively or select the route */ /* select the given imux item; either unmute exclusively or select the route */
static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
unsigned int idx, bool force) unsigned int idx, bool force)
...@@ -303,8 +309,7 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, ...@@ -303,8 +309,7 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
adc_idx = spec->dyn_adc_idx[idx]; adc_idx = spec->dyn_adc_idx[idx];
} }
nid = spec->capsrc_nids ? nid = get_capsrc(spec, adc_idx);
spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
/* no selection? */ /* no selection? */
num_conns = snd_hda_get_conn_list(codec, nid, NULL); num_conns = snd_hda_get_conn_list(codec, nid, NULL);
...@@ -1058,8 +1063,7 @@ static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec) ...@@ -1058,8 +1063,7 @@ static bool alc_rebuild_imux_for_auto_mic(struct hda_codec *codec)
hda_nid_t pin = spec->imux_pins[i]; hda_nid_t pin = spec->imux_pins[i];
int c; int c;
for (c = 0; c < spec->num_adc_nids; c++) { for (c = 0; c < spec->num_adc_nids; c++) {
hda_nid_t cap = spec->capsrc_nids ? hda_nid_t cap = get_capsrc(spec, c);
spec->capsrc_nids[c] : spec->adc_nids[c];
int idx = get_connection_index(codec, cap, pin); int idx = get_connection_index(codec, cap, pin);
if (idx >= 0) { if (idx >= 0) {
imux->items[i].index = idx; imux->items[i].index = idx;
...@@ -1969,10 +1973,8 @@ static int alc_build_controls(struct hda_codec *codec) ...@@ -1969,10 +1973,8 @@ static int alc_build_controls(struct hda_codec *codec)
if (!kctl) if (!kctl)
kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
for (i = 0; kctl && i < kctl->count; i++) { for (i = 0; kctl && i < kctl->count; i++) {
const hda_nid_t *nids = spec->capsrc_nids; err = snd_hda_add_nid(codec, kctl, i,
if (!nids) get_capsrc(spec, i));
nids = spec->adc_nids;
err = snd_hda_add_nid(codec, kctl, i, nids[i]);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -2759,8 +2761,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec) ...@@ -2759,8 +2761,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
} }
for (c = 0; c < num_adcs; c++) { for (c = 0; c < num_adcs; c++) {
hda_nid_t cap = spec->capsrc_nids ? hda_nid_t cap = get_capsrc(spec, c);
spec->capsrc_nids[c] : spec->adc_nids[c];
idx = get_connection_index(codec, cap, pin); idx = get_connection_index(codec, cap, pin);
if (idx >= 0) { if (idx >= 0) {
spec->imux_pins[imux->num_items] = pin; spec->imux_pins[imux->num_items] = pin;
...@@ -3706,8 +3707,7 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) ...@@ -3706,8 +3707,7 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
if (!pin) if (!pin)
return 0; return 0;
for (i = 0; i < spec->num_adc_nids; i++) { for (i = 0; i < spec->num_adc_nids; i++) {
hda_nid_t cap = spec->capsrc_nids ? hda_nid_t cap = get_capsrc(spec, i);
spec->capsrc_nids[i] : spec->adc_nids[i];
int idx; int idx;
idx = get_connection_index(codec, cap, pin); idx = get_connection_index(codec, cap, pin);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册