• Home
  • Raw
  • Download

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()
351 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_bulk_write()
353 return 0; in cs8409_i2c_bulk_write()
356 mutex_unlock(&spec->i2c_mux); in cs8409_i2c_bulk_write()
357 codec_err(codec, "I2C Bulk Write Failed 0x%02x\n", scodec->addr); in cs8409_i2c_bulk_write()
358 return -EIO; 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()
376 if (err < 0) in cs8409_build_controls()
378 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); in cs8409_build_controls()
380 return 0; 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()
387 unsigned int ur_gpios = 0; in cs8409_enable_ur()
390 for (i = 0; i < spec->num_scodecs; i++) in cs8409_enable_ur()
391 ur_gpios |= spec->scodecs[i]->irq_mask; 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()
394 flag ? ur_gpios : 0); in cs8409_enable_ur()
396 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_UNSOLICITED_ENABLE, in cs8409_enable_ur()
397 flag ? AC_UNSOL_ENABLED : 0); 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()
415 if (caps >= 0) 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()
428 ucontrol->value.integer.value[0] = !!(spec->gpio_data & spec->speaker_pdn_gpio); in cs8409_spk_sw_gpio_get()
429 return 0; 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()
439 gpio_data = (spec->gpio_data & ~spec->speaker_pdn_gpio) | in cs8409_spk_sw_gpio_put()
440 (ucontrol->value.integer.value[0] ? spec->speaker_pdn_gpio : 0); in cs8409_spk_sw_gpio_put()
441 if (gpio_data == spec->gpio_data) in cs8409_spk_sw_gpio_put()
442 return 0; in cs8409_spk_sw_gpio_put()
443 spec->gpio_data = gpio_data; 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()
464 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in cs42l42_volume_info()
465 uinfo->value.integer.step = 1; in cs42l42_volume_info()
466 uinfo->count = chs == 3 ? 2 : 1; in cs42l42_volume_info()
470 uinfo->value.integer.min = CS42L42_HP_VOL_REAL_MIN; in cs42l42_volume_info()
471 uinfo->value.integer.max = CS42L42_HP_VOL_REAL_MAX; in cs42l42_volume_info()
474 uinfo->value.integer.min = CS42L42_AMIC_VOL_REAL_MIN; in cs42l42_volume_info()
475 uinfo->value.integer.max = CS42L42_AMIC_VOL_REAL_MAX; in cs42l42_volume_info()
481 return 0; in cs42l42_volume_info()
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()
488 struct sub_codec *cs42l42 = spec->scodecs[get_amp_index(kctrl)]; in cs42l42_volume_get()
491 long *valp = uctrl->value.integer.value; in cs42l42_volume_get()
495 if (chs & BIT(0)) in cs42l42_volume_get()
496 *valp++ = cs42l42->vol[ofs]; in cs42l42_volume_get()
498 *valp = cs42l42->vol[ofs+1]; in cs42l42_volume_get()
501 if (chs & BIT(0)) in cs42l42_volume_get()
502 *valp = cs42l42->vol[ofs]; in cs42l42_volume_get()
508 return 0; in cs42l42_volume_get()
516 if (chs & BIT(0)) in cs42l42_mute()
517 cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHA_VOL, 0x3f); in cs42l42_mute()
519 cs8409_i2c_write(cs42l42, CS42L42_MIXER_CHB_VOL, 0x3f); in cs42l42_mute()
521 if (chs & BIT(0)) in cs42l42_mute()
522 cs8409_i2c_write(cs42l42, CS42L42_ADC_VOLUME, 0x9f); in cs42l42_mute()
526 if (chs & BIT(0)) in cs42l42_mute()
528 -(cs42l42->vol[CS42L42_DAC_CH0_VOL_OFFSET]) in cs42l42_mute()
532 -(cs42l42->vol[CS42L42_DAC_CH1_VOL_OFFSET]) in cs42l42_mute()
535 if (chs & BIT(0)) in cs42l42_mute()
537 cs42l42->vol[CS42L42_ADC_VOL_OFFSET] in cs42l42_mute()
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()
547 struct sub_codec *cs42l42 = spec->scodecs[get_amp_index(kctrl)]; in cs42l42_volume_put()
550 long *valp = uctrl->value.integer.value; in cs42l42_volume_put()
554 if (chs & BIT(0)) in cs42l42_volume_put()
555 cs42l42->vol[ofs] = *valp; in cs42l42_volume_put()
558 cs42l42->vol[ofs + 1] = *valp; in cs42l42_volume_put()
560 if (spec->playback_started) in cs42l42_volume_put()
564 if (chs & BIT(0)) in cs42l42_volume_put()
565 cs42l42->vol[ofs] = *valp; in cs42l42_volume_put()
566 if (spec->capture_started) in cs42l42_volume_put()
573 return 0; 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()
589 spec->playback_started = 1; in cs42l42_playback_pcm_hook()
593 spec->playback_started = 0; in cs42l42_playback_pcm_hook()
599 for (i = 0; i < spec->num_scodecs; i++) { in cs42l42_playback_pcm_hook()
600 cs42l42 = spec->scodecs[i]; in cs42l42_playback_pcm_hook()
601 cs42l42_mute(cs42l42, CS42L42_VOL_DAC, 0x3, mute); 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()
618 spec->capture_started = 1; in cs42l42_capture_pcm_hook()
622 spec->capture_started = 0; in cs42l42_capture_pcm_hook()
628 for (i = 0; i < spec->num_scodecs; i++) { in cs42l42_capture_pcm_hook()
629 cs42l42 = spec->scodecs[i]; in cs42l42_capture_pcm_hook()
630 cs42l42_mute(cs42l42, CS42L42_VOL_ADC, 0x3, mute); in cs42l42_capture_pcm_hook()
634 /* Configure CS42L42 slave codec for jack autodetect */
637 cs8409_i2c_write(cs42l42, CS42L42_HSBIAS_SC_AUTOCTL, cs42l42->hsbias_hiz); in cs42l42_enable_jack_detect()
639 cs8409_i2c_write(cs42l42, CS42L42_WAKE_CTL, 0x00C1); in cs42l42_enable_jack_detect()
643 cs8409_i2c_write(cs42l42, CS42L42_WAKE_CTL, 0x00C0); in cs42l42_enable_jack_detect()
647 cs8409_i2c_write(cs42l42, CS42L42_TSRS_PLUG_INT_MASK, 0xF3); in cs42l42_enable_jack_detect()
650 /* Enable and run CS42L42 slave codec jack auto detect */
656 cs8409_i2c_write(cs42l42, CS42L42_TSRS_PLUG_INT_MASK, 0xFF); in cs42l42_run_jack_detect()
659 cs8409_i2c_write(cs42l42, CS42L42_PWR_CTL2, 0x87); in cs42l42_run_jack_detect()
660 cs8409_i2c_write(cs42l42, CS42L42_DAC_CTL2, 0x86); in cs42l42_run_jack_detect()
661 cs8409_i2c_write(cs42l42, CS42L42_MISC_DET_CTL, 0x07); in cs42l42_run_jack_detect()
662 cs8409_i2c_write(cs42l42, CS42L42_CODEC_INT_MASK, 0xFD); in cs42l42_run_jack_detect()
663 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL2, 0x80); in cs42l42_run_jack_detect()
666 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL1, 0x77); in cs42l42_run_jack_detect()
667 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL2, 0xc0); in cs42l42_run_jack_detect()
681 (0 << CS42L42_HSDET_SET_SHIFT) | in cs42l42_manual_hs_det()
682 (0 << CS42L42_HSBIAS_REF_SHIFT) | in cs42l42_manual_hs_det()
683 (0 << CS42L42_HSDET_AUTO_TIME_SHIFT)); in cs42l42_manual_hs_det()
751 (0 << CS42L42_HSDET_CTRL_SHIFT) | in cs42l42_manual_hs_det()
752 (0 << CS42L42_HSDET_SET_SHIFT) | in cs42l42_manual_hs_det()
753 (0 << CS42L42_HSBIAS_REF_SHIFT) | in cs42l42_manual_hs_det()
754 (0 << CS42L42_HSDET_AUTO_TIME_SHIFT)); in cs42l42_manual_hs_det()
766 int status_changed = 0; in cs42l42_handle_tip_sense()
771 if (cs42l42->no_type_dect) { in cs42l42_handle_tip_sense()
773 cs42l42->hp_jack_in = 1; in cs42l42_handle_tip_sense()
774 cs42l42->mic_jack_in = 0; in cs42l42_handle_tip_sense()
782 cs42l42->hp_jack_in = 0; in cs42l42_handle_tip_sense()
783 cs42l42->mic_jack_in = 0; in cs42l42_handle_tip_sense()
790 codec_dbg(cs42l42->codec, "Tip Sense Detection: (%d)\n", reg_ts_status); in cs42l42_handle_tip_sense()
798 int status_changed = 0; in cs42l42_jack_unsol_event()
809 /* If status values are < 0, read error has occurred. */ in cs42l42_jack_unsol_event()
810 if (reg_cdc_status < 0 || reg_hs_status < 0 || reg_ts_status < 0) in cs42l42_jack_unsol_event()
811 return -EIO; in cs42l42_jack_unsol_event()
820 cs8409_i2c_write(cs42l42, CS42L42_CODEC_INT_MASK, 0xFF); in cs42l42_jack_unsol_event()
825 cs8409_i2c_write(cs42l42, CS42L42_HSDET_CTL2, 0x80); in cs42l42_jack_unsol_event()
827 if (cs42l42->no_type_dect) { in cs42l42_jack_unsol_event()
831 codec_dbg(cs42l42->codec, in cs42l42_jack_unsol_event()
841 cs42l42->hp_jack_in = 1; in cs42l42_jack_unsol_event()
842 cs42l42->mic_jack_in = 1; in cs42l42_jack_unsol_event()
846 cs42l42->hp_jack_in = 1; in cs42l42_jack_unsol_event()
847 cs42l42->mic_jack_in = 0; in cs42l42_jack_unsol_event()
851 cs42l42->hp_jack_in = 0; in cs42l42_jack_unsol_event()
852 cs42l42->mic_jack_in = 0; in cs42l42_jack_unsol_event()
855 codec_dbg(cs42l42->codec, "Detection done (%d)\n", type); in cs42l42_jack_unsol_event()
858 /* Enable the HPOUT ground clamp and configure the HP pull-down */ in cs42l42_jack_unsol_event()
859 cs8409_i2c_write(cs42l42, CS42L42_DAC_CTL2, 0x02); in cs42l42_jack_unsol_event()
860 /* Re-Enable Tip Sense Interrupt */ in cs42l42_jack_unsol_event()
861 cs8409_i2c_write(cs42l42, CS42L42_TSRS_PLUG_INT_MASK, 0xF3); 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()
874 { CS42L42_CODEC_STATUS, 0x00 }, in cs42l42_resume()
875 { CS42L42_DET_INT_STATUS1, 0x00 }, in cs42l42_resume()
876 { CS42L42_DET_INT_STATUS2, 0x00 }, in cs42l42_resume()
877 { CS42L42_TSRS_PLUG_STATUS, 0x00 }, 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()
883 spec->gpio_data |= cs42l42->reset_gpio; in cs42l42_resume()
884 snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs42l42_resume()
887 cs42l42->suspended = 0; in cs42l42_resume()
889 /* Initialize CS42L42 companion codec */ in cs42l42_resume()
890 cs8409_i2c_bulk_write(cs42l42, cs42l42->init_seq, cs42l42->init_seq_num); in cs42l42_resume()
897 if (cs42l42->full_scale_vol == CS42L42_FULL_SCALE_VOL_0DB) 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()
917 int reg_cdc_status = 0; in cs42l42_suspend()
919 { CS42L42_DAC_CTL2, 0x02 }, in cs42l42_suspend()
920 { CS42L42_HS_CLAMP_DISABLE, 0x00 }, in cs42l42_suspend()
921 { CS42L42_MIXER_CHA_VOL, 0x3F }, in cs42l42_suspend()
922 { CS42L42_MIXER_ADC_VOL, 0x3F }, in cs42l42_suspend()
923 { CS42L42_MIXER_CHB_VOL, 0x3F }, in cs42l42_suspend()
924 { CS42L42_HP_CTL, 0x0F }, in cs42l42_suspend()
925 { CS42L42_ASP_RX_DAI0_EN, 0x00 }, in cs42l42_suspend()
926 { CS42L42_ASP_CLK_CFG, 0x00 }, in cs42l42_suspend()
927 { CS42L42_PWR_CTL1, 0xFE }, in cs42l42_suspend()
928 { CS42L42_PWR_CTL2, 0x8C }, in cs42l42_suspend()
929 { CS42L42_PWR_CTL1, 0xFF }, in cs42l42_suspend()
935 (reg_cdc_status & 0x1), CS42L42_PDN_SLEEP_US, CS42L42_PDN_TIMEOUT_US, in cs42l42_suspend()
936 true, cs42l42, CS42L42_CODEC_STATUS) < 0) in cs42l42_suspend()
937 codec_warn(codec, "Timeout waiting for PDN_DONE for CS42L42\n"); in cs42l42_suspend()
940 cs8409_i2c_write(cs42l42, CS42L42_PWR_CTL2, 0x9C); in cs42l42_suspend()
941 cs42l42->suspended = 1; in cs42l42_suspend()
942 cs42l42->last_page = 0; in cs42l42_suspend()
943 cs42l42->hp_jack_in = 0; in cs42l42_suspend()
944 cs42l42->mic_jack_in = 0; 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()
948 spec->gpio_data &= ~cs42l42->reset_gpio; 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()
958 cancel_delayed_work_sync(&spec->i2c_clk_work); in cs8409_free()
959 cs8409_disable_i2c_clock(codec); in cs8409_free()
961 snd_hda_gen_free(codec); in cs8409_free()
970 * In the case of CS8409 we do not have unsolicited events from NID's 0x24
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()
979 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0]; in cs8409_cs42l42_jack_unsol_event()
987 if (res & cs42l42->irq_mask) in cs8409_cs42l42_jack_unsol_event()
991 snd_hda_set_pin_ctl(codec, CS8409_CS42L42_SPK_PIN_NID, in cs8409_cs42l42_jack_unsol_event()
992 cs42l42->hp_jack_in ? 0 : PIN_OUT); 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()
1013 spec->init_done = 0; in cs8409_cs42l42_suspend()
1015 cs8409_enable_ur(codec, 0); in cs8409_cs42l42_suspend()
1017 for (i = 0; i < spec->num_scodecs; i++) in cs8409_cs42l42_suspend()
1018 cs42l42_suspend(spec->scodecs[i]); in cs8409_cs42l42_suspend()
1021 cancel_delayed_work_sync(&spec->i2c_clk_work); in cs8409_cs42l42_suspend()
1022 cs8409_disable_i2c_clock(codec); in cs8409_cs42l42_suspend()
1024 snd_hda_shutup_pins(codec); in cs8409_cs42l42_suspend()
1026 return 0; 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()
1038 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0]; in cs8409_cs42l42_hw_init()
1040 if (spec->gpio_mask) { 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()
1042 spec->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()
1044 spec->gpio_dir); 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()
1046 spec->gpio_data); in cs8409_cs42l42_hw_init()
1049 for (; seq->nid; seq++) 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()
1053 for (; seq_bullseye->nid; seq_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()
1064 /* ASP1/2_xxx_EN=1, ASP1/2_MCLK_EN=0, DMIC1_SCL_EN=0 */ 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()
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()
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()
1323 struct sub_codec *cs42l42 = spec->scodecs[CS8409_CODEC0]; in dolphin_exec_verb()
1325 unsigned int nid = ((cmd >> 20) & 0x07f); in dolphin_exec_verb()
1326 unsigned int verb = ((cmd >> 8) & 0x0fff); in dolphin_exec_verb()
1337 cs42l42 = spec->scodecs[CS8409_CODEC1]; in dolphin_exec_verb()
1339 *res = (cs42l42->hp_jack_in) ? AC_PINSENSE_PRESENCE : 0; in dolphin_exec_verb()
1340 return 0; in dolphin_exec_verb()
1345 *res = (cs42l42->mic_jack_in) ? AC_PINSENSE_PRESENCE : 0; in dolphin_exec_verb()
1346 return 0; in dolphin_exec_verb()
1353 return spec->exec_verb(dev, cmd, flags, res); 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()
1369 spec->scodecs[CS8409_CODEC0] = &dolphin_cs42l42_0; in dolphin_fixups()
1370 spec->scodecs[CS8409_CODEC0]->codec = codec; in dolphin_fixups()
1371 spec->scodecs[CS8409_CODEC1] = &dolphin_cs42l42_1; in dolphin_fixups()
1372 spec->scodecs[CS8409_CODEC1]->codec = codec; in dolphin_fixups()
1373 spec->num_scodecs = 2; in dolphin_fixups()
1374 spec->gen.suppress_vmaster = 1; in dolphin_fixups()
1376 codec->patch_ops = cs8409_dolphin_patch_ops; in dolphin_fixups()
1378 /* GPIO 1,5 out, 0,4 in */ in dolphin_fixups()
1379 spec->gpio_dir = spec->scodecs[CS8409_CODEC0]->reset_gpio | in dolphin_fixups()
1380 spec->scodecs[CS8409_CODEC1]->reset_gpio; in dolphin_fixups()
1381 spec->gpio_data = 0; in dolphin_fixups()
1382 spec->gpio_mask = 0x03f; in dolphin_fixups()
1385 snd_hda_sequence_write(codec, dolphin_init_verbs); in dolphin_fixups()
1387 snd_hda_jack_add_kctl(codec, DOLPHIN_LO_PIN_NID, "Line Out", true, in dolphin_fixups()
1390 snd_hda_jack_add_kctl(codec, DOLPHIN_AMIC_PIN_NID, "Microphone", true, in dolphin_fixups()
1393 cs8409_fix_caps(codec, DOLPHIN_HP_PIN_NID); in dolphin_fixups()
1394 cs8409_fix_caps(codec, DOLPHIN_LO_PIN_NID); in dolphin_fixups()
1395 cs8409_fix_caps(codec, DOLPHIN_AMIC_PIN_NID); in dolphin_fixups()
1397 spec->scodecs[CS8409_CODEC0]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB; in dolphin_fixups()
1398 spec->scodecs[CS8409_CODEC1]->full_scale_vol = CS42L42_FULL_SCALE_VOL_MINUS6DB; in dolphin_fixups()
1403 spec->gen.stream_analog_playback = &cs42l42_48k_pcm_analog_playback; in dolphin_fixups()
1404 spec->gen.stream_analog_capture = &cs42l42_48k_pcm_analog_capture; in dolphin_fixups()
1406 spec->gen.pcm_playback_hook = cs42l42_playback_pcm_hook; in dolphin_fixups()
1407 spec->gen.pcm_capture_hook = cs42l42_capture_pcm_hook; in dolphin_fixups()
1408 snd_hda_gen_add_kctl(&spec->gen, "Headphone Playback Volume", in dolphin_fixups()
1410 snd_hda_gen_add_kctl(&spec->gen, "Mic Capture Volume", &cs42l42_adc_volume_mixer); in dolphin_fixups()
1411 kctrl = snd_hda_gen_add_kctl(&spec->gen, "Line Out Playback Volume", in dolphin_fixups()
1414 kctrl->private_value = HDA_COMPOSE_AMP_VAL_OFS(DOLPHIN_HP_PIN_NID, 3, CS8409_CODEC1, in dolphin_fixups()
1416 cs8409_enable_ur(codec, 0); in dolphin_fixups()
1417 snd_hda_codec_set_name(codec, "CS8409/CS42L42"); in dolphin_fixups()
1420 dolphin_hw_init(codec); in dolphin_fixups()
1421 spec->init_done = 1; in dolphin_fixups()
1422 if (spec->init_done && spec->build_ctrl_done) { in dolphin_fixups()
1423 for (i = 0; i < spec->num_scodecs; i++) { in dolphin_fixups()
1424 if (!spec->scodecs[i]->hp_jack_in) in dolphin_fixups()
1425 cs42l42_run_jack_detect(spec->scodecs[i]); in dolphin_fixups()
1430 spec->build_ctrl_done = 1; in dolphin_fixups()
1436 if (spec->init_done && spec->build_ctrl_done) { in dolphin_fixups()
1437 for (i = 0; i < spec->num_scodecs; i++) { in dolphin_fixups()
1438 if (!spec->scodecs[i]->hp_jack_in) in dolphin_fixups()
1439 cs42l42_run_jack_detect(spec->scodecs[i]); in dolphin_fixups()
1448 static int patch_cs8409(struct hda_codec *codec) in patch_cs8409() argument
1452 if (!cs8409_alloc_spec(codec)) in patch_cs8409()
1453 return -ENOMEM; in patch_cs8409()
1455 snd_hda_pick_fixup(codec, cs8409_models, cs8409_fixup_tbl, cs8409_fixups); in patch_cs8409()
1457 codec_dbg(codec, "Picked ID=%d, VID=%08x, DEV=%08x\n", codec->fixup_id, in patch_cs8409()
1458 codec->bus->pci->subsystem_vendor, in patch_cs8409()
1459 codec->bus->pci->subsystem_device); in patch_cs8409()
1461 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs8409()
1463 err = cs8409_parse_auto_config(codec); in patch_cs8409()
1464 if (err < 0) { in patch_cs8409()
1465 cs8409_free(codec); in patch_cs8409()
1469 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs8409()
1470 return 0; in patch_cs8409()
1474 HDA_CODEC_ENTRY(0x10138409, "CS8409", patch_cs8409),