From patchwork Thu Jun 4 09:02:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 6545971 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1CC859F326 for ; Thu, 4 Jun 2015 11:07:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B53672068E for ; Thu, 4 Jun 2015 11:07:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7429D206D6 for ; Thu, 4 Jun 2015 11:07:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 34F406EB18; Thu, 4 Jun 2015 04:06:51 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by gabe.freedesktop.org (Postfix) with ESMTP id F1D946EAD8 for ; Thu, 4 Jun 2015 02:04:25 -0700 (PDT) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id t5494M4Y030679; Thu, 4 Jun 2015 04:04:22 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5494MkO030182; Thu, 4 Jun 2015 04:04:22 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Thu, 4 Jun 2015 04:04:22 -0500 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id t5493Ywb014785; Thu, 4 Jun 2015 04:04:21 -0500 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCHv2 35/45] drm: omapdrm: Move encoder setup to encoder operations Date: Thu, 4 Jun 2015 12:02:52 +0300 Message-ID: <1433408582-9828-36-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433408582-9828-1-git-send-email-tomi.valkeinen@ti.com> References: <1433408582-9828-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 04 Jun 2015 04:06:34 -0700 Cc: Tomi Valkeinen X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Pinchart Now that the driver is fully converted to atomic operations, and that the atomic helpers call the operations in the right order, we can move encoder setup to where it belongs, in the encoder operations. Signed-off-by: Laurent Pinchart Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/omap_crtc.c | 38 +--------------- drivers/gpu/drm/omapdrm/omap_drv.h | 6 +-- drivers/gpu/drm/omapdrm/omap_encoder.c | 79 +++++++++++++--------------------- 3 files changed, 34 insertions(+), 89 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c index 3a5e68a06af3..2236f52f8bc3 100644 --- a/drivers/gpu/drm/omapdrm/omap_crtc.c +++ b/drivers/gpu/drm/omapdrm/omap_crtc.c @@ -35,7 +35,6 @@ struct omap_crtc { const char *name; enum omap_channel channel; - struct drm_encoder *current_encoder; /* * Temporary: eventually this will go away, but it is needed @@ -70,7 +69,7 @@ uint32_t pipe2vbl(struct drm_crtc *crtc) return dispc_mgr_get_vsync_irq(omap_crtc->channel); } -const struct omap_video_timings *omap_crtc_timings(struct drm_crtc *crtc) +struct omap_video_timings *omap_crtc_timings(struct drm_crtc *crtc) { struct omap_crtc *omap_crtc = to_omap_crtc(crtc); return &omap_crtc->timings; @@ -125,7 +124,7 @@ static void omap_crtc_dss_start_update(struct omap_overlay_manager *mgr) { } -/* Called only from omap_crtc_encoder_setup and suspend/resume handlers. */ +/* Called only from the encoder enable/disable and suspend/resume handlers. */ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable) { struct drm_device *dev = crtc->dev; @@ -365,37 +364,6 @@ static int omap_crtc_flush(struct drm_crtc *crtc) return 0; } -static void omap_crtc_encoder_setup(struct drm_crtc *crtc, bool enable) -{ - struct omap_crtc *omap_crtc = to_omap_crtc(crtc); - struct omap_drm_private *priv = crtc->dev->dev_private; - struct drm_encoder *encoder = NULL; - unsigned int i; - - DBG("%s: enable=%d", omap_crtc->name, enable); - - for (i = 0; i < priv->num_encoders; i++) { - if (priv->encoders[i]->crtc == crtc) { - encoder = priv->encoders[i]; - break; - } - } - - if (omap_crtc->current_encoder && encoder != omap_crtc->current_encoder) - omap_encoder_set_enabled(omap_crtc->current_encoder, false); - - omap_crtc->current_encoder = encoder; - - if (encoder) { - omap_encoder_set_enabled(encoder, false); - if (enable) { - omap_encoder_update(encoder, omap_crtc->mgr, - &omap_crtc->timings); - omap_encoder_set_enabled(encoder, true); - } - } -} - /* ----------------------------------------------------------------------------- * CRTC Functions */ @@ -437,7 +405,6 @@ static void omap_crtc_enable(struct drm_crtc *crtc) WARN_ON(omap_plane_setup(plane)); } - omap_crtc_encoder_setup(crtc, true); omap_crtc_flush(crtc); drm_crtc_vblank_on(crtc); @@ -462,7 +429,6 @@ static void omap_crtc_disable(struct drm_crtc *crtc) WARN_ON(omap_plane_setup(plane)); } - omap_crtc_encoder_setup(crtc, false); omap_crtc_flush(crtc); } diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 81c60284bfb0..bdd54162698f 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -141,7 +141,7 @@ int omap_drm_irq_install(struct drm_device *dev); struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev); void omap_fbdev_free(struct drm_device *dev); -const struct omap_video_timings *omap_crtc_timings(struct drm_crtc *crtc); +struct omap_video_timings *omap_crtc_timings(struct drm_crtc *crtc); enum omap_channel omap_crtc_channel(struct drm_crtc *crtc); void omap_crtc_pre_init(void); void omap_crtc_pre_uninit(void); @@ -156,10 +156,6 @@ void omap_plane_install_properties(struct drm_plane *plane, struct drm_encoder *omap_encoder_init(struct drm_device *dev, struct omap_dss_device *dssdev); -int omap_encoder_set_enabled(struct drm_encoder *encoder, bool enabled); -int omap_encoder_update(struct drm_encoder *encoder, - struct omap_overlay_manager *mgr, - struct omap_video_timings *timings); struct drm_connector *omap_connector_init(struct drm_device *dev, int connector_type, struct omap_dss_device *dssdev, diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c index 54847ed089ef..7d9b32a0eb43 100644 --- a/drivers/gpu/drm/omapdrm/omap_encoder.c +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c @@ -52,8 +52,6 @@ static void omap_encoder_destroy(struct drm_encoder *encoder) { struct omap_encoder *omap_encoder = to_omap_encoder(encoder); - omap_encoder_set_enabled(encoder, false); - drm_encoder_cleanup(encoder); kfree(omap_encoder); } @@ -93,59 +91,18 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder, } } -/* - * The CRTC drm_crtc_helper_set_mode() didn't really give us the right order. - * The easiest way to work around this was to make all the encoder-helper's - * no-op's and have the omap_crtc code take care of the sequencing and call - * us in the right points. - * - * FIXME: Revisit this after switching to atomic updates completely. - */ - static void omap_encoder_disable(struct drm_encoder *encoder) { -} - -static void omap_encoder_enable(struct drm_encoder *encoder) -{ -} - -static int omap_encoder_atomic_check(struct drm_encoder *encoder, - struct drm_crtc_state *crtc_state, - struct drm_connector_state *conn_state) -{ - return 0; -} - -static const struct drm_encoder_helper_funcs omap_encoder_helper_funcs = { - .mode_set = omap_encoder_mode_set, - .disable = omap_encoder_disable, - .enable = omap_encoder_enable, - .atomic_check = omap_encoder_atomic_check, -}; - -/* - * Instead of relying on the helpers for modeset, the omap_crtc code - * calls these functions in the proper sequence. - */ - -int omap_encoder_set_enabled(struct drm_encoder *encoder, bool enabled) -{ struct omap_encoder *omap_encoder = to_omap_encoder(encoder); struct omap_dss_device *dssdev = omap_encoder->dssdev; struct omap_dss_driver *dssdrv = dssdev->driver; - if (enabled) { - return dssdrv->enable(dssdev); - } else { - dssdrv->disable(dssdev); - return 0; - } + dssdrv->disable(dssdev); } -int omap_encoder_update(struct drm_encoder *encoder, - struct omap_overlay_manager *mgr, - struct omap_video_timings *timings) +static int omap_encoder_update(struct drm_encoder *encoder, + enum omap_channel channel, + struct omap_video_timings *timings) { struct drm_device *dev = encoder->dev; struct omap_encoder *omap_encoder = to_omap_encoder(encoder); @@ -153,7 +110,7 @@ int omap_encoder_update(struct drm_encoder *encoder, struct omap_dss_driver *dssdrv = dssdev->driver; int ret; - dssdev->src->manager = mgr; + dssdev->src->manager = omap_dss_get_overlay_manager(channel); if (dssdrv->check_timings) { ret = dssdrv->check_timings(dssdev, timings); @@ -179,6 +136,32 @@ int omap_encoder_update(struct drm_encoder *encoder, return 0; } +static void omap_encoder_enable(struct drm_encoder *encoder) +{ + struct omap_encoder *omap_encoder = to_omap_encoder(encoder); + struct omap_dss_device *dssdev = omap_encoder->dssdev; + struct omap_dss_driver *dssdrv = dssdev->driver; + + omap_encoder_update(encoder, omap_crtc_channel(encoder->crtc), + omap_crtc_timings(encoder->crtc)); + + dssdrv->enable(dssdev); +} + +static int omap_encoder_atomic_check(struct drm_encoder *encoder, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + return 0; +} + +static const struct drm_encoder_helper_funcs omap_encoder_helper_funcs = { + .mode_set = omap_encoder_mode_set, + .disable = omap_encoder_disable, + .enable = omap_encoder_enable, + .atomic_check = omap_encoder_atomic_check, +}; + /* initialize encoder */ struct drm_encoder *omap_encoder_init(struct drm_device *dev, struct omap_dss_device *dssdev)