All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neil Armstrong <narmstrong@baylibre.com>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	dri-devel@lists.freedesktop.org
Cc: linux-renesas-soc@vger.kernel.org,
	"Andrzej Hajda" <a.hajda@samsung.com>,
	"Jernej Skrabec" <jernej.skrabec@siol.net>,
	"Jonas Karlman" <jonas@kwiboo.se>,
	"Sam Ravnborg" <sam@ravnborg.org>,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Sandy Huang" <hjc@rock-chips.com>,
	"Heiko Stübner" <heiko@sntech.de>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Chen-Yu Tsai" <wens@csie.org>,
	linux-amlogic@lists.infradead.org
Subject: Re: [PATCH 11/27] drm: bridge: dw-hdmi: Pass private data pointer to .mode_valid()
Date: Tue, 26 May 2020 11:44:37 +0200	[thread overview]
Message-ID: <ba4aff85-56f1-42b0-8049-ed3ab5eb5559@baylibre.com> (raw)
In-Reply-To: <20200526011505.31884-12-laurent.pinchart+renesas@ideasonboard.com>

On 26/05/2020 03:14, Laurent Pinchart wrote:
> Platform glue drivers for dw_hdmi may need to access device-specific
> data from their .mode_valid() implementation. They currently have no
> clean way to do so, and one driver hacks around it by accessing the
> dev_private data of the drm_device retrieved from the connector.
> 
> Add a priv_data void pointer to the dw_hdmi_plat_data structure, and
> pass it to the .mode_valid() function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c   |  6 ++++--
>  drivers/gpu/drm/imx/dw_hdmi-imx.c           |  6 ++++--
>  drivers/gpu/drm/meson/meson_dw_hdmi.c       |  3 ++-
>  drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c      |  3 ++-
>  drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c |  3 ++-
>  drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c       |  6 ++++--
>  drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h       |  3 ++-
>  include/drm/bridge/dw_hdmi.h                | 14 ++++++++++++--
>  8 files changed, 32 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index b535354150db..2b3f203cf467 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2771,6 +2771,7 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
>  			  const struct drm_display_mode *mode)
>  {
>  	struct dw_hdmi *hdmi = bridge->driver_private;
> +	const struct dw_hdmi_plat_data *pdata = hdmi->plat_data;
>  	struct drm_connector *connector = &hdmi->connector;
>  	enum drm_mode_status mode_status = MODE_OK;
>  
> @@ -2778,8 +2779,9 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
>  	if (mode->flags & DRM_MODE_FLAG_DBLCLK)
>  		return MODE_BAD;
>  
> -	if (hdmi->plat_data->mode_valid)
> -		mode_status = hdmi->plat_data->mode_valid(connector, mode);
> +	if (pdata->mode_valid)
> +		mode_status = pdata->mode_valid(hdmi, pdata->priv_data,
> +						connector, mode);
>  
>  	return mode_status;
>  }
> diff --git a/drivers/gpu/drm/imx/dw_hdmi-imx.c b/drivers/gpu/drm/imx/dw_hdmi-imx.c
> index ba4ca17fd4d8..95aed4666c95 100644
> --- a/drivers/gpu/drm/imx/dw_hdmi-imx.c
> +++ b/drivers/gpu/drm/imx/dw_hdmi-imx.c
> @@ -145,7 +145,8 @@ static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs =
>  };
>  
>  static enum drm_mode_status
> -imx6q_hdmi_mode_valid(struct drm_connector *con,
> +imx6q_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		      struct drm_connector *con,
>  		      const struct drm_display_mode *mode)
>  {
>  	if (mode->clock < 13500)
> @@ -158,7 +159,8 @@ imx6q_hdmi_mode_valid(struct drm_connector *con,
>  }
>  
>  static enum drm_mode_status
> -imx6dl_hdmi_mode_valid(struct drm_connector *con,
> +imx6dl_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		       struct drm_connector *con,
>  		       const struct drm_display_mode *mode)
>  {
>  	if (mode->clock < 13500)
> diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> index 5be963e9db05..5cc311c1b8e0 100644
> --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
> +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> @@ -630,7 +630,8 @@ static irqreturn_t dw_hdmi_top_thread_irq(int irq, void *dev_id)
>  }
>  
>  static enum drm_mode_status
> -dw_hdmi_mode_valid(struct drm_connector *connector,
> +dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		   struct drm_connector *connector,
>  		   const struct drm_display_mode *mode)
>  {
>  	struct meson_drm *priv = connector->dev->dev_private;
> diff --git a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> index 452461dc96f2..4d837a4d302d 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> @@ -38,7 +38,8 @@ static const struct rcar_hdmi_phy_params rcar_hdmi_phy_params[] = {
>  };
>  
>  static enum drm_mode_status
> -rcar_hdmi_mode_valid(struct drm_connector *connector,
> +rcar_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		     struct drm_connector *connector,
>  		     const struct drm_display_mode *mode)
>  {
>  	/*
> diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> index 121aa8a63a76..d08f86783a28 100644
> --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> @@ -220,7 +220,8 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
>  }
>  
>  static enum drm_mode_status
> -dw_hdmi_rockchip_mode_valid(struct drm_connector *connector,
> +dw_hdmi_rockchip_mode_valid(struct dw_hdmi *hdmi, void *data,
> +			    struct drm_connector *connector,
>  			    const struct drm_display_mode *mode)
>  {
>  	const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;
> diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> index 972682bb8000..0a3637442ba6 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> @@ -31,7 +31,8 @@ sun8i_dw_hdmi_encoder_helper_funcs = {
>  };
>  
>  static enum drm_mode_status
> -sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
> +sun8i_dw_hdmi_mode_valid_a83t(struct dw_hdmi *hdmi, void *data,
> +			      struct drm_connector *connector,
>  			      const struct drm_display_mode *mode)
>  {
>  	if (mode->clock > 297000)
> @@ -41,7 +42,8 @@ sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
>  }
>  
>  static enum drm_mode_status
> -sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
> +sun8i_dw_hdmi_mode_valid_h6(struct dw_hdmi *hdmi, void *data,
> +			    struct drm_connector *connector,
>  			    const struct drm_display_mode *mode)
>  {
>  	/*
> diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> index 8e64945167e9..8587b8d2590e 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> @@ -176,7 +176,8 @@ struct sun8i_hdmi_phy {
>  };
>  
>  struct sun8i_dw_hdmi_quirks {
> -	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
> +	enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
> +					   struct drm_connector *connector,
>  					   const struct drm_display_mode *mode);
>  	unsigned int set_rate : 1;
>  	unsigned int use_drm_infoframe : 1;
> diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h
> index 0b34a12c4a1c..66a811f75b91 100644
> --- a/include/drm/bridge/dw_hdmi.h
> +++ b/include/drm/bridge/dw_hdmi.h
> @@ -124,13 +124,23 @@ struct dw_hdmi_phy_ops {
>  
>  struct dw_hdmi_plat_data {
>  	struct regmap *regm;
> -	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
> -					   const struct drm_display_mode *mode);
> +
>  	unsigned long input_bus_format;
>  	unsigned long input_bus_encoding;
>  	bool use_drm_infoframe;
>  	bool ycbcr_420_allowed;
>  
> +	/*
> +	 * Private data passed to all the .mode_valid() and .configure_phy()
> +	 * callback functions.
> +	 */
> +	void *priv_data;
> +
> +	/* Platform-specific mode validation (optional). */
> +	enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
> +					   struct drm_connector *connector,
> +					   const struct drm_display_mode *mode);
> +
>  	/* Vendor PHY support */
>  	const struct dw_hdmi_phy_ops *phy_ops;
>  	const char *phy_name;
> 

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>

WARNING: multiple messages have this Message-ID (diff)
From: Neil Armstrong <narmstrong@baylibre.com>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	dri-devel@lists.freedesktop.org
Cc: Jernej Skrabec <jernej.skrabec@siol.net>,
	Jonas Karlman <jonas@kwiboo.se>,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Sandy Huang <hjc@rock-chips.com>,
	linux-renesas-soc@vger.kernel.org,
	Andrzej Hajda <a.hajda@samsung.com>, Chen-Yu Tsai <wens@csie.org>,
	linux-amlogic@lists.infradead.org,
	Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH 11/27] drm: bridge: dw-hdmi: Pass private data pointer to .mode_valid()
Date: Tue, 26 May 2020 11:44:37 +0200	[thread overview]
Message-ID: <ba4aff85-56f1-42b0-8049-ed3ab5eb5559@baylibre.com> (raw)
In-Reply-To: <20200526011505.31884-12-laurent.pinchart+renesas@ideasonboard.com>

On 26/05/2020 03:14, Laurent Pinchart wrote:
> Platform glue drivers for dw_hdmi may need to access device-specific
> data from their .mode_valid() implementation. They currently have no
> clean way to do so, and one driver hacks around it by accessing the
> dev_private data of the drm_device retrieved from the connector.
> 
> Add a priv_data void pointer to the dw_hdmi_plat_data structure, and
> pass it to the .mode_valid() function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c   |  6 ++++--
>  drivers/gpu/drm/imx/dw_hdmi-imx.c           |  6 ++++--
>  drivers/gpu/drm/meson/meson_dw_hdmi.c       |  3 ++-
>  drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c      |  3 ++-
>  drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c |  3 ++-
>  drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c       |  6 ++++--
>  drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h       |  3 ++-
>  include/drm/bridge/dw_hdmi.h                | 14 ++++++++++++--
>  8 files changed, 32 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index b535354150db..2b3f203cf467 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2771,6 +2771,7 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
>  			  const struct drm_display_mode *mode)
>  {
>  	struct dw_hdmi *hdmi = bridge->driver_private;
> +	const struct dw_hdmi_plat_data *pdata = hdmi->plat_data;
>  	struct drm_connector *connector = &hdmi->connector;
>  	enum drm_mode_status mode_status = MODE_OK;
>  
> @@ -2778,8 +2779,9 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
>  	if (mode->flags & DRM_MODE_FLAG_DBLCLK)
>  		return MODE_BAD;
>  
> -	if (hdmi->plat_data->mode_valid)
> -		mode_status = hdmi->plat_data->mode_valid(connector, mode);
> +	if (pdata->mode_valid)
> +		mode_status = pdata->mode_valid(hdmi, pdata->priv_data,
> +						connector, mode);
>  
>  	return mode_status;
>  }
> diff --git a/drivers/gpu/drm/imx/dw_hdmi-imx.c b/drivers/gpu/drm/imx/dw_hdmi-imx.c
> index ba4ca17fd4d8..95aed4666c95 100644
> --- a/drivers/gpu/drm/imx/dw_hdmi-imx.c
> +++ b/drivers/gpu/drm/imx/dw_hdmi-imx.c
> @@ -145,7 +145,8 @@ static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs =
>  };
>  
>  static enum drm_mode_status
> -imx6q_hdmi_mode_valid(struct drm_connector *con,
> +imx6q_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		      struct drm_connector *con,
>  		      const struct drm_display_mode *mode)
>  {
>  	if (mode->clock < 13500)
> @@ -158,7 +159,8 @@ imx6q_hdmi_mode_valid(struct drm_connector *con,
>  }
>  
>  static enum drm_mode_status
> -imx6dl_hdmi_mode_valid(struct drm_connector *con,
> +imx6dl_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		       struct drm_connector *con,
>  		       const struct drm_display_mode *mode)
>  {
>  	if (mode->clock < 13500)
> diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> index 5be963e9db05..5cc311c1b8e0 100644
> --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
> +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> @@ -630,7 +630,8 @@ static irqreturn_t dw_hdmi_top_thread_irq(int irq, void *dev_id)
>  }
>  
>  static enum drm_mode_status
> -dw_hdmi_mode_valid(struct drm_connector *connector,
> +dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		   struct drm_connector *connector,
>  		   const struct drm_display_mode *mode)
>  {
>  	struct meson_drm *priv = connector->dev->dev_private;
> diff --git a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> index 452461dc96f2..4d837a4d302d 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> @@ -38,7 +38,8 @@ static const struct rcar_hdmi_phy_params rcar_hdmi_phy_params[] = {
>  };
>  
>  static enum drm_mode_status
> -rcar_hdmi_mode_valid(struct drm_connector *connector,
> +rcar_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		     struct drm_connector *connector,
>  		     const struct drm_display_mode *mode)
>  {
>  	/*
> diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> index 121aa8a63a76..d08f86783a28 100644
> --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> @@ -220,7 +220,8 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
>  }
>  
>  static enum drm_mode_status
> -dw_hdmi_rockchip_mode_valid(struct drm_connector *connector,
> +dw_hdmi_rockchip_mode_valid(struct dw_hdmi *hdmi, void *data,
> +			    struct drm_connector *connector,
>  			    const struct drm_display_mode *mode)
>  {
>  	const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;
> diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> index 972682bb8000..0a3637442ba6 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> @@ -31,7 +31,8 @@ sun8i_dw_hdmi_encoder_helper_funcs = {
>  };
>  
>  static enum drm_mode_status
> -sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
> +sun8i_dw_hdmi_mode_valid_a83t(struct dw_hdmi *hdmi, void *data,
> +			      struct drm_connector *connector,
>  			      const struct drm_display_mode *mode)
>  {
>  	if (mode->clock > 297000)
> @@ -41,7 +42,8 @@ sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
>  }
>  
>  static enum drm_mode_status
> -sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
> +sun8i_dw_hdmi_mode_valid_h6(struct dw_hdmi *hdmi, void *data,
> +			    struct drm_connector *connector,
>  			    const struct drm_display_mode *mode)
>  {
>  	/*
> diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> index 8e64945167e9..8587b8d2590e 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> @@ -176,7 +176,8 @@ struct sun8i_hdmi_phy {
>  };
>  
>  struct sun8i_dw_hdmi_quirks {
> -	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
> +	enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
> +					   struct drm_connector *connector,
>  					   const struct drm_display_mode *mode);
>  	unsigned int set_rate : 1;
>  	unsigned int use_drm_infoframe : 1;
> diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h
> index 0b34a12c4a1c..66a811f75b91 100644
> --- a/include/drm/bridge/dw_hdmi.h
> +++ b/include/drm/bridge/dw_hdmi.h
> @@ -124,13 +124,23 @@ struct dw_hdmi_phy_ops {
>  
>  struct dw_hdmi_plat_data {
>  	struct regmap *regm;
> -	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
> -					   const struct drm_display_mode *mode);
> +
>  	unsigned long input_bus_format;
>  	unsigned long input_bus_encoding;
>  	bool use_drm_infoframe;
>  	bool ycbcr_420_allowed;
>  
> +	/*
> +	 * Private data passed to all the .mode_valid() and .configure_phy()
> +	 * callback functions.
> +	 */
> +	void *priv_data;
> +
> +	/* Platform-specific mode validation (optional). */
> +	enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
> +					   struct drm_connector *connector,
> +					   const struct drm_display_mode *mode);
> +
>  	/* Vendor PHY support */
>  	const struct dw_hdmi_phy_ops *phy_ops;
>  	const char *phy_name;
> 

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: Neil Armstrong <narmstrong@baylibre.com>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	dri-devel@lists.freedesktop.org
Cc: "Jernej Skrabec" <jernej.skrabec@siol.net>,
	"Heiko Stübner" <heiko@sntech.de>,
	"Jonas Karlman" <jonas@kwiboo.se>,
	"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Sandy Huang" <hjc@rock-chips.com>,
	linux-renesas-soc@vger.kernel.org,
	"Andrzej Hajda" <a.hajda@samsung.com>,
	"Chen-Yu Tsai" <wens@csie.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	linux-amlogic@lists.infradead.org,
	"Sam Ravnborg" <sam@ravnborg.org>
Subject: Re: [PATCH 11/27] drm: bridge: dw-hdmi: Pass private data pointer to .mode_valid()
Date: Tue, 26 May 2020 11:44:37 +0200	[thread overview]
Message-ID: <ba4aff85-56f1-42b0-8049-ed3ab5eb5559@baylibre.com> (raw)
In-Reply-To: <20200526011505.31884-12-laurent.pinchart+renesas@ideasonboard.com>

On 26/05/2020 03:14, Laurent Pinchart wrote:
> Platform glue drivers for dw_hdmi may need to access device-specific
> data from their .mode_valid() implementation. They currently have no
> clean way to do so, and one driver hacks around it by accessing the
> dev_private data of the drm_device retrieved from the connector.
> 
> Add a priv_data void pointer to the dw_hdmi_plat_data structure, and
> pass it to the .mode_valid() function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c   |  6 ++++--
>  drivers/gpu/drm/imx/dw_hdmi-imx.c           |  6 ++++--
>  drivers/gpu/drm/meson/meson_dw_hdmi.c       |  3 ++-
>  drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c      |  3 ++-
>  drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c |  3 ++-
>  drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c       |  6 ++++--
>  drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h       |  3 ++-
>  include/drm/bridge/dw_hdmi.h                | 14 ++++++++++++--
>  8 files changed, 32 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index b535354150db..2b3f203cf467 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2771,6 +2771,7 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
>  			  const struct drm_display_mode *mode)
>  {
>  	struct dw_hdmi *hdmi = bridge->driver_private;
> +	const struct dw_hdmi_plat_data *pdata = hdmi->plat_data;
>  	struct drm_connector *connector = &hdmi->connector;
>  	enum drm_mode_status mode_status = MODE_OK;
>  
> @@ -2778,8 +2779,9 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge,
>  	if (mode->flags & DRM_MODE_FLAG_DBLCLK)
>  		return MODE_BAD;
>  
> -	if (hdmi->plat_data->mode_valid)
> -		mode_status = hdmi->plat_data->mode_valid(connector, mode);
> +	if (pdata->mode_valid)
> +		mode_status = pdata->mode_valid(hdmi, pdata->priv_data,
> +						connector, mode);
>  
>  	return mode_status;
>  }
> diff --git a/drivers/gpu/drm/imx/dw_hdmi-imx.c b/drivers/gpu/drm/imx/dw_hdmi-imx.c
> index ba4ca17fd4d8..95aed4666c95 100644
> --- a/drivers/gpu/drm/imx/dw_hdmi-imx.c
> +++ b/drivers/gpu/drm/imx/dw_hdmi-imx.c
> @@ -145,7 +145,8 @@ static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs =
>  };
>  
>  static enum drm_mode_status
> -imx6q_hdmi_mode_valid(struct drm_connector *con,
> +imx6q_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		      struct drm_connector *con,
>  		      const struct drm_display_mode *mode)
>  {
>  	if (mode->clock < 13500)
> @@ -158,7 +159,8 @@ imx6q_hdmi_mode_valid(struct drm_connector *con,
>  }
>  
>  static enum drm_mode_status
> -imx6dl_hdmi_mode_valid(struct drm_connector *con,
> +imx6dl_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		       struct drm_connector *con,
>  		       const struct drm_display_mode *mode)
>  {
>  	if (mode->clock < 13500)
> diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> index 5be963e9db05..5cc311c1b8e0 100644
> --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
> +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> @@ -630,7 +630,8 @@ static irqreturn_t dw_hdmi_top_thread_irq(int irq, void *dev_id)
>  }
>  
>  static enum drm_mode_status
> -dw_hdmi_mode_valid(struct drm_connector *connector,
> +dw_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		   struct drm_connector *connector,
>  		   const struct drm_display_mode *mode)
>  {
>  	struct meson_drm *priv = connector->dev->dev_private;
> diff --git a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> index 452461dc96f2..4d837a4d302d 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_dw_hdmi.c
> @@ -38,7 +38,8 @@ static const struct rcar_hdmi_phy_params rcar_hdmi_phy_params[] = {
>  };
>  
>  static enum drm_mode_status
> -rcar_hdmi_mode_valid(struct drm_connector *connector,
> +rcar_hdmi_mode_valid(struct dw_hdmi *hdmi, void *data,
> +		     struct drm_connector *connector,
>  		     const struct drm_display_mode *mode)
>  {
>  	/*
> diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> index 121aa8a63a76..d08f86783a28 100644
> --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
> @@ -220,7 +220,8 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
>  }
>  
>  static enum drm_mode_status
> -dw_hdmi_rockchip_mode_valid(struct drm_connector *connector,
> +dw_hdmi_rockchip_mode_valid(struct dw_hdmi *hdmi, void *data,
> +			    struct drm_connector *connector,
>  			    const struct drm_display_mode *mode)
>  {
>  	const struct dw_hdmi_mpll_config *mpll_cfg = rockchip_mpll_cfg;
> diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> index 972682bb8000..0a3637442ba6 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
> @@ -31,7 +31,8 @@ sun8i_dw_hdmi_encoder_helper_funcs = {
>  };
>  
>  static enum drm_mode_status
> -sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
> +sun8i_dw_hdmi_mode_valid_a83t(struct dw_hdmi *hdmi, void *data,
> +			      struct drm_connector *connector,
>  			      const struct drm_display_mode *mode)
>  {
>  	if (mode->clock > 297000)
> @@ -41,7 +42,8 @@ sun8i_dw_hdmi_mode_valid_a83t(struct drm_connector *connector,
>  }
>  
>  static enum drm_mode_status
> -sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector,
> +sun8i_dw_hdmi_mode_valid_h6(struct dw_hdmi *hdmi, void *data,
> +			    struct drm_connector *connector,
>  			    const struct drm_display_mode *mode)
>  {
>  	/*
> diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> index 8e64945167e9..8587b8d2590e 100644
> --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
> @@ -176,7 +176,8 @@ struct sun8i_hdmi_phy {
>  };
>  
>  struct sun8i_dw_hdmi_quirks {
> -	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
> +	enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
> +					   struct drm_connector *connector,
>  					   const struct drm_display_mode *mode);
>  	unsigned int set_rate : 1;
>  	unsigned int use_drm_infoframe : 1;
> diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h
> index 0b34a12c4a1c..66a811f75b91 100644
> --- a/include/drm/bridge/dw_hdmi.h
> +++ b/include/drm/bridge/dw_hdmi.h
> @@ -124,13 +124,23 @@ struct dw_hdmi_phy_ops {
>  
>  struct dw_hdmi_plat_data {
>  	struct regmap *regm;
> -	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
> -					   const struct drm_display_mode *mode);
> +
>  	unsigned long input_bus_format;
>  	unsigned long input_bus_encoding;
>  	bool use_drm_infoframe;
>  	bool ycbcr_420_allowed;
>  
> +	/*
> +	 * Private data passed to all the .mode_valid() and .configure_phy()
> +	 * callback functions.
> +	 */
> +	void *priv_data;
> +
> +	/* Platform-specific mode validation (optional). */
> +	enum drm_mode_status (*mode_valid)(struct dw_hdmi *hdmi, void *data,
> +					   struct drm_connector *connector,
> +					   const struct drm_display_mode *mode);
> +
>  	/* Vendor PHY support */
>  	const struct dw_hdmi_phy_ops *phy_ops;
>  	const char *phy_name;
> 

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2020-05-26  9:44 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26  1:14 [PATCH 00/27] Converter R-Car DU to the DRM bridge connector helper Laurent Pinchart
2020-05-26  1:14 ` Laurent Pinchart
2020-05-26  1:14 ` [PATCH 01/27] drm: bridge: adv7511: Split EDID read to a separate function Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14 ` [PATCH 02/27] drm: bridge: adv7511: Split connector creation " Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14 ` [PATCH 03/27] drm: bridge: adv7511: Implement bridge connector operations Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-06-21  8:25   ` Sam Ravnborg
2020-06-21  8:25     ` Sam Ravnborg
2020-05-26  1:14 ` [PATCH 04/27] drm: bridge: adv7511: Make connector creation optional Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14 ` [PATCH 05/27] drm: bridge: Return NULL on error from drm_bridge_get_edid() Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-06-21  8:26   ` Sam Ravnborg
2020-06-21  8:26     ` Sam Ravnborg
2020-05-26  1:14 ` [PATCH 06/27] drm: bridge: simple-bridge: Delegate operations to next bridge Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14 ` [PATCH 07/27] drm: bridge: simple-bridge: Make connector creation optional Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14 ` [PATCH 08/27] drm: rcar-du: lvds: Convert to DRM panel bridge helper Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14 ` [PATCH 09/27] drm: edid: Constify connector argument to infoframe functions Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-06-21  8:27   ` Sam Ravnborg
2020-06-21  8:27     ` Sam Ravnborg
2020-05-26  1:14 ` [PATCH 10/27] drm: bridge: Pass drm_display_info to drm_bridge_funcs .mode_valid() Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26 12:51   ` Neil Armstrong
2020-05-26 12:51     ` Neil Armstrong
2020-05-26 12:59   ` Boris Brezillon
2020-05-26 12:59     ` Boris Brezillon
2020-05-26 14:05   ` Guido Günther
2020-05-26 14:05     ` Guido Günther
2020-05-26  1:14 ` [PATCH 11/27] drm: bridge: dw-hdmi: Pass private data pointer to .mode_valid() Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:44   ` Neil Armstrong [this message]
2020-05-26  9:44     ` Neil Armstrong
2020-05-26  9:44     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 12/27] drm: bridge: dw-hdmi: Pass private data pointer to .configure_phy() Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:45   ` Neil Armstrong
2020-05-26  9:45     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 13/27] drm: bridge: dw-hdmi: Remove unused field from dw_hdmi_plat_data Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:45   ` Neil Armstrong
2020-05-26  9:45     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 14/27] drm: meson: dw-hdmi: Use dw_hdmi context to replace hack Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26 12:32   ` Neil Armstrong
2020-05-26 12:32     ` Neil Armstrong
2020-05-26 12:32     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 15/27] drm: bridge: dw-hdmi: Pass drm_display_info to .mode_valid() Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:46   ` Neil Armstrong
2020-05-26  9:46     ` Neil Armstrong
2020-05-26  9:46     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 16/27] drm: bridge: dw-hdmi: Constify mode argument to dw_hdmi_phy_ops .init() Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:46   ` Neil Armstrong
2020-05-26  9:46     ` Neil Armstrong
2020-05-26  9:46     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 17/27] drm: bridge: dw-hdmi: Constify mode argument to internal functions Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:46   ` Neil Armstrong
2020-05-26  9:46     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 18/27] drm: bridge: dw-hdmi: Pass drm_display_info to dw_hdmi_support_scdc() Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:48   ` Neil Armstrong
2020-05-26  9:48     ` Neil Armstrong
2020-05-26  9:48     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 19/27] drm: bridge: dw-hdmi: Split connector creation to a separate function Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26  9:49   ` Neil Armstrong
2020-05-26  9:49     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 20/27] drm: bridge: dw-hdmi: Store current connector in struct dw_hdmi Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26 12:29   ` Neil Armstrong
2020-05-26 12:29     ` Neil Armstrong
2020-05-26  1:14 ` [PATCH 21/27] drm: bridge: dw-hdmi: Pass drm_connector to internal functions as needed Laurent Pinchart
2020-05-26  1:14   ` Laurent Pinchart
2020-05-26 12:29   ` Neil Armstrong
2020-05-26 12:29     ` Neil Armstrong
2020-05-26  1:15 ` [PATCH 22/27] drm: bridge: dw-hdmi: Make connector creation optional Laurent Pinchart
2020-05-26  1:15   ` Laurent Pinchart
2020-05-26 12:35   ` Neil Armstrong
2020-05-26 12:35     ` Neil Armstrong
2020-06-07  1:19     ` Laurent Pinchart
2020-06-07  1:19       ` Laurent Pinchart
2020-05-26  1:15 ` [PATCH 23/27] drm: bridge: dw-hdmi: Attach to next bridge if available Laurent Pinchart
2020-05-26  1:15   ` Laurent Pinchart
2020-05-26 12:50   ` Neil Armstrong
2020-05-26 12:50     ` Neil Armstrong
2020-05-26 14:23     ` Jonas Karlman
2020-05-26 14:23       ` Jonas Karlman
2020-06-07  1:24       ` Laurent Pinchart
2020-06-07  1:24         ` Laurent Pinchart
2020-06-07  1:22     ` Laurent Pinchart
2020-06-07  1:22       ` Laurent Pinchart
2020-05-26  1:15 ` [PATCH 24/27] drm: rcar-du: dw-hdmi: Set output port number Laurent Pinchart
2020-05-26  1:15   ` Laurent Pinchart
2020-05-26  1:15 ` [PATCH 25/27] drm: rcar-du: Fix error handling in rcar_du_encoder_init() Laurent Pinchart
2020-05-26  1:15   ` Laurent Pinchart
2020-05-26  1:15 ` [PATCH 26/27] drm: rcar-du: Use drm_bridge_connector_init() helper Laurent Pinchart
2020-05-26  1:15   ` Laurent Pinchart
2020-05-26  1:15 ` [PATCH 27/27] drm: Add default modes for connectors in unknown state Laurent Pinchart
2020-05-26  1:15   ` Laurent Pinchart
2020-06-21  8:40   ` Sam Ravnborg
2020-06-21  8:40     ` Sam Ravnborg
2020-06-24  1:12     ` Laurent Pinchart
2020-06-24  1:12       ` Laurent Pinchart
2020-06-24  7:23       ` Daniel Vetter
2020-06-24  7:23         ` Daniel Vetter
2020-06-24 15:24         ` Alex Deucher
2020-06-24 15:24           ` Alex Deucher
2020-06-24 19:31           ` Daniel Vetter
2020-06-24 19:31             ` Daniel Vetter
2020-06-24 19:40             ` Alex Deucher
2020-06-24 19:40               ` Alex Deucher
2020-06-25  7:56               ` Daniel Vetter
2020-06-25  7:56                 ` Daniel Vetter
2020-06-25  7:57                 ` Daniel Vetter
2020-06-25  7:57                   ` Daniel Vetter
2020-06-25 10:31                   ` Pekka Paalanen
2020-06-25 10:31                     ` Pekka Paalanen
2020-06-25 10:44                     ` Daniel Vetter
2020-06-25 10:44                       ` Daniel Vetter
2020-06-26  8:59                       ` Pekka Paalanen
2020-06-26  8:59                         ` Pekka Paalanen
2020-06-26  9:25                         ` Daniel Stone
2020-06-26  9:25                           ` Daniel Stone
2020-06-26 13:35                           ` Daniel Vetter
2020-06-26 13:35                             ` Daniel Vetter
2020-06-24 22:47         ` Laurent Pinchart
2020-06-24 22:47           ` Laurent Pinchart
2020-06-23 18:55 ` [PATCH 00/27] Converter R-Car DU to the DRM bridge connector helper Sam Ravnborg
2020-06-23 18:55   ` Sam Ravnborg
2020-06-25  8:48   ` Liu Ying
2020-06-25  8:48     ` Liu Ying
2020-06-27 19:55     ` Sam Ravnborg
2020-06-27 19:55       ` Sam Ravnborg
2020-06-28  8:28       ` Laurent Pinchart
2020-06-28  8:28         ` Laurent Pinchart

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=ba4aff85-56f1-42b0-8049-ed3ab5eb5559@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=a.hajda@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=jernej.skrabec@siol.net \
    --cc=jonas@kwiboo.se \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mripard@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=sam@ravnborg.org \
    --cc=wens@csie.org \
    /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.