All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Sebastian Reichel <sre@kernel.org>,
	Tony Lindgren <tony@atomide.com>,
	Aaro Koskinen <aaro.koskinen@iki.fi>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	David Airlie <airlied@linux.ie>,
	linux-omap@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 15/23] drm: omapdrm: crtc: add support for manual updated displays
Date: Tue,  8 Mar 2016 17:39:47 +0100	[thread overview]
Message-ID: <1457455195-1938-16-git-send-email-sre@kernel.org> (raw)
In-Reply-To: <1457455195-1938-1-git-send-email-sre@kernel.org>

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 91 +++++++++++++++++++++++++++++++++++--
 drivers/gpu/drm/omapdrm/omap_drv.h  |  2 +
 2 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 3ce7143e5a5f..10d2647965c2 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -51,12 +51,14 @@ struct omap_crtc {
 	bool manually_updated;
 
 	struct omap_drm_irq vblank_irq;
+	struct omap_drm_irq framedone_irq;
 	struct omap_drm_irq error_irq;
 
 	bool ignore_digit_sync_lost;
 
 	unsigned long state;
 	wait_queue_head_t pending_wait;
+	struct delayed_work update_work;
 
 	void (*framedone_handler)(void *);
 	void *framedone_handler_data;
@@ -91,7 +93,7 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
 
 	return wait_event_timeout(omap_crtc->pending_wait,
 				  !test_bit(crtc_pending, &omap_crtc->state),
-				  msecs_to_jiffies(50));
+				  msecs_to_jiffies(250));
 }
 
 bool omap_crtc_is_manual_updated(struct drm_crtc *crtc)
