luisbocanegra / linux-guide-split-audio-ports

Split jack(headphones)/speakers outputs into individual sinks on Linux to allow simultaneous playback (listen to different audio streams on each port)
30 stars 3 forks source link

what should I do if the directory doesnt exist? #12

Open Shmerlard opened 2 months ago

Shmerlard commented 2 months ago

what should I do if directory /etc/alsa-card-profile/mixer/paths/ doesn't exist? if i create one then after the command sudo cp -r /usr/share/alsa-card-profile/mixer/paths/ /etc/alsa-card-profile/mixer/paths/ there are a paths folder inside a path folder, I dont think thats what you meant

OS: Debian GNU/Linux 12 (bookworm) x86_64 
Host: 81LG Lenovo IdeaPad L340-15IWL 
Kernel: 6.1.0-18-amd64 
KDE plasma version: 5.27.5
Codec: Realtek ALC257
Address: 0
Vendor Id: 0x10ec0257
Subsystem Id: 0x17aa3811
Codec: Intel Kabylake HDMI
Address: 2
Vendor Id: 0x8086280b
Subsystem Id: 0x80860101
Card #42
        Name: alsa_card.pci-0000_00_1f.3
        Driver: alsa
        Owner Module: n/a
        Properties:
                api.acp.auto-port = "false"
                api.acp.auto-profile = "false"
                api.alsa.card = "0"
                api.alsa.card.longname = "HDA Intel PCH at 0xa421c000 irq 142"
                api.alsa.card.name = "HDA Intel PCH"
                api.alsa.path = "hw:0"
                api.alsa.use-acp = "true"
                api.dbus.ReserveDevice1 = "Audio0"
                device.api = "alsa"
                device.bus = "pci"
                device.bus_path = "pci-0000:00:1f.3"
                device.description = "Built-in Audio"
                device.enum.api = "udev"
                device.form_factor = "internal"
                device.icon_name = "audio-card-analog-pci"
                device.name = "alsa_card.pci-0000_00_1f.3"
                device.nick = "HDA Intel PCH"
                device.plugged.usec = "6160968"
                device.product.id = "0x9dc8"
                device.product.name = "Cannon Point-LP High Definition Audio Controller"
                device.subsystem = "sound"
                sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
                device.vendor.id = "0x8086"
                device.vendor.name = "Intel Corporation"
                media.class = "Audio/Device"
                factory.id = "14"
                client.id = "34"
                object.id = "42"
                object.serial = "42"
                object.path = "alsa:pcm:0"
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.long_card_name = "HDA Intel PCH at 0xa421c000 irq 142"
                alsa.driver_name = "snd_hda_intel"
                device.string = "0"
        Profiles:
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
                output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (sinks: 1, sources: 1, priority: 6565, available: yes)
                output:analog-stereo: Analog Stereo Output (sinks: 1, sources: 0, priority: 6500, available: yes)
                output:hdmi-stereo+input:analog-stereo: Digital Stereo (HDMI) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 5965, available: yes)
                output:hdmi-stereo: Digital Stereo (HDMI) Output (sinks: 1, sources: 0, priority: 5900, available: yes)
                output:hdmi-stereo-extra1+input:analog-stereo: Digital Stereo (HDMI 2) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 5765, available: no)
                output:hdmi-stereo-extra2+input:analog-stereo: Digital Stereo (HDMI 3) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 5765, available: no)
                output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (sinks: 1, sources: 0, priority: 5700, available: no)
                output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (sinks: 1, sources: 0, priority: 5700, available: no)
                output:hdmi-surround-extra1+input:analog-stereo: Digital Surround 5.1 (HDMI 2) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 665, available: no)
                output:hdmi-surround71-extra1+input:analog-stereo: Digital Surround 7.1 (HDMI 2) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 665, available: no)
                output:hdmi-surround-extra2+input:analog-stereo: Digital Surround 5.1 (HDMI 3) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 665, available: no)
                output:hdmi-surround71-extra2+input:analog-stereo: Digital Surround 7.1 (HDMI 3) Output + Analog Stereo Input (sinks: 1, sources: 1, priority: 665, available: no)
                output:hdmi-surround-extra1: Digital Surround 5.1 (HDMI 2) Output (sinks: 1, sources: 0, priority: 600, available: no)
                output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (sinks: 1, sources: 0, priority: 600, available: no)
                output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (sinks: 1, sources: 0, priority: 600, available: no)
                output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (sinks: 1, sources: 0, priority: 600, available: no)
                input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority: 65, available: yes)
                pro-audio: Pro Audio (sinks: 4, sources: 1, priority: 1, available: yes)
        Active Profile: output:analog-stereo+input:analog-stereo
        Ports:
                analog-input-internal-mic: Internal Microphone (type: Mic, priority: 8900, latency offset: 0 usec, availability group: Legacy 1, not available)
                        Properties:
                                port.type = "mic"
                                port.availability-group = "Legacy 1"
                                device.icon_name = "audio-input-microphone"
                                card.profile.port = "0"
                        Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:hdmi-stereo+input:analog-stereo, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1+input:analog-stereo, output:hdmi-surround71-extra1+input:analog-stereo, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2+input:analog-stereo, output:hdmi-surround71-extra2+input:analog-stereo
                analog-input-mic: Microphone (type: Mic, priority: 8700, latency offset: 0 usec, availability group: Legacy 2, available)
                        Properties:
                                port.type = "mic"
                                port.availability-group = "Legacy 2"
                                device.icon_name = "audio-input-microphone"
                                card.profile.port = "1"
                        Part of profile(s): input:analog-stereo, output:analog-stereo+input:analog-stereo, output:hdmi-stereo+input:analog-stereo, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1+input:analog-stereo, output:hdmi-surround71-extra1+input:analog-stereo, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2+input:analog-stereo, output:hdmi-surround71-extra2+input:analog-stereo
                analog-output-speaker: Speakers (type: Speaker, priority: 10000, latency offset: 0 usec, availability group: Legacy 3, not available)
                        Properties:
                                port.type = "speaker"
                                port.availability-group = "Legacy 3"
                                device.icon_name = "audio-speakers"
                                card.profile.port = "2"
                        Part of profile(s): output:analog-stereo, output:analog-stereo+input:analog-stereo
                analog-output-headphones: Headphones (type: Headphones, priority: 9900, latency offset: 0 usec, availability group: Legacy 4, available)
                        Properties:
                                port.type = "headphones"
                                port.availability-group = "Legacy 4"
                                device.icon_name = "audio-headphones"
                                card.profile.port = "3"
                        Part of profile(s): output:analog-stereo, output:analog-stereo+input:analog-stereo
                hdmi-output-0: HDMI / DisplayPort (type: HDMI, priority: 5900, latency offset: 0 usec, availability group: Legacy 5, available)
                        Properties:
                                port.type = "hdmi"
                                port.availability-group = "Legacy 5"
                                device.icon_name = "video-display"
                                card.profile.port = "4"
                                device.product.name = "24E1W1"
                        Part of profile(s): output:hdmi-stereo, output:hdmi-stereo+input:analog-stereo
                hdmi-output-1: HDMI / DisplayPort 2 (type: HDMI, priority: 5800, latency offset: 0 usec, availability group: Legacy 6, not available)
                        Properties:
                                port.type = "hdmi"
                                port.availability-group = "Legacy 6"
                                device.icon_name = "video-display"
                                card.profile.port = "5"
                        Part of profile(s): output:hdmi-stereo-extra1, output:hdmi-stereo-extra1+input:analog-stereo, output:hdmi-surround-extra1, output:hdmi-surround-extra1+input:analog-stereo, output:hdmi-surround71-extra1, output:hdmi-surround71-extra1+input:analog-stereo
                hdmi-output-2: HDMI / DisplayPort 3 (type: HDMI, priority: 5700, latency offset: 0 usec, availability group: Legacy 7, not available)
                        Properties:
                                port.type = "hdmi"
                                port.availability-group = "Legacy 7"
                                device.icon_name = "video-display"
                                card.profile.port = "6"
                        Part of profile(s): output:hdmi-stereo-extra2, output:hdmi-stereo-extra2+input:analog-stereo, output:hdmi-surround-extra2, output:hdmi-surround-extra2+input:analog-stereo, output:hdmi-surround71-extra2, output:hdmi-surround71-extra2+input:analog-stereo
