xref: /freebsd/sys/dev/sound/pci/hda/pin_patch.h (revision c7a063741720ef81d4caa4613242579d12f1d605)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2018 Khamba Staring <k.staring@quickdecay.com>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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.
15  *
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
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 #ifndef PIN_PATCH_H
31 #define PIN_PATCH_H
32 
33 #include "hdac.h"
34 
35 #define PIN_SUBVENDOR(sv)		{ .id = sv }
36 
37 
38 #define PIN_PATCH_STRING(n, patchstr) {		\
39 	.nid = n,				\
40 	.type = PIN_PATCH_TYPE_STRING,		\
41 	.patch.string = patchstr		\
42 }
43 #define PIN_OVERRIDE(n, newvalue) {		\
44 	.nid = n,				\
45 	.type = PIN_PATCH_TYPE_OVERRIDE,	\
46 	.patch.override = newvalue		\
47 }
48 #define PIN_PATCH_NOT_APPLICABLE(n)		\
49 	PIN_PATCH_STRING(n, "as=15 misc=1 color=Black ctype=1/8 device=Speaker loc=Rear conn=None")
50 #define PIN_PATCH_HP_OUT(n)			\
51 	PIN_PATCH_STRING(n, "seq=15 as=1 color=Green ctype=1/8 device=Headphones loc=Rear")
52 #define PIN_PATCH_HP(n)				\
53 	PIN_PATCH_STRING(n, "seq=15 as=1 misc=1 color=Green ctype=1/8 device=Headphones loc=Rear")
54 #define PIN_PATCH_SPEAKER(n)			\
55 	PIN_PATCH_STRING(n, "as=2 misc=1 ctype=ATAPI loc=Onboard conn=Fixed")
56 #define PIN_PATCH_BASS_SPEAKER(n)		\
57 	PIN_PATCH_STRING(n, "as=3 misc=1 ctype=ATAPI loc=Onboard conn=Fixed")
58 #define PIN_PATCH_MIC_IN(n)			\
59 	PIN_PATCH_STRING(n, "as=5 misc=9 color=Pink ctype=1/8 device=Mic loc=Rear")
60 #define PIN_PATCH_MIC_INTERNAL(n)		\
61 	PIN_PATCH_STRING(n, "as=6 misc=1 ctype=Digital device=Mic loc=Internal conn=Fixed")
62 #define PIN_PATCH_MIC_FRONT(n)			\
63 	PIN_PATCH_STRING(n, "as=4 misc=12 color=Pink ctype=1/8 device=Mic loc=Front")
64 #define PIN_PATCH_LINE_IN(n)			\
65 	PIN_PATCH_STRING(n, "seq=1 as=3 color=Blue ctype=1/8 device=Line-in loc=Rear")
66 #define PIN_PATCH_LINE_OUT(n)			\
67 	PIN_PATCH_STRING(n, "as=1 color=Green ctype=1/8 loc=Rear")
68 #define PIN_PATCH_SPDIF_OUT(n)			\
69 	PIN_PATCH_STRING(n, "as=4 misc=1 color=Green ctype=Optical device=SPDIF-out loc=Rear")
70 #define PIN_PATCH_JACK_WO_DETECT(n)		\
71 	PIN_PATCH_STRING(n, "seq=12 as=3 misc=1 color=Pink ctype=1/8 device=Mic loc=Rear")
72 #define PIN_PATCH_HPMIC_WO_DETECT(n)		\
73 	PIN_PATCH_STRING(n, "seq=13 as=3 misc=1 color=Pink ctype=1/8 device=Mic loc=Rear")
74 #define PIN_PATCH_HPMIC_WITH_DETECT(n)		\
75 	PIN_PATCH_STRING(n, "seq=12 as=3 color=Pink ctype=1/8 device=Mic loc=Rear")
76 #define PIN_PATCH_CLFE(n)			\
77 	PIN_PATCH_STRING(n, "seq=1 as=1 misc=4 color=Black ctype=1/8 loc=Rear")
78 #define PIN_PATCH_SURROUND(n)			\
79 	PIN_PATCH_STRING(n, "seq=2 as=1 misc=4 color=Orange ctype=1/8 loc=Rear")
80 #define PIN_PATCH_SUBWOOFER(n)			\
81 	PIN_PATCH_STRING(n, "seq=1 as=1 misc=1 ctype=ATAPI device=Speaker loc=Onboard conn=Fixed")
82 #define PIN_PATCH_DOCK_LINE_OUT(n)		\
83 	PIN_PATCH_STRING(n, "seq=15 as=3 color=Black ctype=1/8 loc=Ext-Rear")
84 #define PIN_PATCH_DOCK_HP(n)			\
85 	PIN_PATCH_STRING(n, "seq=15 as=3 color=Black ctype=1/8 device=Headphones loc=Ext-Rear")
86 #define PIN_PATCH_DOCK_MIC_IN(n)		\
87 	PIN_PATCH_STRING(n, "as=4 color=Black ctype=1/8 device=Mic loc=Ext-Left")
88 
89 enum {
90 	PIN_PATCH_TYPE_EOL,			/* end-of-list */
91 	PIN_PATCH_TYPE_STRING,
92 	PIN_PATCH_TYPE_MASK,
93 	PIN_PATCH_TYPE_OVERRIDE
94 };
95 
96 struct pin_patch_t {
97 	nid_t nid;				/* nid to patch */
98 	int type;				/* patch type */
99 	union {
100 		const char *string;		/* patch string */
101 		uint32_t mask[2];		/* pin config mask */
102 		uint32_t override;		/* pin config override */
103 	} patch;
104 };
105 
106 struct pin_machine_model_t {
107 	uint32_t id;				/* vendor machine id */
108 };
109 
110 struct model_pin_patch_t {
111 	struct pin_machine_model_t *models;	/* list of machine models */
112 	struct pin_patch_t *pin_patches;	/* hardcoded overrides */
113 	void (*fixup_func)(struct hdaa_widget *); /* for future use */
114 };
115 
116 struct hdaa_model_pin_patch_t {
117 	uint32_t id;				/* the hdaa id */
118 	struct model_pin_patch_t *patches;	/* list of machine patches */
119 };
120 
121 #endif /* PIN_PATCH_H */
122