Andrew Geissler | 26e4bea | 2020-11-30 19:54:03 -0600 | [diff] [blame] | 1 | From bdb5bbe994b91a7c64ca6103fbf2bbd590e6b8e5 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 2 Apr 2016 10:54:59 -0700 |
Andrew Geissler | 26e4bea | 2020-11-30 19:54:03 -0600 | [diff] [blame] | 4 | Subject: [PATCH] implement buffer wrapping interface for dispmanx |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 5 | |
| 6 | Courtesy: Zan Dobersek |
| 7 | |
| 8 | Signed-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 | |
| 14 | diff --git a/interface/khronos/ext/egl_wayland.c b/interface/khronos/ext/egl_wayland.c |
| 15 | index 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 |
| 69 | diff --git a/interface/wayland/dispmanx.xml b/interface/wayland/dispmanx.xml |
| 70 | index 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> |