diff mbox series

T113 TCON Top tinting troubleshooting

Message ID Zn8GVkpwXwhaUFno@titan (mailing list archive)
State New
Headers show
Series T113 TCON Top tinting troubleshooting | expand

Commit Message

John Watts June 28, 2024, 6:52 p.m. UTC
Hello,

On the T113 (and most likely the D1) sometimes the RGB LCD output has strange
artifacts such as:

- A blue tint
- A mostly opaque green tint
- A red tint
- A pink tint

The actual tint seems to differ between boards or chips, and has some
probability of showing up that can range from 50% to 90%.

After a week or so of troubleshooting I've managed to figure out what's
happening here, and I'm not too sure how to fix it.

It appears that the TCON Top on this chip can't mux both mixers to a shared
output. The R40 (and H6?) allows this and prioritizes the DE0 when muxing, but
on the T113 it seems to cause graphical artifacts. Disabling DE1 in the
device tree can help but doesn't solve the problem entirely.

Here's a change that tests this behaviour, it sets DE1 to output to TVE0. DE0
then outputs to LCD0 as usual. I would appreciate if anyone with this issue can
test the above workaround on their boards.
There was a previous discussion here:
https://groups.google.com/g/linux-sunxi/c/HxDBpY5HbbQ/m/mX2O2OYlCwAJ

---8<--- CUT HERE ---8<---


---8<--- CUT HERE ---8<---

The sunxi display code works around this issue by ensuring DE0 and DE1 never
map to the same output: If you have DE0 set to TVE0 and DE1 set to LCD0,
then tell it to set DE0 to LCD0, it will silently swap TVE0 on to DE1. 

I'm probably going to send a patch that copies this behaviour as it
should just work, but I'd be interested to see if there's anything I'm
missing.

John.

Comments

John Watts June 29, 2024, 2:12 a.m. UTC | #1
On Sat, Jun 29, 2024 at 01:49:53AM +0200, Jakob L wrote:
> Hi John,
> 
> good find! This seems to fix it on my DSI implementation. Every of the
> recent boots resulted in a pink tint (usually it was green for me, or blue)
> Booted 10 times - no tint.
> 
> So this patch is good, but probably has to be implemented as a quirk?
> 
> Jakob

Hi Jakob,

I'm not sure if this needs to be a quirk: There's not really a reason to
set both DEs to the same output. My thinking right now is to error in
this situation.

However I think we have to somehow track which DEs have been set so we
can pretend they start unset. For example:

DE0: (Unset, LCD0) DE1: (Unset, TVE0)

Setting DE0 to LCD0 should work, then setting DE1 to LCD0 should fail.
Setting DE0 to LCD0 should work, then setting DE0 to TVE0 should work.
Setting DE0 to TVE0 should work, then setting DE1 to TVE0 should fail.

The mechanism here for setting a DE I think would go like this:

1. Check the opposite DE's value
2. If it is duplicate and set, error
3. If it is duplicate and unset, change the opposite DE's value
4. Set the DE
5. Mark it as set

Step three requires finding an unused DE value, this could be done by
inverting the bits of the new DE. Alternatively we could do what
Allwinner does and start with both DEs at different values and the move
instead the current DE value to the opposite DE to avoid conflicts.

'Set' here may make more sense as 'used'.

I'm good at mentally over-engineering things, so if you can think of a
better solution please tell me.

John.
John Watts June 29, 2024, 8:58 p.m. UTC | #2
Hi,

On Sat, Jun 29, 2024 at 12:14:39PM +1000, Kirby Nankivell wrote:
> Tested this on a MangoPI-MQ-R with a RGB lcd and can confirm that this fix
> removes the green tint I experienced.
> 
> Disabling the mixer1 in DTS entirely also works.
> 
> I suspect on the basis that the Mixer/TCON-TOP topology is identical to the
> R40 but does not seem to experience this issue, that is a
> silicon errata specific to the T113/D1s as far as we currently know.
> 
> However, there is no functional reason from a drm perspective to require
> more than one mixer tied to one output via tcon-top - unless someone has a
> good argument here?
> 
> in my opinion:
> 1) implement this as a quirk on the t113 and fix mixer0 > rgb/dsi and
> mixer1 > tv0
> 2) make this a global default for the sun8i tcon top driver where only one
> mixer is initialised against an output (which would also impact the R40)

The only reason I caught this issue was because I implemented LCD output in
U-Boot and saw it looked a little better- I thought the tint was the backlight.
Had you not contacted me and had it not affected the person I'm doing
work for I would not have bothered looking in to this.
It's entirely possible that the other supported devices have this issue,
or that future ones will and nobody will notice.

Going with a preventative approach here by fixing it for all potential devices
and relying on the behaviour the sunxi code assumes rather than the datasheet
says seems like the best approach to me.

John.
diff mbox series

Patch

--- a/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
+++ b/drivers/gpu/drm/sun4i/sun8i_tcon_top.c
@@ -179,7 +179,7 @@  static int sun8i_tcon_top_bind(struct device *dev, struct device *master,
 	 * At least on H6, some registers have some bits set by default
 	 * which may cause issues. Clear them here.
 	 */
-	writel(0, regs + TCON_TOP_PORT_SEL_REG);
+	writel(0x20, regs + TCON_TOP_PORT_SEL_REG);
 	writel(0, regs + TCON_TOP_GATE_SRC_REG);
 
 	/*