blob: c4ec57161cd25a6db9d9df3e90d1994026315427 [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From 48a946e24c3e7172f1044f5815e9cfed96982830 Mon Sep 17 00:00:00 2001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 2 Apr 2016 10:54:59 -0700
Brad Bishop26bdd442019-08-16 17:08:17 -04004Subject: [PATCH 12/19] implement buffer wrapping interface for dispmanx
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08005
6Courtesy: Zan Dobersek
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 interface/khronos/ext/egl_wayland.c | 42 +++++++++++++++++++++++++++++
11 interface/wayland/dispmanx.xml | 10 +++++++
12 2 files changed, 52 insertions(+)
13
14diff --git a/interface/khronos/ext/egl_wayland.c b/interface/khronos/ext/egl_wayland.c
15index 5730743..9ef89cd 100644
16--- a/interface/khronos/ext/egl_wayland.c
17+++ b/interface/khronos/ext/egl_wayland.c
18@@ -133,8 +133,50 @@ dispmanx_create_buffer(struct wl_client *client, struct wl_resource *resource,
19 buffer->handle);
20 }
21
22+static void
23+dispmanx_wrap_buffer(struct wl_client *client, struct wl_resource *resource,
24+ uint32_t id, uint32_t handle, int32_t width, int32_t height,
25+ uint32_t stride, uint32_t buffer_height, uint32_t format)
26+{
27+ struct wl_dispmanx_server_buffer *buffer;
28+ VC_IMAGE_TYPE_T vc_format = get_vc_format(format);
29+ uint32_t dummy;
30+
31+ if(vc_format == VC_IMAGE_MIN) {
32+ wl_resource_post_error(resource,
33+ WL_DISPMANX_ERROR_INVALID_FORMAT,
34+ "invalid format");
35+ return;
36+ }
37+
38+ buffer = calloc(1, sizeof *buffer);
39+ if (buffer == NULL) {
40+ wl_resource_post_no_memory(resource);
41+ return;
42+ }
43+
44+ buffer->handle = handle;
45+ buffer->width = width;
46+ buffer->height = height;
47+ buffer->format = format;
48+
49+ buffer->resource = wl_resource_create(resource->client, &wl_buffer_interface,
50+ 1, id);
51+ if (!buffer->resource) {
52+ wl_resource_post_no_memory(resource);
53+ vc_dispmanx_resource_delete(buffer->handle);
54+ free(buffer);
55+ return;
56+ }
57+
58+ wl_resource_set_implementation(buffer->resource,
59+ (void (**)(void)) &dispmanx_buffer_interface,
60+ buffer, destroy_buffer);
61+}
62+
63 static const struct wl_dispmanx_interface dispmanx_interface = {
64 dispmanx_create_buffer,
65+ dispmanx_wrap_buffer,
66 };
67
68 static void
69diff --git a/interface/wayland/dispmanx.xml b/interface/wayland/dispmanx.xml
70index c18626d..11ed1ef 100644
71--- a/interface/wayland/dispmanx.xml
72+++ b/interface/wayland/dispmanx.xml
73@@ -118,6 +118,16 @@
74 <arg name="buffer" type="object" interface="wl_buffer"/>
75 <arg name="handle" type="uint"/>
76 </event>
77+
78+ <request name="wrap_buffer">
79+ <arg name="id" type="new_id" interface="wl_buffer"/>
80+ <arg name="handle" type="uint"/>
81+ <arg name="width" type="int"/>
82+ <arg name="height" type="int"/>
83+ <arg name="stride" type="uint"/>
84+ <arg name="buffer_height" type="uint"/>
85+ <arg name="format" type="uint"/>
86+ </request>
87 </interface>
88
89 </protocol>
90--
Brad Bishop26bdd442019-08-16 17:08:17 -0400912.22.0
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080092