Changeset 44641 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Feb 11, 2013 7:39:36 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp
r44640 r44641 62 62 #define HDA_NREGS 112 63 63 /* Registers */ 64 #define HDA_REG_IND_NAME(x) ICH6_HDA_REG_##x65 #define HDA_REG_FIELD_NAME(reg, x) ICH6_HDA_##reg##_##x66 #define HDA_REG_FIELD_MASK(reg, x) ICH6_HDA_##reg##_##x##_MASK67 #define HDA_REG_FIELD_FLAG_MASK(reg, x) RT_BIT(ICH6_HDA_##reg##_##x##_SHIFT)68 #define HDA_REG_FIELD_SHIFT(reg, x) ICH6_HDA_##reg##_##x##_SHIFT69 #define HDA_REG_IND(p State, x) ((pState)->au32Regs[(x)])70 #define HDA_REG(p State, x) (HDA_REG_IND((pState), HDA_REG_IND_NAME(x)))71 #define HDA_REG_VALUE(p State, reg, val) (HDA_REG((pState),reg) & (((HDA_REG_FIELD_MASK(reg, val))) << (HDA_REG_FIELD_SHIFT(reg, val))))72 #define HDA_REG_FLAG_VALUE(p State, reg, val) (HDA_REG((pState),reg) & (((HDA_REG_FIELD_FLAG_MASK(reg, val)))))73 #define HDA_REG_SVALUE(p State, reg, val) (HDA_REG_VALUE(pState, reg, val) >> (HDA_REG_FIELD_SHIFT(reg, val)))64 #define HDA_REG_IND_NAME(x) ICH6_HDA_REG_##x 65 #define HDA_REG_FIELD_NAME(reg, x) ICH6_HDA_##reg##_##x 66 #define HDA_REG_FIELD_MASK(reg, x) ICH6_HDA_##reg##_##x##_MASK 67 #define HDA_REG_FIELD_FLAG_MASK(reg, x) RT_BIT(ICH6_HDA_##reg##_##x##_SHIFT) 68 #define HDA_REG_FIELD_SHIFT(reg, x) ICH6_HDA_##reg##_##x##_SHIFT 69 #define HDA_REG_IND(pThis, x) ((pThis)->au32Regs[(x)]) 70 #define HDA_REG(pThis, x) (HDA_REG_IND((pThis), HDA_REG_IND_NAME(x))) 71 #define HDA_REG_VALUE(pThis, reg, val) (HDA_REG((pThis),reg) & (((HDA_REG_FIELD_MASK(reg, val))) << (HDA_REG_FIELD_SHIFT(reg, val)))) 72 #define HDA_REG_FLAG_VALUE(pThis, reg, val) (HDA_REG((pThis),reg) & (((HDA_REG_FIELD_FLAG_MASK(reg, val))))) 73 #define HDA_REG_SVALUE(pThis, reg, val) (HDA_REG_VALUE(pThis, reg, val) >> (HDA_REG_FIELD_SHIFT(reg, val))) 74 74 75 75 #define ICH6_HDA_REG_GCAP 0 /* range 0x00-0x01*/ 76 #define GCAP(p State) (HDA_REG((pState), GCAP))76 #define GCAP(pThis) (HDA_REG((pThis), GCAP)) 77 77 /* GCAP HDASpec 3.3.2 This macro encodes the following information about HDA in a compact manner: 78 78 * oss (15:12) - number of output streams supported … … 89 89 | ((b64sup) & 1)) 90 90 #define ICH6_HDA_REG_VMIN 1 /* range 0x02 */ 91 #define VMIN(p State) (HDA_REG((pState), VMIN))91 #define VMIN(pThis) (HDA_REG((pThis), VMIN)) 92 92 93 93 #define ICH6_HDA_REG_VMAJ 2 /* range 0x03 */ 94 #define VMAJ(p State) (HDA_REG((pState), VMAJ))94 #define VMAJ(pThis) (HDA_REG((pThis), VMAJ)) 95 95 96 96 #define ICH6_HDA_REG_OUTPAY 3 /* range 0x04-0x05 */ 97 #define OUTPAY(p State) (HDA_REG((pState), OUTPAY))97 #define OUTPAY(pThis) (HDA_REG((pThis), OUTPAY)) 98 98 99 99 #define ICH6_HDA_REG_INPAY 4 /* range 0x06-0x07 */ 100 #define INPAY(p State) (HDA_REG((pState), INPAY))100 #define INPAY(pThis) (HDA_REG((pThis), INPAY)) 101 101 102 102 #define ICH6_HDA_REG_GCTL (5) … … 104 104 #define ICH6_HDA_GCTL_FSH_SHIFT (1) 105 105 #define ICH6_HDA_GCTL_UR_SHIFT (8) 106 #define GCTL(p State) (HDA_REG((pState), GCTL))106 #define GCTL(pThis) (HDA_REG((pThis), GCTL)) 107 107 108 108 #define ICH6_HDA_REG_WAKEEN 6 /* 0x0C */ 109 #define WAKEEN(p State) (HDA_REG((pState), WAKEEN))109 #define WAKEEN(pThis) (HDA_REG((pThis), WAKEEN)) 110 110 111 111 #define ICH6_HDA_REG_STATESTS 7 /* range 0x0E */ 112 #define STATESTS(p State) (HDA_REG((pState), STATESTS))112 #define STATESTS(pThis) (HDA_REG((pThis), STATESTS)) 113 113 #define ICH6_HDA_STATES_SCSF 0x7 114 114 115 115 #define ICH6_HDA_REG_GSTS 8 /* range 0x10-0x11*/ 116 116 #define ICH6_HDA_GSTS_FSH_SHIFT (1) 117 #define GSTS(p State) (HDA_REG(pState, GSTS))117 #define GSTS(pThis) (HDA_REG(pThis, GSTS)) 118 118 119 119 #define ICH6_HDA_REG_INTCTL 9 /* 0x20 */ … … 128 128 #define ICH6_HDA_INTCTL_S6_SHIFT (6) 129 129 #define ICH6_HDA_INTCTL_S7_SHIFT (7) 130 #define INTCTL(p State) (HDA_REG((pState), INTCTL))131 #define INTCTL_GIE(p State) (HDA_REG_FLAG_VALUE(pState, INTCTL, GIE))132 #define INTCTL_CIE(p State) (HDA_REG_FLAG_VALUE(pState, INTCTL, CIE))133 #define INTCTL_SX(p State, X) (HDA_REG_FLAG_VALUE((pState), INTCTL, S##X))134 #define INTCTL_SALL(p State) (INTCTL((pState)) & 0xFF)130 #define INTCTL(pThis) (HDA_REG((pThis), INTCTL)) 131 #define INTCTL_GIE(pThis) (HDA_REG_FLAG_VALUE(pThis, INTCTL, GIE)) 132 #define INTCTL_CIE(pThis) (HDA_REG_FLAG_VALUE(pThis, INTCTL, CIE)) 133 #define INTCTL_SX(pThis, X) (HDA_REG_FLAG_VALUE((pThis), INTCTL, S##X)) 134 #define INTCTL_SALL(pThis) (INTCTL((pThis)) & 0xFF) 135 135 136 136 /* Note: The HDA specification defines a SSYNC register at offset 0x38. The … … 139 139 */ 140 140 #define ICH6_HDA_REG_SSYNC 12 /* 0x34 */ 141 #define SSYNC(p State) (HDA_REG((pState), SSYNC))141 #define SSYNC(pThis) (HDA_REG((pThis), SSYNC)) 142 142 143 143 #define ICH6_HDA_REG_INTSTS 10 /* 0x24 */ … … 153 153 #define ICH6_HDA_INTSTS_S7_SHIFT (7) 154 154 #define ICH6_HDA_INTSTS_S_MASK(num) RT_BIT(HDA_REG_FIELD_SHIFT(S##num)) 155 #define INTSTS(p State) (HDA_REG((pState), INTSTS))156 #define INTSTS_GIS(p State) (HDA_REG_FLAG_VALUE((pState), INTSTS, GIS)157 #define INTSTS_CIS(p State) (HDA_REG_FLAG_VALUE((pState), INTSTS, CIS)158 #define INTSTS_SX(p State, X) (HDA_REG_FLAG_VALUE(pState), INTSTS, S##X)159 #define INTSTS_SANY(p State) (INTSTS((pState)) & 0xFF)155 #define INTSTS(pThis) (HDA_REG((pThis), INTSTS)) 156 #define INTSTS_GIS(pThis) (HDA_REG_FLAG_VALUE((pThis), INTSTS, GIS) 157 #define INTSTS_CIS(pThis) (HDA_REG_FLAG_VALUE((pThis), INTSTS, CIS) 158 #define INTSTS_SX(pThis, X) (HDA_REG_FLAG_VALUE(pThis), INTSTS, S##X) 159 #define INTSTS_SANY(pThis) (INTSTS((pThis)) & 0xFF) 160 160 161 161 #define ICH6_HDA_REG_CORBLBASE 13 /* 0x40 */ 162 #define CORBLBASE(p State) (HDA_REG((pState), CORBLBASE))162 #define CORBLBASE(pThis) (HDA_REG((pThis), CORBLBASE)) 163 163 #define ICH6_HDA_REG_CORBUBASE 14 /* 0x44 */ 164 #define CORBUBASE(p State) (HDA_REG((pState), CORBUBASE))164 #define CORBUBASE(pThis) (HDA_REG((pThis), CORBUBASE)) 165 165 #define ICH6_HDA_REG_CORBWP 15 /* 48 */ 166 166 #define ICH6_HDA_REG_CORBRP 16 /* 4A */ … … 169 169 #define ICH6_HDA_CORBRP_WP_MASK 0xFF 170 170 171 #define CORBRP(p State) (HDA_REG(pState, CORBRP))172 #define CORBWP(p State) (HDA_REG(pState, CORBWP))171 #define CORBRP(pThis) (HDA_REG(pThis, CORBRP)) 172 #define CORBWP(pThis) (HDA_REG(pThis, CORBWP)) 173 173 174 174 #define ICH6_HDA_REG_CORBCTL 17 /* 0x4C */ … … 176 176 #define ICH6_HDA_CORBCTL_CMEIE_SHIFT (0) 177 177 178 #define CORBCTL(p State) (HDA_REG(pState, CORBCTL))178 #define CORBCTL(pThis) (HDA_REG(pThis, CORBCTL)) 179 179 180 180 181 181 #define ICH6_HDA_REG_CORBSTS 18 /* 0x4D */ 182 #define CORBSTS(p State) (HDA_REG(pState, CORBSTS))182 #define CORBSTS(pThis) (HDA_REG(pThis, CORBSTS)) 183 183 #define ICH6_HDA_CORBSTS_CMEI_SHIFT (0) 184 184 … … 186 186 #define ICH6_HDA_CORBSIZE_SZ_CAP 0xF0 187 187 #define ICH6_HDA_CORBSIZE_SZ 0x3 188 #define CORBSIZE_SZ(p State) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ)189 #define CORBSIZE_SZ_CAP(p State) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ_CAP)188 #define CORBSIZE_SZ(pThis) (HDA_REG(pThis, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ) 189 #define CORBSIZE_SZ_CAP(pThis) (HDA_REG(pThis, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ_CAP) 190 190 /* till ich 10 sizes of CORB and RIRB are hardcoded to 256 in real hw */ 191 191 192 192 #define ICH6_HDA_REG_RIRLBASE 20 /* 0x50 */ 193 #define RIRLBASE(p State) (HDA_REG((pState), RIRLBASE))193 #define RIRLBASE(pThis) (HDA_REG((pThis), RIRLBASE)) 194 194 195 195 #define ICH6_HDA_REG_RIRUBASE 21 /* 0x54 */ 196 #define RIRUBASE(p State) (HDA_REG((pState), RIRUBASE))196 #define RIRUBASE(pThis) (HDA_REG((pThis), RIRUBASE)) 197 197 198 198 #define ICH6_HDA_REG_RIRBWP 22 /* 0x58 */ 199 199 #define ICH6_HDA_RIRBWP_RST_SHIFT (15) 200 200 #define ICH6_HDA_RIRBWP_WP_MASK 0xFF 201 #define RIRBWP(p State) (HDA_REG(pState, RIRBWP))201 #define RIRBWP(pThis) (HDA_REG(pThis, RIRBWP)) 202 202 203 203 #define ICH6_HDA_REG_RINTCNT 23 /* 0x5A */ 204 #define RINTCNT(p State) (HDA_REG((pState), RINTCNT))205 #define RINTCNT_N(p State) (RINTCNT((pState)) & 0xff)204 #define RINTCNT(pThis) (HDA_REG((pThis), RINTCNT)) 205 #define RINTCNT_N(pThis) (RINTCNT((pThis)) & 0xff) 206 206 207 207 #define ICH6_HDA_REG_RIRBCTL 24 /* 0x5C */ … … 209 209 #define ICH6_HDA_RIRBCTL_DMA_SHIFT (1) 210 210 #define ICH6_HDA_ROI_DMA_SHIFT (2) 211 #define RIRBCTL(p State) (HDA_REG((pState), RIRBCTL))212 #define RIRBCTL_RIRB_RIC(p State) (HDA_REG_FLAG_VALUE(pState, RIRBCTL, RIC))213 #define RIRBCTL_RIRB_DMA(p State) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, DMA)214 #define RIRBCTL_ROI(p State) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, ROI))211 #define RIRBCTL(pThis) (HDA_REG((pThis), RIRBCTL)) 212 #define RIRBCTL_RIRB_RIC(pThis) (HDA_REG_FLAG_VALUE(pThis, RIRBCTL, RIC)) 213 #define RIRBCTL_RIRB_DMA(pThis) (HDA_REG_FLAG_VALUE((pThis), RIRBCTL, DMA) 214 #define RIRBCTL_ROI(pThis) (HDA_REG_FLAG_VALUE((pThis), RIRBCTL, ROI)) 215 215 216 216 #define ICH6_HDA_REG_RIRBSTS 25 /* 0x5D */ 217 217 #define ICH6_HDA_RIRBSTS_RINTFL_SHIFT (0) 218 218 #define ICH6_HDA_RIRBSTS_RIRBOIS_SHIFT (2) 219 #define RIRBSTS(p State) (HDA_REG(pState, RIRBSTS))220 #define RIRBSTS_RINTFL(p State) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RINTFL))221 #define RIRBSTS_RIRBOIS(p State) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RIRBOIS))219 #define RIRBSTS(pThis) (HDA_REG(pThis, RIRBSTS)) 220 #define RIRBSTS_RINTFL(pThis) (HDA_REG_FLAG_VALUE(pThis, RIRBSTS, RINTFL)) 221 #define RIRBSTS_RIRBOIS(pThis) (HDA_REG_FLAG_VALUE(pThis, RIRBSTS, RIRBOIS)) 222 222 223 223 #define ICH6_HDA_REG_RIRBSIZE 26 /* 0x5E */ … … 225 225 #define ICH6_HDA_RIRBSIZE_SZ 0x3 226 226 227 #define RIRBSIZE_SZ(p State) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ)228 #define RIRBSIZE_SZ_CAP(p State) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ_CAP)227 #define RIRBSIZE_SZ(pThis) (HDA_REG(pThis, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ) 228 #define RIRBSIZE_SZ_CAP(pThis) (HDA_REG(pThis, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ_CAP) 229 229 230 230 231 231 #define ICH6_HDA_REG_IC 27 /* 0x60 */ 232 #define IC(p State) (HDA_REG(pState, IC))232 #define IC(pThis) (HDA_REG(pThis, IC)) 233 233 #define ICH6_HDA_REG_IR 28 /* 0x64 */ 234 #define IR(p State) (HDA_REG(pState, IR))234 #define IR(pThis) (HDA_REG(pThis, IR)) 235 235 #define ICH6_HDA_REG_IRS 29 /* 0x68 */ 236 236 #define ICH6_HDA_IRS_ICB_SHIFT (0) 237 237 #define ICH6_HDA_IRS_IRV_SHIFT (1) 238 #define IRS(p State) (HDA_REG(pState, IRS))239 #define IRS_ICB(p State) (HDA_REG_FLAG_VALUE(pState, IRS, ICB))240 #define IRS_IRV(p State) (HDA_REG_FLAG_VALUE(pState, IRS, IRV))238 #define IRS(pThis) (HDA_REG(pThis, IRS)) 239 #define IRS_ICB(pThis) (HDA_REG_FLAG_VALUE(pThis, IRS, ICB)) 240 #define IRS_IRV(pThis) (HDA_REG_FLAG_VALUE(pThis, IRS, IRV)) 241 241 242 242 #define ICH6_HDA_REG_DPLBASE 30 /* 0x70 */ 243 #define DPLBASE(p State) (HDA_REG((pState), DPLBASE))243 #define DPLBASE(pThis) (HDA_REG((pThis), DPLBASE)) 244 244 #define ICH6_HDA_REG_DPUBASE 31 /* 0x74 */ 245 #define DPUBASE(p State) (HDA_REG((pState), DPUBASE))245 #define DPUBASE(pThis) (HDA_REG((pThis), DPUBASE)) 246 246 #define DPBASE_ENABLED 1 247 247 #define DPBASE_ADDR_MASK (~(uint64_t)0x7f) 248 248 249 249 #define HDA_STREAM_REG_DEF(name, num) (ICH6_HDA_REG_SD##num##name) 250 #define HDA_STREAM_REG(p State, name, num) (HDA_REG((pState), N_(HDA_STREAM_REG_DEF(name, num))))250 #define HDA_STREAM_REG(pThis, name, num) (HDA_REG((pThis), N_(HDA_STREAM_REG_DEF(name, num)))) 251 251 /* Note: sdnum here _MUST_ be stream reg number [0,7] */ 252 #define HDA_STREAM_REG2(p State, name, sdnum) (HDA_REG_IND((pState), ICH6_HDA_REG_SD0##name + (sdnum) * 10))252 #define HDA_STREAM_REG2(pThis, name, sdnum) (HDA_REG_IND((pThis), ICH6_HDA_REG_SD0##name + (sdnum) * 10)) 253 253 254 254 #define ICH6_HDA_REG_SD0CTL 32 /* 0x80 */ … … 262 262 263 263 #define SD(func, num) SD##num##func 264 #define SDCTL(p State, num) HDA_REG((pState), SD(CTL, num))265 #define SDCTL_NUM(p State, num) ((SDCTL((pState), num) & HDA_REG_FIELD_MASK(SDCTL,NUM)) >> HDA_REG_FIELD_SHIFT(SDCTL, NUM))264 #define SDCTL(pThis, num) HDA_REG((pThis), SD(CTL, num)) 265 #define SDCTL_NUM(pThis, num) ((SDCTL((pThis), num) & HDA_REG_FIELD_MASK(SDCTL,NUM)) >> HDA_REG_FIELD_SHIFT(SDCTL, NUM)) 266 266 #define ICH6_HDA_SDCTL_NUM_MASK (0xF) 267 267 #define ICH6_HDA_SDCTL_NUM_SHIFT (20) … … 285 285 #define ICH6_HDA_REG_SD7STS (HDA_STREAM_REG_DEF(STS, 0) + 70) /* 0x163 */ 286 286 287 #define SDSTS(p State, num) HDA_REG((pState), SD(STS, num))287 #define SDSTS(pThis, num) HDA_REG((pThis), SD(STS, num)) 288 288 #define ICH6_HDA_SDSTS_FIFORDY_SHIFT (5) 289 289 #define ICH6_HDA_SDSTS_DE_SHIFT (4) … … 300 300 #define ICH6_HDA_REG_SD7LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 70) /* 0x164 */ 301 301 302 #define SDLPIB(p State, num) HDA_REG((pState), SD(LPIB, num))302 #define SDLPIB(pThis, num) HDA_REG((pThis), SD(LPIB, num)) 303 303 304 304 #define ICH6_HDA_REG_SD0CBL 35 /* 0x88 */ … … 311 311 #define ICH6_HDA_REG_SD7CBL (HDA_STREAM_REG_DEF(CBL, 0) + 70) /* 0x168 */ 312 312 313 #define SDLCBL(p State, num) HDA_REG((pState), SD(CBL, num))313 #define SDLCBL(pThis, num) HDA_REG((pThis), SD(CBL, num)) 314 314 315 315 #define ICH6_HDA_REG_SD0LVI 36 /* 0x8C */ … … 322 322 #define ICH6_HDA_REG_SD7LVI (HDA_STREAM_REG_DEF(LVI, 0) + 70) /* 0x16C */ 323 323 324 #define SDLVI(p State, num) HDA_REG((pState), SD(LVI, num))324 #define SDLVI(pThis, num) HDA_REG((pThis), SD(LVI, num)) 325 325 326 326 #define ICH6_HDA_REG_SD0FIFOW 37 /* 0x8E */ … … 339 339 #define HDA_SDFIFOW_16B (0x3) 340 340 #define HDA_SDFIFOW_32B (0x4) 341 #define SDFIFOW(p State, num) HDA_REG((pState), SD(FIFOW, num))341 #define SDFIFOW(pThis, num) HDA_REG((pThis), SD(FIFOW, num)) 342 342 343 343 #define ICH6_HDA_REG_SD0FIFOS 38 /* 0x90 */ … … 363 363 #define HDA_SDINFIFO_120B (0x77) /* 8-, 16-, 20-, 24-, 32-bit Input Streams */ 364 364 #define HDA_SDINFIFO_160B (0x9F) /* 20-, 24-bit Input Streams Streams */ 365 #define SDFIFOS(p State, num) HDA_REG((pState), SD(FIFOS, num))365 #define SDFIFOS(pThis, num) HDA_REG((pThis), SD(FIFOS, num)) 366 366 367 367 #define ICH6_HDA_REG_SD0FMT 39 /* 0x92 */ … … 374 374 #define ICH6_HDA_REG_SD7FMT (HDA_STREAM_REG_DEF(FMT, 0) + 70) /* 0x172 */ 375 375 376 #define SDFMT(p State, num) (HDA_REG((pState), SD(FMT, num)))376 #define SDFMT(pThis, num) (HDA_REG((pThis), SD(FMT, num))) 377 377 #define ICH6_HDA_SDFMT_BASE_RATE_SHIFT (14) 378 378 #define ICH6_HDA_SDFMT_MULT_SHIFT (11) … … 382 382 #define ICH6_HDA_SDFMT_BITS_SHIFT (4) 383 383 #define ICH6_HDA_SDFMT_BITS_MASK (0x7) 384 #define SDFMT_BASE_RATE(p State, num) ((SDFMT(pState, num) & HDA_REG_FIELD_FLAG_MASK(SDFMT, BASE_RATE)) >> HDA_REG_FIELD_SHIFT(SDFMT, BASE_RATE))385 #define SDFMT_MULT(p State, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT))386 #define SDFMT_DIV(p State, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,DIV)) >> HDA_REG_FIELD_SHIFT(SDFMT, DIV))384 #define SDFMT_BASE_RATE(pThis, num) ((SDFMT(pThis, num) & HDA_REG_FIELD_FLAG_MASK(SDFMT, BASE_RATE)) >> HDA_REG_FIELD_SHIFT(SDFMT, BASE_RATE)) 385 #define SDFMT_MULT(pThis, num) ((SDFMT((pThis), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT)) 386 #define SDFMT_DIV(pThis, num) ((SDFMT((pThis), num) & HDA_REG_FIELD_MASK(SDFMT,DIV)) >> HDA_REG_FIELD_SHIFT(SDFMT, DIV)) 387 387 388 388 #define ICH6_HDA_REG_SD0BDPL 40 /* 0x98 */ … … 395 395 #define ICH6_HDA_REG_SD7BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 70) /* 0x178 */ 396 396 397 #define SDBDPL(p State, num) HDA_REG((pState), SD(BDPL, num))397 #define SDBDPL(pThis, num) HDA_REG((pThis), SD(BDPL, num)) 398 398 399 399 #define ICH6_HDA_REG_SD0BDPU 41 /* 0x9C */ … … 406 406 #define ICH6_HDA_REG_SD7BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 70) /* 0x17C */ 407 407 408 #define SDBDPU(p State, num) HDA_REG((pState), SD(BDPU, num))408 #define SDBDPU(pThis, num) HDA_REG((pThis), SD(BDPU, num)) 409 409 410 410 … … 447 447 /** The base interface for LUN\#0. */ 448 448 PDMIBASE IBase; 449 RTGCPHYS addrMMReg;449 RTGCPHYS MMIOBaseAddr; 450 450 uint32_t au32Regs[HDA_NREGS]; 451 451 HDABDLEDESC StInBdle; … … 468 468 bool fInReset; 469 469 CODECState Codec; 470 /** 1.2.3.4.5.6.7. - someone please tell me what I'm counting! - .8.9.10... */ 470 471 uint8_t u8Counter; 471 472 uint64_t u64BaseTS; … … 479 480 #define PCIDEV_2_ICH6_HDASTATE(pPciDev) ((PHDASTATE)(pPciDev)) 480 481 481 #define ISD0FMT_TO_AUDIO_SELECTOR(p State) (AUDIO_FORMAT_SELECTOR(&(pState)->Codec, In,\482 SDFMT_BASE_RATE(pState, 0), SDFMT_MULT(pState, 0), SDFMT_DIV(pState, 0)))483 #define OSD0FMT_TO_AUDIO_SELECTOR(p State) (AUDIO_FORMAT_SELECTOR(&(pState)->Codec, Out,\484 SDFMT_BASE_RATE(pState, 4), SDFMT_MULT(pState, 4), SDFMT_DIV(pState, 4)))482 #define ISD0FMT_TO_AUDIO_SELECTOR(pThis) \ 483 ( AUDIO_FORMAT_SELECTOR(&(pThis)->Codec, In, SDFMT_BASE_RATE(pThis, 0), SDFMT_MULT(pThis, 0), SDFMT_DIV(pThis, 0)) ) 484 #define OSD0FMT_TO_AUDIO_SELECTOR(pThis) \ 485 ( AUDIO_FORMAT_SELECTOR(&(pThis)->Codec, Out, SDFMT_BASE_RATE(pThis, 4), SDFMT_MULT(pThis, 4), SDFMT_DIV(pThis, 4)) ) 485 486 486 487 … … 492 493 /** @todo r=bird: Why aren't these static? And why use DECLCALLBACK for 493 494 * internal functions? */ 494 DECLCALLBACK(int) hdaRegReadUnimplemented( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);495 DECLCALLBACK(int) hdaRegWriteUnimplemented( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);496 DECLCALLBACK(int) hdaRegReadGCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);497 DECLCALLBACK(int) hdaRegWriteGCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);498 DECLCALLBACK(int) hdaRegReadSTATESTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);499 DECLCALLBACK(int) hdaRegWriteSTATESTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);500 DECLCALLBACK(int) hdaRegReadGCAP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);501 DECLCALLBACK(int) hdaRegReadINTSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);502 DECLCALLBACK(int) hdaRegReadWALCLK( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);503 DECLCALLBACK(int) hdaRegWriteINTSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);504 DECLCALLBACK(int) hdaRegWriteCORBWP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);505 DECLCALLBACK(int) hdaRegWriteCORBRP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);506 DECLCALLBACK(int) hdaRegWriteCORBCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);507 DECLCALLBACK(int) hdaRegWriteCORBSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);508 DECLCALLBACK(int) hdaRegWriteRIRBWP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);509 DECLCALLBACK(int) hdaRegWriteRIRBSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);510 DECLCALLBACK(int) hdaRegWriteIRS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);511 DECLCALLBACK(int) hdaRegReadIRS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);512 DECLCALLBACK(int) hdaRegWriteSDCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);513 DECLCALLBACK(int) hdaRegReadSDCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);514 515 DECLCALLBACK(int) hdaRegWriteSDSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);516 DECLCALLBACK(int) hdaRegWriteSDLVI( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);517 DECLCALLBACK(int) hdaRegWriteSDFIFOW( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);518 DECLCALLBACK(int) hdaRegWriteSDFIFOS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);519 DECLCALLBACK(int) hdaRegWriteSDFMT( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);520 DECLCALLBACK(int) hdaRegWriteSDBDPL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);521 DECLCALLBACK(int) hdaRegWriteSDBDPU( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);522 DECLCALLBACK(int) hdaRegWriteBase( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value);523 DECLCALLBACK(int) hdaRegReadU32( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);524 DECLCALLBACK(int) hdaRegWriteU32( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);525 DECLCALLBACK(int) hdaRegReadU24( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);526 DECLCALLBACK(int) hdaRegWriteU24( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);527 DECLCALLBACK(int) hdaRegReadU16( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);528 DECLCALLBACK(int) hdaRegWriteU16( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);529 DECLCALLBACK(int) hdaRegReadU8( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);530 DECLCALLBACK(int) hdaRegWriteU8( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value);531 532 DECLINLINE(void) hdaInitTransferDescriptor(P INTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm,495 DECLCALLBACK(int) hdaRegReadUnimplemented(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 496 DECLCALLBACK(int) hdaRegWriteUnimplemented(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 497 DECLCALLBACK(int) hdaRegReadGCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 498 DECLCALLBACK(int) hdaRegWriteGCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 499 DECLCALLBACK(int) hdaRegReadSTATESTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 500 DECLCALLBACK(int) hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 501 DECLCALLBACK(int) hdaRegReadGCAP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 502 DECLCALLBACK(int) hdaRegReadINTSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 503 DECLCALLBACK(int) hdaRegReadWALCLK(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 504 DECLCALLBACK(int) hdaRegWriteINTSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 505 DECLCALLBACK(int) hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 506 DECLCALLBACK(int) hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 507 DECLCALLBACK(int) hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 508 DECLCALLBACK(int) hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 509 DECLCALLBACK(int) hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 510 DECLCALLBACK(int) hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 511 DECLCALLBACK(int) hdaRegWriteIRS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 512 DECLCALLBACK(int) hdaRegReadIRS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 513 DECLCALLBACK(int) hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 514 DECLCALLBACK(int) hdaRegReadSDCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 515 516 DECLCALLBACK(int) hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 517 DECLCALLBACK(int) hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 518 DECLCALLBACK(int) hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 519 DECLCALLBACK(int) hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 520 DECLCALLBACK(int) hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 521 DECLCALLBACK(int) hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 522 DECLCALLBACK(int) hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 523 DECLCALLBACK(int) hdaRegWriteBase(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 524 DECLCALLBACK(int) hdaRegReadU32(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 525 DECLCALLBACK(int) hdaRegWriteU32(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 526 DECLCALLBACK(int) hdaRegReadU24(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 527 DECLCALLBACK(int) hdaRegWriteU24(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 528 DECLCALLBACK(int) hdaRegReadU16(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 529 DECLCALLBACK(int) hdaRegWriteU16(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 530 DECLCALLBACK(int) hdaRegReadU8(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 531 DECLCALLBACK(int) hdaRegWriteU8(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t pu32Value); 532 533 DECLINLINE(void) hdaInitTransferDescriptor(PHDASTATE pThis, PHDABDLEDESC pBdle, uint8_t u8Strm, 533 534 PHDASTREAMTRANSFERDESC pStreamDesc); 534 static int hdaMMIORegLookup( INTELHDLinkState* pState, uint32_t offReg);535 static void hdaFetchBdle( INTELHDLinkState *pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc);535 static int hdaMMIORegLookup(PHDASTATE pThis, uint32_t offReg); 536 static void hdaFetchBdle(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc); 536 537 #ifdef LOG_ENABLED 537 static void dump_bd( INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA);538 static void dump_bd(PHDASTATE pThis, PHDABDLEDESC pBdle, uint64_t u64BaseDMA); 538 539 #endif 539 540 … … 554 555 uint32_t writable; 555 556 /** Read callback. */ 556 int (*pfnRead)( INTELHDLinkState *pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);557 int (*pfnRead)(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value); 557 558 /** Write callback. */ 558 int (*pfnWrite)( INTELHDLinkState *pState, uint32_t offset, uint32_t index, uint32_t u32Value);559 int (*pfnWrite)(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value); 559 560 /** Abbreviated name. */ 560 561 const char *abbrev; … … 718 719 719 720 720 DECLINLINE(void) hdaUpdatePosBuf(INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc) 721 { 722 if (pState->u64DPBase & DPBASE_ENABLED) 723 PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pState), 724 (pState->u64DPBase & DPBASE_ADDR_MASK) + pStreamDesc->u8Strm*8, pStreamDesc->pu32Lpib, sizeof(uint32_t)); 725 } 726 DECLINLINE(uint32_t) hdaFifoWToSz(INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc) 721 DECLINLINE(void) hdaUpdatePosBuf(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc) 722 { 723 if (pThis->u64DPBase & DPBASE_ENABLED) 724 PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pThis), 725 (pThis->u64DPBase & DPBASE_ADDR_MASK) + pStreamDesc->u8Strm * 8, 726 pStreamDesc->pu32Lpib, sizeof(uint32_t)); 727 } 728 DECLINLINE(uint32_t) hdaFifoWToSz(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc) 727 729 { 728 730 #if 0 729 switch(HDA_STREAM_REG2(p State, FIFOW, pStreamDesc->u8Strm))731 switch(HDA_STREAM_REG2(pThis, FIFOW, pStreamDesc->u8Strm)) 730 732 { 731 733 case HDA_SDFIFOW_8B: return 8; … … 733 735 case HDA_SDFIFOW_32B: return 32; 734 736 default: 735 AssertMsgFailed(("hda: unsupported value (%x) in SDFIFOW(,%d)\n", HDA_REG_IND(p State, pStreamDesc->u8Strm), pStreamDesc->u8Strm));737 AssertMsgFailed(("hda: unsupported value (%x) in SDFIFOW(,%d)\n", HDA_REG_IND(pThis, pStreamDesc->u8Strm), pStreamDesc->u8Strm)); 736 738 } 737 739 #endif … … 739 741 } 740 742 741 static int hdaProcessInterrupt( INTELHDLinkState* pState)742 { 743 #define IS_INTERRUPT_OCCURED_AND_ENABLED(p State, num)\744 ( INTCTL_SX((p State), num)\745 && (SDSTS(p State, num) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))743 static int hdaProcessInterrupt(PHDASTATE pThis) 744 { 745 #define IS_INTERRUPT_OCCURED_AND_ENABLED(pThis, num) \ 746 ( INTCTL_SX((pThis), num) \ 747 && (SDSTS(pThis, num) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS))) 746 748 bool fIrq = false; 747 if ( INTCTL_CIE(p State)748 && ( RIRBSTS_RINTFL(p State)749 || RIRBSTS_RIRBOIS(p State)750 || (STATESTS(p State) & WAKEEN(pState))))749 if ( INTCTL_CIE(pThis) 750 && ( RIRBSTS_RINTFL(pThis) 751 || RIRBSTS_RIRBOIS(pThis) 752 || (STATESTS(pThis) & WAKEEN(pThis)))) 751 753 fIrq = true; 752 754 753 if ( IS_INTERRUPT_OCCURED_AND_ENABLED(p State, 0)754 || IS_INTERRUPT_OCCURED_AND_ENABLED(p State, 4))755 if ( IS_INTERRUPT_OCCURED_AND_ENABLED(pThis, 0) 756 || IS_INTERRUPT_OCCURED_AND_ENABLED(pThis, 4)) 755 757 fIrq = true; 756 758 757 if (INTCTL_GIE(p State))759 if (INTCTL_GIE(pThis)) 758 760 { 759 761 Log(("hda: irq %s\n", fIrq ? "asserted" : "deasserted")); 760 PDMDevHlpPCISetIrq(ICH6_HDASTATE_2_DEVINS(p State), 0 , fIrq);762 PDMDevHlpPCISetIrq(ICH6_HDASTATE_2_DEVINS(pThis), 0 , fIrq); 761 763 } 762 764 return VINF_SUCCESS; 763 765 } 764 766 765 static int hdaMMIORegLookup( INTELHDLinkState* pState, uint32_t offReg)767 static int hdaMMIORegLookup(PHDASTATE pThis, uint32_t offReg) 766 768 { 767 769 /* … … 814 816 } 815 817 816 static int hdaCmdSync( INTELHDLinkState *pState, bool fLocal)818 static int hdaCmdSync(PHDASTATE pThis, bool fLocal) 817 819 { 818 820 int rc = VINF_SUCCESS; 819 821 if (fLocal) 820 822 { 821 Assert((HDA_REG_FLAG_VALUE(p State, CORBCTL, DMA)));822 rc = PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(p State), pState->u64CORBBase, pState->pu32CorbBuf, pState->cbCorbBuf);823 Assert((HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA))); 824 rc = PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pThis), pThis->u64CORBBase, pThis->pu32CorbBuf, pThis->cbCorbBuf); 823 825 if (RT_FAILURE(rc)) 824 826 AssertRCReturn(rc, rc); … … 832 834 { 833 835 const char *prefix; 834 if ((i + j) == CORBRP(p State))836 if ((i + j) == CORBRP(pThis)) 835 837 prefix = "[R]"; 836 else if ((i + j) == CORBWP(p State))838 else if ((i + j) == CORBWP(pThis)) 837 839 prefix = "[W]"; 838 840 else 839 841 prefix = " "; /* three spaces */ 840 Log(("%s%08x", prefix, p State->pu32CorbBuf[i + j]));842 Log(("%s%08x", prefix, pThis->pu32CorbBuf[i + j])); 841 843 j++; 842 844 } while (j < 8); … … 848 850 else 849 851 { 850 Assert((HDA_REG_FLAG_VALUE(p State, RIRBCTL, DMA)));851 rc = PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(p State), pState->u64RIRBBase, pState->pu64RirbBuf, pState->cbRirbBuf);852 Assert((HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA))); 853 rc = PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pThis), pThis->u64RIRBBase, pThis->pu64RirbBuf, pThis->cbRirbBuf); 852 854 if (RT_FAILURE(rc)) 853 855 AssertRCReturn(rc, rc); … … 859 861 do { 860 862 const char *prefix; 861 if ((i + j) == RIRBWP(p State))863 if ((i + j) == RIRBWP(pThis)) 862 864 prefix = "[W]"; 863 865 else 864 866 prefix = " "; 865 Log((" %s%016lx", prefix, p State->pu64RirbBuf[i + j]));867 Log((" %s%016lx", prefix, pThis->pu64RirbBuf[i + j])); 866 868 } while (++j < 8); 867 869 Log(("\n")); … … 873 875 } 874 876 875 static int hdaCORBCmdProcess( INTELHDLinkState *pState)877 static int hdaCORBCmdProcess(PHDASTATE pThis) 876 878 { 877 879 int rc; … … 882 884 PFNCODECVERBPROCESSOR pfn = (PFNCODECVERBPROCESSOR)NULL; 883 885 884 rc = hdaCmdSync(p State, true);886 rc = hdaCmdSync(pThis, true); 885 887 if (RT_FAILURE(rc)) 886 888 AssertRCReturn(rc, rc); 887 corbRp = CORBRP(p State);888 corbWp = CORBWP(p State);889 rirbWp = RIRBWP(p State);889 corbRp = CORBRP(pThis); 890 corbWp = CORBWP(pThis); 891 rirbWp = RIRBWP(pThis); 890 892 Assert((corbWp != corbRp)); 891 Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(p State), CORBWP(pState), RIRBWP(pState)));893 Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(pThis), CORBWP(pThis), RIRBWP(pThis))); 892 894 while (corbRp != corbWp) 893 895 { … … 896 898 pfn = (PFNCODECVERBPROCESSOR)NULL; 897 899 corbRp++; 898 cmd = p State->pu32CorbBuf[corbRp];899 rc = (pState)->Codec.pfnLookup(&pState->Codec, cmd, &pfn);900 cmd = pThis->pu32CorbBuf[corbRp]; 901 rc = pThis->Codec.pfnLookup(&pThis->Codec, cmd, &pfn); 900 902 if (RT_FAILURE(rc)) 901 903 AssertRCReturn(rc, rc); … … 904 906 905 907 if (RT_LIKELY(pfn)) 906 rc = pfn(&p State->Codec, cmd, &resp);908 rc = pfn(&pThis->Codec, cmd, &resp); 907 909 else 908 910 rc = VERR_INVALID_FUNCTION; … … 912 914 Log(("hda: verb:%08x->%016lx\n", cmd, resp)); 913 915 if ( (resp & CODEC_RESPONSE_UNSOLICITED) 914 && !HDA_REG_FLAG_VALUE(p State, GCTL, UR))916 && !HDA_REG_FLAG_VALUE(pThis, GCTL, UR)) 915 917 { 916 918 Log(("hda: unexpected unsolicited response.\n")); 917 p State->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp;919 pThis->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp; 918 920 return rc; 919 921 } 920 p State->pu64RirbBuf[rirbWp] = resp;921 p State->u8Counter++;922 if (p State->u8Counter == RINTCNT_N(pState))922 pThis->pu64RirbBuf[rirbWp] = resp; 923 pThis->u8Counter++; 924 if (pThis->u8Counter == RINTCNT_N(pThis)) 923 925 break; 924 926 } 925 p State->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp;926 p State->au32Regs[ICH6_HDA_REG_RIRBWP] = rirbWp;927 rc = hdaCmdSync(p State, false);928 Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(p State), CORBWP(pState), RIRBWP(pState)));929 if (RIRBCTL_RIRB_RIC(p State))930 { 931 RIRBSTS((p State)) |= HDA_REG_FIELD_FLAG_MASK(RIRBSTS,RINTFL);932 p State->u8Counter = 0;933 rc = hdaProcessInterrupt(p State);927 pThis->au32Regs[ICH6_HDA_REG_CORBRP] = corbRp; 928 pThis->au32Regs[ICH6_HDA_REG_RIRBWP] = rirbWp; 929 rc = hdaCmdSync(pThis, false); 930 Log(("hda: CORB(RP:%x, WP:%x) RIRBWP:%x\n", CORBRP(pThis), CORBWP(pThis), RIRBWP(pThis))); 931 if (RIRBCTL_RIRB_RIC(pThis)) 932 { 933 RIRBSTS((pThis)) |= HDA_REG_FIELD_FLAG_MASK(RIRBSTS,RINTFL); 934 pThis->u8Counter = 0; 935 rc = hdaProcessInterrupt(pThis); 934 936 } 935 937 if (RT_FAILURE(rc)) … … 938 940 } 939 941 940 static void hdaStreamReset( INTELHDLinkState *pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, uint8_t u8Strm)942 static void hdaStreamReset(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, uint8_t u8Strm) 941 943 { 942 944 Log(("hda: reset of stream (%d) started\n", u8Strm)); 943 Assert(( p State945 Assert(( pThis 944 946 && pBdle 945 947 && pStreamDesc … … 950 952 /* According to the ICH6 datasheet, 0x40000 is the default value for stream descriptor register 23:20 951 953 * bits are reserved for stream number 18.2.33, resets SDnCTL except SRCT bit */ 952 HDA_STREAM_REG2(p State, CTL, u8Strm) = 0x40000 | (HDA_STREAM_REG2(pState, CTL, u8Strm) & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST));954 HDA_STREAM_REG2(pThis, CTL, u8Strm) = 0x40000 | (HDA_STREAM_REG2(pThis, CTL, u8Strm) & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)); 953 955 954 956 /* ICH6 defines default values (0x77 for input and 0xBF for output descriptors) of FIFO size. 18.2.39 */ 955 HDA_STREAM_REG2(p State, FIFOS, u8Strm) = u8Strm < 4 ? HDA_SDINFIFO_120B : HDA_SDONFIFO_192B;956 HDA_STREAM_REG2(p State, FIFOW, u8Strm) = u8Strm < 4 ? HDA_SDFIFOW_8B : HDA_SDFIFOW_32B;957 HDA_STREAM_REG2(p State, CBL, u8Strm) = 0;958 HDA_STREAM_REG2(p State, LVI, u8Strm) = 0;959 HDA_STREAM_REG2(p State, FMT, u8Strm) = 0;960 HDA_STREAM_REG2(p State, BDPU, u8Strm) = 0;961 HDA_STREAM_REG2(p State, BDPL, u8Strm) = 0;957 HDA_STREAM_REG2(pThis, FIFOS, u8Strm) = u8Strm < 4 ? HDA_SDINFIFO_120B : HDA_SDONFIFO_192B; 958 HDA_STREAM_REG2(pThis, FIFOW, u8Strm) = u8Strm < 4 ? HDA_SDFIFOW_8B : HDA_SDFIFOW_32B; 959 HDA_STREAM_REG2(pThis, CBL, u8Strm) = 0; 960 HDA_STREAM_REG2(pThis, LVI, u8Strm) = 0; 961 HDA_STREAM_REG2(pThis, FMT, u8Strm) = 0; 962 HDA_STREAM_REG2(pThis, BDPU, u8Strm) = 0; 963 HDA_STREAM_REG2(pThis, BDPL, u8Strm) = 0; 962 964 Log(("hda: reset of stream (%d) finished\n", u8Strm)); 963 965 } 964 966 965 967 966 DECLCALLBACK(int) hdaRegReadUnimplemented( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)968 DECLCALLBACK(int) hdaRegReadUnimplemented(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 967 969 { 968 970 *pu32Value = 0; 969 971 return VINF_SUCCESS; 970 972 } 971 DECLCALLBACK(int) hdaRegWriteUnimplemented( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)973 DECLCALLBACK(int) hdaRegWriteUnimplemented(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 972 974 { 973 975 return VINF_SUCCESS; 974 976 } 975 977 /* U8 */ 976 DECLCALLBACK(int) hdaRegReadU8( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)977 { 978 Assert(((p State->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xffffff00) == 0);979 return hdaRegReadU32(p State, offset, index, pu32Value);980 } 981 982 DECLCALLBACK(int) hdaRegWriteU8( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)978 DECLCALLBACK(int) hdaRegReadU8(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 979 { 980 Assert(((pThis->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xffffff00) == 0); 981 return hdaRegReadU32(pThis, offset, index, pu32Value); 982 } 983 984 DECLCALLBACK(int) hdaRegWriteU8(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 983 985 { 984 986 Assert(((u32Value & 0xffffff00) == 0)); 985 return hdaRegWriteU32(p State, offset, index, u32Value);987 return hdaRegWriteU32(pThis, offset, index, u32Value); 986 988 } 987 989 /* U16 */ 988 DECLCALLBACK(int) hdaRegReadU16( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)989 { 990 Assert(((p State->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xffff0000) == 0);991 return hdaRegReadU32(p State, offset, index, pu32Value);992 } 993 994 DECLCALLBACK(int) hdaRegWriteU16( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)990 DECLCALLBACK(int) hdaRegReadU16(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 991 { 992 Assert(((pThis->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xffff0000) == 0); 993 return hdaRegReadU32(pThis, offset, index, pu32Value); 994 } 995 996 DECLCALLBACK(int) hdaRegWriteU16(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 995 997 { 996 998 Assert(((u32Value & 0xffff0000) == 0)); 997 return hdaRegWriteU32(p State, offset, index, u32Value);999 return hdaRegWriteU32(pThis, offset, index, u32Value); 998 1000 } 999 1001 1000 1002 /* U24 */ 1001 DECLCALLBACK(int) hdaRegReadU24( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1002 { 1003 Assert(((p State->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xff000000) == 0);1004 return hdaRegReadU32(p State, offset, index, pu32Value);1005 } 1006 1007 DECLCALLBACK(int) hdaRegWriteU24( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1003 DECLCALLBACK(int) hdaRegReadU24(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1004 { 1005 Assert(((pThis->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xff000000) == 0); 1006 return hdaRegReadU32(pThis, offset, index, pu32Value); 1007 } 1008 1009 DECLCALLBACK(int) hdaRegWriteU24(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1008 1010 { 1009 1011 Assert(((u32Value & 0xff000000) == 0)); 1010 return hdaRegWriteU32(p State, offset, index, u32Value);1012 return hdaRegWriteU32(pThis, offset, index, u32Value); 1011 1013 } 1012 1014 /* U32 */ 1013 DECLCALLBACK(int) hdaRegReadU32( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1014 { 1015 *pu32Value = p State->au32Regs[index] & g_aIchIntelHDRegMap[index].readable;1015 DECLCALLBACK(int) hdaRegReadU32(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1016 { 1017 *pu32Value = pThis->au32Regs[index] & g_aIchIntelHDRegMap[index].readable; 1016 1018 return VINF_SUCCESS; 1017 1019 } 1018 1020 1019 DECLCALLBACK(int) hdaRegWriteU32( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1020 { 1021 p State->au32Regs[index] = (u32Value & g_aIchIntelHDRegMap[index].writable)1022 | (p State->au32Regs[index] & ~g_aIchIntelHDRegMap[index].writable);1021 DECLCALLBACK(int) hdaRegWriteU32(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1022 { 1023 pThis->au32Regs[index] = (u32Value & g_aIchIntelHDRegMap[index].writable) 1024 | (pThis->au32Regs[index] & ~g_aIchIntelHDRegMap[index].writable); 1023 1025 return VINF_SUCCESS; 1024 1026 } 1025 1027 1026 DECLCALLBACK(int) hdaRegReadGCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1027 { 1028 return hdaRegReadU32(p State, offset, index, pu32Value);1029 } 1030 1031 DECLCALLBACK(int) hdaRegWriteGCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1028 DECLCALLBACK(int) hdaRegReadGCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1029 { 1030 return hdaRegReadU32(pThis, offset, index, pu32Value); 1031 } 1032 1033 DECLCALLBACK(int) hdaRegWriteGCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1032 1034 { 1033 1035 if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, RST)) 1034 1036 { 1035 1037 /* exit reset state */ 1036 GCTL(p State) |= HDA_REG_FIELD_FLAG_MASK(GCTL, RST);1037 p State->fInReset = false;1038 GCTL(pThis) |= HDA_REG_FIELD_FLAG_MASK(GCTL, RST); 1039 pThis->fInReset = false; 1038 1040 } 1039 1041 else 1040 1042 { 1041 1043 /* enter reset state*/ 1042 if ( HDA_REG_FLAG_VALUE(p State, CORBCTL, DMA)1043 || HDA_REG_FLAG_VALUE(p State, RIRBCTL, DMA))1044 if ( HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA) 1045 || HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA)) 1044 1046 { 1045 1047 Log(("hda: HDA enters in reset with DMA(RIRB:%s, CORB:%s)\n", 1046 HDA_REG_FLAG_VALUE(p State, CORBCTL, DMA) ? "on" : "off",1047 HDA_REG_FLAG_VALUE(p State, RIRBCTL, DMA) ? "on" : "off"));1048 HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA) ? "on" : "off", 1049 HDA_REG_FLAG_VALUE(pThis, RIRBCTL, DMA) ? "on" : "off")); 1048 1050 } 1049 hdaReset(ICH6_HDASTATE_2_DEVINS(p State));1050 GCTL(p State) &= ~HDA_REG_FIELD_FLAG_MASK(GCTL, RST);1051 p State->fInReset = true;1051 hdaReset(ICH6_HDASTATE_2_DEVINS(pThis)); 1052 GCTL(pThis) &= ~HDA_REG_FIELD_FLAG_MASK(GCTL, RST); 1053 pThis->fInReset = true; 1052 1054 } 1053 1055 if (u32Value & HDA_REG_FIELD_FLAG_MASK(GCTL, FSH)) 1054 1056 { 1055 1057 /* Flush: GSTS:1 set, see 6.2.6*/ 1056 GSTS(p State) |= HDA_REG_FIELD_FLAG_MASK(GSTS, FSH); /* set the flush state */1058 GSTS(pThis) |= HDA_REG_FIELD_FLAG_MASK(GSTS, FSH); /* set the flush state */ 1057 1059 /* DPLBASE and DPUBASE should be initialized with initial value (see 6.2.6)*/ 1058 1060 } … … 1060 1062 } 1061 1063 1062 DECLCALLBACK(int) hdaRegWriteSTATESTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1063 { 1064 uint32_t v = p State->au32Regs[index];1064 DECLCALLBACK(int) hdaRegWriteSTATESTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1065 { 1066 uint32_t v = pThis->au32Regs[index]; 1065 1067 uint32_t nv = u32Value & ICH6_HDA_STATES_SCSF; 1066 p State->au32Regs[index] &= ~(v & nv); /* write of 1 clears corresponding bit */1068 pThis->au32Regs[index] &= ~(v & nv); /* write of 1 clears corresponding bit */ 1067 1069 return VINF_SUCCESS; 1068 1070 } 1069 1071 1070 DECLCALLBACK(int) hdaRegReadINTSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1072 DECLCALLBACK(int) hdaRegReadINTSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1071 1073 { 1072 1074 uint32_t v = 0; 1073 if ( RIRBSTS_RIRBOIS(p State)1074 || RIRBSTS_RINTFL(p State)1075 || HDA_REG_FLAG_VALUE(p State, CORBSTS, CMEI)1076 || STATESTS(p State))1075 if ( RIRBSTS_RIRBOIS(pThis) 1076 || RIRBSTS_RINTFL(pThis) 1077 || HDA_REG_FLAG_VALUE(pThis, CORBSTS, CMEI) 1078 || STATESTS(pThis)) 1077 1079 v |= RT_BIT(30); 1078 #define HDA_IS_STREAM_EVENT(p State, stream) \1079 ( (SDSTS((p State),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE)) \1080 || (SDSTS((p State),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE)) \1081 || (SDSTS((p State),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))1082 #define MARK_STREAM(p State, stream, v) do {(v) |= HDA_IS_STREAM_EVENT((pState),stream) ? RT_BIT((stream)) : 0;}while(0)1083 MARK_STREAM(p State, 0, v);1084 MARK_STREAM(p State, 1, v);1085 MARK_STREAM(p State, 2, v);1086 MARK_STREAM(p State, 3, v);1087 MARK_STREAM(p State, 4, v);1088 MARK_STREAM(p State, 5, v);1089 MARK_STREAM(p State, 6, v);1090 MARK_STREAM(p State, 7, v);1080 #define HDA_IS_STREAM_EVENT(pThis, stream) \ 1081 ( (SDSTS((pThis),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE)) \ 1082 || (SDSTS((pThis),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE)) \ 1083 || (SDSTS((pThis),stream) & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS))) 1084 #define MARK_STREAM(pThis, stream, v) do { (v) |= HDA_IS_STREAM_EVENT((pThis),stream) ? RT_BIT((stream)) : 0; } while(0) 1085 MARK_STREAM(pThis, 0, v); 1086 MARK_STREAM(pThis, 1, v); 1087 MARK_STREAM(pThis, 2, v); 1088 MARK_STREAM(pThis, 3, v); 1089 MARK_STREAM(pThis, 4, v); 1090 MARK_STREAM(pThis, 5, v); 1091 MARK_STREAM(pThis, 6, v); 1092 MARK_STREAM(pThis, 7, v); 1091 1093 v |= v ? RT_BIT(31) : 0; 1092 1094 *pu32Value = v; … … 1094 1096 } 1095 1097 1096 DECLCALLBACK(int) hdaRegReadWALCLK( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1098 DECLCALLBACK(int) hdaRegReadWALCLK(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1097 1099 { 1098 1100 /* HDA spec (1a): 3.3.16 WALCLK counter ticks with 24Mhz bitclock rate. */ 1099 *pu32Value = (uint32_t)ASMMultU64ByU32DivByU32(PDMDevHlpTMTimeVirtGetNano(ICH6_HDASTATE_2_DEVINS(p State))1100 - p State->u64BaseTS, 24, 1000);1101 *pu32Value = (uint32_t)ASMMultU64ByU32DivByU32(PDMDevHlpTMTimeVirtGetNano(ICH6_HDASTATE_2_DEVINS(pThis)) 1102 - pThis->u64BaseTS, 24, 1000); 1101 1103 return VINF_SUCCESS; 1102 1104 } 1103 1105 1104 DECLCALLBACK(int) hdaRegReadGCAP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1105 { 1106 return hdaRegReadU16(p State, offset, index, pu32Value);1107 } 1108 1109 DECLCALLBACK(int) hdaRegWriteCORBRP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1106 DECLCALLBACK(int) hdaRegReadGCAP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1107 { 1108 return hdaRegReadU16(pThis, offset, index, pu32Value); 1109 } 1110 1111 DECLCALLBACK(int) hdaRegWriteCORBRP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1110 1112 { 1111 1113 if (u32Value & HDA_REG_FIELD_FLAG_MASK(CORBRP, RST)) 1112 CORBRP(p State) = 0;1114 CORBRP(pThis) = 0; 1113 1115 else 1114 return hdaRegWriteU8(p State, offset, index, u32Value);1116 return hdaRegWriteU8(pThis, offset, index, u32Value); 1115 1117 return VINF_SUCCESS; 1116 1118 } 1117 1119 1118 DECLCALLBACK(int) hdaRegWriteCORBCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1119 { 1120 int rc = hdaRegWriteU8(p State, offset, index, u32Value);1120 DECLCALLBACK(int) hdaRegWriteCORBCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1121 { 1122 int rc = hdaRegWriteU8(pThis, offset, index, u32Value); 1121 1123 AssertRC(rc); 1122 if ( CORBWP(p State) != CORBRP(pState)1123 && HDA_REG_FLAG_VALUE(p State, CORBCTL, DMA) != 0)1124 return hdaCORBCmdProcess(p State);1124 if ( CORBWP(pThis) != CORBRP(pThis) 1125 && HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA) != 0) 1126 return hdaCORBCmdProcess(pThis); 1125 1127 return rc; 1126 1128 } 1127 1129 1128 DECLCALLBACK(int) hdaRegWriteCORBSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1129 { 1130 uint32_t v = CORBSTS(p State);1131 CORBSTS(p State) &= ~(v & u32Value);1130 DECLCALLBACK(int) hdaRegWriteCORBSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1131 { 1132 uint32_t v = CORBSTS(pThis); 1133 CORBSTS(pThis) &= ~(v & u32Value); 1132 1134 return VINF_SUCCESS; 1133 1135 } 1134 1136 1135 DECLCALLBACK(int) hdaRegWriteCORBWP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1137 DECLCALLBACK(int) hdaRegWriteCORBWP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1136 1138 { 1137 1139 int rc; 1138 rc = hdaRegWriteU16(p State, offset, index, u32Value);1140 rc = hdaRegWriteU16(pThis, offset, index, u32Value); 1139 1141 if (RT_FAILURE(rc)) 1140 1142 AssertRCReturn(rc, rc); 1141 if (CORBWP(p State) == CORBRP(pState))1143 if (CORBWP(pThis) == CORBRP(pThis)) 1142 1144 return VINF_SUCCESS; 1143 if (!HDA_REG_FLAG_VALUE(p State, CORBCTL, DMA))1145 if (!HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA)) 1144 1146 return VINF_SUCCESS; 1145 rc = hdaCORBCmdProcess(p State);1147 rc = hdaCORBCmdProcess(pThis); 1146 1148 return rc; 1147 1149 } 1148 1150 1149 DECLCALLBACK(int) hdaRegReadSDCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1150 { 1151 return hdaRegReadU24(p State, offset, index, pu32Value);1152 } 1153 1154 DECLCALLBACK(int) hdaRegWriteSDCTL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1155 { 1156 bool fRun = RT_BOOL((u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)));1157 bool fInRun = RT_BOOL((HDA_REG_IND(pState, index) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)));1158 bool fReset = RT_BOOL((u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)));1159 bool fInReset = RT_BOOL( (HDA_REG_IND(pState, index) & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)));1151 DECLCALLBACK(int) hdaRegReadSDCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1152 { 1153 return hdaRegReadU24(pThis, offset, index, pu32Value); 1154 } 1155 1156 DECLCALLBACK(int) hdaRegWriteSDCTL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1157 { 1158 bool fRun = RT_BOOL(u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)); 1159 bool fInRun = RT_BOOL(HDA_REG_IND(pThis, index) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)); 1160 bool fReset = RT_BOOL(u32Value & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)); 1161 bool fInReset = RT_BOOL(HDA_REG_IND(pThis, index) & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)); 1160 1162 int rc = VINF_SUCCESS; 1161 1163 if (fInReset) … … 1181 1183 case ICH6_HDA_REG_SD0CTL: 1182 1184 u8Strm = 0; 1183 pBdle = &p State->StInBdle;1185 pBdle = &pThis->StInBdle; 1184 1186 break; 1185 1187 case ICH6_HDA_REG_SD4CTL: 1186 1188 u8Strm = 4; 1187 pBdle = &p State->StOutBdle;1189 pBdle = &pThis->StOutBdle; 1188 1190 break; 1189 1191 default: … … 1192 1194 } 1193 1195 Log(("hda: guest initiated enter to stream reset.\n")); 1194 hdaInitTransferDescriptor(p State, pBdle, u8Strm, &StreamDesc);1195 hdaStreamReset(p State, pBdle, &StreamDesc, u8Strm);1196 hdaInitTransferDescriptor(pThis, pBdle, u8Strm, &StreamDesc); 1197 hdaStreamReset(pThis, pBdle, &StreamDesc, u8Strm); 1196 1198 goto l_done; 1197 1199 } … … 1205 1207 { 1206 1208 case ICH6_HDA_REG_SD0CTL: 1207 AUD_set_active_in(p State->Codec.SwVoiceIn, fRun);1209 AUD_set_active_in(pThis->Codec.SwVoiceIn, fRun); 1208 1210 break; 1209 1211 case ICH6_HDA_REG_SD4CTL: 1210 AUD_set_active_out(p State->Codec.SwVoiceOut, fRun);1212 AUD_set_active_out(pThis->Codec.SwVoiceOut, fRun); 1211 1213 break; 1212 1214 default: … … 1217 1219 1218 1220 l_done: 1219 rc = hdaRegWriteU24(p State, offset, index, u32Value);1221 rc = hdaRegWriteU24(pThis, offset, index, u32Value); 1220 1222 if (RT_FAILURE(rc)) 1221 1223 AssertRCReturn(rc, VINF_SUCCESS); … … 1223 1225 } 1224 1226 1225 DECLCALLBACK(int) hdaRegWriteSDSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1226 { 1227 uint32_t v = HDA_REG_IND(p State, index);1227 DECLCALLBACK(int) hdaRegWriteSDSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1228 { 1229 uint32_t v = HDA_REG_IND(pThis, index); 1228 1230 v &= ~(u32Value & v); 1229 HDA_REG_IND(p State, index) = v;1230 hdaProcessInterrupt(p State);1231 HDA_REG_IND(pThis, index) = v; 1232 hdaProcessInterrupt(pThis); 1231 1233 return VINF_SUCCESS; 1232 1234 } 1233 1235 1234 DECLCALLBACK(int) hdaRegWriteSDLVI( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1235 { 1236 int rc = hdaRegWriteU32(p State, offset, index, u32Value);1236 DECLCALLBACK(int) hdaRegWriteSDLVI(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1237 { 1238 int rc = hdaRegWriteU32(pThis, offset, index, u32Value); 1237 1239 if (RT_FAILURE(rc)) 1238 1240 AssertRCReturn(rc, VINF_SUCCESS); … … 1240 1242 } 1241 1243 1242 DECLCALLBACK(int) hdaRegWriteSDFIFOW( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1244 DECLCALLBACK(int) hdaRegWriteSDFIFOW(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1243 1245 { 1244 1246 switch (u32Value) … … 1247 1249 case HDA_SDFIFOW_16B: 1248 1250 case HDA_SDFIFOW_32B: 1249 return hdaRegWriteU16(p State, offset, index, u32Value);1251 return hdaRegWriteU16(pThis, offset, index, u32Value); 1250 1252 default: 1251 1253 Log(("hda: Attempt to store unsupported value(%x) in SDFIFOW\n", u32Value)); 1252 return hdaRegWriteU16(p State, offset, index, HDA_SDFIFOW_32B);1254 return hdaRegWriteU16(pThis, offset, index, HDA_SDFIFOW_32B); 1253 1255 } 1254 1256 return VINF_SUCCESS; … … 1258 1260 * 1259 1261 */ 1260 DECLCALLBACK(int) hdaRegWriteSDFIFOS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1262 DECLCALLBACK(int) hdaRegWriteSDFIFOS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1261 1263 { 1262 1264 switch (index) … … 1280 1282 case HDA_SDONFIFO_128B: 1281 1283 case HDA_SDONFIFO_192B: 1282 return hdaRegWriteU16(p State, offset, index, u32Value);1284 return hdaRegWriteU16(pThis, offset, index, u32Value); 1283 1285 1284 1286 case HDA_SDONFIFO_256B: 1285 1287 Log(("hda: 256-bit is unsupported, HDA is switched into 192-bit mode\n")); 1286 1288 default: 1287 return hdaRegWriteU16(p State, offset, index, HDA_SDONFIFO_192B);1289 return hdaRegWriteU16(pThis, offset, index, HDA_SDONFIFO_192B); 1288 1290 } 1289 1291 return VINF_SUCCESS; … … 1352 1354 } 1353 1355 1354 DECLCALLBACK(int) hdaRegWriteSDFMT( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1356 DECLCALLBACK(int) hdaRegWriteSDFMT(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1355 1357 { 1356 1358 #ifdef VBOX_WITH_HDA_CODEC_EMU … … 1359 1361 audsettings_t as; 1360 1362 /* no reason to reopen voice with same settings */ 1361 if (u32Value == HDA_REG_IND(p State, index))1363 if (u32Value == HDA_REG_IND(pThis, index)) 1362 1364 return VINF_SUCCESS; 1363 1365 hdaSdFmtToAudSettings(u32Value, &as); … … 1365 1367 { 1366 1368 case ICH6_HDA_REG_SD0FMT: 1367 rc = codecOpenVoice(&p State->Codec, PI_INDEX, &as);1369 rc = codecOpenVoice(&pThis->Codec, PI_INDEX, &as); 1368 1370 break; 1369 1371 case ICH6_HDA_REG_SD4FMT: 1370 rc = codecOpenVoice(&p State->Codec, PO_INDEX, &as);1372 rc = codecOpenVoice(&pThis->Codec, PO_INDEX, &as); 1371 1373 break; 1372 1374 default: … … 1374 1376 rc = 0; 1375 1377 } 1376 return hdaRegWriteU16(p State, offset, index, u32Value);1378 return hdaRegWriteU16(pThis, offset, index, u32Value); 1377 1379 #else 1378 return hdaRegWriteU16(p State, offset, index, u32Value);1380 return hdaRegWriteU16(pThis, offset, index, u32Value); 1379 1381 #endif 1380 1382 } 1381 1383 1382 DECLCALLBACK(int) hdaRegWriteSDBDPL( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1383 { 1384 int rc = hdaRegWriteU32(p State, offset, index, u32Value);1384 DECLCALLBACK(int) hdaRegWriteSDBDPL(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1385 { 1386 int rc = hdaRegWriteU32(pThis, offset, index, u32Value); 1385 1387 if (RT_FAILURE(rc)) 1386 1388 AssertRCReturn(rc, VINF_SUCCESS); … … 1388 1390 } 1389 1391 1390 DECLCALLBACK(int) hdaRegWriteSDBDPU( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1391 { 1392 int rc = hdaRegWriteU32(p State, offset, index, u32Value);1392 DECLCALLBACK(int) hdaRegWriteSDBDPU(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1393 { 1394 int rc = hdaRegWriteU32(pThis, offset, index, u32Value); 1393 1395 if (RT_FAILURE(rc)) 1394 1396 AssertRCReturn(rc, VINF_SUCCESS); … … 1396 1398 } 1397 1399 1398 DECLCALLBACK(int) hdaRegReadIRS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value)1400 DECLCALLBACK(int) hdaRegReadIRS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1399 1401 { 1400 1402 int rc = VINF_SUCCESS; 1401 1403 /* regarding 3.4.3 we should mark IRS as busy in case CORB is active */ 1402 if ( CORBWP(p State) != CORBRP(pState)1403 || HDA_REG_FLAG_VALUE(p State, CORBCTL, DMA))1404 IRS(p State) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */1405 1406 rc = hdaRegReadU32(p State, offset, index, pu32Value);1404 if ( CORBWP(pThis) != CORBRP(pThis) 1405 || HDA_REG_FLAG_VALUE(pThis, CORBCTL, DMA)) 1406 IRS(pThis) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */ 1407 1408 rc = hdaRegReadU32(pThis, offset, index, pu32Value); 1407 1409 return rc; 1408 1410 } 1409 1411 1410 DECLCALLBACK(int) hdaRegWriteIRS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1412 DECLCALLBACK(int) hdaRegWriteIRS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1411 1413 { 1412 1414 int rc = VINF_SUCCESS; … … 1418 1420 */ 1419 1421 if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, ICB) 1420 && !IRS_ICB(p State))1421 { 1422 uint32_t cmd = IC(p State);1423 if (CORBWP(p State) != CORBRP(pState))1422 && !IRS_ICB(pThis)) 1423 { 1424 uint32_t cmd = IC(pThis); 1425 if (CORBWP(pThis) != CORBRP(pThis)) 1424 1426 { 1425 1427 /* … … 1429 1431 return rc; 1430 1432 } 1431 IRS(p State) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */1433 IRS(pThis) = HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy */ 1432 1434 Log(("hda: IC:%x\n", cmd)); 1433 rc = p State->Codec.pfnLookup(&pState->Codec, cmd, &pfn);1435 rc = pThis->Codec.pfnLookup(&pThis->Codec, cmd, &pfn); 1434 1436 if (RT_FAILURE(rc)) 1435 1437 AssertRCReturn(rc, rc); 1436 rc = pfn(&p State->Codec, cmd, &resp);1438 rc = pfn(&pThis->Codec, cmd, &resp); 1437 1439 if (RT_FAILURE(rc)) 1438 1440 AssertRCReturn(rc, rc); 1439 IR(p State) = (uint32_t)resp;1440 Log(("hda: IR:%x\n", IR(p State)));1441 IRS(p State) = HDA_REG_FIELD_FLAG_MASK(IRS, IRV); /* result is ready */1442 IRS(p State) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy is clear */1441 IR(pThis) = (uint32_t)resp; 1442 Log(("hda: IR:%x\n", IR(pThis))); 1443 IRS(pThis) = HDA_REG_FIELD_FLAG_MASK(IRS, IRV); /* result is ready */ 1444 IRS(pThis) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, ICB); /* busy is clear */ 1443 1445 return rc; 1444 1446 } … … 1447 1449 */ 1448 1450 if ( u32Value & HDA_REG_FIELD_FLAG_MASK(IRS, IRV) 1449 && IRS_IRV(p State))1450 IRS(p State) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, IRV);1451 && IRS_IRV(pThis)) 1452 IRS(pThis) &= ~HDA_REG_FIELD_FLAG_MASK(IRS, IRV); 1451 1453 return rc; 1452 1454 } 1453 1455 1454 DECLCALLBACK(int) hdaRegWriteRIRBWP( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1456 DECLCALLBACK(int) hdaRegWriteRIRBWP(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1455 1457 { 1456 1458 if (u32Value & HDA_REG_FIELD_FLAG_MASK(RIRBWP, RST)) 1457 1459 { 1458 RIRBWP(p State) = 0;1460 RIRBWP(pThis) = 0; 1459 1461 } 1460 1462 /* The remaining bits are O, see 6.2.22 */ … … 1462 1464 } 1463 1465 1464 DECLCALLBACK(int) hdaRegWriteBase( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1465 { 1466 int rc = hdaRegWriteU32(p State, offset, index, u32Value);1466 DECLCALLBACK(int) hdaRegWriteBase(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1467 { 1468 int rc = hdaRegWriteU32(pThis, offset, index, u32Value); 1467 1469 if (RT_FAILURE(rc)) 1468 1470 AssertRCReturn(rc, rc); … … 1470 1472 { 1471 1473 case ICH6_HDA_REG_CORBLBASE: 1472 p State->u64CORBBase &= 0xFFFFFFFF00000000ULL;1473 p State->u64CORBBase |= pState->au32Regs[index];1474 pThis->u64CORBBase &= 0xFFFFFFFF00000000ULL; 1475 pThis->u64CORBBase |= pThis->au32Regs[index]; 1474 1476 break; 1475 1477 case ICH6_HDA_REG_CORBUBASE: 1476 p State->u64CORBBase &= 0x00000000FFFFFFFFULL;1477 p State->u64CORBBase |= ((uint64_t)pState->au32Regs[index] << 32);1478 pThis->u64CORBBase &= 0x00000000FFFFFFFFULL; 1479 pThis->u64CORBBase |= ((uint64_t)pThis->au32Regs[index] << 32); 1478 1480 break; 1479 1481 case ICH6_HDA_REG_RIRLBASE: 1480 p State->u64RIRBBase &= 0xFFFFFFFF00000000ULL;1481 p State->u64RIRBBase |= pState->au32Regs[index];1482 pThis->u64RIRBBase &= 0xFFFFFFFF00000000ULL; 1483 pThis->u64RIRBBase |= pThis->au32Regs[index]; 1482 1484 break; 1483 1485 case ICH6_HDA_REG_RIRUBASE: 1484 p State->u64RIRBBase &= 0x00000000FFFFFFFFULL;1485 p State->u64RIRBBase |= ((uint64_t)pState->au32Regs[index] << 32);1486 pThis->u64RIRBBase &= 0x00000000FFFFFFFFULL; 1487 pThis->u64RIRBBase |= ((uint64_t)pThis->au32Regs[index] << 32); 1486 1488 break; 1487 1489 case ICH6_HDA_REG_DPLBASE: 1488 1490 /* @todo: first bit has special meaning */ 1489 p State->u64DPBase &= 0xFFFFFFFF00000000ULL;1490 p State->u64DPBase |= pState->au32Regs[index];1491 pThis->u64DPBase &= 0xFFFFFFFF00000000ULL; 1492 pThis->u64DPBase |= pThis->au32Regs[index]; 1491 1493 break; 1492 1494 case ICH6_HDA_REG_DPUBASE: 1493 p State->u64DPBase &= 0x00000000FFFFFFFFULL;1494 p State->u64DPBase |= ((uint64_t)pState->au32Regs[index] << 32);1495 pThis->u64DPBase &= 0x00000000FFFFFFFFULL; 1496 pThis->u64DPBase |= ((uint64_t)pThis->au32Regs[index] << 32); 1495 1497 break; 1496 1498 default: 1497 1499 AssertMsgFailed(("Invalid index")); 1498 1500 } 1499 Log(("hda: CORB base:%llx RIRB base: %llx DP base: %llx\n", p State->u64CORBBase, pState->u64RIRBBase, pState->u64DPBase));1501 Log(("hda: CORB base:%llx RIRB base: %llx DP base: %llx\n", pThis->u64CORBBase, pThis->u64RIRBBase, pThis->u64DPBase)); 1500 1502 return rc; 1501 1503 } 1502 1504 1503 DECLCALLBACK(int) hdaRegWriteRIRBSTS( INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value)1504 { 1505 uint8_t v = RIRBSTS(p State);1506 RIRBSTS(p State) &= ~(v & u32Value);1507 1508 return hdaProcessInterrupt(p State);1505 DECLCALLBACK(int) hdaRegWriteRIRBSTS(PHDASTATE pThis, uint32_t offset, uint32_t index, uint32_t u32Value) 1506 { 1507 uint8_t v = RIRBSTS(pThis); 1508 RIRBSTS(pThis) &= ~(v & u32Value); 1509 1510 return hdaProcessInterrupt(pThis); 1509 1511 } 1510 1512 1511 1513 #ifdef LOG_ENABLED 1512 static void dump_bd( INTELHDLinkState *pState, PHDABDLEDESC pBdle, uint64_t u64BaseDMA)1514 static void dump_bd(PHDASTATE pThis, PHDABDLEDESC pBdle, uint64_t u64BaseDMA) 1513 1515 { 1514 1516 #if 0 … … 1523 1525 for (i = 0; i <= pBdle->u32BdleMaxCvi; ++i) 1524 1526 { 1525 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(p State), u64BaseDMA + i*16, bdle, 16);1527 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pThis), u64BaseDMA + i*16, bdle, 16); 1526 1528 addr = *(uint64_t *)bdle; 1527 1529 len = *(uint32_t *)&bdle[8]; … … 1533 1535 for (i = 0; i < 8; ++i) 1534 1536 { 1535 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(p State), (pState->u64DPBase & DPBASE_ADDR_MASK) + i*8, &counter, sizeof(&counter));1536 Log(("hda: %s stream[%d] counter=%x\n", i == SDCTL_NUM(p State, 4) || i == SDCTL_NUM(pState, 0)? "[C]": " ",1537 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pThis), (pThis->u64DPBase & DPBASE_ADDR_MASK) + i*8, &counter, sizeof(&counter)); 1538 Log(("hda: %s stream[%d] counter=%x\n", i == SDCTL_NUM(pThis, 4) || i == SDCTL_NUM(pThis, 0)? "[C]": " ", 1537 1539 i , counter)); 1538 1540 } … … 1541 1543 #endif 1542 1544 1543 static void hdaFetchBdle( INTELHDLinkState *pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc)1545 static void hdaFetchBdle(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc) 1544 1546 { 1545 1547 uint8_t bdle[16]; … … 1547 1549 && pBdle 1548 1550 && pBdle->u32BdleMaxCvi)); 1549 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(p State), pStreamDesc->u64BaseDMA + pBdle->u32BdleCvi*16, bdle, 16);1551 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pThis), pStreamDesc->u64BaseDMA + pBdle->u32BdleCvi*16, bdle, 16); 1550 1552 pBdle->u64BdleCviAddr = *(uint64_t *)bdle; 1551 1553 pBdle->u32BdleCviLen = *(uint32_t *)&bdle[8]; 1552 1554 pBdle->fBdleCviIoc = (*(uint32_t *)&bdle[12]) & 0x1; 1553 1555 #ifdef LOG_ENABLED 1554 dump_bd(p State, pBdle, pStreamDesc->u64BaseDMA);1556 dump_bd(pThis, pBdle, pStreamDesc->u64BaseDMA); 1555 1557 #endif 1556 1558 } … … 1625 1627 } 1626 1628 1627 DECLINLINE(void) hdaBackendTransferUnreported( INTELHDLinkState *pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc,1629 DECLINLINE(void) hdaBackendTransferUnreported(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, 1628 1630 uint32_t cbCopied, uint32_t *pu32BackendBufferCapacity) 1629 1631 { … … 1635 1637 *pu32BackendBufferCapacity -= cbCopied; 1636 1638 Log(("hda:hdaBackendTransferUnreported: CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); 1637 Assert((pBdle->cbUnderFifoW <= hdaFifoWToSz(p State, pStreamDesc)));1638 } 1639 1640 DECLINLINE(bool) hdaIsTransferCountersOverlapped(P INTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc)1639 Assert((pBdle->cbUnderFifoW <= hdaFifoWToSz(pThis, pStreamDesc))); 1640 } 1641 1642 DECLINLINE(bool) hdaIsTransferCountersOverlapped(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc) 1641 1643 { 1642 1644 bool fOnBufferEdge = ( *pStreamDesc->pu32Lpib == pStreamDesc->u32Cbl … … 1647 1649 if (*pStreamDesc->pu32Lpib == pStreamDesc->u32Cbl) 1648 1650 *pStreamDesc->pu32Lpib -= pStreamDesc->u32Cbl; 1649 hdaUpdatePosBuf(p State, pStreamDesc);1651 hdaUpdatePosBuf(pThis, pStreamDesc); 1650 1652 1651 1653 /* don't touch BdleCvi counter on uninitialized descriptor */ … … 1661 1663 } 1662 1664 1663 DECLINLINE(void) hdaStreamCounterUpdate(P INTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc,1665 DECLINLINE(void) hdaStreamCounterUpdate(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, 1664 1666 uint32_t cbInc) 1665 1667 { … … 1677 1679 Assert((*pStreamDesc->pu32Lpib <= pStreamDesc->u32Cbl)); 1678 1680 1679 hdaUpdatePosBuf(p State, pStreamDesc);1680 1681 } 1682 } 1683 1684 static bool hdaDoNextTransferCycle(P INTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc)1681 hdaUpdatePosBuf(pThis, pStreamDesc); 1682 1683 } 1684 } 1685 1686 static bool hdaDoNextTransferCycle(PHDASTATE pThis, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc) 1685 1687 { 1686 1688 bool fDoNextTransferLoop = true; … … 1702 1704 */ 1703 1705 if (pStreamDesc->u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, ICE)) 1704 hdaProcessInterrupt(p State);1706 hdaProcessInterrupt(pThis); 1705 1707 } 1706 1708 fDoNextTransferLoop = false; … … 1713 1715 * Note: this function writes to the DMA buffer immediately, but "reports bytes" when all conditions are met (FIFOW) 1714 1716 */ 1715 static uint32_t hdaReadAudio( INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t *pu32Avail, bool *fStop, uint32_t u32CblLimit)1716 { 1717 PHDABDLEDESC pBdle = &p State->StInBdle;1717 static uint32_t hdaReadAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t *pu32Avail, bool *fStop, uint32_t u32CblLimit) 1718 { 1719 PHDABDLEDESC pBdle = &pThis->StInBdle; 1718 1720 uint32_t cbTransferred = 0; 1719 1721 uint32_t cb2Copy = 0; … … 1734 1736 * read from backend input line to the last unreported position or at the begining. 1735 1737 */ 1736 cbBackendCopy = AUD_read (pState->Codec.SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy);1738 cbBackendCopy = AUD_read(pThis->Codec.SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy); 1737 1739 /* 1738 1740 * write the HDA DMA buffer 1739 1741 */ 1740 PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(p State), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy);1742 PDMDevHlpPhysWrite(ICH6_HDASTATE_2_DEVINS(pThis), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer, cbBackendCopy); 1741 1743 1742 1744 /* Don't see any reason why cb2Copy would differ from cbBackendCopy */ 1743 1745 Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */ 1744 1746 1745 if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(p State, 0))1747 if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pThis, 0)) 1746 1748 hdaBackendReadTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail); 1747 1749 else 1748 1750 { 1749 hdaBackendTransferUnreported(p State, pBdle, pStreamDesc, cbBackendCopy, pu32Avail);1751 hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cbBackendCopy, pu32Avail); 1750 1752 *fStop = true; 1751 1753 } 1752 1754 l_done: 1753 Assert((cbTransferred <= (SDFIFOS(p State, 0) + 1)));1755 Assert((cbTransferred <= (SDFIFOS(pThis, 0) + 1))); 1754 1756 Log(("hda:ra: CVI(pos:%d, len:%d) cbTransferred: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred)); 1755 1757 return cbTransferred; 1756 1758 } 1757 1759 1758 static uint32_t hdaWriteAudio( INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t *pu32Avail, bool *fStop, uint32_t u32CblLimit)1759 { 1760 PHDABDLEDESC pBdle = &p State->StOutBdle;1760 static uint32_t hdaWriteAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t *pu32Avail, bool *fStop, uint32_t u32CblLimit) 1761 { 1762 PHDABDLEDESC pBdle = &pThis->StOutBdle; 1761 1763 uint32_t cbTransferred = 0; 1762 1764 uint32_t cb2Copy = 0; /* local byte counter (on local buffer) */ … … 1776 1778 } 1777 1779 1778 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(p State), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy);1780 PDMDevHlpPhysRead(ICH6_HDASTATE_2_DEVINS(pThis), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy); 1779 1781 /* 1780 1782 * Write to audio backend. we should ensure that we have enough bytes to copy to the backend. 1781 1783 */ 1782 if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(p State, pStreamDesc))1784 if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pThis, pStreamDesc)) 1783 1785 { 1784 1786 /* 1785 1787 * Feed the newly fetched samples, including unreported ones, to the backend. 1786 1788 */ 1787 cbBackendCopy = AUD_write (p State->Codec.SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW);1789 cbBackendCopy = AUD_write (pThis->Codec.SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW); 1788 1790 hdaBackendWriteTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail); 1789 1791 } … … 1791 1793 { 1792 1794 /* Not enough bytes to be processed and reported, we'll try our luck next time around */ 1793 hdaBackendTransferUnreported(p State, pBdle, pStreamDesc, cb2Copy, NULL);1795 hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cb2Copy, NULL); 1794 1796 *fStop = true; 1795 1797 } 1796 1798 1797 1799 l_done: 1798 Assert( (cbTransferred <= (SDFIFOS(pState, 4) + 1)));1800 Assert(cbTransferred <= SDFIFOS(pThis, 4) + 1); 1799 1801 Log(("hda:wa: CVI(pos:%d, len:%d, cbTransferred:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred)); 1800 1802 return cbTransferred; … … 1806 1808 DECLCALLBACK(int) hdaCodecReset(CODECState *pCodecState) 1807 1809 { 1808 INTELHDLinkState *pState= (INTELHDLinkState *)pCodecState->pvHDAState;1810 PHDASTATE pThis = (INTELHDLinkState *)pCodecState->pvHDAState; 1809 1811 return VINF_SUCCESS; 1810 1812 } 1811 1813 1812 DECLINLINE(void) hdaInitTransferDescriptor(P INTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm,1814 DECLINLINE(void) hdaInitTransferDescriptor(PHDASTATE pThis, PHDABDLEDESC pBdle, uint8_t u8Strm, 1813 1815 PHDASTREAMTRANSFERDESC pStreamDesc) 1814 1816 { 1815 Assert(p State); Assert(pBdle); Assert(pStreamDesc); Assert(u8Strm <= 7);1817 Assert(pThis); Assert(pBdle); Assert(pStreamDesc); Assert(u8Strm <= 7); 1816 1818 1817 1819 memset(pStreamDesc, 0, sizeof(HDASTREAMTRANSFERDESC)); 1818 1820 pStreamDesc->u8Strm = u8Strm; 1819 pStreamDesc->u32Ctl = HDA_STREAM_REG2(p State, CTL, u8Strm);1820 pStreamDesc->u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG2(p State, BDPL, u8Strm),1821 HDA_STREAM_REG2(p State, BDPU, u8Strm));1822 pStreamDesc->pu32Lpib = &HDA_STREAM_REG2(p State, LPIB, u8Strm);1823 pStreamDesc->pu32Sts = &HDA_STREAM_REG2(p State, STS, u8Strm);1824 pStreamDesc->u32Cbl = HDA_STREAM_REG2(p State, CBL, u8Strm);1825 pStreamDesc->u32Fifos = HDA_STREAM_REG2(p State, FIFOS, u8Strm);1826 1827 pBdle->u32BdleMaxCvi = HDA_STREAM_REG2(p State, LVI, u8Strm);1821 pStreamDesc->u32Ctl = HDA_STREAM_REG2(pThis, CTL, u8Strm); 1822 pStreamDesc->u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG2(pThis, BDPL, u8Strm), 1823 HDA_STREAM_REG2(pThis, BDPU, u8Strm)); 1824 pStreamDesc->pu32Lpib = &HDA_STREAM_REG2(pThis, LPIB, u8Strm); 1825 pStreamDesc->pu32Sts = &HDA_STREAM_REG2(pThis, STS, u8Strm); 1826 pStreamDesc->u32Cbl = HDA_STREAM_REG2(pThis, CBL, u8Strm); 1827 pStreamDesc->u32Fifos = HDA_STREAM_REG2(pThis, FIFOS, u8Strm); 1828 1829 pBdle->u32BdleMaxCvi = HDA_STREAM_REG2(pThis, LVI, u8Strm); 1828 1830 1829 1831 #ifdef LOG_ENABLED … … 1832 1834 { 1833 1835 Log(("Initialization of transfer descriptor:\n")); 1834 dump_bd(p State, pBdle, pStreamDesc->u64BaseDMA);1836 dump_bd(pThis, pBdle, pStreamDesc->u64BaseDMA); 1835 1837 } 1836 1838 #endif … … 1843 1845 static DECLCALLBACK(void) hdaTransfer(CODECState *pCodecState, ENMSOUNDSOURCE src, int avail) 1844 1846 { 1845 INTELHDLinkState *pState= (INTELHDLinkState *)pCodecState->pvHDAState;1847 PHDASTATE pThis = (INTELHDLinkState *)pCodecState->pvHDAState; 1846 1848 uint8_t u8Strm = 0; 1847 1849 PHDABDLEDESC pBdle = NULL; … … 1852 1854 { 1853 1855 u8Strm = 4; 1854 pBdle = &p State->StOutBdle;1856 pBdle = &pThis->StOutBdle; 1855 1857 break; 1856 1858 } … … 1858 1860 { 1859 1861 u8Strm = 0; 1860 pBdle = &p State->StInBdle;1862 pBdle = &pThis->StInBdle; 1861 1863 break; 1862 1864 } … … 1866 1868 1867 1869 HDASTREAMTRANSFERDESC StreamDesc; 1868 hdaInitTransferDescriptor(p State, pBdle, u8Strm, &StreamDesc);1870 hdaInitTransferDescriptor(pThis, pBdle, u8Strm, &StreamDesc); 1869 1871 1870 1872 bool fStop = false; … … 1877 1879 /* Fetch the Buffer Descriptor Entry (BDE). */ 1878 1880 1879 if (hdaIsTransferCountersOverlapped(p State, pBdle, &StreamDesc))1880 hdaFetchBdle(p State, pBdle, &StreamDesc);1881 if (hdaIsTransferCountersOverlapped(pThis, pBdle, &StreamDesc)) 1882 hdaFetchBdle(pThis, pBdle, &StreamDesc); 1881 1883 *StreamDesc.pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY); 1882 1884 Assert((avail >= 0 && (StreamDesc.u32Cbl >= (*StreamDesc.pu32Lpib)))); /* sanity */ 1883 1885 uint32_t u32CblLimit = StreamDesc.u32Cbl - (*StreamDesc.pu32Lpib); 1884 Assert((u32CblLimit > hdaFifoWToSz(p State, &StreamDesc)));1886 Assert((u32CblLimit > hdaFifoWToSz(pThis, &StreamDesc))); 1885 1887 Log(("hda: CBL=%d, LPIB=%d\n", StreamDesc.u32Cbl, *StreamDesc.pu32Lpib)); 1886 1888 uint32_t cb; … … 1888 1890 { 1889 1891 case PO_INDEX: 1890 cb = hdaWriteAudio(p State, &StreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit);1892 cb = hdaWriteAudio(pThis, &StreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit); 1891 1893 break; 1892 1894 case PI_INDEX: 1893 cb = hdaReadAudio(p State, &StreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit);1895 cb = hdaReadAudio(pThis, &StreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit); 1894 1896 break; 1895 1897 default: … … 1902 1904 1903 1905 /* Process end of buffer condition. */ 1904 hdaStreamCounterUpdate(p State, pBdle, &StreamDesc, cb);1905 fStop = !fStop ? !hdaDoNextTransferCycle(p State, pBdle, &StreamDesc) : fStop;1906 hdaStreamCounterUpdate(pThis, pBdle, &StreamDesc, cb); 1907 fStop = !fStop ? !hdaDoNextTransferCycle(pThis, pBdle, &StreamDesc) : fStop; 1906 1908 } 1907 1909 } … … 1920 1922 { 1921 1923 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 1922 uint32_t offReg = GCPhysAddr - pThis-> addrMMReg;1924 uint32_t offReg = GCPhysAddr - pThis->MMIOBaseAddr; 1923 1925 int idxReg = hdaMMIORegLookup(pThis, offReg); 1924 1926 int rc; … … 1951 1953 { 1952 1954 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 1953 uint32_t offReg = GCPhysAddr - pThis-> addrMMReg;1955 uint32_t offReg = GCPhysAddr - pThis->MMIOBaseAddr; 1954 1956 int idxReg = hdaMMIORegLookup(pThis, offReg); 1955 1957 int rc; … … 2001 2003 return rc; 2002 2004 2003 pThis-> addrMMReg= GCPhysAddress;2005 pThis->MMIOBaseAddr = GCPhysAddress; 2004 2006 return VINF_SUCCESS; 2005 2007 } … … 2210 2212 2211 2213 2212 static int hdaLookUpRegisterByName( INTELHDLinkState *pState, const char *pszArgs)2214 static int hdaLookUpRegisterByName(PHDASTATE pThis, const char *pszArgs) 2213 2215 { 2214 2216 int iReg = 0; … … 2220 2222 2221 2223 2222 static void hdaDbgPrintRegister( INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaIndex)2223 { 2224 Assert( p State2224 static void hdaDbgPrintRegister(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaIndex) 2225 { 2226 Assert( pThis 2225 2227 && iHdaIndex >= 0 2226 2228 && iHdaIndex < HDA_NREGS); 2227 pHlp->pfnPrintf(pHlp, "hda: %s: 0x%x\n", g_aIchIntelHDRegMap[iHdaIndex].abbrev, p State->au32Regs[iHdaIndex]);2229 pHlp->pfnPrintf(pHlp, "hda: %s: 0x%x\n", g_aIchIntelHDRegMap[iHdaIndex].abbrev, pThis->au32Regs[iHdaIndex]); 2228 2230 } 2229 2231 … … 2244 2246 2245 2247 2246 static void hdaDbgPrintStream( INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaStrmIndex)2247 { 2248 Assert( p State2248 static void hdaDbgPrintStream(PHDASTATE pThis, PCDBGFINFOHLP pHlp, int iHdaStrmIndex) 2249 { 2250 Assert( pThis 2249 2251 && iHdaStrmIndex >= 0 2250 2252 && iHdaStrmIndex < 7); 2251 2253 pHlp->pfnPrintf(pHlp, "Dump of %d HDA Stream:\n", iHdaStrmIndex); 2252 pHlp->pfnPrintf(pHlp, "SD%dCTL: %R[sdctl]\n", iHdaStrmIndex, HDA_STREAM_REG2(p State, CTL, iHdaStrmIndex));2253 pHlp->pfnPrintf(pHlp, "SD%dCTS: %R[sdsts]\n", iHdaStrmIndex, HDA_STREAM_REG2(p State, STS, iHdaStrmIndex));2254 pHlp->pfnPrintf(pHlp, "SD%dFIFOS: %R[sdfifos]\n", iHdaStrmIndex, HDA_STREAM_REG2(p State, FIFOS, iHdaStrmIndex));2255 pHlp->pfnPrintf(pHlp, "SD%dFIFOW: %R[sdfifow]\n", iHdaStrmIndex, HDA_STREAM_REG2(p State, FIFOW, iHdaStrmIndex));2256 } 2257 2258 2259 static int hdaLookUpStreamIndex( INTELHDLinkState *pState, const char *pszArgs)2254 pHlp->pfnPrintf(pHlp, "SD%dCTL: %R[sdctl]\n", iHdaStrmIndex, HDA_STREAM_REG2(pThis, CTL, iHdaStrmIndex)); 2255 pHlp->pfnPrintf(pHlp, "SD%dCTS: %R[sdsts]\n", iHdaStrmIndex, HDA_STREAM_REG2(pThis, STS, iHdaStrmIndex)); 2256 pHlp->pfnPrintf(pHlp, "SD%dFIFOS: %R[sdfifos]\n", iHdaStrmIndex, HDA_STREAM_REG2(pThis, FIFOS, iHdaStrmIndex)); 2257 pHlp->pfnPrintf(pHlp, "SD%dFIFOW: %R[sdfifow]\n", iHdaStrmIndex, HDA_STREAM_REG2(pThis, FIFOW, iHdaStrmIndex)); 2258 } 2259 2260 2261 static int hdaLookUpStreamIndex(PHDASTATE pThis, const char *pszArgs) 2260 2262 { 2261 2263 /* todo: add args parsing */
Note:
See TracChangeset
for help on using the changeset viewer.