All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Noralf Trønnes" <noralf@tronnes.org>
To: dri-devel@lists.freedesktop.org
Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 07/12] drm/fb-helper: Prepare to move out commit code
Date: Sun,  7 Apr 2019 18:52:38 +0200	[thread overview]
Message-ID: <20190407165243.54043-8-noralf@tronnes.org> (raw)
In-Reply-To: <20190407165243.54043-1-noralf@tronnes.org>

This makes the necessary changes so the commit code can be moved out to
drm_client as-is in the next patch. It's split up to ease review.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
---
 drivers/gpu/drm/drm_fb_helper.c | 122 +++++++++++++++++++++-----------
 1 file changed, 81 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index b65edfc99feb..0229e187e6de 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -388,9 +388,20 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
 }
 EXPORT_SYMBOL(drm_fb_helper_debug_leave);
 
-/* Check if the plane can hw rotate to match panel orientation */
-static bool drm_fb_helper_panel_rotation(struct drm_mode_set *modeset,
-					 unsigned int *rotation)
+/**
+ * drm_client_panel_rotation() - Check panel orientation
+ * @modeset: DRM modeset
+ * @rotation: Returned rotation value
+ *
+ * This function checks if the primary plane in @modeset can hw rotate to match
+ * the panel orientation on its connector.
+ *
+ * Note: Currently only 0 and 180 degrees are supported.
+ *
+ * Return:
+ * True if the plane can do the rotation, false otherwise.
+ */
+bool drm_client_panel_rotation(struct drm_mode_set *modeset, unsigned int *rotation)
 {
 	struct drm_connector *connector = modeset->connectors[0];
 	struct drm_plane *plane = modeset->crtc->primary;
@@ -431,10 +442,9 @@ static bool drm_fb_helper_panel_rotation(struct drm_mode_set *modeset,
 	return true;
 }
 
-static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool active)
+static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool active)
 {
-	struct drm_client_dev *client = &fb_helper->client;
-	struct drm_device *dev = fb_helper->dev;
+	struct drm_device *dev = client->dev;
 	struct drm_plane_state *plane_state;
 	struct drm_plane *plane;
 	struct drm_atomic_state *state;
@@ -474,7 +484,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ
 		struct drm_plane *primary = mode_set->crtc->primary;
 		unsigned int rotation;
 
-		if (drm_fb_helper_panel_rotation(mode_set, &rotation)) {
+		if (drm_client_panel_rotation(mode_set, &rotation)) {
 			/* Cannot fail as we've already gotten the plane state above */
 			plane_state = drm_atomic_get_new_plane_state(state, primary);
 			plane_state->rotation = rotation;
@@ -516,15 +526,14 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper, bool activ
 	goto retry;
 }
 
-static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper)
+static int drm_client_modeset_commit_legacy(struct drm_client_dev *client)
 {
-	struct drm_client_dev *client = &fb_helper->client;
-	struct drm_device *dev = fb_helper->dev;
+	struct drm_device *dev = client->dev;
 	struct drm_mode_set *mode_set;
 	struct drm_plane *plane;
 	int ret = 0;
 
-	drm_modeset_lock_all(fb_helper->dev);
+	drm_modeset_lock_all(dev);
 	drm_for_each_plane(plane, dev) {
 		if (plane->type != DRM_PLANE_TYPE_PRIMARY)
 			drm_plane_force_disable(plane);
@@ -553,35 +562,53 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper)
 			goto out;
 	}
 out:
-	drm_modeset_unlock_all(fb_helper->dev);
+	drm_modeset_unlock_all(dev);
 
 	return ret;
 }
 
-static int restore_fbdev_mode_force(struct drm_fb_helper *fb_helper)
+/**
+ * drm_client_modeset_commit_force() - Force commit CRTC configuration
+ * @client: DRM client
+ *
+ * Commit modeset configuration to crtcs without checking if there is a DRM master.
+ *
+ * Returns:
+ * Zero on success or negative error code on failure.
+ */
+int drm_client_modeset_commit_force(struct drm_client_dev *client)
 {
-	struct drm_device *dev = fb_helper->dev;
+	struct drm_device *dev = client->dev;
 	int ret;
 
-	mutex_lock(&fb_helper->client.modeset_mutex);
+	mutex_lock(&client->modeset_mutex);
 	if (drm_drv_uses_atomic_modeset(dev))
-		ret = restore_fbdev_mode_atomic(fb_helper, true);
+		ret = drm_client_modeset_commit_atomic(client, true);
 	else
-		ret = restore_fbdev_mode_legacy(fb_helper);
-	mutex_unlock(&fb_helper->client.modeset_mutex);
+		ret = drm_client_modeset_commit_legacy(client);
+	mutex_unlock(&client->modeset_mutex);
 
 	return ret;
 }
 
