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