2022-09-22 13:12:20

by Philippe Schenker

[permalink] [raw]
Subject: [PATCH 0/4] drm/bridge: lt8912b: Fix corrupt display output due to wrong bridge config

From: Philippe Schenker <[email protected]>

This patch-set fixes the lt8912b driver that currently does not take
care whether or not the attached display has postiive or negative syncs
and or reports on EDID if it needs HDMI mode or DVI.

This series addresses also an issue where the LVDS startup sequence was
written to the wrong I2C address (the lt8912 has three). This caused
writing into reserved registers and causing an unstable HDMI picture
that manifests itself only sometimes and depending on the monitor with a
flickering and a repeating of going black and coming up again. While at
it move also some sensible comments to the sequence.


Francesco Dolcini (2):
drm/bridge: lt8912b: fix corrupted image output
drm/bridge: lt8912b: clarify lvds output status

Philippe Schenker (2):
drm/bridge: lt8912b: add vsync hsync
drm/bridge: lt8912b: set hdmi or dvi mode

drivers/gpu/drm/bridge/lontium-lt8912b.c | 39 +++++++++++++++++-------
1 file changed, 28 insertions(+), 11 deletions(-)

--
2.37.3


2022-09-22 13:15:15

by Philippe Schenker

[permalink] [raw]
Subject: [PATCH 2/4] drm/bridge: lt8912b: set hdmi or dvi mode

From: Philippe Schenker <[email protected]>

The Lontium LT8912 does have a setting for DVI or HDMI. This patch reads
from EDID what the display needs and sets it accordingly.

Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
Signed-off-by: Philippe Schenker <[email protected]>
---

drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
index 0fd3472e767c..6a4bb7422176 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
@@ -323,6 +323,8 @@ static int lt8912_video_setup(struct lt8912 *lt)
vsync_activehigh ? BIT(0) : 0);
ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1),
hsync_activehigh ? BIT(1) : 0);
+ ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xb2, BIT(0),
+ lt->connector.display_info.is_hdmi ? BIT(0) : 0);

return ret;
}
--
2.37.3

2022-09-22 13:31:25

by Philippe Schenker

[permalink] [raw]
Subject: [PATCH 1/4] drm/bridge: lt8912b: add vsync hsync

From: Philippe Schenker <[email protected]>

Currently the bridge driver does not take care whether or not the display
needs positive/negative vertical/horizontal syncs. Pass these two flags
to the bridge from the EDID that was read out from the display.

Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
Signed-off-by: Philippe Schenker <[email protected]>

---

drivers/gpu/drm/bridge/lontium-lt8912b.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
index 28bad30dc4e5..0fd3472e767c 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
@@ -268,7 +268,7 @@ static int lt8912_video_setup(struct lt8912 *lt)
u32 hactive, h_total, hpw, hfp, hbp;
u32 vactive, v_total, vpw, vfp, vbp;
u8 settle = 0x08;
- int ret;
+ int ret, hsync_activehigh, vsync_activehigh;

if (!lt)
return -EINVAL;
@@ -278,12 +278,14 @@ static int lt8912_video_setup(struct lt8912 *lt)
hpw = lt->mode.hsync_len;
hbp = lt->mode.hback_porch;
h_total = hactive + hfp + hpw + hbp;
+ hsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_HSYNC_HIGH;

vactive = lt->mode.vactive;
vfp = lt->mode.vfront_porch;
vpw = lt->mode.vsync_len;
vbp = lt->mode.vback_porch;
v_total = vactive + vfp + vpw + vbp;
+ vsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH;

if (vactive <= 600)
settle = 0x04;
@@ -317,6 +319,11 @@ static int lt8912_video_setup(struct lt8912 *lt)
ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3e, hfp & 0xff);
ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3f, hfp >> 8);

+ ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(0),
+ vsync_activehigh ? BIT(0) : 0);
+ ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1),
+ hsync_activehigh ? BIT(1) : 0);
+
return ret;
}

--
2.37.3

2022-09-22 13:36:58

by Philippe Schenker

[permalink] [raw]
Subject: [PATCH 3/4] drm/bridge: lt8912b: fix corrupted image output

From: Francesco Dolcini <[email protected]>

Correct I2C address for the register list in lt8912_write_lvds_config(),
these registers are on the first I2C address (0x48), the current
function is just writing garbage to the wrong registers and this creates
multiple issues (artifacts and output completely corrupted) on some HDMI
displays.

Correct I2C address comes from Lontium documentation and it is the one
used on other out-of-tree LT8912B drivers [1].

[1] https://github.com/boundarydevices/linux/blob/boundary-imx_5.10.x_2.0.0/drivers/video/lt8912.c#L296

Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
Signed-off-by: Francesco Dolcini <[email protected]>
Signed-off-by: Philippe Schenker <[email protected]>
---

drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
index 6a4bb7422176..5968f4af190b 100644
--- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
+++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
@@ -188,7 +188,7 @@ static int lt8912_write_lvds_config(struct lt8912 *lt)
{0x03, 0xff},
};

- return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(seq));
+ return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq));
};

static inline struct lt8912 *bridge_to_lt8912(struct drm_bridge *b)
--
2.37.3

2022-09-22 18:41:59

by Adrien Grassein

[permalink] [raw]
Subject: Re: [PATCH 2/4] drm/bridge: lt8912b: set hdmi or dvi mode

Le jeu. 22 sept. 2022 à 14:43, Philippe Schenker <[email protected]> a écrit :
>
> From: Philippe Schenker <[email protected]>
>
> The Lontium LT8912 does have a setting for DVI or HDMI. This patch reads
> from EDID what the display needs and sets it accordingly.
>
> Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
> Signed-off-by: Philippe Schenker <[email protected]>
Acked-by: Adrien Grassein <[email protected]>
> ---
>
> drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> index 0fd3472e767c..6a4bb7422176 100644
> --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
> +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> @@ -323,6 +323,8 @@ static int lt8912_video_setup(struct lt8912 *lt)
> vsync_activehigh ? BIT(0) : 0);
> ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1),
> hsync_activehigh ? BIT(1) : 0);
> + ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xb2, BIT(0),
> + lt->connector.display_info.is_hdmi ? BIT(0) : 0);
>
> return ret;
> }
> --
> 2.37.3
>

2022-09-22 18:49:56

by Adrien Grassein

[permalink] [raw]
Subject: Re: [PATCH 3/4] drm/bridge: lt8912b: fix corrupted image output

Le jeu. 22 sept. 2022 à 14:43, Philippe Schenker <[email protected]> a écrit :
>
> From: Francesco Dolcini <[email protected]>
>
> Correct I2C address for the register list in lt8912_write_lvds_config(),
> these registers are on the first I2C address (0x48), the current
> function is just writing garbage to the wrong registers and this creates
> multiple issues (artifacts and output completely corrupted) on some HDMI
> displays.
>
> Correct I2C address comes from Lontium documentation and it is the one
> used on other out-of-tree LT8912B drivers [1].
>
> [1] https://github.com/boundarydevices/linux/blob/boundary-imx_5.10.x_2.0.0/drivers/video/lt8912.c#L296
>
> Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
> Signed-off-by: Francesco Dolcini <[email protected]>
> Signed-off-by: Philippe Schenker <[email protected]>
Acked-by: Adrien Grassein <[email protected]>
> ---
>
> drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> index 6a4bb7422176..5968f4af190b 100644
> --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
> +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> @@ -188,7 +188,7 @@ static int lt8912_write_lvds_config(struct lt8912 *lt)
> {0x03, 0xff},
> };
>
> - return regmap_multi_reg_write(lt->regmap[I2C_CEC_DSI], seq, ARRAY_SIZE(seq));
> + return regmap_multi_reg_write(lt->regmap[I2C_MAIN], seq, ARRAY_SIZE(seq));
> };
>
> static inline struct lt8912 *bridge_to_lt8912(struct drm_bridge *b)
> --
> 2.37.3
>

2022-09-22 19:00:54

by Adrien Grassein

[permalink] [raw]
Subject: Re: [PATCH 1/4] drm/bridge: lt8912b: add vsync hsync

Le jeu. 22 sept. 2022 à 14:43, Philippe Schenker <[email protected]> a écrit :
>
> From: Philippe Schenker <[email protected]>
>
> Currently the bridge driver does not take care whether or not the display
> needs positive/negative vertical/horizontal syncs. Pass these two flags
> to the bridge from the EDID that was read out from the display.
>
> Fixes: 30e2ae943c26 ("drm/bridge: Introduce LT8912B DSI to HDMI bridge")
> Signed-off-by: Philippe Schenker <[email protected]>
Acked-by: Adrien Grassein <[email protected]>
>
> ---
>
> drivers/gpu/drm/bridge/lontium-lt8912b.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/bridge/lontium-lt8912b.c b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> index 28bad30dc4e5..0fd3472e767c 100644
> --- a/drivers/gpu/drm/bridge/lontium-lt8912b.c
> +++ b/drivers/gpu/drm/bridge/lontium-lt8912b.c
> @@ -268,7 +268,7 @@ static int lt8912_video_setup(struct lt8912 *lt)
> u32 hactive, h_total, hpw, hfp, hbp;
> u32 vactive, v_total, vpw, vfp, vbp;
> u8 settle = 0x08;
> - int ret;
> + int ret, hsync_activehigh, vsync_activehigh;
>
> if (!lt)
> return -EINVAL;
> @@ -278,12 +278,14 @@ static int lt8912_video_setup(struct lt8912 *lt)
> hpw = lt->mode.hsync_len;
> hbp = lt->mode.hback_porch;
> h_total = hactive + hfp + hpw + hbp;
> + hsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_HSYNC_HIGH;
>
> vactive = lt->mode.vactive;
> vfp = lt->mode.vfront_porch;
> vpw = lt->mode.vsync_len;
> vbp = lt->mode.vback_porch;
> v_total = vactive + vfp + vpw + vbp;
> + vsync_activehigh = lt->mode.flags & DISPLAY_FLAGS_VSYNC_HIGH;
>
> if (vactive <= 600)
> settle = 0x04;
> @@ -317,6 +319,11 @@ static int lt8912_video_setup(struct lt8912 *lt)
> ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3e, hfp & 0xff);
> ret |= regmap_write(lt->regmap[I2C_CEC_DSI], 0x3f, hfp >> 8);
>
> + ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(0),
> + vsync_activehigh ? BIT(0) : 0);
> + ret |= regmap_update_bits(lt->regmap[I2C_MAIN], 0xab, BIT(1),
> + hsync_activehigh ? BIT(1) : 0);
> +
> return ret;
> }
>
> --
> 2.37.3
>

