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

Invalid Argument under xilinx zcu102 platform #8

Open
wcy123 opened this issue Apr 12, 2019 · 3 comments
Open

Invalid Argument under xilinx zcu102 platform #8

wcy123 opened this issue Apr 12, 2019 · 3 comments

Comments

@wcy123
Copy link

wcy123 commented Apr 12, 2019

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".

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.

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;
                                 }
                         }
                }
@hai-yuan
Copy link

hai-yuan commented Jun 5, 2019

Thanks. this patch also worked for my case.

@ryecomp
Copy link

ryecomp commented May 6, 2020

creq.bpp = 16

and

drmModeAddFB(fd, dev->width, dev->height, 16, 16, dev->stride

also works for me (in rk3399pro system)

@gaoweijun2017
Copy link

谢谢。该补丁也适用于我的情况。

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

4 participants