音频编解码器 - ctl

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

用法

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

  audio-codec-ctl [-d|--device <device>] b[ridgeable]

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

  audio-codec-ctl [-d|--device <device>] m[ode_bridged] true|false

  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> [enable|disable] [gain <gain>] [latency <nsecs>]
    [vendor <hex> <hex> ...]

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

命令

<device> 上的音频硬件编解码器驱动程序控制(指定完整路径,例如 /dev/class/codec/123 或仅指定的 devfs 节点名称,例如 123)或未指定(选择 /dev/class/codec 中的第一个设备)。每次调用只能指定一个命令。

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]

检索插头检测功能。

bridgeable

  audio-codec-ctl [-d|--device <device>] b[ridgeable]

返回编解码器是否可以桥接。

reset

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

重置编解码器。

mode_bridged

  audio-codec-ctl [-d|--device <device>] m[ode_bridged] true|false

将编解码器桥接模式设置为 true 或 false。

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> [enable|disable] [gain <gain>] [latency <nsecs>]
    [vendor <hex> <hex> ...]

控制处理元素。

<id>:处理元素 ID。

enable:处理元素启用状态。

disable:进程元素停用状态。

<gain>:支持处理元素矢量中报告的当前增益,采用 GrowType 格式。

<nsecs>:添加到流水线的延迟时间(以纳秒为单位)。

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

示例

检索支持的 DAI 格式

$ audio-codec-ctl f
Executing on device: /dev/class/codec/706
[ 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: /dev/class/codec/706
fuchsia_hardware_audio::CodecInfo{ unique_id = "", manufacturer = "Texas Instruments", product_name = "TAS5825m", }

检索插件检测功能

$ audio-codec-ctl c
Executing on device: /dev/class/codec/706
fuchsia_hardware_audio::PlugDetectCapabilities::kHardwired

返回编解码器是否可桥接

$ audio-codec-ctl b
Executing on device: /dev/class/codec/706
Is bridgeable: false

重置编解码器

$ audio-codec-ctl r
Executing on device: /dev/class/codec/706
Reset done

设置编解码器的桥接模式

$ audio-codec-ctl -m true
Setting bridged mode to: true
Executing on device: /dev/class/codec/706

设置要在编解码器接口中使用的 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: /dev/class/codec/706

开始/重启编解码器操作

$ audio-codec-ctl start
Executing on device: /dev/class/codec/706
Start done

停止编解码器操作

$ audio-codec-ctl stop
Executing on device: /dev/class/codec/706
Stop done

获取插头检测状态

$ audio-codec-ctl p
Executing on device: /dev/class/codec/706
fuchsia_hardware_audio::PlugState{ plugged = true, plug_state_time = 1167863520, }

获取受支持的处理元素

$ audio-codec-ctl e
Executing on device: /dev/class/codec/706
[ 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: /dev/class/codec/706
[ 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: /dev/class/codec/706
fuchsia_hardware_audio_signalprocessing::ElementState{ type_specific = fuchsia_hardware_audio_signalprocessing::TypeSpecificElementState::gain(fuchsia_hardware_audio_signalprocessing::GainElementState{ gain = 0, }), enabled = true, }

控制处理元素

$ audio-codec-ctl set 1 enable 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, }), enabled = true, vendor_specific_data = [ 18, 152, ], }, }
Executing on device: /dev/class/codec/706

指定设备

$ audio-codec-ctl -d 706 p
Executing on device: /dev/class/codec/706
fuchsia_hardware_audio::PlugState{ plugged = true, plug_state_time = 1167863520, }
$ audio-codec-ctl -d 123 p
Executing on device /dev/class/codec/123
watch plug state failed: FIDL operation failed due to peer closed, status: ZX_ERR_PEER_CLOSED (-24)
$ audio-codec-ctl -d /dev/class/codec/706 p
Executing on device: /dev/class/codec/706
fuchsia_hardware_audio::PlugState{ plugged = true, plug_state_time = 1167863520, }

源代码

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