[pulseaudio-discuss] Setting gain when plugging headphone on (non-simple) ALSA controls

Sylvain Bougerel sylvain.bougerel at gmail.com
Wed Jan 20 04:07:33 PST 2016


Hi all,

I have a problem of hearing white-noise on my headphones when I plug them
in my laptop. I know the work around:

$ amixer -c 0 cset 'numid=10' 1
numid=10,iface=MIXER,name='Headphone Mic Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  : values=1,1
  | dBscale-min=0.00dB,step=10.00dB,mute=0

OR

$ amixer -c0 sset 'Headphone Mic Boost' 1
Simple mixer control 'Headphone Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 1 [33%] [10.00dB]
  Front Right: 1 [33%] [10.00dB]

Done, no more white noise. It's all well, but the settings are not
remembered; every time pulseaudio restarts (when I login to my Desktop,
basically):

$ amixer -c 0 cget 'numid=10'
numid=10,iface=MIXER,name='Headphone Mic Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  : values=0,0
  | dBscale-min=0.00dB,step=10.00dB,mute=0

Notice the 0,0? And the white noise is back.

So my end goal is to find my way into hacking pulseaudio so that this is
taken care of without having to do it myself via command line everytime I
use my headphones.

That's where my understanding of things starts to break down. Basically, I
think it's not possible to control this property in pulseaudio at the
moment, so I may need to write/update a module (frankly I'm not actually
sure of that - but I'm not afraid of coding C). I started reading the
coding page on the pulseaudio modules of freedesktop.org, but that did not
really inspire me to find a solution to my issue. So I would like to know
if one of you could guide me a bit.

To help you guide me, I dump the output of a few commands, which I hope
you'll find useful.

Looking forward to hearing from you soon,
Sylvain

$ amixer scontents
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 19526 [30%] [on]
  Front Right: Playback 19526 [30%] [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 3381 [5%] [off]
  Front Right: Capture 3381 [5%] [off]

$ amixer -c0 scontents
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 87
  Mono: Playback 45 [52%] [-31.50dB] [on]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Headphone Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [off]
Simple mixer control 'Headphone Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 1 [33%] [10.00dB]
  Front Right: 1 [33%] [10.00dB]
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 0 [0%] [-65.25dB] [off]
  Front Right: Playback 0 [0%] [-65.25dB] [off]
Simple mixer control 'PCM',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 255 [100%] [0.00dB]
  Front Right: Playback 255 [100%] [0.00dB]
Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [off]
Simple mixer control 'IEC958',1
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958',2
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 63
  Front Left: Capture 0 [0%] [-17.25dB] [off]
  Front Right: Capture 0 [0%] [-17.25dB] [off]
Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'
Simple mixer control 'Headset Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [off]
Simple mixer control 'Headset Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Internal Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [on]
Simple mixer control 'Internal Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]

$ pacmd list-cards
1 card(s) available.
    index: 0
name: <alsa_card.pci-0000_00_1f.3>
driver: <module-alsa-card.c>
owner module: 6
properties:
alsa.card = "0"
alsa.card_name = "HDA Intel PCH"
alsa.long_card_name = "HDA Intel PCH at 0xdc728000 irq 284"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:1f.3"
sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "9d70"
device.form_factor = "internal"
device.string = "0"
device.description = "Built-in Audio"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
profiles:
input:analog-stereo: Analog Stereo Input (priority 60, available: unknown)
output:analog-stereo: Analog Stereo Output (priority 6000, available:
unknown)
output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority
6060, available: unknown)
output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5400, available:
unknown)
output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Output +
Analog Stereo Input (priority 5460, available: unknown)
output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 300,
available: unknown)
output:hdmi-surround+input:analog-stereo: Digital Surround 5.1 (HDMI)
Output + Analog Stereo Input (priority 360, available: unknown)
output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 300,
available: unknown)
output:hdmi-surround71+input:analog-stereo: Digital Surround 7.1 (HDMI)
Output + Analog Stereo Input (priority 360, available: unknown)
output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5200,
available: unknown)
output:hdmi-stereo-extra1+input:analog-stereo: Digital Stereo (HDMI 2)
Output + Analog Stereo Input (priority 5260, available: unknown)
output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (priority
100, available: unknown)
output:hdmi-surround-extra1+input:analog-stereo: Digital Surround 5.1 (HDMI
2) Output + Analog Stereo Input (priority 160, available: unknown)
output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output
(priority 100, available: unknown)
output:hdmi-surround71-extra1+input:analog-stereo: Digital Surround 7.1
(HDMI 2) Output + Analog Stereo Input (priority 160, available: unknown)
output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5200,
available: unknown)
output:hdmi-stereo-extra2+input:analog-stereo: Digital Stereo (HDMI 3)
Output + Analog Stereo Input (priority 5260, available: unknown)
output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority
100, available: unknown)
output:hdmi-surround-extra2+input:analog-stereo: Digital Surround 5.1 (HDMI
3) Output + Analog Stereo Input (priority 160, available: unknown)
output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output
(priority 100, available: unknown)
output:hdmi-surround71-extra2+input:analog-stereo: Digital Surround 7.1
(HDMI 3) Output + Analog Stereo Input (priority 160, available: unknown)
off: Off (priority 0, available: unknown)
active profile: <output:analog-stereo+input:analog-stereo>
sinks:
alsa_output.pci-0000_00_1f.3.analog-stereo/#0: Built-in Audio Analog Stereo
sources:
alsa_output.pci-0000_00_1f.3.analog-stereo.monitor/#0: Monitor of Built-in
Audio Analog Stereo
alsa_input.pci-0000_00_1f.3.analog-stereo/#1: Built-in Audio Analog Stereo
ports:
analog-input-internal-mic: Internal Microphone (priority 8900, latency
offset 0 usec, available: unknown)
properties:
device.icon_name = "audio-input-microphone"
analog-input-headphone-mic: Microphone (priority 8700, latency offset 0
usec, available: unknown)
properties:
device.icon_name = "audio-input-microphone"
analog-input-headset-mic: Headset Microphone (priority 8700, latency offset
0 usec, available: unknown)
properties:
device.icon_name = "audio-input-microphone"
analog-output-speaker: Speakers (priority 10000, latency offset 0 usec,
available: unknown)
properties:
device.icon_name = "audio-speakers"
analog-output-headphones: Headphones (priority 9000, latency offset 0 usec,
available: yes)
properties:
device.icon_name = "audio-headphones"
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec,
available: no)
properties:
device.icon_name = "video-display"
hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec,
available: no)
properties:
device.icon_name = "video-display"
hdmi-output-2: HDMI / DisplayPort 3 (priority 5700, latency offset 0 usec,
available: no)
properties:
device.icon_name = "video-display"

