1 | /* $Id: DevCodec.h 31507 2010-08-10 06:52:49Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * DevCodec - VBox ICH Intel HD Audio Codec.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2008 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 | #ifndef DEV_CODEC_H
|
---|
18 | #define DEV_CODEC_H
|
---|
19 | struct CODECState;
|
---|
20 | struct INTELHDLinkState;
|
---|
21 |
|
---|
22 | typedef DECLCALLBACK(int) FNCODECVERBPROCESSOR(struct CODECState *pState, uint32_t cmd, uint64_t *pResp);
|
---|
23 | typedef FNCODECVERBPROCESSOR *PFNCODECVERBPROCESSOR;
|
---|
24 | typedef FNCODECVERBPROCESSOR **PPFNCODECVERBPROCESSOR;
|
---|
25 |
|
---|
26 | /* RPM 5.3.1 */
|
---|
27 | #define CODEC_RESPONSE_UNSOLICITED RT_BIT_64(34)
|
---|
28 |
|
---|
29 | typedef struct CODECVERB
|
---|
30 | {
|
---|
31 | uint32_t verb;
|
---|
32 | /* operation bitness mask */
|
---|
33 | uint32_t mask;
|
---|
34 | PFNCODECVERBPROCESSOR pfn;
|
---|
35 | } CODECVERB;
|
---|
36 |
|
---|
37 | #define CODECNODE_F0_PARAM_LENGTH 0x14
|
---|
38 | typedef struct CODECCOMMONNODE
|
---|
39 | {
|
---|
40 | uint8_t id; /* 7 - bit format */
|
---|
41 | const char *name;
|
---|
42 | /* RPM 5.3.6 */
|
---|
43 | uint32_t au32F00_param[CODECNODE_F0_PARAM_LENGTH];
|
---|
44 | uint8_t au8F02_param[16];
|
---|
45 | } CODECCOMMONNODE, *PCODECCOMMONNODE;
|
---|
46 |
|
---|
47 | typedef struct ROOTCODECNODE
|
---|
48 | {
|
---|
49 | CODECCOMMONNODE node;
|
---|
50 | }ROOTCODECNODE, *PROOTCODECNODE;
|
---|
51 |
|
---|
52 | #define AMPLIFIER_SIZE 60
|
---|
53 | typedef uint32_t AMPLIFIER[AMPLIFIER_SIZE];
|
---|
54 | #define AMPLIFIER_IN 0
|
---|
55 | #define AMPLIFIER_OUT 1
|
---|
56 | #define AMPLIFIER_LEFT 1
|
---|
57 | #define AMPLIFIER_RIGHT 0
|
---|
58 | #define AMPLIFIER_REGISTER(amp, inout, side, index) ((amp)[30*(inout) + 15*(side) + (index)])
|
---|
59 | typedef struct DACNODE
|
---|
60 | {
|
---|
61 | CODECCOMMONNODE node;
|
---|
62 | uint32_t u32F0d_param;
|
---|
63 | uint32_t u32F04_param;
|
---|
64 | uint32_t u32F05_param;
|
---|
65 | uint32_t u32F06_param;
|
---|
66 | uint32_t u32F0c_param;
|
---|
67 |
|
---|
68 | uint32_t u32A_param;
|
---|
69 | AMPLIFIER B_params;
|
---|
70 |
|
---|
71 | } DACNODE, *PDACNODE;
|
---|
72 |
|
---|
73 | typedef struct ADCNODE
|
---|
74 | {
|
---|
75 | CODECCOMMONNODE node;
|
---|
76 | uint32_t u32F03_param;
|
---|
77 | uint32_t u32F05_param;
|
---|
78 | uint32_t u32F06_param;
|
---|
79 | uint32_t u32F09_param;
|
---|
80 |
|
---|
81 | uint32_t u32A_param;
|
---|
82 | AMPLIFIER B_params;
|
---|
83 | } ADCNODE, *PADCNODE;
|
---|
84 |
|
---|
85 | typedef struct SPDIFOUTNODE
|
---|
86 | {
|
---|
87 | CODECCOMMONNODE node;
|
---|
88 | uint32_t u32F06_param;
|
---|
89 | uint32_t u32F09_param;
|
---|
90 | uint32_t u32F0d_param;
|
---|
91 |
|
---|
92 | uint32_t u32A_param;
|
---|
93 | AMPLIFIER B_params;
|
---|
94 | } SPDIFOUTNODE, *PSPDIFOUTNODE;
|
---|
95 |
|
---|
96 | typedef struct SPDIFINNODE
|
---|
97 | {
|
---|
98 | CODECCOMMONNODE node;
|
---|
99 | uint32_t u32F06_param;
|
---|
100 | uint32_t u32F09_param;
|
---|
101 | uint32_t u32F0d_param;
|
---|
102 |
|
---|
103 | uint32_t u32A_param;
|
---|
104 | AMPLIFIER B_params;
|
---|
105 | } SPDIFINNODE, *PSPDIFINNODE;
|
---|
106 |
|
---|
107 | typedef struct AFGCODECNODE
|
---|
108 | {
|
---|
109 | CODECCOMMONNODE node;
|
---|
110 | uint32_t u32F05_param;
|
---|
111 | uint32_t u32F08_param;
|
---|
112 | uint32_t u32F20_param;
|
---|
113 | } AFGCODECNODE, *PAFGCODECNODE;
|
---|
114 |
|
---|
115 | typedef struct PORTNODE
|
---|
116 | {
|
---|
117 | CODECCOMMONNODE node;
|
---|
118 | uint32_t u32F07_param;
|
---|
119 | uint32_t u32F08_param;
|
---|
120 | uint32_t u32F09_param;
|
---|
121 | uint32_t u32F1c_param;
|
---|
122 | } PORTNODE, *PPORTNODE;
|
---|
123 |
|
---|
124 | typedef struct DIGOUTNODE
|
---|
125 | {
|
---|
126 | CODECCOMMONNODE node;
|
---|
127 | uint32_t u32F01_param;
|
---|
128 | uint32_t u32F07_param;
|
---|
129 | uint32_t u32F09_param;
|
---|
130 | uint32_t u32F1c_param;
|
---|
131 | } DIGOUTNODE, *PDIGOUTNODE;
|
---|
132 |
|
---|
133 | typedef struct DIGINNODE
|
---|
134 | {
|
---|
135 | CODECCOMMONNODE node;
|
---|
136 | uint32_t u32F05_param;
|
---|
137 | uint32_t u32F07_param;
|
---|
138 | uint32_t u32F08_param;
|
---|
139 | uint32_t u32F09_param;
|
---|
140 | uint32_t u32F0c_param;
|
---|
141 | uint32_t u32F1c_param;
|
---|
142 | uint32_t u32F1e_param;
|
---|
143 | } DIGINNODE, *PDIGINNODE;
|
---|
144 |
|
---|
145 | typedef struct ADCMUXNODE
|
---|
146 | {
|
---|
147 | CODECCOMMONNODE node;
|
---|
148 | uint32_t u32F01_param;
|
---|
149 |
|
---|
150 | uint32_t u32A_param;
|
---|
151 | AMPLIFIER B_params;
|
---|
152 | } ADCMUXNODE, *PADCMUXNODE;
|
---|
153 |
|
---|
154 | typedef struct PCBEEPNODE
|
---|
155 | {
|
---|
156 | CODECCOMMONNODE node;
|
---|
157 | uint32_t u32F0a_param;
|
---|
158 |
|
---|
159 | uint32_t u32A_param;
|
---|
160 | AMPLIFIER B_params;
|
---|
161 | } PCBEEPNODE, *PPCBEEPNODE;
|
---|
162 |
|
---|
163 | typedef struct CDNODE
|
---|
164 | {
|
---|
165 | CODECCOMMONNODE node;
|
---|
166 | uint32_t u32F07_param;
|
---|
167 | uint32_t u32F1c_param;
|
---|
168 | } CDNODE, *PCDNODE;
|
---|
169 |
|
---|
170 | typedef struct VOLUMEKNOBNODE
|
---|
171 | {
|
---|
172 | CODECCOMMONNODE node;
|
---|
173 | uint32_t u32F08_param;
|
---|
174 | uint32_t u32F0f_param;
|
---|
175 | } VOLUMEKNOBNODE, *PVOLUMEKNOBNODE;
|
---|
176 |
|
---|
177 | typedef struct ADCVOLNODE
|
---|
178 | {
|
---|
179 | CODECCOMMONNODE node;
|
---|
180 | uint32_t u32F0c_param;
|
---|
181 | uint32_t u32A_params;
|
---|
182 | AMPLIFIER B_params;
|
---|
183 | } ADCVOLNODE, *PADCVOLNODE;
|
---|
184 |
|
---|
185 | typedef union CODECNODE
|
---|
186 | {
|
---|
187 | CODECCOMMONNODE node;
|
---|
188 | ROOTCODECNODE root;
|
---|
189 | AFGCODECNODE afg;
|
---|
190 | DACNODE dac;
|
---|
191 | ADCNODE adc;
|
---|
192 | SPDIFOUTNODE spdifout;
|
---|
193 | SPDIFINNODE spdifin;
|
---|
194 | PORTNODE port;
|
---|
195 | DIGOUTNODE digout;
|
---|
196 | DIGINNODE digin;
|
---|
197 | ADCMUXNODE adcmux;
|
---|
198 | PCBEEPNODE pcbeep;
|
---|
199 | CDNODE cdnode;
|
---|
200 | VOLUMEKNOBNODE volumeKnob;
|
---|
201 | ADCVOLNODE adcvol;
|
---|
202 | } CODECNODE, *PCODECNODE;
|
---|
203 |
|
---|
204 | typedef enum
|
---|
205 | {
|
---|
206 | PI_INDEX = 0, /* PCM in */
|
---|
207 | PO_INDEX, /* PCM out */
|
---|
208 | MC_INDEX, /* Mic in */
|
---|
209 | LAST_INDEX
|
---|
210 | } ENMSOUNDSOURCE;
|
---|
211 |
|
---|
212 | typedef struct CODECState
|
---|
213 | {
|
---|
214 | uint16_t id;
|
---|
215 | CODECVERB *pVerbs;
|
---|
216 | int cVerbs;
|
---|
217 | PCODECNODE pNodes;
|
---|
218 | QEMUSoundCard card;
|
---|
219 | /** PCM in */
|
---|
220 | SWVoiceIn *voice_pi;
|
---|
221 | /** PCM out */
|
---|
222 | SWVoiceOut *voice_po;
|
---|
223 | /** Mic in */
|
---|
224 | SWVoiceIn *voice_mc;
|
---|
225 | void *pHDAState;
|
---|
226 | bool fInReset;
|
---|
227 | DECLR3CALLBACKMEMBER(int, pfnProcess, (struct CODECState *));
|
---|
228 | DECLR3CALLBACKMEMBER(int, pfnLookup, (struct CODECState *pState, uint32_t verb, PPFNCODECVERBPROCESSOR));
|
---|
229 | DECLR3CALLBACKMEMBER(int, pfnReset, (struct CODECState *pState));
|
---|
230 | DECLR3CALLBACKMEMBER(void, pfnTransfer, (struct CODECState *pState, ENMSOUNDSOURCE, int avail));
|
---|
231 | } CODECState;
|
---|
232 |
|
---|
233 | int stac9220Construct(CODECState *pCodecState);
|
---|
234 | int stac9220Destruct(CODECState *pCodecState);
|
---|
235 |
|
---|
236 | #endif
|
---|