Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jul 2021 06:17:02 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: ef790cc7407e - main - hdaa: update pin patch configurations
Message-ID:  <202107030617.1636H22I062745@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=ef790cc7407e827db9563d08a52a71ab36436986

commit ef790cc7407e827db9563d08a52a71ab36436986
Author:     K Staring <qdk@quickdekay.net>
AuthorDate: 2021-07-03 06:15:49 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-07-03 06:15:49 +0000

    hdaa: update pin patch configurations
    
    A number of structural changes:
      - Use decimal nid numbers instead of hex
      - updated the branch to incoorporate the suggestions made in the
        ALC280 pull request github thread
      - Convert magic pin values into strings.
      - Also update hdaa_patches to use clearer enums..
      - made pin patch type enum clearer, add macro for 'string' type
        patches
      - Added pin_patch structures to separate data from logic.
      - Integrated Realtek patches into new structure.
    
    These incorporate fixes for ALC255, ALC256, ALC260, ALC262, ALC268,
    ALC269, ALC280, ALC282, ALC283, ALC286, ALC290, ALC293, ALC296, ALC2880
    
    And have definitions for a number of Dell and HP laptops.
    
    Much of this data has been mined fromt he tables in the Linux driver.
    
    imp squashed these into one commit because the changes from the github
    pull requests no longer cleanly apply individually and made light style
    changes after feedback from jhb.
    
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/139
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/140
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/141
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/142
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/143
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/144
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/145
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/146
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/147
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/148
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/149
    Pull Request:           https://github.com/freebsd/freebsd-src/pull/150
    Differential Revision:  https://reviews.freebsd.org/D30619
---
 sys/dev/sound/pci/hda/hdaa_patches.c      | 259 +++-----
 sys/dev/sound/pci/hda/hdac.h              | 145 ++++-
 sys/dev/sound/pci/hda/pin_patch.h         | 121 ++++
 sys/dev/sound/pci/hda/pin_patch_realtek.h | 992 ++++++++++++++++++++++++++++++
 4 files changed, 1327 insertions(+), 190 deletions(-)

diff --git a/sys/dev/sound/pci/hda/hdaa_patches.c b/sys/dev/sound/pci/hda/hdaa_patches.c
index 590c9e4d46fb..69299ee4344f 100644
--- a/sys/dev/sound/pci/hda/hdaa_patches.c
+++ b/sys/dev/sound/pci/hda/hdaa_patches.c
@@ -44,6 +44,9 @@
 #include <dev/sound/pci/hda/hdaa.h>
 #include <dev/sound/pci/hda/hda_reg.h>
 
+#include "pin_patch.h"
+#include "pin_patch_realtek.h"
+
 SND_DECLARE_FILE("$FreeBSD$");
 
 static const struct {
@@ -145,10 +148,28 @@ static const struct {
 	    0 }
 };
 
