VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/DevHDA.h@ 74572

Last change on this file since 74572 was 71730, checked in by vboxsync, 7 years ago

no need for flowerboxes in headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
Line 
1/* $Id: DevHDA.h 71730 2018-04-07 13:57:45Z vboxsync $ */
2/** @file
3 * DevHDA.h - VBox Intel HD Audio Controller.
4 */
5
6/*
7 * Copyright (C) 2016-2018 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#include <iprt/path.h>
22
23#include <VBox/vmm/pdmdev.h>
24
25#include "AudioMixer.h"
26
27#include "HDACodec.h"
28#include "HDAStream.h"
29#include "HDAStreamMap.h"
30#include "HDAStreamPeriod.h"
31
32
33
34/**
35 * Structure defining an HDA mixer sink.
36 * Its purpose is to know which audio mixer sink is bound to
37 * which SDn (SDI/SDO) device stream.
38 *
39 * This is needed in order to handle interleaved streams
40 * (that is, multiple channels in one stream) or non-interleaved
41 * streams (each channel has a dedicated stream).
42 *
43 * This is only known to the actual device emulation level.
44 */
45typedef struct HDAMIXERSINK
46{
47 R3PTRTYPE(PHDASTREAM) pStream;
48 /** Pointer to the actual audio mixer sink. */
49 R3PTRTYPE(PAUDMIXSINK) pMixSink;
50} HDAMIXERSINK, *PHDAMIXERSINK;
51
52/**
53 * Structure for mapping a stream tag to an HDA stream.
54 */
55typedef struct HDATAG
56{
57 /** Own stream tag. */
58 uint8_t uTag;
59 uint8_t Padding[7];
60 /** Pointer to associated stream. */
61 R3PTRTYPE(PHDASTREAM) pStream;
62} HDATAG, *PHDATAG;
63
64/** @todo Make STAM values out of this? */
65typedef struct HDASTATEDBGINFO
66{
67#ifdef DEBUG
68 /** Timestamp (in ns) of the last timer callback (hdaTimer).
69 * Used to calculate the time actually elapsed between two timer callbacks. */
70 uint64_t tsTimerLastCalledNs;
71 /** IRQ debugging information. */
72 struct
73 {
74 /** Timestamp (in ns) of last processed (asserted / deasserted) IRQ. */
75 uint64_t tsProcessedLastNs;
76 /** Timestamp (in ns) of last asserted IRQ. */
77 uint64_t tsAssertedNs;
78 /** How many IRQs have been asserted already. */
79 uint64_t cAsserted;
80 /** Accumulated elapsed time (in ns) of all IRQ being asserted. */
81 uint64_t tsAssertedTotalNs;
82 /** Timestamp (in ns) of last deasserted IRQ. */
83 uint64_t tsDeassertedNs;
84 /** How many IRQs have been deasserted already. */
85 uint64_t cDeasserted;
86 /** Accumulated elapsed time (in ns) of all IRQ being deasserted. */
87 uint64_t tsDeassertedTotalNs;
88 } IRQ;
89#endif
90 /** Whether debugging is enabled or not. */
91 bool fEnabled;
92 /** Path where to dump the debug output to.
93 * Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH. */
94 char szOutPath[RTPATH_MAX + 1];
95} HDASTATEDBGINFO, *PHDASTATEDBGINFO;
96
97/**
98 * ICH Intel HD Audio Controller state.
99 */
100typedef struct HDASTATE
101{
102 /** The PCI device structure. */
103 PDMPCIDEV PciDev;
104 /** R3 Pointer to the device instance. */
105 PPDMDEVINSR3 pDevInsR3;
106 /** R0 Pointer to the device instance. */
107 PPDMDEVINSR0 pDevInsR0;
108 /** R0 Pointer to the device instance. */
109 PPDMDEVINSRC pDevInsRC;
110 /** Padding for alignment. */
111 uint32_t u32Padding;
112 /** Critical section protecting the HDA state. */
113 PDMCRITSECT CritSect;
114 /** The base interface for LUN\#0. */
115 PDMIBASE IBase;
116 RTGCPHYS MMIOBaseAddr;
117 /** The HDA's register set. */
118 uint32_t au32Regs[HDA_NUM_REGS];
119 /** Internal stream states. */
120 HDASTREAM aStreams[HDA_MAX_STREAMS];
121 /** Mapping table between stream tags and stream states. */
122 HDATAG aTags[HDA_MAX_TAGS];
123 /** CORB buffer base address. */
124 uint64_t u64CORBBase;
125 /** RIRB buffer base address. */
126 uint64_t u64RIRBBase;
127 /** DMA base address.
128 * Made out of DPLBASE + DPUBASE (3.3.32 + 3.3.33). */
129 uint64_t u64DPBase;
130 /** Pointer to CORB buffer. */
131 R3PTRTYPE(uint32_t *) pu32CorbBuf;
132 /** Size in bytes of CORB buffer. */
133 uint32_t cbCorbBuf;
134 /** Padding for alignment. */
135 uint32_t u32Padding1;
136 /** Pointer to RIRB buffer. */
137 R3PTRTYPE(uint64_t *) pu64RirbBuf;
138 /** Size in bytes of RIRB buffer. */
139 uint32_t cbRirbBuf;
140 /** DMA position buffer enable bit. */
141 bool fDMAPosition;
142 /** Flag whether the R0 and RC parts are enabled. */
143 bool fRZEnabled;
144 /** Reserved. */
145 bool fPadding1b;
146 /** Number of active (running) SDn streams. */
147 uint8_t cStreamsActive;
148 /** The stream timers for pumping data thru the attached LUN drivers. */
149 PTMTIMERR3 pTimer[HDA_MAX_STREAMS];
150#ifdef VBOX_WITH_STATISTICS
151 STAMPROFILE StatTimer;
152 STAMPROFILE StatIn;
153 STAMPROFILE StatOut;
154 STAMCOUNTER StatBytesRead;
155 STAMCOUNTER StatBytesWritten;
156#endif
157 /** Pointer to HDA codec to use. */
158 R3PTRTYPE(PHDACODEC) pCodec;
159 /** List of associated LUN drivers (HDADRIVER). */
160 RTLISTANCHORR3 lstDrv;
161 /** The device' software mixer. */
162 R3PTRTYPE(PAUDIOMIXER) pMixer;
163 /** HDA sink for (front) output. */
164 HDAMIXERSINK SinkFront;
165#ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
166 /** HDA sink for center / LFE output. */
167 HDAMIXERSINK SinkCenterLFE;
168 /** HDA sink for rear output. */
169 HDAMIXERSINK SinkRear;
170#endif
171 /** HDA mixer sink for line input. */
172 HDAMIXERSINK SinkLineIn;
173#ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
174 /** Audio mixer sink for microphone input. */
175 HDAMIXERSINK SinkMicIn;
176#endif
177 /** Last updated wall clock (WALCLK) counter. */
178 uint64_t u64WalClk;
179#ifdef VBOX_STRICT
180 /** Wall clock (WALCLK) stale count.
181 * This indicates the number of set wall clock
182 * values which did not actually move the counter forward (stale). */
183 uint8_t u8WalClkStaleCnt;
184 uint8_t au8Padding2[7];
185#endif
186 /** Response Interrupt Count (RINTCNT). */
187 uint16_t u16RespIntCnt;
188 /** Position adjustment (in audio frames).
189 *
190 * This is not an official feature of the HDA specs, but used by
191 * certain OS drivers (e.g. snd_hda_intel) to work around certain
192 * quirks by "real" HDA hardware implementations.
193 *
194 * The position adjustment specifies how many audio frames
195 * a stream is ahead from its actual reading/writing position when
196 * starting a stream.
197 */
198 uint16_t cPosAdjustFrames;
199 /** Whether the position adjustment is enabled or not. */
200 bool fPosAdjustEnabled;
201 uint8_t Padding1[3];
202 /** Current IRQ level. */
203 uint8_t u8IRQL;
204 /** The device timer Hz rate. Defaults to HDA_TIMER_HZ_DEFAULT. */
205 uint16_t u16TimerHz;
206 /** Padding for alignment. */
207 uint8_t au8Padding3[3];
208 HDASTATEDBGINFO Dbg;
209 /** This is for checking that the build was correctly configured in all contexts.
210 * This is set to HDASTATE_ALIGNMENT_CHECK_MAGIC. */
211 uint64_t uAlignmentCheckMagic;
212} HDASTATE, *PHDASTATE;
213
214/** Value for HDASTATE:uAlignmentCheckMagic. */
215#define HDASTATE_ALIGNMENT_CHECK_MAGIC UINT64_C(0x1298afb75893e059)
216
217#endif /* !DEV_HDA_H */
218
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette