[0/4] drm/panel: sitronix-st7789v: add support for partial mode

Message ID 20230718-feature-lcd-panel-v1-0-e9a85d5374fd@wolfvision.net
Headers
Series drm/panel: sitronix-st7789v: add support for partial mode |

Message

Michael Riesch July 18, 2023, 3:31 p.m. UTC
  Hi all,

This series adds support for the partial display mode to the Sitronix
ST7789V panel driver. This is useful for panels that are partially
occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
for this particular panel is added as well.

Note: This series is already based on
https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/

Looking forward to your comments!

---
Michael Riesch (4):
      dt-bindings: vendor-prefixes: add jasonic
      dt-bindings: display: st7789v: add jasonic jt240mhqs-hwt-ek-e3 display
      drm/panel: sitronix-st7789v: add support for partial mode
      drm/panel: sitronix-st7789v: add jasonic jt240mhqs-hwt-ek-e3 support

 .../bindings/display/panel/sitronix,st7789v.yaml   |  1 +
 .../devicetree/bindings/vendor-prefixes.yaml       |  2 +
 drivers/gpu/drm/panel/panel-sitronix-st7789v.c     | 67 +++++++++++++++++++++-
 3 files changed, 68 insertions(+), 2 deletions(-)
---
base-commit: b43dae411767f34288aa347f26b5ed2dade39469
change-id: 20230718-feature-lcd-panel-26d9f29a7830

Best regards,
  

Comments

Daniel Vetter Aug. 2, 2023, 2:25 p.m. UTC | #1
On Tue, Jul 18, 2023 at 05:31:49PM +0200, Michael Riesch wrote:
> Hi all,
> 
> This series adds support for the partial display mode to the Sitronix
> ST7789V panel driver. This is useful for panels that are partially
> occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> for this particular panel is added as well.
> 
> Note: This series is already based on
> https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> 
> Looking forward to your comments!

Summary of my take from a fairly long (and kinda still on-going) irc
discussion:

- Where we do know the exact overscan, the kernel should expose correct
  modes and adjust the display pipeline to match if needed when
  programming the hardware. Meaning the approach in this patch series.

- For hdmi overscan there's a lot of automagic overscan happening by
  default. Drivers can mostly fix this by setting all the right
  infoframes, but unfortuantely a very big pile of infoframes is needed.
  Assuming drivers actually use the helpers I think only i915 gets them
  all, so intel_hdmi_compute_config() at the bottom would be the example
  to follow, and maybe some more code to extract from and share.

- That /should/ only leave the really old analog TV and similar horrors
  leftover. For those we simply can't even guess the right amount of
  overscan (because back then no one cared back then about really seeing
  everything), and so that's the only case where we should rely on the
  overscan properties. And that case only works when the compositor stack
  passes these properties all the way to the user, since only they can
  check when the settings are good.

The overscan properties should _not_ be used to fix issues of the previous
kind, that really should all work out of the box as much as possible.

Cheers, Sima


> 
> ---
> Michael Riesch (4):
>       dt-bindings: vendor-prefixes: add jasonic
>       dt-bindings: display: st7789v: add jasonic jt240mhqs-hwt-ek-e3 display
>       drm/panel: sitronix-st7789v: add support for partial mode
>       drm/panel: sitronix-st7789v: add jasonic jt240mhqs-hwt-ek-e3 support
> 
>  .../bindings/display/panel/sitronix,st7789v.yaml   |  1 +
>  .../devicetree/bindings/vendor-prefixes.yaml       |  2 +
>  drivers/gpu/drm/panel/panel-sitronix-st7789v.c     | 67 +++++++++++++++++++++-
>  3 files changed, 68 insertions(+), 2 deletions(-)
> ---
> base-commit: b43dae411767f34288aa347f26b5ed2dade39469
> change-id: 20230718-feature-lcd-panel-26d9f29a7830
> 
> Best regards,
> -- 
> Michael Riesch <michael.riesch@wolfvision.net>
>
  
Neil Armstrong Aug. 3, 2023, 8:11 a.m. UTC | #2
Hi,

On 18/07/2023 17:31, Michael Riesch wrote:
> Hi all,
> 
> This series adds support for the partial display mode to the Sitronix
> ST7789V panel driver. This is useful for panels that are partially
> occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> for this particular panel is added as well.
> 
> Note: This series is already based on
> https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/

I understand Maxime's arguments, but by looking closely at the code,
this doesn't look like an hack at all and uses capabilities of the
panel controller to expose a smaller area without depending on any
changes or hacks on the display controller side which is coherent.

Following's Daniel's summary we cannot compare it to TV overscan
because overscan is only on *some* displays, we can still get 100%
of the picture from the signal.
While here, we cannot, there's physically less pixels on the panel.

If there's no more still a strong nack or pending comments,
I plan to apply those tomorrow.

Thanks,
Neil

