Lines Matching full:codec
3 * HD audio interface patch for Conexant HDA audio codec
74 static int cx_auto_parse_beep(struct hda_codec *codec)
76 struct conexant_spec *spec = codec->spec;
79 for_each_hda_codec_node(nid, codec)
80 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP)
85 #define cx_auto_parse_beep(codec) 0
93 static void cx_auto_parse_eapd(struct hda_codec *codec)
95 struct conexant_spec *spec = codec->spec;
98 for_each_hda_codec_node(nid, codec) {
99 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
101 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
118 static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
123 if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
124 snd_hda_codec_write(codec, pins[i], 0,
133 struct hda_codec *codec = private_data;
134 struct conexant_spec *spec = codec->spec;
136 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled);
143 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
144 struct conexant_spec *spec = codec->spec;
146 snd_hda_codec_write(codec, spec->mute_led_eapd, 0,
152 static void cxt_init_gpio_led(struct hda_codec *codec)
154 struct conexant_spec *spec = codec->spec;
158 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
160 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
162 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
167 static void cx_fixup_headset_recog(struct hda_codec *codec)
173 snd_hda_codec_write(codec, 0x1c, 0, 0x320, 0x010);
177 snd_hda_codec_write(codec, 0x1c, 0, 0x3b0, 0xe10);
179 mic_persent = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
182 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
185 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
188 static int cx_auto_init(struct hda_codec *codec)
190 struct conexant_spec *spec = codec->spec;
191 snd_hda_gen_init(codec);
193 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
195 cxt_init_gpio_led(codec);
196 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
199 cx_fixup_headset_recog(codec);
204 static void cx_auto_shutdown(struct hda_codec *codec)
206 struct conexant_spec *spec = codec->spec;
208 /* Turn the problematic codec into D3 to avoid spurious noises
210 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
213 static void cx_auto_free(struct hda_codec *codec)
215 cx_auto_shutdown(codec);
216 snd_hda_gen_free(codec);
219 static void cx_process_headset_plugin(struct hda_codec *codec)
226 val = snd_hda_codec_read(codec, 0x1c, 0, 0xca0, 0x0);
228 codec_dbg(codec, "headset type detect done!\n");
234 val = snd_hda_codec_read(codec, 0x1c, 0, 0xcb0, 0x0);
236 codec_dbg(codec, "headset plugin, type is CTIA\n");
237 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
239 codec_dbg(codec, "headset plugin, type is OMTP\n");
240 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
242 codec_dbg(codec, "headphone plugin\n");
246 static void cx_update_headset_mic_vref(struct hda_codec *codec, struct hda_jack_callback *event)
254 mic_present = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
256 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
258 cx_process_headset_plugin(codec);
262 static int cx_auto_suspend(struct hda_codec *codec)
264 cx_auto_shutdown(codec);
320 static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
323 struct conexant_spec *spec = codec->spec;
328 static void cxt_fixup_update_pinctl(struct hda_codec *codec,
333 * This is the value stored in the codec register after
336 snd_hda_set_pin_ctl_cache(codec, 0x1d, AC_PINCTL_HP_EN);
340 static void cxt5066_increase_mic_boost(struct hda_codec *codec,
346 snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT,
353 static void cxt_update_headset_mode(struct hda_codec *codec)
355 /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */
358 struct conexant_spec *spec = codec->spec;
370 snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */
373 snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */
374 spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]);
377 snd_hda_gen_update_outputs(codec);
380 static void cxt_update_headset_mode_hook(struct hda_codec *codec,
384 cxt_update_headset_mode(codec);
387 static void cxt_fixup_headphone_mic(struct hda_codec *codec,
390 struct conexant_spec *spec = codec->spec;
395 snd_hdac_regmap_add_vendor_verb(&codec->core, 0x410);
403 cxt_update_headset_mode(codec);
408 static void cxt_fixup_headset_mic(struct hda_codec *codec,
411 struct conexant_spec *spec = codec->spec;
429 #define update_mic_pin(codec, nid, val) \
430 snd_hda_codec_write_cache(codec, nid, 0, \
442 static void olpc_xo_update_mic_boost(struct hda_codec *codec)
444 struct conexant_spec *spec = codec->spec;
451 val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0);
452 snd_hda_codec_write(codec, 0x17, 0,
457 static void olpc_xo_update_mic_pins(struct hda_codec *codec)
459 struct conexant_spec *spec = codec->spec;
470 update_mic_pin(codec, 0x1e, 0);
471 snd_hda_activate_path(codec, spec->dc_mode_path, false, false);
480 update_mic_pin(codec, 0x1a, spec->recording ?
481 snd_hda_codec_get_pin_target(codec, 0x1a) : 0);
482 update_mic_pin(codec, 0x1b, spec->recording ?
483 snd_hda_codec_get_pin_target(codec, 0x1b) : 0);
485 path = snd_hda_get_path_from_idx(codec, cur_input);
487 snd_hda_activate_path(codec, path, true, false);
490 path = snd_hda_get_path_from_idx(codec, cur_input);
492 snd_hda_activate_path(codec, path, false, false);
503 update_mic_pin(codec, 0x1a, val);
504 update_mic_pin(codec, 0x1b, 0);
506 update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0);
507 snd_hda_activate_path(codec, spec->dc_mode_path, true, false);
512 static void olpc_xo_automic(struct hda_codec *codec,
515 struct conexant_spec *spec = codec->spec;
519 snd_hda_gen_mic_autoswitch(codec, jack);
520 olpc_xo_update_mic_pins(codec);
522 olpc_xo_update_mic_boost(codec);
527 struct hda_codec *codec,
531 struct conexant_spec *spec = codec->spec;
539 olpc_xo_update_mic_pins(codec);
543 olpc_xo_update_mic_pins(codec);
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 struct conexant_spec *spec = codec->spec;
560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
561 struct conexant_spec *spec = codec->spec;
568 olpc_xo_update_mic_pins(codec);
569 olpc_xo_update_mic_boost(codec);
576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
577 struct conexant_spec *spec = codec->spec;
591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
592 struct conexant_spec *spec = codec->spec;
604 olpc_xo_update_mic_pins(codec);
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct conexant_spec *spec = codec->spec;
636 olpc_xo_update_mic_boost(codec);
640 static void cxt_fixup_olpc_xo(struct hda_codec *codec,
643 struct conexant_spec *spec = codec->spec;
652 spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0);
654 snd_hda_add_new_ctls(codec, olpc_xo_mixers);
658 * with the DC input range of the codec.
660 snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50);
671 static void cxt_fixup_mute_led_eapd(struct hda_codec *codec,
674 struct conexant_spec *spec = codec->spec;
679 snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led);
687 static void cxt_fixup_cap_mix_amp(struct hda_codec *codec,
690 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
701 static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec,
704 snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
711 static void cxt_fixup_hp_gate_mic_jack(struct hda_codec *codec,
719 snd_hda_jack_set_gating_jack(codec, 0x19, 0x16);
723 static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int mask,
726 struct conexant_spec *spec = codec->spec;
736 codec_dbg(codec, "mask:%d enabled:%d gpio_led:%d\n",
739 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
747 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
748 struct conexant_spec *spec = codec->spec;
750 cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, brightness);
758 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
759 struct conexant_spec *spec = codec->spec;
761 cxt_update_gpio_led(codec, spec->gpio_mic_led_mask, brightness);
765 static void cxt_setup_mute_led(struct hda_codec *codec,
768 struct conexant_spec *spec = codec->spec;
773 snd_hda_gen_add_mute_led_cdev(codec, cxt_gpio_mute_update);
777 snd_hda_gen_add_micmute_led_cdev(codec, cxt_gpio_micmute_update);
782 static void cxt_setup_gpio_unmute(struct hda_codec *codec,
787 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
788 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, gpio_mute_mask);
789 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, gpio_mute_mask);
790 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_STICKY_MASK, 0);
794 static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
798 cxt_setup_mute_led(codec, 0x01, 0x02);
801 static void cxt_fixup_hp_zbook_mute_led(struct hda_codec *codec,
805 cxt_setup_mute_led(codec, 0x10, 0x20);
808 static void cxt_fixup_hp_a_u(struct hda_codec *codec,
814 cxt_setup_gpio_unmute(codec, 0x2);
1158 static void add_cx5051_fake_mutes(struct hda_codec *codec)
1160 struct conexant_spec *spec = codec->spec;
1167 snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT,
1169 query_amp_caps(codec, *p, HDA_OUTPUT));
1173 static int patch_conexant_auto(struct hda_codec *codec)
1178 codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name);
1184 codec->spec = spec;
1185 codec->patch_ops = cx_auto_patch_ops;
1188 switch (codec->core.vendor_id) {
1192 snd_hda_jack_detect_enable_callback(codec, 0x19, cx_update_headset_mic_vref);
1196 cx_auto_parse_eapd(codec);
1199 switch (codec->core.vendor_id) {
1201 codec->single_adc_amp = 1;
1204 snd_hda_pick_fixup(codec, cxt5045_fixup_models,
1208 codec->pin_amp_workaround = 1;
1211 snd_hda_pick_fixup(codec, cxt5047_fixup_models,
1215 add_cx5051_fake_mutes(codec);
1216 codec->pin_amp_workaround = 1;
1217 snd_hda_pick_fixup(codec, cxt5051_fixup_models,
1221 codec->pin_amp_workaround = 1;
1224 snd_hda_pick_fixup(codec, cxt5066_fixup_models,
1228 codec->power_save_node = 1;
1231 codec->pin_amp_workaround = 1;
1232 snd_hda_pick_fixup(codec, cxt5066_fixup_models,
1240 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1242 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL,
1247 err = cx_auto_parse_beep(codec);
1251 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
1259 if (!codec->bus->core.sync_write) {
1260 codec_info(codec,
1262 codec->bus->core.sync_write = 1;
1263 codec->bus->allow_bus_reset = 1;
1266 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1271 cx_auto_free(codec);
1317 MODULE_DESCRIPTION("Conexant HD-audio codec");