[PATCH v2 05/27] drm/connector: hdmi: Add VTEM EMP generation
From: Nicolas Frattaroli
Date: Thu Nov 05 2026 - 11:15:27 EST
From: Derek Foreman <derek.foreman@xxxxxxxxxxxxx>
Add VTEM EMP generation to enable variable refresh rate signalling over
HDMI.
These infoframes are only generated if the sink supports VRR.
Signed-off-by: Derek Foreman <derek.foreman@xxxxxxxxxxxxx>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@xxxxxxxxxxxxx>
---
drivers/gpu/drm/display/drm_hdmi_state_helper.c | 63 +++++++++++++++++++++++++
include/drm/drm_connector.h | 5 ++
2 files changed, 68 insertions(+)
diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
index eb6abfd1350d..ce680eaa5047 100644
--- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c
+++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c
@@ -853,6 +853,61 @@ static int hdmi_generate_hdmi_vendor_infoframe(const struct drm_connector *conne
return 0;
}
+static int hdmi_generate_emp_infoframe_vtem(const struct drm_connector *connector,
+ struct drm_connector_state *conn_state)
+{
+ const struct drm_display_info *info = &connector->display_info;
+ const struct drm_crtc_state *crtc_state =
+ drm_atomic_get_crtc_state(conn_state->state, conn_state->crtc);
+ struct drm_connector_hdmi_infoframe *infoframe =
+ &conn_state->hdmi.infoframes.vtem;
+ struct hdmi_emp_infoframe_vtem *vtem =
+ &infoframe->data.vtem;
+ const struct drm_crtc_vrr_state *vrr = &crtc_state->vrr_state;
+ int vfront;
+ u8 avi_vic;
+
+ infoframe->set = false;
+
+ if (!connector->hdmi.funcs->vtem.write_infoframe)
+ return 0;
+
+ if (!info->hdmi.vrr_cap.supported)
+ return 0;
+
+ if (conn_state->hdmi.infoframes.avi.set)
+ avi_vic = conn_state->hdmi.infoframes.avi.data.avi.video_code;
+ else
+ avi_vic = 0;
+
+ hdmi_emp_infoframe_vtem_init(vtem);
+
+ switch (conn_state->vrr_display_mode) {
+ case VRR_DISPLAY_MODE_GAME:
+ vtem->game_vrr_en = true;
+ vtem->m_const = !vrr->dynamic;
+ break;
+ case VRR_DISPLAY_MODE_OFF:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (vtem->game_vrr_en && !avi_vic) {
+ vtem->base_refresh_rate = drm_mode_vrefresh(&crtc_state->mode);
+ vfront = crtc_state->adjusted_mode.crtc_vsync_start -
+ crtc_state->adjusted_mode.crtc_vdisplay;
+ if (vfront > U8_MAX || vfront < 0)
+ return -EINVAL;
+
+ vtem->base_vfront = vfront;
+ }
+
+ infoframe->set = true;
+
+ return 0;
+}
+
static int
hdmi_generate_infoframes(const struct drm_connector *connector,
struct drm_connector_state *conn_state)
@@ -884,6 +939,10 @@ hdmi_generate_infoframes(const struct drm_connector *connector,
if (ret)
return ret;
+ ret = hdmi_generate_emp_infoframe_vtem(connector, conn_state);
+ if (ret)
+ return ret;
+
return 0;
}
@@ -1475,6 +1534,10 @@ int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *con
goto out;
}
+ ret = write_or_clear_infoframe(connector, &funcs->vtem, "VTEM",
+ &old_conn_state->hdmi.infoframes.vtem,
+ &new_conn_state->hdmi.infoframes.vtem);
+
out:
mutex_unlock(&connector->hdmi.infoframes.lock);
return ret;
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 184b10c89508..9df745ecff92 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1186,6 +1186,11 @@ struct drm_connector_hdmi_state {
* matching our state.
*/
struct drm_connector_hdmi_infoframe hdmi;
+
+ /**
+ * @vtem: VTEM EMP infoframes structure matching our state.
+ */
+ struct drm_connector_hdmi_infoframe vtem;
} infoframes;
/**
--
2.56.0