1
2
3
4 #ifndef VCHI_H_
5 #define VCHI_H_
6
7 #include "interface/vchi/vchi_cfg.h"
8 #include "interface/vchi/vchi_common.h"
9
10
11
12
13
14 #define VCHI_BULK_ROUND_UP(x) ((((unsigned long)(x))+VCHI_BULK_ALIGN-1) & ~(VCHI_BULK_ALIGN-1))
15 #define VCHI_BULK_ROUND_DOWN(x) (((unsigned long)(x)) & ~(VCHI_BULK_ALIGN-1))
16 #define VCHI_BULK_ALIGN_NBYTES(x) (VCHI_BULK_ALIGNED(x) ? 0 : (VCHI_BULK_ALIGN - ((unsigned long)(x) & (VCHI_BULK_ALIGN-1))))
17
18 #ifdef USE_VCHIQ_ARM
19 #define VCHI_BULK_ALIGNED(x) 1
20 #else
21 #define VCHI_BULK_ALIGNED(x) (((unsigned long)(x) & (VCHI_BULK_ALIGN-1)) == 0)
22 #endif
23
24 struct vchi_version {
25 uint32_t version;
26 uint32_t version_min;
27 };
28 #define VCHI_VERSION(v_) { v_, v_ }
29 #define VCHI_VERSION_EX(v_, m_) { v_, m_ }
30
31
32 #define MAKE_FOURCC(x) ((int32_t)((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3]))
33
34
35 struct opaque_vchi_service_t;
36
37
38
39 struct vchi_held_msg {
40 struct opaque_vchi_service_t *service;
41 void *message;
42 };
43
44
45 struct service_creation {
46 struct vchi_version version;
47 int32_t service_id;
48 VCHI_CALLBACK_T callback;
49 void *callback_param;
50 };
51
52
53 typedef struct opaque_vchi_instance_handle_t *VCHI_INSTANCE_T;
54
55
56 typedef struct opaque_vchi_service_handle_t *VCHI_SERVICE_HANDLE_T;
57
58
59
60
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66
67 extern int32_t vchi_initialise(VCHI_INSTANCE_T *instance_handle);
68
69 extern int32_t vchi_exit(void);
70
71 extern int32_t vchi_connect(VCHI_INSTANCE_T instance_handle);
72
73
74
75 extern int32_t vchi_disconnect(VCHI_INSTANCE_T instance_handle);
76
77
78 extern void *vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *length);
79 extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address);
80 extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle);
81
82
83
84
85
86 extern int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle);
87
88
89 extern int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle,
90 struct service_creation *setup,
91 VCHI_SERVICE_HANDLE_T *handle);
92
93 extern int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle,
94 short *peer_version);
95
96
97 extern int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle);
98
99
100 extern int32_t vchi_service_use(const VCHI_SERVICE_HANDLE_T handle);
101
102
103 extern int32_t vchi_service_release(const VCHI_SERVICE_HANDLE_T handle);
104
105
106 extern int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle,
107 VCHI_SERVICE_OPTION_T option,
108 int value);
109
110
111 extern int
112 vchi_queue_kernel_message(VCHI_SERVICE_HANDLE_T handle,
113 void *data,
114 unsigned int size);
115
116
117 extern int
118 vchi_queue_user_message(VCHI_SERVICE_HANDLE_T handle,
119 void __user *data,
120 unsigned int size);
121
122
123
124 extern int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle,
125 void *data,
126 uint32_t max_data_size_to_read,
127 uint32_t *actual_msg_size,
128 VCHI_FLAGS_T flags);
129
130
131
132
133 extern int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle,
134 void **data,
135 uint32_t *msg_size,
136 VCHI_FLAGS_T flags);
137
138
139
140 extern int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle);
141
142
143
144
145 extern int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle,
146 void **data,
147 uint32_t *msg_size,
148 VCHI_FLAGS_T flags,
149 struct vchi_held_msg *message_descriptor);
150
151
152 extern int32_t vchi_msg_look_ahead(VCHI_SERVICE_HANDLE_T handle,
153 struct vchi_msg_iter *iter,
154 VCHI_FLAGS_T flags);
155
156
157
158
159
160
161 extern void *vchi_held_msg_ptr(const struct vchi_held_msg *message);
162
163
164 extern int32_t vchi_held_msg_size(const struct vchi_held_msg *message);
165
166
167 extern uint32_t vchi_held_msg_tx_timestamp(const struct vchi_held_msg *message);
168
169
170 extern uint32_t vchi_held_msg_rx_timestamp(const struct vchi_held_msg *message);
171
172
173 extern int32_t vchi_held_msg_release(struct vchi_held_msg *message);
174
175
176 extern int32_t vchi_msg_iter_has_next(const struct vchi_msg_iter *iter);
177
178
179 extern int32_t vchi_msg_iter_next(struct vchi_msg_iter *iter,
180 void **data,
181 uint32_t *msg_size);
182
183
184
185 extern int32_t vchi_msg_iter_remove(struct vchi_msg_iter *iter);
186
187
188
189 extern int32_t vchi_msg_iter_hold(struct vchi_msg_iter *iter,
190 struct vchi_held_msg *message);
191
192
193 extern int32_t vchi_msg_iter_hold_next(struct vchi_msg_iter *iter,
194 void **data,
195 uint32_t *msg_size,
196 struct vchi_held_msg *message);
197
198
199
200
201
202
203 extern int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle,
204 void *data_dst,
205 uint32_t data_size,
206 VCHI_FLAGS_T flags,
207 void *transfer_handle);
208
209
210 int32_t vchi_bulk_queue_receive_reloc(const VCHI_SERVICE_HANDLE_T handle,
211 uint32_t offset,
212 uint32_t data_size,
213 const VCHI_FLAGS_T flags,
214 void * const bulk_handle);
215
216
217 extern int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle,
218 const void *data_src,
219 uint32_t data_size,
220 VCHI_FLAGS_T flags,
221 void *transfer_handle);
222
223
224
225
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 extern int32_t vchi_bulk_queue_transmit_reloc(VCHI_SERVICE_HANDLE_T handle,
232 uint32_t offset,
233 uint32_t data_size,
234 VCHI_FLAGS_T flags,
235 void *transfer_handle);
236 #endif
237
238