Lines Matching full:bridge
47 * A bridge is always attached to a single &drm_encoder at a time, but can be
50 * [ CRTC ---> ] Encoder ---> Bridge A ---> Bridge B
52 * Here, the output of the encoder feeds to bridge A, and that furthers feeds to
53 * bridge B. Bridge chains can be arbitrarily long, and shall be fully linear:
54 * Chaining multiple bridges to the output of a bridge, or the same bridge to
66 * Display drivers are responsible for linking encoders with the first bridge
67 * in the chains. This is done by acquiring the appropriate bridge with
68 * devm_drm_of_get_bridge(). Once acquired, the bridge shall be attached to the
71 * Bridges are responsible for linking themselves with the next bridge in the
93 * DRM bridge chain functions shall be called manually.
96 * the bridge chain. Display drivers may use the drm_bridge_connector_init()
98 * connector-related operations exposed by the bridge (see the overview
99 * documentation of bridge operations for more details).
106 * the probing of the upstream driver and the bridge driver can be
111 * MIPI-DSI host. In this case, the bridge driver will probe at some
113 * EPROBE_DEFER as long as the bridge driver hasn't probed.
116 * MIPI-DSI host. The bridge device uses the MIPI-DCS commands to be
117 * controlled. In this case, the bridge device is a child of the
120 * assured that the bridge driver is connected between the
127 * host. The bridge device uses the MIPI-DCS commands to be
132 * host. The bridge device uses a separate bus (such as I2C) to be
134 * of the bridge and upstream drivers, so care must be taken to avoid
145 * - In its probe hook, the bridge driver must try to find its MIPI-DSI
147 * to its host. The bridge driver is now functional.
151 * the bridge driver is attached and registered, we can now look for
155 * the bridge driver are functional and we can't have a deadlock-like
160 * DOC: dsi bridge operations
173 * Ordinarily the downstream bridge DSI peripheral pre_enable will have been
186 * bridge &post_disable will be called before the DSI host's post_disable.
202 * drm_bridge_add - add the given bridge to the global bridge list
204 * @bridge: bridge control structure
206 void drm_bridge_add(struct drm_bridge *bridge) in drm_bridge_add() argument
208 mutex_init(&bridge->hpd_mutex); in drm_bridge_add()
210 if (bridge->ops & DRM_BRIDGE_OP_HDMI) in drm_bridge_add()
211 bridge->ycbcr_420_allowed = !!(bridge->supported_formats & in drm_bridge_add()
215 list_add_tail(&bridge->list, &bridge_list); in drm_bridge_add()
220 static void drm_bridge_remove_void(void *bridge) in drm_bridge_remove_void() argument
222 drm_bridge_remove(bridge); in drm_bridge_remove_void()
228 * @dev: device to tie the bridge lifetime to
229 * @bridge: bridge control structure
236 int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge) in devm_drm_bridge_add() argument
238 drm_bridge_add(bridge); in devm_drm_bridge_add()
239 return devm_add_action_or_reset(dev, drm_bridge_remove_void, bridge); in devm_drm_bridge_add()
244 * drm_bridge_remove - remove the given bridge from the global bridge list
246 * @bridge: bridge control structure
248 void drm_bridge_remove(struct drm_bridge *bridge) in drm_bridge_remove() argument
251 list_del_init(&bridge->list); in drm_bridge_remove()
254 mutex_destroy(&bridge->hpd_mutex); in drm_bridge_remove()
261 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_duplicate_priv_state() local
264 state = bridge->funcs->atomic_duplicate_state(bridge); in drm_bridge_atomic_duplicate_priv_state()
273 struct drm_bridge *bridge = drm_priv_to_bridge(obj); in drm_bridge_atomic_destroy_priv_state() local
275 bridge->funcs->atomic_destroy_state(bridge, state); in drm_bridge_atomic_destroy_priv_state()
284 * drm_bridge_attach - attach the bridge to an encoder's chain
287 * @bridge: bridge to attach
288 * @previous: previous bridge in the chain (optional)
291 * Called by a kms driver to link the bridge to an encoder's chain. The previous
292 * argument specifies the previous bridge in the chain. If NULL, the bridge is
294 * previous bridge's output.
296 * If non-NULL the previous bridge must be already attached by a call to this
306 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, in drm_bridge_attach() argument
312 if (!encoder || !bridge) in drm_bridge_attach()
318 if (bridge->dev) in drm_bridge_attach()
321 bridge->dev = encoder->dev; in drm_bridge_attach()
322 bridge->encoder = encoder; in drm_bridge_attach()
325 list_add(&bridge->chain_node, &previous->chain_node); in drm_bridge_attach()
327 list_add(&bridge->chain_node, &encoder->bridge_chain); in drm_bridge_attach()
329 if (bridge->funcs->attach) { in drm_bridge_attach()
330 ret = bridge->funcs->attach(bridge, flags); in drm_bridge_attach()
335 if (bridge->funcs->atomic_reset) { in drm_bridge_attach()
338 state = bridge->funcs->atomic_reset(bridge); in drm_bridge_attach()
344 drm_atomic_private_obj_init(bridge->dev, &bridge->base, in drm_bridge_attach()
352 if (bridge->funcs->detach) in drm_bridge_attach()
353 bridge->funcs->detach(bridge); in drm_bridge_attach()
356 bridge->dev = NULL; in drm_bridge_attach()
357 bridge->encoder = NULL; in drm_bridge_attach()
358 list_del(&bridge->chain_node); in drm_bridge_attach()
361 DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n", in drm_bridge_attach()
362 bridge->of_node, encoder->name, ret); in drm_bridge_attach()
365 "failed to attach bridge %pOF to encoder %s\n", in drm_bridge_attach()
366 bridge->of_node, encoder->name); in drm_bridge_attach()
372 void drm_bridge_detach(struct drm_bridge *bridge) in drm_bridge_detach() argument
374 if (WARN_ON(!bridge)) in drm_bridge_detach()
377 if (WARN_ON(!bridge->dev)) in drm_bridge_detach()
380 if (bridge->funcs->atomic_reset) in drm_bridge_detach()
381 drm_atomic_private_obj_fini(&bridge->base); in drm_bridge_detach()
383 if (bridge->funcs->detach) in drm_bridge_detach()
384 bridge->funcs->detach(bridge); in drm_bridge_detach()
386 list_del(&bridge->chain_node); in drm_bridge_detach()
387 bridge->dev = NULL; in drm_bridge_detach()
391 * DOC: bridge operations
393 * Bridge drivers expose operations through the &drm_bridge_funcs structure.
395 * drm_bridge.c to call bridge operations. Those operations are divided in
396 * three big categories to support different parts of the bridge usage.
402 * disable the bridge automatically.
409 * Bridge drivers may implement the legacy version of those operations, or
418 * &drm_bridge_funcs.atomic_get_input_bus_fmts allow bridge drivers to
422 * atomic versions of those operations exist, bridge drivers that need to
430 * puts additional burden on bridge drivers, especially for bridges that may
433 * bridge, which doesn't always match the hardware architecture.
435 * To simplify bridge drivers and make the connector implementation more
444 * the bridge connector operations.
446 * Bridge drivers shall implement the connector-related operations for all
447 * the features that the bridge hardware support. For instance, if a bridge
450 * bridge on a particular platform, as they could also be connected to an I2C
452 * running platform is reported through the &drm_bridge.ops flags. Bridge
459 * decide which bridge to delegate a connector operation to. This mechanism
461 * bridge drivers, improving security by storing function pointers in
464 * In order to ease transition, bridge drivers may support both the old and
466 * connected-related bridge operations. Connector creation is then controlled
469 * %DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, and bridge drivers shall then skip
471 * be passed to the drm_bridge_attach() call for the downstream bridge.
472 * Bridge drivers that implement the new model only shall return an error
475 * should use the new model, and convert the bridge drivers they use if
482 * @bridge: bridge control structure
487 * chain, starting from the first bridge to the last. If at least one bridge
490 * Note: the bridge passed should be the one closest to the encoder.
496 drm_bridge_chain_mode_valid(struct drm_bridge *bridge, in drm_bridge_chain_mode_valid() argument
502 if (!bridge) in drm_bridge_chain_mode_valid()
505 encoder = bridge->encoder; in drm_bridge_chain_mode_valid()
506 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_valid()
509 if (!bridge->funcs->mode_valid) in drm_bridge_chain_mode_valid()
512 ret = bridge->funcs->mode_valid(bridge, info, mode); in drm_bridge_chain_mode_valid()
524 * @bridge: bridge control structure
529 * encoder chain, starting from the first bridge to the last.
531 * Note: the bridge passed should be the one closest to the encoder
533 void drm_bridge_chain_mode_set(struct drm_bridge *bridge, in drm_bridge_chain_mode_set() argument
539 if (!bridge) in drm_bridge_chain_mode_set()
542 encoder = bridge->encoder; in drm_bridge_chain_mode_set()
543 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_bridge_chain_mode_set()
544 if (bridge->funcs->mode_set) in drm_bridge_chain_mode_set()
545 bridge->funcs->mode_set(bridge, mode, adjusted_mode); in drm_bridge_chain_mode_set()
552 * @bridge: bridge control structure
557 * starting from the last bridge to the first. These are called before calling
560 * Note: the bridge passed should be the one closest to the encoder
562 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_disable() argument
568 if (!bridge) in drm_atomic_bridge_chain_disable()
571 encoder = bridge->encoder; in drm_atomic_bridge_chain_disable()
587 if (iter == bridge) in drm_atomic_bridge_chain_disable()
593 static void drm_atomic_bridge_call_post_disable(struct drm_bridge *bridge, in drm_atomic_bridge_call_post_disable() argument
596 if (old_state && bridge->funcs->atomic_post_disable) { in drm_atomic_bridge_call_post_disable()
601 bridge); in drm_atomic_bridge_call_post_disable()
605 bridge->funcs->atomic_post_disable(bridge, in drm_atomic_bridge_call_post_disable()
607 } else if (bridge->funcs->post_disable) { in drm_atomic_bridge_call_post_disable()
608 bridge->funcs->post_disable(bridge); in drm_atomic_bridge_call_post_disable()
615 * @bridge: bridge control structure
620 * starting from the first bridge to the last. These are called after completing
623 * If a bridge sets @pre_enable_prev_first, then the @post_disable for that
624 * bridge will be called before the previous one to reverse the @pre_enable
628 * Bridge A ---> Bridge B ---> Bridge C ---> Bridge D ---> Bridge E
630 * With pre_enable_prev_first flag enable in Bridge B, D, E then the resulting
632 * Bridge B, Bridge A, Bridge E, Bridge D, Bridge C.
634 * Note: the bridge passed should be the one closest to the encoder
636 void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_post_disable() argument
642 if (!bridge) in drm_atomic_bridge_chain_post_disable()
645 encoder = bridge->encoder; in drm_atomic_bridge_chain_post_disable()
647 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_post_disable()
650 if (!list_is_last(&bridge->chain_node, &encoder->bridge_chain)) { in drm_atomic_bridge_chain_post_disable()
651 next = list_next_entry(bridge, chain_node); in drm_atomic_bridge_chain_post_disable()
654 /* next bridge had requested that prev in drm_atomic_bridge_chain_post_disable()
659 /* Find the next bridge that has NOT requested in drm_atomic_bridge_chain_post_disable()
680 if (next == bridge) in drm_atomic_bridge_chain_post_disable()
689 drm_atomic_bridge_call_post_disable(bridge, old_state); in drm_atomic_bridge_chain_post_disable()
693 bridge = limit; in drm_atomic_bridge_chain_post_disable()
698 static void drm_atomic_bridge_call_pre_enable(struct drm_bridge *bridge, in drm_atomic_bridge_call_pre_enable() argument
701 if (old_state && bridge->funcs->atomic_pre_enable) { in drm_atomic_bridge_call_pre_enable()
706 bridge); in drm_atomic_bridge_call_pre_enable()
710 bridge->funcs->atomic_pre_enable(bridge, old_bridge_state); in drm_atomic_bridge_call_pre_enable()
711 } else if (bridge->funcs->pre_enable) { in drm_atomic_bridge_call_pre_enable()
712 bridge->funcs->pre_enable(bridge); in drm_atomic_bridge_call_pre_enable()
719 * @bridge: bridge control structure
724 * starting from the last bridge to the first. These are called before calling
727 * If a bridge sets @pre_enable_prev_first, then the pre_enable for the
728 * prev bridge will be called before pre_enable of this bridge.
731 * Bridge A ---> Bridge B ---> Bridge C ---> Bridge D ---> Bridge E
733 * With pre_enable_prev_first flag enable in Bridge B, D, E then the resulting
735 * Bridge C, Bridge D, Bridge E, Bridge A, Bridge B.
737 * Note: the bridge passed should be the one closest to the encoder
739 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_pre_enable() argument
745 if (!bridge) in drm_atomic_bridge_chain_pre_enable()
748 encoder = bridge->encoder; in drm_atomic_bridge_chain_pre_enable()
753 limit = bridge; in drm_atomic_bridge_chain_pre_enable()
757 if (next == bridge) in drm_atomic_bridge_chain_pre_enable()
761 /* Found first bridge that does NOT in drm_atomic_bridge_chain_pre_enable()
770 /* Call requested prev bridge pre_enable in drm_atomic_bridge_chain_pre_enable()
774 /* At the first bridge to request prev in drm_atomic_bridge_chain_pre_enable()
789 if (iter == bridge) in drm_atomic_bridge_chain_pre_enable()
797 * @bridge: bridge control structure
802 * starting from the first bridge to the last. These are called after completing
805 * Note: the bridge passed should be the one closest to the encoder
807 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge, in drm_atomic_bridge_chain_enable() argument
812 if (!bridge) in drm_atomic_bridge_chain_enable()
815 encoder = bridge->encoder; in drm_atomic_bridge_chain_enable()
816 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) { in drm_atomic_bridge_chain_enable()
817 if (bridge->funcs->atomic_enable) { in drm_atomic_bridge_chain_enable()
822 bridge); in drm_atomic_bridge_chain_enable()
826 bridge->funcs->atomic_enable(bridge, old_bridge_state); in drm_atomic_bridge_chain_enable()
827 } else if (bridge->funcs->enable) { in drm_atomic_bridge_chain_enable()
828 bridge->funcs->enable(bridge); in drm_atomic_bridge_chain_enable()
834 static int drm_atomic_bridge_check(struct drm_bridge *bridge, in drm_atomic_bridge_check() argument
838 if (bridge->funcs->atomic_check) { in drm_atomic_bridge_check()
843 bridge); in drm_atomic_bridge_check()
847 ret = bridge->funcs->atomic_check(bridge, bridge_state, in drm_atomic_bridge_check()
851 } else if (bridge->funcs->mode_fixup) { in drm_atomic_bridge_check()
852 if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode, in drm_atomic_bridge_check()
877 * If bus format negotiation is not supported by this bridge, let's in select_bus_fmt_recursive()
878 * pass MEDIA_BUS_FMT_FIXED to the previous bridge in the chain and in select_bus_fmt_recursive()
894 * fine, as long as it does not access the bridge state. in select_bus_fmt_recursive()
949 * It performs bus format negotiation between bridge elements. The negotiation
951 * @bridge.
954 * bridge element and testing them one by one. The test is recursive, meaning
957 * transcoded to the requested output format. When a bridge element does not
959 * the next bridge element will have to try a different format. If none of the
974 * bridge element that lacks this hook and asks the previous element in the
975 * chain to try MEDIA_BUS_FMT_FIXED. It's up to bridge drivers to decide what
981 drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge, in drm_atomic_bridge_chain_select_bus_fmts() argument
986 struct drm_encoder *encoder = bridge->encoder; in drm_atomic_bridge_chain_select_bus_fmts()
1031 ret = select_bus_fmt_recursive(bridge, last_bridge, crtc_state, in drm_atomic_bridge_chain_select_bus_fmts()
1043 drm_atomic_bridge_propagate_bus_flags(struct drm_bridge *bridge, in drm_atomic_bridge_propagate_bus_flags() argument
1051 bridge_state = drm_atomic_get_new_bridge_state(state, bridge); in drm_atomic_bridge_propagate_bus_flags()
1053 /* No bridge state attached to this bridge => nothing to propagate. */ in drm_atomic_bridge_propagate_bus_flags()
1057 next_bridge = drm_bridge_get_next_bridge(bridge); in drm_atomic_bridge_propagate_bus_flags()
1061 * display_info flags for the last bridge, and propagate the input in drm_atomic_bridge_propagate_bus_flags()
1062 * flags of the next bridge element to the output end of the current in drm_atomic_bridge_propagate_bus_flags()
1063 * bridge when the bridge is not the last one. in drm_atomic_bridge_propagate_bus_flags()
1075 * No bridge state attached to the next bridge, just leave the in drm_atomic_bridge_propagate_bus_flags()
1085 * Propagate the output flags to the input end of the bridge. Again, it's in drm_atomic_bridge_propagate_bus_flags()
1094 * drm_atomic_bridge_chain_check() - Do an atomic check on the bridge chain
1095 * @bridge: bridge control structure
1102 * starting from the last bridge to the first. These are called before calling
1108 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge, in drm_atomic_bridge_chain_check() argument
1117 if (!bridge) in drm_atomic_bridge_chain_check()
1120 ret = drm_atomic_bridge_chain_select_bus_fmts(bridge, crtc_state, in drm_atomic_bridge_chain_check()
1125 encoder = bridge->encoder; in drm_atomic_bridge_chain_check()
1130 * Bus flags are propagated by default. If a bridge needs to in drm_atomic_bridge_chain_check()
1143 if (iter == bridge) in drm_atomic_bridge_chain_check()
1152 * drm_bridge_detect - check if anything is attached to the bridge output
1153 * @bridge: bridge control structure
1155 * If the bridge supports output detection, as reported by the
1156 * DRM_BRIDGE_OP_DETECT bridge ops flag, call &drm_bridge_funcs.detect for the
1157 * bridge and return the connection status. Otherwise return
1161 * The detection status on success, or connector_status_unknown if the bridge
1164 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge) in drm_bridge_detect() argument
1166 if (!(bridge->ops & DRM_BRIDGE_OP_DETECT)) in drm_bridge_detect()
1169 return bridge->funcs->detect(bridge); in drm_bridge_detect()
1176 * @bridge: bridge control structure
1179 * If the bridge supports output modes retrieval, as reported by the
1180 * DRM_BRIDGE_OP_MODES bridge ops flag, call &drm_bridge_funcs.get_modes to
1187 int drm_bridge_get_modes(struct drm_bridge *bridge, in drm_bridge_get_modes() argument
1190 if (!(bridge->ops & DRM_BRIDGE_OP_MODES)) in drm_bridge_get_modes()
1193 return bridge->funcs->get_modes(bridge, connector); in drm_bridge_get_modes()
1199 * @bridge: bridge control structure
1202 * If the bridge supports output EDID retrieval, as reported by the
1203 * DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.edid_read to get
1209 const struct drm_edid *drm_bridge_edid_read(struct drm_bridge *bridge, in drm_bridge_edid_read() argument
1212 if (!(bridge->ops & DRM_BRIDGE_OP_EDID)) in drm_bridge_edid_read()
1215 return bridge->funcs->edid_read(bridge, connector); in drm_bridge_edid_read()
1220 * drm_bridge_hpd_enable - enable hot plug detection for the bridge
1221 * @bridge: bridge control structure
1227 * called with @data when an output status change is detected by the bridge,
1231 * bridge->ops. This function shall not be called when the flag is not set.
1235 * the bridge.
1237 void drm_bridge_hpd_enable(struct drm_bridge *bridge, in drm_bridge_hpd_enable() argument
1242 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_enable()
1245 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1247 if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n")) in drm_bridge_hpd_enable()
1250 bridge->hpd_cb = cb; in drm_bridge_hpd_enable()
1251 bridge->hpd_data = data; in drm_bridge_hpd_enable()
1253 if (bridge->funcs->hpd_enable) in drm_bridge_hpd_enable()
1254 bridge->funcs->hpd_enable(bridge); in drm_bridge_hpd_enable()
1257 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_enable()
1262 * drm_bridge_hpd_disable - disable hot plug detection for the bridge
1263 * @bridge: bridge control structure
1267 * Once this function returns the callback will not be called by the bridge
1271 * bridge->ops. This function shall not be called when the flag is not set.
1273 void drm_bridge_hpd_disable(struct drm_bridge *bridge) in drm_bridge_hpd_disable() argument
1275 if (!(bridge->ops & DRM_BRIDGE_OP_HPD)) in drm_bridge_hpd_disable()
1278 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1279 if (bridge->funcs->hpd_disable) in drm_bridge_hpd_disable()
1280 bridge->funcs->hpd_disable(bridge); in drm_bridge_hpd_disable()
1282 bridge->hpd_cb = NULL; in drm_bridge_hpd_disable()
1283 bridge->hpd_data = NULL; in drm_bridge_hpd_disable()
1284 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_disable()
1290 * @bridge: bridge control structure
1293 * Bridge drivers shall call this function to report hot plug events when they
1299 void drm_bridge_hpd_notify(struct drm_bridge *bridge, in drm_bridge_hpd_notify() argument
1302 mutex_lock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1303 if (bridge->hpd_cb) in drm_bridge_hpd_notify()
1304 bridge->hpd_cb(bridge->hpd_data, status); in drm_bridge_hpd_notify()
1305 mutex_unlock(&bridge->hpd_mutex); in drm_bridge_hpd_notify()
1311 * of_drm_find_bridge - find the bridge corresponding to the device node in
1312 * the global bridge list
1321 struct drm_bridge *bridge; in of_drm_find_bridge() local
1325 list_for_each_entry(bridge, &bridge_list, list) { in of_drm_find_bridge()
1326 if (bridge->of_node == np) { in of_drm_find_bridge()
1328 return bridge; in of_drm_find_bridge()
1339 MODULE_DESCRIPTION("DRM bridge infrastructure");