2 * Copyright (c) 2006 Stephane E. Potvin <sepotvin@videotron.ca>
3 * Copyright (c) 2006 Ariff Abdullah <ariff@FreeBSD.org>
4 * Copyright (c) 2008-2012 Alexander Motin <mav@FreeBSD.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Intel High Definition Audio (Audio function quirks) driver for FreeBSD.
33 #ifdef HAVE_KERNEL_OPTION_HEADERS
37 #include <dev/sound/pcm/sound.h>
39 #include <sys/ctype.h>
41 #include <dev/sound/pci/hda/hdac.h>
42 #include <dev/sound/pci/hda/hdaa.h>
43 #include <dev/sound/pci/hda/hda_reg.h>
45 SND_DECLARE_FILE("$FreeBSD$");
55 * XXX Force stereo quirk. Monoural recording / playback
56 * on few codecs (especially ALC880) seems broken or
57 * perhaps unsupported.
59 { HDA_MATCH_ALL, HDA_MATCH_ALL, HDA_MATCH_ALL,
60 HDAA_QUIRK_FORCESTEREO | HDAA_QUIRK_IVREF, 0,
62 { ACER_ALL_SUBVENDOR, HDA_MATCH_ALL, HDA_MATCH_ALL,
65 { ASUS_G2K_SUBVENDOR, HDA_CODEC_ALC660, HDA_MATCH_ALL,
68 { ASUS_M5200_SUBVENDOR, HDA_CODEC_ALC880, HDA_MATCH_ALL,
71 { ASUS_A7M_SUBVENDOR, HDA_CODEC_ALC880, HDA_MATCH_ALL,
74 { ASUS_A7T_SUBVENDOR, HDA_CODEC_ALC882, HDA_MATCH_ALL,
77 { ASUS_W2J_SUBVENDOR, HDA_CODEC_ALC882, HDA_MATCH_ALL,
80 { ASUS_U5F_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
81 HDAA_QUIRK_EAPDINV, 0,
83 { ASUS_A8X_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
84 HDAA_QUIRK_EAPDINV, 0,
86 { ASUS_F3JC_SUBVENDOR, HDA_CODEC_ALC861, HDA_MATCH_ALL,
89 { UNIWILL_9075_SUBVENDOR, HDA_CODEC_ALC861, HDA_MATCH_ALL,
92 /*{ ASUS_M2N_SUBVENDOR, HDA_CODEC_AD1988, HDA_MATCH_ALL,
93 HDAA_QUIRK_IVREF80, HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF100,
95 { MEDION_MD95257_SUBVENDOR, HDA_CODEC_ALC880, HDA_MATCH_ALL,
98 { LENOVO_3KN100_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
99 HDAA_QUIRK_EAPDINV | HDAA_QUIRK_SENSEINV, 0,
101 { SAMSUNG_Q1_SUBVENDOR, HDA_CODEC_AD1986A, HDA_MATCH_ALL,
102 HDAA_QUIRK_EAPDINV, 0,
104 { APPLE_MB3_SUBVENDOR, HDA_CODEC_ALC885, HDA_MATCH_ALL,
105 HDAA_QUIRK_OVREF50, 0,
107 { APPLE_INTEL_MAC, HDA_CODEC_STAC9221, HDA_MATCH_ALL,
109 HDAA_GPIO_SET(0) | HDAA_GPIO_SET(1) },
110 { APPLE_MACBOOKAIR31, HDA_CODEC_CS4206, HDA_MATCH_ALL,
112 HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
113 { APPLE_MACBOOKPRO55, HDA_CODEC_CS4206, HDA_MATCH_ALL,
115 HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
116 { APPLE_MACBOOKPRO71, HDA_CODEC_CS4206, HDA_MATCH_ALL,
118 HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
119 { HDA_INTEL_MACBOOKPRO92, HDA_CODEC_CS4206, HDA_MATCH_ALL,
121 HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) },
122 { DELL_D630_SUBVENDOR, HDA_CODEC_STAC9205X, HDA_MATCH_ALL,
125 { DELL_V1400_SUBVENDOR, HDA_CODEC_STAC9228X, HDA_MATCH_ALL,
128 { DELL_V1500_SUBVENDOR, HDA_CODEC_STAC9205X, HDA_MATCH_ALL,
131 { HDA_MATCH_ALL, HDA_CODEC_AD1988, HDA_MATCH_ALL,
132 HDAA_QUIRK_IVREF80, HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF100,
134 { HDA_MATCH_ALL, HDA_CODEC_AD1988B, HDA_MATCH_ALL,
135 HDAA_QUIRK_IVREF80, HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF100,
137 { HDA_MATCH_ALL, HDA_CODEC_CX20549, HDA_MATCH_ALL,
138 0, HDAA_QUIRK_FORCESTEREO,
140 /* Mac Pro 1,1 requires ovref for proper volume level. */
141 { 0x00000000, HDA_CODEC_ALC885, 0x106b0c00,
147 hdac_pin_patch(struct hdaa_widget *w)
149 const char *patch = NULL;
150 uint32_t config, orig, id, subid;
153 config = orig = w->wclass.pin.config;
154 id = hdaa_codec_id(w->devinfo);
155 subid = hdaa_card_id(w->devinfo);
157 /* XXX: Old patches require complete review.
158 * Now they may create more problem then solve due to
159 * incorrect associations.
161 if (id == HDA_CODEC_ALC880 && subid == LG_LW20_SUBVENDOR) {
164 config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
165 config |= HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN;
168 config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
169 config |= HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT;
174 } else if (id == HDA_CODEC_ALC880 &&
175 (subid == CLEVO_D900T_SUBVENDOR ||
176 subid == ASUS_M5200_SUBVENDOR)) {
182 config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
183 config |= HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN;
185 case 25: /* XXX MIC2 */
186 config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
187 config |= HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN;
190 config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
191 config |= HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN;
193 case 27: /* XXX LINE2 */
194 config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
195 config |= HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN;
198 config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
199 config |= HDA_CONFIG_DEFAULTCONF_DEVICE_CD;
202 } else if (id == HDA_CODEC_ALC883 &&
203 (subid == MSI_MS034A_SUBVENDOR ||
204 HDA_DEV_MATCH(ACER_ALL_SUBVENDOR, subid))) {
207 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
208 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
209 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
210 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
213 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
214 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
215 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_CD |
216 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
219 } else if (id == HDA_CODEC_CX20549 && subid ==
220 HP_V3000_SUBVENDOR) {
223 config &= ~HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK;
224 config |= HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_NONE;
227 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
228 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
229 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
230 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
233 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
234 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
235 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_CD |
236 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
239 } else if (id == HDA_CODEC_CX20551 && subid ==
240 HP_DV5000_SUBVENDOR) {
244 config &= ~HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK;
245 config |= HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_NONE;
248 } else if (id == HDA_CODEC_ALC861 && subid ==
249 ASUS_W6F_SUBVENDOR) {
252 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
253 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
254 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_OUT |
255 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
262 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
263 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
264 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
265 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
268 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
269 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
270 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT |
271 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_JACK);
274 } else if (id == HDA_CODEC_ALC861 && subid ==
275 UNIWILL_9075_SUBVENDOR) {
278 config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
279 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
280 config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT |
281 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_JACK);
287 if (id == HDA_CODEC_AD1984A &&
288 subid == LENOVO_X300_SUBVENDOR) {
290 case 17: /* Headphones with redirection */
291 patch = "as=1 seq=15";
293 case 20: /* Two mics together */
294 patch = "as=2 seq=15";
297 } else if (id == HDA_CODEC_AD1986A &&
298 (subid == ASUS_M2NPVMX_SUBVENDOR ||
299 subid == ASUS_A8NVMCSM_SUBVENDOR ||
300 subid == ASUS_P5PL2_SUBVENDOR)) {
302 case 26: /* Headphones with redirection */
303 patch = "as=1 seq=15";
305 case 28: /* 5.1 out => 2.0 out + 1 input */
306 patch = "device=Line-in as=8 seq=1";
308 case 29: /* Can't use this as input, as the only available mic
309 * preamplifier is busy by front panel mic (nid 31).
310 * If you want to use this rear connector as mic input,
311 * you have to disable the front panel one. */
314 case 31: /* Lot of inputs configured with as=15 and unusable */
315 patch = "as=8 seq=3";
318 patch = "as=8 seq=4";
321 patch = "as=8 seq=5";
324 patch = "as=8 seq=6";
327 } else if (id == HDA_CODEC_ALC260 &&
328 HDA_DEV_MATCH(SONY_S5_SUBVENDOR, subid)) {
331 patch = "seq=15 device=Headphones";
334 } else if (id == HDA_CODEC_ALC268) {
335 if (subid == ACER_T5320_SUBVENDOR) {
337 case 20: /* Headphones Jack */
338 patch = "as=1 seq=15";
342 } else if (id == HDA_CODEC_CX20561 &&
343 subid == LENOVO_B450_SUBVENDOR) {
346 patch = "as=1 seq=15";
349 } else if (id == HDA_CODEC_CX20561 &&
350 subid == LENOVO_T400_SUBVENDOR) {
353 patch = "as=1 seq=15";
356 patch = "as=1 seq=0";
359 } else if (id == HDA_CODEC_CX20590 &&
360 (subid == LENOVO_X1_SUBVENDOR ||
361 subid == LENOVO_X220_SUBVENDOR ||
362 subid == LENOVO_T420_SUBVENDOR ||
363 subid == LENOVO_T520_SUBVENDOR ||
364 subid == LENOVO_G580_SUBVENDOR)) {
367 patch = "as=1 seq=15";
370 * Group onboard mic and headphone mic
371 * together. Fixes onboard mic.
374 patch = "as=2 seq=15";
380 } else if (id == HDA_CODEC_ALC269 &&
381 (subid == LENOVO_X1CRBN_SUBVENDOR ||
382 subid == LENOVO_T430_SUBVENDOR ||
383 subid == LENOVO_T430S_SUBVENDOR ||
384 subid == LENOVO_T530_SUBVENDOR)) {
387 patch = "as=1 seq=15";
390 } else if (id == HDA_CODEC_ALC269 &&
391 subid == ASUS_UX31A_SUBVENDOR) {
394 patch = "as=1 seq=15";
397 } else if (id == HDA_CODEC_ALC892 &&
398 subid == INTEL_DH87RL_SUBVENDOR) {
401 patch = "as=1 seq=15";
404 } else if (id == HDA_CODEC_ALC292 &&
405 subid == LENOVO_X120BS_SUBVENDOR) {
408 patch = "as=1 seq=15";
414 config = hdaa_widget_pin_patch(config, patch);
417 device_printf(w->devinfo->dev,
418 "Patching pin config nid=%u 0x%08x -> 0x%08x\n",
421 w->wclass.pin.config = config;
425 hdaa_widget_patch(struct hdaa_widget *w)
427 struct hdaa_devinfo *devinfo = w->devinfo;
431 orig = w->param.widget_cap;
432 /* On some codecs beeper is an input pin, but it is not recordable
433 alone. Also most of BIOSes does not declare beeper pin.
434 Change beeper pin node type to beeper to help parser. */
435 switch (hdaa_codec_id(devinfo)) {
436 case HDA_CODEC_AD1882:
437 case HDA_CODEC_AD1883:
438 case HDA_CODEC_AD1984:
439 case HDA_CODEC_AD1984A:
440 case HDA_CODEC_AD1984B:
441 case HDA_CODEC_AD1987:
442 case HDA_CODEC_AD1988:
443 case HDA_CODEC_AD1988B:
444 case HDA_CODEC_AD1989B:
447 case HDA_CODEC_ALC260:
451 if (hda_get_vendor_id(devinfo->dev) == REALTEK_VENDORID &&
452 hdaa_codec_id(devinfo) != HDA_CODEC_ALC260)
454 if (w->nid == beeper) {
455 w->param.widget_cap &= ~HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_MASK;
456 w->param.widget_cap |= HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_BEEP_WIDGET <<
457 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_SHIFT;
461 * Clear "digital" flag from digital mic input, as its signal then goes
462 * to "analog" mixer and this separation just limits functionaity.
464 if (hdaa_codec_id(devinfo) == HDA_CODEC_AD1984A &&
466 w->param.widget_cap &= ~HDA_PARAM_AUDIO_WIDGET_CAP_DIGITAL_MASK;
468 if (w->param.widget_cap != orig) {
469 device_printf(w->devinfo->dev,
470 "Patching widget caps nid=%u 0x%08x -> 0x%08x\n",
471 w->nid, orig, w->param.widget_cap);
475 if (w->type == HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX)
480 hdaa_patch(struct hdaa_devinfo *devinfo)
482 struct hdaa_widget *w;
483 uint32_t id, subid, subsystemid;
486 id = hdaa_codec_id(devinfo);
487 subid = hdaa_card_id(devinfo);
488 subsystemid = hda_get_subsystem_id(devinfo->dev);
493 for (i = 0; i < nitems(hdac_quirks); i++) {
494 if (!(HDA_DEV_MATCH(hdac_quirks[i].model, subid) &&
495 HDA_DEV_MATCH(hdac_quirks[i].id, id) &&
496 HDA_DEV_MATCH(hdac_quirks[i].subsystemid, subsystemid)))
498 devinfo->quirks |= hdac_quirks[i].set;
499 devinfo->quirks &= ~(hdac_quirks[i].unset);
500 devinfo->gpio = hdac_quirks[i].gpio;
503 /* Apply per-widget patch. */
504 for (i = devinfo->startnode; i < devinfo->endnode; i++) {
505 w = hdaa_widget_get(devinfo, i);
508 hdaa_widget_patch(w);
512 case HDA_CODEC_AD1983:
514 * This CODEC has several possible usages, but none
515 * fit the parser best. Help parser to choose better.
517 /* Disable direct unmixed playback to get pcm volume. */
518 w = hdaa_widget_get(devinfo, 5);
520 w->connsenable[0] = 0;
521 w = hdaa_widget_get(devinfo, 6);
523 w->connsenable[0] = 0;
524 w = hdaa_widget_get(devinfo, 11);
526 w->connsenable[0] = 0;
527 /* Disable mic and line selectors. */
528 w = hdaa_widget_get(devinfo, 12);
530 w->connsenable[1] = 0;
531 w = hdaa_widget_get(devinfo, 13);
533 w->connsenable[1] = 0;
534 /* Disable recording from mono playback mix. */
535 w = hdaa_widget_get(devinfo, 20);
537 w->connsenable[3] = 0;
539 case HDA_CODEC_AD1986A:
541 * This CODEC has overcomplicated input mixing.
542 * Make some cleaning there.
544 /* Disable input mono mixer. Not needed and not supported. */
545 w = hdaa_widget_get(devinfo, 43);
548 /* Disable any with any input mixing mesh. Use separately. */
549 w = hdaa_widget_get(devinfo, 39);
552 w = hdaa_widget_get(devinfo, 40);
555 w = hdaa_widget_get(devinfo, 41);
558 w = hdaa_widget_get(devinfo, 42);
561 /* Disable duplicate mixer node connector. */
562 w = hdaa_widget_get(devinfo, 15);
564 w->connsenable[3] = 0;
565 /* There is only one mic preamplifier, use it effectively. */
566 w = hdaa_widget_get(devinfo, 31);
568 if ((w->wclass.pin.config &
569 HDA_CONFIG_DEFAULTCONF_DEVICE_MASK) ==
570 HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN) {
571 w = hdaa_widget_get(devinfo, 16);
573 w->connsenable[2] = 0;
575 w = hdaa_widget_get(devinfo, 15);
577 w->connsenable[0] = 0;
580 w = hdaa_widget_get(devinfo, 32);
582 if ((w->wclass.pin.config &
583 HDA_CONFIG_DEFAULTCONF_DEVICE_MASK) ==
584 HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN) {
585 w = hdaa_widget_get(devinfo, 16);
587 w->connsenable[0] = 0;
589 w = hdaa_widget_get(devinfo, 15);
591 w->connsenable[1] = 0;
595 if (subid == ASUS_A8X_SUBVENDOR) {
597 * This is just plain ridiculous.. There
598 * are several A8 series that share the same
599 * pci id but works differently (EAPD).
601 w = hdaa_widget_get(devinfo, 26);
602 if (w != NULL && w->type ==
603 HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX &&
604 (w->wclass.pin.config &
605 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK) !=
606 HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_NONE)
611 case HDA_CODEC_AD1981HD:
613 * This CODEC has very unusual design with several
614 * points inappropriate for the present parser.
616 /* Disable recording from mono playback mix. */
617 w = hdaa_widget_get(devinfo, 21);
619 w->connsenable[3] = 0;
620 /* Disable rear to front mic mixer, use separately. */
621 w = hdaa_widget_get(devinfo, 31);
624 /* Disable direct playback, use mixer. */
625 w = hdaa_widget_get(devinfo, 5);
627 w->connsenable[0] = 0;
628 w = hdaa_widget_get(devinfo, 6);
630 w->connsenable[0] = 0;
631 w = hdaa_widget_get(devinfo, 9);
633 w->connsenable[0] = 0;
634 w = hdaa_widget_get(devinfo, 24);
636 w->connsenable[0] = 0;
638 case HDA_CODEC_ALC269:
640 * ASUS EeePC 1001px has strange variant of ALC269 CODEC,
641 * that mutes speaker if unused mixer at NID 15 is muted.
642 * Probably CODEC incorrectly reports internal connections.
643 * Hide that muter from the driver. There are several CODECs
644 * sharing this ID and I have not enough information about
645 * them to implement more universal solution.
647 if (subid == 0x84371043) {
648 w = hdaa_widget_get(devinfo, 15);
650 w->param.inamp_cap = 0;
653 case HDA_CODEC_CX20582:
654 case HDA_CODEC_CX20583:
655 case HDA_CODEC_CX20584:
656 case HDA_CODEC_CX20585:
657 case HDA_CODEC_CX20590:
659 * These codecs have extra connectivity on record side
660 * too reach for the present parser.
662 w = hdaa_widget_get(devinfo, 20);
664 w->connsenable[1] = 0;
665 w = hdaa_widget_get(devinfo, 21);
667 w->connsenable[1] = 0;
668 w = hdaa_widget_get(devinfo, 22);
670 w->connsenable[0] = 0;
672 case HDA_CODEC_VT1708S_0:
673 case HDA_CODEC_VT1708S_1:
674 case HDA_CODEC_VT1708S_2:
675 case HDA_CODEC_VT1708S_3:
676 case HDA_CODEC_VT1708S_4:
677 case HDA_CODEC_VT1708S_5:
678 case HDA_CODEC_VT1708S_6:
679 case HDA_CODEC_VT1708S_7:
681 * These codecs have hidden mic boost controls.
683 w = hdaa_widget_get(devinfo, 26);
686 (40 << HDA_PARAM_OUTPUT_AMP_CAP_STEPSIZE_SHIFT) |
687 (3 << HDA_PARAM_OUTPUT_AMP_CAP_NUMSTEPS_SHIFT) |
688 (0 << HDA_PARAM_OUTPUT_AMP_CAP_OFFSET_SHIFT);
689 w = hdaa_widget_get(devinfo, 30);
692 (40 << HDA_PARAM_OUTPUT_AMP_CAP_STEPSIZE_SHIFT) |
693 (3 << HDA_PARAM_OUTPUT_AMP_CAP_NUMSTEPS_SHIFT) |
694 (0 << HDA_PARAM_OUTPUT_AMP_CAP_OFFSET_SHIFT);
700 hdaa_read_coef(device_t dev, nid_t nid, uint16_t idx)
703 hda_command(dev, HDA_CMD_SET_COEFF_INDEX(0, nid, idx));
704 return (hda_command(dev, HDA_CMD_GET_PROCESSING_COEFF(0, nid)));
708 hdaa_write_coef(device_t dev, nid_t nid, uint16_t idx, uint16_t val)
711 hda_command(dev, HDA_CMD_SET_COEFF_INDEX(0, nid, idx));
712 return (hda_command(dev, HDA_CMD_SET_PROCESSING_COEFF(0, nid, val)));
716 hdaa_patch_direct(struct hdaa_devinfo *devinfo)
718 device_t dev = devinfo->dev;
719 uint32_t id, subid, val;
721 id = hdaa_codec_id(devinfo);
722 subid = hdaa_card_id(devinfo);
725 case HDA_CODEC_VT1708S_0:
726 case HDA_CODEC_VT1708S_1:
727 case HDA_CODEC_VT1708S_2:
728 case HDA_CODEC_VT1708S_3:
729 case HDA_CODEC_VT1708S_4:
730 case HDA_CODEC_VT1708S_5:
731 case HDA_CODEC_VT1708S_6:
732 case HDA_CODEC_VT1708S_7:
733 /* Enable Mic Boost Volume controls. */
734 hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,
737 case HDA_CODEC_VT1818S:
738 /* Don't bypass mixer. */
739 hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,
742 case HDA_CODEC_ALC1150:
743 if (subid == 0xd9781462) {
744 /* Too low volume on MSI H170 GAMING M3. */
745 hdaa_write_coef(dev, 0x20, 0x07, 0x7cb);
749 if (subid == APPLE_INTEL_MAC)
750 hda_command(dev, HDA_CMD_12BIT(0, devinfo->nid,
752 if (id == HDA_CODEC_ALC269) {
753 if (subid == 0x16e31043 || subid == 0x831a1043 ||
754 subid == 0x834a1043 || subid == 0x83981043 ||
755 subid == 0x83ce1043) {
757 * The ditital mics on some Asus laptops produce
758 * differential signals instead of expected stereo.
759 * That results in silence if downmix it to mono.
760 * To workaround, make codec to handle signal as mono.
762 val = hdaa_read_coef(dev, 0x20, 0x07);
763 hdaa_write_coef(dev, 0x20, 0x07, val|0x80);
765 if (subid == 0x15171043) {
766 /* Increase output amp on ASUS UX31A by +5dB. */
767 hdaa_write_coef(dev, 0x20, 0x12, 0x2800);