audio-codec-ctl

Audio hardware codec driver control. Used to control and get information from an audio hardware codec driver via the FIDL codec interface. See audio-driver-ctl to play, record, and configure audio streams.

Usage

  audio-codec-ctl [-d|--device <device>] f[ormats]

  audio-codec-ctl [-d|--device <device>] r[eset]

  audio-codec-ctl [-d|--device <device>] d[ai] <number_of_channels>
    <channels_to_use_bitmask> pdm|upcm|spcm|fpcm none|i2s|left-stereo|right-stereo|1tdm|2tdm|3tdm
    <frame_rate> <bits_per_slot> <bits_per_sample>

  audio-codec-ctl [-d|--device <device>] start

  audio-codec-ctl [-d|--device <device>] stop

  audio-codec-ctl [-d|--device <device>] p[lug_state]

  audio-codec-ctl [-d|--device <device>] e[elements]

  audio-codec-ctl [-d|--device <device>] t[opologies]

  audio-codec-ctl [-d|--device <device>] w[atch] <id>

  audio-codec-ctl [-d|--device <device>] set <id> [start|stop] [bypass] [gain <gain>]
    [vendor <hex> <hex> ...]

  audio-codec-ctl list

  audio-codec-ctl [-h|--help]

Commands

Audio hardware codec driver control on <device> (full path specified, for example, /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector or only the service instance name specified, for example, default) or unspecified (picks the first device in /svc/fuchsia.hardware.audio.CodecConnectorService). You can specify only one command per invocation.

list command

  audio-codec-ctl list

Lists all available codec devices.

formats command

  audio-codec-ctl [-d|--device <device>] f[ormats]

Retrieves the DAI formats supported by the codec.

info command

  audio-codec-ctl [-d|--device <device>] i[nfo]

Retrieves textual information about the codec.

capabilities_plug_detect command

  audio-codec-ctl [-d|--device <device>] c[apabilities_plug_detect]

Retrieves Plug Detect Capabilities.

reset command

  audio-codec-ctl [-d|--device <device>] r[eset]

Resets the codec.

dai command

  audio-codec-ctl [-d|--device <device>] d[ai] <number_of_channels>
    <channels_to_use_bitmask> pdm|upcm|spcm|fpcm none|i2s|left-stereo|right-stereo|1tdm|2tdm|3tdm
    <frame_rate> <bits_per_slot> <bits_per_sample>

Sets the DAI format to use in the codec interface.

<number_of_channels>: Number of channels.

<channels_to_use_bitmask>: Sets which channels are active via a bitmask. The least significant bit corresponds to channel index 0.

pdm: Pulse Density Modulation samples.

upcm: Signed Linear Pulse Code Modulation samples at the host endianness.

spcm: Unsigned Linear Pulse Code Modulation samples at the host endianness.

fpcm: Floating point samples IEEE-754 encoded.

none: No frame format as in samples without a frame sync like PDM.

i2s: Format as specified in the I2S specification.

left-stereo: Left justified, 2 channels.

right-stereo: Right justified, 2 channels.

1tdm: Left justified, variable number of channels, data starts at frame sync changes from low to high clocked out at the rising edge of sclk. The frame sync must stay high for exactly 1 clock cycle.

2tdm: Left justified, variable number of channels, data starts one clock cycle after the frame sync changes from low to high clocked out at the rising edge of sclk. The frame sync must stay high for exactly 1 clock cycle.

3tdm: Left justified, variable number of channels, data starts two clock cycles after the frame sync changes from low to high clocked out at the rising edge of sclk. The frame sync must stay high for exactly 1 clock cycle.

<frame_rate>: The frame rate for all samples.

<bits_per_slot>: The bits per slot for all channels.

<bits_per_sample>: The bits per sample for all samples. Must be smaller than bits per channel for samples to fit.

start command

  audio-codec-ctl [-d|--device <device>] start

Start/Re-start the codec operation.

stop command

  audio-codec-ctl [-d|--device <device>] stop

Stops the codec operation.

plug_state command

  audio-codec-ctl [-d|--device <device>] p[lug_state]

Get the plug detect state.

elements command

  audio-codec-ctl [-d|--device <device>] e[lements]

Returns a vector of supported processing elements.

topologies command

  audio-codec-ctl [-d|--device <device>] t[opologies]

Returns a vector of supported topologies.

watch command

  audio-codec-ctl [-d|--device <device>] w[atch] <id>

Get a processing element state.

set command

  audio-codec-ctl [-d|--device <device>] set <id> [start|stop] [bypass] [gain <gain>]
    [vendor <hex> <hex> ...]

Controls a processing element.

<id>: Processing element id.

start: Process element started state.

stop: Process element stopped state.

bypass: Process element bypassed state.

<gain>: Current gain in GainType format reported in the supported processing elements vector.

<hex>: Vendor specific raw byte to feed to the processing element in hex format.

Examples

List all available codec devices

audio-codec-ctl list
default

