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