Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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.  */
  26.  
  27. #ifndef DRM_CLIENT_PROTOCOL_H
  28. #define DRM_CLIENT_PROTOCOL_H
  29.  
  30. #ifdef  __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #include <stdint.h>
  35. #include <stddef.h>
  36. #include "wayland-client.h"
  37.  
  38. struct wl_client;
  39. struct wl_resource;
  40.  
  41. struct wl_drm;
  42.  
  43. extern const struct wl_interface wl_drm_interface;
  44.  
  45. #ifndef WL_DRM_ERROR_ENUM
  46. #define WL_DRM_ERROR_ENUM
  47. enum wl_drm_error {
  48.         WL_DRM_ERROR_AUTHENTICATE_FAIL = 0,
  49.         WL_DRM_ERROR_INVALID_FORMAT = 1,
  50.         WL_DRM_ERROR_INVALID_NAME = 2,
  51. };
  52. #endif /* WL_DRM_ERROR_ENUM */
  53.  
  54. #ifndef WL_DRM_FORMAT_ENUM
  55. #define WL_DRM_FORMAT_ENUM
  56. enum wl_drm_format {
  57.         WL_DRM_FORMAT_C8 = 0x20203843,
  58.         WL_DRM_FORMAT_RGB332 = 0x38424752,
  59.         WL_DRM_FORMAT_BGR233 = 0x38524742,
  60.         WL_DRM_FORMAT_XRGB4444 = 0x32315258,
  61.         WL_DRM_FORMAT_XBGR4444 = 0x32314258,
  62.         WL_DRM_FORMAT_RGBX4444 = 0x32315852,
  63.         WL_DRM_FORMAT_BGRX4444 = 0x32315842,
  64.         WL_DRM_FORMAT_ARGB4444 = 0x32315241,
  65.         WL_DRM_FORMAT_ABGR4444 = 0x32314241,
  66.         WL_DRM_FORMAT_RGBA4444 = 0x32314152,
  67.         WL_DRM_FORMAT_BGRA4444 = 0x32314142,
  68.         WL_DRM_FORMAT_XRGB1555 = 0x35315258,
  69.         WL_DRM_FORMAT_XBGR1555 = 0x35314258,
  70.         WL_DRM_FORMAT_RGBX5551 = 0x35315852,
  71.         WL_DRM_FORMAT_BGRX5551 = 0x35315842,
  72.         WL_DRM_FORMAT_ARGB1555 = 0x35315241,
  73.         WL_DRM_FORMAT_ABGR1555 = 0x35314241,
  74.         WL_DRM_FORMAT_RGBA5551 = 0x35314152,
  75.         WL_DRM_FORMAT_BGRA5551 = 0x35314142,
  76.         WL_DRM_FORMAT_RGB565 = 0x36314752,
  77.         WL_DRM_FORMAT_BGR565 = 0x36314742,
  78.         WL_DRM_FORMAT_RGB888 = 0x34324752,
  79.         WL_DRM_FORMAT_BGR888 = 0x34324742,
  80.         WL_DRM_FORMAT_XRGB8888 = 0x34325258,
  81.         WL_DRM_FORMAT_XBGR8888 = 0x34324258,
  82.         WL_DRM_FORMAT_RGBX8888 = 0x34325852,
  83.         WL_DRM_FORMAT_BGRX8888 = 0x34325842,
  84.         WL_DRM_FORMAT_ARGB8888 = 0x34325241,
  85.         WL_DRM_FORMAT_ABGR8888 = 0x34324241,
  86.         WL_DRM_FORMAT_RGBA8888 = 0x34324152,
  87.         WL_DRM_FORMAT_BGRA8888 = 0x34324142,
  88.         WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
  89.         WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
  90.         WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
  91.         WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
  92.         WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
  93.         WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
  94.         WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
  95.         WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
  96.         WL_DRM_FORMAT_YUYV = 0x56595559,
  97.         WL_DRM_FORMAT_YVYU = 0x55595659,
  98.         WL_DRM_FORMAT_UYVY = 0x59565955,
  99.         WL_DRM_FORMAT_VYUY = 0x59555956,
  100.         WL_DRM_FORMAT_AYUV = 0x56555941,
  101.         WL_DRM_FORMAT_NV12 = 0x3231564e,
  102.         WL_DRM_FORMAT_NV21 = 0x3132564e,
  103.         WL_DRM_FORMAT_NV16 = 0x3631564e,
  104.         WL_DRM_FORMAT_NV61 = 0x3136564e,
  105.         WL_DRM_FORMAT_YUV410 = 0x39565559,
  106.         WL_DRM_FORMAT_YVU410 = 0x39555659,
  107.         WL_DRM_FORMAT_YUV411 = 0x31315559,
  108.         WL_DRM_FORMAT_YVU411 = 0x31315659,
  109.         WL_DRM_FORMAT_YUV420 = 0x32315559,
  110.         WL_DRM_FORMAT_YVU420 = 0x32315659,
  111.         WL_DRM_FORMAT_YUV422 = 0x36315559,
  112.         WL_DRM_FORMAT_YVU422 = 0x36315659,
  113.         WL_DRM_FORMAT_YUV444 = 0x34325559,
  114.         WL_DRM_FORMAT_YVU444 = 0x34325659,
  115. };
  116. #endif /* WL_DRM_FORMAT_ENUM */
  117.  
  118. struct wl_drm_listener {
  119.         /**
  120.          * device - device
  121.          * @name: name
  122.          */
  123.         void (*device)(void *data,
  124.                        struct wl_drm *wl_drm,
  125.                        const char *name);
  126.         /**
  127.          * format - format
  128.          * @format: format
  129.          */
  130.         void (*format)(void *data,
  131.                        struct wl_drm *wl_drm,
  132.                        uint32_t format);
  133.         /**
  134.          * authenticated - authenticated
  135.          */
  136.         void (*authenticated)(void *data,
  137.                               struct wl_drm *wl_drm);
  138. };
  139.  
  140. static inline int
  141. wl_drm_add_listener(struct wl_drm *wl_drm,
  142.                     const struct wl_drm_listener *listener, void *data)
  143. {
  144.         return wl_proxy_add_listener((struct wl_proxy *) wl_drm,
  145.                                      (void (**)(void)) listener, data);
  146. }
  147.  
  148. #define WL_DRM_AUTHENTICATE     0
  149. #define WL_DRM_CREATE_BUFFER    1
  150. #define WL_DRM_CREATE_PLANAR_BUFFER     2
  151.  
  152. static inline void
  153. wl_drm_set_user_data(struct wl_drm *wl_drm, void *user_data)
  154. {
  155.         wl_proxy_set_user_data((struct wl_proxy *) wl_drm, user_data);
  156. }
  157.  
  158. static inline void *
  159. wl_drm_get_user_data(struct wl_drm *wl_drm)
  160. {
  161.         return wl_proxy_get_user_data((struct wl_proxy *) wl_drm);
  162. }
  163.  
  164. static inline void
  165. wl_drm_destroy(struct wl_drm *wl_drm)
  166. {
  167.         wl_proxy_destroy((struct wl_proxy *) wl_drm);
  168. }
  169.  
  170. static inline void
  171. wl_drm_authenticate(struct wl_drm *wl_drm, uint32_t id)
  172. {
  173.         wl_proxy_marshal((struct wl_proxy *) wl_drm,
  174.                          WL_DRM_AUTHENTICATE, id);
  175. }
  176.  
  177. static inline struct wl_buffer *
  178. wl_drm_create_buffer(struct wl_drm *wl_drm, uint32_t name, int32_t width, int32_t height, uint32_t stride, uint32_t format)
  179. {
  180.         struct wl_proxy *id;
  181.  
  182.         id = wl_proxy_create((struct wl_proxy *) wl_drm,
  183.                              &wl_buffer_interface);
  184.         if (!id)
  185.                 return NULL;
  186.  
  187.         wl_proxy_marshal((struct wl_proxy *) wl_drm,
  188.                          WL_DRM_CREATE_BUFFER, id, name, width, height, stride, format);
  189.  
  190.         return (struct wl_buffer *) id;
  191. }
  192.  
  193. static inline struct wl_buffer *
  194. 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)
  195. {
  196.         struct wl_proxy *id;
  197.  
  198.         id = wl_proxy_create((struct wl_proxy *) wl_drm,
  199.                              &wl_buffer_interface);
  200.         if (!id)
  201.                 return NULL;
  202.  
  203.         wl_proxy_marshal((struct wl_proxy *) wl_drm,
  204.                          WL_DRM_CREATE_PLANAR_BUFFER, id, name, width, height, format, offset0, stride0, offset1, stride1, offset2, stride2);
  205.  
  206.         return (struct wl_buffer *) id;
  207. }
  208.  
  209. #ifdef  __cplusplus
  210. }
  211. #endif
  212.  
  213. #endif
  214.