Cape4all Alsa Control Registers - HoerTech-gGmbH/Cape4all Wiki

Introduction

The following table contains a list which control registers of the ADAU1761 codec can be set with which alsa controls.

Alsa has 2 names for each control, a simple mixer control name (alsa simple) and a card control name (alsa control).

alsamixer shows the simple mixer control names. amixer can use both. The alsa control names are specified by the driver as such. The simple names are derived from the control names by leaving out recognized parts of the name.

The names given in the following table need to be prepended by "C0 ", "C1 ", "C2 " to choose which of the codecs should be influenced.

Some alsa controls control both a left and a right channel.

Recipies how to use amixer:

With simple mixer controls:

amixer set "simple name" -- value

  • value can be given as:
    • <INT>: directly give the value that is written into the codec's bits. Alsa will perform any necessary left shift, not you, see last section on this page.
    • <INT>%: Map the percentage to the range of possible hardware values
    • <FLOAT>dB: For volume controls, values can be given in dB
    • off, mute: mute or switch off
    • on: unmute or switch on
  • When an amixer simple control controls 2 channels, then
    • giving a single value sets both channels to the same value
    • 2 different values can be given as two of the above values separated by comma: valueL,valueR
    • Only the left value can be set by giving valueL, (that's valueL-comma-nothing)
    • Only the right value can be set by giving the value as 0+,valueR (that's zero-plus-comma-valueR)

With card controls:

amixer cset name="control name" -- value

  • value can only be given as
    • <INT>: directly give the value that is written into the codec's bits, as above. See last section on this page about not shifting left.
    • on
    • off or mute
  • When an amixer card control controls 2 channels, then
    • giving a single value sets both channels to the same value
    • 2 different values can be given as two of the above values separated by comma: valueL,valueR
    • Only the left value can be set by giving valueL, (that's valueL-comma-nothing)
    • Only the right value can be set by giving the value as ,valueR (that's nothing-comma-valueR)

When to use which set of controls

Using the simple alsa names is preferable when we want to set a value in dB. Using the control names is preferable when

  • Two different alsa card control names are mapped to the same alsa simple name, so that one of these two controls cannot be set with alsa simple
  • When only the right channel of a stereo control should be influenced and the 0+,valueR specification is too unreadable.

Table with Register Mappings

Register adau1761.c #DEFINE alsa simple alsa control C DS name E mask
               
0x4000 ADAU17X1_CLOCK_CONTROL N/A N/A   CLKSRC   0x08
    N/A N/A   INFREQ   0x06
    N/A N/A   COREN   0x01
0x4002 N/A N/A N/A   PLL Control   N/A
0x4008 ADAU1761_DIGMIC_JACKDETECT N/A N/A   JDDB   0xC0
    N/A* N/A*   JDFUNC   0x30
    N/A N/A   JDPOL   0x01
0x4009 ADAU17X1_REC_POWER_MGMT   Capture Boost   MXBIAS   0x60
      ADC Bias   ADCBIAS   0x18
      Capture Bias   RBIAS   0x06
0x400a ADAU1761_REC_MIXER_LEFT0 Input 1 Input 1 Capture Volume 1 LINPG S 0x70
    Input 2 Input 2 Capture Volume 1 LINNG S 0x0E
    (set by DAPM) (set by DAPM) 1 MX1EN   0x01
0x400b ADAU1761_REC_MIXER_LEFT1 PGA Boost PGA Boost Capture Volume 2 LDBOOST D 0x18
    Aux Aux Capture Volume 2 MX1AUXG   0x07
0x400c ADAU1761_REC_MIXER_RIGHT0 Input 3 Input 3 Capture Volume 1 RINPG S 0x70
    Input 4 Input 4 Capture Volume 1 RINNG S 0x0E
    (set by DAPM) (set by DAPM) 1 MX2EN   0x01
0x400d ADAU1761_REC_MIXER_RIGHT1 PGA Boost PGA Boost Capture Volume 2 RDBOOST D 0x18
    Aux Aux Capture Volume 2 MX2AUXG   0x07
0x400e ADAU1761_LEFT_DIFF_INPUT_VOL "" Capture Volume 2 LDVOL D 0xFC
    "" Capture Switch 2 LDMUTE D 0x02
    Capture Differential Capture Differential Switch 2 LDEN D 0x01
0x400f ADAU1761_RIGHT_DIFF_INPUT_VOL "" Capture Volume 2 RDVOL D 0xFC
    "" Capture Switch 2 RDMUTE D 0x02
    Capture Differential Capture Differential Switch 2 RDEN D 0x01
0x4010 ADAU17X1_MICBIAS   Mic Bias Mode   MPERF   0x08
      N/A   MBI   0x04
      (set by DAPM)   MBIEN   0x01
0x4011 N/A N/A N/A   ALC ctrl 0   N/A
0x4012 N/A N/A N/A   ALC ctrl 1   N/A
0x4013 N/A N/A N/A   ALC ctrl 2   N/A
0x4014 N/A N/A N/A   ALC ctrl 3   N/A
0x4015 ADAU17X1_SERIAL_PORT0 N/A N/A   Serial 0   N/A
0x4016 ADAU17X1_SERIAL_PORT1 N/A N/A   Serial 1   N/A
0x4017 ADAU17X1_CONVERTER0 N/A N/A   Converter 0   N/A
0x4018 ADAU17X1_CONVERTER1 N/A N/A   Converter 1   N/A
0x4019 ADAU17X1_ADC_CONTROL N/A N/A   ADCPOL   0x40
      ADC High Pass Filter Switch   HPF   0x20
    N/A N/A   DMPOL   0x10
    N/A N/A   DMSW   0x08
    N/A N/A   INSEL   0x04
    (set by DAPM) (set by DAPM)   ADCEN   0x03
0x401A ADAU17X1_LEFT_INPUT_DIGITAL_VOL   Digital Capture Volume 2 LADVOL   0xFF
0x401B ADAU17X1_RIGHT_INPUT_DIGITAL_VOL   Digital Capture Volume 2 RADVOL   0xFF
0x401C ADAU1761_PLAY_MIXER_LEFT0   Left Playback Mixer Right DAC Switch 1 MX3RM   0x40
      Left Playback Mixer Left DAC Switch 1 MX3LM   0x20
      Left Playback Mixer Aux Bypass Volume 1 MX3AUXG   0x1E
      (set by DAPM)   MX3EN   0x01
0x401D ADAU1761_PLAY_MIXER_LEFT1   Left Playback Mixer Right Bypass Volume 1 MX3G2   0xF0
      Left Playback Mixer Left Bypass Volume 1 MX3G1   0x0F
0x401E ADAU1761_PLAY_MIXER_RIGHT0   Right Playback Mixer Right DAC Switch 1 MX4RM   0x40
      Right Playback Mixer Left DAC Switch 1 MX4LM   0x20
      Right Playback Mixer Aux Bypass Volume 1 MX4AUXG   0x1E
      (set by DAPM)   MX4EN   0x01
0x401F ADAU1761_PLAY_MIXER_LEFT1   Right Playback Mixer Right Bypass Volume 1 MX4G2   0xF0
      Right Playback Mixer Left Bypass Volume 1 MX4G1   0x0F
0x4020 ADAU1761_PLAY_LR_MIXER_LEFT   Left LR Playback Mixer Right Volume 1 MX5G4   0x18
      Left LR Playback Mixer Left Volume 1 MX5G3   0x06
      (set by DAPM)   MX5EN   0x01
0x4021 ADAU1761_PLAY_LR_MIXER_RIGHT   Right LR Playback Mixer Right Volume 1 MX6G4   0x18
      Right LR Playback Mixer Left Volume 1 MX6G3   0x06
      (set by DAPM)   MX6EN   0x01
0x4022 ADAU1761_PLAY_MIXER_MONO N/A* N/A* 1 MX7   0x06
      (set by DAPM)   MX7EN   0x01
0x4023 ADAU1761_PLAY_HP_LEFT_VOL Headphone Headphone Playback Volume 2 LHPVOL   0xFC
    Headphone Headphone Playback Switch 2 LHPM   0x02
    automatic 1 (or-ed with HPMODE)   HPEN   0x01
0x4024 ADAU1761_PLAY_HP_RIGHT_VOL Headphone Headphone Playback Volume 2 RHPVOL   0xFC
    Headphone Headphone Playback Switch 2 RHPM   0x02
    automatic 1 (HPMODE: default is 1) 2 HPMODE   0x01
0x4025 ADAU1761_PLAY_LINE_LEFT_VOL   Lineout Playback Volume 2 LOUTVOL   0xFC
      Lineout Playback Switch 2 LOUTM   0x02
      Lineout Playback HeadphoneMode 2 LOMODE   0x01
0x4026 ADAU1761_PLAY_LINE_RIGHT_VOL   Lineout Playback Volume 2 ROUTVOL   0xFC
      Lineout Playback Switch 2 ROUTM   0x02
      Lineout Playback HeadphoneMode 2 ROMODE   0x01
0x4027 ADAU1761_PLAY_MONO_OUTPUT_VOL   Mono Playback Volume 1 MONOVOL   0xFC
      Mono Playback Switch 1 MONOM   0x02
      N/A* 2 MOMODE   0x01
0x4028 ADAU1761_POP_CLICK_SUPPRESS N/A N/A   POPMODE   0x10
    N/A N/A   POPLESS   0x08
    N/A N/A   ASLEW   0x06
0x4029 ADAU17X1_PLAY_POWER_MGMT   Headphone Bias   HPBIAS   0xC0
      DAC Bias   DACBIAS   0x30
      Playback Bias   PBIAS   0x0C
    N/A N/A   PREN   0x02
    N/A N/A   PLEN   0x01
0x402A ADAU17X1_DAC_CONTROL0   DAC Mono-Stereo-Mode   DACMONO   0xC0
    N/A N/A   DACPOL   0x20
      Playback De-emphasis Switch   DEMPH   0x04
      (set by DAPM)   DACEN   0x03
0x402B ADAU17X1_DAC_CONTROL1   Digital Playback Volume   LDAVOL   0xFF
0x402C ADAU17X1_DAC_CONTROL2   Digital Playback Volume   RDAVOL   0xFF
0x402D ADAU17X1_SERIAL_PORT_PAD N/A N/A   Serial Pad    
0x402F ADAU17X1_CONTROL_PORT_PAD0 N/A N/A   Serial Pad0    
0x4030 ADAU17X1_CONTROL_PORT_PAD1 N/A N/A   Serial Pad1    
0x4031 ADAU1761_JACK_DETECT_PIN N/A N/A   JDSTR   0x20
    N/A N/A   JDP   0x0C
0x4036 ADAU1761_DEJITTER N/A N/A   DEJIT   0xFF

Remarks:

  • Table cell for alsa simple name is empty: I have not bothered finding out the alsa simple name. You can add it when you find it out.
  • Alsa simple name is "": Use alsa simple names C0, C1, or C2 without a space to use these.
  • N/A* : The trailing asterisk means, the driver has a control for this, but does not activate it in the Cape4all configuration.
  • When column C contains 2, then this is a stereo alsa control, and the alsa control controls 2 hardware registers. Find the register for the other side by searching for the other table row with the same alsa control name.
  • DS Name: name of the control in the ADAU1761 data sheet.
  • E: Endedness. Some controls as intended for differential microphones (D), some are intended for single-ended microphones (S). Replace "microphones" with other sound hardware as applicable.
  • Mask: unimportant, do not let this value bother you. It is the bit mask that isolates this control from the full byte. Not needed for amixer operations.
  • DAPM: Dynamic Audio Power Management

Example amixer invocations

All examples affect codec C0. They can be adapted to affect C1 or C2.

# Bits 3-4 in 400b set LDBOOST, same bits in 400d set RDBOOST.  
# They allow 3 settings: mute, 0dB, 20dB. Set both to +20dB
amixer set "C0 PGA Boost" -- 20dB
# Set LDBOOST to 0dB and RDBOOST to mute
amixer set "C0 PGA Boost" -- 0dB,-999dB
# Leave LDBOOST unchanged, set RDBOOST to 20dB
amixer set "C0 PGA Boost" -- 0+,20dB
# Set both to mute
amixer set "C0 PGA Boost" -- 0,-999dB

# Bit 1 in 400e sets LDMUTE, in 400f sets RDMUTE.
# These are independent mute switches in differential paths.
# Set the left to mute, leave the right unchanged
amixer cset name="C0 Capture Switch" mute,
# Set both to mute
amixer cset name="C0 Capture Switch" mute

# Set only the right one to unmute
amixer cset name="C0 Capture Switch" ,on # use "on" instead of "unmute"
# or
amixer cset name="C0 Capture Switch" ,1

Example for setting an INT value without left shifting

Suppose you want to set the RINPG value of codec C2 to -3dB using the INT value method. This is your workflow:

  1. Find the description of RINPG in the data sheet https://www.analog.com/media/en/technical-documentation/data-sheets/ADAU1761.pdf. It is the "Gain for a right channel single-ended input from the RINP pin, input to Mixer 2". It is located in the 3 bits [6:4] of the register at 0x400C.
  2. Find the necessary bit pattern that you need to set these bits to. The data sheet shows that -3dB corresponds to bit pattern: 100 (Set bit 6 to one, set bits 5 and 4 to zero).
  3. Translate the bit pattern to an int. binary number "100" has value 4 (= 0*1 + 0*2 + 1*4).
    • If you were the driver you would need to left shift this value 4 by four bits, so that you are actually setting Bits 4-6 and not Bits 0-2. You would also take care not to alter the values of the other bits in the same byte.
    • But when using amixer, then you are not responsible for the left shift nor for caring about the other bits in the same byte. The alsa driver will take care of this for you.
    • Stick to the value 4 from the bit pattern "100". Do not alter your number. Do not shift bits.
  4. Find out the alsa names for RINPG by searching the table above:
    • The simple name is "Input 3". The card control name is "Input 3 Capture Volume"
    • Notice that this is is not mapped as a stereo control, but as a single-channel control: Column C of our table contains a "1".
  5. Set this value with amixer set or amixer cset:
amixer set "C2 Input 3" -- 4
amixer cset "C2 Input 3 Capture Volume" -- 4
⚠️ **GitHub.com Fallback** ⚠️