@@ -143,3 +143,40 @@ void drm_connector_hdmi_cec_phys_addr_set(struct drm_connector *connector)
mutex_unlock(&connector->cec.mutex);
}
EXPORT_SYMBOL(drm_connector_hdmi_cec_phys_addr_set);
+
+void drm_bridge_cec_transmit_done(struct drm_bridge *bridge, u8 status,
+ u8 arb_lost_cnt, u8 nack_cnt,
+ u8 low_drive_cnt, u8 error_cnt)
+{
+ mutex_lock(&bridge->cec_mutex);
+
+ if (bridge->cec_adapter)
+ cec_transmit_done(bridge->cec_adapter, status, arb_lost_cnt,
+ nack_cnt, low_drive_cnt, error_cnt);
+
+ mutex_unlock(&bridge->cec_mutex);
+}
+EXPORT_SYMBOL_GPL(drm_bridge_cec_transmit_done);
+
+void drm_bridge_cec_transmit_attempt_done(struct drm_bridge *bridge, u8 status)
+{
+ mutex_lock(&bridge->cec_mutex);
+
+ if (bridge->cec_adapter)
+ cec_transmit_attempt_done(bridge->cec_adapter, status);
+
+ mutex_unlock(&bridge->cec_mutex);
+}
+EXPORT_SYMBOL_GPL(drm_bridge_cec_transmit_attempt_done);
+
+void drm_bridge_cec_received_msg(struct drm_bridge *bridge,
+ struct cec_msg *msg)
+{
+ mutex_lock(&bridge->cec_mutex);
+
+ if (bridge->cec_adapter)
+ cec_received_msg(bridge->cec_adapter, msg);
+
+ mutex_unlock(&bridge->cec_mutex);
+}
+EXPORT_SYMBOL_GPL(drm_bridge_cec_received_msg);
@@ -206,6 +206,7 @@ static LIST_HEAD(bridge_list);
void drm_bridge_add(struct drm_bridge *bridge)
{
mutex_init(&bridge->hpd_mutex);
+ mutex_init(&bridge->cec_mutex);
mutex_lock(&bridge_lock);
list_add_tail(&bridge->list, &bridge_list);
@@ -248,6 +249,7 @@ void drm_bridge_remove(struct drm_bridge *bridge)
mutex_unlock(&bridge_lock);
mutex_destroy(&bridge->hpd_mutex);
+ mutex_destroy(&bridge->cec_mutex);
}
EXPORT_SYMBOL(drm_bridge_remove);
@@ -1302,6 +1304,20 @@ void drm_bridge_hpd_notify(struct drm_bridge *bridge,
}
EXPORT_SYMBOL_GPL(drm_bridge_hpd_notify);
+void drm_bridge_cec_adapter_set(struct drm_bridge *bridge,
+ struct cec_adapter *cec_adapter)
+{
+ if (!(bridge->ops & DRM_BRIDGE_OP_HDMI))
+ return;
+
+ mutex_lock(&bridge->cec_mutex);
+
+ bridge->cec_adapter = cec_adapter;
+
+ mutex_unlock(&bridge->cec_mutex);
+}
+EXPORT_SYMBOL_GPL(drm_bridge_cec_adapter_set);
+
#ifdef CONFIG_OF
/**
* of_drm_find_bridge - find the bridge corresponding to the device node in
@@ -5,10 +5,12 @@
#include <linux/types.h>
+struct drm_bridge;
struct drm_connector;
struct cec_adap_ops;
struct cec_adapter;
+struct cec_msg;
struct device;
int drm_connector_hdmi_cec_adapter_register(struct drm_connector *connector,
@@ -35,4 +37,12 @@ static inline void drm_connector_hdmi_cec_phys_addr_invalidate(struct drm_connec
static inline void drm_connector_hdmi_cec_phys_addr_set(struct drm_connector *connector) {}
#endif
+void drm_bridge_cec_transmit_done(struct drm_bridge *bridge, u8 status,
+ u8 arb_lost_cnt, u8 nack_cnt,
+ u8 low_drive_cnt, u8 error_cnt);
+void drm_bridge_cec_transmit_attempt_done(struct drm_bridge *bridge, u8 status);
+
+void drm_bridge_cec_received_msg(struct drm_bridge *bridge,
+ struct cec_msg *msg);
+
#endif
@@ -32,6 +32,7 @@
#include <drm/drm_mode_object.h>
#include <drm/drm_modes.h>
+struct cec_adapter;
struct device_node;
struct drm_bridge;
@@ -939,6 +940,15 @@ struct drm_bridge {
* @hpd_cb.
*/
void *hpd_data;
+
+ /**
+ * @cec_mutex: Protects the @cec_adapter field.
+ */
+ struct mutex cec_mutex;
+ /**
+ * @cec_adapter: Private data to be used by the CEC callbacks.
+ */
+ struct cec_adapter *cec_adapter;
};
static inline struct drm_bridge *
@@ -1062,6 +1072,9 @@ void drm_bridge_hpd_disable(struct drm_bridge *bridge);
void drm_bridge_hpd_notify(struct drm_bridge *bridge,
enum drm_connector_status status);
+void drm_bridge_cec_adapter_set(struct drm_bridge *bridge,
+ struct cec_adapter *cec_adapter);
+
#ifdef CONFIG_DRM_PANEL_BRIDGE
bool drm_bridge_is_panel(const struct drm_bridge *bridge);
struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel);
Let drm_bridge drivers handle CEC adapters in a generic way. Add a set of helper functions to be called by DRM bridge drivers to report CEC message-related events. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- drivers/gpu/drm/display/drm_hdmi_cec_helper.c | 37 +++++++++++++++++++++++++++ drivers/gpu/drm/drm_bridge.c | 16 ++++++++++++ include/drm/display/drm_hdmi_cec_helper.h | 10 ++++++++ include/drm/drm_bridge.h | 13 ++++++++++ 4 files changed, 76 insertions(+)