1 | /* $Id: DevIchIntelHDA.cpp 34271 2010-11-23 08:03:20Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DevIchIntelHD - VBox ICH Intel HD Audio Controller.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /*******************************************************************************
|
---|
19 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #define LOG_GROUP LOG_GROUP_DEV_AUDIO
|
---|
22 | #include <VBox/pdmdev.h>
|
---|
23 | #include <iprt/assert.h>
|
---|
24 | #include <iprt/uuid.h>
|
---|
25 | #include <iprt/string.h>
|
---|
26 | #include <iprt/mem.h>
|
---|
27 | #include <iprt/asm.h>
|
---|
28 |
|
---|
29 | #include "../Builtins.h"
|
---|
30 |
|
---|
31 | extern "C" {
|
---|
32 | #include "audio.h"
|
---|
33 | }
|
---|
34 | #include "DevCodec.h"
|
---|
35 |
|
---|
36 | #undef LOG_VOICES
|
---|
37 | #ifndef VBOX
|
---|
38 | //#define USE_MIXER
|
---|
39 | #else
|
---|
40 | #define USE_MIXER
|
---|
41 | #endif
|
---|
42 | #define VBOX_WITH_INTEL_HDA
|
---|
43 |
|
---|
44 | #define HDA_SSM_VERSION 1
|
---|
45 | PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
|
---|
46 | PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);
|
---|
47 | static DECLCALLBACK(void) hdaReset (PPDMDEVINS pDevIns);
|
---|
48 |
|
---|
49 | /* Registers */
|
---|
50 | #define HDA_REG_IND_NAME(x) ICH6_HDA_REG_##x
|
---|
51 | #define HDA_REG_FIELD_NAME(reg, x) ICH6_HDA_##reg##_##x
|
---|
52 | #define HDA_REG_FIELD_MASK(reg, x) ICH6_HDA_##reg##_##x##_MASK
|
---|
53 | #define HDA_REG_FIELD_FLAG_MASK(reg, x) RT_BIT(ICH6_HDA_##reg##_##x##_SHIFT)
|
---|
54 | #define HDA_REG_FIELD_SHIFT(reg, x) ICH6_HDA_##reg##_##x##_SHIFT
|
---|
55 | #define HDA_REG_IND(pState, x) ((pState)->au32Regs[(x)])
|
---|
56 | #define HDA_REG(pState, x) (HDA_REG_IND((pState), HDA_REG_IND_NAME(x)))
|
---|
57 | #define HDA_REG_VALUE(pState, reg, val) (HDA_REG((pState),reg) & (((HDA_REG_FIELD_MASK(reg, val))) << (HDA_REG_FIELD_SHIFT(reg, val))))
|
---|
58 | #define HDA_REG_FLAG_VALUE(pState, reg, val) (HDA_REG((pState),reg) & (((HDA_REG_FIELD_FLAG_MASK(reg, val)))))
|
---|
59 | #define HDA_REG_SVALUE(pState, reg, val) (HDA_REG_VALUE(pState, reg, val) >> (HDA_REG_FIELD_SHIFT(reg, val)))
|
---|
60 |
|
---|
61 | #define ICH6_HDA_REG_GCAP 0 /* range 0x00-0x01*/
|
---|
62 | #define GCAP(pState) (HDA_REG((pState), GCAP))
|
---|
63 |
|
---|
64 | #define ICH6_HDA_REG_VMIN 1 /* range 0x02 */
|
---|
65 | #define VMIN(pState) (HDA_REG((pState), VMIN))
|
---|
66 |
|
---|
67 | #define ICH6_HDA_REG_VMAJ 2 /* range 0x03 */
|
---|
68 | #define VMAJ(pState) (HDA_REG((pState), VMAJ))
|
---|
69 |
|
---|
70 | #define ICH6_HDA_REG_OUTPAY 3 /* range 0x04-0x05 */
|
---|
71 | #define OUTPAY(pState) (HDA_REG((pState), OUTPAY))
|
---|
72 |
|
---|
73 | #define ICH6_HDA_REG_INPAY 4 /* range 0x06-0x07 */
|
---|
74 | #define INPAY(pState) (HDA_REG((pState), INPAY))
|
---|
75 |
|
---|
76 | #define ICH6_HDA_REG_GCTL (5)
|
---|
77 | #define ICH6_HDA_GCTL_RST_SHIFT (0)
|
---|
78 | #define ICH6_HDA_GCTL_FSH_SHIFT (1)
|
---|
79 | #define ICH6_HDA_GCTL_UR_SHIFT (8)
|
---|
80 | #define GCTL(pState) (HDA_REG((pState), GCTL))
|
---|
81 |
|
---|
82 | #define ICH6_HDA_REG_WAKEEN 6 /* 0x0C */
|
---|
83 | #define WAKEEN(pState) (HDA_REG((pState), WAKEEN))
|
---|
84 |
|
---|
85 | #define ICH6_HDA_REG_STATESTS 7 /* range 0x0E */
|
---|
86 | #define STATESTS(pState) (HDA_REG((pState), STATESTS))
|
---|
87 | #define ICH6_HDA_STATES_SCSF 0x7
|
---|
88 |
|
---|
89 | #define ICH6_HDA_REG_GSTS 8 /* range 0x10-0x11*/
|
---|
90 | #define ICH6_HDA_GSTS_FSH_SHIFT (1)
|
---|
91 | #define GSTS(pState) (HDA_REG(pState, GSTS))
|
---|
92 |
|
---|
93 | #define ICH6_HDA_REG_INTCTL 9 /* 0x20 */
|
---|
94 | #define ICH6_HDA_INTCTL_GIE_SHIFT 31
|
---|
95 | #define ICH6_HDA_INTCTL_CIE_SHIFT 30
|
---|
96 | #define ICH6_HDA_INTCTL_S0_SHIFT (0)
|
---|
97 | #define ICH6_HDA_INTCTL_S1_SHIFT (1)
|
---|
98 | #define ICH6_HDA_INTCTL_S2_SHIFT (2)
|
---|
99 | #define ICH6_HDA_INTCTL_S3_SHIFT (3)
|
---|
100 | #define ICH6_HDA_INTCTL_S4_SHIFT (4)
|
---|
101 | #define ICH6_HDA_INTCTL_S5_SHIFT (5)
|
---|
102 | #define ICH6_HDA_INTCTL_S6_SHIFT (6)
|
---|
103 | #define ICH6_HDA_INTCTL_S7_SHIFT (7)
|
---|
104 | #define INTCTL(pState) (HDA_REG((pState), INTCTL))
|
---|
105 | #define INTCTL_GIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, GIE))
|
---|
106 | #define INTCTL_CIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, CIE))
|
---|
107 | #define INTCTL_SX(pState, X) (HDA_REG_FLAG_VALUE((pState), INTCTL, S##X))
|
---|
108 | #define INTCTL_SALL(pState) (INTCTL((pState)) & 0xFF)
|
---|
109 |
|
---|
110 | /* Note: The HDA specification defines a SSYNC register at offset 0x38. The
|
---|
111 | * ICH6/ICH9 datahseet defines SSYNC at offset 0x34. The Linux HDA driver matches
|
---|
112 | * the datasheet.
|
---|
113 | */
|
---|
114 | #define ICH6_HDA_REG_SSYNC 12 /* 0x34 */
|
---|
115 | #define SSYNC(pState) (HDA_REG((pState), SSYNC))
|
---|
116 |
|
---|
117 | #define ICH6_HDA_REG_INTSTS 10 /* 0x24 */
|
---|
118 | #define ICH6_HDA_INTSTS_GIS_SHIFT (31)
|
---|
119 | #define ICH6_HDA_INTSTS_CIS_SHIFT (30)
|
---|
120 | #define ICH6_HDA_INTSTS_S0_SHIFT (0)
|
---|
121 | #define ICH6_HDA_INTSTS_S1_SHIFT (1)
|
---|
122 | #define ICH6_HDA_INTSTS_S2_SHIFT (2)
|
---|
123 | #define ICH6_HDA_INTSTS_S3_SHIFT (3)
|
---|
124 | #define ICH6_HDA_INTSTS_S4_SHIFT (4)
|
---|
125 | #define ICH6_HDA_INTSTS_S5_SHIFT (5)
|
---|
126 | #define ICH6_HDA_INTSTS_S6_SHIFT (6)
|
---|
127 | #define ICH6_HDA_INTSTS_S7_SHIFT (7)
|
---|
128 | #define ICH6_HDA_INTSTS_S_MASK(num) RT_BIT(HDA_REG_FIELD_SHIFT(S##num))
|
---|
129 | #define INTSTS(pState) (HDA_REG((pState), INTSTS))
|
---|
130 | #define INTSTS_GIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, GIS)
|
---|
131 | #define INTSTS_CIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, CIS)
|
---|
132 | #define INTSTS_SX(pState, X) (HDA_REG_FLAG_VALUE(pState), INTSTS, S##X)
|
---|
133 | #define INTSTS_SANY(pState) (INTSTS((pState)) & 0xFF)
|
---|
134 |
|
---|
135 | #define ICH6_HDA_REG_CORBLBASE 13 /* 0x40 */
|
---|
136 | #define CORBLBASE(pState) (HDA_REG((pState), CORBLBASE))
|
---|
137 | #define ICH6_HDA_REG_CORBUBASE 14 /* 0x44 */
|
---|
138 | #define CORBUBASE(pState) (HDA_REG((pState), CORBUBASE))
|
---|
139 | #define ICH6_HDA_REG_CORBWP 15 /* 48 */
|
---|
140 | #define ICH6_HDA_REG_CORBRP 16 /* 4A */
|
---|
141 | #define ICH6_HDA_CORBRP_RST_SHIFT 15
|
---|
142 | #define ICH6_HDA_CORBRP_WP_SHIFT 0
|
---|
143 | #define ICH6_HDA_CORBRP_WP_MASK 0xFF
|
---|
144 |
|
---|
145 | #define CORBRP(pState) (HDA_REG(pState, CORBRP))
|
---|
146 | #define CORBWP(pState) (HDA_REG(pState, CORBWP))
|
---|
147 |
|
---|
148 | #define ICH6_HDA_REG_CORBCTL 17 /* 0x4C */
|
---|
149 | #define ICH6_HDA_CORBCTL_DMA_SHIFT (1)
|
---|
150 | #define ICH6_HDA_CORBCTL_CMEIE_SHIFT (0)
|
---|
151 |
|
---|
152 | #define CORBCTL(pState) (HDA_REG(pState, CORBCTL))
|
---|
153 |
|
---|
154 |
|
---|
155 | #define ICH6_HDA_REG_CORBSTS 18 /* 0x4D */
|
---|
156 | #define CORBSTS(pState) (HDA_REG(pState, CORBSTS))
|
---|
157 | #define ICH6_HDA_CORBSTS_CMEI_SHIFT (0)
|
---|
158 |
|
---|
159 | #define ICH6_HDA_REG_CORBSIZE 19 /* 0x4E */
|
---|
160 | #define ICH6_HDA_CORBSIZE_SZ_CAP 0xF0
|
---|
161 | #define ICH6_HDA_CORBSIZE_SZ 0x3
|
---|
162 | #define CORBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ)
|
---|
163 | #define CORBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ_CAP)
|
---|
164 | /* till ich 10 sizes of CORB and RIRB are hardcoded to 256 in real hw */
|
---|
165 |
|
---|
166 | #define ICH6_HDA_REG_RIRLBASE 20 /* 0x50 */
|
---|
167 | #define RIRLBASE(pState) (HDA_REG((pState), RIRLBASE))
|
---|
168 |
|
---|
169 | #define ICH6_HDA_REG_RIRUBASE 21 /* 0x54 */
|
---|
170 | #define RIRUBASE(pState) (HDA_REG((pState), RIRUBASE))
|
---|
171 |
|
---|
172 | #define ICH6_HDA_REG_RIRBWP 22 /* 0x58 */
|
---|
173 | #define ICH6_HDA_RIRBWP_RST_SHIFT (15)
|
---|
174 | #define ICH6_HDA_RIRBWP_WP_MASK 0xFF
|
---|
175 | #define RIRBWP(pState) (HDA_REG(pState, RIRBWP))
|
---|
176 |
|
---|
177 | #define ICH6_HDA_REG_RINTCNT 23 /* 0x5A */
|
---|
178 | #define RINTCNT(pState) (HDA_REG((pState), RINTCNT))
|
---|
179 | #define RINTCNT_N(pState) (RINTCNT((pState)) & 0xff)
|
---|
180 |
|
---|
181 | #define ICH6_HDA_REG_RIRBCTL 24 /* 0x5C */
|
---|
182 | #define ICH6_HDA_RIRBCTL_RIC_SHIFT (0)
|
---|
183 | #define ICH6_HDA_RIRBCTL_DMA_SHIFT (1)
|
---|
184 | #define ICH6_HDA_ROI_DMA_SHIFT (2)
|
---|
185 | #define RIRBCTL(pState) (HDA_REG((pState), RIRBCTL))
|
---|
186 | #define RIRBCTL_RIRB_RIC(pState) (HDA_REG_FLAG_VALUE(pState, RIRBCTL, RIC))
|
---|
187 | #define RIRBCTL_RIRB_DMA(pState) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, DMA)
|
---|
188 | #define RIRBCTL_ROI(pState) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, ROI))
|
---|
189 |
|
---|
190 | #define ICH6_HDA_REG_RIRBSTS 25 /* 0x5D */
|
---|
191 | #define ICH6_HDA_RIRBSTS_RINTFL_SHIFT (0)
|
---|
192 | #define ICH6_HDA_RIRBSTS_RIRBOIS_SHIFT (2)
|
---|
193 | #define RIRBSTS(pState) (HDA_REG(pState, RIRBSTS))
|
---|
194 | #define RIRBSTS_RINTFL(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RINTFL))
|
---|
195 | #define RIRBSTS_RIRBOIS(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RIRBOIS))
|
---|
196 |
|
---|
197 | #define ICH6_HDA_REG_RIRBSIZE 26 /* 0x5E */
|
---|
198 | #define ICH6_HDA_RIRBSIZE_SZ_CAP 0xF0
|
---|
199 | #define ICH6_HDA_RIRBSIZE_SZ 0x3
|
---|
200 |
|
---|
201 | #define RIRBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ)
|
---|
202 | #define RIRBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ_CAP)
|
---|
203 |
|
---|
204 |
|
---|
205 | #define ICH6_HDA_REG_IC 27 /* 0x60 */
|
---|
206 | #define IC(pState) (HDA_REG(pState, IC))
|
---|
207 | #define ICH6_HDA_REG_IR 28 /* 0x64 */
|
---|
208 | #define IR(pState) (HDA_REG(pState, IR))
|
---|
209 | #define ICH6_HDA_REG_IRS 29 /* 0x68 */
|
---|
210 | #define ICH6_HDA_IRS_ICB_SHIFT (0)
|
---|
211 | #define ICH6_HDA_IRS_IRV_SHIFT (1)
|
---|
212 | #define IRS(pState) (HDA_REG(pState, IRS))
|
---|
213 | #define IRS_ICB(pState) (HDA_REG_FLAG_VALUE(pState, IRS, ICB))
|
---|
214 | #define IRS_IRV(pState) (HDA_REG_FLAG_VALUE(pState, IRS, IRV))
|
---|
215 |
|
---|
216 | #define ICH6_HDA_REG_DPLBASE 30 /* 0x70 */
|
---|
217 | #define DPLBASE(pState) (HDA_REG((pState), DPLBASE))
|
---|
218 | #define ICH6_HDA_REG_DPUBASE 31 /* 0x74 */
|
---|
219 | #define DPUBASE(pState) (HDA_REG((pState), DPUBASE))
|
---|
220 | #define DPBASE_ENABLED 1
|
---|
221 | #define DPBASE_ADDR_MASK (~0x7f)
|
---|
222 |
|
---|
223 | #define HDA_STREAM_REG_DEF(name, num) (ICH6_HDA_REG_SD##num##name)
|
---|
224 | #define HDA_STREAM_REG(pState, name, num) (HDA_REG((pState), N_(HDA_STREAM_REG_DEF(name, num))))
|
---|
225 |
|
---|
226 | #define ICH6_HDA_REG_SD0CTL 32 /* 0x80 */
|
---|
227 | #define ICH6_HDA_REG_SD1CTL (HDA_STREAM_REG_DEF(CTL, 0) + 10) /* 0xA0 */
|
---|
228 | #define ICH6_HDA_REG_SD2CTL (HDA_STREAM_REG_DEF(CTL, 0) + 20) /* 0xC0 */
|
---|
229 | #define ICH6_HDA_REG_SD3CTL (HDA_STREAM_REG_DEF(CTL, 0) + 30) /* 0xE0 */
|
---|
230 | #define ICH6_HDA_REG_SD4CTL (HDA_STREAM_REG_DEF(CTL, 0) + 40) /* 0x100 */
|
---|
231 | #define ICH6_HDA_REG_SD5CTL (HDA_STREAM_REG_DEF(CTL, 0) + 50) /* 0x120 */
|
---|
232 | #define ICH6_HDA_REG_SD6CTL (HDA_STREAM_REG_DEF(CTL, 0) + 60) /* 0x140 */
|
---|
233 | #define ICH6_HDA_REG_SD7CTL (HDA_STREAM_REG_DEF(CTL, 0) + 70) /* 0x160 */
|
---|
234 |
|
---|
235 | #define SD(func, num) SD##num##func
|
---|
236 | #define SDCTL(pState, num) HDA_REG((pState), SD(CTL, num))
|
---|
237 | #define SDCTL_NUM(pState, num) ((SDCTL((pState), num) & HDA_REG_FIELD_MASK(SDCTL,NUM)) >> HDA_REG_FIELD_SHIFT(SDCTL, NUM))
|
---|
238 | #define ICH6_HDA_SDCTL_NUM_MASK (0xF)
|
---|
239 | #define ICH6_HDA_SDCTL_NUM_SHIFT (20)
|
---|
240 | #define ICH6_HDA_SDCTL_DEIE_SHIFT (4)
|
---|
241 | #define ICH6_HDA_SDCTL_FEIE_SHIFT (3)
|
---|
242 | #define ICH6_HDA_SDCTL_ICE_SHIFT (2)
|
---|
243 | #define ICH6_HDA_SDCTL_RUN_SHIFT (1)
|
---|
244 | #define ICH6_HDA_SDCTL_SRST_SHIFT (0)
|
---|
245 |
|
---|
246 | #define ICH6_HDA_REG_SD0STS 33 /* 0x83 */
|
---|
247 | #define ICH6_HDA_REG_SD1STS (HDA_STREAM_REG_DEF(STS, 0) + 10) /* 0xA3 */
|
---|
248 | #define ICH6_HDA_REG_SD2STS (HDA_STREAM_REG_DEF(STS, 0) + 20) /* 0xC3 */
|
---|
249 | #define ICH6_HDA_REG_SD3STS (HDA_STREAM_REG_DEF(STS, 0) + 30) /* 0xE3 */
|
---|
250 | #define ICH6_HDA_REG_SD4STS (HDA_STREAM_REG_DEF(STS, 0) + 40) /* 0x103 */
|
---|
251 | #define ICH6_HDA_REG_SD5STS (HDA_STREAM_REG_DEF(STS, 0) + 50) /* 0x123 */
|
---|
252 | #define ICH6_HDA_REG_SD6STS (HDA_STREAM_REG_DEF(STS, 0) + 60) /* 0x143 */
|
---|
253 | #define ICH6_HDA_REG_SD7STS (HDA_STREAM_REG_DEF(STS, 0) + 70) /* 0x163 */
|
---|
254 |
|
---|
255 | #define SDSTS(pState, num) HDA_REG((pState), SD(STS, num))
|
---|
256 | #define ICH6_HDA_SDSTS_FIFORDY_SHIFT (5)
|
---|
257 | #define ICH6_HDA_SDSTS_DE_SHIFT (4)
|
---|
258 | #define ICH6_HDA_SDSTS_FE_SHIFT (3)
|
---|
259 | #define ICH6_HDA_SDSTS_BCIS_SHIFT (2)
|
---|
260 |
|
---|
261 | #define ICH6_HDA_REG_SD0LPIB 34 /* 0x84 */
|
---|
262 | #define ICH6_HDA_REG_SD1LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 10) /* 0xA4 */
|
---|
263 | #define ICH6_HDA_REG_SD2LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 20) /* 0xC4 */
|
---|
264 | #define ICH6_HDA_REG_SD3LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 30) /* 0xE4 */
|
---|
265 | #define ICH6_HDA_REG_SD4LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 40) /* 0x104 */
|
---|
266 | #define ICH6_HDA_REG_SD5LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 50) /* 0x124 */
|
---|
267 | #define ICH6_HDA_REG_SD6LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 60) /* 0x144 */
|
---|
268 | #define ICH6_HDA_REG_SD7LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 70) /* 0x164 */
|
---|
269 |
|
---|
270 | #define SDLPIB(pState, num) HDA_REG((pState), SD(LPIB, num))
|
---|
271 |
|
---|
272 | #define ICH6_HDA_REG_SD0CBL 35 /* 0x88 */
|
---|
273 | #define ICH6_HDA_REG_SD1CBL (HDA_STREAM_REG_DEF(CBL, 0) + 10) /* 0xA8 */
|
---|
274 | #define ICH6_HDA_REG_SD2CBL (HDA_STREAM_REG_DEF(CBL, 0) + 20) /* 0xC8 */
|
---|
275 | #define ICH6_HDA_REG_SD3CBL (HDA_STREAM_REG_DEF(CBL, 0) + 30) /* 0xE8 */
|
---|
276 | #define ICH6_HDA_REG_SD4CBL (HDA_STREAM_REG_DEF(CBL, 0) + 40) /* 0x108 */
|
---|
277 | #define ICH6_HDA_REG_SD5CBL (HDA_STREAM_REG_DEF(CBL, 0) + 50) /* 0x128 */
|
---|
278 | #define ICH6_HDA_REG_SD6CBL (HDA_STREAM_REG_DEF(CBL, 0) + 60) /* 0x148 */
|
---|
279 | #define ICH6_HDA_REG_SD7CBL (HDA_STREAM_REG_DEF(CBL, 0) + 70) /* 0x168 */
|
---|
280 |
|
---|
281 | #define SDLCBL(pState, num) HDA_REG((pState), SD(CBL, num))
|
---|
282 |
|
---|
283 | #define ICH6_HDA_REG_SD0LVI 36 /* 0x8C */
|
---|
284 | #define ICH6_HDA_REG_SD1LVI (HDA_STREAM_REG_DEF(LVI, 0) + 10) /* 0xAC */
|
---|
285 | #define ICH6_HDA_REG_SD2LVI (HDA_STREAM_REG_DEF(LVI, 0) + 20) /* 0xCC */
|
---|
286 | #define ICH6_HDA_REG_SD3LVI (HDA_STREAM_REG_DEF(LVI, 0) + 30) /* 0xEC */
|
---|
287 | #define ICH6_HDA_REG_SD4LVI (HDA_STREAM_REG_DEF(LVI, 0) + 40) /* 0x10C */
|
---|
288 | #define ICH6_HDA_REG_SD5LVI (HDA_STREAM_REG_DEF(LVI, 0) + 50) /* 0x12C */
|
---|
289 | #define ICH6_HDA_REG_SD6LVI (HDA_STREAM_REG_DEF(LVI, 0) + 60) /* 0x14C */
|
---|
290 | #define ICH6_HDA_REG_SD7LVI (HDA_STREAM_REG_DEF(LVI, 0) + 70) /* 0x16C */
|
---|
291 |
|
---|
292 | #define SDLVI(pState, num) HDA_REG((pState), SD(LVI, num))
|
---|
293 |
|
---|
294 | #define ICH6_HDA_REG_SD0FIFOW 37 /* 0x8E */
|
---|
295 | #define ICH6_HDA_REG_SD1FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 10) /* 0xAE */
|
---|
296 | #define ICH6_HDA_REG_SD2FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 20) /* 0xCE */
|
---|
297 | #define ICH6_HDA_REG_SD3FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 30) /* 0xEE */
|
---|
298 | #define ICH6_HDA_REG_SD4FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 40) /* 0x10E */
|
---|
299 | #define ICH6_HDA_REG_SD5FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 50) /* 0x12E */
|
---|
300 | #define ICH6_HDA_REG_SD6FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 60) /* 0x14E */
|
---|
301 | #define ICH6_HDA_REG_SD7FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 70) /* 0x16E */
|
---|
302 |
|
---|
303 | /*
|
---|
304 | * ICH6 datasheet defined limits for FIFOW values (18.2.38)
|
---|
305 | */
|
---|
306 | #define HDA_SDFIFOW_8B (0x2)
|
---|
307 | #define HDA_SDFIFOW_16B (0x3)
|
---|
308 | #define HDA_SDFIFOW_32B (0x4)
|
---|
309 | #define SDFIFOW(pState, num) HDA_REG((pState), SD(FIFOW, num))
|
---|
310 |
|
---|
311 | #define ICH6_HDA_REG_SD0FIFOS 38 /* 0x90 */
|
---|
312 | #define ICH6_HDA_REG_SD1FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 10) /* 0xB0 */
|
---|
313 | #define ICH6_HDA_REG_SD2FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 20) /* 0xD0 */
|
---|
314 | #define ICH6_HDA_REG_SD3FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 30) /* 0xF0 */
|
---|
315 | #define ICH6_HDA_REG_SD4FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 40) /* 0x110 */
|
---|
316 | #define ICH6_HDA_REG_SD5FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 50) /* 0x130 */
|
---|
317 | #define ICH6_HDA_REG_SD6FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 60) /* 0x150 */
|
---|
318 | #define ICH6_HDA_REG_SD7FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 70) /* 0x170 */
|
---|
319 |
|
---|
320 | /*
|
---|
321 | * ICH6 datasheet defines limits for FIFOS registers (18.2.39)
|
---|
322 | * formula: size - 1
|
---|
323 | * Other values not listed are not supported.
|
---|
324 | */
|
---|
325 | #define HDA_SDONFIFO_16B (0xF) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
326 | #define HDA_SDONFIFO_32B (0x1F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
327 | #define HDA_SDONFIFO_64B (0x3F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
328 | #define HDA_SDONFIFO_128B (0x7F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
329 | #define HDA_SDONFIFO_192B (0xBF) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */
|
---|
330 | #define HDA_SDONFIFO_256B (0xFF) /* 20-, 24-bit Output Streams */
|
---|
331 | #define HDA_SDINFIFO_120B (0x77) /* 8-, 16-, 20-, 24-, 32-bit Input Streams */
|
---|
332 | #define HDA_SDINFIFO_160B (0x9F) /* 20-, 24-bit Input Streams Streams */
|
---|
333 | #define SDFIFOS(pState, num) HDA_REG((pState), SD(FIFOS, num))
|
---|
334 |
|
---|
335 | #define ICH6_HDA_REG_SD0FMT 39 /* 0x92 */
|
---|
336 | #define ICH6_HDA_REG_SD1FMT (HDA_STREAM_REG_DEF(FMT, 0) + 10) /* 0xB2 */
|
---|
337 | #define ICH6_HDA_REG_SD2FMT (HDA_STREAM_REG_DEF(FMT, 0) + 20) /* 0xD2 */
|
---|
338 | #define ICH6_HDA_REG_SD3FMT (HDA_STREAM_REG_DEF(FMT, 0) + 30) /* 0xF2 */
|
---|
339 | #define ICH6_HDA_REG_SD4FMT (HDA_STREAM_REG_DEF(FMT, 0) + 40) /* 0x112 */
|
---|
340 | #define ICH6_HDA_REG_SD5FMT (HDA_STREAM_REG_DEF(FMT, 0) + 50) /* 0x132 */
|
---|
341 | #define ICH6_HDA_REG_SD6FMT (HDA_STREAM_REG_DEF(FMT, 0) + 60) /* 0x152 */
|
---|
342 | #define ICH6_HDA_REG_SD7FMT (HDA_STREAM_REG_DEF(FMT, 0) + 70) /* 0x172 */
|
---|
343 |
|
---|
344 | #define SDFMT(pState, num) (HDA_REG((pState), SD(FMT, num)))
|
---|
345 | #define ICH6_HDA_SDFMT_BASE_RATE_SHIFT (14)
|
---|
346 | #define ICH6_HDA_SDFMT_MULT_SHIFT (11)
|
---|
347 | #define ICH6_HDA_SDFMT_MULT_MASK (0x7)
|
---|
348 | #define ICH6_HDA_SDFMT_DIV_SHIFT (8)
|
---|
349 | #define ICH6_HDA_SDFMT_DIV_MASK (0x7)
|
---|
350 | #define SDFMT_BASE_RATE(pState, num) ((SDFMT(pState, num) & HDA_REG_FIELD_FLAG_MASK(SDFMT, BASE_RATE)) >> HDA_REG_FIELD_SHIFT(SDFMT, BASE_RATE))
|
---|
351 | #define SDFMT_MULT(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT))
|
---|
352 | #define SDFMT_DIV(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,DIV)) >> HDA_REG_FIELD_SHIFT(SDFMT, DIV))
|
---|
353 |
|
---|
354 | #define ICH6_HDA_REG_SD0BDPL 40 /* 0x98 */
|
---|
355 | #define ICH6_HDA_REG_SD1BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 10) /* 0xB8 */
|
---|
356 | #define ICH6_HDA_REG_SD2BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 20) /* 0xD8 */
|
---|
357 | #define ICH6_HDA_REG_SD3BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 30) /* 0xF8 */
|
---|
358 | #define ICH6_HDA_REG_SD4BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 40) /* 0x118 */
|
---|
359 | #define ICH6_HDA_REG_SD5BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 50) /* 0x138 */
|
---|
360 | #define ICH6_HDA_REG_SD6BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 60) /* 0x158 */
|
---|
361 | #define ICH6_HDA_REG_SD7BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 70) /* 0x178 */
|
---|
362 |
|
---|
363 | #define SDBDPL(pState, num) HDA_REG((pState), SD(BDPL, num))
|
---|
364 |
|
---|
365 | #define ICH6_HDA_REG_SD0BDPU 41 /* 0x9C */
|
---|
366 | #define ICH6_HDA_REG_SD1BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 10) /* 0xBC */
|
---|
367 | #define ICH6_HDA_REG_SD2BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 20) /* 0xDC */
|
---|
368 | #define ICH6_HDA_REG_SD3BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 30) /* 0xFC */
|
---|
369 | #define ICH6_HDA_REG_SD4BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 40) /* 0x11C */
|
---|
370 | #define ICH6_HDA_REG_SD5BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 50) /* 0x13C */
|
---|
371 | #define ICH6_HDA_REG_SD6BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 60) /* 0x15C */
|
---|
372 | #define ICH6_HDA_REG_SD7BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 70) /* 0x17C */
|
---|
373 |
|
---|
374 | #define SDBDPU(pState, num) HDA_REG((pState), SD(BDPU, num))
|
---|
375 |
|
---|
376 | /* Predicates */
|
---|
377 |
|
---|
378 | typedef struct HDABDLEDESC
|
---|
379 | {
|
---|
380 | uint64_t u64BdleCviAddr;
|
---|
381 | uint32_t u32BdleMaxCvi;
|
---|
382 | uint32_t u32BdleCvi;
|
---|
383 | uint32_t u32BdleCviLen;
|
---|
384 | uint32_t u32BdleCviPos;
|
---|
385 | bool fBdleCviIoc;
|
---|
386 | uint32_t cbUnderFifoW;
|
---|
387 | uint8_t au8HdaBuffer[HDA_SDONFIFO_256B + 1];
|
---|
388 | } HDABDLEDESC, *PHDABDLEDESC;
|
---|
389 |
|
---|
390 | typedef struct INTELHDLinkState
|
---|
391 | {
|
---|
392 | /** Pointer to the device instance. */
|
---|
393 | PPDMDEVINSR3 pDevIns;
|
---|
394 | /** Pointer to the connector of the attached audio driver. */
|
---|
395 | PPDMIAUDIOCONNECTOR pDrv;
|
---|
396 | /** Pointer to the attached audio driver. */
|
---|
397 | PPDMIBASE pDrvBase;
|
---|
398 | /** The base interface for LUN\#0. */
|
---|
399 | PDMIBASE IBase;
|
---|
400 | RTGCPHYS addrMMReg;
|
---|
401 | uint32_t au32Regs[113];
|
---|
402 | HDABDLEDESC stInBdle;
|
---|
403 | HDABDLEDESC stOutBdle;
|
---|
404 | HDABDLEDESC stMicBdle;
|
---|
405 | /* Interrupt on completion */
|
---|
406 | bool fCviIoc;
|
---|
407 | uint64_t u64CORBBase;
|
---|
408 | uint64_t u64RIRBBase;
|
---|
409 | uint64_t u64DPBase;
|
---|
410 | /* pointer on CORB buf */
|
---|
411 | uint32_t *pu32CorbBuf;
|
---|
412 | /* size in bytes of CORB buf */
|
---|
413 | uint32_t cbCorbBuf;
|
---|
414 | /* pointer on RIRB buf */
|
---|
415 | uint64_t *pu64RirbBuf;
|
---|
416 | /* size in bytes of RIRB buf */
|
---|
417 | uint32_t cbRirbBuf;
|
---|
418 | /* indicates if HDA in reset. */
|
---|
419 | bool fInReset;
|
---|
420 | CODECState Codec;
|
---|
421 | uint8_t u8Counter;
|
---|
422 | uint8_t u8StreamsInReset;
|
---|
423 | } INTELHDLinkState;
|
---|
424 |
|
---|
425 | #define ICH6_HDASTATE_2_DEVINS(pINTELHD) ((pINTELHD)->pDevIns)
|
---|
426 | #define PCIDEV_2_ICH6_HDASTATE(pPciDev) ((PCIINTELHDLinkState *)(pPciDev))
|
---|
427 |
|
---|
428 | #define ISD0FMT_TO_AUDIO_SELECTOR(pState) (AUDIO_FORMAT_SELECTOR(&(pState)->Codec, In, \
|
---|
429 | SDFMT_BASE_RATE(pState, 0), SDFMT_MULT(pState, 0), SDFMT_DIV(pState, 0)))
|
---|
430 | #define OSD0FMT_TO_AUDIO_SELECTOR(pState) (AUDIO_FORMAT_SELECTOR(&(pState)->Codec, Out, \
|
---|
431 | SDFMT_BASE_RATE(pState, 4), SDFMT_MULT(pState, 4), SDFMT_DIV(pState, 4)))
|
---|
432 |
|
---|
433 |
|
---|
434 |
|
---|
435 |
|
---|
436 | typedef struct PCIINTELHDLinkState
|
---|
437 | {
|
---|
438 | PCIDevice dev;
|
---|
439 | INTELHDLinkState hda;
|
---|
440 | } PCIINTELHDLinkState;
|
---|
441 |
|
---|
442 |
|
---|
443 | DECLCALLBACK(int)hdaRegReadUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
444 | DECLCALLBACK(int)hdaRegWriteUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
445 | DECLCALLBACK(int)hdaRegReadGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
446 | DECLCALLBACK(int)hdaRegWriteGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
447 | DECLCALLBACK(int)hdaRegReadSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
448 | DECLCALLBACK(int)hdaRegWriteSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
449 | DECLCALLBACK(int)hdaRegReadGCAP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
450 | DECLCALLBACK(int)hdaRegReadINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
451 | DECLCALLBACK(int)hdaRegWriteINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
452 | DECLCALLBACK(int)hdaRegWriteCORBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
453 | DECLCALLBACK(int)hdaRegWriteCORBRP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
454 | DECLCALLBACK(int)hdaRegWriteCORBCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
455 | DECLCALLBACK(int)hdaRegWriteCORBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
456 | DECLCALLBACK(int)hdaRegWriteRIRBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
457 | DECLCALLBACK(int)hdaRegWriteRIRBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
458 | DECLCALLBACK(int)hdaRegWriteIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
459 | DECLCALLBACK(int)hdaRegReadIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
460 | DECLCALLBACK(int)hdaRegWriteSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
461 | DECLCALLBACK(int)hdaRegReadSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
462 |
|
---|
463 | DECLCALLBACK(int)hdaRegWriteSDSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
464 | DECLCALLBACK(int)hdaRegWriteSDLVI(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
465 | DECLCALLBACK(int)hdaRegWriteSDFIFOW(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
466 | DECLCALLBACK(int)hdaRegWriteSDFIFOS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
467 | DECLCALLBACK(int)hdaRegWriteSDBDPL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
468 | DECLCALLBACK(int)hdaRegWriteSDBDPU(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
469 | DECLCALLBACK(int)hdaRegWriteBase(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
470 | DECLCALLBACK(int)hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
471 | DECLCALLBACK(int)hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
472 | DECLCALLBACK(int)hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
473 | DECLCALLBACK(int)hdaRegWriteU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
474 | DECLCALLBACK(int)hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
475 | DECLCALLBACK(int)hdaRegWriteU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
476 | DECLCALLBACK(int)hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
477 | DECLCALLBACK(int)hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);
|
---|
478 | static int hdaLookup(INTELHDLinkState* pState, uint32_t u32Offset);
|
---|
479 | static void fetch_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA);
|
---|
480 |
|
---|
481 | /* see 302349 p 6.2*/
|
---|
482 | const static struct stIchIntelHDRegMap
|
---|
483 | {
|
---|
484 | /** Register offset in the register space. */
|
---|
485 | uint32_t offset;
|
---|
486 | /** Size in bytes. Registers of size > 4 are in fact tables. */
|
---|
487 | uint32_t size;
|
---|
488 | /** Readable bits. */
|
---|
489 | uint32_t readable;
|
---|
490 | /** Writable bits. */
|
---|
491 | uint32_t writable;
|
---|
492 | /** Read callback. */
|
---|
493 | int (*pfnRead)(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
|
---|
494 | /** Write callback. */
|
---|
495 | int (*pfnWrite)(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
|
---|
496 | /** Abbreviated name. */
|
---|
497 | const char *abbrev;
|
---|
498 | /** Full name. */
|
---|
499 | const char *name;
|
---|
500 | } s_ichIntelHDRegMap[] =
|
---|
501 | {
|
---|
502 | /* offset size read mask write mask read callback write callback abbrev full name */
|
---|
503 | /*------- ------- ---------- ---------- ----------------------- ------------------------ ---------- ------------------------------*/
|
---|
504 | { 0x00000, 0x00002, 0x0000FFFB, 0x00000000, hdaRegReadGCAP , hdaRegWriteUnimplemented, "GCAP" , "Global Capabilities" },
|
---|
505 | { 0x00002, 0x00001, 0x000000FF, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "VMIN" , "Minor Version" },
|
---|
506 | { 0x00003, 0x00001, 0x000000FF, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "VMAJ" , "Major Version" },
|
---|
507 | { 0x00004, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimplemented, "OUTPAY" , "Output Payload Capabilities" },
|
---|
508 | { 0x00006, 0x00002, 0x0000FFFF, 0x00000000, hdaRegReadU16 , hdaRegWriteUnimplemented, "INPAY" , "Input Payload Capabilities" },
|
---|
509 | { 0x00008, 0x00004, 0x00000103, 0x00000103, hdaRegReadGCTL , hdaRegWriteGCTL , "GCTL" , "Global Control" },
|
---|
510 | { 0x0000c, 0x00002, 0x00007FFF, 0x00007FFF, hdaRegReadU16 , hdaRegWriteU16 , "WAKEEN" , "Wake Enable" },
|
---|
511 | { 0x0000e, 0x00002, 0x00000007, 0x00000007, hdaRegReadU8 , hdaRegWriteSTATESTS , "STATESTS" , "State Change Status" },
|
---|
512 | { 0x00010, 0x00002, 0xFFFFFFFF, 0x00000000, hdaRegReadUnimplemented, hdaRegWriteUnimplemented, "GSTS" , "Global Status" },
|
---|
513 | { 0x00020, 0x00004, 0xC00000FF, 0xC00000FF, hdaRegReadU32 , hdaRegWriteU32 , "INTCTL" , "Interrupt Control" },
|
---|
514 | { 0x00024, 0x00004, 0xC00000FF, 0x00000000, hdaRegReadINTSTS , hdaRegWriteUnimplemented, "INTSTS" , "Interrupt Status" },
|
---|
515 | //** @todo r=michaln: Are guests really not reading the WALCLK register at all?
|
---|
516 | { 0x00030, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadUnimplemented, hdaRegWriteUnimplemented, "WALCLK" , "Wall Clock Counter" },
|
---|
517 | //** @todo r=michaln: Doesn't the SSYNC register need to actually stop the stream(s)?
|
---|
518 | { 0x00034, 0x00004, 0x000000FF, 0x000000FF, hdaRegReadU32 , hdaRegWriteU32 , "SSYNC" , "Stream Synchronization" },
|
---|
519 | { 0x00040, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteBase , "CORBLBASE" , "CORB Lower Base Address" },
|
---|
520 | { 0x00044, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , "CORBUBASE" , "CORB Upper Base Address" },
|
---|
521 | { 0x00048, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteCORBWP , "CORBWP" , "CORB Write Pointer" },
|
---|
522 | { 0x0004A, 0x00002, 0x000000FF, 0x000080FF, hdaRegReadU8 , hdaRegWriteCORBRP , "CORBRP" , "CORB Read Pointer" },
|
---|
523 | { 0x0004C, 0x00001, 0x00000003, 0x00000003, hdaRegReadU8 , hdaRegWriteCORBCTL , "CORBCTL" , "CORB Control" },
|
---|
524 | { 0x0004D, 0x00001, 0x00000001, 0x00000001, hdaRegReadU8 , hdaRegWriteCORBSTS , "CORBSTS" , "CORB Status" },
|
---|
525 | { 0x0004E, 0x00001, 0x000000F3, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "CORBSIZE" , "CORB Size" },
|
---|
526 | { 0x00050, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteBase , "RIRBLBASE" , "RIRB Lower Base Address" },
|
---|
527 | { 0x00054, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , "RIRBUBASE" , "RIRB Upper Base Address" },
|
---|
528 | { 0x00058, 0x00002, 0x000000FF, 0x00008000, hdaRegReadU8, hdaRegWriteRIRBWP , "RIRBWP" , "RIRB Write Pointer" },
|
---|
529 | { 0x0005A, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteU16 , "RINTCNT" , "Response Interrupt Count" },
|
---|
530 | { 0x0005C, 0x00001, 0x00000007, 0x00000007, hdaRegReadU8 , hdaRegWriteU8 , "RIRBCTL" , "RIRB Control" },
|
---|
531 | { 0x0005D, 0x00001, 0x00000005, 0x00000005, hdaRegReadU8 , hdaRegWriteRIRBSTS , "RIRBSTS" , "RIRB Status" },
|
---|
532 | { 0x0005E, 0x00001, 0x000000F3, 0x00000000, hdaRegReadU8 , hdaRegWriteUnimplemented, "RIRBSIZE" , "RIRB Size" },
|
---|
533 | { 0x00060, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "IC" , "Immediate Command" },
|
---|
534 | { 0x00064, 0x00004, 0x00000000, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteUnimplemented, "IR" , "Immediate Response" },
|
---|
535 | { 0x00068, 0x00004, 0x00000002, 0x00000002, hdaRegReadIRS , hdaRegWriteIRS , "IRS" , "Immediate Command Status" },
|
---|
536 | { 0x00070, 0x00004, 0xFFFFFFFF, 0xFFFFFF81, hdaRegReadU32 , hdaRegWriteBase , "DPLBASE" , "DMA Position Lower Base" },
|
---|
537 | { 0x00074, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteBase , "DPUBASE" , "DMA Position Upper Base" },
|
---|
538 |
|
---|
539 | { 0x00080, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD0CTL" , "Input Stream Descriptor 0 (ICD0) Control" },
|
---|
540 | { 0x00083, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD0STS" , "ISD0 Status" },
|
---|
541 | { 0x00084, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD0LPIB" , "ISD0 Link Position In Buffer" },
|
---|
542 | { 0x00088, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD0CBL" , "ISD0 Cyclic Buffer Length" },
|
---|
543 | { 0x0008C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD0LVI" , "ISD0 Last Valid Index" },
|
---|
544 | { 0x0008E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , "ISD0FIFOW", "ISD0 FIFO Watermark" },
|
---|
545 | { 0x00090, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , "ISD0FIFOS", "ISD0 FIFO Size" },
|
---|
546 | { 0x00092, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD0FMT" , "ISD0 Format" },
|
---|
547 | { 0x00098, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD0BDPL" , "ISD0 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
548 | { 0x0009C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD0BDPU" , "ISD0 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
549 |
|
---|
550 | { 0x000A0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD1CTL" , "Input Stream Descriptor 1 (ISD1) Control" },
|
---|
551 | { 0x000A3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD1STS" , "ISD1 Status" },
|
---|
552 | { 0x000A4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD1LPIB" , "ISD1 Link Position In Buffer" },
|
---|
553 | { 0x000A8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD1CBL" , "ISD1 Cyclic Buffer Length" },
|
---|
554 | { 0x000AC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD1LVI" , "ISD1 Last Valid Index" },
|
---|
555 | { 0x000AE, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , "ISD1FIFOW", "ISD1 FIFO Watermark" },
|
---|
556 | { 0x000B0, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , "ISD1FIFOS", "ISD1 FIFO Size" },
|
---|
557 | { 0x000B2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD1FMT" , "ISD1 Format" },
|
---|
558 | { 0x000B8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD1BDPL" , "ISD1 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
559 | { 0x000BC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD1BDPU" , "ISD1 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
560 |
|
---|
561 | { 0x000C0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD2CTL" , "Input Stream Descriptor 2 (ISD2) Control" },
|
---|
562 | { 0x000C3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD2STS" , "ISD2 Status" },
|
---|
563 | { 0x000C4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD2LPIB" , "ISD2 Link Position In Buffer" },
|
---|
564 | { 0x000C8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD2CBL" , "ISD2 Cyclic Buffer Length" },
|
---|
565 | { 0x000CC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD2LVI" , "ISD2 Last Valid Index" },
|
---|
566 | { 0x000CE, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , "ISD2FIFOW", "ISD2 FIFO Watermark" },
|
---|
567 | { 0x000D0, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , "ISD2FIFOS", "ISD2 FIFO Size" },
|
---|
568 | { 0x000D2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD2FMT" , "ISD2 Format" },
|
---|
569 | { 0x000D8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD2BDPL" , "ISD2 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
570 | { 0x000DC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD2BDPU" , "ISD2 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
571 |
|
---|
572 | { 0x000E0, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "ISD3CTL" , "Input Stream Descriptor 3 (ISD3) Control" },
|
---|
573 | { 0x000E3, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "ISD3STS" , "ISD3 Status" },
|
---|
574 | { 0x000E4, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "ISD3LPIB" , "ISD3 Link Position In Buffer" },
|
---|
575 | { 0x000E8, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "ISD3CBL" , "ISD3 Cyclic Buffer Length" },
|
---|
576 | { 0x000EC, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "ISD3LVI" , "ISD3 Last Valid Index" },
|
---|
577 | { 0x000EE, 0x00002, 0x00000005, 0x00000005, hdaRegReadU16 , hdaRegWriteU16 , "ISD3FIFOW", "ISD3 FIFO Watermark" },
|
---|
578 | { 0x000F0, 0x00002, 0x000000FF, 0x00000000, hdaRegReadU16 , hdaRegWriteU16 , "ISD3FIFOS", "ISD3 FIFO Size" },
|
---|
579 | { 0x000F2, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "ISD3FMT" , "ISD3 Format" },
|
---|
580 | { 0x000F8, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "ISD3BDPL" , "ISD3 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
581 | { 0x000FC, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "ISD3BDPU" , "ISD3 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
582 |
|
---|
583 | { 0x00100, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadSDCTL , hdaRegWriteSDCTL , "OSD0CTL" , "Input Stream Descriptor 0 (OSD0) Control" },
|
---|
584 | { 0x00103, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD0STS" , "OSD0 Status" },
|
---|
585 | { 0x00104, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD0LPIB" , "OSD0 Link Position In Buffer" },
|
---|
586 | { 0x00108, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD0CBL" , "OSD0 Cyclic Buffer Length" },
|
---|
587 | { 0x0010C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD0LVI" , "OSD0 Last Valid Index" },
|
---|
588 | { 0x0010E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , "OSD0FIFOW", "OSD0 FIFO Watermark" },
|
---|
589 | { 0x00110, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , "OSD0FIFOS", "OSD0 FIFO Size" },
|
---|
590 | { 0x00112, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD0FMT" , "OSD0 Format" },
|
---|
591 | { 0x00118, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD0BDPL" , "OSD0 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
592 | { 0x0011C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD0BDPU" , "OSD0 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
593 |
|
---|
594 | { 0x00120, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "OSD1CTL" , "Input Stream Descriptor 0 (OSD1) Control" },
|
---|
595 | { 0x00123, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD1STS" , "OSD1 Status" },
|
---|
596 | { 0x00124, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD1LPIB" , "OSD1 Link Position In Buffer" },
|
---|
597 | { 0x00128, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD1CBL" , "OSD1 Cyclic Buffer Length" },
|
---|
598 | { 0x0012C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD1LVI" , "OSD1 Last Valid Index" },
|
---|
599 | { 0x0012E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , "OSD1FIFOW", "OSD1 FIFO Watermark" },
|
---|
600 | { 0x00130, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , "OSD1FIFOS", "OSD1 FIFO Size" },
|
---|
601 | { 0x00132, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD1FMT" , "OSD1 Format" },
|
---|
602 | { 0x00138, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD1BDPL" , "OSD1 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
603 | { 0x0013C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD1BDPU" , "OSD1 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
604 |
|
---|
605 | { 0x00140, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "OSD2CTL" , "Input Stream Descriptor 0 (OSD2) Control" },
|
---|
606 | { 0x00143, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD2STS" , "OSD2 Status" },
|
---|
607 | { 0x00144, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD2LPIB" , "OSD2 Link Position In Buffer" },
|
---|
608 | { 0x00148, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD2CBL" , "OSD2 Cyclic Buffer Length" },
|
---|
609 | { 0x0014C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD2LVI" , "OSD2 Last Valid Index" },
|
---|
610 | { 0x0014E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , "OSD2FIFOW", "OSD2 FIFO Watermark" },
|
---|
611 | { 0x00150, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , "OSD2FIFOS", "OSD2 FIFO Size" },
|
---|
612 | { 0x00152, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD2FMT" , "OSD2 Format" },
|
---|
613 | { 0x00158, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD2BDPL" , "OSD2 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
614 | { 0x0015C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD2BDPU" , "OSD2 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
615 |
|
---|
616 | { 0x00160, 0x00003, 0x00FF001F, 0x00F0001F, hdaRegReadU24 , hdaRegWriteSDCTL , "OSD3CTL" , "Input Stream Descriptor 0 (OSD3) Control" },
|
---|
617 | { 0x00163, 0x00001, 0x0000001C, 0x0000003C, hdaRegReadU8 , hdaRegWriteSDSTS , "OSD3STS" , "OSD3 Status" },
|
---|
618 | { 0x00164, 0x00004, 0xFFFFFFFF, 0x00000000, hdaRegReadU32 , hdaRegWriteU32 , "OSD3LPIB" , "OSD3 Link Position In Buffer" },
|
---|
619 | { 0x00168, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteU32 , "OSD3CBL" , "OSD3 Cyclic Buffer Length" },
|
---|
620 | { 0x0016C, 0x00002, 0x0000FFFF, 0x0000FFFF, hdaRegReadU16 , hdaRegWriteSDLVI , "OSD3LVI" , "OSD3 Last Valid Index" },
|
---|
621 | { 0x0016E, 0x00002, 0x00000007, 0x00000007, hdaRegReadU16 , hdaRegWriteSDFIFOW , "OSD3FIFOW", "OSD3 FIFO Watermark" },
|
---|
622 | { 0x00170, 0x00002, 0x000000FF, 0x000000FF, hdaRegReadU16 , hdaRegWriteSDFIFOS , "OSD3FIFOS", "OSD3 FIFO Size" },
|
---|
623 | { 0x00172, 0x00002, 0x00007F7F, 0x00007F7F, hdaRegReadU16 , hdaRegWriteU16 , "OSD3FMT" , "OSD3 Format" },
|
---|
624 | { 0x00178, 0x00004, 0xFFFFFF80, 0xFFFFFF80, hdaRegReadU32 , hdaRegWriteSDBDPL , "OSD3BDPL" , "OSD3 Buffer Descriptor List Pointer-Lower Base Address" },
|
---|
625 | { 0x0017C, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, hdaRegReadU32 , hdaRegWriteSDBDPU , "OSD3BDPU" , "OSD3 Buffer Descriptor List Pointer-Upper Base Address" },
|
---|
626 | };
|
---|
627 |
|
---|
628 | static void inline hdaUpdatePosBuf(INTELHDLinkState *pState, uint8_t u8Strm, uint32_t u32Value)
|
---|
629 | {
|
---|
630 | if (pState->u64DPBase & DPBASE_ENABLED)
|
---|
631 | PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState),
|
---|
632 | (pState->u64DPBase & DPBASE_ADDR_MASK) + u8Strm*8, &u32Value, sizeof(uint32_t));
|
---|
633 | }
|
---|
634 | static uint32_t inline hdaFifoWToSz(INTELHDLinkState *pState, int iNum)
|
---|
635 | {
|
---|
636 | switch (ICH6_HDA_REG_SD0FIFOW + 10*iNum)
|
---|
637 | {
|
---|
638 | case ICH6_HDA_REG_SD0FIFOW:
|
---|
639 | case ICH6_HDA_REG_SD1FIFOW:
|
---|
640 | case ICH6_HDA_REG_SD2FIFOW:
|
---|
641 | case ICH6_HDA_REG_SD3FIFOW:
|
---|
642 | case ICH6_HDA_REG_SD4FIFOW:
|
---|
643 | case ICH6_HDA_REG_SD5FIFOW:
|
---|
644 | case ICH6_HDA_REG_SD6FIFOW:
|
---|
645 | case ICH6_HDA_REG_SD7FIFOW:
|
---|
646 | switch(HDA_REG_IND(pState, ICH6_HDA_REG_SD0FIFOW + 10*iNum))
|
---|
647 | {
|
---|
648 | case HDA_SDFIFOW_8B: return 8;
|
---|
649 | case HDA_SDFIFOW_16B: return 16;
|
---|
650 | case HDA_SDFIFOW_32B: return 32;
|
---|
651 | default:
|
---|
652 | AssertMsgFailed(("hda: unsupported value (%x) in SDFIFOW(,%d)\n", HDA_REG_IND(pState, iNum), iNum));
|
---|
653 | }
|
---|
654 | default:
|
---|
655 | AssertMsgFailed(("hda: Not SDnFIFOW register"));
|
---|
656 | return 0;
|
---|
657 | }
|
---|
658 | }
|
---|
659 |
|
---|
660 | static int hdaProcessInterrupt(INTELHDLinkState* pState)
|
---|
661 | {
|
---|
662 | #define IS_INTERRUPT_OCCURED_AND_ENABLED(pState, num) \
|
---|
663 | ( INTCTL_SX((pState), num) \
|
---|
664 | && (SDSTS(pState, num) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))
|
---|
665 | bool fIrq = false;
|
---|
666 | if( INTCTL_CIE(pState)
|
---|
667 | && ( RIRBSTS_RINTFL(pState)
|
---|
668 | || RIRBSTS_RIRBOIS(pState)
|
---|
669 | || STATESTS(pState)))
|
---|
670 | {
|
---|
671 | fIrq = true;
|
---|
672 | }
|
---|
673 | if ( IS_INTERRUPT_OCCURED_AND_ENABLED(pState, 0)
|
---|
674 | || IS_INTERRUPT_OCCURED_AND_ENABLED(pState, 4))
|
---|
675 | {
|
---|
676 | fIrq = true;
|
---|
677 | }
|
---|
678 | if (INTCTL_GIE(pState))
|
---|
679 | {
|
---|
680 | Log(("hda: irq %s\n", fIrq ? "asserted" : "deasserted"));
|
---|
681 | PDMDevHlpPCISetIrq(ICH6_HDASTATE_2_DEVINS(pState), 0 , fIrq);
|
---|
682 | }
|
---|
683 | return VINF_SUCCESS;
|
---|
684 | }
|
---|
685 |
|
---|
686 | static int hdaLookup(INTELHDLinkState* pState, uint32_t u32Offset)
|
---|
687 | {
|
---|
688 | int index = 0;
|
---|
689 | //** @todo r=michaln: A linear search of an array with over 100 elements is very inefficient.
|
---|
690 | for (;index < (int)(sizeof(s_ichIntelHDRegMap)/sizeof(s_ichIntelHDRegMap[0])); ++index)
|
---|
691 | {
|
---|
692 | if ( u32Offset >= s_ichIntelHDRegMap[index].offset
|
---|
693 | && u32Offset < s_ichIntelHDRegMap[index].offset + s_ichIntelHDRegMap[index].size)
|
---|
694 | {
|
---|
695 | return index;
|
---|
696 | }
|
---|
697 | }
|
---|
698 | /* Aliases HDA spec 3.3.45 */
|
---|
699 | switch(u32Offset)
|
---|
700 | {
|
---|
701 | case 0x2084:
|
---|
702 | return HDA_REG_IND_NAME(SD0LPIB);
|
---|
703 | case 0x20A4:
|
---|
704 | return HDA_REG_IND_NAME(SD1LPIB);
|
---|
705 | case 0x20C4:
|
---|
706 | return HDA_REG_IND_NAME(SD2LPIB);
|
---|
707 | case 0x20E4:
|
---|
708 | return HDA_REG_IND_NAME(SD3LPIB);
|
---|
709 | case 0x2104:
|
---|
710 | return HDA_REG_IND_NAME(SD4LPIB);
|
---|
711 | case 0x2124:
|
---|
712 | return HDA_REG_IND_NAME(SD5LPIB);
|
---|
713 | case 0x2144:
|
---|
714 | return HDA_REG_IND_NAME(SD6LPIB);
|
---|
715 | case 0x2164:
|
---|
716 | return HDA_REG_IND_NAME(SD7LPIB);
|
---|
717 | }
|
---|
718 | return -1;
|
---|
719 | }
|
---|
720 |
|
---|
721 | static int hdaCmdSync(INTELHDLinkState *pState, bool fLocal)
|
---|
722 | {
|
---|
723 | int rc = VINF_SUCCESS;
|
---|
724 | if (fLocal)
|
---|
725 | {
|
---|
726 | Assert((HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA)));
|
---|
727 | rc = PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), pState->u64CORBBase, pState->pu32CorbBuf, pState->cbCorbBuf);
|
---|
728 | if (RT_FAILURE(rc))
|
---|
729 | AssertRCReturn(rc, rc);
|
---|
730 | #ifdef DEBUG_CMD_BUFFER
|
---|
731 | uint8_t i = 0;
|
---|
732 | do
|
---|
733 | {
|
---|
734 | Log(("hda: corb%02x: ", i));
|
---|
735 | uint8_t j = 0;
|
---|
736 | do
|
---|
737 | {
|
---|
738 | const char *prefix;
|
---|
739 | if ((i + j) == CORBRP(pState))
|
---|
740 | prefix = "[R]";
|
---|
741 | else if ((i + j) == CORBWP(pState))
|
---|
742 | prefix = "[W]";
|
---|
743 | else
|
---|
744 | prefix = " "; /* three spaces */
|
---|
745 | Log(("%s%08x", prefix, pState->pu32CorbBuf[i + j]));
|
---|
746 | j++;
|
---|
747 | } while (j < 8);
|
---|
748 | Log(("\n"));
|
---|
749 | i += 8;
|
---|
750 | } while(i != 0);
|
---|
751 | #endif
|
---|
752 | }
|
---|
753 | else
|
---|
754 | {
|
---|
755 | Assert((HDA_REG_FLAG_VALUE(pState, RIRBCTL, DMA)));
|
---|
756 | rc = PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState), pState->u64RIRBBase, pState->pu64RirbBuf, pState->cbRirbBuf);
|
---|
757 | if (RT_FAILURE(rc))
|
---|
758 | AssertRCReturn(rc, rc);
|
---|
759 | #ifdef DEBUG_CMD_BUFFER
|
---|
760 | uint8_t i = 0;
|
---|
761 | do {
|
---|
762 | Log(("hda: rirb%02x: ", i));
|
---|
763 | uint8_t j = 0;
|
---|
764 | do {
|
---|
765 | const char *prefix;
|
---|
766 | if ((i + j) == RIRBWP(pState))
|
---|
767 | prefix = "[W]";
|
---|
768 | else
|
---|
769 | prefix = " ";
|
---|
770 | Log((" %s%016lx", prefix, pState->pu64RirbBuf[i + j]));
|
---|
771 | } while (++j < 8);
|
---|
772 | Log(("\n"));
|
---|
773 | i += 8;
|
---|
774 | } while (i != 0);
|
---|
775 | #endif
|
---|
776 | }
|
---|
777 | return rc;
|
---|
778 | }
|
---|
779 |
|
---|
780 | static int hdaCORBCmdProcess(INTELHDLinkState *pState)
|
---|
781 | {
|
---|
782 | int rc;
|
---|
783 | uint8_t corbRp;
|
---|
784 | uint8_t corbWp;
|
---|
785 | uint8_t rirbWp;
|
---|
786 |
|
---|
787 | PFNCODECVERBPROCESSOR pfn = (PFNCODECVERBPROCESSOR)NULL;
|
---|
788 |
|
---|
789 | rc = hdaCmdSync(pState, true);
|
---|
790 | if (RT_FAILURE(rc))
|
---|
791 | AssertRCReturn(rc, rc);
|
---|
792 | corbRp = CORBRP(pState);
|
---|
793 | corbWp = CORBWP(pState);
|
---|
794 | rirbWp = RIRBWP(pState);
|
---|
795 | Assert((corbWp != corbRp));
|
---|
796 | Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(pState), CORBWP(pState), RIRBWP(pState)));
|
---|
797 | while (corbRp != corbWp)
|
---|
798 | {
|
---|
799 | uint32_t cmd;
|
---|
800 | uint64_t resp;
|
---|
801 | corbRp++;
|
---|
802 | cmd = pState->pu32CorbBuf[corbRp];
|
---|
803 | rc = (pState)->Codec.pfnLookup(&pState->Codec, cmd, &pfn);
|
---|
804 | if (RT_FAILURE(rc))
|
---|
805 | AssertRCReturn(rc, rc);
|
---|
806 | Assert(pfn);
|
---|
807 | (rirbWp)++;
|
---|
808 | rc = pfn(&pState->Codec, cmd, &resp);
|
---|
809 | if (RT_FAILURE(rc))
|
---|
810 | AssertRCReturn(rc, rc);
|
---|
811 | Log(("hda: verb:%08x->%016lx\n", cmd, resp));
|
---|
812 | if ( (resp & CODEC_RESPONSE_UNSOLICITED)
|
---|
813 | && !HDA_REG_FLAG_VALUE(pState, GCTL, UR))
|
---|
814 | {
|
---|
815 | Log(("hda: unexpected unsolicited response.\n"));
|
---|
816 | pState->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp;
|
---|
817 | return rc;
|
---|
818 | }
|
---|
819 | pState->pu64RirbBuf[rirbWp] = resp;
|
---|
820 | pState->u8Counter++;
|
---|
821 | if (pState->u8Counter == RINTCNT_N(pState))
|
---|
822 | break;
|
---|
823 | }
|
---|
824 | pState->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp;
|
---|
825 | pState->au32Regs[ICH6_HDA_REG_RIRBWP] = rirbWp;
|
---|
826 | rc = hdaCmdSync(pState, false);
|
---|
827 | Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(pState), CORBWP(pState), RIRBWP(pState)));
|
---|
828 | if (RIRBCTL_RIRB_RIC(pState))
|
---|
829 | {
|
---|
830 | RIRBSTS((pState)) |= HDA_REG_FIELD_FLAG_MASK(RIRBSTS,RINTFL);
|
---|
831 | pState->u8Counter = 0;
|
---|
832 | rc = hdaProcessInterrupt(pState);
|
---|
833 | }
|
---|
834 | if (RT_FAILURE(rc))
|
---|
835 | AssertRCReturn(rc, rc);
|
---|
836 | return rc;
|
---|
837 | }
|
---|
838 |
|
---|
839 | static void hdaStreamReset(INTELHDLinkState *pState, uint32_t u32Offset)
|
---|
840 | {
|
---|
841 | Log(("hda: reset of stream (%x) started\n", u32Offset));
|
---|
842 | Log(("hda: reset of stream (%x) finished\n", u32Offset));
|
---|
843 | }
|
---|
844 |
|
---|
845 |
|
---|
846 | DECLCALLBACK(int)hdaRegReadUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
847 | {
|
---|
848 | *pu32Value = 0;
|
---|
849 | return VINF_SUCCESS;
|
---|
850 | }
|
---|
851 | DECLCALLBACK(int)hdaRegWriteUnimplemented(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
852 | {
|
---|
853 | return VINF_SUCCESS;
|
---|
854 | }
|
---|
855 | /* U8 */
|
---|
856 | DECLCALLBACK(int)hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
857 | {
|
---|
858 | Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xffffff00) == 0);
|
---|
859 | return hdaRegReadU32(pState, offset, index, pu32Value);
|
---|
860 | }
|
---|
861 |
|
---|
862 | DECLCALLBACK(int)hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
863 | {
|
---|
864 | Assert(((u32Value & 0xffffff00) == 0));
|
---|
865 | return hdaRegWriteU32(pState, offset, index, u32Value);
|
---|
866 | }
|
---|
867 | /* U16 */
|
---|
868 | DECLCALLBACK(int)hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
869 | {
|
---|
870 | Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xffff0000) == 0);
|
---|
871 | return hdaRegReadU32(pState, offset, index, pu32Value);
|
---|
872 | }
|
---|
873 |
|
---|
874 | DECLCALLBACK(int)hdaRegWriteU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
875 | {
|
---|
876 | Assert(((u32Value & 0xffff0000) == 0));
|
---|
877 | return hdaRegWriteU32(pState, offset, index, u32Value);
|
---|
878 | }
|
---|
879 |
|
---|
880 | /* U24 */
|
---|
881 | DECLCALLBACK(int)hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
882 | {
|
---|
883 | Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xff000000) == 0);
|
---|
884 | return hdaRegReadU32(pState, offset, index, pu32Value);
|
---|
885 | }
|
---|
886 |
|
---|
887 | DECLCALLBACK(int)hdaRegWriteU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
888 | {
|
---|
889 | Assert(((u32Value & 0xff000000) == 0));
|
---|
890 | return hdaRegWriteU32(pState, offset, index, u32Value);
|
---|
891 | }
|
---|
892 | /* U32 */
|
---|
893 | DECLCALLBACK(int)hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
894 | {
|
---|
895 | *pu32Value = pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable;
|
---|
896 | return VINF_SUCCESS;
|
---|
897 | }
|
---|
898 |
|
---|
899 | DECLCALLBACK(int)hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
900 | {
|
---|
901 | pState->au32Regs[index] = (u32Value & s_ichIntelHDRegMap[index].writable)
|
---|
902 | | (pState->au32Regs[index] & ~s_ichIntelHDRegMap[index].writable);
|
---|
903 | return VINF_SUCCESS;
|
---|
904 | }
|
---|
905 |
|
---|
906 | DECLCALLBACK(int)hdaRegReadGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
907 | {
|
---|
908 | return hdaRegReadU32(pState, offset, index, pu32Value);
|
---|
909 | }
|
---|
910 |
|
---|
911 | DECLCALLBACK(int)hdaRegWriteGCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
912 | {
|
---|
913 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, RST))
|
---|
914 | {
|
---|
915 | /* exit reset state */
|
---|
916 | GCTL(pState) |= HDA_REG_FIELD_FLAG_MASK(GCTL, RST);
|
---|
917 | pState->fInReset = false;
|
---|
918 | }
|
---|
919 | else
|
---|
920 | {
|
---|
921 | /* enter reset state*/
|
---|
922 | if ( HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA)
|
---|
923 | || HDA_REG_FLAG_VALUE(pState, RIRBCTL, DMA))
|
---|
924 | {
|
---|
925 | Log(("hda: HDA enters in reset with DMA(RIRB:%s, CORB:%s)\n",
|
---|
926 | HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA) ? "on" : "off",
|
---|
927 | HDA_REG_FLAG_VALUE(pState, RIRBCTL, DMA) ? "on" : "off"));
|
---|
928 | }
|
---|
929 | hdaReset(ICH6_HDASTATE_2_DEVINS(pState));
|
---|
930 | GCTL(pState) &= ~HDA_REG_FIELD_FLAG_MASK(GCTL, RST);
|
---|
931 | pState->fInReset = true;
|
---|
932 | }
|
---|
933 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, FSH))
|
---|
934 | {
|
---|
935 | /* Flush: GSTS:1 set, see 6.2.6*/
|
---|
936 | GSTS(pState) |= HDA_REG_FIELD_FLAG_MASK(GSTS, FSH); /* set the flush state */
|
---|
937 | /* DPLBASE and DPUBASE, should be initialized with initial value (see 6.2.6)*/
|
---|
938 | }
|
---|
939 | return VINF_SUCCESS;
|
---|
940 | }
|
---|
941 |
|
---|
942 | DECLCALLBACK(int)hdaRegWriteSTATESTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
943 | {
|
---|
944 | uint32_t v = pState->au32Regs[index];
|
---|
945 | uint32_t nv = u32Value & ICH6_HDA_STATES_SCSF;
|
---|
946 | pState->au32Regs[index] = (v ^ nv) & v; /* write of 1 clears corresponding bit */
|
---|
947 | return VINF_SUCCESS;
|
---|
948 | }
|
---|
949 |
|
---|
950 | DECLCALLBACK(int)hdaRegReadINTSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
951 | {
|
---|
952 | uint32_t v = 0;
|
---|
953 | if ( RIRBSTS_RIRBOIS(pState)
|
---|
954 | || RIRBSTS_RINTFL(pState)
|
---|
955 | || HDA_REG_FLAG_VALUE(pState, CORBSTS, CMEI)
|
---|
956 | || STATESTS(pState))
|
---|
957 | v |= RT_BIT(30);
|
---|
958 | #define HDA_IS_STREAM_EVENT(pState, stream) \
|
---|
959 | ( (SDSTS((pState),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE)) \
|
---|
960 | || (SDSTS((pState),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE)) \
|
---|
961 | || (SDSTS((pState),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))
|
---|
962 | #define MARK_STREAM(pState, stream, v) do {(v) |= HDA_IS_STREAM_EVENT((pState),stream) ? RT_BIT((stream)) : 0;}while(0)
|
---|
963 | MARK_STREAM(pState, 0, v);
|
---|
964 | MARK_STREAM(pState, 1, v);
|
---|
965 | MARK_STREAM(pState, 2, v);
|
---|
966 | MARK_STREAM(pState, 3, v);
|
---|
967 | MARK_STREAM(pState, 4, v);
|
---|
968 | MARK_STREAM(pState, 5, v);
|
---|
969 | MARK_STREAM(pState, 6, v);
|
---|
970 | MARK_STREAM(pState, 7, v);
|
---|
971 | v |= v ? RT_BIT(31) : 0;
|
---|
972 | *pu32Value = v;
|
---|
973 | return VINF_SUCCESS;
|
---|
974 | }
|
---|
975 |
|
---|
976 | DECLCALLBACK(int)hdaRegReadGCAP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
977 | {
|
---|
978 | return hdaRegReadU16(pState, offset, index, pu32Value);
|
---|
979 | }
|
---|
980 |
|
---|
981 | DECLCALLBACK(int)hdaRegWriteCORBRP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
982 | {
|
---|
983 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(CORBRP, RST))
|
---|
984 | CORBRP(pState) = 0;
|
---|
985 | else
|
---|
986 | return hdaRegWriteU8(pState, offset, index, u32Value);
|
---|
987 | return VINF_SUCCESS;
|
---|
988 | }
|
---|
989 |
|
---|
990 | DECLCALLBACK(int)hdaRegWriteCORBCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
991 | {
|
---|
992 | int rc = hdaRegWriteU8(pState, offset, index, u32Value);
|
---|
993 | AssertRC(rc);
|
---|
994 | if ( CORBWP(pState) != CORBRP(pState)
|
---|
995 | && HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA) != 0)
|
---|
996 | return hdaCORBCmdProcess(pState);
|
---|
997 | return rc;
|
---|
998 | }
|
---|
999 |
|
---|
1000 | DECLCALLBACK(int)hdaRegWriteCORBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1001 | {
|
---|
1002 | uint32_t v = CORBSTS(pState);
|
---|
1003 | v = (v ^ u32Value) & v;
|
---|
1004 | CORBSTS(pState) = v;
|
---|
1005 | return VINF_SUCCESS;
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | DECLCALLBACK(int)hdaRegWriteCORBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1009 | {
|
---|
1010 | int rc;
|
---|
1011 | rc = hdaRegWriteU16(pState, offset, index, u32Value);
|
---|
1012 | if (RT_FAILURE(rc))
|
---|
1013 | AssertRCReturn(rc, rc);
|
---|
1014 | if (CORBWP(pState) == CORBRP(pState))
|
---|
1015 | return VINF_SUCCESS;
|
---|
1016 | if (!HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA))
|
---|
1017 | return VINF_SUCCESS;
|
---|
1018 | rc = hdaCORBCmdProcess(pState);
|
---|
1019 | return rc;
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | DECLCALLBACK(int)hdaRegReadSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
1023 | {
|
---|
1024 | return hdaRegReadU24(pState, offset, index, pu32Value);
|
---|
1025 | }
|
---|
1026 | #define HDA_STREAM_BITMASK(offset) (1 << (((offset) - 0x80) >> 5))
|
---|
1027 | #define HDA_IS_STREAM_IN_RESET(pState, offset) ((pState)->u8StreamsInReset & HDA_STREAM_BITMASK((offset)))
|
---|
1028 | DECLCALLBACK(int)hdaRegWriteSDCTL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1029 | {
|
---|
1030 | bool fOn = RT_BOOL((u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)));
|
---|
1031 | int rc = VINF_SUCCESS;
|
---|
1032 | uint64_t u64BaseDMA = 0;
|
---|
1033 | uint8_t u8Strm = 0;
|
---|
1034 | PHDABDLEDESC pBdle = NULL;
|
---|
1035 | uint32_t *pu32Lpib = 0;
|
---|
1036 | if(u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST))
|
---|
1037 | {
|
---|
1038 | Log(("hda: guest has initiated hw stream reset\n"));
|
---|
1039 | pState->u8StreamsInReset |= HDA_STREAM_BITMASK(offset);
|
---|
1040 | hdaStreamReset(pState, offset);
|
---|
1041 | HDA_REG_IND(pState, index) &= ~HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST);
|
---|
1042 | }
|
---|
1043 | else if (HDA_IS_STREAM_IN_RESET(pState, offset))
|
---|
1044 | {
|
---|
1045 | Log(("hda: guest has initiated exit of stream reset\n"));
|
---|
1046 | pState->u8StreamsInReset &= ~HDA_STREAM_BITMASK(offset);
|
---|
1047 | HDA_REG_IND(pState, index) &= ~HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST);
|
---|
1048 | }
|
---|
1049 | /*
|
---|
1050 | * Stopping streams we postpone up to reset exit to let HDA complete the tasks
|
---|
1051 | */
|
---|
1052 | switch (index)
|
---|
1053 | {
|
---|
1054 | case ICH6_HDA_REG_SD0CTL:
|
---|
1055 | u8Strm = 0;
|
---|
1056 | pBdle = &pState->stInBdle;
|
---|
1057 | pu32Lpib = &SDLPIB(pState, 0);
|
---|
1058 | AUD_set_active_in(ISD0FMT_TO_AUDIO_SELECTOR(pState), fOn);
|
---|
1059 | Log(("hda: DMA SD0CTL switched %s\n", fOn ? "on" : " off"));
|
---|
1060 | break;
|
---|
1061 | case ICH6_HDA_REG_SD4CTL:
|
---|
1062 | u8Strm = 4;
|
---|
1063 | pBdle = &pState->stOutBdle;
|
---|
1064 |
|
---|
1065 | pu32Lpib = &SDLPIB(pState, 4);
|
---|
1066 | u64BaseDMA = RT_MAKE_U64(SDBDPL(pState, 4), SDBDPU(pState, 4));
|
---|
1067 | fOn = fOn && u64BaseDMA;
|
---|
1068 | if (fOn)
|
---|
1069 | SDSTS(pState, 4) &= ~(1<<5);
|
---|
1070 | AUD_set_active_out(OSD0FMT_TO_AUDIO_SELECTOR(pState), fOn);
|
---|
1071 | Log(("hda: DMA SD4CTL switched %s\n", fOn ? "on" : " off"));
|
---|
1072 | break;
|
---|
1073 | default:
|
---|
1074 | Log(("Attempt to modify DMA state on unattached SDI(%s), ignored\n", s_ichIntelHDRegMap[index].abbrev));
|
---|
1075 | break;
|
---|
1076 | }
|
---|
1077 | if ( !fOn
|
---|
1078 | && pBdle
|
---|
1079 | && pu32Lpib)
|
---|
1080 | {
|
---|
1081 | memset(pBdle, 0, sizeof(HDABDLEDESC));
|
---|
1082 | *pu32Lpib = 0;
|
---|
1083 | hdaUpdatePosBuf(pState, u8Strm, 0);
|
---|
1084 | }
|
---|
1085 | rc = hdaRegWriteU24(pState, offset, index, u32Value);
|
---|
1086 | if (RT_FAILURE(rc))
|
---|
1087 | AssertRCReturn(rc, VINF_SUCCESS);
|
---|
1088 | return rc;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | DECLCALLBACK(int)hdaRegWriteSDSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1092 | {
|
---|
1093 | uint32_t v = HDA_REG_IND(pState, index);
|
---|
1094 | v ^= (u32Value & v);
|
---|
1095 | HDA_REG_IND(pState, index) = v;
|
---|
1096 | hdaProcessInterrupt(pState);
|
---|
1097 | #if 0
|
---|
1098 | if ( v != u32Value
|
---|
1099 | && (INTCTL_SALL(pState) & (1 << ((offset - 0x83) >> 5))))
|
---|
1100 | {
|
---|
1101 | int rc;
|
---|
1102 | rc = hdaProcessInterrupt(pState);
|
---|
1103 | if (RT_FAILURE(rc))
|
---|
1104 | AssertRCReturn(rc, rc);
|
---|
1105 | }
|
---|
1106 | #endif
|
---|
1107 | return VINF_SUCCESS;
|
---|
1108 | }
|
---|
1109 | DECLCALLBACK(int)hdaRegWriteSDLVI(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1110 | {
|
---|
1111 | int rc = hdaRegWriteU32(pState, offset, index, u32Value);
|
---|
1112 | if (RT_FAILURE(rc))
|
---|
1113 | AssertRCReturn(rc, VINF_SUCCESS);
|
---|
1114 | return rc;
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | DECLCALLBACK(int)hdaRegWriteSDFIFOW(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1118 | {
|
---|
1119 | switch (u32Value)
|
---|
1120 | {
|
---|
1121 | case HDA_SDFIFOW_8B:
|
---|
1122 | case HDA_SDFIFOW_16B:
|
---|
1123 | case HDA_SDFIFOW_32B:
|
---|
1124 | return hdaRegWriteU16(pState, offset, index, u32Value);
|
---|
1125 | default:
|
---|
1126 | Log(("hda: Attempt to store unsupported value(%x) in SDFIFOW\n", u32Value));
|
---|
1127 | return hdaRegWriteU16(pState, offset, index, HDA_SDFIFOW_32B);
|
---|
1128 | }
|
---|
1129 | return VINF_SUCCESS;
|
---|
1130 | }
|
---|
1131 | /*
|
---|
1132 | * Note this method could be called for changing value on Output Streams only (ICH6 datacheet 18.2.39)
|
---|
1133 | *
|
---|
1134 | */
|
---|
1135 | DECLCALLBACK(int)hdaRegWriteSDFIFOS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1136 | {
|
---|
1137 | switch (index)
|
---|
1138 | {
|
---|
1139 | /* SDInFIFOS is RO, n=0-3 */
|
---|
1140 | case ICH6_HDA_REG_SD0FIFOS:
|
---|
1141 | case ICH6_HDA_REG_SD1FIFOS:
|
---|
1142 | case ICH6_HDA_REG_SD2FIFOS:
|
---|
1143 | case ICH6_HDA_REG_SD3FIFOS:
|
---|
1144 | Log(("hda: Guest tries change value of FIFO size of Input Stream\n"));
|
---|
1145 | return VINF_SUCCESS;
|
---|
1146 | case ICH6_HDA_REG_SD4FIFOS:
|
---|
1147 | case ICH6_HDA_REG_SD5FIFOS:
|
---|
1148 | case ICH6_HDA_REG_SD6FIFOS:
|
---|
1149 | case ICH6_HDA_REG_SD7FIFOS:
|
---|
1150 | switch(u32Value)
|
---|
1151 | {
|
---|
1152 | case HDA_SDONFIFO_16B:
|
---|
1153 | case HDA_SDONFIFO_32B:
|
---|
1154 | case HDA_SDONFIFO_64B:
|
---|
1155 | case HDA_SDONFIFO_128B:
|
---|
1156 | case HDA_SDONFIFO_192B:
|
---|
1157 | return hdaRegWriteU16(pState, offset, index, u32Value);
|
---|
1158 |
|
---|
1159 | case HDA_SDONFIFO_256B:
|
---|
1160 | Log(("hda: 256 bit is unsupported, HDA is switched into 192B mode\n"));
|
---|
1161 | default:
|
---|
1162 | return hdaRegWriteU16(pState, offset, index, HDA_SDONFIFO_192B);
|
---|
1163 | }
|
---|
1164 | return VINF_SUCCESS;
|
---|
1165 | default:
|
---|
1166 | AssertMsgFailed(("Something wierd happens with register lookup routine"));
|
---|
1167 | }
|
---|
1168 | return VINF_SUCCESS;
|
---|
1169 | }
|
---|
1170 |
|
---|
1171 | DECLCALLBACK(int)hdaRegWriteSDBDPL(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1172 | {
|
---|
1173 | int rc = hdaRegWriteU32(pState, offset, index, u32Value);
|
---|
1174 | if (RT_FAILURE(rc))
|
---|
1175 | AssertRCReturn(rc, VINF_SUCCESS);
|
---|
1176 | return rc;
|
---|
1177 | }
|
---|
1178 |
|
---|
1179 | DECLCALLBACK(int)hdaRegWriteSDBDPU(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1180 | {
|
---|
1181 | int rc = hdaRegWriteU32(pState, offset, index, u32Value);
|
---|
1182 | if (RT_FAILURE(rc))
|
---|
1183 | AssertRCReturn(rc, VINF_SUCCESS);
|
---|
1184 | return rc;
|
---|
1185 | }
|
---|
1186 |
|
---|
1187 | DECLCALLBACK(int)hdaRegReadIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)
|
---|
1188 | {
|
---|
1189 | int rc = VINF_SUCCESS;
|
---|
1190 | /* regarding 3.4.3 we should mark IRS as busy in case CORB is active */
|
---|
1191 | if ( CORBWP(pState) != CORBRP(pState)
|
---|
1192 | || HDA_REG_FLAG_VALUE(pState, CORBCTL, DMA))
|
---|
1193 | IRS(pState) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */
|
---|
1194 |
|
---|
1195 | rc = hdaRegReadU32(pState, offset, index, pu32Value);
|
---|
1196 | return rc;
|
---|
1197 | }
|
---|
1198 |
|
---|
1199 | DECLCALLBACK(int)hdaRegWriteIRS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1200 | {
|
---|
1201 | int rc = VINF_SUCCESS;
|
---|
1202 | uint64_t resp;
|
---|
1203 | PFNCODECVERBPROCESSOR pfn = (PFNCODECVERBPROCESSOR)NULL;
|
---|
1204 | /*
|
---|
1205 | * if guest set ICB bit of IRS register HDA should process verb in IC register and
|
---|
1206 | * writes response in IR register and set IRV (valid in case of success) bit of IRS register.
|
---|
1207 | */
|
---|
1208 | if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, ICB)
|
---|
1209 | && !IRS_ICB(pState))
|
---|
1210 | {
|
---|
1211 | uint32_t cmd = IC(pState);
|
---|
1212 | if (CORBWP(pState) != CORBRP(pState))
|
---|
1213 | {
|
---|
1214 | /*
|
---|
1215 | * 3.4.3 defines behaviour of immediate Command status register.
|
---|
1216 | */
|
---|
1217 | LogRel(("hda: guest has tried process immediate verb (%x) with active CORB\n", cmd));
|
---|
1218 | return rc;
|
---|
1219 | }
|
---|
1220 | IRS(pState) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */
|
---|
1221 | Log(("hda: IC:%x\n", cmd));
|
---|
1222 | rc = pState->Codec.pfnLookup(&pState->Codec, cmd, &pfn);
|
---|
1223 | if (RT_FAILURE(rc))
|
---|
1224 | AssertRCReturn(rc, rc);
|
---|
1225 | rc = pfn(&pState->Codec, cmd, &resp);
|
---|
1226 | if (RT_FAILURE(rc))
|
---|
1227 | AssertRCReturn(rc, rc);
|
---|
1228 | IR(pState) = (uint32_t)resp;
|
---|
1229 | Log(("hda: IR:%x\n", IR(pState)));
|
---|
1230 | IRS(pState) = HDA_REG_FIELD_FLAG_MASK(IRS, IRV); /* result is ready */
|
---|
1231 | IRS(pState) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy is clear */
|
---|
1232 | return rc;
|
---|
1233 | }
|
---|
1234 | /*
|
---|
1235 | * when guest's read the response it should clean the IRV bit of the IRS register.
|
---|
1236 | */
|
---|
1237 | if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, IRV)
|
---|
1238 | && IRS_IRV(pState))
|
---|
1239 | IRS(pState) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, IRV);
|
---|
1240 | return rc;
|
---|
1241 | }
|
---|
1242 |
|
---|
1243 | DECLCALLBACK(int)hdaRegWriteRIRBWP(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1244 | {
|
---|
1245 | if (u32Value & HDA_REG_FIELD_FLAG_MASK(RIRBWP, RST))
|
---|
1246 | {
|
---|
1247 | RIRBWP(pState) = 0;
|
---|
1248 | }
|
---|
1249 | /*The rest of bits are O, see 6.2.22 */
|
---|
1250 | return VINF_SUCCESS;
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 | DECLCALLBACK(int)hdaRegWriteBase(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1254 | {
|
---|
1255 | int rc = hdaRegWriteU32(pState, offset, index, u32Value);
|
---|
1256 | if (RT_FAILURE(rc))
|
---|
1257 | AssertRCReturn(rc, rc);
|
---|
1258 | switch(index)
|
---|
1259 | {
|
---|
1260 | case ICH6_HDA_REG_CORBLBASE:
|
---|
1261 | pState->u64CORBBase &= 0xFFFFFFFF00000000ULL;
|
---|
1262 | pState->u64CORBBase |= pState->au32Regs[index];
|
---|
1263 | break;
|
---|
1264 | case ICH6_HDA_REG_CORBUBASE:
|
---|
1265 | pState->u64CORBBase &= 0x00000000FFFFFFFFULL;
|
---|
1266 | pState->u64CORBBase |= ((uint64_t)pState->au32Regs[index] << 32);
|
---|
1267 | break;
|
---|
1268 | case ICH6_HDA_REG_RIRLBASE:
|
---|
1269 | pState->u64RIRBBase &= 0xFFFFFFFF00000000ULL;
|
---|
1270 | pState->u64RIRBBase |= pState->au32Regs[index];
|
---|
1271 | break;
|
---|
1272 | case ICH6_HDA_REG_RIRUBASE:
|
---|
1273 | pState->u64RIRBBase &= 0x00000000FFFFFFFFULL;
|
---|
1274 | pState->u64RIRBBase |= ((uint64_t)pState->au32Regs[index] << 32);
|
---|
1275 | break;
|
---|
1276 | case ICH6_HDA_REG_DPLBASE:
|
---|
1277 | /* @todo: first bit has special meaning */
|
---|
1278 | pState->u64DPBase &= 0xFFFFFFFF00000000ULL;
|
---|
1279 | pState->u64DPBase |= pState->au32Regs[index];
|
---|
1280 | break;
|
---|
1281 | case ICH6_HDA_REG_DPUBASE:
|
---|
1282 | pState->u64DPBase &= 0x00000000FFFFFFFFULL;
|
---|
1283 | pState->u64DPBase |= ((uint64_t)pState->au32Regs[index] << 32);
|
---|
1284 | break;
|
---|
1285 | default:
|
---|
1286 | AssertMsgFailed(("Invalid index"));
|
---|
1287 | }
|
---|
1288 | Log(("hda: CORB base:%llx RIRB base: %llx DP base: %llx\n", pState->u64CORBBase, pState->u64RIRBBase, pState->u64DPBase));
|
---|
1289 | return rc;
|
---|
1290 | }
|
---|
1291 |
|
---|
1292 | DECLCALLBACK(int)hdaRegWriteRIRBSTS(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)
|
---|
1293 | {
|
---|
1294 | uint8_t nv = u32Value;
|
---|
1295 | uint8_t v = RIRBSTS(pState);
|
---|
1296 | RIRBSTS(pState) = (v ^ nv) & v;
|
---|
1297 |
|
---|
1298 | return hdaProcessInterrupt(pState);
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | #ifdef LOG_ENABLED
|
---|
1302 | static void dump_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA)
|
---|
1303 | {
|
---|
1304 | uint64_t addr;
|
---|
1305 | uint32_t len;
|
---|
1306 | uint32_t ioc;
|
---|
1307 | uint8_t bdle[16];
|
---|
1308 | uint32_t counter;
|
---|
1309 | uint32_t i;
|
---|
1310 | uint32_t sum = 0;
|
---|
1311 | Assert(pBdle && pBdle->u32BdleMaxCvi);
|
---|
1312 | for (i = 0; i <= pBdle->u32BdleMaxCvi; ++i)
|
---|
1313 | {
|
---|
1314 | PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), u64BaseDMA + i*16, bdle, 16);
|
---|
1315 | addr = *(uint64_t *)bdle;
|
---|
1316 | len = *(uint32_t *)&bdle[8];
|
---|
1317 | ioc = *(uint32_t *)&bdle[12];
|
---|
1318 | Log(("hda: %s bdle[%d] a:%llx, len:%d, ioc:%d\n", (i == pBdle->u32BdleCvi? "[C]": " "), i, addr, len, ioc & 0x1));
|
---|
1319 | sum += len;
|
---|
1320 | }
|
---|
1321 | Log(("hda: sum: %d\n", sum));
|
---|
1322 | for (i = 0; i < 8; ++i)
|
---|
1323 | {
|
---|
1324 | PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), (pState->u64DPBase & DPBASE_ADDR_MASK) + i*8, &counter, sizeof(&counter));
|
---|
1325 | Log(("hda: %s stream[%d] counter=%x\n", i == SDCTL_NUM(pState, 4) || i == SDCTL_NUM(pState, 0)? "[C]": " ",
|
---|
1326 | i , counter));
|
---|
1327 | }
|
---|
1328 | }
|
---|
1329 | #endif
|
---|
1330 |
|
---|
1331 | static void fetch_bd(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA)
|
---|
1332 | {
|
---|
1333 | uint8_t bdle[16];
|
---|
1334 | Assert((u64BaseDMA && pBdle && pBdle->u32BdleMaxCvi));
|
---|
1335 | PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), u64BaseDMA + pBdle->u32BdleCvi*16, bdle, 16);
|
---|
1336 | pBdle->u64BdleCviAddr = *(uint64_t *)bdle;
|
---|
1337 | pBdle->u32BdleCviLen = *(uint32_t *)&bdle[8];
|
---|
1338 | pBdle->fBdleCviIoc = (*(uint32_t *)&bdle[12]) & 0x1;
|
---|
1339 | #ifdef LOG_ENABLED
|
---|
1340 | dump_bd(pState, pBdle, u64BaseDMA);
|
---|
1341 | #endif
|
---|
1342 | }
|
---|
1343 |
|
---|
1344 | static inline uint32_t hdaCalculateTransferBufferLength(PHDABDLEDESC pBdle, uint32_t u32SoundBackendBufferBytesAvail, uint32_t u32Fifos, uint32_t u32CblLimit)
|
---|
1345 | {
|
---|
1346 | uint32_t cb2Copy;
|
---|
1347 | /*
|
---|
1348 | * Amounts of bytes depends on current position in buffer (u32BdleCviLen-u32BdleCviPos)
|
---|
1349 | */
|
---|
1350 | Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos)); /* sanity */
|
---|
1351 | cb2Copy = pBdle->u32BdleCviLen - pBdle->u32BdleCviPos;
|
---|
1352 | /*
|
---|
1353 | * we may increase the counter in range of [0, FIFOS + 1]
|
---|
1354 | */
|
---|
1355 | cb2Copy = RT_MIN(cb2Copy, u32Fifos + 1);
|
---|
1356 | Assert((u32SoundBackendBufferBytesAvail > 0));
|
---|
1357 |
|
---|
1358 | /* sanity check to avoid overriding sound backend buffer */
|
---|
1359 | cb2Copy = RT_MIN(cb2Copy, u32SoundBackendBufferBytesAvail);
|
---|
1360 | cb2Copy = RT_MIN(cb2Copy, u32CblLimit);
|
---|
1361 |
|
---|
1362 | if (cb2Copy <= pBdle->cbUnderFifoW)
|
---|
1363 | return 0;
|
---|
1364 | cb2Copy -= pBdle->cbUnderFifoW; /* forcely reserve amount of ureported bytes to copy */
|
---|
1365 | return cb2Copy;
|
---|
1366 | }
|
---|
1367 |
|
---|
1368 | static inline void hdaBackendWriteTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied, uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity)
|
---|
1369 | {
|
---|
1370 | Log(("hda:hdaBackendWriteTransferReported: cbArranged2Copy: %d, cbCopied: %d, pu32DMACursor: %d, pu32BackendBufferCapacity:%d\n",
|
---|
1371 | cbArranged2Copy, cbCopied, pu32DMACursor ? *pu32DMACursor : 0, pu32BackendBufferCapacity ? *pu32BackendBufferCapacity : 0));
|
---|
1372 | Assert((cbCopied));
|
---|
1373 | Assert((pu32BackendBufferCapacity && *pu32BackendBufferCapacity));
|
---|
1374 | /* Assertion!!! It was copied less than cbUnderFifoW
|
---|
1375 | * Probably we need to move the buffer, but it rather hard to imagine situation
|
---|
1376 | * why it may happen.
|
---|
1377 | */
|
---|
1378 | Assert((cbCopied == pBdle->cbUnderFifoW + cbArranged2Copy)); /* we assume that we write whole buffer including not reported bytes */
|
---|
1379 | if ( pBdle->cbUnderFifoW
|
---|
1380 | && pBdle->cbUnderFifoW <= cbCopied)
|
---|
1381 | Log(("hda:hdaBackendWriteTransferReported: CVI resetting cbUnderFifoW:%d(pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
1382 |
|
---|
1383 | pBdle->cbUnderFifoW -= RT_MIN(pBdle->cbUnderFifoW, cbCopied);
|
---|
1384 | Assert((!pBdle->cbUnderFifoW)); /* Assert!!! Assumption failed */
|
---|
1385 |
|
---|
1386 | /* We always increment position on DMA buffer counter because we're always reading to intermediate buffer */
|
---|
1387 | pBdle->u32BdleCviPos += cbArranged2Copy;
|
---|
1388 |
|
---|
1389 | Assert((pBdle->u32BdleCviLen >= pBdle->u32BdleCviPos && *pu32BackendBufferCapacity >= cbCopied)); /* sanity */
|
---|
1390 | /* We reports all bytes (including unreported previously) */
|
---|
1391 | *pu32DMACursor += cbCopied;
|
---|
1392 | /* reducing backend counter on amount of bytes we copied to backend */
|
---|
1393 | *pu32BackendBufferCapacity -= cbCopied;
|
---|
1394 | Log(("hda:hdaBackendWriteTransferReported: CVI(pos:%d, len:%d), pu32DMACursor: %d, pu32BackendBufferCapacity:%d\n",
|
---|
1395 | pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, *pu32DMACursor, *pu32BackendBufferCapacity));
|
---|
1396 | }
|
---|
1397 |
|
---|
1398 | static inline void hdaBackendReadTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied, uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity)
|
---|
1399 | {
|
---|
1400 | Assert((cbCopied, cbArranged2Copy));
|
---|
1401 | *pu32BackendBufferCapacity -= cbCopied;
|
---|
1402 | pBdle->u32BdleCviPos += cbCopied;
|
---|
1403 | Log(("hda:hdaBackendReadTransferReported: CVI resetting cbUnderFifoW:%d(pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
1404 | *pu32DMACursor += cbCopied + pBdle->cbUnderFifoW;
|
---|
1405 | pBdle->cbUnderFifoW = 0;
|
---|
1406 | Log(("hda:hdaBackendReadTransferReported: CVI(pos:%d, len:%d), pu32DMACursor: %d, pu32BackendBufferCapacity:%d\n",
|
---|
1407 | pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, pu32DMACursor ? *pu32DMACursor : 0, pu32BackendBufferCapacity ? *pu32BackendBufferCapacity : 0));
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 | static inline void hdaBackendTransferUnreported(INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint8_t u8Strm, uint32_t cbCopied, uint32_t *pu32BackendBufferCapacity)
|
---|
1411 | {
|
---|
1412 | Log(("hda:hdaBackendTransferUnreported: CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
1413 | pBdle->u32BdleCviPos += cbCopied;
|
---|
1414 | pBdle->cbUnderFifoW += cbCopied;
|
---|
1415 | /* In case of read transaction we're always coping from backend buffer */
|
---|
1416 | if (pu32BackendBufferCapacity)
|
---|
1417 | *pu32BackendBufferCapacity -= cbCopied;
|
---|
1418 | Log(("hda:hdaBackendTransferUnreported: CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
1419 | Assert((pBdle->cbUnderFifoW <= hdaFifoWToSz(pState, u8Strm)));
|
---|
1420 | }
|
---|
1421 | /*
|
---|
1422 | * hdaReadAudio - copies samples from Qemu Sound back-end to DMA.
|
---|
1423 | * Note: this function writes immediately to DMA buffer, but "reports bytes" when all conditions meet (FIFOW)
|
---|
1424 | */
|
---|
1425 | static uint32_t hdaReadAudio(INTELHDLinkState *pState, uint32_t *pu32Avail, bool *fStop, uint32_t u32CblLimit)
|
---|
1426 | {
|
---|
1427 | PHDABDLEDESC pBdle = &pState->stInBdle;
|
---|
1428 | uint32_t cbTransfered = 0;
|
---|
1429 | uint32_t cb2Copy = 0;
|
---|
1430 | uint32_t cbBackendCopy = 0;
|
---|
1431 |
|
---|
1432 | Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
1433 |
|
---|
1434 | cb2Copy = hdaCalculateTransferBufferLength(pBdle, *pu32Avail, SDFIFOS(pState, 0), u32CblLimit);
|
---|
1435 | if (!cb2Copy)
|
---|
1436 | {
|
---|
1437 | /* if we enter here we can't report "unreported bits" */
|
---|
1438 | *fStop = true;
|
---|
1439 | goto done;
|
---|
1440 | }
|
---|
1441 |
|
---|
1442 |
|
---|
1443 | /*
|
---|
1444 | * read from backend input line to last ureported position or at the begining.
|
---|
1445 | */
|
---|
1446 | cbBackendCopy = AUD_read (ISD0FMT_TO_AUDIO_SELECTOR(pState), pBdle->au8HdaBuffer, cb2Copy);
|
---|
1447 | /*
|
---|
1448 | * write on the HDA DMA
|
---|
1449 | */
|
---|
1450 | PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy);
|
---|
1451 |
|
---|
1452 | /* Don't see reasons why cb2Copy could differ from cbBackendCopy */
|
---|
1453 | Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */
|
---|
1454 |
|
---|
1455 | if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pState, 0))
|
---|
1456 | hdaBackendReadTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransfered, pu32Avail);
|
---|
1457 | else
|
---|
1458 | {
|
---|
1459 | hdaBackendTransferUnreported(pState, pBdle, 0, cbBackendCopy, pu32Avail);
|
---|
1460 | *fStop = true;
|
---|
1461 | }
|
---|
1462 | done:
|
---|
1463 | Assert((cbTransfered <= (SDFIFOS(pState, 0) + 1)));
|
---|
1464 | Log(("hda:ra: CVI(pos:%d, len:%d) cbTransfered: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransfered));
|
---|
1465 | return cbTransfered;
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | static uint32_t hdaWriteAudio(INTELHDLinkState *pState, uint32_t *pu32Avail, bool *fStop, uint32_t u32CblLimit)
|
---|
1469 | {
|
---|
1470 | PHDABDLEDESC pBdle = &pState->stOutBdle;
|
---|
1471 | uint32_t cbTransfered = 0;
|
---|
1472 | uint32_t cb2Copy = 0; /* local byte counter (on local buffer) */
|
---|
1473 | uint32_t cbBackendCopy = 0; /* local byte counter, how many bytes copied to backend */
|
---|
1474 |
|
---|
1475 | Log(("hda:wa: CVI(cvi:%d, pos:%d, len:%d)\n", pBdle->u32BdleCvi, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));
|
---|
1476 |
|
---|
1477 | cb2Copy = hdaCalculateTransferBufferLength(pBdle, *pu32Avail, SDFIFOS(pState, 4), u32CblLimit);
|
---|
1478 |
|
---|
1479 | /*
|
---|
1480 | * Copy from DMA to the corresponding hdaBuffer (if there exists some bytes from the previous not reported transfer we write to ''pBdle->cbUnderFifoW'' offset)
|
---|
1481 | */
|
---|
1482 | if (!cb2Copy)
|
---|
1483 | {
|
---|
1484 | *fStop = true;
|
---|
1485 | goto done;
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 | PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pState), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy);
|
---|
1489 | /*
|
---|
1490 | * Write to audio backend. we should be sure whether we have enought bytes to copy to Audio backend.
|
---|
1491 | */
|
---|
1492 | if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pState, 4))
|
---|
1493 | {
|
---|
1494 | /*
|
---|
1495 | * We feed backend with new portion of fetched samples including not reported.
|
---|
1496 | */
|
---|
1497 | cbBackendCopy = AUD_write (OSD0FMT_TO_AUDIO_SELECTOR(pState), pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW);
|
---|
1498 | hdaBackendWriteTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransfered, pu32Avail);
|
---|
1499 | }
|
---|
1500 | else
|
---|
1501 | {
|
---|
1502 | /* Not enough bytes to be processed and reported, check luck on next enterence */
|
---|
1503 | hdaBackendTransferUnreported(pState, pBdle, 4, cb2Copy, NULL);
|
---|
1504 | *fStop = true;
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | done:
|
---|
1508 | Assert((cbTransfered <= (SDFIFOS(pState, 4) + 1)));
|
---|
1509 | Log(("hda:wa: CVI(pos:%d, len:%d, cbTransfered:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransfered));
|
---|
1510 | return cbTransfered;
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 | DECLCALLBACK(int) hdaCodecReset(CODECState *pCodecState)
|
---|
1514 | {
|
---|
1515 | INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->pHDAState;
|
---|
1516 | return VINF_SUCCESS;
|
---|
1517 | }
|
---|
1518 |
|
---|
1519 | DECLCALLBACK(void) hdaTransfer(CODECState *pCodecState, ENMSOUNDSOURCE src, int avail)
|
---|
1520 | {
|
---|
1521 | bool fStop = false;
|
---|
1522 | uint64_t u64BaseDMA = 0;
|
---|
1523 | PHDABDLEDESC pBdle = NULL;
|
---|
1524 | INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->pHDAState;
|
---|
1525 | uint32_t nBytes;
|
---|
1526 | uint32_t u32Ctl;
|
---|
1527 | uint32_t *pu32Sts;
|
---|
1528 | uint8_t u8Strm;
|
---|
1529 | uint32_t *pu32Lpib;
|
---|
1530 | uint32_t u32Cbl;
|
---|
1531 | uint32_t u32Fifos;
|
---|
1532 | uint32_t u32Fifow;
|
---|
1533 | switch (src)
|
---|
1534 | {
|
---|
1535 | case PO_INDEX:
|
---|
1536 | {
|
---|
1537 | u8Strm = 4;
|
---|
1538 | u32Ctl = SDCTL(pState, 4);
|
---|
1539 | u64BaseDMA = RT_MAKE_U64(SDBDPL(pState, 4), SDBDPU(pState, 4));
|
---|
1540 | pu32Lpib = &SDLPIB(pState, 4);
|
---|
1541 | pu32Sts = &SDSTS(pState, 4);
|
---|
1542 | u32Cbl = SDLCBL(pState, 4);
|
---|
1543 | pBdle = &pState->stOutBdle;
|
---|
1544 | pBdle->u32BdleMaxCvi = SDLVI(pState, 4);
|
---|
1545 | u32Fifos = SDFIFOS(pState, 4);
|
---|
1546 | u32Fifow = hdaFifoWToSz(pState, 4);
|
---|
1547 | break;
|
---|
1548 | }
|
---|
1549 | case PI_INDEX:
|
---|
1550 | {
|
---|
1551 | u8Strm = 0;
|
---|
1552 | u32Ctl = SDCTL(pState, 0);
|
---|
1553 | pu32Lpib = &SDLPIB(pState, 0);
|
---|
1554 | pu32Sts = &SDSTS(pState, 0);
|
---|
1555 | u32Cbl = SDLCBL(pState, 0);
|
---|
1556 | u64BaseDMA = RT_MAKE_U64(SDBDPL(pState, 0), SDBDPU(pState, 0));
|
---|
1557 | pBdle = &pState->stInBdle;
|
---|
1558 | pBdle->u32BdleMaxCvi = SDLVI(pState, 0);
|
---|
1559 | u32Fifos = SDFIFOS(pState, 0);
|
---|
1560 | u32Fifow = hdaFifoWToSz(pState, 0);
|
---|
1561 | break;
|
---|
1562 | }
|
---|
1563 | default:
|
---|
1564 | return;
|
---|
1565 | }
|
---|
1566 | if ( !(u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN))
|
---|
1567 | || !avail
|
---|
1568 | || !u64BaseDMA)
|
---|
1569 | return;
|
---|
1570 | /* Fetch the Buffer Descriptor Entry (BDE). */
|
---|
1571 | fetch_bd(pState, pBdle, u64BaseDMA);
|
---|
1572 | while( avail && !fStop)
|
---|
1573 | {
|
---|
1574 | *pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY);
|
---|
1575 | Assert((avail >= 0 && (u32Cbl >= (*pu32Lpib)))); /* sanity */
|
---|
1576 | uint32_t u32CblLimit = u32Cbl - (*pu32Lpib);
|
---|
1577 | Log(("hda: CBL=%d, LPIB=%d\n", u32Cbl, *pu32Lpib));
|
---|
1578 | switch (src)
|
---|
1579 | {
|
---|
1580 | case PO_INDEX:
|
---|
1581 | nBytes = hdaWriteAudio(pState, (uint32_t *)&avail, &fStop, u32CblLimit);
|
---|
1582 | break;
|
---|
1583 | case PI_INDEX:
|
---|
1584 | nBytes = hdaReadAudio(pState, (uint32_t *)&avail, &fStop, u32CblLimit);
|
---|
1585 | break;
|
---|
1586 | default:
|
---|
1587 | nBytes = 0;
|
---|
1588 | fStop = true;
|
---|
1589 | AssertMsgFailed(("Unsupported"));
|
---|
1590 | }
|
---|
1591 | /*
|
---|
1592 | * if we're under FIFO Watermark it's expected that HDA doesn't fetch anything.
|
---|
1593 | * (ICH6 datasheet 18.2.38)
|
---|
1594 | */
|
---|
1595 | Assert(nBytes <= (u32Fifos + 1));
|
---|
1596 | *pu32Sts &= ~HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY);
|
---|
1597 | if (!pBdle->cbUnderFifoW)
|
---|
1598 | {
|
---|
1599 | *pu32Lpib += nBytes;
|
---|
1600 |
|
---|
1601 | /*
|
---|
1602 | * Assert. Overlapping of buffer counter shouldn't happen.
|
---|
1603 | */
|
---|
1604 | Assert((*pu32Lpib <= u32Cbl));
|
---|
1605 |
|
---|
1606 | /* Optionally write back the current DMA position. */
|
---|
1607 | hdaUpdatePosBuf(pState, u8Strm, *pu32Lpib);
|
---|
1608 |
|
---|
1609 | }
|
---|
1610 | /* Process end of buffer condition. */
|
---|
1611 | if ( pBdle->u32BdleCviPos == pBdle->u32BdleCviLen
|
---|
1612 | || *pu32Lpib == u32Cbl)
|
---|
1613 | {
|
---|
1614 | if ( !pBdle->cbUnderFifoW
|
---|
1615 | && pBdle->fBdleCviIoc)
|
---|
1616 | {
|
---|
1617 | /*
|
---|
1618 | * @todo - more carefully investigate BCIS flag.
|
---|
1619 | * Speech synthesis works fine on Mac Guest if this bit isn't set
|
---|
1620 | * but in general sound quality becomes lesser.
|
---|
1621 | */
|
---|
1622 | *pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS);
|
---|
1623 | /*
|
---|
1624 | * we should generate the interrupt if ICE bit of SDCTL register is set.
|
---|
1625 | */
|
---|
1626 | if (u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, ICE))
|
---|
1627 | hdaProcessInterrupt(pState);
|
---|
1628 | }
|
---|
1629 | if (*pu32Lpib == u32Cbl)
|
---|
1630 | *pu32Lpib -= u32Cbl;
|
---|
1631 | hdaUpdatePosBuf(pState, u8Strm, *pu32Lpib);
|
---|
1632 |
|
---|
1633 | if (pBdle->u32BdleCviPos == pBdle->u32BdleCviLen)
|
---|
1634 | {
|
---|
1635 | pBdle->u32BdleCviPos = 0;
|
---|
1636 | pBdle->u32BdleCvi++;
|
---|
1637 | if (pBdle->u32BdleCvi == pBdle->u32BdleMaxCvi + 1)
|
---|
1638 | pBdle->u32BdleCvi = 0;
|
---|
1639 |
|
---|
1640 | }
|
---|
1641 | fStop = true;
|
---|
1642 | }
|
---|
1643 | }
|
---|
1644 | }
|
---|
1645 |
|
---|
1646 | /**
|
---|
1647 | * Handle register read operation.
|
---|
1648 | *
|
---|
1649 | * Looks up and calls appropriate handler.
|
---|
1650 | *
|
---|
1651 | * @note: while implementation was detected so called "forgotten" or "hole" registers
|
---|
1652 | * which description is missed in RPM, datasheet or spec.
|
---|
1653 | *
|
---|
1654 | * @returns VBox status code.
|
---|
1655 | *
|
---|
1656 | * @param pState The device state structure.
|
---|
1657 | * @param uOffset Register offset in memory-mapped frame.
|
---|
1658 | * @param pv Where to fetch the value.
|
---|
1659 | * @param cb Number of bytes to write.
|
---|
1660 | * @thread EMT
|
---|
1661 | */
|
---|
1662 | PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
|
---|
1663 | {
|
---|
1664 | int rc = VINF_SUCCESS;
|
---|
1665 | PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
|
---|
1666 | uint32_t u32Offset = GCPhysAddr - pThis->hda.addrMMReg;
|
---|
1667 | int index = hdaLookup(&pThis->hda, u32Offset);
|
---|
1668 | if (pThis->hda.fInReset && index != ICH6_HDA_REG_GCTL)
|
---|
1669 | {
|
---|
1670 | Log(("hda: access to registers except GCTL is blocked while reset\n"));
|
---|
1671 | }
|
---|
1672 | if ( index == -1
|
---|
1673 | || cb > 4)
|
---|
1674 | {
|
---|
1675 | LogRel(("hda: Invalid read access @0x%x(of bytes:%d)\n", u32Offset, cb));
|
---|
1676 | }
|
---|
1677 | if (index != -1)
|
---|
1678 | {
|
---|
1679 | uint32_t mask = 0;
|
---|
1680 | uint32_t shift = (u32Offset - s_ichIntelHDRegMap[index].offset) % sizeof(uint32_t) * 8;
|
---|
1681 | uint32_t v = 0;
|
---|
1682 | switch(cb)
|
---|
1683 | {
|
---|
1684 | case 1: mask = 0x000000ff; break;
|
---|
1685 | case 2: mask = 0x0000ffff; break;
|
---|
1686 | case 3: mask = 0x00ffffff; break;
|
---|
1687 | case 4: mask = 0xffffffff; break;
|
---|
1688 | }
|
---|
1689 | mask <<= shift;
|
---|
1690 | rc = s_ichIntelHDRegMap[index].pfnRead(&pThis->hda, u32Offset, index, &v);
|
---|
1691 | *(uint32_t *)pv = (v & mask) >> shift;
|
---|
1692 | Log(("hda: read %s[%x/%x]\n", s_ichIntelHDRegMap[index].abbrev, v, *(uint32_t *)pv));
|
---|
1693 | return rc;
|
---|
1694 | }
|
---|
1695 | *(uint32_t *)pv = 0xFF;
|
---|
1696 | Log(("hda: hole at %X is accessed for read\n", u32Offset));
|
---|
1697 | return rc;
|
---|
1698 | }
|
---|
1699 |
|
---|
1700 | /**
|
---|
1701 | * Handle register write operation.
|
---|
1702 | *
|
---|
1703 | * Looks up and calls appropriate handler.
|
---|
1704 | *
|
---|
1705 | * @returns VBox status code.
|
---|
1706 | *
|
---|
1707 | * @param pState The device state structure.
|
---|
1708 | * @param uOffset Register offset in memory-mapped frame.
|
---|
1709 | * @param pv Where to fetch the value.
|
---|
1710 | * @param cb Number of bytes to write.
|
---|
1711 | * @thread EMT
|
---|
1712 | */
|
---|
1713 | PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
|
---|
1714 | {
|
---|
1715 | int rc = VINF_SUCCESS;
|
---|
1716 | PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
|
---|
1717 | uint32_t u32Offset = GCPhysAddr - pThis->hda.addrMMReg;
|
---|
1718 | int index = hdaLookup(&pThis->hda, u32Offset);
|
---|
1719 | if (pThis->hda.fInReset && index != ICH6_HDA_REG_GCTL)
|
---|
1720 | {
|
---|
1721 | Log(("hda: access to registers except GCTL is blocked while reset\n"));
|
---|
1722 | }
|
---|
1723 | if ( index == -1
|
---|
1724 | || cb > 4)
|
---|
1725 | {
|
---|
1726 | LogRel(("hda: Invalid write access @0x%x(of bytes:%d)\n", u32Offset, cb));
|
---|
1727 | }
|
---|
1728 | if (index != -1)
|
---|
1729 | {
|
---|
1730 | uint32_t v = pThis->hda.au32Regs[index];
|
---|
1731 | uint32_t mask = 0;
|
---|
1732 | uint32_t shift = (u32Offset - s_ichIntelHDRegMap[index].offset) % sizeof(uint32_t) * 8;
|
---|
1733 | switch(cb)
|
---|
1734 | {
|
---|
1735 | case 1: mask = 0xffffff00; break;
|
---|
1736 | case 2: mask = 0xffff0000; break;
|
---|
1737 | case 3: mask = 0xff000000; break;
|
---|
1738 | case 4: mask = 0x00000000; break;
|
---|
1739 | }
|
---|
1740 | mask <<= shift;
|
---|
1741 | *(uint32_t *)pv = ((v & mask) | (*(uint32_t *)pv & ~mask)) >> shift;
|
---|
1742 | rc = s_ichIntelHDRegMap[index].pfnWrite(&pThis->hda, u32Offset, index, *(uint32_t *)pv);
|
---|
1743 | Log(("hda: write %s:(%x) %x => %x\n", s_ichIntelHDRegMap[index].abbrev, *(uint32_t *)pv, v, pThis->hda.au32Regs[index]));
|
---|
1744 | return rc;
|
---|
1745 | }
|
---|
1746 | Log(("hda: hole at %X is accessed for write\n", u32Offset));
|
---|
1747 | return rc;
|
---|
1748 | }
|
---|
1749 |
|
---|
1750 | /**
|
---|
1751 | * Callback function for mapping a PCI I/O region.
|
---|
1752 | *
|
---|
1753 | * @return VBox status code.
|
---|
1754 | * @param pPciDev Pointer to PCI device.
|
---|
1755 | * Use pPciDev->pDevIns to get the device instance.
|
---|
1756 | * @param iRegion The region number.
|
---|
1757 | * @param GCPhysAddress Physical address of the region.
|
---|
1758 | * If iType is PCI_ADDRESS_SPACE_IO, this is an
|
---|
1759 | * I/O port, else it's a physical address.
|
---|
1760 | * This address is *NOT* relative
|
---|
1761 | * to pci_mem_base like earlier!
|
---|
1762 | * @param enmType One of the PCI_ADDRESS_SPACE_* values.
|
---|
1763 | */
|
---|
1764 | static DECLCALLBACK(int) hdaMap (PPCIDEVICE pPciDev, int iRegion,
|
---|
1765 | RTGCPHYS GCPhysAddress, uint32_t cb,
|
---|
1766 | PCIADDRESSSPACE enmType)
|
---|
1767 | {
|
---|
1768 | int rc;
|
---|
1769 | PPDMDEVINS pDevIns = pPciDev->pDevIns;
|
---|
1770 | RTIOPORT Port = (RTIOPORT)GCPhysAddress;
|
---|
1771 | PCIINTELHDLinkState *pThis = PCIDEV_2_ICH6_HDASTATE(pPciDev);
|
---|
1772 |
|
---|
1773 | Assert(enmType == PCI_ADDRESS_SPACE_MEM);
|
---|
1774 | rc = PDMDevHlpMMIORegister(pPciDev->pDevIns, GCPhysAddress, cb, 0,
|
---|
1775 | hdaMMIOWrite, hdaMMIORead, NULL, "ICH6_HDA");
|
---|
1776 |
|
---|
1777 | if (RT_FAILURE(rc))
|
---|
1778 | return rc;
|
---|
1779 |
|
---|
1780 | pThis->hda.addrMMReg = GCPhysAddress;
|
---|
1781 | return VINF_SUCCESS;
|
---|
1782 | }
|
---|
1783 |
|
---|
1784 | /**
|
---|
1785 | * Saves a state of the HDA device.
|
---|
1786 | *
|
---|
1787 | * @returns VBox status code.
|
---|
1788 | * @param pDevIns The device instance.
|
---|
1789 | * @param pSSMHandle The handle to save the state to.
|
---|
1790 | */
|
---|
1791 | static DECLCALLBACK(int) hdaSaveExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
|
---|
1792 | {
|
---|
1793 | PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
|
---|
1794 | /* Save Codec nodes states */
|
---|
1795 | codecSaveState(&pThis->hda.Codec, pSSMHandle);
|
---|
1796 | /* Save MMIO registers */
|
---|
1797 | SSMR3PutMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs));
|
---|
1798 | /* Save HDA dma counters */
|
---|
1799 | SSMR3PutMem (pSSMHandle, &pThis->hda.stOutBdle, sizeof (HDABDLEDESC));
|
---|
1800 | SSMR3PutMem (pSSMHandle, &pThis->hda.stMicBdle, sizeof (HDABDLEDESC));
|
---|
1801 | SSMR3PutMem (pSSMHandle, &pThis->hda.stInBdle, sizeof (HDABDLEDESC));
|
---|
1802 | return VINF_SUCCESS;
|
---|
1803 | }
|
---|
1804 |
|
---|
1805 | /**
|
---|
1806 | * Loads a saved HDA device state.
|
---|
1807 | *
|
---|
1808 | * @returns VBox status code.
|
---|
1809 | * @param pDevIns The device instance.
|
---|
1810 | * @param pSSMHandle The handle to the saved state.
|
---|
1811 | * @param uVersion The data unit version number.
|
---|
1812 | * @param uPass The data pass.
|
---|
1813 | */
|
---|
1814 | static DECLCALLBACK(int) hdaLoadExec (PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle,
|
---|
1815 | uint32_t uVersion, uint32_t uPass)
|
---|
1816 | {
|
---|
1817 | PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
|
---|
1818 | /* Load Codec nodes states */
|
---|
1819 | AssertMsgReturn (uVersion == HDA_SSM_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
|
---|
1820 | Assert (uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
1821 |
|
---|
1822 | codecLoadState(&pThis->hda.Codec, pSSMHandle);
|
---|
1823 | /* Load MMIO registers */
|
---|
1824 | SSMR3GetMem (pSSMHandle, pThis->hda.au32Regs, sizeof (pThis->hda.au32Regs));
|
---|
1825 | /* Load HDA dma counters */
|
---|
1826 | SSMR3GetMem (pSSMHandle, &pThis->hda.stOutBdle, sizeof (HDABDLEDESC));
|
---|
1827 | SSMR3GetMem (pSSMHandle, &pThis->hda.stMicBdle, sizeof (HDABDLEDESC));
|
---|
1828 | SSMR3GetMem (pSSMHandle, &pThis->hda.stInBdle, sizeof (HDABDLEDESC));
|
---|
1829 |
|
---|
1830 | AUD_set_active_in(ISD0FMT_TO_AUDIO_SELECTOR(&pThis->hda), SDCTL(&pThis->hda, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
1831 | AUD_set_active_out(OSD0FMT_TO_AUDIO_SELECTOR(&pThis->hda), SDCTL(&pThis->hda, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));
|
---|
1832 |
|
---|
1833 | pThis->hda.u64CORBBase = CORBLBASE(&pThis->hda);
|
---|
1834 | pThis->hda.u64CORBBase |= ((uint64_t)CORBUBASE(&pThis->hda)) << 32;
|
---|
1835 | pThis->hda.u64RIRBBase = RIRLBASE(&pThis->hda);
|
---|
1836 | pThis->hda.u64RIRBBase |= ((uint64_t)RIRUBASE(&pThis->hda)) << 32;
|
---|
1837 | pThis->hda.u64DPBase = DPLBASE(&pThis->hda);
|
---|
1838 | pThis->hda.u64DPBase |= ((uint64_t)DPUBASE(&pThis->hda)) << 32;
|
---|
1839 | return VINF_SUCCESS;
|
---|
1840 | }
|
---|
1841 |
|
---|
1842 | /**
|
---|
1843 | * Reset notification.
|
---|
1844 | *
|
---|
1845 | * @returns VBox status.
|
---|
1846 | * @param pDevIns The device instance data.
|
---|
1847 | *
|
---|
1848 | * @remark The original sources didn't install a reset handler, but it seems to
|
---|
1849 | * make sense to me so we'll do it.
|
---|
1850 | */
|
---|
1851 | static DECLCALLBACK(void) hdaReset (PPDMDEVINS pDevIns)
|
---|
1852 | {
|
---|
1853 | PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
|
---|
1854 | GCAP(&pThis->hda) = 0x4401; /* see 6.2.1 */
|
---|
1855 | VMIN(&pThis->hda) = 0x00; /* see 6.2.2 */
|
---|
1856 | VMAJ(&pThis->hda) = 0x01; /* see 6.2.3 */
|
---|
1857 | VMAJ(&pThis->hda) = 0x01; /* see 6.2.3 */
|
---|
1858 | OUTPAY(&pThis->hda) = 0x003C; /* see 6.2.4 */
|
---|
1859 | INPAY(&pThis->hda) = 0x001D; /* see 6.2.5 */
|
---|
1860 | pThis->hda.au32Regs[ICH6_HDA_REG_CORBSIZE] = 0x42; /* see 6.2.1 */
|
---|
1861 | pThis->hda.au32Regs[ICH6_HDA_REG_RIRBSIZE] = 0x42; /* see 6.2.1 */
|
---|
1862 | CORBRP(&pThis->hda) = 0x0;
|
---|
1863 | RIRBWP(&pThis->hda) = 0x0;
|
---|
1864 |
|
---|
1865 | Log(("hda: inter HDA reset.\n"));
|
---|
1866 | pThis->hda.cbCorbBuf = 256 * sizeof(uint32_t);
|
---|
1867 |
|
---|
1868 | if (pThis->hda.pu32CorbBuf)
|
---|
1869 | memset(pThis->hda.pu32CorbBuf, 0, pThis->hda.cbCorbBuf);
|
---|
1870 | else
|
---|
1871 | pThis->hda.pu32CorbBuf = (uint32_t *)RTMemAllocZ(pThis->hda.cbCorbBuf);
|
---|
1872 |
|
---|
1873 | pThis->hda.cbRirbBuf = 256 * sizeof(uint64_t);
|
---|
1874 | if (pThis->hda.pu64RirbBuf)
|
---|
1875 | memset(pThis->hda.pu64RirbBuf, 0, pThis->hda.cbRirbBuf);
|
---|
1876 | else
|
---|
1877 | pThis->hda.pu64RirbBuf = (uint64_t *)RTMemAllocZ(pThis->hda.cbRirbBuf);
|
---|
1878 |
|
---|
1879 | /* According to ICH6 datasheet, 0x40000 is default value for stream descriptor register 23:20
|
---|
1880 | * bits are reserved for stream number 18.2.33 */
|
---|
1881 | SDCTL(&pThis->hda, 0) = 0x40000;
|
---|
1882 | SDCTL(&pThis->hda, 1) = 0x40000;
|
---|
1883 | SDCTL(&pThis->hda, 2) = 0x40000;
|
---|
1884 | SDCTL(&pThis->hda, 3) = 0x40000;
|
---|
1885 | SDCTL(&pThis->hda, 4) = 0x40000;
|
---|
1886 | SDCTL(&pThis->hda, 5) = 0x40000;
|
---|
1887 | SDCTL(&pThis->hda, 6) = 0x40000;
|
---|
1888 | SDCTL(&pThis->hda, 7) = 0x40000;
|
---|
1889 |
|
---|
1890 | /* ICH6 defines default values (0x77 for input and 0xBF for output descriptors) of FIFO size. 18.2.39 */
|
---|
1891 | SDFIFOS(&pThis->hda, 0) = HDA_SDINFIFO_120B;
|
---|
1892 | SDFIFOS(&pThis->hda, 1) = HDA_SDINFIFO_120B;
|
---|
1893 | SDFIFOS(&pThis->hda, 2) = HDA_SDINFIFO_120B;
|
---|
1894 | SDFIFOS(&pThis->hda, 3) = HDA_SDINFIFO_120B;
|
---|
1895 |
|
---|
1896 | SDFIFOS(&pThis->hda, 4) = HDA_SDONFIFO_192B;
|
---|
1897 | SDFIFOS(&pThis->hda, 5) = HDA_SDONFIFO_192B;
|
---|
1898 | SDFIFOS(&pThis->hda, 6) = HDA_SDONFIFO_192B;
|
---|
1899 | SDFIFOS(&pThis->hda, 7) = HDA_SDONFIFO_192B;
|
---|
1900 |
|
---|
1901 | SDFIFOW(&pThis->hda, 0) = HDA_SDFIFOW_8B;
|
---|
1902 | SDFIFOW(&pThis->hda, 4) = HDA_SDFIFOW_32B;
|
---|
1903 |
|
---|
1904 | /* emulateion of codec "wake up" HDA spec (5.5.1 and 6.5)*/
|
---|
1905 | STATESTS(&pThis->hda) = 0x1;
|
---|
1906 |
|
---|
1907 | Log(("hda: reset finished\n"));
|
---|
1908 | }
|
---|
1909 |
|
---|
1910 | /**
|
---|
1911 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
1912 | */
|
---|
1913 | static DECLCALLBACK(void *) hdaQueryInterface (struct PDMIBASE *pInterface,
|
---|
1914 | const char *pszIID)
|
---|
1915 | {
|
---|
1916 | PCIINTELHDLinkState *pThis = RT_FROM_MEMBER(pInterface, PCIINTELHDLinkState, hda.IBase);
|
---|
1917 | Assert(&pThis->hda.IBase == pInterface);
|
---|
1918 |
|
---|
1919 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->hda.IBase);
|
---|
1920 | return NULL;
|
---|
1921 | }
|
---|
1922 |
|
---|
1923 | //#define HDA_AS_PCI_EXPRESS
|
---|
1924 |
|
---|
1925 | /**
|
---|
1926 | * @interface_method_impl{PDMDEVREG,pfnConstruct}
|
---|
1927 | */
|
---|
1928 | static DECLCALLBACK(int) hdaConstruct (PPDMDEVINS pDevIns, int iInstance,
|
---|
1929 | PCFGMNODE pCfgHandle)
|
---|
1930 | {
|
---|
1931 | PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
|
---|
1932 | INTELHDLinkState *s = &pThis->hda;
|
---|
1933 | int rc;
|
---|
1934 |
|
---|
1935 | Assert(iInstance == 0);
|
---|
1936 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
1937 |
|
---|
1938 | /*
|
---|
1939 | * Validations.
|
---|
1940 | */
|
---|
1941 | if (!CFGMR3AreValuesValid (pCfgHandle, "\0"))
|
---|
1942 | return PDMDEV_SET_ERROR (pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
|
---|
1943 | N_ ("Invalid configuration for the INTELHD device"));
|
---|
1944 |
|
---|
1945 | // ** @todo r=michaln: This device may need R0/RC enabling, especially if guests
|
---|
1946 | // poll some register(s).
|
---|
1947 |
|
---|
1948 | /*
|
---|
1949 | * Initialize data (most of it anyway).
|
---|
1950 | */
|
---|
1951 | s->pDevIns = pDevIns;
|
---|
1952 | /* IBase */
|
---|
1953 | s->IBase.pfnQueryInterface = hdaQueryInterface;
|
---|
1954 |
|
---|
1955 | /* PCI Device (the assertions will be removed later) */
|
---|
1956 | #if defined(VBOX_WITH_HP_HDA)
|
---|
1957 | /* Linux kernel has whitelist for MSI-enabled HDA, this card seems to be there. */
|
---|
1958 | PCIDevSetVendorId (&pThis->dev, 0x103c); /* HP. */
|
---|
1959 | PCIDevSetDeviceId (&pThis->dev, 0x30f7); /* HP Pavilion dv4t-1300 */
|
---|
1960 | #elif defined(VBOX_WITH_INTEL_HDA)
|
---|
1961 | PCIDevSetVendorId (&pThis->dev, 0x8086); /* 00 ro - intel. */
|
---|
1962 | PCIDevSetDeviceId (&pThis->dev, 0x2668); /* 02 ro - 82801 / 82801aa(?). */
|
---|
1963 | #elif defined(VBOX_WITH_NVIDIA_HDA)
|
---|
1964 | PCIDevSetVendorId (&pThis->dev, 0x10de); /* nVidia */
|
---|
1965 | PCIDevSetDeviceId (&pThis->dev, 0x0ac0); /* HDA */
|
---|
1966 | #else
|
---|
1967 | # error "Please specify your HDA device vendor/device IDs"
|
---|
1968 | #endif
|
---|
1969 | PCIDevSetCommand (&pThis->dev, 0x0000); /* 04 rw,ro - pcicmd. */
|
---|
1970 | PCIDevSetStatus (&pThis->dev, VBOX_PCI_STATUS_CAP_LIST); /* 06 rwc?,ro? - pcists. */
|
---|
1971 | PCIDevSetRevisionId (&pThis->dev, 0x01); /* 08 ro - rid. */
|
---|
1972 | PCIDevSetClassProg (&pThis->dev, 0x00); /* 09 ro - pi. */
|
---|
1973 | PCIDevSetClassSub (&pThis->dev, 0x03); /* 0a ro - scc; 03 == HDA. */
|
---|
1974 | PCIDevSetClassBase (&pThis->dev, 0x04); /* 0b ro - bcc; 04 == multimedia. */
|
---|
1975 | PCIDevSetHeaderType (&pThis->dev, 0x00); /* 0e ro - headtyp. */
|
---|
1976 | PCIDevSetBaseAddress (&pThis->dev, 0, /* 10 rw - MMIO */
|
---|
1977 | false /* fIoSpace */, false /* fPrefetchable */, true /* f64Bit */, 0x00000000);
|
---|
1978 | PCIDevSetInterruptLine (&pThis->dev, 0x00); /* 3c rw. */
|
---|
1979 | PCIDevSetInterruptPin (&pThis->dev, 0x01); /* 3d ro - INTA#. */
|
---|
1980 |
|
---|
1981 | #if defined(HDA_AS_PCI_EXPRESS)
|
---|
1982 | PCIDevSetCapabilityList (&pThis->dev, 0x80);
|
---|
1983 | #elif defined(VBOX_WITH_MSI_DEVICES)
|
---|
1984 | PCIDevSetCapabilityList (&pThis->dev, 0x60);
|
---|
1985 | #else
|
---|
1986 | PCIDevSetCapabilityList (&pThis->dev, 0x50); /* ICH6 datasheet 18.1.16 */
|
---|
1987 | #endif
|
---|
1988 |
|
---|
1989 | //** @todo r=michaln: If there are really no PCIDevSetXx for these, the meaning
|
---|
1990 | // of these values needs to be properly documented!
|
---|
1991 | /* HDCTL off 0x40 bit 0 selects signaling mode (1-HDA, 0 - Ac97) 18.1.19 */
|
---|
1992 | PCIDevSetByte(&pThis->dev, 0x40, 0x01);
|
---|
1993 |
|
---|
1994 | /* Power Management */
|
---|
1995 | PCIDevSetByte(&pThis->dev, 0x50 + 0, VBOX_PCI_CAP_ID_PM);
|
---|
1996 | PCIDevSetByte(&pThis->dev, 0x50 + 1, 0x0); /* next */
|
---|
1997 | PCIDevSetWord(&pThis->dev, 0x50 + 2, VBOX_PCI_PM_CAP_DSI | 0x02 /* version, PM1.1 */ );
|
---|
1998 |
|
---|
1999 | #ifdef HDA_AS_PCI_EXPRESS
|
---|
2000 | /* PCI Express */
|
---|
2001 | PCIDevSetByte (&pThis->dev, 0x80 + 0, VBOX_PCI_CAP_ID_EXP); /* PCI_Express */
|
---|
2002 | PCIDevSetByte (&pThis->dev, 0x80 + 1, 0x60); /* next */
|
---|
2003 | /* Device flags */
|
---|
2004 | PCIDevSetWord (&pThis->dev, 0x80 + 2,
|
---|
2005 | /* version */ 0x1 |
|
---|
2006 | /* Root Complex Integrated Endpoint */ (VBOX_PCI_EXP_TYPE_ROOT_INT_EP << 4) |
|
---|
2007 | /* MSI */ (100) << 9
|
---|
2008 | );
|
---|
2009 | /* Device capabilities */
|
---|
2010 | PCIDevSetDWord (&pThis->dev, 0x80 + 4, VBOX_PCI_EXP_DEVCAP_FLRESET);
|
---|
2011 | /* Device control */
|
---|
2012 | PCIDevSetWord (&pThis->dev, 0x80 + 8, 0);
|
---|
2013 | /* Device status */
|
---|
2014 | PCIDevSetWord (&pThis->dev, 0x80 + 10, 0);
|
---|
2015 | /* Link caps */
|
---|
2016 | PCIDevSetDWord (&pThis->dev, 0x80 + 12, 0);
|
---|
2017 | /* Link control */
|
---|
2018 | PCIDevSetWord (&pThis->dev, 0x80 + 16, 0);
|
---|
2019 | /* Link status */
|
---|
2020 | PCIDevSetWord (&pThis->dev, 0x80 + 18, 0);
|
---|
2021 | /* Slot capabilities */
|
---|
2022 | PCIDevSetDWord (&pThis->dev, 0x80 + 20, 0);
|
---|
2023 | /* Slot control */
|
---|
2024 | PCIDevSetWord (&pThis->dev, 0x80 + 24, 0);
|
---|
2025 | /* Slot status */
|
---|
2026 | PCIDevSetWord (&pThis->dev, 0x80 + 26, 0);
|
---|
2027 | /* Root control */
|
---|
2028 | PCIDevSetWord (&pThis->dev, 0x80 + 28, 0);
|
---|
2029 | /* Root capabilities */
|
---|
2030 | PCIDevSetWord (&pThis->dev, 0x80 + 30, 0);
|
---|
2031 | /* Root status */
|
---|
2032 | PCIDevSetDWord (&pThis->dev, 0x80 + 32, 0);
|
---|
2033 | /* Device capabilities 2 */
|
---|
2034 | PCIDevSetDWord (&pThis->dev, 0x80 + 36, 0);
|
---|
2035 | /* Device control 2 */
|
---|
2036 | PCIDevSetQWord (&pThis->dev, 0x80 + 40, 0);
|
---|
2037 | /* Link control 2 */
|
---|
2038 | PCIDevSetQWord (&pThis->dev, 0x80 + 48, 0);
|
---|
2039 | /* Slot control 2 */
|
---|
2040 | PCIDevSetWord (&pThis->dev, 0x80 + 56, 0);
|
---|
2041 | #endif
|
---|
2042 |
|
---|
2043 | /*
|
---|
2044 | * Register the PCI device.
|
---|
2045 | */
|
---|
2046 | rc = PDMDevHlpPCIRegister (pDevIns, &pThis->dev);
|
---|
2047 | if (RT_FAILURE (rc))
|
---|
2048 | return rc;
|
---|
2049 |
|
---|
2050 | rc = PDMDevHlpPCIIORegionRegister (pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM,
|
---|
2051 | hdaMap);
|
---|
2052 | if (RT_FAILURE (rc))
|
---|
2053 | return rc;
|
---|
2054 |
|
---|
2055 | #ifdef VBOX_WITH_MSI_DEVICES
|
---|
2056 | PDMMSIREG aMsiReg;
|
---|
2057 |
|
---|
2058 | RT_ZERO(aMsiReg);
|
---|
2059 | aMsiReg.cMsiVectors = 1;
|
---|
2060 | aMsiReg.iMsiCapOffset = 0x60;
|
---|
2061 | aMsiReg.iMsiNextOffset = 0x50;
|
---|
2062 | rc = PDMDevHlpPCIRegisterMsi(pDevIns, &aMsiReg);
|
---|
2063 | if (RT_FAILURE (rc))
|
---|
2064 | {
|
---|
2065 | LogRel(("Chipset cannot do MSI: %Rrc\n", rc));
|
---|
2066 | PCIDevSetCapabilityList (&pThis->dev, 0x50);
|
---|
2067 | }
|
---|
2068 | #endif
|
---|
2069 |
|
---|
2070 | rc = PDMDevHlpSSMRegister (pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hdaSaveExec, hdaLoadExec);
|
---|
2071 | if (RT_FAILURE (rc))
|
---|
2072 | return rc;
|
---|
2073 |
|
---|
2074 | /*
|
---|
2075 | * Attach driver.
|
---|
2076 | */
|
---|
2077 | rc = PDMDevHlpDriverAttach (pDevIns, 0, &s->IBase,
|
---|
2078 | &s->pDrvBase, "Audio Driver Port");
|
---|
2079 | if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
2080 | Log (("hda: No attached driver!\n"));
|
---|
2081 | else if (RT_FAILURE (rc))
|
---|
2082 | {
|
---|
2083 | AssertMsgFailed (("Failed to attach INTELHD LUN #0! rc=%Rrc\n", rc));
|
---|
2084 | return rc;
|
---|
2085 | }
|
---|
2086 |
|
---|
2087 |
|
---|
2088 |
|
---|
2089 | pThis->hda.Codec.pHDAState = (void *)&pThis->hda;
|
---|
2090 | rc = codecConstruct(&pThis->hda.Codec, /* ALC885_CODEC */ STAC9220_CODEC);
|
---|
2091 | if (RT_FAILURE(rc))
|
---|
2092 | AssertRCReturn(rc, rc);
|
---|
2093 |
|
---|
2094 | /* ICH6 datasheet defines 0 values for SVID and SID (18.1.14-15), which together with values returned for
|
---|
2095 | verb F20 should provide device/codec recognition. */
|
---|
2096 | Assert(pThis->hda.Codec.u16VendorId);
|
---|
2097 | Assert(pThis->hda.Codec.u16DeviceId);
|
---|
2098 | PCIDevSetSubSystemVendorId (&pThis->dev, pThis->hda.Codec.u16VendorId); /* 2c ro - intel.) */
|
---|
2099 | PCIDevSetSubSystemId (&pThis->dev, pThis->hda.Codec.u16DeviceId); /* 2e ro. */
|
---|
2100 |
|
---|
2101 | hdaReset (pDevIns);
|
---|
2102 | pThis->hda.Codec.id = 0;
|
---|
2103 | pThis->hda.Codec.pfnTransfer = hdaTransfer;
|
---|
2104 | pThis->hda.Codec.pfnReset = hdaCodecReset;
|
---|
2105 | /*
|
---|
2106 | * 18.2.6,7 defines that values of this registers might be cleared on power on/reset
|
---|
2107 | * hdaReset shouldn't affects these registers.
|
---|
2108 | */
|
---|
2109 | WAKEEN(&pThis->hda) = 0x0;
|
---|
2110 | STATESTS(&pThis->hda) = 0x0;
|
---|
2111 |
|
---|
2112 | return VINF_SUCCESS;
|
---|
2113 | }
|
---|
2114 |
|
---|
2115 | /**
|
---|
2116 | * @interface_method_impl{PDMDEVREG,pfnDestruct}
|
---|
2117 | */
|
---|
2118 | static DECLCALLBACK(int) hdaDestruct (PPDMDEVINS pDevIns)
|
---|
2119 | {
|
---|
2120 | PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *);
|
---|
2121 |
|
---|
2122 | int rc = codecDestruct(&pThis->hda.Codec);
|
---|
2123 | AssertRC(rc);
|
---|
2124 | if (pThis->hda.pu32CorbBuf)
|
---|
2125 | RTMemFree(pThis->hda.pu32CorbBuf);
|
---|
2126 | if (pThis->hda.pu64RirbBuf)
|
---|
2127 | RTMemFree(pThis->hda.pu64RirbBuf);
|
---|
2128 | return VINF_SUCCESS;
|
---|
2129 | }
|
---|
2130 |
|
---|
2131 | /**
|
---|
2132 | * The device registration structure.
|
---|
2133 | */
|
---|
2134 | const PDMDEVREG g_DeviceICH6_HDA =
|
---|
2135 | {
|
---|
2136 | /* u32Version */
|
---|
2137 | PDM_DEVREG_VERSION,
|
---|
2138 | /* szName */
|
---|
2139 | "hda",
|
---|
2140 | /* szRCMod */
|
---|
2141 | "",
|
---|
2142 | /* szR0Mod */
|
---|
2143 | "",
|
---|
2144 | /* pszDescription */
|
---|
2145 | "ICH IntelHD Audio Controller",
|
---|
2146 | /* fFlags */
|
---|
2147 | PDM_DEVREG_FLAGS_DEFAULT_BITS,
|
---|
2148 | /* fClass */
|
---|
2149 | PDM_DEVREG_CLASS_AUDIO,
|
---|
2150 | /* cMaxInstances */
|
---|
2151 | 1,
|
---|
2152 | /* cbInstance */
|
---|
2153 | sizeof(PCIINTELHDLinkState),
|
---|
2154 | /* pfnConstruct */
|
---|
2155 | hdaConstruct,
|
---|
2156 | /* pfnDestruct */
|
---|
2157 | hdaDestruct,
|
---|
2158 | /* pfnRelocate */
|
---|
2159 | NULL,
|
---|
2160 | /* pfnIOCtl */
|
---|
2161 | NULL,
|
---|
2162 | /* pfnPowerOn */
|
---|
2163 | NULL,
|
---|
2164 | /* pfnReset */
|
---|
2165 | hdaReset,
|
---|
2166 | /* pfnSuspend */
|
---|
2167 | NULL,
|
---|
2168 | /* pfnResume */
|
---|
2169 | NULL,
|
---|
2170 | /* pfnAttach */
|
---|
2171 | NULL,
|
---|
2172 | /* pfnDetach */
|
---|
2173 | NULL,
|
---|
2174 | /* pfnQueryInterface. */
|
---|
2175 | NULL,
|
---|
2176 | /* pfnInitComplete */
|
---|
2177 | NULL,
|
---|
2178 | /* pfnPowerOff */
|
---|
2179 | NULL,
|
---|
2180 | /* pfnSoftReset */
|
---|
2181 | NULL,
|
---|
2182 | /* u32VersionEnd */
|
---|
2183 | PDM_DEVREG_VERSION
|
---|
2184 | };
|
---|