音频编解码器 - ctl

音频硬件编解码器驱动程序控制。用于通过 FIDL 编解码器接口控制音频硬件编解码器驱动程序并从中获取信息。请参阅 audio-driver-ctl,了解如何播放、录制和配置音频流。

用法

  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]

命令

<device> 上音频硬件编解码器驱动程序控制(指定完整路径,例如 /svc/fuchsia.hardware.audio.CodecConnectorService/default/codec_connector;或仅指定服务实例名称,例如 default)或未指定(选择 /svc/fuchsia.hardware.audio.CodecConnectorService 中的第一个设备)。每次调用只能指定一个命令。

list 命令

  audio-codec-ctl list

列出所有可用的编解码器设备。

formats 命令

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

检索编解码器支持的 DAI 格式。

info 命令

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

检索有关编解码器的文本信息。

capabilities_plug_detect 命令

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

检索插头检测功能。

reset 命令

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

重置编解码器。

dai 命令

  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>

设置要在编解码器接口中使用的 DAI 格式。

<number_of_channels>:渠道数量。

<channels_to_use_bitmask>:通过位掩码设置哪些渠道处于有效状态。最低有效位对应于通道索引 0。

pdm:脉冲密度调制样本。

upcm:采用主机字节序的有符号线性脉冲编码调制采样。

spcm:采用主机字节序的无符号线性脉冲编码调制采样。

fpcm:以 IEEE-754 编码的浮点样本。

none:没有帧格式,如没有帧同步的 PDM 样本。

i2s:格式与 I2S 规范中指定的格式一致。

left-stereo:左对齐,2 个渠道。

right-stereo:靠右对齐,2 个渠道。

1tdm:左对齐,可变数量的声道,数据从帧同步变化(从低到高)开始,在 sclk 的上升沿时输出。帧同步必须保持高电平状态,持续时间正好为 1 个时钟周期。

2tdm:左对齐,可变数量的通道,数据在帧同步从低变为高后的一个时钟周期开始,在 sclk 的上升沿时输出。帧同步必须保持高电平正好 1 个时钟周期。

3tdm:左对齐,可变数量的声道,数据在帧同步从低变为高后的两个时钟周期开始,在 sclk 的上升沿时输出。帧同步必须保持高电平正好 1 个时钟周期。

<frame_rate>:所有样本的帧速率。

<bits_per_slot>:所有渠道的每时隙位数。

<bits_per_sample>:所有样本的每个样本的比特数。必须小于每通道位数,才能容纳样本。

start 命令

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

启动/重新启动编解码器操作。

stop 命令

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

停止编解码器操作。

plug_state 命令

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

获取插头检测状态。

elements 命令

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

返回支持的处理元素的向量。

topologies 命令

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

返回一个包含支持的拓扑的向量。

watch 命令

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

获取处理元素状态。

set 命令

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

控制处理元素。

<id>:处理元素 ID。

start:进程元素启动状态。

stop:处理元素停止状态。

bypass:处理元素绕过状态。

<gain>:以 GainType 格式报告的支持的处理元素向量中的当前增益。

<hex>:以十六进制格式提供给处理元素的供应商特定原始字节。

示例

列出所有可用的编解码器设备

audio-codec-ctl list
default

检索支持的 DAI 格式

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, ], }, ]

检索文本信息

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", }

检索插头检测功能

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

检查编解码器是否可桥接

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

重置编解码器

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

设置编解码器的桥接模式

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

设置要在编解码器接口中使用的 DAI 格式

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

启动或重启编解码器操作

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

停止编解码器操作

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

获取插拔检测状态

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, }

获取支持的处理元素

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, }, ]

获取支持的拓扑

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, }, ], }, ]

获取处理元素状态

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, }

控制处理元素

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

指定设备

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, }

源代码

audio-codec-ctl 的源代码://src/media/audio/tools/audio-codec-ctl/