public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Eric Anholt <eric@anholt.net>
Cc: dri-devel@lists.freedesktop.org,
	Archit Taneja <architt@codeaurora.org>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	CK Hu <ck.hu@mediatek.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Yannick Fertre <yannick.fertre@st.com>,
	Philippe Cornu <philippe.cornu@st.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/7] drm/vc4: Switch DSI to the panel-bridge layer, and support bridges.
Date: Fri, 12 May 2017 10:02:34 +0200	[thread overview]
Message-ID: <20170512100234.12177f30@bbrezillon> (raw)
In-Reply-To: <20170511183128.25085-2-eric@anholt.net>

On Thu, 11 May 2017 11:31:23 -0700
Eric Anholt <eric@anholt.net> wrote:

> The newer version of the RPi panel driver is going to be a combination
> of a bridge and a panel, but we should also support panels without a
> bridge, so the panel-bridge layer lets us do that cleanly.
> 
> v2: Drop "dev" argument.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
>  drivers/gpu/drm/vc4/Kconfig   |   2 +-
>  drivers/gpu/drm/vc4/vc4_dsi.c | 154 ++++++------------------------------------
>  2 files changed, 21 insertions(+), 135 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/Kconfig b/drivers/gpu/drm/vc4/Kconfig
> index b16aefe4a8d3..4361bdcfd28a 100644
> --- a/drivers/gpu/drm/vc4/Kconfig
> +++ b/drivers/gpu/drm/vc4/Kconfig
> @@ -7,7 +7,7 @@ config DRM_VC4
>  	select DRM_KMS_HELPER
>  	select DRM_KMS_CMA_HELPER
>  	select DRM_GEM_CMA_HELPER
> -	select DRM_PANEL
> +	select DRM_PANEL_BRIDGE
>  	select SND_PCM
>  	select SND_PCM_ELD
>  	select SND_SOC_GENERIC_DMAENGINE_PCM
> diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
> index deba62008fd0..fb54a9d10360 100644
> --- a/drivers/gpu/drm/vc4/vc4_dsi.c
> +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
> @@ -503,8 +503,8 @@ struct vc4_dsi {
>  
>  	struct mipi_dsi_host dsi_host;
>  	struct drm_encoder *encoder;
> -	struct drm_connector *connector;
> -	struct drm_panel *panel;
> +	struct drm_bridge *bridge;
> +	bool is_panel_bridge;
>  
>  	void __iomem *regs;
>  
> @@ -604,18 +604,6 @@ to_vc4_dsi_encoder(struct drm_encoder *encoder)
>  	return container_of(encoder, struct vc4_dsi_encoder, base.base);
>  }
>  
> -/* VC4 DSI connector KMS struct */
> -struct vc4_dsi_connector {
> -	struct drm_connector base;
> -	struct vc4_dsi *dsi;
> -};
> -
> -static inline struct vc4_dsi_connector *
> -to_vc4_dsi_connector(struct drm_connector *connector)
> -{
> -	return container_of(connector, struct vc4_dsi_connector, base);
> -}
> -
>  #define DSI_REG(reg) { reg, #reg }
>  static const struct {
>  	u32 reg;
> @@ -723,79 +711,6 @@ int vc4_dsi_debugfs_regs(struct seq_file *m, void *unused)
>  }
>  #endif
>  
> -static enum drm_connector_status
> -vc4_dsi_connector_detect(struct drm_connector *connector, bool force)
> -{
> -	struct vc4_dsi_connector *vc4_connector =
> -		to_vc4_dsi_connector(connector);
> -	struct vc4_dsi *dsi = vc4_connector->dsi;
> -
> -	if (dsi->panel)
> -		return connector_status_connected;
> -	else
> -		return connector_status_disconnected;
> -}
> -
> -static void vc4_dsi_connector_destroy(struct drm_connector *connector)
> -{
> -	drm_connector_unregister(connector);
> -	drm_connector_cleanup(connector);
> -}
> -
> -static int vc4_dsi_connector_get_modes(struct drm_connector *connector)
> -{
> -	struct vc4_dsi_connector *vc4_connector =
> -		to_vc4_dsi_connector(connector);
> -	struct vc4_dsi *dsi = vc4_connector->dsi;
> -
> -	if (dsi->panel)
> -		return drm_panel_get_modes(dsi->panel);
> -
> -	return 0;
> -}
> -
> -static const struct drm_connector_funcs vc4_dsi_connector_funcs = {
> -	.dpms = drm_atomic_helper_connector_dpms,
> -	.detect = vc4_dsi_connector_detect,
> -	.fill_modes = drm_helper_probe_single_connector_modes,
> -	.destroy = vc4_dsi_connector_destroy,
> -	.reset = drm_atomic_helper_connector_reset,
> -	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> -	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> -};
> -
> -static const struct drm_connector_helper_funcs vc4_dsi_connector_helper_funcs = {
> -	.get_modes = vc4_dsi_connector_get_modes,
> -};
> -
> -static struct drm_connector *vc4_dsi_connector_init(struct drm_device *dev,
> -						    struct vc4_dsi *dsi)
> -{
> -	struct drm_connector *connector;
> -	struct vc4_dsi_connector *dsi_connector;
> -
> -	dsi_connector = devm_kzalloc(dev->dev, sizeof(*dsi_connector),
> -				     GFP_KERNEL);
> -	if (!dsi_connector)
> -		return ERR_PTR(-ENOMEM);
> -
> -	connector = &dsi_connector->base;
> -
> -	dsi_connector->dsi = dsi;
> -
> -	drm_connector_init(dev, connector, &vc4_dsi_connector_funcs,
> -			   DRM_MODE_CONNECTOR_DSI);
> -	drm_connector_helper_add(connector, &vc4_dsi_connector_helper_funcs);
> -
> -	connector->polled = 0;
> -	connector->interlace_allowed = 0;
> -	connector->doublescan_allowed = 0;
> -
> -	drm_mode_connector_attach_encoder(connector, dsi->encoder);
> -
> -	return connector;
> -}
> -
>  static void vc4_dsi_encoder_destroy(struct drm_encoder *encoder)
>  {
>  	drm_encoder_cleanup(encoder);
> @@ -893,12 +808,8 @@ static void vc4_dsi_encoder_disable(struct drm_encoder *encoder)
>  	struct vc4_dsi *dsi = vc4_encoder->dsi;
>  	struct device *dev = &dsi->pdev->dev;
>  
> -	drm_panel_disable(dsi->panel);
> -
>  	vc4_dsi_ulps(dsi, true);
>  
> -	drm_panel_unprepare(dsi->panel);
> -
>  	clk_disable_unprepare(dsi->pll_phy_clock);
>  	clk_disable_unprepare(dsi->escape_clock);
>  	clk_disable_unprepare(dsi->pixel_clock);
> @@ -929,12 +840,6 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)
>  		return;
>  	}
>  
> -	ret = drm_panel_prepare(dsi->panel);
> -	if (ret) {
> -		DRM_ERROR("Panel failed to prepare\n");
> -		return;
> -	}
> -
>  	if (debug_dump_regs) {
>  		DRM_INFO("DSI regs before:\n");
>  		vc4_dsi_dump_regs(dsi);
> @@ -1184,13 +1089,6 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)
>  		DRM_INFO("DSI regs after:\n");
>  		vc4_dsi_dump_regs(dsi);
>  	}
> -
> -	ret = drm_panel_enable(dsi->panel);
> -	if (ret) {
> -		DRM_ERROR("Panel failed to enable\n");
> -		drm_panel_unprepare(dsi->panel);
> -		return;
> -	}
>  }
>  
>  static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host,
> @@ -1366,17 +1264,22 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host,
>  		return 0;
>  	}
>  
> -	dsi->panel = of_drm_find_panel(device->dev.of_node);
> -	if (!dsi->panel)
> -		return 0;
> -
> -	ret = drm_panel_attach(dsi->panel, dsi->connector);
> -	if (ret != 0)
> -		return ret;
> +	dsi->bridge = of_drm_find_bridge(device->dev.of_node);
> +	if (!dsi->bridge) {
> +		struct drm_panel *panel =
> +			of_drm_find_panel(device->dev.of_node);
>  
> -	drm_helper_hpd_irq_event(dsi->connector->dev);
> +		dsi->bridge = drm_panel_bridge_add(panel,
> +						   DRM_MODE_CONNECTOR_DSI);
> +		if (IS_ERR(dsi->bridge)) {
> +			ret = PTR_ERR(dsi->bridge);
> +			dsi->bridge = NULL;
> +			return ret;
> +		}
> +		dsi->is_panel_bridge = true;
> +	}
>  
> -	return 0;
> +	return drm_bridge_attach(dsi->encoder, dsi->bridge, NULL);
>  }
>  
>  static int vc4_dsi_host_detach(struct mipi_dsi_host *host,
> @@ -1384,15 +1287,9 @@ static int vc4_dsi_host_detach(struct mipi_dsi_host *host,
>  {
>  	struct vc4_dsi *dsi = host_to_dsi(host);
>  
> -	if (dsi->panel) {
> -		int ret = drm_panel_detach(dsi->panel);
> -
> -		if (ret)
> -			return ret;
> -
> -		dsi->panel = NULL;
> -
> -		drm_helper_hpd_irq_event(dsi->connector->dev);
> +	if (dsi->is_panel_bridge) {
> +		drm_panel_bridge_remove(dsi->bridge);
> +		dsi->bridge = NULL;
>  	}
>  
>  	return 0;
> @@ -1658,12 +1555,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
>  			 DRM_MODE_ENCODER_DSI, NULL);
>  	drm_encoder_helper_add(dsi->encoder, &vc4_dsi_encoder_helper_funcs);
>  
> -	dsi->connector = vc4_dsi_connector_init(drm, dsi);
> -	if (IS_ERR(dsi->connector)) {
> -		ret = PTR_ERR(dsi->connector);
> -		goto err_destroy_encoder;
> -	}
> -
>  	dsi->dsi_host.ops = &vc4_dsi_host_ops;
>  	dsi->dsi_host.dev = dev;
>  
> @@ -1674,11 +1565,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)
>  	pm_runtime_enable(dev);
>  
>  	return 0;
> -
> -err_destroy_encoder:
> -	vc4_dsi_encoder_destroy(dsi->encoder);
> -
> -	return ret;
>  }
>  
>  static void vc4_dsi_unbind(struct device *dev, struct device *master,
> @@ -1690,7 +1576,7 @@ static void vc4_dsi_unbind(struct device *dev, struct device *master,
>  
>  	pm_runtime_disable(dev);
>  
> -	vc4_dsi_connector_destroy(dsi->connector);
> +	drm_bridge_remove(dsi->bridge);
>  	vc4_dsi_encoder_destroy(dsi->encoder);
>  
>  	mipi_dsi_host_unregister(&dsi->dsi_host);

  reply	other threads:[~2017-05-12  8:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 18:31 [PATCH v2 1/7] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge Eric Anholt
2017-05-11 18:31 ` [PATCH v2 2/7] drm/vc4: Switch DSI to the panel-bridge layer, and support bridges Eric Anholt
2017-05-12  8:02   ` Boris Brezillon [this message]
2017-05-11 18:31 ` [PATCH v2 3/7] drm/vc4: Switch DPI to using the panel-bridge helper Eric Anholt
2017-05-12  8:04   ` Boris Brezillon
2017-05-11 18:31 ` [PATCH v2 4/7] drm/mediatek: Use " Eric Anholt
2017-05-12  8:07   ` Boris Brezillon
2017-05-11 18:31 ` [PATCH v2 5/7] drm/ltdc: " Eric Anholt
2017-05-12  8:17   ` Boris Brezillon
2017-05-30 16:55   ` Philippe CORNU
2017-05-31  6:26     ` Boris Brezillon
2017-05-31  8:01       ` Archit Taneja
2017-05-31  8:07         ` Boris Brezillon
2017-05-31  8:35           ` Archit Taneja
2017-06-01  9:53             ` Philippe CORNU
2017-05-11 18:31 ` [PATCH v2 6/7] drm/atmel-hlcdc: Drop custom encoder cleanup func Eric Anholt
2017-05-11 19:15   ` Boris Brezillon
2017-05-11 18:31 ` [PATCH v2 7/7] drm/atmel-hlcdc: Replace the panel usage with drm_panel_bridge Eric Anholt
2017-05-11 19:15   ` Boris Brezillon
2017-05-12  7:35     ` Daniel Vetter
2017-06-05 15:36   ` Archit Taneja
2017-06-06  8:57     ` Boris Brezillon
2017-06-06 10:15       ` Archit Taneja
2017-05-12  7:33 ` [PATCH v2 1/7] drm/bridge: Refactor out the panel wrapper from the lvds-encoder bridge Boris Brezillon
2017-05-12 10:15 ` Archit Taneja

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=20170512100234.12177f30@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=architt@codeaurora.org \
    --cc=ck.hu@mediatek.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric@anholt.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=philippe.cornu@st.com \
    --cc=yannick.fertre@st.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox