diff --git a/fl2000.h b/fl2000.h index 3a3324f..cde5e63 100644 --- a/fl2000.h +++ b/fl2000.h @@ -138,6 +138,6 @@ int fl2000_drm_init(struct usb_device *usb_dev); void fl2000_drm_cleanup(struct usb_device *usb_dev); /* ... and interface */ void fl2000_drm_hotplug(struct usb_device *usb_dev); -bool fl2000_drm_vblank(struct usb_device *usb_dev); +void fl2000_drm_vblank(struct usb_device *usb_dev); #endif /* __FL2000_DRM_H__ */ diff --git a/fl2000_drm.c b/fl2000_drm.c index 2e024bc..862dbef 100644 --- a/fl2000_drm.c +++ b/fl2000_drm.c @@ -93,6 +93,7 @@ struct fl2000_drm_if { struct drm_device drm; struct drm_simple_display_pipe pipe; struct usb_device *usb_dev; + bool vblank_enabled; }; DEFINE_DRM_GEM_DMA_FOPS(fl2000_drm_driver_fops); @@ -340,6 +341,24 @@ static void fl2000_display_update(struct drm_simple_display_pipe *pipe, } } +static void fl2000_display_enable_vblank(struct drm_simple_display_pipe *pipe) +{ + struct drm_crtc *crtc = &pipe->crtc; + struct drm_device *drm = crtc->dev; + struct fl2000_drm_if *drm_if = container_of(drm, struct fl2000_drm_if, drm); + + drm_if->vblank_enabled = true; +} + +static void fl2000_display_disable_vblank(struct drm_simple_display_pipe *pipe) +{ + struct drm_crtc *crtc = &pipe->crtc; + struct drm_device *drm = crtc->dev; + struct fl2000_drm_if *drm_if = container_of(drm, struct fl2000_drm_if, drm); + + drm_if->vblank_enabled = false; +} + /* Logical pipe management (no HW configuration here) */ static const struct drm_simple_display_pipe_funcs fl2000_display_funcs = { .mode_valid = fl2000_display_mode_valid, @@ -420,20 +439,26 @@ void fl2000_drm_hotplug(struct usb_device *usb_dev) return; } - drm_kms_helper_hotplug_event(drm_if->drm); + drm_kms_helper_hotplug_event(&drm_if->drm); } -bool fl2000_drm_vblank(struct usb_device *usb_dev) +void fl2000_drm_vblank(struct usb_device *usb_dev) { + int ret; struct fl2000_drm_if *drm_if; drm_if = dev_get_drvdata(&usb_dev->dev); if (!drm_if) { dev_err(&usb_dev->dev, "Cannot find DRM structure!"); - return false; + return; } - drm_crtc_handle_vblank(drm_if->crtc); + if (!drm_if->vblank_enabled) + return; + + ret = drm_crtc_handle_vblank(drm_if->crtc); + if (ret) + dev_err(&usb_dev->dev, "Cannot handle vblank event (%d)", ret); } static int fl2000_drm_modeset_init(struct drm_device *drm)