1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */
3 
4 #ifndef VCHIQ_IOCTLS_H
5 #define VCHIQ_IOCTLS_H
6 
7 #include <linux/ioctl.h>
8 #include <linux/raspberrypi/vchiq.h>
9 
10 #define VCHIQ_IOC_MAGIC 0xc4
11 #define VCHIQ_INVALID_HANDLE (~0)
12 
13 struct vchiq_service_params {
14 	int fourcc;
15 	enum vchiq_status __user (*callback)(enum vchiq_reason reason,
16 				      struct vchiq_header *header,
17 				      unsigned int handle,
18 				      void *bulk_userdata);
19 	void __user *userdata;
20 	short version;       /* Increment for non-trivial changes */
21 	short version_min;   /* Update for incompatible changes */
22 };
23 
24 struct vchiq_create_service {
25 	struct vchiq_service_params params;
26 	int is_open;
27 	int is_vchi;
28 	unsigned int handle;       /* OUT */
29 };
30 
31 struct vchiq_queue_message {
32 	unsigned int handle;
33 	unsigned int count;
34 	const struct vchiq_element __user *elements;
35 };
36 
37 struct vchiq_queue_bulk_transfer {
38 	unsigned int handle;
39 	void __user *data;
40 	unsigned int size;
41 	void __user *userdata;
42 	enum vchiq_bulk_mode mode;
43 };
44 
45 struct vchiq_completion_data {
46 	enum vchiq_reason reason;
47 	struct vchiq_header __user *header;
48 	void __user *service_userdata;
49 	void __user *bulk_userdata;
50 };
51 
52 struct vchiq_await_completion {
53 	unsigned int count;
54 	struct vchiq_completion_data __user *buf;
55 	unsigned int msgbufsize;
56 	unsigned int msgbufcount; /* IN/OUT */
57 	void * __user *msgbufs;
58 };
59 
60 struct vchiq_dequeue_message {
61 	unsigned int handle;
62 	int blocking;
63 	unsigned int bufsize;
64 	void __user *buf;
65 };
66 
67 struct vchiq_get_config {
68 	unsigned int config_size;
69 	struct vchiq_config __user *pconfig;
70 };
71 
72 struct vchiq_set_service_option {
73 	unsigned int handle;
74 	enum vchiq_service_option option;
75 	int value;
76 };
77 
78 struct vchiq_dump_mem {
79 	void     __user *virt_addr;
80 	size_t    num_bytes;
81 };
82 
83 #define VCHIQ_IOC_CONNECT              _IO(VCHIQ_IOC_MAGIC,   0)
84 #define VCHIQ_IOC_SHUTDOWN             _IO(VCHIQ_IOC_MAGIC,   1)
85 #define VCHIQ_IOC_CREATE_SERVICE \
86 	_IOWR(VCHIQ_IOC_MAGIC, 2, struct vchiq_create_service)
87 #define VCHIQ_IOC_REMOVE_SERVICE       _IO(VCHIQ_IOC_MAGIC,   3)
88 #define VCHIQ_IOC_QUEUE_MESSAGE \
89 	_IOW(VCHIQ_IOC_MAGIC,  4, struct vchiq_queue_message)
90 #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT \
91 	_IOWR(VCHIQ_IOC_MAGIC, 5, struct vchiq_queue_bulk_transfer)
92 #define VCHIQ_IOC_QUEUE_BULK_RECEIVE \
93 	_IOWR(VCHIQ_IOC_MAGIC, 6, struct vchiq_queue_bulk_transfer)
94 #define VCHIQ_IOC_AWAIT_COMPLETION \
95 	_IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion)
96 #define VCHIQ_IOC_DEQUEUE_MESSAGE \
97 	_IOWR(VCHIQ_IOC_MAGIC, 8, struct vchiq_dequeue_message)
98 #define VCHIQ_IOC_GET_CLIENT_ID        _IO(VCHIQ_IOC_MAGIC,   9)
99 #define VCHIQ_IOC_GET_CONFIG \
100 	_IOWR(VCHIQ_IOC_MAGIC, 10, struct vchiq_get_config)
101 #define VCHIQ_IOC_CLOSE_SERVICE        _IO(VCHIQ_IOC_MAGIC,   11)
102 #define VCHIQ_IOC_USE_SERVICE          _IO(VCHIQ_IOC_MAGIC,   12)
103 #define VCHIQ_IOC_RELEASE_SERVICE      _IO(VCHIQ_IOC_MAGIC,   13)
104 #define VCHIQ_IOC_SET_SERVICE_OPTION \
105 	_IOW(VCHIQ_IOC_MAGIC,  14, struct vchiq_set_service_option)
106 #define VCHIQ_IOC_DUMP_PHYS_MEM \
107 	_IOW(VCHIQ_IOC_MAGIC,  15, struct vchiq_dump_mem)
108 #define VCHIQ_IOC_LIB_VERSION          _IO(VCHIQ_IOC_MAGIC,   16)
109 #define VCHIQ_IOC_CLOSE_DELIVERED      _IO(VCHIQ_IOC_MAGIC,   17)
110 #define VCHIQ_IOC_MAX                  17
111 
112 #endif
113