Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garbled output with official touchscreen if DRM_CAP_ASYNC_PAGE_FLIP is used #1851

Closed
maru-sama opened this issue Dec 1, 2023 · 14 comments
Closed

Comments

@maru-sama
Copy link

Describe the bug
I recently upgraded to bookworm and in this process also updated the SDL libraries I am using for my KIVY based touchscreen application. I used the python3-kivy deb and started my application which runs on the console. Instead of the normal GUI I just saw garbled output.
Initially I thought that it was a SDL issue but after bisecting it I found out that DRM_CAP_ASYNC_PAGE_FLIP was the culprit. Starting in SDL-2.0.16 async page flip is supported by SDL and probed for.
Apparently the rpi drm implementation supports it so SDL enables it but this results in garbled output. For testing purposes I recompiled SDL, turned off ASYNC_PAGE_FLIP and it worked fine,
I am not sure if this is a mesa/drm or kernel issue, but as it is right now kivy on the console is not working with the official touchscreen display rpi4 and bookworm.

To reproduce

  • Install python3-kivy
  • Run one of the demo applications on the console using DRM

Expected behaviour
Normal output of the Kivy GUI

Actual behaviour
Garbled output

System

Raspberry Pi 4 Model B Rev 1.4
PRETTY_NAME="Raspbian GNU/Linux 12 (bookworm)"
NAME="Raspbian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"

Raspberry Pi reference 2016-03-18
Generated using Pi-gen, https://github.com/RPi-Distro/Pi-gen, stage2

Linux rpi 6.1.0-rpi6-rpi-v7l #1 SMP Raspbian 1:6.1.58-1+rpt2 (2023-10-27) armv7l GNU/Linux
Revision : d03114
Serial : 10000000d53fdaf2
Model : Raspberry Pi 4 Model B Rev 1.4
Throttled flag : throttled=0x0
Camera : supported=0 detected=0, libcamera interfaces=0

Videocore information

Oct 17 2023 15:39:16
Copyright (c) 2012 Broadcom
version 30f0c5e4d076da3ab4f341d88e7d505760b93ad7 (clean) (release) (start)

alloc failures: 0
compactions: 0
legacy block fails: 0

@6by9
Copy link

6by9 commented Dec 1, 2023

Actual behaviour
Garbled output

A picture is worth 1000 words.

https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#c.DRM_MODE_PAGE_FLIP_ASYNC

DRM_MODE_PAGE_FLIP_ASYNC ()

Parameters

Description

Request that the page-flip is performed as soon as possible, ie. with no delay due to waiting for vblank. This may cause tearing to be visible on the screen.

When used with atomic uAPI, the driver will return an error if the hardware doesn't support performing an asynchronous page-flip for this update. User-space should handle this, e.g. by falling back to a regular page-flip.

Note, some hardware might need to perform one last synchronous page-flip before being able to switch to asynchronous page-flips. As an exception, the driver will return success even though that first page-flip is not asynchronous.

I'd actually want to read up on that, as the HVS latches the display list at the start of each frame, so I don't know exactly what it means by async here.

https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#c.DRM_CAP_ASYNC_PAGE_FLIP

If set to 1, the driver supports [DRM_MODE_PAGE_FLIP_ASYNC](https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#c.DRM_MODE_PAGE_FLIP_ASYNC) for legacy page-flips.

If it's the legacy API, then it sounds like it isn't the call you are wanting.

My recollection is that it was used by X11 for cursor plane updates only.

@maru-sama
Copy link
Author

Please note that a mesa bug was opened for this as well.
https://gitlab.freedesktop.org/mesa/mesa/-/issues/10242

@maru-sama
Copy link
Author

Here pictures with pageflip disabled and enabled...

Enabled
IMG_20231202_092206

Disabled
IMG_20231202_092036

Both on a rpi4

@tekker
Copy link

tekker commented Dec 2, 2023

libsdl-org/SDL#8579 (comment)

same issue can be reproduced in glmark2 (glmark2-es2-drm) and resolved by force disabling check for DRM_CAP_ASYNC_PAGE_FLIP

@appnjoy
Copy link

appnjoy commented Dec 5, 2023

Hi guys, just a stupid question :)

Is it planned somewhere when a Mesa driver fix will be released for Raspberry Pi?

Thanks

@6by9
Copy link

6by9 commented Dec 5, 2023

Is it planned somewhere when a Mesa driver fix will be released for Raspberry Pi?

A fix for this specific issue, or a general update?

For this specific issue would require this issue to be resolved in the first place.

Generally Mesa on Raspberry Pi OS was updated to 23.2.1 on 20th Nov 2023. This is ahead of Debian Bookworm which has stuck on 22.3. Updates take a fair amount of testing effort, so they generally happen when something significant dictates it.

@maru-sama
Copy link
Author

maru-sama commented Dec 5, 2023

Furthermore I think nobody knows yet if this is a Kernel or Mesa library related issue or a combination of both.
The only "good" thing IMO is that it is easily reproducible and that there are workarounds. :)

@dtcooper
Copy link

dtcooper commented Dec 5, 2023

Just weighing in: pygame currently broken using libSDL2's kmsdrm driver on a raspberry pi 5 with the lite os (no display environment)

@cmitu
Copy link

cmitu commented Feb 8, 2024

I think this is fixed with raspberrypi/linux#5827, raspberrypi/linux#5861. Kernel 6.1.73 (available via apt right now) should contain the fixes.

@popcornmix
Copy link
Contributor

Yes, the fix should be present in apt now. Closing.

@maru-sama
Copy link
Author

Hello,

I just tried the latest kernel with pageflip enabled and I am still seeing this issue with my rpi4

Linux rpi 6.1.0-rpi8-rpi-v7l #1 SMP Raspbian 1:6.1.73-1+rpt1 (2024-01-25) armv7l GNU/Linux

@popcornmix
Copy link
Contributor

It looks like that kernel came from this tag which appears to contain the fix.

The 6.1 kernel is unlikely to receive any more updates. It would be useful if you can test the 6.6 kernel using rpi-update.

The 6.6 will become the stable (apt) kernel soon.

@maru-sama
Copy link
Author

Ok, I will test it again as soon as it is available via apt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants