Google is committed to advancing racial equity for Black communities. See how.

fuchsia.hardware.audio

PROTOCOLS

Device

Defined in fuchsia.hardware.audio/audio.fidl

GetChannel

This method obtains a channel in order to serve FIDL over it outside the devhost's control.

Request

NameType

Response

NameType
channel StreamConfig

RingBuffer

Defined in fuchsia.hardware.audio/ring_buffer.fidl

GetProperties

Accessor for top level static properties.

Request

NameType

Response

NameType
properties RingBufferProperties

GetVmo

Requests a shared buffer to be used for moving bulk audio data. Requests the buffer size to fit at least min_frames, and returns the actual num_frames allocated in ring_buffer.

If clock_recovery_notifications_per_ring is non-zero, the driver will send replies to WatchClockRecoveryPositionInfo client requests at most at clock_recovery_notifications_per_ring frequency. These notifications are meant to be used for clock recovery.

Request

NameType
min_frames uint32
clock_recovery_notifications_per_ring uint32

Response

NameType
result RingBuffer_GetVmo_Result

Start

Start the ring buffer.

Request

NameType

Response

NameType
start_time zx/time

Stop

Stop the ring buffer. Once this call's response is received, no further position notifications will be sent until Start() is called again. TODO(39494): Add timestamp parameter.

Request

NameType

Response

NameType

WatchClockRecoveryPositionInfo

Gets the ring buffer current position via a hanging get. The driver must immediately respond to a client's first WatchClockRecoveryPositionInfo call, but will not respond to subsequent client calls until the position information has changed from what was most recently provided to that client. If clock_recovery_notifications_per_ring is not zero, the driver will reply with its estimated position to be used for clock recovery at most at clock_recovery_notifications_per_ring frequency. Must be delivered with timestamps that are monotonically increasing.

Request

NameType

Response

NameType
position_info RingBufferPositionInfo

StreamConfig

Defined in fuchsia.hardware.audio/stream.fidl

CreateRingBuffer

CreateRingBuffer is sent by clients to select a stream format based on information that the driver provides in GetSupportedFormats what is supported by the client, and any other requirement. The ring_buffer channel is used to control the audio buffer, if a previous ring buffer channel had been established and was still active, the driver must close that (ring buffer) channel and make every attempt to gracefully quiesce any on-going streaming operations in the process.

Request

NameType
format Format
ring_buffer request<RingBuffer>

GetProperties

Retrieves top level static properties.

Request

NameType

Response

NameType
properties StreamProperties

GetSupportedFormats

Gets formats supported by a given driver. When not all combinations supported by the driver can be described with one SupportedFormats, the driver returns more than one SupportedFormats in the returned vector. For example, if one SupportedFormats allows for 32 bits samples at 48KHz, and 16 bits samples at 96KHz, but not 32 bits samples at 96KHz, then the driver replies with 2 SupportedFormats: <<32bits>,<48KHz>> and <<16bits>,<96KHz>>. For simplicity, this example ignores parameters other than rate and bits per sample. In the case where the driver supports either 16 or 32 bits samples at either 48 or 96KHz, the driver would reply with 1 SupportedFormats: <<16bits,32bits>,<48KHz,96KHz>>.

Request

NameType

Response

NameType
supported_formats vector<SupportedFormats>[64]

SetGain

Client update of the gain state.

Request

NameType
target_state GainState

WatchGainState

Get the gain state via a hanging get. The driver will reply to the first WatchGainState sent by the client. The driver will not respond to subsequent client WatchGainState calls until the gain state changes from what was most recently reported.

Request

NameType

Response

NameType
gain_state GainState

WatchPlugState

Get the plug detect state via a hanging get. The driver will reply to the first WatchPlugState sent by the client. The driver will not respond to subsequent client WatchPlugState calls until the plug state changes from what was most recently reported.

Request

NameType

Response

NameType
plug_state PlugState

STRUCTS

PcmFormat

Defined in fuchsia.hardware.audio/stream.fidl

Format supporting non-compressed PCM audio. Frames are made up of number_of_channels samples which have valid_bits_per_sample bits of left-justified data within bytes_per_channel. bytes. For more detailed information see //zircon/driver_interfaces/audio_streaming.md.

NameTypeDescriptionDefault
number_of_channels uint8

Number of channels.

No default
channels_to_use_bitmask uint64

Which channels to use as a bitmask. Channels not set in the bitmask are ignored. The least significant bit corresponds to index 0.

No default
sample_format SampleFormat

The format of all samples.

No default
bytes_per_sample uint8

Bytes allocated to hold a sample, equal or bigger than the valid sample size in valid_bits_per_sample.

No default
valid_bits_per_sample uint8

