Lines Matching +full:bridge +full:- +full:enable
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
25 #include <linux/media-bus-format.h>
46 * A bridge is always attached to a single &drm_encoder at a time, but can be
49 * [ CRTC ---> ] Encoder ---> Bridge A ---> Bridge B
51 * Here, the output of the encoder feeds to bridge A, and that furthers feeds to
52 * bridge B. Bridge chains can be arbitrarily long, and shall be fully linear:
53 * Chaining multiple bridges to the output of a bridge, or the same bridge to
65 * Display drivers are responsible for linking encoders with the first bridge
66 * in the chains. This is done by acquiring the appropriate bridge with
67 * devm_drm_of_get_bridge(). Once acquired, the bridge shall be attached to the
70 * Bridges are responsible for linking themselves with the next bridge in the
77 * setting (through drm_bridge_chain_mode_set()), enable (through
87 * drm_atomic_helper_commit_modeset_disables() (either directly in hand-rolled
88 * commit check and commit tail handlers, or through the higher-level
92 * DRM bridge chain functions shall be called manually.
95 * the bridge chain. Display drivers may use the drm_bridge_connector_init()
97 * connector-related operations exposed by the bridge (see the overview
98 * documentation of bridge operations for more details).
105 * the probing of the upstream driver and the bridge driver can be
109 * - The upstream driver doesn't use the component framework and isn't a
110 * MIPI-DSI host. In this case, the bridge driver will probe at some
112 * EPROBE_DEFER as long as the bridge driver hasn't probed.
114 * - The upstream driver doesn't use the component framework, but is a
115 * MIPI-DSI host. The bridge device uses the MIPI-DCS commands to be
116 * controlled. In this case, the bridge device is a child of the
118 * device (and MIPI-DSI host) is present. The upstream driver will be
119 * assured that the bridge driver is connected between the
125 * - The upstream driver uses the component framework and is a MIPI-DSI
126 * host. The bridge device uses the MIPI-DCS commands to be
130 * - The upstream driver uses the component framework and is a MIPI-DSI
131 * host. The bridge device uses a separate bus (such as I2C) to be
133 * of the bridge and upstream drivers, so care must be taken to avoid
138 * MIPI-DSI host driver case) is to split the operations like this:
140 * - The MIPI-DSI host driver must run mipi_dsi_host_register() in its
141 * probe hook. It will make sure that the MIPI-DSI host sticks around,
144 * - In its probe hook, the bridge driver must try to find its MIPI-DSI
145 * host, register as a MIPI-DSI device and attach the MIPI-DSI device
146 * to its host. The bridge driver is now functional.
148 * - In its &struct mipi_dsi_host_ops.attach hook, the MIPI-DSI host can
150 * the bridge driver is attached and registered, we can now look for
154 * the bridge driver are functional and we can't have a deadlock-like
159 * DOC: dsi bridge operations
167 * must not be assumed that it is LP-11.
168 * pre_enable should initialise the PHY, set the data lanes to LP-11, and the
169 * clock lane to either LP-11 or HS depending on the mode_flag
172 * Ordinarily the downstream bridge DSI peripheral pre_enable will have been
173 * called before the DSI host. If the DSI peripheral requires LP-11 and/or
176 * post_disable) order to be altered to enable the DSI host first.
178 * Either the CRTC being enabled, or the DSI host enable operation should switch
182 * should stop transmitting video, and the data lanes should return to the LP-11
185 * bridge &post_disable will be called before the DSI host's post_disable.
201 * drm_bridge_add - add the given bridge to the global bridge list
203 * @bridge: bridge control structure
205 void drm_bridge_add(struct drm_bridge *bridge) in drm_bridge_add() argument
207 mutex_init(&bridge->hpd_mutex); in drm_bridge_add()
210 list_add_tail(&bridge->list, &bridge_list); in drm_bridge_add()
215 static void drm_bridge_remove_void(void *bridge) in drm_bridge_remove_void() argument
217 drm_bridge_remove(bridge); in drm_bridge_remove_void()
221 * devm_drm_bridge_add - devm managed version of drm_bridge_add()
223 * @dev: device to tie the bridge lifetime to
224 * @bridge: bridge control structure
231 int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge) in devm_drm_bridge_add() argument
233 drm_bridge_add(bridge); in devm_drm_bridge_add()
234 return devm_add_action_or_reset(dev, drm_bridge_remove_void, bridge); in devm_drm_bridge_add()
239 * drm_bridge_remove - remove the given bridge from the global bridge list
241 * @bridge: bridge control structure
243 void drm_bridge_remove(struct drm_bridge *bridge) in drm_bridge_remove() argument
246 list_del_init(&bridge->list); in drm_bridge_remove()
249 mutex_destroy(&bridge->hpd_mutex); in drm_bridge_remove()
256 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_duplicate_priv_state() local
259 state = bridge->funcs->atomic_duplicate_state(bridge); in drm_bridge_atomic_duplicate_priv_state()
260 return state ? &state->base : NULL; in drm_bridge_atomic_duplicate_priv_state()
268 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_destroy_priv_state() local
270 bridge->funcs->atomic_destroy_state(bridge, state); in drm_bridge_atomic_destroy_priv_state()
279 * drm_bridge_attach - attach the bridge to an encoder's chain
282 * @bridge: bridge to attach
283 * @previous: previous bridge in the chain (optional)
286 * Called by a kms driver to link the bridge to an encoder's chain. The previous
287 * argument specifies the previous bridge in the chain. If NULL, the bridge is
289 * previous bridge's output.
291 * If non-NULL the previous bridge must be already attached by a call to this
294 * Note that bridges attached to encoders are auto-detached during encoder
301 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, in drm_bridge_attach() argument
307 if (!encoder || !bridge) in drm_bridge_attach()
308 return -EINVAL; in drm_bridge_attach()
310 if (previous && (!previous->dev || previous->encoder != encoder)) in drm_bridge_attach()
311 return -EINVAL; in drm_bridge_attach()
313 if (bridge->dev) in drm_bridge_attach()
314 return -EBUSY; in drm_bridge_attach()
316 bridge->dev = encoder->dev; in drm_bridge_attach()
317 bridge->encoder = encoder; in drm_bridge_attach()
320 list_add(&bridge->chain_node, &previous->chain_node); in drm_bridge_attach()
322 list_add(&bridge->chain_node, &encoder->bridge_chain); in drm_bridge_attach()
324 if (bridge->funcs->attach) { in drm_bridge_attach()
325 ret = bridge->funcs->attach(bridge, flags); in drm_bridge_attach()
330 if (bridge->funcs->atomic_reset) { in drm_bridge_attach()
333 state = bridge->funcs->atomic_reset(bridge); in drm_bridge_attach()
339 drm_atomic_private_obj_init(bridge->dev, &bridge->base, in drm_bridge_attach()
340 &state->base, in drm_bridge_attach()
347 if (bridge->funcs->detach) in drm_bridge_attach()
348 bridge->funcs->detach(bridge); in drm_bridge_attach()
351 bridge->dev = NULL; in drm_bridge_attach()
352 bridge->encoder = NULL; in drm_bridge_attach()
353 list_del(&bridge->chain_node); in drm_bridge_attach()
356 DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n", in drm_bridge_attach()
357 bridge->of_node, encoder->name, ret); in drm_bridge_attach()
359 DRM_ERROR("failed to attach bridge to encoder %s: %d\n", in drm_bridge_attach()
360 encoder->name, ret); in drm_bridge_attach()
367 void drm_bridge_detach(struct drm_bridge *bridge) in drm_bridge_detach() argument
369 if (WARN_ON(!bridge)) in drm_bridge_detach()
372 if (WARN_ON(!bridge->dev)) in drm_bridge_detach()
375 if (bridge->funcs->atomic_reset) in drm_bridge_detach()
376 drm_atomic_private_obj_fini(&bridge->base); in drm_bridge_detach()
378 if (bridge->funcs->detach) in drm_bridge_detach()
379 bridge->funcs->detach(bridge); in drm_bridge_detach()
381 list_del(&bridge->chain_node); in drm_bridge_detach()
382 bridge->dev = NULL; in drm_bridge_detach()
386 * DOC: bridge operations
388 * Bridge drivers expose operations through the &drm_bridge_funcs structure.
390 * drm_bridge.c to call bridge operations. Those operations are divided in
391 * three big categories to support different parts of the bridge usage.
393 * - The encoder-related operations support control of the bridges in the
396 * helpers to perform mode validation, fixup and setting, and enable and
397 * disable the bridge automatically.
399 * The enable and disable operations are split in
400 * &drm_bridge_funcs.pre_enable, &drm_bridge_funcs.enable,
402 * finer-grained control.
404 * Bridge drivers may implement the legacy version of those operations, or
409 * Mixing atomic and non-atomic versions of the operations is not supported.
411 * - The bus format negotiation operations
413 * &drm_bridge_funcs.atomic_get_input_bus_fmts allow bridge drivers to
417 * atomic versions of those operations exist, bridge drivers that need to
419 * encoder-related operations. This feature is not supported by the legacy
422 * - The connector-related operations support implementing a &drm_connector
425 * puts additional burden on bridge drivers, especially for bridges that may
428 * bridge, which doesn't always match the hardware architecture.
430 * To simplify bridge drivers and make the connector implementation more
433 * an externally-implemented &drm_connector. Those operations are
439 * the bridge connector operations.
441 * Bridge drivers shall implement the connector-related operations for all
442 * the features that the bridge hardware support. For instance, if a bridge
445 * bridge on a particular platform, as they could also be connected to an I2C
446 * controller of the SoC. Support for the connector-related operations on the
447 * running platform is reported through the &drm_bridge.ops flags. Bridge
454 * decide which bridge to delegate a connector operation to. This mechanism
456 * bridge drivers, improving security by storing function pointers in
457 * read-only memory.
459 * In order to ease transition, bridge drivers may support both the old and
461 * connected-related bridge operations. Connector creation is then controlled
464 * %DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, and bridge drivers shall then skip
466 * be passed to the drm_bridge_attach() call for the downstream bridge.
467 * Bridge drivers that implement the new model only shall return an error
470 * should use the new model, and convert the bridge drivers they use if
475 * drm_bridge_chain_mode_fixup - fixup proposed mode for all bridges in the
477 * @bridge: bridge control structure
478 * @mode: desired mode to be set for the bridge
479 * @adjusted_mode: updated mode that works for this bridge
482 * encoder chain, starting from the first bridge to the last.
484 * Note: the bridge passed should be the one closest to the encoder
489 bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge, in drm_bridge_chain_mode_fixup() argument
495 if (!bridge) in drm_bridge_chain_mode_fixup()
498 encoder = bridge->encoder; in drm_bridge_chain_mode_fixup()
499 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_fixup()
500 if (!bridge->funcs->mode_fixup) in drm_bridge_chain_mode_fixup()
503 if (!bridge->funcs->mode_fixup(bridge, mode, adjusted_mode)) in drm_bridge_chain_mode_fixup()
512 * drm_bridge_chain_mode_valid - validate the mode against all bridges in the
514 * @bridge: bridge control structure
519 * chain, starting from the first bridge to the last. If at least one bridge
522 * Note: the bridge passed should be the one closest to the encoder.
528 drm_bridge_chain_mode_valid(struct drm_bridge *bridge, in drm_bridge_chain_mode_valid() argument
534 if (!bridge) in drm_bridge_chain_mode_valid()
537 encoder = bridge->encoder; in drm_bridge_chain_mode_valid()
538 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_valid()
541 if (!bridge->funcs->mode_valid) in drm_bridge_chain_mode_valid()
544 ret = bridge->funcs->mode_valid(bridge, info, mode); in drm_bridge_chain_mode_valid()
554 * drm_bridge_chain_mode_set - set proposed mode for all bridges in the
556 * @bridge: bridge control structure
561 * encoder chain, starting from the first bridge to the last.
563 * Note: the bridge passed should be the one closest to the encoder
565 void drm_bridge_chain_mode_set(struct drm_bridge *bridge, in drm_bridge_chain_mode_set() argument
571 if (!bridge) in drm_bridge_chain_mode_set()
574 encoder = bridge->encoder; in drm_bridge_chain_mode_set()
575 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_set()
576 if (bridge->funcs->mode_set) in drm_bridge_chain_mode_set()
577 bridge->funcs->mode_set(bridge, mode, adjusted_mode); in drm_bridge_chain_mode_set()
583 * drm_atomic_bridge_chain_disable - disables all bridges in the encoder chain
584 * @bridge: bridge control structure
589 * starting from the last bridge to the first. These are called before calling
592 * Note: the bridge passed should be the one closest to the encoder
594 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_disable() argument
600 if (!bridge) in drm_atomic_bridge_chain_disable()
603 encoder = bridge->encoder; in drm_atomic_bridge_chain_disable()
604 list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_disable()
605 if (iter->funcs->atomic_disable) { in drm_atomic_bridge_chain_disable()
614 iter->funcs->atomic_disable(iter, old_bridge_state); in drm_atomic_bridge_chain_disable()
615 } else if (iter->funcs->disable) { in drm_atomic_bridge_chain_disable()
616 iter->funcs->disable(iter); in drm_atomic_bridge_chain_disable()
619 if (iter == bridge) in drm_atomic_bridge_chain_disable()
625 static void drm_atomic_bridge_call_post_disable(struct drm_bridge *bridge, in drm_atomic_bridge_call_post_disable() argument
628 if (old_state && bridge->funcs->atomic_post_disable) { in drm_atomic_bridge_call_post_disable()
633 bridge); in drm_atomic_bridge_call_post_disable()
637 bridge->funcs->atomic_post_disable(bridge, in drm_atomic_bridge_call_post_disable()
639 } else if (bridge->funcs->post_disable) { in drm_atomic_bridge_call_post_disable()
640 bridge->funcs->post_disable(bridge); in drm_atomic_bridge_call_post_disable()
645 * drm_atomic_bridge_chain_post_disable - cleans up after disabling all bridges
647 * @bridge: bridge control structure
652 * starting from the first bridge to the last. These are called after completing
655 * If a bridge sets @pre_enable_prev_first, then the @post_disable for that
656 * bridge will be called before the previous one to reverse the @pre_enable
659 * Note: the bridge passed should be the one closest to the encoder
661 void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_post_disable() argument
667 if (!bridge) in drm_atomic_bridge_chain_post_disable()
670 encoder = bridge->encoder; in drm_atomic_bridge_chain_post_disable()
672 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_post_disable()
675 if (!list_is_last(&bridge->chain_node, &encoder->bridge_chain)) { in drm_atomic_bridge_chain_post_disable()
676 next = list_next_entry(bridge, chain_node); in drm_atomic_bridge_chain_post_disable()
678 if (next->pre_enable_prev_first) { in drm_atomic_bridge_chain_post_disable()
679 /* next bridge had requested that prev in drm_atomic_bridge_chain_post_disable()
684 /* Find the next bridge that has NOT requested in drm_atomic_bridge_chain_post_disable()
687 list_for_each_entry_from(next, &encoder->bridge_chain, in drm_atomic_bridge_chain_post_disable()
689 if (next->pre_enable_prev_first) { in drm_atomic_bridge_chain_post_disable()
697 list_for_each_entry_from_reverse(next, &encoder->bridge_chain, in drm_atomic_bridge_chain_post_disable()
699 if (next == bridge) in drm_atomic_bridge_chain_post_disable()
708 drm_atomic_bridge_call_post_disable(bridge, old_state); in drm_atomic_bridge_chain_post_disable()
712 bridge = limit; in drm_atomic_bridge_chain_post_disable()
717 static void drm_atomic_bridge_call_pre_enable(struct drm_bridge *bridge, in drm_atomic_bridge_call_pre_enable() argument
720 if (old_state && bridge->funcs->atomic_pre_enable) { in drm_atomic_bridge_call_pre_enable()
725 bridge); in drm_atomic_bridge_call_pre_enable()
729 bridge->funcs->atomic_pre_enable(bridge, old_bridge_state); in drm_atomic_bridge_call_pre_enable()
730 } else if (bridge->funcs->pre_enable) { in drm_atomic_bridge_call_pre_enable()
731 bridge->funcs->pre_enable(bridge); in drm_atomic_bridge_call_pre_enable()
736 * drm_atomic_bridge_chain_pre_enable - prepares for enabling all bridges in
738 * @bridge: bridge control structure
743 * starting from the last bridge to the first. These are called before calling
746 * If a bridge sets @pre_enable_prev_first, then the pre_enable for the
747 * prev bridge will be called before pre_enable of this bridge.
749 * Note: the bridge passed should be the one closest to the encoder
751 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_pre_enable() argument
757 if (!bridge) in drm_atomic_bridge_chain_pre_enable()
760 encoder = bridge->encoder; in drm_atomic_bridge_chain_pre_enable()
762 list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_pre_enable()
763 if (iter->pre_enable_prev_first) { in drm_atomic_bridge_chain_pre_enable()
765 limit = bridge; in drm_atomic_bridge_chain_pre_enable()
767 &encoder->bridge_chain, in drm_atomic_bridge_chain_pre_enable()
769 if (next == bridge) in drm_atomic_bridge_chain_pre_enable()
772 if (!next->pre_enable_prev_first) { in drm_atomic_bridge_chain_pre_enable()
773 /* Found first bridge that does NOT in drm_atomic_bridge_chain_pre_enable()
781 list_for_each_entry_from(next, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_pre_enable()
782 /* Call requested prev bridge pre_enable in drm_atomic_bridge_chain_pre_enable()
786 /* At the first bridge to request prev in drm_atomic_bridge_chain_pre_enable()
797 if (iter->pre_enable_prev_first) in drm_atomic_bridge_chain_pre_enable()
801 if (iter == bridge) in drm_atomic_bridge_chain_pre_enable()
808 * drm_atomic_bridge_chain_enable - enables all bridges in the encoder chain
809 * @bridge: bridge control structure
813 * &drm_bridge_funcs.enable) op for all the bridges in the encoder chain,
814 * starting from the first bridge to the last. These are called after completing
817 * Note: the bridge passed should be the one closest to the encoder
819 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_enable() argument
824 if (!bridge) in drm_atomic_bridge_chain_enable()
827 encoder = bridge->encoder; in drm_atomic_bridge_chain_enable()
828 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_enable()
829 if (bridge->funcs->atomic_enable) { in drm_atomic_bridge_chain_enable()
834 bridge); in drm_atomic_bridge_chain_enable()
838 bridge->funcs->atomic_enable(bridge, old_bridge_state); in drm_atomic_bridge_chain_enable()
839 } else if (bridge->funcs->enable) { in drm_atomic_bridge_chain_enable()
840 bridge->funcs->enable(bridge); in drm_atomic_bridge_chain_enable()
846 static int drm_atomic_bridge_check(struct drm_bridge *bridge, in drm_atomic_bridge_check() argument
850 if (bridge->funcs->atomic_check) { in drm_atomic_bridge_check()
854 bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, in drm_atomic_bridge_check()
855 bridge); in drm_atomic_bridge_check()
857 return -EINVAL; in drm_atomic_bridge_check()
859 ret = bridge->funcs->atomic_check(bridge, bridge_state, in drm_atomic_bridge_check()
863 } else if (bridge->funcs->mode_fixup) { in drm_atomic_bridge_check()
864 if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode, in drm_atomic_bridge_check()
865 &crtc_state->adjusted_mode)) in drm_atomic_bridge_check()
866 return -EINVAL; in drm_atomic_bridge_check()
885 cur_state = drm_atomic_get_new_bridge_state(crtc_state->state, in select_bus_fmt_recursive()
889 * If bus format negotiation is not supported by this bridge, let's in select_bus_fmt_recursive()
890 * pass MEDIA_BUS_FMT_FIXED to the previous bridge in the chain and in select_bus_fmt_recursive()
894 if (!cur_bridge->funcs->atomic_get_input_bus_fmts) { in select_bus_fmt_recursive()
906 * fine, as long as it does not access the bridge state. in select_bus_fmt_recursive()
909 cur_state->input_bus_cfg.format = MEDIA_BUS_FMT_FIXED; in select_bus_fmt_recursive()
910 cur_state->output_bus_cfg.format = out_bus_fmt; in select_bus_fmt_recursive()
917 * If the driver implements ->atomic_get_input_bus_fmts() it in select_bus_fmt_recursive()
921 return -EINVAL; in select_bus_fmt_recursive()
923 in_bus_fmts = cur_bridge->funcs->atomic_get_input_bus_fmts(cur_bridge, in select_bus_fmt_recursive()
930 return -ENOTSUPP; in select_bus_fmt_recursive()
932 return -ENOMEM; in select_bus_fmt_recursive()
935 cur_state->input_bus_cfg.format = in_bus_fmts[0]; in select_bus_fmt_recursive()
936 cur_state->output_bus_cfg.format = out_bus_fmt; in select_bus_fmt_recursive()
945 if (ret != -ENOTSUPP) in select_bus_fmt_recursive()
950 cur_state->input_bus_cfg.format = in_bus_fmts[i]; in select_bus_fmt_recursive()
951 cur_state->output_bus_cfg.format = out_bus_fmt; in select_bus_fmt_recursive()
961 * It performs bus format negotiation between bridge elements. The negotiation
963 * @bridge.
966 * bridge element and testing them one by one. The test is recursive, meaning
969 * transcoded to the requested output format. When a bridge element does not
970 * support transcoding into a specific output format -ENOTSUPP is returned and
971 * the next bridge element will have to try a different format. If none of the
972 * combinations worked, -ENOTSUPP is returned and the atomic modeset will fail.
986 * bridge element that lacks this hook and asks the previous element in the
987 * chain to try MEDIA_BUS_FMT_FIXED. It's up to bridge drivers to decide what
993 drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge, in drm_atomic_bridge_chain_select_bus_fmts() argument
997 struct drm_connector *conn = conn_state->connector; in drm_atomic_bridge_chain_select_bus_fmts()
998 struct drm_encoder *encoder = bridge->encoder; in drm_atomic_bridge_chain_select_bus_fmts()
1005 last_bridge = list_last_entry(&encoder->bridge_chain, in drm_atomic_bridge_chain_select_bus_fmts()
1007 last_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state, in drm_atomic_bridge_chain_select_bus_fmts()
1010 if (last_bridge->funcs->atomic_get_output_bus_fmts) { in drm_atomic_bridge_chain_select_bus_fmts()
1011 const struct drm_bridge_funcs *funcs = last_bridge->funcs; in drm_atomic_bridge_chain_select_bus_fmts()
1014 * If the driver implements ->atomic_get_output_bus_fmts() it in drm_atomic_bridge_chain_select_bus_fmts()
1018 return -EINVAL; in drm_atomic_bridge_chain_select_bus_fmts()
1020 out_bus_fmts = funcs->atomic_get_output_bus_fmts(last_bridge, in drm_atomic_bridge_chain_select_bus_fmts()
1026 return -ENOTSUPP; in drm_atomic_bridge_chain_select_bus_fmts()
1028 return -ENOMEM; in drm_atomic_bridge_chain_select_bus_fmts()
1033 return -ENOMEM; in drm_atomic_bridge_chain_select_bus_fmts()
1035 if (conn->display_info.num_bus_formats && in drm_atomic_bridge_chain_select_bus_fmts()
1036 conn->display_info.bus_formats) in drm_atomic_bridge_chain_select_bus_fmts()
1037 out_bus_fmts[0] = conn->display_info.bus_formats[0]; in drm_atomic_bridge_chain_select_bus_fmts()
1043 ret = select_bus_fmt_recursive(bridge, last_bridge, crtc_state, in drm_atomic_bridge_chain_select_bus_fmts()
1045 if (ret != -ENOTSUPP) in drm_atomic_bridge_chain_select_bus_fmts()
1055 drm_atomic_bridge_propagate_bus_flags(struct drm_bridge *bridge, in drm_atomic_bridge_propagate_bus_flags() argument
1063 bridge_state = drm_atomic_get_new_bridge_state(state, bridge); in drm_atomic_bridge_propagate_bus_flags()
1065 /* No bridge state attached to this bridge => nothing to propagate. */ in drm_atomic_bridge_propagate_bus_flags()
1069 next_bridge = drm_bridge_get_next_bridge(bridge); in drm_atomic_bridge_propagate_bus_flags()
1073 * display_info flags for the last bridge, and propagate the input in drm_atomic_bridge_propagate_bus_flags()
1074 * flags of the next bridge element to the output end of the current in drm_atomic_bridge_propagate_bus_flags()
1075 * bridge when the bridge is not the last one. in drm_atomic_bridge_propagate_bus_flags()
1082 output_flags = conn->display_info.bus_flags; in drm_atomic_bridge_propagate_bus_flags()
1087 * No bridge state attached to the next bridge, just leave the in drm_atomic_bridge_propagate_bus_flags()
1091 output_flags = next_bridge_state->input_bus_cfg.flags; in drm_atomic_bridge_propagate_bus_flags()
1094 bridge_state->output_bus_cfg.flags = output_flags; in drm_atomic_bridge_propagate_bus_flags()
1097 * Propagate the output flags to the input end of the bridge. Again, it's in drm_atomic_bridge_propagate_bus_flags()
1102 bridge_state->input_bus_cfg.flags = output_flags; in drm_atomic_bridge_propagate_bus_flags()
1106 * drm_atomic_bridge_chain_check() - Do an atomic check on the bridge chain
1107 * @bridge: bridge control structure
1114 * starting from the last bridge to the first. These are called before calling
1120 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge, in drm_atomic_bridge_chain_check() argument
1124 struct drm_connector *conn = conn_state->connector; in drm_atomic_bridge_chain_check()
1129 if (!bridge) in drm_atomic_bridge_chain_check()
1132 ret = drm_atomic_bridge_chain_select_bus_fmts(bridge, crtc_state, in drm_atomic_bridge_chain_check()
1137 encoder = bridge->encoder; in drm_atomic_bridge_chain_check()
1138 list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_check()
1142 * Bus flags are propagated by default. If a bridge needs to in drm_atomic_bridge_chain_check()
1149 crtc_state->state); in drm_atomic_bridge_chain_check()
1155 if (iter == bridge) in drm_atomic_bridge_chain_check()
1164 * drm_bridge_detect - check if anything is attached to the bridge output
1165 * @bridge: bridge control structure
1167 * If the bridge supports output detection, as reported by the
1168 * DRM_BRIDGE_OP_DETECT bridge ops flag, call &drm_bridge_funcs.detect for the
1169 * bridge and return the connection status. Otherwise return
1173 * The detection status on success, or connector_status_unknown if the bridge
1176 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge) in drm_bridge_detect() argument
1178 if (!(bridge->ops & DRM_BRIDGE_OP_DETECT)) in drm_bridge_detect()
1181 return bridge->funcs->detect(bridge); in drm_bridge_detect()
1186 * drm_bridge_get_modes - fill all modes currently valid for the sink into the
1188 * @bridge: bridge control structure
1191 * If the bridge supports output modes retrieval, as reported by the
1192 * DRM_BRIDGE_OP_MODES bridge ops flag, call &drm_bridge_funcs.get_modes to
1199 int drm_bridge_get_modes(struct drm_bridge *bridge, in drm_bridge_get_modes() argument
1202 if (!(bridge->ops & DRM_BRIDGE_OP_MODES)) in drm_bridge_get_modes()
1205 return bridge->funcs->get_modes(bridge, connector); in drm_bridge_get_modes()
1210 * drm_bridge_get_edid - get the EDID data of the connected display
1211 * @bridge: bridge control structure
1214 * If the bridge supports output EDID retrieval, as reported by the
1215 * DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.get_edid to
1221 struct edid *drm_bridge_get_edid(struct drm_bridge *bridge, in drm_bridge_get_edid() argument
1224 if (!(bridge->ops & DRM_BRIDGE_OP_EDID)) in drm_bridge_get_edid()
1227 return bridge->funcs->get_edid(bridge, connector); in drm_bridge_get_edid()
1232 * drm_bridge_hpd_enable - enable hot plug detection for the bridge
1233 * @bridge: bridge control structure
1234 * @cb: hot-plug detection callback
1235 * @data: data to be passed to the hot-plug detection callback
1239 * called with @data when an output status change is detected by the bridge,
1243 * bridge->ops. This function shall not be called when the flag is not set.
1247 * the bridge.
1249 void drm_bridge_hpd_enable(struct drm_bridge *bridge, in drm_bridge_hpd_enable() argument
1254 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_enable()
1257 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1259 if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n")) in drm_bridge_hpd_enable()
1262 bridge->hpd_cb = cb; in drm_bridge_hpd_enable()
1263 bridge->hpd_data = data; in drm_bridge_hpd_enable()
1265 if (bridge->funcs->hpd_enable) in drm_bridge_hpd_enable()
1266 bridge->funcs->hpd_enable(bridge); in drm_bridge_hpd_enable()
1269 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1274 * drm_bridge_hpd_disable - disable hot plug detection for the bridge
1275 * @bridge: bridge control structure
1279 * Once this function returns the callback will not be called by the bridge
1283 * bridge->ops. This function shall not be called when the flag is not set.
1285 void drm_bridge_hpd_disable(struct drm_bridge *bridge) in drm_bridge_hpd_disable() argument
1287 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_disable()
1290 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1291 if (bridge->funcs->hpd_disable) in drm_bridge_hpd_disable()
1292 bridge->funcs->hpd_disable(bridge); in drm_bridge_hpd_disable()
1294 bridge->hpd_cb = NULL; in drm_bridge_hpd_disable()
1295 bridge->hpd_data = NULL; in drm_bridge_hpd_disable()
1296 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1301 * drm_bridge_hpd_notify - notify hot plug detection events
1302 * @bridge: bridge control structure
1305 * Bridge drivers shall call this function to report hot plug events when they
1311 void drm_bridge_hpd_notify(struct drm_bridge *bridge, in drm_bridge_hpd_notify() argument
1314 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1315 if (bridge->hpd_cb) in drm_bridge_hpd_notify()
1316 bridge->hpd_cb(bridge->hpd_data, status); in drm_bridge_hpd_notify()
1317 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1323 * of_drm_find_bridge - find the bridge corresponding to the device node in
1324 * the global bridge list
1333 struct drm_bridge *bridge; in of_drm_find_bridge() local
1337 list_for_each_entry(bridge, &bridge_list, list) { in of_drm_find_bridge()
1338 if (bridge->of_node == np) { in of_drm_find_bridge()
1340 return bridge; in of_drm_find_bridge()
1351 MODULE_DESCRIPTION("DRM bridge infrastructure");