stm-st-stm32mp: add support to wayland/weston recipes for STM32 paltforms

https://onedigi.atlassian.net/browse/DEL-7981

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
This commit is contained in:
Arturo Buzarra 2022-06-30 13:24:39 +02:00
parent 9a2eb7ea5f
commit bdb42db0f1
22 changed files with 1025 additions and 0 deletions

View File

@ -0,0 +1,43 @@
From cae18dad41f11683aa8c99d6e884b3d59a6e6739 Mon Sep 17 00:00:00 2001
From: Mickael Reulier <mickael.reulier@st.com>
Date: Wed, 22 Mar 2017 13:52:49 +0100
Subject: [PATCH] linux-dmabuf: Add support for YUV Full color range
Add new flag yuv_full_color_range to dmabuf protocol for
YUV components color range.
If set, components are in full color range.
If not set, components are in limited color range.
Change-Id: Id4589f050d83d00298a834c444b01a13365ae6f2
Signed-off-by: Mickael Reulier <mickael.reulier@st.com>
---
unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
index 3b4861f..9f3df6e 100644
--- a/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
+++ b/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml
@@ -185,6 +185,8 @@
<entry name="y_invert" value="1" summary="contents are y-inverted"/>
<entry name="interlaced" value="2" summary="content is interlaced"/>
<entry name="bottom_first" value="4" summary="bottom field first"/>
+ <entry name="yuv_full_color_range" value="8"
+ summary="For YUV buffers, components are in full color range"/>
</enum>
<request name="create">
@@ -210,6 +212,10 @@
'bottom_first' is specified. It is undefined whether 'bottom_first'
is ignored if 'interlaced' is not set.
+ Flag 'yuv_full_color_range' specifies YUV components color range.
+ If set, components are in full color range.
+ If not set, components are in limited color range.
+
This protocol does not convey any information about field rate,
duration, or timing, other than the relative ordering between the
two fields in one buffer. A compositor may have to estimate the
--
1.9.1

View File

@ -0,0 +1,4 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-linux-dmabuf-Add-support-for-YUV-Full-color-range.patch"

View File

@ -0,0 +1,99 @@
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
DEPENDS += "${@oe.utils.conditional('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)}"
SRC_URI += " \
file://weston.ini \
file://digi_background.png \
file://weston-launch.service \
file://weston-checkgpu.service \
file://weston_profile.sh \
file://README-CHECK-GPU \
file://72-galcore.rules \
file://73-pulseaudio-hdmi.rules \
file://default_pulseaudio_profile \
file://pulseaudio_hdmi_switch.sh \
"
SRC_URI:append:stm32mpcommon = " file://check-gpu "
FILES:${PN} += " ${datadir}/weston \
${sysconfdir}/etc/default \
${systemd_system_unitdir}/weston-launch.service \
${sbindir}/ \
${sysconfdir}/etc/default \
${sysconfdir}/etc/profile.d \
${sysconfdir}/xdg/weston/weston.ini \
/home/root \
"
CONFFILES:${PN} += "${sysconfdir}/xdg/weston/weston.ini"
do_install:append() {
install -d ${D}${sysconfdir}/xdg/weston/
install -d ${D}${datadir}/weston/backgrounds
install -m 0644 ${WORKDIR}/weston.ini ${D}${sysconfdir}/xdg/weston
install -m 0644 ${WORKDIR}/digi_background.png ${D}${datadir}/weston/backgrounds/digi_background.png
install -d ${D}${systemd_system_unitdir} ${D}${sbindir}
install -d ${D}/lib/systemd/system/
if [ -e ${D}/lib/systemd/system/weston.service ]; then
rm ${D}/lib/systemd/system/weston.service ${D}/lib/systemd/system/weston.socket
install -D -p -m0644 ${WORKDIR}/weston-launch.service ${D}${systemd_system_unitdir}/weston-launch.service
sed -i -e s:/etc:${sysconfdir}:g \
-e s:/usr/bin:${bindir}:g \
-e s:/var:${localstatedir}:g \
${D}${systemd_unitdir}/system/weston-launch.service
install -d ${D}${sysconfdir}/systemd/system/multi-user.target.wants/
#ln -s /lib/systemd/system/weston-launch.service ${D}${sysconfdir}/systemd/system/multi-user.target.wants/display-manager.service
install -D -p -m0644 ${WORKDIR}/weston-checkgpu.service ${D}${systemd_system_unitdir}/
fi
install -d ${D}${sysconfdir}/profile.d
install -m 0755 ${WORKDIR}/weston_profile.sh ${D}${sysconfdir}/profile.d/
if ${@bb.utils.contains('DISTRO_FEATURES','xwayland','true','false',d)}; then
# uncomment modules line for support of xwayland
sed -i -e 's,#xwayland=true,xwayland=true,g' ${D}${sysconfdir}/xdg/weston/weston.ini
fi
sed -i 's,@DATADIR@,${datadir},g' ${D}${bindir}/weston-start
# /etc/default/weston
install -d ${D}${sysconfdir}/default
echo "WESTON_USER=weston" > ${D}${sysconfdir}/default/weston
# check GPU
install -d ${D}/home/root/
install -m 644 ${WORKDIR}/README-CHECK-GPU ${D}/home/root/
if ! test -f ${D}${base_sbindir}/check-gpu; then
install -d ${D}${base_sbindir}
echo '#!/bin/sh' > ${WORKDIR}/check-gpu.empty
echo '/bin/true' >> ${WORKDIR}/check-gpu.empty
install -m 755 ${WORKDIR}/check-gpu.empty ${D}${base_sbindir}/check-gpu
fi
# udev rules for galcore
install -D -p -m0644 ${WORKDIR}/72-galcore.rules ${D}${sysconfdir}/udev/rules.d/72-galcore.rules
# AUDIO: swith between analog stero and HDMI
install -d ${D}${sysconfdir}/default
install -m 0644 ${WORKDIR}/default_pulseaudio_profile ${D}${sysconfdir}/default/pulseaudio_profile
install -d ${D}${sysconfdir}/udev/rules.d
install -p -m 0644 ${WORKDIR}/73-pulseaudio-hdmi.rules ${D}${sysconfdir}/udev/rules.d/73-pulseaudio-hdmi.rules
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/pulseaudio_hdmi_switch.sh ${D}${bindir}/
}
do_install:append:stm32mpcommon() {
if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
install -d ${D}${base_sbindir}
install -m 755 ${WORKDIR}/check-gpu ${D}${base_sbindir}
fi
}
SYSTEMD_SERVICE:${PN}:remove = "weston.service weston.socket"
SYSTEMD_SERVICE:${PN} += "weston-launch.service weston-checkgpu.service"
#inherit useradd
USERADD_PARAM:${PN} = "--home /home/weston --shell /bin/sh --user-group -G video,input,tty,audio,weston-launch,dialout weston"
GROUPADD_PARAM:${PN} = "-r weston-launch; -r wayland"

