We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I am new to DRM programming, this is an excellent example. Unfortunately, I could not get it work under zcu102 platform.
ret = drmModeSetCrtc(fd, iter->crtc, iter->fb, 0, 0, &iter->conn, 1, &iter->mode); if (ret) fprintf(stderr, "cannot set CRTC for connector %u (%d): %m\n", iter->conn, errno);
here ret is -22, it means "invalid argument".
ret
I spent some time to investigate, by comparing it with modetest.c in libdrm, I modify the following lines, it works. But I don't know exactly why.
modetest.c
diff --git a/drm-howto/modeset.c b/drm-howto/modeset.c index d2e56aa..58b2db5 100644 --- a/drm-howto/modeset.c +++ b/drm-howto/modeset.c @@ -447,7 +447,7 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) memset(&creq, 0, sizeof(creq)); creq.width = dev->width; creq.height = dev->height; - creq.bpp = 32; + creq.bpp = 24; ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &creq); if (ret < 0) { fprintf(stderr, "cannot create dumb buffer (%d): %m\n", @@ -459,7 +459,7 @@ static int modeset_create_fb(int fd, struct modeset_dev *dev) dev->handle = creq.handle; /* create framebuffer object for the dumb-buffer */ - ret = drmModeAddFB(fd, dev->width, dev->height, 24, 32, dev->stride, + ret = drmModeAddFB(fd, dev->width, dev->height, 24, 24, dev->stride, dev->handle, &dev->fb); if (ret) { fprintf(stderr, "cannot create framebuffer (%d): %m\n", @@ -630,6 +630,10 @@ static uint8_t next_color(bool *up, uint8_t cur, unsigned int mod) * beyond the scope of this document. */ +struct color_rgb24 { + unsigned int value:24; +} __attribute__((__packed__)); + static void modeset_draw(void) { uint8_t r, g, b; @@ -651,9 +655,9 @@ static void modeset_draw(void) for (iter = modeset_list; iter; iter = iter->next) { for (j = 0; j < iter->height; ++j) { for (k = 0; k < iter->width; ++k) { - off = iter->stride * j + k * 4; - *(uint32_t*)&iter->map[off] = - (r << 16) | (g << 8) | b; + off = iter->stride * j + k * 3; + ((struct color_rgb24 *)&iter->map[off]) + ->value = (r << 16) | (g << 8) | b; } } }
The text was updated successfully, but these errors were encountered:
Thanks. this patch also worked for my case.
Sorry, something went wrong.
creq.bpp = 16
and
drmModeAddFB(fd, dev->width, dev->height, 16, 16, dev->stride
also works for me (in rk3399pro system)
谢谢。该补丁也适用于我的情况。
No branches or pull requests
I am new to DRM programming, this is an excellent example. Unfortunately, I could not get it work under zcu102 platform.
here
ret
is -22, it means "invalid argument".I spent some time to investigate, by comparing it with
modetest.c
in libdrm, I modify the following lines, it works. But I don't know exactly why.The text was updated successfully, but these errors were encountered: