Changeset 44633 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Feb 11, 2013 3:09:46 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83721
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchIntelHDA.cpp
r44571 r44633 5 5 6 6 /* 7 * Copyright (C) 2006-201 2Oracle Corporation7 * Copyright (C) 2006-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 37 37 #include "DevCodec.h" 38 38 39 40 /******************************************************************************* 41 * Defined Constants And Macros * 42 *******************************************************************************/ 43 //#define HDA_AS_PCI_EXPRESS 39 44 #define VBOX_WITH_INTEL_HDA 40 45 … … 55 60 #endif 56 61 57 PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb);58 PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb);59 static DECLCALLBACK(void) hdaReset (PPDMDEVINS pDevIns);60 61 62 #define HDA_NREGS 112 62 63 /* Registers */ … … 82 83 */ 83 84 #define HDA_MAKE_GCAP(oss, iss, bss, bds, b64sup) \ 84 ( (((oss) & 0xF) << 12)\85 | (((iss) & 0xF) << 8)\85 ( (((oss) & 0xF) << 12) \ 86 | (((iss) & 0xF) << 8) \ 86 87 | (((bss) & 0x1F) << 3) \ 87 | (((bds) & 0x3) << 2)\88 | (((bds) & 0x3) << 2) \ 88 89 | ((b64sup) & 1)) 89 #define ICH6_HDA_REG_VMIN 1 /* range 0x02 */90 #define VMIN(pState) (HDA_REG((pState), VMIN))91 92 #define ICH6_HDA_REG_VMAJ 2 /* range 0x03 */93 #define VMAJ(pState) (HDA_REG((pState), VMAJ))94 95 #define ICH6_HDA_REG_OUTPAY 3 /* range 0x04-0x05 */96 #define OUTPAY(pState) (HDA_REG((pState), OUTPAY))97 98 #define ICH6_HDA_REG_INPAY 4 /* range 0x06-0x07 */99 #define INPAY(pState) (HDA_REG((pState), INPAY))100 101 #define ICH6_HDA_REG_GCTL (5)102 #define ICH6_HDA_GCTL_RST_SHIFT (0)103 #define ICH6_HDA_GCTL_FSH_SHIFT (1)104 #define ICH6_HDA_GCTL_UR_SHIFT (8)105 #define GCTL(pState) (HDA_REG((pState), GCTL))106 107 #define ICH6_HDA_REG_WAKEEN 6 /* 0x0C */108 #define WAKEEN(pState) (HDA_REG((pState), WAKEEN))109 110 #define ICH6_HDA_REG_STATESTS 7 /* range 0x0E */111 #define STATESTS(pState) (HDA_REG((pState), STATESTS))112 #define ICH6_HDA_STATES_SCSF 0x7113 114 #define ICH6_HDA_REG_GSTS 8 /* range 0x10-0x11*/115 #define ICH6_HDA_GSTS_FSH_SHIFT (1)116 #define GSTS(pState) (HDA_REG(pState, GSTS))117 118 #define ICH6_HDA_REG_INTCTL 9 /* 0x20 */119 #define ICH6_HDA_INTCTL_GIE_SHIFT 31120 #define ICH6_HDA_INTCTL_CIE_SHIFT 30121 #define ICH6_HDA_INTCTL_S0_SHIFT (0)122 #define ICH6_HDA_INTCTL_S1_SHIFT (1)123 #define ICH6_HDA_INTCTL_S2_SHIFT (2)124 #define ICH6_HDA_INTCTL_S3_SHIFT (3)125 #define ICH6_HDA_INTCTL_S4_SHIFT (4)126 #define ICH6_HDA_INTCTL_S5_SHIFT (5)127 #define ICH6_HDA_INTCTL_S6_SHIFT (6)128 #define ICH6_HDA_INTCTL_S7_SHIFT (7)129 #define INTCTL(pState) (HDA_REG((pState), INTCTL))130 #define INTCTL_GIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, GIE))131 #define INTCTL_CIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, CIE))132 #define INTCTL_SX(pState, X) (HDA_REG_FLAG_VALUE((pState), INTCTL, S##X))133 #define INTCTL_SALL(pState) (INTCTL((pState)) & 0xFF)90 #define ICH6_HDA_REG_VMIN 1 /* range 0x02 */ 91 #define VMIN(pState) (HDA_REG((pState), VMIN)) 92 93 #define ICH6_HDA_REG_VMAJ 2 /* range 0x03 */ 94 #define VMAJ(pState) (HDA_REG((pState), VMAJ)) 95 96 #define ICH6_HDA_REG_OUTPAY 3 /* range 0x04-0x05 */ 97 #define OUTPAY(pState) (HDA_REG((pState), OUTPAY)) 98 99 #define ICH6_HDA_REG_INPAY 4 /* range 0x06-0x07 */ 100 #define INPAY(pState) (HDA_REG((pState), INPAY)) 101 102 #define ICH6_HDA_REG_GCTL (5) 103 #define ICH6_HDA_GCTL_RST_SHIFT (0) 104 #define ICH6_HDA_GCTL_FSH_SHIFT (1) 105 #define ICH6_HDA_GCTL_UR_SHIFT (8) 106 #define GCTL(pState) (HDA_REG((pState), GCTL)) 107 108 #define ICH6_HDA_REG_WAKEEN 6 /* 0x0C */ 109 #define WAKEEN(pState) (HDA_REG((pState), WAKEEN)) 110 111 #define ICH6_HDA_REG_STATESTS 7 /* range 0x0E */ 112 #define STATESTS(pState) (HDA_REG((pState), STATESTS)) 113 #define ICH6_HDA_STATES_SCSF 0x7 114 115 #define ICH6_HDA_REG_GSTS 8 /* range 0x10-0x11*/ 116 #define ICH6_HDA_GSTS_FSH_SHIFT (1) 117 #define GSTS(pState) (HDA_REG(pState, GSTS)) 118 119 #define ICH6_HDA_REG_INTCTL 9 /* 0x20 */ 120 #define ICH6_HDA_INTCTL_GIE_SHIFT 31 121 #define ICH6_HDA_INTCTL_CIE_SHIFT 30 122 #define ICH6_HDA_INTCTL_S0_SHIFT (0) 123 #define ICH6_HDA_INTCTL_S1_SHIFT (1) 124 #define ICH6_HDA_INTCTL_S2_SHIFT (2) 125 #define ICH6_HDA_INTCTL_S3_SHIFT (3) 126 #define ICH6_HDA_INTCTL_S4_SHIFT (4) 127 #define ICH6_HDA_INTCTL_S5_SHIFT (5) 128 #define ICH6_HDA_INTCTL_S6_SHIFT (6) 129 #define ICH6_HDA_INTCTL_S7_SHIFT (7) 130 #define INTCTL(pState) (HDA_REG((pState), INTCTL)) 131 #define INTCTL_GIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, GIE)) 132 #define INTCTL_CIE(pState) (HDA_REG_FLAG_VALUE(pState, INTCTL, CIE)) 133 #define INTCTL_SX(pState, X) (HDA_REG_FLAG_VALUE((pState), INTCTL, S##X)) 134 #define INTCTL_SALL(pState) (INTCTL((pState)) & 0xFF) 134 135 135 136 /* Note: The HDA specification defines a SSYNC register at offset 0x38. The … … 137 138 * the datasheet. 138 139 */ 139 #define ICH6_HDA_REG_SSYNC 12 /* 0x34 */140 #define SSYNC(pState) (HDA_REG((pState), SSYNC))141 142 #define ICH6_HDA_REG_INTSTS 10 /* 0x24 */143 #define ICH6_HDA_INTSTS_GIS_SHIFT (31)144 #define ICH6_HDA_INTSTS_CIS_SHIFT (30)145 #define ICH6_HDA_INTSTS_S0_SHIFT (0)146 #define ICH6_HDA_INTSTS_S1_SHIFT (1)147 #define ICH6_HDA_INTSTS_S2_SHIFT (2)148 #define ICH6_HDA_INTSTS_S3_SHIFT (3)149 #define ICH6_HDA_INTSTS_S4_SHIFT (4)150 #define ICH6_HDA_INTSTS_S5_SHIFT (5)151 #define ICH6_HDA_INTSTS_S6_SHIFT (6)152 #define ICH6_HDA_INTSTS_S7_SHIFT (7)140 #define ICH6_HDA_REG_SSYNC 12 /* 0x34 */ 141 #define SSYNC(pState) (HDA_REG((pState), SSYNC)) 142 143 #define ICH6_HDA_REG_INTSTS 10 /* 0x24 */ 144 #define ICH6_HDA_INTSTS_GIS_SHIFT (31) 145 #define ICH6_HDA_INTSTS_CIS_SHIFT (30) 146 #define ICH6_HDA_INTSTS_S0_SHIFT (0) 147 #define ICH6_HDA_INTSTS_S1_SHIFT (1) 148 #define ICH6_HDA_INTSTS_S2_SHIFT (2) 149 #define ICH6_HDA_INTSTS_S3_SHIFT (3) 150 #define ICH6_HDA_INTSTS_S4_SHIFT (4) 151 #define ICH6_HDA_INTSTS_S5_SHIFT (5) 152 #define ICH6_HDA_INTSTS_S6_SHIFT (6) 153 #define ICH6_HDA_INTSTS_S7_SHIFT (7) 153 154 #define ICH6_HDA_INTSTS_S_MASK(num) RT_BIT(HDA_REG_FIELD_SHIFT(S##num)) 154 #define INTSTS(pState) (HDA_REG((pState), INTSTS))155 #define INTSTS_GIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, GIS)156 #define INTSTS_CIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, CIS)157 #define INTSTS_SX(pState, X) (HDA_REG_FLAG_VALUE(pState), INTSTS, S##X)158 #define INTSTS_SANY(pState) (INTSTS((pState)) & 0xFF)159 160 #define ICH6_HDA_REG_CORBLBASE 13 /* 0x40 */161 #define CORBLBASE(pState) (HDA_REG((pState), CORBLBASE))162 #define ICH6_HDA_REG_CORBUBASE 14 /* 0x44 */163 #define CORBUBASE(pState) (HDA_REG((pState), CORBUBASE))164 #define ICH6_HDA_REG_CORBWP 15 /* 48 */165 #define ICH6_HDA_REG_CORBRP 16 /* 4A */166 #define ICH6_HDA_CORBRP_RST_SHIFT 15167 #define ICH6_HDA_CORBRP_WP_SHIFT 0168 #define ICH6_HDA_CORBRP_WP_MASK 0xFF169 170 #define CORBRP(pState) (HDA_REG(pState, CORBRP))171 #define CORBWP(pState) (HDA_REG(pState, CORBWP))172 173 #define ICH6_HDA_REG_CORBCTL 17 /* 0x4C */174 #define ICH6_HDA_CORBCTL_DMA_SHIFT (1)155 #define INTSTS(pState) (HDA_REG((pState), INTSTS)) 156 #define INTSTS_GIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, GIS) 157 #define INTSTS_CIS(pState) (HDA_REG_FLAG_VALUE((pState), INTSTS, CIS) 158 #define INTSTS_SX(pState, X) (HDA_REG_FLAG_VALUE(pState), INTSTS, S##X) 159 #define INTSTS_SANY(pState) (INTSTS((pState)) & 0xFF) 160 161 #define ICH6_HDA_REG_CORBLBASE 13 /* 0x40 */ 162 #define CORBLBASE(pState) (HDA_REG((pState), CORBLBASE)) 163 #define ICH6_HDA_REG_CORBUBASE 14 /* 0x44 */ 164 #define CORBUBASE(pState) (HDA_REG((pState), CORBUBASE)) 165 #define ICH6_HDA_REG_CORBWP 15 /* 48 */ 166 #define ICH6_HDA_REG_CORBRP 16 /* 4A */ 167 #define ICH6_HDA_CORBRP_RST_SHIFT 15 168 #define ICH6_HDA_CORBRP_WP_SHIFT 0 169 #define ICH6_HDA_CORBRP_WP_MASK 0xFF 170 171 #define CORBRP(pState) (HDA_REG(pState, CORBRP)) 172 #define CORBWP(pState) (HDA_REG(pState, CORBWP)) 173 174 #define ICH6_HDA_REG_CORBCTL 17 /* 0x4C */ 175 #define ICH6_HDA_CORBCTL_DMA_SHIFT (1) 175 176 #define ICH6_HDA_CORBCTL_CMEIE_SHIFT (0) 176 177 177 #define CORBCTL(pState) (HDA_REG(pState, CORBCTL))178 179 180 #define ICH6_HDA_REG_CORBSTS 18 /* 0x4D */181 #define CORBSTS(pState) (HDA_REG(pState, CORBSTS))182 #define ICH6_HDA_CORBSTS_CMEI_SHIFT 183 184 #define ICH6_HDA_REG_CORBSIZE 19 /* 0x4E */185 #define ICH6_HDA_CORBSIZE_SZ_CAP 0xF0186 #define ICH6_HDA_CORBSIZE_SZ 0x3187 #define CORBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ)188 #define CORBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ_CAP)178 #define CORBCTL(pState) (HDA_REG(pState, CORBCTL)) 179 180 181 #define ICH6_HDA_REG_CORBSTS 18 /* 0x4D */ 182 #define CORBSTS(pState) (HDA_REG(pState, CORBSTS)) 183 #define ICH6_HDA_CORBSTS_CMEI_SHIFT (0) 184 185 #define ICH6_HDA_REG_CORBSIZE 19 /* 0x4E */ 186 #define ICH6_HDA_CORBSIZE_SZ_CAP 0xF0 187 #define ICH6_HDA_CORBSIZE_SZ 0x3 188 #define CORBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ) 189 #define CORBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_CORBSIZE) & ICH6_HDA_CORBSIZE_SZ_CAP) 189 190 /* till ich 10 sizes of CORB and RIRB are hardcoded to 256 in real hw */ 190 191 191 #define ICH6_HDA_REG_RIRLBASE 20 /* 0x50 */192 #define RIRLBASE(pState) (HDA_REG((pState), RIRLBASE))193 194 #define ICH6_HDA_REG_RIRUBASE 21 /* 0x54 */195 #define RIRUBASE(pState) (HDA_REG((pState), RIRUBASE))196 197 #define ICH6_HDA_REG_RIRBWP 22 /* 0x58 */198 #define ICH6_HDA_RIRBWP_RST_SHIFT (15)199 #define ICH6_HDA_RIRBWP_WP_MASK 0xFF200 #define RIRBWP(pState) (HDA_REG(pState, RIRBWP))201 202 #define ICH6_HDA_REG_RINTCNT 23 /* 0x5A */203 #define RINTCNT(pState) (HDA_REG((pState), RINTCNT))204 #define RINTCNT_N(pState) (RINTCNT((pState)) & 0xff)205 206 #define ICH6_HDA_REG_RIRBCTL 24 /* 0x5C */207 #define ICH6_HDA_RIRBCTL_RIC_SHIFT 208 #define ICH6_HDA_RIRBCTL_DMA_SHIFT 209 #define ICH6_HDA_ROI_DMA_SHIFT 210 #define RIRBCTL(pState) 211 #define RIRBCTL_RIRB_RIC(pState) 212 #define RIRBCTL_RIRB_DMA(pState) 213 #define RIRBCTL_ROI(pState) 214 215 #define ICH6_HDA_REG_RIRBSTS 25 /* 0x5D */192 #define ICH6_HDA_REG_RIRLBASE 20 /* 0x50 */ 193 #define RIRLBASE(pState) (HDA_REG((pState), RIRLBASE)) 194 195 #define ICH6_HDA_REG_RIRUBASE 21 /* 0x54 */ 196 #define RIRUBASE(pState) (HDA_REG((pState), RIRUBASE)) 197 198 #define ICH6_HDA_REG_RIRBWP 22 /* 0x58 */ 199 #define ICH6_HDA_RIRBWP_RST_SHIFT (15) 200 #define ICH6_HDA_RIRBWP_WP_MASK 0xFF 201 #define RIRBWP(pState) (HDA_REG(pState, RIRBWP)) 202 203 #define ICH6_HDA_REG_RINTCNT 23 /* 0x5A */ 204 #define RINTCNT(pState) (HDA_REG((pState), RINTCNT)) 205 #define RINTCNT_N(pState) (RINTCNT((pState)) & 0xff) 206 207 #define ICH6_HDA_REG_RIRBCTL 24 /* 0x5C */ 208 #define ICH6_HDA_RIRBCTL_RIC_SHIFT (0) 209 #define ICH6_HDA_RIRBCTL_DMA_SHIFT (1) 210 #define ICH6_HDA_ROI_DMA_SHIFT (2) 211 #define RIRBCTL(pState) (HDA_REG((pState), RIRBCTL)) 212 #define RIRBCTL_RIRB_RIC(pState) (HDA_REG_FLAG_VALUE(pState, RIRBCTL, RIC)) 213 #define RIRBCTL_RIRB_DMA(pState) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, DMA) 214 #define RIRBCTL_ROI(pState) (HDA_REG_FLAG_VALUE((pState), RIRBCTL, ROI)) 215 216 #define ICH6_HDA_REG_RIRBSTS 25 /* 0x5D */ 216 217 #define ICH6_HDA_RIRBSTS_RINTFL_SHIFT (0) 217 218 #define ICH6_HDA_RIRBSTS_RIRBOIS_SHIFT (2) 218 #define RIRBSTS(pState) (HDA_REG(pState, RIRBSTS))219 #define RIRBSTS_RINTFL(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RINTFL))220 #define RIRBSTS_RIRBOIS(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RIRBOIS))221 222 #define ICH6_HDA_REG_RIRBSIZE 26 /* 0x5E */223 #define ICH6_HDA_RIRBSIZE_SZ_CAP 0xF0224 #define ICH6_HDA_RIRBSIZE_SZ 0x3225 226 #define RIRBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ)227 #define RIRBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ_CAP)228 229 230 #define ICH6_HDA_REG_IC 27 /* 0x60 */231 #define IC(pState) (HDA_REG(pState, IC))232 #define ICH6_HDA_REG_IR 28 /* 0x64 */233 #define IR(pState) (HDA_REG(pState, IR))234 #define ICH6_HDA_REG_IRS 29 /* 0x68 */235 #define ICH6_HDA_IRS_ICB_SHIFT (0)236 #define ICH6_HDA_IRS_IRV_SHIFT (1)237 #define IRS(pState) (HDA_REG(pState, IRS))238 #define IRS_ICB(pState) (HDA_REG_FLAG_VALUE(pState, IRS, ICB))239 #define IRS_IRV(pState) (HDA_REG_FLAG_VALUE(pState, IRS, IRV))240 241 #define ICH6_HDA_REG_DPLBASE 30 /* 0x70 */242 #define DPLBASE(pState) (HDA_REG((pState), DPLBASE))243 #define ICH6_HDA_REG_DPUBASE 31 /* 0x74 */244 #define DPUBASE(pState) (HDA_REG((pState), DPUBASE))245 #define DPBASE_ENABLED 1246 #define DPBASE_ADDR_MASK (~0x7f)247 248 #define HDA_STREAM_REG_DEF(name, num) (ICH6_HDA_REG_SD##num##name)249 #define HDA_STREAM_REG(pState, name, num) (HDA_REG((pState), N_(HDA_STREAM_REG_DEF(name, num))))219 #define RIRBSTS(pState) (HDA_REG(pState, RIRBSTS)) 220 #define RIRBSTS_RINTFL(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RINTFL)) 221 #define RIRBSTS_RIRBOIS(pState) (HDA_REG_FLAG_VALUE(pState, RIRBSTS, RIRBOIS)) 222 223 #define ICH6_HDA_REG_RIRBSIZE 26 /* 0x5E */ 224 #define ICH6_HDA_RIRBSIZE_SZ_CAP 0xF0 225 #define ICH6_HDA_RIRBSIZE_SZ 0x3 226 227 #define RIRBSIZE_SZ(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ) 228 #define RIRBSIZE_SZ_CAP(pState) (HDA_REG(pState, ICH6_HDA_REG_RIRBSIZE) & ICH6_HDA_RIRBSIZE_SZ_CAP) 229 230 231 #define ICH6_HDA_REG_IC 27 /* 0x60 */ 232 #define IC(pState) (HDA_REG(pState, IC)) 233 #define ICH6_HDA_REG_IR 28 /* 0x64 */ 234 #define IR(pState) (HDA_REG(pState, IR)) 235 #define ICH6_HDA_REG_IRS 29 /* 0x68 */ 236 #define ICH6_HDA_IRS_ICB_SHIFT (0) 237 #define ICH6_HDA_IRS_IRV_SHIFT (1) 238 #define IRS(pState) (HDA_REG(pState, IRS)) 239 #define IRS_ICB(pState) (HDA_REG_FLAG_VALUE(pState, IRS, ICB)) 240 #define IRS_IRV(pState) (HDA_REG_FLAG_VALUE(pState, IRS, IRV)) 241 242 #define ICH6_HDA_REG_DPLBASE 30 /* 0x70 */ 243 #define DPLBASE(pState) (HDA_REG((pState), DPLBASE)) 244 #define ICH6_HDA_REG_DPUBASE 31 /* 0x74 */ 245 #define DPUBASE(pState) (HDA_REG((pState), DPUBASE)) 246 #define DPBASE_ENABLED 1 247 #define DPBASE_ADDR_MASK (~(uint64_t)0x7f) 248 249 #define HDA_STREAM_REG_DEF(name, num) (ICH6_HDA_REG_SD##num##name) 250 #define HDA_STREAM_REG(pState, name, num) (HDA_REG((pState), N_(HDA_STREAM_REG_DEF(name, num)))) 250 251 /* Note: sdnum here _MUST_ be stream reg number [0,7] */ 251 #define HDA_STREAM_REG2(pState, name, sdnum) (HDA_REG_IND((pState), ICH6_HDA_REG_SD0##name + (sdnum) * 10))252 253 #define ICH6_HDA_REG_SD0CTL 32 /* 0x80 */254 #define ICH6_HDA_REG_SD1CTL (HDA_STREAM_REG_DEF(CTL, 0) + 10) /* 0xA0 */255 #define ICH6_HDA_REG_SD2CTL (HDA_STREAM_REG_DEF(CTL, 0) + 20) /* 0xC0 */256 #define ICH6_HDA_REG_SD3CTL (HDA_STREAM_REG_DEF(CTL, 0) + 30) /* 0xE0 */257 #define ICH6_HDA_REG_SD4CTL (HDA_STREAM_REG_DEF(CTL, 0) + 40) /* 0x100 */258 #define ICH6_HDA_REG_SD5CTL (HDA_STREAM_REG_DEF(CTL, 0) + 50) /* 0x120 */259 #define ICH6_HDA_REG_SD6CTL (HDA_STREAM_REG_DEF(CTL, 0) + 60) /* 0x140 */260 #define ICH6_HDA_REG_SD7CTL (HDA_STREAM_REG_DEF(CTL, 0) + 70) /* 0x160 */261 262 #define SD(func, num) SD##num##func263 #define SDCTL(pState, num) HDA_REG((pState), SD(CTL, num))264 #define SDCTL_NUM(pState, num) ((SDCTL((pState), num) & HDA_REG_FIELD_MASK(SDCTL,NUM)) >> HDA_REG_FIELD_SHIFT(SDCTL, NUM))265 #define ICH6_HDA_SDCTL_NUM_MASK (0xF)266 #define ICH6_HDA_SDCTL_NUM_SHIFT (20)267 #define ICH6_HDA_SDCTL_DIR_SHIFT (19)268 #define ICH6_HDA_SDCTL_TP_SHIFT (18)252 #define HDA_STREAM_REG2(pState, name, sdnum) (HDA_REG_IND((pState), ICH6_HDA_REG_SD0##name + (sdnum) * 10)) 253 254 #define ICH6_HDA_REG_SD0CTL 32 /* 0x80 */ 255 #define ICH6_HDA_REG_SD1CTL (HDA_STREAM_REG_DEF(CTL, 0) + 10) /* 0xA0 */ 256 #define ICH6_HDA_REG_SD2CTL (HDA_STREAM_REG_DEF(CTL, 0) + 20) /* 0xC0 */ 257 #define ICH6_HDA_REG_SD3CTL (HDA_STREAM_REG_DEF(CTL, 0) + 30) /* 0xE0 */ 258 #define ICH6_HDA_REG_SD4CTL (HDA_STREAM_REG_DEF(CTL, 0) + 40) /* 0x100 */ 259 #define ICH6_HDA_REG_SD5CTL (HDA_STREAM_REG_DEF(CTL, 0) + 50) /* 0x120 */ 260 #define ICH6_HDA_REG_SD6CTL (HDA_STREAM_REG_DEF(CTL, 0) + 60) /* 0x140 */ 261 #define ICH6_HDA_REG_SD7CTL (HDA_STREAM_REG_DEF(CTL, 0) + 70) /* 0x160 */ 262 263 #define SD(func, num) SD##num##func 264 #define SDCTL(pState, num) HDA_REG((pState), SD(CTL, num)) 265 #define SDCTL_NUM(pState, num) ((SDCTL((pState), num) & HDA_REG_FIELD_MASK(SDCTL,NUM)) >> HDA_REG_FIELD_SHIFT(SDCTL, NUM)) 266 #define ICH6_HDA_SDCTL_NUM_MASK (0xF) 267 #define ICH6_HDA_SDCTL_NUM_SHIFT (20) 268 #define ICH6_HDA_SDCTL_DIR_SHIFT (19) 269 #define ICH6_HDA_SDCTL_TP_SHIFT (18) 269 270 #define ICH6_HDA_SDCTL_STRIPE_MASK (0x3) 270 271 #define ICH6_HDA_SDCTL_STRIPE_SHIFT (16) 271 #define ICH6_HDA_SDCTL_DEIE_SHIFT (4)272 #define ICH6_HDA_SDCTL_FEIE_SHIFT (3)273 #define ICH6_HDA_SDCTL_ICE_SHIFT (2)274 #define ICH6_HDA_SDCTL_RUN_SHIFT (1)275 #define ICH6_HDA_SDCTL_SRST_SHIFT (0)276 277 #define ICH6_HDA_REG_SD0STS 33 /* 0x83 */278 #define ICH6_HDA_REG_SD1STS (HDA_STREAM_REG_DEF(STS, 0) + 10) /* 0xA3 */279 #define ICH6_HDA_REG_SD2STS (HDA_STREAM_REG_DEF(STS, 0) + 20) /* 0xC3 */280 #define ICH6_HDA_REG_SD3STS (HDA_STREAM_REG_DEF(STS, 0) + 30) /* 0xE3 */281 #define ICH6_HDA_REG_SD4STS (HDA_STREAM_REG_DEF(STS, 0) + 40) /* 0x103 */282 #define ICH6_HDA_REG_SD5STS (HDA_STREAM_REG_DEF(STS, 0) + 50) /* 0x123 */283 #define ICH6_HDA_REG_SD6STS (HDA_STREAM_REG_DEF(STS, 0) + 60) /* 0x143 */284 #define ICH6_HDA_REG_SD7STS (HDA_STREAM_REG_DEF(STS, 0) + 70) /* 0x163 */285 286 #define SDSTS(pState, num) HDA_REG((pState), SD(STS, num))272 #define ICH6_HDA_SDCTL_DEIE_SHIFT (4) 273 #define ICH6_HDA_SDCTL_FEIE_SHIFT (3) 274 #define ICH6_HDA_SDCTL_ICE_SHIFT (2) 275 #define ICH6_HDA_SDCTL_RUN_SHIFT (1) 276 #define ICH6_HDA_SDCTL_SRST_SHIFT (0) 277 278 #define ICH6_HDA_REG_SD0STS 33 /* 0x83 */ 279 #define ICH6_HDA_REG_SD1STS (HDA_STREAM_REG_DEF(STS, 0) + 10) /* 0xA3 */ 280 #define ICH6_HDA_REG_SD2STS (HDA_STREAM_REG_DEF(STS, 0) + 20) /* 0xC3 */ 281 #define ICH6_HDA_REG_SD3STS (HDA_STREAM_REG_DEF(STS, 0) + 30) /* 0xE3 */ 282 #define ICH6_HDA_REG_SD4STS (HDA_STREAM_REG_DEF(STS, 0) + 40) /* 0x103 */ 283 #define ICH6_HDA_REG_SD5STS (HDA_STREAM_REG_DEF(STS, 0) + 50) /* 0x123 */ 284 #define ICH6_HDA_REG_SD6STS (HDA_STREAM_REG_DEF(STS, 0) + 60) /* 0x143 */ 285 #define ICH6_HDA_REG_SD7STS (HDA_STREAM_REG_DEF(STS, 0) + 70) /* 0x163 */ 286 287 #define SDSTS(pState, num) HDA_REG((pState), SD(STS, num)) 287 288 #define ICH6_HDA_SDSTS_FIFORDY_SHIFT (5) 288 #define ICH6_HDA_SDSTS_DE_SHIFT (4)289 #define ICH6_HDA_SDSTS_FE_SHIFT (3)290 #define ICH6_HDA_SDSTS_BCIS_SHIFT (2)291 292 #define ICH6_HDA_REG_SD0LPIB 34 /* 0x84 */293 #define ICH6_HDA_REG_SD1LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 10) /* 0xA4 */294 #define ICH6_HDA_REG_SD2LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 20) /* 0xC4 */295 #define ICH6_HDA_REG_SD3LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 30) /* 0xE4 */296 #define ICH6_HDA_REG_SD4LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 40) /* 0x104 */297 #define ICH6_HDA_REG_SD5LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 50) /* 0x124 */298 #define ICH6_HDA_REG_SD6LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 60) /* 0x144 */299 #define ICH6_HDA_REG_SD7LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 70) /* 0x164 */300 301 #define SDLPIB(pState, num) HDA_REG((pState), SD(LPIB, num))302 303 #define ICH6_HDA_REG_SD0CBL 35 /* 0x88 */304 #define ICH6_HDA_REG_SD1CBL (HDA_STREAM_REG_DEF(CBL, 0) + 10) /* 0xA8 */305 #define ICH6_HDA_REG_SD2CBL (HDA_STREAM_REG_DEF(CBL, 0) + 20) /* 0xC8 */306 #define ICH6_HDA_REG_SD3CBL (HDA_STREAM_REG_DEF(CBL, 0) + 30) /* 0xE8 */307 #define ICH6_HDA_REG_SD4CBL (HDA_STREAM_REG_DEF(CBL, 0) + 40) /* 0x108 */308 #define ICH6_HDA_REG_SD5CBL (HDA_STREAM_REG_DEF(CBL, 0) + 50) /* 0x128 */309 #define ICH6_HDA_REG_SD6CBL (HDA_STREAM_REG_DEF(CBL, 0) + 60) /* 0x148 */310 #define ICH6_HDA_REG_SD7CBL (HDA_STREAM_REG_DEF(CBL, 0) + 70) /* 0x168 */311 312 #define SDLCBL(pState, num) HDA_REG((pState), SD(CBL, num))313 314 #define ICH6_HDA_REG_SD0LVI 36 /* 0x8C */315 #define ICH6_HDA_REG_SD1LVI (HDA_STREAM_REG_DEF(LVI, 0) + 10) /* 0xAC */316 #define ICH6_HDA_REG_SD2LVI (HDA_STREAM_REG_DEF(LVI, 0) + 20) /* 0xCC */317 #define ICH6_HDA_REG_SD3LVI (HDA_STREAM_REG_DEF(LVI, 0) + 30) /* 0xEC */318 #define ICH6_HDA_REG_SD4LVI (HDA_STREAM_REG_DEF(LVI, 0) + 40) /* 0x10C */319 #define ICH6_HDA_REG_SD5LVI (HDA_STREAM_REG_DEF(LVI, 0) + 50) /* 0x12C */320 #define ICH6_HDA_REG_SD6LVI (HDA_STREAM_REG_DEF(LVI, 0) + 60) /* 0x14C */321 #define ICH6_HDA_REG_SD7LVI (HDA_STREAM_REG_DEF(LVI, 0) + 70) /* 0x16C */322 323 #define SDLVI(pState, num) HDA_REG((pState), SD(LVI, num))324 325 #define ICH6_HDA_REG_SD0FIFOW 37 /* 0x8E */326 #define ICH6_HDA_REG_SD1FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 10) /* 0xAE */327 #define ICH6_HDA_REG_SD2FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 20) /* 0xCE */328 #define ICH6_HDA_REG_SD3FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 30) /* 0xEE */329 #define ICH6_HDA_REG_SD4FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 40) /* 0x10E */330 #define ICH6_HDA_REG_SD5FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 50) /* 0x12E */331 #define ICH6_HDA_REG_SD6FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 60) /* 0x14E */332 #define ICH6_HDA_REG_SD7FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 70) /* 0x16E */289 #define ICH6_HDA_SDSTS_DE_SHIFT (4) 290 #define ICH6_HDA_SDSTS_FE_SHIFT (3) 291 #define ICH6_HDA_SDSTS_BCIS_SHIFT (2) 292 293 #define ICH6_HDA_REG_SD0LPIB 34 /* 0x84 */ 294 #define ICH6_HDA_REG_SD1LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 10) /* 0xA4 */ 295 #define ICH6_HDA_REG_SD2LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 20) /* 0xC4 */ 296 #define ICH6_HDA_REG_SD3LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 30) /* 0xE4 */ 297 #define ICH6_HDA_REG_SD4LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 40) /* 0x104 */ 298 #define ICH6_HDA_REG_SD5LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 50) /* 0x124 */ 299 #define ICH6_HDA_REG_SD6LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 60) /* 0x144 */ 300 #define ICH6_HDA_REG_SD7LPIB (HDA_STREAM_REG_DEF(LPIB, 0) + 70) /* 0x164 */ 301 302 #define SDLPIB(pState, num) HDA_REG((pState), SD(LPIB, num)) 303 304 #define ICH6_HDA_REG_SD0CBL 35 /* 0x88 */ 305 #define ICH6_HDA_REG_SD1CBL (HDA_STREAM_REG_DEF(CBL, 0) + 10) /* 0xA8 */ 306 #define ICH6_HDA_REG_SD2CBL (HDA_STREAM_REG_DEF(CBL, 0) + 20) /* 0xC8 */ 307 #define ICH6_HDA_REG_SD3CBL (HDA_STREAM_REG_DEF(CBL, 0) + 30) /* 0xE8 */ 308 #define ICH6_HDA_REG_SD4CBL (HDA_STREAM_REG_DEF(CBL, 0) + 40) /* 0x108 */ 309 #define ICH6_HDA_REG_SD5CBL (HDA_STREAM_REG_DEF(CBL, 0) + 50) /* 0x128 */ 310 #define ICH6_HDA_REG_SD6CBL (HDA_STREAM_REG_DEF(CBL, 0) + 60) /* 0x148 */ 311 #define ICH6_HDA_REG_SD7CBL (HDA_STREAM_REG_DEF(CBL, 0) + 70) /* 0x168 */ 312 313 #define SDLCBL(pState, num) HDA_REG((pState), SD(CBL, num)) 314 315 #define ICH6_HDA_REG_SD0LVI 36 /* 0x8C */ 316 #define ICH6_HDA_REG_SD1LVI (HDA_STREAM_REG_DEF(LVI, 0) + 10) /* 0xAC */ 317 #define ICH6_HDA_REG_SD2LVI (HDA_STREAM_REG_DEF(LVI, 0) + 20) /* 0xCC */ 318 #define ICH6_HDA_REG_SD3LVI (HDA_STREAM_REG_DEF(LVI, 0) + 30) /* 0xEC */ 319 #define ICH6_HDA_REG_SD4LVI (HDA_STREAM_REG_DEF(LVI, 0) + 40) /* 0x10C */ 320 #define ICH6_HDA_REG_SD5LVI (HDA_STREAM_REG_DEF(LVI, 0) + 50) /* 0x12C */ 321 #define ICH6_HDA_REG_SD6LVI (HDA_STREAM_REG_DEF(LVI, 0) + 60) /* 0x14C */ 322 #define ICH6_HDA_REG_SD7LVI (HDA_STREAM_REG_DEF(LVI, 0) + 70) /* 0x16C */ 323 324 #define SDLVI(pState, num) HDA_REG((pState), SD(LVI, num)) 325 326 #define ICH6_HDA_REG_SD0FIFOW 37 /* 0x8E */ 327 #define ICH6_HDA_REG_SD1FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 10) /* 0xAE */ 328 #define ICH6_HDA_REG_SD2FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 20) /* 0xCE */ 329 #define ICH6_HDA_REG_SD3FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 30) /* 0xEE */ 330 #define ICH6_HDA_REG_SD4FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 40) /* 0x10E */ 331 #define ICH6_HDA_REG_SD5FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 50) /* 0x12E */ 332 #define ICH6_HDA_REG_SD6FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 60) /* 0x14E */ 333 #define ICH6_HDA_REG_SD7FIFOW (HDA_STREAM_REG_DEF(FIFOW, 0) + 70) /* 0x16E */ 333 334 334 335 /* 335 336 * ICH6 datasheet defined limits for FIFOW values (18.2.38) 336 337 */ 337 #define HDA_SDFIFOW_8B (0x2)338 #define HDA_SDFIFOW_16B (0x3)339 #define HDA_SDFIFOW_32B (0x4)340 #define SDFIFOW(pState, num) HDA_REG((pState), SD(FIFOW, num))341 342 #define ICH6_HDA_REG_SD0FIFOS 38 /* 0x90 */343 #define ICH6_HDA_REG_SD1FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 10) /* 0xB0 */344 #define ICH6_HDA_REG_SD2FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 20) /* 0xD0 */345 #define ICH6_HDA_REG_SD3FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 30) /* 0xF0 */346 #define ICH6_HDA_REG_SD4FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 40) /* 0x110 */347 #define ICH6_HDA_REG_SD5FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 50) /* 0x130 */348 #define ICH6_HDA_REG_SD6FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 60) /* 0x150 */349 #define ICH6_HDA_REG_SD7FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 70) /* 0x170 */338 #define HDA_SDFIFOW_8B (0x2) 339 #define HDA_SDFIFOW_16B (0x3) 340 #define HDA_SDFIFOW_32B (0x4) 341 #define SDFIFOW(pState, num) HDA_REG((pState), SD(FIFOW, num)) 342 343 #define ICH6_HDA_REG_SD0FIFOS 38 /* 0x90 */ 344 #define ICH6_HDA_REG_SD1FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 10) /* 0xB0 */ 345 #define ICH6_HDA_REG_SD2FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 20) /* 0xD0 */ 346 #define ICH6_HDA_REG_SD3FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 30) /* 0xF0 */ 347 #define ICH6_HDA_REG_SD4FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 40) /* 0x110 */ 348 #define ICH6_HDA_REG_SD5FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 50) /* 0x130 */ 349 #define ICH6_HDA_REG_SD6FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 60) /* 0x150 */ 350 #define ICH6_HDA_REG_SD7FIFOS (HDA_STREAM_REG_DEF(FIFOS, 0) + 70) /* 0x170 */ 350 351 351 352 /* … … 354 355 * Other values not listed are not supported. 355 356 */ 356 #define HDA_SDONFIFO_16B (0x0F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */357 #define HDA_SDONFIFO_32B (0x1F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */358 #define HDA_SDONFIFO_64B (0x3F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */359 #define HDA_SDONFIFO_128B (0x7F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */360 #define HDA_SDONFIFO_192B (0xBF) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */361 #define HDA_SDONFIFO_256B (0xFF) /* 20-, 24-bit Output Streams */362 #define HDA_SDINFIFO_120B (0x77) /* 8-, 16-, 20-, 24-, 32-bit Input Streams */363 #define HDA_SDINFIFO_160B (0x9F) /* 20-, 24-bit Input Streams Streams */364 #define SDFIFOS(pState, num) HDA_REG((pState), SD(FIFOS, num))365 366 #define ICH6_HDA_REG_SD0FMT 39 /* 0x92 */367 #define ICH6_HDA_REG_SD1FMT (HDA_STREAM_REG_DEF(FMT, 0) + 10) /* 0xB2 */368 #define ICH6_HDA_REG_SD2FMT (HDA_STREAM_REG_DEF(FMT, 0) + 20) /* 0xD2 */369 #define ICH6_HDA_REG_SD3FMT (HDA_STREAM_REG_DEF(FMT, 0) + 30) /* 0xF2 */370 #define ICH6_HDA_REG_SD4FMT (HDA_STREAM_REG_DEF(FMT, 0) + 40) /* 0x112 */371 #define ICH6_HDA_REG_SD5FMT (HDA_STREAM_REG_DEF(FMT, 0) + 50) /* 0x132 */372 #define ICH6_HDA_REG_SD6FMT (HDA_STREAM_REG_DEF(FMT, 0) + 60) /* 0x152 */373 #define ICH6_HDA_REG_SD7FMT (HDA_STREAM_REG_DEF(FMT, 0) + 70) /* 0x172 */374 375 #define SDFMT(pState, num) (HDA_REG((pState), SD(FMT, num)))357 #define HDA_SDONFIFO_16B (0x0F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */ 358 #define HDA_SDONFIFO_32B (0x1F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */ 359 #define HDA_SDONFIFO_64B (0x3F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */ 360 #define HDA_SDONFIFO_128B (0x7F) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */ 361 #define HDA_SDONFIFO_192B (0xBF) /* 8-, 16-, 20-, 24-, 32-bit Output Streams */ 362 #define HDA_SDONFIFO_256B (0xFF) /* 20-, 24-bit Output Streams */ 363 #define HDA_SDINFIFO_120B (0x77) /* 8-, 16-, 20-, 24-, 32-bit Input Streams */ 364 #define HDA_SDINFIFO_160B (0x9F) /* 20-, 24-bit Input Streams Streams */ 365 #define SDFIFOS(pState, num) HDA_REG((pState), SD(FIFOS, num)) 366 367 #define ICH6_HDA_REG_SD0FMT 39 /* 0x92 */ 368 #define ICH6_HDA_REG_SD1FMT (HDA_STREAM_REG_DEF(FMT, 0) + 10) /* 0xB2 */ 369 #define ICH6_HDA_REG_SD2FMT (HDA_STREAM_REG_DEF(FMT, 0) + 20) /* 0xD2 */ 370 #define ICH6_HDA_REG_SD3FMT (HDA_STREAM_REG_DEF(FMT, 0) + 30) /* 0xF2 */ 371 #define ICH6_HDA_REG_SD4FMT (HDA_STREAM_REG_DEF(FMT, 0) + 40) /* 0x112 */ 372 #define ICH6_HDA_REG_SD5FMT (HDA_STREAM_REG_DEF(FMT, 0) + 50) /* 0x132 */ 373 #define ICH6_HDA_REG_SD6FMT (HDA_STREAM_REG_DEF(FMT, 0) + 60) /* 0x152 */ 374 #define ICH6_HDA_REG_SD7FMT (HDA_STREAM_REG_DEF(FMT, 0) + 70) /* 0x172 */ 375 376 #define SDFMT(pState, num) (HDA_REG((pState), SD(FMT, num))) 376 377 #define ICH6_HDA_SDFMT_BASE_RATE_SHIFT (14) 377 #define ICH6_HDA_SDFMT_MULT_SHIFT (11)378 #define ICH6_HDA_SDFMT_MULT_MASK (0x7)379 #define ICH6_HDA_SDFMT_DIV_SHIFT (8)380 #define ICH6_HDA_SDFMT_DIV_MASK (0x7)381 #define ICH6_HDA_SDFMT_BITS_SHIFT (4)382 #define ICH6_HDA_SDFMT_BITS_MASK (0x7)378 #define ICH6_HDA_SDFMT_MULT_SHIFT (11) 379 #define ICH6_HDA_SDFMT_MULT_MASK (0x7) 380 #define ICH6_HDA_SDFMT_DIV_SHIFT (8) 381 #define ICH6_HDA_SDFMT_DIV_MASK (0x7) 382 #define ICH6_HDA_SDFMT_BITS_SHIFT (4) 383 #define ICH6_HDA_SDFMT_BITS_MASK (0x7) 383 384 #define SDFMT_BASE_RATE(pState, num) ((SDFMT(pState, num) & HDA_REG_FIELD_FLAG_MASK(SDFMT, BASE_RATE)) >> HDA_REG_FIELD_SHIFT(SDFMT, BASE_RATE)) 384 #define SDFMT_MULT(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT)) 385 #define SDFMT_DIV(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,DIV)) >> HDA_REG_FIELD_SHIFT(SDFMT, DIV)) 386 387 #define ICH6_HDA_REG_SD0BDPL 40 /* 0x98 */ 388 #define ICH6_HDA_REG_SD1BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 10) /* 0xB8 */ 389 #define ICH6_HDA_REG_SD2BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 20) /* 0xD8 */ 390 #define ICH6_HDA_REG_SD3BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 30) /* 0xF8 */ 391 #define ICH6_HDA_REG_SD4BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 40) /* 0x118 */ 392 #define ICH6_HDA_REG_SD5BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 50) /* 0x138 */ 393 #define ICH6_HDA_REG_SD6BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 60) /* 0x158 */ 394 #define ICH6_HDA_REG_SD7BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 70) /* 0x178 */ 395 396 #define SDBDPL(pState, num) HDA_REG((pState), SD(BDPL, num)) 397 398 #define ICH6_HDA_REG_SD0BDPU 41 /* 0x9C */ 399 #define ICH6_HDA_REG_SD1BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 10) /* 0xBC */ 400 #define ICH6_HDA_REG_SD2BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 20) /* 0xDC */ 401 #define ICH6_HDA_REG_SD3BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 30) /* 0xFC */ 402 #define ICH6_HDA_REG_SD4BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 40) /* 0x11C */ 403 #define ICH6_HDA_REG_SD5BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 50) /* 0x13C */ 404 #define ICH6_HDA_REG_SD6BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 60) /* 0x15C */ 405 #define ICH6_HDA_REG_SD7BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 70) /* 0x17C */ 406 407 #define SDBDPU(pState, num) HDA_REG((pState), SD(BDPU, num)) 408 409 385 #define SDFMT_MULT(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,MULT)) >> HDA_REG_FIELD_SHIFT(SDFMT, MULT)) 386 #define SDFMT_DIV(pState, num) ((SDFMT((pState), num) & HDA_REG_FIELD_MASK(SDFMT,DIV)) >> HDA_REG_FIELD_SHIFT(SDFMT, DIV)) 387 388 #define ICH6_HDA_REG_SD0BDPL 40 /* 0x98 */ 389 #define ICH6_HDA_REG_SD1BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 10) /* 0xB8 */ 390 #define ICH6_HDA_REG_SD2BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 20) /* 0xD8 */ 391 #define ICH6_HDA_REG_SD3BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 30) /* 0xF8 */ 392 #define ICH6_HDA_REG_SD4BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 40) /* 0x118 */ 393 #define ICH6_HDA_REG_SD5BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 50) /* 0x138 */ 394 #define ICH6_HDA_REG_SD6BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 60) /* 0x158 */ 395 #define ICH6_HDA_REG_SD7BDPL (HDA_STREAM_REG_DEF(BDPL, 0) + 70) /* 0x178 */ 396 397 #define SDBDPL(pState, num) HDA_REG((pState), SD(BDPL, num)) 398 399 #define ICH6_HDA_REG_SD0BDPU 41 /* 0x9C */ 400 #define ICH6_HDA_REG_SD1BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 10) /* 0xBC */ 401 #define ICH6_HDA_REG_SD2BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 20) /* 0xDC */ 402 #define ICH6_HDA_REG_SD3BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 30) /* 0xFC */ 403 #define ICH6_HDA_REG_SD4BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 40) /* 0x11C */ 404 #define ICH6_HDA_REG_SD5BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 50) /* 0x13C */ 405 #define ICH6_HDA_REG_SD6BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 60) /* 0x15C */ 406 #define ICH6_HDA_REG_SD7BDPU (HDA_STREAM_REG_DEF(BDPU, 0) + 70) /* 0x17C */ 407 408 #define SDBDPU(pState, num) HDA_REG((pState), SD(BDPU, num)) 409 410 411 /******************************************************************************* 412 * Structures and Typedefs * 413 *******************************************************************************/ 410 414 typedef struct HDABDLEDESC 411 415 { … … 420 424 } HDABDLEDESC, *PHDABDLEDESC; 421 425 422 423 /** HDABDLEDESC field descriptors the v3+ saved state. */424 static SSMFIELD const g_aHdaBDLEDescFields[] =425 {426 SSMFIELD_ENTRY( HDABDLEDESC, u64BdleCviAddr),427 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleMaxCvi),428 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCvi),429 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviLen),430 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos),431 SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc),432 SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW),433 SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer),434 SSMFIELD_ENTRY_TERM()435 };436 437 /** HDABDLEDESC field descriptors the v1 and v2 saved state. */438 static SSMFIELD const g_aHdaBDLEDescFieldsOld[] =439 {440 SSMFIELD_ENTRY( HDABDLEDESC, u64BdleCviAddr),441 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleMaxCvi),442 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCvi),443 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviLen),444 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos),445 SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc),446 SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3),447 SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW),448 SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer),449 SSMFIELD_ENTRY_TERM()450 };451 452 426 typedef struct HDASTREAMTRANSFERDESC 453 427 { … … 471 445 /** The base interface for LUN\#0. */ 472 446 PDMIBASE IBase; 473 RTGCPHYS addrMMReg;474 uint32_t au32Regs[HDA_NREGS];475 HDABDLEDESC stInBdle;476 HDABDLEDESC stOutBdle;477 HDABDLEDESC stMicBdle;478 /* Interrupt on completion */479 bool fCviIoc;480 uint64_t u64CORBBase;481 uint64_t u64RIRBBase;482 uint64_t u64DPBase;483 /* pointer to CORB buf */484 uint32_t *pu32CorbBuf;485 /* size in bytes of CORB buf */486 uint32_t cbCorbBuf;487 /* pointer on RIRB buf */488 uint64_t *pu64RirbBuf;489 /* size in bytes of RIRB buf */490 uint32_t cbRirbBuf;491 /* indicates if HDA in reset. */492 bool fInReset;493 CODECState Codec;494 uint8_t u8Counter;495 uint64_t u64BaseTS;447 RTGCPHYS addrMMReg; 448 uint32_t au32Regs[HDA_NREGS]; 449 HDABDLEDESC stInBdle; 450 HDABDLEDESC stOutBdle; 451 HDABDLEDESC stMicBdle; 452 /** Interrupt on completion */ 453 bool fCviIoc; 454 uint64_t u64CORBBase; 455 uint64_t u64RIRBBase; 456 uint64_t u64DPBase; 457 /** pointer to CORB buf */ 458 uint32_t *pu32CorbBuf; 459 /** size in bytes of CORB buf */ 460 uint32_t cbCorbBuf; 461 /** pointer on RIRB buf */ 462 uint64_t *pu64RirbBuf; 463 /** size in bytes of RIRB buf */ 464 uint32_t cbRirbBuf; 465 /** indicates if HDA in reset. */ 466 bool fInReset; 467 CODECState Codec; 468 uint8_t u8Counter; 469 uint64_t u64BaseTS; 496 470 } INTELHDLinkState, *PINTELHDLinkState; 497 471 … … 505 479 506 480 507 508 509 481 typedef struct PCIINTELHDLinkState 510 482 { … … 513 485 } PCIINTELHDLinkState; 514 486 487 488 /******************************************************************************* 489 * Internal Functions * 490 *******************************************************************************/ 491 static FNPDMDEVRESET hdaReset; 515 492 516 493 /** @todo r=bird: Why aren't these static? And why use DECLCALLBACK for … … 554 531 DECLCALLBACK(int) hdaRegWriteU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t pu32Value); 555 532 556 DECLINLINE(void) hdaInitTransferDescriptor(PINTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm, PHDASTREAMTRANSFERDESC pStreamDesc); 557 static int hdaMMIORegLookup(INTELHDLinkState* pState, uint32_t u32Offset); 533 DECLINLINE(void) hdaInitTransferDescriptor(PINTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm, 534 PHDASTREAMTRANSFERDESC pStreamDesc); 535 static int hdaMMIORegLookup(INTELHDLinkState* pState, uint32_t offReg); 558 536 static void hdaFetchBdle(INTELHDLinkState *pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc); 559 537 #ifdef LOG_ENABLED … … 562 540 563 541 542 /******************************************************************************* 543 * Global Variables * 544 *******************************************************************************/ 564 545 /* see 302349 p 6.2*/ 565 const static struct stIchIntelHDRegMap 546 static const struct 566 547 { 567 548 /** Register offset in the register space. */ 568 uint32_t offset;549 uint32_t offset; 569 550 /** Size in bytes. Registers of size > 4 are in fact tables. */ 570 uint32_t size;551 uint32_t size; 571 552 /** Readable bits. */ 572 uint32_t readable;553 uint32_t readable; 573 554 /** Writable bits. */ 574 uint32_t writable;555 uint32_t writable; 575 556 /** Read callback. */ 576 int (*pfnRead)(INTELHDLinkState *pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);557 int (*pfnRead)(INTELHDLinkState *pState, uint32_t offset, uint32_t index, uint32_t *pu32Value); 577 558 /** Write callback. */ 578 int (*pfnWrite)(INTELHDLinkState *pState, uint32_t offset, uint32_t index, uint32_t u32Value);559 int (*pfnWrite)(INTELHDLinkState *pState, uint32_t offset, uint32_t index, uint32_t u32Value); 579 560 /** Abbreviated name. */ 580 561 const char *abbrev; 581 562 /** Full name. */ 582 563 const char *name; 583 } s_ichIntelHDRegMap[HDA_NREGS] =564 } g_aIchIntelHDRegMap[HDA_NREGS] = 584 565 { 585 566 /* offset size read mask write mask read callback write callback abbrev full name */ … … 708 689 }; 709 690 710 static void inline hdaUpdatePosBuf(INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc) 691 /** HDABDLEDESC field descriptors the v3+ saved state. */ 692 static SSMFIELD const g_aHdaBDLEDescFields[] = 693 { 694 SSMFIELD_ENTRY( HDABDLEDESC, u64BdleCviAddr), 695 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleMaxCvi), 696 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCvi), 697 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviLen), 698 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos), 699 SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc), 700 SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW), 701 SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer), 702 SSMFIELD_ENTRY_TERM() 703 }; 704 705 /** HDABDLEDESC field descriptors the v1 and v2 saved state. */ 706 static SSMFIELD const g_aHdaBDLEDescFieldsOld[] = 707 { 708 SSMFIELD_ENTRY( HDABDLEDESC, u64BdleCviAddr), 709 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleMaxCvi), 710 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCvi), 711 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviLen), 712 SSMFIELD_ENTRY( HDABDLEDESC, u32BdleCviPos), 713 SSMFIELD_ENTRY( HDABDLEDESC, fBdleCviIoc), 714 SSMFIELD_ENTRY_PAD_HC_AUTO(3, 3), 715 SSMFIELD_ENTRY( HDABDLEDESC, cbUnderFifoW), 716 SSMFIELD_ENTRY( HDABDLEDESC, au8HdaBuffer), 717 SSMFIELD_ENTRY_TERM() 718 }; 719 720 721 DECLINLINE(void) hdaUpdatePosBuf(INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc) 711 722 { 712 723 if (pState->u64DPBase & DPBASE_ENABLED) … … 714 725 (pState->u64DPBase & DPBASE_ADDR_MASK) + pStreamDesc->u8Strm*8, pStreamDesc->pu32Lpib, sizeof(uint32_t)); 715 726 } 716 static uint32_t inlinehdaFifoWToSz(INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc)727 DECLINLINE(uint32_t) hdaFifoWToSz(INTELHDLinkState *pState, PHDASTREAMTRANSFERDESC pStreamDesc) 717 728 { 718 729 #if 0 … … 753 764 } 754 765 755 static int hdaMMIORegLookup(INTELHDLinkState* pState, uint32_t u32Offset) 756 { 757 int idxMiddle; 758 int idxHigh = RT_ELEMENTS(s_ichIntelHDRegMap); 759 int idxLow = 0; 760 /* Aliases HDA spec 3.3.45 */ 761 switch(u32Offset) 766 static int hdaMMIORegLookup(INTELHDLinkState* pState, uint32_t offReg) 767 { 768 /* 769 * Aliases HDA spec 3.3.45 770 */ 771 switch (offReg) 762 772 { 763 773 case 0x2084: … … 778 788 return HDA_REG_IND_NAME(SD7LPIB); 779 789 } 780 while (1) 790 791 /* 792 * Binary search the 793 */ 794 int idxHigh = RT_ELEMENTS(g_aIchIntelHDRegMap); 795 int idxLow = 0; 796 for (;;) 781 797 { 782 798 #ifdef DEBUG_vvl 783 Assert( (idxHigh >= 0784 && idxLow >= 0));799 Assert( idxHigh >= 0 800 && idxLow >= 0); 785 801 #endif 786 802 if ( idxHigh < idxLow 787 803 || idxHigh < 0) 788 804 break; 789 idxMiddle = idxLow + (idxHigh - idxLow)/2; 790 if (u32Offset < s_ichIntelHDRegMap[idxMiddle].offset) 791 { 805 int idxMiddle = idxLow + (idxHigh - idxLow) / 2; 806 if (offReg < g_aIchIntelHDRegMap[idxMiddle].offset) 792 807 idxHigh = idxMiddle - 1; 793 continue; 794 } 795 if (u32Offset >= s_ichIntelHDRegMap[idxMiddle].offset + s_ichIntelHDRegMap[idxMiddle].size) 796 { 797 idxLow = idxMiddle + 1; 798 continue; 799 } 800 if ( u32Offset >= s_ichIntelHDRegMap[idxMiddle].offset 801 && u32Offset < s_ichIntelHDRegMap[idxMiddle].offset + s_ichIntelHDRegMap[idxMiddle].size) 808 else if (offReg >= g_aIchIntelHDRegMap[idxMiddle].offset + g_aIchIntelHDRegMap[idxMiddle].size) 809 idxLow = idxMiddle + 1; 810 else if ( offReg >= g_aIchIntelHDRegMap[idxMiddle].offset 811 && offReg < g_aIchIntelHDRegMap[idxMiddle].offset + g_aIchIntelHDRegMap[idxMiddle].size) 802 812 return idxMiddle; 803 813 } … … 967 977 DECLCALLBACK(int) hdaRegReadU8(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value) 968 978 { 969 Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xffffff00) == 0);979 Assert(((pState->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xffffff00) == 0); 970 980 return hdaRegReadU32(pState, offset, index, pu32Value); 971 981 } … … 979 989 DECLCALLBACK(int) hdaRegReadU16(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value) 980 990 { 981 Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xffff0000) == 0);991 Assert(((pState->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xffff0000) == 0); 982 992 return hdaRegReadU32(pState, offset, index, pu32Value); 983 993 } … … 992 1002 DECLCALLBACK(int) hdaRegReadU24(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value) 993 1003 { 994 Assert(((pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable) & 0xff000000) == 0);1004 Assert(((pState->au32Regs[index] & g_aIchIntelHDRegMap[index].readable) & 0xff000000) == 0); 995 1005 return hdaRegReadU32(pState, offset, index, pu32Value); 996 1006 } … … 1004 1014 DECLCALLBACK(int) hdaRegReadU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value) 1005 1015 { 1006 *pu32Value = pState->au32Regs[index] & s_ichIntelHDRegMap[index].readable;1016 *pu32Value = pState->au32Regs[index] & g_aIchIntelHDRegMap[index].readable; 1007 1017 return VINF_SUCCESS; 1008 1018 } … … 1010 1020 DECLCALLBACK(int) hdaRegWriteU32(INTELHDLinkState* pState, uint32_t offset, uint32_t index, uint32_t u32Value) 1011 1021 { 1012 pState->au32Regs[index] = (u32Value & s_ichIntelHDRegMap[index].writable)1013 | (pState->au32Regs[index] & ~ s_ichIntelHDRegMap[index].writable);1022 pState->au32Regs[index] = (u32Value & g_aIchIntelHDRegMap[index].writable) 1023 | (pState->au32Regs[index] & ~g_aIchIntelHDRegMap[index].writable); 1014 1024 return VINF_SUCCESS; 1015 1025 } … … 1088 1098 { 1089 1099 /* HDA spec (1a): 3.3.16 WALCLK counter ticks with 24Mhz bitclock rate. */ 1090 *pu32Value = (uint32_t)ASMMultU64ByU32DivByU32(PDMDevHlpTMTimeVirtGetNano(ICH6_HDASTATE_2_DEVINS(pState)) - pState->u64BaseTS, 24, 1000); 1100 *pu32Value = (uint32_t)ASMMultU64ByU32DivByU32(PDMDevHlpTMTimeVirtGetNano(ICH6_HDASTATE_2_DEVINS(pState)) 1101 - pState->u64BaseTS, 24, 1000); 1091 1102 return VINF_SUCCESS; 1092 1103 } … … 1156 1167 Assert((!fReset)); 1157 1168 Log(("hda: guest initiated exit of stream reset.\n")); 1158 goto done;1169 goto l_done; 1159 1170 } 1160 1171 else if (fReset) … … 1165 1176 uint8_t u8Strm = 0; 1166 1177 PHDABDLEDESC pBdle = NULL; 1167 HDASTREAMTRANSFERDESC stStreamDesc;1178 HDASTREAMTRANSFERDESC StreamDesc; 1168 1179 Assert((!fInRun && !fRun)); 1169 1180 switch (index) … … 1172 1183 u8Strm = 0; 1173 1184 pBdle = &pState->stInBdle; 1174 break;1185 break; 1175 1186 case ICH6_HDA_REG_SD4CTL: 1176 1187 u8Strm = 4; 1177 1188 pBdle = &pState->stOutBdle; 1178 break;1189 break; 1179 1190 default: 1180 1191 Log(("hda: changing SRST bit on non-attached stream\n")); 1181 goto done;1192 goto l_done; 1182 1193 } 1183 1194 Log(("hda: guest initiated enter to stream reset.\n")); 1184 hdaInitTransferDescriptor(pState, pBdle, u8Strm, & stStreamDesc);1185 hdaStreamReset(pState, pBdle, & stStreamDesc, u8Strm);1186 goto done;1195 hdaInitTransferDescriptor(pState, pBdle, u8Strm, &StreamDesc); 1196 hdaStreamReset(pState, pBdle, &StreamDesc, u8Strm); 1197 goto l_done; 1187 1198 } 1188 1199 … … 1202 1213 default: 1203 1214 Log(("hda: changing RUN bit on non-attached stream\n")); 1204 goto done;1215 goto l_done; 1205 1216 } 1206 1217 } 1207 1218 1208 1219 l_done: 1209 1220 rc = hdaRegWriteU24(pState, offset, index, u32Value); 1210 1221 if (RT_FAILURE(rc)) … … 1284 1295 } 1285 1296 1286 static void inlinehdaSdFmtToAudSettings(uint32_t u32SdFmt, audsettings_t *pAudSetting)1297 static void hdaSdFmtToAudSettings(uint32_t u32SdFmt, audsettings_t *pAudSetting) 1287 1298 { 1288 1299 Assert((pAudSetting)); … … 1546 1557 } 1547 1558 1548 static inline uint32_t hdaCalculateTransferBufferLength(PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t u32SoundBackendBufferBytesAvail, uint32_t u32CblLimit) 1559 DECLINLINE(uint32_t) hdaCalculateTransferBufferLength(PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, 1560 uint32_t u32SoundBackendBufferBytesAvail, uint32_t u32CblLimit) 1549 1561 { 1550 1562 uint32_t cb2Copy; … … 1570 1582 } 1571 1583 1572 DECLINLINE(void) hdaBackendWriteTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied, uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity) 1584 DECLINLINE(void) hdaBackendWriteTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied, 1585 uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity) 1573 1586 { 1574 1587 Log(("hda:hdaBackendWriteTransferReported: cbArranged2Copy: %d, cbCopied: %d, pu32DMACursor: %d, pu32BackendBufferCapacity:%d\n", … … 1600 1613 } 1601 1614 1602 DECLINLINE(void) hdaBackendReadTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied, uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity) 1615 DECLINLINE(void) hdaBackendReadTransferReported(PHDABDLEDESC pBdle, uint32_t cbArranged2Copy, uint32_t cbCopied, 1616 uint32_t *pu32DMACursor, uint32_t *pu32BackendBufferCapacity) 1603 1617 { 1604 1618 Assert((cbCopied, cbArranged2Copy)); … … 1612 1626 } 1613 1627 1614 DECLINLINE(void) hdaBackendTransferUnreported(INTELHDLinkState *pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t cbCopied, uint32_t *pu32BackendBufferCapacity) 1628 DECLINLINE(void) hdaBackendTransferUnreported(INTELHDLinkState *pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, 1629 uint32_t cbCopied, uint32_t *pu32BackendBufferCapacity) 1615 1630 { 1616 1631 Log(("hda:hdaBackendTransferUnreported: CVI (cbUnderFifoW:%d, pos:%d, len:%d)\n", pBdle->cbUnderFifoW, pBdle->u32BdleCviPos, pBdle->u32BdleCviLen)); … … 1623 1638 Assert((pBdle->cbUnderFifoW <= hdaFifoWToSz(pState, pStreamDesc))); 1624 1639 } 1625 static inline bool hdaIsTransferCountersOverlapped(PINTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc) 1640 1641 DECLINLINE(bool) hdaIsTransferCountersOverlapped(PINTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc) 1626 1642 { 1627 1643 bool fOnBufferEdge = ( *pStreamDesc->pu32Lpib == pStreamDesc->u32Cbl … … 1646 1662 } 1647 1663 1648 DECLINLINE(void) hdaStreamCounterUpdate(PINTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t cbInc) 1664 DECLINLINE(void) hdaStreamCounterUpdate(PINTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc, 1665 uint32_t cbInc) 1649 1666 { 1650 1667 /* … … 1666 1683 } 1667 1684 1668 static inlinebool hdaDoNextTransferCycle(PINTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc)1685 static bool hdaDoNextTransferCycle(PINTELHDLinkState pState, PHDABDLEDESC pBdle, PHDASTREAMTRANSFERDESC pStreamDesc) 1669 1686 { 1670 1687 bool fDoNextTransferLoop = true; … … 1711 1728 /* if we enter here we can't report "unreported bits" */ 1712 1729 *fStop = true; 1713 goto done;1730 goto l_done; 1714 1731 } 1715 1732 … … 1734 1751 *fStop = true; 1735 1752 } 1736 1753 l_done: 1737 1754 Assert((cbTransferred <= (SDFIFOS(pState, 0) + 1))); 1738 1755 Log(("hda:ra: CVI(pos:%d, len:%d) cbTransferred: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred)); … … 1757 1774 { 1758 1775 *fStop = true; 1759 goto done;1776 goto l_done; 1760 1777 } 1761 1778 … … 1779 1796 } 1780 1797 1781 1798 l_done: 1782 1799 Assert((cbTransferred <= (SDFIFOS(pState, 4) + 1))); 1783 1800 Log(("hda:wa: CVI(pos:%d, len:%d, cbTransferred:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred)); … … 1785 1802 } 1786 1803 1804 /** 1805 * @interface_method_impl{HDACODEC,pfnReset} 1806 */ 1787 1807 DECLCALLBACK(int) hdaCodecReset(CODECState *pCodecState) 1788 1808 { 1789 INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->p HDAState;1809 INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->pvHDAState; 1790 1810 return VINF_SUCCESS; 1791 1811 } 1792 1812 1793 DECLINLINE(void) hdaInitTransferDescriptor(PINTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm, PHDASTREAMTRANSFERDESC pStreamDesc) 1794 { 1795 Assert(( pState 1796 && pBdle 1797 && pStreamDesc 1798 && u8Strm <= 7)); 1813 DECLINLINE(void) hdaInitTransferDescriptor(PINTELHDLinkState pState, PHDABDLEDESC pBdle, uint8_t u8Strm, 1814 PHDASTREAMTRANSFERDESC pStreamDesc) 1815 { 1816 Assert(pState); Assert(pBdle); Assert(pStreamDesc); Assert(u8Strm <= 7); 1817 1799 1818 memset(pStreamDesc, 0, sizeof(HDASTREAMTRANSFERDESC)); 1800 pStreamDesc->u8Strm = u8Strm;1801 pStreamDesc->u32Ctl = HDA_STREAM_REG2(pState, CTL, u8Strm);1819 pStreamDesc->u8Strm = u8Strm; 1820 pStreamDesc->u32Ctl = HDA_STREAM_REG2(pState, CTL, u8Strm); 1802 1821 pStreamDesc->u64BaseDMA = RT_MAKE_U64(HDA_STREAM_REG2(pState, BDPL, u8Strm), 1803 1822 HDA_STREAM_REG2(pState, BDPU, u8Strm)); 1804 pStreamDesc->pu32Lpib = &HDA_STREAM_REG2(pState, LPIB, u8Strm); 1805 pStreamDesc->pu32Sts = &HDA_STREAM_REG2(pState, STS, u8Strm); 1806 pStreamDesc->u32Cbl = HDA_STREAM_REG2(pState, CBL, u8Strm); 1807 pStreamDesc->u32Fifos = HDA_STREAM_REG2(pState, FIFOS, u8Strm); 1808 1809 pBdle->u32BdleMaxCvi = HDA_STREAM_REG2(pState, LVI, u8Strm); 1823 pStreamDesc->pu32Lpib = &HDA_STREAM_REG2(pState, LPIB, u8Strm); 1824 pStreamDesc->pu32Sts = &HDA_STREAM_REG2(pState, STS, u8Strm); 1825 pStreamDesc->u32Cbl = HDA_STREAM_REG2(pState, CBL, u8Strm); 1826 pStreamDesc->u32Fifos = HDA_STREAM_REG2(pState, FIFOS, u8Strm); 1827 1828 pBdle->u32BdleMaxCvi = HDA_STREAM_REG2(pState, LVI, u8Strm); 1829 1810 1830 #ifdef LOG_ENABLED 1811 1831 if ( pBdle … … 1818 1838 } 1819 1839 1820 DECLCALLBACK(void) hdaTransfer(CODECState *pCodecState, ENMSOUNDSOURCE src, int avail) 1821 { 1822 bool fStop = false; 1823 uint8_t u8Strm = 0; 1824 PHDABDLEDESC pBdle = NULL; 1825 INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->pHDAState; 1826 HDASTREAMTRANSFERDESC stStreamDesc; 1827 uint32_t nBytes; 1840 1841 /** 1842 * @interface_method_impl{HDACODEC,pfnTransfer} 1843 */ 1844 static DECLCALLBACK(void) hdaTransfer(CODECState *pCodecState, ENMSOUNDSOURCE src, int avail) 1845 { 1846 INTELHDLinkState *pState = (INTELHDLinkState *)pCodecState->pvHDAState; 1847 uint8_t u8Strm = 0; 1848 PHDABDLEDESC pBdle = NULL; 1849 1828 1850 switch (src) 1829 1851 { … … 1843 1865 return; 1844 1866 } 1845 hdaInitTransferDescriptor(pState, pBdle, u8Strm, &stStreamDesc); 1846 while( avail && !fStop) 1847 { 1848 Assert ( (stStreamDesc.u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)) 1849 && avail 1850 && stStreamDesc.u64BaseDMA); 1867 1868 HDASTREAMTRANSFERDESC StreamDesc; 1869 hdaInitTransferDescriptor(pState, pBdle, u8Strm, &StreamDesc); 1870 1871 bool fStop = false; 1872 while (avail && !fStop) 1873 { 1874 Assert( (StreamDesc.u32Ctl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)) 1875 && avail 1876 && StreamDesc.u64BaseDMA); 1851 1877 1852 1878 /* Fetch the Buffer Descriptor Entry (BDE). */ 1853 1879 1854 if (hdaIsTransferCountersOverlapped(pState, pBdle, &stStreamDesc)) 1855 hdaFetchBdle(pState, pBdle, &stStreamDesc); 1856 *stStreamDesc.pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY); 1857 Assert((avail >= 0 && (stStreamDesc.u32Cbl >= (*stStreamDesc.pu32Lpib)))); /* sanity */ 1858 uint32_t u32CblLimit = stStreamDesc.u32Cbl - (*stStreamDesc.pu32Lpib); 1859 Assert((u32CblLimit > hdaFifoWToSz(pState, &stStreamDesc))); 1860 Log(("hda: CBL=%d, LPIB=%d\n", stStreamDesc.u32Cbl, *stStreamDesc.pu32Lpib)); 1880 if (hdaIsTransferCountersOverlapped(pState, pBdle, &StreamDesc)) 1881 hdaFetchBdle(pState, pBdle, &StreamDesc); 1882 *StreamDesc.pu32Sts |= HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY); 1883 Assert((avail >= 0 && (StreamDesc.u32Cbl >= (*StreamDesc.pu32Lpib)))); /* sanity */ 1884 uint32_t u32CblLimit = StreamDesc.u32Cbl - (*StreamDesc.pu32Lpib); 1885 Assert((u32CblLimit > hdaFifoWToSz(pState, &StreamDesc))); 1886 Log(("hda: CBL=%d, LPIB=%d\n", StreamDesc.u32Cbl, *StreamDesc.pu32Lpib)); 1887 uint32_t cb; 1861 1888 switch (src) 1862 1889 { 1863 1890 case PO_INDEX: 1864 nBytes = hdaWriteAudio(pState, &stStreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit);1891 cb = hdaWriteAudio(pState, &StreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit); 1865 1892 break; 1866 1893 case PI_INDEX: 1867 nBytes = hdaReadAudio(pState, &stStreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit);1894 cb = hdaReadAudio(pState, &StreamDesc, (uint32_t *)&avail, &fStop, u32CblLimit); 1868 1895 break; 1869 1896 default: 1870 nBytes= 0;1871 fStop 1897 cb = 0; 1898 fStop = true; 1872 1899 AssertMsgFailed(("Unsupported")); 1873 1900 } 1874 Assert( nBytes <= (stStreamDesc.u32Fifos + 1));1875 * stStreamDesc.pu32Sts &= ~HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY);1901 Assert(cb <= StreamDesc.u32Fifos + 1); 1902 *StreamDesc.pu32Sts &= ~HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY); 1876 1903 1877 1904 /* Process end of buffer condition. */ 1878 hdaStreamCounterUpdate(pState, pBdle, &stStreamDesc, nBytes); 1879 fStop = !fStop ? !hdaDoNextTransferCycle(pState, pBdle, &stStreamDesc) : fStop; 1880 } 1881 } 1905 hdaStreamCounterUpdate(pState, pBdle, &StreamDesc, cb); 1906 fStop = !fStop ? !hdaDoNextTransferCycle(pState, pBdle, &StreamDesc) : fStop; 1907 } 1908 } 1909 1910 1911 /* MMIO callbacks */ 1882 1912 1883 1913 /** 1884 * Handle register read operation.1914 * @callback_method_impl{FNIOMMMIOREAD, Looks up and calls the appropriate handler.} 1885 1915 * 1886 * Looks up and calls the appropriate handler. 1887 * 1888 * @note: During implementation, we discovered so-called "forgotten" or "hole" registers 1889 * whose description is not listed in the RPM, datasheet, or spec. 1890 * 1891 * @returns VBox status code. 1892 * 1893 * @param pState The device state structure. 1894 * @param uOffset Register offset in memory-mapped area. 1895 * @param pv Where to place the value. 1896 * @param cb Number of bytes to write. 1897 * @thread EMT 1916 * @note During implementation, we discovered so-called "forgotten" or "hole" 1917 * registers whose description is not listed in the RPM, datasheet, or 1918 * spec. 1898 1919 */ 1899 1920 PDMBOTHCBDECL(int) hdaMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb) … … 1915 1936 * what the rules are. */ 1916 1937 uint32_t mask = 0; 1917 uint32_t shift = ( s_ichIntelHDRegMap[idxReg].offset - offReg) % sizeof(uint32_t) * 8;1938 uint32_t shift = (g_aIchIntelHDRegMap[idxReg].offset - offReg) % sizeof(uint32_t) * 8; 1918 1939 uint32_t u32Value = 0; 1919 1940 switch(cb) … … 1931 1952 /* Cross-register access. Mac guest hits this assert doing assumption 4 byte access to 3 byte registers e.g. {I,O}SDnCTL 1932 1953 */ 1933 //Assert((cb <= s_ichIntelHDRegMap[idxReg].size - (offReg - s_ichIntelHDRegMap[idxReg].offset)));1934 if (cb > s_ichIntelHDRegMap[idxReg].size - (offReg - s_ichIntelHDRegMap[idxReg].offset))1954 //Assert((cb <= g_aIchIntelHDRegMap[idxReg].size - (offReg - g_aIchIntelHDRegMap[idxReg].offset))); 1955 if (cb > g_aIchIntelHDRegMap[idxReg].size - (offReg - g_aIchIntelHDRegMap[idxReg].offset)) 1935 1956 { 1936 int off = cb - ( s_ichIntelHDRegMap[idxReg].size - (offReg - s_ichIntelHDRegMap[idxReg].offset));1957 int off = cb - (g_aIchIntelHDRegMap[idxReg].size - (offReg - g_aIchIntelHDRegMap[idxReg].offset)); 1937 1958 rc = hdaMMIORead(pDevIns, pvUser, GCPhysAddr + cb - off, (char *)pv + cb - off, off); 1938 1959 if (RT_FAILURE(rc)) 1939 1960 AssertRCReturn (rc, rc); 1940 1961 } 1941 //Assert(((offReg - s_ichIntelHDRegMap[idxReg].offset) == 0));1962 //Assert(((offReg - g_aIchIntelHDRegMap[idxReg].offset) == 0)); 1942 1963 #endif 1943 1964 mask <<= shift; 1944 rc = s_ichIntelHDRegMap[idxReg].pfnRead(&pThis->hda, offReg, idxReg, &u32Value);1965 rc = g_aIchIntelHDRegMap[idxReg].pfnRead(&pThis->hda, offReg, idxReg, &u32Value); 1945 1966 *(uint32_t *)pv |= (u32Value & mask); 1946 Log(("hda: read %s[%x/%x]\n", s_ichIntelHDRegMap[idxReg].abbrev, u32Value, *(uint32_t *)pv));1967 Log(("hda: read %s[%x/%x]\n", g_aIchIntelHDRegMap[idxReg].abbrev, u32Value, *(uint32_t *)pv)); 1947 1968 return rc; 1948 1969 } … … 1952 1973 } 1953 1974 1975 1954 1976 /** 1955 * Handle register write operation. 1956 * 1957 * Looks up and calls the appropriate handler. 1958 * 1959 * @returns VBox status code. 1960 * 1961 * @param pState The device state structure. 1962 * @param uOffset Register offset in memory-mapped area. 1963 * @param pv Where to fetch the value. 1964 * @param cb Number of bytes to write. 1965 * @thread EMT 1977 * @callback_method_impl{FNIOMMMIOWRITE, Looks up and calls the appropriate handler.} 1966 1978 */ 1967 1979 PDMBOTHCBDECL(int) hdaMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb) … … 2019 2031 /* cross-register access, see corresponding comment in hdaMMIORead */ 2020 2032 #if 0 2021 if (cb > s_ichIntelHDRegMap[idxReg].size - (offReg - s_ichIntelHDRegMap[idxReg].offset))2033 if (cb > g_aIchIntelHDRegMap[idxReg].size - (offReg - g_aIchIntelHDRegMap[idxReg].offset)) 2022 2034 { 2023 int off = cb - ( s_ichIntelHDRegMap[idxReg].size - (offReg - s_ichIntelHDRegMap[idxReg].offset));2035 int off = cb - (g_aIchIntelHDRegMap[idxReg].size - (offReg - g_aIchIntelHDRegMap[idxReg].offset)); 2024 2036 rc = hdaMMIOWrite(pDevIns, pvUser, GCPhysAddr + cb - off, (char *)pv + cb - off, off); 2025 2037 if (RT_FAILURE(rc)) … … 2027 2039 } 2028 2040 #endif 2029 uint32_t shift = ( s_ichIntelHDRegMap[idxReg].offset - offReg) % sizeof(uint32_t) * 8;2041 uint32_t shift = (g_aIchIntelHDRegMap[idxReg].offset - offReg) % sizeof(uint32_t) * 8; 2030 2042 mask <<= shift; 2031 2043 u32NewValue <<= shift; … … 2033 2045 u32NewValue |= (u32CurValue & ~mask); 2034 2046 2035 rc = s_ichIntelHDRegMap[idxReg].pfnWrite(&pThis->hda, offReg, idxReg, u32NewValue);2036 Log(("hda: write %s:(%x) %x => %x\n", s_ichIntelHDRegMap[idxReg].abbrev, u32NewValue,2047 rc = g_aIchIntelHDRegMap[idxReg].pfnWrite(&pThis->hda, offReg, idxReg, u32NewValue); 2048 Log(("hda: write %s:(%x) %x => %x\n", g_aIchIntelHDRegMap[idxReg].abbrev, u32NewValue, 2037 2049 u32CurValue, pThis->hda.au32Regs[idxReg])); 2038 2050 return rc; … … 2043 2055 } 2044 2056 2057 2058 /* PCI callback. */ 2059 2045 2060 /** 2046 * Callback function for mapping a PCI I/O region. 2047 * 2048 * @return VBox status code. 2049 * @param pPciDev Pointer to PCI device. 2050 * Use pPciDev->pDevIns to get the device instance. 2051 * @param iRegion The region number. 2052 * @param GCPhysAddress Physical address of the region. 2053 * If iType is PCI_ADDRESS_SPACE_IO, this is an 2054 * I/O port, else it's a physical address. 2055 * This address is *NOT* relative 2056 * to pci_mem_base like earlier! 2057 * @param enmType One of the PCI_ADDRESS_SPACE_* values. 2061 * @callback_method_impl{FNPCIIOREGIONMAP} 2058 2062 */ 2059 static DECLCALLBACK(int) hdaMap(PPCIDEVICE pPciDev, int iRegion, 2060 RTGCPHYS GCPhysAddress, uint32_t cb, 2061 PCIADDRESSSPACE enmType) 2063 static DECLCALLBACK(int) hdaMap(PPCIDEVICE pPciDev, int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType) 2062 2064 { 2063 2065 int rc; … … 2078 2080 } 2079 2081 2082 2083 /* Saved state callbacks. */ 2084 2080 2085 /** 2081 * Saves the state of the HDA device. 2082 * 2083 * @returns VBox status code. 2084 * @param pDevIns The device instance. 2085 * @param pSSM The handle to save the state to. 2086 * @callback_method_impl{FNSSMDEVSAVEEXEC} 2086 2087 */ 2087 2088 static DECLCALLBACK(int) hdaSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM) … … 2103 2104 } 2104 2105 2106 2105 2107 /** 2106 * Loads a saved HDA device state. 2107 * 2108 * @returns VBox status code. 2109 * @param pDevIns The device instance. 2110 * @param pSSM The handle to the saved state. 2111 * @param uVersion The data unit version number. 2112 * @param uPass The data pass. 2108 * @callback_method_impl{FNSSMDEVLOADEXEC} 2113 2109 */ 2114 2110 static DECLCALLBACK(int) hdaLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) … … 2196 2192 } 2197 2193 2194 2195 /* Debug and log type formatters. */ 2196 2197 /** 2198 * @callback_method_impl{FNRTSTRFORMATTYPE} 2199 */ 2200 static DECLCALLBACK(size_t) 2201 hdaFormatStrmCtl(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2202 const char *pszType, void const *pvValue, 2203 int cchWidth, int cchPrecision, unsigned fFlags, 2204 void *pvUser) 2205 { 2206 uint32_t sdCtl = (uint32_t)(uintptr_t)pvValue; 2207 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2208 "SDCTL(raw: %#x, strm:%#x, dir:%RTbool, tp:%RTbool strip:%x, deie:%RTbool, ioce:%RTbool, run:%RTbool, srst:%RTbool)", 2209 sdCtl, 2210 (sdCtl & HDA_REG_FIELD_MASK(SDCTL, NUM)) >> ICH6_HDA_SDCTL_NUM_SHIFT, 2211 RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DIR)), 2212 RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, TP)), 2213 (sdCtl & HDA_REG_FIELD_MASK(SDCTL, STRIPE)) >> ICH6_HDA_SDCTL_STRIPE_SHIFT, 2214 RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DEIE)), 2215 RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, ICE)), 2216 RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)), 2217 RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST))); 2218 } 2219 2220 /** 2221 * @callback_method_impl{FNRTSTRFORMATTYPE} 2222 */ 2223 static DECLCALLBACK(size_t) 2224 hdaFormatStrmFifos(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2225 const char *pszType, void const *pvValue, 2226 int cchWidth, int cchPrecision, unsigned fFlags, 2227 void *pvUser) 2228 { 2229 uint32_t uSdFifos = (uint32_t)(uintptr_t)pvValue; 2230 uint32_t cb; 2231 switch (uSdFifos) 2232 { 2233 case HDA_SDONFIFO_16B: cb = 16; break; 2234 case HDA_SDONFIFO_32B: cb = 32; break; 2235 case HDA_SDONFIFO_64B: cb = 64; break; 2236 case HDA_SDONFIFO_128B: cb = 128; break; 2237 case HDA_SDONFIFO_192B: cb = 192; break; 2238 case HDA_SDONFIFO_256B: cb = 256; break; 2239 case HDA_SDINFIFO_120B: cb = 120; break; 2240 case HDA_SDINFIFO_160B: cb = 160; break; 2241 default: cb = 0; break; 2242 } 2243 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOS(raw: %#x, sdfifos:%u B)", uSdFifos, cb); 2244 } 2245 2246 /** 2247 * @callback_method_impl{FNRTSTRFORMATTYPE} 2248 */ 2249 static DECLCALLBACK(size_t) 2250 hdaFormatStrmFifow(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2251 const char *pszType, void const *pvValue, 2252 int cchWidth, int cchPrecision, unsigned fFlags, 2253 void *pvUser) 2254 { 2255 uint32_t uSdFifos = (uint32_t)(uintptr_t)pvValue; 2256 uint32_t cb; 2257 switch (uSdFifos) 2258 { 2259 case HDA_SDFIFOW_8B: cb = 8; break; 2260 case HDA_SDFIFOW_16B: cb = 16; break; 2261 case HDA_SDFIFOW_32B: cb = 32; break; 2262 default: cb = 0; break; 2263 } 2264 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "SDFIFOW(raw: %#0x, sdfifow:%d B)", uSdFifos, cb); 2265 } 2266 2267 /** 2268 * @callback_method_impl{FNRTSTRFORMATTYPE} 2269 */ 2270 static DECLCALLBACK(size_t) 2271 hdaFormatStrmSts(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2272 const char *pszType, void const *pvValue, 2273 int cchWidth, int cchPrecision, unsigned fFlags, 2274 void *pvUser) 2275 { 2276 uint32_t uSdSts = (uint32_t)(uintptr_t)pvValue; 2277 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2278 "SDSTS(raw: %#0x, fifordy:%RTbool, dese:%RTbool, fifoe:%RTbool, bcis:%RTbool)", 2279 uSdSts, 2280 RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY)), 2281 RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE)), 2282 RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE)), 2283 RT_BOOL(uSdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS))); 2284 } 2285 2286 2287 static int hdaLookUpRegisterByName(INTELHDLinkState *pState, const char *pszArgs) 2288 { 2289 int iReg = 0; 2290 for (; iReg < HDA_NREGS; ++iReg) 2291 if (!RTStrICmp(g_aIchIntelHDRegMap[iReg].abbrev, pszArgs)) 2292 return iReg; 2293 return -1; 2294 } 2295 2296 2297 static void hdaDbgPrintRegister(INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaIndex) 2298 { 2299 Assert( pState 2300 && iHdaIndex >= 0 2301 && iHdaIndex < HDA_NREGS); 2302 pHlp->pfnPrintf(pHlp, "hda: %s: 0x%x\n", g_aIchIntelHDRegMap[iHdaIndex].abbrev, pState->au32Regs[iHdaIndex]); 2303 } 2304 2305 2306 /** 2307 * @callback_method_impl{FNDBGFHANDLERDEV} 2308 */ 2309 static DECLCALLBACK(void) hdaInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2310 { 2311 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2312 INTELHDLinkState *hda = &pThis->hda; 2313 int iHdaRegisterIndex = hdaLookUpRegisterByName(hda, pszArgs); 2314 if (iHdaRegisterIndex != -1) 2315 hdaDbgPrintRegister(hda, pHlp, iHdaRegisterIndex); 2316 else 2317 for(iHdaRegisterIndex = 0; (unsigned int)iHdaRegisterIndex < HDA_NREGS; ++iHdaRegisterIndex) 2318 hdaDbgPrintRegister(hda, pHlp, iHdaRegisterIndex); 2319 } 2320 2321 2322 static void hdaDbgPrintStream(INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaStrmIndex) 2323 { 2324 Assert( pState 2325 && iHdaStrmIndex >= 0 2326 && iHdaStrmIndex < 7); 2327 pHlp->pfnPrintf(pHlp, "Dump of %d HDA Stream:\n", iHdaStrmIndex); 2328 pHlp->pfnPrintf(pHlp, "SD%dCTL: %R[sdctl]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, CTL, iHdaStrmIndex)); 2329 pHlp->pfnPrintf(pHlp, "SD%dCTS: %R[sdsts]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, STS, iHdaStrmIndex)); 2330 pHlp->pfnPrintf(pHlp, "SD%dFIFOS: %R[sdfifos]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, FIFOS, iHdaStrmIndex)); 2331 pHlp->pfnPrintf(pHlp, "SD%dFIFOW: %R[sdfifow]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, FIFOW, iHdaStrmIndex)); 2332 } 2333 2334 2335 static int hdaLookUpStreamIndex(INTELHDLinkState *pState, const char *pszArgs) 2336 { 2337 /* todo: add args parsing */ 2338 return -1; 2339 } 2340 2341 2342 /** 2343 * @callback_method_impl{FNDBGFHANDLERDEV} 2344 */ 2345 static DECLCALLBACK(void) hdaInfoStream(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2346 { 2347 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2348 INTELHDLinkState *hda = &pThis->hda; 2349 int iHdaStrmIndex = hdaLookUpStreamIndex(hda, pszArgs); 2350 if (iHdaStrmIndex != -1) 2351 hdaDbgPrintStream(hda, pHlp, iHdaStrmIndex); 2352 else 2353 for(iHdaStrmIndex = 0; iHdaStrmIndex < 7; ++iHdaStrmIndex) 2354 hdaDbgPrintStream(hda, pHlp, iHdaStrmIndex); 2355 } 2356 2357 /** 2358 * @callback_method_impl{FNDBGFHANDLERDEV} 2359 */ 2360 static DECLCALLBACK(void) hdaInfoCodecNodes(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2361 { 2362 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2363 INTELHDLinkState *hda = &pThis->hda; 2364 if (hda->Codec.pfnCodecDbgListNodes) 2365 hda->Codec.pfnCodecDbgListNodes(&hda->Codec, pHlp, pszArgs); 2366 else 2367 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); 2368 } 2369 2370 2371 /** 2372 * @callback_method_impl{FNDBGFHANDLERDEV} 2373 */ 2374 static DECLCALLBACK(void) hdaInfoCodecSelector(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2375 { 2376 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2377 INTELHDLinkState *hda = &pThis->hda; 2378 if (hda->Codec.pfnCodecDbgSelector) 2379 hda->Codec.pfnCodecDbgSelector(&hda->Codec, pHlp, pszArgs); 2380 else 2381 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); 2382 } 2383 2384 2385 /* PDMIBASE */ 2386 2387 /** 2388 * @interface_method_impl{PDMIBASE,pfnQueryInterface} 2389 */ 2390 static DECLCALLBACK(void *) hdaQueryInterface(struct PDMIBASE *pInterface, const char *pszIID) 2391 { 2392 PCIINTELHDLinkState *pThis = RT_FROM_MEMBER(pInterface, PCIINTELHDLinkState, hda.IBase); 2393 Assert(&pThis->hda.IBase == pInterface); 2394 2395 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->hda.IBase); 2396 return NULL; 2397 } 2398 2399 2400 /* PDMDEVREG */ 2401 2198 2402 /** 2199 2403 * Reset notification. … … 2236 2440 2237 2441 HDABDLEDESC stEmptyBdle; 2238 for (uint8_t u8Strm = 0; u8Strm < 8; ++u8Strm)2239 { 2240 HDASTREAMTRANSFERDESC stStreamDesc;2442 for (uint8_t u8Strm = 0; u8Strm < 8; ++u8Strm) 2443 { 2444 HDASTREAMTRANSFERDESC StreamDesc; 2241 2445 PHDABDLEDESC pBdle = NULL; 2242 2446 if (u8Strm == 0) … … 2249 2453 pBdle = &stEmptyBdle; 2250 2454 } 2251 hdaInitTransferDescriptor(&pThis->hda, pBdle, u8Strm, & stStreamDesc);2455 hdaInitTransferDescriptor(&pThis->hda, pBdle, u8Strm, &StreamDesc); 2252 2456 /* hdaStreamReset prevents changing the SRST bit, so we force it to zero here. */ 2253 2457 HDA_STREAM_REG2(&pThis->hda, CTL, u8Strm) = 0; 2254 hdaStreamReset(&pThis->hda, pBdle, & stStreamDesc, u8Strm);2458 hdaStreamReset(&pThis->hda, pBdle, &StreamDesc, u8Strm); 2255 2459 } 2256 2460 … … 2261 2465 } 2262 2466 2467 2263 2468 /** 2264 * @interface_method_impl{PDM IBASE,pfnQueryInterface}2469 * @interface_method_impl{PDMDEVREG,pfnDestruct} 2265 2470 */ 2266 static DECLCALLBACK(void *) hdaQueryInterface (struct PDMIBASE *pInterface, 2267 const char *pszIID) 2268 { 2269 PCIINTELHDLinkState *pThis = RT_FROM_MEMBER(pInterface, PCIINTELHDLinkState, hda.IBase); 2270 Assert(&pThis->hda.IBase == pInterface); 2271 2272 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->hda.IBase); 2273 return NULL; 2274 } 2275 2276 DECLINLINE(int) hdaLookUpRegisterByName(INTELHDLinkState *pState, const char *pszArgs) 2277 { 2278 int iReg = 0; 2279 for (; iReg < HDA_NREGS; ++iReg) 2280 if (!RTStrICmp(s_ichIntelHDRegMap[iReg].abbrev, pszArgs)) 2281 return iReg; 2282 return -1; 2283 } 2284 DECLINLINE(void) hdaDbgPrintRegister(INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaIndex) 2285 { 2286 Assert( pState 2287 && iHdaIndex >= 0 2288 && iHdaIndex < HDA_NREGS); 2289 pHlp->pfnPrintf(pHlp, "hda: %s: 0x%x\n", s_ichIntelHDRegMap[iHdaIndex].abbrev, pState->au32Regs[iHdaIndex]); 2290 } 2291 static DECLCALLBACK(void) hdaDbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2471 static DECLCALLBACK(int) hdaDestruct(PPDMDEVINS pDevIns) 2292 2472 { 2293 2473 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2294 INTELHDLinkState *hda = &pThis->hda; 2295 int iHdaRegisterIndex = hdaLookUpRegisterByName(hda, pszArgs); 2296 if (iHdaRegisterIndex != -1) 2297 hdaDbgPrintRegister(hda, pHlp, iHdaRegisterIndex); 2298 else 2299 for(iHdaRegisterIndex = 0; (unsigned int)iHdaRegisterIndex < HDA_NREGS; ++iHdaRegisterIndex) 2300 hdaDbgPrintRegister(hda, pHlp, iHdaRegisterIndex); 2301 } 2302 2303 DECLINLINE(void) hdaDbgPrintStream(INTELHDLinkState *pState, PCDBGFINFOHLP pHlp, int iHdaStrmIndex) 2304 { 2305 Assert( pState 2306 && iHdaStrmIndex >= 0 2307 && iHdaStrmIndex < 7); 2308 pHlp->pfnPrintf(pHlp, "Dump of %d HDA Stream:\n", iHdaStrmIndex); 2309 pHlp->pfnPrintf(pHlp, "SD%dCTL: %R[sdctl]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, CTL, iHdaStrmIndex)); 2310 pHlp->pfnPrintf(pHlp, "SD%dCTS: %R[sdsts]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, STS, iHdaStrmIndex)); 2311 pHlp->pfnPrintf(pHlp, "SD%dFIFOS: %R[sdfifos]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, FIFOS, iHdaStrmIndex)); 2312 pHlp->pfnPrintf(pHlp, "SD%dFIFOW: %R[sdfifow]\n", iHdaStrmIndex, HDA_STREAM_REG2(pState, FIFOW, iHdaStrmIndex)); 2313 } 2314 2315 DECLINLINE(int) hdaLookUpStreamIndex(INTELHDLinkState *pState, const char *pszArgs) 2316 { 2317 /* todo: add args parsing */ 2318 return -1; 2319 } 2320 static DECLCALLBACK(void) hdaDbgStreamInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2321 { 2322 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2323 INTELHDLinkState *hda = &pThis->hda; 2324 int iHdaStrmIndex = hdaLookUpStreamIndex(hda, pszArgs); 2325 if (iHdaStrmIndex != -1) 2326 hdaDbgPrintStream(hda, pHlp, iHdaStrmIndex); 2327 else 2328 for(iHdaStrmIndex = 0; iHdaStrmIndex < 7; ++iHdaStrmIndex) 2329 hdaDbgPrintStream(hda, pHlp, iHdaStrmIndex); 2330 } 2331 2332 /* Codec debugger interface */ 2333 static DECLCALLBACK(void) hdaCodecDbgNodes(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2334 { 2335 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2336 INTELHDLinkState *hda = &pThis->hda; 2337 if (hda->Codec.pfnCodecDbgListNodes) 2338 hda->Codec.pfnCodecDbgListNodes(&hda->Codec, pHlp, pszArgs); 2339 else 2340 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); 2341 } 2342 2343 static DECLCALLBACK(void) hdaCodecDbgSelector(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 2344 { 2345 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2346 INTELHDLinkState *hda = &pThis->hda; 2347 if (hda->Codec.pfnCodecDbgSelector) 2348 hda->Codec.pfnCodecDbgSelector(&hda->Codec, pHlp, pszArgs); 2349 else 2350 pHlp->pfnPrintf(pHlp, "Codec implementation doesn't provide corresponding callback.\n"); 2351 } 2352 2353 //#define HDA_AS_PCI_EXPRESS 2354 /* Misc routines */ 2355 static inline bool printHdaIsValid(const char *pszType, const char *pszExpectedFlag) 2356 { 2357 return (RTStrCmp(pszType, pszExpectedFlag) == 0); 2358 } 2359 static const char *printHdaYesNo(bool fFlag) 2360 { 2361 return fFlag ? "yes" : "no"; 2362 } 2363 static DECLCALLBACK(size_t) 2364 printHdaStrmCtl(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2365 const char *pszType, void const *pvValue, 2366 int cchWidth, int cchPrecision, unsigned fFlags, 2367 void *pvUser) 2368 { 2369 uint32_t sdCtl = (uint32_t)(uintptr_t)pvValue; 2370 size_t cb = 0; 2371 if (!printHdaIsValid(pszType, "sdctl")) 2372 return cb; 2373 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2374 "SDCTL(raw: %#0x, strm:0x%x, dir:%s, tp:%s strip:%x, deie:%s, ioce:%s, run:%s, srst:%s)", 2375 sdCtl, 2376 ((sdCtl & HDA_REG_FIELD_MASK(SDCTL, NUM)) >> ICH6_HDA_SDCTL_NUM_SHIFT), 2377 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DIR))), 2378 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, TP))), 2379 ((sdCtl & HDA_REG_FIELD_MASK(SDCTL, STRIPE)) >> ICH6_HDA_SDCTL_STRIPE_SHIFT), 2380 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, DEIE))), 2381 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, ICE))), 2382 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN))), 2383 printHdaYesNo(RT_BOOL(sdCtl & HDA_REG_FIELD_FLAG_MASK(SDCTL, SRST)))); 2384 return cb; 2385 } 2386 2387 static DECLCALLBACK(size_t) 2388 printHdaStrmFifos(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2389 const char *pszType, void const *pvValue, 2390 int cchWidth, int cchPrecision, unsigned fFlags, 2391 void *pvUser) 2392 { 2393 uint32_t sdFifos = (uint32_t)(uintptr_t)pvValue; 2394 uint32_t u32Bytes = 0; 2395 size_t cb = 0; 2396 if (!printHdaIsValid(pszType, "sdfifos")) 2397 return cb; 2398 switch(sdFifos) 2399 { 2400 case HDA_SDONFIFO_16B: u32Bytes = 16; break; 2401 case HDA_SDONFIFO_32B: u32Bytes = 32; break; 2402 case HDA_SDONFIFO_64B: u32Bytes = 64; break; 2403 case HDA_SDONFIFO_128B: u32Bytes = 128; break; 2404 case HDA_SDONFIFO_192B: u32Bytes = 192; break; 2405 case HDA_SDONFIFO_256B: u32Bytes = 256; break; 2406 case HDA_SDINFIFO_120B: u32Bytes = 120; break; 2407 case HDA_SDINFIFO_160B: u32Bytes = 160; break; 2408 default:; 2409 } 2410 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2411 "SDFIFOS(raw: %#0x, sdfifos:%d B)", 2412 sdFifos, 2413 u32Bytes); 2414 return cb; 2415 } 2416 2417 static DECLCALLBACK(size_t) 2418 printHdaStrmFifow(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2419 const char *pszType, void const *pvValue, 2420 int cchWidth, int cchPrecision, unsigned fFlags, 2421 void *pvUser) 2422 { 2423 uint32_t sdFifow = (uint32_t)(uintptr_t)pvValue; 2424 uint32_t u32Bytes = 0; 2425 size_t cb = 0; 2426 if (!printHdaIsValid(pszType, "sdfifow")) 2427 return cb; 2428 switch(sdFifow) 2429 { 2430 case HDA_SDFIFOW_8B: u32Bytes = 8; break; 2431 case HDA_SDFIFOW_16B: u32Bytes = 16; break; 2432 case HDA_SDFIFOW_32B: u32Bytes = 32; break; 2433 } 2434 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2435 "SDFIFOW(raw: %#0x, sdfifow:%d B)", 2436 sdFifow, 2437 u32Bytes); 2438 return cb; 2439 } 2440 2441 static DECLCALLBACK(size_t) 2442 printHdaStrmSts(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 2443 const char *pszType, void const *pvValue, 2444 int cchWidth, int cchPrecision, unsigned fFlags, 2445 void *pvUser) 2446 { 2447 uint32_t sdSts = (uint32_t)(uintptr_t)pvValue; 2448 size_t cb = 0; 2449 if (!printHdaIsValid(pszType, "sdsts")) 2450 return cb; 2451 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 2452 "SDSTS(raw: %#0x, fifordy:%s, dese:%s, fifoe:%s, bcis:%s)", 2453 sdSts, 2454 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FIFORDY))), 2455 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, DE))), 2456 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, FE))), 2457 printHdaYesNo(RT_BOOL(sdSts & HDA_REG_FIELD_FLAG_MASK(SDSTS, BCIS)))); 2458 return cb; 2459 } 2460 /** 2461 * This routine registers debugger info extensions and custom printf formatters 2462 */ 2463 DECLINLINE(int) hdaInitMisc(PPDMDEVINS pDevIns) 2464 { 2465 int rc; 2466 PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hdaDbgInfo); 2467 PDMDevHlpDBGFInfoRegister(pDevIns, "hdastrm", "HDA stream info. (hdastrm [stream number])", hdaDbgStreamInfo); 2468 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hdaCodecDbgNodes); 2469 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcselector", "HDA codec's selector states [node number].", hdaCodecDbgSelector); 2470 rc = RTStrFormatTypeRegister("sdctl", printHdaStrmCtl, NULL); 2474 2475 int rc = codecDestruct(&pThis->hda.Codec); 2471 2476 AssertRC(rc); 2472 rc = RTStrFormatTypeRegister("sdsts", printHdaStrmSts, NULL); 2473 AssertRC(rc); 2474 rc = RTStrFormatTypeRegister("sdfifos", printHdaStrmFifos, NULL); 2475 AssertRC(rc); 2476 rc = RTStrFormatTypeRegister("sdfifow", printHdaStrmFifow, NULL); 2477 AssertRC(rc); 2478 #if 0 2479 rc = RTStrFormatTypeRegister("sdfmt", printHdaStrmFmt, NULL); 2480 AssertRC(rc); 2481 #endif 2482 return rc; 2477 if (pThis->hda.pu32CorbBuf) 2478 RTMemFree(pThis->hda.pu32CorbBuf); 2479 if (pThis->hda.pu64RirbBuf) 2480 RTMemFree(pThis->hda.pu64RirbBuf); 2481 return VINF_SUCCESS; 2483 2482 } 2484 2483 … … 2499 2498 * Validations. 2500 2499 */ 2501 if (!CFGMR3AreValuesValid 2502 return PDMDEV_SET_ERROR 2503 2500 if (!CFGMR3AreValuesValid(pCfgHandle, "\0")) 2501 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 2502 N_ ("Invalid configuration for the Intel HDA device")); 2504 2503 2505 2504 // ** @todo r=michaln: This device may need R0/RC enabling, especially if guests … … 2538 2537 2539 2538 /// @todo r=michaln: If there are really no PCIDevSetXx for these, the meaning 2540 // of these values needs to be properly documented!2539 /// of these values needs to be properly documented! 2541 2540 /* HDCTL off 0x40 bit 0 selects signaling mode (1-HDA, 0 - Ac97) 18.1.19 */ 2542 2541 PCIDevSetByte(&pThis->dev, 0x40, 0x01); … … 2549 2548 #ifdef HDA_AS_PCI_EXPRESS 2550 2549 /* PCI Express */ 2551 PCIDevSetByte 2552 PCIDevSetByte 2550 PCIDevSetByte(&pThis->dev, 0x80 + 0, VBOX_PCI_CAP_ID_EXP); /* PCI_Express */ 2551 PCIDevSetByte(&pThis->dev, 0x80 + 1, 0x60); /* next */ 2553 2552 /* Device flags */ 2554 PCIDevSetWord (&pThis->dev, 0x80 + 2, 2555 /* version */ 0x1 | 2556 /* Root Complex Integrated Endpoint */ (VBOX_PCI_EXP_TYPE_ROOT_INT_EP << 4) | 2557 /* MSI */ (100) << 9 2558 ); 2553 PCIDevSetWord(&pThis->dev, 0x80 + 2, 2554 /* version */ 0x1 | 2555 /* Root Complex Integrated Endpoint */ (VBOX_PCI_EXP_TYPE_ROOT_INT_EP << 4) | 2556 /* MSI */ (100) << 9 ); 2559 2557 /* Device capabilities */ 2560 PCIDevSetDWord 2558 PCIDevSetDWord(&pThis->dev, 0x80 + 4, VBOX_PCI_EXP_DEVCAP_FLRESET); 2561 2559 /* Device control */ 2562 PCIDevSetWord (&pThis->dev, 0x80 + 8, 0);2560 PCIDevSetWord( &pThis->dev, 0x80 + 8, 0); 2563 2561 /* Device status */ 2564 PCIDevSetWord (&pThis->dev, 0x80 + 10, 0);2562 PCIDevSetWord( &pThis->dev, 0x80 + 10, 0); 2565 2563 /* Link caps */ 2566 PCIDevSetDWord 2564 PCIDevSetDWord(&pThis->dev, 0x80 + 12, 0); 2567 2565 /* Link control */ 2568 PCIDevSetWord (&pThis->dev, 0x80 + 16, 0);2566 PCIDevSetWord( &pThis->dev, 0x80 + 16, 0); 2569 2567 /* Link status */ 2570 PCIDevSetWord (&pThis->dev, 0x80 + 18, 0);2568 PCIDevSetWord( &pThis->dev, 0x80 + 18, 0); 2571 2569 /* Slot capabilities */ 2572 PCIDevSetDWord 2570 PCIDevSetDWord(&pThis->dev, 0x80 + 20, 0); 2573 2571 /* Slot control */ 2574 PCIDevSetWord (&pThis->dev, 0x80 + 24, 0);2572 PCIDevSetWord( &pThis->dev, 0x80 + 24, 0); 2575 2573 /* Slot status */ 2576 PCIDevSetWord (&pThis->dev, 0x80 + 26, 0);2574 PCIDevSetWord( &pThis->dev, 0x80 + 26, 0); 2577 2575 /* Root control */ 2578 PCIDevSetWord (&pThis->dev, 0x80 + 28, 0);2576 PCIDevSetWord( &pThis->dev, 0x80 + 28, 0); 2579 2577 /* Root capabilities */ 2580 PCIDevSetWord (&pThis->dev, 0x80 + 30, 0);2578 PCIDevSetWord( &pThis->dev, 0x80 + 30, 0); 2581 2579 /* Root status */ 2582 PCIDevSetDWord 2580 PCIDevSetDWord(&pThis->dev, 0x80 + 32, 0); 2583 2581 /* Device capabilities 2 */ 2584 PCIDevSetDWord 2582 PCIDevSetDWord(&pThis->dev, 0x80 + 36, 0); 2585 2583 /* Device control 2 */ 2586 PCIDevSetQWord 2584 PCIDevSetQWord(&pThis->dev, 0x80 + 40, 0); 2587 2585 /* Link control 2 */ 2588 PCIDevSetQWord 2586 PCIDevSetQWord(&pThis->dev, 0x80 + 48, 0); 2589 2587 /* Slot control 2 */ 2590 PCIDevSetWord (&pThis->dev, 0x80 + 56, 0);2588 PCIDevSetWord( &pThis->dev, 0x80 + 56, 0); 2591 2589 #endif 2592 2590 … … 2594 2592 * Register the PCI device. 2595 2593 */ 2596 rc = PDMDevHlpPCIRegister 2597 if (RT_FAILURE 2594 rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev); 2595 if (RT_FAILURE(rc)) 2598 2596 return rc; 2599 2597 2600 rc = PDMDevHlpPCIIORegionRegister (pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM, 2601 hdaMap); 2602 if (RT_FAILURE (rc)) 2598 rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x4000, PCI_ADDRESS_SPACE_MEM, hdaMap); 2599 if (RT_FAILURE(rc)) 2603 2600 return rc; 2604 2601 … … 2610 2607 MsiReg.iMsiNextOffset = 0x50; 2611 2608 rc = PDMDevHlpPCIRegisterMsi(pDevIns, &MsiReg); 2612 if (RT_FAILURE 2609 if (RT_FAILURE(rc)) 2613 2610 { 2614 2611 LogRel(("Chipset cannot do MSI: %Rrc\n", rc)); 2615 PCIDevSetCapabilityList 2612 PCIDevSetCapabilityList(&pThis->dev, 0x50); 2616 2613 } 2617 2614 #endif 2618 2615 2619 rc = PDMDevHlpSSMRegister 2620 if (RT_FAILURE 2616 rc = PDMDevHlpSSMRegister(pDevIns, HDA_SSM_VERSION, sizeof(*pThis), hdaSaveExec, hdaLoadExec); 2617 if (RT_FAILURE(rc)) 2621 2618 return rc; 2622 2619 … … 2624 2621 * Attach driver. 2625 2622 */ 2626 rc = PDMDevHlpDriverAttach (pDevIns, 0, &s->IBase, 2627 &s->pDrvBase, "Audio Driver Port"); 2623 rc = PDMDevHlpDriverAttach(pDevIns, 0, &s->IBase, &s->pDrvBase, "Audio Driver Port"); 2628 2624 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2629 Log 2630 else if (RT_FAILURE 2631 { 2632 AssertMsgFailed 2625 Log(("hda: No attached driver!\n")); 2626 else if (RT_FAILURE(rc)) 2627 { 2628 AssertMsgFailed(("Failed to attach Intel HDA LUN #0! rc=%Rrc\n", rc)); 2633 2629 return rc; 2634 2630 } … … 2636 2632 2637 2633 2638 pThis->hda.Codec.p HDAState = (void *)&pThis->hda;2634 pThis->hda.Codec.pvHDAState = (void *)&pThis->hda; 2639 2635 rc = codecConstruct(pDevIns, &pThis->hda.Codec, pCfgHandle); 2640 2636 if (RT_FAILURE(rc)) … … 2648 2644 PCIDevSetSubSystemId (&pThis->dev, pThis->hda.Codec.u16DeviceId); /* 2e ro. */ 2649 2645 2650 hdaReset 2646 hdaReset(pDevIns); 2651 2647 pThis->hda.Codec.id = 0; 2652 2648 pThis->hda.Codec.pfnTransfer = hdaTransfer; 2653 2649 pThis->hda.Codec.pfnReset = hdaCodecReset; 2650 2654 2651 /* 2655 2652 * 18.2.6,7 defines that values of this registers might be cleared on power on/reset … … 2658 2655 WAKEEN(&pThis->hda) = 0x0; 2659 2656 STATESTS(&pThis->hda) = 0x0; 2660 hdaInitMisc(pDevIns); 2661 2662 return VINF_SUCCESS; 2663 } 2664 2665 /** 2666 * @interface_method_impl{PDMDEVREG,pfnDestruct} 2667 */ 2668 static DECLCALLBACK(int) hdaDestruct (PPDMDEVINS pDevIns) 2669 { 2670 PCIINTELHDLinkState *pThis = PDMINS_2_DATA(pDevIns, PCIINTELHDLinkState *); 2671 2672 int rc = codecDestruct(&pThis->hda.Codec); 2657 2658 /* 2659 * Debug and string formatter types. 2660 */ 2661 PDMDevHlpDBGFInfoRegister(pDevIns, "hda", "HDA info. (hda [register case-insensitive])", hdaInfo); 2662 PDMDevHlpDBGFInfoRegister(pDevIns, "hdastrm", "HDA stream info. (hdastrm [stream number])", hdaInfoStream); 2663 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcnodes", "HDA codec nodes.", hdaInfoCodecNodes); 2664 PDMDevHlpDBGFInfoRegister(pDevIns, "hdcselector", "HDA codec's selector states [node number].", hdaInfoCodecSelector); 2665 2666 rc = RTStrFormatTypeRegister("sdctl", hdaFormatStrmCtl, NULL); 2673 2667 AssertRC(rc); 2674 if (pThis->hda.pu32CorbBuf) 2675 RTMemFree(pThis->hda.pu32CorbBuf); 2676 if (pThis->hda.pu64RirbBuf) 2677 RTMemFree(pThis->hda.pu64RirbBuf); 2668 rc = RTStrFormatTypeRegister("sdsts", hdaFormatStrmSts, NULL); 2669 AssertRC(rc); 2670 rc = RTStrFormatTypeRegister("sdfifos", hdaFormatStrmFifos, NULL); 2671 AssertRC(rc); 2672 rc = RTStrFormatTypeRegister("sdfifow", hdaFormatStrmFifow, NULL); 2673 AssertRC(rc); 2674 #if 0 2675 rc = RTStrFormatTypeRegister("sdfmt", printHdaStrmFmt, NULL); 2676 AssertRC(rc); 2677 #endif 2678 2678 2679 return VINF_SUCCESS; 2679 2680 }
Note:
See TracChangeset
for help on using the changeset viewer.