+static struct pin_patch_t *
+match_pin_patches(int vendor_id, int vendor_subid)
+{
+	for (int ci = 0; ci < nitems(realtek_model_pin_patches); ci++) {
+		struct hdaa_model_pin_patch_t *p = &realtek_model_pin_patches[ci];
+		if (vendor_id != p->id)
+			continue;
+		for (struct model_pin_patch_t *pp =  p->patches; pp->models; pp++) {
+			for (struct pin_machine_model_t *model = pp->models; model->id != 0; model++) {
+				if (vendor_subid == model->id)
+					return (pp->pin_patches);
+			}
+		}
+	}
+
+	return (0);
+}
+
 static void
 hdac_pin_patch(struct hdaa_widget *w)
 {
-	const char *patch = NULL;
+	const char *patch_str = NULL;
 	uint32_t config, orig, id, subid;
 	nid_t nid = w->nid;
 
@@ -156,54 +177,7 @@ hdac_pin_patch(struct hdaa_widget *w)
 	id = hdaa_codec_id(w->devinfo);
 	subid = hdaa_card_id(w->devinfo);
 
-	/* XXX: Old patches require complete review.
-	 * Now they may create more problem then solve due to
-	 * incorrect associations.
-	 */
-	if (id == HDA_CODEC_ALC880 && subid == LG_LW20_SUBVENDOR) {
-		switch (nid) {
-		case 26:
-			config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
-			config |= HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN;
-			break;
-		case 27:
-			config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
-			config |= HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT;
-			break;
-		default:
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC880 &&
-	    (subid == CLEVO_D900T_SUBVENDOR ||
-	    subid == ASUS_M5200_SUBVENDOR)) {
-		/*
-		 * Super broken BIOS
-		 */
-		switch (nid) {
-		case 24:	/* MIC1 */
-			config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
-			config |= HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN;
-			break;
-		case 25:	/* XXX MIC2 */
-			config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
-			config |= HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN;
-			break;
-		case 26:	/* LINE1 */
-			config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
-			config |= HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN;
-			break;
-		case 27:	/* XXX LINE2 */
-			config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
-			config |= HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN;
-			break;
-		case 28:	/* CD */
-			config &= ~HDA_CONFIG_DEFAULTCONF_DEVICE_MASK;
-			config |= HDA_CONFIG_DEFAULTCONF_DEVICE_CD;
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC883 &&
-	    (subid == MSI_MS034A_SUBVENDOR ||
-	    HDA_DEV_MATCH(ACER_ALL_SUBVENDOR, subid))) {
+	if (id == HDA_CODEC_ALC883 && HDA_DEV_MATCH(ACER_ALL_SUBVENDOR, subid)) {
 		switch (nid) {
 		case 25:
 			config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
@@ -247,42 +221,6 @@ hdac_pin_patch(struct hdaa_widget *w)
 			config |= HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_NONE;
 			break;
 		}
-	} else if (id == HDA_CODEC_ALC861 && subid ==
-	    ASUS_W6F_SUBVENDOR) {
-		switch (nid) {
-		case 11:
-			config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
-			config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_OUT |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
-			break;
-		case 12:
-		case 14:
-		case 16:
-		case 31:
-		case 32:
-			config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
-			config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED);
-			break;
-		case 15:
-			config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
-			config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_JACK);
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC861 && subid ==
-	    UNIWILL_9075_SUBVENDOR) {
-		switch (nid) {
-		case 15:
-			config &= ~(HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK);
-			config |= (HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT |
-			    HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_JACK);
-			break;
-		}
 	}
 
 	/* New patches */
@@ -290,10 +228,10 @@ hdac_pin_patch(struct hdaa_widget *w)
 	    subid == LENOVO_X300_SUBVENDOR) {
 		switch (nid) {
 		case 17: /* Headphones with redirection */
-			patch = "as=1 seq=15";
+			patch_str = "as=1 seq=15";
 			break;
 		case 20: /* Two mics together */
-			patch = "as=2 seq=15";
+			patch_str = "as=2 seq=15";
 			break;
 		}
 	} else if (id == HDA_CODEC_AD1986A &&
@@ -302,60 +240,45 @@ hdac_pin_patch(struct hdaa_widget *w)
 	    subid == ASUS_P5PL2_SUBVENDOR)) {
 		switch (nid) {
 		case 26: /* Headphones with redirection */
-			patch = "as=1 seq=15";
+			patch_str = "as=1 seq=15";
 			break;
 		case 28: /* 5.1 out => 2.0 out + 1 input */
-			patch = "device=Line-in as=8 seq=1";
+			patch_str = "device=Line-in as=8 seq=1";
 			break;
 		case 29: /* Can't use this as input, as the only available mic
 			  * preamplifier is busy by front panel mic (nid 31).
 			  * If you want to use this rear connector as mic input,
 			  * you have to disable the front panel one. */
-			patch = "as=0";
+			patch_str = "as=0";
 			break;
 		case 31: /* Lot of inputs configured with as=15 and unusable */
-			patch = "as=8 seq=3";
+			patch_str = "as=8 seq=3";
 			break;
 		case 32:
-			patch = "as=8 seq=4";
+			patch_str = "as=8 seq=4";
 			break;
 		case 34:
-			patch = "as=8 seq=5";
+			patch_str = "as=8 seq=5";
 			break;
 		case 36:
-			patch = "as=8 seq=6";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC260 &&
-	    HDA_DEV_MATCH(SONY_S5_SUBVENDOR, subid)) {
-		switch (nid) {
-		case 16:
-			patch = "seq=15 device=Headphones";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC268) {
-	    if (subid == ACER_T5320_SUBVENDOR) {
-		switch (nid) {
-		case 20: /* Headphones Jack */
-			patch = "as=1 seq=15";
+			patch_str = "as=8 seq=6";
 			break;
 		}
-	    }
 	} else if (id == HDA_CODEC_CX20561 &&
 	    subid == LENOVO_B450_SUBVENDOR) {
 		switch (nid) {
 		case 22:
-			patch = "as=1 seq=15";
+			patch_str = "as=1 seq=15";
 			break;
 		}
 	} else if (id == HDA_CODEC_CX20561 &&
 	    subid == LENOVO_T400_SUBVENDOR) {
 		switch (nid) {
 		case 22:
-			patch = "as=1 seq=15";
+			patch_str = "as=1 seq=15";
 			break;
 		case 26:
-			patch = "as=1 seq=0";
+			patch_str = "as=1 seq=0";
 			break;
 		}
 	} else if (id == HDA_CODEC_CX20590 &&
@@ -366,102 +289,62 @@ hdac_pin_patch(struct hdaa_widget *w)
 	    subid == LENOVO_G580_SUBVENDOR)) {
 		switch (nid) {
 		case 25:
-			patch = "as=1 seq=15";
+			patch_str = "as=1 seq=15";
 			break;
 		/*
 		 * Group onboard mic and headphone mic
 		 * together.  Fixes onboard mic.
 		 */
 		case 27:
-			patch = "as=2 seq=15";
+			patch_str = "as=2 seq=15";
 			break;
 		case 35:
-			patch = "as=2";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC269 &&
-	    (subid == LENOVO_X1CRBN_SUBVENDOR ||
-	    subid == LENOVO_T430_SUBVENDOR ||
-	    subid == LENOVO_T430S_SUBVENDOR ||
-	    subid == LENOVO_T530_SUBVENDOR)) {
-		switch (nid) {
-		case 21:
-			patch = "as=1 seq=15";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC285 &&
-	    (subid == LENOVO_X120KH_SUBVENDOR ||
-	    subid == LENOVO_X120QD_SUBVENDOR)) {
-		switch (nid) {
-		case 33:
-			patch = "as=1 seq=15";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC269 &&
-	    subid == ASUS_UX31A_SUBVENDOR) {
-		switch (nid) {
-		case 33:
-			patch = "as=1 seq=15";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC892 &&
-	    subid == INTEL_DH87RL_SUBVENDOR) {
-		switch (nid) {
-		case 27:
-			patch = "as=1 seq=15";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC292 &&
-	    subid == LENOVO_X120BS_SUBVENDOR) {
-		switch (nid) {
-		case 21:
-			patch = "as=1 seq=15";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC295 && subid == HP_AF006UR_SUBVENDOR) {
-		switch (nid) {
-		case 18:
-			patch = "as=2";
-			break;
-		case 25:
-			patch = "as=2 seq=15";
-			break;
-		case 33:
-			patch = "as=1 seq=15";
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC298 && HDA_DEV_MATCH(LENOVO_ALL_SUBVENDOR, subid)) {
-		switch (nid) {
-		case 23:
-			config = 0x03a1103f;
-			break;
-		case 33:
-			config = 0x2121101f;
-			break;
-		}
-	} else if (id == HDA_CODEC_ALC298 && subid == DELL_XPS9560_SUBVENDOR) {
-		switch (nid) {
-		case 24:
-			config = 0x01a1913c;
-			break;
-		case 26:
-			config = 0x01a1913d;
+			patch_str = "as=2";
 			break;
 		}
 	} else if (id == HDA_CODEC_ALC256 && (subid == DELL_I7577_SUBVENDOR ||
 	    subid == DELL_L7480_SUBVENDOR)) {
 		switch (nid) {
 		case 20:
-			patch = "as=1 seq=0";
+			patch_str = "as=1 seq=0";
 			break;
 		case 33:
-			patch = "as=1 seq=15";
+			patch_str = "as=1 seq=15";
 			break;
 		}
+	} else {
+		/*
+		 * loop over hdaa_model_pin_patch
+		 */
+		struct pin_patch_t *pin_patches = NULL;
+
+		pin_patches = match_pin_patches(id, subid);
+
+		if (pin_patches != NULL) {
+			for (struct pin_patch_t *patch = pin_patches; patch->type; patch++) {
+				if (nid == patch->nid) {
+					switch (patch->type) {
+					case PIN_PATCH_TYPE_STRING:
+						patch_str = patch->patch.string;
+					case PIN_PATCH_TYPE_MASK:
+						config &= ~patch->patch.mask[0];
+						config |= patch->patch.mask[1];
+						break;
+					case PIN_PATCH_TYPE_OVERRIDE:
+						config = patch->patch.override;
+						break;
+					default:
+						/* should panic hard */
+						break;
+					}
+					break;
+				}
+			}
+		}
 	}
 
-	if (patch != NULL)
-		config = hdaa_widget_pin_patch(config, patch);
+	if (patch_str != NULL)
+		config = hdaa_widget_pin_patch(config, patch_str);
 	HDA_BOOTVERBOSE(
 		if (config != orig)
 			device_printf(w->devinfo->dev,
diff --git a/sys/dev/sound/pci/hda/hdac.h b/sys/dev/sound/pci/hda/hdac.h
index 8e427d3412da..611cb98badd8 100644
--- a/sys/dev/sound/pci/hda/hdac.h
+++ b/sys/dev/sound/pci/hda/hdac.h
@@ -61,6 +61,7 @@
 #define HDA_INTEL_82801G	HDA_MODEL_CONSTRUCT(INTEL, 0x27d8)
 #define HDA_INTEL_82801H	HDA_MODEL_CONSTRUCT(INTEL, 0x284b)
 #define HDA_INTEL_82801I	HDA_MODEL_CONSTRUCT(INTEL, 0x293e)
+#define HDA_INTEL_GMLK		HDA_MODEL_CONSTRUCT(INTEL, 0x3198)
 #define HDA_INTEL_JLK		HDA_MODEL_CONSTRUCT(INTEL, 0x38c8)
 #define HDA_INTEL_82801JI	HDA_MODEL_CONSTRUCT(INTEL, 0x3a3e)
 #define HDA_INTEL_82801JD	HDA_MODEL_CONSTRUCT(INTEL, 0x3a6e)
@@ -91,7 +92,16 @@
 #define HDA_INTEL_CMLKLP	HDA_MODEL_CONSTRUCT(INTEL, 0x02c8)
 #define HDA_INTEL_CMLKH 	HDA_MODEL_CONSTRUCT(INTEL, 0x06c8)
 #define HDA_INTEL_TGLK		HDA_MODEL_CONSTRUCT(INTEL, 0xa0c8)
-#define HDA_INTEL_GMLK		HDA_MODEL_CONSTRUCT(INTEL, 0x3198)
+#define INTEL_A100ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xa100)
+#define INTEL_D400ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xd400)
+#define INTEL_D401ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xd401)
+#define INTEL_D402ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xd402)
+#define INTEL_E305ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xe305)
+#define INTEL_E308ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xe308)
+#define INTEL_E224ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xe224)
+#define INTEL_E400ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xe400)
+#define INTEL_E401ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xe401)
+#define INTEL_E402ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(INTEL, 0xe402)
 #define HDA_INTEL_ALL		HDA_MODEL_CONSTRUCT(INTEL, 0xffff)
 
 /* Nvidia */
@@ -198,6 +208,10 @@
 
 /* HP/Compaq */
 #define HP_VENDORID		0x103c
+#define HP_Z200_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x103c)
+#define HP_225AID_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x225a)
+#define HP_2272ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x2272)
+#define HP_2273ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x2273)
 #define HP_V3000_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x30b5)
 #define HP_NX7400_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x30a2)
 #define HP_NX6310_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x30aa)
@@ -207,6 +221,7 @@
 #define HP_DV5000_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x30a5)
 #define HP_DC7700S_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x2801)
 #define HP_DC7700_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x2802)
+#define HP_DC5750_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x280a)
 #define HP_AF006UR_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0x83a2)
 #define HP_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(HP, 0xffff)
 /* What is wrong with XN 2563 anyway? (Got the picture ?) */
@@ -222,7 +237,28 @@
 #define DELL_L7480_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x07a0)
 #define DELL_XPSM1210_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x01d7)
 #define DELL_OPLX745_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x01da)
+#define DELL_05F4ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x05f4)
+#define DELL_05F5ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x05f5)
+#define DELL_05F6ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x05f6)
+#define DELL_V5470_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0615)
+#define DELL_V5470_1_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0616)
+#define DELL_064AID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x064a)
+#define DELL_064BID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x064b)
+#define DELL_9020M_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0669)
+#define DELL_V5480_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x069a)
+#define DELL_06D9ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x06d9)
+#define DELL_06DAID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x06da)
+#define DELL_06DBID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x06db)
+#define DELL_06DDID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x06dd)
+#define DELL_06DEID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x06de)
+#define DELL_06DFID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x06df)
+#define DELL_06E0ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x06e0)
+#define DELL_7559_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0706)
+#define DELL_7000_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0798)
 #define DELL_XPS9560_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x07be)
+#define DELL_E7240_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x05ca)
+#define DELL_164AID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x164a)
+#define DELL_164BID_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x164b)
 #define DELL_I7577_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0x0802)
 #define DELL_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(DELL, 0xffff)
 
@@ -233,34 +269,66 @@
 
 /* Acer */
 #define ACER_VENDORID		0x1025
+#define ACER_0070ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0070)
+#define ACER_0077ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0077)
+#define ACER_0078ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0078)
+#define ACER_0087ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0087)
 #define ACER_A5050_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x010f)
 #define ACER_A4520_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0127)
 #define ACER_A4710_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x012f)
 #define ACER_A4715_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0133)
+#define ACER_TM_6293_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0139)
 #define ACER_3681WXM_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0110)
 #define ACER_T6292_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x011b)
 #define ACER_T5320_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x011f)
+#define ACER_TM_6293_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0139)
+#define ACER_AC700_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x047c)
+#define ACER_V5_571G_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x072d)
+#define ACER_AO725_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0740)
+#define ACER_AO756_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0742)
+#define ACER_E1_472_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0762)
+#define ACER_E1_572_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x0775)
+#define ACER_V5_573G_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x079b)
+#define ACER_CB_14_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0x106d)
+#define ACER_V5_122P_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0xa80d)
+#define ACER_APFV_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0xa884)
+#define ACER_E309ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0xe309)
+#define ACER_E310ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0xe310)
 #define ACER_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(ACER, 0xffff)
 
 /* Asus */
 #define ASUS_VENDORID		0x1043
+#define ASUS_X540A_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x103e)
+#define ASUS_X540SA_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x10c0)
+#define ASUS_X556UR_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x11c0)
+#define ASUS_W5A_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x10c3)
+#define ASUS_X540LA_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x10d0)
 #define ASUS_A8X_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1153)
 #define ASUS_U5F_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1263)
 #define ASUS_W6F_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1263)
+#define ASUS_X541SA_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x12e0)
+#define ASUS_X541UV_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x12f0)
 #define ASUS_A7M_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1323)
 #define ASUS_F3JC_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1338)
 #define ASUS_G2K_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1339)
+#define ASUS_Z550SA_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x13b0)
 #define ASUS_A7T_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x13c2)
 #define ASUS_UX31A_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1517)
+#define ASUS_Z71V_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1964)
 #define ASUS_W2J_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1971)
 #define ASUS_M5200_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1993)
+#define ASUS_G73JW_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1a13)
+#define ASUS_X705UD_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1a30)
+#define ASUS_Z550MA_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1bbd)
+#define ASUS_X555UB_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x1ccd)
 #define ASUS_P5PL2_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x817f)
 #define ASUS_P1AH2_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x81cb)
 #define ASUS_M2NPVMX_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x81cb)
 #define ASUS_M2V_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x81e7)
 #define ASUS_P5BWD_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x81ec)
 #define ASUS_M2N_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x8234)
-#define ASUS_A8NVMCSM_SUBVENDOR	HDA_MODEL_CONSTRUCT(NVIDIA, 0xcb84)
+#define ASUS_A8NVMCSM_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0xcb84)
+#define ASUS_X101CH_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0x8516)
 #define ASUS_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(ASUS, 0xffff)
 
 /* IBM / Lenovo */
@@ -287,7 +355,11 @@
 #define	LENOVO_T430S_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21fb)
 #define	LENOVO_T520_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21cf)
 #define	LENOVO_T530_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21f6)
+#define	LENOVO_X230_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x21fa)
+#define	LENOVO_X230T_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x2203)
+#define	LENOVO_T431S_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x2208)
 #define	LENOVO_G580_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x3977)
+#define	LENOVO_3000_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0x384e)
 #define LENOVO_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(LENOVO, 0xffff)
 
 /* Samsung */
@@ -307,8 +379,19 @@
 /* Sony */
 #define SONY_VENDORID		0x104d
 #define SONY_S5_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x81cc)
+#define SONY_81A0ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x81a0)
+#define SONY_81D6ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x81d6)
+#define SONY_81BBID_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x81bb)
+#define SONY_VAIO_TX_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x81e2)
+#define SONY_VAIO_S13_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x9099)
+#define SONY_VAIO_P11_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x90b5)
+#define SONY_VAIO_P13_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0x90b6)
 #define SONY_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(SONY, 0xffff)
 
+/* Tyan? */
+#define TYAN_VENDORID		0x10f1
+#define TYAN_N6650W_SUBVENDOR	HDA_MODEL_CONSTRUCT(TYAN, 0x2915)
+
 /*
  * Apple Intel MacXXXX seems using Sigmatel codec/vendor id
  * instead of their own, which is beyond my comprehension
@@ -322,18 +405,32 @@
 /* LG Electronics */
 #define LG_VENDORID		0x1854
 #define LG_LW20_SUBVENDOR	HDA_MODEL_CONSTRUCT(LG, 0x0018)
+#define LG_M1_SUBVENDOR		HDA_MODEL_CONSTRUCT(LG, 0x003b)
+#define LG_P1_SUBVENDOR		HDA_MODEL_CONSTRUCT(LG, 0x005f)
+#define LG_W1_SUBVENDOR		HDA_MODEL_CONSTRUCT(LG, 0x0068)
+#define LG_LW25_SUBVENDOR	HDA_MODEL_CONSTRUCT(LG, 0x0077)
 #define LG_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(LG, 0xffff)
 
 /* Fujitsu Siemens */
 #define FS_VENDORID		0x1734
 #define FS_PA1510_SUBVENDOR	HDA_MODEL_CONSTRUCT(FS, 0x10b8)
 #define FS_SI1848_SUBVENDOR	HDA_MODEL_CONSTRUCT(FS, 0x10cd)
+#define FS_AMILO_M1437_SUBVENDOR HDA_MODEL_CONSTRUCT(FS, 0x107c)
+#define FS_AMILO_M1451G_SUBVENDOR HDA_MODEL_CONSTRUCT(FS, 0x1094)
+#define FS_AMILO_PI1556_SUBVENDOR HDA_MODEL_CONSTRUCT(FS, 0x10b0)
+#define FS_AMILO_XI1526_SUBVENDOR HDA_MODEL_CONSTRUCT(FS, 0x10ac)
+#define FS_H270_SUBVENDOR	HDA_MODEL_CONSTRUCT(FS, 0x1147)
 #define FS_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(FS, 0xffff)
 
 /* Fujitsu Limited */
 #define FL_VENDORID		0x10cf
 #define FL_S7020D_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0x1326)
+#define FL_LB_S7110_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0x1397)
 #define FL_U1010_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0x142d)
+#define FL_1475ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0x1475)
+#define FL_LB_U904_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0x1845)
+#define FL_LB_T731_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0x15dc)
+#define FL_LB_E725_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0x1757)
 #define FL_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(FL, 0xffff)
 
 /* Toshiba */
@@ -346,18 +443,61 @@
 #define MSI_VENDORID		0x1462
 #define MSI_MS1034_SUBVENDOR	HDA_MODEL_CONSTRUCT(MSI, 0x0349)
 #define MSI_MS034A_SUBVENDOR	HDA_MODEL_CONSTRUCT(MSI, 0x034a)
+#define MSI_1150ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(MSI, 0x1150)
+#define MSI_MS_B120_SUBVENDOR	HDA_MODEL_CONSTRUCT(MSI, 0xb120)
 #define MSI_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(MSI, 0xffff)
 
 /* Giga-Byte Technology */
 #define GB_VENDORID		0x1458
 #define GB_G33S2H_SUBVENDOR	HDA_MODEL_CONSTRUCT(GB, 0xa022)
+#define GB_K8_SUBVENDOR		HDA_MODEL_CONSTRUCT(GB, 0xa102)
+#define GB_BXBT2807_SUBVENDOR	HDA_MODEL_CONSTRUCT(GB, 0xfa53)
 #define GP_ALL_SUBVENDOR	HDA_MODEL_CONSTRUCT(GB, 0xffff)
 
 /* Uniwill ? */
 #define UNIWILL_VENDORID	0x1584
 #define UNIWILL_9075_SUBVENDOR	HDA_MODEL_CONSTRUCT(UNIWILL, 0x9075)
+#define UNIWILL_9050_SUBVENDOR	HDA_MODEL_CONSTRUCT(UNIWILL, 0x9050)
+#define UNIWILL_9054_SUBVENDOR	HDA_MODEL_CONSTRUCT(UNIWILL, 0x9054)
+#define UNIWILL_9070_SUBVENDOR	HDA_MODEL_CONSTRUCT(UNIWILL, 0x9070)
 #define UNIWILL_9080_SUBVENDOR	HDA_MODEL_CONSTRUCT(UNIWILL, 0x9080)
 
+/* Coeus / Elitegroup */
+#define COEUS_VENDORID		0x1019
+#define COEUS_G610P_SUBVENDOR	HDA_MODEL_CONSTRUCT(COEUS, 0x0f69)
+#define COEUS_A880ID_SUBVENDOR	HDA_MODEL_CONSTRUCT(COEUS, 0xa880)
+
+/* Arima */
+#define ARIMA_VENDORID		0x161f
+#define ARIMA_W810_SUBVENDOR	HDA_MODEL_CONSTRUCT(ARIMA, 0x0f69)
+
+/* Shuttle Computer */
+#define SHUTTLE_VENDORID	0x1039
+#define SHUTTLE_ST20G5_SUBVENDOR HDA_MODEL_CONSTRUCT(SHUTTLE, 0xc790)
+
+/* First International Computer */
+#define FIC_VENDORID		0x1509
+#define FIC_P4M_SUBVENDOR	HDA_MODEL_CONSTRUCT(FIC, 0x925d)
+
+/* Gateway 2000 */
+#define GATEWAY_VENDORID	0x107b
+#define GATEWAY_3032ID_SUBVENDOR HDA_MODEL_CONSTRUCT(GATEWAY, 0x3032)
+#define GATEWAY_3033ID_SUBVENDOR HDA_MODEL_CONSTRUCT(GATEWAY, 0x3033)
+#define GATEWAY_4039ID_SUBVENDOR HDA_MODEL_CONSTRUCT(GATEWAY, 0x4039)
+
+/* Biostar */
+#define BIOSTAR_VENDORID	0x1565
+#define BIOSTAR_8202ID_SUBVENDOR HDA_MODEL_CONSTRUCT(BIOSTAR, 0x8202)
+
+/* EPoX Computer Co., Ltd. */
+#define EPOX_VENDORID		0x1695
+#define EPOX_400DID_SUBVENDOR	HDA_MODEL_CONSTRUCT(EPOX, 0x400d)
+#define EPOX_EP5LDA_SUBVENDOR	HDA_MODEL_CONSTRUCT(EPOX, 0x4012)
+
+/* AOpen */
+#define AOPEN_VENDORID	0xa0a0
+#define AOPEN_I915GMMHFS_SUBVENDOR HDA_MODEL_CONSTRUCT(AOPEN, 0x8202)
+
 /* All codecs you can eat... */
 #define HDA_CODEC_CONSTRUCT(vendor, id) \
 		(((uint32_t)(vendor##_VENDORID) << 16) | ((id) & 0xffff))
@@ -390,6 +530,7 @@
 #define HDA_CODEC_ALC268	HDA_CODEC_CONSTRUCT(REALTEK, 0x0268)
 #define HDA_CODEC_ALC269	HDA_CODEC_CONSTRUCT(REALTEK, 0x0269)
 #define HDA_CODEC_ALC270	HDA_CODEC_CONSTRUCT(REALTEK, 0x0270)
+#define HDA_CODEC_ALC271	HDA_CODEC_CONSTRUCT(REALTEK, 0x0271)
 #define HDA_CODEC_ALC272	HDA_CODEC_CONSTRUCT(REALTEK, 0x0272)
 #define HDA_CODEC_ALC273	HDA_CODEC_CONSTRUCT(REALTEK, 0x0273)
 #define HDA_CODEC_ALC274	HDA_CODEC_CONSTRUCT(REALTEK, 0x0274)
diff --git a/sys/dev/sound/pci/hda/pin_patch.h b/sys/dev/sound/pci/hda/pin_patch.h
new file mode 100644
index 000000000000..8e2c9875906f
--- /dev/null
+++ b/sys/dev/sound/pci/hda/pin_patch.h
@@ -0,0 +1,121 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Khamba Staring <k.staring@quickdecay.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+#ifndef PIN_PATCH_H
+#define PIN_PATCH_H
+
+#include "hdac.h"
+
+#define PIN_SUBVENDOR(sv)		{ .id = sv }
+
+
+#define PIN_PATCH_STRING(n, patchstr) {		\
+	.nid = n,				\
+	.type = PIN_PATCH_TYPE_STRING,		\
+	.patch.string = patchstr		\
+}
+#define PIN_OVERRIDE(n, newvalue) {		\
+	.nid = n,				\
+	.type = PIN_PATCH_TYPE_OVERRIDE,	\
+	.patch.override = newvalue		\
+}
+#define PIN_PATCH_NOT_APPLICABLE(n)		\
+	PIN_PATCH_STRING(n, "as=15 misc=1 color=Black ctype=1/8 device=Speaker loc=Rear conn=None")
+#define PIN_PATCH_HP_OUT(n)			\
+	PIN_PATCH_STRING(n, "seq=15 as=1 color=Green ctype=1/8 device=Headphones loc=Rear")
+#define PIN_PATCH_HP(n)				\
+	PIN_PATCH_STRING(n, "seq=15 as=1 misc=1 color=Green ctype=1/8 device=Headphones loc=Rear")
+#define PIN_PATCH_SPEAKER(n)			\
+	PIN_PATCH_STRING(n, "as=2 misc=1 ctype=ATAPI loc=Onboard conn=Fixed")
+#define PIN_PATCH_BASS_SPEAKER(n)		\
+	PIN_PATCH_STRING(n, "as=3 misc=1 ctype=ATAPI loc=Onboard conn=Fixed")
+#define PIN_PATCH_MIC_IN(n)			\
+	PIN_PATCH_STRING(n, "as=5 misc=9 color=Pink ctype=1/8 device=Mic loc=Rear")
+#define PIN_PATCH_MIC_INTERNAL(n)		\
+	PIN_PATCH_STRING(n, "as=6 misc=1 ctype=Digital device=Mic loc=Internal conn=Fixed")
+#define PIN_PATCH_MIC_FRONT(n)			\
+	PIN_PATCH_STRING(n, "as=4 misc=12 color=Pink ctype=1/8 device=Mic loc=Front")
+#define PIN_PATCH_LINE_IN(n)			\
+	PIN_PATCH_STRING(n, "seq=1 as=3 color=Blue ctype=1/8 device=Line-in loc=Rear")
+#define PIN_PATCH_LINE_OUT(n)			\
+	PIN_PATCH_STRING(n, "as=1 color=Green ctype=1/8 loc=Rear")
+#define PIN_PATCH_SPDIF_OUT(n)			\
+	PIN_PATCH_STRING(n, "as=4 misc=1 color=Green ctype=Optical device=SPDIF-out loc=Rear")
+#define PIN_PATCH_JACK_WO_DETECT(n)		\
+	PIN_PATCH_STRING(n, "seq=12 as=3 misc=1 color=Pink ctype=1/8 device=Mic loc=Rear")
+#define PIN_PATCH_HPMIC_WO_DETECT(n)		\
+	PIN_PATCH_STRING(n, "seq=13 as=3 misc=1 color=Pink ctype=1/8 device=Mic loc=Rear")
+#define PIN_PATCH_HPMIC_WITH_DETECT(n)		\
+	PIN_PATCH_STRING(n, "seq=12 as=3 color=Pink ctype=1/8 device=Mic loc=Rear")
+#define PIN_PATCH_CLFE(n)			\
+	PIN_PATCH_STRING(n, "seq=1 as=1 misc=4 color=Black ctype=1/8 loc=Rear")
+#define PIN_PATCH_SURROUND(n)			\
+	PIN_PATCH_STRING(n, "seq=2 as=1 misc=4 color=Orange ctype=1/8 loc=Rear")
+#define PIN_PATCH_SUBWOOFER(n)			\
+	PIN_PATCH_STRING(n, "seq=1 as=1 misc=1 ctype=ATAPI device=Speaker loc=Onboard conn=Fixed")
+#define PIN_PATCH_DOCK_LINE_OUT(n)		\
+	PIN_PATCH_STRING(n, "seq=15 as=3 color=Black ctype=1/8 loc=Ext-Rear")
+#define PIN_PATCH_DOCK_HP(n)			\
+	PIN_PATCH_STRING(n, "seq=15 as=3 color=Black ctype=1/8 device=Headphones loc=Ext-Rear")
+#define PIN_PATCH_DOCK_MIC_IN(n)		\
+	PIN_PATCH_STRING(n, "as=4 color=Black ctype=1/8 device=Mic loc=Ext-Left")
+
+enum {
+	PIN_PATCH_TYPE_EOL,			/* end-of-list */
+	PIN_PATCH_TYPE_STRING,
+	PIN_PATCH_TYPE_MASK,
+	PIN_PATCH_TYPE_OVERRIDE
+};
+
+struct pin_patch_t {
+	nid_t nid;				/* nid to patch */
+	int type;				/* patch type */
+	union {
+		const char *string;		/* patch string */
+		uint32_t mask[2];		/* pin config mask */
+		uint32_t override;		/* pin config override */
+	} patch;
+};
+
+struct pin_machine_model_t {
+	uint32_t id;				/* vendor machine id */
+};
+
+struct model_pin_patch_t {
+	struct pin_machine_model_t *models;	/* list of machine models */
+	struct pin_patch_t *pin_patches;  	/* hardcoded overrides */
+	void (*fixup_func)(struct hdaa_widget *); /* for future use */
+};
+
+struct hdaa_model_pin_patch_t {
+	uint32_t id;				/* the hdaa id */
+	struct model_pin_patch_t *patches;	/* list of machine patches */
+};
+
+#endif /* PIN_PATCH_H */
diff --git a/sys/dev/sound/pci/hda/pin_patch_realtek.h b/sys/dev/sound/pci/hda/pin_patch_realtek.h
new file mode 100644
index 000000000000..ddaeeaef5345
--- /dev/null
+++ b/sys/dev/sound/pci/hda/pin_patch_realtek.h
@@ -0,0 +1,992 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 Khamba Staring <k.staring@quickdecay.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef PIN_PATCH_REALTEK_H
+#define PIN_PATCH_REALTEK_H
+
+#include "hdac.h"
+#include "pin_patch.h"
+
+/*
+ * Pin patches
+ */
+static struct pin_patch_t pin_patches_lg_lw20[] = {
+	{
+		.nid = 26,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {	HDA_CONFIG_DEFAULTCONF_DEVICE_MASK,
+					HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN }
+	}, {
+		.nid = 27,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {	HDA_CONFIG_DEFAULTCONF_DEVICE_MASK,
+					HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT }
+	}, { }
+};
+
+static struct pin_patch_t pin_patches_clevo_d900t_asus_m5200[] = {
+	{
+		.nid = 24,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {	HDA_CONFIG_DEFAULTCONF_DEVICE_MASK,
+					HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN }
+	}, {
+		.nid = 25,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {	HDA_CONFIG_DEFAULTCONF_DEVICE_MASK,
+					HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN }
+	}, {
+		.nid = 26,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {	HDA_CONFIG_DEFAULTCONF_DEVICE_MASK,
+					HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN }
+	}, {
+		.nid = 27,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {	HDA_CONFIG_DEFAULTCONF_DEVICE_MASK,
+					HDA_CONFIG_DEFAULTCONF_DEVICE_LINE_IN }
+	}, {
+		.nid = 28,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {	HDA_CONFIG_DEFAULTCONF_DEVICE_MASK,
+					HDA_CONFIG_DEFAULTCONF_DEVICE_CD }
+	}, { }
+};
+
+static struct pin_patch_t pin_patches_msi_ms034a[] = {
+	{
+		.nid = 25,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED }
+	}, {
+		.nid = 28,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_CD |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED }
+	}, { }
+};
+
+static struct pin_patch_t pin_patches_asus_w6f[] = {
+	{
+		.nid = 11,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED }
+	}, {
+		.nid = 12,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED }
+	}, {
+		.nid = 14,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED }
+	}, {
+		.nid = 15,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_HP_OUT |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_JACK }
+	}, {
+		.nid = 16,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED }
+	}, {
+		.nid = 31,
+		.type = PIN_PATCH_TYPE_MASK,
+		.patch.mask = {
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MASK |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_MASK,
+			HDA_CONFIG_DEFAULTCONF_DEVICE_MIC_IN |
+                        HDA_CONFIG_DEFAULTCONF_CONNECTIVITY_FIXED }
+	}, {
+		.nid = 32,
*** 839 LINES SKIPPED ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107030617.1636H22I062745>