| 1 | |
| 2 | |
| 3 | * Copyright (C) 2016 Laurent Pinchart <[email protected]>
|
| 4 | * Copyright (C) 2017 Broadcom
|
| 5 |
|
| 6 |
|
| 7 | #include <linux/debugfs.h>
|
| 8 | #include <linux/export.h>
|
| 9 |
|
| 10 | #include <drm/drm_atomic_helper.h>
|
| 11 | #include <drm/drm_bridge.h>
|
| 12 | #include <drm/drm_connector.h>
|
| 13 | #include <drm/drm_encoder.h>
|
| 14 | #include <drm/drm_managed.h>
|
| 15 | #include <drm/drm_modeset_helper_vtables.h>
|
| 16 | #include <drm/drm_of.h>
|
| 17 | #include <drm/drm_panel.h>
|
| 18 | #include <drm/drm_print.h>
|
| 19 | #include <drm/drm_probe_helper.h>
|
| 20 |
|
| 21 | struct panel_bridge {
|
| 22 | struct drm_bridge bridge;
|
| 23 | struct drm_connector connector;
|
| 24 | struct drm_panel *panel;
|
| 25 | u32 connector_type;
|
| 26 | };
|
| 27 |
|
| 28 | static inline struct panel_bridge *
|
| 29 | drm_bridge_to_panel_bridge(struct drm_bridge *bridge)
|
| 30 | {
|
| 31 | return container_of(bridge, struct panel_bridge, bridge);
|
| 32 | }
|
| 33 |
|
| 34 | static inline struct panel_bridge *
|
| 35 | drm_connector_to_panel_bridge(struct drm_connector *connector)
|
| 36 | {
|
| 37 | return container_of(connector, struct panel_bridge, connector);
|
| 38 | }
|
| 39 |
|
| 40 | static int panel_bridge_connector_get_modes(struct drm_connector *connector)
|
| 41 | {
|
| 42 | struct panel_bridge *panel_bridge =
|
| 43 | drm_connector_to_panel_bridge(connector);
|
| 44 |
|
| 45 | return drm_panel_get_modes(panel_bridge->panel, connector);
|
| 46 | }
|
| 47 |
|
| 48 | static const struct drm_connector_helper_funcs
|
| 49 | panel_bridge_connector_helper_funcs = {
|
| 50 | .get_modes = panel_bridge_connector_get_modes,
|
| 51 | };
|
| 52 |
|
| 53 | static const struct drm_connector_funcs panel_bridge_connector_funcs = {
|
| 54 | .reset = drm_atomic_helper_connector_reset,
|
| 55 | .fill_modes = drm_helper_probe_single_connector_modes,
|
| 56 | .destroy = drm_connector_cleanup,
|
| 57 | .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
|
| 58 | .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
|
| 59 | };
|
| 60 |
|
| 61 | static int panel_bridge_attach(struct drm_bridge *bridge,
|
| 62 | struct drm_encoder *encoder,
|
| 63 | enum drm_bridge_attach_flags flags)
|
| 64 | {
|
| 65 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 66 | struct drm_connector *connector = &panel_bridge->connector;
|
| 67 | int ret;
|
| 68 |
|
| 69 | if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
|
| 70 | return 0;
|
| 71 |
|
| 72 | drm_connector_helper_add(connector,
|
| 73 | &panel_bridge_connector_helper_funcs);
|
| 74 |
|
| 75 | ret = drm_connector_init(bridge->dev, connector,
|
| 76 | &panel_bridge_connector_funcs,
|
| 77 | panel_bridge->connector_type);
|
| 78 | if (ret) {
|
| 79 | DRM_ERROR("Failed to initialize connector\n");
|
| 80 | return ret;
|
| 81 | }
|
| 82 |
|
| 83 | drm_panel_bridge_set_orientation(connector, bridge);
|
| 84 |
|
| 85 | drm_connector_attach_encoder(&panel_bridge->connector,
|
| 86 | encoder);
|
| 87 |
|
| 88 | if (bridge->dev->registered) {
|
| 89 | if (connector->funcs->reset)
|
| 90 | connector->funcs->reset(connector);
|
| 91 | drm_connector_register(connector);
|
| 92 | }
|
| 93 |
|
| 94 | return 0;
|
| 95 | }
|
| 96 |
|
| 97 | static void panel_bridge_detach(struct drm_bridge *bridge)
|
| 98 | {
|
| 99 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 100 | struct drm_connector *connector = &panel_bridge->connector;
|
| 101 |
|
| 102 | |
| 103 | * Cleanup the connector if we know it was initialized.
|
| 104 | *
|
| 105 | * FIXME: This wouldn't be needed if the panel_bridge structure was
|
| 106 | * allocated with drmm_kzalloc(). This might be tricky since the
|
| 107 | * drm_device pointer can only be retrieved when the bridge is attached.
|
| 108 |
|
| 109 | if (connector->dev)
|
| 110 | drm_connector_cleanup(connector);
|
| 111 | }
|
| 112 |
|
| 113 | static void panel_bridge_atomic_pre_enable(struct drm_bridge *bridge,
|
| 114 | struct drm_atomic_commit *atomic_state)
|
| 115 | {
|
| 116 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 117 | struct drm_encoder *encoder = bridge->encoder;
|
| 118 | struct drm_crtc *crtc;
|
| 119 | struct drm_crtc_state *old_crtc_state;
|
| 120 |
|
| 121 | crtc = drm_atomic_get_new_crtc_for_encoder(atomic_state, encoder);
|
| 122 | if (!crtc)
|
| 123 | return;
|
| 124 |
|
| 125 | old_crtc_state = drm_atomic_get_old_crtc_state(atomic_state, crtc);
|
| 126 | if (old_crtc_state && old_crtc_state->self_refresh_active)
|
| 127 | return;
|
| 128 |
|
| 129 | drm_panel_prepare(panel_bridge->panel);
|
| 130 | }
|
| 131 |
|
| 132 | static void panel_bridge_atomic_enable(struct drm_bridge *bridge,
|
| 133 | struct drm_atomic_commit *atomic_state)
|
| 134 | {
|
| 135 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 136 | struct drm_encoder *encoder = bridge->encoder;
|
| 137 | struct drm_crtc *crtc;
|
| 138 | struct drm_crtc_state *old_crtc_state;
|
| 139 |
|
| 140 | crtc = drm_atomic_get_new_crtc_for_encoder(atomic_state, encoder);
|
| 141 | if (!crtc)
|
| 142 | return;
|
| 143 |
|
| 144 | old_crtc_state = drm_atomic_get_old_crtc_state(atomic_state, crtc);
|
| 145 | if (old_crtc_state && old_crtc_state->self_refresh_active)
|
| 146 | return;
|
| 147 |
|
| 148 | drm_panel_enable(panel_bridge->panel);
|
| 149 | }
|
| 150 |
|
| 151 | static void panel_bridge_atomic_disable(struct drm_bridge *bridge,
|
| 152 | struct drm_atomic_commit *atomic_state)
|
| 153 | {
|
| 154 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 155 | struct drm_encoder *encoder = bridge->encoder;
|
| 156 | struct drm_crtc *crtc;
|
| 157 | struct drm_crtc_state *new_crtc_state;
|
| 158 |
|
| 159 | crtc = drm_atomic_get_old_crtc_for_encoder(atomic_state, encoder);
|
| 160 | if (!crtc)
|
| 161 | return;
|
| 162 |
|
| 163 | new_crtc_state = drm_atomic_get_new_crtc_state(atomic_state, crtc);
|
| 164 | if (new_crtc_state && new_crtc_state->self_refresh_active)
|
| 165 | return;
|
| 166 |
|
| 167 | drm_panel_disable(panel_bridge->panel);
|
| 168 | }
|
| 169 |
|
| 170 | static void panel_bridge_atomic_post_disable(struct drm_bridge *bridge,
|
| 171 | struct drm_atomic_commit *atomic_state)
|
| 172 | {
|
| 173 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 174 | struct drm_encoder *encoder = bridge->encoder;
|
| 175 | struct drm_crtc *crtc;
|
| 176 | struct drm_crtc_state *new_crtc_state;
|
| 177 |
|
| 178 | crtc = drm_atomic_get_old_crtc_for_encoder(atomic_state, encoder);
|
| 179 | if (!crtc)
|
| 180 | return;
|
| 181 |
|
| 182 | new_crtc_state = drm_atomic_get_new_crtc_state(atomic_state, crtc);
|
| 183 | if (new_crtc_state && new_crtc_state->self_refresh_active)
|
| 184 | return;
|
| 185 |
|
| 186 | drm_panel_unprepare(panel_bridge->panel);
|
| 187 | }
|
| 188 |
|
| 189 | static int panel_bridge_get_modes(struct drm_bridge *bridge,
|
| 190 | struct drm_connector *connector)
|
| 191 | {
|
| 192 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 193 |
|
| 194 | return drm_panel_get_modes(panel_bridge->panel, connector);
|
| 195 | }
|
| 196 |
|
| 197 | static void panel_bridge_debugfs_init(struct drm_bridge *bridge,
|
| 198 | struct dentry *root)
|
| 199 | {
|
| 200 | struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 201 | struct drm_panel *panel = panel_bridge->panel;
|
| 202 |
|
| 203 | root = debugfs_create_dir("panel", root);
|
| 204 | if (panel->funcs->debugfs_init)
|
| 205 | panel->funcs->debugfs_init(panel, root);
|
| 206 | }
|
| 207 |
|
| 208 | static const struct drm_bridge_funcs panel_bridge_bridge_funcs = {
|
| 209 | .attach = panel_bridge_attach,
|
| 210 | .detach = panel_bridge_detach,
|
| 211 | .atomic_pre_enable = panel_bridge_atomic_pre_enable,
|
| 212 | .atomic_enable = panel_bridge_atomic_enable,
|
| 213 | .atomic_disable = panel_bridge_atomic_disable,
|
| 214 | .atomic_post_disable = panel_bridge_atomic_post_disable,
|
| 215 | .get_modes = panel_bridge_get_modes,
|
| 216 | .atomic_create_state = drm_atomic_helper_bridge_create_state,
|
| 217 | .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
|
| 218 | .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
|
| 219 | .atomic_get_input_bus_fmts = drm_atomic_helper_bridge_propagate_bus_fmt,
|
| 220 | .debugfs_init = panel_bridge_debugfs_init,
|
| 221 | };
|
| 222 |
|
| 223 | |
| 224 | * drm_bridge_is_panel - Checks if a drm_bridge is a panel_bridge.
|
| 225 | *
|
| 226 | * @bridge: The drm_bridge to be checked.
|
| 227 | *
|
| 228 | * Returns true if the bridge is a panel bridge, or false otherwise.
|
| 229 |
|
| 230 | bool drm_bridge_is_panel(const struct drm_bridge *bridge)
|
| 231 | {
|
| 232 | return bridge->funcs == &panel_bridge_bridge_funcs;
|
| 233 | }
|
| 234 | EXPORT_SYMBOL(drm_bridge_is_panel);
|
| 235 |
|
| 236 | |
| 237 | * drm_panel_bridge_add - Creates a &drm_bridge and &drm_connector that
|
| 238 | * just calls the appropriate functions from &drm_panel.
|
| 239 | *
|
| 240 | * @panel: The drm_panel being wrapped. Must be non-NULL.
|
| 241 | *
|
| 242 | * For drivers converting from directly using drm_panel: The expected
|
| 243 | * usage pattern is that during either encoder module probe or DSI
|
| 244 | * host attach, a drm_panel will be looked up through
|
| 245 | * drm_of_find_panel_or_bridge(). drm_panel_bridge_add() is used to
|
| 246 | * wrap that panel in the new bridge, and the result can then be
|
| 247 | * passed to drm_bridge_attach(). The drm_panel_prepare() and related
|
| 248 | * functions can be dropped from the encoder driver (they're now
|
| 249 | * called by the KMS helpers before calling into the encoder), along
|
| 250 | * with connector creation. When done with the bridge (after
|
| 251 | * drm_mode_config_cleanup() if the bridge has already been attached), then
|
| 252 | * drm_panel_bridge_remove() to free it.
|
| 253 | *
|
| 254 | * The connector type is set to @panel->connector_type, which must be set to a
|
| 255 | * known type. Calling this function with a panel whose connector type is
|
| 256 | * DRM_MODE_CONNECTOR_Unknown will return ERR_PTR(-EINVAL).
|
| 257 | *
|
| 258 | * See devm_drm_panel_bridge_add() for an automatically managed version of this
|
| 259 | * function.
|
| 260 |
|
| 261 | struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel)
|
| 262 | {
|
| 263 | if (WARN_ON(panel->connector_type == DRM_MODE_CONNECTOR_Unknown))
|
| 264 | return ERR_PTR(-EINVAL);
|
| 265 |
|
| 266 | return drm_panel_bridge_add_typed(panel, panel->connector_type);
|
| 267 | }
|
| 268 | EXPORT_SYMBOL(drm_panel_bridge_add);
|
| 269 |
|
| 270 | |
| 271 | * drm_panel_bridge_add_typed - Creates a &drm_bridge and &drm_connector with
|
| 272 | * an explicit connector type.
|
| 273 | * @panel: The drm_panel being wrapped. Must be non-NULL.
|
| 274 | * @connector_type: The connector type (DRM_MODE_CONNECTOR_*)
|
| 275 | *
|
| 276 | * This is just like drm_panel_bridge_add(), but forces the connector type to
|
| 277 | * @connector_type instead of infering it from the panel.
|
| 278 | *
|
| 279 | * This function is deprecated and should not be used in new drivers. Use
|
| 280 | * drm_panel_bridge_add() instead, and fix panel drivers as necessary if they
|
| 281 | * don't report a connector type.
|
| 282 |
|
| 283 | struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel,
|
| 284 | u32 connector_type)
|
| 285 | {
|
| 286 | struct panel_bridge *panel_bridge;
|
| 287 |
|
| 288 | if (!panel)
|
| 289 | return ERR_PTR(-EINVAL);
|
| 290 |
|
| 291 | panel_bridge = devm_drm_bridge_alloc(panel->dev, struct panel_bridge, bridge,
|
| 292 | &panel_bridge_bridge_funcs);
|
| 293 | if (IS_ERR(panel_bridge))
|
| 294 | return (void *)panel_bridge;
|
| 295 |
|
| 296 | panel_bridge->connector_type = connector_type;
|
| 297 | panel_bridge->panel = drm_panel_get(panel);
|
| 298 |
|
| 299 | panel_bridge->bridge.of_node = panel->dev->of_node;
|
| 300 | panel_bridge->bridge.ops = DRM_BRIDGE_OP_MODES;
|
| 301 | panel_bridge->bridge.type = connector_type;
|
| 302 | panel_bridge->bridge.pre_enable_prev_first = panel->prepare_prev_first;
|
| 303 |
|
| 304 | drm_bridge_add(&panel_bridge->bridge);
|
| 305 |
|
| 306 | return &panel_bridge->bridge;
|
| 307 | }
|
| 308 | EXPORT_SYMBOL(drm_panel_bridge_add_typed);
|
| 309 |
|
| 310 | |
| 311 | * drm_panel_bridge_remove - Unregisters and frees a drm_bridge
|
| 312 | * created by drm_panel_bridge_add().
|
| 313 | *
|
| 314 | * @bridge: The drm_bridge being freed.
|
| 315 |
|
| 316 | void drm_panel_bridge_remove(struct drm_bridge *bridge)
|
| 317 | {
|
| 318 | struct panel_bridge *panel_bridge;
|
| 319 | struct drm_panel *panel;
|
| 320 |
|
| 321 | if (!bridge)
|
| 322 | return;
|
| 323 |
|
| 324 | if (!drm_bridge_is_panel(bridge)) {
|
| 325 | drm_warn(bridge->dev, "%s: called on non-panel bridge!\n", __func__);
|
| 326 | return;
|
| 327 | }
|
| 328 |
|
| 329 | panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 330 | panel = panel_bridge->panel;
|
| 331 |
|
| 332 | drm_bridge_remove(bridge);
|
| 333 |
|
| 334 | devm_drm_put_bridge(panel->dev, bridge);
|
| 335 | drm_panel_put(panel);
|
| 336 | }
|
| 337 | EXPORT_SYMBOL(drm_panel_bridge_remove);
|
| 338 |
|
| 339 | |
| 340 | * drm_panel_bridge_set_orientation - Set the connector's panel orientation
|
| 341 | * from the bridge that can be transformed to panel bridge.
|
| 342 | *
|
| 343 | * @connector: The connector to be set panel orientation.
|
| 344 | * @bridge: The drm_bridge to be transformed to panel bridge.
|
| 345 | *
|
| 346 | * Returns 0 on success, negative errno on failure.
|
| 347 |
|
| 348 | int drm_panel_bridge_set_orientation(struct drm_connector *connector,
|
| 349 | struct drm_bridge *bridge)
|
| 350 | {
|
| 351 | struct panel_bridge *panel_bridge;
|
| 352 |
|
| 353 | panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 354 |
|
| 355 | return drm_connector_set_orientation_from_panel(connector,
|
| 356 | panel_bridge->panel);
|
| 357 | }
|
| 358 | EXPORT_SYMBOL(drm_panel_bridge_set_orientation);
|
| 359 |
|
| 360 | static void devm_drm_panel_bridge_release(struct device *dev, void *res)
|
| 361 | {
|
| 362 | struct drm_bridge *bridge = *(struct drm_bridge **)res;
|
| 363 | struct panel_bridge *panel_bridge;
|
| 364 | struct drm_panel *panel;
|
| 365 |
|
| 366 | if (!bridge)
|
| 367 | return;
|
| 368 |
|
| 369 | panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 370 | panel = panel_bridge->panel;
|
| 371 | drm_bridge_remove(bridge);
|
| 372 | drm_panel_put(panel);
|
| 373 | }
|
| 374 |
|
| 375 | |
| 376 | * devm_drm_panel_bridge_add - Creates a managed &drm_bridge and &drm_connector
|
| 377 | * that just calls the appropriate functions from &drm_panel.
|
| 378 | * @dev: device to tie the bridge lifetime to
|
| 379 | * @panel: The drm_panel being wrapped. Must be non-NULL.
|
| 380 | *
|
| 381 | * This is the managed version of drm_panel_bridge_add() which automatically
|
| 382 | * calls drm_panel_bridge_remove() when @dev is unbound.
|
| 383 |
|
| 384 | struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev,
|
| 385 | struct drm_panel *panel)
|
| 386 | {
|
| 387 | if (WARN_ON(panel->connector_type == DRM_MODE_CONNECTOR_Unknown))
|
| 388 | return ERR_PTR(-EINVAL);
|
| 389 |
|
| 390 | return devm_drm_panel_bridge_add_typed(dev, panel,
|
| 391 | panel->connector_type);
|
| 392 | }
|
| 393 | EXPORT_SYMBOL(devm_drm_panel_bridge_add);
|
| 394 |
|
| 395 | |
| 396 | * devm_drm_panel_bridge_add_typed - Creates a managed &drm_bridge and
|
| 397 | * &drm_connector with an explicit connector type.
|
| 398 | * @dev: device to tie the bridge lifetime to
|
| 399 | * @panel: The drm_panel being wrapped. Must be non-NULL.
|
| 400 | * @connector_type: The connector type (DRM_MODE_CONNECTOR_*)
|
| 401 | *
|
| 402 | * This is just like devm_drm_panel_bridge_add(), but forces the connector type
|
| 403 | * to @connector_type instead of infering it from the panel.
|
| 404 | *
|
| 405 | * This function is deprecated and should not be used in new drivers. Use
|
| 406 | * devm_drm_panel_bridge_add() instead, and fix panel drivers as necessary if
|
| 407 | * they don't report a connector type.
|
| 408 |
|
| 409 | struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev,
|
| 410 | struct drm_panel *panel,
|
| 411 | u32 connector_type)
|
| 412 | {
|
| 413 | struct drm_bridge **ptr, *bridge;
|
| 414 |
|
| 415 | ptr = devres_alloc(devm_drm_panel_bridge_release, sizeof(*ptr),
|
| 416 | GFP_KERNEL);
|
| 417 | if (!ptr)
|
| 418 | return ERR_PTR(-ENOMEM);
|
| 419 |
|
| 420 | bridge = drm_panel_bridge_add_typed(panel, connector_type);
|
| 421 | if (IS_ERR(bridge)) {
|
| 422 | devres_free(ptr);
|
| 423 | return bridge;
|
| 424 | }
|
| 425 |
|
| 426 | *ptr = bridge;
|
| 427 | devres_add(dev, ptr);
|
| 428 |
|
| 429 | return bridge;
|
| 430 | }
|
| 431 | EXPORT_SYMBOL(devm_drm_panel_bridge_add_typed);
|
| 432 |
|
| 433 | static void drmm_drm_panel_bridge_release(struct drm_device *drm, void *ptr)
|
| 434 | {
|
| 435 | struct drm_bridge *bridge = ptr;
|
| 436 |
|
| 437 | drm_panel_bridge_remove(bridge);
|
| 438 | }
|
| 439 |
|
| 440 | |
| 441 | * drmm_panel_bridge_add - Creates a DRM-managed &drm_bridge and
|
| 442 | * &drm_connector that just calls the
|
| 443 | * appropriate functions from &drm_panel.
|
| 444 | *
|
| 445 | * @drm: DRM device to tie the bridge lifetime to
|
| 446 | * @panel: The drm_panel being wrapped. Must be non-NULL.
|
| 447 | *
|
| 448 | * This is the DRM-managed version of drm_panel_bridge_add() which
|
| 449 | * automatically calls drm_panel_bridge_remove() when @dev is cleaned
|
| 450 | * up.
|
| 451 |
|
| 452 | struct drm_bridge *drmm_panel_bridge_add(struct drm_device *drm,
|
| 453 | struct drm_panel *panel)
|
| 454 | {
|
| 455 | struct drm_bridge *bridge;
|
| 456 | int ret;
|
| 457 |
|
| 458 | bridge = drm_panel_bridge_add_typed(panel, panel->connector_type);
|
| 459 | if (IS_ERR(bridge))
|
| 460 | return bridge;
|
| 461 |
|
| 462 | ret = drmm_add_action_or_reset(drm, drmm_drm_panel_bridge_release,
|
| 463 | bridge);
|
| 464 | if (ret)
|
| 465 | return ERR_PTR(ret);
|
| 466 |
|
| 467 | return bridge;
|
| 468 | }
|
| 469 | EXPORT_SYMBOL(drmm_panel_bridge_add);
|
| 470 |
|
| 471 | |
| 472 | * drm_panel_bridge_connector - return the connector for the panel bridge
|
| 473 | * @bridge: The drm_bridge.
|
| 474 | *
|
| 475 | * drm_panel_bridge creates the connector.
|
| 476 | * This function gives external access to the connector.
|
| 477 | *
|
| 478 | * Returns: Pointer to drm_connector
|
| 479 |
|
| 480 | struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge)
|
| 481 | {
|
| 482 | struct panel_bridge *panel_bridge;
|
| 483 |
|
| 484 | panel_bridge = drm_bridge_to_panel_bridge(bridge);
|
| 485 |
|
| 486 | return &panel_bridge->connector;
|
| 487 | }
|
| 488 | EXPORT_SYMBOL(drm_panel_bridge_connector);
|
| 489 |
|
| 490 | #ifdef CONFIG_OF
|
| 491 | |
| 492 | * devm_drm_of_get_bridge - Return next bridge in the chain
|
| 493 | * @dev: device to tie the bridge lifetime to
|
| 494 | * @np: device tree node containing encoder output ports
|
| 495 | * @port: port in the device tree node
|
| 496 | * @endpoint: endpoint in the device tree node
|
| 497 | *
|
| 498 | * Given a DT node's port and endpoint number, finds the connected node
|
| 499 | * and returns the associated bridge if any, or creates and returns a
|
| 500 | * drm panel bridge instance if a panel is connected.
|
| 501 | *
|
| 502 | * Returns a pointer to the bridge if successful, or an error pointer
|
| 503 | * otherwise.
|
| 504 |
|
| 505 | struct drm_bridge *devm_drm_of_get_bridge(struct device *dev,
|
| 506 | struct device_node *np,
|
| 507 | u32 port, u32 endpoint)
|
| 508 | {
|
| 509 | struct drm_bridge *bridge;
|
| 510 | struct drm_panel *panel;
|
| 511 | int ret;
|
| 512 |
|
| 513 | ret = drm_of_find_panel_or_bridge(np, port, endpoint,
|
| 514 | &panel, &bridge);
|
| 515 | if (ret)
|
| 516 | return ERR_PTR(ret);
|
| 517 |
|
| 518 | if (panel) {
|
| 519 | bridge = devm_drm_panel_bridge_add(dev, panel);
|
| 520 | drm_panel_put(panel);
|
| 521 | }
|
| 522 |
|
| 523 | return bridge;
|
| 524 | }
|
| 525 | EXPORT_SYMBOL(devm_drm_of_get_bridge);
|
| 526 |
|
| 527 | |
| 528 | * drmm_of_get_bridge - Return next bridge in the chain
|
| 529 | * @drm: device to tie the bridge lifetime to
|
| 530 | * @np: device tree node containing encoder output ports
|
| 531 | * @port: port in the device tree node
|
| 532 | * @endpoint: endpoint in the device tree node
|
| 533 | *
|
| 534 | * Given a DT node's port and endpoint number, finds the connected node
|
| 535 | * and returns the associated bridge if any, or creates and returns a
|
| 536 | * drm panel bridge instance if a panel is connected.
|
| 537 | *
|
| 538 | * Returns a drmm managed pointer to the bridge if successful, or an error
|
| 539 | * pointer otherwise.
|
| 540 |
|
| 541 | struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm,
|
| 542 | struct device_node *np,
|
| 543 | u32 port, u32 endpoint)
|
| 544 | {
|
| 545 | struct drm_bridge *bridge;
|
| 546 | struct drm_panel *panel;
|
| 547 | int ret;
|
| 548 |
|
| 549 | ret = drm_of_find_panel_or_bridge(np, port, endpoint,
|
| 550 | &panel, &bridge);
|
| 551 | if (ret)
|
| 552 | return ERR_PTR(ret);
|
| 553 |
|
| 554 | if (panel) {
|
| 555 | bridge = drmm_panel_bridge_add(drm, panel);
|
| 556 | drm_panel_put(panel);
|
| 557 | }
|
| 558 |
|
| 559 | return bridge;
|
| 560 | }
|
| 561 | EXPORT_SYMBOL(drmm_of_get_bridge);
|
| 562 |
|
| 563 | #endif
|