limin.tian | 8c5c1e1 | 2023-02-28 03:27:14 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
limin.tian | 79bf2b1 | 2023-02-24 10:28:26 +0000 | [diff] [blame] | 2 | /*
|
| 3 | * Framework for buffer objects that can be shared across devices/subsystems.
|
| 4 | *
|
| 5 | * Copyright(C) 2015 Intel Ltd
|
| 6 | *
|
| 7 | * This program is free software; you can redistribute it and/or modify it
|
| 8 | * under the terms of the GNU General Public License version 2 as published by
|
| 9 | * the Free Software Foundation.
|
| 10 | *
|
| 11 | * This program is distributed in the hope that it will be useful, but WITHOUT
|
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
| 14 | * more details.
|
| 15 | *
|
| 16 | * You should have received a copy of the GNU General Public License along with
|
| 17 | * this program. If not, see <http://www.gnu.org/licenses/>.
|
| 18 | */
|
wenlong.zhang | e389b37 | 2021-12-16 16:42:08 +0800 | [diff] [blame] | 19 | |
| 20 | #ifndef _DMA_BUF_UAPI_H_ |
| 21 | #define _DMA_BUF_UAPI_H_ |
| 22 | |
| 23 | #include <linux/types.h> |
| 24 | |
| 25 | /* begin/end dma-buf functions used for userspace mmap. */ |
| 26 | struct dma_buf_sync { |
| 27 | __u64 flags; |
| 28 | }; |
| 29 | |
| 30 | #define DMA_BUF_SYNC_READ (1 << 0) |
| 31 | #define DMA_BUF_SYNC_WRITE (2 << 0) |
| 32 | #define DMA_BUF_SYNC_RW (DMA_BUF_SYNC_READ | DMA_BUF_SYNC_WRITE) |
| 33 | #define DMA_BUF_SYNC_START (0 << 2) |
| 34 | #define DMA_BUF_SYNC_END (1 << 2) |
| 35 | #define DMA_BUF_SYNC_VALID_FLAGS_MASK \ |
| 36 | (DMA_BUF_SYNC_RW | DMA_BUF_SYNC_END) |
| 37 | |
limin.tian | 8c5c1e1 | 2023-02-28 03:27:14 +0000 | [diff] [blame] | 38 | #define DMA_BUF_NAME_LEN 32
|
| 39 |
|
wenlong.zhang | e389b37 | 2021-12-16 16:42:08 +0800 | [diff] [blame] | 40 | /** |
| 41 | * struct dma_buf_export_sync_file - Get a sync_file from a dma-buf |
| 42 | * |
| 43 | * Userspace can perform a DMA_BUF_IOCTL_EXPORT_SYNC_FILE to retrieve the |
| 44 | * current set of fences on a dma-buf file descriptor as a sync_file. CPU |
| 45 | * waits via poll() or other driver-specific mechanisms typically wait on |
| 46 | * whatever fences are on the dma-buf at the time the wait begins. This |
| 47 | * is similar except that it takes a snapshot of the current fences on the |
| 48 | * dma-buf for waiting later instead of waiting immediately. This is |
| 49 | * useful for modern graphics APIs such as Vulkan which assume an explicit |
| 50 | * synchronization model but still need to inter-operate with dma-buf. |
| 51 | */ |
| 52 | struct dma_buf_export_sync_file { |
| 53 | /** |
| 54 | * @flags: Read/write flags |
| 55 | * |
| 56 | * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both. |
| 57 | * |
| 58 | * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set, |
| 59 | * the returned sync file waits on any writers of the dma-buf to |
| 60 | * complete. Waiting on the returned sync file is equivalent to |
| 61 | * poll() with POLLIN. |
| 62 | * |
| 63 | * If DMA_BUF_SYNC_WRITE is set, the returned sync file waits on |
| 64 | * any users of the dma-buf (read or write) to complete. Waiting |
| 65 | * on the returned sync file is equivalent to poll() with POLLOUT. |
| 66 | * If both DMA_BUF_SYNC_WRITE and DMA_BUF_SYNC_READ are set, this |
| 67 | * is equivalent to just DMA_BUF_SYNC_WRITE. |
| 68 | */ |
| 69 | __u32 flags; |
| 70 | /** @fd: Returned sync file descriptor */ |
| 71 | __s32 fd; |
| 72 | }; |
| 73 | |
| 74 | #define DMA_BUF_BASE 'b' |
| 75 | #define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync) |
limin.tian | 8c5c1e1 | 2023-02-28 03:27:14 +0000 | [diff] [blame] | 76 |
|
| 77 | /* 32/64bitness of this uapi was botched in android, there's no difference
|
| 78 | * between them in actual uapi, they're just different numbers.
|
| 79 | */
|
| 80 | #define DMA_BUF_SET_NAME _IOW(DMA_BUF_BASE, 1, const char *)
|
| 81 | #define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, __u32)
|
| 82 | #define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, __u64)
|
wenlong.zhang | e389b37 | 2021-12-16 16:42:08 +0800 | [diff] [blame] | 83 | #define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file) |
| 84 | |
| 85 | #endif |