summaryrefslogtreecommitdiff
path: root/src/lib/ecore_buffer/bq_mgr_protocol.h
blob: 7cf9ad9380baf4ad1fea8424e32dfdb04e488fff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#ifndef BQ_MGR_CLIENT_PROTOCOL_H
#define BQ_MGR_CLIENT_PROTOCOL_H

#ifdef  __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"

struct wl_client;
struct wl_resource;

struct bq_mgr;
struct bq_consumer;
struct bq_provider;
struct bq_buffer;

extern const struct wl_interface bq_mgr_interface;
extern const struct wl_interface bq_consumer_interface;
extern const struct wl_interface bq_provider_interface;
extern const struct wl_interface bq_buffer_interface;

#ifndef BQ_MGR_ERROR_ENUM
#define BQ_MGR_ERROR_ENUM
enum bq_mgr_error {
	BQ_MGR_ERROR_INVALID_PERMISSION = 0,
	BQ_MGR_ERROR_INVALID_NAME = 1,
	BQ_MGR_ERROR_ALREADY_USED = 2,
};
#endif /* BQ_MGR_ERROR_ENUM */

#define BQ_MGR_CREATE_CONSUMER	0
#define BQ_MGR_CREATE_PROVIDER	1

static inline void
bq_mgr_set_user_data(struct bq_mgr *bq_mgr, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) bq_mgr, user_data);
}

static inline void *
bq_mgr_get_user_data(struct bq_mgr *bq_mgr)
{
	return wl_proxy_get_user_data((struct wl_proxy *) bq_mgr);
}

static inline void
bq_mgr_destroy(struct bq_mgr *bq_mgr)
{
	wl_proxy_destroy((struct wl_proxy *) bq_mgr);
}

static inline struct bq_consumer *
bq_mgr_create_consumer(struct bq_mgr *bq_mgr, const char *name, int32_t queue_size, int32_t width, int32_t height)
{
	struct wl_proxy *id;

	id = wl_proxy_marshal_constructor((struct wl_proxy *) bq_mgr,
			 BQ_MGR_CREATE_CONSUMER, &bq_consumer_interface, NULL, name, queue_size, width, height);

	return (struct bq_consumer *) id;
}

static inline struct bq_provider *
bq_mgr_create_provider(struct bq_mgr *bq_mgr, const char *name)
{
	struct wl_proxy *id;

	id = wl_proxy_marshal_constructor((struct wl_proxy *) bq_mgr,
			 BQ_MGR_CREATE_PROVIDER, &bq_provider_interface, NULL, name);

	return (struct bq_provider *) id;
}

struct bq_consumer_listener {
	/**
	 * connected - (none)
	 */
	void (*connected)(void *data,
			  struct bq_consumer *bq_consumer);
	/**
	 * disconnected - (none)
	 */
	void (*disconnected)(void *data,
			     struct bq_consumer *bq_consumer);
	/**
	 * buffer_attached - (none)
	 * @buffer: (none)
	 * @engine: (none)
	 * @width: (none)
	 * @height: (none)
	 * @format: (none)
	 * @flags: (none)
	 */
	void (*buffer_attached)(void *data,
				struct bq_consumer *bq_consumer,
				struct bq_buffer *buffer,
				const char *engine,
				int32_t width,
				int32_t height,
				int32_t format,
				uint32_t flags);
	/**
	 * set_buffer_id - (none)
	 * @buffer: (none)
	 * @id: (none)
	 * @offset0: (none)
	 * @stride0: (none)
	 * @offset1: (none)
	 * @stride1: (none)
	 * @offset2: (none)
	 * @stride2: (none)
	 */
	void (*set_buffer_id)(void *data,
			      struct bq_consumer *bq_consumer,
			      struct bq_buffer *buffer,
			      int32_t id,
			      int32_t offset0,
			      int32_t stride0,
			      int32_t offset1,
			      int32_t stride1,
			      int32_t offset2,
			      int32_t stride2);
	/**
	 * set_buffer_fd - (none)
	 * @buffer: (none)
	 * @fd: (none)
	 * @offset0: (none)
	 * @stride0: (none)
	 * @offset1: (none)
	 * @stride1: (none)
	 * @offset2: (none)
	 * @stride2: (none)
	 */
	void (*set_buffer_fd)(void *data,
			      struct bq_consumer *bq_consumer,
			      struct bq_buffer *buffer,
			      int32_t fd,
			      int32_t offset0,
			      int32_t stride0,
			      int32_t offset1,
			      int32_t stride1,
			      int32_t offset2,
			      int32_t stride2);
	/**
	 * buffer_detached - (none)
	 * @buffer: (none)
	 */
	void (*buffer_detached)(void *data,
				struct bq_consumer *bq_consumer,
				struct bq_buffer *buffer);
	/**
	 * add_buffer - (none)
	 * @buffer: (none)
	 * @serial: (none)
	 */
	void (*add_buffer)(void *data,
			   struct bq_consumer *bq_consumer,
			   struct bq_buffer *buffer,
			   uint32_t serial);
};

static inline int
bq_consumer_add_listener(struct bq_consumer *bq_consumer,
			 const struct bq_consumer_listener *listener, void *data)
{
	return wl_proxy_add_listener((struct wl_proxy *) bq_consumer,
				     (void (**)(void)) listener, data);
}

#define BQ_CONSUMER_RELEASE_BUFFER	0

