* [PATCH v3 0/3] HDR aux backlight range calculation
@ 2022-07-19 9:56 Jouni Högander
2022-07-19 9:56 ` [PATCH v3 1/3] drm: New function to get luminance range based on static hdr metadata Jouni Högander
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jouni Högander @ 2022-07-19 9:56 UTC (permalink / raw)
To: dri-devel, intel-gfx, amd-gfx
Cc: Jani Nikula, Maarten Lankhorst, Rodrigo Siqueira, Roman Li,
Manasi Navare, Mika Kahola, Jouni Högander, Harry Wentland
This patch set splits out static hdr metadata backlight range parsing
from gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c into gpu/drm/drm-edid.c
as a new function. This new function is then used during edid parsing
when HDR static metadata block parsing.
Calculated values are stored in a new struct drm_luminance_range
introduced into display_info. Amdgpu_dm.c and intel_dp_aux_backlight.c
are using this new data.
v3: Some clean-ups suggested by Jani Nikula
v2: Calculate the range during edid parsing and store into display_info
Cc: Roman Li <roman.li@amd.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
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>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Jouni Högander (3):
drm: New function to get luminance range based on static hdr metadata
drm/amdgpu_dm: Rely on split out luminance calculation function
drm/i915: Use luminance range calculated during edid parsing
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 35 ++-----------
drivers/gpu/drm/drm_edid.c | 52 ++++++++++++++++++-
.../drm/i915/display/intel_dp_aux_backlight.c | 15 +++++-
include/drm/drm_connector.h | 21 ++++++++
4 files changed, 89 insertions(+), 34 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] drm: New function to get luminance range based on static hdr metadata
2022-07-19 9:56 [PATCH v3 0/3] HDR aux backlight range calculation Jouni Högander
@ 2022-07-19 9:56 ` Jouni Högander
2022-07-19 9:56 ` [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function Jouni Högander
2022-07-19 9:57 ` [PATCH v3 3/3] drm/i915: Use luminance range calculated during edid parsing Jouni Högander
2 siblings, 0 replies; 7+ messages in thread
From: Jouni Högander @ 2022-07-19 9:56 UTC (permalink / raw)
To: dri-devel, intel-gfx, amd-gfx
Cc: Jani Nikula, Rodrigo Siqueira, Roman Li, Manasi Navare,
Mika Kahola, Jouni Högander, Harry Wentland
Split luminance min/max calculation using static hdr metadata from
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:update_connector_ext_caps
into drm/drm_edid.c and use it during edid parsing. Calculated range is
stored into connector->display_info->luminance_range.
Add new data structure (drm_luminance_range_inf) to store luminance range
calculated using data from EDID's static hdr metadata block. Add this new
struct as a part of drm_display_info struct.
v3: Squashed adding drm_luminance_range_info patch here
v2: Calculate range during edid parsing
Cc: Roman Li <roman.li@amd.com>
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>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
---
drivers/gpu/drm/drm_edid.c | 52 ++++++++++++++++++++++++++++++++++++-
include/drm/drm_connector.h | 21 +++++++++++++++
2 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index bbc25e3b7220..90a5e26eafa8 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -5165,6 +5165,51 @@ static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode)
mode->clock = clock;
}
+static void drm_calculate_luminance_range(struct drm_connector *connector)
+{
+ struct hdr_static_metadata *hdr_metadata = &connector->hdr_sink_metadata.hdmi_type1;
+ struct drm_luminance_range_info *luminance_range =
+ &connector->display_info.luminance_range;
+ 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
+ };
+ u32 max_avg, min_cll, max, min, q, r;
+
+ if (!(hdr_metadata->metadata_type & BIT(HDMI_STATIC_METADATA_TYPE1)))
+ return;
+
+ max_avg = hdr_metadata->max_fall;
+ min_cll = hdr_metadata->min_cll;
+
+ /*
+ * 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);
+
+ luminance_range->min_luminance = min;
+ luminance_range->max_luminance = max;
+}
+
static uint8_t eotf_supported(const u8 *edid_ext)
{
return edid_ext[2] &
@@ -5196,8 +5241,12 @@ drm_parse_hdr_metadata_block(struct drm_connector *connector, const u8 *db)
connector->hdr_sink_metadata.hdmi_type1.max_cll = db[4];
if (len >= 5)
connector->hdr_sink_metadata.hdmi_type1.max_fall = db[5];
- if (len >= 6)
+ if (len >= 6) {
connector->hdr_sink_metadata.hdmi_type1.min_cll = db[6];
+
+ /* Calculate only when all values are available */
+ drm_calculate_luminance_range(connector);
+ }
}
static void
@@ -6101,6 +6150,7 @@ static void drm_reset_display_info(struct drm_connector *connector)
info->non_desktop = 0;
memset(&info->monitor_range, 0, sizeof(info->monitor_range));
+ memset(&info->luminance_range, 0, sizeof(info->luminance_range));
info->mso_stream_count = 0;
info->mso_pixel_overlap = 0;
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 2c6fa746efac..248206bbd975 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -323,6 +323,22 @@ struct drm_monitor_range_info {
u8 max_vfreq;
};
+/**
+ * struct drm_luminance_range_info - Panel's luminance range for
+ * &drm_display_info. Calculated using data in EDID
+ *
+ * This struct is used to store a luminance range supported by panel
+ * as calculated using data from EDID's static hdr metadata.
+ *
+ * @min_luminance: This is the min supported luminance value
+ *
+ * @max_luminance: This is the max supported luminance value
+ */
+struct drm_luminance_range_info {
+ u32 min_luminance;
+ u32 max_luminance;
+};
+
/**
* enum drm_privacy_screen_status - privacy screen status
*
@@ -624,6 +640,11 @@ struct drm_display_info {
*/
struct drm_monitor_range_info monitor_range;
+ /**
+ * @luminance_range: Luminance range supported by panel
+ */
+ struct drm_luminance_range_info luminance_range;
+
/**
* @mso_stream_count: eDP Multi-SST Operation (MSO) stream count from
* the DisplayID VESA vendor block. 0 for conventional Single-Stream
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function
2022-07-19 9:56 [PATCH v3 0/3] HDR aux backlight range calculation Jouni Högander
2022-07-19 9:56 ` [PATCH v3 1/3] drm: New function to get luminance range based on static hdr metadata Jouni Högander
@ 2022-07-19 9:56 ` Jouni Högander
2022-08-04 9:54 ` Jani Nikula
2022-07-19 9:57 ` [PATCH v3 3/3] drm/i915: Use luminance range calculated during edid parsing Jouni Högander
2 siblings, 1 reply; 7+ messages in thread
From: Jouni Högander @ 2022-07-19 9:56 UTC (permalink / raw)
To: dri-devel, intel-gfx, amd-gfx
Cc: Jani Nikula, Rodrigo Siqueira, Roman Li, Manasi Navare,
Mika Kahola, Jouni Högander, Harry Wentland
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.
v2: Use values calculated during edid parsing
Cc: Roman Li <roman.li@amd.com>
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>
Cc: Manasi Navare <manasi.d.navare@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 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(
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] drm/i915: Use luminance range calculated during edid parsing
2022-07-19 9:56 [PATCH v3 0/3] HDR aux backlight range calculation Jouni Högander
2022-07-19 9:56 ` [PATCH v3 1/3] drm: New function to get luminance range based on static hdr metadata Jouni Högander
2022-07-19 9:56 ` [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function Jouni Högander
@ 2022-07-19 9:57 ` Jouni Högander
2 siblings, 0 replies; 7+ messages in thread
From: Jouni Högander @ 2022-07-19 9:57 UTC (permalink / raw)
To: dri-devel, intel-gfx, amd-gfx
Cc: Jouni Högander, Jani Nikula, Manasi Navare, Mika Kahola
Instead of using fixed 0 - 512 range use luminance range calculated
as a part of edid parsing. As a backup fall back to static 0 - 512.
v3: Clean-ups suggested by Jani Nikula
v2: Use values calculated during edid parsing
Cc: Lyude Paul <lyude@redhat.com>
Cc: Mika Kahola <mika.kahola@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Manasi Navare <manasi.d.navare@intel.com>
Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
---
.../gpu/drm/i915/display/intel_dp_aux_backlight.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
index c92d5bb2326a..83af95bce98d 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_aux_backlight.c
@@ -278,6 +278,8 @@ intel_dp_aux_hdr_setup_backlight(struct intel_connector *connector, enum pipe pi
{
struct drm_i915_private *i915 = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
+ struct drm_luminance_range_info *luminance_range =
+ &connector->base.display_info.luminance_range;
int ret;
if (panel->backlight.edp.intel.sdr_uses_aux) {
@@ -293,8 +295,17 @@ intel_dp_aux_hdr_setup_backlight(struct intel_connector *connector, enum pipe pi
}
}
- panel->backlight.max = 512;
- panel->backlight.min = 0;
+ if (luminance_range->max_luminance) {
+ panel->backlight.max = luminance_range->max_luminance;
+ panel->backlight.min = luminance_range->min_luminance;
+ } else {
+ panel->backlight.max = 512;
+ panel->backlight.min = 0;
+ }
+
+ drm_dbg_kms(&i915->drm, "Using backlight range %d..%d\n", panel->backlight.min,
+ panel->backlight.max);
+
panel->backlight.level = intel_dp_aux_hdr_get_backlight(connector, pipe);
panel->backlight.enabled = panel->backlight.level != 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function
2022-07-19 9:56 ` [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function Jouni Högander
@ 2022-08-04 9:54 ` Jani Nikula
2022-08-11 17:43 ` Deucher, Alexander
0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2022-08-04 9:54 UTC (permalink / raw)
To: Jouni Högander, dri-devel, intel-gfx, amd-gfx
Cc: Rodrigo Siqueira, Roman Li, Manasi Navare, Mika Kahola,
Jouni Högander, Harry Wentland
On Tue, 19 Jul 2022, Jouni Högander <jouni.hogander@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?
BR,
Jani.
>
> v2: Use values calculated during edid parsing
>
> Cc: Roman Li <roman.li@amd.com>
> 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>
> Cc: Manasi Navare <manasi.d.navare@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 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function
2022-08-04 9:54 ` Jani Nikula
@ 2022-08-11 17:43 ` Deucher, Alexander
2022-08-12 7:04 ` Jani Nikula
0 siblings, 1 reply; 7+ messages in thread
From: Deucher, Alexander @ 2022-08-11 17:43 UTC (permalink / raw)
To: Jani Nikula, Jouni Högander, dri-devel, intel-gfx, amd-gfx
Cc: Siqueira, Rodrigo, Li, Roman, Manasi Navare, Mika Kahola,
Jouni Högander, Wentland, Harry
[Public]
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Jani
> Nikula
> Sent: Thursday, August 4, 2022 5:55 AM
> To: Jouni Högander <jouni.hogander@intel.com>; dri-
> devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; amd-
> gfx@lists.freedesktop.org
> Cc: Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Li, Roman
> <Roman.Li@amd.com>; Manasi Navare <manasi.d.navare@intel.com>; Mika
> Kahola <mika.kahola@intel.com>; Jouni Högander
> <jouni.hogander@intel.com>; Wentland, Harry
> <Harry.Wentland@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@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@amd.com>
>
> BR,
> Jani.
>
>
> >
> > v2: Use values calculated during edid parsing
> >
> > Cc: Roman Li <roman.li@amd.com>
> > 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>
> > Cc: Manasi Navare <manasi.d.navare@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 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function
2022-08-11 17:43 ` Deucher, Alexander
@ 2022-08-12 7:04 ` Jani Nikula
0 siblings, 0 replies; 7+ messages in thread
From: Jani Nikula @ 2022-08-12 7:04 UTC (permalink / raw)
To: Deucher, Alexander, Jouni Högander, dri-devel, intel-gfx, amd-gfx
Cc: Siqueira, Rodrigo, Li, Roman, Manasi Navare, Mika Kahola,
Jouni Högander, Wentland, Harry
On Thu, 11 Aug 2022, "Deucher, Alexander" <Alexander.Deucher@amd.com> wrote:
> [Public]
>
>> -----Original Message-----
>> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Jani
>> Nikula
>> Sent: Thursday, August 4, 2022 5:55 AM
>> To: Jouni Högander <jouni.hogander@intel.com>; dri-
>> devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; amd-
>> gfx@lists.freedesktop.org
>> Cc: Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Li, Roman
>> <Roman.Li@amd.com>; Manasi Navare <manasi.d.navare@intel.com>; Mika
>> Kahola <mika.kahola@intel.com>; Jouni Högander
>> <jouni.hogander@intel.com>; Wentland, Harry
>> <Harry.Wentland@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@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@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@amd.com>
>> > 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>
>> > Cc: Manasi Navare <manasi.d.navare@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 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-08-12 16:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19 9:56 [PATCH v3 0/3] HDR aux backlight range calculation Jouni Högander
2022-07-19 9:56 ` [PATCH v3 1/3] drm: New function to get luminance range based on static hdr metadata Jouni Högander
2022-07-19 9:56 ` [PATCH v3 2/3] drm/amdgpu_dm: Rely on split out luminance calculation function Jouni Högander
2022-08-04 9:54 ` Jani Nikula
2022-08-11 17:43 ` Deucher, Alexander
2022-08-12 7:04 ` Jani Nikula
2022-07-19 9:57 ` [PATCH v3 3/3] drm/i915: Use luminance range calculated during edid parsing Jouni Högander
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).