1 | /* $Id: DevHDA.h 69119 2017-10-17 19:08:38Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DevHDA.h - VBox Intel HD Audio Controller.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef DEV_HDA_H
|
---|
19 | #define DEV_HDA_H
|
---|
20 |
|
---|
21 | /*********************************************************************************************************************************
|
---|
22 | * Header Files *
|
---|
23 | *********************************************************************************************************************************/
|
---|
24 | #include <VBox/vmm/pdmdev.h>
|
---|
25 |
|
---|
26 | #include "AudioMixer.h"
|
---|
27 |
|
---|
28 | #include "HDACodec.h"
|
---|
29 | #include "HDAStream.h"
|
---|
30 | #include "HDAStreamMap.h"
|
---|
31 | #include "HDAStreamPeriod.h"
|
---|
32 |
|
---|
33 |
|
---|
34 | /*********************************************************************************************************************************
|
---|
35 | * Defines *
|
---|
36 | *********************************************************************************************************************************/
|
---|
37 |
|
---|
38 |
|
---|
39 | /*********************************************************************************************************************************
|
---|
40 | * Structures and Typedefs *
|
---|
41 | *********************************************************************************************************************************/
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Structure defining an HDA mixer sink.
|
---|
45 | * Its purpose is to know which audio mixer sink is bound to
|
---|
46 | * which SDn (SDI/SDO) device stream.
|
---|
47 | *
|
---|
48 | * This is needed in order to handle interleaved streams
|
---|
49 | * (that is, multiple channels in one stream) or non-interleaved
|
---|
50 | * streams (each channel has a dedicated stream).
|
---|
51 | *
|
---|
52 | * This is only known to the actual device emulation level.
|
---|
53 | */
|
---|
54 | typedef struct HDAMIXERSINK
|
---|
55 | {
|
---|
56 | /** SDn ID this sink is assigned to. 0 if not assigned. */
|
---|
57 | uint8_t uSD;
|
---|
58 | /** Channel ID of SDn ID. Only valid if SDn ID is valid. */
|
---|
59 | uint8_t uChannel;
|
---|
60 | uint8_t Padding[3];
|
---|
61 | /** Pointer to the actual audio mixer sink. */
|
---|
62 | R3PTRTYPE(PAUDMIXSINK) pMixSink;
|
---|
63 | } HDAMIXERSINK, *PHDAMIXERSINK;
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Structure for mapping a stream tag to an HDA stream.
|
---|
67 | */
|
---|
68 | typedef struct HDATAG
|
---|
69 | {
|
---|
70 | /** Own stream tag. */
|
---|
71 | uint8_t uTag;
|
---|
72 | uint8_t Padding[7];
|
---|
73 | /** Pointer to associated stream. */
|
---|
74 | R3PTRTYPE(PHDASTREAM) pStream;
|
---|
75 | } HDATAG, *PHDATAG;
|
---|
76 |
|
---|
77 | #ifdef DEBUG
|
---|
78 | /** @todo Make STAM values out of this? */
|
---|
79 | typedef struct HDASTATEDBGINFO
|
---|
80 | {
|
---|
81 | /** Timestamp (in ns) of the last timer callback (hdaTimer).
|
---|
82 | * Used to calculate the time actually elapsed between two timer callbacks. */
|
---|
83 | uint64_t tsTimerLastCalledNs;
|
---|
84 | /** IRQ debugging information. */
|
---|
85 | struct
|
---|
86 | {
|
---|
87 | /** Timestamp (in ns) of last processed (asserted / deasserted) IRQ. */
|
---|
88 | uint64_t tsProcessedLastNs;
|
---|
89 | /** Timestamp (in ns) of last asserted IRQ. */
|
---|
90 | uint64_t tsAssertedNs;
|
---|
91 | /** How many IRQs have been asserted already. */
|
---|
92 | uint64_t cAsserted;
|
---|
93 | /** Accumulated elapsed time (in ns) of all IRQ being asserted. */
|
---|
94 | uint64_t tsAssertedTotalNs;
|
---|
95 | /** Timestamp (in ns) of last deasserted IRQ. */
|
---|
96 | uint64_t tsDeassertedNs;
|
---|
97 | /** How many IRQs have been deasserted already. */
|
---|
98 | uint64_t cDeasserted;
|
---|
99 | /** Accumulated elapsed time (in ns) of all IRQ being deasserted. */
|
---|
100 | uint64_t tsDeassertedTotalNs;
|
---|
101 | } IRQ;
|
---|
102 | } HDASTATEDBGINFO, *PHDASTATEDBGINFO;
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * ICH Intel HD Audio Controller state.
|
---|
107 | */
|
---|
108 | typedef struct HDASTATE
|
---|
109 | {
|
---|
110 | /** The PCI device structure. */
|
---|
111 | PDMPCIDEV PciDev;
|
---|
112 | /** R3 Pointer to the device instance. */
|
---|
113 | PPDMDEVINSR3 pDevInsR3;
|
---|
114 | /** R0 Pointer to the device instance. */
|
---|
115 | PPDMDEVINSR0 pDevInsR0;
|
---|
116 | /** R0 Pointer to the device instance. */
|
---|
117 | PPDMDEVINSRC pDevInsRC;
|
---|
118 | /** Padding for alignment. */
|
---|
119 | uint32_t u32Padding;
|
---|
120 | /** Critical section protecting the HDA state. */
|
---|
121 | PDMCRITSECT CritSect;
|
---|
122 | /** The base interface for LUN\#0. */
|
---|
123 | PDMIBASE IBase;
|
---|
124 | RTGCPHYS MMIOBaseAddr;
|
---|
125 | /** The HDA's register set. */
|
---|
126 | uint32_t au32Regs[HDA_NUM_REGS];
|
---|
127 | /** Internal stream states. */
|
---|
128 | HDASTREAM aStreams[HDA_MAX_STREAMS];
|
---|
129 | /** Mapping table between stream tags and stream states. */
|
---|
130 | HDATAG aTags[HDA_MAX_TAGS];
|
---|
131 | /** CORB buffer base address. */
|
---|
132 | uint64_t u64CORBBase;
|
---|
133 | /** RIRB buffer base address. */
|
---|
134 | uint64_t u64RIRBBase;
|
---|
135 | /** DMA base address.
|
---|
136 | * Made out of DPLBASE + DPUBASE (3.3.32 + 3.3.33). */
|
---|
137 | uint64_t u64DPBase;
|
---|
138 | /** Pointer to CORB buffer. */
|
---|
139 | R3PTRTYPE(uint32_t *) pu32CorbBuf;
|
---|
140 | /** Size in bytes of CORB buffer. */
|
---|
141 | uint32_t cbCorbBuf;
|
---|
142 | /** Padding for alignment. */
|
---|
143 | uint32_t u32Padding1;
|
---|
144 | /** Pointer to RIRB buffer. */
|
---|
145 | R3PTRTYPE(uint64_t *) pu64RirbBuf;
|
---|
146 | /** Size in bytes of RIRB buffer. */
|
---|
147 | uint32_t cbRirbBuf;
|
---|
148 | /** DMA position buffer enable bit. */
|
---|
149 | bool fDMAPosition;
|
---|
150 | /** Flag whether the R0 part is enabled. */
|
---|
151 | bool fR0Enabled;
|
---|
152 | /** Flag whether the RC part is enabled. */
|
---|
153 | bool fRCEnabled;
|
---|
154 | /** Number of active (running) SDn streams. */
|
---|
155 | uint8_t cStreamsActive;
|
---|
156 | #ifndef VBOX_WITH_AUDIO_HDA_CALLBACKS
|
---|
157 | /** The timer for pumping data thru the attached LUN drivers. */
|
---|
158 | PTMTIMERR3 pTimer;
|
---|
159 | /** Flag indicating whether the timer is active or not. */
|
---|
160 | bool fTimerActive;
|
---|
161 | uint8_t u8Padding1[7];
|
---|
162 | /** Timer ticks per Hz. */
|
---|
163 | uint64_t cTimerTicks;
|
---|
164 | /** The current timer expire time (in timer ticks). */
|
---|
165 | uint64_t tsTimerExpire;
|
---|
166 | #endif
|
---|
167 | #ifdef VBOX_WITH_STATISTICS
|
---|
168 | # ifndef VBOX_WITH_AUDIO_HDA_CALLBACKS
|
---|
169 | STAMPROFILE StatTimer;
|
---|
170 | # endif
|
---|
171 | STAMPROFILE StatIn;
|
---|
172 | STAMPROFILE StatOut;
|
---|
173 | STAMCOUNTER StatBytesRead;
|
---|
174 | STAMCOUNTER StatBytesWritten;
|
---|
175 | #endif
|
---|
176 | /** Pointer to HDA codec to use. */
|
---|
177 | R3PTRTYPE(PHDACODEC) pCodec;
|
---|
178 | /** List of associated LUN drivers (HDADRIVER). */
|
---|
179 | RTLISTANCHORR3 lstDrv;
|
---|
180 | /** The device' software mixer. */
|
---|
181 | R3PTRTYPE(PAUDIOMIXER) pMixer;
|
---|
182 | /** HDA sink for (front) output. */
|
---|
183 | HDAMIXERSINK SinkFront;
|
---|
184 | #ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
|
---|
185 | /** HDA sink for center / LFE output. */
|
---|
186 | HDAMIXERSINK SinkCenterLFE;
|
---|
187 | /** HDA sink for rear output. */
|
---|
188 | HDAMIXERSINK SinkRear;
|
---|
189 | #endif
|
---|
190 | /** HDA mixer sink for line input. */
|
---|
191 | HDAMIXERSINK SinkLineIn;
|
---|
192 | #ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
|
---|
193 | /** Audio mixer sink for microphone input. */
|
---|
194 | HDAMIXERSINK SinkMicIn;
|
---|
195 | #endif
|
---|
196 | /** Last updated wall clock (WALCLK) counter. */
|
---|
197 | uint64_t u64WalClk;
|
---|
198 | #ifdef VBOX_STRICT
|
---|
199 | /** Wall clock (WALCLK) stale count.
|
---|
200 | * This indicates the number of set wall clock
|
---|
201 | * values which did not actually move the counter forward (stale). */
|
---|
202 | uint8_t u8WalClkStaleCnt;
|
---|
203 | uint8_t au8Padding2[7];
|
---|
204 | #endif
|
---|
205 | /** Response Interrupt Count (RINTCNT). */
|
---|
206 | uint8_t u8RespIntCnt;
|
---|
207 | /** Current IRQ level. */
|
---|
208 | uint8_t u8IRQL;
|
---|
209 | /** Padding for alignment. */
|
---|
210 | uint8_t au8Padding3[6];
|
---|
211 | #ifdef DEBUG
|
---|
212 | HDASTATEDBGINFO Dbg;
|
---|
213 | #endif
|
---|
214 | } HDASTATE, *PHDASTATE;
|
---|
215 |
|
---|
216 | #ifdef VBOX_WITH_AUDIO_HDA_CALLBACKS
|
---|
217 | typedef struct HDACALLBACKCTX
|
---|
218 | {
|
---|
219 | PHDASTATE pThis;
|
---|
220 | PHDADRIVER pDriver;
|
---|
221 | } HDACALLBACKCTX, *PHDACALLBACKCTX;
|
---|
222 | #endif
|
---|
223 |
|
---|
224 | #endif /* !DEV_HDA_H */
|
---|
225 |
|
---|