All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Christopher Obbard <christopher.obbard@linaro.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	Rui Miguel Silva <rui.silva@linaro.org>,
	Abel Vesa <abel.vesa@linaro.org>
Subject: Re: [PATCH v6] drm/dp: clamp PWM bit count to advertised MIN and MAX capabilities
Date: Thu, 24 Jul 2025 11:50:20 +0200	[thread overview]
Message-ID: <aIIB3G6WEEzldXEn@hovoldconsulting.com> (raw)
In-Reply-To: <a9df2561-95d4-47a5-b5df-5874b71937a6@linaro.org>

On Thu, Jul 24, 2025 at 11:42:38AM +0200, Neil Armstrong wrote:
> On 24/07/2025 11:32, Dmitry Baryshkov wrote:
> > On Thu, 24 Jul 2025 at 12:08, <neil.armstrong@linaro.org> wrote:
> >> On 20/05/2025 10:06, Johan Hovold wrote:
> >>> On Fri, Apr 04, 2025 at 02:24:32PM +0100, Christopher Obbard wrote:
> >>>> On Fri, 4 Apr 2025 at 09:54, Johan Hovold <johan@kernel.org> wrote:
> >>>>> On Fri, Apr 04, 2025 at 08:54:29AM +0100, Christopher Obbard wrote:
> >>>>>> On Mon, 31 Mar 2025 at 09:33, Johan Hovold <johan@kernel.org> wrote:

> >>>>>>>> +     /*
> >>>>>>>> +      * Per VESA eDP Spec v1.4b, section 3.3.10.2:
> >>>>>>>> +      * If DP_EDP_PWMGEN_BIT_COUNT is less than DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN,
> >>>>>>>> +      * the sink must use the MIN value as the effective PWM bit count.
> >>>>>>>> +      * Clamp the reported value to the [MIN, MAX] capability range to ensure
> >>>>>>>> +      * correct brightness scaling on compliant eDP panels.
> >>>>>>>> +      */
> >>>>>>>> +     pn = clamp(pn, pn_min, pn_max);
> >>>>>>>
> >>>>>>> You never make sure that pn_min <= pn_max so you could end up with
> >>>>>>> pn < pn_min on broken hardware here. Not sure if it's something you need
> >>>>>>> to worry about at this point.
> >>
> >> I'm trying to figure out what would be the behavior in this case ?
> >>
> >> - Warn ?
> >> - pn_max = pn_min ?
> >> - use BIT_COUNT as-is and ignore MIN/MAX ?
> >> - pm_max = max(pn_min, pn_max); pm_min = min(pn_min, pn_max); ?
> >> - reverse clamp? clamp(pn, pn_max, pn_min); ?
> >> - generic clamp? clamp(pn, min(pn_min, pn_max), max(pn_min, pn_max)); ?
> > 
> > Per the standard, the min >= 1 and max >= min. We don't need to bother
> > about anything here.
> 
> Yeah, I agree. But I think a:
> if (likely(pn_min <= pn_max))
> is simple and doesn't cost much...

> >> Or just bail out ?

Yeah, just bail out. If we ever run into broken hardware like this, we
can determine some workaround then.

Johan

  reply	other threads:[~2025-07-24  9:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-30 19:31 [PATCH v6] drm/dp: clamp PWM bit count to advertised MIN and MAX capabilities Christopher Obbard
2025-03-30 21:04 ` Dmitry Baryshkov
2025-03-31  8:33 ` Johan Hovold
2025-04-04  7:54   ` Christopher Obbard
2025-04-04  8:54     ` Johan Hovold
2025-04-04 13:24       ` Christopher Obbard
2025-05-20  8:06         ` Johan Hovold
2025-07-24  9:08           ` neil.armstrong
2025-07-24  9:32             ` Dmitry Baryshkov
2025-07-24  9:42               ` Neil Armstrong
2025-07-24  9:50                 ` Johan Hovold [this message]
2025-07-24 11:09                 ` Dmitry Baryshkov
2025-08-04 13:22                   ` Johan Hovold
2025-08-05  5:07                     ` Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aIIB3G6WEEzldXEn@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=abel.vesa@linaro.org \
    --cc=airlied@gmail.com \
    --cc=christopher.obbard@linaro.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rui.silva@linaro.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.