1 | /* $Id: HDACodec.h 70249 2017-12-20 18:13:26Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * HDACodec - VBox HD Audio Codec.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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_CODEC_H
|
---|
19 | #define DEV_HDA_CODEC_H
|
---|
20 |
|
---|
21 | #include <iprt/list.h>
|
---|
22 |
|
---|
23 | #include "AudioMixer.h"
|
---|
24 |
|
---|
25 | /** The ICH HDA (Intel) controller. */
|
---|
26 | typedef struct HDASTATE *PHDASTATE;
|
---|
27 | /** The ICH HDA (Intel) codec state. */
|
---|
28 | typedef struct HDACODEC *PHDACODEC;
|
---|
29 | /** The HDA host driver backend. */
|
---|
30 | typedef struct HDADRIVER *PHDADRIVER;
|
---|
31 | typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
|
---|
32 | typedef struct PDMAUDIOGSTSTRMOUT *PPDMAUDIOGSTSTRMOUT;
|
---|
33 | typedef struct PDMAUDIOGSTSTRMIN *PPDMAUDIOGSTSTRMIN;
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * Verb processor method.
|
---|
37 | */
|
---|
38 | typedef DECLCALLBACK(int) FNHDACODECVERBPROCESSOR(PHDACODEC pThis, uint32_t cmd, uint64_t *pResp);
|
---|
39 | typedef FNHDACODECVERBPROCESSOR *PFNHDACODECVERBPROCESSOR;
|
---|
40 | typedef FNHDACODECVERBPROCESSOR **PPFNHDACODECVERBPROCESSOR;
|
---|
41 |
|
---|
42 | /* PRM 5.3.1 */
|
---|
43 | #define CODEC_RESPONSE_UNSOLICITED RT_BIT_64(34)
|
---|
44 |
|
---|
45 | typedef struct CODECVERB
|
---|
46 | {
|
---|
47 | /** Verb. */
|
---|
48 | uint32_t verb;
|
---|
49 | /** Verb mask. */
|
---|
50 | uint32_t mask;
|
---|
51 | /** Function pointer for implementation callback. */
|
---|
52 | PFNHDACODECVERBPROCESSOR pfn;
|
---|
53 | /** Friendly name, for debugging. */
|
---|
54 | const char *pszName;
|
---|
55 | } CODECVERB;
|
---|
56 |
|
---|
57 | union CODECNODE;
|
---|
58 | typedef union CODECNODE CODECNODE, *PCODECNODE;
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Structure for keeping a HDA codec state.
|
---|
62 | */
|
---|
63 | typedef struct HDACODEC
|
---|
64 | {
|
---|
65 | uint16_t id;
|
---|
66 | uint16_t u16VendorId;
|
---|
67 | uint16_t u16DeviceId;
|
---|
68 | uint8_t u8BSKU;
|
---|
69 | uint8_t u8AssemblyId;
|
---|
70 | /** List of assigned HDA drivers to this codec.
|
---|
71 | * A driver only can be assigned to one codec at a time. */
|
---|
72 | RTLISTANCHOR lstDrv;
|
---|
73 |
|
---|
74 | CODECVERB const *paVerbs;
|
---|
75 | size_t cVerbs;
|
---|
76 |
|
---|
77 | PCODECNODE paNodes;
|
---|
78 | /** Pointer to HDA state (controller) this
|
---|
79 | * codec is assigned to. */
|
---|
80 | PHDASTATE pHDAState;
|
---|
81 | bool fInReset;
|
---|
82 |
|
---|
83 | const uint8_t cTotalNodes;
|
---|
84 | const uint8_t *au8Ports;
|
---|
85 | const uint8_t *au8Dacs;
|
---|
86 | const uint8_t *au8AdcVols;
|
---|
87 | const uint8_t *au8Adcs;
|
---|
88 | const uint8_t *au8AdcMuxs;
|
---|
89 | const uint8_t *au8Pcbeeps;
|
---|
90 | const uint8_t *au8SpdifIns;
|
---|
91 | const uint8_t *au8SpdifOuts;
|
---|
92 | const uint8_t *au8DigInPins;
|
---|
93 | const uint8_t *au8DigOutPins;
|
---|
94 | const uint8_t *au8Cds;
|
---|
95 | const uint8_t *au8VolKnobs;
|
---|
96 | const uint8_t *au8Reserveds;
|
---|
97 | const uint8_t u8AdcVolsLineIn;
|
---|
98 | const uint8_t u8DacLineOut;
|
---|
99 |
|
---|
100 | /** Public codec functions. */
|
---|
101 | DECLR3CALLBACKMEMBER(int, pfnLookup, (PHDACODEC pThis, uint32_t uVerb, uint64_t *puResp));
|
---|
102 | DECLR3CALLBACKMEMBER(void, pfnReset, (PHDACODEC pThis));
|
---|
103 | DECLR3CALLBACKMEMBER(int, pfnNodeReset, (PHDACODEC pThis, uint8_t, PCODECNODE));
|
---|
104 |
|
---|
105 | /** Callbacks to the HDA controller, mostly used for multiplexing to the various host backends. */
|
---|
106 | DECLR3CALLBACKMEMBER(int, pfnCbMixerAddStream, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg));
|
---|
107 | DECLR3CALLBACKMEMBER(int, pfnCbMixerRemoveStream, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl));
|
---|
108 | DECLR3CALLBACKMEMBER(int, pfnCbMixerControl, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, uint8_t uSD, uint8_t uChannel));
|
---|
109 | DECLR3CALLBACKMEMBER(int, pfnCbMixerSetVolume, (PHDASTATE pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOVOLUME pVol));
|
---|
110 |
|
---|
111 | /** These callbacks are set by codec implementation to answer debugger requests. */
|
---|
112 | DECLR3CALLBACKMEMBER(void, pfnDbgListNodes, (PHDACODEC pThis, PCDBGFINFOHLP pHlp, const char *pszArgs));
|
---|
113 | DECLR3CALLBACKMEMBER(void, pfnDbgSelector, (PHDACODEC pThis, PCDBGFINFOHLP pHlp, const char *pszArgs));
|
---|
114 | } HDACODEC;
|
---|
115 |
|
---|
116 | int hdaCodecConstruct(PPDMDEVINS pDevIns, PHDACODEC pThis, uint16_t uLUN, PCFGMNODE pCfg);
|
---|
117 | void hdaCodecDestruct(PHDACODEC pThis);
|
---|
118 | void hdaCodecPowerOff(PHDACODEC pThis);
|
---|
119 | int hdaCodecSaveState(PHDACODEC pThis, PSSMHANDLE pSSM);
|
---|
120 | int hdaCodecLoadState(PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion);
|
---|
121 | int hdaCodecAddStream(PHDACODEC pThis, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg);
|
---|
122 | int hdaCodecRemoveStream(PHDACODEC pThis, PDMAUDIOMIXERCTL enmMixerCtl);
|
---|
123 |
|
---|
124 | /** Added (Controller): Current wall clock value (this independent from WALCLK register value).
|
---|
125 | * Added (Controller): Current IRQ level.
|
---|
126 | * Added (Per stream): Ring buffer. This is optional and can be skipped if (not) needed.
|
---|
127 | * Added (Per stream): Struct g_aSSMStreamStateFields7.
|
---|
128 | * Added (Per stream): Struct g_aSSMStreamPeriodFields7.
|
---|
129 | * Added (Current BDLE per stream): Struct g_aSSMBDLEDescFields7.
|
---|
130 | * Added (Current BDLE per stream): Struct g_aSSMBDLEStateFields7. */
|
---|
131 | #define HDA_SSM_VERSION 7
|
---|
132 | /** Saves the current BDLE state. */
|
---|
133 | #define HDA_SSM_VERSION_6 6
|
---|
134 | /** Introduced dynamic number of streams + stream identifiers for serialization.
|
---|
135 | * Bug: Did not save the BDLE states correctly.
|
---|
136 | * Those will be skipped on load then. */
|
---|
137 | #define HDA_SSM_VERSION_5 5
|
---|
138 | /** Since this version the number of MMIO registers can be flexible. */
|
---|
139 | #define HDA_SSM_VERSION_4 4
|
---|
140 | #define HDA_SSM_VERSION_3 3
|
---|
141 | #define HDA_SSM_VERSION_2 2
|
---|
142 | #define HDA_SSM_VERSION_1 1
|
---|
143 |
|
---|
144 | #endif /* !DEV_HDA_CODEC_H */
|
---|
145 |
|
---|