luisbocanegra commented 2 months ago

what should I do if directory /etc/alsa-card-profile/mixer/paths/ doesn't exist? if i create one then after the command sudo cp -r /usr/share/alsa-card-profile/mixer/paths/ /etc/alsa-card-profile/mixer/paths/ there are a paths folder inside a path folder, I dont think thats what you meant

Yes, the folder should be created, I have fixed the copy command and made some things clearer, thanks for the observation. Can you try again?

This is how the file structure should look like after completing the guide (and replacing with your card information):

$ tree /etc/alsa-card-profile
/etc/alsa-card-profile
└── mixer
    ├── paths
    │   ├── analog-output.conf.common
    │   └── analog-output-speaker-split.conf
    └── profile-sets
        └── split-ports-profile.conf

4 directories, 3 files
$ cat /lib/firmware/hda-jack-retask.fw
[codec]
0x10ec0295 0x103c8575 0

[verb]
0x20 0x500 0x67
0x20 0x400 0x3200

[hints]
indep_hp=yes
vmaster=no
$ cat /etc/udev/rules.d/91-pipewire-alsa-port-split.rules
SUBSYSTEM!="sound", GOTO="pipewire_end"
ACTION!="change", GOTO="pipewire_end"
KERNEL!="card*", GOTO="pipewire_end"

SUBSYSTEMS=="pci", ATTRS{vendor}=="0x8086", ATTRS{device}=="0xa348", \
ENV{ACP_PROFILE_SET}="/etc/alsa-card-profile/mixer/profile-sets/split-ports-profile.conf"

# Use this instead for immutable distributions
# SUBSYSTEMS=="pci", ATTRS{vendor}=="0x8086", ATTRS{device}=="0xa348", \
# ENV{ACP_PROFILE_SET}="/etc/alsa-card-profile/mixer/profile-sets/split-ports-profile.conf", \
# RUN+="/usr/local/bin/alsa-split-ports.sh"

LABEL="pipewire_end"
$ cat /etc/modprobe.d/alsa-base.conf
options snd-hda-intel patch=hda-jack-retask.fw
Shmerlard commented 2 months ago

when I'm running pactl list sinks i get:

        State: SUSPENDED
        Name: alsa_output.pci-0000_00_1f.3.analog-stereo
        Description: Built-in Audio Analog Stereo
        Driver: PipeWire
        Sample Specification: s32le 2ch 48000Hz
        Channel Map: front-left,front-right
        Owner Module: 4294967295
        Mute: no
        Volume: front-left: 14418 /  22% / -39.45 dB,   front-right: 14418 /  22% / -39.45 dB
                balance 0.00
        Base Volume: 65536 / 100% / 0.00 dB
        Monitor Source: alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
        Latency: 0 usec, configured 0 usec
        Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY 
        Properties:
                alsa.card = "0"
                alsa.card_name = "HDA Intel PCH"
                alsa.class = "generic"
                alsa.device = "0"
                alsa.driver_name = "snd_hda_intel"
                alsa.id = "ALC257 Analog"
                alsa.long_card_name = "HDA Intel PCH at 0xa421c000 irq 142"
                alsa.name = "ALC257 Analog"
                alsa.resolution_bits = "16"
                alsa.subclass = "generic-mix"
                alsa.subdevice = "0"
                alsa.subdevice_name = "subdevice #0"
                api.alsa.card.longname = "HDA Intel PCH at 0xa421c000 irq 142"
                api.alsa.card.name = "HDA Intel PCH"
                api.alsa.path = "front:0"
                api.alsa.pcm.card = "0"
                api.alsa.pcm.stream = "playback"
                audio.channels = "2"
                audio.position = "FL,FR"
                card.profile.device = "6"
                device.api = "alsa"
                device.class = "sound"
                device.id = "45"
                device.profile.description = "Analog Stereo"
                device.profile.name = "analog-stereo"
                device.routes = "2"
                factory.name = "api.alsa.pcm.sink"
                media.class = "Audio/Sink"
                device.description = "Built-in Audio"
                node.name = "alsa_output.pci-0000_00_1f.3.analog-stereo"
                node.nick = "ALC257 Analog"
                node.pause-on-idle = "false"
                object.path = "alsa:pcm:0:front:0:playback"
                priority.driver = "1009"
                priority.session = "1009"
                factory.id = "18"
                clock.quantum-limit = "8192"
                client.id = "36"
                node.driver = "true"
                factory.mode = "merge"
                audio.adapt.follower = ""
                library.name = "audioconvert/libspa-audioconvert"
                object.id = "52"
                object.serial = "52"
                api.acp.auto-port = "false"
                api.acp.auto-profile = "false"
                api.alsa.card = "0"
                api.alsa.use-acp = "true"
                api.dbus.ReserveDevice1 = "Audio0"
                device.bus = "pci"
                device.bus_path = "pci-0000:00:1f.3"
                device.enum.api = "udev"
                device.form_factor = "internal"
                device.icon_name = "audio-card-analog-pci"
                device.name = "alsa_card.pci-0000_00_1f.3"
                device.nick = "HDA Intel PCH"
                device.plugged.usec = "5043343"
                device.product.id = "0x9dc8"
                device.product.name = "Cannon Point-LP High Definition Audio Controller"
                device.subsystem = "sound"
                sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
                device.vendor.id = "0x8086"
                device.vendor.name = "Intel Corporation"
                device.string = "0"
        Ports:
                analog-output-speaker: Speakers (type: Speaker, priority: 10000, availability group: Legacy 3, not available)
                analog-output-headphones: Headphones (type: Headphones, priority: 9900, availability group: Legacy 4, available)
        Active Port: analog-output-headphones
        Formats:
                pcm