Number of valid bits in a sample, must be equal or smaller than bits in bytes_per_sample. If smaller, bits are left justified, and any additional bits must be ignored by the receiver.

No default
frame_rate uint32

The frame rate for all samples.

No default

PcmSupportedFormats

Defined in fuchsia.hardware.audio/stream.fidl

Format supporting non-compressed PCM audio. Frames are made up of number_of_channels samples which have valid_bits_per_sample bits of left-justified data within bytes_per_sample bytes. All values listed in each vector are supported. When not all combinations supported by the driver can be described with one SupportedFormats (and hence one PcmSupportedFormats), GetSupportedFormats returns more than one SupportedFormats in the returned vector. For more detailed information see //zircon/driver_interfaces/audio_streaming.md.

NameTypeDescriptionDefault
number_of_channels vector<uint8>[64]

Vector of possible number of channels supported in ascending order.

No default
sample_formats vector<SampleFormat>[3]

Vector of possible SampleFormats supported.

No default
bytes_per_sample vector<uint8>[8]

Vector of possible number of bits allocated to hold a sample, equal or bigger than the actual sample size in valid_bits_per_sample in ascending order.

No default
valid_bits_per_sample vector<uint8>[8]

Vector of possible number of bits in a sample in ascending order, must be equal or smaller than bytes_per_channel for samples to fit. If smaller, bits are left justified, and any additional bits will be ignored.

No default
frame_rates vector<uint32>[64]

Vector of possible frame rates supported in ascending order.

No default

RingBufferPositionInfo

Defined in fuchsia.hardware.audio/ring_buffer.fidl

NameTypeDescriptionDefault
timestamp zx/time

The driver's best estimate of the time at which the playback/capture pointer reached the position indicated by position.

No default
position uint32

The playback/capture pointer position (in bytes) in the ring buffer at time timestamp as estimated by the driver.

No default

RingBuffer_GetVmo_Response

Defined in fuchsia.hardware.audio/ring_buffer.fidl

NameTypeDescriptionDefault
num_frames uint32 No default
ring_buffer handle<vmo> No default

ENUMS

GetVmoError

Type: uint32

Defined in fuchsia.hardware.audio/ring_buffer.fidl

NameValueDescription
INVALID_ARGS 1

The ring buffer setup failed due to an invalid argument, e.g. min_frames is too big.

INTERNAL_ERROR 2

The ring buffer setup failed due to an internal error.

PlugDetectCapabilities

Type: uint32

Defined in fuchsia.hardware.audio/stream.fidl

NameValueDescription
HARDWIRED 0

Stream is hardwired (will always be plugged in).

CAN_ASYNC_NOTIFY 1

Stream is able to asynchronously notify of plug state changes.

SampleFormat

Type: uint8

Defined in fuchsia.hardware.audio/stream.fidl

NameValueDescription
PCM_SIGNED 1

Signed Linear Pulse Code Modulation samples at the host endianness.

PCM_UNSIGNED 2

Unsigned Linear Pulse Code Modulation samples at the host endianness.

PCM_FLOAT 3

Floating point samples IEEE-754 encoded.

TABLES

Format

Defined in fuchsia.hardware.audio/stream.fidl

OrdinalNameTypeDescription
1 pcm_format PcmFormat

Format supporting non-compressed PCM samples.

GainState

Defined in fuchsia.hardware.audio/stream.fidl

Gain state requested by the client or returned a current by the driver.

OrdinalNameTypeDescription
1 muted bool

Current mute state. If not included, the state is unmuted.

2 agc_enabled bool

Current Automatic Gain Control (AGC) state. If not included, AGC is disabled.

3 gain_db float32

Current gain in decibels. Must be included.

PlugState

Defined in fuchsia.hardware.audio/stream.fidl

Plug state as returned by the driver.

OrdinalNameTypeDescription
1 plugged bool

Stream is currently plugged in. Must be included.

2 plug_state_time zx/time

Timestamps the information provided in the rest of the fields of this struct. Must be included.

RingBufferProperties

Defined in fuchsia.hardware.audio/ring_buffer.fidl

OrdinalNameTypeDescription
1 external_delay zx/duration

The driver's best estimate of the external delay (in nanoseconds) present in the presentation pipeline for the chosen format. When precisely synchronizing presentation across multiple entities (e.g. devices), the external delay should be taken into account.

2 fifo_depth uint32

Size (in bytes) representing a temporary buffer used by the driver in order to consume or generate the ring buffer contents. The ring buffer contents must be produced and consumed at the rate specified with the CreateRingBuffer command, however some amount of buffering is required when the data is written into and read from the ring buffer. For playback the data is consumed by the driver by reading ahead up to fifo_depth bytes. For capture the data is produced by the driver holding up to fifo_depth bytes at the time before committing it to main system memory. Hence fifo_depth must be taken into account by the client when determining either the minimum lead time requirement (for playback) or the maximum capture delay (for capture).

