音訊-轉碼器

音訊硬體轉碼器驅動程式庫控制項。用於透過 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:Pulse 密度調變範例。

upcm:主機端的已簽署線性脈衝程式碼調變範例。

spcm:位於主機端的未簽署線性脈衝程式碼調節範例。

fpcm:經過 IEEE-754 編碼的浮點範例。

none:沒有像 PDM 這類沒有影格同步的樣本則沒有影格格式。

i2s:I2S 規格中指定的格式。

left-stereo:靠左對齊,2 個頻道。

right-stereo:靠右對齊,2 個頻道。

1tdm:左右對齊且可變的聲道數,資料會在影格同步時從低到高出現,輪廓在螺絲上升邊緣時顯示。影格同步程序必須要剛好 1 個時鐘週期。

2tdm:左對齊且可變的聲道數,資料會在影格同步後,從低到高的迅速波出,從低到高,開始一個時鐘週期。影格同步速度必須維持在高速率 1 個時鐘週期。

3tdm:左對齊且可變的聲道數,資料會在影格同步後,於螺絲起伏的高波同步從低到高時開始兩個時鐘週期。影格同步速度必須維持在高速率 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>:支援的處理元素向量目前回報的 GetType 格式增幅。

<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/