so I assume that the mixer path im looking for is analog-output-speaker.

I've created the folder and copied, after running tree /etc/alsa-card-profile/ i get

/etc/alsa-card-profile/
└── mixer
    └── paths
        ├── analog-input-aux.conf
        ├── analog-input.conf
        ├── analog-input.conf.common
        ├── analog-input-dock-mic.conf
        ├── analog-input-fm.conf
        ├── analog-input-front-mic.conf
        ├── analog-input-headphone-mic.conf
        ├── analog-input-headset-mic.conf
        ├── analog-input-internal-mic-always.conf
        ├── analog-input-internal-mic.conf
        ├── analog-input-linein.conf
        ├── analog-input-mic.conf
        ├── analog-input-mic.conf.common
        ├── analog-input-mic-line.conf
        ├── analog-input-rear-mic.conf
        ├── analog-input-tvtuner.conf
        ├── analog-input-video.conf
        ├── analog-output-chat.conf
        ├── analog-output.conf
        ├── analog-output.conf.common
        ├── analog-output-headphones-2.conf
        ├── analog-output-headphones.conf
        ├── analog-output-lineout.conf
        ├── analog-output-mono.conf
        ├── analog-output-speaker-always.conf
        ├── analog-output-speaker.conf
        ├── hdmi-output-0.conf
        ├── hdmi-output-10.conf
        ├── hdmi-output-1.conf
        ├── hdmi-output-2.conf
        ├── hdmi-output-3.conf
        ├── hdmi-output-4.conf
        ├── hdmi-output-5.conf
        ├── hdmi-output-6.conf
        ├── hdmi-output-7.conf
        ├── hdmi-output-8.conf
        ├── hdmi-output-9.conf
        ├── iec958-stereo-input.conf
        ├── iec958-stereo-output.conf
        ├── steelseries-arctis-output-chat-common.conf
        ├── steelseries-arctis-output-game-common.conf
        ├── usb-gaming-headset-input.conf
        ├── usb-gaming-headset-output-mono.conf
        ├── usb-gaming-headset-output-stereo.conf
        └── virtual-surround-7.1.conf

3 directories, 45 files

I've edited the file analog-output-speaker.conf and changed the description-key to something else. but after restarting pipewire and listing the sinks again i still get the same message, however if i do it on the same file in /usr/share/alsa-card-profile/mixer/paths/ I do see a change, it's like pipewire doesn't care about the folder in /etc

Shmerlard commented 2 months ago

also since I'm using debian the only package I couldn't find is alsa-card-profiles but the files were already there so I don't know if it matters.

luisbocanegra commented 2 months ago

Fount this in PipeWire documentation

For ACP, PipeWire looks for the profile configuration files under

