UEFIStarter
a simple UEFI framework
|
AC'97 audio functions. More...
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <UEFIStarter/ac97.h>
#include <UEFIStarter/core/memory.h>
#include <UEFIStarter/core/string.h>
#include <UEFIStarter/core/logger.h>
Functions | |
BOOLEAN | validate_volume (cmdline_value_t value) |
validator for "-volume" command-line argument More... | |
BOOLEAN | validate_sample_rate (cmdline_value_t value) |
validator for "-sample-rate" command-line argument More... | |
EFI_PCI_IO_PROTOCOL * | find_ac97_device () |
Gets a PCI device handle for the AC'97 device. More... | |
int | init_buffers (ac97_buffers_s16_t *buffers, UINT64 hardware_address) |
Initializes AC'97 audio buffers. More... | |
EFI_STATUS | write_mixer_reg (ac97_handle_t *handle, UINT32 reg, UINT16 value) |
Writes to an AC'97 mixer register. More... | |
EFI_STATUS | read_mixer_reg (ac97_handle_t *handle, UINT32 reg, UINT16 *value) |
Reads an AC'97 mixer register. More... | |
static UINTN | get_busmaster_register_width (UINT32 reg) |
internal: returns a bus master register's width More... | |
EFI_STATUS | write_busmaster_reg (ac97_handle_t *handle, UINT32 reg, UINTN value) |
Writes to an AC'97 bus master register. More... | |
EFI_STATUS | read_busmaster_reg (ac97_handle_t *handle, UINT32 reg, UINTN *value) |
Reads an AC'97 bus master register. More... | |
EFI_STATUS | set_ac97_cmdline_volume (ac97_handle_t *handle) |
Takes the "volume" and "mute" command-line arguments and configures the AC'97 PCM OUT channel with them. More... | |
EFI_STATUS | set_ac97_cmdline_sample_rate (ac97_handle_t *handle) |
Takes the "sample rate" command-line argument and sets the AC'97 PCM OUT channel's sample rate to that. More... | |
static void | _determine_maximum_master_volume (ac97_handle_t *handle) |
Internal: determines the maximum master volume value. More... | |
void * | init_ac97_handle (ac97_handle_t *handle, EFI_PCI_IO_PROTOCOL *pip) |
Initializes an AC'97 handle. More... | |
void | close_ac97_handle (ac97_handle_t *handle) |
Destroys an AC'97 handle. More... | |
EFI_STATUS | flush_ac97_output (ac97_handle_t *handle) |
Flushes all pending AC'97 memory writes. More... | |
EFI_STATUS | ac97_play (ac97_handle_t *handle) |
Starts AC'97 playback. More... | |
static void | _trace_busmaster_status_register (CHAR16 *name, ac97_busmaster_status_t value) |
internal: dumps a bus master status register's content More... | |
void | ac97_wait_until_last_buffer_sent (ac97_handle_t *handle, UINTN timeout) |
Waits until the AC'97 codec signaled the "last valid buffer completion" event. More... | |
void | print_volume_register (UINT16 *text, UINT16 value) |
Prints a volume register's contents. More... | |
void | print_volume_register_mono (UINT16 *text, UINT16 value) |
Prints a mono volume register's contents. More... | |
void | dump_audio_registers (ac97_handle_t *handle, UINTN flags) |
Prints some of the AC'97 registers. More... | |
Variables | |
cmdline_argument_t | ac97_argument_list [] |
AC'97 command-line argument list. More... | |
cmdline_argument_group_t | ac97_arguments ={ L"Audio options" ,sizeof( ac97_argument_list )/sizeof(cmdline_argument_t), ac97_argument_list } |
command-line argument group for AC'97 | |
static CHAR16 * | AC97_REVISION_IDS [] |
internal: list of AC'97 revision ID strings More... | |
static CHAR16 * | AC97_CODEC_CONFIGURATION_IDS [] |
internal: list of AC'97 code configuration ID string More... | |
AC'97 audio functions.
BOOLEAN validate_volume | ( | cmdline_value_t | value | ) |
validator for "-volume" command-line argument
value | the value to validate |
BOOLEAN validate_sample_rate | ( | cmdline_value_t | value | ) |
validator for "-sample-rate" command-line argument
value | the value to validate |
EFI_PCI_IO_PROTOCOL* find_ac97_device | ( | ) |
Gets a PCI device handle for the AC'97 device.
int init_buffers | ( | ac97_buffers_s16_t * | buffers, |
UINT64 | hardware_address | ||
) |
Initializes AC'97 audio buffers.
buffers | the buffer structure to initialize |
hardware_address | the hardware memory address to write into the descriptor structure |
EFI_STATUS write_mixer_reg | ( | ac97_handle_t * | handle, |
UINT32 | reg, | ||
UINT16 | value | ||
) |
Writes to an AC'97 mixer register.
handle | the AC'97 handle to use |
reg | the register to write to |
value | the value to write |
EFI_STATUS read_mixer_reg | ( | ac97_handle_t * | handle, |
UINT32 | reg, | ||
UINT16 * | value | ||
) |
Reads an AC'97 mixer register.
handle | the AC'97 handle to use |
reg | the register to read from |
value | the output value |
|
inlinestatic |
internal: returns a bus master register's width
reg | the bus master register |
EFI_STATUS write_busmaster_reg | ( | ac97_handle_t * | handle, |
UINT32 | reg, | ||
UINTN | value | ||
) |
Writes to an AC'97 bus master register.
handle | the AC'97 handle to use |
reg | the register to write to |
value | the value to write |
EFI_STATUS read_busmaster_reg | ( | ac97_handle_t * | handle, |
UINT32 | reg, | ||
UINTN * | value | ||
) |
Reads an AC'97 bus master register.
handle | the AC'97 handle to use |
reg | the register to read from |
value | the output value |
EFI_STATUS set_ac97_cmdline_volume | ( | ac97_handle_t * | handle | ) |
Takes the "volume" and "mute" command-line arguments and configures the AC'97 PCM OUT channel with them.
handle | the AC'97 handle to use |
EFI_STATUS set_ac97_cmdline_sample_rate | ( | ac97_handle_t * | handle | ) |
Takes the "sample rate" command-line argument and sets the AC'97 PCM OUT channel's sample rate to that.
Careful, this operation resets the "mute" flag on at least the master output channel, so call this before set_ac97_cmdline_volume().
handle | the AC'97 handle to use |
|
static |
Internal: determines the maximum master volume value.
The master volume register is either 5 or 6 bits wide. If the 6th bit is written to but not supported the first 5 bits will be set to 1 instead.
handle | the AC'97 handle to use and update |
void* init_ac97_handle | ( | ac97_handle_t * | handle, |
EFI_PCI_IO_PROTOCOL * | pip | ||
) |
Initializes an AC'97 handle.
handle | the AC'97 handle to initialize |
pip | the UEFI PCI I/O protocol to use |
void close_ac97_handle | ( | ac97_handle_t * | handle | ) |
Destroys an AC'97 handle.
handle | the AC'97 handle to destroy |
EFI_STATUS flush_ac97_output | ( | ac97_handle_t * | handle | ) |
Flushes all pending AC'97 memory writes.
handle | the AC'97 handle to use |
EFI_STATUS ac97_play | ( | ac97_handle_t * | handle | ) |
Starts AC'97 playback.
handle | the AC'97 handle to use |
|
static |
internal: dumps a bus master status register's content
name | the register's name to display |
value | the register's value |
void ac97_wait_until_last_buffer_sent | ( | ac97_handle_t * | handle, |
UINTN | timeout | ||
) |
Waits until the AC'97 codec signaled the "last valid buffer completion" event.
handle | the AC'97 handle to use |
timeout | the (approximate) number of milliseconds to wait before aborting |
void print_volume_register | ( | UINT16 * | text, |
UINT16 | value | ||
) |
Prints a volume register's contents.
text | the register's name to print |
value | the register's value |
void print_volume_register_mono | ( | UINT16 * | text, |
UINT16 | value | ||
) |
Prints a mono volume register's contents.
text | the register's name to print |
value | the register's value |
void dump_audio_registers | ( | ac97_handle_t * | handle, |
UINTN | flags | ||
) |
Prints some of the AC'97 registers.
handle | the AC'97 handle to use |
flags | which registers to print, see the AC97_DUMP_* flags |
cmdline_argument_t ac97_argument_list[] |
AC'97 command-line argument list.
|
static |
internal: list of AC'97 revision ID strings
|
static |
internal: list of AC'97 code configuration ID string