diff mbox series

drm: mxsfb: Obtain bus flags from bridge state

Message ID 20220406092929.17498-1-marex@denx.de (mailing list archive)
State New, archived
Headers show
Series drm: mxsfb: Obtain bus flags from bridge state | expand

Commit Message

Marek Vasut April 6, 2022, 9:29 a.m. UTC
In case the MXSFB is connected to a bridge, attempt to obtain bus flags
from that bridge state too. The bus flags may specify e.g. the DE signal
polarity.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Robby Cai <robby.cai@nxp.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Stefan Agner <stefan@agner.ch>
---
 drivers/gpu/drm/mxsfb/mxsfb_kms.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Alexander Stein April 6, 2022, 3:42 p.m. UTC | #1
Am Mittwoch, 6. April 2022, 11:29:29 CEST schrieb Marek Vasut:
> In case the MXSFB is connected to a bridge, attempt to obtain bus flags
> from that bridge state too. The bus flags may specify e.g. the DE signal
> polarity.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Alexander Stein <alexander.stein@ew.tq-group.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Peng Fan <peng.fan@nxp.com>
> Cc: Robby Cai <robby.cai@nxp.com>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Stefan Agner <stefan@agner.ch>
> ---
>  drivers/gpu/drm/mxsfb/mxsfb_kms.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 4baa3db1f3d10..c7f14ef1edc25
> 100644
> --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
> @@ -298,6 +298,7 @@ static int mxsfb_reset_block(struct mxsfb_drm_private
> *mxsfb) }
> 
>  static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
> +				     struct drm_bridge_state 
*bridge_state,
>  				     const u32 bus_format)
>  {
>  	struct drm_device *drm = mxsfb->crtc.dev;
> @@ -307,6 +308,8 @@ static void mxsfb_crtc_mode_set_nofb(struct
> mxsfb_drm_private *mxsfb,
> 
>  	if (mxsfb->bridge && mxsfb->bridge->timings)
>  		bus_flags = mxsfb->bridge->timings->input_bus_flags;
> +	else if (bridge_state)
> +		bus_flags = bridge_state->input_bus_cfg.flags;
> 
>  	DRM_DEV_DEBUG_DRIVER(drm->dev, "Pixel clock: %dkHz (actual: %dkHz)
\n",
>  			     m->crtc_clock,
> @@ -365,7 +368,7 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc
> *crtc, {
>  	struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
>  	struct drm_display_mode *m = &mxsfb->crtc.state->adjusted_mode;
> -	struct drm_bridge_state *bridge_state;
> +	struct drm_bridge_state *bridge_state = NULL;
>  	struct drm_device *drm = mxsfb->drm;
>  	u32 bus_format = 0;
> 
> @@ -399,7 +402,7 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc
> *crtc,
> 
>  	pm_runtime_get_sync(drm->dev);
> 
> -	mxsfb_crtc_mode_set_nofb(mxsfb, bus_format);
> +	mxsfb_crtc_mode_set_nofb(mxsfb, bridge_state, bus_format);
> 
>  	/* Write cur_buf as well to avoid an initial corrupt frame */
>  	mxsfb_update_buffer(mxsfb, crtc->primary, true);

I only have boards with an lvds-encoder bridge connected, which provides the 
timings, so I can't test it. Otherwise LGTM.

Acked-by: Alexander Stein <alexander.stein@ew.tq-group.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
index 4baa3db1f3d10..c7f14ef1edc25 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c
@@ -298,6 +298,7 @@  static int mxsfb_reset_block(struct mxsfb_drm_private *mxsfb)
 }
 
 static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
+				     struct drm_bridge_state *bridge_state,
 				     const u32 bus_format)
 {
 	struct drm_device *drm = mxsfb->crtc.dev;
@@ -307,6 +308,8 @@  static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb,
 
 	if (mxsfb->bridge && mxsfb->bridge->timings)
 		bus_flags = mxsfb->bridge->timings->input_bus_flags;
+	else if (bridge_state)
+		bus_flags = bridge_state->input_bus_cfg.flags;
 
 	DRM_DEV_DEBUG_DRIVER(drm->dev, "Pixel clock: %dkHz (actual: %dkHz)\n",
 			     m->crtc_clock,
@@ -365,7 +368,7 @@  static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
 {
 	struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(crtc->dev);
 	struct drm_display_mode *m = &mxsfb->crtc.state->adjusted_mode;
-	struct drm_bridge_state *bridge_state;
+	struct drm_bridge_state *bridge_state = NULL;
 	struct drm_device *drm = mxsfb->drm;
 	u32 bus_format = 0;
 
@@ -399,7 +402,7 @@  static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc,
 
 	pm_runtime_get_sync(drm->dev);
 
-	mxsfb_crtc_mode_set_nofb(mxsfb, bus_format);
+	mxsfb_crtc_mode_set_nofb(mxsfb, bridge_state, bus_format);
 
 	/* Write cur_buf as well to avoid an initial corrupt frame */
 	mxsfb_update_buffer(mxsfb, crtc->primary, true);