Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 1 | /* |
| 2 | * \file xf86drmMode.h |
| 3 | * Header for DRM modesetting interface. |
| 4 | * |
| 5 | * \author Jakob Bornecrantz <wallbraker@gmail.com> |
| 6 | * |
| 7 | * \par Acknowledgements: |
| 8 | * Feb 2007, Dave Airlie <airlied@linux.ie> |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
| 13 | * Copyright (c) 2007-2008 Dave Airlie <airlied@linux.ie> |
| 14 | * Copyright (c) 2007-2008 Jakob Bornecrantz <wallbraker@gmail.com> |
| 15 | * |
| 16 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 17 | * copy of this software and associated documentation files (the "Software"), |
| 18 | * to deal in the Software without restriction, including without limitation |
| 19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 20 | * and/or sell copies of the Software, and to permit persons to whom the |
| 21 | * Software is furnished to do so, subject to the following conditions: |
| 22 | * |
| 23 | * The above copyright notice and this permission notice shall be included in |
| 24 | * all copies or substantial portions of the Software. |
| 25 | * |
| 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 29 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 30 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 31 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 32 | * IN THE SOFTWARE. |
| 33 | * |
| 34 | */ |
| 35 | |
David Herrman | fd39e61 | 2012-03-09 13:40:14 -0500 | [diff] [blame] | 36 | #ifndef _XF86DRMMODE_H_ |
| 37 | #define _XF86DRMMODE_H_ |
| 38 | |
Tapani Pälli | 1c20574 | 2015-08-07 10:37:56 +0300 | [diff] [blame] | 39 | #if defined(__cplusplus) |
Tapani Pälli | cfee521 | 2011-09-23 14:17:42 +0300 | [diff] [blame] | 40 | extern "C" { |
| 41 | #endif |
| 42 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 43 | #include <drm.h> |
Simon Ser | d5682de | 2019-10-26 19:36:37 +0200 | [diff] [blame] | 44 | #include <stddef.h> |
| 45 | #include <stdint.h> |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 46 | |
| 47 | /* |
| 48 | * This is the interface for modesetting for drm. |
| 49 | * |
| 50 | * In order to use this interface you must include either <stdint.h> or another |
| 51 | * header defining uint32_t, int32_t and uint16_t. |
| 52 | * |
| 53 | * It aims to provide a randr1.2 compatible interface for modesettings in the |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 54 | * kernel, the interface is also meant to be used by libraries like EGL. |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 55 | * |
| 56 | * More information can be found in randrproto.txt which can be found here: |
| 57 | * http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git |
| 58 | * |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 59 | * There are some major differences to be noted. Unlike the randr1.2 proto you |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 60 | * need to create the memory object of the framebuffer yourself with the ttm |
| 61 | * buffer object interface. This object needs to be pinned. |
| 62 | */ |
| 63 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 64 | /* |
| 65 | * If we pickup an old version of drm.h which doesn't include drm_mode.h |
| 66 | * we should redefine defines. This is so that builds doesn't breaks with |
| 67 | * new libdrm on old kernels. |
| 68 | */ |
| 69 | #ifndef _DRM_MODE_H |
| 70 | |
| 71 | #define DRM_DISPLAY_INFO_LEN 32 |
| 72 | #define DRM_CONNECTOR_NAME_LEN 32 |
| 73 | #define DRM_DISPLAY_MODE_LEN 32 |
| 74 | #define DRM_PROP_NAME_LEN 32 |
| 75 | |
| 76 | #define DRM_MODE_TYPE_BUILTIN (1<<0) |
| 77 | #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) |
| 78 | #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN) |
| 79 | #define DRM_MODE_TYPE_PREFERRED (1<<3) |
| 80 | #define DRM_MODE_TYPE_DEFAULT (1<<4) |
| 81 | #define DRM_MODE_TYPE_USERDEF (1<<5) |
| 82 | #define DRM_MODE_TYPE_DRIVER (1<<6) |
| 83 | |
| 84 | /* Video mode flags */ |
| 85 | /* bit compatible with the xorg definitions. */ |
Damien Lespiau | edf5c7c | 2013-08-23 15:57:40 +0100 | [diff] [blame] | 86 | #define DRM_MODE_FLAG_PHSYNC (1<<0) |
| 87 | #define DRM_MODE_FLAG_NHSYNC (1<<1) |
| 88 | #define DRM_MODE_FLAG_PVSYNC (1<<2) |
| 89 | #define DRM_MODE_FLAG_NVSYNC (1<<3) |
| 90 | #define DRM_MODE_FLAG_INTERLACE (1<<4) |
| 91 | #define DRM_MODE_FLAG_DBLSCAN (1<<5) |
| 92 | #define DRM_MODE_FLAG_CSYNC (1<<6) |
| 93 | #define DRM_MODE_FLAG_PCSYNC (1<<7) |
| 94 | #define DRM_MODE_FLAG_NCSYNC (1<<8) |
| 95 | #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */ |
| 96 | #define DRM_MODE_FLAG_BCAST (1<<10) |
| 97 | #define DRM_MODE_FLAG_PIXMUX (1<<11) |
| 98 | #define DRM_MODE_FLAG_DBLCLK (1<<12) |
| 99 | #define DRM_MODE_FLAG_CLKDIV2 (1<<13) |
| 100 | #define DRM_MODE_FLAG_3D_MASK (0x1f<<14) |
| 101 | #define DRM_MODE_FLAG_3D_NONE (0<<14) |
| 102 | #define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14) |
| 103 | #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14) |
| 104 | #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14) |
| 105 | #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14) |
| 106 | #define DRM_MODE_FLAG_3D_L_DEPTH (5<<14) |
| 107 | #define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14) |
| 108 | #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14) |
| 109 | #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14) |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 110 | |
| 111 | /* DPMS flags */ |
| 112 | /* bit compatible with the xorg definitions. */ |
| 113 | #define DRM_MODE_DPMS_ON 0 |
| 114 | #define DRM_MODE_DPMS_STANDBY 1 |
| 115 | #define DRM_MODE_DPMS_SUSPEND 2 |
| 116 | #define DRM_MODE_DPMS_OFF 3 |
| 117 | |
| 118 | /* Scaling mode options */ |
| 119 | #define DRM_MODE_SCALE_NON_GPU 0 |
| 120 | #define DRM_MODE_SCALE_FULLSCREEN 1 |
| 121 | #define DRM_MODE_SCALE_NO_SCALE 2 |
| 122 | #define DRM_MODE_SCALE_ASPECT 3 |
| 123 | |
| 124 | /* Dithering mode options */ |
| 125 | #define DRM_MODE_DITHERING_OFF 0 |
| 126 | #define DRM_MODE_DITHERING_ON 1 |
| 127 | |
Thierry Reding | ab50ffb | 2014-12-17 11:52:40 +0100 | [diff] [blame] | 128 | #define DRM_MODE_ENCODER_NONE 0 |
| 129 | #define DRM_MODE_ENCODER_DAC 1 |
| 130 | #define DRM_MODE_ENCODER_TMDS 2 |
| 131 | #define DRM_MODE_ENCODER_LVDS 3 |
| 132 | #define DRM_MODE_ENCODER_TVDAC 4 |
Thomas Hellstrom | c601444 | 2013-11-19 07:50:11 +0100 | [diff] [blame] | 133 | #define DRM_MODE_ENCODER_VIRTUAL 5 |
Thierry Reding | ab50ffb | 2014-12-17 11:52:40 +0100 | [diff] [blame] | 134 | #define DRM_MODE_ENCODER_DSI 6 |
Thierry Reding | 4bfbe4c | 2014-12-17 11:53:31 +0100 | [diff] [blame] | 135 | #define DRM_MODE_ENCODER_DPMST 7 |
| 136 | #define DRM_MODE_ENCODER_DPI 8 |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 137 | |
| 138 | #define DRM_MODE_SUBCONNECTOR_Automatic 0 |
| 139 | #define DRM_MODE_SUBCONNECTOR_Unknown 0 |
| 140 | #define DRM_MODE_SUBCONNECTOR_DVID 3 |
| 141 | #define DRM_MODE_SUBCONNECTOR_DVIA 4 |
| 142 | #define DRM_MODE_SUBCONNECTOR_Composite 5 |
| 143 | #define DRM_MODE_SUBCONNECTOR_SVIDEO 6 |
| 144 | #define DRM_MODE_SUBCONNECTOR_Component 8 |
Thomas Hellstrom | c601444 | 2013-11-19 07:50:11 +0100 | [diff] [blame] | 145 | #define DRM_MODE_SUBCONNECTOR_SCART 9 |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 146 | |
| 147 | #define DRM_MODE_CONNECTOR_Unknown 0 |
| 148 | #define DRM_MODE_CONNECTOR_VGA 1 |
| 149 | #define DRM_MODE_CONNECTOR_DVII 2 |
| 150 | #define DRM_MODE_CONNECTOR_DVID 3 |
| 151 | #define DRM_MODE_CONNECTOR_DVIA 4 |
| 152 | #define DRM_MODE_CONNECTOR_Composite 5 |
| 153 | #define DRM_MODE_CONNECTOR_SVIDEO 6 |
| 154 | #define DRM_MODE_CONNECTOR_LVDS 7 |
| 155 | #define DRM_MODE_CONNECTOR_Component 8 |
| 156 | #define DRM_MODE_CONNECTOR_9PinDIN 9 |
| 157 | #define DRM_MODE_CONNECTOR_DisplayPort 10 |
| 158 | #define DRM_MODE_CONNECTOR_HDMIA 11 |
| 159 | #define DRM_MODE_CONNECTOR_HDMIB 12 |
Thierry Reding | ab50ffb | 2014-12-17 11:52:40 +0100 | [diff] [blame] | 160 | #define DRM_MODE_CONNECTOR_TV 13 |
| 161 | #define DRM_MODE_CONNECTOR_eDP 14 |
Thomas Hellstrom | c601444 | 2013-11-19 07:50:11 +0100 | [diff] [blame] | 162 | #define DRM_MODE_CONNECTOR_VIRTUAL 15 |
| 163 | #define DRM_MODE_CONNECTOR_DSI 16 |
Thierry Reding | 4bfbe4c | 2014-12-17 11:53:31 +0100 | [diff] [blame] | 164 | #define DRM_MODE_CONNECTOR_DPI 17 |
Daniel Stone | 665c0f7 | 2019-11-26 10:41:26 +0000 | [diff] [blame] | 165 | #define DRM_MODE_CONNECTOR_WRITEBACK 18 |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 166 | |
| 167 | #define DRM_MODE_PROP_PENDING (1<<0) |
| 168 | #define DRM_MODE_PROP_RANGE (1<<1) |
| 169 | #define DRM_MODE_PROP_IMMUTABLE (1<<2) |
| 170 | #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */ |
| 171 | #define DRM_MODE_PROP_BLOB (1<<4) |
| 172 | |
| 173 | #define DRM_MODE_CURSOR_BO (1<<0) |
| 174 | #define DRM_MODE_CURSOR_MOVE (1<<1) |
| 175 | |
| 176 | #endif /* _DRM_MODE_H */ |
| 177 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 178 | |
| 179 | /* |
| 180 | * Feature defines |
| 181 | * |
| 182 | * Just because these are defined doesn't mean that the kernel |
| 183 | * can do that feature, its just for new code vs old libdrm. |
| 184 | */ |
| 185 | #define DRM_MODE_FEATURE_KMS 1 |
| 186 | #define DRM_MODE_FEATURE_DIRTYFB 1 |
| 187 | |
| 188 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 189 | typedef struct _drmModeRes { |
| 190 | |
| 191 | int count_fbs; |
| 192 | uint32_t *fbs; |
| 193 | |
| 194 | int count_crtcs; |
| 195 | uint32_t *crtcs; |
| 196 | |
| 197 | int count_connectors; |
| 198 | uint32_t *connectors; |
| 199 | |
| 200 | int count_encoders; |
| 201 | uint32_t *encoders; |
| 202 | |
| 203 | uint32_t min_width, max_width; |
| 204 | uint32_t min_height, max_height; |
| 205 | } drmModeRes, *drmModeResPtr; |
| 206 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 207 | typedef struct _drmModeModeInfo { |
| 208 | uint32_t clock; |
| 209 | uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew; |
| 210 | uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan; |
| 211 | |
Marcin Kościelnicki | 694ef59 | 2010-02-27 15:04:42 +0000 | [diff] [blame] | 212 | uint32_t vrefresh; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 213 | |
| 214 | uint32_t flags; |
| 215 | uint32_t type; |
| 216 | char name[DRM_DISPLAY_MODE_LEN]; |
| 217 | } drmModeModeInfo, *drmModeModeInfoPtr; |
| 218 | |
| 219 | typedef struct _drmModeFB { |
| 220 | uint32_t fb_id; |
| 221 | uint32_t width, height; |
| 222 | uint32_t pitch; |
| 223 | uint32_t bpp; |
| 224 | uint32_t depth; |
| 225 | /* driver specific handle */ |
| 226 | uint32_t handle; |
| 227 | } drmModeFB, *drmModeFBPtr; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 228 | |
Daniel Stone | d8731e9 | 2020-02-11 12:19:16 -0800 | [diff] [blame] | 229 | typedef struct _drmModeFB2 { |
| 230 | uint32_t fb_id; |
| 231 | uint32_t width, height; |
| 232 | uint32_t pixel_format; /* fourcc code from drm_fourcc.h */ |
| 233 | uint64_t modifier; /* applies to all buffers */ |
| 234 | uint32_t flags; |
| 235 | |
| 236 | /* per-plane GEM handle; may be duplicate entries for multiple planes */ |
| 237 | uint32_t handles[4]; |
| 238 | uint32_t pitches[4]; /* bytes */ |
| 239 | uint32_t offsets[4]; /* bytes */ |
| 240 | } drmModeFB2, *drmModeFB2Ptr; |
| 241 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 242 | typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr; |
| 243 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 244 | typedef struct _drmModePropertyBlob { |
| 245 | uint32_t id; |
| 246 | uint32_t length; |
| 247 | void *data; |
| 248 | } drmModePropertyBlobRes, *drmModePropertyBlobPtr; |
| 249 | |
| 250 | typedef struct _drmModeProperty { |
| 251 | uint32_t prop_id; |
| 252 | uint32_t flags; |
| 253 | char name[DRM_PROP_NAME_LEN]; |
| 254 | int count_values; |
Daniel Kurtz | 0f4452b | 2013-08-26 23:39:16 +0800 | [diff] [blame] | 255 | uint64_t *values; /* store the blob lengths */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 256 | int count_enums; |
| 257 | struct drm_mode_property_enum *enums; |
| 258 | int count_blobs; |
Daniel Kurtz | 0f4452b | 2013-08-26 23:39:16 +0800 | [diff] [blame] | 259 | uint32_t *blob_ids; /* store the blob IDs */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 260 | } drmModePropertyRes, *drmModePropertyPtr; |
| 261 | |
Daniel Kurtz | d20314d | 2015-03-24 18:01:02 -0700 | [diff] [blame] | 262 | static __inline int drm_property_type_is(drmModePropertyPtr property, |
Rob Clark | fb41770 | 2013-10-12 12:16:44 -0400 | [diff] [blame] | 263 | uint32_t type) |
| 264 | { |
| 265 | /* instanceof for props.. handles extended type vs original types: */ |
| 266 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) |
| 267 | return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; |
| 268 | return property->flags & type; |
| 269 | } |
| 270 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 271 | typedef struct _drmModeCrtc { |
| 272 | uint32_t crtc_id; |
| 273 | uint32_t buffer_id; /**< FB id to connect to 0 = disconnect */ |
| 274 | |
| 275 | uint32_t x, y; /**< Position on the framebuffer */ |
| 276 | uint32_t width, height; |
| 277 | int mode_valid; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 278 | drmModeModeInfo mode; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 279 | |
| 280 | int gamma_size; /**< Number of gamma stops */ |
| 281 | |
| 282 | } drmModeCrtc, *drmModeCrtcPtr; |
| 283 | |
| 284 | typedef struct _drmModeEncoder { |
| 285 | uint32_t encoder_id; |
| 286 | uint32_t encoder_type; |
| 287 | uint32_t crtc_id; |
| 288 | uint32_t possible_crtcs; |
| 289 | uint32_t possible_clones; |
| 290 | } drmModeEncoder, *drmModeEncoderPtr; |
| 291 | |
Simon Ser | df37342 | 2020-11-18 10:58:59 +0100 | [diff] [blame] | 292 | /** |
| 293 | * Describes the connector status. |
| 294 | * |
| 295 | * DRM_MODE_CONNECTED means that the connector has a sink plugged in. |
| 296 | * DRM_MODE_DISCONNECTED means the contrary. DRM_MODE_UNKNOWNCONNECTION is used |
| 297 | * when it could be either. |
| 298 | * |
| 299 | * User-space should first try to enable DRM_MODE_CONNECTED connectors and |
| 300 | * ignore other connectors. If there are no DRM_MODE_CONNECTED connectors, |
| 301 | * user-space should then try to probe and enable DRM_MODE_UNKNOWNCONNECTION |
| 302 | * connectors. |
| 303 | */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 304 | typedef enum { |
| 305 | DRM_MODE_CONNECTED = 1, |
| 306 | DRM_MODE_DISCONNECTED = 2, |
| 307 | DRM_MODE_UNKNOWNCONNECTION = 3 |
| 308 | } drmModeConnection; |
| 309 | |
| 310 | typedef enum { |
| 311 | DRM_MODE_SUBPIXEL_UNKNOWN = 1, |
| 312 | DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2, |
| 313 | DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3, |
| 314 | DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4, |
| 315 | DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5, |
| 316 | DRM_MODE_SUBPIXEL_NONE = 6 |
| 317 | } drmModeSubPixel; |
| 318 | |
| 319 | typedef struct _drmModeConnector { |
| 320 | uint32_t connector_id; |
| 321 | uint32_t encoder_id; /**< Encoder currently connected to */ |
| 322 | uint32_t connector_type; |
| 323 | uint32_t connector_type_id; |
| 324 | drmModeConnection connection; |
| 325 | uint32_t mmWidth, mmHeight; /**< HxW in millimeters */ |
| 326 | drmModeSubPixel subpixel; |
| 327 | |
| 328 | int count_modes; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 329 | drmModeModeInfoPtr modes; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 330 | |
| 331 | int count_props; |
| 332 | uint32_t *props; /**< List of property ids */ |
| 333 | uint64_t *prop_values; /**< List of property values */ |
| 334 | |
| 335 | int count_encoders; |
| 336 | uint32_t *encoders; /**< List of encoder ids */ |
| 337 | } drmModeConnector, *drmModeConnectorPtr; |
| 338 | |
Matt Roper | 8fc62ca | 2014-04-10 14:23:12 -0700 | [diff] [blame] | 339 | #define DRM_PLANE_TYPE_OVERLAY 0 |
| 340 | #define DRM_PLANE_TYPE_PRIMARY 1 |
| 341 | #define DRM_PLANE_TYPE_CURSOR 2 |
| 342 | |
Paulo Zanoni | 8c75703 | 2012-05-15 18:38:28 -0300 | [diff] [blame] | 343 | typedef struct _drmModeObjectProperties { |
| 344 | uint32_t count_props; |
| 345 | uint32_t *props; |
| 346 | uint64_t *prop_values; |
| 347 | } drmModeObjectProperties, *drmModeObjectPropertiesPtr; |
| 348 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 349 | typedef struct _drmModePlane { |
| 350 | uint32_t count_formats; |
| 351 | uint32_t *formats; |
| 352 | uint32_t plane_id; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 353 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 354 | uint32_t crtc_id; |
| 355 | uint32_t fb_id; |
| 356 | |
| 357 | uint32_t crtc_x, crtc_y; |
| 358 | uint32_t x, y; |
| 359 | |
| 360 | uint32_t possible_crtcs; |
| 361 | uint32_t gamma_size; |
| 362 | } drmModePlane, *drmModePlanePtr; |
| 363 | |
| 364 | typedef struct _drmModePlaneRes { |
| 365 | uint32_t count_planes; |
| 366 | uint32_t *planes; |
| 367 | } drmModePlaneRes, *drmModePlaneResPtr; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 368 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 369 | extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr ); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 370 | extern void drmModeFreeResources( drmModeResPtr ptr ); |
| 371 | extern void drmModeFreeFB( drmModeFBPtr ptr ); |
Daniel Stone | d8731e9 | 2020-02-11 12:19:16 -0800 | [diff] [blame] | 372 | extern void drmModeFreeFB2( drmModeFB2Ptr ptr ); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 373 | extern void drmModeFreeCrtc( drmModeCrtcPtr ptr ); |
| 374 | extern void drmModeFreeConnector( drmModeConnectorPtr ptr ); |
| 375 | extern void drmModeFreeEncoder( drmModeEncoderPtr ptr ); |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 376 | extern void drmModeFreePlane( drmModePlanePtr ptr ); |
Ville Syrjälä | a14c3dd | 2012-02-02 14:53:41 -0500 | [diff] [blame] | 377 | extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 378 | |
| 379 | /** |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 380 | * Retrieves all of the resources associated with a card. |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 381 | */ |
| 382 | extern drmModeResPtr drmModeGetResources(int fd); |
| 383 | |
| 384 | /* |
| 385 | * FrameBuffer manipulation. |
| 386 | */ |
| 387 | |
| 388 | /** |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 389 | * Retrieve information about framebuffer bufferId |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 390 | */ |
| 391 | extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId); |
Daniel Stone | d8731e9 | 2020-02-11 12:19:16 -0800 | [diff] [blame] | 392 | extern drmModeFB2Ptr drmModeGetFB2(int fd, uint32_t bufferId); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 393 | |
| 394 | /** |
| 395 | * Creates a new framebuffer with an buffer object as its scanout buffer. |
| 396 | */ |
| 397 | extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, |
| 398 | uint8_t bpp, uint32_t pitch, uint32_t bo_handle, |
| 399 | uint32_t *buf_id); |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 400 | /* ...with a specific pixel format */ |
| 401 | extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height, |
Tobias Jakobi | 09be541 | 2017-10-10 12:12:52 +0200 | [diff] [blame] | 402 | uint32_t pixel_format, const uint32_t bo_handles[4], |
| 403 | const uint32_t pitches[4], const uint32_t offsets[4], |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 404 | uint32_t *buf_id, uint32_t flags); |
Kristian H. Kristensen | abfa680 | 2016-09-08 13:08:59 -0700 | [diff] [blame] | 405 | |
| 406 | /* ...with format modifiers */ |
| 407 | int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height, |
Tobias Jakobi | 09be541 | 2017-10-10 12:12:52 +0200 | [diff] [blame] | 408 | uint32_t pixel_format, const uint32_t bo_handles[4], |
| 409 | const uint32_t pitches[4], const uint32_t offsets[4], |
| 410 | const uint64_t modifier[4], uint32_t *buf_id, |
| 411 | uint32_t flags); |
Kristian H. Kristensen | abfa680 | 2016-09-08 13:08:59 -0700 | [diff] [blame] | 412 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 413 | /** |
| 414 | * Destroies the given framebuffer. |
| 415 | */ |
| 416 | extern int drmModeRmFB(int fd, uint32_t bufferId); |
| 417 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 418 | /** |
| 419 | * Mark a region of a framebuffer as dirty. |
| 420 | */ |
| 421 | extern int drmModeDirtyFB(int fd, uint32_t bufferId, |
| 422 | drmModeClipPtr clips, uint32_t num_clips); |
| 423 | |
| 424 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 425 | /* |
| 426 | * Crtc functions |
| 427 | */ |
| 428 | |
| 429 | /** |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 430 | * Retrieve information about the ctrt crtcId |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 431 | */ |
| 432 | extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId); |
| 433 | |
| 434 | /** |
| 435 | * Set the mode on a crtc crtcId with the given mode modeId. |
| 436 | */ |
| 437 | int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, |
| 438 | uint32_t x, uint32_t y, uint32_t *connectors, int count, |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 439 | drmModeModeInfoPtr mode); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 440 | |
| 441 | /* |
| 442 | * Cursor functions |
| 443 | */ |
| 444 | |
| 445 | /** |
| 446 | * Set the cursor on crtc |
| 447 | */ |
| 448 | int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height); |
| 449 | |
Dave Airlie | 2e0ab62 | 2013-07-02 09:21:06 +0100 | [diff] [blame] | 450 | int drmModeSetCursor2(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height, int32_t hot_x, int32_t hot_y); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 451 | /** |
| 452 | * Move the cursor on crtc |
| 453 | */ |
| 454 | int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y); |
| 455 | |
| 456 | /** |
| 457 | * Encoder functions |
| 458 | */ |
| 459 | drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id); |
| 460 | |
| 461 | /* |
| 462 | * Connector manipulation |
| 463 | */ |
| 464 | |
| 465 | /** |
Chris Wilson | 5ed5fa1 | 2015-03-04 10:07:19 +0000 | [diff] [blame] | 466 | * Retrieve all information about the connector connectorId. This will do a |
| 467 | * forced probe on the connector to retrieve remote information such as EDIDs |
| 468 | * from the display device. |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 469 | */ |
| 470 | extern drmModeConnectorPtr drmModeGetConnector(int fd, |
Chris Wilson | 5ed5fa1 | 2015-03-04 10:07:19 +0000 | [diff] [blame] | 471 | uint32_t connectorId); |
| 472 | |
| 473 | /** |
| 474 | * Retrieve current information, i.e the currently active mode and encoder, |
| 475 | * about the connector connectorId. This will not do any probing on the |
| 476 | * connector or remote device, and only reports what is currently known. |
| 477 | * For the complete set of modes and encoders associated with the connector |
| 478 | * use drmModeGetConnector() which will do a probe to determine any display |
| 479 | * link changes first. |
| 480 | */ |
| 481 | extern drmModeConnectorPtr drmModeGetConnectorCurrent(int fd, |
| 482 | uint32_t connector_id); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 483 | |
| 484 | /** |
| 485 | * Attaches the given mode to an connector. |
| 486 | */ |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 487 | extern int drmModeAttachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 488 | |
| 489 | /** |
| 490 | * Detaches a mode from the connector |
| 491 | * must be unused, by the given mode. |
| 492 | */ |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 493 | extern int drmModeDetachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 494 | |
| 495 | extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId); |
| 496 | extern void drmModeFreeProperty(drmModePropertyPtr ptr); |
| 497 | |
| 498 | extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id); |
| 499 | extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr); |
| 500 | extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id, |
| 501 | uint64_t value); |
| 502 | extern int drmCheckModesettingSupported(const char *busid); |
| 503 | |
| 504 | extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, |
| 505 | uint16_t *red, uint16_t *green, uint16_t *blue); |
| 506 | extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size, |
| 507 | uint16_t *red, uint16_t *green, uint16_t *blue); |
Kristian Høgsberg | b80bcff | 2009-11-12 14:06:45 -0500 | [diff] [blame] | 508 | extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id, |
| 509 | uint32_t flags, void *user_data); |
Michel Dänzer | 7dd2847 | 2016-06-29 18:07:25 +0900 | [diff] [blame] | 510 | extern int drmModePageFlipTarget(int fd, uint32_t crtc_id, uint32_t fb_id, |
| 511 | uint32_t flags, void *user_data, |
| 512 | uint32_t target_vblank); |
Tapani Pälli | cfee521 | 2011-09-23 14:17:42 +0300 | [diff] [blame] | 513 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 514 | extern drmModePlaneResPtr drmModeGetPlaneResources(int fd); |
| 515 | extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id); |
| 516 | extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id, |
| 517 | uint32_t fb_id, uint32_t flags, |
Daniel Kurtz | 828c3e8 | 2014-05-01 19:56:43 +0800 | [diff] [blame] | 518 | int32_t crtc_x, int32_t crtc_y, |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 519 | uint32_t crtc_w, uint32_t crtc_h, |
| 520 | uint32_t src_x, uint32_t src_y, |
| 521 | uint32_t src_w, uint32_t src_h); |
| 522 | |
Paulo Zanoni | 8c75703 | 2012-05-15 18:38:28 -0300 | [diff] [blame] | 523 | extern drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd, |
| 524 | uint32_t object_id, |
| 525 | uint32_t object_type); |
| 526 | extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr); |
| 527 | extern int drmModeObjectSetProperty(int fd, uint32_t object_id, |
| 528 | uint32_t object_type, uint32_t property_id, |
| 529 | uint64_t value); |
| 530 | |
Ville Syrjälä | ed44e0b | 2015-06-22 17:26:02 +0100 | [diff] [blame] | 531 | |
| 532 | typedef struct _drmModeAtomicReq drmModeAtomicReq, *drmModeAtomicReqPtr; |
| 533 | |
| 534 | extern drmModeAtomicReqPtr drmModeAtomicAlloc(void); |
| 535 | extern drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr req); |
| 536 | extern int drmModeAtomicMerge(drmModeAtomicReqPtr base, |
| 537 | drmModeAtomicReqPtr augment); |
| 538 | extern void drmModeAtomicFree(drmModeAtomicReqPtr req); |
| 539 | extern int drmModeAtomicGetCursor(drmModeAtomicReqPtr req); |
| 540 | extern void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor); |
| 541 | extern int drmModeAtomicAddProperty(drmModeAtomicReqPtr req, |
| 542 | uint32_t object_id, |
| 543 | uint32_t property_id, |
| 544 | uint64_t value); |
| 545 | extern int drmModeAtomicCommit(int fd, |
| 546 | drmModeAtomicReqPtr req, |
| 547 | uint32_t flags, |
| 548 | void *user_data); |
| 549 | |
Daniel Stone | 32471b2 | 2015-06-22 17:26:03 +0100 | [diff] [blame] | 550 | extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size, |
| 551 | uint32_t *id); |
| 552 | extern int drmModeDestroyPropertyBlob(int fd, uint32_t id); |
| 553 | |
Keith Packard | c417153 | 2017-03-16 18:11:05 -0700 | [diff] [blame] | 554 | /* |
| 555 | * DRM mode lease APIs. These create and manage new drm_masters with |
| 556 | * access to a subset of the available DRM resources |
| 557 | */ |
| 558 | |
| 559 | extern int drmModeCreateLease(int fd, const uint32_t *objects, int num_objects, int flags, uint32_t *lessee_id); |
| 560 | |
| 561 | typedef struct drmModeLesseeList { |
| 562 | uint32_t count; |
Simon Ser | 31dc148 | 2020-11-26 17:20:04 +0100 | [diff] [blame] | 563 | uint32_t lessees[]; |
Keith Packard | c417153 | 2017-03-16 18:11:05 -0700 | [diff] [blame] | 564 | } drmModeLesseeListRes, *drmModeLesseeListPtr; |
| 565 | |
| 566 | extern drmModeLesseeListPtr drmModeListLessees(int fd); |
| 567 | |
| 568 | typedef struct drmModeObjectList { |
| 569 | uint32_t count; |
Simon Ser | 31dc148 | 2020-11-26 17:20:04 +0100 | [diff] [blame] | 570 | uint32_t objects[]; |
Keith Packard | c417153 | 2017-03-16 18:11:05 -0700 | [diff] [blame] | 571 | } drmModeObjectListRes, *drmModeObjectListPtr; |
| 572 | |
| 573 | extern drmModeObjectListPtr drmModeGetLease(int fd); |
| 574 | |
| 575 | extern int drmModeRevokeLease(int fd, uint32_t lessee_id); |
Daniel Stone | 32471b2 | 2015-06-22 17:26:03 +0100 | [diff] [blame] | 576 | |
Tapani Pälli | 1c20574 | 2015-08-07 10:37:56 +0300 | [diff] [blame] | 577 | #if defined(__cplusplus) |
Tapani Pälli | cfee521 | 2011-09-23 14:17:42 +0300 | [diff] [blame] | 578 | } |
| 579 | #endif |
David Herrman | fd39e61 | 2012-03-09 13:40:14 -0500 | [diff] [blame] | 580 | |
| 581 | #endif |