VU7A - rotate 180 degrees in linux

Post Reply
User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

VU7A - rotate 180 degrees in linux

Unread post by mad_ady » Wed Oct 30, 2019 6:16 pm

Hello,
I'm trying to set up my VU7A as a digital photo frame for use on my C2 that already has a 3.5" screen. The 3.5" screen works with Xorg/lightdm (and I want to keep it that way). I will be using the VU7 as a framebuffer, without touch, with fim, to display photos (something like fim -a -d /dev/fb0 Awesome-HD-Pic.jpg). So far the VU7 and 3.5" displays seem to coexist fine (haven't seen Xorg trying to start on the VU7), but I need to rotate the framebuffer on the VU7 so that I can mount it upside-down so that the cables exit through the left side.

I tried:

Code: Select all

root@uy-scuti:~# cat /sys/class/graphics/fb0/rotate
0
root@uy-scuti:~# echo 2 > /sys/class/graphics/fb0/rotate
root@uy-scuti:~# cat /sys/class/graphics/fb0/rotate
2
Though the setting sticks, the framebuffer is still the same, not rotated.

I also tried:

Code: Select all

root@uy-scuti:~# cat /sys/class/graphics/fbcon/rotate
0
root@uy-scuti:~# echo 2 > /sys/class/graphics/fbcon/rotate
root@uy-scuti:~# cat /sys/class/graphics/fbcon/rotate
0
But it doesn't stick and doesn't work.

I could use imagemagik and rotate the image before displaying it, but it's messy and leaves fim's status bar upside-down which I dislike, so I'd like to see how I can rotate the whole display from software.
Any ideas?

User avatar
odroid
Site Admin
Posts: 32552
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 189 times
Been thanked: 352 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by odroid » Wed Oct 30, 2019 6:26 pm

I have no experience of rotating the framebuffer console.
"CONFIG_FRAMEBUFFER_CONSOLE_ROTATION" is enabled in Kernel config?

User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by mad_ady » Wed Oct 30, 2019 7:05 pm

Yes, it's enabled:

Code: Select all

adrianp@uy-scuti:~$ zcat /proc/config.gz | grep FRAMEBUFFER_CONSOLE_ROTATION
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
And when I rebooted, I could see the console text rotated on the display, as I intended. I need to play with it some more... Maybe the console is rotated, not the framebuffer, and fim uses the framebuffer directly... I need to do more digging...

User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by mad_ady » Wed Oct 30, 2019 9:53 pm

Ok, I've done some talking with @crashoverride on IRC and he confirms that /sys/class/graphics/fb0/rotate only applies to the console, not the framebuffer. So, he suggested an alternative - extend fb1 (the cursor plane) to fb0's dimensions, copy the contents of fb0 to fb1 while applying a rotation and I should have a rotated display. His suggestion was using some low-level (for me) C API that he's working on, but I went the known path - with shell commands.

Here's what I managed so far:
1. Extend fb1 to be as large as fb0:

Code: Select all

fbset -xres 1024 -yres 1200 -match -fb /dev/fb1
When I ran this command I got a screen of noise on top of my image.
Image
I tried to clear it (already turned off /dev/fb0) with:

Code: Select all

cat /dev/zero > /dev/fb1
but only about 1/3rd of the screen was cleared. (@crashoverride points out it's 42.6%!)
Image

2. Copy the framebuffer fb0 to a file:

Code: Select all

apt-get install fbgrab
fbcat /dev/fb0 > image.ppm
3. Rotate the image and write it to a framebuffer friendly format:

Code: Select all

convert image.ppm -rotate 180 -color-matrix '0 0 1 0 1 0 1 0 0'  image-rotated.rgba
4. Write the image to fb1:

Code: Select all

cat image-rotated.rgba > /dev/fb1
Image

So, if only I could find a way to use the complete fb1 framebuffer, I could make it work... Maybe the size of /dev/fb1 is limited somewhere in the kernel? Where would I start checking?

Code: Select all

root@uy-scuti:/dev/shm# fbset -fb /dev/fb0

mode "1024x600-60"
    # D: 49.000 MHz, H: 37.348 kHz, V: 60.045 Hz
    geometry 1024 600 1024 1200 32
    timings 20408 270 5 17 2 13 3
    nonstd 1
    rgba 8/16,8/8,8/0,0/24
endmode

root@uy-scuti:/dev/shm# fbset -fb /dev/fb1

mode "1024x1200"
    geometry 1024 1200 1024 1200 32
    timings 0 0 0 0 0 0 0
    rgba 8/16,8/8,8/0,8/24
endmode


User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by mad_ady » Wed Oct 30, 2019 10:53 pm

Edit: @crashoverride pointed out the problem. The memory allocation for fb1 is not enough to support the VU7's resolution. So the resolution needs to be increased from 1M to let's say 8M (needs to be more than 2.5M):

Code: Select all

fdtput /media/boot/meson64_odroidc2.dtb /meson-fb mem_size 100663296 8388608
After reboot, the rotated picture is correctly displayed.

Thanks @crashoverride for saving the day once more!

User avatar
odroid
Site Admin
Posts: 32552
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 189 times
Been thanked: 352 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by odroid » Thu Oct 31, 2019 10:31 am

Good to hear you found a solution by helping from crashoverride. :)

