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

# Troubleshoot audio

> Capture and analyze audio logs to diagnose and resolve audio issues on Qualcomm Linux platforms.

This section gives commands for audio logging and debugging.

## **Capture logs**

User space and kernel audio driver logs can help find issues.

| **User space logs** | To capture user space logs: |
| :------------------ | :-------------------------- |

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

See [User space logs](https://dragonwingdocs.qualcomm.com/System/Debug-Subsystem/debug-with-user-space-logs) for more instructions.

| **Kernel audio driver logs** | To capture kernel logs: |
| :--------------------------- | :---------------------- |

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

To disable kernel logs in a specific file:

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

| **Dynamic kernel logs** | Dynamic logging is disabled by default. To enable it, add the `CONFIG_DYNAMIC_DEBUG` kernel configuration, recompile, and re-flash the device. To enable audio dynamic kernel logs: |
| :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

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

See [Enable dynamic debug](https://dragonwingdocs.qualcomm.com/System/Debug-Subsystem/enable-kernel-debugging) for more instructions.

## **Analyze logs**

Analyze user space and kernel audio driver logs for playback and record use cases.

### **Playback logs**

The following log snippet shows the information collected for the playback use case.

```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: setDeviceMediaConfig: 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
```

### **Record logs**

The following log snippet shows the information collected for the record use case.

```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]: setDeviceMediaConfig: 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
```

## **Enable diagnostic logging with QXDM**

QXDM Professional™ (QXDM Pro) provides a fast prototyping platform for diagnostic
clients. It provides a GUI to visualize data transmitted from the device, and allows
you to configure and filter audio logs using DMC (Diagnostic Mask Configuration) files.

### **Configure QXDM for audio logging**

1. Open QXDM Professional on your PC.

2. Connect to the target device.

3. Select **File** → **Manage Configuration**.

4. Select the required use case DMC log mask from the list.

5. Apply the DMC configuration to start capturing audio diagnostic logs.

<Note>
  Download QXDM Professional from the Qualcomm Software Center. For more details,
  see the QACT V8.1 User Guide (80-VM407-21).
</Note>

### **Required tools for audio diagnostics**

The following tools are required for full audio diagnostic capability:

| Tool                                  | Purpose                                              |
| :------------------------------------ | :--------------------------------------------------- |
| QACT v8.1                             | Configure and calibrate audio use cases and features |
| QXDM Professional                     | Configure and filter audio diagnostic logs           |
| Qualcomm USB Drivers                  | USB connectivity between PC and target device        |
| Qualcomm Unified Tools Service (QUTS) | Required service for QXDM and QACT connectivity      |

Download all tools from the Qualcomm Software Center.

### **Analyze MI2S/TDM capture logs**

When verifying MI2S or TDM capture, check for the following log patterns to confirm
correct operation:

The device open should be called for the speaker mic:

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

The backend used for capture should show the correct MI2S interface, sample rate,
and channel count:

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

The device open should exit with status 0 and a correct device count:

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

The hardware endpoints should be configured correctly for 48 kHz, stereo, 16-bit:

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

## **Next steps**

* [Audio Addendum](../audio-addendum-overview) — Use QACT and QXDM for calibration and diagnostics
* [Customize audio graph](customize-audio-graph) — Modify audio graphs and PAL configuration
* [Advanced audio features](advanced-audio-features) — Enable echo cancellation and noise suppression
