1 | /* ENDIANNESS: DevIchHdaCodec.cpp 99354 2015-04-01 09:29:05Z andy $ */
|
---|
2 | /** @file
|
---|
3 | * DevIchHdaCodec - VBox ICH Intel HD Audio Codec.
|
---|
4 | *
|
---|
5 | * Implemented against "Intel I/O Controller Hub 6 (ICH6) High Definition
|
---|
6 | * Audio / AC '97 - Programmer's Reference Manual (PRM)", document number
|
---|
7 | * 302349-003.
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Copyright (C) 2006-2014 Oracle Corporation
|
---|
12 | *
|
---|
13 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | * available from http://www.virtualbox.org. This file is free software;
|
---|
15 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | * General Public License (GPL) as published by the Free Software
|
---|
17 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /*******************************************************************************
|
---|
24 | * Header Files *
|
---|
25 | *******************************************************************************/
|
---|
26 | //#define LOG_GROUP LOG_GROUP_DEV_AUDIO
|
---|
27 | #include <VBox/vmm/pdmdev.h>
|
---|
28 | #include <VBox/vmm/pdmaudioifs.h>
|
---|
29 | #include <iprt/assert.h>
|
---|
30 | #include <iprt/uuid.h>
|
---|
31 | #include <iprt/string.h>
|
---|
32 | #include <iprt/mem.h>
|
---|
33 | #include <iprt/asm.h>
|
---|
34 | #include <iprt/cpp/utils.h>
|
---|
35 |
|
---|
36 | #include "VBoxDD.h"
|
---|
37 | #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
38 | extern "C" {
|
---|
39 | #include "audio.h"
|
---|
40 | }
|
---|
41 | #endif
|
---|
42 | #include "DevIchHdaCodec.h"
|
---|
43 |
|
---|
44 |
|
---|
45 | /*******************************************************************************
|
---|
46 | * Defined Constants And Macros *
|
---|
47 | *******************************************************************************/
|
---|
48 | /* PRM 5.3.1 */
|
---|
49 | /** Codec address mask. */
|
---|
50 | #define CODEC_CAD_MASK 0xF0000000
|
---|
51 | /** Codec address shift. */
|
---|
52 | #define CODEC_CAD_SHIFT 28
|
---|
53 | #define CODEC_DIRECT_MASK RT_BIT(27)
|
---|
54 | /** Node ID mask. */
|
---|
55 | #define CODEC_NID_MASK 0x07F00000
|
---|
56 | /** Node ID shift. */
|
---|
57 | #define CODEC_NID_SHIFT 20
|
---|
58 | #define CODEC_VERBDATA_MASK 0x000FFFFF
|
---|
59 | #define CODEC_VERB_4BIT_CMD 0x000FFFF0
|
---|
60 | #define CODEC_VERB_4BIT_DATA 0x0000000F
|
---|
61 | #define CODEC_VERB_8BIT_CMD 0x000FFF00
|
---|
62 | #define CODEC_VERB_8BIT_DATA 0x000000FF
|
---|
63 | #define CODEC_VERB_16BIT_CMD 0x000F0000
|
---|
64 | #define CODEC_VERB_16BIT_DATA 0x0000FFFF
|
---|
65 |
|
---|
66 | #define CODEC_CAD(cmd) (((cmd) & CODEC_CAD_MASK) >> CODEC_CAD_SHIFT)
|
---|
67 | #define CODEC_DIRECT(cmd) ((cmd) & CODEC_DIRECT_MASK)
|
---|
68 | #define CODEC_NID(cmd) ((((cmd) & CODEC_NID_MASK)) >> CODEC_NID_SHIFT)
|
---|
69 | #define CODEC_VERBDATA(cmd) ((cmd) & CODEC_VERBDATA_MASK)
|
---|
70 | #define CODEC_VERB_CMD(cmd, mask, x) (((cmd) & (mask)) >> (x))
|
---|
71 | #define CODEC_VERB_CMD4(cmd) (CODEC_VERB_CMD((cmd), CODEC_VERB_4BIT_CMD, 4))
|
---|
72 | #define CODEC_VERB_CMD8(cmd) (CODEC_VERB_CMD((cmd), CODEC_VERB_8BIT_CMD, 8))
|
---|
73 | #define CODEC_VERB_CMD16(cmd) (CODEC_VERB_CMD((cmd), CODEC_VERB_16BIT_CMD, 16))
|
---|
74 | #define CODEC_VERB_PAYLOAD4(cmd) ((cmd) & CODEC_VERB_4BIT_DATA)
|
---|
75 | #define CODEC_VERB_PAYLOAD8(cmd) ((cmd) & CODEC_VERB_8BIT_DATA)
|
---|
76 | #define CODEC_VERB_PAYLOAD16(cmd) ((cmd) & CODEC_VERB_16BIT_DATA)
|
---|
77 |
|
---|
78 | #define CODEC_VERB_GET_AMP_DIRECTION RT_BIT(15)
|
---|
79 | #define CODEC_VERB_GET_AMP_SIDE RT_BIT(13)
|
---|
80 | #define CODEC_VERB_GET_AMP_INDEX 0x7
|
---|
81 |
|
---|
82 | /* HDA spec 7.3.3.7 NoteA */
|
---|
83 | #define CODEC_GET_AMP_DIRECTION(cmd) (((cmd) & CODEC_VERB_GET_AMP_DIRECTION) >> 15)
|
---|
84 | #define CODEC_GET_AMP_SIDE(cmd) (((cmd) & CODEC_VERB_GET_AMP_SIDE) >> 13)
|
---|
85 | #define CODEC_GET_AMP_INDEX(cmd) (CODEC_GET_AMP_DIRECTION(cmd) ? 0 : ((cmd) & CODEC_VERB_GET_AMP_INDEX))
|
---|
86 |
|
---|
87 | /* HDA spec 7.3.3.7 NoteC */
|
---|
88 | #define CODEC_VERB_SET_AMP_OUT_DIRECTION RT_BIT(15)
|
---|
89 | #define CODEC_VERB_SET_AMP_IN_DIRECTION RT_BIT(14)
|
---|
90 | #define CODEC_VERB_SET_AMP_LEFT_SIDE RT_BIT(13)
|
---|
91 | #define CODEC_VERB_SET_AMP_RIGHT_SIDE RT_BIT(12)
|
---|
92 | #define CODEC_VERB_SET_AMP_INDEX (0x7 << 8)
|
---|
93 |
|
---|
94 | #define CODEC_SET_AMP_IS_OUT_DIRECTION(cmd) (((cmd) & CODEC_VERB_SET_AMP_OUT_DIRECTION) != 0)
|
---|
95 | #define CODEC_SET_AMP_IS_IN_DIRECTION(cmd) (((cmd) & CODEC_VERB_SET_AMP_IN_DIRECTION) != 0)
|
---|
96 | #define CODEC_SET_AMP_IS_LEFT_SIDE(cmd) (((cmd) & CODEC_VERB_SET_AMP_LEFT_SIDE) != 0)
|
---|
97 | #define CODEC_SET_AMP_IS_RIGHT_SIDE(cmd) (((cmd) & CODEC_VERB_SET_AMP_RIGHT_SIDE) != 0)
|
---|
98 | #define CODEC_SET_AMP_INDEX(cmd) (((cmd) & CODEC_VERB_SET_AMP_INDEX) >> 7)
|
---|
99 |
|
---|
100 | /* HDA spec 7.3.3.1 defines layout of configuration registers/verbs (0xF00) */
|
---|
101 | /* VendorID (7.3.4.1) */
|
---|
102 | #define CODEC_MAKE_F00_00(vendorID, deviceID) (((vendorID) << 16) | (deviceID))
|
---|
103 | #define CODEC_F00_00_VENDORID(f00_00) (((f00_00) >> 16) & 0xFFFF)
|
---|
104 | #define CODEC_F00_00_DEVICEID(f00_00) ((f00_00) & 0xFFFF)
|
---|
105 | /* RevisionID (7.3.4.2)*/
|
---|
106 | #define CODEC_MAKE_F00_02(MajRev, MinRev, RevisionID, SteppingID) (((MajRev) << 20)|((MinRev) << 16)|((RevisionID) << 8)|(SteppingID))
|
---|
107 | /* Subordinate node count (7.3.4.3)*/
|
---|
108 | #define CODEC_MAKE_F00_04(startNodeNumber, totalNodeNumber) ((((startNodeNumber) & 0xFF) << 16)|((totalNodeNumber) & 0xFF))
|
---|
109 | #define CODEC_F00_04_TO_START_NODE_NUMBER(f00_04) (((f00_04) >> 16) & 0xFF)
|
---|
110 | #define CODEC_F00_04_TO_NODE_COUNT(f00_04) ((f00_04) & 0xFF)
|
---|
111 | /*
|
---|
112 | * Function Group Type (7.3.4.4)
|
---|
113 | * 0 & [0x3-0x7f] are reserved types
|
---|
114 | * [0x80 - 0xff] are vendor defined function groups
|
---|
115 | */
|
---|
116 | #define CODEC_MAKE_F00_05(UnSol, NodeType) (((UnSol) << 8)|(NodeType))
|
---|
117 | #define CODEC_F00_05_UNSOL RT_BIT(8)
|
---|
118 | #define CODEC_F00_05_AFG (0x1)
|
---|
119 | #define CODEC_F00_05_MFG (0x2)
|
---|
120 | #define CODEC_F00_05_IS_UNSOL(f00_05) RT_BOOL((f00_05) & RT_BIT(8))
|
---|
121 | #define CODEC_F00_05_GROUP(f00_05) ((f00_05) & 0xff)
|
---|
122 | /* Audio Function Group capabilities (7.3.4.5) */
|
---|
123 | #define CODEC_MAKE_F00_08(BeepGen, InputDelay, OutputDelay) ((((BeepGen) & 0x1) << 16)| (((InputDelay) & 0xF) << 8) | ((OutputDelay) & 0xF))
|
---|
124 | #define CODEC_F00_08_BEEP_GEN(f00_08) ((f00_08) & RT_BIT(16)
|
---|
125 |
|
---|
126 | /* Widget Capabilities (7.3.4.6) */
|
---|
127 | #define CODEC_MAKE_F00_09(type, delay, chanel_count) \
|
---|
128 | ( (((type) & 0xF) << 20) \
|
---|
129 | | (((delay) & 0xF) << 16) \
|
---|
130 | | (((chanel_count) & 0xF) << 13))
|
---|
131 | /* note: types 0x8-0xe are reserved */
|
---|
132 | #define CODEC_F00_09_TYPE_AUDIO_OUTPUT (0x0)
|
---|
133 | #define CODEC_F00_09_TYPE_AUDIO_INPUT (0x1)
|
---|
134 | #define CODEC_F00_09_TYPE_AUDIO_MIXER (0x2)
|
---|
135 | #define CODEC_F00_09_TYPE_AUDIO_SELECTOR (0x3)
|
---|
136 | #define CODEC_F00_09_TYPE_PIN_COMPLEX (0x4)
|
---|
137 | #define CODEC_F00_09_TYPE_POWER_WIDGET (0x5)
|
---|
138 | #define CODEC_F00_09_TYPE_VOLUME_KNOB (0x6)
|
---|
139 | #define CODEC_F00_09_TYPE_BEEP_GEN (0x7)
|
---|
140 | #define CODEC_F00_09_TYPE_VENDOR_DEFINED (0xF)
|
---|
141 |
|
---|
142 | #define CODEC_F00_09_CAP_CP RT_BIT(12)
|
---|
143 | #define CODEC_F00_09_CAP_L_R_SWAP RT_BIT(11)
|
---|
144 | #define CODEC_F00_09_CAP_POWER_CTRL RT_BIT(10)
|
---|
145 | #define CODEC_F00_09_CAP_DIGITAL RT_BIT(9)
|
---|
146 | #define CODEC_F00_09_CAP_CONNECTION_LIST RT_BIT(8)
|
---|
147 | #define CODEC_F00_09_CAP_UNSOL RT_BIT(7)
|
---|
148 | #define CODEC_F00_09_CAP_PROC_WIDGET RT_BIT(6)
|
---|
149 | #define CODEC_F00_09_CAP_STRIPE RT_BIT(5)
|
---|
150 | #define CODEC_F00_09_CAP_FMT_OVERRIDE RT_BIT(4)
|
---|
151 | #define CODEC_F00_09_CAP_AMP_FMT_OVERRIDE RT_BIT(3)
|
---|
152 | #define CODEC_F00_09_CAP_OUT_AMP_PRESENT RT_BIT(2)
|
---|
153 | #define CODEC_F00_09_CAP_IN_AMP_PRESENT RT_BIT(1)
|
---|
154 | #define CODEC_F00_09_CAP_LSB RT_BIT(0)
|
---|
155 |
|
---|
156 | #define CODEC_F00_09_TYPE(f00_09) (((f00_09) >> 20) & 0xF)
|
---|
157 |
|
---|
158 | #define CODEC_F00_09_IS_CAP_CP(f00_09) RT_BOOL((f00_09) & RT_BIT(12))
|
---|
159 | #define CODEC_F00_09_IS_CAP_L_R_SWAP(f00_09) RT_BOOL((f00_09) & RT_BIT(11))
|
---|
160 | #define CODEC_F00_09_IS_CAP_POWER_CTRL(f00_09) RT_BOOL((f00_09) & RT_BIT(10))
|
---|
161 | #define CODEC_F00_09_IS_CAP_DIGITAL(f00_09) RT_BOOL((f00_09) & RT_BIT(9))
|
---|
162 | #define CODEC_F00_09_IS_CAP_CONNECTION_LIST(f00_09) RT_BOOL((f00_09) & RT_BIT(8))
|
---|
163 | #define CODEC_F00_09_IS_CAP_UNSOL(f00_09) RT_BOOL((f00_09) & RT_BIT(7))
|
---|
164 | #define CODEC_F00_09_IS_CAP_PROC_WIDGET(f00_09) RT_BOOL((f00_09) & RT_BIT(6))
|
---|
165 | #define CODEC_F00_09_IS_CAP_STRIPE(f00_09) RT_BOOL((f00_09) & RT_BIT(5))
|
---|
166 | #define CODEC_F00_09_IS_CAP_FMT_OVERRIDE(f00_09) RT_BOOL((f00_09) & RT_BIT(4))
|
---|
167 | #define CODEC_F00_09_IS_CAP_AMP_OVERRIDE(f00_09) RT_BOOL((f00_09) & RT_BIT(3))
|
---|
168 | #define CODEC_F00_09_IS_CAP_OUT_AMP_PRESENT(f00_09) RT_BOOL((f00_09) & RT_BIT(2))
|
---|
169 | #define CODEC_F00_09_IS_CAP_IN_AMP_PRESENT(f00_09) RT_BOOL((f00_09) & RT_BIT(1))
|
---|
170 | #define CODEC_F00_09_IS_CAP_LSB(f00_09) RT_BOOL((f00_09) & RT_BIT(0))
|
---|
171 |
|
---|
172 | /* Supported PCM size, rates (7.3.4.7) */
|
---|
173 | #define CODEC_F00_0A_32_BIT RT_BIT(19)
|
---|
174 | #define CODEC_F00_0A_24_BIT RT_BIT(18)
|
---|
175 | #define CODEC_F00_0A_16_BIT RT_BIT(17)
|
---|
176 | #define CODEC_F00_0A_8_BIT RT_BIT(16)
|
---|
177 |
|
---|
178 | #define CODEC_F00_0A_48KHZ_MULT_8X RT_BIT(11)
|
---|
179 | #define CODEC_F00_0A_48KHZ_MULT_4X RT_BIT(10)
|
---|
180 | #define CODEC_F00_0A_44_1KHZ_MULT_4X RT_BIT(9)
|
---|
181 | #define CODEC_F00_0A_48KHZ_MULT_2X RT_BIT(8)
|
---|
182 | #define CODEC_F00_0A_44_1KHZ_MULT_2X RT_BIT(7)
|
---|
183 | #define CODEC_F00_0A_48KHZ RT_BIT(6)
|
---|
184 | #define CODEC_F00_0A_44_1KHZ RT_BIT(5)
|
---|
185 | /* 2/3 * 48kHz */
|
---|
186 | #define CODEC_F00_0A_48KHZ_2_3X RT_BIT(4)
|
---|
187 | /* 1/2 * 44.1kHz */
|
---|
188 | #define CODEC_F00_0A_44_1KHZ_1_2X RT_BIT(3)
|
---|
189 | /* 1/3 * 48kHz */
|
---|
190 | #define CODEC_F00_0A_48KHZ_1_3X RT_BIT(2)
|
---|
191 | /* 1/4 * 44.1kHz */
|
---|
192 | #define CODEC_F00_0A_44_1KHZ_1_4X RT_BIT(1)
|
---|
193 | /* 1/6 * 48kHz */
|
---|
194 | #define CODEC_F00_0A_48KHZ_1_6X RT_BIT(0)
|
---|
195 |
|
---|
196 | /* Supported streams formats (7.3.4.8) */
|
---|
197 | #define CODEC_F00_0B_AC3 RT_BIT(2)
|
---|
198 | #define CODEC_F00_0B_FLOAT32 RT_BIT(1)
|
---|
199 | #define CODEC_F00_0B_PCM RT_BIT(0)
|
---|
200 |
|
---|
201 | /* Pin Capabilities (7.3.4.9)*/
|
---|
202 | #define CODEC_MAKE_F00_0C(vref_ctrl) (((vref_ctrl) & 0xFF) << 8)
|
---|
203 | #define CODEC_F00_0C_CAP_HBR RT_BIT(27)
|
---|
204 | #define CODEC_F00_0C_CAP_DP RT_BIT(24)
|
---|
205 | #define CODEC_F00_0C_CAP_EAPD RT_BIT(16)
|
---|
206 | #define CODEC_F00_0C_CAP_HDMI RT_BIT(7)
|
---|
207 | #define CODEC_F00_0C_CAP_BALANCED_IO RT_BIT(6)
|
---|
208 | #define CODEC_F00_0C_CAP_INPUT RT_BIT(5)
|
---|
209 | #define CODEC_F00_0C_CAP_OUTPUT RT_BIT(4)
|
---|
210 | #define CODEC_F00_0C_CAP_HP RT_BIT(3)
|
---|
211 | #define CODEC_F00_0C_CAP_PRESENSE_DETECT RT_BIT(2)
|
---|
212 | #define CODEC_F00_0C_CAP_TRIGGER_REQUIRED RT_BIT(1)
|
---|
213 | #define CODEC_F00_0C_CAP_IMPENDANCE_SENSE RT_BIT(0)
|
---|
214 |
|
---|
215 | #define CODEC_F00_0C_IS_CAP_HBR(f00_0c) ((f00_0c) & RT_BIT(27))
|
---|
216 | #define CODEC_F00_0C_IS_CAP_DP(f00_0c) ((f00_0c) & RT_BIT(24))
|
---|
217 | #define CODEC_F00_0C_IS_CAP_EAPD(f00_0c) ((f00_0c) & RT_BIT(16))
|
---|
218 | #define CODEC_F00_0C_IS_CAP_HDMI(f00_0c) ((f00_0c) & RT_BIT(7))
|
---|
219 | #define CODEC_F00_0C_IS_CAP_BALANCED_IO(f00_0c) ((f00_0c) & RT_BIT(6))
|
---|
220 | #define CODEC_F00_0C_IS_CAP_INPUT(f00_0c) ((f00_0c) & RT_BIT(5))
|
---|
221 | #define CODEC_F00_0C_IS_CAP_OUTPUT(f00_0c) ((f00_0c) & RT_BIT(4))
|
---|
222 | #define CODEC_F00_0C_IS_CAP_HP(f00_0c) ((f00_0c) & RT_BIT(3))
|
---|
223 | #define CODEC_F00_0C_IS_CAP_PRESENSE_DETECT(f00_0c) ((f00_0c) & RT_BIT(2))
|
---|
224 | #define CODEC_F00_0C_IS_CAP_TRIGGER_REQUIRED(f00_0c) ((f00_0c) & RT_BIT(1))
|
---|
225 | #define CODEC_F00_0C_IS_CAP_IMPENDANCE_SENSE(f00_0c) ((f00_0c) & RT_BIT(0))
|
---|
226 |
|
---|
227 | /* Input Amplifier capabilities (7.3.4.10) */
|
---|
228 | #define CODEC_MAKE_F00_0D(mute_cap, step_size, num_steps, offset) \
|
---|
229 | ( (((mute_cap) & 0x1) << 31) \
|
---|
230 | | (((step_size) & 0xFF) << 16) \
|
---|
231 | | (((num_steps) & 0xFF) << 8) \
|
---|
232 | | ((offset) & 0xFF))
|
---|
233 |
|
---|
234 | /* Output Amplifier capabilities (7.3.4.10) */
|
---|
235 | #define CODEC_MAKE_F00_12 CODEC_MAKE_F00_0D
|
---|
236 |
|
---|
237 | /* Connection list lenght (7.3.4.11) */
|
---|
238 | #define CODEC_MAKE_F00_0E(long_form, length) \
|
---|
239 | ( (((long_form) & 0x1) << 7) \
|
---|
240 | | ((length) & 0x7F))
|
---|
241 | #define CODEC_F00_0E_IS_LONG(f00_0e) RT_BOOL((f00_0e) & RT_BIT(7))
|
---|
242 | #define CODEC_F00_0E_COUNT(f00_0e) ((f00_0e) & 0x7F)
|
---|
243 | /* Supported Power States (7.3.4.12) */
|
---|
244 | #define CODEC_F00_0F_EPSS RT_BIT(31)
|
---|
245 | #define CODEC_F00_0F_CLKSTOP RT_BIT(30)
|
---|
246 | #define CODEC_F00_0F_S3D3 RT_BIT(29)
|
---|
247 | #define CODEC_F00_0F_D3COLD RT_BIT(4)
|
---|
248 | #define CODEC_F00_0F_D3 RT_BIT(3)
|
---|
249 | #define CODEC_F00_0F_D2 RT_BIT(2)
|
---|
250 | #define CODEC_F00_0F_D1 RT_BIT(1)
|
---|
251 | #define CODEC_F00_0F_D0 RT_BIT(0)
|
---|
252 |
|
---|
253 | /* Processing capabilities 7.3.4.13 */
|
---|
254 | #define CODEC_MAKE_F00_10(num, benign) ((((num) & 0xFF) << 8) | ((benign) & 0x1))
|
---|
255 | #define CODEC_F00_10_NUM(f00_10) (((f00_10) & (0xFF << 8)) >> 8)
|
---|
256 | #define CODEC_F00_10_BENING(f00_10) ((f00_10) & 0x1)
|
---|
257 |
|
---|
258 | /* CP/IO Count (7.3.4.14) */
|
---|
259 | #define CODEC_MAKE_F00_11(wake, unsol, numgpi, numgpo, numgpio) \
|
---|
260 | ( (((wake) & 0x1) << 31) \
|
---|
261 | | (((unsol) & 0x1) << 30) \
|
---|
262 | | (((numgpi) & 0xFF) << 16) \
|
---|
263 | | (((numgpo) & 0xFF) << 8) \
|
---|
264 | | ((numgpio) & 0xFF))
|
---|
265 |
|
---|
266 | /* Processing States (7.3.3.4) */
|
---|
267 | #define CODEC_F03_OFF (0)
|
---|
268 | #define CODEC_F03_ON RT_BIT(0)
|
---|
269 | #define CODEC_F03_BENING RT_BIT(1)
|
---|
270 | /* Power States (7.3.3.10) */
|
---|
271 | #define CODEC_MAKE_F05(reset, stopok, error, act, set) \
|
---|
272 | ( (((reset) & 0x1) << 10) \
|
---|
273 | | (((stopok) & 0x1) << 9) \
|
---|
274 | | (((error) & 0x1) << 8) \
|
---|
275 | | (((act) & 0x7) << 4) \
|
---|
276 | | ((set) & 0x7))
|
---|
277 | #define CODEC_F05_D3COLD (4)
|
---|
278 | #define CODEC_F05_D3 (3)
|
---|
279 | #define CODEC_F05_D2 (2)
|
---|
280 | #define CODEC_F05_D1 (1)
|
---|
281 | #define CODEC_F05_D0 (0)
|
---|
282 |
|
---|
283 | #define CODEC_F05_IS_RESET(value) (((value) & RT_BIT(10)) != 0)
|
---|
284 | #define CODEC_F05_IS_STOPOK(value) (((value) & RT_BIT(9)) != 0)
|
---|
285 | #define CODEC_F05_IS_ERROR(value) (((value) & RT_BIT(8)) != 0)
|
---|
286 | #define CODEC_F05_ACT(value) (((value) & 0x7) >> 4)
|
---|
287 | #define CODEC_F05_SET(value) (((value) & 0x7))
|
---|
288 |
|
---|
289 | #define CODEC_F05_GE(p0, p1) ((p0) <= (p1))
|
---|
290 | #define CODEC_F05_LE(p0, p1) ((p0) >= (p1))
|
---|
291 |
|
---|
292 | /* Pin Widged Control (7.3.3.13) */
|
---|
293 | #define CODEC_F07_VREF_HIZ (0)
|
---|
294 | #define CODEC_F07_VREF_50 (0x1)
|
---|
295 | #define CODEC_F07_VREF_GROUND (0x2)
|
---|
296 | #define CODEC_F07_VREF_80 (0x4)
|
---|
297 | #define CODEC_F07_VREF_100 (0x5)
|
---|
298 | #define CODEC_F07_IN_ENABLE RT_BIT(5)
|
---|
299 | #define CODEC_F07_OUT_ENABLE RT_BIT(6)
|
---|
300 | #define CODEC_F07_OUT_H_ENABLE RT_BIT(7)
|
---|
301 |
|
---|
302 | /* Unsolicited enabled (7.3.3.14) */
|
---|
303 | #define CODEC_MAKE_F08(enable, tag) ((((enable) & 1) << 7) | ((tag) & 0x3F))
|
---|
304 |
|
---|
305 | /* Converter formats (7.3.3.8) and (3.7.1) */
|
---|
306 | #define CODEC_MAKE_A(fNonPCM, f44_1BaseRate, mult, div, bits, chan) \
|
---|
307 | ( (((fNonPCM) & 0x1) << 15) \
|
---|
308 | | (((f44_1BaseRate) & 0x1) << 14) \
|
---|
309 | | (((mult) & 0x7) << 11) \
|
---|
310 | | (((div) & 0x7) << 8) \
|
---|
311 | | (((bits) & 0x7) << 4) \
|
---|
312 | | ((chan) & 0xF))
|
---|
313 |
|
---|
314 | #define CODEC_A_MULT_1X (0)
|
---|
315 | #define CODEC_A_MULT_2X (1)
|
---|
316 | #define CODEC_A_MULT_3X (2)
|
---|
317 | #define CODEC_A_MULT_4X (3)
|
---|
318 |
|
---|
319 | #define CODEC_A_DIV_1X (0)
|
---|
320 | #define CODEC_A_DIV_2X (1)
|
---|
321 | #define CODEC_A_DIV_3X (2)
|
---|
322 | #define CODEC_A_DIV_4X (3)
|
---|
323 | #define CODEC_A_DIV_5X (4)
|
---|
324 | #define CODEC_A_DIV_6X (5)
|
---|
325 | #define CODEC_A_DIV_7X (6)
|
---|
326 | #define CODEC_A_DIV_8X (7)
|
---|
327 |
|
---|
328 | #define CODEC_A_8_BIT (0)
|
---|
329 | #define CODEC_A_16_BIT (1)
|
---|
330 | #define CODEC_A_20_BIT (2)
|
---|
331 | #define CODEC_A_24_BIT (3)
|
---|
332 | #define CODEC_A_32_BIT (4)
|
---|
333 |
|
---|
334 | /* Pin Sense (7.3.3.15) */
|
---|
335 | #define CODEC_MAKE_F09_ANALOG(fPresent, impedance) \
|
---|
336 | ( (((fPresent) & 0x1) << 31) \
|
---|
337 | | (((impedance) & 0x7FFFFFFF)))
|
---|
338 | #define CODEC_F09_ANALOG_NA 0x7FFFFFFF
|
---|
339 | #define CODEC_MAKE_F09_DIGITAL(fPresent, fELDValid) \
|
---|
340 | ( (((fPresent) & 0x1) << 31) \
|
---|
341 | | (((fELDValid) & 0x1) << 30))
|
---|
342 |
|
---|
343 | #define CODEC_MAKE_F0C(lrswap, eapd, btl) ((((lrswap) & 1) << 2) | (((eapd) & 1) << 1) | ((btl) & 1))
|
---|
344 | #define CODEC_FOC_IS_LRSWAP(f0c) RT_BOOL((f0c) & RT_BIT(2))
|
---|
345 | #define CODEC_FOC_IS_EAPD(f0c) RT_BOOL((f0c) & RT_BIT(1))
|
---|
346 | #define CODEC_FOC_IS_BTL(f0c) RT_BOOL((f0c) & RT_BIT(0))
|
---|
347 | /* HDA spec 7.3.3.31 defines layout of configuration registers/verbs (0xF1C) */
|
---|
348 | /* Configuration's port connection */
|
---|
349 | #define CODEC_F1C_PORT_MASK (0x3)
|
---|
350 | #define CODEC_F1C_PORT_SHIFT (30)
|
---|
351 |
|
---|
352 | #define CODEC_F1C_PORT_COMPLEX (0x0)
|
---|
353 | #define CODEC_F1C_PORT_NO_PHYS (0x1)
|
---|
354 | #define CODEC_F1C_PORT_FIXED (0x2)
|
---|
355 | #define CODEC_F1C_BOTH (0x3)
|
---|
356 |
|
---|
357 | /* Configuration's location */
|
---|
358 | #define CODEC_F1C_LOCATION_MASK (0x3F)
|
---|
359 | #define CODEC_F1C_LOCATION_SHIFT (24)
|
---|
360 | /* [4:5] bits of location region means chassis attachment */
|
---|
361 | #define CODEC_F1C_LOCATION_PRIMARY_CHASSIS (0)
|
---|
362 | #define CODEC_F1C_LOCATION_INTERNAL RT_BIT(4)
|
---|
363 | #define CODEC_F1C_LOCATION_SECONDRARY_CHASSIS RT_BIT(5)
|
---|
364 | #define CODEC_F1C_LOCATION_OTHER (RT_BIT(5))
|
---|
365 |
|
---|
366 | /* [0:3] bits of location region means geometry location attachment */
|
---|
367 | #define CODEC_F1C_LOCATION_NA (0)
|
---|
368 | #define CODEC_F1C_LOCATION_REAR (0x1)
|
---|
369 | #define CODEC_F1C_LOCATION_FRONT (0x2)
|
---|
370 | #define CODEC_F1C_LOCATION_LEFT (0x3)
|
---|
371 | #define CODEC_F1C_LOCATION_RIGTH (0x4)
|
---|
372 | #define CODEC_F1C_LOCATION_TOP (0x5)
|
---|
373 | #define CODEC_F1C_LOCATION_BOTTOM (0x6)
|
---|
374 | #define CODEC_F1C_LOCATION_SPECIAL_0 (0x7)
|
---|
375 | #define CODEC_F1C_LOCATION_SPECIAL_1 (0x8)
|
---|
376 | #define CODEC_F1C_LOCATION_SPECIAL_2 (0x9)
|
---|
377 |
|
---|
378 | /* Configuration's devices */
|
---|
379 | #define CODEC_F1C_DEVICE_MASK (0xF)
|
---|
380 | #define CODEC_F1C_DEVICE_SHIFT (20)
|
---|
381 | #define CODEC_F1C_DEVICE_LINE_OUT (0)
|
---|
382 | #define CODEC_F1C_DEVICE_SPEAKER (0x1)
|
---|
383 | #define CODEC_F1C_DEVICE_HP (0x2)
|
---|
384 | #define CODEC_F1C_DEVICE_CD (0x3)
|
---|
385 | #define CODEC_F1C_DEVICE_SPDIF_OUT (0x4)
|
---|
386 | #define CODEC_F1C_DEVICE_DIGITAL_OTHER_OUT (0x5)
|
---|
387 | #define CODEC_F1C_DEVICE_MODEM_LINE_SIDE (0x6)
|
---|
388 | #define CODEC_F1C_DEVICE_MODEM_HANDSET_SIDE (0x7)
|
---|
389 | #define CODEC_F1C_DEVICE_LINE_IN (0x8)
|
---|
390 | #define CODEC_F1C_DEVICE_AUX (0x9)
|
---|
391 | #define CODEC_F1C_DEVICE_MIC (0xA)
|
---|
392 | #define CODEC_F1C_DEVICE_PHONE (0xB)
|
---|
393 | #define CODEC_F1C_DEVICE_SPDIF_IN (0xC)
|
---|
394 | #define CODEC_F1C_DEVICE_RESERVED (0xE)
|
---|
395 | #define CODEC_F1C_DEVICE_OTHER (0xF)
|
---|
396 |
|
---|
397 | /* Configuration's Connection type */
|
---|
398 | #define CODEC_F1C_CONNECTION_TYPE_MASK (0xF)
|
---|
399 | #define CODEC_F1C_CONNECTION_TYPE_SHIFT (16)
|
---|
400 |
|
---|
401 | #define CODEC_F1C_CONNECTION_TYPE_UNKNOWN (0)
|
---|
402 | #define CODEC_F1C_CONNECTION_TYPE_1_8INCHES (0x1)
|
---|
403 | #define CODEC_F1C_CONNECTION_TYPE_1_4INCHES (0x2)
|
---|
404 | #define CODEC_F1C_CONNECTION_TYPE_ATAPI (0x3)
|
---|
405 | #define CODEC_F1C_CONNECTION_TYPE_RCA (0x4)
|
---|
406 | #define CODEC_F1C_CONNECTION_TYPE_OPTICAL (0x5)
|
---|
407 | #define CODEC_F1C_CONNECTION_TYPE_OTHER_DIGITAL (0x6)
|
---|
408 | #define CODEC_F1C_CONNECTION_TYPE_ANALOG (0x7)
|
---|
409 | #define CODEC_F1C_CONNECTION_TYPE_DIN (0x8)
|
---|
410 | #define CODEC_F1C_CONNECTION_TYPE_XLR (0x9)
|
---|
411 | #define CODEC_F1C_CONNECTION_TYPE_RJ_11 (0xA)
|
---|
412 | #define CODEC_F1C_CONNECTION_TYPE_COMBO (0xB)
|
---|
413 | #define CODEC_F1C_CONNECTION_TYPE_OTHER (0xF)
|
---|
414 |
|
---|
415 | /* Configuration's color */
|
---|
416 | #define CODEC_F1C_COLOR_MASK (0xF)
|
---|
417 | #define CODEC_F1C_COLOR_SHIFT (12)
|
---|
418 | #define CODEC_F1C_COLOR_UNKNOWN (0)
|
---|
419 | #define CODEC_F1C_COLOR_BLACK (0x1)
|
---|
420 | #define CODEC_F1C_COLOR_GREY (0x2)
|
---|
421 | #define CODEC_F1C_COLOR_BLUE (0x3)
|
---|
422 | #define CODEC_F1C_COLOR_GREEN (0x4)
|
---|
423 | #define CODEC_F1C_COLOR_RED (0x5)
|
---|
424 | #define CODEC_F1C_COLOR_ORANGE (0x6)
|
---|
425 | #define CODEC_F1C_COLOR_YELLOW (0x7)
|
---|
426 | #define CODEC_F1C_COLOR_PURPLE (0x8)
|
---|
427 | #define CODEC_F1C_COLOR_PINK (0x9)
|
---|
428 | #define CODEC_F1C_COLOR_RESERVED_0 (0xA)
|
---|
429 | #define CODEC_F1C_COLOR_RESERVED_1 (0xB)
|
---|
430 | #define CODEC_F1C_COLOR_RESERVED_2 (0xC)
|
---|
431 | #define CODEC_F1C_COLOR_RESERVED_3 (0xD)
|
---|
432 | #define CODEC_F1C_COLOR_WHITE (0xE)
|
---|
433 | #define CODEC_F1C_COLOR_OTHER (0xF)
|
---|
434 |
|
---|
435 | /* Configuration's misc */
|
---|
436 | #define CODEC_F1C_MISC_MASK (0xF)
|
---|
437 | #define CODEC_F1C_MISC_SHIFT (8)
|
---|
438 | #define CODEC_F1C_MISC_JACK_DETECT (0)
|
---|
439 | #define CODEC_F1C_MISC_RESERVED_0 (1)
|
---|
440 | #define CODEC_F1C_MISC_RESERVED_1 (2)
|
---|
441 | #define CODEC_F1C_MISC_RESERVED_2 (3)
|
---|
442 |
|
---|
443 | /* Configuration's association */
|
---|
444 | #define CODEC_F1C_ASSOCIATION_MASK (0xF)
|
---|
445 | #define CODEC_F1C_ASSOCIATION_SHIFT (4)
|
---|
446 | /* Connection's sequence */
|
---|
447 | #define CODEC_F1C_SEQ_MASK (0xF)
|
---|
448 | #define CODEC_F1C_SEQ_SHIFT (0)
|
---|
449 |
|
---|
450 | /* Implementation identification (7.3.3.30) */
|
---|
451 | #define CODEC_MAKE_F20(bmid, bsku, aid) \
|
---|
452 | ( (((bmid) & 0xFFFF) << 16) \
|
---|
453 | | (((bsku) & 0xFF) << 8) \
|
---|
454 | | (((aid) & 0xFF)) \
|
---|
455 | )
|
---|
456 |
|
---|
457 | /* macro definition helping in filling the configuration registers. */
|
---|
458 | #define CODEC_MAKE_F1C(port_connectivity, location, device, connection_type, color, misc, association, sequence) \
|
---|
459 | ( ((port_connectivity) << CODEC_F1C_PORT_SHIFT) \
|
---|
460 | | ((location) << CODEC_F1C_LOCATION_SHIFT) \
|
---|
461 | | ((device) << CODEC_F1C_DEVICE_SHIFT) \
|
---|
462 | | ((connection_type) << CODEC_F1C_CONNECTION_TYPE_SHIFT) \
|
---|
463 | | ((color) << CODEC_F1C_COLOR_SHIFT) \
|
---|
464 | | ((misc) << CODEC_F1C_MISC_SHIFT) \
|
---|
465 | | ((association) << CODEC_F1C_ASSOCIATION_SHIFT) \
|
---|
466 | | ((sequence)))
|
---|
467 |
|
---|
468 |
|
---|
469 | /*******************************************************************************
|
---|
470 | * Structures and Typedefs *
|
---|
471 | *******************************************************************************/
|
---|
472 | /** The F00 parameter length (in dwords). */
|
---|
473 | #define CODECNODE_F00_PARAM_LENGTH 20
|
---|
474 | /** The F02 parameter length (in dwords). */
|
---|
475 | #define CODECNODE_F02_PARAM_LENGTH 16
|
---|
476 |
|
---|
477 | /**
|
---|
478 | * Common (or core) codec node structure.
|
---|
479 | */
|
---|
480 | typedef struct CODECCOMMONNODE
|
---|
481 | {
|
---|
482 | /** Node id - 7 bit format */
|
---|
483 | uint8_t id;
|
---|
484 | /** The node name. */
|
---|
485 | char const *pszName;
|
---|
486 | /* PRM 5.3.6 */
|
---|
487 | uint32_t au32F00_param[CODECNODE_F00_PARAM_LENGTH];
|
---|
488 | uint32_t au32F02_param[CODECNODE_F02_PARAM_LENGTH];
|
---|
489 | } CODECCOMMONNODE;
|
---|
490 | typedef CODECCOMMONNODE *PCODECCOMMONNODE;
|
---|
491 | AssertCompile(CODECNODE_F00_PARAM_LENGTH == 20); /* saved state */
|
---|
492 | AssertCompile(CODECNODE_F02_PARAM_LENGTH == 16); /* saved state */
|
---|
493 |
|
---|
494 | /**
|
---|
495 | * Compile time assertion on the expected node size.
|
---|
496 | */
|
---|
497 | #define AssertNodeSize(a_Node, a_cParams) \
|
---|
498 | AssertCompile((a_cParams) <= (60 + 6)); /* the max size - saved state */ \
|
---|
499 | AssertCompile( sizeof(a_Node) - sizeof(CODECCOMMONNODE) \
|
---|
500 | == (((a_cParams) * sizeof(uint32_t) + sizeof(void *) - 1) & ~(sizeof(void *) - 1)) )
|
---|
501 |
|
---|
502 | typedef struct ROOTCODECNODE
|
---|
503 | {
|
---|
504 | CODECCOMMONNODE node;
|
---|
505 | } ROOTCODECNODE, *PROOTCODECNODE;
|
---|
506 | AssertNodeSize(ROOTCODECNODE, 0);
|
---|
507 |
|
---|
508 | #define AMPLIFIER_SIZE 60
|
---|
509 | typedef uint32_t AMPLIFIER[AMPLIFIER_SIZE];
|
---|
510 | #define AMPLIFIER_IN 0
|
---|
511 | #define AMPLIFIER_OUT 1
|
---|
512 | #define AMPLIFIER_LEFT 1
|
---|
513 | #define AMPLIFIER_RIGHT 0
|
---|
514 | #define AMPLIFIER_REGISTER(amp, inout, side, index) ((amp)[30*(inout) + 15*(side) + (index)])
|
---|
515 | typedef struct DACNODE
|
---|
516 | {
|
---|
517 | CODECCOMMONNODE node;
|
---|
518 | uint32_t u32F0d_param;
|
---|
519 | uint32_t u32F04_param;
|
---|
520 | uint32_t u32F05_param;
|
---|
521 | uint32_t u32F06_param;
|
---|
522 | uint32_t u32F0c_param;
|
---|
523 |
|
---|
524 | uint32_t u32A_param;
|
---|
525 | AMPLIFIER B_params;
|
---|
526 |
|
---|
527 | } DACNODE, *PDACNODE;
|
---|
528 | AssertNodeSize(DACNODE, 6 + 60);
|
---|
529 |
|
---|
530 | typedef struct ADCNODE
|
---|
531 | {
|
---|
532 | CODECCOMMONNODE node;
|
---|
533 | uint32_t u32F03_param;
|
---|
534 | uint32_t u32F05_param;
|
---|
535 | uint32_t u32F06_param;
|
---|
536 | uint32_t u32F09_param;
|
---|
537 |
|
---|
538 | uint32_t u32A_param;
|
---|
539 | uint32_t u32F01_param;
|
---|
540 | AMPLIFIER B_params;
|
---|
541 | } ADCNODE, *PADCNODE;
|
---|
542 | AssertNodeSize(DACNODE, 6 + 60);
|
---|
543 |
|
---|
544 | typedef struct SPDIFOUTNODE
|
---|
545 | {
|
---|
546 | CODECCOMMONNODE node;
|
---|
547 | uint32_t u32F05_param;
|
---|
548 | uint32_t u32F06_param;
|
---|
549 | uint32_t u32F09_param;
|
---|
550 | uint32_t u32F0d_param;
|
---|
551 |
|
---|
552 | uint32_t u32A_param;
|
---|
553 | AMPLIFIER B_params;
|
---|
554 | } SPDIFOUTNODE, *PSPDIFOUTNODE;
|
---|
555 | AssertNodeSize(SPDIFOUTNODE, 5 + 60);
|
---|
556 |
|
---|
557 | typedef struct SPDIFINNODE
|
---|
558 | {
|
---|
559 | CODECCOMMONNODE node;
|
---|
560 | uint32_t u32F05_param;
|
---|
561 | uint32_t u32F06_param;
|
---|
562 | uint32_t u32F09_param;
|
---|
563 | uint32_t u32F0d_param;
|
---|
564 |
|
---|
565 | uint32_t u32A_param;
|
---|
566 | AMPLIFIER B_params;
|
---|
567 | } SPDIFINNODE, *PSPDIFINNODE;
|
---|
568 | AssertNodeSize(SPDIFINNODE, 5 + 60);
|
---|
569 |
|
---|
570 | typedef struct AFGCODECNODE
|
---|
571 | {
|
---|
572 | CODECCOMMONNODE node;
|
---|
573 | uint32_t u32F05_param;
|
---|
574 | uint32_t u32F08_param;
|
---|
575 | uint32_t u32F20_param;
|
---|
576 | uint32_t u32F17_param;
|
---|
577 | } AFGCODECNODE, *PAFGCODECNODE;
|
---|
578 | AssertNodeSize(AFGCODECNODE, 4);
|
---|
579 |
|
---|
580 | typedef struct PORTNODE
|
---|
581 | {
|
---|
582 | CODECCOMMONNODE node;
|
---|
583 | uint32_t u32F07_param;
|
---|
584 | uint32_t u32F08_param;
|
---|
585 | uint32_t u32F09_param;
|
---|
586 | uint32_t u32F01_param;
|
---|
587 | uint32_t u32F1c_param;
|
---|
588 | AMPLIFIER B_params;
|
---|
589 | } PORTNODE, *PPORTNODE;
|
---|
590 | AssertNodeSize(PORTNODE, 5 + 60);
|
---|
591 |
|
---|
592 | typedef struct DIGOUTNODE
|
---|
593 | {
|
---|
594 | CODECCOMMONNODE node;
|
---|
595 | uint32_t u32F01_param;
|
---|
596 | uint32_t u32F08_param;
|
---|
597 | uint32_t u32F07_param;
|
---|
598 | uint32_t u32F09_param;
|
---|
599 | uint32_t u32F1c_param;
|
---|
600 | } DIGOUTNODE, *PDIGOUTNODE;
|
---|
601 | AssertNodeSize(DIGOUTNODE, 5);
|
---|
602 |
|
---|
603 | typedef struct DIGINNODE
|
---|
604 | {
|
---|
605 | CODECCOMMONNODE node;
|
---|
606 | uint32_t u32F05_param;
|
---|
607 | uint32_t u32F07_param;
|
---|
608 | uint32_t u32F08_param;
|
---|
609 | uint32_t u32F09_param;
|
---|
610 | uint32_t u32F0c_param;
|
---|
611 | uint32_t u32F1c_param;
|
---|
612 | uint32_t u32F1e_param;
|
---|
613 | } DIGINNODE, *PDIGINNODE;
|
---|
614 | AssertNodeSize(DIGINNODE, 7);
|
---|
615 |
|
---|
616 | typedef struct ADCMUXNODE
|
---|
617 | {
|
---|
618 | CODECCOMMONNODE node;
|
---|
619 | uint32_t u32F01_param;
|
---|
620 |
|
---|
621 | uint32_t u32A_param;
|
---|
622 | AMPLIFIER B_params;
|
---|
623 | } ADCMUXNODE, *PADCMUXNODE;
|
---|
624 | AssertNodeSize(ADCMUXNODE, 2 + 60);
|
---|
625 |
|
---|
626 | typedef struct PCBEEPNODE
|
---|
627 | {
|
---|
628 | CODECCOMMONNODE node;
|
---|
629 | uint32_t u32F07_param;
|
---|
630 | uint32_t u32F0a_param;
|
---|
631 |
|
---|
632 | uint32_t u32A_param;
|
---|
633 | AMPLIFIER B_params;
|
---|
634 | uint32_t u32F1c_param;
|
---|
635 | } PCBEEPNODE, *PPCBEEPNODE;
|
---|
636 | AssertNodeSize(PCBEEPNODE, 3 + 60 + 1);
|
---|
637 |
|
---|
638 | typedef struct CDNODE
|
---|
639 | {
|
---|
640 | CODECCOMMONNODE node;
|
---|
641 | uint32_t u32F07_param;
|
---|
642 | uint32_t u32F1c_param;
|
---|
643 | } CDNODE, *PCDNODE;
|
---|
644 | AssertNodeSize(CDNODE, 2);
|
---|
645 |
|
---|
646 | typedef struct VOLUMEKNOBNODE
|
---|
647 | {
|
---|
648 | CODECCOMMONNODE node;
|
---|
649 | uint32_t u32F08_param;
|
---|
650 | uint32_t u32F0f_param;
|
---|
651 | } VOLUMEKNOBNODE, *PVOLUMEKNOBNODE;
|
---|
652 | AssertNodeSize(VOLUMEKNOBNODE, 2);
|
---|
653 |
|
---|
654 | typedef struct ADCVOLNODE
|
---|
655 | {
|
---|
656 | CODECCOMMONNODE node;
|
---|
657 | uint32_t u32F0c_param;
|
---|
658 | uint32_t u32F01_param;
|
---|
659 | uint32_t u32A_params;
|
---|
660 | AMPLIFIER B_params;
|
---|
661 | } ADCVOLNODE, *PADCVOLNODE;
|
---|
662 | AssertNodeSize(ADCVOLNODE, 3 + 60);
|
---|
663 |
|
---|
664 | typedef struct RESNODE
|
---|
665 | {
|
---|
666 | CODECCOMMONNODE node;
|
---|
667 | uint32_t u32F05_param;
|
---|
668 | uint32_t u32F06_param;
|
---|
669 | uint32_t u32F07_param;
|
---|
670 | uint32_t u32F1c_param;
|
---|
671 | } RESNODE, *PRESNODE;
|
---|
672 | AssertNodeSize(RESNODE, 4);
|
---|
673 |
|
---|
674 | /**
|
---|
675 | * Used for the saved state.
|
---|
676 | */
|
---|
677 | typedef struct CODECSAVEDSTATENODE
|
---|
678 | {
|
---|
679 | CODECCOMMONNODE Core;
|
---|
680 | uint32_t au32Params[60 + 6];
|
---|
681 | } CODECSAVEDSTATENODE;
|
---|
682 | AssertNodeSize(CODECSAVEDSTATENODE, 60 + 6);
|
---|
683 |
|
---|
684 | typedef union CODECNODE
|
---|
685 | {
|
---|
686 | CODECCOMMONNODE node;
|
---|
687 | ROOTCODECNODE root;
|
---|
688 | AFGCODECNODE afg;
|
---|
689 | DACNODE dac;
|
---|
690 | ADCNODE adc;
|
---|
691 | SPDIFOUTNODE spdifout;
|
---|
692 | SPDIFINNODE spdifin;
|
---|
693 | PORTNODE port;
|
---|
694 | DIGOUTNODE digout;
|
---|
695 | DIGINNODE digin;
|
---|
696 | ADCMUXNODE adcmux;
|
---|
697 | PCBEEPNODE pcbeep;
|
---|
698 | CDNODE cdnode;
|
---|
699 | VOLUMEKNOBNODE volumeKnob;
|
---|
700 | ADCVOLNODE adcvol;
|
---|
701 | RESNODE reserved;
|
---|
702 | CODECSAVEDSTATENODE SavedState;
|
---|
703 | } CODECNODE, *PCODECNODE;
|
---|
704 | AssertNodeSize(CODECNODE, 60 + 6);
|
---|
705 | /*******************************************************************************
|
---|
706 | * Global Variables *
|
---|
707 | *******************************************************************************/
|
---|
708 | /* STAC9220 - Referenced thru STAC9220WIDGET in the constructor below. */
|
---|
709 | static uint8_t const g_abStac9220Ports[] = { 0x0A, 0xB, 0xC, 0xD, 0xE, 0xF, 0};
|
---|
710 | static uint8_t const g_abStac9220Dacs[] = { 0x02, 0x3, 0x4, 0x5, 0};
|
---|
711 | static uint8_t const g_abStac9220Adcs[] = { 0x06, 0x7, 0};
|
---|
712 | static uint8_t const g_abStac9220SpdifOuts[] = { 0x08, 0 };
|
---|
713 | static uint8_t const g_abStac9220SpdifIns[] = { 0x09, 0 };
|
---|
714 | static uint8_t const g_abStac9220DigOutPins[] = { 0x10, 0 };
|
---|
715 | static uint8_t const g_abStac9220DigInPins[] = { 0x11, 0 };
|
---|
716 | static uint8_t const g_abStac9220AdcVols[] = { 0x17, 0x18, 0};
|
---|
717 | static uint8_t const g_abStac9220AdcMuxs[] = { 0x12, 0x13, 0};
|
---|
718 | static uint8_t const g_abStac9220Pcbeeps[] = { 0x14, 0 };
|
---|
719 | static uint8_t const g_abStac9220Cds[] = { 0x15, 0 };
|
---|
720 | static uint8_t const g_abStac9220VolKnobs[] = { 0x16, 0 };
|
---|
721 | static uint8_t const g_abStac9220Reserveds[] = { 0x09, 0x19, 0x1a, 0x1b, 0 };
|
---|
722 |
|
---|
723 |
|
---|
724 | /** SSM description of a CODECNODE. */
|
---|
725 | static SSMFIELD const g_aCodecNodeFields[] =
|
---|
726 | {
|
---|
727 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.id),
|
---|
728 | SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3),
|
---|
729 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F00_param),
|
---|
730 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F02_param),
|
---|
731 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, au32Params),
|
---|
732 | SSMFIELD_ENTRY_TERM()
|
---|
733 | };
|
---|
734 |
|
---|
735 | /** Backward compatibility with v1 of the CODECNODE. */
|
---|
736 | static SSMFIELD const g_aCodecNodeFieldsV1[] =
|
---|
737 | {
|
---|
738 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.id),
|
---|
739 | SSMFIELD_ENTRY_PAD_HC_AUTO(3, 7),
|
---|
740 | SSMFIELD_ENTRY_OLD_HCPTR(Core.name),
|
---|
741 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F00_param),
|
---|
742 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F02_param),
|
---|
743 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, au32Params),
|
---|
744 | SSMFIELD_ENTRY_TERM()
|
---|
745 | };
|
---|
746 |
|
---|
747 |
|
---|
748 |
|
---|
749 |
|
---|
750 | static int stac9220ResetNode(PHDACODEC pThis, uint8_t nodenum, PCODECNODE pNode)
|
---|
751 | {
|
---|
752 | pNode->node.id = nodenum;
|
---|
753 | pNode->node.au32F00_param[0xF] = 0; /* Power statest Supported: are the same as AFG reports */
|
---|
754 | switch (nodenum)
|
---|
755 | {
|
---|
756 | /* Root Node*/
|
---|
757 | case 0:
|
---|
758 | pNode->node.au32F00_param[0x02] = CODEC_MAKE_F00_02(0x1, 0x0, 0x34, 0x1); /* rev id */
|
---|
759 | break;
|
---|
760 | case 1:
|
---|
761 | pNode->node.au32F00_param[0x08] = CODEC_MAKE_F00_08(1, 0xd, 0xd);
|
---|
762 | pNode->node.au32F00_param[0x0C] = CODEC_MAKE_F00_0C(0x17)
|
---|
763 | | CODEC_F00_0C_CAP_BALANCED_IO
|
---|
764 | | CODEC_F00_0C_CAP_INPUT
|
---|
765 | | CODEC_F00_0C_CAP_PRESENSE_DETECT
|
---|
766 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED
|
---|
767 | | CODEC_F00_0C_CAP_IMPENDANCE_SENSE;//(17 << 8)|RT_BIT(6)|RT_BIT(5)|RT_BIT(2)|RT_BIT(1)|RT_BIT(0);
|
---|
768 | pNode->node.au32F00_param[0x0B] = CODEC_F00_0B_PCM;
|
---|
769 | pNode->node.au32F00_param[0x0D] = CODEC_MAKE_F00_0D(1, 0x5, 0xE, 0);//RT_BIT(31)|(0x5 << 16)|(0xE)<<8;
|
---|
770 | pNode->node.au32F00_param[0x12] = RT_BIT(31)|(0x2 << 16)|(0x7f << 8)|0x7f;
|
---|
771 | pNode->node.au32F00_param[0x11] = CODEC_MAKE_F00_11(1, 1, 0, 0, 4);//0xc0000004;
|
---|
772 | pNode->node.au32F00_param[0x0F] = CODEC_F00_0F_D3|CODEC_F00_0F_D2|CODEC_F00_0F_D1|CODEC_F00_0F_D0;
|
---|
773 | pNode->afg.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D2, CODEC_F05_D2);//0x2 << 4| 0x2; /* PS-Act: D3, PS->Set D3 */
|
---|
774 | pNode->afg.u32F08_param = 0;
|
---|
775 | pNode->afg.u32F17_param = 0;
|
---|
776 | break;
|
---|
777 | case 2:
|
---|
778 | case 3:
|
---|
779 | case 4:
|
---|
780 | case 5:
|
---|
781 | memset(pNode->dac.B_params, 0, AMPLIFIER_SIZE);
|
---|
782 | pNode->dac.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//RT_BIT(14)|(0x1 << 4)|0x1; /* 441000Hz/16bit/2ch */
|
---|
783 |
|
---|
784 | AMPLIFIER_REGISTER(pNode->dac.B_params, AMPLIFIER_OUT, AMPLIFIER_LEFT, 0) = 0x7F | RT_BIT(7);
|
---|
785 | AMPLIFIER_REGISTER(pNode->dac.B_params, AMPLIFIER_OUT, AMPLIFIER_RIGHT, 0) = 0x7F | RT_BIT(7);
|
---|
786 |
|
---|
787 | pNode->dac.node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_OUTPUT, 0xD, 0)
|
---|
788 | | CODEC_F00_09_CAP_L_R_SWAP
|
---|
789 | | CODEC_F00_09_CAP_POWER_CTRL
|
---|
790 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT
|
---|
791 | | CODEC_F00_09_CAP_LSB;//(0xD << 16) | RT_BIT(11) | RT_BIT(10) | RT_BIT(2) | RT_BIT(0);
|
---|
792 | pNode->dac.u32F0c_param = 0;
|
---|
793 | pNode->dac.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D3, CODEC_F05_D3);//0x3 << 4 | 0x3; /* PS-Act: D3, Set: D3 */
|
---|
794 | break;
|
---|
795 | case 6:
|
---|
796 | pNode->node.au32F02_param[0] = 0x17;
|
---|
797 | goto adc_init;
|
---|
798 | case 7:
|
---|
799 | pNode->node.au32F02_param[0] = 0x18;
|
---|
800 | adc_init:
|
---|
801 | pNode->adc.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//RT_BIT(14)|(0x1 << 3)|0x1; /* 441000Hz/16bit/2ch */
|
---|
802 | pNode->adc.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(0, 1);//RT_BIT(0);
|
---|
803 | pNode->adc.u32F03_param = RT_BIT(0);
|
---|
804 | pNode->adc.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D3, CODEC_F05_D3);//0x3 << 4 | 0x3; /* PS-Act: D3 Set: D3 */
|
---|
805 | pNode->adc.u32F06_param = 0;
|
---|
806 | pNode->adc.node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_INPUT, 0xD, 0)
|
---|
807 | | CODEC_F00_09_CAP_POWER_CTRL
|
---|
808 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
809 | | CODEC_F00_09_CAP_PROC_WIDGET
|
---|
810 | | CODEC_F00_09_CAP_LSB;//RT_BIT(20)| (0xd << 16) | RT_BIT(10) | RT_BIT(8) | RT_BIT(6)| RT_BIT(0);
|
---|
811 | break;
|
---|
812 | case 8:
|
---|
813 | pNode->spdifout.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(1<<14)|(0x1<<4) | 0x1;
|
---|
814 | pNode->spdifout.node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_OUTPUT, 0x4, 0)
|
---|
815 | | CODEC_F00_09_CAP_DIGITAL
|
---|
816 | | CODEC_F00_09_CAP_FMT_OVERRIDE
|
---|
817 | | CODEC_F00_09_CAP_LSB;//(4 << 16) | RT_BIT(9)|RT_BIT(4)|0x1;
|
---|
818 | pNode->node.au32F00_param[0xa] = pThis->paNodes[1].node.au32F00_param[0xA];
|
---|
819 | pNode->spdifout.node.au32F00_param[0xB] = CODEC_F00_0B_PCM;
|
---|
820 | pNode->spdifout.u32F06_param = 0;
|
---|
821 | pNode->spdifout.u32F0d_param = 0;
|
---|
822 | break;
|
---|
823 | case 9:
|
---|
824 | pNode->spdifin.u32A_param = CODEC_MAKE_A(0, 1, CODEC_A_MULT_1X, CODEC_A_DIV_1X, CODEC_A_16_BIT, 1);//(0x1<<4) | 0x1;
|
---|
825 | pNode->spdifin.node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_INPUT, 0x4, 0)
|
---|
826 | | CODEC_F00_09_CAP_DIGITAL
|
---|
827 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
828 | | CODEC_F00_09_CAP_FMT_OVERRIDE
|
---|
829 | | CODEC_F00_09_CAP_LSB;//(0x1 << 20)|(4 << 16) | RT_BIT(9)| RT_BIT(8)|RT_BIT(4)|0x1;
|
---|
830 | pNode->node.au32F00_param[0xA] = pThis->paNodes[1].node.au32F00_param[0xA];
|
---|
831 | pNode->node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(0, 1);//RT_BIT(0);
|
---|
832 | pNode->node.au32F02_param[0] = 0x11;
|
---|
833 | pNode->spdifin.node.au32F00_param[0xB] = CODEC_F00_0B_PCM;
|
---|
834 | pNode->spdifin.u32F06_param = 0;
|
---|
835 | pNode->spdifin.u32F0d_param = 0;
|
---|
836 | break;
|
---|
837 | case 0xA:
|
---|
838 | pNode->node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
839 | | CODEC_F00_0C_CAP_INPUT
|
---|
840 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
841 | | CODEC_F00_0C_CAP_HP
|
---|
842 | | CODEC_F00_0C_CAP_PRESENSE_DETECT
|
---|
843 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED
|
---|
844 | | CODEC_F00_0C_CAP_IMPENDANCE_SENSE;//0x173f;
|
---|
845 | pNode->node.au32F02_param[0] = 0x2;
|
---|
846 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE
|
---|
847 | | CODEC_F07_OUT_ENABLE;
|
---|
848 | pNode->port.u32F08_param = 0;
|
---|
849 | if (!pThis->fInReset)
|
---|
850 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
851 | CODEC_F1C_LOCATION_FRONT,
|
---|
852 | CODEC_F1C_DEVICE_HP,
|
---|
853 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
854 | CODEC_F1C_COLOR_GREEN,
|
---|
855 | CODEC_F1C_MISC_JACK_DETECT,
|
---|
856 | 0x2, 0);//RT_MAKE_U32_FROM_U8(0x20, 0x40, 0x21, 0x02);
|
---|
857 | goto port_init;
|
---|
858 | case 0xB:
|
---|
859 | pNode->node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
860 | | CODEC_F00_0C_CAP_INPUT
|
---|
861 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
862 | | CODEC_F00_0C_CAP_PRESENSE_DETECT
|
---|
863 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED
|
---|
864 | | CODEC_F00_0C_CAP_IMPENDANCE_SENSE;//0x1737;
|
---|
865 | pNode->node.au32F02_param[0] = 0x4;
|
---|
866 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE;
|
---|
867 | if (!pThis->fInReset)
|
---|
868 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
869 | CODEC_F1C_LOCATION_INTERNAL|CODEC_F1C_LOCATION_REAR,
|
---|
870 | CODEC_F1C_DEVICE_SPEAKER,
|
---|
871 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
872 | CODEC_F1C_COLOR_BLACK,
|
---|
873 | CODEC_F1C_MISC_JACK_DETECT,
|
---|
874 | 0x1, 0x1);//RT_MAKE_U32_FROM_U8(0x11, 0x60, 0x11, 0x01);
|
---|
875 | goto port_init;
|
---|
876 | case 0xC:
|
---|
877 | pNode->node.au32F02_param[0] = 0x3;
|
---|
878 | pNode->node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
879 | | CODEC_F00_0C_CAP_INPUT
|
---|
880 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
881 | | CODEC_F00_0C_CAP_PRESENSE_DETECT
|
---|
882 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED
|
---|
883 | | CODEC_F00_0C_CAP_IMPENDANCE_SENSE;//0x1737;
|
---|
884 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE;
|
---|
885 | if (!pThis->fInReset)
|
---|
886 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
887 | CODEC_F1C_LOCATION_REAR,
|
---|
888 | CODEC_F1C_DEVICE_SPEAKER,
|
---|
889 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
890 | CODEC_F1C_COLOR_GREEN,
|
---|
891 | 0x0, 0x1, 0x0);//RT_MAKE_U32_FROM_U8(0x10, 0x40, 0x11, 0x01);
|
---|
892 | goto port_init;
|
---|
893 | case 0xD:
|
---|
894 | pNode->node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
895 | | CODEC_F00_0C_CAP_INPUT
|
---|
896 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
897 | | CODEC_F00_0C_CAP_PRESENSE_DETECT
|
---|
898 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED
|
---|
899 | | CODEC_F00_0C_CAP_IMPENDANCE_SENSE;//0x1737;
|
---|
900 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE;
|
---|
901 | pNode->node.au32F02_param[0] = 0x2;
|
---|
902 | if (!pThis->fInReset)
|
---|
903 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
904 | CODEC_F1C_LOCATION_FRONT,
|
---|
905 | CODEC_F1C_DEVICE_MIC,
|
---|
906 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
907 | CODEC_F1C_COLOR_PINK,
|
---|
908 | 0x0, 0x5, 0x0);//RT_MAKE_U32_FROM_U8(0x50, 0x90, 0xA1, 0x02); /* Microphone */
|
---|
909 | port_init:
|
---|
910 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(1, CODEC_F09_ANALOG_NA);//RT_BIT(31)|0x7fffffff;
|
---|
911 | pNode->port.u32F08_param = 0;
|
---|
912 | pNode->node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0x0, 0)
|
---|
913 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
914 | | CODEC_F00_09_CAP_UNSOL
|
---|
915 | | CODEC_F00_09_CAP_LSB;//(4 << 20)|RT_BIT(8)|RT_BIT(7)|RT_BIT(0);
|
---|
916 | pNode->node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(0, 1);//0x1;
|
---|
917 | break;
|
---|
918 | case 0xE:
|
---|
919 | pNode->node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0x0, 0)
|
---|
920 | | CODEC_F00_09_CAP_UNSOL
|
---|
921 | | CODEC_F00_09_CAP_LSB;//(4 << 20)|RT_BIT(7)|RT_BIT(0);
|
---|
922 | pNode->port.u32F08_param = 0;
|
---|
923 | pNode->node.au32F00_param[0xC] = CODEC_F00_0C_CAP_INPUT
|
---|
924 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
925 | | CODEC_F00_0C_CAP_PRESENSE_DETECT;//0x34;
|
---|
926 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE;
|
---|
927 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(0, CODEC_F09_ANALOG_NA);//0x7fffffff;
|
---|
928 | if (!pThis->fInReset)
|
---|
929 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
930 | CODEC_F1C_LOCATION_REAR,
|
---|
931 | CODEC_F1C_DEVICE_LINE_OUT,
|
---|
932 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
933 | CODEC_F1C_COLOR_BLUE,
|
---|
934 | 0x0, 0x4, 0x0);//0x01013040; /* Line Out */
|
---|
935 | break;
|
---|
936 | case 0xF:
|
---|
937 | pNode->node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0x0, 0x0)
|
---|
938 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
939 | | CODEC_F00_09_CAP_UNSOL
|
---|
940 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT
|
---|
941 | | CODEC_F00_09_CAP_LSB;//(4 << 20)|RT_BIT(8)|RT_BIT(7)|RT_BIT(2)|RT_BIT(0);
|
---|
942 | pNode->node.au32F00_param[0xC] = CODEC_F00_0C_CAP_INPUT
|
---|
943 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
944 | | CODEC_F00_0C_CAP_PRESENSE_DETECT
|
---|
945 | /* | CODEC_F00_0C_CAP_TRIGGER_REQUIRED
|
---|
946 | | CODEC_F00_0C_CAP_IMPENDANCE_SENSE */;//0x37;
|
---|
947 | pNode->node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(0, 1);//0x1;
|
---|
948 | pNode->port.u32F08_param = 0;
|
---|
949 | pNode->port.u32F07_param = CODEC_F07_OUT_ENABLE
|
---|
950 | | CODEC_F07_IN_ENABLE;
|
---|
951 | if (!pThis->fInReset)
|
---|
952 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
953 | CODEC_F1C_LOCATION_INTERNAL,
|
---|
954 | CODEC_F1C_DEVICE_SPEAKER,
|
---|
955 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
956 | CODEC_F1C_COLOR_ORANGE,
|
---|
957 | 0x0, 0x1, 0x2);//RT_MAKE_U32_FROM_U8(0x12, 0x60, 0x11, 0x01);
|
---|
958 | pNode->node.au32F02_param[0] = 0x5;
|
---|
959 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(0, CODEC_F09_ANALOG_NA);//0x7fffffff;
|
---|
960 | break;
|
---|
961 | case 0x10:
|
---|
962 | pNode->node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0x0, 0x0)
|
---|
963 | | CODEC_F00_09_CAP_DIGITAL
|
---|
964 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
965 | | CODEC_F00_09_CAP_LSB;//(4<<20)|RT_BIT(9)|RT_BIT(8)|RT_BIT(0);
|
---|
966 | pNode->node.au32F00_param[0xC] = CODEC_F00_0C_CAP_OUTPUT;//RT_BIT(4);
|
---|
967 | pNode->node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(0, 0x3);
|
---|
968 | pNode->node.au32F02_param[0] = RT_MAKE_U32_FROM_U8(0x08, 0x17, 0x19, 0);
|
---|
969 | if (!pThis->fInReset)
|
---|
970 | pNode->digout.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
971 | CODEC_F1C_LOCATION_REAR,
|
---|
972 | CODEC_F1C_DEVICE_SPDIF_OUT,
|
---|
973 | CODEC_F1C_CONNECTION_TYPE_DIN,
|
---|
974 | CODEC_F1C_COLOR_BLACK,
|
---|
975 | 0x0, 0x3, 0x0);//RT_MAKE_U32_FROM_U8(0x30, 0x10, 0x45, 0x01);
|
---|
976 | break;
|
---|
977 | case 0x11:
|
---|
978 | pNode->node.au32F00_param[9] = (4 << 20) | (3 << 16) | RT_BIT(10) | RT_BIT(9) | RT_BIT(7) | RT_BIT(0);
|
---|
979 | pNode->node.au32F00_param[0xC] = CODEC_F00_0C_CAP_EAPD
|
---|
980 | | CODEC_F00_0C_CAP_INPUT
|
---|
981 | | CODEC_F00_0C_CAP_PRESENSE_DETECT;//RT_BIT(16)| RT_BIT(5)|RT_BIT(2);
|
---|
982 | pNode->digin.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D3, CODEC_F05_D3);//0x3 << 4 | 0x3; /* PS-Act: D3 -> D3 */
|
---|
983 | pNode->digin.u32F07_param = 0;
|
---|
984 | pNode->digin.u32F08_param = 0;
|
---|
985 | pNode->digin.u32F09_param = 0;
|
---|
986 | pNode->digin.u32F0c_param = 0;
|
---|
987 | if (!pThis->fInReset)
|
---|
988 | pNode->digin.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
989 | CODEC_F1C_LOCATION_REAR,
|
---|
990 | CODEC_F1C_DEVICE_SPDIF_IN,
|
---|
991 | CODEC_F1C_CONNECTION_TYPE_OTHER_DIGITAL,
|
---|
992 | CODEC_F1C_COLOR_BLACK,
|
---|
993 | 0x0, 0x6, 0x0);//(0x1 << 24) | (0xc5 << 16) | (0x10 << 8) | 0x60;
|
---|
994 | break;
|
---|
995 | case 0x12:
|
---|
996 | pNode->adcmux.u32F01_param = 0;
|
---|
997 | goto adcmux_init;
|
---|
998 | case 0x13:
|
---|
999 | pNode->adcmux.u32F01_param = 1;
|
---|
1000 | adcmux_init:
|
---|
1001 | pNode->node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_SELECTOR, 0x0, 0)
|
---|
1002 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
1003 | | CODEC_F00_09_CAP_AMP_FMT_OVERRIDE
|
---|
1004 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT
|
---|
1005 | | CODEC_F00_09_CAP_LSB;//(3<<20)|RT_BIT(8)|RT_BIT(3)|RT_BIT(2)|RT_BIT(0);
|
---|
1006 | pNode->node.au32F00_param[0xe] = CODEC_MAKE_F00_0E(0, 0x7);
|
---|
1007 | pNode->node.au32F00_param[0x12] = (0x27 << 16)|(0x4 << 8);
|
---|
1008 | /* STAC 9220 v10 6.21-22.{4,5} both(left and right) out amplefiers inited with 0*/
|
---|
1009 | memset(pNode->adcmux.B_params, 0, AMPLIFIER_SIZE);
|
---|
1010 | pNode->node.au32F02_param[0] = RT_MAKE_U32_FROM_U8(0xe, 0x15, 0xf, 0xb);
|
---|
1011 | pNode->node.au32F02_param[4] = RT_MAKE_U32_FROM_U8(0xc, 0xd, 0xa, 0x0);
|
---|
1012 | break;
|
---|
1013 | case 0x14:
|
---|
1014 | pNode->node.au32F00_param[9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_BEEP_GEN, 0, 0)
|
---|
1015 | | CODEC_F00_09_CAP_AMP_FMT_OVERRIDE
|
---|
1016 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT;//(7 << 20) | RT_BIT(3) | RT_BIT(2);
|
---|
1017 | pNode->node.au32F00_param[0x12] = (0x17 << 16)|(0x3 << 8)| 0x3;
|
---|
1018 | pNode->pcbeep.u32F0a_param = 0;
|
---|
1019 | memset(pNode->pcbeep.B_params, 0, AMPLIFIER_SIZE);
|
---|
1020 | break;
|
---|
1021 | case 0x15:
|
---|
1022 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
1023 | | CODEC_F00_09_CAP_LSB;//(4 << 20)|RT_BIT(0);
|
---|
1024 | pNode->node.au32F00_param[0xc] = CODEC_F00_0C_CAP_INPUT;//RT_BIT(5);
|
---|
1025 | if (!pThis->fInReset)
|
---|
1026 | pNode->cdnode.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_FIXED,
|
---|
1027 | CODEC_F1C_LOCATION_INTERNAL,
|
---|
1028 | CODEC_F1C_DEVICE_CD,
|
---|
1029 | CODEC_F1C_CONNECTION_TYPE_ATAPI,
|
---|
1030 | CODEC_F1C_COLOR_UNKNOWN,
|
---|
1031 | 0x0, 0x7, 0x0);//RT_MAKE_U32_FROM_U8(0x70, 0x0, 0x33, 0x90);
|
---|
1032 | break;
|
---|
1033 | case 0x16:
|
---|
1034 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_VOLUME_KNOB, 0x0, 0x0);//(0x6 << 20);
|
---|
1035 | pNode->node.au32F00_param[0x13] = RT_BIT(7)| 0x7F;
|
---|
1036 | pNode->node.au32F00_param[0xe] = CODEC_MAKE_F00_0E(0, 0x4);
|
---|
1037 | pNode->node.au32F02_param[0] = RT_MAKE_U32_FROM_U8(0x2, 0x3, 0x4, 0x5);
|
---|
1038 | pNode->volumeKnob.u32F08_param = 0;
|
---|
1039 | pNode->volumeKnob.u32F0f_param = 0x7f;
|
---|
1040 | break;
|
---|
1041 | case 0x17:
|
---|
1042 | pNode->node.au32F02_param[0] = 0x12;
|
---|
1043 | goto adcvol_init;
|
---|
1044 | case 0x18:
|
---|
1045 | pNode->node.au32F02_param[0] = 0x13;
|
---|
1046 | adcvol_init:
|
---|
1047 | memset(pNode->adcvol.B_params, 0, AMPLIFIER_SIZE);
|
---|
1048 |
|
---|
1049 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_SELECTOR, 0, 0)
|
---|
1050 | | CODEC_F00_09_CAP_L_R_SWAP
|
---|
1051 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
1052 | | CODEC_F00_09_CAP_IN_AMP_PRESENT
|
---|
1053 | | CODEC_F00_09_CAP_LSB;//(0x3 << 20)|RT_BIT(11)|RT_BIT(8)|RT_BIT(1)|RT_BIT(0);
|
---|
1054 | pNode->node.au32F00_param[0xe] = CODEC_MAKE_F00_0E(0, 0x1);
|
---|
1055 | AMPLIFIER_REGISTER(pNode->adcvol.B_params, AMPLIFIER_IN, AMPLIFIER_LEFT, 0) = RT_BIT(7);
|
---|
1056 | AMPLIFIER_REGISTER(pNode->adcvol.B_params, AMPLIFIER_IN, AMPLIFIER_RIGHT, 0) = RT_BIT(7);
|
---|
1057 | pNode->adcvol.u32F0c_param = 0;
|
---|
1058 | break;
|
---|
1059 | case 0x19:
|
---|
1060 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_VENDOR_DEFINED, 0x3, 0)
|
---|
1061 | | CODEC_F00_09_CAP_DIGITAL
|
---|
1062 | | CODEC_F00_09_CAP_LSB;//(0xF << 20)|(0x3 << 16)|RT_BIT(9)|RT_BIT(0);
|
---|
1063 | break;
|
---|
1064 | case 0x1A:
|
---|
1065 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_OUTPUT, 0x3, 0)
|
---|
1066 | | CODEC_F00_09_CAP_DIGITAL
|
---|
1067 | | CODEC_F00_09_CAP_LSB;//(0x3 << 16)|RT_BIT(9)|RT_BIT(0);
|
---|
1068 | break;
|
---|
1069 | case 0x1B:
|
---|
1070 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
1071 | | CODEC_F00_09_CAP_DIGITAL
|
---|
1072 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
1073 | | CODEC_F00_09_CAP_LSB;//(0x4 << 20)|RT_BIT(9)|RT_BIT(8)|RT_BIT(0);
|
---|
1074 | pNode->node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(0, 0x1);
|
---|
1075 | pNode->node.au32F00_param[0xC] = CODEC_F00_0C_CAP_OUTPUT;//0x10;
|
---|
1076 | pNode->node.au32F02_param[0] = 0x1a;
|
---|
1077 | pNode->reserved.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_NO_PHYS,
|
---|
1078 | CODEC_F1C_LOCATION_NA,
|
---|
1079 | CODEC_F1C_DEVICE_LINE_OUT,
|
---|
1080 | CODEC_F1C_CONNECTION_TYPE_UNKNOWN,
|
---|
1081 | CODEC_F1C_COLOR_UNKNOWN,
|
---|
1082 | 0x0, 0x0, 0xf);//0x4000000f;
|
---|
1083 | break;
|
---|
1084 | default:
|
---|
1085 | break;
|
---|
1086 | }
|
---|
1087 | return VINF_SUCCESS;
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 |
|
---|
1091 | static int stac9220Construct(PHDACODEC pThis)
|
---|
1092 | {
|
---|
1093 | unconst(pThis->cTotalNodes) = 0x1C;
|
---|
1094 | pThis->pfnCodecNodeReset = stac9220ResetNode;
|
---|
1095 | pThis->u16VendorId = 0x8384;
|
---|
1096 | pThis->u16DeviceId = 0x7680;
|
---|
1097 | pThis->u8BSKU = 0x76;
|
---|
1098 | pThis->u8AssemblyId = 0x80;
|
---|
1099 | pThis->paNodes = (PCODECNODE)RTMemAllocZ(sizeof(CODECNODE) * pThis->cTotalNodes);
|
---|
1100 | if (!pThis->paNodes)
|
---|
1101 | return VERR_NO_MEMORY;
|
---|
1102 | pThis->fInReset = false;
|
---|
1103 | #define STAC9220WIDGET(type) pThis->au8##type##s = g_abStac9220##type##s
|
---|
1104 | STAC9220WIDGET(Port);
|
---|
1105 | STAC9220WIDGET(Dac);
|
---|
1106 | STAC9220WIDGET(Adc);
|
---|
1107 | STAC9220WIDGET(AdcVol);
|
---|
1108 | STAC9220WIDGET(AdcMux);
|
---|
1109 | STAC9220WIDGET(Pcbeep);
|
---|
1110 | STAC9220WIDGET(SpdifIn);
|
---|
1111 | STAC9220WIDGET(SpdifOut);
|
---|
1112 | STAC9220WIDGET(DigInPin);
|
---|
1113 | STAC9220WIDGET(DigOutPin);
|
---|
1114 | STAC9220WIDGET(Cd);
|
---|
1115 | STAC9220WIDGET(VolKnob);
|
---|
1116 | STAC9220WIDGET(Reserved);
|
---|
1117 | #undef STAC9220WIDGET
|
---|
1118 | unconst(pThis->u8AdcVolsLineIn) = 0x17;
|
---|
1119 | unconst(pThis->u8DacLineOut) = 0x2;
|
---|
1120 |
|
---|
1121 | return VINF_SUCCESS;
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 |
|
---|
1125 | /*
|
---|
1126 | * Some generic predicate functions.
|
---|
1127 | */
|
---|
1128 |
|
---|
1129 | #define DECLISNODEOFTYPE(type) \
|
---|
1130 | DECLINLINE(int) hdaCodecIs##type##Node(PHDACODEC pThis, uint8_t cNode) \
|
---|
1131 | { \
|
---|
1132 | Assert(pThis->au8##type##s); \
|
---|
1133 | for (int i = 0; pThis->au8##type##s[i] != 0; ++i) \
|
---|
1134 | if (pThis->au8##type##s[i] == cNode) \
|
---|
1135 | return 1; \
|
---|
1136 | return 0; \
|
---|
1137 | }
|
---|
1138 | /* hdaCodecIsPortNode */
|
---|
1139 | DECLISNODEOFTYPE(Port)
|
---|
1140 | /* hdaCodecIsDacNode */
|
---|
1141 | DECLISNODEOFTYPE(Dac)
|
---|
1142 | /* hdaCodecIsAdcVolNode */
|
---|
1143 | DECLISNODEOFTYPE(AdcVol)
|
---|
1144 | /* hdaCodecIsAdcNode */
|
---|
1145 | DECLISNODEOFTYPE(Adc)
|
---|
1146 | /* hdaCodecIsAdcMuxNode */
|
---|
1147 | DECLISNODEOFTYPE(AdcMux)
|
---|
1148 | /* hdaCodecIsPcbeepNode */
|
---|
1149 | DECLISNODEOFTYPE(Pcbeep)
|
---|
1150 | /* hdaCodecIsSpdifOutNode */
|
---|
1151 | DECLISNODEOFTYPE(SpdifOut)
|
---|
1152 | /* hdaCodecIsSpdifInNode */
|
---|
1153 | DECLISNODEOFTYPE(SpdifIn)
|
---|
1154 | /* hdaCodecIsDigInPinNode */
|
---|
1155 | DECLISNODEOFTYPE(DigInPin)
|
---|
1156 | /* hdaCodecIsDigOutPinNode */
|
---|
1157 | DECLISNODEOFTYPE(DigOutPin)
|
---|
1158 | /* hdaCodecIsCdNode */
|
---|
1159 | DECLISNODEOFTYPE(Cd)
|
---|
1160 | /* hdaCodecIsVolKnobNode */
|
---|
1161 | DECLISNODEOFTYPE(VolKnob)
|
---|
1162 | /* hdaCodecIsReservedNode */
|
---|
1163 | DECLISNODEOFTYPE(Reserved)
|
---|
1164 |
|
---|
1165 |
|
---|
1166 | /*
|
---|
1167 | * Misc helpers.
|
---|
1168 | */
|
---|
1169 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1170 | static int hdaCodecToAudVolume(PHDACODEC pThis, AMPLIFIER *pAmp, PDMAUDIOMIXERCTL mt)
|
---|
1171 | #else
|
---|
1172 | static int hdaCodecToAudVolume(AMPLIFIER *pAmp, audmixerctl_t mt)
|
---|
1173 | #endif
|
---|
1174 | {
|
---|
1175 | uint32_t dir = AMPLIFIER_OUT;
|
---|
1176 | switch (mt)
|
---|
1177 | {
|
---|
1178 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1179 | case PDMAUDIOMIXERCTL_VOLUME:
|
---|
1180 | case PDMAUDIOMIXERCTL_PCM:
|
---|
1181 | #else
|
---|
1182 | case AUD_MIXER_VOLUME:
|
---|
1183 | case AUD_MIXER_PCM:
|
---|
1184 | #endif
|
---|
1185 | dir = AMPLIFIER_OUT;
|
---|
1186 | break;
|
---|
1187 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1188 | case PDMAUDIOMIXERCTL_LINE_IN:
|
---|
1189 | #else
|
---|
1190 | case AUD_MIXER_LINE_IN:
|
---|
1191 | #endif
|
---|
1192 | dir = AMPLIFIER_IN;
|
---|
1193 | break;
|
---|
1194 | default:
|
---|
1195 | AssertMsgFailed(("Invalid mixer control %ld\n", mt));
|
---|
1196 | break;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | int mute = AMPLIFIER_REGISTER(*pAmp, dir, AMPLIFIER_LEFT, 0) & RT_BIT(7);
|
---|
1200 | mute |= AMPLIFIER_REGISTER(*pAmp, dir, AMPLIFIER_RIGHT, 0) & RT_BIT(7);
|
---|
1201 | mute >>=7;
|
---|
1202 | mute &= 0x1;
|
---|
1203 | uint8_t lVol = AMPLIFIER_REGISTER(*pAmp, dir, AMPLIFIER_LEFT, 0) & 0x7f;
|
---|
1204 | uint8_t rVol = AMPLIFIER_REGISTER(*pAmp, dir, AMPLIFIER_RIGHT, 0) & 0x7f;
|
---|
1205 |
|
---|
1206 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1207 | /** @todo In SetVolume no passing audmixerctl_in as its not used in DrvAudio.cpp. */
|
---|
1208 | pThis->pfnSetVolume(pThis->pHDAState, RT_BOOL(mute), lVol, rVol);
|
---|
1209 | #else
|
---|
1210 | AUD_set_volume(mt, &mute, &lVol, &rVol);
|
---|
1211 | #endif
|
---|
1212 | return VINF_SUCCESS;
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | DECLINLINE(void) hdaCodecSetRegister(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset, uint32_t mask)
|
---|
1216 | {
|
---|
1217 | Assert((pu32Reg && u8Offset < 32));
|
---|
1218 | *pu32Reg &= ~(mask << u8Offset);
|
---|
1219 | *pu32Reg |= (u32Cmd & mask) << u8Offset;
|
---|
1220 | }
|
---|
1221 |
|
---|
1222 | DECLINLINE(void) hdaCodecSetRegisterU8(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset)
|
---|
1223 | {
|
---|
1224 | hdaCodecSetRegister(pu32Reg, u32Cmd, u8Offset, CODEC_VERB_8BIT_DATA);
|
---|
1225 | }
|
---|
1226 |
|
---|
1227 | DECLINLINE(void) hdaCodecSetRegisterU16(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset)
|
---|
1228 | {
|
---|
1229 | hdaCodecSetRegister(pu32Reg, u32Cmd, u8Offset, CODEC_VERB_16BIT_DATA);
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 |
|
---|
1233 | /*
|
---|
1234 | * Verb processor functions.
|
---|
1235 | */
|
---|
1236 |
|
---|
1237 | static DECLCALLBACK(int) vrbProcUnimplemented(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1238 | {
|
---|
1239 | LogFlowFunc(("cmd(raw:%x: cad:%x, d:%c, nid:%x, verb:%x)\n", cmd,
|
---|
1240 | CODEC_CAD(cmd), CODEC_DIRECT(cmd) ? 'N' : 'Y', CODEC_NID(cmd), CODEC_VERBDATA(cmd)));
|
---|
1241 | *pResp = 0;
|
---|
1242 | return VINF_SUCCESS;
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 | static DECLCALLBACK(int) vrbProcBreak(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1246 | {
|
---|
1247 | int rc;
|
---|
1248 | rc = vrbProcUnimplemented(pThis, cmd, pResp);
|
---|
1249 | *pResp |= CODEC_RESPONSE_UNSOLICITED;
|
---|
1250 | return rc;
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 | /* B-- */
|
---|
1254 | static DECLCALLBACK(int) vrbProcGetAmplifier(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1255 | {
|
---|
1256 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1257 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1258 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1259 | {
|
---|
1260 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1261 | return VINF_SUCCESS;
|
---|
1262 | }
|
---|
1263 | *pResp = 0;
|
---|
1264 | /* HDA spec 7.3.3.7 Note A */
|
---|
1265 | /** @todo: if index out of range response should be 0 */
|
---|
1266 | uint8_t u8Index = CODEC_GET_AMP_DIRECTION(cmd) == AMPLIFIER_OUT? 0 : CODEC_GET_AMP_INDEX(cmd);
|
---|
1267 |
|
---|
1268 | PCODECNODE pNode = &pThis->paNodes[CODEC_NID(cmd)];
|
---|
1269 | if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1270 | *pResp = AMPLIFIER_REGISTER(pNode->dac.B_params,
|
---|
1271 | CODEC_GET_AMP_DIRECTION(cmd),
|
---|
1272 | CODEC_GET_AMP_SIDE(cmd),
|
---|
1273 | u8Index);
|
---|
1274 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(cmd)))
|
---|
1275 | *pResp = AMPLIFIER_REGISTER(pNode->adcvol.B_params,
|
---|
1276 | CODEC_GET_AMP_DIRECTION(cmd),
|
---|
1277 | CODEC_GET_AMP_SIDE(cmd),
|
---|
1278 | u8Index);
|
---|
1279 | else if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(cmd)))
|
---|
1280 | *pResp = AMPLIFIER_REGISTER(pNode->adcmux.B_params,
|
---|
1281 | CODEC_GET_AMP_DIRECTION(cmd),
|
---|
1282 | CODEC_GET_AMP_SIDE(cmd),
|
---|
1283 | u8Index);
|
---|
1284 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(cmd)))
|
---|
1285 | *pResp = AMPLIFIER_REGISTER(pNode->pcbeep.B_params,
|
---|
1286 | CODEC_GET_AMP_DIRECTION(cmd),
|
---|
1287 | CODEC_GET_AMP_SIDE(cmd),
|
---|
1288 | u8Index);
|
---|
1289 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1290 | *pResp = AMPLIFIER_REGISTER(pNode->port.B_params,
|
---|
1291 | CODEC_GET_AMP_DIRECTION(cmd),
|
---|
1292 | CODEC_GET_AMP_SIDE(cmd),
|
---|
1293 | u8Index);
|
---|
1294 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1295 | *pResp = AMPLIFIER_REGISTER(pNode->adc.B_params,
|
---|
1296 | CODEC_GET_AMP_DIRECTION(cmd),
|
---|
1297 | CODEC_GET_AMP_SIDE(cmd),
|
---|
1298 | u8Index);
|
---|
1299 | else
|
---|
1300 | AssertMsgFailedReturn(("access to fields of %x need to be implemented\n", CODEC_NID(cmd)), VINF_SUCCESS);
|
---|
1301 | return VINF_SUCCESS;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | /* 3-- */
|
---|
1305 | static DECLCALLBACK(int) vrbProcSetAmplifier(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1306 | {
|
---|
1307 | bool fIsLeft = false;
|
---|
1308 | bool fIsRight = false;
|
---|
1309 | bool fIsOut = false;
|
---|
1310 | bool fIsIn = false;
|
---|
1311 | uint8_t u8Index = 0;
|
---|
1312 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1313 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1314 | {
|
---|
1315 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1316 | return VINF_SUCCESS;
|
---|
1317 | }
|
---|
1318 | *pResp = 0;
|
---|
1319 | PCODECNODE pNode = &pThis->paNodes[CODEC_NID(cmd)];
|
---|
1320 | AMPLIFIER *pAmplifier;
|
---|
1321 | if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1322 | pAmplifier = &pNode->dac.B_params;
|
---|
1323 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(cmd)))
|
---|
1324 | pAmplifier = &pNode->adcvol.B_params;
|
---|
1325 | else if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(cmd)))
|
---|
1326 | pAmplifier = &pNode->adcmux.B_params;
|
---|
1327 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(cmd)))
|
---|
1328 | pAmplifier = &pNode->pcbeep.B_params;
|
---|
1329 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1330 | pAmplifier = &pNode->port.B_params;
|
---|
1331 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1332 | pAmplifier = &pNode->adc.B_params;
|
---|
1333 | else
|
---|
1334 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1335 |
|
---|
1336 | fIsOut = CODEC_SET_AMP_IS_OUT_DIRECTION(cmd);
|
---|
1337 | fIsIn = CODEC_SET_AMP_IS_IN_DIRECTION(cmd);
|
---|
1338 | fIsRight = CODEC_SET_AMP_IS_RIGHT_SIDE(cmd);
|
---|
1339 | fIsLeft = CODEC_SET_AMP_IS_LEFT_SIDE(cmd);
|
---|
1340 | u8Index = CODEC_SET_AMP_INDEX(cmd);
|
---|
1341 | if ( (!fIsLeft && !fIsRight)
|
---|
1342 | || (!fIsOut && !fIsIn))
|
---|
1343 | return VINF_SUCCESS;
|
---|
1344 | if (fIsIn)
|
---|
1345 | {
|
---|
1346 | if (fIsLeft)
|
---|
1347 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_IN, AMPLIFIER_LEFT, u8Index), cmd, 0);
|
---|
1348 | if (fIsRight)
|
---|
1349 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_IN, AMPLIFIER_RIGHT, u8Index), cmd, 0);
|
---|
1350 |
|
---|
1351 | /** @todo Fix ID of u8AdcVolsLineIn! */
|
---|
1352 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1353 | hdaCodecToAudVolume(pThis, pAmplifier, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
1354 | #else
|
---|
1355 | hdaCodecToAudVolume(pAmplifier, AUD_MIXER_LINE_IN);
|
---|
1356 | #endif
|
---|
1357 | }
|
---|
1358 | if (fIsOut)
|
---|
1359 | {
|
---|
1360 | if (fIsLeft)
|
---|
1361 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_OUT, AMPLIFIER_LEFT, u8Index), cmd, 0);
|
---|
1362 | if (fIsRight)
|
---|
1363 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_OUT, AMPLIFIER_RIGHT, u8Index), cmd, 0);
|
---|
1364 |
|
---|
1365 | /** @todo Fix ID of u8DacLineOut! */
|
---|
1366 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1367 | hdaCodecToAudVolume(pThis, pAmplifier, PDMAUDIOMIXERCTL_VOLUME);
|
---|
1368 | #else
|
---|
1369 | hdaCodecToAudVolume(pAmplifier, AUD_MIXER_VOLUME);
|
---|
1370 | #endif
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | return VINF_SUCCESS;
|
---|
1374 | }
|
---|
1375 |
|
---|
1376 | static DECLCALLBACK(int) vrbProcGetParameter(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1377 | {
|
---|
1378 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1379 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1380 | {
|
---|
1381 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1382 | return VINF_SUCCESS;
|
---|
1383 | }
|
---|
1384 | Assert((cmd & CODEC_VERB_8BIT_DATA) < CODECNODE_F00_PARAM_LENGTH);
|
---|
1385 | if ((cmd & CODEC_VERB_8BIT_DATA) >= CODECNODE_F00_PARAM_LENGTH)
|
---|
1386 | {
|
---|
1387 | LogFlowFunc(("invalid F00 parameter %d\n", (cmd & CODEC_VERB_8BIT_DATA)));
|
---|
1388 | return VINF_SUCCESS;
|
---|
1389 | }
|
---|
1390 | *pResp = pThis->paNodes[CODEC_NID(cmd)].node.au32F00_param[cmd & CODEC_VERB_8BIT_DATA];
|
---|
1391 | return VINF_SUCCESS;
|
---|
1392 | }
|
---|
1393 |
|
---|
1394 | /* F01 */
|
---|
1395 | static DECLCALLBACK(int) vrbProcGetConSelectCtrl(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1396 | {
|
---|
1397 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1398 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1399 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1400 | {
|
---|
1401 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1402 | return VINF_SUCCESS;
|
---|
1403 | }
|
---|
1404 | *pResp = 0;
|
---|
1405 | if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(cmd)))
|
---|
1406 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adcmux.u32F01_param;
|
---|
1407 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
1408 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digout.u32F01_param;
|
---|
1409 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1410 | *pResp = pThis->paNodes[CODEC_NID(cmd)].port.u32F01_param;
|
---|
1411 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1412 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adc.u32F01_param;
|
---|
1413 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(cmd)))
|
---|
1414 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adcvol.u32F01_param;
|
---|
1415 | return VINF_SUCCESS;
|
---|
1416 | }
|
---|
1417 |
|
---|
1418 | /* 701 */
|
---|
1419 | static DECLCALLBACK(int) vrbProcSetConSelectCtrl(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1420 | {
|
---|
1421 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1422 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1423 | {
|
---|
1424 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1425 | return VINF_SUCCESS;
|
---|
1426 | }
|
---|
1427 | *pResp = 0;
|
---|
1428 | uint32_t *pu32Reg;
|
---|
1429 | if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(cmd)))
|
---|
1430 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].adcmux.u32F01_param;
|
---|
1431 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
1432 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digout.u32F01_param;
|
---|
1433 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1434 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].port.u32F01_param;
|
---|
1435 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1436 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].adc.u32F01_param;
|
---|
1437 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(cmd)))
|
---|
1438 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].adcvol.u32F01_param;
|
---|
1439 | else
|
---|
1440 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1441 | hdaCodecSetRegisterU8(pu32Reg, cmd, 0);
|
---|
1442 | return VINF_SUCCESS;
|
---|
1443 | }
|
---|
1444 |
|
---|
1445 | /* F07 */
|
---|
1446 | static DECLCALLBACK(int) vrbProcGetPinCtrl(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1447 | {
|
---|
1448 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1449 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1450 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1451 | {
|
---|
1452 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1453 | return VINF_SUCCESS;
|
---|
1454 | }
|
---|
1455 | *pResp = 0;
|
---|
1456 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1457 | *pResp = pThis->paNodes[CODEC_NID(cmd)].port.u32F07_param;
|
---|
1458 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
1459 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digout.u32F07_param;
|
---|
1460 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1461 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digin.u32F07_param;
|
---|
1462 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(cmd)))
|
---|
1463 | *pResp = pThis->paNodes[CODEC_NID(cmd)].cdnode.u32F07_param;
|
---|
1464 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(cmd)))
|
---|
1465 | *pResp = pThis->paNodes[CODEC_NID(cmd)].pcbeep.u32F07_param;
|
---|
1466 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
|
---|
1467 | *pResp = pThis->paNodes[CODEC_NID(cmd)].reserved.u32F07_param;
|
---|
1468 | else
|
---|
1469 | AssertMsgFailed(("Unsupported"));
|
---|
1470 | return VINF_SUCCESS;
|
---|
1471 | }
|
---|
1472 |
|
---|
1473 | /* 707 */
|
---|
1474 | static DECLCALLBACK(int) vrbProcSetPinCtrl(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1475 | {
|
---|
1476 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1477 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1478 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1479 | {
|
---|
1480 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1481 | return VINF_SUCCESS;
|
---|
1482 | }
|
---|
1483 | *pResp = 0;
|
---|
1484 | uint32_t *pu32Reg;
|
---|
1485 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1486 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].port.u32F07_param;
|
---|
1487 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1488 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digin.u32F07_param;
|
---|
1489 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
1490 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digout.u32F07_param;
|
---|
1491 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(cmd)))
|
---|
1492 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].cdnode.u32F07_param;
|
---|
1493 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(cmd)))
|
---|
1494 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].pcbeep.u32F07_param;
|
---|
1495 | else if ( hdaCodecIsReservedNode(pThis, CODEC_NID(cmd))
|
---|
1496 | && CODEC_NID(cmd) == 0x1b)
|
---|
1497 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].reserved.u32F07_param;
|
---|
1498 | else
|
---|
1499 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1500 | hdaCodecSetRegisterU8(pu32Reg, cmd, 0);
|
---|
1501 | return VINF_SUCCESS;
|
---|
1502 | }
|
---|
1503 |
|
---|
1504 | /* F08 */
|
---|
1505 | static DECLCALLBACK(int) vrbProcGetUnsolicitedEnabled(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1506 | {
|
---|
1507 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1508 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1509 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1510 | {
|
---|
1511 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1512 | return VINF_SUCCESS;
|
---|
1513 | }
|
---|
1514 | *pResp = 0;
|
---|
1515 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1516 | *pResp = pThis->paNodes[CODEC_NID(cmd)].port.u32F08_param;
|
---|
1517 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1518 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digin.u32F08_param;
|
---|
1519 | else if ((cmd) == 1 /* AFG */)
|
---|
1520 | *pResp = pThis->paNodes[CODEC_NID(cmd)].afg.u32F08_param;
|
---|
1521 | else if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(cmd)))
|
---|
1522 | *pResp = pThis->paNodes[CODEC_NID(cmd)].volumeKnob.u32F08_param;
|
---|
1523 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
1524 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digout.u32F08_param;
|
---|
1525 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1526 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digin.u32F08_param;
|
---|
1527 | else
|
---|
1528 | AssertMsgFailed(("unsupported operation %x on node: %x\n", CODEC_VERB_CMD8(cmd), CODEC_NID(cmd)));
|
---|
1529 | return VINF_SUCCESS;
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | /* 708 */
|
---|
1533 | static DECLCALLBACK(int) vrbProcSetUnsolicitedEnabled(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1534 | {
|
---|
1535 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1536 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1537 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1538 | {
|
---|
1539 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1540 | return VINF_SUCCESS;
|
---|
1541 | }
|
---|
1542 | *pResp = 0;
|
---|
1543 | uint32_t *pu32Reg;
|
---|
1544 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1545 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].port.u32F08_param;
|
---|
1546 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1547 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digin.u32F08_param;
|
---|
1548 | else if (CODEC_NID(cmd) == 1 /* AFG */)
|
---|
1549 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].afg.u32F08_param;
|
---|
1550 | else if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(cmd)))
|
---|
1551 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].volumeKnob.u32F08_param;
|
---|
1552 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1553 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digin.u32F08_param;
|
---|
1554 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
1555 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digout.u32F08_param;
|
---|
1556 | else
|
---|
1557 | AssertMsgFailedReturn(("unsupported operation %x on node: %x\n", CODEC_VERB_CMD8(cmd), CODEC_NID(cmd)), VINF_SUCCESS);
|
---|
1558 | hdaCodecSetRegisterU8(pu32Reg, cmd, 0);
|
---|
1559 | return VINF_SUCCESS;
|
---|
1560 | }
|
---|
1561 |
|
---|
1562 | /* F09 */
|
---|
1563 | static DECLCALLBACK(int) vrbProcGetPinSense(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1564 | {
|
---|
1565 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1566 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1567 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1568 | {
|
---|
1569 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1570 | return VINF_SUCCESS;
|
---|
1571 | }
|
---|
1572 | *pResp = 0;
|
---|
1573 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1574 | *pResp = pThis->paNodes[CODEC_NID(cmd)].port.u32F09_param;
|
---|
1575 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1576 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digin.u32F09_param;
|
---|
1577 | else
|
---|
1578 | AssertMsgFailed(("unsupported operation %x on node: %x\n", CODEC_VERB_CMD8(cmd), CODEC_NID(cmd)));
|
---|
1579 | return VINF_SUCCESS;
|
---|
1580 | }
|
---|
1581 |
|
---|
1582 | /* 709 */
|
---|
1583 | static DECLCALLBACK(int) vrbProcSetPinSense(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1584 | {
|
---|
1585 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1586 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1587 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1588 | {
|
---|
1589 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1590 | return VINF_SUCCESS;
|
---|
1591 | }
|
---|
1592 | *pResp = 0;
|
---|
1593 | uint32_t *pu32Reg;
|
---|
1594 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
1595 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].port.u32F09_param;
|
---|
1596 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1597 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digin.u32F09_param;
|
---|
1598 | else
|
---|
1599 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1600 | hdaCodecSetRegisterU8(pu32Reg, cmd, 0);
|
---|
1601 | return VINF_SUCCESS;
|
---|
1602 | }
|
---|
1603 |
|
---|
1604 | static DECLCALLBACK(int) vrbProcGetConnectionListEntry(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1605 | {
|
---|
1606 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1607 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1608 | *pResp = 0;
|
---|
1609 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1610 | {
|
---|
1611 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1612 | return VINF_SUCCESS;
|
---|
1613 | }
|
---|
1614 | Assert((cmd & CODEC_VERB_8BIT_DATA) < CODECNODE_F02_PARAM_LENGTH);
|
---|
1615 | if ((cmd & CODEC_VERB_8BIT_DATA) >= CODECNODE_F02_PARAM_LENGTH)
|
---|
1616 | {
|
---|
1617 | LogFlowFunc(("access to invalid F02 index %d\n", (cmd & CODEC_VERB_8BIT_DATA)));
|
---|
1618 | return VINF_SUCCESS;
|
---|
1619 | }
|
---|
1620 | *pResp = pThis->paNodes[CODEC_NID(cmd)].node.au32F02_param[cmd & CODEC_VERB_8BIT_DATA];
|
---|
1621 | return VINF_SUCCESS;
|
---|
1622 | }
|
---|
1623 |
|
---|
1624 | /* F03 */
|
---|
1625 | static DECLCALLBACK(int) vrbProcGetProcessingState(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1626 | {
|
---|
1627 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1628 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1629 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1630 | {
|
---|
1631 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1632 | return VINF_SUCCESS;
|
---|
1633 | }
|
---|
1634 | *pResp = 0;
|
---|
1635 | if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1636 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adc.u32F03_param;
|
---|
1637 | return VINF_SUCCESS;
|
---|
1638 | }
|
---|
1639 |
|
---|
1640 | /* 703 */
|
---|
1641 | static DECLCALLBACK(int) vrbProcSetProcessingState(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1642 | {
|
---|
1643 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1644 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1645 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1646 | {
|
---|
1647 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1648 | return VINF_SUCCESS;
|
---|
1649 | }
|
---|
1650 | *pResp = 0;
|
---|
1651 | if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1652 | hdaCodecSetRegisterU8(&pThis->paNodes[CODEC_NID(cmd)].adc.u32F03_param, cmd, 0);
|
---|
1653 | return VINF_SUCCESS;
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 | /* F0D */
|
---|
1657 | static DECLCALLBACK(int) vrbProcGetDigitalConverter(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1658 | {
|
---|
1659 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1660 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1661 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1662 | {
|
---|
1663 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1664 | return VINF_SUCCESS;
|
---|
1665 | }
|
---|
1666 | *pResp = 0;
|
---|
1667 | if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1668 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifout.u32F0d_param;
|
---|
1669 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1670 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifin.u32F0d_param;
|
---|
1671 | return VINF_SUCCESS;
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | static int codecSetDigitalConverter(PHDACODEC pThis, uint32_t cmd, uint8_t u8Offset, uint64_t *pResp)
|
---|
1675 | {
|
---|
1676 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1677 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1678 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1679 | {
|
---|
1680 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1681 | return VINF_SUCCESS;
|
---|
1682 | }
|
---|
1683 | *pResp = 0;
|
---|
1684 | if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1685 | hdaCodecSetRegisterU8(&pThis->paNodes[CODEC_NID(cmd)].spdifout.u32F0d_param, cmd, u8Offset);
|
---|
1686 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1687 | hdaCodecSetRegisterU8(&pThis->paNodes[CODEC_NID(cmd)].spdifin.u32F0d_param, cmd, u8Offset);
|
---|
1688 | return VINF_SUCCESS;
|
---|
1689 | }
|
---|
1690 |
|
---|
1691 | /* 70D */
|
---|
1692 | static DECLCALLBACK(int) vrbProcSetDigitalConverter1(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1693 | {
|
---|
1694 | return codecSetDigitalConverter(pThis, cmd, 0, pResp);
|
---|
1695 | }
|
---|
1696 |
|
---|
1697 | /* 70E */
|
---|
1698 | static DECLCALLBACK(int) vrbProcSetDigitalConverter2(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1699 | {
|
---|
1700 | return codecSetDigitalConverter(pThis, cmd, 8, pResp);
|
---|
1701 | }
|
---|
1702 |
|
---|
1703 | /* F20 */
|
---|
1704 | static DECLCALLBACK(int) vrbProcGetSubId(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1705 | {
|
---|
1706 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1707 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1708 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1709 | {
|
---|
1710 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1711 | return VINF_SUCCESS;
|
---|
1712 | }
|
---|
1713 | if (CODEC_NID(cmd) == 1 /* AFG */)
|
---|
1714 | *pResp = pThis->paNodes[CODEC_NID(cmd)].afg.u32F20_param;
|
---|
1715 | else
|
---|
1716 | *pResp = 0;
|
---|
1717 | return VINF_SUCCESS;
|
---|
1718 | }
|
---|
1719 |
|
---|
1720 | static int codecSetSubIdX(PHDACODEC pThis, uint32_t cmd, uint8_t u8Offset)
|
---|
1721 | {
|
---|
1722 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1723 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1724 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1725 | {
|
---|
1726 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1727 | return VINF_SUCCESS;
|
---|
1728 | }
|
---|
1729 | uint32_t *pu32Reg;
|
---|
1730 | if (CODEC_NID(cmd) == 0x1 /* AFG */)
|
---|
1731 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].afg.u32F20_param;
|
---|
1732 | else
|
---|
1733 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1734 | hdaCodecSetRegisterU8(pu32Reg, cmd, u8Offset);
|
---|
1735 | return VINF_SUCCESS;
|
---|
1736 | }
|
---|
1737 |
|
---|
1738 | /* 720 */
|
---|
1739 | static DECLCALLBACK(int) vrbProcSetSubId0(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1740 | {
|
---|
1741 | *pResp = 0;
|
---|
1742 | return codecSetSubIdX(pThis, cmd, 0);
|
---|
1743 | }
|
---|
1744 |
|
---|
1745 | /* 721 */
|
---|
1746 | static DECLCALLBACK(int) vrbProcSetSubId1(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1747 | {
|
---|
1748 | *pResp = 0;
|
---|
1749 | return codecSetSubIdX(pThis, cmd, 8);
|
---|
1750 | }
|
---|
1751 |
|
---|
1752 | /* 722 */
|
---|
1753 | static DECLCALLBACK(int) vrbProcSetSubId2(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1754 | {
|
---|
1755 | *pResp = 0;
|
---|
1756 | return codecSetSubIdX(pThis, cmd, 16);
|
---|
1757 | }
|
---|
1758 |
|
---|
1759 | /* 723 */
|
---|
1760 | static DECLCALLBACK(int) vrbProcSetSubId3(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1761 | {
|
---|
1762 | *pResp = 0;
|
---|
1763 | return codecSetSubIdX(pThis, cmd, 24);
|
---|
1764 | }
|
---|
1765 |
|
---|
1766 | static DECLCALLBACK(int) vrbProcReset(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1767 | {
|
---|
1768 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1769 | Assert(CODEC_NID(cmd) == 1 /* AFG */);
|
---|
1770 | if ( CODEC_NID(cmd) == 1 /* AFG */
|
---|
1771 | && pThis->pfnCodecNodeReset)
|
---|
1772 | {
|
---|
1773 | uint8_t i;
|
---|
1774 | LogFlowFunc(("enters reset\n"));
|
---|
1775 | Assert(pThis->pfnCodecNodeReset);
|
---|
1776 | for (i = 0; i < pThis->cTotalNodes; ++i)
|
---|
1777 | {
|
---|
1778 | pThis->pfnCodecNodeReset(pThis, i, &pThis->paNodes[i]);
|
---|
1779 | }
|
---|
1780 | pThis->fInReset = false;
|
---|
1781 | LogFlowFunc(("exits reset\n"));
|
---|
1782 | }
|
---|
1783 | *pResp = 0;
|
---|
1784 | return VINF_SUCCESS;
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 | /* F05 */
|
---|
1788 | static DECLCALLBACK(int) vrbProcGetPowerState(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1789 | {
|
---|
1790 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1791 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1792 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1793 | {
|
---|
1794 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1795 | return VINF_SUCCESS;
|
---|
1796 | }
|
---|
1797 | *pResp = 0;
|
---|
1798 | if (CODEC_NID(cmd) == 1 /* AFG */)
|
---|
1799 | *pResp = pThis->paNodes[CODEC_NID(cmd)].afg.u32F05_param;
|
---|
1800 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1801 | *pResp = pThis->paNodes[CODEC_NID(cmd)].dac.u32F05_param;
|
---|
1802 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1803 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digin.u32F05_param;
|
---|
1804 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1805 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adc.u32F05_param;
|
---|
1806 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1807 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifout.u32F05_param;
|
---|
1808 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1809 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifin.u32F05_param;
|
---|
1810 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
|
---|
1811 | *pResp = pThis->paNodes[CODEC_NID(cmd)].reserved.u32F05_param;
|
---|
1812 | return VINF_SUCCESS;
|
---|
1813 | }
|
---|
1814 |
|
---|
1815 | /* 705 */
|
---|
1816 |
|
---|
1817 | DECLINLINE(void) codecPropogatePowerState(uint32_t *pu32F05_param)
|
---|
1818 | {
|
---|
1819 | Assert(pu32F05_param);
|
---|
1820 | if (!pu32F05_param)
|
---|
1821 | return;
|
---|
1822 | bool fReset = CODEC_F05_IS_RESET(*pu32F05_param);
|
---|
1823 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32F05_param);
|
---|
1824 | uint8_t u8SetPowerState = CODEC_F05_SET(*pu32F05_param);
|
---|
1825 | *pu32F05_param = CODEC_MAKE_F05(fReset, fStopOk, 0, u8SetPowerState, u8SetPowerState);
|
---|
1826 | }
|
---|
1827 |
|
---|
1828 | static DECLCALLBACK(int) vrbProcSetPowerState(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1829 | {
|
---|
1830 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1831 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1832 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1833 | {
|
---|
1834 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1835 | return VINF_SUCCESS;
|
---|
1836 | }
|
---|
1837 | *pResp = 0;
|
---|
1838 | uint32_t *pu32Reg;
|
---|
1839 | if (CODEC_NID(cmd) == 1 /* AFG */)
|
---|
1840 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].afg.u32F05_param;
|
---|
1841 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1842 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].dac.u32F05_param;
|
---|
1843 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
1844 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digin.u32F05_param;
|
---|
1845 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1846 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].adc.u32F05_param;
|
---|
1847 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1848 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].spdifout.u32F05_param;
|
---|
1849 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1850 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].spdifin.u32F05_param;
|
---|
1851 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
|
---|
1852 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].reserved.u32F05_param;
|
---|
1853 | else
|
---|
1854 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1855 |
|
---|
1856 | bool fReset = CODEC_F05_IS_RESET(*pu32Reg);
|
---|
1857 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32Reg);
|
---|
1858 |
|
---|
1859 | if (CODEC_NID(cmd) != 1 /* AFG */)
|
---|
1860 | {
|
---|
1861 | /*
|
---|
1862 | * We shouldn't propogate actual power state, which actual for AFG
|
---|
1863 | */
|
---|
1864 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0,
|
---|
1865 | CODEC_F05_ACT(pThis->paNodes[1].afg.u32F05_param),
|
---|
1866 | CODEC_F05_SET(cmd));
|
---|
1867 | }
|
---|
1868 |
|
---|
1869 | /* Propagate next power state only if AFG is on or verb modifies AFG power state */
|
---|
1870 | if ( CODEC_NID(cmd) == 1 /* AFG */
|
---|
1871 | || !CODEC_F05_ACT(pThis->paNodes[1].afg.u32F05_param))
|
---|
1872 | {
|
---|
1873 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0, CODEC_F05_SET(cmd), CODEC_F05_SET(cmd));
|
---|
1874 | if ( CODEC_NID(cmd) == 1 /* AFG */
|
---|
1875 | && (CODEC_F05_SET(cmd)) == CODEC_F05_D0)
|
---|
1876 | {
|
---|
1877 | /* now we're powered on AFG and may propogate power states on nodes */
|
---|
1878 | const uint8_t *pu8NodeIndex = &pThis->au8Dacs[0];
|
---|
1879 | while (*(++pu8NodeIndex))
|
---|
1880 | codecPropogatePowerState(&pThis->paNodes[*pu8NodeIndex].dac.u32F05_param);
|
---|
1881 |
|
---|
1882 | pu8NodeIndex = &pThis->au8Adcs[0];
|
---|
1883 | while (*(++pu8NodeIndex))
|
---|
1884 | codecPropogatePowerState(&pThis->paNodes[*pu8NodeIndex].adc.u32F05_param);
|
---|
1885 |
|
---|
1886 | pu8NodeIndex = &pThis->au8DigInPins[0];
|
---|
1887 | while (*(++pu8NodeIndex))
|
---|
1888 | codecPropogatePowerState(&pThis->paNodes[*pu8NodeIndex].digin.u32F05_param);
|
---|
1889 | }
|
---|
1890 | }
|
---|
1891 | return VINF_SUCCESS;
|
---|
1892 | }
|
---|
1893 |
|
---|
1894 | static DECLCALLBACK(int) vrbProcGetStreamId(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1895 | {
|
---|
1896 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1897 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1898 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1899 | {
|
---|
1900 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1901 | return VINF_SUCCESS;
|
---|
1902 | }
|
---|
1903 | *pResp = 0;
|
---|
1904 | if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1905 | *pResp = pThis->paNodes[CODEC_NID(cmd)].dac.u32F06_param;
|
---|
1906 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1907 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adc.u32F06_param;
|
---|
1908 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1909 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifin.u32F06_param;
|
---|
1910 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1911 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifout.u32F06_param;
|
---|
1912 | else if (CODEC_NID(cmd) == 0x1A)
|
---|
1913 | *pResp = pThis->paNodes[CODEC_NID(cmd)].reserved.u32F06_param;
|
---|
1914 | return VINF_SUCCESS;
|
---|
1915 | }
|
---|
1916 |
|
---|
1917 | static DECLCALLBACK(int) vrbProcSetStreamId(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1918 | {
|
---|
1919 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1920 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1921 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1922 | {
|
---|
1923 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1924 | return VINF_SUCCESS;
|
---|
1925 | }
|
---|
1926 | *pResp = 0;
|
---|
1927 | uint32_t *pu32addr;
|
---|
1928 | if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1929 | pu32addr = &pThis->paNodes[CODEC_NID(cmd)].dac.u32F06_param;
|
---|
1930 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1931 | pu32addr = &pThis->paNodes[CODEC_NID(cmd)].adc.u32F06_param;
|
---|
1932 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1933 | pu32addr = &pThis->paNodes[CODEC_NID(cmd)].spdifout.u32F06_param;
|
---|
1934 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1935 | pu32addr = &pThis->paNodes[CODEC_NID(cmd)].spdifin.u32F06_param;
|
---|
1936 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
|
---|
1937 | pu32addr = &pThis->paNodes[CODEC_NID(cmd)].reserved.u32F06_param;
|
---|
1938 | else
|
---|
1939 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1940 | hdaCodecSetRegisterU8(pu32addr, cmd, 0);
|
---|
1941 | return VINF_SUCCESS;
|
---|
1942 | }
|
---|
1943 |
|
---|
1944 | static DECLCALLBACK(int) vrbProcGetConverterFormat(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1945 | {
|
---|
1946 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1947 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1948 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1949 | {
|
---|
1950 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1951 | return VINF_SUCCESS;
|
---|
1952 | }
|
---|
1953 | *pResp = 0;
|
---|
1954 | if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1955 | *pResp = pThis->paNodes[CODEC_NID(cmd)].dac.u32A_param;
|
---|
1956 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1957 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adc.u32A_param;
|
---|
1958 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1959 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifout.u32A_param;
|
---|
1960 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1961 | *pResp = pThis->paNodes[CODEC_NID(cmd)].spdifin.u32A_param;
|
---|
1962 | return VINF_SUCCESS;
|
---|
1963 | }
|
---|
1964 |
|
---|
1965 | static DECLCALLBACK(int) vrbProcSetConverterFormat(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1966 | {
|
---|
1967 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1968 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1969 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1970 | {
|
---|
1971 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1972 | return VINF_SUCCESS;
|
---|
1973 | }
|
---|
1974 | *pResp = 0;
|
---|
1975 | if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
1976 | hdaCodecSetRegisterU16(&pThis->paNodes[CODEC_NID(cmd)].dac.u32A_param, cmd, 0);
|
---|
1977 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(cmd)))
|
---|
1978 | hdaCodecSetRegisterU16(&pThis->paNodes[CODEC_NID(cmd)].adc.u32A_param, cmd, 0);
|
---|
1979 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(cmd)))
|
---|
1980 | hdaCodecSetRegisterU16(&pThis->paNodes[CODEC_NID(cmd)].spdifout.u32A_param, cmd, 0);
|
---|
1981 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(cmd)))
|
---|
1982 | hdaCodecSetRegisterU16(&pThis->paNodes[CODEC_NID(cmd)].spdifin.u32A_param, cmd, 0);
|
---|
1983 | return VINF_SUCCESS;
|
---|
1984 | }
|
---|
1985 |
|
---|
1986 | /* F0C */
|
---|
1987 | static DECLCALLBACK(int) vrbProcGetEAPD_BTLEnabled(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
1988 | {
|
---|
1989 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
1990 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
1991 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
1992 | {
|
---|
1993 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
1994 | return VINF_SUCCESS;
|
---|
1995 | }
|
---|
1996 | *pResp = 0;
|
---|
1997 | if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(cmd)))
|
---|
1998 | *pResp = pThis->paNodes[CODEC_NID(cmd)].adcvol.u32F0c_param;
|
---|
1999 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
2000 | *pResp = pThis->paNodes[CODEC_NID(cmd)].dac.u32F0c_param;
|
---|
2001 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
2002 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digin.u32F0c_param;
|
---|
2003 | return VINF_SUCCESS;
|
---|
2004 | }
|
---|
2005 |
|
---|
2006 | /* 70C */
|
---|
2007 | static DECLCALLBACK(int) vrbProcSetEAPD_BTLEnabled(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2008 | {
|
---|
2009 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2010 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
2011 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2012 | {
|
---|
2013 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
2014 | return VINF_SUCCESS;
|
---|
2015 | }
|
---|
2016 |
|
---|
2017 | *pResp = 0;
|
---|
2018 | uint32_t *pu32Reg;
|
---|
2019 | if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(cmd)))
|
---|
2020 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].adcvol.u32F0c_param;
|
---|
2021 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(cmd)))
|
---|
2022 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].dac.u32F0c_param;
|
---|
2023 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
2024 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digin.u32F0c_param;
|
---|
2025 | else
|
---|
2026 | AssertFailedReturn(VINF_SUCCESS);
|
---|
2027 | hdaCodecSetRegisterU8(pu32Reg, cmd, 0);
|
---|
2028 |
|
---|
2029 | return VINF_SUCCESS;
|
---|
2030 | }
|
---|
2031 |
|
---|
2032 | /* F0F */
|
---|
2033 | static DECLCALLBACK(int) vrbProcGetVolumeKnobCtrl(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2034 | {
|
---|
2035 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2036 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
2037 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2038 | {
|
---|
2039 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
2040 | return VINF_SUCCESS;
|
---|
2041 | }
|
---|
2042 | *pResp = 0;
|
---|
2043 | if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(cmd)))
|
---|
2044 | *pResp = pThis->paNodes[CODEC_NID(cmd)].volumeKnob.u32F0f_param;
|
---|
2045 | return VINF_SUCCESS;
|
---|
2046 | }
|
---|
2047 |
|
---|
2048 | /* 70F */
|
---|
2049 | static DECLCALLBACK(int) vrbProcSetVolumeKnobCtrl(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2050 | {
|
---|
2051 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2052 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
2053 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2054 | {
|
---|
2055 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
2056 | return VINF_SUCCESS;
|
---|
2057 | }
|
---|
2058 | uint32_t *pu32Reg = NULL;
|
---|
2059 | *pResp = 0;
|
---|
2060 | if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(cmd)))
|
---|
2061 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].volumeKnob.u32F0f_param;
|
---|
2062 | Assert(pu32Reg);
|
---|
2063 | if (pu32Reg)
|
---|
2064 | hdaCodecSetRegisterU8(pu32Reg, cmd, 0);
|
---|
2065 | return VINF_SUCCESS;
|
---|
2066 | }
|
---|
2067 |
|
---|
2068 | /* F17 */
|
---|
2069 | static DECLCALLBACK(int) vrbProcGetGPIOUnsolisted(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2070 | {
|
---|
2071 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2072 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
2073 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2074 | {
|
---|
2075 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
2076 | return VINF_SUCCESS;
|
---|
2077 | }
|
---|
2078 | *pResp = 0;
|
---|
2079 | /* note: this is true for ALC885 */
|
---|
2080 | if (CODEC_NID(cmd) == 0x1 /* AFG */)
|
---|
2081 | *pResp = pThis->paNodes[1].afg.u32F17_param;
|
---|
2082 | return VINF_SUCCESS;
|
---|
2083 | }
|
---|
2084 |
|
---|
2085 | /* 717 */
|
---|
2086 | static DECLCALLBACK(int) vrbProcSetGPIOUnsolisted(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2087 | {
|
---|
2088 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2089 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
2090 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2091 | {
|
---|
2092 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
2093 | return VINF_SUCCESS;
|
---|
2094 | }
|
---|
2095 | uint32_t *pu32Reg = NULL;
|
---|
2096 | *pResp = 0;
|
---|
2097 | if (CODEC_NID(cmd) == 1 /* AFG */)
|
---|
2098 | pu32Reg = &pThis->paNodes[1].afg.u32F17_param;
|
---|
2099 | Assert(pu32Reg);
|
---|
2100 | if (pu32Reg)
|
---|
2101 | hdaCodecSetRegisterU8(pu32Reg, cmd, 0);
|
---|
2102 | return VINF_SUCCESS;
|
---|
2103 | }
|
---|
2104 |
|
---|
2105 | /* F1C */
|
---|
2106 | static DECLCALLBACK(int) vrbProcGetConfig(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2107 | {
|
---|
2108 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2109 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
2110 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2111 | {
|
---|
2112 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
2113 | return VINF_SUCCESS;
|
---|
2114 | }
|
---|
2115 | *pResp = 0;
|
---|
2116 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
2117 | *pResp = pThis->paNodes[CODEC_NID(cmd)].port.u32F1c_param;
|
---|
2118 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
2119 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digout.u32F1c_param;
|
---|
2120 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
2121 | *pResp = pThis->paNodes[CODEC_NID(cmd)].digin.u32F1c_param;
|
---|
2122 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(cmd)))
|
---|
2123 | *pResp = pThis->paNodes[CODEC_NID(cmd)].pcbeep.u32F1c_param;
|
---|
2124 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(cmd)))
|
---|
2125 | *pResp = pThis->paNodes[CODEC_NID(cmd)].cdnode.u32F1c_param;
|
---|
2126 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
|
---|
2127 | *pResp = pThis->paNodes[CODEC_NID(cmd)].reserved.u32F1c_param;
|
---|
2128 | return VINF_SUCCESS;
|
---|
2129 | }
|
---|
2130 |
|
---|
2131 | static int codecSetConfigX(PHDACODEC pThis, uint32_t cmd, uint8_t u8Offset)
|
---|
2132 | {
|
---|
2133 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2134 | Assert(CODEC_NID(cmd) < pThis->cTotalNodes);
|
---|
2135 | if (CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2136 | {
|
---|
2137 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(cmd)));
|
---|
2138 | return VINF_SUCCESS;
|
---|
2139 | }
|
---|
2140 | uint32_t *pu32Reg = NULL;
|
---|
2141 | if (hdaCodecIsPortNode(pThis, CODEC_NID(cmd)))
|
---|
2142 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].port.u32F1c_param;
|
---|
2143 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(cmd)))
|
---|
2144 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digin.u32F1c_param;
|
---|
2145 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(cmd)))
|
---|
2146 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].digout.u32F1c_param;
|
---|
2147 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(cmd)))
|
---|
2148 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].cdnode.u32F1c_param;
|
---|
2149 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(cmd)))
|
---|
2150 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].pcbeep.u32F1c_param;
|
---|
2151 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
|
---|
2152 | pu32Reg = &pThis->paNodes[CODEC_NID(cmd)].reserved.u32F1c_param;
|
---|
2153 | Assert(pu32Reg);
|
---|
2154 | if (pu32Reg)
|
---|
2155 | hdaCodecSetRegisterU8(pu32Reg, cmd, u8Offset);
|
---|
2156 | return VINF_SUCCESS;
|
---|
2157 | }
|
---|
2158 |
|
---|
2159 | /* 71C */
|
---|
2160 | static DECLCALLBACK(int) vrbProcSetConfig0(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2161 | {
|
---|
2162 | *pResp = 0;
|
---|
2163 | return codecSetConfigX(pThis, cmd, 0);
|
---|
2164 | }
|
---|
2165 |
|
---|
2166 | /* 71D */
|
---|
2167 | static DECLCALLBACK(int) vrbProcSetConfig1(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2168 | {
|
---|
2169 | *pResp = 0;
|
---|
2170 | return codecSetConfigX(pThis, cmd, 8);
|
---|
2171 | }
|
---|
2172 |
|
---|
2173 | /* 71E */
|
---|
2174 | static DECLCALLBACK(int) vrbProcSetConfig2(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2175 | {
|
---|
2176 | *pResp = 0;
|
---|
2177 | return codecSetConfigX(pThis, cmd, 16);
|
---|
2178 | }
|
---|
2179 |
|
---|
2180 | /* 71E */
|
---|
2181 | static DECLCALLBACK(int) vrbProcSetConfig3(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp)
|
---|
2182 | {
|
---|
2183 | *pResp = 0;
|
---|
2184 | return codecSetConfigX(pThis, cmd, 24);
|
---|
2185 | }
|
---|
2186 |
|
---|
2187 |
|
---|
2188 | /**
|
---|
2189 | * HDA codec verb map.
|
---|
2190 | * @todo Any reason not to use binary search here?
|
---|
2191 | */
|
---|
2192 | static const CODECVERB g_aCodecVerbs[] =
|
---|
2193 | {
|
---|
2194 | /* verb | verb mask | callback */
|
---|
2195 | /* ----------- -------------------- ----------------------- */
|
---|
2196 | { 0x000F0000, CODEC_VERB_8BIT_CMD , vrbProcGetParameter },
|
---|
2197 | { 0x000F0100, CODEC_VERB_8BIT_CMD , vrbProcGetConSelectCtrl },
|
---|
2198 | { 0x00070100, CODEC_VERB_8BIT_CMD , vrbProcSetConSelectCtrl },
|
---|
2199 | { 0x000F0600, CODEC_VERB_8BIT_CMD , vrbProcGetStreamId },
|
---|
2200 | { 0x00070600, CODEC_VERB_8BIT_CMD , vrbProcSetStreamId },
|
---|
2201 | { 0x000F0700, CODEC_VERB_8BIT_CMD , vrbProcGetPinCtrl },
|
---|
2202 | { 0x00070700, CODEC_VERB_8BIT_CMD , vrbProcSetPinCtrl },
|
---|
2203 | { 0x000F0800, CODEC_VERB_8BIT_CMD , vrbProcGetUnsolicitedEnabled },
|
---|
2204 | { 0x00070800, CODEC_VERB_8BIT_CMD , vrbProcSetUnsolicitedEnabled },
|
---|
2205 | { 0x000F0900, CODEC_VERB_8BIT_CMD , vrbProcGetPinSense },
|
---|
2206 | { 0x00070900, CODEC_VERB_8BIT_CMD , vrbProcSetPinSense },
|
---|
2207 | { 0x000F0200, CODEC_VERB_8BIT_CMD , vrbProcGetConnectionListEntry },
|
---|
2208 | { 0x000F0300, CODEC_VERB_8BIT_CMD , vrbProcGetProcessingState },
|
---|
2209 | { 0x00070300, CODEC_VERB_8BIT_CMD , vrbProcSetProcessingState },
|
---|
2210 | { 0x000F0D00, CODEC_VERB_8BIT_CMD , vrbProcGetDigitalConverter },
|
---|
2211 | { 0x00070D00, CODEC_VERB_8BIT_CMD , vrbProcSetDigitalConverter1 },
|
---|
2212 | { 0x00070E00, CODEC_VERB_8BIT_CMD , vrbProcSetDigitalConverter2 },
|
---|
2213 | { 0x000F2000, CODEC_VERB_8BIT_CMD , vrbProcGetSubId },
|
---|
2214 | { 0x00072000, CODEC_VERB_8BIT_CMD , vrbProcSetSubId0 },
|
---|
2215 | { 0x00072100, CODEC_VERB_8BIT_CMD , vrbProcSetSubId1 },
|
---|
2216 | { 0x00072200, CODEC_VERB_8BIT_CMD , vrbProcSetSubId2 },
|
---|
2217 | { 0x00072300, CODEC_VERB_8BIT_CMD , vrbProcSetSubId3 },
|
---|
2218 | { 0x0007FF00, CODEC_VERB_8BIT_CMD , vrbProcReset },
|
---|
2219 | { 0x000F0500, CODEC_VERB_8BIT_CMD , vrbProcGetPowerState },
|
---|
2220 | { 0x00070500, CODEC_VERB_8BIT_CMD , vrbProcSetPowerState },
|
---|
2221 | { 0x000F0C00, CODEC_VERB_8BIT_CMD , vrbProcGetEAPD_BTLEnabled },
|
---|
2222 | { 0x00070C00, CODEC_VERB_8BIT_CMD , vrbProcSetEAPD_BTLEnabled },
|
---|
2223 | { 0x000F0F00, CODEC_VERB_8BIT_CMD , vrbProcGetVolumeKnobCtrl },
|
---|
2224 | { 0x00070F00, CODEC_VERB_8BIT_CMD , vrbProcSetVolumeKnobCtrl },
|
---|
2225 | { 0x000F1700, CODEC_VERB_8BIT_CMD , vrbProcGetGPIOUnsolisted },
|
---|
2226 | { 0x00071700, CODEC_VERB_8BIT_CMD , vrbProcSetGPIOUnsolisted },
|
---|
2227 | { 0x000F1C00, CODEC_VERB_8BIT_CMD , vrbProcGetConfig },
|
---|
2228 | { 0x00071C00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig0 },
|
---|
2229 | { 0x00071D00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig1 },
|
---|
2230 | { 0x00071E00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig2 },
|
---|
2231 | { 0x00071F00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig3 },
|
---|
2232 | { 0x000A0000, CODEC_VERB_16BIT_CMD, vrbProcGetConverterFormat },
|
---|
2233 | { 0x00020000, CODEC_VERB_16BIT_CMD, vrbProcSetConverterFormat },
|
---|
2234 | { 0x000B0000, CODEC_VERB_16BIT_CMD, vrbProcGetAmplifier },
|
---|
2235 | { 0x00030000, CODEC_VERB_16BIT_CMD, vrbProcSetAmplifier },
|
---|
2236 | };
|
---|
2237 |
|
---|
2238 | static int codecLookup(PHDACODEC pThis, uint32_t cmd, PPFNHDACODECVERBPROCESSOR pfn)
|
---|
2239 | {
|
---|
2240 | Assert(CODEC_CAD(cmd) == pThis->id);
|
---|
2241 | if (hdaCodecIsReservedNode(pThis, CODEC_NID(cmd)))
|
---|
2242 | LogFlowFunc(("cmd %x was addressed to reserved node\n", cmd));
|
---|
2243 |
|
---|
2244 | if ( CODEC_VERBDATA(cmd) == 0
|
---|
2245 | || CODEC_NID(cmd) >= pThis->cTotalNodes)
|
---|
2246 | {
|
---|
2247 | *pfn = vrbProcUnimplemented;
|
---|
2248 | /// @todo r=michaln: There needs to be a counter to avoid log flooding (see e.g. DevRTC.cpp)
|
---|
2249 | LogFlowFunc(("cmd %x was ignored\n", cmd));
|
---|
2250 | return VINF_SUCCESS;
|
---|
2251 | }
|
---|
2252 |
|
---|
2253 | for (int i = 0; i < pThis->cVerbs; ++i)
|
---|
2254 | {
|
---|
2255 | if ((CODEC_VERBDATA(cmd) & pThis->paVerbs[i].mask) == pThis->paVerbs[i].verb)
|
---|
2256 | {
|
---|
2257 | *pfn = pThis->paVerbs[i].pfn;
|
---|
2258 | return VINF_SUCCESS;
|
---|
2259 | }
|
---|
2260 | }
|
---|
2261 |
|
---|
2262 | *pfn = vrbProcUnimplemented;
|
---|
2263 | LogFlowFunc(("callback for %x wasn't found\n", CODEC_VERBDATA(cmd)));
|
---|
2264 | return VINF_SUCCESS;
|
---|
2265 | }
|
---|
2266 |
|
---|
2267 | #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2268 | static void pi_callback(void *opaque, int avail)
|
---|
2269 | {
|
---|
2270 | PHDACODEC pThis = (PHDACODEC)opaque;
|
---|
2271 | pThis->pfnTransfer(pThis, PI_INDEX, avail);
|
---|
2272 | }
|
---|
2273 |
|
---|
2274 | static void po_callback(void *opaque, int avail)
|
---|
2275 | {
|
---|
2276 | PHDACODEC pThis = (PHDACODEC)opaque;
|
---|
2277 | pThis->pfnTransfer(pThis, PO_INDEX, avail);
|
---|
2278 | }
|
---|
2279 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2280 |
|
---|
2281 | /*
|
---|
2282 | * APIs exposed to DevHDA.
|
---|
2283 | */
|
---|
2284 |
|
---|
2285 |
|
---|
2286 | /**
|
---|
2287 | *
|
---|
2288 | * routines open one of the voices (IN, OUT) with corresponding parameters.
|
---|
2289 | * this routine could be called from HDA on setting/resseting sound format.
|
---|
2290 | *
|
---|
2291 | * @todo Probably passed settings should be verified (if AFG's declared proposed
|
---|
2292 | * format) before enabling.
|
---|
2293 | */
|
---|
2294 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2295 | int hdaCodecOpenStream(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, PPDMAUDIOSTREAMCFG pCfg)
|
---|
2296 | #else
|
---|
2297 | int hdaCodecOpenStream(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings)
|
---|
2298 | #endif
|
---|
2299 | {
|
---|
2300 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2301 |
|
---|
2302 | int rc;
|
---|
2303 |
|
---|
2304 | switch (enmSoundSource)
|
---|
2305 | {
|
---|
2306 | case PI_INDEX:
|
---|
2307 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2308 | rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in",
|
---|
2309 | PDMAUDIORECSOURCE_LINE_IN, pCfg);
|
---|
2310 | #else
|
---|
2311 | pThis->SwVoiceIn = AUD_open_in(&pThis->card, pThis->SwVoiceIn, "hda.in", pThis, pi_callback, pAudioSettings);
|
---|
2312 | rc = pThis->SwVoiceIn ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
|
---|
2313 | #endif
|
---|
2314 | break;
|
---|
2315 |
|
---|
2316 | case PO_INDEX:
|
---|
2317 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2318 | rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg);
|
---|
2319 | #else
|
---|
2320 | pThis->SwVoiceOut = AUD_open_out(&pThis->card, pThis->SwVoiceOut, "hda.out", pThis, po_callback, pAudioSettings);
|
---|
2321 | rc = pThis->SwVoiceOut ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
|
---|
2322 | #endif
|
---|
2323 | break;
|
---|
2324 |
|
---|
2325 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2326 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
2327 | case MC_INDEX:
|
---|
2328 | rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc",
|
---|
2329 | PDMAUDIORECSOURCE_MIC, pCfg);
|
---|
2330 | break;
|
---|
2331 | # endif
|
---|
2332 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2333 |
|
---|
2334 | default:
|
---|
2335 | AssertMsgFailed(("Index %ld not implemented\n", enmSoundSource));
|
---|
2336 | rc = VERR_NOT_IMPLEMENTED;
|
---|
2337 | }
|
---|
2338 |
|
---|
2339 | LogFlowFuncLeaveRC(rc);
|
---|
2340 | return rc;
|
---|
2341 | }
|
---|
2342 |
|
---|
2343 | int hdaCodecSaveState(PHDACODEC pThis, PSSMHANDLE pSSM)
|
---|
2344 | {
|
---|
2345 | AssertLogRelMsgReturn(pThis->cTotalNodes == 0x1c, ("cTotalNodes=%#x, should be 0x1c", pThis->cTotalNodes),
|
---|
2346 | VERR_INTERNAL_ERROR);
|
---|
2347 | SSMR3PutU32(pSSM, pThis->cTotalNodes);
|
---|
2348 | for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
|
---|
2349 | SSMR3PutStructEx(pSSM, &pThis->paNodes[idxNode].SavedState, sizeof(pThis->paNodes[idxNode].SavedState),
|
---|
2350 | 0 /*fFlags*/, g_aCodecNodeFields, NULL /*pvUser*/);
|
---|
2351 | return VINF_SUCCESS;
|
---|
2352 | }
|
---|
2353 |
|
---|
2354 | int hdaCodecLoadState(PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion)
|
---|
2355 | {
|
---|
2356 | PCSSMFIELD pFields;
|
---|
2357 | uint32_t fFlags;
|
---|
2358 | switch (uVersion)
|
---|
2359 | {
|
---|
2360 | case HDA_SSM_VERSION_1:
|
---|
2361 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2362 | pFields = g_aCodecNodeFieldsV1;
|
---|
2363 | fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
|
---|
2364 | break;
|
---|
2365 |
|
---|
2366 | case HDA_SSM_VERSION_2:
|
---|
2367 | case HDA_SSM_VERSION_3:
|
---|
2368 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2369 | pFields = g_aCodecNodeFields;
|
---|
2370 | fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
|
---|
2371 | break;
|
---|
2372 |
|
---|
2373 | case HDA_SSM_VERSION:
|
---|
2374 | {
|
---|
2375 | uint32_t cNodes;
|
---|
2376 | int rc2 = SSMR3GetU32(pSSM, &cNodes);
|
---|
2377 | AssertRCReturn(rc2, rc2);
|
---|
2378 | if (cNodes != 0x1c)
|
---|
2379 | return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
|
---|
2380 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2381 |
|
---|
2382 | pFields = g_aCodecNodeFields;
|
---|
2383 | fFlags = 0;
|
---|
2384 | break;
|
---|
2385 | }
|
---|
2386 |
|
---|
2387 | default:
|
---|
2388 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
2389 | }
|
---|
2390 |
|
---|
2391 | for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
|
---|
2392 | {
|
---|
2393 | uint8_t idOld = pThis->paNodes[idxNode].SavedState.Core.id;
|
---|
2394 | int rc = SSMR3GetStructEx(pSSM, &pThis->paNodes[idxNode].SavedState,
|
---|
2395 | sizeof(pThis->paNodes[idxNode].SavedState),
|
---|
2396 | fFlags, pFields, NULL);
|
---|
2397 | if (RT_FAILURE(rc))
|
---|
2398 | return rc;
|
---|
2399 | AssertLogRelMsgReturn(idOld == pThis->paNodes[idxNode].SavedState.Core.id,
|
---|
2400 | ("loaded %#x, expected \n", pThis->paNodes[idxNode].SavedState.Core.id, idOld),
|
---|
2401 | VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
2402 | }
|
---|
2403 |
|
---|
2404 | /*
|
---|
2405 | * Update stuff after changing the state.
|
---|
2406 | */
|
---|
2407 | if (hdaCodecIsDacNode(pThis, pThis->u8DacLineOut))
|
---|
2408 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2409 | hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_VOLUME);
|
---|
2410 | #else
|
---|
2411 | hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);
|
---|
2412 | #endif
|
---|
2413 | else if (hdaCodecIsSpdifOutNode(pThis, pThis->u8DacLineOut))
|
---|
2414 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2415 | hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].spdifout.B_params, PDMAUDIOMIXERCTL_VOLUME);
|
---|
2416 | hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2417 | #else
|
---|
2418 | hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].spdifout.B_params, AUD_MIXER_VOLUME);
|
---|
2419 | hdaCodecToAudVolume(&pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, AUD_MIXER_LINE_IN);
|
---|
2420 | #endif
|
---|
2421 |
|
---|
2422 | return VINF_SUCCESS;
|
---|
2423 | }
|
---|
2424 |
|
---|
2425 | int hdaCodecDestruct(PHDACODEC pThis)
|
---|
2426 | {
|
---|
2427 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2428 |
|
---|
2429 | if (pThis->paNodes)
|
---|
2430 | {
|
---|
2431 | RTMemFree(pThis->paNodes);
|
---|
2432 | pThis->paNodes = NULL;
|
---|
2433 | }
|
---|
2434 |
|
---|
2435 | return VINF_SUCCESS;
|
---|
2436 | }
|
---|
2437 |
|
---|
2438 | int hdaCodecConstruct(PPDMDEVINS pDevIns, PHDACODEC pThis,
|
---|
2439 | uint16_t uLUN, PCFGMNODE pCfg)
|
---|
2440 | {
|
---|
2441 | AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
|
---|
2442 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2443 | AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
|
---|
2444 |
|
---|
2445 | pThis->id = uLUN;
|
---|
2446 | pThis->paVerbs = &g_aCodecVerbs[0];
|
---|
2447 | pThis->cVerbs = RT_ELEMENTS(g_aCodecVerbs);
|
---|
2448 | pThis->pfnLookup = codecLookup;
|
---|
2449 | int rc = stac9220Construct(pThis);
|
---|
2450 | AssertRC(rc);
|
---|
2451 |
|
---|
2452 | /* common root node initializers */
|
---|
2453 | pThis->paNodes[0].node.au32F00_param[0] = CODEC_MAKE_F00_00(pThis->u16VendorId, pThis->u16DeviceId);
|
---|
2454 | pThis->paNodes[0].node.au32F00_param[4] = CODEC_MAKE_F00_04(0x1, 0x1);
|
---|
2455 | /* common AFG node initializers */
|
---|
2456 | pThis->paNodes[1].node.au32F00_param[4] = CODEC_MAKE_F00_04(0x2, pThis->cTotalNodes - 2);
|
---|
2457 | pThis->paNodes[1].node.au32F00_param[5] = CODEC_MAKE_F00_05(1, CODEC_F00_05_AFG);
|
---|
2458 | pThis->paNodes[1].afg.u32F20_param = CODEC_MAKE_F20(pThis->u16VendorId, pThis->u8BSKU, pThis->u8AssemblyId);
|
---|
2459 |
|
---|
2460 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2461 | /* 44.1 kHz. */
|
---|
2462 | PDMAUDIOSTREAMCFG as;
|
---|
2463 | as.uHz = 44100;
|
---|
2464 | as.cChannels = 2;
|
---|
2465 | as.enmFormat = AUD_FMT_S16;
|
---|
2466 | as.enmEndianness = PDMAUDIOHOSTENDIANNESS;
|
---|
2467 | #else
|
---|
2468 | AUD_register_card("ICH0", &pThis->card);
|
---|
2469 |
|
---|
2470 | /* 44.1 kHz */
|
---|
2471 | audsettings_t as;
|
---|
2472 | as.freq = 44100;
|
---|
2473 | as.nchannels = 2;
|
---|
2474 | as.fmt = AUD_FMT_S16;
|
---|
2475 | as.endianness = 0;
|
---|
2476 | #endif
|
---|
2477 |
|
---|
2478 | pThis->paNodes[1].node.au32F00_param[0xA] = CODEC_F00_0A_16_BIT;
|
---|
2479 |
|
---|
2480 | hdaCodecOpenStream(pThis, PI_INDEX, &as);
|
---|
2481 | hdaCodecOpenStream(pThis, PO_INDEX, &as);
|
---|
2482 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2483 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
2484 | hdaCodecOpenStream(pThis, MC_INDEX, &as);
|
---|
2485 | # endif
|
---|
2486 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2487 |
|
---|
2488 | pThis->paNodes[1].node.au32F00_param[0xA] |= CODEC_F00_0A_44_1KHZ;
|
---|
2489 |
|
---|
2490 | uint8_t i;
|
---|
2491 | Assert(pThis->paNodes);
|
---|
2492 | Assert(pThis->pfnCodecNodeReset);
|
---|
2493 |
|
---|
2494 | for (i = 0; i < pThis->cTotalNodes; ++i)
|
---|
2495 | pThis->pfnCodecNodeReset(pThis, i, &pThis->paNodes[i]);
|
---|
2496 |
|
---|
2497 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2498 | hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_VOLUME);
|
---|
2499 | hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2500 |
|
---|
2501 |
|
---|
2502 | #else
|
---|
2503 | hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);
|
---|
2504 | hdaCodecToAudVolume(&pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, AUD_MIXER_LINE_IN);
|
---|
2505 |
|
---|
2506 | if (!AUD_is_host_voice_in_ok(pThis->SwVoiceIn))
|
---|
2507 | LogRel (("HDA: WARNING: Unable to open PCM IN!\n"));
|
---|
2508 | if (!AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
|
---|
2509 | LogRel (("HDA: WARNING: Unable to open PCM OUT!\n"));
|
---|
2510 |
|
---|
2511 | if ( !AUD_is_host_voice_in_ok(pThis->SwVoiceIn)
|
---|
2512 | && !AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
|
---|
2513 | {
|
---|
2514 | AUD_close_in(&pThis->card, pThis->SwVoiceIn);
|
---|
2515 | AUD_close_out(&pThis->card, pThis->SwVoiceOut);
|
---|
2516 |
|
---|
2517 | pThis->SwVoiceOut = NULL;
|
---|
2518 | pThis->SwVoiceIn = NULL;
|
---|
2519 |
|
---|
2520 | AUD_init_null ();
|
---|
2521 |
|
---|
2522 | PDMDevHlpVMSetRuntimeError (pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
|
---|
2523 | N_ ("No audio devices could be opened. Selecting the NULL audio backend "
|
---|
2524 | "with the consequence that no sound is audible"));
|
---|
2525 | }
|
---|
2526 | else if ( !AUD_is_host_voice_in_ok(pThis->SwVoiceIn)
|
---|
2527 | || !AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
|
---|
2528 | {
|
---|
2529 | char szMissingVoices[128];
|
---|
2530 | size_t len = 0;
|
---|
2531 |
|
---|
2532 | if (!AUD_is_host_voice_in_ok(pThis->SwVoiceIn))
|
---|
2533 | len = RTStrPrintf (szMissingVoices, sizeof(szMissingVoices), "PCM_in");
|
---|
2534 | if (!AUD_is_host_voice_out_ok(pThis->SwVoiceOut))
|
---|
2535 | len += RTStrPrintf (szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_out" : "PCM_out");
|
---|
2536 |
|
---|
2537 | PDMDevHlpVMSetRuntimeError (pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
|
---|
2538 | N_ ("Some audio devices (%s) could not be opened. Guest applications generating audio "
|
---|
2539 | "output or depending on audio input may hang. Make sure your host audio device "
|
---|
2540 | "is working properly. Check the logfile for error messages of the audio "
|
---|
2541 | "subsystem"), szMissingVoices);
|
---|
2542 | }
|
---|
2543 | #endif
|
---|
2544 |
|
---|
2545 | return VINF_SUCCESS;
|
---|
2546 | }
|
---|
2547 |
|
---|