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 randr 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 * All framebuffer, crtc and output ids start at 1 while 0 is either an invalid
50 * parameter or used to indicate that the command should disconnect from the
51 * currently bound target, as with drmModeMapOutput.
53 * Currently only one framebuffer exist and has a id of 1, which is also the
54 * default framebuffer and should allways be avaible to the client, unless
55 * it is locked/used or any other limiting state is applied on it.
59 typedef struct _drmModeGammaTriple {
61 } drmModeGammaTriple, *drmModeGammaTriplePtr;
63 typedef struct _drmModeRes {
75 struct drm_mode_modeinfo *modes;
77 } drmModeRes, *drmModeResPtr;
79 typedef struct _drmModeFrameBuffer {
86 } drmModeFrameBuffer, *drmModeFrameBufferPtr;
88 typedef struct _drmModeCrtc {
90 unsigned int bufferId; /**< Buffer currently connected to */
92 uint32_t x, y; /**< Position on the frameuffer */
93 uint32_t width, height;
94 uint32_t mode; /**< Current mode used */
97 uint32_t outputs; /**< Outputs that are connected */
100 uint32_t possibles; /**< Outputs that can be connected */
102 int gamma_size; /**< Number of gamma stops */
104 } drmModeCrtc, *drmModeCrtcPtr;
107 DRM_MODE_CONNECTED = 1,
108 DRM_MODE_DISCONNECTED = 2,
109 DRM_MODE_UNKNOWNCONNECTION = 3
113 DRM_MODE_SUBPIXEL_UNKNOWN = 1,
114 DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2,
115 DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3,
116 DRM_MODE_SUBPIXEL_VERTICAL_RGB = 4,
117 DRM_MODE_SUBPIXEL_VERTICAL_BGR = 5,
118 DRM_MODE_SUBPIXEL_NONE = 6
121 typedef struct _drmModeOutput {
123 unsigned int crtc; /**< Crtc currently connected to */
124 unsigned char name[DRM_OUTPUT_NAME_LEN];
125 drmModeConnection connection;
126 uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
127 drmModeSubPixel subpixel;
130 uint32_t crtcs; /**< Possible crtc to connect to */
133 uint32_t clones; /**< Mask of clones */
136 uint32_t *modes; /**< List of modes ids */
138 } drmModeOutput, *drmModeOutputPtr;
141 * RRSetScreenConfig o
144 * RRGetScreenSizeRange - see frameBuffer info
146 * RRGetScreenResources
150 * RRListOutputProperties *
151 * RRQueryOutputProperty *
152 * RRConfigureOutputProperty *
153 * RRChangeOutputProperty *
154 * RRDeleteOutputProperty *
155 * RRGetOutputProperty *
165 * RRGetCrtcGammaSize - see crtc info
169 * drmModeGetResources
172 * drmModeGetFrameBufferInfo
173 * drmModeSetFrameBufferSize
176 * drmModeSetCrtcConfig
177 * drmModeGetCrtcGamma
178 * drmModeSetCrtcGamma
180 * drmModeGetOutputInfo
184 * drmModeAddOutputMode
185 * drmModeDeleteOutputMode
188 extern void drmModeFreeModeInfo( struct drm_mode_modeinfo *ptr );
189 extern void drmModeFreeResources( drmModeResPtr ptr );
190 extern void drmModeFreeFrameBuffer( drmModeFrameBufferPtr ptr );
191 extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
192 extern void drmModeFreeOutput( drmModeOutputPtr ptr );
195 * Retrives all of the resources associated with a card.
197 extern drmModeResPtr drmModeGetResources(int fd);
200 * Forces a probe of the give output outputId, on 0 all will be probed.
202 extern int drmModeForceProbe(int fd, uint32_t outputId);
206 * FrameBuffer manipulation.
210 * Retrive information about framebuffer bufferId
212 extern drmModeFrameBufferPtr drmModeGetFB(int fd,
216 * Creates a new framebuffer with an buffer object as its scanout buffer.
218 extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
219 uint8_t bpp, uint32_t pitch, drmBO *bo, uint32_t *buf_id);
221 * Destroies the given framebuffer.
223 extern int drmModeRmFB(int fd, uint32_t bufferId);
226 * Changes the scanout buffer to the given buffer object.
228 extern int drmModeFlipFrameBuffer(int fd, uint32_t bufferId, drmBO *bo);
235 * Retrive information about the ctrt crtcId
237 extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
240 * Set the mode on a crtc crtcId with the given mode modeId.
242 extern int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
243 uint32_t x, uint32_t y, uint32_t modeId,
244 uint32_t *outputs, int count);
247 * Gets the gamma from a crtc
249 extern drmModeGammaTriplePtr drmModeGetCrtcGamma(int fd, uint32_t crtcId,
253 * Sets the gamma on a crtc
255 extern int drmModeSetCrtcGamma(int fd, uint32_t crtcId,
256 drmModeGammaTriplePtr ptr, int count);
261 * Output manipulation
265 * Retrive information about the output outputId.
267 extern drmModeOutputPtr drmModeGetOutput(int fd,
271 * Creates a new mode from the given mode info.
272 * Name must be unique.
274 extern uint32_t drmModeNewMode(int fd, struct drm_mode_modeinfo *modeInfo);
277 * Destroys a mode created with CreateMode, must be unused.
279 extern int drmModeDesMode(int fd, uint32_t modeId);
282 * Adds the given mode to an output.
284 extern int drmModeAddMode(int fd, uint32_t outputId, uint32_t modeId);
287 * Deletes a mode Added with AddOutputMode from the output,
288 * must be unused, by the given mode.
290 extern int drmModeDelMode(int fd, uint32_t outputId, uint32_t modeId);