[PATCH v4 00/27] drm/amd: VRR fixes, HDMI Gaming Features

Tomasz Pakuła posted 27 patches 2 weeks, 2 days ago
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 299 ++++++++++++++----
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 +
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  49 ++-
drivers/gpu/drm/amd/display/dc/core/dc.c      |   3 +
.../gpu/drm/amd/display/dc/core/dc_resource.c |   2 +-
drivers/gpu/drm/amd/display/dc/dc.h           |   1 +
drivers/gpu/drm/amd/display/dc/dc_stream.h    |   2 +
drivers/gpu/drm/amd/display/dc/dc_types.h     |   7 +-
drivers/gpu/drm/amd/display/dc/dm_helpers.h   |   2 +-
.../amd/display/include/ddc_service_types.h   |   1 +
.../amd/display/modules/freesync/freesync.c   |   4 +
.../amd/display/modules/inc/mod_info_packet.h |  17 +-
.../display/modules/info_packet/info_packet.c | 298 +++++++++++------
drivers/gpu/drm/amd/include/amd_shared.h      |   6 +
drivers/gpu/drm/drm_atomic_uapi.c             |   8 +
drivers/gpu/drm/drm_connector.c               | 188 +++++++++++
drivers/gpu/drm/drm_crtc.c                    |   2 +
drivers/gpu/drm/drm_edid.c                    |  41 ++-
drivers/gpu/drm/drm_mode_config.c             |   6 +
include/drm/drm_connector.h                   |  99 ++++++
include/drm/drm_crtc.h                        |   9 +
include/drm/drm_mode_config.h                 |   6 +
22 files changed, 864 insertions(+), 190 deletions(-)
[PATCH v4 00/27] drm/amd: VRR fixes, HDMI Gaming Features
Posted by Tomasz Pakuła 2 weeks, 2 days ago
This patch series tackles a few things:
- Fixes VRR not detected if monitor uses GTF flag for ranges
  instead of Range Limits Only
- Detects if AMD vsdb carries a wider VRR range and uses it instead
- DP->HDMI PCON changes which includes a module property to override
  PCON ID check
- Parses HDMI gaming features in generic drm
- Reintroduces proper HF-VSIF and VTEM info packets
- Adds support for Auto Low Latency Mode
- Adds support for HDMI VRR

Built on top of amd-staging-drm-next

VRR range fixes are simple and fix VRR support for many monitors. They
close about 5 issues on the amdgpu issue tracker.

Adaptive Sync over PCON is only available as FreeSync over HDMI. TVs which
do not support FreeSync, do not have working VRR with DP -> HDMI 2.1
adapters even though adapters will take care of HDMI VRR info packets.

I myself validated these changes with my Samsung S95B + Bernhard validated
on LG C4 + FreeSync-less Sony Bravia 8. I used Alienware AW3423DWF that
only has HDMI 2.0 to check that FreeSync still triggers properly for
"older" hardware,

For missing VRRmax or VRRmax == 0, the upper boundary is the currently
selected video mode refresh rate. I wasn't sure how best to implement it
but ended up on a great solution. We first check if maybe there is a VRR
range in AMD vsdb. If not, rely on limitation of base refresh rate in
VTEM vsif.

More history on previous shape of HF-VSIF and VTEM in their respective
patches but the info packets were previously included in the driver code.
HF-VSIF was improperly handled and VTEM doesn't seem to have been plumbed
as it had no use before. I recoded these and this code should be much
easier to understand and maintain.

ALLM support uses the info from EDID to determine if ALLM is supported by
sink and if that's the case, always signals for ALLM to be enabled. In PC
use, be it for gaming, desktop use, work etc. we always want the lowest
latency and less processing + possibly higher available refresh rates when
gaming mode is turned on.

HDMI VRR support relies on sending VTEM info packet in place of FreeSync
info packets. Though VTEM has it's own place in the info packet pipeline,
I didn't touch it as it already replaces FreeSync info packets. If there's
a need to change this, please let me know for v2.

Both features were tested and work just like they were intended to. Gaming
mode is automatically triggered and HDMI VRR is used in place of FreeSync
(if available). This HDMI VRR preference actually fixes VRR-induced
flickering on many TVs (S95B in my case) with somehow subpar
FreeSync implementation.

I still think it's better to not force users to search for solutions
manually especially since it seems like DP and eDP don't save info about
FreeSync version and completely rely on basic VRR support.
This would then be mirrored.

There's still an issue with some TVs behaving like a mode change is
happening when VRR is triggered and I'd like to maybe tackle this too. When
using HDMI through PCON, VRR is always active, like it's in
VRR_STATE_ACTIVE_FIXED mode. This makes my TV much nicer to use and
replication this behavior would be worthwhile IMO.

Everything in this patch series has been based on already public
code/knowledge or trying things out until they work/break.

This patch series supersedes previous patches/series:
https://lore.kernel.org/amd-gfx/20251209231107.1968472-1-tomasz.pakula.oficjalny@gmail.com/
https://lore.kernel.org/amd-gfx/20260113214104.146856-1-tomasz.pakula.oficjalny@gmail.com/
https://lore.kernel.org/amd-gfx/20260113183540.86266-1-tomasz.pakula.oficjalny@gmail.com/

Changes in v2:
- Updated BRR max value to 1023 after testing one by one. This should've
  been obvious since 1023 is the max value for a 10-bit field
- Fixed some comments, to silence "not a kernel doc" warning
- Considered ALLM comments from Michel Dänzer, Daniel Stone and
  Jani Nikula. ALLM is now triggered if either VRR is active or Content
  Type Hint is set to "Game". Content type hint is already supported by
  amdgpu and fully plumbed.
- Added module parameter for controlling ALLM trigger behavior. Now it can
  be configured to never trigger ALLM, trigger with VRR/Game (default) or
  be always forced on.
- Added HDMI VRR desktop mode module parameter, which is on by default.
  This mimics how FreeSync is handeled on Windows and this fixes a lot of
  issues with unwanted screen blanking and glitches around entering/exiting
  VRR mode.
- Moved hdmi vic mode check to one central function to avoid checking for
  3D and ALLM in different places which could sometimes break the logic for
  translating HDMI VIC modes into CTA vic modes (when such translation 
  is needed).
  
Changes in v3:
- Fixed wonky English
- Less struct traversal in helper functions
- Fixed possible NULL pointer dereference while checking if ALLM support is
  indicated in edid_caps of local_sink
- Fixed ALLM bit assignment overriding 3D bit data in HF-VSIF
- Fixed assignment of the upper 2 bits of BRR in VTEM

Changes in v4:
- Removed amdgpu module settings for vrr and allm
- Introduced passive_vrr properties to drm_crtc and drm_connector
- Introduced ALLM properites to drm_connector
- Implemented said properties in amdgpu for HDMI connectors
- Updated the range extending logic
- Rebased on current amd-staging-drm-next

I'd really love to figure out how to enable drivers to override property
defaults for crtc/connector. Ideally, ALLM would default to dynamic mode, 
but attaching with said value doesn't matter as it will be set back to 0
after connector reset.

Range extending logic better explained in the comment/commit but turns out,
some manufacturers modify the lower VRR bound in Monitor Ranges due to
issues found just before release but the range wasn't updated in vsdb.
Using VRR with the extended lower limit caused blanking and other issues.

The reworked range extending logic will only extend the lower range, if
the VRR min found in Monitor Ranges disables LFC (vrr_min > vrr_max / 2).

The report and findings can be found here:
https://github.com/CachyOS/distribution/issues/329

Passive VRR is enabled by default for connectors that support it. It's
not super useful for DisplayPort so amdgpu only attaches it and uses it
for HDMI connectors. It hooks up to the already established
freesync_on_desktop logic which wasn't used at all, at least in the public
code.

Tomasz Pakuła (27):
  drm/amd/display: Return if DisplayID not found in parse_amd_vsdb()
  drm/amd/display: Refactor amdgpu_dm_update_freesync_caps()
  drm/amd/display: Remove redundant edid checks
  drm/amd/display: Move DisplayID vrr parsing
  drm/amd/display: Always try to parse AMD vsdb
  drm/amd/display: Check for VRR range in CEA AMD vsdb
  drm/amd/display: Use bigger VRR range if found in AMD vsdb
  drm/amd/display: Separate DP/eDP and PCON paths completely
  drm/amd/display: Refactor PCON VRR compatibility check
  drm/amd/display: Add PCON VRR ID check override
  drm/amd/display: Add CH7218 PCON ID
  drm/edid: Parse more info from HDMI Forum vsdb
  drm/amd/display: Rename PCON adaptive sync types
  drm/amd/display: Enable HDMI VRR over PCON
  drm/amd/display: Support HDMI VRRmax=0
  drm/amd/display: Build HDMI vsif in correct slot
  drm/amd/display: Save HDMI gaming info to edid caps
  drm/amd/display: Restore ALLM support in HDMI vsif
  drm/amd/display: Trigger ALLM if it's available
  drm/amd/display: Reintroduce VTEM info frame
  drm/amd/display: Enable HDMI VRR
  drm/amd/display: freesync_on_desktop support for HDMI VRR
  drm: Add passive_vrr_disabled property to crtc
  drm: Add passive_vrr_capable property to connector
  drm: Add ALLM properties to connector
  drm/amd/display: Use passive_vrr properties in amdgpu
  drm/amd/display: Use ALLM properties in amdgpu

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 299 ++++++++++++++----
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 +
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  49 ++-
 drivers/gpu/drm/amd/display/dc/core/dc.c      |   3 +
 .../gpu/drm/amd/display/dc/core/dc_resource.c |   2 +-
 drivers/gpu/drm/amd/display/dc/dc.h           |   1 +
 drivers/gpu/drm/amd/display/dc/dc_stream.h    |   2 +
 drivers/gpu/drm/amd/display/dc/dc_types.h     |   7 +-
 drivers/gpu/drm/amd/display/dc/dm_helpers.h   |   2 +-
 .../amd/display/include/ddc_service_types.h   |   1 +
 .../amd/display/modules/freesync/freesync.c   |   4 +
 .../amd/display/modules/inc/mod_info_packet.h |  17 +-
 .../display/modules/info_packet/info_packet.c | 298 +++++++++++------
 drivers/gpu/drm/amd/include/amd_shared.h      |   6 +
 drivers/gpu/drm/drm_atomic_uapi.c             |   8 +
 drivers/gpu/drm/drm_connector.c               | 188 +++++++++++
 drivers/gpu/drm/drm_crtc.c                    |   2 +
 drivers/gpu/drm/drm_edid.c                    |  41 ++-
 drivers/gpu/drm/drm_mode_config.c             |   6 +
 include/drm/drm_connector.h                   |  99 ++++++
 include/drm/drm_crtc.h                        |   9 +
 include/drm/drm_mode_config.h                 |   6 +
 22 files changed, 864 insertions(+), 190 deletions(-)

-- 
2.53.0