Lines Matching refs:bridge

41  * A bridge is always attached to a single &drm_encoder at a time, but can be
46 * Here, the output of the encoder feeds to bridge A, and that furthers feeds to
47 * bridge B. Bridge chains can be arbitrarily long, and shall be fully linear:
48 * Chaining multiple bridges to the output of a bridge, or the same bridge to
51 * Display drivers are responsible for linking encoders with the first bridge
52 * in the chains. This is done by acquiring the appropriate bridge with
55 * devm_drm_panel_bridge_add_typed()). Once acquired, the bridge shall be
58 * Bridges are responsible for linking themselves with the next bridge in the
80 * DRM bridge chain functions shall be called manually.
83 * the bridge chain. Display drivers may use the drm_bridge_connector_init()
85 * connector-related operations exposed by the bridge (see the overview
86 * documentation of bridge operations for more details).
98 * drm_bridge_add - add the given bridge to the global bridge list
100 * @bridge: bridge control structure
102 void drm_bridge_add(struct drm_bridge *bridge)
104 mutex_init(&bridge->hpd_mutex);
107 list_add_tail(&bridge->list, &bridge_list);
113 * drm_bridge_remove - remove the given bridge from the global bridge list
115 * @bridge: bridge control structure
117 void drm_bridge_remove(struct drm_bridge *bridge)
120 list_del_init(&bridge->list);
123 mutex_destroy(&bridge->hpd_mutex);
130 struct drm_bridge *bridge = drm_priv_to_bridge(obj);
133 state = bridge->funcs->atomic_duplicate_state(bridge);
142 struct drm_bridge *bridge = drm_priv_to_bridge(obj);
144 bridge->funcs->atomic_destroy_state(bridge, state);
153 * drm_bridge_attach - attach the bridge to an encoder's chain
156 * @bridge: bridge to attach
157 * @previous: previous bridge in the chain (optional)
160 * Called by a kms driver to link the bridge to an encoder's chain. The previous
161 * argument specifies the previous bridge in the chain. If NULL, the bridge is
163 * previous bridge's output.
165 * If non-NULL the previous bridge must be already attached by a call to this
175 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
181 if (!encoder || !bridge)
187 if (bridge->dev)
190 bridge->dev = encoder->dev;
191 bridge->encoder = encoder;
194 list_add(&bridge->chain_node, &previous->chain_node);
196 list_add(&bridge->chain_node, &encoder->bridge_chain);
198 if (bridge->funcs->attach) {
199 ret = bridge->funcs->attach(bridge, flags);
204 if (bridge->funcs->atomic_reset) {
207 state = bridge->funcs->atomic_reset(bridge);
213 drm_atomic_private_obj_init(bridge->dev, &bridge->base,
221 if (bridge->funcs->detach)
222 bridge->funcs->detach(bridge);
225 bridge->dev = NULL;
226 bridge->encoder = NULL;
227 list_del(&bridge->chain_node);
232 void drm_bridge_detach(struct drm_bridge *bridge)
234 if (WARN_ON(!bridge))
237 if (WARN_ON(!bridge->dev))
240 if (bridge->funcs->atomic_reset)
241 drm_atomic_private_obj_fini(&bridge->base);
243 if (bridge->funcs->detach)
244 bridge->funcs->detach(bridge);
246 list_del(&bridge->chain_node);
247 bridge->dev = NULL;
251 * DOC: bridge operations
255 * drm_bridge.c to call bridge operations. Those operations are divided in
256 * three big categories to support different parts of the bridge usage.
262 * disable the bridge automatically.
278 * &drm_bridge_funcs.atomic_get_input_bus_fmts allow bridge drivers to
282 * atomic versions of those operations exist, bridge drivers that need to
290 * puts additional burden on bridge drivers, especially for bridges that may
293 * bridge, which doesn't always match the hardware architecture.
295 * To simplify bridge drivers and make the connector implementation more
304 * the bridge connector operations.
307 * the features that the bridge hardware support. For instance, if a bridge
310 * bridge on a particular platform, as they could also be connected to an I2C
319 * decide which bridge to delegate a connector operation to. This mechanism
321 * bridge drivers, improving security by storing function pointers in
324 * In order to ease transition, bridge drivers may support both the old and
326 * connected-related bridge operations. Connector creation is then controlled
329 * %DRM_BRIDGE_ATTACH_NO_CONNECTOR flag, and bridge drivers shall then skip
331 * be passed to the drm_bridge_attach() call for the downstream bridge.
335 * should use the new model, and convert the bridge drivers they use if
342 * @bridge: bridge control structure
343 * @mode: desired mode to be set for the bridge
344 * @adjusted_mode: updated mode that works for this bridge
347 * encoder chain, starting from the first bridge to the last.
349 * Note: the bridge passed should be the one closest to the encoder
354 bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
360 if (!bridge)
363 encoder = bridge->encoder;
364 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
365 if (!bridge->funcs->mode_fixup)
368 if (!bridge->funcs->mode_fixup(bridge, mode, adjusted_mode))
379 * @bridge: bridge control structure
384 * chain, starting from the first bridge to the last. If at least one bridge
387 * Note: the bridge passed should be the one closest to the encoder.
393 drm_bridge_chain_mode_valid(struct drm_bridge *bridge,
399 if (!bridge)
402 encoder = bridge->encoder;
403 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
406 if (!bridge->funcs->mode_valid)
409 ret = bridge->funcs->mode_valid(bridge, info, mode);
420 * @bridge: bridge control structure
423 * chain, starting from the last bridge to the first. These are called before
426 * Note: the bridge passed should be the one closest to the encoder
428 void drm_bridge_chain_disable(struct drm_bridge *bridge)
433 if (!bridge)
436 encoder = bridge->encoder;
441 if (iter == bridge)
450 * @bridge: bridge control structure
453 * encoder chain, starting from the first bridge to the last. These are called
456 * Note: the bridge passed should be the one closest to the encoder
458 void drm_bridge_chain_post_disable(struct drm_bridge *bridge)
462 if (!bridge)
465 encoder = bridge->encoder;
466 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
467 if (bridge->funcs->post_disable)
468 bridge->funcs->post_disable(bridge);
476 * @bridge: bridge control structure
481 * encoder chain, starting from the first bridge to the last.
483 * Note: the bridge passed should be the one closest to the encoder
485 void drm_bridge_chain_mode_set(struct drm_bridge *bridge,
491 if (!bridge)
494 encoder = bridge->encoder;
495 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
496 if (bridge->funcs->mode_set)
497 bridge->funcs->mode_set(bridge, mode, adjusted_mode);
505 * @bridge: bridge control structure
508 * chain, starting from the last bridge to the first. These are called
511 * Note: the bridge passed should be the one closest to the encoder
513 void drm_bridge_chain_pre_enable(struct drm_bridge *bridge)
518 if (!bridge)
521 encoder = bridge->encoder;
526 if (iter == bridge)
534 * @bridge: bridge control structure
537 * chain, starting from the first bridge to the last. These are called
540 * Note that the bridge passed should be the one closest to the encoder
542 void drm_bridge_chain_enable(struct drm_bridge *bridge)
546 if (!bridge)
549 encoder = bridge->encoder;
550 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
551 if (bridge->funcs->enable)
552 bridge->funcs->enable(bridge);
559 * @bridge: bridge control structure
564 * starting from the last bridge to the first. These are called before calling
567 * Note: the bridge passed should be the one closest to the encoder
569 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge,
575 if (!bridge)
578 encoder = bridge->encoder;
594 if (iter == bridge)
603 * @bridge: bridge control structure
608 * starting from the first bridge to the last. These are called after completing
611 * Note: the bridge passed should be the one closest to the encoder
613 void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
618 if (!bridge)
621 encoder = bridge->encoder;
622 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
623 if (bridge->funcs->atomic_post_disable) {
628 bridge);
632 bridge->funcs->atomic_post_disable(bridge,
634 } else if (bridge->funcs->post_disable) {
635 bridge->funcs->post_disable(bridge);
644 * @bridge: bridge control structure
649 * starting from the last bridge to the first. These are called before calling
652 * Note: the bridge passed should be the one closest to the encoder
654 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
660 if (!bridge)
663 encoder = bridge->encoder;
679 if (iter == bridge)
687 * @bridge: bridge control structure
692 * starting from the first bridge to the last. These are called after completing
695 * Note: the bridge passed should be the one closest to the encoder
697 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,
702 if (!bridge)
705 encoder = bridge->encoder;
706 list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
707 if (bridge->funcs->atomic_enable) {
712 bridge);
716 bridge->funcs->atomic_enable(bridge, old_bridge_state);
717 } else if (bridge->funcs->enable) {
718 bridge->funcs->enable(bridge);
724 static int drm_atomic_bridge_check(struct drm_bridge *bridge,
728 if (bridge->funcs->atomic_check) {
733 bridge);
737 ret = bridge->funcs->atomic_check(bridge, bridge_state,
741 } else if (bridge->funcs->mode_fixup) {
742 if (!bridge->funcs->mode_fixup(bridge, &crtc_state->mode,
767 * If bus format negotiation is not supported by this bridge, let's
768 * pass MEDIA_BUS_FMT_FIXED to the previous bridge in the chain and
784 * fine, as long as it does not access the bridge state.
839 * It performs bus format negotiation between bridge elements. The negotiation
841 * @bridge.
844 * bridge element and testing them one by one. The test is recursive, meaning
847 * transcoded to the requested output format. When a bridge element does not
849 * the next bridge element will have to try a different format. If none of the
864 * bridge element that lacks this hook and asks the previous element in the
865 * chain to try MEDIA_BUS_FMT_FIXED. It's up to bridge drivers to decide what
871 drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge,
876 struct drm_encoder *encoder = bridge->encoder;
921 ret = select_bus_fmt_recursive(bridge, last_bridge, crtc_state,
933 drm_atomic_bridge_propagate_bus_flags(struct drm_bridge *bridge,
941 bridge_state = drm_atomic_get_new_bridge_state(state, bridge);
943 /* No bridge state attached to this bridge => nothing to propagate. */
947 next_bridge = drm_bridge_get_next_bridge(bridge);
951 * display_info flags for the last bridge, and propagate the input
952 * flags of the next bridge element to the output end of the current
953 * bridge when the bridge is not the last one.
965 * No bridge state attached to the next bridge, just leave the
975 * Propage the output flags to the input end of the bridge. Again, it's
984 * drm_atomic_bridge_chain_check() - Do an atomic check on the bridge chain
985 * @bridge: bridge control structure
992 * starting from the last bridge to the first. These are called before calling
998 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge,
1007 if (!bridge)
1010 ret = drm_atomic_bridge_chain_select_bus_fmts(bridge, crtc_state,
1015 encoder = bridge->encoder;
1020 * Bus flags are propagated by default. If a bridge needs to
1033 if (iter == bridge)
1042 * drm_bridge_detect - check if anything is attached to the bridge output
1043 * @bridge: bridge control structure
1045 * If the bridge supports output detection, as reported by the
1046 * DRM_BRIDGE_OP_DETECT bridge ops flag, call &drm_bridge_funcs.detect for the
1047 * bridge and return the connection status. Otherwise return
1051 * The detection status on success, or connector_status_unknown if the bridge
1054 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge)
1056 if (!(bridge->ops & DRM_BRIDGE_OP_DETECT))
1059 return bridge->funcs->detect(bridge);
1066 * @bridge: bridge control structure
1069 * If the bridge supports output modes retrieval, as reported by the
1070 * DRM_BRIDGE_OP_MODES bridge ops flag, call &drm_bridge_funcs.get_modes to
1077 int drm_bridge_get_modes(struct drm_bridge *bridge,
1080 if (!(bridge->ops & DRM_BRIDGE_OP_MODES))
1083 return bridge->funcs->get_modes(bridge, connector);
1089 * @bridge: bridge control structure
1092 * If the bridge supports output EDID retrieval, as reported by the
1093 * DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.get_edid to
1099 struct edid *drm_bridge_get_edid(struct drm_bridge *bridge,
1102 if (!(bridge->ops & DRM_BRIDGE_OP_EDID))
1105 return bridge->funcs->get_edid(bridge, connector);
1110 * drm_bridge_hpd_enable - enable hot plug detection for the bridge
1111 * @bridge: bridge control structure
1117 * called with @data when an output status change is detected by the bridge,
1121 * bridge->ops. This function shall not be called when the flag is not set.
1125 * the bridge.
1127 void drm_bridge_hpd_enable(struct drm_bridge *bridge,
1132 if (!(bridge->ops & DRM_BRIDGE_OP_HPD))
1135 mutex_lock(&bridge->hpd_mutex);
1137 if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n"))
1140 bridge->hpd_cb = cb;
1141 bridge->hpd_data = data;
1143 if (bridge->funcs->hpd_enable)
1144 bridge->funcs->hpd_enable(bridge);
1147 mutex_unlock(&bridge->hpd_mutex);
1152 * drm_bridge_hpd_disable - disable hot plug detection for the bridge
1153 * @bridge: bridge control structure
1157 * Once this function returns the callback will not be called by the bridge
1161 * bridge->ops. This function shall not be called when the flag is not set.
1163 void drm_bridge_hpd_disable(struct drm_bridge *bridge)
1165 if (!(bridge->ops & DRM_BRIDGE_OP_HPD))
1168 mutex_lock(&bridge->hpd_mutex);
1169 if (bridge->funcs->hpd_disable)
1170 bridge->funcs->hpd_disable(bridge);
1172 bridge->hpd_cb = NULL;
1173 bridge->hpd_data = NULL;
1174 mutex_unlock(&bridge->hpd_mutex);
1180 * @bridge: bridge control structure
1189 void drm_bridge_hpd_notify(struct drm_bridge *bridge,
1192 mutex_lock(&bridge->hpd_mutex);
1193 if (bridge->hpd_cb)
1194 bridge->hpd_cb(bridge->hpd_data, status);
1195 mutex_unlock(&bridge->hpd_mutex);
1201 * of_drm_find_bridge - find the bridge corresponding to the device node in
1202 * the global bridge list
1211 struct drm_bridge *bridge;
1215 list_for_each_entry(bridge, &bridge_list, list) {
1216 if (bridge->of_node == np) {
1218 return bridge;
1229 MODULE_DESCRIPTION("DRM bridge infrastructure");