$ pacmd list-sinks
1 sink(s) available.
  * index: 0
name: <alsa_output.pci-0000_00_1f.3.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
DYNAMIC_LATENCY
state: RUNNING
suspend cause:
priority: 9959
volume: front-left: 19526 /  30% / -31.55 dB,   front-right: 19526 /  30% /
-31.55 dB
       balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 979.64 ms
max request: 168 KiB
max rewind: 344 KiB
monitor source: 0
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
            Stereo
used by: 1
linked by: 1
configured latency: 980.00 ms; range is 0.50 .. 2000.00 ms
card: 0 <alsa_card.pci-0000_00_1f.3>
module: 6
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC3246 Analog"
alsa.id = "ALC3246 Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "HDA Intel PCH"
alsa.long_card_name = "HDA Intel PCH at 0xdc728000 irq 284"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:1f.3"
sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "9d70"
device.form_factor = "internal"
device.string = "front:0"
device.buffering.buffer_size = "352800"
device.buffering.fragment_size = "176400"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "Built-in Audio Analog Stereo"
alsa.mixer_name = "Realtek ALC3246"
alsa.components = "HDA:10ec0256,10280704,00100002
HDA:80862809,80860101,00100000"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
analog-output-speaker: Speakers (priority 10000, latency offset 0 usec,
available: unknown)
properties:
device.icon_name = "audio-speakers"
analog-output-headphones: Headphones (priority 9000, latency offset 0 usec,
available: yes)
properties:
device.icon_name = "audio-headphones"
active port: <analog-output-headphones>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20160120/ad75adaa/attachment-0001.html>


More information about the pulseaudio-discuss mailing list