View File

@ -0,0 +1,2 @@
SUBSYSTEMS=="graphics_class", KERNEL=="galcore", GROUP="video", MODE="0666"

View File

@ -0,0 +1 @@
SUBSYSTEMS=="drm", ACTION=="change", RUN+="/usr/bin/pulseaudio_hdmi_switch.sh

View File

@ -0,0 +1,9 @@
Check GPU
=========
GPU can be deactivated by fuse or not present in some SOC
So in case the GPU is not present, you must configure weston on pix-man by creating this file :
/etc/default/weston with this content :
OPTARGS=--use-pixman

View File

@ -0,0 +1,115 @@
#!/bin/sh -
#===============================================================================
#
# FILE: system-generator-check-gpu
#
# DESCRIPTION: The goal are to detect if the gpu are present/loaded or not
# ORGANIZATION: STMicroelectronics
# COPYRIGHT: Copyright (C) 2018, STMicroelectronics - All Rights Reserved
#===============================================================================
check_dt_status() {
gcnano_dir=$(ls /proc/device-tree/soc/ | grep gpu)
if [ -z "$gcnano_dir" ] || [ ! -d /proc/device-tree/soc/$gcnano_dir ];
then
echo "Gcnano in /proc/device-tree/soc/ is not available" > /dev/kmsg
force_no_dtb_gpu="1"
else
if [ ! -f /proc/device-tree/soc/$gcnano_dir/status ]; then
gcnano_status="okay"
else
if $(grep -q "okay" /proc/device-tree/soc/$gcnano_dir/status); then
gcnano_status="okay"
fi
fi
fi
}
check_load_module() {
local _timeout=0
if [ -n "$(cat /proc/modules | grep etnaviv)" ]; then
galcore_module=$(cat /proc/modules | grep ^etnaviv)
return
fi
while [ -z "$(cat /proc/modules | grep galcore)" ]; do
sleep 1
_timeout=$(($_timeout+1))
if [ "$_timeout" -eq "10" ]; then
echo "Time out check load galcore module expired" > /dev/kmsg
break
fi
done
galcore_module=$(cat /proc/modules | grep galcore)
}
check_devices() {
local _timeout=0
if [ -n "$(cat /proc/modules | grep etnaviv)" ]; then
galcore_device=$(cat /proc/modules | grep ^etnaviv)
return
fi
while [ -z "$(ls -l /dev/ | grep galcore)" ]; do
sleep 1
_timeout=$(($_timeout+1))
if [ "$_timeout" -eq "10" ]; then
echo "Time out check galcore device expired" > /dev/kmsg
break
fi
done
galcore_device=$(ls -l /dev/ | grep galcore)
}
check_default_weston_config() {
if [ "$force_no_dtb_gpu" = "1" ];
then
if [ -e /etc/default/weston ] && $(grep -q "Autogenerated" /etc/default/weston);
then
default_weston_status="Autogenerated"
fi
fi
}
#
# Main
#
gcnano_status="disabled"
galcore_module=""
galcore_device=""
default_weston_status=""
force_no_dtb_gpu=0
check_dt_status
check_default_weston_config
if [ "$default_weston_status" = "Autogenerated" ];
then
echo "Weston already configured"
exit 0
fi
check_load_module
check_devices
if [ "$gcnano_status" = "okay" ] && [ -n "$galcore_module" ] && [ -n "$galcore_device" ];
then
#echo "Gcnano is present and activated" > /dev/kmsg
if [ -f /etc/default/weston ] && $(grep -q "Autogenerated" /etc/default/weston) ;
then
sed -i "s/OPTARGS=--use-pixman/#OPTARGS=--use-pixman/g" /etc/default/weston
sed -i "/#Autogenerated/d" /etc/default/weston
fi
else
if [ -f /etc/default/weston ] && $(grep -q "Autogenerated" /etc/default/weston) ;
then
echo "Weston already configured on pixman" > /dev/kmsg
else
echo "Configure weston on pixman" > /dev/kmsg
echo "#Autogenerated" > /etc/default/weston
echo "OPTARGS=--use-pixman" >> /etc/default/weston
echo "WESTON_USER=weston" >> /etc/default/weston
fi
fi
dri_device=$(ls -l /dev/ | grep dri)
if [ -z "$dri_device" ];
then
exit 1
fi

