Re: [PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-26 Thread Jani Nikula
On Thu, 21 Mar 2024, gareth...@intel.com wrote:
> From: Gareth Yu 
>
> Turn on the panel from zero brightness of the last state, the panel was
> set a maximum PWM in the flow. Once the panel initialization is completed,
> the backlight is restored to xero brightness. There is a flckering
> generated. This flicker happens in "Screen dimming and power off" of
> Google's design and resume from sleep. The sample of DMESG is below.
>
> (suspend)
> [53949.248875] i915 :00:02.0: [drm:intel_edp_backlight_off]
> [53949.452046] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
> backlight PWM = 0
>
> (wakeup)
> [53986.067356] i915 :00:02.0: [drm:intel_edp_backlight_on]
> [53986.067367] i915 :00:02.0: [drm:intel_backlight_enable] pipe A
> [53986.067476] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
> backlight PWM = 96000
> [53986.119766] backlight intel_backlight: PM: calling 
> backlight_resume+0x0/0x7a @ 4916, parent: card0-eDP-1
> [53986.119781] backlight intel_backlight: PM: backlight_resume+0x0/0x7a 
> returned 0 after 0 usecs
> [53986.220068] [drm:intel_backlight_device_update_status] updating 
> intel_backlight, brightness=26321/96000
> [53986.220086] i915 :00:02.0: [drm:intel_panel_actually_set_backlight] 
> set backlight level = 27961
>
> Set the brightness to the minimum value when the new brightness is less
> or equal to the minimum value to mitigate this flickering.

Thanks for the patch. I've pushed this to drm-intel-next, but took the
liberty to rewrite the commit message:

commit 92714006eb4d10ddfaa0eca41c81e6b483e02f93
Author: Gareth Yu 
Date:   Thu Mar 21 12:53:11 2024 +0800

drm/i915/backlight: Do not bump min brightness to max on enable

Historically the expectation was to set brightness to max on enable, if
it was zero. However, the policy should be to preserve brightness across
disable/enable, for example the userspace might want to dim the
brightness before disable (e.g. on suspend) and gradually bring it back
up after enable (e.g. on resume). If the brightness gets bumped to max
at enable, this causes flicker as the userspace expects the brightness
to have been preserved across disable/enable.

For example:

(suspend)
[53949.248875] i915 :00:02.0: [drm:intel_edp_backlight_off]
[53949.452046] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 0

(wakeup)
[53986.067356] i915 :00:02.0: [drm:intel_edp_backlight_on]
[53986.067367] i915 :00:02.0: [drm:intel_backlight_enable] pipe A
[53986.067476] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 96000
[53986.119766] backlight intel_backlight: PM: calling 
backlight_resume+0x0/0x7a @ 4916, parent: card0-eDP-1
[53986.119781] backlight intel_backlight: PM: backlight_resume+0x0/0x7a 
returned 0 after 0 usecs
[53986.220068] [drm:intel_backlight_device_update_status] updating 
intel_backlight, brightness=26321/96000
[53986.220086] i915 :00:02.0: [drm:intel_panel_actually_set_backlight] 
set backlight level = 27961

Reduce the check to respecting the minimum brightness, and avoid bumping
min brightness to max on enable.

Note: It's possible there's still userspace out there that relies on the
old behaviour. It would be unfortunate, but there's really only one way
to find out.

Fingers crossed, let's hope nothing regresses.

BR,
Jani.


>
> Cc : Tejas Upadhyay 
> Cc : Matt Roper 
> Cc : Ville Syrjälä 
> Signed-off-by: Gareth Yu 
> ---
>  drivers/gpu/drm/i915/display/intel_backlight.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c 
> b/drivers/gpu/drm/i915/display/intel_backlight.c
> index 3f3cd944a1c5..23fd011b6bfb 100644
> --- a/drivers/gpu/drm/i915/display/intel_backlight.c
> +++ b/drivers/gpu/drm/i915/display/intel_backlight.c
> @@ -761,8 +761,8 @@ static void __intel_backlight_enable(const struct 
> intel_crtc_state *crtc_state,
>  
>   WARN_ON(panel->backlight.max == 0);
>  
> - if (panel->backlight.level <= panel->backlight.min) {
> - panel->backlight.level = panel->backlight.max;
> + if (panel->backlight.level < panel->backlight.min) {
> + panel->backlight.level = panel->backlight.min;
>   if (panel->backlight.device)
>   panel->backlight.device->props.brightness =
>   scale_hw_to_user(connector,

-- 
Jani Nikula, Intel


[PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-20 Thread gareth . yu
From: Gareth Yu 

Turn on the panel from zero brightness of the last state, the panel was
set a maximum PWM in the flow. Once the panel initialization is completed,
the backlight is restored to xero brightness. There is a flckering
generated. This flicker happens in "Screen dimming and power off" of
Google's design and resume from sleep. The sample of DMESG is below.

(suspend)
[53949.248875] i915 :00:02.0: [drm:intel_edp_backlight_off]
[53949.452046] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 0

(wakeup)
[53986.067356] i915 :00:02.0: [drm:intel_edp_backlight_on]
[53986.067367] i915 :00:02.0: [drm:intel_backlight_enable] pipe A
[53986.067476] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 96000
[53986.119766] backlight intel_backlight: PM: calling backlight_resume+0x0/0x7a 
@ 4916, parent: card0-eDP-1
[53986.119781] backlight intel_backlight: PM: backlight_resume+0x0/0x7a 
returned 0 after 0 usecs
[53986.220068] [drm:intel_backlight_device_update_status] updating 
intel_backlight, brightness=26321/96000
[53986.220086] i915 :00:02.0: [drm:intel_panel_actually_set_backlight] set 
backlight level = 27961

Set the brightness to the minimum value when the new brightness is less
or equal to the minimum value to mitigate this flickering.

Cc : Tejas Upadhyay 
Cc : Matt Roper 
Cc : Ville Syrjälä 
Signed-off-by: Gareth Yu 
---
 drivers/gpu/drm/i915/display/intel_backlight.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c 
b/drivers/gpu/drm/i915/display/intel_backlight.c
index 3f3cd944a1c5..23fd011b6bfb 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -761,8 +761,8 @@ static void __intel_backlight_enable(const struct 
intel_crtc_state *crtc_state,
 
WARN_ON(panel->backlight.max == 0);
 
-   if (panel->backlight.level <= panel->backlight.min) {
-   panel->backlight.level = panel->backlight.max;
+   if (panel->backlight.level < panel->backlight.min) {
+   panel->backlight.level = panel->backlight.min;
if (panel->backlight.device)
panel->backlight.device->props.brightness =
scale_hw_to_user(connector,
-- 
2.25.1



RE: [PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-18 Thread Yu, Gareth
https://patchwork.freedesktop.org/patch/582411/?series=130780=2 provides 
the scenario and the details of DMESG in the commit message on rev#1. I'll 
assume we'll go with rev#2.

Thanks,
Gareth

-Original Message-
From: Jani Nikula  
Sent: Monday, March 18, 2024 9:45 PM
To: Dolan Liu ; Ville Syrjälä 

Cc: Yu, Gareth ; intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/display: Fixed a screen flickering when turning 
on display from off

...

As far as the change goes, the original patch is pretty much the only one we 
should consider. I only ever asked for 1) an issue to be reported at fdo 
gitlab, and 2) a commit message properly detailing the issue.

I never asked for functional changes in the patch. Frankly, all the alternative 
versions are nonsense.

I think we can try to go with the patch, but please understand that if it 
regresses some silly userspace, the change will be reverted instead of fixing 
that silly userspace, because that's the rule in kernel development.


BR,
Jani.


PS. Please try to reply inline instead of top-posting in public mailing lists.



Re: [PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-18 Thread Jani Nikula
On Mon, 18 Mar 2024, Dolan Liu  wrote:
> this case have been there so many years, it's time to fix it if 
> possible. And user-space software may improved by themselves in we 
> didn't realize place.
>
> even if not,  for the proof user-space setting  0, it's better to change to
>
>
>     if (level < min || level == 0 )
>
>      level =max;
>
>
> Intel default FSP will set the default min is 2% (6/255). if someone 
> missed the setting, it will be keep the default and level.min will be 
> larger than 0.
>
> if someone changed the default min in VBT or coreboot, the user-space 
> lowest level set as 0, still can go though to this logic.
>
>
> whatever, we think this one should correct back, otherwise it will keep 
> occurring in each new kernel release on all Intel device, this is not 
> very friendly to all developers.
>
> and the only fix way is  hack patch to remove "level=max".

As far as the change goes, the original patch is pretty much the only
one we should consider. I only ever asked for 1) an issue to be reported
at fdo gitlab, and 2) a commit message properly detailing the issue.

I never asked for functional changes in the patch. Frankly, all the
alternative versions are nonsense.

I think we can try to go with the patch, but please understand that if
it regresses some silly userspace, the change will be reverted instead
of fixing that silly userspace, because that's the rule in kernel
development.


BR,
Jani.


PS. Please try to reply inline instead of top-posting in public mailing
lists.



>
>
> On 3/15/24 19:02, Ville Syrjälä wrote:
>> On Wed, Mar 06, 2024 at 12:19:42PM +0200, Jani Nikula wrote:
>>> On Wed, 06 Mar 2024, gareth...@intel.com wrote:
 From: Gareth Yu 

 Turn on the panel from zero brightness of the last state, the panel was set
 a maximum PWM in the flow. Once the panel initialization is completed, the
 backlight is restored to zero brightness. There is a flckering generated.
>>> Please be more precise in describing what exactly happens and
>>> when. Driver probe? Modeset? What restores backlight to zero brightness?
>>>
>>> Better yet, please file a bug at fdo gitlab, attach full dmesg with
>>> debugs, etc.
>>>
>>> Before we had the concept of minimum brightness, the minimum was always
>>> 0. And the check was:
>>>
>>> if (level == 0)
>>> level = max;
>>>
>>> Historically, the point was, if you're enabling the display and
>>> backlight, you don't want it to be at 0 brightness, because for most
>>> displays that means a black screen.
>> I think that hack was originally added becaue some silly
>> userspace thingy was setting the backlight level to 0 on
>> suspend/etc. and then forgetting to restore it back to a
>> sane value afterwards. Dunno if that nonsense behaviour
>> still persists to this day.
>>

-- 
Jani Nikula, Intel


Re: [PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-18 Thread Dolan Liu



this case have been there so many years, it's time to fix it if 
possible. And user-space software may improved by themselves in we 
didn't realize place.


even if not,  for the proof user-space setting  0, it's better to change to


   if (level < min || level == 0 )

    level =max;


Intel default FSP will set the default min is 2% (6/255). if someone 
missed the setting, it will be keep the default and level.min will be 
larger than 0.


if someone changed the default min in VBT or coreboot, the user-space 
lowest level set as 0, still can go though to this logic.



whatever, we think this one should correct back, otherwise it will keep 
occurring in each new kernel release on all Intel device, this is not 
very friendly to all developers.


and the only fix way is  hack patch to remove "level=max".


On 3/15/24 19:02, Ville Syrjälä wrote:

On Wed, Mar 06, 2024 at 12:19:42PM +0200, Jani Nikula wrote:

On Wed, 06 Mar 2024, gareth...@intel.com wrote:

From: Gareth Yu 

Turn on the panel from zero brightness of the last state, the panel was set
a maximum PWM in the flow. Once the panel initialization is completed, the
backlight is restored to zero brightness. There is a flckering generated.

Please be more precise in describing what exactly happens and
when. Driver probe? Modeset? What restores backlight to zero brightness?

Better yet, please file a bug at fdo gitlab, attach full dmesg with
debugs, etc.

Before we had the concept of minimum brightness, the minimum was always
0. And the check was:

if (level == 0)
level = max;

Historically, the point was, if you're enabling the display and
backlight, you don't want it to be at 0 brightness, because for most
displays that means a black screen.

I think that hack was originally added becaue some silly
userspace thingy was setting the backlight level to 0 on
suspend/etc. and then forgetting to restore it back to a
sane value afterwards. Dunno if that nonsense behaviour
still persists to this day.



RE: [PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-17 Thread Yu, Gareth
The original implementation was 47356eb67285 in Sep 17, 2001. The condition 
can't be replicated for now. 

The condition for invalid brightness level includes the minimum available 
value. It does not make sense. I've added the new condition in rev #5. Please 
consider if the condition is workable.

-   if (panel->backlight.level <= panel->backlight.min) {
+   if (panel->backlight.level < panel->backlight.min) {

Thanks,
Gareth

-Original Message-
From: Ville Syrjälä  
Sent: Friday, March 15, 2024 7:03 PM
To: Jani Nikula 
Cc: Yu, Gareth ; intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/display: Fixed a screen flickering when turning 
on display from off

On Wed, Mar 06, 2024 at 12:19:42PM +0200, Jani Nikula wrote:
> On Wed, 06 Mar 2024, gareth...@intel.com wrote:
> > From: Gareth Yu 
> >
> > Turn on the panel from zero brightness of the last state, the panel 
> > was set a maximum PWM in the flow. Once the panel initialization is 
> > completed, the backlight is restored to zero brightness. There is a 
> > flckering generated.
> 
> Please be more precise in describing what exactly happens and when. 
> Driver probe? Modeset? What restores backlight to zero brightness?
> 
> Better yet, please file a bug at fdo gitlab, attach full dmesg with 
> debugs, etc.
> 
> Before we had the concept of minimum brightness, the minimum was 
> always 0. And the check was:
> 
>   if (level == 0)
>   level = max;
> 
> Historically, the point was, if you're enabling the display and 
> backlight, you don't want it to be at 0 brightness, because for most 
> displays that means a black screen.

I think that hack was originally added becaue some silly userspace thingy was 
setting the backlight level to 0 on suspend/etc. and then forgetting to restore 
it back to a sane value afterwards. Dunno if that nonsense behaviour still 
persists to this day.

--
Ville Syrjälä
Intel


[PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-17 Thread gareth . yu
From: Gareth Yu 

Turn on the panel from zero brightness of the last state, the panel was
set a maximum PWM in the flow. Once the panel initialization is completed,
the backlight is restored to xero brightness. There is a flckering
generated. This flicker happens in "Screen dimming and power off" of
Google's design and resume from sleep. The sample of DMESG is below.

(suspend)
[53949.248875] i915 :00:02.0: [drm:intel_edp_backlight_off]
[53949.452046] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 0

(wakeup)
[53986.067356] i915 :00:02.0: [drm:intel_edp_backlight_on]
[53986.067367] i915 :00:02.0: [drm:intel_backlight_enable] pipe A
[53986.067476] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 96000
[53986.119766] backlight intel_backlight: PM: calling backlight_resume+0x0/0x7a 
@ 4916, parent: card0-eDP-1
[53986.119781] backlight intel_backlight: PM: backlight_resume+0x0/0x7a 
returned 0 after 0 usecs
[53986.220068] [drm:intel_backlight_device_update_status] updating 
intel_backlight, brightness=26321/96000
[53986.220086] i915 :00:02.0: [drm:intel_panel_actually_set_backlight] set 
backlight level = 27961

Set the brightness to the minimum value when the brightness is less or
equal to the minimum value to mitigate this flickering.

Cc : Tejas Upadhyay 
Cc : Matt Roper 
Cc : Ville Syrjälä 
Signed-off-by: Gareth Yu 
---
 drivers/gpu/drm/i915/display/intel_backlight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c 
b/drivers/gpu/drm/i915/display/intel_backlight.c
index 3f3cd944a1c5..1cfac72aacc6 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -761,7 +761,7 @@ static void __intel_backlight_enable(const struct 
intel_crtc_state *crtc_state,
 
WARN_ON(panel->backlight.max == 0);
 
-   if (panel->backlight.level <= panel->backlight.min) {
+   if (panel->backlight.level < panel->backlight.min) {
panel->backlight.level = panel->backlight.max;
if (panel->backlight.device)
panel->backlight.device->props.brightness =
-- 
2.25.1



Re: [PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-15 Thread Ville Syrjälä
On Wed, Mar 06, 2024 at 12:19:42PM +0200, Jani Nikula wrote:
> On Wed, 06 Mar 2024, gareth...@intel.com wrote:
> > From: Gareth Yu 
> >
> > Turn on the panel from zero brightness of the last state, the panel was set
> > a maximum PWM in the flow. Once the panel initialization is completed, the
> > backlight is restored to zero brightness. There is a flckering generated.
> 
> Please be more precise in describing what exactly happens and
> when. Driver probe? Modeset? What restores backlight to zero brightness?
> 
> Better yet, please file a bug at fdo gitlab, attach full dmesg with
> debugs, etc.
> 
> Before we had the concept of minimum brightness, the minimum was always
> 0. And the check was:
> 
>   if (level == 0)
>   level = max;
> 
> Historically, the point was, if you're enabling the display and
> backlight, you don't want it to be at 0 brightness, because for most
> displays that means a black screen.

I think that hack was originally added becaue some silly
userspace thingy was setting the backlight level to 0 on
suspend/etc. and then forgetting to restore it back to a
sane value afterwards. Dunno if that nonsense behaviour
still persists to this day.

-- 
Ville Syrjälä
Intel


[PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-15 Thread gareth . yu
From: Gareth Yu 

Turn on the panel from zero brightness of the last state, the panel was
set a maximum PWM in the flow. Once the panel initialization is completed,
the backlight is restored to xero brightness. There is a flckering
generated. This flicker happens in "Screen dimming and power off" of
Google's design and resume from sleep. The sample of DMESG is below.

(suspend)
[53949.248875] i915 :00:02.0: [drm:intel_edp_backlight_off]
[53949.452046] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 0

(wakeup)
[53986.067356] i915 :00:02.0: [drm:intel_edp_backlight_on]
[53986.067367] i915 :00:02.0: [drm:intel_backlight_enable] pipe A
[53986.067476] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 96000
[53986.119766] backlight intel_backlight: PM: calling backlight_resume+0x0/0x7a 
@ 4916, parent: card0-eDP-1
[53986.119781] backlight intel_backlight: PM: backlight_resume+0x0/0x7a 
returned 0 after 0 usecs
[53986.220068] [drm:intel_backlight_device_update_status] updating 
intel_backlight, brightness=26321/96000
[53986.220086] i915 :00:02.0: [drm:intel_panel_actually_set_backlight] set 
backlight level = 27961

Set the brightness to the minimum value when the brightness is less or
equal to the minimum value to mitigate this flickering.

Cc : Tejas Upadhyay 
Cc : Matt Roper 
Cc : Ville Syrjälä 
Signed-off-by: Gareth Yu 
---
 drivers/gpu/drm/i915/display/intel_backlight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c 
b/drivers/gpu/drm/i915/display/intel_backlight.c
index 3f3cd944a1c5..c7a314b624fc 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -761,7 +761,7 @@ static void __intel_backlight_enable(const struct 
intel_crtc_state *crtc_state,
 
WARN_ON(panel->backlight.max == 0);
 
-   if (panel->backlight.level <= panel->backlight.min) {
+   if (panel->backlight.level == 0) {
panel->backlight.level = panel->backlight.max;
if (panel->backlight.device)
panel->backlight.device->props.brightness =
-- 
2.25.1



[PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-11 Thread gareth . yu
From: Gareth Yu 

Turn on the panel from zero brightness of the last state, the panel was
set a maximum PWM in the flow. Once the panel initialization is completed,
the backlight is restored to xero brightness. There is a flckering
generated. This flicker happens in "Screen dimming and power off" of
Google's design and resume from sleep. The sample of DMESG is below.

(suspend)
[53949.248875] i915 :00:02.0: [drm:intel_edp_backlight_off]
[53949.452046] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 0

(wakeup)
[53986.067356] i915 :00:02.0: [drm:intel_edp_backlight_on]
[53986.067367] i915 :00:02.0: [drm:intel_backlight_enable] pipe A
[53986.067476] i915 :00:02.0: [drm:intel_backlight_set_pwm_level] set 
backlight PWM = 96000
[53986.119766] backlight intel_backlight: PM: calling backlight_resume+0x0/0x7a 
@ 4916, parent: card0-eDP-1
[53986.119781] backlight intel_backlight: PM: backlight_resume+0x0/0x7a 
returned 0 after 0 usecs
[53986.220068] [drm:intel_backlight_device_update_status] updating 
intel_backlight, brightness=26321/96000
[53986.220086] i915 :00:02.0: [drm:intel_panel_actually_set_backlight] set 
backlight level = 27961

Set the brightness to the minimum value when the brightness is less or
equal to the minimum value to mitigate this flickering.

Cc : Tejas Upadhyay 
Cc : Matt Roper 
Cc : Ville Syrjälä 
Signed-off-by: Gareth Yu 
---
 drivers/gpu/drm/i915/display/intel_backlight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c 
b/drivers/gpu/drm/i915/display/intel_backlight.c
index 3f3cd944a1c5..855d6ead905c 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -762,7 +762,7 @@ static void __intel_backlight_enable(const struct 
intel_crtc_state *crtc_state,
WARN_ON(panel->backlight.max == 0);
 
if (panel->backlight.level <= panel->backlight.min) {
-   panel->backlight.level = panel->backlight.max;
+   panel->backlight.level = panel->backlight.min;
if (panel->backlight.device)
panel->backlight.device->props.brightness =
scale_hw_to_user(connector,
-- 
2.25.1



Re: [PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-06 Thread Jani Nikula
On Wed, 06 Mar 2024, gareth...@intel.com wrote:
> From: Gareth Yu 
>
> Turn on the panel from zero brightness of the last state, the panel was set
> a maximum PWM in the flow. Once the panel initialization is completed, the
> backlight is restored to zero brightness. There is a flckering generated.

Please be more precise in describing what exactly happens and
when. Driver probe? Modeset? What restores backlight to zero brightness?

Better yet, please file a bug at fdo gitlab, attach full dmesg with
debugs, etc.

Before we had the concept of minimum brightness, the minimum was always
0. And the check was:

if (level == 0)
level = max;

Historically, the point was, if you're enabling the display and
backlight, you don't want it to be at 0 brightness, because for most
displays that means a black screen.

BR,
Jani.


> Set the brightness to the minimum value when the brightness is less or equal
> to the minimum value to fix this flickering
>
> Cc : Tejas Upadhyay 
> Cc : Matt Roper 
> Cc : Ville Syrjälä 
> Signed-off-by: Gareth Yu 
> ---
>  drivers/gpu/drm/i915/display/intel_backlight.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c 
> b/drivers/gpu/drm/i915/display/intel_backlight.c
> index 3f3cd944a1c5..855d6ead905c 100644
> --- a/drivers/gpu/drm/i915/display/intel_backlight.c
> +++ b/drivers/gpu/drm/i915/display/intel_backlight.c
> @@ -762,7 +762,7 @@ static void __intel_backlight_enable(const struct 
> intel_crtc_state *crtc_state,
>   WARN_ON(panel->backlight.max == 0);
>  
>   if (panel->backlight.level <= panel->backlight.min) {
> - panel->backlight.level = panel->backlight.max;
> + panel->backlight.level = panel->backlight.min;
>   if (panel->backlight.device)
>   panel->backlight.device->props.brightness =
>   scale_hw_to_user(connector,

-- 
Jani Nikula, Intel


[PATCH] drm/i915/display: Fixed a screen flickering when turning on display from off

2024-03-05 Thread gareth . yu
From: Gareth Yu 

Turn on the panel from zero brightness of the last state, the panel was set
a maximum PWM in the flow. Once the panel initialization is completed, the
backlight is restored to zero brightness. There is a flckering generated.

Set the brightness to the minimum value when the brightness is less or equal
to the minimum value to fix this flickering

Cc : Tejas Upadhyay 
Cc : Matt Roper 
Cc : Ville Syrjälä 
Signed-off-by: Gareth Yu 
---
 drivers/gpu/drm/i915/display/intel_backlight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c 
b/drivers/gpu/drm/i915/display/intel_backlight.c
index 3f3cd944a1c5..855d6ead905c 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -762,7 +762,7 @@ static void __intel_backlight_enable(const struct 
intel_crtc_state *crtc_state,
WARN_ON(panel->backlight.max == 0);
 
if (panel->backlight.level <= panel->backlight.min) {
-   panel->backlight.level = panel->backlight.max;
+   panel->backlight.level = panel->backlight.min;
if (panel->backlight.device)
panel->backlight.device->props.brightness =
scale_hw_to_user(connector,
-- 
2.25.1