Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 Samsung Electronics Co., Ltd |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sub license, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice (including the |
| 12 | * next paragraph) shall be included in all copies or substantial portions |
| 13 | * of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | * DEALINGS IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
| 24 | #include <linux/err.h> |
| 25 | #include <linux/module.h> |
Daniel Vetter | 199e4e9 | 2016-08-31 18:09:05 +0200 | [diff] [blame] | 26 | #include <linux/mutex.h> |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 27 | |
Daniel Vetter | 199e4e9 | 2016-08-31 18:09:05 +0200 | [diff] [blame] | 28 | #include <drm/drm_bridge.h> |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 29 | #include <drm/drm_encoder.h> |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 30 | |
Laurent Pinchart | 4a878c0 | 2016-11-28 18:32:05 +0200 | [diff] [blame] | 31 | #include "drm_crtc_internal.h" |
| 32 | |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 33 | /** |
| 34 | * DOC: overview |
| 35 | * |
Daniel Vetter | ea0dd85 | 2016-12-29 21:48:26 +0100 | [diff] [blame] | 36 | * &struct drm_bridge represents a device that hangs on to an encoder. These are |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 37 | * handy when a regular &drm_encoder entity isn't enough to represent the entire |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 38 | * encoder chain. |
| 39 | * |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 40 | * A bridge is always attached to a single &drm_encoder at a time, but can be |
Daniel Vetter | da5335b | 2016-05-31 22:55:13 +0200 | [diff] [blame] | 41 | * either connected to it directly, or through an intermediate bridge:: |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 42 | * |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 43 | * encoder ---> bridge B ---> bridge A |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 44 | * |
| 45 | * Here, the output of the encoder feeds to bridge B, and that furthers feeds to |
| 46 | * bridge A. |
| 47 | * |
| 48 | * The driver using the bridge is responsible to make the associations between |
| 49 | * the encoder and bridges. Once these links are made, the bridges will |
| 50 | * participate along with encoder functions to perform mode_set/enable/disable |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 51 | * through the ops provided in &drm_bridge_funcs. |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 52 | * |
| 53 | * drm_bridge, like drm_panel, aren't drm_mode_object entities like planes, |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 54 | * CRTCs, encoders or connectors and hence are not visible to userspace. They |
| 55 | * just provide additional hooks to get the desired output at the end of the |
| 56 | * encoder chain. |
| 57 | * |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 58 | * Bridges can also be chained up using the &drm_bridge.next pointer. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 59 | * |
| 60 | * Both legacy CRTC helpers and the new atomic modeset helpers support bridges. |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 61 | */ |
| 62 | |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 63 | static DEFINE_MUTEX(bridge_lock); |
| 64 | static LIST_HEAD(bridge_list); |
| 65 | |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 66 | /** |
| 67 | * drm_bridge_add - add the given bridge to the global bridge list |
| 68 | * |
| 69 | * @bridge: bridge control structure |
| 70 | * |
| 71 | * RETURNS: |
| 72 | * Unconditionally returns Zero. |
| 73 | */ |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 74 | int drm_bridge_add(struct drm_bridge *bridge) |
| 75 | { |
| 76 | mutex_lock(&bridge_lock); |
| 77 | list_add_tail(&bridge->list, &bridge_list); |
| 78 | mutex_unlock(&bridge_lock); |
| 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | EXPORT_SYMBOL(drm_bridge_add); |
| 83 | |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 84 | /** |
| 85 | * drm_bridge_remove - remove the given bridge from the global bridge list |
| 86 | * |
| 87 | * @bridge: bridge control structure |
| 88 | */ |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 89 | void drm_bridge_remove(struct drm_bridge *bridge) |
| 90 | { |
| 91 | mutex_lock(&bridge_lock); |
| 92 | list_del_init(&bridge->list); |
| 93 | mutex_unlock(&bridge_lock); |
| 94 | } |
| 95 | EXPORT_SYMBOL(drm_bridge_remove); |
| 96 | |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 97 | /** |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 98 | * drm_bridge_attach - attach the bridge to an encoder's chain |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 99 | * |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 100 | * @encoder: DRM encoder |
| 101 | * @bridge: bridge to attach |
| 102 | * @previous: previous bridge in the chain (optional) |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 103 | * |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 104 | * Called by a kms driver to link the bridge to an encoder's chain. The previous |
| 105 | * argument specifies the previous bridge in the chain. If NULL, the bridge is |
| 106 | * linked directly at the encoder's output. Otherwise it is linked at the |
| 107 | * previous bridge's output. |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 108 | * |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 109 | * If non-NULL the previous bridge must be already attached by a call to this |
| 110 | * function. |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 111 | * |
| 112 | * RETURNS: |
| 113 | * Zero on success, error code on failure |
| 114 | */ |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 115 | int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, |
| 116 | struct drm_bridge *previous) |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 117 | { |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 118 | int ret; |
| 119 | |
| 120 | if (!encoder || !bridge) |
| 121 | return -EINVAL; |
| 122 | |
| 123 | if (previous && (!previous->dev || previous->encoder != encoder)) |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 124 | return -EINVAL; |
| 125 | |
| 126 | if (bridge->dev) |
| 127 | return -EBUSY; |
| 128 | |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 129 | bridge->dev = encoder->dev; |
| 130 | bridge->encoder = encoder; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 131 | |
Laurent Pinchart | 3bb80f2 | 2016-11-28 17:59:08 +0200 | [diff] [blame] | 132 | if (bridge->funcs->attach) { |
| 133 | ret = bridge->funcs->attach(bridge); |
| 134 | if (ret < 0) { |
| 135 | bridge->dev = NULL; |
| 136 | bridge->encoder = NULL; |
| 137 | return ret; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | if (previous) |
| 142 | previous->next = bridge; |
| 143 | else |
| 144 | encoder->bridge = bridge; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 145 | |
| 146 | return 0; |
| 147 | } |
| 148 | EXPORT_SYMBOL(drm_bridge_attach); |
| 149 | |
Andrea Merello | cf3bef9 | 2016-08-25 11:04:32 +0200 | [diff] [blame] | 150 | void drm_bridge_detach(struct drm_bridge *bridge) |
| 151 | { |
| 152 | if (WARN_ON(!bridge)) |
| 153 | return; |
| 154 | |
| 155 | if (WARN_ON(!bridge->dev)) |
| 156 | return; |
| 157 | |
| 158 | if (bridge->funcs->detach) |
| 159 | bridge->funcs->detach(bridge); |
| 160 | |
| 161 | bridge->dev = NULL; |
| 162 | } |
Andrea Merello | cf3bef9 | 2016-08-25 11:04:32 +0200 | [diff] [blame] | 163 | |
| 164 | /** |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 165 | * DOC: bridge callbacks |
| 166 | * |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 167 | * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM |
| 168 | * internals (atomic and CRTC helpers) use the helpers defined in drm_bridge.c |
| 169 | * These helpers call a specific &drm_bridge_funcs op for all the bridges |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 170 | * during encoder configuration. |
| 171 | * |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 172 | * For detailed specification of the bridge callbacks see &drm_bridge_funcs. |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 173 | */ |
| 174 | |
| 175 | /** |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 176 | * drm_bridge_mode_fixup - fixup proposed mode for all bridges in the |
| 177 | * encoder chain |
| 178 | * @bridge: bridge control structure |
| 179 | * @mode: desired mode to be set for the bridge |
| 180 | * @adjusted_mode: updated mode that works for this bridge |
| 181 | * |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 182 | * Calls &drm_bridge_funcs.mode_fixup for all the bridges in the |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 183 | * encoder chain, starting from the first bridge to the last. |
| 184 | * |
| 185 | * Note: the bridge passed should be the one closest to the encoder |
| 186 | * |
| 187 | * RETURNS: |
| 188 | * true on success, false on failure |
| 189 | */ |
| 190 | bool drm_bridge_mode_fixup(struct drm_bridge *bridge, |
| 191 | const struct drm_display_mode *mode, |
| 192 | struct drm_display_mode *adjusted_mode) |
| 193 | { |
| 194 | bool ret = true; |
| 195 | |
| 196 | if (!bridge) |
| 197 | return true; |
| 198 | |
| 199 | if (bridge->funcs->mode_fixup) |
| 200 | ret = bridge->funcs->mode_fixup(bridge, mode, adjusted_mode); |
| 201 | |
| 202 | ret = ret && drm_bridge_mode_fixup(bridge->next, mode, adjusted_mode); |
| 203 | |
| 204 | return ret; |
| 205 | } |
| 206 | EXPORT_SYMBOL(drm_bridge_mode_fixup); |
| 207 | |
| 208 | /** |
Jose Abreu | b1240f8 | 2017-05-25 15:19:14 +0100 | [diff] [blame] | 209 | * drm_bridge_mode_valid - validate the mode against all bridges in the |
| 210 | * encoder chain. |
| 211 | * @bridge: bridge control structure |
| 212 | * @mode: desired mode to be validated |
| 213 | * |
| 214 | * Calls &drm_bridge_funcs.mode_valid for all the bridges in the encoder |
| 215 | * chain, starting from the first bridge to the last. If at least one bridge |
| 216 | * does not accept the mode the function returns the error code. |
| 217 | * |
| 218 | * Note: the bridge passed should be the one closest to the encoder. |
| 219 | * |
| 220 | * RETURNS: |
| 221 | * MODE_OK on success, drm_mode_status Enum error code on failure |
| 222 | */ |
| 223 | enum drm_mode_status drm_bridge_mode_valid(struct drm_bridge *bridge, |
| 224 | const struct drm_display_mode *mode) |
| 225 | { |
| 226 | enum drm_mode_status ret = MODE_OK; |
| 227 | |
| 228 | if (!bridge) |
| 229 | return ret; |
| 230 | |
| 231 | if (bridge->funcs->mode_valid) |
| 232 | ret = bridge->funcs->mode_valid(bridge, mode); |
| 233 | |
| 234 | if (ret != MODE_OK) |
| 235 | return ret; |
| 236 | |
| 237 | return drm_bridge_mode_valid(bridge->next, mode); |
| 238 | } |
| 239 | EXPORT_SYMBOL(drm_bridge_mode_valid); |
| 240 | |
| 241 | /** |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 242 | * drm_bridge_disable - disables all bridges in the encoder chain |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 243 | * @bridge: bridge control structure |
| 244 | * |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 245 | * Calls &drm_bridge_funcs.disable op for all the bridges in the encoder |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 246 | * chain, starting from the last bridge to the first. These are called before |
| 247 | * calling the encoder's prepare op. |
| 248 | * |
| 249 | * Note: the bridge passed should be the one closest to the encoder |
| 250 | */ |
| 251 | void drm_bridge_disable(struct drm_bridge *bridge) |
| 252 | { |
| 253 | if (!bridge) |
| 254 | return; |
| 255 | |
| 256 | drm_bridge_disable(bridge->next); |
| 257 | |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 258 | if (bridge->funcs->disable) |
| 259 | bridge->funcs->disable(bridge); |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 260 | } |
| 261 | EXPORT_SYMBOL(drm_bridge_disable); |
| 262 | |
| 263 | /** |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 264 | * drm_bridge_post_disable - cleans up after disabling all bridges in the encoder chain |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 265 | * @bridge: bridge control structure |
| 266 | * |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 267 | * Calls &drm_bridge_funcs.post_disable op for all the bridges in the |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 268 | * encoder chain, starting from the first bridge to the last. These are called |
| 269 | * after completing the encoder's prepare op. |
| 270 | * |
| 271 | * Note: the bridge passed should be the one closest to the encoder |
| 272 | */ |
| 273 | void drm_bridge_post_disable(struct drm_bridge *bridge) |
| 274 | { |
| 275 | if (!bridge) |
| 276 | return; |
| 277 | |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 278 | if (bridge->funcs->post_disable) |
| 279 | bridge->funcs->post_disable(bridge); |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 280 | |
| 281 | drm_bridge_post_disable(bridge->next); |
| 282 | } |
| 283 | EXPORT_SYMBOL(drm_bridge_post_disable); |
| 284 | |
| 285 | /** |
| 286 | * drm_bridge_mode_set - set proposed mode for all bridges in the |
| 287 | * encoder chain |
| 288 | * @bridge: bridge control structure |
| 289 | * @mode: desired mode to be set for the bridge |
| 290 | * @adjusted_mode: updated mode that works for this bridge |
| 291 | * |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 292 | * Calls &drm_bridge_funcs.mode_set op for all the bridges in the |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 293 | * encoder chain, starting from the first bridge to the last. |
| 294 | * |
| 295 | * Note: the bridge passed should be the one closest to the encoder |
| 296 | */ |
| 297 | void drm_bridge_mode_set(struct drm_bridge *bridge, |
| 298 | struct drm_display_mode *mode, |
| 299 | struct drm_display_mode *adjusted_mode) |
| 300 | { |
| 301 | if (!bridge) |
| 302 | return; |
| 303 | |
| 304 | if (bridge->funcs->mode_set) |
| 305 | bridge->funcs->mode_set(bridge, mode, adjusted_mode); |
| 306 | |
| 307 | drm_bridge_mode_set(bridge->next, mode, adjusted_mode); |
| 308 | } |
| 309 | EXPORT_SYMBOL(drm_bridge_mode_set); |
| 310 | |
| 311 | /** |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 312 | * drm_bridge_pre_enable - prepares for enabling all |
| 313 | * bridges in the encoder chain |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 314 | * @bridge: bridge control structure |
| 315 | * |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 316 | * Calls &drm_bridge_funcs.pre_enable op for all the bridges in the encoder |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 317 | * chain, starting from the last bridge to the first. These are called |
| 318 | * before calling the encoder's commit op. |
| 319 | * |
| 320 | * Note: the bridge passed should be the one closest to the encoder |
| 321 | */ |
| 322 | void drm_bridge_pre_enable(struct drm_bridge *bridge) |
| 323 | { |
| 324 | if (!bridge) |
| 325 | return; |
| 326 | |
| 327 | drm_bridge_pre_enable(bridge->next); |
| 328 | |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 329 | if (bridge->funcs->pre_enable) |
| 330 | bridge->funcs->pre_enable(bridge); |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 331 | } |
| 332 | EXPORT_SYMBOL(drm_bridge_pre_enable); |
| 333 | |
| 334 | /** |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 335 | * drm_bridge_enable - enables all bridges in the encoder chain |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 336 | * @bridge: bridge control structure |
| 337 | * |
Daniel Vetter | 4541d31 | 2017-01-02 09:17:26 +0100 | [diff] [blame] | 338 | * Calls &drm_bridge_funcs.enable op for all the bridges in the encoder |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 339 | * chain, starting from the first bridge to the last. These are called |
| 340 | * after completing the encoder's commit op. |
| 341 | * |
| 342 | * Note that the bridge passed should be the one closest to the encoder |
| 343 | */ |
| 344 | void drm_bridge_enable(struct drm_bridge *bridge) |
| 345 | { |
| 346 | if (!bridge) |
| 347 | return; |
| 348 | |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 349 | if (bridge->funcs->enable) |
| 350 | bridge->funcs->enable(bridge); |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 351 | |
| 352 | drm_bridge_enable(bridge->next); |
| 353 | } |
| 354 | EXPORT_SYMBOL(drm_bridge_enable); |
| 355 | |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 356 | #ifdef CONFIG_OF |
Archit Taneja | 2331b4e | 2015-05-21 11:03:17 +0530 | [diff] [blame] | 357 | /** |
| 358 | * of_drm_find_bridge - find the bridge corresponding to the device node in |
| 359 | * the global bridge list |
| 360 | * |
| 361 | * @np: device node |
| 362 | * |
| 363 | * RETURNS: |
| 364 | * drm_bridge control struct on success, NULL on failure |
| 365 | */ |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 366 | struct drm_bridge *of_drm_find_bridge(struct device_node *np) |
| 367 | { |
| 368 | struct drm_bridge *bridge; |
| 369 | |
| 370 | mutex_lock(&bridge_lock); |
| 371 | |
| 372 | list_for_each_entry(bridge, &bridge_list, list) { |
| 373 | if (bridge->of_node == np) { |
| 374 | mutex_unlock(&bridge_lock); |
| 375 | return bridge; |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | mutex_unlock(&bridge_lock); |
| 380 | return NULL; |
| 381 | } |
| 382 | EXPORT_SYMBOL(of_drm_find_bridge); |
| 383 | #endif |
| 384 | |
| 385 | MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>"); |
| 386 | MODULE_DESCRIPTION("DRM bridge infrastructure"); |
| 387 | MODULE_LICENSE("GPL and additional rights"); |