- ~/.config/alsa-card-profile
- /etc/alsa-card-profile
- /usr/share/alsa-card-profile/mixer`. 

The `path` and `profile-set` files are in subdirectories `paths` and `profile-sets` of these directories.
It is possible to override individual files locally by putting a modified copy into the ACP directories under `~/.config` or `/etc`.

So that means paths and profile-sets should be read from /etc/alsa-card-profile instead of /etc/alsa-card-profile/mixer can you try that or putting it in ~/.config?

I think your pipewire version is just too old and may not support any of that. If that's the case you can still use /usr/share/alsa-card-profile/mixer to continue the tutorial but that folder will be overwritten by updates

also since I'm using debian the only package I couldn't find is alsa-card-profiles but the files were already there so I don't know if it matters.

On debian those files are provided by pipewire-bin

Shmerlard commented 2 months ago

so after trying the with putting it in ~/.config and in /etc/alsa-card-profile it didnt work. so I checked and apparently yes the version of my pipe wire was outdated because of debian 12 (it was version 0.3.65), so i added the testing repository of debian and updated pipewire to 1.0.3. after editing the file in ~/.config/alsa-profile-card/paths it worked! i can see a different output for pactl list sinks. so I will continue like this and see what happens although after everything I changed in the system for the past 2 days I feel like changing to arch.

Shmerlard commented 2 months ago

Ok, so 2 more things. 1) after updating the version i tried again with putting it in /etc/alsa-card-profile/ but it didn't work, but with ~/.config it worked,

2) ive edited the file by commenting the lines and changing from no to unknown as described. and when I changed the output to headphones the speaker was muted, but all I had to do was changing it in alsamixer and now it works. so maybe you would want to add these things to the guide, meanwhile lets see if any more problems occur.

luisbocanegra commented 2 months ago

Glad you were able to get it working.

Ok, so 2 more things.

1. after updating the version i tried again with putting it in `/etc/alsa-card-profile/` but it didn't work, but with `~/.config` it worked,

Thanks, will try these two locations and add it to the guide probably this weekend

2. ive edited the file by commenting the lines and changing from no to unknown as described. and when I changed the output to headphones the speaker was muted, but all I had to do was changing it in `alsamixer` and now it works.
   so maybe you would want to add these things to the guide, meanwhile lets see if any more problems occur.

This is with or without the firmware patch?

Shmerlard commented 2 months ago

that was without the firmware patch, but yesterday I installed arch (wanted to try kde6) and today it worked flawlessly and now everything is working great. I have another audio device which is my screen via hdmi so I'll try to add this too. you don't know how I appreciate your help man! Many many thanks

Shmerlard commented 2 months ago

Okay the HDMI now works! for me the HDMI was on device 3, so in /etc/alsa-card-profile/mixer/profile-sets/split-ports-profile.conf I added the following:

[Mapping hdmi-output-0]
description = HDMI
device-strings = hw:%f,3
paths-output = hdmi-output-0
channel-map = left,right
direction = output

and replaced

[Profile output:analog-stereo-headphones+output:analog-stereo-speaker+input:analog-stereo-input]
description = Analog Stereo Duplex
output-mappings = analog-stereo-headphones analog-stereo-speaker
input-mappings = analog-stereo-input
priority = 80

with:

[Profile output:analog-stereo-headphones+output:analog-stereo-speaker+output:hdmi-output-0+input:analog-stereo-input]
description = Analog Stereo Duplex
output-mappings = analog-stereo-headphones analog-stereo-speaker hdmi-output-0
input-mappings = analog-stereo-input
priority = 80

after rebooting an HDMI sink appeared but no sound came out of it so in alsamixer just unmute the S/PDIF channels and store the results. and it should work

luisbocanegra commented 2 months ago

Okay the HDMI now works! for me the HDMI was on device 3, so in /etc/alsa-card-profile/mixer/profile-sets/split-ports-profile.conf I added the following: ...

Nice that you were able to extend even further 🎉

after rebooting an HDMI sink appeared but no sound came out of it so in alsamixer just unmute the S/PDIF channels and store the results. and it should work

Yeah, this muting started happening for me too after some update, I am tracking it here for when I have time to investigate it. In the meantime will add a note about alsamixer as you mentioned earlier.

you don't know how I appreciate your help man! Many many thanks

You're welcome! If you are able to, consider making a small donation (if you can't is also fine) ❤️

luisbocanegra commented 2 months ago

Hi again, can you try https://github.com/luisbocanegra/linux-guide-split-audio-ports/issues/13#issuecomment-2053710320 for the muting problem?