-static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
+/**
+ * drm_client_modeset_commit() - Commit CRTC configuration
+ * @client: DRM client
+ *
+ * Commit modeset configuration to crtcs.
+ *
+ * Returns:
+ * Zero on success or negative error code on failure.
+ */
+int drm_client_modeset_commit(struct drm_client_dev *client)
 {
-	struct drm_device *dev = fb_helper->dev;
+	struct drm_device *dev = client->dev;
 	int ret;
 
 	if (!drm_master_internal_acquire(dev))
 		return -EBUSY;
 
-	ret = restore_fbdev_mode_force(fb_helper);
+	ret = drm_client_modeset_commit_force(client);
 
 	drm_master_internal_release(dev);
 
@@ -611,7 +638,7 @@ int drm_fb_helper_restore_fbdev_mode_unlocked(struct drm_fb_helper *fb_helper)
 		return 0;
 
 	mutex_lock(&fb_helper->lock);
-	ret = restore_fbdev_mode(fb_helper);
+	ret = drm_client_modeset_commit(&fb_helper->client);
 
 	do_delayed = fb_helper->delayed_hotplug;
 	if (do_delayed)
@@ -645,7 +672,7 @@ static bool drm_fb_helper_force_kernel_mode(void)
 			continue;
 
 		mutex_lock(&helper->lock);
-		ret = restore_fbdev_mode_force(helper);
+		ret = drm_client_modeset_commit_force(&helper->client);
 		if (ret)
 			error = true;
 		mutex_unlock(&helper->lock);
@@ -677,10 +704,9 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {
 static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
 #endif
 
-static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)
+static void drm_client_modeset_dpms_legacy(struct drm_client_dev *client, int dpms_mode)
 {
-	struct drm_client_dev *client = &fb_helper->client;
-	struct drm_device *dev = fb_helper->dev;
+	struct drm_device *dev = client->dev;
 	struct drm_connector *connector;
 	struct drm_mode_set *modeset;
 	int j;
@@ -700,28 +726,42 @@ static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)
 	drm_modeset_unlock_all(dev);
 }
 
-static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
+/**
+ * drm_client_modeset_dpms() - Set DPMS mode
+ * @client: DRM client
+ * @mode: DPMS mode
+ *
+ * Note: For atomic drivers @mode is reduced to on/off.
+ *
+ * Returns:
+ * Zero on success or negative error code on failure.
+ */
+int drm_client_modeset_dpms(struct drm_client_dev *client, int mode)
 {
-	struct drm_fb_helper *fb_helper = info->par;
-	struct drm_client_dev *client = &fb_helper->client;
-	struct drm_device *dev = fb_helper->dev;
+	struct drm_device *dev = client->dev;
+	int ret = 0;
 
-	/*
-	 * For each CRTC in this fb, turn the connectors on/off.
-	 */
-	mutex_lock(&fb_helper->lock);
 	if (!drm_master_internal_acquire(dev))
-		goto unlock;
+		return -EBUSY;
 
 	mutex_lock(&client->modeset_mutex);
 	if (drm_drv_uses_atomic_modeset(dev))
-		restore_fbdev_mode_atomic(fb_helper, dpms_mode == DRM_MODE_DPMS_ON);
+		ret = drm_client_modeset_commit_atomic(client, mode == DRM_MODE_DPMS_ON);
 	else
-		dpms_legacy(fb_helper, dpms_mode);
+		drm_client_modeset_dpms_legacy(client, mode);
 	mutex_unlock(&client->modeset_mutex);
 
 	drm_master_internal_release(dev);
-unlock:
+
+	return ret;
+}
+
+static void drm_fb_helper_dpms(struct fb_info *info, int dpms_mode)
+{
+	struct drm_fb_helper *fb_helper = info->par;
+
+	mutex_lock(&fb_helper->lock);
+	drm_client_modeset_dpms(&fb_helper->client, dpms_mode);
 	mutex_unlock(&fb_helper->lock);
 }
 
