xref: /OK3568_Linux_fs/kernel/include/linux/dma-buf-test-exporter.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2012-2013, 2017, 2020-2021 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 #ifndef _LINUX_DMA_BUF_TEST_EXPORTER_H_
23 #define _LINUX_DMA_BUF_TEST_EXPORTER_H_
24 
25 #include <linux/types.h>
26 #include <linux/ioctl.h>
27 
28 #define DMA_BUF_TE_VER_MAJOR 1
29 #define DMA_BUF_TE_VER_MINOR 0
30 #define DMA_BUF_TE_ENQ 0x642d7465
31 #define DMA_BUF_TE_ACK 0x68692100
32 
33 struct dma_buf_te_ioctl_version {
34 	int op;    /**< Must be set to DMA_BUF_TE_ENQ by client, driver will set it to DMA_BUF_TE_ACK */
35 	int major; /**< Major version */
36 	int minor; /**< Minor version */
37 };
38 
39 struct dma_buf_te_ioctl_alloc {
40 	__u64 size; /* size of buffer to allocate, in pages */
41 };
42 
43 struct dma_buf_te_ioctl_status {
44 	/* in */
45 	int fd; /* the dma_buf to query, only dma_buf objects exported by this driver is supported */
46 	/* out */
47 	int attached_devices; /* number of devices attached (active 'dma_buf_attach's) */
48 	int device_mappings; /* number of device mappings (active 'dma_buf_map_attachment's) */
49 	int cpu_mappings;    /* number of cpu mappings (active 'mmap's) */
50 };
51 
52 struct dma_buf_te_ioctl_set_failing {
53 	/* in */
54 	int fd; /* the dma_buf to set failure mode for, only dma_buf objects exported by this driver is supported */
55 
56 	/* zero = no fail injection, non-zero = inject failure */
57 	int fail_attach;
58 	int fail_map;
59 	int fail_mmap;
60 };
61 
62 struct dma_buf_te_ioctl_fill {
63 	int fd;
64 	unsigned int value;
65 };
66 
67 #define DMA_BUF_TE_IOCTL_BASE 'E'
68 /* Below all returning 0 if successful or -errcode except DMA_BUF_TE_ALLOC which will return fd or -errcode */
69 #define DMA_BUF_TE_VERSION         _IOR(DMA_BUF_TE_IOCTL_BASE, 0x00, struct dma_buf_te_ioctl_version)
70 #define DMA_BUF_TE_ALLOC           _IOR(DMA_BUF_TE_IOCTL_BASE, 0x01, struct dma_buf_te_ioctl_alloc)
71 #define DMA_BUF_TE_QUERY           _IOR(DMA_BUF_TE_IOCTL_BASE, 0x02, struct dma_buf_te_ioctl_status)
72 #define DMA_BUF_TE_SET_FAILING     _IOW(DMA_BUF_TE_IOCTL_BASE, 0x03, struct dma_buf_te_ioctl_set_failing)
73 #define DMA_BUF_TE_ALLOC_CONT      _IOR(DMA_BUF_TE_IOCTL_BASE, 0x04, struct dma_buf_te_ioctl_alloc)
74 #define DMA_BUF_TE_FILL            _IOR(DMA_BUF_TE_IOCTL_BASE, 0x05, struct dma_buf_te_ioctl_fill)
75 
76 #endif /* _LINUX_DMA_BUF_TEST_EXPORTER_H_ */
77