dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, Hans de Goede <hdegoede@redhat.com>,
	Michael Thayer <michael.thayer@oracle.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH resend 09/15] staging: vboxvideo: Atomic phase 3: Switch last bits over to atomic
Date: Sat, 29 Sep 2018 14:18:19 +0200	[thread overview]
Message-ID: <20180929121825.25765-10-hdegoede@redhat.com> (raw)
In-Reply-To: <20180929121825.25765-1-hdegoede@redhat.com>

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@redhat.com>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-09-29 12:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-29 12:18 [PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API Hans de Goede
2018-09-29 12:18 ` [PATCH resend 01/15] staging: vboxvideo: Cleanup vbox_set_up_input_mapping() Hans de Goede
2018-09-29 12:18 ` [PATCH resend 02/15] staging: vboxvideo: Remove empty encoder_helper_funcs Hans de Goede
2018-09-29 12:18 ` [PATCH resend 03/15] staging: vboxvideo: Temporarily remove page_flip support Hans de Goede
2018-09-29 12:18 ` [PATCH resend 04/15] staging: vboxvideo: Cache mode width, height and crtc panning in vbox_crtc Hans de Goede
2018-09-29 12:18 ` [PATCH resend 05/15] staging: vboxvideo: Atomic phase 1: convert cursor to universal plane Hans de Goede
2018-09-29 12:18 ` [PATCH resend 06/15] staging: vboxvideo: Atomic phase 1: Use drm_plane_helpers for primary plane Hans de Goede
2018-09-29 12:18 ` [PATCH resend 07/15] staging: vboxvideo: Atomic phase 2: Wire up state object handlers Hans de Goede
2018-09-29 12:18 ` [PATCH resend 08/15] staging: vboxvideo: Atomic phase 2: Stop using plane->fb and crtc->* Hans de Goede
2018-09-29 12:18 ` Hans de Goede [this message]
2018-09-29 12:18 ` [PATCH resend 10/15] staging: vboxvideo: Restore page-flip support Hans de Goede
2018-09-29 12:18 ` [PATCH resend 11/15] staging: vboxvideo: Fix DPMS support after atomic conversion Hans de Goede
2018-09-29 12:18 ` [PATCH resend 12/15] staging: vboxvideo: Replace crtc_helper enable/disable functions Hans de Goede
2018-09-29 12:18 ` [PATCH resend 13/15] staging: vboxvideo: Call drm_atomic_helper_check_plane_state from atomic_check Hans de Goede
2018-09-29 12:18 ` [PATCH resend 14/15] staging: vboxvideo: Drop unnecessary drm_connector_helper_funcs callbacks Hans de Goede
2018-09-29 12:18 ` [PATCH resend 15/15] staging: vboxvideo: Use more drm_fb_helper functions Hans de Goede
2018-10-01  7:25 ` [PATCH resend 00/15] staging: vboxvideo: Convert to atomic modesetting API Dan Carpenter
2018-10-01  9:20   ` Hans de Goede
2018-10-05 16:01     ` Daniel Vetter
2018-10-06  8:12       ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180929121825.25765-10-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=michael.thayer@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox