aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-12-07 07:56:29 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:30:40 -0500
commit4a471b7ddfe76e39c1633d5a23a687f4b5fc0d8d (patch)
tree7ec3b5952d03751e5d5da2d6254f8ce63ba2ba05 /sound/pci
parentf7a9275d949cb0bf1f259a1546e52a0bf518151c (diff)
[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>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_codec.c6
-rw-r--r--sound/pci/hda/hda_local.h2
-rw-r--r--sound/pci/hda/patch_analog.c8
-rw-r--r--sound/pci/hda/patch_realtek.c87
-rw-r--r--sound/pci/hda/patch_sigmatel.c5
5 files changed, 56 insertions, 52 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index bd375f895ec0..4a6dd97deba6 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -2051,6 +2051,12 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c
2051 return 0; 2051 return 0;
2052} 2052}
2053 2053
2054/* labels for input pins */
2055const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = {
2056 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
2057};
2058
2059
2054#ifdef CONFIG_PM 2060#ifdef CONFIG_PM
2055/* 2061/*
2056 * power management 2062 * power management
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index a9863eb20c75..c82d2a72d13e 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -211,6 +211,8 @@ enum {
211 AUTO_PIN_LAST 211 AUTO_PIN_LAST
212}; 212};
213 213
214extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST];
215
214struct auto_pin_cfg { 216struct auto_pin_cfg {
215 int line_outs; 217 int line_outs;
216 hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ 218 hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index d1e1ded27532..1ada1b075c9a 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -1850,18 +1850,16 @@ static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin,
1850static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, 1850static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec,
1851 const struct auto_pin_cfg *cfg) 1851 const struct auto_pin_cfg *cfg)
1852{ 1852{
1853 static char *labels[AUTO_PIN_LAST] = {
1854 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
1855 };
1856 struct hda_input_mux *imux = &spec->private_imux; 1853 struct hda_input_mux *imux = &spec->private_imux;
1857 int i, err; 1854 int i, err;
1858 1855
1859 for (i = 0; i < AUTO_PIN_LAST; i++) { 1856 for (i = 0; i < AUTO_PIN_LAST; i++) {
1860 err = new_analog_input(spec, cfg->input_pins[i], labels[i], 1857 err = new_analog_input(spec, cfg->input_pins[i],
1858 auto_pin_cfg_labels[i],
1861 i <= AUTO_PIN_FRONT_MIC); 1859 i <= AUTO_PIN_FRONT_MIC);
1862 if (err < 0) 1860 if (err < 0)
1863 return err; 1861 return err;
1864 imux->items[imux->num_items].label = labels[i]; 1862 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1865 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); 1863 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]);
1866 imux->num_items++; 1864 imux->num_items++;
1867 } 1865 }
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 2a6a4804cb92..cac109268f73 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1259,18 +1259,24 @@ static int alc_build_pcms(struct hda_codec *codec)
1259 codec->num_pcms = 1; 1259 codec->num_pcms = 1;
1260 codec->pcm_info = info; 1260 codec->pcm_info = info;
1261 1261
1262 snd_assert(spec->stream_analog_playback, return -EINVAL);
1263 snd_assert(spec->stream_analog_capture, return -EINVAL);
1264 info->name = spec->stream_name_analog; 1262 info->name = spec->stream_name_analog;
1265 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 1263 if (spec->stream_analog_playback) {
1266 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 1264 snd_assert(spec->multiout.dac_nids, return -EINVAL);
1267 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 1265 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
1268 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 1266 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
1269 1267 }
1270 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; 1268 if (spec->stream_analog_capture) {
1271 for (i = 0; i < spec->num_channel_mode; i++) { 1269 snd_assert(spec->adc_nids, return -EINVAL);
1272 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { 1270 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
1273 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; 1271 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1272 }
1273
1274 if (spec->channel_mode) {
1275 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
1276 for (i = 0; i < spec->num_channel_mode; i++) {
1277 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
1278 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
1279 }
1274 } 1280 }
1275 } 1281 }
1276 1282
@@ -1278,13 +1284,13 @@ static int alc_build_pcms(struct hda_codec *codec)
1278 codec->num_pcms++; 1284 codec->num_pcms++;
1279 info++; 1285 info++;
1280 info->name = spec->stream_name_digital; 1286 info->name = spec->stream_name_digital;
1281 if (spec->multiout.dig_out_nid) { 1287 if (spec->multiout.dig_out_nid &&
1282 snd_assert(spec->stream_digital_playback, return -EINVAL); 1288 spec->stream_digital_playback) {
1283 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 1289 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
1284 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 1290 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1285 } 1291 }
1286 if (spec->dig_in_nid) { 1292 if (spec->dig_in_nid &&
1287 snd_assert(spec->stream_digital_capture, return -EINVAL); 1293 spec->stream_digital_capture) {
1288 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); 1294 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
1289 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 1295 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1290 } 1296 }
@@ -2091,20 +2097,18 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ct
2091static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 2097static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
2092 const struct auto_pin_cfg *cfg) 2098 const struct auto_pin_cfg *cfg)
2093{ 2099{
2094 static char *labels[AUTO_PIN_LAST] = {
2095 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
2096 };
2097 struct hda_input_mux *imux = &spec->private_imux; 2100 struct hda_input_mux *imux = &spec->private_imux;
2098 int i, err, idx; 2101 int i, err, idx;
2099 2102
2100 for (i = 0; i < AUTO_PIN_LAST; i++) { 2103 for (i = 0; i < AUTO_PIN_LAST; i++) {
2101 if (alc880_is_input_pin(cfg->input_pins[i])) { 2104 if (alc880_is_input_pin(cfg->input_pins[i])) {
2102 idx = alc880_input_pin_idx(cfg->input_pins[i]); 2105 idx = alc880_input_pin_idx(cfg->input_pins[i]);
2103 err = new_analog_input(spec, cfg->input_pins[i], labels[i], 2106 err = new_analog_input(spec, cfg->input_pins[i],
2107 auto_pin_cfg_labels[i],
2104 idx, 0x0b); 2108 idx, 0x0b);
2105 if (err < 0) 2109 if (err < 0)
2106 return err; 2110 return err;
2107 imux->items[imux->num_items].label = labels[i]; 2111 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2108 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); 2112 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
2109 imux->num_items++; 2113 imux->num_items++;
2110 } 2114 }
@@ -2664,6 +2668,8 @@ static struct hda_verb alc260_fujitsu_init_verbs[] = {
2664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 2668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
2665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 2669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
2666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 2670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
2671
2672 { }
2667}; 2673};
2668 2674
2669static struct hda_pcm_stream alc260_pcm_analog_playback = { 2675static struct hda_pcm_stream alc260_pcm_analog_playback = {
@@ -2755,28 +2761,27 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
2755static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 2761static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
2756 const struct auto_pin_cfg *cfg) 2762 const struct auto_pin_cfg *cfg)
2757{ 2763{
2758 static char *labels[AUTO_PIN_LAST] = {
2759 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
2760 };
2761 struct hda_input_mux *imux = &spec->private_imux; 2764 struct hda_input_mux *imux = &spec->private_imux;
2762 int i, err, idx; 2765 int i, err, idx;
2763 2766
2764 for (i = 0; i < AUTO_PIN_LAST; i++) { 2767 for (i = 0; i < AUTO_PIN_LAST; i++) {
2765 if (cfg->input_pins[i] >= 0x12) { 2768 if (cfg->input_pins[i] >= 0x12) {
2766 idx = cfg->input_pins[i] - 0x12; 2769 idx = cfg->input_pins[i] - 0x12;
2767 err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); 2770 err = new_analog_input(spec, cfg->input_pins[i],
2771 auto_pin_cfg_labels[i], idx, 0x07);
2768 if (err < 0) 2772 if (err < 0)
2769 return err; 2773 return err;
2770 imux->items[imux->num_items].label = labels[i]; 2774 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2771 imux->items[imux->num_items].index = idx; 2775 imux->items[imux->num_items].index = idx;
2772 imux->num_items++; 2776 imux->num_items++;
2773 } 2777 }
2774 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ 2778 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
2775 idx = cfg->input_pins[i] - 0x09; 2779 idx = cfg->input_pins[i] - 0x09;
2776 err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); 2780 err = new_analog_input(spec, cfg->input_pins[i],
2781 auto_pin_cfg_labels[i], idx, 0x07);
2777 if (err < 0) 2782 if (err < 0)
2778 return err; 2783 return err;
2779 imux->items[imux->num_items].label = labels[i]; 2784 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2780 imux->items[imux->num_items].index = idx; 2785 imux->items[imux->num_items].index = idx;
2781 imux->num_items++; 2786 imux->num_items++;
2782 } 2787 }
@@ -2889,11 +2894,11 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
2889 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 2894 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
2890 alc260_ignore)) < 0) 2895 alc260_ignore)) < 0)
2891 return err; 2896 return err;
2892 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 2897 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
2893 ! spec->autocfg.hp_pin) 2898 return err;
2899 if (! spec->kctl_alloc)
2894 return 0; /* can't find valid BIOS pin config */ 2900 return 0; /* can't find valid BIOS pin config */
2895 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 2901 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2896 (err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
2897 return err; 2902 return err;
2898 2903
2899 spec->multiout.max_channels = 2; 2904 spec->multiout.max_channels = 2;
@@ -2908,19 +2913,18 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
2908 spec->input_mux = &spec->private_imux; 2913 spec->input_mux = &spec->private_imux;
2909 2914
2910 /* check whether NID 0x04 is valid */ 2915 /* check whether NID 0x04 is valid */
2911 wcap = snd_hda_param_read(codec, alc260_adc_nids[0], AC_PAR_AUDIO_WIDGET_CAP); 2916 wcap = get_wcaps(codec, 0x04);
2912 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 2917 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
2913 if (wcap != AC_WID_AUD_IN) { 2918 if (wcap != AC_WID_AUD_IN) {
2914 spec->adc_nids = alc260_adc_nids_alt; 2919 spec->adc_nids = alc260_adc_nids_alt;
2915 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); 2920 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
2916 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; 2921 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
2917 spec->num_mixers++;
2918 } else { 2922 } else {
2919 spec->adc_nids = alc260_adc_nids; 2923 spec->adc_nids = alc260_adc_nids;
2920 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 2924 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
2921 spec->mixers[spec->num_mixers] = alc260_capture_mixer; 2925 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
2922 spec->num_mixers++;
2923 } 2926 }
2927 spec->num_mixers++;
2924 2928
2925 return 1; 2929 return 1;
2926} 2930}
@@ -3582,8 +3586,7 @@ static int patch_alc882(struct hda_codec *codec)
3582 3586
3583 if (! spec->adc_nids && spec->input_mux) { 3587 if (! spec->adc_nids && spec->input_mux) {
3584 /* check whether NID 0x07 is valid */ 3588 /* check whether NID 0x07 is valid */
3585 unsigned int wcap = snd_hda_param_read(codec, 0x07, 3589 unsigned int wcap = get_wcaps(codec, 0x07);
3586 AC_PAR_AUDIO_WIDGET_CAP);
3587 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3590 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3588 if (wcap != AC_WID_AUD_IN) { 3591 if (wcap != AC_WID_AUD_IN) {
3589 spec->adc_nids = alc882_adc_nids_alt; 3592 spec->adc_nids = alc882_adc_nids_alt;
@@ -3991,8 +3994,8 @@ static int patch_alc262(struct hda_codec *codec)
3991 3994
3992 if (! spec->adc_nids && spec->input_mux) { 3995 if (! spec->adc_nids && spec->input_mux) {
3993 /* check whether NID 0x07 is valid */ 3996 /* check whether NID 0x07 is valid */
3994 unsigned int wcap = snd_hda_param_read(codec, 0x07, 3997 unsigned int wcap = get_wcaps(codec, 0x07);
3995 AC_PAR_AUDIO_WIDGET_CAP); 3998
3996 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3999 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
3997 if (wcap != AC_WID_AUD_IN) { 4000 if (wcap != AC_WID_AUD_IN) {
3998 spec->adc_nids = alc262_adc_nids_alt; 4001 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)
4423/* create playback/capture controls for input pins */ 4426/* create playback/capture controls for input pins */
4424static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 4427static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
4425{ 4428{
4426 static char *labels[AUTO_PIN_LAST] = {
4427 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
4428 };
4429 struct hda_input_mux *imux = &spec->private_imux; 4429 struct hda_input_mux *imux = &spec->private_imux;
4430 int i, err, idx, idx1; 4430 int i, err, idx, idx1;
4431 4431
@@ -4455,11 +4455,12 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str
4455 continue; 4455 continue;
4456 } 4456 }
4457 4457
4458 err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x15); 4458 err = new_analog_input(spec, cfg->input_pins[i],
4459 auto_pin_cfg_labels[i], idx, 0x15);
4459 if (err < 0) 4460 if (err < 0)
4460 return err; 4461 return err;
4461 4462
4462 imux->items[imux->num_items].label = labels[i]; 4463 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
4463 imux->items[imux->num_items].index = idx1; 4464 imux->items[imux->num_items].index = idx1;
4464 imux->num_items++; 4465 imux->num_items++;
4465 } 4466 }
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 8311c9fa0527..61903848cd43 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -702,9 +702,6 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin
702static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 702static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
703{ 703{
704 struct sigmatel_spec *spec = codec->spec; 704 struct sigmatel_spec *spec = codec->spec;
705 static char *labels[AUTO_PIN_LAST] = {
706 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux"
707 };
708 struct hda_input_mux *imux = &spec->private_imux; 705 struct hda_input_mux *imux = &spec->private_imux;
709 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 706 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
710 int i, j, k; 707 int i, j, k;
@@ -715,7 +712,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
715 /* Enable active pin widget as an input */ 712 /* Enable active pin widget as an input */
716 stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN); 713 stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN);
717 714
718 imux->items[imux->num_items].label = labels[i]; 715 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
719 716
720 for (j=0; j<spec->num_muxes; j++) { 717 for (j=0; j<spec->num_muxes; j++) {
721 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS); 718 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);