[PATCH 09/15] staging: vboxvideo: Atomic phase 3: Switch last bits over to atomic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that the state objects are wired up, we can:

1) Move to the final atomic handlers
2) Wire up atomic set_config helper
3) Switch to drm_mode_config_helper_suspend/resume for suspend/resume
4) Enable atomic modesetting ioctl

This is all done in one commit because doing this piecemeal leads to
an intermediate state which triggers WARN_ONs in the atomic code because
e.g. plane->fb is still being set.

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
 drivers/staging/vboxvideo/TODO        |  1 -
 drivers/staging/vboxvideo/vbox_drv.c  | 40 +++++----------------------
 drivers/staging/vboxvideo/vbox_mode.c | 35 +++++++----------------
 3 files changed, 17 insertions(+), 59 deletions(-)

diff --git a/drivers/staging/vboxvideo/TODO b/drivers/staging/vboxvideo/TODO
index 468eea856ca6..2e0f99c3f10c 100644
--- a/drivers/staging/vboxvideo/TODO
+++ b/drivers/staging/vboxvideo/TODO
@@ -1,5 +1,4 @@
 TODO:
--Move the driver over to the atomic API
 -Get a full review from the drm-maintainers on dri-devel done on this driver
 -Extend this TODO with the results of that review
 
diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c
index c6a53b0ad66c..c3e14107da0d 100644
--- a/drivers/staging/vboxvideo/vbox_drv.c
+++ b/drivers/staging/vboxvideo/vbox_drv.c
@@ -132,35 +132,16 @@ static void vbox_pci_remove(struct pci_dev *pdev)
 	drm_dev_put(&vbox->ddev);
 }
 
