• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
3  * Copyright (c) 2007 Jakob Bornecrantz <wallbraker@gmail.com>
4  * Copyright (c) 2008 Red Hat Inc.
5  * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
6  * Copyright (c) 2007-2008 Intel Corporation
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24  * IN THE SOFTWARE.
25  */
26 
27 #ifndef _DRM_MODE_H
28 #define _DRM_MODE_H
29 
30 #include "drm.h"
31 
32 #if defined(__cplusplus)
33 extern "C" {
34 #endif
35 
36 /**
37  * DOC: overview
38  *
39  * DRM exposes many UAPI and structure definition to have a consistent
40  * and standardized interface with user.
41  * Userspace can refer to these structure definitions and UAPI formats
42  * to communicate to driver
43  */
44 #define DRM_CONNECTOR_NAME_LEN	32
45 #define DRM_DISPLAY_MODE_LEN	32
46 #define DRM_PROP_NAME_LEN	32
47 
48 #define DRM_MODE_TYPE_BUILTIN	(1<<0) /* deprecated */
49 #define DRM_MODE_TYPE_CLOCK_C	((1<<1) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
50 #define DRM_MODE_TYPE_CRTC_C	((1<<2) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
51 #define DRM_MODE_TYPE_PREFERRED	(1<<3)
52 #define DRM_MODE_TYPE_DEFAULT	(1<<4) /* deprecated */
53 #define DRM_MODE_TYPE_USERDEF	(1<<5)
54 #define DRM_MODE_TYPE_DRIVER	(1<<6)
55 
56 #define DRM_MODE_TYPE_ALL	(DRM_MODE_TYPE_PREFERRED |	\
57 				 DRM_MODE_TYPE_USERDEF |	\
58 				 DRM_MODE_TYPE_DRIVER)
59 
60 /* Video mode flags */
61 /* bit compatible with the xrandr RR_ definitions (bits 0-13)
62  *
63  * ABI warning: Existing userspace really expects
64  * the mode flags to match the xrandr definitions. Any
65  * changes that don't match the xrandr definitions will
66  * likely need a new client cap or some other mechanism
67  * to avoid breaking existing userspace. This includes
68  * allocating new flags in the previously unused bits!
69  */
70 #define DRM_MODE_FLAG_PHSYNC			(1<<0)
71 #define DRM_MODE_FLAG_NHSYNC			(1<<1)
72 #define DRM_MODE_FLAG_PVSYNC			(1<<2)
73 #define DRM_MODE_FLAG_NVSYNC			(1<<3)
74 #define DRM_MODE_FLAG_INTERLACE			(1<<4)
75 #define DRM_MODE_FLAG_DBLSCAN			(1<<5)
76 #define DRM_MODE_FLAG_CSYNC			(1<<6)
77 #define DRM_MODE_FLAG_PCSYNC			(1<<7)
78 #define DRM_MODE_FLAG_NCSYNC			(1<<8)
79 #define DRM_MODE_FLAG_HSKEW			(1<<9) /* hskew provided */
80 #define DRM_MODE_FLAG_BCAST			(1<<10) /* deprecated */
81 #define DRM_MODE_FLAG_PIXMUX			(1<<11) /* deprecated */
82 #define DRM_MODE_FLAG_DBLCLK			(1<<12)
83 #define DRM_MODE_FLAG_CLKDIV2			(1<<13)
84  /*
85   * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX
86   * (define not exposed to user space).
87   */
88 #define DRM_MODE_FLAG_3D_MASK			(0x1f<<14)
89 #define  DRM_MODE_FLAG_3D_NONE		(0<<14)
90 #define  DRM_MODE_FLAG_3D_FRAME_PACKING		(1<<14)
91 #define  DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE	(2<<14)
92 #define  DRM_MODE_FLAG_3D_LINE_ALTERNATIVE	(3<<14)
93 #define  DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL	(4<<14)
94 #define  DRM_MODE_FLAG_3D_L_DEPTH		(5<<14)
95 #define  DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH	(6<<14)
96 #define  DRM_MODE_FLAG_3D_TOP_AND_BOTTOM	(7<<14)
97 #define  DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF	(8<<14)
98 
99 /* Picture aspect ratio options */
100 #define DRM_MODE_PICTURE_ASPECT_NONE		0
101 #define DRM_MODE_PICTURE_ASPECT_4_3		1
102 #define DRM_MODE_PICTURE_ASPECT_16_9		2
103 #define DRM_MODE_PICTURE_ASPECT_64_27		3
104 #define DRM_MODE_PICTURE_ASPECT_256_135		4
105 
106 /* Content type options */
107 #define DRM_MODE_CONTENT_TYPE_NO_DATA		0
108 #define DRM_MODE_CONTENT_TYPE_GRAPHICS		1
109 #define DRM_MODE_CONTENT_TYPE_PHOTO		2
110 #define DRM_MODE_CONTENT_TYPE_CINEMA		3
111 #define DRM_MODE_CONTENT_TYPE_GAME		4
112 
113 /* Aspect ratio flag bitmask (4 bits 22:19) */
114 #define DRM_MODE_FLAG_PIC_AR_MASK		(0x0F<<19)
115 #define  DRM_MODE_FLAG_PIC_AR_NONE \
116 			(DRM_MODE_PICTURE_ASPECT_NONE<<19)
117 #define  DRM_MODE_FLAG_PIC_AR_4_3 \
118 			(DRM_MODE_PICTURE_ASPECT_4_3<<19)
119 #define  DRM_MODE_FLAG_PIC_AR_16_9 \
120 			(DRM_MODE_PICTURE_ASPECT_16_9<<19)
121 #define  DRM_MODE_FLAG_PIC_AR_64_27 \
122 			(DRM_MODE_PICTURE_ASPECT_64_27<<19)
123 #define  DRM_MODE_FLAG_PIC_AR_256_135 \
124 			(DRM_MODE_PICTURE_ASPECT_256_135<<19)
125 
126 #define  DRM_MODE_FLAG_SUPPORTS_RGB		(1<<27)
127 
128 #define  DRM_MODE_FLAG_SUPPORTS_YUV		(1<<28)
129 #define  DRM_MODE_FLAG_VID_MODE_PANEL	(1<<29)
130 #define  DRM_MODE_FLAG_CMD_MODE_PANEL	(1<<30)
131 #define  DRM_MODE_FLAG_SEAMLESS			(1<<31)
132 
133 #define  DRM_MODE_FLAG_ALL	(DRM_MODE_FLAG_PHSYNC |		\
134 				 DRM_MODE_FLAG_NHSYNC |		\
135 				 DRM_MODE_FLAG_PVSYNC |		\
136 				 DRM_MODE_FLAG_NVSYNC |		\
137 				 DRM_MODE_FLAG_INTERLACE |	\
138 				 DRM_MODE_FLAG_DBLSCAN |	\
139 				 DRM_MODE_FLAG_CSYNC |		\
140 				 DRM_MODE_FLAG_PCSYNC |		\
141 				 DRM_MODE_FLAG_NCSYNC |		\
142 				 DRM_MODE_FLAG_HSKEW |		\
143 				 DRM_MODE_FLAG_DBLCLK |		\
144 				 DRM_MODE_FLAG_CLKDIV2 |	\
145 				 DRM_MODE_FLAG_SUPPORTS_RGB |	\
146 				 DRM_MODE_FLAG_SUPPORTS_YUV |	\
147 				 DRM_MODE_FLAG_VID_MODE_PANEL |	\
148 				 DRM_MODE_FLAG_CMD_MODE_PANEL |	\
149 				 DRM_MODE_FLAG_3D_MASK)
150 
151 /* DPMS flags */
152 /* bit compatible with the xorg definitions. */
153 #define DRM_MODE_DPMS_ON	0
154 #define DRM_MODE_DPMS_STANDBY	1
155 #define DRM_MODE_DPMS_SUSPEND	2
156 #define DRM_MODE_DPMS_OFF	3
157 
158 /* Scaling mode options */
159 #define DRM_MODE_SCALE_NONE		0 /* Unmodified timing (display or
160 					     software can still scale) */
161 #define DRM_MODE_SCALE_FULLSCREEN	1 /* Full screen, ignore aspect */
162 #define DRM_MODE_SCALE_CENTER		2 /* Centered, no scaling */
163 #define DRM_MODE_SCALE_ASPECT		3 /* Full screen, preserve aspect */
164 
165 /* Dithering mode options */
166 #define DRM_MODE_DITHERING_OFF	0
167 #define DRM_MODE_DITHERING_ON	1
168 #define DRM_MODE_DITHERING_AUTO 2
169 
170 /* Dirty info options */
171 #define DRM_MODE_DIRTY_OFF      0
172 #define DRM_MODE_DIRTY_ON       1
173 #define DRM_MODE_DIRTY_ANNOTATE 2
174 
175 /* Link Status options */
176 #define DRM_MODE_LINK_STATUS_GOOD	0
177 #define DRM_MODE_LINK_STATUS_BAD	1
178 
179 /*
180  * DRM_MODE_ROTATE_<degrees>
181  *
182  * Signals that a drm plane is been rotated <degrees> degrees in counter
183  * clockwise direction.
184  *
185  * This define is provided as a convenience, looking up the property id
186  * using the name->prop id lookup is the preferred method.
187  */
188 #define DRM_MODE_ROTATE_0       (1<<0)
189 #define DRM_MODE_ROTATE_90      (1<<1)
190 #define DRM_MODE_ROTATE_180     (1<<2)
191 #define DRM_MODE_ROTATE_270     (1<<3)
192 
193 /*
194  * DRM_MODE_ROTATE_MASK
195  *
196  * Bitmask used to look for drm plane rotations.
197  */
198 #define DRM_MODE_ROTATE_MASK (\
199 		DRM_MODE_ROTATE_0  | \
200 		DRM_MODE_ROTATE_90  | \
201 		DRM_MODE_ROTATE_180 | \
202 		DRM_MODE_ROTATE_270)
203 
204 /*
205  * DRM_MODE_REFLECT_<axis>
206  *
207  * Signals that the contents of a drm plane is reflected along the <axis> axis,
208  * in the same way as mirroring.
209  * See kerneldoc chapter "Plane Composition Properties" for more details.
210  *
211  * This define is provided as a convenience, looking up the property id
212  * using the name->prop id lookup is the preferred method.
213  */
214 #define DRM_MODE_REFLECT_X      (1<<4)
215 #define DRM_MODE_REFLECT_Y      (1<<5)
216 
217 /*
218  * DRM_MODE_REFLECT_MASK
219  *
220  * Bitmask used to look for drm plane reflections.
221  */
222 #define DRM_MODE_REFLECT_MASK (\
223 		DRM_MODE_REFLECT_X | \
224 		DRM_MODE_REFLECT_Y)
225 
226 /* Content Protection Flags */
227 #define DRM_MODE_CONTENT_PROTECTION_UNDESIRED	0
228 #define DRM_MODE_CONTENT_PROTECTION_DESIRED     1
229 #define DRM_MODE_CONTENT_PROTECTION_ENABLED     2
230 
231 struct drm_mode_modeinfo {
232 	__u32 clock;
233 	__u16 hdisplay;
234 	__u16 hsync_start;
235 	__u16 hsync_end;
236 	__u16 htotal;
237 	__u16 hskew;
238 	__u16 vdisplay;
239 	__u16 vsync_start;
240 	__u16 vsync_end;
241 	__u16 vtotal;
242 	__u16 vscan;
243 
244 	__u32 vrefresh;
245 
246 	__u32 flags;
247 	__u32 type;
248 	char name[DRM_DISPLAY_MODE_LEN];
249 };
250 
251 struct drm_mode_card_res {
252 	__u64 fb_id_ptr;
253 	__u64 crtc_id_ptr;
254 	__u64 connector_id_ptr;
255 	__u64 encoder_id_ptr;
256 	__u32 count_fbs;
257 	__u32 count_crtcs;
258 	__u32 count_connectors;
259 	__u32 count_encoders;
260 	__u32 min_width;
261 	__u32 max_width;
262 	__u32 min_height;
263 	__u32 max_height;
264 };
265 
266 struct drm_mode_crtc {
267 	__u64 set_connectors_ptr;
268 	__u32 count_connectors;
269 
270 	__u32 crtc_id; /**< Id */
271 	__u32 fb_id; /**< Id of framebuffer */
272 
273 	__u32 x; /**< x Position on the framebuffer */
274 	__u32 y; /**< y Position on the framebuffer */
275 
276 	__u32 gamma_size;
277 	__u32 mode_valid;
278 	struct drm_mode_modeinfo mode;
279 };
280 
281 #define DRM_MODE_PRESENT_TOP_FIELD	(1<<0)
282 #define DRM_MODE_PRESENT_BOTTOM_FIELD	(1<<1)
283 
284 /* Planes blend with or override other bits on the CRTC */
285 struct drm_mode_set_plane {
286 	__u32 plane_id;
287 	__u32 crtc_id;
288 	__u32 fb_id; /* fb object contains surface format type */
289 	__u32 flags; /* see above flags */
290 
291 	/* Signed dest location allows it to be partially off screen */
292 	__s32 crtc_x;
293 	__s32 crtc_y;
294 	__u32 crtc_w;
295 	__u32 crtc_h;
296 
297 	/* Source values are 16.16 fixed point */
298 	__u32 src_x;
299 	__u32 src_y;
300 	__u32 src_h;
301 	__u32 src_w;
302 };
303 
304 struct drm_mode_get_plane {
305 	__u32 plane_id;
306 
307 	__u32 crtc_id;
308 	__u32 fb_id;
309 
310 	__u32 possible_crtcs;
311 	__u32 gamma_size;
312 
313 	__u32 count_format_types;
314 	__u64 format_type_ptr;
315 };
316 
317 struct drm_mode_get_plane_res {
318 	__u64 plane_id_ptr;
319 	__u32 count_planes;
320 };
321 
322 #define DRM_MODE_ENCODER_NONE	0
323 #define DRM_MODE_ENCODER_DAC	1
324 #define DRM_MODE_ENCODER_TMDS	2
325 #define DRM_MODE_ENCODER_LVDS	3
326 #define DRM_MODE_ENCODER_TVDAC	4
327 #define DRM_MODE_ENCODER_VIRTUAL 5
328 #define DRM_MODE_ENCODER_DSI	6
329 #define DRM_MODE_ENCODER_DPMST	7
330 #define DRM_MODE_ENCODER_DPI	8
331 
332 struct drm_mode_get_encoder {
333 	__u32 encoder_id;
334 	__u32 encoder_type;
335 
336 	__u32 crtc_id; /**< Id of crtc */
337 
338 	__u32 possible_crtcs;
339 	__u32 possible_clones;
340 };
341 
342 /* This is for connectors with multiple signal types. */
343 /* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
344 enum drm_mode_subconnector {
345 	DRM_MODE_SUBCONNECTOR_Automatic = 0,
346 	DRM_MODE_SUBCONNECTOR_Unknown = 0,
347 	DRM_MODE_SUBCONNECTOR_DVID = 3,
348 	DRM_MODE_SUBCONNECTOR_DVIA = 4,
349 	DRM_MODE_SUBCONNECTOR_Composite = 5,
350 	DRM_MODE_SUBCONNECTOR_SVIDEO = 6,
351 	DRM_MODE_SUBCONNECTOR_Component = 8,
352 	DRM_MODE_SUBCONNECTOR_SCART = 9,
353 };
354 
355 #define DRM_MODE_CONNECTOR_Unknown	0
356 #define DRM_MODE_CONNECTOR_VGA		1
357 #define DRM_MODE_CONNECTOR_DVII		2
358 #define DRM_MODE_CONNECTOR_DVID		3
359 #define DRM_MODE_CONNECTOR_DVIA		4
360 #define DRM_MODE_CONNECTOR_Composite	5
361 #define DRM_MODE_CONNECTOR_SVIDEO	6
362 #define DRM_MODE_CONNECTOR_LVDS		7
363 #define DRM_MODE_CONNECTOR_Component	8
364 #define DRM_MODE_CONNECTOR_9PinDIN	9
365 #define DRM_MODE_CONNECTOR_DisplayPort	10
366 #define DRM_MODE_CONNECTOR_HDMIA	11
367 #define DRM_MODE_CONNECTOR_HDMIB	12
368 #define DRM_MODE_CONNECTOR_TV		13
369 #define DRM_MODE_CONNECTOR_eDP		14
370 #define DRM_MODE_CONNECTOR_VIRTUAL      15
371 #define DRM_MODE_CONNECTOR_DSI		16
372 #define DRM_MODE_CONNECTOR_DPI		17
373 #define DRM_MODE_CONNECTOR_WRITEBACK	18
374 #define DRM_MODE_CONNECTOR_SPI		19
375 
376 struct drm_mode_get_connector {
377 
378 	__u64 encoders_ptr;
379 	__u64 modes_ptr;
380 	__u64 props_ptr;
381 	__u64 prop_values_ptr;
382 
383 	__u32 count_modes;
384 	__u32 count_props;
385 	__u32 count_encoders;
386 
387 	__u32 encoder_id; /**< Current Encoder */
388 	__u32 connector_id; /**< Id */
389 	__u32 connector_type;
390 	__u32 connector_type_id;
391 
392 	__u32 connection;
393 	__u32 mm_width;  /**< width in millimeters */
394 	__u32 mm_height; /**< height in millimeters */
395 	__u32 subpixel;
396 
397 	__u32 pad;
398 };
399 
400 #define DRM_MODE_PROP_PENDING	(1<<0) /* deprecated, do not use */
401 #define DRM_MODE_PROP_RANGE	(1<<1)
402 #define DRM_MODE_PROP_IMMUTABLE	(1<<2)
403 #define DRM_MODE_PROP_ENUM	(1<<3) /* enumerated type with text strings */
404 #define DRM_MODE_PROP_BLOB	(1<<4)
405 #define DRM_MODE_PROP_BITMASK	(1<<5) /* bitmask of enumerated types */
406 
407 /* non-extended types: legacy bitmask, one bit per type: */
408 #define DRM_MODE_PROP_LEGACY_TYPE  ( \
409 		DRM_MODE_PROP_RANGE | \
410 		DRM_MODE_PROP_ENUM | \
411 		DRM_MODE_PROP_BLOB | \
412 		DRM_MODE_PROP_BITMASK)
413 
414 /* extended-types: rather than continue to consume a bit per type,
415  * grab a chunk of the bits to use as integer type id.
416  */
417 #define DRM_MODE_PROP_EXTENDED_TYPE	0x0000ffc0
418 #define DRM_MODE_PROP_TYPE(n)		((n) << 6)
419 #define DRM_MODE_PROP_OBJECT		DRM_MODE_PROP_TYPE(1)
420 #define DRM_MODE_PROP_SIGNED_RANGE	DRM_MODE_PROP_TYPE(2)
421 
422 /* the PROP_ATOMIC flag is used to hide properties from userspace that
423  * is not aware of atomic properties.  This is mostly to work around
424  * older userspace (DDX drivers) that read/write each prop they find,
425  * witout being aware that this could be triggering a lengthy modeset.
426  */
427 #define DRM_MODE_PROP_ATOMIC        0x80000000
428 
429 struct drm_mode_property_enum {
430 	__u64 value;
431 	char name[DRM_PROP_NAME_LEN];
432 };
433 
434 struct drm_mode_get_property {
435 	__u64 values_ptr; /* values and blob lengths */
436 	__u64 enum_blob_ptr; /* enum and blob id ptrs */
437 
438 	__u32 prop_id;
439 	__u32 flags;
440 	char name[DRM_PROP_NAME_LEN];
441 
442 	__u32 count_values;
443 	/* This is only used to count enum values, not blobs. The _blobs is
444 	 * simply because of a historical reason, i.e. backwards compat. */
445 	__u32 count_enum_blobs;
446 };
447 
448 struct drm_mode_connector_set_property {
449 	__u64 value;
450 	__u32 prop_id;
451 	__u32 connector_id;
452 };
453 
454 #define DRM_MODE_OBJECT_CRTC 0xcccccccc
455 #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
456 #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
457 #define DRM_MODE_OBJECT_MODE 0xdededede
458 #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
459 #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
460 #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
461 #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
462 #define DRM_MODE_OBJECT_ANY 0
463 
464 struct drm_mode_obj_get_properties {
465 	__u64 props_ptr;
466 	__u64 prop_values_ptr;
467 	__u32 count_props;
468 	__u32 obj_id;
469 	__u32 obj_type;
470 };
471 
472 struct drm_mode_obj_set_property {
473 	__u64 value;
474 	__u32 prop_id;
475 	__u32 obj_id;
476 	__u32 obj_type;
477 };
478 
479 struct drm_mode_get_blob {
480 	__u32 blob_id;
481 	__u32 length;
482 	__u64 data;
483 };
484 
485 struct drm_mode_fb_cmd {
486 	__u32 fb_id;
487 	__u32 width;
488 	__u32 height;
489 	__u32 pitch;
490 	__u32 bpp;
491 	__u32 depth;
492 	/* driver specific handle */
493 	__u32 handle;
494 };
495 
496 #define DRM_MODE_FB_INTERLACED	(1<<0) /* for interlaced framebuffers */
497 #define DRM_MODE_FB_MODIFIERS	(1<<1) /* enables ->modifer[] */
498 #define DRM_MODE_FB_SECURE	(1<<2) /* for secure framebuffers */
499 
500 struct drm_mode_fb_cmd2 {
501 	__u32 fb_id;
502 	__u32 width;
503 	__u32 height;
504 	__u32 pixel_format; /* fourcc code from drm_fourcc.h */
505 	__u32 flags; /* see above flags */
506 
507 	/*
508 	 * In case of planar formats, this ioctl allows up to 4
509 	 * buffer objects with offsets and pitches per plane.
510 	 * The pitch and offset order is dictated by the fourcc,
511 	 * e.g. NV12 (http://fourcc.org/yuv.php#NV12) is described as:
512 	 *
513 	 *   YUV 4:2:0 image with a plane of 8 bit Y samples
514 	 *   followed by an interleaved U/V plane containing
515 	 *   8 bit 2x2 subsampled colour difference samples.
516 	 *
517 	 * So it would consist of Y as offsets[0] and UV as
518 	 * offsets[1].  Note that offsets[0] will generally
519 	 * be 0 (but this is not required).
520 	 *
521 	 * To accommodate tiled, compressed, etc formats, a
522 	 * modifier can be specified.  The default value of zero
523 	 * indicates "native" format as specified by the fourcc.
524 	 * Vendor specific modifier token.  Note that even though
525 	 * it looks like we have a modifier per-plane, we in fact
526 	 * do not. The modifier for each plane must be identical.
527 	 * Thus all combinations of different data layouts for
528 	 * multi plane formats must be enumerated as separate
529 	 * modifiers.
530 	 */
531 	__u32 handles[4];
532 	__u32 pitches[4]; /* pitch for each plane */
533 	__u32 offsets[4]; /* offset of each plane */
534 	__u64 modifier[4]; /* ie, tiling, compress */
535 };
536 
537 #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
538 #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
539 #define DRM_MODE_FB_DIRTY_FLAGS         0x03
540 
541 #define DRM_MODE_FB_DIRTY_MAX_CLIPS     256
542 
543 /*
544  * Mark a region of a framebuffer as dirty.
545  *
546  * Some hardware does not automatically update display contents
547  * as a hardware or software draw to a framebuffer. This ioctl
548  * allows userspace to tell the kernel and the hardware what
549  * regions of the framebuffer have changed.
550  *
551  * The kernel or hardware is free to update more then just the
552  * region specified by the clip rects. The kernel or hardware
553  * may also delay and/or coalesce several calls to dirty into a
554  * single update.
555  *
556  * Userspace may annotate the updates, the annotates are a
557  * promise made by the caller that the change is either a copy
558  * of pixels or a fill of a single color in the region specified.
559  *
560  * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
561  * the number of updated regions are half of num_clips given,
562  * where the clip rects are paired in src and dst. The width and
563  * height of each one of the pairs must match.
564  *
565  * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
566  * promises that the region specified of the clip rects is filled
567  * completely with a single color as given in the color argument.
568  */
569 
570 struct drm_mode_fb_dirty_cmd {
571 	__u32 fb_id;
572 	__u32 flags;
573 	__u32 color;
574 	__u32 num_clips;
575 	__u64 clips_ptr;
576 };
577 
578 struct drm_mode_mode_cmd {
579 	__u32 connector_id;
580 	struct drm_mode_modeinfo mode;
581 };
582 
583 #define DRM_MODE_CURSOR_BO	0x01
584 #define DRM_MODE_CURSOR_MOVE	0x02
585 #define DRM_MODE_CURSOR_FLAGS	0x03
586 
587 /*
588  * depending on the value in flags different members are used.
589  *
590  * CURSOR_BO uses
591  *    crtc_id
592  *    width
593  *    height
594  *    handle - if 0 turns the cursor off
595  *
596  * CURSOR_MOVE uses
597  *    crtc_id
598  *    x
599  *    y
600  */
601 struct drm_mode_cursor {
602 	__u32 flags;
603 	__u32 crtc_id;
604 	__s32 x;
605 	__s32 y;
606 	__u32 width;
607 	__u32 height;
608 	/* driver specific handle */
609 	__u32 handle;
610 };
611 
612 struct drm_mode_cursor2 {
613 	__u32 flags;
614 	__u32 crtc_id;
615 	__s32 x;
616 	__s32 y;
617 	__u32 width;
618 	__u32 height;
619 	/* driver specific handle */
620 	__u32 handle;
621 	__s32 hot_x;
622 	__s32 hot_y;
623 };
624 
625 struct drm_mode_crtc_lut {
626 	__u32 crtc_id;
627 	__u32 gamma_size;
628 
629 	/* pointers to arrays */
630 	__u64 red;
631 	__u64 green;
632 	__u64 blue;
633 };
634 
635 struct drm_color_ctm {
636 	/*
637 	 * Conversion matrix in S31.32 sign-magnitude
638 	 * (not two's complement!) format.
639 	 */
640 	__u64 matrix[9];
641 };
642 
643 struct drm_color_lut {
644 	/*
645 	 * Values are mapped linearly to 0.0 - 1.0 range, with 0x0 == 0.0 and
646 	 * 0xffff == 1.0.
647 	 */
648 	__u16 red;
649 	__u16 green;
650 	__u16 blue;
651 	__u16 reserved;
652 };
653 
654 /**
655  * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
656  *
657  * HDR Metadata Infoframe as per CTA 861.G spec. This is expected
658  * to match exactly with the spec.
659  *
660  * Userspace is expected to pass the metadata information as per
661  * the format described in this structure.
662  */
663 struct hdr_metadata_infoframe {
664 	/**
665 	 * @eotf: Electro-Optical Transfer Function (EOTF)
666 	 * used in the stream.
667 	 */
668 	__u8 eotf;
669 	/**
670 	 * @metadata_type: Static_Metadata_Descriptor_ID.
671 	 */
672 	__u8 metadata_type;
673 	/**
674 	 * @display_primaries: Color Primaries of the Data.
675 	 * These are coded as unsigned 16-bit values in units of
676 	 * 0.00002, where 0x0000 represents zero and 0xC350
677 	 * represents 1.0000.
678 	 * @display_primaries.x: X cordinate of color primary.
679 	 * @display_primaries.y: Y cordinate of color primary.
680 	 */
681 	struct {
682 		__u16 x, y;
683 		} display_primaries[3];
684 	/**
685 	 * @white_point: White Point of Colorspace Data.
686 	 * These are coded as unsigned 16-bit values in units of
687 	 * 0.00002, where 0x0000 represents zero and 0xC350
688 	 * represents 1.0000.
689 	 * @white_point.x: X cordinate of whitepoint of color primary.
690 	 * @white_point.y: Y cordinate of whitepoint of color primary.
691 	 */
692 	struct {
693 		__u16 x, y;
694 		} white_point;
695 	/**
696 	 * @max_display_mastering_luminance: Max Mastering Display Luminance.
697 	 * This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
698 	 * where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
699 	 */
700 	__u16 max_display_mastering_luminance;
701 	/**
702 	 * @min_display_mastering_luminance: Min Mastering Display Luminance.
703 	 * This value is coded as an unsigned 16-bit value in units of
704 	 * 0.0001 cd/m2, where 0x0001 represents 0.0001 cd/m2 and 0xFFFF
705 	 * represents 6.5535 cd/m2.
706 	 */
707 	__u16 min_display_mastering_luminance;
708 	/**
709 	 * @max_cll: Max Content Light Level.
710 	 * This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
711 	 * where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
712 	 */
713 	__u16 max_cll;
714 	/**
715 	 * @max_fall: Max Frame Average Light Level.
716 	 * This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
717 	 * where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
718 	 */
719 	__u16 max_fall;
720 };
721 
722 /**
723  * struct hdr_output_metadata - HDR output metadata
724  *
725  * Metadata Information to be passed from userspace
726  */
727 struct hdr_output_metadata {
728 	/**
729 	 * @metadata_type: Static_Metadata_Descriptor_ID.
730 	 */
731 	__u32 metadata_type;
732 	/**
733 	 * @hdmi_metadata_type1: HDR Metadata Infoframe.
734 	 */
735 	union {
736 		struct hdr_metadata_infoframe hdmi_metadata_type1;
737 	};
738 };
739 
740 #define DRM_MODE_PAGE_FLIP_EVENT 0x01
741 #define DRM_MODE_PAGE_FLIP_ASYNC 0x02
742 #define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
743 #define DRM_MODE_PAGE_FLIP_TARGET_RELATIVE 0x8
744 #define DRM_MODE_PAGE_FLIP_TARGET (DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE | \
745 				   DRM_MODE_PAGE_FLIP_TARGET_RELATIVE)
746 #define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT | \
747 				  DRM_MODE_PAGE_FLIP_ASYNC | \
748 				  DRM_MODE_PAGE_FLIP_TARGET)
749 
750 /*
751  * Request a page flip on the specified crtc.
752  *
753  * This ioctl will ask KMS to schedule a page flip for the specified
754  * crtc.  Once any pending rendering targeting the specified fb (as of
755  * ioctl time) has completed, the crtc will be reprogrammed to display
756  * that fb after the next vertical refresh.  The ioctl returns
757  * immediately, but subsequent rendering to the current fb will block
758  * in the execbuffer ioctl until the page flip happens.  If a page
759  * flip is already pending as the ioctl is called, EBUSY will be
760  * returned.
761  *
762  * Flag DRM_MODE_PAGE_FLIP_EVENT requests that drm sends back a vblank
763  * event (see drm.h: struct drm_event_vblank) when the page flip is
764  * done.  The user_data field passed in with this ioctl will be
765  * returned as the user_data field in the vblank event struct.
766  *
767  * Flag DRM_MODE_PAGE_FLIP_ASYNC requests that the flip happen
768  * 'as soon as possible', meaning that it not delay waiting for vblank.
769  * This may cause tearing on the screen.
770  *
771  * The reserved field must be zero.
772  */
773 
774 struct drm_mode_crtc_page_flip {
775 	__u32 crtc_id;
776 	__u32 fb_id;
777 	__u32 flags;
778 	__u32 reserved;
779 	__u64 user_data;
780 };
781 
782 /*
783  * Request a page flip on the specified crtc.
784  *
785  * Same as struct drm_mode_crtc_page_flip, but supports new flags and
786  * re-purposes the reserved field:
787  *
788  * The sequence field must be zero unless either of the
789  * DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags is specified. When
790  * the ABSOLUTE flag is specified, the sequence field denotes the absolute
791  * vblank sequence when the flip should take effect. When the RELATIVE
792  * flag is specified, the sequence field denotes the relative (to the
793  * current one when the ioctl is called) vblank sequence when the flip
794  * should take effect. NOTE: DRM_IOCTL_WAIT_VBLANK must still be used to
795  * make sure the vblank sequence before the target one has passed before
796  * calling this ioctl. The purpose of the
797  * DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags is merely to clarify
798  * the target for when code dealing with a page flip runs during a
799  * vertical blank period.
800  */
801 
802 struct drm_mode_crtc_page_flip_target {
803 	__u32 crtc_id;
804 	__u32 fb_id;
805 	__u32 flags;
806 	__u32 sequence;
807 	__u64 user_data;
808 };
809 
810 /* create a dumb scanout buffer */
811 struct drm_mode_create_dumb {
812 	__u32 height;
813 	__u32 width;
814 	__u32 bpp;
815 	__u32 flags;
816 	/* handle, pitch, size will be returned */
817 	__u32 handle;
818 	__u32 pitch;
819 	__u64 size;
820 };
821 
822 /* set up for mmap of a dumb scanout buffer */
823 struct drm_mode_map_dumb {
824 	/** Handle for the object being mapped. */
825 	__u32 handle;
826 	__u32 pad;
827 	/**
828 	 * Fake offset to use for subsequent mmap call
829 	 *
830 	 * This is a fixed-size type for 32/64 compatibility.
831 	 */
832 	__u64 offset;
833 };
834 
835 struct drm_mode_destroy_dumb {
836 	__u32 handle;
837 };
838 
839 /* page-flip flags are valid, plus: */
840 #define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
841 #define DRM_MODE_ATOMIC_NONBLOCK  0x0200
842 #define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
843 
844 #define DRM_MODE_ATOMIC_FLAGS (\
845 		DRM_MODE_PAGE_FLIP_EVENT |\
846 		DRM_MODE_PAGE_FLIP_ASYNC |\
847 		DRM_MODE_ATOMIC_TEST_ONLY |\
848 		DRM_MODE_ATOMIC_NONBLOCK |\
849 		DRM_MODE_ATOMIC_ALLOW_MODESET)
850 
851 struct drm_mode_atomic {
852 	__u32 flags;
853 	__u32 count_objs;
854 	__u64 objs_ptr;
855 	__u64 count_props_ptr;
856 	__u64 props_ptr;
857 	__u64 prop_values_ptr;
858 	__u64 reserved;
859 	__u64 user_data;
860 };
861 
862 struct drm_format_modifier_blob {
863 #define FORMAT_BLOB_CURRENT 1
864 	/* Version of this blob format */
865 	__u32 version;
866 
867 	/* Flags */
868 	__u32 flags;
869 
870 	/* Number of fourcc formats supported */
871 	__u32 count_formats;
872 
873 	/* Where in this blob the formats exist (in bytes) */
874 	__u32 formats_offset;
875 
876 	/* Number of drm_format_modifiers */
877 	__u32 count_modifiers;
878 
879 	/* Where in this blob the modifiers exist (in bytes) */
880 	__u32 modifiers_offset;
881 
882 	/* __u32 formats[] */
883 	/* struct drm_format_modifier modifiers[] */
884 };
885 
886 struct drm_format_modifier {
887 	/* Bitmask of formats in get_plane format list this info applies to. The
888 	 * offset allows a sliding window of which 64 formats (bits).
889 	 *
890 	 * Some examples:
891 	 * In today's world with < 65 formats, and formats 0, and 2 are
892 	 * supported
893 	 * 0x0000000000000005
894 	 *		  ^-offset = 0, formats = 5
895 	 *
896 	 * If the number formats grew to 128, and formats 98-102 are
897 	 * supported with the modifier:
898 	 *
899 	 * 0x0000007c00000000 0000000000000000
900 	 *		  ^
901 	 *		  |__offset = 64, formats = 0x7c00000000
902 	 *
903 	 */
904 	__u64 formats;
905 	__u32 offset;
906 	__u32 pad;
907 
908 	/* The modifier that applies to the >get_plane format list bitmask. */
909 	__u64 modifier;
910 };
911 
912 /**
913  * struct drm_mode_create_blob - Create New block property
914  * @data: Pointer to data to copy.
915  * @length: Length of data to copy.
916  * @blob_id: new property ID.
917  * Create a new 'blob' data property, copying length bytes from data pointer,
918  * and returning new blob ID.
919  */
920 struct drm_mode_create_blob {
921 	/** Pointer to data to copy. */
922 	__u64 data;
923 	/** Length of data to copy. */
924 	__u32 length;
925 	/** Return: new property ID. */
926 	__u32 blob_id;
927 };
928 
929 /**
930  * struct drm_mode_destroy_blob - Destroy user blob
931  * @blob_id: blob_id to destroy
932  * Destroy a user-created blob property.
933  */
934 struct drm_mode_destroy_blob {
935 	__u32 blob_id;
936 };
937 
938 /**
939  * struct drm_mode_create_lease - Create lease
940  * @object_ids: Pointer to array of object ids.
941  * @object_count: Number of object ids.
942  * @flags: flags for new FD.
943  * @lessee_id: unique identifier for lessee.
944  * @fd: file descriptor to new drm_master file.
945  * Lease mode resources, creating another drm_master.
946  */
947 struct drm_mode_create_lease {
948 	/** Pointer to array of object ids (__u32) */
949 	__u64 object_ids;
950 	/** Number of object ids */
951 	__u32 object_count;
952 	/** flags for new FD (O_CLOEXEC, etc) */
953 	__u32 flags;
954 
955 	/** Return: unique identifier for lessee. */
956 	__u32 lessee_id;
957 	/** Return: file descriptor to new drm_master file */
958 	__u32 fd;
959 };
960 
961 /**
962  * struct drm_mode_list_lessees - List lessees
963  * @count_lessees: Number of lessees.
964  * @pad: pad.
965  * @lessees_ptr: Pointer to lessess.
966  * List lesses from a drm_master
967  */
968 struct drm_mode_list_lessees {
969 	/** Number of lessees.
970 	 * On input, provides length of the array.
971 	 * On output, provides total number. No
972 	 * more than the input number will be written
973 	 * back, so two calls can be used to get
974 	 * the size and then the data.
975 	 */
976 	__u32 count_lessees;
977 	__u32 pad;
978 
979 	/** Pointer to lessees.
980 	 * pointer to __u64 array of lessee ids
981 	 */
982 	__u64 lessees_ptr;
983 };
984 
985 /**
986  * struct drm_mode_get_lease - Get Lease
987  * @count_objects: Number of leased objects.
988  * @pad: pad.
989  * @objects_ptr: Pointer to objects.
990  * Get leased objects
991  */
992 struct drm_mode_get_lease {
993 	/** Number of leased objects.
994 	 * On input, provides length of the array.
995 	 * On output, provides total number. No
996 	 * more than the input number will be written
997 	 * back, so two calls can be used to get
998 	 * the size and then the data.
999 	 */
1000 	__u32 count_objects;
1001 	__u32 pad;
1002 
1003 	/** Pointer to objects.
1004 	 * pointer to __u32 array of object ids
1005 	 */
1006 	__u64 objects_ptr;
1007 };
1008 
1009 /**
1010  * struct drm_mode_revoke_lease - Revoke lease
1011  * @lessee_id: Unique ID of lessee.
1012  * Revoke lease
1013  */
1014 struct drm_mode_revoke_lease {
1015 	/** Unique ID of lessee
1016 	 */
1017 	__u32 lessee_id;
1018 };
1019 
1020 /**
1021  * struct drm_mode_rect - Two dimensional rectangle.
1022  * @x1: Horizontal starting coordinate (inclusive).
1023  * @y1: Vertical starting coordinate (inclusive).
1024  * @x2: Horizontal ending coordinate (exclusive).
1025  * @y2: Vertical ending coordinate (exclusive).
1026  *
1027  * With drm subsystem using struct drm_rect to manage rectangular area this
1028  * export it to user-space.
1029  *
1030  * Currently used by drm_mode_atomic blob property FB_DAMAGE_CLIPS.
1031  */
1032 struct drm_mode_rect {
1033 	__s32 x1;
1034 	__s32 y1;
1035 	__s32 x2;
1036 	__s32 y2;
1037 };
1038 
1039 #if defined(__cplusplus)
1040 }
1041 #endif
1042 
1043 #endif
1044