@@ -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);
@@ -698,6 +699,16 @@ static void drm_mode_remove(struct drm_connector *connector,
drm_mode_destroy(connector->dev, mode);
}
+static void drm_connector_cec_unregister(struct drm_connector *connector)
+{
+ mutex_lock(&connector->cec.mutex);
+
+ if (connector->cec.funcs->unregister)
+ connector->cec.funcs->unregister(connector);
+
+ mutex_unlock(&connector->cec.mutex);
+}
+
/**
* drm_connector_cleanup - cleans up an initialised connector
* @connector: connector to cleanup
@@ -718,6 +729,8 @@ void drm_connector_cleanup(struct drm_connector *connector)
platform_device_unregister(connector->hdmi_audio.codec_pdev);
+ drm_connector_cec_unregister(connector);
+
if (connector->privacy_screen) {
drm_privacy_screen_put(connector->privacy_screen);
connector->privacy_screen = NULL;
@@ -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,19 @@ 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.
+ */
+ void (*unregister)(struct drm_connector *connector);
+};
+
/**
* struct drm_connector_hdmi_funcs - drm_hdmi_connector control functions
*/
@@ -1832,6 +1846,31 @@ struct drm_connector_hdmi {
} infoframes;
};
+/**
+ * struct drm_connector_cec - DRM Connector CEC-related structure
+ */
+struct drm_connector_cec {
+ /**
+ * @mutex: protects all CEC-related fields
+ */
+ 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 +2292,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)
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@linaro.org> --- drivers/gpu/drm/drm_connector.c | 13 ++++++++++++ include/drm/drm_connector.h | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)