@@ -1795,7 +1835,7 @@ static int pan_display_atomic(struct fb_var_screeninfo *var,
 
 	pan_set(fb_helper, var->xoffset, var->yoffset);
 
-	ret = restore_fbdev_mode_force(fb_helper);
+	ret = drm_client_modeset_commit_force(&fb_helper->client);
 	if (!ret) {
 		info->var.xoffset = var->xoffset;
 		info->var.yoffset = var->yoffset;
@@ -2021,7 +2061,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper,
 
 		/* First time: disable all crtc's.. */
 		if (!fb_helper->deferred_setup)
-			restore_fbdev_mode(fb_helper);
+			drm_client_modeset_commit(client);
 		return -EAGAIN;
 	}
 
@@ -2794,7 +2834,7 @@ static void drm_setup_crtcs_fb(struct drm_fb_helper *fb_helper)
 
 		modeset->fb = fb_helper->fb;
 
-		if (drm_fb_helper_panel_rotation(modeset, &rotation))
+		if (drm_client_panel_rotation(modeset, &rotation))
 			/* Rotating in hardware, fbcon should not rotate */
 			sw_rotations |= DRM_MODE_ROTATE_0;
 		else
-- 
2.20.1

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

  parent reply	other threads:[~2019-04-07 16:52 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-07 16:52 [PATCH v2 00/12] drm/fb-helper: Move modesetting code to drm_client Noralf Trønnes
2019-04-07 16:52 ` [PATCH v2 01/12] drm/atomic: Move __drm_atomic_helper_disable_plane/set_config() Noralf Trønnes
2019-04-16  9:12   ` Maxime Ripard
2019-04-07 16:52 ` [PATCH v2 02/12] drm/fb-helper: Avoid race with DRM userspace Noralf Trønnes
2019-04-16  7:59   ` Daniel Vetter
2019-04-16 18:46     ` Noralf Trønnes
2019-04-17 13:24       ` Daniel Vetter
2019-04-17 13:26         ` Daniel Vetter
2019-04-17 14:48           ` Noralf Trønnes
2019-04-16  9:26   ` Maxime Ripard
2019-04-07 16:52 ` [PATCH v2 03/12] drm/i915/fbdev: Move intel_fb_initial_config() to fbdev helper Noralf Trønnes
2019-04-11 14:25   ` Noralf Trønnes
2019-04-23 14:17   ` Thomas Zimmermann
2019-04-23 14:58     ` Noralf Trønnes
2019-04-07 16:52 ` [PATCH v2 04/12] drm/fb-helper: No need to cache rotation and sw_rotations Noralf Trønnes
2019-04-16  9:28   ` Maxime Ripard
2019-04-07 16:52 ` [PATCH v2 05/12] drm/fb-helper: Remove drm_fb_helper_crtc->{x, y, desired_mode} Noralf Trønnes
2019-04-16  9:29   ` Maxime Ripard
2019-04-07 16:52 ` [PATCH v2 06/12] drm/fb-helper: Remove drm_fb_helper_crtc Noralf Trønnes
2019-04-16  8:34   ` Daniel Vetter
2019-04-07 16:52 ` Noralf Trønnes [this message]
2019-04-07 16:52 ` [PATCH v2 08/12] drm/fb-helper: Move out commit code Noralf Trønnes
2019-04-16  8:38   ` Daniel Vetter
2019-04-17 17:56     ` Noralf Trønnes
2019-04-18  8:30       ` Daniel Vetter
2019-04-07 16:52 ` [PATCH v2 09/12] drm/fb-helper: Remove drm_fb_helper_connector Noralf Trønnes
2019-04-16  9:42   ` Maxime Ripard
2019-04-16 14:57     ` Noralf Trønnes
2019-04-17 16:48       ` Maxime Ripard
2019-04-07 16:52 ` [PATCH v2 10/12] drm/fb-helper: Prepare to move out modeset config code Noralf Trønnes
2019-04-16  9:43   ` Maxime Ripard
2019-04-07 16:52 ` [PATCH v2 11/12] drm/fb-helper: Move " Noralf Trønnes
2019-04-16  9:43   ` Maxime Ripard
2019-04-07 16:52 ` [PATCH v2 12/12] drm/client: Hack: Add bootsplash example Noralf Trønnes
2019-04-07 17:02 ` ✗ Fi.CI.CHECKPATCH: warning for drm/fb-helper: Move modesetting code to drm_client (rev2) Patchwork
2019-04-07 17:10 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-04-07 17:21 ` ✓ Fi.CI.BAT: success " Patchwork
2019-04-07 18:29 ` ✓ Fi.CI.IGT: " Patchwork
2019-04-16  8:41 ` [PATCH v2 00/12] drm/fb-helper: Move modesetting code to drm_client Daniel Vetter
2019-04-16  8:46   ` Daniel Vetter
2019-04-17 18:06   ` Noralf Trønnes

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=20190407165243.54043-8-noralf@tronnes.org \
    --to=noralf@tronnes.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.