VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/HDACodec.h@ 82781

Last change on this file since 82781 was 82452, checked in by vboxsync, 4 years ago

DevHDA: Put debug path on the heap rather than always grabbing ~4KB of state data for it. doxygen and scm fixes. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
Line 
1/* $Id: HDACodec.h 82452 2019-12-06 12:46:40Z vboxsync $ */
2/** @file
3 * HDACodec - VBox HD Audio Codec.
4 */
5
6/*
7 * Copyright (C) 2006-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_HDACodec_h
19#define VBOX_INCLUDED_SRC_Audio_HDACodec_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/list.h>
25
26#include "AudioMixer.h"
27
28/** Pointer to a shared HDA device state. */
29typedef struct HDASTATE *PHDASTATE;
30/** Pointer to a ring-3 HDA device state. */
31typedef struct HDASTATER3 *PHDASTATER3;
32/** The ICH HDA (Intel) codec state. */
33typedef struct HDACODEC *PHDACODEC;
34/** The HDA host driver backend. */
35typedef struct HDADRIVER *PHDADRIVER;
36
37/**
38 * Verb processor method.
39 */
40typedef DECLCALLBACK(int) FNHDACODECVERBPROCESSOR(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp);
41typedef FNHDACODECVERBPROCESSOR *PFNHDACODECVERBPROCESSOR;
42
43/* PRM 5.3.1 */
44#define CODEC_RESPONSE_UNSOLICITED RT_BIT_64(34)
45
46typedef struct CODECVERB
47{
48 /** Verb. */
49 uint32_t verb;
50 /** Verb mask. */
51 uint32_t mask;
52 /** Function pointer for implementation callback. */
53 PFNHDACODECVERBPROCESSOR pfn;
54 /** Friendly name, for debugging. */
55 const char *pszName;
56} CODECVERB;
57
58union CODECNODE;
59typedef union CODECNODE CODECNODE, *PCODECNODE;
60
61/**
62 * HDA codec state.
63 */
64typedef struct HDACODEC
65{
66 uint16_t id;
67 uint16_t u16VendorId;
68 uint16_t u16DeviceId;
69 uint8_t u8BSKU;
70 uint8_t u8AssemblyId;
71
72 /** List of assigned HDA drivers to this codec.
73 * A driver only can be assigned to one codec at a time. */
74 RTLISTANCHOR lstDrv;
75
76 CODECVERB const *paVerbs;
77 size_t cVerbs;
78
79 PCODECNODE paNodes;
80
81 bool fInReset;
82 uint8_t abPadding1[3];
83
84 const uint8_t cTotalNodes;
85 const uint8_t u8AdcVolsLineIn;
86 const uint8_t u8DacLineOut;
87 uint8_t bPadding2;
88 const uint8_t *au8Ports;
89 const uint8_t *au8Dacs;
90 const uint8_t *au8AdcVols;
91 const uint8_t *au8Adcs;
92 const uint8_t *au8AdcMuxs;
93 const uint8_t *au8Pcbeeps;
94 const uint8_t *au8SpdifIns;
95 const uint8_t *au8SpdifOuts;
96 const uint8_t *au8DigInPins;
97 const uint8_t *au8DigOutPins;
98 const uint8_t *au8Cds;
99 const uint8_t *au8VolKnobs;
100 const uint8_t *au8Reserveds;
101
102 /** @name Public codec functions.
103 * @{ */
104 DECLR3CALLBACKMEMBER(int, pfnLookup, (PHDACODEC pThis, uint32_t uVerb, uint64_t *puResp));
105 DECLR3CALLBACKMEMBER(void, pfnReset, (PHDACODEC pThis));
106 DECLR3CALLBACKMEMBER(int, pfnNodeReset, (PHDACODEC pThis, uint8_t, PCODECNODE));
107 DECLR3CALLBACKMEMBER(void, pfnDbgListNodes, (PHDACODEC pThis, PCDBGFINFOHLP pHlp, const char *pszArgs));
108 DECLR3CALLBACKMEMBER(void, pfnDbgSelector, (PHDACODEC pThis, PCDBGFINFOHLP pHlp, const char *pszArgs));
109 /** @} */
110
111 /** The parent device instance. */
112 PPDMDEVINS pDevIns;
113
114 /** @name Callbacks to the HDA controller, mostly used for multiplexing to the
115 * various host backends.
116 * @{ */
117 /**
118 *
119 * Adds a new audio stream to a specific mixer control.
120 *
121 * Depending on the mixer control the stream then gets assigned to one of the
122 * internal mixer sinks, which in turn then handle the mixing of all connected
123 * streams to that sink.
124 *
125 * @return VBox status code.
126 * @param pDevIns The device instance.
127 * @param enmMixerCtl Mixer control to assign new stream to.
128 * @param pCfg Stream configuration for the new stream.
129 */
130 DECLR3CALLBACKMEMBER(int, pfnCbMixerAddStream, (PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg));
131 /**
132 * Removes a specified mixer control from the HDA's mixer.
133 *
134 * @return VBox status code.
135 * @param pDevIns The device instance.
136 * @param enmMixerCtl Mixer control to remove.
137 */
138 DECLR3CALLBACKMEMBER(int, pfnCbMixerRemoveStream, (PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl));
139 /**
140 * Controls an input / output converter widget, that is, which converter is
141 * connected to which stream (and channel).
142 *
143 * @return VBox status code.
144 * @param pDevIns The device instance.
145 * @param enmMixerCtl Mixer control to set SD stream number and channel for.
146 * @param uSD SD stream number (number + 1) to set. Set to 0 for unassign.
147 * @param uChannel Channel to set. Only valid if a valid SD stream number is specified.
148 */
149 DECLR3CALLBACKMEMBER(int, pfnCbMixerControl, (PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl, uint8_t uSD, uint8_t uChannel));
150 /**
151 * Sets the volume of a specified mixer control.
152 *
153 * @return IPRT status code.
154 * @param pDevIns The device instance.
155 * @param enmMixerCtl Mixer control to set volume for.
156 * @param pVol Pointer to volume data to set.
157 */
158 DECLR3CALLBACKMEMBER(int, pfnCbMixerSetVolume, (PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOVOLUME pVol));
159 /** @} */
160
161#ifdef VBOX_WITH_STATISTICS
162 STAMCOUNTER StatLookups;
163#endif
164} HDACODEC;
165
166int hdaCodecConstruct(PPDMDEVINS pDevIns, PHDACODEC pThis, uint16_t uLUN, PCFGMNODE pCfg);
167void hdaCodecDestruct(PHDACODEC pThis);
168void hdaCodecPowerOff(PHDACODEC pThis);
169int hdaCodecSaveState(PPDMDEVINS pDevIns, PHDACODEC pThis, PSSMHANDLE pSSM);
170int hdaCodecLoadState(PPDMDEVINS pDevIns, PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion);
171int hdaCodecAddStream(PHDACODEC pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg);
172int hdaCodecRemoveStream(PHDACODEC pThis, PDMAUDIOMIXERCTL enmMixerCtl);
173
174/** @name DevHDA saved state versions
175 * @{ */
176/** Added (Controller): Current wall clock value (this independent from WALCLK register value).
177 * Added (Controller): Current IRQ level.
178 * Added (Per stream): Ring buffer. This is optional and can be skipped if (not) needed.
179 * Added (Per stream): Struct g_aSSMStreamStateFields7.
180 * Added (Per stream): Struct g_aSSMStreamPeriodFields7.
181 * Added (Current BDLE per stream): Struct g_aSSMBDLEDescFields7.
182 * Added (Current BDLE per stream): Struct g_aSSMBDLEStateFields7. */
183#define HDA_SAVED_STATE_VERSION 7
184/** Saves the current BDLE state.
185 * @since 5.0.14 (r104839) */
186#define HDA_SAVED_STATE_VERSION_6 6
187/** Introduced dynamic number of streams + stream identifiers for serialization.
188 * Bug: Did not save the BDLE states correctly.
189 * Those will be skipped on load then.
190 * @since 5.0.12 (r104520) */
191#define HDA_SAVED_STATE_VERSION_5 5
192/** Since this version the number of MMIO registers can be flexible. */
193#define HDA_SAVED_STATE_VERSION_4 4
194#define HDA_SAVED_STATE_VERSION_3 3
195#define HDA_SAVED_STATE_VERSION_2 2
196#define HDA_SAVED_STATE_VERSION_1 1
197/** @} */
198
199#endif /* !VBOX_INCLUDED_SRC_Audio_HDACodec_h */
200
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use