> 
> Looking forward to your comments!
> 
> ---
> Michael Riesch (4):
>        dt-bindings: vendor-prefixes: add jasonic
>        dt-bindings: display: st7789v: add jasonic jt240mhqs-hwt-ek-e3 display
>        drm/panel: sitronix-st7789v: add support for partial mode
>        drm/panel: sitronix-st7789v: add jasonic jt240mhqs-hwt-ek-e3 support
> 
>   .../bindings/display/panel/sitronix,st7789v.yaml   |  1 +
>   .../devicetree/bindings/vendor-prefixes.yaml       |  2 +
>   drivers/gpu/drm/panel/panel-sitronix-st7789v.c     | 67 +++++++++++++++++++++-
>   3 files changed, 68 insertions(+), 2 deletions(-)
> ---
> base-commit: b43dae411767f34288aa347f26b5ed2dade39469
> change-id: 20230718-feature-lcd-panel-26d9f29a7830
> 
> Best regards,
  
Maxime Ripard Aug. 3, 2023, 8:48 a.m. UTC | #3
On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
> Hi,
> 
> On 18/07/2023 17:31, Michael Riesch wrote:
> > Hi all,
> > 
> > This series adds support for the partial display mode to the Sitronix
> > ST7789V panel driver. This is useful for panels that are partially
> > occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> > for this particular panel is added as well.
> > 
> > Note: This series is already based on
> > https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> 
> I understand Maxime's arguments, but by looking closely at the code,
> this doesn't look like an hack at all and uses capabilities of the
> panel controller to expose a smaller area without depending on any
> changes or hacks on the display controller side which is coherent.
> 
> Following's Daniel's summary we cannot compare it to TV overscan
> because overscan is only on *some* displays, we can still get 100%
> of the picture from the signal.

Still disagree on the fact that it only affects some display. But it's
not really relevant for that series.

I think I'll still like to have something clarified before we merge it:
if userspace forces a mode, does it contain the margins or not? I don't
have an opinion there, I just think it should be documented.

Maxime
  
Daniel Vetter Aug. 3, 2023, 8:51 a.m. UTC | #4
On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
> On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
> > Hi,
> > 
> > On 18/07/2023 17:31, Michael Riesch wrote:
> > > Hi all,
> > > 
> > > This series adds support for the partial display mode to the Sitronix
> > > ST7789V panel driver. This is useful for panels that are partially
> > > occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> > > for this particular panel is added as well.
> > > 
> > > Note: This series is already based on
> > > https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> > 
> > I understand Maxime's arguments, but by looking closely at the code,
> > this doesn't look like an hack at all and uses capabilities of the
> > panel controller to expose a smaller area without depending on any
> > changes or hacks on the display controller side which is coherent.
> > 
> > Following's Daniel's summary we cannot compare it to TV overscan
> > because overscan is only on *some* displays, we can still get 100%
> > of the picture from the signal.
> 
> Still disagree on the fact that it only affects some display. But it's
> not really relevant for that series.

See my 2nd point, from a quick grep aside from i915 hdmi support, no one
else sets all the required hdmi infoframes correctly. Which means on a
compliant hdmi tv, you _should_ get overscan. That's how that stuff is
speced.

Iirc you need to at least set both the VIC and the content type, maybe
even more stuff.

Unless all that stuff is set I'd say it's a kms driver bug if you get
overscan on a hdmi TV.

> I think I'll still like to have something clarified before we merge it:
> if userspace forces a mode, does it contain the margins or not? I don't
> have an opinion there, I just think it should be documented.

The mode comes with the margins, so if userspace does something really
funny then either it gets garbage (as in, part of it's crtc area isn't
visible, or maybe black bars on the screen), or the driver rejects it
(which I think is the case for panels, they only take their mode and
nothing else).

Cheers, Sima
  
Maxime Ripard Aug. 3, 2023, 9:22 a.m. UTC | #5
On Thu, Aug 03, 2023 at 10:51:57AM +0200, Daniel Vetter wrote:
> On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
> > On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
> > > Hi,
> > > 
> > > On 18/07/2023 17:31, Michael Riesch wrote:
> > > > Hi all,
> > > > 
> > > > This series adds support for the partial display mode to the Sitronix
> > > > ST7789V panel driver. This is useful for panels that are partially
> > > > occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> > > > for this particular panel is added as well.
> > > > 
> > > > Note: This series is already based on
> > > > https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> > > 
> > > I understand Maxime's arguments, but by looking closely at the code,
> > > this doesn't look like an hack at all and uses capabilities of the
> > > panel controller to expose a smaller area without depending on any
> > > changes or hacks on the display controller side which is coherent.
> > > 
> > > Following's Daniel's summary we cannot compare it to TV overscan
> > > because overscan is only on *some* displays, we can still get 100%
> > > of the picture from the signal.
> > 
> > Still disagree on the fact that it only affects some display. But it's
> > not really relevant for that series.
> 
> See my 2nd point, from a quick grep aside from i915 hdmi support, no one
> else sets all the required hdmi infoframes correctly. Which means on a
> compliant hdmi tv, you _should_ get overscan. That's how that stuff is
> speced.
> 
> Iirc you need to at least set both the VIC and the content type, maybe
> even more stuff.
> 
> Unless all that stuff is set I'd say it's a kms driver bug if you get
> overscan on a hdmi TV.

