diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-12-04 03:46:08 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-12-09 03:29:42 -0500 |
commit | 36b66080dc66ab08ff6c36237147638e2d060874 (patch) | |
tree | d6a72e90c392074101b78ff90526d5242fb84ace | |
parent | 30ecad77fe849b60c9a1f8df24dca50e3f083d41 (diff) |
drm: Document drm_encoder/crtc_helper_funcs
Mostly this is about all the callbacks used for modesets by both legacy
CRTC helpers and atomic helpers and I figured it doesn't make all that
much sense to split this up.
v2: Suggestions from Thierry.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1449218769-16577-28-git-send-email-daniel.vetter@ffwll.ch
Reviewed-by: Thierry Reding <treding@nvidia.com>
-rw-r--r-- | include/drm/drm_modeset_helper_vtables.h | 449 |
1 files changed, 401 insertions, 48 deletions
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index 4b3869bd49b5..29e0dc50031d 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h | |||
@@ -51,58 +51,236 @@ enum mode_set_atomic; | |||
51 | 51 | ||
52 | /** | 52 | /** |
53 | * struct drm_crtc_helper_funcs - helper operations for CRTCs | 53 | * struct drm_crtc_helper_funcs - helper operations for CRTCs |
54 | * @dpms: set power state | ||
55 | * @prepare: prepare the CRTC, called before @mode_set | ||
56 | * @commit: commit changes to CRTC, called after @mode_set | ||
57 | * @mode_fixup: try to fixup proposed mode for this CRTC | ||
58 | * @mode_set: set this mode | ||
59 | * @mode_set_nofb: set mode only (no scanout buffer attached) | ||
60 | * @mode_set_base: update the scanout buffer | ||
61 | * @mode_set_base_atomic: non-blocking mode set (used for kgdb support) | ||
62 | * @load_lut: load color palette | ||
63 | * @disable: disable CRTC when no longer in use | ||
64 | * @enable: enable CRTC | ||
65 | * | 54 | * |
66 | * The helper operations are called by the mid-layer CRTC helper. | 55 | * These hooks are used by the legacy CRTC helpers, the transitional plane |
67 | * | 56 | * helpers and the new atomic modesetting helpers. |
68 | * Note that with atomic helpers @dpms, @prepare and @commit hooks are | ||
69 | * deprecated. Used @enable and @disable instead exclusively. | ||
70 | * | ||
71 | * With legacy crtc helpers there's a big semantic difference between @disable | ||
72 | * and the other hooks: @disable also needs to release any resources acquired in | ||
73 | * @mode_set (like shared PLLs). | ||
74 | */ | 57 | */ |
75 | struct drm_crtc_helper_funcs { | 58 | struct drm_crtc_helper_funcs { |
76 | /* | 59 | /** |
77 | * Control power levels on the CRTC. If the mode passed in is | 60 | * @dpms: |
78 | * unsupported, the provider must use the next lowest power level. | 61 | * |
62 | * Callback to control power levels on the CRTC. If the mode passed in | ||
63 | * is unsupported, the provider must use the next lowest power level. | ||
64 | * This is used by the legacy CRTC helpers to implement DPMS | ||
65 | * functionality in drm_helper_connector_dpms(). | ||
66 | * | ||
67 | * This callback is also used to disable a CRTC by calling it with | ||
68 | * DRM_MODE_DPMS_OFF if the @disable hook isn't used. | ||
69 | * | ||
70 | * This callback is used by the legacy CRTC helpers. Atomic helpers | ||
71 | * also support using this hook for enabling and disabling a CRTC to | ||
72 | * facilitate transitions to atomic, but it is deprecated. Instead | ||
73 | * @enable and @disable should be used. | ||
79 | */ | 74 | */ |
80 | void (*dpms)(struct drm_crtc *crtc, int mode); | 75 | void (*dpms)(struct drm_crtc *crtc, int mode); |
76 | |||
77 | /** | ||
78 | * @prepare: | ||
79 | * | ||
80 | * This callback should prepare the CRTC for a subsequent modeset, which | ||
81 | * in practice means the driver should disable the CRTC if it is | ||
82 | * running. Most drivers ended up implementing this by calling their | ||
83 | * @dpms hook with DRM_MODE_DPMS_OFF. | ||
84 | * | ||
85 | * This callback is used by the legacy CRTC helpers. Atomic helpers | ||
86 | * also support using this hook for disabling a CRTC to facilitate | ||
87 | * transitions to atomic, but it is deprecated. Instead @disable should | ||
88 | * be used. | ||
89 | */ | ||
81 | void (*prepare)(struct drm_crtc *crtc); | 90 | void (*prepare)(struct drm_crtc *crtc); |
91 | |||
92 | /** | ||
93 | * @commit: | ||
94 | * | ||
95 | * This callback should commit the new mode on the CRTC after a modeset, | ||
96 | * which in practice means the driver should enable the CRTC. Most | ||
97 | * drivers ended up implementing this by calling their @dpms hook with | ||
98 | * DRM_MODE_DPMS_ON. | ||
99 | * | ||
100 | * This callback is used by the legacy CRTC helpers. Atomic helpers | ||
101 | * also support using this hook for enabling a CRTC to facilitate | ||
102 | * transitions to atomic, but it is deprecated. Instead @enable should | ||
103 | * be used. | ||
104 | */ | ||
82 | void (*commit)(struct drm_crtc *crtc); | 105 | void (*commit)(struct drm_crtc *crtc); |
83 | 106 | ||
84 | /* Provider can fixup or change mode timings before modeset occurs */ | 107 | /** |
108 | * @mode_fixup: | ||
109 | * | ||
110 | * This callback is used to validate a mode. The parameter mode is the | ||
111 | * display mode that userspace requested, adjusted_mode is the mode the | ||
112 | * encoders need to be fed with. Note that this is the inverse semantics | ||
113 | * of the meaning for the &drm_encoder and &drm_bridge | ||
114 | * ->mode_fixup() functions. If the CRTC cannot support the requested | ||
115 | * conversion from mode to adjusted_mode it should reject the modeset. | ||
116 | * | ||
117 | * This function is used by both legacy CRTC helpers and atomic helpers. | ||
118 | * With atomic helpers it is optional. | ||
119 | * | ||
120 | * NOTE: | ||
121 | * | ||
122 | * This function is called in the check phase of atomic modesets, which | ||
123 | * can be aborted for any reason (including on userspace's request to | ||
124 | * just check whether a configuration would be possible). Atomic drivers | ||
125 | * MUST NOT touch any persistent state (hardware or software) or data | ||
126 | * structures except the passed in adjusted_mode parameter. | ||
127 | * | ||
128 | * This is in contrast to the legacy CRTC helpers where this was | ||
129 | * allowed. | ||
130 | * | ||
131 | * Atomic drivers which need to inspect and adjust more state should | ||
132 | * instead use the @atomic_check callback. | ||
133 | * | ||
134 | * RETURNS: | ||
135 | * | ||
136 | * True if an acceptable configuration is possible, false if the modeset | ||
137 | * operation should be rejected. | ||
138 | */ | ||
85 | bool (*mode_fixup)(struct drm_crtc *crtc, | 139 | bool (*mode_fixup)(struct drm_crtc *crtc, |
86 | const struct drm_display_mode *mode, | 140 | const struct drm_display_mode *mode, |
87 | struct drm_display_mode *adjusted_mode); | 141 | struct drm_display_mode *adjusted_mode); |
88 | /* Actually set the mode */ | 142 | |
143 | /** | ||
144 | * @mode_set: | ||
145 | * | ||
146 | * This callback is used by the legacy CRTC helpers to set a new mode, | ||
147 | * position and framebuffer. Since it ties the primary plane to every | ||
148 | * mode change it is incompatible with universal plane support. And | ||
149 | * since it can't update other planes it's incompatible with atomic | ||
150 | * modeset support. | ||
151 | * | ||
152 | * This callback is only used by CRTC helpers and deprecated. | ||
153 | * | ||
154 | * RETURNS: | ||
155 | * | ||
156 | * 0 on success or a negative error code on failure. | ||
157 | */ | ||
89 | int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, | 158 | int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, |
90 | struct drm_display_mode *adjusted_mode, int x, int y, | 159 | struct drm_display_mode *adjusted_mode, int x, int y, |
91 | struct drm_framebuffer *old_fb); | 160 | struct drm_framebuffer *old_fb); |
92 | /* Actually set the mode for atomic helpers, optional */ | 161 | |
162 | /** | ||
163 | * @mode_set_nofb: | ||
164 | * | ||
165 | * This callback is used to update the display mode of a CRTC without | ||
166 | * changing anything of the primary plane configuration. This fits the | ||
167 | * requirement of atomic and hence is used by the atomic helpers. It is | ||
168 | * also used by the transitional plane helpers to implement a | ||
169 | * @mode_set hook in drm_helper_crtc_mode_set(). | ||
170 | * | ||
171 | * Note that the display pipe is completely off when this function is | ||
172 | * called. Atomic drivers which need hardware to be running before they | ||
173 | * program the new display mode (e.g. because they implement runtime PM) | ||
174 | * should not use this hook. This is because the helper library calls | ||
175 | * this hook only once per mode change and not every time the display | ||
176 | * pipeline is suspended using either DPMS or the new "ACTIVE" property. | ||
177 | * Which means register values set in this callback might get reset when | ||
178 | * the CRTC is suspended, but not restored. Such drivers should instead | ||
179 | * move all their CRTC setup into the @enable callback. | ||
180 | * | ||
181 | * This callback is optional. | ||
182 | */ | ||
93 | void (*mode_set_nofb)(struct drm_crtc *crtc); | 183 | void (*mode_set_nofb)(struct drm_crtc *crtc); |
94 | 184 | ||
95 | /* Move the crtc on the current fb to the given position *optional* */ | 185 | /** |
186 | * @mode_set_base: | ||
187 | * | ||
188 | * This callback is used by the legacy CRTC helpers to set a new | ||
189 | * framebuffer and scanout position. It is optional and used as an | ||
190 | * optimized fast-path instead of a full mode set operation with all the | ||
191 | * resulting flickering. Since it can't update other planes it's | ||
192 | * incompatible with atomic modeset support. | ||
193 | * | ||
194 | * This callback is only used by the CRTC helpers and deprecated. | ||
195 | * | ||
196 | * RETURNS: | ||
197 | * | ||
198 | * 0 on success or a negative error code on failure. | ||
199 | */ | ||
96 | int (*mode_set_base)(struct drm_crtc *crtc, int x, int y, | 200 | int (*mode_set_base)(struct drm_crtc *crtc, int x, int y, |
97 | struct drm_framebuffer *old_fb); | 201 | struct drm_framebuffer *old_fb); |
202 | |||
203 | /** | ||
204 | * @mode_set_base_atomic: | ||
205 | * | ||
206 | * This callback is used by the fbdev helpers to set a new framebuffer | ||
207 | * and scanout without sleeping, i.e. from an atomic calling context. It | ||
208 | * is only used to implement kgdb support. | ||
209 | * | ||
210 | * This callback is optional and only needed for kgdb support in the fbdev | ||
211 | * helpers. | ||
212 | * | ||
213 | * RETURNS: | ||
214 | * | ||
215 | * 0 on success or a negative error code on failure. | ||
216 | */ | ||
98 | int (*mode_set_base_atomic)(struct drm_crtc *crtc, | 217 | int (*mode_set_base_atomic)(struct drm_crtc *crtc, |
99 | struct drm_framebuffer *fb, int x, int y, | 218 | struct drm_framebuffer *fb, int x, int y, |
100 | enum mode_set_atomic); | 219 | enum mode_set_atomic); |
101 | 220 | ||
102 | /* reload the current crtc LUT */ | 221 | /** |
222 | * @load_lut: | ||
223 | * | ||
224 | * Load a LUT prepared with the @gamma_set functions from | ||
225 | * &drm_fb_helper_funcs. | ||
226 | * | ||
227 | * This callback is optional and is only used by the fbdev emulation | ||
228 | * helpers. | ||
229 | * | ||
230 | * FIXME: | ||
231 | * | ||
232 | * This callback is functionally redundant with the core gamma table | ||
233 | * support and simply exists because the fbdev hasn't yet been | ||
234 | * refactored to use the core gamma table interfaces. | ||
235 | */ | ||
103 | void (*load_lut)(struct drm_crtc *crtc); | 236 | void (*load_lut)(struct drm_crtc *crtc); |
104 | 237 | ||
238 | /** | ||
239 | * @disable: | ||
240 | * | ||
241 | * This callback should be used to disable the CRTC. With the atomic | ||
242 | * drivers it is called after all encoders connected to this CRTC have | ||
243 | * been shut off already using their own ->disable hook. If that | ||
244 | * sequence is too simple drivers can just add their own hooks and call | ||
245 | * it from this CRTC callback here by looping over all encoders | ||
246 | * connected to it using for_each_encoder_on_crtc(). | ||
247 | * | ||
248 | * This hook is used both by legacy CRTC helpers and atomic helpers. | ||
249 | * Atomic drivers don't need to implement it if there's no need to | ||
250 | * disable anything at the CRTC level. To ensure that runtime PM | ||
251 | * handling (using either DPMS or the new "ACTIVE" property) works | ||
252 | * @disable must be the inverse of @enable for atomic drivers. | ||
253 | * | ||
254 | * NOTE: | ||
255 | * | ||
256 | * With legacy CRTC helpers there's a big semantic difference between | ||
257 | * @disable and other hooks (like @prepare or @dpms) used to shut down a | ||
258 | * CRTC: @disable is only called when also logically disabling the | ||
259 | * display pipeline and needs to release any resources acquired in | ||
260 | * @mode_set (like shared PLLs, or again release pinned framebuffers). | ||
261 | * | ||
262 | * Therefore @disable must be the inverse of @mode_set plus @commit for | ||
263 | * drivers still using legacy CRTC helpers, which is different from the | ||
264 | * rules under atomic. | ||
265 | */ | ||
105 | void (*disable)(struct drm_crtc *crtc); | 266 | void (*disable)(struct drm_crtc *crtc); |
267 | |||
268 | /** | ||
269 | * @enable: | ||
270 | * | ||
271 | * This callback should be used to enable the CRTC. With the atomic | ||
272 | * drivers it is called before all encoders connected to this CRTC are | ||
273 | * enabled through the encoder's own ->enable hook. If that sequence is | ||
274 | * too simple drivers can just add their own hooks and call it from this | ||
275 | * CRTC callback here by looping over all encoders connected to it using | ||
276 | * for_each_encoder_on_crtc(). | ||
277 | * | ||
278 | * This hook is used only by atomic helpers, for symmetry with @disable. | ||
279 | * Atomic drivers don't need to implement it if there's no need to | ||
280 | * enable anything at the CRTC level. To ensure that runtime PM handling | ||
281 | * (using either DPMS or the new "ACTIVE" property) works | ||
282 | * @enable must be the inverse of @disable for atomic drivers. | ||
283 | */ | ||
106 | void (*enable)(struct drm_crtc *crtc); | 284 | void (*enable)(struct drm_crtc *crtc); |
107 | 285 | ||
108 | /** | 286 | /** |
@@ -212,53 +390,228 @@ static inline void drm_crtc_helper_add(struct drm_crtc *crtc, | |||
212 | 390 | ||
213 | /** | 391 | /** |
214 | * struct drm_encoder_helper_funcs - helper operations for encoders | 392 | * struct drm_encoder_helper_funcs - helper operations for encoders |
215 | * @dpms: set power state | ||
216 | * @mode_fixup: try to fixup proposed mode for this connector | ||
217 | * @prepare: part of the disable sequence, called before the CRTC modeset | ||
218 | * @commit: called after the CRTC modeset | ||
219 | * @mode_set: set this mode, optional for atomic helpers | ||
220 | * @get_crtc: return CRTC that the encoder is currently attached to | ||
221 | * @detect: connection status detection | ||
222 | * @disable: disable encoder when not in use (overrides DPMS off) | ||
223 | * @enable: enable encoder | ||
224 | * @atomic_check: check for validity of an atomic update | ||
225 | * | ||
226 | * The helper operations are called by the mid-layer CRTC helper. | ||
227 | * | 393 | * |
228 | * Note that with atomic helpers @dpms, @prepare and @commit hooks are | 394 | * These hooks are used by the legacy CRTC helpers, the transitional plane |
229 | * deprecated. Used @enable and @disable instead exclusively. | 395 | * helpers and the new atomic modesetting helpers. |
230 | * | ||
231 | * With legacy crtc helpers there's a big semantic difference between @disable | ||
232 | * and the other hooks: @disable also needs to release any resources acquired in | ||
233 | * @mode_set (like shared PLLs). | ||
234 | */ | 396 | */ |
235 | struct drm_encoder_helper_funcs { | 397 | struct drm_encoder_helper_funcs { |
398 | /** | ||
399 | * @dpms: | ||
400 | * | ||
401 | * Callback to control power levels on the encoder. If the mode passed in | ||
402 | * is unsupported, the provider must use the next lowest power level. | ||
403 | * This is used by the legacy encoder helpers to implement DPMS | ||
404 | * functionality in drm_helper_connector_dpms(). | ||
405 | * | ||
406 | * This callback is also used to disable an encoder by calling it with | ||
407 | * DRM_MODE_DPMS_OFF if the @disable hook isn't used. | ||
408 | * | ||
409 | * This callback is used by the legacy CRTC helpers. Atomic helpers | ||
410 | * also support using this hook for enabling and disabling an encoder to | ||
411 | * facilitate transitions to atomic, but it is deprecated. Instead | ||
412 | * @enable and @disable should be used. | ||
413 | */ | ||
236 | void (*dpms)(struct drm_encoder *encoder, int mode); | 414 | void (*dpms)(struct drm_encoder *encoder, int mode); |
237 | 415 | ||
416 | /** | ||
417 | * @mode_fixup: | ||
418 | * | ||
419 | * This callback is used to validate and adjust a mode. The parameter | ||
420 | * mode is the display mode that should be fed to the next element in | ||
421 | * the display chain, either the final &drm_connector or a &drm_bridge. | ||
422 | * The parameter adjusted_mode is the input mode the encoder requires. It | ||
423 | * can be modified by this callback and does not need to match mode. | ||
424 | * | ||
425 | * This function is used by both legacy CRTC helpers and atomic helpers. | ||
426 | * With atomic helpers it is optional. | ||
427 | * | ||
428 | * NOTE: | ||
429 | * | ||
430 | * This function is called in the check phase of atomic modesets, which | ||
431 | * can be aborted for any reason (including on userspace's request to | ||
432 | * just check whether a configuration would be possible). Atomic drivers | ||
433 | * MUST NOT touch any persistent state (hardware or software) or data | ||
434 | * structures except the passed in adjusted_mode parameter. | ||
435 | * | ||
436 | * This is in contrast to the legacy CRTC helpers where this was | ||
437 | * allowed. | ||
438 | * | ||
439 | * Atomic drivers which need to inspect and adjust more state should | ||
440 | * instead use the @atomic_check callback. | ||
441 | * | ||
442 | * RETURNS: | ||
443 | * | ||
444 | * True if an acceptable configuration is possible, false if the modeset | ||
445 | * operation should be rejected. | ||
446 | */ | ||
238 | bool (*mode_fixup)(struct drm_encoder *encoder, | 447 | bool (*mode_fixup)(struct drm_encoder *encoder, |
239 | const struct drm_display_mode *mode, | 448 | const struct drm_display_mode *mode, |
240 | struct drm_display_mode *adjusted_mode); | 449 | struct drm_display_mode *adjusted_mode); |
450 | |||
451 | /** | ||
452 | * @prepare: | ||
453 | * | ||
454 | * This callback should prepare the encoder for a subsequent modeset, | ||
455 | * which in practice means the driver should disable the encoder if it | ||
456 | * is running. Most drivers ended up implementing this by calling their | ||
457 | * @dpms hook with DRM_MODE_DPMS_OFF. | ||
458 | * | ||
459 | * This callback is used by the legacy CRTC helpers. Atomic helpers | ||
460 | * also support using this hook for disabling an encoder to facilitate | ||
461 | * transitions to atomic, but it is deprecated. Instead @disable should | ||
462 | * be used. | ||
463 | */ | ||
241 | void (*prepare)(struct drm_encoder *encoder); | 464 | void (*prepare)(struct drm_encoder *encoder); |
465 | |||
466 | /** | ||
467 | * @commit: | ||
468 | * | ||
469 | * This callback should commit the new mode on the encoder after a modeset, | ||
470 | * which in practice means the driver should enable the encoder. Most | ||
471 | * drivers ended up implementing this by calling their @dpms hook with | ||
472 | * DRM_MODE_DPMS_ON. | ||
473 | * | ||
474 | * This callback is used by the legacy CRTC helpers. Atomic helpers | ||
475 | * also support using this hook for enabling an encoder to facilitate | ||
476 | * transitions to atomic, but it is deprecated. Instead @enable should | ||
477 | * be used. | ||
478 | */ | ||
242 | void (*commit)(struct drm_encoder *encoder); | 479 | void (*commit)(struct drm_encoder *encoder); |
480 | |||
481 | /** | ||
482 | * @mode_set: | ||
483 | * | ||
484 | * This callback is used to update the display mode of an encoder. | ||
485 | * | ||
486 | * Note that the display pipe is completely off when this function is | ||
487 | * called. Drivers which need hardware to be running before they program | ||
488 | * the new display mode (because they implement runtime PM) should not | ||
489 | * use this hook, because the helper library calls it only once and not | ||
490 | * every time the display pipeline is suspend using either DPMS or the | ||
491 | * new "ACTIVE" property. Such drivers should instead move all their | ||
492 | * encoder setup into the ->enable() callback. | ||
493 | * | ||
494 | * This callback is used both by the legacy CRTC helpers and the atomic | ||
495 | * modeset helpers. It is optional in the atomic helpers. | ||
496 | */ | ||
243 | void (*mode_set)(struct drm_encoder *encoder, | 497 | void (*mode_set)(struct drm_encoder *encoder, |
244 | struct drm_display_mode *mode, | 498 | struct drm_display_mode *mode, |
245 | struct drm_display_mode *adjusted_mode); | 499 | struct drm_display_mode *adjusted_mode); |
500 | |||
501 | /** | ||
502 | * @get_crtc: | ||
503 | * | ||
504 | * This callback is used by the legacy CRTC helpers to work around | ||
505 | * deficiencies in its own book-keeping. | ||
506 | * | ||
507 | * Do not use, use atomic helpers instead, which get the book keeping | ||
508 | * right. | ||
509 | * | ||
510 | * FIXME: | ||
511 | * | ||
512 | * Currently only nouveau is using this, and as soon as nouveau is | ||
513 | * atomic we can ditch this hook. | ||
514 | */ | ||
246 | struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder); | 515 | struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder); |
247 | /* detect for DAC style encoders */ | 516 | |
517 | /** | ||
518 | * @detect: | ||
519 | * | ||
520 | * This callback can be used by drivers who want to do detection on the | ||
521 | * encoder object instead of in connector functions. | ||
522 | * | ||
523 | * It is not used by any helper and therefore has purely driver-specific | ||
524 | * semantics. New drivers shouldn't use this and instead just implement | ||
525 | * their own private callbacks. | ||
526 | * | ||
527 | * FIXME: | ||
528 | * | ||
529 | * This should just be converted into a pile of driver vfuncs. | ||
530 | * Currently radeon, amdgpu and nouveau are using it. | ||
531 | */ | ||
248 | enum drm_connector_status (*detect)(struct drm_encoder *encoder, | 532 | enum drm_connector_status (*detect)(struct drm_encoder *encoder, |
249 | struct drm_connector *connector); | 533 | struct drm_connector *connector); |
534 | |||
535 | /** | ||
536 | * @disable: | ||
537 | * | ||
538 | * This callback should be used to disable the encoder. With the atomic | ||
539 | * drivers it is called before this encoder's CRTC has been shut off | ||
540 | * using the CRTC's own ->disable hook. If that sequence is too simple | ||
541 | * drivers can just add their own driver private encoder hooks and call | ||
542 | * them from CRTC's callback by looping over all encoders connected to | ||
543 | * it using for_each_encoder_on_crtc(). | ||
544 | * | ||
545 | * This hook is used both by legacy CRTC helpers and atomic helpers. | ||
546 | * Atomic drivers don't need to implement it if there's no need to | ||
547 | * disable anything at the encoder level. To ensure that runtime PM | ||
548 | * handling (using either DPMS or the new "ACTIVE" property) works | ||
549 | * @disable must be the inverse of @enable for atomic drivers. | ||
550 | * | ||
551 | * NOTE: | ||
552 | * | ||
553 | * With legacy CRTC helpers there's a big semantic difference between | ||
554 | * @disable and other hooks (like @prepare or @dpms) used to shut down a | ||
555 | * encoder: @disable is only called when also logically disabling the | ||
556 | * display pipeline and needs to release any resources acquired in | ||
557 | * @mode_set (like shared PLLs, or again release pinned framebuffers). | ||
558 | * | ||
559 | * Therefore @disable must be the inverse of @mode_set plus @commit for | ||
560 | * drivers still using legacy CRTC helpers, which is different from the | ||
561 | * rules under atomic. | ||
562 | */ | ||
250 | void (*disable)(struct drm_encoder *encoder); | 563 | void (*disable)(struct drm_encoder *encoder); |
251 | 564 | ||
565 | /** | ||
566 | * @enable: | ||
567 | * | ||
568 | * This callback should be used to enable the encoder. With the atomic | ||
569 | * drivers it is called after this encoder's CRTC has been enabled using | ||
570 | * the CRTC's own ->enable hook. If that sequence is too simple drivers | ||
571 | * can just add their own driver private encoder hooks and call them | ||
572 | * from CRTC's callback by looping over all encoders connected to it | ||
573 | * using for_each_encoder_on_crtc(). | ||
574 | * | ||
575 | * This hook is used only by atomic helpers, for symmetry with @disable. | ||
576 | * Atomic drivers don't need to implement it if there's no need to | ||
577 | * enable anything at the encoder level. To ensure that runtime PM handling | ||
578 | * (using either DPMS or the new "ACTIVE" property) works | ||
579 | * @enable must be the inverse of @disable for atomic drivers. | ||
580 | */ | ||
252 | void (*enable)(struct drm_encoder *encoder); | 581 | void (*enable)(struct drm_encoder *encoder); |
253 | 582 | ||
254 | /* atomic helpers */ | 583 | /** |
584 | * @atomic_check: | ||
585 | * | ||
586 | * This callback is used to validate encoder state for atomic drivers. | ||
587 | * Since the encoder is the object connecting the CRTC and connector it | ||
588 | * gets passed both states, to be able to validate interactions and | ||
589 | * update the CRTC to match what the encoder needs for the requested | ||
590 | * connector. | ||
591 | * | ||
592 | * This function is used by the atomic helpers, but it is optional. | ||
593 | * | ||
594 | * NOTE: | ||
595 | * | ||
596 | * This function is called in the check phase of an atomic update. The | ||
597 | * driver is not allowed to change anything outside of the free-standing | ||
598 | * state objects passed-in or assembled in the overall &drm_atomic_state | ||
599 | * update tracking structure. | ||
600 | * | ||
601 | * RETURNS: | ||
602 | * | ||
603 | * 0 on success, -EINVAL if the state or the transition can't be | ||
604 | * supported, -ENOMEM on memory allocation failure and -EDEADLK if an | ||
605 | * attempt to obtain another state object ran into a &drm_modeset_lock | ||
606 | * deadlock. | ||
607 | */ | ||
255 | int (*atomic_check)(struct drm_encoder *encoder, | 608 | int (*atomic_check)(struct drm_encoder *encoder, |
256 | struct drm_crtc_state *crtc_state, | 609 | struct drm_crtc_state *crtc_state, |
257 | struct drm_connector_state *conn_state); | 610 | struct drm_connector_state *conn_state); |
258 | }; | 611 | }; |
259 | 612 | ||
260 | /** | 613 | /** |
261 | * drm_encoder_helper_add - sets the helper vtable for a encoder | 614 | * drm_encoder_helper_add - sets the helper vtable for an encoder |
262 | * @encoder: DRM encoder | 615 | * @encoder: DRM encoder |
263 | * @funcs: helper vtable to set for @encoder | 616 | * @funcs: helper vtable to set for @encoder |
264 | */ | 617 | */ |