From 23b224d9d42a111ce451e4300304415a0ba5da75 Mon Sep 17 00:00:00 2001 From: Garnet MacPhee Date: Sat, 21 Aug 2010 14:37:34 -0600 Subject: ALSA: ice1712: Add support for Edirol DA-2496 This device is similar to the M-Audio Delta 1010LT in that it uses the AK4524VF ADC/DAC, but it does not use the CS8427 for SPDIF. The SPDIF appears to be set up correctly, but I am not able to test it as I do not have any devices that use it. This patch makes the ADC/DAC's and the hardware mixer visible to apps such as alsamixer and envy24control. Signed-off-by: Garnet MacPhee Signed-off-by: Takashi Iwai --- sound/pci/ice1712/delta.c | 10 ++++++++++ sound/pci/ice1712/delta.h | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c index d216362626d..712c1710f9a 100644 --- a/sound/pci/ice1712/delta.c +++ b/sound/pci/ice1712/delta.c @@ -563,6 +563,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice) case ICE1712_SUBDEVICE_DELTA1010E: case ICE1712_SUBDEVICE_DELTA1010LT: case ICE1712_SUBDEVICE_MEDIASTATION: + case ICE1712_SUBDEVICE_EDIROLDA2496: ice->num_total_dacs = 8; ice->num_total_adcs = 8; break; @@ -635,6 +636,7 @@ static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice) err = snd_ice1712_akm4xxx_init(ak, &akm_delta410, &akm_delta410_priv, ice); break; case ICE1712_SUBDEVICE_DELTA1010LT: + case ICE1712_SUBDEVICE_EDIROLDA2496: err = snd_ice1712_akm4xxx_init(ak, &akm_delta1010lt, &akm_delta1010lt_priv, ice); break; case ICE1712_SUBDEVICE_DELTA66: @@ -734,6 +736,7 @@ static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice) case ICE1712_SUBDEVICE_DELTA66: case ICE1712_SUBDEVICE_VX442: case ICE1712_SUBDEVICE_DELTA66E: + case ICE1712_SUBDEVICE_EDIROLDA2496: err = snd_ice1712_akm4xxx_build_controls(ice); if (err < 0) return err; @@ -813,5 +816,12 @@ struct snd_ice1712_card_info snd_ice1712_delta_cards[] __devinitdata = { .chip_init = snd_ice1712_delta_init, .build_controls = snd_ice1712_delta_add_controls, }, + { + .subvendor = ICE1712_SUBDEVICE_EDIROLDA2496, + .name = "Edirol DA2496", + .model = "da2496", + .chip_init = snd_ice1712_delta_init, + .build_controls = snd_ice1712_delta_add_controls, + }, { } /* terminator */ }; diff --git a/sound/pci/ice1712/delta.h b/sound/pci/ice1712/delta.h index f7f14df81f2..1a0ac6cd650 100644 --- a/sound/pci/ice1712/delta.h +++ b/sound/pci/ice1712/delta.h @@ -34,7 +34,8 @@ "{MidiMan M Audio,Delta 410},"\ "{MidiMan M Audio,Audiophile 24/96},"\ "{Digigram,VX442},"\ - "{Lionstracs,Mediastation}," + "{Lionstracs,Mediastation},"\ + "{Edirol,DA2496}," #define ICE1712_SUBDEVICE_DELTA1010 0x121430d6 #define ICE1712_SUBDEVICE_DELTA1010E 0xff1430d6 @@ -47,6 +48,7 @@ #define ICE1712_SUBDEVICE_DELTA1010LT 0x12143bd6 #define ICE1712_SUBDEVICE_VX442 0x12143cd6 #define ICE1712_SUBDEVICE_MEDIASTATION 0x694c0100 +#define ICE1712_SUBDEVICE_EDIROLDA2496 0xce164010 /* entry point */ extern struct snd_ice1712_card_info snd_ice1712_delta_cards[]; -- cgit v1.2.3 From 73413b120d5d6eb6c98451bbc19acf43e0e300ae Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 09:39:57 +0200 Subject: ALSA: hda - embed alc_fixup contents into struct definitions Instead of defining each content as a separate struct, put all into the definition of struct alc_fixup arrays so that reader doesn't go back to see the definition again. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 70 ++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 41 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 627bf996336..50e0c82fd99 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -6799,14 +6799,12 @@ enum { PINFIX_HP_DC5750, }; -static struct alc_pincfg alc260_hp_dc5750_pinfix[] = { - { 0x11, 0x90130110 }, /* speaker */ - { } -}; - static const struct alc_fixup alc260_fixups[] = { [PINFIX_HP_DC5750] = { - .pins = alc260_hp_dc5750_pinfix + .pins = (const struct alc_pincfg[]) { + { 0x11, 0x90130110 }, /* speaker */ + { } + } }, }; @@ -10452,24 +10450,20 @@ enum { PINFIX_PB_M5210, }; -static struct alc_pincfg alc882_abit_aw9d_pinfix[] = { - { 0x15, 0x01080104 }, /* side */ - { 0x16, 0x01011012 }, /* rear */ - { 0x17, 0x01016011 }, /* clfe */ - { } -}; - -static const struct hda_verb pb_m5210_verbs[] = { - { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, - {} -}; - static const struct alc_fixup alc882_fixups[] = { [PINFIX_ABIT_AW9D_MAX] = { - .pins = alc882_abit_aw9d_pinfix + .pins = (const struct alc_pincfg[]) { + { 0x15, 0x01080104 }, /* side */ + { 0x16, 0x01011012 }, /* rear */ + { 0x17, 0x01016011 }, /* clfe */ + { } + } }, [PINFIX_PB_M5210] = { - .verbs = pb_m5210_verbs + .verbs = (const struct hda_verb[]) { + { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, + {} + } }, }; @@ -14454,14 +14448,12 @@ enum { ALC269_FIXUP_SONY_VAIO, }; -static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = { - {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, - {} -}; - static const struct alc_fixup alc269_fixups[] = { [ALC269_FIXUP_SONY_VAIO] = { - .verbs = alc269_sony_vaio_fixup_verbs + .verbs = (const struct hda_verb[]) { + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, + {} + } }, }; @@ -15819,15 +15811,13 @@ enum { PINFIX_FSC_AMILO_PI1505, }; -static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = { - { 0x0b, 0x0221101f }, /* HP */ - { 0x0f, 0x90170310 }, /* speaker */ - { } -}; - static const struct alc_fixup alc861_fixups[] = { [PINFIX_FSC_AMILO_PI1505] = { - .pins = alc861_fsc_amilo_pi1505_pinfix + .pins = (const struct alc_pincfg[]) { + { 0x0b, 0x0221101f }, /* HP */ + { 0x0f, 0x90170310 }, /* speaker */ + { } + } }, }; @@ -16794,16 +16784,14 @@ enum { }; /* reset GPIO1 */ -static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = { - {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, - {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, - {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, - { } -}; - static const struct alc_fixup alc861vd_fixups[] = { [ALC660VD_FIX_ASUS_GPIO1] = { - .verbs = alc660vd_fix_asus_gpio1_verbs, + .verbs = (const struct hda_verb[]) { + {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, + {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, + {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, + { } + } }, }; -- cgit v1.2.3 From f3268512c3a5dea587cfe875b8bca98d9e164cd9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 11:00:19 +0200 Subject: ALSA: hda - Refactor input-pin parser for VIA codecs patch_via.c has redundant codes for parsing the input-pins. Although they are pretty similar, but all implemented in different functions just because of hard-coded ids and slight incompatibilities. This patch refactors the codes to use the common helper function, resulting in the reduction of many lines. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_via.c | 390 +++++++--------------------------------------- 1 file changed, 60 insertions(+), 330 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index ae3acb2b42d..41861388f43 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -2413,51 +2413,53 @@ static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, - const struct auto_pin_cfg *cfg) +static int vt_auto_create_analog_input_ctls(struct via_spec *spec, + const struct auto_pin_cfg *cfg, + hda_nid_t cap_nid, + hda_nid_t pin_idxs[], int num_idxs) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; + int i, err, idx; /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = idx; - imux->num_items++; + for (idx = 0; idx < num_idxs; idx++) { + if (pin_idxs[idx] == 0xff) { + imux->items[imux->num_items].label = "Stereo Mixer"; + imux->items[imux->num_items].index = idx; + imux->num_items++; + break; + } + } for (i = 0; i < AUTO_PIN_LAST; i++) { if (!cfg->input_pins[i]) continue; - switch (cfg->input_pins[i]) { - case 0x1d: /* Mic */ - idx = 2; - break; - - case 0x1e: /* Line In */ - idx = 3; - break; - - case 0x21: /* Front Mic */ - idx = 4; - break; - - case 0x24: /* CD */ - idx = 1; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x17); + for (idx = 0; idx < num_idxs; idx++) + if (pin_idxs[idx] == cfg->input_pins[i]) + break; + if (idx >= num_idxs) + continue; + err = via_new_analog_input(spec, auto_pin_cfg_labels[i], + idx, cap_nid); if (err < 0) 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->num_items++; } return 0; } +/* create playback/capture controls for input pins */ +static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, + const struct auto_pin_cfg *cfg) +{ + static hda_nid_t pin_idxs[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 }; + return vt_auto_create_analog_input_ctls(spec, cfg, 0x17, pin_idxs, + ARRAY_SIZE(pin_idxs)); +} + #ifdef CONFIG_SND_HDA_POWER_SAVE static struct hda_amp_list vt1708_loopbacks[] = { { 0x17, HDA_INPUT, 1 }, @@ -3024,46 +3026,9 @@ static int vt1709_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; - struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = idx; - imux->num_items++; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x1d: /* Mic */ - idx = 2; - break; - - case 0x1e: /* Line In */ - idx = 3; - break; - - case 0x21: /* Front Mic */ - idx = 4; - break; - - case 0x23: /* CD */ - idx = 1; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x18); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx; - imux->num_items++; - } - return 0; + static hda_nid_t pin_idxs[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 }; + return vt_auto_create_analog_input_ctls(spec, cfg, 0x18, pin_idxs, + ARRAY_SIZE(pin_idxs)); } static int vt1709_parse_auto_config(struct hda_codec *codec) @@ -3591,46 +3556,9 @@ static int vt1708B_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt1708B_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; - struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = idx; - imux->num_items++; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x1a: /* Mic */ - idx = 2; - break; - - case 0x1b: /* Line In */ - idx = 3; - break; - - case 0x1e: /* Front Mic */ - idx = 4; - break; - - case 0x1f: /* CD */ - idx = 1; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x16); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx; - imux->num_items++; - } - return 0; + static hda_nid_t pin_idxs[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e }; + return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + ARRAY_SIZE(pin_idxs)); } static int vt1708B_parse_auto_config(struct hda_codec *codec) @@ -4064,46 +3992,9 @@ static int vt1708S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt1708S_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; - struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = 5; - imux->num_items++; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x1a: /* Mic */ - idx = 2; - break; - - case 0x1b: /* Line In */ - idx = 3; - break; - - case 0x1e: /* Front Mic */ - idx = 4; - break; - - case 0x1f: /* CD */ - idx = 1; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x16); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx-1; - imux->num_items++; - } - return 0; + static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; + return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + ARRAY_SIZE(pin_idxs)); } /* fill out digital output widgets; one for master and one for slave outputs */ @@ -4457,42 +4348,9 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt1702_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; - struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = 3; - imux->num_items++; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x14: /* Mic */ - idx = 1; - break; - - case 0x15: /* Line In */ - idx = 2; - break; - - case 0x18: /* Front Mic */ - idx = 3; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x1A); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx-1; - imux->num_items++; - } - return 0; + static hda_nid_t pin_idxs[] = { 0x14, 0x15, 0x18, 0xff }; + return vt_auto_create_analog_input_ctls(spec, cfg, 0x1a, pin_idxs, + ARRAY_SIZE(pin_idxs)); } static int vt1702_parse_auto_config(struct hda_codec *codec) @@ -4875,46 +4733,9 @@ static int vt1718S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt1718S_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; - struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = 5; - imux->num_items++; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x2b: /* Mic */ - idx = 1; - break; - - case 0x2a: /* Line In */ - idx = 2; - break; - - case 0x29: /* Front Mic */ - idx = 3; - break; - - case 0x2c: /* CD */ - idx = 0; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x21); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx; - imux->num_items++; - } - return 0; + static hda_nid_t pin_idxs[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff }; + return vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + ARRAY_SIZE(pin_idxs)); } static int vt1718S_parse_auto_config(struct hda_codec *codec) @@ -5374,46 +5195,9 @@ static int vt1716S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt1716S_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; - struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = 5; - imux->num_items++; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x1a: /* Mic */ - idx = 2; - break; - - case 0x1b: /* Line In */ - idx = 3; - break; - - case 0x1e: /* Front Mic */ - idx = 4; - break; - - case 0x1f: /* CD */ - idx = 1; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x16); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx-1; - imux->num_items++; - } - return 0; + static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; + return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + ARRAY_SIZE(pin_idxs)); } static int vt1716S_parse_auto_config(struct hda_codec *codec) @@ -5720,47 +5504,19 @@ static int vt2002P_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x2b: /* Mic */ - idx = 0; - break; - - case 0x2a: /* Line In */ - idx = 1; - break; - - case 0x29: /* Front Mic */ - idx = 2; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x21); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx; - imux->num_items++; - } + static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0xff }; + int err; + err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + ARRAY_SIZE(pin_idxs)); + if (err < 0) + return err; /* build volume/mute control of loopback */ err = via_new_analog_input(spec, "Stereo Mixer", 3, 0x21); if (err < 0) return err; - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = 3; - imux->num_items++; - /* for digital mic select */ imux->items[imux->num_items].label = "Digital Mic"; imux->items[imux->num_items].index = 4; @@ -6070,46 +5826,20 @@ static int vt1812_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux", NULL - }; struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx = 0; - - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - - switch (cfg->input_pins[i]) { - case 0x2b: /* Mic */ - idx = 0; - break; + static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff }; + int err; - case 0x2a: /* Line In */ - idx = 1; - break; + err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + ARRAY_SIZE(pin_idxs)); + if (err < 0) + return err; - case 0x29: /* Front Mic */ - idx = 2; - break; - } - err = via_new_analog_input(spec, labels[i], idx, 0x21); - if (err < 0) - return err; - imux->items[imux->num_items].label = labels[i]; - imux->items[imux->num_items].index = idx; - imux->num_items++; - } /* build volume/mute control of loopback */ err = via_new_analog_input(spec, "Stereo Mixer", 5, 0x21); if (err < 0) return err; - /* for internal loopback recording select */ - imux->items[imux->num_items].label = "Stereo Mixer"; - imux->items[imux->num_items].index = 5; - imux->num_items++; - /* for digital mic select */ imux->items[imux->num_items].label = "Digital Mic"; imux->items[imux->num_items].index = 6; -- cgit v1.2.3 From 75e0eb24ee3ec3549c2e53707dcc87e5f7a2c791 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 12:56:55 +0200 Subject: ALSA: hda - Add inputs[] to auto_pin_cfg struct Added the new fields to contain all input-pins to struct auto_pin_cfg. Unlike the existing input_pins[], this array contains all input pins even if the multiple pins are assigned for a single role (i.e. two front mics). The former input_pins[] still remains for a while, but will be removed in near future. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 40 +++++++++++++++++++++++++++++----------- sound/pci/hda/hda_local.h | 12 +++++++++++- 2 files changed, 40 insertions(+), 12 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 3827092cc1d..280a739c2a9 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4372,6 +4372,17 @@ static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences, } +/* add the found input-pin to the cfg->inputs[] table */ +static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid, + int type) +{ + if (cfg->num_inputs < AUTO_CFG_MAX_INS) { + cfg->inputs[cfg->num_inputs].pin = nid; + cfg->inputs[cfg->num_inputs].type = type; + cfg->num_inputs++; + } +} + /* * Parse all pin widgets and store the useful pin nids to cfg * @@ -4398,6 +4409,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, short sequences_line_out[ARRAY_SIZE(cfg->line_out_pins)]; short sequences_speaker[ARRAY_SIZE(cfg->speaker_pins)]; short sequences_hp[ARRAY_SIZE(cfg->hp_pins)]; + int i; memset(cfg, 0, sizeof(*cfg)); @@ -4482,19 +4494,26 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, cfg->input_pins[preferred] = nid; else if (!cfg->input_pins[alt]) cfg->input_pins[alt] = nid; + add_auto_cfg_input_pin(cfg, nid, preferred); break; } - case AC_JACK_LINE_IN: + case AC_JACK_LINE_IN: { + int type; if (loc == AC_JACK_LOC_FRONT) - cfg->input_pins[AUTO_PIN_FRONT_LINE] = nid; + type = AUTO_PIN_FRONT_LINE; else - cfg->input_pins[AUTO_PIN_LINE] = nid; + type = AUTO_PIN_LINE; + cfg->input_pins[type] = nid; + add_auto_cfg_input_pin(cfg, nid, type); break; + } case AC_JACK_CD: cfg->input_pins[AUTO_PIN_CD] = nid; + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_CD); break; case AC_JACK_AUX: cfg->input_pins[AUTO_PIN_AUX] = nid; + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_AUX); break; case AC_JACK_SPDIF_OUT: case AC_JACK_DIG_OTHER_OUT: @@ -4621,14 +4640,13 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, if (cfg->dig_outs) snd_printd(" dig-out=0x%x/0x%x\n", cfg->dig_out_pins[0], cfg->dig_out_pins[1]); - snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x," - " cd=0x%x, aux=0x%x\n", - cfg->input_pins[AUTO_PIN_MIC], - cfg->input_pins[AUTO_PIN_FRONT_MIC], - cfg->input_pins[AUTO_PIN_LINE], - cfg->input_pins[AUTO_PIN_FRONT_LINE], - cfg->input_pins[AUTO_PIN_CD], - cfg->input_pins[AUTO_PIN_AUX]); + snd_printd(" inputs:"); + for (i = 0; i < cfg->num_inputs; i++) { + snd_printdd(" %s=0x%x", + auto_pin_cfg_labels[cfg->inputs[i].type], + cfg->inputs[i].pin); + } + snd_printd("\n"); if (cfg->dig_in_pin) snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin); diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 28ab4aead48..44c909445ba 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -383,6 +383,14 @@ enum { extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; #define AUTO_CFG_MAX_OUTS 5 +#define AUTO_CFG_MAX_INS 8 + +struct auto_pin_cfg_item { + hda_nid_t pin; + int type; +}; + +struct auto_pin_cfg; struct auto_pin_cfg { int line_outs; @@ -393,7 +401,9 @@ struct auto_pin_cfg { int hp_outs; int line_out_type; /* AUTO_PIN_XXX_OUT */ hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; - hda_nid_t input_pins[AUTO_PIN_LAST]; + hda_nid_t input_pins[AUTO_PIN_LAST]; /* old config; to be deprecated */ + int num_inputs; + struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; int dig_outs; hda_nid_t dig_out_pins[2]; hda_nid_t dig_in_pin; -- cgit v1.2.3 From d7b1ae9d8851bd247590cf7ab53248a2dac0419f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:00:16 +0200 Subject: ALSA: hda - Add snd_hda_get_input_pin_label() helper function Added snd_hda_get_input_pin_label() helper function to return the string that can be used for control or capture-source ids. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 25 ++++++++++++++++++++++++- sound/pci/hda/hda_local.h | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 280a739c2a9..72334b7f60e 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4654,12 +4654,35 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); -/* labels for input pins */ +/* labels for input pins - for obsoleted config stuff */ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" }; EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); +static const char *input_labels[AUTO_PIN_LAST][4] = { + { "Mic", "Mic 2", "Mic 3", "Mic 4" }, + { "Front Mic", "Front Mic 2", "Front Mic 3", "Front Mic 4" }, + { "Line", "Line 2", "Line 3", "Line 4" }, + { "Front Line", "Front Line 2", "Front Line 3", "Front Line 4" }, + { "CD", "CD 2", "CD 3", "CD 4" }, + { "Aux", "Aux 2", "Aux 3", "Aux 4" }, +}; + +const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, + int input) +{ + int type = cfg->inputs[input].type; + int idx; + + for (idx = 0; idx < 3 && --input >= 0; idx++) { + if (type != cfg->inputs[input].type) + break; + } + return input_labels[type][idx]; +} +EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_label); + #ifdef CONFIG_PM /* diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 44c909445ba..fb561748adb 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -391,6 +391,8 @@ struct auto_pin_cfg_item { }; struct auto_pin_cfg; +const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, + int input); struct auto_pin_cfg { int line_outs; -- cgit v1.2.3 From 9e042e71325eeda03636aedfde6f2d27d6332188 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:04:44 +0200 Subject: ALSA: hda - Use new inputs[] field to parse input-pins for AD codecs Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index b697fd2a6f8..3409d315f50 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -2880,7 +2880,7 @@ static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, /* create input playback/capture controls for the given pin */ static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, - const char *ctlname, int boost) + const char *ctlname, int ctlidx, int boost) { char name[32]; int err, idx; @@ -2913,16 +2913,23 @@ static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, const struct auto_pin_cfg *cfg) { struct hda_input_mux *imux = &spec->private_imux; - int i, err; + int i, err, type, type_idx = 0; - for (i = 0; i < AUTO_PIN_LAST; i++) { - err = new_analog_input(spec, cfg->input_pins[i], - auto_pin_cfg_labels[i], - i <= AUTO_PIN_FRONT_MIC); + for (i = 0; i < cfg->num_inputs; i++) { + type = cfg->inputs[i].type; + if (i > 0 && type != cfg->inputs[i - 1].type) + type_idx++; + else + type_idx = 0; + err = new_analog_input(spec, cfg->inputs[i].pin, + auto_pin_cfg_labels[type], type_idx, + type <= AUTO_PIN_FRONT_MIC); if (err < 0) return err; - 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].label = + snd_hda_get_input_pin_label(cfg, i); + imux->items[imux->num_items].index = + ad1988_pin_to_adc_idx(cfg->inputs[i].pin); imux->num_items++; } imux->items[imux->num_items].label = "Mix"; @@ -2994,12 +3001,11 @@ static void ad1988_auto_init_extra_out(struct hda_codec *codec) static void ad1988_auto_init_analog_input(struct hda_codec *codec) { struct ad198x_spec *spec = codec->spec; + const struct auto_pin_cfg *cfg = &spec->autocfg; int i, idx; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; - if (! nid) - continue; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; switch (nid) { case 0x15: /* port-C */ snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); -- cgit v1.2.3 From fa4968a8b231816d161583e604a9f972e5713f17 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:05:08 +0200 Subject: ALSA: hda - Use new inputs[] field to parse input-pins for CA-IBG codecs Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_ca0110.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index af478019088..42b3fb4cafc 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c @@ -468,13 +468,14 @@ static void parse_input(struct hda_codec *codec) spec->dig_in = nid; continue; } - for (j = 0; j < AUTO_PIN_LAST; j++) - if (cfg->input_pins[j] == pin) + for (j = 0; j < cfg->num_inputs; j++) + if (cfg->inputs[j].pin == pin) break; - if (j >= AUTO_PIN_LAST) + if (j >= cfg->num_inputs) continue; spec->input_pins[n] = pin; - spec->input_labels[n] = auto_pin_cfg_labels[j]; + spec->input_labels[n] = + auto_pin_cfg_labels[cfg->inputs[j].type]; spec->adcs[n] = nid; n++; } -- cgit v1.2.3 From c1e0bb92174dd16ffba5be0e4e5fbd366f61ff7f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:05:30 +0200 Subject: ALSA: hda - Use new inputs[] field to parse input-pins for CirrusLogic codecs Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 4ef5efaaaef..ee1aea7296e 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -329,7 +329,7 @@ static int is_ext_mic(struct hda_codec *codec, unsigned int idx) { struct cs_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; - hda_nid_t pin = cfg->input_pins[idx]; + hda_nid_t pin = cfg->inputs[idx].pin; unsigned int val = snd_hda_query_pin_caps(codec, pin); if (!(val & AC_PINCAP_PRES_DETECT)) return 0; @@ -424,10 +424,8 @@ static int parse_input(struct hda_codec *codec) struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t pin = cfg->input_pins[i]; - if (!pin) - continue; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t pin = cfg->inputs[i].pin; spec->input_idx[spec->num_inputs] = i; spec->capsrc_idx[i] = spec->num_inputs++; spec->cur_input = i; @@ -438,16 +436,17 @@ static int parse_input(struct hda_codec *codec) /* check whether the automatic mic switch is available */ if (spec->num_inputs == 2 && - spec->adc_nid[AUTO_PIN_MIC] && spec->adc_nid[AUTO_PIN_FRONT_MIC]) { - if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_FRONT_MIC])) { - if (!is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { + cfg->inputs[0].type <= AUTO_PIN_FRONT_MIC && + cfg->inputs[1].type == AUTO_PIN_FRONT_MIC) { + if (is_ext_mic(codec, cfg->inputs[0].pin)) { + if (!is_ext_mic(codec, cfg->inputs[1].pin)) { spec->mic_detect = 1; - spec->automic_idx = AUTO_PIN_FRONT_MIC; + spec->automic_idx = 0; } } else { - if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) { + if (is_ext_mic(codec, cfg->inputs[1].pin)) { spec->mic_detect = 1; - spec->automic_idx = AUTO_PIN_MIC; + spec->automic_idx = 1; } } } @@ -853,15 +852,12 @@ static void cs_automic(struct hda_codec *codec) hda_nid_t nid; unsigned int present; - nid = cfg->input_pins[spec->automic_idx]; + nid = cfg->inputs[spec->automic_idx].pin; present = snd_hda_jack_detect(codec, nid); if (present) change_cur_input(codec, spec->automic_idx, 0); - else { - unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ? - AUTO_PIN_FRONT_MIC : AUTO_PIN_MIC; - change_cur_input(codec, imic, 0); - } + else + change_cur_input(codec, !spec->automic_idx, 0); } /* @@ -918,14 +914,14 @@ static void init_input(struct hda_codec *codec) unsigned int coef; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { + for (i = 0; i < cfg->num_inputs; i++) { unsigned int ctl; - hda_nid_t pin = cfg->input_pins[i]; - if (!pin || !spec->adc_nid[i]) + hda_nid_t pin = cfg->inputs[i].pin; + if (!spec->adc_nid[i]) continue; /* set appropriate pin control and mute first */ ctl = PIN_IN; - if (i <= AUTO_PIN_FRONT_MIC) { + if (cfg->inputs[i].type <= AUTO_PIN_FRONT_MIC) { unsigned int caps = snd_hda_query_pin_caps(codec, pin); caps >>= AC_PINCAP_VREF_SHIFT; if (caps & AC_PINCAP_VREF_80) -- cgit v1.2.3 From 66ceeb6bc2809bef0cfa18b1e22ddad5fc9b58b0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:05:52 +0200 Subject: ALSA: hda - Use new inputs[] field to parse input-pins for Realtek codecs Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 208 ++++++++++++++++++++++-------------------- 1 file changed, 110 insertions(+), 98 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 50e0c82fd99..3e0f4816aed 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1265,16 +1265,14 @@ static void alc_init_auto_mic(struct hda_codec *codec) int i; /* there must be only two mic inputs exclusively */ - for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) - if (cfg->input_pins[i]) + for (i = 0; i < cfg->num_inputs; i++) + if (cfg->inputs[i].type >= AUTO_PIN_LINE) return; fixed = ext = 0; - for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) { - hda_nid_t nid = cfg->input_pins[i]; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; unsigned int defcfg; - if (!nid) - return; defcfg = snd_hda_codec_get_pincfg(codec, nid); switch (get_defcfg_connect(defcfg)) { case AC_JACK_PORT_FIXED: @@ -4719,7 +4717,7 @@ static struct snd_kcontrol_new alc880_control_templates[] = { /* add dynamic controls */ static int add_control(struct alc_spec *spec, int type, const char *name, - unsigned long val) + int cidx, unsigned long val) { struct snd_kcontrol_new *knew; @@ -4731,6 +4729,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, knew->name = kstrdup(name, GFP_KERNEL); if (!knew->name) return -ENOMEM; + knew->index = cidx; if (get_amp_nid_(val)) knew->subdevice = HDA_SUBDEV_AMP_FLAG; knew->private_value = val; @@ -4739,17 +4738,21 @@ static int add_control(struct alc_spec *spec, int type, const char *name, static int add_control_with_pfx(struct alc_spec *spec, int type, const char *pfx, const char *dir, - const char *sfx, unsigned long val) + const char *sfx, int cidx, unsigned long val) { char name[32]; snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); - return add_control(spec, type, name, val); + return add_control(spec, type, name, cidx, val); } -#define add_pb_vol_ctrl(spec, type, pfx, val) \ - add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val) -#define add_pb_sw_ctrl(spec, type, pfx, val) \ - add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val) +#define add_pb_vol_ctrl(spec, type, pfx, val) \ + add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) +#define add_pb_sw_ctrl(spec, type, pfx, val) \ + add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) +#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ + add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) +#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ + add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) @@ -4902,16 +4905,16 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, /* create input playback/capture controls for the given pin */ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, - const char *ctlname, + const char *ctlname, int ctlidx, int idx, hda_nid_t mix_nid) { int err; - err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, + err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); if (err < 0) return err; - err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, + err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); if (err < 0) return err; @@ -4932,21 +4935,26 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, { struct alc_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx; + int i, err, idx, type, type_idx = 0; - for (i = 0; i < AUTO_PIN_LAST; i++) { + for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t pin; - pin = cfg->input_pins[i]; + pin = cfg->inputs[i].pin; if (!alc_is_input_pin(codec, pin)) continue; + type = cfg->inputs[i].type; + if (i > 0 && type == cfg->inputs[i - 1].type) + type_idx++; + else + type_idx = 0; if (mixer) { idx = get_connection_index(codec, mixer, pin); if (idx >= 0) { err = new_analog_input(spec, pin, - auto_pin_cfg_labels[i], - idx, mixer); + auto_pin_cfg_labels[type], + type_idx, idx, mixer); if (err < 0) return err; } @@ -4959,7 +4967,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, idx = get_connection_index(codec, cap2, pin); if (idx >= 0) { imux->items[imux->num_items].label = - auto_pin_cfg_labels[i]; + snd_hda_get_input_pin_label(cfg, i); imux->items[imux->num_items].index = idx; imux->num_items++; } @@ -5034,10 +5042,11 @@ static void alc880_auto_init_extra_out(struct hda_codec *codec) static void alc880_auto_init_analog_input(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; if (alc_is_input_pin(codec, nid)) { alc_set_input_pin(codec, nid, i); if (nid != ALC880_PIN_CD_NID && @@ -5204,19 +5213,13 @@ static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) static void fixup_single_adc(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; - hda_nid_t pin = 0; + struct auto_pin_cfg *cfg = &spec->autocfg; int i; /* search for the input pin; there must be only one */ - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (spec->autocfg.input_pins[i]) { - pin = spec->autocfg.input_pins[i]; - break; - } - } - if (!pin) + if (cfg->num_inputs != 1) return; - i = init_capsrc_for_pin(codec, pin); + i = init_capsrc_for_pin(codec, cfg->inputs[0].pin); if (i >= 0) { /* use only this ADC */ if (spec->capsrc_nids) @@ -5269,6 +5272,7 @@ static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids, int num_nids) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; int n; hda_nid_t fallback_adc = 0, fallback_cap = 0; @@ -5294,10 +5298,8 @@ static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids, fallback_adc = adc; fallback_cap = cap; } - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; - if (!nid) - continue; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; for (j = 0; j < nconns; j++) { if (conn[j] == nid) break; @@ -5305,7 +5307,7 @@ static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids, if (j >= nconns) break; } - if (i >= AUTO_PIN_LAST) { + if (i >= cfg->num_inputs) { int num_adcs = spec->num_adc_nids; spec->private_adc_nids[num_adcs] = adc; spec->private_capsrc_nids[num_adcs] = cap; @@ -6672,10 +6674,11 @@ static void alc260_auto_init_multi_out(struct hda_codec *codec) static void alc260_auto_init_analog_input(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; if (nid >= 0x12) { alc_set_input_pin(codec, nid, i); if (nid != ALC260_PIN_CD_NID && @@ -10538,12 +10541,11 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec) static void alc882_auto_init_analog_input(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; - if (!nid) - continue; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; alc_set_input_pin(codec, nid, i); if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) snd_hda_codec_write(codec, nid, 0, @@ -10606,24 +10608,23 @@ static void alc882_auto_init_input_src(struct hda_codec *codec) static int alc_auto_add_mic_boost(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; - int err; + struct auto_pin_cfg *cfg = &spec->autocfg; + int i, err; hda_nid_t nid; - nid = spec->autocfg.input_pins[AUTO_PIN_MIC]; - if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { - err = add_control(spec, ALC_CTL_WIDGET_VOL, - "Mic Boost", - HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); - if (err < 0) - return err; - } - nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC]; - if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) { - err = add_control(spec, ALC_CTL_WIDGET_VOL, - "Front Mic Boost", + for (i = 0; i < cfg->num_inputs; i++) { + if (cfg->inputs[i].type > AUTO_PIN_FRONT_MIC) + break; + nid = cfg->inputs[i].pin; + if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { + char label[32]; + snprintf(label, sizeof(label), "%s Boost", + snd_hda_get_input_pin_label(cfg, i)); + err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0, HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); - if (err < 0) - return err; + if (err < 0) + return err; + } } return 0; } @@ -15577,10 +15578,11 @@ static void alc861_auto_init_hp_out(struct hda_codec *codec) static void alc861_auto_init_analog_input(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; if (nid >= 0x0c && nid <= 0x11) alc_set_input_pin(codec, nid, i); } @@ -16569,10 +16571,11 @@ static void alc861vd_auto_init_hp_out(struct hda_codec *codec) static void alc861vd_auto_init_analog_input(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; if (alc_is_input_pin(codec, nid)) { alc_set_input_pin(codec, nid, i); if (nid != ALC861VD_PIN_CD_NID && @@ -18805,10 +18808,11 @@ static void alc662_auto_init_hp_out(struct hda_codec *codec) static void alc662_auto_init_analog_input(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; if (alc_is_input_pin(codec, nid)) { alc_set_input_pin(codec, nid, i); if (nid != ALC662_PIN_CD_NID && @@ -19037,6 +19041,39 @@ static hda_nid_t alc680_adc_nids[3] = { /* * Analog capture ADC cgange */ +static void alc680_rec_autoswitch(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + int pin_found = 0; + int type_found = AUTO_PIN_LAST; + hda_nid_t nid; + int i; + + for (i = 0; i < cfg->num_inputs; i++) { + nid = cfg->inputs[i].pin; + if (!(snd_hda_query_pin_caps(codec, nid) & + AC_PINCAP_PRES_DETECT)) + continue; + if (snd_hda_jack_detect(codec, nid)) { + if (cfg->inputs[i].type < type_found) { + type_found = cfg->inputs[i].type; + pin_found = nid; + } + } + } + + nid = 0x07; + if (pin_found) + snd_hda_get_connections(codec, pin_found, &nid, 1); + + if (nid != spec->cur_adc) + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); + spec->cur_adc = nid; + snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0, + spec->cur_adc_format); +} + static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, @@ -19044,24 +19081,12 @@ static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo, struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; - struct auto_pin_cfg *cfg = &spec->autocfg; - unsigned int pre_mic, pre_line; - - pre_mic = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]); - pre_line = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_LINE]); + spec->cur_adc = 0x07; spec->cur_adc_stream_tag = stream_tag; spec->cur_adc_format = format; - if (pre_mic || pre_line) { - if (pre_mic) - snd_hda_codec_setup_stream(codec, 0x08, stream_tag, 0, - format); - else - snd_hda_codec_setup_stream(codec, 0x09, stream_tag, 0, - format); - } else - snd_hda_codec_setup_stream(codec, 0x07, stream_tag, 0, format); + alc680_rec_autoswitch(codec); return 0; } @@ -19147,6 +19172,7 @@ static struct hda_verb alc680_init_verbs[] = { {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, + {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, { } }; @@ -19159,25 +19185,11 @@ static void alc680_base_setup(struct hda_codec *codec) spec->autocfg.hp_pins[0] = 0x16; spec->autocfg.speaker_pins[0] = 0x14; spec->autocfg.speaker_pins[1] = 0x15; - spec->autocfg.input_pins[AUTO_PIN_MIC] = 0x18; - spec->autocfg.input_pins[AUTO_PIN_LINE] = 0x19; -} - -static void alc680_rec_autoswitch(struct hda_codec *codec) -{ - struct alc_spec *spec = codec->spec; - struct auto_pin_cfg *cfg = &spec->autocfg; - unsigned int present; - hda_nid_t new_adc; - - present = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]); - - new_adc = present ? 0x8 : 0x7; - __snd_hda_codec_cleanup_stream(codec, !present ? 0x8 : 0x7, 1); - snd_hda_codec_setup_stream(codec, new_adc, - spec->cur_adc_stream_tag, 0, - spec->cur_adc_format); - + spec->autocfg.num_inputs = 2; + spec->autocfg.inputs[0].pin = 0x18; + spec->autocfg.inputs[0].type = AUTO_PIN_MIC; + spec->autocfg.inputs[1].pin = 0x19; + spec->autocfg.inputs[1].type = AUTO_PIN_LINE; } static void alc680_unsol_event(struct hda_codec *codec, -- cgit v1.2.3 From eea7dc932bfa802ad0377755ea821f416f4f8623 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:06:15 +0200 Subject: ALSA: hda - Use new inputs[] field to parse input-pins for STAC/IDT codecs Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 183 +++++++++++++++++++++-------------------- 1 file changed, 96 insertions(+), 87 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 95148e58026..d226edd1e14 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -1180,14 +1180,11 @@ static int stac92xx_build_controls(struct hda_codec *codec) if (err < 0) return err; } - for (i = 0; i < AUTO_PIN_LAST; i++) { - nid = cfg->input_pins[i]; - if (nid) { - err = stac92xx_add_jack(codec, nid, - SND_JACK_MICROPHONE); - if (err < 0) - return err; - } + for (i = 0; i < cfg->num_inputs; i++) { + nid = cfg->inputs[i].pin; + err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE); + if (err < 0) + return err; } return 0; @@ -2821,41 +2818,55 @@ static hda_nid_t check_line_out_switch(struct hda_codec *codec) struct auto_pin_cfg *cfg = &spec->autocfg; hda_nid_t nid; unsigned int pincap; + int i; if (cfg->line_out_type != AUTO_PIN_LINE_OUT) return 0; - nid = cfg->input_pins[AUTO_PIN_LINE]; - pincap = snd_hda_query_pin_caps(codec, nid); - if (pincap & AC_PINCAP_OUT) - return nid; + for (i = 0; i < cfg->num_inputs; i++) { + if (cfg->inputs[i].type == AUTO_PIN_LINE) { + nid = cfg->inputs[i].pin; + pincap = snd_hda_query_pin_caps(codec, nid); + if (pincap & AC_PINCAP_OUT) + return nid; + } + } return 0; } +static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid); + /* check whether the mic-input can be used as line-out */ -static hda_nid_t check_mic_out_switch(struct hda_codec *codec) +static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) { struct sigmatel_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int def_conf, pincap; - unsigned int mic_pin; + int i, mic_type; + *dac = 0; if (cfg->line_out_type != AUTO_PIN_LINE_OUT) return 0; - mic_pin = AUTO_PIN_MIC; - for (;;) { - hda_nid_t nid = cfg->input_pins[mic_pin]; + mic_type = AUTO_PIN_MIC; + again: + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; + if (cfg->inputs[i].type != mic_type) + continue; def_conf = snd_hda_codec_get_pincfg(codec, nid); /* some laptops have an internal analog microphone * which can't be used as a output */ if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { pincap = snd_hda_query_pin_caps(codec, nid); - if (pincap & AC_PINCAP_OUT) - return nid; + if (pincap & AC_PINCAP_OUT) { + *dac = get_unassigned_dac(codec, nid); + if (*dac) + return nid; + } } - if (mic_pin == AUTO_PIN_MIC) - mic_pin = AUTO_PIN_FRONT_MIC; - else - break; + } + if (mic_type == AUTO_PIN_MIC) { + mic_type = AUTO_PIN_FRONT_MIC; + goto again; } return 0; } @@ -3002,17 +3013,14 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) } } /* add mic as output */ - nid = check_mic_out_switch(codec); - if (nid) { - dac = get_unassigned_dac(codec, nid); - if (dac) { - snd_printdd("STAC: Add mic-in 0x%x as output %d\n", - nid, cfg->line_outs); - cfg->line_out_pins[cfg->line_outs] = nid; - cfg->line_outs++; - spec->mic_switch = nid; - add_spec_dacs(spec, dac); - } + nid = check_mic_out_switch(codec, &dac); + if (nid && dac) { + snd_printdd("STAC: Add mic-in 0x%x as output %d\n", + nid, cfg->line_outs); + cfg->line_out_pins[cfg->line_outs] = nid; + cfg->line_outs++; + spec->mic_switch = nid; + add_spec_dacs(spec, dac); } snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", @@ -3202,13 +3210,13 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, return err; } - for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) { - nid = cfg->input_pins[idx]; - if (nid) { - err = stac92xx_add_jack_mode_control(codec, nid, idx); - if (err < 0) - return err; - } + for (idx = 0; idx < cfg->num_inputs; idx++) { + if (cfg->inputs[idx].type > AUTO_PIN_FRONT_LINE) + break; + nid = cfg->inputs[idx].pin; + err = stac92xx_add_jack_mode_control(codec, nid, idx); + if (err < 0) + return err; } return 0; @@ -3415,7 +3423,7 @@ static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, /* create a volume assigned to the given pin (only if supported) */ /* return 1 if the volume control is created */ static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, - const char *label, int direction) + const char *label, int idx, int direction) { unsigned int caps, nums; char name[32]; @@ -3432,8 +3440,8 @@ static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, if (!nums) return 0; snprintf(name, sizeof(name), "%s Capture Volume", label); - err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name, - HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); + err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction)); if (err < 0) return err; return 1; @@ -3485,11 +3493,11 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, else label = stac92xx_dmic_labels[dimux->num_items]; - err = create_elem_capture_vol(codec, nid, label, HDA_INPUT); + err = create_elem_capture_vol(codec, nid, label, 0, HDA_INPUT); if (err < 0) return err; if (!err) { - err = create_elem_capture_vol(codec, nid, label, + err = create_elem_capture_vol(codec, nid, label, 0, HDA_OUTPUT); if (err < 0) return err; @@ -3540,10 +3548,11 @@ static int set_mic_route(struct hda_codec *codec, int i; mic->pin = pin; - for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) - if (pin == cfg->input_pins[i]) + for (i = 0; i < cfg->num_inputs; i++) { + if (pin == cfg->inputs[i].pin) break; - if (i <= AUTO_PIN_FRONT_MIC) { + } + if (i < cfg->num_inputs && cfg->inputs[i].type <= AUTO_PIN_FRONT_MIC) { /* analog pin */ i = get_connection_index(codec, spec->mux_nids[0], pin); if (i < 0) @@ -3577,13 +3586,13 @@ static int stac_check_auto_mic(struct hda_codec *codec) hda_nid_t fixed, ext; int i; - for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) { - if (cfg->input_pins[i]) + for (i = 0; i < cfg->num_inputs; i++) { + if (cfg->inputs[i].type >= AUTO_PIN_LINE) return 0; /* must be exclusively mics */ } fixed = ext = 0; - for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) - if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext)) + for (i = 0; i < cfg->num_inputs; i++) + if (check_mic_pin(codec, cfg->inputs[i].pin, &fixed, &ext)) return 0; for (i = 0; i < spec->num_dmics; i++) if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) @@ -3603,14 +3612,12 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const { struct sigmatel_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux; - int i, j; + int i, j, type_idx = 0; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = cfg->input_pins[i]; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; int index, err; - if (!nid) - continue; index = -1; for (j = 0; j < spec->num_muxes; j++) { index = get_connection_index(codec, spec->mux_nids[j], @@ -3621,13 +3628,18 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const if (index < 0) continue; + if (i > 0 && cfg->inputs[i].type == cfg->inputs[i - 1].type) + type_idx++; + else + type_idx = 0; err = create_elem_capture_vol(codec, nid, - auto_pin_cfg_labels[i], + auto_pin_cfg_labels[i], type_idx, HDA_INPUT); if (err < 0) return err; - imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; + imux->items[imux->num_items].label = + snd_hda_get_input_pin_label(cfg, i); imux->items[imux->num_items].index = index; imux->num_items++; } @@ -4304,37 +4316,34 @@ static int stac92xx_init(struct hda_codec *codec) if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) stac_issue_unsol_event(codec, spec->ext_mic.pin); } - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = cfg->input_pins[i]; - if (nid) { - unsigned int pinctl, conf; - if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { - /* for mic pins, force to initialize */ - pinctl = stac92xx_get_default_vref(codec, nid); + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; + int type = cfg->inputs[i].type; + unsigned int pinctl, conf; + if (type == AUTO_PIN_MIC || type == AUTO_PIN_FRONT_MIC) { + /* for mic pins, force to initialize */ + pinctl = stac92xx_get_default_vref(codec, nid); + pinctl |= AC_PINCTL_IN_EN; + stac92xx_auto_set_pinctl(codec, nid, pinctl); + } else { + pinctl = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + /* if PINCTL already set then skip */ + /* Also, if both INPUT and OUTPUT are set, + * it must be a BIOS bug; need to override, too + */ + if (!(pinctl & AC_PINCTL_IN_EN) || + (pinctl & AC_PINCTL_OUT_EN)) { + pinctl &= ~AC_PINCTL_OUT_EN; pinctl |= AC_PINCTL_IN_EN; stac92xx_auto_set_pinctl(codec, nid, pinctl); - } else { - pinctl = snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); - /* if PINCTL already set then skip */ - /* Also, if both INPUT and OUTPUT are set, - * it must be a BIOS bug; need to override, too - */ - if (!(pinctl & AC_PINCTL_IN_EN) || - (pinctl & AC_PINCTL_OUT_EN)) { - pinctl &= ~AC_PINCTL_OUT_EN; - pinctl |= AC_PINCTL_IN_EN; - stac92xx_auto_set_pinctl(codec, nid, - pinctl); - } - } - conf = snd_hda_codec_get_pincfg(codec, nid); - if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { - if (enable_pin_detect(codec, nid, - STAC_INSERT_EVENT)) - stac_issue_unsol_event(codec, nid); } } + conf = snd_hda_codec_get_pincfg(codec, nid); + if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { + if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT)) + stac_issue_unsol_event(codec, nid); + } } for (i = 0; i < spec->num_dmics; i++) stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], -- cgit v1.2.3 From 7b315bb4980448250c80a7464c256b54d546cb26 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 30 Aug 2010 13:06:30 +0200 Subject: ALSA: hda - Use new inputs[] field to parse input-pins for VIA codecs Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_via.c | 144 +++++++++++++++++++++++----------------------- 1 file changed, 73 insertions(+), 71 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 41861388f43..93b86adbce6 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -444,8 +444,8 @@ static hda_nid_t vt1812_adc_nids[2] = { /* add dynamic controls */ -static int via_add_control(struct via_spec *spec, int type, const char *name, - unsigned long val) +static int __via_add_control(struct via_spec *spec, int type, const char *name, + int idx, unsigned long val) { struct snd_kcontrol_new *knew; @@ -463,6 +463,9 @@ static int via_add_control(struct via_spec *spec, int type, const char *name, return 0; } +#define via_add_control(spec, type, name, val) \ + __via_add_control(spec, type, name, 0, val) + static struct snd_kcontrol_new *via_clone_control(struct via_spec *spec, struct snd_kcontrol_new *tmpl) { @@ -494,18 +497,18 @@ static void via_free_kctls(struct hda_codec *codec) /* create input playback/capture controls for the given pin */ static int via_new_analog_input(struct via_spec *spec, const char *ctlname, - int idx, int mix_nid) + int type_idx, int idx, int mix_nid) { char name[32]; int err; sprintf(name, "%s Playback Volume", ctlname); - err = via_add_control(spec, VIA_CTL_WIDGET_VOL, name, + err = __via_add_control(spec, VIA_CTL_WIDGET_VOL, name, type_idx, HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); if (err < 0) return err; sprintf(name, "%s Playback Switch", ctlname); - err = via_add_control(spec, VIA_CTL_WIDGET_ANALOG_MUTE, name, + err = __via_add_control(spec, VIA_CTL_WIDGET_ANALOG_MUTE, name, type_idx, HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); if (err < 0) return err; @@ -557,14 +560,12 @@ static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin); static void via_auto_init_analog_input(struct hda_codec *codec) { struct via_spec *spec = codec->spec; + const struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int ctl; int i; - for (i = 0; i < AUTO_PIN_LAST; i++) { - hda_nid_t nid = spec->autocfg.input_pins[i]; - if (!nid) - continue; - + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; if (spec->smart51_enabled && is_smart51_pins(spec, nid)) ctl = PIN_OUT; else if (i <= AUTO_PIN_FRONT_MIC) @@ -1322,15 +1323,14 @@ static void mute_aa_path(struct hda_codec *codec, int mute) } static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin) { - int res = 0; - int index; - for (index = AUTO_PIN_MIC; index < AUTO_PIN_FRONT_LINE; index++) { - if (pin == spec->autocfg.input_pins[index]) { - res = 1; - break; - } + const struct auto_pin_cfg *cfg = &spec->autocfg; + int i; + + for (i = 0; i < cfg->num_inputs; i++) { + if (pin == cfg->inputs[i].pin) + return cfg->inputs[i].type < AUTO_PIN_FRONT_LINE; } - return res; + return 0; } static int via_smart51_info(struct snd_kcontrol *kcontrol, @@ -1348,25 +1348,21 @@ static int via_smart51_get(struct snd_kcontrol *kcontrol, { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct via_spec *spec = codec->spec; - int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; + const struct auto_pin_cfg *cfg = &spec->autocfg; int on = 1; int i; - for (i = 0; i < ARRAY_SIZE(index); i++) { - hda_nid_t nid = spec->autocfg.input_pins[index[i]]; - if (nid) { - int ctl = - snd_hda_codec_read(codec, nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, - 0); - if (i == AUTO_PIN_FRONT_MIC - && spec->hp_independent_mode - && spec->codec_type != VT1718S) - continue; /* ignore FMic for independent HP */ - if (ctl & AC_PINCTL_IN_EN - && !(ctl & AC_PINCTL_OUT_EN)) - on = 0; - } + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; + int ctl = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + if (cfg->inputs[i].type >= AUTO_PIN_FRONT_LINE) + continue; + if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC && + spec->hp_independent_mode && spec->codec_type != VT1718S) + continue; /* ignore FMic for independent HP */ + if ((ctl & AC_PINCTL_IN_EN) && !(ctl & AC_PINCTL_OUT_EN)) + on = 0; } *ucontrol->value.integer.value = on; return 0; @@ -1377,36 +1373,38 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct via_spec *spec = codec->spec; + const struct auto_pin_cfg *cfg = &spec->autocfg; int out_in = *ucontrol->value.integer.value ? AC_PINCTL_OUT_EN : AC_PINCTL_IN_EN; - int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; int i; - for (i = 0; i < ARRAY_SIZE(index); i++) { - hda_nid_t nid = spec->autocfg.input_pins[index[i]]; - if (i == AUTO_PIN_FRONT_MIC - && spec->hp_independent_mode - && spec->codec_type != VT1718S) + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; + unsigned int parm; + + if (cfg->inputs[i].type >= AUTO_PIN_FRONT_LINE) + continue; + if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC && + spec->hp_independent_mode && spec->codec_type != VT1718S) continue; /* don't retask FMic for independent HP */ - if (nid) { - unsigned int parm = snd_hda_codec_read( - codec, nid, 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); - parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); - parm |= out_in; - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_PIN_WIDGET_CONTROL, - parm); - if (out_in == AC_PINCTL_OUT_EN) { - mute_aa_path(codec, 1); - notify_aa_path_ctls(codec); - } - if (spec->codec_type == VT1718S) - snd_hda_codec_amp_stereo( + + parm = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + parm &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); + parm |= out_in; + snd_hda_codec_write(codec, nid, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + parm); + if (out_in == AC_PINCTL_OUT_EN) { + mute_aa_path(codec, 1); + notify_aa_path_ctls(codec); + } + if (spec->codec_type == VT1718S) { + snd_hda_codec_amp_stereo( codec, nid, HDA_OUTPUT, 0, HDA_AMP_MUTE, HDA_AMP_UNMUTE); } - if (i == AUTO_PIN_FRONT_MIC) { + if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC) { if (spec->codec_type == VT1708S || spec->codec_type == VT1716S) { /* input = index 1 (AOW3) */ @@ -1442,7 +1440,7 @@ static struct snd_kcontrol_new via_smart51_mixer[2] = { static int via_smart51_build(struct via_spec *spec) { struct snd_kcontrol_new *knew; - int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE }; + const struct auto_pin_cfg *cfg = &spec->autocfg; hda_nid_t nid; int i; @@ -1450,13 +1448,14 @@ static int via_smart51_build(struct via_spec *spec) if (knew == NULL) return -ENOMEM; - for (i = 0; i < ARRAY_SIZE(index); i++) { - nid = spec->autocfg.input_pins[index[i]]; - if (nid) { + for (i = 0; i < cfg->num_inputs; i++) { + nid = cfg->inputs[i].pin; + if (cfg->inputs[i].type < AUTO_PIN_FRONT_LINE) { knew = via_clone_control(spec, &via_smart51_mixer[1]); if (knew == NULL) return -ENOMEM; knew->subdevice = nid; + break; } } @@ -2419,7 +2418,7 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec, hda_nid_t pin_idxs[], int num_idxs) { struct hda_input_mux *imux = &spec->private_imux[0]; - int i, err, idx; + int i, err, idx, type, type_idx = 0; /* for internal loopback recording select */ for (idx = 0; idx < num_idxs; idx++) { @@ -2431,20 +2430,23 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec, } } - for (i = 0; i < AUTO_PIN_LAST; i++) { - if (!cfg->input_pins[i]) - continue; - + for (i = 0; i < cfg->num_inputs; i++) { + type = cfg->inputs[i].type; for (idx = 0; idx < num_idxs; idx++) - if (pin_idxs[idx] == cfg->input_pins[i]) + if (pin_idxs[idx] == cfg->inputs[i].pin) break; if (idx >= num_idxs) continue; - err = via_new_analog_input(spec, auto_pin_cfg_labels[i], - idx, cap_nid); + if (i > 0 && type == cfg->inputs[i - 1].type) + type_idx++; + else + type_idx = 0; + err = via_new_analog_input(spec, auto_pin_cfg_labels[type], + type_idx, idx, cap_nid); if (err < 0) return err; - imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; + imux->items[imux->num_items].label = + snd_hda_get_input_pin_label(cfg, i); imux->items[imux->num_items].index = idx; imux->num_items++; } @@ -5513,7 +5515,7 @@ static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, if (err < 0) return err; /* build volume/mute control of loopback */ - err = via_new_analog_input(spec, "Stereo Mixer", 3, 0x21); + err = via_new_analog_input(spec, "Stereo Mixer", 0, 3, 0x21); if (err < 0) return err; @@ -5836,7 +5838,7 @@ static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, return err; /* build volume/mute control of loopback */ - err = via_new_analog_input(spec, "Stereo Mixer", 5, 0x21); + err = via_new_analog_input(spec, "Stereo Mixer", 0, 5, 0x21); if (err < 0) return err; -- cgit v1.2.3 From 9fe856e47e1751204faf3d604c6d20ab24bd3b93 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sat, 4 Sep 2010 18:52:54 -0700 Subject: sound: Remove unnecessary casts of private_data Signed-off-by: Joe Perches Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emumpu401.c | 2 +- sound/pci/ice1712/pontis.c | 6 +++--- sound/pci/ice1712/prodigy192.c | 2 +- sound/pci/rme96.c | 8 ++++---- sound/pci/rme9652/hdsp.c | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/emu10k1/emumpu401.c b/sound/pci/emu10k1/emumpu401.c index 8578c70c61f..bab564824ef 100644 --- a/sound/pci/emu10k1/emumpu401.c +++ b/sound/pci/emu10k1/emumpu401.c @@ -321,7 +321,7 @@ static struct snd_rawmidi_ops snd_emu10k1_midi_input = static void snd_emu10k1_midi_free(struct snd_rawmidi *rmidi) { - struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)rmidi->private_data; + struct snd_emu10k1_midi *midi = rmidi->private_data; midi->interrupt = NULL; midi->rmidi = NULL; } diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c index 6bc3f91b728..cdb873f5da5 100644 --- a/sound/pci/ice1712/pontis.c +++ b/sound/pci/ice1712/pontis.c @@ -638,7 +638,7 @@ static struct snd_kcontrol_new pontis_controls[] __devinitdata = { */ static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; + struct snd_ice1712 *ice = entry->private_data; char line[64]; unsigned int reg, val; mutex_lock(&ice->gpio_mutex); @@ -653,7 +653,7 @@ static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buf static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; + struct snd_ice1712 *ice = entry->private_data; int reg, val; mutex_lock(&ice->gpio_mutex); @@ -676,7 +676,7 @@ static void wm_proc_init(struct snd_ice1712 *ice) static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; + struct snd_ice1712 *ice = entry->private_data; int reg, val; mutex_lock(&ice->gpio_mutex); diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c index 2a8e5cd8f2d..e36ddb94c38 100644 --- a/sound/pci/ice1712/prodigy192.c +++ b/sound/pci/ice1712/prodigy192.c @@ -654,7 +654,7 @@ static int prodigy192_ak4114_init(struct snd_ice1712 *ice) static void stac9460_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; + struct snd_ice1712 *ice = entry->private_data; int reg, val; /* registers 0x0 - 0x14 */ for (reg = 0; reg <= 0x15; reg++) { diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index d19dc052c39..d5f5b440fc4 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -1527,14 +1527,14 @@ snd_rme96_free(void *private_data) static void snd_rme96_free_spdif_pcm(struct snd_pcm *pcm) { - struct rme96 *rme96 = (struct rme96 *) pcm->private_data; + struct rme96 *rme96 = pcm->private_data; rme96->spdif_pcm = NULL; } static void snd_rme96_free_adat_pcm(struct snd_pcm *pcm) { - struct rme96 *rme96 = (struct rme96 *) pcm->private_data; + struct rme96 *rme96 = pcm->private_data; rme96->adat_pcm = NULL; } @@ -1661,7 +1661,7 @@ static void snd_rme96_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { int n; - struct rme96 *rme96 = (struct rme96 *)entry->private_data; + struct rme96 *rme96 = entry->private_data; rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER); @@ -2348,7 +2348,7 @@ snd_rme96_probe(struct pci_dev *pci, if (err < 0) return err; card->private_free = snd_rme96_card_free; - rme96 = (struct rme96 *)card->private_data; + rme96 = card->private_data; rme96->card = card; rme96->pci = pci; snd_card_set_dev(card, &pci->dev); diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index b92adef8e81..599e0905166 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -3284,7 +3284,7 @@ static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp) static void snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - struct hdsp *hdsp = (struct hdsp *) entry->private_data; + struct hdsp *hdsp = entry->private_data; unsigned int status; unsigned int status2; char *pref_sync_ref; @@ -4566,7 +4566,7 @@ static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rm static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) { - struct hdsp *hdsp = (struct hdsp *)hw->private_data; + struct hdsp *hdsp = hw->private_data; void __user *argp = (void __user *)arg; int err; @@ -5155,7 +5155,7 @@ static int snd_hdsp_free(struct hdsp *hdsp) static void snd_hdsp_card_free(struct snd_card *card) { - struct hdsp *hdsp = (struct hdsp *) card->private_data; + struct hdsp *hdsp = card->private_data; if (hdsp) snd_hdsp_free(hdsp); @@ -5181,7 +5181,7 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci, if (err < 0) return err; - hdsp = (struct hdsp *) card->private_data; + hdsp = card->private_data; card->private_free = snd_hdsp_card_free; hdsp->dev = dev; hdsp->pci = pci; -- cgit v1.2.3 From add7c0a6a4b8669ebd726f9c08ba6002900ca671 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 16 Jul 2009 18:19:12 +0200 Subject: ALSA: ca0106 - clean up playback pointer callback Clean up the playback pointer callback function a bit, and make the pointer check more strictly to avoid bogus pointers. Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 0a3d3d6e77b..8e69620da20 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1002,29 +1002,27 @@ snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream) struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct snd_ca0106_pcm *epcm = runtime->private_data; - snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; + unsigned int ptr, prev_ptr; int channel = epcm->channel_id; + int timeout = 10; if (!epcm->running) return 0; - ptr3 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); - ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); - ptr4 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); - if (ptr3 != ptr4) ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); - ptr2 = bytes_to_frames(runtime, ptr1); - ptr2+= (ptr4 >> 3) * runtime->period_size; - ptr=ptr2; - if (ptr >= runtime->buffer_size) - ptr -= runtime->buffer_size; - /* - printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " - "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", - ptr1, ptr2, ptr, (int)runtime->buffer_size, - (int)runtime->period_size, (int)runtime->frame_bits, - (int)runtime->rate); - */ - return ptr; + prev_ptr = -1; + do { + ptr = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); + ptr = (ptr >> 3) * runtime->period_size; + ptr += bytes_to_frames(runtime, + snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel)); + if (ptr >= runtime->buffer_size) + ptr -= runtime->buffer_size; + if (prev_ptr == ptr) + return ptr; + prev_ptr = ptr; + } while (--timeout); + snd_printk(KERN_WARNING "ca0106: unstable DMA pointer!\n"); + return 0; } /* pointer_capture callback */ -- cgit v1.2.3 From ab5a6ebee38f3ed311f0565ecd3fba5cf111564a Mon Sep 17 00:00:00 2001 From: Vitaliy Kulikov Date: Wed, 8 Sep 2010 09:00:17 +0200 Subject: ALSA: hda - Adding support for new IDT 92HD90BXX and 92HD91BXX codecs Adding support for digital MIC in 92HD83/90/91XXX codecs family. Signed-off-by: Vitaliy Kulikov Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 79 ++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 33 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index d226edd1e14..82d1e437862 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -382,6 +382,11 @@ static unsigned int stac92hd83xxx_pwr_mapping[4] = { 0x03, 0x0c, 0x20, 0x40, }; +#define STAC92HD83XXX_NUM_DMICS 2 +static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { + 0x11, 0x20, 0 +}; + #define STAC92HD83XXX_NUM_CAPS 2 static unsigned long stac92hd83xxx_capvols[] = { HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT), @@ -4695,6 +4700,36 @@ static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) } } +/* get the pin connection (fixed, none, etc) */ +static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) +{ + struct sigmatel_spec *spec = codec->spec; + unsigned int cfg; + + cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); + return get_defcfg_connect(cfg); +} + +static int stac92xx_connected_ports(struct hda_codec *codec, + hda_nid_t *nids, int num_nids) +{ + struct sigmatel_spec *spec = codec->spec; + int idx, num; + unsigned int def_conf; + + for (num = 0; num < num_nids; num++) { + for (idx = 0; idx < spec->num_pins; idx++) + if (spec->pin_nids[idx] == nids[num]) + break; + if (idx >= spec->num_pins) + break; + def_conf = stac_get_defcfg_connect(codec, idx); + if (def_conf == AC_JACK_PORT_NONE) + break; + } + return num; +} + static void stac92xx_mic_detect(struct hda_codec *codec) { struct sigmatel_spec *spec = codec->spec; @@ -5325,6 +5360,8 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) spec->linear_tone_beep = 1; codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; spec->digbeep_nid = 0x21; + spec->dmic_nids = stac92hd83xxx_dmic_nids; + spec->dmux_nids = stac92hd83xxx_mux_nids; spec->mux_nids = stac92hd83xxx_mux_nids; spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids); spec->adc_nids = stac92hd83xxx_adc_nids; @@ -5370,9 +5407,13 @@ again: case 0x111d76d4: case 0x111d7605: case 0x111d76d5: + case 0x111d76e7: if (spec->board_config == STAC_92HD83XXX_PWR_REF) break; spec->num_pwrs = 0; + spec->num_dmics = stac92xx_connected_ports(codec, + stac92hd83xxx_dmic_nids, + STAC92HD83XXX_NUM_DMICS); break; } @@ -5431,36 +5472,6 @@ again: return 0; } -/* get the pin connection (fixed, none, etc) */ -static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) -{ - struct sigmatel_spec *spec = codec->spec; - unsigned int cfg; - - cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); - return get_defcfg_connect(cfg); -} - -static int stac92hd71bxx_connected_ports(struct hda_codec *codec, - hda_nid_t *nids, int num_nids) -{ - struct sigmatel_spec *spec = codec->spec; - int idx, num; - unsigned int def_conf; - - for (num = 0; num < num_nids; num++) { - for (idx = 0; idx < spec->num_pins; idx++) - if (spec->pin_nids[idx] == nids[num]) - break; - if (idx >= spec->num_pins) - break; - def_conf = stac_get_defcfg_connect(codec, idx); - if (def_conf == AC_JACK_PORT_NONE) - break; - } - return num; -} - static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, hda_nid_t dig0pin) { @@ -5599,7 +5610,7 @@ again: case 0x111d76b5: spec->init = stac92hd71bxx_core_init; codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; - spec->num_dmics = stac92hd71bxx_connected_ports(codec, + spec->num_dmics = stac92xx_connected_ports(codec, stac92hd71bxx_dmic_nids, STAC92HD71BXX_NUM_DMICS); break; @@ -5631,7 +5642,7 @@ again: snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; - spec->num_dmics = stac92hd71bxx_connected_ports(codec, + spec->num_dmics = stac92xx_connected_ports(codec, stac92hd71bxx_dmic_nids, STAC92HD71BXX_NUM_DMICS - 1); break; @@ -5645,7 +5656,7 @@ again: default: spec->init = stac92hd71bxx_core_init; codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; - spec->num_dmics = stac92hd71bxx_connected_ports(codec, + spec->num_dmics = stac92xx_connected_ports(codec, stac92hd71bxx_dmic_nids, STAC92HD71BXX_NUM_DMICS); break; @@ -6327,6 +6338,8 @@ static struct hda_codec_preset snd_hda_preset_sigmatel[] = { { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx }, { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx }, { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx }, + { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx}, + { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx}, {} /* terminator */ }; -- cgit v1.2.3 From 263d0328c46995d8e4fb478005177839104483d2 Mon Sep 17 00:00:00 2001 From: Vitaliy Kulikov Date: Wed, 8 Sep 2010 08:56:03 +0200 Subject: ALSA: hda - Improve input control names for IDT/STAC codecs Changing the way the input controls are named using port connection type and jack location info. Signed-off-by: Vitaliy Kulikov Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 107 +++++++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 19 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 82d1e437862..7f09e140953 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -191,6 +191,11 @@ struct sigmatel_mic_route { signed char dmux_idx; }; +struct unique_input_names { + int num; + char uname[HDA_MAX_NUM_INPUTS][32]; +}; + struct sigmatel_spec { struct snd_kcontrol_new *mixers[4]; unsigned int num_mixers; @@ -307,6 +312,7 @@ struct sigmatel_spec { struct hda_input_mux private_imux; struct hda_input_mux private_smux; struct hda_input_mux private_mono_mux; + struct unique_input_names private_u_inp_names; }; static hda_nid_t stac9200_adc_nids[1] = { @@ -3452,6 +3458,76 @@ static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, return 1; } +static const char *get_input_src_label(struct hda_codec *codec, hda_nid_t nid) +{ + unsigned int def_conf; + + def_conf = snd_hda_codec_get_pincfg(codec, nid); + + switch (get_defcfg_device(def_conf)) { + case AC_JACK_MIC_IN: + if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || + ((get_defcfg_location(def_conf) & 0xf0) + == AC_JACK_LOC_INTERNAL)) + return "Internal Mic"; + if ((get_defcfg_location(def_conf) & 0xf0) + == AC_JACK_LOC_SEPARATE) + return "Dock Mic"; + if (get_defcfg_location(def_conf) == AC_JACK_LOC_REAR) + return "Rear Mic"; + return "Mic"; + case AC_JACK_LINE_IN: + if ((get_defcfg_location(def_conf) & 0xf0) + == AC_JACK_LOC_SEPARATE) + return "Dock Line"; + return "Line"; + case AC_JACK_AUX: + return "Aux"; + case AC_JACK_CD: + return "CD"; + case AC_JACK_SPDIF_IN: + return "SPDIF In"; + case AC_JACK_DIG_OTHER_IN: + return "Digital In"; + } + + snd_printd("invalid inp pin %02x device config %08x", nid, def_conf); + return NULL; +} + +static const char *get_unique_inp_src_label(struct hda_codec *codec, + hda_nid_t nid) +{ + int i, n; + const char *label; + struct sigmatel_spec *spec = codec->spec; + struct hda_input_mux *imux = &spec->private_imux; + struct hda_input_mux *dimux = &spec->private_dimux; + struct unique_input_names *unames = &spec->private_u_inp_names; + + label = get_input_src_label(codec, nid); + n = 0; + + for (i = 0; i < imux->num_items; i++) { + if (!strncmp(label, imux->items[i].label, strlen(label))) + n++; + } + if (snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { + for (i = 0; i < dimux->num_items; i++) { + if (!strncmp(label, dimux->items[i].label, + strlen(label))) + n++; + } + } + if (n > 0 && unames->num < HDA_MAX_NUM_INPUTS) { + sprintf(&unames->uname[unames->num][0], "%.28s %d", label, n); + label = &unames->uname[unames->num][0]; + unames->num++; + } + + return label; +} + /* create playback/capture controls for input pins on dmic capable codecs */ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) @@ -3459,24 +3535,13 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, struct sigmatel_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux; struct hda_input_mux *dimux = &spec->private_dimux; - int err, i, active_mics; + int err, i; unsigned int def_conf; dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; dimux->items[dimux->num_items].index = 0; dimux->num_items++; - active_mics = 0; - for (i = 0; i < spec->num_dmics; i++) { - /* check the validity: sometimes it's a dead vendor-spec node */ - if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i])) - != AC_WID_PIN) - continue; - def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); - if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) - active_mics++; - } - for (i = 0; i < spec->num_dmics; i++) { hda_nid_t nid; int index; @@ -3493,10 +3558,9 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, if (index < 0) continue; - if (active_mics == 1) - label = "Digital Mic"; - else - label = stac92xx_dmic_labels[dimux->num_items]; + label = get_unique_inp_src_label(codec, nid); + if (label == NULL) + return -EINVAL; err = create_elem_capture_vol(codec, nid, label, 0, HDA_INPUT); if (err < 0) @@ -3618,6 +3682,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct sigmatel_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux; int i, j, type_idx = 0; + const char *label; for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; @@ -3637,14 +3702,18 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const type_idx++; else type_idx = 0; + + label = get_unique_inp_src_label(codec, nid); + if (label == NULL) + return -EINVAL; + err = create_elem_capture_vol(codec, nid, - auto_pin_cfg_labels[i], type_idx, + label, type_idx, HDA_INPUT); if (err < 0) return err; - imux->items[imux->num_items].label = - snd_hda_get_input_pin_label(cfg, i); + imux->items[imux->num_items].label = label; imux->items[imux->num_items].index = index; imux->num_items++; } -- cgit v1.2.3 From 03642c9a444079aa13f0864383a8f9ca04bfd198 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 8 Sep 2010 15:28:19 +0200 Subject: ALSA: hda - Clear left-over hp_pins in snd_hda_parse_pin_def_config() In snd_hda_parse_def_config(), some unused values may remain in hp_pins[] array during the headphone-reassignment workaround. This patch clears the unused array members. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 2980c277847..bfdde7b0baf 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4558,6 +4558,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, memmove(sequences_hp + i, sequences_hp + i + 1, sizeof(sequences_hp[0]) * (cfg->hp_outs - i)); } + memset(cfg->hp_pins + cfg->hp_outs, 0, + sizeof(hda_nid_t) * (AUTO_CFG_MAX_OUTS - cfg->hp_outs)); } /* sort by sequence */ -- cgit v1.2.3 From bb35febd16fe5ac8c30f9116a25210c4f63a5267 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 8 Sep 2010 15:30:49 +0200 Subject: ALSA: hda - Support multiple headphone auto-mute Currently headphone auto-mute using alc_automute_pin() assumes only the single pin used for the headphone output. Since there are devices with multiple headphone jacks, we need to check all these pins there, too. Also this patch merges the common code between alc_automute_pin() and alc_automute_amp() helper functions. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 92 +++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 42 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 81e4b1d957c..ee59df7a41f 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -990,25 +990,46 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, alc_fix_pll(codec); } -static void alc_automute_pin(struct hda_codec *codec) +static void alc_automute_speaker(struct hda_codec *codec, int pinctl) { struct alc_spec *spec = codec->spec; - unsigned int nid = spec->autocfg.hp_pins[0]; + unsigned int mute; + hda_nid_t nid; int i; - if (!nid) - return; - spec->jack_present = snd_hda_jack_detect(codec, nid); + spec->jack_present = 0; + for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { + nid = spec->autocfg.hp_pins[i]; + if (!nid) + break; + if (snd_hda_jack_detect(codec, nid)) { + spec->jack_present = 1; + break; + } + } + + mute = spec->jack_present ? HDA_AMP_MUTE : 0; + /* Toggle internal speakers muting */ for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { nid = spec->autocfg.speaker_pins[i]; if (!nid) break; - snd_hda_codec_write(codec, nid, 0, + if (pinctl) { + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, spec->jack_present ? 0 : PIN_OUT); + } else { + snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, + HDA_AMP_MUTE, mute); + } } } +static void alc_automute_pin(struct hda_codec *codec) +{ + alc_automute_speaker(codec, 1); +} + static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, hda_nid_t nid) { @@ -1236,24 +1257,35 @@ static void alc_auto_init_amp(struct hda_codec *codec, int type) static void alc_init_auto_hp(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + int i; - if (!spec->autocfg.hp_pins[0]) - return; + if (!cfg->hp_pins[0]) { + if (cfg->line_out_type != AUTO_PIN_HP_OUT) + return; + } - if (!spec->autocfg.speaker_pins[0]) { - if (spec->autocfg.line_out_pins[0] && - spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) - spec->autocfg.speaker_pins[0] = - spec->autocfg.line_out_pins[0]; - else + if (!cfg->speaker_pins[0]) { + if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) return; + memcpy(cfg->speaker_pins, cfg->line_out_pins, + sizeof(cfg->speaker_pins)); + cfg->speaker_outs = cfg->line_outs; + } + + if (!cfg->hp_pins[0]) { + memcpy(cfg->hp_pins, cfg->line_out_pins, + sizeof(cfg->hp_pins)); + cfg->hp_outs = cfg->line_outs; } - snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", - spec->autocfg.hp_pins[0]); - snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0, + for (i = 0; i < cfg->hp_outs; i++) { + snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", + cfg->hp_pins[i]); + snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT); + } spec->unsol_event = alc_sku_unsol_event; } @@ -1711,31 +1743,7 @@ static struct hda_verb alc888_fujitsu_xa3530_verbs[] = { static void alc_automute_amp(struct hda_codec *codec) { - struct alc_spec *spec = codec->spec; - unsigned int mute; - hda_nid_t nid; - int i; - - spec->jack_present = 0; - for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { - nid = spec->autocfg.hp_pins[i]; - if (!nid) - break; - if (snd_hda_jack_detect(codec, nid)) { - spec->jack_present = 1; - break; - } - } - - mute = spec->jack_present ? HDA_AMP_MUTE : 0; - /* Toggle internal speakers muting */ - for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { - nid = spec->autocfg.speaker_pins[i]; - if (!nid) - break; - snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, - HDA_AMP_MUTE, mute); - } + alc_automute_speaker(codec, 0); } static void alc_automute_amp_unsol_event(struct hda_codec *codec, -- cgit v1.2.3 From 033688a5a80f9d56b2e7d56c4cb8188ae1448919 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 8 Sep 2010 15:47:09 +0200 Subject: ALSA: hda - Add multiple headphone support to ALC262 codec This patch changes the alc262 auto-parser to allow multiple pins assigned for a single purpose (line-out, headphone or speaker). Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 71 +++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 29 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ee59df7a41f..26069e397fc 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -11824,7 +11824,7 @@ static int alc262_check_volbit(hda_nid_t nid) } static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, - const char *pfx, int *vbits) + const char *pfx, int *vbits, int idx) { unsigned long val; int vbit; @@ -11839,11 +11839,11 @@ static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid, val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT); else val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT); - return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val); + return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val); } static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, - const char *pfx) + const char *pfx, int idx) { unsigned long val; @@ -11853,7 +11853,7 @@ static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid, val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); else val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); - return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val); + return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val); } /* add playback controls from the parsed DAC table */ @@ -11862,7 +11862,7 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, { const char *pfx; int vbits; - int err; + int i, err; spec->multiout.num_dacs = 1; /* only use one dac */ spec->multiout.dac_nids = spec->private_dac_nids; @@ -11872,39 +11872,52 @@ static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, pfx = "Master"; else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) pfx = "Speaker"; + else if (cfg->line_out_type == AUTO_PIN_HP_OUT) + pfx = "Headphone"; else pfx = "Front"; - err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx); - if (err < 0) - return err; - err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker"); - if (err < 0) - return err; - err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone"); - if (err < 0) - return err; + for (i = 0; i < 2; i++) { + err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i); + if (err < 0) + return err; + if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { + err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i], + "Speaker", i); + if (err < 0) + return err; + } + if (cfg->line_out_type != AUTO_PIN_HP_OUT) { + err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i], + "Headphone", i); + if (err < 0) + return err; + } + } vbits = alc262_check_volbit(cfg->line_out_pins[0]) | alc262_check_volbit(cfg->speaker_pins[0]) | alc262_check_volbit(cfg->hp_pins[0]); if (vbits == 1 || vbits == 2) pfx = "Master"; /* only one mixer is used */ - else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) - pfx = "Speaker"; - else - pfx = "Front"; vbits = 0; - err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits); - if (err < 0) - return err; - err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker", - &vbits); - if (err < 0) - return err; - err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone", - &vbits); - if (err < 0) - return err; + for (i = 0; i < 2; i++) { + err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx, + &vbits, i); + if (err < 0) + return err; + if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { + err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i], + "Speaker", &vbits, i); + if (err < 0) + return err; + } + if (cfg->line_out_type != AUTO_PIN_HP_OUT) { + err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i], + "Headphone", &vbits, i); + if (err < 0) + return err; + } + } return 0; } -- cgit v1.2.3 From 18675e4283f575594d55ef1239c14ab5b4de53b6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 8 Sep 2010 15:55:44 +0200 Subject: ALSA: hda - Add fixup for FSC Celsius H270 Added a fixup table for ALC262 codec containing the entry for FSC Celsius H270. Now both headphone jacks are detected properly as headphones. Reference: Novell bnc637263 https://bugzilla.novell.com/show_bug.cgi?id=637263 Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 26069e397fc..f11a9ca2c4b 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -12205,6 +12205,35 @@ static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = { {} }; +/* + * Pin config fixes + */ +enum { + PINFIX_FSC_H270, +}; + +static const struct alc_fixup alc262_fixups[] = { + [PINFIX_FSC_H270] = { + .pins = (const struct alc_pincfg[]) { + { 0x14, 0x99130110 }, /* speaker */ + { 0x15, 0x0221142f }, /* front HP */ + { 0x1b, 0x0121141f }, /* rear HP */ + { } + } + }, + [PINFIX_PB_M5210] = { + .verbs = (const struct hda_verb[]) { + { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, + {} + } + }, +}; + +static struct snd_pci_quirk alc262_fixup_tbl[] = { + SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270), + {} +}; + #ifdef CONFIG_SND_HDA_POWER_SAVE #define alc262_loopbacks alc880_loopbacks @@ -12628,6 +12657,9 @@ static int patch_alc262(struct hda_codec *codec) board_config = ALC262_AUTO; } + if (board_config == ALC262_AUTO) + alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1); + if (board_config == ALC262_AUTO) { /* automatic parse from the BIOS config */ err = alc262_parse_auto_config(codec); @@ -12696,6 +12728,9 @@ static int patch_alc262(struct hda_codec *codec) if (!spec->no_analog && has_cdefine_beep(codec)) set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); + if (board_config == ALC262_AUTO) + alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0); + spec->vmaster_nid = 0x0c; codec->patch_ops = alc_patch_ops; -- cgit v1.2.3 From 6cb3b707f95954ac18f19b4b3919af235738371a Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Thu, 9 Sep 2010 08:51:44 +0200 Subject: ALSA: HDA: Add fixup pins for Ideapad Y550 By adding the subwoofer as a speaker pin, it is treated correctly when auto-muting. BugLink: https://launchpad.net/bugs/611803 Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f11a9ca2c4b..0c25d22be87 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -18963,6 +18963,26 @@ static void alc662_auto_init(struct hda_codec *codec) alc_inithook(codec); } +enum { + ALC662_FIXUP_IDEAPAD, +}; + +static const struct alc_fixup alc662_fixups[] = { + [ALC662_FIXUP_IDEAPAD] = { + .pins = (const struct alc_pincfg[]) { + { 0x17, 0x99130112 }, /* subwoofer */ + { } + } + }, +}; + +static struct snd_pci_quirk alc662_fixup_tbl[] = { + SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), + {} +}; + + + static int patch_alc662(struct hda_codec *codec) { struct alc_spec *spec; @@ -18995,6 +19015,7 @@ static int patch_alc662(struct hda_codec *codec) } if (board_config == ALC662_AUTO) { + alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1); /* automatic parse from the BIOS config */ err = alc662_parse_auto_config(codec); if (err < 0) { @@ -19053,8 +19074,11 @@ static int patch_alc662(struct hda_codec *codec) spec->vmaster_nid = 0x02; codec->patch_ops = alc_patch_ops; - if (board_config == ALC662_AUTO) + if (board_config == ALC662_AUTO) { spec->init_hook = alc662_auto_init; + alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0); + } + #ifdef CONFIG_SND_HDA_POWER_SAVE if (!spec->loopback.amplist) spec->loopback.amplist = alc662_loopbacks; -- cgit v1.2.3 From da0dab5ecb5001f76e739e71ee199db4c61e7af2 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 9 Sep 2010 12:18:35 +0200 Subject: ALSA: virtuoso: fix WM8766 register writes with MSB The check for the volume update latch bit was accidentally in the wrong function, where it would prevent the MSB from being written, instead of correctly ignoring it for cached values. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/xonar_wm87x6.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index b82c1cfa96f..4346006df3e 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -97,8 +97,12 @@ static void wm8766_write(struct oxygen *chip, (0 << OXYGEN_SPI_CODEC_SHIFT) | OXYGEN_SPI_CEN_LATCH_CLOCK_LO, (reg << 9) | value); - if (reg < ARRAY_SIZE(data->wm8766_regs)) + if (reg < ARRAY_SIZE(data->wm8766_regs)) { + if ((reg >= WM8766_LDA1 && reg <= WM8766_RDA1) || + (reg >= WM8766_LDA2 && reg <= WM8766_MASTDA)) + value &= ~WM8766_UPDATE; data->wm8766_regs[reg] = value; + } } static void wm8766_write_cached(struct oxygen *chip, @@ -107,12 +111,8 @@ static void wm8766_write_cached(struct oxygen *chip, struct xonar_wm87x6 *data = chip->model_data; if (reg >= ARRAY_SIZE(data->wm8766_regs) || - value != data->wm8766_regs[reg]) { - if ((reg >= WM8766_LDA1 && reg <= WM8766_RDA1) || - (reg >= WM8766_LDA2 && reg <= WM8766_MASTDA)) - value &= ~WM8766_UPDATE; + value != data->wm8766_regs[reg]) wm8766_write(chip, reg, value); - } } static void wm8776_registers_init(struct oxygen *chip) -- cgit v1.2.3 From 9bac84edf0360ac94a27308778ef98dc9068777c Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 9 Sep 2010 12:19:21 +0200 Subject: ALSA: virtuoso: fix Xonar DS input switches Use the correct number, register bits, and names for the input switches. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/xonar_wm87x6.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index 4346006df3e..fb3f95ccafa 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -29,6 +29,13 @@ * GPIO 6 -> route input jack to input 1/2 (1/0) * GPIO 7 -> enable output to speakers * GPIO 8 -> enable output to speakers + * + * WM8766: + * + * input 1 <- line + * input 2 <- mic + * input 3 <- front mic + * input 4 <- aux */ #include @@ -896,7 +903,10 @@ static const struct snd_kcontrol_new ds_controls[] = { .put = wm8776_input_mux_put, .private_value = 1 << 1, }, - WM8776_BIT_SWITCH("Aux", WM8776_ADCMUX, 1 << 2, 0, 0), + WM8776_BIT_SWITCH("Front Mic Capture Switch", + WM8776_ADCMUX, 1 << 2, 0, 0), + WM8776_BIT_SWITCH("Aux Capture Switch", + WM8776_ADCMUX, 1 << 3, 0, 0), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "ADC Filter Capture Enum", -- cgit v1.2.3 From 435feac648cab190990aa0bf9355f77d1f082db3 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 9 Sep 2010 12:20:29 +0200 Subject: ALSA: virtuoso: add Xonar DS headphone jack detection Now that the polarity of the headphone detection pin is known, replace the debugging message with a proper jack plug input device. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/Kconfig | 1 + sound/pci/oxygen/xonar_wm87x6.c | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index e7a8cd058ef..b40f2b8df53 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -817,6 +817,7 @@ config SND_VIA82XX_MODEM config SND_VIRTUOSO tristate "Asus Virtuoso 100/200 (Xonar)" select SND_OXYGEN_LIB + select SND_JACK if INPUT=y || INPUT=SND help Say Y here to include support for sound cards based on the Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index fb3f95ccafa..9d57b5eee3f 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -25,8 +25,8 @@ * SPI 0 -> WM8766 (surround, center/LFE, back) * SPI 1 -> WM8776 (front, input) * - * GPIO 4 <- headphone detect - * GPIO 6 -> route input jack to input 1/2 (1/0) + * GPIO 4 <- headphone detect, 0 = plugged + * GPIO 6 -> route input jack to mic-in (0) or line-in (1) * GPIO 7 -> enable output to speakers * GPIO 8 -> enable output to speakers * @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -63,6 +64,7 @@ struct xonar_wm87x6 { struct snd_kcontrol *line_adcmux_control; struct snd_kcontrol *mic_adcmux_control; struct snd_kcontrol *lc_controls[13]; + struct snd_jack *hp_jack; }; static void wm8776_write(struct oxygen *chip, @@ -177,6 +179,16 @@ static void wm8776_init(struct oxygen *chip) wm8776_registers_init(chip); } +static void xonar_ds_report_hp_jack(struct oxygen *chip) +{ + struct xonar_wm87x6 *data = chip->model_data; + u16 bits; + + bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); + snd_jack_report(data->hp_jack, + bits & GPIO_DS_HP_DETECT ? 0 : SND_JACK_HEADPHONE); +} + static void xonar_ds_init(struct oxygen *chip) { struct xonar_wm87x6 *data = chip->model_data; @@ -195,6 +207,10 @@ static void xonar_ds_init(struct oxygen *chip) xonar_enable_output(chip); + snd_jack_new(chip->card, "Headphone", + SND_JACK_HEADPHONE, &data->hp_jack); + xonar_ds_report_hp_jack(chip); + snd_component_add(chip->card, "WM8776"); snd_component_add(chip->card, "WM8766"); } @@ -332,10 +348,7 @@ static void update_wm87x6_mute(struct oxygen *chip) static void xonar_ds_gpio_changed(struct oxygen *chip) { - u16 bits; - - bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); - snd_printk(KERN_INFO "HP detect: %d\n", !!(bits & GPIO_DS_HP_DETECT)); + xonar_ds_report_hp_jack(chip); } static int wm8776_bit_switch_get(struct snd_kcontrol *ctl, -- cgit v1.2.3 From 84cf83a28d4a3cd1fac1384cbaa4ed0ba650d309 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 9 Sep 2010 12:23:06 +0200 Subject: ALSA: virtuoso: automatically handle Xonar DS headphone routing Automatically mute the speaker outputs as long as a headphone is plugged. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/xonar_wm87x6.c | 57 +++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 13 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index 9d57b5eee3f..cee07fe3aa3 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -27,8 +27,8 @@ * * GPIO 4 <- headphone detect, 0 = plugged * GPIO 6 -> route input jack to mic-in (0) or line-in (1) - * GPIO 7 -> enable output to speakers - * GPIO 8 -> enable output to speakers + * GPIO 7 -> enable output to front L/R speaker channels + * GPIO 8 -> enable output to other speaker channels and front panel headphone * * WM8766: * @@ -52,7 +52,8 @@ #define GPIO_DS_HP_DETECT 0x0010 #define GPIO_DS_INPUT_ROUTE 0x0040 -#define GPIO_DS_OUTPUT_ENABLE 0x0180 +#define GPIO_DS_OUTPUT_FRONTLR 0x0080 +#define GPIO_DS_OUTPUT_ENABLE 0x0100 #define LC_CONTROL_LIMITER 0x40000000 #define LC_CONTROL_ALC 0x20000000 @@ -150,7 +151,10 @@ static void wm8776_registers_init(struct oxygen *chip) static void wm8766_registers_init(struct oxygen *chip) { + struct xonar_wm87x6 *data = chip->model_data; + wm8766_write(chip, WM8766_RESET, 0); + wm8766_write(chip, WM8766_DAC_CTRL, data->wm8766_regs[WM8766_DAC_CTRL]); wm8766_write(chip, WM8766_INT_CTRL, WM8766_FMT_LJUST | WM8766_IWL_24); wm8766_write(chip, WM8766_DAC_CTRL2, WM8766_ZCD | (chip->dac_mute ? WM8766_DMUTE_MASK : 0)); @@ -179,14 +183,38 @@ static void wm8776_init(struct oxygen *chip) wm8776_registers_init(chip); } -static void xonar_ds_report_hp_jack(struct oxygen *chip) +static void wm8766_init(struct oxygen *chip) { struct xonar_wm87x6 *data = chip->model_data; - u16 bits; - bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); - snd_jack_report(data->hp_jack, - bits & GPIO_DS_HP_DETECT ? 0 : SND_JACK_HEADPHONE); + data->wm8766_regs[WM8766_DAC_CTRL] = + WM8766_PL_LEFT_LEFT | WM8766_PL_RIGHT_RIGHT; + wm8766_registers_init(chip); +} + +static void xonar_ds_handle_hp_jack(struct oxygen *chip) +{ + struct xonar_wm87x6 *data = chip->model_data; + bool hp_plugged; + unsigned int reg; + + mutex_lock(&chip->mutex); + + hp_plugged = !(oxygen_read16(chip, OXYGEN_GPIO_DATA) & + GPIO_DS_HP_DETECT); + + oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, + hp_plugged ? 0 : GPIO_DS_OUTPUT_FRONTLR, + GPIO_DS_OUTPUT_FRONTLR); + + reg = data->wm8766_regs[WM8766_DAC_CTRL] & ~WM8766_MUTEALL; + if (hp_plugged) + reg |= WM8766_MUTEALL; + wm8766_write_cached(chip, WM8766_DAC_CTRL, reg); + + snd_jack_report(data->hp_jack, hp_plugged ? SND_JACK_HEADPHONE : 0); + + mutex_unlock(&chip->mutex); } static void xonar_ds_init(struct oxygen *chip) @@ -197,10 +225,12 @@ static void xonar_ds_init(struct oxygen *chip) data->generic.output_enable_bit = GPIO_DS_OUTPUT_ENABLE; wm8776_init(chip); - wm8766_registers_init(chip); + wm8766_init(chip); - oxygen_write16_masked(chip, OXYGEN_GPIO_CONTROL, GPIO_DS_INPUT_ROUTE, - GPIO_DS_HP_DETECT | GPIO_DS_INPUT_ROUTE); + oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, + GPIO_DS_INPUT_ROUTE | GPIO_DS_OUTPUT_FRONTLR); + oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, + GPIO_DS_HP_DETECT); oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, GPIO_DS_INPUT_ROUTE); oxygen_set_bits16(chip, OXYGEN_GPIO_INTERRUPT_MASK, GPIO_DS_HP_DETECT); chip->interrupt_mask |= OXYGEN_INT_GPIO; @@ -209,7 +239,7 @@ static void xonar_ds_init(struct oxygen *chip) snd_jack_new(chip->card, "Headphone", SND_JACK_HEADPHONE, &data->hp_jack); - xonar_ds_report_hp_jack(chip); + xonar_ds_handle_hp_jack(chip); snd_component_add(chip->card, "WM8776"); snd_component_add(chip->card, "WM8766"); @@ -231,6 +261,7 @@ static void xonar_ds_resume(struct oxygen *chip) wm8776_registers_init(chip); wm8766_registers_init(chip); xonar_enable_output(chip); + xonar_ds_handle_hp_jack(chip); } static void wm8776_adc_hardware_filter(unsigned int channel, @@ -348,7 +379,7 @@ static void update_wm87x6_mute(struct oxygen *chip) static void xonar_ds_gpio_changed(struct oxygen *chip) { - xonar_ds_report_hp_jack(chip); + xonar_ds_handle_hp_jack(chip); } static int wm8776_bit_switch_get(struct snd_kcontrol *ctl, -- cgit v1.2.3 From 2dbf0ea29c1e4dff4ee5f0c59b367168fa2e5a40 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 9 Sep 2010 12:24:35 +0200 Subject: ALSA: virtuoso: Xonar DS: add stereo upmixing to center/LFE channels Add the possibility to route a mix of the two channels of stereo data to the center and LFE outputs. Due to a WM8766 restriction, all surround and back channels also get the mixed L/R signal in this case. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/xonar_wm87x6.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index cee07fe3aa3..aceaaa036da 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -377,6 +377,24 @@ static void update_wm87x6_mute(struct oxygen *chip) (chip->dac_mute ? WM8766_DMUTE_MASK : 0)); } +static void update_wm8766_center_lfe_mix(struct oxygen *chip, bool mixed) +{ + struct xonar_wm87x6 *data = chip->model_data; + unsigned int reg; + + /* + * The WM8766 can mix left and right channels, but this setting + * applies to all three stereo pairs. + */ + reg = data->wm8766_regs[WM8766_DAC_CTRL] & + ~(WM8766_PL_LEFT_MASK | WM8766_PL_RIGHT_MASK); + if (mixed) + reg |= WM8766_PL_LEFT_LRMIX | WM8766_PL_RIGHT_LRMIX; + else + reg |= WM8766_PL_LEFT_LEFT | WM8766_PL_RIGHT_RIGHT; + wm8766_write_cached(chip, WM8766_DAC_CTRL, reg); +} + static void xonar_ds_gpio_changed(struct oxygen *chip) { xonar_ds_handle_hp_jack(chip); @@ -1067,6 +1085,7 @@ static const struct oxygen_model model_xonar_ds = { .set_adc_params = set_wm8776_adc_params, .update_dac_volume = update_wm87x6_volume, .update_dac_mute = update_wm87x6_mute, + .update_center_lfe_mix = update_wm8766_center_lfe_mix, .gpio_changed = xonar_ds_gpio_changed, .dac_tlv = wm87x6_dac_db_scale, .model_data_size = sizeof(struct xonar_wm87x6), -- cgit v1.2.3 From 99f08bf59019ca6c9056f10ee8f7e1ba6663251c Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 9 Sep 2010 12:25:29 +0200 Subject: ALSA: oxygen: fix CONFIG_SND_OXYGEN_LIB dependency selection As the select directive does not handle indirect dependencies, select those explicitly in the driver sections. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/Kconfig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index b40f2b8df53..0e75d558f30 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -207,12 +207,12 @@ config SND_CMIPCI config SND_OXYGEN_LIB tristate - select SND_PCM - select SND_MPU401_UART config SND_OXYGEN tristate "C-Media 8788 (Oxygen)" select SND_OXYGEN_LIB + select SND_PCM + select SND_MPU401_UART help Say Y here to include support for sound cards based on the C-Media CMI8788 (Oxygen HD Audio) chip: @@ -581,6 +581,8 @@ config SND_HDSPM config SND_HIFIER tristate "TempoTec HiFier Fantasia" select SND_OXYGEN_LIB + select SND_PCM + select SND_MPU401_UART help Say Y here to include support for the MediaTek/TempoTec HiFier Fantasia sound card. @@ -817,6 +819,8 @@ config SND_VIA82XX_MODEM config SND_VIRTUOSO tristate "Asus Virtuoso 100/200 (Xonar)" select SND_OXYGEN_LIB + select SND_PCM + select SND_MPU401_UART select SND_JACK if INPUT=y || INPUT=SND help Say Y here to include support for sound cards based on the -- cgit v1.2.3 From 51485e8e24919be10bd61dba1dede0032de2d952 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Thu, 9 Sep 2010 12:26:52 +0200 Subject: ALSA: virtuoso: update Kconfig text Update the Xonar config texts with the latest information about the Xonar DS, HDAV1.3 Slim, and Xense. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 0e75d558f30..12e34653b8a 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -817,17 +817,17 @@ config SND_VIA82XX_MODEM will be called snd-via82xx-modem. config SND_VIRTUOSO - tristate "Asus Virtuoso 100/200 (Xonar)" + tristate "Asus Virtuoso 66/100/200 (Xonar)" select SND_OXYGEN_LIB select SND_PCM select SND_MPU401_UART select SND_JACK if INPUT=y || INPUT=SND help Say Y here to include support for sound cards based on the - Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, + Asus AV66/AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X, DS, Essence ST (Deluxe), and Essence STX. - Support for the DS is experimental. - Support for the HDAV1.3 (Deluxe) is very experimental. + Support for the HDAV1.3 (Deluxe) is incomplete; for the + HDAV1.3 Slim and Xense, missing. To compile this driver as a module, choose M here: the module will be called snd-virtuoso. -- cgit v1.2.3 From b5786e85cb2ffd0b07e86dec38a442bd20765ad8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 14:21:17 +0200 Subject: ALSA: hda - Keep char arrays in input_mux items Keep char array in the input_mux item itself instead of pointing to an external string. This is a preliminary work for improving the input-mux name based on the pin role. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 18 ++++++------------ sound/pci/hda/hda_generic.c | 2 +- sound/pci/hda/hda_local.h | 6 +++--- sound/pci/hda/patch_analog.c | 6 +++--- sound/pci/hda/patch_realtek.c | 10 +++++----- sound/pci/hda/patch_sigmatel.c | 16 ++++++++-------- sound/pci/hda/patch_via.c | 15 ++++++++------- 7 files changed, 34 insertions(+), 39 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index bfdde7b0baf..4348c33c6b8 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4662,17 +4662,8 @@ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { }; EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); -static const char *input_labels[AUTO_PIN_LAST][4] = { - { "Mic", "Mic 2", "Mic 3", "Mic 4" }, - { "Front Mic", "Front Mic 2", "Front Mic 3", "Front Mic 4" }, - { "Line", "Line 2", "Line 3", "Line 4" }, - { "Front Line", "Front Line 2", "Front Line 3", "Front Line 4" }, - { "CD", "CD 2", "CD 3", "CD 4" }, - { "Aux", "Aux 2", "Aux 3", "Aux 4" }, -}; - -const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, - int input) +void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, + int input, char *str) { int type = cfg->inputs[input].type; int idx; @@ -4681,7 +4672,10 @@ const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, if (type != cfg->inputs[input].type) break; } - return input_labels[type][idx]; + if (idx > 0) + sprintf(str, "%s %d", auto_pin_cfg_labels[type], idx); + else + strcpy(str, auto_pin_cfg_labels[type]); } EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_label); diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 5ea21285ee1..cce18ba8b5a 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -566,7 +566,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, } label = spec->cap_labels[spec->input_mux.num_items]; strcpy(label, type); - spec->input_mux.items[spec->input_mux.num_items].label = label; + strcpy(spec->input_mux.items[spec->input_mux.num_items].label, label); /* unmute the PIN external input */ unmute_input(codec, node, 0); /* index = 0? */ diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index fb561748adb..b448b0a997b 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -215,7 +215,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid); */ #define HDA_MAX_NUM_INPUTS 16 struct hda_input_mux_item { - const char *label; + char label[32]; unsigned int index; }; struct hda_input_mux { @@ -391,8 +391,8 @@ struct auto_pin_cfg_item { }; struct auto_pin_cfg; -const char *snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, - int input); +void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, + int input, char *label); struct auto_pin_cfg { int line_outs; diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 3409d315f50..8de3a0dc45e 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -2926,13 +2926,13 @@ static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, type <= AUTO_PIN_FRONT_MIC); if (err < 0) return err; - imux->items[imux->num_items].label = - snd_hda_get_input_pin_label(cfg, i); + snd_hda_get_input_pin_label(cfg, i, + imux->items[imux->num_items].label); imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->inputs[i].pin); imux->num_items++; } - imux->items[imux->num_items].label = "Mix"; + strcpy(imux->items[imux->num_items].label, "Mix"); imux->items[imux->num_items].index = 9; imux->num_items++; diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 0c25d22be87..0a7d9d5ea40 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4974,8 +4974,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, if (idx < 0 && cap2) idx = get_connection_index(codec, cap2, pin); if (idx >= 0) { - imux->items[imux->num_items].label = - snd_hda_get_input_pin_label(cfg, i); + snd_hda_get_input_pin_label(cfg, i, + imux->items[imux->num_items].label); imux->items[imux->num_items].index = idx; imux->num_items++; } @@ -10626,9 +10626,9 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec) break; nid = cfg->inputs[i].pin; if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { - char label[32]; - snprintf(label, sizeof(label), "%s Boost", - snd_hda_get_input_pin_label(cfg, i)); + char pinname[32], label[32]; + snd_hda_get_input_pin_label(cfg, i, pinname); + snprintf(label, sizeof(label), "%s Boost", pinname); err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0, HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); if (err < 0) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 7f09e140953..852dae91edb 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -1116,7 +1116,7 @@ static int stac92xx_build_controls(struct hda_codec *codec) struct hda_input_mux *smux = &spec->private_smux; /* check for mute support on SPDIF out */ if (wcaps & AC_WCAP_OUT_AMP) { - smux->items[smux->num_items].label = "Off"; + strcpy(smux->items[smux->num_items].label, "Off"); smux->items[smux->num_items].index = 0; smux->num_items++; spec->spdif_mute = 1; @@ -3274,8 +3274,8 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) return -EINVAL; for (i = 0; i < num_cons; i++) { - mono_mux->items[mono_mux->num_items].label = - stac92xx_mono_labels[i]; + strcpy(mono_mux->items[mono_mux->num_items].label, + stac92xx_mono_labels[i]); mono_mux->items[mono_mux->num_items].index = i; mono_mux->num_items++; } @@ -3404,7 +3404,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) labels = stac92xx_spdif_labels; for (i = 0; i < num_cons; i++) { - spdif_mux->items[spdif_mux->num_items].label = labels[i]; + strcpy(spdif_mux->items[spdif_mux->num_items].label, labels[i]); spdif_mux->items[spdif_mux->num_items].index = i; spdif_mux->num_items++; } @@ -3538,7 +3538,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, int err, i; unsigned int def_conf; - dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; + strcpy(dimux->items[dimux->num_items].label, stac92xx_dmic_labels[0]); dimux->items[dimux->num_items].index = 0; dimux->num_items++; @@ -3572,11 +3572,11 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, return err; } - dimux->items[dimux->num_items].label = label; + strcpy(dimux->items[dimux->num_items].label, label); dimux->items[dimux->num_items].index = index; dimux->num_items++; if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { - imux->items[imux->num_items].label = label; + strcpy(imux->items[imux->num_items].label, label); imux->items[imux->num_items].index = index; imux->num_items++; } @@ -3713,7 +3713,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const if (err < 0) return err; - imux->items[imux->num_items].label = label; + strcpy(imux->items[imux->num_items].label, label); imux->items[imux->num_items].index = index; imux->num_items++; } diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 93b86adbce6..9c1909d398e 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -2376,7 +2376,7 @@ static void create_hp_imux(struct via_spec *spec) /* for hp mode select */ i = 0; while (texts[i] != NULL) { - imux->items[imux->num_items].label = texts[i]; + strcpy(imux->items[imux->num_items].label, texts[i]); imux->items[imux->num_items].index = i; imux->num_items++; i++; @@ -2423,7 +2423,8 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec, /* for internal loopback recording select */ for (idx = 0; idx < num_idxs; idx++) { if (pin_idxs[idx] == 0xff) { - imux->items[imux->num_items].label = "Stereo Mixer"; + strcpy(imux->items[imux->num_items].label, + "Stereo Mixer"); imux->items[imux->num_items].index = idx; imux->num_items++; break; @@ -2445,8 +2446,8 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec, type_idx, idx, cap_nid); if (err < 0) return err; - imux->items[imux->num_items].label = - snd_hda_get_input_pin_label(cfg, i); + snd_hda_get_input_pin_label(cfg, i, + imux->items[imux->num_items].label); imux->items[imux->num_items].index = idx; imux->num_items++; } @@ -4336,7 +4337,7 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) /* for hp mode select */ i = 0; while (texts[i] != NULL) { - imux->items[imux->num_items].label = texts[i]; + strcpy(imux->items[imux->num_items].label, texts[i]); imux->items[imux->num_items].index = i; imux->num_items++; i++; @@ -5520,7 +5521,7 @@ static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, return err; /* for digital mic select */ - imux->items[imux->num_items].label = "Digital Mic"; + strcpy(imux->items[imux->num_items].label, "Digital Mic"); imux->items[imux->num_items].index = 4; imux->num_items++; @@ -5843,7 +5844,7 @@ static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, return err; /* for digital mic select */ - imux->items[imux->num_items].label = "Digital Mic"; + strcpy(imux->items[imux->num_items].label, "Digital Mic"); imux->items[imux->num_items].index = 6; imux->num_items++; -- cgit v1.2.3 From 86e2959a10828dd2614e037fb2502bc833adca52 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 14:50:17 +0200 Subject: ALSA: hda - Remove AUTO_PIN_FRONT_{MIC|LINE} We can assign multiple pins to a single role now, let's reduce the redundant FRONT_MIC and FRONT_LINE. Also, autocfg->input_pins[] is no longer used, so this is removed as well. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 50 +++++------------------------------------- sound/pci/hda/hda_local.h | 5 +---- sound/pci/hda/patch_analog.c | 4 ++-- sound/pci/hda/patch_cirrus.c | 6 ++--- sound/pci/hda/patch_realtek.c | 8 +++---- sound/pci/hda/patch_sigmatel.c | 20 ++++++----------- sound/pci/hda/patch_via.c | 16 +++++++------- 7 files changed, 31 insertions(+), 78 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 4348c33c6b8..0ee4439c68c 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4396,7 +4396,7 @@ static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid, * output, i.e. to line_out_pins[0]. So, line_outs is always positive * if any analog output exists. * - * The analog input pins are assigned to input_pins array. + * The analog input pins are assigned to inputs array. * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, * respectively. */ @@ -4480,39 +4480,16 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, sequences_hp[cfg->hp_outs] = (assoc << 4) | seq; cfg->hp_outs++; break; - case AC_JACK_MIC_IN: { - int preferred, alt; - if (loc == AC_JACK_LOC_FRONT || - (loc & 0x30) == AC_JACK_LOC_INTERNAL) { - preferred = AUTO_PIN_FRONT_MIC; - alt = AUTO_PIN_MIC; - } else { - preferred = AUTO_PIN_MIC; - alt = AUTO_PIN_FRONT_MIC; - } - if (!cfg->input_pins[preferred]) - cfg->input_pins[preferred] = nid; - else if (!cfg->input_pins[alt]) - cfg->input_pins[alt] = nid; - add_auto_cfg_input_pin(cfg, nid, preferred); + case AC_JACK_MIC_IN: + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_MIC); break; - } - case AC_JACK_LINE_IN: { - int type; - if (loc == AC_JACK_LOC_FRONT) - type = AUTO_PIN_FRONT_LINE; - else - type = AUTO_PIN_LINE; - cfg->input_pins[type] = nid; - add_auto_cfg_input_pin(cfg, nid, type); + case AC_JACK_LINE_IN: + add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_LINE_IN); break; - } case AC_JACK_CD: - cfg->input_pins[AUTO_PIN_CD] = nid; add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_CD); break; case AC_JACK_AUX: - cfg->input_pins[AUTO_PIN_AUX] = nid; add_auto_cfg_input_pin(cfg, nid, AUTO_PIN_AUX); break; case AC_JACK_SPDIF_OUT: @@ -4570,21 +4547,6 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, sort_pins_by_sequence(cfg->hp_pins, sequences_hp, cfg->hp_outs); - /* if we have only one mic, make it AUTO_PIN_MIC */ - if (!cfg->input_pins[AUTO_PIN_MIC] && - cfg->input_pins[AUTO_PIN_FRONT_MIC]) { - cfg->input_pins[AUTO_PIN_MIC] = - cfg->input_pins[AUTO_PIN_FRONT_MIC]; - cfg->input_pins[AUTO_PIN_FRONT_MIC] = 0; - } - /* ditto for line-in */ - if (!cfg->input_pins[AUTO_PIN_LINE] && - cfg->input_pins[AUTO_PIN_FRONT_LINE]) { - cfg->input_pins[AUTO_PIN_LINE] = - cfg->input_pins[AUTO_PIN_FRONT_LINE]; - cfg->input_pins[AUTO_PIN_FRONT_LINE] = 0; - } - /* * FIX-UP: if no line-outs are detected, try to use speaker or HP pin * as a primary output @@ -4658,7 +4620,7 @@ EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); /* labels for input pins - for obsoleted config stuff */ const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" + "Mic", "Line", "CD", "Aux" }; EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index b448b0a997b..72e7b2f210e 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -366,9 +366,7 @@ struct hda_bus_unsolicited { enum { AUTO_PIN_MIC, - AUTO_PIN_FRONT_MIC, - AUTO_PIN_LINE, - AUTO_PIN_FRONT_LINE, + AUTO_PIN_LINE_IN, AUTO_PIN_CD, AUTO_PIN_AUX, AUTO_PIN_LAST @@ -403,7 +401,6 @@ struct auto_pin_cfg { int hp_outs; int line_out_type; /* AUTO_PIN_XXX_OUT */ hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; - hda_nid_t input_pins[AUTO_PIN_LAST]; /* old config; to be deprecated */ int num_inputs; struct auto_pin_cfg_item inputs[AUTO_CFG_MAX_INS]; int dig_outs; diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 8de3a0dc45e..85fc0b95460 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -2923,7 +2923,7 @@ static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, type_idx = 0; err = new_analog_input(spec, cfg->inputs[i].pin, auto_pin_cfg_labels[type], type_idx, - type <= AUTO_PIN_FRONT_MIC); + type == AUTO_PIN_MIC); if (err < 0) return err; snd_hda_get_input_pin_label(cfg, i, @@ -3015,7 +3015,7 @@ static void ad1988_auto_init_analog_input(struct hda_codec *codec) break; } snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, - i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); + i == AUTO_PIN_MIC ? PIN_VREF80 : PIN_IN); if (nid != AD1988_PIN_CD_NID) snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 6adfc562528..adb5ec50252 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -436,8 +436,8 @@ static int parse_input(struct hda_codec *codec) /* check whether the automatic mic switch is available */ if (spec->num_inputs == 2 && - cfg->inputs[0].type <= AUTO_PIN_FRONT_MIC && - cfg->inputs[1].type == AUTO_PIN_FRONT_MIC) { + cfg->inputs[0].type == AUTO_PIN_MIC && + cfg->inputs[1].type == AUTO_PIN_MIC) { if (is_ext_mic(codec, cfg->inputs[0].pin)) { if (!is_ext_mic(codec, cfg->inputs[1].pin)) { spec->mic_detect = 1; @@ -921,7 +921,7 @@ static void init_input(struct hda_codec *codec) continue; /* set appropriate pin control and mute first */ ctl = PIN_IN; - if (cfg->inputs[i].type <= AUTO_PIN_FRONT_MIC) { + if (cfg->inputs[i].type == AUTO_PIN_MIC) { unsigned int caps = snd_hda_query_pin_caps(codec, pin); caps >>= AC_PINCAP_VREF_SHIFT; if (caps & AC_PINCAP_VREF_80) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 0a7d9d5ea40..8ae30ccf537 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -846,7 +846,7 @@ static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, { unsigned int val = PIN_IN; - if (auto_pin_type <= AUTO_PIN_FRONT_MIC) { + if (auto_pin_type == AUTO_PIN_MIC) { unsigned int pincap; unsigned int oldval; oldval = snd_hda_codec_read(codec, nid, 0, @@ -1298,7 +1298,7 @@ static void alc_init_auto_mic(struct hda_codec *codec) /* there must be only two mic inputs exclusively */ for (i = 0; i < cfg->num_inputs; i++) - if (cfg->inputs[i].type >= AUTO_PIN_LINE) + if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN) return; fixed = ext = 0; @@ -10622,7 +10622,7 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec) hda_nid_t nid; for (i = 0; i < cfg->num_inputs; i++) { - if (cfg->inputs[i].type > AUTO_PIN_FRONT_MIC) + if (cfg->inputs[i].type > AUTO_PIN_MIC) break; nid = cfg->inputs[i].pin; if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { @@ -19270,7 +19270,7 @@ static void alc680_base_setup(struct hda_codec *codec) spec->autocfg.inputs[0].pin = 0x18; spec->autocfg.inputs[0].type = AUTO_PIN_MIC; spec->autocfg.inputs[1].pin = 0x19; - spec->autocfg.inputs[1].type = AUTO_PIN_LINE; + spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN; } static void alc680_unsol_event(struct hda_codec *codec, diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 852dae91edb..d9c8b4d335d 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -2834,7 +2834,7 @@ static hda_nid_t check_line_out_switch(struct hda_codec *codec) if (cfg->line_out_type != AUTO_PIN_LINE_OUT) return 0; for (i = 0; i < cfg->num_inputs; i++) { - if (cfg->inputs[i].type == AUTO_PIN_LINE) { + if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) { nid = cfg->inputs[i].pin; pincap = snd_hda_query_pin_caps(codec, nid); if (pincap & AC_PINCAP_OUT) @@ -2852,16 +2852,14 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) struct sigmatel_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int def_conf, pincap; - int i, mic_type; + int i; *dac = 0; if (cfg->line_out_type != AUTO_PIN_LINE_OUT) return 0; - mic_type = AUTO_PIN_MIC; - again: for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; - if (cfg->inputs[i].type != mic_type) + if (cfg->inputs[i].type != AUTO_PIN_MIC) continue; def_conf = snd_hda_codec_get_pincfg(codec, nid); /* some laptops have an internal analog microphone @@ -2875,10 +2873,6 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) } } } - if (mic_type == AUTO_PIN_MIC) { - mic_type = AUTO_PIN_FRONT_MIC; - goto again; - } return 0; } @@ -3222,7 +3216,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, } for (idx = 0; idx < cfg->num_inputs; idx++) { - if (cfg->inputs[idx].type > AUTO_PIN_FRONT_LINE) + if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN) break; nid = cfg->inputs[idx].pin; err = stac92xx_add_jack_mode_control(codec, nid, idx); @@ -3621,7 +3615,7 @@ static int set_mic_route(struct hda_codec *codec, if (pin == cfg->inputs[i].pin) break; } - if (i < cfg->num_inputs && cfg->inputs[i].type <= AUTO_PIN_FRONT_MIC) { + if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) { /* analog pin */ i = get_connection_index(codec, spec->mux_nids[0], pin); if (i < 0) @@ -3656,7 +3650,7 @@ static int stac_check_auto_mic(struct hda_codec *codec) int i; for (i = 0; i < cfg->num_inputs; i++) { - if (cfg->inputs[i].type >= AUTO_PIN_LINE) + if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN) return 0; /* must be exclusively mics */ } fixed = ext = 0; @@ -4394,7 +4388,7 @@ static int stac92xx_init(struct hda_codec *codec) hda_nid_t nid = cfg->inputs[i].pin; int type = cfg->inputs[i].type; unsigned int pinctl, conf; - if (type == AUTO_PIN_MIC || type == AUTO_PIN_FRONT_MIC) { + if (type == AUTO_PIN_MIC) { /* for mic pins, force to initialize */ pinctl = stac92xx_get_default_vref(codec, nid); pinctl |= AC_PINCTL_IN_EN; diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 9c1909d398e..de5f61d1b72 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -568,7 +568,7 @@ static void via_auto_init_analog_input(struct hda_codec *codec) hda_nid_t nid = cfg->inputs[i].pin; if (spec->smart51_enabled && is_smart51_pins(spec, nid)) ctl = PIN_OUT; - else if (i <= AUTO_PIN_FRONT_MIC) + else if (i == AUTO_PIN_MIC) ctl = PIN_VREF50; else ctl = PIN_IN; @@ -1328,7 +1328,7 @@ static int is_smart51_pins(struct via_spec *spec, hda_nid_t pin) for (i = 0; i < cfg->num_inputs; i++) { if (pin == cfg->inputs[i].pin) - return cfg->inputs[i].type < AUTO_PIN_FRONT_LINE; + return cfg->inputs[i].type <= AUTO_PIN_LINE_IN; } return 0; } @@ -1356,9 +1356,9 @@ static int via_smart51_get(struct snd_kcontrol *kcontrol, hda_nid_t nid = cfg->inputs[i].pin; int ctl = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); - if (cfg->inputs[i].type >= AUTO_PIN_FRONT_LINE) + if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) continue; - if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC && + if (cfg->inputs[i].type == AUTO_PIN_MIC && spec->hp_independent_mode && spec->codec_type != VT1718S) continue; /* ignore FMic for independent HP */ if ((ctl & AC_PINCTL_IN_EN) && !(ctl & AC_PINCTL_OUT_EN)) @@ -1382,9 +1382,9 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, hda_nid_t nid = cfg->inputs[i].pin; unsigned int parm; - if (cfg->inputs[i].type >= AUTO_PIN_FRONT_LINE) + if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) continue; - if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC && + if (cfg->inputs[i].type == AUTO_PIN_MIC && spec->hp_independent_mode && spec->codec_type != VT1718S) continue; /* don't retask FMic for independent HP */ @@ -1404,7 +1404,7 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol, codec, nid, HDA_OUTPUT, 0, HDA_AMP_MUTE, HDA_AMP_UNMUTE); } - if (cfg->inputs[i].type == AUTO_PIN_FRONT_MIC) { + if (cfg->inputs[i].type == AUTO_PIN_MIC) { if (spec->codec_type == VT1708S || spec->codec_type == VT1716S) { /* input = index 1 (AOW3) */ @@ -1450,7 +1450,7 @@ static int via_smart51_build(struct via_spec *spec) for (i = 0; i < cfg->num_inputs; i++) { nid = cfg->inputs[i].pin; - if (cfg->inputs[i].type < AUTO_PIN_FRONT_LINE) { + if (cfg->inputs[i].type <= AUTO_PIN_LINE_IN) { knew = via_clone_control(spec, &via_smart51_mixer[1]); if (knew == NULL) return -ENOMEM; -- cgit v1.2.3 From 10a20af7c944649dc6d1ffa06bc759f5f3a16cd9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 16:28:02 +0200 Subject: ALSA: hda - Improve the input source name labels This patch improves the input-source label strings to be generated from the pin information instead of fixed strings per AUTO_PIN_* type. This gives more suitable labels, especially for mic and line-in pins. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 91 +++++++++++++++++++++----- sound/pci/hda/hda_generic.c | 41 ++---------- sound/pci/hda/hda_local.h | 11 ++-- sound/pci/hda/patch_analog.c | 27 ++++---- sound/pci/hda/patch_ca0110.c | 3 +- sound/pci/hda/patch_cirrus.c | 4 +- sound/pci/hda/patch_realtek.c | 20 +++--- sound/pci/hda/patch_sigmatel.c | 144 ++++++----------------------------------- sound/pci/hda/patch_via.c | 100 ++++++++++++---------------- 9 files changed, 174 insertions(+), 267 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 0ee4439c68c..e3284341c48 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4607,7 +4607,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, snd_printd(" inputs:"); for (i = 0; i < cfg->num_inputs; i++) { snd_printdd(" %s=0x%x", - auto_pin_cfg_labels[cfg->inputs[i].type], + hda_get_autocfg_input_label(codec, cfg, i), cfg->inputs[i].pin); } snd_printd("\n"); @@ -4618,28 +4618,87 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); -/* labels for input pins - for obsoleted config stuff */ -const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { - "Mic", "Line", "CD", "Aux" -}; -EXPORT_SYMBOL_HDA(auto_pin_cfg_labels); +const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, + int check_location) +{ + unsigned int def_conf, loc; + + def_conf = snd_hda_codec_get_pincfg(codec, pin); + loc = get_defcfg_location(def_conf); + + switch (get_defcfg_device(def_conf)) { + case AC_JACK_MIC_IN: + if (!check_location) + return "Mic"; + if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || + (loc & 0x30) == AC_JACK_LOC_INTERNAL) + return "Internal Mic"; + if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) + return "Dock Mic"; + if (loc == AC_JACK_LOC_REAR) + return "Rear Mic"; + return "Mic"; + case AC_JACK_LINE_IN: + if (!check_location) + return "Line"; + if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE) + return "Dock Line"; + return "Line"; + case AC_JACK_AUX: + return "Aux"; + case AC_JACK_CD: + return "CD"; + case AC_JACK_SPDIF_IN: + return "SPDIF In"; + case AC_JACK_DIG_OTHER_IN: + return "Digital In"; + default: + return "Misc"; + } +} +EXPORT_SYMBOL_HDA(hda_get_input_pin_label); -void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, - int input, char *str) +const char *hda_get_autocfg_input_label(struct hda_codec *codec, + const struct auto_pin_cfg *cfg, + int input) { int type = cfg->inputs[input].type; - int idx; + int has_multiple_pins = 0; - for (idx = 0; idx < 3 && --input >= 0; idx++) { - if (type != cfg->inputs[input].type) - break; + if ((input > 0 && cfg->inputs[input - 1].type == type) || + (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) + has_multiple_pins = 1; + return hda_get_input_pin_label(codec, cfg->inputs[input].pin, + has_multiple_pins); +} +EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); + +int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, + int index, int *type_idx) +{ + int i, label_idx = 0; + if (imux->num_items >= HDA_MAX_NUM_INPUTS) { + snd_printd(KERN_ERR "hda_codec: Too many imux items!\n"); + return -EINVAL; + } + for (i = 0; i < imux->num_items; i++) { + if (!strncmp(label, imux->items[i].label, strlen(label))) + label_idx++; } - if (idx > 0) - sprintf(str, "%s %d", auto_pin_cfg_labels[type], idx); + if (type_idx) + *type_idx = label_idx; + if (label_idx > 0) + snprintf(imux->items[imux->num_items].label, + sizeof(imux->items[imux->num_items].label), + "%s %d", label, label_idx); else - strcpy(str, auto_pin_cfg_labels[type]); + strlcpy(imux->items[imux->num_items].label, label, + sizeof(imux->items[imux->num_items].label)); + imux->items[imux->num_items].index = index; + imux->num_items++; + return 0; } -EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_label); +EXPORT_SYMBOL_HDA(snd_hda_add_imux_item); #ifdef CONFIG_PM diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index cce18ba8b5a..fb0582f8d72 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -61,7 +61,6 @@ struct hda_gspec { struct hda_gnode *cap_vol_node; /* Node for capture volume */ unsigned int cur_cap_src; /* current capture source */ struct hda_input_mux input_mux; - char cap_labels[HDA_MAX_NUM_INPUTS][16]; unsigned int def_amp_in_caps; unsigned int def_amp_out_caps; @@ -506,11 +505,10 @@ static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl) * returns 0 if not found, 1 if found, or a negative error code. */ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, - struct hda_gnode *node) + struct hda_gnode *node, int idx) { int i, err; unsigned int pinctl; - char *label; const char *type; if (node->checked) @@ -523,7 +521,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, child = hda_get_node(spec, node->conn_list[i]); if (! child) continue; - err = parse_adc_sub_nodes(codec, spec, child); + err = parse_adc_sub_nodes(codec, spec, child, idx); if (err < 0) return err; if (err > 0) { @@ -564,9 +562,7 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, return 0; type = "Input"; } - label = spec->cap_labels[spec->input_mux.num_items]; - strcpy(label, type); - strcpy(spec->input_mux.items[spec->input_mux.num_items].label, label); + snd_hda_add_imux_item(&spec->input_mux, type, idx, NULL); /* unmute the PIN external input */ unmute_input(codec, node, 0); /* index = 0? */ @@ -577,29 +573,6 @@ static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, return 1; /* found */ } -/* add a capture source element */ -static void add_cap_src(struct hda_gspec *spec, int idx) -{ - struct hda_input_mux_item *csrc; - char *buf; - int num, ocap; - - num = spec->input_mux.num_items; - csrc = &spec->input_mux.items[num]; - buf = spec->cap_labels[num]; - for (ocap = 0; ocap < num; ocap++) { - if (! strcmp(buf, spec->cap_labels[ocap])) { - /* same label already exists, - * put the index number to be unique - */ - sprintf(buf, "%s %d", spec->cap_labels[ocap], num); - break; - } - } - csrc->index = idx; - spec->input_mux.num_items++; -} - /* * parse input */ @@ -624,22 +597,18 @@ static int parse_input_path(struct hda_codec *codec, struct hda_gnode *adc_node) for (i = 0; i < adc_node->nconns; i++) { node = hda_get_node(spec, adc_node->conn_list[i]); if (node && node->type == AC_WID_PIN) { - err = parse_adc_sub_nodes(codec, spec, node); + err = parse_adc_sub_nodes(codec, spec, node, i); if (err < 0) return err; - else if (err > 0) - add_cap_src(spec, i); } } /* ... then check the rests, more complicated connections */ for (i = 0; i < adc_node->nconns; i++) { node = hda_get_node(spec, adc_node->conn_list[i]); if (node && node->type != AC_WID_PIN) { - err = parse_adc_sub_nodes(codec, spec, node); + err = parse_adc_sub_nodes(codec, spec, node, i); if (err < 0) return err; - else if (err > 0) - add_cap_src(spec, i); } } diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 72e7b2f210e..6943efc78f6 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -378,8 +378,6 @@ enum { AUTO_PIN_HP_OUT }; -extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; - #define AUTO_CFG_MAX_OUTS 5 #define AUTO_CFG_MAX_INS 8 @@ -389,8 +387,13 @@ struct auto_pin_cfg_item { }; struct auto_pin_cfg; -void snd_hda_get_input_pin_label(const struct auto_pin_cfg *cfg, - int input, char *label); +const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, + int check_location); +const char *hda_get_autocfg_input_label(struct hda_codec *codec, + const struct auto_pin_cfg *cfg, + int input); +int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, + int index, int *type_index_ret); struct auto_pin_cfg { int line_outs; diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 85fc0b95460..05db1cfcd8b 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -2909,32 +2909,27 @@ static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, } /* create playback/capture controls for input pins */ -static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, +static int ad1988_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { + struct ad198x_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux; - int i, err, type, type_idx = 0; + int i, err, type, type_idx; for (i = 0; i < cfg->num_inputs; i++) { + const char *label; type = cfg->inputs[i].type; - if (i > 0 && type != cfg->inputs[i - 1].type) - type_idx++; - else - type_idx = 0; + label = hda_get_autocfg_input_label(codec, cfg, i); + snd_hda_add_imux_item(imux, label, + ad1988_pin_to_adc_idx(cfg->inputs[i].pin), + &type_idx); err = new_analog_input(spec, cfg->inputs[i].pin, - auto_pin_cfg_labels[type], type_idx, + label, type_idx, type == AUTO_PIN_MIC); if (err < 0) return err; - snd_hda_get_input_pin_label(cfg, i, - imux->items[imux->num_items].label); - imux->items[imux->num_items].index = - ad1988_pin_to_adc_idx(cfg->inputs[i].pin); - imux->num_items++; } - strcpy(imux->items[imux->num_items].label, "Mix"); - imux->items[imux->num_items].index = 9; - imux->num_items++; + snd_hda_add_imux_item(imux, "Mix", 9, NULL); if ((err = add_control(spec, AD_CTL_WIDGET_VOL, "Analog Mix Playback Volume", @@ -3046,7 +3041,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec) "Speaker")) < 0 || (err = ad1988_auto_create_extra_out(codec, spec->autocfg.hp_pins[0], "Headphone")) < 0 || - (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) + (err = ad1988_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) return err; spec->multiout.max_channels = spec->multiout.num_dacs * 2; diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index 42b3fb4cafc..cca11fdd3d7 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c @@ -474,8 +474,7 @@ static void parse_input(struct hda_codec *codec) if (j >= cfg->num_inputs) continue; spec->input_pins[n] = pin; - spec->input_labels[n] = - auto_pin_cfg_labels[cfg->inputs[j].type]; + spec->input_labels[n] = hda_get_input_pin_label(codec, pin, 1); spec->adcs[n] = nid; n++; } diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index adb5ec50252..ae75283a558 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -673,6 +673,7 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol, { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cs_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int idx; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -681,7 +682,8 @@ static int cs_capture_source_info(struct snd_kcontrol *kcontrol, if (uinfo->value.enumerated.item >= spec->num_inputs) uinfo->value.enumerated.item = spec->num_inputs - 1; idx = spec->input_idx[uinfo->value.enumerated.item]; - strcpy(uinfo->value.enumerated.name, auto_pin_cfg_labels[idx]); + strcpy(uinfo->value.enumerated.name, + hda_get_input_pin_label(codec, cfg->inputs[idx].pin, 1)); return 0; } diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 8ae30ccf537..9c2c19c8b05 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4947,6 +4947,7 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t pin; + const char *label; pin = cfg->inputs[i].pin; if (!alc_is_input_pin(codec, pin)) @@ -4957,12 +4958,13 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, type_idx++; else type_idx = 0; + label = hda_get_autocfg_input_label(codec, cfg, i); if (mixer) { idx = get_connection_index(codec, mixer, pin); if (idx >= 0) { err = new_analog_input(spec, pin, - auto_pin_cfg_labels[type], - type_idx, idx, mixer); + label, type_idx, + idx, mixer); if (err < 0) return err; } @@ -4973,12 +4975,8 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec, idx = get_connection_index(codec, cap1, pin); if (idx < 0 && cap2) idx = get_connection_index(codec, cap2, pin); - if (idx >= 0) { - snd_hda_get_input_pin_label(cfg, i, - imux->items[imux->num_items].label); - imux->items[imux->num_items].index = idx; - imux->num_items++; - } + if (idx >= 0) + snd_hda_add_imux_item(imux, label, idx, NULL); } return 0; } @@ -10626,9 +10624,9 @@ static int alc_auto_add_mic_boost(struct hda_codec *codec) break; nid = cfg->inputs[i].pin; if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { - char pinname[32], label[32]; - snd_hda_get_input_pin_label(cfg, i, pinname); - snprintf(label, sizeof(label), "%s Boost", pinname); + char label[32]; + snprintf(label, sizeof(label), "%s Boost", + hda_get_autocfg_input_label(codec, cfg, i)); err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0, HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); if (err < 0) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index d9c8b4d335d..e4e7d43f911 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -191,11 +191,6 @@ struct sigmatel_mic_route { signed char dmux_idx; }; -struct unique_input_names { - int num; - char uname[HDA_MAX_NUM_INPUTS][32]; -}; - struct sigmatel_spec { struct snd_kcontrol_new *mixers[4]; unsigned int num_mixers; @@ -312,7 +307,6 @@ struct sigmatel_spec { struct hda_input_mux private_imux; struct hda_input_mux private_smux; struct hda_input_mux private_mono_mux; - struct unique_input_names private_u_inp_names; }; static hda_nid_t stac9200_adc_nids[1] = { @@ -1116,9 +1110,7 @@ static int stac92xx_build_controls(struct hda_codec *codec) struct hda_input_mux *smux = &spec->private_smux; /* check for mute support on SPDIF out */ if (wcaps & AC_WCAP_OUT_AMP) { - strcpy(smux->items[smux->num_items].label, "Off"); - smux->items[smux->num_items].index = 0; - smux->num_items++; + snd_hda_add_imux_item(smux, "Off", 0, NULL); spec->spdif_mute = 1; } stac_smux_mixer.count = spec->num_smuxes; @@ -2797,7 +2789,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, } if (control) { - strcpy(name, auto_pin_cfg_labels[idx]); + strcpy(name, hda_get_input_pin_label(codec, nid, 1)); return stac92xx_add_control(codec->spec, control, strcat(name, " Jack Mode"), nid); } @@ -3267,12 +3259,9 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec) if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) return -EINVAL; - for (i = 0; i < num_cons; i++) { - strcpy(mono_mux->items[mono_mux->num_items].label, - stac92xx_mono_labels[i]); - mono_mux->items[mono_mux->num_items].index = i; - mono_mux->num_items++; - } + for (i = 0; i < num_cons; i++) + snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i, + NULL); return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX, "Mono Mux", spec->mono_nid); @@ -3397,11 +3386,8 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec) if (!labels) labels = stac92xx_spdif_labels; - for (i = 0; i < num_cons; i++) { - strcpy(spdif_mux->items[spdif_mux->num_items].label, labels[i]); - spdif_mux->items[spdif_mux->num_items].index = i; - spdif_mux->num_items++; - } + for (i = 0; i < num_cons; i++) + snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL); return 0; } @@ -3452,76 +3438,6 @@ static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, return 1; } -static const char *get_input_src_label(struct hda_codec *codec, hda_nid_t nid) -{ - unsigned int def_conf; - - def_conf = snd_hda_codec_get_pincfg(codec, nid); - - switch (get_defcfg_device(def_conf)) { - case AC_JACK_MIC_IN: - if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || - ((get_defcfg_location(def_conf) & 0xf0) - == AC_JACK_LOC_INTERNAL)) - return "Internal Mic"; - if ((get_defcfg_location(def_conf) & 0xf0) - == AC_JACK_LOC_SEPARATE) - return "Dock Mic"; - if (get_defcfg_location(def_conf) == AC_JACK_LOC_REAR) - return "Rear Mic"; - return "Mic"; - case AC_JACK_LINE_IN: - if ((get_defcfg_location(def_conf) & 0xf0) - == AC_JACK_LOC_SEPARATE) - return "Dock Line"; - return "Line"; - case AC_JACK_AUX: - return "Aux"; - case AC_JACK_CD: - return "CD"; - case AC_JACK_SPDIF_IN: - return "SPDIF In"; - case AC_JACK_DIG_OTHER_IN: - return "Digital In"; - } - - snd_printd("invalid inp pin %02x device config %08x", nid, def_conf); - return NULL; -} - -static const char *get_unique_inp_src_label(struct hda_codec *codec, - hda_nid_t nid) -{ - int i, n; - const char *label; - struct sigmatel_spec *spec = codec->spec; - struct hda_input_mux *imux = &spec->private_imux; - struct hda_input_mux *dimux = &spec->private_dimux; - struct unique_input_names *unames = &spec->private_u_inp_names; - - label = get_input_src_label(codec, nid); - n = 0; - - for (i = 0; i < imux->num_items; i++) { - if (!strncmp(label, imux->items[i].label, strlen(label))) - n++; - } - if (snd_hda_get_bool_hint(codec, "separate_dmux") == 1) { - for (i = 0; i < dimux->num_items; i++) { - if (!strncmp(label, dimux->items[i].label, - strlen(label))) - n++; - } - } - if (n > 0 && unames->num < HDA_MAX_NUM_INPUTS) { - sprintf(&unames->uname[unames->num][0], "%.28s %d", label, n); - label = &unames->uname[unames->num][0]; - unames->num++; - } - - return label; -} - /* create playback/capture controls for input pins on dmic capable codecs */ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) @@ -3532,13 +3448,11 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, int err, i; unsigned int def_conf; - strcpy(dimux->items[dimux->num_items].label, stac92xx_dmic_labels[0]); - dimux->items[dimux->num_items].index = 0; - dimux->num_items++; + snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL); for (i = 0; i < spec->num_dmics; i++) { hda_nid_t nid; - int index; + int index, type_idx; const char *label; nid = spec->dmic_nids[i]; @@ -3552,28 +3466,22 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, if (index < 0) continue; - label = get_unique_inp_src_label(codec, nid); - if (label == NULL) - return -EINVAL; + label = hda_get_input_pin_label(codec, nid, 1); + snd_hda_add_imux_item(dimux, label, index, &type_idx); - err = create_elem_capture_vol(codec, nid, label, 0, HDA_INPUT); + err = create_elem_capture_vol(codec, nid, label, type_idx, + HDA_INPUT); if (err < 0) return err; if (!err) { - err = create_elem_capture_vol(codec, nid, label, 0, - HDA_OUTPUT); + err = create_elem_capture_vol(codec, nid, label, + type_idx, HDA_OUTPUT); if (err < 0) return err; } - strcpy(dimux->items[dimux->num_items].label, label); - dimux->items[dimux->num_items].index = index; - dimux->num_items++; - if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { - strcpy(imux->items[imux->num_items].label, label); - imux->items[imux->num_items].index = index; - imux->num_items++; - } + if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) + snd_hda_add_imux_item(imux, label, index, NULL); } return 0; @@ -3675,12 +3583,12 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const { struct sigmatel_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux; - int i, j, type_idx = 0; + int i, j; const char *label; for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; - int index, err; + int index, err, type_idx; index = -1; for (j = 0; j < spec->num_muxes; j++) { @@ -3692,24 +3600,14 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const if (index < 0) continue; - if (i > 0 && cfg->inputs[i].type == cfg->inputs[i - 1].type) - type_idx++; - else - type_idx = 0; - - label = get_unique_inp_src_label(codec, nid); - if (label == NULL) - return -EINVAL; + label = hda_get_autocfg_input_label(codec, cfg, i); + snd_hda_add_imux_item(imux, label, index, &type_idx); err = create_elem_capture_vol(codec, nid, label, type_idx, HDA_INPUT); if (err < 0) return err; - - strcpy(imux->items[imux->num_items].label, label); - imux->items[imux->num_items].index = index; - imux->num_items++; } spec->num_analog_muxes = imux->num_items; diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index de5f61d1b72..d1c3f8defc4 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -2374,13 +2374,8 @@ static void create_hp_imux(struct via_spec *spec) static const char *texts[] = { "OFF", "ON", NULL}; /* for hp mode select */ - i = 0; - while (texts[i] != NULL) { - strcpy(imux->items[imux->num_items].label, texts[i]); - imux->items[imux->num_items].index = i; - imux->num_items++; - i++; - } + for (i = 0; texts[i]; i++) + snd_hda_add_imux_item(imux, texts[i], i, NULL); spec->hp_mux = &spec->private_imux[1]; } @@ -2412,26 +2407,25 @@ static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg, hda_nid_t cap_nid, hda_nid_t pin_idxs[], int num_idxs) { + struct via_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux[0]; int i, err, idx, type, type_idx = 0; /* for internal loopback recording select */ for (idx = 0; idx < num_idxs; idx++) { if (pin_idxs[idx] == 0xff) { - strcpy(imux->items[imux->num_items].label, - "Stereo Mixer"); - imux->items[imux->num_items].index = idx; - imux->num_items++; + snd_hda_add_imux_item(imux, "Stereo Mixer", idx, NULL); break; } } for (i = 0; i < cfg->num_inputs; i++) { + const char *label; type = cfg->inputs[i].type; for (idx = 0; idx < num_idxs; idx++) if (pin_idxs[idx] == cfg->inputs[i].pin) @@ -2442,24 +2436,21 @@ static int vt_auto_create_analog_input_ctls(struct via_spec *spec, type_idx++; else type_idx = 0; - err = via_new_analog_input(spec, auto_pin_cfg_labels[type], - type_idx, idx, cap_nid); + label = hda_get_autocfg_input_label(codec, cfg, i); + err = via_new_analog_input(spec, label, type_idx, idx, cap_nid); if (err < 0) return err; - snd_hda_get_input_pin_label(cfg, i, - imux->items[imux->num_items].label); - imux->items[imux->num_items].index = idx; - imux->num_items++; + snd_hda_add_imux_item(imux, label, idx, NULL); } return 0; } /* create playback/capture controls for input pins */ -static int vt1708_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1708_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x17, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x17, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -2559,7 +2550,7 @@ static int vt1708_parse_auto_config(struct hda_codec *codec) err = vt1708_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1708_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1708_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; /* add jack detect on/off control */ @@ -3026,11 +3017,11 @@ static int vt1709_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1709_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1709_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x18, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x18, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -3054,7 +3045,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec) err = vt1709_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1709_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1709_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -3556,11 +3547,11 @@ static int vt1708B_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1708B_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1708B_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -3584,7 +3575,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec) err = vt1708B_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1708B_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1708B_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -3992,11 +3983,11 @@ static int vt1708S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1708S_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1708S_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -4045,7 +4036,7 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec) err = vt1708S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1708S_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1708S_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -4335,24 +4326,19 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) imux = &spec->private_imux[1]; /* for hp mode select */ - i = 0; - while (texts[i] != NULL) { - strcpy(imux->items[imux->num_items].label, texts[i]); - imux->items[imux->num_items].index = i; - imux->num_items++; - i++; - } + for (i = 0; texts[i]; i++) + snd_hda_add_imux_item(imux, texts[i], i, NULL); spec->hp_mux = &spec->private_imux[1]; return 0; } /* create playback/capture controls for input pins */ -static int vt1702_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1702_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x14, 0x15, 0x18, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x1a, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x1a, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -4382,7 +4368,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec) (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) | (0x5 << AC_AMPCAP_STEP_SIZE_SHIFT) | (1 << AC_AMPCAP_MUTE_SHIFT)); - err = vt1702_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1702_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -4733,11 +4719,11 @@ static int vt1718S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1718S_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1718S_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -4762,7 +4748,7 @@ static int vt1718S_parse_auto_config(struct hda_codec *codec) err = vt1718S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1718S_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1718S_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -5195,11 +5181,11 @@ static int vt1716S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1716S_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1716S_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { static hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; - return vt_auto_create_analog_input_ctls(spec, cfg, 0x16, pin_idxs, + return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, ARRAY_SIZE(pin_idxs)); } @@ -5223,7 +5209,7 @@ static int vt1716S_parse_auto_config(struct hda_codec *codec) err = vt1716S_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1716S_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1716S_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -5504,14 +5490,15 @@ static int vt2002P_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt2002P_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { + struct via_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux[0]; static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0xff }; int err; - err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, ARRAY_SIZE(pin_idxs)); if (err < 0) return err; @@ -5521,9 +5508,7 @@ static int vt2002P_auto_create_analog_input_ctls(struct via_spec *spec, return err; /* for digital mic select */ - strcpy(imux->items[imux->num_items].label, "Digital Mic"); - imux->items[imux->num_items].index = 4; - imux->num_items++; + snd_hda_add_imux_item(imux, "Digital Mic", 4, NULL); return 0; } @@ -5551,7 +5536,7 @@ static int vt2002P_parse_auto_config(struct hda_codec *codec) err = vt2002P_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt2002P_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt2002P_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; @@ -5826,14 +5811,15 @@ static int vt1812_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) } /* create playback/capture controls for input pins */ -static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, +static int vt1812_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { + struct via_spec *spec = codec->spec; struct hda_input_mux *imux = &spec->private_imux[0]; static hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff }; int err; - err = vt_auto_create_analog_input_ctls(spec, cfg, 0x21, pin_idxs, + err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, ARRAY_SIZE(pin_idxs)); if (err < 0) return err; @@ -5844,9 +5830,7 @@ static int vt1812_auto_create_analog_input_ctls(struct via_spec *spec, return err; /* for digital mic select */ - strcpy(imux->items[imux->num_items].label, "Digital Mic"); - imux->items[imux->num_items].index = 6; - imux->num_items++; + snd_hda_add_imux_item(imux, "Digital Mic", 6, NULL); return 0; } @@ -5874,7 +5858,7 @@ static int vt1812_parse_auto_config(struct hda_codec *codec) err = vt1812_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]); if (err < 0) return err; - err = vt1812_auto_create_analog_input_ctls(spec, &spec->autocfg); + err = vt1812_auto_create_analog_input_ctls(codec, &spec->autocfg); if (err < 0) return err; -- cgit v1.2.3 From a1c985158382cbce0b58b3264f771b3b153668a6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 21:36:27 +0200 Subject: ALSA: hda - Reduce redundant mic location prefix in input source labels When the mic pins are assigned to the same location, we can omit the redundant location prefix like "Front" or "Rear". Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 90 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 13 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index e3284341c48..affb4607c6d 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4618,32 +4618,64 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); +enum { + MIC_ATTR_INT, + MIC_ATTR_DOCK, + MIC_ATTR_NORMAL, + MIC_ATTR_FRONT, + MIC_ATTR_REAR, +}; + +static int get_mic_pin_attr(unsigned int def_conf) +{ + unsigned int loc = get_defcfg_location(def_conf); + if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || + (loc & 0x30) == AC_JACK_LOC_INTERNAL) + return MIC_ATTR_INT; + if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) + return MIC_ATTR_DOCK; + if (loc == AC_JACK_LOC_REAR) + return MIC_ATTR_REAR; + if (loc == AC_JACK_LOC_FRONT) + return MIC_ATTR_FRONT; + return MIC_ATTR_NORMAL; +} + +enum { + LINE_ATTR_DOCK, + LINE_ATTR_NORMAL, +}; + +static int get_line_pin_attr(unsigned int def_conf) +{ + unsigned int loc = get_defcfg_location(def_conf); + if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE) + return LINE_ATTR_DOCK; + return LINE_ATTR_NORMAL; +} + const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, int check_location) { - unsigned int def_conf, loc; + unsigned int def_conf; + static const char *mic_names[] = { + "Internal Mic", "Dock Mic", "Mic", "Front Mic", "Rear Mic", + }; + static const char *line_names[] = { + "Dock Line", "Line", + }; def_conf = snd_hda_codec_get_pincfg(codec, pin); - loc = get_defcfg_location(def_conf); switch (get_defcfg_device(def_conf)) { case AC_JACK_MIC_IN: if (!check_location) return "Mic"; - if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || - (loc & 0x30) == AC_JACK_LOC_INTERNAL) - return "Internal Mic"; - if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) - return "Dock Mic"; - if (loc == AC_JACK_LOC_REAR) - return "Rear Mic"; - return "Mic"; + return mic_names[get_mic_pin_attr(def_conf)]; case AC_JACK_LINE_IN: if (!check_location) return "Line"; - if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE) - return "Dock Line"; - return "Line"; + return line_names[get_line_pin_attr(def_conf)]; case AC_JACK_AUX: return "Aux"; case AC_JACK_CD: @@ -4658,6 +4690,36 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, } EXPORT_SYMBOL_HDA(hda_get_input_pin_label); +/* Check whether the location prefix needs to be added to the label. + * If all mic-jacks are in the same location (e.g. rear panel), we don't + * have to put "Front" prefix to each label. In such a case, returns false. + */ +static int check_mic_location_need(struct hda_codec *codec, + const struct auto_pin_cfg *cfg, + int input) +{ + unsigned int defc; + int i, attr, attr2; + + defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); + attr = get_mic_pin_attr(defc); + /* for internal or docking mics, we need locations */ + if (attr <= MIC_ATTR_NORMAL) + return 1; + + attr = 0; + for (i = 0; i < cfg->num_inputs; i++) { + defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); + attr2 = get_mic_pin_attr(defc); + if (attr2 >= MIC_ATTR_NORMAL) { + if (attr && attr != attr2) + return 1; /* different locations found */ + attr = attr2; + } + } + return 0; +} + const char *hda_get_autocfg_input_label(struct hda_codec *codec, const struct auto_pin_cfg *cfg, int input) @@ -4668,6 +4730,8 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec, if ((input > 0 && cfg->inputs[input - 1].type == type) || (input < cfg->num_inputs - 1 && cfg->inputs[input + 1].type == type)) has_multiple_pins = 1; + if (has_multiple_pins && type == AUTO_PIN_MIC) + has_multiple_pins &= check_mic_location_need(codec, cfg, input); return hda_get_input_pin_label(codec, cfg->inputs[input].pin, has_multiple_pins); } -- cgit v1.2.3 From 990061c28ab6c84e1120afb772b69d92d8965da8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 22:08:44 +0200 Subject: ALSA: hda - Add comments to new helper functions Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index affb4607c6d..ec38bdfad81 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4654,6 +4654,14 @@ static int get_line_pin_attr(unsigned int def_conf) return LINE_ATTR_NORMAL; } +/** + * hda_get_input_pin_label - Give a label for the given input pin + * + * When check_location is true, the function checks the pin location + * for mic and line-in pins, and set an appropriate prefix like "Front", + * "Rear", "Internal". + */ + const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, int check_location) { @@ -4720,6 +4728,14 @@ static int check_mic_location_need(struct hda_codec *codec, return 0; } +/** + * hda_get_autocfg_input_label - Get a label for the given input + * + * Get a label for the given input pin defined by the autocfg item. + * Unlike hda_get_input_pin_label(), this function checks all inputs + * defined in autocfg and avoids the redundant mic/line prefix as much as + * possible. + */ const char *hda_get_autocfg_input_label(struct hda_codec *codec, const struct auto_pin_cfg *cfg, int input) @@ -4737,6 +4753,13 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(hda_get_autocfg_input_label); +/** + * snd_hda_add_imux_item - Add an item to input_mux + * + * When the same label is used already in the existing items, the number + * suffix is appended to the label. This label index number is stored + * to type_idx when non-NULL pointer is given. + */ int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, int index, int *type_idx) { -- cgit v1.2.3 From 4a4d4a6985dd37a3c96534027f054be796bf95f6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 9 Sep 2010 22:22:02 +0200 Subject: ALSA: hda - Sort input pins in snd_hda_parse_pin_def_config() Sort inputs[] array in autocfg so that the codec parsers can filter out easily per input pin types. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index ec38bdfad81..08d81b87302 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4383,6 +4383,23 @@ static void add_auto_cfg_input_pin(struct auto_pin_cfg *cfg, hda_nid_t nid, } } +/* sort inputs in the order of AUTO_PIN_* type */ +static void sort_autocfg_input_pins(struct auto_pin_cfg *cfg) +{ + int i, j; + + for (i = 0; i < cfg->num_inputs; i++) { + for (j = i + 1; j < cfg->num_inputs; j++) { + if (cfg->inputs[i].type > cfg->inputs[j].type) { + struct auto_pin_cfg_item tmp; + tmp = cfg->inputs[i]; + cfg->inputs[i] = cfg->inputs[j]; + cfg->inputs[j] = tmp; + } + } + } +} + /* * Parse all pin widgets and store the useful pin nids to cfg * @@ -4585,6 +4602,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, break; } + sort_autocfg_input_pins(cfg); + /* * debug prints of the parsed results */ -- cgit v1.2.3 From 9ad0e496519d99eb2c34f01e41500a775122c744 Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Tue, 14 Sep 2010 23:22:00 +0200 Subject: ALSA: hda - Add input jack layer support to Realtek codec Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 98 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 9c2c19c8b05..3b040870365 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "hda_codec.h" #include "hda_local.h" #include "hda_beep.h" @@ -282,6 +283,12 @@ struct alc_mic_route { unsigned char amix_idx; }; +struct alc_jack { + hda_nid_t nid; + int type; + struct snd_jack *jack; +}; + #define MUX_IDX_UNDEF ((unsigned char)-1) struct alc_customize_define { @@ -357,6 +364,9 @@ struct alc_spec { /* PCM information */ struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ + /* jack detection */ + struct snd_array jacks; + /* dynamic controls, init_verbs and input_mux */ struct auto_pin_cfg autocfg; struct alc_customize_define cdefine; @@ -990,6 +1000,91 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, alc_fix_pll(codec); } +#ifdef CONFIG_SND_HDA_INPUT_JACK +static void alc_free_jack_priv(struct snd_jack *jack) +{ + struct alc_jack *jacks = jack->private_data; + jacks->nid = 0; + jacks->jack = NULL; +} + +static int alc_add_jack(struct hda_codec *codec, + hda_nid_t nid, int type) +{ + struct alc_spec *spec; + struct alc_jack *jack; + const char *name; + int err; + + spec = codec->spec; + snd_array_init(&spec->jacks, sizeof(*jack), 32); + jack = snd_array_new(&spec->jacks); + if (!jack) + return -ENOMEM; + + jack->nid = nid; + jack->type = type; + name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ; + + err = snd_jack_new(codec->bus->card, name, type, &jack->jack); + if (err < 0) + return err; + jack->jack->private_data = jack; + jack->jack->private_free = alc_free_jack_priv; + return 0; +} + +static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid) +{ + struct alc_spec *spec = codec->spec; + struct alc_jack *jacks = spec->jacks.list; + + if (jacks) { + int i; + for (i = 0; i < spec->jacks.used; i++) { + if (jacks->nid == nid) { + unsigned int present; + present = snd_hda_jack_detect(codec, nid); + + present = (present) ? jacks->type : 0; + + snd_jack_report(jacks->jack, present); + } + jacks++; + } + } +} + +static int alc_init_jacks(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int err; + unsigned int hp_nid = spec->autocfg.hp_pins[0]; + unsigned int mic_nid = spec->ext_mic.pin; + + err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE); + if (err < 0) + return err; + alc_report_jack(codec, hp_nid); + + err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE); + if (err < 0) + return err; + alc_report_jack(codec, mic_nid); + + return 0; +} +#else +static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid) +{ +} + +static inline int alc_init_jacks(struct hda_codec *codec) +{ + return 0; +} +#endif + static void alc_automute_speaker(struct hda_codec *codec, int pinctl) { struct alc_spec *spec = codec->spec; @@ -1006,6 +1101,7 @@ static void alc_automute_speaker(struct hda_codec *codec, int pinctl) spec->jack_present = 1; break; } + alc_report_jack(codec, spec->autocfg.hp_pins[i]); } mute = spec->jack_present ? HDA_AMP_MUTE : 0; @@ -1111,6 +1207,7 @@ static void alc_mic_automute(struct hda_codec *codec) AC_VERB_SET_CONNECT_SEL, alive->mux_idx); } + alc_report_jack(codec, spec->ext_mic.pin); /* FIXME: analog mixer */ } @@ -14496,6 +14593,7 @@ static void alc269_auto_init(struct hda_codec *codec) alc269_auto_init_hp_out(codec); alc269_auto_init_analog_input(codec); alc_auto_init_digital(codec); + alc_init_jacks(codec); if (spec->unsol_event) alc_inithook(codec); } -- cgit v1.2.3 From 977ddd6b2e63716cfefe669bbdb30ec0bcea1fe4 Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Wed, 15 Sep 2010 10:02:29 +0200 Subject: ALSA: hda - Set up COEFs for ALC269 to avoid click noises at power-saving For avoiding the click noises at power-saving, set some COEF values for ALC269* codecs. Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 114 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 3b040870365..ab2947d8723 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1673,6 +1673,15 @@ static int alc_read_coef_idx(struct hda_codec *codec, return val; } +static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, + unsigned int coef_val) +{ + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, + coef_idx); + snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, + coef_val); +} + /* set right pin controls for digital I/O */ static void alc_auto_init_digital(struct hda_codec *codec) { @@ -14598,6 +14607,68 @@ static void alc269_auto_init(struct hda_codec *codec) alc_inithook(codec); } +#ifdef CONFIG_SND_HDA_POWER_SAVE +static int alc269_suspend(struct hda_codec *codec, pm_message_t state) +{ + struct alc_spec *spec = codec->spec; + int val; + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { + val = alc_read_coef_idx(codec, 0x04); + /* Power down output pin */ + alc_write_coef_idx(codec, 0x04, val & ~(1<<11)); + } + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { + val = alc_read_coef_idx(codec, 0x04); + /* Power down output pin */ + alc_write_coef_idx(codec, 0x04, val & ~(1<<11)); + msleep(150); + } + + alc_shutup(codec); + if (spec && spec->power_hook) + spec->power_hook(codec); + return 0; +} +#endif +#ifdef SND_HDA_NEEDS_RESUME +static int alc269_resume(struct hda_codec *codec) +{ + int val; + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { + val = alc_read_coef_idx(codec, 0x04); + /* Power down output pin */ + alc_write_coef_idx(codec, 0x04, val & ~(1<<11)); + msleep(150); + } + + codec->patch_ops.init(codec); + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { + val = alc_read_coef_idx(codec, 0x04); + /* Power up output pin */ + alc_write_coef_idx(codec, 0x04, val | (1<<11)); + msleep(200); + } + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { + val = alc_read_coef_idx(codec, 0x04); + /* Power up output pin */ + alc_write_coef_idx(codec, 0x04, val | (1<<11)); + } + + snd_hda_codec_resume_amp(codec); + snd_hda_codec_resume_cache(codec); +#ifdef CONFIG_SND_HDA_POWER_SAVE + if (codec->patch_ops.check_power_status) + codec->patch_ops.check_power_status(codec, 0x01); +#endif + return 0; +} +#endif + enum { ALC269_FIXUP_SONY_VAIO, }; @@ -14814,6 +14885,41 @@ static struct alc_config_preset alc269_presets[] = { }, }; +static int alc269_fill_coef(struct hda_codec *codec) +{ + int val; + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) { + alc_write_coef_idx(codec, 0xf, 0x960b); + alc_write_coef_idx(codec, 0xe, 0x8817); + } + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) { + alc_write_coef_idx(codec, 0xf, 0x960b); + alc_write_coef_idx(codec, 0xe, 0x8814); + } + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { + val = alc_read_coef_idx(codec, 0x04); + /* Power up output pin */ + alc_write_coef_idx(codec, 0x04, val | (1<<11)); + } + + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { + val = alc_read_coef_idx(codec, 0xd); + if ((val & 0x0c00) >> 10 != 0x1) { + /* Capless ramp up clock control */ + alc_write_coef_idx(codec, 0xd, val | 1<<10); + } + val = alc_read_coef_idx(codec, 0x17); + if ((val & 0x01c0) >> 6 != 0x4) { + /* Class D power on reset */ + alc_write_coef_idx(codec, 0x17, val | 1<<7); + } + } + return 0; +} + static int patch_alc269(struct hda_codec *codec) { struct alc_spec *spec; @@ -14839,6 +14945,8 @@ static int patch_alc269(struct hda_codec *codec) } else alc_fix_pll_init(codec, 0x20, 0x04, 15); + alc269_fill_coef(codec); + board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, alc269_models, alc269_cfg_tbl); @@ -14917,6 +15025,12 @@ static int patch_alc269(struct hda_codec *codec) spec->vmaster_nid = 0x02; codec->patch_ops = alc_patch_ops; +#ifdef CONFIG_SND_HDA_POWER_SAVE + codec->patch_ops.suspend = alc269_suspend; +#endif +#ifdef SND_HDA_NEEDS_RESUME + codec->patch_ops.resume = alc269_resume; +#endif if (board_config == ALC269_AUTO) spec->init_hook = alc269_auto_init; #ifdef CONFIG_SND_HDA_POWER_SAVE -- cgit v1.2.3 From f2e5731dfd3ba08b023d0626d36ccf78f54ab5e7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 15 Sep 2010 10:07:08 +0200 Subject: ALSA: hda - Preliminary support for new Conexant audio codecs This patch adds the preliminary support for new Conexant audio codecs with 14f1:5097, 14f1:5098, 14f1:50a1, 14f1:50a2, 14f1:50ab, 14f1:50ac, 14f1:50b8 and 14f1:50b9. Unlike other Conexant parsers, this is designed to be mostly automatic, parsing from BIOS pin configurations. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 640 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 639 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 972e7c453b3..7eee0ff65ac 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -57,6 +57,12 @@ struct conexant_jack { }; +struct pin_dac_pair { + hda_nid_t pin; + hda_nid_t dac; + int type; +}; + struct conexant_spec { struct snd_kcontrol_new *mixers[5]; @@ -77,6 +83,7 @@ struct conexant_spec { unsigned int cur_eapd; unsigned int hp_present; unsigned int auto_mic; + int auto_mic_ext; /* autocfg.inputs[] index for ext mic */ unsigned int need_dac_fix; /* capture */ @@ -110,9 +117,12 @@ struct conexant_spec { struct auto_pin_cfg autocfg; struct hda_input_mux private_imux; hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; + struct pin_dac_pair dac_info[8]; + int dac_info_filled; - unsigned int dell_automute; unsigned int port_d_mode; + unsigned int auto_mute:1; /* used in auto-parser */ + unsigned int dell_automute:1; unsigned int dell_vostro:1; unsigned int ideapad:1; unsigned int thinkpad:1; @@ -3253,6 +3263,610 @@ static int patch_cxt5066(struct hda_codec *codec) return 0; } +/* + * Automatic parser for CX20641 & co + */ + +static hda_nid_t cx_auto_adc_nids[] = { 0x14 }; + +/* get the connection index of @nid in the widget @mux */ +static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, + hda_nid_t nid) +{ + hda_nid_t conn[HDA_MAX_NUM_INPUTS]; + int i, nums; + + nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); + for (i = 0; i < nums; i++) + if (conn[i] == nid) + return i; + return -1; +} + +/* get an unassigned DAC from the given list. + * Return the nid if found and reduce the DAC list, or return zero if + * not found + */ +static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t pin, + hda_nid_t *dacs, int *num_dacs) +{ + int i, nums = *num_dacs; + hda_nid_t ret = 0; + + for (i = 0; i < nums; i++) { + if (get_connection_index(codec, pin, dacs[i]) >= 0) { + ret = dacs[i]; + break; + } + } + if (!ret) + return 0; + if (--nums > 0) + memmove(dacs, dacs + 1, nums * sizeof(hda_nid_t)); + *num_dacs = nums; + return ret; +} + +#define MAX_AUTO_DACS 5 + +/* fill analog DAC list from the widget tree */ +static int fill_cx_auto_dacs(struct hda_codec *codec, hda_nid_t *dacs) +{ + hda_nid_t nid, end_nid; + int nums = 0; + + end_nid = codec->start_nid + codec->num_nodes; + for (nid = codec->start_nid; nid < end_nid; nid++) { + unsigned int wcaps = get_wcaps(codec, nid); + unsigned int type = get_wcaps_type(wcaps); + if (type == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) { + dacs[nums++] = nid; + if (nums >= MAX_AUTO_DACS) + break; + } + } + return nums; +} + +/* fill pin_dac_pair list from the pin and dac list */ +static int fill_dacs_for_pins(struct hda_codec *codec, hda_nid_t *pins, + int num_pins, hda_nid_t *dacs, int *rest, + struct pin_dac_pair *filled, int type) +{ + int i, nums; + + nums = 0; + for (i = 0; i < num_pins; i++) { + filled[nums].pin = pins[i]; + filled[nums].type = type; + filled[nums].dac = get_unassigned_dac(codec, pins[i], dacs, rest); + nums++; + } + return nums; +} + +/* parse analog output paths */ +static void cx_auto_parse_output(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + hda_nid_t dacs[MAX_AUTO_DACS]; + int i, j, nums, rest; + + rest = fill_cx_auto_dacs(codec, dacs); + /* parse all analog output pins */ + nums = fill_dacs_for_pins(codec, cfg->line_out_pins, cfg->line_outs, + dacs, &rest, spec->dac_info, + AUTO_PIN_LINE_OUT); + nums += fill_dacs_for_pins(codec, cfg->hp_pins, cfg->hp_outs, + dacs, &rest, spec->dac_info + nums, + AUTO_PIN_HP_OUT); + nums += fill_dacs_for_pins(codec, cfg->speaker_pins, cfg->speaker_outs, + dacs, &rest, spec->dac_info + nums, + AUTO_PIN_SPEAKER_OUT); + spec->dac_info_filled = nums; + /* fill multiout struct */ + for (i = 0; i < nums; i++) { + hda_nid_t dac = spec->dac_info[i].dac; + if (!dac) + continue; + switch (spec->dac_info[i].type) { + case AUTO_PIN_LINE_OUT: + spec->private_dac_nids[spec->multiout.num_dacs] = dac; + spec->multiout.num_dacs++; + break; + case AUTO_PIN_HP_OUT: + case AUTO_PIN_SPEAKER_OUT: + if (!spec->multiout.hp_nid) { + spec->multiout.hp_nid = dac; + break; + } + for (j = 0; j < ARRAY_SIZE(spec->multiout.extra_out_nid); j++) + if (!spec->multiout.extra_out_nid[j]) { + spec->multiout.extra_out_nid[j] = dac; + break; + } + break; + } + } + spec->multiout.dac_nids = spec->private_dac_nids; + spec->multiout.max_channels = nums * 2; + + if (cfg->hp_outs > 0) + spec->auto_mute = 1; + spec->vmaster_nid = spec->private_dac_nids[0]; +} + +/* auto-mute/unmute speaker and line outs according to headphone jack */ +static void cx_auto_hp_automute(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + int i, present; + + if (!spec->auto_mute) + return; + present = 0; + for (i = 0; i < cfg->hp_outs; i++) { + if (snd_hda_jack_detect(codec, cfg->hp_pins[i])) { + present = 1; + break; + } + } + for (i = 0; i < cfg->line_outs; i++) { + snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + present ? 0 : PIN_OUT); + } + for (i = 0; i < cfg->speaker_outs; i++) { + snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, + present ? 0 : PIN_OUT); + } +} + +/* automatic switch internal and external mic */ +static void cx_auto_automic(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + struct hda_input_mux *imux = &spec->private_imux; + int ext_idx = spec->auto_mic_ext; + + if (!spec->auto_mic) + return; + if (snd_hda_jack_detect(codec, cfg->inputs[ext_idx].pin)) { + snd_hda_codec_write(codec, spec->adc_nids[0], 0, + AC_VERB_SET_CONNECT_SEL, + imux->items[ext_idx].index); + } else { + snd_hda_codec_write(codec, spec->adc_nids[0], 0, + AC_VERB_SET_CONNECT_SEL, + imux->items[!ext_idx].index); + } +} + +static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) +{ + int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20; + switch (res >> 26) { + case CONEXANT_HP_EVENT: + cx_auto_hp_automute(codec); + conexant_report_jack(codec, nid); + break; + case CONEXANT_MIC_EVENT: + cx_auto_automic(codec); + conexant_report_jack(codec, nid); + break; + } +} + +static int is_int_mic_conn(unsigned int def_conf) +{ + unsigned int loc = get_defcfg_location(def_conf); + return get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || + (loc & 0x30) == AC_JACK_LOC_INTERNAL; +} + +/* return true if it's an internal-mic pin */ +static int is_int_mic(struct hda_codec *codec, hda_nid_t pin) +{ + unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); + return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && + is_int_mic_conn(def_conf); +} + +/* return true if it's an external-mic pin */ +static int is_ext_mic(struct hda_codec *codec, hda_nid_t pin) +{ + unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); + return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && + !is_int_mic_conn(def_conf); +} + +/* check whether the pin config is suitable for auto-mic switching; + * auto-mic is enabled only when one int-mic and one-ext mic exist + */ +static void cx_auto_check_auto_mic(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + + if (is_ext_mic(codec, cfg->inputs[0].pin) && + is_int_mic(codec, cfg->inputs[1].pin)) { + spec->auto_mic = 1; + spec->auto_mic_ext = 1; + return; + } + if (is_int_mic(codec, cfg->inputs[1].pin) && + is_ext_mic(codec, cfg->inputs[0].pin)) { + spec->auto_mic = 1; + spec->auto_mic_ext = 0; + return; + } +} + +static void cx_auto_parse_input(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + struct hda_input_mux *imux; + int i; + + imux = &spec->private_imux; + for (i = 0; i < cfg->num_inputs; i++) { + int idx = get_connection_index(codec, spec->adc_nids[0], + cfg->inputs[i].pin); + if (idx >= 0) { + const char *label; + label = hda_get_autocfg_input_label(codec, cfg, i); + snd_hda_add_imux_item(imux, label, idx, NULL); + } + } + if (imux->num_items == 2 && cfg->num_inputs == 2) + cx_auto_check_auto_mic(codec); + if (imux->num_items > 1 && !spec->auto_mic) + spec->input_mux = imux; +} + +/* get digital-input audio widget corresponding to the given pin */ +static hda_nid_t cx_auto_get_dig_in(struct hda_codec *codec, hda_nid_t pin) +{ + hda_nid_t nid, end_nid; + + end_nid = codec->start_nid + codec->num_nodes; + for (nid = codec->start_nid; nid < end_nid; nid++) { + unsigned int wcaps = get_wcaps(codec, nid); + unsigned int type = get_wcaps_type(wcaps); + if (type == AC_WID_AUD_IN && (wcaps & AC_WCAP_DIGITAL)) { + if (get_connection_index(codec, nid, pin) >= 0) + return nid; + } + } + return 0; +} + +static void cx_auto_parse_digital(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + hda_nid_t nid; + + if (cfg->dig_outs && + snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) == 1) + spec->multiout.dig_out_nid = nid; + if (cfg->dig_in_pin) + spec->dig_in_nid = cx_auto_get_dig_in(codec, cfg->dig_in_pin); +} + +#ifdef CONFIG_SND_HDA_INPUT_BEEP +static void cx_auto_parse_beep(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + hda_nid_t nid, end_nid; + + end_nid = codec->start_nid + codec->num_nodes; + for (nid = codec->start_nid; nid < end_nid; nid++) + if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP) { + set_beep_amp(spec, nid, 0, HDA_OUTPUT); + break; + } +} +#else +#define cx_auto_parse_beep(codec) +#endif + +static int cx_auto_parse_auto_config(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + int err; + + err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL); + if (err < 0) + return err; + + cx_auto_parse_output(codec); + cx_auto_parse_input(codec); + cx_auto_parse_digital(codec); + cx_auto_parse_beep(codec); + return 0; +} + +static void cx_auto_turn_on_eapd(struct hda_codec *codec, int num_pins, + hda_nid_t *pins) +{ + int i; + for (i = 0; i < num_pins; i++) { + if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD) + snd_hda_codec_write(codec, pins[i], 0, + AC_VERB_SET_EAPD_BTLENABLE, 0x02); + } +} + +static void select_connection(struct hda_codec *codec, hda_nid_t pin, + hda_nid_t src) +{ + int idx = get_connection_index(codec, pin, src); + if (idx >= 0) + snd_hda_codec_write(codec, pin, 0, + AC_VERB_SET_CONNECT_SEL, idx); +} + +static void cx_auto_init_output(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + hda_nid_t nid; + int i; + + for (i = 0; i < spec->multiout.num_dacs; i++) + snd_hda_codec_write(codec, spec->multiout.dac_nids[i], 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE); + + for (i = 0; i < cfg->hp_outs; i++) + snd_hda_codec_write(codec, cfg->hp_pins[i], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP); + if (spec->auto_mute) { + for (i = 0; i < cfg->hp_outs; i++) { + snd_hda_codec_write(codec, cfg->hp_pins[i], 0, + AC_VERB_SET_UNSOLICITED_ENABLE, + AC_USRSP_EN | CONEXANT_HP_EVENT); + } + cx_auto_hp_automute(codec); + } else { + for (i = 0; i < cfg->line_outs; i++) + snd_hda_codec_write(codec, cfg->line_out_pins[i], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + for (i = 0; i < cfg->speaker_outs; i++) + snd_hda_codec_write(codec, cfg->speaker_pins[i], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + } + + for (i = 0; i < spec->dac_info_filled; i++) { + nid = spec->dac_info[i].dac; + if (!nid) + nid = spec->multiout.dac_nids[0]; + select_connection(codec, spec->dac_info[i].pin, nid); + } + + /* turn on EAPD */ + cx_auto_turn_on_eapd(codec, cfg->line_outs, cfg->line_out_pins); + cx_auto_turn_on_eapd(codec, cfg->hp_outs, cfg->hp_pins); + cx_auto_turn_on_eapd(codec, cfg->speaker_outs, cfg->speaker_pins); +} + +static void cx_auto_init_input(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + int i; + + for (i = 0; i < spec->num_adc_nids; i++) + snd_hda_codec_write(codec, spec->adc_nids[i], 0, + AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)); + + for (i = 0; i < cfg->num_inputs; i++) { + unsigned int type; + if (cfg->inputs[i].type == AUTO_PIN_MIC) + type = PIN_VREF80; + else + type = PIN_IN; + snd_hda_codec_write(codec, cfg->inputs[i].pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, type); + } + + if (spec->auto_mic) { + int ext_idx = spec->auto_mic_ext; + snd_hda_codec_write(codec, cfg->inputs[ext_idx].pin, 0, + AC_VERB_SET_UNSOLICITED_ENABLE, + AC_USRSP_EN | CONEXANT_MIC_EVENT); + cx_auto_automic(codec); + } else { + for (i = 0; i < spec->num_adc_nids; i++) { + snd_hda_codec_write(codec, spec->adc_nids[i], 0, + AC_VERB_SET_CONNECT_SEL, + spec->private_imux.items[0].index); + } + } +} + +static void cx_auto_init_digital(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + + if (spec->multiout.dig_out_nid) + snd_hda_codec_write(codec, cfg->dig_out_pins[0], 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); + if (spec->dig_in_nid) + snd_hda_codec_write(codec, cfg->dig_in_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN); +} + +static int cx_auto_init(struct hda_codec *codec) +{ + /*snd_hda_sequence_write(codec, cx_auto_init_verbs);*/ + cx_auto_init_output(codec); + cx_auto_init_input(codec); + cx_auto_init_digital(codec); + return 0; +} + +static int cx_auto_add_volume(struct hda_codec *codec, const char *basename, + const char *dir, int cidx, + hda_nid_t nid, int hda_dir) +{ + static char name[32]; + static struct snd_kcontrol_new knew[] = { + HDA_CODEC_VOLUME(name, 0, 0, 0), + HDA_CODEC_MUTE(name, 0, 0, 0), + }; + static char *sfx[2] = { "Volume", "Switch" }; + int i, err; + + for (i = 0; i < 2; i++) { + struct snd_kcontrol *kctl; + knew[i].private_value = HDA_COMPOSE_AMP_VAL(nid, 3, 0, hda_dir); + knew[i].subdevice = HDA_SUBDEV_AMP_FLAG; + knew[i].index = cidx; + snprintf(name, sizeof(name), "%s%s %s", basename, dir, sfx[i]); + kctl = snd_ctl_new1(&knew[i], codec); + if (!kctl) + return -ENOMEM; + err = snd_hda_ctl_add(codec, nid, kctl); + if (err < 0) + return err; + if (!(query_amp_caps(codec, nid, hda_dir) & AC_AMPCAP_MUTE)) + break; + } + return 0; +} + +#define cx_auto_add_pb_volume(codec, nid, str, idx) \ + cx_auto_add_volume(codec, str, " Playback", idx, nid, HDA_OUTPUT) + +static int cx_auto_build_output_controls(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + int i, err; + int num_line = 0, num_hp = 0, num_spk = 0; + static const char *texts[3] = { "Front", "Surround", "CLFE" }; + + if (spec->dac_info_filled == 1) + return cx_auto_add_pb_volume(codec, spec->dac_info[0].dac, + "Master", 0); + for (i = 0; i < spec->dac_info_filled; i++) { + const char *label; + int idx, type; + if (!spec->dac_info[i].dac) + continue; + type = spec->dac_info[i].type; + if (type == AUTO_PIN_LINE_OUT) + type = spec->autocfg.line_out_type; + switch (type) { + case AUTO_PIN_LINE_OUT: + default: + label = texts[num_line++]; + idx = 0; + break; + case AUTO_PIN_HP_OUT: + label = "Headphone"; + idx = num_hp++; + break; + case AUTO_PIN_SPEAKER_OUT: + label = "Speaker"; + idx = num_spk++; + break; + } + err = cx_auto_add_pb_volume(codec, spec->dac_info[i].dac, + label, idx); + if (err < 0) + return err; + } + return 0; +} + +static int cx_auto_build_input_controls(struct hda_codec *codec) +{ + struct conexant_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + static const char *prev_label; + int i, err, cidx; + + err = cx_auto_add_volume(codec, "Capture", "", 0, spec->adc_nids[0], + HDA_INPUT); + if (err < 0) + return err; + prev_label = NULL; + cidx = 0; + for (i = 0; i < cfg->num_inputs; i++) { + hda_nid_t nid = cfg->inputs[i].pin; + const char *label; + if (!(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) + continue; + label = hda_get_autocfg_input_label(codec, cfg, i); + if (label == prev_label) + cidx++; + else + cidx = 0; + prev_label = label; + err = cx_auto_add_volume(codec, label, " Capture", cidx, + nid, HDA_INPUT); + if (err < 0) + return err; + } + return 0; +} + +static int cx_auto_build_controls(struct hda_codec *codec) +{ + int err; + + err = cx_auto_build_output_controls(codec); + if (err < 0) + return err; + err = cx_auto_build_input_controls(codec); + if (err < 0) + return err; + return conexant_build_controls(codec); +} + +static struct hda_codec_ops cx_auto_patch_ops = { + .build_controls = cx_auto_build_controls, + .build_pcms = conexant_build_pcms, + .init = cx_auto_init, + .free = conexant_free, + .unsol_event = cx_auto_unsol_event, +#ifdef CONFIG_SND_HDA_POWER_SAVE + .suspend = conexant_suspend, +#endif + .reboot_notify = snd_hda_shutup_pins, +}; + +static int patch_conexant_auto(struct hda_codec *codec) +{ + struct conexant_spec *spec; + int err; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (!spec) + return -ENOMEM; + codec->spec = spec; + spec->adc_nids = cx_auto_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(cx_auto_adc_nids); + spec->capsrc_nids = spec->adc_nids; + err = cx_auto_parse_auto_config(codec); + if (err < 0) { + kfree(codec->spec); + codec->spec = NULL; + return err; + } + codec->patch_ops = cx_auto_patch_ops; + if (spec->beep_amp) + snd_hda_attach_beep_device(codec, spec->beep_amp); + return 0; +} + /* */ @@ -3271,6 +3885,22 @@ static struct hda_codec_preset snd_hda_preset_conexant[] = { .patch = patch_cxt5066 }, { .id = 0x14f15069, .name = "CX20585", .patch = patch_cxt5066 }, + { .id = 0x14f15097, .name = "CX20631", + .patch = patch_conexant_auto }, + { .id = 0x14f15098, .name = "CX20632", + .patch = patch_conexant_auto }, + { .id = 0x14f150a1, .name = "CX20641", + .patch = patch_conexant_auto }, + { .id = 0x14f150a2, .name = "CX20642", + .patch = patch_conexant_auto }, + { .id = 0x14f150ab, .name = "CX20651", + .patch = patch_conexant_auto }, + { .id = 0x14f150ac, .name = "CX20652", + .patch = patch_conexant_auto }, + { .id = 0x14f150b8, .name = "CX20664", + .patch = patch_conexant_auto }, + { .id = 0x14f150b9, .name = "CX20665", + .patch = patch_conexant_auto }, {} /* terminator */ }; @@ -3281,6 +3911,14 @@ MODULE_ALIAS("snd-hda-codec-id:14f15066"); MODULE_ALIAS("snd-hda-codec-id:14f15067"); MODULE_ALIAS("snd-hda-codec-id:14f15068"); MODULE_ALIAS("snd-hda-codec-id:14f15069"); +MODULE_ALIAS("snd-hda-codec-id:14f15097"); +MODULE_ALIAS("snd-hda-codec-id:14f15098"); +MODULE_ALIAS("snd-hda-codec-id:14f150a1"); +MODULE_ALIAS("snd-hda-codec-id:14f150a2"); +MODULE_ALIAS("snd-hda-codec-id:14f150ab"); +MODULE_ALIAS("snd-hda-codec-id:14f150ac"); +MODULE_ALIAS("snd-hda-codec-id:14f150b8"); +MODULE_ALIAS("snd-hda-codec-id:14f150b9"); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Conexant HD-audio codec"); -- cgit v1.2.3 From b686453543fd56332e8730a2abd7bf5bca756149 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 15 Sep 2010 10:17:26 +0200 Subject: ALSA: hda - Reduce pci id list for Intel with class id Most of Intel controllers work as generic HD-audio without quirks, and it'll be hopefully so in future. Let's mark pci id with the PCI_CLASS_MULTIMEDIA_HD_AUDIO for Intel so that the driver will work with any new control chips in future. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 34940a07905..5f6f9039a41 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2735,25 +2735,17 @@ static void __devexit azx_remove(struct pci_dev *pci) /* PCI IDs */ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { - /* ICH 6..10 */ - { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x269a), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x284b), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x2911), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x293e), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x293f), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x3a3e), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH }, - /* PCH */ - { PCI_DEVICE(0x8086, 0x3b56), .driver_data = AZX_DRIVER_ICH }, - { PCI_DEVICE(0x8086, 0x3b57), .driver_data = AZX_DRIVER_ICH }, /* CPT */ { PCI_DEVICE(0x8086, 0x1c20), .driver_data = AZX_DRIVER_PCH }, /* PBG */ { PCI_DEVICE(0x8086, 0x1d20), .driver_data = AZX_DRIVER_PCH }, /* SCH */ { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH }, + /* Generic Intel */ + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID), + .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, + .class_mask = 0xffffff, + .driver_data = AZX_DRIVER_ICH }, /* ATI SB 450/600 */ { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI }, { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI }, -- cgit v1.2.3 From 3b119f662d9054d734e3c74d662e7de6d7b35687 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 15 Sep 2010 15:53:50 +0200 Subject: ALSA: hda - Add quirk for Acer laptop with CX20585 codec Its pin configuration is compatible with ideapad. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 7eee0ff65ac..7e22ed14ae8 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3098,6 +3098,7 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", CXT5066_DELL_LAPTOP), SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), + SND_PCI_QUIRK(0x1025, 0x040a, "Acer", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTO), SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), -- cgit v1.2.3 From 5855fb8076e784a657bc2441cd29f166c7c1ea8c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 16 Sep 2010 18:24:02 +0200 Subject: ALSA: hda - Fix initialization of secondary headphone and speaker The secondary or later headphones or speakers aren't initialized preoprly for some codecs. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ab2947d8723..945826da23b 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -10634,16 +10634,21 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; hda_nid_t pin, dac; + int i; - pin = spec->autocfg.hp_pins[0]; - if (pin) { + for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) { + pin = spec->autocfg.hp_pins[i]; + if (!pin) + break; dac = spec->multiout.hp_nid; if (!dac) dac = spec->multiout.dac_nids[0]; /* to front */ alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); } - pin = spec->autocfg.speaker_pins[0]; - if (pin) { + for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) { + pin = spec->autocfg.speaker_pins[i]; + if (!pin) + break; dac = spec->multiout.extra_out_nid[0]; if (!dac) dac = spec->multiout.dac_nids[0]; /* to front */ -- cgit v1.2.3 From 30ea098fc000bb05081a1999269658f1a88af36a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 16 Sep 2010 18:47:56 +0200 Subject: ALSA: hda - Fix input-pin setup for Realtek codecs Through the transition of autocfg to individual inputs array, I forgot to rewrite the argument passed to alc_set_input_pin(). This resulted in wrongly setup input pins. Fixed now. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 945826da23b..5df88798895 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -5160,7 +5160,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec) for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; if (alc_is_input_pin(codec, nid)) { - alc_set_input_pin(codec, nid, i); + alc_set_input_pin(codec, nid, cfg->inputs[i].type); if (nid != ALC880_PIN_CD_NID && (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) snd_hda_codec_write(codec, nid, 0, @@ -6793,7 +6793,7 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec) for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; if (nid >= 0x12) { - alc_set_input_pin(codec, nid, i); + alc_set_input_pin(codec, nid, cfg->inputs[i].type); if (nid != ALC260_PIN_CD_NID && (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) snd_hda_codec_write(codec, nid, 0, @@ -10664,7 +10664,7 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec) for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; - alc_set_input_pin(codec, nid, i); + alc_set_input_pin(codec, nid, cfg->inputs[i].type); if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, @@ -15856,7 +15856,7 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec) for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; if (nid >= 0x0c && nid <= 0x11) - alc_set_input_pin(codec, nid, i); + alc_set_input_pin(codec, nid, cfg->inputs[i].type); } } @@ -16849,7 +16849,7 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec) for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; if (alc_is_input_pin(codec, nid)) { - alc_set_input_pin(codec, nid, i); + alc_set_input_pin(codec, nid, cfg->inputs[i].type); if (nid != ALC861VD_PIN_CD_NID && (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) snd_hda_codec_write(codec, nid, 0, @@ -19086,7 +19086,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec) for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; if (alc_is_input_pin(codec, nid)) { - alc_set_input_pin(codec, nid, i); + alc_set_input_pin(codec, nid, cfg->inputs[i].type); if (nid != ALC662_PIN_CD_NID && (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)) snd_hda_codec_write(codec, nid, 0, -- cgit v1.2.3 From 9907790aa06bfc04bf78b445e732ea10039c61e4 Mon Sep 17 00:00:00 2001 From: Charles Chin Date: Fri, 17 Sep 2010 10:22:32 +0200 Subject: ALSA: hda - Fix automatic MIC switching and include dock MIC for IDT codecs Signed-off-by: Charles Chin Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index e4e7d43f911..7eb359a030d 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -263,6 +263,7 @@ struct sigmatel_spec { struct sigmatel_mic_route ext_mic; struct sigmatel_mic_route int_mic; + struct sigmatel_mic_route dock_mic; const char **spdif_labels; @@ -3488,7 +3489,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, } static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, - hda_nid_t *fixed, hda_nid_t *ext) + hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock) { unsigned int cfg; @@ -3496,15 +3497,22 @@ static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, return 0; cfg = snd_hda_codec_get_pincfg(codec, nid); switch (get_defcfg_connect(cfg)) { + case AC_JACK_PORT_BOTH: case AC_JACK_PORT_FIXED: if (*fixed) return 1; /* already occupied */ *fixed = nid; break; case AC_JACK_PORT_COMPLEX: - if (*ext) - return 1; /* already occupied */ - *ext = nid; + if ((get_defcfg_location(cfg) & 0xF0) == AC_JACK_LOC_SEPARATE) { + if (*dock) + return 1; /* already occupied */ + *dock = nid; + } else { + if (*ext) + return 1; /* already occupied */ + *ext = nid; + } break; } return 0; @@ -3519,6 +3527,8 @@ static int set_mic_route(struct hda_codec *codec, int i; mic->pin = pin; + if (pin == 0) + return 0; for (i = 0; i < cfg->num_inputs; i++) { if (pin == cfg->inputs[i].pin) break; @@ -3554,26 +3564,29 @@ static int stac_check_auto_mic(struct hda_codec *codec) { struct sigmatel_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; - hda_nid_t fixed, ext; + hda_nid_t fixed, ext, dock; int i; for (i = 0; i < cfg->num_inputs; i++) { if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN) return 0; /* must be exclusively mics */ } - fixed = ext = 0; + fixed = ext = dock = 0; for (i = 0; i < cfg->num_inputs; i++) - if (check_mic_pin(codec, cfg->inputs[i].pin, &fixed, &ext)) + if (check_mic_pin(codec, cfg->inputs[i].pin, + &fixed, &ext, &dock)) return 0; for (i = 0; i < spec->num_dmics; i++) - if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext)) + if (check_mic_pin(codec, spec->dmic_nids[i], + &fixed, &ext, &dock)) return 0; - if (!fixed || !ext) - return 0; + if (!fixed && !ext && !dock) + return 0; /* no input to switch */ if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP)) return 0; /* no unsol support */ if (set_mic_route(codec, &spec->ext_mic, ext) || - set_mic_route(codec, &spec->int_mic, fixed)) + set_mic_route(codec, &spec->int_mic, fixed) || + set_mic_route(codec, &spec->dock_mic, dock)) return 0; /* something is wrong */ return 1; } @@ -4281,6 +4294,9 @@ static int stac92xx_init(struct hda_codec *codec) AC_VERB_SET_CONNECT_SEL, 0); if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT)) stac_issue_unsol_event(codec, spec->ext_mic.pin); + if (enable_pin_detect(codec, spec->dock_mic.pin, + STAC_MIC_EVENT)) + stac_issue_unsol_event(codec, spec->dock_mic.pin); } for (i = 0; i < cfg->num_inputs; i++) { hda_nid_t nid = cfg->inputs[i].pin; @@ -4698,6 +4714,8 @@ static void stac92xx_mic_detect(struct hda_codec *codec) if (get_pin_presence(codec, spec->ext_mic.pin)) mic = &spec->ext_mic; + else if (get_pin_presence(codec, spec->dock_mic.pin)) + mic = &spec->dock_mic; else mic = &spec->int_mic; if (mic->dmux_idx >= 0) -- cgit v1.2.3 From 41c89ef3aafea5f35601fa75edba90e7417f604e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 17 Sep 2010 10:26:37 +0200 Subject: ALSA: hda - Fix mic attribute check for internal mics Now Windows claims that the BIOS sets pins for internal mics to be BOTH connection instead of FIXED. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 08d81b87302..9f668efbe42 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4648,8 +4648,11 @@ enum { static int get_mic_pin_attr(unsigned int def_conf) { unsigned int loc = get_defcfg_location(def_conf); - if (get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || - (loc & 0x30) == AC_JACK_LOC_INTERNAL) + unsigned int conn = get_defcfg_connect(def_conf); + /* Windows may claim the internal mic to be BOTH, too */ + if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH) + return MIC_ATTR_INT; + if ((loc & 0x30) == AC_JACK_LOC_INTERNAL) return MIC_ATTR_INT; if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) return MIC_ATTR_DOCK; -- cgit v1.2.3 From 1feba3b7367b333c3fc7deba638a3a1068f22932 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Fri, 17 Sep 2010 10:52:50 +0200 Subject: ALSA: HDA: Fix spelling (change VOSTO to VOSTRO) It was just a boring day. Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 7e22ed14ae8..a12a9f6f795 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3075,7 +3075,7 @@ enum { CXT5066_LAPTOP, /* Laptops w/ EAPD support */ CXT5066_DELL_LAPTOP, /* Dell Laptop */ CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */ - CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */ + CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ CXT5066_HP_LAPTOP, /* HP Laptop */ @@ -3086,7 +3086,7 @@ static const char *cxt5066_models[CXT5066_MODELS] = { [CXT5066_LAPTOP] = "laptop", [CXT5066_DELL_LAPTOP] = "dell-laptop", [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5", - [CXT5066_DELL_VOSTO] = "dell-vostro", + [CXT5066_DELL_VOSTRO] = "dell-vostro", [CXT5066_IDEAPAD] = "ideapad", [CXT5066_THINKPAD] = "thinkpad", [CXT5066_HP_LAPTOP] = "hp-laptop", @@ -3099,8 +3099,8 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { CXT5066_DELL_LAPTOP), SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), SND_PCI_QUIRK(0x1025, 0x040a, "Acer", CXT5066_IDEAPAD), - SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTO), - SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), + SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), + SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO), SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), @@ -3207,7 +3207,7 @@ static int patch_cxt5066(struct hda_codec *codec) spec->capture_prepare = cxt5066_olpc_capture_prepare; spec->capture_cleanup = cxt5066_olpc_capture_cleanup; break; - case CXT5066_DELL_VOSTO: + case CXT5066_DELL_VOSTRO: codec->patch_ops.init = cxt5066_init; codec->patch_ops.unsol_event = cxt5066_vostro_event; spec->init_verbs[0] = cxt5066_init_verbs_vostro; -- cgit v1.2.3 From 5637edb2e1c2d13b276748508ae17f319fb7f066 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Fri, 17 Sep 2010 10:58:03 +0200 Subject: ALSA: HDA: Sort CXT5066 quirk table It was just a boring day. Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index a12a9f6f795..e501a85b561 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3093,19 +3093,19 @@ static const char *cxt5066_models[CXT5066_MODELS] = { }; static struct snd_pci_quirk cxt5066_cfg_tbl[] = { - SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", - CXT5066_LAPTOP), - SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", - CXT5066_DELL_LAPTOP), - SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), SND_PCI_QUIRK(0x1025, 0x040a, "Acer", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), + SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", + CXT5066_DELL_LAPTOP), SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTRO), SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), SND_PCI_QUIRK(0x1179, 0xffe0, "Toshiba Satellite Pro T130-15F", CXT5066_OLPC_XO_1_5), + SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", + CXT5066_LAPTOP), + SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5), SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), SND_PCI_QUIRK(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x21b3, "Thinkpad Edge 13 (197)", CXT5066_IDEAPAD), -- cgit v1.2.3 From 99ae28bea984df4c38234eb6d2f29a552def6c1b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 17 Sep 2010 14:42:34 +0200 Subject: ALSA: hda - Make snd_hda_get_input_pin_attr() helper Make the helper function to give the input-pin attribute for jack connectivity and location. This simplifies checks of input-pin jacks a bit in some places. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 62 +++++++++++++++++------------------------- sound/pci/hda/hda_local.h | 11 ++++++++ sound/pci/hda/patch_cirrus.c | 2 +- sound/pci/hda/patch_conexant.c | 11 ++------ sound/pci/hda/patch_realtek.c | 10 +++---- sound/pci/hda/patch_sigmatel.c | 30 ++++++++++---------- 6 files changed, 59 insertions(+), 67 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 9f668efbe42..e15a75751f5 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -4637,44 +4637,26 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, } EXPORT_SYMBOL_HDA(snd_hda_parse_pin_def_config); -enum { - MIC_ATTR_INT, - MIC_ATTR_DOCK, - MIC_ATTR_NORMAL, - MIC_ATTR_FRONT, - MIC_ATTR_REAR, -}; - -static int get_mic_pin_attr(unsigned int def_conf) +int snd_hda_get_input_pin_attr(unsigned int def_conf) { unsigned int loc = get_defcfg_location(def_conf); unsigned int conn = get_defcfg_connect(def_conf); + if (conn == AC_JACK_PORT_NONE) + return INPUT_PIN_ATTR_UNUSED; /* Windows may claim the internal mic to be BOTH, too */ if (conn == AC_JACK_PORT_FIXED || conn == AC_JACK_PORT_BOTH) - return MIC_ATTR_INT; + return INPUT_PIN_ATTR_INT; if ((loc & 0x30) == AC_JACK_LOC_INTERNAL) - return MIC_ATTR_INT; + return INPUT_PIN_ATTR_INT; if ((loc & 0x30) == AC_JACK_LOC_SEPARATE) - return MIC_ATTR_DOCK; + return INPUT_PIN_ATTR_DOCK; if (loc == AC_JACK_LOC_REAR) - return MIC_ATTR_REAR; + return INPUT_PIN_ATTR_REAR; if (loc == AC_JACK_LOC_FRONT) - return MIC_ATTR_FRONT; - return MIC_ATTR_NORMAL; -} - -enum { - LINE_ATTR_DOCK, - LINE_ATTR_NORMAL, -}; - -static int get_line_pin_attr(unsigned int def_conf) -{ - unsigned int loc = get_defcfg_location(def_conf); - if ((loc & 0xf0) == AC_JACK_LOC_SEPARATE) - return LINE_ATTR_DOCK; - return LINE_ATTR_NORMAL; + return INPUT_PIN_ATTR_FRONT; + return INPUT_PIN_ATTR_NORMAL; } +EXPORT_SYMBOL_HDA(snd_hda_get_input_pin_attr); /** * hda_get_input_pin_label - Give a label for the given input pin @@ -4691,9 +4673,7 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, static const char *mic_names[] = { "Internal Mic", "Dock Mic", "Mic", "Front Mic", "Rear Mic", }; - static const char *line_names[] = { - "Dock Line", "Line", - }; + int attr; def_conf = snd_hda_codec_get_pincfg(codec, pin); @@ -4701,11 +4681,19 @@ const char *hda_get_input_pin_label(struct hda_codec *codec, hda_nid_t pin, case AC_JACK_MIC_IN: if (!check_location) return "Mic"; - return mic_names[get_mic_pin_attr(def_conf)]; + attr = snd_hda_get_input_pin_attr(def_conf); + if (!attr) + return "None"; + return mic_names[attr - 1]; case AC_JACK_LINE_IN: if (!check_location) return "Line"; - return line_names[get_line_pin_attr(def_conf)]; + attr = snd_hda_get_input_pin_attr(def_conf); + if (!attr) + return "None"; + if (attr == INPUT_PIN_ATTR_DOCK) + return "Dock Line"; + return "Line"; case AC_JACK_AUX: return "Aux"; case AC_JACK_CD: @@ -4732,16 +4720,16 @@ static int check_mic_location_need(struct hda_codec *codec, int i, attr, attr2; defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[input].pin); - attr = get_mic_pin_attr(defc); + attr = snd_hda_get_input_pin_attr(defc); /* for internal or docking mics, we need locations */ - if (attr <= MIC_ATTR_NORMAL) + if (attr <= INPUT_PIN_ATTR_NORMAL) return 1; attr = 0; for (i = 0; i < cfg->num_inputs; i++) { defc = snd_hda_codec_get_pincfg(codec, cfg->inputs[i].pin); - attr2 = get_mic_pin_attr(defc); - if (attr2 >= MIC_ATTR_NORMAL) { + attr2 = snd_hda_get_input_pin_attr(defc); + if (attr2 >= INPUT_PIN_ATTR_NORMAL) { if (attr && attr != attr2) return 1; /* different locations found */ attr = attr2; diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 6943efc78f6..d7dfa547e2d 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -395,6 +395,17 @@ const char *hda_get_autocfg_input_label(struct hda_codec *codec, int snd_hda_add_imux_item(struct hda_input_mux *imux, const char *label, int index, int *type_index_ret); +enum { + INPUT_PIN_ATTR_UNUSED, /* pin not connected */ + INPUT_PIN_ATTR_INT, /* internal mic/line-in */ + INPUT_PIN_ATTR_DOCK, /* docking mic/line-in */ + INPUT_PIN_ATTR_NORMAL, /* mic/line-in jack */ + INPUT_PIN_ATTR_FRONT, /* mic/line-in jack in front */ + INPUT_PIN_ATTR_REAR, /* mic/line-in jack in rear */ +}; + +int snd_hda_get_input_pin_attr(unsigned int def_conf); + struct auto_pin_cfg { int line_outs; /* sorted in the order of Front/Surr/CLFE/Side */ diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index ae75283a558..483c3f2d8d3 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -334,7 +334,7 @@ static int is_ext_mic(struct hda_codec *codec, unsigned int idx) if (!(val & AC_PINCAP_PRES_DETECT)) return 0; val = snd_hda_codec_get_pincfg(codec, pin); - return (get_defcfg_connect(val) == AC_JACK_PORT_COMPLEX); + return (snd_hda_get_input_pin_attr(val) != INPUT_PIN_ATTR_INT); } static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin, diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index e501a85b561..09d573c59be 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3462,19 +3462,12 @@ static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) } } -static int is_int_mic_conn(unsigned int def_conf) -{ - unsigned int loc = get_defcfg_location(def_conf); - return get_defcfg_connect(def_conf) == AC_JACK_PORT_FIXED || - (loc & 0x30) == AC_JACK_LOC_INTERNAL; -} - /* return true if it's an internal-mic pin */ static int is_int_mic(struct hda_codec *codec, hda_nid_t pin) { unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && - is_int_mic_conn(def_conf); + snd_hda_get_input_pin_attr(def_conf) == INPUT_PIN_ATTR_INT; } /* return true if it's an external-mic pin */ @@ -3482,7 +3475,7 @@ static int is_ext_mic(struct hda_codec *codec, hda_nid_t pin) { unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && - !is_int_mic_conn(def_conf); + snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT; } /* check whether the pin config is suitable for auto-mic switching; diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 5df88798895..6045f281b22 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1403,19 +1403,19 @@ static void alc_init_auto_mic(struct hda_codec *codec) hda_nid_t nid = cfg->inputs[i].pin; unsigned int defcfg; defcfg = snd_hda_codec_get_pincfg(codec, nid); - switch (get_defcfg_connect(defcfg)) { - case AC_JACK_PORT_FIXED: + switch (snd_hda_get_input_pin_attr(defcfg)) { + case INPUT_PIN_ATTR_INT: if (fixed) return; /* already occupied */ fixed = nid; break; - case AC_JACK_PORT_COMPLEX: + case INPUT_PIN_ATTR_UNUSED: + return; /* invalid entry */ + default: if (ext) return; /* already occupied */ ext = nid; break; - default: - return; /* invalid entry */ } } if (!ext || !fixed) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 7eb359a030d..6bfbc2fe46e 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -2778,7 +2778,7 @@ static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec, struct sigmatel_spec *spec = codec->spec; char name[22]; - if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) { + if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD && nid == spec->line_switch) control = STAC_CTL_WIDGET_IO_SWITCH; @@ -2857,7 +2857,7 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac) def_conf = snd_hda_codec_get_pincfg(codec, nid); /* some laptops have an internal analog microphone * which can't be used as a output */ - if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { + if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) { pincap = snd_hda_query_pin_caps(codec, nid); if (pincap & AC_PINCAP_OUT) { *dac = get_unassigned_dac(codec, nid); @@ -3496,23 +3496,23 @@ static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid, if (!nid) return 0; cfg = snd_hda_codec_get_pincfg(codec, nid); - switch (get_defcfg_connect(cfg)) { - case AC_JACK_PORT_BOTH: - case AC_JACK_PORT_FIXED: + switch (snd_hda_get_input_pin_attr(cfg)) { + case INPUT_PIN_ATTR_INT: if (*fixed) return 1; /* already occupied */ *fixed = nid; break; - case AC_JACK_PORT_COMPLEX: - if ((get_defcfg_location(cfg) & 0xF0) == AC_JACK_LOC_SEPARATE) { - if (*dock) - return 1; /* already occupied */ - *dock = nid; - } else { - if (*ext) - return 1; /* already occupied */ - *ext = nid; - } + case INPUT_PIN_ATTR_UNUSED: + break; + case INPUT_PIN_ATTR_DOCK: + if (*dock) + return 1; /* already occupied */ + *dock = nid; + break; + default: + if (*ext) + return 1; /* already occupied */ + *ext = nid; break; } return 0; -- cgit v1.2.3 From f68b3b291d39f1e3361b194a95459f9cbdaf31e6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 17 Sep 2010 14:45:14 +0200 Subject: ALSA: hda - Check the external mic pin more strictly for Conexant chips The external mic jack for auto-mic switch must be really an external jack and with a presense-detection capability. This patch makes the check more paranoia. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 09d573c59be..a6c68cb06dd 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3475,7 +3475,8 @@ static int is_ext_mic(struct hda_codec *codec, hda_nid_t pin) { unsigned int def_conf = snd_hda_codec_get_pincfg(codec, pin); return get_defcfg_device(def_conf) == AC_JACK_MIC_IN && - snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT; + snd_hda_get_input_pin_attr(def_conf) >= INPUT_PIN_ATTR_NORMAL && + (snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_PRES_DETECT); } /* check whether the pin config is suitable for auto-mic switching; -- cgit v1.2.3 From 84eb01be18df7012ac31bf678da5aaf1accc6a77 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 7 Sep 2010 12:27:25 +0200 Subject: ALSA: hda - Merge all HDMI modules into the unified module This patch merges all three patch_*hdmi variants to the single HDMI parser. There is only one snd-hda-codec-hdmi module now. In this patch, the behavior of each parser isn't changed much. The old ATI parser still doesn't use the dynamic parser yet. In later patches, they'll be cleaned up. Also, this patch gets rid of the individual snd-hda-eld module and builds into snd-hda-codec-hdmi, since this is referred only from the HDMI parser. Signed-off-by: Takashi Iwai --- sound/pci/hda/Kconfig | 39 +-- sound/pci/hda/Makefile | 15 +- sound/pci/hda/hda_eld.c | 7 - sound/pci/hda/patch_atihdmi.c | 224 ------------- sound/pci/hda/patch_hdmi.c | 685 +++++++++++++++++++++++++++++++++++++++- sound/pci/hda/patch_intelhdmi.c | 220 ------------- sound/pci/hda/patch_nvhdmi.c | 608 ----------------------------------- 7 files changed, 691 insertions(+), 1107 deletions(-) delete mode 100644 sound/pci/hda/patch_atihdmi.c delete mode 100644 sound/pci/hda/patch_intelhdmi.c delete mode 100644 sound/pci/hda/patch_nvhdmi.c (limited to 'sound/pci') diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 9194c3c1d04..0ea5cc60ac7 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig @@ -119,47 +119,20 @@ config SND_HDA_CODEC_VIA snd-hda-codec-via. This module is automatically loaded at probing. -config SND_HDA_CODEC_ATIHDMI - bool "Build ATI HDMI HD-audio codec support" - default y - help - Say Y here to include ATI HDMI HD-audio codec support in - snd-hda-intel driver, such as ATI RS600 HDMI. - - When the HD-audio driver is built as a module, the codec - support code is also built as another module, - snd-hda-codec-atihdmi. - This module is automatically loaded at probing. - -config SND_HDA_CODEC_NVHDMI - bool "Build NVIDIA HDMI HD-audio codec support" - default y - help - Say Y here to include NVIDIA HDMI HD-audio codec support in - snd-hda-intel driver, such as NVIDIA MCP78 HDMI. - - When the HD-audio driver is built as a module, the codec - support code is also built as another module, - snd-hda-codec-nvhdmi. - This module is automatically loaded at probing. - -config SND_HDA_CODEC_INTELHDMI - bool "Build INTEL HDMI HD-audio codec support" +config SND_HDA_CODEC_HDMI + bool "Build HDMI/DisplayPort HD-audio codec support" select SND_DYNAMIC_MINORS default y help - Say Y here to include INTEL HDMI HD-audio codec support in - snd-hda-intel driver, such as Eaglelake integrated HDMI. + Say Y here to include HDMI and DisplayPort HD-audio codec + support in snd-hda-intel driver. This includes all AMD/ATI, + Intel and Nvidia HDMI/DisplayPort codecs. When the HD-audio driver is built as a module, the codec support code is also built as another module, - snd-hda-codec-intelhdmi. + snd-hda-codec-hdmi. This module is automatically loaded at probing. -config SND_HDA_ELD - def_bool y - depends on SND_HDA_CODEC_INTELHDMI || SND_HDA_CODEC_NVHDMI - config SND_HDA_CODEC_CIRRUS bool "Build Cirrus Logic codec support" depends on SND_HDA_INTEL diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile index 24bc195b02d..17ef3658f34 100644 --- a/sound/pci/hda/Makefile +++ b/sound/pci/hda/Makefile @@ -3,7 +3,6 @@ snd-hda-intel-objs := hda_intel.o snd-hda-codec-y := hda_codec.o snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o -snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o @@ -12,13 +11,11 @@ snd-hda-codec-cmedia-objs := patch_cmedia.o snd-hda-codec-analog-objs := patch_analog.o snd-hda-codec-idt-objs := patch_sigmatel.o snd-hda-codec-si3054-objs := patch_si3054.o -snd-hda-codec-atihdmi-objs := patch_atihdmi.o snd-hda-codec-cirrus-objs := patch_cirrus.o snd-hda-codec-ca0110-objs := patch_ca0110.o snd-hda-codec-conexant-objs := patch_conexant.o snd-hda-codec-via-objs := patch_via.o -snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o -snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o +snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o # common driver obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o @@ -39,9 +36,6 @@ endif ifdef CONFIG_SND_HDA_CODEC_SI3054 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-si3054.o endif -ifdef CONFIG_SND_HDA_CODEC_ATIHDMI -obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-atihdmi.o -endif ifdef CONFIG_SND_HDA_CODEC_CIRRUS obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-cirrus.o endif @@ -54,11 +48,8 @@ endif ifdef CONFIG_SND_HDA_CODEC_VIA obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-via.o endif -ifdef CONFIG_SND_HDA_CODEC_NVHDMI -obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-nvhdmi.o -endif -ifdef CONFIG_SND_HDA_CODEC_INTELHDMI -obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-intelhdmi.o +ifdef CONFIG_SND_HDA_CODEC_HDMI +obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-hdmi.o endif # this must be the last entry after codec drivers; diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index 26c3ade7358..cb0c23a6b47 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c @@ -332,7 +332,6 @@ int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid) return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, AC_DIPSIZE_ELD_BUF); } -EXPORT_SYMBOL_HDA(snd_hdmi_get_eld_size); int snd_hdmi_get_eld(struct hdmi_eld *eld, struct hda_codec *codec, hda_nid_t nid) @@ -368,7 +367,6 @@ int snd_hdmi_get_eld(struct hdmi_eld *eld, kfree(buf); return ret; } -EXPORT_SYMBOL_HDA(snd_hdmi_get_eld); static void hdmi_show_short_audio_desc(struct cea_sad *a) { @@ -407,7 +405,6 @@ void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen) } buf[j] = '\0'; /* necessary when j == 0 */ } -EXPORT_SYMBOL_HDA(snd_print_channel_allocation); void snd_hdmi_show_eld(struct hdmi_eld *e) { @@ -426,7 +423,6 @@ void snd_hdmi_show_eld(struct hdmi_eld *e) for (i = 0; i < e->sad_count; i++) hdmi_show_short_audio_desc(e->sad + i); } -EXPORT_SYMBOL_HDA(snd_hdmi_show_eld); #ifdef CONFIG_PROC_FS @@ -585,7 +581,6 @@ int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, return 0; } -EXPORT_SYMBOL_HDA(snd_hda_eld_proc_new); void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) { @@ -594,7 +589,6 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) eld->proc_entry = NULL; } } -EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free); #endif /* CONFIG_PROC_FS */ @@ -645,4 +639,3 @@ void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max); pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps); } -EXPORT_SYMBOL_HDA(hdmi_eld_update_pcm_info); diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c deleted file mode 100644 index fb684f00156..00000000000 --- a/sound/pci/hda/patch_atihdmi.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Universal Interface for Intel High Definition Audio Codec - * - * HD audio interface patch for ATI HDMI codecs - * - * Copyright (c) 2006 ATI Technologies Inc. - * - * - * This driver is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This driver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include "hda_codec.h" -#include "hda_local.h" - -struct atihdmi_spec { - struct hda_multi_out multiout; - - struct hda_pcm pcm_rec; -}; - -#define CVT_NID 0x02 /* audio converter */ -#define PIN_NID 0x03 /* HDMI output pin */ - -static struct hda_verb atihdmi_basic_init[] = { - /* enable digital output on pin widget */ - { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, - {} /* terminator */ -}; - -/* - * Controls - */ -static int atihdmi_build_controls(struct hda_codec *codec) -{ - struct atihdmi_spec *spec = codec->spec; - int err; - - err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); - if (err < 0) - return err; - - return 0; -} - -static int atihdmi_init(struct hda_codec *codec) -{ - snd_hda_sequence_write(codec, atihdmi_basic_init); - /* SI codec requires to unmute the pin */ - if (get_wcaps(codec, PIN_NID) & AC_WCAP_OUT_AMP) - snd_hda_codec_write(codec, PIN_NID, 0, - AC_VERB_SET_AMP_GAIN_MUTE, - AMP_OUT_UNMUTE); - return 0; -} - -/* - * Digital out - */ -static int atihdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - struct snd_pcm_substream *substream) -{ - struct atihdmi_spec *spec = codec->spec; - return snd_hda_multi_out_dig_open(codec, &spec->multiout); -} - -static int atihdmi_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - struct snd_pcm_substream *substream) -{ - struct atihdmi_spec *spec = codec->spec; - return snd_hda_multi_out_dig_close(codec, &spec->multiout); -} - -static int atihdmi_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - unsigned int stream_tag, - unsigned int format, - struct snd_pcm_substream *substream) -{ - struct atihdmi_spec *spec = codec->spec; - int chans = substream->runtime->channels; - int i, err; - - err = snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, - format, substream); - if (err < 0) - return err; - snd_hda_codec_write(codec, CVT_NID, 0, AC_VERB_SET_CVT_CHAN_COUNT, - chans - 1); - /* FIXME: XXX */ - for (i = 0; i < chans; i++) { - snd_hda_codec_write(codec, CVT_NID, 0, - AC_VERB_SET_HDMI_CHAN_SLOT, - (i << 4) | i); - } - return 0; -} - -static struct hda_pcm_stream atihdmi_pcm_digital_playback = { - .substreams = 1, - .channels_min = 2, - .channels_max = 2, - .nid = CVT_NID, /* NID to query formats and rates and setup streams */ - .ops = { - .open = atihdmi_dig_playback_pcm_open, - .close = atihdmi_dig_playback_pcm_close, - .prepare = atihdmi_dig_playback_pcm_prepare - }, -}; - -static int atihdmi_build_pcms(struct hda_codec *codec) -{ - struct atihdmi_spec *spec = codec->spec; - struct hda_pcm *info = &spec->pcm_rec; - unsigned int chans; - - codec->num_pcms = 1; - codec->pcm_info = info; - - info->name = "ATI HDMI"; - info->pcm_type = HDA_PCM_TYPE_HDMI; - info->stream[SNDRV_PCM_STREAM_PLAYBACK] = atihdmi_pcm_digital_playback; - - /* FIXME: we must check ELD and change the PCM parameters dynamically - */ - chans = get_wcaps(codec, CVT_NID); - chans = get_wcaps_channels(chans); - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; - - return 0; -} - -static void atihdmi_free(struct hda_codec *codec) -{ - kfree(codec->spec); -} - -static struct hda_codec_ops atihdmi_patch_ops = { - .build_controls = atihdmi_build_controls, - .build_pcms = atihdmi_build_pcms, - .init = atihdmi_init, - .free = atihdmi_free, -}; - -static int patch_atihdmi(struct hda_codec *codec) -{ - struct atihdmi_spec *spec; - - spec = kzalloc(sizeof(*spec), GFP_KERNEL); - if (spec == NULL) - return -ENOMEM; - - codec->spec = spec; - - spec->multiout.num_dacs = 0; /* no analog */ - spec->multiout.max_channels = 2; - /* NID for copying analog to digital, - * seems to be unused in pure-digital - * case. - */ - spec->multiout.dig_out_nid = CVT_NID; - - codec->patch_ops = atihdmi_patch_ops; - - return 0; -} - -/* - * patch entries - */ -static struct hda_codec_preset snd_hda_preset_atihdmi[] = { - { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, - { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, - { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, - { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi }, - { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_atihdmi }, - { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi }, - {} /* terminator */ -}; - -MODULE_ALIAS("snd-hda-codec-id:1002793c"); -MODULE_ALIAS("snd-hda-codec-id:10027919"); -MODULE_ALIAS("snd-hda-codec-id:1002791a"); -MODULE_ALIAS("snd-hda-codec-id:1002aa01"); -MODULE_ALIAS("snd-hda-codec-id:10951390"); -MODULE_ALIAS("snd-hda-codec-id:17e80047"); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("ATI HDMI HD-audio codec"); - -static struct hda_codec_preset_list atihdmi_list = { - .preset = snd_hda_preset_atihdmi, - .owner = THIS_MODULE, -}; - -static int __init patch_atihdmi_init(void) -{ - return snd_hda_add_codec_preset(&atihdmi_list); -} - -static void __exit patch_atihdmi_exit(void) -{ - snd_hda_delete_codec_preset(&atihdmi_list); -} - -module_init(patch_atihdmi_init) -module_exit(patch_atihdmi_exit) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index afd6022a96a..cb997ca0fdf 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -3,6 +3,9 @@ * patch_hdmi.c - routines for HDMI/DisplayPort codecs * * Copyright(c) 2008-2010 Intel Corporation. All rights reserved. + * Copyright (c) 2006 ATI Technologies Inc. + * Copyright (c) 2008 NVIDIA Corp. All rights reserved. + * Copyright (c) 2008 Wei Ni * * Authors: * Wu Fengguang @@ -25,6 +28,22 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include +#include +#include +#include +#include "hda_codec.h" +#include "hda_local.h" + +/* + * The HDMI/DisplayPort configuration can be highly dynamic. A graphics device + * could support two independent pipes, each of them can be connected to one or + * more ports (DVI, HDMI or DisplayPort). + * + * The HDA correspondence of pipes/ports are converter/pin nodes. + */ +#define MAX_HDMI_CVTS 3 +#define MAX_HDMI_PINS 3 struct hdmi_spec { int num_cvts; @@ -49,10 +68,10 @@ struct hdmi_spec { struct hda_pcm_stream codec_pcm_pars[MAX_HDMI_CVTS]; /* - * nvhdmi specific + * ati/nvhdmi specific */ struct hda_multi_out multiout; - unsigned int codec_type; + struct hda_pcm_stream *pcm_playback; /* misc flags */ /* PD bit indicates only the update, not the current state */ @@ -791,7 +810,6 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, /* * HDA/HDMI auto parsing */ - static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) { struct hdmi_spec *spec = codec->spec; @@ -922,3 +940,664 @@ static int hdmi_parse_codec(struct hda_codec *codec) return 0; } +/* + */ +static char *generic_hdmi_pcm_names[MAX_HDMI_CVTS] = { + "HDMI 0", + "HDMI 1", + "HDMI 2", +}; + +/* + * HDMI callbacks + */ + +static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + hdmi_set_channel_count(codec, hinfo->nid, + substream->runtime->channels); + + hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); + + return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); +} + +static struct hda_pcm_stream generic_hdmi_pcm_playback = { + .substreams = 1, + .channels_min = 2, + .ops = { + .open = hdmi_pcm_open, + .prepare = generic_hdmi_playback_pcm_prepare, + }, +}; + +static int generic_hdmi_build_pcms(struct hda_codec *codec) +{ + struct hdmi_spec *spec = codec->spec; + struct hda_pcm *info = spec->pcm_rec; + int i; + + codec->num_pcms = spec->num_cvts; + codec->pcm_info = info; + + for (i = 0; i < codec->num_pcms; i++, info++) { + unsigned int chans; + struct hda_pcm_stream *pstr; + + chans = get_wcaps(codec, spec->cvt[i]); + chans = get_wcaps_channels(chans); + + info->name = generic_hdmi_pcm_names[i]; + info->pcm_type = HDA_PCM_TYPE_HDMI; + pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK]; + if (spec->pcm_playback) + *pstr = *spec->pcm_playback; + else + *pstr = generic_hdmi_pcm_playback; + pstr->nid = spec->cvt[i]; + if (pstr->channels_max <= 2 && chans && chans <= 16) + pstr->channels_max = chans; + } + + return 0; +} + +static int generic_hdmi_build_controls(struct hda_codec *codec) +{ + struct hdmi_spec *spec = codec->spec; + int err; + int i; + + for (i = 0; i < codec->num_pcms; i++) { + err = snd_hda_create_spdif_out_ctls(codec, spec->cvt[i]); + if (err < 0) + return err; + } + + return 0; +} + +static int generic_hdmi_init(struct hda_codec *codec) +{ + struct hdmi_spec *spec = codec->spec; + int i; + + for (i = 0; spec->pin[i]; i++) { + hdmi_enable_output(codec, spec->pin[i]); + snd_hda_codec_write(codec, spec->pin[i], 0, + AC_VERB_SET_UNSOLICITED_ENABLE, + AC_USRSP_EN | spec->pin[i]); + } + return 0; +} + +static void generic_hdmi_free(struct hda_codec *codec) +{ + struct hdmi_spec *spec = codec->spec; + int i; + + for (i = 0; i < spec->num_pins; i++) + snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); + + kfree(spec); +} + +static struct hda_codec_ops generic_hdmi_patch_ops = { + .init = generic_hdmi_init, + .free = generic_hdmi_free, + .build_pcms = generic_hdmi_build_pcms, + .build_controls = generic_hdmi_build_controls, + .unsol_event = hdmi_unsol_event, +}; + +static int patch_generic_hdmi(struct hda_codec *codec) +{ + struct hdmi_spec *spec; + int i; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + if (hdmi_parse_codec(codec) < 0) { + codec->spec = NULL; + kfree(spec); + return -EINVAL; + } + codec->patch_ops = generic_hdmi_patch_ops; + + for (i = 0; i < spec->num_pins; i++) + snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); + + init_channel_allocations(); + + return 0; +} + +/* + * Nvidia specific implementations + */ + +#define Nv_VERB_SET_Channel_Allocation 0xF79 +#define Nv_VERB_SET_Info_Frame_Checksum 0xF7A +#define Nv_VERB_SET_Audio_Protection_On 0xF98 +#define Nv_VERB_SET_Audio_Protection_Off 0xF99 + +#define nvhdmi_master_con_nid_7x 0x04 +#define nvhdmi_master_pin_nid_7x 0x05 + +static hda_nid_t nvhdmi_con_nids_7x[4] = { + /*front, rear, clfe, rear_surr */ + 0x6, 0x8, 0xa, 0xc, +}; + +static struct hda_verb nvhdmi_basic_init_7x[] = { + /* set audio protect on */ + { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, + /* enable digital output on pin widget */ + { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, + { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, + { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, + { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, + { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, + {} /* terminator */ +}; + +#ifdef LIMITED_RATE_FMT_SUPPORT +/* support only the safe format and rate */ +#define SUPPORTED_RATES SNDRV_PCM_RATE_48000 +#define SUPPORTED_MAXBPS 16 +#define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE +#else +/* support all rates and formats */ +#define SUPPORTED_RATES \ + (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\ + SNDRV_PCM_RATE_192000) +#define SUPPORTED_MAXBPS 24 +#define SUPPORTED_FORMATS \ + (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) +#endif + +static int nvhdmi_7x_init(struct hda_codec *codec) +{ + snd_hda_sequence_write(codec, nvhdmi_basic_init_7x); + return 0; +} + +static int simple_playback_pcm_open(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct hdmi_spec *spec = codec->spec; + return snd_hda_multi_out_dig_open(codec, &spec->multiout); +} + +static int simple_playback_pcm_close(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct hdmi_spec *spec = codec->spec; + return snd_hda_multi_out_dig_close(codec, &spec->multiout); +} + +static int simple_playback_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + struct hdmi_spec *spec = codec->spec; + return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, + stream_tag, format, substream); +} + +static int nvhdmi_8ch_7x_pcm_close(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + struct snd_pcm_substream *substream) +{ + struct hdmi_spec *spec = codec->spec; + int i; + + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, + 0, AC_VERB_SET_CHANNEL_STREAMID, 0); + for (i = 0; i < 4; i++) { + /* set the stream id */ + snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_CHANNEL_STREAMID, 0); + /* set the stream format */ + snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, + AC_VERB_SET_STREAM_FORMAT, 0); + } + + return snd_hda_multi_out_dig_close(codec, &spec->multiout); +} + +static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + int chs; + unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id; + int i; + + mutex_lock(&codec->spdif_mutex); + + chs = substream->runtime->channels; + chan = chs ? (chs - 1) : 1; + + switch (chs) { + default: + case 0: + case 2: + chanmask = 0x00; + break; + case 4: + chanmask = 0x08; + break; + case 6: + chanmask = 0x0b; + break; + case 8: + chanmask = 0x13; + break; + } + dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT; + dataDCC2 = 0x2; + + /* set the Audio InforFrame Channel Allocation */ + snd_hda_codec_write(codec, 0x1, 0, + Nv_VERB_SET_Channel_Allocation, chanmask); + + /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ + if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) + snd_hda_codec_write(codec, + nvhdmi_master_con_nid_7x, + 0, + AC_VERB_SET_DIGI_CONVERT_1, + codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); + + /* set the stream id */ + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, + AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); + + /* set the stream format */ + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, + AC_VERB_SET_STREAM_FORMAT, format); + + /* turn on again (if needed) */ + /* enable and set the channel status audio/data flag */ + if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { + snd_hda_codec_write(codec, + nvhdmi_master_con_nid_7x, + 0, + AC_VERB_SET_DIGI_CONVERT_1, + codec->spdif_ctls & 0xff); + snd_hda_codec_write(codec, + nvhdmi_master_con_nid_7x, + 0, + AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); + } + + for (i = 0; i < 4; i++) { + if (chs == 2) + channel_id = 0; + else + channel_id = i * 2; + + /* turn off SPDIF once; + *otherwise the IEC958 bits won't be updated + */ + if (codec->spdif_status_reset && + (codec->spdif_ctls & AC_DIG1_ENABLE)) + snd_hda_codec_write(codec, + nvhdmi_con_nids_7x[i], + 0, + AC_VERB_SET_DIGI_CONVERT_1, + codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); + /* set the stream id */ + snd_hda_codec_write(codec, + nvhdmi_con_nids_7x[i], + 0, + AC_VERB_SET_CHANNEL_STREAMID, + (stream_tag << 4) | channel_id); + /* set the stream format */ + snd_hda_codec_write(codec, + nvhdmi_con_nids_7x[i], + 0, + AC_VERB_SET_STREAM_FORMAT, + format); + /* turn on again (if needed) */ + /* enable and set the channel status audio/data flag */ + if (codec->spdif_status_reset && + (codec->spdif_ctls & AC_DIG1_ENABLE)) { + snd_hda_codec_write(codec, + nvhdmi_con_nids_7x[i], + 0, + AC_VERB_SET_DIGI_CONVERT_1, + codec->spdif_ctls & 0xff); + snd_hda_codec_write(codec, + nvhdmi_con_nids_7x[i], + 0, + AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); + } + } + + /* set the Audio Info Frame Checksum */ + snd_hda_codec_write(codec, 0x1, 0, + Nv_VERB_SET_Info_Frame_Checksum, + (0x71 - chan - chanmask)); + + mutex_unlock(&codec->spdif_mutex); + return 0; +} + +static struct hda_pcm_stream nvhdmi_pcm_playback_8ch_7x = { + .substreams = 1, + .channels_min = 2, + .channels_max = 8, + .nid = nvhdmi_master_con_nid_7x, + .rates = SUPPORTED_RATES, + .maxbps = SUPPORTED_MAXBPS, + .formats = SUPPORTED_FORMATS, + .ops = { + .open = simple_playback_pcm_open, + .close = nvhdmi_8ch_7x_pcm_close, + .prepare = nvhdmi_8ch_7x_pcm_prepare + }, +}; + +static struct hda_pcm_stream nvhdmi_pcm_playback_2ch = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + .nid = nvhdmi_master_con_nid_7x, + .rates = SUPPORTED_RATES, + .maxbps = SUPPORTED_MAXBPS, + .formats = SUPPORTED_FORMATS, + .ops = { + .open = simple_playback_pcm_open, + .close = simple_playback_pcm_close, + .prepare = simple_playback_pcm_prepare + }, +}; + +static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = { + .build_controls = generic_hdmi_build_controls, + .build_pcms = generic_hdmi_build_pcms, + .init = nvhdmi_7x_init, + .free = generic_hdmi_free, +}; + +static struct hda_codec_ops nvhdmi_patch_ops_2ch = { + .build_controls = generic_hdmi_build_controls, + .build_pcms = generic_hdmi_build_pcms, + .init = nvhdmi_7x_init, + .free = generic_hdmi_free, +}; + +static int patch_nvhdmi_8ch_89(struct hda_codec *codec) +{ + struct hdmi_spec *spec; + int err = patch_generic_hdmi(codec); + + if (err < 0) + return err; + spec = codec->spec; + spec->old_pin_detect = 1; + return 0; +} + +static int patch_nvhdmi_2ch(struct hda_codec *codec) +{ + struct hdmi_spec *spec; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + spec->multiout.num_dacs = 0; /* no analog */ + spec->multiout.max_channels = 2; + spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; + spec->old_pin_detect = 1; + spec->num_cvts = 1; + spec->cvt[0] = nvhdmi_master_con_nid_7x; + spec->pcm_playback = &nvhdmi_pcm_playback_2ch; + + codec->patch_ops = nvhdmi_patch_ops_2ch; + + return 0; +} + +static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) +{ + struct hdmi_spec *spec; + int err = patch_nvhdmi_2ch(codec); + + if (err < 0) + return err; + spec = codec->spec; + spec->multiout.max_channels = 8; + spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x; + codec->patch_ops = nvhdmi_patch_ops_8ch_7x; + return 0; +} + +/* + * ATI-specific implementations + * + * FIXME: we may omit the whole this and use the generic code once after + * it's confirmed to work. + */ + +#define ATIHDMI_CVT_NID 0x02 /* audio converter */ +#define ATIHDMI_PIN_NID 0x03 /* HDMI output pin */ + +static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, + struct hda_codec *codec, + unsigned int stream_tag, + unsigned int format, + struct snd_pcm_substream *substream) +{ + struct hdmi_spec *spec = codec->spec; + int chans = substream->runtime->channels; + int i, err; + + err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format, + substream); + if (err < 0) + return err; + snd_hda_codec_write(codec, spec->cvt[0], 0, AC_VERB_SET_CVT_CHAN_COUNT, + chans - 1); + /* FIXME: XXX */ + for (i = 0; i < chans; i++) { + snd_hda_codec_write(codec, spec->cvt[0], 0, + AC_VERB_SET_HDMI_CHAN_SLOT, + (i << 4) | i); + } + return 0; +} + +static struct hda_pcm_stream atihdmi_pcm_digital_playback = { + .substreams = 1, + .channels_min = 2, + .channels_max = 2, + .nid = ATIHDMI_CVT_NID, + .ops = { + .open = simple_playback_pcm_open, + .close = simple_playback_pcm_close, + .prepare = atihdmi_playback_pcm_prepare + }, +}; + +static struct hda_verb atihdmi_basic_init[] = { + /* enable digital output on pin widget */ + { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + {} /* terminator */ +}; + +static int atihdmi_init(struct hda_codec *codec) +{ + struct hdmi_spec *spec = codec->spec; + + snd_hda_sequence_write(codec, atihdmi_basic_init); + /* SI codec requires to unmute the pin */ + if (get_wcaps(codec, spec->pin[0]) & AC_WCAP_OUT_AMP) + snd_hda_codec_write(codec, spec->pin[0], 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_UNMUTE); + return 0; +} + +static struct hda_codec_ops atihdmi_patch_ops = { + .build_controls = generic_hdmi_build_controls, + .build_pcms = generic_hdmi_build_pcms, + .init = atihdmi_init, + .free = generic_hdmi_free, +}; + + +static int patch_atihdmi(struct hda_codec *codec) +{ + struct hdmi_spec *spec; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + spec->multiout.num_dacs = 0; /* no analog */ + spec->multiout.max_channels = 2; + spec->multiout.dig_out_nid = ATIHDMI_CVT_NID; + spec->num_cvts = 1; + spec->cvt[0] = ATIHDMI_CVT_NID; + spec->pin[0] = ATIHDMI_PIN_NID; + spec->pcm_playback = &atihdmi_pcm_digital_playback; + + codec->patch_ops = atihdmi_patch_ops; + + return 0; +} + + +/* + * patch entries + */ +static struct hda_codec_preset snd_hda_preset_hdmi[] = { +{ .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, +{ .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, +{ .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, +{ .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi }, +{ .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, +{ .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, +{ .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, +{ .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, +{ .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, +{ .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, +{ .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, +{ .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, +{ .id = 0x80860054, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x80862801, .name = "Bearlake HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x80862802, .name = "Cantiga HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x80862803, .name = "Eaglelake HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x80862804, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x80862805, .name = "CougarPoint HDMI", .patch = patch_generic_hdmi }, +{ .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi }, +{} /* terminator */ +}; + +MODULE_ALIAS("snd-hda-codec-id:1002793c"); +MODULE_ALIAS("snd-hda-codec-id:10027919"); +MODULE_ALIAS("snd-hda-codec-id:1002791a"); +MODULE_ALIAS("snd-hda-codec-id:1002aa01"); +MODULE_ALIAS("snd-hda-codec-id:10951390"); +MODULE_ALIAS("snd-hda-codec-id:10951392"); +MODULE_ALIAS("snd-hda-codec-id:10de0002"); +MODULE_ALIAS("snd-hda-codec-id:10de0003"); +MODULE_ALIAS("snd-hda-codec-id:10de0005"); +MODULE_ALIAS("snd-hda-codec-id:10de0006"); +MODULE_ALIAS("snd-hda-codec-id:10de0007"); +MODULE_ALIAS("snd-hda-codec-id:10de000a"); +MODULE_ALIAS("snd-hda-codec-id:10de000b"); +MODULE_ALIAS("snd-hda-codec-id:10de000c"); +MODULE_ALIAS("snd-hda-codec-id:10de000d"); +MODULE_ALIAS("snd-hda-codec-id:10de0010"); +MODULE_ALIAS("snd-hda-codec-id:10de0011"); +MODULE_ALIAS("snd-hda-codec-id:10de0012"); +MODULE_ALIAS("snd-hda-codec-id:10de0013"); +MODULE_ALIAS("snd-hda-codec-id:10de0014"); +MODULE_ALIAS("snd-hda-codec-id:10de0018"); +MODULE_ALIAS("snd-hda-codec-id:10de0019"); +MODULE_ALIAS("snd-hda-codec-id:10de001a"); +MODULE_ALIAS("snd-hda-codec-id:10de001b"); +MODULE_ALIAS("snd-hda-codec-id:10de001c"); +MODULE_ALIAS("snd-hda-codec-id:10de0040"); +MODULE_ALIAS("snd-hda-codec-id:10de0041"); +MODULE_ALIAS("snd-hda-codec-id:10de0042"); +MODULE_ALIAS("snd-hda-codec-id:10de0043"); +MODULE_ALIAS("snd-hda-codec-id:10de0044"); +MODULE_ALIAS("snd-hda-codec-id:10de0067"); +MODULE_ALIAS("snd-hda-codec-id:10de8001"); +MODULE_ALIAS("snd-hda-codec-id:17e80047"); +MODULE_ALIAS("snd-hda-codec-id:80860054"); +MODULE_ALIAS("snd-hda-codec-id:80862801"); +MODULE_ALIAS("snd-hda-codec-id:80862802"); +MODULE_ALIAS("snd-hda-codec-id:80862803"); +MODULE_ALIAS("snd-hda-codec-id:80862804"); +MODULE_ALIAS("snd-hda-codec-id:80862805"); +MODULE_ALIAS("snd-hda-codec-id:808629fb"); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("HDMI HD-audio codec"); +MODULE_ALIAS("snd-hda-codec-intelhdmi"); +MODULE_ALIAS("snd-hda-codec-nvhdmi"); +MODULE_ALIAS("snd-hda-codec-atihdmi"); + +static struct hda_codec_preset_list intel_list = { + .preset = snd_hda_preset_hdmi, + .owner = THIS_MODULE, +}; + +static int __init patch_hdmi_init(void) +{ + return snd_hda_add_codec_preset(&intel_list); +} + +static void __exit patch_hdmi_exit(void) +{ + snd_hda_delete_codec_preset(&intel_list); +} + +module_init(patch_hdmi_init) +module_exit(patch_hdmi_exit) diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c deleted file mode 100644 index 36a9b83a617..00000000000 --- a/sound/pci/hda/patch_intelhdmi.c +++ /dev/null @@ -1,220 +0,0 @@ -/* - * - * patch_intelhdmi.c - Patch for Intel HDMI codecs - * - * Copyright(c) 2008 Intel Corporation. All rights reserved. - * - * Authors: - * Jiang Zhe - * Wu Fengguang - * - * Maintained by: - * Wu Fengguang - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include -#include "hda_codec.h" -#include "hda_local.h" - -/* - * The HDMI/DisplayPort configuration can be highly dynamic. A graphics device - * could support two independent pipes, each of them can be connected to one or - * more ports (DVI, HDMI or DisplayPort). - * - * The HDA correspondence of pipes/ports are converter/pin nodes. - */ -#define MAX_HDMI_CVTS 3 -#define MAX_HDMI_PINS 3 - -#include "patch_hdmi.c" - -static char *intel_hdmi_pcm_names[MAX_HDMI_CVTS] = { - "INTEL HDMI 0", - "INTEL HDMI 1", - "INTEL HDMI 2", -}; - -/* - * HDMI callbacks - */ - -static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - unsigned int stream_tag, - unsigned int format, - struct snd_pcm_substream *substream) -{ - hdmi_set_channel_count(codec, hinfo->nid, - substream->runtime->channels); - - hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); - - return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); -} - -static struct hda_pcm_stream intel_hdmi_pcm_playback = { - .substreams = 1, - .channels_min = 2, - .ops = { - .open = hdmi_pcm_open, - .prepare = intel_hdmi_playback_pcm_prepare, - }, -}; - -static int intel_hdmi_build_pcms(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - struct hda_pcm *info = spec->pcm_rec; - int i; - - codec->num_pcms = spec->num_cvts; - codec->pcm_info = info; - - for (i = 0; i < codec->num_pcms; i++, info++) { - unsigned int chans; - - chans = get_wcaps(codec, spec->cvt[i]); - chans = get_wcaps_channels(chans); - - info->name = intel_hdmi_pcm_names[i]; - info->pcm_type = HDA_PCM_TYPE_HDMI; - info->stream[SNDRV_PCM_STREAM_PLAYBACK] = - intel_hdmi_pcm_playback; - info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i]; - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; - } - - return 0; -} - -static int intel_hdmi_build_controls(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - int err; - int i; - - for (i = 0; i < codec->num_pcms; i++) { - err = snd_hda_create_spdif_out_ctls(codec, spec->cvt[i]); - if (err < 0) - return err; - } - - return 0; -} - -static int intel_hdmi_init(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - int i; - - for (i = 0; spec->pin[i]; i++) { - hdmi_enable_output(codec, spec->pin[i]); - snd_hda_codec_write(codec, spec->pin[i], 0, - AC_VERB_SET_UNSOLICITED_ENABLE, - AC_USRSP_EN | spec->pin[i]); - } - return 0; -} - -static void intel_hdmi_free(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - int i; - - for (i = 0; i < spec->num_pins; i++) - snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); - - kfree(spec); -} - -static struct hda_codec_ops intel_hdmi_patch_ops = { - .init = intel_hdmi_init, - .free = intel_hdmi_free, - .build_pcms = intel_hdmi_build_pcms, - .build_controls = intel_hdmi_build_controls, - .unsol_event = hdmi_unsol_event, -}; - -static int patch_intel_hdmi(struct hda_codec *codec) -{ - struct hdmi_spec *spec; - int i; - - spec = kzalloc(sizeof(*spec), GFP_KERNEL); - if (spec == NULL) - return -ENOMEM; - - codec->spec = spec; - if (hdmi_parse_codec(codec) < 0) { - codec->spec = NULL; - kfree(spec); - return -EINVAL; - } - codec->patch_ops = intel_hdmi_patch_ops; - - for (i = 0; i < spec->num_pins; i++) - snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); - - init_channel_allocations(); - - return 0; -} - -static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { -{ .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_intel_hdmi }, -{ .id = 0x80862801, .name = "Bearlake HDMI", .patch = patch_intel_hdmi }, -{ .id = 0x80862802, .name = "Cantiga HDMI", .patch = patch_intel_hdmi }, -{ .id = 0x80862803, .name = "Eaglelake HDMI", .patch = patch_intel_hdmi }, -{ .id = 0x80862804, .name = "IbexPeak HDMI", .patch = patch_intel_hdmi }, -{ .id = 0x80860054, .name = "IbexPeak HDMI", .patch = patch_intel_hdmi }, -{ .id = 0x80862805, .name = "CougarPoint HDMI", .patch = patch_intel_hdmi }, -{ .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, -{} /* terminator */ -}; - -MODULE_ALIAS("snd-hda-codec-id:808629fb"); -MODULE_ALIAS("snd-hda-codec-id:80862801"); -MODULE_ALIAS("snd-hda-codec-id:80862802"); -MODULE_ALIAS("snd-hda-codec-id:80862803"); -MODULE_ALIAS("snd-hda-codec-id:80862804"); -MODULE_ALIAS("snd-hda-codec-id:80862805"); -MODULE_ALIAS("snd-hda-codec-id:80860054"); -MODULE_ALIAS("snd-hda-codec-id:10951392"); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Intel HDMI HD-audio codec"); - -static struct hda_codec_preset_list intel_list = { - .preset = snd_hda_preset_intelhdmi, - .owner = THIS_MODULE, -}; - -static int __init patch_intelhdmi_init(void) -{ - return snd_hda_add_codec_preset(&intel_list); -} - -static void __exit patch_intelhdmi_exit(void) -{ - snd_hda_delete_codec_preset(&intel_list); -} - -module_init(patch_intelhdmi_init) -module_exit(patch_intelhdmi_exit) diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c deleted file mode 100644 index baa108b9d6a..00000000000 --- a/sound/pci/hda/patch_nvhdmi.c +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Universal Interface for Intel High Definition Audio Codec - * - * HD audio interface patch for NVIDIA HDMI codecs - * - * Copyright (c) 2008 NVIDIA Corp. All rights reserved. - * Copyright (c) 2008 Wei Ni - * - * - * This driver is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This driver is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include "hda_codec.h" -#include "hda_local.h" - -#define MAX_HDMI_CVTS 1 -#define MAX_HDMI_PINS 1 - -#include "patch_hdmi.c" - -static char *nvhdmi_pcm_names[MAX_HDMI_CVTS] = { - "NVIDIA HDMI", -}; - -/* define below to restrict the supported rates and formats */ -/* #define LIMITED_RATE_FMT_SUPPORT */ - -enum HDACodec { - HDA_CODEC_NVIDIA_MCP7X, - HDA_CODEC_NVIDIA_MCP89, - HDA_CODEC_NVIDIA_GT21X, - HDA_CODEC_INVALID -}; - -#define Nv_VERB_SET_Channel_Allocation 0xF79 -#define Nv_VERB_SET_Info_Frame_Checksum 0xF7A -#define Nv_VERB_SET_Audio_Protection_On 0xF98 -#define Nv_VERB_SET_Audio_Protection_Off 0xF99 - -#define nvhdmi_master_con_nid_7x 0x04 -#define nvhdmi_master_pin_nid_7x 0x05 - -#define nvhdmi_master_con_nid_89 0x04 -#define nvhdmi_master_pin_nid_89 0x05 - -static hda_nid_t nvhdmi_con_nids_7x[4] = { - /*front, rear, clfe, rear_surr */ - 0x6, 0x8, 0xa, 0xc, -}; - -static struct hda_verb nvhdmi_basic_init_7x[] = { - /* set audio protect on */ - { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, - /* enable digital output on pin widget */ - { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, - { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, - { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, - { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, - { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 }, - {} /* terminator */ -}; - -#ifdef LIMITED_RATE_FMT_SUPPORT -/* support only the safe format and rate */ -#define SUPPORTED_RATES SNDRV_PCM_RATE_48000 -#define SUPPORTED_MAXBPS 16 -#define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE -#else -/* support all rates and formats */ -#define SUPPORTED_RATES \ - (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\ - SNDRV_PCM_RATE_192000) -#define SUPPORTED_MAXBPS 24 -#define SUPPORTED_FORMATS \ - (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE) -#endif - -/* - * Controls - */ -static int nvhdmi_build_controls(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - int err; - int i; - - if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) - || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { - for (i = 0; i < codec->num_pcms; i++) { - err = snd_hda_create_spdif_out_ctls(codec, - spec->cvt[i]); - if (err < 0) - return err; - } - } else { - err = snd_hda_create_spdif_out_ctls(codec, - spec->multiout.dig_out_nid); - if (err < 0) - return err; - } - - return 0; -} - -static int nvhdmi_init(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - int i; - if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) - || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { - for (i = 0; spec->pin[i]; i++) { - hdmi_enable_output(codec, spec->pin[i]); - snd_hda_codec_write(codec, spec->pin[i], 0, - AC_VERB_SET_UNSOLICITED_ENABLE, - AC_USRSP_EN | spec->pin[i]); - } - } else { - snd_hda_sequence_write(codec, nvhdmi_basic_init_7x); - } - return 0; -} - -static void nvhdmi_free(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - int i; - - if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) - || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { - for (i = 0; i < spec->num_pins; i++) - snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); - } - - kfree(spec); -} - -/* - * Digital out - */ -static int nvhdmi_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - struct snd_pcm_substream *substream) -{ - struct hdmi_spec *spec = codec->spec; - return snd_hda_multi_out_dig_open(codec, &spec->multiout); -} - -static int nvhdmi_dig_playback_pcm_close_8ch_7x(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - struct snd_pcm_substream *substream) -{ - struct hdmi_spec *spec = codec->spec; - int i; - - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, - 0, AC_VERB_SET_CHANNEL_STREAMID, 0); - for (i = 0; i < 4; i++) { - /* set the stream id */ - snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, - AC_VERB_SET_CHANNEL_STREAMID, 0); - /* set the stream format */ - snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, - AC_VERB_SET_STREAM_FORMAT, 0); - } - - return snd_hda_multi_out_dig_close(codec, &spec->multiout); -} - -static int nvhdmi_dig_playback_pcm_close_2ch(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - struct snd_pcm_substream *substream) -{ - struct hdmi_spec *spec = codec->spec; - return snd_hda_multi_out_dig_close(codec, &spec->multiout); -} - -static int nvhdmi_dig_playback_pcm_prepare_8ch_89(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - unsigned int stream_tag, - unsigned int format, - struct snd_pcm_substream *substream) -{ - hdmi_set_channel_count(codec, hinfo->nid, - substream->runtime->channels); - - hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); - - return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); -} - -static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - unsigned int stream_tag, - unsigned int format, - struct snd_pcm_substream *substream) -{ - int chs; - unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id; - int i; - - mutex_lock(&codec->spdif_mutex); - - chs = substream->runtime->channels; - chan = chs ? (chs - 1) : 1; - - switch (chs) { - default: - case 0: - case 2: - chanmask = 0x00; - break; - case 4: - chanmask = 0x08; - break; - case 6: - chanmask = 0x0b; - break; - case 8: - chanmask = 0x13; - break; - } - dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT; - dataDCC2 = 0x2; - - /* set the Audio InforFrame Channel Allocation */ - snd_hda_codec_write(codec, 0x1, 0, - Nv_VERB_SET_Channel_Allocation, chanmask); - - /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ - if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) - snd_hda_codec_write(codec, - nvhdmi_master_con_nid_7x, - 0, - AC_VERB_SET_DIGI_CONVERT_1, - codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); - - /* set the stream id */ - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, - AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); - - /* set the stream format */ - snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, - AC_VERB_SET_STREAM_FORMAT, format); - - /* turn on again (if needed) */ - /* enable and set the channel status audio/data flag */ - if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { - snd_hda_codec_write(codec, - nvhdmi_master_con_nid_7x, - 0, - AC_VERB_SET_DIGI_CONVERT_1, - codec->spdif_ctls & 0xff); - snd_hda_codec_write(codec, - nvhdmi_master_con_nid_7x, - 0, - AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); - } - - for (i = 0; i < 4; i++) { - if (chs == 2) - channel_id = 0; - else - channel_id = i * 2; - - /* turn off SPDIF once; - *otherwise the IEC958 bits won't be updated - */ - if (codec->spdif_status_reset && - (codec->spdif_ctls & AC_DIG1_ENABLE)) - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_DIGI_CONVERT_1, - codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); - /* set the stream id */ - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_CHANNEL_STREAMID, - (stream_tag << 4) | channel_id); - /* set the stream format */ - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_STREAM_FORMAT, - format); - /* turn on again (if needed) */ - /* enable and set the channel status audio/data flag */ - if (codec->spdif_status_reset && - (codec->spdif_ctls & AC_DIG1_ENABLE)) { - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_DIGI_CONVERT_1, - codec->spdif_ctls & 0xff); - snd_hda_codec_write(codec, - nvhdmi_con_nids_7x[i], - 0, - AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); - } - } - - /* set the Audio Info Frame Checksum */ - snd_hda_codec_write(codec, 0x1, 0, - Nv_VERB_SET_Info_Frame_Checksum, - (0x71 - chan - chanmask)); - - mutex_unlock(&codec->spdif_mutex); - return 0; -} - -static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, - struct hda_codec *codec, - unsigned int stream_tag, - unsigned int format, - struct snd_pcm_substream *substream) -{ - struct hdmi_spec *spec = codec->spec; - return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, - format, substream); -} - -static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { - .substreams = 1, - .channels_min = 2, - .ops = { - .open = hdmi_pcm_open, - .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, - }, -}; - -static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_7x = { - .substreams = 1, - .channels_min = 2, - .channels_max = 8, - .nid = nvhdmi_master_con_nid_7x, - .rates = SUPPORTED_RATES, - .maxbps = SUPPORTED_MAXBPS, - .formats = SUPPORTED_FORMATS, - .ops = { - .open = nvhdmi_dig_playback_pcm_open, - .close = nvhdmi_dig_playback_pcm_close_8ch_7x, - .prepare = nvhdmi_dig_playback_pcm_prepare_8ch - }, -}; - -static struct hda_pcm_stream nvhdmi_pcm_digital_playback_2ch = { - .substreams = 1, - .channels_min = 2, - .channels_max = 2, - .nid = nvhdmi_master_con_nid_7x, - .rates = SUPPORTED_RATES, - .maxbps = SUPPORTED_MAXBPS, - .formats = SUPPORTED_FORMATS, - .ops = { - .open = nvhdmi_dig_playback_pcm_open, - .close = nvhdmi_dig_playback_pcm_close_2ch, - .prepare = nvhdmi_dig_playback_pcm_prepare_2ch - }, -}; - -static int nvhdmi_build_pcms_8ch_89(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - struct hda_pcm *info = spec->pcm_rec; - int i; - - codec->num_pcms = spec->num_cvts; - codec->pcm_info = info; - - for (i = 0; i < codec->num_pcms; i++, info++) { - unsigned int chans; - - chans = get_wcaps(codec, spec->cvt[i]); - chans = get_wcaps_channels(chans); - - info->name = nvhdmi_pcm_names[i]; - info->pcm_type = HDA_PCM_TYPE_HDMI; - info->stream[SNDRV_PCM_STREAM_PLAYBACK] - = nvhdmi_pcm_digital_playback_8ch_89; - info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i]; - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; - } - - return 0; -} - -static int nvhdmi_build_pcms_8ch_7x(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - struct hda_pcm *info = spec->pcm_rec; - - codec->num_pcms = 1; - codec->pcm_info = info; - - info->name = "NVIDIA HDMI"; - info->pcm_type = HDA_PCM_TYPE_HDMI; - info->stream[SNDRV_PCM_STREAM_PLAYBACK] - = nvhdmi_pcm_digital_playback_8ch_7x; - - return 0; -} - -static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) -{ - struct hdmi_spec *spec = codec->spec; - struct hda_pcm *info = spec->pcm_rec; - - codec->num_pcms = 1; - codec->pcm_info = info; - - info->name = "NVIDIA HDMI"; - info->pcm_type = HDA_PCM_TYPE_HDMI; - info->stream[SNDRV_PCM_STREAM_PLAYBACK] - = nvhdmi_pcm_digital_playback_2ch; - - return 0; -} - -static struct hda_codec_ops nvhdmi_patch_ops_8ch_89 = { - .build_controls = nvhdmi_build_controls, - .build_pcms = nvhdmi_build_pcms_8ch_89, - .init = nvhdmi_init, - .free = nvhdmi_free, - .unsol_event = hdmi_unsol_event, -}; - -static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = { - .build_controls = nvhdmi_build_controls, - .build_pcms = nvhdmi_build_pcms_8ch_7x, - .init = nvhdmi_init, - .free = nvhdmi_free, -}; - -static struct hda_codec_ops nvhdmi_patch_ops_2ch = { - .build_controls = nvhdmi_build_controls, - .build_pcms = nvhdmi_build_pcms_2ch, - .init = nvhdmi_init, - .free = nvhdmi_free, -}; - -static int patch_nvhdmi_8ch_89(struct hda_codec *codec) -{ - struct hdmi_spec *spec; - int i; - - spec = kzalloc(sizeof(*spec), GFP_KERNEL); - if (spec == NULL) - return -ENOMEM; - - codec->spec = spec; - spec->codec_type = HDA_CODEC_NVIDIA_MCP89; - spec->old_pin_detect = 1; - - if (hdmi_parse_codec(codec) < 0) { - codec->spec = NULL; - kfree(spec); - return -EINVAL; - } - codec->patch_ops = nvhdmi_patch_ops_8ch_89; - - for (i = 0; i < spec->num_pins; i++) - snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); - - init_channel_allocations(); - - return 0; -} - -static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) -{ - struct hdmi_spec *spec; - - spec = kzalloc(sizeof(*spec), GFP_KERNEL); - if (spec == NULL) - return -ENOMEM; - - codec->spec = spec; - - spec->multiout.num_dacs = 0; /* no analog */ - spec->multiout.max_channels = 8; - spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; - spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; - spec->old_pin_detect = 1; - - codec->patch_ops = nvhdmi_patch_ops_8ch_7x; - - return 0; -} - -static int patch_nvhdmi_2ch(struct hda_codec *codec) -{ - struct hdmi_spec *spec; - - spec = kzalloc(sizeof(*spec), GFP_KERNEL); - if (spec == NULL) - return -ENOMEM; - - codec->spec = spec; - - spec->multiout.num_dacs = 0; /* no analog */ - spec->multiout.max_channels = 2; - spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; - spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; - spec->old_pin_detect = 1; - - codec->patch_ops = nvhdmi_patch_ops_2ch; - - return 0; -} - -/* - * patch entries - */ -static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { - { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x }, - { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 }, - { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, - { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, - {} /* terminator */ -}; - -MODULE_ALIAS("snd-hda-codec-id:10de0002"); -MODULE_ALIAS("snd-hda-codec-id:10de0003"); -MODULE_ALIAS("snd-hda-codec-id:10de0005"); -MODULE_ALIAS("snd-hda-codec-id:10de0006"); -MODULE_ALIAS("snd-hda-codec-id:10de0007"); -MODULE_ALIAS("snd-hda-codec-id:10de000a"); -MODULE_ALIAS("snd-hda-codec-id:10de000b"); -MODULE_ALIAS("snd-hda-codec-id:10de000c"); -MODULE_ALIAS("snd-hda-codec-id:10de000d"); -MODULE_ALIAS("snd-hda-codec-id:10de0010"); -MODULE_ALIAS("snd-hda-codec-id:10de0011"); -MODULE_ALIAS("snd-hda-codec-id:10de0012"); -MODULE_ALIAS("snd-hda-codec-id:10de0013"); -MODULE_ALIAS("snd-hda-codec-id:10de0014"); -MODULE_ALIAS("snd-hda-codec-id:10de0018"); -MODULE_ALIAS("snd-hda-codec-id:10de0019"); -MODULE_ALIAS("snd-hda-codec-id:10de001a"); -MODULE_ALIAS("snd-hda-codec-id:10de001b"); -MODULE_ALIAS("snd-hda-codec-id:10de001c"); -MODULE_ALIAS("snd-hda-codec-id:10de0040"); -MODULE_ALIAS("snd-hda-codec-id:10de0041"); -MODULE_ALIAS("snd-hda-codec-id:10de0042"); -MODULE_ALIAS("snd-hda-codec-id:10de0043"); -MODULE_ALIAS("snd-hda-codec-id:10de0044"); -MODULE_ALIAS("snd-hda-codec-id:10de0067"); -MODULE_ALIAS("snd-hda-codec-id:10de8001"); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("NVIDIA HDMI HD-audio codec"); - -static struct hda_codec_preset_list nvhdmi_list = { - .preset = snd_hda_preset_nvhdmi, - .owner = THIS_MODULE, -}; - -static int __init patch_nvhdmi_init(void) -{ - return snd_hda_add_codec_preset(&nvhdmi_list); -} - -static void __exit patch_nvhdmi_exit(void) -{ - snd_hda_delete_codec_preset(&nvhdmi_list); -} - -module_init(patch_nvhdmi_init) -module_exit(patch_nvhdmi_exit) -- cgit v1.2.3 From f6837bbd599c2a4e1f621441f84286434bcc91ae Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Sep 2010 14:56:32 +0200 Subject: ALSA: hda - Fix up autocfg output pin numbers in realtek parser When quirks are applied, the numbers of output pins in autocfg aren't set up properly but only pin arrays are changed. Let's fix it up so that the rest of the parser can use autocfg.line_outs & co safely. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6045f281b22..bb3cf3b7282 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -876,6 +876,28 @@ static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val); } +static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + struct auto_pin_cfg *cfg = &spec->autocfg; + + if (!cfg->line_outs) { + while (cfg->line_outs < AUTO_CFG_MAX_OUTS && + cfg->line_out_pins[cfg->line_outs]) + cfg->line_outs++; + } + if (!cfg->speaker_outs) { + while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS && + cfg->speaker_pins[cfg->speaker_outs]) + cfg->speaker_outs++; + } + if (!cfg->hp_outs) { + while (cfg->hp_outs < AUTO_CFG_MAX_OUTS && + cfg->hp_pins[cfg->hp_outs]) + cfg->hp_outs++; + } +} + /* */ static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix) @@ -944,6 +966,8 @@ static void setup_preset(struct hda_codec *codec, if (preset->setup) preset->setup(codec); + + alc_fixup_autocfg_pin_nums(codec); } /* Enable GPIO mask and set output */ -- cgit v1.2.3 From e1ca7b4ea29707920650d86b22afdb7e94ad5986 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Sep 2010 14:58:57 +0200 Subject: ALSA: hda - Fix initialization of multiple output pins for ALC268/269 When multiple pins are assigned to headphones or speakers, they haven't been initialized properly. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index bb3cf3b7282..c4d9ad70fde 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -13484,8 +13484,10 @@ static void alc268_auto_set_output_and_unmute(struct hda_codec *codec, static void alc268_auto_init_multi_out(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; - hda_nid_t nid = spec->autocfg.line_out_pins[0]; - if (nid) { + int i; + + for (i = 0; i < spec->autocfg.line_outs; i++) { + hda_nid_t nid = spec->autocfg.line_out_pins[i]; int pin_type = get_pin_type(spec->autocfg.line_out_type); alc268_auto_set_output_and_unmute(codec, nid, pin_type); } @@ -13495,13 +13497,19 @@ static void alc268_auto_init_hp_out(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; hda_nid_t pin; + int i; - pin = spec->autocfg.hp_pins[0]; - if (pin) + for (i = 0; i < spec->autocfg.hp_outs; i++) { + pin = spec->autocfg.hp_pins[i]; alc268_auto_set_output_and_unmute(codec, pin, PIN_HP); - pin = spec->autocfg.speaker_pins[0]; - if (pin) + } + for (i = 0; i < spec->autocfg.speaker_outs; i++) { + pin = spec->autocfg.speaker_pins[i]; alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT); + } + if (spec->autocfg.mono_out_pin) + snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0, + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); } static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec) -- cgit v1.2.3 From d433a67831ab2c470cc53a3ff9b60f656767be15 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Sep 2010 15:11:54 +0200 Subject: ALSA: hda - Optimize the check of ALC269 codec variants Don't call the COEF check for checking ACL269 codec variants at each time in init but remember the type at the initialization. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index c4d9ad70fde..9bcf34eab67 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -393,6 +393,7 @@ struct alc_spec { unsigned int no_analog :1; /* digital I/O only */ unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */ int init_amp; + int codec_variant; /* flag for other variants */ /* for virtual master */ hda_nid_t vmaster_nid; @@ -14568,6 +14569,13 @@ static int alc275_setup_dual_adc(struct hda_codec *codec) return 0; } +/* different alc269-variants */ +enum { + ALC269_TYPE_NORMAL, + ALC269_TYPE_ALC259, + ALC269_TYPE_ALC271X, +}; + /* * BIOS auto configuration */ @@ -14596,7 +14604,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec) if (spec->kctls.list) add_mixer(spec, spec->kctls.list); - if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) { + if (spec->codec_variant != ALC269_TYPE_NORMAL) { add_verb(spec, alc269vb_init_verbs); alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21); } else { @@ -14962,7 +14970,6 @@ static int patch_alc269(struct hda_codec *codec) struct alc_spec *spec; int board_config; int err; - int is_alc269vb = 0; spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) @@ -14974,11 +14981,13 @@ static int patch_alc269(struct hda_codec *codec) if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ if (codec->bus->pci->subsystem_vendor == 0x1025 && - spec->cdefine.platform_type == 1) + spec->cdefine.platform_type == 1) { alc_codec_rename(codec, "ALC271X"); - else + spec->codec_variant = ALC269_TYPE_ALC271X; + } else { alc_codec_rename(codec, "ALC259"); - is_alc269vb = 1; + spec->codec_variant = ALC269_TYPE_ALC259; + } } else alc_fix_pll_init(codec, 0x20, 0x04, 15); @@ -15040,7 +15049,7 @@ static int patch_alc269(struct hda_codec *codec) spec->stream_digital_capture = &alc269_pcm_digital_capture; if (!spec->adc_nids) { /* wasn't filled automatically? use default */ - if (!is_alc269vb) { + if (spec->codec_variant != ALC269_TYPE_NORMAL) { spec->adc_nids = alc269_adc_nids; spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids); spec->capsrc_nids = alc269_capsrc_nids; -- cgit v1.2.3 From f3550d1b052a8acf4159b407dbdd1def47f223f9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Sep 2010 15:09:03 +0200 Subject: ALSA: hda - Fix capture widget for ALC269vb and co ALC269vb and other variants don't use the widgets 0x24 but prefer the widget 0x22 instead. We need to fix the input parser. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 9bcf34eab67..4abe3da1240 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -14593,7 +14593,11 @@ static int alc269_parse_auto_config(struct hda_codec *codec) err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg); if (err < 0) return err; - err = alc269_auto_create_input_ctls(codec, &spec->autocfg); + if (spec->codec_variant == ALC269_TYPE_NORMAL) + err = alc269_auto_create_input_ctls(codec, &spec->autocfg); + else + err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0, + 0x22, 0); if (err < 0) return err; -- cgit v1.2.3 From 0ec33d1f952934ea3251cefc6d108b47818eedd0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Sep 2010 15:20:52 +0200 Subject: ALSA: hda - Refactor ALC269 power-ups/downs in PM callbacks Create a helper function to simplify the code. Also, cleaned up the ifdef SND_HDA_NEEDS_RESUME and CONFIG_SND_HDA_POWER_SAVE. The former is always defined when the latter is set. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 51 ++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 4abe3da1240..8689216fdcc 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -4128,10 +4128,8 @@ static int alc_resume(struct hda_codec *codec) codec->patch_ops.init(codec); snd_hda_codec_resume_amp(codec); snd_hda_codec_resume_cache(codec); -#ifdef CONFIG_SND_HDA_POWER_SAVE if (codec->patch_ops.check_power_status) codec->patch_ops.check_power_status(codec, 0x01); -#endif return 0; } #endif @@ -14656,22 +14654,26 @@ static void alc269_auto_init(struct hda_codec *codec) alc_inithook(codec); } +#ifdef SND_HDA_NEEDS_RESUME +static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) +{ + int val = alc_read_coef_idx(codec, 0x04); + if (power_up) + val |= 1 << 11; + else + val &= ~(1 << 11); + alc_write_coef_idx(codec, 0x04, val); +} + #ifdef CONFIG_SND_HDA_POWER_SAVE static int alc269_suspend(struct hda_codec *codec, pm_message_t state) { struct alc_spec *spec = codec->spec; - int val; - - if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { - val = alc_read_coef_idx(codec, 0x04); - /* Power down output pin */ - alc_write_coef_idx(codec, 0x04, val & ~(1<<11)); - } + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) + alc269_toggle_power_output(codec, 0); if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { - val = alc_read_coef_idx(codec, 0x04); - /* Power down output pin */ - alc_write_coef_idx(codec, 0x04, val & ~(1<<11)); + alc269_toggle_power_output(codec, 0); msleep(150); } @@ -14680,43 +14682,32 @@ static int alc269_suspend(struct hda_codec *codec, pm_message_t state) spec->power_hook(codec); return 0; } -#endif -#ifdef SND_HDA_NEEDS_RESUME +#endif /* CONFIG_SND_HDA_POWER_SAVE */ + static int alc269_resume(struct hda_codec *codec) { - int val; - if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { - val = alc_read_coef_idx(codec, 0x04); - /* Power down output pin */ - alc_write_coef_idx(codec, 0x04, val & ~(1<<11)); + alc269_toggle_power_output(codec, 0); msleep(150); } codec->patch_ops.init(codec); if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) { - val = alc_read_coef_idx(codec, 0x04); - /* Power up output pin */ - alc_write_coef_idx(codec, 0x04, val | (1<<11)); + alc269_toggle_power_output(codec, 1); msleep(200); } - if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) { - val = alc_read_coef_idx(codec, 0x04); - /* Power up output pin */ - alc_write_coef_idx(codec, 0x04, val | (1<<11)); - } + if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) + alc269_toggle_power_output(codec, 1); snd_hda_codec_resume_amp(codec); snd_hda_codec_resume_cache(codec); -#ifdef CONFIG_SND_HDA_POWER_SAVE if (codec->patch_ops.check_power_status) codec->patch_ops.check_power_status(codec, 0x01); -#endif return 0; } -#endif +#endif /* SND_HDA_NEEDS_RESUME */ enum { ALC269_FIXUP_SONY_VAIO, -- cgit v1.2.3 From 53d7d69d8ffdfa60c5b66cc2e9ee0774aaaef5c0 Mon Sep 17 00:00:00 2001 From: Wu Fengguang Date: Tue, 21 Sep 2010 14:25:49 +0800 Subject: ALSA: hdmi - support infoframe for DisplayPort DisplayPort works mostly in the same way as HDMI, except that it expects a slightly different audio infoframe format. Citations from "HDA036-A: Display Port Support and HDMI Miscellaneous Corrections": The HDMI specification defines a data island packet with a header of 4 bytes (3 bytes content + 1 byte ECC) and packet body of 32 bytes (28 bytes content and 4 bytes ECC). Display Port specification on the other hand defines a data island packet (secondary data packet) with header of 4 bytes protected by 4 bytes of parity, and data of theoretically up to 1024 bytes with each 16 bytes chunk of data protected by 4 bytes of parity. Note that the ECC or parity bytes are not present in the DIP content populated by software and are hardware generated. It tests DP connection based on the ELD conn_type field, which will be set by the graphics driver and can be overriden manually by users through the /proc/asound/card0/eld* interface. The DP infoframe is tested OK on Intel SandyBridge/CougarPoint platform. Signed-off-by: Wu Fengguang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 110 ++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 37 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index cb997ca0fdf..1f4ae1aeca4 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -84,13 +84,25 @@ struct hdmi_audio_infoframe { u8 ver; /* 0x01 */ u8 len; /* 0x0a */ - u8 checksum; /* PB0 */ + u8 checksum; + u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ u8 SS01_SF24; u8 CXT04; u8 CA; u8 LFEPBL01_LSV36_DM_INH7; - u8 reserved[5]; /* PB6 - PB10 */ +}; + +struct dp_audio_infoframe { + u8 type; /* 0x84 */ + u8 len; /* 0x1b */ + u8 ver; /* 0x11 << 2 */ + + u8 CC02_CT47; /* match with HDMI infoframe from this on */ + u8 SS01_SF24; + u8 CXT04; + u8 CA; + u8 LFEPBL01_LSV36_DM_INH7; }; /* @@ -194,7 +206,7 @@ static int hdmi_channel_mapping[0x32][8] = { * This is an ordered list! * * The preceding ones have better chances to be selected by - * hdmi_setup_channel_allocation(). + * hdmi_channel_allocation(). */ static struct cea_channel_speaker_allocation channel_allocations[] = { /* channel: 7 6 5 4 3 2 1 0 */ @@ -371,14 +383,14 @@ static void init_channel_allocations(void) * * TODO: it could select the wrong CA from multiple candidates. */ -static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, - struct hdmi_audio_infoframe *ai) +static int hdmi_channel_allocation(struct hda_codec *codec, hda_nid_t nid, + int channels) { struct hdmi_spec *spec = codec->spec; struct hdmi_eld *eld; int i; + int ca = 0; int spk_mask = 0; - int channels = 1 + (ai->CC02_CT47 & 0x7); char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; /* @@ -416,16 +428,16 @@ static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, if (channels == channel_allocations[i].channels && (spk_mask & channel_allocations[i].spk_mask) == channel_allocations[i].spk_mask) { - ai->CA = channel_allocations[i].ca_index; + ca = channel_allocations[i].ca_index; break; } } snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf)); snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n", - ai->CA, channels, buf); + ca, channels, buf); - return ai->CA; + return ca; } static void hdmi_debug_channel_mapping(struct hda_codec *codec, @@ -447,10 +459,9 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec, static void hdmi_setup_channel_mapping(struct hda_codec *codec, hda_nid_t pin_nid, - struct hdmi_audio_infoframe *ai) + int ca) { int i; - int ca = ai->CA; int err; if (hdmi_channel_mapping[ca][1] == 0) { @@ -547,41 +558,37 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) #endif } -static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) +static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *hdmi_ai) { - u8 *bytes = (u8 *)ai; + u8 *bytes = (u8 *)hdmi_ai; u8 sum = 0; int i; - ai->checksum = 0; + hdmi_ai->checksum = 0; - for (i = 0; i < sizeof(*ai); i++) + for (i = 0; i < sizeof(*hdmi_ai); i++) sum += bytes[i]; - ai->checksum = -sum; + hdmi_ai->checksum = -sum; } static void hdmi_fill_audio_infoframe(struct hda_codec *codec, hda_nid_t pin_nid, - struct hdmi_audio_infoframe *ai) + u8 *dip, int size) { - u8 *bytes = (u8 *)ai; int i; hdmi_debug_dip_size(codec, pin_nid); hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ - hdmi_checksum_audio_infoframe(ai); - hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); - for (i = 0; i < sizeof(*ai); i++) - hdmi_write_dip_byte(codec, pin_nid, bytes[i]); + for (i = 0; i < size; i++) + hdmi_write_dip_byte(codec, pin_nid, dip[i]); } static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, - struct hdmi_audio_infoframe *ai) + u8 *dip, int size) { - u8 *bytes = (u8 *)ai; u8 val; int i; @@ -590,10 +597,10 @@ static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, return false; hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); - for (i = 0; i < sizeof(*ai); i++) { + for (i = 0; i < size; i++) { val = snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_DATA, 0); - if (val != bytes[i]) + if (val != dip[i]) return false; } @@ -605,15 +612,13 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, { struct hdmi_spec *spec = codec->spec; hda_nid_t pin_nid; + int channels = substream->runtime->channels; + int ca; int i; - struct hdmi_audio_infoframe ai = { - .type = 0x84, - .ver = 0x01, - .len = 0x0a, - .CC02_CT47 = substream->runtime->channels - 1, - }; + u8 ai[max(sizeof(struct hdmi_audio_infoframe), + sizeof(struct dp_audio_infoframe))]; - hdmi_setup_channel_allocation(codec, nid, &ai); + ca = hdmi_channel_allocation(codec, nid, channels); for (i = 0; i < spec->num_pins; i++) { if (spec->pin_cvt[i] != nid) @@ -622,14 +627,45 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, continue; pin_nid = spec->pin[i]; - if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { + + memset(ai, 0, sizeof(ai)); + if (spec->sink_eld[i].conn_type == 0) { /* HDMI */ + struct hdmi_audio_infoframe *hdmi_ai; + + hdmi_ai = (struct hdmi_audio_infoframe *)ai; + hdmi_ai->type = 0x84; + hdmi_ai->ver = 0x01; + hdmi_ai->len = 0x0a; + hdmi_ai->CC02_CT47 = channels - 1; + hdmi_checksum_audio_infoframe(hdmi_ai); + } else if (spec->sink_eld[i].conn_type == 1) { /* DisplayPort */ + struct dp_audio_infoframe *dp_ai; + + dp_ai = (struct dp_audio_infoframe *)ai; + dp_ai->type = 0x84; + dp_ai->len = 0x1b; + dp_ai->ver = 0x11 << 2; + dp_ai->CC02_CT47 = channels - 1; + } else { + snd_printd("HDMI: unknown connection type at pin %d\n", + pin_nid); + continue; + } + + /* + * sizeof(ai) is used instead of sizeof(*hdmi_ai) or + * sizeof(*dp_ai) to avoid partial match/update problems when + * the user switches between HDMI/DP monitors. + */ + if (!hdmi_infoframe_uptodate(codec, pin_nid, ai, sizeof(ai))) { snd_printdd("hdmi_setup_audio_infoframe: " "cvt=%d pin=%d channels=%d\n", nid, pin_nid, - substream->runtime->channels); - hdmi_setup_channel_mapping(codec, pin_nid, &ai); + channels); + hdmi_setup_channel_mapping(codec, pin_nid, ca); hdmi_stop_infoframe_trans(codec, pin_nid); - hdmi_fill_audio_infoframe(codec, pin_nid, &ai); + hdmi_fill_audio_infoframe(codec, pin_nid, + ai, sizeof(ai)); hdmi_start_infoframe_trans(codec, pin_nid); } } -- cgit v1.2.3 From 9396d3174b761685d6fefb1103e66b96a2e5db6d Mon Sep 17 00:00:00 2001 From: Jerry Zhou Date: Tue, 21 Sep 2010 14:44:51 +0800 Subject: ALSA: hdmi - fix surround41 channel mapping Channel 2 and channel 3 were all wrongly mapped to HDMI slot 4. This shows up as a bug that one channel is "lost" when playing in surround41 mode. Signed-off-by: Jerry Zhou Signed-off-by: Wu Fengguang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 1f4ae1aeca4..d3e49aa5b9e 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -193,7 +193,7 @@ static int hdmi_channel_mapping[0x32][8] = { /* 4ch */ [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, /* surround41 */ - [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, + [0x09] = { 0x00, 0x11, 0x24, 0x35, 0x42, 0xf3, 0xf6, 0xf7 }, /* surround50 */ [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, /* surround51 */ -- cgit v1.2.3 From 9e5341b92d1d2dde11691b394721b45b36416bef Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 21 Sep 2010 09:57:06 +0200 Subject: ALSA: hda - Introduce hda_call_check_power_status() helper Replace the explicit ifdef check and call of check_power_status ops with a new helper function, hda_call_check_power_status(). Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 5 +---- sound/pci/hda/hda_codec.h | 12 ++++++++++++ sound/pci/hda/patch_realtek.c | 11 +++-------- sound/pci/hda/patch_sigmatel.c | 12 ++++-------- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index e15a75751f5..053f827d2c2 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2228,10 +2228,7 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, HDA_AMP_MUTE, *valp ? 0 : HDA_AMP_MUTE); -#ifdef CONFIG_SND_HDA_POWER_SAVE - if (codec->patch_ops.check_power_status) - codec->patch_ops.check_power_status(codec, nid); -#endif + hda_call_check_power_status(codec, nid); snd_hda_power_down(codec); return change; } diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 62c70224010..ebf8eb02e3c 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -989,6 +989,18 @@ int snd_hda_suspend(struct hda_bus *bus); int snd_hda_resume(struct hda_bus *bus); #endif +#ifdef CONFIG_SND_HDA_POWER_SAVE +static inline +int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid) +{ + if (codec->patch_ops.check_power_status) + return codec->patch_ops.check_power_status(codec, nid); + return 0; +} +#else +#define hda_call_check_power_status(codec, nid) 0 +#endif + /* * get widget information */ diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 8689216fdcc..9bedca073e9 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -3729,10 +3729,7 @@ static int alc_init(struct hda_codec *codec) if (spec->init_hook) spec->init_hook(codec); -#ifdef CONFIG_SND_HDA_POWER_SAVE - if (codec->patch_ops.check_power_status) - codec->patch_ops.check_power_status(codec, 0x01); -#endif + hda_call_check_power_status(codec, 0x01); return 0; } @@ -4128,8 +4125,7 @@ static int alc_resume(struct hda_codec *codec) codec->patch_ops.init(codec); snd_hda_codec_resume_amp(codec); snd_hda_codec_resume_cache(codec); - if (codec->patch_ops.check_power_status) - codec->patch_ops.check_power_status(codec, 0x01); + hda_call_check_power_status(codec, 0x01); return 0; } #endif @@ -14703,8 +14699,7 @@ static int alc269_resume(struct hda_codec *codec) snd_hda_codec_resume_amp(codec); snd_hda_codec_resume_cache(codec); - if (codec->patch_ops.check_power_status) - codec->patch_ops.check_power_status(codec, 0x01); + hda_call_check_power_status(codec, 0x01); return 0; } #endif /* SND_HDA_NEEDS_RESUME */ diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 6bfbc2fe46e..a90327b0cc3 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -4372,11 +4372,9 @@ static int stac92xx_init(struct hda_codec *codec) stac_issue_unsol_event(codec, nid); } -#ifdef CONFIG_SND_HDA_POWER_SAVE /* sync mute LED */ - if (spec->gpio_led && codec->patch_ops.check_power_status) - codec->patch_ops.check_power_status(codec, 0x01); -#endif + if (spec->gpio_led) + hda_call_check_power_status(codec, 0x01); if (spec->dac_list) stac92xx_power_down(codec); return 0; @@ -4958,11 +4956,9 @@ static int stac92xx_resume(struct hda_codec *codec) stac_issue_unsol_event(codec, spec->autocfg.line_out_pins[0]); } -#ifdef CONFIG_SND_HDA_POWER_SAVE /* sync mute LED */ - if (spec->gpio_led && codec->patch_ops.check_power_status) - codec->patch_ops.check_power_status(codec, 0x01); -#endif + if (spec->gpio_led) + hda_call_check_power_status(codec, 0x01); return 0; } -- cgit v1.2.3 From 265a02478db5217eda8063004ded1ef0a461c240 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 21 Sep 2010 11:26:21 +0200 Subject: ALSA: hda - Check invalid NIDs in alc_init_jacks() The headphone and external-mic pin NIDs can be null, and the jack input elements should be skipped in such a case. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 9bedca073e9..f5ccba0fd18 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1087,15 +1087,19 @@ static int alc_init_jacks(struct hda_codec *codec) unsigned int hp_nid = spec->autocfg.hp_pins[0]; unsigned int mic_nid = spec->ext_mic.pin; - err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE); - if (err < 0) - return err; - alc_report_jack(codec, hp_nid); + if (hp_nid) { + err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE); + if (err < 0) + return err; + alc_report_jack(codec, hp_nid); + } - err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE); - if (err < 0) - return err; - alc_report_jack(codec, mic_nid); + if (mic_nid) { + err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE); + if (err < 0) + return err; + alc_report_jack(codec, mic_nid); + } return 0; } -- cgit v1.2.3 From abdd8f510686da0a58e475bc0143d1069e5f53da Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 21 Sep 2010 17:38:14 +0200 Subject: ALSA: hda - Apply ALC269 VAIO fix-up to all Sony laptops with ALC269 We've applied a fix-up for ALC269 VAIO only for two models. But all Sony VAIO models with ALC269 codec seem to require the similar fix. Let's apply it with vendor-id mask. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f2a30447f26..eea88b7ddb9 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -14731,8 +14731,7 @@ static const struct alc_fixup alc269_fixups[] = { }; static struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), - SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), + SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), {} }; -- cgit v1.2.3 From 4e7d7c6018567fa03f387d06602d4145c75ebbe0 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 22 Sep 2010 17:31:37 -0400 Subject: ALSA: hda - MacBookPro 5,3 line-in support I've found the following patch is necessary to enable line-in on my MacBookPro 5,3 machine. With the patch applied I've successfully recorded audio from the line-in jack. This is based on the existing 5,5 support. Signed-off-by: Vince Weaver Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 483c3f2d8d3..5c00106cbc2 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -65,6 +65,7 @@ struct cs_spec { /* available models */ enum { + CS420X_MBP53, CS420X_MBP55, CS420X_IMAC27, CS420X_AUTO, @@ -839,7 +840,8 @@ static void cs_automute(struct hda_codec *codec) AC_VERB_SET_PIN_WIDGET_CONTROL, hp_present ? 0 : PIN_OUT); } - if (spec->board_config == CS420X_MBP55 || + if (spec->board_config == CS420X_MBP53 || + spec->board_config == CS420X_MBP55 || spec->board_config == CS420X_IMAC27) { unsigned int gpio = hp_present ? 0x02 : 0x08; snd_hda_codec_write(codec, 0x01, 0, @@ -1128,6 +1130,7 @@ static int cs_parse_auto_config(struct hda_codec *codec) } static const char *cs420x_models[CS420X_MODELS] = { + [CS420X_MBP53] = "mbp53", [CS420X_MBP55] = "mbp55", [CS420X_IMAC27] = "imac27", [CS420X_AUTO] = "auto", @@ -1135,6 +1138,7 @@ static const char *cs420x_models[CS420X_MODELS] = { static struct snd_pci_quirk cs420x_cfg_tbl[] = { + SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), {} /* terminator */ @@ -1145,6 +1149,20 @@ struct cs_pincfg { u32 val; }; +static struct cs_pincfg mbp53_pincfgs[] = { + { 0x09, 0x012b4050 }, + { 0x0a, 0x90100141 }, + { 0x0b, 0x90100140 }, + { 0x0c, 0x018b3020 }, + { 0x0d, 0x90a00110 }, + { 0x0e, 0x400000f0 }, + { 0x0f, 0x01cbe030 }, + { 0x10, 0x014be060 }, + { 0x12, 0x400000f0 }, + { 0x15, 0x400000f0 }, + {} /* terminator */ +}; + static struct cs_pincfg mbp55_pincfgs[] = { { 0x09, 0x012b4030 }, { 0x0a, 0x90100121 }, @@ -1174,6 +1192,7 @@ static struct cs_pincfg imac27_pincfgs[] = { }; static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = { + [CS420X_MBP53] = mbp53_pincfgs, [CS420X_MBP55] = mbp55_pincfgs, [CS420X_IMAC27] = imac27_pincfgs, }; @@ -1206,6 +1225,7 @@ static int patch_cs420x(struct hda_codec *codec) switch (spec->board_config) { case CS420X_IMAC27: + case CS420X_MBP53: case CS420X_MBP55: /* GPIO1 = headphones */ /* GPIO3 = speakers */ -- cgit v1.2.3 From f41cc2a85d52ac6971299922084ac5ac59dc339d Mon Sep 17 00:00:00 2001 From: Vitaliy Kulikov Date: Fri, 24 Sep 2010 16:21:53 -0500 Subject: ALSA: hda - Fix switching between dmic and mic using the same mux on IDT/STAC Fix bug in switching between dmic and mic when both use the same mux. Signed-off-by: Vitaliy Kulikov Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index a90327b0cc3..d8dfafeab80 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -3481,8 +3481,10 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, return err; } - if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) + if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) { snd_hda_add_imux_item(imux, label, index, NULL); + spec->num_analog_muxes++; + } } return 0; -- cgit v1.2.3 From e35d4b119578a054515ccb4ed5dddc4e8a81ec15 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sun, 26 Sep 2010 23:35:06 -0300 Subject: ALSA: hda: add Vortex86MX PCI ids Signed-off-by: Otavio Salvador Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 5f6f9039a41..ec07e4700e3 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2791,6 +2791,8 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { /* this entry seems still valid -- i.e. without emu20kx chip */ { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, #endif + /* Vortex86MX */ + { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC }, /* AMD/ATI Generic, PCI class code and Vendor ID for HD Audio */ { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, -- cgit v1.2.3 From c123e5e437a0e61e364c1cbad3ef9a7384975fb2 Mon Sep 17 00:00:00 2001 From: Luke Yelavich Date: Tue, 28 Sep 2010 12:04:06 +1000 Subject: ALSA: hda - Add quirk for another Acer laptop with a CX20585 codec BugLink: https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/647374 Set another Acer laptop (SSID 1025:043d) to use CXT5066_IDEAPAD Signed-off-by: Luke Yelavich Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index a6c68cb06dd..80cc74bf77a 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3094,6 +3094,7 @@ static const char *cxt5066_models[CXT5066_MODELS] = { static struct snd_pci_quirk cxt5066_cfg_tbl[] = { SND_PCI_QUIRK(0x1025, 0x040a, "Acer", CXT5066_IDEAPAD), + SND_PCI_QUIRK(0x1025, 0x043d, "Acer", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", CXT5066_DELL_LAPTOP), -- cgit v1.2.3 From 4cb36310848fd17766aa72afd1f2873f54b4e055 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Thu, 30 Sep 2010 10:12:50 +0200 Subject: ALSA: HDA: Add position_fix=3 module option, and refactor related code What was previously known as via_dmapos_patch, and hard-coded to be used for VIA and ATI controllers, is now configurable through a module option. The background is that some VIA controllers seem to prefer via_dmapos_patch to be turned off. Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index ec07e4700e3..38b063eb80e 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -78,8 +78,8 @@ MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); module_param_array(model, charp, NULL, 0444); MODULE_PARM_DESC(model, "Use the given board model."); module_param_array(position_fix, int, NULL, 0444); -MODULE_PARM_DESC(position_fix, "Fix DMA pointer " - "(0 = auto, 1 = none, 2 = POSBUF)."); +MODULE_PARM_DESC(position_fix, "DMA pointer read method." + "(0 = auto, 1 = LPIB, 2 = POSBUF, 3 = VIACOMBO)."); module_param_array(bdl_pos_adj, int, NULL, 0644); MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset."); module_param_array(probe_mask, int, NULL, 0444); @@ -305,6 +305,7 @@ enum { POS_FIX_AUTO, POS_FIX_LPIB, POS_FIX_POSBUF, + POS_FIX_VIACOMBO, }; /* Defines for ATI HD Audio support in SB450 south bridge */ @@ -433,7 +434,6 @@ struct azx { unsigned int polling_mode :1; unsigned int msi :1; unsigned int irq_pending_warned :1; - unsigned int via_dmapos_patch :1; /* enable DMA-position fix for VIA */ unsigned int probing :1; /* codec probing phase */ /* for debugging */ @@ -1309,11 +1309,8 @@ static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev) azx_sd_writel(azx_dev, SD_BDLPU, upper_32_bits(azx_dev->bdl.addr)); /* enable the position buffer */ - if (chip->position_fix[0] == POS_FIX_POSBUF || - chip->position_fix[0] == POS_FIX_AUTO || - chip->position_fix[1] == POS_FIX_POSBUF || - chip->position_fix[1] == POS_FIX_AUTO || - chip->via_dmapos_patch) { + if (chip->position_fix[0] != POS_FIX_LPIB || + chip->position_fix[1] != POS_FIX_LPIB) { if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); @@ -1852,20 +1849,21 @@ static unsigned int azx_get_position(struct azx *chip, struct azx_dev *azx_dev) { unsigned int pos; + int stream = azx_dev->substream->stream; - if (chip->via_dmapos_patch) + switch (chip->position_fix[stream]) { + case POS_FIX_LPIB: + /* read LPIB */ + pos = azx_sd_readl(azx_dev, SD_LPIB); + break; + case POS_FIX_VIACOMBO: pos = azx_via_get_position(chip, azx_dev); - else { - int stream = azx_dev->substream->stream; - if (chip->position_fix[stream] == POS_FIX_POSBUF || - chip->position_fix[stream] == POS_FIX_AUTO) { - /* use the position buffer */ - pos = le32_to_cpu(*azx_dev->posbuf); - } else { - /* read LPIB */ - pos = azx_sd_readl(azx_dev, SD_LPIB); - } + break; + default: + /* use the position buffer */ + pos = le32_to_cpu(*azx_dev->posbuf); } + if (pos >= azx_dev->bufsize) pos = 0; return pos; @@ -2313,6 +2311,7 @@ static int __devinit check_position_fix(struct azx *chip, int fix) switch (fix) { case POS_FIX_LPIB: case POS_FIX_POSBUF: + case POS_FIX_VIACOMBO: return fix; } @@ -2320,11 +2319,9 @@ static int __devinit check_position_fix(struct azx *chip, int fix) switch (chip->driver_type) { case AZX_DRIVER_VIA: case AZX_DRIVER_ATI: - chip->via_dmapos_patch = 1; /* Use link position directly, avoid any transfer problem. */ - return POS_FIX_LPIB; + return POS_FIX_VIACOMBO; } - chip->via_dmapos_patch = 0; q = snd_pci_quirk_lookup(chip->pci, position_fix_list); if (q) { -- cgit v1.2.3 From d41185882b828896ccecac319c9f65f708baaf0d Mon Sep 17 00:00:00 2001 From: Valentine Sinitsyn Date: Fri, 1 Oct 2010 22:24:08 +0600 Subject: ALSA: hda - Added fixup for Lenovo Y550P Signed-off-by: Valentine Sinitsyn Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index f6427cc12a2..b4e0959b1f9 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -19246,6 +19246,7 @@ static const struct alc_fixup alc662_fixups[] = { }; static struct snd_pci_quirk alc662_fixup_tbl[] = { + SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), {} }; -- cgit v1.2.3 From 45bc307f328c044e69cad2a18a9ae972bb15f254 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Oct 2010 13:17:26 +0200 Subject: ALSA: virtuoso: fix Xonar DS chip name The controller on the Xonar DS is labeled "AV66", not "AV200". Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/virtuoso.c | 4 ++-- sound/pci/oxygen/xonar_wm87x6.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 06c863e86e3..599bb9ab97e 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c @@ -25,9 +25,9 @@ #include "xonar.h" MODULE_AUTHOR("Clemens Ladisch "); -MODULE_DESCRIPTION("Asus AVx00 driver"); +MODULE_DESCRIPTION("Asus Virtuoso driver"); MODULE_LICENSE("GPL v2"); -MODULE_SUPPORTED_DEVICE("{{Asus,AV100},{Asus,AV200}}"); +MODULE_SUPPORTED_DEVICE("{{Asus,AV66},{Asus,AV100},{Asus,AV200}}"); static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index aceaaa036da..5f9f59c1019 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -1071,7 +1071,7 @@ static int xonar_ds_mixer_init(struct oxygen *chip) static const struct oxygen_model model_xonar_ds = { .shortname = "Xonar DS", - .longname = "Asus Virtuoso 200", + .longname = "Asus Virtuoso 66", .chip = "AV200", .init = xonar_ds_init, .control_filter = xonar_ds_control_filter, -- cgit v1.2.3 From b6ca8ab399d913eed0d89d65d6b768337a3d20d7 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Oct 2010 13:21:52 +0200 Subject: ALSA: oxygen: handle CD input configuration with a flag There are more models without a CD input than with one, so handle this explicitly with a device_config flag to avoid having to define a control filter callback to filter it out. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen.c | 3 ++- sound/pci/oxygen/oxygen.h | 1 + sound/pci/oxygen/oxygen_mixer.c | 3 +++ sound/pci/oxygen/xonar_cs43xx.c | 8 -------- sound/pci/oxygen/xonar_pcm179x.c | 11 ++--------- sound/pci/oxygen/xonar_wm87x6.c | 8 -------- 6 files changed, 8 insertions(+), 26 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index 289cb4dacfc..f4fdf6dac80 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c @@ -505,7 +505,8 @@ static const struct oxygen_model model_generic = { PLAYBACK_2_TO_AC97_1 | CAPTURE_0_FROM_I2S_1 | CAPTURE_1_FROM_SPDIF | - CAPTURE_2_FROM_AC97_1, + CAPTURE_2_FROM_AC97_1 | + AC97_CD_INPUT, .dac_channels = 8, .dac_volume_min = 0, .dac_volume_max = 255, diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index a3409edcfb5..7d5222caa0a 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h @@ -34,6 +34,7 @@ /* CAPTURE_3_FROM_I2S_3 not implemented */ #define MIDI_OUTPUT 0x0800 #define MIDI_INPUT 0x1000 +#define AC97_CD_INPUT 0x2000 enum { CONTROL_SPDIF_PCM, diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index f375b8a2786..7d40ba8db9f 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c @@ -972,6 +972,9 @@ static int add_controls(struct oxygen *chip, if (!strcmp(template.name, "Stereo Upmixing") && chip->model.dac_channels == 2) continue; + if (!strncmp(template.name, "CD Capture ", 11) && + !(chip->model.device_config & AC97_CD_INPUT)) + continue; if (!strcmp(template.name, "Master Playback Volume") && chip->model.dac_tlv) { template.tlv.p = chip->model.dac_tlv; diff --git a/sound/pci/oxygen/xonar_cs43xx.c b/sound/pci/oxygen/xonar_cs43xx.c index 7c4986b27f2..aa27c31049a 100644 --- a/sound/pci/oxygen/xonar_cs43xx.c +++ b/sound/pci/oxygen/xonar_cs43xx.c @@ -367,13 +367,6 @@ static void xonar_d1_line_mic_ac97_switch(struct oxygen *chip, static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -6000, 100, 0); -static int xonar_d1_control_filter(struct snd_kcontrol_new *template) -{ - if (!strncmp(template->name, "CD Capture ", 11)) - return 1; /* no CD input */ - return 0; -} - static int xonar_d1_mixer_init(struct oxygen *chip) { int err; @@ -391,7 +384,6 @@ static const struct oxygen_model model_xonar_d1 = { .longname = "Asus Virtuoso 100", .chip = "AV200", .init = xonar_d1_init, - .control_filter = xonar_d1_control_filter, .mixer_init = xonar_d1_mixer_init, .cleanup = xonar_d1_cleanup, .suspend = xonar_d1_suspend, diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c index ba18fb546b4..338f88567f5 100644 --- a/sound/pci/oxygen/xonar_pcm179x.c +++ b/sound/pci/oxygen/xonar_pcm179x.c @@ -915,13 +915,6 @@ static int xonar_d2_control_filter(struct snd_kcontrol_new *template) return 0; } -static int xonar_st_control_filter(struct snd_kcontrol_new *template) -{ - if (!strncmp(template->name, "CD Capture ", 11)) - return 1; /* no CD input */ - return 0; -} - static int add_pcm1796_controls(struct oxygen *chip) { int err; @@ -991,7 +984,8 @@ static const struct oxygen_model model_xonar_d2 = { CAPTURE_0_FROM_I2S_2 | CAPTURE_1_FROM_SPDIF | MIDI_OUTPUT | - MIDI_INPUT, + MIDI_INPUT | + AC97_CD_INPUT, .dac_channels = 8, .dac_volume_min = 255 - 2*60, .dac_volume_max = 255, @@ -1037,7 +1031,6 @@ static const struct oxygen_model model_xonar_st = { .longname = "Asus Virtuoso 100", .chip = "AV200", .init = xonar_st_init, - .control_filter = xonar_st_control_filter, .mixer_init = xonar_st_mixer_init, .cleanup = xonar_st_cleanup, .suspend = xonar_st_suspend, diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index 5f9f59c1019..200f7601276 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -1028,13 +1028,6 @@ static const struct snd_kcontrol_new lc_controls[] = { LC_CONTROL_ALC, wm8776_ngth_db_scale), }; -static int xonar_ds_control_filter(struct snd_kcontrol_new *template) -{ - if (!strncmp(template->name, "CD Capture ", 11)) - return 1; /* no CD input */ - return 0; -} - static int xonar_ds_mixer_init(struct oxygen *chip) { struct xonar_wm87x6 *data = chip->model_data; @@ -1074,7 +1067,6 @@ static const struct oxygen_model model_xonar_ds = { .longname = "Asus Virtuoso 66", .chip = "AV200", .init = xonar_ds_init, - .control_filter = xonar_ds_control_filter, .mixer_init = xonar_ds_mixer_init, .cleanup = xonar_ds_cleanup, .suspend = xonar_ds_suspend, -- cgit v1.2.3 From 2b830bae1fc2a27b3b0ab86091013bdec3c12427 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Oct 2010 13:22:51 +0200 Subject: ALSA: virtuoso: add HDAV1.3 Slim PCI ID Add a PCI ID for the Xonar HDAV1.3 Slim. There is no actual support, but the presence of the ID allows the EEPROM repair code to work for this card. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/virtuoso.c | 1 + sound/pci/oxygen/xonar_pcm179x.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 599bb9ab97e..469010a8b84 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c @@ -49,6 +49,7 @@ static DEFINE_PCI_DEVICE_TABLE(xonar_ids) = { { OXYGEN_PCI_SUBID(0x1043, 0x834f) }, { OXYGEN_PCI_SUBID(0x1043, 0x835c) }, { OXYGEN_PCI_SUBID(0x1043, 0x835d) }, + { OXYGEN_PCI_SUBID(0x1043, 0x835e) }, { OXYGEN_PCI_SUBID(0x1043, 0x838e) }, { OXYGEN_PCI_SUBID_BROKEN_EEPROM }, { } diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c index 338f88567f5..571d0ae42af 100644 --- a/sound/pci/oxygen/xonar_pcm179x.c +++ b/sound/pci/oxygen/xonar_pcm179x.c @@ -132,6 +132,18 @@ * GPIO 5 <- 0 */ +/* + * Xonar HDAV1.3 Slim + * ------------------ + * + * CMI8788: + * + * GPIO 1 -> enable output + * + * TXD -> HDMI controller + * RXD <- HDMI controller + */ + #include #include #include @@ -1101,6 +1113,9 @@ int __devinit get_xonar_pcm179x_model(struct oxygen *chip, chip->model.resume = xonar_stx_resume; chip->model.set_dac_params = set_pcm1796_params; break; + case 0x835e: + snd_printk(KERN_ERR "the HDAV1.3 Slim is not supported\n"); + return -ENODEV; default: return -EINVAL; } -- cgit v1.2.3 From d737f3eedef0717c8b8233bb6455ff13637ff243 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Oct 2010 13:23:26 +0200 Subject: ALSA: virtuoso: fix Xonar STX anti-pop delay The anti-pop delay for the STX should be 800 ms, not 100 ms like the ST. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/xonar_pcm179x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c index 571d0ae42af..d491fd6c0be 100644 --- a/sound/pci/oxygen/xonar_pcm179x.c +++ b/sound/pci/oxygen/xonar_pcm179x.c @@ -374,7 +374,6 @@ static void xonar_st_init_common(struct oxygen *chip) { struct xonar_pcm179x *data = chip->model_data; - data->generic.anti_pop_delay = 100; data->generic.output_enable_bit = GPIO_ST_OUTPUT_ENABLE; data->dacs = chip->model.private_data ? 4 : 1; data->hp_gain_offset = 2*-18; @@ -420,6 +419,7 @@ static void xonar_st_init(struct oxygen *chip) { struct xonar_pcm179x *data = chip->model_data; + data->generic.anti_pop_delay = 100; data->has_cs2000 = 1; data->cs2000_fun_cfg_1 = CS2000_REF_CLK_DIV_1; @@ -440,6 +440,7 @@ static void xonar_stx_init(struct oxygen *chip) struct xonar_pcm179x *data = chip->model_data; xonar_st_init_i2c(chip); + data->generic.anti_pop_delay = 800; data->generic.ext_power_reg = OXYGEN_GPI_DATA; data->generic.ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; data->generic.ext_power_bit = GPI_EXT_POWER; -- cgit v1.2.3 From de0074ee7ae7d61da40567afa53912d7e3e16b25 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Oct 2010 13:24:43 +0200 Subject: ALSA: oxygen: fix chip ID register symbols Rename the symbol for the XCID pins, fix up a decimal/hex confusion for the CMI8787 package ID, and add the other known package IDs. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_regs.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/oxygen_regs.h b/sound/pci/oxygen/oxygen_regs.h index 72de159d456..4dcd41b7825 100644 --- a/sound/pci/oxygen/oxygen_regs.h +++ b/sound/pci/oxygen/oxygen_regs.h @@ -436,13 +436,15 @@ /* OXYGEN_CHANNEL_* */ #define OXYGEN_CODEC_VERSION 0xe4 -#define OXYGEN_XCID_MASK 0x07 +#define OXYGEN_CODEC_ID_MASK 0x07 #define OXYGEN_REVISION 0xe6 -#define OXYGEN_REVISION_XPKGID_MASK 0x0007 +#define OXYGEN_PACKAGE_ID_MASK 0x0007 +#define OXYGEN_PACKAGE_ID_8786 0x0004 +#define OXYGEN_PACKAGE_ID_8787 0x0006 +#define OXYGEN_PACKAGE_ID_8788 0x0007 #define OXYGEN_REVISION_MASK 0xfff8 -#define OXYGEN_REVISION_2 0x0008 /* bit flag */ -#define OXYGEN_REVISION_8787 0x0014 /* 8 bits */ +#define OXYGEN_REVISION_2 0x0008 #define OXYGEN_OFFSIN_48K 0xe8 #define OXYGEN_OFFSBASE_48K 0xe9 -- cgit v1.2.3 From 9a0b37926595b57c4b5fc56aa6fd243bed4ee4eb Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 4 Oct 2010 13:25:13 +0200 Subject: ALSA: oxygen: fix input monitor dB scale The input monitor half volume bit results in a factor of 0.5, so the minimum scale value should be -6 dB. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index 7d40ba8db9f..2849b36f5f7 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c @@ -708,7 +708,7 @@ static int ac97_fp_rec_volume_put(struct snd_kcontrol *ctl, .private_value = ((codec) << 24) | ((stereo) << 16) | (index), \ } -static DECLARE_TLV_DB_SCALE(monitor_db_scale, -1000, 1000, 0); +static DECLARE_TLV_DB_SCALE(monitor_db_scale, -600, 600, 0); static DECLARE_TLV_DB_SCALE(ac97_db_scale, -3450, 150, 0); static DECLARE_TLV_DB_SCALE(ac97_rec_db_scale, 0, 150, 0); -- cgit v1.2.3 From 93943beb29be7084afb61556e96bc454079bfb0e Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 6 Oct 2010 10:57:11 +0200 Subject: ALSA: oxygen: reduce minimum period count The interrupt counter is independent of the buffer counter, so there are no restrictions on the period size. Having fewer periods also makes PulseAudio happy. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_pcm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index 9dff6954c39..814667442eb 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c @@ -56,8 +56,8 @@ static const struct snd_pcm_hardware oxygen_stereo_hardware = { .channels_max = 2, .buffer_bytes_max = BUFFER_BYTES_MAX, .period_bytes_min = PERIOD_BYTES_MIN, - .period_bytes_max = BUFFER_BYTES_MAX / 2, - .periods_min = 2, + .period_bytes_max = BUFFER_BYTES_MAX, + .periods_min = 1, .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN, }; static const struct snd_pcm_hardware oxygen_multichannel_hardware = { @@ -82,8 +82,8 @@ static const struct snd_pcm_hardware oxygen_multichannel_hardware = { .channels_max = 8, .buffer_bytes_max = BUFFER_BYTES_MAX_MULTICH, .period_bytes_min = PERIOD_BYTES_MIN, - .period_bytes_max = BUFFER_BYTES_MAX_MULTICH / 2, - .periods_min = 2, + .period_bytes_max = BUFFER_BYTES_MAX_MULTICH, + .periods_min = 1, .periods_max = BUFFER_BYTES_MAX_MULTICH / PERIOD_BYTES_MIN, }; static const struct snd_pcm_hardware oxygen_ac97_hardware = { @@ -100,8 +100,8 @@ static const struct snd_pcm_hardware oxygen_ac97_hardware = { .channels_max = 2, .buffer_bytes_max = BUFFER_BYTES_MAX, .period_bytes_min = PERIOD_BYTES_MIN, - .period_bytes_max = BUFFER_BYTES_MAX / 2, - .periods_min = 2, + .period_bytes_max = BUFFER_BYTES_MAX, + .periods_min = 1, .periods_max = BUFFER_BYTES_MAX / PERIOD_BYTES_MIN, }; -- cgit v1.2.3 From 7cb4ced5aa83b681c76b004c8960b4f2a6471fef Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 6 Oct 2010 10:57:50 +0200 Subject: ALSA: oxygen: rewrite PCIe bridge initialization Change the PCIe/PCI bridge initialization code to configure only the bridge that is actually connected to the sound chip, instead of any bridge found in the system. The new code also makes it easier to add other bridges. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_lib.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index 7e93cf88443..d10cc6ee1a6 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -308,25 +308,31 @@ static void oxygen_restore_eeprom(struct oxygen *chip, } } -static void pci_bridge_magic(void) +static void configure_pcie_bridge(struct pci_dev *pci) { - struct pci_dev *pci = NULL; + enum { PI7C9X110 }; + static const struct pci_device_id bridge_ids[] = { + { PCI_DEVICE(0x12d8, 0xe110), .driver_data = PI7C9X110 }, + { } + }; + struct pci_dev *bridge; + const struct pci_device_id *id; u32 tmp; - for (;;) { - /* If there is any Pericom PI7C9X110 PCI-E/PCI bridge ... */ - pci = pci_get_device(0x12d8, 0xe110, pci); - if (!pci) - break; - /* - * ... configure its secondary internal arbiter to park to - * the secondary port, instead of to the last master. - */ - if (!pci_read_config_dword(pci, 0x40, &tmp)) { - tmp |= 1; - pci_write_config_dword(pci, 0x40, tmp); - } - /* Why? Try asking C-Media. */ + if (!pci->bus || !pci->bus->self) + return; + bridge = pci->bus->self; + + id = pci_match_id(bridge_ids, bridge); + if (!id) + return; + + switch (id->driver_data) { + case PI7C9X110: /* Pericom PI7C9X110 PCIe/PCI bridge */ + pci_read_config_dword(bridge, 0x40, &tmp); + tmp |= 1; /* park the PCI arbiter to the sound chip */ + pci_write_config_dword(bridge, 0x40, tmp); + break; } } @@ -613,7 +619,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, snd_card_set_dev(card, &pci->dev); card->private_free = oxygen_card_free; - pci_bridge_magic(); + configure_pcie_bridge(pci); oxygen_init(chip); chip->model.init(chip); -- cgit v1.2.3 From ebebeece4ba596973c0c181a8cce5fd77bae427c Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 6 Oct 2010 10:58:50 +0200 Subject: ALSA: oxygen: add PEX8111 initialization Configure the PEX8111 bridge on the PCI Express cards so that the audio DMA controller can do proper burst reads and is less likely to lose data. This is usually done automatically, but is required on older cards where the user has not applied the PLX firmware update. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen_lib.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index d10cc6ee1a6..e5ebe56fb0c 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c @@ -310,8 +310,10 @@ static void oxygen_restore_eeprom(struct oxygen *chip, static void configure_pcie_bridge(struct pci_dev *pci) { - enum { PI7C9X110 }; + enum { PEX811X, PI7C9X110 }; static const struct pci_device_id bridge_ids[] = { + { PCI_VDEVICE(PLX, 0x8111), .driver_data = PEX811X }, + { PCI_VDEVICE(PLX, 0x8112), .driver_data = PEX811X }, { PCI_DEVICE(0x12d8, 0xe110), .driver_data = PI7C9X110 }, { } }; @@ -328,6 +330,19 @@ static void configure_pcie_bridge(struct pci_dev *pci) return; switch (id->driver_data) { + case PEX811X: /* PLX PEX8111/PEX8112 PCIe/PCI bridge */ + pci_read_config_dword(bridge, 0x48, &tmp); + tmp |= 1; /* enable blind prefetching */ + tmp |= 1 << 11; /* enable beacon generation */ + pci_write_config_dword(bridge, 0x48, tmp); + + pci_write_config_dword(bridge, 0x84, 0x0c); + pci_read_config_dword(bridge, 0x88, &tmp); + tmp &= ~(7 << 27); + tmp |= 2 << 27; /* set prefetch size to 128 bytes */ + pci_write_config_dword(bridge, 0x88, tmp); + break; + case PI7C9X110: /* Pericom PI7C9X110 PCIe/PCI bridge */ pci_read_config_dword(bridge, 0x40, &tmp); tmp |= 1; /* park the PCI arbiter to the sound chip */ -- cgit v1.2.3 From dd1d3a49db4ae5c6afffadaff526b96c7993c7dd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 6 Oct 2010 17:28:56 +0200 Subject: ALSA: oxygen - Add a SSID for CMI8787-HG2PCI This board has a strange PCI SSID 13f6:ffff. Works as compabile as MODEL_CMEDIA_REF. Reported-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/pci/oxygen/oxygen.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci') diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index f4fdf6dac80..1d915efb269 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c @@ -79,6 +79,7 @@ static DEFINE_PCI_DEVICE_TABLE(oxygen_ids) = { { OXYGEN_PCI_SUBID(0x13f6, 0x0001), .driver_data = MODEL_CMEDIA_REF }, { OXYGEN_PCI_SUBID(0x13f6, 0x0010), .driver_data = MODEL_CMEDIA_REF }, { OXYGEN_PCI_SUBID(0x13f6, 0x8788), .driver_data = MODEL_CMEDIA_REF }, + { OXYGEN_PCI_SUBID(0x13f6, 0xffff), .driver_data = MODEL_CMEDIA_REF }, { OXYGEN_PCI_SUBID(0x147a, 0xa017), .driver_data = MODEL_CMEDIA_REF }, { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF }, { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN }, -- cgit v1.2.3 From f46119b73425df9d1e05c5d5e909a993d95b0218 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 11 Oct 2010 14:46:35 +0200 Subject: ALSA: hda - Add model=mbp55 entry for MacBookPro 7,1 Reference: Novell bnc#645066 https://bugzilla.novell.com/show_bug.cgi?id=645066 Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 5c00106cbc2..d9a3dbcc9ba 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -1140,6 +1140,7 @@ static const char *cs420x_models[CS420X_MODELS] = { static struct snd_pci_quirk cs420x_cfg_tbl[] = { SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53), SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55), + SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55), SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27), {} /* terminator */ }; -- cgit v1.2.3 From 6a92934d9e987b6363db3e6a08e17bc0f2078c5d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 11 Oct 2010 15:16:20 +0200 Subject: ALSA: hda - Add input volume control for each mic/line-in pin The input pins on cirrus codecs have also input amps. Let's make control elemetns for them. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_cirrus.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index d9a3dbcc9ba..460fb2ef7e3 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c @@ -742,6 +742,27 @@ static struct hda_bind_ctls *make_bind_capture(struct hda_codec *codec, return bind; } +/* add a (input-boost) volume control to the given input pin */ +static int add_input_volume_control(struct hda_codec *codec, + struct auto_pin_cfg *cfg, + int item) +{ + hda_nid_t pin = cfg->inputs[item].pin; + u32 caps; + const char *label; + struct snd_kcontrol *kctl; + + if (!(get_wcaps(codec, pin) & AC_WCAP_IN_AMP)) + return 0; + caps = query_amp_caps(codec, pin, HDA_INPUT); + caps = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; + if (caps <= 1) + return 0; + label = hda_get_autocfg_input_label(codec, cfg, item); + return add_volume(codec, label, 0, + HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_INPUT), 1, &kctl); +} + static int build_input(struct hda_codec *codec) { struct cs_spec *spec = codec->spec; @@ -781,6 +802,12 @@ static int build_input(struct hda_codec *codec) return err; } + for (i = 0; i < spec->num_inputs; i++) { + err = add_input_volume_control(codec, &spec->autocfg, i); + if (err < 0) + return err; + } + return 0; } -- cgit v1.2.3 From bdd9ef24cd343c508ed93f1e08f30d4db595b754 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Mon, 4 Oct 2010 12:02:14 +0200 Subject: ALSA: HDA: Correctly apply position_fix quirks for ATI and VIA controllers Position_fix quirks for specific machines now override the default position_fix behavior for all HDA controllers. BugLink: http://launchpad.net/bugs/465942 BugLink: http://launchpad.net/bugs/580749 BugLink: http://launchpad.net/bugs/587546 Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 38b063eb80e..5cbea85a645 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -2315,14 +2315,6 @@ static int __devinit check_position_fix(struct azx *chip, int fix) return fix; } - /* Check VIA/ATI HD Audio Controller exist */ - switch (chip->driver_type) { - case AZX_DRIVER_VIA: - case AZX_DRIVER_ATI: - /* Use link position directly, avoid any transfer problem. */ - return POS_FIX_VIACOMBO; - } - q = snd_pci_quirk_lookup(chip->pci, position_fix_list); if (q) { printk(KERN_INFO @@ -2331,6 +2323,15 @@ static int __devinit check_position_fix(struct azx *chip, int fix) q->value, q->subvendor, q->subdevice); return q->value; } + + /* Check VIA/ATI HD Audio Controller exist */ + switch (chip->driver_type) { + case AZX_DRIVER_VIA: + case AZX_DRIVER_ATI: + /* Use link position directly, avoid any transfer problem. */ + return POS_FIX_VIACOMBO; + } + return POS_FIX_AUTO; } -- cgit v1.2.3 From 2df03514de41f3bbb5623f2e7f2bf594e49cb2ec Mon Sep 17 00:00:00 2001 From: Daniel T Chen Date: Sun, 10 Oct 2010 22:39:28 -0400 Subject: ALSA: hda: Add speaker pin to automute Acer Aspire 8943G BugLink: https://bugs.launchpad.net/bugs/656625 Add clause for handling Acer Aspire 8943G's subwoofer as additional speaker pin for automuting. Reported-by: RussianNeuroMancer Cc: stable@kernel.org Signed-off-by: Daniel T Chen Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index b4e0959b1f9..c41ac30ffc7 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -19233,10 +19233,17 @@ static void alc662_auto_init(struct hda_codec *codec) } enum { + ALC662_FIXUP_ASPIRE, ALC662_FIXUP_IDEAPAD, }; static const struct alc_fixup alc662_fixups[] = { + [ALC662_FIXUP_ASPIRE] = { + .pins = (const struct alc_pincfg[]) { + { 0x15, 0x99130112 }, /* subwoofer */ + { } + } + }, [ALC662_FIXUP_IDEAPAD] = { .pins = (const struct alc_pincfg[]) { { 0x17, 0x99130112 }, /* subwoofer */ @@ -19246,6 +19253,7 @@ static const struct alc_fixup alc662_fixups[] = { }; static struct snd_pci_quirk alc662_fixup_tbl[] = { + SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), {} -- cgit v1.2.3 From fa2eb005ebcbac89745a1f9a9f0c8678ba63f61a Mon Sep 17 00:00:00 2001 From: Andrea Gelmini Date: Sat, 16 Oct 2010 15:19:20 +0200 Subject: sound: fixed typos Signed-off-by: Andrea Gelmini Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0_mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/au88x0/au88x0_mixer.c b/sound/pci/au88x0/au88x0_mixer.c index c92f493d341..557c782ae4f 100644 --- a/sound/pci/au88x0/au88x0_mixer.c +++ b/sound/pci/au88x0/au88x0_mixer.c @@ -23,7 +23,7 @@ static int __devinit snd_vortex_mixer(vortex_t * vortex) if ((err = snd_ac97_bus(vortex->card, 0, &ops, NULL, &pbus)) < 0) return err; memset(&ac97, 0, sizeof(ac97)); - // Intialize AC97 codec stuff. + // Initialize AC97 codec stuff. ac97.private_data = vortex; ac97.scaps = AC97_SCAP_NO_SPDIF; err = snd_ac97_mixer(pbus, &ac97, &vortex->codec); -- cgit v1.2.3 From 906229174c20e3d5cbda8da070af8f30196316c3 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Thu, 14 Oct 2010 14:50:18 +0200 Subject: ALSA: HDA: Enable SKU quirks for Realtek Realtek have ways of specifying external amps and more via a special nid or via the Codec's subsystem ID, this is called "SKU". The computer manufacturer sometimes gets this wrong, so we need to be able to override or ignore the SKU customization value. Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index c41ac30ffc7..7b24a2d7293 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -301,6 +301,7 @@ struct alc_customize_define { unsigned int platform_type:1; unsigned int swap:1; unsigned int override:1; + unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ }; struct alc_spec { @@ -1464,6 +1465,11 @@ static void alc_init_auto_mic(struct hda_codec *codec) spec->unsol_event = alc_sku_unsol_event; } +/* Could be any non-zero and even value. When used as fixup, tells + * the driver to ignore any present sku defines. + */ +#define ALC_FIXUP_SKU_IGNORE (2) + static int alc_auto_parse_customize_define(struct hda_codec *codec) { unsigned int ass, tmp, i; @@ -1472,6 +1478,13 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec) spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ + if (spec->cdefine.fixup) { + ass = spec->cdefine.sku_cfg; + if (ass == ALC_FIXUP_SKU_IGNORE) + return -1; + goto do_sku; + } + ass = codec->subsystem_id & 0xffff; if (ass != codec->bus->pci->subsystem_device && (ass & 1)) goto do_sku; @@ -1539,6 +1552,13 @@ static int alc_subsystem_id(struct hda_codec *codec, unsigned nid; struct alc_spec *spec = codec->spec; + if (spec->cdefine.fixup) { + ass = spec->cdefine.sku_cfg; + if (ass == ALC_FIXUP_SKU_IGNORE) + return 0; + goto do_sku; + } + ass = codec->subsystem_id & 0xffff; if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) goto do_sku; @@ -1658,6 +1678,7 @@ struct alc_pincfg { }; struct alc_fixup { + unsigned int sku; const struct alc_pincfg *pins; const struct hda_verb *verbs; }; @@ -1668,12 +1689,22 @@ static void alc_pick_fixup(struct hda_codec *codec, int pre_init) { const struct alc_pincfg *cfg; + struct alc_spec *spec; quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk); if (!quirk) return; fix += quirk->value; cfg = fix->pins; + if (pre_init && fix->sku) { +#ifdef CONFIG_SND_DEBUG_VERBOSE + snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n", + codec->chip_name, quirk->name); +#endif + spec = codec->spec; + spec->cdefine.sku_cfg = fix->sku; + spec->cdefine.fixup = 1; + } if (pre_init && cfg) { #ifdef CONFIG_SND_DEBUG_VERBOSE snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n", @@ -10861,8 +10892,6 @@ static int patch_alc882(struct hda_codec *codec) codec->spec = spec; - alc_auto_parse_customize_define(codec); - switch (codec->vendor_id) { case 0x10ec0882: case 0x10ec0885: @@ -10890,6 +10919,8 @@ static int patch_alc882(struct hda_codec *codec) if (board_config == ALC882_AUTO) alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1); + alc_auto_parse_customize_define(codec); + if (board_config == ALC882_AUTO) { /* automatic parse from the BIOS config */ err = alc882_parse_auto_config(codec); -- cgit v1.2.3 From c3d226ab8b44fe31e5e6d5739eb353597cea4029 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Thu, 14 Oct 2010 15:42:08 +0200 Subject: ALSA: HDA: Apply SKU override for Acer aspire 7736z BugLink: http://launchpad.net/bugs/617647 The current SKU value disables playback, so ignore the SKU value. Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 7b24a2d7293..788ac4bbbba 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -10628,6 +10628,7 @@ static struct alc_config_preset alc882_presets[] = { enum { PINFIX_ABIT_AW9D_MAX, PINFIX_PB_M5210, + PINFIX_ACER_ASPIRE_7736, }; static const struct alc_fixup alc882_fixups[] = { @@ -10645,11 +10646,15 @@ static const struct alc_fixup alc882_fixups[] = { {} } }, + [PINFIX_ACER_ASPIRE_7736] = { + .sku = ALC_FIXUP_SKU_IGNORE, + }, }; static struct snd_pci_quirk alc882_fixup_tbl[] = { SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210), SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX), + SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736), {} }; -- cgit v1.2.3 From de8c85f7840e5e29629de95f5af24297fb325e0b Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 15 Oct 2010 10:32:50 +0200 Subject: ALSA: HDA: Sigmatel: work around incorrect master muting The HDA specification does not allow for a codec to mute itself just because the volume is reduced, so _of course_ somebody had to go and do it. This wouldn'\''t hurt too much when the volume is adjusted by hand, but programs like PA that try to set the volume automatically could inadvertently mute the output. To work around this, change the TLV dB information for the Master volume on all Sigmatel HDA codecs to indicate the the minimal volume setting actually mutes. Reported-by: Colin Guthrie Reported-by: "Alexander E. Patrakov" Tested-by: Colin Guthrie Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 3 +++ sound/pci/hda/hda_local.h | 14 ++++++++++---- sound/pci/hda/patch_sigmatel.c | 6 ++++-- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 053f827d2c2..8c933c8006f 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1831,6 +1831,7 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, hda_nid_t nid = get_amp_nid(kcontrol); int dir = get_amp_direction(kcontrol); unsigned int ofs = get_amp_offset(kcontrol); + bool min_mute = get_amp_min_mute(kcontrol); u32 caps, val1, val2; if (size < 4 * sizeof(unsigned int)) @@ -1841,6 +1842,8 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); val1 += ofs; val1 = ((int)val1) * ((int)val2); + if (min_mute) + val2 |= 0x10000; if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) return -EFAULT; if (put_user(2 * sizeof(unsigned int), _tlv + 1)) diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index d7dfa547e2d..46bbefe2e4a 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -38,10 +38,11 @@ */ #define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs) \ ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23)) +#define HDA_AMP_VAL_MIN_MUTE (1<<29) #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \ HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0) /* mono volume with index (index=0,1,...) (channel=1,2) */ -#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ +#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, dir, flags) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ .subdevice = HDA_SUBDEV_AMP_FLAG, \ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ @@ -51,16 +52,20 @@ .get = snd_hda_mixer_amp_volume_get, \ .put = snd_hda_mixer_amp_volume_put, \ .tlv = { .c = snd_hda_mixer_amp_tlv }, \ - .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) } + .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, dir) | flags } /* stereo volume with index */ #define HDA_CODEC_VOLUME_IDX(xname, xcidx, nid, xindex, direction) \ - HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction) + HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction, 0) /* mono volume */ #define HDA_CODEC_VOLUME_MONO(xname, nid, channel, xindex, direction) \ - HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction) + HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction, 0) /* stereo volume */ #define HDA_CODEC_VOLUME(xname, nid, xindex, direction) \ HDA_CODEC_VOLUME_MONO(xname, nid, 3, xindex, direction) +/* stereo volume with min=mute */ +#define HDA_CODEC_VOLUME_MIN_MUTE(xname, nid, xindex, direction) \ + HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, 3, xindex, direction, \ + HDA_AMP_VAL_MIN_MUTE) /* mono mute switch with index (index=0,1,...) (channel=1,2) */ #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ @@ -581,6 +586,7 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec, #define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) #define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f) +#define get_amp_min_mute(kc) (((kc)->private_value >> 29) & 0x1) /* * CEA Short Audio Descriptor data diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index d8dfafeab80..1a563a2fbbe 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -992,7 +992,7 @@ static struct hda_verb stac9205_core_init[] = { } static struct snd_kcontrol_new stac9200_mixer[] = { - HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xb, 0, HDA_OUTPUT), HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), @@ -1020,7 +1020,7 @@ static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { }; static struct snd_kcontrol_new stac925x_mixer[] = { - HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xe, 0, HDA_OUTPUT), HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), { } /* end */ }; @@ -1144,6 +1144,8 @@ static int stac92xx_build_controls(struct hda_codec *codec) HDA_OUTPUT, vmaster_tlv); /* correct volume offset */ vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; + /* minimum value is actually mute */ + vmaster_tlv[3] |= 0x1000; err = snd_hda_add_vmaster(codec, "Master Playback Volume", vmaster_tlv, slave_vols); if (err < 0) -- cgit v1.2.3 From c08d91695b2a3349254a62b60f03f7971bd90fa0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Sun, 17 Oct 2010 10:40:53 +0200 Subject: ALSA: tlv - Define numbers in sound/tlv.h Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 8c933c8006f..ee134a25092 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1843,7 +1843,7 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag, val1 += ofs; val1 = ((int)val1) * ((int)val2); if (min_mute) - val2 |= 0x10000; + val2 |= TLV_DB_SCALE_MUTE; if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) return -EFAULT; if (put_user(2 * sizeof(unsigned int), _tlv + 1)) -- cgit v1.2.3 From 1cc9e8f4c45999e6069f41521d9d391eeeccc3b3 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 18 Oct 2010 16:22:00 +0800 Subject: ALSA: hda - Fix codec muted after rebooting from Windows Windows may leave pin power-down registers set after reboot, and this resulted in muted output on Linux. Reset these registers at initialization properly. Signed-off-by: Charles Chin Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 1a563a2fbbe..7d70f8ca374 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -5334,6 +5334,9 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) if (spec == NULL) return -ENOMEM; + /* reset pin power-down; Windows may leave these bits after reboot */ + snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7EC, 0); + snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7ED, 0); codec->no_trigger_sense = 1; codec->spec = spec; spec->linear_tone_beep = 1; -- cgit v1.2.3 From bf1b022588eba78c990fd58fd2471cd92c2c5683 Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Thu, 21 Oct 2010 08:49:56 +0200 Subject: ALSA: hda - Add alc_init_jacks() call to other codecs Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 788ac4bbbba..2363f1893e8 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -11006,6 +11006,8 @@ static int patch_alc882(struct hda_codec *codec) codec->patch_ops = alc_patch_ops; if (board_config == ALC882_AUTO) spec->init_hook = alc882_auto_init; + + alc_init_jacks(codec); #ifdef CONFIG_SND_HDA_POWER_SAVE if (!spec->loopback.amplist) spec->loopback.amplist = alc882_loopbacks; @@ -12914,6 +12916,8 @@ static int patch_alc262(struct hda_codec *codec) codec->patch_ops = alc_patch_ops; if (board_config == ALC262_AUTO) spec->init_hook = alc262_auto_init; + + alc_init_jacks(codec); #ifdef CONFIG_SND_HDA_POWER_SAVE if (!spec->loopback.amplist) spec->loopback.amplist = alc262_loopbacks; @@ -13993,6 +13997,8 @@ static int patch_alc268(struct hda_codec *codec) if (board_config == ALC268_AUTO) spec->init_hook = alc268_auto_init; + alc_init_jacks(codec); + return 0; } @@ -14359,6 +14365,7 @@ static void alc269_speaker_automute(struct hda_codec *codec) HDA_AMP_MUTE, bits); snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1, HDA_AMP_MUTE, bits); + alc_report_jack(codec, nid); } /* unsolicited event for HP jack sensing */ @@ -14695,7 +14702,6 @@ static void alc269_auto_init(struct hda_codec *codec) alc269_auto_init_hp_out(codec); alc269_auto_init_analog_input(codec); alc_auto_init_digital(codec); - alc_init_jacks(codec); if (spec->unsol_event) alc_inithook(codec); } @@ -15128,6 +15134,8 @@ static int patch_alc269(struct hda_codec *codec) #endif if (board_config == ALC269_AUTO) spec->init_hook = alc269_auto_init; + + alc_init_jacks(codec); #ifdef CONFIG_SND_HDA_POWER_SAVE if (!spec->loopback.amplist) spec->loopback.amplist = alc269_loopbacks; @@ -19393,6 +19401,8 @@ static int patch_alc662(struct hda_codec *codec) alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0); } + alc_init_jacks(codec); + #ifdef CONFIG_SND_HDA_POWER_SAVE if (!spec->loopback.amplist) spec->loopback.amplist = alc662_loopbacks; -- cgit v1.2.3 From 693194f3b8af349a510604dffad9bdbbcf1c7db8 Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Thu, 21 Oct 2010 08:51:48 +0200 Subject: ALSA: hda - Fix codec rename rules for ALC662-compatible codecs Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 2363f1893e8..5f00589cb79 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -19309,6 +19309,7 @@ static int patch_alc662(struct hda_codec *codec) { struct alc_spec *spec; int err, board_config; + int coef; spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (!spec) @@ -19320,12 +19321,15 @@ static int patch_alc662(struct hda_codec *codec) alc_fix_pll_init(codec, 0x20, 0x04, 15); - if (alc_read_coef_idx(codec, 0) == 0x8020) + coef = alc_read_coef_idx(codec, 0); + if (coef == 0x8020 || coef == 0x8011) alc_codec_rename(codec, "ALC661"); - else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) && - codec->bus->pci->subsystem_vendor == 0x1025 && - spec->cdefine.platform_type == 1) + else if (coef & (1 << 14) && + codec->bus->pci->subsystem_vendor == 0x1025 && + spec->cdefine.platform_type == 1) alc_codec_rename(codec, "ALC272X"); + else if (coef == 0x4011) + alc_codec_rename(codec, "ALC656"); board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, alc662_models, -- cgit v1.2.3 From 24b55c69b66eb2a122842820ec14ab215fc8572f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 21 Oct 2010 08:55:13 +0200 Subject: ALSA: hda - Fix wrong SPDIF NID assignment for CA0110 The dig_out_nid field must take a digital-converter widget, but the current ca0110 parser passed the pin wrongly instead. Reported-by: Wai Yew CHAY Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_ca0110.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c index cca11fdd3d7..46c8bf48c31 100644 --- a/sound/pci/hda/patch_ca0110.c +++ b/sound/pci/hda/patch_ca0110.c @@ -489,7 +489,7 @@ static void parse_digital(struct hda_codec *codec) if (cfg->dig_outs && snd_hda_get_connections(codec, cfg->dig_out_pins[0], &spec->dig_out, 1) == 1) - spec->multiout.dig_out_nid = cfg->dig_out_pins[0]; + spec->multiout.dig_out_nid = spec->dig_out; } static int ca0110_parse_auto_config(struct hda_codec *codec) -- cgit v1.2.3 From 14d34f166c57e77e3d7f9bc8b43d349186d922c1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 21 Oct 2010 09:03:25 +0200 Subject: ALSA: hda - Add some workarounds for Creative IBG Creative HD-audio controller chips require some workarounds: - Additional delay before RIRB response - Set the initial RIRB counter to 0xc0 The latter seems to be done in general in Windows driver, so we may use this value later for all types if it's confirmed to work better. Reported-by: Wai Yew CHAY Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 5cbea85a645..ee445bc6e81 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -458,6 +458,7 @@ enum { AZX_DRIVER_ULI, AZX_DRIVER_NVIDIA, AZX_DRIVER_TERA, + AZX_DRIVER_CTX, AZX_DRIVER_GENERIC, AZX_NUM_DRIVERS, /* keep this as last entry */ }; @@ -473,6 +474,7 @@ static char *driver_short_names[] __devinitdata = { [AZX_DRIVER_ULI] = "HDA ULI M5461", [AZX_DRIVER_NVIDIA] = "HDA NVidia", [AZX_DRIVER_TERA] = "HDA Teradici", + [AZX_DRIVER_CTX] = "HDA Creative", [AZX_DRIVER_GENERIC] = "HD-Audio Generic", }; @@ -563,7 +565,10 @@ static void azx_init_cmd_io(struct azx *chip) /* reset the rirb hw write pointer */ azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST); /* set N=1, get RIRB response interrupt for new entry */ - azx_writew(chip, RINTCNT, 1); + if (chip->driver_type == AZX_DRIVER_CTX) + azx_writew(chip, RINTCNT, 0xc0); + else + azx_writew(chip, RINTCNT, 1); /* enable rirb dma and response irq */ azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); spin_unlock_irq(&chip->reg_lock); @@ -1136,8 +1141,11 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) /* clear rirb int */ status = azx_readb(chip, RIRBSTS); if (status & RIRB_INT_MASK) { - if (status & RIRB_INT_RESPONSE) + if (status & RIRB_INT_RESPONSE) { + if (chip->driver_type == AZX_DRIVER_CTX) + udelay(80); azx_update_rirb(chip); + } azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); } @@ -2784,10 +2792,10 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_ANY_ID), .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, .class_mask = 0xffffff, - .driver_data = AZX_DRIVER_GENERIC }, + .driver_data = AZX_DRIVER_CTX }, #else /* this entry seems still valid -- i.e. without emu20kx chip */ - { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC }, + { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_CTX }, #endif /* Vortex86MX */ { PCI_DEVICE(0x17f3, 0x3010), .driver_data = AZX_DRIVER_GENERIC }, -- cgit v1.2.3 From 00cd0bb7307970b745aefd2b3e1db929792b43bd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 21 Oct 2010 09:57:40 +0200 Subject: ALSA: hda - Apply ideapad quirk to Acer laptops with Cxt5066 Multiple Acer laptops with the SSID 1025:04xx require the quirk mode=ideapad, so let's use mask to apply to all these. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 80cc74bf77a..6361f752b5f 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3093,8 +3093,7 @@ static const char *cxt5066_models[CXT5066_MODELS] = { }; static struct snd_pci_quirk cxt5066_cfg_tbl[] = { - SND_PCI_QUIRK(0x1025, 0x040a, "Acer", CXT5066_IDEAPAD), - SND_PCI_QUIRK(0x1025, 0x043d, "Acer", CXT5066_IDEAPAD), + SND_PCI_QUIRK_MASK(0x1025, 0xff00, 0x0400, "Acer", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x1028, 0x02d8, "Dell Vostro", CXT5066_DELL_VOSTRO), SND_PCI_QUIRK(0x1028, 0x02f5, "Dell", CXT5066_DELL_LAPTOP), -- cgit v1.2.3 From a74ccea51d4314632a81d568d59bf885e5b09d93 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Fri, 22 Oct 2010 15:52:34 +0200 Subject: ALSA: hda - Fix wrong TLV mute bit for STAC/IDT codecs The bit value set for TLV mute was wrong in commit de8c85f7840e5e29629de95f5af24297fb325e0b, which resulted in bogus dB ranges that screw up PulseAudio. Corrected with the right constant. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 7d70f8ca374..7f487ab4dad 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "hda_codec.h" #include "hda_local.h" #include "hda_beep.h" @@ -1145,7 +1146,7 @@ static int stac92xx_build_controls(struct hda_codec *codec) /* correct volume offset */ vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset; /* minimum value is actually mute */ - vmaster_tlv[3] |= 0x1000; + vmaster_tlv[3] |= TLV_DB_SCALE_MUTE; err = snd_hda_add_vmaster(codec, "Master Playback Volume", vmaster_tlv, slave_vols); if (err < 0) -- cgit v1.2.3 From 62b7e5e09bcb854ff05e6ee1aa161f8283dc36ee Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 22 Oct 2010 17:15:47 +0200 Subject: ALSA: hda - Add workarounds for CT-IBG controllers Creative IBG controllers require the playback stream-tags to be started from 1, instead of capture+1. Otherwise the stream stalls. Reported-by: Wai Yew CHAY Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 5 ++++- sound/pci/hda/hda_intel.c | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index ee134a25092..13c1e7703c4 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1216,6 +1216,7 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, struct hda_codec *c; struct hda_cvt_setup *p; unsigned int oldval, newval; + int type; int i; if (!nid) @@ -1254,10 +1255,12 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, p->dirty = 0; /* make other inactive cvts with the same stream-tag dirty */ + type = get_wcaps_type(get_wcaps(codec, nid)); list_for_each_entry(c, &codec->bus->codec_list, list) { for (i = 0; i < c->cvt_setups.used; i++) { p = snd_array_elem(&c->cvt_setups, i); - if (!p->active && p->stream_tag == stream_tag) + if (!p->active && p->stream_tag == stream_tag && + get_wcaps_type(get_wcaps(codec, p->nid)) == type) p->dirty = 1; } } diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index ee445bc6e81..21aa9b0e28f 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1652,7 +1652,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) struct azx_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; struct snd_pcm_runtime *runtime = substream->runtime; - unsigned int bufsize, period_bytes, format_val; + unsigned int bufsize, period_bytes, format_val, stream_tag; int err; azx_stream_reset(chip, azx_dev); @@ -1694,7 +1694,12 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) else azx_dev->fifo_size = 0; - return snd_hda_codec_prepare(apcm->codec, hinfo, azx_dev->stream_tag, + stream_tag = azx_dev->stream_tag; + /* CA-IBG chips need the playback stream starting from 1 */ + if (chip->driver_type == AZX_DRIVER_CTX && + stream_tag > chip->capture_streams) + stream_tag -= chip->capture_streams; + return snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag, azx_dev->format_val, substream); } -- cgit v1.2.3 From 23156e8faed5df60364976bffea0711a4f38d88a Mon Sep 17 00:00:00 2001 From: Andy Owen Date: Sat, 23 Oct 2010 22:12:28 +1100 Subject: ALSA: ca0106 - add Sound Blaster 5.1vx info. Signed-off-by: Andy Owen Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 8e69620da20..6dc9a5d01af 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -239,6 +239,16 @@ static struct snd_ca0106_details ca0106_chip_details[] = { .gpio_type = 1, .i2c_adc = 1, .spi_dac = 1 } , + /* Sound Blaster 5.1vx + * Tested: Playback on front, rear, center/lfe speakers + * Not-Tested: Capture + */ + { .serial = 0x10041102, + .name = "Sound Blaster 5.1vx [SB1070]", + .gpio_type = 1, + .i2c_adc = 0, + .spi_dac = 1 + } , /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ /* SB0438 * CTRL:CA0106-DAT -- cgit v1.2.3 From 51630142ed7da31618c0aca8f2767824834e18a8 Mon Sep 17 00:00:00 2001 From: Andy Owen Date: Sat, 23 Oct 2010 22:12:29 +1100 Subject: ALSA: ca0106: Pull out dac powering routine into separate function. This is ground work for a future commit where cards (such as the Sound Blaster 5.1vx) have different mappings between dacs and channels. Signed-off-by: Andy Owen Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 6dc9a5d01af..22d2f6b6a05 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -514,6 +514,23 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) } } +static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id, + int power) +{ + if (chip->details->spi_dac) { + const int reg = spi_dacd_reg[channel_id]; + + if (power) + /* Power up */ + chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id]; + else + /* Power down */ + chip->spi_dac_reg[reg] |= spi_dacd_bit[channel_id]; + return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); + } + return 0; +} + /* open_playback callback */ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, int channel_id) @@ -553,12 +570,9 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr return err; snd_pcm_set_sync(substream); - if (chip->details->spi_dac && channel_id != PCM_FRONT_CHANNEL) { - const int reg = spi_dacd_reg[channel_id]; - - /* Power up dac */ - chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id]; - err = snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); + /* Front channel dac should already be on */ + if (channel_id != PCM_FRONT_CHANNEL) { + err = snd_ca0106_pcm_power_dac(chip, channel_id, 1); if (err < 0) return err; } @@ -578,13 +592,14 @@ static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream) restore_spdif_bits(chip, epcm->channel_id); - if (chip->details->spi_dac && epcm->channel_id != PCM_FRONT_CHANNEL) { - const int reg = spi_dacd_reg[epcm->channel_id]; - - /* Power down DAC */ - chip->spi_dac_reg[reg] |= spi_dacd_bit[epcm->channel_id]; - snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); + /* Front channel dac should stay on */ + if (epcm->channel_id != PCM_FRONT_CHANNEL) { + int err; + err = snd_ca0106_pcm_power_dac(chip, epcm->channel_id, 0); + if (err < 0) + return err; } + /* FIXME: maybe zero others */ return 0; } -- cgit v1.2.3 From 9bfd94132dd97b76af41024eb7e980a5cb41afee Mon Sep 17 00:00:00 2001 From: Andy Owen Date: Sat, 23 Oct 2010 22:12:30 +1100 Subject: ALSA: ca0106: Move enabling of front dac out of hardcoded setup sequence. Signed-off-by: Andy Owen Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sound/pci') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 22d2f6b6a05..46ae98d9cb4 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1385,7 +1385,7 @@ static unsigned int spi_dac_init[] = { SPI_REG(12, 0x00), SPI_REG(SPI_LDA4_REG, SPI_DA_BIT_0dB), SPI_REG(SPI_RDA4_REG, SPI_DA_BIT_0dB | SPI_DA_BIT_UPDATE), - SPI_REG(SPI_DACD4_REG, 0x00), + SPI_REG(SPI_DACD4_REG, SPI_DACD4_BIT), }; static unsigned int i2c_adc_init[][2] = { @@ -1576,6 +1576,9 @@ static void ca0106_init_chip(struct snd_ca0106 *chip, int resume) if (reg < ARRAY_SIZE(chip->spi_dac_reg)) chip->spi_dac_reg[reg] = spi_dac_init[n]; } + + /* Enable front dac only */ + snd_ca0106_pcm_power_dac(chip, PCM_FRONT_CHANNEL, 1); } } -- cgit v1.2.3 From 861391d3a037fab38020c741baffdb147e1c732a Mon Sep 17 00:00:00 2001 From: Andy Owen Date: Sat, 23 Oct 2010 22:12:31 +1100 Subject: ALSA: ca0106: Create a nice spot for mapping channels to dacs. This is to allow a future patch to have card specific mappings between dacs, which is required since the Sound Blaster 5.1vx seems to have a different mapping to what was previously used. Signed-off-by: Andy Owen Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_main.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 46ae98d9cb4..da910031edf 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -493,16 +493,18 @@ static void snd_ca0106_pcm_free_substream(struct snd_pcm_runtime *runtime) } static const int spi_dacd_reg[] = { - [PCM_FRONT_CHANNEL] = SPI_DACD4_REG, - [PCM_REAR_CHANNEL] = SPI_DACD0_REG, - [PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_REG, - [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_REG, + SPI_DACD0_REG, + SPI_DACD1_REG, + SPI_DACD2_REG, + 0, + SPI_DACD4_REG, }; static const int spi_dacd_bit[] = { - [PCM_FRONT_CHANNEL] = SPI_DACD4_BIT, - [PCM_REAR_CHANNEL] = SPI_DACD0_BIT, - [PCM_CENTER_LFE_CHANNEL]= SPI_DACD2_BIT, - [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_BIT, + SPI_DACD0_BIT, + SPI_DACD1_BIT, + SPI_DACD2_BIT, + 0, + SPI_DACD4_BIT, }; static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) @@ -514,18 +516,34 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx) } } +static int snd_ca0106_channel_dac(struct snd_ca0106_details *details, + int channel_id) +{ + switch (channel_id) { + case PCM_FRONT_CHANNEL: return 4; + case PCM_REAR_CHANNEL: return 0; + case PCM_CENTER_LFE_CHANNEL: return 2; + case PCM_UNKNOWN_CHANNEL: return 1; + } + snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n", channel_id); + return 0; +} + static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id, int power) { if (chip->details->spi_dac) { - const int reg = spi_dacd_reg[channel_id]; + const int dac = snd_ca0106_channel_dac(chip->details, + channel_id); + const int reg = spi_dacd_reg[dac]; + const int bit = spi_dacd_bit[dac]; if (power) /* Power up */ - chip->spi_dac_reg[reg] &= ~spi_dacd_bit[channel_id]; + chip->spi_dac_reg[reg] &= ~bit; else /* Power down */ - chip->spi_dac_reg[reg] |= spi_dacd_bit[channel_id]; + chip->spi_dac_reg[reg] |= bit; return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]); } return 0; -- cgit v1.2.3 From 6fef153afa8b25f81417488150e04db7c6b0b229 Mon Sep 17 00:00:00 2001 From: Andy Owen Date: Sat, 23 Oct 2010 22:12:32 +1100 Subject: ALSA: ca0106: Allow different sound cards to use different SPI channel mappings. Signed-off-by: Andy Owen Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106.h | 5 +++-- sound/pci/ca0106/ca0106_main.c | 26 ++++++++++++++++---------- sound/pci/ca0106/ca0106_mixer.c | 4 ++-- 3 files changed, 21 insertions(+), 14 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h index 14b8d9a91aa..f19c1107725 100644 --- a/sound/pci/ca0106/ca0106.h +++ b/sound/pci/ca0106/ca0106.h @@ -670,8 +670,9 @@ struct snd_ca0106_details { gpio_type = 2 -> shared side-out/line-in. */ int i2c_adc; /* with i2c_adc=1, the driver adds some capture volume controls, phone, mic, line-in and aux. */ - int spi_dac; /* spi_dac=1 adds the mute switch for each analog - output, front, rear, etc. */ + u16 spi_dac; /* spi_dac = 0 -> no spi interface for DACs + spi_dac = 0x + -> specifies DAC id for each channel pair. */ }; // definition of the chip-specific record diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index da910031edf..d2d12c08f93 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -227,7 +227,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = { .name = "Audigy SE [SB0570]", .gpio_type = 1, .i2c_adc = 1, - .spi_dac = 1 } , + .spi_dac = 0x4021 } , /* New Audigy LS. Has a different DAC. */ /* SB0570: * CTRL:CA0106-DAT @@ -238,7 +238,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = { .name = "Audigy SE OEM [SB0570a]", .gpio_type = 1, .i2c_adc = 1, - .spi_dac = 1 } , + .spi_dac = 0x4021 } , /* Sound Blaster 5.1vx * Tested: Playback on front, rear, center/lfe speakers * Not-Tested: Capture @@ -247,7 +247,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = { .name = "Sound Blaster 5.1vx [SB1070]", .gpio_type = 1, .i2c_adc = 0, - .spi_dac = 1 + .spi_dac = 0x0124 } , /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ /* SB0438 @@ -264,7 +264,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = { .name = "MSI K8N Diamond MB", .gpio_type = 2, .i2c_adc = 1, - .spi_dac = 1 } , + .spi_dac = 0x4021 } , /* Giga-byte GA-G1975X mobo * Novell bnc#395807 */ @@ -520,12 +520,18 @@ static int snd_ca0106_channel_dac(struct snd_ca0106_details *details, int channel_id) { switch (channel_id) { - case PCM_FRONT_CHANNEL: return 4; - case PCM_REAR_CHANNEL: return 0; - case PCM_CENTER_LFE_CHANNEL: return 2; - case PCM_UNKNOWN_CHANNEL: return 1; + case PCM_FRONT_CHANNEL: + return (details->spi_dac & 0xf000) >> (4 * 3); + case PCM_REAR_CHANNEL: + return (details->spi_dac & 0x0f00) >> (4 * 2); + case PCM_CENTER_LFE_CHANNEL: + return (details->spi_dac & 0x00f0) >> (4 * 1); + case PCM_UNKNOWN_CHANNEL: + return (details->spi_dac & 0x000f) >> (4 * 0); + default: + snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n", + channel_id); } - snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n", channel_id); return 0; } @@ -1582,7 +1588,7 @@ static void ca0106_init_chip(struct snd_ca0106 *chip, int resume) /* snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); */ } - if (chip->details->spi_dac == 1) { + if (chip->details->spi_dac) { /* The SB0570 use SPI to control DAC. */ int size, n; diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 85fd315d999..b522401b031 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -832,7 +832,7 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) if (err < 0) return err; } - if (emu->details->spi_dac == 1) + if (emu->details->spi_dac) ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls); /* Create virtual master controls */ @@ -845,7 +845,7 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) return err; add_slaves(card, vmaster, slave_vols); - if (emu->details->spi_dac == 1) { + if (emu->details->spi_dac) { vmaster = snd_ctl_make_virtual_master("Master Playback Switch", NULL); if (!vmaster) -- cgit v1.2.3 From 64e5310a249ba641ab6a00c6c1d61146d51b7984 Mon Sep 17 00:00:00 2001 From: Andy Owen Date: Sat, 23 Oct 2010 22:12:33 +1100 Subject: ALSA: ca0106: Use card specific dac id for mute controls. Signed-off-by: Andy Owen Signed-off-by: Takashi Iwai --- sound/pci/ca0106/ca0106_mixer.c | 91 +++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 22 deletions(-) (limited to 'sound/pci') diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index b522401b031..630aa499818 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -676,28 +676,65 @@ static struct snd_kcontrol_new snd_ca0106_volume_i2c_adc_ctls[] __devinitdata = I2C_VOLUME("Aux Capture Volume", 3), }; -#define SPI_SWITCH(xname,reg,bit) \ -{ \ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .info = spi_mute_info, \ - .get = spi_mute_get, \ - .put = spi_mute_put, \ - .private_value = (reg<spi_dac & 0xf000) >> (4 * 3); + break; + case PCM_REAR_CHANNEL: + spi_switch.name = "Analog Rear Playback Switch"; + dac_id = (details->spi_dac & 0x0f00) >> (4 * 2); + break; + case PCM_CENTER_LFE_CHANNEL: + spi_switch.name = "Analog Center/LFE Playback Switch"; + dac_id = (details->spi_dac & 0x00f0) >> (4 * 1); + break; + case PCM_UNKNOWN_CHANNEL: + spi_switch.name = "Analog Side Playback Switch"; + dac_id = (details->spi_dac & 0x000f) >> (4 * 0); + break; + default: + /* Unused channel */ + spi_switch.name = NULL; + dac_id = 0; + } + reg = spi_dmute_reg[dac_id]; + bit = spi_dmute_bit[dac_id]; + + spi_switch.private_value = (reg << SPI_REG_SHIFT) | bit; + + return spi_switch; +} + static int __devinit remove_ctl(struct snd_card *card, const char *name) { struct snd_ctl_elem_id id; @@ -832,8 +869,18 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) if (err < 0) return err; } - if (emu->details->spi_dac) - ADD_CTLS(emu, snd_ca0106_volume_spi_dac_ctls); + if (emu->details->spi_dac) { + int i; + for (i = 0;; i++) { + struct snd_kcontrol_new ctl; + ctl = snd_ca0106_volume_spi_dac_ctl(emu->details, i); + if (!ctl.name) + break; + err = snd_ctl_add(card, snd_ctl_new1(&ctl, emu)); + if (err < 0) + return err; + } + } /* Create virtual master controls */ vmaster = snd_ctl_make_virtual_master("Master Playback Volume", -- cgit v1.2.3 From 0e7adbe263f89ea2ef15b5af5e80a812b2a85025 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 25 Oct 2010 10:37:11 +0200 Subject: ALSA: hda - Disable sticky PCM stream assignment for AD codecs The sticky PCM stream assignment introduced in 2.6.36 kernel seems causing problems on AD codecs. At some time later, the streaming no longer works by unknown reason. A simple workaround is to disable sticky-assignment for these codecs. Tested-by: Vasily Khoruzhick Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 3 +++ sound/pci/hda/hda_codec.h | 1 + sound/pci/hda/patch_analog.c | 7 +++++++ 3 files changed, 11 insertions(+) (limited to 'sound/pci') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 13c1e7703c4..644e3f14f8c 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1284,6 +1284,9 @@ void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid, if (!nid) return; + if (codec->no_sticky_stream) + do_now = 1; + snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); p = get_hda_cvt_setup(codec, nid); if (p) { diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index ebf8eb02e3c..fdf8d44f8b6 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -850,6 +850,7 @@ struct hda_codec { unsigned int pin_amp_workaround:1; /* pin out-amp takes index * (e.g. Conexant codecs) */ + unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */ unsigned int pins_shutup:1; /* pins are shut up */ unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */ #ifdef CONFIG_SND_HDA_POWER_SAVE diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 507523d5ed4..f7ff3f7ccb8 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -1276,6 +1276,7 @@ static int patch_ad1986a(struct hda_codec *codec) spec->multiout.no_share_stream = 1; codec->no_trigger_sense = 1; + codec->no_sticky_stream = 1; return 0; } @@ -1463,6 +1464,7 @@ static int patch_ad1983(struct hda_codec *codec) codec->patch_ops = ad198x_patch_ops; codec->no_trigger_sense = 1; + codec->no_sticky_stream = 1; return 0; } @@ -1917,6 +1919,7 @@ static int patch_ad1981(struct hda_codec *codec) } codec->no_trigger_sense = 1; + codec->no_sticky_stream = 1; return 0; } @@ -3236,6 +3239,7 @@ static int patch_ad1988(struct hda_codec *codec) spec->vmaster_nid = 0x04; codec->no_trigger_sense = 1; + codec->no_sticky_stream = 1; return 0; } @@ -3450,6 +3454,7 @@ static int patch_ad1884(struct hda_codec *codec) codec->patch_ops = ad198x_patch_ops; codec->no_trigger_sense = 1; + codec->no_sticky_stream = 1; return 0; } @@ -4423,6 +4428,7 @@ static int patch_ad1884a(struct hda_codec *codec) } codec->no_trigger_sense = 1; + codec->no_sticky_stream = 1; return 0; } @@ -4762,6 +4768,7 @@ static int patch_ad1882(struct hda_codec *codec) } codec->no_trigger_sense = 1; + codec->no_sticky_stream = 1; return 0; } -- cgit v1.2.3