use FB everywhere
[profile/ivi/libdrm.git] / libdrm / xf86drmMode.h
1 /*
2  * \file xf86drmMode.h
3  * Header for DRM modesetting interface.
4  *
5  * \author Jakob Bornecrantz <wallbraker@gmail.com>
6  *
7  * \par Acknowledgements:
8  * Feb 2007, Dave Airlie <airlied@linux.ie>
9  */
10
11 /*
12  * Copyright (c) <year> <copyright holders>
13  *
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:
20  *
21  * The above copyright notice and this permission notice shall be included in
22  * all copies or substantial portions of the Software.
23  *
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
30  * IN THE SOFTWARE.
31  *
32  */
33
34 #include <drm.h>
35 #include "xf86mm.h"
36
37 /*
38  * This is the interface for modesetting for drm.
39  *
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.
42  *
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.
45  *
46  * More information can be found in randrproto.txt which can be found here:
47  * http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git
48  *
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.
52  *
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.
56  *
57  */
58
59 typedef struct _drmModeGammaTriple {
60         uint16_t r, g, b;
61 } drmModeGammaTriple, *drmModeGammaTriplePtr;
62
63 typedef struct _drmModeRes {
64
65         int count_fbs;
66         uint32_t *fbs;
67
68         int count_crtcs;
69         uint32_t *crtcs;
70
71         int count_outputs;
72         uint32_t *outputs;
73
74         int count_modes;
75         struct drm_mode_modeinfo *modes;
76
77 } drmModeRes, *drmModeResPtr;
78
79 typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr;
80
81 typedef struct _drmModeCrtc {
82
83         unsigned int buffer_id; /**< FB id to connect to 0 = disconnect*/
84
85         uint32_t x, y; /**< Position on the frameuffer */
86         uint32_t width, height;
87         uint32_t mode; /**< Current mode used */
88
89         int count_outputs;
90         uint32_t outputs; /**< Outputs that are connected */
91
92         int count_possibles;
93         uint32_t possibles; /**< Outputs that can be connected */
94
95         int gamma_size; /**< Number of gamma stops */
96
97 } drmModeCrtc, *drmModeCrtcPtr;
98
99 typedef enum {
100         DRM_MODE_CONNECTED         = 1,
101         DRM_MODE_DISCONNECTED      = 2,
102         DRM_MODE_UNKNOWNCONNECTION = 3
103 } drmModeConnection;
104
105 typedef enum {
106         DRM_MODE_SUBPIXEL_UNKNOWN        = 1,
107         DRM_MODE_SUBPIXEL_HORIZONTAL_RGB = 2,
108         DRM_MODE_SUBPIXEL_HORIZONTAL_BGR = 3,
109         DRM_MODE_SUBPIXEL_VERTICAL_RGB   = 4,
110         DRM_MODE_SUBPIXEL_VERTICAL_BGR   = 5,
111         DRM_MODE_SUBPIXEL_NONE           = 6
112 } drmModeSubPixel;
113
114 typedef struct _drmModeOutput {
115
116         unsigned int crtc; /**< Crtc currently connected to */
117         unsigned char name[DRM_OUTPUT_NAME_LEN];
118         drmModeConnection connection;
119         uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
120         drmModeSubPixel subpixel;
121
122         int count_crtcs;
123         uint32_t crtcs; /**< Possible crtc to connect to */
124
125         int count_clones;
126         uint32_t clones; /**< Mask of clones */
127
128         int count_modes;
129         uint32_t *modes; /**< List of modes ids */
130
131 } drmModeOutput, *drmModeOutputPtr;
132
133 /*
134  * RRSetScreenConfig o
135  * RRGetScreenInfo o
136  *
137  * RRGetScreenSizeRange - see frameBuffer info
138  * RRSetScreenSize
139  * RRGetScreenResources
140  *
141  * RRGetOutputInfo
142  *
143  * RRListOutputProperties *
144  * RRQueryOutputProperty *
145  * RRConfigureOutputProperty *
146  * RRChangeOutputProperty *
147  * RRDeleteOutputProperty *
148  * RRGetOutputProperty *
149  *
150  * RRCreateMode
151  * RRDestroyMode
152  * RRAddOutputMode
153  * RRDeleteOutputMode
154  *
155  * RRGetCrtcInfo
156  * RRSetCrtcConfig
157  *
158  * RRGetCrtcGammaSize - see crtc info
159  * RRGetCrtcGamma
160  * RRSetCrtcGamma
161  *
162  * drmModeGetResources
163  * drmModeForceProbe
164  *
165  * drmModeGetFrameBufferInfo
166  * drmModeSetFrameBufferSize
167  *
168  * drmModeGetCrtcInfo
169  * drmModeSetCrtcConfig
170  * drmModeGetCrtcGamma
171  * drmModeSetCrtcGamma
172  *
173  * drmModeGetOutputInfo
174  *
175  * drmModeAddMode
176  * drmModeDestroyMode
177  * drmModeAddOutputMode
178  * drmModeDeleteOutputMode
179  */
180
181 extern void drmModeFreeModeInfo( struct drm_mode_modeinfo *ptr );
182 extern void drmModeFreeResources( drmModeResPtr ptr );
183 extern void drmModeFreeFB( drmModeFBPtr ptr );
184 extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
185 extern void drmModeFreeOutput( drmModeOutputPtr ptr );
186
187 /**
188  * Retrives all of the resources associated with a card.
189  */
190 extern drmModeResPtr drmModeGetResources(int fd);
191
192 /**
193  * Forces a probe of the give output outputId, on 0 all will be probed.
194  */
195 extern int drmModeForceProbe(int fd, uint32_t outputId);
196
197
198 /*
199  * FrameBuffer manipulation.
200  */
201
202 /**
203  * Retrive information about framebuffer bufferId
204  */
205 extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId);
206
207 /**
208  * Creates a new framebuffer with an buffer object as its scanout buffer.
209  */
210 extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
211                         uint8_t bpp, uint32_t pitch, drmBO *bo,
212                         uint32_t *buf_id);
213 /**
214  * Destroies the given framebuffer.
215  */
216 extern int drmModeRmFB(int fd, uint32_t bufferId);
217
218 /**
219  * Changes the scanout buffer to the given buffer object.
220  */
221 extern int drmModeFlipFrameBuffer(int fd, uint32_t bufferId, drmBO *bo);
222
223 /*
224  * Crtc function.
225  */
226
227 /**
228  * Retrive information about the ctrt crtcId
229  */
230 extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
231
232 /**
233  * Set the mode on a crtc crtcId with the given mode modeId.
234  */
235 extern int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
236                 uint32_t x, uint32_t y, uint32_t modeId,
237                 uint32_t *outputs, int count);
238
239 /**
240  * Gets the gamma from a crtc
241  */
242 extern drmModeGammaTriplePtr drmModeGetCrtcGamma(int fd, uint32_t crtcId,
243                 int *count);
244
245 /**
246  * Sets the gamma on a crtc
247  */
248 extern int drmModeSetCrtcGamma(int fd, uint32_t crtcId,
249                 drmModeGammaTriplePtr ptr, int count);
250
251
252
253 /*
254  * Output manipulation
255  */
256
257 /**
258  * Retrive information about the output outputId.
259  */
260 extern drmModeOutputPtr drmModeGetOutput(int fd,
261                 uint32_t outputId);
262
263 /**
264  * Creates a new mode from the given mode info.
265  * Name must be unique.
266  */
267 extern uint32_t drmModeNewMode(int fd, struct drm_mode_modeinfo *modeInfo);
268
269 /**
270  * Destroys a mode created with CreateMode, must be unused.
271  */
272 extern int drmModeDesMode(int fd, uint32_t modeId);
273
274 /**
275  * Adds the given mode to an output.
276  */
277 extern int drmModeAddMode(int fd, uint32_t outputId, uint32_t modeId);
278
279 /**
280  * Deletes a mode Added with AddOutputMode from the output,
281  * must be unused, by the given mode.
282  */
283 extern int drmModeDelMode(int fd, uint32_t outputId, uint32_t modeId);
284