From 3683e07313808d636cf9bea22236eb26e6f3f3a4 Mon Sep 17 00:00:00 2001 From: Ray Zhang Date: Mon, 22 Jan 2018 09:51:28 +0800 Subject: [PATCH] drm/bridge: add connector_init interface in drm_bridge_funcs Add the connector_init callback so a bridge is allowed to initialize the connector passed to itself. This is useful in certain cases like, the connector and bridge are created in two different modules, while the connector funcs need access extra information of the bridge. This callback offers the opportunity to override the connector's behavior. CRs-Fixed: 2140653 Change-Id: Iee228dd610d2e72d0a9e0bd960b0715b4ea6c644 Signed-off-by: Ray Zhang Signed-off-by: Narendra Muppalla --- drivers/gpu/drm/drm_bridge.c | 26 ++++++++++++++++++++++++++ include/drm/drm_bridge.h | 18 ++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index dc8cdfe1dcac..83933522496d 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -161,6 +161,32 @@ void drm_bridge_detach(struct drm_bridge *bridge) bridge->dev = NULL; } +/** + * drm_bridge_connector_init - call bridge's connector_init callback to allow + * the bridge to update connector's behavior. + * @bridge: bridge control structure + * @connector: connector control structure + * + * Calls ->connector_init() &drm_bridge_funcs op for the bridge. + * + * RETURNS: + * Zero on success, error code on failure + */ +int drm_bridge_connector_init(struct drm_bridge *bridge, + struct drm_connector *connector) +{ + int ret = 0; + + if (!bridge || !connector) + return -EINVAL; + + if (bridge->funcs->connector_init) + ret = bridge->funcs->connector_init(bridge, connector); + + return ret; +} +EXPORT_SYMBOL(drm_bridge_connector_init); + /** * DOC: bridge callbacks * diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 6522d4cbc9d9..a76bf45acd67 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -92,6 +92,22 @@ struct drm_bridge_funcs { */ enum drm_mode_status (*mode_valid)(struct drm_bridge *crtc, const struct drm_display_mode *mode); + /** + * @connector_init: + * + * This callback is used to init the connector from bridge side. In some + * cases connector and bridge are created in different modules, and the + * connector ops might need extra info from bridge. This callback offers + * the opportunity to overwrite connector's behavior in external bridge. + * + * The connector_init callback is optional. + * + * RETURNS: + * + * Zero on success, error code on failure. + */ + int (*connector_init)(struct drm_bridge *bridge, + struct drm_connector *connector); /** * @mode_fixup: @@ -263,6 +279,8 @@ void drm_bridge_mode_set(struct drm_bridge *bridge, struct drm_display_mode *adjusted_mode); void drm_bridge_pre_enable(struct drm_bridge *bridge); void drm_bridge_enable(struct drm_bridge *bridge); +int drm_bridge_connector_init(struct drm_bridge *bridge, + struct drm_connector *connector); #ifdef CONFIG_DRM_PANEL_BRIDGE struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel,