Add Virtual Vblank, virtual hardware module option ('virtual_hw') allows to skip the timing of vblank routine. Signed-off-by: Gabriela Bittencourt <gabrielabittencourt00@xxxxxxxxx> --- drivers/gpu/drm/vkms/vkms_crtc.c | 28 ++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.c | 13 +++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 2 ++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index a72769b81efe..d4aa1ed93bf2 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -58,6 +58,18 @@ static enum hrtimer_restart vkms_vblank_simulate(struct hrtimer *timer) return HRTIMER_RESTART; } +static void vkms_virtual_vblank_simulate(struct vkms_output *output, + struct drm_crtc *crtc) +{ + struct vkms_crtc_state *state; + bool ret; + + state = output->composer_state; + ret = vkms_queue_compose_worker(output, state); + if (!ret) + DRM_DEBUG_DRIVER("Composer worker already queued\n"); +} + static int vkms_enable_vblank(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; @@ -214,16 +226,25 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc, return 0; } +static bool vkms_crtc_atomic_check_vblank_enable(struct drm_crtc *crtc) +{ + struct vkms_output *vkms_out = drm_crtc_to_vkms_output(crtc); + + return (!vkms_out->disable_vblank); +} + static void vkms_crtc_atomic_enable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - drm_crtc_vblank_on(crtc); + if (vkms_crtc_atomic_check_vblank_enable(crtc)) + drm_crtc_vblank_on(crtc); } static void vkms_crtc_atomic_disable(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { - drm_crtc_vblank_off(crtc); + if (vkms_crtc_atomic_check_vblank_enable(crtc)) + drm_crtc_vblank_off(crtc); } static void vkms_crtc_atomic_begin(struct drm_crtc *crtc, @@ -258,6 +279,9 @@ static void vkms_crtc_atomic_flush(struct drm_crtc *crtc, vkms_output->composer_state = to_vkms_crtc_state(crtc->state); spin_unlock_irq(&vkms_output->lock); + + if (vkms_output->disable_vblank) + vkms_virtual_vblank_simulate(vkms_output, crtc); } static const struct drm_crtc_helper_funcs vkms_crtc_helper_funcs = { diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index eef85f1a0ce5..f7c25961b083 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -39,6 +39,11 @@ bool enable_cursor; module_param_named(enable_cursor, enable_cursor, bool, 0444); MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support"); +bool virtual_hw; +module_param_named(virtual_hw, virtual_hw, bool, 0444); +MODULE_PARM_DESC(virtual_hw, + "Enable virtual hardware mode / Disable vblank"); + static const struct file_operations vkms_driver_fops = { .owner = THIS_MODULE, .open = drm_open, @@ -168,9 +173,13 @@ static int __init vkms_init(void) goto out_put; } - vkms_device->drm.irq_enabled = true; + vkms_device->output.disable_vblank = virtual_hw; + vkms_device->drm.irq_enabled = !virtual_hw; + + if (virtual_hw) + DRM_INFO("Virtual hardware mode enabled"); - ret = drm_vblank_init(&vkms_device->drm, 1); + ret = (virtual_hw) ? 0 : drm_vblank_init(&vkms_device->drm, 1); if (ret) { DRM_ERROR("Failed to vblank\n"); goto out_put; diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index eda04ffba7b1..52ad8e06adc5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -19,6 +19,7 @@ #define YRES_MAX 8192 extern bool enable_cursor; +extern bool virtual_hw; struct vkms_composer { struct drm_framebuffer fb; @@ -64,6 +65,7 @@ struct vkms_output { struct drm_encoder encoder; struct drm_connector connector; struct hrtimer vblank_hrtimer; + bool disable_vblank; ktime_t period_ns; struct drm_pending_vblank_event *event; /* ordered wq for composer_work */ -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel