Lines Matching +full:codec +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-or-later
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()
29 if (err < 0) in cs8409_parse_auto_config()
32 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs8409_parse_auto_config()
33 if (err < 0) in cs8409_parse_auto_config()
37 if (spec->gen.dyn_adc_switch) { in cs8409_parse_auto_config()
38 unsigned int done = 0; in cs8409_parse_auto_config()
40 for (i = 0; i < spec->gen.input_mux.num_items; i++) { in cs8409_parse_auto_config()
41 int idx = spec->gen.dyn_adc_idx[i]; in cs8409_parse_auto_config()
45 snd_hda_gen_fix_pin_power(codec, spec->gen.adc_nids[idx]); in cs8409_parse_auto_config()
50 return 0; 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()
65 mutex_init(&spec->i2c_mux); in cs8409_alloc_spec()
66 INIT_DELAYED_WORK(&spec->i2c_clk_work, cs8409_disable_i2c_clock_worker); in cs8409_alloc_spec()
67 snd_hda_gen_spec_init(&spec->gen); 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()
86 * cs8409_enable_i2c_clock - Disable I2C clocks
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()
95 mutex_lock(&spec->i2c_mux); in cs8409_disable_i2c_clock()
96 if (spec->i2c_clck_enabled) { 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()
99 spec->i2c_clck_enabled = 0; in cs8409_disable_i2c_clock()
101 mutex_unlock(&spec->i2c_mux); in cs8409_disable_i2c_clock()
105 * cs8409_disable_i2c_clock_worker - Worker that disable the I2C Clock after 25ms without use
111 cs8409_disable_i2c_clock(spec->codec); in cs8409_disable_i2c_clock_worker()
115 * cs8409_enable_i2c_clock - Enable I2C clocks
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()
128 * afterwards in the scenario. The next enable call will re-enable the clock, regardless. in cs8409_enable_i2c_clock()
130 cancel_delayed_work(&spec->i2c_clk_work); in cs8409_enable_i2c_clock()
132 if (!spec->i2c_clck_enabled) { in cs8409_enable_i2c_clock()
133 cs8409_vendor_coef_set(codec, 0x0, cs8409_vendor_coef_get(codec, 0x0) | 0x8); in cs8409_enable_i2c_clock()
134 spec->i2c_clck_enabled = 1; in cs8409_enable_i2c_clock()
136 queue_delayed_work(system_power_efficient_wq, &spec->i2c_clk_work, msecs_to_jiffies(25)); in cs8409_enable_i2c_clock()
140 * cs8409_i2c_wait_complete - Wait for I2C transaction
141 * @codec: the codec instance
144 * Return -ETIMEDOUT if transaction wait times out.
146 static int cs8409_i2c_wait_complete(struct hda_codec *codec) in cs8409_i2c_wait_complete() argument
150 return read_poll_timeout(cs8409_vendor_coef_get, retval, retval & 0x18, in cs8409_i2c_wait_complete()
151 CS42L42_I2C_SLEEP_US, CS42L42_I2C_TIMEOUT_US, false, codec, CS8409_I2C_STS); in cs8409_i2c_wait_complete()
155 * cs8409_set_i2c_dev_addr - Set i2c address for transaction
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()
163 if (spec->dev_addr != addr) { in cs8409_set_i2c_dev_addr()
164 cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, addr); in cs8409_set_i2c_dev_addr()
165 spec->dev_addr = addr; in cs8409_set_i2c_dev_addr()
170 * cs8409_i2c_set_page - CS8409 I2C set page register.
171 * @scodec: the codec instance
178 struct hda_codec *codec = scodec->codec; in cs8409_i2c_set_page() local
180 if (scodec->paged && (scodec->last_page != (i2c_reg >> 8))) { in cs8409_i2c_set_page()
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()
183 return -EIO; in cs8409_i2c_set_page()
184 scodec->last_page = i2c_reg >> 8; in cs8409_i2c_set_page()
187 return 0; in cs8409_i2c_set_page()
191 * cs8409_i2c_read - CS8409 I2C Read.
192 * @scodec: the codec instance
195 * Returns negative on error, otherwise returns read value in bits 0-7.
199 struct hda_codec *codec = scodec->codec; in cs8409_i2c_read() local
200 struct cs8409_spec *spec = codec->spec; in cs8409_i2c_read()
204 if (scodec->suspended) in cs8409_i2c_read()
205 return -EPERM; in cs8409_i2c_read()
207 mutex_lock(&spec->i2c_mux); 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()
214 i2c_reg_data = (addr << 8) & 0x0ffff; 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()
219 /* Register in bits 15-8 and the data in 7-0 */ in cs8409_i2c_read()
220 read_data = cs8409_vendor_coef_get(codec, CS8409_I2C_QREAD); in cs8409_i2c_read()
222 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_read()
224 return read_data & 0x0ff; in cs8409_i2c_read()
227 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_read()
228 codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr); in cs8409_i2c_read()
229 return -EIO; in cs8409_i2c_read()
233 * cs8409_i2c_bulk_read - CS8409 I2C Read Sequence.
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()
247 if (scodec->suspended) in cs8409_i2c_bulk_read()
248 return -EPERM; in cs8409_i2c_bulk_read()
250 mutex_lock(&spec->i2c_mux); in cs8409_i2c_bulk_read()
251 cs8409_set_i2c_dev_addr(codec, scodec->addr); in cs8409_i2c_bulk_read()
253 for (i = 0; i < count; i++) { in cs8409_i2c_bulk_read()
254 cs8409_enable_i2c_clock(codec); in cs8409_i2c_bulk_read()
258 i2c_reg_data = (seq[i].addr << 8) & 0x0ffff; 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()
267 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_bulk_read()
269 return 0; in cs8409_i2c_bulk_read()
272 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_bulk_read()
273 codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr); in cs8409_i2c_bulk_read()
274 return -EIO; in cs8409_i2c_bulk_read()
278 * cs8409_i2c_write - CS8409 I2C Write.
279 * @scodec: the codec instance
283 * Returns negative on error, otherwise returns 0.
287 struct hda_codec *codec = scodec->codec; in cs8409_i2c_write() local
288 struct cs8409_spec *spec = codec->spec; in cs8409_i2c_write()
291 if (scodec->suspended) in cs8409_i2c_write()
292 return -EPERM; in cs8409_i2c_write()
294 mutex_lock(&spec->i2c_mux); 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()
302 i2c_reg_data = ((addr << 8) & 0x0ff00) | (value & 0x0ff); 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()
308 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_write()
309 return 0; in cs8409_i2c_write()
312 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_write()
313 codec_err(codec, "%s() Failed 0x%02x : 0x%04x\n", __func__, scodec->addr, addr); in cs8409_i2c_write()
314 return -EIO; in cs8409_i2c_write()
318 * cs8409_i2c_bulk_write - CS8409 I2C Write Sequence.
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()
333 if (scodec->suspended) in cs8409_i2c_bulk_write()
334 return -EPERM; in cs8409_i2c_bulk_write()
336 mutex_lock(&spec->i2c_mux); in cs8409_i2c_bulk_write()
337 cs8409_set_i2c_dev_addr(codec, scodec->addr); in cs8409_i2c_bulk_write()
339 for (i = 0; i < count; i++) { in cs8409_i2c_bulk_write()
340 cs8409_enable_i2c_clock(codec); in cs8409_i2c_bulk_write()
344 i2c_reg_data = ((seq[i].addr << 8) & 0x0ff00) | (seq[i].value & 0x0ff); 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()
356 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_bulk_write()
358 return 0; in cs8409_i2c_bulk_write()
361 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_bulk_write()
362 codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr); in cs8409_i2c_bulk_write()
363 return -EIO; in cs8409_i2c_bulk_write()
366 static int cs8409_init(struct hda_codec *codec) in cs8409_init() argument
368 int ret = snd_hda_gen_init(codec); in cs8409_init()
371 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); in cs8409_init()
376 static int cs8409_build_controls(struct hda_codec *codec) in cs8409_build_controls() argument
380 err = snd_hda_gen_build_controls(codec); in cs8409_build_controls()
381 if (err < 0) in cs8409_build_controls()
383 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); in cs8409_build_controls()
385 return 0; in cs8409_build_controls()
389 static void cs8409_enable_ur(struct hda_codec *codec, int flag) in cs8409_enable_ur() argument
391 struct cs8409_spec *spec = codec->spec; in cs8409_enable_ur()
392 unsigned int ur_gpios = 0; in cs8409_enable_ur()
395 for (i = 0; i < spec->num_scodecs; i++) in cs8409_enable_ur()
396 ur_gpios |= spec->scodecs[i]->irq_mask; in cs8409_enable_ur()
398 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, in cs8409_enable_ur()
399 flag ? ur_gpios : 0); in cs8409_enable_ur()
401 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_UNSOLICITED_ENABLE, in cs8409_enable_ur()
402 flag ? AC_UNSOL_ENABLED : 0); in cs8409_enable_ur()
405 static void cs8409_fix_caps(struct hda_codec *codec, unsigned int nid) in cs8409_fix_caps() argument
410 * companion codec. Most of input/output PIN(s) have only basic in cs8409_fix_caps()
414 * phantom jacks. However, a companion codec may be in cs8409_fix_caps()
419 caps = snd_hdac_read_parm(&codec->core, nid, AC_PAR_PIN_CAP); in cs8409_fix_caps()
420 if (caps >= 0) in cs8409_fix_caps()
421 snd_hdac_override_parm(&codec->core, nid, AC_PAR_PIN_CAP, in cs8409_fix_caps()
424 snd_hda_override_wcaps(codec, nid, (get_wcaps(codec, nid) | AC_WCAP_UNSOL_CAP)); in cs8409_fix_caps()
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs8409_spk_sw_gpio_get() local
431 struct cs8409_spec *spec = codec->spec; in cs8409_spk_sw_gpio_get()
433 ucontrol->value.integer.value[0] = !!(spec->gpio_data & spec->speaker_pdn_gpio); in cs8409_spk_sw_gpio_get()
434 return 0; in cs8409_spk_sw_gpio_get()
440 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs8409_spk_sw_gpio_put() local
441 struct cs8409_spec *spec = codec->spec; in cs8409_spk_sw_gpio_put()
444 gpio_data = (spec->gpio_data & ~spec->speaker_pdn_gpio) | in cs8409_spk_sw_gpio_put()
445 (ucontrol->value.integer.value[0] ? spec->speaker_pdn_gpio : 0); in cs8409_spk_sw_gpio_put()
446 if (gpio_data == spec->gpio_data) in cs8409_spk_sw_gpio_put()
447 return 0; in cs8409_spk_sw_gpio_put()
448 spec->gpio_data = gpio_data; in cs8409_spk_sw_gpio_put()
449 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs8409_spk_sw_gpio_put()
469 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in cs42l42_volume_info()
470 uinfo->value.integer.step = 1; in cs42l42_volume_info()
471 uinfo->count = chs == 3 ? 2 : 1; in cs42l42_volume_info()
475 uinfo->value.integer.min = CS42L42_HP_VOL_REAL_MIN; in cs42l42_volume_info()
476 uinfo->value.integer.max = CS42L42_HP_VOL_REAL_MAX; in cs42l42_volume_info()
479 uinfo->value.integer.min = CS42L42_AMIC_VOL_REAL_MIN; in cs42l42_volume_info()
480 uinfo->value.integer.max = CS42L42_AMIC_VOL_REAL_MAX; in cs42l42_volume_info()
486 return 0; in cs42l42_volume_info()
491 struct hda_codec *codec = snd_kcontrol_chip(kctrl); in cs42l42_volume_get() local
492 struct cs8409_spec *spec = codec->spec; in cs42l42_volume_get()
493 struct sub_codec *cs42l42 = spec->scodecs[get_amp_index(kctrl)]; in cs42l42_volume_get()
496 long *valp = uctrl->value.integer.value; in cs42l42_volume_get()
500 if (chs & BIT(0)) in cs42l42_volume_get()
501 *valp++ = cs42l42->vol[ofs]; in cs42l42_volume_get()
503 *valp = cs42l42->vol[ofs+1]; in cs42l42_volume_get()
506 if (chs & BIT(0)) in cs42l42_volume_get()
507 *valp = cs42l42->vol[ofs]; in cs42l42_volume_get()
513 return 0; in cs42l42_volume_get()
521 if (chs & BIT(0)) in cs42l42_mute()
522 cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHA_VOL, 0x3f); in cs42l42_mute()
524 cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHB_VOL, 0x3f); in cs42l42_mute()
526 if (chs & BIT(0)) in cs42l42_mute()
527 cs8409_i2c_write(cs42l42, CS42L42_ADC_VOLUME, 0x9f); in cs42l42_mute()
531 if (chs & BIT(0)) in cs42l42_mute()
533 -(cs42l42->vol[CS42L42_DAC_CH0_VOL_OFFSET]) in cs42l42_mute()
537 -(cs42l42->vol[CS42L42_DAC_CH1_VOL_OFFSET]) in cs42l42_mute()
540 if (chs & BIT(0)) in cs42l42_mute()
542 cs42l42->vol[CS42L42_ADC_VOL_OFFSET] in cs42l42_mute()
550 struct hda_codec *codec = snd_kcontrol_chip(kctrl); in cs42l42_volume_put() local
551 struct cs8409_spec *spec = codec->spec; in cs42l42_volume_put()
552 struct sub_codec *cs42l42 = spec->scodecs[get_amp_index(kctrl)]; in cs42l42_volume_put()
555 long *valp = uctrl->value.integer.value; in cs42l42_volume_put()
559 if (chs & BIT(0)) in cs42l42_volume_put()
560 cs42l42->vol[ofs] = *valp; in cs42l42_volume_put()
563 cs42l42->vol[ofs + 1] = *valp; in cs42l42_volume_put()
565 if (spec->playback_started) in cs42l42_volume_put()
569 if (chs & BIT(0)) in cs42l42_volume_put()
570 cs42l42->vol[ofs] = *valp; in cs42l42_volume_put()
571 if (spec->capture_started) in cs42l42_volume_put()
578 return 0; in cs42l42_volume_put()
582 struct hda_codec *codec, in cs42l42_playback_pcm_hook() argument
586 struct cs8409_spec *spec = codec->spec; in cs42l42_playback_pcm_hook()
594 spec->playback_started = 1; in cs42l42_playback_pcm_hook()
598 spec->playback_started = 0; in cs42l42_playback_pcm_hook()
604 for (i = 0; i < spec->num_scodecs; i++) { in cs42l42_playback_pcm_hook()
605 cs42l42 = spec->scodecs[i]; in cs42l42_playback_pcm_hook()
606 cs42l42_mute(cs42l42, CS42L42_VOL_DAC, 0x3, mute); in cs42l42_playback_pcm_hook()
611 struct hda_codec *codec, in cs42l42_capture_pcm_hook() argument
615 struct cs8409_spec *spec = codec->spec; in cs42l42_capture_pcm_hook()
623 spec->capture_started = 1; in cs42l42_capture_pcm_hook()
627 spec->capture_started = 0; in cs42l42_capture_pcm_hook()
633 for (i = 0; i < spec->num_scodecs; i++) { in cs42l42_capture_pcm_hook()
634 cs42l42 = spec->scodecs[i]; in cs42l42_capture_pcm_hook()
635 cs42l42_mute(cs42l42, CS42L42_VOL_ADC, 0x3, mute); in cs42l42_capture_pcm_hook()
639 /* Configure CS42L42 slave codec for jack autodetect */
642 cs8409_i2c_write(cs42l42, CS42L42_HSBIAS_SC_AUTOCTL, cs42l42->hsbias_hiz); in cs42l42_enable_jack_detect()
644 cs8409_i2c_write(cs42l42, CS42L42_WAKE_CTL, 0x00C1); in cs42l42_enable_jack_detect()
648 cs8409_i2c_write(cs42l42, CS42L42_WAKE_CTL, 0x00C0); in cs42l42_enable_jack_detect()
652 cs8409_i2c_write(cs42l42, CS42L42_TSRS_PLUG_INT_MASK, 0xF3); in cs42l42_enable_jack_detect()
655 /* Enable and run CS42L42 slave codec jack auto detect */
661 cs8409_i2c_write(cs42l42, CS42L42_TSRS_PLUG_INT_MASK, 0xFF); in cs42l42_run_jack_detect()
664 cs8409_i2c_write(cs42l42, CS42L42_PWR_CTL2, 0x87); in cs42l42_run_jack_detect()
665 cs8409_i2c_write(cs42l42, CS42L42_DAC_CTL2, 0x86); in cs42l42_run_jack_detect()
666 cs8409_i2c_write(cs42l42, CS42L42_MISC_DET_CTL, 0x07); in cs42l42_run_jack_detect()
667 cs8409_i2c_write(cs42l42, CS42L42_CODEC_INT_MASK, 0xFD); in cs42l42_run_jack_detect()
668 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL2, 0x80); in cs42l42_run_jack_detect()
671 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL1, 0x77); in cs42l42_run_jack_detect()
672 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL2, 0xc0); in cs42l42_run_jack_detect()
686 (0 << CS42L42_HSDET_SET_SHIFT) | in cs42l42_manual_hs_det()
687 (0 << CS42L42_HSBIAS_REF_SHIFT) | in cs42l42_manual_hs_det()
688 (0 << CS42L42_HSDET_AUTO_TIME_SHIFT)); in cs42l42_manual_hs_det()
756 (0 << CS42L42_HSDET_CTRL_SHIFT) | in cs42l42_manual_hs_det()
757 (0 << CS42L42_HSDET_SET_SHIFT) | in cs42l42_manual_hs_det()
758 (0 << CS42L42_HSBIAS_REF_SHIFT) | in cs42l42_manual_hs_det()
759 (0 << CS42L42_HSDET_AUTO_TIME_SHIFT)); in cs42l42_manual_hs_det()
771 int status_changed = 0; in cs42l42_handle_tip_sense()
776 if (cs42l42->no_type_dect) { in cs42l42_handle_tip_sense()
778 cs42l42->hp_jack_in = 1; in cs42l42_handle_tip_sense()
779 cs42l42->mic_jack_in = 0; in cs42l42_handle_tip_sense()
787 cs42l42->hp_jack_in = 0; in cs42l42_handle_tip_sense()
788 cs42l42->mic_jack_in = 0; in cs42l42_handle_tip_sense()
795 codec_dbg(cs42l42->codec, "Tip Sense Detection: (%d)\n", reg_ts_status); in cs42l42_handle_tip_sense()
803 int status_changed = 0; in cs42l42_jack_unsol_event()
814 /* If status values are < 0, read error has occurred. */ in cs42l42_jack_unsol_event()
815 if (reg_cdc_status < 0 || reg_hs_status < 0 || reg_ts_status < 0) in cs42l42_jack_unsol_event()
816 return -EIO; in cs42l42_jack_unsol_event()
825 cs8409_i2c_write(cs42l42, CS42L42_CODEC_INT_MASK, 0xFF); in cs42l42_jack_unsol_event()
830 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL2, 0x80); in cs42l42_jack_unsol_event()
832 if (cs42l42->no_type_dect) { in cs42l42_jack_unsol_event()
836 codec_dbg(cs42l42->codec, in cs42l42_jack_unsol_event()
846 cs42l42->hp_jack_in = 1; in cs42l42_jack_unsol_event()
847 cs42l42->mic_jack_in = 1; in cs42l42_jack_unsol_event()
851 cs42l42->hp_jack_in = 1; in cs42l42_jack_unsol_event()
852 cs42l42->mic_jack_in = 0; in cs42l42_jack_unsol_event()
856 cs42l42->hp_jack_in = 0; in cs42l42_jack_unsol_event()
857 cs42l42->mic_jack_in = 0; in cs42l42_jack_unsol_event()
860 codec_dbg(cs42l42->codec, "Detection done (%d)\n", type); in cs42l42_jack_unsol_event()
863 /* Enable the HPOUT ground clamp and configure the HP pull-down */ in cs42l42_jack_unsol_event()
864 cs8409_i2c_write(cs42l42, CS42L42_DAC_CTL2, 0x02); in cs42l42_jack_unsol_event()
865 /* Re-Enable Tip Sense Interrupt */ in cs42l42_jack_unsol_event()
866 cs8409_i2c_write(cs42l42, CS42L42_TSRS_PLUG_INT_MASK, 0xF3); in cs42l42_jack_unsol_event()
876 struct hda_codec *codec = cs42l42->codec; in cs42l42_resume() local
877 struct cs8409_spec *spec = codec->spec; in cs42l42_resume()
879 { CS42L42_CODEC_STATUS, 0x00 }, in cs42l42_resume()
880 { CS42L42_DET_INT_STATUS1, 0x00 }, in cs42l42_resume()
881 { CS42L42_DET_INT_STATUS2, 0x00 }, in cs42l42_resume()
882 { CS42L42_TSRS_PLUG_STATUS, 0x00 }, in cs42l42_resume()
887 spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); in cs42l42_resume()
888 spec->gpio_data |= cs42l42->reset_gpio; in cs42l42_resume()
889 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs42l42_resume()
892 cs42l42->suspended = 0; in cs42l42_resume()
894 /* Initialize CS42L42 companion codec */ in cs42l42_resume()
895 cs8409_i2c_bulk_write(cs42l42, cs42l42->init_seq, cs42l42->init_seq_num); in cs42l42_resume()
901 if (cs42l42->full_scale_vol) { in cs42l42_resume()
913 snd_hda_codec_allow_unsol_events(cs42l42->codec); in cs42l42_resume()
920 struct hda_codec *codec = cs42l42->codec; in cs42l42_suspend() local
921 struct cs8409_spec *spec = codec->spec; in cs42l42_suspend()
922 int reg_cdc_status = 0; in cs42l42_suspend()
924 { CS42L42_DAC_CTL2, 0x02 }, in cs42l42_suspend()
925 { CS42L42_HS_CLAMP_DISABLE, 0x00 }, in cs42l42_suspend()
926 { CS42L42_MIXER_CHA_VOL, 0x3F }, in cs42l42_suspend()
927 { CS42L42_MIXER_ADC_VOL, 0x3F }, in cs42l42_suspend()
928 { CS42L42_MIXER_CHB_VOL, 0x3F }, in cs42l42_suspend()
929 { CS42L42_HP_CTL, 0x0D }, in cs42l42_suspend()
930 { CS42L42_ASP_RX_DAI0_EN, 0x00 }, in cs42l42_suspend()
931 { CS42L42_ASP_CLK_CFG, 0x00 }, in cs42l42_suspend()
932 { CS42L42_PWR_CTL1, 0xFE }, in cs42l42_suspend()
933 { CS42L42_PWR_CTL2, 0x8C }, in cs42l42_suspend()
934 { CS42L42_PWR_CTL1, 0xFF }, in cs42l42_suspend()
940 (reg_cdc_status & 0x1), CS42L42_PDN_SLEEP_US, CS42L42_PDN_TIMEOUT_US, in cs42l42_suspend()
941 true, cs42l42, CS42L42_CODEC_STATUS) < 0) in cs42l42_suspend()
942 codec_warn(codec, "Timeout waiting for PDN_DONE for CS42L42\n"); in cs42l42_suspend()
945 cs8409_i2c_write(cs42l42, CS42L42_PWR_CTL2, 0x9C); in cs42l42_suspend()
946 cs42l42->suspended = 1; in cs42l42_suspend()
947 cs42l42->last_page = 0; in cs42l42_suspend()
948 cs42l42->hp_jack_in = 0; in cs42l42_suspend()
949 cs42l42->mic_jack_in = 0; in cs42l42_suspend()
952 spec->gpio_data = snd_hda_codec_read(codec, CS8409_PIN_AFG, 0, AC_VERB_GET_GPIO_DATA, 0); in cs42l42_suspend()
953 spec->gpio_data &= ~cs42l42->reset_gpio; in cs42l42_suspend()
954 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs42l42_suspend()
957 static void cs8409_free(struct hda_codec *codec) in cs8409_free() argument
959 struct cs8409_spec *spec = codec->spec; in cs8409_free()
962 cancel_delayed_work_sync(&spec->i2c_clk_work); in cs8409_free()
963 cs8409_disable_i2c_clock(codec); in cs8409_free()
965 snd_hda_gen_free(codec); in cs8409_free()
974 * In the case of CS8409 we do not have unsolicited events from NID's 0x24
975 * and 0x34 where hs mic and hp are connected. Companion codec CS42L42 will
980 static void cs8409_cs42l42_jack_unsol_event(struct hda_codec *codec, unsigned int res) in cs8409_cs42l42_jack_unsol_event() argument
982 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_jack_unsol_event()
983 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0]; in cs8409_cs42l42_jack_unsol_event()
991 if (res & cs42l42->irq_mask) in cs8409_cs42l42_jack_unsol_event()
995 snd_hda_set_pin_ctl(codec, CS8409_CS42L42_SPK_PIN_NID, in cs8409_cs42l42_jack_unsol_event()
996 cs42l42->hp_jack_in ? 0 : PIN_OUT); in cs8409_cs42l42_jack_unsol_event()
998 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_HP_PIN_NID, 0); in cs8409_cs42l42_jack_unsol_event()
1000 snd_hda_jack_unsol_event(codec, (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & in cs8409_cs42l42_jack_unsol_event()
1003 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_AMIC_PIN_NID, 0); in cs8409_cs42l42_jack_unsol_event()
1005 snd_hda_jack_unsol_event(codec, (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & in cs8409_cs42l42_jack_unsol_event()
1011 static int cs8409_cs42l42_suspend(struct hda_codec *codec) in cs8409_cs42l42_suspend() argument
1013 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_suspend()
1016 spec->init_done = 0; in cs8409_cs42l42_suspend()
1018 cs8409_enable_ur(codec, 0); in cs8409_cs42l42_suspend()
1020 for (i = 0; i < spec->num_scodecs; i++) in cs8409_cs42l42_suspend()
1021 cs42l42_suspend(spec->scodecs[i]); in cs8409_cs42l42_suspend()
1024 cancel_delayed_work_sync(&spec->i2c_clk_work); in cs8409_cs42l42_suspend()
1025 cs8409_disable_i2c_clock(codec); in cs8409_cs42l42_suspend()
1027 snd_hda_shutup_pins(codec); in cs8409_cs42l42_suspend()
1029 return 0; in cs8409_cs42l42_suspend()
1035 static void cs8409_cs42l42_hw_init(struct hda_codec *codec) in cs8409_cs42l42_hw_init() argument
1039 struct cs8409_spec *spec = codec->spec; in cs8409_cs42l42_hw_init()
1040 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0]; in cs8409_cs42l42_hw_init()
1042 if (spec->gpio_mask) { in cs8409_cs42l42_hw_init()
1043 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_MASK, in cs8409_cs42l42_hw_init()
1044 spec->gpio_mask); in cs8409_cs42l42_hw_init()
1045 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DIRECTION, in cs8409_cs42l42_hw_init()
1046 spec->gpio_dir); in cs8409_cs42l42_hw_init()
1047 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, in cs8409_cs42l42_hw_init()
1048 spec->gpio_data); in cs8409_cs42l42_hw_init()
1051 for (; seq->nid; seq++) in cs8409_cs42l42_hw_init()
1052 cs8409_vendor_coef_set(codec, seq->cir, seq->coeff); in cs8409_cs42l42_hw_init()
1054 if (codec->fixup_id == CS8409_BULLSEYE) { in cs8409_cs42l42_hw_init()
1055 for (; seq_bullseye->nid; seq_bullseye++) in cs8409_cs42l42_hw_init()
1056 cs8409_vendor_coef_set(codec, seq_bullseye->cir, seq_bullseye->coeff); in cs8409_cs42l42_hw_init()
1059 switch (codec->fixup_id) { in cs8409_cs42l42_hw_init()
1063 cs8409_vendor_coef_set(codec, CS8409_DMIC_CFG, 0x0003); in cs8409_cs42l42_hw_init()
1066 /* ASP1/2_xxx_EN=1, ASP1/2_MCLK_EN=0, DMIC1_SCL_EN=0 */ in cs8409_cs42l42_hw_init()
1067 cs8409_vendor_coef_set(codec, CS8409_PAD_CFG_SLW_RATE_CTRL, 0xfc00); in cs8409_cs42l42_hw_init()
1076 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()
1093 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0]; in cs8409_cs42l42_exec_verb()
1095 unsigned int nid = ((cmd >> 20) & 0x07f); in cs8409_cs42l42_exec_verb()
1096 unsigned int verb = ((cmd >> 8) & 0x0fff); in cs8409_cs42l42_exec_verb()
1099 * capabilities. We have to intercept 2 calls for pins 0x24 and 0x34 in cs8409_cs42l42_exec_verb()
1106 *res = (cs42l42->hp_jack_in) ? AC_PINSENSE_PRESENCE : 0; in cs8409_cs42l42_exec_verb()
1107 return 0; in cs8409_cs42l42_exec_verb()
1112 *res = (cs42l42->mic_jack_in) ? AC_PINSENSE_PRESENCE : 0; in cs8409_cs42l42_exec_verb()
1113 return 0; in cs8409_cs42l42_exec_verb()
1120 return spec->exec_verb(dev, cmd, flags, res); 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()
1134 spec->scodecs[CS8409_CODEC0] = &cs8409_cs42l42_codec; in cs8409_cs42l42_fixups()
1135 spec->num_scodecs = 1; 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()
1139 spec->gen.suppress_auto_mute = 1; in cs8409_cs42l42_fixups()
1140 spec->gen.no_primary_hp = 1; in cs8409_cs42l42_fixups()
1141 spec->gen.suppress_vmaster = 1; in cs8409_cs42l42_fixups()
1143 spec->speaker_pdn_gpio = 0; in cs8409_cs42l42_fixups()
1146 spec->gpio_dir = spec->scodecs[CS8409_CODEC0]->reset_gpio; in cs8409_cs42l42_fixups()
1147 spec->gpio_data = 0; in cs8409_cs42l42_fixups()
1148 spec->gpio_mask = 0x03f; 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()
1156 spec->scodecs[CS8409_CODEC0]->hsbias_hiz = 0x0020; in cs8409_cs42l42_fixups()
1158 switch (codec->fixup_id) { in cs8409_cs42l42_fixups()
1160 spec->scodecs[CS8409_CODEC0]->full_scale_vol = in cs8409_cs42l42_fixups()
1162 spec->speaker_pdn_gpio = CS8409_CYBORG_SPEAKER_PDN; in cs8409_cs42l42_fixups()
1165 spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_0DB; in cs8409_cs42l42_fixups()
1166 spec->speaker_pdn_gpio = CS8409_CYBORG_SPEAKER_PDN; in cs8409_cs42l42_fixups()
1170 spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_0DB; in cs8409_cs42l42_fixups()
1171 spec->speaker_pdn_gpio = CS8409_WARLOCK_SPEAKER_PDN; in cs8409_cs42l42_fixups()
1174 spec->scodecs[CS8409_CODEC0]->full_scale_vol = in cs8409_cs42l42_fixups()
1176 spec->speaker_pdn_gpio = CS8409_WARLOCK_SPEAKER_PDN; in cs8409_cs42l42_fixups()
1180 if (spec->speaker_pdn_gpio > 0) { in cs8409_cs42l42_fixups()
1181 spec->gpio_dir |= spec->speaker_pdn_gpio; in cs8409_cs42l42_fixups()
1182 spec->gpio_data |= spec->speaker_pdn_gpio; in cs8409_cs42l42_fixups()
1188 spec->gen.stream_analog_playback = &cs42l42_48k_pcm_analog_playback; in cs8409_cs42l42_fixups()
1189 spec->gen.stream_analog_capture = &cs42l42_48k_pcm_analog_capture; in cs8409_cs42l42_fixups()
1191 spec->gen.pcm_playback_hook = cs42l42_playback_pcm_hook; in cs8409_cs42l42_fixups()
1192 spec->gen.pcm_capture_hook = cs42l42_capture_pcm_hook; in cs8409_cs42l42_fixups()
1193 if (codec->fixup_id != CS8409_ODIN) in cs8409_cs42l42_fixups()
1194 /* Set initial DMIC volume to -26 dB */ in cs8409_cs42l42_fixups()
1195 snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID, in cs8409_cs42l42_fixups()
1196 HDA_INPUT, 0, 0xff, 0x19); in cs8409_cs42l42_fixups()
1197 snd_hda_gen_add_kctl(&spec->gen, "Headphone Playback Volume", in cs8409_cs42l42_fixups()
1199 snd_hda_gen_add_kctl(&spec->gen, "Mic Capture Volume", in cs8409_cs42l42_fixups()
1201 if (spec->speaker_pdn_gpio > 0) in cs8409_cs42l42_fixups()
1202 snd_hda_gen_add_kctl(&spec->gen, "Speaker Playback Switch", 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()
1210 spec->init_done = 1; in cs8409_cs42l42_fixups()
1211 if (spec->init_done && spec->build_ctrl_done in cs8409_cs42l42_fixups()
1212 && !spec->scodecs[CS8409_CODEC0]->hp_jack_in) in cs8409_cs42l42_fixups()
1213 cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]); in cs8409_cs42l42_fixups()
1216 spec->build_ctrl_done = 1; in cs8409_cs42l42_fixups()
1222 if (spec->init_done && spec->build_ctrl_done in cs8409_cs42l42_fixups()
1223 && !spec->scodecs[CS8409_CODEC0]->hp_jack_in) in cs8409_cs42l42_fixups()
1224 cs42l42_run_jack_detect(spec->scodecs[CS8409_CODEC0]); 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()
1249 cs42l42 = spec->scodecs[CS8409_CODEC0]; in dolphin_jack_unsol_event()
1250 if (!cs42l42->suspended && (~res & cs42l42->irq_mask) && 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()
1255 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & 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()
1261 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & in dolphin_jack_unsol_event()
1265 cs42l42 = spec->scodecs[CS8409_CODEC1]; in dolphin_jack_unsol_event()
1266 if (!cs42l42->suspended && (~res & cs42l42->irq_mask) && 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()
1271 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & 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()
1286 if (spec->gpio_mask) { in dolphin_hw_init()
1287 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_MASK, in dolphin_hw_init()
1288 spec->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()
1290 spec->gpio_dir); in dolphin_hw_init()
1291 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, in dolphin_hw_init()
1292 spec->gpio_data); in dolphin_hw_init()
1295 for (; seq->nid; seq++) in dolphin_hw_init()
1296 cs8409_vendor_coef_set(codec, seq->cir, seq->coeff); in dolphin_hw_init()
1298 for (i = 0; i < spec->num_scodecs; i++) { in dolphin_hw_init()
1299 cs42l42 = spec->scodecs[i]; in dolphin_hw_init()
1304 cs8409_enable_ur(codec, 1); in dolphin_hw_init()
1319 struct hda_codec *codec = container_of(dev, struct hda_codec, core); in dolphin_exec_verb() local
1320 struct cs8409_spec *spec = codec->spec; in dolphin_exec_verb()
1321 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0]; in dolphin_exec_verb()
1323 unsigned int nid = ((cmd >> 20) & 0x07f); in dolphin_exec_verb()
1324 unsigned int verb = ((cmd >> 8) & 0x0fff); in dolphin_exec_verb()
1335 cs42l42 = spec->scodecs[CS8409_CODEC1]; in dolphin_exec_verb()
1337 *res = (cs42l42->hp_jack_in) ? AC_PINSENSE_PRESENCE : 0; in dolphin_exec_verb()
1338 return 0; in dolphin_exec_verb()
1343 *res = (cs42l42->mic_jack_in) ? AC_PINSENSE_PRESENCE : 0; in dolphin_exec_verb()
1344 return 0; in dolphin_exec_verb()
1351 return spec->exec_verb(dev, cmd, flags, res); in dolphin_exec_verb()
1354 void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int action) in dolphin_fixups() argument
1356 struct cs8409_spec *spec = codec->spec; in dolphin_fixups()
1362 snd_hda_add_verbs(codec, dolphin_init_verbs); in dolphin_fixups()
1364 spec->exec_verb = codec->core.exec_verb; in dolphin_fixups()
1365 codec->core.exec_verb = dolphin_exec_verb; in dolphin_fixups()
1367 spec->scodecs[CS8409_CODEC0] = &dolphin_cs42l42_0; in dolphin_fixups()
1368 spec->scodecs[CS8409_CODEC0]->codec = codec; in dolphin_fixups()
1369 spec->scodecs[CS8409_CODEC1] = &dolphin_cs42l42_1; in dolphin_fixups()
1370 spec->scodecs[CS8409_CODEC1]->codec = codec; in dolphin_fixups()
1371 spec->num_scodecs = 2; in dolphin_fixups()
1372 spec->gen.suppress_vmaster = 1; in dolphin_fixups()
1374 codec->patch_ops = cs8409_dolphin_patch_ops; in dolphin_fixups()
1376 /* GPIO 1,5 out, 0,4 in */ in dolphin_fixups()
1377 spec->gpio_dir = spec->scodecs[CS8409_CODEC0]->reset_gpio | in dolphin_fixups()
1378 spec->scodecs[CS8409_CODEC1]->reset_gpio; in dolphin_fixups()
1379 spec->gpio_data = 0; in dolphin_fixups()
1380 spec->gpio_mask = 0x03f; in dolphin_fixups()
1383 snd_hda_sequence_write(codec, dolphin_init_verbs); in dolphin_fixups()
1385 snd_hda_jack_add_kctl(codec, DOLPHIN_LO_PIN_NID, "Line Out", true, in dolphin_fixups()
1388 snd_hda_jack_add_kctl(codec, DOLPHIN_AMIC_PIN_NID, "Microphone", true, in dolphin_fixups()
1391 cs8409_fix_caps(codec, DOLPHIN_HP_PIN_NID); in dolphin_fixups()
1392 cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID); in dolphin_fixups()
1393 cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID); in dolphin_fixups()
1395 spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB; in dolphin_fixups()
1396 spec->scodecs[CS8409_CODEC1]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB; in dolphin_fixups()
1401 spec->gen.stream_analog_playback = &cs42l42_48k_pcm_analog_playback; in dolphin_fixups()
1402 spec->gen.stream_analog_capture = &cs42l42_48k_pcm_analog_capture; in dolphin_fixups()
1404 spec->gen.pcm_playback_hook = cs42l42_playback_pcm_hook; in dolphin_fixups()
1405 spec->gen.pcm_capture_hook = cs42l42_capture_pcm_hook; in dolphin_fixups()
1406 snd_hda_gen_add_kctl(&spec->gen, "Headphone Playback Volume", in dolphin_fixups()
1408 snd_hda_gen_add_kctl(&spec->gen, "Mic Capture Volume", &cs42l42_adc_volume_mixer); in dolphin_fixups()
1409 kctrl = snd_hda_gen_add_kctl(&spec->gen, "Line Out Playback Volume", in dolphin_fixups()
1413 kctrl->private_value = HDA_COMPOSE_AMP_VAL_OFS(DOLPHIN_HP_PIN_NID, 3, CS8409_CODEC1, 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()
1420 spec->init_done = 1; in dolphin_fixups()
1421 if (spec->init_done && spec->build_ctrl_done) { in dolphin_fixups()
1422 for (i = 0; i < spec->num_scodecs; i++) { in dolphin_fixups()
1423 if (!spec->scodecs[i]->hp_jack_in) in dolphin_fixups()
1424 cs42l42_run_jack_detect(spec->scodecs[i]); in dolphin_fixups()
1429 spec->build_ctrl_done = 1; in dolphin_fixups()
1435 if (spec->init_done && spec->build_ctrl_done) { in dolphin_fixups()
1436 for (i = 0; i < spec->num_scodecs; i++) { in dolphin_fixups()
1437 if (!spec->scodecs[i]->hp_jack_in) in dolphin_fixups()
1438 cs42l42_run_jack_detect(spec->scodecs[i]); 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()
1452 return -ENOMEM; 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()
1463 if (err < 0) { in patch_cs8409()
1464 cs8409_free(codec); in patch_cs8409()
1468 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs8409()
1469 return 0; in patch_cs8409()
1473 HDA_CODEC_ENTRY(0x10138409, "CS8409", patch_cs8409),