File indexing completed on 2025-01-17 09:56:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifndef _XF86DRMMODE_H_
0037 #define _XF86DRMMODE_H_
0038
0039 #if defined(__cplusplus)
0040 extern "C" {
0041 #endif
0042
0043 #include <drm.h>
0044 #include <drm_mode.h>
0045 #include <stdbool.h>
0046 #include <stddef.h>
0047 #include <stdint.h>
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 #define DRM_MODE_FEATURE_KMS 1
0070 #define DRM_MODE_FEATURE_DIRTYFB 1
0071
0072
0073 typedef struct _drmModeRes {
0074
0075 int count_fbs;
0076 uint32_t *fbs;
0077
0078 int count_crtcs;
0079 uint32_t *crtcs;
0080
0081 int count_connectors;
0082 uint32_t *connectors;
0083
0084 int count_encoders;
0085 uint32_t *encoders;
0086
0087 uint32_t min_width, max_width;
0088 uint32_t min_height, max_height;
0089 } drmModeRes, *drmModeResPtr;
0090
0091 typedef struct _drmModeModeInfo {
0092 uint32_t clock;
0093 uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
0094 uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
0095
0096 uint32_t vrefresh;
0097
0098 uint32_t flags;
0099 uint32_t type;
0100 char name[DRM_DISPLAY_MODE_LEN];
0101 } drmModeModeInfo, *drmModeModeInfoPtr;
0102
0103 typedef struct _drmModeFB {
0104 uint32_t fb_id;
0105 uint32_t width, height;
0106 uint32_t pitch;
0107 uint32_t bpp;
0108 uint32_t depth;
0109
0110 uint32_t handle;
0111 } drmModeFB, *drmModeFBPtr;
0112
0113 typedef struct _drmModeFB2 {
0114 uint32_t fb_id;
0115 uint32_t width, height;
0116 uint32_t pixel_format;
0117 uint64_t modifier;
0118 uint32_t flags;
0119
0120
0121 uint32_t handles[4];
0122 uint32_t pitches[4];
0123 uint32_t offsets[4];
0124 } drmModeFB2, *drmModeFB2Ptr;
0125
0126 typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr;
0127
0128 typedef struct _drmModePropertyBlob {
0129 uint32_t id;
0130 uint32_t length;
0131 void *data;
0132 } drmModePropertyBlobRes, *drmModePropertyBlobPtr;
0133
0134 typedef struct _drmModeProperty {
0135 uint32_t prop_id;
0136 uint32_t flags;
0137 char name[DRM_PROP_NAME_LEN];
0138 int count_values;
0139 uint64_t *values;
0140 int count_enums;
0141 struct drm_mode_property_enum *enums;
0142 int count_blobs;
0143 uint32_t *blob_ids;
0144 } drmModePropertyRes, *drmModePropertyPtr;
0145
0146 static inline uint32_t drmModeGetPropertyType(const drmModePropertyRes *prop)
0147 {
0148 return prop->flags & (DRM_MODE_PROP_LEGACY_TYPE | DRM_MODE_PROP_EXTENDED_TYPE);
0149 }
0150
0151 static inline int drm_property_type_is(const drmModePropertyPtr property,
0152 uint32_t type)
0153 {
0154 return drmModeGetPropertyType(property) == type;
0155 }
0156
0157 typedef struct _drmModeCrtc {
0158 uint32_t crtc_id;
0159 uint32_t buffer_id;
0160
0161 uint32_t x, y;
0162 uint32_t width, height;
0163 int mode_valid;
0164 drmModeModeInfo mode;
0165
0166 int gamma_size;
0167
0168 } drmModeCrtc, *drmModeCrtcPtr;
0169
0170 typedef struct _drmModeEncoder {
0171 uint32_t encoder_id;
0172 uint32_t encoder_type;
0173 uint32_t crtc_id;
0174 uint32_t possible_crtcs;
0175 uint32_t possible_clones;
0176 } drmModeEncoder, *drmModeEncoderPtr;
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190 typedef enum {
0191 DRM_MODE_CONNECTED = 1,
0192 DRM_MODE_DISCONNECTED = 2,
0193 DRM_MODE_UNKNOWNCONNECTION = 3
0194 } drmModeConnection;
0195
0196 typedef enum {
0197 DRM_MODE_SUBPIXEL_UNKNOWN = 1,
0198 DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2,
0199 DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3,
0200 DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4,
0201 DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5,
0202 DRM_MODE_SUBPIXEL_NONE = 6
0203 } drmModeSubPixel;
0204
0205 typedef struct _drmModeConnector {
0206 uint32_t connector_id;
0207 uint32_t encoder_id;
0208 uint32_t connector_type;
0209 uint32_t connector_type_id;
0210 drmModeConnection connection;
0211 uint32_t mmWidth, mmHeight;
0212 drmModeSubPixel subpixel;
0213
0214 int count_modes;
0215 drmModeModeInfoPtr modes;
0216
0217 int count_props;
0218 uint32_t *props;
0219 uint64_t *prop_values;
0220
0221 int count_encoders;
0222 uint32_t *encoders;
0223 } drmModeConnector, *drmModeConnectorPtr;
0224
0225 #define DRM_PLANE_TYPE_OVERLAY 0
0226 #define DRM_PLANE_TYPE_PRIMARY 1
0227 #define DRM_PLANE_TYPE_CURSOR 2
0228
0229 typedef struct _drmModeObjectProperties {
0230 uint32_t count_props;
0231 uint32_t *props;
0232 uint64_t *prop_values;
0233 } drmModeObjectProperties, *drmModeObjectPropertiesPtr;
0234
0235 typedef struct _drmModeFormatModifierIterator {
0236 uint32_t fmt_idx, mod_idx;
0237 uint32_t fmt;
0238 uint64_t mod;
0239 } drmModeFormatModifierIterator;
0240
0241 typedef struct _drmModePlane {
0242 uint32_t count_formats;
0243 uint32_t *formats;
0244 uint32_t plane_id;
0245
0246 uint32_t crtc_id;
0247 uint32_t fb_id;
0248
0249 uint32_t crtc_x, crtc_y;
0250 uint32_t x, y;
0251
0252 uint32_t possible_crtcs;
0253 uint32_t gamma_size;
0254 } drmModePlane, *drmModePlanePtr;
0255
0256 typedef struct _drmModePlaneRes {
0257 uint32_t count_planes;
0258 uint32_t *planes;
0259 } drmModePlaneRes, *drmModePlaneResPtr;
0260
0261 extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr );
0262 extern void drmModeFreeResources( drmModeResPtr ptr );
0263 extern void drmModeFreeFB( drmModeFBPtr ptr );
0264 extern void drmModeFreeFB2( drmModeFB2Ptr ptr );
0265 extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
0266 extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
0267 extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
0268 extern void drmModeFreePlane( drmModePlanePtr ptr );
0269 extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr);
0270
0271
0272
0273
0274
0275
0276 extern int drmIsKMS(int fd);
0277
0278
0279
0280
0281 extern drmModeResPtr drmModeGetResources(int fd);
0282
0283
0284
0285
0286
0287
0288
0289
0290 extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId);
0291 extern drmModeFB2Ptr drmModeGetFB2(int fd, uint32_t bufferId);
0292
0293
0294
0295
0296 extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
0297 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
0298 uint32_t *buf_id);
0299
0300 extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
0301 uint32_t pixel_format, const uint32_t bo_handles[4],
0302 const uint32_t pitches[4], const uint32_t offsets[4],
0303 uint32_t *buf_id, uint32_t flags);
0304
0305
0306 int drmModeAddFB2WithModifiers(int fd, uint32_t width, uint32_t height,
0307 uint32_t pixel_format, const uint32_t bo_handles[4],
0308 const uint32_t pitches[4], const uint32_t offsets[4],
0309 const uint64_t modifier[4], uint32_t *buf_id,
0310 uint32_t flags);
0311
0312
0313
0314
0315 extern int drmModeRmFB(int fd, uint32_t bufferId);
0316
0317
0318
0319
0320
0321
0322 extern int drmModeCloseFB(int fd, uint32_t buffer_id);
0323
0324
0325
0326
0327 extern int drmModeDirtyFB(int fd, uint32_t bufferId,
0328 drmModeClipPtr clips, uint32_t num_clips);
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338 extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
0339
0340
0341
0342
0343 int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
0344 uint32_t x, uint32_t y, uint32_t *connectors, int count,
0345 drmModeModeInfoPtr mode);
0346
0347
0348
0349
0350
0351
0352
0353
0354 int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height);
0355
0356 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);
0357
0358
0359
0360 int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y);
0361
0362
0363
0364
0365 drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id);
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376 extern drmModeConnectorPtr drmModeGetConnector(int fd,
0377 uint32_t connectorId);
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387 extern drmModeConnectorPtr drmModeGetConnectorCurrent(int fd,
0388 uint32_t connector_id);
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400 extern uint32_t drmModeConnectorGetPossibleCrtcs(int fd,
0401 const drmModeConnector *connector);
0402
0403
0404
0405
0406 extern int drmModeAttachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info);
0407
0408
0409
0410
0411
0412 extern int drmModeDetachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info);
0413
0414 extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId);
0415 extern void drmModeFreeProperty(drmModePropertyPtr ptr);
0416
0417 extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id);
0418 extern bool drmModeFormatModifierBlobIterNext(const drmModePropertyBlobRes *blob,
0419 drmModeFormatModifierIterator *iter);
0420 extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr);
0421 extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id,
0422 uint64_t value);
0423 extern int drmCheckModesettingSupported(const char *busid);
0424
0425 extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
0426 const uint16_t *red, const uint16_t *green, const uint16_t *blue);
0427 extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
0428 uint16_t *red, uint16_t *green, uint16_t *blue);
0429 extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
0430 uint32_t flags, void *user_data);
0431 extern int drmModePageFlipTarget(int fd, uint32_t crtc_id, uint32_t fb_id,
0432 uint32_t flags, void *user_data,
0433 uint32_t target_vblank);
0434
0435 extern drmModePlaneResPtr drmModeGetPlaneResources(int fd);
0436 extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id);
0437 extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
0438 uint32_t fb_id, uint32_t flags,
0439 int32_t crtc_x, int32_t crtc_y,
0440 uint32_t crtc_w, uint32_t crtc_h,
0441 uint32_t src_x, uint32_t src_y,
0442 uint32_t src_w, uint32_t src_h);
0443
0444 extern drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd,
0445 uint32_t object_id,
0446 uint32_t object_type);
0447 extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr);
0448 extern int drmModeObjectSetProperty(int fd, uint32_t object_id,
0449 uint32_t object_type, uint32_t property_id,
0450 uint64_t value);
0451
0452
0453 typedef struct _drmModeAtomicReq drmModeAtomicReq, *drmModeAtomicReqPtr;
0454
0455 extern drmModeAtomicReqPtr drmModeAtomicAlloc(void);
0456 extern drmModeAtomicReqPtr drmModeAtomicDuplicate(const drmModeAtomicReqPtr req);
0457 extern int drmModeAtomicMerge(drmModeAtomicReqPtr base,
0458 const drmModeAtomicReqPtr augment);
0459 extern void drmModeAtomicFree(drmModeAtomicReqPtr req);
0460 extern int drmModeAtomicGetCursor(const drmModeAtomicReqPtr req);
0461 extern void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor);
0462 extern int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
0463 uint32_t object_id,
0464 uint32_t property_id,
0465 uint64_t value);
0466 extern int drmModeAtomicCommit(int fd,
0467 const drmModeAtomicReqPtr req,
0468 uint32_t flags,
0469 void *user_data);
0470
0471 extern int drmModeCreatePropertyBlob(int fd, const void *data, size_t size,
0472 uint32_t *id);
0473 extern int drmModeDestroyPropertyBlob(int fd, uint32_t id);
0474
0475
0476
0477
0478
0479
0480 extern int drmModeCreateLease(int fd, const uint32_t *objects, int num_objects, int flags, uint32_t *lessee_id);
0481
0482 typedef struct drmModeLesseeList {
0483 uint32_t count;
0484 uint32_t lessees[];
0485 } drmModeLesseeListRes, *drmModeLesseeListPtr;
0486
0487 extern drmModeLesseeListPtr drmModeListLessees(int fd);
0488
0489 typedef struct drmModeObjectList {
0490 uint32_t count;
0491 uint32_t objects[];
0492 } drmModeObjectListRes, *drmModeObjectListPtr;
0493
0494 extern drmModeObjectListPtr drmModeGetLease(int fd);
0495
0496 extern int drmModeRevokeLease(int fd, uint32_t lessee_id);
0497
0498
0499
0500
0501
0502
0503
0504 extern const char *
0505 drmModeGetConnectorTypeName(uint32_t connector_type);
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515 extern int
0516 drmModeCreateDumbBuffer(int fd, uint32_t width, uint32_t height, uint32_t bpp,
0517 uint32_t flags, uint32_t *handle, uint32_t *pitch,
0518 uint64_t *size);
0519
0520
0521
0522
0523
0524
0525 extern int
0526 drmModeDestroyDumbBuffer(int fd, uint32_t handle);
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536 extern int
0537 drmModeMapDumbBuffer(int fd, uint32_t handle, uint64_t *offset);
0538
0539 #if defined(__cplusplus)
0540 }
0541 #endif
0542
0543 #endif