VirtualBox

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

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

DevHDA: Cleanups. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/* $Id: HDACodec.h 82406 2019-12-05 00:47:02Z 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/** The ICH HDA (Intel) controller. */
29typedef struct HDASTATE *PHDASTATE;
30/** The ICH HDA (Intel) codec state. */
31typedef struct HDACODEC *PHDACODEC;
32/** The HDA host driver backend. */
33typedef struct HDADRIVER *PHDADRIVER;
34typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
35typedef struct PDMAUDIOGSTSTRMOUT *PPDMAUDIOGSTSTRMOUT;
36typedef struct PDMAUDIOGSTSTRMIN *PPDMAUDIOGSTSTRMIN;
37
38/**
39 * Verb processor method.
40 */
41typedef DECLCALLBACK(int) FNHDACODECVERBPROCESSOR(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp);
42typedef FNHDACODECVERBPROCESSOR *PFNHDACODECVERBPROCESSOR;
43typedef FNHDACODECVERBPROCESSOR **PPFNHDACODECVERBPROCESSOR;
44
45/* PRM 5.3.1 */
46#define CODEC_RESPONSE_UNSOLICITED RT_BIT_64(34)
47
48typedef struct CODECVERB
49{
50 /** Verb. */
51 uint32_t verb;
52 /** Verb mask. */
53 uint32_t mask;
54 /** Function pointer for implementation callback. */
55 PFNHDACODECVERBPROCESSOR pfn;
56 /** Friendly name, for debugging. */
57 const char *pszName;
58} CODECVERB;
59
60union CODECNODE;
61typedef union CODECNODE CODECNODE, *PCODECNODE;
62
63/**
64 * HDA codec state.
65 */
66typedef struct HDACODEC
67{
68 uint16_t id;
69 uint16_t u16VendorId;
70 uint16_t u16DeviceId;
71 uint8_t u8BSKU;
72 uint8_t u8AssemblyId;
73 /** List of assigned HDA drivers to this codec.
74 * A driver only can be assigned to one codec at a time. */
75 RTLISTANCHOR lstDrv;
76
77 CODECVERB const *paVerbs;
78 size_t cVerbs;
79
80 PCODECNODE paNodes;
81 /** Pointer to HDA state (controller) this
82 * codec is assigned to. */
83 PHDASTATE pHDAState;
84 bool fInReset;
85
86 const uint8_t cTotalNodes;
87 const uint8_t *au8Ports;
88 const uint8_t *au8Dacs;
89 const uint8_t *au8AdcVols;
90 const uint8_t *au8Adcs;
91 const uint8_t *au8AdcMuxs;
92 const uint8_t *au8Pcbeeps;
93 const uint8_t *au8SpdifIns;
94 const uint8_t *au8SpdifOuts;
95 const uint8_t *au8DigInPins;
96 const uint8_t *au8DigOutPins;
97 const uint8_t *au8Cds;
98 const uint8_t *au8VolKnobs;
99 const uint8_t *au8Reserveds;
100 const uint8_t u8AdcVolsLineIn;
101 const uint8_t u8DacLineOut;
102
103 /** @name Public codec functions.
104 * @{ */
105 DECLR3CALLBACKMEMBER(int, pfnLookup, (PHDACODEC pThis, uint32_t uVerb, uint64_t *puResp));
106 DECLR3CALLBACKMEMBER(void, pfnReset, (PHDACODEC pThis));
107 DECLR3CALLBACKMEMBER(int, pfnNodeReset, (PHDACODEC pThis, uint8_t, PCODECNODE));
108 /** @} */
109
110 /** @name Callbacks to the HDA controller, mostly used for multiplexing to the
111 * various host backends.
112 * @{ */
113 DECLR3CALLBACKMEMBER(int, pfnCbMixerAddStream, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg));
114 DECLR3CALLBACKMEMBER(int, pfnCbMixerRemoveStream, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl));
115 DECLR3CALLBACKMEMBER(int, pfnCbMixerControl, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, uint8_t uSD, uint8_t uChannel));
116 DECLR3CALLBACKMEMBER(int, pfnCbMixerSetVolume, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOVOLUME pVol));
117 /** @} */
118
119 /** @name These callbacks are set by codec implementation to answer debugger requests.
120 * @{ */
121 DECLR3CALLBACKMEMBER(void, pfnDbgListNodes, (PHDACODEC pThis, PCDBGFINFOHLP pHlp, const char *pszArgs));
122 DECLR3CALLBACKMEMBER(void, pfnDbgSelector, (PHDACODEC pThis, PCDBGFINFOHLP pHlp, const char *pszArgs));
123 /** @} */
124
125#ifdef VBOX_WITH_STATISTICS
126 STAMCOUNTER StatLookups;
127#endif
128} HDACODEC;
129
130int hdaCodecConstruct(PPDMDEVINS pDevIns, PHDACODEC pThis, uint16_t uLUN, PCFGMNODE pCfg);
131void hdaCodecDestruct(PHDACODEC pThis);
132void hdaCodecPowerOff(PHDACODEC pThis);
133int hdaCodecSaveState(PPDMDEVINS pDevIns, PHDACODEC pThis, PSSMHANDLE pSSM);
134int hdaCodecLoadState(PPDMDEVINS pDevIns, PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion);
135int hdaCodecAddStream(PHDACODEC pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg);
136int hdaCodecRemoveStream(PHDACODEC pThis, PDMAUDIOMIXERCTL enmMixerCtl);
137
138/** @name DevHDA saved state versions
139 * @{ */
140/** Added (Controller): Current wall clock value (this independent from WALCLK register value).
141 * Added (Controller): Current IRQ level.
142 * Added (Per stream): Ring buffer. This is optional and can be skipped if (not) needed.
143 * Added (Per stream): Struct g_aSSMStreamStateFields7.
144 * Added (Per stream): Struct g_aSSMStreamPeriodFields7.
145 * Added (Current BDLE per stream): Struct g_aSSMBDLEDescFields7.
146 * Added (Current BDLE per stream): Struct g_aSSMBDLEStateFields7. */
147#define HDA_SAVED_STATE_VERSION 7
148/** Saves the current BDLE state.
149 * @since 5.0.14 (r104839) */
150#define HDA_SAVED_STATE_VERSION_6 6
151/** Introduced dynamic number of streams + stream identifiers for serialization.
152 * Bug: Did not save the BDLE states correctly.
153 * Those will be skipped on load then.
154 * @since 5.0.12 (r104520) */
155#define HDA_SAVED_STATE_VERSION_5 5
156/** Since this version the number of MMIO registers can be flexible. */
157#define HDA_SAVED_STATE_VERSION_4 4
158#define HDA_SAVED_STATE_VERSION_3 3
159#define HDA_SAVED_STATE_VERSION_2 2
160#define HDA_SAVED_STATE_VERSION_1 1
161/** @} */
162
163#endif /* !VBOX_INCLUDED_SRC_Audio_HDACodec_h */
164
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