Release DMABUFs when destroying the buffer.
[platform/adaptation/renesas_rcar/wayland-kms.git] / wayland-kms.h
1 /*
2  * Copyright 息 2013 Renesas Solutions Corp.
3  *
4  * Based on src/egl/wayland/wayland-drm/wayland-drm.h in Mesa.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  * Authors:
27  *    Takanari Hayama <taki@igel.co.jp>
28  */
29
30 #ifndef WAYLAND_KMS_H
31 #define WAYLAND_KMS_H
32
33 #include <wayland-server.h>
34
35 struct wl_kms;
36
37 #define MAX_PLANES 3
38
39 struct wl_kms_planes {
40         int fd;
41         uint32_t stride;
42 };
43
44 struct wl_kms_buffer {
45         struct wl_resource *resource;
46         struct wl_kms *kms;
47         int32_t width, height;
48         uint32_t stride, format;
49         uint32_t handle;
50         int fd;
51         void *private;
52
53         // for multi-planer formats
54         int num_planes;
55         struct wl_kms_planes planes[MAX_PLANES];
56 };
57
58 int wayland_kms_fd_get(struct wl_kms *kms);
59
60 struct wl_kms_buffer *wayland_kms_buffer_get(struct wl_resource *resource);
61
62 struct wl_kms *wayland_kms_init(struct wl_display *display,
63                                 struct wl_display *server, char *device_name, int fd);
64
65 void wayland_kms_uninit(struct wl_kms *kms);
66
67 uint32_t wayland_kms_buffer_get_format(struct wl_kms_buffer *buffer);
68
69 void *wayland_kms_buffer_get_buffer(struct wl_kms_buffer *buffer);
70
71 enum wl_kms_attribute {
72         WL_KMS_WIDTH,
73         WL_KMS_HEIGHT,
74         WL_KMS_TEXTURE_FORMAT
75 };
76
77 int wayland_kms_query_buffer(struct wl_kms *kms, struct wl_resource *resource,
78                                 enum wl_kms_attribute attr, int *value);
79
80 #endif