Lines Matching refs:bridge

47  * A bridge is always attached to a single &drm_encoder at a time, but can be
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)
208 mutex_init(&bridge->hpd_mutex);
211 list_add_tail(&bridge->list, &bridge_list);
216 static void drm_bridge_remove_void(void *bridge)
218 drm_bridge_remove(bridge);
224 * @dev: device to tie the bridge lifetime to
225 * @bridge: bridge control structure
232 int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge)
234 drm_bridge_add(bridge);
235 return devm_add_action_or_reset(dev, drm_bridge_remove_void, bridge);
240 * drm_bridge_remove - remove the given bridge from the global bridge list
242 * @bridge: bridge control structure
244 void drm_bridge_remove(struct drm_bridge *bridge)
247 list_del_init(&bridge->list);
250 mutex_destroy(&bridge->hpd_mutex);
257 struct drm_bridge *bridge = drm_priv_to_bridge(obj);
260 state = bridge->funcs->atomic_duplicate_state(bridge);
269 struct drm_bridge *bridge = drm_priv_to_bridge(obj);
271 bridge->funcs->atomic_destroy_state(bridge, state);
280 * drm_bridge_attach - attach the bridge to an encoder's chain
283 * @bridge: bridge to attach
284 * @previous: previous bridge in the chain (optional)
287 * Called by a kms driver to link the bridge to an encoder's chain. The previous
288 * argument specifies the previous bridge in the chain. If NULL, the bridge is
290 * previous bridge's output.
292 * If non-NULL the previous bridge must be already attached by a call to this
302 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
308 if (!encoder || !bridge)
314 if (bridge->dev)
317 bridge->dev = encoder->dev;
318 bridge->encoder = encoder;
321 list_add(&bridge->chain_node, &previous->chain_node);
323 list_add(&bridge->chain_node, &encoder->bridge_chain);
325 if (bridge->funcs->attach) {
326 ret = bridge->funcs->attach(bridge, flags);
331 if (bridge->funcs->atomic_reset) {
334 state = bridge->funcs->atomic_reset(bridge);
340 drm_atomic_private_obj_init(bridge->dev, &bridge->base,
348 if (bridge->funcs->detach)
349 bridge->funcs->detach(bridge);
352 bridge->dev = NULL;
353 bridge->encoder = NULL;
354 list_del(&bridge->chain_node);
357 DRM_ERROR("failed to attach bridge %pOF to encoder %s: %d\n",
358 bridge->of_node, encoder->name, ret);
360 DRM_ERROR("failed to attach bridge to encoder %s: %d\n",
368 void drm_bridge_detach(struct drm_bridge *bridge)
370 if (WARN_ON(!bridge))
373 if (WARN_ON(!bridge->dev))
376 if (bridge->funcs->atomic_reset)
377 drm_atomic_private_obj_fini(&bridge->base);
379 if (bridge->funcs->detach)
380 bridge->funcs->detach(bridge);
382 list_del(&bridge->chain_node);
383 bridge->dev = NULL;
387 * DOC: bridge operations
391 * drm_bridge.c to call bridge operations. Those operations are divided in
392 * three big categories to support different parts of the bridge usage.
398 * disable the bridge automatically.
414 * &drm_bridge_funcs.atomic_get_input_bus_fmts allow bridge drivers to
418 * atomic versions of those operations exist, bridge drivers that need to
426 * puts additional burden on bridge drivers, especially for bridges that may
429 * bridge, which doesn't always match the hardware architecture.
431 * To simplify bridge drivers and make the connector implementation more
440 * the bridge connector operations.
443 * the features that the bridge hardware support. For instance, if a bridge
446 * bridge on a particular platform, as they could also be connected to an I2C
455 * decide which bridge to delegate a connector operation to. This mechanism
457 * bridge drivers, improving security by storing function pointers in
460 * In order to ease transition, bridge drivers may support both the old and
462 * connected-related bridge operations. Connector creation is then controlled
465 * %DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, and bridge drivers shall then skip
467 * be passed to the drm_bridge_attach() call for the downstream bridge.
471 * should use the new model, and convert the bridge drivers they use if
478 * @bridge: bridge control structure
479 * @mode: desired mode to be set for the bridge
480 * @adjusted_mode: updated mode that works for this bridge
483 * encoder chain, starting from the first bridge to the last.
485 * Note: the bridge passed should be the one closest to the encoder
490 bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
496 if (!bridge)
499 encoder = bridge->encoder;
500 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
501 if (!bridge->funcs->mode_fixup)
504 if (!bridge->funcs->mode_fixup(bridge, mode, adjusted_mode))
515 * @bridge: bridge control structure
520 * chain, starting from the first bridge to the last. If at least one bridge
523 * Note: the bridge passed should be the one closest to the encoder.
529 drm_bridge_chain_mode_valid(struct drm_bridge *bridge,
535 if (!bridge)
538 encoder = bridge->encoder;
539 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
542 if (!bridge->funcs->mode_valid)
545 ret = bridge->funcs->mode_valid(bridge, info, mode);
557 * @bridge: bridge control structure
562 * encoder chain, starting from the first bridge to the last.
564 * Note: the bridge passed should be the one closest to the encoder
566 void drm_bridge_chain_mode_set(struct drm_bridge *bridge,
572 if (!bridge)
575 encoder = bridge->encoder;
576 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
577 if (bridge->funcs->mode_set)
578 bridge->funcs->mode_set(bridge, mode, adjusted_mode);
585 * @bridge: bridge control structure
590 * starting from the last bridge to the first. These are called before calling
593 * Note: the bridge passed should be the one closest to the encoder
595 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge,
601 if (!bridge)
604 encoder = bridge->encoder;
620 if (iter == bridge)
626 static void drm_atomic_bridge_call_post_disable(struct drm_bridge *bridge,
629 if (old_state && bridge->funcs->atomic_post_disable) {
634 bridge);
638 bridge->funcs->atomic_post_disable(bridge,
640 } else if (bridge->funcs->post_disable) {
641 bridge->funcs->post_disable(bridge);
648 * @bridge: bridge control structure
653 * starting from the first bridge to the last. These are called after completing
656 * If a bridge sets @pre_enable_prev_first, then the @post_disable for that
657 * bridge will be called before the previous one to reverse the @pre_enable
660 * Note: the bridge passed should be the one closest to the encoder
662 void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
668 if (!bridge)
671 encoder = bridge->encoder;
673 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
676 if (!list_is_last(&bridge->chain_node, &encoder->bridge_chain)) {
677 next = list_next_entry(bridge, chain_node);
680 /* next bridge had requested that prev
685 /* Find the next bridge that has NOT requested
700 if (next == bridge)
709 drm_atomic_bridge_call_post_disable(bridge, old_state);
713 bridge = limit;
718 static void drm_atomic_bridge_call_pre_enable(struct drm_bridge *bridge,
721 if (old_state && bridge->funcs->atomic_pre_enable) {
726 bridge);
730 bridge->funcs->atomic_pre_enable(bridge, old_bridge_state);
731 } else if (bridge->funcs->pre_enable) {
732 bridge->funcs->pre_enable(bridge);
739 * @bridge: bridge control structure
744 * starting from the last bridge to the first. These are called before calling
747 * If a bridge sets @pre_enable_prev_first, then the pre_enable for the
748 * prev bridge will be called before pre_enable of this bridge.
750 * Note: the bridge passed should be the one closest to the encoder
752 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
758 if (!bridge)
761 encoder = bridge->encoder;
766 limit = bridge;
770 if (next == bridge)
774 /* Found first bridge that does NOT
783 /* Call requested prev bridge pre_enable
787 /* At the first bridge to request prev
802 if (iter == bridge)
810 * @bridge: bridge control structure
815 * starting from the first bridge to the last. These are called after completing
818 * Note: the bridge passed should be the one closest to the encoder
820 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,
825 if (!bridge)
828 encoder = bridge->encoder;
829 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
830 if (bridge->funcs->atomic_enable) {
835 bridge);
839 bridge->funcs->atomic_enable(bridge, old_bridge_state);
840 } else if (bridge->funcs->enable) {
841 bridge->funcs->enable(bridge);
847 static int drm_atomic_bridge_check(struct drm_bridge *bridge,
851 if (bridge->funcs->atomic_check) {
856 bridge);
860 ret = bridge->funcs->atomic_check(bridge, bridge_state,
864 } else if (bridge->funcs->mode_fixup) {
865 if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
890 * If bus format negotiation is not supported by this bridge, let's
891 * pass MEDIA_BUS_FMT_FIXED to the previous bridge in the chain and
907 * fine, as long as it does not access the bridge state.
962 * It performs bus format negotiation between bridge elements. The negotiation
964 * @bridge.
967 * bridge element and testing them one by one. The test is recursive, meaning
970 * transcoded to the requested output format. When a bridge element does not
972 * the next bridge element will have to try a different format. If none of the
987 * bridge element that lacks this hook and asks the previous element in the
988 * chain to try MEDIA_BUS_FMT_FIXED. It's up to bridge drivers to decide what
994 drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge,
999 struct drm_encoder *encoder = bridge->encoder;
1044 ret = select_bus_fmt_recursive(bridge, last_bridge, crtc_state,
1056 drm_atomic_bridge_propagate_bus_flags(struct drm_bridge *bridge,
1064 bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
1066 /* No bridge state attached to this bridge => nothing to propagate. */
1070 next_bridge = drm_bridge_get_next_bridge(bridge);
1074 * display_info flags for the last bridge, and propagate the input
1075 * flags of the next bridge element to the output end of the current
1076 * bridge when the bridge is not the last one.
1088 * No bridge state attached to the next bridge, just leave the
1098 * Propagate the output flags to the input end of the bridge. Again, it's
1107 * drm_atomic_bridge_chain_check() - Do an atomic check on the bridge chain
1108 * @bridge: bridge control structure
1115 * starting from the last bridge to the first. These are called before calling
1121 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge,
1130 if (!bridge)
1133 ret = drm_atomic_bridge_chain_select_bus_fmts(bridge, crtc_state,
1138 encoder = bridge->encoder;
1143 * Bus flags are propagated by default. If a bridge needs to
1156 if (iter == bridge)
1165 * drm_bridge_detect - check if anything is attached to the bridge output
1166 * @bridge: bridge control structure
1168 * If the bridge supports output detection, as reported by the
1169 * DRM_BRIDGE_OP_DETECT bridge ops flag, call &drm_bridge_funcs.detect for the
1170 * bridge and return the connection status. Otherwise return
1174 * The detection status on success, or connector_status_unknown if the bridge
1177 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge)
1179 if (!(bridge->ops & DRM_BRIDGE_OP_DETECT))
1182 return bridge->funcs->detect(bridge);
1189 * @bridge: bridge control structure
1192 * If the bridge supports output modes retrieval, as reported by the
1193 * DRM_BRIDGE_OP_MODES bridge ops flag, call &drm_bridge_funcs.get_modes to
1200 int drm_bridge_get_modes(struct drm_bridge *bridge,
1203 if (!(bridge->ops & DRM_BRIDGE_OP_MODES))
1206 return bridge->funcs->get_modes(bridge, connector);
1212 * @bridge: bridge control structure
1215 * If the bridge supports output EDID retrieval, as reported by the
1216 * DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.edid_read to get
1222 const struct drm_edid *drm_bridge_edid_read(struct drm_bridge *bridge,
1225 if (!(bridge->ops & DRM_BRIDGE_OP_EDID))
1228 return bridge->funcs->edid_read(bridge, connector);
1233 * drm_bridge_hpd_enable - enable hot plug detection for the bridge
1234 * @bridge: bridge control structure
1240 * called with @data when an output status change is detected by the bridge,
1244 * bridge->ops. This function shall not be called when the flag is not set.
1248 * the bridge.
1250 void drm_bridge_hpd_enable(struct drm_bridge *bridge,
1255 if (!(bridge->ops & DRM_BRIDGE_OP_HPD))
1258 mutex_lock(&bridge->hpd_mutex);
1260 if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n"))
1263 bridge->hpd_cb = cb;
1264 bridge->hpd_data = data;
1266 if (bridge->funcs->hpd_enable)
1267 bridge->funcs->hpd_enable(bridge);
1270 mutex_unlock(&bridge->hpd_mutex);
1275 * drm_bridge_hpd_disable - disable hot plug detection for the bridge
1276 * @bridge: bridge control structure
1280 * Once this function returns the callback will not be called by the bridge
1284 * bridge->ops. This function shall not be called when the flag is not set.
1286 void drm_bridge_hpd_disable(struct drm_bridge *bridge)
1288 if (!(bridge->ops & DRM_BRIDGE_OP_HPD))
1291 mutex_lock(&bridge->hpd_mutex);
1292 if (bridge->funcs->hpd_disable)
1293 bridge->funcs->hpd_disable(bridge);
1295 bridge->hpd_cb = NULL;
1296 bridge->hpd_data = NULL;
1297 mutex_unlock(&bridge->hpd_mutex);
1303 * @bridge: bridge control structure
1312 void drm_bridge_hpd_notify(struct drm_bridge *bridge,
1315 mutex_lock(&bridge->hpd_mutex);
1316 if (bridge->hpd_cb)
1317 bridge->hpd_cb(bridge->hpd_data, status);
1318 mutex_unlock(&bridge->hpd_mutex);
1324 * of_drm_find_bridge - find the bridge corresponding to the device node in
1325 * the global bridge list
1334 struct drm_bridge *bridge;
1338 list_for_each_entry(bridge, &bridge_list, list) {
1339 if (bridge->of_node == np) {
1341 return bridge;
1352 MODULE_DESCRIPTION("DRM bridge infrastructure");