lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACr-zFBwbniB3H5cnq0higsX6a_G4Be26N-nNL8JAzci8y9_Mw@mail.gmail.com>
Date: Thu, 27 Mar 2025 18:19:07 +0000
From: Christopher Obbard <christopher.obbard@...aro.org>
To: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard <mripard@...nel.org>, 
	Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, 
	dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org, 
	linux-arm-msm@...r.kernel.org, Johan Hovold <johan@...nel.org>, 
	Rui Miguel Silva <rui.silva@...aro.org>, Abel Vesa <abel.vesa@...aro.org>
Subject: Re: [PATCH v2] drm/dp: fallback to minimum when PWM bit count is zero

Hi Dmitry,

On Thu, 27 Mar 2025 at 17:40, Dmitry Baryshkov
<dmitry.baryshkov@....qualcomm.com> wrote:
>
> On 27/03/2025 19:25, Christopher Obbard wrote:
> > According to the eDP specification (e.g., VESA eDP 1.4b, section 3.3.10.2),
> > if DP_EDP_PWMGEN_BIT_COUNT is less than DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN,
> > the sink is required to use the MIN value as the effective bit count.
> >
> > Some eDP panels report DP_EDP_PWMGEN_BIT_COUNT as 0 while still providing
> > valid non-zero MIN and MAX capability values. This patch updates the logic
> > to use the CAP_MIN value in such cases, ensuring correct scaling of AUX-set
> > backlight brightness values.
> >
> > This improves compatibility with panels like the Samsung ATNA40YK20 used
> > on the Lenovo T14s Gen6 (Snapdragon variant with OLED) which report a
> > bit count of 0 but declares an 11-bit PWM capability range.
> >
> > Co-developed-by: Rui Miguel Silva <rui.silva@...aro.org>
> > Signed-off-by: Rui Miguel Silva <rui.silva@...aro.org>
> > Signed-off-by: Christopher Obbard <christopher.obbard@...aro.org>
> > ---
> > Changes in v2:
> > - Split backlight brightness patch from T14s OLED enablement series.
> > - Use PWMGEN_CAP_MIN rather than MAX (Dmitry).
> > - Rework commit message to reference eDP spec.
> > - Rebase on drm-misc-next.
> > - Link to v1: https://lore.kernel.org/all/20250325-wip-obbardc-qcom-t14s-oled-panel-v2-4-e9bc7c9d30cc@linaro.org/
> > ---
> >   drivers/gpu/drm/display/drm_dp_helper.c | 50 ++++++++++++++++++++++-----------
> >   1 file changed, 33 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
> > index dbce1c3f49691fc687fee2404b723c73d533f23d..0b843d5b634f89f144b62b30311834d118b79ba9 100644
> > --- a/drivers/gpu/drm/display/drm_dp_helper.c
> > +++ b/drivers/gpu/drm/display/drm_dp_helper.c
> > @@ -4083,7 +4083,7 @@ drm_edp_backlight_probe_max(struct drm_dp_aux *aux, struct drm_edp_backlight_inf
> >   {
> >       int fxp, fxp_min, fxp_max, fxp_actual, f = 1;
> >       int ret;
> > -     u8 pn, pn_min, pn_max;
> > +     u8 pn, pn_min, pn_max, bl_caps;
> >
> >       if (!bl->aux_set)
> >               return 0;
> > @@ -4094,8 +4094,39 @@ drm_edp_backlight_probe_max(struct drm_dp_aux *aux, struct drm_edp_backlight_inf
> >                           aux->name, ret);
> >               return -ENODEV;
> >       }
> > -
> >       pn &= DP_EDP_PWMGEN_BIT_COUNT_MASK;
> > +
> > +     ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN, &pn_min);
> > +     if (ret != 1) {
> > +             drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap min: %d\n",
> > +                         aux->name, ret);
> > +             return 0;
> > +     }
> > +     pn_min &= DP_EDP_PWMGEN_BIT_COUNT_MASK;
> > +
> > +     ret = drm_dp_dpcd_readb(aux, DP_EDP_PWMGEN_BIT_COUNT_CAP_MAX, &pn_max);
> > +     if (ret != 1) {
> > +             drm_dbg_kms(aux->drm_dev, "%s: Failed to read pwmgen bit count cap max: %d\n",
> > +                         aux->name, ret);
> > +             return 0;
> > +     }
> > +     pn_max &= DP_EDP_PWMGEN_BIT_COUNT_MASK;
> > +
> > +     ret = drm_dp_dpcd_readb(aux, DP_EDP_BACKLIGHT_ADJUSTMENT_CAP, &bl_caps);
> > +     if (ret != 1) {
> > +             bl_caps = 0;
> > +             drm_dbg_kms(aux->drm_dev, "%s: Failed to read backlight adjustment cap: %d\n",
> > +                     aux->name, ret);
> > +     }
> > +
> > +     /*
> > +      * Some eDP panels report brightness byte count support, but the byte count
> > +      * reading is 0 (e.g. Samsung ATNA40YK20) so use pn_min instead.
> > +      */
> > +     if (!pn && (bl_caps & DP_EDP_BACKLIGHT_BRIGHTNESS_BYTE_COUNT)
> > +         && pn_min)
> > +             pn = pn_min;
>
> I wonder, what stops you from implementing this part according to the
> standard, rather than adding a hack for 0 value.

I am simply quite dense, I do not know this spec or the DRM code well
at all ;-).
I do appreciate your continued reviews though, however painful it must be.

Before I send v3, can I clarify a proper solution?
I think you are saying that I can remove the section where I read the
capabilities and instead simply have something like (in pseudocode):

/* Determine effective bit count according to eDP spec */
u8 effective_bit_count = pwm_bit_count;
if (pwm_bit_count == 0 || pwm_bit_count < cap_min) {
    effective_bit_count = cap_min;
}

I would like to introduce this new variable to make the code easier to read.

If my understanding is correct, I'll send a v3 later.


> > +
> >       bl->max = (1 << pn) - 1;
> >       if (!driver_pwm_freq_hz)
> >               return 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