All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jyri Sarha <jsarha@ti.com>
To: dri-devel@lists.freedesktop.org
Cc: Jyri Sarha <jsarha@ti.com>,
	tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com
Subject: [PATCH v2 08/21] drm/tilcdc: Add atomic mode config funcs
Date: Tue, 28 Jun 2016 10:21:03 +0300	[thread overview]
Message-ID: <f1459faa34dd5c5f5c851c442e76520156c93d2f.1467098026.git.jsarha@ti.com> (raw)
In-Reply-To: <cover.1467098026.git.jsarha@ti.com>

Add atomic mode config funcs. The atomic_commit implementation is a
copy-paste from drm_atomic_helper_commit(), leaving out the async
test. The similar copy-paste implementation appears to be used in many
other drivers too. The standard drm_atomic_helper_check() is used for
checking.

The drm_atomic_helper_check() can not be used in drm_mode_config_funcs
atomic_check() callback because the plane's check implementation may
update crtc state's ->mode_changed flag. Because of this the
drm_atomic_helper_check_modeset() has to be called once more after
drm_atomic_helper_check_planes() (see drm_atomic_helper_check_modeset()
documentation).

Signed-off-by: Jyri Sarha <jsarha@ti.com>
---
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 71 +++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 10fd3ee..c431870 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -20,6 +20,8 @@
 #include <linux/component.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/suspend.h>
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
 
 #include "tilcdc_drv.h"
 #include "tilcdc_regs.h"
@@ -59,9 +61,78 @@ static void tilcdc_fb_output_poll_changed(struct drm_device *dev)
 	drm_fbdev_cma_hotplug_event(priv->fbdev);
 }
 
+int tilcdc_atomic_check(struct drm_device *dev,
+			struct drm_atomic_state *state)
+{
+	int ret;
+
+	ret = drm_atomic_helper_check_modeset(dev, state);
+	if (ret)
+		return ret;
+
+	ret = drm_atomic_helper_check_planes(dev, state);
+	if (ret)
+		return ret;
+
+	/*
+	 * tilcdc ->atomic_check can update ->mode_changed if pixel format
+	 * changes, hence will we check modeset changes again.
+	 */
+	ret = drm_atomic_helper_check_modeset(dev, state);
+	if (ret)
+		return ret;
+
+	return ret;
+}
+
+static int tilcdc_commit(struct drm_device *dev,
+		  struct drm_atomic_state *state,
+		  bool async)
+{
+	int ret;
+
+	ret = drm_atomic_helper_prepare_planes(dev, state);
+	if (ret)
+		return ret;
+
+	drm_atomic_helper_swap_state(dev, state);
+
+	/*
+	 * Everything below can be run asynchronously without the need to grab
+	 * any modeset locks at all under one condition: It must be guaranteed
+	 * that the asynchronous work has either been cancelled (if the driver
+	 * supports it, which at least requires that the framebuffers get
+	 * cleaned up with drm_atomic_helper_cleanup_planes()) or completed
+	 * before the new state gets committed on the software side with
+	 * drm_atomic_helper_swap_state().
+	 *
+	 * This scheme allows new atomic state updates to be prepared and
+	 * checked in parallel to the asynchronous completion of the previous
+	 * update. Which is important since compositors need to figure out the
+	 * composition of the next frame right after having submitted the
+	 * current layout.
+	 */
+
+	drm_atomic_helper_commit_modeset_disables(dev, state);
+
+	drm_atomic_helper_commit_planes(dev, state, false);
+
+	drm_atomic_helper_commit_modeset_enables(dev, state);
+
+	drm_atomic_helper_wait_for_vblanks(dev, state);
+
+	drm_atomic_helper_cleanup_planes(dev, state);
+
+	drm_atomic_state_free(state);
+
+	return 0;
+}
+
 static const struct drm_mode_config_funcs mode_config_funcs = {
 	.fb_create = tilcdc_fb_create,
 	.output_poll_changed = tilcdc_fb_output_poll_changed,
+	.atomic_check = tilcdc_atomic_check,
+	.atomic_commit = tilcdc_commit,
 };
 
 static int modeset_init(struct drm_device *dev)
-- 
1.9.1

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

  parent reply	other threads:[~2016-06-28  7:21 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-28  7:20 [PATCH v2 00/21] drm/tilcdc: Atomic modeset support Jyri Sarha
2016-06-28  7:20 ` [PATCH v2 01/21] drm/tilcdc: Fix tilcdc component master unloading Jyri Sarha
2016-06-28  7:20 ` [PATCH v2 02/21] drm/tilcdc: Make tilcdc_crtc_page_flip() public Jyri Sarha
2016-06-28  7:20 ` [PATCH v2 03/21] drm/tilcdc: Make tilcdc_crtc_page_flip() work if crtc is not yet on Jyri Sarha
2016-06-28  7:20 ` [PATCH v2 04/21] drm/tilcdc: Add dummy primary plane implementation Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 05/21] drm/tilcdc: Initialize dummy primary plane from crtc init Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 06/21] drm/tilcdc: Add tilcdc_crtc_mode_set_nofb() Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 07/21] drm/tilcdc: Add tilcdc_crtc_atomic_check() Jyri Sarha
2016-06-28  7:21 ` Jyri Sarha [this message]
2016-06-28  7:21 ` [PATCH v2 09/21] drm/tilcdc: Add drm_mode_config_reset() call to tilcdc_load() Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 10/21] drm/tilcdc: Set DRIVER_ATOMIC and use atomic crtc helpers Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 11/21] drm/tilcdc: Remove obsolete crtc helper functions Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 12/21] drm/tilcdc: Remove tilcdc_verify_fb() Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 13/21] drm/tilcdc: panel: Set crtc panel info at init phase Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 14/21] drm/tilcdc: panel: Add atomic modeset helpers to connector funcs Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 15/21] drm/tilcdc: tfp410: Set crtc panel info at init phase Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 16/21] drm/tilcdc: tfp410: Add atomic modeset helpers to connector funcs Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 17/21] drm/tilcdc: Enable and disable interrupts in crtc start() and stop() Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 18/21] drm/tilcdc: Use drm_atomic_helper_resume/suspend() Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 19/21] drm/tilcdc: Get rid of legacy dpms mechanism Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 20/21] drm/tilcdc: Remove unnecessary pm_runtime_get() and *_put() calls Jyri Sarha
2016-06-28  7:21 ` [PATCH v2 21/21] drm/tilcdc: Change tilcdc_crtc_page_flip() to tilcdc_crtc_update_fb() Jyri Sarha

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=f1459faa34dd5c5f5c851c442e76520156c93d2f.1467098026.git.jsarha@ti.com \
    --to=jsarha@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=tomi.valkeinen@ti.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 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.