Lines Matching full:codec
3 * HD audio codec driver for Cirrus Logic CS8409 HDA bridge chip
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);
110 cs8409_disable_i2c_clock(spec->codec);
115 * @codec: the codec instance
119 static void cs8409_enable_i2c_clock(struct hda_codec *codec)
121 struct cs8409_spec *spec = codec->spec;
132 cs8409_vendor_coef_set(codec, 0x0, cs8409_vendor_coef_get(codec, 0x0) | 0x8);
140 * @codec: the codec instance
145 static int cs8409_i2c_wait_complete(struct hda_codec *codec)
150 CS42L42_I2C_SLEEP_US, CS42L42_I2C_TIMEOUT_US, false, codec, CS8409_I2C_STS);
155 * @codec: the codec instance
158 static void cs8409_set_i2c_dev_addr(struct hda_codec *codec, unsigned int addr)
160 struct cs8409_spec *spec = codec->spec;
163 cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, addr);
170 * @scodec: the codec instance
177 struct hda_codec *codec = scodec->codec;
180 cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg >> 8);
181 if (cs8409_i2c_wait_complete(codec) < 0)
191 * @scodec: the codec instance
198 struct hda_codec *codec = scodec->codec;
199 struct cs8409_spec *spec = codec->spec;
207 cs8409_enable_i2c_clock(codec);
208 cs8409_set_i2c_dev_addr(codec, scodec->addr);
214 cs8409_vendor_coef_set(codec, CS8409_I2C_QREAD, i2c_reg_data);
215 if (cs8409_i2c_wait_complete(codec) < 0)
219 read_data = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD);
224 codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr);
230 * @scodec: the codec instance
238 struct hda_codec *codec = scodec->codec;
239 struct cs8409_spec *spec = codec->spec;
247 cs8409_set_i2c_dev_addr(codec, scodec->addr);
250 cs8409_enable_i2c_clock(codec);
255 cs8409_vendor_coef_set(codec, CS8409_I2C_QREAD, i2c_reg_data);
257 if (cs8409_i2c_wait_complete(codec) < 0)
260 seq[i].value = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD) & 0xff;
266 codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr);
272 * @scodec: the codec instance
280 struct hda_codec *codec = scodec->codec;
281 struct cs8409_spec *spec = codec->spec;
289 cs8409_enable_i2c_clock(codec);
290 cs8409_set_i2c_dev_addr(codec, scodec->addr);
296 cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg_data);
298 if (cs8409_i2c_wait_complete(codec) < 0)
304 codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr);
310 * @scodec: the codec instance
319 struct hda_codec *codec = scodec->codec;
320 struct cs8409_spec *spec = codec->spec;
328 cs8409_set_i2c_dev_addr(codec, scodec->addr);
331 cs8409_enable_i2c_clock(codec);
336 cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg_data);
338 if (cs8409_i2c_wait_complete(codec) < 0)
350 codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr);
354 static int cs8409_init(struct hda_codec *codec)
356 int ret = snd_hda_gen_init(codec);
359 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
364 static int cs8409_build_controls(struct hda_codec *codec)
368 err = snd_hda_gen_build_controls(codec);
371 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
377 static void cs8409_enable_ur(struct hda_codec *codec, int flag)
379 struct cs8409_spec *spec = codec->spec;
386 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK,
389 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_UNSOLICITED_ENABLE,
393 static void cs8409_fix_caps(struct hda_codec *codec, unsigned int nid)
398 * companion codec. Most of input/output PIN(s) have only basic
402 * phantom jacks. However, a companion codec may be
407 caps = snd_hdac_read_parm(&codec->core, nid, AC_PAR_PIN_CAP);
409 snd_hdac_override_parm(&codec->core, nid, AC_PAR_PIN_CAP,
412 snd_hda_override_wcaps(codec, nid, (get_wcaps(codec, nid) | AC_WCAP_UNSOL_CAP));
418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
419 struct cs8409_spec *spec = codec->spec;
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 struct cs8409_spec *spec = codec->spec;
437 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data);
479 struct hda_codec *codec = snd_kcontrol_chip(kctrl);
480 struct cs8409_spec *spec = codec->spec;
538 struct hda_codec *codec = snd_kcontrol_chip(kctrl);
539 struct cs8409_spec *spec = codec->spec;
570 struct hda_codec *codec,
574 struct cs8409_spec *spec = codec->spec;
599 struct hda_codec *codec,
603 struct cs8409_spec *spec = codec->spec;
627 /* Configure CS42L42 slave codec for jack autodetect */
643 /* Enable and run CS42L42 slave codec jack auto detect */
783 codec_dbg(cs42l42->codec, "Tip Sense Detection: (%d)\n", reg_ts_status);
824 codec_dbg(cs42l42->codec,
848 codec_dbg(cs42l42->codec, "Detection done (%d)\n", type);
864 struct hda_codec *codec = cs42l42->codec;
865 struct cs8409_spec *spec = codec->spec;
875 spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0);
877 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data);
882 /* Initialize CS42L42 companion codec */
901 snd_hda_codec_allow_unsol_events(cs42l42->codec);
908 struct hda_codec *codec = cs42l42->codec;
909 struct cs8409_spec *spec = codec->spec;
930 codec_warn(codec, "Timeout waiting for PDN_DONE for CS42L42\n");
940 spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0);
942 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data);
945 static void cs8409_remove(struct hda_codec *codec)
947 struct cs8409_spec *spec = codec->spec;
951 cs8409_disable_i2c_clock(codec);
953 snd_hda_gen_remove(codec);
963 * and 0x34 where hs mic and hp are connected. Companion codec CS42L42 will
968 static void cs8409_cs42l42_jack_unsol_event(struct hda_codec *codec, unsigned int res)
970 struct cs8409_spec *spec = codec->spec;
983 snd_hda_set_pin_ctl(codec, CS8409_CS42L42_SPK_PIN_NID,
986 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_HP_PIN_NID, 0);
988 snd_hda_jack_unsol_event(codec, (jk->tag << AC_UNSOL_RES_TAG_SHIFT) &
991 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_AMIC_PIN_NID, 0);
993 snd_hda_jack_unsol_event(codec, (jk->tag << AC_UNSOL_RES_TAG_SHIFT) &
998 static void cs8409_unsol_event(struct hda_codec *codec, unsigned int res)
1000 struct cs8409_spec *spec = codec->spec;
1003 spec->unsol_event(codec, res);
1005 cs8409_cs42l42_jack_unsol_event(codec, res);
1009 static int cs8409_cs42l42_suspend(struct hda_codec *codec)
1011 struct cs8409_spec *spec = codec->spec;
1016 cs8409_enable_ur(codec, 0);
1023 cs8409_disable_i2c_clock(codec);
1025 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);
1080 struct hda_codec *codec = container_of(dev, struct hda_codec, core);
1081 struct cs8409_spec *spec = codec->spec;
1112 void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int action)
1114 struct cs8409_spec *spec = codec->spec;
1118 snd_hda_add_verbs(codec, cs8409_cs42l42_init_verbs);
1120 spec->exec_verb = codec->core.exec_verb;
1121 codec->core.exec_verb = cs8409_cs42l42_exec_verb;
1125 spec->scodecs[CS8409_CODEC0]->codec = codec;
1139 snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs);
1141 cs8409_fix_caps(codec, CS8409_CS42L42_HP_PIN_NID);
1142 cs8409_fix_caps(codec, CS8409_CS42L42_AMIC_PIN_NID);
1146 switch (codec->fixup_id) {
1181 if (codec->fixup_id != CS8409_ODIN)
1183 snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID,
1193 cs8409_enable_ur(codec, 0);
1194 snd_hda_codec_set_name(codec, "CS8409/CS42L42");
1197 cs8409_cs42l42_hw_init(codec);
1226 * hs mic and hp are connected. Companion codec CS42L42 will
1231 static void dolphin_jack_unsol_event(struct hda_codec *codec, unsigned int res)
1233 struct cs8409_spec *spec = codec->spec;
1240 jk = snd_hda_jack_tbl_get_mst(codec, DOLPHIN_HP_PIN_NID, 0);
1242 snd_hda_jack_unsol_event(codec,
1246 jk = snd_hda_jack_tbl_get_mst(codec, DOLPHIN_AMIC_PIN_NID, 0);
1248 snd_hda_jack_unsol_event(codec,
1256 jk = snd_hda_jack_tbl_get_mst(codec, DOLPHIN_LO_PIN_NID, 0);
1258 snd_hda_jack_unsol_event(codec,
1267 static void dolphin_hw_init(struct hda_codec *codec)
1270 struct cs8409_spec *spec = codec->spec;
1275 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_MASK,
1277 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DIRECTION,
1279 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA,
1284 cs8409_vendor_coef_set(codec, seq->cir, seq->coeff);
1292 cs8409_enable_ur(codec, 1);
1298 struct hda_codec *codec = container_of(dev, struct hda_codec, core);
1299 struct cs8409_spec *spec = codec->spec;
1333 void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int action)
1335 struct cs8409_spec *spec = codec->spec;
1341 snd_hda_add_verbs(codec, dolphin_init_verbs);
1343 spec->exec_verb = codec->core.exec_verb;
1344 codec->core.exec_verb = dolphin_exec_verb;
1347 spec->scodecs[CS8409_CODEC0]->codec = codec;
1349 spec->scodecs[CS8409_CODEC1]->codec = codec;
1362 snd_hda_sequence_write(codec, dolphin_init_verbs);
1364 snd_hda_jack_add_kctl(codec, DOLPHIN_LO_PIN_NID, "Line Out", true,
1367 snd_hda_jack_add_kctl(codec, DOLPHIN_AMIC_PIN_NID, "Microphone", true,
1370 cs8409_fix_caps(codec, DOLPHIN_HP_PIN_NID);
1371 cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID);
1372 cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID);
1394 cs8409_enable_ur(codec, 0);
1395 snd_hda_codec_set_name(codec, "CS8409/CS42L42");
1398 dolphin_hw_init(codec);
1426 static int cs8409_probe(struct hda_codec *codec, const struct hda_device_id *id)
1430 if (!cs8409_alloc_spec(codec))
1433 snd_hda_pick_fixup(codec, cs8409_models, cs8409_fixup_tbl, cs8409_fixups);
1435 codec_dbg(codec, "Picked ID=%d, VID=%08x, DEV=%08x\n", codec->fixup_id,
1436 codec->bus->pci->subsystem_vendor,
1437 codec->bus->pci->subsystem_device);
1439 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
1441 err = cs8409_parse_auto_config(codec);
1443 cs8409_remove(codec);
1447 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);