View File

@ -0,0 +1,3 @@
DEFAULT_PULSE_AUDIO_LOCAL_PROFILE=output:analog-stereo
DEFAULT_PULSE_AUDIO_HDMI_PROFILE=output:hdmi-stereo

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -0,0 +1,39 @@
#!/bin/sh -
source /etc/default/pulseaudio_profile
PROFILE_LOCAL=$DEFAULT_PULSE_AUDIO_LOCAL_PROFILE
PROFILE_HDMI=$DEFAULT_PULSE_AUDIO_HDMI_PROFILE
HDMI_STATUS=$(cat /sys/class/drm/card0/*HDMI*/status)
if [ "$HDMI_STATUS" = "connected" ]; then
PROFILE=$PROFILE_HDMI
else
PROFILE=$PROFILE_LOCAL
fi
cat > /tmp/pulse_temp_switch.sh <<EOF
#!/bin/sh
cards=\$(pactl list cards | egrep -i 'Card #' | sed 's/Card //g')
index=0
for i in \$cards;
do
card_info=\$(pactl list cards | grep "Card \$i" -A15 | grep "alsa.card_name" | sed 's/ //g'| sed 's/alsa.card_name=\"//g'| sed 's/\"//g' | tr '\t' ' ' | sed 's/^\s*//g')
echo "\$i \$card_info"
# for each card, search alsa.card_name
found=\$(echo \$card_info | grep -n STM32MP | wc -l)
if [ \$found -eq 1 ];
then
echo "pactl set-card-profile \$index $PROFILE"
pactl set-card-profile \$index $PROFILE
break;
fi
index=\$((index+1))
done
EOF
chmod +x /tmp/pulse_temp_switch.sh
if [ "$USER" == "weston" ]; then
script -qc "/tmp/pulse_temp_switch.sh"
else
script -qc "su -l weston -c /tmp/pulse_temp_switch.sh"
fi
rm -f /tmp/pulse_temp_switch.sh

View File

