Pekka Paalanen | 230f3b1 | 2014-09-29 14:18:40 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2014, 2015 Collabora, Ltd. |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and |
| 5 | * its documentation for any purpose is hereby granted without fee, provided |
| 6 | * that the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation, and that the name of the copyright holders not be used in |
| 9 | * advertising or publicity pertaining to distribution of the software |
| 10 | * without specific, written prior permission. The copyright holders make |
| 11 | * no representations about the suitability of this software for any |
| 12 | * purpose. It is provided "as is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS |
| 15 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 16 | * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 17 | * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER |
| 18 | * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
| 19 | * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 20 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #ifndef WESTON_LINUX_DMABUF_H |
| 24 | #define WESTON_LINUX_DMABUF_H |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | |
| 28 | #define MAX_DMABUF_PLANES 4 |
| 29 | |
| 30 | struct linux_dmabuf_buffer; |
| 31 | typedef void (*dmabuf_user_data_destroy_func)( |
| 32 | struct linux_dmabuf_buffer *buffer); |
| 33 | |
Emmanuel Gil Peyrot | c399692 | 2015-11-24 19:28:24 +0000 | [diff] [blame^] | 34 | struct dmabuf_attributes { |
Pekka Paalanen | 230f3b1 | 2014-09-29 14:18:40 -0400 | [diff] [blame] | 35 | int32_t width; |
| 36 | int32_t height; |
| 37 | uint32_t format; |
| 38 | uint32_t flags; /* enum zlinux_buffer_params_flags */ |
| 39 | int n_planes; |
Emmanuel Gil Peyrot | c399692 | 2015-11-24 19:28:24 +0000 | [diff] [blame^] | 40 | int fd[MAX_DMABUF_PLANES]; |
Pekka Paalanen | 230f3b1 | 2014-09-29 14:18:40 -0400 | [diff] [blame] | 41 | uint32_t offset[MAX_DMABUF_PLANES]; |
| 42 | uint32_t stride[MAX_DMABUF_PLANES]; |
| 43 | uint64_t modifier[MAX_DMABUF_PLANES]; |
Emmanuel Gil Peyrot | c399692 | 2015-11-24 19:28:24 +0000 | [diff] [blame^] | 44 | }; |
| 45 | |
| 46 | struct linux_dmabuf_buffer { |
| 47 | struct wl_resource *buffer_resource; |
| 48 | struct wl_resource *params_resource; |
| 49 | struct weston_compositor *compositor; |
| 50 | struct dmabuf_attributes attributes; |
Pekka Paalanen | 230f3b1 | 2014-09-29 14:18:40 -0400 | [diff] [blame] | 51 | |
| 52 | void *user_data; |
| 53 | dmabuf_user_data_destroy_func user_data_destroy_func; |
| 54 | |
| 55 | /* XXX: |
| 56 | * |
| 57 | * Add backend private data. This would be for the backend |
| 58 | * to do all additional imports it might ever use in advance. |
| 59 | * The basic principle, even if not implemented in drivers today, |
| 60 | * is that dmabufs are first attached, but the actual allocation |
| 61 | * is deferred to first use. This would allow the exporter and all |
| 62 | * attachers to agree on how to allocate. |
| 63 | * |
| 64 | * The DRM backend would use this to create drmFBs for each |
| 65 | * dmabuf_buffer, just in case at some point it would become |
| 66 | * feasible to scan it out directly. This would improve the |
| 67 | * possibilities to successfully scan out, avoiding compositing. |
| 68 | */ |
| 69 | }; |
| 70 | |
| 71 | int |
| 72 | linux_dmabuf_setup(struct weston_compositor *compositor); |
| 73 | |
| 74 | struct linux_dmabuf_buffer * |
| 75 | linux_dmabuf_buffer_get(struct wl_resource *resource); |
| 76 | |
| 77 | void |
| 78 | linux_dmabuf_buffer_set_user_data(struct linux_dmabuf_buffer *buffer, |
| 79 | void *data, |
| 80 | dmabuf_user_data_destroy_func func); |
| 81 | void * |
| 82 | linux_dmabuf_buffer_get_user_data(struct linux_dmabuf_buffer *buffer); |
| 83 | |
| 84 | void |
| 85 | linux_dmabuf_buffer_send_server_error(struct linux_dmabuf_buffer *buffer, |
| 86 | const char *msg); |
| 87 | |
| 88 | #endif /* WESTON_LINUX_DMABUF_H */ |