Adding HDMI serviec for RK3399 build
This commit is contained in:
parent
650aaa7795
commit
4f339eccd1
8 changed files with 116 additions and 16 deletions
|
@ -12,6 +12,8 @@ DEVICE_PLAYBACK_PATH_HP="0*"
|
|||
DEVICE_BRIGHTNESS="128"
|
||||
DEVICE_JACK="8"
|
||||
DEVICE_HEADPHONE_DEV="/dev/input/by-path/platform-es8316-sound-event"
|
||||
DEVICE_HAS_HDMI=true
|
||||
DEVICE_HDMI_GPIO="54"
|
||||
UI_SERVICE="weston.service"
|
||||
|
||||
DEVICE_TEMP_SENSOR=("/sys/devices/virtual/thermal/thermal_zone0/temp" "/sys/devices/virtual/thermal/thermal_zone1/temp")
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2023-present BrooksyTech (https://github.com/brooksytech)
|
||||
|
||||
. /etc/profile
|
||||
|
||||
# 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
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2023-present BrooksyTech (https://github.com/brooksytech)
|
||||
|
||||
. /etc/profile
|
||||
|
||||
# Set export GPIO for HDMI
|
||||
if [ ! -d "/sys/class/gpio/gpio${DEVICE_HDMI_GPIO}" ]; then
|
||||
echo ${DEVICE_HDMI_GPIO} > /sys/class/gpio/export
|
||||
echo in > /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/direction
|
||||
fi
|
||||
|
||||
# Check HDMI plug state and switch to HDMI audo if true
|
||||
HDMI_VALUE=$(cat /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/value)
|
||||
case ${HDMI_VALUE} in
|
||||
"0")
|
||||
sed -i 's/pcm "hw:0,0"/pcm "hw:1,0"'/ /storage/.config/asound.conf
|
||||
;;
|
||||
esac
|
|
@ -16,6 +16,8 @@ export SLOW_CORES \
|
|||
DEVICE_FUNC_KEYA_MODIFIER \
|
||||
DEVICE_FUNC_KEYB_MODIFIER \
|
||||
DEVICE_HAS_FAN \
|
||||
DEVICE_HAS_HDMI \
|
||||
DEVICE_HDMI_GPIO \
|
||||
DEVICE_HEADPHONE_DEV \
|
||||
DEVICE_INTERNAL_WIFI \
|
||||
DEVICE_JACK \
|
||||
|
|
|
@ -28,3 +28,10 @@ else
|
|||
nohup systemctl stop volume &
|
||||
fi
|
||||
|
||||
if [ "${DEVICE_HAS_HDMI}" == "true" ]
|
||||
then
|
||||
tocon "Starting hdmi service..."
|
||||
nohup systemctl start hdmi &
|
||||
else
|
||||
nohup systemctl stop hdmi &
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/bash
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2023-present BrooksyTech (https://github.com/brooksytech)
|
||||
|
||||
. /etc/profile
|
||||
|
||||
DEVICE_HDMI_GPIO="54"
|
||||
|
||||
# Set export GPIO for HDMI
|
||||
if [ ! -d "/sys/class/gpio/gpio${DEVICE_HDMI_GPIO}" ]; then
|
||||
echo ${DEVICE_HDMI_GPIO} > /sys/class/gpio/export
|
||||
echo in > /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/direction
|
||||
fi
|
||||
|
||||
# Pull GPIO for Speaker / Headphone plugged
|
||||
if [ -d "/sys/class/gpio/gpio${DEVICE_JACK}" ]; then
|
||||
HP_GPIO=$(cat /sys/class/gpio/gpio${DEVICE_JACK}/value)
|
||||
fi
|
||||
|
||||
# Check HDMI plugged / unplugged, set audio output, restart Emulation Station
|
||||
HDMI_VALUE=$(cat /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/value)
|
||||
while true
|
||||
do
|
||||
HDMI_NEW_VALUE=$(cat /sys/class/gpio/gpio${DEVICE_HDMI_GPIO}/value)
|
||||
|
||||
if test "${HDMI_VALUE}" != "${HDMI_NEW_VALUE}"
|
||||
then
|
||||
case ${HDMI_NEW_VALUE} in
|
||||
"0") #HDMI plugged
|
||||
sed -i 's/pcm "hw:0,0"/pcm "hw:1,0"/' /storage/.config/asound.conf
|
||||
;;
|
||||
"1") #HDMI unpluagged
|
||||
sed -i 's/pcm "hw:1,0"/pcm "hw:0,0"/' /storage/.config/asound.conf
|
||||
case ${HP_GPIO} in
|
||||
"1")
|
||||
amixer set 'Headphone' '67%'
|
||||
set_setting "audio.device" "headphone"
|
||||
;;
|
||||
*)
|
||||
amixer set 'Headphone' '100%'
|
||||
set_setting "audio.device" "speakers"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
systemctl restart weston
|
||||
|
||||
HDMI_VALUE=${HDMI_NEW_VALUE}
|
||||
fi
|
||||
sleep 5
|
||||
done
|
|
@ -3,24 +3,8 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2023-present BrooksyTech (https://github.com/brooksytech)
|
||||
|
||||
# Source predefined functions and variables
|
||||
. /etc/profile
|
||||
|
||||
# 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}"
|
||||
|
||||
|
|
12
packages/sysutils/system-utils/system.d/hdmi.service
Normal file
12
packages/sysutils/system-utils/system.d/hdmi.service
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=HDMI Sense
|
||||
Before=jelos.target
|
||||
|
||||
[Service]
|
||||
Environment=HOME=/storage
|
||||
EnvironmentFile=/etc/profile
|
||||
ExecStart=/usr/bin/hdmi_sense
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in a new issue