joshuagrisham / galaxy-book2-pro-linux

Notes and utilities for running Linux on the Samsung Galaxy Book2 Pro
115 stars 10 forks source link

Sound partially works #13

Open aymendn opened 1 month ago

aymendn commented 1 month ago

Hi there, First, thank you so much! I just installed Ubuntu on my Galaxy book 2 Pro, and this repo saved me hours of work.

I tried to run the sound verbs script sound/necessary-verbs.sh. And only the left speaker is working.

I really want to help on this. So can you explain to me what I can do to help. Also is it safe to run the verbs in all-verbs.txt?

I don't know exactly what info to provide in this issue, so please let me know if you want me to add anything.

aymendn commented 1 month ago

Update: I run the sound/necessary-verbs.sh again today, and both speakers are working. I will try it more times in the future and keep this issue updated.

RTom2701 commented 1 month ago

I had the exact same problem, the first time I ran the script, speakers volumes were low and the right one was almost silent. But after the next reboot, and after I added this script as a systemd service, they were totally functional Maybe the script doesn’t work well the first time you use it, or maybe it doesn’t work well if you don’t launch it immediately after booting (like if you change audio settings before, or run a program that uses speakers)

aymendn commented 1 month ago

Hi @RTom2701. Thank you for helping on this issue. I just tried it again, and both speakers work.

Maybe the script doesn’t work well the first time you use it, or maybe it doesn’t work well if you don’t launch it immediately after booting (like if you change audio settings before, or run a program that uses speakers)

I don't think it has anything to do with when to run it, because I run it while a youtube video is playing and it worked as expected. I think it has more to do with running for the first time as you mentionned.

This could be added as a note in the readme file, and this issue should be closed at this point.

@joshuagrisham what do you think on adding a warning or something on the readme file about that the sound may not work properly on the first time. Also we may add a script to create a service to auto run on startup. I'm open to contribute on this if you're ok with it.

aymendn commented 1 month ago

Update:

I'm running dual boot Ubuntu/ Windows 11. I boot to Ubuntu, run the sound/necessary-verbs.sh, and again, only the left speakers are working (I'm not entirely sure whether the right speakers are completely off or just very low volume).

What I found interresting is, when reboot, it is still the same situation. But when I reboot to windows then back to ubuntu, the speakers work perfectly. It is the same thing that happened yesterday.

At this point I'm not sure why this is heppening, I'll let these observations here as they might help others find the solution or the reason for this.

aymendn commented 1 month ago

Another Update

So appearently, the right speaker is not completely off, but its sound is very low, and when trying to balance it from the settings (letf 30%, right 70%), the sound is very weird.

joshuagrisham commented 1 month ago

Hi @aymendn and thanks for digging into this!

Your experience with the speaker volume difference mirrors mine and this whole thing is a bit of a tricky thing to nail down IMO. I have not spent so much time on it recently... I did take about 20x more traces a few months ago and tried to diff them all to really boil down exactly what is the "core" but could never really come to anything better unfortunately.

If I really took the time on this then my plan would be to further modify the QEMU tracing and parsing so that I could get timestamps for each event to help me figure out what is part of startup and what seems to be part of "normal ongoing operations", plus when I actively use the speakers vs not etc PLUS that I would want to try and add traces for DMA reads instead of just writes, as it feels a bit like the Windows driver is writing things in response to reading some value? Maybe there is something to that?

TBH the absolute best would be if Realtek / Realtek + Samsung could actually help with this as it seems overly complex when you initially glance at it, and I feel a bit at a loss for what is really happening here.

Having said alllllllllll of that, there is actually a user @hamfirst who has tried to take my trace plus some others, did a lot of experiments, tweaked quite a bit of things so that it would work more consistently and with better volume on both speakers, and even prepared it as an actual kernel driver update (which got accepted!); see: https://github.com/thesofproject/linux/issues/4055#issuecomment-2143993607 .

I am not totally "in love" with it still but it is a huge step forward and @hamfirst has done a fantastic job of really taking it to the next step

Here are some new helper functions they added that essentially provide all of these crazy payload sequences: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/sound/pci/hda/samsung_helper.c

Also each device that would want to use this needs to be added to the quirk table and tagged with the id ALC298_FIXUP_SAMSUNG_AMP2 like this: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/sound/pci/hda/patch_realtek.c?id=0336807572f177a1fdfc71b66600ade75d071db4#n10523

I have not yet given it a try but was thinking about doing so soon, and if it works then trying to get my specific device added to the quirk table :smile_cat:

joshuagrisham commented 1 month ago

By the way just to mention, from what I can tell from various tags, @hamfirst 's driver updates will come starting with kernel 6.11 but again the device needs to be in the quirks table of patch_realtek.c for it to actually get picked up on your device.

aymendn commented 1 month ago

First thank you @joshuagrisham for replying. I want also to thank @hamfirst for the fantastic job he did. Reading through your comments made me feel a little behind as I don’t understand clearly some terms here, I'm new to Linux and I have limited knowledge about drivers. I don’t think I can help a lot in terms of defining the list of verbs and the kernel stuff. But I can help testing and update you with my observations.

I tested the list of verbs provided by @hamfirst (hda-verbs.txt) and both speakers work. I will continue using @hamfirst's verbs script as a service on startup untill you guys fix this on the kernel level.

If there is anything I can help with, I'm here ready to help.