VirtualBox

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

Last change on this file since 82421 was 82421, checked in by vboxsync, 5 years ago

DevHDA: Keep the 'hdcnodes' debug info item working in release builds too. bugref:9218

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