How to use the writeback connector by the Linux DRM api /libdrm?

Viewed 33

I recently start learning Direct Rendering Manager and tried to use the writeback connector and the libdrm.

There are some documents and codes of how the kernel implements it, but not enough of how the userspace uses the api, such as drmModeAtomicAddProperty and drmModeAtomicCommit of the writeback connector in libdrm.

I have referred to libdrm/tests/modetest; Linux API Reference; linux/v6.0-rc5/source/drivers/gpu/drm/drm_writeback.c and some patch imformation.

I used modetest to get some driver information and tried my code using the libdrm:

 /* I previously get the value of writeback connector:wbc_conn_id
  * and create an output framebuffer:fb_id
  * and find the active crtc: crtc_id
  * next to get writeback connector property*/
    props = drmModeObjectGetProperties(fd, wbc_conn_id, DRM_MODE_OBJECT_CONNECTOR);
    printf("the number of properties in  connector %d : %d \n", wbc_conn_id, props->count_props);
    writeback_fb_id_property = get_property_id(fd, props,"WRITEBACK_FB_ID");
    writeback_crtc_id_property = get_property_id(fd, props,"CRTC_ID");
    printf("writeback_fb_property: %d\n",writeback_fb_id_property);
    printf("writeback_crtc_id_property: %d\n",writeback_crtc_id_property);
    drmModeFreeObjectProperties(props);

    /* atomic writeback connector update */
    req = drmModeAtomicAlloc();
    drmModeAtomicAddProperty(req, wbc_conn_id, writeback_crtc_id_property, crtc_id);
    printf ("%d\n",ret);
    drmModeAtomicAddProperty(req, wbc_conn_id, writeback_fb_id_property, buf.fb_id);
    ret = drmModeAtomicCommit(fd, req, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
    if (ret) {
        fprintf(stderr, "Atomic Commit failed [1]\n");
        return 1;
    }
    drmModeAtomicFree(req);
    printf("drmModeAtomicCommit Set Writeback\n");
    getchar();  

It turns out that the drmModeAtomicCommit failed. Was there any property set wrongly or missed? The value of two steps of addproperty is 1 and 2, and the atomic commit returned EINVAL -22 .

I've looked around but found no solution or similar question about the property set of writebackconnector.

0 Answers
Related