I have no doubt that i915 works there. The source of my disagreement is
that if all drivers but one don't do that, then userspace will have to
care. You kind of said it yourself, i915 is kind of the exception there.

The exception can be (and I'm sure it is) right, but still, it deviates
from the norm.

> > I think I'll still like to have something clarified before we merge it:
> > if userspace forces a mode, does it contain the margins or not? I don't
> > have an opinion there, I just think it should be documented.
> 
> The mode comes with the margins, so if userspace does something really
> funny then either it gets garbage (as in, part of it's crtc area isn't
> visible, or maybe black bars on the screen), or the driver rejects it
> (which I think is the case for panels, they only take their mode and
> nothing else).

Panels can usually be quite flexible when it comes to the timings they
accept, and we could actually use that to our advantage, but even if we
assume that they have a single mode, I don't think we have anything that
enforces that, either at the framework or documentation levels?

Maxime
  
Neil Armstrong Aug. 3, 2023, 9:30 a.m. UTC | #6
On 03/08/2023 11:22, Maxime Ripard wrote:
> On Thu, Aug 03, 2023 at 10:51:57AM +0200, Daniel Vetter wrote:
>> On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
>>> On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
>>>> Hi,
>>>>
>>>> On 18/07/2023 17:31, Michael Riesch wrote:
>>>>> Hi all,
>>>>>
>>>>> This series adds support for the partial display mode to the Sitronix
>>>>> ST7789V panel driver. This is useful for panels that are partially
>>>>> occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
>>>>> for this particular panel is added as well.
>>>>>
>>>>> Note: This series is already based on
>>>>> https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
>>>>
>>>> I understand Maxime's arguments, but by looking closely at the code,
>>>> this doesn't look like an hack at all and uses capabilities of the
>>>> panel controller to expose a smaller area without depending on any
>>>> changes or hacks on the display controller side which is coherent.
>>>>
>>>> Following's Daniel's summary we cannot compare it to TV overscan
>>>> because overscan is only on *some* displays, we can still get 100%
>>>> of the picture from the signal.
>>>
>>> Still disagree on the fact that it only affects some display. But it's
>>> not really relevant for that series.
>>
>> See my 2nd point, from a quick grep aside from i915 hdmi support, no one
>> else sets all the required hdmi infoframes correctly. Which means on a
>> compliant hdmi tv, you _should_ get overscan. That's how that stuff is
>> speced.
>>
>> Iirc you need to at least set both the VIC and the content type, maybe
>> even more stuff.
>>
>> Unless all that stuff is set I'd say it's a kms driver bug if you get
>> overscan on a hdmi TV.
> 
> I have no doubt that i915 works there. The source of my disagreement is
> that if all drivers but one don't do that, then userspace will have to
> care. You kind of said it yourself, i915 is kind of the exception there.
> 
> The exception can be (and I'm sure it is) right, but still, it deviates
> from the norm.

HDMI spec is hidden behind a paywall, HDMI testing is a mess, HDMI real
implementation on TVs and Displays is mostly broken, and HDMI certification
devices are too expensive... this is mainly why only i915 handles it correctly.

> 
>>> I think I'll still like to have something clarified before we merge it:
>>> if userspace forces a mode, does it contain the margins or not? I don't
>>> have an opinion there, I just think it should be documented.
>>
>> The mode comes with the margins, so if userspace does something really
>> funny then either it gets garbage (as in, part of it's crtc area isn't
>> visible, or maybe black bars on the screen), or the driver rejects it
>> (which I think is the case for panels, they only take their mode and
>> nothing else).
> 
> Panels can usually be quite flexible when it comes to the timings they
> accept, and we could actually use that to our advantage, but even if we
> assume that they have a single mode, I don't think we have anything that
> enforces that, either at the framework or documentation levels?

Yep, this is why we would need a better atomic based panel API that would
permit us handling dynamic timings for panel and get out of the single-mode
for modern panels.

Neil

> 
> Maxime
  
Maxime Ripard Aug. 3, 2023, 9:38 a.m. UTC | #7
On Thu, Aug 03, 2023 at 11:30:52AM +0200, Neil Armstrong wrote:
> On 03/08/2023 11:22, Maxime Ripard wrote:
> > On Thu, Aug 03, 2023 at 10:51:57AM +0200, Daniel Vetter wrote:
> > > On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
> > > > On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
> > > > > Hi,
> > > > > 
> > > > > On 18/07/2023 17:31, Michael Riesch wrote:
> > > > > > Hi all,
> > > > > > 
> > > > > > This series adds support for the partial display mode to the Sitronix
> > > > > > ST7789V panel driver. This is useful for panels that are partially
> > > > > > occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> > > > > > for this particular panel is added as well.
> > > > > > 
> > > > > > Note: This series is already based on
> > > > > > https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> > > > > 
> > > > > I understand Maxime's arguments, but by looking closely at the code,
> > > > > this doesn't look like an hack at all and uses capabilities of the
> > > > > panel controller to expose a smaller area without depending on any
> > > > > changes or hacks on the display controller side which is coherent.
> > > > > 
> > > > > Following's Daniel's summary we cannot compare it to TV overscan
> > > > > because overscan is only on *some* displays, we can still get 100%
> > > > > of the picture from the signal.
> > > > 
> > > > Still disagree on the fact that it only affects some display. But it's
> > > > not really relevant for that series.
> > > 
> > > See my 2nd point, from a quick grep aside from i915 hdmi support, no one
> > > else sets all the required hdmi infoframes correctly. Which means on a
> > > compliant hdmi tv, you _should_ get overscan. That's how that stuff is
> > > speced.
> > > 
> > > Iirc you need to at least set both the VIC and the content type, maybe
> > > even more stuff.
> > > 
> > > Unless all that stuff is set I'd say it's a kms driver bug if you get
> > > overscan on a hdmi TV.
> > 
> > I have no doubt that i915 works there. The source of my disagreement is
> > that if all drivers but one don't do that, then userspace will have to
> > care. You kind of said it yourself, i915 is kind of the exception there.
> > 
> > The exception can be (and I'm sure it is) right, but still, it deviates
> > from the norm.
> 
> HDMI spec is hidden behind a paywall, HDMI testing is a mess, HDMI real
> implementation on TVs and Displays is mostly broken, and HDMI certification
> devices are too expensive... this is mainly why only i915 handles it correctly.

Sure, I know all that, it's why I was disagreeing with the fact that
it's mostly old news and we shouldn't care anymore. And it could largely
be fixed if i915 was using more helpers in general.

But that's a separate discussion entirely. The point I was trying to
make is that it's still very much the current situation for the vast
majority of drivers, for whatever reason, so we can't really treat as if
it isn't anymore.

> > > > I think I'll still like to have something clarified before we merge it:
> > > > if userspace forces a mode, does it contain the margins or not? I don't
> > > > have an opinion there, I just think it should be documented.
> > > 
> > > The mode comes with the margins, so if userspace does something really
> > > funny then either it gets garbage (as in, part of it's crtc area isn't
> > > visible, or maybe black bars on the screen), or the driver rejects it
> > > (which I think is the case for panels, they only take their mode and
> > > nothing else).
> > 
> > Panels can usually be quite flexible when it comes to the timings they
> > accept, and we could actually use that to our advantage, but even if we
> > assume that they have a single mode, I don't think we have anything that
> > enforces that, either at the framework or documentation levels?
> 
> Yep, this is why we would need a better atomic based panel API that would
> permit us handling dynamic timings for panel and get out of the single-mode
> for modern panels.

Again, I definitely agree on the new API, but that seems a bit out of
scope :)

My point was that we can't expect modes to be the one we provided in
.get_modes. And that's for all the drivers, even i915 doesn't do it (as
far as I could see)

Maxime
  
Daniel Vetter Aug. 3, 2023, 10:26 a.m. UTC | #8
On Thu, 3 Aug 2023 at 11:22, Maxime Ripard <mripard@kernel.org> wrote:
>
> On Thu, Aug 03, 2023 at 10:51:57AM +0200, Daniel Vetter wrote:
> > On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
> > > On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
> > > > Hi,
> > > >
> > > > On 18/07/2023 17:31, Michael Riesch wrote:
> > > > > Hi all,
> > > > >
> > > > > This series adds support for the partial display mode to the Sitronix
> > > > > ST7789V panel driver. This is useful for panels that are partially
> > > > > occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> > > > > for this particular panel is added as well.
> > > > >
> > > > > Note: This series is already based on
> > > > > https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> > > >
> > > > I understand Maxime's arguments, but by looking closely at the code,
> > > > this doesn't look like an hack at all and uses capabilities of the
> > > > panel controller to expose a smaller area without depending on any
> > > > changes or hacks on the display controller side which is coherent.
> > > >
> > > > Following's Daniel's summary we cannot compare it to TV overscan
> > > > because overscan is only on *some* displays, we can still get 100%
> > > > of the picture from the signal.
> > >
> > > Still disagree on the fact that it only affects some display. But it's
> > > not really relevant for that series.
> >
> > See my 2nd point, from a quick grep aside from i915 hdmi support, no one
> > else sets all the required hdmi infoframes correctly. Which means on a
> > compliant hdmi tv, you _should_ get overscan. That's how that stuff is
> > speced.
> >
> > Iirc you need to at least set both the VIC and the content type, maybe
> > even more stuff.
> >
> > Unless all that stuff is set I'd say it's a kms driver bug if you get
> > overscan on a hdmi TV.
>
> I have no doubt that i915 works there. The source of my disagreement is
> that if all drivers but one don't do that, then userspace will have to
> care. You kind of said it yourself, i915 is kind of the exception there.
>
> The exception can be (and I'm sure it is) right, but still, it deviates
> from the norm.

The right fix for these is sending the right infoframes, _not_ trying
to fiddle with overscan margins. Only the kernel can make sure the
right infoframes are sent out. If you try to paper over this in
userspace, you'll make the situation worse, not better (because
fiddling with overscan means you get scaling, and so rescaling
artifacts, and for hard contrasts along pixel lines that'll look like
crap).

So yeah this is a case of "most upstream hdmi drivers are broken".
Please don't try to fix kernel bugs in userspace.

> > > I think I'll still like to have something clarified before we merge it:
> > > if userspace forces a mode, does it contain the margins or not? I don't
> > > have an opinion there, I just think it should be documented.
> >
> > The mode comes with the margins, so if userspace does something really
> > funny then either it gets garbage (as in, part of it's crtc area isn't
> > visible, or maybe black bars on the screen), or the driver rejects it
> > (which I think is the case for panels, they only take their mode and
> > nothing else).
>
> Panels can usually be quite flexible when it comes to the timings they
> accept, and we could actually use that to our advantage, but even if we
> assume that they have a single mode, I don't think we have anything that
> enforces that, either at the framework or documentation levels?

Maybe more bugs? We've been slowly filling out all kinds of atomic kms
validation bugs in core/helper code because as a rule of thumb,
drivers get it wrong. Developers test until things work, then call it
good enough, and very few driver teams make a serious effort in trying
to really validate all invalid input. Because doing that is an
enormous amount of work.

I think for clear-cut cases like drm_panel the fix is to just put more
stricter validation into shared code (and then if we break something,
figure out how we can be sufficiently lenient again).
-Sima
  
Maxime Ripard Aug. 3, 2023, 11:43 a.m. UTC | #9
On Thu, Aug 03, 2023 at 12:26:03PM +0200, Daniel Vetter wrote:
> On Thu, 3 Aug 2023 at 11:22, Maxime Ripard <mripard@kernel.org> wrote:
> >
> > On Thu, Aug 03, 2023 at 10:51:57AM +0200, Daniel Vetter wrote:
> > > On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
> > > > On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
> > > > > Hi,
> > > > >
> > > > > On 18/07/2023 17:31, Michael Riesch wrote:
> > > > > > Hi all,
> > > > > >
> > > > > > This series adds support for the partial display mode to the Sitronix
> > > > > > ST7789V panel driver. This is useful for panels that are partially
> > > > > > occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> > > > > > for this particular panel is added as well.
> > > > > >
> > > > > > Note: This series is already based on
> > > > > > https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> > > > >
> > > > > I understand Maxime's arguments, but by looking closely at the code,
> > > > > this doesn't look like an hack at all and uses capabilities of the
> > > > > panel controller to expose a smaller area without depending on any
> > > > > changes or hacks on the display controller side which is coherent.
> > > > >
> > > > > Following's Daniel's summary we cannot compare it to TV overscan
> > > > > because overscan is only on *some* displays, we can still get 100%
> > > > > of the picture from the signal.
> > > >
> > > > Still disagree on the fact that it only affects some display. But it's
> > > > not really relevant for that series.
> > >
> > > See my 2nd point, from a quick grep aside from i915 hdmi support, no one
> > > else sets all the required hdmi infoframes correctly. Which means on a
> > > compliant hdmi tv, you _should_ get overscan. That's how that stuff is
> > > speced.
> > >
> > > Iirc you need to at least set both the VIC and the content type, maybe
> > > even more stuff.
> > >
> > > Unless all that stuff is set I'd say it's a kms driver bug if you get
> > > overscan on a hdmi TV.
> >
> > I have no doubt that i915 works there. The source of my disagreement is
> > that if all drivers but one don't do that, then userspace will have to
> > care. You kind of said it yourself, i915 is kind of the exception there.
> >
> > The exception can be (and I'm sure it is) right, but still, it deviates
> > from the norm.
> 
> The right fix for these is sending the right infoframes, _not_ trying
> to fiddle with overscan margins. Only the kernel can make sure the
> right infoframes are sent out. If you try to paper over this in
> userspace, you'll make the situation worse, not better (because
> fiddling with overscan means you get scaling, and so rescaling
> artifacts, and for hard contrasts along pixel lines that'll look like
> crap).
> 
> So yeah this is a case of "most upstream hdmi drivers are broken".
> Please don't try to fix kernel bugs in userspace.

ACK.

> > > > I think I'll still like to have something clarified before we merge it:
> > > > if userspace forces a mode, does it contain the margins or not? I don't
> > > > have an opinion there, I just think it should be documented.
> > >
> > > The mode comes with the margins, so if userspace does something really
> > > funny then either it gets garbage (as in, part of it's crtc area isn't
> > > visible, or maybe black bars on the screen), or the driver rejects it
> > > (which I think is the case for panels, they only take their mode and
> > > nothing else).
> >
> > Panels can usually be quite flexible when it comes to the timings they
> > accept, and we could actually use that to our advantage, but even if we
> > assume that they have a single mode, I don't think we have anything that
> > enforces that, either at the framework or documentation levels?
> 
> Maybe more bugs? We've been slowly filling out all kinds of atomic kms
> validation bugs in core/helper code because as a rule of thumb,
> drivers get it wrong. Developers test until things work, then call it
> good enough, and very few driver teams make a serious effort in trying
> to really validate all invalid input. Because doing that is an
> enormous amount of work.
> 
> I think for clear-cut cases like drm_panel the fix is to just put more
> stricter validation into shared code (and then if we break something,
> figure out how we can be sufficiently lenient again).

Panels are kind of weird, since they essentially don't exist at all in
the framework so it's difficult to make it handle them or their state.

It's typically handled by encoders directly, so each and every driver
would need to make that check, and from a quick grep, none of them are
(for the reasons you said).

Just like for HDMI, even though we can commit to changing those facts,
it won't happen overnight, so to circle back to that series, I'd like a
comment in the driver when the partial mode is enabled that if userspace
ever pushes a mode different from the expected one, we'll add the margins.

That way, if and when we come back to it, we'll know what the original
intent and semantics were.

Maxime
  
Neil Armstrong Aug. 3, 2023, 12:34 p.m. UTC | #10
On 03/08/2023 13:43, Maxime Ripard wrote:
> On Thu, Aug 03, 2023 at 12:26:03PM +0200, Daniel Vetter wrote:
>> On Thu, 3 Aug 2023 at 11:22, Maxime Ripard <mripard@kernel.org> wrote:
>>>
>>> On Thu, Aug 03, 2023 at 10:51:57AM +0200, Daniel Vetter wrote:
>>>> On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
>>>>> On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
>>>>>> Hi,
>>>>>>
>>>>>> On 18/07/2023 17:31, Michael Riesch wrote:
>>>>>>> Hi all,
>>>>>>>
>>>>>>> This series adds support for the partial display mode to the Sitronix
>>>>>>> ST7789V panel driver. This is useful for panels that are partially
>>>>>>> occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
>>>>>>> for this particular panel is added as well.
>>>>>>>
>>>>>>> Note: This series is already based on
>>>>>>> https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
>>>>>>
>>>>>> I understand Maxime's arguments, but by looking closely at the code,
>>>>>> this doesn't look like an hack at all and uses capabilities of the
>>>>>> panel controller to expose a smaller area without depending on any
>>>>>> changes or hacks on the display controller side which is coherent.
>>>>>>
>>>>>> Following's Daniel's summary we cannot compare it to TV overscan
>>>>>> because overscan is only on *some* displays, we can still get 100%
>>>>>> of the picture from the signal.
>>>>>
>>>>> Still disagree on the fact that it only affects some display. But it's
>>>>> not really relevant for that series.
>>>>
>>>> See my 2nd point, from a quick grep aside from i915 hdmi support, no one
>>>> else sets all the required hdmi infoframes correctly. Which means on a
>>>> compliant hdmi tv, you _should_ get overscan. That's how that stuff is
>>>> speced.
>>>>
>>>> Iirc you need to at least set both the VIC and the content type, maybe
>>>> even more stuff.
>>>>
>>>> Unless all that stuff is set I'd say it's a kms driver bug if you get
>>>> overscan on a hdmi TV.
>>>
>>> I have no doubt that i915 works there. The source of my disagreement is
>>> that if all drivers but one don't do that, then userspace will have to
>>> care. You kind of said it yourself, i915 is kind of the exception there.
>>>
>>> The exception can be (and I'm sure it is) right, but still, it deviates
>>> from the norm.
>>
>> The right fix for these is sending the right infoframes, _not_ trying
>> to fiddle with overscan margins. Only the kernel can make sure the
>> right infoframes are sent out. If you try to paper over this in
>> userspace, you'll make the situation worse, not better (because
>> fiddling with overscan means you get scaling, and so rescaling
>> artifacts, and for hard contrasts along pixel lines that'll look like
>> crap).
>>
>> So yeah this is a case of "most upstream hdmi drivers are broken".
>> Please don't try to fix kernel bugs in userspace.
> 
> ACK.
> 
>>>>> I think I'll still like to have something clarified before we merge it:
>>>>> if userspace forces a mode, does it contain the margins or not? I don't
>>>>> have an opinion there, I just think it should be documented.
>>>>
>>>> The mode comes with the margins, so if userspace does something really
>>>> funny then either it gets garbage (as in, part of it's crtc area isn't
>>>> visible, or maybe black bars on the screen), or the driver rejects it
>>>> (which I think is the case for panels, they only take their mode and
>>>> nothing else).
>>>
>>> Panels can usually be quite flexible when it comes to the timings they
>>> accept, and we could actually use that to our advantage, but even if we
>>> assume that they have a single mode, I don't think we have anything that
>>> enforces that, either at the framework or documentation levels?
>>
>> Maybe more bugs? We've been slowly filling out all kinds of atomic kms
>> validation bugs in core/helper code because as a rule of thumb,
>> drivers get it wrong. Developers test until things work, then call it
>> good enough, and very few driver teams make a serious effort in trying
>> to really validate all invalid input. Because doing that is an
>> enormous amount of work.
>>
>> I think for clear-cut cases like drm_panel the fix is to just put more
>> stricter validation into shared code (and then if we break something,
>> figure out how we can be sufficiently lenient again).
> 
> Panels are kind of weird, since they essentially don't exist at all in
> the framework so it's difficult to make it handle them or their state.
> 
> It's typically handled by encoders directly, so each and every driver
> would need to make that check, and from a quick grep, none of them are
> (for the reasons you said).
> 
> Just like for HDMI, even though we can commit to changing those facts,
> it won't happen overnight, so to circle back to that series, I'd like a
> comment in the driver when the partial mode is enabled that if userspace
> ever pushes a mode different from the expected one, we'll add the margins.

To be fair, a majority of the panel drivers would do the wrong
init of the controller with a different mode because:
- mainly the controller model is unknown
- when it's known the datasheet is missing
- when the datasheet is here, most of the registers are missing
- and most of the time the timings are buried in the init sequence

It's sad but it's the real situation.

Only a few drivers can handle a different mode, and we should perhaps
add a flag when not set rejecting a different mode for those controllers and
mark the few ones who can handle that...
And this should be a first step before adding an atomic Panel API.

Neil

> 
> That way, if and when we come back to it, we'll know what the original
> intent and semantics were.
> 
> Maxime
  
Maxime Ripard Aug. 3, 2023, 12:44 p.m. UTC | #11
On Thu, Aug 03, 2023 at 02:34:58PM +0200, Neil Armstrong wrote:
> > > > > > I think I'll still like to have something clarified before we merge it:
> > > > > > if userspace forces a mode, does it contain the margins or not? I don't
> > > > > > have an opinion there, I just think it should be documented.
> > > > > 
> > > > > The mode comes with the margins, so if userspace does something really
> > > > > funny then either it gets garbage (as in, part of it's crtc area isn't
> > > > > visible, or maybe black bars on the screen), or the driver rejects it
> > > > > (which I think is the case for panels, they only take their mode and
> > > > > nothing else).
> > > > 
> > > > Panels can usually be quite flexible when it comes to the timings they
> > > > accept, and we could actually use that to our advantage, but even if we
> > > > assume that they have a single mode, I don't think we have anything that
> > > > enforces that, either at the framework or documentation levels?
> > > 
> > > Maybe more bugs? We've been slowly filling out all kinds of atomic kms
> > > validation bugs in core/helper code because as a rule of thumb,
> > > drivers get it wrong. Developers test until things work, then call it
> > > good enough, and very few driver teams make a serious effort in trying
> > > to really validate all invalid input. Because doing that is an
> > > enormous amount of work.
> > > 
> > > I think for clear-cut cases like drm_panel the fix is to just put more
> > > stricter validation into shared code (and then if we break something,
> > > figure out how we can be sufficiently lenient again).
> > 
> > Panels are kind of weird, since they essentially don't exist at all in
> > the framework so it's difficult to make it handle them or their state.
> > 
> > It's typically handled by encoders directly, so each and every driver
> > would need to make that check, and from a quick grep, none of them are
> > (for the reasons you said).
> > 
> > Just like for HDMI, even though we can commit to changing those facts,
> > it won't happen overnight, so to circle back to that series, I'd like a
> > comment in the driver when the partial mode is enabled that if userspace
> > ever pushes a mode different from the expected one, we'll add the margins.
> 
> To be fair, a majority of the panel drivers would do the wrong
> init of the controller with a different mode because:
> - mainly the controller model is unknown
> - when it's known the datasheet is missing
> - when the datasheet is here, most of the registers are missing
> - and most of the time the timings are buried in the init sequence
> 
> It's sad but it's the real situation.

Again, I agree. As far as I'm aware, none of them add arbitrary numbers
to timings though, so it's easy enough to figure out what the mode is
meant to be: it's the mode. Here, we add some numbers to the mode, so
the interaction with the userspace forcing a mode is less clear.

> Only a few drivers can handle a different mode, and we should perhaps
> add a flag when not set rejecting a different mode for those controllers and
> mark the few ones who can handle that...
> And this should be a first step before adding an atomic Panel API.

I'm really just asking for a comment in the code here.

Everything that you mentioned are improvements that we should have on
our todo list, but I don't see them as pre-requisite for this series and
we get to it later on.

Maxime
  
Daniel Vetter Aug. 3, 2023, 2:55 p.m. UTC | #12
On Thu, Aug 03, 2023 at 01:43:08PM +0200, Maxime Ripard wrote:
> On Thu, Aug 03, 2023 at 12:26:03PM +0200, Daniel Vetter wrote:
> > On Thu, 3 Aug 2023 at 11:22, Maxime Ripard <mripard@kernel.org> wrote:
> > >
> > > On Thu, Aug 03, 2023 at 10:51:57AM +0200, Daniel Vetter wrote:
> > > > On Thu, Aug 03, 2023 at 10:48:57AM +0200, Maxime Ripard wrote:
> > > > > On Thu, Aug 03, 2023 at 10:11:22AM +0200, Neil Armstrong wrote:
> > > > > > Hi,
> > > > > >
> > > > > > On 18/07/2023 17:31, Michael Riesch wrote:
> > > > > > > Hi all,
> > > > > > >
> > > > > > > This series adds support for the partial display mode to the Sitronix
> > > > > > > ST7789V panel driver. This is useful for panels that are partially
> > > > > > > occluded by design, such as the Jasonic JT240MHQS-HWT-EK-E3. Support
> > > > > > > for this particular panel is added as well.
> > > > > > >
> > > > > > > Note: This series is already based on
> > > > > > > https://lore.kernel.org/lkml/20230714013756.1546769-1-sre@kernel.org/
> > > > > >
> > > > > > I understand Maxime's arguments, but by looking closely at the code,
> > > > > > this doesn't look like an hack at all and uses capabilities of the
> > > > > > panel controller to expose a smaller area without depending on any
> > > > > > changes or hacks on the display controller side which is coherent.
> > > > > >
> > > > > > Following's Daniel's summary we cannot compare it to TV overscan
> > > > > > because overscan is only on *some* displays, we can still get 100%
> > > > > > of the picture from the signal.
> > > > >
> > > > > Still disagree on the fact that it only affects some display. But it's
> > > > > not really relevant for that series.
> > > >
> > > > See my 2nd point, from a quick grep aside from i915 hdmi support, no one
> > > > else sets all the required hdmi infoframes correctly. Which means on a
> > > > compliant hdmi tv, you _should_ get overscan. That's how that stuff is
> > > > speced.
> > > >
> > > > Iirc you need to at least set both the VIC and the content type, maybe
> > > > even more stuff.
> > > >
> > > > Unless all that stuff is set I'd say it's a kms driver bug if you get
> > > > overscan on a hdmi TV.
> > >
> > > I have no doubt that i915 works there. The source of my disagreement is
> > > that if all drivers but one don't do that, then userspace will have to
> > > care. You kind of said it yourself, i915 is kind of the exception there.
> > >
> > > The exception can be (and I'm sure it is) right, but still, it deviates
> > > from the norm.
> > 
> > The right fix for these is sending the right infoframes, _not_ trying
> > to fiddle with overscan margins. Only the kernel can make sure the
> > right infoframes are sent out. If you try to paper over this in
> > userspace, you'll make the situation worse, not better (because
> > fiddling with overscan means you get scaling, and so rescaling
> > artifacts, and for hard contrasts along pixel lines that'll look like
> > crap).
> > 
> > So yeah this is a case of "most upstream hdmi drivers are broken".
> > Please don't try to fix kernel bugs in userspace.
> 
> ACK.
> 
> > > > > I think I'll still like to have something clarified before we merge it:
> > > > > if userspace forces a mode, does it contain the margins or not? I don't
> > > > > have an opinion there, I just think it should be documented.
> > > >
> > > > The mode comes with the margins, so if userspace does something really
> > > > funny then either it gets garbage (as in, part of it's crtc area isn't
> > > > visible, or maybe black bars on the screen), or the driver rejects it
> > > > (which I think is the case for panels, they only take their mode and
> > > > nothing else).
> > >
> > > Panels can usually be quite flexible when it comes to the timings they
> > > accept, and we could actually use that to our advantage, but even if we
> > > assume that they have a single mode, I don't think we have anything that
> > > enforces that, either at the framework or documentation levels?
> > 
> > Maybe more bugs? We've been slowly filling out all kinds of atomic kms
> > validation bugs in core/helper code because as a rule of thumb,
> > drivers get it wrong. Developers test until things work, then call it
> > good enough, and very few driver teams make a serious effort in trying
> > to really validate all invalid input. Because doing that is an
> > enormous amount of work.
> > 
> > I think for clear-cut cases like drm_panel the fix is to just put more
> > stricter validation into shared code (and then if we break something,
> > figure out how we can be sufficiently lenient again).
> 
> Panels are kind of weird, since they essentially don't exist at all in
> the framework so it's difficult to make it handle them or their state.
> 
> It's typically handled by encoders directly, so each and every driver
> would need to make that check, and from a quick grep, none of them are
> (for the reasons you said).

I think the panel bridge driver infra is the right spot to put this, and
then push drivers a bit more towards using that.

Because yeah if they hand-roll the panel integration, they'll probably
miss a lot of these details :-/
-Sima

> 
> Just like for HDMI, even though we can commit to changing those facts,
> it won't happen overnight, so to circle back to that series, I'd like a
> comment in the driver when the partial mode is enabled that if userspace
> ever pushes a mode different from the expected one, we'll add the margins.
> 
> That way, if and when we come back to it, we'll know what the original
> intent and semantics were.
> 
> Maxime