3 * Header for DRM modesetting interface.
5 * \author Jakob Bornecrantz <wallbraker@gmail.com>
7 * \par Acknowledgements:
8 * Feb 2007, Dave Airlie <airlied@linux.ie>
12 * Copyright (c) <year> <copyright holders>
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
38 * This is the interface for modesetting for drm.
40 * In order to use this interface you must include either <stdint.h> or another
41 * header defining uint32_t, int32_t and uint16_t.
43 * It aims to provide a randr1.2 compatible interface for modesettings in the
44 * kernel, the interface is also ment to be used by libraries like EGL.
46 * More information can be found in randrproto.txt which can be found here:
47 * http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git
49 * There are some major diffrences to be noted. Unlike the randr1.2 proto you
50 * need to create the memory object of the framebuffer yourself with the ttm
51 * buffer object interface. This object needs to be pinned.
55 typedef struct _drmModeRes {
69 uint32_t min_width, max_width;
70 uint32_t min_height, max_height;
71 } drmModeRes, *drmModeResPtr;
73 typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr;
75 typedef struct _drmModePropertyBlob {
79 } drmModePropertyBlobRes, *drmModePropertyBlobPtr;
81 typedef struct _drmModeProperty {
84 char name[DRM_PROP_NAME_LEN];
86 uint64_t *values; // store the blob lengths
88 struct drm_mode_property_enum *enums;
90 uint32_t *blob_ids; // store the blob IDs
91 } drmModePropertyRes, *drmModePropertyPtr;
93 typedef struct _drmModeCrtc {
95 unsigned int buffer_id; /**< FB id to connect to 0 = disconnect*/
97 uint32_t x, y; /**< Position on the frameuffer */
98 uint32_t width, height;
100 struct drm_mode_modeinfo mode;
102 int count_connectors;
103 uint32_t connectors; /**< Connectors that are connected */
106 uint32_t possibles; /**< Connectors that can be connected */
108 int gamma_size; /**< Number of gamma stops */
110 } drmModeCrtc, *drmModeCrtcPtr;
112 typedef struct _drmModeEncoder {
113 unsigned int encoder_id;
114 unsigned int encoder_type;
118 } drmModeEncoder, *drmModeEncoderPtr;
121 DRM_MODE_CONNECTED = 1,
122 DRM_MODE_DISCONNECTED = 2,
123 DRM_MODE_UNKNOWNCONNECTION = 3
127 DRM_MODE_SUBPIXEL_UNKNOWN = 1,
128 DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2,
129 DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3,
130 DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4,
131 DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5,
132 DRM_MODE_SUBPIXEL_NONE = 6
135 typedef struct _drmModeConnector {
136 unsigned int connector_id;
138 unsigned int encoder; /**< Crtc currently connected to */
139 unsigned int connector_type;
140 unsigned int connector_type_id;
141 drmModeConnection connection;
142 uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
143 drmModeSubPixel subpixel;
146 struct drm_mode_modeinfo *modes;
149 uint32_t *props; /**< List of property ids */
150 uint64_t *prop_values; /**< List of property values */
153 uint32_t *encoders; /**< List of encoder ids */
154 } drmModeConnector, *drmModeConnectorPtr;
158 extern void drmModeFreeModeInfo( struct drm_mode_modeinfo *ptr );
159 extern void drmModeFreeResources( drmModeResPtr ptr );
160 extern void drmModeFreeFB( drmModeFBPtr ptr );
161 extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
162 extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
163 extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
166 * Retrives all of the resources associated with a card.
168 extern drmModeResPtr drmModeGetResources(int fd);
171 * Retrives the hotplug counter
173 extern uint32_t drmModeGetHotplug(int fd);
176 * FrameBuffer manipulation.
180 * Retrive information about framebuffer bufferId
182 extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId);
185 * Creates a new framebuffer with an buffer object as its scanout buffer.
187 extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
188 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
191 * Destroies the given framebuffer.
193 extern int drmModeRmFB(int fd, uint32_t bufferId);
196 * Replace a framebuffer object with a new one - for resizing the screen.
198 extern int drmModeReplaceFB(int fd, uint32_t buffer_id,
199 uint32_t width, uint32_t height, uint8_t depth,
200 uint8_t bpp, uint32_t pitch, uint32_t bo_handle);
207 * Retrive information about the ctrt crtcId
209 extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
212 * Set the mode on a crtc crtcId with the given mode modeId.
214 int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
215 uint32_t x, uint32_t y, uint32_t *connectors, int count,
216 struct drm_mode_modeinfo *mode);
223 * Set the cursor on crtc
225 int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height);
228 * Move the cursor on crtc
230 int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y);
235 drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id);
238 * Connector manipulation
242 * Retrive information about the connector connectorId.
244 extern drmModeConnectorPtr drmModeGetConnector(int fd,
245 uint32_t connectorId);
248 * Attaches the given mode to an connector.
250 extern int drmModeAttachMode(int fd, uint32_t connectorId, struct drm_mode_modeinfo *mode_info);
253 * Detaches a mode from the connector
254 * must be unused, by the given mode.
256 extern int drmModeDetachMode(int fd, uint32_t connectorId, struct drm_mode_modeinfo *mode_info);
258 extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId);
259 extern void drmModeFreeProperty(drmModePropertyPtr ptr);
261 extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id);
262 extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr);
263 extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id,
265 extern int drmCheckModesettingSupported(const char *busid);