Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cave audio support #8

Open
wants to merge 2 commits into
base: master
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Cave audio support

  * add skylake-audio-helper to retrieve CrOS topologies
  * register same w/ systemd for startup dynamic topology install
  * ditto for pulseaudio system-level unload of idle module
      (to fix audio pops on Cave and perhaps others)
  * remove initramfs rebuild (kernel rev since bad sdhi)
  * Per-chromebook Google-X-1.0-X configurations
  * Move audio reset logic from postinst to "skylake-audio-helper reset"
  • Loading branch information...
Brian Carnes
Brian Carnes committed Jul 29, 2019
commit af90f78ed4642b020b1a3407e14f86d94e73e988
@@ -1,7 +1,19 @@
galliumos-skylake (3.0+dev2) bismuth; urgency=medium

* add skylake-audio-helper to retrieve CrOS topologies
* register same w/ systemd for startup dynamic topology install
* ditto for pulseaudio system-level unload of idle module
(to fix audio pops on Cave and perhaps others)
* remove initramfs rebuild (kernel rev since bad sdhi)
* Per-chromebook Google-X-1.0-X configurations
* Move audio reset logic from postinst to "skylake-audio-helper reset"

-- bcarnes <bmcarnes@gmail.com> Sun, 28 Jul 2019 19:21:19 +0000

galliumos-skylake (3.0+dev1) bismuth; urgency=medium

* bcarnes: suspend/resume: fix touchscreen and i2c kernel spew #6
* bcarnes: sklnau8825adi: increase audio levels to ~0 dB #7
* bcarnes: sklnau8825adi: increase audio levels to ~0 dB #7

-- reynhout <reynhout@galliumos.org> Fri, 05 Jul 2019 04:07:26 +0000

@@ -1,25 +1,14 @@
#!/bin/bash
set -euxo pipefail

# rebuild initramfs due to /etc/modprobe.d/* changes in re: sdhci
update-initramfs -u -k all
set -eu

service acpid restart

# If sound card is found by kernel, reset system ALSA config.
# This will only work if an appropriate kernel version is in place.
CARD0_ID_FILE="/proc/asound/card0/id"