static inline void
bq_consumer_set_user_data(struct bq_consumer *bq_consumer, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) bq_consumer, user_data);
}

static inline void *
bq_consumer_get_user_data(struct bq_consumer *bq_consumer)
{
	return wl_proxy_get_user_data((struct wl_proxy *) bq_consumer);
}

static inline void
bq_consumer_destroy(struct bq_consumer *bq_consumer)
{
	wl_proxy_destroy((struct wl_proxy *) bq_consumer);
}

static inline void
bq_consumer_release_buffer(struct bq_consumer *bq_consumer, struct bq_buffer *buffer)
{
	wl_proxy_marshal((struct wl_proxy *) bq_consumer,
			 BQ_CONSUMER_RELEASE_BUFFER, buffer);
}

#ifndef BQ_PROVIDER_ERROR_ENUM
#define BQ_PROVIDER_ERROR_ENUM
enum bq_provider_error {
	BQ_PROVIDER_ERROR_OVERFLOW_QUEUE_SIZE = 0,
	BQ_PROVIDER_ERROR_CONNECTION = 1,
};
#endif /* BQ_PROVIDER_ERROR_ENUM */

struct bq_provider_listener {
	/**
	 * connected - (none)
	 * @queue_size: (none)
	 * @width: (none)
	 * @height: (none)
	 */
	void (*connected)(void *data,
			  struct bq_provider *bq_provider,
			  int32_t queue_size,
			  int32_t width,
			  int32_t height);
	/**
	 * disconnected - (none)
	 */
	void (*disconnected)(void *data,
			     struct bq_provider *bq_provider);
	/**
	 * add_buffer - (none)
	 * @buffer: (none)
	 * @serial: (none)
	 */
	void (*add_buffer)(void *data,
			   struct bq_provider *bq_provider,
			   struct bq_buffer *buffer,
			   uint32_t serial);
};

static inline int
bq_provider_add_listener(struct bq_provider *bq_provider,
			 const struct bq_provider_listener *listener, void *data)
{
	return wl_proxy_add_listener((struct wl_proxy *) bq_provider,
				     (void (**)(void)) listener, data);
}

#define BQ_PROVIDER_ATTACH_BUFFER	0
#define BQ_PROVIDER_SET_BUFFER_ID	1
#define BQ_PROVIDER_SET_BUFFER_FD	2
#define BQ_PROVIDER_DETACH_BUFFER	3
#define BQ_PROVIDER_ENQUEUE_BUFFER	4

static inline void
bq_provider_set_user_data(struct bq_provider *bq_provider, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) bq_provider, user_data);
}

static inline void *
bq_provider_get_user_data(struct bq_provider *bq_provider)
{
	return wl_proxy_get_user_data((struct wl_proxy *) bq_provider);
}

static inline void
bq_provider_destroy(struct bq_provider *bq_provider)
{
	wl_proxy_destroy((struct wl_proxy *) bq_provider);
}

static inline struct bq_buffer *
bq_provider_attach_buffer(struct bq_provider *bq_provider, const char *engine, int32_t width, int32_t height, int32_t format, uint32_t flags)
{
	struct wl_proxy *buffer;

	buffer = wl_proxy_marshal_constructor((struct wl_proxy *) bq_provider,
			 BQ_PROVIDER_ATTACH_BUFFER, &bq_buffer_interface, NULL, engine, width, height, format, flags);

	return (struct bq_buffer *) buffer;
}

static inline void
bq_provider_set_buffer_id(struct bq_provider *bq_provider, struct bq_buffer *buffer, int32_t id, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
{
	wl_proxy_marshal((struct wl_proxy *) bq_provider,
			 BQ_PROVIDER_SET_BUFFER_ID, buffer, id, offset0, stride0, offset1, stride1, offset2, stride2);
}

static inline void
bq_provider_set_buffer_fd(struct bq_provider *bq_provider, struct bq_buffer *buffer, int32_t fd, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
{
	wl_proxy_marshal((struct wl_proxy *) bq_provider,
			 BQ_PROVIDER_SET_BUFFER_FD, buffer, fd, offset0, stride0, offset1, stride1, offset2, stride2);
}

static inline void
bq_provider_detach_buffer(struct bq_provider *bq_provider, struct bq_buffer *buffer)
{
	wl_proxy_marshal((struct wl_proxy *) bq_provider,
			 BQ_PROVIDER_DETACH_BUFFER, buffer);
}

static inline void
bq_provider_enqueue_buffer(struct bq_provider *bq_provider, struct bq_buffer *buffer, uint32_t serial)
{
	wl_proxy_marshal((struct wl_proxy *) bq_provider,
			 BQ_PROVIDER_ENQUEUE_BUFFER, buffer, serial);
}

static inline void
bq_buffer_set_user_data(struct bq_buffer *bq_buffer, void *user_data)
{
	wl_proxy_set_user_data((struct wl_proxy *) bq_buffer, user_data);
}

static inline void *
bq_buffer_get_user_data(struct bq_buffer *bq_buffer)
{
	return wl_proxy_get_user_data((struct wl_proxy *) bq_buffer);
}

static inline void
bq_buffer_destroy(struct bq_buffer *bq_buffer)
{
	wl_proxy_destroy((struct wl_proxy *) bq_buffer);
}

#ifdef  __cplusplus
}
#endif

#endif