@ -0,0 +1,13 @@
[Unit]
Description=Check if the gpu are present and set the correct weston configuration
Before=weston-launch.service
After=psplash-drm-wait.service
[Service]
ExecStart=-/sbin/check-gpu
Type=oneshot
RemainAfterExit=yes
TimeoutSec=0
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,73 @@
# This is a system unit for launching Weston with auto-login as the
# user configured here.
#
# Weston must be built with systemd support, and your weston.ini must load
# the plugin systemd-notify.so.
[Unit]
Description=Weston, a Wayland compositor, as a system service
Documentation=man:weston(1) man:weston.ini(5)
Documentation=http://wayland.freedesktop.org/
# Make sure we are started after logins are permitted.
Requires=systemd-user-sessions.service
After=systemd-user-sessions.service
# D-Bus is necessary for contacting logind. Logind is required.
Wants=dbus.socket
After=dbus.socket
After=psplash-drm-wait.service
After=weston-checkgpu.service
# Since we are part of the graphical session, make sure we are started before
# it is complete.
Before=graphical.target
# Prevent starting on systems without virtual consoles, Weston requires one
# for now.
ConditionPathExists=/dev/tty0
[Service]
# Requires systemd-notify.so Weston plugin.
#Type=notify
EnvironmentFile=-/etc/default/weston
Environment="XDG_RUNTIME_DIR=/home/weston"
Environment="WESTON_USER=weston"
Environment="WL_EGL_GBM_FENCE=0"
#ExecStart=/usr/bin/weston-launch -- --modules=systemd-notify.so --log=/home/weston/weston.log $OPTARGS
ExecStart=/usr/bin/weston-start --modules=systemd-notify.so --log=/home/weston/weston.log $OPTARGS
ExecStop=/usr/bin/killall weston-launch
# Optional watchdog setup
#TimeoutStartSec=60
#WatchdogSec=20
# The user to run Weston as.
User=weston
Group=weston
# Make sure the working directory is the users home directory
WorkingDirectory=/home/weston
# Set up a full user session for the user, required by Weston.
PAMName=weston-autologin
# A virtual terminal is needed.
TTYPath=/dev/tty7
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes
# Fail to start if not controlling the tty.
StandardInput=tty-fail
StandardOutput=journal
StandardError=journal
# Log this user with utmp, letting it show up with commands 'w' and 'who'.
UtmpIdentifier=tty7
UtmpMode=user
[Install]
# Note: If you only want weston to start on-demand, remove this line with a
# service drop file
Alias=display-manager.service
WantedBy=multi-user.target

View File

