cb-linux / breath

Linux for Chromebooks
https://cb-linux.github.io/breath/
MIT License
301 stars 55 forks source link

Patch kernel/UCM for Headphone Jack detection #223

Closed MilkyDeveloper closed 2 years ago

MilkyDeveloper commented 2 years ago

FYI, it turns out that all Chromebook machine drivers missed a detail that is required for upstream UCM/PulseAudio/Pipewire to detect the headset jack correctly. Kernel changes: https://github.com/thesofproject/linux/pull/3681 UCM changes: https://github.com/alsa-project/alsa-ucm-conf/pull/150

Originally posted by @plbossart in https://github.com/cb-linux/breath/issues/29#issuecomment-1151599605

Denisuu commented 2 years ago

Nice, I’ve merged into my own downstream kernel tree based on ChromeOS’s. Originally posted by @MilkyDeveloper in https://github.com/cb-linux/breath/issues/29#issuecomment-1156666506

I’ve merged it into our own kernel tree, but there’s a bug with the automated kernel building system that I’m still fixing :D Originally posted by @MilkyDeveloper in https://github.com/cb-linux/breath/issues/200#issuecomment-1156663899

Since plbossart's kernel patch #3681 is merged and you implemented it in the Breath kernel, can we build an .ISO now or is it better to wait?

Has any fix/workaround been found for the graphical PulseAudio interface not working?

MilkyDeveloper commented 2 years ago

Done! Jack Detection should work once the user runs:

bash updatekernel.sh

I think I still need to patch the UCM though. I still don’t have a SOF chromebook 🙃, so huge thanks for testing with me. Eventually I’ll package up this kernel into a snap and you can use it through UEFI.

Denisuu commented 2 years ago

You're welcome, it's the least I can do. You put so much work into this. Someone should donate you one!

I'm building the Arch ISO now. Will the scripts run on Arch or should I try on Ubuntu? In that case I'll also make a stick for Ubuntu.

I'll only be able to test over the weekend though.

MilkyDeveloper commented 2 years ago

I’d use Ubuntu until I integrate UPM into the script. Currently apt is hard-coded in.

RodBarnes commented 2 years ago

@MilkyDeveloper Should updatekernel.sh work on all instances? Or only recent ones? I ask because this script doesn't exist on my current instance I'm running. If I need to build a new instance, I can do that.

UPDATE: I just built a new image from the latest commit (8eb866) and I have no audio after running the apl-sof-setup-audio and the reboot. Maybe I should open a new issue...

Denisuu commented 2 years ago

@MilkyDeveloper Should updatekernel.sh work on all instances? Or only recent ones? I ask because this script doesn't exist on my current instance I'm running. If I need to build a new instance, I can do that.

UPDATE: I just built a new image from the latest commit (8eb866) and I have no audio after running the apl-sof-setup-audio and the reboot. Maybe I should open a new issue...

You can always just copy the updatekernel.sh from the /breath/main Github.

I assume you know how to run a script, in case you don't:

nano updatekernel.sh
<paste script content & close with ctrl + x >
chmod +x ./updatekernel.sh
./updatekernel.sh

You can use any text editor you want of course. Edit: I just looked at your profile, I definitely didn't have to explain. 😆

MilkyDeveloper commented 2 years ago

Make sure to run this on another computer with the breath USB plugged in, or just build a new USB.

Denisuu commented 2 years ago

Make sure to run this on another computer with the breath USB plugged in, or just build a new USB.

The script is not meant to be run within breath? Is it the same case for sof-setup-aux.sh? That could explain why it completely broke audio last time 😅

MilkyDeveloper commented 2 years ago

sof-setup-aux should be run on your Chromebook :D. updatekernel.sh is only used for updating the kernel when you have an old image that you want to update with a newer kernel.

Denisuu commented 2 years ago

I'm back on Breath but sof-setup-audio doesn't make audio work anymore. When I run setup-audio I get the following error:

mount: /mnt: special device /dev/mmcblk0p3 does not exist.
       dmesg(1) may have more information after failed mount system call.

Also the Breath Ubuntu KDE image I build yesterday didn't want to boot.

[FAILED] Failed to start OpenBSD Secure Shell Server
runcros commented 2 years ago

Same setup-audio error mount: /mnt: special device /dev/mmcblk0p3 does not exist.

MilkyDeveloper commented 2 years ago

@Denisuu What’s the output of dmesg and sof-setup-audio?

You probably need to install pulseaudio since setup-audio removed them. Also, setup-audio masks PulseAudio. To undo this, run:

systemctl unmask —user pulseaudio.{socket,service}

If we get headphone audio working on here, packaging all of this into a Snap for UEFI would work great.

Denisuu commented 2 years ago

The output of sof-setup-audio or setup-audio is the same in dmesg:

[root@BLOOGLET denisuu]# dmesg -C
[root@BLOOGLET denisuu]# setup-audio 
Installing Audio...
Failed to connect to bus: No medium found
Failed to connect to bus: No medium found
Failed to connect to bus: No medium found
Failed to connect to bus: No medium found
Please install a desktop and rerun this script if audio doesn't work.
umount: /mnt: not mounted.
mount: /mnt: special device /dev/mmcblk0p3 does not exist.
       dmesg(1) may have more information after failed mount system call.
mount: /mnt: special device /dev/mmcblk1p3 does not exist.
       dmesg(1) may have more information after failed mount system call.
[root@BLOOGLET denisuu]# dmesg
[  376.590653] kauditd_printk_skb: 5 callbacks suppressed
[  376.590655] audit: type=1101 audit(1655836575.504:416): pid=1389 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:accounting grantors=pam_unix,pam_permit,pam_time acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.591949] audit: type=1110 audit(1655836575.506:417): pid=1389 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_env,pam_faillock acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.593163] audit: type=1105 audit(1655836575.507:418): pid=1389 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:session_open grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.595591] audit: type=1106 audit(1655836575.509:419): pid=1389 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:session_close grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.595788] audit: type=1104 audit(1655836575.510:420): pid=1389 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_env,pam_faillock acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.604936] audit: type=1101 audit(1655836575.519:421): pid=1391 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:accounting grantors=pam_unix,pam_permit,pam_time acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.606046] audit: type=1110 audit(1655836575.520:422): pid=1391 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_env,pam_faillock acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.607006] audit: type=1105 audit(1655836575.521:423): pid=1391 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:session_open grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.609030] audit: type=1106 audit(1655836575.523:424): pid=1391 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:session_close grantors=pam_systemd_home,pam_limits,pam_unix,pam_permit acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'
[  376.609101] audit: type=1104 audit(1655836575.523:425): pid=1391 uid=0 auid=1000 ses=2 subj=kernel msg='op=PAM:setcred grantors=pam_faillock,pam_permit,pam_env,pam_faillock acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/0 res=success'

Full dmesg (before clearing it)

It looks like sof isn't getting loaded:
[7.127817] sof-audio-pci-intel-apl 0000:00:0e.0: Direct firmware load for intel/sof/community/sof-glk.ri failed with error -2

ellyq commented 2 years ago

@Denisuu: APL can only load Intel-signed firmware. GLK can load community firmware, but APL cannot.

MilkyDeveloper commented 2 years ago

Functionality completed with latest kernel (patched with plbossart's Jack Detection PR) and handmade UCMs (though not enabled as of yet).