From patchwork Tue Aug 20 01:16:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11102475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 294C214DE for ; Tue, 20 Aug 2019 01:18:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1355022CF5 for ; Tue, 20 Aug 2019 01:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1355022CF5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 924A56E571; Tue, 20 Aug 2019 01:18:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id CCCF26E504 for ; Tue, 20 Aug 2019 01:17:50 +0000 (UTC) Received: from pendragon.bb.dnainternet.fi (dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4085CAF9; Tue, 20 Aug 2019 03:17:45 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 20/50] drm/omap: Use the drm_panel_bridge API Date: Tue, 20 Aug 2019 04:16:51 +0300 Message-Id: <20190820011721.30136-21-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190820011721.30136-1-laurent.pinchart@ideasonboard.com> References: <20190820011721.30136-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1566263865; bh=sssVpt03GfVpjLa1198bIUaCmuHLMoyoLB8WAvThmYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wHt3FxiQSWEadKpGJCzJZuouHrM6uVPpvc3XTh1cMYPrQGZB0cs97N7/PaZiXTrGd TnbTatLWLMefyVtfKwXnhGPb882d+cYrMagdNhjDCsgL+gTm+8UTtDbIkdShrIZd26 BRuybtdSCu/MW3Scxgk+9KalgoxkF+DGhRGihOto= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , Tomi Valkeinen , Sean Paul , Sebastian Reichel Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Replace the manual panel handling code by a drm_panel_bridge. This simplifies the driver and allows all components in the display pipeline to be treated as bridges, paving the way to generic connector handling. Signed-off-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen --- Changes since v1: - Keep #include --- drivers/gpu/drm/omapdrm/dss/base.c | 12 ++++----- drivers/gpu/drm/omapdrm/dss/output.c | 33 +++++++++++++++++++++--- drivers/gpu/drm/omapdrm/omap_connector.c | 9 ------- drivers/gpu/drm/omapdrm/omap_drv.c | 13 ---------- drivers/gpu/drm/omapdrm/omap_encoder.c | 13 ---------- 5 files changed, 34 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/base.c b/drivers/gpu/drm/omapdrm/dss/base.c index cae5687822e2..80d48936d177 100644 --- a/drivers/gpu/drm/omapdrm/dss/base.c +++ b/drivers/gpu/drm/omapdrm/dss/base.c @@ -149,8 +149,7 @@ struct omap_dss_device *omapdss_device_next_output(struct omap_dss_device *from) goto done; } - if (dssdev->id && - (dssdev->next || dssdev->bridge || dssdev->panel)) + if (dssdev->id && (dssdev->next || dssdev->bridge)) goto done; } @@ -185,11 +184,10 @@ int omapdss_device_connect(struct dss_device *dss, if (!dst) { /* * The destination is NULL when the source is connected to a - * bridge or panel instead of a DSS device. Stop here, we will - * attach the bridge or panel later when we will have a DRM - * encoder. + * bridge instead of a DSS device. Stop here, we will attach + * the bridge later when we will have a DRM encoder. */ - return src && (src->bridge || src->panel) ? 0 : -EINVAL; + return src && src->bridge ? 0 : -EINVAL; } if (omapdss_device_is_connected(dst)) @@ -217,7 +215,7 @@ void omapdss_device_disconnect(struct omap_dss_device *src, dst ? dev_name(dst->dev) : "NULL"); if (!dst) { - WARN_ON(!src->bridge && !src->panel); + WARN_ON(!src->bridge); return; } diff --git a/drivers/gpu/drm/omapdrm/dss/output.c b/drivers/gpu/drm/omapdrm/dss/output.c index de0f882f0f7b..ca02728acc15 100644 --- a/drivers/gpu/drm/omapdrm/dss/output.c +++ b/drivers/gpu/drm/omapdrm/dss/output.c @@ -19,6 +19,7 @@ int omapdss_device_init_output(struct omap_dss_device *out) { struct device_node *remote_node; + int ret; remote_node = of_graph_get_remote_node(out->dev->of_node, 0, 0); if (!remote_node) { @@ -36,17 +37,41 @@ int omapdss_device_init_output(struct omap_dss_device *out) if (out->next && out->type != out->next->type) { dev_err(out->dev, "output type and display type don't match\n"); - omapdss_device_put(out->next); - out->next = NULL; - return -EINVAL; + ret = -EINVAL; + goto error; } - return out->next || out->bridge || out->panel ? 0 : -EPROBE_DEFER; + if (out->panel) { + unsigned int connector_type; + struct drm_bridge *bridge; + + connector_type = omapdss_device_connector_type(out->type); + bridge = drm_panel_bridge_add(out->panel, connector_type); + if (IS_ERR(bridge)) { + dev_err(out->dev, + "unable to create panel bridge (%ld)\n", + PTR_ERR(bridge)); + ret = PTR_ERR(bridge); + goto error; + } + + out->bridge = bridge; + } + + return out->next || out->bridge ? 0 : -EPROBE_DEFER; + +error: + omapdss_device_put(out->next); + out->next = NULL; + return ret; } EXPORT_SYMBOL(omapdss_device_init_output); void omapdss_device_cleanup_output(struct omap_dss_device *out) { + if (out->bridge && out->panel) + drm_panel_bridge_remove(out->bridge); + if (out->next) omapdss_device_put(out->next); } diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c index 8dc613afb1c5..b0cb2ecb30ab 100644 --- a/drivers/gpu/drm/omapdrm/omap_connector.c +++ b/drivers/gpu/drm/omapdrm/omap_connector.c @@ -6,7 +6,6 @@ #include #include -#include #include #include "omap_drv.h" @@ -190,7 +189,6 @@ static int omap_connector_get_modes_edid(struct drm_connector *connector, static int omap_connector_get_modes(struct drm_connector *connector) { - struct omap_connector *omap_connector = to_omap_connector(connector); struct omap_dss_device *dssdev; DBG("%s", connector->name); @@ -213,13 +211,6 @@ static int omap_connector_get_modes(struct drm_connector *connector) if (dssdev) return dssdev->ops->get_modes(dssdev, connector); - /* - * Otherwise if the display pipeline uses a drm_panel, we delegate the - * operation to the panel API. - */ - if (omap_connector->output->panel) - return drm_panel_get_modes(omap_connector->output->panel); - /* * We can't retrieve modes, which can happen for instance for a DVI or * VGA output with the DDC bus unconnected. The KMS core will add the diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 2988af9ae743..72872dfdb73e 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -133,9 +132,6 @@ static void omap_disconnect_pipelines(struct drm_device *ddev) for (i = 0; i < priv->num_pipes; i++) { struct omap_drm_pipeline *pipe = &priv->pipes[i]; - if (pipe->output->panel) - drm_panel_detach(pipe->output->panel); - omapdss_device_disconnect(NULL, pipe->output); omapdss_device_put(pipe->output); @@ -220,8 +216,6 @@ static int omap_display_id(struct omap_dss_device *output) bridge = bridge->next; node = bridge->of_node; - } else if (output->panel) { - node = output->panel->dev->of_node; } return node ? of_alias_get_id(node, "display") : -ENODEV; @@ -336,13 +330,6 @@ static int omap_modeset_init(struct drm_device *dev) return -ENOMEM; drm_connector_attach_encoder(pipe->connector, encoder); - - if (pipe->output->panel) { - ret = drm_panel_attach(pipe->output->panel, - pipe->connector); - if (ret < 0) - return ret; - } } crtc = omap_crtc_init(dev, pipe, priv->planes[i]); diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c index 415d0eac1c0c..7f3f5844c62a 100644 --- a/drivers/gpu/drm/omapdrm/omap_encoder.c +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "omap_drv.h" @@ -155,12 +154,6 @@ static void omap_encoder_disable(struct drm_encoder *encoder) dev_dbg(dev->dev, "disable(%s)\n", dssdev->name); - /* Disable the panel if present. */ - if (dssdev->panel) { - drm_panel_disable(dssdev->panel); - drm_panel_unprepare(dssdev->panel); - } - /* * Disable the chain of external devices, starting at the one at the * internal encoder's output. @@ -210,12 +203,6 @@ static void omap_encoder_enable(struct drm_encoder *encoder) * internal encoder's output. */ omapdss_device_enable(dssdev->next); - - /* Enable the panel if present. */ - if (dssdev->panel) { - drm_panel_prepare(dssdev->panel); - drm_panel_enable(dssdev->panel); - } } static int omap_encoder_atomic_check(struct drm_encoder *encoder,