Lines Matching full:codec

22 static int cs8409_parse_auto_config(struct hda_codec *codec)  in cs8409_parse_auto_config()  argument
24 struct cs8409_spec *spec = codec->spec; in cs8409_parse_auto_config()
28 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in cs8409_parse_auto_config()
32 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs8409_parse_auto_config()
45 snd_hda_gen_fix_pin_power(codec, spec->gen.adc_nids[idx]); in cs8409_parse_auto_config()
55 static struct cs8409_spec *cs8409_alloc_spec(struct hda_codec *codec) in cs8409_alloc_spec() argument
62 codec->spec = spec; in cs8409_alloc_spec()
63 spec->codec = codec; in cs8409_alloc_spec()
64 codec->power_save_node = 1; in cs8409_alloc_spec()
72 static inline int cs8409_vendor_coef_get(struct hda_codec *codec, unsigned int idx) in cs8409_vendor_coef_get() argument
74 snd_hda_codec_write(codec, CS8409_PIN_VENDOR_WIDGET, 0, AC_VERB_SET_COEF_INDEX, idx); in cs8409_vendor_coef_get()
75 return snd_hda_codec_read(codec, CS8409_PIN_VENDOR_WIDGET, 0, AC_VERB_GET_PROC_COEF, 0); in cs8409_vendor_coef_get()
78 static inline void cs8409_vendor_coef_set(struct hda_codec *codec, unsigned int idx, in cs8409_vendor_coef_set() argument
81 snd_hda_codec_write(codec, CS8409_PIN_VENDOR_WIDGET, 0, AC_VERB_SET_COEF_INDEX, idx); in cs8409_vendor_coef_set()
82 snd_hda_codec_write(codec, CS8409_PIN_VENDOR_WIDGET, 0, AC_VERB_SET_PROC_COEF, coef); in cs8409_vendor_coef_set()
87 * @codec: the codec instance
91 static void cs8409_disable_i2c_clock(struct hda_codec *codec) in cs8409_disable_i2c_clock() argument
93 struct cs8409_spec *spec = codec->spec; in cs8409_disable_i2c_clock()
97 cs8409_vendor_coef_set(spec->codec, 0x0, in cs8409_disable_i2c_clock()
98 cs8409_vendor_coef_get(spec->codec, 0x0) & 0xfffffff7); in cs8409_disable_i2c_clock()
111 cs8409_disable_i2c_clock(spec->codec); in cs8409_disable_i2c_clock_worker()
116 * @codec: the codec instance
120 static void cs8409_enable_i2c_clock(struct hda_codec *codec) in cs8409_enable_i2c_clock() argument
122 struct cs8409_spec *spec = codec->spec; in cs8409_enable_i2c_clock()
133 cs8409_vendor_coef_set(codec, 0x0, cs8409_vendor_coef_get(codec, 0x0) | 0x8); in cs8409_enable_i2c_clock()
141 * @codec: the codec instance
146 static int cs8409_i2c_wait_complete(struct hda_codec *codec) in cs8409_i2c_wait_complete() argument
151 CS42L42_I2C_SLEEP_US, CS42L42_I2C_TIMEOUT_US, false, codec, CS8409_I2C_STS); in cs8409_i2c_wait_complete()
156 * @codec: the codec instance
159 static void cs8409_set_i2c_dev_addr(struct hda_codec *codec, unsigned int addr) in cs8409_set_i2c_dev_addr() argument
161 struct cs8409_spec *spec = codec->spec; in cs8409_set_i2c_dev_addr()
164 cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, addr); in cs8409_set_i2c_dev_addr()
171 * @scodec: the codec instance
178 struct hda_codec *codec = scodec->codec; in cs8409_i2c_set_page() local
181 cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg >> 8); in cs8409_i2c_set_page()
182 if (cs8409_i2c_wait_complete(codec) < 0) in cs8409_i2c_set_page()
192 * @scodec: the codec instance
199 struct hda_codec *codec = scodec->codec; in cs8409_i2c_read() local
200 struct cs8409_spec *spec = codec->spec; in cs8409_i2c_read()
208 cs8409_enable_i2c_clock(codec); in cs8409_i2c_read()
209 cs8409_set_i2c_dev_addr(codec, scodec->addr); in cs8409_i2c_read()
215 cs8409_vendor_coef_set(codec, CS8409_I2C_QREAD, i2c_reg_data); in cs8409_i2c_read()
216 if (cs8409_i2c_wait_complete(codec) < 0) in cs8409_i2c_read()
220 read_data = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD); in cs8409_i2c_read()
228 codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr); in cs8409_i2c_read()
234 * @scodec: the codec instance
242 struct hda_codec *codec = scodec->codec; in cs8409_i2c_bulk_read() local
243 struct cs8409_spec *spec = codec->spec; in cs8409_i2c_bulk_read()
251 cs8409_set_i2c_dev_addr(codec, scodec->addr); in cs8409_i2c_bulk_read()
254 cs8409_enable_i2c_clock(codec); in cs8409_i2c_bulk_read()
259 cs8409_vendor_coef_set(codec, CS8409_I2C_QREAD, i2c_reg_data); in cs8409_i2c_bulk_read()
261 if (cs8409_i2c_wait_complete(codec) < 0) in cs8409_i2c_bulk_read()
264 seq[i].value = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD) & 0xff; in cs8409_i2c_bulk_read()
273 codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr); in cs8409_i2c_bulk_read()
279 * @scodec: the codec instance
287 struct hda_codec *codec = scodec->codec; in cs8409_i2c_write() local
288 struct cs8409_spec *spec = codec->spec; in cs8409_i2c_write()
296 cs8409_enable_i2c_clock(codec); in cs8409_i2c_write()
297 cs8409_set_i2c_dev_addr(codec, scodec->addr); in cs8409_i2c_write()
303 cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg_data); in cs8409_i2c_write()
305 if (cs8409_i2c_wait_complete(codec) < 0) in cs8409_i2c_write()
313 codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr); in cs8409_i2c_write()
319 * @scodec: the codec instance
328 struct hda_codec *codec = scodec->codec; in cs8409_i2c_bulk_write() local
329 struct cs8409_spec *spec = codec->spec; in cs8409_i2c_bulk_write()
337 cs8409_set_i2c_dev_addr(codec, scodec->addr); in cs8409_i2c_bulk_write()
340 cs8409_enable_i2c_clock(codec); in cs8409_i2c_bulk_write()
345 cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg_data); in cs8409_i2c_bulk_write()
347 if (cs8409_i2c_wait_complete(codec) < 0) in cs8409_i2c_bulk_write()
357 codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr); in cs8409_i2c_bulk_write()
361 static int cs8409_init(struct hda_codec *codec) in cs8409_init() argument
363 int ret = snd_hda_gen_init(codec); in cs8409_init()
366 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); in cs8409_init()
371 static int cs8409_build_controls(struct hda_codec *codec) in cs8409_build_controls() argument
375 err = snd_hda_gen_build_controls(codec); in cs8409_build_controls()
378 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); in cs8409_build_controls()
384 static void cs8409_enable_ur(struct hda_codec *codec, int flag) in cs8409_enable_ur() argument
386 struct cs8409_spec *spec = codec->spec; in cs8409_enable_ur()
393 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, in cs8409_enable_ur()
396 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_UNSOLICITED_ENABLE, in cs8409_enable_ur()
400 static void cs8409_fix_caps(struct hda_codec *codec, unsigned int nid) in cs8409_fix_caps() argument
405 * companion codec. Most of input/output PIN(s) have only basic in cs8409_fix_caps()
409 * phantom jacks. However, a companion codec may be in cs8409_fix_caps()
414 caps = snd_hdac_read_parm(&codec->core, nid, AC_PAR_PIN_CAP); in cs8409_fix_caps()
416 snd_hdac_override_parm(&codec->core, nid, AC_PAR_PIN_CAP, in cs8409_fix_caps()
419 snd_hda_override_wcaps(codec, nid, (get_wcaps(codec, nid) | AC_WCAP_UNSOL_CAP)); in cs8409_fix_caps()
425 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs8409_spk_sw_gpio_get() local
426 struct cs8409_spec *spec = codec->spec; in cs8409_spk_sw_gpio_get()
435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs8409_spk_sw_gpio_put() local
436 struct cs8409_spec *spec = codec->spec; in cs8409_spk_sw_gpio_put()
444 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs8409_spk_sw_gpio_put()
486 struct hda_codec *codec = snd_kcontrol_chip(kctrl); in cs42l42_volume_get() local
487 struct cs8409_spec *spec = codec->spec; in cs42l42_volume_get()
545 struct hda_codec *codec = snd_kcontrol_chip(kctrl); in cs42l42_volume_put() local
546 struct cs8409_spec *spec = codec->spec; in cs42l42_volume_put()
577 struct hda_codec *codec, in cs42l42_playback_pcm_hook() argument
581 struct cs8409_spec *spec = codec->spec; in cs42l42_playback_pcm_hook()
606 struct hda_codec *codec, in cs42l42_capture_pcm_hook() argument
610 struct cs8409_spec *spec = codec->spec; in cs42l42_capture_pcm_hook()
634 /* Configure CS42L42 slave codec for jack autodetect */
650 /* Enable and run CS42L42 slave codec jack auto detect */
790 codec_dbg(cs42l42->codec, "Tip Sense Detection: (%d)\n", reg_ts_status); in cs42l42_handle_tip_sense()
831 codec_dbg(cs42l42->codec, in cs42l42_jack_unsol_event()
855 codec_dbg(cs42l42->codec, "Detection done (%d)\n", type); in cs42l42_jack_unsol_event()
871 struct hda_codec *codec = cs42l42->codec; in cs42l42_resume() local
872 struct cs8409_spec *spec = codec->spec; in cs42l42_resume()
882 spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); in cs42l42_resume()
884 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs42l42_resume()
889 /* Initialize CS42L42 companion codec */ in cs42l42_resume()
907 snd_hda_codec_allow_unsol_events(cs42l42->codec); in cs42l42_resume()
915 struct hda_codec *codec = cs42l42->codec; in cs42l42_suspend() local
916 struct cs8409_spec *spec = codec->spec; in cs42l42_suspend()
937 codec_warn(codec, "Timeout waiting for PDN_DONE for CS42L42\n"); in cs42l42_suspend()
947 spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); in cs42l42_suspend()
949 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs42l42_suspend()
953 static void cs8409_free(struct hda_codec *codec) in cs8409_free() argument
955 struct cs8409_spec *spec = codec->spec; in cs8409_free()
959 cs8409_disable_i2c_clock(codec); in cs8409_free()
961 snd_hda_gen_free(codec); in cs8409_free()
971 * and 0x34 where hs mic and hp are connected. Companion codec CS42L42 will
976 static void cs8409_cs42l42_jack_unsol_event(struct hda_codec *codec, unsigned int res) in cs8409_cs42l42_jack_unsol_event() argument
978 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_jack_unsol_event()
991 snd_hda_set_pin_ctl(codec, CS8409_CS42L42_SPK_PIN_NID, in cs8409_cs42l42_jack_unsol_event()
994 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_HP_PIN_NID, 0); in cs8409_cs42l42_jack_unsol_event()
996 snd_hda_jack_unsol_event(codec, (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & in cs8409_cs42l42_jack_unsol_event()
999 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_AMIC_PIN_NID, 0); in cs8409_cs42l42_jack_unsol_event()
1001 snd_hda_jack_unsol_event(codec, (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & in cs8409_cs42l42_jack_unsol_event()
1008 static int cs8409_cs42l42_suspend(struct hda_codec *codec) in cs8409_cs42l42_suspend() argument
1010 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_suspend()
1015 cs8409_enable_ur(codec, 0); in cs8409_cs42l42_suspend()
1022 cs8409_disable_i2c_clock(codec); in cs8409_cs42l42_suspend()
1024 snd_hda_shutup_pins(codec); in cs8409_cs42l42_suspend()
1033 static void cs8409_cs42l42_hw_init(struct hda_codec *codec) in cs8409_cs42l42_hw_init() argument
1037 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_hw_init()
1041 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_MASK, in cs8409_cs42l42_hw_init()
1043 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DIRECTION, in cs8409_cs42l42_hw_init()
1045 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, in cs8409_cs42l42_hw_init()
1050 cs8409_vendor_coef_set(codec, seq->cir, seq->coeff); in cs8409_cs42l42_hw_init()
1052 if (codec->fixup_id == CS8409_BULLSEYE) { in cs8409_cs42l42_hw_init()
1054 cs8409_vendor_coef_set(codec, seq_bullseye->cir, seq_bullseye->coeff); in cs8409_cs42l42_hw_init()
1057 switch (codec->fixup_id) { in cs8409_cs42l42_hw_init()
1061 cs8409_vendor_coef_set(codec, CS8409_DMIC_CFG, 0x0003); in cs8409_cs42l42_hw_init()
1065 cs8409_vendor_coef_set(codec, CS8409_PAD_CFG_SLW_RATE_CTRL, 0xfc00); in cs8409_cs42l42_hw_init()
1074 cs8409_enable_ur(codec, 1); in cs8409_cs42l42_hw_init()
1091 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in cs8409_cs42l42_exec_verb() local
1092 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_exec_verb()
1123 void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int action) in cs8409_cs42l42_fixups() argument
1125 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_fixups()
1129 snd_hda_add_verbs(codec, cs8409_cs42l42_init_verbs); in cs8409_cs42l42_fixups()
1131 spec->exec_verb = codec->core.exec_verb; in cs8409_cs42l42_fixups()
1132 codec->core.exec_verb = cs8409_cs42l42_exec_verb; in cs8409_cs42l42_fixups()
1136 spec->scodecs[CS8409_CODEC0]->codec = codec; in cs8409_cs42l42_fixups()
1137 codec->patch_ops = cs8409_cs42l42_patch_ops; in cs8409_cs42l42_fixups()
1151 snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs); in cs8409_cs42l42_fixups()
1153 cs8409_fix_caps(codec, CS8409_CS42L42_HP_PIN_NID); in cs8409_cs42l42_fixups()
1154 cs8409_fix_caps(codec, CS8409_CS42L42_AMIC_PIN_NID); in cs8409_cs42l42_fixups()
1158 switch (codec->fixup_id) { in cs8409_cs42l42_fixups()
1193 if (codec->fixup_id != CS8409_ODIN) in cs8409_cs42l42_fixups()
1195 snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID, in cs8409_cs42l42_fixups()
1205 cs8409_enable_ur(codec, 0); in cs8409_cs42l42_fixups()
1206 snd_hda_codec_set_name(codec, "CS8409/CS42L42"); in cs8409_cs42l42_fixups()
1209 cs8409_cs42l42_hw_init(codec); in cs8409_cs42l42_fixups()
1238 * hs mic and hp are connected. Companion codec CS42L42 will
1243 static void dolphin_jack_unsol_event(struct hda_codec *codec, unsigned int res) in dolphin_jack_unsol_event() argument
1245 struct cs8409_spec *spec = codec->spec; in dolphin_jack_unsol_event()
1252 jk = snd_hda_jack_tbl_get_mst(codec, DOLPHIN_HP_PIN_NID, 0); in dolphin_jack_unsol_event()
1254 snd_hda_jack_unsol_event(codec, in dolphin_jack_unsol_event()
1258 jk = snd_hda_jack_tbl_get_mst(codec, DOLPHIN_AMIC_PIN_NID, 0); in dolphin_jack_unsol_event()
1260 snd_hda_jack_unsol_event(codec, in dolphin_jack_unsol_event()
1268 jk = snd_hda_jack_tbl_get_mst(codec, DOLPHIN_LO_PIN_NID, 0); in dolphin_jack_unsol_event()
1270 snd_hda_jack_unsol_event(codec, in dolphin_jack_unsol_event()
1279 static void dolphin_hw_init(struct hda_codec *codec) in dolphin_hw_init() argument
1282 struct cs8409_spec *spec = codec->spec; in dolphin_hw_init()
1287 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_MASK, in dolphin_hw_init()
1289 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DIRECTION, in dolphin_hw_init()
1291 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, in dolphin_hw_init()
1296 cs8409_vendor_coef_set(codec, seq->cir, seq->coeff); in dolphin_hw_init()
1304 cs8409_enable_ur(codec, 1); in dolphin_hw_init()
1321 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in dolphin_exec_verb() local
1322 struct cs8409_spec *spec = codec->spec; in dolphin_exec_verb()
1356 void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int action) in dolphin_fixups() argument
1358 struct cs8409_spec *spec = codec->spec; in dolphin_fixups()
1364 snd_hda_add_verbs(codec, dolphin_init_verbs); in dolphin_fixups()
1366 spec->exec_verb = codec->core.exec_verb; in dolphin_fixups()
1367 codec->core.exec_verb = dolphin_exec_verb; in dolphin_fixups()
1370 spec->scodecs[CS8409_CODEC0]->codec = codec; in dolphin_fixups()
1372 spec->scodecs[CS8409_CODEC1]->codec = codec; in dolphin_fixups()
1375 codec->patch_ops = cs8409_dolphin_patch_ops; in dolphin_fixups()
1384 snd_hda_sequence_write(codec, dolphin_init_verbs); in dolphin_fixups()
1386 snd_hda_jack_add_kctl(codec, DOLPHIN_LO_PIN_NID, "Line Out", true, in dolphin_fixups()
1389 snd_hda_jack_add_kctl(codec, DOLPHIN_AMIC_PIN_NID, "Microphone", true, in dolphin_fixups()
1392 cs8409_fix_caps(codec, DOLPHIN_HP_PIN_NID); in dolphin_fixups()
1393 cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID); in dolphin_fixups()
1394 cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID); in dolphin_fixups()
1415 cs8409_enable_ur(codec, 0); in dolphin_fixups()
1416 snd_hda_codec_set_name(codec, "CS8409/CS42L42"); in dolphin_fixups()
1419 dolphin_hw_init(codec); in dolphin_fixups()
1447 static int patch_cs8409(struct hda_codec *codec) in patch_cs8409() argument
1451 if (!cs8409_alloc_spec(codec)) in patch_cs8409()
1454 snd_hda_pick_fixup(codec, cs8409_models, cs8409_fixup_tbl, cs8409_fixups); in patch_cs8409()
1456 codec_dbg(codec, "Picked ID=%d, VID=%08x, DEV=%08x\n", codec->fixup_id, in patch_cs8409()
1457 codec->bus->pci->subsystem_vendor, in patch_cs8409()
1458 codec->bus->pci->subsystem_device); in patch_cs8409()
1460 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs8409()
1462 err = cs8409_parse_auto_config(codec); in patch_cs8409()
1464 cs8409_free(codec); in patch_cs8409()
1468 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs8409()