alsa
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| alsa [2026-04-18 09:29 UTC (7 months ago)] – I had better luck with audio output, added my own notes aaronjamt | alsa [2026-11-22 22:40 UTC (5 days ago)] (current) – remove some useless AI text / verbosity jazzy | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | Alsa is used for audio playback. | + | The two grille speakers are on the Line-Out of a TI TLV320AIC32x4 codec. The |
| + | codec is on I2C bus 0 at address '' | ||
| + | 0, '' | ||
| - | NX does some initialization of audio: | + | The Line-Out |
| - | | + | amplifier, |
| - | * other magic to get it actually working? | + | PIC32 over '' |
| - | People have had mixed results with Alsa initialization. One person only had success by running | + | * PIC32 key '' |
| - | > Saving and restoring | + | * It reads back with '' |
| + | * It remains in this state until the PIC32 resets at the next power-off. | ||
| + | |||
| + | |||
| + | ===== Turning the amp on ===== | ||
| + | |||
| + | You can toggle the amp using NxExe: | ||
| + | |||
| + | < | ||
| + | NxExe prox2 amp | ||
| + | </ | ||
| + | |||
| + | That command toggles the amplifier. The state persists until the PIC32 loses power, so | ||
| + | blindly toggling after a reboot can turn it off if it was already on. | ||
| + | |||
| + | To set the amp explicitly, write the PIC32 frame directly. These are IPP frames | ||
| + | with sequence 1 and no payload CRC, because '' | ||
| + | |||
| + | < | ||
| + | stty -F / | ||
| + | |||
| + | # amp on: ValueWrite 0x07E0 = 1 | ||
| + | printf ' | ||
| + | |||
| + | # amp off: ValueWrite 0x07E0 = 0 | ||
| + | printf ' | ||
| + | |||
| + | # read state: ValueRead 0x07E0 | ||
| + | printf ' | ||
| + | timeout -t 2 dd if=/ | ||
| + | </ | ||
| + | |||
| + | The reply to the read is a '' | ||
| + | value. The examples use sequence 1. If you write a script, increment the sequence | ||
| + | byte and recompute the CRC-8 for each frame. | ||
| + | |||
| + | ===== ALSA setup ===== | ||
| + | |||
| + | '' | ||
| + | usually already set. The two details that still cause silence are: | ||
| + | |||
| + | Line-Out driver gain must be at the 0 dB baseline. '' | ||
| + | |||
| + | < | ||
| + | amixer -c 0 sset 'LO Driver Gain' 6 | ||
| + | </ | ||
| + | |||
| + | Playing a file: | ||
| + | |||
| + | < | ||
| + | aplay / | ||
| + | </ | ||
| + | |||
| + | Volume is the '' | ||
| + | |||
| + | < | ||
| + | amixer -c 0 sset PCM 65% | ||
| + | </ | ||
| + | |||
| + | A complete manual sequence: | ||
| + | |||
| + | < | ||
| + | printf ' | ||
| + | alsactl -f / | ||
| + | amixer -c 0 sset 'LO Driver Gain' 6 | ||
| + | amixer -c 0 sset PCM 65% | ||
| + | scp -O tone.wav root@< | ||
| + | ssh root@< | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Why nx seemed to be required ===== | ||
| + | |||
| + | nx turned the speaker amp on once at startup and never turns it off. The PIC32 | ||
| + | keeps that state until it loses power. | ||
| + | |||
| + | 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 | ||
| + | '' | ||
| + | control. It writes '' | ||
| + | |||
| + | |||
| + | ===== Notes (maybe outdated) ===== | ||
| + | |||
| + | People have had mixed results with ALSA initialization. One person only had | ||
| + | success by running | ||
| + | |||
| + | > Saving and restoring | ||
| + | > The nx binary is built with [[https:// | ||
| + | > inside it, so perhaps it does some external hardware initialization of the | ||
| + | > speaker. I couldn't get miniaudio in a custom binary to work without | ||
| + | > initializing by running | ||
| + | > logs from a running | ||
| + | |||
| + | Another person found that it worked out of the box: | ||
| + | |||
| + | > Copying an audio file (a 44.1 kHz mono WAV in my case) onto the SD card and | ||
| + | > playing it with '' | ||
| + | > is preinstalled and works for setting the volume. | ||
| + | |||
| + | ===== Addendum ===== | ||
| + | |||
| + | 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 '' | ||
| + | stopped. That is the " | ||
| + | |||
| + | If the unit is cold-booted with nx never started, '' | ||
| + | '' | ||
| + | the amp, so it cannot fix that case. | ||
| + | |||
| + | The miniaudio theory was speculation. nx does not need to stay running for | ||
| + | audio. It only needs to leave the amp switched on. | ||
| + | |||
| + | ===== Stock ALSA state ===== | ||
| + | |||
| + | The stock '' | ||
| + | file and restore it at boot: | ||
| + | |||
| + | < | ||
| + | alsactl -f / | ||
| + | </ | ||
| + | |||
| + | The important parts are the Line-Out DAC switches, '' | ||
| + | (0 dB), and '' | ||
| + | and AGC configuration. | ||
| + | |||
| + | < | ||
| + | state.Audio { | ||
| + | control.1 { | ||
| + | iface MIXER | ||
| + | name 'PCM Playback Volume' | ||
| + | value.0 85 | ||
| + | value.1 85 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 175' | ||
| + | dbmin -6350 | ||
| + | dbmax 2400 | ||
| + | dbvalue.0 -2100 | ||
| + | dbvalue.1 -2100 | ||
| + | } | ||
| + | } | ||
| + | control.2 { | ||
| + | iface MIXER | ||
| + | name 'HP Driver Gain Volume' | ||
| + | value.0 6 | ||
| + | value.1 6 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 35' | ||
| + | dbmin -600 | ||
| + | dbmax 2900 | ||
| + | dbvalue.0 0 | ||
| + | dbvalue.1 0 | ||
| + | } | ||
| + | } | ||
| + | control.3 { | ||
| + | iface MIXER | ||
| + | name 'LO Driver Gain Volume' | ||
| + | value.0 6 | ||
| + | value.1 6 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 35' | ||
| + | dbmin -600 | ||
| + | dbmax 2900 | ||
| + | dbvalue.0 0 | ||
| + | dbvalue.1 0 | ||
| + | } | ||
| + | } | ||
| + | control.4 { | ||
| + | iface MIXER | ||
| + | name 'HP DAC Playback Switch' | ||
| + | value.0 false | ||
| + | value.1 false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 2 | ||
| + | } | ||
| + | } | ||
| + | control.5 { | ||
| + | iface MIXER | ||
| + | name 'LO DAC Playback Switch' | ||
| + | value.0 true | ||
| + | value.1 true | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 2 | ||
| + | } | ||
| + | } | ||
| + | control.6 { | ||
| + | iface MIXER | ||
| + | name 'Mic PGA Switch' | ||
| + | value.0 false | ||
| + | value.1 false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 2 | ||
| + | } | ||
| + | } | ||
| + | control.7 { | ||
| + | iface MIXER | ||
| + | name ' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.8 { | ||
| + | iface MIXER | ||
| + | name ' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.9 { | ||
| + | iface MIXER | ||
| + | name 'ADC Level Volume' | ||
| + | value.0 24 | ||
| + | value.1 24 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 64' | ||
| + | dbmin -1200 | ||
| + | dbmax 2000 | ||
| + | dbvalue.0 0 | ||
| + | dbvalue.1 0 | ||
| + | } | ||
| + | } | ||
| + | control.10 { | ||
| + | iface MIXER | ||
| + | name 'PGA Level Volume' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 95' | ||
| + | dbmin 0 | ||
| + | dbmax 4750 | ||
| + | dbvalue.0 0 | ||
| + | dbvalue.1 0 | ||
| + | } | ||
| + | } | ||
| + | control.11 { | ||
| + | iface MIXER | ||
| + | name ' | ||
| + | value 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 1 | ||
| + | range '0 - 7' | ||
| + | } | ||
| + | } | ||
| + | control.12 { | ||
| + | iface MIXER | ||
| + | name 'AGC Left Switch' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.13 { | ||
| + | iface MIXER | ||
| + | name 'AGC Right Switch' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.14 { | ||
| + | iface MIXER | ||
| + | name 'AGC Target Level' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 7' | ||
| + | } | ||
| + | } | ||
| + | control.15 { | ||
| + | iface MIXER | ||
| + | name 'AGC Gain Hysteresis' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 3' | ||
| + | } | ||
| + | } | ||
| + | control.16 { | ||
| + | iface MIXER | ||
| + | name 'AGC Hysteresis' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 3' | ||
| + | } | ||
| + | } | ||
| + | control.17 { | ||
| + | iface MIXER | ||
| + | name 'AGC Noise Threshold' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 31' | ||
| + | } | ||
| + | } | ||
| + | control.18 { | ||
| + | iface MIXER | ||
| + | name 'AGC Max PGA' | ||
| + | value.0 127 | ||
| + | value.1 127 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 127' | ||
| + | } | ||
| + | } | ||
| + | control.19 { | ||
| + | iface MIXER | ||
| + | name 'AGC Attack Time' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 31' | ||
| + | } | ||
| + | } | ||
| + | control.20 { | ||
| + | iface MIXER | ||
| + | name 'AGC Decay Time' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 31' | ||
| + | } | ||
| + | } | ||
| + | control.21 { | ||
| + | iface MIXER | ||
| + | name 'AGC Noise Debounce' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 31' | ||
| + | } | ||
| + | } | ||
| + | control.22 { | ||
| + | iface MIXER | ||
| + | name 'AGC Signal Debounce' | ||
| + | value.0 0 | ||
| + | value.1 0 | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type INTEGER | ||
| + | count 2 | ||
| + | range '0 - 15' | ||
| + | } | ||
| + | } | ||
| + | control.23 { | ||
| + | iface MIXER | ||
| + | name 'HPL Output Mixer L_DAC Switch' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.24 { | ||
| + | iface MIXER | ||
| + | name 'HPL Output Mixer IN1_L Switch' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.25 { | ||
| + | iface MIXER | ||
| + | name 'LOL Output Mixer L_DAC Switch' | ||
| + | value true | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.26 { | ||
| + | iface MIXER | ||
| + | name 'HPR Output Mixer R_DAC Switch' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.27 { | ||
| + | iface MIXER | ||
| + | name 'HPR Output Mixer IN1_R Switch' | ||
| + | value false | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.28 { | ||
| + | iface MIXER | ||
| + | name 'LOR Output Mixer R_DAC Switch' | ||
| + | value true | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type BOOLEAN | ||
| + | count 1 | ||
| + | } | ||
| + | } | ||
| + | control.29 { | ||
| + | iface MIXER | ||
| + | name 'IN1_R to Right Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.30 { | ||
| + | iface MIXER | ||
| + | name 'IN2_R to Right Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.31 { | ||
| + | iface MIXER | ||
| + | name 'IN3_R to Right Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.32 { | ||
| + | iface MIXER | ||
| + | name 'IN2_L to Right Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.33 { | ||
| + | iface MIXER | ||
| + | name 'IN1_L to Right Mixer Negative Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.34 { | ||
| + | iface MIXER | ||
| + | name 'IN3_L to Right Mixer Negative Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.35 { | ||
| + | iface MIXER | ||
| + | name 'IN1_L to Left Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.36 { | ||
| + | iface MIXER | ||
| + | name 'IN2_L to Left Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.37 { | ||
| + | iface MIXER | ||
| + | name 'IN3_L to Left Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.38 { | ||
| + | iface MIXER | ||
| + | name 'IN1_R to Left Mixer Positive Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.39 { | ||
| + | iface MIXER | ||
| + | name 'IN2_R to Left Mixer Negative Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | control.40 { | ||
| + | iface MIXER | ||
| + | name 'IN3_R to Left Mixer Negative Resistor' | ||
| + | value Off | ||
| + | comment { | ||
| + | access 'read write' | ||
| + | type ENUMERATED | ||
| + | count 1 | ||
| + | item.0 Off | ||
| + | item.1 '10 kOhm' | ||
| + | item.2 '20 kOhm' | ||
| + | item.3 '40 kOhm' | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| - | Another person found that it worked out-of-the-box: | ||
| - | > Copying an audio file (in my case, a 44.1kHz mono WAV file) onto the SD card and then playing it with '' | ||
alsa.1776504564.txt.gz · Last modified: by aaronjamt
