Lines Matching full:bridge

44  * A bridge is always attached to a single &drm_encoder at a time, but can be
47 * [ CRTC ---> ] Encoder ---> Bridge A ---> Bridge B
49 * Here, the output of the encoder feeds to bridge A, and that furthers feeds to
50 * bridge B. Bridge chains can be arbitrarily long, and shall be fully linear:
51 * Chaining multiple bridges to the output of a bridge, or the same bridge to
63 * Display drivers are responsible for linking encoders with the first bridge
64 * in the chains. This is done by acquiring the appropriate bridge with
65 * devm_drm_of_get_bridge(). Once acquired, the bridge shall be attached to the
68 * Bridges are responsible for linking themselves with the next bridge in the
90 * DRM bridge chain functions shall be called manually.
93 * the bridge chain. Display drivers may use the drm_bridge_connector_init()
95 * connector-related operations exposed by the bridge (see the overview
96 * documentation of bridge operations for more details).
103 * the probing of the upstream driver and the bridge driver can be
108 * MIPI-DSI host. In this case, the bridge driver will probe at some
110 * EPROBE_DEFER as long as the bridge driver hasn't probed.
113 * MIPI-DSI host. The bridge device uses the MIPI-DCS commands to be
114 * controlled. In this case, the bridge device is a child of the
117 * assured that the bridge driver is connected between the
124 * host. The bridge device uses the MIPI-DCS commands to be
129 * host. The bridge device uses a separate bus (such as I2C) to be
131 * of the bridge and upstream drivers, so care must be taken to avoid
142 * - In its probe hook, the bridge driver must try to find its MIPI-DSI
144 * to its host. The bridge driver is now functional.
148 * the bridge driver is attached and registered, we can now look for
152 * the bridge driver are functional and we can't have a deadlock-like
160 * drm_bridge_add - add the given bridge to the global bridge list
162 * @bridge: bridge control structure
164 void drm_bridge_add(struct drm_bridge *bridge) in drm_bridge_add() argument
166 mutex_init(&bridge->hpd_mutex); in drm_bridge_add()
169 list_add_tail(&bridge->list, &bridge_list); in drm_bridge_add()
174 static void drm_bridge_remove_void(void *bridge) in drm_bridge_remove_void() argument
176 drm_bridge_remove(bridge); in drm_bridge_remove_void()
182 * @dev: device to tie the bridge lifetime to
183 * @bridge: bridge control structure
190 int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge) in devm_drm_bridge_add() argument
192 drm_bridge_add(bridge); in devm_drm_bridge_add()
193 return devm_add_action_or_reset(dev, drm_bridge_remove_void, bridge); in devm_drm_bridge_add()
198 * drm_bridge_remove - remove the given bridge from the global bridge list
200 * @bridge: bridge control structure
202 void drm_bridge_remove(struct drm_bridge *bridge) in drm_bridge_remove() argument
205 list_del_init(&bridge->list); in drm_bridge_remove()
208 mutex_destroy(&bridge->hpd_mutex); in drm_bridge_remove()
215 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_duplicate_priv_state() local
218 state = bridge->funcs->atomic_duplicate_state(bridge); in drm_bridge_atomic_duplicate_priv_state()
227 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_destroy_priv_state() local
229 bridge->funcs->atomic_destroy_state(bridge, state); in drm_bridge_atomic_destroy_priv_state()
238 * drm_bridge_attach - attach the bridge to an encoder's chain
241 * @bridge: bridge to attach
242 * @previous: previous bridge in the chain (optional)
245 * Called by a kms driver to link the bridge to an encoder's chain. The previous
246 * argument specifies the previous bridge in the chain. If NULL, the bridge is
248 * previous bridge's output.
250 * If non-NULL the previous bridge must be already attached by a call to this
260 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, in drm_bridge_attach() argument
266 if (!encoder || !bridge) in drm_bridge_attach()
272 if (bridge->dev) in drm_bridge_attach()
275 bridge->dev = encoder->dev; in drm_bridge_attach()
276 bridge->encoder = encoder; in drm_bridge_attach()
279 list_add(&bridge->chain_node, &previous->chain_node); in drm_bridge_attach()
281 list_add(&bridge->chain_node, &encoder->bridge_chain); in drm_bridge_attach()
283 if (bridge->funcs->attach) { in drm_bridge_attach()
284 ret = bridge->funcs->attach(bridge, flags); in drm_bridge_attach()
289 if (bridge->funcs->atomic_reset) { in drm_bridge_attach()
292 state = bridge->funcs->atomic_reset(bridge); in drm_bridge_attach()
298 drm_atomic_private_obj_init(bridge->dev, &bridge->base, in drm_bridge_attach()
306 if (bridge->funcs->detach) in drm_bridge_attach()
307 bridge->funcs->detach(bridge); in drm_bridge_attach()
310 bridge->dev = NULL; in drm_bridge_attach()
311 bridge->encoder = NULL; in drm_bridge_attach()
312 list_del(&bridge->chain_node); in drm_bridge_attach()
315 DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n", in drm_bridge_attach()
316 bridge->of_node, encoder->name, ret); in drm_bridge_attach()
318 DRM_ERROR("failed to attach bridge to encoder %s: %d\n", in drm_bridge_attach()
326 void drm_bridge_detach(struct drm_bridge *bridge) in drm_bridge_detach() argument
328 if (WARN_ON(!bridge)) in drm_bridge_detach()
331 if (WARN_ON(!bridge->dev)) in drm_bridge_detach()
334 if (bridge->funcs->atomic_reset) in drm_bridge_detach()
335 drm_atomic_private_obj_fini(&bridge->base); in drm_bridge_detach()
337 if (bridge->funcs->detach) in drm_bridge_detach()
338 bridge->funcs->detach(bridge); in drm_bridge_detach()
340 list_del(&bridge->chain_node); in drm_bridge_detach()
341 bridge->dev = NULL; in drm_bridge_detach()
345 * DOC: bridge operations
347 * Bridge drivers expose operations through the &drm_bridge_funcs structure.
349 * drm_bridge.c to call bridge operations. Those operations are divided in
350 * three big categories to support different parts of the bridge usage.
356 * disable the bridge automatically.
363 * Bridge drivers may implement the legacy version of those operations, or
372 * &drm_bridge_funcs.atomic_get_input_bus_fmts allow bridge drivers to
376 * atomic versions of those operations exist, bridge drivers that need to
384 * puts additional burden on bridge drivers, especially for bridges that may
387 * bridge, which doesn't always match the hardware architecture.
389 * To simplify bridge drivers and make the connector implementation more
398 * the bridge connector operations.
400 * Bridge drivers shall implement the connector-related operations for all
401 * the features that the bridge hardware support. For instance, if a bridge
404 * bridge on a particular platform, as they could also be connected to an I2C
406 * running platform is reported through the &drm_bridge.ops flags. Bridge
413 * decide which bridge to delegate a connector operation to. This mechanism
415 * bridge drivers, improving security by storing function pointers in
418 * In order to ease transition, bridge drivers may support both the old and
420 * connected-related bridge operations. Connector creation is then controlled
423 * %DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, and bridge drivers shall then skip
425 * be passed to the drm_bridge_attach() call for the downstream bridge.
426 * Bridge drivers that implement the new model only shall return an error
429 * should use the new model, and convert the bridge drivers they use if
436 * @bridge: bridge control structure
437 * @mode: desired mode to be set for the bridge
438 * @adjusted_mode: updated mode that works for this bridge
441 * encoder chain, starting from the first bridge to the last.
443 * Note: the bridge passed should be the one closest to the encoder
448 bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge, in drm_bridge_chain_mode_fixup() argument
454 if (!bridge) in drm_bridge_chain_mode_fixup()
457 encoder = bridge->encoder; in drm_bridge_chain_mode_fixup()
458 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_fixup()
459 if (!bridge->funcs->mode_fixup) in drm_bridge_chain_mode_fixup()
462 if (!bridge->funcs->mode_fixup(bridge, mode, adjusted_mode)) in drm_bridge_chain_mode_fixup()
473 * @bridge: bridge control structure
478 * chain, starting from the first bridge to the last. If at least one bridge
481 * Note: the bridge passed should be the one closest to the encoder.
487 drm_bridge_chain_mode_valid(struct drm_bridge *bridge, in drm_bridge_chain_mode_valid() argument
493 if (!bridge) in drm_bridge_chain_mode_valid()
496 encoder = bridge->encoder; in drm_bridge_chain_mode_valid()
497 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_valid()
500 if (!bridge->funcs->mode_valid) in drm_bridge_chain_mode_valid()
503 ret = bridge->funcs->mode_valid(bridge, info, mode); in drm_bridge_chain_mode_valid()
514 * @bridge: bridge control structure
517 * chain, starting from the last bridge to the first. These are called before
520 * Note: the bridge passed should be the one closest to the encoder
522 void drm_bridge_chain_disable(struct drm_bridge *bridge) in drm_bridge_chain_disable() argument
527 if (!bridge) in drm_bridge_chain_disable()
530 encoder = bridge->encoder; in drm_bridge_chain_disable()
535 if (iter == bridge) in drm_bridge_chain_disable()
544 * @bridge: bridge control structure
547 * encoder chain, starting from the first bridge to the last. These are called
550 * Note: the bridge passed should be the one closest to the encoder
552 void drm_bridge_chain_post_disable(struct drm_bridge *bridge) in drm_bridge_chain_post_disable() argument
556 if (!bridge) in drm_bridge_chain_post_disable()
559 encoder = bridge->encoder; in drm_bridge_chain_post_disable()
560 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_post_disable()
561 if (bridge->funcs->post_disable) in drm_bridge_chain_post_disable()
562 bridge->funcs->post_disable(bridge); in drm_bridge_chain_post_disable()
570 * @bridge: bridge control structure
575 * encoder chain, starting from the first bridge to the last.
577 * Note: the bridge passed should be the one closest to the encoder
579 void drm_bridge_chain_mode_set(struct drm_bridge *bridge, in drm_bridge_chain_mode_set() argument
585 if (!bridge) in drm_bridge_chain_mode_set()
588 encoder = bridge->encoder; in drm_bridge_chain_mode_set()
589 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_set()
590 if (bridge->funcs->mode_set) in drm_bridge_chain_mode_set()
591 bridge->funcs->mode_set(bridge, mode, adjusted_mode); in drm_bridge_chain_mode_set()
599 * @bridge: bridge control structure
602 * chain, starting from the last bridge to the first. These are called
605 * Note: the bridge passed should be the one closest to the encoder
607 void drm_bridge_chain_pre_enable(struct drm_bridge *bridge) in drm_bridge_chain_pre_enable() argument
612 if (!bridge) in drm_bridge_chain_pre_enable()
615 encoder = bridge->encoder; in drm_bridge_chain_pre_enable()
620 if (iter == bridge) in drm_bridge_chain_pre_enable()
628 * @bridge: bridge control structure
631 * chain, starting from the first bridge to the last. These are called
634 * Note that the bridge passed should be the one closest to the encoder
636 void drm_bridge_chain_enable(struct drm_bridge *bridge) in drm_bridge_chain_enable() argument
640 if (!bridge) in drm_bridge_chain_enable()
643 encoder = bridge->encoder; in drm_bridge_chain_enable()
644 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_enable()
645 if (bridge->funcs->enable) in drm_bridge_chain_enable()
646 bridge->funcs->enable(bridge); in drm_bridge_chain_enable()
653 * @bridge: bridge control structure
658 * starting from the last bridge to the first. These are called before calling
661 * Note: the bridge passed should be the one closest to the encoder
663 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_disable() argument
669 if (!bridge) in drm_atomic_bridge_chain_disable()
672 encoder = bridge->encoder; in drm_atomic_bridge_chain_disable()
688 if (iter == bridge) in drm_atomic_bridge_chain_disable()
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_post_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_post_disable() argument
712 if (!bridge) in drm_atomic_bridge_chain_post_disable()
715 encoder = bridge->encoder; in drm_atomic_bridge_chain_post_disable()
716 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_post_disable()
717 if (bridge->funcs->atomic_post_disable) { in drm_atomic_bridge_chain_post_disable()
722 bridge); in drm_atomic_bridge_chain_post_disable()
726 bridge->funcs->atomic_post_disable(bridge, in drm_atomic_bridge_chain_post_disable()
728 } else if (bridge->funcs->post_disable) { in drm_atomic_bridge_chain_post_disable()
729 bridge->funcs->post_disable(bridge); in drm_atomic_bridge_chain_post_disable()
738 * @bridge: bridge control structure
743 * starting from the last bridge to the first. These are called before calling
746 * Note: the bridge passed should be the one closest to the encoder
748 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_pre_enable() argument
754 if (!bridge) in drm_atomic_bridge_chain_pre_enable()
757 encoder = bridge->encoder; in drm_atomic_bridge_chain_pre_enable()
773 if (iter == bridge) in drm_atomic_bridge_chain_pre_enable()
781 * @bridge: bridge control structure
786 * starting from the first bridge to the last. These are called after completing
789 * Note: the bridge passed should be the one closest to the encoder
791 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_enable() argument
796 if (!bridge) in drm_atomic_bridge_chain_enable()
799 encoder = bridge->encoder; in drm_atomic_bridge_chain_enable()
800 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_enable()
801 if (bridge->funcs->atomic_enable) { in drm_atomic_bridge_chain_enable()
806 bridge); in drm_atomic_bridge_chain_enable()
810 bridge->funcs->atomic_enable(bridge, old_bridge_state); in drm_atomic_bridge_chain_enable()
811 } else if (bridge->funcs->enable) { in drm_atomic_bridge_chain_enable()
812 bridge->funcs->enable(bridge); in drm_atomic_bridge_chain_enable()
818 static int drm_atomic_bridge_check(struct drm_bridge *bridge, in drm_atomic_bridge_check() argument
822 if (bridge->funcs->atomic_check) { in drm_atomic_bridge_check()
827 bridge); in drm_atomic_bridge_check()
831 ret = bridge->funcs->atomic_check(bridge, bridge_state, in drm_atomic_bridge_check()
835 } else if (bridge->funcs->mode_fixup) { in drm_atomic_bridge_check()
836 if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode, in drm_atomic_bridge_check()
861 * If bus format negotiation is not supported by this bridge, let's in select_bus_fmt_recursive()
862 * pass MEDIA_BUS_FMT_FIXED to the previous bridge in the chain and in select_bus_fmt_recursive()
878 * fine, as long as it does not access the bridge state. in select_bus_fmt_recursive()
933 * It performs bus format negotiation between bridge elements. The negotiation
935 * @bridge.
938 * bridge element and testing them one by one. The test is recursive, meaning
941 * transcoded to the requested output format. When a bridge element does not
943 * the next bridge element will have to try a different format. If none of the
958 * bridge element that lacks this hook and asks the previous element in the
959 * chain to try MEDIA_BUS_FMT_FIXED. It's up to bridge drivers to decide what
965 drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge, in drm_atomic_bridge_chain_select_bus_fmts() argument
970 struct drm_encoder *encoder = bridge->encoder; in drm_atomic_bridge_chain_select_bus_fmts()
1015 ret = select_bus_fmt_recursive(bridge, last_bridge, crtc_state, in drm_atomic_bridge_chain_select_bus_fmts()
1027 drm_atomic_bridge_propagate_bus_flags(struct drm_bridge *bridge, in drm_atomic_bridge_propagate_bus_flags() argument
1035 bridge_state = drm_atomic_get_new_bridge_state(state, bridge); in drm_atomic_bridge_propagate_bus_flags()
1037 /* No bridge state attached to this bridge => nothing to propagate. */ in drm_atomic_bridge_propagate_bus_flags()
1041 next_bridge = drm_bridge_get_next_bridge(bridge); in drm_atomic_bridge_propagate_bus_flags()
1045 * display_info flags for the last bridge, and propagate the input in drm_atomic_bridge_propagate_bus_flags()
1046 * flags of the next bridge element to the output end of the current in drm_atomic_bridge_propagate_bus_flags()
1047 * bridge when the bridge is not the last one. in drm_atomic_bridge_propagate_bus_flags()
1059 * No bridge state attached to the next bridge, just leave the in drm_atomic_bridge_propagate_bus_flags()
1069 * Propagate the output flags to the input end of the bridge. Again, it's in drm_atomic_bridge_propagate_bus_flags()
1078 * drm_atomic_bridge_chain_check() - Do an atomic check on the bridge chain
1079 * @bridge: bridge control structure
1086 * starting from the last bridge to the first. These are called before calling
1092 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge, in drm_atomic_bridge_chain_check() argument
1101 if (!bridge) in drm_atomic_bridge_chain_check()
1104 ret = drm_atomic_bridge_chain_select_bus_fmts(bridge, crtc_state, in drm_atomic_bridge_chain_check()
1109 encoder = bridge->encoder; in drm_atomic_bridge_chain_check()
1114 * Bus flags are propagated by default. If a bridge needs to in drm_atomic_bridge_chain_check()
1127 if (iter == bridge) in drm_atomic_bridge_chain_check()
1136 * drm_bridge_detect - check if anything is attached to the bridge output
1137 * @bridge: bridge control structure
1139 * If the bridge supports output detection, as reported by the
1140 * DRM_BRIDGE_OP_DETECT bridge ops flag, call &drm_bridge_funcs.detect for the
1141 * bridge and return the connection status. Otherwise return
1145 * The detection status on success, or connector_status_unknown if the bridge
1148 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge) in drm_bridge_detect() argument
1150 if (!(bridge->ops & DRM_BRIDGE_OP_DETECT)) in drm_bridge_detect()
1153 return bridge->funcs->detect(bridge); in drm_bridge_detect()
1160 * @bridge: bridge control structure
1163 * If the bridge supports output modes retrieval, as reported by the
1164 * DRM_BRIDGE_OP_MODES bridge ops flag, call &drm_bridge_funcs.get_modes to
1171 int drm_bridge_get_modes(struct drm_bridge *bridge, in drm_bridge_get_modes() argument
1174 if (!(bridge->ops & DRM_BRIDGE_OP_MODES)) in drm_bridge_get_modes()
1177 return bridge->funcs->get_modes(bridge, connector); in drm_bridge_get_modes()
1183 * @bridge: bridge control structure
1186 * If the bridge supports output EDID retrieval, as reported by the
1187 * DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.get_edid to
1193 struct edid *drm_bridge_get_edid(struct drm_bridge *bridge, in drm_bridge_get_edid() argument
1196 if (!(bridge->ops & DRM_BRIDGE_OP_EDID)) in drm_bridge_get_edid()
1199 return bridge->funcs->get_edid(bridge, connector); in drm_bridge_get_edid()
1204 * drm_bridge_hpd_enable - enable hot plug detection for the bridge
1205 * @bridge: bridge control structure
1211 * called with @data when an output status change is detected by the bridge,
1215 * bridge->ops. This function shall not be called when the flag is not set.
1219 * the bridge.
1221 void drm_bridge_hpd_enable(struct drm_bridge *bridge, in drm_bridge_hpd_enable() argument
1226 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_enable()
1229 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1231 if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n")) in drm_bridge_hpd_enable()
1234 bridge->hpd_cb = cb; in drm_bridge_hpd_enable()
1235 bridge->hpd_data = data; in drm_bridge_hpd_enable()
1237 if (bridge->funcs->hpd_enable) in drm_bridge_hpd_enable()
1238 bridge->funcs->hpd_enable(bridge); in drm_bridge_hpd_enable()
1241 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1246 * drm_bridge_hpd_disable - disable hot plug detection for the bridge
1247 * @bridge: bridge control structure
1251 * Once this function returns the callback will not be called by the bridge
1255 * bridge->ops. This function shall not be called when the flag is not set.
1257 void drm_bridge_hpd_disable(struct drm_bridge *bridge) in drm_bridge_hpd_disable() argument
1259 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_disable()
1262 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1263 if (bridge->funcs->hpd_disable) in drm_bridge_hpd_disable()
1264 bridge->funcs->hpd_disable(bridge); in drm_bridge_hpd_disable()
1266 bridge->hpd_cb = NULL; in drm_bridge_hpd_disable()
1267 bridge->hpd_data = NULL; in drm_bridge_hpd_disable()
1268 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1274 * @bridge: bridge control structure
1277 * Bridge drivers shall call this function to report hot plug events when they
1283 void drm_bridge_hpd_notify(struct drm_bridge *bridge, in drm_bridge_hpd_notify() argument
1286 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1287 if (bridge->hpd_cb) in drm_bridge_hpd_notify()
1288 bridge->hpd_cb(bridge->hpd_data, status); in drm_bridge_hpd_notify()
1289 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1295 * of_drm_find_bridge - find the bridge corresponding to the device node in
1296 * the global bridge list
1305 struct drm_bridge *bridge; in of_drm_find_bridge() local
1309 list_for_each_entry(bridge, &bridge_list, list) { in of_drm_find_bridge()
1310 if (bridge->of_node == np) { in of_drm_find_bridge()
1312 return bridge; in of_drm_find_bridge()
1323 MODULE_DESCRIPTION("DRM bridge infrastructure");