tomsom / yoga-linux

Run Linux on the Lenovo Yoga 7 14 (14ARB7) with AMD Ryzen 6800U (Rembrand).
https://github.com/tomsom/yoga-linux/wiki
56 stars 2 forks source link

speaker 'fix' when using pipewire+wireplumber #25

Open accumulator opened 1 year ago

accumulator commented 1 year ago

I've applied the following workaround to have the bass speakers always on. Well, almost always, there's a catch. It requires you to suspend the laptop once.

Add file /etc/systemd/system/yoga-bass-speaker-fix.service

[Unit]
Description=Triggers the yoga7 bass-speaker toggle with i2c on resume from sleep and hibernate.
After=systemd-suspend.service systemd-hibernate.service

[Service]
Type=oneshot
User=root
ExecStart=/usr/bin/i2cset -y 3 0x48 0x2 0

[Install]
RequiredBy=systemd-suspend.service systemd-hibernate.service
WantedBy=multi-user.target

This applies the bass-speaker fix when returning from sleep.

And add file /etc/wireplumber/main.lua.d/51-yoga-alsa-config.lua

table.insert(alsa_monitor.rules,  {
    matches = {
      -- no suspend for ALC287
      {
        { "node.nick", "matches", "ALC287 Analog" },
      },
    },
    apply_properties = {
      ["session.suspend-timeout-seconds"] = 0,  -- 0 disables suspend
    },
  }
)

This instructs wireplumber/pipewire to not release the audio device after a while (which would reset the speaker fix).

What's missing is to apply the bass-speaker fix the first time the audio device is opened, but I haven't found a way to do that from the wireplumber/pipewire session (which doesn't run as root). Therefore, suspending the laptop at least once after using audio is required.

In practice, I hardly notice the problem anymore, as I don't reboot that often.

Edit: updated with the systemd service mentioned below

sylcas commented 9 months ago

i am using the 14ARB7 since last year and since yesterday i also have the Yoga Pro 7 14.5 (company laptop) where the speakers are working out of the box with kernel 6.5.5 (archlinux). if someone can point me i the right direction i am happy to provide more details - maybe there is something to learn from the newer model that helps fixing the speaker issue in the 14ARB7.

soupglasses commented 7 months ago

I have created my own version of this concept in a systemd service inside NixOS here: https://github.com/soupglasses/coturnix/commit/1c0ed94f57120eabae929109160732d3e04ea59f

It allows for starting on boot and resume. A translated non-nixos version would be something similar to this, but it is untested:

[Unit]
Description=Triggers the yoga7 bass-speaker toggle with i2c on boot and resume.
After=systemd-suspend.service systemd-hibernate.service

[Service]
Type=oneshot
User=root
ExecStart=/usr/bin/i2cset -y 3 0x48 0x2 0

[Install]
RequiredBy=systemd-suspend.service systemd-hibernate.service
WantedBy=multi-user.target
RayOfLight1 commented 7 months ago

I've had to modify it but so far it seems to work:

/etc/systemd/system/yoga-bass-speaker-fix.service

[Unit] Description=Triggers the yoga7 bass-speaker toggle with i2c on boot and resume. After=systemd-suspend.service systemd-hibernate.service

[Service] Type=oneshot User=root ExecStart=/usr/bin/i2cset -y 3 0x48 0x2 0

[Install] RequiredBy=systemd-suspend.service systemd-hibernate.service WantedBy=multi-user.target

Missatge de Sofi @.***> del dia dc., 15 de nov. 2023 a les 13:55:

I have created my own version of this concept in a systemd service inside NixOS here: @.*** https://github.com/soupglasses/coturnix/commit/1c0ed94f57120eabae929109160732d3e04ea59f

It allows for starting on boot and resume. A translated non-nixos version would be something similar to this, but it is untested:

[Unit]Description=Triggers the yoga7 bass-speaker toggle with i2c on boot and resume.After=systemd-suspend.service systemd-hibernate.serviceRequiredBy=systemd-suspend.service systemd-hibernate.service [Service]Type=oneshotUser=rootExecStart=/usr/bin/i2cset -y 3 0x48 0x2 0 [Install]WantedBy=multi-user.target

— Reply to this email directly, view it on GitHub https://github.com/tomsom/yoga-linux/issues/25#issuecomment-1812488719, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADJ52UOAM43BAB2GCGBV77LYES3U5AVCNFSM6AAAAAAUUODU7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMJSGQ4DQNZRHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

soupglasses commented 7 months ago

Thanks for spotting that! I have updated my comment to reflect this, as it was just something i quickly wrote up without verifying if it was correct.

stuarthayhurst commented 4 months ago

Since we have a driver in the kernel now, can this be closed?

soupglasses commented 4 months ago

I would propose a PR updating the README with the relevant merged code and when it became generally available before closing speaker fix related issues.