@ -0,0 +1,41 @@
#!/bin/sh
weston_args=$*
if [ -z "$WESTON_USER" ]; then
WESTON_USER=weston
fi
if [ "$USER" != "$WESTON_USER" ]; then
weston_args_user="-u $WESTON_USER"
fi
# for associated service: pulseaudio
if [ ! -d "/var/run/pulse" ]; then
su -c "mkdir -p /var/run/pulse"
su -c "chown -R weston.weston /var/run/pulse"
fi
## Module support
start_application_dir=/usr/share/weston-start-at-startup
start_local_application_dir=/usr/local/weston-start-at-startup
systemctl --user restart pulseaudio
if [ "$USER" == "$WESTON_USER" ]; then
# Load and run application at startup
if [ -d "$start_application_dir" ]; then
for m in "$start_application_dir"/*; do
echo "($m)"
(sleep 5 && $m)&
done
fi
if [ -d "$start_local_application_dir" ]; then
for m in "$start_local_application_dir"/*; do
echo "($m)"
(sleep 5 && $m)&
done
fi
fi
exec /usr/bin/weston-launch $weston_args_user -- $weston_args

View File

@ -0,0 +1,46 @@
[core]
#modules=cms-colord.so
#xwayland=true
shell=desktop-shell.so
#gbm-format=xrgb2101010
backend=drm-backend.so
idle-time=0
repaint-window=100
require-input=false
[keyboard]
keymap_layout=us
[shell]
background-image=/usr/share/weston/backgrounds/digi_background.png
background-type=scale-crop
# HDMI connector
# If the hdmi cable is plugged, weston uses the hdmi output (else dsi output).
# Use the command "systemctl restart weston@root" after pluging/unpluging the hdmi cable.
[output]
name=HDMI-A-1
mode=1280x720
# DSI connector
[output]
name=DSI-1
mode=preferred
transform=rotate-90
app-ids=1000
# LTDC connector
[output]
name=DPI-1
mode=preferred
[libinput]
touchscreen_calibrator=true
calibration_helper=/bin/echo
[screen-share]
command=/usr/bin/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize
#start-on-startup=false
#[xwayland]
#path=/usr/bin/Xwayland

View File

@ -0,0 +1,139 @@
#!/bin/sh
# Weston
#uncomment some part of the following line if you like:
# - see the weston log
# LOG_FILE: file on which the log are writed
# - use a software compositor instead of egl compositor
# USE_PIXMAN: populate the variable to use the software compositor on
# weston
# - add some new option to weston application
# ST_WESTON_ADDONS
# - debug weston via openvt
# DEBUG_OPENGL_VIA_OPENVT: file on which the all stdout, sdterr trace
# are stocked
#LOG_FILE=/tmp/weston.log
#USE_PIXMAN=1
#ST_WESTON_ADDONS
#DEBUG_OPENGL_VIA_OPENVT=/tmp/opengl.log
mkdir -p $XDG_RUNTIME_DIR
chmod 0700 $XDG_RUNTIME_DIR
# psplash management
case "$1" in
start)
PSPLASH_PID=`pgrep psplash`
if [ ! -z $PSPLASH_PID ]; then
echo -n "Stop psplash: "
/usr/bin/psplash-write QUIT
#kill -9 $PSPLASH_PID
echo "done."
fi
PSPLASH_PID=`pgrep psplash-drm`
if [ ! -z $PSPLASH_PID ]; then
echo -n "Stop psplash: "
echo QUIT > /tmp/splash_fifo
#kill -9 $PSPLASH_PID
echo "done."
fi
;;
*)
;;
esac
#log file managment on weston CMD line
CMD_LINE_WESTON=""
if [ -z $LOG_FILE ];
then
CMD_LINE_WESTON=" "
else
if [ -f $LOG_FILE ]; then
rm $LOG_FILE
fi
CMD_LINE_WESTON="--log=$LOG_FILE"
fi
if [ -z "$ST_WESTON_IDLE_TIME" ];
then
ST_WESTON_IDLE_TIME=648000
fi
#compositor managment on CMD line
if [ -z $USE_PIXMAN ];
then
echo "";
else
CMD_LINE_WESTON="$CMD_LINE_WESTON --use-pixman"
fi
#Addons paramaters
if [ -n $ST_WESTON_ADDONS ];
then
CMD_LINE_WESTON="$CMD_LINE_WESTON $ST_WESTON_ADDONS"
fi
# See how we were called.
case "$1" in
start)
if [ ! -z $LOG_FILE ];
then
echo "[SERVICE] start.........." >> $LOG_FILE
fi
echo "Starting Weston"
if [ -n "$DEBUG_OPENGL_VIA_OPENVT" ];
then
echo "[DEBUG] use script /tmp/launch_basic_weston.sh"
echo "[DEBUG] output saved on file $DEBUG_OPENGL_VIA_OPENVT"
#generate a wrapper script to launch weston
cat > /tmp/launch_basic_weston.sh << EOF
/usr/bin/weston $CMD_LINE_WESTON 2>&1 > $DEBUG_OPENGL_VIA_OPENVT
EOF
chmod +x /tmp/launch_basic_weston.sh
openvt -s -w -- /tmp/launch_basic_weston.sh
else
echo "/usr/bin/weston $CMD_LINE_WESTON"
openvt -s -w -- /usr/bin/weston $CMD_LINE_WESTON
# weston --tty=1 $CMD_LINE_WESTON
fi
;;
stop)
echo "Stopping Weston"
if [ ! -z $LOG_FILE ];
then
echo "[SERVICE] stop.........." >> $LOG_FILE
fi
pid_weston=`pidof weston`
kill -9 $pid_weston
;;
status)
if pidof weston >/dev/null
then
echo "Weston: running"
echo "CMDLINE of weston:"
echo " /usr/bin/weston $CMD_LINE_WESTON"
else
echo "Weston: not running"
exit 3
fi
exit 0
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: weston.sh {start|stop|status|restart}"
exit 1
;;
esac
exit 0

View File

@ -0,0 +1,16 @@
if [ "$USER" == "weston" ]; then
export XDG_RUNTIME_DIR=/run/user/`id -u weston`
export ELM_ENGINE=wayland_shm
export ECORE_EVAS_ENGINE=wayland_shm
export ECORE_EVAS_ENGINE=wayland_shm
export GDK_BACKEND=wayland
export PULSE_RUNTIME_PATH=/run/user/`id -u weston`
if [ -e $XDG_RUNTIME_DIR/wayland-0 ]; then
export WAYLAND_DISPLAY=wayland-0
else
if [ -e $XDG_RUNTIME_DIR/wayland-1 ]; then
export WAYLAND_DISPLAY=wayland-1
fi
fi
fi

View File

@ -0,0 +1,40 @@
From c2489e20f7803159444150ff03bd78fbf9b1bae4 Mon Sep 17 00:00:00 2001
From: Christophe Priouzeau <christophe.priouzeau@st.com>
Date: Thu, 19 Mar 2020 12:15:19 +0100
Subject: [PATCH 1/4] Allow to get hdmi output with several outputs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If an ouput fail to be attach or enable then this output must be only
destroyed and an error doesn't be re which detach & destroy
all other output.
Signed-off-by: Yannick Fertré <yannick.fertre@st.com>
---
compositor/main.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/compositor/main.c b/compositor/main.c
index 322f2ff..055eed3 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -2246,8 +2246,14 @@ drm_process_layoutput(struct wet_compositor *wet, struct wet_layoutput *lo)
return -1;
if (drm_try_attach_enable(output->output, lo) < 0) {
+ /*
+ * if a wet_ouput fail to be attach or enable
+ * then this output must be destroyed
+ * but don't return an error which dettatch & destroy
+ * all other output.
+ */
wet_output_destroy(output);
- return -1;
+ //return -1;
}
}
--
2.25.1

