aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Merello <andrea.merello@gmail.com>2016-08-25 05:04:32 -0400
committerArchit Taneja <architt@codeaurora.org>2016-08-28 23:43:00 -0400
commitcf3bef95e1014233cb1ce89da8cfa5cd22e7412c (patch)
treeaa79bd6123a9669499178ee470ec3bd333b486bd
parent6dcf0de7ef10244b17442f47956a1d9fabe2abe1 (diff)
drm/bridge: introduce bridge detaching mechanism
Up to now, once a bridge has been attached to a DRM device, it cannot be undone. In particular you couldn't rmmod/insmod a DRM driver that uses a bridge, because the bridge would remain bound to the first (dead) driver instance. This patch fixes this by introducing drm_encoder_detach() and a ->detach callback in drm_bridge_funcs for the bridge to be notified about detaches. It's DRM/KMS driver responsibility to call drm_encoder_detach(). While adding the bridge detach callback, with its kerneldoc, I also added kerneldoc for attach callback. Few other kerneldocs fixes around there are included. Suggested-by: Daniel Vetter <daniel@ffwll.ch> Suggested-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Andrea Merello <andrea.merello@gmail.com> Cc: Archit Taneja <architt@codeaurora.org> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Archit Taneja <architt@codeaurora.org> Link: http://patchwork.freedesktop.org/patch/msgid/1472115874-6219-1-git-send-email-andrea.merello@gmail.com
-rw-r--r--drivers/gpu/drm/drm_bridge.c29
-rw-r--r--include/drm/drm_crtc.h26
2 files changed, 52 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 255543086590..484046664d6c 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -98,11 +98,11 @@ EXPORT_SYMBOL(drm_bridge_remove);
98 * @dev: DRM device 98 * @dev: DRM device
99 * @bridge: bridge control structure 99 * @bridge: bridge control structure
100 * 100 *
101 * called by a kms driver to link one of our encoder/bridge to the given 101 * Called by a kms driver to link one of our encoder/bridge to the given
102 * bridge. 102 * bridge.
103 * 103 *
104 * Note that setting up links between the bridge and our encoder/bridge 104 * Note that setting up links between the bridge and our encoder/bridge
105 * objects needs to be handled by the kms driver itself 105 * objects needs to be handled by the kms driver itself.
106 * 106 *
107 * RETURNS: 107 * RETURNS:
108 * Zero on success, error code on failure 108 * Zero on success, error code on failure
@@ -125,6 +125,31 @@ int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge)
125EXPORT_SYMBOL(drm_bridge_attach); 125EXPORT_SYMBOL(drm_bridge_attach);
126 126
127/** 127/**
128 * drm_bridge_detach - deassociate given bridge from its DRM device
129 *
130 * @bridge: bridge control structure
131 *
132 * Called by a kms driver to unlink the given bridge from its DRM device.
133 *
134 * Note that tearing down links between the bridge and our encoder/bridge
135 * objects needs to be handled by the kms driver itself.
136 */
137void drm_bridge_detach(struct drm_bridge *bridge)
138{
139 if (WARN_ON(!bridge))
140 return;
141
142 if (WARN_ON(!bridge->dev))
143 return;
144
145 if (bridge->funcs->detach)
146 bridge->funcs->detach(bridge);
147
148 bridge->dev = NULL;
149}
150EXPORT_SYMBOL(drm_bridge_detach);
151
152/**
128 * DOC: bridge callbacks 153 * DOC: bridge callbacks
129 * 154 *
130 * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM 155 * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 3fa0275e509f..bb214a114329 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1118,12 +1118,33 @@ struct drm_plane {
1118 1118
1119/** 1119/**
1120 * struct drm_bridge_funcs - drm_bridge control functions 1120 * struct drm_bridge_funcs - drm_bridge control functions
1121 * @attach: Called during drm_bridge_attach
1122 */ 1121 */
1123struct drm_bridge_funcs { 1122struct drm_bridge_funcs {
1123 /**
1124 * @attach:
1125 *
1126 * This callback is invoked whenever our bridge is being attached to a
1127 * &drm_encoder.
1128 *
1129 * The attach callback is optional.
1130 *
1131 * RETURNS:
1132 *
1133 * Zero on success, error code on failure.
1134 */
1124 int (*attach)(struct drm_bridge *bridge); 1135 int (*attach)(struct drm_bridge *bridge);
1125 1136
1126 /** 1137 /**
1138 * @detach:
1139 *
1140 * This callback is invoked whenever our bridge is being detached from a
1141 * &drm_encoder.
1142 *
1143 * The detach callback is optional.
1144 */
1145 void (*detach)(struct drm_bridge *bridge);
1146
1147 /**
1127 * @mode_fixup: 1148 * @mode_fixup:
1128 * 1149 *
1129 * This callback is used to validate and adjust a mode. The paramater 1150 * This callback is used to validate and adjust a mode. The paramater
@@ -1137,6 +1158,8 @@ struct drm_bridge_funcs {
1137 * this function passes all other callbacks must succeed for this 1158 * this function passes all other callbacks must succeed for this
1138 * configuration. 1159 * configuration.
1139 * 1160 *
1161 * The mode_fixup callback is optional.
1162 *
1140 * NOTE: 1163 * NOTE:
1141 * 1164 *
1142 * This function is called in the check phase of atomic modesets, which 1165 * This function is called in the check phase of atomic modesets, which
@@ -2426,6 +2449,7 @@ extern int drm_bridge_add(struct drm_bridge *bridge);
2426extern void drm_bridge_remove(struct drm_bridge *bridge); 2449extern void drm_bridge_remove(struct drm_bridge *bridge);
2427extern struct drm_bridge *of_drm_find_bridge(struct device_node *np); 2450extern struct drm_bridge *of_drm_find_bridge(struct device_node *np);
2428extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge); 2451extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge);
2452extern void drm_bridge_detach(struct drm_bridge *bridge);
2429 2453
2430bool drm_bridge_mode_fixup(struct drm_bridge *bridge, 2454bool drm_bridge_mode_fixup(struct drm_bridge *bridge,
2431 const struct drm_display_mode *mode, 2455 const struct drm_display_mode *mode,