Subject: Bug#904437: Fix for pin mapping on HP EliteBook x360 1020 G2

From: Enrico Zini <[email-masked]>
Date: Tue, 24 Jul 2018 18:29:55 +0800

Package: alsa-utils
Version: 1.1.6-1
Severity: normal

Hello,

I have this issue in my EliteBook as well:
https://ubuntuforums.org/showthread.php?t=2317239
that is, when plugging in headphones, the audio for the speakers is not
muted, only lowered a bit.

I tried hda-analyzer and generated this pin mapping fix script:

   #!/usr/bin/env python
   
   import os
   import struct
   from fcntl import ioctl
   
   def __ioctl_val(val):
     # workaround for OverFlow bug in python 2.4
     if val & 0x80000000:
       return -((val^0xffffffff)+1)
     return val
   
   IOCTL_INFO = __ioctl_val(0x80dc4801)
   IOCTL_PVERSION = __ioctl_val(0x80044810)
   IOCTL_VERB_WRITE = __ioctl_val(0xc0084811)
   
   def set(nid, verb, param):
     verb = (nid << 24) | (verb << 8) | param
     res = ioctl(FD, IOCTL_VERB_WRITE, struct.pack('II', verb, 0))  
   
   FD = os.open("/dev/snd/hwC0D0", os.O_RDONLY)
   info = struct.pack('Ii64s80si64s', 0, 0, '', '', 0, '')
   res = ioctl(FD, IOCTL_INFO, info)
   name = struct.unpack('Ii64s80si64s', res)[3]
   if not name.startswith('HDA Codec'):
     raise IOError, "unknown HDA hwdep interface"
   res = ioctl(FD, IOCTL_PVERSION, struct.pack('I', 0))
   version = struct.unpack('I', res)
   if version < 0x00010000:	# 1.0.0
     raise IOError, "unknown HDA hwdep version"
   
   # initialization sequence starts here...
   
   set(0x17, 0x701,   0x01) # 0x17070101 (SET_CONNECT_SEL)
   
   os.close(FD)

I'd like to report this so that it can eventually make its way upstream.
I don't know what extra information to provide to that end.

I tried https://bugtrack.alsa-project.org/alsa-bug (linked from
https://bugtrack.alsa-project.org/main/index.php/Main_Page) but it gives
error 404, so I'm falling back here.

Enrico

-- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 4.17.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8), LANGUAGE=en_IE:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages alsa-utils depends on:
ii  kmod              25-1
ii  libasound2        1.1.6-1
ii  libc6             2.27-5
ii  libfftw3-single3  3.3.8-1
ii  libncursesw6      6.1+20180714-1
ii  libsamplerate0    0.1.9-2
ii  libtinfo6         6.1+20180714-1
ii  lsb-base          9.20170808
ii  whiptail          0.52.20-5

alsa-utils recommends no packages.

alsa-utils suggests no packages.

-- no debconf information