Merge pull request #1677 from brooksytech/dev

Finish up RK3399 jack sense
This commit is contained in:
Brooksytech 2023-07-06 16:02:19 -07:00 committed by GitHub
commit 41c4eeb021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 15 deletions

View file

@ -7,8 +7,8 @@ cat <<EOF >/storage/.config/profile.d/001-deviceconfig
DEVICE_FAKE_JACKSENSE=true
DEVICE_VOLUMECTL=true
DEVICE_AUDIO_MIXER="DAC"
DEVICE_PLAYBACK_PATH_SPK="0*"
DEVICE_PLAYBACK_PATH_HP="1*"
DEVICE_PLAYBACK_PATH_SPK="1*"
DEVICE_PLAYBACK_PATH_HP="0*"
DEVICE_BRIGHTNESS="128"
DEVICE_JACK="8"
DEVICE_HEADPHONE_DEV="/dev/input/by-path/platform-es8316-sound-event"

View file

@ -80,7 +80,7 @@ state.rockchipes8316c {
control.4 {
iface MIXER
name 'Playback Polarity'
value 'R Invert'
value Normal
comment {
access 'read write'
type ENUMERATED

View file

@ -1,35 +1,42 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020-present Shanti Gilbert (https://github.com/shantigilbert)
# Copyright (C) 2021-present Fewtarius
# Copyright (C) 2023-present BrooksyTech (https://github.com/brooksytech)
# Source predefined functions and variables
. /etc/profile
# Switch to headphones if we have them already connected at boot
GPIO=$(cat /sys/class/gpio/gpio${DEVICE_JACK}/value)
[[ "$GPIO" == "0" ]] && set_setting "audio.device" "headphone" || set_setting "audio.device" "speakers"
if [ -e "/storage/.config/system/configs/system.cfg" ]; then
/usr/bin/system_utils setaudio $(get_setting "audio.device")
/usr/bin/system_utils vol $(get_setting "audio.volume")
fi
# Check headphone gpio at boot and set the correct output device
HP_GPIO=$(cat /sys/class/gpio/gpio${DEVICE_JACK}/value)
case ${HP_GPIO} in
"1")
amixer cset name='Speaker Switch' ${DEVICE_PLAYBACK_PATH_HP}
amixer set 'Headphone' '67%'
set_setting "audio.device" "headphone"
;;
*)
amixer cset name='Speaker Switch' ${DEVICE_PLAYBACK_PATH_SPK}
amixer set 'Headphone' '100%'
set_setting "audio.device" "speakers"
;;
esac
# Headphone sensing
DEVICE="${DEVICE_HEADPHONE_DEV}"
HP_ON='*(SW_HEADPHONE_INSERT), value 0*'
HP_OFF='*(SW_HEADPHONE_INSERT), value 1*'
HP_OFF='*(SW_HEADPHONE_INSERT), value 0*'
HP_ON='*(SW_HEADPHONE_INSERT), value 1*'
evtest "${DEVICE}" | while read line; do
case $line in
(${HP_ON})
amixer cset name='Speaker Switch' ${DEVICE_PLAYBACK_PATH_HP}
amixer set 'Headphone' '67%'
set_setting "audio.device" "headphone"
;;
(${HP_OFF})
amixer cset name='Speaker Switch' ${DEVICE_PLAYBACK_PATH_SPK}
amixer set 'Headphone' '100%'
set_setting "audio.device" "speakers"
;;
esac