Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Solved: HDMI screen rotation doesn't "stick"
#1
Hi, it's been a couple of years since I've checked in here, as my Moodes have been fine.  Tongue

I decided that I was going to do a full upgrade to the current Moode image, and so far everything seems to be fine, but bookworm broke my screen configuration.

I was using a small Waveshare HDMI screen in Portrait mode, rotated by settings in config.txt. This no longer works in bookworm, but it appears that the solution is supposed to be to add "video=HDMI-A-1:800x480@60,rotate=90" to /boot/firmware/cmdline.txt. This seems to work, as partway through the boot sequence, the text rotates to the correct orientation and stays that way until the login prompt shows. 

When the local Moode display starts up, however, it starts in the native landscape mode. It appears that somehow Moode is overriding the cmdline.txt setting, which I hope is the incorrect behaviour.

Is this a bug? Is there something else I'm missing in setting up the local display?
TIA
Michael

RPi4 —> HiFiBerry DAC+ —> Rotel RA01 —> Celestion DL8
Reply
#2
I don't think it's a moode bug because the script that starts the local display only queries for the screen size, it does not update it.

You could try running the command below and see if it reports the right screen size.

If /boot/firmware/config.txt contains #dtoverlay=vc4-kms-v3d (with the pound sign)
Code:
fbset -s | awk '$1 == "geometry" {print $2","$3}'

If /boot/firmware/config.txt contains dtoverlay=vc4-kms-v3d (without the pound sign)
Code:
kmsprint | awk '$1 == "FB" {print $3}' | awk -F"x" '{print $1","$2}'
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
It's got dtoverlay=vc4-kms-v3d

