2 * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, Texas.
3 * Copyright (c) 2007-2008 Dave Airlie <airlied@linux.ie>
4 * Copyright (c) 2007-2008 Jakob Bornecrantz <wallbraker@gmail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 typedef struct _drmModeRes
{
42 uint32_t min_width
, max_width
;
43 uint32_t min_height
, max_height
;
44 } drmModeRes
, *drmModeResPtr
;
46 typedef struct _drmModeModeInfo
{
48 uint16_t hdisplay
, hsync_start
, hsync_end
, htotal
, hskew
;
49 uint16_t vdisplay
, vsync_start
, vsync_end
, vtotal
, vscan
;
51 uint32_t vrefresh
; /* vertical refresh * 1000 */
55 char name
[DRM_DISPLAY_MODE_LEN
];
56 } drmModeModeInfo
, *drmModeModeInfoPtr
;
58 typedef struct _drmModeEncoder
{
60 uint32_t encoder_type
;
62 uint32_t possible_crtcs
;
63 uint32_t possible_clones
;
64 } drmModeEncoder
, *drmModeEncoderPtr
;
67 DRM_MODE_CONNECTED
= 1,
68 DRM_MODE_DISCONNECTED
= 2,
69 DRM_MODE_UNKNOWNCONNECTION
= 3
73 DRM_MODE_SUBPIXEL_UNKNOWN
= 1,
74 DRM_MODE_SUBPIXEL_HORIZONTAL_RGB
= 2,
75 DRM_MODE_SUBPIXEL_HORIZONTAL_BGR
= 3,
76 DRM_MODE_SUBPIXEL_VERTICAL_RGB
= 4,
77 DRM_MODE_SUBPIXEL_VERTICAL_BGR
= 5,
78 DRM_MODE_SUBPIXEL_NONE
= 6
81 typedef struct _drmModeConnector
{
82 uint32_t connector_id
;
83 uint32_t encoder_id
; /**< Encoder currently connected to */
84 uint32_t connector_type
;
85 uint32_t connector_type_id
;
86 drmModeConnection connection
;
87 uint32_t mmWidth
, mmHeight
; /**< HxW in millimeters */
88 drmModeSubPixel subpixel
;
91 drmModeModeInfoPtr modes
;
94 uint32_t *props
; /**< List of property ids */
95 uint64_t *prop_values
; /**< List of property values */
98 uint32_t *encoders
; /**< List of encoder ids */
99 } drmModeConnector
, *drmModeConnectorPtr
;
101 typedef struct _drmModeCrtc
{
103 uint32_t buffer_id
; /**< FB id to connect to 0 = disconnect */
105 uint32_t x
, y
; /**< Position on the framebuffer */
106 uint32_t width
, height
;
108 drmModeModeInfo mode
;
110 int gamma_size
; /**< Number of gamma stops */
112 } drmModeCrtc
, *drmModeCrtcPtr
;
114 /* Add passed bo (handle) to list of frame buffers */
115 extern int drmModeAddFB(int fd
, uint32_t width
, uint32_t height
, uint8_t depth
,
116 uint8_t bpp
, uint32_t pitch
, uint32_t bo_handle
,
118 extern int drmModeRmFB(int fd
, uint32_t bufferId
);
120 /* Gets information about all resources of card:
125 extern drmModeResPtr
drmModeGetResources(int fd
);
126 extern void drmModeFreeResources(drmModeResPtr ptr
);
128 /* Connector support */
129 extern drmModeConnectorPtr
drmModeGetConnector(int fd
, uint32_t connectorId
);
130 extern void drmModeFreeConnector(drmModeConnectorPtr ptr
);
132 /* CRTC support */ /* bufferId == id of nouveau_bo registered using drmModeAddFB */
133 extern int drmModeSetCrtc(int fd
, uint32_t crtcId
, uint32_t bufferId
,
134 uint32_t x
, uint32_t y
, uint32_t *connectors
, int count
,
135 drmModeModeInfoPtr mode
);
136 extern drmModeCrtcPtr
drmModeGetCrtc(int fd
, uint32_t crtcId
);
137 extern void drmModeFreeCrtc( drmModeCrtcPtr ptr
);
139 /* Encoder support */
140 extern drmModeEncoderPtr
drmModeGetEncoder(int fd
, uint32_t encoder_id
);
141 extern void drmModeFreeEncoder(drmModeEncoderPtr ptr
);
144 extern int drmModeSetCursor(int fd
, uint32_t crtcId
, uint32_t bo_handle
,
145 uint32_t width
, uint32_t height
);
146 extern int drmModeMoveCursor(int fd
, uint32_t crtcId
, int x
, int y
);