Skip to content

Commit

Permalink
penumbra: independent headphone pcm
Browse files Browse the repository at this point in the history
  • Loading branch information
leo60228 committed Nov 21, 2024
1 parent 4cc7318 commit d8edbb9
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 1 deletion.
246 changes: 246 additions & 0 deletions files/analog-output-speaker-split.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

; Path for mixers that have a 'Speaker' control
;
; See analog-output.conf.common for an explanation on the directives

[General]
priority = 100
description-key = analog-output-speaker

[Properties]
device.icon_name = audio-speakers

[Jack Headphone]
state.plugged = unknown
state.unplugged = unknown

[Jack Dock Headphone]
state.plugged = no
state.unplugged = unknown

[Jack Front Headphone]
state.plugged = no
state.unplugged = unknown

[Jack Line Out]
state.plugged = no
state.unplugged = unknown

[Jack Line Out Front]
state.plugged = no
state.unplugged = unknown

[Jack Front Line Out]
state.plugged = no
state.unplugged = unknown

[Jack Rear Line Out]
state.plugged = no
state.unplugged = unknown

[Jack Dock Line Out]
state.plugged = no
state.unplugged = unknown

[Jack Speaker]
required-any = any

[Jack Speaker Phantom]
required-any = any
state.plugged = unknown
state.unplugged = unknown

[Jack Speaker Front Phantom]
required-any = any
state.plugged = unknown
state.unplugged = unknown

[Jack Speaker - Output]
required-any = any

[Element Hardware Master]
switch = mute
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right

[Element Master]
switch = mute
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right

[Element Master Mono]
switch = off
volume = off

; Make sure the internal speakers are not auto-muted once the system has speakers
[Element Auto-Mute Mode]
enumeration = select

[Option Auto-Mute Mode:Disabled]
name = analog-output-speaker

; This profile path is intended to control the speaker, let's mute headphones
; else there will be a spike when plugging in headphones
;[Element Headphone]
;switch = off
;volume = off

[Element Headphone,1]
switch = off
volume = off

[Element Headphone2]
switch = off
volume = off

[Element Headphone+LO]
switch = off
volume = off

[Element Speaker+LO]
required-any = any
switch = mute
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right

[Element Speaker]
required-any = any
switch = mute
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right

[Element Desktop Speaker]
required-any = any
switch = mute
volume = merge
override-map.1 = all
override-map.2 = all-left,all-right

[Element Front]
switch = mute
volume = merge
override-map.1 = all-front
override-map.2 = front-left,front-right

[Element Front Speaker]
switch = mute
volume = merge
override-map.1 = all-front
override-map.2 = front-left,front-right
required-any = any

[Element Speaker Front]
switch = mute
volume = merge
override-map.1 = all-front
override-map.2 = front-left,front-right
required-any = any

[Element Rear]
switch = mute
volume = merge
override-map.1 = all-rear
override-map.2 = rear-left,rear-right

[Element Surround]
switch = mute
volume = merge
override-map.1 = all-rear
override-map.2 = rear-left,rear-right

[Element Surround Speaker]
switch = mute
volume = merge
override-map.1 = all-rear
override-map.2 = rear-left,rear-right
required-any = any

[Element Speaker Surround]
switch = mute
volume = merge
override-map.1 = all-rear
override-map.2 = rear-left,rear-right
required-any = any

[Element Side]
switch = mute
volume = merge
override-map.1 = all-side
override-map.2 = side-left,side-right

[Element Speaker Side]
switch = mute
volume = merge
override-map.1 = all-side
override-map.2 = side-left,side-right

[Element Center]
switch = mute
volume = merge
override-map.1 = all-center
override-map.2 = all-center,all-center

[Element Center Speaker]
switch = mute
volume = merge
override-map.1 = all-center
override-map.2 = all-center,all-center
required-any = any

[Element LFE]
switch = mute
volume = merge
override-map.1 = lfe
override-map.2 = lfe,lfe

[Element LFE Speaker]
switch = mute
volume = merge
override-map.1 = lfe
override-map.2 = lfe,lfe
required-any = any

[Element Bass Speaker]
switch = mute
volume = merge
override-map.1 = lfe
override-map.2 = lfe,lfe
required-any = any

[Element CLFE]
switch = mute
volume = merge
override-map.1 = all-center
override-map.2 = all-center,lfe

[Element Center/LFE]
switch = mute
volume = merge
override-map.1 = all-center
override-map.2 = all-center,lfe

