Lines Matching refs:codec

3  * HD audio interface patch for Conexant HDA audio codec
81 static int cx_auto_parse_beep(struct hda_codec *codec)
83 struct conexant_spec *spec = codec->spec;
86 for_each_hda_codec_node(nid, codec)
87 if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_BEEP)
92 #define cx_auto_parse_beep(codec) 0
100 static void cx_auto_parse_eapd(struct hda_codec *codec)
102 struct conexant_spec *spec = codec->spec;
105 for_each_hda_codec_node(nid, codec) {
106 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
108 if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD))
125 static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
130 if (snd_hda_query_pin_caps(codec, pins[i]) & AC_PINCAP_EAPD)
131 snd_hda_codec_write(codec, pins[i], 0,
140 struct hda_codec *codec = private_data;
141 struct conexant_spec *spec = codec->spec;
143 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, enabled);
150 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
151 struct conexant_spec *spec = codec->spec;
153 snd_hda_codec_write(codec, spec->mute_led_eapd, 0,
159 static void cxt_init_gpio_led(struct hda_codec *codec)
161 struct conexant_spec *spec = codec->spec;
165 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
167 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
169 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
174 static void cx_fixup_headset_recog(struct hda_codec *codec)
180 snd_hda_codec_write(codec, 0x1c, 0, 0x320, 0x010);
184 snd_hda_codec_write(codec, 0x1c, 0, 0x3b0, 0xe10);
186 mic_persent = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0);
189 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
192 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
195 static int cx_auto_init(struct hda_codec *codec)
197 struct conexant_spec *spec = codec->spec;
198 snd_hda_gen_init(codec);
200 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
202 cxt_init_gpio_led(codec);
203 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
206 cx_fixup_headset_recog(codec);
211 static void cx_auto_shutdown(struct hda_codec *codec)
213 struct conexant_spec *spec = codec->spec;
215 /* Turn the problematic codec into D3 to avoid spurious noises
217 cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, false);
220 static void cx_auto_free(struct hda_codec *codec)
222 cx_auto_shutdown(codec);
223 snd_hda_gen_free(codec);
226 static void cx_process_headset_plugin(struct hda_codec *codec)
233 val = snd_hda_codec_read(codec, 0x1c, 0, 0xca0, 0x0);
235 codec_dbg(codec, "headset type detect done!\n");
241 val = snd_hda_codec_read(codec, 0x1c, 0, 0xcb0, 0x0);
243 codec_dbg(codec, "headset plugin, type is CTIA\n");
244 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
246 codec_dbg(codec, "headset plugin, type is OMTP\n");
247 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24);
249 codec_dbg(codec, "headphone plugin\n");
253 static void cx_update_headset_mic_vref(struct hda_codec *codec, unsigned int res)
256 struct conexant_spec *spec = codec->spec;
262 phone_tag = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0);
263 mic_tag = snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_UNSOLICITED_RESPONSE, 0x0);
266 phone_present = snd_hda_codec_read(codec, 0x16, 0, AC_VERB_GET_PIN_SENSE, 0x0);
269 snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20);
275 mic_persent = snd_hda_codec_read(codec, 0x19, 0,
280 cx_process_headset_plugin(codec);
287 static void cx_jack_unsol_event(struct hda_codec *codec, unsigned int res)
289 struct conexant_spec *spec = codec->spec;
292 cx_update_headset_mic_vref(codec, res);
294 snd_hda_jack_unsol_event(codec, res);
298 static int cx_auto_suspend(struct hda_codec *codec)
300 cx_auto_shutdown(codec);
353 static void cxt_fixup_stereo_dmic(struct hda_codec *codec,
356 struct conexant_spec *spec = codec->spec;
360 static void cxt5066_increase_mic_boost(struct hda_codec *codec,
366 snd_hda_override_amp_caps(codec, 0x17, HDA_OUTPUT,
373 static void cxt_update_headset_mode(struct hda_codec *codec)
375 /* The verbs used in this function were tested on a Conexant CX20751/2 codec. */
378 struct conexant_spec *spec = codec->spec;
390 snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x7c); /* enable merged mode for analog int-mic */
393 snd_hda_codec_write_cache(codec, 0x1c, 0, 0x410, 0x54); /* disable merged mode for analog int-mic */
394 spec->gen.hp_jack_present = snd_hda_jack_detect(codec, spec->gen.autocfg.hp_pins[0]);
397 snd_hda_gen_update_outputs(codec);
400 static void cxt_update_headset_mode_hook(struct hda_codec *codec,
404 cxt_update_headset_mode(codec);
407 static void cxt_fixup_headphone_mic(struct hda_codec *codec,
410 struct conexant_spec *spec = codec->spec;
415 snd_hdac_regmap_add_vendor_verb(&codec->core, 0x410);
423 cxt_update_headset_mode(codec);
428 static void cxt_fixup_headset_mic(struct hda_codec *codec,
431 struct conexant_spec *spec = codec->spec;
449 #define update_mic_pin(codec, nid, val) \
450 snd_hda_codec_write_cache(codec, nid, 0, \
462 static void olpc_xo_update_mic_boost(struct hda_codec *codec)
464 struct conexant_spec *spec = codec->spec;
471 val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0);
472 snd_hda_codec_write(codec, 0x17, 0,
477 static void olpc_xo_update_mic_pins(struct hda_codec *codec)
479 struct conexant_spec *spec = codec->spec;
490 update_mic_pin(codec, 0x1e, 0);
491 snd_hda_activate_path(codec, spec->dc_mode_path, false, false);
500 update_mic_pin(codec, 0x1a, spec->recording ?
501 snd_hda_codec_get_pin_target(codec, 0x1a) : 0);
502 update_mic_pin(codec, 0x1b, spec->recording ?
503 snd_hda_codec_get_pin_target(codec, 0x1b) : 0);
505 path = snd_hda_get_path_from_idx(codec, cur_input);
507 snd_hda_activate_path(codec, path, true, false);
510 path = snd_hda_get_path_from_idx(codec, cur_input);
512 snd_hda_activate_path(codec, path, false, false);
523 update_mic_pin(codec, 0x1a, val);
524 update_mic_pin(codec, 0x1b, 0);
526 update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0);
527 snd_hda_activate_path(codec, spec->dc_mode_path, true, false);
532 static void olpc_xo_automic(struct hda_codec *codec,
535 struct conexant_spec *spec = codec->spec;
539 snd_hda_gen_mic_autoswitch(codec, jack);
540 olpc_xo_update_mic_pins(codec);
542 olpc_xo_update_mic_boost(codec);
547 struct hda_codec *codec,
551 struct conexant_spec *spec = codec->spec;
559 olpc_xo_update_mic_pins(codec);
563 olpc_xo_update_mic_pins(codec);
571 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
572 struct conexant_spec *spec = codec->spec;
580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
581 struct conexant_spec *spec = codec->spec;
588 olpc_xo_update_mic_pins(codec);
589 olpc_xo_update_mic_boost(codec);
596 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
597 struct conexant_spec *spec = codec->spec;
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct conexant_spec *spec = codec->spec;
624 olpc_xo_update_mic_pins(codec);
652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
653 struct conexant_spec *spec = codec->spec;
656 olpc_xo_update_mic_boost(codec);
660 static void cxt_fixup_olpc_xo(struct hda_codec *codec,
663 struct conexant_spec *spec = codec->spec;
672 spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0);
674 snd_hda_add_new_ctls(codec, olpc_xo_mixers);
678 * with the DC input range of the codec.
680 snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50);
691 static void cxt_fixup_mute_led_eapd(struct hda_codec *codec,
694 struct conexant_spec *spec = codec->spec;
699 snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led);
707 static void cxt_fixup_cap_mix_amp(struct hda_codec *codec,
710 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
721 static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec,
724 snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
731 static void cxt_fixup_hp_gate_mic_jack(struct hda_codec *codec,
739 snd_hda_jack_set_gating_jack(codec, 0x19, 0x16);
743 static void cxt_update_gpio_led(struct hda_codec *codec, unsigned int mask,
746 struct conexant_spec *spec = codec->spec;
756 codec_dbg(codec, "mask:%d enabled:%d gpio_led:%d\n",
759 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
767 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
768 struct conexant_spec *spec = codec->spec;
770 cxt_update_gpio_led(codec, spec->gpio_mute_led_mask, brightness);
778 struct hda_codec *codec = dev_to_hda_codec(led_cdev->dev->parent);
779 struct conexant_spec *spec = codec->spec;
781 cxt_update_gpio_led(codec, spec->gpio_mic_led_mask, brightness);
785 static void cxt_setup_mute_led(struct hda_codec *codec,
788 struct conexant_spec *spec = codec->spec;
793 snd_hda_gen_add_mute_led_cdev(codec, cxt_gpio_mute_update);
797 snd_hda_gen_add_micmute_led_cdev(codec, cxt_gpio_micmute_update);
802 static void cxt_fixup_mute_led_gpio(struct hda_codec *codec,
806 cxt_setup_mute_led(codec, 0x01, 0x02);
809 static void cxt_fixup_hp_zbook_mute_led(struct hda_codec *codec,
813 cxt_setup_mute_led(codec, 0x10, 0x20);
1136 static void add_cx5051_fake_mutes(struct hda_codec *codec)
1138 struct conexant_spec *spec = codec->spec;
1145 snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT,
1147 query_amp_caps(codec, *p, HDA_OUTPUT));
1151 static int patch_conexant_auto(struct hda_codec *codec)
1156 codec_info(codec, "%s: BIOS auto-probing.\n", codec->core.chip_name);
1162 codec->spec = spec;
1163 codec->patch_ops = cx_auto_patch_ops;
1166 switch (codec->core.vendor_id) {
1174 cx_auto_parse_eapd(codec);
1177 switch (codec->core.vendor_id) {
1179 codec->single_adc_amp = 1;
1182 snd_hda_pick_fixup(codec, cxt5045_fixup_models,
1186 codec->pin_amp_workaround = 1;
1189 snd_hda_pick_fixup(codec, cxt5047_fixup_models,
1193 add_cx5051_fake_mutes(codec);
1194 codec->pin_amp_workaround = 1;
1195 snd_hda_pick_fixup(codec, cxt5051_fixup_models,
1199 codec->pin_amp_workaround = 1;
1202 snd_hda_pick_fixup(codec, cxt5066_fixup_models,
1206 codec->power_save_node = 1;
1209 codec->pin_amp_workaround = 1;
1210 snd_hda_pick_fixup(codec, cxt5066_fixup_models,
1218 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1220 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL,
1225 err = cx_auto_parse_beep(codec);
1229 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
1237 if (!codec->bus->core.sync_write) {
1238 codec_info(codec,
1240 codec->bus->core.sync_write = 1;
1241 codec->bus->allow_bus_reset = 1;
1244 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
1249 cx_auto_free(codec);
1295 MODULE_DESCRIPTION("Conexant HD-audio codec");