User Tools

Site Tools


alsa

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
alsa [2026-11-22 21:10 UTC (5 days ago)] – update with speaker enable-disable research, examples, stock alsa config, and reasoning. qkbalsa [2026-11-22 22:40 UTC (5 days ago)] (current) – remove some useless AI text / verbosity jazzy
Line 2: Line 2:
  
 The two grille speakers are on the Line-Out of a TI TLV320AIC32x4 codec. The The two grille speakers are on the Line-Out of a TI TLV320AIC32x4 codec. The
-codec is on I2C bus 0 at address `0x18`, fed over SSI, and shows up as ALSA card +codec is on I2C bus 0 at address ''%%0x18%%'', fed over SSI, and shows up as ALSA card 
-0, `PM3 Audio`. There is a capture path too (Mic PGA / ADC).+0, ''%%PM3 Audio%%''. There is a capture path too (Mic PGA / ADC).
  
 The Line-Out does not drive the speakers directly. It feeds an external power The Line-Out does not drive the speakers directly. It feeds an external power
-amplifier, `PAmobil2`, which is off at power-on. The amp is switched on by the +amplifier, ''%%PAmobil2%%'', which is off at power-on. The amp is switched on by the 
-PIC32 over `/dev/ttymxc2`:+PIC32 over ''%%/dev/ttymxc2%%'':
  
-* PIC32 key `0x07E0` (`ValueWrite`, type `0x04`): `1` = amp on, `0` = amp off. +  * PIC32 key ''%%0x07E0%%'' (''%%ValueWrite%%'', type ''%%0x04%%''): ''%%1%%'' = amp on, ''%%0%%'' = amp off. 
-* One master gate for both channels. +  * It reads back with ''%%ValueRead%%'', so the state can be queried. 
-* It reads back with `ValueRead`, so the state can be queried. +  * It remains in this state until the PIC32 resets at the next power-off.
-* It latches until the PIC32 resets at the next power-off. Nothing persistent is +
-  written.+
  
-With the amp off, ALSA, the codec, the mixer, and the clocks can all be perfectly 
-configured and the speaker is still silent. That is why playback appears 
-to need nx: nx switches the amp on once at startup through 
-`NxPaCtrl`/`NxPaMobil2PicDev`. 
  
 ===== Turning the amp on ===== ===== Turning the amp on =====
  
-The stock tool does it with:+You can toggle the amp using NxExe:
  
 <code> <code>
Line 28: Line 22:
 </code> </code>
  
-That command toggles the amp. The state persists until the PIC32 loses power, so +That command toggles the amplifier. The state persists until the PIC32 loses power, so 
-blindly toggling on boot can turn it off if it was already on. Read the state +blindly toggling after a reboot can turn it off if it was already on.
-first, or set it explicitly.+
  
 To set the amp explicitly, write the PIC32 frame directly. These are IPP frames To set the amp explicitly, write the PIC32 frame directly. These are IPP frames
-with sequence 1 and no payload CRC, because `0x04` and `0x02` are below `0x80`:+with sequence 1 and no payload CRC, because ''%%0x04%%'' and ''%%0x02%%'' are below ''%%0x80%%'':
  
 <code> <code>
Line 49: Line 42:
 </code> </code>
  
-The reply to the read is a `0x03` frame with the 2-byte key and the current+The reply to the read is a ''%%0x03%%'' frame with the 2-byte key and the current
 value. The examples use sequence 1. If you write a script, increment the sequence value. The examples use sequence 1. If you write a script, increment the sequence
 byte and recompute the CRC-8 for each frame. byte and recompute the CRC-8 for each frame.
Line 55: Line 48:
 ===== ALSA setup ===== ===== ALSA setup =====
  
-`alsa-restore.service` restores `/etc/asound.state` at boot, so the routing is+''%%alsa-restore.service%%'' restores ''%%/etc/asound.state%%'' at boot, so the routing is
 usually already set. The two details that still cause silence are: usually already set. The two details that still cause silence are:
  
-1. Line-Out driver gain must be at the 0 dB baseline: +Line-Out driver gain must be at the 0 dB baseline. ''%%6%%'' is the baseline, not a volume control.
-   <code> +
-   amixer -c 0 sset 'LO Driver Gain' 6 +
-   </code> +
-   `6` is the 0 dB baseline, not a volume control.+
  