@@ -141,6 +143,15 @@ static void omap_crtc_dss_disconnect(struct omap_overlay_manager *mgr,
 
 static void omap_crtc_dss_start_update(struct omap_overlay_manager *mgr)
 {
+	struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
+	struct drm_device *dev = omap_crtc->base.dev;
+	enum omap_channel channel = omap_crtc->channel;
+
+	WARN_ON(dispc_mgr_is_enabled(channel));
+
+	omap_irq_register(dev, &omap_crtc->framedone_irq);
+
+	dispc_mgr_enable(channel, true);
 }
 
 /* Called only from the encoder enable/disable and suspend/resume handlers. */
@@ -209,8 +220,11 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 static int omap_crtc_dss_enable(struct omap_overlay_manager *mgr)
 {
 	struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
+	struct drm_device *dev = omap_crtc->base.dev;
 	struct omap_overlay_manager_info info;
 
+	dev_dbg(dev->dev, "crtc dss enable %s", omap_crtc->name);
+
 	memset(&info, 0, sizeof(info));
 	info.default_color = 0x00000000;
 	info.trans_key = 0x00000000;
@@ -230,6 +244,9 @@ static int omap_crtc_dss_enable(struct omap_overlay_manager *mgr)
 static void omap_crtc_dss_disable(struct omap_overlay_manager *mgr)
 {
 	struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
+	struct drm_device *dev = omap_crtc->base.dev;
+
+	dev_dbg(dev->dev, "crtc dss disable %s", omap_crtc->name);
 
 	clear_bit(crtc_enabled, &omap_crtc->state);
 
@@ -376,6 +393,63 @@ static void omap_crtc_vblank_irq(struct omap_drm_irq *irq, uint32_t irqstatus)
 	wake_up(&omap_crtc->pending_wait);
 }
 
+static void omap_crtc_framedone_irq(struct omap_drm_irq *irq, uint32_t irqstatus)
+{
+	struct omap_crtc *omap_crtc =
+			container_of(irq, struct omap_crtc, framedone_irq);
+	struct drm_device *dev = omap_crtc->base.dev;
+
+	if (omap_crtc->framedone_handler)
+		omap_crtc->framedone_handler(omap_crtc->framedone_handler_data);
+
+	__omap_irq_unregister(dev, &omap_crtc->framedone_irq);
+
+	clear_bit(crtc_pending, &omap_crtc->state);
+	wake_up(&omap_crtc->pending_wait);
+}
+
+void omap_crtc_flush(struct drm_crtc *crtc,
+		int x, int y, int w, int h)
+{
+	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+
+	if (!omap_crtc->manually_updated)
+		return;
+
+	if (!test_bit(crtc_enabled, &omap_crtc->state))
+		return;
+
+	if (!delayed_work_pending(&omap_crtc->update_work))
+		schedule_delayed_work(&omap_crtc->update_work, 0);
+}
+
+static void omap_crtc_manual_display_update(struct work_struct *data)
+{
+	struct omap_crtc *omap_crtc = container_of(data, struct omap_crtc,
+					update_work.work);
+	struct omap_dss_device *dssdev = omap_crtc->mgr->output->dst;
+	struct omap_dss_driver *dssdrv = dssdev->driver;
+	int ret;
+
+	if (!dssdrv || !dssdrv->update)
+		return;
+
+	if (!test_bit(crtc_enabled, &omap_crtc->state))
+		return;
+
+	if (test_and_set_bit(crtc_pending, &omap_crtc->state))
+		return;
+
+	if (dssdrv->sync)
+		dssdrv->sync(dssdev);
+
+	ret = dssdrv->update(dssdev, 0, 0, omap_crtc->timings.x_res, omap_crtc->timings.y_res);
+	if (ret < 0) {
+		clear_bit(crtc_pending, &omap_crtc->state);
+		wake_up(&omap_crtc->pending_wait);
+	}
+}
+
 /* -----------------------------------------------------------------------------
  * CRTC Functions
  */
@@ -407,7 +481,7 @@ static void omap_crtc_enable(struct drm_crtc *crtc)
 	struct omap_dss_device *display = omap_crtc->mgr->output->dst;
 	struct drm_device *dev = crtc->dev;
 
-	DBG("%s", omap_crtc->name);
+	dev_dbg(dev->dev, "enable crtc %s", omap_crtc->name);
 
 	/* manual updated display will not trigger vsync irq */
 	/* omap_crtc->manually_updated is not yet set */
@@ -427,8 +501,14 @@ static void omap_crtc_enable(struct drm_crtc *crtc)
 static void omap_crtc_disable(struct drm_crtc *crtc)
 {
 	struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
+	struct drm_device *dev = crtc->dev;
 
-	DBG("%s", omap_crtc->name);
+	dev_dbg(dev->dev, "disable crtc %s", omap_crtc->name);
+
+	cancel_delayed_work(&omap_crtc->update_work);
+
+	if (!omap_crtc_wait_pending(crtc))
+		dev_warn(dev->dev, "manual display update did not finish!");
 
 	drm_crtc_vblank_off(crtc);
 }
@@ -571,6 +651,8 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 
 	init_waitqueue_head(&omap_crtc->pending_wait);
 
+	INIT_DELAYED_WORK(&omap_crtc->update_work, omap_crtc_manual_display_update);
+
 	omap_crtc->state = 0;
 
 	omap_crtc->channel = channel;
@@ -579,6 +661,9 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 	omap_crtc->vblank_irq.irqmask = pipe2vbl(crtc);
 	omap_crtc->vblank_irq.irq = omap_crtc_vblank_irq;
 
+	omap_crtc->framedone_irq.irqmask = dispc_mgr_get_framedone_irq(omap_crtc->channel);
+	omap_crtc->framedone_irq.irq = omap_crtc_framedone_irq;
+
 	omap_crtc->error_irq.irqmask =
 			dispc_mgr_get_sync_lost_irq(channel);
 	omap_crtc->error_irq.irq = omap_crtc_error_irq;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h
index 3ab4919aff4b..e08f4ef1bf3c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/omap_drv.h
@@ -174,6 +174,8 @@ struct drm_encoder *omap_connector_attached_encoder(
 bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
 void omap_connector_flush(struct drm_connector *connector,
 		int x, int y, int w, int h);
+void omap_crtc_flush(struct drm_crtc *crtc,
+		int x, int y, int w, int h);
 
 void copy_timings_omap_to_drm(struct drm_display_mode *mode,
 		struct omap_video_timings *timings);
-- 
2.7.0

  parent reply	other threads:[~2016-03-08 16:52 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 16:39 [PATCH 00/23] Nokia N950 display support Sebastian Reichel
2016-03-08 16:39 ` [PATCH 01/23] ARM: dts: n9/n950: regulator configuration Sebastian Reichel
2016-03-08 16:39 ` [PATCH 02/23] ARM: dts: n950: add display support Sebastian Reichel
2016-03-17 12:14   ` Laurent Pinchart
2016-03-17 12:14     ` Laurent Pinchart
2016-03-17 17:49     ` Sebastian Reichel
2016-03-23 12:40       ` Jani Nikula
2016-03-23 12:40         ` Jani Nikula
2016-03-23 14:01         ` Sebastian Reichel
2016-03-24 10:03           ` Jani Nikula
2016-03-24 10:03             ` Jani Nikula
2016-03-24 14:26             ` Sebastian Reichel
2016-03-24 15:11               ` Jani Nikula
2016-03-24 15:11                 ` Jani Nikula
2016-03-25  0:15                 ` Sebastian Reichel
2016-04-12 20:51                   ` Tony Lindgren
2016-06-21 11:01                     ` Tony Lindgren
2016-06-24  0:30                       ` Sebastian Reichel
2016-03-08 16:39 ` [PATCH 03/23] drm: omapdrm: dss: reset dsi module during initialization Sebastian Reichel
2016-05-10 12:07   ` Tomi Valkeinen
2016-05-10 12:07     ` Tomi Valkeinen
2016-03-08 16:39 ` [PATCH 04/23] drm: omapdrm: add DSI mapping Sebastian Reichel
2016-03-26  9:09   ` Laurent Pinchart
2016-03-26  9:09     ` Laurent Pinchart
2016-05-10 12:08   ` Tomi Valkeinen
2016-05-10 12:08     ` Tomi Valkeinen
2016-03-08 16:39 ` [PATCH 05/23] Revert "drm: omapdrm: Remove manual update display support" Sebastian Reichel
2016-03-08 16:39 ` [PATCH 06/23] drm: omapdrm: wait for pending operations before updating plane Sebastian Reichel
2016-03-26  9:20   ` Laurent Pinchart
2016-03-26  9:20     ` Laurent Pinchart
2016-03-26 15:52     ` Sebastian Reichel
2016-03-08 16:39 ` [PATCH 07/23] drm: omapdrm: crtc: switch pending variable to atomic bitset Sebastian Reichel
2016-03-26 16:30   ` Laurent Pinchart
2016-03-08 16:39 ` [PATCH 08/23] drm: omapdrm: crtc: add enabled bit to state Sebastian Reichel
2016-03-26 16:35   ` Laurent Pinchart
2016-03-08 16:39 ` [PATCH 09/23] drm: omapdrm: dss: method to get stallmode from lcd config Sebastian Reichel
2016-03-08 16:39 ` [PATCH 10/23] drm: omapdrm: crtc: detect manually updated displays Sebastian Reichel
2016-03-26 16:51   ` Laurent Pinchart
2016-03-08 16:39 ` [PATCH 11/23] include: video: omapdss: provide fifo threshold methods Sebastian Reichel
2016-03-26 16:44   ` Laurent Pinchart
2016-03-08 16:39 ` [PATCH 12/23] drm: omapdrm: plane: update fifo size on atomic update Sebastian Reichel
2016-12-13 17:35   ` Laurent Pinchart
2016-12-13 17:35     ` Laurent Pinchart
2016-12-14  8:43     ` Tomi Valkeinen
2016-12-14  8:43       ` Tomi Valkeinen
2016-12-14  9:10       ` Laurent Pinchart
2016-12-14  9:10         ` Laurent Pinchart
2016-12-14  9:14         ` Tomi Valkeinen
2016-12-14  9:14           ` Tomi Valkeinen
2016-12-14 14:03           ` Sebastian Reichel
2016-12-14 21:36             ` Laurent Pinchart
2016-12-15  8:40               ` Tomi Valkeinen
2016-12-15  8:40                 ` Tomi Valkeinen
2016-03-08 16:39 ` [PATCH 13/23] drm: omapdrm: crtc: update plane fifos on lcd config change Sebastian Reichel
2016-03-26 17:00   ` Laurent Pinchart
2016-03-26 17:00     ` Laurent Pinchart
2016-03-08 16:39 ` [PATCH 14/23] drm: omapdrm: crtc: save framedone callback from dss Sebastian Reichel
2016-03-26 17:03   ` Laurent Pinchart
2016-03-26 17:03     ` Laurent Pinchart
2016-03-08 16:39 ` Sebastian Reichel [this message]
2016-03-08 16:39 ` [PATCH 16/23] drm: omapdrm: update manual displays on dirty ioctl Sebastian Reichel
2016-03-08 16:39 ` [PATCH 17/23] drm: omapdrm: panel-dsi-cm: add regulator support Sebastian Reichel
2016-03-08 16:39 ` [PATCH 18/23] drm: omapdrm: panel-dsi-cm: use threaded irq handler Sebastian Reichel
2016-05-10 12:19   ` Tomi Valkeinen
2016-05-10 12:19     ` Tomi Valkeinen
2016-03-08 16:39 ` [PATCH 19/23] drm: omapdrm: panel-dsi-cm: improve DT support Sebastian Reichel
2016-03-08 16:39 ` [PATCH 20/23] drm: omapdrm: panel-dsi-cm: add offset support Sebastian Reichel
2016-03-08 16:39 ` [PATCH 21/23] drm: omapdrm: panel-dsi-cm: block disable until update completed Sebastian Reichel
2016-03-08 16:39 ` [PATCH 22/23] drm: omapdrm: panel-dsi-cm: ratelimit debug output in update path Sebastian Reichel
2016-03-08 16:39 ` [PATCH 23/23] drm: omapdrm: panel-dsi-cm: provide timings methods for omapdrm Sebastian Reichel
2016-03-08 18:39 ` [PATCH 00/23] Nokia N950 display support Aaro Koskinen
2016-03-08 20:45   ` Sebastian Reichel
2016-03-09  7:10     ` Tomi Valkeinen
2016-03-09  7:10       ` Tomi Valkeinen
2016-03-09 14:33       ` Sebastian Reichel
2016-03-09 21:02     ` Aaro Koskinen
2016-03-09 16:19 ` Emil Velikov
2016-03-09 16:24   ` Tomi Valkeinen
2016-03-09 16:24     ` Tomi Valkeinen
2016-03-09 16:58     ` Emil Velikov
2016-03-09 16:58       ` Emil Velikov
2016-03-09 17:09   ` Sebastian Reichel
2016-03-28 12:34     ` Emil Velikov
2016-03-28 12:34       ` Emil Velikov

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=1457455195-1938-16-git-send-email-sre@kernel.org \
    --to=sre@kernel.org \
    --cc=aaro.koskinen@iki.fi \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    --cc=tony@atomide.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.