aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-26 10:57:41 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-12-17 14:23:22 -0500
commitd9b13620fa09d2652008f96e083592c772532fd1 (patch)
tree418292e212afc0e8242e27097955d7cc6fbb68eb
parent4b08eae52f2f73723dbc4dd4d251eb60a7d8c0e1 (diff)
drm/atomic-helper: Export both plane and modeset check helpers
The default call sequence for these two parts won't fit for all drivers. So export the two pieces and explain with a bit of kerneldoc when each should be called. v2: Squash in fixup from Rob to actually add the newly exported functions to headers Cc: Rob Clark <robdclark@gmail.com> Reviewed-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c65
-rw-r--r--include/drm/drm_atomic_helper.h4
-rw-r--r--include/drm/drm_crtc.h8
3 files changed, 69 insertions, 8 deletions
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index bbdbe4721573..0cd71dac394e 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -330,7 +330,29 @@ mode_fixup(struct drm_atomic_state *state)
330 return 0; 330 return 0;
331} 331}
332 332
333static int 333/**
334 * drm_atomic_helper_check - validate state object for modeset changes
335 * @dev: DRM device
336 * @state: the driver state object
337 *
338 * Check the state object to see if the requested state is physically possible.
339 * This does all the crtc and connector related computations for an atomic
340 * update. It computes and updates crtc_state->mode_changed, adds any additional
341 * connectors needed for full modesets and calls down into ->mode_fixup
342 * functions of the driver backend.
343 *
344 * IMPORTANT:
345 *
346 * Drivers which update ->mode_changed (e.g. in their ->atomic_check hooks if a
347 * plane update can't be done without a full modeset) _must_ call this function
348 * afterwards after that change. It is permitted to call this function multiple
349 * times for the same update, e.g. when the ->atomic_check functions depend upon
350 * the adjusted dotclock for fifo space allocation and watermark computation.
351 *
352 * RETURNS
353 * Zero for success or -errno
354 */
355int
334drm_atomic_helper_check_modeset(struct drm_device *dev, 356drm_atomic_helper_check_modeset(struct drm_device *dev,
335 struct drm_atomic_state *state) 357 struct drm_atomic_state *state)
336{ 358{
@@ -406,23 +428,23 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
406 428
407 return mode_fixup(state); 429 return mode_fixup(state);
408} 430}
431EXPORT_SYMBOL(drm_atomic_helper_check_modeset);
409 432
410/** 433/**
411 * drm_atomic_helper_check - validate state object 434 * drm_atomic_helper_check - validate state object for modeset changes
412 * @dev: DRM device 435 * @dev: DRM device
413 * @state: the driver state object 436 * @state: the driver state object
414 * 437 *
415 * Check the state object to see if the requested state is physically possible. 438 * Check the state object to see if the requested state is physically possible.
416 * Only crtcs and planes have check callbacks, so for any additional (global) 439 * This does all the plane update related checks using by calling into the
417 * checking that a driver needs it can simply wrap that around this function. 440 * ->atomic_check hooks provided by the driver.
418 * Drivers without such needs can directly use this as their ->atomic_check()
419 * callback.
420 * 441 *
421 * RETURNS 442 * RETURNS
422 * Zero for success or -errno 443 * Zero for success or -errno
423 */ 444 */
424int drm_atomic_helper_check(struct drm_device *dev, 445int
425 struct drm_atomic_state *state) 446drm_atomic_helper_check_planes(struct drm_device *dev,
447 struct drm_atomic_state *state)
426{ 448{
427 int nplanes = dev->mode_config.num_total_plane; 449 int nplanes = dev->mode_config.num_total_plane;
428 int ncrtcs = dev->mode_config.num_crtc; 450 int ncrtcs = dev->mode_config.num_crtc;
@@ -471,6 +493,33 @@ int drm_atomic_helper_check(struct drm_device *dev,
471 } 493 }
472 } 494 }
473 495
496 return ret;
497}
498EXPORT_SYMBOL(drm_atomic_helper_check_planes);
499
500/**
501 * drm_atomic_helper_check - validate state object
502 * @dev: DRM device
503 * @state: the driver state object
504 *
505 * Check the state object to see if the requested state is physically possible.
506 * Only crtcs and planes have check callbacks, so for any additional (global)
507 * checking that a driver needs it can simply wrap that around this function.
508 * Drivers without such needs can directly use this as their ->atomic_check()
509 * callback.
510 *
511 * RETURNS
512 * Zero for success or -errno
513 */
514int drm_atomic_helper_check(struct drm_device *dev,
515 struct drm_atomic_state *state)
516{
517 int ret;
518
519 ret = drm_atomic_helper_check_planes(dev, state);
520 if (ret)
521 return ret;
522
474 ret = drm_atomic_helper_check_modeset(dev, state); 523 ret = drm_atomic_helper_check_modeset(dev, state);
475 if (ret) 524 if (ret)
476 return ret; 525 return ret;
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index f956b413311e..2095917ff8c7 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -30,6 +30,10 @@
30 30
31#include <drm/drm_crtc.h> 31#include <drm/drm_crtc.h>
32 32
33int drm_atomic_helper_check_modeset(struct drm_device *dev,
34 struct drm_atomic_state *state);
35int drm_atomic_helper_check_planes(struct drm_device *dev,
36 struct drm_atomic_state *state);
33int drm_atomic_helper_check(struct drm_device *dev, 37int drm_atomic_helper_check(struct drm_device *dev,
34 struct drm_atomic_state *state); 38 struct drm_atomic_state *state);
35int drm_atomic_helper_commit(struct drm_device *dev, 39int drm_atomic_helper_commit(struct drm_device *dev,
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b86329813ad3..4ee78212f8bf 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -238,6 +238,7 @@ struct drm_atomic_state;
238/** 238/**
239 * struct drm_crtc_state - mutable CRTC state 239 * struct drm_crtc_state - mutable CRTC state
240 * @enable: whether the CRTC should be enabled, gates all other state 240 * @enable: whether the CRTC should be enabled, gates all other state
241 * @active: whether the CRTC is actively displaying (used for DPMS)
241 * @mode_changed: for use by helpers and drivers when computing state updates 242 * @mode_changed: for use by helpers and drivers when computing state updates
242 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes 243 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
243 * @last_vblank_count: for helpers and drivers to capture the vblank of the 244 * @last_vblank_count: for helpers and drivers to capture the vblank of the
@@ -248,9 +249,16 @@ struct drm_atomic_state;
248 * @event: optional pointer to a DRM event to signal upon completion of the 249 * @event: optional pointer to a DRM event to signal upon completion of the
249 * state update 250 * state update
250 * @state: backpointer to global drm_atomic_state 251 * @state: backpointer to global drm_atomic_state
252 *
253 * Note that the distinction between @enable and @active is rather subtile:
254 * Flipping @active while @enable is set without changing anything else may
255 * never return in a failure from the ->atomic_check callback. Userspace assumes
256 * that a DPMS On will always succeed. In other words: @enable controls resource
257 * assignment, @active controls the actual hardware state.
251 */ 258 */
252struct drm_crtc_state { 259struct drm_crtc_state {
253 bool enable; 260 bool enable;
261 bool active;
254 262
255 /* computed state bits used by helpers and drivers */ 263 /* computed state bits used by helpers and drivers */
256 bool planes_changed : 1; 264 bool planes_changed : 1;