-
Notifications
You must be signed in to change notification settings - Fork 17
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
Support Linux DRM backend #69
base: main
Are you sure you want to change the base?
Conversation
What compatibility risks exist when using DRM legacy interfaces with newer Linux kernels? Could you verify the compatibility status of libdrm across different kernel versions? What prevents the DRM backend from rendering content across the full screen resolution? |
@a1091150, You might check DRM backend for your environment as well. |
|
||
return true; | ||
|
||
bail_crtc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase the latest main
branch and resolve conflicts.
I need more time to research and adjust. |
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
|
||
/* Register the Linux DRM backend */ | ||
|
||
const twin_backend_t g_twin_backend = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add poll
operation as it is required in recent main
branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the original implementation, we creates another thread to handle the events in function twin_linux_evdev_thread
. So do you suggest refactoring linux_input.c#L255~278?
Or we just assign NULL to .poll
?
/* Register the Linux DRM backend */
const twin_backend_t g_twin_backend = {
.init = twin_drm_init,
.poll = NULL, /*without implementation*/
.configure = twin_drm_configure,
.exit = twin_drm_exit,
};
$ sudo ./demo-drm | ||
``` | ||
|
||
The DRM device can be assigened via the environment variable `DRI_CARD`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DRI_CARD
is not common for understanding. How about DRMDEVICE
?
Implemented DRM-based framebuffer setup, including: - Opening DRM device - Creating dumb buffers and mapping them to framebuffers - Setting mode and handling CRTC for connected display output Currently, using the DRM legacy interface is suitable for Mado's backend if we only need basic window display without advanced features. The DRM legacy is simpler to implement. Close sysprog21#60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine git commit messages:
- Use
Close #60
instead ofClose sysprog21#60
- Always use third-person perspective: Avoid personal pronouns like "I", "you", and "we", focusing on an objective description of changes.
- More explanation for using legacy DRM interface. Provide context for why the alternatives are not suitable.
if (drmModeAddFB(tx->drm_dri_fd, tx->width, tx->height, 24, 32, | ||
create_req.pitch, create_req.handle, &tx->fb_id) != 0) { | ||
log_error("Cannot create framebubber"); | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider that this line should be changed to goto bail_dumb
.
bail_dumb:
struct drm_mode_destroy_dumb destroy = { .handle = create_req.handle };
ioctl(tx->drm_dri_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy);
return false;
/* Create framebuffer object for the dumb-buffer */ | ||
if (drmModeAddFB(tx->drm_dri_fd, tx->width, tx->height, 24, 32, | ||
create_req.pitch, create_req.handle, &tx->fb_id) != 0) { | ||
log_error("Cannot create framebubber"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct the typo in framebubber
.
twin_screen_resize(SCREEN(ctx), width, height); | ||
} | ||
|
||
static void twin_drm_exit(twin_context_t *ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
I ran the DRM backend on a VM with Ubuntu 24.04. However, I noticed that the screen froze. drm.mov |
Currently, using the DRM legacy interface is suitable for Mado's backend because we only need basic window display without advanced features.