OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
HdaCodecAudioIo.c File Reference
#include <Guid/AppleVariable.h>
#include "HdaCodec.h"
#include <Protocol/AudioIo.h>
#include <Library/OcMiscLib.h>
#include <Library/PcdLib.h>

Go to the source code of this file.

Functions

VOID EFIAPI HdaCodecHdaIoStreamCallback (IN EFI_HDA_IO_PROTOCOL_TYPE Type, IN VOID *Context1, IN VOID *Context2, IN VOID *Context3)
 
EFI_STATUS EFIAPI HdaCodecAudioIoGetOutputs (IN EFI_AUDIO_IO_PROTOCOL *This, OUT EFI_AUDIO_IO_PROTOCOL_PORT **OutputPorts, OUT UINTN *OutputPortsCount)
 
EFI_STATUS EFIAPI HdaCodecAudioIoRawGainToDecibels (IN EFI_AUDIO_IO_PROTOCOL *This, IN UINT64 OutputIndexMask, IN UINT8 GainParam, OUT INT8 *Gain)
 
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 HdaCodecAudioIoStartPlayback (IN EFI_AUDIO_IO_PROTOCOL *This, IN VOID *Data, IN UINTN DataLength, IN UINTN Position OPTIONAL)
 
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 HdaCodecAudioIoStopPlayback (IN EFI_AUDIO_IO_PROTOCOL *This)
 

Variables

STATIC UINT64 mOutputIndexMask = 0
 
STATIC INT8 mGain = APPLE_SYSTEM_AUDIO_VOLUME_DB_MIN
 
STATIC EFI_AUDIO_IO_PROTOCOL_FREQ mFreq = 0
 
STATIC EFI_AUDIO_IO_PROTOCOL_BITS mBits = 0
 
STATIC UINT8 mChannels = 0xFFU
 

Detailed Description

Copyright (C) 2018-2021, John Davis, Mike Beaton. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause

Definition in file HdaCodecAudioIo.c.

Function Documentation

◆ HdaCodecAudioIoGetOutputs()

EFI_STATUS EFIAPI HdaCodecAudioIoGetOutputs ( IN EFI_AUDIO_IO_PROTOCOL * This,
OUT EFI_AUDIO_IO_PROTOCOL_PORT ** OutputPorts,
OUT UINTN * OutputPortsCount )

Gets the collection of output ports.

Parameters
[in]ThisA pointer to the EFI_AUDIO_IO_PROTOCOL instance.
[out]OutputPortsA pointer to a buffer where the output ports will be placed.
[out]OutputPortsCountThe number of ports in OutputPorts.
Return values
EFI_SUCCESSThe audio data was played successfully.
EFI_INVALID_PARAMETEROne or more parameters are invalid.

Definition at line 59 of file HdaCodecAudioIo.c.

◆ HdaCodecAudioIoRawGainToDecibels()

EFI_STATUS EFIAPI HdaCodecAudioIoRawGainToDecibels ( IN EFI_AUDIO_IO_PROTOCOL * This,
IN UINT64 OutputIndexMask,
IN UINT8 GainParam,
OUT INT8 * Gain )

Convert raw amplifier gain setting to decibel gain value; converts using the parameters of the first channel specified in OutputIndexMask which has non-zero amp capabilities. Note: It seems very typical - though it is certainly not required by the spec - that all amps on a codec which have non-zero amp capabilities, actually all have the same params as each other.

Parameters
[in]ThisA pointer to the EFI_AUDIO_IO_PROTOCOL instance.
[in]OutputIndexMaskA mask indicating the desired outputs.
[in]GainParamThe raw gain parameter for the amplifier.
[out]GainThe amplifier gain (or attentuation if negative) in dB to use, relative to 0 dB level (0 dB is usually at at or near max available volume, but is not required to be so in the spec).
Return values
EFI_SUCCESSThe gain value was calculated successfully.
EFI_INVALID_PARAMETEROne or more parameters are invalid.

Definition at line 270 of file HdaCodecAudioIo.c.

◆ HdaCodecAudioIoSetupPlayback()

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 )

Sets up the device to play audio data. Basic caching is implemented: no actions are taken the second and subsequent times that set up is called again with exactly the same paremeters.