To convert fifo_depth to the corresponding number of audio frames, use the frame size returned by CreateRingBuffer in the StreamConfig protocol, note that the fifo_depth is not necessarily a multiple size of an audio frame.

The ring buffer data may be directly consumed/generated by hardware, in this case fifo_depth maps directly to the size of a hardware FIFO block, since the hardware FIFO block determines the amount of data read ahead or held back.

The ring buffer data may instead be consumed/generated by audio driver software that is conceptually situated between the ring buffer and the audio hardware. In this case, for playback the fifo_depth read ahead amount is set large enough such that the driver guarantees no undetected underruns, this assuming the client is generating the data as determined by the CreateRingBuffer and Start commands. For capture, the fifo_depth held back amount is set large enough such that the driver guarantees no undetected underruns when generating the data as determined by the CreateRingBuffer and Start commands. The driver must set fifo_depth big enough such that the potential delays added by any software interfacing with the audio hardware do not occur under most scenarios, and must detect and report underruns. How an underrun is reported is not defined in this API.

3 needs_cache_flush_or_invalidate bool

When set to true, indicates that clients need to make sure that their data has been flushed all the way to physical memory (in the case of playback) or that their view of the ring buffer will need to be invalidated before read (in the case of capture).

StreamProperties

Defined in fuchsia.hardware.audio/stream.fidl

OrdinalNameTypeDescription
1 unique_id uint8[16]

A unique identifier. If not included, there is no unique id for the StreamConfig.

2 is_input bool

Stream type is input or output. Must be included.

3 can_mute bool

Gain mute capability. If not included, the StreamConfig can't mute.

4 can_agc bool

Automatic Gain Control (AGC) capability. If not included, the StreamConfig can't AGC.

5 min_gain_db float32

Minimum gain in decibels. Must be included.

6 max_gain_db float32

Maximum gain in decibels. Must be included.

7 gain_step_db float32

Gain step in decibels, this value must not be negative, but may be zero to convey an effectively continuous range of values. Must not exceed max_gain_db - min_gain_db. Must be included.

8 plug_detect_capabilities PlugDetectCapabilities

Plug Detect Capabilities. Must be included.

9 manufacturer string[256]

UI string for the manufacturer name. If not included, the manufacturer is unspecified.

10 product string[256]

UI string for the product name. If not included, the product name is unspecified.

11 clock_domain clock_domain

An identifier for the clock domain in which this hardware operates. If the hardware is operating in CLOCK_DOMAIN_MONOTONIC, its nominal rate is locked to that of the ZX_CLOCK_MONOTONIC time reference. Given the start time, and a nominal rate, the position of the playback/capture pointer may always be calculated using a clock monotonic timestamp as the pointer's movement is locked to that of ZX_CLOCK_MONOTONIC.

Other values indicate that playback/capture is not locked to ZX_CLOCK_MONOTONIC, and moves at its own rate depending on a number of factors. Client will need to make use of the timing information present in the position notification updates in order to recover the clock of the audio stream. The clock_domain comes from an system wide entity (or instance a platform bus or clock tree/global driver). Audio drivers retrieve clock_domain from such system wide entity. Must be included.

SupportedFormats

Defined in fuchsia.hardware.audio/stream.fidl

OrdinalNameTypeDescription
1 pcm_supported_formats PcmSupportedFormats

Supported formats for non-compressed PCM samples.

UNIONS

RingBuffer_GetVmo_Result

Defined in fuchsia.hardware.audio/ring_buffer.fidl

NameTypeDescription
response RingBuffer_GetVmo_Response
err GetVmoError

CONSTANTS

NameValueTypeDescription
CLOCK_DOMAIN_EXTERNAL 4294967295 uint32
CLOCK_DOMAIN_MONOTONIC 0 uint32
MAX_COUNT_CHANNELS_TO_USE 64 uint32
MAX_COUNT_FORMATS 64 uint32
MAX_COUNT_SUPPORTED_BYTES_PER_SAMPLE 8 uint32
MAX_COUNT_SUPPORTED_NUMBER_OF_CHANNELS 64 uint32
MAX_COUNT_SUPPORTED_RATES 64 uint32
MAX_COUNT_SUPPORTED_SAMPLE_FORMATS 3 uint32
MAX_COUNT_SUPPORTED_VALID_BITS_PER_SAMPLE 8 uint32
MAX_UI_STRING_SIZE 256 uint32
UNIQUE_ID_SIZE 16 uint32

TYPE ALIASES

NameValueDescription
clock_domain uint32