Support Linux DRM backend#69
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
|
||
| return true; | ||
|
|
||
| bail_crtc: |
There was a problem hiding this comment.
I'm confused about this. It should be as below.
/* Retrieve resources */
if (!get_resources(tx->drm_dri_fd, &RES(tx)))
goto bail_res;
....
bail_fb:
drmModeRmFB(tx->drm_dri_fd, tx->fb_id);
munmap(tx->fb_base, tx->fb_len);
bail_crtc:
drmModeFreeCrtc(CRTC(tx));
bail_conn:
drmModeFreeConnector(CONN(tx));
bail_res:
drmModeFreeResources(RES(tx));
This comment was marked as outdated.
This comment was marked as outdated.
|
Check the DRM implementation for reference: https://github.com/zlgopen/awtk-linux-fb/blob/master/awtk-port/lcd_linux/lcd_linux_drm.c |
32e2217 to
3cba956
Compare
f711c33 to
e275994
Compare
| twin_screen_resize(SCREEN(ctx), width, height); | ||
| } | ||
|
|
||
| static void twin_drm_exit(twin_context_t *ctx) |
There was a problem hiding this comment.
I consider that twin_drm_exit should handle ioctl(tx->drm_dri_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy) to ensure allocated resources are properly released.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
For mado, a libdrm-free DRM backend is realistic because the use caseonly needs KMS + dumb buffer + CPU rendering, not GBM/EGL/GPU rendering. This pull request currently uses libdrm helpers such as The dumb-buffer path is appropriate: DRM dumb buffers are CPU-mappable scanout buffers, suitable for simple rendering but not complex GPU composition. Minimal ioctl-only framebuffer sequence is shown below: open("/dev/dri/card0", O_RDWR | O_CLOEXEC);
DRM_IOCTL_MODE_GETRESOURCES;
DRM_IOCTL_MODE_GETCONNECTOR; /* two-pass */
DRM_IOCTL_MODE_GETCRTC;
DRM_IOCTL_MODE_CREATE_DUMB;
DRM_IOCTL_MODE_ADDFB2;
DRM_IOCTL_MODE_MAP_DUMB;
mmap();
DRM_IOCTL_MODE_SETCRTC;Use legacy |
I verified that the DRM backend runs successfully on Ubuntu 24.04 VM. Screencast.from.2026.02.00.56.24.webm |
|
I'm curious which part of the code fixed the VM issue. |
Hi @Bennctu, Also, does commit e4f93e9 show the same rendering result as this one? I’d like to learn more about this part as well. Thank you for your generous explanation! |
Implemented DRM-based framebuffer setup, including: - Opening the DRM device - Creating dumb buffers and mapping them to framebuffers - Setting mode and handling CRTC for connected display output The legacy DRM ioctl interface is used as the current implementation does not require atomic mode-setting or page flipping. Atomic mode-setting prevents inconsistent states, supports rollback on failures, and enables mode testing before committing changes. Atomic page flipping synchronizes multiple planes within a VBLANK interval, preventing tearing and improving display updates, especially for power-efficient embedded controllers. While the atomic API enhances KMS with property-based state management, its complexity is unnecessary for now. The legacy interface remains adequate, but future needs may justify adopting atomic mode-setting. Close sysprog21#60
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="configs/Kconfig">
<violation number="1" location="configs/Kconfig:81">
P2: `BACKEND_DRM` is missing a dependency gate for libdrm, so users can enable it in Kconfig and hit build failures on systems without libdrm installed.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| config BACKEND_DRM | ||
| bool "Linux DRM support" | ||
| depends on !CC_IS_EMCC |
There was a problem hiding this comment.
P2: BACKEND_DRM is missing a dependency gate for libdrm, so users can enable it in Kconfig and hit build failures on systems without libdrm installed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At configs/Kconfig, line 81:
<comment>`BACKEND_DRM` is missing a dependency gate for libdrm, so users can enable it in Kconfig and hit build failures on systems without libdrm installed.</comment>
<file context>
@@ -76,6 +76,15 @@ choice
+config BACKEND_DRM
+ bool "Linux DRM support"
+ depends on !CC_IS_EMCC
+ select CURSOR
+ help
</file context>
Currently, using the DRM legacy interface is suitable for Mado's backend because we only need basic window display without advanced features.