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> |
| 44 | |
| 45 | /* |
| 46 | * This is the interface for modesetting for drm. |
| 47 | * |
| 48 | * In order to use this interface you must include either <stdint.h> or another |
| 49 | * header defining uint32_t, int32_t and uint16_t. |
| 50 | * |
| 51 | * It aims to provide a randr1.2 compatible interface for modesettings in the |
| 52 | * kernel, the interface is also ment to be used by libraries like EGL. |
| 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 | * |
| 57 | * There are some major diffrences to be noted. Unlike the randr1.2 proto you |
| 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 | /* |
| 63 | * If we pickup an old version of drm.h which doesn't include drm_mode.h |
| 64 | * we should redefine defines. This is so that builds doesn't breaks with |
| 65 | * new libdrm on old kernels. |
| 66 | */ |
| 67 | #ifndef _DRM_MODE_H |
| 68 | |
| 69 | #define DRM_DISPLAY_INFO_LEN 32 |
| 70 | #define DRM_CONNECTOR_NAME_LEN 32 |
| 71 | #define DRM_DISPLAY_MODE_LEN 32 |
| 72 | #define DRM_PROP_NAME_LEN 32 |
| 73 | |
| 74 | #define DRM_MODE_TYPE_BUILTIN (1<<0) |
| 75 | #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) |
| 76 | #define DRM_MODE_TYPE_CRTC_C ((1<<2) | DRM_MODE_TYPE_BUILTIN) |
| 77 | #define DRM_MODE_TYPE_PREFERRED (1<<3) |
| 78 | #define DRM_MODE_TYPE_DEFAULT (1<<4) |
| 79 | #define DRM_MODE_TYPE_USERDEF (1<<5) |
| 80 | #define DRM_MODE_TYPE_DRIVER (1<<6) |
| 81 | |
| 82 | /* Video mode flags */ |
| 83 | /* bit compatible with the xorg definitions. */ |
Damien Lespiau | edf5c7c | 2013-08-23 15:57:40 +0100 | [diff] [blame] | 84 | #define DRM_MODE_FLAG_PHSYNC (1<<0) |
| 85 | #define DRM_MODE_FLAG_NHSYNC (1<<1) |
| 86 | #define DRM_MODE_FLAG_PVSYNC (1<<2) |
| 87 | #define DRM_MODE_FLAG_NVSYNC (1<<3) |
| 88 | #define DRM_MODE_FLAG_INTERLACE (1<<4) |
| 89 | #define DRM_MODE_FLAG_DBLSCAN (1<<5) |
| 90 | #define DRM_MODE_FLAG_CSYNC (1<<6) |
| 91 | #define DRM_MODE_FLAG_PCSYNC (1<<7) |
| 92 | #define DRM_MODE_FLAG_NCSYNC (1<<8) |
| 93 | #define DRM_MODE_FLAG_HSKEW (1<<9) /* hskew provided */ |
| 94 | #define DRM_MODE_FLAG_BCAST (1<<10) |
| 95 | #define DRM_MODE_FLAG_PIXMUX (1<<11) |
| 96 | #define DRM_MODE_FLAG_DBLCLK (1<<12) |
| 97 | #define DRM_MODE_FLAG_CLKDIV2 (1<<13) |
| 98 | #define DRM_MODE_FLAG_3D_MASK (0x1f<<14) |
| 99 | #define DRM_MODE_FLAG_3D_NONE (0<<14) |
| 100 | #define DRM_MODE_FLAG_3D_FRAME_PACKING (1<<14) |
| 101 | #define DRM_MODE_FLAG_3D_FIELD_ALTERNATIVE (2<<14) |
| 102 | #define DRM_MODE_FLAG_3D_LINE_ALTERNATIVE (3<<14) |
| 103 | #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_FULL (4<<14) |
| 104 | #define DRM_MODE_FLAG_3D_L_DEPTH (5<<14) |
| 105 | #define DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH (6<<14) |
| 106 | #define DRM_MODE_FLAG_3D_TOP_AND_BOTTOM (7<<14) |
| 107 | #define DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF (8<<14) |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 108 | |
| 109 | /* DPMS flags */ |
| 110 | /* bit compatible with the xorg definitions. */ |
| 111 | #define DRM_MODE_DPMS_ON 0 |
| 112 | #define DRM_MODE_DPMS_STANDBY 1 |
| 113 | #define DRM_MODE_DPMS_SUSPEND 2 |
| 114 | #define DRM_MODE_DPMS_OFF 3 |
| 115 | |
| 116 | /* Scaling mode options */ |
| 117 | #define DRM_MODE_SCALE_NON_GPU 0 |
| 118 | #define DRM_MODE_SCALE_FULLSCREEN 1 |
| 119 | #define DRM_MODE_SCALE_NO_SCALE 2 |
| 120 | #define DRM_MODE_SCALE_ASPECT 3 |
| 121 | |
| 122 | /* Dithering mode options */ |
| 123 | #define DRM_MODE_DITHERING_OFF 0 |
| 124 | #define DRM_MODE_DITHERING_ON 1 |
| 125 | |
| 126 | #define DRM_MODE_ENCODER_NONE 0 |
| 127 | #define DRM_MODE_ENCODER_DAC 1 |
| 128 | #define DRM_MODE_ENCODER_TMDS 2 |
| 129 | #define DRM_MODE_ENCODER_LVDS 3 |
| 130 | #define DRM_MODE_ENCODER_TVDAC 4 |
Thomas Hellstrom | c601444 | 2013-11-19 07:50:11 +0100 | [diff] [blame] | 131 | #define DRM_MODE_ENCODER_VIRTUAL 5 |
| 132 | #define DRM_MODE_ENCODER_DSI 6 |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 133 | |
| 134 | #define DRM_MODE_SUBCONNECTOR_Automatic 0 |
| 135 | #define DRM_MODE_SUBCONNECTOR_Unknown 0 |
| 136 | #define DRM_MODE_SUBCONNECTOR_DVID 3 |
| 137 | #define DRM_MODE_SUBCONNECTOR_DVIA 4 |
| 138 | #define DRM_MODE_SUBCONNECTOR_Composite 5 |
| 139 | #define DRM_MODE_SUBCONNECTOR_SVIDEO 6 |
| 140 | #define DRM_MODE_SUBCONNECTOR_Component 8 |
Thomas Hellstrom | c601444 | 2013-11-19 07:50:11 +0100 | [diff] [blame] | 141 | #define DRM_MODE_SUBCONNECTOR_SCART 9 |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 142 | |
| 143 | #define DRM_MODE_CONNECTOR_Unknown 0 |
| 144 | #define DRM_MODE_CONNECTOR_VGA 1 |
| 145 | #define DRM_MODE_CONNECTOR_DVII 2 |
| 146 | #define DRM_MODE_CONNECTOR_DVID 3 |
| 147 | #define DRM_MODE_CONNECTOR_DVIA 4 |
| 148 | #define DRM_MODE_CONNECTOR_Composite 5 |
| 149 | #define DRM_MODE_CONNECTOR_SVIDEO 6 |
| 150 | #define DRM_MODE_CONNECTOR_LVDS 7 |
| 151 | #define DRM_MODE_CONNECTOR_Component 8 |
| 152 | #define DRM_MODE_CONNECTOR_9PinDIN 9 |
| 153 | #define DRM_MODE_CONNECTOR_DisplayPort 10 |
| 154 | #define DRM_MODE_CONNECTOR_HDMIA 11 |
| 155 | #define DRM_MODE_CONNECTOR_HDMIB 12 |
Alex Deucher | 4a17be4 | 2010-02-10 19:39:46 -0500 | [diff] [blame] | 156 | #define DRM_MODE_CONNECTOR_TV 13 |
| 157 | #define DRM_MODE_CONNECTOR_eDP 14 |
Thomas Hellstrom | c601444 | 2013-11-19 07:50:11 +0100 | [diff] [blame] | 158 | #define DRM_MODE_CONNECTOR_VIRTUAL 15 |
| 159 | #define DRM_MODE_CONNECTOR_DSI 16 |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 160 | |
| 161 | #define DRM_MODE_PROP_PENDING (1<<0) |
| 162 | #define DRM_MODE_PROP_RANGE (1<<1) |
| 163 | #define DRM_MODE_PROP_IMMUTABLE (1<<2) |
| 164 | #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */ |
| 165 | #define DRM_MODE_PROP_BLOB (1<<4) |
| 166 | |
| 167 | #define DRM_MODE_CURSOR_BO (1<<0) |
| 168 | #define DRM_MODE_CURSOR_MOVE (1<<1) |
| 169 | |
| 170 | #endif /* _DRM_MODE_H */ |
| 171 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 172 | |
| 173 | /* |
| 174 | * Feature defines |
| 175 | * |
| 176 | * Just because these are defined doesn't mean that the kernel |
| 177 | * can do that feature, its just for new code vs old libdrm. |
| 178 | */ |
| 179 | #define DRM_MODE_FEATURE_KMS 1 |
| 180 | #define DRM_MODE_FEATURE_DIRTYFB 1 |
| 181 | |
| 182 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 183 | typedef struct _drmModeRes { |
| 184 | |
| 185 | int count_fbs; |
| 186 | uint32_t *fbs; |
| 187 | |
| 188 | int count_crtcs; |
| 189 | uint32_t *crtcs; |
| 190 | |
| 191 | int count_connectors; |
| 192 | uint32_t *connectors; |
| 193 | |
| 194 | int count_encoders; |
| 195 | uint32_t *encoders; |
| 196 | |
| 197 | uint32_t min_width, max_width; |
| 198 | uint32_t min_height, max_height; |
| 199 | } drmModeRes, *drmModeResPtr; |
| 200 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 201 | typedef struct _drmModeModeInfo { |
| 202 | uint32_t clock; |
| 203 | uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew; |
| 204 | uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan; |
| 205 | |
Marcin Kościelnicki | 694ef59 | 2010-02-27 15:04:42 +0000 | [diff] [blame] | 206 | uint32_t vrefresh; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 207 | |
| 208 | uint32_t flags; |
| 209 | uint32_t type; |
| 210 | char name[DRM_DISPLAY_MODE_LEN]; |
| 211 | } drmModeModeInfo, *drmModeModeInfoPtr; |
| 212 | |
| 213 | typedef struct _drmModeFB { |
| 214 | uint32_t fb_id; |
| 215 | uint32_t width, height; |
| 216 | uint32_t pitch; |
| 217 | uint32_t bpp; |
| 218 | uint32_t depth; |
| 219 | /* driver specific handle */ |
| 220 | uint32_t handle; |
| 221 | } drmModeFB, *drmModeFBPtr; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 222 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 223 | typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr; |
| 224 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 225 | typedef struct _drmModePropertyBlob { |
| 226 | uint32_t id; |
| 227 | uint32_t length; |
| 228 | void *data; |
| 229 | } drmModePropertyBlobRes, *drmModePropertyBlobPtr; |
| 230 | |
| 231 | typedef struct _drmModeProperty { |
| 232 | uint32_t prop_id; |
| 233 | uint32_t flags; |
| 234 | char name[DRM_PROP_NAME_LEN]; |
| 235 | int count_values; |
Daniel Kurtz | 0f4452b | 2013-08-26 23:39:16 +0800 | [diff] [blame] | 236 | uint64_t *values; /* store the blob lengths */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 237 | int count_enums; |
| 238 | struct drm_mode_property_enum *enums; |
| 239 | int count_blobs; |
Daniel Kurtz | 0f4452b | 2013-08-26 23:39:16 +0800 | [diff] [blame] | 240 | uint32_t *blob_ids; /* store the blob IDs */ |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 241 | } drmModePropertyRes, *drmModePropertyPtr; |
| 242 | |
Daniel Kurtz | d20314d | 2015-03-24 18:01:02 -0700 | [diff] [blame] | 243 | static __inline int drm_property_type_is(drmModePropertyPtr property, |
Rob Clark | fb41770 | 2013-10-12 12:16:44 -0400 | [diff] [blame] | 244 | uint32_t type) |
| 245 | { |
| 246 | /* instanceof for props.. handles extended type vs original types: */ |
| 247 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) |
| 248 | return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; |
| 249 | return property->flags & type; |
| 250 | } |
| 251 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 252 | typedef struct _drmModeCrtc { |
| 253 | uint32_t crtc_id; |
| 254 | uint32_t buffer_id; /**< FB id to connect to 0 = disconnect */ |
| 255 | |
| 256 | uint32_t x, y; /**< Position on the framebuffer */ |
| 257 | uint32_t width, height; |
| 258 | int mode_valid; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 259 | drmModeModeInfo mode; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 260 | |
| 261 | int gamma_size; /**< Number of gamma stops */ |
| 262 | |
| 263 | } drmModeCrtc, *drmModeCrtcPtr; |
| 264 | |
| 265 | typedef struct _drmModeEncoder { |
| 266 | uint32_t encoder_id; |
| 267 | uint32_t encoder_type; |
| 268 | uint32_t crtc_id; |
| 269 | uint32_t possible_crtcs; |
| 270 | uint32_t possible_clones; |
| 271 | } drmModeEncoder, *drmModeEncoderPtr; |
| 272 | |
| 273 | typedef enum { |
| 274 | DRM_MODE_CONNECTED = 1, |
| 275 | DRM_MODE_DISCONNECTED = 2, |
| 276 | DRM_MODE_UNKNOWNCONNECTION = 3 |
| 277 | } drmModeConnection; |
| 278 | |
| 279 | typedef enum { |
| 280 | DRM_MODE_SUBPIXEL_UNKNOWN = 1, |
| 281 | DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2, |
| 282 | DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3, |
| 283 | DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4, |
| 284 | DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5, |
| 285 | DRM_MODE_SUBPIXEL_NONE = 6 |
| 286 | } drmModeSubPixel; |
| 287 | |
| 288 | typedef struct _drmModeConnector { |
| 289 | uint32_t connector_id; |
| 290 | uint32_t encoder_id; /**< Encoder currently connected to */ |
| 291 | uint32_t connector_type; |
| 292 | uint32_t connector_type_id; |
| 293 | drmModeConnection connection; |
| 294 | uint32_t mmWidth, mmHeight; /**< HxW in millimeters */ |
| 295 | drmModeSubPixel subpixel; |
| 296 | |
| 297 | int count_modes; |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 298 | drmModeModeInfoPtr modes; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 299 | |
| 300 | int count_props; |
| 301 | uint32_t *props; /**< List of property ids */ |
| 302 | uint64_t *prop_values; /**< List of property values */ |
| 303 | |
| 304 | int count_encoders; |
| 305 | uint32_t *encoders; /**< List of encoder ids */ |
| 306 | } drmModeConnector, *drmModeConnectorPtr; |
| 307 | |
Matt Roper | 8fc62ca | 2014-04-10 14:23:12 -0700 | [diff] [blame] | 308 | #define DRM_PLANE_TYPE_OVERLAY 0 |
| 309 | #define DRM_PLANE_TYPE_PRIMARY 1 |
| 310 | #define DRM_PLANE_TYPE_CURSOR 2 |
| 311 | |
Paulo Zanoni | 8c75703 | 2012-05-15 18:38:28 -0300 | [diff] [blame] | 312 | typedef struct _drmModeObjectProperties { |
| 313 | uint32_t count_props; |
| 314 | uint32_t *props; |
| 315 | uint64_t *prop_values; |
| 316 | } drmModeObjectProperties, *drmModeObjectPropertiesPtr; |
| 317 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 318 | typedef struct _drmModePlane { |
| 319 | uint32_t count_formats; |
| 320 | uint32_t *formats; |
| 321 | uint32_t plane_id; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 322 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 323 | uint32_t crtc_id; |
| 324 | uint32_t fb_id; |
| 325 | |
| 326 | uint32_t crtc_x, crtc_y; |
| 327 | uint32_t x, y; |
| 328 | |
| 329 | uint32_t possible_crtcs; |
| 330 | uint32_t gamma_size; |
| 331 | } drmModePlane, *drmModePlanePtr; |
| 332 | |
| 333 | typedef struct _drmModePlaneRes { |
| 334 | uint32_t count_planes; |
| 335 | uint32_t *planes; |
| 336 | } drmModePlaneRes, *drmModePlaneResPtr; |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 337 | |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 338 | extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr ); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 339 | extern void drmModeFreeResources( drmModeResPtr ptr ); |
| 340 | extern void drmModeFreeFB( drmModeFBPtr ptr ); |
| 341 | extern void drmModeFreeCrtc( drmModeCrtcPtr ptr ); |
| 342 | extern void drmModeFreeConnector( drmModeConnectorPtr ptr ); |
| 343 | extern void drmModeFreeEncoder( drmModeEncoderPtr ptr ); |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 344 | extern void drmModeFreePlane( drmModePlanePtr ptr ); |
Ville Syrjälä | a14c3dd | 2012-02-02 14:53:41 -0500 | [diff] [blame] | 345 | extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 346 | |
| 347 | /** |
| 348 | * Retrives all of the resources associated with a card. |
| 349 | */ |
| 350 | extern drmModeResPtr drmModeGetResources(int fd); |
| 351 | |
| 352 | /* |
| 353 | * FrameBuffer manipulation. |
| 354 | */ |
| 355 | |
| 356 | /** |
| 357 | * Retrive information about framebuffer bufferId |
| 358 | */ |
| 359 | extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId); |
| 360 | |
| 361 | /** |
| 362 | * Creates a new framebuffer with an buffer object as its scanout buffer. |
| 363 | */ |
| 364 | extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, |
| 365 | uint8_t bpp, uint32_t pitch, uint32_t bo_handle, |
| 366 | uint32_t *buf_id); |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 367 | /* ...with a specific pixel format */ |
| 368 | extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height, |
| 369 | uint32_t pixel_format, uint32_t bo_handles[4], |
| 370 | uint32_t pitches[4], uint32_t offsets[4], |
| 371 | uint32_t *buf_id, uint32_t flags); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 372 | /** |
| 373 | * Destroies the given framebuffer. |
| 374 | */ |
| 375 | extern int drmModeRmFB(int fd, uint32_t bufferId); |
| 376 | |
Jakob Bornecrantz | 3e48613 | 2009-11-24 18:00:12 +0100 | [diff] [blame] | 377 | /** |
| 378 | * Mark a region of a framebuffer as dirty. |
| 379 | */ |
| 380 | extern int drmModeDirtyFB(int fd, uint32_t bufferId, |
| 381 | drmModeClipPtr clips, uint32_t num_clips); |
| 382 | |
| 383 | |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 384 | /* |
| 385 | * Crtc functions |
| 386 | */ |
| 387 | |
| 388 | /** |
| 389 | * Retrive information about the ctrt crtcId |
| 390 | */ |
| 391 | extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId); |
| 392 | |
| 393 | /** |
| 394 | * Set the mode on a crtc crtcId with the given mode modeId. |
| 395 | */ |
| 396 | int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, |
| 397 | uint32_t x, uint32_t y, uint32_t *connectors, int count, |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 398 | drmModeModeInfoPtr mode); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 399 | |
| 400 | /* |
| 401 | * Cursor functions |
| 402 | */ |
| 403 | |
| 404 | /** |
| 405 | * Set the cursor on crtc |
| 406 | */ |
| 407 | int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height); |
| 408 | |
Dave Airlie | 2e0ab62 | 2013-07-02 09:21:06 +0100 | [diff] [blame] | 409 | 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] | 410 | /** |
| 411 | * Move the cursor on crtc |
| 412 | */ |
| 413 | int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y); |
| 414 | |
| 415 | /** |
| 416 | * Encoder functions |
| 417 | */ |
| 418 | drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id); |
| 419 | |
| 420 | /* |
| 421 | * Connector manipulation |
| 422 | */ |
| 423 | |
| 424 | /** |
Chris Wilson | 5ed5fa1 | 2015-03-04 10:07:19 +0000 | [diff] [blame] | 425 | * Retrieve all information about the connector connectorId. This will do a |
| 426 | * forced probe on the connector to retrieve remote information such as EDIDs |
| 427 | * from the display device. |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 428 | */ |
| 429 | extern drmModeConnectorPtr drmModeGetConnector(int fd, |
Chris Wilson | 5ed5fa1 | 2015-03-04 10:07:19 +0000 | [diff] [blame] | 430 | uint32_t connectorId); |
| 431 | |
| 432 | /** |
| 433 | * Retrieve current information, i.e the currently active mode and encoder, |
| 434 | * about the connector connectorId. This will not do any probing on the |
| 435 | * connector or remote device, and only reports what is currently known. |
| 436 | * For the complete set of modes and encoders associated with the connector |
| 437 | * use drmModeGetConnector() which will do a probe to determine any display |
| 438 | * link changes first. |
| 439 | */ |
| 440 | extern drmModeConnectorPtr drmModeGetConnectorCurrent(int fd, |
| 441 | uint32_t connector_id); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 442 | |
| 443 | /** |
| 444 | * Attaches the given mode to an connector. |
| 445 | */ |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 446 | extern int drmModeAttachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 447 | |
| 448 | /** |
| 449 | * Detaches a mode from the connector |
| 450 | * must be unused, by the given mode. |
| 451 | */ |
Jakob Bornecrantz | eb78c53 | 2009-02-11 16:43:20 +0100 | [diff] [blame] | 452 | extern int drmModeDetachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info); |
Jesse Barnes | 731cd55 | 2008-12-17 10:09:49 -0800 | [diff] [blame] | 453 | |
| 454 | extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId); |
| 455 | extern void drmModeFreeProperty(drmModePropertyPtr ptr); |
| 456 | |
| 457 | extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id); |
| 458 | extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr); |
| 459 | extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id, |
| 460 | uint64_t value); |
| 461 | extern int drmCheckModesettingSupported(const char *busid); |
| 462 | |
| 463 | extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, |
| 464 | uint16_t *red, uint16_t *green, uint16_t *blue); |
| 465 | extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size, |
| 466 | uint16_t *red, uint16_t *green, uint16_t *blue); |
Kristian Høgsberg | b80bcff | 2009-11-12 14:06:45 -0500 | [diff] [blame] | 467 | extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id, |
| 468 | uint32_t flags, void *user_data); |
Tapani Pälli | cfee521 | 2011-09-23 14:17:42 +0300 | [diff] [blame] | 469 | |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 470 | extern drmModePlaneResPtr drmModeGetPlaneResources(int fd); |
| 471 | extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id); |
| 472 | extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id, |
| 473 | uint32_t fb_id, uint32_t flags, |
Daniel Kurtz | 828c3e8 | 2014-05-01 19:56:43 +0800 | [diff] [blame] | 474 | int32_t crtc_x, int32_t crtc_y, |
Jesse Barnes | ac168bf | 2011-04-29 08:53:53 -0700 | [diff] [blame] | 475 | uint32_t crtc_w, uint32_t crtc_h, |
| 476 | uint32_t src_x, uint32_t src_y, |
| 477 | uint32_t src_w, uint32_t src_h); |
| 478 | |
Paulo Zanoni | 8c75703 | 2012-05-15 18:38:28 -0300 | [diff] [blame] | 479 | extern drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd, |
| 480 | uint32_t object_id, |
| 481 | uint32_t object_type); |
| 482 | extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr); |
| 483 | extern int drmModeObjectSetProperty(int fd, uint32_t object_id, |
| 484 | uint32_t object_type, uint32_t property_id, |
| 485 | uint64_t value); |
| 486 | |
Ville Syrjälä | ed44e0b | 2015-06-22 17:26:02 +0100 | [diff] [blame] | 487 | |
| 488 | typedef struct _drmModeAtomicReq drmModeAtomicReq, *drmModeAtomicReqPtr; |
| 489 | |
| 490 | extern drmModeAtomicReqPtr drmModeAtomicAlloc(void); |
| 491 | extern drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr req); |
| 492 | extern int drmModeAtomicMerge(drmModeAtomicReqPtr base, |
| 493 | drmModeAtomicReqPtr augment); |
| 494 | extern void drmModeAtomicFree(drmModeAtomicReqPtr req); |
| 495 | extern int drmModeAtomicGetCursor(drmModeAtomicReqPtr req); |
| 496 | extern void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor); |
| 497 | extern int drmModeAtomicAddProperty(drmModeAtomicReqPtr req, |
| 498 | uint32_t object_id, |
| 499 | uint32_t property_id, |
| 500 | uint64_t value); |
| 501 | extern int drmModeAtomicCommit(int fd, |
| 502 | drmModeAtomicReqPtr req, |
| 503 | uint32_t flags, |
| 504 | void *user_data); |
| 505 | |
Daniel Stone | 32471b2 | 2015-06-22 17:26:03 +0100 | [diff] [blame] | 506 | extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size, |
| 507 | uint32_t *id); |
| 508 | extern int drmModeDestroyPropertyBlob(int fd, uint32_t id); |
| 509 | |
| 510 | |
Tapani Pälli | 1c20574 | 2015-08-07 10:37:56 +0300 | [diff] [blame] | 511 | #if defined(__cplusplus) |
Tapani Pälli | cfee521 | 2011-09-23 14:17:42 +0300 | [diff] [blame] | 512 | } |
| 513 | #endif |
David Herrman | fd39e61 | 2012-03-09 13:40:14 -0500 | [diff] [blame] | 514 | |
| 515 | #endif |