1 | /* $Id: DevIchHda.cpp 55335 2015-04-17 16:00:22Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DevIchHda - VBox ICH Intel HD Audio Controller.
|
---|
4 | *
|
---|
5 | * Implemented against the specifications found in "High Definition Audio
|
---|
6 | * Specification", Revision 1.0a June 17, 2010, and "Intel I/O Controller
|
---|
7 | * HUB 6 (ICH6) Family, Datasheet", document number 301473-002.
|
---|
8 | */
|
---|
9 |
|
---|
10 | /*
|
---|
11 | * Copyright (C) 2006-2015 Oracle Corporation
|
---|
12 | *
|
---|
13 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | * available from http://www.virtualbox.org. This file is free software;
|
---|
15 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | * General Public License (GPL) as published by the Free Software
|
---|
17 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*******************************************************************************
|
---|
23 | * Header Files *
|
---|
24 | *******************************************************************************/
|
---|
25 | #include <VBox/vmm/pdmdev.h>
|
---|
26 | #include <VBox/vmm/pdmaudioifs.h>
|
---|
27 | #include <VBox/version.h>
|
---|
28 |
|
---|
29 | #include <iprt/assert.h>
|
---|
30 | #include <iprt/asm.h>
|
---|
31 | #include <iprt/asm-math.h>
|
---|
32 | #ifdef IN_RING3
|
---|
33 | # include <iprt/uuid.h>
|
---|
34 | # include <iprt/string.h>
|
---|
35 | # include <iprt/mem.h>
|
---|
36 | #endif
|
---|
37 | #include <iprt/list.h>
|
---|
38 |
|
---|
39 | #ifdef LOG_GROUP
|
---|
40 | # undef LOG_GROUP
|
---|
41 | #endif
|
---|
42 | #define LOG_GROUP LOG_GROUP_DEV_AUDIO
|
---|
43 | #include <VBox/log.h>
|
---|
44 |
|
---|
45 | #include "VBoxDD.h"
|
---|
46 |
|
---|
47 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
48 | # include "AudioMixer.h"
|
---|
49 | #else
|
---|
50 | extern "C" {
|
---|
51 | #include "audio.h"
|
---|
52 | }
|
---|
53 | #endif
|
---|
54 | #include "DevIchHdaCodec.h"
|
---|
55 |
|
---|
56 | /*******************************************************************************
|
---|
57 | * Defined Constants And Macros *
|
---|
58 | *******************************************************************************/
|
---|
59 | //#define HDA_AS_PCI_EXPRESS
|
---|
60 | #define VBOX_WITH_INTEL_HDA
|
---|
61 |
|
---|
62 | #if (defined(DEBUG) && defined(DEBUG_andy))
|
---|
63 | /* Enables experimental support for separate mic-in handling.
|
---|
64 | Do not enable this yet for regular builds, as this needs more testing first! */
|
---|
65 | # define VBOX_WITH_HDA_MIC_IN
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | #if defined(VBOX_WITH_HP_HDA)
|
---|
69 | /* HP Pavilion dv4t-1300 */
|
---|
70 | # define HDA_PCI_VENDOR_ID 0x103c
|
---|
71 | # define HDA_PCI_DEVICE_ID 0x30f7
|
---|
72 | #elif defined(VBOX_WITH_INTEL_HDA)
|
---|
73 | /* Intel HDA controller */
|
---|
74 | # define HDA_PCI_VENDOR_ID 0x8086
|
---|
75 | # define HDA_PCI_DEVICE_ID 0x2668
|
---|
76 | #elif defined(VBOX_WITH_NVIDIA_HDA)
|
---|
77 | /* nVidia HDA controller */
|
---|
78 | # define HDA_PCI_VENDOR_ID 0x10de
|
---|
79 | # define HDA_PCI_DEVICE_ID 0x0ac0
|
---|
80 | #else
|
---|
81 | # error "Please specify your HDA device vendor/device IDs"
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /** @todo r=bird: Looking at what the linux driver (accidentally?) does when
|
---|
85 | * updating CORBWP, I belive that the ICH6 datahsheet is wrong and that CORBRP
|
---|
86 | * is read only except for bit 15 like the HDA spec states.
|
---|
87 | *
|
---|
88 | * Btw. the CORBRPRST implementation is incomplete according to both docs (sw
|
---|
89 | * writes 1, hw sets it to 1 (after completion), sw reads 1, sw writes 0). */
|
---|
90 | #define BIRD_THINKS_CORBRP_IS_MOSTLY_RO
|
---|
91 |
|
---|
92 | #define HDA_NREGS 114
|
---|
93 | #define HDA_NREGS_SAVED 112
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * NB: Register values stored in memory (au32Regs[]) are indexed through
|
---|
97 | * the HDA_RMX_xxx macros (also HDA_MEM_IND_NAME()). On the other hand, the
|
---|
98 | * register descriptors in g_aHdaRegMap[] are indexed through the
|
---|
99 | * HDA_REG_xxx macros (also HDA_REG_IND_NAME()).
|
---|
100 | *
|
---|
101 | * The au32Regs[] layout is kept unchanged for saved state
|
---|
102 | * compatibility. */
|
---|
103 |
|
---|
104 | /* Registers */
|
---|
105 | #define HDA_REG_IND_NAME(x) HDA_REG_##x
|
---|
106 | #define HDA_MEM_IND_NAME(x) HDA_RMX_##x
|
---|
107 | #define HDA_REG_FIELD_MASK(reg, x) HDA_##reg##_##x##_MASK
|
---|
108 | #define HDA_REG_FIELD_FLAG_MASK(reg, x) RT_BIT(HDA_##reg##_##x##_SHIFT)
|
---|
109 | #define HDA_REG_FIELD_SHIFT(reg, x) HDA_##reg##_##x##_SHIFT
|
---|
110 | #define HDA_REG_IND(pThis, x) ((pThis)->au32Regs[g_aHdaRegMap[x].mem_idx])
|
---|
111 | #define HDA_REG(pThis, x) (HDA_REG_IND((pThis), HDA_REG_IND_NAME(x)))
|
---|
112 | #define HDA_REG_FLAG_VALUE(pThis, reg, val) (HDA_REG((pThis),reg) & (((HDA_REG_FIELD_FLAG_MASK(reg, val)))))
|
---|
113 |
|
---|
114 |
|
---|
115 | #define HDA_REG_GCAP 0 /* range 0x00-0x01*/
|
---|
116 | #define HDA_RMX_GCAP 0
|
---|
117 | /* GCAP HDASpec 3.3.2 This macro encodes the following information about HDA in a compact manner:
|
---|
118 | * oss (15:12) - number of output streams supported
|
---|
119 | * iss (11:8) - number of input streams supported
|
---|
120 | * bss (7:3) - number of bidirectional streams supported
|
---|
121 | * bds (2:1) - number of serial data out signals supported
|
---|
122 | * b64sup (0) - 64 bit addressing supported.
|
---|
123 | */
|
---|
124 | #define HDA_MAKE_GCAP(oss, iss, bss, bds, b64sup) \
|
---|
125 | ( (((oss) & 0xF) << 12) \
|
---|
126 | | (((iss) & 0xF) << 8) \
|
---|
127 | | (((bss) & 0x1F) << 3) \
|
---|
128 | | (((bds) & 0x3) << 2) \
|
---|
129 | | ((b64sup) & 1))
|
---|
130 |
|
---|
131 | #define HDA_REG_VMIN 1 /* 0x02 */
|
---|
132 | #define HDA_RMX_VMIN 1
|
---|
133 |
|
---|
134 | #define HDA_REG_VMAJ 2 /* 0x03 */
|
---|
135 | #define HDA_RMX_VMAJ 2
|
---|
136 |
|
---|
137 | #define HDA_REG_OUTPAY 3 /* 0x04-0x05 */
|
---|
138 | #define HDA_RMX_OUTPAY 3
|
---|
139 |
|
---|
140 | #define HDA_REG_INPAY 4 /* 0x06-0x07 */
|
---|
141 | #define HDA_RMX_INPAY 4
|
---|
142 |
|
---|
143 | #define HDA_REG_GCTL 5 /* 0x08-0x0B */
|
---|
144 | #define HDA_RMX_GCTL 5
|
---|
145 | #define HDA_GCTL_RST_SHIFT 0
|
---|
146 | #define HDA_GCTL_FSH_SHIFT 1
|
---|
147 | #define HDA_GCTL_UR_SHIFT 8
|
---|
148 |
|
---|
149 | #define HDA_REG_WAKEEN 6 /* 0x0C */
|
---|
150 | #define HDA_RMX_WAKEEN 6
|
---|
151 |
|
---|
152 | #define HDA_REG_STATESTS 7 /* 0x0E */
|
---|
153 | #define HDA_RMX_STATESTS 7
|
---|
154 | #define HDA_STATES_SCSF 0x7
|
---|
155 |
|
---|
156 | #define HDA_REG_GSTS 8 /* 0x10-0x11*/
|
---|
157 | #define HDA_RMX_GSTS 8
|
---|
158 | #define HDA_GSTS_FSH_SHIFT 1
|
---|
159 |
|
---|
160 | #define HDA_REG_OUTSTRMPAY 9 /* 0x18 */
|
---|
161 | #define HDA_RMX_OUTSTRMPAY 112
|
---|
162 |
|
---|
163 | #define HDA_REG_INSTRMPAY 10 /* 0x1a */
|
---|
164 | #define HDA_RMX_INSTRMPAY 113
|
---|
165 |
|
---|
166 | #define HDA_REG_INTCTL 11 /* 0x20 */
|
---|
167 | #define HDA_RMX_INTCTL 9
|
---|
168 | #define HDA_INTCTL_GIE_SHIFT 31
|
---|
169 | #define HDA_INTCTL_CIE_SHIFT 30
|
---|
170 | #define HDA_INTCTL_S0_SHIFT 0
|
---|
171 | #define HDA_INTCTL_S1_SHIFT 1
|
---|
172 | #define HDA_INTCTL_S2_SHIFT 2
|
---|
173 | #define HDA_INTCTL_S3_SHIFT 3
|
---|
174 | #define HDA_INTCTL_S4_SHIFT 4
|
---|
175 | #define HDA_INTCTL_S5_SHIFT 5
|
---|
176 | #define HDA_INTCTL_S6_SHIFT 6
|
---|
177 | #define HDA_INTCTL_S7_SHIFT 7
|
---|
178 | #define INTCTL_SX(pThis, X) (HDA_REG_FLAG_VALUE((pThis), INTCTL, S##X))
|
---|
179 |
|
---|
180 | #define HDA_REG_INTSTS 12 /* 0x24 */
|
---|
181 | #define HDA_RMX_INTSTS 10
|
---|
182 | #define HDA_INTSTS_GIS_SHIFT 31
|
---|
183 | #define HDA_INTSTS_CIS_SHIFT 30
|
---|
184 | #define HDA_INTSTS_S0_SHIFT 0
|
---|
185 | #define HDA_INTSTS_S1_SHIFT 1
|
---|
186 | #define HDA_INTSTS_S2_SHIFT 2
|
---|
187 | #define HDA_INTSTS_S3_SHIFT 3
|
---|
188 | #define HDA_INTSTS_S4_SHIFT 4
|
---|
189 | #define HDA_INTSTS_S5_SHIFT 5
|
---|
190 | #define HDA_INTSTS_S6_SHIFT 6
|
---|
191 | #define HDA_INTSTS_S7_SHIFT 7
|
---|
192 | #define HDA_INTSTS_S_MASK(num) RT_BIT(HDA_REG_FIELD_SHIFT(S##num))
|
---|
193 |
|
---|
194 | #define HDA_REG_WALCLK 13 /* 0x24 */
|
---|
195 | #define HDA_RMX_WALCLK /* Not defined! */
|
---|
196 |
|
---|
197 | /* Note: The HDA specification defines a SSYNC register at offset 0x38. The
|
---|
198 | * ICH6/ICH9 datahseet defines SSYNC at offset 0x34. The Linux HDA driver matches
|
---|
199 | * the datasheet.
|
---|
200 | */
|
---|
201 | #define HDA_REG_SSYNC 14 /* 0x34 */
|
---|
202 | #define HDA_RMX_SSYNC 12
|
---|
203 |
|
---|
204 | #define HDA_REG_CORBLBASE 15 /* 0x40 */
|
---|
205 | #define HDA_RMX_CORBLBASE 13
|
---|
206 |
|
---|
207 | #define HDA_REG_CORBUBASE 16 /* 0x44 */
|
---|
208 | #define HDA_RMX_CORBUBASE 14
|
---|
209 |
|
---|
210 | #define HDA_REG_CORBWP 17 /* 0x48 */
|
---|
211 | #define HDA_RMX_CORBWP 15
|
---|
212 |
|
---|
213 | #define HDA_REG_CORBRP 18 /* 0x4A */
|
---|
214 | #define HDA_RMX_CORBRP 16
|
---|
215 | #define HDA_CORBRP_RST_SHIFT 15
|
---|
216 | #define HDA_CORBRP_WP_SHIFT 0
|
---|
217 | #define HDA_CORBRP_WP_MASK 0xFF
|
---|
218 |
|
---|
219 | #define HDA_REG_CORBCTL 19 /* 0x4C */
|
---|
220 | #define HDA_RMX_CORBCTL 17
|
---|
221 | #define HDA_CORBCTL_DMA_SHIFT 1
|
---|
222 | #define HDA_CORBCTL_CMEIE_SHIFT 0
|
---|
223 |
|
---|
224 | #define HDA_REG_CORBSTS 20 /* 0x4D */
|
---|
225 | #define HDA_RMX_CORBSTS 18
|
---|
226 | #define HDA_CORBSTS_CMEI_SHIFT 0
|
---|
227 |
|
---|
228 | #define HDA_REG_CORBSIZE 21 /* 0x4E */
|
---|
229 | #define HDA_RMX_CORBSIZE 19
|
---|
230 | #define HDA_CORBSIZE_SZ_CAP 0xF0
|
---|
231 | #define HDA_CORBSIZE_SZ 0x3
|
---|
232 | /* till ich 10 sizes of CORB and RIRB are hardcoded to 256 in real hw */
|
---|
233 |
|
---|
234 | #define HDA_REG_RIRBLBASE 22 /* 0x50 */
|
---|
235 | #define HDA_RMX_RIRBLBASE 20
|
---|
236 |
|
---|
237 | #define HDA_REG_RIRBUBASE 23 /* 0x54 */
|
---|
238 | #define HDA_RMX_RIRBUBASE 21
|
---|
239 |
|
---|
240 | #define HDA_REG_RIRBWP 24 /* 0x58 */
|
---|
241 | #define HDA_RMX_RIRBWP 22
|
---|
242 | #define HDA_RIRBWP_RST_SHIFT 15
|
---|
243 | #define HDA_RIRBWP_WP_MASK 0xFF
|
---|
244 |
|
---|
245 | #define HDA_REG_RINTCNT 25 /* 0x5A */
|
---|
246 | #define HDA_RMX_RINTCNT 23
|
---|
247 | #define RINTCNT_N(pThis) (HDA_REG(pThis, RINTCNT) & 0xff)
|
---|
248 |
|
---|
249 | #define HDA_REG_RIRBCTL 26 /* 0x5C */
|
---|
250 | #define HDA_RMX_RIRBCTL 24
|
---|
251 | #define HDA_RIRBCTL_RIC_SHIFT 0
|
---|
252 | #define HDA_RIRBCTL_DMA_SHIFT 1
|
---|
253 | #define HDA_ROI_DMA_SHIFT 2
|
---|
254 |
|
---|
255 | #define HDA_REG_RIRBSTS 27 /* 0x5D */
|
---|
256 | #define HDA_RMX_RIRBSTS 25
|
---|
257 | #define HDA_RIRBSTS_RINTFL_SHIFT 0
|
---|
258 | #define HDA_RIRBSTS_RIRBOIS_SHIFT 2
|
---|
259 |
|
---|
260 | #define HDA_REG_RIRBSIZE 28 /* 0x5E */
|
---|
261 | #define HDA_RMX_RIRBSIZE 26
|
---|
262 | #define HDA_RIRBSIZE_SZ_CAP 0xF0
|
---|
263 | #define HDA_RIRBSIZE_SZ 0x3
|
---|
264 |
|
---|
265 | #define RIRBSIZE_SZ(pThis) (HDA_REG(pThis, HDA_REG_RIRBSIZE) & HDA_RIRBSIZE_SZ)
|
---|
266 | #define RIRBSIZE_SZ_CAP(pThis) (HDA_REG(pThis, HDA_REG_RIRBSIZE) & HDA_RIRBSIZE_SZ_CAP)
|
---|
267 |
|
---|
268 |
|
---|
269 | #define HDA_REG_IC 29 /* 0x60 */
|
---|
270 | #define HDA_RMX_IC 27
|
---|
271 |
|
---|
272 | #define HDA_REG_IR 30 /* 0x64 */
|
---|
273 | #define HDA_RMX_IR 28
|
---|
274 |
|
---|
275 | #define HDA_REG_IRS 31 /* 0x68 */
|
---|
276 | #define HDA_RMX_IRS 29
|
---|
277 | #define HDA_IRS_ICB_SHIFT 0
|
---|
278 | #define HDA_IRS_IRV_SHIFT 1
|
---|
279 |
|
---|
280 | #define HDA_REG_DPLBASE 32 /* 0x70 */
|
---|
281 | #define HDA_RMX_DPLBASE 30
|
---|
282 | #define DPLBASE(pThis) (HDA_REG((pThis), DPLBASE))
|
---|
283 |
|
---|
284 | #define HDA_REG_DPUBASE 33 /* 0x74 */
|
---|
285 | #define HDA_RMX_DPUBASE 31
|
---|
286 | #define DPUBASE(pThis) (HDA_REG((pThis), DPUBASE))
|
---|
287 | #define DPBASE_ENABLED 1
|
---|
288 | #define DPBASE_ADDR_MASK (~(uint64_t)0x7f)
|
---|
289 |
|
---|
290 | #define HDA_STREAM_REG_DEF(name, num) (HDA_REG_SD##num##name)
|
---|
291 | #define HDA_STREAM_RMX_DEF(name, num) (HDA_RMX_SD##num##name)
|
---|
292 | /* Note: sdnum here _MUST_ be stream reg number [0,7]. */
|
---|
293 | #define HDA_STREAM_REG(pThis, name, sdnum) (HDA_REG_IND((pThis), HDA_REG_SD0##name + (sdnum) * 10))
|
---|
294 |
|
---|
295 | #define HDA_REG_SD0CTL 34 /* 0x80 */
|
---|
296 | #define HDA_REG_SD1CTL (HDA_STREAM_REG_DEF(CTL, 0) + 10) /* 0xA0 */
|
---|
297 | #define HDA_REG_SD2CTL (HDA_STREAM_REG_DEF(CTL, 0) + 20) /* 0xC0 */
|
---|
298 | #define HDA_REG_SD3CTL (HDA_STREAM_REG_DEF(CTL, 0) + 30) /* 0xE0 */
|
---|
299 | #define HDA_REG_SD4CTL (HDA_STREAM_REG_DEF(CTL, 0) + 40) /* 0x100 */
|
---|
300 | #define HDA_REG_SD5CTL (HDA_STREAM_REG_DEF(CTL, 0) + 50) /* 0x120 */
|
---|
301 | #define HDA_REG_SD6CTL (HDA_STREAM_REG_DEF(CTL, 0) + 60) /* 0x140 */
|
---|
302 | #define HDA_REG_SD7CTL (HDA_STREAM_REG_DEF(CTL, 0) + 70) /* 0x160 */
|
---|
303 | #define HDA_RMX_SD0CTL 32
|
---|
304 | #define HDA_RMX_SD1CTL (HDA_STREAM_RMX_DEF(CTL, 0) + 10)
|
---|
305 | #define HDA_RMX_SD2CTL (HDA_STREAM_RMX_DEF(CTL, 0) + 20)
|
---|
306 | #define HDA_RMX_SD3CTL (HDA_STREAM_RMX_DEF(CTL, 0) + 30)
|
---|
307 | #define HDA_RMX_SD4CTL (HDA_STREAM_RMX_DEF(CTL, 0) + 40)
|
---|
308 | #define HDA_RMX_SD5CTL (HDA_STREAM_RMX_DEF(CTL, 0) + 50)
|
---|
309 | #define HDA_RMX_SD6CTL (HDA_STREAM_RMX_DEF(CTL, 0) + 60)
|
---|
310 | #define HDA_RMX_SD7CTL (HDA_STREAM_RMX_DEF(CTL, 0) + 70)
|
---|
311 |
|
---|
312 | #define SD(func, num) SD##num##func
|
---|
313 | #define SDCTL(pThis, num) HDA_REG((pThis), SD(CTL, num))
|
---|
314 | #define SDCTL_NUM(pThis, num) ((SDCTL((pThis), num) & HDA_REG_FIELD_MASK(SDCTL,NUM)) >> HDA_REG_FIELD_SHIFT(SDCTL, NUM))
|
---|
315 | #define HDA_SDCTL_NUM_MASK 0xF
|
---|
316 | #define HDA_SDCTL_NUM_SHIFT 20
|
---|
317 | #define HDA_SDCTL_DIR_SHIFT 19
|
---|
318 | #define HDA_SDCTL_TP_SHIFT 18
|
---|
319 | #define HDA_SDCTL_STRIPE_MASK 0x3
|
---|
320 | #define HDA_SDCTL_STRIPE_SHIFT 16
|
---|
321 | #define HDA_SDCTL_DEIE_SHIFT 4
|
---|
322 | #define HDA_SDCTL_FEIE_SHIFT 3
|
---|
323 | #define HDA_SDCTL_ICE_SHIFT 2
|
---|
324 | #define HDA_SDCTL_RUN_SHIFT 1
|
---|
325 | #define HDA_SDCTL_SRST_SHIFT 0
|
---|
326 |
|
---|
327 | #define HDA_REG_SD0STS 35 /* 0x83 */
|
---|
328 | #define HDA_REG_SD1STS (HDA_STREAM_REG_DEF(STS, 0) + 10) /* 0xA3 */
|
---|
329 | #define HDA_REG_SD2STS (HDA_STREAM_REG_DEF(STS, 0) + 20) /* 0xC3 */
|
---|
330 | #define HDA_REG_SD3STS (HDA_STREAM_REG_DEF(STS, 0) + 30) /* 0xE3 */
|
---|
331 | #define HDA_REG_SD4STS (HDA_STREAM_REG_DEF(STS, 0) + 40) /* 0x103 */
|
---|
332 | #define HDA_REG_SD5STS (HDA_STREAM_REG_DEF(STS, 0) + 50) /* 0x123 */
|
---|
333 | #define HDA_REG_SD6STS (HDA_STREAM_REG_DEF(STS, 0) + 60) /* 0x143 */
|
---|
334 | #define HDA_REG_SD7STS (HDA_STREAM_REG_DEF(STS, 0) + 70) /* 0x163 */
|
---|
335 | #define HDA_RMX_SD0STS 33
|
---|
336 | #define HDA_RMX_SD1STS (HDA_STREAM_RMX_DEF(STS, 0) + 10)
|
---|
337 | #define HDA_RMX_SD2STS (HDA_STREAM_RMX_DEF(STS, 0) + 20)
|
---|
338 | #define HDA_RMX_SD3STS (HDA_STREAM_RMX_DEF(STS, 0) + 30)
|
---|
339 | #define HDA_RMX_SD4STS (HDA_STREAM_RMX_DEF(STS, 0) + 40)
|
---|
340 | #define HDA_RMX_SD5STS (HDA_STREAM_RMX_DEF(STS, 0) + 50)
|
---|
341 | #define HDA_RMX_SD6STS (HDA_STREAM_RMX_DEF(STS, 0) + 60)
|
---|
342 | #define HDA_RMX_SD7STS (HDA_STREAM_RMX_DEF(STS, 0) + 70)
|
---|
343 |
|
---|
344 | #define SDSTS(pThis, num) HDA_REG((pThis), SD(STS, num))
|
---|
345 | #define HDA_SDSTS_FIFORDY_SHIFT 5
|
---|
346 | #define HDA_SDSTS_DE_SHIFT 4
|
---|
347 | #define HDA_SDSTS_FE_SHIFT 3
|
---|
348 | #define HDA_SDSTS_BCIS_SHIFT 2
|
---|
349 |
|
---|
350 | #define HDA_REG_SD0LPIB 36 /* 0x84 */
|
---|
351 | #define HDA_REG_SD1LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 10) /* 0xA4 */
|
---|
352 | #define HDA_REG_SD2LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 20) /* 0xC4 */
|
---|
353 | #define HDA_REG_SD3LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 30) /* 0xE4 */
|
---|
354 | #define HDA_REG_SD4LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 40) /* 0x104 */
|
---|
355 | #define HDA_REG_SD5LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 50) /* 0x124 */
|
---|
356 | #define HDA_REG_SD6LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 60) /* 0x144 */
|
---|
357 | #define HDA_REG_SD7LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 70) /* 0x164 */
|
---|
358 | #define HDA_RMX_SD0LPIB 34
|
---|
359 | #define HDA_RMX_SD1LPIB (HDA_STREAM_RMX_DEF(LPIB, 0) + 10)
|
---|
360 | #define HDA_RMX_SD2LPIB (HDA_STREAM_RMX_DEF(LPIB, 0) + 20)
|
---|
361 | #define HDA_RMX_SD3LPIB (HDA_STREAM_RMX_DEF(LPIB, 0) + 30)
|
---|
362 | #define HDA_RMX_SD4LPIB (HDA_STREAM_RMX_DEF(LPIB, 0) + 40)
|
---|
363 | #define HDA_RMX_SD5LPIB (HDA_STREAM_RMX_DEF(LPIB, 0) + 50)
|
---|
364 | #define HDA_RMX_SD6LPIB (HDA_STREAM_RMX_DEF(LPIB, 0) + 60)
|
---|
365 | #define HDA_RMX_SD7LPIB (HDA_STREAM_RMX_DEF(LPIB, 0) + 70)
|
---|
366 |
|
---|
367 | #define HDA_REG_SD0CBL 37 /* 0x88 */
|
---|
368 | #define HDA_REG_SD1CBL (HDA_STREAM_REG_DEF(CBL, 0) + 10) /* 0xA8 */
|
---|
369 | #define HDA_REG_SD2CBL (HDA_STREAM_REG_DEF(CBL, 0) + 20) /* 0xC8 */
|
---|
370 | #define HDA_REG_SD3CBL (HDA_STREAM_REG_DEF(CBL, 0) + 30) /* 0xE8 */
|
---|
371 | #define HDA_REG_SD4CBL (HDA_STREAM_REG_DEF(CBL, 0) + 40) /* 0x108 */
|
---|
372 | #define HDA_REG_SD5CBL (HDA_STREAM_REG_DEF(CBL, 0) + 50) /* 0x128 */
|
---|
373 | #define HDA_REG_SD6CBL (HDA_STREAM_REG_DEF(CBL, 0) + 60) /* 0x148 */
|
---|
374 | #define HDA_REG_SD7CBL (HDA_STREAM_REG_DEF(CBL, 0) + 70) /* 0x168 */
|
---|
375 | #define HDA_RMX_SD0CBL 35
|
---|
376 | #define HDA_RMX_SD1CBL (HDA_STREAM_RMX_DEF(CBL, 0) + 10)
|
---|
377 | #define HDA_RMX_SD2CBL (HDA_STREAM_RMX_DEF(CBL, 0) + 20)
|
---|
378 | #define HDA_RMX_SD3CBL (HDA_STREAM_RMX_DEF(CBL, 0) + 30)
|
---|
379 | #define HDA_RMX_SD4CBL (HDA_STREAM_RMX_DEF(CBL, 0) + 40)
|
---|
380 | #define HDA_RMX_SD5CBL (HDA_STREAM_RMX_DEF(CBL, 0) + 50)
|
---|
381 | #define HDA_RMX_SD6CBL (HDA_STREAM_RMX_DEF(CBL, 0) + 60)
|
---|
382 | #define HDA_RMX_SD7CBL (HDA_STREAM_RMX_DEF(CBL, 0) + 70)
|
---|
383 |
|
---|
384 |
|
---|
385 | #define HDA_REG_SD0LVI 38 /* 0x8C */
|
---|
386 | #define HDA_REG_SD1LVI (HDA_STREAM_REG_DEF(LVI, 0) + 10) /* 0xAC */
|
---|
387 | #define HDA_REG_SD2LVI (HDA_STREAM_REG_DEF(LVI, 0) + 20) /* 0xCC */
|
---|
388 | #define HDA_REG_SD3LVI (HDA_STREAM_REG_DEF(LVI, 0) + 30) /* 0xEC */
|
---|
389 | #define HDA_REG_SD4LVI (HDA_STREAM_REG_DEF(LVI, 0) + 40) /* 0x10C */
|
---|
390 | #define HDA_REG_SD5LVI (HDA_STREAM_REG_DEF(LVI, 0) + 50) /* 0x12C */
|
---|
391 | #define HDA_REG_SD6LVI (HDA_STREAM_REG_DEF(LVI, 0) + 60) /* 0x14C */
|
---|
392 | #define HDA_REG_SD7LVI (HDA_STREAM_REG_DEF(LVI, 0) + 70) /* 0x16C */
|
---|
393 | #define HDA_RMX_SD0LVI 36
|
---|
394 | #define HDA_RMX_SD1LVI (HDA_STREAM_RMX_DEF(LVI, 0) + 10)
|
---|
395 | #define HDA_RMX_SD2LVI (HDA_STREAM_RMX_DEF(LVI, 0) + 20)
|
---|
396 | #define HDA_RMX_SD3LVI (HDA_STREAM_RMX_DEF(LVI, 0) + 30)
|
---|
397 | #define HDA_RMX_SD4LVI (HDA_STREAM_RMX_DEF(LVI, 0) + 40)
|
---|
398 | #define HDA_RMX_SD5LVI (HDA_STREAM_RMX_DEF(LVI, 0) + 50)
|
---|
399 | #define HDA_RMX_SD6LVI (HDA_STREAM_RMX_DEF(LVI, 0) + 60)
|
---|
400 | #define HDA_RMX_SD7LVI (HDA_STREAM_RMX_DEF(LVI, 0) + 70)
|
---|
401 |
|
---|
402 | #define HDA_REG_SD0FIFOW 39 /* 0x8E */
|
---|
403 | #define HDA_REG_SD1FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 10) /* 0xAE */
|
---|
404 | #define HDA_REG_SD2FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 20) /* 0xCE */
|
---|
405 | #define HDA_REG_SD3FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 30) /* 0xEE */
|
---|
406 | #define HDA_REG_SD4FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 40) /* 0x10E */
|
---|
407 | #define HDA_REG_SD5FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 50) /* 0x12E */
|
---|
408 | #define HDA_REG_SD6FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 60) /* 0x14E */
|
---|
409 | #define HDA_REG_SD7FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 70) /* 0x16E */
|
---|
410 | #define HDA_RMX_SD0FIFOW 37
|
---|
411 | #define HDA_RMX_SD1FIFOW (HDA_STREAM_RMX_DEF(FIFOW, 0) + 10)
|
---|
412 | #define HDA_RMX_SD2FIFOW (HDA_STREAM_RMX_DEF(FIFOW, 0) + 20)
|
---|
413 | #define HDA_RMX_SD3FIFOW (HDA_STREAM_RMX_DEF(FIFOW, 0) + 30)
|
---|
414 | #define HDA_RMX_SD4FIFOW (HDA_STREAM_RMX_DEF(FIFOW, 0) + 40)
|
---|
415 | #define HDA_RMX_SD5FIFOW (HDA_STREAM_RMX_DEF(FIFOW, 0) + 50)
|
---|
416 | #define HDA_RMX_SD6FIFOW (HDA_STREAM_RMX_DEF(FIFOW, 0) + 60)
|
---|
417 | #define HDA_RMX_SD7FIFOW (HDA_STREAM_RMX_DEF(FIFOW, 0) + 70)
|
---|
418 |
|
---|
419 | /*
|
---|
420 | * ICH6 datasheet defined limits for FIFOW values (18.2.38)
|
---|
421 | */
|
---|
422 | #define HDA_SDFIFOW_8B 0x2
|
---|
423 | #define HDA_SDFIFOW_16B 0x3
|
---|
424 | #define HDA_SDFIFOW_32B 0x4
|
---|
425 |
|
---|
426 | #define HDA_REG_SD0FIFOS 40 /* 0x90 */
|
---|
427 | #define HDA_REG_SD1FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 10) /* 0xB0 */
|
---|
428 | #define HDA_REG_SD2FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 20) /* 0xD0 */
|
---|
429 | #define HDA_REG_SD3FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 30) /* 0xF0 */
|
---|
430 | #define HDA_REG_SD4FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 40) /* 0x110 */
|
---|
431 | #define HDA_REG_SD5FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 50) /* 0x130 */
|
---|
432 | #define HDA_REG_SD6FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 60) /* 0x150 */
|
---|
433 | #define HDA_REG_SD7FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 70) /* 0x170 */
|
---|
434 | #define HDA_RMX_SD0FIFOS 38
|
---|
435 | #define HDA_RMX_SD1FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 10)
|
---|
436 | #define HDA_RMX_SD2FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 20)
|
---|
437 | #define HDA_RMX_SD3FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 30)
|
---|
438 | #define HDA_RMX_SD4FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 40)
|
---|
439 | #define HDA_RMX_SD5FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 50)
|
---|
440 | #define HDA_RMX_SD6FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 60)
|
---|
441 | #define HDA_RMX_SD7FIFOS (HDA_STREAM_RMX_DEF(FIFOS, 0) + 70)
|
---|
442 |
|
---|
443 | /*
|
---|
444 | * ICH6 datasheet defines limits for FIFOS registers (18.2.39)
|
---|
445 | * formula: size - 1
|
---|
446 | * Other values not listed are not supported.
|
---|
447 | */
|
---|
448 | #define HDA_SDONFIFO_16B 0x0F /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
449 | #define HDA_SDONFIFO_32B 0x1F /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
450 | #define HDA_SDONFIFO_64B 0x3F /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
451 | #define HDA_SDONFIFO_128B 0x7F /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
452 | #define HDA_SDONFIFO_192B 0xBF /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
453 | #define HDA_SDONFIFO_256B 0xFF /* 20-, 24-bit Output Streams */
|
---|
454 | #define HDA_SDINFIFO_120B 0x77 /* 8-, 16-, 20-, 24-, 32-bit Input Streams */
|
---|
455 | #define HDA_SDINFIFO_160B 0x9F /* 20-, 24-bit Input Streams Streams */
|
---|
456 | #define SDFIFOS(pThis, num) HDA_REG((pThis), SD(FIFOS, num))
|
---|
457 |
|
---|
458 | #define HDA_REG_SD0FMT 41 /* 0x92 */
|
---|
459 | #define HDA_REG_SD1FMT (HDA_STREAM_REG_DEF(FMT, 0) + 10) /* 0xB2 */
|
---|
460 | #define HDA_REG_SD2FMT (HDA_STREAM_REG_DEF(FMT, 0) + 20) /* 0xD2 */
|
---|
461 | #define HDA_REG_SD3FMT (HDA_STREAM_REG_DEF(FMT, 0) + 30) /* 0xF2 */
|
---|
462 | #define HDA_REG_SD4FMT (HDA_STREAM_REG_DEF(FMT, 0) + 40) /* 0x112 */
|
---|
463 | #define HDA_REG_SD5FMT (HDA_STREAM_REG_DEF(FMT, 0) + 50) /* 0x132 */
|
---|
464 | #define HDA_REG_SD6FMT (HDA_STREAM_REG_DEF(FMT, 0) + 60) /* 0x152 */
|
---|
465 | #define HDA_REG_SD7FMT (HDA_STREAM_REG_DEF(FMT, 0) + 70) /* 0x172 */
|
---|
466 | #define HDA_RMX_SD0FMT 39
|
---|
467 | #define HDA_RMX_SD1FMT (HDA_STREAM_RMX_DEF(FMT, 0) + 10)
|
---|
468 | #define HDA_RMX_SD2FMT (HDA_STREAM_RMX_DEF(FMT, 0) + 20)
|
---|
469 | #define HDA_RMX_SD3FMT (HDA_STREAM_RMX_DEF(FMT, 0) + 30)
|
---|
470 | #define HDA_RMX_SD4FMT (HDA_STREAM_RMX_DEF(FMT, 0) + 40)
|
---|
471 | #define HDA_RMX_SD5FMT (HDA_STREAM_RMX_DEF(FMT, 0) + 50)
|
---|
472 | #define HDA_RMX_SD6FMT (HDA_STREAM_RMX_DEF(FMT, 0) + 60)
|
---|
473 | #define HDA_RMX_SD7FMT (HDA_STREAM_RMX_DEF(FMT, 0) + 70)
|
---|
474 |
|
---|
475 | #define SDFMT(pThis, num) (HDA_REG((pThis), SD(FMT, num)))
|
---|
476 | #define HDA_SDFMT_BASE_RATE_SHIFT 14
|
---|
477 | #define HDA_SDFMT_MULT_SHIFT 11
|
---|
478 | #define HDA_SDFMT_MULT_MASK 0x7
|
---|
479 | #define HDA_SDFMT_DIV_SHIFT 8
|
---|
480 | #define HDA_SDFMT_DIV_MASK 0x7
|
---|
481 | #define HDA_SDFMT_BITS_SHIFT 4
|
---|
482 | #define HDA_SDFMT_BITS_MASK 0x7
|
---|
483 | #define SDFMT_BASE_RATE(pThis, num) ((SDFMT(pThis, num) & HDA_REG_FIELD_FLAG_MASK(SDFMT, BASE_RATE)) >> HDA_REG_FIELD_SHIFT(SDFMT, BASE_RATE))
|
---|
484 | #define SDFMT_MULT(pThis, num) ((SDFMT((pThis), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT))
|
---|
485 | #define SDFMT_DIV(pThis, num) ((SDFMT((pThis), num) & HDA_REG_FIELD_MASK(SDFMT,DIV)) >> HDA_REG_FIELD_SHIFT(SDFMT, DIV))
|
---|
486 |
|
---|
487 | #define HDA_REG_SD0BDPL 42 /* 0x98 */
|
---|
488 | #define HDA_REG_SD1BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 10) /* 0xB8 */
|
---|
489 | #define HDA_REG_SD2BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 20) /* 0xD8 */
|
---|
490 | #define HDA_REG_SD3BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 30) /* 0xF8 */
|
---|
491 | #define HDA_REG_SD4BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 40) /* 0x118 */
|
---|
492 | #define HDA_REG_SD5BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 50) /* 0x138 */
|
---|
493 | #define HDA_REG_SD6BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 60) /* 0x158 */
|
---|
494 | #define HDA_REG_SD7BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 70) /* 0x178 */
|
---|
495 | #define HDA_RMX_SD0BDPL 40
|
---|
496 | #define HDA_RMX_SD1BDPL (HDA_STREAM_RMX_DEF(BDPL, 0) + 10)
|
---|
497 | #define HDA_RMX_SD2BDPL (HDA_STREAM_RMX_DEF(BDPL, 0) + 20)
|
---|
498 | #define HDA_RMX_SD3BDPL (HDA_STREAM_RMX_DEF(BDPL, 0) + 30)
|
---|
499 | #define HDA_RMX_SD4BDPL (HDA_STREAM_RMX_DEF(BDPL, 0) + 40)
|
---|
500 | #define HDA_RMX_SD5BDPL (HDA_STREAM_RMX_DEF(BDPL, 0) + 50)
|
---|
501 | #define HDA_RMX_SD6BDPL (HDA_STREAM_RMX_DEF(BDPL, 0) + 60)
|
---|
502 | #define HDA_RMX_SD7BDPL (HDA_STREAM_RMX_DEF(BDPL, 0) + 70)
|
---|
503 |
|
---|
504 | #define HDA_REG_SD0BDPU 43 /* 0x9C */
|
---|
505 | #define HDA_REG_SD1BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 10) /* 0xBC */
|
---|
506 | #define HDA_REG_SD2BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 20) /* 0xDC */
|
---|
507 | #define HDA_REG_SD3BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 30) /* 0xFC */
|
---|
508 | #define HDA_REG_SD4BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 40) /* 0x11C */
|
---|
509 | #define HDA_REG_SD5BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 50) /* 0x13C */
|
---|
510 | #define HDA_REG_SD6BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 60) /* 0x15C */
|
---|
511 | #define HDA_REG_SD7BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 70) /* 0x17C */
|
---|
512 | #define HDA_RMX_SD0BDPU 41
|
---|
513 | #define HDA_RMX_SD1BDPU (HDA_STREAM_RMX_DEF(BDPU, 0) + 10)
|
---|
514 | #define HDA_RMX_SD2BDPU (HDA_STREAM_RMX_DEF(BDPU, 0) + 20)
|
---|
515 | #define HDA_RMX_SD3BDPU (HDA_STREAM_RMX_DEF(BDPU, 0) + 30)
|
---|
516 | #define HDA_RMX_SD4BDPU (HDA_STREAM_RMX_DEF(BDPU, 0) + 40)
|
---|
517 | #define HDA_RMX_SD5BDPU (HDA_STREAM_RMX_DEF(BDPU, 0) + 50)
|
---|
518 | #define HDA_RMX_SD6BDPU (HDA_STREAM_RMX_DEF(BDPU, 0) + 60)
|
---|
519 | #define HDA_RMX_SD7BDPU (HDA_STREAM_RMX_DEF(BDPU, 0) + 70)
|
---|
520 |
|
---|
521 | #define HDA_CODEC_CAD_SHIFT 28
|
---|
522 | /* Encodes the (required) LUN into a codec command. */
|
---|
523 | #define HDA_CODEC_CMD(cmd, lun) ((cmd) | (lun << HDA_CODEC_CAD_SHIFT))
|
---|
524 |
|
---|
525 |
|
---|
526 |
|
---|
527 | /*******************************************************************************
|
---|
528 | * Structures and Typedefs *
|
---|
529 | *******************************************************************************/
|
---|
530 | typedef struct HDABDLEDESC
|
---|
531 | {
|
---|
532 | uint64_t u64BdleCviAddr;
|
---|
533 | uint32_t u32BdleMaxCvi;
|
---|
534 | uint32_t u32BdleCvi;
|
---|
535 | uint32_t u32BdleCviLen;
|
---|
536 | uint32_t u32BdleCviPos;
|
---|
537 | bool fBdleCviIoc;
|
---|
538 | uint32_t cbUnderFifoW;
|
---|
539 | uint8_t au8HdaBuffer[HDA_SDONFIFO_256B + 1];
|
---|
540 | } HDABDLEDESC, *PHDABDLEDESC;
|
---|
541 |
|
---|
542 | typedef struct HDASTREAMTRANSFERDESC
|
---|
543 | {
|
---|
544 | uint64_t u64BaseDMA;
|
---|
545 | uint32_t u32Ctl;
|
---|
546 | uint32_t *pu32Sts;
|
---|
547 | uint8_t u8Strm;
|
---|
548 | uint32_t *pu32Lpib;
|
---|
549 | uint32_t u32Cbl;
|
---|
550 | uint32_t u32Fifos;
|
---|
551 | } HDASTREAMTRANSFERDESC, *PHDASTREAMTRANSFERDESC;
|
---|
552 |
|
---|
553 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
554 | typedef struct HDAINPUTSTREAM
|
---|
555 | {
|
---|
556 | /** PCM line input stream. */
|
---|
557 | R3PTRTYPE(PPDMAUDIOGSTSTRMIN) pStrmIn;
|
---|
558 | /** Mixer handle for line input stream. */
|
---|
559 | R3PTRTYPE(PAUDMIXSTREAM) phStrmIn;
|
---|
560 | } HDAINPUTSTREAM, *PHDAINPUTSTREAM;
|
---|
561 |
|
---|
562 | typedef struct HDAOUTPUTSTREAM
|
---|
563 | {
|
---|
564 | /** PCM output stream. */
|
---|
565 | R3PTRTYPE(PPDMAUDIOGSTSTRMOUT) pStrmOut;
|
---|
566 | /** Mixer handle for line output stream. */
|
---|
567 | R3PTRTYPE(PAUDMIXSTREAM) phStrmOut;
|
---|
568 | } HDAOUTPUTSTREAM, *PHDAOUTPUTSTREAM;
|
---|
569 |
|
---|
570 | /**
|
---|
571 | * Struct for maintaining a host backend driver.
|
---|
572 | * This driver must be associated to one, and only one,
|
---|
573 | * HDA codec. The HDA controller does the actual multiplexing
|
---|
574 | * of HDA codec data to various host backend drivers then.
|
---|
575 | *
|
---|
576 | * This HDA device uses a timer in order to synchronize all
|
---|
577 | * read/write accesses across all attached LUNs / backends.
|
---|
578 | */
|
---|
579 | typedef struct HDADRIVER
|
---|
580 | {
|
---|
581 | union
|
---|
582 | {
|
---|
583 | /** Node for storing this driver in our device driver
|
---|
584 | * list of HDASTATE. */
|
---|
585 | RTLISTNODE Node;
|
---|
586 | struct
|
---|
587 | {
|
---|
588 | R3PTRTYPE(void *) dummy1;
|
---|
589 | R3PTRTYPE(void *) dummy2;
|
---|
590 | } dummy;
|
---|
591 | };
|
---|
592 |
|
---|
593 | /** Pointer to HDA controller (state). */
|
---|
594 | R3PTRTYPE(PHDASTATE) pHDAState;
|
---|
595 | /** Driver flags. */
|
---|
596 | PDMAUDIODRVFLAGS Flags;
|
---|
597 | uint8_t u32Padding0[3];
|
---|
598 | /** LUN to which this driver has been assigned. */
|
---|
599 | uint8_t uLUN;
|
---|
600 | /** Audio connector interface to the underlying
|
---|
601 | * host backend. */
|
---|
602 | R3PTRTYPE(PPDMIAUDIOCONNECTOR) pConnector;
|
---|
603 | /** Stream for line input. */
|
---|
604 | HDAINPUTSTREAM LineIn;
|
---|
605 | /** Stream for mic input. */
|
---|
606 | HDAINPUTSTREAM MicIn;
|
---|
607 | /** Stream for output. */
|
---|
608 | HDAOUTPUTSTREAM Out;
|
---|
609 | } HDADRIVER, *PHDADRIVER;
|
---|
610 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
611 |
|
---|
612 | /**
|
---|
613 | * ICH Intel HD Audio Controller state.
|
---|
614 | */
|
---|
615 | typedef struct HDASTATE
|
---|
616 | {
|
---|
617 | /** The PCI device structure. */
|
---|
618 | PCIDevice PciDev;
|
---|
619 | /** R3 Pointer to the device instance. */
|
---|
620 | PPDMDEVINSR3 pDevInsR3;
|
---|
621 | /** R0 Pointer to the device instance. */
|
---|
622 | PPDMDEVINSR0 pDevInsR0;
|
---|
623 | /** R0 Pointer to the device instance. */
|
---|
624 | PPDMDEVINSRC pDevInsRC;
|
---|
625 |
|
---|
626 | uint32_t u32Padding;
|
---|
627 |
|
---|
628 | /** Pointer to the attached audio driver. */
|
---|
629 | R3PTRTYPE(PPDMIBASE) pDrvBase;
|
---|
630 | /** The base interface for LUN\#0. */
|
---|
631 | PDMIBASE IBase;
|
---|
632 | RTGCPHYS MMIOBaseAddr;
|
---|
633 | uint32_t au32Regs[HDA_NREGS];
|
---|
634 | HDABDLEDESC StInBdle;
|
---|
635 | HDABDLEDESC StOutBdle;
|
---|
636 | HDABDLEDESC StMicBdle;
|
---|
637 | uint64_t u64CORBBase;
|
---|
638 | uint64_t u64RIRBBase;
|
---|
639 | uint64_t u64DPBase;
|
---|
640 | /** Pointer to CORB buffer. */
|
---|
641 | R3PTRTYPE(uint32_t *) pu32CorbBuf;
|
---|
642 | /** Size in bytes of CORB buffer. */
|
---|
643 | uint32_t cbCorbBuf;
|
---|
644 | uint32_t u32Padding2;
|
---|
645 | /** Pointer to RIRB buffer. */
|
---|
646 | R3PTRTYPE(uint64_t *) pu64RirbBuf;
|
---|
647 | /** Size in bytes of RIRB buffer. */
|
---|
648 | uint32_t cbRirbBuf;
|
---|
649 | /** Indicates if HDA is in reset. */
|
---|
650 | bool fInReset;
|
---|
651 | /** Interrupt on completion */
|
---|
652 | bool fCviIoc;
|
---|
653 | /** Flag whether the R0 part is enabled. */
|
---|
654 | bool fR0Enabled;
|
---|
655 | /** Flag whether the RC part is enabled. */
|
---|
656 | bool fRCEnabled;
|
---|
657 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
658 | /** The emulation timer for handling the attached
|
---|
659 | * LUN drivers. */
|
---|
660 | PTMTIMERR3 pTimer;
|
---|
661 | /** Timer ticks for handling the LUN drivers. */
|
---|
662 | uint64_t uTicks;
|
---|
663 | # ifdef VBOX_WITH_STATISTICS
|
---|
664 | STAMPROFILE StatTimer;
|
---|
665 | STAMCOUNTER StatBytesRead;
|
---|
666 | STAMCOUNTER StatBytesWritten;
|
---|
667 | # endif
|
---|
668 | /** Pointer to HDA codec to use. */
|
---|
669 | R3PTRTYPE(PHDACODEC) pCodec;
|
---|
670 | union
|
---|
671 | {
|
---|
672 | /** List of associated LUN drivers. */
|
---|
673 | RTLISTANCHOR lstDrv;
|
---|
674 | struct
|
---|
675 | {
|
---|
676 | R3PTRTYPE(void *) dummy1;
|
---|
677 | R3PTRTYPE(void *) dummy2;
|
---|
678 | } dummy;
|
---|
679 | };
|
---|
680 | /** The device' software mixer. */
|
---|
681 | R3PTRTYPE(PAUDIOMIXER) pMixer;
|
---|
682 | /** Audio sink for PCM output. */
|
---|
683 | R3PTRTYPE(PAUDMIXSINK) pSinkOutput;
|
---|
684 | /** Audio mixer sink for line input. */
|
---|
685 | R3PTRTYPE(PAUDMIXSINK) pSinkLineIn;
|
---|
686 | /** Audio mixer sink for microphone input. */
|
---|
687 | R3PTRTYPE(PAUDMIXSINK) pSinkMicIn;
|
---|
688 | #else /* !VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
689 | /** The HDA codec to use. */
|
---|
690 | R3PTRTYPE(PHDACODEC) pCodec;
|
---|
691 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
692 | uint64_t u64BaseTS;
|
---|
693 | /** 1.2.3.4.5.6.7. - someone please tell me what I'm counting! - .8.9.10... */
|
---|
694 | uint8_t u8Counter;
|
---|
695 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
696 | uint8_t au8Padding[7];
|
---|
697 | #else
|
---|
698 | uint8_t au8Padding[7];
|
---|
699 | #endif
|
---|
700 | } HDASTATE;
|
---|
701 | /** Pointer to the ICH Intel HD Audio Controller state. */
|
---|
702 | typedef HDASTATE *PHDASTATE;
|
---|
703 |
|
---|
704 | #define ISD0FMT_TO_AUDIO_SELECTOR(pThis) \
|
---|
705 | ( AUDIO_FORMAT_SELECTOR((pThis)->pCodec, In, SDFMT_BASE_RATE(pThis, 0), SDFMT_MULT(pThis, 0), SDFMT_DIV(pThis, 0)) )
|
---|
706 | #define OSD0FMT_TO_AUDIO_SELECTOR(pThis) \
|
---|
707 | ( AUDIO_FORMAT_SELECTOR((pThis)->pCodec, Out, SDFMT_BASE_RATE(pThis, 4), SDFMT_MULT(pThis, 4), SDFMT_DIV(pThis, 4)) )
|
---|
708 |
|
---|
709 |
|
---|
710 | /*******************************************************************************
|
---|
711 | * Internal Functions *
|
---|
712 | *******************************************************************************/
|
---|
713 | #ifndef VBOX_DEVICE_STRUCT_TESTCASE
|
---|
714 | static FNPDMDEVRESET hdaReset;
|
---|
715 |
|
---|
716 | static int hdaRegReadUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
717 | static int hdaRegWriteUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
718 | static int hdaRegWriteGCTL(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
719 | static int hdaRegReadSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
720 | static int hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
721 | static int hdaRegReadINTSTS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
722 | static int hdaRegReadWALCLK(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
723 | static int hdaRegWriteINTSTS(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
724 | static int hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
725 | static int hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
726 | static int hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
727 | static int hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
728 | static int hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
729 | static int hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
730 | static int hdaRegWriteIRS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
731 | static int hdaRegReadIRS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
732 | static int hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
733 |
|
---|
734 | static int hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
735 | static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
736 | static int hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
737 | static int hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
738 | static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
739 | static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
740 | static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
741 | static int hdaRegWriteBase(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
742 | static int hdaRegReadU32(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
743 | static int hdaRegWriteU32(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
744 | static int hdaRegReadU24(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
745 | static int hdaRegWriteU24(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
746 | static int hdaRegReadU16(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
747 | static int hdaRegWriteU16(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
748 | static int hdaRegReadU8(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
749 | static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value);
|
---|
750 |
|
---|
751 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
752 | static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);
|
---|
753 | static int hdaTransfer(PHDASTATE pThis, ENMSOUNDSOURCE enmSrc, uint32_t cbAvail);
|
---|
754 | #else
|
---|
755 | static int hdaTransfer(PHDACODEC pCodec, ENMSOUNDSOURCE enmSource, int cbAvail);
|
---|
756 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
757 |
|
---|
758 | #ifdef IN_RING3
|
---|
759 | DECLINLINE(void) hdaInitTransferDescriptor(PHDASTATE pThis, PHDABDLEDESC pBdle, uint8_t u8Strm,
|
---|
760 | PHDASTREAMTRANSFERDESC pStreamDesc);
|
---|
761 | static void hdaFetchBdle(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc);
|
---|
762 | #ifdef LOG_ENABLED
|
---|
763 | static void dump_bd(PHDASTATE pThis, PHDABDLEDESC pBdle, uint64_t u64BaseDMA);
|
---|
764 | #endif
|
---|
765 | #endif
|
---|
766 |
|
---|
767 |
|
---|
768 | /*******************************************************************************
|
---|
769 | * Global Variables *
|
---|
770 | *******************************************************************************/
|
---|
771 |
|
---|
772 | /* see 302349 p 6.2*/
|
---|
773 | static const struct HDAREGDESC
|
---|
774 | {
|
---|
775 | /** Register offset in the register space. */
|
---|
776 | uint32_t offset;
|
---|
777 | /** Size in bytes. Registers of size > 4 are in fact tables. */
|
---|
778 | uint32_t size;
|
---|
779 | /** Readable bits. */
|
---|
780 | uint32_t readable;
|
---|
781 | /** Writable bits. */
|
---|
782 | uint32_t writable;
|
---|
783 | /** Read callback. */
|
---|
784 | int (*pfnRead)(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value);
|
---|
785 | /** Write callback. */
|
---|
786 | int (*pfnWrite)(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value);
|
---|
787 | /** Index into the register storage array. */
|
---|
788 | uint32_t mem_idx;
|
---|
789 | /** Abbreviated name. */
|
---|
790 | const char *abbrev;
|
---|
791 | } g_aHdaRegMap[HDA_NREGS] =
|
---|
792 |
|
---|
793 | /* Turn a short register name into an memory index and a stringized name. */
|
---|
794 | #define RA(abbrev) HDA_MEM_IND_NAME(abbrev), #abbrev
|
---|
795 | /* Same as above for an input stream ('I' prefixed). */
|
---|
796 | #define IA(abbrev) HDA_MEM_IND_NAME(abbrev), "I"#abbrev
|
---|
797 | /* Same as above for an output stream ('O' prefixed). */
|
---|
798 | #define OA(abbrev) HDA_MEM_IND_NAME(abbrev), "O"#abbrev
|
---|
799 | /* Same as above for a register *not* stored in memory. */
|
---|
800 | #define UA(abbrev) 0, #abbrev
|
---|
801 |
|
---|
802 | {
|
---|
803 | /* offset size read mask write mask read callback write callback abbrev */
|
---|
804 | /*------- ------- ---------- ---------- ----------------------- ------------------------ ---------- */
|
---|
805 | { 0x00000, 0x00002, 0x0000FFFB, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimpl , RA(GCAP) }, /* Global Capabilities */
|
---|
806 | { 0x00002, 0x00001, 0x000000FF, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimpl , RA(VMIN) }, /* Minor Version */
|
---|
807 | { 0x00003, 0x00001, 0x000000FF, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimpl , RA(VMAJ) }, /* Major Version */
|
---|
808 | { 0x00004, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimpl , RA(OUTPAY) }, /* Output Payload Capabilities */
|
---|
809 | { 0x00006, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimpl , RA(INPAY) }, /* Input Payload Capabilities */
|
---|
810 | { 0x00008, 0x00004, 0x00000103, 0x00000103, hdaRegReadU32 , hdaRegWriteGCTL , RA(GCTL) }, /* Global Control */
|
---|
811 | { 0x0000c, 0x00002, 0x00007FFF, 0x00007FFF, hdaRegReadU16 , hdaRegWriteU16 , RA(WAKEEN) }, /* Wake Enable */
|
---|
812 | { 0x0000e, 0x00002, 0x00000007, 0x00000007, hdaRegReadU8 , hdaRegWriteSTATESTS , RA(STATESTS) }, /* State Change Status */
|
---|
813 | { 0x00010, 0x00002, 0xFFFFFFFF, 0x00000000, hdaRegReadUnimpl , hdaRegWriteUnimpl , RA(GSTS) }, /* Global Status */
|
---|
814 | { 0x00018, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimpl , RA(OUTSTRMPAY)}, /* Output Stream Payload Capability */
|
---|
815 | { 0x0001A, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimpl , RA(INSTRMPAY) }, /* Input Stream Payload Capability */
|
---|
816 | { 0x00020, 0x00004, 0xC00000FF, 0xC00000FF, hdaRegReadU32 , hdaRegWriteU32 , RA(INTCTL) }, /* Interrupt Control */
|
---|
817 | { 0x00024, 0x00004, 0xC00000FF, 0x00000000, hdaRegReadINTSTS , hdaRegWriteUnimpl , RA(INTSTS) }, /* Interrupt Status */
|
---|
818 | { 0x00030, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadWALCLK , hdaRegWriteUnimpl , UA(WALCLK) }, /* Wall Clock Counter */
|
---|
819 | /// @todo r=michaln: Doesn't the SSYNC register need to actually stop the stream(s)?
|
---|
820 | { 0x00034, 0x00004, 0x000000FF, 0x000000FF, hdaRegReadU32 , hdaRegWriteU32 , RA(SSYNC) }, /* Stream Synchronization */
|
---|
821 | { 0x00040, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteBase , RA(CORBLBASE) }, /* CORB Lower Base Address */
|
---|
822 | { 0x00044, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , RA(CORBUBASE) }, /* CORB Upper Base Address */
|
---|
823 | { 0x00048, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteCORBWP , RA(CORBWP) }, /* CORB Write Pointer */
|
---|
824 | { 0x0004A, 0x00002, 0x000080FF, 0x000080FF, hdaRegReadU16 , hdaRegWriteCORBRP , RA(CORBRP) }, /* CORB Read Pointer */
|
---|
825 | { 0x0004C, 0x00001, 0x00000003, 0x00000003, hdaRegReadU8 , hdaRegWriteCORBCTL , RA(CORBCTL) }, /* CORB Control */
|
---|
826 | { 0x0004D, 0x00001, 0x00000001, 0x00000001, hdaRegReadU8 , hdaRegWriteCORBSTS , RA(CORBSTS) }, /* CORB Status */
|
---|
827 | { 0x0004E, 0x00001, 0x000000F3, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimpl , RA(CORBSIZE) }, /* CORB Size */
|
---|
828 | { 0x00050, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteBase , RA(RIRBLBASE) }, /* RIRB Lower Base Address */
|
---|
829 | { 0x00054, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , RA(RIRBUBASE) }, /* RIRB Upper Base Address */
|
---|
830 | { 0x00058, 0x00002, 0x000000FF, 0x00008000, hdaRegReadU8 , hdaRegWriteRIRBWP , RA(RIRBWP) }, /* RIRB Write Pointer */
|
---|
831 | { 0x0005A, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , RA(RINTCNT) }, /* Response Interrupt Count */
|
---|
832 | { 0x0005C, 0x00001, 0x00000007, 0x00000007, hdaRegReadU8 , hdaRegWriteU8 , RA(RIRBCTL) }, /* RIRB Control */
|
---|
833 | { 0x0005D, 0x00001, 0x00000005, 0x00000005, hdaRegReadU8 , hdaRegWriteRIRBSTS , RA(RIRBSTS) }, /* RIRB Status */
|
---|
834 | { 0x0005E, 0x00001, 0x000000F3, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimpl , RA(RIRBSIZE) }, /* RIRB Size */
|
---|
835 | { 0x00060, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , RA(IC) }, /* Immediate Command */
|
---|
836 | { 0x00064, 0x00004, 0x00000000, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteUnimpl , RA(IR) }, /* Immediate Response */
|
---|
837 | { 0x00068, 0x00002, 0x00000002, 0x00000002, hdaRegReadIRS , hdaRegWriteIRS , RA(IRS) }, /* Immediate Command Status */
|
---|
838 | { 0x00070, 0x00004, 0xFFFFFFFF, 0xFFFFFF81, hdaRegReadU32 , hdaRegWriteBase , RA(DPLBASE) }, /* MA Position Lower Base */
|
---|
839 | { 0x00074, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , RA(DPUBASE) }, /* DMA Position Upper Base */
|
---|
840 |
|
---|
841 | { 0x00080, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , IA(SD0CTL) }, /* Input Stream Descriptor 0 (ICD0) Control */
|
---|
842 | { 0x00083, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , IA(SD0STS) }, /* ISD0 Status */
|
---|
843 | { 0x00084, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , IA(SD0LPIB) }, /* ISD0 Link Position In Buffer */
|
---|
844 | { 0x00088, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , IA(SD0CBL) }, /* ISD0 Cyclic Buffer Length */
|
---|
845 | { 0x0008C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , IA(SD0LVI) }, /* ISD0 Last Valid Index */
|
---|
846 | { 0x0008E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , IA(SD0FIFOW) }, /* ISD0 FIFO Watermark */
|
---|
847 | { 0x00090, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , IA(SD0FIFOS) }, /* ISD0 FIFO Size */
|
---|
848 | { 0x00092, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , IA(SD0FMT) }, /* ISD0 Format */
|
---|
849 | { 0x00098, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , IA(SD0BDPL) }, /* ISD0 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
850 | { 0x0009C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , IA(SD0BDPU) }, /* ISD0 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
851 |
|
---|
852 | { 0x000A0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , IA(SD1CTL) }, /* Input Stream Descriptor 1 (ISD1) Control */
|
---|
853 | { 0x000A3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , IA(SD1STS) }, /* ISD1 Status */
|
---|
854 | { 0x000A4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , IA(SD1LPIB) }, /* ISD1 Link Position In Buffer */
|
---|
855 | { 0x000A8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , IA(SD1CBL) }, /* ISD1 Cyclic Buffer Length */
|
---|
856 | { 0x000AC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , IA(SD1LVI) }, /* ISD1 Last Valid Index */
|
---|
857 | { 0x000AE, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , IA(SD1FIFOW) }, /* ISD1 FIFO Watermark */
|
---|
858 | { 0x000B0, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , IA(SD1FIFOS) }, /* ISD1 FIFO Size */
|
---|
859 | { 0x000B2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , IA(SD1FMT) }, /* ISD1 Format */
|
---|
860 | { 0x000B8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , IA(SD1BDPL) }, /* ISD1 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
861 | { 0x000BC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , IA(SD1BDPU) }, /* ISD1 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
862 |
|
---|
863 | { 0x000C0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , IA(SD2CTL) }, /* Input Stream Descriptor 2 (ISD2) Control */
|
---|
864 | { 0x000C3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , IA(SD2STS) }, /* ISD2 Status */
|
---|
865 | { 0x000C4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , IA(SD2LPIB) }, /* ISD2 Link Position In Buffer */
|
---|
866 | { 0x000C8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , IA(SD2CBL) }, /* ISD2 Cyclic Buffer Length */
|
---|
867 | { 0x000CC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , IA(SD2LVI) }, /* ISD2 Last Valid Index */
|
---|
868 | { 0x000CE, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , IA(SD2FIFOW) }, /* ISD2 FIFO Watermark */
|
---|
869 | { 0x000D0, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , IA(SD2FIFOS) }, /* ISD2 FIFO Size */
|
---|
870 | { 0x000D2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , IA(SD2FMT) }, /* ISD2 Format */
|
---|
871 | { 0x000D8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , IA(SD2BDPL) }, /* ISD2 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
872 | { 0x000DC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , IA(SD2BDPU) }, /* ISD2 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
873 |
|
---|
874 | { 0x000E0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , IA(SD3CTL) }, /* Input Stream Descriptor 3 (ISD3) Control */
|
---|
875 | { 0x000E3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , IA(SD3STS) }, /* ISD3 Status */
|
---|
876 | { 0x000E4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , IA(SD3LPIB) }, /* ISD3 Link Position In Buffer */
|
---|
877 | { 0x000E8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , IA(SD3CBL) }, /* ISD3 Cyclic Buffer Length */
|
---|
878 | { 0x000EC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , IA(SD3LVI) }, /* ISD3 Last Valid Index */
|
---|
879 | { 0x000EE, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , IA(SD3FIFOW) }, /* ISD3 FIFO Watermark */
|
---|
880 | { 0x000F0, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , IA(SD3FIFOS) }, /* ISD3 FIFO Size */
|
---|
881 | { 0x000F2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , IA(SD3FMT) }, /* ISD3 Format */
|
---|
882 | { 0x000F8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , IA(SD3BDPL) }, /* ISD3 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
883 | { 0x000FC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , IA(SD3BDPU) }, /* ISD3 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
884 |
|
---|
885 | { 0x00100, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , OA(SD4CTL) }, /* Output Stream Descriptor 4 (OSD4) Control */
|
---|
886 | { 0x00103, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , OA(SD4STS) }, /* OSD4 Status */
|
---|
887 | { 0x00104, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , OA(SD4LPIB) }, /* OSD4 Link Position In Buffer */
|
---|
888 | { 0x00108, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , OA(SD4CBL) }, /* OSD4 Cyclic Buffer Length */
|
---|
889 | { 0x0010C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , OA(SD4LVI) }, /* OSD4 Last Valid Index */
|
---|
890 | { 0x0010E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , OA(SD4FIFOW) }, /* OSD4 FIFO Watermark */
|
---|
891 | { 0x00110, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , OA(SD4FIFOS) }, /* OSD4 FIFO Size */
|
---|
892 | { 0x00112, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , OA(SD4FMT) }, /* OSD4 Format */
|
---|
893 | { 0x00118, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , OA(SD4BDPL) }, /* OSD4 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
894 | { 0x0011C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , OA(SD4BDPU) }, /* OSD4 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
895 |
|
---|
896 | { 0x00120, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , OA(SD5CTL) }, /* Output Stream Descriptor 5 (OSD5) Control */
|
---|
897 | { 0x00123, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , OA(SD5STS) }, /* OSD5 Status */
|
---|
898 | { 0x00124, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , OA(SD5LPIB) }, /* OSD5 Link Position In Buffer */
|
---|
899 | { 0x00128, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , OA(SD5CBL) }, /* OSD5 Cyclic Buffer Length */
|
---|
900 | { 0x0012C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , OA(SD5LVI) }, /* OSD5 Last Valid Index */
|
---|
901 | { 0x0012E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , OA(SD5FIFOW) }, /* OSD5 FIFO Watermark */
|
---|
902 | { 0x00130, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , OA(SD5FIFOS) }, /* OSD5 FIFO Size */
|
---|
903 | { 0x00132, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , OA(SD5FMT) }, /* OSD5 Format */
|
---|
904 | { 0x00138, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , OA(SD5BDPL) }, /* OSD5 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
905 | { 0x0013C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , OA(SD5BDPU) }, /* OSD5 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
906 |
|
---|
907 | { 0x00140, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , OA(SD6CTL) }, /* Output Stream Descriptor 6 (OSD6) Control */
|
---|
908 | { 0x00143, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , OA(SD6STS) }, /* OSD6 Status */
|
---|
909 | { 0x00144, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , OA(SD6LPIB) }, /* OSD6 Link Position In Buffer */
|
---|
910 | { 0x00148, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , OA(SD6CBL) }, /* OSD6 Cyclic Buffer Length */
|
---|
911 | { 0x0014C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , OA(SD6LVI) }, /* OSD6 Last Valid Index */
|
---|
912 | { 0x0014E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , OA(SD6FIFOW) }, /* OSD6 FIFO Watermark */
|
---|
913 | { 0x00150, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , OA(SD6FIFOS) }, /* OSD6 FIFO Size */
|
---|
914 | { 0x00152, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , OA(SD6FMT) }, /* OSD6 Format */
|
---|
915 | { 0x00158, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , OA(SD6BDPL) }, /* OSD6 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
916 | { 0x0015C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , OA(SD6BDPU) }, /* OSD6 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
917 |
|
---|
918 | { 0x00160, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , OA(SD7CTL) }, /* Output Stream Descriptor 7 (OSD7) Control */
|
---|
919 | { 0x00163, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , OA(SD7STS) }, /* OSD7 Status */
|
---|
920 | { 0x00164, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , OA(SD7LPIB) }, /* OSD7 Link Position In Buffer */
|
---|
921 | { 0x00168, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , OA(SD7CBL) }, /* OSD7 Cyclic Buffer Length */
|
---|
922 | { 0x0016C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , OA(SD7LVI) }, /* OSD7 Last Valid Index */
|
---|
923 | { 0x0016E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , OA(SD7FIFOW) }, /* OSD7 FIFO Watermark */
|
---|
924 | { 0x00170, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , OA(SD7FIFOS) }, /* OSD7 FIFO Size */
|
---|
925 | { 0x00172, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteSDFMT , OA(SD7FMT) }, /* OSD7 Format */
|
---|
926 | { 0x00178, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , OA(SD7BDPL) }, /* OSD7 Buffer Descriptor List Pointer-Lower Base Address */
|
---|
927 | { 0x0017C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , OA(SD7BDPU) }, /* OSD7 Buffer Descriptor List Pointer-Upper Base Address */
|
---|
928 | };
|
---|
929 |
|
---|
930 | /**
|
---|
931 | * HDA register aliases (HDA spec 3.3.45).
|
---|
932 | * @remarks Sorted by offReg.
|
---|
933 | */
|
---|
934 | static const struct
|
---|
935 | {
|
---|
936 | /** The alias register offset. */
|
---|
937 | uint32_t offReg;
|
---|
938 | /** The register index. */
|
---|
939 | int idxAlias;
|
---|
940 | } g_aHdaRegAliases[] =
|
---|
941 | {
|
---|
942 | { 0x2084, HDA_REG_SD0LPIB },
|
---|
943 | { 0x20a4, HDA_REG_SD1LPIB },
|
---|
944 | { 0x20c4, HDA_REG_SD2LPIB },
|
---|
945 | { 0x20e4, HDA_REG_SD3LPIB },
|
---|
946 | { 0x2104, HDA_REG_SD4LPIB },
|
---|
947 | { 0x2124, HDA_REG_SD5LPIB },
|
---|
948 | { 0x2144, HDA_REG_SD6LPIB },
|
---|
949 | { 0x2164, HDA_REG_SD7LPIB },
|
---|
950 | };
|
---|
951 |
|
---|
952 | #ifdef IN_RING3
|
---|
953 | /** HDABDLEDESC field descriptors the v3+ saved state. */
|
---|
954 | static SSMFIELD const g_aHdaBDLEDescFields[] =
|
---|
955 | {
|
---|
956 | SSMFIELD_ENTRY( HDABDLEDESC, u64BdleCviAddr),
|
---|
957 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleMaxCvi),
|
---|
958 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCvi),
|
---|
959 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviLen),
|
---|
960 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos),
|
---|
961 | SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc),
|
---|
962 | SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW),
|
---|
963 | SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer),
|
---|
964 | SSMFIELD_ENTRY_TERM()
|
---|
965 | };
|
---|
966 |
|
---|
967 | /** HDABDLEDESC field descriptors the v1 and v2 saved state. */
|
---|
968 | static SSMFIELD const g_aHdaBDLEDescFieldsOld[] =
|
---|
969 | {
|
---|
970 | SSMFIELD_ENTRY( HDABDLEDESC, u64BdleCviAddr),
|
---|
971 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleMaxCvi),
|
---|
972 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCvi),
|
---|
973 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviLen),
|
---|
974 | SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos),
|
---|
975 | SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc),
|
---|
976 | SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3),
|
---|
977 | SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW),
|
---|
978 | SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer),
|
---|
979 | SSMFIELD_ENTRY_TERM()
|
---|
980 | };
|
---|
981 | #endif
|
---|
982 |
|
---|
983 | /**
|
---|
984 | * 32-bit size indexed masks, i.e. g_afMasks[2 bytes] = 0xffff.
|
---|
985 | */
|
---|
986 | static uint32_t const g_afMasks[5] =
|
---|
987 | {
|
---|
988 | UINT32_C(0), UINT32_C(0x000000ff), UINT32_C(0x0000ffff), UINT32_C(0x00ffffff), UINT32_C(0xffffffff)
|
---|
989 | };
|
---|
990 |
|
---|
991 | #ifdef IN_RING3
|
---|
992 | DECLINLINE(void) hdaUpdatePosBuf(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc)
|
---|
993 | {
|
---|
994 | if (pThis->u64DPBase & DPBASE_ENABLED)
|
---|
995 | PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns),
|
---|
996 | (pThis->u64DPBase & DPBASE_ADDR_MASK) + pStreamDesc->u8Strm * 8,
|
---|
997 | pStreamDesc->pu32Lpib, sizeof(uint32_t));
|
---|
998 | }
|
---|
999 | #endif
|
---|
1000 |
|
---|
1001 | DECLINLINE(uint32_t) hdaFifoWToSz(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc)
|
---|
1002 | {
|
---|
1003 | #if 0
|
---|
1004 | switch(HDA_STREAM_REG(pThis, FIFOW, pStreamDesc->u8Strm))
|
---|
1005 | {
|
---|
1006 | case HDA_SDFIFOW_8B: return 8;
|
---|
1007 | case HDA_SDFIFOW_16B: return 16;
|
---|
1008 | case HDA_SDFIFOW_32B: return 32;
|
---|
1009 | default:
|
---|
1010 | AssertMsgFailed(("unsupported value (%x) in SDFIFOW(,%d)\n", HDA_REG_IND(pThis, pStreamDesc->u8Strm), pStreamDesc->u8Strm));
|
---|
1011 | }
|
---|
1012 | #endif
|
---|
1013 | return 0;
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | static int hdaProcessInterrupt(PHDASTATE pThis)
|
---|
1017 | {
|
---|
1018 | #define IS_INTERRUPT_OCCURED_AND_ENABLED(pThis, num) \
|
---|
1019 | ( INTCTL_SX((pThis), num) \
|
---|
1020 | && (SDSTS(pThis, num) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))
|
---|
1021 | bool fIrq = false;
|
---|
1022 | if ( HDA_REG_FLAG_VALUE(pThis, INTCTL, CIE)
|
---|
1023 | && ( HDA_REG_FLAG_VALUE(pThis, RIRBSTS, RINTFL)
|
---|
1024 | || HDA_REG_FLAG_VALUE(pThis, RIRBSTS, RIRBOIS)
|
---|
1025 | || (HDA_REG(pThis, STATESTS) & HDA_REG(pThis, WAKEEN))))
|
---|
1026 | fIrq = true;
|
---|
1027 |
|
---|
1028 | if ( IS_INTERRUPT_OCCURED_AND_ENABLED(pThis, 0)
|
---|
1029 | || IS_INTERRUPT_OCCURED_AND_ENABLED(pThis, 4))
|
---|
1030 | fIrq = true;
|
---|
1031 |
|
---|
1032 | if (HDA_REG_FLAG_VALUE(pThis, INTCTL, GIE))
|
---|
1033 | {
|
---|
1034 | LogFunc(("irq %s\n", fIrq ? "asserted" : "deasserted"));
|
---|
1035 | PDMDevHlpPCISetIrq(pThis->CTX_SUFF(pDevIns), 0 , fIrq);
|
---|
1036 | }
|
---|
1037 | return VINF_SUCCESS;
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 | /**
|
---|
1041 | * Looks up a register at the exact offset given by @a offReg.
|
---|
1042 | *
|
---|
1043 | * @returns Register index on success, -1 if not found.
|
---|
1044 | * @param pThis The HDA device state.
|
---|
1045 | * @param offReg The register offset.
|
---|
1046 | */
|
---|
1047 | static int hdaRegLookup(PHDASTATE pThis, uint32_t offReg)
|
---|
1048 | {
|
---|
1049 | /*
|
---|
1050 | * Aliases.
|
---|
1051 | */
|
---|
1052 | if (offReg >= g_aHdaRegAliases[0].offReg)
|
---|
1053 | {
|
---|
1054 | for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegAliases); i++)
|
---|
1055 | if (offReg == g_aHdaRegAliases[i].offReg)
|
---|
1056 | return g_aHdaRegAliases[i].idxAlias;
|
---|
1057 | Assert(g_aHdaRegMap[RT_ELEMENTS(g_aHdaRegMap) - 1].offset < offReg);
|
---|
1058 | return -1;
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | /*
|
---|
1062 | * Binary search the
|
---|
1063 | */
|
---|
1064 | int idxEnd = RT_ELEMENTS(g_aHdaRegMap);
|
---|
1065 | int idxLow = 0;
|
---|
1066 | for (;;)
|
---|
1067 | {
|
---|
1068 | int idxMiddle = idxLow + (idxEnd - idxLow) / 2;
|
---|
1069 | if (offReg < g_aHdaRegMap[idxMiddle].offset)
|
---|
1070 | {
|
---|
1071 | if (idxLow == idxMiddle)
|
---|
1072 | break;
|
---|
1073 | idxEnd = idxMiddle;
|
---|
1074 | }
|
---|
1075 | else if (offReg > g_aHdaRegMap[idxMiddle].offset)
|
---|
1076 | {
|
---|
1077 | idxLow = idxMiddle + 1;
|
---|
1078 | if (idxLow >= idxEnd)
|
---|
1079 | break;
|
---|
1080 | }
|
---|
1081 | else
|
---|
1082 | return idxMiddle;
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | #ifdef RT_STRICT
|
---|
1086 | for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegMap); i++)
|
---|
1087 | Assert(g_aHdaRegMap[i].offset != offReg);
|
---|
1088 | #endif
|
---|
1089 | return -1;
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | /**
|
---|
1093 | * Looks up a register covering the offset given by @a offReg.
|
---|
1094 | *
|
---|
1095 | * @returns Register index on success, -1 if not found.
|
---|
1096 | * @param pThis The HDA device state.
|
---|
1097 | * @param offReg The register offset.
|
---|
1098 | */
|
---|
1099 | static int hdaRegLookupWithin(PHDASTATE pThis, uint32_t offReg)
|
---|
1100 | {
|
---|
1101 | /*
|
---|
1102 | * Aliases.
|
---|
1103 | */
|
---|
1104 | if (offReg >= g_aHdaRegAliases[0].offReg)
|
---|
1105 | {
|
---|
1106 | for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegAliases); i++)
|
---|
1107 | {
|
---|
1108 | uint32_t off = offReg - g_aHdaRegAliases[i].offReg;
|
---|
1109 | if (off < 4 && off < g_aHdaRegMap[g_aHdaRegAliases[i].idxAlias].size)
|
---|
1110 | return g_aHdaRegAliases[i].idxAlias;
|
---|
1111 | }
|
---|
1112 | Assert(g_aHdaRegMap[RT_ELEMENTS(g_aHdaRegMap) - 1].offset < offReg);
|
---|
1113 | return -1;
|
---|
1114 | }
|
---|
1115 |
|
---|
1116 | /*
|
---|
1117 | * Binary search the
|
---|
1118 | */
|
---|
1119 | int idxEnd = RT_ELEMENTS(g_aHdaRegMap);
|
---|
1120 | int idxLow = 0;
|
---|
1121 | for (;;)
|
---|
1122 | {
|
---|
1123 | int idxMiddle = idxLow + (idxEnd - idxLow) / 2;
|
---|
1124 | if (offReg < g_aHdaRegMap[idxMiddle].offset)
|
---|
1125 | {
|
---|
1126 | if (idxLow == idxMiddle)
|
---|
1127 | break;
|
---|
1128 | idxEnd = idxMiddle;
|
---|
1129 | }
|
---|
1130 | else if (offReg >= g_aHdaRegMap[idxMiddle].offset + g_aHdaRegMap[idxMiddle].size)
|
---|
1131 | {
|
---|
1132 | idxLow = idxMiddle + 1;
|
---|
1133 | if (idxLow >= idxEnd)
|
---|
1134 | break;
|
---|
1135 | }
|
---|
1136 | else
|
---|
1137 | return idxMiddle;
|
---|
1138 | }
|
---|
1139 |
|
---|
1140 | #ifdef RT_STRICT
|
---|
1141 | for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegMap); i++)
|
---|
1142 | Assert(offReg - g_aHdaRegMap[i].offset >= g_aHdaRegMap[i].size);
|
---|
1143 | #endif
|
---|
1144 | return -1;
|
---|
1145 | }
|
---|
1146 |
|
---|
1147 | #ifdef IN_RING3
|
---|
1148 | static int hdaCmdSync(PHDASTATE pThis, bool fLocal)
|
---|
1149 | {
|
---|
1150 | int rc = VINF_SUCCESS;
|
---|
1151 | if (fLocal)
|
---|
1152 | {
|
---|
1153 | Assert((HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA)));
|
---|
1154 | rc = PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pThis->u64CORBBase, pThis->pu32CorbBuf, pThis->cbCorbBuf);
|
---|
1155 | if (RT_FAILURE(rc))
|
---|
1156 | AssertRCReturn(rc, rc);
|
---|
1157 | #ifdef DEBUG_CMD_BUFFER
|
---|
1158 | uint8_t i = 0;
|
---|
1159 | do
|
---|
1160 | {
|
---|
1161 | LogFunc(("corb%02x: ", i));
|
---|
1162 | uint8_t j = 0;
|
---|
1163 | do
|
---|
1164 | {
|
---|
1165 | const char *prefix;
|
---|
1166 | if ((i + j) == HDA_REG(pThis, CORBRP);
|
---|
1167 | prefix = "[R]";
|
---|
1168 | else if ((i + j) == HDA_REG(pThis, CORBWP);
|
---|
1169 | prefix = "[W]";
|
---|
1170 | else
|
---|
1171 | prefix = " "; /* three spaces */
|
---|
1172 | LogFunc(("%s%08x", prefix, pThis->pu32CorbBuf[i + j]));
|
---|
1173 | j++;
|
---|
1174 | } while (j < 8);
|
---|
1175 | LogFunc(("\n"));
|
---|
1176 | i += 8;
|
---|
1177 | } while(i != 0);
|
---|
1178 | #endif
|
---|
1179 | }
|
---|
1180 | else
|
---|
1181 | {
|
---|
1182 | Assert((HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA)));
|
---|
1183 | rc = PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), pThis->u64RIRBBase, pThis->pu64RirbBuf, pThis->cbRirbBuf);
|
---|
1184 | if (RT_FAILURE(rc))
|
---|
1185 | AssertRCReturn(rc, rc);
|
---|
1186 | #ifdef DEBUG_CMD_BUFFER
|
---|
1187 | uint8_t i = 0;
|
---|
1188 | do {
|
---|
1189 | LogFunc(("rirb%02x: ", i));
|
---|
1190 | uint8_t j = 0;
|
---|
1191 | do {
|
---|
1192 | const char *prefix;
|
---|
1193 | if ((i + j) == HDA_REG(pThis, RIRBWP))
|
---|
1194 | prefix = "[W]";
|
---|
1195 | else
|
---|
1196 | prefix = " ";
|
---|
1197 | LogFunc((" %s%016lx", prefix, pThis->pu64RirbBuf[i + j]));
|
---|
1198 | } while (++j < 8);
|
---|
1199 | LogFunc(("\n"));
|
---|
1200 | i += 8;
|
---|
1201 | } while (i != 0);
|
---|
1202 | #endif
|
---|
1203 | }
|
---|
1204 | return rc;
|
---|
1205 | }
|
---|
1206 |
|
---|
1207 | static int hdaCORBCmdProcess(PHDASTATE pThis)
|
---|
1208 | {
|
---|
1209 | int rc;
|
---|
1210 | uint8_t corbRp;
|
---|
1211 | uint8_t corbWp;
|
---|
1212 | uint8_t rirbWp;
|
---|
1213 |
|
---|
1214 | PFNHDACODECVERBPROCESSOR pfn = (PFNHDACODECVERBPROCESSOR)NULL;
|
---|
1215 |
|
---|
1216 | rc = hdaCmdSync(pThis, true);
|
---|
1217 | if (RT_FAILURE(rc))
|
---|
1218 | AssertRCReturn(rc, rc);
|
---|
1219 | corbRp = HDA_REG(pThis, CORBRP);
|
---|
1220 | corbWp = HDA_REG(pThis, CORBWP);
|
---|
1221 | rirbWp = HDA_REG(pThis, RIRBWP);
|
---|
1222 | Assert((corbWp != corbRp));
|
---|
1223 | LogFlowFunc(("CORB(RP:%x, WP:%x) RIRBWP:%x\n", HDA_REG(pThis, CORBRP),
|
---|
1224 | HDA_REG(pThis, CORBWP), HDA_REG(pThis, RIRBWP)));
|
---|
1225 | while (corbRp != corbWp)
|
---|
1226 | {
|
---|
1227 | uint32_t cmd;
|
---|
1228 | uint64_t resp;
|
---|
1229 | pfn = NULL;
|
---|
1230 | corbRp++;
|
---|
1231 | cmd = pThis->pu32CorbBuf[corbRp];
|
---|
1232 |
|
---|
1233 | rc = pThis->pCodec->pfnLookup(pThis->pCodec,
|
---|
1234 | HDA_CODEC_CMD(cmd, 0 /* Codec index */),
|
---|
1235 | &pfn);
|
---|
1236 | if (RT_SUCCESS(rc))
|
---|
1237 | {
|
---|
1238 | rc = pfn(pThis->pCodec,
|
---|
1239 | HDA_CODEC_CMD(cmd, 0 /* LUN */), &resp);
|
---|
1240 | }
|
---|
1241 |
|
---|
1242 | if (RT_FAILURE(rc))
|
---|
1243 | AssertRCReturn(rc, rc);
|
---|
1244 | Assert(pfn);
|
---|
1245 | (rirbWp)++;
|
---|
1246 |
|
---|
1247 | LogFunc(("verb:%08x->%016lx\n", cmd, resp));
|
---|
1248 | if ( (resp & CODEC_RESPONSE_UNSOLICITED)
|
---|
1249 | && !HDA_REG_FLAG_VALUE(pThis, GCTL, UR))
|
---|
1250 | {
|
---|
1251 | LogFunc(("unexpected unsolicited response.\n"));
|
---|
1252 | HDA_REG(pThis, CORBRP) = corbRp;
|
---|
1253 | return rc;
|
---|
1254 | }
|
---|
1255 | pThis->pu64RirbBuf[rirbWp] = resp;
|
---|
1256 | pThis->u8Counter++;
|
---|
1257 | if (pThis->u8Counter == RINTCNT_N(pThis))
|
---|
1258 | break;
|
---|
1259 | }
|
---|
1260 | HDA_REG(pThis, CORBRP) = corbRp;
|
---|
1261 | HDA_REG(pThis, RIRBWP) = rirbWp;
|
---|
1262 | rc = hdaCmdSync(pThis, false);
|
---|
1263 | LogFunc(("CORB(RP:%x, WP:%x) RIRBWP:%x\n", HDA_REG(pThis, CORBRP),
|
---|
1264 | HDA_REG(pThis, CORBWP), HDA_REG(pThis, RIRBWP)));
|
---|
1265 | if (HDA_REG_FLAG_VALUE(pThis, RIRBCTL, RIC))
|
---|
1266 | {
|
---|
1267 | HDA_REG(pThis, RIRBSTS) |= HDA_REG_FIELD_FLAG_MASK(RIRBSTS,RINTFL);
|
---|
1268 | pThis->u8Counter = 0;
|
---|
1269 | rc = hdaProcessInterrupt(pThis);
|
---|
1270 | }
|
---|
1271 | if (RT_FAILURE(rc))
|
---|
1272 | AssertRCReturn(rc, rc);
|
---|
1273 | return rc;
|
---|
1274 | }
|
---|
1275 | #endif
|
---|
1276 |
|
---|
1277 | static void hdaStreamReset(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, uint8_t u8Strm)
|
---|
1278 | {
|
---|
1279 | LogFunc(("reset of stream (%d) started\n", u8Strm));
|
---|
1280 | Assert(( pThis
|
---|
1281 | && pBdle
|
---|
1282 | && pStreamDesc
|
---|
1283 | && u8Strm <= 7));
|
---|
1284 | RT_BZERO(pBdle, sizeof(HDABDLEDESC));
|
---|
1285 | *pStreamDesc->pu32Lpib = 0;
|
---|
1286 | *pStreamDesc->pu32Sts = 0;
|
---|
1287 | /* According to the ICH6 datasheet, 0x40000 is the default value for stream descriptor register 23:20
|
---|
1288 | * bits are reserved for stream number 18.2.33, resets SDnCTL except SRCT bit */
|
---|
1289 | HDA_STREAM_REG(pThis, CTL, u8Strm) = 0x40000 | (HDA_STREAM_REG(pThis, CTL, u8Strm) & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST));
|
---|
1290 |
|
---|
1291 | /* ICH6 defines default values (0x77 for input and 0xBF for output descriptors) of FIFO size. 18.2.39 */
|
---|
1292 | HDA_STREAM_REG(pThis, FIFOS, u8Strm) = u8Strm < 4 ? HDA_SDINFIFO_120B : HDA_SDONFIFO_192B;
|
---|
1293 | HDA_STREAM_REG(pThis, FIFOW, u8Strm) = u8Strm < 4 ? HDA_SDFIFOW_8B : HDA_SDFIFOW_32B;
|
---|
1294 | HDA_STREAM_REG(pThis, CBL, u8Strm) = 0;
|
---|
1295 | HDA_STREAM_REG(pThis, LVI, u8Strm) = 0;
|
---|
1296 | HDA_STREAM_REG(pThis, FMT, u8Strm) = 0;
|
---|
1297 | HDA_STREAM_REG(pThis, BDPU, u8Strm) = 0;
|
---|
1298 | HDA_STREAM_REG(pThis, BDPL, u8Strm) = 0;
|
---|
1299 | LogFunc(("reset of stream (%d) finished\n", u8Strm));
|
---|
1300 | }
|
---|
1301 |
|
---|
1302 | /* Register access handlers. */
|
---|
1303 |
|
---|
1304 | static int hdaRegReadUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1305 | {
|
---|
1306 | *pu32Value = 0;
|
---|
1307 | return VINF_SUCCESS;
|
---|
1308 | }
|
---|
1309 |
|
---|
1310 | static int hdaRegWriteUnimpl(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1311 | {
|
---|
1312 | return VINF_SUCCESS;
|
---|
1313 | }
|
---|
1314 |
|
---|
1315 | /* U8 */
|
---|
1316 | static int hdaRegReadU8(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1317 | {
|
---|
1318 | Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffffff00) == 0);
|
---|
1319 | return hdaRegReadU32(pThis, iReg, pu32Value);
|
---|
1320 | }
|
---|
1321 |
|
---|
1322 | static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1323 | {
|
---|
1324 | Assert((u32Value & 0xffffff00) == 0);
|
---|
1325 | return hdaRegWriteU32(pThis, iReg, u32Value);
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | /* U16 */
|
---|
1329 | static int hdaRegReadU16(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1330 | {
|
---|
1331 | Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xffff0000) == 0);
|
---|
1332 | return hdaRegReadU32(pThis, iReg, pu32Value);
|
---|
1333 | }
|
---|
1334 |
|
---|
1335 | static int hdaRegWriteU16(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1336 | {
|
---|
1337 | Assert((u32Value & 0xffff0000) == 0);
|
---|
1338 | return hdaRegWriteU32(pThis, iReg, u32Value);
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 | /* U24 */
|
---|
1342 | static int hdaRegReadU24(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1343 | {
|
---|
1344 | Assert(((pThis->au32Regs[g_aHdaRegMap[iReg].mem_idx] & g_aHdaRegMap[iReg].readable) & 0xff000000) == 0);
|
---|
1345 | return hdaRegReadU32(pThis, iReg, pu32Value);
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | static int hdaRegWriteU24(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1349 | {
|
---|
1350 | Assert((u32Value & 0xff000000) == 0);
|
---|
1351 | return hdaRegWriteU32(pThis, iReg, u32Value);
|
---|
1352 | }
|
---|
1353 |
|
---|
1354 | /* U32 */
|
---|
1355 | static int hdaRegReadU32(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1356 | {
|
---|
1357 | uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx;
|
---|
1358 |
|
---|
1359 | *pu32Value = pThis->au32Regs[iRegMem] & g_aHdaRegMap[iReg].readable;
|
---|
1360 | return VINF_SUCCESS;
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 | static int hdaRegWriteU32(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1364 | {
|
---|
1365 | uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx;
|
---|
1366 |
|
---|
1367 | pThis->au32Regs[iRegMem] = (u32Value & g_aHdaRegMap[iReg].writable)
|
---|
1368 | | (pThis->au32Regs[iRegMem] & ~g_aHdaRegMap[iReg].writable);
|
---|
1369 | return VINF_SUCCESS;
|
---|
1370 | }
|
---|
1371 |
|
---|
1372 | static int hdaRegWriteGCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1373 | {
|
---|
1374 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, RST))
|
---|
1375 | {
|
---|
1376 | /* exit reset state */
|
---|
1377 | HDA_REG(pThis, GCTL) |= HDA_REG_FIELD_FLAG_MASK(GCTL, RST);
|
---|
1378 | pThis->fInReset = false;
|
---|
1379 | }
|
---|
1380 | else
|
---|
1381 | {
|
---|
1382 | #ifdef IN_RING3
|
---|
1383 | /* enter reset state*/
|
---|
1384 | if ( HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA)
|
---|
1385 | || HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA))
|
---|
1386 | {
|
---|
1387 | LogFunc(("HDA enters in reset with DMA(RIRB:%s, CORB:%s)\n",
|
---|
1388 | HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA) ? "on" : "off",
|
---|
1389 | HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA) ? "on" : "off"));
|
---|
1390 | }
|
---|
1391 | hdaReset(pThis->CTX_SUFF(pDevIns));
|
---|
1392 | HDA_REG(pThis, GCTL) &= ~HDA_REG_FIELD_FLAG_MASK(GCTL, RST);
|
---|
1393 | pThis->fInReset = true;
|
---|
1394 | #else
|
---|
1395 | return VINF_IOM_R3_MMIO_WRITE;
|
---|
1396 | #endif
|
---|
1397 | }
|
---|
1398 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, FSH))
|
---|
1399 | {
|
---|
1400 | /* Flush: GSTS:1 set, see 6.2.6*/
|
---|
1401 | HDA_REG(pThis, GSTS) |= HDA_REG_FIELD_FLAG_MASK(GSTS, FSH); /* set the flush state */
|
---|
1402 | /* DPLBASE and DPUBASE should be initialized with initial value (see 6.2.6)*/
|
---|
1403 | }
|
---|
1404 | return VINF_SUCCESS;
|
---|
1405 | }
|
---|
1406 |
|
---|
1407 | static int hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1408 | {
|
---|
1409 | uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx;
|
---|
1410 |
|
---|
1411 | uint32_t v = pThis->au32Regs[iRegMem];
|
---|
1412 | uint32_t nv = u32Value & HDA_STATES_SCSF;
|
---|
1413 | pThis->au32Regs[iRegMem] &= ~(v & nv); /* write of 1 clears corresponding bit */
|
---|
1414 | return VINF_SUCCESS;
|
---|
1415 | }
|
---|
1416 |
|
---|
1417 | static int hdaRegReadINTSTS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1418 | {
|
---|
1419 | uint32_t v = 0;
|
---|
1420 | if ( HDA_REG_FLAG_VALUE(pThis, RIRBSTS, RIRBOIS)
|
---|
1421 | || HDA_REG_FLAG_VALUE(pThis, RIRBSTS, RINTFL)
|
---|
1422 | || HDA_REG_FLAG_VALUE(pThis, CORBSTS, CMEI)
|
---|
1423 | || HDA_REG(pThis, STATESTS))
|
---|
1424 | v |= RT_BIT(30);
|
---|
1425 | #define HDA_IS_STREAM_EVENT(pThis, stream) \
|
---|
1426 | ( (SDSTS((pThis),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE)) \
|
---|
1427 | || (SDSTS((pThis),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE)) \
|
---|
1428 | || (SDSTS((pThis),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))
|
---|
1429 | #define MARK_STREAM(pThis, stream, v) do { (v) |= HDA_IS_STREAM_EVENT((pThis),stream) ? RT_BIT((stream)) : 0; } while(0)
|
---|
1430 | MARK_STREAM(pThis, 0, v);
|
---|
1431 | MARK_STREAM(pThis, 1, v);
|
---|
1432 | MARK_STREAM(pThis, 2, v);
|
---|
1433 | MARK_STREAM(pThis, 3, v);
|
---|
1434 | MARK_STREAM(pThis, 4, v);
|
---|
1435 | MARK_STREAM(pThis, 5, v);
|
---|
1436 | MARK_STREAM(pThis, 6, v);
|
---|
1437 | MARK_STREAM(pThis, 7, v);
|
---|
1438 | v |= v ? RT_BIT(31) : 0;
|
---|
1439 | *pu32Value = v;
|
---|
1440 | return VINF_SUCCESS;
|
---|
1441 | }
|
---|
1442 |
|
---|
1443 | static int hdaRegReadWALCLK(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1444 | {
|
---|
1445 | /* HDA spec (1a): 3.3.16 WALCLK counter ticks with 24Mhz bitclock rate. */
|
---|
1446 | *pu32Value = (uint32_t)ASMMultU64ByU32DivByU32(PDMDevHlpTMTimeVirtGetNano(pThis->CTX_SUFF(pDevIns))
|
---|
1447 | - pThis->u64BaseTS, 24, 1000);
|
---|
1448 | return VINF_SUCCESS;
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | static int hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1452 | {
|
---|
1453 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(CORBRP, RST))
|
---|
1454 | HDA_REG(pThis, CORBRP) = 0;
|
---|
1455 | #ifndef BIRD_THINKS_CORBRP_IS_MOSTLY_RO
|
---|
1456 | else
|
---|
1457 | return hdaRegWriteU8(pThis, iReg, u32Value);
|
---|
1458 | #endif
|
---|
1459 | return VINF_SUCCESS;
|
---|
1460 | }
|
---|
1461 |
|
---|
1462 | static int hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1463 | {
|
---|
1464 | #ifdef IN_RING3
|
---|
1465 | int rc = hdaRegWriteU8(pThis, iReg, u32Value);
|
---|
1466 | AssertRC(rc);
|
---|
1467 | if ( HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP)
|
---|
1468 | && HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA) != 0)
|
---|
1469 | return hdaCORBCmdProcess(pThis);
|
---|
1470 | return rc;
|
---|
1471 | #else
|
---|
1472 | return VINF_IOM_R3_MMIO_WRITE;
|
---|
1473 | #endif
|
---|
1474 | }
|
---|
1475 |
|
---|
1476 | static int hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1477 | {
|
---|
1478 | uint32_t v = HDA_REG(pThis, CORBSTS);
|
---|
1479 | HDA_REG(pThis, CORBSTS) &= ~(v & u32Value);
|
---|
1480 | return VINF_SUCCESS;
|
---|
1481 | }
|
---|
1482 |
|
---|
1483 | static int hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1484 | {
|
---|
1485 | #ifdef IN_RING3
|
---|
1486 | int rc;
|
---|
1487 | rc = hdaRegWriteU16(pThis, iReg, u32Value);
|
---|
1488 | if (RT_FAILURE(rc))
|
---|
1489 | AssertRCReturn(rc, rc);
|
---|
1490 | if (HDA_REG(pThis, CORBWP) == HDA_REG(pThis, CORBRP))
|
---|
1491 | return VINF_SUCCESS;
|
---|
1492 | if (!HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA))
|
---|
1493 | return VINF_SUCCESS;
|
---|
1494 | rc = hdaCORBCmdProcess(pThis);
|
---|
1495 | return rc;
|
---|
1496 | #else
|
---|
1497 | return VINF_IOM_R3_MMIO_WRITE;
|
---|
1498 | #endif
|
---|
1499 | }
|
---|
1500 |
|
---|
1501 | static int hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1502 | {
|
---|
1503 | bool fRun = RT_BOOL(u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
1504 | bool fInRun = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
1505 | bool fReset = RT_BOOL(u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST));
|
---|
1506 | bool fInReset = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST));
|
---|
1507 |
|
---|
1508 | if (fInReset)
|
---|
1509 | {
|
---|
1510 | /*
|
---|
1511 | * Assert!!! Guest is resetting HDA's stream, we're expecting guest will mark stream as exit
|
---|
1512 | * from reset
|
---|
1513 | */
|
---|
1514 | Assert((!fReset));
|
---|
1515 | LogFunc(("guest initiated exit of stream reset.\n"));
|
---|
1516 | }
|
---|
1517 | else if (fReset)
|
---|
1518 | {
|
---|
1519 | #ifdef IN_RING3
|
---|
1520 | /*
|
---|
1521 | * Assert!!! ICH6 datasheet 18.2.33 says that RUN bit should be cleared before initiation of reset.
|
---|
1522 | */
|
---|
1523 | uint8_t u8Strm = 0;
|
---|
1524 | PHDABDLEDESC pBdle = NULL;
|
---|
1525 | HDASTREAMTRANSFERDESC StreamDesc;
|
---|
1526 | Assert((!fInRun && !fRun));
|
---|
1527 | switch (iReg)
|
---|
1528 | {
|
---|
1529 | case HDA_REG_SD0CTL:
|
---|
1530 | u8Strm = 0;
|
---|
1531 | pBdle = &pThis->StInBdle;
|
---|
1532 | break;
|
---|
1533 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1534 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
1535 | case HDA_REG_SD2CTL:
|
---|
1536 | u8Strm = 2;
|
---|
1537 | pBdle = &pThis->StMicBdle;
|
---|
1538 | break;
|
---|
1539 | # endif
|
---|
1540 | #endif
|
---|
1541 | case HDA_REG_SD4CTL:
|
---|
1542 | u8Strm = 4;
|
---|
1543 | pBdle = &pThis->StOutBdle;
|
---|
1544 | break;
|
---|
1545 | default:
|
---|
1546 | LogFunc(("changing SRST bit on non-attached stream\n"));
|
---|
1547 | return hdaRegWriteU24(pThis, iReg, u32Value);
|
---|
1548 | }
|
---|
1549 | LogFunc(("guest initiated enter to stream reset.\n"));
|
---|
1550 | hdaInitTransferDescriptor(pThis, pBdle, u8Strm, &StreamDesc);
|
---|
1551 | hdaStreamReset(pThis, pBdle, &StreamDesc, u8Strm);
|
---|
1552 | #else
|
---|
1553 | return VINF_IOM_R3_MMIO_WRITE;
|
---|
1554 | #endif
|
---|
1555 | }
|
---|
1556 | else
|
---|
1557 | {
|
---|
1558 | #ifdef IN_RING3
|
---|
1559 | /* we enter here to change DMA states only */
|
---|
1560 | if ( (fInRun && !fRun)
|
---|
1561 | || (fRun && !fInRun))
|
---|
1562 | {
|
---|
1563 | Assert((!fReset && !fInReset));
|
---|
1564 |
|
---|
1565 | # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1566 | PHDADRIVER pDrv;
|
---|
1567 | # endif
|
---|
1568 | switch (iReg)
|
---|
1569 | {
|
---|
1570 | case HDA_REG_SD0CTL:
|
---|
1571 | # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1572 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
1573 | pDrv->pConnector->pfnEnableIn(pDrv->pConnector,
|
---|
1574 | pDrv->LineIn.pStrmIn, fRun);
|
---|
1575 | # else
|
---|
1576 | AUD_set_active_in(pThis->pCodec->SwVoiceIn, fRun);
|
---|
1577 | # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1578 | break;
|
---|
1579 | # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1580 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
1581 | case HDA_REG_SD2CTL:
|
---|
1582 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
1583 | pDrv->pConnector->pfnEnableIn(pDrv->pConnector,
|
---|
1584 | pDrv->MicIn.pStrmIn, fRun);
|
---|
1585 | # endif
|
---|
1586 | # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1587 | break;
|
---|
1588 | case HDA_REG_SD4CTL:
|
---|
1589 | # ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1590 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
1591 | pDrv->pConnector->pfnEnableOut(pDrv->pConnector,
|
---|
1592 | pDrv->Out.pStrmOut, fRun);
|
---|
1593 | # else
|
---|
1594 | AUD_set_active_out(pThis->pCodec->SwVoiceOut, fRun);
|
---|
1595 | # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1596 | break;
|
---|
1597 | default:
|
---|
1598 | AssertMsgFailed(("Changing RUN bit on non-attached stream, register %RU32\n", iReg));
|
---|
1599 | break;
|
---|
1600 | }
|
---|
1601 | }
|
---|
1602 | #else /* !IN_RING3 */
|
---|
1603 | return VINF_IOM_R3_MMIO_WRITE;
|
---|
1604 | #endif /* IN_RING3 */
|
---|
1605 | }
|
---|
1606 |
|
---|
1607 | return hdaRegWriteU24(pThis, iReg, u32Value);
|
---|
1608 | }
|
---|
1609 |
|
---|
1610 | static int hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1611 | {
|
---|
1612 | uint32_t v = HDA_REG_IND(pThis, iReg);
|
---|
1613 | v &= ~(u32Value & v);
|
---|
1614 | HDA_REG_IND(pThis, iReg) = v;
|
---|
1615 | hdaProcessInterrupt(pThis);
|
---|
1616 | return VINF_SUCCESS;
|
---|
1617 | }
|
---|
1618 |
|
---|
1619 | static int hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1620 | {
|
---|
1621 | int rc = hdaRegWriteU32(pThis, iReg, u32Value);
|
---|
1622 | if (RT_FAILURE(rc))
|
---|
1623 | AssertRCReturn(rc, VINF_SUCCESS);
|
---|
1624 | return rc;
|
---|
1625 | }
|
---|
1626 |
|
---|
1627 | static int hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1628 | {
|
---|
1629 | switch (u32Value)
|
---|
1630 | {
|
---|
1631 | case HDA_SDFIFOW_8B:
|
---|
1632 | case HDA_SDFIFOW_16B:
|
---|
1633 | case HDA_SDFIFOW_32B:
|
---|
1634 | return hdaRegWriteU16(pThis, iReg, u32Value);
|
---|
1635 | default:
|
---|
1636 | LogFunc(("Attempt to store unsupported value(%x) in SDFIFOW\n", u32Value));
|
---|
1637 | return hdaRegWriteU16(pThis, iReg, HDA_SDFIFOW_32B);
|
---|
1638 | }
|
---|
1639 | return VINF_SUCCESS;
|
---|
1640 | }
|
---|
1641 |
|
---|
1642 | /**
|
---|
1643 | * @note This method could be called for changing value on Output Streams
|
---|
1644 | * only (ICH6 datasheet 18.2.39)
|
---|
1645 | */
|
---|
1646 | static int hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1647 | {
|
---|
1648 | switch (iReg)
|
---|
1649 | {
|
---|
1650 | /* SDInFIFOS is RO, n=0-3 */
|
---|
1651 | case HDA_REG_SD0FIFOS:
|
---|
1652 | case HDA_REG_SD1FIFOS:
|
---|
1653 | case HDA_REG_SD2FIFOS:
|
---|
1654 | case HDA_REG_SD3FIFOS:
|
---|
1655 | LogFunc(("Guest tries change value of FIFO size of input stream\n"));
|
---|
1656 | break;
|
---|
1657 | case HDA_REG_SD4FIFOS:
|
---|
1658 | case HDA_REG_SD5FIFOS:
|
---|
1659 | case HDA_REG_SD6FIFOS:
|
---|
1660 | case HDA_REG_SD7FIFOS:
|
---|
1661 | switch(u32Value)
|
---|
1662 | {
|
---|
1663 | case HDA_SDONFIFO_16B:
|
---|
1664 | case HDA_SDONFIFO_32B:
|
---|
1665 | case HDA_SDONFIFO_64B:
|
---|
1666 | case HDA_SDONFIFO_128B:
|
---|
1667 | case HDA_SDONFIFO_192B:
|
---|
1668 | return hdaRegWriteU16(pThis, iReg, u32Value);
|
---|
1669 |
|
---|
1670 | case HDA_SDONFIFO_256B:
|
---|
1671 | LogFunc(("256-bit is unsupported, HDA is switched into 192-bit mode\n"));
|
---|
1672 | default:
|
---|
1673 | return hdaRegWriteU16(pThis, iReg, HDA_SDONFIFO_192B);
|
---|
1674 | }
|
---|
1675 | break;
|
---|
1676 | default:
|
---|
1677 | AssertMsgFailed(("Something weird happened with register lookup routine\n"));
|
---|
1678 | }
|
---|
1679 |
|
---|
1680 | return VINF_SUCCESS;
|
---|
1681 | }
|
---|
1682 |
|
---|
1683 | #ifdef IN_RING3
|
---|
1684 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1685 | static int hdaSdFmtToAudSettings(uint32_t u32SdFmt, PPDMAUDIOSTREAMCFG pCfg)
|
---|
1686 | #else
|
---|
1687 | static int hdaSdFmtToAudSettings(uint32_t u32SdFmt, audsettings_t *pCfg)
|
---|
1688 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1689 | {
|
---|
1690 | AssertPtrReturn(pCfg, VERR_INVALID_POINTER);
|
---|
1691 |
|
---|
1692 | # define EXTRACT_VALUE(v, mask, shift) ((v & ((mask) << (shift))) >> (shift))
|
---|
1693 |
|
---|
1694 | int rc = VINF_SUCCESS;
|
---|
1695 |
|
---|
1696 | uint32_t u32Hz = (u32SdFmt & HDA_SDFMT_BASE_RATE_SHIFT) ? 44100 : 48000;
|
---|
1697 | uint32_t u32HzMult = 1;
|
---|
1698 | uint32_t u32HzDiv = 1;
|
---|
1699 |
|
---|
1700 | switch (EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_MULT_MASK, HDA_SDFMT_MULT_SHIFT))
|
---|
1701 | {
|
---|
1702 | case 0: u32HzMult = 1; break;
|
---|
1703 | case 1: u32HzMult = 2; break;
|
---|
1704 | case 2: u32HzMult = 3; break;
|
---|
1705 | case 3: u32HzMult = 4; break;
|
---|
1706 | default:
|
---|
1707 | LogFunc(("Unsupported multiplier %x\n",
|
---|
1708 | EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_MULT_MASK, HDA_SDFMT_MULT_SHIFT)));
|
---|
1709 | rc = VERR_NOT_SUPPORTED;
|
---|
1710 | break;
|
---|
1711 | }
|
---|
1712 | switch (EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_DIV_MASK, HDA_SDFMT_DIV_SHIFT))
|
---|
1713 | {
|
---|
1714 | case 0: u32HzDiv = 1; break;
|
---|
1715 | case 1: u32HzDiv = 2; break;
|
---|
1716 | case 2: u32HzDiv = 3; break;
|
---|
1717 | case 3: u32HzDiv = 4; break;
|
---|
1718 | case 4: u32HzDiv = 5; break;
|
---|
1719 | case 5: u32HzDiv = 6; break;
|
---|
1720 | case 6: u32HzDiv = 7; break;
|
---|
1721 | case 7: u32HzDiv = 8; break;
|
---|
1722 | default:
|
---|
1723 | LogFunc(("Unsupported divisor %x\n",
|
---|
1724 | EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_DIV_MASK, HDA_SDFMT_DIV_SHIFT)));
|
---|
1725 | rc = VERR_NOT_SUPPORTED;
|
---|
1726 | break;
|
---|
1727 | }
|
---|
1728 |
|
---|
1729 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1730 | PDMAUDIOFMT enmFmt = AUD_FMT_S16; /* Default to 16-bit signed. */
|
---|
1731 | #else
|
---|
1732 | audfmt_e enmFmt = AUD_FMT_S16; /* Default to 16-bit signed. */
|
---|
1733 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1734 |
|
---|
1735 | switch (EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT))
|
---|
1736 | {
|
---|
1737 | case 0:
|
---|
1738 | LogFunc(("%s requested 8-bit\n", __FUNCTION__));
|
---|
1739 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1740 | enmFmt = AUD_FMT_S8;
|
---|
1741 | #else
|
---|
1742 | enmFmt = AUD_FMT_S8;
|
---|
1743 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1744 | break;
|
---|
1745 | case 1:
|
---|
1746 | LogFunc(("%s requested 16-bit\n", __FUNCTION__));
|
---|
1747 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1748 | enmFmt = AUD_FMT_S16;
|
---|
1749 | #else
|
---|
1750 | enmFmt = AUD_FMT_S16;
|
---|
1751 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1752 | break;
|
---|
1753 | case 2:
|
---|
1754 | LogFunc(("%s requested 20-bit\n", __FUNCTION__));
|
---|
1755 | break;
|
---|
1756 | case 3:
|
---|
1757 | LogFunc(("%s requested 24-bit\n", __FUNCTION__));
|
---|
1758 | break;
|
---|
1759 | case 4:
|
---|
1760 | LogFunc(("%s requested 32-bit\n", __FUNCTION__));
|
---|
1761 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1762 | enmFmt = AUD_FMT_S32;
|
---|
1763 | #else
|
---|
1764 | enmFmt = AUD_FMT_S32;
|
---|
1765 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1766 | break;
|
---|
1767 | default:
|
---|
1768 | AssertMsgFailed(("Unsupported bits shift %x\n",
|
---|
1769 | EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT)));
|
---|
1770 | rc = VERR_NOT_SUPPORTED;
|
---|
1771 | break;
|
---|
1772 | }
|
---|
1773 |
|
---|
1774 | if (RT_SUCCESS(rc))
|
---|
1775 | {
|
---|
1776 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1777 | pCfg->uHz = u32Hz * u32HzMult / u32HzDiv;
|
---|
1778 | pCfg->cChannels = (u32SdFmt & 0xf) + 1;
|
---|
1779 | pCfg->enmFormat = enmFmt;
|
---|
1780 | pCfg->enmEndianness = PDMAUDIOHOSTENDIANNESS;
|
---|
1781 | #else
|
---|
1782 | pCfg->nchannels = (u32SdFmt & 0xf) + 1;
|
---|
1783 | pCfg->fmt = enmFmt;
|
---|
1784 | pCfg->endianness = 0;
|
---|
1785 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
1786 | }
|
---|
1787 |
|
---|
1788 | # undef EXTRACT_VALUE
|
---|
1789 |
|
---|
1790 | return rc;
|
---|
1791 | }
|
---|
1792 | #endif
|
---|
1793 |
|
---|
1794 | static int hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1795 | {
|
---|
1796 | #ifdef IN_RING3
|
---|
1797 | # ifdef VBOX_WITH_HDA_CODEC_EMU
|
---|
1798 | /* No reason to reopen voice with same settings. */
|
---|
1799 | if (u32Value == HDA_REG_IND(pThis, iReg))
|
---|
1800 | return VINF_SUCCESS;
|
---|
1801 |
|
---|
1802 | PDMAUDIOSTREAMCFG as;
|
---|
1803 | int rc = hdaSdFmtToAudSettings(u32Value, &as);
|
---|
1804 | if (RT_FAILURE(rc))
|
---|
1805 | return rc;
|
---|
1806 |
|
---|
1807 | PHDADRIVER pDrv;
|
---|
1808 | switch (iReg)
|
---|
1809 | {
|
---|
1810 | case HDA_REG_SD0FMT:
|
---|
1811 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
1812 | rc = hdaCodecOpenStream(pThis->pCodec, PI_INDEX, &as);
|
---|
1813 | break;
|
---|
1814 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
1815 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
1816 | case HDA_REG_SD2FMT:
|
---|
1817 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
1818 | rc = hdaCodecOpenStream(pThis->pCodec, MC_INDEX, &as);
|
---|
1819 | break;
|
---|
1820 | # endif
|
---|
1821 | #endif
|
---|
1822 | default:
|
---|
1823 | LogFunc(("Warning: Attempt to change format on register %d\n", iReg));
|
---|
1824 | break;
|
---|
1825 | }
|
---|
1826 |
|
---|
1827 | /** @todo r=andy rc gets lost; needs fixing. */
|
---|
1828 | return hdaRegWriteU16(pThis, iReg, u32Value);
|
---|
1829 | # else
|
---|
1830 | return hdaRegWriteU16(pThis, iReg, u32Value);
|
---|
1831 | # endif
|
---|
1832 | #else
|
---|
1833 | return VINF_IOM_R3_MMIO_WRITE;
|
---|
1834 | #endif
|
---|
1835 | }
|
---|
1836 |
|
---|
1837 | static int hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1838 | {
|
---|
1839 | int rc = hdaRegWriteU32(pThis, iReg, u32Value);
|
---|
1840 | if (RT_FAILURE(rc))
|
---|
1841 | AssertRCReturn(rc, VINF_SUCCESS);
|
---|
1842 | return rc;
|
---|
1843 | }
|
---|
1844 |
|
---|
1845 | static int hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1846 | {
|
---|
1847 | int rc = hdaRegWriteU32(pThis, iReg, u32Value);
|
---|
1848 | if (RT_FAILURE(rc))
|
---|
1849 | AssertRCReturn(rc, VINF_SUCCESS);
|
---|
1850 | return rc;
|
---|
1851 | }
|
---|
1852 |
|
---|
1853 | static int hdaRegReadIRS(PHDASTATE pThis, uint32_t iReg, uint32_t *pu32Value)
|
---|
1854 | {
|
---|
1855 | int rc = VINF_SUCCESS;
|
---|
1856 | /* regarding 3.4.3 we should mark IRS as busy in case CORB is active */
|
---|
1857 | if ( HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP)
|
---|
1858 | || HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA))
|
---|
1859 | HDA_REG(pThis, IRS) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */
|
---|
1860 |
|
---|
1861 | rc = hdaRegReadU32(pThis, iReg, pu32Value);
|
---|
1862 | return rc;
|
---|
1863 | }
|
---|
1864 |
|
---|
1865 | static int hdaRegWriteIRS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1866 | {
|
---|
1867 | int rc = VINF_SUCCESS;
|
---|
1868 |
|
---|
1869 | /*
|
---|
1870 | * If the guest set the ICB bit of IRS register, HDA should process the verb in IC register,
|
---|
1871 | * write the response to IR register, and set the IRV (valid in case of success) bit of IRS register.
|
---|
1872 | */
|
---|
1873 | if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, ICB)
|
---|
1874 | && !HDA_REG_FLAG_VALUE(pThis, IRS, ICB))
|
---|
1875 | {
|
---|
1876 | #ifdef IN_RING3
|
---|
1877 | PFNHDACODECVERBPROCESSOR pfn = NULL;
|
---|
1878 | uint64_t resp;
|
---|
1879 | uint32_t cmd = HDA_REG(pThis, IC);
|
---|
1880 | if (HDA_REG(pThis, CORBWP) != HDA_REG(pThis, CORBRP))
|
---|
1881 | {
|
---|
1882 | /*
|
---|
1883 | * 3.4.3 defines behavior of immediate Command status register.
|
---|
1884 | */
|
---|
1885 | LogRel(("guest attempted process immediate verb (%x) with active CORB\n", cmd));
|
---|
1886 | return rc;
|
---|
1887 | }
|
---|
1888 | HDA_REG(pThis, IRS) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */
|
---|
1889 | LogFunc(("IC:%x\n", cmd));
|
---|
1890 |
|
---|
1891 | rc = pThis->pCodec->pfnLookup(pThis->pCodec,
|
---|
1892 | HDA_CODEC_CMD(cmd, 0 /* LUN */),
|
---|
1893 | &pfn);
|
---|
1894 | if (RT_FAILURE(rc))
|
---|
1895 | AssertRCReturn(rc, rc);
|
---|
1896 | rc = pfn(pThis->pCodec,
|
---|
1897 | HDA_CODEC_CMD(cmd, 0 /* LUN */), &resp);
|
---|
1898 | if (RT_FAILURE(rc))
|
---|
1899 | AssertRCReturn(rc, rc);
|
---|
1900 |
|
---|
1901 | HDA_REG(pThis, IR) = (uint32_t)resp;
|
---|
1902 | LogFunc(("IR:%x\n", HDA_REG(pThis, IR)));
|
---|
1903 | HDA_REG(pThis, IRS) = HDA_REG_FIELD_FLAG_MASK(IRS, IRV); /* result is ready */
|
---|
1904 | HDA_REG(pThis, IRS) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy is clear */
|
---|
1905 | #else /* !IN_RING3 */
|
---|
1906 | rc = VINF_IOM_R3_MMIO_WRITE;
|
---|
1907 | #endif
|
---|
1908 | return rc;
|
---|
1909 | }
|
---|
1910 | /*
|
---|
1911 | * Once the guest read the response, it should clean the IRV bit of the IRS register.
|
---|
1912 | */
|
---|
1913 | if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, IRV)
|
---|
1914 | && HDA_REG_FLAG_VALUE(pThis, IRS, IRV))
|
---|
1915 | HDA_REG(pThis, IRS) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, IRV);
|
---|
1916 | return rc;
|
---|
1917 | }
|
---|
1918 |
|
---|
1919 | static int hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1920 | {
|
---|
1921 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(RIRBWP, RST))
|
---|
1922 | {
|
---|
1923 | HDA_REG(pThis, RIRBWP) = 0;
|
---|
1924 | }
|
---|
1925 | /* The remaining bits are O, see 6.2.22 */
|
---|
1926 | return VINF_SUCCESS;
|
---|
1927 | }
|
---|
1928 |
|
---|
1929 | static int hdaRegWriteBase(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1930 | {
|
---|
1931 | uint32_t iRegMem = g_aHdaRegMap[iReg].mem_idx;
|
---|
1932 | int rc = hdaRegWriteU32(pThis, iReg, u32Value);
|
---|
1933 | if (RT_FAILURE(rc))
|
---|
1934 | AssertRCReturn(rc, rc);
|
---|
1935 |
|
---|
1936 | switch(iReg)
|
---|
1937 | {
|
---|
1938 | case HDA_REG_CORBLBASE:
|
---|
1939 | pThis->u64CORBBase &= UINT64_C(0xFFFFFFFF00000000);
|
---|
1940 | pThis->u64CORBBase |= pThis->au32Regs[iRegMem];
|
---|
1941 | break;
|
---|
1942 | case HDA_REG_CORBUBASE:
|
---|
1943 | pThis->u64CORBBase &= UINT64_C(0x00000000FFFFFFFF);
|
---|
1944 | pThis->u64CORBBase |= ((uint64_t)pThis->au32Regs[iRegMem] << 32);
|
---|
1945 | break;
|
---|
1946 | case HDA_REG_RIRBLBASE:
|
---|
1947 | pThis->u64RIRBBase &= UINT64_C(0xFFFFFFFF00000000);
|
---|
1948 | pThis->u64RIRBBase |= pThis->au32Regs[iRegMem];
|
---|
1949 | break;
|
---|
1950 | case HDA_REG_RIRBUBASE:
|
---|
1951 | pThis->u64RIRBBase &= UINT64_C(0x00000000FFFFFFFF);
|
---|
1952 | pThis->u64RIRBBase |= ((uint64_t)pThis->au32Regs[iRegMem] << 32);
|
---|
1953 | break;
|
---|
1954 | case HDA_REG_DPLBASE:
|
---|
1955 | /** @todo: first bit has special meaning */
|
---|
1956 | pThis->u64DPBase &= UINT64_C(0xFFFFFFFF00000000);
|
---|
1957 | pThis->u64DPBase |= pThis->au32Regs[iRegMem];
|
---|
1958 | break;
|
---|
1959 | case HDA_REG_DPUBASE:
|
---|
1960 | pThis->u64DPBase &= UINT64_C(0x00000000FFFFFFFF);
|
---|
1961 | pThis->u64DPBase |= ((uint64_t)pThis->au32Regs[iRegMem] << 32);
|
---|
1962 | break;
|
---|
1963 | default:
|
---|
1964 | AssertMsgFailed(("Invalid index"));
|
---|
1965 | break;
|
---|
1966 | }
|
---|
1967 |
|
---|
1968 | LogFunc(("CORB base:%llx RIRB base: %llx DP base: %llx\n",
|
---|
1969 | pThis->u64CORBBase, pThis->u64RIRBBase, pThis->u64DPBase));
|
---|
1970 | return rc;
|
---|
1971 | }
|
---|
1972 |
|
---|
1973 | static int hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t iReg, uint32_t u32Value)
|
---|
1974 | {
|
---|
1975 | uint8_t v = HDA_REG(pThis, RIRBSTS);
|
---|
1976 | HDA_REG(pThis, RIRBSTS) &= ~(v & u32Value);
|
---|
1977 |
|
---|
1978 | return hdaProcessInterrupt(pThis);
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | #ifdef IN_RING3
|
---|
1982 | #ifdef LOG_ENABLED
|
---|
1983 | static void dump_bd(PHDASTATE pThis, PHDABDLEDESC pBdle, uint64_t u64BaseDMA)
|
---|
1984 | {
|
---|
1985 | #if 0
|
---|
1986 | uint64_t addr;
|
---|
1987 | uint32_t len;
|
---|
1988 | uint32_t ioc;
|
---|
1989 | uint8_t bdle[16];
|
---|
1990 | uint32_t counter;
|
---|
1991 | uint32_t i;
|
---|
1992 | uint32_t sum = 0;
|
---|
1993 | Assert(pBdle && pBdle->u32BdleMaxCvi);
|
---|
1994 | for (i = 0; i <= pBdle->u32BdleMaxCvi; ++i)
|
---|
1995 | {
|
---|
1996 | PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), u64BaseDMA + i*16, bdle, 16);
|
---|
1997 | addr = *(uint64_t *)bdle;
|
---|
1998 | len = *(uint32_t *)&bdle[8];
|
---|
1999 | ioc = *(uint32_t *)&bdle[12];
|
---|
2000 | LogFunc(("%s bdle[%d] a:%llx, len:%d, ioc:%d\n", (i == pBdle->u32BdleCvi? "[C]": " "), i, addr, len, ioc & 0x1));
|
---|
2001 | sum += len;
|
---|
2002 | }
|
---|
2003 | LogFunc(("sum: %d\n", sum));
|
---|
2004 | for (i = 0; i < 8; ++i)
|
---|
2005 | {
|
---|
2006 | PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), (pThis->u64DPBase & DPBASE_ADDR_MASK) + i*8, &counter, sizeof(&counter));
|
---|
2007 | LogFunc(("%s stream[%d] counter=%x\n", i == SDCTL_NUM(pThis, 4) || i == SDCTL_NUM(pThis, 0)? "[C]": " ",
|
---|
2008 | i , counter));
|
---|
2009 | }
|
---|
2010 | #endif
|
---|
2011 | }
|
---|
2012 | #endif
|
---|
2013 |
|
---|
2014 | static void hdaFetchBdle(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc)
|
---|
2015 | {
|
---|
2016 | uint8_t bdle[16];
|
---|
2017 | Assert(( pStreamDesc->u64BaseDMA
|
---|
2018 | && pBdle
|
---|
2019 | && pBdle->u32BdleMaxCvi));
|
---|
2020 | PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), pStreamDesc->u64BaseDMA + pBdle->u32BdleCvi*16, bdle, 16);
|
---|
2021 | pBdle->u64BdleCviAddr = *(uint64_t *)bdle;
|
---|
2022 | pBdle->u32BdleCviLen = *(uint32_t *)&bdle[8];
|
---|
2023 | pBdle->fBdleCviIoc = (*(uint32_t *)&bdle[12]) & 0x1;
|
---|
2024 | #ifdef LOG_ENABLED
|
---|
2025 | dump_bd(pThis, pBdle, pStreamDesc->u64BaseDMA);
|
---|
2026 | #endif
|
---|
2027 | }
|
---|
2028 |
|
---|
2029 | DECLINLINE(uint32_t) hdaCalculateTransferBufferLength(PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc,
|
---|
2030 | uint32_t u32SoundBackendBufferBytesAvail, uint32_t u32CblLimit)
|
---|
2031 | {
|
---|
2032 | /*
|
---|
2033 | * Number of bytes depends on the current position in buffer (u32BdleCviLen-u32BdleCviPos)
|
---|
2034 | */
|
---|
2035 | Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos)); /* sanity */
|
---|
2036 | uint32_t cb2Copy = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos;
|
---|
2037 | /*
|
---|
2038 | * we may increase the counter in range of [0, FIFOS + 1]
|
---|
2039 | */
|
---|
2040 | cb2Copy = RT_MIN(cb2Copy, pStreamDesc->u32Fifos + 1);
|
---|
2041 | Assert((u32SoundBackendBufferBytesAvail > 0));
|
---|
2042 |
|
---|
2043 | /* sanity check to avoid overriding the backend audio buffer */
|
---|
2044 | cb2Copy = RT_MIN(cb2Copy, u32SoundBackendBufferBytesAvail);
|
---|
2045 | cb2Copy = RT_MIN(cb2Copy, u32CblLimit);
|
---|
2046 |
|
---|
2047 | if (cb2Copy <= pBdle->cbUnderFifoW)
|
---|
2048 | return 0;
|
---|
2049 | cb2Copy -= pBdle->cbUnderFifoW; /* forcibly reserve the amount of unreported bytes to copy */
|
---|
2050 | return cb2Copy;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | DECLINLINE(void) hdaBackendWriteTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied,
|
---|
2054 | uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity)
|
---|
2055 | {
|
---|
2056 | LogFunc(("cbArranged2Copy: %d, cbCopied: %d, pu32DMACursor: %d, pu32BackendBufferCapacity:%d\n",
|
---|
2057 | cbArranged2Copy, cbCopied, pu32DMACursor ? *pu32DMACursor : 0, pu32BackendBufferCapacity ? *pu32BackendBufferCapacity : 0));
|
---|
2058 | Assert((cbCopied));
|
---|
2059 | AssertPtr(pu32DMACursor);
|
---|
2060 | Assert((pu32BackendBufferCapacity && *pu32BackendBufferCapacity));
|
---|
2061 | /* Assertion!!! Fewer than cbUnderFifoW bytes were copied.
|
---|
2062 | * Probably we need to move the buffer, but it is rather hard to imagine a situation
|
---|
2063 | * where it might happen.
|
---|
2064 | */
|
---|
2065 | AssertMsg((cbCopied == pBdle->cbUnderFifoW + cbArranged2Copy), /* we assume that we write the entire buffer including unreported bytes */
|
---|
2066 | ("cbCopied=%RU32 != pBdle->cbUnderFifoW=%RU32 + cbArranged2Copy=%RU32\n",
|
---|
2067 | cbCopied, pBdle->cbUnderFifoW, cbArranged2Copy));
|
---|
2068 | if ( pBdle->cbUnderFifoW
|
---|
2069 | && pBdle->cbUnderFifoW <= cbCopied)
|
---|
2070 | {
|
---|
2071 | LogFunc(("CVI resetting cbUnderFifoW:%d(pos:%d, len:%d)\n",
|
---|
2072 | pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 | pBdle->cbUnderFifoW -= RT_MIN(pBdle->cbUnderFifoW, cbCopied);
|
---|
2076 | Assert((!pBdle->cbUnderFifoW)); /* Assert!!! Incorrect assumption */
|
---|
2077 |
|
---|
2078 | /* We always increment the position of DMA buffer counter because we're always reading into an intermediate buffer */
|
---|
2079 | pBdle->u32BdleCviPos += cbArranged2Copy;
|
---|
2080 |
|
---|
2081 | Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos && *pu32BackendBufferCapacity >= cbCopied)); /* sanity */
|
---|
2082 | /* We report all bytes (including previously unreported bytes) */
|
---|
2083 | *pu32DMACursor += cbCopied;
|
---|
2084 | /* Decrease the backend counter by the number of bytes we copied to the backend */
|
---|
2085 | *pu32BackendBufferCapacity -= cbCopied;
|
---|
2086 | LogFunc(("CVI(pos:%d, len:%d), pu32DMACursor: %d, pu32BackendBufferCapacity:%d\n",
|
---|
2087 | pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, *pu32DMACursor, *pu32BackendBufferCapacity));
|
---|
2088 | }
|
---|
2089 |
|
---|
2090 | DECLINLINE(void) hdaBackendReadTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied,
|
---|
2091 | uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity)
|
---|
2092 | {
|
---|
2093 | Assert((cbCopied, cbArranged2Copy));
|
---|
2094 | *pu32BackendBufferCapacity -= cbCopied;
|
---|
2095 | pBdle->u32BdleCviPos += cbCopied;
|
---|
2096 | LogFunc(("CVI resetting cbUnderFifoW:%d(pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
2097 | *pu32DMACursor += cbCopied + pBdle->cbUnderFifoW;
|
---|
2098 | pBdle->cbUnderFifoW = 0;
|
---|
2099 | LogFunc(("CVI(pos:%d, len:%d), pu32DMACursor: %d, pu32BackendBufferCapacity:%d\n",
|
---|
2100 | pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, pu32DMACursor ? *pu32DMACursor : 0, pu32BackendBufferCapacity ? *pu32BackendBufferCapacity : 0));
|
---|
2101 | }
|
---|
2102 |
|
---|
2103 | DECLINLINE(void) hdaBackendTransferUnreported(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc,
|
---|
2104 | uint32_t cbCopied, uint32_t *pu32BackendBufferCapacity)
|
---|
2105 | {
|
---|
2106 | LogFunc(("CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
2107 | pBdle->u32BdleCviPos += cbCopied;
|
---|
2108 | pBdle->cbUnderFifoW += cbCopied;
|
---|
2109 | /* In case of a read transaction we're always copying from the backend buffer */
|
---|
2110 | if (pu32BackendBufferCapacity)
|
---|
2111 | *pu32BackendBufferCapacity -= cbCopied;
|
---|
2112 | LogFunc(("CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
2113 | Assert((pBdle->cbUnderFifoW <= hdaFifoWToSz(pThis, pStreamDesc)));
|
---|
2114 | }
|
---|
2115 |
|
---|
2116 | DECLINLINE(bool) hdaIsTransferCountersOverlapped(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc)
|
---|
2117 | {
|
---|
2118 | bool fOnBufferEdge = ( *pStreamDesc->pu32Lpib == pStreamDesc->u32Cbl
|
---|
2119 | || pBdle->u32BdleCviPos == pBdle->u32BdleCviLen);
|
---|
2120 |
|
---|
2121 | Assert((*pStreamDesc->pu32Lpib <= pStreamDesc->u32Cbl));
|
---|
2122 |
|
---|
2123 | if (*pStreamDesc->pu32Lpib == pStreamDesc->u32Cbl)
|
---|
2124 | *pStreamDesc->pu32Lpib -= pStreamDesc->u32Cbl;
|
---|
2125 | hdaUpdatePosBuf(pThis, pStreamDesc);
|
---|
2126 |
|
---|
2127 | /* don't touch BdleCvi counter on uninitialized descriptor */
|
---|
2128 | if ( pBdle->u32BdleCviPos
|
---|
2129 | && pBdle->u32BdleCviPos == pBdle->u32BdleCviLen)
|
---|
2130 | {
|
---|
2131 | pBdle->u32BdleCviPos = 0;
|
---|
2132 | pBdle->u32BdleCvi++;
|
---|
2133 | if (pBdle->u32BdleCvi == pBdle->u32BdleMaxCvi + 1)
|
---|
2134 | pBdle->u32BdleCvi = 0;
|
---|
2135 | }
|
---|
2136 | return fOnBufferEdge;
|
---|
2137 | }
|
---|
2138 |
|
---|
2139 | DECLINLINE(void) hdaStreamCounterUpdate(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc,
|
---|
2140 | uint32_t cbInc)
|
---|
2141 | {
|
---|
2142 | /*
|
---|
2143 | * if we're below the FIFO Watermark, it's expected that HDA doesn't fetch anything.
|
---|
2144 | * (ICH6 datasheet 18.2.38)
|
---|
2145 | */
|
---|
2146 | if (!pBdle->cbUnderFifoW)
|
---|
2147 | {
|
---|
2148 | *pStreamDesc->pu32Lpib += cbInc;
|
---|
2149 |
|
---|
2150 | /*
|
---|
2151 | * Assert. The buffer counters should never overlap.
|
---|
2152 | */
|
---|
2153 | Assert((*pStreamDesc->pu32Lpib <= pStreamDesc->u32Cbl));
|
---|
2154 |
|
---|
2155 | hdaUpdatePosBuf(pThis, pStreamDesc);
|
---|
2156 | }
|
---|
2157 | }
|
---|
2158 |
|
---|
2159 | static bool hdaDoNextTransferCycle(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc)
|
---|
2160 | {
|
---|
2161 | bool fDoNextTransferLoop = true;
|
---|
2162 | if ( pBdle->u32BdleCviPos == pBdle->u32BdleCviLen
|
---|
2163 | || *pStreamDesc->pu32Lpib == pStreamDesc->u32Cbl)
|
---|
2164 | {
|
---|
2165 | if ( !pBdle->cbUnderFifoW
|
---|
2166 | && pBdle->fBdleCviIoc)
|
---|
2167 | {
|
---|
2168 | /**
|
---|
2169 | * @todo - more carefully investigate BCIS flag.
|
---|
2170 | * Speech synthesis works fine on Mac Guest if this bit isn't set
|
---|
2171 | * but in general sound quality gets worse.
|
---|
2172 | */
|
---|
2173 | *pStreamDesc->pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS);
|
---|
2174 |
|
---|
2175 | /*
|
---|
2176 | * we should generate the interrupt if ICE bit of SDCTL register is set.
|
---|
2177 | */
|
---|
2178 | if (pStreamDesc->u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, ICE))
|
---|
2179 | hdaProcessInterrupt(pThis);
|
---|
2180 | }
|
---|
2181 | fDoNextTransferLoop = false;
|
---|
2182 | }
|
---|
2183 | return fDoNextTransferLoop;
|
---|
2184 | }
|
---|
2185 |
|
---|
2186 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2187 | /**
|
---|
2188 | * hdaReadAudio - copies samples from audio backend to DMA.
|
---|
2189 | * Note: This function writes to the DMA buffer immediately,
|
---|
2190 | * but "reports bytes" when all conditions are met (FIFOW).
|
---|
2191 | */
|
---|
2192 | static int hdaReadAudio(PHDASTATE pThis, PAUDMIXSINK pSink,
|
---|
2193 | PHDASTREAMTRANSFERDESC pStreamDesc,
|
---|
2194 | uint32_t u32CblLimit, uint32_t *pcbAvail, uint32_t *pcbRead)
|
---|
2195 | {
|
---|
2196 | PHDABDLEDESC pBdle = &pThis->StInBdle; /** @todo Add support for mic in. */
|
---|
2197 |
|
---|
2198 | int rc;
|
---|
2199 | uint32_t cbTransferred = 0;
|
---|
2200 |
|
---|
2201 | LogFlowFunc(("CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
2202 |
|
---|
2203 | uint32_t cb2Copy = hdaCalculateTransferBufferLength(pBdle, pStreamDesc, *pcbAvail, u32CblLimit);
|
---|
2204 | if (!cb2Copy)
|
---|
2205 | {
|
---|
2206 | /* If we enter here we can't report "unreported bits". */
|
---|
2207 | rc = VERR_NO_DATA;
|
---|
2208 | }
|
---|
2209 | else
|
---|
2210 | {
|
---|
2211 | uint32_t cbRead = 0;
|
---|
2212 | rc = audioMixerProcessSinkIn(pSink, AUDMIXOP_BLEND, pBdle->au8HdaBuffer, cb2Copy, &cbRead);
|
---|
2213 | if (RT_SUCCESS(rc))
|
---|
2214 | {
|
---|
2215 | Assert(cbRead);
|
---|
2216 |
|
---|
2217 | /*
|
---|
2218 | * Write the HDA DMA buffer.
|
---|
2219 | */
|
---|
2220 | PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns),
|
---|
2221 | pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos,
|
---|
2222 | pBdle->au8HdaBuffer, cbRead);
|
---|
2223 |
|
---|
2224 | /* Don't see any reason why cb2Copy would differ from cbRead. */
|
---|
2225 | Assert((cbRead == cb2Copy && (*pcbAvail) >= cb2Copy)); /* sanity */
|
---|
2226 |
|
---|
2227 | if (pBdle->cbUnderFifoW + cbRead > hdaFifoWToSz(pThis, 0))
|
---|
2228 | hdaBackendReadTransferReported(pBdle, cb2Copy, cbRead, &cbTransferred, pcbAvail);
|
---|
2229 | else
|
---|
2230 | {
|
---|
2231 | hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cbRead, pcbAvail);
|
---|
2232 | rc = VERR_NO_DATA;
|
---|
2233 | }
|
---|
2234 | }
|
---|
2235 | }
|
---|
2236 |
|
---|
2237 | Assert((cbTransferred <= (SDFIFOS(pThis, 0) + 1)));
|
---|
2238 | LogFunc(("CVI(pos:%RU32, len:%RU32), cbTransferred=%RU32, rc=%Rrc\n",
|
---|
2239 | pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred, rc));
|
---|
2240 |
|
---|
2241 | if (RT_SUCCESS(rc))
|
---|
2242 | *pcbRead = cbTransferred;
|
---|
2243 |
|
---|
2244 | return rc;
|
---|
2245 | }
|
---|
2246 | #else
|
---|
2247 | static int hdaReadAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc,
|
---|
2248 | uint32_t u32CblLimit, uint32_t *pu32Avail, uint32_t *pcbRead)
|
---|
2249 | {
|
---|
2250 | PHDABDLEDESC pBdle = &pThis->StInBdle;
|
---|
2251 |
|
---|
2252 | uint32_t cbTransferred = 0;
|
---|
2253 | uint32_t cb2Copy = 0;
|
---|
2254 | uint32_t cbBackendCopy = 0;
|
---|
2255 |
|
---|
2256 | int rc;
|
---|
2257 |
|
---|
2258 | Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
2259 |
|
---|
2260 | cb2Copy = hdaCalculateTransferBufferLength(pBdle, pStreamDesc, *pu32Avail, u32CblLimit);
|
---|
2261 | if (!cb2Copy)
|
---|
2262 | {
|
---|
2263 | /* if we enter here we can't report "unreported bits" */
|
---|
2264 | rc = VINF_EOF;
|
---|
2265 | }
|
---|
2266 | else
|
---|
2267 | {
|
---|
2268 | /*
|
---|
2269 | * read from backend input line to the last unreported position or at the begining.
|
---|
2270 | */
|
---|
2271 | cbBackendCopy = AUD_read(pThis->pCodec->SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy);
|
---|
2272 |
|
---|
2273 | /*
|
---|
2274 | * write the HDA DMA buffer
|
---|
2275 | */
|
---|
2276 | PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer,
|
---|
2277 | cbBackendCopy);
|
---|
2278 |
|
---|
2279 | /* Don't see any reason why cb2Copy would differ from cbBackendCopy */
|
---|
2280 | Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */
|
---|
2281 |
|
---|
2282 | if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pThis, 0))
|
---|
2283 | {
|
---|
2284 | hdaBackendReadTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail);
|
---|
2285 | rc = VINF_SUCCESS;
|
---|
2286 | }
|
---|
2287 | else
|
---|
2288 | {
|
---|
2289 | hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cbBackendCopy, pu32Avail);
|
---|
2290 | rc = VINF_EOF;
|
---|
2291 | }
|
---|
2292 | }
|
---|
2293 |
|
---|
2294 | Assert((cbTransferred <= (SDFIFOS(pThis, 0) + 1)));
|
---|
2295 | Log(("hda:ra: CVI(pos:%d, len:%d) cbTransferred: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred));
|
---|
2296 |
|
---|
2297 | if (pcbRead)
|
---|
2298 | *pcbRead = cbTransferred;
|
---|
2299 |
|
---|
2300 | return rc;
|
---|
2301 | }
|
---|
2302 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2303 |
|
---|
2304 | static int hdaWriteAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t u32CblLimit,
|
---|
2305 | uint32_t *pcbAvail, uint32_t *pcbWritten)
|
---|
2306 | {
|
---|
2307 | PHDABDLEDESC pBdle = &pThis->StOutBdle;
|
---|
2308 |
|
---|
2309 | int rc = VINF_SUCCESS;
|
---|
2310 |
|
---|
2311 | uint32_t cbTransferred = 0;
|
---|
2312 | uint32_t cbWrittenMin = 0; /* local byte counter, how many bytes copied to backend */
|
---|
2313 |
|
---|
2314 | LogFunc(("CVI(cvi:%RU32, pos:%RU32, len:%RU32)\n", pBdle->u32BdleCvi, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
2315 |
|
---|
2316 | /* Local byte counter (on local buffer). */
|
---|
2317 | uint32_t cb2Copy = hdaCalculateTransferBufferLength(pBdle, pStreamDesc, *pcbAvail, u32CblLimit);
|
---|
2318 |
|
---|
2319 | /*
|
---|
2320 | * Copy from DMA to the corresponding hdaBuffer (if there are any bytes from the
|
---|
2321 | * previous unreported transfer we write at offset 'pBdle->cbUnderFifoW').
|
---|
2322 | */
|
---|
2323 | if (!cb2Copy)
|
---|
2324 | {
|
---|
2325 | rc = VINF_EOF;
|
---|
2326 | }
|
---|
2327 | else
|
---|
2328 | {
|
---|
2329 | PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns),
|
---|
2330 | pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos,
|
---|
2331 | pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy);
|
---|
2332 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2333 | STAM_COUNTER_ADD(&pThis->StatBytesRead, cb2Copy);
|
---|
2334 | #endif
|
---|
2335 |
|
---|
2336 | /*
|
---|
2337 | * Write to audio backend. We should ensure that we have enough bytes to copy to the backend.
|
---|
2338 | */
|
---|
2339 | if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pThis, pStreamDesc))
|
---|
2340 | {
|
---|
2341 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2342 | uint32_t cbWritten;
|
---|
2343 | cbWrittenMin = UINT32_MAX;
|
---|
2344 |
|
---|
2345 | PHDADRIVER pDrv;
|
---|
2346 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
2347 | {
|
---|
2348 | if (pDrv->pConnector->pfnIsActiveOut(pDrv->pConnector, pDrv->Out.pStrmOut))
|
---|
2349 | {
|
---|
2350 | int rc2 = pDrv->pConnector->pfnWrite(pDrv->pConnector, pDrv->Out.pStrmOut,
|
---|
2351 | pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW,
|
---|
2352 | &cbWritten);
|
---|
2353 | if (RT_FAILURE(rc2))
|
---|
2354 | continue;
|
---|
2355 | }
|
---|
2356 | else /* Stream disabled, just assume all was copied. */
|
---|
2357 | cbWritten = cb2Copy;
|
---|
2358 |
|
---|
2359 | cbWrittenMin = RT_MIN(cbWrittenMin, cbWritten);
|
---|
2360 | LogFlowFunc(("\tLUN#%RU8: cbWritten=%RU32, cWrittenMin=%RU32\n", pDrv->uLUN, cbWritten, cbWrittenMin));
|
---|
2361 | }
|
---|
2362 |
|
---|
2363 | if (cbWrittenMin == UINT32_MAX)
|
---|
2364 | cbWrittenMin = 0;
|
---|
2365 | #else
|
---|
2366 | cbWrittenMin = AUD_write (pThis->pCodec->SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW);
|
---|
2367 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2368 |
|
---|
2369 | hdaBackendWriteTransferReported(pBdle, cb2Copy, cbWrittenMin, &cbTransferred, pcbAvail);
|
---|
2370 | }
|
---|
2371 | else
|
---|
2372 | {
|
---|
2373 | /* Not enough bytes to be processed and reported, we'll try our luck next time around. */
|
---|
2374 | hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cb2Copy, NULL);
|
---|
2375 | rc = VINF_EOF;
|
---|
2376 | }
|
---|
2377 | }
|
---|
2378 |
|
---|
2379 | Assert(cbTransferred <= SDFIFOS(pThis, 4) + 1);
|
---|
2380 | LogFunc(("CVI(pos:%RU32, len:%RU32, cbTransferred:%RU32), rc=%Rrc\n",
|
---|
2381 | pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred, rc));
|
---|
2382 |
|
---|
2383 | if (RT_SUCCESS(rc))
|
---|
2384 | *pcbWritten = cbTransferred;
|
---|
2385 |
|
---|
2386 | return rc;
|
---|
2387 | }
|
---|
2388 |
|
---|
2389 | /**
|
---|
2390 | * @interface_method_impl{HDACODEC,pfnReset}
|
---|
2391 | */
|
---|
2392 | DECLCALLBACK(int) hdaCodecReset(PHDACODEC pCodec)
|
---|
2393 | {
|
---|
2394 | PHDASTATE pThis = pCodec->pHDAState;
|
---|
2395 | NOREF(pThis);
|
---|
2396 | return VINF_SUCCESS;
|
---|
2397 | }
|
---|
2398 |
|
---|
2399 | DECLINLINE(void) hdaInitTransferDescriptor(PHDASTATE pThis, PHDABDLEDESC pBdle, uint8_t u8Strm,
|
---|
2400 | PHDASTREAMTRANSFERDESC pStreamDesc)
|
---|
2401 | {
|
---|
2402 | Assert(pThis); Assert(pBdle); Assert(pStreamDesc); Assert(u8Strm <= 7);
|
---|
2403 |
|
---|
2404 | RT_BZERO(pStreamDesc, sizeof(HDASTREAMTRANSFERDESC));
|
---|
2405 | pStreamDesc->u8Strm = u8Strm;
|
---|
2406 | pStreamDesc->u32Ctl = HDA_STREAM_REG(pThis, CTL, u8Strm);
|
---|
2407 | pStreamDesc->u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG(pThis, BDPL, u8Strm),
|
---|
2408 | HDA_STREAM_REG(pThis, BDPU, u8Strm));
|
---|
2409 | pStreamDesc->pu32Lpib = &HDA_STREAM_REG(pThis, LPIB, u8Strm);
|
---|
2410 | pStreamDesc->pu32Sts = &HDA_STREAM_REG(pThis, STS, u8Strm);
|
---|
2411 | pStreamDesc->u32Cbl = HDA_STREAM_REG(pThis, CBL, u8Strm);
|
---|
2412 | pStreamDesc->u32Fifos = HDA_STREAM_REG(pThis, FIFOS, u8Strm);
|
---|
2413 |
|
---|
2414 | pBdle->u32BdleMaxCvi = HDA_STREAM_REG(pThis, LVI, u8Strm);
|
---|
2415 |
|
---|
2416 | #ifdef LOG_ENABLED
|
---|
2417 | if ( pBdle
|
---|
2418 | && pBdle->u32BdleMaxCvi)
|
---|
2419 | {
|
---|
2420 | LogFunc(("Initialization of transfer descriptor:\n"));
|
---|
2421 | dump_bd(pThis, pBdle, pStreamDesc->u64BaseDMA);
|
---|
2422 | }
|
---|
2423 | #endif
|
---|
2424 | }
|
---|
2425 |
|
---|
2426 | static DECLCALLBACK(void) hdaCloseIn(PHDASTATE pThis, PDMAUDIORECSOURCE enmRecSource)
|
---|
2427 | {
|
---|
2428 | NOREF(pThis);
|
---|
2429 | NOREF(enmRecSource);
|
---|
2430 | LogFlowFuncEnter();
|
---|
2431 | }
|
---|
2432 |
|
---|
2433 | static DECLCALLBACK(void) hdaCloseOut(PHDASTATE pThis)
|
---|
2434 | {
|
---|
2435 | NOREF(pThis);
|
---|
2436 | LogFlowFuncEnter();
|
---|
2437 | }
|
---|
2438 |
|
---|
2439 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2440 | static DECLCALLBACK(int) hdaOpenIn(PHDASTATE pThis,
|
---|
2441 | const char *pszName, PDMAUDIORECSOURCE enmRecSource,
|
---|
2442 | PPDMAUDIOSTREAMCFG pCfg)
|
---|
2443 | {
|
---|
2444 | PAUDMIXSINK pSink;
|
---|
2445 |
|
---|
2446 | switch (enmRecSource)
|
---|
2447 | {
|
---|
2448 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
2449 | case PDMAUDIORECSOURCE_MIC:
|
---|
2450 | pSink = pThis->pSinkMicIn;
|
---|
2451 | break;
|
---|
2452 | # endif
|
---|
2453 | case PDMAUDIORECSOURCE_LINE_IN:
|
---|
2454 | pSink = pThis->pSinkLineIn;
|
---|
2455 | break;
|
---|
2456 | default:
|
---|
2457 | AssertMsgFailed(("Audio source %ld not supported\n", enmRecSource));
|
---|
2458 | return VERR_NOT_SUPPORTED;
|
---|
2459 | }
|
---|
2460 |
|
---|
2461 | int rc = VINF_SUCCESS;
|
---|
2462 | char *pszDesc;
|
---|
2463 |
|
---|
2464 | PHDADRIVER pDrv;
|
---|
2465 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
2466 | {
|
---|
2467 | if (RTStrAPrintf(&pszDesc, "[LUN#%RU8] %s", pDrv->uLUN, pszName) <= 0)
|
---|
2468 | {
|
---|
2469 | rc = VERR_NO_MEMORY;
|
---|
2470 | break;
|
---|
2471 | }
|
---|
2472 |
|
---|
2473 | rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector, pszDesc, enmRecSource, pCfg, &pDrv->LineIn.pStrmIn);
|
---|
2474 | LogFlowFunc(("LUN#%RU8: Opened input \"%s\", with rc=%Rrc\n", pDrv->uLUN, pszDesc, rc));
|
---|
2475 | if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
|
---|
2476 | {
|
---|
2477 | audioMixerRemoveStream(pSink, pDrv->LineIn.phStrmIn);
|
---|
2478 | rc = audioMixerAddStreamIn(pSink,
|
---|
2479 | pDrv->pConnector, pDrv->LineIn.pStrmIn,
|
---|
2480 | 0 /* uFlags */, &pDrv->LineIn.phStrmIn);
|
---|
2481 | }
|
---|
2482 |
|
---|
2483 | RTStrFree(pszDesc);
|
---|
2484 | }
|
---|
2485 |
|
---|
2486 | LogFlowFuncLeaveRC(rc);
|
---|
2487 | return rc;
|
---|
2488 | }
|
---|
2489 |
|
---|
2490 | static DECLCALLBACK(int) hdaOpenOut(PHDASTATE pThis,
|
---|
2491 | const char *pszName, PPDMAUDIOSTREAMCFG pCfg)
|
---|
2492 | {
|
---|
2493 | int rc = VINF_SUCCESS;
|
---|
2494 | char *pszDesc;
|
---|
2495 |
|
---|
2496 | PHDADRIVER pDrv;
|
---|
2497 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
2498 | {
|
---|
2499 | if (RTStrAPrintf(&pszDesc, "[LUN#%RU8] %s", pDrv->uLUN, pszName) <= 0)
|
---|
2500 | {
|
---|
2501 | rc = VERR_NO_MEMORY;
|
---|
2502 | break;
|
---|
2503 | }
|
---|
2504 |
|
---|
2505 | rc = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszDesc, pCfg, &pDrv->Out.pStrmOut);
|
---|
2506 | LogFlowFunc(("LUN#%RU8: Opened output \"%s\", with rc=%Rrc\n", pDrv->uLUN, pszDesc, rc));
|
---|
2507 | if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
|
---|
2508 | {
|
---|
2509 | audioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
|
---|
2510 | rc = audioMixerAddStreamOut(pThis->pSinkOutput,
|
---|
2511 | pDrv->pConnector, pDrv->Out.pStrmOut,
|
---|
2512 | 0 /* uFlags */, &pDrv->Out.phStrmOut);
|
---|
2513 | }
|
---|
2514 |
|
---|
2515 | RTStrFree(pszDesc);
|
---|
2516 | }
|
---|
2517 |
|
---|
2518 | LogFlowFuncLeaveRC(rc);
|
---|
2519 | return rc;
|
---|
2520 | }
|
---|
2521 |
|
---|
2522 | static DECLCALLBACK(int) hdaSetVolume(PHDASTATE pThis,
|
---|
2523 | bool fMute, uint8_t uVolLeft, uint8_t uVolRight)
|
---|
2524 | {
|
---|
2525 | int rc = VINF_SUCCESS;
|
---|
2526 |
|
---|
2527 | PDMAUDIOVOLUME vol = { fMute, uVolLeft, uVolRight };
|
---|
2528 | audioMixerSetMasterVolume(pThis->pMixer, &vol);
|
---|
2529 |
|
---|
2530 | LogFlowFuncLeaveRC(rc);
|
---|
2531 | return rc;
|
---|
2532 | }
|
---|
2533 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2534 |
|
---|
2535 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2536 | static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
|
---|
2537 | {
|
---|
2538 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
2539 | AssertPtr(pThis);
|
---|
2540 |
|
---|
2541 | STAM_PROFILE_START(&pThis->StatTimer, a);
|
---|
2542 |
|
---|
2543 | int rc = VINF_SUCCESS;
|
---|
2544 |
|
---|
2545 | uint32_t cbInMax = 0;
|
---|
2546 | uint32_t cbOutMin = UINT32_MAX;
|
---|
2547 |
|
---|
2548 | PHDADRIVER pDrv;
|
---|
2549 |
|
---|
2550 | uint32_t cbIn, cbOut, cSamplesLive;
|
---|
2551 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
2552 | {
|
---|
2553 | rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector,
|
---|
2554 | &cbIn, &cbOut, &cSamplesLive);
|
---|
2555 | if (RT_SUCCESS(rc))
|
---|
2556 | {
|
---|
2557 | #ifdef DEBUG_TIMER
|
---|
2558 | LogFlowFunc(("\tLUN#%RU8: [1] cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, cbIn, cbOut));
|
---|
2559 | #endif
|
---|
2560 | if (cSamplesLive)
|
---|
2561 | {
|
---|
2562 | uint32_t cSamplesPlayed;
|
---|
2563 | int rc2 = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, &cSamplesPlayed);
|
---|
2564 | if (RT_SUCCESS(rc2))
|
---|
2565 | LogFlowFunc(("LUN#%RU8: cSamplesLive=%RU32, cSamplesPlayed=%RU32\n",
|
---|
2566 | pDrv->uLUN, cSamplesLive, cSamplesPlayed));
|
---|
2567 |
|
---|
2568 | rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector,
|
---|
2569 | &cbIn, &cbOut, &cSamplesLive);
|
---|
2570 | #ifdef DEBUG_TIMER
|
---|
2571 | if (RT_SUCCESS(rc))
|
---|
2572 | LogFlowFunc(("\tLUN#%RU8: [2] cbIn=%RU32, cbOut=%RU32\n", pDrv->uLUN, cbIn, cbOut));
|
---|
2573 | #endif
|
---|
2574 | }
|
---|
2575 |
|
---|
2576 | cbInMax = RT_MAX(cbInMax, cbIn);
|
---|
2577 | cbOutMin = RT_MIN(cbOutMin, cbOut);
|
---|
2578 | }
|
---|
2579 | }
|
---|
2580 |
|
---|
2581 | #ifdef DEBUG_TIMER
|
---|
2582 | LogFlowFunc(("cbInMax=%RU32, cbOutMin=%RU32\n", cbInMax, cbOutMin));
|
---|
2583 | #endif
|
---|
2584 |
|
---|
2585 | if (cbOutMin == UINT32_MAX)
|
---|
2586 | cbOutMin = 0;
|
---|
2587 |
|
---|
2588 | /*
|
---|
2589 | * Playback.
|
---|
2590 | */
|
---|
2591 | if (cbOutMin)
|
---|
2592 | {
|
---|
2593 | Assert(cbOutMin != UINT32_MAX);
|
---|
2594 | hdaTransfer(pThis, PO_INDEX, cbOutMin); /** @todo Add rc! */
|
---|
2595 | }
|
---|
2596 |
|
---|
2597 | /*
|
---|
2598 | * Recording.
|
---|
2599 | */
|
---|
2600 | if (cbInMax)
|
---|
2601 | hdaTransfer(pThis, PI_INDEX, cbInMax); /** @todo Add rc! */
|
---|
2602 |
|
---|
2603 | TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTicks);
|
---|
2604 |
|
---|
2605 | STAM_PROFILE_STOP(&pThis->StatTimer, a);
|
---|
2606 | }
|
---|
2607 |
|
---|
2608 | static DECLCALLBACK(int) hdaTransfer(PHDASTATE pThis,
|
---|
2609 | ENMSOUNDSOURCE enmSrc, uint32_t cbAvail)
|
---|
2610 | {
|
---|
2611 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2612 |
|
---|
2613 | LogFlowFunc(("pThis=%p, cbAvail=%RU32\n", pThis, cbAvail));
|
---|
2614 | #else
|
---|
2615 | static DECLCALLBACK(int) hdaTransfer(PHDACODEC pCodec, ENMSOUNDSOURCE enmSrc, uint32_t cbAvail)
|
---|
2616 | {
|
---|
2617 | AssertPtrReturn(pCodec, VERR_INVALID_POINTER);
|
---|
2618 | PHDASTATE pThis = pCodec->pHDAState;
|
---|
2619 | AssertPtrReturn(pThis, VERR_INVALID_POINTER);
|
---|
2620 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2621 |
|
---|
2622 | uint8_t u8Strm;
|
---|
2623 | PHDABDLEDESC pBdle;
|
---|
2624 |
|
---|
2625 | switch (enmSrc)
|
---|
2626 | {
|
---|
2627 | case PI_INDEX:
|
---|
2628 | {
|
---|
2629 | u8Strm = 0;
|
---|
2630 | pBdle = &pThis->StInBdle;
|
---|
2631 | break;
|
---|
2632 | }
|
---|
2633 |
|
---|
2634 | #ifdef VBOX_WITH_HDA_MIC_IN
|
---|
2635 | case MC_INDEX:
|
---|
2636 | {
|
---|
2637 | u8Strm = 2;
|
---|
2638 | pBdle = &pThis->StMicBdle;
|
---|
2639 | break;
|
---|
2640 | }
|
---|
2641 | #endif
|
---|
2642 | case PO_INDEX:
|
---|
2643 | {
|
---|
2644 | u8Strm = 4;
|
---|
2645 | pBdle = &pThis->StOutBdle;
|
---|
2646 | break;
|
---|
2647 | }
|
---|
2648 |
|
---|
2649 | default:
|
---|
2650 | AssertMsgFailed(("Unknown source index %ld\n", enmSrc));
|
---|
2651 | return VERR_NOT_SUPPORTED;
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 | HDASTREAMTRANSFERDESC StreamDesc;
|
---|
2655 | hdaInitTransferDescriptor(pThis, pBdle, u8Strm, &StreamDesc);
|
---|
2656 |
|
---|
2657 | int rc = VINF_EOF;
|
---|
2658 | while (cbAvail)
|
---|
2659 | {
|
---|
2660 | Assert( (StreamDesc.u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN))
|
---|
2661 | && cbAvail
|
---|
2662 | && StreamDesc.u64BaseDMA);
|
---|
2663 |
|
---|
2664 | /* Fetch the Buffer Descriptor Entry (BDE). */
|
---|
2665 | if (hdaIsTransferCountersOverlapped(pThis, pBdle, &StreamDesc))
|
---|
2666 | hdaFetchBdle(pThis, pBdle, &StreamDesc);
|
---|
2667 |
|
---|
2668 | *StreamDesc.pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY);
|
---|
2669 | Assert((StreamDesc.u32Cbl >= (*StreamDesc.pu32Lpib))); /* sanity */
|
---|
2670 | uint32_t u32CblLimit = StreamDesc.u32Cbl - (*StreamDesc.pu32Lpib);
|
---|
2671 | Assert((u32CblLimit > hdaFifoWToSz(pThis, &StreamDesc)));
|
---|
2672 |
|
---|
2673 | LogFunc(("CBL=%RU32, LPIB=%RU32\n", StreamDesc.u32Cbl, *StreamDesc.pu32Lpib));
|
---|
2674 |
|
---|
2675 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2676 | PAUDMIXSINK pSink;
|
---|
2677 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2678 | uint32_t cbWritten = 0;
|
---|
2679 | switch (enmSrc)
|
---|
2680 | {
|
---|
2681 | case PI_INDEX:
|
---|
2682 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2683 | pSink = pThis->pSinkLineIn;
|
---|
2684 | rc = hdaReadAudio(pThis, pSink, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten);
|
---|
2685 | #else
|
---|
2686 | rc = hdaReadAudio(pThis, &StreamDesc, u32CblLimit, (uint32_t *)&cbAvail, &cbWritten);
|
---|
2687 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2688 | break;
|
---|
2689 | case PO_INDEX:
|
---|
2690 | rc = hdaWriteAudio(pThis, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten);
|
---|
2691 | break;
|
---|
2692 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
2693 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
2694 | case MC_INDEX:
|
---|
2695 | pSink = pThis->pSinkMicIn;
|
---|
2696 | rc = hdaReadAudio(pThis, pSink, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten);
|
---|
2697 | break;
|
---|
2698 | # endif
|
---|
2699 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
2700 | default:
|
---|
2701 | AssertMsgFailed(("Unsupported source index %ld\n", enmSrc));
|
---|
2702 | rc = VERR_NOT_SUPPORTED;
|
---|
2703 | break;
|
---|
2704 | }
|
---|
2705 | Assert(cbWritten <= StreamDesc.u32Fifos + 1);
|
---|
2706 | *StreamDesc.pu32Sts &= ~HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY);
|
---|
2707 |
|
---|
2708 | /* Process end of buffer condition. */
|
---|
2709 | hdaStreamCounterUpdate(pThis, pBdle, &StreamDesc, cbWritten);
|
---|
2710 |
|
---|
2711 | if (!hdaDoNextTransferCycle(pThis, pBdle, &StreamDesc))
|
---|
2712 | break;
|
---|
2713 |
|
---|
2714 | if ( RT_FAILURE(rc)
|
---|
2715 | || rc == VINF_EOF) /* All data processed? */
|
---|
2716 | {
|
---|
2717 | break;
|
---|
2718 | }
|
---|
2719 | }
|
---|
2720 |
|
---|
2721 | return rc;
|
---|
2722 | }
|
---|
2723 | #endif /* IN_RING3 */
|
---|
2724 |
|
---|
2725 | /* MMIO callbacks */
|
---|
2726 |
|
---|
2727 | /**
|
---|
2728 | * @callback_method_impl{FNIOMMMIOREAD, Looks up and calls the appropriate handler.}
|
---|
2729 | *
|
---|
2730 | * @note During implementation, we discovered so-called "forgotten" or "hole"
|
---|
2731 | * registers whose description is not listed in the RPM, datasheet, or
|
---|
2732 | * spec.
|
---|
2733 | */
|
---|
2734 | PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
|
---|
2735 | {
|
---|
2736 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
2737 | int rc;
|
---|
2738 |
|
---|
2739 | /*
|
---|
2740 | * Look up and log.
|
---|
2741 | */
|
---|
2742 | uint32_t offReg = GCPhysAddr - pThis->MMIOBaseAddr;
|
---|
2743 | int idxRegDsc = hdaRegLookup(pThis, offReg); /* Register descriptor index. */
|
---|
2744 | #ifdef LOG_ENABLED
|
---|
2745 | unsigned const cbLog = cb;
|
---|
2746 | uint32_t offRegLog = offReg;
|
---|
2747 | #endif
|
---|
2748 |
|
---|
2749 | LogFunc(("offReg=%#x cb=%#x\n", offReg, cb));
|
---|
2750 | #define NEW_READ_CODE
|
---|
2751 | #ifdef NEW_READ_CODE
|
---|
2752 | Assert(cb == 4); Assert((offReg & 3) == 0);
|
---|
2753 |
|
---|
2754 | if (pThis->fInReset && idxRegDsc != HDA_REG_GCTL)
|
---|
2755 | LogFunc(("access to registers except GCTL is blocked while reset\n"));
|
---|
2756 |
|
---|
2757 | if (idxRegDsc == -1)
|
---|
2758 | LogRel(("Invalid read access @0x%x(of bytes:%d)\n", offReg, cb));
|
---|
2759 |
|
---|
2760 | if (idxRegDsc != -1)
|
---|
2761 | {
|
---|
2762 | /* ASSUMES gapless DWORD at end of map. */
|
---|
2763 | if (g_aHdaRegMap[idxRegDsc].size == 4)
|
---|
2764 | {
|
---|
2765 | /*
|
---|
2766 | * Straight forward DWORD access.
|
---|
2767 | */
|
---|
2768 | rc = g_aHdaRegMap[idxRegDsc].pfnRead(pThis, idxRegDsc, (uint32_t *)pv);
|
---|
2769 | LogFunc(("read %s => %x (%Rrc)\n", g_aHdaRegMap[idxRegDsc].abbrev, *(uint32_t *)pv, rc));
|
---|
2770 | }
|
---|
2771 | else
|
---|
2772 | {
|
---|
2773 | /*
|
---|
2774 | * Multi register read (unless there are trailing gaps).
|
---|
2775 | * ASSUMES that only DWORD reads have sideeffects.
|
---|
2776 | */
|
---|
2777 | uint32_t u32Value = 0;
|
---|
2778 | unsigned cbLeft = 4;
|
---|
2779 | do
|
---|
2780 | {
|
---|
2781 | uint32_t const cbReg = g_aHdaRegMap[idxRegDsc].size;
|
---|
2782 | uint32_t u32Tmp = 0;
|
---|
2783 |
|
---|
2784 | rc = g_aHdaRegMap[idxRegDsc].pfnRead(pThis, idxRegDsc, &u32Tmp);
|
---|
2785 | LogFunc(("read %s[%db] => %x (%Rrc)*\n", g_aHdaRegMap[idxRegDsc].abbrev, cbReg, u32Tmp, rc));
|
---|
2786 | if (rc != VINF_SUCCESS)
|
---|
2787 | break;
|
---|
2788 | u32Value |= (u32Tmp & g_afMasks[cbReg]) << ((4 - cbLeft) * 8);
|
---|
2789 |
|
---|
2790 | cbLeft -= cbReg;
|
---|
2791 | offReg += cbReg;
|
---|
2792 | idxRegDsc++;
|
---|
2793 | } while (cbLeft > 0 && g_aHdaRegMap[idxRegDsc].offset == offReg);
|
---|
2794 |
|
---|
2795 | if (rc == VINF_SUCCESS)
|
---|
2796 | *(uint32_t *)pv = u32Value;
|
---|
2797 | else
|
---|
2798 | Assert(!IOM_SUCCESS(rc));
|
---|
2799 | }
|
---|
2800 | }
|
---|
2801 | else
|
---|
2802 | {
|
---|
2803 | rc = VINF_IOM_MMIO_UNUSED_FF;
|
---|
2804 | LogFunc(("hole at %x is accessed for read\n", offReg));
|
---|
2805 | }
|
---|
2806 | #else
|
---|
2807 | if (idxRegDsc != -1)
|
---|
2808 | {
|
---|
2809 | /** @todo r=bird: Accesses crossing register boundraries aren't handled
|
---|
2810 | * right from what I can tell? If they are, please explain
|
---|
2811 | * what the rules are. */
|
---|
2812 | uint32_t mask = 0;
|
---|
2813 | uint32_t shift = (g_aHdaRegMap[idxRegDsc].offset - offReg) % sizeof(uint32_t) * 8;
|
---|
2814 | uint32_t u32Value = 0;
|
---|
2815 | switch(cb)
|
---|
2816 | {
|
---|
2817 | case 1: mask = 0x000000ff; break;
|
---|
2818 | case 2: mask = 0x0000ffff; break;
|
---|
2819 | case 4:
|
---|
2820 | /* 18.2 of the ICH6 datasheet defines the valid access widths as byte, word, and double word */
|
---|
2821 | case 8:
|
---|
2822 | mask = 0xffffffff;
|
---|
2823 | cb = 4;
|
---|
2824 | break;
|
---|
2825 | }
|
---|
2826 | #if 0
|
---|
2827 | /* Cross-register access. Mac guest hits this assert doing assumption 4 byte access to 3 byte registers e.g. {I,O}SDnCTL
|
---|
2828 | */
|
---|
2829 | //Assert((cb <= g_aHdaRegMap[idxRegDsc].size - (offReg - g_aHdaRegMap[idxRegDsc].offset)));
|
---|
2830 | if (cb > g_aHdaRegMap[idxRegDsc].size - (offReg - g_aHdaRegMap[idxRegDsc].offset))
|
---|
2831 | {
|
---|
2832 | int off = cb - (g_aHdaRegMap[idxRegDsc].size - (offReg - g_aHdaRegMap[idxRegDsc].offset));
|
---|
2833 | rc = hdaMMIORead(pDevIns, pvUser, GCPhysAddr + cb - off, (char *)pv + cb - off, off);
|
---|
2834 | if (RT_FAILURE(rc))
|
---|
2835 | AssertRCReturn (rc, rc);
|
---|
2836 | }
|
---|
2837 | //Assert(((offReg - g_aHdaRegMap[idxRegDsc].offset) == 0));
|
---|
2838 | #endif
|
---|
2839 | mask <<= shift;
|
---|
2840 | rc = g_aHdaRegMap[idxRegDsc].pfnRead(pThis, idxRegDsc, &u32Value);
|
---|
2841 | *(uint32_t *)pv |= (u32Value & mask);
|
---|
2842 | LogFunc(("read %s[%x/%x]\n", g_aHdaRegMap[idxRegDsc].abbrev, u32Value, *(uint32_t *)pv));
|
---|
2843 | }
|
---|
2844 | else
|
---|
2845 | {
|
---|
2846 | *(uint32_t *)pv = 0xFF;
|
---|
2847 | LogFunc(("hole at %x is accessed for read\n", offReg));
|
---|
2848 | rc = VINF_SUCCESS;
|
---|
2849 | }
|
---|
2850 | #endif
|
---|
2851 |
|
---|
2852 | /*
|
---|
2853 | * Log the outcome.
|
---|
2854 | */
|
---|
2855 | #ifdef LOG_ENABLED
|
---|
2856 | if (cbLog == 4)
|
---|
2857 | LogFunc(("@%#05x -> %#010x %Rrc\n", offRegLog, *(uint32_t *)pv, rc));
|
---|
2858 | else if (cbLog == 2)
|
---|
2859 | LogFunc(("@%#05x -> %#06x %Rrc\n", offRegLog, *(uint16_t *)pv, rc));
|
---|
2860 | else if (cbLog == 1)
|
---|
2861 | LogFunc(("@%#05x -> %#04x %Rrc\n", offRegLog, *(uint8_t *)pv, rc));
|
---|
2862 | #endif
|
---|
2863 | return rc;
|
---|
2864 | }
|
---|
2865 |
|
---|
2866 |
|
---|
2867 | DECLINLINE(int) hdaWriteReg(PHDASTATE pThis, int idxRegDsc, uint32_t u32Value, char const *pszLog)
|
---|
2868 | {
|
---|
2869 | if (pThis->fInReset && idxRegDsc != HDA_REG_GCTL)
|
---|
2870 | LogFunc(("access to registers except GCTL is blocked while reset\n")); /** @todo where is this enforced? */
|
---|
2871 |
|
---|
2872 | uint32_t idxRegMem = g_aHdaRegMap[idxRegDsc].mem_idx;
|
---|
2873 | #ifdef LOG_ENABLED
|
---|
2874 | uint32_t const u32CurValue = pThis->au32Regs[idxRegMem];
|
---|
2875 | #endif
|
---|
2876 | int rc = g_aHdaRegMap[idxRegDsc].pfnWrite(pThis, idxRegDsc, u32Value);
|
---|
2877 | LogFunc(("write %#x -> %s[%db]; %x => %x%s\n", u32Value, g_aHdaRegMap[idxRegDsc].abbrev,
|
---|
2878 | g_aHdaRegMap[idxRegDsc].size, u32CurValue, pThis->au32Regs[idxRegMem], pszLog));
|
---|
2879 | return rc;
|
---|
2880 | }
|
---|
2881 |
|
---|
2882 |
|
---|
2883 | /**
|
---|
2884 | * @callback_method_impl{FNIOMMMIOWRITE, Looks up and calls the appropriate handler.}
|
---|
2885 | */
|
---|
2886 | PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
|
---|
2887 | {
|
---|
2888 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
2889 | int rc;
|
---|
2890 |
|
---|
2891 | /*
|
---|
2892 | * The behavior of accesses that aren't aligned on natural boundraries is
|
---|
2893 | * undefined. Just reject them outright.
|
---|
2894 | */
|
---|
2895 | /** @todo IOM could check this, it could also split the 8 byte accesses for us. */
|
---|
2896 | Assert(cb == 1 || cb == 2 || cb == 4 || cb == 8);
|
---|
2897 | if (GCPhysAddr & (cb - 1))
|
---|
2898 | return PDMDevHlpDBGFStop(pDevIns, RT_SRC_POS, "misaligned write access: GCPhysAddr=%RGp cb=%u\n", GCPhysAddr, cb);
|
---|
2899 |
|
---|
2900 | /*
|
---|
2901 | * Look up and log the access.
|
---|
2902 | */
|
---|
2903 | uint32_t offReg = GCPhysAddr - pThis->MMIOBaseAddr;
|
---|
2904 | int idxRegDsc = hdaRegLookup(pThis, offReg);
|
---|
2905 | uint32_t idxRegMem = idxRegDsc != -1 ? g_aHdaRegMap[idxRegDsc].mem_idx : UINT32_MAX;
|
---|
2906 | uint64_t u64Value;
|
---|
2907 | if (cb == 4) u64Value = *(uint32_t const *)pv;
|
---|
2908 | else if (cb == 2) u64Value = *(uint16_t const *)pv;
|
---|
2909 | else if (cb == 1) u64Value = *(uint8_t const *)pv;
|
---|
2910 | else if (cb == 8) u64Value = *(uint64_t const *)pv;
|
---|
2911 | else
|
---|
2912 | {
|
---|
2913 | u64Value = 0; /* shut up gcc. */
|
---|
2914 | AssertReleaseMsgFailed(("%d\n", cb));
|
---|
2915 | }
|
---|
2916 |
|
---|
2917 | #ifdef LOG_ENABLED
|
---|
2918 | uint32_t const u32LogOldValue = idxRegDsc >= 0 ? pThis->au32Regs[idxRegMem] : UINT32_MAX;
|
---|
2919 | uint32_t const offRegLog = offReg;
|
---|
2920 | int const idxRegLog = idxRegMem;
|
---|
2921 | if (idxRegDsc == -1)
|
---|
2922 | LogFunc(("@%#05x u32=%#010x cb=%d\n", offReg, *(uint32_t const *)pv, cb));
|
---|
2923 | else if (cb == 4)
|
---|
2924 | LogFunc(("@%#05x u32=%#010x %s\n", offReg, *(uint32_t *)pv, g_aHdaRegMap[idxRegDsc].abbrev));
|
---|
2925 | else if (cb == 2)
|
---|
2926 | LogFunc(("@%#05x u16=%#06x (%#010x) %s\n", offReg, *(uint16_t *)pv, *(uint32_t *)pv, g_aHdaRegMap[idxRegDsc].abbrev));
|
---|
2927 | else if (cb == 1)
|
---|
2928 | LogFunc(("@%#05x u8=%#04x (%#010x) %s\n", offReg, *(uint8_t *)pv, *(uint32_t *)pv, g_aHdaRegMap[idxRegDsc].abbrev));
|
---|
2929 | if (idxRegDsc >= 0 && g_aHdaRegMap[idxRegDsc].size != cb)
|
---|
2930 | LogFunc(("size=%d != cb=%d!!\n", g_aHdaRegMap[idxRegDsc].size, cb));
|
---|
2931 | #endif
|
---|
2932 |
|
---|
2933 | #define NEW_WRITE_CODE
|
---|
2934 | #ifdef NEW_WRITE_CODE
|
---|
2935 | /*
|
---|
2936 | * Try for a direct hit first.
|
---|
2937 | */
|
---|
2938 | if (idxRegDsc != -1 && g_aHdaRegMap[idxRegDsc].size == cb)
|
---|
2939 | {
|
---|
2940 | rc = hdaWriteReg(pThis, idxRegDsc, u64Value, "");
|
---|
2941 | LogFunc(("@%#05x %#x -> %#x\n", offRegLog, u32LogOldValue,
|
---|
2942 | idxRegLog != -1 ? pThis->au32Regs[idxRegLog] : UINT32_MAX));
|
---|
2943 | }
|
---|
2944 | /*
|
---|
2945 | * Partial or multiple register access, loop thru the requested memory.
|
---|
2946 | */
|
---|
2947 | else
|
---|
2948 | {
|
---|
2949 | /* If it's an access beyond the start of the register, shift the input
|
---|
2950 | value and fill in missing bits. Natural alignment rules means we
|
---|
2951 | will only see 1 or 2 byte accesses of this kind, so no risk of
|
---|
2952 | shifting out input values. */
|
---|
2953 | if (idxRegDsc == -1 && (idxRegDsc = hdaRegLookupWithin(pThis, offReg)) != -1)
|
---|
2954 | {
|
---|
2955 | uint32_t const cbBefore = offReg - g_aHdaRegMap[idxRegDsc].offset; Assert(cbBefore > 0 && cbBefore < 4);
|
---|
2956 | offReg -= cbBefore;
|
---|
2957 | idxRegMem = g_aHdaRegMap[idxRegDsc].mem_idx;
|
---|
2958 | u64Value <<= cbBefore * 8;
|
---|
2959 | u64Value |= pThis->au32Regs[idxRegMem] & g_afMasks[cbBefore];
|
---|
2960 | LogFunc(("Within register, supplied %u leading bits: %#llx -> %#llx ...\n",
|
---|
2961 | cbBefore * 8, ~g_afMasks[cbBefore] & u64Value, u64Value));
|
---|
2962 | }
|
---|
2963 |
|
---|
2964 | /* Loop thru the write area, it may cover multiple registers. */
|
---|
2965 | rc = VINF_SUCCESS;
|
---|
2966 | for (;;)
|
---|
2967 | {
|
---|
2968 | uint32_t cbReg;
|
---|
2969 | if (idxRegDsc != -1)
|
---|
2970 | {
|
---|
2971 | idxRegMem = g_aHdaRegMap[idxRegDsc].mem_idx;
|
---|
2972 | cbReg = g_aHdaRegMap[idxRegDsc].size;
|
---|
2973 | if (cb < cbReg)
|
---|
2974 | {
|
---|
2975 | u64Value |= pThis->au32Regs[idxRegMem] & g_afMasks[cbReg] & ~g_afMasks[cb];
|
---|
2976 | LogFunc(("Supplying missing bits (%#x): %#llx -> %#llx ...\n",
|
---|
2977 | g_afMasks[cbReg] & ~g_afMasks[cb], u64Value & g_afMasks[cb], u64Value));
|
---|
2978 | }
|
---|
2979 | uint32_t u32LogOldVal = pThis->au32Regs[idxRegMem];
|
---|
2980 | rc = hdaWriteReg(pThis, idxRegDsc, u64Value, "*");
|
---|
2981 | LogFunc(("@%#05x %#x -> %#x\n", offRegLog, u32LogOldVal,
|
---|
2982 | pThis->au32Regs[idxRegMem]));
|
---|
2983 | }
|
---|
2984 | else
|
---|
2985 | {
|
---|
2986 | LogRel(("HDA: Invalid write access @0x%x!\n", offReg));
|
---|
2987 | cbReg = 1;
|
---|
2988 | }
|
---|
2989 | if (rc != VINF_SUCCESS)
|
---|
2990 | break;
|
---|
2991 | if (cbReg >= cb)
|
---|
2992 | break;
|
---|
2993 |
|
---|
2994 | /* advance */
|
---|
2995 | offReg += cbReg;
|
---|
2996 | cb -= cbReg;
|
---|
2997 | u64Value >>= cbReg * 8;
|
---|
2998 | if (idxRegDsc == -1)
|
---|
2999 | idxRegDsc = hdaRegLookup(pThis, offReg);
|
---|
3000 | else
|
---|
3001 | {
|
---|
3002 | idxRegDsc++;
|
---|
3003 | if ( (unsigned)idxRegDsc >= RT_ELEMENTS(g_aHdaRegMap)
|
---|
3004 | || g_aHdaRegMap[idxRegDsc].offset != offReg)
|
---|
3005 | idxRegDsc = -1;
|
---|
3006 | }
|
---|
3007 | }
|
---|
3008 | }
|
---|
3009 | #else
|
---|
3010 | if (idxRegDsc != -1)
|
---|
3011 | {
|
---|
3012 | /** @todo r=bird: This looks like code for handling unaligned register
|
---|
3013 | * accesses. If it isn't, then add a comment explaining what you're
|
---|
3014 | * trying to do here. OTOH, if it is then it has the following
|
---|
3015 | * issues:
|
---|
3016 | * -# You're calculating the wrong new value for the register.
|
---|
3017 | * -# You're not handling cross register accesses. Imagine a
|
---|
3018 | * 4-byte write starting at CORBCTL, or a 8-byte write.
|
---|
3019 | *
|
---|
3020 | * PS! consider dropping the 'offset' argument to pfnWrite/pfnRead as
|
---|
3021 | * nobody seems to be using it and it just adds complexity when reading
|
---|
3022 | * the code.
|
---|
3023 | *
|
---|
3024 | */
|
---|
3025 | uint32_t u32CurValue = pThis->au32Regs[idxRegMem];
|
---|
3026 | uint32_t u32NewValue;
|
---|
3027 | uint32_t mask;
|
---|
3028 | switch (cb)
|
---|
3029 | {
|
---|
3030 | case 1:
|
---|
3031 | u32NewValue = *(uint8_t const *)pv;
|
---|
3032 | mask = 0xff;
|
---|
3033 | break;
|
---|
3034 | case 2:
|
---|
3035 | u32NewValue = *(uint16_t const *)pv;
|
---|
3036 | mask = 0xffff;
|
---|
3037 | break;
|
---|
3038 | case 4:
|
---|
3039 | case 8:
|
---|
3040 | /* 18.2 of the ICH6 datasheet defines the valid access widths as byte, word, and double word */
|
---|
3041 | u32NewValue = *(uint32_t const *)pv;
|
---|
3042 | mask = 0xffffffff;
|
---|
3043 | cb = 4;
|
---|
3044 | break;
|
---|
3045 | default:
|
---|
3046 | AssertFailedReturn(VERR_INTERNAL_ERROR_4); /* shall not happen. */
|
---|
3047 | }
|
---|
3048 | /* cross-register access, see corresponding comment in hdaMMIORead */
|
---|
3049 | uint32_t shift = (g_aHdaRegMap[idxRegDsc].offset - offReg) % sizeof(uint32_t) * 8;
|
---|
3050 | mask <<= shift;
|
---|
3051 | u32NewValue <<= shift;
|
---|
3052 | u32NewValue &= mask;
|
---|
3053 | u32NewValue |= (u32CurValue & ~mask);
|
---|
3054 |
|
---|
3055 | rc = g_aHdaRegMap[idxRegDsc].pfnWrite(pThis, idxRegDsc, u32NewValue);
|
---|
3056 | LogFunc(("write %s:(%x) %x => %x\n", g_aHdaRegMap[idxRegDsc].abbrev, u32NewValue,
|
---|
3057 | u32CurValue, pThis->au32Regs[idxRegMem]));
|
---|
3058 | }
|
---|
3059 | else
|
---|
3060 | rc = VINF_SUCCESS;
|
---|
3061 |
|
---|
3062 | LogFunc(("@%#05x %#x -> %#x\n", offRegLog, u32LogOldValue,
|
---|
3063 | idxRegLog != -1 ? pThis->au32Regs[idxRegLog] : UINT32_MAX));
|
---|
3064 | #endif
|
---|
3065 | return rc;
|
---|
3066 | }
|
---|
3067 |
|
---|
3068 |
|
---|
3069 | /* PCI callback. */
|
---|
3070 |
|
---|
3071 | #ifdef IN_RING3
|
---|
3072 | /**
|
---|
3073 | * @callback_method_impl{FNPCIIOREGIONMAP}
|
---|
3074 | */
|
---|
3075 | static DECLCALLBACK(int) hdaPciIoRegionMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb,
|
---|
3076 | PCIADDRESSSPACE enmType)
|
---|
3077 | {
|
---|
3078 | PPDMDEVINS pDevIns = pPciDev->pDevIns;
|
---|
3079 | PHDASTATE pThis = RT_FROM_MEMBER(pPciDev, HDASTATE, PciDev);
|
---|
3080 | RTIOPORT Port = (RTIOPORT)GCPhysAddress;
|
---|
3081 | int rc;
|
---|
3082 |
|
---|
3083 | /*
|
---|
3084 | * 18.2 of the ICH6 datasheet defines the valid access widths as byte, word, and double word.
|
---|
3085 | *
|
---|
3086 | * Let IOM talk DWORDs when reading, saves a lot of complications. On
|
---|
3087 | * writing though, we have to do it all ourselves because of sideeffects.
|
---|
3088 | */
|
---|
3089 | Assert(enmType == PCI_ADDRESS_SPACE_MEM);
|
---|
3090 | rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, NULL /*pvUser*/,
|
---|
3091 | #ifdef NEW_READ_CODE
|
---|
3092 | IOMMMIO_FLAGS_READ_DWORD |
|
---|
3093 | #else
|
---|
3094 | IOMMMIO_FLAGS_READ_PASSTHRU |
|
---|
3095 | #endif
|
---|
3096 | IOMMMIO_FLAGS_WRITE_PASSTHRU,
|
---|
3097 | hdaMMIOWrite, hdaMMIORead, "HDA");
|
---|
3098 |
|
---|
3099 | if (RT_FAILURE(rc))
|
---|
3100 | return rc;
|
---|
3101 |
|
---|
3102 | if (pThis->fR0Enabled)
|
---|
3103 | {
|
---|
3104 | rc = PDMDevHlpMMIORegisterR0(pDevIns, GCPhysAddress, cb, NIL_RTR0PTR /*pvUser*/,
|
---|
3105 | "hdaMMIOWrite", "hdaMMIORead");
|
---|
3106 | if (RT_FAILURE(rc))
|
---|
3107 | return rc;
|
---|
3108 | }
|
---|
3109 |
|
---|
3110 | if (pThis->fRCEnabled)
|
---|
3111 | {
|
---|
3112 | rc = PDMDevHlpMMIORegisterRC(pDevIns, GCPhysAddress, cb, NIL_RTRCPTR /*pvUser*/,
|
---|
3113 | "hdaMMIOWrite", "hdaMMIORead");
|
---|
3114 | if (RT_FAILURE(rc))
|
---|
3115 | return rc;
|
---|
3116 | }
|
---|
3117 |
|
---|
3118 | pThis->MMIOBaseAddr = GCPhysAddress;
|
---|
3119 | return VINF_SUCCESS;
|
---|
3120 | }
|
---|
3121 |
|
---|
3122 |
|
---|
3123 | /* Saved state callbacks. */
|
---|
3124 |
|
---|
3125 | /**
|
---|
3126 | * @callback_method_impl{FNSSMDEVSAVEEXEC}
|
---|
3127 | */
|
---|
3128 | static DECLCALLBACK(int) hdaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
3129 | {
|
---|
3130 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3131 |
|
---|
3132 | /* Save Codec nodes states */
|
---|
3133 | hdaCodecSaveState(pThis->pCodec, pSSM);
|
---|
3134 |
|
---|
3135 | /* Save MMIO registers */
|
---|
3136 | AssertCompile(RT_ELEMENTS(pThis->au32Regs) >= HDA_NREGS_SAVED);
|
---|
3137 | SSMR3PutU32(pSSM, RT_ELEMENTS(pThis->au32Regs));
|
---|
3138 | SSMR3PutMem(pSSM, pThis->au32Regs, sizeof(pThis->au32Regs));
|
---|
3139 |
|
---|
3140 | /* Save HDA dma counters */
|
---|
3141 | SSMR3PutStructEx(pSSM, &pThis->StOutBdle, sizeof(pThis->StOutBdle), 0 /*fFlags*/, g_aHdaBDLEDescFields, NULL);
|
---|
3142 | SSMR3PutStructEx(pSSM, &pThis->StMicBdle, sizeof(pThis->StMicBdle), 0 /*fFlags*/, g_aHdaBDLEDescFields, NULL);
|
---|
3143 | SSMR3PutStructEx(pSSM, &pThis->StInBdle, sizeof(pThis->StInBdle), 0 /*fFlags*/, g_aHdaBDLEDescFields, NULL);
|
---|
3144 | return VINF_SUCCESS;
|
---|
3145 | }
|
---|
3146 |
|
---|
3147 |
|
---|
3148 | /**
|
---|
3149 | * @callback_method_impl{FNSSMDEVLOADEXEC}
|
---|
3150 | */
|
---|
3151 | static DECLCALLBACK(int) hdaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
3152 | {
|
---|
3153 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3154 |
|
---|
3155 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
3156 |
|
---|
3157 | /*
|
---|
3158 | * Load Codec nodes states.
|
---|
3159 | */
|
---|
3160 | int rc = hdaCodecLoadState(pThis->pCodec, pSSM, uVersion);
|
---|
3161 | if (RT_FAILURE(rc))
|
---|
3162 | return rc;
|
---|
3163 |
|
---|
3164 | /*
|
---|
3165 | * Load MMIO registers.
|
---|
3166 | */
|
---|
3167 | uint32_t cRegs;
|
---|
3168 | switch (uVersion)
|
---|
3169 | {
|
---|
3170 | case HDA_SSM_VERSION_1:
|
---|
3171 | /* Starting with r71199, we would save 112 instead of 113
|
---|
3172 | registers due to some code cleanups. This only affected trunk
|
---|
3173 | builds in the 4.1 development period. */
|
---|
3174 | cRegs = 113;
|
---|
3175 | if (SSMR3HandleRevision(pSSM) >= 71199)
|
---|
3176 | {
|
---|
3177 | uint32_t uVer = SSMR3HandleVersion(pSSM);
|
---|
3178 | if ( VBOX_FULL_VERSION_GET_MAJOR(uVer) == 4
|
---|
3179 | && VBOX_FULL_VERSION_GET_MINOR(uVer) == 0
|
---|
3180 | && VBOX_FULL_VERSION_GET_BUILD(uVer) >= 51)
|
---|
3181 | cRegs = 112;
|
---|
3182 | }
|
---|
3183 | break;
|
---|
3184 |
|
---|
3185 | case HDA_SSM_VERSION_2:
|
---|
3186 | case HDA_SSM_VERSION_3:
|
---|
3187 | cRegs = 112;
|
---|
3188 | AssertCompile(RT_ELEMENTS(pThis->au32Regs) >= HDA_NREGS_SAVED);
|
---|
3189 | break;
|
---|
3190 |
|
---|
3191 | case HDA_SSM_VERSION:
|
---|
3192 | rc = SSMR3GetU32(pSSM, &cRegs); AssertRCReturn(rc, rc);
|
---|
3193 | if (cRegs != RT_ELEMENTS(pThis->au32Regs))
|
---|
3194 | LogRel(("HDA: SSM version cRegs is %RU32, expected %RU32\n", cRegs, RT_ELEMENTS(pThis->au32Regs)));
|
---|
3195 | break;
|
---|
3196 |
|
---|
3197 | default:
|
---|
3198 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
3199 | }
|
---|
3200 |
|
---|
3201 | if (cRegs >= RT_ELEMENTS(pThis->au32Regs))
|
---|
3202 | {
|
---|
3203 | SSMR3GetMem(pSSM, pThis->au32Regs, sizeof(pThis->au32Regs));
|
---|
3204 | SSMR3Skip(pSSM, sizeof(uint32_t) * (cRegs - RT_ELEMENTS(pThis->au32Regs)));
|
---|
3205 | }
|
---|
3206 | else
|
---|
3207 | SSMR3GetMem(pSSM, pThis->au32Regs, sizeof(uint32_t) * cRegs);
|
---|
3208 |
|
---|
3209 | /*
|
---|
3210 | * Load HDA DMA counters.
|
---|
3211 | */
|
---|
3212 | uint32_t fFlags = uVersion <= HDA_SSM_VERSION_2 ? SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED : 0;
|
---|
3213 | PCSSMFIELD paFields = uVersion <= HDA_SSM_VERSION_2 ? g_aHdaBDLEDescFieldsOld : g_aHdaBDLEDescFields;
|
---|
3214 | rc = SSMR3GetStructEx(pSSM, &pThis->StOutBdle, sizeof(pThis->StOutBdle), fFlags, paFields, NULL);
|
---|
3215 | AssertRCReturn(rc, rc);
|
---|
3216 | rc = SSMR3GetStructEx(pSSM, &pThis->StMicBdle, sizeof(pThis->StMicBdle), fFlags, paFields, NULL);
|
---|
3217 | AssertRCReturn(rc, rc);
|
---|
3218 | rc = SSMR3GetStructEx(pSSM, &pThis->StInBdle, sizeof(pThis->StInBdle), fFlags, paFields, NULL);
|
---|
3219 | AssertRCReturn(rc, rc);
|
---|
3220 |
|
---|
3221 | /*
|
---|
3222 | * Update stuff after the state changes.
|
---|
3223 | */
|
---|
3224 | bool fEnableIn = RT_BOOL(SDCTL(pThis, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
3225 | #ifdef VBOX_WITH_HDA_MIC_IN
|
---|
3226 | bool fEnableMicIn = RT_BOOL(SDCTL(pThis, 2) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
3227 | #else
|
---|
3228 | bool fEnableMicIn = fEnableIn; /* Mic In == Line In */
|
---|
3229 | #endif
|
---|
3230 | bool fEnableOut = RT_BOOL(SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
3231 |
|
---|
3232 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
3233 | PHDADRIVER pDrv;
|
---|
3234 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
3235 | {
|
---|
3236 | rc = pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->LineIn.pStrmIn, fEnableIn);
|
---|
3237 | if (RT_FAILURE(rc))
|
---|
3238 | break;
|
---|
3239 | rc = pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->MicIn.pStrmIn, fEnableMicIn);
|
---|
3240 | if (RT_FAILURE(rc))
|
---|
3241 | break;
|
---|
3242 | rc = pDrv->pConnector->pfnEnableOut(pDrv->pConnector, pDrv->Out.pStrmOut, fEnableOut);
|
---|
3243 | if (RT_FAILURE(rc))
|
---|
3244 | break;
|
---|
3245 | }
|
---|
3246 | #else
|
---|
3247 | AUD_set_active_in(pThis->pCodec->SwVoiceIn, SDCTL(pThis, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
3248 | AUD_set_active_out(pThis->pCodec->SwVoiceOut, SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
3249 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
3250 |
|
---|
3251 | if (RT_SUCCESS(rc))
|
---|
3252 | {
|
---|
3253 | pThis->u64CORBBase = RT_MAKE_U64(HDA_REG(pThis, CORBLBASE), HDA_REG(pThis, CORBUBASE));
|
---|
3254 | pThis->u64RIRBBase = RT_MAKE_U64(HDA_REG(pThis, RIRBLBASE), HDA_REG(pThis, RIRBUBASE));
|
---|
3255 | pThis->u64DPBase = RT_MAKE_U64(HDA_REG(pThis, DPLBASE), HDA_REG(pThis, DPUBASE));
|
---|
3256 | }
|
---|
3257 |
|
---|
3258 | LogFlowFuncLeaveRC(rc);
|
---|
3259 | return rc;
|
---|
3260 | }
|
---|
3261 |
|
---|
3262 |
|
---|
3263 | /* Debug and log type formatters. */
|
---|
3264 |
|
---|
3265 | /**
|
---|
3266 | * @callback_method_impl{FNRTSTRFORMATTYPE}
|
---|
3267 | */
|
---|
3268 | static DECLCALLBACK(size_t)
|
---|
3269 | hdaFormatStrmCtl(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
|
---|
3270 | const char *pszType, void const *pvValue,
|
---|
3271 | int cchWidth, int cchPrecision, unsigned fFlags,
|
---|
3272 | void *pvUser)
|
---|
3273 | {
|
---|
3274 | uint32_t sdCtl = (uint32_t)(uintptr_t)pvValue;
|
---|
3275 | return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0,
|
---|
3276 | "SDCTL(raw: %#x, strm:%#x, dir:%RTbool, tp:%RTbool strip:%x, deie:%RTbool, ioce:%RTbool, run:%RTbool, srst:%RTbool)",
|
---|
3277 | sdCtl,
|
---|
3278 | (sdCtl & HDA_REG_FIELD_MASK(SDCTL, NUM)) >> HDA_SDCTL_NUM_SHIFT,
|
---|
3279 | RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DIR)),
|
---|
3280 | RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, TP)),
|
---|
3281 | (sdCtl & HDA_REG_FIELD_MASK(SDCTL, STRIPE)) >> HDA_SDCTL_STRIPE_SHIFT,
|
---|
3282 | RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DEIE)),
|
---|
3283 | RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, ICE)),
|
---|
3284 | RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)),
|
---|
3285 | RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)));
|
---|
3286 | }
|
---|
3287 |
|
---|
3288 | /**
|
---|
3289 | * @callback_method_impl{FNRTSTRFORMATTYPE}
|
---|
3290 | */
|
---|
3291 | static DECLCALLBACK(size_t)
|
---|
3292 | hdaFormatStrmFifos(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
|
---|
3293 | const char *pszType, void const *pvValue,
|
---|
3294 | int cchWidth, int cchPrecision, unsigned fFlags,
|
---|
3295 | void *pvUser)
|
---|
3296 | {
|
---|
3297 | uint32_t uSdFifos = (uint32_t)(uintptr_t)pvValue;
|
---|
3298 | uint32_t cb;
|
---|
3299 | switch (uSdFifos)
|
---|
3300 | {
|
---|
3301 | case HDA_SDONFIFO_16B: cb = 16; break;
|
---|
3302 | case HDA_SDONFIFO_32B: cb = 32; break;
|
---|
3303 | case HDA_SDONFIFO_64B: cb = 64; break;
|
---|
3304 | case HDA_SDONFIFO_128B: cb = 128; break;
|
---|
3305 | case HDA_SDONFIFO_192B: cb = 192; break;
|
---|
3306 | case HDA_SDONFIFO_256B: cb = 256; break;
|
---|
3307 | case HDA_SDINFIFO_120B: cb = 120; break;
|
---|
3308 | case HDA_SDINFIFO_160B: cb = 160; break;
|
---|
3309 | default: cb = 0; break;
|
---|
3310 | }
|
---|
3311 | return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOS(raw: %#x, sdfifos:%u B)", uSdFifos, cb);
|
---|
3312 | }
|
---|
3313 |
|
---|
3314 | /**
|
---|
3315 | * @callback_method_impl{FNRTSTRFORMATTYPE}
|
---|
3316 | */
|
---|
3317 | static DECLCALLBACK(size_t)
|
---|
3318 | hdaFormatStrmFifow(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
|
---|
3319 | const char *pszType, void const *pvValue,
|
---|
3320 | int cchWidth, int cchPrecision, unsigned fFlags,
|
---|
3321 | void *pvUser)
|
---|
3322 | {
|
---|
3323 | uint32_t uSdFifos = (uint32_t)(uintptr_t)pvValue;
|
---|
3324 | uint32_t cb;
|
---|
3325 | switch (uSdFifos)
|
---|
3326 | {
|
---|
3327 | case HDA_SDFIFOW_8B: cb = 8; break;
|
---|
3328 | case HDA_SDFIFOW_16B: cb = 16; break;
|
---|
3329 | case HDA_SDFIFOW_32B: cb = 32; break;
|
---|
3330 | default: cb = 0; break;
|
---|
3331 | }
|
---|
3332 | return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOW(raw: %#0x, sdfifow:%d B)", uSdFifos, cb);
|
---|
3333 | }
|
---|
3334 |
|
---|
3335 | /**
|
---|
3336 | * @callback_method_impl{FNRTSTRFORMATTYPE}
|
---|
3337 | */
|
---|
3338 | static DECLCALLBACK(size_t)
|
---|
3339 | hdaFormatStrmSts(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
|
---|
3340 | const char *pszType, void const *pvValue,
|
---|
3341 | int cchWidth, int cchPrecision, unsigned fFlags,
|
---|
3342 | void *pvUser)
|
---|
3343 | {
|
---|
3344 | uint32_t uSdSts = (uint32_t)(uintptr_t)pvValue;
|
---|
3345 | return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0,
|
---|
3346 | "SDSTS(raw: %#0x, fifordy:%RTbool, dese:%RTbool, fifoe:%RTbool, bcis:%RTbool)",
|
---|
3347 | uSdSts,
|
---|
3348 | RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY)),
|
---|
3349 | RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE)),
|
---|
3350 | RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE)),
|
---|
3351 | RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)));
|
---|
3352 | }
|
---|
3353 |
|
---|
3354 |
|
---|
3355 | static int hdaLookUpRegisterByName(PHDASTATE pThis, const char *pszArgs)
|
---|
3356 | {
|
---|
3357 | int iReg = 0;
|
---|
3358 | for (; iReg < HDA_NREGS; ++iReg)
|
---|
3359 | if (!RTStrICmp(g_aHdaRegMap[iReg].abbrev, pszArgs))
|
---|
3360 | return iReg;
|
---|
3361 | return -1;
|
---|
3362 | }
|
---|
3363 |
|
---|
3364 |
|
---|
3365 | static void hdaDbgPrintRegister(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaIndex)
|
---|
3366 | {
|
---|
3367 | Assert( pThis
|
---|
3368 | && iHdaIndex >= 0
|
---|
3369 | && iHdaIndex < HDA_NREGS);
|
---|
3370 | pHlp->pfnPrintf(pHlp, "%s: 0x%x\n", g_aHdaRegMap[iHdaIndex].abbrev, pThis->au32Regs[g_aHdaRegMap[iHdaIndex].mem_idx]);
|
---|
3371 | }
|
---|
3372 |
|
---|
3373 |
|
---|
3374 | /**
|
---|
3375 | * @callback_method_impl{FNDBGFHANDLERDEV}
|
---|
3376 | */
|
---|
3377 | static DECLCALLBACK(void) hdaInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
3378 | {
|
---|
3379 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3380 | int iHdaRegisterIndex = hdaLookUpRegisterByName(pThis, pszArgs);
|
---|
3381 | if (iHdaRegisterIndex != -1)
|
---|
3382 | hdaDbgPrintRegister(pThis, pHlp, iHdaRegisterIndex);
|
---|
3383 | else
|
---|
3384 | for(iHdaRegisterIndex = 0; (unsigned int)iHdaRegisterIndex < HDA_NREGS; ++iHdaRegisterIndex)
|
---|
3385 | hdaDbgPrintRegister(pThis, pHlp, iHdaRegisterIndex);
|
---|
3386 | }
|
---|
3387 |
|
---|
3388 |
|
---|
3389 | static void hdaDbgPrintStream(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaStrmIndex)
|
---|
3390 | {
|
---|
3391 | Assert( pThis
|
---|
3392 | && iHdaStrmIndex >= 0
|
---|
3393 | && iHdaStrmIndex < 7);
|
---|
3394 | pHlp->pfnPrintf(pHlp, "Dump of %d HDA Stream:\n", iHdaStrmIndex);
|
---|
3395 | pHlp->pfnPrintf(pHlp, "SD%dCTL: %R[sdctl]\n", iHdaStrmIndex, HDA_STREAM_REG(pThis, CTL, iHdaStrmIndex));
|
---|
3396 | pHlp->pfnPrintf(pHlp, "SD%dCTS: %R[sdsts]\n", iHdaStrmIndex, HDA_STREAM_REG(pThis, STS, iHdaStrmIndex));
|
---|
3397 | pHlp->pfnPrintf(pHlp, "SD%dFIFOS: %R[sdfifos]\n", iHdaStrmIndex, HDA_STREAM_REG(pThis, FIFOS, iHdaStrmIndex));
|
---|
3398 | pHlp->pfnPrintf(pHlp, "SD%dFIFOW: %R[sdfifow]\n", iHdaStrmIndex, HDA_STREAM_REG(pThis, FIFOW, iHdaStrmIndex));
|
---|
3399 | }
|
---|
3400 |
|
---|
3401 |
|
---|
3402 | static int hdaLookUpStreamIndex(PHDASTATE pThis, const char *pszArgs)
|
---|
3403 | {
|
---|
3404 | /* todo: add args parsing */
|
---|
3405 | return -1;
|
---|
3406 | }
|
---|
3407 |
|
---|
3408 |
|
---|
3409 | /**
|
---|
3410 | * @callback_method_impl{FNDBGFHANDLERDEV}
|
---|
3411 | */
|
---|
3412 | static DECLCALLBACK(void) hdaInfoStream(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
3413 | {
|
---|
3414 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3415 | int iHdaStrmIndex = hdaLookUpStreamIndex(pThis, pszArgs);
|
---|
3416 | if (iHdaStrmIndex != -1)
|
---|
3417 | hdaDbgPrintStream(pThis, pHlp, iHdaStrmIndex);
|
---|
3418 | else
|
---|
3419 | for(iHdaStrmIndex = 0; iHdaStrmIndex < 7; ++iHdaStrmIndex)
|
---|
3420 | hdaDbgPrintStream(pThis, pHlp, iHdaStrmIndex);
|
---|
3421 | }
|
---|
3422 |
|
---|
3423 |
|
---|
3424 | /**
|
---|
3425 | * @callback_method_impl{FNDBGFHANDLERDEV}
|
---|
3426 | */
|
---|
3427 | static DECLCALLBACK(void) hdaInfoCodecNodes(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
3428 | {
|
---|
3429 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3430 |
|
---|
3431 | if (pThis->pCodec->pfnCodecDbgListNodes)
|
---|
3432 | pThis->pCodec->pfnCodecDbgListNodes(pThis->pCodec, pHlp, pszArgs);
|
---|
3433 | else
|
---|
3434 | pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback\n");
|
---|
3435 | }
|
---|
3436 |
|
---|
3437 |
|
---|
3438 | /**
|
---|
3439 | * @callback_method_impl{FNDBGFHANDLERDEV}
|
---|
3440 | */
|
---|
3441 | static DECLCALLBACK(void) hdaInfoCodecSelector(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
|
---|
3442 | {
|
---|
3443 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3444 |
|
---|
3445 | if (pThis->pCodec->pfnCodecDbgSelector)
|
---|
3446 | pThis->pCodec->pfnCodecDbgSelector(pThis->pCodec, pHlp, pszArgs);
|
---|
3447 | else
|
---|
3448 | pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback\n");
|
---|
3449 | }
|
---|
3450 |
|
---|
3451 |
|
---|
3452 | /* PDMIBASE */
|
---|
3453 |
|
---|
3454 | /**
|
---|
3455 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
3456 | */
|
---|
3457 | static DECLCALLBACK(void *) hdaQueryInterface(struct PDMIBASE *pInterface, const char *pszIID)
|
---|
3458 | {
|
---|
3459 | PHDASTATE pThis = RT_FROM_MEMBER(pInterface, HDASTATE, IBase);
|
---|
3460 | Assert(&pThis->IBase == pInterface);
|
---|
3461 |
|
---|
3462 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
|
---|
3463 | return NULL;
|
---|
3464 | }
|
---|
3465 |
|
---|
3466 |
|
---|
3467 | /* PDMDEVREG */
|
---|
3468 |
|
---|
3469 | /**
|
---|
3470 | * Reset notification.
|
---|
3471 | *
|
---|
3472 | * @returns VBox status.
|
---|
3473 | * @param pDevIns The device instance data.
|
---|
3474 | *
|
---|
3475 | * @remark The original sources didn't install a reset handler, but it seems to
|
---|
3476 | * make sense to me so we'll do it.
|
---|
3477 | */
|
---|
3478 | static DECLCALLBACK(void) hdaReset(PPDMDEVINS pDevIns)
|
---|
3479 | {
|
---|
3480 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3481 | HDA_REG(pThis, GCAP) = HDA_MAKE_GCAP(4,4,0,0,1); /* see 6.2.1 */
|
---|
3482 | HDA_REG(pThis, VMIN) = 0x00; /* see 6.2.2 */
|
---|
3483 | HDA_REG(pThis, VMAJ) = 0x01; /* see 6.2.3 */
|
---|
3484 | HDA_REG(pThis, OUTPAY) = 0x003C; /* see 6.2.4 */
|
---|
3485 | HDA_REG(pThis, INPAY) = 0x001D; /* see 6.2.5 */
|
---|
3486 | HDA_REG(pThis, CORBSIZE) = 0x42; /* see 6.2.1 */
|
---|
3487 | HDA_REG(pThis, RIRBSIZE) = 0x42; /* see 6.2.1 */
|
---|
3488 | HDA_REG(pThis, CORBRP) = 0x0;
|
---|
3489 | HDA_REG(pThis, RIRBWP) = 0x0;
|
---|
3490 |
|
---|
3491 | LogFunc(("Resetting ...\n"));
|
---|
3492 |
|
---|
3493 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
3494 | /* Stop any audio currently playing. */
|
---|
3495 | PHDADRIVER pDrv;
|
---|
3496 | RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
|
---|
3497 | {
|
---|
3498 | pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->LineIn.pStrmIn, false /* Disable */);
|
---|
3499 | /* Ignore rc. */
|
---|
3500 | pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->MicIn.pStrmIn, false /* Disable */);
|
---|
3501 | /* Ditto. */
|
---|
3502 | pDrv->pConnector->pfnEnableOut(pDrv->pConnector, pDrv->Out.pStrmOut, false /* Disable */);
|
---|
3503 | /* Ditto. */
|
---|
3504 | }
|
---|
3505 | #else
|
---|
3506 | AUD_set_active_in(pThis->pCodec->SwVoiceIn, false);
|
---|
3507 | AUD_set_active_out(pThis->pCodec->SwVoiceOut, false);
|
---|
3508 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
3509 |
|
---|
3510 | pThis->cbCorbBuf = 256 * sizeof(uint32_t);
|
---|
3511 |
|
---|
3512 | if (pThis->pu32CorbBuf)
|
---|
3513 | RT_BZERO(pThis->pu32CorbBuf, pThis->cbCorbBuf);
|
---|
3514 | else
|
---|
3515 | pThis->pu32CorbBuf = (uint32_t *)RTMemAllocZ(pThis->cbCorbBuf);
|
---|
3516 |
|
---|
3517 | pThis->cbRirbBuf = 256 * sizeof(uint64_t);
|
---|
3518 | if (pThis->pu64RirbBuf)
|
---|
3519 | RT_BZERO(pThis->pu64RirbBuf, pThis->cbRirbBuf);
|
---|
3520 | else
|
---|
3521 | pThis->pu64RirbBuf = (uint64_t *)RTMemAllocZ(pThis->cbRirbBuf);
|
---|
3522 |
|
---|
3523 | pThis->u64BaseTS = PDMDevHlpTMTimeVirtGetNano(pDevIns);
|
---|
3524 |
|
---|
3525 | HDABDLEDESC StEmptyBdle;
|
---|
3526 | for (uint8_t u8Strm = 0; u8Strm < 8; ++u8Strm)
|
---|
3527 | {
|
---|
3528 | HDASTREAMTRANSFERDESC StreamDesc;
|
---|
3529 | PHDABDLEDESC pBdle = NULL;
|
---|
3530 | if (u8Strm == 0)
|
---|
3531 | pBdle = &pThis->StInBdle;
|
---|
3532 | # ifdef VBOX_WITH_HDA_MIC_IN
|
---|
3533 | else if (u8Strm == 2)
|
---|
3534 | pBdle = &pThis->StMicBdle;
|
---|
3535 | # endif
|
---|
3536 | else if(u8Strm == 4)
|
---|
3537 | pBdle = &pThis->StOutBdle;
|
---|
3538 | else
|
---|
3539 | {
|
---|
3540 | RT_ZERO(StEmptyBdle);
|
---|
3541 | pBdle = &StEmptyBdle;
|
---|
3542 | }
|
---|
3543 | hdaInitTransferDescriptor(pThis, pBdle, u8Strm, &StreamDesc);
|
---|
3544 | /* hdaStreamReset prevents changing the SRST bit, so we force it to zero here. */
|
---|
3545 | HDA_STREAM_REG(pThis, CTL, u8Strm) = 0;
|
---|
3546 | hdaStreamReset(pThis, pBdle, &StreamDesc, u8Strm);
|
---|
3547 | }
|
---|
3548 |
|
---|
3549 | /* Emulation of codec "wake up" (HDA spec 5.5.1 and 6.5). */
|
---|
3550 | HDA_REG(pThis, STATESTS) = 0x1;
|
---|
3551 |
|
---|
3552 | LogRel(("HDA: Reset\n"));
|
---|
3553 | }
|
---|
3554 |
|
---|
3555 | /**
|
---|
3556 | * @interface_method_impl{PDMDEVREG,pfnDestruct}
|
---|
3557 | */
|
---|
3558 | static DECLCALLBACK(int) hdaDestruct(PPDMDEVINS pDevIns)
|
---|
3559 | {
|
---|
3560 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3561 |
|
---|
3562 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
3563 | PHDADRIVER pDrv;
|
---|
3564 | while (!RTListIsEmpty(&pThis->lstDrv))
|
---|
3565 | {
|
---|
3566 | pDrv = RTListGetFirst(&pThis->lstDrv, HDADRIVER, Node);
|
---|
3567 |
|
---|
3568 | RTListNodeRemove(&pDrv->Node);
|
---|
3569 | RTMemFree(pDrv);
|
---|
3570 | }
|
---|
3571 |
|
---|
3572 | if (pThis->pMixer)
|
---|
3573 | {
|
---|
3574 | audioMixerDestroy(pThis->pMixer);
|
---|
3575 | pThis->pMixer = NULL;
|
---|
3576 | }
|
---|
3577 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
3578 |
|
---|
3579 | if (pThis->pCodec)
|
---|
3580 | {
|
---|
3581 | int rc = hdaCodecDestruct(pThis->pCodec);
|
---|
3582 | AssertRC(rc);
|
---|
3583 |
|
---|
3584 | RTMemFree(pThis->pCodec);
|
---|
3585 | pThis->pCodec = NULL;
|
---|
3586 | }
|
---|
3587 |
|
---|
3588 | RTMemFree(pThis->pu32CorbBuf);
|
---|
3589 | pThis->pu32CorbBuf = NULL;
|
---|
3590 |
|
---|
3591 | RTMemFree(pThis->pu64RirbBuf);
|
---|
3592 | pThis->pu64RirbBuf = NULL;
|
---|
3593 |
|
---|
3594 | return VINF_SUCCESS;
|
---|
3595 | }
|
---|
3596 |
|
---|
3597 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
3598 | /**
|
---|
3599 | * Attach command.
|
---|
3600 | *
|
---|
3601 | * This is called to let the device attach to a driver for a specified LUN
|
---|
3602 | * during runtime. This is not called during VM construction, the device
|
---|
3603 | * constructor have to attach to all the available drivers.
|
---|
3604 | *
|
---|
3605 | * @returns VBox status code.
|
---|
3606 | * @param pDevIns The device instance.
|
---|
3607 | * @param uLUN The logical unit which is being detached.
|
---|
3608 | * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
|
---|
3609 | */
|
---|
3610 | static DECLCALLBACK(int) hdaAttach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
|
---|
3611 | {
|
---|
3612 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3613 |
|
---|
3614 | AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
|
---|
3615 | ("HDA device does not support hotplugging\n"),
|
---|
3616 | VERR_INVALID_PARAMETER);
|
---|
3617 |
|
---|
3618 | /*
|
---|
3619 | * Attach driver.
|
---|
3620 | */
|
---|
3621 | char *pszDesc = NULL;
|
---|
3622 | if (RTStrAPrintf(&pszDesc, "Audio driver port (HDA) for LUN#%u", uLUN) <= 0)
|
---|
3623 | AssertMsgReturn(pszDesc,
|
---|
3624 | ("Not enough memory for HDA driver port description of LUN #%u\n", uLUN),
|
---|
3625 | VERR_NO_MEMORY);
|
---|
3626 |
|
---|
3627 | int rc = PDMDevHlpDriverAttach(pDevIns, uLUN,
|
---|
3628 | &pThis->IBase, &pThis->pDrvBase, pszDesc);
|
---|
3629 | if (RT_SUCCESS(rc))
|
---|
3630 | {
|
---|
3631 | PHDADRIVER pDrv = (PHDADRIVER)RTMemAllocZ(sizeof(HDADRIVER));
|
---|
3632 | if (pDrv)
|
---|
3633 | {
|
---|
3634 | pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIAUDIOCONNECTOR);
|
---|
3635 | AssertMsg(pDrv->pConnector != NULL,
|
---|
3636 | ("Configuration error: LUN#%u has no host audio interface, rc=%Rrc\n",
|
---|
3637 | uLUN, rc));
|
---|
3638 | pDrv->pHDAState = pThis;
|
---|
3639 | pDrv->uLUN = uLUN;
|
---|
3640 |
|
---|
3641 | /*
|
---|
3642 | * For now we always set the driver at LUN 0 as our primary
|
---|
3643 | * host backend. This might change in the future.
|
---|
3644 | */
|
---|
3645 | if (pDrv->uLUN == 0)
|
---|
3646 | pDrv->Flags |= PDMAUDIODRVFLAG_PRIMARY;
|
---|
3647 |
|
---|
3648 | LogFunc(("LUN#%u: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags));
|
---|
3649 |
|
---|
3650 | /* Attach to driver list. */
|
---|
3651 | RTListAppend(&pThis->lstDrv, &pDrv->Node);
|
---|
3652 | }
|
---|
3653 | else
|
---|
3654 | rc = VERR_NO_MEMORY;
|
---|
3655 | }
|
---|
3656 | else if ( rc == VERR_PDM_NO_ATTACHED_DRIVER
|
---|
3657 | || rc == VERR_PDM_CFG_MISSING_DRIVER_NAME)
|
---|
3658 | {
|
---|
3659 | LogFunc(("No attached driver for LUN #%u\n", uLUN));
|
---|
3660 | }
|
---|
3661 | else if (RT_FAILURE(rc))
|
---|
3662 | AssertMsgFailed(("Failed to attach HDA LUN #%u (\"%s\"), rc=%Rrc\n",
|
---|
3663 | uLUN, pszDesc, rc));
|
---|
3664 |
|
---|
3665 | RTStrFree(pszDesc);
|
---|
3666 |
|
---|
3667 | LogFunc(("uLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc));
|
---|
3668 | return rc;
|
---|
3669 | }
|
---|
3670 |
|
---|
3671 | static DECLCALLBACK(void) hdaDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
|
---|
3672 | {
|
---|
3673 | NOREF(pDevIns); NOREF(iLUN); NOREF(fFlags);
|
---|
3674 |
|
---|
3675 | LogFlowFuncEnter();
|
---|
3676 | }
|
---|
3677 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
3678 |
|
---|
3679 | /**
|
---|
3680 | * @interface_method_impl{PDMDEVREG,pfnConstruct}
|
---|
3681 | */
|
---|
3682 | static DECLCALLBACK(int) hdaConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfgHandle)
|
---|
3683 | {
|
---|
3684 | PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
|
---|
3685 | Assert(iInstance == 0);
|
---|
3686 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
3687 |
|
---|
3688 | /*
|
---|
3689 | * Validations.
|
---|
3690 | */
|
---|
3691 | if (!CFGMR3AreValuesValid(pCfgHandle, "R0Enabled\0"
|
---|
3692 | "RCEnabled\0"))
|
---|
3693 | return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
|
---|
3694 | N_ ("Invalid configuration for the Intel HDA device"));
|
---|
3695 |
|
---|
3696 | int rc = CFGMR3QueryBoolDef(pCfgHandle, "RCEnabled", &pThis->fRCEnabled, false);
|
---|
3697 | if (RT_FAILURE(rc))
|
---|
3698 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3699 | N_("HDA configuration error: failed to read RCEnabled as boolean"));
|
---|
3700 | rc = CFGMR3QueryBoolDef(pCfgHandle, "R0Enabled", &pThis->fR0Enabled, false);
|
---|
3701 | if (RT_FAILURE(rc))
|
---|
3702 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3703 | N_("HDA configuration error: failed to read R0Enabled as boolean"));
|
---|
3704 |
|
---|
3705 | /*
|
---|
3706 | * Initialize data (most of it anyway).
|
---|
3707 | */
|
---|
3708 | pThis->pDevInsR3 = pDevIns;
|
---|
3709 | pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
|
---|
3710 | pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
|
---|
3711 | /* IBase */
|
---|
3712 | pThis->IBase.pfnQueryInterface = hdaQueryInterface;
|
---|
3713 |
|
---|
3714 | /* PCI Device */
|
---|
3715 | PCIDevSetVendorId (&pThis->PciDev, HDA_PCI_VENDOR_ID); /* nVidia */
|
---|
3716 | PCIDevSetDeviceId (&pThis->PciDev, HDA_PCI_DEVICE_ID); /* HDA */
|
---|
3717 |
|
---|
3718 | PCIDevSetCommand (&pThis->PciDev, 0x0000); /* 04 rw,ro - pcicmd. */
|
---|
3719 | PCIDevSetStatus (&pThis->PciDev, VBOX_PCI_STATUS_CAP_LIST); /* 06 rwc?,ro? - pcists. */
|
---|
3720 | PCIDevSetRevisionId (&pThis->PciDev, 0x01); /* 08 ro - rid. */
|
---|
3721 | PCIDevSetClassProg (&pThis->PciDev, 0x00); /* 09 ro - pi. */
|
---|
3722 | PCIDevSetClassSub (&pThis->PciDev, 0x03); /* 0a ro - scc; 03 == HDA. */
|
---|
3723 | PCIDevSetClassBase (&pThis->PciDev, 0x04); /* 0b ro - bcc; 04 == multimedia. */
|
---|
3724 | PCIDevSetHeaderType (&pThis->PciDev, 0x00); /* 0e ro - headtyp. */
|
---|
3725 | PCIDevSetBaseAddress (&pThis->PciDev, 0, /* 10 rw - MMIO */
|
---|
3726 | false /* fIoSpace */, false /* fPrefetchable */, true /* f64Bit */, 0x00000000);
|
---|
3727 | PCIDevSetInterruptLine (&pThis->PciDev, 0x00); /* 3c rw. */
|
---|
3728 | PCIDevSetInterruptPin (&pThis->PciDev, 0x01); /* 3d ro - INTA#. */
|
---|
3729 |
|
---|
3730 | #if defined(HDA_AS_PCI_EXPRESS)
|
---|
3731 | PCIDevSetCapabilityList (&pThis->PciDev, 0x80);
|
---|
3732 | #elif defined(VBOX_WITH_MSI_DEVICES)
|
---|
3733 | PCIDevSetCapabilityList (&pThis->PciDev, 0x60);
|
---|
3734 | #else
|
---|
3735 | PCIDevSetCapabilityList (&pThis->PciDev, 0x50); /* ICH6 datasheet 18.1.16 */
|
---|
3736 | #endif
|
---|
3737 |
|
---|
3738 | /// @todo r=michaln: If there are really no PCIDevSetXx for these, the meaning
|
---|
3739 | /// of these values needs to be properly documented!
|
---|
3740 | /* HDCTL off 0x40 bit 0 selects signaling mode (1-HDA, 0 - Ac97) 18.1.19 */
|
---|
3741 | PCIDevSetByte(&pThis->PciDev, 0x40, 0x01);
|
---|
3742 |
|
---|
3743 | /* Power Management */
|
---|
3744 | PCIDevSetByte(&pThis->PciDev, 0x50 + 0, VBOX_PCI_CAP_ID_PM);
|
---|
3745 | PCIDevSetByte(&pThis->PciDev, 0x50 + 1, 0x0); /* next */
|
---|
3746 | PCIDevSetWord(&pThis->PciDev, 0x50 + 2, VBOX_PCI_PM_CAP_DSI | 0x02 /* version, PM1.1 */ );
|
---|
3747 |
|
---|
3748 | #ifdef HDA_AS_PCI_EXPRESS
|
---|
3749 | /* PCI Express */
|
---|
3750 | PCIDevSetByte(&pThis->PciDev, 0x80 + 0, VBOX_PCI_CAP_ID_EXP); /* PCI_Express */
|
---|
3751 | PCIDevSetByte(&pThis->PciDev, 0x80 + 1, 0x60); /* next */
|
---|
3752 | /* Device flags */
|
---|
3753 | PCIDevSetWord(&pThis->PciDev, 0x80 + 2,
|
---|
3754 | /* version */ 0x1 |
|
---|
3755 | /* Root Complex Integrated Endpoint */ (VBOX_PCI_EXP_TYPE_ROOT_INT_EP << 4) |
|
---|
3756 | /* MSI */ (100) << 9 );
|
---|
3757 | /* Device capabilities */
|
---|
3758 | PCIDevSetDWord(&pThis->PciDev, 0x80 + 4, VBOX_PCI_EXP_DEVCAP_FLRESET);
|
---|
3759 | /* Device control */
|
---|
3760 | PCIDevSetWord( &pThis->PciDev, 0x80 + 8, 0);
|
---|
3761 | /* Device status */
|
---|
3762 | PCIDevSetWord( &pThis->PciDev, 0x80 + 10, 0);
|
---|
3763 | /* Link caps */
|
---|
3764 | PCIDevSetDWord(&pThis->PciDev, 0x80 + 12, 0);
|
---|
3765 | /* Link control */
|
---|
3766 | PCIDevSetWord( &pThis->PciDev, 0x80 + 16, 0);
|
---|
3767 | /* Link status */
|
---|
3768 | PCIDevSetWord( &pThis->PciDev, 0x80 + 18, 0);
|
---|
3769 | /* Slot capabilities */
|
---|
3770 | PCIDevSetDWord(&pThis->PciDev, 0x80 + 20, 0);
|
---|
3771 | /* Slot control */
|
---|
3772 | PCIDevSetWord( &pThis->PciDev, 0x80 + 24, 0);
|
---|
3773 | /* Slot status */
|
---|
3774 | PCIDevSetWord( &pThis->PciDev, 0x80 + 26, 0);
|
---|
3775 | /* Root control */
|
---|
3776 | PCIDevSetWord( &pThis->PciDev, 0x80 + 28, 0);
|
---|
3777 | /* Root capabilities */
|
---|
3778 | PCIDevSetWord( &pThis->PciDev, 0x80 + 30, 0);
|
---|
3779 | /* Root status */
|
---|
3780 | PCIDevSetDWord(&pThis->PciDev, 0x80 + 32, 0);
|
---|
3781 | /* Device capabilities 2 */
|
---|
3782 | PCIDevSetDWord(&pThis->PciDev, 0x80 + 36, 0);
|
---|
3783 | /* Device control 2 */
|
---|
3784 | PCIDevSetQWord(&pThis->PciDev, 0x80 + 40, 0);
|
---|
3785 | /* Link control 2 */
|
---|
3786 | PCIDevSetQWord(&pThis->PciDev, 0x80 + 48, 0);
|
---|
3787 | /* Slot control 2 */
|
---|
3788 | PCIDevSetWord( &pThis->PciDev, 0x80 + 56, 0);
|
---|
3789 | #endif
|
---|
3790 |
|
---|
3791 | /*
|
---|
3792 | * Register the PCI device.
|
---|
3793 | */
|
---|
3794 | rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev);
|
---|
3795 | if (RT_FAILURE(rc))
|
---|
3796 | return rc;
|
---|
3797 |
|
---|
3798 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM, hdaPciIoRegionMap);
|
---|
3799 | if (RT_FAILURE(rc))
|
---|
3800 | return rc;
|
---|
3801 |
|
---|
3802 | #ifdef VBOX_WITH_MSI_DEVICES
|
---|
3803 | PDMMSIREG MsiReg;
|
---|
3804 | RT_ZERO(MsiReg);
|
---|
3805 | MsiReg.cMsiVectors = 1;
|
---|
3806 | MsiReg.iMsiCapOffset = 0x60;
|
---|
3807 | MsiReg.iMsiNextOffset = 0x50;
|
---|
3808 | rc = PDMDevHlpPCIRegisterMsi(pDevIns, &MsiReg);
|
---|
3809 | if (RT_FAILURE(rc))
|
---|
3810 | {
|
---|
3811 | /* That's OK, we can work without MSI */
|
---|
3812 | PCIDevSetCapabilityList(&pThis->PciDev, 0x50);
|
---|
3813 | }
|
---|
3814 | #endif
|
---|
3815 |
|
---|
3816 | rc = PDMDevHlpSSMRegister(pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hdaSaveExec, hdaLoadExec);
|
---|
3817 | if (RT_FAILURE(rc))
|
---|
3818 | return rc;
|
---|
3819 |
|
---|
3820 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
3821 | RTListInit(&pThis->lstDrv);
|
---|
3822 |
|
---|
3823 | uint8_t uLUN;
|
---|
3824 | for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
|
---|
3825 | {
|
---|
3826 | LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN));
|
---|
3827 | rc = hdaAttach(pDevIns, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);
|
---|
3828 | if (RT_FAILURE(rc))
|
---|
3829 | {
|
---|
3830 | if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
3831 | rc = VINF_SUCCESS;
|
---|
3832 |
|
---|
3833 | break;
|
---|
3834 | }
|
---|
3835 |
|
---|
3836 | uLUN++;
|
---|
3837 | }
|
---|
3838 |
|
---|
3839 | LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc));
|
---|
3840 |
|
---|
3841 | if (RT_SUCCESS(rc))
|
---|
3842 | {
|
---|
3843 | rc = audioMixerCreate("HDA Mixer", 0 /* uFlags */, &pThis->pMixer);
|
---|
3844 | if (RT_SUCCESS(rc))
|
---|
3845 | {
|
---|
3846 | /* Set a default audio format for our mixer. */
|
---|
3847 | PDMAUDIOSTREAMCFG streamCfg;
|
---|
3848 | streamCfg.uHz = 41000;
|
---|
3849 | streamCfg.cChannels = 2;
|
---|
3850 | streamCfg.enmFormat = AUD_FMT_S16;
|
---|
3851 | streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
|
---|
3852 |
|
---|
3853 | rc = audioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
|
---|
3854 | AssertRC(rc);
|
---|
3855 |
|
---|
3856 | /* Add all required audio sinks. */
|
---|
3857 | rc = audioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
|
---|
3858 | AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput);
|
---|
3859 | AssertRC(rc);
|
---|
3860 |
|
---|
3861 | rc = audioMixerAddSink(pThis->pMixer, "[Recording] Line In",
|
---|
3862 | AUDMIXSINKDIR_INPUT, &pThis->pSinkLineIn);
|
---|
3863 | AssertRC(rc);
|
---|
3864 |
|
---|
3865 | rc = audioMixerAddSink(pThis->pMixer, "[Recording] Microphone In",
|
---|
3866 | AUDMIXSINKDIR_INPUT, &pThis->pSinkMicIn);
|
---|
3867 | AssertRC(rc);
|
---|
3868 | }
|
---|
3869 | }
|
---|
3870 |
|
---|
3871 | LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc));
|
---|
3872 | #else
|
---|
3873 | /*
|
---|
3874 | * Attach driver.
|
---|
3875 | */
|
---|
3876 | rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port");
|
---|
3877 | if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
3878 | Log(("hda: No attached driver!\n"));
|
---|
3879 | else if (RT_FAILURE(rc))
|
---|
3880 | {
|
---|
3881 | AssertMsgFailed(("Failed to attach Intel HDA LUN #0! rc=%Rrc\n", rc));
|
---|
3882 | return rc;
|
---|
3883 | }
|
---|
3884 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
3885 |
|
---|
3886 | if (RT_SUCCESS(rc))
|
---|
3887 | {
|
---|
3888 | /* Construct codec. */
|
---|
3889 | pThis->pCodec = (PHDACODEC)RTMemAllocZ(sizeof(HDACODEC));
|
---|
3890 | if (!pThis->pCodec)
|
---|
3891 | return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Out of memory allocating HDA codec state"));
|
---|
3892 |
|
---|
3893 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
3894 | /* Audio driver callbacks for multiplexing. */
|
---|
3895 | pThis->pCodec->pfnCloseIn = hdaCloseIn;
|
---|
3896 | pThis->pCodec->pfnCloseOut = hdaCloseOut;
|
---|
3897 | pThis->pCodec->pfnOpenIn = hdaOpenIn;
|
---|
3898 | pThis->pCodec->pfnOpenOut = hdaOpenOut;
|
---|
3899 | pThis->pCodec->pfnSetVolume = hdaSetVolume;
|
---|
3900 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
3901 |
|
---|
3902 | pThis->pCodec->pHDAState = pThis; /* Assign HDA controller state to codec. */
|
---|
3903 |
|
---|
3904 | /* Construct the codec. */
|
---|
3905 | rc = hdaCodecConstruct(pDevIns, pThis->pCodec, 0 /* Codec index */, pCfgHandle);
|
---|
3906 | if (RT_FAILURE(rc))
|
---|
3907 | AssertRCReturn(rc, rc);
|
---|
3908 |
|
---|
3909 | /* ICH6 datasheet defines 0 values for SVID and SID (18.1.14-15), which together with values returned for
|
---|
3910 | verb F20 should provide device/codec recognition. */
|
---|
3911 | Assert(pThis->pCodec->u16VendorId);
|
---|
3912 | Assert(pThis->pCodec->u16DeviceId);
|
---|
3913 | PCIDevSetSubSystemVendorId(&pThis->PciDev, pThis->pCodec->u16VendorId); /* 2c ro - intel.) */
|
---|
3914 | PCIDevSetSubSystemId( &pThis->PciDev, pThis->pCodec->u16DeviceId); /* 2e ro. */
|
---|
3915 |
|
---|
3916 | #ifndef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
3917 | pThis->pCodec->pfnTransfer = hdaTransfer;
|
---|
3918 | #endif
|
---|
3919 | pThis->pCodec->pfnReset = hdaCodecReset;
|
---|
3920 | }
|
---|
3921 |
|
---|
3922 | if (RT_SUCCESS(rc))
|
---|
3923 | {
|
---|
3924 | hdaReset(pDevIns);
|
---|
3925 |
|
---|
3926 | /*
|
---|
3927 | * 18.2.6,7 defines that values of this registers might be cleared on power on/reset
|
---|
3928 | * hdaReset shouldn't affects these registers.
|
---|
3929 | */
|
---|
3930 | HDA_REG(pThis, WAKEEN) = 0x0;
|
---|
3931 | HDA_REG(pThis, STATESTS) = 0x0;
|
---|
3932 |
|
---|
3933 | /*
|
---|
3934 | * Debug and string formatter types.
|
---|
3935 | */
|
---|
3936 | PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hdaInfo);
|
---|
3937 | PDMDevHlpDBGFInfoRegister(pDevIns, "hdastrm", "HDA stream info. (hdastrm [stream number])", hdaInfoStream);
|
---|
3938 | PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hdaInfoCodecNodes);
|
---|
3939 | PDMDevHlpDBGFInfoRegister(pDevIns, "hdcselector", "HDA codec's selector states [node number].", hdaInfoCodecSelector);
|
---|
3940 |
|
---|
3941 | rc = RTStrFormatTypeRegister("sdctl", hdaFormatStrmCtl, NULL);
|
---|
3942 | AssertRC(rc);
|
---|
3943 | rc = RTStrFormatTypeRegister("sdsts", hdaFormatStrmSts, NULL);
|
---|
3944 | AssertRC(rc);
|
---|
3945 | rc = RTStrFormatTypeRegister("sdfifos", hdaFormatStrmFifos, NULL);
|
---|
3946 | AssertRC(rc);
|
---|
3947 | rc = RTStrFormatTypeRegister("sdfifow", hdaFormatStrmFifow, NULL);
|
---|
3948 | AssertRC(rc);
|
---|
3949 | #if 0
|
---|
3950 | rc = RTStrFormatTypeRegister("sdfmt", printHdaStrmFmt, NULL);
|
---|
3951 | AssertRC(rc);
|
---|
3952 | #endif
|
---|
3953 |
|
---|
3954 | /*
|
---|
3955 | * Some debug assertions.
|
---|
3956 | */
|
---|
3957 | for (unsigned i = 0; i < RT_ELEMENTS(g_aHdaRegMap); i++)
|
---|
3958 | {
|
---|
3959 | struct HDAREGDESC const *pReg = &g_aHdaRegMap[i];
|
---|
3960 | struct HDAREGDESC const *pNextReg = i + 1 < RT_ELEMENTS(g_aHdaRegMap) ? &g_aHdaRegMap[i + 1] : NULL;
|
---|
3961 |
|
---|
3962 | /* binary search order. */
|
---|
3963 | AssertReleaseMsg(!pNextReg || pReg->offset + pReg->size <= pNextReg->offset,
|
---|
3964 | ("[%#x] = {%#x LB %#x} vs. [%#x] = {%#x LB %#x}\n",
|
---|
3965 | i, pReg->offset, pReg->size, i + 1, pNextReg->offset, pNextReg->size));
|
---|
3966 |
|
---|
3967 | /* alignment. */
|
---|
3968 | AssertReleaseMsg( pReg->size == 1
|
---|
3969 | || (pReg->size == 2 && (pReg->offset & 1) == 0)
|
---|
3970 | || (pReg->size == 3 && (pReg->offset & 3) == 0)
|
---|
3971 | || (pReg->size == 4 && (pReg->offset & 3) == 0),
|
---|
3972 | ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size));
|
---|
3973 |
|
---|
3974 | /* registers are packed into dwords - with 3 exceptions with gaps at the end of the dword. */
|
---|
3975 | AssertRelease(((pReg->offset + pReg->size) & 3) == 0 || pNextReg);
|
---|
3976 | if (pReg->offset & 3)
|
---|
3977 | {
|
---|
3978 | struct HDAREGDESC const *pPrevReg = i > 0 ? &g_aHdaRegMap[i - 1] : NULL;
|
---|
3979 | AssertReleaseMsg(pPrevReg, ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size));
|
---|
3980 | if (pPrevReg)
|
---|
3981 | AssertReleaseMsg(pPrevReg->offset + pPrevReg->size == pReg->offset,
|
---|
3982 | ("[%#x] = {%#x LB %#x} vs. [%#x] = {%#x LB %#x}\n",
|
---|
3983 | i - 1, pPrevReg->offset, pPrevReg->size, i + 1, pReg->offset, pReg->size));
|
---|
3984 | }
|
---|
3985 | #if 0
|
---|
3986 | if ((pReg->offset + pReg->size) & 3)
|
---|
3987 | {
|
---|
3988 | AssertReleaseMsg(pNextReg, ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size));
|
---|
3989 | if (pNextReg)
|
---|
3990 | AssertReleaseMsg(pReg->offset + pReg->size == pNextReg->offset,
|
---|
3991 | ("[%#x] = {%#x LB %#x} vs. [%#x] = {%#x LB %#x}\n",
|
---|
3992 | i, pReg->offset, pReg->size, i + 1, pNextReg->offset, pNextReg->size));
|
---|
3993 | }
|
---|
3994 | #endif
|
---|
3995 |
|
---|
3996 | /* The final entry is a full DWORD, no gaps! Allows shortcuts. */
|
---|
3997 | AssertReleaseMsg(pNextReg || ((pReg->offset + pReg->size) & 3) == 0,
|
---|
3998 | ("[%#x] = {%#x LB %#x}\n", i, pReg->offset, pReg->size));
|
---|
3999 | }
|
---|
4000 | }
|
---|
4001 |
|
---|
4002 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
4003 | if (RT_SUCCESS(rc))
|
---|
4004 | {
|
---|
4005 | /* Start the emulation timer. */
|
---|
4006 | rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, hdaTimer, pThis,
|
---|
4007 | TMTIMER_FLAGS_NO_CRIT_SECT, "DevIchHda", &pThis->pTimer);
|
---|
4008 | AssertRCReturn(rc, rc);
|
---|
4009 |
|
---|
4010 | if (RT_SUCCESS(rc))
|
---|
4011 | {
|
---|
4012 | /** @todo Investigate why sounds is getting corrupted if the "ticks" value is too
|
---|
4013 | * low, e.g. "PDMDevHlpTMTimeVirtGetFreq / 200". */
|
---|
4014 | pThis->uTicks = PDMDevHlpTMTimeVirtGetFreq(pDevIns) / 500; /** @todo Make this configurable! */
|
---|
4015 | if (pThis->uTicks < 100)
|
---|
4016 | pThis->uTicks = 100;
|
---|
4017 | LogFunc(("Timer ticks=%RU64\n", pThis->uTicks));
|
---|
4018 |
|
---|
4019 | /* Fire off timer. */
|
---|
4020 | TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTicks);
|
---|
4021 | }
|
---|
4022 | }
|
---|
4023 |
|
---|
4024 | # ifdef VBOX_WITH_STATISTICS
|
---|
4025 | if (RT_SUCCESS(rc))
|
---|
4026 | {
|
---|
4027 | /*
|
---|
4028 | * Register statistics.
|
---|
4029 | */
|
---|
4030 | PDMDevHlpSTAMRegister(pDevIns, &pThis->StatTimer, STAMTYPE_PROFILE, "/Devices/HDA/Timer", STAMUNIT_TICKS_PER_CALL, "Profiling hdaTimer.");
|
---|
4031 | PDMDevHlpSTAMRegister(pDevIns, &pThis->StatBytesRead, STAMTYPE_COUNTER, "/Devices/HDA/BytesRead" , STAMUNIT_BYTES, "Bytes read from HDA emulation.");
|
---|
4032 | PDMDevHlpSTAMRegister(pDevIns, &pThis->StatBytesWritten, STAMTYPE_COUNTER, "/Devices/HDA/BytesWritten", STAMUNIT_BYTES, "Bytes written to HDA emulation.");
|
---|
4033 | }
|
---|
4034 | # endif
|
---|
4035 |
|
---|
4036 | #endif
|
---|
4037 |
|
---|
4038 | LogFlowFuncLeaveRC(rc);
|
---|
4039 | return rc;
|
---|
4040 | }
|
---|
4041 |
|
---|
4042 | /**
|
---|
4043 | * The device registration structure.
|
---|
4044 | */
|
---|
4045 | const PDMDEVREG g_DeviceICH6_HDA =
|
---|
4046 | {
|
---|
4047 | /* u32Version */
|
---|
4048 | PDM_DEVREG_VERSION,
|
---|
4049 | /* szName */
|
---|
4050 | "hda",
|
---|
4051 | /* szRCMod */
|
---|
4052 | "VBoxDDGC.gc",
|
---|
4053 | /* szR0Mod */
|
---|
4054 | "VBoxDDR0.r0",
|
---|
4055 | /* pszDescription */
|
---|
4056 | "Intel HD Audio Controller",
|
---|
4057 | /* fFlags */
|
---|
4058 | PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
|
---|
4059 | /* fClass */
|
---|
4060 | PDM_DEVREG_CLASS_AUDIO,
|
---|
4061 | /* cMaxInstances */
|
---|
4062 | 1,
|
---|
4063 | /* cbInstance */
|
---|
4064 | sizeof(HDASTATE),
|
---|
4065 | /* pfnConstruct */
|
---|
4066 | hdaConstruct,
|
---|
4067 | /* pfnDestruct */
|
---|
4068 | hdaDestruct,
|
---|
4069 | /* pfnRelocate */
|
---|
4070 | NULL,
|
---|
4071 | /* pfnMemSetup */
|
---|
4072 | NULL,
|
---|
4073 | /* pfnPowerOn */
|
---|
4074 | NULL,
|
---|
4075 | /* pfnReset */
|
---|
4076 | hdaReset,
|
---|
4077 | /* pfnSuspend */
|
---|
4078 | NULL,
|
---|
4079 | /* pfnResume */
|
---|
4080 | NULL,
|
---|
4081 | /* pfnAttach */
|
---|
4082 | NULL,
|
---|
4083 | /* pfnDetach */
|
---|
4084 | NULL,
|
---|
4085 | /* pfnQueryInterface. */
|
---|
4086 | NULL,
|
---|
4087 | /* pfnInitComplete */
|
---|
4088 | NULL,
|
---|
4089 | /* pfnPowerOff */
|
---|
4090 | NULL,
|
---|
4091 | /* pfnSoftReset */
|
---|
4092 | NULL,
|
---|
4093 | /* u32VersionEnd */
|
---|
4094 | PDM_DEVREG_VERSION
|
---|
4095 | };
|
---|
4096 |
|
---|
4097 | #endif /* IN_RING3 */
|
---|
4098 | #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
|
---|