-static int vbox_drm_freeze(struct vbox_private *vbox)
-{
-	drm_kms_helper_poll_disable(&vbox->ddev);
-
-	pci_save_state(vbox->ddev.pdev);
-
-	drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true);
-
-	return 0;
-}
-
-static int vbox_drm_thaw(struct vbox_private *vbox)
-{
-	drm_mode_config_reset(&vbox->ddev);
-	drm_helper_resume_force_mode(&vbox->ddev);
-	drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, false);
-
-	return 0;
-}
-
 static int vbox_pm_suspend(struct device *dev)
 {
 	struct vbox_private *vbox = dev_get_drvdata(dev);
 	int error;
 
-	error = vbox_drm_freeze(vbox);
+	error = drm_mode_config_helper_suspend(&vbox->ddev);
 	if (error)
 		return error;
 
+	pci_save_state(vbox->ddev.pdev);
 	pci_disable_device(vbox->ddev.pdev);
 	pci_set_power_state(vbox->ddev.pdev, PCI_D3hot);
 
@@ -170,39 +151,32 @@ static int vbox_pm_suspend(struct device *dev)
 static int vbox_pm_resume(struct device *dev)
 {
 	struct vbox_private *vbox = dev_get_drvdata(dev);
-	int ret;
 
 	if (pci_enable_device(vbox->ddev.pdev))
 		return -EIO;
 
-	ret = vbox_drm_thaw(vbox);
-	if (ret)
-		return ret;
-
-	drm_kms_helper_poll_enable(&vbox->ddev);
-
-	return 0;
+	return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_freeze(struct device *dev)
 {
 	struct vbox_private *vbox = dev_get_drvdata(dev);
 
-	return vbox_drm_freeze(vbox);
+	return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static int vbox_pm_thaw(struct device *dev)
 {
 	struct vbox_private *vbox = dev_get_drvdata(dev);
 
-	return vbox_drm_thaw(vbox);
+	return drm_mode_config_helper_resume(&vbox->ddev);
 }
 
 static int vbox_pm_poweroff(struct device *dev)
 {
 	struct vbox_private *vbox = dev_get_drvdata(dev);
 
-	return vbox_drm_freeze(vbox);
+	return drm_mode_config_helper_suspend(&vbox->ddev);
 }
 
 static const struct dev_pm_ops vbox_pm_ops = {
@@ -280,7 +254,7 @@ static void vbox_master_drop(struct drm_device *dev, struct drm_file *file_priv)
 static struct drm_driver driver = {
 	.driver_features =
 	    DRIVER_MODESET | DRIVER_GEM | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
-	    DRIVER_PRIME,
+	    DRIVER_PRIME | DRIVER_ATOMIC,
 	.dev_priv_size = 0,
 
 	.lastclose = vbox_driver_lastclose,
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c
index 54e6aac784f7..69a1e6c163b9 100644
--- a/drivers/staging/vboxvideo/vbox_mode.c
+++ b/drivers/staging/vboxvideo/vbox_mode.c
@@ -148,13 +148,6 @@ static void vbox_crtc_dpms(struct drm_crtc *crtc, int mode)
 	mutex_unlock(&vbox->hw_mutex);
 }
 
-static bool vbox_crtc_mode_fixup(struct drm_crtc *crtc,
-				 const struct drm_display_mode *mode,
-				 struct drm_display_mode *adjusted_mode)
-{
-	return true;
-}
-
 /*
  * Try to map the layout of virtual screens to the range of the input device.
  * Return true if we need to re-set the crtc modes due to screen offset
@@ -260,19 +253,10 @@ static void vbox_crtc_disable(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
 static void vbox_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static void vbox_crtc_mode_set_nofb(struct drm_crtc *crtc)
-{
-	/* We always set the mode when we set the fb/base */
-}
-
 static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 				   struct drm_crtc_state *old_crtc_state)
 {
@@ -291,11 +275,7 @@ static void vbox_crtc_atomic_flush(struct drm_crtc *crtc,
 
 static const struct drm_crtc_helper_funcs vbox_crtc_helper_funcs = {
 	.dpms = vbox_crtc_dpms,
-	.mode_fixup = vbox_crtc_mode_fixup,
-	.mode_set = drm_helper_crtc_mode_set,
-	.mode_set_nofb = vbox_crtc_mode_set_nofb,
 	.disable = vbox_crtc_disable,
-	.prepare = vbox_crtc_prepare,
 	.commit = vbox_crtc_commit,
 	.atomic_flush = vbox_crtc_atomic_flush,
 };
@@ -307,7 +287,7 @@ static void vbox_crtc_destroy(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs vbox_crtc_funcs = {
-	.set_config = drm_crtc_helper_set_config,
+	.set_config = drm_atomic_helper_set_config,
 	/* .gamma_set = vbox_crtc_gamma_set, */
 	.destroy = vbox_crtc_destroy,
 	.reset = drm_atomic_helper_crtc_reset,
@@ -521,8 +501,8 @@ static const struct drm_plane_helper_funcs vbox_cursor_helper_funcs = {
 };
 
 static const struct drm_plane_funcs vbox_cursor_plane_funcs = {
-	.update_plane	= drm_plane_helper_update,
-	.disable_plane	= drm_plane_helper_disable,
+	.update_plane	= drm_atomic_helper_update_plane,
+	.disable_plane	= drm_atomic_helper_disable_plane,
 	.destroy	= drm_primary_helper_destroy,
 	.reset		= drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
@@ -543,8 +523,8 @@ static const struct drm_plane_helper_funcs vbox_primary_helper_funcs = {
 };
 
 static const struct drm_plane_funcs vbox_primary_plane_funcs = {
-	.update_plane	= drm_plane_helper_update,
-	.disable_plane	= drm_primary_helper_disable,
+	.update_plane	= drm_atomic_helper_update_plane,
+	.disable_plane	= drm_atomic_helper_disable_plane,
 	.destroy	= drm_primary_helper_destroy,
 	.reset		= drm_atomic_helper_plane_reset,
 	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
@@ -882,6 +862,9 @@ static const struct drm_connector_funcs vbox_connector_funcs = {
 	.detect = vbox_connector_detect,
 	.fill_modes = vbox_fill_modes,
 	.destroy = vbox_connector_destroy,
+	.reset = drm_atomic_helper_connector_reset,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
 static int vbox_connector_init(struct drm_device *dev,
@@ -950,6 +933,8 @@ static struct drm_framebuffer *vbox_user_framebuffer_create(
 
 static const struct drm_mode_config_funcs vbox_mode_funcs = {
 	.fb_create = vbox_user_framebuffer_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
 };
 
 int vbox_mode_init(struct vbox_private *vbox)
-- 
2.19.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux