[ALSA] hda-codec - Small clean up and fixes

Modules: HDA Codec driver,HDA generic driver

- Common labels for input pins
- Fix and clean up of Realtek codec parsers

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2005-12-07 13:56:29 +01:00 committed by Jaroslav Kysela
parent f7a9275d94
commit 4a471b7ddf
5 changed files with 55 additions and 51 deletions

View File

@ -2051,6 +2051,12 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
return 0; return 0;
} }
/* labels for input pins */
const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
"Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
};
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* /*
* power management * power management

View File

@ -211,6 +211,8 @@ enum {
AUTO_PIN_LAST AUTO_PIN_LAST
}; };
extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
struct auto_pin_cfg { struct auto_pin_cfg {
int line_outs; int line_outs;
hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */

View File

@ -1850,18 +1850,16 @@ static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
const struct auto_pin_cfg *cfg) const struct auto_pin_cfg *cfg)
{ {
static char *labels[AUTO_PIN_LAST] = {
"Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
};
struct hda_input_mux *imux = &spec->private_imux; struct hda_input_mux *imux = &spec->private_imux;
int i, err; int i, err;
for (i = 0; i < AUTO_PIN_LAST; i++) { for (i = 0; i < AUTO_PIN_LAST; i++) {
err = new_analog_input(spec, cfg->input_pins[i], labels[i], err = new_analog_input(spec, cfg->input_pins[i],
auto_pin_cfg_labels[i],
i <= AUTO_PIN_FRONT_MIC); i <= AUTO_PIN_FRONT_MIC);
if (err < 0) if (err < 0)
return err; return err;
imux->items[imux->num_items].label = labels[i]; imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
imux->num_items++; imux->num_items++;
} }

View File

@ -1259,18 +1259,24 @@ static int alc_build_pcms(struct hda_codec *codec)
codec->num_pcms = 1; codec->num_pcms = 1;
codec->pcm_info = info; codec->pcm_info = info;
snd_assert(spec->stream_analog_playback, return -EINVAL);
snd_assert(spec->stream_analog_capture, return -EINVAL);
info->name = spec->stream_name_analog; info->name = spec->stream_name_analog;
info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); if (spec->stream_analog_playback) {
info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; snd_assert(spec->multiout.dac_nids, return -EINVAL);
info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
}
if (spec->stream_analog_capture) {
snd_assert(spec->adc_nids, return -EINVAL);
info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
}
info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; if (spec->channel_mode) {
for (i = 0; i < spec->num_channel_mode; i++) { info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { for (i = 0; i < spec->num_channel_mode; i++) {
info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
}
} }
} }
@ -1278,13 +1284,13 @@ static int alc_build_pcms(struct hda_codec *codec)
codec->num_pcms++; codec->num_pcms++;
info++; info++;
info->name = spec->stream_name_digital; info->name = spec->stream_name_digital;
if (spec->multiout.dig_out_nid) { if (spec->multiout.dig_out_nid &&
snd_assert(spec->stream_digital_playback, return -EINVAL); spec->stream_digital_playback) {
info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
} }
if (spec->dig_in_nid) { if (spec->dig_in_nid &&
snd_assert(spec->stream_digital_capture, return -EINVAL); spec->stream_digital_capture) {
info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
} }
@ -2091,20 +2097,18 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ct
static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
const struct auto_pin_cfg *cfg) const struct auto_pin_cfg *cfg)
{ {
static char *labels[AUTO_PIN_LAST] = {
"Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
};
struct hda_input_mux *imux = &spec->private_imux; struct hda_input_mux *imux = &spec->private_imux;
int i, err, idx; int i, err, idx;
for (i = 0; i < AUTO_PIN_LAST; i++) { for (i = 0; i < AUTO_PIN_LAST; i++) {
if (alc880_is_input_pin(cfg->input_pins[i])) { if (alc880_is_input_pin(cfg->input_pins[i])) {
idx = alc880_input_pin_idx(cfg->input_pins[i]); idx = alc880_input_pin_idx(cfg->input_pins[i]);
err = new_analog_input(spec, cfg->input_pins[i], labels[i], err = new_analog_input(spec, cfg->input_pins[i],
auto_pin_cfg_labels[i],
idx, 0x0b); idx, 0x0b);
if (err < 0) if (err < 0)
return err; return err;
imux->items[imux->num_items].label = labels[i]; imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
imux->num_items++; imux->num_items++;
} }
@ -2664,6 +2668,8 @@ static struct hda_verb alc260_fujitsu_init_verbs[] = {
{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
{0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
{ }
}; };
static struct hda_pcm_stream alc260_pcm_analog_playback = { static struct hda_pcm_stream alc260_pcm_analog_playback = {
@ -2755,28 +2761,27 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
const struct auto_pin_cfg *cfg) const struct auto_pin_cfg *cfg)
{ {
static char *labels[AUTO_PIN_LAST] = {
"Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
};
struct hda_input_mux *imux = &spec->private_imux; struct hda_input_mux *imux = &spec->private_imux;
int i, err, idx; int i, err, idx;
for (i = 0; i < AUTO_PIN_LAST; i++) { for (i = 0; i < AUTO_PIN_LAST; i++) {
if (cfg->input_pins[i] >= 0x12) { if (cfg->input_pins[i] >= 0x12) {
idx = cfg->input_pins[i] - 0x12; idx = cfg->input_pins[i] - 0x12;
err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); err = new_analog_input(spec, cfg->input_pins[i],
auto_pin_cfg_labels[i], idx, 0x07);
if (err < 0) if (err < 0)
return err; return err;
imux->items[imux->num_items].label = labels[i]; imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
imux->items[imux->num_items].index = idx; imux->items[imux->num_items].index = idx;
imux->num_items++; imux->num_items++;
} }
if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
idx = cfg->input_pins[i] - 0x09; idx = cfg->input_pins[i] - 0x09;
err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); err = new_analog_input(spec, cfg->input_pins[i],
auto_pin_cfg_labels[i], idx, 0x07);
if (err < 0) if (err < 0)
return err; return err;
imux->items[imux->num_items].label = labels[i]; imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
imux->items[imux->num_items].index = idx; imux->items[imux->num_items].index = idx;
imux->num_items++; imux->num_items++;
} }
@ -2889,11 +2894,11 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
alc260_ignore)) < 0) alc260_ignore)) < 0)
return err; return err;
if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
! spec->autocfg.hp_pin) return err;
if (! spec->kctl_alloc)
return 0; /* can't find valid BIOS pin config */ return 0; /* can't find valid BIOS pin config */
if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
(err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
return err; return err;
spec->multiout.max_channels = 2; spec->multiout.max_channels = 2;
@ -2908,19 +2913,18 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
spec->input_mux = &spec->private_imux; spec->input_mux = &spec->private_imux;
/* check whether NID 0x04 is valid */ /* check whether NID 0x04 is valid */
wcap = snd_hda_param_read(codec, alc260_adc_nids[0], AC_PAR_AUDIO_WIDGET_CAP); wcap = get_wcaps(codec, 0x04);
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
if (wcap != AC_WID_AUD_IN) { if (wcap != AC_WID_AUD_IN) {
spec->adc_nids = alc260_adc_nids_alt; spec->adc_nids = alc260_adc_nids_alt;
spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
spec->num_mixers++;
} else { } else {
spec->adc_nids = alc260_adc_nids; spec->adc_nids = alc260_adc_nids;
spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
spec->mixers[spec->num_mixers] = alc260_capture_mixer; spec->mixers[spec->num_mixers] = alc260_capture_mixer;
spec->num_mixers++;
} }
spec->num_mixers++;
return 1; return 1;
} }
@ -3582,8 +3586,7 @@ static int patch_alc882(struct hda_codec *codec)
if (! spec->adc_nids && spec->input_mux) { if (! spec->adc_nids && spec->input_mux) {
/* check whether NID 0x07 is valid */ /* check whether NID 0x07 is valid */
unsigned int wcap = snd_hda_param_read(codec, 0x07, unsigned int wcap = get_wcaps(codec, 0x07);
AC_PAR_AUDIO_WIDGET_CAP);
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
if (wcap != AC_WID_AUD_IN) { if (wcap != AC_WID_AUD_IN) {
spec->adc_nids = alc882_adc_nids_alt; spec->adc_nids = alc882_adc_nids_alt;
@ -3991,8 +3994,8 @@ static int patch_alc262(struct hda_codec *codec)
if (! spec->adc_nids && spec->input_mux) { if (! spec->adc_nids && spec->input_mux) {
/* check whether NID 0x07 is valid */ /* check whether NID 0x07 is valid */
unsigned int wcap = snd_hda_param_read(codec, 0x07, unsigned int wcap = get_wcaps(codec, 0x07);
AC_PAR_AUDIO_WIDGET_CAP);
wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
if (wcap != AC_WID_AUD_IN) { if (wcap != AC_WID_AUD_IN) {
spec->adc_nids = alc262_adc_nids_alt; spec->adc_nids = alc262_adc_nids_alt;
@ -4423,9 +4426,6 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
/* create playback/capture controls for input pins */ /* create playback/capture controls for input pins */
static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
{ {
static char *labels[AUTO_PIN_LAST] = {
"Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
};
struct hda_input_mux *imux = &spec->private_imux; struct hda_input_mux *imux = &spec->private_imux;
int i, err, idx, idx1; int i, err, idx, idx1;
@ -4455,11 +4455,12 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str
continue; continue;
} }
err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x15); err = new_analog_input(spec, cfg->input_pins[i],
auto_pin_cfg_labels[i], idx, 0x15);
if (err < 0) if (err < 0)
return err; return err;
imux->items[imux->num_items].label = labels[i]; imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
imux->items[imux->num_items].index = idx1; imux->items[imux->num_items].index = idx1;
imux->num_items++; imux->num_items++;
} }

View File

@ -702,9 +702,6 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin
static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
{ {
struct sigmatel_spec *spec = codec->spec; struct sigmatel_spec *spec = codec->spec;
static char *labels[AUTO_PIN_LAST] = {
"Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
};
struct hda_input_mux *imux = &spec->private_imux; struct hda_input_mux *imux = &spec->private_imux;
hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
int i, j, k; int i, j, k;
@ -715,7 +712,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
/* Enable active pin widget as an input */ /* Enable active pin widget as an input */
stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN); stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN);
imux->items[imux->num_items].label = labels[i]; imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
for (j=0; j<spec->num_muxes; j++) { for (j=0; j<spec->num_muxes; j++) {
int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS); int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);