> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 故障排除音频

> 捕获并分析音频日志以诊断和解决 Qualcomm Linux 平台上的音频问题。

本节提供音频日志记录和调试的命令。

## **捕获日志**

用户空间和内核音频驱动日志有助于发现问题。

| **用户空间日志** | 要捕获用户空间日志： |
| :--------- | :--------- |

```text theme={null}
ssh root@ip-addr
mount -o remount,rw /
cat /var/log/user.log
```

有关更多说明，请参阅 [用户空间日志](https://dragonwingdocs.qualcomm.com/System/Debug-Subsystem/debug-with-user-space-logs)。

| **内核音频驱动日志** | 要捕获内核日志： |
| :----------- | :------- |

```text theme={null}
ssh root@ip-addr dmesg
```

要在特定文件中禁用内核日志：

```text theme={null}
echo -n "file <filename> -p" > /sys/kernel/debug/dynamic_debug/control
```

| **动态内核日志** | 默认情况下禁用动态日志记录。要启用它，请添加 `CONFIG_DYNAMIC_DEBUG` 内核配置，重新编译并重新刷写设备。要启用音频动态内核日志： |
| :--------- | :-------------------------------------------------------------------------- |

```text theme={null}
ssh root@ip-addr
mount -o rw,remount /
mount -t debugfs none /sys/kernel/debug
echo -n "file <filename> +p" > /sys/kernel/debug/dynamic_debug/control
```

有关更多说明，请参阅 [启用动态调试](https://dragonwingdocs.qualcomm.com/System/Debug-Subsystem/enable-kernel-debugging)。

## **分析日志**

分析播放和录音用例的用户空间和内核音频驱动日志。

### **播放日志**

以下日志片段显示了为播放用例收集的信息。

```text theme={null}
//Open Low latency Playback stream. Details of each stream type can be found at sources/audio/opensource/arpal-lx/inc/PalDefs.h
2022-04-28T18:02:08.748280+00:00 pipewire: pal_stream_open: 224: Enter, stream type:1

//Verify the backend device, sample rate, bitwidth, channels etc
2022-04-28T18:02:08.748627+00:00 pipewire: setMediaConfig: 1056: CODEC_DMA-LPAIF_WSA-RX-0 rate ch fmt data_fmt 48000 2 2 1

//Start playback stream
2022-04-28T18:02:08.751947+00:00 pipewire: pal_stream_start: 338: Enter. Stream handle 0xffff94001040K

//Map the metadata with kvh2xml.h file for playback use case details.
2022-04-28T18:02:08.853157+00:00 pipewire: metadata_print: 82 key:0xa1000000, value:0xa100000e//PCM_LL_PLAYBACK
2022-04-28T18:02:08.853395+00:00 pipewire: metadata_print: 82 key:0xab000000, value:0x1
2022-04-28T18:02:08.853660+00:00 pipewire: metadata_print: 82 key:0xa2000000, value:0xa2000001//Speaker
2022-04-28T18:02:08.853881+00:00 pipewire: metadata_print: 82 key:0xac000000, value:0xac000002//DEVICEPP_RX_AUDIO_MBDRC

//Verify the graph opened for playback use case
2022-04-28T18:02:08.856934+00:00 pipewire: print_graph_alias: 2334 GKV Alias 142 | StreamRX_PCM_LL_Playback_DeviceRX_Speaker_Instance_Instance_1_DevicePP_Rx_Audio_MBDRC
//graph_open called
2022-04-28T18:02:08.859509+00:00 pipewire: graph_open: 709 graph_handle 0x47534c

//Configure hardware endpoint module
2022-04-28T18:02:08.864386+00:00 pipewire: configure_hw_ep_media_config: 636 entry mod tag c0000004 miid 43b1 mid 7001023
2022-04-28T18:02:08.864495+00:00 pipewire: configure_hw_ep_media_config: 664 rate 48000 bw 16 ch 2, data_fmt 1
2022-04-28T18:02:08.864603+00:00 pipewire: configure_hw_ep_media_config: 676 exit, ret 0

//graph_start entry
2022-04-28T18:02:08.867234+00:00 pipewire: graph_start: 899 entry graph_handle 0x47534c
//Stream started
2022-04-28T18:02:08.867864+00:00 pipewire: pal_stream_start: 387: Exit. status 0

//graph_stop entry
2022-04-28T18:02:25.037338+00:00 pipewire: graph_stop: 928 entry graph_handle 0x47534c
//Stop the PAL stream once playback completes
2022-04-28T18:02:25.039923+00:00 pipewire: pal_stream_stop: 441: Exit. status 0

//graph_close entry
2022-04-28T18:02:25.050944+00:00 pipewire: graph_close: 762 entry handle 0x47534c
//Close the PAL stream
2022-04-28T18:02:25.054510+00:00 pipewire: pal_stream_close: 322: Exit. status 0
```

### **录音日志**

以下日志片段显示了为录音用例收集的信息。

```text theme={null}
//Open Recording stream for PAL_STREAM_RAW. Details of stream type can be found at sources/audio/opensource/arpal-lx/inc/PalDefs.h
Apr 29 09:23:11 pipewire[862]: pal_stream_open: 224: Enter, stream type:9

//Verify the backend device, sample rate, bitwidth, channels etc
Apr 29 09:23:11 pipewire[862]: setMediaConfig: 1056: CODEC_DMA-LPAIF_VA-TX-0 rate ch fmt data_fmt 48000 1 2 1

//Start recording stream
Apr 29 09:23:11 pipewire[862]: pal_stream_start: 338: Enter. Stream handle 0xffff6c001040K

//graph_open entry
Apr 29 09:23:11 pipewire[862]: graph_open: 709 graph_handle 0x47534c

//Metadata details to identify the use case
Apr 29 09:23:11 pipewire[862]: metadata_print: 82 key:0xb1000000, value:0xb1000009//RAW_RECORD
Apr 29 09:23:11 pipewire[862]: metadata_print: 82 key:0xa3000000, value:0xa3000004//HANDSETMIC

//Verify the graph opened for recording use case
Apr 29 09:23:11 pipewire[862]: print_graph_alias: 2334 GKV Alias 29 | DeviceTX_Handset_Mic_StreamTX_RAW_Record

//Configure hardware endpoint module
Apr 29 09:23:11 pipewire[862]: configure_hw_ep_media_config: 636 entry mod tag c0000005 miid 43af mid 7001024
Apr 29 09:23:11 pipewire[862]: configure_hw_ep_media_config: 664 rate 48000 bw 16 ch 1, data_fmt 1
Apr 29 09:23:11 pipewire[862]: configure_hw_ep_media_config: 676 exit, ret 0

//graph_start entry
Apr 29 09:23:11 pipewire[862]: graph_start: 899 entry graph_handle 0x47534c
//Stream recording started
Apr 29 09:23:11 pipewire[862]: pal_stream_start: 387: Exit. status 0


//graph_stop entry
Apr 29 09:23:26 pipewire[862]: graph_stop: 928 entry graph_handle 0x47534c
//Stop the PAL stream once user stops recording
Apr 29 09:23:26 pipewire[862]: D: [regular2] pal-source.c: pal_stream_stop returned 0

//Close the PAL stream
Apr 29 09:23:26 pipewire[862]: pal_stream_close: 284: Enter. Stream handle :0xffff6c001040K
//graph_close entry
Apr 29 09:23:26 pipewire[862]: graph_close: 762 entry handle 0x47534c
//Close the PAL stream
Apr 29 09:23:26 pipewire[862]: pal_stream_close: 322: Exit. status 0
```

## **使用 QXDM 启用诊断日志记录**

QXDM Professional™ (QXDM Pro) 为诊断客户端提供了一个快速原型平台。它提供图形界面用于可视化从设备传输的数据，并允许您使用 DMC (Diagnostic Mask Configuration) 文件配置和过滤音频日志。

### **配置 QXDM 用于音频日志记录**

1. 在您的 PC 上打开 QXDM Professional。

2. 连接到目标设备。

3. 选择 **File** → **Manage Configuration**。

4. 从列表中选择所需的用例 DMC 日志掩码。

5. 应用 DMC 配置以开始捕获音频诊断日志。

<Note>
  从 Qualcomm Software Center 下载 QXDM Professional。有关更多详细信息，请参阅 QACT V8.1 用户指南 (80-VM407-21)。
</Note>

### **音频诊断所需的工具**

以下工具是完整音频诊断能力所必需的：

| 工具                                    | 用途                  |
| :------------------------------------ | :------------------ |
| QACT v8.1                             | 配置和校准音频用例和功能        |
| QXDM Professional                     | 配置和过滤音频诊断日志         |
| Qualcomm USB Drivers                  | PC 和目标设备之间的 USB 连接  |
| Qualcomm Unified Tools Service (QUTS) | QXDM 和 QACT 连接所需的服务 |

从 Qualcomm Software Center 下载所有工具。

### **分析 MI2S/TDM 捕获日志**

在验证 MI2S 或 TDM 捕获时，请检查以下日志模式以确认操作正确：

设备打开应为扬声器麦克风调用：

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: open: 469: Enter. deviceCount 0 for device id 28 (PAL_DEVICE_IN_SPEAKER_MIC)
```

用于捕获的后端应显示正确的 MI2S 接口、采样率和通道数：

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: setMediaConfig: 1056: MI2S-LPAIF-TX-PRIMARY rate ch fmt data_fmt 48000 2 2 1
```

设备打开应以状态 0 和正确的设备计数退出：

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: open: 504: Exit. deviceCount 1 for device id 28 (PAL_DEVICE_IN_SPEAKER_MIC), exit status: 0
```

硬件端点应正确配置为 48 kHz、立体声、16 位：

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: configure_hw_ep_media_config: 664 rate 48000 bw 16 ch 2, data_fmt 1
```

## **后续步骤**

* [Audio Addendum](https://dragonwingdocs.qualcomm.com/Addendum-docs/Audio/audio-addendum-overview) — 使用 QACT 和 QXDM 进行校准和诊断
* [自定义音频图](customize-audio-graph) — 修改音频图和 PAL 配置
* [高级音频功能](advanced-audio-features) — 启用回声消除和噪声抑制
