diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-10-27 15:28:44 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-11-05 11:23:26 -0500 |
commit | 144ecb97cd57d2a61cc455730a3337e413499cae (patch) | |
tree | d5567b71fd6faaf3b72337b8649b07fd0516a6eb /include/drm/drm_crtc.h | |
parent | b7a1aafda61c27d54230ce7c8a4806a749ecf2f3 (diff) |
drm: Add atomic driver interface definitions for objects
Heavily based upon Rob Clark's atomic series.
- Dropped the connector state from the crtc state, instead opting for a
full-blown connector state. The only thing it has is the desired
crtc, but drivers which have connector properties have now a
data-structure to subclass.
- Rename create_state to duplicate_state. Especially for legacy ioctls
we want updates on top of existing state, so we need a way to get at
the current state. We need to be careful to clear the backpointers
to the global state correctly though.
- Drop property values. Drivers with properties simply need to
subclass the datastructures and track the decoded values in there. I
also think that common properties (like rotation) should be decoded
and stored in the core structures.
- Create a new set of ->atomic_set_prop functions, for smoother
transitions from legacy to atomic operations.
- Pass the ->atomic_set_prop ioctl the right structure to avoid
chasing pointers in drivers.
- Drop temporary boolean state for now until we resurrect them with
the helper functions.
- Drop invert_dimensions. For now we don't need any checking since
that's done by the higher-level legacy ioctls. But even then we
should also add rotation/flip tracking to the core drm_crtc_state,
not just whether the dimensions are inverted.
- Track crtc state with an enable/disable. That's equivalent to
mode_valid, but a bit clearer that it means the entire crtc.
The global interface will follow in subsequent patches.
v2: We need to allow drivers to somehow set up the initial state and
clear it on resume. So add a plane->reset callback for that. Helpers
will be provided with default behaviour for all these.
v3: Split out the plane->reset into a separate patch.
v4: Improve kerneldoc in drm_crtc.h
v5: Remove unused inline functions for handling state objects, those
callbacks are now mandatory for full atomic support.
v6: Fix commit message nit Sean noticed.
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'include/drm/drm_crtc.h')
-rw-r--r-- | include/drm/drm_crtc.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 125bb7f290a1..3554868dbf09 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -224,6 +224,25 @@ struct drm_encoder; | |||
224 | struct drm_pending_vblank_event; | 224 | struct drm_pending_vblank_event; |
225 | struct drm_plane; | 225 | struct drm_plane; |
226 | struct drm_bridge; | 226 | struct drm_bridge; |
227 | struct drm_atomic_state; | ||
228 | |||
229 | /** | ||
230 | * struct drm_crtc_state - mutable crtc state | ||
231 | * @enable: whether the CRTC should be enabled, gates all other state | ||
232 | * @mode: current mode timings | ||
233 | * @event: optional pointer to a DRM event to signal upon completion of the | ||
234 | * state update | ||
235 | * @state: backpointer to global drm_atomic_state | ||
236 | */ | ||
237 | struct drm_crtc_state { | ||
238 | bool enable : 1; | ||
239 | |||
240 | struct drm_display_mode mode; | ||
241 | |||
242 | struct drm_pending_vblank_event *event; | ||
243 | |||
244 | struct drm_atomic_state *state; | ||
245 | }; | ||
227 | 246 | ||
228 | /** | 247 | /** |
229 | * struct drm_crtc_funcs - control CRTCs for a given device | 248 | * struct drm_crtc_funcs - control CRTCs for a given device |
@@ -238,6 +257,9 @@ struct drm_bridge; | |||
238 | * @set_property: called when a property is changed | 257 | * @set_property: called when a property is changed |
239 | * @set_config: apply a new CRTC configuration | 258 | * @set_config: apply a new CRTC configuration |
240 | * @page_flip: initiate a page flip | 259 | * @page_flip: initiate a page flip |
260 | * @atomic_duplicate_state: duplicate the atomic state for this CRTC | ||
261 | * @atomic_destroy_state: destroy an atomic state for this CRTC | ||
262 | * @atomic_set_property: set a property on an atomic state for this CRTC | ||
241 | * | 263 | * |
242 | * The drm_crtc_funcs structure is the central CRTC management structure | 264 | * The drm_crtc_funcs structure is the central CRTC management structure |
243 | * in the DRM. Each CRTC controls one or more connectors (note that the name | 265 | * in the DRM. Each CRTC controls one or more connectors (note that the name |
@@ -288,6 +310,15 @@ struct drm_crtc_funcs { | |||
288 | 310 | ||
289 | int (*set_property)(struct drm_crtc *crtc, | 311 | int (*set_property)(struct drm_crtc *crtc, |
290 | struct drm_property *property, uint64_t val); | 312 | struct drm_property *property, uint64_t val); |
313 | |||
314 | /* atomic update handling */ | ||
315 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); | ||
316 | void (*atomic_destroy_state)(struct drm_crtc *crtc, | ||
317 | struct drm_crtc_state *cstate); | ||
318 | int (*atomic_set_property)(struct drm_crtc *crtc, | ||
319 | struct drm_crtc_state *state, | ||
320 | struct drm_property *property, | ||
321 | uint64_t val); | ||
291 | }; | 322 | }; |
292 | 323 | ||
293 | /** | 324 | /** |
@@ -317,6 +348,7 @@ struct drm_crtc_funcs { | |||
317 | * @pixeldur_ns: precise pixel timing | 348 | * @pixeldur_ns: precise pixel timing |
318 | * @helper_private: mid-layer private data | 349 | * @helper_private: mid-layer private data |
319 | * @properties: property tracking for this CRTC | 350 | * @properties: property tracking for this CRTC |
351 | * @state: current atomic state for this CRTC | ||
320 | * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for | 352 | * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for |
321 | * legacy ioctls | 353 | * legacy ioctls |
322 | * | 354 | * |
@@ -374,6 +406,8 @@ struct drm_crtc { | |||
374 | 406 | ||
375 | struct drm_object_properties properties; | 407 | struct drm_object_properties properties; |
376 | 408 | ||
409 | struct drm_crtc_state *state; | ||
410 | |||
377 | /* | 411 | /* |
378 | * For legacy crtc ioctls so that atomic drivers can get at the locking | 412 | * For legacy crtc ioctls so that atomic drivers can get at the locking |
379 | * acquire context. | 413 | * acquire context. |
@@ -381,6 +415,16 @@ struct drm_crtc { | |||
381 | struct drm_modeset_acquire_ctx *acquire_ctx; | 415 | struct drm_modeset_acquire_ctx *acquire_ctx; |
382 | }; | 416 | }; |
383 | 417 | ||
418 | /** | ||
419 | * struct drm_connector_state - mutable connector state | ||
420 | * @crtc: crtc to connect connector to, NULL if disabled | ||
421 | * @state: backpointer to global drm_atomic_state | ||
422 | */ | ||
423 | struct drm_connector_state { | ||
424 | struct drm_crtc *crtc; | ||
425 | |||
426 | struct drm_atomic_state *state; | ||
427 | }; | ||
384 | 428 | ||
385 | /** | 429 | /** |
386 | * struct drm_connector_funcs - control connectors on a given device | 430 | * struct drm_connector_funcs - control connectors on a given device |
@@ -393,6 +437,10 @@ struct drm_crtc { | |||
393 | * @set_property: property for this connector may need an update | 437 | * @set_property: property for this connector may need an update |
394 | * @destroy: make object go away | 438 | * @destroy: make object go away |
395 | * @force: notify the driver that the connector is forced on | 439 | * @force: notify the driver that the connector is forced on |
440 | * @atomic_duplicate_state: duplicate the atomic state for this connector | ||
441 | * @atomic_destroy_state: destroy an atomic state for this connector | ||
442 | * @atomic_set_property: set a property on an atomic state for this connector | ||
443 | * | ||
396 | * | 444 | * |
397 | * Each CRTC may have one or more connectors attached to it. The functions | 445 | * Each CRTC may have one or more connectors attached to it. The functions |
398 | * below allow the core DRM code to control connectors, enumerate available modes, | 446 | * below allow the core DRM code to control connectors, enumerate available modes, |
@@ -417,6 +465,15 @@ struct drm_connector_funcs { | |||
417 | uint64_t val); | 465 | uint64_t val); |
418 | void (*destroy)(struct drm_connector *connector); | 466 | void (*destroy)(struct drm_connector *connector); |
419 | void (*force)(struct drm_connector *connector); | 467 | void (*force)(struct drm_connector *connector); |
468 | |||
469 | /* atomic update handling */ | ||
470 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); | ||
471 | void (*atomic_destroy_state)(struct drm_connector *connector, | ||
472 | struct drm_connector_state *cstate); | ||
473 | int (*atomic_set_property)(struct drm_connector *connector, | ||
474 | struct drm_connector_state *state, | ||
475 | struct drm_property *property, | ||
476 | uint64_t val); | ||
420 | }; | 477 | }; |
421 | 478 | ||
422 | /** | 479 | /** |
@@ -515,6 +572,7 @@ struct drm_encoder { | |||
515 | * @null_edid_counter: track sinks that give us all zeros for the EDID | 572 | * @null_edid_counter: track sinks that give us all zeros for the EDID |
516 | * @bad_edid_counter: track sinks that give us an EDID with invalid checksum | 573 | * @bad_edid_counter: track sinks that give us an EDID with invalid checksum |
517 | * @debugfs_entry: debugfs directory for this connector | 574 | * @debugfs_entry: debugfs directory for this connector |
575 | * @state: current atomic state for this connector | ||
518 | * | 576 | * |
519 | * Each connector may be connected to one or more CRTCs, or may be clonable by | 577 | * Each connector may be connected to one or more CRTCs, or may be clonable by |
520 | * another connector if they can share a CRTC. Each connector also has a specific | 578 | * another connector if they can share a CRTC. Each connector also has a specific |
@@ -575,8 +633,42 @@ struct drm_connector { | |||
575 | unsigned bad_edid_counter; | 633 | unsigned bad_edid_counter; |
576 | 634 | ||
577 | struct dentry *debugfs_entry; | 635 | struct dentry *debugfs_entry; |
636 | |||
637 | struct drm_connector_state *state; | ||
638 | }; | ||
639 | |||
640 | /** | ||
641 | * struct drm_plane_state - mutable plane state | ||
642 | * @crtc: currently bound CRTC, NULL if disabled | ||
643 | * @fb: currently bound fb | ||
644 | * @crtc_x: left position of visible portion of plane on crtc | ||
645 | * @crtc_y: upper position of visible portion of plane on crtc | ||
646 | * @crtc_w: width of visible portion of plane on crtc | ||
647 | * @crtc_h: height of visible portion of plane on crtc | ||
648 | * @src_x: left position of visible portion of plane within | ||
649 | * plane (in 16.16) | ||
650 | * @src_y: upper position of visible portion of plane within | ||
651 | * plane (in 16.16) | ||
652 | * @src_w: width of visible portion of plane (in 16.16) | ||
653 | * @src_h: height of visible portion of plane (in 16.16) | ||
654 | * @state: backpointer to global drm_atomic_state | ||
655 | */ | ||
656 | struct drm_plane_state { | ||
657 | struct drm_crtc *crtc; | ||
658 | struct drm_framebuffer *fb; | ||
659 | |||
660 | /* Signed dest location allows it to be partially off screen */ | ||
661 | int32_t crtc_x, crtc_y; | ||
662 | uint32_t crtc_w, crtc_h; | ||
663 | |||
664 | /* Source values are 16.16 fixed point */ | ||
665 | uint32_t src_x, src_y; | ||
666 | uint32_t src_h, src_w; | ||
667 | |||
668 | struct drm_atomic_state *state; | ||
578 | }; | 669 | }; |
579 | 670 | ||
671 | |||
580 | /** | 672 | /** |
581 | * struct drm_plane_funcs - driver plane control functions | 673 | * struct drm_plane_funcs - driver plane control functions |
582 | * @update_plane: update the plane configuration | 674 | * @update_plane: update the plane configuration |
@@ -584,6 +676,9 @@ struct drm_connector { | |||
584 | * @destroy: clean up plane resources | 676 | * @destroy: clean up plane resources |
585 | * @reset: reset plane after state has been invalidated (e.g. resume) | 677 | * @reset: reset plane after state has been invalidated (e.g. resume) |
586 | * @set_property: called when a property is changed | 678 | * @set_property: called when a property is changed |
679 | * @atomic_duplicate_state: duplicate the atomic state for this plane | ||
680 | * @atomic_destroy_state: destroy an atomic state for this plane | ||
681 | * @atomic_set_property: set a property on an atomic state for this plane | ||
587 | */ | 682 | */ |
588 | struct drm_plane_funcs { | 683 | struct drm_plane_funcs { |
589 | int (*update_plane)(struct drm_plane *plane, | 684 | int (*update_plane)(struct drm_plane *plane, |
@@ -598,6 +693,15 @@ struct drm_plane_funcs { | |||
598 | 693 | ||
599 | int (*set_property)(struct drm_plane *plane, | 694 | int (*set_property)(struct drm_plane *plane, |
600 | struct drm_property *property, uint64_t val); | 695 | struct drm_property *property, uint64_t val); |
696 | |||
697 | /* atomic update handling */ | ||
698 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); | ||
699 | void (*atomic_destroy_state)(struct drm_plane *plane, | ||
700 | struct drm_plane_state *cstate); | ||
701 | int (*atomic_set_property)(struct drm_plane *plane, | ||
702 | struct drm_plane_state *state, | ||
703 | struct drm_property *property, | ||
704 | uint64_t val); | ||
601 | }; | 705 | }; |
602 | 706 | ||
603 | enum drm_plane_type { | 707 | enum drm_plane_type { |
@@ -621,6 +725,7 @@ enum drm_plane_type { | |||
621 | * @funcs: helper functions | 725 | * @funcs: helper functions |
622 | * @properties: property tracking for this plane | 726 | * @properties: property tracking for this plane |
623 | * @type: type of plane (overlay, primary, cursor) | 727 | * @type: type of plane (overlay, primary, cursor) |
728 | * @state: current atomic state for this plane | ||
624 | */ | 729 | */ |
625 | struct drm_plane { | 730 | struct drm_plane { |
626 | struct drm_device *dev; | 731 | struct drm_device *dev; |
@@ -642,6 +747,8 @@ struct drm_plane { | |||
642 | struct drm_object_properties properties; | 747 | struct drm_object_properties properties; |
643 | 748 | ||
644 | enum drm_plane_type type; | 749 | enum drm_plane_type type; |
750 | |||
751 | struct drm_plane_state *state; | ||
645 | }; | 752 | }; |
646 | 753 | ||
647 | /** | 754 | /** |