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