Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+107
+107
include/drm/drm_crtc.h
··· 224 224 struct drm_pending_vblank_event; 225 225 struct drm_plane; 226 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 248 * struct drm_crtc_funcs - control CRTCs for a given device ··· 257 238 * @set_property: called when a property is changed 258 239 * @set_config: apply a new CRTC configuration 259 240 * @page_flip: initiate a page flip 241 + * @atomic_duplicate_state: duplicate the atomic state for this CRTC 242 + * @atomic_destroy_state: destroy an atomic state for this CRTC 243 + * @atomic_set_property: set a property on an atomic state for this CRTC 260 244 * 261 245 * The drm_crtc_funcs structure is the central CRTC management structure 262 246 * in the DRM. Each CRTC controls one or more connectors (note that the name ··· 310 288 311 289 int (*set_property)(struct drm_crtc *crtc, 312 290 struct drm_property *property, uint64_t val); 291 + 292 + /* atomic update handling */ 293 + struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); 294 + void (*atomic_destroy_state)(struct drm_crtc *crtc, 295 + struct drm_crtc_state *cstate); 296 + int (*atomic_set_property)(struct drm_crtc *crtc, 297 + struct drm_crtc_state *state, 298 + struct drm_property *property, 299 + uint64_t val); 313 300 }; 314 301 315 302 /** ··· 348 317 * @pixeldur_ns: precise pixel timing 349 318 * @helper_private: mid-layer private data 350 319 * @properties: property tracking for this CRTC 320 + * @state: current atomic state for this CRTC 351 321 * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for 352 322 * legacy ioctls 353 323 * ··· 406 374 407 375 struct drm_object_properties properties; 408 376 377 + struct drm_crtc_state *state; 378 + 409 379 /* 410 380 * For legacy crtc ioctls so that atomic drivers can get at the locking 411 381 * acquire context. ··· 415 381 struct drm_modeset_acquire_ctx *acquire_ctx; 416 382 }; 417 383 384 + /** 385 + * struct drm_connector_state - mutable connector state 386 + * @crtc: crtc to connect connector to, NULL if disabled 387 + * @state: backpointer to global drm_atomic_state 388 + */ 389 + struct drm_connector_state { 390 + struct drm_crtc *crtc; 391 + 392 + struct drm_atomic_state *state; 393 + }; 418 394 419 395 /** 420 396 * struct drm_connector_funcs - control connectors on a given device ··· 437 393 * @set_property: property for this connector may need an update 438 394 * @destroy: make object go away 439 395 * @force: notify the driver that the connector is forced on 396 + * @atomic_duplicate_state: duplicate the atomic state for this connector 397 + * @atomic_destroy_state: destroy an atomic state for this connector 398 + * @atomic_set_property: set a property on an atomic state for this connector 399 + * 440 400 * 441 401 * Each CRTC may have one or more connectors attached to it. The functions 442 402 * below allow the core DRM code to control connectors, enumerate available modes, ··· 465 417 uint64_t val); 466 418 void (*destroy)(struct drm_connector *connector); 467 419 void (*force)(struct drm_connector *connector); 420 + 421 + /* atomic update handling */ 422 + struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); 423 + void (*atomic_destroy_state)(struct drm_connector *connector, 424 + struct drm_connector_state *cstate); 425 + int (*atomic_set_property)(struct drm_connector *connector, 426 + struct drm_connector_state *state, 427 + struct drm_property *property, 428 + uint64_t val); 468 429 }; 469 430 470 431 /** ··· 572 515 * @null_edid_counter: track sinks that give us all zeros for the EDID 573 516 * @bad_edid_counter: track sinks that give us an EDID with invalid checksum 574 517 * @debugfs_entry: debugfs directory for this connector 518 + * @state: current atomic state for this connector 575 519 * 576 520 * Each connector may be connected to one or more CRTCs, or may be clonable by 577 521 * another connector if they can share a CRTC. Each connector also has a specific ··· 633 575 unsigned bad_edid_counter; 634 576 635 577 struct dentry *debugfs_entry; 578 + 579 + struct drm_connector_state *state; 636 580 }; 581 + 582 + /** 583 + * struct drm_plane_state - mutable plane state 584 + * @crtc: currently bound CRTC, NULL if disabled 585 + * @fb: currently bound fb 586 + * @crtc_x: left position of visible portion of plane on crtc 587 + * @crtc_y: upper position of visible portion of plane on crtc 588 + * @crtc_w: width of visible portion of plane on crtc 589 + * @crtc_h: height of visible portion of plane on crtc 590 + * @src_x: left position of visible portion of plane within 591 + * plane (in 16.16) 592 + * @src_y: upper position of visible portion of plane within 593 + * plane (in 16.16) 594 + * @src_w: width of visible portion of plane (in 16.16) 595 + * @src_h: height of visible portion of plane (in 16.16) 596 + * @state: backpointer to global drm_atomic_state 597 + */ 598 + struct drm_plane_state { 599 + struct drm_crtc *crtc; 600 + struct drm_framebuffer *fb; 601 + 602 + /* Signed dest location allows it to be partially off screen */ 603 + int32_t crtc_x, crtc_y; 604 + uint32_t crtc_w, crtc_h; 605 + 606 + /* Source values are 16.16 fixed point */ 607 + uint32_t src_x, src_y; 608 + uint32_t src_h, src_w; 609 + 610 + struct drm_atomic_state *state; 611 + }; 612 + 637 613 638 614 /** 639 615 * struct drm_plane_funcs - driver plane control functions ··· 676 584 * @destroy: clean up plane resources 677 585 * @reset: reset plane after state has been invalidated (e.g. resume) 678 586 * @set_property: called when a property is changed 587 + * @atomic_duplicate_state: duplicate the atomic state for this plane 588 + * @atomic_destroy_state: destroy an atomic state for this plane 589 + * @atomic_set_property: set a property on an atomic state for this plane 679 590 */ 680 591 struct drm_plane_funcs { 681 592 int (*update_plane)(struct drm_plane *plane, ··· 693 598 694 599 int (*set_property)(struct drm_plane *plane, 695 600 struct drm_property *property, uint64_t val); 601 + 602 + /* atomic update handling */ 603 + struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); 604 + void (*atomic_destroy_state)(struct drm_plane *plane, 605 + struct drm_plane_state *cstate); 606 + int (*atomic_set_property)(struct drm_plane *plane, 607 + struct drm_plane_state *state, 608 + struct drm_property *property, 609 + uint64_t val); 696 610 }; 697 611 698 612 enum drm_plane_type { ··· 725 621 * @funcs: helper functions 726 622 * @properties: property tracking for this plane 727 623 * @type: type of plane (overlay, primary, cursor) 624 + * @state: current atomic state for this plane 728 625 */ 729 626 struct drm_plane { 730 627 struct drm_device *dev; ··· 747 642 struct drm_object_properties properties; 748 643 749 644 enum drm_plane_type type; 645 + 646 + struct drm_plane_state *state; 750 647 }; 751 648 752 649 /**