1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3  * Copyright 2021 Google LLC.
4  *
5  * Author: Vinay Kalia <vinaykalia@google.com>
6  */
7 
8 #ifndef _BIGO_H_
9 #define _BIGO_H_
10 
11 #include <linux/ioctl.h>
12 
13 #include <linux/types.h>
14 
15 /*
16  * Structures as parameters for BigOcean commands. It should be passed
17  * into ioctl() as the third parameter.
18  *
19  * The usage and meaning of each field is documented in command
20  * identifiers.
21  */
22 
23 struct bigo_ioc_regs {
24 	__u64 regs;
25 	__u32 regs_size;
26 };
27 
28 struct bigo_ioc_mapping {
29 	int fd;
30 	__u32 iova;
31 	__u32 offset;
32 	__u32 size;
33 };
34 
35 struct bigo_ioc_frmsize {
36 	__u32 height;
37 	__u32 width;
38 };
39 
40 struct bigo_cache_info {
41 	__u32 size;
42 	__u32 pid;
43 };
44 
45 /*
46  * Helpers for defining command identifiers. User space should not
47  * use these macros directly.
48  *
49  * <START OF HELPERS>
50  */
51 #define BIGO_IOC_MAGIC 'B'
52 
53 #define _BIGO_IO(nr) _IO(BIGO_IOC_MAGIC, nr)
54 #define _BIGO_IOR(nr, size) _IOR(BIGO_IOC_MAGIC, nr, size)
55 #define _BIGO_IOW(nr, size) _IOW(BIGO_IOC_MAGIC, nr, size)
56 #define _BIGO_IOWR(nr, size) _IOWR(BIGO_IOC_MAGIC, nr, size)
57 
58 enum bigo_cmd_id {
59 	BIGO_CMD_PROCESS,
60 	BIGO_CMD_ABORT,
61 	BIGO_CMD_MAP,
62 	BIGO_CMD_UNMAP,
63 	BIGO_CMD_CONFIG_FRMRATE,
64 	BIGO_CMD_CONFIG_FRMSIZE,
65 	BIGO_CMD_GET_CACHE_INFO,
66 	BIGO_CMD_CONFIG_SECURE,
67 	BIGO_CMD_CONFIG_PRIORITY,
68 	BIGO_CMD_MAXNR,
69 };
70 /* <END OF HELPERS> */
71 
72 #define BIGO_IOCX_PROCESS _BIGO_IOWR(BIGO_CMD_PROCESS, struct bigo_ioc_regs)
73 #define BIGO_IOCX_MAP _BIGO_IOWR(BIGO_CMD_MAP, struct bigo_ioc_mapping)
74 #define BIGO_IOCX_UNMAP _BIGO_IOW(BIGO_CMD_UNMAP, struct bigo_ioc_mapping)
75 #define BIGO_IOCX_CONFIG_FRMRATE _BIGO_IOW(BIGO_CMD_CONFIG_FRMRATE, __u32)
76 #define BIGO_IOCX_CONFIG_FRMSIZE                                               \
77 	_BIGO_IOW(BIGO_CMD_CONFIG_FRMSIZE, struct bigo_ioc_frmsize)
78 #define BIGO_IOCX_GET_CACHE_INFO                                               \
79 	_BIGO_IOR(BIGO_CMD_GET_CACHE_INFO, struct bigo_cache_info)
80 #define BIGO_IOCX_ABORT _BIGO_IO(BIGO_CMD_ABORT)
81 #define BIGO_IOCX_CONFIG_SECURE _BIGO_IOW(BIGO_CMD_CONFIG_SECURE, __u32)
82 #define BIGO_IOCX_CONFIG_PRIORITY _BIGO_IOW(BIGO_CMD_CONFIG_PRIORITY, __s32)
83 
84 #endif /* _BIGO_H_ */
85