1 | /* $Id: DevHdaCodec.cpp 90145 2021-07-09 23:35:18Z 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 | uint16_t *pafNodeClassifications = (uint16_t *)&pThis->afNodeClassifications[0];
|
---|
801 | #define STAC9220WIDGET(a_Type) do { \
|
---|
802 | AssertCompile(RT_ELEMENTS(g_abStac9220##a_Type##s) <= RT_ELEMENTS(pThis->ab##a_Type##s)); \
|
---|
803 | uint8_t *pbDst = (uint8_t *)&pThis->ab##a_Type##s[0]; \
|
---|
804 | uintptr_t i; \
|
---|
805 | for (i = 0; i < RT_ELEMENTS(g_abStac9220##a_Type##s); i++) \
|
---|
806 | { \
|
---|
807 | uint8_t const idNode = g_abStac9220##a_Type##s[i]; \
|
---|
808 | if (idNode != 0) \
|
---|
809 | { \
|
---|
810 | AssertReturn(idNode < RT_ELEMENTS(pThis->aNodes), VERR_INTERNAL_ERROR_3); \
|
---|
811 | pafNodeClassifications[idNode] |= RT_CONCAT(CODEC_NODE_CLS_,a_Type); \
|
---|
812 | } \
|
---|
813 | pbDst[i] = idNode; \
|
---|
814 | } \
|
---|
815 | for (; i < RT_ELEMENTS(pThis->ab##a_Type##s); i++) \
|
---|
816 | pbDst[i] = 0; \
|
---|
817 | } while (0)
|
---|
818 | STAC9220WIDGET(Port);
|
---|
819 | STAC9220WIDGET(Dac);
|
---|
820 | STAC9220WIDGET(Adc);
|
---|
821 | STAC9220WIDGET(AdcVol);
|
---|
822 | STAC9220WIDGET(AdcMux);
|
---|
823 | STAC9220WIDGET(Pcbeep);
|
---|
824 | STAC9220WIDGET(SpdifIn);
|
---|
825 | STAC9220WIDGET(SpdifOut);
|
---|
826 | STAC9220WIDGET(DigInPin);
|
---|
827 | STAC9220WIDGET(DigOutPin);
|
---|
828 | STAC9220WIDGET(Cd);
|
---|
829 | STAC9220WIDGET(VolKnob);
|
---|
830 | STAC9220WIDGET(Reserved);
|
---|
831 | #undef STAC9220WIDGET
|
---|
832 |
|
---|
833 | AssertCompile(STAC9221_NUM_NODES <= RT_ELEMENTS(pThis->aNodes));
|
---|
834 | pThis->cTotalNodes = STAC9221_NUM_NODES;
|
---|
835 |
|
---|
836 | pThis->u8AdcVolsLineIn = STAC9220_NID_AMP_ADC0;
|
---|
837 | pThis->u8DacLineOut = STAC9220_NID_DAC1;
|
---|
838 |
|
---|
839 | /*
|
---|
840 | * Initialize all codec nodes.
|
---|
841 | * This is specific to the codec, so do this here.
|
---|
842 | *
|
---|
843 | * Note: Do *not* call stac9220Reset() here, as this would not
|
---|
844 | * initialize the node default configuration values then!
|
---|
845 | */
|
---|
846 | for (uint8_t i = 0; i < STAC9221_NUM_NODES; i++)
|
---|
847 | stac9220NodeReset(pThis, i, &pThis->aNodes[i]);
|
---|
848 |
|
---|
849 | /* Common root node initializers. */
|
---|
850 | pThis->aNodes[STAC9220_NID_ROOT].root.node.au32F00_param[0] = CODEC_MAKE_F00_00(pThis->idVendor, pThis->idDevice);
|
---|
851 | pThis->aNodes[STAC9220_NID_ROOT].root.node.au32F00_param[4] = CODEC_MAKE_F00_04(0x1, 0x1);
|
---|
852 |
|
---|
853 | /* Common AFG node initializers. */
|
---|
854 | pThis->aNodes[STAC9220_NID_AFG].afg.node.au32F00_param[0x4] = CODEC_MAKE_F00_04(0x2, STAC9221_NUM_NODES - 2);
|
---|
855 | pThis->aNodes[STAC9220_NID_AFG].afg.node.au32F00_param[0x5] = CODEC_MAKE_F00_05(1, CODEC_F00_05_AFG);
|
---|
856 | pThis->aNodes[STAC9220_NID_AFG].afg.node.au32F00_param[0xA] = CODEC_F00_0A_44_1KHZ | CODEC_F00_0A_16_BIT;
|
---|
857 | pThis->aNodes[STAC9220_NID_AFG].afg.u32F20_param = CODEC_MAKE_F20(pThis->idVendor, pThis->bBSKU, pThis->idAssembly);
|
---|
858 |
|
---|
859 | return VINF_SUCCESS;
|
---|
860 | }
|
---|
861 |
|
---|
862 |
|
---|
863 | /*********************************************************************************************************************************
|
---|
864 | * Common Helpers *
|
---|
865 | *********************************************************************************************************************************/
|
---|
866 |
|
---|
867 | /*
|
---|
868 | * Some generic predicate functions.
|
---|
869 | */
|
---|
870 | #define HDA_CODEC_IS_NODE_OF_TYPE_FUNC(a_Type) \
|
---|
871 | DECLINLINE(bool) hdaCodecIs##a_Type##Node(PHDACODECR3 pThis, uint8_t idNode) \
|
---|
872 | { \
|
---|
873 | Assert(idNode < RT_ELEMENTS(pThis->afNodeClassifications)); \
|
---|
874 | Assert( (memchr(&pThis->RT_CONCAT3(ab,a_Type,s)[0], idNode, sizeof(pThis->RT_CONCAT3(ab,a_Type,s))) != NULL) \
|
---|
875 | == RT_BOOL(pThis->afNodeClassifications[idNode] & RT_CONCAT(CODEC_NODE_CLS_,a_Type))); \
|
---|
876 | return RT_BOOL(pThis->afNodeClassifications[idNode] & RT_CONCAT(CODEC_NODE_CLS_,a_Type)); \
|
---|
877 | }
|
---|
878 | /* hdaCodecIsPortNode */
|
---|
879 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Port)
|
---|
880 | /* hdaCodecIsDacNode */
|
---|
881 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Dac)
|
---|
882 | /* hdaCodecIsAdcVolNode */
|
---|
883 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(AdcVol)
|
---|
884 | /* hdaCodecIsAdcNode */
|
---|
885 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Adc)
|
---|
886 | /* hdaCodecIsAdcMuxNode */
|
---|
887 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(AdcMux)
|
---|
888 | /* hdaCodecIsPcbeepNode */
|
---|
889 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Pcbeep)
|
---|
890 | /* hdaCodecIsSpdifOutNode */
|
---|
891 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(SpdifOut)
|
---|
892 | /* hdaCodecIsSpdifInNode */
|
---|
893 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(SpdifIn)
|
---|
894 | /* hdaCodecIsDigInPinNode */
|
---|
895 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(DigInPin)
|
---|
896 | /* hdaCodecIsDigOutPinNode */
|
---|
897 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(DigOutPin)
|
---|
898 | /* hdaCodecIsCdNode */
|
---|
899 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Cd)
|
---|
900 | /* hdaCodecIsVolKnobNode */
|
---|
901 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(VolKnob)
|
---|
902 | /* hdaCodecIsReservedNode */
|
---|
903 | HDA_CODEC_IS_NODE_OF_TYPE_FUNC(Reserved)
|
---|
904 |
|
---|
905 |
|
---|
906 | /*
|
---|
907 | * Misc helpers.
|
---|
908 | */
|
---|
909 | static int hdaR3CodecToAudVolume(PHDACODECR3 pThis, PCODECNODE pNode, AMPLIFIER *pAmp, PDMAUDIOMIXERCTL enmMixerCtl)
|
---|
910 | {
|
---|
911 | RT_NOREF(pNode);
|
---|
912 |
|
---|
913 | uint8_t iDir;
|
---|
914 | switch (enmMixerCtl)
|
---|
915 | {
|
---|
916 | case PDMAUDIOMIXERCTL_VOLUME_MASTER:
|
---|
917 | case PDMAUDIOMIXERCTL_FRONT:
|
---|
918 | iDir = AMPLIFIER_OUT;
|
---|
919 | break;
|
---|
920 | case PDMAUDIOMIXERCTL_LINE_IN:
|
---|
921 | case PDMAUDIOMIXERCTL_MIC_IN:
|
---|
922 | iDir = AMPLIFIER_IN;
|
---|
923 | break;
|
---|
924 | default:
|
---|
925 | AssertMsgFailedReturn(("Invalid mixer control %RU32\n", enmMixerCtl), VERR_INVALID_PARAMETER);
|
---|
926 | break;
|
---|
927 | }
|
---|
928 |
|
---|
929 | int iMute;
|
---|
930 | iMute = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_LEFT, 0) & RT_BIT(7);
|
---|
931 | iMute |= AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_RIGHT, 0) & RT_BIT(7);
|
---|
932 | iMute >>=7;
|
---|
933 | iMute &= 0x1;
|
---|
934 |
|
---|
935 | uint8_t bLeft = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_LEFT, 0) & 0x7f;
|
---|
936 | uint8_t bRight = AMPLIFIER_REGISTER(*pAmp, iDir, AMPLIFIER_RIGHT, 0) & 0x7f;
|
---|
937 |
|
---|
938 | /*
|
---|
939 | * The STAC9220 volume controls have 0 to -96dB attenuation range in 128 steps.
|
---|
940 | * We have 0 to -96dB range in 256 steps. HDA volume setting of 127 must map
|
---|
941 | * to 255 internally (0dB), while HDA volume setting of 0 (-96dB) should map
|
---|
942 | * to 1 (rather than zero) internally.
|
---|
943 | */
|
---|
944 | bLeft = (bLeft + 1) * (2 * 255) / 256;
|
---|
945 | bRight = (bRight + 1) * (2 * 255) / 256;
|
---|
946 |
|
---|
947 | PDMAUDIOVOLUME Vol;
|
---|
948 | PDMAudioVolumeInitFromStereo(&Vol, RT_BOOL(iMute), bLeft, bRight);
|
---|
949 |
|
---|
950 | LogFunc(("[NID0x%02x] %RU8/%RU8%s\n", pNode->node.uID, bLeft, bRight, Vol.fMuted ? "- Muted!" : ""));
|
---|
951 | LogRel2(("HDA: Setting volume for mixer control '%s' to %RU8/%RU8%s\n",
|
---|
952 | PDMAudioMixerCtlGetName(enmMixerCtl), bLeft, bRight, Vol.fMuted ? "- Muted!" : ""));
|
---|
953 |
|
---|
954 | return hdaR3MixerSetVolume(pThis, enmMixerCtl, &Vol);
|
---|
955 | }
|
---|
956 |
|
---|
957 |
|
---|
958 | DECLINLINE(void) hdaCodecSetRegister(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset, uint32_t mask)
|
---|
959 | {
|
---|
960 | Assert((pu32Reg && u8Offset < 32));
|
---|
961 | *pu32Reg &= ~(mask << u8Offset);
|
---|
962 | *pu32Reg |= (u32Cmd & mask) << u8Offset;
|
---|
963 | }
|
---|
964 |
|
---|
965 | DECLINLINE(void) hdaCodecSetRegisterU8(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset)
|
---|
966 | {
|
---|
967 | hdaCodecSetRegister(pu32Reg, u32Cmd, u8Offset, CODEC_VERB_8BIT_DATA);
|
---|
968 | }
|
---|
969 |
|
---|
970 | DECLINLINE(void) hdaCodecSetRegisterU16(uint32_t *pu32Reg, uint32_t u32Cmd, uint8_t u8Offset)
|
---|
971 | {
|
---|
972 | hdaCodecSetRegister(pu32Reg, u32Cmd, u8Offset, CODEC_VERB_16BIT_DATA);
|
---|
973 | }
|
---|
974 |
|
---|
975 |
|
---|
976 | /*********************************************************************************************************************************
|
---|
977 | * Verb Processor Functions. *
|
---|
978 | *********************************************************************************************************************************/
|
---|
979 | #if 0 /* unused */
|
---|
980 |
|
---|
981 | /**
|
---|
982 | * @interface_method_impl{CODECVERB,pfn, Unimplemented}
|
---|
983 | */
|
---|
984 | static DECLCALLBACK(int) vrbProcUnimplemented(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
985 | {
|
---|
986 | RT_NOREF(pThis, uCmd);
|
---|
987 | LogFlowFunc(("uCmd(raw:%x: cad:%x, d:%c, nid:%x, verb:%x)\n", uCmd,
|
---|
988 | CODEC_CAD(uCmd), CODEC_DIRECT(uCmd) ? 'N' : 'Y', CODEC_NID(uCmd), CODEC_VERBDATA(uCmd)));
|
---|
989 | *puResp = 0;
|
---|
990 | return VINF_SUCCESS;
|
---|
991 | }
|
---|
992 |
|
---|
993 |
|
---|
994 | /**
|
---|
995 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
996 | */
|
---|
997 | static DECLCALLBACK(int) vrbProcBreak(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
998 | {
|
---|
999 | int rc;
|
---|
1000 | rc = vrbProcUnimplemented(pThis, uCmd, puResp);
|
---|
1001 | *puResp |= CODEC_RESPONSE_UNSOLICITED;
|
---|
1002 | return rc;
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | #endif /* unused */
|
---|
1006 |
|
---|
1007 | /**
|
---|
1008 | * @interface_method_impl{CODECVERB,pfn, b-- }
|
---|
1009 | */
|
---|
1010 | static DECLCALLBACK(int) vrbProcGetAmplifier(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1011 | {
|
---|
1012 | *puResp = 0;
|
---|
1013 |
|
---|
1014 | /* HDA spec 7.3.3.7 Note A */
|
---|
1015 | /** @todo If index out of range response should be 0. */
|
---|
1016 | uint8_t u8Index = CODEC_GET_AMP_DIRECTION(uCmd) == AMPLIFIER_OUT ? 0 : CODEC_GET_AMP_INDEX(uCmd);
|
---|
1017 |
|
---|
1018 | PCODECNODE pNode = &pThis->aNodes[CODEC_NID(uCmd)];
|
---|
1019 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1020 | *puResp = AMPLIFIER_REGISTER(pNode->dac.B_params,
|
---|
1021 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1022 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1023 | u8Index);
|
---|
1024 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1025 | *puResp = AMPLIFIER_REGISTER(pNode->adcvol.B_params,
|
---|
1026 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1027 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1028 | u8Index);
|
---|
1029 | else if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
1030 | *puResp = AMPLIFIER_REGISTER(pNode->adcmux.B_params,
|
---|
1031 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1032 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1033 | u8Index);
|
---|
1034 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1035 | *puResp = AMPLIFIER_REGISTER(pNode->pcbeep.B_params,
|
---|
1036 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1037 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1038 | u8Index);
|
---|
1039 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1040 | *puResp = AMPLIFIER_REGISTER(pNode->port.B_params,
|
---|
1041 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1042 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1043 | u8Index);
|
---|
1044 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1045 | *puResp = AMPLIFIER_REGISTER(pNode->adc.B_params,
|
---|
1046 | CODEC_GET_AMP_DIRECTION(uCmd),
|
---|
1047 | CODEC_GET_AMP_SIDE(uCmd),
|
---|
1048 | u8Index);
|
---|
1049 | else
|
---|
1050 | LogRel2(("HDA: Warning: Unhandled get amplifier command: 0x%x (NID=0x%x [%RU8])\n", uCmd, CODEC_NID(uCmd), CODEC_NID(uCmd)));
|
---|
1051 |
|
---|
1052 | return VINF_SUCCESS;
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 |
|
---|
1056 | /**
|
---|
1057 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
1058 | */
|
---|
1059 | static DECLCALLBACK(int) vrbProcGetParameter(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1060 | {
|
---|
1061 | Assert((uCmd & CODEC_VERB_8BIT_DATA) < CODECNODE_F00_PARAM_LENGTH);
|
---|
1062 | if ((uCmd & CODEC_VERB_8BIT_DATA) >= CODECNODE_F00_PARAM_LENGTH)
|
---|
1063 | {
|
---|
1064 | *puResp = 0;
|
---|
1065 |
|
---|
1066 | LogFlowFunc(("invalid F00 parameter %d\n", (uCmd & CODEC_VERB_8BIT_DATA)));
|
---|
1067 | return VINF_SUCCESS;
|
---|
1068 | }
|
---|
1069 |
|
---|
1070 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].node.au32F00_param[uCmd & CODEC_VERB_8BIT_DATA];
|
---|
1071 | return VINF_SUCCESS;
|
---|
1072 | }
|
---|
1073 |
|
---|
1074 |
|
---|
1075 | /**
|
---|
1076 | * @interface_method_impl{CODECVERB,pfn, f01 }
|
---|
1077 | */
|
---|
1078 | static DECLCALLBACK(int) vrbProcGetConSelectCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1079 | {
|
---|
1080 | *puResp = 0;
|
---|
1081 |
|
---|
1082 | if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
1083 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adcmux.u32F01_param;
|
---|
1084 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1085 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F01_param;
|
---|
1086 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1087 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F01_param;
|
---|
1088 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1089 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F01_param;
|
---|
1090 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1091 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F01_param;
|
---|
1092 | else
|
---|
1093 | LogRel2(("HDA: Warning: Unhandled get connection select control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1094 |
|
---|
1095 | return VINF_SUCCESS;
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 |
|
---|
1099 | /**
|
---|
1100 | * @interface_method_impl{CODECVERB,pfn, 701 }
|
---|
1101 | */
|
---|
1102 | static DECLCALLBACK(int) vrbProcSetConSelectCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1103 | {
|
---|
1104 | *puResp = 0;
|
---|
1105 |
|
---|
1106 | uint32_t *pu32Reg = NULL;
|
---|
1107 | if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
1108 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adcmux.u32F01_param;
|
---|
1109 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1110 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F01_param;
|
---|
1111 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1112 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F01_param;
|
---|
1113 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1114 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F01_param;
|
---|
1115 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1116 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F01_param;
|
---|
1117 | else
|
---|
1118 | LogRel2(("HDA: Warning: Unhandled set connection select control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1119 |
|
---|
1120 | if (pu32Reg)
|
---|
1121 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1122 |
|
---|
1123 | return VINF_SUCCESS;
|
---|
1124 | }
|
---|
1125 |
|
---|
1126 |
|
---|
1127 | /**
|
---|
1128 | * @interface_method_impl{CODECVERB,pfn, f07 }
|
---|
1129 | */
|
---|
1130 | static DECLCALLBACK(int) vrbProcGetPinCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1131 | {
|
---|
1132 | *puResp = 0;
|
---|
1133 |
|
---|
1134 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1135 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F07_param;
|
---|
1136 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1137 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F07_param;
|
---|
1138 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1139 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F07_param;
|
---|
1140 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1141 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F07_param;
|
---|
1142 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1143 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F07_param;
|
---|
1144 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1145 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F07_param;
|
---|
1146 | else
|
---|
1147 | LogRel2(("HDA: Warning: Unhandled get pin control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1148 |
|
---|
1149 | return VINF_SUCCESS;
|
---|
1150 | }
|
---|
1151 |
|
---|
1152 |
|
---|
1153 | /**
|
---|
1154 | * @interface_method_impl{CODECVERB,pfn, 707 }
|
---|
1155 | */
|
---|
1156 | static DECLCALLBACK(int) vrbProcSetPinCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1157 | {
|
---|
1158 | *puResp = 0;
|
---|
1159 |
|
---|
1160 | uint32_t *pu32Reg = NULL;
|
---|
1161 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1162 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F07_param;
|
---|
1163 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1164 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F07_param;
|
---|
1165 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1166 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F07_param;
|
---|
1167 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1168 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F07_param;
|
---|
1169 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1170 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F07_param;
|
---|
1171 | else if ( hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd))
|
---|
1172 | && CODEC_NID(uCmd) == 0x1b)
|
---|
1173 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F07_param;
|
---|
1174 | else
|
---|
1175 | LogRel2(("HDA: Warning: Unhandled set pin control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1176 |
|
---|
1177 | if (pu32Reg)
|
---|
1178 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1179 |
|
---|
1180 | return VINF_SUCCESS;
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 |
|
---|
1184 | /**
|
---|
1185 | * @interface_method_impl{CODECVERB,pfn, f08 }
|
---|
1186 | */
|
---|
1187 | static DECLCALLBACK(int) vrbProcGetUnsolicitedEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1188 | {
|
---|
1189 | *puResp = 0;
|
---|
1190 |
|
---|
1191 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1192 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F08_param;
|
---|
1193 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1194 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1195 | else if ((uCmd) == STAC9220_NID_AFG)
|
---|
1196 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].afg.u32F08_param;
|
---|
1197 | else if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1198 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F08_param;
|
---|
1199 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1200 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F08_param;
|
---|
1201 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1202 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1203 | else
|
---|
1204 | LogRel2(("HDA: Warning: Unhandled get unsolicited enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1205 |
|
---|
1206 | return VINF_SUCCESS;
|
---|
1207 | }
|
---|
1208 |
|
---|
1209 |
|
---|
1210 | /**
|
---|
1211 | * @interface_method_impl{CODECVERB,pfn, 708 }
|
---|
1212 | */
|
---|
1213 | static DECLCALLBACK(int) vrbProcSetUnsolicitedEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1214 | {
|
---|
1215 | *puResp = 0;
|
---|
1216 |
|
---|
1217 | uint32_t *pu32Reg = NULL;
|
---|
1218 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1219 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F08_param;
|
---|
1220 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1221 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1222 | else if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1223 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F08_param;
|
---|
1224 | else if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1225 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F08_param;
|
---|
1226 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1227 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F08_param;
|
---|
1228 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1229 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F08_param;
|
---|
1230 | else
|
---|
1231 | LogRel2(("HDA: Warning: Unhandled set unsolicited enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1232 |
|
---|
1233 | if (pu32Reg)
|
---|
1234 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1235 |
|
---|
1236 | return VINF_SUCCESS;
|
---|
1237 | }
|
---|
1238 |
|
---|
1239 |
|
---|
1240 | /**
|
---|
1241 | * @interface_method_impl{CODECVERB,pfn, f09 }
|
---|
1242 | */
|
---|
1243 | static DECLCALLBACK(int) vrbProcGetPinSense(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1244 | {
|
---|
1245 | *puResp = 0;
|
---|
1246 |
|
---|
1247 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1248 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F09_param;
|
---|
1249 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1250 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F09_param;
|
---|
1251 | else
|
---|
1252 | {
|
---|
1253 | AssertFailed();
|
---|
1254 | LogRel2(("HDA: Warning: Unhandled get pin sense command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1255 | }
|
---|
1256 |
|
---|
1257 | return VINF_SUCCESS;
|
---|
1258 | }
|
---|
1259 |
|
---|
1260 |
|
---|
1261 | /**
|
---|
1262 | * @interface_method_impl{CODECVERB,pfn, 709 }
|
---|
1263 | */
|
---|
1264 | static DECLCALLBACK(int) vrbProcSetPinSense(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1265 | {
|
---|
1266 | *puResp = 0;
|
---|
1267 |
|
---|
1268 | uint32_t *pu32Reg = NULL;
|
---|
1269 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1270 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F09_param;
|
---|
1271 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1272 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F09_param;
|
---|
1273 | else
|
---|
1274 | LogRel2(("HDA: Warning: Unhandled set pin sense command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1275 |
|
---|
1276 | if (pu32Reg)
|
---|
1277 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1278 |
|
---|
1279 | return VINF_SUCCESS;
|
---|
1280 | }
|
---|
1281 |
|
---|
1282 |
|
---|
1283 | /**
|
---|
1284 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
1285 | */
|
---|
1286 | static DECLCALLBACK(int) vrbProcGetConnectionListEntry(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1287 | {
|
---|
1288 | *puResp = 0;
|
---|
1289 |
|
---|
1290 | Assert((uCmd & CODEC_VERB_8BIT_DATA) < CODECNODE_F02_PARAM_LENGTH);
|
---|
1291 | if ((uCmd & CODEC_VERB_8BIT_DATA) >= CODECNODE_F02_PARAM_LENGTH)
|
---|
1292 | {
|
---|
1293 | LogFlowFunc(("access to invalid F02 index %d\n", (uCmd & CODEC_VERB_8BIT_DATA)));
|
---|
1294 | return VINF_SUCCESS;
|
---|
1295 | }
|
---|
1296 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].node.au32F02_param[uCmd & CODEC_VERB_8BIT_DATA];
|
---|
1297 | return VINF_SUCCESS;
|
---|
1298 | }
|
---|
1299 |
|
---|
1300 |
|
---|
1301 | /**
|
---|
1302 | * @interface_method_impl{CODECVERB,pfn, f03 }
|
---|
1303 | */
|
---|
1304 | static DECLCALLBACK(int) vrbProcGetProcessingState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1305 | {
|
---|
1306 | *puResp = 0;
|
---|
1307 |
|
---|
1308 | if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1309 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F03_param;
|
---|
1310 |
|
---|
1311 | return VINF_SUCCESS;
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 |
|
---|
1315 | /**
|
---|
1316 | * @interface_method_impl{CODECVERB,pfn, 703 }
|
---|
1317 | */
|
---|
1318 | static DECLCALLBACK(int) vrbProcSetProcessingState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1319 | {
|
---|
1320 | *puResp = 0;
|
---|
1321 |
|
---|
1322 | if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1323 | hdaCodecSetRegisterU8(&pThis->aNodes[CODEC_NID(uCmd)].adc.u32F03_param, uCmd, 0);
|
---|
1324 | return VINF_SUCCESS;
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 |
|
---|
1328 | /**
|
---|
1329 | * @interface_method_impl{CODECVERB,pfn, f0d }
|
---|
1330 | */
|
---|
1331 | static DECLCALLBACK(int) vrbProcGetDigitalConverter(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1332 | {
|
---|
1333 | *puResp = 0;
|
---|
1334 |
|
---|
1335 | if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1336 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F0d_param;
|
---|
1337 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1338 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F0d_param;
|
---|
1339 | return VINF_SUCCESS;
|
---|
1340 | }
|
---|
1341 |
|
---|
1342 |
|
---|
1343 | static int codecSetDigitalConverter(PHDACODECR3 pThis, uint32_t uCmd, uint8_t u8Offset, uint64_t *puResp)
|
---|
1344 | {
|
---|
1345 | *puResp = 0;
|
---|
1346 |
|
---|
1347 | if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1348 | hdaCodecSetRegisterU8(&pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F0d_param, uCmd, u8Offset);
|
---|
1349 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1350 | hdaCodecSetRegisterU8(&pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F0d_param, uCmd, u8Offset);
|
---|
1351 | return VINF_SUCCESS;
|
---|
1352 | }
|
---|
1353 |
|
---|
1354 |
|
---|
1355 | /**
|
---|
1356 | * @interface_method_impl{CODECVERB,pfn, 70d }
|
---|
1357 | */
|
---|
1358 | static DECLCALLBACK(int) vrbProcSetDigitalConverter1(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1359 | {
|
---|
1360 | return codecSetDigitalConverter(pThis, uCmd, 0, puResp);
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 |
|
---|
1364 | /**
|
---|
1365 | * @interface_method_impl{CODECVERB,pfn, 70e }
|
---|
1366 | */
|
---|
1367 | static DECLCALLBACK(int) vrbProcSetDigitalConverter2(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1368 | {
|
---|
1369 | return codecSetDigitalConverter(pThis, uCmd, 8, puResp);
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 |
|
---|
1373 | /**
|
---|
1374 | * @interface_method_impl{CODECVERB,pfn, f20 }
|
---|
1375 | */
|
---|
1376 | static DECLCALLBACK(int) vrbProcGetSubId(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1377 | {
|
---|
1378 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1379 | uint8_t const cTotalNodes = (uint8_t)RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
1380 | Assert(CODEC_NID(uCmd) < cTotalNodes);
|
---|
1381 | if (CODEC_NID(uCmd) >= cTotalNodes)
|
---|
1382 | {
|
---|
1383 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(uCmd)));
|
---|
1384 | *puResp = 0;
|
---|
1385 | return VINF_SUCCESS;
|
---|
1386 | }
|
---|
1387 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1388 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].afg.u32F20_param;
|
---|
1389 | else
|
---|
1390 | *puResp = 0;
|
---|
1391 | return VINF_SUCCESS;
|
---|
1392 | }
|
---|
1393 |
|
---|
1394 |
|
---|
1395 | static int codecSetSubIdX(PHDACODECR3 pThis, uint32_t uCmd, uint8_t u8Offset)
|
---|
1396 | {
|
---|
1397 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1398 | uint8_t const cTotalNodes = (uint8_t)RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
1399 | Assert(CODEC_NID(uCmd) < cTotalNodes);
|
---|
1400 | if (CODEC_NID(uCmd) >= cTotalNodes)
|
---|
1401 | {
|
---|
1402 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(uCmd)));
|
---|
1403 | return VINF_SUCCESS;
|
---|
1404 | }
|
---|
1405 | uint32_t *pu32Reg;
|
---|
1406 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1407 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F20_param;
|
---|
1408 | else
|
---|
1409 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1410 | hdaCodecSetRegisterU8(pu32Reg, uCmd, u8Offset);
|
---|
1411 | return VINF_SUCCESS;
|
---|
1412 | }
|
---|
1413 |
|
---|
1414 |
|
---|
1415 | /**
|
---|
1416 | * @interface_method_impl{CODECVERB,pfn, 720 }
|
---|
1417 | */
|
---|
1418 | static DECLCALLBACK(int) vrbProcSetSubId0(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1419 | {
|
---|
1420 | *puResp = 0;
|
---|
1421 | return codecSetSubIdX(pThis, uCmd, 0);
|
---|
1422 | }
|
---|
1423 |
|
---|
1424 |
|
---|
1425 | /**
|
---|
1426 | * @interface_method_impl{CODECVERB,pfn, 721 }
|
---|
1427 | */
|
---|
1428 | static DECLCALLBACK(int) vrbProcSetSubId1(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1429 | {
|
---|
1430 | *puResp = 0;
|
---|
1431 | return codecSetSubIdX(pThis, uCmd, 8);
|
---|
1432 | }
|
---|
1433 |
|
---|
1434 |
|
---|
1435 | /**
|
---|
1436 | * @interface_method_impl{CODECVERB,pfn, 722 }
|
---|
1437 | */
|
---|
1438 | static DECLCALLBACK(int) vrbProcSetSubId2(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1439 | {
|
---|
1440 | *puResp = 0;
|
---|
1441 | return codecSetSubIdX(pThis, uCmd, 16);
|
---|
1442 | }
|
---|
1443 |
|
---|
1444 |
|
---|
1445 | /**
|
---|
1446 | * @interface_method_impl{CODECVERB,pfn, 723 }
|
---|
1447 | */
|
---|
1448 | static DECLCALLBACK(int) vrbProcSetSubId3(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1449 | {
|
---|
1450 | *puResp = 0;
|
---|
1451 | return codecSetSubIdX(pThis, uCmd, 24);
|
---|
1452 | }
|
---|
1453 |
|
---|
1454 |
|
---|
1455 | /**
|
---|
1456 | * @interface_method_impl{CODECVERB,pfn, ??? }
|
---|
1457 | */
|
---|
1458 | static DECLCALLBACK(int) vrbProcReset(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1459 | {
|
---|
1460 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1461 |
|
---|
1462 | if (pThis->enmType == CODECTYPE_STAC9220)
|
---|
1463 | {
|
---|
1464 | Assert(CODEC_NID(uCmd) == STAC9220_NID_AFG);
|
---|
1465 |
|
---|
1466 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1467 | stac9220Reset(pThis);
|
---|
1468 | }
|
---|
1469 | else
|
---|
1470 | AssertFailedReturn(VERR_NOT_IMPLEMENTED);
|
---|
1471 |
|
---|
1472 | *puResp = 0;
|
---|
1473 | return VINF_SUCCESS;
|
---|
1474 | }
|
---|
1475 |
|
---|
1476 |
|
---|
1477 | /**
|
---|
1478 | * @interface_method_impl{CODECVERB,pfn, f05 }
|
---|
1479 | */
|
---|
1480 | static DECLCALLBACK(int) vrbProcGetPowerState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1481 | {
|
---|
1482 | *puResp = 0;
|
---|
1483 |
|
---|
1484 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1485 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].afg.u32F05_param;
|
---|
1486 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1487 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F05_param;
|
---|
1488 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1489 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F05_param;
|
---|
1490 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1491 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F05_param;
|
---|
1492 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1493 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F05_param;
|
---|
1494 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1495 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F05_param;
|
---|
1496 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1497 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F05_param;
|
---|
1498 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1499 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F05_param;
|
---|
1500 | else
|
---|
1501 | LogRel2(("HDA: Warning: Unhandled get power state command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1502 |
|
---|
1503 | LogFunc(("[NID0x%02x]: fReset=%RTbool, fStopOk=%RTbool, Act=D%RU8, Set=D%RU8\n",
|
---|
1504 | CODEC_NID(uCmd), CODEC_F05_IS_RESET(*puResp), CODEC_F05_IS_STOPOK(*puResp), CODEC_F05_ACT(*puResp), CODEC_F05_SET(*puResp)));
|
---|
1505 | return VINF_SUCCESS;
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 | #if 1
|
---|
1509 |
|
---|
1510 | /**
|
---|
1511 | * @interface_method_impl{CODECVERB,pfn, 705 }
|
---|
1512 | */
|
---|
1513 | static DECLCALLBACK(int) vrbProcSetPowerState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1514 | {
|
---|
1515 | *puResp = 0;
|
---|
1516 |
|
---|
1517 | uint32_t *pu32Reg = NULL;
|
---|
1518 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1519 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F05_param;
|
---|
1520 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1521 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F05_param;
|
---|
1522 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1523 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F05_param;
|
---|
1524 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1525 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F05_param;
|
---|
1526 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1527 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F05_param;
|
---|
1528 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1529 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F05_param;
|
---|
1530 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1531 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F05_param;
|
---|
1532 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1533 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F05_param;
|
---|
1534 | else
|
---|
1535 | {
|
---|
1536 | LogRel2(("HDA: Warning: Unhandled set power state command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1537 | }
|
---|
1538 |
|
---|
1539 | if (!pu32Reg)
|
---|
1540 | return VINF_SUCCESS;
|
---|
1541 |
|
---|
1542 | uint8_t uPwrCmd = CODEC_F05_SET (uCmd);
|
---|
1543 | bool fReset = CODEC_F05_IS_RESET (*pu32Reg);
|
---|
1544 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32Reg);
|
---|
1545 | #ifdef LOG_ENABLED
|
---|
1546 | bool fError = CODEC_F05_IS_ERROR (*pu32Reg);
|
---|
1547 | uint8_t uPwrAct = CODEC_F05_ACT (*pu32Reg);
|
---|
1548 | uint8_t uPwrSet = CODEC_F05_SET (*pu32Reg);
|
---|
1549 | LogFunc(("[NID0x%02x] Cmd=D%RU8, fReset=%RTbool, fStopOk=%RTbool, fError=%RTbool, uPwrAct=D%RU8, uPwrSet=D%RU8\n",
|
---|
1550 | CODEC_NID(uCmd), uPwrCmd, fReset, fStopOk, fError, uPwrAct, uPwrSet));
|
---|
1551 | LogFunc(("AFG: Act=D%RU8, Set=D%RU8\n",
|
---|
1552 | CODEC_F05_ACT(pThis->aNodes[STAC9220_NID_AFG].afg.u32F05_param),
|
---|
1553 | CODEC_F05_SET(pThis->aNodes[STAC9220_NID_AFG].afg.u32F05_param)));
|
---|
1554 | #endif
|
---|
1555 |
|
---|
1556 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1557 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0, uPwrCmd /* PS-Act */, uPwrCmd /* PS-Set */);
|
---|
1558 |
|
---|
1559 | const uint8_t uAFGPwrAct = CODEC_F05_ACT(pThis->aNodes[STAC9220_NID_AFG].afg.u32F05_param);
|
---|
1560 | if (uAFGPwrAct == CODEC_F05_D0) /* Only propagate power state if AFG is on (D0). */
|
---|
1561 | {
|
---|
1562 | /* Propagate to all other nodes under this AFG. */
|
---|
1563 | LogFunc(("Propagating Act=D%RU8 (AFG), Set=D%RU8 to all AFG child nodes ...\n", uAFGPwrAct, uPwrCmd));
|
---|
1564 |
|
---|
1565 | #define PROPAGATE_PWR_STATE(a_abList, a_Member) \
|
---|
1566 | do { \
|
---|
1567 | for (uintptr_t idxList = 0; idxList < RT_ELEMENTS(a_abList); idxList++) \
|
---|
1568 | { \
|
---|
1569 | uint8_t const idxNode = a_abList[idxList]; \
|
---|
1570 | if (idxNode) \
|
---|
1571 | { \
|
---|
1572 | pThis->aNodes[idxNode].a_Member.u32F05_param = CODEC_MAKE_F05(fReset, fStopOk, 0, uAFGPwrAct, uPwrCmd); \
|
---|
1573 | LogFunc(("\t[NID0x%02x]: Act=D%RU8, Set=D%RU8\n", idxNode, \
|
---|
1574 | CODEC_F05_ACT(pThis->aNodes[idxNode].a_Member.u32F05_param), \
|
---|
1575 | CODEC_F05_SET(pThis->aNodes[idxNode].a_Member.u32F05_param))); \
|
---|
1576 | } \
|
---|
1577 | else \
|
---|
1578 | break; \
|
---|
1579 | } \
|
---|
1580 | } while (0)
|
---|
1581 |
|
---|
1582 | PROPAGATE_PWR_STATE(pThis->abDacs, dac);
|
---|
1583 | PROPAGATE_PWR_STATE(pThis->abAdcs, adc);
|
---|
1584 | PROPAGATE_PWR_STATE(pThis->abDigInPins, digin);
|
---|
1585 | PROPAGATE_PWR_STATE(pThis->abDigOutPins, digout);
|
---|
1586 | PROPAGATE_PWR_STATE(pThis->abSpdifIns, spdifin);
|
---|
1587 | PROPAGATE_PWR_STATE(pThis->abSpdifOuts, spdifout);
|
---|
1588 | PROPAGATE_PWR_STATE(pThis->abReserveds, reserved);
|
---|
1589 |
|
---|
1590 | #undef PROPAGATE_PWR_STATE
|
---|
1591 | }
|
---|
1592 | /*
|
---|
1593 | * If this node is a reqular node (not the AFG one), adopt PS-Set of the AFG node
|
---|
1594 | * as PS-Set of this node. PS-Act always is one level under PS-Set here.
|
---|
1595 | */
|
---|
1596 | else
|
---|
1597 | {
|
---|
1598 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0, uAFGPwrAct, uPwrCmd);
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 | LogFunc(("[NID0x%02x] fReset=%RTbool, fStopOk=%RTbool, Act=D%RU8, Set=D%RU8\n",
|
---|
1602 | CODEC_NID(uCmd),
|
---|
1603 | CODEC_F05_IS_RESET(*pu32Reg), CODEC_F05_IS_STOPOK(*pu32Reg), CODEC_F05_ACT(*pu32Reg), CODEC_F05_SET(*pu32Reg)));
|
---|
1604 |
|
---|
1605 | return VINF_SUCCESS;
|
---|
1606 | }
|
---|
1607 |
|
---|
1608 | #else
|
---|
1609 |
|
---|
1610 | DECLINLINE(void) codecPropogatePowerState(uint32_t *pu32F05_param)
|
---|
1611 | {
|
---|
1612 | Assert(pu32F05_param);
|
---|
1613 | if (!pu32F05_param)
|
---|
1614 | return;
|
---|
1615 | bool fReset = CODEC_F05_IS_RESET(*pu32F05_param);
|
---|
1616 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32F05_param);
|
---|
1617 | uint8_t u8SetPowerState = CODEC_F05_SET(*pu32F05_param);
|
---|
1618 | *pu32F05_param = CODEC_MAKE_F05(fReset, fStopOk, 0, u8SetPowerState, u8SetPowerState);
|
---|
1619 | }
|
---|
1620 |
|
---|
1621 |
|
---|
1622 | /**
|
---|
1623 | * @interface_method_impl{CODECVERB,pfn, 705 }
|
---|
1624 | */
|
---|
1625 | static DECLCALLBACK(int) vrbProcSetPowerState(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1626 | {
|
---|
1627 | Assert(CODEC_CAD(uCmd) == pThis->id);
|
---|
1628 | uint8_t const cTotalNodes = (uint8_t)RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
1629 | Assert(CODEC_NID(uCmd) < cTotalNodes);
|
---|
1630 | if (CODEC_NID(uCmd) >= cTotalNodes)
|
---|
1631 | {
|
---|
1632 | *puResp = 0;
|
---|
1633 | LogFlowFunc(("invalid node address %d\n", CODEC_NID(uCmd)));
|
---|
1634 | return VINF_SUCCESS;
|
---|
1635 | }
|
---|
1636 | *puResp = 0;
|
---|
1637 | uint32_t *pu32Reg;
|
---|
1638 | if (CODEC_NID(uCmd) == 1 /* AFG */)
|
---|
1639 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].afg.u32F05_param;
|
---|
1640 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1641 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F05_param;
|
---|
1642 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1643 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F05_param;
|
---|
1644 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1645 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F05_param;
|
---|
1646 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1647 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F05_param;
|
---|
1648 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1649 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F05_param;
|
---|
1650 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1651 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F05_param;
|
---|
1652 | else
|
---|
1653 | AssertFailedReturn(VINF_SUCCESS);
|
---|
1654 |
|
---|
1655 | bool fReset = CODEC_F05_IS_RESET(*pu32Reg);
|
---|
1656 | bool fStopOk = CODEC_F05_IS_STOPOK(*pu32Reg);
|
---|
1657 |
|
---|
1658 | if (CODEC_NID(uCmd) != 1 /* AFG */)
|
---|
1659 | {
|
---|
1660 | /*
|
---|
1661 | * We shouldn't propogate actual power state, which actual for AFG
|
---|
1662 | */
|
---|
1663 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0,
|
---|
1664 | CODEC_F05_ACT(pThis->aNodes[1].afg.u32F05_param),
|
---|
1665 | CODEC_F05_SET(uCmd));
|
---|
1666 | }
|
---|
1667 |
|
---|
1668 | /* Propagate next power state only if AFG is on or verb modifies AFG power state */
|
---|
1669 | if ( CODEC_NID(uCmd) == 1 /* AFG */
|
---|
1670 | || !CODEC_F05_ACT(pThis->aNodes[1].afg.u32F05_param))
|
---|
1671 | {
|
---|
1672 | *pu32Reg = CODEC_MAKE_F05(fReset, fStopOk, 0, CODEC_F05_SET(uCmd), CODEC_F05_SET(uCmd));
|
---|
1673 | if ( CODEC_NID(uCmd) == 1 /* AFG */
|
---|
1674 | && (CODEC_F05_SET(uCmd)) == CODEC_F05_D0)
|
---|
1675 | {
|
---|
1676 | /* now we're powered on AFG and may propogate power states on nodes */
|
---|
1677 | const uint8_t *pu8NodeIndex = &pThis->abDacs[0];
|
---|
1678 | while (*(++pu8NodeIndex))
|
---|
1679 | codecPropogatePowerState(&pThis->aNodes[*pu8NodeIndex].dac.u32F05_param);
|
---|
1680 |
|
---|
1681 | pu8NodeIndex = &pThis->abAdcs[0];
|
---|
1682 | while (*(++pu8NodeIndex))
|
---|
1683 | codecPropogatePowerState(&pThis->aNodes[*pu8NodeIndex].adc.u32F05_param);
|
---|
1684 |
|
---|
1685 | pu8NodeIndex = &pThis->abDigInPins[0];
|
---|
1686 | while (*(++pu8NodeIndex))
|
---|
1687 | codecPropogatePowerState(&pThis->aNodes[*pu8NodeIndex].digin.u32F05_param);
|
---|
1688 | }
|
---|
1689 | }
|
---|
1690 | return VINF_SUCCESS;
|
---|
1691 | }
|
---|
1692 |
|
---|
1693 | #endif
|
---|
1694 |
|
---|
1695 | /**
|
---|
1696 | * @interface_method_impl{CODECVERB,pfn, f06 }
|
---|
1697 | */
|
---|
1698 | static DECLCALLBACK(int) vrbProcGetStreamId(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1699 | {
|
---|
1700 | *puResp = 0;
|
---|
1701 |
|
---|
1702 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1703 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F06_param;
|
---|
1704 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1705 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32F06_param;
|
---|
1706 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1707 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F06_param;
|
---|
1708 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1709 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F06_param;
|
---|
1710 | else if (CODEC_NID(uCmd) == STAC9221_NID_I2S_OUT)
|
---|
1711 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F06_param;
|
---|
1712 | else
|
---|
1713 | LogRel2(("HDA: Warning: Unhandled get stream ID command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1714 |
|
---|
1715 | LogFlowFunc(("[NID0x%02x] Stream ID=%RU8, channel=%RU8\n",
|
---|
1716 | CODEC_NID(uCmd), CODEC_F00_06_GET_STREAM_ID(uCmd), CODEC_F00_06_GET_CHANNEL_ID(uCmd)));
|
---|
1717 |
|
---|
1718 | return VINF_SUCCESS;
|
---|
1719 | }
|
---|
1720 |
|
---|
1721 |
|
---|
1722 | /**
|
---|
1723 | * @interface_method_impl{CODECVERB,pfn, a0 }
|
---|
1724 | */
|
---|
1725 | static DECLCALLBACK(int) vrbProcGetConverterFormat(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1726 | {
|
---|
1727 | *puResp = 0;
|
---|
1728 |
|
---|
1729 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1730 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32A_param;
|
---|
1731 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1732 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adc.u32A_param;
|
---|
1733 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1734 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32A_param;
|
---|
1735 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1736 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32A_param;
|
---|
1737 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1738 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32A_param;
|
---|
1739 | else
|
---|
1740 | LogRel2(("HDA: Warning: Unhandled get converter format command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1741 |
|
---|
1742 | return VINF_SUCCESS;
|
---|
1743 | }
|
---|
1744 |
|
---|
1745 |
|
---|
1746 | /**
|
---|
1747 | * @interface_method_impl{CODECVERB,pfn, ??? - Also see section 3.7.1. }
|
---|
1748 | */
|
---|
1749 | static DECLCALLBACK(int) vrbProcSetConverterFormat(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1750 | {
|
---|
1751 | *puResp = 0;
|
---|
1752 |
|
---|
1753 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1754 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].dac.u32A_param, uCmd, 0);
|
---|
1755 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
1756 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].adc.u32A_param, uCmd, 0);
|
---|
1757 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
1758 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32A_param, uCmd, 0);
|
---|
1759 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
1760 | hdaCodecSetRegisterU16(&pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32A_param, uCmd, 0);
|
---|
1761 | else
|
---|
1762 | LogRel2(("HDA: Warning: Unhandled set converter format command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1763 |
|
---|
1764 | return VINF_SUCCESS;
|
---|
1765 | }
|
---|
1766 |
|
---|
1767 |
|
---|
1768 | /**
|
---|
1769 | * @interface_method_impl{CODECVERB,pfn, f0c }
|
---|
1770 | */
|
---|
1771 | static DECLCALLBACK(int) vrbProcGetEAPD_BTLEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1772 | {
|
---|
1773 | *puResp = 0;
|
---|
1774 |
|
---|
1775 | if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1776 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F0c_param;
|
---|
1777 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1778 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F0c_param;
|
---|
1779 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1780 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F0c_param;
|
---|
1781 | else
|
---|
1782 | LogRel2(("HDA: Warning: Unhandled get EAPD/BTL enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1783 |
|
---|
1784 | return VINF_SUCCESS;
|
---|
1785 | }
|
---|
1786 |
|
---|
1787 |
|
---|
1788 | /**
|
---|
1789 | * @interface_method_impl{CODECVERB,pfn, 70c }
|
---|
1790 | */
|
---|
1791 | static DECLCALLBACK(int) vrbProcSetEAPD_BTLEnabled(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1792 | {
|
---|
1793 | *puResp = 0;
|
---|
1794 |
|
---|
1795 | uint32_t *pu32Reg = NULL;
|
---|
1796 | if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
1797 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].adcvol.u32F0c_param;
|
---|
1798 | else if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
1799 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F0c_param;
|
---|
1800 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1801 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F0c_param;
|
---|
1802 | else
|
---|
1803 | LogRel2(("HDA: Warning: Unhandled set EAPD/BTL enabled command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1804 |
|
---|
1805 | if (pu32Reg)
|
---|
1806 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1807 |
|
---|
1808 | return VINF_SUCCESS;
|
---|
1809 | }
|
---|
1810 |
|
---|
1811 |
|
---|
1812 | /**
|
---|
1813 | * @interface_method_impl{CODECVERB,pfn, f0f }
|
---|
1814 | */
|
---|
1815 | static DECLCALLBACK(int) vrbProcGetVolumeKnobCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1816 | {
|
---|
1817 | *puResp = 0;
|
---|
1818 |
|
---|
1819 | if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1820 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F0f_param;
|
---|
1821 | else
|
---|
1822 | LogRel2(("HDA: Warning: Unhandled get volume knob control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1823 |
|
---|
1824 | return VINF_SUCCESS;
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 |
|
---|
1828 | /**
|
---|
1829 | * @interface_method_impl{CODECVERB,pfn, 70f }
|
---|
1830 | */
|
---|
1831 | static DECLCALLBACK(int) vrbProcSetVolumeKnobCtrl(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1832 | {
|
---|
1833 | *puResp = 0;
|
---|
1834 |
|
---|
1835 | uint32_t *pu32Reg = NULL;
|
---|
1836 | if (hdaCodecIsVolKnobNode(pThis, CODEC_NID(uCmd)))
|
---|
1837 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].volumeKnob.u32F0f_param;
|
---|
1838 | else
|
---|
1839 | LogRel2(("HDA: Warning: Unhandled set volume knob control command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1840 |
|
---|
1841 | if (pu32Reg)
|
---|
1842 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1843 |
|
---|
1844 | return VINF_SUCCESS;
|
---|
1845 | }
|
---|
1846 |
|
---|
1847 |
|
---|
1848 | /**
|
---|
1849 | * @interface_method_impl{CODECVERB,pfn, f15 }
|
---|
1850 | */
|
---|
1851 | static DECLCALLBACK(int) vrbProcGetGPIOData(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1852 | {
|
---|
1853 | RT_NOREF(pThis, uCmd);
|
---|
1854 | *puResp = 0;
|
---|
1855 | return VINF_SUCCESS;
|
---|
1856 | }
|
---|
1857 |
|
---|
1858 |
|
---|
1859 | /**
|
---|
1860 | * @interface_method_impl{CODECVERB,pfn, 715 }
|
---|
1861 | */
|
---|
1862 | static DECLCALLBACK(int) vrbProcSetGPIOData(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1863 | {
|
---|
1864 | RT_NOREF(pThis, uCmd);
|
---|
1865 | *puResp = 0;
|
---|
1866 | return VINF_SUCCESS;
|
---|
1867 | }
|
---|
1868 |
|
---|
1869 |
|
---|
1870 | /**
|
---|
1871 | * @interface_method_impl{CODECVERB,pfn, f16 }
|
---|
1872 | */
|
---|
1873 | static DECLCALLBACK(int) vrbProcGetGPIOEnableMask(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1874 | {
|
---|
1875 | RT_NOREF(pThis, uCmd);
|
---|
1876 | *puResp = 0;
|
---|
1877 | return VINF_SUCCESS;
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 |
|
---|
1881 | /**
|
---|
1882 | * @interface_method_impl{CODECVERB,pfn, 716 }
|
---|
1883 | */
|
---|
1884 | static DECLCALLBACK(int) vrbProcSetGPIOEnableMask(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1885 | {
|
---|
1886 | RT_NOREF(pThis, uCmd);
|
---|
1887 | *puResp = 0;
|
---|
1888 | return VINF_SUCCESS;
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 |
|
---|
1892 | /**
|
---|
1893 | * @interface_method_impl{CODECVERB,pfn, f17 }
|
---|
1894 | */
|
---|
1895 | static DECLCALLBACK(int) vrbProcGetGPIODirection(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1896 | {
|
---|
1897 | *puResp = 0;
|
---|
1898 |
|
---|
1899 | /* Note: this is true for ALC885. */
|
---|
1900 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1901 | *puResp = pThis->aNodes[1].afg.u32F17_param;
|
---|
1902 | else
|
---|
1903 | LogRel2(("HDA: Warning: Unhandled get GPIO direction command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1904 |
|
---|
1905 | return VINF_SUCCESS;
|
---|
1906 | }
|
---|
1907 |
|
---|
1908 |
|
---|
1909 | /**
|
---|
1910 | * @interface_method_impl{CODECVERB,pfn, 717 }
|
---|
1911 | */
|
---|
1912 | static DECLCALLBACK(int) vrbProcSetGPIODirection(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1913 | {
|
---|
1914 | *puResp = 0;
|
---|
1915 |
|
---|
1916 | uint32_t *pu32Reg = NULL;
|
---|
1917 | if (CODEC_NID(uCmd) == STAC9220_NID_AFG)
|
---|
1918 | pu32Reg = &pThis->aNodes[1].afg.u32F17_param;
|
---|
1919 | else
|
---|
1920 | LogRel2(("HDA: Warning: Unhandled set GPIO direction command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1921 |
|
---|
1922 | if (pu32Reg)
|
---|
1923 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
1924 |
|
---|
1925 | return VINF_SUCCESS;
|
---|
1926 | }
|
---|
1927 |
|
---|
1928 |
|
---|
1929 | /**
|
---|
1930 | * @interface_method_impl{CODECVERB,pfn, f1c }
|
---|
1931 | */
|
---|
1932 | static DECLCALLBACK(int) vrbProcGetConfig(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1933 | {
|
---|
1934 | *puResp = 0;
|
---|
1935 |
|
---|
1936 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1937 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].port.u32F1c_param;
|
---|
1938 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1939 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digout.u32F1c_param;
|
---|
1940 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1941 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].digin.u32F1c_param;
|
---|
1942 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1943 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F1c_param;
|
---|
1944 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1945 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F1c_param;
|
---|
1946 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1947 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F1c_param;
|
---|
1948 | else
|
---|
1949 | LogRel2(("HDA: Warning: Unhandled get config command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
1950 |
|
---|
1951 | return VINF_SUCCESS;
|
---|
1952 | }
|
---|
1953 |
|
---|
1954 | static int codecSetConfigX(PHDACODECR3 pThis, uint32_t uCmd, uint8_t u8Offset)
|
---|
1955 | {
|
---|
1956 | uint32_t *pu32Reg = NULL;
|
---|
1957 | if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
1958 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].port.u32F1c_param;
|
---|
1959 | else if (hdaCodecIsDigInPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1960 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digin.u32F1c_param;
|
---|
1961 | else if (hdaCodecIsDigOutPinNode(pThis, CODEC_NID(uCmd)))
|
---|
1962 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].digout.u32F1c_param;
|
---|
1963 | else if (hdaCodecIsCdNode(pThis, CODEC_NID(uCmd)))
|
---|
1964 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].cdnode.u32F1c_param;
|
---|
1965 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
1966 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].pcbeep.u32F1c_param;
|
---|
1967 | else if (hdaCodecIsReservedNode(pThis, CODEC_NID(uCmd)))
|
---|
1968 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].reserved.u32F1c_param;
|
---|
1969 | else
|
---|
1970 | LogRel2(("HDA: Warning: Unhandled set config command (%RU8) for NID0x%02x: 0x%x\n", u8Offset, CODEC_NID(uCmd), uCmd));
|
---|
1971 |
|
---|
1972 | if (pu32Reg)
|
---|
1973 | hdaCodecSetRegisterU8(pu32Reg, uCmd, u8Offset);
|
---|
1974 |
|
---|
1975 | return VINF_SUCCESS;
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 |
|
---|
1979 | /**
|
---|
1980 | * @interface_method_impl{CODECVERB,pfn, 71c }
|
---|
1981 | */
|
---|
1982 | static DECLCALLBACK(int) vrbProcSetConfig0(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1983 | {
|
---|
1984 | *puResp = 0;
|
---|
1985 | return codecSetConfigX(pThis, uCmd, 0);
|
---|
1986 | }
|
---|
1987 |
|
---|
1988 |
|
---|
1989 | /**
|
---|
1990 | * @interface_method_impl{CODECVERB,pfn, 71d }
|
---|
1991 | */
|
---|
1992 | static DECLCALLBACK(int) vrbProcSetConfig1(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
1993 | {
|
---|
1994 | *puResp = 0;
|
---|
1995 | return codecSetConfigX(pThis, uCmd, 8);
|
---|
1996 | }
|
---|
1997 |
|
---|
1998 |
|
---|
1999 | /**
|
---|
2000 | * @interface_method_impl{CODECVERB,pfn, 71e }
|
---|
2001 | */
|
---|
2002 | static DECLCALLBACK(int) vrbProcSetConfig2(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2003 | {
|
---|
2004 | *puResp = 0;
|
---|
2005 | return codecSetConfigX(pThis, uCmd, 16);
|
---|
2006 | }
|
---|
2007 |
|
---|
2008 |
|
---|
2009 | /**
|
---|
2010 | * @interface_method_impl{CODECVERB,pfn, 71e }
|
---|
2011 | */
|
---|
2012 | static DECLCALLBACK(int) vrbProcSetConfig3(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2013 | {
|
---|
2014 | *puResp = 0;
|
---|
2015 | return codecSetConfigX(pThis, uCmd, 24);
|
---|
2016 | }
|
---|
2017 |
|
---|
2018 |
|
---|
2019 | /**
|
---|
2020 | * @interface_method_impl{CODECVERB,pfn, f04 }
|
---|
2021 | */
|
---|
2022 | static DECLCALLBACK(int) vrbProcGetSDISelect(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2023 | {
|
---|
2024 | *puResp = 0;
|
---|
2025 |
|
---|
2026 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2027 | *puResp = pThis->aNodes[CODEC_NID(uCmd)].dac.u32F04_param;
|
---|
2028 | else
|
---|
2029 | LogRel2(("HDA: Warning: Unhandled get SDI select command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
2030 |
|
---|
2031 | return VINF_SUCCESS;
|
---|
2032 | }
|
---|
2033 |
|
---|
2034 |
|
---|
2035 | /**
|
---|
2036 | * @interface_method_impl{CODECVERB,pfn, 704 }
|
---|
2037 | */
|
---|
2038 | static DECLCALLBACK(int) vrbProcSetSDISelect(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2039 | {
|
---|
2040 | *puResp = 0;
|
---|
2041 |
|
---|
2042 | uint32_t *pu32Reg = NULL;
|
---|
2043 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2044 | pu32Reg = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F04_param;
|
---|
2045 | else
|
---|
2046 | LogRel2(("HDA: Warning: Unhandled set SDI select command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
2047 |
|
---|
2048 | if (pu32Reg)
|
---|
2049 | hdaCodecSetRegisterU8(pu32Reg, uCmd, 0);
|
---|
2050 |
|
---|
2051 | return VINF_SUCCESS;
|
---|
2052 | }
|
---|
2053 |
|
---|
2054 |
|
---|
2055 | /**
|
---|
2056 | * @interface_method_impl{CODECVERB,pfn, 3-- }
|
---|
2057 | */
|
---|
2058 | static DECLCALLBACK(int) vrbProcR3SetAmplifier(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2059 | {
|
---|
2060 | *puResp = 0;
|
---|
2061 |
|
---|
2062 | PCODECNODE pNode = &pThis->aNodes[CODEC_NID(uCmd)];
|
---|
2063 | AMPLIFIER *pAmplifier = NULL;
|
---|
2064 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2065 | pAmplifier = &pNode->dac.B_params;
|
---|
2066 | else if (hdaCodecIsAdcVolNode(pThis, CODEC_NID(uCmd)))
|
---|
2067 | pAmplifier = &pNode->adcvol.B_params;
|
---|
2068 | else if (hdaCodecIsAdcMuxNode(pThis, CODEC_NID(uCmd)))
|
---|
2069 | pAmplifier = &pNode->adcmux.B_params;
|
---|
2070 | else if (hdaCodecIsPcbeepNode(pThis, CODEC_NID(uCmd)))
|
---|
2071 | pAmplifier = &pNode->pcbeep.B_params;
|
---|
2072 | else if (hdaCodecIsPortNode(pThis, CODEC_NID(uCmd)))
|
---|
2073 | pAmplifier = &pNode->port.B_params;
|
---|
2074 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
2075 | pAmplifier = &pNode->adc.B_params;
|
---|
2076 | else
|
---|
2077 | LogRel2(("HDA: Warning: Unhandled set amplifier command: 0x%x (Payload=%RU16, NID=0x%x [%RU8])\n",
|
---|
2078 | uCmd, CODEC_VERB_PAYLOAD16(uCmd), CODEC_NID(uCmd), CODEC_NID(uCmd)));
|
---|
2079 |
|
---|
2080 | if (!pAmplifier)
|
---|
2081 | return VINF_SUCCESS;
|
---|
2082 |
|
---|
2083 | bool fIsOut = CODEC_SET_AMP_IS_OUT_DIRECTION(uCmd);
|
---|
2084 | bool fIsIn = CODEC_SET_AMP_IS_IN_DIRECTION(uCmd);
|
---|
2085 | bool fIsLeft = CODEC_SET_AMP_IS_LEFT_SIDE(uCmd);
|
---|
2086 | bool fIsRight = CODEC_SET_AMP_IS_RIGHT_SIDE(uCmd);
|
---|
2087 | uint8_t u8Index = CODEC_SET_AMP_INDEX(uCmd);
|
---|
2088 |
|
---|
2089 | if ( (!fIsLeft && !fIsRight)
|
---|
2090 | || (!fIsOut && !fIsIn))
|
---|
2091 | return VINF_SUCCESS;
|
---|
2092 |
|
---|
2093 | LogFunc(("[NID0x%02x] fIsOut=%RTbool, fIsIn=%RTbool, fIsLeft=%RTbool, fIsRight=%RTbool, Idx=%RU8\n",
|
---|
2094 | CODEC_NID(uCmd), fIsOut, fIsIn, fIsLeft, fIsRight, u8Index));
|
---|
2095 |
|
---|
2096 | if (fIsIn)
|
---|
2097 | {
|
---|
2098 | if (fIsLeft)
|
---|
2099 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_IN, AMPLIFIER_LEFT, u8Index), uCmd, 0);
|
---|
2100 | if (fIsRight)
|
---|
2101 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_IN, AMPLIFIER_RIGHT, u8Index), uCmd, 0);
|
---|
2102 |
|
---|
2103 | // if (CODEC_NID(uCmd) == pThis->u8AdcVolsLineIn)
|
---|
2104 | // {
|
---|
2105 | hdaR3CodecToAudVolume(pThis, pNode, pAmplifier, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2106 | // }
|
---|
2107 | }
|
---|
2108 | if (fIsOut)
|
---|
2109 | {
|
---|
2110 | if (fIsLeft)
|
---|
2111 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_OUT, AMPLIFIER_LEFT, u8Index), uCmd, 0);
|
---|
2112 | if (fIsRight)
|
---|
2113 | hdaCodecSetRegisterU8(&LIFIER_REGISTER(*pAmplifier, AMPLIFIER_OUT, AMPLIFIER_RIGHT, u8Index), uCmd, 0);
|
---|
2114 |
|
---|
2115 | if (CODEC_NID(uCmd) == pThis->u8DacLineOut)
|
---|
2116 | hdaR3CodecToAudVolume(pThis, pNode, pAmplifier, PDMAUDIOMIXERCTL_FRONT);
|
---|
2117 | }
|
---|
2118 |
|
---|
2119 | return VINF_SUCCESS;
|
---|
2120 | }
|
---|
2121 |
|
---|
2122 |
|
---|
2123 | /**
|
---|
2124 | * @interface_method_impl{CODECVERB,pfn, 706 }
|
---|
2125 | */
|
---|
2126 | static DECLCALLBACK(int) vrbProcR3SetStreamId(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2127 | {
|
---|
2128 | *puResp = 0;
|
---|
2129 |
|
---|
2130 | uint8_t uSD = CODEC_F00_06_GET_STREAM_ID(uCmd);
|
---|
2131 | uint8_t uChannel = CODEC_F00_06_GET_CHANNEL_ID(uCmd);
|
---|
2132 |
|
---|
2133 | LogFlowFunc(("[NID0x%02x] Setting to stream ID=%RU8, channel=%RU8\n",
|
---|
2134 | CODEC_NID(uCmd), uSD, uChannel));
|
---|
2135 |
|
---|
2136 | ASSERT_GUEST_LOGREL_MSG_RETURN(uSD < HDA_MAX_STREAMS,
|
---|
2137 | ("Setting stream ID #%RU8 is invalid\n", uSD), VERR_INVALID_PARAMETER);
|
---|
2138 |
|
---|
2139 | PDMAUDIODIR enmDir;
|
---|
2140 | uint32_t *pu32Addr;
|
---|
2141 | if (hdaCodecIsDacNode(pThis, CODEC_NID(uCmd)))
|
---|
2142 | {
|
---|
2143 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].dac.u32F06_param;
|
---|
2144 | enmDir = PDMAUDIODIR_OUT;
|
---|
2145 | }
|
---|
2146 | else if (hdaCodecIsAdcNode(pThis, CODEC_NID(uCmd)))
|
---|
2147 | {
|
---|
2148 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].adc.u32F06_param;
|
---|
2149 | enmDir = PDMAUDIODIR_IN;
|
---|
2150 | }
|
---|
2151 | else if (hdaCodecIsSpdifOutNode(pThis, CODEC_NID(uCmd)))
|
---|
2152 | {
|
---|
2153 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].spdifout.u32F06_param;
|
---|
2154 | enmDir = PDMAUDIODIR_OUT;
|
---|
2155 | }
|
---|
2156 | else if (hdaCodecIsSpdifInNode(pThis, CODEC_NID(uCmd)))
|
---|
2157 | {
|
---|
2158 | pu32Addr = &pThis->aNodes[CODEC_NID(uCmd)].spdifin.u32F06_param;
|
---|
2159 | enmDir = PDMAUDIODIR_IN;
|
---|
2160 | }
|
---|
2161 | else
|
---|
2162 | {
|
---|
2163 | enmDir = PDMAUDIODIR_UNKNOWN;
|
---|
2164 | LogRel2(("HDA: Warning: Unhandled set stream ID command for NID0x%02x: 0x%x\n", CODEC_NID(uCmd), uCmd));
|
---|
2165 | return VINF_SUCCESS;
|
---|
2166 | }
|
---|
2167 |
|
---|
2168 | /* Do we (re-)assign our input/output SDn (SDI/SDO) IDs? */
|
---|
2169 | pThis->aNodes[CODEC_NID(uCmd)].node.uSD = uSD;
|
---|
2170 | pThis->aNodes[CODEC_NID(uCmd)].node.uChannel = uChannel;
|
---|
2171 |
|
---|
2172 | if (enmDir == PDMAUDIODIR_OUT)
|
---|
2173 | {
|
---|
2174 | /** @todo Check if non-interleaved streams need a different channel / SDn? */
|
---|
2175 |
|
---|
2176 | /* Propagate to the controller. */
|
---|
2177 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_FRONT, uSD, uChannel);
|
---|
2178 | # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
|
---|
2179 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, uSD, uChannel);
|
---|
2180 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_REAR, uSD, uChannel);
|
---|
2181 | # endif
|
---|
2182 | }
|
---|
2183 | else if (enmDir == PDMAUDIODIR_IN)
|
---|
2184 | {
|
---|
2185 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_LINE_IN, uSD, uChannel);
|
---|
2186 | # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2187 | hdaR3MixerControl(pThis, PDMAUDIOMIXERCTL_MIC_IN, uSD, uChannel);
|
---|
2188 | # endif
|
---|
2189 | }
|
---|
2190 |
|
---|
2191 | hdaCodecSetRegisterU8(pu32Addr, uCmd, 0);
|
---|
2192 |
|
---|
2193 | return VINF_SUCCESS;
|
---|
2194 | }
|
---|
2195 |
|
---|
2196 |
|
---|
2197 |
|
---|
2198 | /**
|
---|
2199 | * HDA codec verb descriptors.
|
---|
2200 | *
|
---|
2201 | * @note This must be ordered by uVerb so we can do a binary lookup.
|
---|
2202 | */
|
---|
2203 | static const CODECVERB g_aCodecVerbs[] =
|
---|
2204 | {
|
---|
2205 | /* Verb Verb mask Callback Name
|
---|
2206 | ---------- --------------------- ------------------------------------------------------------------- */
|
---|
2207 | { 0x00020000, CODEC_VERB_16BIT_CMD, vrbProcSetConverterFormat , "SetConverterFormat " },
|
---|
2208 | { 0x00030000, CODEC_VERB_16BIT_CMD, vrbProcR3SetAmplifier , "SetAmplifier " },
|
---|
2209 | { 0x00070100, CODEC_VERB_8BIT_CMD , vrbProcSetConSelectCtrl , "SetConSelectCtrl " },
|
---|
2210 | { 0x00070300, CODEC_VERB_8BIT_CMD , vrbProcSetProcessingState , "SetProcessingState " },
|
---|
2211 | { 0x00070400, CODEC_VERB_8BIT_CMD , vrbProcSetSDISelect , "SetSDISelect " },
|
---|
2212 | { 0x00070500, CODEC_VERB_8BIT_CMD , vrbProcSetPowerState , "SetPowerState " },
|
---|
2213 | { 0x00070600, CODEC_VERB_8BIT_CMD , vrbProcR3SetStreamId , "SetStreamId " },
|
---|
2214 | { 0x00070700, CODEC_VERB_8BIT_CMD , vrbProcSetPinCtrl , "SetPinCtrl " },
|
---|
2215 | { 0x00070800, CODEC_VERB_8BIT_CMD , vrbProcSetUnsolicitedEnabled , "SetUnsolicitedEnabled " },
|
---|
2216 | { 0x00070900, CODEC_VERB_8BIT_CMD , vrbProcSetPinSense , "SetPinSense " },
|
---|
2217 | { 0x00070C00, CODEC_VERB_8BIT_CMD , vrbProcSetEAPD_BTLEnabled , "SetEAPD_BTLEnabled " },
|
---|
2218 | { 0x00070D00, CODEC_VERB_8BIT_CMD , vrbProcSetDigitalConverter1 , "SetDigitalConverter1 " },
|
---|
2219 | { 0x00070E00, CODEC_VERB_8BIT_CMD , vrbProcSetDigitalConverter2 , "SetDigitalConverter2 " },
|
---|
2220 | { 0x00070F00, CODEC_VERB_8BIT_CMD , vrbProcSetVolumeKnobCtrl , "SetVolumeKnobCtrl " },
|
---|
2221 | { 0x00071500, CODEC_VERB_8BIT_CMD , vrbProcSetGPIOData , "SetGPIOData " },
|
---|
2222 | { 0x00071600, CODEC_VERB_8BIT_CMD , vrbProcSetGPIOEnableMask , "SetGPIOEnableMask " },
|
---|
2223 | { 0x00071700, CODEC_VERB_8BIT_CMD , vrbProcSetGPIODirection , "SetGPIODirection " },
|
---|
2224 | { 0x00071C00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig0 , "SetConfig0 " },
|
---|
2225 | { 0x00071D00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig1 , "SetConfig1 " },
|
---|
2226 | { 0x00071E00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig2 , "SetConfig2 " },
|
---|
2227 | { 0x00071F00, CODEC_VERB_8BIT_CMD , vrbProcSetConfig3 , "SetConfig3 " },
|
---|
2228 | { 0x00072000, CODEC_VERB_8BIT_CMD , vrbProcSetSubId0 , "SetSubId0 " },
|
---|
2229 | { 0x00072100, CODEC_VERB_8BIT_CMD , vrbProcSetSubId1 , "SetSubId1 " },
|
---|
2230 | { 0x00072200, CODEC_VERB_8BIT_CMD , vrbProcSetSubId2 , "SetSubId2 " },
|
---|
2231 | { 0x00072300, CODEC_VERB_8BIT_CMD , vrbProcSetSubId3 , "SetSubId3 " },
|
---|
2232 | { 0x0007FF00, CODEC_VERB_8BIT_CMD , vrbProcReset , "Reset " },
|
---|
2233 | { 0x000A0000, CODEC_VERB_16BIT_CMD, vrbProcGetConverterFormat , "GetConverterFormat " },
|
---|
2234 | { 0x000B0000, CODEC_VERB_16BIT_CMD, vrbProcGetAmplifier , "GetAmplifier " },
|
---|
2235 | { 0x000F0000, CODEC_VERB_8BIT_CMD , vrbProcGetParameter , "GetParameter " },
|
---|
2236 | { 0x000F0100, CODEC_VERB_8BIT_CMD , vrbProcGetConSelectCtrl , "GetConSelectCtrl " },
|
---|
2237 | { 0x000F0200, CODEC_VERB_8BIT_CMD , vrbProcGetConnectionListEntry , "GetConnectionListEntry" },
|
---|
2238 | { 0x000F0300, CODEC_VERB_8BIT_CMD , vrbProcGetProcessingState , "GetProcessingState " },
|
---|
2239 | { 0x000F0400, CODEC_VERB_8BIT_CMD , vrbProcGetSDISelect , "GetSDISelect " },
|
---|
2240 | { 0x000F0500, CODEC_VERB_8BIT_CMD , vrbProcGetPowerState , "GetPowerState " },
|
---|
2241 | { 0x000F0600, CODEC_VERB_8BIT_CMD , vrbProcGetStreamId , "GetStreamId " },
|
---|
2242 | { 0x000F0700, CODEC_VERB_8BIT_CMD , vrbProcGetPinCtrl , "GetPinCtrl " },
|
---|
2243 | { 0x000F0800, CODEC_VERB_8BIT_CMD , vrbProcGetUnsolicitedEnabled , "GetUnsolicitedEnabled " },
|
---|
2244 | { 0x000F0900, CODEC_VERB_8BIT_CMD , vrbProcGetPinSense , "GetPinSense " },
|
---|
2245 | { 0x000F0C00, CODEC_VERB_8BIT_CMD , vrbProcGetEAPD_BTLEnabled , "GetEAPD_BTLEnabled " },
|
---|
2246 | { 0x000F0D00, CODEC_VERB_8BIT_CMD , vrbProcGetDigitalConverter , "GetDigitalConverter " },
|
---|
2247 | { 0x000F0F00, CODEC_VERB_8BIT_CMD , vrbProcGetVolumeKnobCtrl , "GetVolumeKnobCtrl " },
|
---|
2248 | { 0x000F1500, CODEC_VERB_8BIT_CMD , vrbProcGetGPIOData , "GetGPIOData " },
|
---|
2249 | { 0x000F1600, CODEC_VERB_8BIT_CMD , vrbProcGetGPIOEnableMask , "GetGPIOEnableMask " },
|
---|
2250 | { 0x000F1700, CODEC_VERB_8BIT_CMD , vrbProcGetGPIODirection , "GetGPIODirection " },
|
---|
2251 | { 0x000F1C00, CODEC_VERB_8BIT_CMD , vrbProcGetConfig , "GetConfig " },
|
---|
2252 | { 0x000F2000, CODEC_VERB_8BIT_CMD , vrbProcGetSubId , "GetSubId " },
|
---|
2253 | /** @todo Implement 0x7e7: IDT Set GPIO (STAC922x only). */
|
---|
2254 | };
|
---|
2255 |
|
---|
2256 |
|
---|
2257 | /**
|
---|
2258 | * Implements codec lookup and will call the handler on the verb it finds,
|
---|
2259 | * returning the handler response.
|
---|
2260 | *
|
---|
2261 | * @returns VBox status code (not strict).
|
---|
2262 | */
|
---|
2263 | DECLHIDDEN(int) hdaR3CodecLookup(PHDACODECR3 pThis, uint32_t uCmd, uint64_t *puResp)
|
---|
2264 | {
|
---|
2265 | /*
|
---|
2266 | * Clear the return value and assert some sanity.
|
---|
2267 | */
|
---|
2268 | AssertPtr(puResp);
|
---|
2269 | *puResp = 0;
|
---|
2270 | AssertPtr(pThis);
|
---|
2271 | AssertMsgReturn(CODEC_CAD(uCmd) == pThis->id,
|
---|
2272 | ("Unknown codec address 0x%x\n", CODEC_CAD(uCmd)),
|
---|
2273 | VERR_INVALID_PARAMETER);
|
---|
2274 | uint32_t const uCmdData = CODEC_VERBDATA(uCmd);
|
---|
2275 | AssertMsgReturn( uCmdData != 0
|
---|
2276 | && CODEC_NID(uCmd) < RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes)),
|
---|
2277 | ("[NID0x%02x] Unknown / invalid node or data (0x%x)\n", CODEC_NID(uCmd), uCmdData),
|
---|
2278 | VERR_INVALID_PARAMETER);
|
---|
2279 | STAM_COUNTER_INC(&pThis->CTX_SUFF(StatLookups));
|
---|
2280 |
|
---|
2281 | /*
|
---|
2282 | * Do a binary lookup of the verb.
|
---|
2283 | * Note! if we want other verb tables, add a table selector before the loop.
|
---|
2284 | */
|
---|
2285 | size_t iFirst = 0;
|
---|
2286 | size_t iEnd = RT_ELEMENTS(g_aCodecVerbs);
|
---|
2287 | for (;;)
|
---|
2288 | {
|
---|
2289 | size_t const iCur = iFirst + (iEnd - iFirst) / 2;
|
---|
2290 | uint32_t const uVerb = g_aCodecVerbs[iCur].uVerb;
|
---|
2291 | if (uCmdData < uVerb)
|
---|
2292 | {
|
---|
2293 | if (iCur > iFirst)
|
---|
2294 | iEnd = iCur;
|
---|
2295 | else
|
---|
2296 | break;
|
---|
2297 | }
|
---|
2298 | else if ((uCmdData & g_aCodecVerbs[iCur].fMask) != uVerb)
|
---|
2299 | {
|
---|
2300 | if (iCur + 1 < iEnd)
|
---|
2301 | iFirst = iCur + 1;
|
---|
2302 | else
|
---|
2303 | break;
|
---|
2304 | }
|
---|
2305 | else
|
---|
2306 | {
|
---|
2307 | /*
|
---|
2308 | * Found it! Run the callback and return.
|
---|
2309 | */
|
---|
2310 | AssertPtrReturn(g_aCodecVerbs[iCur].pfn, VERR_INTERNAL_ERROR_5); /* Paranoia^2. */
|
---|
2311 |
|
---|
2312 | int rc = g_aCodecVerbs[iCur].pfn(pThis, uCmd, puResp);
|
---|
2313 | AssertRC(rc);
|
---|
2314 | Log3Func(("[NID0x%02x] (0x%x) %s: 0x%x -> 0x%x\n",
|
---|
2315 | CODEC_NID(uCmd), g_aCodecVerbs[iCur].uVerb, g_aCodecVerbs[iCur].pszName, CODEC_VERB_PAYLOAD8(uCmd), *puResp));
|
---|
2316 | return rc;
|
---|
2317 | }
|
---|
2318 | }
|
---|
2319 |
|
---|
2320 | #ifdef VBOX_STRICT
|
---|
2321 | for (size_t i = 0; i < RT_ELEMENTS(g_aCodecVerbs); i++)
|
---|
2322 | {
|
---|
2323 | AssertMsg(i == 0 || g_aCodecVerbs[i - 1].uVerb < g_aCodecVerbs[i].uVerb,
|
---|
2324 | ("i=%#x uVerb[-1]=%#x uVerb=%#x - buggy table!\n", i, g_aCodecVerbs[i - 1].uVerb, g_aCodecVerbs[i].uVerb));
|
---|
2325 | AssertMsg((uCmdData & g_aCodecVerbs[i].fMask) != g_aCodecVerbs[i].uVerb,
|
---|
2326 | ("i=%#x uVerb=%#x uCmd=%#x - buggy binary search or table!\n", i, g_aCodecVerbs[i].uVerb, uCmd));
|
---|
2327 | }
|
---|
2328 | #endif
|
---|
2329 | LogFunc(("[NID0x%02x] Callback for %x not found\n", CODEC_NID(uCmd), CODEC_VERBDATA(uCmd)));
|
---|
2330 | return VERR_NOT_FOUND;
|
---|
2331 | }
|
---|
2332 |
|
---|
2333 |
|
---|
2334 | /*********************************************************************************************************************************
|
---|
2335 | * Debug *
|
---|
2336 | *********************************************************************************************************************************/
|
---|
2337 | /**
|
---|
2338 | * CODEC debug info item printing state.
|
---|
2339 | */
|
---|
2340 | typedef struct CODECDEBUG
|
---|
2341 | {
|
---|
2342 | /** DBGF info helpers. */
|
---|
2343 | PCDBGFINFOHLP pHlp;
|
---|
2344 | /** Current recursion level. */
|
---|
2345 | uint8_t uLevel;
|
---|
2346 | /** Pointer to codec state. */
|
---|
2347 | PHDACODECR3 pThis;
|
---|
2348 | } CODECDEBUG;
|
---|
2349 | /** Pointer to the debug info item printing state for the codec. */
|
---|
2350 | typedef CODECDEBUG *PCODECDEBUG;
|
---|
2351 |
|
---|
2352 | #define CODECDBG_INDENT pInfo->uLevel++;
|
---|
2353 | #define CODECDBG_UNINDENT if (pInfo->uLevel) pInfo->uLevel--;
|
---|
2354 |
|
---|
2355 | #define CODECDBG_PRINT(...) pInfo->pHlp->pfnPrintf(pInfo->pHlp, __VA_ARGS__)
|
---|
2356 | #define CODECDBG_PRINTI(...) codecDbgPrintf(pInfo, __VA_ARGS__)
|
---|
2357 |
|
---|
2358 |
|
---|
2359 | /** Wrapper around DBGFINFOHLP::pfnPrintf that adds identation. */
|
---|
2360 | static void codecDbgPrintf(PCODECDEBUG pInfo, const char *pszFormat, ...)
|
---|
2361 | {
|
---|
2362 | va_list va;
|
---|
2363 | va_start(va, pszFormat);
|
---|
2364 | pInfo->pHlp->pfnPrintf(pInfo->pHlp, "%*s%N", pInfo->uLevel * 4, "", pszFormat, &va);
|
---|
2365 | va_end(va);
|
---|
2366 | }
|
---|
2367 |
|
---|
2368 |
|
---|
2369 | /** Power state */
|
---|
2370 | static void codecDbgPrintNodeRegF05(PCODECDEBUG pInfo, uint32_t u32Reg)
|
---|
2371 | {
|
---|
2372 | codecDbgPrintf(pInfo, "Power (F05): fReset=%RTbool, fStopOk=%RTbool, Set=%RU8, Act=%RU8\n",
|
---|
2373 | CODEC_F05_IS_RESET(u32Reg), CODEC_F05_IS_STOPOK(u32Reg), CODEC_F05_SET(u32Reg), CODEC_F05_ACT(u32Reg));
|
---|
2374 | }
|
---|
2375 |
|
---|
2376 |
|
---|
2377 | static void codecDbgPrintNodeRegA(PCODECDEBUG pInfo, uint32_t u32Reg)
|
---|
2378 | {
|
---|
2379 | codecDbgPrintf(pInfo, "RegA: %x\n", u32Reg);
|
---|
2380 | }
|
---|
2381 |
|
---|
2382 |
|
---|
2383 | static void codecDbgPrintNodeRegF00(PCODECDEBUG pInfo, uint32_t *paReg00)
|
---|
2384 | {
|
---|
2385 | codecDbgPrintf(pInfo, "Parameters (F00):\n");
|
---|
2386 |
|
---|
2387 | CODECDBG_INDENT
|
---|
2388 | codecDbgPrintf(pInfo, "Connections: %RU8\n", CODEC_F00_0E_COUNT(paReg00[0xE]));
|
---|
2389 | codecDbgPrintf(pInfo, "Amplifier Caps:\n");
|
---|
2390 | uint32_t uReg = paReg00[0xD];
|
---|
2391 | CODECDBG_INDENT
|
---|
2392 | codecDbgPrintf(pInfo, "Input Steps=%02RU8, StepSize=%02RU8, StepOff=%02RU8, fCanMute=%RTbool\n",
|
---|
2393 | CODEC_F00_0D_NUM_STEPS(uReg),
|
---|
2394 | CODEC_F00_0D_STEP_SIZE(uReg),
|
---|
2395 | CODEC_F00_0D_OFFSET(uReg),
|
---|
2396 | RT_BOOL(CODEC_F00_0D_IS_CAP_MUTE(uReg)));
|
---|
2397 |
|
---|
2398 | uReg = paReg00[0x12];
|
---|
2399 | codecDbgPrintf(pInfo, "Output Steps=%02RU8, StepSize=%02RU8, StepOff=%02RU8, fCanMute=%RTbool\n",
|
---|
2400 | CODEC_F00_12_NUM_STEPS(uReg),
|
---|
2401 | CODEC_F00_12_STEP_SIZE(uReg),
|
---|
2402 | CODEC_F00_12_OFFSET(uReg),
|
---|
2403 | RT_BOOL(CODEC_F00_12_IS_CAP_MUTE(uReg)));
|
---|
2404 | CODECDBG_UNINDENT
|
---|
2405 | CODECDBG_UNINDENT
|
---|
2406 | }
|
---|
2407 |
|
---|
2408 |
|
---|
2409 | static void codecDbgPrintNodeAmp(PCODECDEBUG pInfo, uint32_t *paReg, uint8_t uIdx, uint8_t uDir)
|
---|
2410 | {
|
---|
2411 | #define CODECDBG_AMP(reg, chan) \
|
---|
2412 | codecDbgPrintf(pInfo, "Amp %RU8 %s %s: In=%RTbool, Out=%RTbool, Left=%RTbool, Right=%RTbool, Idx=%RU8, fMute=%RTbool, uGain=%RU8\n", \
|
---|
2413 | uIdx, chan, uDir == AMPLIFIER_IN ? "In" : "Out", \
|
---|
2414 | RT_BOOL(CODEC_SET_AMP_IS_IN_DIRECTION(reg)), RT_BOOL(CODEC_SET_AMP_IS_OUT_DIRECTION(reg)), \
|
---|
2415 | RT_BOOL(CODEC_SET_AMP_IS_LEFT_SIDE(reg)), RT_BOOL(CODEC_SET_AMP_IS_RIGHT_SIDE(reg)), \
|
---|
2416 | CODEC_SET_AMP_INDEX(reg), RT_BOOL(CODEC_SET_AMP_MUTE(reg)), CODEC_SET_AMP_GAIN(reg))
|
---|
2417 |
|
---|
2418 | uint32_t regAmp = AMPLIFIER_REGISTER(paReg, uDir, AMPLIFIER_LEFT, uIdx);
|
---|
2419 | CODECDBG_AMP(regAmp, "Left");
|
---|
2420 | regAmp = AMPLIFIER_REGISTER(paReg, uDir, AMPLIFIER_RIGHT, uIdx);
|
---|
2421 | CODECDBG_AMP(regAmp, "Right");
|
---|
2422 |
|
---|
2423 | #undef CODECDBG_AMP
|
---|
2424 | }
|
---|
2425 |
|
---|
2426 |
|
---|
2427 | #if 0 /* unused */
|
---|
2428 | static void codecDbgPrintNodeConnections(PCODECDEBUG pInfo, PCODECNODE pNode)
|
---|
2429 | {
|
---|
2430 | if (pNode->node.au32F00_param[0xE] == 0) /* Directly connected to HDA link. */
|
---|
2431 | {
|
---|
2432 | codecDbgPrintf(pInfo, "[HDA LINK]\n");
|
---|
2433 | return;
|
---|
2434 | }
|
---|
2435 | }
|
---|
2436 | #endif
|
---|
2437 |
|
---|
2438 |
|
---|
2439 | static void codecDbgPrintNode(PCODECDEBUG pInfo, PCODECNODE pNode, bool fRecursive)
|
---|
2440 | {
|
---|
2441 | codecDbgPrintf(pInfo, "Node 0x%02x (%02RU8): ", pNode->node.uID, pNode->node.uID);
|
---|
2442 |
|
---|
2443 | if (pNode->node.uID == STAC9220_NID_ROOT)
|
---|
2444 | CODECDBG_PRINT("ROOT\n");
|
---|
2445 | else if (pNode->node.uID == STAC9220_NID_AFG)
|
---|
2446 | {
|
---|
2447 | CODECDBG_PRINT("AFG\n");
|
---|
2448 | CODECDBG_INDENT
|
---|
2449 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2450 | codecDbgPrintNodeRegF05(pInfo, pNode->afg.u32F05_param);
|
---|
2451 | CODECDBG_UNINDENT
|
---|
2452 | }
|
---|
2453 | else if (hdaCodecIsPortNode(pInfo->pThis, pNode->node.uID))
|
---|
2454 | CODECDBG_PRINT("PORT\n");
|
---|
2455 | else if (hdaCodecIsDacNode(pInfo->pThis, pNode->node.uID))
|
---|
2456 | {
|
---|
2457 | CODECDBG_PRINT("DAC\n");
|
---|
2458 | CODECDBG_INDENT
|
---|
2459 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2460 | codecDbgPrintNodeRegF05(pInfo, pNode->dac.u32F05_param);
|
---|
2461 | codecDbgPrintNodeRegA (pInfo, pNode->dac.u32A_param);
|
---|
2462 | codecDbgPrintNodeAmp (pInfo, pNode->dac.B_params, 0, AMPLIFIER_OUT);
|
---|
2463 | CODECDBG_UNINDENT
|
---|
2464 | }
|
---|
2465 | else if (hdaCodecIsAdcVolNode(pInfo->pThis, pNode->node.uID))
|
---|
2466 | {
|
---|
2467 | CODECDBG_PRINT("ADC VOLUME\n");
|
---|
2468 | CODECDBG_INDENT
|
---|
2469 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2470 | codecDbgPrintNodeRegA (pInfo, pNode->adcvol.u32A_params);
|
---|
2471 | codecDbgPrintNodeAmp (pInfo, pNode->adcvol.B_params, 0, AMPLIFIER_IN);
|
---|
2472 | CODECDBG_UNINDENT
|
---|
2473 | }
|
---|
2474 | else if (hdaCodecIsAdcNode(pInfo->pThis, pNode->node.uID))
|
---|
2475 | {
|
---|
2476 | CODECDBG_PRINT("ADC\n");
|
---|
2477 | CODECDBG_INDENT
|
---|
2478 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2479 | codecDbgPrintNodeRegF05(pInfo, pNode->adc.u32F05_param);
|
---|
2480 | codecDbgPrintNodeRegA (pInfo, pNode->adc.u32A_param);
|
---|
2481 | codecDbgPrintNodeAmp (pInfo, pNode->adc.B_params, 0, AMPLIFIER_IN);
|
---|
2482 | CODECDBG_UNINDENT
|
---|
2483 | }
|
---|
2484 | else if (hdaCodecIsAdcMuxNode(pInfo->pThis, pNode->node.uID))
|
---|
2485 | {
|
---|
2486 | CODECDBG_PRINT("ADC MUX\n");
|
---|
2487 | CODECDBG_INDENT
|
---|
2488 | codecDbgPrintNodeRegF00(pInfo, pNode->node.au32F00_param);
|
---|
2489 | codecDbgPrintNodeRegA (pInfo, pNode->adcmux.u32A_param);
|
---|
2490 | codecDbgPrintNodeAmp (pInfo, pNode->adcmux.B_params, 0, AMPLIFIER_IN);
|
---|
2491 | CODECDBG_UNINDENT
|
---|
2492 | }
|
---|
2493 | else if (hdaCodecIsPcbeepNode(pInfo->pThis, pNode->node.uID))
|
---|
2494 | CODECDBG_PRINT("PC BEEP\n");
|
---|
2495 | else if (hdaCodecIsSpdifOutNode(pInfo->pThis, pNode->node.uID))
|
---|
2496 | CODECDBG_PRINT("SPDIF OUT\n");
|
---|
2497 | else if (hdaCodecIsSpdifInNode(pInfo->pThis, pNode->node.uID))
|
---|
2498 | CODECDBG_PRINT("SPDIF IN\n");
|
---|
2499 | else if (hdaCodecIsDigInPinNode(pInfo->pThis, pNode->node.uID))
|
---|
2500 | CODECDBG_PRINT("DIGITAL IN PIN\n");
|
---|
2501 | else if (hdaCodecIsDigOutPinNode(pInfo->pThis, pNode->node.uID))
|
---|
2502 | CODECDBG_PRINT("DIGITAL OUT PIN\n");
|
---|
2503 | else if (hdaCodecIsCdNode(pInfo->pThis, pNode->node.uID))
|
---|
2504 | CODECDBG_PRINT("CD\n");
|
---|
2505 | else if (hdaCodecIsVolKnobNode(pInfo->pThis, pNode->node.uID))
|
---|
2506 | CODECDBG_PRINT("VOLUME KNOB\n");
|
---|
2507 | else if (hdaCodecIsReservedNode(pInfo->pThis, pNode->node.uID))
|
---|
2508 | CODECDBG_PRINT("RESERVED\n");
|
---|
2509 | else
|
---|
2510 | CODECDBG_PRINT("UNKNOWN TYPE 0x%x\n", pNode->node.uID);
|
---|
2511 |
|
---|
2512 | if (fRecursive)
|
---|
2513 | {
|
---|
2514 | #define CODECDBG_PRINT_CONLIST_ENTRY(_aNode, _aEntry) \
|
---|
2515 | if (cCnt >= _aEntry) \
|
---|
2516 | { \
|
---|
2517 | const uint8_t uID = RT_BYTE##_aEntry(_aNode->node.au32F02_param[0x0]); \
|
---|
2518 | if (pNode->node.uID == uID) \
|
---|
2519 | codecDbgPrintNode(pInfo, _aNode, false /* fRecursive */); \
|
---|
2520 | }
|
---|
2521 |
|
---|
2522 | /* Slow recursion, but this is debug stuff anyway. */
|
---|
2523 | for (uint8_t i = 0; i < pInfo->pThis->cTotalNodes; i++)
|
---|
2524 | {
|
---|
2525 | const PCODECNODE pSubNode = &pInfo->pThis->aNodes[i];
|
---|
2526 | if (pSubNode->node.uID == pNode->node.uID)
|
---|
2527 | continue;
|
---|
2528 |
|
---|
2529 | const uint8_t cCnt = CODEC_F00_0E_COUNT(pSubNode->node.au32F00_param[0xE]);
|
---|
2530 | if (cCnt == 0) /* No connections present? Skip. */
|
---|
2531 | continue;
|
---|
2532 |
|
---|
2533 | CODECDBG_INDENT
|
---|
2534 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 1)
|
---|
2535 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 2)
|
---|
2536 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 3)
|
---|
2537 | CODECDBG_PRINT_CONLIST_ENTRY(pSubNode, 4)
|
---|
2538 | CODECDBG_UNINDENT
|
---|
2539 | }
|
---|
2540 |
|
---|
2541 | #undef CODECDBG_PRINT_CONLIST_ENTRY
|
---|
2542 | }
|
---|
2543 | }
|
---|
2544 |
|
---|
2545 |
|
---|
2546 | /**
|
---|
2547 | * Worker for hdaR3DbgInfoCodecNodes implementing the 'hdcnodes' info item.
|
---|
2548 | */
|
---|
2549 | DECLHIDDEN(void) hdaR3CodecDbgListNodes(PHDACODECR3 pThis, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
2550 | {
|
---|
2551 | RT_NOREF(pszArgs);
|
---|
2552 |
|
---|
2553 | pHlp->pfnPrintf(pHlp, "HDA LINK / INPUTS\n");
|
---|
2554 |
|
---|
2555 | CODECDEBUG DbgInfo;
|
---|
2556 | DbgInfo.pHlp = pHlp;
|
---|
2557 | DbgInfo.pThis = pThis;
|
---|
2558 | DbgInfo.uLevel = 0;
|
---|
2559 |
|
---|
2560 | PCODECDEBUG pInfo = &DbgInfo;
|
---|
2561 |
|
---|
2562 | CODECDBG_INDENT
|
---|
2563 | for (uint8_t i = 0; i < pThis->cTotalNodes; i++)
|
---|
2564 | {
|
---|
2565 | PCODECNODE pNode = &pThis->aNodes[i];
|
---|
2566 |
|
---|
2567 | /* Start with all nodes which have connection entries set. */
|
---|
2568 | if (CODEC_F00_0E_COUNT(pNode->node.au32F00_param[0xE]))
|
---|
2569 | codecDbgPrintNode(&DbgInfo, pNode, true /* fRecursive */);
|
---|
2570 | }
|
---|
2571 | CODECDBG_UNINDENT
|
---|
2572 | }
|
---|
2573 |
|
---|
2574 |
|
---|
2575 | /**
|
---|
2576 | * Worker for hdaR3DbgInfoCodecSelector implementing the 'hdcselector' info item.
|
---|
2577 | */
|
---|
2578 | DECLHIDDEN(void) hdaR3CodecDbgSelector(PHDACODECR3 pThis, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
2579 | {
|
---|
2580 | RT_NOREF(pThis, pHlp, pszArgs);
|
---|
2581 | }
|
---|
2582 |
|
---|
2583 |
|
---|
2584 | #if 0 /* unused */
|
---|
2585 | static DECLCALLBACK(void) stac9220DbgNodes(PHDACODECR3 pThis, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
2586 | {
|
---|
2587 | RT_NOREF(pszArgs);
|
---|
2588 | uint8_t const cTotalNodes = RT_MIN(pThis->cTotalNodes, RT_ELEMENTS(pThis->aNodes));
|
---|
2589 | for (uint8_t i = 1; i < cTotalNodes; i++)
|
---|
2590 | {
|
---|
2591 | PCODECNODE pNode = &pThis->aNodes[i];
|
---|
2592 | AMPLIFIER *pAmp = &pNode->dac.B_params;
|
---|
2593 |
|
---|
2594 | uint8_t lVol = AMPLIFIER_REGISTER(*pAmp, AMPLIFIER_OUT, AMPLIFIER_LEFT, 0) & 0x7f;
|
---|
2595 | uint8_t rVol = AMPLIFIER_REGISTER(*pAmp, AMPLIFIER_OUT, AMPLIFIER_RIGHT, 0) & 0x7f;
|
---|
2596 |
|
---|
2597 | pHlp->pfnPrintf(pHlp, "0x%x: lVol=%RU8, rVol=%RU8\n", i, lVol, rVol);
|
---|
2598 | }
|
---|
2599 | }
|
---|
2600 | #endif
|
---|
2601 |
|
---|
2602 |
|
---|
2603 | /*********************************************************************************************************************************
|
---|
2604 | * Stream and State Management *
|
---|
2605 | *********************************************************************************************************************************/
|
---|
2606 |
|
---|
2607 | int hdaR3CodecAddStream(PHDACODECR3 pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg)
|
---|
2608 | {
|
---|
2609 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2610 | AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
|
---|
2611 |
|
---|
2612 | int rc = VINF_SUCCESS;
|
---|
2613 |
|
---|
2614 | switch (enmMixerCtl)
|
---|
2615 | {
|
---|
2616 | case PDMAUDIOMIXERCTL_VOLUME_MASTER:
|
---|
2617 | case PDMAUDIOMIXERCTL_FRONT:
|
---|
2618 | #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
|
---|
2619 | case PDMAUDIOMIXERCTL_CENTER_LFE:
|
---|
2620 | case PDMAUDIOMIXERCTL_REAR:
|
---|
2621 | #endif
|
---|
2622 | break;
|
---|
2623 |
|
---|
2624 | case PDMAUDIOMIXERCTL_LINE_IN:
|
---|
2625 | #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2626 | case PDMAUDIOMIXERCTL_MIC_IN:
|
---|
2627 | #endif
|
---|
2628 | break;
|
---|
2629 |
|
---|
2630 | default:
|
---|
2631 | AssertMsgFailed(("Mixer control %#x not implemented\n", enmMixerCtl));
|
---|
2632 | rc = VERR_NOT_IMPLEMENTED;
|
---|
2633 | break;
|
---|
2634 | }
|
---|
2635 |
|
---|
2636 | if (RT_SUCCESS(rc))
|
---|
2637 | rc = hdaR3MixerAddStream(pThis, enmMixerCtl, pCfg);
|
---|
2638 |
|
---|
2639 | LogFlowFuncLeaveRC(rc);
|
---|
2640 | return rc;
|
---|
2641 | }
|
---|
2642 |
|
---|
2643 |
|
---|
2644 | int hdaR3CodecRemoveStream(PHDACODECR3 pThis, PDMAUDIOMIXERCTL enmMixerCtl, bool fImmediate)
|
---|
2645 | {
|
---|
2646 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2647 |
|
---|
2648 | int rc = hdaR3MixerRemoveStream(pThis, enmMixerCtl, fImmediate);
|
---|
2649 |
|
---|
2650 | LogFlowFuncLeaveRC(rc);
|
---|
2651 | return rc;
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 |
|
---|
2655 | /**
|
---|
2656 | * Saved the codec state.
|
---|
2657 | *
|
---|
2658 | * @returns VBox status code.
|
---|
2659 | * @param pDevIns The device instance of the HDA device.
|
---|
2660 | * @param pThis The codec instance data.
|
---|
2661 | * @param pSSM The saved state handle.
|
---|
2662 | */
|
---|
2663 | int hdaCodecSaveState(PPDMDEVINS pDevIns, PHDACODECR3 pThis, PSSMHANDLE pSSM)
|
---|
2664 | {
|
---|
2665 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
2666 | AssertLogRelMsgReturn(pThis->cTotalNodes == STAC9221_NUM_NODES, ("cTotalNodes=%#x, should be 0x1c", pThis->cTotalNodes),
|
---|
2667 | VERR_INTERNAL_ERROR);
|
---|
2668 | pHlp->pfnSSMPutU32(pSSM, pThis->cTotalNodes);
|
---|
2669 | for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
|
---|
2670 | pHlp->pfnSSMPutStructEx(pSSM, &pThis->aNodes[idxNode].SavedState, sizeof(pThis->aNodes[idxNode].SavedState),
|
---|
2671 | 0 /*fFlags*/, g_aCodecNodeFields, NULL /*pvUser*/);
|
---|
2672 | return VINF_SUCCESS;
|
---|
2673 | }
|
---|
2674 |
|
---|
2675 |
|
---|
2676 | /**
|
---|
2677 | * Loads the codec state.
|
---|
2678 | *
|
---|
2679 | * @returns VBox status code.
|
---|
2680 | * @param pDevIns The device instance of the HDA device.
|
---|
2681 | * @param pThis The codec instance data.
|
---|
2682 | * @param pSSM The saved state handle.
|
---|
2683 | * @param uVersion The state version.
|
---|
2684 | */
|
---|
2685 | int hdaR3CodecLoadState(PPDMDEVINS pDevIns, PHDACODECR3 pThis, PSSMHANDLE pSSM, uint32_t uVersion)
|
---|
2686 | {
|
---|
2687 | PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3;
|
---|
2688 | PCSSMFIELD pFields = NULL;
|
---|
2689 | uint32_t fFlags = 0;
|
---|
2690 | if (uVersion >= HDA_SAVED_STATE_VERSION_4)
|
---|
2691 | {
|
---|
2692 | /* Since version 4 a flexible node count is supported. */
|
---|
2693 | uint32_t cNodes;
|
---|
2694 | int rc2 = pHlp->pfnSSMGetU32(pSSM, &cNodes);
|
---|
2695 | AssertRCReturn(rc2, rc2);
|
---|
2696 | AssertReturn(cNodes == 0x1c, VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
2697 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2698 |
|
---|
2699 | pFields = g_aCodecNodeFields;
|
---|
2700 | fFlags = 0;
|
---|
2701 | }
|
---|
2702 | else if (uVersion >= HDA_SAVED_STATE_VERSION_2)
|
---|
2703 | {
|
---|
2704 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2705 | pFields = g_aCodecNodeFields;
|
---|
2706 | fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
|
---|
2707 | }
|
---|
2708 | else if (uVersion >= HDA_SAVED_STATE_VERSION_1)
|
---|
2709 | {
|
---|
2710 | AssertReturn(pThis->cTotalNodes == 0x1c, VERR_INTERNAL_ERROR);
|
---|
2711 | pFields = g_aCodecNodeFieldsV1;
|
---|
2712 | fFlags = SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED;
|
---|
2713 | }
|
---|
2714 | else
|
---|
2715 | AssertFailedReturn(VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
|
---|
2716 |
|
---|
2717 | for (unsigned idxNode = 0; idxNode < pThis->cTotalNodes; ++idxNode)
|
---|
2718 | {
|
---|
2719 | uint8_t idOld = pThis->aNodes[idxNode].SavedState.Core.uID;
|
---|
2720 | int rc = pHlp->pfnSSMGetStructEx(pSSM, &pThis->aNodes[idxNode].SavedState, sizeof(pThis->aNodes[idxNode].SavedState),
|
---|
2721 | fFlags, pFields, NULL);
|
---|
2722 | AssertRCReturn(rc, rc);
|
---|
2723 | AssertLogRelMsgReturn(idOld == pThis->aNodes[idxNode].SavedState.Core.uID,
|
---|
2724 | ("loaded %#x, expected %#x\n", pThis->aNodes[idxNode].SavedState.Core.uID, idOld),
|
---|
2725 | VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
|
---|
2726 | }
|
---|
2727 |
|
---|
2728 | /*
|
---|
2729 | * Update stuff after changing the state.
|
---|
2730 | */
|
---|
2731 | PCODECNODE pNode;
|
---|
2732 | if (hdaCodecIsDacNode(pThis, pThis->u8DacLineOut))
|
---|
2733 | {
|
---|
2734 | pNode = &pThis->aNodes[pThis->u8DacLineOut];
|
---|
2735 | hdaR3CodecToAudVolume(pThis, pNode, &pNode->dac.B_params, PDMAUDIOMIXERCTL_FRONT);
|
---|
2736 | }
|
---|
2737 | else if (hdaCodecIsSpdifOutNode(pThis, pThis->u8DacLineOut))
|
---|
2738 | {
|
---|
2739 | pNode = &pThis->aNodes[pThis->u8DacLineOut];
|
---|
2740 | hdaR3CodecToAudVolume(pThis, pNode, &pNode->spdifout.B_params, PDMAUDIOMIXERCTL_FRONT);
|
---|
2741 | }
|
---|
2742 |
|
---|
2743 | pNode = &pThis->aNodes[pThis->u8AdcVolsLineIn];
|
---|
2744 | hdaR3CodecToAudVolume(pThis, pNode, &pNode->adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2745 |
|
---|
2746 | LogFlowFuncLeaveRC(VINF_SUCCESS);
|
---|
2747 | return VINF_SUCCESS;
|
---|
2748 | }
|
---|
2749 |
|
---|
2750 |
|
---|
2751 | /**
|
---|
2752 | * Powers off the codec (ring-3).
|
---|
2753 | *
|
---|
2754 | * @param pThis The codec data.
|
---|
2755 | */
|
---|
2756 | void hdaR3CodecPowerOff(PHDACODECR3 pThis)
|
---|
2757 | {
|
---|
2758 | LogFlowFuncEnter();
|
---|
2759 | LogRel2(("HDA: Powering off codec ...\n"));
|
---|
2760 |
|
---|
2761 | int rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_FRONT, true /*fImmediate*/);
|
---|
2762 | AssertRC(rc2);
|
---|
2763 | #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
|
---|
2764 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_CENTER_LFE, true /*fImmediate*/);
|
---|
2765 | AssertRC(rc2);
|
---|
2766 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_REAR, true /*fImmediate*/);
|
---|
2767 | AssertRC(rc2);
|
---|
2768 | #endif
|
---|
2769 |
|
---|
2770 | #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2771 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_MIC_IN, true /*fImmediate*/);
|
---|
2772 | AssertRC(rc2);
|
---|
2773 | #endif
|
---|
2774 | rc2 = hdaR3CodecRemoveStream(pThis, PDMAUDIOMIXERCTL_LINE_IN, true /*fImmediate*/);
|
---|
2775 | AssertRC(rc2);
|
---|
2776 | }
|
---|
2777 |
|
---|
2778 |
|
---|
2779 | /**
|
---|
2780 | * Constructs a codec (ring-3).
|
---|
2781 | *
|
---|
2782 | * @returns VBox status code.
|
---|
2783 | * @param pDevIns The associated device instance.
|
---|
2784 | * @param pThis The codec data.
|
---|
2785 | * @param uLUN Device LUN to assign.
|
---|
2786 | * @param pCfg CFGM node to use for configuration.
|
---|
2787 | */
|
---|
2788 | int hdaR3CodecConstruct(PPDMDEVINS pDevIns, PHDACODECR3 pThis, uint16_t uLUN, PCFGMNODE pCfg)
|
---|
2789 | {
|
---|
2790 | AssertPtrReturn(pDevIns, VERR_INVALID_POINTER);
|
---|
2791 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2792 | AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
|
---|
2793 |
|
---|
2794 | pThis->id = uLUN;
|
---|
2795 | pThis->enmType = CODECTYPE_STAC9220; /** @todo Make this dynamic. */
|
---|
2796 |
|
---|
2797 | int rc;
|
---|
2798 |
|
---|
2799 | switch (pThis->enmType)
|
---|
2800 | {
|
---|
2801 | case CODECTYPE_STAC9220:
|
---|
2802 | {
|
---|
2803 | rc = stac9220Construct(pThis);
|
---|
2804 | AssertRCReturn(rc, rc);
|
---|
2805 | break;
|
---|
2806 | }
|
---|
2807 |
|
---|
2808 | default:
|
---|
2809 | AssertFailedReturn(VERR_NOT_IMPLEMENTED);
|
---|
2810 | break;
|
---|
2811 | }
|
---|
2812 |
|
---|
2813 | /*
|
---|
2814 | * Set initial volume.
|
---|
2815 | */
|
---|
2816 | PCODECNODE pNode = &pThis->aNodes[pThis->u8DacLineOut];
|
---|
2817 | rc = hdaR3CodecToAudVolume(pThis, pNode, &pNode->dac.B_params, PDMAUDIOMIXERCTL_FRONT);
|
---|
2818 | AssertRCReturn(rc, rc);
|
---|
2819 |
|
---|
2820 | pNode = &pThis->aNodes[pThis->u8AdcVolsLineIn];
|
---|
2821 | rc = hdaR3CodecToAudVolume(pThis, pNode, &pNode->adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN);
|
---|
2822 | AssertRCReturn(rc, rc);
|
---|
2823 |
|
---|
2824 | #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
2825 | # error "Implement mic-in support!"
|
---|
2826 | #endif
|
---|
2827 |
|
---|
2828 | /*
|
---|
2829 | * Statistics
|
---|
2830 | */
|
---|
2831 | PDMDevHlpSTAMRegister(pDevIns, &pThis->StatLookupsR3, STAMTYPE_COUNTER, "Codec/LookupsR0", STAMUNIT_OCCURENCES, "Number of R0 codecLookup calls");
|
---|
2832 | #if 0 /* Codec is not yet kosher enough for ring-0. @bugref{9890c64} */
|
---|
2833 | PDMDevHlpSTAMRegister(pDevIns, &pThis->StatLookupsR0, STAMTYPE_COUNTER, "Codec/LookupsR3", STAMUNIT_OCCURENCES, "Number of R3 codecLookup calls");
|
---|
2834 | #endif
|
---|
2835 |
|
---|
2836 | return rc;
|
---|
2837 | }
|
---|
2838 |
|
---|
2839 |
|
---|
2840 | /**
|
---|
2841 | * Destructs a codec.
|
---|
2842 | *
|
---|
2843 | * @param pThis Codec to destruct.
|
---|
2844 | */
|
---|
2845 | void hdaCodecDestruct(PHDACODECR3 pThis)
|
---|
2846 | {
|
---|
2847 | LogFlowFuncEnter();
|
---|
2848 |
|
---|
2849 | /* Nothing to do here atm. */
|
---|
2850 | RT_NOREF(pThis);
|
---|
2851 | }
|
---|
2852 |
|
---|
2853 |
|
---|
2854 | /**
|
---|
2855 | * Resets a codec.
|
---|
2856 | *
|
---|
2857 | * @param pThis Codec to reset.
|
---|
2858 | */
|
---|
2859 | void hdaCodecReset(PHDACODECR3 pThis)
|
---|
2860 | {
|
---|
2861 | switch (pThis->enmType)
|
---|
2862 | {
|
---|
2863 | case CODECTYPE_STAC9220:
|
---|
2864 | stac9220Reset(pThis);
|
---|
2865 | break;
|
---|
2866 |
|
---|
2867 | default:
|
---|
2868 | AssertFailed();
|
---|
2869 | break;
|
---|
2870 | }
|
---|
2871 | }
|
---|
2872 |
|
---|