2022-09-23 09:28:06

by Neil Armstrong

[permalink] [raw]
Subject: Re: (subset) [PATCH 0/4] drm/bridge: lt8912b: Fix corrupt display output due to wrong bridge config

Hi,

On Thu, 22 Sep 2022 14:43:02 +0200, Philippe Schenker wrote:
> From: Philippe Schenker <[email protected]>
>
> This patch-set fixes the lt8912b driver that currently does not take
> care whether or not the attached display has postiive or negative syncs
> and or reports on EDID if it needs HDMI mode or DVI.
>
> This series addresses also an issue where the LVDS startup sequence was
> written to the wrong I2C address (the lt8912 has three). This caused
> writing into reserved registers and causing an unstable HDMI picture
> that manifests itself only sometimes and depending on the monitor with a
> flickering and a repeating of going black and coming up again. While at
> it move also some sensible comments to the sequence.
>
> [...]

Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-fixes)

[1/4] drm/bridge: lt8912b: add vsync hsync
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=da73a94fa282f78d485bd0aab36c8ac15b6f792c
[2/4] drm/bridge: lt8912b: set hdmi or dvi mode
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=6dd1de12e1243f2013e4fabf31e99e63b1a860d0
[3/4] drm/bridge: lt8912b: fix corrupted image output
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=051ad2788d35ca07aec8402542e5d38429f2426a

--
Neil

2022-09-23 10:01:26

by Neil Armstrong

[permalink] [raw]
Subject: Re: (subset) [PATCH 0/4] drm/bridge: lt8912b: Fix corrupt display output due to wrong bridge config

Hi,

On Thu, 22 Sep 2022 14:43:02 +0200, Philippe Schenker wrote:
> From: Philippe Schenker <[email protected]>
>
> This patch-set fixes the lt8912b driver that currently does not take
> care whether or not the attached display has postiive or negative syncs
> and or reports on EDID if it needs HDMI mode or DVI.
>
> This series addresses also an issue where the LVDS startup sequence was
> written to the wrong I2C address (the lt8912 has three). This caused
> writing into reserved registers and causing an unstable HDMI picture
> that manifests itself only sometimes and depending on the monitor with a
> flickering and a repeating of going black and coming up again. While at
> it move also some sensible comments to the sequence.
>
> [...]

Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-next)

[4/4] drm/bridge: lt8912b: clarify lvds output status
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=fc44f3636a4db6544fd1532280e8adcd1ef13ba2

--
Neil

2022-09-28 15:42:39

by Robert Foss

[permalink] [raw]
Subject: Re: [PATCH 0/4] drm/bridge: lt8912b: Fix corrupt display output due to wrong bridge config

On Thu, 22 Sept 2022 at 14:43, Philippe Schenker <[email protected]> wrote:
>
> From: Philippe Schenker <[email protected]>
>
> This patch-set fixes the lt8912b driver that currently does not take
> care whether or not the attached display has postiive or negative syncs
> and or reports on EDID if it needs HDMI mode or DVI.
>
> This series addresses also an issue where the LVDS startup sequence was
> written to the wrong I2C address (the lt8912 has three). This caused
> writing into reserved registers and causing an unstable HDMI picture
> that manifests itself only sometimes and depending on the monitor with a
> flickering and a repeating of going black and coming up again. While at
> it move also some sensible comments to the sequence.
>
>
> Francesco Dolcini (2):
> drm/bridge: lt8912b: fix corrupted image output
> drm/bridge: lt8912b: clarify lvds output status
>
> Philippe Schenker (2):
> drm/bridge: lt8912b: add vsync hsync
> drm/bridge: lt8912b: set hdmi or dvi mode
>
> drivers/gpu/drm/bridge/lontium-lt8912b.c | 39 +++++++++++++++++-------
> 1 file changed, 28 insertions(+), 11 deletions(-)
>
> --
> 2.37.3
>

Thanks for the series & the reviews.

Applied to drm-misc-next.