[PATCH v4 01/12] drm/connector: add CEC-related fields
From: Dmitry Baryshkov
Date: Sun Feb 02 2025 - 07:07:35 EST
As a preparation to adding HDMI CEC helper code, add CEC-related fields
to the struct drm_connector. Include both cec_adapter and cec_notifier,
allowing drivers to select which one to use. The unregister callback
is provided to let drivers unregister CEC-related data in a generic way
without polluting drm_connector.c with dependencies on the CEC
functions.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
---
drivers/gpu/drm/drm_connector.c | 1 +
include/drm/drm_connector.h | 46 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 1383fa9fff9bcf31488453e209a36c6fe97be2f1..9890b00e8f9be856f67cc2835733a056ddb98efb 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -279,6 +279,7 @@ static int drm_connector_init_only(struct drm_device *dev,
INIT_LIST_HEAD(&connector->probed_modes);
INIT_LIST_HEAD(&connector->modes);
mutex_init(&connector->mutex);
+ mutex_init(&connector->cec.mutex);
mutex_init(&connector->eld_mutex);
mutex_init(&connector->edid_override_mutex);
mutex_init(&connector->hdmi.infoframes.lock);
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index f13d597370a30dc1b14c630ee00145256052ba56..790a4d6266436b1853ba458456529403e5597a3b 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -46,6 +46,7 @@ struct drm_property_blob;
struct drm_printer;
struct drm_privacy_screen;
struct drm_edid;
+struct cec_adapter;
struct edid;
struct hdmi_codec_daifmt;
struct hdmi_codec_params;
@@ -1191,6 +1192,21 @@ struct drm_connector_hdmi_audio_funcs {
bool enable, int direction);
};
+/**
+ * struct drm_connector_cec_funcs - drm_hdmi_connector control functions
+ */
+struct drm_connector_cec_funcs {
+ /**
+ * @adap_unregister: unregister CEC adapter / notifier.
+ *
+ * The callback to unregister CEC adapter or notifier, so that the core
+ * DRM layer doesn't depend on the CEC_CORE. The callback should also
+ * clean all data in the @drm_connector_cec struct, including the
+ * 'funcs' field.
+ */
+ void (*unregister)(struct drm_connector *connector);
+};
+
/**
* struct drm_connector_hdmi_funcs - drm_hdmi_connector control functions
*/
@@ -1832,6 +1848,31 @@ struct drm_connector_hdmi {
} infoframes;
};
+/**
+ * struct drm_connector_cec - DRM Connector CEC-related structure
+ */
+struct drm_connector_cec {
+ /**
+ * @mutex: protects all fields in this structure.
+ */
+ struct mutex mutex;
+
+ /**
+ * @adap: CEC adapter corresponding to the DRM connector.
+ */
+ struct cec_adapter *adapter;
+
+ /**
+ * @notifier: CEC notifier corresponding to the DRM connector.
+ */
+ struct cec_notifier *notifier;
+
+ /**
+ * @funcs: CEC Control Functions
+ */
+ const struct drm_connector_cec_funcs *funcs;
+};
+
/**
* struct drm_connector - central DRM connector control structure
*
@@ -2253,6 +2294,11 @@ struct drm_connector {
* @hdmi_audio: HDMI codec properties and non-DRM state.
*/
struct drm_connector_hdmi_audio hdmi_audio;
+
+ /**
+ * @cec: CEC-related data.
+ */
+ struct drm_connector_cec cec;
};
#define obj_to_connector(x) container_of(x, struct drm_connector, base)
--
2.39.5