[PATCH 029/108] drm/i915/dp_link_caps: Introduce DP link capability module

Imre Deak
2026-04-28T12:53:34Z

Start isolating the DP link capability logic from the generic DP code by
adding a separate intel_dp_link_caps module and a corresponding state
object.

Allocate the state so it can remain opaque within its module.

Follow-up changes will move link capability helpers and state from
intel_dp.c and intel_dp_link_training.c to the new module and state.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/Makefile | 1 +
.../drm/i915/display/intel_display_types.h | 2 +
drivers/gpu/drm/i915/display/intel_dp.c | 9 ++++
.../gpu/drm/i915/display/intel_dp_link_caps.c | 47 +++++++++++++++++++
.../gpu/drm/i915/display/intel_dp_link_caps.h | 12 +++++
drivers/gpu/drm/xe/Makefile | 1 +
6 files changed, 72 insertions(+)
create mode 100644 drivers/gpu/drm/i915/display/intel_dp_link_caps.c
create mode 100644 drivers/gpu/drm/i915/display/intel_dp_link_caps.h

diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index fa632f4e505c9..0c04c6d9bb13e 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -355,6 +355,7 @@ i915-y += \
display/intel_dp_aux.o \
display/intel_dp_aux_backlight.o \
display/intel_dp_hdcp.o \
+ display/intel_dp_link_caps.o \
display/intel_dp_link_training.o \
display/intel_dp_mst.o \
display/intel_dp_test.o \
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 28a8a149157e0..d11686ce2963d 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -58,6 +58,7 @@ struct cec_notifier;
struct drm_printer;
struct intel_connector;
struct intel_ddi_buf_trans;
+struct intel_dp_link_caps;
struct intel_dp_link_training;
struct intel_fbc;
struct intel_global_objs_state;
@@ -1858,6 +1859,7 @@ struct intel_dp {
int force_lane_count;
int force_rate;
struct intel_dp_link_training *training;
+ struct intel_dp_link_caps *caps;
} link;
bool reset_link_params;
int mso_link_count;
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 4f016adef93be..e63e341aa5c8d 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -71,6 +71,7 @@
#include "intel_dp.h"
#include "intel_dp_aux.h"
#include "intel_dp_hdcp.h"
+#include "intel_dp_link_caps.h"
#include "intel_dp_link_training.h"
#include "intel_dp_mst.h"
#include "intel_dp_test.h"
@@ -7357,6 +7358,13 @@ int intel_dp_link_init(struct intel_dp *intel_dp)
if (!intel_dp->link.training)
return -ENOMEM;

+ intel_dp->link.caps = intel_dp_link_caps_init(intel_dp);
+ if (!intel_dp->link.caps) {
+ intel_dp_link_training_cleanup(intel_dp->link.training);
+
+ return -ENOMEM;
+ }
+
return 0;
}

@@ -7368,5 +7376,6 @@ int intel_dp_link_init(struct intel_dp *intel_dp)
*/
void intel_dp_link_cleanup(struct intel_dp *intel_dp)
{
+ intel_dp_link_caps_cleanup(intel_dp->link.caps);
intel_dp_link_training_cleanup(intel_dp->link.training);
}
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
new file mode 100644
index 0000000000000..335382d193475
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2026 Intel Corporation
+ */
+
+#include <linux/slab.h>
+
+#include "intel_dp_link_caps.h"
+
+struct intel_dp_link_caps {
+ struct intel_dp *dp;
+};
+
+/**
+ * intel_dp_link_caps_init - allocate and initialize link caps state
+ * @intel_dp: DP encoder state
+ *
+ * Allocate and initialize the link capabilities state for @intel_dp and
+ * the connectors attached to it.
+ *
+ * Return:
+ * - Pointer to the newly allocated link capabilities state.
+ * - %NULL if allocation fails.
+ */
+struct intel_dp_link_caps *intel_dp_link_caps_init(struct intel_dp *intel_dp)
+{
+ struct intel_dp_link_caps *link_caps;
+
+ link_caps = kzalloc_obj(*link_caps);
+ if (!link_caps)
+ return NULL;
+
+ link_caps->dp = intel_dp;
+
+ return link_caps;
+}
+
+/**
+ * intel_dp_link_caps_cleanup - free link caps state
+ * @link_caps: link capabilities state to free
+ *
+ * Free @link_caps.
+ */
+void intel_dp_link_caps_cleanup(struct intel_dp_link_caps *link_caps)
+{
+ kfree(link_caps);
+}
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
new file mode 100644
index 0000000000000..050b279463d6e
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: MIT */
+/* Copyright © 2026 Intel Corporation */
+
+#ifndef __INTEL_DP_LINK_CAPS_H__
+#define __INTEL_DP_LINK_CAPS_H__
+
+struct intel_dp;
+
+struct intel_dp_link_caps *intel_dp_link_caps_init(struct intel_dp *intel_dp);
+void intel_dp_link_caps_cleanup(struct intel_dp_link_caps *link_caps);
+
+#endif /* __INTEL_DP_LINK_CAPS_H__ */
diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
index 95666f950a6fc..9450d487123a3 100644
--- a/drivers/gpu/drm/xe/Makefile
+++ b/drivers/gpu/drm/xe/Makefile
@@ -276,6 +276,7 @@ xe-$(CONFIG_DRM_XE_DISPLAY) += \
i915-display/intel_dp_aux.o \
i915-display/intel_dp_aux_backlight.o \
i915-display/intel_dp_hdcp.o \
+ i915-display/intel_dp_link_caps.o \
i915-display/intel_dp_link_training.o \
i915-display/intel_dp_mst.o \
i915-display/intel_dp_test.o \
--
2.49.1