Lines Matching full:bridge
42 * A bridge is always attached to a single &drm_encoder at a time, but can be
45 * [ CRTC ---> ] Encoder ---> Bridge A ---> Bridge B
47 * Here, the output of the encoder feeds to bridge A, and that furthers feeds to
48 * bridge B. Bridge chains can be arbitrarily long, and shall be fully linear:
49 * Chaining multiple bridges to the output of a bridge, or the same bridge to
52 * Display drivers are responsible for linking encoders with the first bridge
53 * in the chains. This is done by acquiring the appropriate bridge with
56 * devm_drm_panel_bridge_add_typed()). Once acquired, the bridge shall be
59 * Bridges are responsible for linking themselves with the next bridge in the
81 * DRM bridge chain functions shall be called manually.
84 * the bridge chain. Display drivers may use the drm_bridge_connector_init()
86 * connector-related operations exposed by the bridge (see the overview
87 * documentation of bridge operations for more details).
99 * drm_bridge_add - add the given bridge to the global bridge list
101 * @bridge: bridge control structure
103 void drm_bridge_add(struct drm_bridge *bridge) in drm_bridge_add() argument
105 mutex_init(&bridge->hpd_mutex); in drm_bridge_add()
108 list_add_tail(&bridge->list, &bridge_list); in drm_bridge_add()
114 * drm_bridge_remove - remove the given bridge from the global bridge list
116 * @bridge: bridge control structure
118 void drm_bridge_remove(struct drm_bridge *bridge) in drm_bridge_remove() argument
121 list_del_init(&bridge->list); in drm_bridge_remove()
124 mutex_destroy(&bridge->hpd_mutex); in drm_bridge_remove()
131 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_duplicate_priv_state() local
134 state = bridge->funcs->atomic_duplicate_state(bridge); in drm_bridge_atomic_duplicate_priv_state()
143 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_destroy_priv_state() local
145 bridge->funcs->atomic_destroy_state(bridge, state); in drm_bridge_atomic_destroy_priv_state()
154 * drm_bridge_attach - attach the bridge to an encoder's chain
157 * @bridge: bridge to attach
158 * @previous: previous bridge in the chain (optional)
161 * Called by a kms driver to link the bridge to an encoder's chain. The previous
162 * argument specifies the previous bridge in the chain. If NULL, the bridge is
164 * previous bridge's output.
166 * If non-NULL the previous bridge must be already attached by a call to this
176 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, in drm_bridge_attach() argument
182 if (!encoder || !bridge) in drm_bridge_attach()
188 if (bridge->dev) in drm_bridge_attach()
191 bridge->dev = encoder->dev; in drm_bridge_attach()
192 bridge->encoder = encoder; in drm_bridge_attach()
195 list_add(&bridge->chain_node, &previous->chain_node); in drm_bridge_attach()
197 list_add(&bridge->chain_node, &encoder->bridge_chain); in drm_bridge_attach()
199 if (bridge->funcs->attach) { in drm_bridge_attach()
200 ret = bridge->funcs->attach(bridge, flags); in drm_bridge_attach()
205 if (bridge->funcs->atomic_reset) { in drm_bridge_attach()
208 state = bridge->funcs->atomic_reset(bridge); in drm_bridge_attach()
214 drm_atomic_private_obj_init(bridge->dev, &bridge->base, in drm_bridge_attach()
222 if (bridge->funcs->detach) in drm_bridge_attach()
223 bridge->funcs->detach(bridge); in drm_bridge_attach()
226 bridge->dev = NULL; in drm_bridge_attach()
227 bridge->encoder = NULL; in drm_bridge_attach()
228 list_del(&bridge->chain_node); in drm_bridge_attach()
231 DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n", in drm_bridge_attach()
232 bridge->of_node, encoder->name, ret); in drm_bridge_attach()
234 DRM_ERROR("failed to attach bridge to encoder %s: %d\n", in drm_bridge_attach()
242 void drm_bridge_detach(struct drm_bridge *bridge) in drm_bridge_detach() argument
244 if (WARN_ON(!bridge)) in drm_bridge_detach()
247 if (WARN_ON(!bridge->dev)) in drm_bridge_detach()
250 if (bridge->funcs->atomic_reset) in drm_bridge_detach()
251 drm_atomic_private_obj_fini(&bridge->base); in drm_bridge_detach()
253 if (bridge->funcs->detach) in drm_bridge_detach()
254 bridge->funcs->detach(bridge); in drm_bridge_detach()
256 list_del(&bridge->chain_node); in drm_bridge_detach()
257 bridge->dev = NULL; in drm_bridge_detach()
261 * DOC: bridge operations
263 * Bridge drivers expose operations through the &drm_bridge_funcs structure.
265 * drm_bridge.c to call bridge operations. Those operations are divided in
266 * three big categories to support different parts of the bridge usage.
272 * disable the bridge automatically.
279 * Bridge drivers may implement the legacy version of those operations, or
288 * &drm_bridge_funcs.atomic_get_input_bus_fmts allow bridge drivers to
292 * atomic versions of those operations exist, bridge drivers that need to
300 * puts additional burden on bridge drivers, especially for bridges that may
303 * bridge, which doesn't always match the hardware architecture.
305 * To simplify bridge drivers and make the connector implementation more
314 * the bridge connector operations.
316 * Bridge drivers shall implement the connector-related operations for all
317 * the features that the bridge hardware support. For instance, if a bridge
320 * bridge on a particular platform, as they could also be connected to an I2C
322 * running platform is reported through the &drm_bridge.ops flags. Bridge
329 * decide which bridge to delegate a connector operation to. This mechanism
331 * bridge drivers, improving security by storing function pointers in
334 * In order to ease transition, bridge drivers may support both the old and
336 * connected-related bridge operations. Connector creation is then controlled
339 * %DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, and bridge drivers shall then skip
341 * be passed to the drm_bridge_attach() call for the downstream bridge.
342 * Bridge drivers that implement the new model only shall return an error
345 * should use the new model, and convert the bridge drivers they use if
352 * @bridge: bridge control structure
353 * @mode: desired mode to be set for the bridge
354 * @adjusted_mode: updated mode that works for this bridge
357 * encoder chain, starting from the first bridge to the last.
359 * Note: the bridge passed should be the one closest to the encoder
364 bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge, in drm_bridge_chain_mode_fixup() argument
370 if (!bridge) in drm_bridge_chain_mode_fixup()
373 encoder = bridge->encoder; in drm_bridge_chain_mode_fixup()
374 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_fixup()
375 if (!bridge->funcs->mode_fixup) in drm_bridge_chain_mode_fixup()
378 if (!bridge->funcs->mode_fixup(bridge, mode, adjusted_mode)) in drm_bridge_chain_mode_fixup()
389 * @bridge: bridge control structure
394 * chain, starting from the first bridge to the last. If at least one bridge
397 * Note: the bridge passed should be the one closest to the encoder.
403 drm_bridge_chain_mode_valid(struct drm_bridge *bridge, in drm_bridge_chain_mode_valid() argument
409 if (!bridge) in drm_bridge_chain_mode_valid()
412 encoder = bridge->encoder; in drm_bridge_chain_mode_valid()
413 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_valid()
416 if (!bridge->funcs->mode_valid) in drm_bridge_chain_mode_valid()
419 ret = bridge->funcs->mode_valid(bridge, info, mode); in drm_bridge_chain_mode_valid()
430 * @bridge: bridge control structure
433 * chain, starting from the last bridge to the first. These are called before
436 * Note: the bridge passed should be the one closest to the encoder
438 void drm_bridge_chain_disable(struct drm_bridge *bridge) in drm_bridge_chain_disable() argument
443 if (!bridge) in drm_bridge_chain_disable()
446 encoder = bridge->encoder; in drm_bridge_chain_disable()
451 if (iter == bridge) in drm_bridge_chain_disable()
460 * @bridge: bridge control structure
463 * encoder chain, starting from the first bridge to the last. These are called
466 * Note: the bridge passed should be the one closest to the encoder
468 void drm_bridge_chain_post_disable(struct drm_bridge *bridge) in drm_bridge_chain_post_disable() argument
472 if (!bridge) in drm_bridge_chain_post_disable()
475 encoder = bridge->encoder; in drm_bridge_chain_post_disable()
476 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_post_disable()
477 if (bridge->funcs->post_disable) in drm_bridge_chain_post_disable()
478 bridge->funcs->post_disable(bridge); in drm_bridge_chain_post_disable()
486 * @bridge: bridge control structure
491 * encoder chain, starting from the first bridge to the last.
493 * Note: the bridge passed should be the one closest to the encoder
495 void drm_bridge_chain_mode_set(struct drm_bridge *bridge, in drm_bridge_chain_mode_set() argument
501 if (!bridge) in drm_bridge_chain_mode_set()
504 encoder = bridge->encoder; in drm_bridge_chain_mode_set()
505 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_set()
506 if (bridge->funcs->mode_set) in drm_bridge_chain_mode_set()
507 bridge->funcs->mode_set(bridge, mode, adjusted_mode); in drm_bridge_chain_mode_set()
515 * @bridge: bridge control structure
518 * chain, starting from the last bridge to the first. These are called
521 * Note: the bridge passed should be the one closest to the encoder
523 void drm_bridge_chain_pre_enable(struct drm_bridge *bridge) in drm_bridge_chain_pre_enable() argument
528 if (!bridge) in drm_bridge_chain_pre_enable()
531 encoder = bridge->encoder; in drm_bridge_chain_pre_enable()
536 if (iter == bridge) in drm_bridge_chain_pre_enable()
544 * @bridge: bridge control structure
547 * chain, starting from the first bridge to the last. These are called
550 * Note that the bridge passed should be the one closest to the encoder
552 void drm_bridge_chain_enable(struct drm_bridge *bridge) in drm_bridge_chain_enable() argument
556 if (!bridge) in drm_bridge_chain_enable()
559 encoder = bridge->encoder; in drm_bridge_chain_enable()
560 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_enable()
561 if (bridge->funcs->enable) in drm_bridge_chain_enable()
562 bridge->funcs->enable(bridge); in drm_bridge_chain_enable()
569 * @bridge: bridge control structure
574 * starting from the last bridge to the first. These are called before calling
577 * Note: the bridge passed should be the one closest to the encoder
579 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_disable() argument
585 if (!bridge) in drm_atomic_bridge_chain_disable()
588 encoder = bridge->encoder; in drm_atomic_bridge_chain_disable()
604 if (iter == bridge) in drm_atomic_bridge_chain_disable()
613 * @bridge: bridge control structure
618 * starting from the first bridge to the last. These are called after completing
621 * Note: the bridge passed should be the one closest to the encoder
623 void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_post_disable() argument
628 if (!bridge) in drm_atomic_bridge_chain_post_disable()
631 encoder = bridge->encoder; in drm_atomic_bridge_chain_post_disable()
632 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_post_disable()
633 if (bridge->funcs->atomic_post_disable) { in drm_atomic_bridge_chain_post_disable()
638 bridge); in drm_atomic_bridge_chain_post_disable()
642 bridge->funcs->atomic_post_disable(bridge, in drm_atomic_bridge_chain_post_disable()
644 } else if (bridge->funcs->post_disable) { in drm_atomic_bridge_chain_post_disable()
645 bridge->funcs->post_disable(bridge); in drm_atomic_bridge_chain_post_disable()
654 * @bridge: bridge control structure
659 * starting from the last bridge to the first. These are called before calling
662 * Note: the bridge passed should be the one closest to the encoder
664 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_pre_enable() argument
670 if (!bridge) in drm_atomic_bridge_chain_pre_enable()
673 encoder = bridge->encoder; in drm_atomic_bridge_chain_pre_enable()
689 if (iter == bridge) in drm_atomic_bridge_chain_pre_enable()
697 * @bridge: bridge control structure
702 * starting from the first bridge to the last. These are called after completing
705 * Note: the bridge passed should be the one closest to the encoder
707 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_enable() argument
712 if (!bridge) in drm_atomic_bridge_chain_enable()
715 encoder = bridge->encoder; in drm_atomic_bridge_chain_enable()
716 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_enable()
717 if (bridge->funcs->atomic_enable) { in drm_atomic_bridge_chain_enable()
722 bridge); in drm_atomic_bridge_chain_enable()
726 bridge->funcs->atomic_enable(bridge, old_bridge_state); in drm_atomic_bridge_chain_enable()
727 } else if (bridge->funcs->enable) { in drm_atomic_bridge_chain_enable()
728 bridge->funcs->enable(bridge); in drm_atomic_bridge_chain_enable()
734 static int drm_atomic_bridge_check(struct drm_bridge *bridge, in drm_atomic_bridge_check() argument
738 if (bridge->funcs->atomic_check) { in drm_atomic_bridge_check()
743 bridge); in drm_atomic_bridge_check()
747 ret = bridge->funcs->atomic_check(bridge, bridge_state, in drm_atomic_bridge_check()
751 } else if (bridge->funcs->mode_fixup) { in drm_atomic_bridge_check()
752 if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode, in drm_atomic_bridge_check()
777 * If bus format negotiation is not supported by this bridge, let's in select_bus_fmt_recursive()
778 * pass MEDIA_BUS_FMT_FIXED to the previous bridge in the chain and in select_bus_fmt_recursive()
794 * fine, as long as it does not access the bridge state. in select_bus_fmt_recursive()
849 * It performs bus format negotiation between bridge elements. The negotiation
851 * @bridge.
854 * bridge element and testing them one by one. The test is recursive, meaning
857 * transcoded to the requested output format. When a bridge element does not
859 * the next bridge element will have to try a different format. If none of the
874 * bridge element that lacks this hook and asks the previous element in the
875 * chain to try MEDIA_BUS_FMT_FIXED. It's up to bridge drivers to decide what
881 drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge, in drm_atomic_bridge_chain_select_bus_fmts() argument
886 struct drm_encoder *encoder = bridge->encoder; in drm_atomic_bridge_chain_select_bus_fmts()
931 ret = select_bus_fmt_recursive(bridge, last_bridge, crtc_state, in drm_atomic_bridge_chain_select_bus_fmts()
943 drm_atomic_bridge_propagate_bus_flags(struct drm_bridge *bridge, in drm_atomic_bridge_propagate_bus_flags() argument
951 bridge_state = drm_atomic_get_new_bridge_state(state, bridge); in drm_atomic_bridge_propagate_bus_flags()
953 /* No bridge state attached to this bridge => nothing to propagate. */ in drm_atomic_bridge_propagate_bus_flags()
957 next_bridge = drm_bridge_get_next_bridge(bridge); in drm_atomic_bridge_propagate_bus_flags()
961 * display_info flags for the last bridge, and propagate the input in drm_atomic_bridge_propagate_bus_flags()
962 * flags of the next bridge element to the output end of the current in drm_atomic_bridge_propagate_bus_flags()
963 * bridge when the bridge is not the last one. in drm_atomic_bridge_propagate_bus_flags()
975 * No bridge state attached to the next bridge, just leave the in drm_atomic_bridge_propagate_bus_flags()
985 * Propagate the output flags to the input end of the bridge. Again, it's in drm_atomic_bridge_propagate_bus_flags()
994 * drm_atomic_bridge_chain_check() - Do an atomic check on the bridge chain
995 * @bridge: bridge control structure
1002 * starting from the last bridge to the first. These are called before calling
1008 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge, in drm_atomic_bridge_chain_check() argument
1017 if (!bridge) in drm_atomic_bridge_chain_check()
1020 ret = drm_atomic_bridge_chain_select_bus_fmts(bridge, crtc_state, in drm_atomic_bridge_chain_check()
1025 encoder = bridge->encoder; in drm_atomic_bridge_chain_check()
1030 * Bus flags are propagated by default. If a bridge needs to in drm_atomic_bridge_chain_check()
1043 if (iter == bridge) in drm_atomic_bridge_chain_check()
1052 * drm_bridge_detect - check if anything is attached to the bridge output
1053 * @bridge: bridge control structure
1055 * If the bridge supports output detection, as reported by the
1056 * DRM_BRIDGE_OP_DETECT bridge ops flag, call &drm_bridge_funcs.detect for the
1057 * bridge and return the connection status. Otherwise return
1061 * The detection status on success, or connector_status_unknown if the bridge
1064 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge) in drm_bridge_detect() argument
1066 if (!(bridge->ops & DRM_BRIDGE_OP_DETECT)) in drm_bridge_detect()
1069 return bridge->funcs->detect(bridge); in drm_bridge_detect()
1076 * @bridge: bridge control structure
1079 * If the bridge supports output modes retrieval, as reported by the
1080 * DRM_BRIDGE_OP_MODES bridge ops flag, call &drm_bridge_funcs.get_modes to
1087 int drm_bridge_get_modes(struct drm_bridge *bridge, in drm_bridge_get_modes() argument
1090 if (!(bridge->ops & DRM_BRIDGE_OP_MODES)) in drm_bridge_get_modes()
1093 return bridge->funcs->get_modes(bridge, connector); in drm_bridge_get_modes()
1099 * @bridge: bridge control structure
1102 * If the bridge supports output EDID retrieval, as reported by the
1103 * DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.get_edid to
1109 struct edid *drm_bridge_get_edid(struct drm_bridge *bridge, in drm_bridge_get_edid() argument
1112 if (!(bridge->ops & DRM_BRIDGE_OP_EDID)) in drm_bridge_get_edid()
1115 return bridge->funcs->get_edid(bridge, connector); in drm_bridge_get_edid()
1120 * drm_bridge_hpd_enable - enable hot plug detection for the bridge
1121 * @bridge: bridge control structure
1127 * called with @data when an output status change is detected by the bridge,
1131 * bridge->ops. This function shall not be called when the flag is not set.
1135 * the bridge.
1137 void drm_bridge_hpd_enable(struct drm_bridge *bridge, in drm_bridge_hpd_enable() argument
1142 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_enable()
1145 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1147 if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n")) in drm_bridge_hpd_enable()
1150 bridge->hpd_cb = cb; in drm_bridge_hpd_enable()
1151 bridge->hpd_data = data; in drm_bridge_hpd_enable()
1153 if (bridge->funcs->hpd_enable) in drm_bridge_hpd_enable()
1154 bridge->funcs->hpd_enable(bridge); in drm_bridge_hpd_enable()
1157 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1162 * drm_bridge_hpd_disable - disable hot plug detection for the bridge
1163 * @bridge: bridge control structure
1167 * Once this function returns the callback will not be called by the bridge
1171 * bridge->ops. This function shall not be called when the flag is not set.
1173 void drm_bridge_hpd_disable(struct drm_bridge *bridge) in drm_bridge_hpd_disable() argument
1175 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_disable()
1178 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1179 if (bridge->funcs->hpd_disable) in drm_bridge_hpd_disable()
1180 bridge->funcs->hpd_disable(bridge); in drm_bridge_hpd_disable()
1182 bridge->hpd_cb = NULL; in drm_bridge_hpd_disable()
1183 bridge->hpd_data = NULL; in drm_bridge_hpd_disable()
1184 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1190 * @bridge: bridge control structure
1193 * Bridge drivers shall call this function to report hot plug events when they
1199 void drm_bridge_hpd_notify(struct drm_bridge *bridge, in drm_bridge_hpd_notify() argument
1202 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1203 if (bridge->hpd_cb) in drm_bridge_hpd_notify()
1204 bridge->hpd_cb(bridge->hpd_data, status); in drm_bridge_hpd_notify()
1205 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1211 * of_drm_find_bridge - find the bridge corresponding to the device node in
1212 * the global bridge list
1221 struct drm_bridge *bridge; in of_drm_find_bridge() local
1225 list_for_each_entry(bridge, &bridge_list, list) { in of_drm_find_bridge()
1226 if (bridge->of_node == np) { in of_drm_find_bridge()
1228 return bridge; in of_drm_find_bridge()
1239 MODULE_DESCRIPTION("DRM bridge infrastructure");