Multiple Screen DRM Page Flipping Issue
I am working on a Qt5 based application that utilizes two displays connected via HDMI on a Raspberry Pi 4. I am encountering a issue that I think is similar to the below post.
viewtopic.php?p=1511966&hilit=drmModePageFlip#p1511966
Basically, if drmModePageFlip is called on multiple displays, they seem to interfere with each other resulting in long delays (30+ ms) and missed vsyncs, which causes jittery animation. The delay can be avoided via passing the ASYNC flag to one of the drmModePageFlip calls, but that interferes with the animation timing, which is reliant on waiting for vsync.
The current environment:
Yocto Kirkstone
Kernel: 5.15.92
Firmware: 20220830
If anyone knows if there were any bugs fixed in the kernel and/or firmware that may address this, or any other general advice on the usage on the DRM api in this regard, your input is appreciated.
viewtopic.php?p=1511966&hilit=drmModePageFlip#p1511966
Basically, if drmModePageFlip is called on multiple displays, they seem to interfere with each other resulting in long delays (30+ ms) and missed vsyncs, which causes jittery animation. The delay can be avoided via passing the ASYNC flag to one of the drmModePageFlip calls, but that interferes with the animation timing, which is reliant on waiting for vsync.
The current environment:
Yocto Kirkstone
Kernel: 5.15.92
Firmware: 20220830
If anyone knows if there were any bugs fixed in the kernel and/or firmware that may address this, or any other general advice on the usage on the DRM api in this regard, your input is appreciated.
- 6by9
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 18476
- Joined: Wed Dec 04, 2013 11:27 am
Re: Multiple Screen DRM Page Flipping Issue
5.15 is obsolete having been last updated over 2 years ago.
Using DRM_MODE_PAGE_FLIP_ASYNC is unlikely to be what you want - it immediately updates the plane properties, which can result in tearing. (There are some restrictions on which properties can change with an ASYNC flip).
Using DRM_MODE_PAGE_FLIP_EVENT should trigger a page flip event. I seem to recall a recent thread where the main DRM devs acknowledged that vsync and flip events miss out saying which crtc they belong to.
More common these days is to use the atomic API to commit changes atomically. I'd need to double check with a colleague, but I believe that as long as the commits contain no state in common, then you can have 2 atomic commits running in parallel. (If any resources are shared, then you're likely to get an EBUSY when submitting the second one as it does not allow queuing multiple commits).
Using DRM_MODE_PAGE_FLIP_ASYNC is unlikely to be what you want - it immediately updates the plane properties, which can result in tearing. (There are some restrictions on which properties can change with an ASYNC flip).
Using DRM_MODE_PAGE_FLIP_EVENT should trigger a page flip event. I seem to recall a recent thread where the main DRM devs acknowledged that vsync and flip events miss out saying which crtc they belong to.
More common these days is to use the atomic API to commit changes atomically. I'd need to double check with a colleague, but I believe that as long as the commits contain no state in common, then you can have 2 atomic commits running in parallel. (If any resources are shared, then you're likely to get an EBUSY when submitting the second one as it does not allow queuing multiple commits).
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
Re: Multiple Screen DRM Page Flipping Issue
I don't think I've used the combination of drmModePageFlip and page_flip_handler2 in any of my various implementation I've written over the years, but maybe using version 4 of the drmHandleEvent fills in the crtc_id? At least it did for me when I was using it together with drmModeAtomicCommit. One more reason maybe to use those:Using DRM_MODE_PAGE_FLIP_EVENT should trigger a page flip event. I seem to recall a recent thread where the main DRM devs acknowledged that vsync and flip events miss out saying which crtc they belong to.
Code: Select all
static void drm_page_flip_event(
int fd,
unsigned int frame,
unsigned int sec,
unsigned int usec,
unsigned int crtc_id,
void *data
) { ... }
static const drmEventContext evctx = {
.version = 4,
.page_flip_handler2 = drm_page_flip_event,
};
Unless the intent is to drive two displays with different refresh rates, It might be easier to do one atomic commit across all resources. At least that's what I've been doing for a while now and I don't notice any downsides so far. Although I'm using fences instead of drmHandleEvent now. Whether or not that all works well on such an old kernel is the question though.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted
Return to "Graphics programming"
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion