Skip to contentSkip to conversation

drm/edid: Read the monitor range from the DisplayID Adaptive-Sync block

PATCH New ElXreno 2 participants 2 messages Nov 14

Subsystems (2)
lore
Share & tools
lore

ElXreno

author
#0 lore raw

PATCH 1/1 drm/edid: Read the monitor range from the DisplayID Adaptive-Sync block

A DisplayID 2.x Adaptive-Sync data block (tag 0x2b) lists the refresh rate ranges a display supports with an adaptive vertical total. Some panels advertise their variable refresh range only there, and some keep a narrower one in the base block range limits. The BOE NE180QA1-MM1 is of the second kind: the range limits descriptor says 48-120 Hz, the Adaptive-Sync block has three descriptors,

27 00 30 ef 00 00
27 00 30 77 00 00
27 00 30 3b 00 00

for 48-240, 48-120 and 48-60 Hz. A driver that checks a mode against monitor_range then refuses VRR for the 240 Hz timing of that panel.

Use the block in both cases. Without a range from the base block take the range from the descriptors. With one, keep its minimum and only raise the maximum, and only from descriptors that reach down into it, so that the result never goes below what the base block promises.

monitor_range stays one range per connector. Only descriptors for the native panel range that declare the adaptive vertical total operation mode count: a descriptor for fixed average vertical total alone does not describe a range to pick a vertical total from. Where several count, the highest minimum and the highest maximum are used. Without a base range every rate in the result is then within the descriptor that reaches highest. With one, every rate is within the base range or within that descriptor, which overlaps it.

The layout is taken from edid-decode (parse_displayid_adaptive_sync() in utils/edid-decode/parse-displayid-block.cpp of v4l-utils), not from the DisplayID text: a descriptor is 6 bytes plus the count in bits 6:4 of the block revision, byte 0 has the native panel range flag in bit 0 and the operation mode in bits 3:2 (1 for fixed average and adaptive vertical total), byte 2 is the minimum refresh rate, bytes 3-4 hold the maximum refresh rate minus one in ten bits. The block is read from any section of structure version 2.0 or later, which is what the panel above declares.

This reaches every driver that reads monitor_range. A display with such a block and no base block range now has a range where it had none, which is the point for i915 and xe (their other VRR conditions still apply). amdgpu scans DisplayID tag 0x25 on its own when the minimum or the maximum is zero, and with a range from the Adaptive-Sync block that scan is no longer reached. When the display has no AMD VSDB, amdgpu takes monitor_range as its refresh rate range, so it follows the raised maximum, and a DP or eDP display that has only the Adaptive-Sync block can now pass its FreeSync test (a range wider than 10 Hz and a sink that ignores the MSA timing). With a VSDB that advertises FreeSync the range still comes from there.

---

Two parsers for this area were posted this spring, both as a fallback for panels with no range in the base block: Adriano Vero's for tag 0x25, v1 in [1] and a v2 on April 1 after Jani's review, and Jake S's for tags 0x2b and 0x25 [2]. Asked by Ville why he had posted a different version, Jake offered to fold the 0x2b part into Adriano's series [3]. I found no later posting of either, and the DRM core in drm-tip parses neither tag. This one covers the case where the base block has a range that is narrower than the Adaptive-Sync one, looks at the native range flag and the operation mode of the descriptors, and leaves tag 0x25 alone. I am happy to rebase onto either of them instead.

The i915 series that needs it for a 3840x2400@240 panel is "drm/i915:
VRR with the pipe joiner" on intel-gfx.

Tested on the BOE NE180QA1-MM1 only: monitor_range goes from 48-120 to 48-240. No KUnit case comes with it.

On tooling, per Documentation/process/generated-content.rst: written with an LLM coding assistant (Claude Code), which also decoded the panel's EDID against edid-decode. I have reviewed all of it and take responsibility for the result.

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
[3] https://lore.kernel.org/r/[email protected]

 drivers/gpu/drm/drm_displayid_internal.h | 17 ++++++
 drivers/gpu/drm/drm_edid.c               | 68 ++++++++++++++++++++++++
 include/drm/drm_connector.h              | 10 ++--
 3 files changed, 92 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_displayid_internal.h +17 -0
index ef7e6c9bd4db..6ea1c45c04b6 100644
@@ -67,6 +67,7 @@ struct drm_edid;
 #define DATA_BLOCK_2_TILED_DISPLAY_TOPOLOGY	0x28
 #define DATA_BLOCK_2_CONTAINER_ID		0x29
 #define DATA_BLOCK_2_TYPE_10_FORMULA_TIMING	0x2a
+#define DATA_BLOCK_2_ADAPTIVE_SYNC		0x2b
 #define DATA_BLOCK_2_VENDOR_SPECIFIC		0x7e
 #define DATA_BLOCK_2_CTA_DISPLAY_ID		0x81
 
@@ -142,6 +143,22 @@ struct displayid_formula_timing_block {
 	struct displayid_formula_timings_9 timings[];
 } __packed;
 