if [ -r "$CARD0_ID_FILE" ]; then
HOME=/tmp alsaucm -c $(cat $CARD0_ID_FILE) reset
fi
cat <<EOD
For first time audio support, you may wish to run:
# Reset all user sound settings and clear pulseaudio tdb cache, to
# allow in-place upgrading, and "sudo apt install --reinstall" to fix
# system audio.
set +e
rm -f /var/lib/alsa/asound.state
rm -rf /home/*/.config/pulse
killall pulseaudio || true
sudo skylake-audio-helper get-topology
sudo skylake-audio-helper reset
Then reboot.
EOD
exit 0

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
[Unit]
Description=Skylake audio helper
DefaultDependencies=no
Wants=systemd-udevd.service
Before=systemd-udev-trigger.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/skylake-audio-helper systemd-startup
@@ -0,0 +1,147 @@
#!/bin/bash
set -eu

if (( $EUID != 0 )); then
echo "Please run as root or via sudo"
exit 1
fi

model=$(dmidecode -s system-product-name)
model=${model,,}
global_topology="/lib/firmware/dfw_sst.bin"
model_topology="${global_topology}.cros.${model}"

suppress_pulseaudio_idle() {
for pulse_init in default.pa system.pa; do
EPHEMERAL=/run/pulse-"${pulse_init}"
SRC=/etc/pulse/"${pulse_init}"
(cat <<EOD1 ; cat "${SRC}" ; cat <<EOD2 ) > "${EPHEMERAL}"
# Automatically generated; DO NOT EDIT
# 'umount ${SRC}' to edit source template
EOD1

# Below line added by skylake-audio-helper
unload-module module-suspend-on-idle
EOD2

mount --bind "${EPHEMERAL}" "${SRC}"
done
}

bind_model_topology() {
touch "${global_topology}"
mount --bind "${model_topology}" "${global_topology}"
}

status() {
for file in "${global_topology}" /etc/pulse/default.pa /etc/pulse/system.pa; do
echo -n "${file}: "
if mountpoint -q "${file}"; then
echo "fixed"
else
echo "fix not applied"
fi
done
for file in "${global_topology}" "${model_topology}"; do
echo "${file}: $(md5sum ${file} | cut -d' ' -f1)"
done
for bad in /lib/firmware/9d70-*-tplg.bin; do
if [[ -e "${bad}" ]] ; then
echo "You should remove file: ${bad}"
echo "e.g. 'sudo rm ${bad}'"
fi
done
if [[ ! -e "${model_topology}" ]] ; then
echo "File '${model_topology}' is not present"
echo "Please run '$0 get-topology' to retrieve it"
fi
}

get_topology() {
if [[ -e "${model_topology}" ]]; then
echo "Topology file '${model_topology}' already exists."
echo "You don't need to do this step if you've retrieved it previously."
echo "If desired, you can remove that file and rerun this command."
exit 1
fi

prefix="chromeos_11895.118.0"
recovery="${prefix}_${model}_recovery_stable-channel_mp.bin.zip"
root="/tmp/${prefix}_${model}_root.part"
mount="/tmp/${prefix}_mount"

wget -P /tmp -c https://dl.google.com/dl/edgedl/chromeos/recovery/"${recovery}"
echo "Extracting root partition..."
unzip -p /tmp/"${recovery}" | dd skip=319488 count=4096000 of="${root}"
echo "Extracting topology file..."
mkdir -p "${mount}"
mount -o ro "${root}" "${mount}"
cp "${mount}/lib/firmware/dfw_sst.bin" "${model_topology}" \
2>/dev/null || true
cp "${mount}/lib/firmware/9d70-CORE-COREBOOT-0-tplg.bin" "${model_topology}" \
2>/dev/null || true
umount $mount
echo "Success!"
}

reset() {
# If sound card is found by kernel, reset system ALSA config.
# This will only work if an appropriate kernel version is in place.
CARD0_ID_FILE="/proc/asound/card0/id"
if [ -r "$CARD0_ID_FILE" ]; then
HOME=/tmp alsaucm -c $(cat $CARD0_ID_FILE) reset 2>&1 \
| grep -v "error: could not parse configuration for card Google-" \
| grep -v "could not open configuration file /usr/share/alsa/ucm/Google-" \
| cat
fi

# Reset all user sound settings and clear pulseaudio tdb cache
rm -f /var/lib/alsa/asound.state
rm -rf /home/*/.config/pulse
killall pulseaudio || true

echo "Alsa and Pulseaudio caches reset."
echo "Please type 'reboot' now."
}

usage() {
cat <<EOD
Usage: $0 <command>
Commands:
get-topology
Retrieve ideal CrOS audio topology file from online recovery images
status
Show state of skylake audio on this machine
reset
Reset audio configuration
systemd-startup
[Internal - called by systemd] Perform startup tasks
EOD
exit 1
}

case "${1:-usage}" in
systemd-startup)
suppress_pulseaudio_idle
bind_model_topology
;;
get-topology)
get_topology
;;
status)
status
;;
reset)
reset
;;
*)
usage
;;
esac
@@ -1,5 +1,4 @@
Comment "Chromebook Asuka, Cave, Lars, Sentry(some) - sklnau8825max"
# cf. https://github.com/coreboot/coreboot/blob/master/src/mainboard/google/glados/Kconfig.name
Comment "Chromebook Asuka"

