1 | /* $Id: DevHdaCodec.cpp 90143 2021-07-09 22:57:47Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Intel HD Audio Controller Emulation - Codec, Sigmatel/IDT STAC9220.
|
---|
4 | *
|
---|
5 | * Implemented based on the Intel HD Audio specification and the
|
---|
6 | * Sigmatel/IDT STAC9220 datasheet.
|
---|
7 | */
|
---|
8 |
|
---|
9 | /*
|
---|
10 | * Copyright (C) 2006-2020 Oracle Corporation
|
---|
11 | *
|
---|
12 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | * available from http://www.virtualbox.org. This file is free software;
|
---|
14 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | * General Public License (GPL) as published by the Free Software
|
---|
16 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 | */
|
---|
20 |
|
---|
21 |
|
---|
22 | /*********************************************************************************************************************************
|
---|
23 | * Header Files *
|
---|
24 | *********************************************************************************************************************************/
|
---|
25 | #define LOG_GROUP LOG_GROUP_DEV_HDA_CODEC
|
---|
26 | #include <VBox/log.h>
|
---|
27 |
|
---|
28 | #include <VBox/AssertGuest.h>
|
---|
29 | #include <VBox/vmm/pdmdev.h>
|
---|
30 | #include <VBox/vmm/pdmaudioifs.h>
|
---|
31 | #include <VBox/vmm/pdmaudioinline.h>
|
---|
32 |
|
---|
33 | #include <iprt/assert.h>
|
---|
34 | #include <iprt/uuid.h>
|
---|
35 | #include <iprt/string.h>
|
---|
36 | #include <iprt/mem.h>
|
---|
37 | #include <iprt/asm.h>
|
---|
38 | #include <iprt/cpp/utils.h>
|
---|
39 |
|
---|
40 | #include "VBoxDD.h"
|
---|
41 | #include "AudioMixer.h"
|
---|
42 | #include "DevHda.h"
|
---|
43 |
|
---|
44 |
|
---|
45 | /*********************************************************************************************************************************
|
---|
46 | * Defined Constants And Macros *
|
---|
47 | *********************************************************************************************************************************/
|
---|
48 | #define AMPLIFIER_IN 0
|
---|
49 | #define AMPLIFIER_OUT 1
|
---|
50 | #define AMPLIFIER_LEFT 1
|
---|
51 | #define AMPLIFIER_RIGHT 0
|
---|
52 | #define AMPLIFIER_REGISTER(amp, inout, side, index) ((amp)[30*(inout) + 15*(side) + (index)])
|
---|
53 |
|
---|
54 |
|
---|
55 | /** @name STAC9220 - Nodes IDs / Names.
|
---|
56 | * @{ */
|
---|
57 | #define STAC9220_NID_ROOT 0x0 /* Root node */
|
---|
58 | #define STAC9220_NID_AFG 0x1 /* Audio Configuration Group */
|
---|
59 | #define STAC9220_NID_DAC0 0x2 /* Out */
|
---|
60 | #define STAC9220_NID_DAC1 0x3 /* Out */
|
---|
61 | #define STAC9220_NID_DAC2 0x4 /* Out */
|
---|
62 | #define STAC9220_NID_DAC3 0x5 /* Out */
|
---|
63 | #define STAC9220_NID_ADC0 0x6 /* In */
|
---|
64 | #define STAC9220_NID_ADC1 0x7 /* In */
|
---|
65 | #define STAC9220_NID_SPDIF_OUT 0x8 /* Out */
|
---|
66 | #define STAC9220_NID_SPDIF_IN 0x9 /* In */
|
---|
67 | /** Also known as PIN_A. */
|
---|
68 | #define STAC9220_NID_PIN_HEADPHONE0 0xA /* In, Out */
|
---|
69 | #define STAC9220_NID_PIN_B 0xB /* In, Out */
|
---|
70 | #define STAC9220_NID_PIN_C 0xC /* In, Out */
|
---|
71 | /** Also known as PIN D. */
|
---|
72 | #define STAC9220_NID_PIN_HEADPHONE1 0xD /* In, Out */
|
---|
73 | #define STAC9220_NID_PIN_E 0xE /* In */
|
---|
74 | #define STAC9220_NID_PIN_F 0xF /* In, Out */
|
---|
75 | /** Also known as DIGOUT0. */
|
---|
76 | #define STAC9220_NID_PIN_SPDIF_OUT 0x10 /* Out */
|
---|
77 | /** Also known as DIGIN. */
|
---|
78 | #define STAC9220_NID_PIN_SPDIF_IN 0x11 /* In */
|
---|
79 | #define STAC9220_NID_ADC0_MUX 0x12 /* In */
|
---|
80 | #define STAC9220_NID_ADC1_MUX 0x13 /* In */
|
---|
81 | #define STAC9220_NID_PCBEEP 0x14 /* Out */
|
---|
82 | #define STAC9220_NID_PIN_CD 0x15 /* In */
|
---|
83 | #define STAC9220_NID_VOL_KNOB 0x16
|
---|
84 | #define STAC9220_NID_AMP_ADC0 0x17 /* In */
|
---|
85 | #define STAC9220_NID_AMP_ADC1 0x18 /* In */
|
---|
86 | /* Only for STAC9221. */
|
---|
87 | #define STAC9221_NID_ADAT_OUT 0x19 /* Out */
|
---|
88 | #define STAC9221_NID_I2S_OUT 0x1A /* Out */
|
---|
89 | #define STAC9221_NID_PIN_I2S_OUT 0x1B /* Out */
|
---|
90 |
|
---|
91 | /** Number of total nodes emulated. */
|
---|
92 | #define STAC9221_NUM_NODES 0x1C
|
---|
93 | /** @} */
|
---|
94 |
|
---|
95 |
|
---|
96 | /*********************************************************************************************************************************
|
---|
97 | * Internal Functions *
|
---|
98 | *********************************************************************************************************************************/
|
---|
99 | /**
|
---|
100 | * A codec verb descriptor.
|
---|
101 | */
|
---|
102 | typedef struct CODECVERB
|
---|
103 | {
|
---|
104 | /** Verb. */
|
---|
105 | uint32_t uVerb;
|
---|
106 | /** Verb mask. */
|
---|
107 | uint32_t fMask;
|
---|
108 | /**
|
---|
109 | * Function pointer for implementation callback.
|
---|
110 | *
|
---|
111 | * This is always a valid pointer in ring-3, while elsewhere a NULL indicates
|
---|
112 | * that we must return to ring-3 to process it.
|
---|
113 | *
|
---|
114 | * @returns VBox status code (99.9% is VINF_SUCCESS, caller doesn't care much
|
---|
115 | * what you return at present).
|
---|
116 | *
|
---|
117 | * @param pThis The shared codec intance data.
|
---|
118 | * @param uCmd The command.
|
---|
119 | * @param puResp Where to return the response value.
|
---|
120 | *
|
---|
121 | * @thread EMT or task worker thread (see HDASTATE::hCorbDmaTask).
|
---|
122 | */
|
---|
123 | DECLCALLBACKMEMBER(int, pfn, (PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp));
|
---|
124 | /** Friendly name, for debugging. */
|
---|
125 | const char *pszName;
|
---|
126 | } CODECVERB;
|
---|
127 | /** Pointer to a const codec verb descriptor. */
|
---|
128 | typedef CODECVERB const *PCCODECVERB;
|
---|
129 |
|
---|
130 |
|
---|
131 | /*********************************************************************************************************************************
|
---|
132 | * Global Variables *
|
---|
133 | *********************************************************************************************************************************/
|
---|
134 | /** @name STAC9220 Node Classifications.
|
---|
135 | * @note Referenced through STAC9220WIDGET in the constructor below.
|
---|
136 | * @{ */
|
---|
137 | static uint8_t const g_abStac9220Ports[] = { STAC9220_NID_PIN_HEADPHONE0, STAC9220_NID_PIN_B, STAC9220_NID_PIN_C, STAC9220_NID_PIN_HEADPHONE1, STAC9220_NID_PIN_E, STAC9220_NID_PIN_F, 0 };
|
---|
138 | static uint8_t const g_abStac9220Dacs[] = { STAC9220_NID_DAC0, STAC9220_NID_DAC1, STAC9220_NID_DAC2, STAC9220_NID_DAC3, 0 };
|
---|
139 | static uint8_t const g_abStac9220Adcs[] = { STAC9220_NID_ADC0, STAC9220_NID_ADC1, 0 };
|
---|
140 | static uint8_t const g_abStac9220SpdifOuts[] = { STAC9220_NID_SPDIF_OUT, 0 };
|
---|
141 | static uint8_t const g_abStac9220SpdifIns[] = { STAC9220_NID_SPDIF_IN, 0 };
|
---|
142 | static uint8_t const g_abStac9220DigOutPins[] = { STAC9220_NID_PIN_SPDIF_OUT, 0 };
|
---|
143 | static uint8_t const g_abStac9220DigInPins[] = { STAC9220_NID_PIN_SPDIF_IN, 0 };
|
---|
144 | static uint8_t const g_abStac9220AdcVols[] = { STAC9220_NID_AMP_ADC0, STAC9220_NID_AMP_ADC1, 0 };
|
---|
145 | static uint8_t const g_abStac9220AdcMuxs[] = { STAC9220_NID_ADC0_MUX, STAC9220_NID_ADC1_MUX, 0 };
|
---|
146 | static uint8_t const g_abStac9220Pcbeeps[] = { STAC9220_NID_PCBEEP, 0 };
|
---|
147 | static uint8_t const g_abStac9220Cds[] = { STAC9220_NID_PIN_CD, 0 };
|
---|
148 | static uint8_t const g_abStac9220VolKnobs[] = { STAC9220_NID_VOL_KNOB, 0 };
|
---|
149 | /** @} */
|
---|
150 |
|
---|
151 | /** @name STAC 9221 Values.
|
---|
152 | * @note Referenced through STAC9220WIDGET in the constructor below
|
---|
153 | * @{ */
|
---|
154 | /** @todo Is STAC9220_NID_SPDIF_IN really correct for reserved nodes? */
|
---|
155 | static uint8_t const g_abStac9220Reserveds[] = { STAC9220_NID_SPDIF_IN, STAC9221_NID_ADAT_OUT, STAC9221_NID_I2S_OUT, STAC9221_NID_PIN_I2S_OUT, 0 };
|
---|
156 | /** @} */
|
---|
157 |
|
---|
158 |
|
---|
159 | /** SSM description of CODECCOMMONNODE. */
|
---|
160 | static SSMFIELD const g_aCodecNodeFields[] =
|
---|
161 | {
|
---|
162 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.uID),
|
---|
163 | SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3),
|
---|
164 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F00_param),
|
---|
165 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F02_param),
|
---|
166 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, au32Params),
|
---|
167 | SSMFIELD_ENTRY_TERM()
|
---|
168 | };
|
---|
169 |
|
---|
170 | /** Backward compatibility with v1 of CODECCOMMONNODE. */
|
---|
171 | static SSMFIELD const g_aCodecNodeFieldsV1[] =
|
---|
172 | {
|
---|
173 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.uID),
|
---|
174 | SSMFIELD_ENTRY_PAD_HC_AUTO(3, 7),
|
---|
175 | SSMFIELD_ENTRY_OLD_HCPTR(Core.name),
|
---|
176 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F00_param),
|
---|
177 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, Core.au32F02_param),
|
---|
178 | SSMFIELD_ENTRY( CODECSAVEDSTATENODE, au32Params),
|
---|
179 | SSMFIELD_ENTRY_TERM()
|
---|
180 | };
|
---|
181 |
|
---|
182 |
|
---|
183 |
|
---|
184 | /*********************************************************************************************************************************
|
---|
185 | * STAC9220 Constructor / Reset *
|
---|
186 | *********************************************************************************************************************************/
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Resets a single node of the codec.
|
---|
190 | *
|
---|
191 | * @param pThis HDA codec of node to reset.
|
---|
192 | * @param uNID Node ID to set node to.
|
---|
193 | * @param pNode Node to reset.
|
---|
194 | */
|
---|
195 | static void stac9220NodeReset(PHDACODECR3 pThis, uint8_t uNID, PCODECNODE pNode)
|
---|
196 | {
|
---|
197 | LogFlowFunc(("NID=0x%x (%RU8)\n", uNID, uNID));
|
---|
198 |
|
---|
199 | if ( !pThis->fInReset
|
---|
200 | && ( uNID != STAC9220_NID_ROOT
|
---|
201 | && uNID != STAC9220_NID_AFG)
|
---|
202 | )
|
---|
203 | {
|
---|
204 | RT_ZERO(pNode->node);
|
---|
205 | }
|
---|
206 |
|
---|
207 | /* Set common parameters across all nodes. */
|
---|
208 | pNode->node.uID = uNID;
|
---|
209 | pNode->node.uSD = 0;
|
---|
210 |
|
---|
211 | switch (uNID)
|
---|
212 | {
|
---|
213 | /* Root node. */
|
---|
214 | case STAC9220_NID_ROOT:
|
---|
215 | {
|
---|
216 | /* Set the revision ID. */
|
---|
217 | pNode->root.node.au32F00_param[0x02] = CODEC_MAKE_F00_02(0x1, 0x0, 0x3, 0x4, 0x0, 0x1);
|
---|
218 | break;
|
---|
219 | }
|
---|
220 |
|
---|
221 | /*
|
---|
222 | * AFG (Audio Function Group).
|
---|
223 | */
|
---|
224 | case STAC9220_NID_AFG:
|
---|
225 | {
|
---|
226 | pNode->afg.node.au32F00_param[0x08] = CODEC_MAKE_F00_08(1, 0xd, 0xd);
|
---|
227 | /* We set the AFG's PCM capabitilies fixed to 16kHz, 22.5kHz + 44.1kHz, 16-bit signed. */
|
---|
228 | pNode->afg.node.au32F00_param[0x0A] = CODEC_F00_0A_44_1KHZ /* 44.1 kHz */
|
---|
229 | | CODEC_F00_0A_44_1KHZ_1_2X /* Messed up way of saying 22.05 kHz */
|
---|
230 | | CODEC_F00_0A_48KHZ_1_3X /* Messed up way of saying 16 kHz. */
|
---|
231 | | CODEC_F00_0A_16_BIT; /* 16-bit signed */
|
---|
232 | /* Note! We do not set CODEC_F00_0A_48KHZ here because we end up with
|
---|
233 | S/PDIF output showing up in windows and it trying to configure
|
---|
234 | streams other than 0 and 4 and stuff going sideways in the
|
---|
235 | stream setup/removal area. */
|
---|
236 | pNode->afg.node.au32F00_param[0x0B] = CODEC_F00_0B_PCM;
|
---|
237 | pNode->afg.node.au32F00_param[0x0C] = CODEC_MAKE_F00_0C(0x17)
|
---|
238 | | CODEC_F00_0C_CAP_BALANCED_IO
|
---|
239 | | CODEC_F00_0C_CAP_INPUT
|
---|
240 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
241 | | CODEC_F00_0C_CAP_PRESENCE_DETECT
|
---|
242 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED
|
---|
243 | | CODEC_F00_0C_CAP_IMPENDANCE_SENSE;
|
---|
244 |
|
---|
245 | /* Default input amplifier capabilities. */
|
---|
246 | pNode->node.au32F00_param[0x0D] = CODEC_MAKE_F00_0D(CODEC_AMP_CAP_MUTE,
|
---|
247 | CODEC_AMP_STEP_SIZE,
|
---|
248 | CODEC_AMP_NUM_STEPS,
|
---|
249 | CODEC_AMP_OFF_INITIAL);
|
---|
250 | /* Default output amplifier capabilities. */
|
---|
251 | pNode->node.au32F00_param[0x12] = CODEC_MAKE_F00_12(CODEC_AMP_CAP_MUTE,
|
---|
252 | CODEC_AMP_STEP_SIZE,
|
---|
253 | CODEC_AMP_NUM_STEPS,
|
---|
254 | CODEC_AMP_OFF_INITIAL);
|
---|
255 |
|
---|
256 | pNode->afg.node.au32F00_param[0x11] = CODEC_MAKE_F00_11(1, 1, 0, 0, 4);
|
---|
257 | pNode->afg.node.au32F00_param[0x0F] = CODEC_F00_0F_D3
|
---|
258 | | CODEC_F00_0F_D2
|
---|
259 | | CODEC_F00_0F_D1
|
---|
260 | | CODEC_F00_0F_D0;
|
---|
261 |
|
---|
262 | pNode->afg.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D2, CODEC_F05_D2); /* PS-Act: D2, PS->Set D2. */
|
---|
263 | pNode->afg.u32F08_param = 0;
|
---|
264 | pNode->afg.u32F17_param = 0;
|
---|
265 | break;
|
---|
266 | }
|
---|
267 |
|
---|
268 | /*
|
---|
269 | * DACs.
|
---|
270 | */
|
---|
271 | case STAC9220_NID_DAC0: /* DAC0: Headphones 0 + 1 */
|
---|
272 | case STAC9220_NID_DAC1: /* DAC1: PIN C */
|
---|
273 | case STAC9220_NID_DAC2: /* DAC2: PIN B */
|
---|
274 | case STAC9220_NID_DAC3: /* DAC3: PIN F */
|
---|
275 | {
|
---|
276 | pNode->dac.u32A_param = CODEC_MAKE_A(HDA_SDFMT_TYPE_PCM, HDA_SDFMT_BASE_44KHZ,
|
---|
277 | HDA_SDFMT_MULT_1X, HDA_SDFMT_DIV_2X, HDA_SDFMT_16_BIT,
|
---|
278 | HDA_SDFMT_CHAN_STEREO);
|
---|
279 |
|
---|
280 | /* 7.3.4.6: Audio widget capabilities. */
|
---|
281 | pNode->dac.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_OUTPUT, 13, 0)
|
---|
282 | | CODEC_F00_09_CAP_L_R_SWAP
|
---|
283 | | CODEC_F00_09_CAP_POWER_CTRL
|
---|
284 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT
|
---|
285 | | CODEC_F00_09_CAP_STEREO;
|
---|
286 |
|
---|
287 | /* Connection list; must be 0 if the only connection for the widget is
|
---|
288 | * to the High Definition Audio Link. */
|
---|
289 | pNode->dac.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 0 /* Entries */);
|
---|
290 |
|
---|
291 | pNode->dac.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D3, CODEC_F05_D3);
|
---|
292 |
|
---|
293 | RT_ZERO(pNode->dac.B_params);
|
---|
294 | AMPLIFIER_REGISTER(pNode->dac.B_params, AMPLIFIER_OUT, AMPLIFIER_LEFT, 0) = 0x7F | RT_BIT(7);
|
---|
295 | AMPLIFIER_REGISTER(pNode->dac.B_params, AMPLIFIER_OUT, AMPLIFIER_RIGHT, 0) = 0x7F | RT_BIT(7);
|
---|
296 | break;
|
---|
297 | }
|
---|
298 |
|
---|
299 | /*
|
---|
300 | * ADCs.
|
---|
301 | */
|
---|
302 | case STAC9220_NID_ADC0: /* Analog input. */
|
---|
303 | {
|
---|
304 | pNode->node.au32F02_param[0] = STAC9220_NID_AMP_ADC0;
|
---|
305 | goto adc_init;
|
---|
306 | }
|
---|
307 |
|
---|
308 | case STAC9220_NID_ADC1: /* Analog input (CD). */
|
---|
309 | {
|
---|
310 | pNode->node.au32F02_param[0] = STAC9220_NID_AMP_ADC1;
|
---|
311 |
|
---|
312 | /* Fall through is intentional. */
|
---|
313 | adc_init:
|
---|
314 |
|
---|
315 | pNode->adc.u32A_param = CODEC_MAKE_A(HDA_SDFMT_TYPE_PCM, HDA_SDFMT_BASE_44KHZ,
|
---|
316 | HDA_SDFMT_MULT_1X, HDA_SDFMT_DIV_2X, HDA_SDFMT_16_BIT,
|
---|
317 | HDA_SDFMT_CHAN_STEREO);
|
---|
318 |
|
---|
319 | pNode->adc.u32F03_param = RT_BIT(0);
|
---|
320 | pNode->adc.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D3, CODEC_F05_D3); /* PS-Act: D3 Set: D3 */
|
---|
321 |
|
---|
322 | pNode->adc.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_INPUT, 0xD, 0)
|
---|
323 | | CODEC_F00_09_CAP_POWER_CTRL
|
---|
324 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
325 | | CODEC_F00_09_CAP_PROC_WIDGET
|
---|
326 | | CODEC_F00_09_CAP_STEREO;
|
---|
327 | /* Connection list entries. */
|
---|
328 | pNode->adc.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 1 /* Entries */);
|
---|
329 | break;
|
---|
330 | }
|
---|
331 |
|
---|
332 | /*
|
---|
333 | * SP/DIF In/Out.
|
---|
334 | */
|
---|
335 | case STAC9220_NID_SPDIF_OUT:
|
---|
336 | {
|
---|
337 | pNode->spdifout.u32A_param = CODEC_MAKE_A(HDA_SDFMT_TYPE_PCM, HDA_SDFMT_BASE_44KHZ,
|
---|
338 | HDA_SDFMT_MULT_1X, HDA_SDFMT_DIV_2X, HDA_SDFMT_16_BIT,
|
---|
339 | HDA_SDFMT_CHAN_STEREO);
|
---|
340 | pNode->spdifout.u32F06_param = 0;
|
---|
341 | pNode->spdifout.u32F0d_param = 0;
|
---|
342 |
|
---|
343 | pNode->spdifout.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_OUTPUT, 4, 0)
|
---|
344 | | CODEC_F00_09_CAP_DIGITAL
|
---|
345 | | CODEC_F00_09_CAP_FMT_OVERRIDE
|
---|
346 | | CODEC_F00_09_CAP_STEREO;
|
---|
347 |
|
---|
348 | /* Use a fixed format from AFG. */
|
---|
349 | pNode->spdifout.node.au32F00_param[0xA] = pThis->aNodes[STAC9220_NID_AFG].node.au32F00_param[0xA];
|
---|
350 | pNode->spdifout.node.au32F00_param[0xB] = CODEC_F00_0B_PCM;
|
---|
351 | break;
|
---|
352 | }
|
---|
353 |
|
---|
354 | case STAC9220_NID_SPDIF_IN:
|
---|
355 | {
|
---|
356 | pNode->spdifin.u32A_param = CODEC_MAKE_A(HDA_SDFMT_TYPE_PCM, HDA_SDFMT_BASE_44KHZ,
|
---|
357 | HDA_SDFMT_MULT_1X, HDA_SDFMT_DIV_2X, HDA_SDFMT_16_BIT,
|
---|
358 | HDA_SDFMT_CHAN_STEREO);
|
---|
359 |
|
---|
360 | pNode->spdifin.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_INPUT, 4, 0)
|
---|
361 | | CODEC_F00_09_CAP_DIGITAL
|
---|
362 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
363 | | CODEC_F00_09_CAP_FMT_OVERRIDE
|
---|
364 | | CODEC_F00_09_CAP_STEREO;
|
---|
365 |
|
---|
366 | /* Use a fixed format from AFG. */
|
---|
367 | pNode->spdifin.node.au32F00_param[0xA] = pThis->aNodes[STAC9220_NID_AFG].node.au32F00_param[0xA];
|
---|
368 | pNode->spdifin.node.au32F00_param[0xB] = CODEC_F00_0B_PCM;
|
---|
369 |
|
---|
370 | /* Connection list entries. */
|
---|
371 | pNode->spdifin.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 1 /* Entries */);
|
---|
372 | pNode->spdifin.node.au32F02_param[0] = 0x11;
|
---|
373 | break;
|
---|
374 | }
|
---|
375 |
|
---|
376 | /*
|
---|
377 | * PINs / Ports.
|
---|
378 | */
|
---|
379 | case STAC9220_NID_PIN_HEADPHONE0: /* Port A: Headphone in/out (front). */
|
---|
380 | {
|
---|
381 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(0 /*fPresent*/, CODEC_F09_ANALOG_NA);
|
---|
382 |
|
---|
383 | pNode->port.node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
384 | | CODEC_F00_0C_CAP_INPUT
|
---|
385 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
386 | | CODEC_F00_0C_CAP_HEADPHONE_AMP
|
---|
387 | | CODEC_F00_0C_CAP_PRESENCE_DETECT
|
---|
388 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED;
|
---|
389 |
|
---|
390 | /* Connection list entry 0: Goes to DAC0. */
|
---|
391 | pNode->port.node.au32F02_param[0] = STAC9220_NID_DAC0;
|
---|
392 |
|
---|
393 | if (!pThis->fInReset)
|
---|
394 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
395 | CODEC_F1C_LOCATION_FRONT,
|
---|
396 | CODEC_F1C_DEVICE_HP,
|
---|
397 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
398 | CODEC_F1C_COLOR_GREEN,
|
---|
399 | CODEC_F1C_MISC_NONE,
|
---|
400 | CODEC_F1C_ASSOCIATION_GROUP_1, 0x0 /* Seq */);
|
---|
401 | goto port_init;
|
---|
402 | }
|
---|
403 |
|
---|
404 | case STAC9220_NID_PIN_B: /* Port B: Rear CLFE (Center / Subwoofer). */
|
---|
405 | {
|
---|
406 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(1 /*fPresent*/, CODEC_F09_ANALOG_NA);
|
---|
407 |
|
---|
408 | pNode->port.node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
409 | | CODEC_F00_0C_CAP_INPUT
|
---|
410 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
411 | | CODEC_F00_0C_CAP_PRESENCE_DETECT
|
---|
412 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED;
|
---|
413 |
|
---|
414 | /* Connection list entry 0: Goes to DAC2. */
|
---|
415 | pNode->port.node.au32F02_param[0] = STAC9220_NID_DAC2;
|
---|
416 |
|
---|
417 | if (!pThis->fInReset)
|
---|
418 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
419 | CODEC_F1C_LOCATION_REAR,
|
---|
420 | CODEC_F1C_DEVICE_SPEAKER,
|
---|
421 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
422 | CODEC_F1C_COLOR_BLACK,
|
---|
423 | CODEC_F1C_MISC_NONE,
|
---|
424 | CODEC_F1C_ASSOCIATION_GROUP_0, 0x1 /* Seq */);
|
---|
425 | goto port_init;
|
---|
426 | }
|
---|
427 |
|
---|
428 | case STAC9220_NID_PIN_C: /* Rear Speaker. */
|
---|
429 | {
|
---|
430 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(1 /*fPresent*/, CODEC_F09_ANALOG_NA);
|
---|
431 |
|
---|
432 | pNode->port.node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
433 | | CODEC_F00_0C_CAP_INPUT
|
---|
434 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
435 | | CODEC_F00_0C_CAP_PRESENCE_DETECT
|
---|
436 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED;
|
---|
437 |
|
---|
438 | /* Connection list entry 0: Goes to DAC1. */
|
---|
439 | pNode->port.node.au32F02_param[0x0] = STAC9220_NID_DAC1;
|
---|
440 |
|
---|
441 | if (!pThis->fInReset)
|
---|
442 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
443 | CODEC_F1C_LOCATION_REAR,
|
---|
444 | CODEC_F1C_DEVICE_SPEAKER,
|
---|
445 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
446 | CODEC_F1C_COLOR_GREEN,
|
---|
447 | CODEC_F1C_MISC_NONE,
|
---|
448 | CODEC_F1C_ASSOCIATION_GROUP_0, 0x0 /* Seq */);
|
---|
449 | goto port_init;
|
---|
450 | }
|
---|
451 |
|
---|
452 | case STAC9220_NID_PIN_HEADPHONE1: /* Also known as PIN_D. */
|
---|
453 | {
|
---|
454 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(1 /*fPresent*/, CODEC_F09_ANALOG_NA);
|
---|
455 |
|
---|
456 | pNode->port.node.au32F00_param[0xC] = CODEC_MAKE_F00_0C(0x17)
|
---|
457 | | CODEC_F00_0C_CAP_INPUT
|
---|
458 | | CODEC_F00_0C_CAP_OUTPUT
|
---|
459 | | CODEC_F00_0C_CAP_HEADPHONE_AMP
|
---|
460 | | CODEC_F00_0C_CAP_PRESENCE_DETECT
|
---|
461 | | CODEC_F00_0C_CAP_TRIGGER_REQUIRED;
|
---|
462 |
|
---|
463 | /* Connection list entry 0: Goes to DAC1. */
|
---|
464 | pNode->port.node.au32F02_param[0x0] = STAC9220_NID_DAC0;
|
---|
465 |
|
---|
466 | if (!pThis->fInReset)
|
---|
467 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
468 | CODEC_F1C_LOCATION_FRONT,
|
---|
469 | CODEC_F1C_DEVICE_MIC,
|
---|
470 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
471 | CODEC_F1C_COLOR_PINK,
|
---|
472 | CODEC_F1C_MISC_NONE,
|
---|
473 | CODEC_F1C_ASSOCIATION_GROUP_15, 0x0 /* Ignored */);
|
---|
474 | /* Fall through is intentional. */
|
---|
475 |
|
---|
476 | port_init:
|
---|
477 |
|
---|
478 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE
|
---|
479 | | CODEC_F07_OUT_ENABLE;
|
---|
480 | pNode->port.u32F08_param = 0;
|
---|
481 |
|
---|
482 | pNode->port.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
483 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
484 | | CODEC_F00_09_CAP_UNSOL
|
---|
485 | | CODEC_F00_09_CAP_STEREO;
|
---|
486 | /* Connection list entries. */
|
---|
487 | pNode->port.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 1 /* Entries */);
|
---|
488 | break;
|
---|
489 | }
|
---|
490 |
|
---|
491 | case STAC9220_NID_PIN_E:
|
---|
492 | {
|
---|
493 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE;
|
---|
494 | pNode->port.u32F08_param = 0;
|
---|
495 | /* If Line in is reported as enabled, OS X sees no speakers! Windows does
|
---|
496 | * not care either way, although Linux does.
|
---|
497 | */
|
---|
498 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(0 /* fPresent */, 0);
|
---|
499 |
|
---|
500 | pNode->port.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
501 | | CODEC_F00_09_CAP_UNSOL
|
---|
502 | | CODEC_F00_09_CAP_STEREO;
|
---|
503 |
|
---|
504 | pNode->port.node.au32F00_param[0xC] = CODEC_F00_0C_CAP_INPUT
|
---|
505 | | CODEC_F00_0C_CAP_PRESENCE_DETECT;
|
---|
506 |
|
---|
507 | if (!pThis->fInReset)
|
---|
508 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
509 | CODEC_F1C_LOCATION_REAR,
|
---|
510 | CODEC_F1C_DEVICE_LINE_IN,
|
---|
511 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
512 | CODEC_F1C_COLOR_BLUE,
|
---|
513 | CODEC_F1C_MISC_NONE,
|
---|
514 | CODEC_F1C_ASSOCIATION_GROUP_4, 0x1 /* Seq */);
|
---|
515 | break;
|
---|
516 | }
|
---|
517 |
|
---|
518 | case STAC9220_NID_PIN_F:
|
---|
519 | {
|
---|
520 | pNode->port.u32F07_param = CODEC_F07_IN_ENABLE | CODEC_F07_OUT_ENABLE;
|
---|
521 | pNode->port.u32F08_param = 0;
|
---|
522 | pNode->port.u32F09_param = CODEC_MAKE_F09_ANALOG(1 /* fPresent */, CODEC_F09_ANALOG_NA);
|
---|
523 |
|
---|
524 | pNode->port.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
525 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
526 | | CODEC_F00_09_CAP_UNSOL
|
---|
527 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT
|
---|
528 | | CODEC_F00_09_CAP_STEREO;
|
---|
529 |
|
---|
530 | pNode->port.node.au32F00_param[0xC] = CODEC_F00_0C_CAP_INPUT
|
---|
531 | | CODEC_F00_0C_CAP_OUTPUT;
|
---|
532 |
|
---|
533 | /* Connection list entry 0: Goes to DAC3. */
|
---|
534 | pNode->port.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 1 /* Entries */);
|
---|
535 | pNode->port.node.au32F02_param[0x0] = STAC9220_NID_DAC3;
|
---|
536 |
|
---|
537 | if (!pThis->fInReset)
|
---|
538 | pNode->port.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
539 | CODEC_F1C_LOCATION_INTERNAL,
|
---|
540 | CODEC_F1C_DEVICE_SPEAKER,
|
---|
541 | CODEC_F1C_CONNECTION_TYPE_1_8INCHES,
|
---|
542 | CODEC_F1C_COLOR_ORANGE,
|
---|
543 | CODEC_F1C_MISC_NONE,
|
---|
544 | CODEC_F1C_ASSOCIATION_GROUP_0, 0x2 /* Seq */);
|
---|
545 | break;
|
---|
546 | }
|
---|
547 |
|
---|
548 | case STAC9220_NID_PIN_SPDIF_OUT: /* Rear SPDIF Out. */
|
---|
549 | {
|
---|
550 | pNode->digout.u32F07_param = CODEC_F07_OUT_ENABLE;
|
---|
551 | pNode->digout.u32F09_param = 0;
|
---|
552 |
|
---|
553 | pNode->digout.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
554 | | CODEC_F00_09_CAP_DIGITAL
|
---|
555 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
556 | | CODEC_F00_09_CAP_STEREO;
|
---|
557 | pNode->digout.node.au32F00_param[0xC] = CODEC_F00_0C_CAP_OUTPUT;
|
---|
558 |
|
---|
559 | /* Connection list entries. */
|
---|
560 | pNode->digout.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 3 /* Entries */);
|
---|
561 | pNode->digout.node.au32F02_param[0x0] = RT_MAKE_U32_FROM_U8(STAC9220_NID_SPDIF_OUT,
|
---|
562 | STAC9220_NID_AMP_ADC0, STAC9221_NID_ADAT_OUT, 0);
|
---|
563 | if (!pThis->fInReset)
|
---|
564 | pNode->digout.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
565 | CODEC_F1C_LOCATION_REAR,
|
---|
566 | CODEC_F1C_DEVICE_SPDIF_OUT,
|
---|
567 | CODEC_F1C_CONNECTION_TYPE_DIN,
|
---|
568 | CODEC_F1C_COLOR_BLACK,
|
---|
569 | CODEC_F1C_MISC_NONE,
|
---|
570 | CODEC_F1C_ASSOCIATION_GROUP_2, 0x0 /* Seq */);
|
---|
571 | break;
|
---|
572 | }
|
---|
573 |
|
---|
574 | case STAC9220_NID_PIN_SPDIF_IN:
|
---|
575 | {
|
---|
576 | pNode->digin.u32F05_param = CODEC_MAKE_F05(0, 0, 0, CODEC_F05_D3, CODEC_F05_D3); /* PS-Act: D3 -> D3 */
|
---|
577 | pNode->digin.u32F07_param = CODEC_F07_IN_ENABLE;
|
---|
578 | pNode->digin.u32F08_param = 0;
|
---|
579 | pNode->digin.u32F09_param = CODEC_MAKE_F09_DIGITAL(0, 0);
|
---|
580 | pNode->digin.u32F0c_param = 0;
|
---|
581 |
|
---|
582 | pNode->digin.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 3, 0)
|
---|
583 | | CODEC_F00_09_CAP_POWER_CTRL
|
---|
584 | | CODEC_F00_09_CAP_DIGITAL
|
---|
585 | | CODEC_F00_09_CAP_UNSOL
|
---|
586 | | CODEC_F00_09_CAP_STEREO;
|
---|
587 |
|
---|
588 | pNode->digin.node.au32F00_param[0xC] = CODEC_F00_0C_CAP_EAPD
|
---|
589 | | CODEC_F00_0C_CAP_INPUT
|
---|
590 | | CODEC_F00_0C_CAP_PRESENCE_DETECT;
|
---|
591 | if (!pThis->fInReset)
|
---|
592 | pNode->digin.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_COMPLEX,
|
---|
593 | CODEC_F1C_LOCATION_REAR,
|
---|
594 | CODEC_F1C_DEVICE_SPDIF_IN,
|
---|
595 | CODEC_F1C_CONNECTION_TYPE_OTHER_DIGITAL,
|
---|
596 | CODEC_F1C_COLOR_BLACK,
|
---|
597 | CODEC_F1C_MISC_NONE,
|
---|
598 | CODEC_F1C_ASSOCIATION_GROUP_5, 0x0 /* Seq */);
|
---|
599 | break;
|
---|
600 | }
|
---|
601 |
|
---|
602 | case STAC9220_NID_ADC0_MUX:
|
---|
603 | {
|
---|
604 | pNode->adcmux.u32F01_param = 0; /* Connection select control index (STAC9220_NID_PIN_E). */
|
---|
605 | goto adcmux_init;
|
---|
606 | }
|
---|
607 |
|
---|
608 | case STAC9220_NID_ADC1_MUX:
|
---|
609 | {
|
---|
610 | pNode->adcmux.u32F01_param = 1; /* Connection select control index (STAC9220_NID_PIN_CD). */
|
---|
611 | /* Fall through is intentional. */
|
---|
612 |
|
---|
613 | adcmux_init:
|
---|
614 |
|
---|
615 | pNode->adcmux.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_SELECTOR, 0, 0)
|
---|
616 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
617 | | CODEC_F00_09_CAP_AMP_FMT_OVERRIDE
|
---|
618 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT
|
---|
619 | | CODEC_F00_09_CAP_STEREO;
|
---|
620 |
|
---|
621 | pNode->adcmux.node.au32F00_param[0xD] = CODEC_MAKE_F00_0D(0, 27, 4, 0);
|
---|
622 |
|
---|
623 | /* Connection list entries. */
|
---|
624 | pNode->adcmux.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 7 /* Entries */);
|
---|
625 | pNode->adcmux.node.au32F02_param[0x0] = RT_MAKE_U32_FROM_U8(STAC9220_NID_PIN_E,
|
---|
626 | STAC9220_NID_PIN_CD,
|
---|
627 | STAC9220_NID_PIN_F,
|
---|
628 | STAC9220_NID_PIN_B);
|
---|
629 | pNode->adcmux.node.au32F02_param[0x4] = RT_MAKE_U32_FROM_U8(STAC9220_NID_PIN_C,
|
---|
630 | STAC9220_NID_PIN_HEADPHONE1,
|
---|
631 | STAC9220_NID_PIN_HEADPHONE0,
|
---|
632 | 0x0 /* Unused */);
|
---|
633 |
|
---|
634 | /* STAC 9220 v10 6.21-22.{4,5} both(left and right) out amplifiers initialized with 0. */
|
---|
635 | RT_ZERO(pNode->adcmux.B_params);
|
---|
636 | break;
|
---|
637 | }
|
---|
638 |
|
---|
639 | case STAC9220_NID_PCBEEP:
|
---|
640 | {
|
---|
641 | pNode->pcbeep.u32F0a_param = 0;
|
---|
642 |
|
---|
643 | pNode->pcbeep.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_BEEP_GEN, 0, 0)
|
---|
644 | | CODEC_F00_09_CAP_AMP_FMT_OVERRIDE
|
---|
645 | | CODEC_F00_09_CAP_OUT_AMP_PRESENT;
|
---|
646 | pNode->pcbeep.node.au32F00_param[0xD] = CODEC_MAKE_F00_0D(0, 17, 3, 3);
|
---|
647 |
|
---|
648 | RT_ZERO(pNode->pcbeep.B_params);
|
---|
649 | break;
|
---|
650 | }
|
---|
651 |
|
---|
652 | case STAC9220_NID_PIN_CD:
|
---|
653 | {
|
---|
654 | pNode->cdnode.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
655 | | CODEC_F00_09_CAP_STEREO;
|
---|
656 | pNode->cdnode.node.au32F00_param[0xC] = CODEC_F00_0C_CAP_INPUT;
|
---|
657 |
|
---|
658 | if (!pThis->fInReset)
|
---|
659 | pNode->cdnode.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_FIXED,
|
---|
660 | CODEC_F1C_LOCATION_INTERNAL,
|
---|
661 | CODEC_F1C_DEVICE_CD,
|
---|
662 | CODEC_F1C_CONNECTION_TYPE_ATAPI,
|
---|
663 | CODEC_F1C_COLOR_UNKNOWN,
|
---|
664 | CODEC_F1C_MISC_NONE,
|
---|
665 | CODEC_F1C_ASSOCIATION_GROUP_4, 0x2 /* Seq */);
|
---|
666 | break;
|
---|
667 | }
|
---|
668 |
|
---|
669 | case STAC9220_NID_VOL_KNOB:
|
---|
670 | {
|
---|
671 | pNode->volumeKnob.u32F08_param = 0;
|
---|
672 | pNode->volumeKnob.u32F0f_param = 0x7f;
|
---|
673 |
|
---|
674 | pNode->volumeKnob.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_VOLUME_KNOB, 0, 0);
|
---|
675 | pNode->volumeKnob.node.au32F00_param[0xD] = RT_BIT(7) | 0x7F;
|
---|
676 |
|
---|
677 | /* Connection list entries. */
|
---|
678 | pNode->volumeKnob.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 4 /* Entries */);
|
---|
679 | pNode->volumeKnob.node.au32F02_param[0x0] = RT_MAKE_U32_FROM_U8(STAC9220_NID_DAC0,
|
---|
680 | STAC9220_NID_DAC1,
|
---|
681 | STAC9220_NID_DAC2,
|
---|
682 | STAC9220_NID_DAC3);
|
---|
683 | break;
|
---|
684 | }
|
---|
685 |
|
---|
686 | case STAC9220_NID_AMP_ADC0: /* ADC0Vol */
|
---|
687 | {
|
---|
688 | pNode->adcvol.node.au32F02_param[0] = STAC9220_NID_ADC0_MUX;
|
---|
689 | goto adcvol_init;
|
---|
690 | }
|
---|
691 |
|
---|
692 | case STAC9220_NID_AMP_ADC1: /* ADC1Vol */
|
---|
693 | {
|
---|
694 | pNode->adcvol.node.au32F02_param[0] = STAC9220_NID_ADC1_MUX;
|
---|
695 | /* Fall through is intentional. */
|
---|
696 |
|
---|
697 | adcvol_init:
|
---|
698 |
|
---|
699 | pNode->adcvol.node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_SELECTOR, 0, 0)
|
---|
700 | | CODEC_F00_09_CAP_L_R_SWAP
|
---|
701 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
702 | | CODEC_F00_09_CAP_IN_AMP_PRESENT
|
---|
703 | | CODEC_F00_09_CAP_STEREO;
|
---|
704 |
|
---|
705 |
|
---|
706 | pNode->adcvol.node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 1 /* Entries */);
|
---|
707 |
|
---|
708 | RT_ZERO(pNode->adcvol.B_params);
|
---|
709 | AMPLIFIER_REGISTER(pNode->adcvol.B_params, AMPLIFIER_IN, AMPLIFIER_LEFT, 0) = RT_BIT(7);
|
---|
710 | AMPLIFIER_REGISTER(pNode->adcvol.B_params, AMPLIFIER_IN, AMPLIFIER_RIGHT, 0) = RT_BIT(7);
|
---|
711 | break;
|
---|
712 | }
|
---|
713 |
|
---|
714 | /*
|
---|
715 | * STAC9221 nodes.
|
---|
716 | */
|
---|
717 |
|
---|
718 | case STAC9221_NID_ADAT_OUT:
|
---|
719 | {
|
---|
720 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_VENDOR_DEFINED, 3, 0)
|
---|
721 | | CODEC_F00_09_CAP_DIGITAL
|
---|
722 | | CODEC_F00_09_CAP_STEREO;
|
---|
723 | break;
|
---|
724 | }
|
---|
725 |
|
---|
726 | case STAC9221_NID_I2S_OUT:
|
---|
727 | {
|
---|
728 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_AUDIO_OUTPUT, 3, 0)
|
---|
729 | | CODEC_F00_09_CAP_DIGITAL
|
---|
730 | | CODEC_F00_09_CAP_STEREO;
|
---|
731 | break;
|
---|
732 | }
|
---|
733 |
|
---|
734 | case STAC9221_NID_PIN_I2S_OUT:
|
---|
735 | {
|
---|
736 | pNode->node.au32F00_param[0x9] = CODEC_MAKE_F00_09(CODEC_F00_09_TYPE_PIN_COMPLEX, 0, 0)
|
---|
737 | | CODEC_F00_09_CAP_DIGITAL
|
---|
738 | | CODEC_F00_09_CAP_CONNECTION_LIST
|
---|
739 | | CODEC_F00_09_CAP_STEREO;
|
---|
740 |
|
---|
741 | pNode->node.au32F00_param[0xC] = CODEC_F00_0C_CAP_OUTPUT;
|
---|
742 |
|
---|
743 | /* Connection list entries. */
|
---|
744 | pNode->node.au32F00_param[0xE] = CODEC_MAKE_F00_0E(CODEC_F00_0E_LIST_NID_SHORT, 1 /* Entries */);
|
---|
745 | pNode->node.au32F02_param[0] = STAC9221_NID_I2S_OUT;
|
---|
746 |
|
---|
747 | if (!pThis->fInReset)
|
---|
748 | pNode->reserved.u32F1c_param = CODEC_MAKE_F1C(CODEC_F1C_PORT_NO_PHYS,
|
---|
749 | CODEC_F1C_LOCATION_NA,
|
---|
750 | CODEC_F1C_DEVICE_LINE_OUT,
|
---|
751 | CODEC_F1C_CONNECTION_TYPE_UNKNOWN,
|
---|
752 | CODEC_F1C_COLOR_UNKNOWN,
|
---|
753 | CODEC_F1C_MISC_NONE,
|
---|
754 | CODEC_F1C_ASSOCIATION_GROUP_15, 0x0 /* Ignored */);
|
---|
755 | break;
|
---|
756 | }
|
---|
757 |
|
---|
758 | default:
|
---|
759 | AssertMsgFailed(("Node %RU8 not implemented\n", uNID));
|
---|
760 | break;
|
---|
761 | }
|
---|
762 | }
|
---|
763 |
|
---|
764 |
|
---|
765 | /**
|
---|
766 | * Resets the codec with all its connected nodes.
|
---|
767 | *
|
---|
768 | * @param pThis HDA codec to reset.
|
---|
769 | */
|
---|
770 | static void stac9220Reset(PHDACODECR3 pThis)
|
---|
771 | {
|
---|
772 | AssertPtrReturnVoid(pThis->aNodes);
|
---|
773 |
|
---|
774 | LogRel(("HDA: Codec reset\n"));
|
---|
775 |
|
---|
776 | pThis->fInReset = true;
|
---|
777 |
|
---|
778 | uint8_t const cTotalNodes = (uint8_t)RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
779 | for (uint8_t i = 0; i < cTotalNodes; i++)
|
---|
780 | stac9220NodeReset(pThis, i, &pThis->aNodes[i]);
|
---|
781 |
|
---|
782 | pThis->fInReset = false;
|
---|
783 | }
|
---|
784 |
|
---|
785 |
|
---|
786 | static int stac9220Construct(PHDACODECR3 pThis)
|
---|
787 | {
|
---|
788 | pThis->idVendor = 0x8384; /* SigmaTel */
|
---|
789 | /*
|
---|
790 | * Note: The Linux kernel uses "patch_stac922x" for the fixups,
|
---|
791 | * which in turn uses "ref922x_pin_configs" for the configuration
|
---|
792 | * defaults tweaking in sound/pci/hda/patch_sigmatel.c.
|
---|
793 | */
|
---|
794 | pThis->idDevice = 0x7680; /* STAC9221 A1 */
|
---|
795 | pThis->bBSKU = 0x76;
|
---|
796 | pThis->idAssembly = 0x80;
|
---|
797 |
|
---|
798 | pThis->fInReset = false;
|
---|
799 |
|
---|
800 | #define STAC9220WIDGET(a_Type) do { \
|
---|
801 | AssertCompile(RT_ELEMENTS(g_abStac9220##a_Type##s) <= RT_ELEMENTS(pThis->ab##a_Type##s)); \
|
---|
802 | memcpy((void *)&pThis->ab##a_Type##s[0], &g_abStac9220##a_Type##s[0], \
|
---|
803 | sizeof(uint8_t) * RT_ELEMENTS(g_abStac9220##a_Type##s)); \
|
---|
804 | } while (0)
|
---|
805 | STAC9220WIDGET(Port);
|
---|
806 | STAC9220WIDGET(Dac);
|
---|
807 | STAC9220WIDGET(Adc);
|
---|
808 | STAC9220WIDGET(AdcVol);
|
---|
809 | STAC9220WIDGET(AdcMux);
|
---|
810 | STAC9220WIDGET(Pcbeep);
|
---|
811 | STAC9220WIDGET(SpdifIn);
|
---|
812 | STAC9220WIDGET(SpdifOut);
|
---|
813 | STAC9220WIDGET(DigInPin);
|
---|
814 | STAC9220WIDGET(DigOutPin);
|
---|
815 | STAC9220WIDGET(Cd);
|
---|
816 | STAC9220WIDGET(VolKnob);
|
---|
817 | STAC9220WIDGET(Reserved);
|
---|
818 | #undef STAC9220WIDGET
|
---|
819 |
|
---|
820 | AssertCompile(STAC9221_NUM_NODES <= RT_ELEMENTS(pThis->aNodes));
|
---|
821 | pThis->cTotalNodes = STAC9221_NUM_NODES;
|
---|
822 |
|
---|
823 | pThis->u8AdcVolsLineIn = STAC9220_NID_AMP_ADC0;
|
---|
824 | pThis->u8DacLineOut = STAC9220_NID_DAC1;
|
---|
825 |
|
---|
826 | /*
|
---|
827 | * Initialize all codec nodes.
|
---|
828 | * This is specific to the codec, so do this here.
|
---|
829 | *
|
---|
830 | * Note: Do *not* call stac9220Reset() here, as this would not
|
---|
831 | * initialize the node default configuration values then!
|
---|
832 | */
|
---|
833 | for (uint8_t i = 0; i < STAC9221_NUM_NODES; i++)
|
---|
834 | stac9220NodeReset(pThis, i, &pThis->aNodes[i]);
|
---|
835 |
|
---|
836 | /* Common root node initializers. */
|
---|
837 | pThis->aNodes[STAC9220_NID_ROOT].root.node.au32F00_param[0] = CODEC_MAKE_F00_00(pThis->idVendor, pThis->idDevice);
|
---|
838 | pThis->aNodes[STAC9220_NID_ROOT].root.node.au32F00_param[4] = CODEC_MAKE_F00_04(0x1, 0x1);
|
---|
839 |
|
---|
840 | /* Common AFG node initializers. */
|
---|
841 | pThis->aNodes[STAC9220_NID_AFG].afg.node.au32F00_param[0x4] = CODEC_MAKE_F00_04(0x2, STAC9221_NUM_NODES - 2);
|
---|
842 | pThis->aNodes[STAC9220_NID_AFG].afg.node.au32F00_param[0x5] = CODEC_MAKE_F00_05(1, CODEC_F00_05_AFG);
|
---|
843 | pThis->aNodes[STAC9220_NID_AFG].afg.node.au32F00_param[0xA] = CODEC_F00_0A_44_1KHZ | CODEC_F00_0A_16_BIT;
|
---|
844 | pThis->aNodes[STAC9220_NID_AFG].afg.u32F20_param = CODEC_MAKE_F20(pThis->idVendor, pThis->bBSKU, pThis->idAssembly);
|
---|
845 |
|
---|
846 | return VINF_SUCCESS;
|
---|
847 | }
|
---|
848 |
|
---|
849 |
|
---|
850 | /*********************************************************************************************************************************
|
---|
851 | * Common Helpers *
|
---|
852 | *********************************************************************************************************************************/
|
---|
853 |
|
---|
854 | /*
|
---|
855 | * Some generic predicate functions.
|
---|
856 | */
|
---|
857 | /** @todo r=bird: we could use memchr here if we knew the array always ended with zeros
|
---|
858 | * What would be even quicker would be an array of 16-bit flag masks for each node,
|
---|
859 | * compiled by STAC9220WIDGET at construction time. */
|
---|
860 | #define HDA_CODEC_IS_NODE_OF_TYPE_FUNC(a_Type) \
|
---|
861 | DECLINLINE(bool) hdaCodecIs##a_Type##Node(PHDACODECR3 pThis, uint8_t idNode) \
|
---|
862 | { \
|
---|
863 | Assert(pThis->ab##a_Type##s); \
|
---|
864 | for (uintptr_t i = 0; i < RT_ELEMENTS(pThis->ab##a_Type##s) && pThis->ab##a_Type##s[i] != 0; i++) \
|
---|
865 | if (pThis->ab##a_Type##s[i] == idNode) \
|
---|
866 | return true; \
|
---|
867 | return false; \
|
---|
868 | }
|
---|
869 | /* hdaCodecIsPortNode */
|
---|
870 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Port)
|
---|
871 | /* hdaCodecIsDacNode */
|
---|
872 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Dac)
|
---|
873 | /* hdaCodecIsAdcVolNode */
|
---|
874 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(AdcVol)
|
---|
875 | /* hdaCodecIsAdcNode */
|
---|
876 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Adc)
|
---|
877 | /* hdaCodecIsAdcMuxNode */
|
---|
878 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(AdcMux)
|
---|
879 | /* hdaCodecIsPcbeepNode */
|
---|
880 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Pcbeep)
|
---|
881 | /* hdaCodecIsSpdifOutNode */
|
---|
882 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(SpdifOut)
|
---|
883 | /* hdaCodecIsSpdifInNode */
|
---|
884 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(SpdifIn)
|
---|
885 | /* hdaCodecIsDigInPinNode */
|
---|
886 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(DigInPin)
|
---|
887 | /* hdaCodecIsDigOutPinNode */
|
---|
888 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(DigOutPin)
|
---|
889 | /* hdaCodecIsCdNode */
|
---|
890 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Cd)
|
---|
891 | /* hdaCodecIsVolKnobNode */
|
---|
892 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(VolKnob)
|
---|
893 | /* hdaCodecIsReservedNode */
|
---|
894 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Reserved)
|
---|
895 |
|
---|
896 |
|
---|
897 | /*
|
---|
898 | * Misc helpers.
|
---|
899 | */
|
---|
900 | static int hdaR3CodecToAudVolume(PHDACODECR3 pThis, PCODECNODE pNode, AMPLIFIER *pAmp, PDMAUDIOMIXERCTL enmMixerCtl)
|
---|
901 | {
|
---|
902 | RT_NOREF(pNode);
|
---|
903 |
|
---|
904 | uint8_t iDir;
|
---|
905 | switch (enmMixerCtl)
|
---|
906 | {
|
---|
907 | case PDMAUDIOMIXERCTL_VOLUME_MASTER:
|
---|
908 | case PDMAUDIOMIXERCTL_FRONT:
|
---|
909 | iDir = AMPLIFIER_OUT;
|
---|
910 | break;
|
---|
911 | case PDMAUDIOMIXERCTL_LINE_IN:
|
---|
912 | case PDMAUDIOMIXERCTL_MIC_IN:
|
---|
913 | iDir = AMPLIFIER_IN;
|
---|
914 | break;
|
---|
915 | default:
|
---|
916 | AssertMsgFailedReturn(("Invalid mixer control %RU32\n", enmMixerCtl), VERR_INVALID_PARAMETER);
|
---|
917 | break;
|
---|
918 | }
|
---|
919 |
|
---|
920 | int iMute;
|
---|
921 | iMute = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_LEFT, 0) & RT_BIT(7);
|
---|
922 | iMute |= AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_RIGHT, 0) & RT_BIT(7);
|
---|
923 | iMute >>=7;
|
---|
924 | iMute &= 0x1;
|
---|
925 |
|
---|
926 | uint8_t bLeft = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_LEFT, 0) & 0x7f;
|
---|
927 | uint8_t bRight = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_RIGHT, 0) & 0x7f;
|
---|
928 |
|
---|
929 | /*
|
---|
930 | * The STAC9220 volume controls have 0 to -96dB attenuation range in 128 steps.
|
---|
931 | * We have 0 to -96dB range in 256 steps. HDA volume setting of 127 must map
|
---|
932 | * to 255 internally (0dB), while HDA volume setting of 0 (-96dB) should map
|
---|
933 | * to 1 (rather than zero) internally.
|
---|
934 | */
|
---|
935 | bLeft = (bLeft + 1) * (2 * 255) / 256;
|
---|
936 | bRight = (bRight + 1) * (2 * 255) / 256;
|
---|
937 |
|
---|
938 | PDMAUDIOVOLUME Vol;
|
---|
939 | PDMAudioVolumeInitFromStereo(&Vol, RT_BOOL(iMute), bLeft, bRight);
|
---|
940 |
|
---|
941 | LogFunc(("[NID0x%02x] %RU8/%RU8%s\n", pNode->node.uID, bLeft, bRight, Vol.fMuted ? "- Muted!" : ""));
|
---|
942 | LogRel2(("HDA: Setting volume for mixer control '%s' to %RU8/%RU8%s\n",
|
---|
943 | PDMAudioMixerCtlGetName(enmMixerCtl), bLeft, bRight, Vol.fMuted ? "- Muted!" : ""));
|
---|
944 |
|
---|
945 | return hdaR3MixerSetVolume(pThis, enmMixerCtl, &Vol);
|
---|
946 | }
|
---|
947 |
|
---|
948 |
|
---|
949 | DECLINLINE(void) hdaCodecSetRegister(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset, uint32_t mask)
|
---|
950 | {
|
---|
951 | Assert((pu32Reg && u8Offset < 32));
|
---|
952 | *pu32Reg &= ~(mask << u8Offset);
|
---|
953 | *pu32Reg |= (u32Cmd & mask) << u8Offset;
|
---|
954 | }
|
---|
955 |
|
---|
956 | DECLINLINE(void) hdaCodecSetRegisterU8(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset)
|
---|
957 | {
|
---|
958 | hdaCodecSetRegister(pu32Reg, u32Cmd, u8Offset, CODEC_VERB_8BIT_DATA);
|
---|
959 | }
|
---|
960 |
|
---|
961 | DECLINLINE(void) hdaCodecSetRegisterU16(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset)
|
---|
962 | {
|
---|
963 | hdaCodecSetRegister(pu32Reg, u32Cmd, u8Offset, CODEC_VERB_16BIT_DATA);
|
---|
964 | }
|
---|
965 |
|
---|
966 |
|
---|
967 | /*********************************************************************************************************************************
|
---|
968 | * Verb Processor Functions. *
|
---|
969 | *********************************************************************************************************************************/
|
---|
970 | #if 0 /* unused */
|
---|
971 |
|
---|
972 | /**
|
---|
973 | * @interface_method_impl{CODECVERB,pfn, Unimplemented}
|
---|
974 | */
|
---|
975 | static DECLCALLBACK(int) vrbProcUnimplemented(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
976 | {
|
---|
977 | RT_NOREF(pThis, uCmd);
|
---|
978 | LogFlowFunc(("uCmd(raw:%x: cad:%x, d:%c, nid:%x, verb:%x)\n", uCmd,
|
---|
979 | CODEC_CAD(uCmd), CODEC_DIRECT(uCmd) ? 'N' : 'Y', CODEC_NID(uCmd), CODEC_VERBDATA(uCmd)));
|
---|
980 | *puResp = 0;
|
---|
981 | return VINF_SUCCESS;
|
---|
982 | }
|
---|
983 |
|
---|
984 |
|
---|
985 | /**
|
---|
986 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
987 | */
|
---|
988 | static DECLCALLBACK(int) vrbProcBreak(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
989 | {
|
---|
990 | int rc;
|
---|
991 | rc = vrbProcUnimplemented(pThis, uCmd, puResp);
|
---|
992 | *puResp |= CODEC_RESPONSE_UNSOLICITED;
|
---|
993 | return rc;
|
---|
994 | }
|
---|
995 |
|
---|
996 | #endif /* unused */
|
---|
997 |
|
---|
998 | /**
|
---|
999 | * @interface_method_impl{CODECVERB,pfn, b-- }
|
---|
1000 | */
|
---|
1001 | static DECLCALLBACK(int) vrbProcGetAmplifier(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1002 | {
|
---|
1003 | *puResp = 0;
|
---|
1004 |
|
---|
1005 | /* HDA spec 7.3.3.7 Note A */
|
---|
1006 | /** @todo If index out of range response should be 0. */
|
---|
1007 | uint8_t u8Index = CODEC_GET_AMP_DIRECTION(uCmd) == AMPLIFIER_OUT ? 0 : CODEC_GET_AMP_INDEX(uCmd);
|
---|
1008 |
|
---|
1009 | PCODECNODE pNode = &pThis->aNodes[CODEC_NID(uCmd)];
|
---|
1010 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1011 | *puResp = AMPLIFIER_REGISTER(pNode->dac.B_params,
|
---|
1012 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1013 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1014 | u8Index);
|
---|
1015 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1016 | *puResp = AMPLIFIER_REGISTER(pNode->adcvol.B_params,
|
---|
1017 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1018 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1019 | u8Index);
|
---|
1020 | else if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
1021 | *puResp = AMPLIFIER_REGISTER(pNode->adcmux.B_params,
|
---|
1022 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1023 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1024 | u8Index);
|
---|
1025 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1026 | *puResp = AMPLIFIER_REGISTER(pNode->pcbeep.B_params,
|
---|
1027 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1028 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1029 | u8Index);
|
---|
1030 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1031 | *puResp = AMPLIFIER_REGISTER(pNode->port.B_params,
|
---|
1032 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1033 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1034 | u8Index);
|
---|
1035 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1036 | *puResp = AMPLIFIER_REGISTER(pNode->adc.B_params,
|
---|
1037 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1038 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1039 | u8Index);
|
---|
1040 | else
|
---|
1041 | LogRel2(("HDA: Warning: Unhandled get amplifier command: 0x%x (NID=0x%x [%RU8])\n", uCmd, CODEC_NID(uCmd), CODEC_NID(uCmd)));
|
---|
1042 |
|
---|
1043 | return VINF_SUCCESS;
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 |
|
---|
1047 | /**
|
---|
1048 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
1049 | */
|
---|
1050 | static DECLCALLBACK(int) vrbProcGetParameter(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1051 | {
|
---|
1052 | Assert((uCmd & CODEC_VERB_8BIT_DATA) < CODECNODE_F00_PARAM_LENGTH);
|
---|
1053 | if ((uCmd & CODEC_VERB_8BIT_DATA) >= CODECNODE_F00_PARAM_LENGTH)
|
---|
1054 | {
|
---|
1055 | *puResp = 0;
|
---|
1056 |
|
---|
1057 | LogFlowFunc(("invalid F00 parameter %d\n", (uCmd & CODEC_VERB_8BIT_DATA)));
|
---|
1058 | return VINF_SUCCESS;
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].node.au32F00_param[uCmd & CODEC_VERB_8BIT_DATA];
|
---|
1062 | return VINF_SUCCESS;
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 |
|
---|
1066 | /**
|
---|
1067 | * @interface_method_impl{CODECVERB,pfn, f01 }
|
---|
1068 | */
|
---|
1069 | static DECLCALLBACK(int) vrbProcGetConSelectCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1070 | {
|
---|
1071 | *puResp = 0;
|
---|
1072 |
|
---|
1073 | if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
1074 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adcmux.u32F01_param;
|
---|
1075 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1076 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F01_param;
|
---|
1077 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1078 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F01_param;
|
---|
1079 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1080 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F01_param;
|
---|
1081 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1082 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F01_param;
|
---|
1083 | else
|
---|
1084 | LogRel2(("HDA: Warning: Unhandled get connection select control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1085 |
|
---|
1086 | return VINF_SUCCESS;
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 |
|
---|
1090 | /**
|
---|
1091 | * @interface_method_impl{CODECVERB,pfn, 701 }
|
---|
1092 | */
|
---|
1093 | static DECLCALLBACK(int) vrbProcSetConSelectCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1094 | {
|
---|
1095 | *puResp = 0;
|
---|
1096 |
|
---|
1097 | uint32_t *pu32Reg = NULL;
|
---|
1098 | if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
1099 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adcmux.u32F01_param;
|
---|
1100 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1101 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F01_param;
|
---|
1102 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1103 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F01_param;
|
---|
1104 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1105 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F01_param;
|
---|
1106 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1107 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F01_param;
|
---|
1108 | else
|
---|
1109 | LogRel2(("HDA: Warning: Unhandled set connection select control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1110 |
|
---|
1111 | if (pu32Reg)
|
---|
1112 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1113 |
|
---|
1114 | return VINF_SUCCESS;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 |
|
---|
1118 | /**
|
---|
1119 | * @interface_method_impl{CODECVERB,pfn, f07 }
|
---|
1120 | */
|
---|
1121 | static DECLCALLBACK(int) vrbProcGetPinCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1122 | {
|
---|
1123 | *puResp = 0;
|
---|
1124 |
|
---|
1125 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1126 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F07_param;
|
---|
1127 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1128 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F07_param;
|
---|
1129 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1130 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F07_param;
|
---|
1131 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1132 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F07_param;
|
---|
1133 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1134 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F07_param;
|
---|
1135 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1136 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F07_param;
|
---|
1137 | else
|
---|
1138 | LogRel2(("HDA: Warning: Unhandled get pin control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1139 |
|
---|
1140 | return VINF_SUCCESS;
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 |
|
---|
1144 | /**
|
---|
1145 | * @interface_method_impl{CODECVERB,pfn, 707 }
|
---|
1146 | */
|
---|
1147 | static DECLCALLBACK(int) vrbProcSetPinCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1148 | {
|
---|
1149 | *puResp = 0;
|
---|
1150 |
|
---|
1151 | uint32_t *pu32Reg = NULL;
|
---|
1152 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1153 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F07_param;
|
---|
1154 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1155 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F07_param;
|
---|
1156 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1157 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F07_param;
|
---|
1158 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1159 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F07_param;
|
---|
1160 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1161 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F07_param;
|
---|
1162 | else if ( hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd))
|
---|
1163 | && CODEC_NID(uCmd) == 0x1b)
|
---|
1164 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F07_param;
|
---|
1165 | else
|
---|
1166 | LogRel2(("HDA: Warning: Unhandled set pin control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1167 |
|
---|
1168 | if (pu32Reg)
|
---|
1169 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1170 |
|
---|
1171 | return VINF_SUCCESS;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 |
|
---|
1175 | /**
|
---|
1176 | * @interface_method_impl{CODECVERB,pfn, f08 }
|
---|
1177 | */
|
---|
1178 | static DECLCALLBACK(int) vrbProcGetUnsolicitedEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1179 | {
|
---|
1180 | *puResp = 0;
|
---|
1181 |
|
---|
1182 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1183 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F08_param;
|
---|
1184 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1185 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1186 | else if ((uCmd) == STAC9220_NID_AFG)
|
---|
1187 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].afg.u32F08_param;
|
---|
1188 | else if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1189 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F08_param;
|
---|
1190 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1191 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F08_param;
|
---|
1192 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1193 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1194 | else
|
---|
1195 | LogRel2(("HDA: Warning: Unhandled get unsolicited enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1196 |
|
---|
1197 | return VINF_SUCCESS;
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 |
|
---|
1201 | /**
|
---|
1202 | * @interface_method_impl{CODECVERB,pfn, 708 }
|
---|
1203 | */
|
---|
1204 | static DECLCALLBACK(int) vrbProcSetUnsolicitedEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1205 | {
|
---|
1206 | *puResp = 0;
|
---|
1207 |
|
---|
1208 | uint32_t *pu32Reg = NULL;
|
---|
1209 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1210 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F08_param;
|
---|
1211 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1212 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1213 | else if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1214 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F08_param;
|
---|
1215 | else if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1216 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F08_param;
|
---|
1217 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1218 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1219 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1220 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F08_param;
|
---|
1221 | else
|
---|
1222 | LogRel2(("HDA: Warning: Unhandled set unsolicited enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1223 |
|
---|
1224 | if (pu32Reg)
|
---|
1225 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1226 |
|
---|
1227 | return VINF_SUCCESS;
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 |
|
---|
1231 | /**
|
---|
1232 | * @interface_method_impl{CODECVERB,pfn, f09 }
|
---|
1233 | */
|
---|
1234 | static DECLCALLBACK(int) vrbProcGetPinSense(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1235 | {
|
---|
1236 | *puResp = 0;
|
---|
1237 |
|
---|
1238 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1239 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F09_param;
|
---|
1240 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1241 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F09_param;
|
---|
1242 | else
|
---|
1243 | {
|
---|
1244 | AssertFailed();
|
---|
1245 | LogRel2(("HDA: Warning: Unhandled get pin sense command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | return VINF_SUCCESS;
|
---|
1249 | }
|
---|
1250 |
|
---|
1251 |
|
---|
1252 | /**
|
---|
1253 | * @interface_method_impl{CODECVERB,pfn, 709 }
|
---|
1254 | */
|
---|
1255 | static DECLCALLBACK(int) vrbProcSetPinSense(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1256 | {
|
---|
1257 | *puResp = 0;
|
---|
1258 |
|
---|
1259 | uint32_t *pu32Reg = NULL;
|
---|
1260 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1261 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F09_param;
|
---|
1262 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1263 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F09_param;
|
---|
1264 | else
|
---|
1265 | LogRel2(("HDA: Warning: Unhandled set pin sense command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1266 |
|
---|
1267 | if (pu32Reg)
|
---|
1268 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1269 |
|
---|
1270 | return VINF_SUCCESS;
|
---|
1271 | }
|
---|
1272 |
|
---|
1273 |
|
---|
1274 | /**
|
---|
1275 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
1276 | */
|
---|
1277 | static DECLCALLBACK(int) vrbProcGetConnectionListEntry(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1278 | {
|
---|
1279 | *puResp = 0;
|
---|
1280 |
|
---|
1281 | Assert((uCmd & CODEC_VERB_8BIT_DATA) < CODECNODE_F02_PARAM_LENGTH);
|
---|
1282 | if ((uCmd & CODEC_VERB_8BIT_DATA) >= CODECNODE_F02_PARAM_LENGTH)
|
---|
1283 | {
|
---|
1284 | LogFlowFunc(("access to invalid F02 index %d\n", (uCmd & CODEC_VERB_8BIT_DATA)));
|
---|
1285 | return VINF_SUCCESS;
|
---|
1286 | }
|
---|
1287 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].node.au32F02_param[uCmd & CODEC_VERB_8BIT_DATA];
|
---|
1288 | return VINF_SUCCESS;
|
---|
1289 | }
|
---|
1290 |
|
---|
1291 |
|
---|
1292 | /**
|
---|
1293 | * @interface_method_impl{CODECVERB,pfn, f03 }
|
---|
1294 | */
|
---|
1295 | static DECLCALLBACK(int) vrbProcGetProcessingState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1296 | {
|
---|
1297 | *puResp = 0;
|
---|
1298 |
|
---|
1299 | if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1300 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F03_param;
|
---|
1301 |
|
---|
1302 | return VINF_SUCCESS;
|
---|
1303 | }
|
---|
1304 |
|
---|
1305 |
|
---|
1306 | /**
|
---|
1307 | * @interface_method_impl{CODECVERB,pfn, 703 }
|
---|
1308 | */
|
---|
1309 | static DECLCALLBACK(int) vrbProcSetProcessingState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1310 | {
|
---|
1311 | *puResp = 0;
|
---|
1312 |
|
---|
1313 | if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1314 | hdaCodecSetRegisterU8(&pThis->aNodes[CODEC_NID(uCmd)].adc.u32F03_param, uCmd, 0);
|
---|
1315 | return VINF_SUCCESS;
|
---|
1316 | }
|
---|
1317 |
|
---|
1318 |
|
---|
1319 | /**
|
---|
1320 | * @interface_method_impl{CODECVERB,pfn, f0d }
|
---|
1321 | */
|
---|
1322 | static DECLCALLBACK(int) vrbProcGetDigitalConverter(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1323 | {
|
---|
1324 | *puResp = 0;
|
---|
1325 |
|
---|
1326 | if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1327 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F0d_param;
|
---|
1328 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1329 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F0d_param;
|
---|
1330 | return VINF_SUCCESS;
|
---|
1331 | }
|
---|
1332 |
|
---|
1333 |
|
---|
1334 | static int codecSetDigitalConverter(PHDACODECR3 pThis, uint32_t uCmd, uint8_t u8Offset, uint64_t *puResp)
|
---|
1335 | {
|
---|
1336 | *puResp = 0;
|
---|
1337 |
|
---|
1338 | if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1339 | hdaCodecSetRegisterU8(&pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F0d_param, uCmd, u8Offset);
|
---|
1340 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1341 | hdaCodecSetRegisterU8(&pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F0d_param, uCmd, u8Offset);
|
---|
1342 | return VINF_SUCCESS;
|
---|
1343 | }
|
---|
1344 |
|
---|
1345 |
|
---|
1346 | /**
|
---|
1347 | * @interface_method_impl{CODECVERB,pfn, 70d }
|
---|
1348 | */
|
---|
1349 | static DECLCALLBACK(int) vrbProcSetDigitalConverter1(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1350 | {
|
---|
1351 | return codecSetDigitalConverter(pThis, uCmd, 0, puResp);
|
---|
1352 | }
|
---|
1353 |
|
---|
1354 |
|
---|
1355 | /**
|
---|
1356 | * @interface_method_impl{CODECVERB,pfn, 70e }
|
---|
1357 | */
|
---|
1358 | static DECLCALLBACK(int) vrbProcSetDigitalConverter2(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1359 | {
|
---|
1360 | return codecSetDigitalConverter(pThis, uCmd, 8, puResp);
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 |
|
---|
1364 | /**
|
---|
1365 | * @interface_method_impl{CODECVERB,pfn, f20 }
|
---|
1366 | */
|
---|
1367 | static DECLCALLBACK(int) vrbProcGetSubId(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1368 | {
|
---|
1369 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1370 | uint8_t const cTotalNodes = (uint8_t)RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
1371 | Assert(CODEC_NID(uCmd) < cTotalNodes);
|
---|
1372 | if (CODEC_NID(uCmd) >= cTotalNodes)
|
---|
1373 | {
|
---|
1374 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(uCmd)));
|
---|
1375 | *puResp = 0;
|
---|
1376 | return VINF_SUCCESS;
|
---|
1377 | }
|
---|
1378 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1379 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].afg.u32F20_param;
|
---|
1380 | else
|
---|
1381 | *puResp = 0;
|
---|
1382 | return VINF_SUCCESS;
|
---|
1383 | }
|
---|
1384 |
|
---|
1385 |
|
---|
1386 | static int codecSetSubIdX(PHDACODECR3 pThis, uint32_t uCmd, uint8_t u8Offset)
|
---|
1387 | {
|
---|
1388 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1389 | uint8_t const cTotalNodes = (uint8_t)RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
1390 | Assert(CODEC_NID(uCmd) < cTotalNodes);
|
---|
1391 | if (CODEC_NID(uCmd) >= cTotalNodes)
|
---|
1392 | {
|
---|
1393 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(uCmd)));
|
---|
1394 | return VINF_SUCCESS;
|
---|
1395 | }
|
---|
1396 | uint32_t *pu32Reg;
|
---|
1397 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1398 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F20_param;
|
---|
1399 | else
|
---|
1400 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1401 | hdaCodecSetRegisterU8(pu32Reg, uCmd, u8Offset);
|
---|
1402 | return VINF_SUCCESS;
|
---|
1403 | }
|
---|
1404 |
|
---|
1405 |
|
---|
1406 | /**
|
---|
1407 | * @interface_method_impl{CODECVERB,pfn, 720 }
|
---|
1408 | */
|
---|
1409 | static DECLCALLBACK(int) vrbProcSetSubId0(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1410 | {
|
---|
1411 | *puResp = 0;
|
---|
1412 | return codecSetSubIdX(pThis, uCmd, 0);
|
---|
1413 | }
|
---|
1414 |
|
---|
1415 |
|
---|
1416 | /**
|
---|
1417 | * @interface_method_impl{CODECVERB,pfn, 721 }
|
---|
1418 | */
|
---|
1419 | static DECLCALLBACK(int) vrbProcSetSubId1(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1420 | {
|
---|
1421 | *puResp = 0;
|
---|
1422 | return codecSetSubIdX(pThis, uCmd, 8);
|
---|
1423 | }
|
---|
1424 |
|
---|
1425 |
|
---|
1426 | /**
|
---|
1427 | * @interface_method_impl{CODECVERB,pfn, 722 }
|
---|
1428 | */
|
---|
1429 | static DECLCALLBACK(int) vrbProcSetSubId2(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1430 | {
|
---|
1431 | *puResp = 0;
|
---|
1432 | return codecSetSubIdX(pThis, uCmd, 16);
|
---|
1433 | }
|
---|
1434 |
|
---|
1435 |
|
---|
1436 | /**
|
---|
1437 | * @interface_method_impl{CODECVERB,pfn, 723 }
|
---|
1438 | */
|
---|
1439 | static DECLCALLBACK(int) vrbProcSetSubId3(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1440 | {
|
---|
1441 | *puResp = 0;
|
---|
1442 | return codecSetSubIdX(pThis, uCmd, 24);
|
---|
1443 | }
|
---|
1444 |
|
---|
1445 |
|
---|
1446 | /**
|
---|
1447 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
1448 | */
|
---|
1449 | static DECLCALLBACK(int) vrbProcReset(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1450 | {
|
---|
1451 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1452 |
|
---|
1453 | if (pThis->enmType == CODECTYPE_STAC9220)
|
---|
1454 | {
|
---|
1455 | Assert(CODEC_NID(uCmd) == STAC9220_NID_AFG);
|
---|
1456 |
|
---|
1457 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1458 | stac9220Reset(pThis);
|
---|
1459 | }
|
---|
1460 | else
|
---|
1461 | AssertFailedReturn(VERR_NOT_IMPLEMENTED);
|
---|
1462 |
|
---|
1463 | *puResp = 0;
|
---|
1464 | return VINF_SUCCESS;
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 |
|
---|
1468 | /**
|
---|
1469 | * @interface_method_impl{CODECVERB,pfn, f05 }
|
---|
1470 | */
|
---|
1471 | static DECLCALLBACK(int) vrbProcGetPowerState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1472 | {
|
---|
1473 | *puResp = 0;
|
---|
1474 |
|
---|
1475 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1476 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].afg.u32F05_param;
|
---|
1477 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1478 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F05_param;
|
---|
1479 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1480 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F05_param;
|
---|
1481 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1482 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F05_param;
|
---|
1483 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1484 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F05_param;
|
---|
1485 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1486 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F05_param;
|
---|
1487 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1488 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F05_param;
|
---|
1489 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1490 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F05_param;
|
---|
1491 | else
|
---|
1492 | LogRel2(("HDA: Warning: Unhandled get power state command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1493 |
|
---|
1494 | LogFunc(("[NID0x%02x]: fReset=%RTbool, fStopOk=%RTbool, Act=D%RU8, Set=D%RU8\n",
|
---|
1495 | CODEC_NID(uCmd), CODEC_F05_IS_RESET(*puResp), CODEC_F05_IS_STOPOK(*puResp), CODEC_F05_ACT(*puResp), CODEC_F05_SET(*puResp)));
|
---|
1496 | return VINF_SUCCESS;
|
---|
1497 | }
|
---|
1498 |
|
---|
1499 | #if 1
|
---|
1500 |
|
---|
1501 | /**
|
---|
1502 | * @interface_method_impl{CODECVERB,pfn, 705 }
|
---|
1503 | */
|
---|
1504 | static DECLCALLBACK(int) vrbProcSetPowerState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1505 | {
|
---|
1506 | *puResp = 0;
|
---|
1507 |
|
---|
1508 | uint32_t *pu32Reg = NULL;
|
---|
1509 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1510 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F05_param;
|
---|
1511 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1512 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F05_param;
|
---|
1513 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1514 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F05_param;
|
---|
1515 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1516 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F05_param;
|
---|
1517 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1518 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F05_param;
|
---|
1519 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1520 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F05_param;
|
---|
1521 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1522 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F05_param;
|
---|
1523 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1524 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F05_param;
|
---|
1525 | else
|
---|
1526 | {
|
---|
1527 | LogRel2(("HDA: Warning: Unhandled set power state command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1528 | }
|
---|
1529 |
|
---|
1530 | if (!pu32Reg)
|
---|
1531 | return VINF_SUCCESS;
|
---|
1532 |
|
---|
1533 | uint8_t uPwrCmd = CODEC_F05_SET (uCmd);
|
---|
1534 | bool fReset = CODEC_F05_IS_RESET (*pu32Reg);
|
---|
1535 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32Reg);
|
---|
1536 | #ifdef LOG_ENABLED
|
---|
1537 | bool fError = CODEC_F05_IS_ERROR (*pu32Reg);
|
---|
1538 | uint8_t uPwrAct = CODEC_F05_ACT (*pu32Reg);
|
---|
1539 | uint8_t uPwrSet = CODEC_F05_SET (*pu32Reg);
|
---|
1540 | LogFunc(("[NID0x%02x] Cmd=D%RU8, fReset=%RTbool, fStopOk=%RTbool, fError=%RTbool, uPwrAct=D%RU8, uPwrSet=D%RU8\n",
|
---|
1541 | CODEC_NID(uCmd), uPwrCmd, fReset, fStopOk, fError, uPwrAct, uPwrSet));
|
---|
1542 | LogFunc(("AFG: Act=D%RU8, Set=D%RU8\n",
|
---|
1543 | CODEC_F05_ACT(pThis->aNodes[STAC9220_NID_AFG].afg.u32F05_param),
|
---|
1544 | CODEC_F05_SET(pThis->aNodes[STAC9220_NID_AFG].afg.u32F05_param)));
|
---|
1545 | #endif
|
---|
1546 |
|
---|
1547 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1548 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0, uPwrCmd /* PS-Act */, uPwrCmd /* PS-Set */);
|
---|
1549 |
|
---|
1550 | const uint8_t uAFGPwrAct = CODEC_F05_ACT(pThis->aNodes[STAC9220_NID_AFG].afg.u32F05_param);
|
---|
1551 | if (uAFGPwrAct == CODEC_F05_D0) /* Only propagate power state if AFG is on (D0). */
|
---|
1552 | {
|
---|
1553 | /* Propagate to all other nodes under this AFG. */
|
---|
1554 | LogFunc(("Propagating Act=D%RU8 (AFG), Set=D%RU8 to all AFG child nodes ...\n", uAFGPwrAct, uPwrCmd));
|
---|
1555 |
|
---|
1556 | #define PROPAGATE_PWR_STATE(a_abList, a_Member) \
|
---|
1557 | do { \
|
---|
1558 | for (uintptr_t idxList = 0; idxList < RT_ELEMENTS(a_abList); idxList++) \
|
---|
1559 | { \
|
---|
1560 | uint8_t const idxNode = a_abList[idxList]; \
|
---|
1561 | if (idxNode) \
|
---|
1562 | { \
|
---|
1563 | pThis->aNodes[idxNode].a_Member.u32F05_param = CODEC_MAKE_F05(fReset, fStopOk, 0, uAFGPwrAct, uPwrCmd); \
|
---|
1564 | LogFunc(("\t[NID0x%02x]: Act=D%RU8, Set=D%RU8\n", idxNode, \
|
---|
1565 | CODEC_F05_ACT(pThis->aNodes[idxNode].a_Member.u32F05_param), \
|
---|
1566 | CODEC_F05_SET(pThis->aNodes[idxNode].a_Member.u32F05_param))); \
|
---|
1567 | } \
|
---|
1568 | else \
|
---|
1569 | break; \
|
---|
1570 | } \
|
---|
1571 | } while (0)
|
---|
1572 |
|
---|
1573 | PROPAGATE_PWR_STATE(pThis->abDacs, dac);
|
---|
1574 | PROPAGATE_PWR_STATE(pThis->abAdcs, adc);
|
---|
1575 | PROPAGATE_PWR_STATE(pThis->abDigInPins, digin);
|
---|
1576 | PROPAGATE_PWR_STATE(pThis->abDigOutPins, digout);
|
---|
1577 | PROPAGATE_PWR_STATE(pThis->abSpdifIns, spdifin);
|
---|
1578 | PROPAGATE_PWR_STATE(pThis->abSpdifOuts, spdifout);
|
---|
1579 | PROPAGATE_PWR_STATE(pThis->abReserveds, reserved);
|
---|
1580 |
|
---|
1581 | #undef PROPAGATE_PWR_STATE
|
---|
1582 | }
|
---|
1583 | /*
|
---|
1584 | * If this node is a reqular node (not the AFG one), adopt PS-Set of the AFG node
|
---|
1585 | * as PS-Set of this node. PS-Act always is one level under PS-Set here.
|
---|
1586 | */
|
---|
1587 | else
|
---|
1588 | {
|
---|
1589 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0, uAFGPwrAct, uPwrCmd);
|
---|
1590 | }
|
---|
1591 |
|
---|
1592 | LogFunc(("[NID0x%02x] fReset=%RTbool, fStopOk=%RTbool, Act=D%RU8, Set=D%RU8\n",
|
---|
1593 | CODEC_NID(uCmd),
|
---|
1594 | CODEC_F05_IS_RESET(*pu32Reg), CODEC_F05_IS_STOPOK(*pu32Reg), CODEC_F05_ACT(*pu32Reg), CODEC_F05_SET(*pu32Reg)));
|
---|
1595 |
|
---|
1596 | return VINF_SUCCESS;
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 | #else
|
---|
1600 |
|
---|
1601 | DECLINLINE(void) codecPropogatePowerState(uint32_t *pu32F05_param)
|
---|
1602 | {
|
---|
1603 | Assert(pu32F05_param);
|
---|
1604 | if (!pu32F05_param)
|
---|
1605 | return;
|
---|
1606 | bool fReset = CODEC_F05_IS_RESET(*pu32F05_param);
|
---|
1607 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32F05_param);
|
---|
1608 | uint8_t u8SetPowerState = CODEC_F05_SET(*pu32F05_param);
|
---|
1609 | *pu32F05_param = CODEC_MAKE_F05(fReset, fStopOk, 0, u8SetPowerState, u8SetPowerState);
|
---|
1610 | }
|
---|
1611 |
|
---|
1612 |
|
---|
1613 | /**
|
---|
1614 | * @interface_method_impl{CODECVERB,pfn, 705 }
|
---|
1615 | */
|
---|
1616 | static DECLCALLBACK(int) vrbProcSetPowerState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1617 | {
|
---|
1618 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1619 | uint8_t const cTotalNodes = (uint8_t)RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
1620 | Assert(CODEC_NID(uCmd) < cTotalNodes);
|
---|
1621 | if (CODEC_NID(uCmd) >= cTotalNodes)
|
---|
1622 | {
|
---|
1623 | *puResp = 0;
|
---|
1624 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(uCmd)));
|
---|
1625 | return VINF_SUCCESS;
|
---|
1626 | }
|
---|
1627 | *puResp = 0;
|
---|
1628 | uint32_t *pu32Reg;
|
---|
1629 | if (CODEC_NID(uCmd) == 1 /* AFG */)
|
---|
1630 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F05_param;
|
---|
1631 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1632 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F05_param;
|
---|
1633 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1634 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F05_param;
|
---|
1635 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1636 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F05_param;
|
---|
1637 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1638 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F05_param;
|
---|
1639 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1640 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F05_param;
|
---|
1641 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1642 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F05_param;
|
---|
1643 | else
|
---|
1644 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1645 |
|
---|
1646 | bool fReset = CODEC_F05_IS_RESET(*pu32Reg);
|
---|
1647 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32Reg);
|
---|
1648 |
|
---|
1649 | if (CODEC_NID(uCmd) != 1 /* AFG */)
|
---|
1650 | {
|
---|
1651 | /*
|
---|
1652 | * We shouldn't propogate actual power state, which actual for AFG
|
---|
1653 | */
|
---|
1654 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0,
|
---|
1655 | CODEC_F05_ACT(pThis->aNodes[1].afg.u32F05_param),
|
---|
1656 | CODEC_F05_SET(uCmd));
|
---|
1657 | }
|
---|
1658 |
|
---|
1659 | /* Propagate next power state only if AFG is on or verb modifies AFG power state */
|
---|
1660 | if ( CODEC_NID(uCmd) == 1 /* AFG */
|
---|
1661 | || !CODEC_F05_ACT(pThis->aNodes[1].afg.u32F05_param))
|
---|
1662 | {
|
---|
1663 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0, CODEC_F05_SET(uCmd), CODEC_F05_SET(uCmd));
|
---|
1664 | if ( CODEC_NID(uCmd) == 1 /* AFG */
|
---|
1665 | && (CODEC_F05_SET(uCmd)) == CODEC_F05_D0)
|
---|
1666 | {
|
---|
1667 | /* now we're powered on AFG and may propogate power states on nodes */
|
---|
1668 | const uint8_t *pu8NodeIndex = &pThis->abDacs[0];
|
---|
1669 | while (*(++pu8NodeIndex))
|
---|
1670 | codecPropogatePowerState(&pThis->aNodes[*pu8NodeIndex].dac.u32F05_param);
|
---|
1671 |
|
---|
1672 | pu8NodeIndex = &pThis->abAdcs[0];
|
---|
1673 | while (*(++pu8NodeIndex))
|
---|
1674 | codecPropogatePowerState(&pThis->aNodes[*pu8NodeIndex].adc.u32F05_param);
|
---|
1675 |
|
---|
1676 | pu8NodeIndex = &pThis->abDigInPins[0];
|
---|
1677 | while (*(++pu8NodeIndex))
|
---|
1678 | codecPropogatePowerState(&pThis->aNodes[*pu8NodeIndex].digin.u32F05_param);
|
---|
1679 | }
|
---|
1680 | }
|
---|
1681 | return VINF_SUCCESS;
|
---|
1682 | }
|
---|
1683 |
|
---|
1684 | #endif
|
---|
1685 |
|
---|
1686 | /**
|
---|
1687 | * @interface_method_impl{CODECVERB,pfn, f06 }
|
---|
1688 | */
|
---|
1689 | static DECLCALLBACK(int) vrbProcGetStreamId(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1690 | {
|
---|
1691 | *puResp = 0;
|
---|
1692 |
|
---|
1693 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1694 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F06_param;
|
---|
1695 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1696 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F06_param;
|
---|
1697 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1698 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F06_param;
|
---|
1699 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1700 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F06_param;
|
---|
1701 | else if (CODEC_NID(uCmd) == STAC9221_NID_I2S_OUT)
|
---|
1702 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F06_param;
|
---|
1703 | else
|
---|
1704 | LogRel2(("HDA: Warning: Unhandled get stream ID command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1705 |
|
---|
1706 | LogFlowFunc(("[NID0x%02x] Stream ID=%RU8, channel=%RU8\n",
|
---|
1707 | CODEC_NID(uCmd), CODEC_F00_06_GET_STREAM_ID(uCmd), CODEC_F00_06_GET_CHANNEL_ID(uCmd)));
|
---|
1708 |
|
---|
1709 | return VINF_SUCCESS;
|
---|
1710 | }
|
---|
1711 |
|
---|
1712 |
|
---|
1713 | /**
|
---|
1714 | * @interface_method_impl{CODECVERB,pfn, a0 }
|
---|
1715 | */
|
---|
1716 | static DECLCALLBACK(int) vrbProcGetConverterFormat(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1717 | {
|
---|
1718 | *puResp = 0;
|
---|
1719 |
|
---|
1720 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1721 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32A_param;
|
---|
1722 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1723 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32A_param;
|
---|
1724 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1725 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32A_param;
|
---|
1726 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1727 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32A_param;
|
---|
1728 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1729 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32A_param;
|
---|
1730 | else
|
---|
1731 | LogRel2(("HDA: Warning: Unhandled get converter format command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1732 |
|
---|
1733 | return VINF_SUCCESS;
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 |
|
---|
1737 | /**
|
---|
1738 | * @interface_method_impl{CODECVERB,pfn, ??? - Also see section 3.7.1. }
|
---|
1739 | */
|
---|
1740 | static DECLCALLBACK(int) vrbProcSetConverterFormat(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1741 | {
|
---|
1742 | *puResp = 0;
|
---|
1743 |
|
---|
1744 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1745 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].dac.u32A_param, uCmd, 0);
|
---|
1746 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1747 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].adc.u32A_param, uCmd, 0);
|
---|
1748 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1749 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32A_param, uCmd, 0);
|
---|
1750 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1751 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32A_param, uCmd, 0);
|
---|
1752 | else
|
---|
1753 | LogRel2(("HDA: Warning: Unhandled set converter format command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1754 |
|
---|
1755 | return VINF_SUCCESS;
|
---|
1756 | }
|
---|
1757 |
|
---|
1758 |
|
---|
1759 | /**
|
---|
1760 | * @interface_method_impl{CODECVERB,pfn, f0c }
|
---|
1761 | */
|
---|
1762 | static DECLCALLBACK(int) vrbProcGetEAPD_BTLEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1763 | {
|
---|
1764 | *puResp = 0;
|
---|
1765 |
|
---|
1766 | if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1767 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F0c_param;
|
---|
1768 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1769 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F0c_param;
|
---|
1770 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1771 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F0c_param;
|
---|
1772 | else
|
---|
1773 | LogRel2(("HDA: Warning: Unhandled get EAPD/BTL enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1774 |
|
---|
1775 | return VINF_SUCCESS;
|
---|
1776 | }
|
---|
1777 |
|
---|
1778 |
|
---|
1779 | /**
|
---|
1780 | * @interface_method_impl{CODECVERB,pfn, 70c }
|
---|
1781 | */
|
---|
1782 | static DECLCALLBACK(int) vrbProcSetEAPD_BTLEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1783 | {
|
---|
1784 | *puResp = 0;
|
---|
1785 |
|
---|
1786 | uint32_t *pu32Reg = NULL;
|
---|
1787 | if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1788 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F0c_param;
|
---|
1789 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1790 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F0c_param;
|
---|
1791 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1792 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F0c_param;
|
---|
1793 | else
|
---|
1794 | LogRel2(("HDA: Warning: Unhandled set EAPD/BTL enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1795 |
|
---|
1796 | if (pu32Reg)
|
---|
1797 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1798 |
|
---|
1799 | return VINF_SUCCESS;
|
---|
1800 | }
|
---|
1801 |
|
---|
1802 |
|
---|
1803 | /**
|
---|
1804 | * @interface_method_impl{CODECVERB,pfn, f0f }
|
---|
1805 | */
|
---|
1806 | static DECLCALLBACK(int) vrbProcGetVolumeKnobCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1807 | {
|
---|
1808 | *puResp = 0;
|
---|
1809 |
|
---|
1810 | if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1811 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F0f_param;
|
---|
1812 | else
|
---|
1813 | LogRel2(("HDA: Warning: Unhandled get volume knob control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1814 |
|
---|
1815 | return VINF_SUCCESS;
|
---|
1816 | }
|
---|
1817 |
|
---|
1818 |
|
---|
1819 | /**
|
---|
1820 | * @interface_method_impl{CODECVERB,pfn, 70f }
|
---|
1821 | */
|
---|
1822 | static DECLCALLBACK(int) vrbProcSetVolumeKnobCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1823 | {
|
---|
1824 | *puResp = 0;
|
---|
1825 |
|
---|
1826 | uint32_t *pu32Reg = NULL;
|
---|
1827 | if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1828 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F0f_param;
|
---|
1829 | else
|
---|
1830 | LogRel2(("HDA: Warning: Unhandled set volume knob control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1831 |
|
---|
1832 | if (pu32Reg)
|
---|
1833 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1834 |
|
---|
1835 | return VINF_SUCCESS;
|
---|
1836 | }
|
---|
1837 |
|
---|
1838 |
|
---|
1839 | /**
|
---|
1840 | * @interface_method_impl{CODECVERB,pfn, f15 }
|
---|
1841 | */
|
---|
1842 | static DECLCALLBACK(int) vrbProcGetGPIOData(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1843 | {
|
---|
1844 | RT_NOREF(pThis, uCmd);
|
---|
1845 | *puResp = 0;
|
---|
1846 | return VINF_SUCCESS;
|
---|
1847 | }
|
---|
1848 |
|
---|
1849 |
|
---|
1850 | /**
|
---|
1851 | * @interface_method_impl{CODECVERB,pfn, 715 }
|
---|
1852 | */
|
---|
1853 | static DECLCALLBACK(int) vrbProcSetGPIOData(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1854 | {
|
---|
1855 | RT_NOREF(pThis, uCmd);
|
---|
1856 | *puResp = 0;
|
---|
1857 | return VINF_SUCCESS;
|
---|
1858 | }
|
---|
1859 |
|
---|
1860 |
|
---|
1861 | /**
|
---|
1862 | * @interface_method_impl{CODECVERB,pfn, f16 }
|
---|
1863 | */
|
---|
1864 | static DECLCALLBACK(int) vrbProcGetGPIOEnableMask(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1865 | {
|
---|
1866 | RT_NOREF(pThis, uCmd);
|
---|
1867 | *puResp = 0;
|
---|
1868 | return VINF_SUCCESS;
|
---|
1869 | }
|
---|
1870 |
|
---|
1871 |
|
---|
1872 | /**
|
---|
1873 | * @interface_method_impl{CODECVERB,pfn, 716 }
|
---|
1874 | */
|
---|
1875 | static DECLCALLBACK(int) vrbProcSetGPIOEnableMask(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1876 | {
|
---|
1877 | RT_NOREF(pThis, uCmd);
|
---|
1878 | *puResp = 0;
|
---|
1879 | return VINF_SUCCESS;
|
---|
1880 | }
|
---|
1881 |
|
---|
1882 |
|
---|
1883 | /**
|
---|
1884 | * @interface_method_impl{CODECVERB,pfn, f17 }
|
---|
1885 | */
|
---|
1886 | static DECLCALLBACK(int) vrbProcGetGPIODirection(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1887 | {
|
---|
1888 | *puResp = 0;
|
---|
1889 |
|
---|
1890 | /* Note: this is true for ALC885. */
|
---|
1891 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1892 | *puResp = pThis->aNodes[1].afg.u32F17_param;
|
---|
1893 | else
|
---|
1894 | LogRel2(("HDA: Warning: Unhandled get GPIO direction command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1895 |
|
---|
1896 | return VINF_SUCCESS;
|
---|
1897 | }
|
---|
1898 |
|
---|
1899 |
|
---|
1900 | /**
|
---|
1901 | * @interface_method_impl{CODECVERB,pfn, 717 }
|
---|
1902 | */
|
---|
1903 | static DECLCALLBACK(int) vrbProcSetGPIODirection(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1904 | {
|
---|
1905 | *puResp = 0;
|
---|
1906 |
|
---|
1907 | uint32_t *pu32Reg = NULL;
|
---|
1908 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1909 | pu32Reg = &pThis->aNodes[1].afg.u32F17_param;
|
---|
1910 | else
|
---|
1911 | LogRel2(("HDA: Warning: Unhandled set GPIO direction command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1912 |
|
---|
1913 | if (pu32Reg)
|
---|
1914 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1915 |
|
---|
1916 | return VINF_SUCCESS;
|
---|
1917 | }
|
---|
1918 |
|
---|
1919 |
|
---|
1920 | /**
|
---|
1921 | * @interface_method_impl{CODECVERB,pfn, f1c }
|
---|
1922 | */
|
---|
1923 | static DECLCALLBACK(int) vrbProcGetConfig(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1924 | {
|
---|
1925 | *puResp = 0;
|
---|
1926 |
|
---|
1927 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1928 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F1c_param;
|
---|
1929 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1930 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F1c_param;
|
---|
1931 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1932 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F1c_param;
|
---|
1933 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1934 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F1c_param;
|
---|
1935 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1936 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F1c_param;
|
---|
1937 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1938 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F1c_param;
|
---|
1939 | else
|
---|
1940 | LogRel2(("HDA: Warning: Unhandled get config command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1941 |
|
---|
1942 | return VINF_SUCCESS;
|
---|
1943 | }
|
---|
1944 |
|
---|
1945 | static int codecSetConfigX(PHDACODECR3 pThis, uint32_t uCmd, uint8_t u8Offset)
|
---|
1946 | {
|
---|
1947 | uint32_t *pu32Reg = NULL;
|
---|
1948 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1949 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F1c_param;
|
---|
1950 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1951 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F1c_param;
|
---|
1952 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1953 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F1c_param;
|
---|
1954 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1955 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F1c_param;
|
---|
1956 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1957 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F1c_param;
|
---|
1958 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1959 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F1c_param;
|
---|
1960 | else
|
---|
1961 | LogRel2(("HDA: Warning: Unhandled set config command (%RU8) for NID0x%02x: 0x%x\n", u8Offset, CODEC_NID(uCmd), uCmd));
|
---|
1962 |
|
---|
1963 | if (pu32Reg)
|
---|
1964 | hdaCodecSetRegisterU8(pu32Reg, uCmd, u8Offset);
|
---|
1965 |
|
---|
1966 | return VINF_SUCCESS;
|
---|
1967 | }
|
---|
1968 |
|
---|
1969 |
|
---|
1970 | /**
|
---|
1971 | * @interface_method_impl{CODECVERB,pfn, 71c }
|
---|
1972 | */
|
---|
1973 | static DECLCALLBACK(int) vrbProcSetConfig0(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1974 | {
|
---|
1975 | *puResp = 0;
|
---|
1976 | return codecSetConfigX(pThis, uCmd, 0);
|
---|
1977 | }
|
---|
1978 |
|
---|
1979 |
|
---|
1980 | /**
|
---|
1981 | * @interface_method_impl{CODECVERB,pfn, 71d }
|
---|
1982 | */
|
---|
1983 | static DECLCALLBACK(int) vrbProcSetConfig1(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1984 | {
|
---|
1985 | *puResp = 0;
|
---|
1986 | return codecSetConfigX(pThis, uCmd, 8);
|
---|
1987 | }
|
---|
1988 |
|
---|
1989 |
|
---|
1990 | /**
|
---|
1991 | * @interface_method_impl{CODECVERB,pfn, 71e }
|
---|
1992 | */
|
---|
1993 | static DECLCALLBACK(int) vrbProcSetConfig2(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1994 | {
|
---|
1995 | *puResp = 0;
|
---|
1996 | return codecSetConfigX(pThis, uCmd, 16);
|
---|
1997 | }
|
---|
1998 |
|
---|
1999 |
|
---|
2000 | /**
|
---|
2001 | * @interface_method_impl{CODECVERB,pfn, 71e }
|
---|
2002 | */
|
---|
2003 | static DECLCALLBACK(int) vrbProcSetConfig3(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2004 | {
|
---|
2005 | *puResp = 0;
|
---|
2006 | return codecSetConfigX(pThis, uCmd, 24);
|
---|
2007 | }
|
---|
2008 |
|
---|
2009 |
|
---|
2010 | /**
|
---|
2011 | * @interface_method_impl{CODECVERB,pfn, f04 }
|
---|
2012 | */
|
---|
2013 | static DECLCALLBACK(int) vrbProcGetSDISelect(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2014 | {
|
---|
2015 | *puResp = 0;
|
---|
2016 |
|
---|
2017 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2018 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F04_param;
|
---|
2019 | else
|
---|
2020 | LogRel2(("HDA: Warning: Unhandled get SDI select command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
2021 |
|
---|
2022 | return VINF_SUCCESS;
|
---|
2023 | }
|
---|
2024 |
|
---|
2025 |
|
---|
2026 | /**
|
---|
2027 | * @interface_method_impl{CODECVERB,pfn, 704 }
|
---|
2028 | */
|
---|
2029 | static DECLCALLBACK(int) vrbProcSetSDISelect(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2030 | {
|
---|
2031 | *puResp = 0;
|
---|
2032 |
|
---|
2033 | uint32_t *pu32Reg = NULL;
|
---|
2034 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2035 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F04_param;
|
---|
2036 | else
|
---|
2037 | LogRel2(("HDA: Warning: Unhandled set SDI select command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
2038 |
|
---|
2039 | if (pu32Reg)
|
---|
2040 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
2041 |
|
---|
2042 | return VINF_SUCCESS;
|
---|
2043 | }
|
---|
2044 |
|
---|
2045 |
|
---|
2046 | /**
|
---|
2047 | * @interface_method_impl{CODECVERB,pfn, 3-- }
|
---|
2048 | */
|
---|
2049 | static DECLCALLBACK(int) vrbProcR3SetAmplifier(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2050 | {
|
---|
2051 | *puResp = 0;
|
---|
2052 |
|
---|
2053 | PCODECNODE pNode = &pThis->aNodes[CODEC_NID(uCmd)];
|
---|
2054 | AMPLIFIER *pAmplifier = NULL;
|
---|
2055 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2056 | pAmplifier = &pNode->dac.B_params;
|
---|
2057 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
2058 | pAmplifier = &pNode->adcvol.B_params;
|
---|
2059 | else if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
2060 | pAmplifier = &pNode->adcmux.B_params;
|
---|
2061 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
2062 | pAmplifier = &pNode->pcbeep.B_params;
|
---|
2063 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
2064 | pAmplifier = &pNode->port.B_params;
|
---|
2065 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
2066 | pAmplifier = &pNode->adc.B_params;
|
---|
2067 | else
|
---|
2068 | LogRel2(("HDA: Warning: Unhandled set amplifier command: 0x%x (Payload=%RU16, NID=0x%x [%RU8])\n",
|
---|
2069 | uCmd, CODEC_VERB_PAYLOAD16(uCmd), CODEC_NID(uCmd), CODEC_NID(uCmd)));
|
---|
2070 |
|
---|
2071 | if (!pAmplifier)
|
---|
2072 | return VINF_SUCCESS;
|
---|
2073 |
|
---|
2074 | bool fIsOut = CODEC_SET_AMP_IS_OUT_DIRECTION(uCmd);
|
---|
2075 | bool fIsIn = CODEC_SET_AMP_IS_IN_DIRECTION(uCmd);
|
---|
2076 | bool fIsLeft = CODEC_SET_AMP_IS_LEFT_SIDE(uCmd);
|
---|
2077 | bool fIsRight = CODEC_SET_AMP_IS_RIGHT_SIDE(uCmd);
|
---|
2078 | uint8_t u8Index = CODEC_SET_AMP_INDEX(uCmd);
|
---|
2079 |
|
---|
2080 | if ( (!fIsLeft && !fIsRight)
|
---|
2081 | || (!fIsOut && !fIsIn))
|
---|
2082 | return VINF_SUCCESS;
|
---|
2083 |
|
---|
2084 | LogFunc(("[NID0x%02x] fIsOut=%RTbool, fIsIn=%RTbool, fIsLeft=%RTbool, fIsRight=%RTbool, Idx=%RU8\n",
|
---|
2085 | CODEC_NID(uCmd), fIsOut, fIsIn, fIsLeft, fIsRight, u8Index));
|
---|
2086 |
|
---|
2087 | if (fIsIn)
|
---|
2088 | {
|
---|
2089 | if (fIsLeft)
|
---|
2090 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_IN, AMPLIFIER_LEFT, u8Index), uCmd, 0);
|
---|
2091 | if (fIsRight)
|
---|
2092 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_IN, AMPLIFIER_RIGHT, u8Index), uCmd, 0);
|
---|
2093 |
|
---|
2094 | // if (CODEC_NID(uCmd) == pThis->u8AdcVolsLineIn)
|
---|
2095 | // {
|
---|
2096 | hdaR3CodecToAudVolume(pThis, pNode, pAmplifier, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2097 | // }
|
---|
2098 | }
|
---|
2099 | if (fIsOut)
|
---|
2100 | {
|
---|
2101 | if (fIsLeft)
|
---|
2102 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_OUT, AMPLIFIER_LEFT, u8Index), uCmd, 0);
|
---|
2103 | if (fIsRight)
|
---|
2104 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_OUT, AMPLIFIER_RIGHT, u8Index), uCmd, 0);
|
---|
2105 |
|
---|
2106 | if (CODEC_NID(uCmd) == pThis->u8DacLineOut)
|
---|
2107 | hdaR3CodecToAudVolume(pThis, pNode, pAmplifier, PDMAUDIOMIXERCTL_FRONT);
|
---|
2108 | }
|
---|
2109 |
|
---|
2110 | return VINF_SUCCESS;
|
---|
2111 | }
|
---|
2112 |
|
---|
2113 |
|
---|
2114 | /**
|
---|
2115 | * @interface_method_impl{CODECVERB,pfn, 706 }
|
---|
2116 | */
|
---|
2117 | static DECLCALLBACK(int) vrbProcR3SetStreamId(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2118 | {
|
---|
2119 | *puResp = 0;
|
---|
2120 |
|
---|
2121 | uint8_t uSD = CODEC_F00_06_GET_STREAM_ID(uCmd);
|
---|
2122 | uint8_t uChannel = CODEC_F00_06_GET_CHANNEL_ID(uCmd);
|
---|
2123 |
|
---|
2124 | LogFlowFunc(("[NID0x%02x] Setting to stream ID=%RU8, channel=%RU8\n",
|
---|
2125 | CODEC_NID(uCmd), uSD, uChannel));
|
---|
2126 |
|
---|
2127 | ASSERT_GUEST_LOGREL_MSG_RETURN(uSD < HDA_MAX_STREAMS,
|
---|
2128 | ("Setting stream ID #%RU8 is invalid\n", uSD), VERR_INVALID_PARAMETER);
|
---|
2129 |
|
---|
2130 | PDMAUDIODIR enmDir;
|
---|
2131 | uint32_t *pu32Addr;
|
---|
2132 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2133 | {
|
---|
2134 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F06_param;
|
---|
2135 | enmDir = PDMAUDIODIR_OUT;
|
---|
2136 | }
|
---|
2137 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
2138 | {
|
---|
2139 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F06_param;
|
---|
2140 | enmDir = PDMAUDIODIR_IN;
|
---|
2141 | }
|
---|
2142 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
2143 | {
|
---|
2144 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F06_param;
|
---|
2145 | enmDir = PDMAUDIODIR_OUT;
|
---|
2146 | }
|
---|
2147 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
2148 | {
|
---|
2149 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F06_param;
|
---|
2150 | enmDir = PDMAUDIODIR_IN;
|
---|
2151 | }
|
---|
2152 | else
|
---|
2153 | {
|
---|
2154 | enmDir = PDMAUDIODIR_UNKNOWN;
|
---|
2155 | LogRel2(("HDA: Warning: Unhandled set stream ID command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
2156 | return VINF_SUCCESS;
|
---|
2157 | }
|
---|
2158 |
|
---|
2159 | /* Do we (re-)assign our input/output SDn (SDI/SDO) IDs? */
|
---|
2160 | pThis->aNodes[CODEC_NID(uCmd)].node.uSD = uSD;
|
---|
2161 | pThis->aNodes[CODEC_NID(uCmd)].node.uChannel = uChannel;
|
---|
2162 |
|
---|
2163 | if (enmDir == PDMAUDIODIR_OUT)
|
---|
2164 | {
|
---|
2165 | /** @todo Check if non-interleaved streams need a different channel / SDn? */
|
---|
2166 |
|
---|
2167 | /* Propagate to the controller. */
|
---|
2168 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_FRONT, uSD, uChannel);
|
---|
2169 | # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
|
---|
2170 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, uSD, uChannel);
|
---|
2171 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_REAR, uSD, uChannel);
|
---|
2172 | # endif
|
---|
2173 | }
|
---|
2174 | else if (enmDir == PDMAUDIODIR_IN)
|
---|
2175 | {
|
---|
2176 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_LINE_IN, uSD, uChannel);
|
---|
2177 | # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2178 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_MIC_IN, uSD, uChannel);
|
---|
2179 | # endif
|
---|
2180 | }
|
---|
2181 |
|
---|
2182 | hdaCodecSetRegisterU8(pu32Addr, uCmd, 0);
|
---|
2183 |
|
---|
2184 | return VINF_SUCCESS;
|
---|
2185 | }
|
---|
2186 |
|
---|
2187 |
|
---|
2188 |
|
---|
2189 | /**
|
---|
2190 | * HDA codec verb descriptors.
|
---|
2191 | *
|
---|
2192 | * @note This must be ordered by uVerb so we can do a binary lookup.
|
---|
2193 | */
|
---|
2194 | static const CODECVERB g_aCodecVerbs[] =
|
---|
2195 | {
|
---|
2196 | /* Verb Verb mask Callback Name
|
---|
2197 | ---------- --------------------- ------------------------------------------------------------------- */
|
---|
2198 | { 0x00020000, CODEC_VERB_16BIT_CMD, vrbProcSetConverterFormat , "SetConverterFormat " },
|
---|
2199 | { 0x00030000, CODEC_VERB_16BIT_CMD, vrbProcR3SetAmplifier , "SetAmplifier " },
|
---|
2200 | { 0x00070100, CODEC_VERB_8BIT_CMD , vrbProcSetConSelectCtrl , "SetConSelectCtrl " },
|
---|
2201 | { 0x00070300, CODEC_VERB_8BIT_CMD , vrbProcSetProcessingState , "SetProcessingState " },
|
---|
2202 | { 0x00070400, CODEC_VERB_8BIT_CMD , vrbProcSetSDISelect , "SetSDISelect " },
|
---|
2203 | { 0x00070500, CODEC_VERB_8BIT_CMD , vrbProcSetPowerState , "SetPowerState " },
|
---|
2204 | { 0x00070600, CODEC_VERB_8BIT_CMD , vrbProcR3SetStreamId , "SetStreamId " },
|
---|
2205 | { 0x00070700, CODEC_VERB_8BIT_CMD , vrbProcSetPinCtrl , "SetPinCtrl " },
|
---|
2206 | { 0x00070800, CODEC_VERB_8BIT_CMD , vrbProcSetUnsolicitedEnabled , "SetUnsolicitedEnabled " },
|
---|
2207 | { 0x00070900, CODEC_VERB_8BIT_CMD , vrbProcSetPinSense , "SetPinSense " },
|
---|
2208 | { 0x00070C00, CODEC_VERB_8BIT_CMD , vrbProcSetEAPD_BTLEnabled , "SetEAPD_BTLEnabled " },
|
---|
2209 | { 0x00070D00, CODEC_VERB_8BIT_CMD , vrbProcSetDigitalConverter1 , "SetDigitalConverter1 " },
|
---|
2210 | { 0x00070E00, CODEC_VERB_8BIT_CMD , vrbProcSetDigitalConverter2 , "SetDigitalConverter2 " },
|
---|
2211 | { 0x00070F00, CODEC_VERB_8BIT_CMD , vrbProcSetVolumeKnobCtrl , "SetVolumeKnobCtrl " },
|
---|
2212 | { 0x00071500, CODEC_VERB_8BIT_CMD , vrbProcSetGPIOData , "SetGPIOData " },
|
---|
2213 | { 0x00071600, CODEC_VERB_8BIT_CMD , vrbProcSetGPIOEnableMask , "SetGPIOEnableMask " },
|
---|
2214 | { 0x00071700, CODEC_VERB_8BIT_CMD , vrbProcSetGPIODirection , "SetGPIODirection " },
|
---|
2215 | { 0x00071C00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig0 , "SetConfig0 " },
|
---|
2216 | { 0x00071D00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig1 , "SetConfig1 " },
|
---|
2217 | { 0x00071E00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig2 , "SetConfig2 " },
|
---|
2218 | { 0x00071F00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig3 , "SetConfig3 " },
|
---|
2219 | { 0x00072000, CODEC_VERB_8BIT_CMD , vrbProcSetSubId0 , "SetSubId0 " },
|
---|
2220 | { 0x00072100, CODEC_VERB_8BIT_CMD , vrbProcSetSubId1 , "SetSubId1 " },
|
---|
2221 | { 0x00072200, CODEC_VERB_8BIT_CMD , vrbProcSetSubId2 , "SetSubId2 " },
|
---|
2222 | { 0x00072300, CODEC_VERB_8BIT_CMD , vrbProcSetSubId3 , "SetSubId3 " },
|
---|
2223 | { 0x0007FF00, CODEC_VERB_8BIT_CMD , vrbProcReset , "Reset " },
|
---|
2224 | { 0x000A0000, CODEC_VERB_16BIT_CMD, vrbProcGetConverterFormat , "GetConverterFormat " },
|
---|
2225 | { 0x000B0000, CODEC_VERB_16BIT_CMD, vrbProcGetAmplifier , "GetAmplifier " },
|
---|
2226 | { 0x000F0000, CODEC_VERB_8BIT_CMD , vrbProcGetParameter , "GetParameter " },
|
---|
2227 | { 0x000F0100, CODEC_VERB_8BIT_CMD , vrbProcGetConSelectCtrl , "GetConSelectCtrl " },
|
---|
2228 | { 0x000F0200, CODEC_VERB_8BIT_CMD , vrbProcGetConnectionListEntry , "GetConnectionListEntry" },
|
---|
2229 | { 0x000F0300, CODEC_VERB_8BIT_CMD , vrbProcGetProcessingState , "GetProcessingState " },
|
---|
2230 | { 0x000F0400, CODEC_VERB_8BIT_CMD , vrbProcGetSDISelect , "GetSDISelect " },
|
---|
2231 | { 0x000F0500, CODEC_VERB_8BIT_CMD , vrbProcGetPowerState , "GetPowerState " },
|
---|
2232 | { 0x000F0600, CODEC_VERB_8BIT_CMD , vrbProcGetStreamId , "GetStreamId " },
|
---|
2233 | { 0x000F0700, CODEC_VERB_8BIT_CMD , vrbProcGetPinCtrl , "GetPinCtrl " },
|
---|
2234 | { 0x000F0800, CODEC_VERB_8BIT_CMD , vrbProcGetUnsolicitedEnabled , "GetUnsolicitedEnabled " },
|
---|
2235 | { 0x000F0900, CODEC_VERB_8BIT_CMD , vrbProcGetPinSense , "GetPinSense " },
|
---|
2236 | { 0x000F0C00, CODEC_VERB_8BIT_CMD , vrbProcGetEAPD_BTLEnabled , "GetEAPD_BTLEnabled " },
|
---|
2237 | { 0x000F0D00, CODEC_VERB_8BIT_CMD , vrbProcGetDigitalConverter , "GetDigitalConverter " },
|
---|
2238 | { 0x000F0F00, CODEC_VERB_8BIT_CMD , vrbProcGetVolumeKnobCtrl , "GetVolumeKnobCtrl " },
|
---|
2239 | { 0x000F1500, CODEC_VERB_8BIT_CMD , vrbProcGetGPIOData , "GetGPIOData " },
|
---|
2240 | { 0x000F1600, CODEC_VERB_8BIT_CMD , vrbProcGetGPIOEnableMask , "GetGPIOEnableMask " },
|
---|
2241 | { 0x000F1700, CODEC_VERB_8BIT_CMD , vrbProcGetGPIODirection , "GetGPIODirection " },
|
---|
2242 | { 0x000F1C00, CODEC_VERB_8BIT_CMD , vrbProcGetConfig , "GetConfig " },
|
---|
2243 | { 0x000F2000, CODEC_VERB_8BIT_CMD , vrbProcGetSubId , "GetSubId " },
|
---|
2244 | /** @todo Implement 0x7e7: IDT Set GPIO (STAC922x only). */
|
---|
2245 | };
|
---|
2246 |
|
---|
2247 |
|
---|
2248 | /**
|
---|
2249 | * Implements codec lookup and will call the handler on the verb it finds,
|
---|
2250 | * returning the handler response.
|
---|
2251 | *
|
---|
2252 | * @returns VBox status code (not strict).
|
---|
2253 | */
|
---|
2254 | DECLHIDDEN(int) hdaR3CodecLookup(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2255 | {
|
---|
2256 | /*
|
---|
2257 | * Clear the return value and assert some sanity.
|
---|
2258 | */
|
---|
2259 | AssertPtr(puResp);
|
---|
2260 | *puResp = 0;
|
---|
2261 | AssertPtr(pThis);
|
---|
2262 | AssertMsgReturn(CODEC_CAD(uCmd) == pThis->id,
|
---|
2263 | ("Unknown codec address 0x%x\n", CODEC_CAD(uCmd)),
|
---|
2264 | VERR_INVALID_PARAMETER);
|
---|
2265 | uint32_t const uCmdData = CODEC_VERBDATA(uCmd);
|
---|
2266 | AssertMsgReturn( uCmdData != 0
|
---|
2267 | && CODEC_NID(uCmd) < RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes)),
|
---|
2268 | ("[NID0x%02x] Unknown / invalid node or data (0x%x)\n", CODEC_NID(uCmd), uCmdData),
|
---|
2269 | VERR_INVALID_PARAMETER);
|
---|
2270 | STAM_COUNTER_INC(&pThis->CTX_SUFF(StatLookups));
|
---|
2271 |
|
---|
2272 | /*
|
---|
2273 | * Do a binary lookup of the verb.
|
---|
2274 | * Note! if we want other verb tables, add a table selector before the loop.
|
---|
2275 | */
|
---|
2276 | size_t iFirst = 0;
|
---|
2277 | size_t iEnd = RT_ELEMENTS(g_aCodecVerbs);
|
---|
2278 | for (;;)
|
---|
2279 | {
|
---|
2280 | size_t const iCur = iFirst + (iEnd - iFirst) / 2;
|
---|
2281 | uint32_t const uVerb = g_aCodecVerbs[iCur].uVerb;
|
---|
2282 | if (uCmdData < uVerb)
|
---|
2283 | {
|
---|
2284 | if (iCur > iFirst)
|
---|
2285 | iEnd = iCur;
|
---|
2286 | else
|
---|
2287 | break;
|
---|
2288 | }
|
---|
2289 | else if ((uCmdData & g_aCodecVerbs[iCur].fMask) != uVerb)
|
---|
2290 | {
|
---|
2291 | if (iCur + 1 < iEnd)
|
---|
2292 | iFirst = iCur + 1;
|
---|
2293 | else
|
---|
2294 | break;
|
---|
2295 | }
|
---|
2296 | else
|
---|
2297 | {
|
---|
2298 | /*
|
---|
2299 | * Found it! Run the callback and return.
|
---|
2300 | */
|
---|
2301 | AssertPtrReturn(g_aCodecVerbs[iCur].pfn, VERR_INTERNAL_ERROR_5); /* Paranoia^2. */
|
---|
2302 |
|
---|
2303 | int rc = g_aCodecVerbs[iCur].pfn(pThis, uCmd, puResp);
|
---|
2304 | AssertRC(rc);
|
---|
2305 | Log3Func(("[NID0x%02x] (0x%x) %s: 0x%x -> 0x%x\n",
|
---|
2306 | CODEC_NID(uCmd), g_aCodecVerbs[iCur].uVerb, g_aCodecVerbs[iCur].pszName, CODEC_VERB_PAYLOAD8(uCmd), *puResp));
|
---|
2307 | return rc;
|
---|
2308 | }
|
---|
2309 | }
|
---|
2310 |
|
---|
2311 | #ifdef VBOX_STRICT
|
---|
2312 | for (size_t i = 0; i < RT_ELEMENTS(g_aCodecVerbs); i++)
|
---|
2313 | {
|
---|
2314 | AssertMsg(i == 0 || g_aCodecVerbs[i - 1].uVerb < g_aCodecVerbs[i].uVerb,
|
---|
2315 | ("i=%#x uVerb[-1]=%#x uVerb=%#x - buggy table!\n", i, g_aCodecVerbs[i - 1].uVerb, g_aCodecVerbs[i].uVerb));
|
---|
2316 | AssertMsg((uCmdData & g_aCodecVerbs[i].fMask) != g_aCodecVerbs[i].uVerb,
|
---|
2317 | ("i=%#x uVerb=%#x uCmd=%#x - buggy binary search or table!\n", i, g_aCodecVerbs[i].uVerb, uCmd));
|
---|
2318 | }
|
---|
2319 | #endif
|
---|
2320 | LogFunc(("[NID0x%02x] Callback for %x not found\n", CODEC_NID(uCmd), CODEC_VERBDATA(uCmd)));
|
---|
2321 | return VERR_NOT_FOUND;
|
---|
2322 | }
|
---|
2323 |
|
---|
2324 |
|
---|
2325 | /*********************************************************************************************************************************
|
---|
2326 | * Debug *
|
---|
2327 | *********************************************************************************************************************************/
|
---|
2328 | /**
|
---|
2329 | * CODEC debug info item printing state.
|
---|
2330 | */
|
---|
2331 | typedef struct CODECDEBUG
|
---|
2332 | {
|
---|
2333 | /** DBGF info helpers. */
|
---|
2334 | PCDBGFINFOHLP pHlp;
|
---|
2335 | /** Current recursion level. */
|
---|
2336 | uint8_t uLevel;
|
---|
2337 | /** Pointer to codec state. */
|
---|
2338 | PHDACODECR3 pThis;
|
---|
2339 | } CODECDEBUG;
|
---|
2340 | /** Pointer to the debug info item printing state for the codec. */
|
---|
2341 | typedef CODECDEBUG *PCODECDEBUG;
|
---|
2342 |
|
---|
2343 | #define CODECDBG_INDENT pInfo->uLevel++;
|
---|
2344 | #define CODECDBG_UNINDENT if (pInfo->uLevel) pInfo->uLevel--;
|
---|
2345 |
|
---|
2346 | #define CODECDBG_PRINT(...) pInfo->pHlp->pfnPrintf(pInfo->pHlp, __VA_ARGS__)
|
---|
2347 | #define CODECDBG_PRINTI(...) codecDbgPrintf(pInfo, __VA_ARGS__)
|
---|
2348 |
|
---|
2349 |
|
---|
2350 | /** Wrapper around DBGFINFOHLP::pfnPrintf that adds identation. */
|
---|
2351 | static void codecDbgPrintf(PCODECDEBUG pInfo, const char *pszFormat, ...)
|
---|
2352 | {
|
---|
2353 | va_list va;
|
---|
2354 | va_start(va, pszFormat);
|
---|
2355 | pInfo->pHlp->pfnPrintf(pInfo->pHlp, "%*s%N", pInfo->uLevel * 4, "", pszFormat, &va);
|
---|
2356 | va_end(va);
|
---|
2357 | }
|
---|
2358 |
|
---|
2359 |
|
---|
2360 | /** Power state */
|
---|
2361 | static void codecDbgPrintNodeRegF05(PCODECDEBUG pInfo, uint32_t u32Reg)
|
---|
2362 | {
|
---|
2363 | codecDbgPrintf(pInfo, "Power (F05): fReset=%RTbool, fStopOk=%RTbool, Set=%RU8, Act=%RU8\n",
|
---|
2364 | CODEC_F05_IS_RESET(u32Reg), CODEC_F05_IS_STOPOK(u32Reg), CODEC_F05_SET(u32Reg), CODEC_F05_ACT(u32Reg));
|
---|
2365 | }
|
---|
2366 |
|
---|
2367 |
|
---|
2368 | static void codecDbgPrintNodeRegA(PCODECDEBUG pInfo, uint32_t u32Reg)
|
---|
2369 | {
|
---|
2370 | codecDbgPrintf(pInfo, "RegA: %x\n", u32Reg);
|
---|
2371 | }
|
---|
2372 |
|
---|
2373 |
|
---|
2374 | static void codecDbgPrintNodeRegF00(PCODECDEBUG pInfo, uint32_t *paReg00)
|
---|
2375 | {
|
---|
2376 | codecDbgPrintf(pInfo, "Parameters (F00):\n");
|
---|
2377 |
|
---|
2378 | CODECDBG_INDENT
|
---|
2379 | codecDbgPrintf(pInfo, "Connections: %RU8\n", CODEC_F00_0E_COUNT(paReg00[0xE]));
|
---|
2380 | codecDbgPrintf(pInfo, "Amplifier Caps:\n");
|
---|
2381 | uint32_t uReg = paReg00[0xD];
|
---|
2382 | CODECDBG_INDENT
|
---|
2383 | codecDbgPrintf(pInfo, "Input Steps=%02RU8, StepSize=%02RU8, StepOff=%02RU8, fCanMute=%RTbool\n",
|
---|
2384 | CODEC_F00_0D_NUM_STEPS(uReg),
|
---|
2385 | CODEC_F00_0D_STEP_SIZE(uReg),
|
---|
2386 | CODEC_F00_0D_OFFSET(uReg),
|
---|
2387 | RT_BOOL(CODEC_F00_0D_IS_CAP_MUTE(uReg)));
|
---|
2388 |
|
---|
2389 | uReg = paReg00[0x12];
|
---|
2390 | codecDbgPrintf(pInfo, "Output Steps=%02RU8, StepSize=%02RU8, StepOff=%02RU8, fCanMute=%RTbool\n",
|
---|
2391 | CODEC_F00_12_NUM_STEPS(uReg),
|
---|
2392 | CODEC_F00_12_STEP_SIZE(uReg),
|
---|
2393 | CODEC_F00_12_OFFSET(uReg),
|
---|
2394 | RT_BOOL(CODEC_F00_12_IS_CAP_MUTE(uReg)));
|
---|
2395 | CODECDBG_UNINDENT
|
---|
2396 | CODECDBG_UNINDENT
|
---|
2397 | }
|
---|
2398 |
|
---|
2399 |
|
---|
2400 | static void codecDbgPrintNodeAmp(PCODECDEBUG pInfo, uint32_t *paReg, uint8_t uIdx, uint8_t uDir)
|
---|
2401 | {
|
---|
2402 | #define CODECDBG_AMP(reg, chan) \
|
---|
2403 | codecDbgPrintf(pInfo, "Amp %RU8 %s %s: In=%RTbool, Out=%RTbool, Left=%RTbool, Right=%RTbool, Idx=%RU8, fMute=%RTbool, uGain=%RU8\n", \
|
---|
2404 | uIdx, chan, uDir == AMPLIFIER_IN ? "In" : "Out", \
|
---|
2405 | RT_BOOL(CODEC_SET_AMP_IS_IN_DIRECTION(reg)), RT_BOOL(CODEC_SET_AMP_IS_OUT_DIRECTION(reg)), \
|
---|
2406 | RT_BOOL(CODEC_SET_AMP_IS_LEFT_SIDE(reg)), RT_BOOL(CODEC_SET_AMP_IS_RIGHT_SIDE(reg)), \
|
---|
2407 | CODEC_SET_AMP_INDEX(reg), RT_BOOL(CODEC_SET_AMP_MUTE(reg)), CODEC_SET_AMP_GAIN(reg))
|
---|
2408 |
|
---|
2409 | uint32_t regAmp = AMPLIFIER_REGISTER(paReg, uDir, AMPLIFIER_LEFT, uIdx);
|
---|
2410 | CODECDBG_AMP(regAmp, "Left");
|
---|
2411 | regAmp = AMPLIFIER_REGISTER(paReg, uDir, AMPLIFIER_RIGHT, uIdx);
|
---|
2412 | CODECDBG_AMP(regAmp, "Right");
|
---|
2413 |
|
---|
2414 | #undef CODECDBG_AMP
|
---|
2415 | }
|
---|
2416 |
|
---|
2417 |
|
---|
2418 | #if 0 /* unused */
|
---|
2419 | static void codecDbgPrintNodeConnections(PCODECDEBUG pInfo, PCODECNODE pNode)
|
---|
2420 | {
|
---|
2421 | if (pNode->node.au32F00_param[0xE] == 0) /* Directly connected to HDA link. */
|
---|
2422 | {
|
---|
2423 | codecDbgPrintf(pInfo, "[HDA LINK]\n");
|
---|
2424 | return;
|
---|
2425 | }
|
---|
2426 | }
|
---|
2427 | #endif
|
---|
2428 |
|
---|
2429 |
|
---|
2430 | static void codecDbgPrintNode(PCODECDEBUG pInfo, PCODECNODE pNode, bool fRecursive)
|
---|
2431 | {
|
---|
2432 | codecDbgPrintf(pInfo, "Node 0x%02x (%02RU8): ", pNode->node.uID, pNode->node.uID);
|
---|
2433 |
|
---|
2434 | if (pNode->node.uID == STAC9220_NID_ROOT)
|
---|
2435 | CODECDBG_PRINT("ROOT\n");
|
---|
2436 | else if (pNode->node.uID == STAC9220_NID_AFG)
|
---|
2437 | {
|
---|
2438 | CODECDBG_PRINT("AFG\n");
|
---|
2439 | CODECDBG_INDENT
|
---|
2440 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2441 | codecDbgPrintNodeRegF05(pInfo, pNode->afg.u32F05_param);
|
---|
2442 | CODECDBG_UNINDENT
|
---|
2443 | }
|
---|
2444 | else if (hdaCodecIsPortNode(pInfo->pThis, pNode->node.uID))
|
---|
2445 | CODECDBG_PRINT("PORT\n");
|
---|
2446 | else if (hdaCodecIsDacNode(pInfo->pThis, pNode->node.uID))
|
---|
2447 | {
|
---|
2448 | CODECDBG_PRINT("DAC\n");
|
---|
2449 | CODECDBG_INDENT
|
---|
2450 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2451 | codecDbgPrintNodeRegF05(pInfo, pNode->dac.u32F05_param);
|
---|
2452 | codecDbgPrintNodeRegA (pInfo, pNode->dac.u32A_param);
|
---|
2453 | codecDbgPrintNodeAmp (pInfo, pNode->dac.B_params, 0, AMPLIFIER_OUT);
|
---|
2454 | CODECDBG_UNINDENT
|
---|
2455 | }
|
---|
2456 | else if (hdaCodecIsAdcVolNode(pInfo->pThis, pNode->node.uID))
|
---|
2457 | {
|
---|
2458 | CODECDBG_PRINT("ADC VOLUME\n");
|
---|
2459 | CODECDBG_INDENT
|
---|
2460 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2461 | codecDbgPrintNodeRegA (pInfo, pNode->adcvol.u32A_params);
|
---|
2462 | codecDbgPrintNodeAmp (pInfo, pNode->adcvol.B_params, 0, AMPLIFIER_IN);
|
---|
2463 | CODECDBG_UNINDENT
|
---|
2464 | }
|
---|
2465 | else if (hdaCodecIsAdcNode(pInfo->pThis, pNode->node.uID))
|
---|
2466 | {
|
---|
2467 | CODECDBG_PRINT("ADC\n");
|
---|
2468 | CODECDBG_INDENT
|
---|
2469 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2470 | codecDbgPrintNodeRegF05(pInfo, pNode->adc.u32F05_param);
|
---|
2471 | codecDbgPrintNodeRegA (pInfo, pNode->adc.u32A_param);
|
---|
2472 | codecDbgPrintNodeAmp (pInfo, pNode->adc.B_params, 0, AMPLIFIER_IN);
|
---|
2473 | CODECDBG_UNINDENT
|
---|
2474 | }
|
---|
2475 | else if (hdaCodecIsAdcMuxNode(pInfo->pThis, pNode->node.uID))
|
---|
2476 | {
|
---|
2477 | CODECDBG_PRINT("ADC MUX\n");
|
---|
2478 | CODECDBG_INDENT
|
---|
2479 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2480 | codecDbgPrintNodeRegA (pInfo, pNode->adcmux.u32A_param);
|
---|
2481 | codecDbgPrintNodeAmp (pInfo, pNode->adcmux.B_params, 0, AMPLIFIER_IN);
|
---|
2482 | CODECDBG_UNINDENT
|
---|
2483 | }
|
---|
2484 | else if (hdaCodecIsPcbeepNode(pInfo->pThis, pNode->node.uID))
|
---|
2485 | CODECDBG_PRINT("PC BEEP\n");
|
---|
2486 | else if (hdaCodecIsSpdifOutNode(pInfo->pThis, pNode->node.uID))
|
---|
2487 | CODECDBG_PRINT("SPDIF OUT\n");
|
---|
2488 | else if (hdaCodecIsSpdifInNode(pInfo->pThis, pNode->node.uID))
|
---|
2489 | CODECDBG_PRINT("SPDIF IN\n");
|
---|
2490 | else if (hdaCodecIsDigInPinNode(pInfo->pThis, pNode->node.uID))
|
---|
2491 | CODECDBG_PRINT("DIGITAL IN PIN\n");
|
---|
2492 | else if (hdaCodecIsDigOutPinNode(pInfo->pThis, pNode->node.uID))
|
---|
2493 | CODECDBG_PRINT("DIGITAL OUT PIN\n");
|
---|
2494 | else if (hdaCodecIsCdNode(pInfo->pThis, pNode->node.uID))
|
---|
2495 | CODECDBG_PRINT("CD\n");
|
---|
2496 | else if (hdaCodecIsVolKnobNode(pInfo->pThis, pNode->node.uID))
|
---|
2497 | CODECDBG_PRINT("VOLUME KNOB\n");
|
---|
2498 | else if (hdaCodecIsReservedNode(pInfo->pThis, pNode->node.uID))
|
---|
2499 | CODECDBG_PRINT("RESERVED\n");
|
---|
2500 | else
|
---|
2501 | CODECDBG_PRINT("UNKNOWN TYPE 0x%x\n", pNode->node.uID);
|
---|
2502 |
|
---|
2503 | if (fRecursive)
|
---|
2504 | {
|
---|
2505 | #define CODECDBG_PRINT_CONLIST_ENTRY(_aNode, _aEntry) \
|
---|
2506 | if (cCnt >= _aEntry) \
|
---|
2507 | { \
|
---|
2508 | const uint8_t uID = RT_BYTE##_aEntry(_aNode->node.au32F02_param[0x0]); \
|
---|
2509 | if (pNode->node.uID == uID) \
|
---|
2510 | codecDbgPrintNode(pInfo, _aNode, false /* fRecursive */); \
|
---|
2511 | }
|
---|
2512 |
|
---|
2513 | /* Slow recursion, but this is debug stuff anyway. */
|
---|
2514 | for (uint8_t i = 0; i < pInfo->pThis->cTotalNodes; i++)
|
---|
2515 | {
|
---|
2516 | const PCODECNODE pSubNode = &pInfo->pThis->aNodes[i];
|
---|
2517 | if (pSubNode->node.uID == pNode->node.uID)
|
---|
2518 | continue;
|
---|
2519 |
|
---|
2520 | const uint8_t cCnt = CODEC_F00_0E_COUNT(pSubNode->node.au32F00_param[0xE]);
|
---|
2521 | if (cCnt == 0) /* No connections present? Skip. */
|
---|
2522 | continue;
|
---|
2523 |
|
---|
2524 | CODECDBG_INDENT
|
---|
2525 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 1)
|
---|
2526 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 2)
|
---|
2527 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 3)
|
---|
2528 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 4)
|
---|
2529 | CODECDBG_UNINDENT
|
---|
2530 | }
|
---|
2531 |
|
---|
2532 | #undef CODECDBG_PRINT_CONLIST_ENTRY
|
---|
2533 | }
|
---|
2534 | }
|
---|
2535 |
|
---|
2536 |
|
---|
2537 | /**
|
---|
2538 | * Worker for hdaR3DbgInfoCodecNodes implementing the 'hdcnodes' info item.
|
---|
2539 | */
|
---|
2540 | DECLHIDDEN(void) hdaR3CodecDbgListNodes(PHDACODECR3 pThis, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
2541 | {
|
---|
2542 | RT_NOREF(pszArgs);
|
---|
2543 |
|
---|
2544 | pHlp->pfnPrintf(pHlp, "HDA LINK / INPUTS\n");
|
---|
2545 |
|
---|
2546 | CODECDEBUG DbgInfo;
|
---|
2547 | DbgInfo.pHlp = pHlp;
|
---|
2548 | DbgInfo.pThis = pThis;
|
---|
2549 | DbgInfo.uLevel = 0;
|
---|
2550 |
|
---|
2551 | PCODECDEBUG pInfo = &DbgInfo;
|
---|
2552 |
|
---|
2553 | CODECDBG_INDENT
|
---|
2554 | for (uint8_t i = 0; i < pThis->cTotalNodes; i++)
|
---|
2555 | {
|
---|
2556 | PCODECNODE pNode = &pThis->aNodes[i];
|
---|
2557 |
|
---|
2558 | /* Start with all nodes which have connection entries set. */
|
---|
2559 | if (CODEC_F00_0E_COUNT(pNode->node.au32F00_param[0xE]))
|
---|
2560 | codecDbgPrintNode(&DbgInfo, pNode, true /* fRecursive */);
|
---|
2561 | }
|
---|
2562 | CODECDBG_UNINDENT
|
---|
2563 | }
|
---|
2564 |
|
---|
2565 |
|
---|
2566 | /**
|
---|
2567 | * Worker for hdaR3DbgInfoCodecSelector implementing the 'hdcselector' info item.
|
---|
2568 | */
|
---|
2569 | DECLHIDDEN(void) hdaR3CodecDbgSelector(PHDACODECR3 pThis, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
2570 | {
|
---|
2571 | RT_NOREF(pThis, pHlp, pszArgs);
|
---|
2572 | }
|
---|
2573 |
|
---|
2574 |
|
---|
2575 | #if 0 /* unused */
|
---|
2576 | static DECLCALLBACK(void) stac9220DbgNodes(PHDACODECR3 pThis, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
2577 | {
|
---|
2578 | RT_NOREF(pszArgs);
|
---|
2579 | uint8_t const cTotalNodes = RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
2580 | for (uint8_t i = 1; i < cTotalNodes; i++)
|
---|
2581 | {
|
---|
2582 | PCODECNODE pNode = &pThis->aNodes[i];
|
---|
2583 | AMPLIFIER *pAmp = &pNode->dac.B_params;
|
---|
2584 |
|
---|
2585 | uint8_t lVol = AMPLIFIER_REGISTER(*pAmp, AMPLIFIER_OUT, AMPLIFIER_LEFT, 0) & 0x7f;
|
---|
2586 | uint8_t rVol = AMPLIFIER_REGISTER(*pAmp, AMPLIFIER_OUT, AMPLIFIER_RIGHT, 0) & 0x7f;
|
---|
2587 |
|
---|
2588 | pHlp->pfnPrintf(pHlp, "0x%x: lVol=%RU8, rVol=%RU8\n", i, lVol, rVol);
|
---|
2589 | }
|
---|
2590 | }
|
---|
2591 | #endif
|
---|
2592 |
|
---|
2593 |
|
---|
2594 | /*********************************************************************************************************************************
|
---|
2595 | * Stream and State Management *
|
---|
2596 | *********************************************************************************************************************************/
|
---|
2597 |
|
---|
2598 | int hdaR3CodecAddStream(PHDACODECR3 pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg)
|
---|
2599 | {
|
---|
2600 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2601 | AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
|
---|
2602 |
|
---|
2603 | int rc = VINF_SUCCESS;
|
---|
2604 |
|
---|
2605 | switch (enmMixerCtl)
|
---|
2606 | {
|
---|
2607 | case PDMAUDIOMIXERCTL_VOLUME_MASTER:
|
---|
2608 | case PDMAUDIOMIXERCTL_FRONT:
|
---|
2609 | #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
|
---|
2610 | case PDMAUDIOMIXERCTL_CENTER_LFE:
|
---|
2611 | case PDMAUDIOMIXERCTL_REAR:
|
---|
2612 | #endif
|
---|
2613 | break;
|
---|
2614 |
|
---|
2615 | case PDMAUDIOMIXERCTL_LINE_IN:
|
---|
2616 | #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2617 | case PDMAUDIOMIXERCTL_MIC_IN:
|
---|
2618 | #endif
|
---|
2619 | break;
|
---|
2620 |
|
---|
2621 | default:
|
---|
2622 | AssertMsgFailed(("Mixer control %#x not implemented\n", enmMixerCtl));
|
---|
2623 | rc = VERR_NOT_IMPLEMENTED;
|
---|
2624 | break;
|
---|
2625 | }
|
---|
2626 |
|
---|
2627 | if (RT_SUCCESS(rc))
|
---|
2628 | rc = hdaR3MixerAddStream(pThis, enmMixerCtl, pCfg);
|
---|
2629 |
|
---|
2630 | LogFlowFuncLeaveRC(rc);
|
---|
2631 | return rc;
|
---|
2632 | }
|
---|
2633 |
|
---|
2634 |
|
---|
2635 | int hdaR3CodecRemoveStream(PHDACODECR3 pThis, PDMAUDIOMIXERCTL enmMixerCtl, bool fImmediate)
|
---|
2636 | {
|
---|
2637 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2638 |
|
---|
2639 | int rc = hdaR3MixerRemoveStream(pThis, enmMixerCtl, fImmediate);
|
---|
2640 |
|
---|
2641 | LogFlowFuncLeaveRC(rc);
|
---|
2642 | return rc;
|
---|
2643 | }
|
---|
2644 |
|
---|
2645 |
|
---|
2646 | /**
|
---|
2647 | * Saved the codec state.
|
---|
2648 | *
|
---|
2649 | * @returns VBox status code.
|
---|
2650 | * @param pDevIns The device instance of the HDA device.
|
---|
2651 | * @param pThis The codec instance data.
|
---|
2652 | * @param pSSM The saved state handle.
|
---|
2653 | */
|
---|
2654 | int hdaCodecSaveState(PPDMDEVINS pDevIns, PHDACODECR3 pThis, PSSMHANDLE pSSM)
|
---|
2655 | {
|
---|
2656 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
2657 | AssertLogRelMsgReturn(pThis->cTotalNodes == STAC9221_NUM_NODES, ("cTotalNodes=%#x, should be 0x1c", pThis->cTotalNodes),
|
---|
2658 | VERR_INTERNAL_ERROR);
|
---|
2659 | pHlp->pfnSSMPutU32(pSSM, pThis->cTotalNodes);
|
---|
2660 | for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
|
---|
2661 | pHlp->pfnSSMPutStructEx(pSSM, &pThis->aNodes[idxNode].SavedState, sizeof(pThis->aNodes[idxNode].SavedState),
|
---|
2662 | 0 /*fFlags*/, g_aCodecNodeFields, NULL /*pvUser*/);
|
---|
2663 | return VINF_SUCCESS;
|
---|
2664 | }
|
---|
2665 |
|
---|
2666 |
|
---|
2667 | /**
|
---|
2668 | * Loads the codec state.
|
---|
2669 | *
|
---|
2670 | * @returns VBox status code.
|
---|
2671 | * @param pDevIns The device instance of the HDA device.
|
---|
2672 | * @param pThis The codec instance data.
|
---|
2673 | * @param pSSM The saved state handle.
|
---|
2674 | * @param uVersion The state version.
|
---|
2675 | */
|
---|
2676 | int hdaR3CodecLoadState(PPDMDEVINS pDevIns, PHDACODECR3 pThis, PSSMHANDLE pSSM, uint32_t uVersion)
|
---|
2677 | {
|
---|
2678 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
2679 | PCSSMFIELD pFields = NULL;
|
---|
2680 | uint32_t fFlags = 0;
|
---|
2681 | if (uVersion >= HDA_SAVED_STATE_VERSION_4)
|
---|
2682 | {
|
---|
2683 | /* Since version 4 a flexible node count is supported. */
|
---|
2684 | uint32_t cNodes;
|
---|
2685 | int rc2 = pHlp->pfnSSMGetU32(pSSM, &cNodes);
|
---|
2686 | AssertRCReturn(rc2, rc2);
|
---|
2687 | AssertReturn(cNodes == 0x1c, VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
2688 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2689 |
|
---|
2690 | pFields = g_aCodecNodeFields;
|
---|
2691 | fFlags = 0;
|
---|
2692 | }
|
---|
2693 | else if (uVersion >= HDA_SAVED_STATE_VERSION_2)
|
---|
2694 | {
|
---|
2695 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2696 | pFields = g_aCodecNodeFields;
|
---|
2697 | fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
|
---|
2698 | }
|
---|
2699 | else if (uVersion >= HDA_SAVED_STATE_VERSION_1)
|
---|
2700 | {
|
---|
2701 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2702 | pFields = g_aCodecNodeFieldsV1;
|
---|
2703 | fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
|
---|
2704 | }
|
---|
2705 | else
|
---|
2706 | AssertFailedReturn(VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
|
---|
2707 |
|
---|
2708 | for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
|
---|
2709 | {
|
---|
2710 | uint8_t idOld = pThis->aNodes[idxNode].SavedState.Core.uID;
|
---|
2711 | int rc = pHlp->pfnSSMGetStructEx(pSSM, &pThis->aNodes[idxNode].SavedState, sizeof(pThis->aNodes[idxNode].SavedState),
|
---|
2712 | fFlags, pFields, NULL);
|
---|
2713 | AssertRCReturn(rc, rc);
|
---|
2714 | AssertLogRelMsgReturn(idOld == pThis->aNodes[idxNode].SavedState.Core.uID,
|
---|
2715 | ("loaded %#x, expected %#x\n", pThis->aNodes[idxNode].SavedState.Core.uID, idOld),
|
---|
2716 | VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
2717 | }
|
---|
2718 |
|
---|
2719 | /*
|
---|
2720 | * Update stuff after changing the state.
|
---|
2721 | */
|
---|
2722 | PCODECNODE pNode;
|
---|
2723 | if (hdaCodecIsDacNode(pThis, pThis->u8DacLineOut))
|
---|
2724 | {
|
---|
2725 | pNode = &pThis->aNodes[pThis->u8DacLineOut];
|
---|
2726 | hdaR3CodecToAudVolume(pThis, pNode, &pNode->dac.B_params, PDMAUDIOMIXERCTL_FRONT);
|
---|
2727 | }
|
---|
2728 | else if (hdaCodecIsSpdifOutNode(pThis, pThis->u8DacLineOut))
|
---|
2729 | {
|
---|
2730 | pNode = &pThis->aNodes[pThis->u8DacLineOut];
|
---|
2731 | hdaR3CodecToAudVolume(pThis, pNode, &pNode->spdifout.B_params, PDMAUDIOMIXERCTL_FRONT);
|
---|
2732 | }
|
---|
2733 |
|
---|
2734 | pNode = &pThis->aNodes[pThis->u8AdcVolsLineIn];
|
---|
2735 | hdaR3CodecToAudVolume(pThis, pNode, &pNode->adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2736 |
|
---|
2737 | LogFlowFuncLeaveRC(VINF_SUCCESS);
|
---|
2738 | return VINF_SUCCESS;
|
---|
2739 | }
|
---|
2740 |
|
---|
2741 |
|
---|
2742 | /**
|
---|
2743 | * Powers off the codec (ring-3).
|
---|
2744 | *
|
---|
2745 | * @param pThis The codec data.
|
---|
2746 | */
|
---|
2747 | void hdaR3CodecPowerOff(PHDACODECR3 pThis)
|
---|
2748 | {
|
---|
2749 | LogFlowFuncEnter();
|
---|
2750 | LogRel2(("HDA: Powering off codec ...\n"));
|
---|
2751 |
|
---|
2752 | int rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_FRONT, true /*fImmediate*/);
|
---|
2753 | AssertRC(rc2);
|
---|
2754 | #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
|
---|
2755 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, true /*fImmediate*/);
|
---|
2756 | AssertRC(rc2);
|
---|
2757 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_REAR, true /*fImmediate*/);
|
---|
2758 | AssertRC(rc2);
|
---|
2759 | #endif
|
---|
2760 |
|
---|
2761 | #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2762 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_MIC_IN, true /*fImmediate*/);
|
---|
2763 | AssertRC(rc2);
|
---|
2764 | #endif
|
---|
2765 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_LINE_IN, true /*fImmediate*/);
|
---|
2766 | AssertRC(rc2);
|
---|
2767 | }
|
---|
2768 |
|
---|
2769 |
|
---|
2770 | /**
|
---|
2771 | * Constructs a codec (ring-3).
|
---|
2772 | *
|
---|
2773 | * @returns VBox status code.
|
---|
2774 | * @param pDevIns The associated device instance.
|
---|
2775 | * @param pThis The codec data.
|
---|
2776 | * @param uLUN Device LUN to assign.
|
---|
2777 | * @param pCfg CFGM node to use for configuration.
|
---|
2778 | */
|
---|
2779 | int hdaR3CodecConstruct(PPDMDEVINS pDevIns, PHDACODECR3 pThis, uint16_t uLUN, PCFGMNODE pCfg)
|
---|
2780 | {
|
---|
2781 | AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
|
---|
2782 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2783 | AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
|
---|
2784 |
|
---|
2785 | pThis->id = uLUN;
|
---|
2786 | pThis->enmType = CODECTYPE_STAC9220; /** @todo Make this dynamic. */
|
---|
2787 |
|
---|
2788 | int rc;
|
---|
2789 |
|
---|
2790 | switch (pThis->enmType)
|
---|
2791 | {
|
---|
2792 | case CODECTYPE_STAC9220:
|
---|
2793 | {
|
---|
2794 | rc = stac9220Construct(pThis);
|
---|
2795 | AssertRCReturn(rc, rc);
|
---|
2796 | break;
|
---|
2797 | }
|
---|
2798 |
|
---|
2799 | default:
|
---|
2800 | AssertFailedReturn(VERR_NOT_IMPLEMENTED);
|
---|
2801 | break;
|
---|
2802 | }
|
---|
2803 |
|
---|
2804 | /*
|
---|
2805 | * Set initial volume.
|
---|
2806 | */
|
---|
2807 | PCODECNODE pNode = &pThis->aNodes[pThis->u8DacLineOut];
|
---|
2808 | rc = hdaR3CodecToAudVolume(pThis, pNode, &pNode->dac.B_params, PDMAUDIOMIXERCTL_FRONT);
|
---|
2809 | AssertRCReturn(rc, rc);
|
---|
2810 |
|
---|
2811 | pNode = &pThis->aNodes[pThis->u8AdcVolsLineIn];
|
---|
2812 | rc = hdaR3CodecToAudVolume(pThis, pNode, &pNode->adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2813 | AssertRCReturn(rc, rc);
|
---|
2814 |
|
---|
2815 | #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2816 | # error "Implement mic-in support!"
|
---|
2817 | #endif
|
---|
2818 |
|
---|
2819 | /*
|
---|
2820 | * Statistics
|
---|
2821 | */
|
---|
2822 | PDMDevHlpSTAMRegister(pDevIns, &pThis->StatLookupsR3, STAMTYPE_COUNTER, "Codec/LookupsR0", STAMUNIT_OCCURENCES, "Number of R0 codecLookup calls");
|
---|
2823 | #if 0 /* Codec is not yet kosher enough for ring-0. @bugref{9890c64} */
|
---|
2824 | PDMDevHlpSTAMRegister(pDevIns, &pThis->StatLookupsR0, STAMTYPE_COUNTER, "Codec/LookupsR3", STAMUNIT_OCCURENCES, "Number of R3 codecLookup calls");
|
---|
2825 | #endif
|
---|
2826 |
|
---|
2827 | return rc;
|
---|
2828 | }
|
---|
2829 |
|
---|
2830 |
|
---|
2831 | /**
|
---|
2832 | * Destructs a codec.
|
---|
2833 | *
|
---|
2834 | * @param pThis Codec to destruct.
|
---|
2835 | */
|
---|
2836 | void hdaCodecDestruct(PHDACODECR3 pThis)
|
---|
2837 | {
|
---|
2838 | LogFlowFuncEnter();
|
---|
2839 |
|
---|
2840 | /* Nothing to do here atm. */
|
---|
2841 | RT_NOREF(pThis);
|
---|
2842 | }
|
---|
2843 |
|
---|
2844 |
|
---|
2845 | /**
|
---|
2846 | * Resets a codec.
|
---|
2847 | *
|
---|
2848 | * @param pThis Codec to reset.
|
---|
2849 | */
|
---|
2850 | void hdaCodecReset(PHDACODECR3 pThis)
|
---|
2851 | {
|
---|
2852 | switch (pThis->enmType)
|
---|
2853 | {
|
---|
2854 | case CODECTYPE_STAC9220:
|
---|
2855 | stac9220Reset(pThis);
|
---|
2856 | break;
|
---|
2857 |
|
---|
2858 | default:
|
---|
2859 | AssertFailed();
|
---|
2860 | break;
|
---|
2861 | }
|
---|
2862 | }
|
---|
2863 |
|
---|