[PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function

Jani Nikula jani.nikula at intel.com
Fri Aug 12 07:04:44 UTC 2022


On Thu, 11 Aug 2022, "Deucher, Alexander" <Alexander.Deucher at amd.com> wrote:
> [Public]
>
>> -----Original Message-----
>> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Jani
>> Nikula
>> Sent: Thursday, August 4, 2022 5:55 AM
>> To: Jouni Högander <jouni.hogander at intel.com>; dri-
>> devel at lists.freedesktop.org; intel-gfx at lists.freedesktop.org; amd-
>> gfx at lists.freedesktop.org
>> Cc: Siqueira, Rodrigo <Rodrigo.Siqueira at amd.com>; Li, Roman
>> <Roman.Li at amd.com>; Manasi Navare <manasi.d.navare at intel.com>; Mika
>> Kahola <mika.kahola at intel.com>; Jouni Högander
>> <jouni.hogander at intel.com>; Wentland, Harry
>> <Harry.Wentland at amd.com>
>> Subject: Re: [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance
>> calculation function
>> 
>> On Tue, 19 Jul 2022, Jouni Högander <jouni.hogander at intel.com> wrote:
>> > Luminance range calculation was split out into drm_edid.c and is now
>> > part of edid parsing. Rely on values calculated during edid parsing
>> > and use these for caps->aux_max_input_signal and caps-
>> >aux_min_input_signal.
>> 
>> Harry, I'll merge patches 1 & 3 in this series through drm-misc-next, because I
>> think they're good to go, and fix stuff in i915.
>> 
>> Can I get your rb/ack to merge this patch as well, or do you want to take this
>> later via your tree?
>
> You can take this via drm-misc.
> Acked-by: Alex Deucher <alexander.deucher at amd.com>

Thanks, pushed the series to drm-misc-next.

BR,
Jani.

>
>
>> 
>> BR,
>> Jani.
>> 
>> 
>> >
>> > v2: Use values calculated during edid parsing
>> >
>> > Cc: Roman Li <roman.li at amd.com>
>> > Cc: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
>> > Cc: Harry Wentland <harry.wentland at amd.com>
>> > Cc: Lyude Paul <lyude at redhat.com>
>> > Cc: Mika Kahola <mika.kahola at intel.com>
>> > Cc: Jani Nikula <jani.nikula at intel.com>
>> > Cc: Manasi Navare <manasi.d.navare at intel.com>
>> > Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
>> > ---
>> >  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 35
>> > +++----------------
>> >  1 file changed, 4 insertions(+), 31 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> > b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> > index 3e83fed540e8..eb7abdeb8653 100644
>> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> > @@ -2903,15 +2903,12 @@ static struct drm_mode_config_helper_funcs
>> > amdgpu_dm_mode_config_helperfuncs = {
>> >
>> >  static void update_connector_ext_caps(struct amdgpu_dm_connector
>> > *aconnector)  {
>> > -	u32 max_avg, min_cll, max, min, q, r;
>> >  	struct amdgpu_dm_backlight_caps *caps;
>> >  	struct amdgpu_display_manager *dm;
>> >  	struct drm_connector *conn_base;
>> >  	struct amdgpu_device *adev;
>> >  	struct dc_link *link = NULL;
>> > -	static const u8 pre_computed_values[] = {
>> > -		50, 51, 52, 53, 55, 56, 57, 58, 59, 61, 62, 63, 65, 66, 68, 69,
>> > -		71, 72, 74, 75, 77, 79, 81, 82, 84, 86, 88, 90, 92, 94, 96, 98};
>> > +	struct drm_luminance_range_info *luminance_range;
>> >  	int i;
>> >
>> >  	if (!aconnector || !aconnector->dc_link) @@ -2933,8 +2930,6 @@
>> > static void update_connector_ext_caps(struct amdgpu_dm_connector
>> *aconnector)
>> >  	caps = &dm->backlight_caps[i];
>> >  	caps->ext_caps = &aconnector->dc_link->dpcd_sink_ext_caps;
>> >  	caps->aux_support = false;
>> > -	max_avg = conn_base->hdr_sink_metadata.hdmi_type1.max_fall;
>> > -	min_cll = conn_base->hdr_sink_metadata.hdmi_type1.min_cll;
>> >
>> >  	if (caps->ext_caps->bits.oled == 1 /*||
>> >  	    caps->ext_caps->bits.sdr_aux_backlight_control == 1 || @@
>> > -2946,31 +2941,9 @@ static void update_connector_ext_caps(struct
>> amdgpu_dm_connector *aconnector)
>> >  	else if (amdgpu_backlight == 1)
>> >  		caps->aux_support = true;
>> >
>> > -	/* From the specification (CTA-861-G), for calculating the maximum
>> > -	 * luminance we need to use:
>> > -	 *	Luminance = 50*2**(CV/32)
>> > -	 * Where CV is a one-byte value.
>> > -	 * For calculating this expression we may need float point precision;
>> > -	 * to avoid this complexity level, we take advantage that CV is divided
>> > -	 * by a constant. From the Euclids division algorithm, we know that
>> CV
>> > -	 * can be written as: CV = 32*q + r. Next, we replace CV in the
>> > -	 * Luminance expression and get 50*(2**q)*(2**(r/32)), hence we
>> just
>> > -	 * need to pre-compute the value of r/32. For pre-computing the
>> values
>> > -	 * We just used the following Ruby line:
>> > -	 *	(0...32).each {|cv| puts (50*2**(cv/32.0)).round}
>> > -	 * The results of the above expressions can be verified at
>> > -	 * pre_computed_values.
>> > -	 */
>> > -	q = max_avg >> 5;
>> > -	r = max_avg % 32;
>> > -	max = (1 << q) * pre_computed_values[r];
>> > -
>> > -	// min luminance: maxLum * (CV/255)^2 / 100
>> > -	q = DIV_ROUND_CLOSEST(min_cll, 255);
>> > -	min = max * DIV_ROUND_CLOSEST((q * q), 100);
>> > -
>> > -	caps->aux_max_input_signal = max;
>> > -	caps->aux_min_input_signal = min;
>> > +	luminance_range = &conn_base->display_info.luminance_range;
>> > +	caps->aux_min_input_signal = luminance_range->min_luminance;
>> > +	caps->aux_max_input_signal = luminance_range->max_luminance;
>> >  }
>> >
>> >  void amdgpu_dm_update_connector_after_detect(
>> 
>> --
>> Jani Nikula, Intel Open Source Graphics Center

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the dri-devel mailing list