aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2015-12-04 03:46:04 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-12-08 10:13:53 -0500
commit11a0ba972d55dd21d88b62e918d6cf072c9c67af (patch)
tree13f28c1a34421c28e5ad25f0e96efadd3443cee4
parent9953f41799bdad34c367196541a7a9a3b6e13a6c (diff)
drm: Document drm_plane_helper_funcs
Plus related hooks used to do atomic plane updates since they only really make sense as a package. v2: Suggestions from Thierry. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1449218769-16577-24-git-send-email-daniel.vetter@ffwll.ch Reviewed-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--include/drm/drm_modeset_helper_vtables.h210
1 files changed, 199 insertions, 11 deletions
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 56dadfe7a181..c77b7dcf343b 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -62,9 +62,6 @@ enum mode_set_atomic;
62 * @load_lut: load color palette 62 * @load_lut: load color palette
63 * @disable: disable CRTC when no longer in use 63 * @disable: disable CRTC when no longer in use
64 * @enable: enable CRTC 64 * @enable: enable CRTC
65 * @atomic_check: check for validity of an atomic state
66 * @atomic_begin: begin atomic update
67 * @atomic_flush: flush atomic update
68 * 65 *
69 * The helper operations are called by the mid-layer CRTC helper. 66 * The helper operations are called by the mid-layer CRTC helper.
70 * 67 *
@@ -108,11 +105,96 @@ struct drm_crtc_helper_funcs {
108 void (*disable)(struct drm_crtc *crtc); 105 void (*disable)(struct drm_crtc *crtc);
109 void (*enable)(struct drm_crtc *crtc); 106 void (*enable)(struct drm_crtc *crtc);
110 107
111 /* atomic helpers */ 108 /**
109 * @atomic_check:
110 *
111 * Drivers should check plane-update related CRTC constraints in this
112 * hook. They can also check mode related limitations but need to be
113 * aware of the calling order, since this hook is used by
114 * drm_atomic_helper_check_planes() whereas the preparations needed to
115 * check output routing and the display mode is done in
116 * drm_atomic_helper_check_modeset(). Therefore drivers that want to
117 * check output routing and display mode constraints in this callback
118 * must ensure that drm_atomic_helper_check_modeset() has been called
119 * beforehand. This is calling order used by the default helper
120 * implementation in drm_atomic_helper_check().
121 *
122 * When using drm_atomic_helper_check_planes() CRTCs' ->atomic_check()
123 * hooks are called after the ones for planes, which allows drivers to
124 * assign shared resources requested by planes in the CRTC callback
125 * here. For more complicated dependencies the driver can call the provided
126 * check helpers multiple times until the computed state has a final
127 * configuration and everything has been checked.
128 *
129 * This function is also allowed to inspect any other object's state and
130 * can add more state objects to the atomic commit if needed. Care must
131 * be taken though to ensure that state check&compute functions for
132 * these added states are all called, and derived state in other objects
133 * all updated. Again the recommendation is to just call check helpers
134 * until a maximal configuration is reached.
135 *
136 * This callback is used by the atomic modeset helpers and by the
137 * transitional plane helpers, but it is optional.
138 *
139 * NOTE:
140 *
141 * This function is called in the check phase of an atomic update. The
142 * driver is not allowed to change anything outside of the free-standing
143 * state objects passed-in or assembled in the overall &drm_atomic_state
144 * update tracking structure.
145 *
146 * RETURNS:
147 *
148 * 0 on success, -EINVAL if the state or the transition can't be
149 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
150 * attempt to obtain another state object ran into a &drm_modeset_lock
151 * deadlock.
152 */
112 int (*atomic_check)(struct drm_crtc *crtc, 153 int (*atomic_check)(struct drm_crtc *crtc,
113 struct drm_crtc_state *state); 154 struct drm_crtc_state *state);
155
156 /**
157 * @atomic_begin:
158 *
159 * Drivers should prepare for an atomic update of multiple planes on
160 * a CRTC in this hook. Depending upon hardware this might be vblank
161 * evasion, blocking updates by setting bits or doing preparatory work
162 * for e.g. manual update display.
163 *
164 * This hook is called before any plane commit functions are called.
165 *
166 * Note that the power state of the display pipe when this function is
167 * called depends upon the exact helpers and calling sequence the driver
168 * has picked. See drm_atomic_commit_planes() for a discussion of the
169 * tradeoffs and variants of plane commit helpers.
170 *
171 * This callback is used by the atomic modeset helpers and by the
172 * transitional plane helpers, but it is optional.
173 */
114 void (*atomic_begin)(struct drm_crtc *crtc, 174 void (*atomic_begin)(struct drm_crtc *crtc,
115 struct drm_crtc_state *old_crtc_state); 175 struct drm_crtc_state *old_crtc_state);
176 /**
177 * @atomic_flush:
178 *
179 * Drivers should finalize an atomic update of multiple planes on
180 * a CRTC in this hook. Depending upon hardware this might include
181 * checking that vblank evasion was successful, unblocking updates by
182 * setting bits or setting the GO bit to flush out all updates.
183 *
184 * Simple hardware or hardware with special requirements can commit and
185 * flush out all updates for all planes from this hook and forgo all the
186 * other commit hooks for plane updates.
187 *
188 * This hook is called after any plane commit functions are called.
189 *
190 * Note that the power state of the display pipe when this function is
191 * called depends upon the exact helpers and calling sequence the driver
192 * has picked. See drm_atomic_commit_planes() for a discussion of the
193 * tradeoffs and variants of plane commit helpers.
194 *
195 * This callback is used by the atomic modeset helpers and by the
196 * transitional plane helpers, but it is optional.
197 */
116 void (*atomic_flush)(struct drm_crtc *crtc, 198 void (*atomic_flush)(struct drm_crtc *crtc,
117 struct drm_crtc_state *old_crtc_state); 199 struct drm_crtc_state *old_crtc_state);
118}; 200};
@@ -216,25 +298,131 @@ static inline void drm_connector_helper_add(struct drm_connector *connector,
216} 298}
217 299
218/** 300/**
219 * struct drm_plane_helper_funcs - helper operations for CRTCs 301 * struct drm_plane_helper_funcs - helper operations for planes
220 * @prepare_fb: prepare a framebuffer for use by the plane
221 * @cleanup_fb: cleanup a framebuffer when it's no longer used by the plane
222 * @atomic_check: check that a given atomic state is valid and can be applied
223 * @atomic_update: apply an atomic state to the plane (mandatory)
224 * @atomic_disable: disable the plane
225 * 302 *
226 * The helper operations are called by the mid-layer CRTC helper. 303 * These functions are used by the atomic helpers and by the transitional plane
304 * helpers.
227 */ 305 */
228struct drm_plane_helper_funcs { 306struct drm_plane_helper_funcs {
307 /**
308 * @prepare_fb:
309 *
310 * This hook is to prepare a framebuffer for scanout by e.g. pinning
311 * it's backing storage or relocating it into a contiguous block of
312 * VRAM. Other possible preparatory work includes flushing caches.
313 *
314 * This function must not block for outstanding rendering, since it is
315 * called in the context of the atomic IOCTL even for async commits to
316 * be able to return any errors to userspace. Instead the recommended
317 * way is to fill out the fence member of the passed-in
318 * &drm_plane_state. If the driver doesn't support native fences then
319 * equivalent functionality should be implemented through private
320 * members in the plane structure.
321 *
322 * The helpers will call @cleanup_fb with matching arguments for every
323 * successful call to this hook.
324 *
325 * This callback is used by the atomic modeset helpers and by the
326 * transitional plane helpers, but it is optional.
327 *
328 * RETURNS:
329 *
330 * 0 on success or one of the following negative error codes allowed by
331 * the atomic_commit hook in &drm_mode_config_funcs. When using helpers
332 * this callback is the only one which can fail an atomic commit,
333 * everything else must complete successfully.
334 */
229 int (*prepare_fb)(struct drm_plane *plane, 335 int (*prepare_fb)(struct drm_plane *plane,
230 const struct drm_plane_state *new_state); 336 const struct drm_plane_state *new_state);
337 /**
338 * @cleanup_fb:
339 *
340 * This hook is called to clean up any resources allocated for the given
341 * framebuffer and plane configuration in @prepare_fb.
342 *
343 * This callback is used by the atomic modeset helpers and by the
344 * transitional plane helpers, but it is optional.
345 */
231 void (*cleanup_fb)(struct drm_plane *plane, 346 void (*cleanup_fb)(struct drm_plane *plane,
232 const struct drm_plane_state *old_state); 347 const struct drm_plane_state *old_state);
233 348
349 /**
350 * @atomic_check:
351 *
352 * Drivers should check plane specific constraints in this hook.
353 *
354 * When using drm_atomic_helper_check_planes() plane's ->atomic_check()
355 * hooks are called before the ones for CRTCs, which allows drivers to
356 * request shared resources that the CRTC controls here. For more
357 * complicated dependencies the driver can call the provided check helpers
358 * multiple times until the computed state has a final configuration and
359 * everything has been checked.
360 *
361 * This function is also allowed to inspect any other object's state and
362 * can add more state objects to the atomic commit if needed. Care must
363 * be taken though to ensure that state check&compute functions for
364 * these added states are all called, and derived state in other objects
365 * all updated. Again the recommendation is to just call check helpers
366 * until a maximal configuration is reached.
367 *
368 * This callback is used by the atomic modeset helpers and by the
369 * transitional plane helpers, but it is optional.
370 *
371 * NOTE:
372 *
373 * This function is called in the check phase of an atomic update. The
374 * driver is not allowed to change anything outside of the free-standing
375 * state objects passed-in or assembled in the overall &drm_atomic_state
376 * update tracking structure.
377 *
378 * RETURNS:
379 *
380 * 0 on success, -EINVAL if the state or the transition can't be
381 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
382 * attempt to obtain another state object ran into a &drm_modeset_lock
383 * deadlock.
384 */
234 int (*atomic_check)(struct drm_plane *plane, 385 int (*atomic_check)(struct drm_plane *plane,
235 struct drm_plane_state *state); 386 struct drm_plane_state *state);
387
388 /**
389 * @atomic_update:
390 *
391 * Drivers should use this function to update the plane state. This
392 * hook is called in-between the ->atomic_begin() and
393 * ->atomic_flush() of &drm_crtc_helper_funcs.
394 *
395 * Note that the power state of the display pipe when this function is
396 * called depends upon the exact helpers and calling sequence the driver
397 * has picked. See drm_atomic_commit_planes() for a discussion of the
398 * tradeoffs and variants of plane commit helpers.
399 *
400 * This callback is used by the atomic modeset helpers and by the
401 * transitional plane helpers, but it is optional.
402 */
236 void (*atomic_update)(struct drm_plane *plane, 403 void (*atomic_update)(struct drm_plane *plane,
237 struct drm_plane_state *old_state); 404 struct drm_plane_state *old_state);
405 /**
406 * @atomic_disable:
407 *
408 * Drivers should use this function to unconditionally disable a plane.
409 * This hook is called in-between the ->atomic_begin() and
410 * ->atomic_flush() of &drm_crtc_helper_funcs. It is an alternative to
411 * @atomic_update, which will be called for disabling planes, too, if
412 * the @atomic_disable hook isn't implemented.
413 *
414 * This hook is also useful to disable planes in preparation of a modeset,
415 * by calling drm_atomic_helper_disable_planes_on_crtc() from the
416 * ->disable() hook in &drm_crtc_helper_funcs.
417 *
418 * Note that the power state of the display pipe when this function is
419 * called depends upon the exact helpers and calling sequence the driver
420 * has picked. See drm_atomic_commit_planes() for a discussion of the
421 * tradeoffs and variants of plane commit helpers.
422 *
423 * This callback is used by the atomic modeset helpers and by the
424 * transitional plane helpers, but it is optional.
425 */
238 void (*atomic_disable)(struct drm_plane *plane, 426 void (*atomic_disable)(struct drm_plane *plane,
239 struct drm_plane_state *old_state); 427 struct drm_plane_state *old_state);
240}; 428};