Skip to content

Month: October 2016

dell xps 13 (9343) combo jack

I’ve been wanting to play around with echolink via qtel, but have been having trouble with the combo jack on my xps 13. When I would plug in a headset, it would see the headphones, but would never see that a mic was available. I think it is a problem with the sound card initialized in I2S mode. According to the Arch wiki, the kernel can be recompiled with the option CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y  and it will force on HDA mode.

Here are the steps that I went through to recompile the kernel using the arch build system.

cd ~
mkdir build
cd build
ABSROOT=. abs core/linux
cd core/linux
vim PKGBUILD

Edit the PKGBUILD  file and change pkgbase. I used pkgbase=linux-custom , then save the file and exit.

vim config.x86_64

Edit config.x86_64  and uncomment CONFIG_ACPI_REV_OVERRIDE_POSSIBLE

Ensure the line says:

CONFIG_ACPI_REV_OVERRIDE_POSSIBLE=y

Save the file and exit.

updpkgsums

Next, you will need to import Linus Torvalds and Greg Kroah-Hartman’s pgp keys as they are the keys used to sign the kernel releases.

gpg --keyserver http://pgp.mit.edu --recv-key 79BE3E4300411886
gpg --keyserver http://pgp.mit.edu --recv-key 38DBBDC86092693E

Now we can compile the kernel.

makepkg -s

That will take some time.

Once it is done, we can install it.

sudo pacman -U linux-custom-headers-4.7.6-1-x86_64.pkg.tar.xz
sudo pacman -U linux-custom-4.7.6-1-x86_64.pkg.tar.xz

Once that is done, you’ll need to edit the bootloader to use the new kernel. I am currently using systemd-boot, so edit /boot/loader/entries/{whatever}.conf

A basic example would look like:

title arch
linux /vmlinuz-linux-custom
initrd /initramfs-linux-custom

Once that is done, reboot the machine twice and the audio should work as expected. If you are using an xps 13, you will probably need to reinstall the wireless drivers.

yaourt -S broadcom-wl

auto switching sinks and sources

Now that the audio works, I wanted it to switch to the headset automatically when the headset was plugged in. I also prefer to have the audio mute when I unplug the headset. To do that, install and enable acpid.

pacman -S acpid

Next, create a script somewhere called headphones.sh  with the contents:

#!/bin/sh

SINK="alsa_output.pci-0000_00_1b.0.analog-stereo"
SINK_PLUG="analog-output-headphones"
SINK_UNPLUG="analog-output-speaker"

SOURCE="alsa_input.pci-0000_00_1b.0.analog-stereo"
SOURCE_PLUG="analog-input-headset-mic"
SOURCE_UNPLUG="analog-input-internal-mic"

USERS="$(ps axc -o command,user | grep pulseaudio | tr -s ' ' | cut -f2 -d ' ' | sort | uniq)"

case "$1" in jack/headphone)
    case "$2" in HEADPHONE)
        case "$3" in
            unplug)
                logger "Headphones unplugged"
                for user in $USERS;
                do
                    PULSE_RUNTIME_PATH=/run/user/$(id -u $user)/pulse su $user -c "pacmd set-sink-port $SINK $SINK_UNPLUG"
                    PULSE_RUNTIME_PATH=/run/user/$(id -u $user)/pulse su $user -c "pacmd set-source-port $SOURCE $SOURCE_UNPLUG"
                done
                amixer set Master mute
                ;;
            plug) 
                logger "Headphones plugged"
                for user in $USERS;
                do
                    PULSE_RUNTIME_PATH=/run/user/$(id -u $user)/pulse su $user -c "pacmd set-sink-port $SINK $SINK_PLUG"
                    PULSE_RUNTIME_PATH=/run/user/$(id -u $user)/pulse su $user -c "pacmd set-source-port $SOURCE $SOURCE_PLUG"
                done
                amixer set Master unmute
                amixer set Headphone unmute
                ;;
        esac
    esac
esac

Next, open /etc/acpi/events/anything  and comment everything out.

Then create /etc/acpi/events/headphone-jack  with the contents:

event=jack/headphone
action=/path/to/script/headphones.sh %e

Then enable and start the acpid service and when you plug in your headset, the audio sink and source should switch to the headset and when the headset is unplugged, it will mute the audio and switch back to the internal speakers and mic.

 

 

Comments closed