View File

@ -0,0 +1,178 @@
From 7f9365919153c9ba17bfeb48049df2ee5a77b047 Mon Sep 17 00:00:00 2001
From: Pierre-Yves MORDRET <pierre-yves.mordret@st.som>
Date: Mon, 23 May 2022 14:27:13 +0200
Subject: [PATCH] Remove useless code from new Fragment Shader
Generic Weston 10.0 consumes more GPU than before (8.0).
The compilation doesn't get rid from unreachable code.
Since not used and not optimized during compilation
state, we simply remove the code.
Change-Id: I37880d5fcb8487c77e084b289db8d2fb945c21ab
Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.som>
---
libweston/renderer-gl/fragment.glsl | 93 ++---------------------------
libweston/renderer-gl/gl-shaders.c | 5 --
2 files changed, 5 insertions(+), 93 deletions(-)
diff --git a/libweston/renderer-gl/fragment.glsl b/libweston/renderer-gl/fragment.glsl
index 63a20cd6..f735ab3a 100644
--- a/libweston/renderer-gl/fragment.glsl
+++ b/libweston/renderer-gl/fragment.glsl
@@ -42,30 +42,17 @@
#define SHADER_VARIANT_SOLID 7
#define SHADER_VARIANT_EXTERNAL 8
-/* enum gl_shader_color_curve */
-#define SHADER_COLOR_CURVE_IDENTITY 0
-#define SHADER_COLOR_CURVE_LUT_3x1D 1
-
#if DEF_VARIANT == SHADER_VARIANT_EXTERNAL
#extension GL_OES_EGL_image_external : require
#endif
-#ifdef GL_FRAGMENT_PRECISION_HIGH
-#define HIGHPRECISION highp
-#else
-#define HIGHPRECISION mediump
-#endif
-
-precision HIGHPRECISION float;
+precision mediump float;
/*
* These undeclared identifiers will be #defined by a runtime generated code
* snippet.
*/
compile_const int c_variant = DEF_VARIANT;
-compile_const bool c_input_is_premult = DEF_INPUT_IS_PREMULT;
-compile_const bool c_green_tint = DEF_GREEN_TINT;
-compile_const int c_color_pre_curve = DEF_COLOR_PRE_CURVE;
vec4
yuva2rgba(vec4 yuva)
@@ -91,6 +78,7 @@ yuva2rgba(vec4 yuva)
color_out.g = Y - 0.39176229 * su - 0.81296764 * sv;
color_out.b = Y + 2.01723214 * su;
+ color_out.rgb *= yuva.w;
color_out.a = yuva.w;
return color_out;
@@ -107,8 +95,6 @@ uniform sampler2D tex1;
uniform sampler2D tex2;
uniform float alpha;
uniform vec4 unicolor;
-uniform HIGHPRECISION sampler2D color_pre_curve_lut_2d;
-uniform HIGHPRECISION vec2 color_pre_curve_lut_scale_offset;
vec4
sample_input_texture()
@@ -154,85 +140,16 @@ sample_input_texture()
return yuva2rgba(yuva);
}
-/*
- * Texture coordinates go from 0.0 to 1.0 corresponding to texture edges.
- * When we do LUT look-ups with linear filtering, the correct range to sample
- * from is not from edge to edge, but center of first texel to center of last
- * texel. This follows because with LUTs, you have the exact end points given,
- * you never extrapolate but only interpolate.
- * The scale and offset are precomputed to achieve this mapping.
- */
-float
-lut_texcoord(float x, vec2 scale_offset)
-{
- return x * scale_offset.s + scale_offset.t;
-}
-
-/*
- * Sample a 1D LUT which is a single row of a 2D texture. The 2D texture has
- * four rows so that the centers of texels have precise y-coordinates.
- */
-float
-sample_color_pre_curve_lut_2d(float x, compile_const int row)
-{
- float tx = lut_texcoord(x, color_pre_curve_lut_scale_offset);
-
- return texture2D(color_pre_curve_lut_2d,
- vec2(tx, (float(row) + 0.5) / 4.0)).x;
-}
-
-vec3
-color_pre_curve(vec3 color)
-{
- vec3 ret;
-
- if (c_color_pre_curve == SHADER_COLOR_CURVE_IDENTITY) {
- return color;
- } else if (c_color_pre_curve == SHADER_COLOR_CURVE_LUT_3x1D) {
- ret.r = sample_color_pre_curve_lut_2d(color.r, 0);
- ret.g = sample_color_pre_curve_lut_2d(color.g, 1);
- ret.b = sample_color_pre_curve_lut_2d(color.b, 2);
- return ret;
- } else {
- /* Never reached, bad c_color_pre_curve. */
- return vec3(1.0, 0.3, 1.0);
- }
-}
-
-vec4
-color_pipeline(vec4 color)
-{
- /* View alpha (opacity) */
- color.a *= alpha;
-
- color.rgb = color_pre_curve(color.rgb);
-
- return color;
-}
-
void
main()
{
vec4 color;
- /* Electrical (non-linear) RGBA values, may be premult or not */
+ /* Electrical (non-linear) RGBA values, pre-multiplied */
color = sample_input_texture();
- /* Ensure straight alpha */
- if (c_input_is_premult) {
- if (color.a == 0.0)
- color.rgb = vec3(0, 0, 0);
- else
- color.rgb *= 1.0 / color.a;
- }
-
- color = color_pipeline(color);
-
- /* pre-multiply for blending */
- color.rgb *= color.a;
-
- if (c_green_tint)
- color = vec4(0.0, 0.3, 0.0, 0.2) + color * 0.8;
+ /* View alpha (opacity) */
+ color *= alpha;
gl_FragColor = color;
}
diff --git a/libweston/renderer-gl/gl-shaders.c b/libweston/renderer-gl/gl-shaders.c
index 97f288c0..c8e3d297 100644
--- a/libweston/renderer-gl/gl-shaders.c
+++ b/libweston/renderer-gl/gl-shaders.c
@@ -263,11 +263,6 @@ gl_shader_create(struct gl_renderer *gr,
shader->alpha_uniform = glGetUniformLocation(shader->program, "alpha");
shader->color_uniform = glGetUniformLocation(shader->program,
"unicolor");
- shader->color_pre_curve_lut_2d_uniform =
- glGetUniformLocation(shader->program, "color_pre_curve_lut_2d");
- shader->color_pre_curve_lut_scale_offset_uniform =
- glGetUniformLocation(shader->program, "color_pre_curve_lut_scale_offset");
-
free(conf);
wl_list_insert(&gr->shader_list, &shader->link);
--
2.17.1

View File

@ -0,0 +1,36 @@
From 5d96505846d911c942a42f74c2a6f816f5c940b5 Mon Sep 17 00:00:00 2001
From: Christophe Priouzeau <christophe.priouzeau@st.com>
Date: Thu, 19 Mar 2020 12:20:32 +0100
Subject: [PATCH 2/4] Force to close all output
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In case of plug/unplug HMDI, it's necessary to close all output enabled.
Without this patch, weston is stuck on DSI output.
Signed-off-by: Yannick Fertré <yannick.fertre@st.com>
---
compositor/main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/compositor/main.c b/compositor/main.c
index 055eed3..ac366a0 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -2322,7 +2322,11 @@ drm_heads_changed(struct wl_listener *listener, void *arg)
if ((connected || forced) && !enabled) {
drm_head_prepare_enable(wet, head);
- } else if (!(connected || forced) && enabled) {
+ } else if (enabled) {
+ /*
+ * closed all output (connected or not connected)
+ * this is neccessary to switch between HDMI <> DSI
+ */
drm_head_disable(head);
} else if (enabled && changed) {
weston_log("Detected a monitor change on head '%s', "
--
2.25.1

View File

@ -0,0 +1,49 @@
From 00384d5c39473f95868b1173aee81b763794de54 Mon Sep 17 00:00:00 2001
From: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
Date: Tue, 26 Apr 2022 09:59:10 +0200
Subject: [PATCH 3/4] Disable gles3
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
---
libweston/renderer-gl/gl-renderer.c | 6 ++++++
.../renderer-gl/gl-shader-config-color-transformation.c | 5 +++++
2 files changed, 11 insertions(+)
diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
index a5f5eae..2f7941f 100644
--- a/libweston/renderer-gl/gl-renderer.c
+++ b/libweston/renderer-gl/gl-renderer.c
@@ -29,7 +29,13 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+#if 0
#include <GLES3/gl3.h>
+#else
+#define GL_RGBA16F 0x881A
+#define GL_RGB10_A2 0x8059
+#define GL_HALF_FLOAT 0x140B
+#endif
#include <stdbool.h>
#include <stdint.h>
diff --git a/libweston/renderer-gl/gl-shader-config-color-transformation.c b/libweston/renderer-gl/gl-shader-config-color-transformation.c
index 21a4565..d5f2491 100644
--- a/libweston/renderer-gl/gl-shader-config-color-transformation.c
+++ b/libweston/renderer-gl/gl-shader-config-color-transformation.c
@@ -25,7 +25,12 @@
#include "config.h"
+#if 0
#include <GLES3/gl3.h>
+#else
+#include <GLES2/gl2.h>
+#define GL_R32F 0x822E
+#endif
#include <GLES2/gl2ext.h>
#include <assert.h>
--
2.25.1

View File

@ -0,0 +1,56 @@
From 45a8c37e9dbff9207d58846df048406bf54ce30b Mon Sep 17 00:00:00 2001
From: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
Date: Fri, 6 May 2022 11:41:10 +0200
Subject: [PATCH 4/4] Revert gl-renderer: Add EGL_IMAGE_PRESERVED_KHR to our
attributes
Signed-off-by: Christophe Priouzeau <christophe.priouzeau@foss.st.com>
---
libweston/renderer-gl/gl-renderer.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c
index 2f7941f..2ab707c 100644
--- a/libweston/renderer-gl/gl-renderer.c
+++ b/libweston/renderer-gl/gl-renderer.c
@@ -2152,7 +2152,7 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
struct weston_compositor *ec = es->compositor;
struct gl_renderer *gr = get_renderer(ec);
struct gl_surface_state *gs = get_surface_state(es);
- EGLint attribs[5];
+ EGLint attribs[3];
GLenum target;
int i, num_planes;
@@ -2205,9 +2205,7 @@ gl_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer,
for (i = 0; i < num_planes; i++) {
attribs[0] = EGL_WAYLAND_PLANE_WL;
attribs[1] = i;
- attribs[2] = EGL_IMAGE_PRESERVED_KHR;
- attribs[3] = EGL_TRUE;
- attribs[4] = EGL_NONE;
+ attribs[2] = EGL_NONE;
gs->images[i] = egl_image_create(gr,
EGL_WAYLAND_BUFFER_WL,
@@ -2242,7 +2240,7 @@ import_simple_dmabuf(struct gl_renderer *gr,
struct dmabuf_attributes *attributes)
{
struct egl_image *image;
- EGLint attribs[52];
+ EGLint attribs[50];
int atti = 0;
bool has_modifier;
@@ -2260,8 +2258,6 @@ import_simple_dmabuf(struct gl_renderer *gr,
attribs[atti++] = attributes->height;
attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT;
attribs[atti++] = attributes->format;
- attribs[atti++] = EGL_IMAGE_PRESERVED_KHR;
- attribs[atti++] = EGL_TRUE;
if (attributes->modifier[0] != DRM_FORMAT_MOD_INVALID) {
if (!gr->has_dmabuf_import_modifiers)
--
2.25.1

View File

@ -0,0 +1,23 @@
FILESEXTRAPATHS:prepend:stm32mpcommon := "${THISDIR}/${PN}:"
SRC_URI:append:stm32mpcommon = " \
file://0001-Allow-to-get-hdmi-output-with-several-outputs.patch \
file://0002-Force-to-close-all-output.patch \
file://0003-Disable-gles3.patch \
file://0004-Revert-gl-renderer-Add-EGL_IMAGE_PRESERVED_KHR-to-ou.patch \
file://0001-Remove-useless-code-from-new-Fragment-Shader.patch \
"
SIMPLECLIENTS="egl,touch,dmabuf-v4l,dmabuf-egl"
PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'kms wayland egl clients', '', d)} \
${@bb.utils.contains('DISTRO_FEATURES', 'x11 wayland', 'xwayland', '', d)} \
${@bb.utils.filter('DISTRO_FEATURES', 'systemd x11', d)} \
${@bb.utils.contains_any('DISTRO_FEATURES', 'wayland x11', '', 'headless', d)} \
${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'sysvinit', 'launcher-libseat', '', d)} \
image-jpeg \
screenshare \
shell-desktop \
shell-fullscreen \
launch"
EXTRA_OEMESON += "-Ddeprecated-wl-shell=true"