Skip to content

Converging some additional requirements for FRL enablement #1

@aenertia

Description

@aenertia

Hi there; I have been working on more broad community implementation for generic FRL in software (mainly for validation and providing a community/HDMI consortia free implementation(fully legal in NZ). I did a quick look this morning between your patch set and my working tree. This is AI based analysis but might be helpful. I've attached a repomix.xml to this issue of one of the revisions of where I had got to. Hopefully this is somewhat helpful.


AMD FRL Enablement: Directory & File Structure

This document outlines the complete file structure for the Hybrid Integration Model. It maps the "Brain" (Repomix protocol helpers) and the "Hands" (Mkopec hardware sequences) into the standard Linux kernel directory hierarchy, specifically tailored for the target mkopec branch state.

1. Directory Tree Visualization

drivers/gpu/drm/
├── Kconfig                          [Modified: Upstream Reorder + DRM_HDMI_FRL]
├── Makefile                         [Modified: Links new FRL objects]
├── drm_edid.c                       [Modified: Exports HF-VSDB parsing helpers]
│
├── drm_hdmi_frl_tables.c            [New: Repomix - FRL Pattern/Rate Tables]
├── drm_hdmi_frl_helper.c            [New: Repomix - Bandwidth Math & Validation]
├── drm_hdmi_frl_software.c          [New: Repomix - Software FEC Dispatcher]
├── drm_hdmi_frl_fec_avx2.c          [New: Repomix - Software FEC (Guarded)]
├── drm_hdmi_frl_fec_neon.c          [New: Repomix - Software FEC (Guarded)]
│
├── drm_hdmi_emp.c                   [New: Repomix - Extended Metadata Packets]
├── drm_hdmi_qms_helper.c            [New: Repomix - Quick Media Switching]
├── drm_hdmi_audio_helper.c          [New: Repomix - 3D Audio Packets]
├── drm_hdmi_earc_helper.c           [New: Repomix - eARC / LIP Sync]
├── drm_hdmi_dynamic_hdr.c           [New: Repomix - Dynamic HDR Metadata]
├── drm_hdmi_hdcp_helper.c           [New: Repomix - HDCP 2.3 Protocol]
│
└── amd/
    └── display/
        └── dc/
            ├── core/
            │   ├── dc_link.c        [Modified: Hybrid - State Machine Glue]
            │   └── dc_resource.c    [Modified: Hybrid - Bandwidth Logic]
            │
            ├── dcn30/
            │   └── dcn30_hwseq.c    [Modified: Mkopec - Clock Gating/Routing]
            │
            └── dcn31/
                ├── dcn31_hpo_dp_link_encoder.c  [Modified: Mkopec - The "FRL Hack"]
                └── dcn31_hpo_dp_link_encoder.h  [Modified: Mkopec - Definitions]

include/drm/                         [New Section: Based on include diff]
├── drm_edid.h                       [Modified: Exposes HF-VSDB structs]
├── drm_connector.h                  [Modified: Adds FRL capability structs]
├── drm_hdmi_frl_helper.h            [New: Repomix - Prototypes]
├── drm_hdmi_audio_helper.h          [New: Repomix - Prototypes]
├── drm_hdmi_earc_helper.h           [New: Repomix - Prototypes]
├── drm_hdmi_emp.h                   [New: Repomix - Prototypes]
└── drm_hdmi_hdcp_helper.h           [New: Repomix - Prototypes]

2. Generic DRM Subsystem (drivers/gpu/drm/)

These files provide the protocol "Brain" and are derived primarily from the Repomix codebase.

A. Core Logic & Tables

drm_hdmi_frl_tables.c

  • Origin: Repomix
  • Purpose: The "Truth Source" for HDMI 2.1 specs.
  • Key Content:
    • const u32 frl_rate_bandwidths[]: {0, 9, 18, 24, 32, 40, 48} (Gbps).
    • const u8 frl_pattern_ltp1[] through ltp8: Binary definitions of Link Training Patterns.
    • Export: Must use EXPORT_SYMBOL_GPL(drm_hdmi_frl_bandwidths); etc.

drm_hdmi_frl_helper.c

  • Origin: Repomix (Math Subset)
  • Purpose: Calculates requirements without touching hardware.
  • Key Functions:
    • int drm_hdmi_frl_bandwidth_required(const struct drm_display_mode *mode, int bpc, int format);
    • bool drm_hdmi_frl_check_validity(const struct drm_connector *connector, int rate);

drm_hdmi_frl_software.c

  • Origin: Repomix
  • Purpose: The software FEC dispatcher.
  • Key Content:
    • Integration: Used primarily for validation/testing or non-DCN targets. Should be guarded by CONFIG_DRM_HDMI_FRL_SOFTWARE.
    • Function: drm_hdmi_frl_fec_encode_software(void *buf, size_t len) -> dispatches to AVX2/Neon implementation.

B. Advanced Protocol Features

drm_hdmi_emp.c

  • Origin: Repomix
  • Purpose: Handles Extended Metadata Packets (EMP).
  • Context: Used for Dynamic HDR, VRR, and 3D Audio.
  • Integration: drm_hdmi_emp_pack(struct hdmi_emp_data *data, u8 *buffer, size_t size);

drm_hdmi_qms_helper.c

  • Origin: Repomix
  • Purpose: Quick Media Switching (QMS) support.
  • Integration: Requires deep hooks into AMD's dc_stream timing logic to ensure the vertical blanking interval is adjusted seamlessly.

drm_hdmi_dynamic_hdr.c

  • Origin: Repomix
  • Purpose: Handles Dynamic HDR (Dolby Vision / HDR10+) metadata.

C. Audio & Security

drm_hdmi_audio_helper.c

  • Origin: Repomix
  • Purpose: Enables High-Bitrate Audio (HBR) and 3D Audio over FRL.
  • Key Content: Implements "Audio Clock Regeneration" (ACR) packet logic (N and CTS values) which differs for FRL compared to TMDS.

drm_hdmi_earc_helper.c

  • Origin: Repomix
  • Purpose: Enhanced Audio Return Channel (eARC).
  • Key Content: State machine for eARC discovery and Common Mode negotiation.

drm_hdmi_hdcp_helper.c

  • Origin: Repomix
  • Purpose: HDCP 2.3 Protocol State Machine.
  • Usage: Use only for protocol state tracking. AMD psp driver handles the crypto.

D. Core Infrastructure Modifications (Zero Loss)

drm_edid.c

  • Origin: Upstream (Modified)
  • Purpose: Parses the raw binary EDID from the Sink.
  • The Gap: Mainline 6.18 parses the HDMI Forum VSDB (HF-VSDB) but may not expose all FRL-specific flags (e.g., DSC-with-FRL constraints or VRR-min/max specifically for FRL modes).
  • Modification:
    • Locate drm_edid_parse_hf_vsdb.
    • Do not delete existing logic.
    • Add: Parsing for SCDC_Present and RR_Capable (Read Request) if missing.
    • Add: Extraction of Max_FRL_Rate into connector->display_info.hdmi.frl_rate.

3. Build System Integration (The Merge)

A. Kconfig Integration Strategy

Context: drivers_gpu_drm.diff moves driver sources to the top.

File: drivers/gpu/drm/Kconfig

# ... existing generic DRM configs (DRM_SCHED, etc) ...

# [INSERTION POINT START]
# Place this BEFORE the reordered source list in your diff
config DRM_HDMI_FRL
    bool "HDMI 2.1 FRL Support"
    depends on DRM
    select DRM_HDMI_HELPER
    help
      Enable support for Fixed Rate Link (FRL) signaling.
      Required for HDMI 2.1 bandwidths > 18Gbps.

config DRM_HDMI_FRL_SOFTWARE
    bool "HDMI 2.1 Software FEC (Debug)"
    depends on DRM_HDMI_FRL
    help
      Enables software-based Forward Error Correction.
      WARNING: CPU intensive. Use only for validation or virtual drivers.
# [INSERTION POINT END]

# The reordered list from your diff follows here:
source "drivers/gpu/drm/sysfb/Kconfig"
source "drivers/gpu/drm/arm/Kconfig"
source "drivers/gpu/drm/radeon/Kconfig"
source "drivers/gpu/drm/amd/amdgpu/Kconfig"

B. Makefile Integration

File: drivers/gpu/drm/Makefile

# ... existing obj-y ...
# Append these lines:

# Repomix Protocol Stack
obj-$(CONFIG_DRM_HDMI_FRL) += drm_hdmi_frl_tables.o \
                              drm_hdmi_frl_helper.o \
                              drm_hdmi_emp.o \
                              drm_hdmi_dynamic_hdr.o \
                              drm_hdmi_audio_helper.o \
                              drm_hdmi_earc_helper.o \
                              drm_hdmi_qms_helper.o \
                              drm_hdmi_hdcp_helper.o

# Software FEC (Guarded)
obj-$(CONFIG_DRM_HDMI_FRL_SOFTWARE) += drm_hdmi_frl_software.o \
                                       drm_hdmi_frl_fec_avx2.o \
                                       drm_hdmi_frl_fec_neon.o

4. AMD Display Core Integration (amd/display/)

A. Logic Integration (dc/core/)

dc_link.c: The Decision Matrix

You must modify dc_link_decide_link_settings (or equivalent) to check for FRL conditions.

/* PSEUDO-CODE for dc_link.c integration */

#include <drm/drm_hdmi_frl_helper.h>

bool dc_link_decide_frl_enable(struct dc_link *link, struct dc_stream_state *stream)
{
    // 1. Calculate Required Bandwidth using Repomix helper
    //    Convert DC stream format to DRM format constants first
    int bw_needed = drm_hdmi_frl_bandwidth_required(
        &stream->timing, 
        stream->bpc, 
        stream->pixel_encoding
    );

    // 2. Check if TMDS is sufficient (<= 18Gbps / 600MHz)
    if (bw_needed <= 18000)
        return false; // Stay on TMDS

    // 3. Check if Sink supports FRL (parsed from EDID)
    if (!link->hdmi_frl_caps.supported)
        return false; // Cap at HDMI 2.0

    // 4. Check if we exceed max FRL rate
    if (bw_needed > 48000)
        return false; // Mode not supported

    // 5. Success - Enable FRL
    return true;
}

dc_resource.c: Unlocking Bandwidth

  • Action: Find resource_validate_bandwidth.
  • Change: Remove the check if (pixel_clk > 600000) return FAIL; for HDMI signals.
  • Replace with: if (pixel_clk > 600000 && !frl_enabled) return FAIL;

B. Hardware Abstraction (dc/dcn31/)

dcn31_hpo_dp_link_encoder.c: The "FRL Hack"

  • Purpose: The HPO (High Performance Output) block is the only PHY fast enough for 48Gbps. On AMD, it is nominally for DisplayPort 2.0.
  • Mechanism: usage of mkopec's register values forces the HPO block to construct HDMI packets instead of DP micro-packets.
  • Critical Modification: In hpo_dp_link_encoder_enable_dp_output, add a check:
    if (signal == SIGNAL_TYPE_HDMI_TYPE_A) {
        // configure HPO for FRL specifically
        // (Insert mkopec specific register writes here)
    }

5. DRM Header Subsystem (include/drm/)

New files required to support the Repomix source code.

drm_edid.h (Modified)

  • Purpose: Expose the HF-VSDB offsets and parsing capabilities.
  • Zero Loss Change: Add DRM_EDID_HDMI_FORUM_VSDB constant if missing. Add struct drm_hdmi_forum_vsdb definition if private in .c file.

drm_connector.h (Modified)

  • Action: Check struct drm_connector or struct drm_display_info.
  • Add:
    struct drm_hdmi_frl_caps {
        bool supported;
        u8 max_lanes; // 3 or 4
        u8 max_rate_per_lane; // 3, 6, 8, 10, 12 Gbps
        bool scdc_present;
        bool qms_vrr_supported;
    };
    // Add 'struct drm_hdmi_frl_caps frl' to drm_display_info

drm_hdmi_frl_helper.h

  • Structs:
    • enum hdmi_frl_rate { HDMI_FRL_RATE_NONE, HDMI_FRL_RATE_3L_3G, ... };
    • struct hdmi_frl_config { enum hdmi_frl_rate rate; bool fec_enabled; };
  • Prototypes:
    • drm_hdmi_frl_bandwidth_required(...)

drm_hdmi_emp.h

  • Structs:
    • struct hdmi_emp_data { u8 type; u8 length; u8 *payload; }; (Extended Metadata Packet definition).

repomix-output.xml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions