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