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