From d8e31a905829fac6bde3dfbe3167a4e428db0ba5 Mon Sep 17 00:00:00 2001 From: paul-1 <6473457+paul-1@users.noreply.github.com> Date: Sun, 1 Dec 2024 17:01:51 -0500 Subject: [PATCH 1/6] Add auto detection of touch drivers. Add 90 and 270 rotations for the portrait mode piDisplay 2. Detect if vc4 or firmware drivers are being used. Move all environment variables to this script. --- jivelite-sp | 71 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/jivelite-sp b/jivelite-sp index 1aab26f..68467bd 100644 --- a/jivelite-sp +++ b/jivelite-sp @@ -4,22 +4,57 @@ export LOG=/var/log/pcp_jivelite.log if [ -f /usr/local/etc/pcp/pcp.cfg ]; then source /usr/local/etc/pcp/pcp.cfg - if [ ! -z ${SCREENROTATE} ]; then - MODEL=$(busybox awk '/^Model/ { print $5 }' /proc/cpuinfo) - if [ "${MODEL}" == "5" ]; then - # Rotation CCW=270, UD=180, CW=90 degrees - if [ "${SCREENROTATE}" == "180" ]; then - export SDL_VIDEO_FBCON_ROTATION=UD - export TSLIB_CALIBFILE=/usr/local/etc/pointercal-r2 - echo "Pi5 detected sdl screen rotation enabled." >> $LOG - fi - fi - fi fi +# Autodetect Touchscreen, and then mouse if no touch is found. +TMPFILE=$(mktemp) +udevadm info --export-db | grep "P: " | grep "event" | sed 's/P: //' > $TMPFILE +for LINE in $(cat $TMPFILE); do + udevadm info --query=property --path=$LINE | grep -q TOUCH + [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=1;MOUSE=0 + [ "$eventno" != "" ] && break + udevadm info --query=property --path=$LINE | grep -q MOUSE + [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=0;MOUSE=1 + [ "$eventno" != "" ] && break +done +rm -f $TMPFILE + +if [ x"" != x"$eventno" ]; then + [ $TOUCH -eq 1 ] && export JIVE_NOCURSOR=1 + export TSLIB_TSDEVICE=/dev/input/$eventno + export SDL_MOUSEDRV=TSLIB + export SDL_MOUSEDEV=$TSLIB_TSDEVICE +fi + +# Determine the driver being used. (drm-rpi-dsadrmf is a pi5 which must use the vc4 driver) if [ ! -z ${JL_FRAME_BUFFER} ]; then export SDL_FBDEV=$JL_FRAME_BUFFER echo "Using $SDL_FBDEV as frame buffer device." >> $LOG + + case $(cat /proc/fb | grep -E ^${JL_FRAME_BUFFER: -1} | cut -d' ' -f2) in + vc4drmfb|drm-rp1-dsidrmf) DRIVER="VC4";; + BCM2708) DRIVER="BCM2708";; + *) DRIVER="OTHER" + esac +fi + +# Set software rotation if screen rotate is set and vc4 driver is being used. +if [ ! -z ${SCREENROTATE} ]; then + if [ "${DRIVER}" = "VC4" ]; then + # Rotation CCW=270, UD=180, CW=90 degrees + case "${SCREENROTATE}" in + 90) export SDL_VIDEO_FBCON_ROTATION=CW;; +# 180) export SDL_VIDEO_FBCON_ROTATION=UD ; export TSLIB_CALIBFILE=/usr/local/etc/pointercal-r2 ;; + 180) export SDL_VIDEO_FBCON_ROTATION=UD;; + 270) export SDL_VIDEO_FBCON_ROTATION=CCW;; + *) unset SDL_VIDEO_FBCON_ROTATION;; + esac + fi + if [ ! -z ${SDL_VIDEO_FBCON_ROTATION} ]; then + echo "SDL screen rotation set to $SDL_VIDEO_FBCON_ROTATION." >> $LOG + else + echo "No Screen rotation, or handled in firmware." >> $LOG + fi fi if [ -z ${JL_FRAME_RATE} ]; then @@ -34,13 +69,15 @@ if [ -z ${JL_FRAME_DEPTH} ]; then JL_FRAME_DEPTH=32 fi -/usr/sbin/fbset -depth $JL_FRAME_DEPTH >> $LOG - -echo "Frame buffer color bit depth set to $JL_FRAME_DEPTH." >> $LOG - -if [ ! -z ${SDL_TOUCHSCREEN} ]; then - export JIVE_NOCURSOR=1 +if [ ${DRIVER} != "VC4" ]; then + /usr/sbin/fbset -depth $JL_FRAME_DEPTH >> $LOG +else + case "${SCREENROTATE}" in + 0) break;; + *) JL_FRAME_DEPTH=16;; + esac fi +echo "Frame buffer color bit depth set to $JL_FRAME_DEPTH." >> $LOG export HOME=/home/tc From 5ec98f662a206e2a1692aaf6a7f8e7d388b647f9 Mon Sep 17 00:00:00 2001 From: paul-1 <6473457+paul-1@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:26:17 -0500 Subject: [PATCH 2/6] Add logging information as a result of detections. --- jivelite-sp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/jivelite-sp b/jivelite-sp index 68467bd..a09f396 100644 --- a/jivelite-sp +++ b/jivelite-sp @@ -7,20 +7,26 @@ if [ -f /usr/local/etc/pcp/pcp.cfg ]; then fi # Autodetect Touchscreen, and then mouse if no touch is found. +TOUCH=0 +MOUSE=0 TMPFILE=$(mktemp) udevadm info --export-db | grep "P: " | grep "event" | sed 's/P: //' > $TMPFILE for LINE in $(cat $TMPFILE); do udevadm info --query=property --path=$LINE | grep -q TOUCH [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=1;MOUSE=0 - [ "$eventno" != "" ] && break + if [ "$eventno" != "" ]; then + echo -e "Automatic touchscreen detection found input device on $eventno: \nDevice Info:" >> $LOG + udevadm info --query=all --path=${LINE%/*} >> $LOG + break + fi udevadm info --query=property --path=$LINE | grep -q MOUSE [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=0;MOUSE=1 - [ "$eventno" != "" ] && break + [ "$eventno" != "" ] && echo "Found mouse: $eventno" >> $LOG && break done rm -f $TMPFILE -if [ x"" != x"$eventno" ]; then - [ $TOUCH -eq 1 ] && export JIVE_NOCURSOR=1 +if [ x"" != x"$eventno" -a $TOUCH -eq 1 ]; then + export JIVE_NOCURSOR=1 export TSLIB_TSDEVICE=/dev/input/$eventno export SDL_MOUSEDRV=TSLIB export SDL_MOUSEDEV=$TSLIB_TSDEVICE @@ -36,6 +42,7 @@ if [ ! -z ${JL_FRAME_BUFFER} ]; then BCM2708) DRIVER="BCM2708";; *) DRIVER="OTHER" esac + echo "Detected framebuffer driver: $DRIVER" >> $LOG fi # Set software rotation if screen rotate is set and vc4 driver is being used. @@ -44,7 +51,6 @@ if [ ! -z ${SCREENROTATE} ]; then # Rotation CCW=270, UD=180, CW=90 degrees case "${SCREENROTATE}" in 90) export SDL_VIDEO_FBCON_ROTATION=CW;; -# 180) export SDL_VIDEO_FBCON_ROTATION=UD ; export TSLIB_CALIBFILE=/usr/local/etc/pointercal-r2 ;; 180) export SDL_VIDEO_FBCON_ROTATION=UD;; 270) export SDL_VIDEO_FBCON_ROTATION=CCW;; *) unset SDL_VIDEO_FBCON_ROTATION;; From 21f6f10a47c39a59a5090858ecd04e00fdf0eab6 Mon Sep 17 00:00:00 2001 From: paul-1 <6473457+paul-1@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:36:27 -0500 Subject: [PATCH 3/6] Add some comments to script for editing clues. --- jivelite-sp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jivelite-sp b/jivelite-sp index a09f396..4e28180 100644 --- a/jivelite-sp +++ b/jivelite-sp @@ -1,5 +1,18 @@ #!/bin/sh +# Jivelite device detection and startup script. +# - Script handles all RasberryPi DSI touchscreens on RasberryPi boards +# - If you have an spi based screen that needs configuration. +# - Copy this script to /etc/sysconfig/tcedir/jivlite.sh +# +# +# - Insert screen startup related code + + + +# - End screen related startup code +# + export LOG=/var/log/pcp_jivelite.log if [ -f /usr/local/etc/pcp/pcp.cfg ]; then From 4d92292afa13741816ba34ea4893b7d55490b349 Mon Sep 17 00:00:00 2001 From: paul-1 <6473457+paul-1@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:08:29 -0500 Subject: [PATCH 4/6] Match rotation angles for RPi Display2. --- jivelite-sp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jivelite-sp b/jivelite-sp index 4e28180..fec2fec 100644 --- a/jivelite-sp +++ b/jivelite-sp @@ -63,9 +63,9 @@ if [ ! -z ${SCREENROTATE} ]; then if [ "${DRIVER}" = "VC4" ]; then # Rotation CCW=270, UD=180, CW=90 degrees case "${SCREENROTATE}" in - 90) export SDL_VIDEO_FBCON_ROTATION=CW;; + 90) export SDL_VIDEO_FBCON_ROTATION=CCW;; 180) export SDL_VIDEO_FBCON_ROTATION=UD;; - 270) export SDL_VIDEO_FBCON_ROTATION=CCW;; + 270) export SDL_VIDEO_FBCON_ROTATION=CW;; *) unset SDL_VIDEO_FBCON_ROTATION;; esac fi From 58857e8c51d093f8e5e81c4a6f4fedd72759420d Mon Sep 17 00:00:00 2001 From: paul-1 <6473457+paul-1@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:29:50 -0500 Subject: [PATCH 5/6] Automatically load multitouch driver for USBHID touch devices. Set tslib debounce for these devices. --- jivelite-sp | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/jivelite-sp b/jivelite-sp index fec2fec..32aef9c 100644 --- a/jivelite-sp +++ b/jivelite-sp @@ -25,24 +25,32 @@ MOUSE=0 TMPFILE=$(mktemp) udevadm info --export-db | grep "P: " | grep "event" | sed 's/P: //' > $TMPFILE for LINE in $(cat $TMPFILE); do - udevadm info --query=property --path=$LINE | grep -q TOUCH - [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=1;MOUSE=0 - if [ "$eventno" != "" ]; then - echo -e "Automatic touchscreen detection found input device on $eventno: \nDevice Info:" >> $LOG - udevadm info --query=all --path=${LINE%/*} >> $LOG - break - fi - udevadm info --query=property --path=$LINE | grep -q MOUSE - [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=0;MOUSE=1 - [ "$eventno" != "" ] && echo "Found mouse: $eventno" >> $LOG && break + udevadm info --query=property --path=$LINE | grep -q TOUCH + [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=1;MOUSE=0 + if [ "$eventno" != "" ]; then + echo -e "Automatic touchscreen detection found input device on $eventno: \nDevice Info:" >> $LOG + udevadm info --query=all --path=${LINE%/*} >> $LOG + + # Recent USBHID touch screens require the multitouch driver + udevadm info --query=all --path=${LINE%/*} | grep -q "E: ID_USB_DRIVER=usbhid" + if [ $? -eq 0 ]; then + echo "Detected USB HID touchscreen driver, enabling multitouch driver." >> $LOG + modprobe hid_multitouch + sed -i 's/^# module debounce/module debounce/' /usr/local/etc/ts.conf + break + fi + fi + udevadm info --query=property --path=$LINE | grep -q MOUSE + [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=0;MOUSE=1 + [ "$eventno" != "" ] && echo "Found mouse: $eventno" >> $LOG && break done rm -f $TMPFILE if [ x"" != x"$eventno" -a $TOUCH -eq 1 ]; then - export JIVE_NOCURSOR=1 - export TSLIB_TSDEVICE=/dev/input/$eventno - export SDL_MOUSEDRV=TSLIB - export SDL_MOUSEDEV=$TSLIB_TSDEVICE + export JIVE_NOCURSOR=1 + export TSLIB_TSDEVICE=/dev/input/$eventno + export SDL_MOUSEDRV=TSLIB + export SDL_MOUSEDEV=$TSLIB_TSDEVICE fi # Determine the driver being used. (drm-rpi-dsadrmf is a pi5 which must use the vc4 driver) From 235bdeaeb4102f86214d5dfabe0bdb1cbce03a64 Mon Sep 17 00:00:00 2001 From: paul-1 <6473457+paul-1@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:37:27 -0500 Subject: [PATCH 6/6] Break in wrong spot. --- jivelite-sp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jivelite-sp b/jivelite-sp index 32aef9c..6f18b53 100644 --- a/jivelite-sp +++ b/jivelite-sp @@ -37,8 +37,8 @@ for LINE in $(cat $TMPFILE); do echo "Detected USB HID touchscreen driver, enabling multitouch driver." >> $LOG modprobe hid_multitouch sed -i 's/^# module debounce/module debounce/' /usr/local/etc/ts.conf - break fi + break fi udevadm info --query=property --path=$LINE | grep -q MOUSE [ $? -eq 0 ] && eventno=$(basename $LINE);TOUCH=0;MOUSE=1