-2. Play a file, not a pipe. A file plays: +<code> 
-   <code> +amixer -c 0 sset 'LO Driver Gain' 6 
-   aplay /tmp/tone.wav +</code>
-   </code> +
-   Piping into `aplay` from stdin is silent on this device: +
-   <code> +
-   cat tone.wav | aplay -q - +
-   </code>+
  
-Volume is the `PCM` control. Use it as a percentage:+Playing a file:
  
 <code> <code>
-amixer -c 0 sset PCM 65%+aplay /tmp/tone.wav
 </code> </code>
  
-The old `amixer sset PCM 144` command sets a raw level. Treat it as a high level, +Volume is the ''%%PCM%%'' control. Use it as a percentage: 
-not a percentage.+ 
 +<code> 
 +amixer -c 0 sset PCM 65% 
 +</code>
  
 A complete manual sequence: A complete manual sequence:
Line 96: Line 83:
 ===== Why nx seemed to be required ===== ===== Why nx seemed to be required =====
  
-nx turns the speaker amp on once at startup and never turns it off. The PIC32+nx turned the speaker amp on once at startup and never turns it off. The PIC32
 keeps that state until it loses power. keeps that state until it loses power.
  
-The codec is not the gate. Its registers, DAPM, GPIO, clocks, AUDMUX, and SSI1+The codec can be configured fine without the amp but the speakers will remain silent. Its registers, DAPM, GPIO, clocks, AUDMUX, and SSI1
 can all match while the speaker is silent. The amp is a separate PIC32 value on can all match while the speaker is silent. The amp is a separate PIC32 value on
-`ttymxc2`, after the codec. nx does not touch any extra ALSA mixer or codec +''%%ttymxc2%%'', after the codec. nx does not touch any extra ALSA mixer or codec 
-control. It writes `0x07E0 = 1` once near boot.+control. It writes ''%%0x07E0 = 1%%'' once near boot.
  
-Set `0x07E0` to 1 and the speaker works from a cold boot with no nx. It stays on 
-until the PIC32 resets, so it only needs setting once per power cycle. 
  
 ===== Notes (maybe outdated) ===== ===== Notes (maybe outdated) =====
Line 125: Line 110:
 > is preinstalled and works for setting the volume. > is preinstalled and works for setting the volume.
  
-===== Notes Addendum and reasoning =====+===== Addendum =====
  
 The older reports about mixed ALSA results are consistent with the amp latch. The older reports about mixed ALSA results are consistent with the amp latch.
  
-If nx has run since power-on, the amp is on and `aplay` works even after nx is+If nx has run since power-on, the amp is on and ''%%aplay%%'' works even after nx is
 stopped. That is the "worked out of the box" case. stopped. That is the "worked out of the box" case.
  
-If the unit is cold-booted with nx never started, `aplay` is silent until +If the unit is cold-booted with nx never started, ''%%aplay%%'' is silent until 
-`0x07E0` is set to 1. Saving and restoring `/etc/asound.state` does not touch+''%%0x07E0%%'' is set to 1. Saving and restoring ''%%/etc/asound.state%%'' does not touch
 the amp, so it cannot fix that case. the amp, so it cannot fix that case.
  
-The miniaudio theory was a reasonable guess at the time. nx does not need to stay +The miniaudio theory was speculation. nx does not need to stay running for 
-running for audio. The device only needs the amp switched on.  +audio. It only needs to leave the amp switched on.
  
 ===== Stock ALSA state ===== ===== Stock ALSA state =====
  
-The stock `/etc/asound.state` is below. If you build a custom rootfs, keep this+The stock ''%%/etc/asound.state%%'' is below. If you build a custom rootfs, keep this
 file and restore it at boot: file and restore it at boot:
  
Line 149: Line 133:
 </code> </code>
  
-The important parts are the Line-Out DAC switches, `LO Driver Gain` at 6 +The important parts are the Line-Out DAC switches, ''%%LO Driver Gain%%'' at 6 
-(0 dB), and `PCM Playback Volume` at 85 (about -21 dB). The rest is the input+(0 dB), and ''%%PCM Playback Volume%%'' at 85 (about -21 dB). The rest is the input
 and AGC configuration. and AGC configuration.
  
Line 657: Line 641:
 } }
 </code> </code>
 +
alsa.1795381807.txt.gz · Last modified: by qkb