drm: Pass CRTC ID in userspace vblank events
authorPeeter Must <karu.pruun@gmail.com>
Thu, 23 Jan 2020 08:43:48 +0000 (10:43 +0200)
committerPeeter Must <karu.pruun@gmail.com>
Thu, 23 Jan 2020 08:43:48 +0000 (10:43 +0200)
* Add DRM_CAP_CRTC_IN_VBLANK_EVENT so userspace can
  query the crtc field.

* This follows Linux's commit
  5db06a8a98f515f67446a69c57577c4c363ec65d.

sys/dev/drm/drm_ioctl.c
sys/dev/drm/drm_irq.c
sys/dev/drm/include/uapi/drm/drm.h

index 2d99515..63756af 100644 (file)
@@ -265,6 +265,9 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
        case DRM_CAP_ADDFB2_MODIFIERS:
                req->value = dev->mode_config.allow_fb_modifiers;
                break;
+       case DRM_CAP_CRTC_IN_VBLANK_EVENT:
+               req->value = 1;
+               break;
        default:
                return -EINVAL;
        }
index 59e86a9..fdf21ea 100644 (file)
@@ -1040,6 +1040,7 @@ void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
 
        e->pipe = pipe;
        e->event.sequence = drm_vblank_count(dev, pipe);
+       e->event.crtc_id = crtc->base.id;
        list_add_tail(&e->base.link, &dev->vblank_event_list);
 }
 EXPORT_SYMBOL(drm_crtc_arm_vblank_event);
@@ -1070,6 +1071,7 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
                now = get_drm_timestamp();
        }
        e->pipe = pipe;
+       e->event.crtc_id = crtc->base.id;
        send_vblank_event(dev, e, seq, &now);
 }
 EXPORT_SYMBOL(drm_crtc_send_vblank_event);
index d71c747..3d065ca 100644 (file)
@@ -641,6 +641,7 @@ struct drm_gem_open {
 #define DRM_CAP_CURSOR_HEIGHT          0x9
 #define DRM_CAP_ADDFB2_MODIFIERS       0x10
 #define DRM_CAP_PAGE_FLIP_TARGET       0x11
+#define DRM_CAP_CRTC_IN_VBLANK_EVENT   0x12
 
 /** DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {
@@ -863,7 +864,7 @@ struct drm_event_vblank {
        __u32 tv_sec;
        __u32 tv_usec;
        __u32 sequence;
-       __u32 reserved;
+       __u32 crtc_id; /* 0 on older kernels that do not support this */
 };
 
 /* typedef area */