The response to the dmsprint command is 800,480, even though the tty display is rotated (not sure if it should say 480,800 but I don't see anything in kmsprint that seems to indicate rotation status.)

When I remove "rotate=90" from cmdline.txt and reboot, the boot up to and including the login prompt stays in portrait orientation, and Moode starts up in portrait as well. The kmsprint awk gives the same response i.e. 800,480

For sheer bloody mindedness, I compared the full kmsprint output, and they're the same whether I use rotate=90 or not.

FWIW, there seems to be a fair bit of this going on. e.g. https://forums.raspberrypi.com/viewtopic.php?t=365313 (for a Pi5). I've been looking for things to try that might lead to changes, but the moode image doesn't seem to have Wayfire files or tools. What is the graphic system you're using?

I'm happy to try whatever you suggest if it can lead to discovering (and hopefully fixing) the problem.
Michael

RPi4 —> HiFiBerry DAC+ —> Rotel RA01 —> Celestion DL8
Reply
#4
(11-11-2024, 09:11 PM)MJR42 Wrote: It's got dtoverlay=vc4-kms-v3d

The response to the dmsprint command is 800,480, even though the tty display is rotated (not sure if it should say 480,800 but I don't see anything in kmsprint that seems to indicate rotation status.)

When I remove "rotate=90" from cmdline.txt and reboot, the boot up to and including the login prompt stays in portrait orientation, and Moode starts up in portrait as well. The kmsprint awk gives the same response i.e. 800,480

For sheer bloody mindedness, I compared the full kmsprint output, and they're the same whether I use rotate=90 or not.

FWIW, there seems to be a fair bit of this going on. e.g. https://forums.raspberrypi.com/viewtopic.php?t=365313 (for a Pi5). I've been looking for things to try that might lead to changes, but the moode image doesn't seem to have Wayfire files or tools. What is the graphic system you're using?

I'm happy to try whatever you suggest if it can lead to discovering (and hopefully fixing) the problem.

Moode continues to use X and not the new Wayland/Wayfire/labwc compositor but this "shouldn't" matter when it comes to boot level rotation and other such things but maybe it does?

You could try some X commands to see if anything useful happens.

1. Take the video settings out of cmdline.txt and reboot
2. Edit ./.xinitrc and hardcode the resolution SCREENSIZE="480x800"
3. Open Peripheral Config and RESTART the display
4. Try these commands

Code:
DISPLAY=:0 xrandr --output HDMI-1 --rotate left
DISPLAY=:0 xrandr --output HDMI-1 --rotate normal

Other xrandr options
Code:
pi@moode9test:~ $ xrandr --help
usage: xrandr [options]
 where options are:
 --display <display> or -d <display>
 --help
 -o <normal,inverted,left,right,0,1,2,3>
           or --orientation <normal,inverted,left,right,0,1,2,3>
 -q        or --query
 -s <size>/<width>x<height> or --size <size>/<width>x<height>
 -r <rate> or --rate <rate> or --refresh <rate>
 -v        or --version
 -x        (reflect in x)
 -y        (reflect in y)
 --screen <screen>
 --verbose
 --current
 --dryrun
 --nograb
 --prop or --properties
 --fb <width>x<height>
 --fbmm <width>x<height>
 --dpi <dpi>/<output>
 --output <output>
     --auto
     --mode <mode>
     --preferred
     --pos <x>x<y>
     --rate <rate> or --refresh <rate>
     --reflect normal,x,y,xy
     --rotate normal,inverted,left,right
     --left-of <output>
     --right-of <output>
     --above <output>
     --below <output>
     --same-as <output>
     --set <property> <value>
     --scale <x>[x<y>]
     --scale-from <w>x<h>
     --transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>
     --filter nearest,bilinear
     --off
     --crtc <crtc>
     --panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]
     --gamma <r>[:<g>:<b>]
     --brightness <value>
     --primary
 --noprimary
 --newmode <name> <clock MHz>
           <hdisp> <hsync-start> <hsync-end> <htotal>
           <vdisp> <vsync-start> <vsync-end> <vtotal>
           [flags...]
           Valid flags: +HSync -HSync +VSync -VSync
                        +CSync -CSync CSync Interlace DoubleScan
 --rmmode <name>
 --addmode <output> <name>
 --delmode <output> <name>
 --listproviders
 --setprovideroutputsource <prov-xid> <source-xid>
 --setprovideroffloadsink <prov-xid> <sink-xid>
 --listmonitors
 --listactivemonitors
 --setmonitor <name> {auto|<w>/<mmw>x<h>/<mmh>+<x>+<y>} {none|<output>,<output>,...}
 --delmonitor <name>
pi@moode9test:~ $
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
I need to move on to some other things for a few hours/days, but I couldn't resist checking a few things. I tried the following as an obvious quick test


Code:
DISPLAY=:0 xrandr --output HDMI-1 --rotate left
It does rotate the display, and it looks like the system is using 800x480 in 480x800 mode, and the touch display is not aligned at all. Not looking for a reply yet, just letting you know that it's something to do with the X system, so I'll be exploring the rest of your thoughts to see if I can get this all to work.

I'm hoping that the realignment of the touch system that I was using under Buster will also work here - why not? It's part of the X system.

I'll report back whether I solve this or not - just wanted to say thanks for such a quick and helpful response.
Michael

RPi4 —> HiFiBerry DAC+ —> Rotel RA01 —> Celestion DL8
Reply
#6
This worked on my 10.1" winaxit display to switch it to portrait orientation with the correct touch angle.

./.xinitrc
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2014 The moOde audio player project / Tim Curtis
#

# Turn off display power management
xset -dpms

# Screensaver timeout in secs or 'off' for no timeout
xset s off

# Capture screen size
fgrep "#dtoverlay=vc4-kms-v3d" /boot/firmware/config.txt
if [ $? -ne 0 ]; then
   SCREENSIZE="$(kmsprint | awk '$1 == "FB" {print $3}' | awk -F"x" '{print $1","$2}')"
else
   SCREENSIZE="$(fbset -s | awk '$1 == "geometry" { print $2","$3 }')"
fi
SCREENSIZE="900,1600"
DISPLAY=:0 xrandr --output HDMI-1 --rotate left
# Clear browser cache
$(/var/www/util/sysutil.sh clearbrcache)

# Launch chromium browser
chromium-browser --app="http://localhost/" \
--window-size="$SCREENSIZE" \
--window-position="0,0" \
--enable-features="OverlayScrollbar" \
--no-first-run \
--disable-infobars \
--disable-session-crashed-bubble \
--kiosk

/usr/share/X11/xorg.conf.d/40-libinput.conf
# Match on all types of devices but joysticks
#
# If you want to configure your devices, do not copy this file.
# Instead, use a config snippet that contains something like this:
#
# Section "InputClass"
#   Identifier "something or other"
#   MatchDriver "libinput"
#
#   MatchIsTouchpad "on"
#   ... other Match directives ...
#   Option "someoption" "value"
# EndSection
#
# This applies the option any libinput device also matched by the other
# directives. See the xorg.conf(5) man page for more info on
# matching devices.

Section "InputClass"
        Identifier "libinput pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchpad catchall"
        MatchIsTouchpad "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
        Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"
EndSection

Section "InputClass"
        Identifier "libinput tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

Here are the CalibrationMatrix options. I used the 270 deg option.
0    Option "CalibrationMatrix" "1 0 0 0 1 0 0 0 1"
90   Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"
180 Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"
270 Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
That was it exactly, Tim, except for the substitution of screen resolution.

I did a little investigation, and it looks like 
1) everything you highlighted in red rotated the display and set the correct resolution (using 480x800)

2) the touchscreen rotation/calibration worked as well, and is the same as I was using in Moode 7

3) dtoverlay rotate=90 changes the orientation of the (hardware) screen (to rotate counter-clockwise to 270 deg) However, this does not lead to KMSPrint reporting the correct display resolution and X11 seems to ignore it. Also, it's not necessary if you are using X11 .initrc to make the changes

My learning and conclusion: Moode is using X11, and you can easily rotate the screen to a known resolution by using the fix above.

Sent a donation to support the code work! Many thanks
Michael

RPi4 —> HiFiBerry DAC+ —> Rotel RA01 —> Celestion DL8
Reply
#8
Glad that worked. I'll have to think about how best to provide these options in Peripheral Config.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: