> For the complete documentation index, see [llms.txt](https://amobile-solutions.gitbook.io/yocto-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://amobile-solutions.gitbook.io/yocto-developer-guide/test-and-use-the-interface/audio/audio-iot-800n-g420.md).

# Audio - IOT-800N-G420

## Overview

|            |                                               |
| ---------- | --------------------------------------------- |
| Codec      | PMIC built-in ADDA                            |
| ALSA card  | `card 0: mt8391evk`                           |
| Line out   | 3-pin Phoenix push-in connector, from HP-L    |
| Speaker    | 1 built-in, driven from HP-R through a PT3300 |
| Microphone | 2 built-in, digital (DMIC)                    |

Both outputs are analogue and come straight from the PMIC codec. There is no I2S codec on this board.

## The speaker amplifier

The PT3300 is a class-D amplifier with an **analogue input**. Its signal comes directly from the PMIC's HP-R output, so no driver is involved in the audio path at all.

|           |                                                             |
| --------- | ----------------------------------------------------------- |
| Gain      | Fixed at about 33× by resistors, not adjustable in software |
| High-pass | About 80 Hz, set by the input capacitor                     |
| Mode      | Class-D, selected by a pull-up on the MODE pin              |
| Enable    | `GPIO58`, active high, held high by the board               |

{% hint style="info" %}
Because the part is analogue and its gain is set by resistors, volume is controlled entirely through the ALSA mixer on the PMIC side. There is no I2C interface to the amplifier and no kernel driver for it.

Earlier carrier revisions used an AW87390, which did have I2C control. `CONFIG_SND_SOC_AW87XXX` is disabled from R02 onwards.
{% endhint %}

### Muting the speaker

`GPIO58` reaches the amplifier's shutdown pin. The board holds it high, so the amplifier is enabled from power-on with nothing in software claiming the line:

```
gpioinfo | grep -w 58
gpioget -c gpiochip0 58
```

```
"58"=active
```

Driving it low mutes the speaker without touching the mixer, which is useful when the line output should stay active:

```
gpioset -c gpiochip0 58=0 &
```

{% hint style="warning" %}
`gpioset` holds the line only while it runs. Releasing it returns the pin to its default, and the speaker comes back.
{% endhint %}

## Playback devices

```
aplay -l
```

The card exposes many downlink paths. The ones normally used:

| Device   | Purpose |
| -------- | ------- |
| `hw:0,0` | DL0     |
| `hw:0,1` | DL1     |
| `hw:0,6` | DL2     |

```
speaker-test -c2 -twav -l1
aplay -D hw:0,0 <file>.wav
```

## Capture devices

```
arecord -l
```

| Device   | Purpose |
| -------- | ------- |
| `hw:0,2` | UL0     |
| `hw:0,3` | UL1     |
| `hw:0,4` | UL2     |

```
arecord -D hw:0,2 -f cd -d 3 /tmp/rec.wav
aplay /tmp/rec.wav
```

## Volume

```
amixer -c0 cset name='Headset Volume' 4,4
amixer -c0 cget name='Headset Volume'
```

The two values are the left and right channels. The range is 0 to 18.

{% hint style="warning" %}
**Larger values are quieter.** The control is an attenuator, so 0 is loudest and 18 is quietest — the opposite of what the dB scale reported by ALSA suggests.
{% endhint %}

{% hint style="info" %}
`amixer sset` will not find this control. It exists only in the full control interface, not the simple mixer layer, so `cset name=...` is required. The same applies to the other volume controls below.
{% endhint %}

The line output is controlled separately:

```
amixer -c0 cset name='Lineout Volume' 4,4
```

### Microphone gain

```
amixer -c0 cset name='PGA1 Volume' 2
```

Range 0 to 4 in 6 dB steps.

### Range of adjustment

The usable range is around 18 dB. The PT3300's gain is fixed by resistors at roughly 33×, so the codec attenuator is the only adjustment available and even its minimum setting is still reasonably loud.

A wider range would need the amplifier's input resistor changed, which is a hardware modification.

## Mixer routing

```
amixer -c0 scontrols
amixer -c0 contents
```

The routing controls follow MediaTek's naming: `ADDA_DL_CH1 DL0_CH1` and similar connect a downlink path to the codec.

{% hint style="info" %}
MediaTek's AFE exposes a large routing matrix rather than a small set of volume controls, so most entries are switches connecting one path to another rather than gain settings.
{% endhint %}

## Saving the mixer state

```
amixer -c0 cset name='Headset Volume' 4,4
alsactl store
```

The state is restored at boot from `/var/lib/alsa/asound.state`. The image ships a default state file so the audio path works without manual configuration.

## Testing

```
speaker-test -c2 -twav -l1
```

A tone should come from the built-in speaker.

```
arecord -f cd -d 3 /tmp/r.wav && aplay /tmp/r.wav
```

Speak while recording; the playback should reproduce it.

## Troubleshooting

### aplay succeeds but there is no sound

The audio path is analogue after the PMIC, so ALSA reporting success only means the digital side is working. Check in this order:

```
amixer -c0 sget 'Lineout'
gpioget -c gpiochip0 58
```

`GPIO58` has to read `active`. With it low the amplifier is in shutdown and the speaker is silent while everything else looks correct.

### Line out works but the speaker does not

They come from different PMIC outputs — line out from HP-L, the speaker from HP-R — so one working does not imply the other. Check the amplifier enable as above.

### The volume does not change

`amixer sset` reports the control as missing, because these live in the full control interface rather than the simple mixer layer. Use `cset name=...` instead.

If `cset` succeeds but nothing audible changes, check which control is on the path being used — the speaker and the line output are separate.

### No capture devices

```
dmesg | grep -i dmic
```

The microphones are digital and connect through DMIC rather than an analogue path.
