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