Commit 27d31536 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda/realtek - Clean up some spec fields

Remove some fields from struct alc_spec, and clean up the usage.
Namely,
- spec->input_mux becomes a single element, private_imux[] is removed
- spec->adc_nids becomes an array by itself, and private_adc_nids[]
  gets removed, too
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 666a70d4
...@@ -128,7 +128,6 @@ struct alc_spec { ...@@ -128,7 +128,6 @@ struct alc_spec {
/* codec parameterization */ /* codec parameterization */
const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
unsigned int num_mixers; unsigned int num_mixers;
const struct snd_kcontrol_new *cap_mixer; /* capture mixer */
unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
char stream_name_analog[32]; /* analog PCM stream */ char stream_name_analog[32]; /* analog PCM stream */
...@@ -152,8 +151,7 @@ struct alc_spec { ...@@ -152,8 +151,7 @@ struct alc_spec {
/* capture */ /* capture */
unsigned int num_adc_nids; unsigned int num_adc_nids;
const hda_nid_t *adc_nids; hda_nid_t adc_nids[AUTO_CFG_MAX_OUTS];
const hda_nid_t *capsrc_nids;
hda_nid_t dig_in_nid; /* digital-in NID; optional */ hda_nid_t dig_in_nid; /* digital-in NID; optional */
hda_nid_t mixer_nid; /* analog-mixer NID */ hda_nid_t mixer_nid; /* analog-mixer NID */
...@@ -164,7 +162,7 @@ struct alc_spec { ...@@ -164,7 +162,7 @@ struct alc_spec {
/* capture source */ /* capture source */
unsigned int num_mux_defs; unsigned int num_mux_defs;
const struct hda_input_mux *input_mux; struct hda_input_mux input_mux;
unsigned int cur_mux[3]; unsigned int cur_mux[3];
hda_nid_t ext_mic_pin; hda_nid_t ext_mic_pin;
hda_nid_t dock_mic_pin; hda_nid_t dock_mic_pin;
...@@ -184,10 +182,7 @@ struct alc_spec { ...@@ -184,10 +182,7 @@ struct alc_spec {
struct auto_pin_cfg autocfg; struct auto_pin_cfg autocfg;
struct alc_customize_define cdefine; struct alc_customize_define cdefine;
struct snd_array kctls; struct snd_array kctls;
struct hda_input_mux private_imux[3];
hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS];
unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS];
int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */
...@@ -291,7 +286,7 @@ static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, ...@@ -291,7 +286,7 @@ static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
return snd_hda_input_mux_info(&spec->input_mux[0], uinfo); return snd_hda_input_mux_info(&spec->input_mux, uinfo);
} }
static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
...@@ -374,8 +369,8 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, ...@@ -374,8 +369,8 @@ static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx,
const struct hda_input_mux *imux; const struct hda_input_mux *imux;
struct nid_path *path; struct nid_path *path;
imux = spec->input_mux; imux = &spec->input_mux;
if (!imux || !imux->num_items) if (!imux->num_items)
return 0; return 0;
if (idx >= imux->num_items) if (idx >= imux->num_items)
...@@ -632,8 +627,6 @@ static void alc_mic_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) ...@@ -632,8 +627,6 @@ static void alc_mic_automute(struct hda_codec *codec, struct hda_jack_tbl *jack)
if (!spec->auto_mic || !spec->auto_mic_valid_imux) if (!spec->auto_mic || !spec->auto_mic_valid_imux)
return; return;
if (snd_BUG_ON(!spec->adc_nids))
return;
if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0)) if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0))
return; return;
...@@ -998,7 +991,7 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec) ...@@ -998,7 +991,7 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec)
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
const struct hda_input_mux *imux; const struct hda_input_mux *imux;
imux = spec->input_mux; imux = &spec->input_mux;
spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin,
spec->imux_pins, imux->num_items); spec->imux_pins, imux->num_items);
spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin,
...@@ -1441,7 +1434,7 @@ static int alc_cap_put_caller(struct snd_kcontrol *kcontrol, ...@@ -1441,7 +1434,7 @@ static int alc_cap_put_caller(struct snd_kcontrol *kcontrol,
struct nid_path *path; struct nid_path *path;
int i, adc_idx, err = 0; int i, adc_idx, err = 0;
imux = spec->input_mux; imux = &spec->input_mux;
adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
mutex_lock(&codec->control_mutex); mutex_lock(&codec->control_mutex);
codec->cached_write = 1; codec->cached_write = 1;
...@@ -1488,7 +1481,7 @@ static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, ...@@ -1488,7 +1481,7 @@ static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx) static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
struct hda_input_mux *imux = &spec->private_imux[0]; struct hda_input_mux *imux = &spec->input_mux;
struct nid_path *path; struct nid_path *path;
hda_nid_t nid; hda_nid_t nid;
int i, dir, parm; int i, dir, parm;
...@@ -1650,11 +1643,6 @@ static int __alc_build_controls(struct hda_codec *codec) ...@@ -1650,11 +1643,6 @@ static int __alc_build_controls(struct hda_codec *codec)
if (err < 0) if (err < 0)
return err; return err;
} }
if (spec->cap_mixer) {
err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
if (err < 0)
return err;
}
if (spec->multiout.dig_out_nid) { if (spec->multiout.dig_out_nid) {
err = snd_hda_create_dig_out_ctls(codec, err = snd_hda_create_dig_out_ctls(codec,
spec->multiout.dig_out_nid, spec->multiout.dig_out_nid,
...@@ -2014,7 +2002,7 @@ static int alc_build_pcms(struct hda_codec *codec) ...@@ -2014,7 +2002,7 @@ static int alc_build_pcms(struct hda_codec *codec)
info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap =
snd_pcm_2_1_chmaps; snd_pcm_2_1_chmaps;
} }
if (spec->adc_nids) { if (spec->num_adc_nids) {
p = spec->stream_analog_capture; p = spec->stream_analog_capture;
if (!p) { if (!p) {
if (spec->dyn_adc_switch) if (spec->dyn_adc_switch)
...@@ -2074,8 +2062,7 @@ static int alc_build_pcms(struct hda_codec *codec) ...@@ -2074,8 +2062,7 @@ static int alc_build_pcms(struct hda_codec *codec)
* model, configure a second analog capture-only PCM. * model, configure a second analog capture-only PCM.
*/ */
have_multi_adcs = (spec->num_adc_nids > 1) && have_multi_adcs = (spec->num_adc_nids > 1) &&
!spec->dyn_adc_switch && !spec->auto_mic && !spec->dyn_adc_switch && !spec->auto_mic;
(!spec->input_mux || spec->input_mux->num_items > 1);
/* Additional Analaog capture for index #2 */ /* Additional Analaog capture for index #2 */
if (spec->alt_dac_nid || have_multi_adcs) { if (spec->alt_dac_nid || have_multi_adcs) {
codec->num_pcms = 3; codec->num_pcms = 3;
...@@ -2442,8 +2429,8 @@ static int alc_auto_fill_adc_nids(struct hda_codec *codec) ...@@ -2442,8 +2429,8 @@ static int alc_auto_fill_adc_nids(struct hda_codec *codec)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
hda_nid_t nid; hda_nid_t nid;
hda_nid_t *adc_nids = spec->private_adc_nids; hda_nid_t *adc_nids = spec->adc_nids;
int max_nums = ARRAY_SIZE(spec->private_adc_nids); int max_nums = ARRAY_SIZE(spec->adc_nids);
int i, nums = 0; int i, nums = 0;
nid = codec->start_nid; nid = codec->start_nid;
...@@ -2457,7 +2444,6 @@ static int alc_auto_fill_adc_nids(struct hda_codec *codec) ...@@ -2457,7 +2444,6 @@ static int alc_auto_fill_adc_nids(struct hda_codec *codec)
if (++nums >= max_nums) if (++nums >= max_nums)
break; break;
} }
spec->adc_nids = spec->private_adc_nids;
spec->num_adc_nids = nums; spec->num_adc_nids = nums;
return nums; return nums;
} }
...@@ -2468,8 +2454,8 @@ static int alc_auto_fill_adc_nids(struct hda_codec *codec) ...@@ -2468,8 +2454,8 @@ static int alc_auto_fill_adc_nids(struct hda_codec *codec)
static int check_dyn_adc_switch(struct hda_codec *codec) static int check_dyn_adc_switch(struct hda_codec *codec)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
struct hda_input_mux *imux = &spec->private_imux[0]; struct hda_input_mux *imux = &spec->input_mux;
hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; hda_nid_t adc_nids[ARRAY_SIZE(spec->adc_nids)];
int i, n, nums; int i, n, nums;
hda_nid_t pin, adc; hda_nid_t pin, adc;
...@@ -2489,7 +2475,7 @@ static int check_dyn_adc_switch(struct hda_codec *codec) ...@@ -2489,7 +2475,7 @@ static int check_dyn_adc_switch(struct hda_codec *codec)
if (!nums) { if (!nums) {
if (spec->shared_mic_hp) { if (spec->shared_mic_hp) {
spec->shared_mic_hp = 0; spec->shared_mic_hp = 0;
spec->private_imux[0].num_items = 1; imux->num_items = 1;
goto again; goto again;
} }
...@@ -2508,12 +2494,11 @@ static int check_dyn_adc_switch(struct hda_codec *codec) ...@@ -2508,12 +2494,11 @@ static int check_dyn_adc_switch(struct hda_codec *codec)
snd_printdd("realtek: enabling ADC switching\n"); snd_printdd("realtek: enabling ADC switching\n");
spec->dyn_adc_switch = 1; spec->dyn_adc_switch = 1;
} else if (nums != spec->num_adc_nids) { } else if (nums != spec->num_adc_nids) {
memcpy(spec->private_adc_nids, adc_nids, memcpy(spec->adc_nids, adc_nids, nums * sizeof(hda_nid_t));
nums * sizeof(hda_nid_t));
spec->num_adc_nids = nums; spec->num_adc_nids = nums;
} }
if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) { if (imux->num_items == 1 || spec->shared_mic_hp) {
snd_printdd("realtek: reducing to a single ADC\n"); snd_printdd("realtek: reducing to a single ADC\n");
spec->num_adc_nids = 1; /* reduce to a single ADC */ spec->num_adc_nids = 1; /* reduce to a single ADC */
} }
...@@ -2592,7 +2577,7 @@ static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path) ...@@ -2592,7 +2577,7 @@ static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path)
static int create_capture_mixers(struct hda_codec *codec) static int create_capture_mixers(struct hda_codec *codec)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
struct hda_input_mux *imux = &spec->private_imux[0]; struct hda_input_mux *imux = &spec->input_mux;
struct snd_kcontrol_new *knew; struct snd_kcontrol_new *knew;
int i, n, nums; int i, n, nums;
...@@ -2654,7 +2639,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec) ...@@ -2654,7 +2639,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
const struct auto_pin_cfg *cfg = &spec->autocfg; const struct auto_pin_cfg *cfg = &spec->autocfg;
hda_nid_t mixer = spec->mixer_nid; hda_nid_t mixer = spec->mixer_nid;
struct hda_input_mux *imux = &spec->private_imux[0]; struct hda_input_mux *imux = &spec->input_mux;
int num_adcs; int num_adcs;
int i, c, err, type_idx = 0; int i, c, err, type_idx = 0;
const char *prev_label = NULL; const char *prev_label = NULL;
...@@ -2718,7 +2703,6 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec) ...@@ -2718,7 +2703,6 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
} }
} }
spec->input_mux = imux;
return 0; return 0;
} }
...@@ -4187,7 +4171,7 @@ static void alc_auto_init_multi_io(struct hda_codec *codec) ...@@ -4187,7 +4171,7 @@ static void alc_auto_init_multi_io(struct hda_codec *codec)
static void alc_auto_init_input_src(struct hda_codec *codec) static void alc_auto_init_input_src(struct hda_codec *codec)
{ {
struct alc_spec *spec = codec->spec; struct alc_spec *spec = codec->spec;
struct hda_input_mux *imux = &spec->private_imux[0]; struct hda_input_mux *imux = &spec->input_mux;
struct nid_path *path; struct nid_path *path;
int i, c, nums; int i, c, nums;
......
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