Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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 <linux/bits.h>
31#include <linux/const.h>
32
33#include "drm.h"
34
35#if defined(__cplusplus)
36extern "C" {
37#endif
38
39/**
40 * DOC: overview
41 *
42 * DRM exposes many UAPI and structure definitions to have a consistent
43 * and standardized interface with users.
44 * Userspace can refer to these structure definitions and UAPI formats
45 * to communicate to drivers.
46 */
47
48#define DRM_CONNECTOR_NAME_LEN 32
49#define DRM_DISPLAY_MODE_LEN 32
50#define DRM_PROP_NAME_LEN 32
51
52#define DRM_MODE_TYPE_BUILTIN (1<<0) /* deprecated */
53#define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
54#define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN) /* deprecated */
55#define DRM_MODE_TYPE_PREFERRED (1<<3)
56#define DRM_MODE_TYPE_DEFAULT (1<<4) /* deprecated */
57#define DRM_MODE_TYPE_USERDEF (1<<5)
58#define DRM_MODE_TYPE_DRIVER (1<<6)
59
60#define DRM_MODE_TYPE_ALL (DRM_MODE_TYPE_PREFERRED | \
61 DRM_MODE_TYPE_USERDEF | \
62 DRM_MODE_TYPE_DRIVER)
63
64/* Video mode flags */
65/* bit compatible with the xrandr RR_ definitions (bits 0-13)
66 *
67 * ABI warning: Existing userspace really expects
68 * the mode flags to match the xrandr definitions. Any
69 * changes that don't match the xrandr definitions will
70 * likely need a new client cap or some other mechanism
71 * to avoid breaking existing userspace. This includes
72 * allocating new flags in the previously unused bits!
73 */
74#define DRM_MODE_FLAG_PHSYNC (1<<0)
75#define DRM_MODE_FLAG_NHSYNC (1<<1)
76#define DRM_MODE_FLAG_PVSYNC (1<<2)
77#define DRM_MODE_FLAG_NVSYNC (1<<3)
78#define DRM_MODE_FLAG_INTERLACE (1<<4)
79#define DRM_MODE_FLAG_DBLSCAN (1<<5)
80#define DRM_MODE_FLAG_CSYNC (1<<6)
81#define DRM_MODE_FLAG_PCSYNC (1<<7)
82#define DRM_MODE_FLAG_NCSYNC (1<<8)
83#define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */
84#define DRM_MODE_FLAG_BCAST (1<<10) /* deprecated */
85#define DRM_MODE_FLAG_PIXMUX (1<<11) /* deprecated */
86#define DRM_MODE_FLAG_DBLCLK (1<<12)
87#define DRM_MODE_FLAG_CLKDIV2 (1<<13)
88 /*
89 * When adding a new stereo mode don't forget to adjust DRM_MODE_FLAGS_3D_MAX
90 * (define not exposed to user space).
91 */
92#define DRM_MODE_FLAG_3D_MASK (0x1f<<14)
93#define DRM_MODE_FLAG_3D_NONE (0<<14)
94#define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14)
95#define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14)
96#define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14)
97#define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14)
98#define DRM_MODE_FLAG_3D_L_DEPTH (5<<14)
99#define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14)
100#define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14)
101#define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14)
102
103/* Picture aspect ratio options */
104#define DRM_MODE_PICTURE_ASPECT_NONE 0
105#define DRM_MODE_PICTURE_ASPECT_4_3 1
106#define DRM_MODE_PICTURE_ASPECT_16_9 2
107#define DRM_MODE_PICTURE_ASPECT_64_27 3
108#define DRM_MODE_PICTURE_ASPECT_256_135 4
109
110/* Content type options */
111#define DRM_MODE_CONTENT_TYPE_NO_DATA 0
112#define DRM_MODE_CONTENT_TYPE_GRAPHICS 1
113#define DRM_MODE_CONTENT_TYPE_PHOTO 2
114#define DRM_MODE_CONTENT_TYPE_CINEMA 3
115#define DRM_MODE_CONTENT_TYPE_GAME 4
116
117/* Aspect ratio flag bitmask (4 bits 22:19) */
118#define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19)
119#define DRM_MODE_FLAG_PIC_AR_NONE \
120 (DRM_MODE_PICTURE_ASPECT_NONE<<19)
121#define DRM_MODE_FLAG_PIC_AR_4_3 \
122 (DRM_MODE_PICTURE_ASPECT_4_3<<19)
123#define DRM_MODE_FLAG_PIC_AR_16_9 \
124 (DRM_MODE_PICTURE_ASPECT_16_9<<19)
125#define DRM_MODE_FLAG_PIC_AR_64_27 \
126 (DRM_MODE_PICTURE_ASPECT_64_27<<19)
127#define DRM_MODE_FLAG_PIC_AR_256_135 \
128 (DRM_MODE_PICTURE_ASPECT_256_135<<19)
129
130#define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | \
131 DRM_MODE_FLAG_NHSYNC | \
132 DRM_MODE_FLAG_PVSYNC | \
133 DRM_MODE_FLAG_NVSYNC | \
134 DRM_MODE_FLAG_INTERLACE | \
135 DRM_MODE_FLAG_DBLSCAN | \
136 DRM_MODE_FLAG_CSYNC | \
137 DRM_MODE_FLAG_PCSYNC | \
138 DRM_MODE_FLAG_NCSYNC | \
139 DRM_MODE_FLAG_HSKEW | \
140 DRM_MODE_FLAG_DBLCLK | \
141 DRM_MODE_FLAG_CLKDIV2 | \
142 DRM_MODE_FLAG_3D_MASK)
143
144/* DPMS flags */
145/* bit compatible with the xorg definitions. */
146#define DRM_MODE_DPMS_ON 0
147#define DRM_MODE_DPMS_STANDBY 1
148#define DRM_MODE_DPMS_SUSPEND 2
149#define DRM_MODE_DPMS_OFF 3
150
151/* Scaling mode options */
152#define DRM_MODE_SCALE_NONE 0 /* Unmodified timing (display or
153 software can still scale) */
154#define DRM_MODE_SCALE_FULLSCREEN 1 /* Full screen, ignore aspect */
155#define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */
156#define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */
157
158/* Dithering mode options */
159#define DRM_MODE_DITHERING_OFF 0
160#define DRM_MODE_DITHERING_ON 1
161#define DRM_MODE_DITHERING_AUTO 2
162
163/* Dirty info options */
164#define DRM_MODE_DIRTY_OFF 0
165#define DRM_MODE_DIRTY_ON 1
166#define DRM_MODE_DIRTY_ANNOTATE 2
167
168/* Link Status options */
169#define DRM_MODE_LINK_STATUS_GOOD 0
170#define DRM_MODE_LINK_STATUS_BAD 1
171
172/* Panel type property */
173#define DRM_MODE_PANEL_TYPE_UNKNOWN 0
174#define DRM_MODE_PANEL_TYPE_OLED 1
175
176/*
177 * DRM_MODE_ROTATE_<degrees>
178 *
179 * Signals that a drm plane is been rotated <degrees> degrees in counter
180 * clockwise direction.
181 *
182 * This define is provided as a convenience, looking up the property id
183 * using the name->prop id lookup is the preferred method.
184 */
185#define DRM_MODE_ROTATE_0 (1<<0)
186#define DRM_MODE_ROTATE_90 (1<<1)
187#define DRM_MODE_ROTATE_180 (1<<2)
188#define DRM_MODE_ROTATE_270 (1<<3)
189
190/*
191 * DRM_MODE_ROTATE_MASK
192 *
193 * Bitmask used to look for drm plane rotations.
194 */
195#define DRM_MODE_ROTATE_MASK (\
196 DRM_MODE_ROTATE_0 | \
197 DRM_MODE_ROTATE_90 | \
198 DRM_MODE_ROTATE_180 | \
199 DRM_MODE_ROTATE_270)
200
201/*
202 * DRM_MODE_REFLECT_<axis>
203 *
204 * Signals that the contents of a drm plane is reflected along the <axis> axis,
205 * in the same way as mirroring.
206 * See kerneldoc chapter "Plane Composition Properties" for more details.
207 *
208 * This define is provided as a convenience, looking up the property id
209 * using the name->prop id lookup is the preferred method.
210 */
211#define DRM_MODE_REFLECT_X (1<<4)
212#define DRM_MODE_REFLECT_Y (1<<5)
213
214/*
215 * DRM_MODE_REFLECT_MASK
216 *
217 * Bitmask used to look for drm plane reflections.
218 */
219#define DRM_MODE_REFLECT_MASK (\
220 DRM_MODE_REFLECT_X | \
221 DRM_MODE_REFLECT_Y)
222
223/* Content Protection Flags */
224#define DRM_MODE_CONTENT_PROTECTION_UNDESIRED 0
225#define DRM_MODE_CONTENT_PROTECTION_DESIRED 1
226#define DRM_MODE_CONTENT_PROTECTION_ENABLED 2
227
228/**
229 * struct drm_mode_modeinfo - Display mode information.
230 * @clock: pixel clock in kHz
231 * @hdisplay: horizontal display size
232 * @hsync_start: horizontal sync start
233 * @hsync_end: horizontal sync end
234 * @htotal: horizontal total size
235 * @hskew: horizontal skew
236 * @vdisplay: vertical display size
237 * @vsync_start: vertical sync start
238 * @vsync_end: vertical sync end
239 * @vtotal: vertical total size
240 * @vscan: vertical scan
241 * @vrefresh: approximate vertical refresh rate in Hz
242 * @flags: bitmask of misc. flags, see DRM_MODE_FLAG_* defines
243 * @type: bitmask of type flags, see DRM_MODE_TYPE_* defines
244 * @name: string describing the mode resolution
245 *
246 * This is the user-space API display mode information structure. For the
247 * kernel version see struct drm_display_mode.
248 */
249struct drm_mode_modeinfo {
250 __u32 clock;
251 __u16 hdisplay;
252 __u16 hsync_start;
253 __u16 hsync_end;
254 __u16 htotal;
255 __u16 hskew;
256 __u16 vdisplay;
257 __u16 vsync_start;
258 __u16 vsync_end;
259 __u16 vtotal;
260 __u16 vscan;
261
262 __u32 vrefresh;
263
264 __u32 flags;
265 __u32 type;
266 char name[DRM_DISPLAY_MODE_LEN];
267};
268
269struct drm_mode_card_res {
270 __u64 fb_id_ptr;
271 __u64 crtc_id_ptr;
272 __u64 connector_id_ptr;
273 __u64 encoder_id_ptr;
274 __u32 count_fbs;
275 __u32 count_crtcs;
276 __u32 count_connectors;
277 __u32 count_encoders;
278 __u32 min_width;
279 __u32 max_width;
280 __u32 min_height;
281 __u32 max_height;
282};
283
284struct drm_mode_crtc {
285 __u64 set_connectors_ptr;
286 __u32 count_connectors;
287
288 __u32 crtc_id; /**< Id */
289 __u32 fb_id; /**< Id of framebuffer */
290
291 __u32 x; /**< x Position on the framebuffer */
292 __u32 y; /**< y Position on the framebuffer */
293
294 __u32 gamma_size;
295 __u32 mode_valid;
296 struct drm_mode_modeinfo mode;
297};
298
299#define DRM_MODE_PRESENT_TOP_FIELD (1<<0)
300#define DRM_MODE_PRESENT_BOTTOM_FIELD (1<<1)
301
302/* Planes blend with or override other bits on the CRTC */
303struct drm_mode_set_plane {
304 __u32 plane_id;
305 __u32 crtc_id;
306 __u32 fb_id; /* fb object contains surface format type */
307 __u32 flags; /* see above flags */
308
309 /* Signed dest location allows it to be partially off screen */
310 __s32 crtc_x;
311 __s32 crtc_y;
312 __u32 crtc_w;
313 __u32 crtc_h;
314
315 /* Source values are 16.16 fixed point */
316 __u32 src_x;
317 __u32 src_y;
318 __u32 src_h;
319 __u32 src_w;
320};
321
322/**
323 * struct drm_mode_get_plane - Get plane metadata.
324 *
325 * Userspace can perform a GETPLANE ioctl to retrieve information about a
326 * plane.
327 *
328 * To retrieve the number of formats supported, set @count_format_types to zero
329 * and call the ioctl. @count_format_types will be updated with the value.
330 *
331 * To retrieve these formats, allocate an array with the memory needed to store
332 * @count_format_types formats. Point @format_type_ptr to this array and call
333 * the ioctl again (with @count_format_types still set to the value returned in
334 * the first ioctl call).
335 */
336struct drm_mode_get_plane {
337 /**
338 * @plane_id: Object ID of the plane whose information should be
339 * retrieved. Set by caller.
340 */
341 __u32 plane_id;
342
343 /** @crtc_id: Object ID of the current CRTC. */
344 __u32 crtc_id;
345 /** @fb_id: Object ID of the current fb. */
346 __u32 fb_id;
347
348 /**
349 * @possible_crtcs: Bitmask of CRTC's compatible with the plane. CRTC's
350 * are created and they receive an index, which corresponds to their
351 * position in the bitmask. Bit N corresponds to
352 * :ref:`CRTC index<crtc_index>` N.
353 */
354 __u32 possible_crtcs;
355 /** @gamma_size: Never used. */
356 __u32 gamma_size;
357
358 /** @count_format_types: Number of formats. */
359 __u32 count_format_types;
360 /**
361 * @format_type_ptr: Pointer to ``__u32`` array of formats that are
362 * supported by the plane. These formats do not require modifiers.
363 */
364 __u64 format_type_ptr;
365};
366
367struct drm_mode_get_plane_res {
368 __u64 plane_id_ptr;
369 __u32 count_planes;
370};
371
372#define DRM_MODE_ENCODER_NONE 0
373#define DRM_MODE_ENCODER_DAC 1
374#define DRM_MODE_ENCODER_TMDS 2
375#define DRM_MODE_ENCODER_LVDS 3
376#define DRM_MODE_ENCODER_TVDAC 4
377#define DRM_MODE_ENCODER_VIRTUAL 5
378#define DRM_MODE_ENCODER_DSI 6
379#define DRM_MODE_ENCODER_DPMST 7
380#define DRM_MODE_ENCODER_DPI 8
381
382struct drm_mode_get_encoder {
383 __u32 encoder_id;
384 __u32 encoder_type;
385
386 __u32 crtc_id; /**< Id of crtc */
387
388 __u32 possible_crtcs;
389 __u32 possible_clones;
390};
391
392/* This is for connectors with multiple signal types. */
393/* Try to match DRM_MODE_CONNECTOR_X as closely as possible. */
394enum drm_mode_subconnector {
395 DRM_MODE_SUBCONNECTOR_Automatic = 0, /* DVI-I, TV */
396 DRM_MODE_SUBCONNECTOR_Unknown = 0, /* DVI-I, TV, DP */
397 DRM_MODE_SUBCONNECTOR_VGA = 1, /* DP */
398 DRM_MODE_SUBCONNECTOR_DVID = 3, /* DVI-I DP */
399 DRM_MODE_SUBCONNECTOR_DVIA = 4, /* DVI-I */
400 DRM_MODE_SUBCONNECTOR_Composite = 5, /* TV */
401 DRM_MODE_SUBCONNECTOR_SVIDEO = 6, /* TV */
402 DRM_MODE_SUBCONNECTOR_Component = 8, /* TV */
403 DRM_MODE_SUBCONNECTOR_SCART = 9, /* TV */
404 DRM_MODE_SUBCONNECTOR_DisplayPort = 10, /* DP */
405 DRM_MODE_SUBCONNECTOR_HDMIA = 11, /* DP */
406 DRM_MODE_SUBCONNECTOR_Native = 15, /* DP */
407 DRM_MODE_SUBCONNECTOR_Wireless = 18, /* DP */
408};
409
410#define DRM_MODE_CONNECTOR_Unknown 0
411#define DRM_MODE_CONNECTOR_VGA 1
412#define DRM_MODE_CONNECTOR_DVII 2
413#define DRM_MODE_CONNECTOR_DVID 3
414#define DRM_MODE_CONNECTOR_DVIA 4
415#define DRM_MODE_CONNECTOR_Composite 5
416#define DRM_MODE_CONNECTOR_SVIDEO 6
417#define DRM_MODE_CONNECTOR_LVDS 7
418#define DRM_MODE_CONNECTOR_Component 8
419#define DRM_MODE_CONNECTOR_9PinDIN 9
420#define DRM_MODE_CONNECTOR_DisplayPort 10
421#define DRM_MODE_CONNECTOR_HDMIA 11
422#define DRM_MODE_CONNECTOR_HDMIB 12
423#define DRM_MODE_CONNECTOR_TV 13
424#define DRM_MODE_CONNECTOR_eDP 14
425#define DRM_MODE_CONNECTOR_VIRTUAL 15
426#define DRM_MODE_CONNECTOR_DSI 16
427#define DRM_MODE_CONNECTOR_DPI 17
428#define DRM_MODE_CONNECTOR_WRITEBACK 18
429#define DRM_MODE_CONNECTOR_SPI 19
430#define DRM_MODE_CONNECTOR_USB 20
431
432/**
433 * struct drm_mode_get_connector - Get connector metadata.
434 *
435 * User-space can perform a GETCONNECTOR ioctl to retrieve information about a
436 * connector. User-space is expected to retrieve encoders, modes and properties
437 * by performing this ioctl at least twice: the first time to retrieve the
438 * number of elements, the second time to retrieve the elements themselves.
439 *
440 * To retrieve the number of elements, set @count_props and @count_encoders to
441 * zero, set @count_modes to 1, and set @modes_ptr to a temporary struct
442 * drm_mode_modeinfo element.
443 *
444 * To retrieve the elements, allocate arrays for @encoders_ptr, @modes_ptr,
445 * @props_ptr and @prop_values_ptr, then set @count_modes, @count_props and
446 * @count_encoders to their capacity.
447 *
448 * Performing the ioctl only twice may be racy: the number of elements may have
449 * changed with a hotplug event in-between the two ioctls. User-space is
450 * expected to retry the last ioctl until the number of elements stabilizes.
451 * The kernel won't fill any array which doesn't have the expected length.
452 *
453 * **Force-probing a connector**
454 *
455 * If the @count_modes field is set to zero and the DRM client is the current
456 * DRM master, the kernel will perform a forced probe on the connector to
457 * refresh the connector status, modes and EDID. A forced-probe can be slow,
458 * might cause flickering and the ioctl will block.
459 *
460 * User-space needs to force-probe connectors to ensure their metadata is
461 * up-to-date at startup and after receiving a hot-plug event. User-space
462 * may perform a forced-probe when the user explicitly requests it. User-space
463 * shouldn't perform a forced-probe in other situations.
464 */
465struct drm_mode_get_connector {
466 /** @encoders_ptr: Pointer to ``__u32`` array of object IDs. */
467 __u64 encoders_ptr;
468 /** @modes_ptr: Pointer to struct drm_mode_modeinfo array. */
469 __u64 modes_ptr;
470 /** @props_ptr: Pointer to ``__u32`` array of property IDs. */
471 __u64 props_ptr;
472 /** @prop_values_ptr: Pointer to ``__u64`` array of property values. */
473 __u64 prop_values_ptr;
474
475 /** @count_modes: Number of modes. */
476 __u32 count_modes;
477 /** @count_props: Number of properties. */
478 __u32 count_props;
479 /** @count_encoders: Number of encoders. */
480 __u32 count_encoders;
481
482 /** @encoder_id: Object ID of the current encoder. */
483 __u32 encoder_id;
484 /** @connector_id: Object ID of the connector. */
485 __u32 connector_id;
486 /**
487 * @connector_type: Type of the connector.
488 *
489 * See DRM_MODE_CONNECTOR_* defines.
490 */
491 __u32 connector_type;
492 /**
493 * @connector_type_id: Type-specific connector number.
494 *
495 * This is not an object ID. This is a per-type connector number. Each
496 * (type, type_id) combination is unique across all connectors of a DRM
497 * device.
498 *
499 * The (type, type_id) combination is not a stable identifier: the
500 * type_id can change depending on the driver probe order.
501 */
502 __u32 connector_type_id;
503
504 /**
505 * @connection: Status of the connector.
506 *
507 * See enum drm_connector_status.
508 */
509 __u32 connection;
510 /** @mm_width: Width of the connected sink in millimeters. */
511 __u32 mm_width;
512 /** @mm_height: Height of the connected sink in millimeters. */
513 __u32 mm_height;
514 /**
515 * @subpixel: Subpixel order of the connected sink.
516 *
517 * See enum subpixel_order.
518 */
519 __u32 subpixel;
520
521 /** @pad: Padding, must be zero. */
522 __u32 pad;
523};
524
525#define DRM_MODE_PROP_PENDING (1<<0) /* deprecated, do not use */
526#define DRM_MODE_PROP_RANGE (1<<1)
527#define DRM_MODE_PROP_IMMUTABLE (1<<2)
528#define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
529#define DRM_MODE_PROP_BLOB (1<<4)
530#define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */
531
532/* non-extended types: legacy bitmask, one bit per type: */
533#define DRM_MODE_PROP_LEGACY_TYPE ( \
534 DRM_MODE_PROP_RANGE | \
535 DRM_MODE_PROP_ENUM | \
536 DRM_MODE_PROP_BLOB | \
537 DRM_MODE_PROP_BITMASK)
538
539/* extended-types: rather than continue to consume a bit per type,
540 * grab a chunk of the bits to use as integer type id.
541 */
542#define DRM_MODE_PROP_EXTENDED_TYPE 0x0000ffc0
543#define DRM_MODE_PROP_TYPE(n) ((n) << 6)
544#define DRM_MODE_PROP_OBJECT DRM_MODE_PROP_TYPE(1)
545#define DRM_MODE_PROP_SIGNED_RANGE DRM_MODE_PROP_TYPE(2)
546
547/* the PROP_ATOMIC flag is used to hide properties from userspace that
548 * is not aware of atomic properties. This is mostly to work around
549 * older userspace (DDX drivers) that read/write each prop they find,
550 * without being aware that this could be triggering a lengthy modeset.
551 */
552#define DRM_MODE_PROP_ATOMIC 0x80000000
553
554/**
555 * struct drm_mode_property_enum - Description for an enum/bitfield entry.
556 * @value: numeric value for this enum entry.
557 * @name: symbolic name for this enum entry.
558 *
559 * See struct drm_property_enum for details.
560 */
561struct drm_mode_property_enum {
562 __u64 value;
563 char name[DRM_PROP_NAME_LEN];
564};
565
566/**
567 * struct drm_mode_get_property - Get property metadata.
568 *
569 * User-space can perform a GETPROPERTY ioctl to retrieve information about a
570 * property. The same property may be attached to multiple objects, see
571 * "Modeset Base Object Abstraction".
572 *
573 * The meaning of the @values_ptr field changes depending on the property type.
574 * See &drm_property.flags for more details.
575 *
576 * The @enum_blob_ptr and @count_enum_blobs fields are only meaningful when the
577 * property has the type &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK. For
578 * backwards compatibility, the kernel will always set @count_enum_blobs to
579 * zero when the property has the type &DRM_MODE_PROP_BLOB. User-space must
580 * ignore these two fields if the property has a different type.
581 *
582 * User-space is expected to retrieve values and enums by performing this ioctl
583 * at least twice: the first time to retrieve the number of elements, the
584 * second time to retrieve the elements themselves.
585 *
586 * To retrieve the number of elements, set @count_values and @count_enum_blobs
587 * to zero, then call the ioctl. @count_values will be updated with the number
588 * of elements. If the property has the type &DRM_MODE_PROP_ENUM or
589 * &DRM_MODE_PROP_BITMASK, @count_enum_blobs will be updated as well.
590 *
591 * To retrieve the elements themselves, allocate an array for @values_ptr and
592 * set @count_values to its capacity. If the property has the type
593 * &DRM_MODE_PROP_ENUM or &DRM_MODE_PROP_BITMASK, allocate an array for
594 * @enum_blob_ptr and set @count_enum_blobs to its capacity. Calling the ioctl
595 * again will fill the arrays.
596 */
597struct drm_mode_get_property {
598 /** @values_ptr: Pointer to a ``__u64`` array. */
599 __u64 values_ptr;
600 /** @enum_blob_ptr: Pointer to a struct drm_mode_property_enum array. */
601 __u64 enum_blob_ptr;
602
603 /**
604 * @prop_id: Object ID of the property which should be retrieved. Set
605 * by the caller.
606 */
607 __u32 prop_id;
608 /**
609 * @flags: ``DRM_MODE_PROP_*`` bitfield. See &drm_property.flags for
610 * a definition of the flags.
611 */
612 __u32 flags;
613 /**
614 * @name: Symbolic property name. User-space should use this field to
615 * recognize properties.
616 */
617 char name[DRM_PROP_NAME_LEN];
618
619 /** @count_values: Number of elements in @values_ptr. */
620 __u32 count_values;
621 /** @count_enum_blobs: Number of elements in @enum_blob_ptr. */
622 __u32 count_enum_blobs;
623};
624
625struct drm_mode_connector_set_property {
626 __u64 value;
627 __u32 prop_id;
628 __u32 connector_id;
629};
630
631#define DRM_MODE_OBJECT_CRTC 0xcccccccc
632#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
633#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
634#define DRM_MODE_OBJECT_MODE 0xdededede
635#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
636#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
637#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
638#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
639#define DRM_MODE_OBJECT_COLOROP 0xfafafafa
640#define DRM_MODE_OBJECT_ANY 0
641
642struct drm_mode_obj_get_properties {
643 __u64 props_ptr;
644 __u64 prop_values_ptr;
645 __u32 count_props;
646 __u32 obj_id;
647 __u32 obj_type;
648};
649
650struct drm_mode_obj_set_property {
651 __u64 value;
652 __u32 prop_id;
653 __u32 obj_id;
654 __u32 obj_type;
655};
656
657struct drm_mode_get_blob {
658 __u32 blob_id;
659 __u32 length;
660 __u64 data;
661};
662
663struct drm_mode_fb_cmd {
664 __u32 fb_id;
665 __u32 width;
666 __u32 height;
667 __u32 pitch;
668 __u32 bpp;
669 __u32 depth;
670 /* driver specific handle */
671 __u32 handle;
672};
673
674#define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */
675#define DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifier[] */
676
677/**
678 * struct drm_mode_fb_cmd2 - Frame-buffer metadata.
679 *
680 * This struct holds frame-buffer metadata. There are two ways to use it:
681 *
682 * - User-space can fill this struct and perform a &DRM_IOCTL_MODE_ADDFB2
683 * ioctl to register a new frame-buffer. The new frame-buffer object ID will
684 * be set by the kernel in @fb_id.
685 * - User-space can set @fb_id and perform a &DRM_IOCTL_MODE_GETFB2 ioctl to
686 * fetch metadata about an existing frame-buffer.
687 *
688 * In case of planar formats, this struct allows up to 4 buffer objects with
689 * offsets and pitches per plane. The pitch and offset order are dictated by
690 * the format FourCC as defined by ``drm_fourcc.h``, e.g. NV12 is described as:
691 *
692 * YUV 4:2:0 image with a plane of 8-bit Y samples followed by an
693 * interleaved U/V plane containing 8-bit 2x2 subsampled colour difference
694 * samples.
695 *
696 * So it would consist of a Y plane at ``offsets[0]`` and a UV plane at
697 * ``offsets[1]``.
698 *
699 * To accommodate tiled, compressed, etc formats, a modifier can be specified.
700 * For more information see the "Format Modifiers" section. Note that even
701 * though it looks like we have a modifier per-plane, we in fact do not. The
702 * modifier for each plane must be identical. Thus all combinations of
703 * different data layouts for multi-plane formats must be enumerated as
704 * separate modifiers.
705 *
706 * All of the entries in @handles, @pitches, @offsets and @modifier must be
707 * zero when unused. Warning, for @offsets and @modifier zero can't be used to
708 * figure out whether the entry is used or not since it's a valid value (a zero
709 * offset is common, and a zero modifier is &DRM_FORMAT_MOD_LINEAR).
710 */
711struct drm_mode_fb_cmd2 {
712 /** @fb_id: Object ID of the frame-buffer. */
713 __u32 fb_id;
714 /** @width: Width of the frame-buffer. */
715 __u32 width;
716 /** @height: Height of the frame-buffer. */
717 __u32 height;
718 /**
719 * @pixel_format: FourCC format code, see ``DRM_FORMAT_*`` constants in
720 * ``drm_fourcc.h``.
721 */
722 __u32 pixel_format;
723 /**
724 * @flags: Frame-buffer flags (see &DRM_MODE_FB_INTERLACED and
725 * &DRM_MODE_FB_MODIFIERS).
726 */
727 __u32 flags;
728
729 /**
730 * @handles: GEM buffer handle, one per plane. Set to 0 if the plane is
731 * unused. The same handle can be used for multiple planes.
732 */
733 __u32 handles[4];
734 /** @pitches: Pitch (aka. stride) in bytes, one per plane. */
735 __u32 pitches[4];
736 /** @offsets: Offset into the buffer in bytes, one per plane. */
737 __u32 offsets[4];
738 /**
739 * @modifier: Format modifier, one per plane. See ``DRM_FORMAT_MOD_*``
740 * constants in ``drm_fourcc.h``. All planes must use the same
741 * modifier. Ignored unless &DRM_MODE_FB_MODIFIERS is set in @flags.
742 */
743 __u64 modifier[4];
744};
745
746#define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
747#define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
748#define DRM_MODE_FB_DIRTY_FLAGS 0x03
749
750#define DRM_MODE_FB_DIRTY_MAX_CLIPS 256
751
752/*
753 * Mark a region of a framebuffer as dirty.
754 *
755 * Some hardware does not automatically update display contents
756 * as a hardware or software draw to a framebuffer. This ioctl
757 * allows userspace to tell the kernel and the hardware what
758 * regions of the framebuffer have changed.
759 *
760 * The kernel or hardware is free to update more then just the
761 * region specified by the clip rects. The kernel or hardware
762 * may also delay and/or coalesce several calls to dirty into a
763 * single update.
764 *
765 * Userspace may annotate the updates, the annotates are a
766 * promise made by the caller that the change is either a copy
767 * of pixels or a fill of a single color in the region specified.
768 *
769 * If the DRM_MODE_FB_DIRTY_ANNOTATE_COPY flag is given then
770 * the number of updated regions are half of num_clips given,
771 * where the clip rects are paired in src and dst. The width and
772 * height of each one of the pairs must match.
773 *
774 * If the DRM_MODE_FB_DIRTY_ANNOTATE_FILL flag is given the caller
775 * promises that the region specified of the clip rects is filled
776 * completely with a single color as given in the color argument.
777 */
778
779struct drm_mode_fb_dirty_cmd {
780 __u32 fb_id;
781 __u32 flags;
782 __u32 color;
783 __u32 num_clips;
784 __u64 clips_ptr;
785};
786
787struct drm_mode_mode_cmd {
788 __u32 connector_id;
789 struct drm_mode_modeinfo mode;
790};
791
792#define DRM_MODE_CURSOR_BO 0x01
793#define DRM_MODE_CURSOR_MOVE 0x02
794#define DRM_MODE_CURSOR_FLAGS 0x03
795
796/*
797 * depending on the value in flags different members are used.
798 *
799 * CURSOR_BO uses
800 * crtc_id
801 * width
802 * height
803 * handle - if 0 turns the cursor off
804 *
805 * CURSOR_MOVE uses
806 * crtc_id
807 * x
808 * y
809 */
810struct drm_mode_cursor {
811 __u32 flags;
812 __u32 crtc_id;
813 __s32 x;
814 __s32 y;
815 __u32 width;
816 __u32 height;
817 /* driver specific handle */
818 __u32 handle;
819};
820
821struct drm_mode_cursor2 {
822 __u32 flags;
823 __u32 crtc_id;
824 __s32 x;
825 __s32 y;
826 __u32 width;
827 __u32 height;
828 /* driver specific handle */
829 __u32 handle;
830 __s32 hot_x;
831 __s32 hot_y;
832};
833
834struct drm_mode_crtc_lut {
835 __u32 crtc_id;
836 __u32 gamma_size;
837
838 /* pointers to arrays */
839 __u64 red;
840 __u64 green;
841 __u64 blue;
842};
843
844struct drm_color_ctm {
845 /*
846 * Conversion matrix in S31.32 sign-magnitude
847 * (not two's complement!) format.
848 *
849 * out matrix in
850 * |R| |0 1 2| |R|
851 * |G| = |3 4 5| x |G|
852 * |B| |6 7 8| |B|
853 */
854 __u64 matrix[9];
855};
856
857struct drm_color_ctm_3x4 {
858 /*
859 * Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude
860 * (not two's complement!) format.
861 *
862 * out matrix in
863 * |R| |0 1 2 3 | | R |
864 * |G| = |4 5 6 7 | x | G |
865 * |B| |8 9 10 11| | B |
866 * |1.0|
867 */
868 __u64 matrix[12];
869};
870
871struct drm_color_lut {
872 /*
873 * Values are mapped linearly to 0.0 - 1.0 range, with 0x0 == 0.0 and
874 * 0xffff == 1.0.
875 */
876 __u16 red;
877 __u16 green;
878 __u16 blue;
879 __u16 reserved;
880};
881
882/*
883 * struct drm_color_lut32
884 *
885 * 32-bit per channel color LUT entry, similar to drm_color_lut.
886 */
887struct drm_color_lut32 {
888 __u32 red;
889 __u32 green;
890 __u32 blue;
891 __u32 reserved;
892};
893
894/**
895 * enum drm_colorop_type - Type of color operation
896 *
897 * drm_colorops can be of many different types. Each type behaves differently
898 * and defines a different set of properties. This enum defines all types and
899 * gives a high-level description.
900 */
901enum drm_colorop_type {
902 /**
903 * @DRM_COLOROP_1D_CURVE:
904 *
905 * enum string "1D Curve"
906 *
907 * A 1D curve that is being applied to all color channels. The
908 * curve is specified via the CURVE_1D_TYPE colorop property.
909 */
910 DRM_COLOROP_1D_CURVE,
911
912 /**
913 * @DRM_COLOROP_1D_LUT:
914 *
915 * enum string "1D LUT"
916 *
917 * A simple 1D LUT of uniformly spaced &drm_color_lut32 entries,
918 * packed into a blob via the DATA property. The driver's
919 * expected LUT size is advertised via the SIZE property.
920 *
921 * The DATA blob is an array of struct drm_color_lut32 with size
922 * of "size".
923 */
924 DRM_COLOROP_1D_LUT,
925
926 /**
927 * @DRM_COLOROP_CTM_3X4:
928 *
929 * enum string "3x4 Matrix"
930 *
931 * A 3x4 matrix. Its values are specified via the
932 * &drm_color_ctm_3x4 struct provided via the DATA property.
933 *
934 * The DATA blob is a float[12]:
935 * out matrix in
936 * | R | | 0 1 2 3 | | R |
937 * | G | = | 4 5 6 7 | x | G |
938 * | B | | 8 9 10 12 | | B |
939 */
940 DRM_COLOROP_CTM_3X4,
941
942 /**
943 * @DRM_COLOROP_MULTIPLIER:
944 *
945 * enum string "Multiplier"
946 *
947 * A simple multiplier, applied to all color values. The
948 * multiplier is specified as a S31.32 via the MULTIPLIER
949 * property.
950 */
951 DRM_COLOROP_MULTIPLIER,
952
953 /**
954 * @DRM_COLOROP_3D_LUT:
955 *
956 * enum string "3D LUT"
957 *
958 * A 3D LUT of &drm_color_lut32 entries,
959 * packed into a blob via the DATA property. The driver's expected
960 * LUT size is advertised via the SIZE property, i.e., a 3D LUT with
961 * 17x17x17 entries will have SIZE set to 17.
962 *
963 * The DATA blob is a 3D array of struct drm_color_lut32 with dimension
964 * length of "size".
965 * The LUT elements are traversed like so:
966 *
967 * for B in range 0..n
968 * for G in range 0..n
969 * for R in range 0..n
970 * index = R + n * (G + n * B)
971 * color = lut3d[index]
972 */
973 DRM_COLOROP_3D_LUT,
974};
975
976/**
977 * enum drm_colorop_lut3d_interpolation_type - type of 3DLUT interpolation
978 */
979enum drm_colorop_lut3d_interpolation_type {
980 /**
981 * @DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL:
982 *
983 * Tetrahedral 3DLUT interpolation
984 */
985 DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL,
986};
987
988/**
989 * enum drm_colorop_lut1d_interpolation_type - type of interpolation for 1D LUTs
990 */
991enum drm_colorop_lut1d_interpolation_type {
992 /**
993 * @DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR:
994 *
995 * Linear interpolation. Values between points of the LUT will be
996 * linearly interpolated.
997 */
998 DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
999};
1000
1001/**
1002 * struct drm_plane_size_hint - Plane size hints
1003 * @width: The width of the plane in pixel
1004 * @height: The height of the plane in pixel
1005 *
1006 * The plane SIZE_HINTS property blob contains an
1007 * array of struct drm_plane_size_hint.
1008 */
1009struct drm_plane_size_hint {
1010 __u16 width;
1011 __u16 height;
1012};
1013
1014/**
1015 * struct hdr_metadata_infoframe - HDR Metadata Infoframe Data.
1016 *
1017 * HDR Metadata Infoframe as per CTA 861.G spec. This is expected
1018 * to match exactly with the spec.
1019 *
1020 * Userspace is expected to pass the metadata information as per
1021 * the format described in this structure.
1022 */
1023struct hdr_metadata_infoframe {
1024 /**
1025 * @eotf: Electro-Optical Transfer Function (EOTF)
1026 * used in the stream.
1027 */
1028 __u8 eotf;
1029 /**
1030 * @metadata_type: Static_Metadata_Descriptor_ID.
1031 */
1032 __u8 metadata_type;
1033 /**
1034 * @display_primaries: Color Primaries of the Data.
1035 * These are coded as unsigned 16-bit values in units of
1036 * 0.00002, where 0x0000 represents zero and 0xC350
1037 * represents 1.0000.
1038 * @display_primaries.x: X coordinate of color primary.
1039 * @display_primaries.y: Y coordinate of color primary.
1040 */
1041 struct {
1042 __u16 x, y;
1043 } display_primaries[3];
1044 /**
1045 * @white_point: White Point of Colorspace Data.
1046 * These are coded as unsigned 16-bit values in units of
1047 * 0.00002, where 0x0000 represents zero and 0xC350
1048 * represents 1.0000.
1049 * @white_point.x: X coordinate of whitepoint of color primary.
1050 * @white_point.y: Y coordinate of whitepoint of color primary.
1051 */
1052 struct {
1053 __u16 x, y;
1054 } white_point;
1055 /**
1056 * @max_display_mastering_luminance: Max Mastering Display Luminance.
1057 * This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
1058 * where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
1059 */
1060 __u16 max_display_mastering_luminance;
1061 /**
1062 * @min_display_mastering_luminance: Min Mastering Display Luminance.
1063 * This value is coded as an unsigned 16-bit value in units of
1064 * 0.0001 cd/m2, where 0x0001 represents 0.0001 cd/m2 and 0xFFFF
1065 * represents 6.5535 cd/m2.
1066 */
1067 __u16 min_display_mastering_luminance;
1068 /**
1069 * @max_cll: Max Content Light Level.
1070 * This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
1071 * where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
1072 */
1073 __u16 max_cll;
1074 /**
1075 * @max_fall: Max Frame Average Light Level.
1076 * This value is coded as an unsigned 16-bit value in units of 1 cd/m2,
1077 * where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.
1078 */
1079 __u16 max_fall;
1080};
1081
1082/**
1083 * struct hdr_output_metadata - HDR output metadata
1084 *
1085 * Metadata Information to be passed from userspace
1086 */
1087struct hdr_output_metadata {
1088 /**
1089 * @metadata_type: Static_Metadata_Descriptor_ID.
1090 */
1091 __u32 metadata_type;
1092 /**
1093 * @hdmi_metadata_type1: HDR Metadata Infoframe.
1094 */
1095 union {
1096 struct hdr_metadata_infoframe hdmi_metadata_type1;
1097 };
1098};
1099
1100/**
1101 * DRM_MODE_PAGE_FLIP_EVENT
1102 *
1103 * Request that the kernel sends back a vblank event (see
1104 * struct drm_event_vblank) with the &DRM_EVENT_FLIP_COMPLETE type when the
1105 * page-flip is done.
1106 *
1107 * When used with atomic uAPI, one event will be delivered per CRTC included in
1108 * the atomic commit. A CRTC is included in an atomic commit if one of its
1109 * properties is set, or if a property is set on a connector or plane linked
1110 * via the CRTC_ID property to the CRTC. At least one CRTC must be included,
1111 * and all pulled in CRTCs must be either previously or newly powered on (in
1112 * other words, a powered off CRTC which stays off cannot be included in the
1113 * atomic commit).
1114 */
1115#define DRM_MODE_PAGE_FLIP_EVENT 0x01
1116/**
1117 * DRM_MODE_PAGE_FLIP_ASYNC
1118 *
1119 * Request that the page-flip is performed as soon as possible, ie. with no
1120 * delay due to waiting for vblank. This may cause tearing to be visible on
1121 * the screen.
1122 *
1123 * When used with atomic uAPI, the driver will return an error if the hardware
1124 * doesn't support performing an asynchronous page-flip for this update.
1125 * User-space should handle this, e.g. by falling back to a regular page-flip.
1126 *
1127 * Note, some hardware might need to perform one last synchronous page-flip
1128 * before being able to switch to asynchronous page-flips. As an exception,
1129 * the driver will return success even though that first page-flip is not
1130 * asynchronous.
1131 */
1132#define DRM_MODE_PAGE_FLIP_ASYNC 0x02
1133#define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
1134#define DRM_MODE_PAGE_FLIP_TARGET_RELATIVE 0x8
1135#define DRM_MODE_PAGE_FLIP_TARGET (DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE | \
1136 DRM_MODE_PAGE_FLIP_TARGET_RELATIVE)
1137/**
1138 * DRM_MODE_PAGE_FLIP_FLAGS
1139 *
1140 * Bitmask of flags suitable for &drm_mode_crtc_page_flip_target.flags.
1141 */
1142#define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT | \
1143 DRM_MODE_PAGE_FLIP_ASYNC | \
1144 DRM_MODE_PAGE_FLIP_TARGET)
1145
1146/*
1147 * Request a page flip on the specified crtc.
1148 *
1149 * This ioctl will ask KMS to schedule a page flip for the specified
1150 * crtc. Once any pending rendering targeting the specified fb (as of
1151 * ioctl time) has completed, the crtc will be reprogrammed to display
1152 * that fb after the next vertical refresh. The ioctl returns
1153 * immediately, but subsequent rendering to the current fb will block
1154 * in the execbuffer ioctl until the page flip happens. If a page
1155 * flip is already pending as the ioctl is called, EBUSY will be
1156 * returned.
1157 *
1158 * Flag DRM_MODE_PAGE_FLIP_EVENT requests that drm sends back a vblank
1159 * event (see drm.h: struct drm_event_vblank) when the page flip is
1160 * done. The user_data field passed in with this ioctl will be
1161 * returned as the user_data field in the vblank event struct.
1162 *
1163 * Flag DRM_MODE_PAGE_FLIP_ASYNC requests that the flip happen
1164 * 'as soon as possible', meaning that it not delay waiting for vblank.
1165 * This may cause tearing on the screen.
1166 *
1167 * The reserved field must be zero.
1168 */
1169
1170struct drm_mode_crtc_page_flip {
1171 __u32 crtc_id;
1172 __u32 fb_id;
1173 __u32 flags;
1174 __u32 reserved;
1175 __u64 user_data;
1176};
1177
1178/*
1179 * Request a page flip on the specified crtc.
1180 *
1181 * Same as struct drm_mode_crtc_page_flip, but supports new flags and
1182 * re-purposes the reserved field:
1183 *
1184 * The sequence field must be zero unless either of the
1185 * DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags is specified. When
1186 * the ABSOLUTE flag is specified, the sequence field denotes the absolute
1187 * vblank sequence when the flip should take effect. When the RELATIVE
1188 * flag is specified, the sequence field denotes the relative (to the
1189 * current one when the ioctl is called) vblank sequence when the flip
1190 * should take effect. NOTE: DRM_IOCTL_WAIT_VBLANK must still be used to
1191 * make sure the vblank sequence before the target one has passed before
1192 * calling this ioctl. The purpose of the
1193 * DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags is merely to clarify
1194 * the target for when code dealing with a page flip runs during a
1195 * vertical blank period.
1196 */
1197
1198struct drm_mode_crtc_page_flip_target {
1199 __u32 crtc_id;
1200 __u32 fb_id;
1201 __u32 flags;
1202 __u32 sequence;
1203 __u64 user_data;
1204};
1205
1206/**
1207 * struct drm_mode_create_dumb - Create a KMS dumb buffer for scanout.
1208 * @height: buffer height in pixels
1209 * @width: buffer width in pixels
1210 * @bpp: color mode
1211 * @flags: must be zero
1212 * @handle: buffer object handle
1213 * @pitch: number of bytes between two consecutive lines
1214 * @size: size of the whole buffer in bytes
1215 *
1216 * User-space fills @height, @width, @bpp and @flags. If the IOCTL succeeds,
1217 * the kernel fills @handle, @pitch and @size.
1218 *
1219 * The value of @bpp is a color-mode number describing a specific format
1220 * or a variant thereof. The value often corresponds to the number of bits
1221 * per pixel for most modes, although there are exceptions. Each color mode
1222 * maps to a DRM format plus a number of modes with similar pixel layout.
1223 * Framebuffer layout is always linear.
1224 *
1225 * Support for all modes and formats is optional. Even if dumb-buffer
1226 * creation with a certain color mode succeeds, it is not guaranteed that
1227 * the DRM driver supports any of the related formats. Most drivers support
1228 * a color mode of 32 with a format of DRM_FORMAT_XRGB8888 on their primary
1229 * plane.
1230 *
1231 * +------------+------------------------+------------------------+
1232 * | Color mode | Framebuffer format | Compatible formats |
1233 * +============+========================+========================+
1234 * | 32 | * DRM_FORMAT_XRGB8888 | * DRM_FORMAT_BGRX8888 |
1235 * | | | * DRM_FORMAT_RGBX8888 |
1236 * | | | * DRM_FORMAT_XBGR8888 |
1237 * +------------+------------------------+------------------------+
1238 * | 24 | * DRM_FORMAT_RGB888 | * DRM_FORMAT_BGR888 |
1239 * +------------+------------------------+------------------------+
1240 * | 16 | * DRM_FORMAT_RGB565 | * DRM_FORMAT_BGR565 |
1241 * +------------+------------------------+------------------------+
1242 * | 15 | * DRM_FORMAT_XRGB1555 | * DRM_FORMAT_BGRX1555 |
1243 * | | | * DRM_FORMAT_RGBX1555 |
1244 * | | | * DRM_FORMAT_XBGR1555 |
1245 * +------------+------------------------+------------------------+
1246 * | 8 | * DRM_FORMAT_C8 | * DRM_FORMAT_D8 |
1247 * | | | * DRM_FORMAT_R8 |
1248 * +------------+------------------------+------------------------+
1249 * | 4 | * DRM_FORMAT_C4 | * DRM_FORMAT_D4 |
1250 * | | | * DRM_FORMAT_R4 |
1251 * +------------+------------------------+------------------------+
1252 * | 2 | * DRM_FORMAT_C2 | * DRM_FORMAT_D2 |
1253 * | | | * DRM_FORMAT_R2 |
1254 * +------------+------------------------+------------------------+
1255 * | 1 | * DRM_FORMAT_C1 | * DRM_FORMAT_D1 |
1256 * | | | * DRM_FORMAT_R1 |
1257 * +------------+------------------------+------------------------+
1258 *
1259 * Color modes of 10, 12, 15, 30 and 64 are only supported for use by
1260 * legacy user space. Please don't use them in new code. Other modes
1261 * are not support.
1262 *
1263 * Do not attempt to allocate anything but linear framebuffer memory
1264 * with single-plane RGB data. Allocation of other framebuffer
1265 * layouts requires dedicated ioctls in the respective DRM driver.
1266 */
1267struct drm_mode_create_dumb {
1268 __u32 height;
1269 __u32 width;
1270 __u32 bpp;
1271 __u32 flags;
1272
1273 __u32 handle;
1274 __u32 pitch;
1275 __u64 size;
1276};
1277
1278/* set up for mmap of a dumb scanout buffer */
1279struct drm_mode_map_dumb {
1280 /** Handle for the object being mapped. */
1281 __u32 handle;
1282 __u32 pad;
1283 /**
1284 * Fake offset to use for subsequent mmap call
1285 *
1286 * This is a fixed-size type for 32/64 compatibility.
1287 */
1288 __u64 offset;
1289};
1290
1291struct drm_mode_destroy_dumb {
1292 __u32 handle;
1293};
1294
1295/**
1296 * DRM_MODE_ATOMIC_TEST_ONLY
1297 *
1298 * Do not apply the atomic commit, instead check whether the hardware supports
1299 * this configuration.
1300 *
1301 * See &drm_mode_config_funcs.atomic_check for more details on test-only
1302 * commits.
1303 */
1304#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
1305/**
1306 * DRM_MODE_ATOMIC_NONBLOCK
1307 *
1308 * Do not block while applying the atomic commit. The &DRM_IOCTL_MODE_ATOMIC
1309 * IOCTL returns immediately instead of waiting for the changes to be applied
1310 * in hardware. Note, the driver will still check that the update can be
1311 * applied before retuning.
1312 */
1313#define DRM_MODE_ATOMIC_NONBLOCK 0x0200
1314/**
1315 * DRM_MODE_ATOMIC_ALLOW_MODESET
1316 *
1317 * Allow the update to result in temporary or transient visible artifacts while
1318 * the update is being applied. Applying the update may also take significantly
1319 * more time than a page flip. All visual artifacts will disappear by the time
1320 * the update is completed, as signalled through the vblank event's timestamp
1321 * (see struct drm_event_vblank).
1322 *
1323 * This flag must be set when the KMS update might cause visible artifacts.
1324 * Without this flag such KMS update will return a EINVAL error. What kind of
1325 * update may cause visible artifacts depends on the driver and the hardware.
1326 * User-space that needs to know beforehand if an update might cause visible
1327 * artifacts can use &DRM_MODE_ATOMIC_TEST_ONLY without
1328 * &DRM_MODE_ATOMIC_ALLOW_MODESET to see if it fails.
1329 *
1330 * To the best of the driver's knowledge, visual artifacts are guaranteed to
1331 * not appear when this flag is not set. Some sinks might display visual
1332 * artifacts outside of the driver's control.
1333 */
1334#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
1335
1336/**
1337 * DRM_MODE_ATOMIC_FLAGS
1338 *
1339 * Bitfield of flags accepted by the &DRM_IOCTL_MODE_ATOMIC IOCTL in
1340 * &drm_mode_atomic.flags.
1341 */
1342#define DRM_MODE_ATOMIC_FLAGS (\
1343 DRM_MODE_PAGE_FLIP_EVENT |\
1344 DRM_MODE_PAGE_FLIP_ASYNC |\
1345 DRM_MODE_ATOMIC_TEST_ONLY |\
1346 DRM_MODE_ATOMIC_NONBLOCK |\
1347 DRM_MODE_ATOMIC_ALLOW_MODESET)
1348
1349struct drm_mode_atomic {
1350 __u32 flags;
1351 __u32 count_objs;
1352 __u64 objs_ptr;
1353 __u64 count_props_ptr;
1354 __u64 props_ptr;
1355 __u64 prop_values_ptr;
1356 __u64 reserved;
1357 __u64 user_data;
1358};
1359
1360struct drm_format_modifier_blob {
1361#define FORMAT_BLOB_CURRENT 1
1362 /* Version of this blob format */
1363 __u32 version;
1364
1365 /* Flags */
1366 __u32 flags;
1367
1368 /* Number of fourcc formats supported */
1369 __u32 count_formats;
1370
1371 /* Where in this blob the formats exist (in bytes) */
1372 __u32 formats_offset;
1373
1374 /* Number of drm_format_modifiers */
1375 __u32 count_modifiers;
1376
1377 /* Where in this blob the modifiers exist (in bytes) */
1378 __u32 modifiers_offset;
1379
1380 /* __u32 formats[] */
1381 /* struct drm_format_modifier modifiers[] */
1382};
1383
1384struct drm_format_modifier {
1385 /* Bitmask of formats in get_plane format list this info applies to. The
1386 * offset allows a sliding window of which 64 formats (bits).
1387 *
1388 * Some examples:
1389 * In today's world with < 65 formats, and formats 0, and 2 are
1390 * supported
1391 * 0x0000000000000005
1392 * ^-offset = 0, formats = 5
1393 *
1394 * If the number formats grew to 128, and formats 98-102 are
1395 * supported with the modifier:
1396 *
1397 * 0x0000007c00000000 0000000000000000
1398 * ^
1399 * |__offset = 64, formats = 0x7c00000000
1400 *
1401 */
1402 __u64 formats;
1403 __u32 offset;
1404 __u32 pad;
1405
1406 /* The modifier that applies to the >get_plane format list bitmask. */
1407 __u64 modifier;
1408};
1409
1410/**
1411 * struct drm_mode_create_blob - Create New blob property
1412 *
1413 * Create a new 'blob' data property, copying length bytes from data pointer,
1414 * and returning new blob ID.
1415 */
1416struct drm_mode_create_blob {
1417 /** @data: Pointer to data to copy. */
1418 __u64 data;
1419 /** @length: Length of data to copy. */
1420 __u32 length;
1421 /** @blob_id: Return: new property ID. */
1422 __u32 blob_id;
1423};
1424
1425/**
1426 * struct drm_mode_destroy_blob - Destroy user blob
1427 * @blob_id: blob_id to destroy
1428 *
1429 * Destroy a user-created blob property.
1430 *
1431 * User-space can release blobs as soon as they do not need to refer to them by
1432 * their blob object ID. For instance, if you are using a MODE_ID blob in an
1433 * atomic commit and you will not make another commit re-using the same ID, you
1434 * can destroy the blob as soon as the commit has been issued, without waiting
1435 * for it to complete.
1436 */
1437struct drm_mode_destroy_blob {
1438 __u32 blob_id;
1439};
1440
1441/**
1442 * struct drm_mode_create_lease - Create lease
1443 *
1444 * Lease mode resources, creating another drm_master.
1445 *
1446 * The @object_ids array must reference at least one CRTC, one connector and
1447 * one plane if &DRM_CLIENT_CAP_UNIVERSAL_PLANES is enabled. Alternatively,
1448 * the lease can be completely empty.
1449 */
1450struct drm_mode_create_lease {
1451 /** @object_ids: Pointer to array of object ids (__u32) */
1452 __u64 object_ids;
1453 /** @object_count: Number of object ids */
1454 __u32 object_count;
1455 /** @flags: flags for new FD (O_CLOEXEC, etc) */
1456 __u32 flags;
1457
1458 /** @lessee_id: Return: unique identifier for lessee. */
1459 __u32 lessee_id;
1460 /** @fd: Return: file descriptor to new drm_master file */
1461 __u32 fd;
1462};
1463
1464/**
1465 * struct drm_mode_list_lessees - List lessees
1466 *
1467 * List lesses from a drm_master.
1468 */
1469struct drm_mode_list_lessees {
1470 /**
1471 * @count_lessees: Number of lessees.
1472 *
1473 * On input, provides length of the array.
1474 * On output, provides total number. No
1475 * more than the input number will be written
1476 * back, so two calls can be used to get
1477 * the size and then the data.
1478 */
1479 __u32 count_lessees;
1480 /** @pad: Padding. */
1481 __u32 pad;
1482
1483 /**
1484 * @lessees_ptr: Pointer to lessees.
1485 *
1486 * Pointer to __u64 array of lessee ids
1487 */
1488 __u64 lessees_ptr;
1489};
1490
1491/**
1492 * struct drm_mode_get_lease - Get Lease
1493 *
1494 * Get leased objects.
1495 */
1496struct drm_mode_get_lease {
1497 /**
1498 * @count_objects: Number of leased objects.
1499 *
1500 * On input, provides length of the array.
1501 * On output, provides total number. No
1502 * more than the input number will be written
1503 * back, so two calls can be used to get
1504 * the size and then the data.
1505 */
1506 __u32 count_objects;
1507 /** @pad: Padding. */
1508 __u32 pad;
1509
1510 /**
1511 * @objects_ptr: Pointer to objects.
1512 *
1513 * Pointer to __u32 array of object ids.
1514 */
1515 __u64 objects_ptr;
1516};
1517
1518/**
1519 * struct drm_mode_revoke_lease - Revoke lease
1520 */
1521struct drm_mode_revoke_lease {
1522 /** @lessee_id: Unique ID of lessee */
1523 __u32 lessee_id;
1524};
1525
1526/**
1527 * struct drm_mode_rect - Two dimensional rectangle.
1528 * @x1: Horizontal starting coordinate (inclusive).
1529 * @y1: Vertical starting coordinate (inclusive).
1530 * @x2: Horizontal ending coordinate (exclusive).
1531 * @y2: Vertical ending coordinate (exclusive).
1532 *
1533 * With drm subsystem using struct drm_rect to manage rectangular area this
1534 * export it to user-space.
1535 *
1536 * Currently used by drm_mode_atomic blob property FB_DAMAGE_CLIPS.
1537 */
1538struct drm_mode_rect {
1539 __s32 x1;
1540 __s32 y1;
1541 __s32 x2;
1542 __s32 y2;
1543};
1544
1545/**
1546 * struct drm_mode_closefb
1547 * @fb_id: Framebuffer ID.
1548 * @pad: Must be zero.
1549 */
1550struct drm_mode_closefb {
1551 __u32 fb_id;
1552 __u32 pad;
1553};
1554
1555/*
1556 * Put 16-bit ARGB values into a standard 64-bit representation that can be
1557 * used for ioctl parameters, inter-driver communication, etc.
1558 *
1559 * If the component values being provided contain less than 16 bits of
1560 * precision, use a conversion ratio to get a better color approximation.
1561 * The ratio is computed as (2^16 - 1) / (2^bpc - 1), where bpc and 16 are
1562 * the input and output precision, respectively.
1563 * Also note bpc must be greater than 0.
1564 */
1565#define __DRM_ARGB64_PREP(c, shift) \
1566 (((__u64)(c) & __GENMASK(15, 0)) << (shift))
1567
1568#define __DRM_ARGB64_PREP_BPC(c, shift, bpc) \
1569({ \
1570 __u16 mask = __GENMASK((bpc) - 1, 0); \
1571 __u16 conv = __KERNEL_DIV_ROUND_CLOSEST((mask & (c)) * \
1572 __GENMASK(15, 0), mask);\
1573 __DRM_ARGB64_PREP(conv, shift); \
1574})
1575
1576#define DRM_ARGB64_PREP(alpha, red, green, blue) \
1577( \
1578 __DRM_ARGB64_PREP(alpha, 48) | \
1579 __DRM_ARGB64_PREP(red, 32) | \
1580 __DRM_ARGB64_PREP(green, 16) | \
1581 __DRM_ARGB64_PREP(blue, 0) \
1582)
1583
1584#define DRM_ARGB64_PREP_BPC(alpha, red, green, blue, bpc) \
1585({ \
1586 __typeof__(bpc) __bpc = bpc; \
1587 __DRM_ARGB64_PREP_BPC(alpha, 48, __bpc) | \
1588 __DRM_ARGB64_PREP_BPC(red, 32, __bpc) | \
1589 __DRM_ARGB64_PREP_BPC(green, 16, __bpc) | \
1590 __DRM_ARGB64_PREP_BPC(blue, 0, __bpc); \
1591})
1592
1593/*
1594 * Extract the specified color component from a standard 64-bit ARGB value.
1595 *
1596 * If the requested precision is less than 16 bits, make use of a conversion
1597 * ratio calculated as (2^bpc - 1) / (2^16 - 1), where bpc and 16 are the
1598 * output and input precision, respectively.
1599 *
1600 * If speed is more important than accuracy, use DRM_ARGB64_GET*_BPCS()
1601 * instead of DRM_ARGB64_GET*_BPC() in order to replace the expensive
1602 * division with a simple bit right-shift operation.
1603 */
1604#define __DRM_ARGB64_GET(c, shift) \
1605 ((__u16)(((__u64)(c) >> (shift)) & __GENMASK(15, 0)))
1606
1607#define __DRM_ARGB64_GET_BPC(c, shift, bpc) \
1608({ \
1609 __u16 comp = __DRM_ARGB64_GET(c, shift); \
1610 __KERNEL_DIV_ROUND_CLOSEST(comp * __GENMASK((bpc) - 1, 0), \
1611 __GENMASK(15, 0)); \
1612})
1613
1614#define __DRM_ARGB64_GET_BPCS(c, shift, bpc) \
1615 (__DRM_ARGB64_GET(c, shift) >> (16 - (bpc)))
1616
1617#define DRM_ARGB64_GETA(c) __DRM_ARGB64_GET(c, 48)
1618#define DRM_ARGB64_GETR(c) __DRM_ARGB64_GET(c, 32)
1619#define DRM_ARGB64_GETG(c) __DRM_ARGB64_GET(c, 16)
1620#define DRM_ARGB64_GETB(c) __DRM_ARGB64_GET(c, 0)
1621
1622#define DRM_ARGB64_GETA_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 48, bpc)
1623#define DRM_ARGB64_GETR_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 32, bpc)
1624#define DRM_ARGB64_GETG_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 16, bpc)
1625#define DRM_ARGB64_GETB_BPC(c, bpc) __DRM_ARGB64_GET_BPC(c, 0, bpc)
1626
1627#define DRM_ARGB64_GETA_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 48, bpc)
1628#define DRM_ARGB64_GETR_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 32, bpc)
1629#define DRM_ARGB64_GETG_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 16, bpc)
1630#define DRM_ARGB64_GETB_BPCS(c, bpc) __DRM_ARGB64_GET_BPCS(c, 0, bpc)
1631
1632#if defined(__cplusplus)
1633}
1634#endif
1635
1636#endif