From: "Jouni Högander" <jouni.hogander@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: "Jani Nikula" <jani.nikula@intel.com>,
"Rodrigo Siqueira" <Rodrigo.Siqueira@amd.com>,
"Mika Kahola" <mika.kahola@intel.com>,
"Jouni Högander" <jouni.hogander@intel.com>
Subject: [PATCH 2/3] drm/amdgpu_dm: Use split out luminance calculation function
Date: Tue, 26 Apr 2022 15:30:43 +0300 [thread overview]
Message-ID: <20220426123044.320415-3-jouni.hogander@intel.com> (raw)
In-Reply-To: <20220426123044.320415-1-jouni.hogander@intel.com>
Luminance range was split out into drm_edid.c to share the calculation
function. Use this new interface for caps->aux_max_input_signal and
caps->aux_min_input_signal.
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Jouni Högander <jouni.hogander@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 2ade82cfb1ac..49c03400e962 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -2836,15 +2836,11 @@ 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_cll, 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};
int i;
if (!aconnector || !aconnector->dc_link)
@@ -2866,8 +2862,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_cll = conn_base->hdr_sink_metadata.hdmi_type1.max_cll;
- 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 ||
@@ -2879,31 +2873,10 @@ 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_cll >> 5;
- r = max_cll % 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;
+ if (!drm_luminance_range_from_static_hdr_metadata(conn_base,
+ &caps->aux_min_input_signal,
+ &caps->aux_max_input_signal))
+ DRM_ERROR("No backligt range in static hdr metadata\n");
}
void amdgpu_dm_update_connector_after_detect(
--
2.25.1
next prev parent reply other threads:[~2022-04-26 12:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 12:30 [PATCH 0/3] HDR aux backlight range calculation Jouni Högander
2022-04-26 12:30 ` [PATCH 1/3] drm: New function to get luminance range based on static hdr metadata Jouni Högander
2022-04-26 13:37 ` Jani Nikula
2022-04-26 18:27 ` Navare, Manasi D
2022-04-26 12:30 ` Jouni Högander [this message]
2022-04-26 12:30 ` [PATCH 3/3] drm/i915: Use luminance range from " Jouni Högander
2022-04-27 18:57 ` [PATCH 0/3] HDR aux backlight range calculation Lyude Paul
2022-04-29 23:34 ` Lyude Paul
2022-05-02 5:25 ` Hogander, Jouni
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=20220426123044.320415-3-jouni.hogander@intel.com \
--to=jouni.hogander@intel.com \
--cc=Rodrigo.Siqueira@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=mika.kahola@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox