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