2 * Copyright (c) 2016 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23 #ifndef __DRM_BRIDGE_H__
24 #define __DRM_BRIDGE_H__
26 #include <linux/ctype.h>
27 #include <linux/list.h>
28 #include <linux/mutex.h>
30 #include <drm/drm_atomic.h>
31 #include <drm/drm_encoder.h>
32 #include <drm/drm_mode_object.h>
33 #include <drm/drm_modes.h>
38 struct drm_bridge_timings;
40 struct drm_display_info;
47 * enum drm_bridge_attach_flags - Flags for &drm_bridge_funcs.attach
49 enum drm_bridge_attach_flags {
51 * @DRM_BRIDGE_ATTACH_NO_CONNECTOR: When this flag is set the bridge
52 * shall not create a drm_connector.
54 DRM_BRIDGE_ATTACH_NO_CONNECTOR = BIT(0),
58 * struct drm_bridge_funcs - drm_bridge control functions
60 struct drm_bridge_funcs {
64 * This callback is invoked whenever our bridge is being attached to a
65 * &drm_encoder. The flags argument tunes the behaviour of the attach
66 * operation (see DRM_BRIDGE_ATTACH_*).
68 * The @attach callback is optional.
72 * Zero on success, error code on failure.
74 int (*attach)(struct drm_bridge *bridge,
75 enum drm_bridge_attach_flags flags);
80 * This callback is invoked whenever our bridge is being detached from a
83 * The @detach callback is optional.
85 void (*detach)(struct drm_bridge *bridge);
90 * This callback is used to check if a specific mode is valid in this
91 * bridge. This should be implemented if the bridge has some sort of
92 * restriction in the modes it can display. For example, a given bridge
93 * may be responsible to set a clock value. If the clock can not
94 * produce all the values for the available modes then this callback
95 * can be used to restrict the number of modes to only the ones that
98 * This hook is used by the probe helpers to filter the mode list in
99 * drm_helper_probe_single_connector_modes(), and it is used by the
100 * atomic helpers to validate modes supplied by userspace in
101 * drm_atomic_helper_check_modeset().
103 * The @mode_valid callback is optional.
107 * Since this function is both called from the check phase of an atomic
108 * commit, and the mode validation in the probe paths it is not allowed
109 * to look at anything else but the passed-in mode, and validate it
110 * against configuration-invariant hardward constraints. Any further
111 * limits which depend upon the configuration can only be checked in
116 * drm_mode_status Enum
118 enum drm_mode_status (*mode_valid)(struct drm_bridge *bridge,
119 const struct drm_display_info *info,
120 const struct drm_display_mode *mode);
125 * This callback is used to validate and adjust a mode. The parameter
126 * mode is the display mode that should be fed to the next element in
127 * the display chain, either the final &drm_connector or the next
128 * &drm_bridge. The parameter adjusted_mode is the input mode the bridge
129 * requires. It can be modified by this callback and does not need to
130 * match mode. See also &drm_crtc_state.adjusted_mode for more details.
132 * This is the only hook that allows a bridge to reject a modeset. If
133 * this function passes all other callbacks must succeed for this
136 * The mode_fixup callback is optional. &drm_bridge_funcs.mode_fixup()
137 * is not called when &drm_bridge_funcs.atomic_check() is implemented,
138 * so only one of them should be provided.
142 * This function is called in the check phase of atomic modesets, which
143 * can be aborted for any reason (including on userspace's request to
144 * just check whether a configuration would be possible). Drivers MUST
145 * NOT touch any persistent state (hardware or software) or data
146 * structures except the passed in @state parameter.
148 * Also beware that userspace can request its own custom modes, neither
149 * core nor helpers filter modes to the list of probe modes reported by
150 * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
151 * that modes are filtered consistently put any bridge constraints and
152 * limits checks into @mode_valid.
156 * True if an acceptable configuration is possible, false if the modeset
157 * operation should be rejected.
159 bool (*mode_fixup)(struct drm_bridge *bridge,
160 const struct drm_display_mode *mode,
161 struct drm_display_mode *adjusted_mode);
165 * This callback should disable the bridge. It is called right before
166 * the preceding element in the display pipe is disabled. If the
167 * preceding element is a bridge this means it's called before that
168 * bridge's @disable vfunc. If the preceding element is a &drm_encoder
169 * it's called right before the &drm_encoder_helper_funcs.disable,
170 * &drm_encoder_helper_funcs.prepare or &drm_encoder_helper_funcs.dpms
173 * The bridge can assume that the display pipe (i.e. clocks and timing
174 * signals) feeding it is still running when this callback is called.
176 * The @disable callback is optional.
180 * This is deprecated, do not use!
181 * New drivers shall use &drm_bridge_funcs.atomic_disable.
183 void (*disable)(struct drm_bridge *bridge);
188 * This callback should disable the bridge. It is called right after the
189 * preceding element in the display pipe is disabled. If the preceding
190 * element is a bridge this means it's called after that bridge's
191 * @post_disable function. If the preceding element is a &drm_encoder
192 * it's called right after the encoder's
193 * &drm_encoder_helper_funcs.disable, &drm_encoder_helper_funcs.prepare
194 * or &drm_encoder_helper_funcs.dpms hook.
196 * The bridge must assume that the display pipe (i.e. clocks and timing
197 * singals) feeding it is no longer running when this callback is
200 * The @post_disable callback is optional.
204 * This is deprecated, do not use!
205 * New drivers shall use &drm_bridge_funcs.atomic_post_disable.
207 void (*post_disable)(struct drm_bridge *bridge);
212 * This callback should set the given mode on the bridge. It is called
213 * after the @mode_set callback for the preceding element in the display
214 * pipeline has been called already. If the bridge is the first element
215 * then this would be &drm_encoder_helper_funcs.mode_set. The display
216 * pipe (i.e. clocks and timing signals) is off when this function is
219 * The adjusted_mode parameter is the mode output by the CRTC for the
220 * first bridge in the chain. It can be different from the mode
221 * parameter that contains the desired mode for the connector at the end
222 * of the bridges chain, for instance when the first bridge in the chain
223 * performs scaling. The adjusted mode is mostly useful for the first
224 * bridge in the chain and is likely irrelevant for the other bridges.
226 * For atomic drivers the adjusted_mode is the mode stored in
227 * &drm_crtc_state.adjusted_mode.
231 * This is deprecated, do not use!
232 * New drivers shall set their mode in the
233 * &drm_bridge_funcs.atomic_enable operation.
235 void (*mode_set)(struct drm_bridge *bridge,
236 const struct drm_display_mode *mode,
237 const struct drm_display_mode *adjusted_mode);
241 * This callback should enable the bridge. It is called right before
242 * the preceding element in the display pipe is enabled. If the
243 * preceding element is a bridge this means it's called before that
244 * bridge's @pre_enable function. If the preceding element is a
245 * &drm_encoder it's called right before the encoder's
246 * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or
247 * &drm_encoder_helper_funcs.dpms hook.
249 * The display pipe (i.e. clocks and timing signals) feeding this bridge
250 * will not yet be running when this callback is called. The bridge must
251 * not enable the display link feeding the next bridge in the chain (if
252 * there is one) when this callback is called.
254 * The @pre_enable callback is optional.
258 * This is deprecated, do not use!
259 * New drivers shall use &drm_bridge_funcs.atomic_pre_enable.
261 void (*pre_enable)(struct drm_bridge *bridge);
266 * This callback should enable the bridge. It is called right after
267 * the preceding element in the display pipe is enabled. If the
268 * preceding element is a bridge this means it's called after that
269 * bridge's @enable function. If the preceding element is a
270 * &drm_encoder it's called right after the encoder's
271 * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or
272 * &drm_encoder_helper_funcs.dpms hook.
274 * The bridge can assume that the display pipe (i.e. clocks and timing
275 * signals) feeding it is running when this callback is called. This
276 * callback must enable the display link feeding the next bridge in the
277 * chain if there is one.
279 * The @enable callback is optional.
283 * This is deprecated, do not use!
284 * New drivers shall use &drm_bridge_funcs.atomic_enable.
286 void (*enable)(struct drm_bridge *bridge);
289 * @atomic_pre_enable:
291 * This callback should enable the bridge. It is called right before
292 * the preceding element in the display pipe is enabled. If the
293 * preceding element is a bridge this means it's called before that
294 * bridge's @atomic_pre_enable or @pre_enable function. If the preceding
295 * element is a &drm_encoder it's called right before the encoder's
296 * &drm_encoder_helper_funcs.atomic_enable hook.
298 * The display pipe (i.e. clocks and timing signals) feeding this bridge
299 * will not yet be running when this callback is called. The bridge must
300 * not enable the display link feeding the next bridge in the chain (if
301 * there is one) when this callback is called.
303 * The @atomic_pre_enable callback is optional.
305 void (*atomic_pre_enable)(struct drm_bridge *bridge,
306 struct drm_bridge_state *old_bridge_state);
311 * This callback should enable the bridge. It is called right after
312 * the preceding element in the display pipe is enabled. If the
313 * preceding element is a bridge this means it's called after that
314 * bridge's @atomic_enable or @enable function. If the preceding element
315 * is a &drm_encoder it's called right after the encoder's
316 * &drm_encoder_helper_funcs.atomic_enable hook.
318 * The bridge can assume that the display pipe (i.e. clocks and timing
319 * signals) feeding it is running when this callback is called. This
320 * callback must enable the display link feeding the next bridge in the
321 * chain if there is one.
323 * The @atomic_enable callback is optional.
325 void (*atomic_enable)(struct drm_bridge *bridge,
326 struct drm_bridge_state *old_bridge_state);
330 * This callback should disable the bridge. It is called right before
331 * the preceding element in the display pipe is disabled. If the
332 * preceding element is a bridge this means it's called before that
333 * bridge's @atomic_disable or @disable vfunc. If the preceding element
334 * is a &drm_encoder it's called right before the
335 * &drm_encoder_helper_funcs.atomic_disable hook.
337 * The bridge can assume that the display pipe (i.e. clocks and timing
338 * signals) feeding it is still running when this callback is called.
340 * The @atomic_disable callback is optional.
342 void (*atomic_disable)(struct drm_bridge *bridge,
343 struct drm_bridge_state *old_bridge_state);
346 * @atomic_post_disable:
348 * This callback should disable the bridge. It is called right after the
349 * preceding element in the display pipe is disabled. If the preceding
350 * element is a bridge this means it's called after that bridge's
351 * @atomic_post_disable or @post_disable function. If the preceding
352 * element is a &drm_encoder it's called right after the encoder's
353 * &drm_encoder_helper_funcs.atomic_disable hook.
355 * The bridge must assume that the display pipe (i.e. clocks and timing
356 * signals) feeding it is no longer running when this callback is
359 * The @atomic_post_disable callback is optional.
361 void (*atomic_post_disable)(struct drm_bridge *bridge,
362 struct drm_bridge_state *old_bridge_state);
365 * @atomic_duplicate_state:
367 * Duplicate the current bridge state object (which is guaranteed to be
370 * The atomic_duplicate_state hook is mandatory if the bridge
371 * implements any of the atomic hooks, and should be left unassigned
372 * otherwise. For bridges that don't subclass &drm_bridge_state, the
373 * drm_atomic_helper_bridge_duplicate_state() helper function shall be
374 * used to implement this hook.
377 * A valid drm_bridge_state object or NULL if the allocation fails.
379 struct drm_bridge_state *(*atomic_duplicate_state)(struct drm_bridge *bridge);
382 * @atomic_destroy_state:
384 * Destroy a bridge state object previously allocated by
385 * &drm_bridge_funcs.atomic_duplicate_state().
387 * The atomic_destroy_state hook is mandatory if the bridge implements
388 * any of the atomic hooks, and should be left unassigned otherwise.
389 * For bridges that don't subclass &drm_bridge_state, the
390 * drm_atomic_helper_bridge_destroy_state() helper function shall be
391 * used to implement this hook.
393 void (*atomic_destroy_state)(struct drm_bridge *bridge,
394 struct drm_bridge_state *state);
397 * @atomic_get_output_bus_fmts:
399 * Return the supported bus formats on the output end of a bridge.
400 * The returned array must be allocated with kmalloc() and will be
401 * freed by the caller. If the allocation fails, NULL should be
402 * returned. num_output_fmts must be set to the returned array size.
403 * Formats listed in the returned array should be listed in decreasing
404 * preference order (the core will try all formats until it finds one
407 * This method is only called on the last element of the bridge chain
408 * as part of the bus format negotiation process that happens in
409 * &drm_atomic_bridge_chain_select_bus_fmts().
410 * This method is optional. When not implemented, the core will
411 * fall back to &drm_connector.display_info.bus_formats[0] if
412 * &drm_connector.display_info.num_bus_formats > 0,
413 * or to MEDIA_BUS_FMT_FIXED otherwise.
415 u32 *(*atomic_get_output_bus_fmts)(struct drm_bridge *bridge,
416 struct drm_bridge_state *bridge_state,
417 struct drm_crtc_state *crtc_state,
418 struct drm_connector_state *conn_state,
419 unsigned int *num_output_fmts);
422 * @atomic_get_input_bus_fmts:
424 * Return the supported bus formats on the input end of a bridge for
425 * a specific output bus format.
427 * The returned array must be allocated with kmalloc() and will be
428 * freed by the caller. If the allocation fails, NULL should be
429 * returned. num_input_fmts must be set to the returned array size.
430 * Formats listed in the returned array should be listed in decreasing
431 * preference order (the core will try all formats until it finds one
432 * that works). When the format is not supported NULL should be
433 * returned and num_input_fmts should be set to 0.
435 * This method is called on all elements of the bridge chain as part of
436 * the bus format negotiation process that happens in
437 * drm_atomic_bridge_chain_select_bus_fmts().
438 * This method is optional. When not implemented, the core will bypass
439 * bus format negotiation on this element of the bridge without
440 * failing, and the previous element in the chain will be passed
441 * MEDIA_BUS_FMT_FIXED as its output bus format.
443 * Bridge drivers that need to support being linked to bridges that are
444 * not supporting bus format negotiation should handle the
445 * output_fmt == MEDIA_BUS_FMT_FIXED case appropriately, by selecting a
446 * sensible default value or extracting this information from somewhere
447 * else (FW property, &drm_display_mode, &drm_display_info, ...)
449 * Note: Even if input format selection on the first bridge has no
450 * impact on the negotiation process (bus format negotiation stops once
451 * we reach the first element of the chain), drivers are expected to
452 * return accurate input formats as the input format may be used to
453 * configure the CRTC output appropriately.
455 u32 *(*atomic_get_input_bus_fmts)(struct drm_bridge *bridge,
456 struct drm_bridge_state *bridge_state,
457 struct drm_crtc_state *crtc_state,
458 struct drm_connector_state *conn_state,
460 unsigned int *num_input_fmts);
465 * This method is responsible for checking bridge state correctness.
466 * It can also check the state of the surrounding components in chain
467 * to make sure the whole pipeline can work properly.
469 * &drm_bridge_funcs.atomic_check() hooks are called in reverse
470 * order (from the last to the first bridge).
472 * This method is optional. &drm_bridge_funcs.mode_fixup() is not
473 * called when &drm_bridge_funcs.atomic_check() is implemented, so only
474 * one of them should be provided.
476 * If drivers need to tweak &drm_bridge_state.input_bus_cfg.flags or
477 * &drm_bridge_state.output_bus_cfg.flags it should happen in
478 * this function. By default the &drm_bridge_state.output_bus_cfg.flags
479 * field is set to the next bridge
480 * &drm_bridge_state.input_bus_cfg.flags value or
481 * &drm_connector.display_info.bus_flags if the bridge is the last
482 * element in the chain.
485 * zero if the check passed, a negative error code otherwise.
487 int (*atomic_check)(struct drm_bridge *bridge,
488 struct drm_bridge_state *bridge_state,
489 struct drm_crtc_state *crtc_state,
490 struct drm_connector_state *conn_state);
495 * Reset the bridge to a predefined state (or retrieve its current
496 * state) and return a &drm_bridge_state object matching this state.
497 * This function is called at attach time.
499 * The atomic_reset hook is mandatory if the bridge implements any of
500 * the atomic hooks, and should be left unassigned otherwise. For
501 * bridges that don't subclass &drm_bridge_state, the
502 * drm_atomic_helper_bridge_reset() helper function shall be used to
503 * implement this hook.
505 * Note that the atomic_reset() semantics is not exactly matching the
506 * reset() semantics found on other components (connector, plane, ...).
508 * 1. The reset operation happens when the bridge is attached, not when
509 * drm_mode_config_reset() is called
510 * 2. It's meant to be used exclusively on bridges that have been
511 * converted to the ATOMIC API
514 * A valid drm_bridge_state object in case of success, an ERR_PTR()
515 * giving the reason of the failure otherwise.
517 struct drm_bridge_state *(*atomic_reset)(struct drm_bridge *bridge);
522 * Check if anything is attached to the bridge output.
524 * This callback is optional, if not implemented the bridge will be
525 * considered as always having a component attached to its output.
526 * Bridges that implement this callback shall set the
527 * DRM_BRIDGE_OP_DETECT flag in their &drm_bridge->ops.
531 * drm_connector_status indicating the bridge output status.
533 enum drm_connector_status (*detect)(struct drm_bridge *bridge);
538 * Fill all modes currently valid for the sink into the &drm_connector
539 * with drm_mode_probed_add().
541 * The @get_modes callback is mostly intended to support non-probeable
542 * displays such as many fixed panels. Bridges that support reading
543 * EDID shall leave @get_modes unimplemented and implement the
544 * &drm_bridge_funcs->get_edid callback instead.
546 * This callback is optional. Bridges that implement it shall set the
547 * DRM_BRIDGE_OP_MODES flag in their &drm_bridge->ops.
549 * The connector parameter shall be used for the sole purpose of
550 * filling modes, and shall not be stored internally by bridge drivers
555 * The number of modes added by calling drm_mode_probed_add().
557 int (*get_modes)(struct drm_bridge *bridge,
558 struct drm_connector *connector);
563 * Read and parse the EDID data of the connected display.
565 * The @get_edid callback is the preferred way of reporting mode
566 * information for a display connected to the bridge output. Bridges
567 * that support reading EDID shall implement this callback and leave
568 * the @get_modes callback unimplemented.
570 * The caller of this operation shall first verify the output
571 * connection status and refrain from reading EDID from a disconnected
574 * This callback is optional. Bridges that implement it shall set the
575 * DRM_BRIDGE_OP_EDID flag in their &drm_bridge->ops.
577 * The connector parameter shall be used for the sole purpose of EDID
578 * retrieval and parsing, and shall not be stored internally by bridge
579 * drivers for future usage.
583 * An edid structure newly allocated with kmalloc() (or similar) on
584 * success, or NULL otherwise. The caller is responsible for freeing
585 * the returned edid structure with kfree().
587 struct edid *(*get_edid)(struct drm_bridge *bridge,
588 struct drm_connector *connector);
593 * Notify the bridge of hot plug detection.
595 * This callback is optional, it may be implemented by bridges that
596 * need to be notified of display connection or disconnection for
597 * internal reasons. One use case is to reset the internal state of CEC
598 * controllers for HDMI bridges.
600 void (*hpd_notify)(struct drm_bridge *bridge,
601 enum drm_connector_status status);
606 * Enable hot plug detection. From now on the bridge shall call
607 * drm_bridge_hpd_notify() each time a change is detected in the output
608 * connection status, until hot plug detection gets disabled with
611 * This callback is optional and shall only be implemented by bridges
612 * that support hot-plug notification without polling. Bridges that
613 * implement it shall also implement the @hpd_disable callback and set
614 * the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops.
616 void (*hpd_enable)(struct drm_bridge *bridge);
621 * Disable hot plug detection. Once this function returns the bridge
622 * shall not call drm_bridge_hpd_notify() when a change in the output
623 * connection status occurs.
625 * This callback is optional and shall only be implemented by bridges
626 * that support hot-plug notification without polling. Bridges that
627 * implement it shall also implement the @hpd_enable callback and set
628 * the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops.
630 void (*hpd_disable)(struct drm_bridge *bridge);
635 * Allows bridges to create bridge-specific debugfs files.
637 void (*debugfs_init)(struct drm_bridge *bridge, struct dentry *root);
641 * struct drm_bridge_timings - timing information for the bridge
643 struct drm_bridge_timings {
647 * Tells what additional settings for the pixel data on the bus
648 * this bridge requires (like pixel signal polarity). See also
649 * &drm_display_info->bus_flags.
655 * Defines the time in picoseconds the input data lines must be
656 * stable before the clock edge.
662 * Defines the time in picoseconds taken for the bridge to sample the
663 * input signal after the clock edge.
669 * True if the bus operates in dual-link mode. The exact meaning is
670 * dependent on the bus type. For LVDS buses, this indicates that even-
671 * and odd-numbered pixels are received on separate links.
677 * enum drm_bridge_ops - Bitmask of operations supported by the bridge
679 enum drm_bridge_ops {
681 * @DRM_BRIDGE_OP_DETECT: The bridge can detect displays connected to
682 * its output. Bridges that set this flag shall implement the
683 * &drm_bridge_funcs->detect callback.
685 DRM_BRIDGE_OP_DETECT = BIT(0),
687 * @DRM_BRIDGE_OP_EDID: The bridge can retrieve the EDID of the display
688 * connected to its output. Bridges that set this flag shall implement
689 * the &drm_bridge_funcs->get_edid callback.
691 DRM_BRIDGE_OP_EDID = BIT(1),
693 * @DRM_BRIDGE_OP_HPD: The bridge can detect hot-plug and hot-unplug
694 * without requiring polling. Bridges that set this flag shall
695 * implement the &drm_bridge_funcs->hpd_enable and
696 * &drm_bridge_funcs->hpd_disable callbacks if they support enabling
697 * and disabling hot-plug detection dynamically.
699 DRM_BRIDGE_OP_HPD = BIT(2),
701 * @DRM_BRIDGE_OP_MODES: The bridge can retrieve the modes supported
702 * by the display at its output. This does not include reading EDID
703 * which is separately covered by @DRM_BRIDGE_OP_EDID. Bridges that set
704 * this flag shall implement the &drm_bridge_funcs->get_modes callback.
706 DRM_BRIDGE_OP_MODES = BIT(3),
710 * struct drm_bridge - central DRM bridge control structure
713 /** @base: inherit from &drm_private_object */
714 struct drm_private_obj base;
715 /** @dev: DRM device this bridge belongs to */
716 struct drm_device *dev;
717 /** @encoder: encoder to which this bridge is connected */
718 struct drm_encoder *encoder;
719 /** @chain_node: used to form a bridge chain */
720 struct list_head chain_node;
721 /** @of_node: device node pointer to the bridge */
722 struct device_node *of_node;
723 /** @list: to keep track of all added bridges */
724 struct list_head list;
728 * the timing specification for the bridge, if any (may be NULL)
730 const struct drm_bridge_timings *timings;
731 /** @funcs: control functions */
732 const struct drm_bridge_funcs *funcs;
733 /** @driver_private: pointer to the bridge driver's internal context */
734 void *driver_private;
735 /** @ops: bitmask of operations supported by the bridge */
736 enum drm_bridge_ops ops;
738 * @type: Type of the connection at the bridge output
739 * (DRM_MODE_CONNECTOR_*). For bridges at the end of this chain this
740 * identifies the type of connected display.
744 * @interlace_allowed: Indicate that the bridge can handle interlaced
747 bool interlace_allowed;
749 * @pre_enable_prev_first: The bridge requires that the prev
750 * bridge @pre_enable function is called before its @pre_enable,
751 * and conversely for post_disable. This is most frequently a
752 * requirement for DSI devices which need the host to be initialised
753 * before the peripheral.
755 bool pre_enable_prev_first;
757 * @ddc: Associated I2C adapter for DDC access, if any.
759 struct i2c_adapter *ddc;
762 * @hpd_mutex: Protects the @hpd_cb and @hpd_data fields.
764 struct mutex hpd_mutex;
766 * @hpd_cb: Hot plug detection callback, registered with
767 * drm_bridge_hpd_enable().
769 void (*hpd_cb)(void *data, enum drm_connector_status status);
771 * @hpd_data: Private data passed to the Hot plug detection callback
777 static inline struct drm_bridge *
778 drm_priv_to_bridge(struct drm_private_obj *priv)
780 return container_of(priv, struct drm_bridge, base);
783 void drm_bridge_add(struct drm_bridge *bridge);
784 int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge);
785 void drm_bridge_remove(struct drm_bridge *bridge);
786 int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
787 struct drm_bridge *previous,
788 enum drm_bridge_attach_flags flags);
791 struct drm_bridge *of_drm_find_bridge(struct device_node *np);
793 static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np)
800 * drm_bridge_get_next_bridge() - Get the next bridge in the chain
801 * @bridge: bridge object
804 * the next bridge in the chain after @bridge, or NULL if @bridge is the last.
806 static inline struct drm_bridge *
807 drm_bridge_get_next_bridge(struct drm_bridge *bridge)
809 if (list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain))
812 return list_next_entry(bridge, chain_node);
816 * drm_bridge_get_prev_bridge() - Get the previous bridge in the chain
817 * @bridge: bridge object
820 * the previous bridge in the chain, or NULL if @bridge is the first.
822 static inline struct drm_bridge *
823 drm_bridge_get_prev_bridge(struct drm_bridge *bridge)
825 if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))
828 return list_prev_entry(bridge, chain_node);
832 * drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain
833 * @encoder: encoder object
836 * the first bridge in the chain, or NULL if @encoder has no bridge attached
839 static inline struct drm_bridge *
840 drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder)
842 return list_first_entry_or_null(&encoder->bridge_chain,
843 struct drm_bridge, chain_node);
847 * drm_for_each_bridge_in_chain() - Iterate over all bridges present in a chain
848 * @encoder: the encoder to iterate bridges on
849 * @bridge: a bridge pointer updated to point to the current bridge at each
852 * Iterate over all bridges present in the bridge chain attached to @encoder.
854 #define drm_for_each_bridge_in_chain(encoder, bridge) \
855 list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node)
857 bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
858 const struct drm_display_mode *mode,
859 struct drm_display_mode *adjusted_mode);
861 drm_bridge_chain_mode_valid(struct drm_bridge *bridge,
862 const struct drm_display_info *info,
863 const struct drm_display_mode *mode);
864 void drm_bridge_chain_mode_set(struct drm_bridge *bridge,
865 const struct drm_display_mode *mode,
866 const struct drm_display_mode *adjusted_mode);
868 int drm_atomic_bridge_chain_check(struct drm_bridge *bridge,
869 struct drm_crtc_state *crtc_state,
870 struct drm_connector_state *conn_state);
871 void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge,
872 struct drm_atomic_state *state);
873 void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
874 struct drm_atomic_state *state);
875 void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
876 struct drm_atomic_state *state);
877 void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,
878 struct drm_atomic_state *state);
881 drm_atomic_helper_bridge_propagate_bus_fmt(struct drm_bridge *bridge,
882 struct drm_bridge_state *bridge_state,
883 struct drm_crtc_state *crtc_state,
884 struct drm_connector_state *conn_state,
886 unsigned int *num_input_fmts);
888 enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge);
889 int drm_bridge_get_modes(struct drm_bridge *bridge,
890 struct drm_connector *connector);
891 struct edid *drm_bridge_get_edid(struct drm_bridge *bridge,
892 struct drm_connector *connector);
893 void drm_bridge_hpd_enable(struct drm_bridge *bridge,
894 void (*cb)(void *data,
895 enum drm_connector_status status),
897 void drm_bridge_hpd_disable(struct drm_bridge *bridge);
898 void drm_bridge_hpd_notify(struct drm_bridge *bridge,
899 enum drm_connector_status status);
901 #ifdef CONFIG_DRM_PANEL_BRIDGE
902 bool drm_bridge_is_panel(const struct drm_bridge *bridge);
903 struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel);
904 struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel,
906 void drm_panel_bridge_remove(struct drm_bridge *bridge);
907 int drm_panel_bridge_set_orientation(struct drm_connector *connector,
908 struct drm_bridge *bridge);
909 struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev,
910 struct drm_panel *panel);
911 struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev,
912 struct drm_panel *panel,
914 struct drm_bridge *drmm_panel_bridge_add(struct drm_device *drm,
915 struct drm_panel *panel);
916 struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge);
918 static inline bool drm_bridge_is_panel(const struct drm_bridge *bridge)
923 static inline int drm_panel_bridge_set_orientation(struct drm_connector *connector,
924 struct drm_bridge *bridge)
930 #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL_BRIDGE)
931 struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node,
932 u32 port, u32 endpoint);
933 struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, struct device_node *node,
934 u32 port, u32 endpoint);
936 static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev,
937 struct device_node *node,
941 return ERR_PTR(-ENODEV);
944 static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm,
945 struct device_node *node,
949 return ERR_PTR(-ENODEV);
953 void drm_bridge_debugfs_init(struct drm_device *dev);