aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/drm/drmP.h4
-rw-r--r--include/drm/drm_atomic.h13
-rw-r--r--include/drm/drm_atomic_helper.h4
-rw-r--r--include/drm/drm_crtc.h70
-rw-r--r--include/uapi/drm/drm.h8
-rw-r--r--include/uapi/drm/drm_mode.h30
6 files changed, 123 insertions, 6 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index a5f6a1f563c4..e928625a9da0 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -143,6 +143,7 @@ void drm_err(const char *format, ...);
143#define DRIVER_MODESET 0x2000 143#define DRIVER_MODESET 0x2000
144#define DRIVER_PRIME 0x4000 144#define DRIVER_PRIME 0x4000
145#define DRIVER_RENDER 0x8000 145#define DRIVER_RENDER 0x8000
146#define DRIVER_ATOMIC 0x10000
146 147
147/***********************************************************************/ 148/***********************************************************************/
148/** \name Macros to make printk easier */ 149/** \name Macros to make printk easier */
@@ -283,6 +284,8 @@ struct drm_file {
283 * in the plane list 284 * in the plane list
284 */ 285 */
285 unsigned universal_planes:1; 286 unsigned universal_planes:1;
287 /* true if client understands atomic properties */
288 unsigned atomic:1;
286 289
287 struct pid *pid; 290 struct pid *pid;
288 kuid_t uid; 291 kuid_t uid;
@@ -954,6 +957,7 @@ extern void drm_master_put(struct drm_master **master);
954extern void drm_put_dev(struct drm_device *dev); 957extern void drm_put_dev(struct drm_device *dev);
955extern void drm_unplug_dev(struct drm_device *dev); 958extern void drm_unplug_dev(struct drm_device *dev);
956extern unsigned int drm_debug; 959extern unsigned int drm_debug;
960extern bool drm_atomic;
957 961
958 /* Debugfs support */ 962 /* Debugfs support */
959#if defined(CONFIG_DEBUG_FS) 963#if defined(CONFIG_DEBUG_FS)
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index ad2229574dd9..51168a8b723a 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -38,16 +38,25 @@ void drm_atomic_state_free(struct drm_atomic_state *state);
38struct drm_crtc_state * __must_check 38struct drm_crtc_state * __must_check
39drm_atomic_get_crtc_state(struct drm_atomic_state *state, 39drm_atomic_get_crtc_state(struct drm_atomic_state *state,
40 struct drm_crtc *crtc); 40 struct drm_crtc *crtc);
41int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
42 struct drm_crtc_state *state, struct drm_property *property,
43 uint64_t val);
41struct drm_plane_state * __must_check 44struct drm_plane_state * __must_check
42drm_atomic_get_plane_state(struct drm_atomic_state *state, 45drm_atomic_get_plane_state(struct drm_atomic_state *state,
43 struct drm_plane *plane); 46 struct drm_plane *plane);
47int drm_atomic_plane_set_property(struct drm_plane *plane,
48 struct drm_plane_state *state, struct drm_property *property,
49 uint64_t val);
44struct drm_connector_state * __must_check 50struct drm_connector_state * __must_check
45drm_atomic_get_connector_state(struct drm_atomic_state *state, 51drm_atomic_get_connector_state(struct drm_atomic_state *state,
46 struct drm_connector *connector); 52 struct drm_connector *connector);
53int drm_atomic_connector_set_property(struct drm_connector *connector,
54 struct drm_connector_state *state, struct drm_property *property,
55 uint64_t val);
47 56
48int __must_check 57int __must_check
49drm_atomic_set_crtc_for_plane(struct drm_atomic_state *state, 58drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
50 struct drm_plane *plane, struct drm_crtc *crtc); 59 struct drm_crtc *crtc);
51void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state, 60void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
52 struct drm_framebuffer *fb); 61 struct drm_framebuffer *fb);
53int __must_check 62int __must_check
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 291239f2fafc..6588bffb6518 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -63,8 +63,16 @@ struct drm_mode_object {
63 63
64#define DRM_OBJECT_MAX_PROPERTY 24 64#define DRM_OBJECT_MAX_PROPERTY 24
65struct drm_object_properties { 65struct drm_object_properties {
66 int count; 66 int count, atomic_count;
67 uint32_t ids[DRM_OBJECT_MAX_PROPERTY]; 67 /* NOTE: if we ever start dynamically destroying properties (ie.
68 * not at drm_mode_config_cleanup() time), then we'd have to do
69 * a better job of detaching property from mode objects to avoid
70 * dangling property pointers:
71 */
72 struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY];
73 /* do not read/write values directly, but use drm_object_property_get_value()
74 * and drm_object_property_set_value():
75 */
68 uint64_t values[DRM_OBJECT_MAX_PROPERTY]; 76 uint64_t values[DRM_OBJECT_MAX_PROPERTY];
69}; 77};
70 78
@@ -237,7 +245,9 @@ struct drm_atomic_state;
237 245
238/** 246/**
239 * struct drm_crtc_state - mutable CRTC state 247 * struct drm_crtc_state - mutable CRTC state
248 * @crtc: backpointer to the CRTC
240 * @enable: whether the CRTC should be enabled, gates all other state 249 * @enable: whether the CRTC should be enabled, gates all other state
250 * @active: whether the CRTC is actively displaying (used for DPMS)
241 * @mode_changed: for use by helpers and drivers when computing state updates 251 * @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 252 * @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 253 * @last_vblank_count: for helpers and drivers to capture the vblank of the
@@ -248,9 +258,18 @@ struct drm_atomic_state;
248 * @event: optional pointer to a DRM event to signal upon completion of the 258 * @event: optional pointer to a DRM event to signal upon completion of the
249 * state update 259 * state update
250 * @state: backpointer to global drm_atomic_state 260 * @state: backpointer to global drm_atomic_state
261 *
262 * Note that the distinction between @enable and @active is rather subtile:
263 * Flipping @active while @enable is set without changing anything else may
264 * never return in a failure from the ->atomic_check callback. Userspace assumes
265 * that a DPMS On will always succeed. In other words: @enable controls resource
266 * assignment, @active controls the actual hardware state.
251 */ 267 */
252struct drm_crtc_state { 268struct drm_crtc_state {
269 struct drm_crtc *crtc;
270
253 bool enable; 271 bool enable;
272 bool active;
254 273
255 /* computed state bits used by helpers and drivers */ 274 /* computed state bits used by helpers and drivers */
256 bool planes_changed : 1; 275 bool planes_changed : 1;
@@ -292,6 +311,9 @@ struct drm_crtc_state {
292 * @atomic_duplicate_state: duplicate the atomic state for this CRTC 311 * @atomic_duplicate_state: duplicate the atomic state for this CRTC
293 * @atomic_destroy_state: destroy an atomic state for this CRTC 312 * @atomic_destroy_state: destroy an atomic state for this CRTC
294 * @atomic_set_property: set a property on an atomic state for this CRTC 313 * @atomic_set_property: set a property on an atomic state for this CRTC
314 * (do not call directly, use drm_atomic_crtc_set_property())
315 * @atomic_get_property: get a property on an atomic state for this CRTC
316 * (do not call directly, use drm_atomic_crtc_get_property())
295 * 317 *
296 * The drm_crtc_funcs structure is the central CRTC management structure 318 * The drm_crtc_funcs structure is the central CRTC management structure
297 * in the DRM. Each CRTC controls one or more connectors (note that the name 319 * in the DRM. Each CRTC controls one or more connectors (note that the name
@@ -351,6 +373,10 @@ struct drm_crtc_funcs {
351 struct drm_crtc_state *state, 373 struct drm_crtc_state *state,
352 struct drm_property *property, 374 struct drm_property *property,
353 uint64_t val); 375 uint64_t val);
376 int (*atomic_get_property)(struct drm_crtc *crtc,
377 const struct drm_crtc_state *state,
378 struct drm_property *property,
379 uint64_t *val);
354}; 380};
355 381
356/** 382/**
@@ -449,11 +475,14 @@ struct drm_crtc {
449 475
450/** 476/**
451 * struct drm_connector_state - mutable connector state 477 * struct drm_connector_state - mutable connector state
478 * @connector: backpointer to the connector
452 * @crtc: CRTC to connect connector to, NULL if disabled 479 * @crtc: CRTC to connect connector to, NULL if disabled
453 * @best_encoder: can be used by helpers and drivers to select the encoder 480 * @best_encoder: can be used by helpers and drivers to select the encoder
454 * @state: backpointer to global drm_atomic_state 481 * @state: backpointer to global drm_atomic_state
455 */ 482 */
456struct drm_connector_state { 483struct drm_connector_state {
484 struct drm_connector *connector;
485
457 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ 486 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */
458 487
459 struct drm_encoder *best_encoder; 488 struct drm_encoder *best_encoder;
@@ -475,6 +504,9 @@ struct drm_connector_state {
475 * @atomic_duplicate_state: duplicate the atomic state for this connector 504 * @atomic_duplicate_state: duplicate the atomic state for this connector
476 * @atomic_destroy_state: destroy an atomic state for this connector 505 * @atomic_destroy_state: destroy an atomic state for this connector
477 * @atomic_set_property: set a property on an atomic state for this connector 506 * @atomic_set_property: set a property on an atomic state for this connector
507 * (do not call directly, use drm_atomic_connector_set_property())
508 * @atomic_get_property: get a property on an atomic state for this connector
509 * (do not call directly, use drm_atomic_connector_get_property())
478 * 510 *
479 * Each CRTC may have one or more connectors attached to it. The functions 511 * Each CRTC may have one or more connectors attached to it. The functions
480 * below allow the core DRM code to control connectors, enumerate available modes, 512 * below allow the core DRM code to control connectors, enumerate available modes,
@@ -508,6 +540,10 @@ struct drm_connector_funcs {
508 struct drm_connector_state *state, 540 struct drm_connector_state *state,
509 struct drm_property *property, 541 struct drm_property *property,
510 uint64_t val); 542 uint64_t val);
543 int (*atomic_get_property)(struct drm_connector *connector,
544 const struct drm_connector_state *state,
545 struct drm_property *property,
546 uint64_t *val);
511}; 547};
512 548
513/** 549/**
@@ -693,6 +729,7 @@ struct drm_connector {
693 729
694/** 730/**
695 * struct drm_plane_state - mutable plane state 731 * struct drm_plane_state - mutable plane state
732 * @plane: backpointer to the plane
696 * @crtc: currently bound CRTC, NULL if disabled 733 * @crtc: currently bound CRTC, NULL if disabled
697 * @fb: currently bound framebuffer 734 * @fb: currently bound framebuffer
698 * @fence: optional fence to wait for before scanning out @fb 735 * @fence: optional fence to wait for before scanning out @fb
@@ -709,6 +746,8 @@ struct drm_connector {
709 * @state: backpointer to global drm_atomic_state 746 * @state: backpointer to global drm_atomic_state
710 */ 747 */
711struct drm_plane_state { 748struct drm_plane_state {
749 struct drm_plane *plane;
750
712 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ 751 struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */
713 struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */ 752 struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */
714 struct fence *fence; 753 struct fence *fence;
@@ -735,6 +774,9 @@ struct drm_plane_state {
735 * @atomic_duplicate_state: duplicate the atomic state for this plane 774 * @atomic_duplicate_state: duplicate the atomic state for this plane
736 * @atomic_destroy_state: destroy an atomic state for this plane 775 * @atomic_destroy_state: destroy an atomic state for this plane
737 * @atomic_set_property: set a property on an atomic state for this plane 776 * @atomic_set_property: set a property on an atomic state for this plane
777 * (do not call directly, use drm_atomic_plane_set_property())
778 * @atomic_get_property: get a property on an atomic state for this plane
779 * (do not call directly, use drm_atomic_plane_get_property())
738 */ 780 */
739struct drm_plane_funcs { 781struct drm_plane_funcs {
740 int (*update_plane)(struct drm_plane *plane, 782 int (*update_plane)(struct drm_plane *plane,
@@ -758,6 +800,10 @@ struct drm_plane_funcs {
758 struct drm_plane_state *state, 800 struct drm_plane_state *state,
759 struct drm_property *property, 801 struct drm_property *property,
760 uint64_t val); 802 uint64_t val);
803 int (*atomic_get_property)(struct drm_plane *plane,
804 const struct drm_plane_state *state,
805 struct drm_property *property,
806 uint64_t *val);
761}; 807};
762 808
763enum drm_plane_type { 809enum drm_plane_type {
@@ -856,7 +902,7 @@ struct drm_bridge {
856/** 902/**
857 * struct struct drm_atomic_state - the global state object for atomic updates 903 * struct struct drm_atomic_state - the global state object for atomic updates
858 * @dev: parent DRM device 904 * @dev: parent DRM device
859 * @flags: state flags like async update 905 * @allow_modeset: allow full modeset
860 * @planes: pointer to array of plane pointers 906 * @planes: pointer to array of plane pointers
861 * @plane_states: pointer to array of plane states pointers 907 * @plane_states: pointer to array of plane states pointers
862 * @crtcs: pointer to array of CRTC pointers 908 * @crtcs: pointer to array of CRTC pointers
@@ -868,7 +914,7 @@ struct drm_bridge {
868 */ 914 */
869struct drm_atomic_state { 915struct drm_atomic_state {
870 struct drm_device *dev; 916 struct drm_device *dev;
871 uint32_t flags; 917 bool allow_modeset : 1;
872 struct drm_plane **planes; 918 struct drm_plane **planes;
873 struct drm_plane_state **plane_states; 919 struct drm_plane_state **plane_states;
874 struct drm_crtc **crtcs; 920 struct drm_crtc **crtcs;
@@ -1053,6 +1099,16 @@ struct drm_mode_config {
1053 struct drm_property *tile_property; 1099 struct drm_property *tile_property;
1054 struct drm_property *plane_type_property; 1100 struct drm_property *plane_type_property;
1055 struct drm_property *rotation_property; 1101 struct drm_property *rotation_property;
1102 struct drm_property *prop_src_x;
1103 struct drm_property *prop_src_y;
1104 struct drm_property *prop_src_w;
1105 struct drm_property *prop_src_h;
1106 struct drm_property *prop_crtc_x;
1107 struct drm_property *prop_crtc_y;
1108 struct drm_property *prop_crtc_w;
1109 struct drm_property *prop_crtc_h;
1110 struct drm_property *prop_fb_id;
1111 struct drm_property *prop_crtc_id;
1056 1112
1057 /* DVI-I properties */ 1113 /* DVI-I properties */
1058 struct drm_property *dvi_i_subconnector_property; 1114 struct drm_property *dvi_i_subconnector_property;
@@ -1290,6 +1346,10 @@ extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
1290extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev); 1346extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
1291extern int drm_mode_create_dirty_info_property(struct drm_device *dev); 1347extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
1292extern int drm_mode_create_suggested_offset_properties(struct drm_device *dev); 1348extern int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
1349extern bool drm_property_change_valid_get(struct drm_property *property,
1350 uint64_t value, struct drm_mode_object **ref);
1351extern void drm_property_change_valid_put(struct drm_property *property,
1352 struct drm_mode_object *ref);
1293 1353
1294extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, 1354extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
1295 struct drm_encoder *encoder); 1355 struct drm_encoder *encoder);
@@ -1381,6 +1441,8 @@ extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
1381extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane, 1441extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
1382 struct drm_property *property, 1442 struct drm_property *property,
1383 uint64_t value); 1443 uint64_t value);
1444extern int drm_mode_atomic_ioctl(struct drm_device *dev,
1445 void *data, struct drm_file *file_priv);
1384 1446
1385extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, 1447extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
1386 int *bpp); 1448 int *bpp);
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index b0b855613641..01b2d6d0e355 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -654,6 +654,13 @@ struct drm_get_cap {
654 */ 654 */
655#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2 655#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2
656 656
657/**
658 * DRM_CLIENT_CAP_ATOMIC
659 *
660 * If set to 1, the DRM core will expose atomic properties to userspace
661 */
662#define DRM_CLIENT_CAP_ATOMIC 3
663
657/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ 664/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
658struct drm_set_client_cap { 665struct drm_set_client_cap {
659 __u64 capability; 666 __u64 capability;
@@ -777,6 +784,7 @@ struct drm_prime_handle {
777#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties) 784#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
778#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property) 785#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property)
779#define DRM_IOCTL_MODE_CURSOR2 DRM_IOWR(0xBB, struct drm_mode_cursor2) 786#define DRM_IOCTL_MODE_CURSOR2 DRM_IOWR(0xBB, struct drm_mode_cursor2)
787#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBC, struct drm_mode_atomic)
780 788
781/** 789/**
782 * Device specific ioctls should only be in their respective headers 790 * Device specific ioctls should only be in their respective headers
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index aae71cb32123..ca788e01dab2 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -272,6 +272,13 @@ struct drm_mode_get_connector {
272#define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1) 272#define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1)
273#define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2) 273#define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2)
274 274
275/* the PROP_ATOMIC flag is used to hide properties from userspace that
276 * is not aware of atomic properties. This is mostly to work around
277 * older userspace (DDX drivers) that read/write each prop they find,
278 * witout being aware that this could be triggering a lengthy modeset.
279 */
280#define DRM_MODE_PROP_ATOMIC 0x80000000
281
275struct drm_mode_property_enum { 282struct drm_mode_property_enum {
276 __u64 value; 283 __u64 value;
277 char name[DRM_PROP_NAME_LEN]; 284 char name[DRM_PROP_NAME_LEN];
@@ -519,4 +526,27 @@ struct drm_mode_destroy_dumb {
519 uint32_t handle; 526 uint32_t handle;
520}; 527};
521 528
529/* page-flip flags are valid, plus: */
530#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
531#define DRM_MODE_ATOMIC_NONBLOCK 0x0200
532#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
533
534#define DRM_MODE_ATOMIC_FLAGS (\
535 DRM_MODE_PAGE_FLIP_EVENT |\
536 DRM_MODE_PAGE_FLIP_ASYNC |\
537 DRM_MODE_ATOMIC_TEST_ONLY |\
538 DRM_MODE_ATOMIC_NONBLOCK |\
539 DRM_MODE_ATOMIC_ALLOW_MODESET)
540
541struct drm_mode_atomic {
542 __u32 flags;
543 __u32 count_objs;
544 __u64 objs_ptr;
545 __u64 count_props_ptr;
546 __u64 props_ptr;
547 __u64 prop_values_ptr;
548 __u64 reserved;
549 __u64 user_data;
550};
551
522#endif 552#endif