From c3e68fad88143fd1fe8fe640207fb19c0f087dbc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 16 Aug 2010 10:15:57 +0200 Subject: ALSA: hda - Add quirk for Dell Vostro 1220 model=dell-vostro is needed for Dell Vostro 1220 with Coexnat 5067. Reference: Novell bnc#631066 https://bugzilla.novell.com/show_bug.cgi?id=631066 Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 31b5d9eeba68..c424952a734e 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3049,6 +3049,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(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), SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5), -- cgit v1.2.3-59-g8ed1b From 6f0ef6ea1d11ef242de584e345355b0de756fcb2 Mon Sep 17 00:00:00 2001 From: Jerone Young Date: Mon, 23 Aug 2010 08:34:36 +0200 Subject: ALSA: hda - Add support for Lenovo S10-3t This patch adds quirk for the Lenovo S10-3t so the headphone & microphone jacks will now work. Signed-off-by: Jerone Young Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index c424952a734e..5cdb80edbd7f 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3059,6 +3059,7 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo Thinkpad", CXT5066_THINKPAD), SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo G series", CXT5066_IDEAPAD), + SND_PCI_QUIRK(0x17aa, 0x390a, "Lenovo S10-3t", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x3938, "Lenovo G series (AMD)", CXT5066_IDEAPAD), SND_PCI_QUIRK(0x17aa, 0x3a0d, "ideapad", CXT5066_IDEAPAD), {} -- cgit v1.2.3-59-g8ed1b From 048e78a5bc22c27410cb5ca9680c3c7ac400607f Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Thu, 2 Sep 2010 08:35:47 +0200 Subject: ALSA: hda - Add a new hp-laptop model for Conexant 5066, tested on HP G60 This new model adds the following functionality to HP G60: - Automute of internal speakers - Autoswitch of internal/external mics - Remove SPDIF not physically present BugLink: http://launchpad.net/bugs/587388 Cc: stable@kernel.org Signed-off-by: David Henningsson Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/HD-Audio-Models.txt | 1 + sound/pci/hda/patch_conexant.c | 57 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'sound/pci/hda/patch_conexant.c') diff --git a/Documentation/sound/alsa/HD-Audio-Models.txt b/Documentation/sound/alsa/HD-Audio-Models.txt index ce46fa1e643e..37c6aad5e590 100644 --- a/Documentation/sound/alsa/HD-Audio-Models.txt +++ b/Documentation/sound/alsa/HD-Audio-Models.txt @@ -296,6 +296,7 @@ Conexant 5051 Conexant 5066 ============= laptop Basic Laptop config (default) + hp-laptop HP laptops, e g G60 dell-laptop Dell laptops dell-vostro Dell Vostro olpc-xo-1_5 OLPC XO 1.5 diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 5cdb80edbd7f..4f0619908a30 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -116,6 +116,7 @@ struct conexant_spec { unsigned int dell_vostro:1; unsigned int ideapad:1; unsigned int thinkpad:1; + unsigned int hp_laptop:1; unsigned int ext_mic_present; unsigned int recording; @@ -2299,6 +2300,18 @@ static void cxt5066_ideapad_automic(struct hda_codec *codec) } } +/* toggle input of built-in digital mic and mic jack appropriately */ +static void cxt5066_hp_laptop_automic(struct hda_codec *codec) +{ + unsigned int present; + + present = snd_hda_jack_detect(codec, 0x1b); + snd_printdd("CXT5066: external microphone present=%d\n", present); + snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, + present ? 1 : 3); +} + + /* toggle input of built-in digital mic and mic jack appropriately order is: external mic -> dock mic -> interal mic */ static void cxt5066_thinkpad_automic(struct hda_codec *codec) @@ -2407,6 +2420,20 @@ static void cxt5066_ideapad_event(struct hda_codec *codec, unsigned int res) } } +/* unsolicited event for jack sensing */ +static void cxt5066_hp_laptop_event(struct hda_codec *codec, unsigned int res) +{ + snd_printdd("CXT5066_hp_laptop: unsol event %x (%x)\n", res, res >> 26); + switch (res >> 26) { + case CONEXANT_HP_EVENT: + cxt5066_hp_automute(codec); + break; + case CONEXANT_MIC_EVENT: + cxt5066_hp_laptop_automic(codec); + break; + } +} + /* unsolicited event for jack sensing */ static void cxt5066_thinkpad_event(struct hda_codec *codec, unsigned int res) { @@ -2989,6 +3016,14 @@ static struct hda_verb cxt5066_init_verbs_portd_lo[] = { { } /* end */ }; + +static struct hda_verb cxt5066_init_verbs_hp_laptop[] = { + {0x14, AC_VERB_SET_CONNECT_SEL, 0x0}, + {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT}, + {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT}, + { } /* end */ +}; + /* initialize jack-sensing, too */ static int cxt5066_init(struct hda_codec *codec) { @@ -3004,6 +3039,8 @@ static int cxt5066_init(struct hda_codec *codec) cxt5066_ideapad_automic(codec); else if (spec->thinkpad) cxt5066_thinkpad_automic(codec); + else if (spec->hp_laptop) + cxt5066_hp_laptop_automic(codec); } cxt5066_set_mic_boost(codec); return 0; @@ -3031,6 +3068,7 @@ enum { CXT5066_DELL_VOSTO, /* Dell Vostro 1015i */ CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ + CXT5066_HP_LAPTOP, /* HP Laptop */ CXT5066_MODELS }; @@ -3041,6 +3079,7 @@ static const char *cxt5066_models[CXT5066_MODELS] = { [CXT5066_DELL_VOSTO] = "dell-vostro", [CXT5066_IDEAPAD] = "ideapad", [CXT5066_THINKPAD] = "thinkpad", + [CXT5066_HP_LAPTOP] = "hp-laptop", }; static struct snd_pci_quirk cxt5066_cfg_tbl[] = { @@ -3052,6 +3091,7 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { 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), + SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 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(0x17aa, 0x21b2, "Thinkpad X100e", CXT5066_IDEAPAD), @@ -3116,6 +3156,23 @@ static int patch_cxt5066(struct hda_codec *codec) spec->num_init_verbs++; spec->dell_automute = 1; break; + case CXT5066_HP_LAPTOP: + codec->patch_ops.init = cxt5066_init; + codec->patch_ops.unsol_event = cxt5066_hp_laptop_event; + spec->init_verbs[spec->num_init_verbs] = + cxt5066_init_verbs_hp_laptop; + spec->num_init_verbs++; + spec->hp_laptop = 1; + spec->mixers[spec->num_mixers++] = cxt5066_mixer_master; + spec->mixers[spec->num_mixers++] = cxt5066_mixers; + /* no S/PDIF out */ + spec->multiout.dig_out_nid = 0; + /* input source automatically selected */ + spec->input_mux = NULL; + spec->port_d_mode = 0; + spec->mic_boost = 3; /* default 30dB gain */ + break; + case CXT5066_OLPC_XO_1_5: codec->patch_ops.init = cxt5066_olpc_init; codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event; -- cgit v1.2.3-59-g8ed1b From 4d155641c81203440da64c4633b4efaab75f63b3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 7 Sep 2010 11:58:30 +0200 Subject: ALSA: hda - Add quirk for Lenovo T400s Lenovo T400s requires the quirk to make automatic HP/mic switching working. Reported-by: Frank Becker Cc: Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 4f0619908a30..71f9d6475b09 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3094,6 +3094,7 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 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(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), SND_PCI_QUIRK(0x17aa, 0x21b4, "Thinkpad Edge", CXT5066_IDEAPAD), -- cgit v1.2.3-59-g8ed1b From 2ca9cac965e81da4b74f2dcec4b87ebfd106b357 Mon Sep 17 00:00:00 2001 From: Anisse Astier Date: Fri, 10 Sep 2010 15:47:55 +0200 Subject: ALSA: hda - Add quirk for Toshiba C650D using a Conexant CX20585 Add a quirk for laptop Toshiba Satellite C650D to have proper external HP and external Mic support. Signed-off-by: Anisse Astier Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sound/pci/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 71f9d6475b09..972e7c453b3d 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -3092,6 +3092,7 @@ static struct snd_pci_quirk cxt5066_cfg_tbl[] = { SND_PCI_QUIRK(0x1028, 0x0402, "Dell Vostro", CXT5066_DELL_VOSTO), 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(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), -- cgit v1.2.3-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 972e7c453b3d..7eee0ff65ac9 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-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 7eee0ff65ac9..7e22ed14ae8d 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-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 7e22ed14ae8d..a12a9f6f795a 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-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index a12a9f6f795a..e501a85b5612 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-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 9f668efbe420..e15a75751f57 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 6943efc78f66..d7dfa547e2d8 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 ae75283a5583..483c3f2d8d39 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 e501a85b5612..09d573c59bef 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 5df88798895b..6045f281b225 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 7eb359a030de..6bfbc2fe46ed 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-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 09d573c59bef..a6c68cb06ddb 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-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index a6c68cb06ddb..80cc74bf77a0 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-59-g8ed1b 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/hda/patch_conexant.c') diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 80cc74bf77a0..6361f752b5f3 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-59-g8ed1b