Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / gbm / main / gbm.h
1 /*
2  * Copyright © 2011 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  *
24  * Authors:
25  *    Benjamin Franzke <benjaminfranzke@googlemail.com>
26  */
27
28 #ifndef _GBM_H_
29 #define _GBM_H_
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35
36 #define __GBM__ 1
37
38 #include <stdint.h>
39
40 struct gbm_device;
41 struct gbm_bo;
42
43 union gbm_bo_handle {
44    void *ptr;
45    int32_t s32;
46    uint32_t u32;
47    int64_t s64;
48    uint64_t u64;
49 };
50
51 enum gbm_bo_format {
52    GBM_BO_FORMAT_XRGB8888,
53    GBM_BO_FORMAT_ARGB8888,
54 };
55
56 enum gbm_bo_flags {
57    GBM_BO_USE_SCANOUT      = (1 << 0),
58    GBM_BO_USE_CURSOR_64X64 = (1 << 1),
59    GBM_BO_USE_RENDERING    = (1 << 2),
60 };
61
62 int
63 gbm_device_get_fd(struct gbm_device *gbm);
64
65 const char *
66 gbm_device_get_backend_name(struct gbm_device *gbm);
67
68 int
69 gbm_device_is_format_supported(struct gbm_device *gbm,
70                                enum gbm_bo_format format,
71                                uint32_t usage);
72
73 void
74 gbm_device_destroy(struct gbm_device *gbm);
75
76 struct gbm_device *
77 gbm_create_device(int fd);
78
79 struct gbm_bo *
80 gbm_bo_create(struct gbm_device *gbm,
81               uint32_t width, uint32_t height,
82               enum gbm_bo_format format, uint32_t flags);
83
84 struct gbm_bo *
85 gbm_bo_create_from_egl_image(struct gbm_device *gbm,
86                              void *egl_dpy, void *egl_img,
87                              uint32_t width, uint32_t height,
88                              uint32_t usage);
89
90 uint32_t
91 gbm_bo_get_width(struct gbm_bo *bo);
92
93 uint32_t
94 gbm_bo_get_height(struct gbm_bo *bo);
95
96 uint32_t
97 gbm_bo_get_pitch(struct gbm_bo *bo);
98
99 union gbm_bo_handle
100 gbm_bo_get_handle(struct gbm_bo *bo);
101
102 void
103 gbm_bo_destroy(struct gbm_bo *bo);
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif