diff mbox series

[v2,13/13] drm/bridge: lt9611: properly program the dual host mode

Message ID 20230108165656.136871-14-dmitry.baryshkov@linaro.org (mailing list archive)
State Superseded
Headers show
Series drm/bridge: lt9611: several fixes and improvements | expand

Commit Message

Dmitry Baryshkov Jan. 8, 2023, 4:56 p.m. UTC
If the bridge is connected using both DSI ports, the driver should use
both of them all the time. Correct programming sequence to always use
dual-port mode if both dsi0 and dsi1 are connected.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/gpu/drm/bridge/lontium-lt9611.c | 28 ++++++++++++-------------
 1 file changed, 13 insertions(+), 15 deletions(-)

Comments

Neil Armstrong Jan. 12, 2023, 1:51 p.m. UTC | #1
On 08/01/2023 17:56, Dmitry Baryshkov wrote:
> If the bridge is connected using both DSI ports, the driver should use
> both of them all the time. Correct programming sequence to always use
> dual-port mode if both dsi0 and dsi1 are connected.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>   drivers/gpu/drm/bridge/lontium-lt9611.c | 28 ++++++++++++-------------
>   1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/bridge/lontium-lt9611.c
> index df9f015aa3a0..561da6bd2698 100644
> --- a/drivers/gpu/drm/bridge/lontium-lt9611.c
> +++ b/drivers/gpu/drm/bridge/lontium-lt9611.c
> @@ -118,7 +118,7 @@ static int lt9611_mipi_input_digital(struct lt9611 *lt9611,
>   		{ 0x8306, 0x0a },
>   	};
>   
> -	if (mode->hdisplay == 3840)
> +	if (lt9611->dsi1_node)
>   		reg_cfg[1].def = 0x03;
>   
>   	return regmap_multi_reg_write(lt9611->regmap, reg_cfg, ARRAY_SIZE(reg_cfg));
> @@ -191,16 +191,6 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod
>   		{ 0x832d, 0x38 },
>   		{ 0x8331, 0x08 },
>   	};
> -	const struct reg_sequence reg_cfg2[] = {
> -		{ 0x830b, 0x03 },
> -		{ 0x830c, 0xd0 },
> -		{ 0x8348, 0x03 },
> -		{ 0x8349, 0xe0 },
> -		{ 0x8324, 0x72 },
> -		{ 0x8325, 0x00 },
> -		{ 0x832a, 0x01 },
> -		{ 0x834a, 0x10 },
> -	};
>   	u8 pol = 0x10;
>   
>   	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
> @@ -209,10 +199,18 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod
>   		pol |= 0x1;
>   	regmap_write(lt9611->regmap, 0x831d, pol);
>   
> -	if (mode->hdisplay == 3840)
> -		regmap_multi_reg_write(lt9611->regmap, reg_cfg2, ARRAY_SIZE(reg_cfg2));
> -	else
> -		regmap_multi_reg_write(lt9611->regmap, reg_cfg, ARRAY_SIZE(reg_cfg));
> +	regmap_multi_reg_write(lt9611->regmap, reg_cfg, ARRAY_SIZE(reg_cfg));
> +	if (lt9611->dsi1_node) {
> +		unsigned int hact = mode->hdisplay;
> +
> +		hact >>= 2;
> +		hact += 0x50;
> +		hact = min(hact, 0x3e0U);
> +		regmap_write(lt9611->regmap, 0x830b, hact / 256);
> +		regmap_write(lt9611->regmap, 0x830c, hact % 256);
> +		regmap_write(lt9611->regmap, 0x8348, hact / 256);
> +		regmap_write(lt9611->regmap, 0x8349, hact % 256);
> +	}
>   
>   	regmap_write(lt9611->regmap, 0x8326, pcr_m);
>   

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/bridge/lontium-lt9611.c
index df9f015aa3a0..561da6bd2698 100644
--- a/drivers/gpu/drm/bridge/lontium-lt9611.c
+++ b/drivers/gpu/drm/bridge/lontium-lt9611.c
@@ -118,7 +118,7 @@  static int lt9611_mipi_input_digital(struct lt9611 *lt9611,
 		{ 0x8306, 0x0a },
 	};
 
-	if (mode->hdisplay == 3840)
+	if (lt9611->dsi1_node)
 		reg_cfg[1].def = 0x03;
 
 	return regmap_multi_reg_write(lt9611->regmap, reg_cfg, ARRAY_SIZE(reg_cfg));
@@ -191,16 +191,6 @@  static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod
 		{ 0x832d, 0x38 },
 		{ 0x8331, 0x08 },
 	};
-	const struct reg_sequence reg_cfg2[] = {
-		{ 0x830b, 0x03 },
-		{ 0x830c, 0xd0 },
-		{ 0x8348, 0x03 },
-		{ 0x8349, 0xe0 },
-		{ 0x8324, 0x72 },
-		{ 0x8325, 0x00 },
-		{ 0x832a, 0x01 },
-		{ 0x834a, 0x10 },
-	};
 	u8 pol = 0x10;
 
 	if (mode->flags & DRM_MODE_FLAG_NHSYNC)
@@ -209,10 +199,18 @@  static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod
 		pol |= 0x1;
 	regmap_write(lt9611->regmap, 0x831d, pol);
 
-	if (mode->hdisplay == 3840)
-		regmap_multi_reg_write(lt9611->regmap, reg_cfg2, ARRAY_SIZE(reg_cfg2));
-	else
-		regmap_multi_reg_write(lt9611->regmap, reg_cfg, ARRAY_SIZE(reg_cfg));
+	regmap_multi_reg_write(lt9611->regmap, reg_cfg, ARRAY_SIZE(reg_cfg));
+	if (lt9611->dsi1_node) {
+		unsigned int hact = mode->hdisplay;
+
+		hact >>= 2;
+		hact += 0x50;
+		hact = min(hact, 0x3e0U);
+		regmap_write(lt9611->regmap, 0x830b, hact / 256);
+		regmap_write(lt9611->regmap, 0x830c, hact % 256);
+		regmap_write(lt9611->regmap, 0x8348, hact / 256);
+		regmap_write(lt9611->regmap, 0x8349, hact % 256);
+	}
 
 	regmap_write(lt9611->regmap, 0x8326, pcr_m);