<div dir='auto'><div>Hi, <br><div class="gmail_extra"><br><div class="gmail_quote">Il 26 gen 2018 4:55 PM, Giulio Benetti <giulio.benetti@micronovasrl.com> ha scritto:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Hi,
<br>
<br>
Il 26/01/2018 15:56, Maxime Ripard ha scritto:
<br>
> On Thu, Jan 25, 2018 at 05:50:18PM +0100, Giulio Benetti wrote:
<br>
>>>>>>> On Sat, Jan 20, 2018 at 07:50:21PM +0100, Giulio Benetti wrote:
<br>
>>>>>>>> On previous handling, if specified DRM_MODE_FLAG_N*SYNC,
<br>
>>>>>>>> it was ignored,
<br>
>>>>>>>> because only PHSYNC and PVSYNC were taken into account.
<br>
>>>>>>>> DRM_MODE_FLAG_P*SYNC and DRM_MODE_FLAG_N*SYNC are not exclusive.
<br>
>>>>>>>>
<br>
>>>>>>>> If flags contains PVSYNC, it doesn't mean it is NVSYNC.
<br>
>>>>>>>> And it's true also the contrary.
<br>
>>>>>>>> Also, as I've checked with scope on A20,
<br>
>>>>>>>> if (flags & PVSYNC) then SUN4I_TCON0_IO_POL_VSYNC_POSITIVE
<br>
>>>>>>>> must be set, as name suggests.
<br>
>>>>>>>> It seems all display io polarities starts inverted if 0.
<br>
>>>>>>>>
<br>
>>>>>>>> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
<br>
>>>>>>>>
<br>
>>>>>>>> PVSYNC and PHSYNC only
<br>
>>>>>>>>
<br>
>>>>>>>> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
<br>
>>>>>>>
<br>
>>>>>>> Checkpatch:
<br>
>>>>>>> WARNING: Duplicate signature
<br>
>>>>>>
<br>
>>>>>> Sorry I didn't use ./scripts/checkpatch.pl
<br>
>>>>>>
<br>
>>>>>>>
<br>
>>>>>>>> ---
<br>
>>>>>>>> drivers/gpu/drm/sun4i/sun4i_tcon.c | 4 ++--
<br>
>>>>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
<br>
>>>>>>>>
<br>
>>>>>>>> diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c
<br>
>>>>>>>> b/drivers/gpu/drm/sun4i/sun4i_tcon.c
<br>
>>>>>>>> index 6121210..e873a37 100644
<br>
>>>>>>>> --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
<br>
>>>>>>>> +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
<br>
>>>>>>>> @@ -224,10 +224,10 @@ static void
<br>
>>>>>>>> sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
<br>
>>>>>>>> SUN4I_TCON0_BASIC3_H_SYNC(hsync));
<br>
>>>>>>>> /* Setup the polarity of the various signals */
<br>
>>>>>>>> - if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
<br>
>>>>>>>> + if (mode->flags & DRM_MODE_FLAG_PHSYNC)
<br>
>>>>>>>> val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE;
<br>
>>>>>>>> - if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
<br>
>>>>>>>> + if (mode->flags & DRM_MODE_FLAG_PVSYNC)
<br>
>>>>>>>> val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE;
<br>
>>>>>>>
<br>
>>>>>>> I'm not sure why you were talking of the differences between NVSYNC
<br>
>>>>>>> and PVSYNC if you're not making use of any of it here?
<br>
>>>>>>
<br>
>>>>>> Thinking about it more now, the point is that all Lcd IOs seem to be
<br>
>>>>>> inverted by default(at least on A20).
<br>
>>>>>> With inverted, I mean that if for example PVSYNC,
<br>
>>>>>> I should see vsync line low and when asserted to give VSync,
<br>
>>>>>> it goes high.
<br>
>>>>>> This is what I've checked with oscilloscope on A20.
<br>
>>>>>> Can someone give a try on A33? Otherwise I will,
<br>
>>>>>> but I will take some time.
<br>
>>>>>> On uboot, everything is treated equal to kernel,
<br>
>>>>>> but to have my falling edge dclk and low h/vsync I had to specify:
<br>
>>>>>> CONFIG_VIDEO_LCD_DCLK_PHASE=0 (giving me falling edge on dclk)
<br>
>>>>>> and
<br>
>>>>>> CONFIG_VIDEO_LCD_MODE="....,sync:3,..."
<br>
>>>>>> but digging into code, I see "sync:3" means H/VSYNC HIGH,
<br>
>>>>>> but I experience both LOW during their pulse.
<br>
>>>>>>
<br>
>>>>>>>
<br>
>>>>>>> Also, how was it tested? This seems quite weird that we haven't caught
<br>
>>>>>>> that one sooner, and I'm a bit worried about the possible regressions
<br>
>>>>>>> here.
<br>
>>>>>>
<br>
>>>>>> It sounds really strange to me too,
<br>
>>>>>> because everybody under uboot use "sync:3"(HIGH).
<br>
>>>>>> I will retry to measure,
<br>
>>>>>> unfortunately at home I don't have a scope,
<br>
>>>>>> but I think I'm going to have one soon, because of this. :)
<br>
>>>>>
<br>
>>>>> Here I am with scope captures and tcon0 registers dump:
<br>
>>>>> tcon0_regs => https://pasteboard.co/H4r8Zcs.png
<br>
>>>>> dclk_d0 => https://pasteboard.co/H4r8QRe.png
<br>
>>>>> dclk_de => https://pasteboard.co/H4r8zh4R.png
<br>
>>>>> dclk_vsnc => https://pasteboard.co/H4r8Hye.png
<br>
>>>>>
<br>
>>>>> As you can see circled in reg on registers,
<br>
>>>>> TCON0_IO_POL_REG = 0x00000000.
<br>
>>>>> But on all the waveforms you can see:
<br>
>>>>> - dclk_d0: clock phase is 0, but it starts with falling edge, otherwise
<br>
>>>>> the rising front overlaps dclk rising edge(not good), so to me this is
<br>
>>>>> falling, then I mean it Negative.
<br>
>>>>> - dclk_de: de pulse is clearly negative, even if register is 0 and its'
<br>
>>>>> polarity bit is 0.
<br>
>>>>> - dclk_vsnc: same as dclk_de
<br>
>>>>> - dclk_hsync: I didn't take scope screenshot but I can assure you it's
<br>
>>>>> negative.
<br>
>>>>>
<br>
>>>>> You can also check all the other registers about TCON0.
<br>
>>>>>
<br>
>>>>> Now I proceed testing it on A33, maybe the peripheral is slightly
<br>
>>>>> different between Axx SoCs, if I find it that way,
<br>
>>>>> it should be only a check about SoC or peripheral ID,
<br>
>>>>> and treat polarity as it should be done.
<br>
>>>>
<br>
>>>> Here I am with A33 waveforms:
<br>
>>>> tcon0_regs => https://pasteboard.co/H4rXfN0M.png
<br>
>>>> dclk_d0 => https://pasteboard.co/H4rVXwy.png
<br>
>>>> dclk_de => https://pasteboard.co/H4rWDt8.png
<br>
>>>> dclk_vsnc => https://pasteboard.co/H4rWRACu.png
<br>
>>>> dclk_hsync => https://pasteboard.co/H4rWK6I.png
<br>
>>>
<br>
>>> Thanks, that's really helpful.
<br>
>>>
<br>
>>>> It behaves the same way as A20, so as I mean IO polarity,
<br>
>>>> all signals(except D0-D23), are inverted.
<br>
>>>> For A33 I've used A33-OLinuXino.
<br>
>>>> For A20 our LiNova1.
<br>
>>>
<br>
>>> Indeed, HSYNC and VSYNC look inverted.
<br>
>>
<br>
>> Yes, so they should be inverted inside the driver.
<br>
>
<br>
> Yep. And the LCD panels used on our boards as well in order to avoid
<br>
> any breakages.
<br>
<br>
Can you provide a list?
<br>
Or is there a way I can find it on my own?
<br>
I can create a whole patch-set providing this too on panel-simple.c
<br>
Ok?
<br>
<br>
>
<br>
>>> I don't really know what the polarity of D0 would be just by
<br>
>>> judging at that capture, but we would have noticed if the colors
<br>
>>> were inverted for quite some time now.
<br>
>>
<br>
>> D0-D23 are correct.
<br>
>>
<br>
>> With that capture, I mean to show you instead dclk is inverted, as
<br>
>> dclk samples D0 on falling edge.
<br>
>
<br>
> Ah right, DCLK being the first channel?
<br>
<br>
Yes, sorry I didn't place a label on channels
<br>
<br>
>
<br>
>> So 0 is NEGEDGE and 1 is POSEDGE(1/3 of clock phase).
<br>
>> 1/3 clock phase seems enough to me to be considered POSEDGE,
<br>
>> 2/3 instead risks to go too much to the right of D0(even if it could work).
<br>
>
<br>
> Do you have captures with both settings?
<br>
<br>
Not now, but asap I'm going to take.
<br>
<br>
>
<br>
>>> DE seems to be active high though, since it's only going to be at
<br>
>>> a logical low level when data are not transmitted, so during the
<br>
>>> blank periods.
<br>
>>
<br>
>> Yes, you're right, DE is data enable, and is asserted high as 0.
<br>
>
<br>
> No, it is asserted high as 1
<br>
<br>
Sorry, I wanted to tell it is asserted high with IO_POL register bit
<br>
cleared to 0. So we're saying same thing now.
<br>
<br>
>
<br>
>> But it must be added.
<br>
>> I'm planning to send a new patchset with all these things corrected for
<br>
>> kernel.
<br>
>
<br>
> Ok.
<br>
>
<br>
>> A little out of thread but:
<br>
>> I'd like to send one for u-boot too,
<br>
>> but this means also to modify every sunxi "sync:3" to "sync:0" and
<br>
>> vice-versa.
<br>
>>
<br>
>> What do you think?
<br>
>
<br>
> That it's going to be a nightmare... We've advertised since the very
<br>
> beginning something, and we're about to break it. I'm not sure we want
<br>
> to do that.
<br>
<br>
I can take care about that.
<br>
But I also think that a lot of displays work because they use only
<br>
DE-mode, almost ignoring HSync and VSync signals(HV-mode).
<br></p></blockquote></div></div></div><div dir="auto">I think that we have only to take care about displays that don't have DE signal. </div><div dir="auto">If DE signal exists, then displays are driven through DE only for back and front porch as I know, and on most displays I've used, Hsync and VSync are ignored. </div><div dir="auto">This is should be why nobody noticed it before IMHO. </div><div dir="auto">So, if we fix bug for Hsync and VSync, risk should be very low. </div><div dir="auto">Indeed, everybody or almost, use sync:3 because display ignore those 2 nets.</div><div dir="auto">And I don't know how many people checked with oscilloscope signals after getting display working in few. </div><div dir="auto"><br></div><div dir="auto">So maybe we can keep all Def configured untouched. </div><div dir="auto">The same in Linux, prior displays have DE signal.</div><div dir="auto"><br></div><div dir="auto">Maybe nightmare is less than we thought. </div><div dir="auto"><br></div><div dir="auto">Giulio </div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">
<br>
In any case I have to produce these patches because of my company's
<br>
board based on A20 and A33, and modify defconfig according to it.
<br>
The only technical nightmare I see is to produce a commit for every
<br>
defconfig to be modified and copy-paste che commit-log substituing board
<br>
name(1-2 days of work).
<br>
Problem is testing, but we're speaking about something that probably was
<br>
badly working, but you couldn't see it on display.
<br>
So I think this is only an improvement at the end.
<br>
<br>
I'm sorry I've taken bad news.
<br>
Drink 1 glass of Spritz to go over! :)
<br>
<br>
>
<br>
> Thanks!
<br>
> Maxime
<br>
>
<br>
<br>
<br>
--
<br>
Giulio Benetti
<br>
R&D Manager &
<br>
Advanced Research
<br>
<br>
MICRONOVA SRL
<br>
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
<br>
Tel. 049/8931563 - Fax 049/8931346
<br>
Cod.Fiscale - P.IVA 02663420285
<br>
Capitale Sociale € 26.000 i.v.
<br>
Iscritta al Reg. Imprese di Padova N. 02663420285
<br>
Numero R.E.A. 258642
<br>
</p>
</blockquote></div><br></div></div></div>