Add an API to get the fd used by the kms
[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 struct wl_kms_buffer {
38         struct wl_resource *resource;
39         struct wl_kms *kms;
40         int32_t width, height;
41         uint32_t stride, format;
42         uint32_t handle;
43         int fd;
44 };
45
46 int wayland_kms_fd_get(struct wl_kms *kms);
47
48 struct wl_kms_buffer *wayland_kms_buffer_get(struct wl_resource *resource);
49
50 struct wl_kms *wayland_kms_init(struct wl_display *display,
51                                 struct wl_display *server, char *device_name, int fd);
52
53 void wayland_kms_uninit(struct wl_kms *kms);
54
55 uint32_t wayland_kms_buffer_get_format(struct wl_kms_buffer *buffer);
56
57 void *wayland_kms_buffer_get_buffer(struct wl_kms_buffer *buffer);
58
59 enum wl_kms_attribute {
60         WL_KMS_WIDTH,
61         WL_KMS_HEIGHT,
62         WL_KMS_TEXTURE_FORMAT
63 };
64
65 int wayland_kms_query_buffer(struct wl_kms *kms, struct wl_resource *resource,
66                                 enum wl_kms_attribute attr, int *value);
67
68 #endif