OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
HdaCodec.h
Go to the documentation of this file.
1/*
2 * File: HdaCodec.h
3 *
4 * Copyright (c) 2018 John Davis
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#ifndef _EFI_HDA_CODEC_H_
26#define _EFI_HDA_CODEC_H_
27
28#include "AudioDxe.h"
29
35#define HDA_CODEC_PRIVATE_DATA_SIGNATURE SIGNATURE_32('H','D','C','O')
36
84
103
105 // Signature.
107
108 // Protocols.
110 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
112
113 // Published protocols.
116
117 // Codec information.
118 UINT32 VendorId;
120 CHAR16 *Name;
121
125
126 // Output and input ports.
131};
132
133// HDA Codec Info private data.
135 // Signature.
137
138 // HDA Codec Info protocol and codec device.
141};
142
143#define HDA_CODEC_INFO_PRIVATE_DATA_FROM_THIS(This) CR(This, HDA_CODEC_INFO_PRIVATE_DATA, HdaCodecInfo, HDA_CODEC_PRIVATE_DATA_SIGNATURE)
144
145// Audio I/O private data.
147 // Signature.
149
150 // Audio I/O protocol.
154
155 // Codec device.
157};
158
159#define AUDIO_IO_PRIVATE_DATA_FROM_THIS(This) CR(This, AUDIO_IO_PRIVATE_DATA, AudioIo, HDA_CODEC_PRIVATE_DATA_SIGNATURE)
160
161//
162// HDA Codec Info protocol functions.
163//
164EFI_STATUS
165EFIAPI
168 OUT UINT8 *Address
169 );
170
171EFI_STATUS
172EFIAPI
175 OUT CONST CHAR16 **CodecName
176 );
177
178EFI_STATUS
179EFIAPI
182 OUT UINT32 *VendorId
183 );
184
185EFI_STATUS
186EFIAPI
189 OUT UINT32 *RevisionId
190 );
191
192EFI_STATUS
193EFIAPI
196 OUT UINT8 *AudioFuncId,
197 OUT BOOLEAN *UnsolCapable
198 );
199
200EFI_STATUS
201EFIAPI
204 OUT UINT32 *Rates,
205 OUT UINT32 *Formats
206 );
207
208EFI_STATUS
209EFIAPI
212 OUT UINT32 *AmpInCaps,
213 OUT UINT32 *AmpOutCaps
214 );
215
216EFI_STATUS
217EFIAPI
220 OUT HDA_WIDGET **Widgets,
221 OUT UINTN *WidgetCount
222 );
223
224EFI_STATUS
225EFIAPI
227 IN HDA_WIDGET *Widgets,
228 IN UINTN WidgetCount
229 );
230
231//
232// Audio I/O protocol functions.
233//
234EFI_STATUS
235EFIAPI
237 IN EFI_AUDIO_IO_PROTOCOL *This,
238 OUT EFI_AUDIO_IO_PROTOCOL_PORT **OutputPorts,
239 OUT UINTN *OutputPortsCount
240 );
241
242EFI_STATUS
243EFIAPI
245 IN EFI_AUDIO_IO_PROTOCOL *This,
246 IN UINT64 OutputIndexMask,
247 IN UINT8 GainParam,
248 OUT INT8 *Gain
249 );
250
251EFI_STATUS
252EFIAPI
254 IN EFI_AUDIO_IO_PROTOCOL *This,
255 IN UINT64 OutputIndexMask,
256 IN INT8 Gain,
259 IN UINT8 Channels,
260 IN UINTN PlaybackDelay
261 );
262
263EFI_STATUS
264EFIAPI
266 IN EFI_AUDIO_IO_PROTOCOL *This,
267 IN VOID *Data,
268 IN UINTN DataLength,
269 IN UINTN Position OPTIONAL
270 );
271
272EFI_STATUS
273EFIAPI
275 IN EFI_AUDIO_IO_PROTOCOL *This,
276 IN VOID *Data,
277 IN UINTN DataLength,
278 IN UINTN Position OPTIONAL,
279 IN EFI_AUDIO_IO_CALLBACK Callback OPTIONAL,
280 IN VOID *Context OPTIONAL
281 );
282
283EFI_STATUS
284EFIAPI
286 IN EFI_AUDIO_IO_PROTOCOL *This
287 );
288
289//
290// HDA Codec internal functions.
291//
292EFI_STATUS
293EFIAPI
295 HDA_CODEC_DEV *HdaCodecDev
296 );
297
298EFI_STATUS
299EFIAPI
301 IN HDA_WIDGET_DEV *HdaWidget,
302 OUT HDA_WIDGET_DEV **HdaOutputWidget
303 );
304
305EFI_STATUS
306EFIAPI
308 IN HDA_WIDGET_DEV *HdaPinWidget,
309 OUT UINT32 *SupportedRates
310 );
311
312EFI_STATUS
313EFIAPI
315 IN HDA_WIDGET_DEV *HdaWidget
316 );
317
318EFI_STATUS
319EFIAPI
321 IN HDA_WIDGET_DEV *HdaWidget,
322 IN UINT8 GainParam,
323 OUT INT8 *Gain
324 );
325
326EFI_STATUS
327EFIAPI
329 IN HDA_WIDGET_DEV *HdaWidget,
330 IN INT8 Gain,
331 IN UINT8 StreamId,
332 IN UINT16 StreamFormat
333 );
334
335VOID
336EFIAPI
338 IN HDA_CODEC_DEV *HdaCodecDev
339 );
340
341//
342// Driver Binding protocol functions.
343//
344EFI_STATUS
345EFIAPI
347 IN EFI_DRIVER_BINDING_PROTOCOL *This,
348 IN EFI_HANDLE ControllerHandle,
349 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
350 );
351
352EFI_STATUS
353EFIAPI
355 IN EFI_DRIVER_BINDING_PROTOCOL *This,
356 IN EFI_HANDLE ControllerHandle,
357 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
358 );
359
360EFI_STATUS
361EFIAPI
363 IN EFI_DRIVER_BINDING_PROTOCOL *This,
364 IN EFI_HANDLE ControllerHandle,
365 IN UINTN NumberOfChildren,
366 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
367 );
368
369// GPIO setup stages.
370#define GPIO_SETUP_STAGE_DATA BIT0
371#define GPIO_SETUP_STAGE_DIRECTION BIT1
372#define GPIO_SETUP_STAGE_ENABLE BIT2
373
374#define GPIO_SETUP_STAGE_NONE 0
375
376#define GPIO_SETUP_STAGE_ALL ( \
377 GPIO_SETUP_STAGE_DATA | \
378 GPIO_SETUP_STAGE_DIRECTION | \
379 GPIO_SETUP_STAGE_ENABLE \
380 )
381
382// GPIO setup pin mask.
383#define GPIO_PIN_MASK_AUTO 0
384
385//
386// Setup stage mask.
387//
388extern
389UINTN
391
392//
393// GPIO pin mask.
394//
395extern
396UINTN
398
399//
400// Time to wait in microseconds per codec for all widgets to fully come on.
401//
402extern
403UINTN
405
406//
407// Whether to use forced codec.
408//
409extern BOOLEAN
411
412//
413// Forced codec number.
414//
415extern UINTN
417
418//
419// Whether to attempt to output on CONN_NONE nodes.
420//
421extern BOOLEAN
423
424#endif
EFI_AUDIO_IO_PROTOCOL_FREQ
Definition AudioIo.h:104
VOID(EFIAPI * EFI_AUDIO_IO_CALLBACK)(IN EFI_AUDIO_IO_PROTOCOL *AudioIo, IN VOID *Context)
Definition AudioIo.h:140
EFI_AUDIO_IO_PROTOCOL_BITS
Definition AudioIo.h:93
UINTN gForcedCodec
Definition HdaCodec.c:46
EFI_STATUS EFIAPI HdaCodecGetSupportedPcmRates(IN HDA_WIDGET_DEV *HdaPinWidget, OUT UINT32 *SupportedRates)
Definition HdaCodec.c:1183
EFI_STATUS EFIAPI HdaCodecAudioIoSetupPlayback(IN EFI_AUDIO_IO_PROTOCOL *This, IN UINT64 OutputIndexMask, IN INT8 Gain, IN EFI_AUDIO_IO_PROTOCOL_FREQ Freq, IN EFI_AUDIO_IO_PROTOCOL_BITS Bits, IN UINT8 Channels, IN UINTN PlaybackDelay)
EFI_STATUS EFIAPI HdaCodecInfoGetCodecName(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT CONST CHAR16 **CodecName)
EFI_STATUS EFIAPI HdaCodecPrintDefaults(HDA_CODEC_DEV *HdaCodecDev)
EFI_STATUS EFIAPI HdaCodecInfoGetWidgets(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT HDA_WIDGET **Widgets, OUT UINTN *WidgetCount)
UINTN gCodecSetupDelay
Definition HdaCodec.c:40
VOID EFIAPI HdaCodecCleanup(IN HDA_CODEC_DEV *HdaCodecDev)
Definition HdaCodec.c:1612
EFI_STATUS EFIAPI HdaCodecAudioIoStartPlaybackAsync(IN EFI_AUDIO_IO_PROTOCOL *This, IN VOID *Data, IN UINTN DataLength, IN UINTN Position OPTIONAL, IN EFI_AUDIO_IO_CALLBACK Callback OPTIONAL, IN VOID *Context OPTIONAL)
EFI_STATUS EFIAPI HdaCodecInfoGetAudioFuncId(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT UINT8 *AudioFuncId, OUT BOOLEAN *UnsolCapable)
BOOLEAN gCodecUseConnNoneNode
Definition HdaCodec.c:49
EFI_STATUS EFIAPI HdaCodecDisableWidgetPath(IN HDA_WIDGET_DEV *HdaWidget)
Definition HdaCodec.c:1228
EFI_STATUS EFIAPI HdaCodecGetOutputDac(IN HDA_WIDGET_DEV *HdaWidget, OUT HDA_WIDGET_DEV **HdaOutputWidget)
Definition HdaCodec.c:1153
EFI_STATUS EFIAPI HdaCodecEnableWidgetPath(IN HDA_WIDGET_DEV *HdaWidget, IN INT8 Gain, IN UINT8 StreamId, IN UINT16 StreamFormat)
Definition HdaCodec.c:1344
EFI_STATUS EFIAPI HdaCodecAudioIoStartPlayback(IN EFI_AUDIO_IO_PROTOCOL *This, IN VOID *Data, IN UINTN DataLength, IN UINTN Position OPTIONAL)
EFI_STATUS EFIAPI HdaCodecInfoGetRevisionId(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT UINT32 *RevisionId)
EFI_STATUS EFIAPI HdaCodecDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
Definition HdaCodec.c:1717
EFI_STATUS EFIAPI HdaCodecInfoFreeWidgetsBuffer(IN HDA_WIDGET *Widgets, IN UINTN WidgetCount)
EFI_STATUS EFIAPI HdaCodecDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
Definition HdaCodec.c:1765
UINTN gGpioSetupStageMask
Definition HdaCodec.c:34
EFI_STATUS EFIAPI HdaCodecInfoGetVendorId(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT UINT32 *VendorId)
EFI_STATUS EFIAPI HdaCodecAudioIoGetOutputs(IN EFI_AUDIO_IO_PROTOCOL *This, OUT EFI_AUDIO_IO_PROTOCOL_PORT **OutputPorts, OUT UINTN *OutputPortsCount)
EFI_STATUS EFIAPI HdaCodecWidgetRawGainToDecibels(IN HDA_WIDGET_DEV *HdaWidget, IN UINT8 GainParam, OUT INT8 *Gain)
Definition HdaCodec.c:1288
UINTN gGpioPinMask
Definition HdaCodec.c:37
BOOLEAN gUseForcedCodec
Definition HdaCodec.c:43
EFI_STATUS EFIAPI HdaCodecDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
Definition HdaCodec.c:1854
EFI_STATUS EFIAPI HdaCodecInfoGetAddress(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT UINT8 *Address)
EFI_STATUS EFIAPI HdaCodecInfoGetDefaultRatesFormats(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT UINT32 *Rates, OUT UINT32 *Formats)
EFI_STATUS EFIAPI HdaCodecInfoGetDefaultAmpCaps(IN EFI_HDA_CODEC_INFO_PROTOCOL *This, OUT UINT32 *AmpInCaps, OUT UINT32 *AmpOutCaps)
EFI_STATUS EFIAPI HdaCodecAudioIoRawGainToDecibels(IN EFI_AUDIO_IO_PROTOCOL *This, IN UINT64 OutputIndexMask, IN UINT8 GainParam, OUT INT8 *Gain)
EFI_STATUS EFIAPI HdaCodecAudioIoStopPlayback(IN EFI_AUDIO_IO_PROTOCOL *This)
#define Freq
Definition deflate.h:79
UINT64 SelectedOutputIndexMask
Definition HdaCodec.h:152
HDA_CODEC_DEV * HdaCodecDev
Definition HdaCodec.h:156
EFI_AUDIO_IO_PROTOCOL AudioIo
Definition HdaCodec.h:151
UINTN FuncGroupsCount
Definition HdaCodec.h:123
HDA_FUNC_GROUP * FuncGroups
Definition HdaCodec.h:122
UINTN Signature
Definition HdaCodec.h:106
AUDIO_IO_PRIVATE_DATA * AudioIoData
Definition HdaCodec.h:115
EFI_HANDLE ControllerHandle
Definition HdaCodec.h:111
UINTN InputPortsCount
Definition HdaCodec.h:130
HDA_WIDGET_DEV ** OutputPorts
Definition HdaCodec.h:127
EFI_HDA_IO_PROTOCOL * HdaIo
Definition HdaCodec.h:109
UINT32 RevisionId
Definition HdaCodec.h:119
UINT32 VendorId
Definition HdaCodec.h:118
HDA_FUNC_GROUP * AudioFuncGroup
Definition HdaCodec.h:124
EFI_DEVICE_PATH_PROTOCOL * DevicePath
Definition HdaCodec.h:110
UINTN OutputPortsCount
Definition HdaCodec.h:129
CHAR16 * Name
Definition HdaCodec.h:120
HDA_CODEC_INFO_PRIVATE_DATA * HdaCodecInfoData
Definition HdaCodec.h:114
HDA_WIDGET_DEV ** InputPorts
Definition HdaCodec.h:128
HDA_CODEC_DEV * HdaCodecDev
Definition HdaCodec.h:140
EFI_HDA_CODEC_INFO_PROTOCOL HdaCodecInfo
Definition HdaCodec.h:139
UINT32 AmpOutCapabilities
Definition HdaCodec.h:96
UINT32 SupportedPowerStates
Definition HdaCodec.h:97
UINT8 WidgetsCount
Definition HdaCodec.h:101
HDA_WIDGET_DEV * Widgets
Definition HdaCodec.h:100
UINT32 SupportedFormats
Definition HdaCodec.h:94
UINT32 SupportedPcmRates
Definition HdaCodec.h:93
UINT32 GpioCapabilities
Definition HdaCodec.h:98
UINT32 Capabilities
Definition HdaCodec.h:92
UINT32 AmpInCapabilities
Definition HdaCodec.h:95
HDA_CODEC_DEV * HdaCodecDev
Definition HdaCodec.h:86
BOOLEAN UnsolCapable
Definition HdaCodec.h:88
UINT8 DefaultConvChannelCount
Definition HdaCodec.h:72
UINT8 UpstreamIndex
Definition HdaCodec.h:52
UINT8 * AmpInRightDefaultGainMute
Definition HdaCodec.h:63
UINT8 DefaultVolume
Definition HdaCodec.h:82
UINT32 DefaultPowerState
Definition HdaCodec.h:56
UINT32 AmpOutCapabilities
Definition HdaCodec.h:61
UINT8 AmpOutLeftDefaultGainMute
Definition HdaCodec.h:64
UINT8 DefaultConvStreamChannel
Definition HdaCodec.h:71
UINT32 ConnectionCount
Definition HdaCodec.h:50
HDA_WIDGET_DEV * UpstreamWidget
Definition HdaCodec.h:51
HDA_FUNC_GROUP * FuncGroup
Definition HdaCodec.h:38
UINT32 DefaultConfiguration
Definition HdaCodec.h:78
UINT8 AmpOutRightDefaultGainMute
Definition HdaCodec.h:65
UINT16 * Connections
Definition HdaCodec.h:48
UINT32 ConnectionListLength
Definition HdaCodec.h:47
HDA_WIDGET_DEV ** WidgetConnections
Definition HdaCodec.h:49
UINT32 VolumeCapabilities
Definition HdaCodec.h:81
UINT8 * AmpInLeftDefaultGainMute
Definition HdaCodec.h:62
UINT8 DefaultUnSol
Definition HdaCodec.h:44
UINT32 SupportedPowerStates
Definition HdaCodec.h:55
UINT32 AmpInCapabilities
Definition HdaCodec.h:60
UINT16 DefaultConvFormat
Definition HdaCodec.h:70
BOOLEAN AmpOverride
Definition HdaCodec.h:59
UINT8 DefaultEapd
Definition HdaCodec.h:76
UINT32 SupportedFormats
Definition HdaCodec.h:69
UINT32 PinCapabilities
Definition HdaCodec.h:75
UINT8 DefaultPinControl
Definition HdaCodec.h:77
UINT32 Capabilities
Definition HdaCodec.h:43
UINT32 SupportedPcmRates
Definition HdaCodec.h:68