[Element Speaker CLFE]
switch = mute
volume = merge
override-map.1 = all-center
override-map.2 = all-center,lfe

.include analog-output.conf.common
20 changes: 20 additions & 0 deletions files/hda-jack-retask.fw
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[codec]
0x10ec0295 0xf1110006 0

[pincfg]
0x12 0x90a60130
0x13 0x40000000
0x14 0x90170110
0x16 0x411111f0
0x17 0x411111f0
0x18 0x411111f0
0x19 0x02a1112c
0x1a 0x411111f0
0x1b 0x411111f0
0x1d 0x40661b45
0x1e 0x411111f0
0x21 0x04211020

[hints]
indep_hp=yes
vmaster=no
39 changes: 39 additions & 0 deletions files/split-ports-profile.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
; This will let alsa generate automatic profiles (e.g internal speaker + microphone)
[General]
auto-profiles = yes


; device-strings describes the ALSA device string(s) that PulseAudio uses to open the device, where "%f" specifies the card number (should always be present in the string).

; This is the mapping for the internal speaker
; If needed, change the 0 in "hw:%f,0" to your sub device location
; You can change the description for this and other mappings if you want
; in paths output put the name of the previously created custom mixer path
[Mapping analog-stereo-speaker]
description = Speakers
device-strings = hw:%f,0
paths-output = analog-output-speaker-split
channel-map = left,right
direction = output

; This is the mapping for the jack output (headphones)
; If needed, change the 2 in "hw:%f,2" to your sub device location
; in paths output put the name of the from card details
[Mapping analog-stereo-headphones]
description = Headphones
device-strings = hw:%f,2
paths-output = analog-output-headphones
channel-map = left,right
direction = output


; This is the mapping that will handle internal and external microphones, as you could see in `cat /proc/asound/pcm`, the card also had a capture port
; in the 0,0 sub device location so let's add it here too (change the 0 in "hw:%f,0" to your sub device location that has the capture port)
; All the paths-input names here came from the default.conf profile set and you may have to adapt it if your input port name is not included

[Mapping analog-stereo-input]
description = Microphone
device-strings = hw:%f,0
channel-map = left,right
paths-input = analog-input-front-mic analog-input-rear-mic analog-input-internal-mic analog-input-dock-mic analog-input analog-input-mic analog-input-linein analog-input-aux analog-input-video analog-input-tvtuner analog-input-fm analog-input-mic-line analog-input-headphone-mic analog-input-headset-mic
direction = input
26 changes: 25 additions & 1 deletion hardware/penumbra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
boot.extraModprobeConfig = ''
options cfg80211 ieee80211_regdom="US"
options amdgpu dcdebugmask=0x10
options snd-hda-intel patch=hda-jack-retask.fw,hda-jack-retask.fw,hda-jack-retask.fw,hda-jack-retask.fw power_save=0
'';

fileSystems."/" = {
Expand Down Expand Up @@ -72,7 +73,30 @@

networking.networkmanager.wifi.backend = "iwd";

hardware.framework.laptop13.audioEnhancement.enable = true;
hardware.framework.laptop13.audioEnhancement = {
enable = true;
rawDeviceName = "alsa_output.pci-0000_c1_00.6.analog-stereo-speaker";
};

environment.etc."alsa-card-profile/mixer/paths/analog-output-speaker-split.conf".source = ../files/analog-output-speaker-split.conf;
services.udev.extraRules = ''
SUBSYSTEM!="sound", GOTO="pipewire_end"
ACTION!="change", GOTO="pipewire_end"
KERNEL!="card*", GOTO="pipewire_end"
SUBSYSTEMS=="pci", ATTRS{vendor}=="0x1022", ATTRS{device}=="0x15e3", ENV{ACP_PROFILE_SET}="${../files/split-ports-profile.conf}"
LABEL="pipewire_end"
'';

hardware.firmware = [
(pkgs.runCommand "hda-jack-retask-fw" { } ''
mkdir -p $out/lib/firmware
cp ${../files/hda-jack-retask.fw} $out/lib/firmware/hda-jack-retask.fw
'')
];
hardware.alsa.enablePersistence = true;
systemd.services.alsa-store.serviceConfig.ExecStart = lib.mkForce "-${pkgs.alsa-utils}/sbin/alsactl restore --ignore";

deployment.tags = [ "workstation" ];
deployment.allowLocalDeployment = true;
Expand Down

0 comments on commit d8edbb9

Please sign in to comment.