Lines Matching +full:codec +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-or-later
65 /* Vendor-specific processing widget */
66 #define CS420X_VENDOR_NID 0x11
67 #define CS_DIG_OUT1_PIN_NID 0x10
68 #define CS_DIG_OUT2_PIN_NID 0x15
69 #define CS_DMIC1_PIN_NID 0x0e
70 #define CS_DMIC2_PIN_NID 0x12
73 #define IDX_SPDIF_STAT 0x0000
74 #define IDX_SPDIF_CTL 0x0001
75 #define IDX_ADC_CFG 0x0002
77 * 0 = immediate,
78 * 1 = digital immediate, analog zero-cross
79 * 2 = digtail & analog soft-ramp
80 * 3 = digital soft-ramp, analog zero-cross
82 #define CS_COEF_ADC_SZC_MASK (3 << 0)
83 #define CS_COEF_ADC_MIC_SZC_MODE (3 << 0) /* SZC setup for mic */
84 #define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */
85 /* PGA mode: 0 = differential, 1 = signle-ended */
87 #define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */
88 #define IDX_DAC_CFG 0x0003
90 * 0 = Immediate
91 * 1 = zero-cross
92 * 2 = soft-ramp
93 * 3 = soft-ramp on zero-cross
95 #define CS_COEF_DAC_HP_SZC_MODE (3 << 0) /* nid 0x02 */
96 #define CS_COEF_DAC_LO_SZC_MODE (3 << 2) /* nid 0x03 */
97 #define CS_COEF_DAC_SPK_SZC_MODE (3 << 4) /* nid 0x04 */
99 #define IDX_BEEP_CFG 0x0004
100 /* 0x0008 - test reg key */
101 /* 0x0009 - 0x0014 -> 12 test regs */
102 /* 0x0015 - visibility reg */
105 #define CS4208_VENDOR_NID 0x24
114 #define CS4210_DAC_NID 0x02
115 #define CS4210_ADC_NID 0x03
116 #define CS4210_VENDOR_NID 0x0B
117 #define CS421X_DMIC_PIN_NID 0x09 /* Port E */
118 #define CS421X_SPDIF_PIN_NID 0x0A /* Port H */
120 #define CS421X_IDX_DEV_CFG 0x01
121 #define CS421X_IDX_ADC_CFG 0x02
122 #define CS421X_IDX_DAC_CFG 0x03
123 #define CS421X_IDX_SPK_CTL 0x04
126 #define CS4213_VENDOR_NID 0x09
129 static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx) in cs_vendor_coef_get() argument
131 struct cs_spec *spec = codec->spec; in cs_vendor_coef_get()
132 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_get()
134 return snd_hda_codec_read(codec, spec->vendor_nid, 0, in cs_vendor_coef_get()
135 AC_VERB_GET_PROC_COEF, 0); in cs_vendor_coef_get()
138 static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx, in cs_vendor_coef_set() argument
141 struct cs_spec *spec = codec->spec; in cs_vendor_coef_set()
142 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_set()
144 snd_hda_codec_write(codec, spec->vendor_nid, 0, in cs_vendor_coef_set()
149 * auto-mute and auto-mic switching
150 * CS421x auto-output redirecting
154 static void cs_automute(struct hda_codec *codec) in cs_automute() argument
156 struct cs_spec *spec = codec->spec; in cs_automute()
159 spec->gen.master_mute = !!(spec->spdif_present && spec->sense_b); in cs_automute()
161 snd_hda_gen_update_outputs(codec); in cs_automute()
163 if (spec->gpio_eapd_hp || spec->gpio_eapd_speaker) { in cs_automute()
164 if (spec->gen.automute_speaker) in cs_automute()
165 spec->gpio_data = spec->gen.hp_jack_present ? in cs_automute()
166 spec->gpio_eapd_hp : spec->gpio_eapd_speaker; in cs_automute()
168 spec->gpio_data = in cs_automute()
169 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs_automute()
170 snd_hda_codec_write(codec, 0x01, 0, in cs_automute()
171 AC_VERB_SET_GPIO_DATA, spec->gpio_data); in cs_automute()
175 static bool is_active_pin(struct hda_codec *codec, hda_nid_t nid) in is_active_pin() argument
178 val = snd_hda_codec_get_pincfg(codec, nid); in is_active_pin()
182 static void init_input_coef(struct hda_codec *codec) in init_input_coef() argument
184 struct cs_spec *spec = codec->spec; in init_input_coef()
188 if (spec->vendor_nid == CS420X_VENDOR_NID) { in init_input_coef()
189 coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG); in init_input_coef()
190 if (is_active_pin(codec, CS_DMIC2_PIN_NID)) in init_input_coef()
192 if (is_active_pin(codec, CS_DMIC1_PIN_NID)) in init_input_coef()
198 cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef); in init_input_coef()
203 {0x11, AC_VERB_SET_PROC_STATE, 1},
204 {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG},
205 {0x11, AC_VERB_SET_PROC_COEF,
206 (0x002a /* DAC1/2/3 SZCMode Soft Ramp */
207 | 0x0040 /* Mute DACs on FIFO error */
208 | 0x1000 /* Enable DACs High Pass Filter */
209 | 0x0400 /* Disable Coefficient Auto increment */
211 /* ADC1/2 - Digital and Analog Soft Ramp */
212 {0x11, AC_VERB_SET_COEF_INDEX, IDX_ADC_CFG},
213 {0x11, AC_VERB_SET_PROC_COEF, 0x000a},
215 {0x11, AC_VERB_SET_COEF_INDEX, IDX_BEEP_CFG},
216 {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */
222 {0x01, AC_VERB_SET_POWER_STATE, 0x00}, /* AFG: D0 */
223 {0x24, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
224 {0x24, AC_VERB_SET_COEF_INDEX, 0x0033},
225 {0x24, AC_VERB_SET_PROC_COEF, 0x0001}, /* A1 ICS */
226 {0x24, AC_VERB_SET_COEF_INDEX, 0x0034},
227 {0x24, AC_VERB_SET_PROC_COEF, 0x1C01}, /* A1 Enable, A Thresh = 300mV */
250 {0x01, AC_VERB_SET_POWER_STATE, 0x00}, /* AFG: D0 */
251 {0x11, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
253 {0x11, AC_VERB_SET_COEF_INDEX, 0x0008},
254 {0x11, AC_VERB_SET_PROC_COEF, 0x9999},
255 {0x11, AC_VERB_SET_COEF_INDEX, 0x0017},
256 {0x11, AC_VERB_SET_PROC_COEF, 0xa412},
257 {0x11, AC_VERB_SET_COEF_INDEX, 0x0001},
258 {0x11, AC_VERB_SET_PROC_COEF, 0x0009},
260 {0x07, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Rx: D0 */
261 {0x08, AC_VERB_SET_POWER_STATE, 0x00}, /* S/PDIF Tx: D0 */
263 {0x11, AC_VERB_SET_COEF_INDEX, 0x0017},
264 {0x11, AC_VERB_SET_PROC_COEF, 0x2412},
265 {0x11, AC_VERB_SET_COEF_INDEX, 0x0008},
266 {0x11, AC_VERB_SET_PROC_COEF, 0x0000},
267 {0x11, AC_VERB_SET_COEF_INDEX, 0x0001},
268 {0x11, AC_VERB_SET_PROC_COEF, 0x0008},
269 {0x11, AC_VERB_SET_PROC_STATE, 0x00},
271 #if 0 /* Don't to set to D3 as we are in power-up sequence */
272 {0x07, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Rx: D3 */
273 {0x08, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Tx: D3 */
274 /*{0x01, AC_VERB_SET_POWER_STATE, 0x03},*/ /* AFG: D3 This is already handled */
281 static void init_digital_coef(struct hda_codec *codec) in init_digital_coef() argument
285 coef = 0x0002; /* SRC_MUTE soft-mute on SPDIF (if no lock) */ in init_digital_coef()
286 coef |= 0x0008; /* Replace with mute on error */ in init_digital_coef()
287 if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID)) in init_digital_coef()
288 coef |= 0x4000; /* RX to TX1 or TX2 Loopthru / SPDIF2 in init_digital_coef()
292 cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef); in init_digital_coef()
295 static int cs_init(struct hda_codec *codec) in cs_init() argument
297 struct cs_spec *spec = codec->spec; in cs_init()
299 if (spec->vendor_nid == CS420X_VENDOR_NID) { in cs_init()
301 snd_hda_sequence_write(codec, cs_errata_init_verbs); in cs_init()
302 snd_hda_sequence_write(codec, cs_coef_init_verbs); in cs_init()
303 } else if (spec->vendor_nid == CS4208_VENDOR_NID) { in cs_init()
304 snd_hda_sequence_write(codec, cs4208_coef_init_verbs); in cs_init()
307 snd_hda_gen_init(codec); in cs_init()
309 if (spec->gpio_mask) { in cs_init()
310 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, in cs_init()
311 spec->gpio_mask); in cs_init()
312 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, in cs_init()
313 spec->gpio_dir); in cs_init()
314 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, in cs_init()
315 spec->gpio_data); in cs_init()
318 if (spec->vendor_nid == CS420X_VENDOR_NID) { in cs_init()
319 init_input_coef(codec); in cs_init()
320 init_digital_coef(codec); in cs_init()
323 return 0; in cs_init()
326 static int cs_build_controls(struct hda_codec *codec) in cs_build_controls() argument
330 err = snd_hda_gen_build_controls(codec); in cs_build_controls()
331 if (err < 0) in cs_build_controls()
333 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD); in cs_build_controls()
334 return 0; in cs_build_controls()
347 static int cs_parse_auto_config(struct hda_codec *codec) in cs_parse_auto_config() argument
349 struct cs_spec *spec = codec->spec; in cs_parse_auto_config()
353 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in cs_parse_auto_config()
354 if (err < 0) in cs_parse_auto_config()
357 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs_parse_auto_config()
358 if (err < 0) in cs_parse_auto_config()
362 if (spec->gen.dyn_adc_switch) { in cs_parse_auto_config()
363 unsigned int done = 0; in cs_parse_auto_config()
364 for (i = 0; i < spec->gen.input_mux.num_items; i++) { in cs_parse_auto_config()
365 int idx = spec->gen.dyn_adc_idx[i]; in cs_parse_auto_config()
368 snd_hda_gen_fix_pin_power(codec, in cs_parse_auto_config()
369 spec->gen.adc_nids[idx]); in cs_parse_auto_config()
374 return 0; in cs_parse_auto_config()
390 SND_PCI_QUIRK(0x10de, 0x0ac0, "MacBookPro 5,3", CS420X_MBP53),
391 SND_PCI_QUIRK(0x10de, 0x0d94, "MacBookAir 3,1(2)", CS420X_MBP55),
392 SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55),
393 SND_PCI_QUIRK(0x10de, 0xcb89, "MacBookPro 7,1", CS420X_MBP55),
395 /*SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),*/
397 /* codec SSID */
398 SND_PCI_QUIRK(0x106b, 0x0600, "iMac 14,1", CS420X_IMAC27_122),
399 SND_PCI_QUIRK(0x106b, 0x0900, "iMac 12,1", CS420X_IMAC27_122),
400 SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
401 SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
402 SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
403 SND_PCI_QUIRK(0x106b, 0x5600, "MacBookAir 5,2", CS420X_MBP81),
404 SND_PCI_QUIRK(0x106b, 0x5b00, "MacBookAir 4,2", CS420X_MBA42),
405 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS420X_APPLE),
410 { 0x09, 0x012b4050 },
411 { 0x0a, 0x90100141 },
412 { 0x0b, 0x90100140 },
413 { 0x0c, 0x018b3020 },
414 { 0x0d, 0x90a00110 },
415 { 0x0e, 0x400000f0 },
416 { 0x0f, 0x01cbe030 },
417 { 0x10, 0x014be060 },
418 { 0x12, 0x400000f0 },
419 { 0x15, 0x400000f0 },
424 { 0x09, 0x012b4030 },
425 { 0x0a, 0x90100121 },
426 { 0x0b, 0x90100120 },
427 { 0x0c, 0x400000f0 },
428 { 0x0d, 0x90a00110 },
429 { 0x0e, 0x400000f0 },
430 { 0x0f, 0x400000f0 },
431 { 0x10, 0x014be040 },
432 { 0x12, 0x400000f0 },
433 { 0x15, 0x400000f0 },
438 { 0x09, 0x012b4050 },
439 { 0x0a, 0x90100140 },
440 { 0x0b, 0x90100142 },
441 { 0x0c, 0x018b3020 },
442 { 0x0d, 0x90a00110 },
443 { 0x0e, 0x400000f0 },
444 { 0x0f, 0x01cbe030 },
445 { 0x10, 0x014be060 },
446 { 0x12, 0x01ab9070 },
447 { 0x15, 0x400000f0 },
452 { 0x0d, 0x40ab90f0 },
453 { 0x0e, 0x90a600f0 },
454 { 0x12, 0x50a600f0 },
459 { 0x09, 0x012b4030 }, /* HP */
460 { 0x0a, 0x400000f0 },
461 { 0x0b, 0x90100120 }, /* speaker */
462 { 0x0c, 0x400000f0 },
463 { 0x0d, 0x90a00110 }, /* mic */
464 { 0x0e, 0x400000f0 },
465 { 0x0f, 0x400000f0 },
466 { 0x10, 0x400000f0 },
467 { 0x12, 0x400000f0 },
468 { 0x15, 0x400000f0 },
473 { 0x10, 0x032120f0 }, /* HP */
474 { 0x11, 0x500000f0 },
475 { 0x12, 0x90100010 }, /* Speaker */
476 { 0x13, 0x500000f0 },
477 { 0x14, 0x500000f0 },
478 { 0x15, 0x770000f0 },
479 { 0x16, 0x770000f0 },
480 { 0x17, 0x430000f0 },
481 { 0x18, 0x43ab9030 }, /* Mic */
482 { 0x19, 0x770000f0 },
483 { 0x1a, 0x770000f0 },
484 { 0x1b, 0x770000f0 },
485 { 0x1c, 0x90a00090 },
486 { 0x1d, 0x500000f0 },
487 { 0x1e, 0x500000f0 },
488 { 0x1f, 0x500000f0 },
489 { 0x20, 0x500000f0 },
490 { 0x21, 0x430000f0 },
491 { 0x22, 0x430000f0 },
495 static void cs420x_fixup_gpio_13(struct hda_codec *codec, in cs420x_fixup_gpio_13() argument
499 struct cs_spec *spec = codec->spec; in cs420x_fixup_gpio_13()
500 spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ in cs420x_fixup_gpio_13()
501 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ in cs420x_fixup_gpio_13()
502 spec->gpio_mask = spec->gpio_dir = in cs420x_fixup_gpio_13()
503 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs420x_fixup_gpio_13()
507 static void cs420x_fixup_gpio_23(struct hda_codec *codec, in cs420x_fixup_gpio_23() argument
511 struct cs_spec *spec = codec->spec; in cs420x_fixup_gpio_23()
512 spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ in cs420x_fixup_gpio_23()
513 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ in cs420x_fixup_gpio_23()
514 spec->gpio_mask = spec->gpio_dir = in cs420x_fixup_gpio_23()
515 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs420x_fixup_gpio_23()
556 {0x11, AC_VERB_SET_COEF_INDEX, IDX_ADC_CFG},
557 {0x11, AC_VERB_SET_PROC_COEF, 0x102a},
571 static struct cs_spec *cs_alloc_spec(struct hda_codec *codec, int vendor_nid) in cs_alloc_spec() argument
578 codec->spec = spec; in cs_alloc_spec()
579 spec->vendor_nid = vendor_nid; in cs_alloc_spec()
580 codec->power_save_node = 1; in cs_alloc_spec()
581 snd_hda_gen_spec_init(&spec->gen); in cs_alloc_spec()
586 static int patch_cs420x(struct hda_codec *codec) in patch_cs420x() argument
591 spec = cs_alloc_spec(codec, CS420X_VENDOR_NID); in patch_cs420x()
593 return -ENOMEM; in patch_cs420x()
595 codec->patch_ops = cs_patch_ops; in patch_cs420x()
596 spec->gen.automute_hook = cs_automute; in patch_cs420x()
597 codec->single_adc_amp = 1; in patch_cs420x()
599 snd_hda_pick_fixup(codec, cs420x_models, cs420x_fixup_tbl, in patch_cs420x()
601 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs420x()
603 err = cs_parse_auto_config(codec); in patch_cs420x()
604 if (err < 0) in patch_cs420x()
607 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs420x()
609 return 0; in patch_cs420x()
612 cs_free(codec); in patch_cs420x()
637 SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS4208_MAC_AUTO),
641 /* codec SSID matching */
643 SND_PCI_QUIRK(0x106b, 0x5e00, "MacBookPro 11,2", CS4208_MBP11),
644 SND_PCI_QUIRK(0x106b, 0x6c00, "MacMini 7,1", CS4208_MACMINI),
645 SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6),
646 SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6),
647 SND_PCI_QUIRK(0x106b, 0x7b00, "MacBookPro 12,1", CS4208_MBP11),
651 static void cs4208_fixup_gpio0(struct hda_codec *codec, in cs4208_fixup_gpio0() argument
655 struct cs_spec *spec = codec->spec; in cs4208_fixup_gpio0()
656 spec->gpio_eapd_hp = 0; in cs4208_fixup_gpio0()
657 spec->gpio_eapd_speaker = 1; in cs4208_fixup_gpio0()
658 spec->gpio_mask = spec->gpio_dir = in cs4208_fixup_gpio0()
659 spec->gpio_eapd_hp | spec->gpio_eapd_speaker; in cs4208_fixup_gpio0()
665 /* remap the fixup from codec SSID and apply it */
666 static void cs4208_fixup_mac(struct hda_codec *codec, in cs4208_fixup_mac() argument
672 codec->fixup_id = HDA_FIXUP_ID_NOT_SET; in cs4208_fixup_mac()
673 snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups); in cs4208_fixup_mac()
674 if (codec->fixup_id == HDA_FIXUP_ID_NOT_SET) in cs4208_fixup_mac()
675 codec->fixup_id = CS4208_GPIO0; /* default fixup */ in cs4208_fixup_mac()
676 snd_hda_apply_fixup(codec, action); in cs4208_fixup_mac()
680 static void cs4208_fixup_macmini(struct hda_codec *codec, in cs4208_fixup_macmini() argument
684 { 0x18, 0x00ab9150 }, /* mic (audio-in) jack: disable detect */ in cs4208_fixup_macmini()
685 { 0x21, 0x004be140 }, /* SPDIF: disable detect */ in cs4208_fixup_macmini()
690 /* HP pin (0x10) has an inverted detection */ in cs4208_fixup_macmini()
691 codec->inv_jack_detect = 1; in cs4208_fixup_macmini()
693 snd_hda_apply_pincfgs(codec, pincfgs); in cs4208_fixup_macmini()
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs4208_spdif_sw_put() local
701 struct cs_spec *spec = codec->spec; in cs4208_spdif_sw_put()
702 hda_nid_t pin = spec->gen.autocfg.dig_out_pins[0]; in cs4208_spdif_sw_put()
703 int pinctl = ucontrol->value.integer.value[0] ? PIN_OUT : 0; in cs4208_spdif_sw_put()
705 snd_hda_set_pin_ctl_cache(codec, pin, pinctl); in cs4208_spdif_sw_put()
706 return spec->spdif_sw_put(kcontrol, ucontrol); in cs4208_spdif_sw_put()
710 static void cs4208_fixup_spdif_switch(struct hda_codec *codec, in cs4208_fixup_spdif_switch() argument
714 struct cs_spec *spec = codec->spec; in cs4208_fixup_spdif_switch()
717 if (!spec->gen.autocfg.dig_out_pins[0]) in cs4208_fixup_spdif_switch()
719 kctl = snd_hda_find_mixer_ctl(codec, "IEC958 Playback Switch"); in cs4208_fixup_spdif_switch()
722 spec->spdif_sw_put = kctl->put; in cs4208_fixup_spdif_switch()
723 kctl->put = cs4208_spdif_sw_put; in cs4208_fixup_spdif_switch()
756 /* correct the 0dB offset of input pins */
757 static void cs4208_fix_amp_caps(struct hda_codec *codec, hda_nid_t adc) in cs4208_fix_amp_caps() argument
761 caps = query_amp_caps(codec, adc, HDA_INPUT); in cs4208_fix_amp_caps()
763 caps |= 0x02; in cs4208_fix_amp_caps()
764 snd_hda_override_amp_caps(codec, adc, HDA_INPUT, caps); in cs4208_fix_amp_caps()
767 static int patch_cs4208(struct hda_codec *codec) in patch_cs4208() argument
772 spec = cs_alloc_spec(codec, CS4208_VENDOR_NID); in patch_cs4208()
774 return -ENOMEM; in patch_cs4208()
776 codec->patch_ops = cs_patch_ops; in patch_cs4208()
777 spec->gen.automute_hook = cs_automute; in patch_cs4208()
778 /* exclude NID 0x10 (HP) from output volumes due to different steps */ in patch_cs4208()
779 spec->gen.out_vol_mask = 1ULL << 0x10; in patch_cs4208()
781 snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl, in patch_cs4208()
783 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs4208()
785 snd_hda_override_wcaps(codec, 0x18, in patch_cs4208()
786 get_wcaps(codec, 0x18) | AC_WCAP_STEREO); in patch_cs4208()
787 cs4208_fix_amp_caps(codec, 0x18); in patch_cs4208()
788 cs4208_fix_amp_caps(codec, 0x1b); in patch_cs4208()
789 cs4208_fix_amp_caps(codec, 0x1c); in patch_cs4208()
791 err = cs_parse_auto_config(codec); in patch_cs4208()
792 if (err < 0) in patch_cs4208()
795 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs4208()
797 return 0; in patch_cs4208()
800 cs_free(codec); in patch_cs4208()
821 SND_PCI_QUIRK(0x8086, 0x5001, "DP45SG/CDB4210", CS421X_CDB4210),
828 { 0x05, 0x0321401f },
829 { 0x06, 0x90170010 },
830 { 0x07, 0x03813031 },
831 { 0x08, 0xb7a70037 },
832 { 0x09, 0xb7a6003e },
833 { 0x0a, 0x034510f0 },
839 { 0x05, 0x022120f0 },
840 { 0x06, 0x901700f0 },
841 { 0x07, 0x02a120f0 },
842 { 0x08, 0x77a70037 },
843 { 0x09, 0x77a6003e },
844 { 0x0a, 0x434510f0 },
849 static void cs421x_fixup_sense_b(struct hda_codec *codec, in cs421x_fixup_sense_b() argument
852 struct cs_spec *spec = codec->spec; in cs421x_fixup_sense_b()
854 spec->sense_b = 1; in cs421x_fixup_sense_b()
875 {0x0B, AC_VERB_SET_PROC_STATE, 1},
876 {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DEV_CFG},
878 Disable Coefficient Index Auto-Increment(DAI)=1,
879 PDREF=0
881 {0x0B, AC_VERB_SET_PROC_COEF, 0x0001 },
883 {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_ADC_CFG},
885 {0x0B, AC_VERB_SET_PROC_COEF, 0x0002 },
887 {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DAC_CFG},
888 {0x0B, AC_VERB_SET_PROC_COEF,
889 (0x0002 /* DAC SZCMode = Digital Soft Ramp */
890 | 0x0004 /* Mute DAC on FIFO error */
891 | 0x0008 /* Enable DAC High Pass Filter */
912 {0x0B, AC_VERB_SET_PROC_STATE, 0x01}, /* VPW: processing on */
914 {0x0B, AC_VERB_SET_COEF_INDEX, 0x0006},
915 {0x0B, AC_VERB_SET_PROC_COEF, 0x9999}, /* Test mode: on */
917 {0x0B, AC_VERB_SET_COEF_INDEX, 0x000A},
918 {0x0B, AC_VERB_SET_PROC_COEF, 0x14CB}, /* Chop double */
920 {0x0B, AC_VERB_SET_COEF_INDEX, 0x0011},
921 {0x0B, AC_VERB_SET_PROC_COEF, 0xA2D0}, /* Increase ADC current */
923 {0x0B, AC_VERB_SET_COEF_INDEX, 0x001A},
924 {0x0B, AC_VERB_SET_PROC_COEF, 0x02A9}, /* Mute speaker */
926 {0x0B, AC_VERB_SET_COEF_INDEX, 0x001B},
927 {0x0B, AC_VERB_SET_PROC_COEF, 0X1006}, /* Remove noise */
933 static const DECLARE_TLV_DB_SCALE(cs421x_speaker_boost_db_scale, 900, 300, 0);
938 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in cs421x_boost_vol_info()
939 uinfo->count = 1; in cs421x_boost_vol_info()
940 uinfo->value.integer.min = 0; in cs421x_boost_vol_info()
941 uinfo->value.integer.max = 3; in cs421x_boost_vol_info()
942 return 0; in cs421x_boost_vol_info()
948 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs421x_boost_vol_get() local
950 ucontrol->value.integer.value[0] = in cs421x_boost_vol_get()
951 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL) & 0x0003; in cs421x_boost_vol_get()
952 return 0; in cs421x_boost_vol_get()
958 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); in cs421x_boost_vol_put() local
960 unsigned int vol = ucontrol->value.integer.value[0]; in cs421x_boost_vol_put()
962 cs_vendor_coef_get(codec, CS421X_IDX_SPK_CTL); in cs421x_boost_vol_put()
965 coef &= ~0x0003; in cs421x_boost_vol_put()
966 coef |= (vol & 0x0003); in cs421x_boost_vol_put()
968 return 0; in cs421x_boost_vol_put()
970 cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef); in cs421x_boost_vol_put()
987 static void cs4210_pinmux_init(struct hda_codec *codec) in cs4210_pinmux_init() argument
989 struct cs_spec *spec = codec->spec; in cs4210_pinmux_init()
993 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); in cs4210_pinmux_init()
995 if (spec->gpio_mask) in cs4210_pinmux_init()
996 coef |= 0x0008; /* B1,B2 are GPIOs */ in cs4210_pinmux_init()
998 coef &= ~0x0008; in cs4210_pinmux_init()
1000 if (spec->sense_b) in cs4210_pinmux_init()
1001 coef |= 0x0010; /* B2 is SENSE_B, not inverted */ in cs4210_pinmux_init()
1003 coef &= ~0x0010; in cs4210_pinmux_init()
1005 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); in cs4210_pinmux_init()
1007 if ((spec->gpio_mask || spec->sense_b) && in cs4210_pinmux_init()
1008 is_active_pin(codec, CS421X_DMIC_PIN_NID)) { in cs4210_pinmux_init()
1011 GPIO or SENSE_B forced - disconnect the DMIC pin. in cs4210_pinmux_init()
1013 def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID); in cs4210_pinmux_init()
1016 snd_hda_codec_set_pincfg(codec, CS421X_DMIC_PIN_NID, def_conf); in cs4210_pinmux_init()
1020 static void cs4210_spdif_automute(struct hda_codec *codec, in cs4210_spdif_automute() argument
1023 struct cs_spec *spec = codec->spec; in cs4210_spdif_automute()
1025 hda_nid_t spdif_pin = spec->gen.autocfg.dig_out_pins[0]; in cs4210_spdif_automute()
1028 if (!spec->spdif_detect || in cs4210_spdif_automute()
1029 spec->vendor_nid != CS4210_VENDOR_NID) in cs4210_spdif_automute()
1032 spdif_present = snd_hda_jack_detect(codec, spdif_pin); in cs4210_spdif_automute()
1033 if (spdif_present == spec->spdif_present) in cs4210_spdif_automute()
1036 spec->spdif_present = spdif_present; in cs4210_spdif_automute()
1038 snd_hda_set_pin_ctl(codec, spdif_pin, spdif_present ? PIN_OUT : 0); in cs4210_spdif_automute()
1040 cs_automute(codec); in cs4210_spdif_automute()
1043 static void parse_cs421x_digital(struct hda_codec *codec) in parse_cs421x_digital() argument
1045 struct cs_spec *spec = codec->spec; in parse_cs421x_digital()
1046 struct auto_pin_cfg *cfg = &spec->gen.autocfg; in parse_cs421x_digital()
1049 for (i = 0; i < cfg->dig_outs; i++) { in parse_cs421x_digital()
1050 hda_nid_t nid = cfg->dig_out_pins[i]; in parse_cs421x_digital()
1051 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { in parse_cs421x_digital()
1052 spec->spdif_detect = 1; in parse_cs421x_digital()
1053 snd_hda_jack_detect_enable_callback(codec, nid, in parse_cs421x_digital()
1059 static int cs421x_init(struct hda_codec *codec) in cs421x_init() argument
1061 struct cs_spec *spec = codec->spec; in cs421x_init()
1063 if (spec->vendor_nid == CS4210_VENDOR_NID) { in cs421x_init()
1064 snd_hda_sequence_write(codec, cs421x_coef_init_verbs); in cs421x_init()
1065 snd_hda_sequence_write(codec, cs421x_coef_init_verbs_A1_silicon_fixes); in cs421x_init()
1066 cs4210_pinmux_init(codec); in cs421x_init()
1069 snd_hda_gen_init(codec); in cs421x_init()
1071 if (spec->gpio_mask) { in cs421x_init()
1072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, in cs421x_init()
1073 spec->gpio_mask); in cs421x_init()
1074 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, in cs421x_init()
1075 spec->gpio_dir); in cs421x_init()
1076 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, in cs421x_init()
1077 spec->gpio_data); in cs421x_init()
1080 init_input_coef(codec); in cs421x_init()
1082 cs4210_spdif_automute(codec, NULL); in cs421x_init()
1084 return 0; in cs421x_init()
1087 static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac) in fix_volume_caps() argument
1091 /* set the upper-limit for mixer amp to 0dB */ in fix_volume_caps()
1092 caps = query_amp_caps(codec, dac, HDA_OUTPUT); in fix_volume_caps()
1093 caps &= ~(0x7f << AC_AMPCAP_NUM_STEPS_SHIFT); in fix_volume_caps()
1094 caps |= ((caps >> AC_AMPCAP_OFFSET_SHIFT) & 0x7f) in fix_volume_caps()
1096 snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps); in fix_volume_caps()
1099 static int cs421x_parse_auto_config(struct hda_codec *codec) in cs421x_parse_auto_config() argument
1101 struct cs_spec *spec = codec->spec; in cs421x_parse_auto_config()
1105 fix_volume_caps(codec, dac); in cs421x_parse_auto_config()
1107 err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, 0); in cs421x_parse_auto_config()
1108 if (err < 0) in cs421x_parse_auto_config()
1111 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); in cs421x_parse_auto_config()
1112 if (err < 0) in cs421x_parse_auto_config()
1115 parse_cs421x_digital(codec); in cs421x_parse_auto_config()
1117 if (spec->gen.autocfg.speaker_outs && in cs421x_parse_auto_config()
1118 spec->vendor_nid == CS4210_VENDOR_NID) { in cs421x_parse_auto_config()
1119 if (!snd_hda_gen_add_kctl(&spec->gen, NULL, in cs421x_parse_auto_config()
1121 return -ENOMEM; in cs421x_parse_auto_config()
1124 return 0; in cs421x_parse_auto_config()
1130 (DAC,ADC) -> D3, PDREF=1, AFG->D3
1132 static int cs421x_suspend(struct hda_codec *codec) in cs421x_suspend() argument
1134 struct cs_spec *spec = codec->spec; in cs421x_suspend()
1137 snd_hda_shutup_pins(codec); in cs421x_suspend()
1139 snd_hda_codec_write(codec, CS4210_DAC_NID, 0, in cs421x_suspend()
1141 snd_hda_codec_write(codec, CS4210_ADC_NID, 0, in cs421x_suspend()
1144 if (spec->vendor_nid == CS4210_VENDOR_NID) { in cs421x_suspend()
1145 coef = cs_vendor_coef_get(codec, CS421X_IDX_DEV_CFG); in cs421x_suspend()
1146 coef |= 0x0004; /* PDREF */ in cs421x_suspend()
1147 cs_vendor_coef_set(codec, CS421X_IDX_DEV_CFG, coef); in cs421x_suspend()
1150 return 0; in cs421x_suspend()
1165 static int patch_cs4210(struct hda_codec *codec) in patch_cs4210() argument
1170 spec = cs_alloc_spec(codec, CS4210_VENDOR_NID); in patch_cs4210()
1172 return -ENOMEM; in patch_cs4210()
1174 codec->patch_ops = cs421x_patch_ops; in patch_cs4210()
1175 spec->gen.automute_hook = cs_automute; in patch_cs4210()
1177 snd_hda_pick_fixup(codec, cs421x_models, cs421x_fixup_tbl, in patch_cs4210()
1179 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); in patch_cs4210()
1183 is auto-parsed. If GPIO or SENSE_B is forced, DMIC input in patch_cs4210()
1186 cs4210_pinmux_init(codec); in patch_cs4210()
1188 err = cs421x_parse_auto_config(codec); in patch_cs4210()
1189 if (err < 0) in patch_cs4210()
1192 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); in patch_cs4210()
1194 return 0; in patch_cs4210()
1197 cs_free(codec); in patch_cs4210()
1201 static int patch_cs4213(struct hda_codec *codec) in patch_cs4213() argument
1206 spec = cs_alloc_spec(codec, CS4213_VENDOR_NID); in patch_cs4213()
1208 return -ENOMEM; in patch_cs4213()
1210 codec->patch_ops = cs421x_patch_ops; in patch_cs4213()
1212 err = cs421x_parse_auto_config(codec); in patch_cs4213()
1213 if (err < 0) in patch_cs4213()
1216 return 0; in patch_cs4213()
1219 cs_free(codec); in patch_cs4213()
1228 HDA_CODEC_ENTRY(0x10134206, "CS4206", patch_cs420x),
1229 HDA_CODEC_ENTRY(0x10134207, "CS4207", patch_cs420x),
1230 HDA_CODEC_ENTRY(0x10134208, "CS4208", patch_cs4208),
1231 HDA_CODEC_ENTRY(0x10134210, "CS4210", patch_cs4210),
1232 HDA_CODEC_ENTRY(0x10134213, "CS4213", patch_cs4213),
1238 MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");