SectionUseCase."HiFi" {
File "HiFi.conf"
@@ -17,16 +16,17 @@ SectionUseCase."Headset-Profile" {
}

SectionDefaults [
cdev "hw:sklnau8825max"
cdev "hw:0"
cset "name='codec1_out mo media0_in mi Switch' off"
cset "name='codec0_out mo media0_in mi Switch' on"
cset "name='DAC Oversampling Rate' 128"
cset "name='Spk Switch' on"
cset "name='Headphone Jack Switch' off"
cset "name='Headset Mic Switch' off"
cset "name='media0_out mo codec0_in mi Switch' off"
cset "name='media0_out mo dmic01_hifi_in mi Switch' on"
cset "name='Pin5-Port0 Mux' 1"
cset "name='Pin6-Port0 Mux' 2"
cset "name='Pin7-Port0 Mux' 3"
cset "name='Headphone Jack Switch' off"
cset "name='BIQ Coefficients' 0"
cset "name='Pin5-Port0 Mux' 'cvt 2'"
cset "name='Pin6-Port0 Mux' 'cvt 3'"
cset "name='Pin7-Port0 Mux' 'cvt 4'"
cset "name='Mic Volume' 255"
]
@@ -7,8 +7,8 @@ SectionVerb {

Value {
TQ "HiFi"
CapturePCM "hw:sklnau8825max,1"
PlaybackPCM "hw:sklnau8825max,0"
CapturePCM "hw:0,1"
PlaybackPCM "hw:0,0"
}
}

@@ -18,12 +18,14 @@ SectionDevice."Headphone".0 {
Value {
CoupledMixers "Left Master,Right Master"
PlaybackChannels "2"
OutputDspName ""
}

EnableSequence [
cdev "hw:sklnau8825max"
cdev "hw:0"
cset "name='codec0_out mo media0_in mi Switch' off"
cset "name='codec1_out mo media0_in mi Switch' on"
cset "name='Spk Switch' off"
cset "name='Headphone Jack Switch' on"
]

@@ -35,7 +37,7 @@ SectionDevice."Mic".0 {
Comment "Mic"

EnableSequence [
cdev "hw:sklnau8825max"
cdev "hw:0"
cset "name='Headset Mic Switch' off"
cset "name='media0_out mo codec0_in mi Switch' off"
cset "name='media0_out mo dmic01_hifi_in mi Switch' on"
@@ -46,5 +48,7 @@ SectionDevice."Mic".0 {

Value {
CaptureChannels "2"
MaxSoftwareGain "2000"
InputDspName ""
}
}
@@ -7,8 +7,8 @@ SectionVerb {

Value {
TQ "HiFi"
CapturePCM "hw:sklnau8825max,1"
PlaybackPCM "hw:sklnau8825max,0"
CapturePCM "hw:0,1"
PlaybackPCM "hw:0,0"
}
}

@@ -18,13 +18,15 @@ SectionDevice."Headphone".0 {
Value {
CoupledMixers "Left Master,Right Master"
PlaybackChannels "2"
OutputDspName ""
}

EnableSequence [
cdev "hw:sklnau8825max"
cdev "hw:0"
cset "name='codec0_out mo media0_in mi Switch' off"
cset "name='codec1_out mo media0_in mi Switch' on"
cset "name='Headphone Jack Switch' on"
cset "name='Spk Switch' off"
]

DisableSequence [
@@ -35,7 +37,7 @@ SectionDevice."Headet Mic".0 {
Comment "Headset Mic"

EnableSequence [
cdev "hw:sklnau8825max"
cdev "hw:0"
cset "name='Headset Mic Switch' on"
cset "name='media0_out mo codec0_in mi Switch' on"
cset "name='media0_out mo dmic01_hifi_in mi Switch' off"
@@ -46,5 +48,6 @@ SectionDevice."Headet Mic".0 {

Value {
CaptureChannels "2"
InputDspName "extmic_eq"
}
}
@@ -0,0 +1,54 @@
SectionVerb {
EnableSequence [
]

DisableSequence [
]

Value {
TQ "HiFi"
CapturePCM "hw:0,1"
PlaybackPCM "hw:0,0"
}
}

SectionDevice."Speakers".0 {
Comment "Speakers"

Value {
CoupledMixers "Left Master,Right Master"
PlaybackChannels "2"
OutputDspName "speaker_eq"
}

EnableSequence [
cdev "hw:0"
cset "name='codec0_out mo media0_in mi Switch' on"
cset "name='codec1_out mo media0_in mi Switch' off"
cset "name='Headphone Jack Switch' off"
cset "name='Spk Switch' on"
]

DisableSequence [
]
}

SectionDevice."Mic".0 {
Comment "Mic"

EnableSequence [
cdev "hw:0"
cset "name='Headset Mic Switch' off"
cset "name='media0_out mo codec0_in mi Switch' off"
cset "name='media0_out mo dmic01_hifi_in mi Switch' on"
]

DisableSequence [
]

Value {
CaptureChannels "2"
MaxSoftwareGain "2000"
InputDspName ""
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.