[GLP] Libdce linux implementation
[glsdk/libdce2.git] / linux / wayland-drm-client-protocol.h
1 /*
2  * Copyright © 2008-2011 Kristian Høgsberg
3  * Copyright © 2010-2011 Intel Corporation
4  *
5  * Permission to use, copy, modify, distribute, and sell this
6  * software and its documentation for any purpose is hereby granted
7  * without fee, provided that\n the above copyright notice appear in
8  * all copies and that both that copyright notice and this permission
9  * notice appear in supporting documentation, and that the name of
10  * the copyright holders not be used in advertising or publicity
11  * pertaining to distribution of the software without specific,
12  * written prior permission.  The copyright holders make no
13  * representations about the suitability of this software for any
14  * purpose.  It is provided "as is" without express or implied
15  * warranty.
16  *
17  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
18  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
19  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
22  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
23  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
24  * THIS SOFTWARE.
25  */
27 #ifndef DRM_CLIENT_PROTOCOL_H
28 #define DRM_CLIENT_PROTOCOL_H
30 #ifdef  __cplusplus
31 extern "C" {
32 #endif
34 #include <stdint.h>
35 #include <stddef.h>
36 #include "wayland-util.h"
38 struct wl_client;
39 struct wl_resource;
40 struct wl_drm;
41 extern const struct wl_interface wl_drm_interface;
43 #ifndef WL_DRM_ERROR_ENUM
44 #define WL_DRM_ERROR_ENUM
45 enum wl_drm_error {
46     WL_DRM_ERROR_AUTHENTICATE_FAIL = 0,
47     WL_DRM_ERROR_INVALID_FORMAT = 1,
48     WL_DRM_ERROR_INVALID_NAME = 2,
49 };
50 #endif /* WL_DRM_ERROR_ENUM */
52 #ifndef WL_DRM_FORMAT_ENUM
53 #define WL_DRM_FORMAT_ENUM
54 enum wl_drm_format {
55     WL_DRM_FORMAT_C8 = 0x20203843,
56     WL_DRM_FORMAT_RGB332 = 0x38424752,
57     WL_DRM_FORMAT_BGR233 = 0x38524742,
58     WL_DRM_FORMAT_XRGB4444 = 0x32315258,
59     WL_DRM_FORMAT_XBGR4444 = 0x32314258,
60     WL_DRM_FORMAT_RGBX4444 = 0x32315852,
61     WL_DRM_FORMAT_BGRX4444 = 0x32315842,
62     WL_DRM_FORMAT_ARGB4444 = 0x32315241,
63     WL_DRM_FORMAT_ABGR4444 = 0x32314241,
64     WL_DRM_FORMAT_RGBA4444 = 0x32314152,
65     WL_DRM_FORMAT_BGRA4444 = 0x32314142,
66     WL_DRM_FORMAT_XRGB1555 = 0x35315258,
67     WL_DRM_FORMAT_XBGR1555 = 0x35314258,
68     WL_DRM_FORMAT_RGBX5551 = 0x35315852,
69     WL_DRM_FORMAT_BGRX5551 = 0x35315842,
70     WL_DRM_FORMAT_ARGB1555 = 0x35315241,
71     WL_DRM_FORMAT_ABGR1555 = 0x35314241,
72     WL_DRM_FORMAT_RGBA5551 = 0x35314152,
73     WL_DRM_FORMAT_BGRA5551 = 0x35314142,
74     WL_DRM_FORMAT_RGB565 = 0x36314752,
75     WL_DRM_FORMAT_BGR565 = 0x36314742,
76     WL_DRM_FORMAT_RGB888 = 0x34324752,
77     WL_DRM_FORMAT_BGR888 = 0x34324742,
78     WL_DRM_FORMAT_XRGB8888 = 0x34325258,
79     WL_DRM_FORMAT_XBGR8888 = 0x34324258,
80     WL_DRM_FORMAT_RGBX8888 = 0x34325852,
81     WL_DRM_FORMAT_BGRX8888 = 0x34325842,
82     WL_DRM_FORMAT_ARGB8888 = 0x34325241,
83     WL_DRM_FORMAT_ABGR8888 = 0x34324241,
84     WL_DRM_FORMAT_RGBA8888 = 0x34324152,
85     WL_DRM_FORMAT_BGRA8888 = 0x34324142,
86     WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
87     WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
88     WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
89     WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
90     WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
91     WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
92     WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
93     WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
94     WL_DRM_FORMAT_YUYV = 0x56595559,
95     WL_DRM_FORMAT_YVYU = 0x55595659,
96     WL_DRM_FORMAT_UYVY = 0x59565955,
97     WL_DRM_FORMAT_VYUY = 0x59555956,
98     WL_DRM_FORMAT_AYUV = 0x56555941,
99     WL_DRM_FORMAT_NV12 = 0x3231564e,
100     WL_DRM_FORMAT_NV21 = 0x3132564e,
101     WL_DRM_FORMAT_NV16 = 0x3631564e,
102     WL_DRM_FORMAT_NV61 = 0x3136564e,
103     WL_DRM_FORMAT_YUV410 = 0x39565559,
104     WL_DRM_FORMAT_YVU410 = 0x39555659,
105     WL_DRM_FORMAT_YUV411 = 0x31315559,
106     WL_DRM_FORMAT_YVU411 = 0x31315659,
107     WL_DRM_FORMAT_YUV420 = 0x32315559,
108     WL_DRM_FORMAT_YVU420 = 0x32315659,
109     WL_DRM_FORMAT_YUV422 = 0x36315559,
110     WL_DRM_FORMAT_YVU422 = 0x36315659,
111     WL_DRM_FORMAT_YUV444 = 0x34325559,
112     WL_DRM_FORMAT_YVU444 = 0x34325659,
113 };
114 #endif /* WL_DRM_FORMAT_ENUM */
116 struct wl_drm_listener {
117     /**
118      * device - (none)
119      * @name: (none)
120      */
121     void (*device)(void *data,
122         struct wl_drm *wl_drm,
123         const char *name);
124     /**
125      * format - (none)
126      * @format: (none)
127      */
128     void (*format)(void *data,
129         struct wl_drm *wl_drm,
130         uint32_t format);
131     /**
132      * authenticated - (none)
133      */
134      void (*authenticated)(void *data,
135          struct wl_drm *wl_drm);
136 };
138 static inline int
139 wl_drm_add_listener(struct wl_drm *wl_drm,
140     const struct wl_drm_listener *listener, void *data)
142     return wl_proxy_add_listener((struct wl_proxy *) wl_drm,
143         (void (**)(void)) listener, data);
146 #define WL_DRM_AUTHENTICATE     0
147 #define WL_DRM_CREATE_BUFFER    1
148 #define WL_DRM_CREATE_PLANAR_BUFFER     2
150 static inline void
151 wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data)
153     wl_proxy_set_user_data((struct wl_proxy *) wl_drm, user_data);
156 static inline void *
157 wl_drm_get_user_data(struct wl_drm *wl_drm)
159     return wl_proxy_get_user_data((struct wl_proxy *) wl_drm);
162 static inline void
163 wl_drm_destroy(struct wl_drm *wl_drm)
165     wl_proxy_destroy((struct wl_proxy *) wl_drm);
168 static inline void
169 wl_drm_authenticate(struct wl_drm *wl_drm, uint32_t id)
171     wl_proxy_marshal((struct wl_proxy *) wl_drm,
172         WL_DRM_AUTHENTICATE, id);
175 static inline struct wl_buffer *
176 wl_drm_create_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
178     struct wl_proxy *id;
179         id = wl_proxy_create((struct wl_proxy *) wl_drm,
180                  &wl_buffer_interface);
181     if (!id)
182         return NULL;
184     wl_proxy_marshal((struct wl_proxy *) wl_drm,
185         WL_DRM_CREATE_BUFFER, id, name, width, height, stride, format);
187     return (struct wl_buffer *) id;
190 static inline struct wl_buffer *
191 wl_drm_create_planar_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t format, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
193     struct wl_proxy *id;
194     id = wl_proxy_create((struct wl_proxy *) wl_drm,
195                              &wl_buffer_interface);
196     if (!id)
197         return NULL;
199     wl_proxy_marshal((struct wl_proxy *) wl_drm,
200         WL_DRM_CREATE_PLANAR_BUFFER, id, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2);
202     return (struct wl_buffer *) id;
205 #ifdef  __cplusplus
207 #endif
209 #endif