1 | /* |
2 | * Copyright (c) 2016 Intel Corporation |
3 | * |
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. |
13 | * |
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 |
20 | * OF THIS SOFTWARE. |
21 | */ |
22 | |
23 | #ifndef __DRM_BRIDGE_H__ |
24 | #define __DRM_BRIDGE_H__ |
25 | |
26 | #include <linux/ctype.h> |
27 | #include <linux/list.h> |
28 | #include <linux/mutex.h> |
29 | |
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> |
34 | |
35 | struct device_node; |
36 | |
37 | struct drm_bridge; |
38 | struct drm_bridge_timings; |
39 | struct drm_connector; |
40 | struct drm_display_info; |
41 | struct drm_minor; |
42 | struct drm_panel; |
43 | struct edid; |
44 | struct hdmi_codec_daifmt; |
45 | struct hdmi_codec_params; |
46 | struct i2c_adapter; |
47 | |
48 | /** |
49 | * enum drm_bridge_attach_flags - Flags for &drm_bridge_funcs.attach |
50 | */ |
51 | enum drm_bridge_attach_flags { |
52 | /** |
53 | * @DRM_BRIDGE_ATTACH_NO_CONNECTOR: When this flag is set the bridge |
54 | * shall not create a drm_connector. |
55 | */ |
56 | DRM_BRIDGE_ATTACH_NO_CONNECTOR = BIT(0), |
57 | }; |
58 | |
59 | /** |
60 | * struct drm_bridge_funcs - drm_bridge control functions |
61 | */ |
62 | struct drm_bridge_funcs { |
63 | /** |
64 | * @attach: |
65 | * |
66 | * This callback is invoked whenever our bridge is being attached to a |
67 | * &drm_encoder. The flags argument tunes the behaviour of the attach |
68 | * operation (see DRM_BRIDGE_ATTACH_*). |
69 | * |
70 | * The @attach callback is optional. |
71 | * |
72 | * RETURNS: |
73 | * |
74 | * Zero on success, error code on failure. |
75 | */ |
76 | int (*attach)(struct drm_bridge *bridge, struct drm_encoder *encoder, |
77 | enum drm_bridge_attach_flags flags); |
78 | |
79 | /** |
80 | * @detach: |
81 | * |
82 | * This callback is invoked whenever our bridge is being detached from a |
83 | * &drm_encoder. |
84 | * |
85 | * The @detach callback is optional. |
86 | */ |
87 | void (*detach)(struct drm_bridge *bridge); |
88 | |
89 | /** |
90 | * @mode_valid: |
91 | * |
92 | * This callback is used to check if a specific mode is valid in this |
93 | * bridge. This should be implemented if the bridge has some sort of |
94 | * restriction in the modes it can display. For example, a given bridge |
95 | * may be responsible to set a clock value. If the clock can not |
96 | * produce all the values for the available modes then this callback |
97 | * can be used to restrict the number of modes to only the ones that |
98 | * can be displayed. |
99 | * |
100 | * This hook is used by the probe helpers to filter the mode list in |
101 | * drm_helper_probe_single_connector_modes(), and it is used by the |
102 | * atomic helpers to validate modes supplied by userspace in |
103 | * drm_atomic_helper_check_modeset(). |
104 | * |
105 | * The @mode_valid callback is optional. |
106 | * |
107 | * NOTE: |
108 | * |
109 | * Since this function is both called from the check phase of an atomic |
110 | * commit, and the mode validation in the probe paths it is not allowed |
111 | * to look at anything else but the passed-in mode, and validate it |
112 | * against configuration-invariant hardware constraints. Any further |
113 | * limits which depend upon the configuration can only be checked in |
114 | * @mode_fixup. |
115 | * |
116 | * RETURNS: |
117 | * |
118 | * drm_mode_status Enum |
119 | */ |
120 | enum drm_mode_status (*mode_valid)(struct drm_bridge *bridge, |
121 | const struct drm_display_info *info, |
122 | const struct drm_display_mode *mode); |
123 | |
124 | /** |
125 | * @mode_fixup: |
126 | * |
127 | * This callback is used to validate and adjust a mode. The parameter |
128 | * mode is the display mode that should be fed to the next element in |
129 | * the display chain, either the final &drm_connector or the next |
130 | * &drm_bridge. The parameter adjusted_mode is the input mode the bridge |
131 | * requires. It can be modified by this callback and does not need to |
132 | * match mode. See also &drm_crtc_state.adjusted_mode for more details. |
133 | * |
134 | * This is the only hook that allows a bridge to reject a modeset. If |
135 | * this function passes all other callbacks must succeed for this |
136 | * configuration. |
137 | * |
138 | * The mode_fixup callback is optional. &drm_bridge_funcs.mode_fixup() |
139 | * is not called when &drm_bridge_funcs.atomic_check() is implemented, |
140 | * so only one of them should be provided. |
141 | * |
142 | * NOTE: |
143 | * |
144 | * This function is called in the check phase of atomic modesets, which |
145 | * can be aborted for any reason (including on userspace's request to |
146 | * just check whether a configuration would be possible). Drivers MUST |
147 | * NOT touch any persistent state (hardware or software) or data |
148 | * structures except the passed in @state parameter. |
149 | * |
150 | * Also beware that userspace can request its own custom modes, neither |
151 | * core nor helpers filter modes to the list of probe modes reported by |
152 | * the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure |
153 | * that modes are filtered consistently put any bridge constraints and |
154 | * limits checks into @mode_valid. |
155 | * |
156 | * RETURNS: |
157 | * |
158 | * True if an acceptable configuration is possible, false if the modeset |
159 | * operation should be rejected. |
160 | */ |
161 | bool (*mode_fixup)(struct drm_bridge *bridge, |
162 | const struct drm_display_mode *mode, |
163 | struct drm_display_mode *adjusted_mode); |
164 | /** |
165 | * @disable: |
166 | * |
167 | * This callback should disable the bridge. It is called right before |
168 | * the preceding element in the display pipe is disabled. If the |
169 | * preceding element is a bridge this means it's called before that |
170 | * bridge's @disable vfunc. If the preceding element is a &drm_encoder |
171 | * it's called right before the &drm_encoder_helper_funcs.disable, |
172 | * &drm_encoder_helper_funcs.prepare or &drm_encoder_helper_funcs.dpms |
173 | * hook. |
174 | * |
175 | * The bridge can assume that the display pipe (i.e. clocks and timing |
176 | * signals) feeding it is still running when this callback is called. |
177 | * |
178 | * The @disable callback is optional. |
179 | * |
180 | * NOTE: |
181 | * |
182 | * This is deprecated, do not use! |
183 | * New drivers shall use &drm_bridge_funcs.atomic_disable. |
184 | */ |
185 | void (*disable)(struct drm_bridge *bridge); |
186 | |
187 | /** |
188 | * @post_disable: |
189 | * |
190 | * This callback should disable the bridge. It is called right after the |
191 | * preceding element in the display pipe is disabled. If the preceding |
192 | * element is a bridge this means it's called after that bridge's |
193 | * @post_disable function. If the preceding element is a &drm_encoder |
194 | * it's called right after the encoder's |
195 | * &drm_encoder_helper_funcs.disable, &drm_encoder_helper_funcs.prepare |
196 | * or &drm_encoder_helper_funcs.dpms hook. |
197 | * |
198 | * The bridge must assume that the display pipe (i.e. clocks and timing |
199 | * signals) feeding it is no longer running when this callback is |
200 | * called. |
201 | * |
202 | * The @post_disable callback is optional. |
203 | * |
204 | * NOTE: |
205 | * |
206 | * This is deprecated, do not use! |
207 | * New drivers shall use &drm_bridge_funcs.atomic_post_disable. |
208 | */ |
209 | void (*post_disable)(struct drm_bridge *bridge); |
210 | |
211 | /** |
212 | * @mode_set: |
213 | * |
214 | * This callback should set the given mode on the bridge. It is called |
215 | * after the @mode_set callback for the preceding element in the display |
216 | * pipeline has been called already. If the bridge is the first element |
217 | * then this would be &drm_encoder_helper_funcs.mode_set. The display |
218 | * pipe (i.e. clocks and timing signals) is off when this function is |
219 | * called. |
220 | * |
221 | * The adjusted_mode parameter is the mode output by the CRTC for the |
222 | * first bridge in the chain. It can be different from the mode |
223 | * parameter that contains the desired mode for the connector at the end |
224 | * of the bridges chain, for instance when the first bridge in the chain |
225 | * performs scaling. The adjusted mode is mostly useful for the first |
226 | * bridge in the chain and is likely irrelevant for the other bridges. |
227 | * |
228 | * For atomic drivers the adjusted_mode is the mode stored in |
229 | * &drm_crtc_state.adjusted_mode. |
230 | * |
231 | * NOTE: |
232 | * |
233 | * This is deprecated, do not use! |
234 | * New drivers shall set their mode in the |
235 | * &drm_bridge_funcs.atomic_enable operation. |
236 | */ |
237 | void (*mode_set)(struct drm_bridge *bridge, |
238 | const struct drm_display_mode *mode, |
239 | const struct drm_display_mode *adjusted_mode); |
240 | /** |
241 | * @pre_enable: |
242 | * |
243 | * This callback should enable the bridge. It is called right before |
244 | * the preceding element in the display pipe is enabled. If the |
245 | * preceding element is a bridge this means it's called before that |
246 | * bridge's @pre_enable function. If the preceding element is a |
247 | * &drm_encoder it's called right before the encoder's |
248 | * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or |
249 | * &drm_encoder_helper_funcs.dpms hook. |
250 | * |
251 | * The display pipe (i.e. clocks and timing signals) feeding this bridge |
252 | * will not yet be running when this callback is called. The bridge must |
253 | * not enable the display link feeding the next bridge in the chain (if |
254 | * there is one) when this callback is called. |
255 | * |
256 | * The @pre_enable callback is optional. |
257 | * |
258 | * NOTE: |
259 | * |
260 | * This is deprecated, do not use! |
261 | * New drivers shall use &drm_bridge_funcs.atomic_pre_enable. |
262 | */ |
263 | void (*pre_enable)(struct drm_bridge *bridge); |
264 | |
265 | /** |
266 | * @enable: |
267 | * |
268 | * This callback should enable the bridge. It is called right after |
269 | * the preceding element in the display pipe is enabled. If the |
270 | * preceding element is a bridge this means it's called after that |
271 | * bridge's @enable function. If the preceding element is a |
272 | * &drm_encoder it's called right after the encoder's |
273 | * &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or |
274 | * &drm_encoder_helper_funcs.dpms hook. |
275 | * |
276 | * The bridge can assume that the display pipe (i.e. clocks and timing |
277 | * signals) feeding it is running when this callback is called. This |
278 | * callback must enable the display link feeding the next bridge in the |
279 | * chain if there is one. |
280 | * |
281 | * The @enable callback is optional. |
282 | * |
283 | * NOTE: |
284 | * |
285 | * This is deprecated, do not use! |
286 | * New drivers shall use &drm_bridge_funcs.atomic_enable. |
287 | */ |
288 | void (*enable)(struct drm_bridge *bridge); |
289 | |
290 | /** |
291 | * @atomic_pre_enable: |
292 | * |
293 | * This callback should enable the bridge. It is called right before |
294 | * the preceding element in the display pipe is enabled. If the |
295 | * preceding element is a bridge this means it's called before that |
296 | * bridge's @atomic_pre_enable or @pre_enable function. If the preceding |
297 | * element is a &drm_encoder it's called right before the encoder's |
298 | * &drm_encoder_helper_funcs.atomic_enable hook. |
299 | * |
300 | * The display pipe (i.e. clocks and timing signals) feeding this bridge |
301 | * will not yet be running when this callback is called. The bridge must |
302 | * not enable the display link feeding the next bridge in the chain (if |
303 | * there is one) when this callback is called. |
304 | * |
305 | * The @atomic_pre_enable callback is optional. |
306 | */ |
307 | void (*atomic_pre_enable)(struct drm_bridge *bridge, |
308 | struct drm_atomic_state *state); |
309 | |
310 | /** |
311 | * @atomic_enable: |
312 | * |
313 | * This callback should enable the bridge. It is called right after |
314 | * the preceding element in the display pipe is enabled. If the |
315 | * preceding element is a bridge this means it's called after that |
316 | * bridge's @atomic_enable or @enable function. If the preceding element |
317 | * is a &drm_encoder it's called right after the encoder's |
318 | * &drm_encoder_helper_funcs.atomic_enable hook. |
319 | * |
320 | * The bridge can assume that the display pipe (i.e. clocks and timing |
321 | * signals) feeding it is running when this callback is called. This |
322 | * callback must enable the display link feeding the next bridge in the |
323 | * chain if there is one. |
324 | * |
325 | * The @atomic_enable callback is optional. |
326 | */ |
327 | void (*atomic_enable)(struct drm_bridge *bridge, |
328 | struct drm_atomic_state *state); |
329 | /** |
330 | * @atomic_disable: |
331 | * |
332 | * This callback should disable the bridge. It is called right before |
333 | * the preceding element in the display pipe is disabled. If the |
334 | * preceding element is a bridge this means it's called before that |
335 | * bridge's @atomic_disable or @disable vfunc. If the preceding element |
336 | * is a &drm_encoder it's called right before the |
337 | * &drm_encoder_helper_funcs.atomic_disable hook. |
338 | * |
339 | * The bridge can assume that the display pipe (i.e. clocks and timing |
340 | * signals) feeding it is still running when this callback is called. |
341 | * |
342 | * The @atomic_disable callback is optional. |
343 | */ |
344 | void (*atomic_disable)(struct drm_bridge *bridge, |
345 | struct drm_atomic_state *state); |
346 | |
347 | /** |
348 | * @atomic_post_disable: |
349 | * |
350 | * This callback should disable the bridge. It is called right after the |
351 | * preceding element in the display pipe is disabled. If the preceding |
352 | * element is a bridge this means it's called after that bridge's |
353 | * @atomic_post_disable or @post_disable function. If the preceding |
354 | * element is a &drm_encoder it's called right after the encoder's |
355 | * &drm_encoder_helper_funcs.atomic_disable hook. |
356 | * |
357 | * The bridge must assume that the display pipe (i.e. clocks and timing |
358 | * signals) feeding it is no longer running when this callback is |
359 | * called. |
360 | * |
361 | * The @atomic_post_disable callback is optional. |
362 | */ |
363 | void (*atomic_post_disable)(struct drm_bridge *bridge, |
364 | struct drm_atomic_state *state); |
365 | |
366 | /** |
367 | * @atomic_duplicate_state: |
368 | * |
369 | * Duplicate the current bridge state object (which is guaranteed to be |
370 | * non-NULL). |
371 | * |
372 | * The atomic_duplicate_state hook is mandatory if the bridge |
373 | * implements any of the atomic hooks, and should be left unassigned |
374 | * otherwise. For bridges that don't subclass &drm_bridge_state, the |
375 | * drm_atomic_helper_bridge_duplicate_state() helper function shall be |
376 | * used to implement this hook. |
377 | * |
378 | * RETURNS: |
379 | * A valid drm_bridge_state object or NULL if the allocation fails. |
380 | */ |
381 | struct drm_bridge_state *(*atomic_duplicate_state)(struct drm_bridge *bridge); |
382 | |
383 | /** |
384 | * @atomic_destroy_state: |
385 | * |
386 | * Destroy a bridge state object previously allocated by |
387 | * &drm_bridge_funcs.atomic_duplicate_state(). |
388 | * |
389 | * The atomic_destroy_state hook is mandatory if the bridge implements |
390 | * any of the atomic hooks, and should be left unassigned otherwise. |
391 | * For bridges that don't subclass &drm_bridge_state, the |
392 | * drm_atomic_helper_bridge_destroy_state() helper function shall be |
393 | * used to implement this hook. |
394 | */ |
395 | void (*atomic_destroy_state)(struct drm_bridge *bridge, |
396 | struct drm_bridge_state *state); |
397 | |
398 | /** |
399 | * @atomic_get_output_bus_fmts: |
400 | * |
401 | * Return the supported bus formats on the output end of a bridge. |
402 | * The returned array must be allocated with kmalloc() and will be |
403 | * freed by the caller. If the allocation fails, NULL should be |
404 | * returned. num_output_fmts must be set to the returned array size. |
405 | * Formats listed in the returned array should be listed in decreasing |
406 | * preference order (the core will try all formats until it finds one |
407 | * that works). |
408 | * |
409 | * This method is only called on the last element of the bridge chain |
410 | * as part of the bus format negotiation process that happens in |
411 | * &drm_atomic_bridge_chain_select_bus_fmts(). |
412 | * This method is optional. When not implemented, the core will |
413 | * fall back to &drm_connector.display_info.bus_formats[0] if |
414 | * &drm_connector.display_info.num_bus_formats > 0, |
415 | * or to MEDIA_BUS_FMT_FIXED otherwise. |
416 | */ |
417 | u32 *(*atomic_get_output_bus_fmts)(struct drm_bridge *bridge, |
418 | struct drm_bridge_state *bridge_state, |
419 | struct drm_crtc_state *crtc_state, |
420 | struct drm_connector_state *conn_state, |
421 | unsigned int *num_output_fmts); |
422 | |
423 | /** |
424 | * @atomic_get_input_bus_fmts: |
425 | * |
426 | * Return the supported bus formats on the input end of a bridge for |
427 | * a specific output bus format. |
428 | * |
429 | * The returned array must be allocated with kmalloc() and will be |
430 | * freed by the caller. If the allocation fails, NULL should be |
431 | * returned. num_input_fmts must be set to the returned array size. |
432 | * Formats listed in the returned array should be listed in decreasing |
433 | * preference order (the core will try all formats until it finds one |
434 | * that works). When the format is not supported NULL should be |
435 | * returned and num_input_fmts should be set to 0. |
436 | * |
437 | * This method is called on all elements of the bridge chain as part of |
438 | * the bus format negotiation process that happens in |
439 | * drm_atomic_bridge_chain_select_bus_fmts(). |
440 | * This method is optional. When not implemented, the core will bypass |
441 | * bus format negotiation on this element of the bridge without |
442 | * failing, and the previous element in the chain will be passed |
443 | * MEDIA_BUS_FMT_FIXED as its output bus format. |
444 | * |
445 | * Bridge drivers that need to support being linked to bridges that are |
446 | * not supporting bus format negotiation should handle the |
447 | * output_fmt == MEDIA_BUS_FMT_FIXED case appropriately, by selecting a |
448 | * sensible default value or extracting this information from somewhere |
449 | * else (FW property, &drm_display_mode, &drm_display_info, ...) |
450 | * |
451 | * Note: Even if input format selection on the first bridge has no |
452 | * impact on the negotiation process (bus format negotiation stops once |
453 | * we reach the first element of the chain), drivers are expected to |
454 | * return accurate input formats as the input format may be used to |
455 | * configure the CRTC output appropriately. |
456 | */ |
457 | u32 *(*atomic_get_input_bus_fmts)(struct drm_bridge *bridge, |
458 | struct drm_bridge_state *bridge_state, |
459 | struct drm_crtc_state *crtc_state, |
460 | struct drm_connector_state *conn_state, |
461 | u32 output_fmt, |
462 | unsigned int *num_input_fmts); |
463 | |
464 | /** |
465 | * @atomic_check: |
466 | * |
467 | * This method is responsible for checking bridge state correctness. |
468 | * It can also check the state of the surrounding components in chain |
469 | * to make sure the whole pipeline can work properly. |
470 | * |
471 | * &drm_bridge_funcs.atomic_check() hooks are called in reverse |
472 | * order (from the last to the first bridge). |
473 | * |
474 | * This method is optional. &drm_bridge_funcs.mode_fixup() is not |
475 | * called when &drm_bridge_funcs.atomic_check() is implemented, so only |
476 | * one of them should be provided. |
477 | * |
478 | * If drivers need to tweak &drm_bridge_state.input_bus_cfg.flags or |
479 | * &drm_bridge_state.output_bus_cfg.flags it should happen in |
480 | * this function. By default the &drm_bridge_state.output_bus_cfg.flags |
481 | * field is set to the next bridge |
482 | * &drm_bridge_state.input_bus_cfg.flags value or |
483 | * &drm_connector.display_info.bus_flags if the bridge is the last |
484 | * element in the chain. |
485 | * |
486 | * RETURNS: |
487 | * zero if the check passed, a negative error code otherwise. |
488 | */ |
489 | int (*atomic_check)(struct drm_bridge *bridge, |
490 | struct drm_bridge_state *bridge_state, |
491 | struct drm_crtc_state *crtc_state, |
492 | struct drm_connector_state *conn_state); |
493 | |
494 | /** |
495 | * @atomic_reset: |
496 | * |
497 | * Reset the bridge to a predefined state (or retrieve its current |
498 | * state) and return a &drm_bridge_state object matching this state. |
499 | * This function is called at attach time. |
500 | * |
501 | * The atomic_reset hook is mandatory if the bridge implements any of |
502 | * the atomic hooks, and should be left unassigned otherwise. For |
503 | * bridges that don't subclass &drm_bridge_state, the |
504 | * drm_atomic_helper_bridge_reset() helper function shall be used to |
505 | * implement this hook. |
506 | * |
507 | * Note that the atomic_reset() semantics is not exactly matching the |
508 | * reset() semantics found on other components (connector, plane, ...). |
509 | * |
510 | * 1. The reset operation happens when the bridge is attached, not when |
511 | * drm_mode_config_reset() is called |
512 | * 2. It's meant to be used exclusively on bridges that have been |
513 | * converted to the ATOMIC API |
514 | * |
515 | * RETURNS: |
516 | * A valid drm_bridge_state object in case of success, an ERR_PTR() |
517 | * giving the reason of the failure otherwise. |
518 | */ |
519 | struct drm_bridge_state *(*atomic_reset)(struct drm_bridge *bridge); |
520 | |
521 | /** |
522 | * @detect: |
523 | * |
524 | * Check if anything is attached to the bridge output. |
525 | * |
526 | * This callback is optional, if not implemented the bridge will be |
527 | * considered as always having a component attached to its output. |
528 | * Bridges that implement this callback shall set the |
529 | * DRM_BRIDGE_OP_DETECT flag in their &drm_bridge->ops. |
530 | * |
531 | * RETURNS: |
532 | * |
533 | * drm_connector_status indicating the bridge output status. |
534 | */ |
535 | enum drm_connector_status (*detect)(struct drm_bridge *bridge); |
536 | |
537 | /** |
538 | * @get_modes: |
539 | * |
540 | * Fill all modes currently valid for the sink into the &drm_connector |
541 | * with drm_mode_probed_add(). |
542 | * |
543 | * The @get_modes callback is mostly intended to support non-probeable |
544 | * displays such as many fixed panels. Bridges that support reading |
545 | * EDID shall leave @get_modes unimplemented and implement the |
546 | * &drm_bridge_funcs->edid_read callback instead. |
547 | * |
548 | * This callback is optional. Bridges that implement it shall set the |
549 | * DRM_BRIDGE_OP_MODES flag in their &drm_bridge->ops. |
550 | * |
551 | * The connector parameter shall be used for the sole purpose of |
552 | * filling modes, and shall not be stored internally by bridge drivers |
553 | * for future usage. |
554 | * |
555 | * RETURNS: |
556 | * |
557 | * The number of modes added by calling drm_mode_probed_add(). |
558 | */ |
559 | int (*get_modes)(struct drm_bridge *bridge, |
560 | struct drm_connector *connector); |
561 | |
562 | /** |
563 | * @edid_read: |
564 | * |
565 | * Read the EDID data of the connected display. |
566 | * |
567 | * The @edid_read callback is the preferred way of reporting mode |
568 | * information for a display connected to the bridge output. Bridges |
569 | * that support reading EDID shall implement this callback and leave |
570 | * the @get_modes callback unimplemented. |
571 | * |
572 | * The caller of this operation shall first verify the output |
573 | * connection status and refrain from reading EDID from a disconnected |
574 | * output. |
575 | * |
576 | * This callback is optional. Bridges that implement it shall set the |
577 | * DRM_BRIDGE_OP_EDID flag in their &drm_bridge->ops. |
578 | * |
579 | * The connector parameter shall be used for the sole purpose of EDID |
580 | * retrieval, and shall not be stored internally by bridge drivers for |
581 | * future usage. |
582 | * |
583 | * RETURNS: |
584 | * |
585 | * An edid structure newly allocated with drm_edid_alloc() or returned |
586 | * from drm_edid_read() family of functions on success, or NULL |
587 | * otherwise. The caller is responsible for freeing the returned edid |
588 | * structure with drm_edid_free(). |
589 | */ |
590 | const struct drm_edid *(*edid_read)(struct drm_bridge *bridge, |
591 | struct drm_connector *connector); |
592 | |
593 | /** |
594 | * @hpd_notify: |
595 | * |
596 | * Notify the bridge of hot plug detection. |
597 | * |
598 | * This callback is optional, it may be implemented by bridges that |
599 | * need to be notified of display connection or disconnection for |
600 | * internal reasons. One use case is to reset the internal state of CEC |
601 | * controllers for HDMI bridges. |
602 | */ |
603 | void (*hpd_notify)(struct drm_bridge *bridge, |
604 | enum drm_connector_status status); |
605 | |
606 | /** |
607 | * @hpd_enable: |
608 | * |
609 | * Enable hot plug detection. From now on the bridge shall call |
610 | * drm_bridge_hpd_notify() each time a change is detected in the output |
611 | * connection status, until hot plug detection gets disabled with |
612 | * @hpd_disable. |
613 | * |
614 | * This callback is optional and shall only be implemented by bridges |
615 | * that support hot-plug notification without polling. Bridges that |
616 | * implement it shall also implement the @hpd_disable callback and set |
617 | * the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops. |
618 | */ |
619 | void (*hpd_enable)(struct drm_bridge *bridge); |
620 | |
621 | /** |
622 | * @hpd_disable: |
623 | * |
624 | * Disable hot plug detection. Once this function returns the bridge |
625 | * shall not call drm_bridge_hpd_notify() when a change in the output |
626 | * connection status occurs. |
627 | * |
628 | * This callback is optional and shall only be implemented by bridges |
629 | * that support hot-plug notification without polling. Bridges that |
630 | * implement it shall also implement the @hpd_enable callback and set |
631 | * the DRM_BRIDGE_OP_HPD flag in their &drm_bridge->ops. |
632 | */ |
633 | void (*hpd_disable)(struct drm_bridge *bridge); |
634 | |
635 | /** |
636 | * @hdmi_tmds_char_rate_valid: |
637 | * |
638 | * Check whether a particular TMDS character rate is supported by the |
639 | * driver. |
640 | * |
641 | * This callback is optional and should only be implemented by the |
642 | * bridges that take part in the HDMI connector implementation. Bridges |
643 | * that implement it shall set the DRM_BRIDGE_OP_HDMI flag in their |
644 | * &drm_bridge->ops. |
645 | * |
646 | * Returns: |
647 | * |
648 | * Either &drm_mode_status.MODE_OK or one of the failure reasons |
649 | * in &enum drm_mode_status. |
650 | */ |
651 | enum drm_mode_status |
652 | (*hdmi_tmds_char_rate_valid)(const struct drm_bridge *bridge, |
653 | const struct drm_display_mode *mode, |
654 | unsigned long long tmds_rate); |
655 | |
656 | /** |
657 | * @hdmi_clear_infoframe: |
658 | * |
659 | * This callback clears the infoframes in the hardware during commit. |
660 | * It will be called multiple times, once for every disabled infoframe |
661 | * type. |
662 | * |
663 | * This callback is optional but it must be implemented by bridges that |
664 | * set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops. |
665 | */ |
666 | int (*hdmi_clear_infoframe)(struct drm_bridge *bridge, |
667 | enum hdmi_infoframe_type type); |
668 | /** |
669 | * @hdmi_write_infoframe: |
670 | * |
671 | * Program the infoframe into the hardware. It will be called multiple |
672 | * times, once for every updated infoframe type. |
673 | * |
674 | * This callback is optional but it must be implemented by bridges that |
675 | * set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops. |
676 | */ |
677 | int (*hdmi_write_infoframe)(struct drm_bridge *bridge, |
678 | enum hdmi_infoframe_type type, |
679 | const u8 *buffer, size_t len); |
680 | |
681 | /** |
682 | * @hdmi_audio_startup: |
683 | * |
684 | * Called when ASoC starts an audio stream setup. |
685 | * |
686 | * This callback is optional, it can be implemented by bridges that |
687 | * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. |
688 | * |
689 | * Returns: |
690 | * 0 on success, a negative error code otherwise |
691 | */ |
692 | int (*hdmi_audio_startup)(struct drm_connector *connector, |
693 | struct drm_bridge *bridge); |
694 | |
695 | /** |
696 | * @hdmi_audio_prepare: |
697 | * Configures HDMI-encoder for audio stream. Can be called multiple |
698 | * times for each setup. |
699 | * |
700 | * This callback is optional but it must be implemented by bridges that |
701 | * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. |
702 | * |
703 | * Returns: |
704 | * 0 on success, a negative error code otherwise |
705 | */ |
706 | int (*hdmi_audio_prepare)(struct drm_connector *connector, |
707 | struct drm_bridge *bridge, |
708 | struct hdmi_codec_daifmt *fmt, |
709 | struct hdmi_codec_params *hparms); |
710 | |
711 | /** |
712 | * @hdmi_audio_shutdown: |
713 | * |
714 | * Shut down the audio stream. |
715 | * |
716 | * This callback is optional but it must be implemented by bridges that |
717 | * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. |
718 | * |
719 | * Returns: |
720 | * 0 on success, a negative error code otherwise |
721 | */ |
722 | void (*hdmi_audio_shutdown)(struct drm_connector *connector, |
723 | struct drm_bridge *bridge); |
724 | |
725 | /** |
726 | * @hdmi_audio_mute_stream: |
727 | * |
728 | * Mute/unmute HDMI audio stream. |
729 | * |
730 | * This callback is optional, it can be implemented by bridges that |
731 | * set the @DRM_BRIDGE_OP_HDMI_AUDIO flag in their &drm_bridge->ops. |
732 | * |
733 | * Returns: |
734 | * 0 on success, a negative error code otherwise |
735 | */ |
736 | int (*hdmi_audio_mute_stream)(struct drm_connector *connector, |
737 | struct drm_bridge *bridge, |
738 | bool enable, int direction); |
739 | |
740 | /** |
741 | * @dp_audio_startup: |
742 | * |
743 | * Called when ASoC starts a DisplayPort audio stream setup. |
744 | * |
745 | * This callback is optional, it can be implemented by bridges that |
746 | * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. |
747 | * |
748 | * Returns: |
749 | * 0 on success, a negative error code otherwise |
750 | */ |
751 | int (*dp_audio_startup)(struct drm_connector *connector, |
752 | struct drm_bridge *bridge); |
753 | |
754 | /** |
755 | * @dp_audio_prepare: |
756 | * Configures DisplayPort audio stream. Can be called multiple |
757 | * times for each setup. |
758 | * |
759 | * This callback is optional but it must be implemented by bridges that |
760 | * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. |
761 | * |
762 | * Returns: |
763 | * 0 on success, a negative error code otherwise |
764 | */ |
765 | int (*dp_audio_prepare)(struct drm_connector *connector, |
766 | struct drm_bridge *bridge, |
767 | struct hdmi_codec_daifmt *fmt, |
768 | struct hdmi_codec_params *hparms); |
769 | |
770 | /** |
771 | * @dp_audio_shutdown: |
772 | * |
773 | * Shut down the DisplayPort audio stream. |
774 | * |
775 | * This callback is optional but it must be implemented by bridges that |
776 | * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. |
777 | * |
778 | * Returns: |
779 | * 0 on success, a negative error code otherwise |
780 | */ |
781 | void (*dp_audio_shutdown)(struct drm_connector *connector, |
782 | struct drm_bridge *bridge); |
783 | |
784 | /** |
785 | * @dp_audio_mute_stream: |
786 | * |
787 | * Mute/unmute DisplayPort audio stream. |
788 | * |
789 | * This callback is optional, it can be implemented by bridges that |
790 | * set the @DRM_BRIDGE_OP_DP_AUDIO flag in their &drm_bridge->ops. |
791 | * |
792 | * Returns: |
793 | * 0 on success, a negative error code otherwise |
794 | */ |
795 | int (*dp_audio_mute_stream)(struct drm_connector *connector, |
796 | struct drm_bridge *bridge, |
797 | bool enable, int direction); |
798 | |
799 | /** |
800 | * @debugfs_init: |
801 | * |
802 | * Allows bridges to create bridge-specific debugfs files. |
803 | */ |
804 | void (*debugfs_init)(struct drm_bridge *bridge, struct dentry *root); |
805 | }; |
806 | |
807 | /** |
808 | * struct drm_bridge_timings - timing information for the bridge |
809 | */ |
810 | struct drm_bridge_timings { |
811 | /** |
812 | * @input_bus_flags: |
813 | * |
814 | * Tells what additional settings for the pixel data on the bus |
815 | * this bridge requires (like pixel signal polarity). See also |
816 | * &drm_display_info->bus_flags. |
817 | */ |
818 | u32 input_bus_flags; |
819 | /** |
820 | * @setup_time_ps: |
821 | * |
822 | * Defines the time in picoseconds the input data lines must be |
823 | * stable before the clock edge. |
824 | */ |
825 | u32 setup_time_ps; |
826 | /** |
827 | * @hold_time_ps: |
828 | * |
829 | * Defines the time in picoseconds taken for the bridge to sample the |
830 | * input signal after the clock edge. |
831 | */ |
832 | u32 hold_time_ps; |
833 | /** |
834 | * @dual_link: |
835 | * |
836 | * True if the bus operates in dual-link mode. The exact meaning is |
837 | * dependent on the bus type. For LVDS buses, this indicates that even- |
838 | * and odd-numbered pixels are received on separate links. |
839 | */ |
840 | bool dual_link; |
841 | }; |
842 | |
843 | /** |
844 | * enum drm_bridge_ops - Bitmask of operations supported by the bridge |
845 | */ |
846 | enum drm_bridge_ops { |
847 | /** |
848 | * @DRM_BRIDGE_OP_DETECT: The bridge can detect displays connected to |
849 | * its output. Bridges that set this flag shall implement the |
850 | * &drm_bridge_funcs->detect callback. |
851 | */ |
852 | DRM_BRIDGE_OP_DETECT = BIT(0), |
853 | /** |
854 | * @DRM_BRIDGE_OP_EDID: The bridge can retrieve the EDID of the display |
855 | * connected to its output. Bridges that set this flag shall implement |
856 | * the &drm_bridge_funcs->edid_read callback. |
857 | */ |
858 | DRM_BRIDGE_OP_EDID = BIT(1), |
859 | /** |
860 | * @DRM_BRIDGE_OP_HPD: The bridge can detect hot-plug and hot-unplug |
861 | * without requiring polling. Bridges that set this flag shall |
862 | * implement the &drm_bridge_funcs->hpd_enable and |
863 | * &drm_bridge_funcs->hpd_disable callbacks if they support enabling |
864 | * and disabling hot-plug detection dynamically. |
865 | */ |
866 | DRM_BRIDGE_OP_HPD = BIT(2), |
867 | /** |
868 | * @DRM_BRIDGE_OP_MODES: The bridge can retrieve the modes supported |
869 | * by the display at its output. This does not include reading EDID |
870 | * which is separately covered by @DRM_BRIDGE_OP_EDID. Bridges that set |
871 | * this flag shall implement the &drm_bridge_funcs->get_modes callback. |
872 | */ |
873 | DRM_BRIDGE_OP_MODES = BIT(3), |
874 | /** |
875 | * @DRM_BRIDGE_OP_HDMI: The bridge provides HDMI connector operations, |
876 | * including infoframes support. Bridges that set this flag must |
877 | * implement the &drm_bridge_funcs->write_infoframe callback. |
878 | * |
879 | * Note: currently there can be at most one bridge in a chain that sets |
880 | * this bit. This is to simplify corresponding glue code in connector |
881 | * drivers. |
882 | */ |
883 | DRM_BRIDGE_OP_HDMI = BIT(4), |
884 | /** |
885 | * @DRM_BRIDGE_OP_HDMI_AUDIO: The bridge provides HDMI audio operations. |
886 | * Bridges that set this flag must implement the |
887 | * &drm_bridge_funcs->hdmi_audio_prepare and |
888 | * &drm_bridge_funcs->hdmi_audio_shutdown callbacks. |
889 | * |
890 | * Note: currently there can be at most one bridge in a chain that sets |
891 | * this bit. This is to simplify corresponding glue code in connector |
892 | * drivers. Also it is not possible to have a bridge in the chain that |
893 | * sets @DRM_BRIDGE_OP_DP_AUDIO if there is a bridge that sets this |
894 | * flag. |
895 | */ |
896 | DRM_BRIDGE_OP_HDMI_AUDIO = BIT(5), |
897 | /** |
898 | * @DRM_BRIDGE_OP_DP_AUDIO: The bridge provides DisplayPort audio operations. |
899 | * Bridges that set this flag must implement the |
900 | * &drm_bridge_funcs->dp_audio_prepare and |
901 | * &drm_bridge_funcs->dp_audio_shutdown callbacks. |
902 | * |
903 | * Note: currently there can be at most one bridge in a chain that sets |
904 | * this bit. This is to simplify corresponding glue code in connector |
905 | * drivers. Also it is not possible to have a bridge in the chain that |
906 | * sets @DRM_BRIDGE_OP_HDMI_AUDIO if there is a bridge that sets this |
907 | * flag. |
908 | */ |
909 | DRM_BRIDGE_OP_DP_AUDIO = BIT(6), |
910 | }; |
911 | |
912 | /** |
913 | * struct drm_bridge - central DRM bridge control structure |
914 | */ |
915 | struct drm_bridge { |
916 | /** @base: inherit from &drm_private_object */ |
917 | struct drm_private_obj base; |
918 | /** @dev: DRM device this bridge belongs to */ |
919 | struct drm_device *dev; |
920 | /** @encoder: encoder to which this bridge is connected */ |
921 | struct drm_encoder *encoder; |
922 | /** @chain_node: used to form a bridge chain */ |
923 | struct list_head chain_node; |
924 | /** @of_node: device node pointer to the bridge */ |
925 | struct device_node *of_node; |
926 | /** @list: to keep track of all added bridges */ |
927 | struct list_head list; |
928 | /** |
929 | * @timings: |
930 | * |
931 | * the timing specification for the bridge, if any (may be NULL) |
932 | */ |
933 | const struct drm_bridge_timings *timings; |
934 | /** @funcs: control functions */ |
935 | const struct drm_bridge_funcs *funcs; |
936 | |
937 | /** |
938 | * @container: Pointer to the private driver struct embedding this |
939 | * @struct drm_bridge. |
940 | */ |
941 | void *container; |
942 | |
943 | /** |
944 | * @refcount: reference count of users referencing this bridge. |
945 | */ |
946 | struct kref refcount; |
947 | |
948 | /** @driver_private: pointer to the bridge driver's internal context */ |
949 | void *driver_private; |
950 | /** @ops: bitmask of operations supported by the bridge */ |
951 | enum drm_bridge_ops ops; |
952 | /** |
953 | * @type: Type of the connection at the bridge output |
954 | * (DRM_MODE_CONNECTOR_*). For bridges at the end of this chain this |
955 | * identifies the type of connected display. |
956 | */ |
957 | int type; |
958 | /** |
959 | * @interlace_allowed: Indicate that the bridge can handle interlaced |
960 | * modes. |
961 | */ |
962 | bool interlace_allowed; |
963 | /** |
964 | * @ycbcr_420_allowed: Indicate that the bridge can handle YCbCr 420 |
965 | * output. |
966 | */ |
967 | bool ycbcr_420_allowed; |
968 | /** |
969 | * @pre_enable_prev_first: The bridge requires that the prev |
970 | * bridge @pre_enable function is called before its @pre_enable, |
971 | * and conversely for post_disable. This is most frequently a |
972 | * requirement for DSI devices which need the host to be initialised |
973 | * before the peripheral. |
974 | */ |
975 | bool pre_enable_prev_first; |
976 | /** |
977 | * @ddc: Associated I2C adapter for DDC access, if any. |
978 | */ |
979 | struct i2c_adapter *ddc; |
980 | /** private: */ |
981 | /** |
982 | * @hpd_mutex: Protects the @hpd_cb and @hpd_data fields. |
983 | */ |
984 | struct mutex hpd_mutex; |
985 | /** |
986 | * @hpd_cb: Hot plug detection callback, registered with |
987 | * drm_bridge_hpd_enable(). |
988 | */ |
989 | void (*hpd_cb)(void *data, enum drm_connector_status status); |
990 | /** |
991 | * @hpd_data: Private data passed to the Hot plug detection callback |
992 | * @hpd_cb. |
993 | */ |
994 | void *hpd_data; |
995 | |
996 | /** |
997 | * @vendor: Vendor of the product to be used for the SPD InfoFrame |
998 | * generation. This is required if @DRM_BRIDGE_OP_HDMI is set. |
999 | */ |
1000 | const char *vendor; |
1001 | |
1002 | /** |
1003 | * @product: Name of the product to be used for the SPD InfoFrame |
1004 | * generation. This is required if @DRM_BRIDGE_OP_HDMI is set. |
1005 | */ |
1006 | const char *product; |
1007 | |
1008 | /** |
1009 | * @supported_formats: Bitmask of @hdmi_colorspace listing supported |
1010 | * output formats. This is only relevant if @DRM_BRIDGE_OP_HDMI is set. |
1011 | */ |
1012 | unsigned int supported_formats; |
1013 | |
1014 | /** |
1015 | * @max_bpc: Maximum bits per char the HDMI bridge supports. Allowed |
1016 | * values are 8, 10 and 12. This is only relevant if |
1017 | * @DRM_BRIDGE_OP_HDMI is set. |
1018 | */ |
1019 | unsigned int max_bpc; |
1020 | |
1021 | /** |
1022 | * @hdmi_audio_dev: device to be used as a parent for the HDMI Codec if |
1023 | * either of @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO is set. |
1024 | */ |
1025 | struct device *hdmi_audio_dev; |
1026 | |
1027 | /** |
1028 | * @hdmi_audio_max_i2s_playback_channels: maximum number of playback |
1029 | * I2S channels for the @DRM_BRIDGE_OP_HDMI_AUDIO or |
1030 | * @DRM_BRIDGE_OP_DP_AUDIO. |
1031 | */ |
1032 | int hdmi_audio_max_i2s_playback_channels; |
1033 | |
1034 | /** |
1035 | * @hdmi_audio_spdif_playback: set if this bridge has S/PDIF playback |
1036 | * port for @DRM_BRIDGE_OP_HDMI_AUDIO or @DRM_BRIDGE_OP_DP_AUDIO. |
1037 | */ |
1038 | unsigned int hdmi_audio_spdif_playback : 1; |
1039 | |
1040 | /** |
1041 | * @hdmi_audio_dai_port: sound DAI port for either of |
1042 | * @DRM_BRIDGE_OP_HDMI_AUDIO and @DRM_BRIDGE_OP_DP_AUDIO, -1 if it is |
1043 | * not used. |
1044 | */ |
1045 | int hdmi_audio_dai_port; |
1046 | }; |
1047 | |
1048 | static inline struct drm_bridge * |
1049 | drm_priv_to_bridge(struct drm_private_obj *priv) |
1050 | { |
1051 | return container_of(priv, struct drm_bridge, base); |
1052 | } |
1053 | |
1054 | struct drm_bridge *drm_bridge_get(struct drm_bridge *bridge); |
1055 | void drm_bridge_put(struct drm_bridge *bridge); |
1056 | |
1057 | void *__devm_drm_bridge_alloc(struct device *dev, size_t size, size_t offset, |
1058 | const struct drm_bridge_funcs *funcs); |
1059 | |
1060 | /** |
1061 | * devm_drm_bridge_alloc - Allocate and initialize a bridge |
1062 | * @dev: struct device of the bridge device |
1063 | * @type: the type of the struct which contains struct &drm_bridge |
1064 | * @member: the name of the &drm_bridge within @type |
1065 | * @funcs: callbacks for this bridge |
1066 | * |
1067 | * The reference count of the returned bridge is initialized to 1. This |
1068 | * reference will be automatically dropped via devm (by calling |
1069 | * drm_bridge_put()) when @dev is removed. |
1070 | * |
1071 | * Returns: |
1072 | * Pointer to new bridge, or ERR_PTR on failure. |
1073 | */ |
1074 | #define devm_drm_bridge_alloc(dev, type, member, funcs) \ |
1075 | ((type *)__devm_drm_bridge_alloc(dev, sizeof(type), \ |
1076 | offsetof(type, member), funcs)) |
1077 | |
1078 | void drm_bridge_add(struct drm_bridge *bridge); |
1079 | int devm_drm_bridge_add(struct device *dev, struct drm_bridge *bridge); |
1080 | void drm_bridge_remove(struct drm_bridge *bridge); |
1081 | int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, |
1082 | struct drm_bridge *previous, |
1083 | enum drm_bridge_attach_flags flags); |
1084 | |
1085 | #ifdef CONFIG_OF |
1086 | struct drm_bridge *of_drm_find_bridge(struct device_node *np); |
1087 | #else |
1088 | static inline struct drm_bridge *of_drm_find_bridge(struct device_node *np) |
1089 | { |
1090 | return NULL; |
1091 | } |
1092 | #endif |
1093 | |
1094 | /** |
1095 | * drm_bridge_get_current_state() - Get the current bridge state |
1096 | * @bridge: bridge object |
1097 | * |
1098 | * This function must be called with the modeset lock held. |
1099 | * |
1100 | * RETURNS: |
1101 | * |
1102 | * The current bridge state, or NULL if there is none. |
1103 | */ |
1104 | static inline struct drm_bridge_state * |
1105 | drm_bridge_get_current_state(struct drm_bridge *bridge) |
1106 | { |
1107 | if (!bridge) |
1108 | return NULL; |
1109 | |
1110 | /* |
1111 | * Only atomic bridges will have bridge->base initialized by |
1112 | * drm_atomic_private_obj_init(), so we need to make sure we're |
1113 | * working with one before we try to use the lock. |
1114 | */ |
1115 | if (!bridge->funcs || !bridge->funcs->atomic_reset) |
1116 | return NULL; |
1117 | |
1118 | drm_modeset_lock_assert_held(lock: &bridge->base.lock); |
1119 | |
1120 | if (!bridge->base.state) |
1121 | return NULL; |
1122 | |
1123 | return drm_priv_to_bridge_state(priv: bridge->base.state); |
1124 | } |
1125 | |
1126 | /** |
1127 | * drm_bridge_get_next_bridge() - Get the next bridge in the chain |
1128 | * @bridge: bridge object |
1129 | * |
1130 | * RETURNS: |
1131 | * the next bridge in the chain after @bridge, or NULL if @bridge is the last. |
1132 | */ |
1133 | static inline struct drm_bridge * |
1134 | drm_bridge_get_next_bridge(struct drm_bridge *bridge) |
1135 | { |
1136 | if (list_is_last(list: &bridge->chain_node, head: &bridge->encoder->bridge_chain)) |
1137 | return NULL; |
1138 | |
1139 | return list_next_entry(bridge, chain_node); |
1140 | } |
1141 | |
1142 | /** |
1143 | * drm_bridge_get_prev_bridge() - Get the previous bridge in the chain |
1144 | * @bridge: bridge object |
1145 | * |
1146 | * RETURNS: |
1147 | * the previous bridge in the chain, or NULL if @bridge is the first. |
1148 | */ |
1149 | static inline struct drm_bridge * |
1150 | drm_bridge_get_prev_bridge(struct drm_bridge *bridge) |
1151 | { |
1152 | if (list_is_first(list: &bridge->chain_node, head: &bridge->encoder->bridge_chain)) |
1153 | return NULL; |
1154 | |
1155 | return list_prev_entry(bridge, chain_node); |
1156 | } |
1157 | |
1158 | /** |
1159 | * drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain |
1160 | * @encoder: encoder object |
1161 | * |
1162 | * RETURNS: |
1163 | * the first bridge in the chain, or NULL if @encoder has no bridge attached |
1164 | * to it. |
1165 | */ |
1166 | static inline struct drm_bridge * |
1167 | drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder) |
1168 | { |
1169 | return list_first_entry_or_null(&encoder->bridge_chain, |
1170 | struct drm_bridge, chain_node); |
1171 | } |
1172 | |
1173 | /** |
1174 | * drm_for_each_bridge_in_chain() - Iterate over all bridges present in a chain |
1175 | * @encoder: the encoder to iterate bridges on |
1176 | * @bridge: a bridge pointer updated to point to the current bridge at each |
1177 | * iteration |
1178 | * |
1179 | * Iterate over all bridges present in the bridge chain attached to @encoder. |
1180 | */ |
1181 | #define drm_for_each_bridge_in_chain(encoder, bridge) \ |
1182 | list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node) |
1183 | |
1184 | enum drm_mode_status |
1185 | drm_bridge_chain_mode_valid(struct drm_bridge *bridge, |
1186 | const struct drm_display_info *info, |
1187 | const struct drm_display_mode *mode); |
1188 | void drm_bridge_chain_mode_set(struct drm_bridge *bridge, |
1189 | const struct drm_display_mode *mode, |
1190 | const struct drm_display_mode *adjusted_mode); |
1191 | |
1192 | int drm_atomic_bridge_chain_check(struct drm_bridge *bridge, |
1193 | struct drm_crtc_state *crtc_state, |
1194 | struct drm_connector_state *conn_state); |
1195 | void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge, |
1196 | struct drm_atomic_state *state); |
1197 | void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge, |
1198 | struct drm_atomic_state *state); |
1199 | void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge, |
1200 | struct drm_atomic_state *state); |
1201 | void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge, |
1202 | struct drm_atomic_state *state); |
1203 | |
1204 | u32 * |
1205 | drm_atomic_helper_bridge_propagate_bus_fmt(struct drm_bridge *bridge, |
1206 | struct drm_bridge_state *bridge_state, |
1207 | struct drm_crtc_state *crtc_state, |
1208 | struct drm_connector_state *conn_state, |
1209 | u32 output_fmt, |
1210 | unsigned int *num_input_fmts); |
1211 | |
1212 | enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge); |
1213 | int drm_bridge_get_modes(struct drm_bridge *bridge, |
1214 | struct drm_connector *connector); |
1215 | const struct drm_edid *drm_bridge_edid_read(struct drm_bridge *bridge, |
1216 | struct drm_connector *connector); |
1217 | void drm_bridge_hpd_enable(struct drm_bridge *bridge, |
1218 | void (*cb)(void *data, |
1219 | enum drm_connector_status status), |
1220 | void *data); |
1221 | void drm_bridge_hpd_disable(struct drm_bridge *bridge); |
1222 | void drm_bridge_hpd_notify(struct drm_bridge *bridge, |
1223 | enum drm_connector_status status); |
1224 | |
1225 | #ifdef CONFIG_DRM_PANEL_BRIDGE |
1226 | bool drm_bridge_is_panel(const struct drm_bridge *bridge); |
1227 | struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel); |
1228 | struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel, |
1229 | u32 connector_type); |
1230 | void drm_panel_bridge_remove(struct drm_bridge *bridge); |
1231 | int drm_panel_bridge_set_orientation(struct drm_connector *connector, |
1232 | struct drm_bridge *bridge); |
1233 | struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, |
1234 | struct drm_panel *panel); |
1235 | struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, |
1236 | struct drm_panel *panel, |
1237 | u32 connector_type); |
1238 | struct drm_bridge *drmm_panel_bridge_add(struct drm_device *drm, |
1239 | struct drm_panel *panel); |
1240 | struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge); |
1241 | #else |
1242 | static inline bool drm_bridge_is_panel(const struct drm_bridge *bridge) |
1243 | { |
1244 | return false; |
1245 | } |
1246 | |
1247 | static inline int drm_panel_bridge_set_orientation(struct drm_connector *connector, |
1248 | struct drm_bridge *bridge) |
1249 | { |
1250 | return -EINVAL; |
1251 | } |
1252 | #endif |
1253 | |
1254 | #if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL_BRIDGE) |
1255 | struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node, |
1256 | u32 port, u32 endpoint); |
1257 | struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, struct device_node *node, |
1258 | u32 port, u32 endpoint); |
1259 | #else |
1260 | static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, |
1261 | struct device_node *node, |
1262 | u32 port, |
1263 | u32 endpoint) |
1264 | { |
1265 | return ERR_PTR(-ENODEV); |
1266 | } |
1267 | |
1268 | static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, |
1269 | struct device_node *node, |
1270 | u32 port, |
1271 | u32 endpoint) |
1272 | { |
1273 | return ERR_PTR(-ENODEV); |
1274 | } |
1275 | #endif |
1276 | |
1277 | void drm_bridge_debugfs_params(struct dentry *root); |
1278 | void drm_bridge_debugfs_encoder_params(struct dentry *root, struct drm_encoder *encoder); |
1279 | |
1280 | #endif |
1281 | |