drm/vkms/crc: Implement verify_crc_source callback
authorMahesh Kumar <mahesh1.kumar@intel.com>
Tue, 21 Aug 2018 08:38:55 +0000 (14:08 +0530)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 22 Aug 2018 16:47:02 +0000 (09:47 -0700)
This patch implements "verify_crc_source" callback function for
Virtual KMS drm driver.

Changes Since V1:
- update values_cnt in verify_crc_source
Changes Since V2:
- don't return early from set_crc_source to keep behavior same (Haneen)

Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Signed-off-by: Mahesh Kumar <mahesh1.kumar@intel.com>
Reviewed-by: Haneen Mohammed <hamohammed.sa@gmail.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180821083858.26275-2-mahesh1.kumar@intel.com
drivers/gpu/drm/vkms/vkms_crc.c
drivers/gpu/drm/vkms/vkms_crtc.c
drivers/gpu/drm/vkms/vkms_drv.h

index 37d717f38e3c14b959d978c7c3fc4f1b331b46a7..68421d3d809ac7dcaaeefa94c8e486e8f82e9773 100644 (file)
@@ -70,6 +70,37 @@ void vkms_crc_work_handle(struct work_struct *work)
        drm_crtc_add_crc_entry(crtc, true, crtc_state->n_frame, &crc32);
 }
 
+static int vkms_crc_parse_source(const char *src_name, bool *enabled)
+{
+       int ret = 0;
+
+       if (!src_name) {
+               *enabled = false;
+       } else if (strcmp(src_name, "auto") == 0) {
+               *enabled = true;
+       } else {
+               *enabled = false;
+               ret = -EINVAL;
+       }
+
+       return ret;
+}
+
+int vkms_verify_crc_source(struct drm_crtc *crtc, const char *src_name,
+                          size_t *values_cnt)
+{
+       bool enabled;
+
+       if (vkms_crc_parse_source(src_name, &enabled) < 0) {
+               DRM_DEBUG_DRIVER("unknown source %s\n", src_name);
+               return -EINVAL;
+       }
+
+       *values_cnt = 1;
+
+       return 0;
+}
+
 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name,
                        size_t *values_cnt)
 {
@@ -78,10 +109,7 @@ int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name,
        unsigned long flags;
        int ret = 0;
 
-       if (src_name && strcmp(src_name, "auto") == 0)
-               enabled = true;
-       else if (src_name)
-               ret = -EINVAL;
+       ret = vkms_crc_parse_source(src_name, &enabled);
 
        *values_cnt = 1;
 
index bfe6e0312cc47beef008a22213b614fd1471c6e8..9d0b1a325a78a1f3a13d0542c3ed131cedd59559 100644 (file)
@@ -140,6 +140,7 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
        .enable_vblank          = vkms_enable_vblank,
        .disable_vblank         = vkms_disable_vblank,
        .set_crc_source         = vkms_set_crc_source,
+       .verify_crc_source      = vkms_verify_crc_source,
 };
 
 static void vkms_crtc_atomic_enable(struct drm_crtc *crtc,
index f156c930366aef332b5eb64868f22935ac401113..090c5e4f55440e44b1dbfd94a129667a56a9c358 100644 (file)
@@ -125,6 +125,8 @@ void vkms_gem_vunmap(struct drm_gem_object *obj);
 /* CRC Support */
 int vkms_set_crc_source(struct drm_crtc *crtc, const char *src_name,
                        size_t *values_cnt);
+int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
+                          size_t *values_cnt);
 void vkms_crc_work_handle(struct work_struct *work);
 
 #endif /* _VKMS_DRV_H_ */