+/* Bits 6:4 of the block revision: descriptor bytes beyond the base six */
+#define DISPLAYID_ADAPTIVE_SYNC_DESC_EXTRA	GENMASK(6, 4)
+
+#define DISPLAYID_ADAPTIVE_SYNC_NATIVE_RANGE	BIT(0)
+#define DISPLAYID_ADAPTIVE_SYNC_MODE		GENMASK(3, 2)
+#define DISPLAYID_ADAPTIVE_SYNC_MODE_FAVT_AVT	1
+#define DISPLAYID_ADAPTIVE_SYNC_MAX_REFRESH	GENMASK(9, 0)
+
+struct displayid_adaptive_sync_descriptor {
+	u8 flags;
+	u8 max_duration_increase;
+	u8 min_refresh;
+	__le16 max_refresh;	/* [9:0] refresh rate - 1 */
+	u8 max_duration_decrease;
+} __packed;
+
 #define DISPLAYID_DEVICE_TECH_UNSPECIFIED	0
 #define DISPLAYID_DEVICE_TECH_LCD		1
 #define DISPLAYID_DEVICE_TECH_OLED		2
drivers/gpu/drm/drm_edid.c +68 -0

85 lines not on this page · raw message

include/drm/drm_connector.h +7 -3
index f656ed8324d3..8fd484d36671 100644
@@ -456,12 +456,15 @@ drm_hdmi_connector_get_broadcast_rgb_name(enum drm_hdmi_broadcast_rgb broadcast_
  * &drm_display_info
  *
  * This struct is used to store a frequency range supported by panel
- * as parsed from EDID's detailed monitor range descriptor block.
+ * as parsed from EDID's detailed monitor range descriptor block and
+ * from the DisplayID Adaptive-Sync data block.
  *
  * @min_vfreq: This is the min supported refresh rate in Hz from
- *             EDID's detailed monitor range.
+ *             EDID's detailed monitor range, or from the Adaptive-Sync
+ *             data block when there is no such range.
  * @max_vfreq: This is the max supported refresh rate in Hz from
- *             EDID's detailed monitor range
+ *             EDID's detailed monitor range or the Adaptive-Sync data
+ *             block, whichever is higher.
  */
 struct drm_monitor_range_info {
 	u16 min_vfreq;
@@ -1002,6 +1005,7 @@ struct drm_display_info {
 
 	/**
 	 * @monitor_range: Frequency range supported by monitor range descriptor
+	 * and the DisplayID Adaptive-Sync data block
 	 */
 	struct drm_monitor_range_info monitor_range;
 

base-commit: f40cc5e715fe9e7a5e61f7cd44f63f68c1625f2c

Signature · 1 line
2.56.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/edid: Signed-off-by trailer uses handle instead of full real name --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] drm/edid: Signed-off-by trailer uses handle instead of full real name
--

commit ccbdbf24ebcae6dbb6cf32b1e44947510278e9c5
Author: ElXreno <[email protected]>

Quoted 52 lines

drm/edid: Read the monitor range from the DisplayID Adaptive-Sync block

A DisplayID 2.x Adaptive-Sync data block (tag 0x2b) lists the refresh rate ranges a display supports with an adaptive vertical total. Some panels advertise their variable refresh range only there, and some keep a narrower one in the base block range limits. The BOE NE180QA1-MM1 is of the second kind: the range limits descriptor says 48-120 Hz, the Adaptive-Sync block has three descriptors,

27 00 30 ef 00 00
27 00 30 77 00 00
27 00 30 3b 00 00

for 48-240, 48-120 and 48-60 Hz. A driver that checks a mode against monitor_range then refuses VRR for the 240 Hz timing of that panel.

Use the block in both cases. Without a range from the base block take the range from the descriptors. With one, keep its minimum and only raise the maximum, and only from descriptors that reach down into it, so that the result never goes below what the base block promises.

monitor_range stays one range per connector. Only descriptors for the native panel range that declare the adaptive vertical total operation mode count: a descriptor for fixed average vertical total alone does not describe a range to pick a vertical total from. Where several count, the highest minimum and the highest maximum are used. Without a base range every rate in the result is then within the descriptor that reaches highest. With one, every rate is within the base range or within that descriptor, which overlaps it.

The layout is taken from edid-decode (parse_displayid_adaptive_sync() in utils/edid-decode/parse-displayid-block.cpp of v4l-utils), not from the DisplayID text: a descriptor is 6 bytes plus the count in bits 6:4 of the block revision, byte 0 has the native panel range flag in bit 0 and the operation mode in bits 3:2 (1 for fixed average and adaptive vertical total), byte 2 is the minimum refresh rate, bytes 3-4 hold the maximum refresh rate minus one in ten bits. The block is read from any section of structure version 2.0 or later, which is what the panel above declares.

This reaches every driver that reads monitor_range. A display with such a block and no base block range now has a range where it had none, which is the point for i915 and xe (their other VRR conditions still apply). amdgpu scans DisplayID tag 0x25 on its own when the minimum or the maximum is zero, and with a range from the Adaptive-Sync block that scan is no longer reached. When the display has no AMD VSDB, amdgpu takes monitor_range as its refresh rate range, so it follows the raised maximum, and a DP or eDP display that has only the Adaptive-Sync block can now pass its FreeSync test (a range wider than 10 Hz and a sink that ignores the MSA timing). With a VSDB that advertises FreeSync the range still comes from there.

Quoted 1 line

[Severity: High]
Could the Author header and Signed-off-by trailer use a full real name instead of the handle ElXreno? Documentation/process/submitting-patches.rst requires a real name for the Developer's Certificate of Origin and does not permit pseudonyms or handles.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1