Retrieve the DAI formats supported

audio-codec-ctl f
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
[ fuchsia_hardware_audio::DaiSupportedFormats{ number_of_channels = [ 2, 4, ], sample_formats = [ fuchsia_hardware_audio::DaiSampleFormat::kPcmSigned, ], frame_formats = [ fuchsia_hardware_audio::DaiFrameFormat::frame_format_standard(fuchsia_hardware_audio::DaiFrameFormatStandard::kI2S), fuchsia_hardware_audio::DaiFrameFormat::frame_format_standard(fuchsia_hardware_audio::DaiFrameFormatStandard::kTdm1), ], frame_rates = [ 48000, 96000, ], bits_per_slot = [ 16, 32, ], bits_per_sample = [ 16, 32, ], }, ]

Retrieve textual information

audio-codec-ctl i
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
fuchsia_hardware_audio::CodecInfo{ unique_id = "", manufacturer = "Texas Instruments", product_name = "TAS5825m", }

Retrieve plug detect capabilities

audio-codec-ctl c
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
fuchsia_hardware_audio::PlugDetectCapabilities::kHardwired

Check if the codec is bridgeable

audio-codec-ctl b
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
Is bridgeable: false

Reset the codec

audio-codec-ctl r
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
Reset done

Set a codec's bridged mode

audio-codec-ctl -m true
Setting bridged mode to: true
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector

Set the DAI format to use in the codec interface

audio-codec-ctl d 2 1 s i 48000 16 32
Setting DAI format:
fuchsia_hardware_audio::DaiFormat{ number_of_channels = 2, channels_to_use_bitmask = 1, sample_format = fuchsia_hardware_audio::DaiSampleFormat::kPcmSigned, frame_format = fuchsia_hardware_audio::DaiFrameFormat::frame_format_standard(fuchsia_hardware_audio::DaiFrameFormatStandard::kI2S), frame_rate = 48000, bits_per_slot = 16, bits_per_sample = 32, }
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector

Start or restart the codec operation

audio-codec-ctl start
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
Start done

Stop the codec operation

audio-codec-ctl stop
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
Stop done

Get the plug detect state

audio-codec-ctl p
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
fuchsia_hardware_audio::PlugState{ plugged = true, plug_state_time = 1167863520, }

Get the supported processing elements

audio-codec-ctl e
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
[ fuchsia_hardware_audio_signalprocessing::Element{ id = 1, type = fuchsia_hardware_audio_signalprocessing::ElementType::kGain, type_specific = fuchsia_hardware_audio_signalprocessing::TypeSpecificElement::gain(fuchsia_hardware_audio_signalprocessing::Gain{ type = fuchsia_hardware_audio_signalprocessing::GainType::kDecibels, min_gain = -63.5, max_gain = 0, min_gain_step = 0.5, }), }, fuchsia_hardware_audio_signalprocessing::Element{ id = 2, type = fuchsia_hardware_audio_signalprocessing::ElementType::kMute, }, ]

Get the supported topologies

audio-codec-ctl t
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
[ fuchsia_hardware_audio_signalprocessing::Topology{ id = 1, processing_elements_edge_pairs = [ fuchsia_hardware_audio_signalprocessing::EdgePair{ processing_element_id_from = 1, processing_element_id_to = 2, }, fuchsia_hardware_audio_signalprocessing::EdgePair{ processing_element_id_from = 2, processing_element_id_to = 3, }, ], }, ]

Get a processing element state

audio-codec-ctl w 1
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
fuchsia_hardware_audio_signalprocessing::ElementState{ type_specific = fuchsia_hardware_audio_signalprocessing::TypeSpecificElementState::gain(fuchsia_hardware_audio_signalprocessing::GainElementState{ gain = 0, }), started = true, }

Control a processing element

audio-codec-ctl set 1 start gain 1.23 vendor 0x12 0x98
Setting element state:
fuchsia_hardware_audio_signalprocessing::SignalProcessingSetElementStateRequest{ processing_element_id = 1, state = fuchsia_hardware_audio_signalprocessing::ElementState{ type_specific = fuchsia_hardware_audio_signalprocessing::TypeSpecificElementState::gain(fuchsia_hardware_audio_signalprocessing::GainElementState{ gain = 1.23, }), started = true, vendor_specific_data = [ 18, 152, ], }, }
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector

Specify device

audio-codec-ctl -d default p
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
fuchsia_hardware_audio::PlugState{ plugged = true, plug_state_time = 1167863520, }
audio-codec-ctl -d non-existent p
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/non-existent/codec_connector
could not connect to:/svc/fuchsia.hardware.audio.CodecConnectorService/non-existent/codec_connector status:ZX_ERR_NOT_FOUND
audio-codec-ctl -d /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector p
Executing on device: /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector
fuchsia_hardware_audio::PlugState{ plugged = true, plug_state_time = 1167863520, }

Source code

Source code for audio-codec-ctl: //src/media/audio/tools/audio-codec-ctl/