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 | b82ed18 | 2020-12-11 22:23:00 +0100 | [diff] [blame] | 44 | #include <drm_mode.h> |
Luigi Santivetti | e641e2a | 2021-03-25 22:42:38 +0000 | [diff] [blame] | 45 | #include <stdbool.h> |
Simon Ser | d5682de | 2019-10-26 19:36:37 +0200 | [diff] [blame] | 46 | #include <stddef.h> |
| 47 | #include <stdint.h> |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * This is the interface for modesetting for drm. |
| 51 | * |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 52 | * 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] | 53 | * 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] | 54 | * |
| 55 | * More information can be found in randrproto.txt which can be found here: |
| 56 | * http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git |
| 57 | * |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 58 | * 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] | 59 | * need to create the memory object of the framebuffer yourself with the ttm |
| 60 | * buffer object interface. This object needs to be pinned. |
| 61 | */ |
| 62 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 63 | /* |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 64 | * Feature defines |
| 65 | * |
| 66 | * Just because these are defined doesn't mean that the kernel |
| 67 | * can do that feature, its just for new code vs old libdrm. |
| 68 | */ |
| 69 | #define DRM_MODE_FEATURE_KMS 1 |
| 70 | #define DRM_MODE_FEATURE_DIRTYFB 1 |
| 71 | |
| 72 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 73 | typedef struct _drmModeRes { |
| 74 | |
| 75 | int count_fbs; |
| 76 | uint32_t *fbs; |
| 77 | |
| 78 | int count_crtcs; |
| 79 | uint32_t *crtcs; |
| 80 | |
| 81 | int count_connectors; |
| 82 | uint32_t *connectors; |
| 83 | |
| 84 | int count_encoders; |
| 85 | uint32_t *encoders; |
| 86 | |
| 87 | uint32_t min_width, max_width; |
| 88 | uint32_t min_height, max_height; |
| 89 | } drmModeRes, *drmModeResPtr; |
| 90 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 91 | typedef struct _drmModeModeInfo { |
| 92 | uint32_t clock; |
| 93 | uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew; |
| 94 | uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan; |
| 95 | |
Marcin Kościelnicki | 694ef59 | 2010-02-27 15:04:42 +0000 | [diff] [blame] | 96 | uint32_t vrefresh; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 97 | |
| 98 | uint32_t flags; |
| 99 | uint32_t type; |
| 100 | char name[DRM_DISPLAY_MODE_LEN]; |
| 101 | } drmModeModeInfo, *drmModeModeInfoPtr; |
| 102 | |
| 103 | typedef struct _drmModeFB { |
| 104 | uint32_t fb_id; |
| 105 | uint32_t width, height; |
| 106 | uint32_t pitch; |
| 107 | uint32_t bpp; |
| 108 | uint32_t depth; |
| 109 | /* driver specific handle */ |
| 110 | uint32_t handle; |
| 111 | } drmModeFB, *drmModeFBPtr; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 112 | |
Daniel Stone | d8731e9 | 2020-02-11 12:19:16 -0800 | [diff] [blame] | 113 | typedef struct _drmModeFB2 { |
| 114 | uint32_t fb_id; |
| 115 | uint32_t width, height; |
| 116 | uint32_t pixel_format; /* fourcc code from drm_fourcc.h */ |
| 117 | uint64_t modifier; /* applies to all buffers */ |
| 118 | uint32_t flags; |
| 119 | |
| 120 | /* per-plane GEM handle; may be duplicate entries for multiple planes */ |
| 121 | uint32_t handles[4]; |
| 122 | uint32_t pitches[4]; /* bytes */ |
| 123 | uint32_t offsets[4]; /* bytes */ |
| 124 | } drmModeFB2, *drmModeFB2Ptr; |
| 125 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 126 | typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr; |
| 127 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 128 | typedef struct _drmModePropertyBlob { |
| 129 | uint32_t id; |
| 130 | uint32_t length; |
| 131 | void *data; |
| 132 | } drmModePropertyBlobRes, *drmModePropertyBlobPtr; |
| 133 | |
| 134 | typedef struct _drmModeProperty { |
| 135 | uint32_t prop_id; |
| 136 | uint32_t flags; |
| 137 | char name[DRM_PROP_NAME_LEN]; |
| 138 | int count_values; |
Daniel Kurtz | 0f4452b | 2013-08-26 23:39:16 +0800 | [diff] [blame] | 139 | uint64_t *values; /* store the blob lengths */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 140 | int count_enums; |
| 141 | struct drm_mode_property_enum *enums; |
| 142 | int count_blobs; |
Daniel Kurtz | 0f4452b | 2013-08-26 23:39:16 +0800 | [diff] [blame] | 143 | uint32_t *blob_ids; /* store the blob IDs */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 144 | } drmModePropertyRes, *drmModePropertyPtr; |
| 145 | |
Simon Ser | 6d82161 | 2021-02-25 12:19:43 +0100 | [diff] [blame] | 146 | static inline uint32_t drmModeGetPropertyType(const drmModePropertyRes *prop) |
| 147 | { |
| 148 | return prop->flags & (DRM_MODE_PROP_LEGACY_TYPE | DRM_MODE_PROP_EXTENDED_TYPE); |
| 149 | } |
| 150 | |
Simon Ser | 02ac4a0 | 2021-06-15 14:48:28 +0200 | [diff] [blame] | 151 | static inline int drm_property_type_is(const drmModePropertyPtr property, |
| 152 | uint32_t type) |
| 153 | { |
| 154 | return drmModeGetPropertyType(property) == type; |
| 155 | } |
| 156 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 157 | typedef struct _drmModeCrtc { |
| 158 | uint32_t crtc_id; |
| 159 | uint32_t buffer_id; /**< FB id to connect to 0 = disconnect */ |
| 160 | |
| 161 | uint32_t x, y; /**< Position on the framebuffer */ |
| 162 | uint32_t width, height; |
| 163 | int mode_valid; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 164 | drmModeModeInfo mode; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 165 | |
| 166 | int gamma_size; /**< Number of gamma stops */ |
| 167 | |
| 168 | } drmModeCrtc, *drmModeCrtcPtr; |
| 169 | |
| 170 | typedef struct _drmModeEncoder { |
| 171 | uint32_t encoder_id; |
| 172 | uint32_t encoder_type; |
| 173 | uint32_t crtc_id; |
| 174 | uint32_t possible_crtcs; |
| 175 | uint32_t possible_clones; |
| 176 | } drmModeEncoder, *drmModeEncoderPtr; |
| 177 | |
Simon Ser | df37342 | 2020-11-18 10:58:59 +0100 | [diff] [blame] | 178 | /** |
| 179 | * Describes the connector status. |
| 180 | * |
| 181 | * DRM_MODE_CONNECTED means that the connector has a sink plugged in. |
| 182 | * DRM_MODE_DISCONNECTED means the contrary. DRM_MODE_UNKNOWNCONNECTION is used |
| 183 | * when it could be either. |
| 184 | * |
| 185 | * User-space should first try to enable DRM_MODE_CONNECTED connectors and |
| 186 | * ignore other connectors. If there are no DRM_MODE_CONNECTED connectors, |
| 187 | * user-space should then try to probe and enable DRM_MODE_UNKNOWNCONNECTION |
| 188 | * connectors. |
| 189 | */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 190 | typedef enum { |
| 191 | DRM_MODE_CONNECTED = 1, |
| 192 | DRM_MODE_DISCONNECTED = 2, |
| 193 | DRM_MODE_UNKNOWNCONNECTION = 3 |
| 194 | } drmModeConnection; |
| 195 | |
| 196 | typedef enum { |
| 197 | DRM_MODE_SUBPIXEL_UNKNOWN = 1, |
| 198 | DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2, |
| 199 | DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3, |
| 200 | DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4, |
| 201 | DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5, |
| 202 | DRM_MODE_SUBPIXEL_NONE = 6 |
| 203 | } drmModeSubPixel; |
| 204 | |
| 205 | typedef struct _drmModeConnector { |
| 206 | uint32_t connector_id; |
| 207 | uint32_t encoder_id; /**< Encoder currently connected to */ |
| 208 | uint32_t connector_type; |
| 209 | uint32_t connector_type_id; |
| 210 | drmModeConnection connection; |
| 211 | uint32_t mmWidth, mmHeight; /**< HxW in millimeters */ |
| 212 | drmModeSubPixel subpixel; |
| 213 | |
| 214 | int count_modes; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 215 | drmModeModeInfoPtr modes; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 216 | |
| 217 | int count_props; |
| 218 | uint32_t *props; /**< List of property ids */ |
| 219 | uint64_t *prop_values; /**< List of property values */ |
| 220 | |
| 221 | int count_encoders; |
| 222 | uint32_t *encoders; /**< List of encoder ids */ |
| 223 | } drmModeConnector, *drmModeConnectorPtr; |
| 224 | |
Matt Roper | 8fc62ca | 2014-04-10 14:23:12 -0700 | [diff] [blame] | 225 | #define DRM_PLANE_TYPE_OVERLAY 0 |
| 226 | #define DRM_PLANE_TYPE_PRIMARY 1 |
| 227 | #define DRM_PLANE_TYPE_CURSOR 2 |
| 228 | |
Paulo Zanoni | 8c75703 | 2012-05-15 18:38:28 -0300 | [diff] [blame] | 229 | typedef struct _drmModeObjectProperties { |
| 230 | uint32_t count_props; |
| 231 | uint32_t *props; |
| 232 | uint64_t *prop_values; |
| 233 | } drmModeObjectProperties, *drmModeObjectPropertiesPtr; |
| 234 | |
Luigi Santivetti | e641e2a | 2021-03-25 22:42:38 +0000 | [diff] [blame] | 235 | typedef struct _drmModeFormatModifierIterator { |
| 236 | uint32_t fmt_idx, mod_idx; |
| 237 | uint32_t fmt; |
| 238 | uint64_t mod; |
| 239 | } drmModeFormatModifierIterator; |
| 240 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 241 | typedef struct _drmModePlane { |
| 242 | uint32_t count_formats; |
| 243 | uint32_t *formats; |
| 244 | uint32_t plane_id; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 245 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 246 | uint32_t crtc_id; |
| 247 | uint32_t fb_id; |
| 248 | |
| 249 | uint32_t crtc_x, crtc_y; |
| 250 | uint32_t x, y; |
| 251 | |
| 252 | uint32_t possible_crtcs; |
| 253 | uint32_t gamma_size; |
| 254 | } drmModePlane, *drmModePlanePtr; |
| 255 | |
| 256 | typedef struct _drmModePlaneRes { |
| 257 | uint32_t count_planes; |
| 258 | uint32_t *planes; |
| 259 | } drmModePlaneRes, *drmModePlaneResPtr; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 260 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 261 | extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr ); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 262 | extern void drmModeFreeResources( drmModeResPtr ptr ); |
| 263 | extern void drmModeFreeFB( drmModeFBPtr ptr ); |
Daniel Stone | d8731e9 | 2020-02-11 12:19:16 -0800 | [diff] [blame] | 264 | extern void drmModeFreeFB2( drmModeFB2Ptr ptr ); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 265 | extern void drmModeFreeCrtc( drmModeCrtcPtr ptr ); |
| 266 | extern void drmModeFreeConnector( drmModeConnectorPtr ptr ); |
| 267 | extern void drmModeFreeEncoder( drmModeEncoderPtr ptr ); |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 268 | extern void drmModeFreePlane( drmModePlanePtr ptr ); |
Ville Syrjälä | a14c3dd | 2012-02-02 14:53:41 -0500 | [diff] [blame] | 269 | extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 270 | |
| 271 | /** |
Simon Ser | 523b365 | 2021-02-23 18:19:33 +0100 | [diff] [blame] | 272 | * Check whether the DRM node supports Kernel Mode-Setting. |
| 273 | * |
| 274 | * Returns 1 if suitable for KMS, 0 otherwise. |
| 275 | */ |
| 276 | extern int drmIsKMS(int fd); |
| 277 | |
| 278 | /** |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 279 | * Retrieves all of the resources associated with a card. |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 280 | */ |
| 281 | extern drmModeResPtr drmModeGetResources(int fd); |
| 282 | |
| 283 | /* |
| 284 | * FrameBuffer manipulation. |
| 285 | */ |
| 286 | |
| 287 | /** |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 288 | * Retrieve information about framebuffer bufferId |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 289 | */ |
| 290 | extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId); |
Daniel Stone | d8731e9 | 2020-02-11 12:19:16 -0800 | [diff] [blame] | 291 | extern drmModeFB2Ptr drmModeGetFB2(int fd, uint32_t bufferId); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 292 | |
| 293 | /** |
| 294 | * Creates a new framebuffer with an buffer object as its scanout buffer. |
| 295 | */ |
| 296 | extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, |
| 297 | uint8_t bpp, uint32_t pitch, uint32_t bo_handle, |
| 298 | uint32_t *buf_id); |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 299 | /* ...with a specific pixel format */ |
| 300 | extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height, |
Tobias Jakobi | 09be541 | 2017-10-10 12:12:52 +0200 | [diff] [blame] | 301 | uint32_t pixel_format, const uint32_t bo_handles[4], |
| 302 | const uint32_t pitches[4], const uint32_t offsets[4], |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 303 | uint32_t *buf_id, uint32_t flags); |
Kristian H. Kristensen | abfa680 | 2016-09-08 13:08:59 -0700 | [diff] [blame] | 304 | |
| 305 | /* ...with format modifiers */ |
| 306 | int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height, |
Tobias Jakobi | 09be541 | 2017-10-10 12:12:52 +0200 | [diff] [blame] | 307 | uint32_t pixel_format, const uint32_t bo_handles[4], |
| 308 | const uint32_t pitches[4], const uint32_t offsets[4], |
| 309 | const uint64_t modifier[4], uint32_t *buf_id, |
| 310 | uint32_t flags); |
Kristian H. Kristensen | abfa680 | 2016-09-08 13:08:59 -0700 | [diff] [blame] | 311 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 312 | /** |
| 313 | * Destroies the given framebuffer. |
| 314 | */ |
| 315 | extern int drmModeRmFB(int fd, uint32_t bufferId); |
| 316 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 317 | /** |
| 318 | * Mark a region of a framebuffer as dirty. |
| 319 | */ |
| 320 | extern int drmModeDirtyFB(int fd, uint32_t bufferId, |
| 321 | drmModeClipPtr clips, uint32_t num_clips); |
| 322 | |
| 323 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 324 | /* |
| 325 | * Crtc functions |
| 326 | */ |
| 327 | |
| 328 | /** |
Eric Engestrom | 360292c | 2018-12-19 14:55:45 +0000 | [diff] [blame] | 329 | * Retrieve information about the ctrt crtcId |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 330 | */ |
| 331 | extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId); |
| 332 | |
| 333 | /** |
| 334 | * Set the mode on a crtc crtcId with the given mode modeId. |
| 335 | */ |
| 336 | int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, |
| 337 | uint32_t x, uint32_t y, uint32_t *connectors, int count, |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 338 | drmModeModeInfoPtr mode); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 339 | |
| 340 | /* |
| 341 | * Cursor functions |
| 342 | */ |
| 343 | |
| 344 | /** |
| 345 | * Set the cursor on crtc |
| 346 | */ |
| 347 | int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height); |
| 348 | |
Dave Airlie | 2e0ab62 | 2013-07-02 09:21:06 +0100 | [diff] [blame] | 349 | 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] | 350 | /** |
| 351 | * Move the cursor on crtc |
| 352 | */ |
| 353 | int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y); |
| 354 | |
| 355 | /** |
| 356 | * Encoder functions |
| 357 | */ |
| 358 | drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id); |
| 359 | |
| 360 | /* |
| 361 | * Connector manipulation |
| 362 | */ |
| 363 | |
| 364 | /** |
Chris Wilson | 5ed5fa1 | 2015-03-04 10:07:19 +0000 | [diff] [blame] | 365 | * Retrieve all information about the connector connectorId. This will do a |
| 366 | * forced probe on the connector to retrieve remote information such as EDIDs |
| 367 | * from the display device. |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 368 | */ |
| 369 | extern drmModeConnectorPtr drmModeGetConnector(int fd, |
Chris Wilson | 5ed5fa1 | 2015-03-04 10:07:19 +0000 | [diff] [blame] | 370 | uint32_t connectorId); |
| 371 | |
| 372 | /** |
| 373 | * Retrieve current information, i.e the currently active mode and encoder, |
| 374 | * about the connector connectorId. This will not do any probing on the |
| 375 | * connector or remote device, and only reports what is currently known. |
| 376 | * For the complete set of modes and encoders associated with the connector |
| 377 | * use drmModeGetConnector() which will do a probe to determine any display |
| 378 | * link changes first. |
| 379 | */ |
| 380 | extern drmModeConnectorPtr drmModeGetConnectorCurrent(int fd, |
| 381 | uint32_t connector_id); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 382 | |
| 383 | /** |
| 384 | * Attaches the given mode to an connector. |
| 385 | */ |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 386 | extern int drmModeAttachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 387 | |
| 388 | /** |
| 389 | * Detaches a mode from the connector |
| 390 | * must be unused, by the given mode. |
| 391 | */ |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 392 | extern int drmModeDetachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 393 | |
| 394 | extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId); |
| 395 | extern void drmModeFreeProperty(drmModePropertyPtr ptr); |
| 396 | |
| 397 | extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id); |
Luigi Santivetti | e641e2a | 2021-03-25 22:42:38 +0000 | [diff] [blame] | 398 | extern bool drmModeFormatModifierBlobIterNext(const drmModePropertyBlobRes *blob, |
| 399 | drmModeFormatModifierIterator *iter); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 400 | extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr); |
| 401 | extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id, |
| 402 | uint64_t value); |
| 403 | extern int drmCheckModesettingSupported(const char *busid); |
| 404 | |
| 405 | extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, |
| 406 | uint16_t *red, uint16_t *green, uint16_t *blue); |
| 407 | extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size, |
| 408 | uint16_t *red, uint16_t *green, uint16_t *blue); |
Kristian Høgsberg | b80bcff | 2009-11-12 14:06:45 -0500 | [diff] [blame] | 409 | extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id, |
| 410 | uint32_t flags, void *user_data); |
Michel Dänzer | 7dd2847 | 2016-06-29 18:07:25 +0900 | [diff] [blame] | 411 | extern int drmModePageFlipTarget(int fd, uint32_t crtc_id, uint32_t fb_id, |
| 412 | uint32_t flags, void *user_data, |
| 413 | uint32_t target_vblank); |
Tapani Pälli | cfee521 | 2011-09-23 14:17:42 +0300 | [diff] [blame] | 414 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 415 | extern drmModePlaneResPtr drmModeGetPlaneResources(int fd); |
| 416 | extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id); |
| 417 | extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id, |
| 418 | uint32_t fb_id, uint32_t flags, |
Daniel Kurtz | 828c3e8 | 2014-05-01 19:56:43 +0800 | [diff] [blame] | 419 | int32_t crtc_x, int32_t crtc_y, |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 420 | uint32_t crtc_w, uint32_t crtc_h, |
| 421 | uint32_t src_x, uint32_t src_y, |
| 422 | uint32_t src_w, uint32_t src_h); |
| 423 | |
Paulo Zanoni | 8c75703 | 2012-05-15 18:38:28 -0300 | [diff] [blame] | 424 | extern drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd, |
| 425 | uint32_t object_id, |
| 426 | uint32_t object_type); |
| 427 | extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr); |
| 428 | extern int drmModeObjectSetProperty(int fd, uint32_t object_id, |
| 429 | uint32_t object_type, uint32_t property_id, |
| 430 | uint64_t value); |
| 431 | |
Ville Syrjälä | ed44e0b | 2015-06-22 17:26:02 +0100 | [diff] [blame] | 432 | |
| 433 | typedef struct _drmModeAtomicReq drmModeAtomicReq, *drmModeAtomicReqPtr; |
| 434 | |
| 435 | extern drmModeAtomicReqPtr drmModeAtomicAlloc(void); |
| 436 | extern drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr req); |
| 437 | extern int drmModeAtomicMerge(drmModeAtomicReqPtr base, |
| 438 | drmModeAtomicReqPtr augment); |
| 439 | extern void drmModeAtomicFree(drmModeAtomicReqPtr req); |
| 440 | extern int drmModeAtomicGetCursor(drmModeAtomicReqPtr req); |
| 441 | extern void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor); |
| 442 | extern int drmModeAtomicAddProperty(drmModeAtomicReqPtr req, |
| 443 | uint32_t object_id, |
| 444 | uint32_t property_id, |
| 445 | uint64_t value); |
| 446 | extern int drmModeAtomicCommit(int fd, |
| 447 | drmModeAtomicReqPtr req, |
| 448 | uint32_t flags, |
| 449 | void *user_data); |
| 450 | |
Daniel Stone | 32471b2 | 2015-06-22 17:26:03 +0100 | [diff] [blame] | 451 | extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size, |
| 452 | uint32_t *id); |
| 453 | extern int drmModeDestroyPropertyBlob(int fd, uint32_t id); |
| 454 | |
Keith Packard | c417153 | 2017-03-16 18:11:05 -0700 | [diff] [blame] | 455 | /* |
| 456 | * DRM mode lease APIs. These create and manage new drm_masters with |
| 457 | * access to a subset of the available DRM resources |
| 458 | */ |
| 459 | |
| 460 | extern int drmModeCreateLease(int fd, const uint32_t *objects, int num_objects, int flags, uint32_t *lessee_id); |
| 461 | |
| 462 | typedef struct drmModeLesseeList { |
| 463 | uint32_t count; |
Simon Ser | 31dc148 | 2020-11-26 17:20:04 +0100 | [diff] [blame] | 464 | uint32_t lessees[]; |
Keith Packard | c417153 | 2017-03-16 18:11:05 -0700 | [diff] [blame] | 465 | } drmModeLesseeListRes, *drmModeLesseeListPtr; |
| 466 | |
| 467 | extern drmModeLesseeListPtr drmModeListLessees(int fd); |
| 468 | |
| 469 | typedef struct drmModeObjectList { |
| 470 | uint32_t count; |
Simon Ser | 31dc148 | 2020-11-26 17:20:04 +0100 | [diff] [blame] | 471 | uint32_t objects[]; |
Keith Packard | c417153 | 2017-03-16 18:11:05 -0700 | [diff] [blame] | 472 | } drmModeObjectListRes, *drmModeObjectListPtr; |
| 473 | |
| 474 | extern drmModeObjectListPtr drmModeGetLease(int fd); |
| 475 | |
| 476 | extern int drmModeRevokeLease(int fd, uint32_t lessee_id); |
Daniel Stone | 32471b2 | 2015-06-22 17:26:03 +0100 | [diff] [blame] | 477 | |
Tapani Pälli | 1c20574 | 2015-08-07 10:37:56 +0300 | [diff] [blame] | 478 | #if defined(__cplusplus) |
Tapani Pälli | cfee521 | 2011-09-23 14:17:42 +0300 | [diff] [blame] | 479 | } |
| 480 | #endif |
David Herrman | fd39e61 | 2012-03-09 13:40:14 -0500 | [diff] [blame] | 481 | |
| 482 | #endif |