But "fim" also has a parameter r to rotate an image.

User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by mad_ady » Thu Oct 31, 2019 2:08 pm

I know about that, but it's not a startup parameter and needs to be injected via keyboard for every picture (could be scripted, but would be problematic for screensavers). Also it rotates just the picture, leaving the status bar upside down.

User avatar
odroid
Site Admin
Posts: 32552
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 189 times
Been thanked: 352 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by odroid » Thu Oct 31, 2019 3:49 pm

Ahh.. make sense.

User avatar
mad_ady
Posts: 6796
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 216 times
Been thanked: 166 times
Contact:

Re: VU7A - rotate 180 degrees in linux

Unread post by mad_ady » Fri Nov 01, 2019 9:34 pm

Here's the inefficient script that does what I described above:

Code: Select all

#!/bin/bash

#copy the image from SRCFB, rotate it by 180 degrees and show it on DSTFB
#the hard way...

#https://forum.odroid.com/viewtopic.php?f=101&t=36708

#dependencies:
#fbset
#fbgrab
#convert

XRES=1024
YRES=1200
SRCFB=fb0
DSTFB=fb1
#should be a ramdirve
TMPDIR=/dev/shm
SLEEP=0.5

#extend fb1 to match VU7 resolution
fbset -xres $XRES -yres $YRES -match -fb /dev/$DSTFB

#clear fb1
cat /dev/zero > /dev/$DSTFB

while :
do
    #date +%N
    fbcat /dev/$SRCFB > "$TMPDIR/image.ppm"
    convert "$TMPDIR/image.ppm" -rotate 180 -color-matrix '0 0 1 0 1 0 1 0 0' "$TMPDIR/image-rotated.rgba"
    cat "$TMPDIR/image-rotated.rgba" > /dev/$DSTFB
    sleep $SLEEP
done

With SLEEP=0 it can do about 3fps, but increases the system load.

There is a 0 CPU method by @crashoverride that I may look into, but for now this will do. I'll leave here his advice, because otherwise I'll lose it...
(16:07:10) crashovrd: it is, however, EASY to blit it and color convert it from NV12 with GE2D
(16:07:14) crashovrd: ITS SO EASY!
(16:09:44) crashovrd: btw, the code to do it is here: https://github.com/OtherCrashOverride/c2screen2lcd
(16:10:13) crashovrd: just replace 'fb2" with "fb1" for starters
(16:10:15) crashovrd: https://github.com/OtherCrashOverride/c ... in.cpp#L84
(16:10:55) crashovrd: will also need some minor changes to use 32bit color instead of 16bit
(16:11:03) crashovrd: the code is for the C2 LCD shield
(16:11:45) crashovrd: and you dont need all the ion stuff
(16:11:49) crashovrd: so you can just replace https://github.com/OtherCrashOverride/c ... #L153-L161
(16:12:23) crashovrd: and specify CANVAS_OSD1 instead
(16:12:51) crashovrd: so fwiw, you really only need the main.cpp file
(16:13:13) crashovrd: it does exactly what i talked about earlier
(16:13:26) crashovrd: copies from fb0 to fb2 on every VSYNC
(16:13:49) crashovrd: but since GE2D natively understand what FB0 and FB1 are, you dont need the ion stuff
(16:14:16) crashovrd: that was only for the LCD fb that used its non canvas framebuffer
(16:16:15) crashovrd: huh, i thought the video blit was already in there
(16:16:19) crashovrd: maybe on a different branch
(16:16:42) crashovrd: it just adds a blit from VID0 before the blit from OSD0
(16:17:16) crashovrd: ah! here it is: https://github.com/OtherCrashOverride/c ... ee/amvideo
(16:34:15) crashovrd: GE2D will do the flip for you during its blit
(16:34:25) crashovrd: ZERO cpu cost
(16:35:33) crashovrd: https://github.com/OtherCrashOverride/c ... e2d.h#L640
(16:35:51) crashovrd: set it to 1
These users thanked the author mad_ady for the post:
rooted (Sat Nov 02, 2019 3:59 pm)

Post Reply

Return to “ODROID-VU”

Who is online

Users browsing this forum: No registered users and 3 guests