Parameters
[in]ThisA pointer to the EFI_AUDIO_IO_PROTOCOL instance.
[in]OutputIndexMaskA mask indicating the desired outputs.
[in]GainThe amplifier gain (or attentuation if negative) in dB to use, relative to 0 dB level (0 dB is usually at at or near max available volume, but is not required to be so in the spec).
[in]BitsThe width in bits of the source data.
[in]FreqThe frequency of the source data.
[in]ChannelsThe number of channels the source data contains.
[in]PlaybackDelayThe required delay before playback after a change in setup.
Return values
EFI_SUCCESSThe audio data was played successfully.
EFI_INVALID_PARAMETEROne or more parameters are invalid.

< TODO: Why does Clover has TRUE here?

< TODO: Why does Clover has TRUE here?

< Enable all available pins

Definition at line 327 of file HdaCodecAudioIo.c.

◆ HdaCodecAudioIoStartPlayback()

EFI_STATUS EFIAPI HdaCodecAudioIoStartPlayback ( IN EFI_AUDIO_IO_PROTOCOL * This,
IN VOID * Data,
IN UINTN DataLength,
IN UINTN Position OPTIONAL )

Begins playback on the device and waits for playback to complete.

Parameters
[in]ThisA pointer to the EFI_AUDIO_IO_PROTOCOL instance.
[in]DataA pointer to the buffer containing the audio data to play.
[in]DataLengthThe size, in bytes, of the data buffer specified by Data.
[in]PositionThe position in the buffer to start at.
Return values
EFI_SUCCESSThe audio data was played successfully.
EFI_INVALID_PARAMETEROne or more parameters are invalid.

Definition at line 764 of file HdaCodecAudioIo.c.

◆ HdaCodecAudioIoStartPlaybackAsync()

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 )

Begins playback on the device asynchronously.

Parameters
[in]ThisA pointer to the EFI_AUDIO_IO_PROTOCOL instance.
[in]DataA pointer to the buffer containing the audio data to play.
[in]DataLengthThe size, in bytes, of the data buffer specified by Data.
[in]PositionThe position in the buffer to start at.
[in]CallbackA pointer to an optional callback to be invoked when playback is complete.
[in]ContextA pointer to data to be passed to the callback function.
Return values
EFI_SUCCESSThe audio data was played successfully.
EFI_INVALID_PARAMETEROne or more parameters are invalid.

Definition at line 840 of file HdaCodecAudioIo.c.

◆ HdaCodecAudioIoStopPlayback()

EFI_STATUS EFIAPI HdaCodecAudioIoStopPlayback ( IN EFI_AUDIO_IO_PROTOCOL * This)

Stops playback on the device.

Parameters
[in]ThisA pointer to the EFI_AUDIO_IO_PROTOCOL instance.
Return values
EFI_SUCCESSThe audio data was played successfully.
EFI_INVALID_PARAMETEROne or more parameters are invalid.

Definition at line 890 of file HdaCodecAudioIo.c.

◆ HdaCodecHdaIoStreamCallback()

VOID EFIAPI HdaCodecHdaIoStreamCallback ( IN EFI_HDA_IO_PROTOCOL_TYPE Type,
IN VOID * Context1,
IN VOID * Context2,
IN VOID * Context3 )

Definition at line 25 of file HdaCodecAudioIo.c.

Variable Documentation

◆ mBits

STATIC EFI_AUDIO_IO_PROTOCOL_BITS mBits = 0

Definition at line 19 of file HdaCodecAudioIo.c.

◆ mChannels

STATIC UINT8 mChannels = 0xFFU

Definition at line 20 of file HdaCodecAudioIo.c.

◆ mFreq

STATIC EFI_AUDIO_IO_PROTOCOL_FREQ mFreq = 0

Definition at line 18 of file HdaCodecAudioIo.c.

◆ mGain

STATIC INT8 mGain = APPLE_SYSTEM_AUDIO_VOLUME_DB_MIN

Definition at line 17 of file HdaCodecAudioIo.c.

◆ mOutputIndexMask

STATIC UINT64 mOutputIndexMask = 0

Definition at line 16 of file HdaCodecAudioIo.c.