Back to index

libdrm  2.4.37
xf86drmMode.h
Go to the documentation of this file.
00001 /*
00002  * \file xf86drmMode.h
00003  * Header for DRM modesetting interface.
00004  *
00005  * \author Jakob Bornecrantz <wallbraker@gmail.com>
00006  *
00007  * \par Acknowledgements:
00008  * Feb 2007, Dave Airlie <airlied@linux.ie>
00009  */
00010 
00011 /*
00012  * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
00013  * Copyright (c) 2007-2008 Dave Airlie <airlied@linux.ie>
00014  * Copyright (c) 2007-2008 Jakob Bornecrantz <wallbraker@gmail.com>
00015  *
00016  * Permission is hereby granted, free of charge, to any person obtaining a
00017  * copy of this software and associated documentation files (the "Software"),
00018  * to deal in the Software without restriction, including without limitation
00019  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00020  * and/or sell copies of the Software, and to permit persons to whom the
00021  * Software is furnished to do so, subject to the following conditions:
00022  *
00023  * The above copyright notice and this permission notice shall be included in
00024  * all copies or substantial portions of the Software.
00025  *
00026  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00027  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00028  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00029  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00030  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00031  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00032  * IN THE SOFTWARE.
00033  *
00034  */
00035 
00036 #ifndef _XF86DRMMODE_H_
00037 #define _XF86DRMMODE_H_
00038 
00039 #if defined(__cplusplus) || defined(c_plusplus)
00040 extern "C" {
00041 #endif
00042 
00043 #include <drm.h>
00044 
00045 /*
00046  * This is the interface for modesetting for drm.
00047  *
00048  * In order to use this interface you must include either <stdint.h> or another
00049  * header defining uint32_t, int32_t and uint16_t.
00050  *
00051  * It aims to provide a randr1.2 compatible interface for modesettings in the
00052  * kernel, the interface is also ment to be used by libraries like EGL.
00053  *
00054  * More information can be found in randrproto.txt which can be found here:
00055  * http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git
00056  *
00057  * There are some major diffrences to be noted. Unlike the randr1.2 proto you
00058  * need to create the memory object of the framebuffer yourself with the ttm
00059  * buffer object interface. This object needs to be pinned.
00060  */
00061 
00062 /*
00063  * If we pickup an old version of drm.h which doesn't include drm_mode.h
00064  * we should redefine defines. This is so that builds doesn't breaks with
00065  * new libdrm on old kernels.
00066  */
00067 #ifndef _DRM_MODE_H
00068 
00069 #define DRM_DISPLAY_INFO_LEN    32
00070 #define DRM_CONNECTOR_NAME_LEN  32
00071 #define DRM_DISPLAY_MODE_LEN    32
00072 #define DRM_PROP_NAME_LEN       32
00073 
00074 #define DRM_MODE_TYPE_BUILTIN   (1<<0)
00075 #define DRM_MODE_TYPE_CLOCK_C   ((1<<1) | DRM_MODE_TYPE_BUILTIN)
00076 #define DRM_MODE_TYPE_CRTC_C    ((1<<2) | DRM_MODE_TYPE_BUILTIN)
00077 #define DRM_MODE_TYPE_PREFERRED (1<<3)
00078 #define DRM_MODE_TYPE_DEFAULT   (1<<4)
00079 #define DRM_MODE_TYPE_USERDEF   (1<<5)
00080 #define DRM_MODE_TYPE_DRIVER    (1<<6)
00081 
00082 /* Video mode flags */
00083 /* bit compatible with the xorg definitions. */
00084 #define DRM_MODE_FLAG_PHSYNC    (1<<0)
00085 #define DRM_MODE_FLAG_NHSYNC    (1<<1)
00086 #define DRM_MODE_FLAG_PVSYNC    (1<<2)
00087 #define DRM_MODE_FLAG_NVSYNC    (1<<3)
00088 #define DRM_MODE_FLAG_INTERLACE (1<<4)
00089 #define DRM_MODE_FLAG_DBLSCAN   (1<<5)
00090 #define DRM_MODE_FLAG_CSYNC     (1<<6)
00091 #define DRM_MODE_FLAG_PCSYNC    (1<<7)
00092 #define DRM_MODE_FLAG_NCSYNC    (1<<8)
00093 #define DRM_MODE_FLAG_HSKEW     (1<<9) /* hskew provided */
00094 #define DRM_MODE_FLAG_BCAST     (1<<10)
00095 #define DRM_MODE_FLAG_PIXMUX    (1<<11)
00096 #define DRM_MODE_FLAG_DBLCLK    (1<<12)
00097 #define DRM_MODE_FLAG_CLKDIV2   (1<<13)
00098 
00099 /* DPMS flags */
00100 /* bit compatible with the xorg definitions. */
00101 #define DRM_MODE_DPMS_ON        0
00102 #define DRM_MODE_DPMS_STANDBY   1
00103 #define DRM_MODE_DPMS_SUSPEND   2
00104 #define DRM_MODE_DPMS_OFF       3
00105 
00106 /* Scaling mode options */
00107 #define DRM_MODE_SCALE_NON_GPU          0
00108 #define DRM_MODE_SCALE_FULLSCREEN       1
00109 #define DRM_MODE_SCALE_NO_SCALE         2
00110 #define DRM_MODE_SCALE_ASPECT           3
00111 
00112 /* Dithering mode options */
00113 #define DRM_MODE_DITHERING_OFF  0
00114 #define DRM_MODE_DITHERING_ON   1
00115 
00116 #define DRM_MODE_ENCODER_NONE   0
00117 #define DRM_MODE_ENCODER_DAC    1
00118 #define DRM_MODE_ENCODER_TMDS   2
00119 #define DRM_MODE_ENCODER_LVDS   3
00120 #define DRM_MODE_ENCODER_TVDAC  4
00121 
00122 #define DRM_MODE_SUBCONNECTOR_Automatic 0
00123 #define DRM_MODE_SUBCONNECTOR_Unknown   0
00124 #define DRM_MODE_SUBCONNECTOR_DVID      3
00125 #define DRM_MODE_SUBCONNECTOR_DVIA      4
00126 #define DRM_MODE_SUBCONNECTOR_Composite 5
00127 #define DRM_MODE_SUBCONNECTOR_SVIDEO    6
00128 #define DRM_MODE_SUBCONNECTOR_Component 8
00129 
00130 #define DRM_MODE_CONNECTOR_Unknown      0
00131 #define DRM_MODE_CONNECTOR_VGA          1
00132 #define DRM_MODE_CONNECTOR_DVII         2
00133 #define DRM_MODE_CONNECTOR_DVID         3
00134 #define DRM_MODE_CONNECTOR_DVIA         4
00135 #define DRM_MODE_CONNECTOR_Composite    5
00136 #define DRM_MODE_CONNECTOR_SVIDEO       6
00137 #define DRM_MODE_CONNECTOR_LVDS         7
00138 #define DRM_MODE_CONNECTOR_Component    8
00139 #define DRM_MODE_CONNECTOR_9PinDIN      9
00140 #define DRM_MODE_CONNECTOR_DisplayPort  10
00141 #define DRM_MODE_CONNECTOR_HDMIA        11
00142 #define DRM_MODE_CONNECTOR_HDMIB        12
00143 #define DRM_MODE_CONNECTOR_TV             13
00144 #define DRM_MODE_CONNECTOR_eDP            14
00145 
00146 #define DRM_MODE_PROP_PENDING   (1<<0)
00147 #define DRM_MODE_PROP_RANGE     (1<<1)
00148 #define DRM_MODE_PROP_IMMUTABLE (1<<2)
00149 #define DRM_MODE_PROP_ENUM      (1<<3) /* enumerated type with text strings */
00150 #define DRM_MODE_PROP_BLOB      (1<<4)
00151 
00152 #define DRM_MODE_CURSOR_BO      (1<<0)
00153 #define DRM_MODE_CURSOR_MOVE    (1<<1)
00154 
00155 #endif /* _DRM_MODE_H */
00156 
00157 
00158 /*
00159  * Feature defines
00160  *
00161  * Just because these are defined doesn't mean that the kernel
00162  * can do that feature, its just for new code vs old libdrm.
00163  */
00164 #define DRM_MODE_FEATURE_KMS              1
00165 #define DRM_MODE_FEATURE_DIRTYFB   1
00166 
00167 
00168 typedef struct _drmModeRes {
00169 
00170        int count_fbs;
00171        uint32_t *fbs;
00172 
00173        int count_crtcs;
00174        uint32_t *crtcs;
00175 
00176        int count_connectors;
00177        uint32_t *connectors;
00178 
00179        int count_encoders;
00180        uint32_t *encoders;
00181 
00182        uint32_t min_width, max_width;
00183        uint32_t min_height, max_height;
00184 } drmModeRes, *drmModeResPtr;
00185 
00186 typedef struct _drmModeModeInfo {
00187        uint32_t clock;
00188        uint16_t hdisplay, hsync_start, hsync_end, htotal, hskew;
00189        uint16_t vdisplay, vsync_start, vsync_end, vtotal, vscan;
00190 
00191        uint32_t vrefresh;
00192 
00193        uint32_t flags;
00194        uint32_t type;
00195        char name[DRM_DISPLAY_MODE_LEN];
00196 } drmModeModeInfo, *drmModeModeInfoPtr;
00197 
00198 typedef struct _drmModeFB {
00199        uint32_t fb_id;
00200        uint32_t width, height;
00201        uint32_t pitch;
00202        uint32_t bpp;
00203        uint32_t depth;
00204        /* driver specific handle */
00205        uint32_t handle;
00206 } drmModeFB, *drmModeFBPtr;
00207 
00208 typedef struct drm_clip_rect drmModeClip, *drmModeClipPtr;
00209 
00210 typedef struct _drmModePropertyBlob {
00211        uint32_t id;
00212        uint32_t length;
00213        void *data;
00214 } drmModePropertyBlobRes, *drmModePropertyBlobPtr;
00215 
00216 typedef struct _drmModeProperty {
00217        uint32_t prop_id;
00218        uint32_t flags;
00219        char name[DRM_PROP_NAME_LEN];
00220        int count_values;
00221        uint64_t *values; // store the blob lengths
00222        int count_enums;
00223        struct drm_mode_property_enum *enums;
00224        int count_blobs;
00225        uint32_t *blob_ids; // store the blob IDs
00226 } drmModePropertyRes, *drmModePropertyPtr;
00227 
00228 typedef struct _drmModeCrtc {
00229        uint32_t crtc_id;
00230        uint32_t buffer_id; 
00232        uint32_t x, y; 
00233        uint32_t width, height;
00234        int mode_valid;
00235        drmModeModeInfo mode;
00236 
00237        int gamma_size; 
00239 } drmModeCrtc, *drmModeCrtcPtr;
00240 
00241 typedef struct _drmModeEncoder {
00242        uint32_t encoder_id;
00243        uint32_t encoder_type;
00244        uint32_t crtc_id;
00245        uint32_t possible_crtcs;
00246        uint32_t possible_clones;
00247 } drmModeEncoder, *drmModeEncoderPtr;
00248 
00249 typedef enum {
00250        DRM_MODE_CONNECTED         = 1,
00251        DRM_MODE_DISCONNECTED      = 2,
00252        DRM_MODE_UNKNOWNCONNECTION = 3
00253 } drmModeConnection;
00254 
00255 typedef enum {
00256        DRM_MODE_SUBPIXEL_UNKNOWN        = 1,
00257        DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2,
00258        DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3,
00259        DRM_MODE_SUBPIXEL_VERTICAL_RGB   = 4,
00260        DRM_MODE_SUBPIXEL_VERTICAL_BGR   = 5,
00261        DRM_MODE_SUBPIXEL_NONE           = 6
00262 } drmModeSubPixel;
00263 
00264 typedef struct _drmModeConnector {
00265        uint32_t connector_id;
00266        uint32_t encoder_id; 
00267        uint32_t connector_type;
00268        uint32_t connector_type_id;
00269        drmModeConnection connection;
00270        uint32_t mmWidth, mmHeight; 
00271        drmModeSubPixel subpixel;
00272 
00273        int count_modes;
00274        drmModeModeInfoPtr modes;
00275 
00276        int count_props;
00277        uint32_t *props; 
00278        uint64_t *prop_values; 
00280        int count_encoders;
00281        uint32_t *encoders; 
00282 } drmModeConnector, *drmModeConnectorPtr;
00283 
00284 typedef struct _drmModeObjectProperties {
00285        uint32_t count_props;
00286        uint32_t *props;
00287        uint64_t *prop_values;
00288 } drmModeObjectProperties, *drmModeObjectPropertiesPtr;
00289 
00290 typedef struct _drmModePlane {
00291        uint32_t count_formats;
00292        uint32_t *formats;
00293        uint32_t plane_id;
00294 
00295        uint32_t crtc_id;
00296        uint32_t fb_id;
00297 
00298        uint32_t crtc_x, crtc_y;
00299        uint32_t x, y;
00300 
00301        uint32_t possible_crtcs;
00302        uint32_t gamma_size;
00303 } drmModePlane, *drmModePlanePtr;
00304 
00305 typedef struct _drmModePlaneRes {
00306        uint32_t count_planes;
00307        uint32_t *planes;
00308 } drmModePlaneRes, *drmModePlaneResPtr;
00309 
00310 extern void drmModeFreeModeInfo( drmModeModeInfoPtr ptr );
00311 extern void drmModeFreeResources( drmModeResPtr ptr );
00312 extern void drmModeFreeFB( drmModeFBPtr ptr );
00313 extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
00314 extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
00315 extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
00316 extern void drmModeFreePlane( drmModePlanePtr ptr );
00317 extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr);
00318 
00322 extern drmModeResPtr drmModeGetResources(int fd);
00323 
00324 /*
00325  * FrameBuffer manipulation.
00326  */
00327 
00331 extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId);
00332 
00336 extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
00337                      uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
00338                      uint32_t *buf_id);
00339 /* ...with a specific pixel format */
00340 extern int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
00341                       uint32_t pixel_format, uint32_t bo_handles[4],
00342                       uint32_t pitches[4], uint32_t offsets[4],
00343                       uint32_t *buf_id, uint32_t flags);
00347 extern int drmModeRmFB(int fd, uint32_t bufferId);
00348 
00352 extern int drmModeDirtyFB(int fd, uint32_t bufferId,
00353                        drmModeClipPtr clips, uint32_t num_clips);
00354 
00355 
00356 /*
00357  * Crtc functions
00358  */
00359 
00363 extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
00364 
00368 int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
00369                    uint32_t x, uint32_t y, uint32_t *connectors, int count,
00370                  drmModeModeInfoPtr mode);
00371 
00372 /*
00373  * Cursor functions
00374  */
00375 
00379 int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height);
00380 
00384 int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y);
00385 
00389 drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id);
00390 
00391 /*
00392  * Connector manipulation
00393  */
00394 
00398 extern drmModeConnectorPtr drmModeGetConnector(int fd,
00399               uint32_t connectorId);
00400 
00404 extern int drmModeAttachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info);
00405 
00410 extern int drmModeDetachMode(int fd, uint32_t connectorId, drmModeModeInfoPtr mode_info);
00411 
00412 extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId);
00413 extern void drmModeFreeProperty(drmModePropertyPtr ptr);
00414 
00415 extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id);
00416 extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr);
00417 extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id,
00418                                 uint64_t value);
00419 extern int drmCheckModesettingSupported(const char *busid);
00420 
00421 extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
00422                             uint16_t *red, uint16_t *green, uint16_t *blue);
00423 extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
00424                             uint16_t *red, uint16_t *green, uint16_t *blue);
00425 extern int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
00426                         uint32_t flags, void *user_data);
00427 
00428 extern drmModePlaneResPtr drmModeGetPlaneResources(int fd);
00429 extern drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id);
00430 extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
00431                         uint32_t fb_id, uint32_t flags,
00432                         uint32_t crtc_x, uint32_t crtc_y,
00433                         uint32_t crtc_w, uint32_t crtc_h,
00434                         uint32_t src_x, uint32_t src_y,
00435                         uint32_t src_w, uint32_t src_h);
00436 
00437 extern drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd,
00438                                                  uint32_t object_id,
00439                                                  uint32_t object_type);
00440 extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr);
00441 extern int drmModeObjectSetProperty(int fd, uint32_t object_id,
00442                                 uint32_t object_type, uint32_t property_id,
00443                                 uint64_t value);
00444 
00445 #if defined(__cplusplus) || defined(c_plusplus)
00446 }
00447 #endif
00448 
00449 #endif