mediatek: add v4.19 support
[openwrt/staging/lynxis.git] / target / linux / brcm2708 / patches-4.19 / 950-0267-staging-vc04_services-Split-vchiq-mmal-into-a-module.patch
1 From abd417b71f4b157cb183cab26620d08c303ce805 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Mon, 24 Sep 2018 16:30:37 +0100
4 Subject: [PATCH 267/703] staging: vc04_services: Split vchiq-mmal into a
5 module
6
7 In preparation for adding a video codec V4L2 module which also
8 wants to use vchiq-mmal functions, split it out into an
9 independent module.
10 The minimum number of changes have been made to achieve this
11 (eg straight moves where possible) so existing checkpatch
12 errors will still be present.
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
15 ---
16 drivers/staging/vc04_services/Kconfig | 1 +
17 drivers/staging/vc04_services/Makefile | 1 +
18 .../vc04_services/bcm2835-camera/Kconfig | 2 +-
19 .../vc04_services/bcm2835-camera/Makefile | 4 ++--
20 .../staging/vc04_services/vchiq-mmal/Kconfig | 7 ++++++
21 .../staging/vc04_services/vchiq-mmal/Makefile | 8 +++++++
22 .../mmal-common.h | 0
23 .../mmal-encodings.h | 0
24 .../mmal-msg-common.h | 0
25 .../mmal-msg-format.h | 0
26 .../mmal-msg-port.h | 0
27 .../{bcm2835-camera => vchiq-mmal}/mmal-msg.h | 0
28 .../mmal-parameters.h | 0
29 .../mmal-vchiq.c | 22 +++++++++++++++++++
30 .../mmal-vchiq.h | 0
31 15 files changed, 42 insertions(+), 3 deletions(-)
32 create mode 100644 drivers/staging/vc04_services/vchiq-mmal/Kconfig
33 create mode 100644 drivers/staging/vc04_services/vchiq-mmal/Makefile
34 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-common.h (100%)
35 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-encodings.h (100%)
36 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-msg-common.h (100%)
37 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-msg-format.h (100%)
38 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-msg-port.h (100%)
39 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-msg.h (100%)
40 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-parameters.h (100%)
41 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-vchiq.c (98%)
42 rename drivers/staging/vc04_services/{bcm2835-camera => vchiq-mmal}/mmal-vchiq.h (100%)
43
44 --- a/drivers/staging/vc04_services/Kconfig
45 +++ b/drivers/staging/vc04_services/Kconfig
46 @@ -21,6 +21,7 @@ config BCM2835_VCHIQ
47 source "drivers/staging/vc04_services/bcm2835-audio/Kconfig"
48
49 source "drivers/staging/vc04_services/bcm2835-camera/Kconfig"
50 +source "drivers/staging/vc04_services/vchiq-mmal/Kconfig"
51
52 endif
53
54 --- a/drivers/staging/vc04_services/Makefile
55 +++ b/drivers/staging/vc04_services/Makefile
56 @@ -12,6 +12,7 @@ vchiq-objs := \
57
58 obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/
59 obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/
60 +obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += vchiq-mmal/
61
62 ccflags-y += -Idrivers/staging/vc04_services -D__VCCOREVER__=0x04000000
63
64 --- a/drivers/staging/vc04_services/bcm2835-camera/Kconfig
65 +++ b/drivers/staging/vc04_services/bcm2835-camera/Kconfig
66 @@ -2,7 +2,7 @@ config VIDEO_BCM2835
67 tristate "BCM2835 Camera"
68 depends on MEDIA_SUPPORT
69 depends on VIDEO_V4L2 && (ARCH_BCM2835 || COMPILE_TEST)
70 - select BCM2835_VCHIQ
71 + select BCM2835_VCHIQ_MMAL
72 select VIDEOBUF2_VMALLOC
73 select BTREE
74 help
75 --- a/drivers/staging/vc04_services/bcm2835-camera/Makefile
76 +++ b/drivers/staging/vc04_services/bcm2835-camera/Makefile
77 @@ -1,11 +1,11 @@
78 # SPDX-License-Identifier: GPL-2.0
79 bcm2835-v4l2-$(CONFIG_VIDEO_BCM2835) := \
80 bcm2835-camera.o \
81 - controls.o \
82 - mmal-vchiq.o
83 + controls.o
84
85 obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-v4l2.o
86
87 ccflags-y += \
88 -Idrivers/staging/vc04_services \
89 + -Idrivers/staging/vc04_services/vchiq-mmal \
90 -D__VCCOREVER__=0x04000000
91 --- /dev/null
92 +++ b/drivers/staging/vc04_services/vchiq-mmal/Kconfig
93 @@ -0,0 +1,7 @@
94 +config BCM2835_VCHIQ_MMAL
95 + tristate "BCM2835 MMAL VCHIQ service"
96 + depends on (ARCH_BCM2835 || COMPILE_TEST)
97 + select BCM2835_VCHIQ
98 + help
99 + Enables the MMAL API over VCHIQ as used for the
100 + majority of the multimedia services on VideoCore.
101 --- /dev/null
102 +++ b/drivers/staging/vc04_services/vchiq-mmal/Makefile
103 @@ -0,0 +1,8 @@
104 +# SPDX-License-Identifier: GPL-2.0
105 +bcm2835-mmal-vchiq-objs := mmal-vchiq.o
106 +
107 +obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += bcm2835-mmal-vchiq.o
108 +
109 +ccflags-y += \
110 + -Idrivers/staging/vc04_services \
111 + -D__VCCOREVER__=0x04000000
112 --- /dev/null
113 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
114 @@ -0,0 +1,1921 @@
115 +// SPDX-License-Identifier: GPL-2.0
116 +/*
117 + * Broadcom BM2835 V4L2 driver
118 + *
119 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
120 + *
121 + * Authors: Vincent Sanders @ Collabora
122 + * Dave Stevenson @ Broadcom
123 + * (now dave.stevenson@raspberrypi.org)
124 + * Simon Mellor @ Broadcom
125 + * Luke Diamand @ Broadcom
126 + *
127 + * V4L2 driver MMAL vchiq interface code
128 + */
129 +
130 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
131 +
132 +#include <linux/errno.h>
133 +#include <linux/kernel.h>
134 +#include <linux/module.h>
135 +#include <linux/mutex.h>
136 +#include <linux/mm.h>
137 +#include <linux/slab.h>
138 +#include <linux/completion.h>
139 +#include <linux/vmalloc.h>
140 +#include <asm/cacheflush.h>
141 +#include <media/videobuf2-vmalloc.h>
142 +
143 +#include "mmal-common.h"
144 +#include "mmal-vchiq.h"
145 +#include "mmal-msg.h"
146 +
147 +#define USE_VCHIQ_ARM
148 +#include "interface/vchi/vchi.h"
149 +
150 +MODULE_DESCRIPTION("BCM2835 MMAL VCHIQ interface");
151 +MODULE_AUTHOR("Dave Stevenson, <dave.stevenson@raspberrypi.org>");
152 +MODULE_LICENSE("GPL");
153 +MODULE_VERSION("0.0.1");
154 +
155 +/* maximum number of components supported */
156 +#define VCHIQ_MMAL_MAX_COMPONENTS 4
157 +
158 +/*#define FULL_MSG_DUMP 1*/
159 +
160 +#ifdef DEBUG
161 +static const char *const msg_type_names[] = {
162 + "UNKNOWN",
163 + "QUIT",
164 + "SERVICE_CLOSED",
165 + "GET_VERSION",
166 + "COMPONENT_CREATE",
167 + "COMPONENT_DESTROY",
168 + "COMPONENT_ENABLE",
169 + "COMPONENT_DISABLE",
170 + "PORT_INFO_GET",
171 + "PORT_INFO_SET",
172 + "PORT_ACTION",
173 + "BUFFER_FROM_HOST",
174 + "BUFFER_TO_HOST",
175 + "GET_STATS",
176 + "PORT_PARAMETER_SET",
177 + "PORT_PARAMETER_GET",
178 + "EVENT_TO_HOST",
179 + "GET_CORE_STATS_FOR_PORT",
180 + "OPAQUE_ALLOCATOR",
181 + "CONSUME_MEM",
182 + "LMK",
183 + "OPAQUE_ALLOCATOR_DESC",
184 + "DRM_GET_LHS32",
185 + "DRM_GET_TIME",
186 + "BUFFER_FROM_HOST_ZEROLEN",
187 + "PORT_FLUSH",
188 + "HOST_LOG",
189 +};
190 +#endif
191 +
192 +static const char *const port_action_type_names[] = {
193 + "UNKNOWN",
194 + "ENABLE",
195 + "DISABLE",
196 + "FLUSH",
197 + "CONNECT",
198 + "DISCONNECT",
199 + "SET_REQUIREMENTS",
200 +};
201 +
202 +#if defined(DEBUG)
203 +#if defined(FULL_MSG_DUMP)
204 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
205 + do { \
206 + pr_debug(TITLE" type:%s(%d) length:%d\n", \
207 + msg_type_names[(MSG)->h.type], \
208 + (MSG)->h.type, (MSG_LEN)); \
209 + print_hex_dump(KERN_DEBUG, "<<h: ", DUMP_PREFIX_OFFSET, \
210 + 16, 4, (MSG), \
211 + sizeof(struct mmal_msg_header), 1); \
212 + print_hex_dump(KERN_DEBUG, "<<p: ", DUMP_PREFIX_OFFSET, \
213 + 16, 4, \
214 + ((u8 *)(MSG)) + sizeof(struct mmal_msg_header),\
215 + (MSG_LEN) - sizeof(struct mmal_msg_header), 1); \
216 + } while (0)
217 +#else
218 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
219 + { \
220 + pr_debug(TITLE" type:%s(%d) length:%d\n", \
221 + msg_type_names[(MSG)->h.type], \
222 + (MSG)->h.type, (MSG_LEN)); \
223 + }
224 +#endif
225 +#else
226 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE)
227 +#endif
228 +
229 +struct vchiq_mmal_instance;
230 +
231 +/* normal message context */
232 +struct mmal_msg_context {
233 + struct vchiq_mmal_instance *instance;
234 +
235 + /* Index in the context_map idr so that we can find the
236 + * mmal_msg_context again when servicing the VCHI reply.
237 + */
238 + int handle;
239 +
240 + union {
241 + struct {
242 + /* work struct for buffer_cb callback */
243 + struct work_struct work;
244 + /* work struct for deferred callback */
245 + struct work_struct buffer_to_host_work;
246 + /* mmal instance */
247 + struct vchiq_mmal_instance *instance;
248 + /* mmal port */
249 + struct vchiq_mmal_port *port;
250 + /* actual buffer used to store bulk reply */
251 + struct mmal_buffer *buffer;
252 + /* amount of buffer used */
253 + unsigned long buffer_used;
254 + /* MMAL buffer flags */
255 + u32 mmal_flags;
256 + /* Presentation and Decode timestamps */
257 + s64 pts;
258 + s64 dts;
259 +
260 + int status; /* context status */
261 +
262 + } bulk; /* bulk data */
263 +
264 + struct {
265 + /* message handle to release */
266 + VCHI_HELD_MSG_T msg_handle;
267 + /* pointer to received message */
268 + struct mmal_msg *msg;
269 + /* received message length */
270 + u32 msg_len;
271 + /* completion upon reply */
272 + struct completion cmplt;
273 + } sync; /* synchronous response */
274 + } u;
275 +
276 +};
277 +
278 +struct vchiq_mmal_instance {
279 + VCHI_SERVICE_HANDLE_T handle;
280 +
281 + /* ensure serialised access to service */
282 + struct mutex vchiq_mutex;
283 +
284 + /* vmalloc page to receive scratch bulk xfers into */
285 + void *bulk_scratch;
286 +
287 + struct idr context_map;
288 + /* protect accesses to context_map */
289 + struct mutex context_map_lock;
290 +
291 + /* component to use next */
292 + int component_idx;
293 + struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
294 +
295 + /* ordered workqueue to process all bulk operations */
296 + struct workqueue_struct *bulk_wq;
297 +};
298 +
299 +static struct mmal_msg_context *
300 +get_msg_context(struct vchiq_mmal_instance *instance)
301 +{
302 + struct mmal_msg_context *msg_context;
303 + int handle;
304 +
305 + /* todo: should this be allocated from a pool to avoid kzalloc */
306 + msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
307 +
308 + if (!msg_context)
309 + return ERR_PTR(-ENOMEM);
310 +
311 + /* Create an ID that will be passed along with our message so
312 + * that when we service the VCHI reply, we can look up what
313 + * message is being replied to.
314 + */
315 + mutex_lock(&instance->context_map_lock);
316 + handle = idr_alloc(&instance->context_map, msg_context,
317 + 0, 0, GFP_KERNEL);
318 + mutex_unlock(&instance->context_map_lock);
319 +
320 + if (handle < 0) {
321 + kfree(msg_context);
322 + return ERR_PTR(handle);
323 + }
324 +
325 + msg_context->instance = instance;
326 + msg_context->handle = handle;
327 +
328 + return msg_context;
329 +}
330 +
331 +static struct mmal_msg_context *
332 +lookup_msg_context(struct vchiq_mmal_instance *instance, int handle)
333 +{
334 + return idr_find(&instance->context_map, handle);
335 +}
336 +
337 +static void
338 +release_msg_context(struct mmal_msg_context *msg_context)
339 +{
340 + struct vchiq_mmal_instance *instance = msg_context->instance;
341 +
342 + mutex_lock(&instance->context_map_lock);
343 + idr_remove(&instance->context_map, msg_context->handle);
344 + mutex_unlock(&instance->context_map_lock);
345 + kfree(msg_context);
346 +}
347 +
348 +/* deals with receipt of event to host message */
349 +static void event_to_host_cb(struct vchiq_mmal_instance *instance,
350 + struct mmal_msg *msg, u32 msg_len)
351 +{
352 + pr_debug("unhandled event\n");
353 + pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n",
354 + msg->u.event_to_host.client_component,
355 + msg->u.event_to_host.port_type,
356 + msg->u.event_to_host.port_num,
357 + msg->u.event_to_host.cmd, msg->u.event_to_host.length);
358 +}
359 +
360 +/* workqueue scheduled callback
361 + *
362 + * we do this because it is important we do not call any other vchiq
363 + * sync calls from witin the message delivery thread
364 + */
365 +static void buffer_work_cb(struct work_struct *work)
366 +{
367 + struct mmal_msg_context *msg_context =
368 + container_of(work, struct mmal_msg_context, u.bulk.work);
369 +
370 + atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu);
371 +
372 + msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
373 + msg_context->u.bulk.port,
374 + msg_context->u.bulk.status,
375 + msg_context->u.bulk.buffer,
376 + msg_context->u.bulk.buffer_used,
377 + msg_context->u.bulk.mmal_flags,
378 + msg_context->u.bulk.dts,
379 + msg_context->u.bulk.pts);
380 +}
381 +
382 +/* workqueue scheduled callback to handle receiving buffers
383 + *
384 + * VCHI will allow up to 4 bulk receives to be scheduled before blocking.
385 + * If we block in the service_callback context then we can't process the
386 + * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked
387 + * vchi_bulk_queue_receive() call to complete.
388 + */
389 +static void buffer_to_host_work_cb(struct work_struct *work)
390 +{
391 + struct mmal_msg_context *msg_context =
392 + container_of(work, struct mmal_msg_context,
393 + u.bulk.buffer_to_host_work);
394 + struct vchiq_mmal_instance *instance = msg_context->instance;
395 + unsigned long len = msg_context->u.bulk.buffer_used;
396 + int ret;
397 +
398 + if (!len)
399 + /* Dummy receive to ensure the buffers remain in order */
400 + len = 8;
401 + /* queue the bulk submission */
402 + vchi_service_use(instance->handle);
403 + ret = vchi_bulk_queue_receive(instance->handle,
404 + msg_context->u.bulk.buffer->buffer,
405 + /* Actual receive needs to be a multiple
406 + * of 4 bytes
407 + */
408 + (len + 3) & ~3,
409 + VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE |
410 + VCHI_FLAGS_BLOCK_UNTIL_QUEUED,
411 + msg_context);
412 +
413 + vchi_service_release(instance->handle);
414 +
415 + if (ret != 0)
416 + pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n",
417 + __func__, msg_context, ret);
418 +}
419 +
420 +/* enqueue a bulk receive for a given message context */
421 +static int bulk_receive(struct vchiq_mmal_instance *instance,
422 + struct mmal_msg *msg,
423 + struct mmal_msg_context *msg_context)
424 +{
425 + unsigned long rd_len;
426 +
427 + rd_len = msg->u.buffer_from_host.buffer_header.length;
428 +
429 + if (!msg_context->u.bulk.buffer) {
430 + pr_err("bulk.buffer not configured - error in buffer_from_host\n");
431 +
432 + /* todo: this is a serious error, we should never have
433 + * committed a buffer_to_host operation to the mmal
434 + * port without the buffer to back it up (underflow
435 + * handling) and there is no obvious way to deal with
436 + * this - how is the mmal servie going to react when
437 + * we fail to do the xfer and reschedule a buffer when
438 + * it arrives? perhaps a starved flag to indicate a
439 + * waiting bulk receive?
440 + */
441 +
442 + return -EINVAL;
443 + }
444 +
445 + /* ensure we do not overrun the available buffer */
446 + if (rd_len > msg_context->u.bulk.buffer->buffer_size) {
447 + rd_len = msg_context->u.bulk.buffer->buffer_size;
448 + pr_warn("short read as not enough receive buffer space\n");
449 + /* todo: is this the correct response, what happens to
450 + * the rest of the message data?
451 + */
452 + }
453 +
454 + /* store length */
455 + msg_context->u.bulk.buffer_used = rd_len;
456 + msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts;
457 + msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts;
458 +
459 + queue_work(msg_context->instance->bulk_wq,
460 + &msg_context->u.bulk.buffer_to_host_work);
461 +
462 + return 0;
463 +}
464 +
465 +/* data in message, memcpy from packet into output buffer */
466 +static int inline_receive(struct vchiq_mmal_instance *instance,
467 + struct mmal_msg *msg,
468 + struct mmal_msg_context *msg_context)
469 +{
470 + memcpy(msg_context->u.bulk.buffer->buffer,
471 + msg->u.buffer_from_host.short_data,
472 + msg->u.buffer_from_host.payload_in_message);
473 +
474 + msg_context->u.bulk.buffer_used =
475 + msg->u.buffer_from_host.payload_in_message;
476 +
477 + return 0;
478 +}
479 +
480 +/* queue the buffer availability with MMAL_MSG_TYPE_BUFFER_FROM_HOST */
481 +static int
482 +buffer_from_host(struct vchiq_mmal_instance *instance,
483 + struct vchiq_mmal_port *port, struct mmal_buffer *buf)
484 +{
485 + struct mmal_msg_context *msg_context;
486 + struct mmal_msg m;
487 + int ret;
488 +
489 + if (!port->enabled)
490 + return -EINVAL;
491 +
492 + pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
493 +
494 + /* get context */
495 + if (!buf->msg_context) {
496 + pr_err("%s: msg_context not allocated, buf %p\n", __func__,
497 + buf);
498 + return -EINVAL;
499 + }
500 + msg_context = buf->msg_context;
501 +
502 + /* store bulk message context for when data arrives */
503 + msg_context->u.bulk.instance = instance;
504 + msg_context->u.bulk.port = port;
505 + msg_context->u.bulk.buffer = buf;
506 + msg_context->u.bulk.buffer_used = 0;
507 +
508 + /* initialise work structure ready to schedule callback */
509 + INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb);
510 + INIT_WORK(&msg_context->u.bulk.buffer_to_host_work,
511 + buffer_to_host_work_cb);
512 +
513 + atomic_inc(&port->buffers_with_vpu);
514 +
515 + /* prep the buffer from host message */
516 + memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */
517 +
518 + m.h.type = MMAL_MSG_TYPE_BUFFER_FROM_HOST;
519 + m.h.magic = MMAL_MAGIC;
520 + m.h.context = msg_context->handle;
521 + m.h.status = 0;
522 +
523 + /* drvbuf is our private data passed back */
524 + m.u.buffer_from_host.drvbuf.magic = MMAL_MAGIC;
525 + m.u.buffer_from_host.drvbuf.component_handle = port->component->handle;
526 + m.u.buffer_from_host.drvbuf.port_handle = port->handle;
527 + m.u.buffer_from_host.drvbuf.client_context = msg_context->handle;
528 +
529 + /* buffer header */
530 + m.u.buffer_from_host.buffer_header.cmd = 0;
531 + m.u.buffer_from_host.buffer_header.data =
532 + (u32)(unsigned long)buf->buffer;
533 + m.u.buffer_from_host.buffer_header.alloc_size = buf->buffer_size;
534 + m.u.buffer_from_host.buffer_header.length = 0; /* nothing used yet */
535 + m.u.buffer_from_host.buffer_header.offset = 0; /* no offset */
536 + m.u.buffer_from_host.buffer_header.flags = 0; /* no flags */
537 + m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN;
538 + m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN;
539 +
540 + /* clear buffer type sepecific data */
541 + memset(&m.u.buffer_from_host.buffer_header_type_specific, 0,
542 + sizeof(m.u.buffer_from_host.buffer_header_type_specific));
543 +
544 + /* no payload in message */
545 + m.u.buffer_from_host.payload_in_message = 0;
546 +
547 + vchi_service_use(instance->handle);
548 +
549 + ret = vchi_queue_kernel_message(instance->handle,
550 + &m,
551 + sizeof(struct mmal_msg_header) +
552 + sizeof(m.u.buffer_from_host));
553 +
554 + vchi_service_release(instance->handle);
555 +
556 + return ret;
557 +}
558 +
559 +/* deals with receipt of buffer to host message */
560 +static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
561 + struct mmal_msg *msg, u32 msg_len)
562 +{
563 + struct mmal_msg_context *msg_context;
564 + u32 handle;
565 +
566 + pr_debug("%s: instance:%p msg:%p msg_len:%d\n",
567 + __func__, instance, msg, msg_len);
568 +
569 + if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) {
570 + handle = msg->u.buffer_from_host.drvbuf.client_context;
571 + msg_context = lookup_msg_context(instance, handle);
572 +
573 + if (!msg_context) {
574 + pr_err("drvbuf.client_context(%u) is invalid\n",
575 + handle);
576 + return;
577 + }
578 + } else {
579 + pr_err("MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n");
580 + return;
581 + }
582 +
583 + msg_context->u.bulk.mmal_flags =
584 + msg->u.buffer_from_host.buffer_header.flags;
585 +
586 + if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) {
587 + /* message reception had an error */
588 + pr_warn("error %d in reply\n", msg->h.status);
589 +
590 + msg_context->u.bulk.status = msg->h.status;
591 +
592 + } else if (msg->u.buffer_from_host.buffer_header.length == 0) {
593 + /* empty buffer */
594 + if (msg->u.buffer_from_host.buffer_header.flags &
595 + MMAL_BUFFER_HEADER_FLAG_EOS) {
596 + msg_context->u.bulk.status =
597 + bulk_receive(instance, msg, msg_context);
598 + if (msg_context->u.bulk.status == 0)
599 + return; /* successful bulk submission, bulk
600 + * completion will trigger callback
601 + */
602 + } else {
603 + /* do callback with empty buffer - not EOS though */
604 + msg_context->u.bulk.status = 0;
605 + msg_context->u.bulk.buffer_used = 0;
606 + }
607 + } else if (msg->u.buffer_from_host.payload_in_message == 0) {
608 + /* data is not in message, queue a bulk receive */
609 + msg_context->u.bulk.status =
610 + bulk_receive(instance, msg, msg_context);
611 + if (msg_context->u.bulk.status == 0)
612 + return; /* successful bulk submission, bulk
613 + * completion will trigger callback
614 + */
615 +
616 + /* failed to submit buffer, this will end badly */
617 + pr_err("error %d on bulk submission\n",
618 + msg_context->u.bulk.status);
619 +
620 + } else if (msg->u.buffer_from_host.payload_in_message <=
621 + MMAL_VC_SHORT_DATA) {
622 + /* data payload within message */
623 + msg_context->u.bulk.status = inline_receive(instance, msg,
624 + msg_context);
625 + } else {
626 + pr_err("message with invalid short payload\n");
627 +
628 + /* signal error */
629 + msg_context->u.bulk.status = -EINVAL;
630 + msg_context->u.bulk.buffer_used =
631 + msg->u.buffer_from_host.payload_in_message;
632 + }
633 +
634 + /* schedule the port callback */
635 + schedule_work(&msg_context->u.bulk.work);
636 +}
637 +
638 +static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
639 + struct mmal_msg_context *msg_context)
640 +{
641 + msg_context->u.bulk.status = 0;
642 +
643 + /* schedule the port callback */
644 + schedule_work(&msg_context->u.bulk.work);
645 +}
646 +
647 +static void bulk_abort_cb(struct vchiq_mmal_instance *instance,
648 + struct mmal_msg_context *msg_context)
649 +{
650 + pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
651 +
652 + msg_context->u.bulk.status = -EINTR;
653 +
654 + schedule_work(&msg_context->u.bulk.work);
655 +}
656 +
657 +/* incoming event service callback */
658 +static void service_callback(void *param,
659 + const VCHI_CALLBACK_REASON_T reason,
660 + void *bulk_ctx)
661 +{
662 + struct vchiq_mmal_instance *instance = param;
663 + int status;
664 + u32 msg_len;
665 + struct mmal_msg *msg;
666 + VCHI_HELD_MSG_T msg_handle;
667 + struct mmal_msg_context *msg_context;
668 +
669 + if (!instance) {
670 + pr_err("Message callback passed NULL instance\n");
671 + return;
672 + }
673 +
674 + switch (reason) {
675 + case VCHI_CALLBACK_MSG_AVAILABLE:
676 + status = vchi_msg_hold(instance->handle, (void **)&msg,
677 + &msg_len, VCHI_FLAGS_NONE, &msg_handle);
678 + if (status) {
679 + pr_err("Unable to dequeue a message (%d)\n", status);
680 + break;
681 + }
682 +
683 + DBG_DUMP_MSG(msg, msg_len, "<<< reply message");
684 +
685 + /* handling is different for buffer messages */
686 + switch (msg->h.type) {
687 + case MMAL_MSG_TYPE_BUFFER_FROM_HOST:
688 + vchi_held_msg_release(&msg_handle);
689 + break;
690 +
691 + case MMAL_MSG_TYPE_EVENT_TO_HOST:
692 + event_to_host_cb(instance, msg, msg_len);
693 + vchi_held_msg_release(&msg_handle);
694 +
695 + break;
696 +
697 + case MMAL_MSG_TYPE_BUFFER_TO_HOST:
698 + buffer_to_host_cb(instance, msg, msg_len);
699 + vchi_held_msg_release(&msg_handle);
700 + break;
701 +
702 + default:
703 + /* messages dependent on header context to complete */
704 + if (!msg->h.context) {
705 + pr_err("received message context was null!\n");
706 + vchi_held_msg_release(&msg_handle);
707 + break;
708 + }
709 +
710 + msg_context = lookup_msg_context(instance,
711 + msg->h.context);
712 + if (!msg_context) {
713 + pr_err("received invalid message context %u!\n",
714 + msg->h.context);
715 + vchi_held_msg_release(&msg_handle);
716 + break;
717 + }
718 +
719 + /* fill in context values */
720 + msg_context->u.sync.msg_handle = msg_handle;
721 + msg_context->u.sync.msg = msg;
722 + msg_context->u.sync.msg_len = msg_len;
723 +
724 + /* todo: should this check (completion_done()
725 + * == 1) for no one waiting? or do we need a
726 + * flag to tell us the completion has been
727 + * interrupted so we can free the message and
728 + * its context. This probably also solves the
729 + * message arriving after interruption todo
730 + * below
731 + */
732 +
733 + /* complete message so caller knows it happened */
734 + complete(&msg_context->u.sync.cmplt);
735 + break;
736 + }
737 +
738 + break;
739 +
740 + case VCHI_CALLBACK_BULK_RECEIVED:
741 + bulk_receive_cb(instance, bulk_ctx);
742 + break;
743 +
744 + case VCHI_CALLBACK_BULK_RECEIVE_ABORTED:
745 + bulk_abort_cb(instance, bulk_ctx);
746 + break;
747 +
748 + case VCHI_CALLBACK_SERVICE_CLOSED:
749 + /* TODO: consider if this requires action if received when
750 + * driver is not explicitly closing the service
751 + */
752 + break;
753 +
754 + default:
755 + pr_err("Received unhandled message reason %d\n", reason);
756 + break;
757 + }
758 +}
759 +
760 +static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
761 + struct mmal_msg *msg,
762 + unsigned int payload_len,
763 + struct mmal_msg **msg_out,
764 + VCHI_HELD_MSG_T *msg_handle_out)
765 +{
766 + struct mmal_msg_context *msg_context;
767 + int ret;
768 + unsigned long timeout;
769 +
770 + /* payload size must not cause message to exceed max size */
771 + if (payload_len >
772 + (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) {
773 + pr_err("payload length %d exceeds max:%d\n", payload_len,
774 + (int)(MMAL_MSG_MAX_SIZE -
775 + sizeof(struct mmal_msg_header)));
776 + return -EINVAL;
777 + }
778 +
779 + msg_context = get_msg_context(instance);
780 + if (IS_ERR(msg_context))
781 + return PTR_ERR(msg_context);
782 +
783 + init_completion(&msg_context->u.sync.cmplt);
784 +
785 + msg->h.magic = MMAL_MAGIC;
786 + msg->h.context = msg_context->handle;
787 + msg->h.status = 0;
788 +
789 + DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len),
790 + ">>> sync message");
791 +
792 + vchi_service_use(instance->handle);
793 +
794 + ret = vchi_queue_kernel_message(instance->handle,
795 + msg,
796 + sizeof(struct mmal_msg_header) +
797 + payload_len);
798 +
799 + vchi_service_release(instance->handle);
800 +
801 + if (ret) {
802 + pr_err("error %d queuing message\n", ret);
803 + release_msg_context(msg_context);
804 + return ret;
805 + }
806 +
807 + timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt,
808 + 3 * HZ);
809 + if (timeout == 0) {
810 + pr_err("timed out waiting for sync completion\n");
811 + ret = -ETIME;
812 + /* todo: what happens if the message arrives after aborting */
813 + release_msg_context(msg_context);
814 + return ret;
815 + }
816 +
817 + *msg_out = msg_context->u.sync.msg;
818 + *msg_handle_out = msg_context->u.sync.msg_handle;
819 + release_msg_context(msg_context);
820 +
821 + return 0;
822 +}
823 +
824 +static void dump_port_info(struct vchiq_mmal_port *port)
825 +{
826 + pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled);
827 +
828 + pr_debug("buffer minimum num:%d size:%d align:%d\n",
829 + port->minimum_buffer.num,
830 + port->minimum_buffer.size, port->minimum_buffer.alignment);
831 +
832 + pr_debug("buffer recommended num:%d size:%d align:%d\n",
833 + port->recommended_buffer.num,
834 + port->recommended_buffer.size,
835 + port->recommended_buffer.alignment);
836 +
837 + pr_debug("buffer current values num:%d size:%d align:%d\n",
838 + port->current_buffer.num,
839 + port->current_buffer.size, port->current_buffer.alignment);
840 +
841 + pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n",
842 + port->format.type,
843 + port->format.encoding, port->format.encoding_variant);
844 +
845 + pr_debug(" bitrate:%d flags:0x%x\n",
846 + port->format.bitrate, port->format.flags);
847 +
848 + if (port->format.type == MMAL_ES_TYPE_VIDEO) {
849 + pr_debug
850 + ("es video format: width:%d height:%d colourspace:0x%x\n",
851 + port->es.video.width, port->es.video.height,
852 + port->es.video.color_space);
853 +
854 + pr_debug(" : crop xywh %d,%d,%d,%d\n",
855 + port->es.video.crop.x,
856 + port->es.video.crop.y,
857 + port->es.video.crop.width, port->es.video.crop.height);
858 + pr_debug(" : framerate %d/%d aspect %d/%d\n",
859 + port->es.video.frame_rate.num,
860 + port->es.video.frame_rate.den,
861 + port->es.video.par.num, port->es.video.par.den);
862 + }
863 +}
864 +
865 +static void port_to_mmal_msg(struct vchiq_mmal_port *port, struct mmal_port *p)
866 +{
867 + /* todo do readonly fields need setting at all? */
868 + p->type = port->type;
869 + p->index = port->index;
870 + p->index_all = 0;
871 + p->is_enabled = port->enabled;
872 + p->buffer_num_min = port->minimum_buffer.num;
873 + p->buffer_size_min = port->minimum_buffer.size;
874 + p->buffer_alignment_min = port->minimum_buffer.alignment;
875 + p->buffer_num_recommended = port->recommended_buffer.num;
876 + p->buffer_size_recommended = port->recommended_buffer.size;
877 +
878 + /* only three writable fields in a port */
879 + p->buffer_num = port->current_buffer.num;
880 + p->buffer_size = port->current_buffer.size;
881 + p->userdata = (u32)(unsigned long)port;
882 +}
883 +
884 +static int port_info_set(struct vchiq_mmal_instance *instance,
885 + struct vchiq_mmal_port *port)
886 +{
887 + int ret;
888 + struct mmal_msg m;
889 + struct mmal_msg *rmsg;
890 + VCHI_HELD_MSG_T rmsg_handle;
891 +
892 + pr_debug("setting port info port %p\n", port);
893 + if (!port)
894 + return -1;
895 + dump_port_info(port);
896 +
897 + m.h.type = MMAL_MSG_TYPE_PORT_INFO_SET;
898 +
899 + m.u.port_info_set.component_handle = port->component->handle;
900 + m.u.port_info_set.port_type = port->type;
901 + m.u.port_info_set.port_index = port->index;
902 +
903 + port_to_mmal_msg(port, &m.u.port_info_set.port);
904 +
905 + /* elementary stream format setup */
906 + m.u.port_info_set.format.type = port->format.type;
907 + m.u.port_info_set.format.encoding = port->format.encoding;
908 + m.u.port_info_set.format.encoding_variant =
909 + port->format.encoding_variant;
910 + m.u.port_info_set.format.bitrate = port->format.bitrate;
911 + m.u.port_info_set.format.flags = port->format.flags;
912 +
913 + memcpy(&m.u.port_info_set.es, &port->es,
914 + sizeof(union mmal_es_specific_format));
915 +
916 + m.u.port_info_set.format.extradata_size = port->format.extradata_size;
917 + memcpy(&m.u.port_info_set.extradata, port->format.extradata,
918 + port->format.extradata_size);
919 +
920 + ret = send_synchronous_mmal_msg(instance, &m,
921 + sizeof(m.u.port_info_set),
922 + &rmsg, &rmsg_handle);
923 + if (ret)
924 + return ret;
925 +
926 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_SET) {
927 + /* got an unexpected message type in reply */
928 + ret = -EINVAL;
929 + goto release_msg;
930 + }
931 +
932 + /* return operation status */
933 + ret = -rmsg->u.port_info_get_reply.status;
934 +
935 + pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret,
936 + port->component->handle, port->handle);
937 +
938 +release_msg:
939 + vchi_held_msg_release(&rmsg_handle);
940 +
941 + return ret;
942 +}
943 +
944 +/* use port info get message to retrieve port information */
945 +static int port_info_get(struct vchiq_mmal_instance *instance,
946 + struct vchiq_mmal_port *port)
947 +{
948 + int ret;
949 + struct mmal_msg m;
950 + struct mmal_msg *rmsg;
951 + VCHI_HELD_MSG_T rmsg_handle;
952 +
953 + /* port info time */
954 + m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET;
955 + m.u.port_info_get.component_handle = port->component->handle;
956 + m.u.port_info_get.port_type = port->type;
957 + m.u.port_info_get.index = port->index;
958 +
959 + ret = send_synchronous_mmal_msg(instance, &m,
960 + sizeof(m.u.port_info_get),
961 + &rmsg, &rmsg_handle);
962 + if (ret)
963 + return ret;
964 +
965 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_GET) {
966 + /* got an unexpected message type in reply */
967 + ret = -EINVAL;
968 + goto release_msg;
969 + }
970 +
971 + /* return operation status */
972 + ret = -rmsg->u.port_info_get_reply.status;
973 + if (ret != MMAL_MSG_STATUS_SUCCESS)
974 + goto release_msg;
975 +
976 + if (rmsg->u.port_info_get_reply.port.is_enabled == 0)
977 + port->enabled = false;
978 + else
979 + port->enabled = true;
980 +
981 + /* copy the values out of the message */
982 + port->handle = rmsg->u.port_info_get_reply.port_handle;
983 +
984 + /* port type and index cached to use on port info set because
985 + * it does not use a port handle
986 + */
987 + port->type = rmsg->u.port_info_get_reply.port_type;
988 + port->index = rmsg->u.port_info_get_reply.port_index;
989 +
990 + port->minimum_buffer.num =
991 + rmsg->u.port_info_get_reply.port.buffer_num_min;
992 + port->minimum_buffer.size =
993 + rmsg->u.port_info_get_reply.port.buffer_size_min;
994 + port->minimum_buffer.alignment =
995 + rmsg->u.port_info_get_reply.port.buffer_alignment_min;
996 +
997 + port->recommended_buffer.alignment =
998 + rmsg->u.port_info_get_reply.port.buffer_alignment_min;
999 + port->recommended_buffer.num =
1000 + rmsg->u.port_info_get_reply.port.buffer_num_recommended;
1001 +
1002 + port->current_buffer.num = rmsg->u.port_info_get_reply.port.buffer_num;
1003 + port->current_buffer.size =
1004 + rmsg->u.port_info_get_reply.port.buffer_size;
1005 +
1006 + /* stream format */
1007 + port->format.type = rmsg->u.port_info_get_reply.format.type;
1008 + port->format.encoding = rmsg->u.port_info_get_reply.format.encoding;
1009 + port->format.encoding_variant =
1010 + rmsg->u.port_info_get_reply.format.encoding_variant;
1011 + port->format.bitrate = rmsg->u.port_info_get_reply.format.bitrate;
1012 + port->format.flags = rmsg->u.port_info_get_reply.format.flags;
1013 +
1014 + /* elementary stream format */
1015 + memcpy(&port->es,
1016 + &rmsg->u.port_info_get_reply.es,
1017 + sizeof(union mmal_es_specific_format));
1018 + port->format.es = &port->es;
1019 +
1020 + port->format.extradata_size =
1021 + rmsg->u.port_info_get_reply.format.extradata_size;
1022 + memcpy(port->format.extradata,
1023 + rmsg->u.port_info_get_reply.extradata,
1024 + port->format.extradata_size);
1025 +
1026 + pr_debug("received port info\n");
1027 + dump_port_info(port);
1028 +
1029 +release_msg:
1030 +
1031 + pr_debug("%s:result:%d component:0x%x port:%d\n",
1032 + __func__, ret, port->component->handle, port->handle);
1033 +
1034 + vchi_held_msg_release(&rmsg_handle);
1035 +
1036 + return ret;
1037 +}
1038 +
1039 +/* create comonent on vc */
1040 +static int create_component(struct vchiq_mmal_instance *instance,
1041 + struct vchiq_mmal_component *component,
1042 + const char *name)
1043 +{
1044 + int ret;
1045 + struct mmal_msg m;
1046 + struct mmal_msg *rmsg;
1047 + VCHI_HELD_MSG_T rmsg_handle;
1048 +
1049 + /* build component create message */
1050 + m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE;
1051 + m.u.component_create.client_component = (u32)(unsigned long)component;
1052 + strncpy(m.u.component_create.name, name,
1053 + sizeof(m.u.component_create.name));
1054 +
1055 + ret = send_synchronous_mmal_msg(instance, &m,
1056 + sizeof(m.u.component_create),
1057 + &rmsg, &rmsg_handle);
1058 + if (ret)
1059 + return ret;
1060 +
1061 + if (rmsg->h.type != m.h.type) {
1062 + /* got an unexpected message type in reply */
1063 + ret = -EINVAL;
1064 + goto release_msg;
1065 + }
1066 +
1067 + ret = -rmsg->u.component_create_reply.status;
1068 + if (ret != MMAL_MSG_STATUS_SUCCESS)
1069 + goto release_msg;
1070 +
1071 + /* a valid component response received */
1072 + component->handle = rmsg->u.component_create_reply.component_handle;
1073 + component->inputs = rmsg->u.component_create_reply.input_num;
1074 + component->outputs = rmsg->u.component_create_reply.output_num;
1075 + component->clocks = rmsg->u.component_create_reply.clock_num;
1076 +
1077 + pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n",
1078 + component->handle,
1079 + component->inputs, component->outputs, component->clocks);
1080 +
1081 +release_msg:
1082 + vchi_held_msg_release(&rmsg_handle);
1083 +
1084 + return ret;
1085 +}
1086 +
1087 +/* destroys a component on vc */
1088 +static int destroy_component(struct vchiq_mmal_instance *instance,
1089 + struct vchiq_mmal_component *component)
1090 +{
1091 + int ret;
1092 + struct mmal_msg m;
1093 + struct mmal_msg *rmsg;
1094 + VCHI_HELD_MSG_T rmsg_handle;
1095 +
1096 + m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY;
1097 + m.u.component_destroy.component_handle = component->handle;
1098 +
1099 + ret = send_synchronous_mmal_msg(instance, &m,
1100 + sizeof(m.u.component_destroy),
1101 + &rmsg, &rmsg_handle);
1102 + if (ret)
1103 + return ret;
1104 +
1105 + if (rmsg->h.type != m.h.type) {
1106 + /* got an unexpected message type in reply */
1107 + ret = -EINVAL;
1108 + goto release_msg;
1109 + }
1110 +
1111 + ret = -rmsg->u.component_destroy_reply.status;
1112 +
1113 +release_msg:
1114 +
1115 + vchi_held_msg_release(&rmsg_handle);
1116 +
1117 + return ret;
1118 +}
1119 +
1120 +/* enable a component on vc */
1121 +static int enable_component(struct vchiq_mmal_instance *instance,
1122 + struct vchiq_mmal_component *component)
1123 +{
1124 + int ret;
1125 + struct mmal_msg m;
1126 + struct mmal_msg *rmsg;
1127 + VCHI_HELD_MSG_T rmsg_handle;
1128 +
1129 + m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE;
1130 + m.u.component_enable.component_handle = component->handle;
1131 +
1132 + ret = send_synchronous_mmal_msg(instance, &m,
1133 + sizeof(m.u.component_enable),
1134 + &rmsg, &rmsg_handle);
1135 + if (ret)
1136 + return ret;
1137 +
1138 + if (rmsg->h.type != m.h.type) {
1139 + /* got an unexpected message type in reply */
1140 + ret = -EINVAL;
1141 + goto release_msg;
1142 + }
1143 +
1144 + ret = -rmsg->u.component_enable_reply.status;
1145 +
1146 +release_msg:
1147 + vchi_held_msg_release(&rmsg_handle);
1148 +
1149 + return ret;
1150 +}
1151 +
1152 +/* disable a component on vc */
1153 +static int disable_component(struct vchiq_mmal_instance *instance,
1154 + struct vchiq_mmal_component *component)
1155 +{
1156 + int ret;
1157 + struct mmal_msg m;
1158 + struct mmal_msg *rmsg;
1159 + VCHI_HELD_MSG_T rmsg_handle;
1160 +
1161 + m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE;
1162 + m.u.component_disable.component_handle = component->handle;
1163 +
1164 + ret = send_synchronous_mmal_msg(instance, &m,
1165 + sizeof(m.u.component_disable),
1166 + &rmsg, &rmsg_handle);
1167 + if (ret)
1168 + return ret;
1169 +
1170 + if (rmsg->h.type != m.h.type) {
1171 + /* got an unexpected message type in reply */
1172 + ret = -EINVAL;
1173 + goto release_msg;
1174 + }
1175 +
1176 + ret = -rmsg->u.component_disable_reply.status;
1177 +
1178 +release_msg:
1179 +
1180 + vchi_held_msg_release(&rmsg_handle);
1181 +
1182 + return ret;
1183 +}
1184 +
1185 +/* get version of mmal implementation */
1186 +static int get_version(struct vchiq_mmal_instance *instance,
1187 + u32 *major_out, u32 *minor_out)
1188 +{
1189 + int ret;
1190 + struct mmal_msg m;
1191 + struct mmal_msg *rmsg;
1192 + VCHI_HELD_MSG_T rmsg_handle;
1193 +
1194 + m.h.type = MMAL_MSG_TYPE_GET_VERSION;
1195 +
1196 + ret = send_synchronous_mmal_msg(instance, &m,
1197 + sizeof(m.u.version),
1198 + &rmsg, &rmsg_handle);
1199 + if (ret)
1200 + return ret;
1201 +
1202 + if (rmsg->h.type != m.h.type) {
1203 + /* got an unexpected message type in reply */
1204 + ret = -EINVAL;
1205 + goto release_msg;
1206 + }
1207 +
1208 + *major_out = rmsg->u.version.major;
1209 + *minor_out = rmsg->u.version.minor;
1210 +
1211 +release_msg:
1212 + vchi_held_msg_release(&rmsg_handle);
1213 +
1214 + return ret;
1215 +}
1216 +
1217 +/* do a port action with a port as a parameter */
1218 +static int port_action_port(struct vchiq_mmal_instance *instance,
1219 + struct vchiq_mmal_port *port,
1220 + enum mmal_msg_port_action_type action_type)
1221 +{
1222 + int ret;
1223 + struct mmal_msg m;
1224 + struct mmal_msg *rmsg;
1225 + VCHI_HELD_MSG_T rmsg_handle;
1226 +
1227 + m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
1228 + m.u.port_action_port.component_handle = port->component->handle;
1229 + m.u.port_action_port.port_handle = port->handle;
1230 + m.u.port_action_port.action = action_type;
1231 +
1232 + port_to_mmal_msg(port, &m.u.port_action_port.port);
1233 +
1234 + ret = send_synchronous_mmal_msg(instance, &m,
1235 + sizeof(m.u.port_action_port),
1236 + &rmsg, &rmsg_handle);
1237 + if (ret)
1238 + return ret;
1239 +
1240 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
1241 + /* got an unexpected message type in reply */
1242 + ret = -EINVAL;
1243 + goto release_msg;
1244 + }
1245 +
1246 + ret = -rmsg->u.port_action_reply.status;
1247 +
1248 + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n",
1249 + __func__,
1250 + ret, port->component->handle, port->handle,
1251 + port_action_type_names[action_type], action_type);
1252 +
1253 +release_msg:
1254 + vchi_held_msg_release(&rmsg_handle);
1255 +
1256 + return ret;
1257 +}
1258 +
1259 +/* do a port action with handles as parameters */
1260 +static int port_action_handle(struct vchiq_mmal_instance *instance,
1261 + struct vchiq_mmal_port *port,
1262 + enum mmal_msg_port_action_type action_type,
1263 + u32 connect_component_handle,
1264 + u32 connect_port_handle)
1265 +{
1266 + int ret;
1267 + struct mmal_msg m;
1268 + struct mmal_msg *rmsg;
1269 + VCHI_HELD_MSG_T rmsg_handle;
1270 +
1271 + m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
1272 +
1273 + m.u.port_action_handle.component_handle = port->component->handle;
1274 + m.u.port_action_handle.port_handle = port->handle;
1275 + m.u.port_action_handle.action = action_type;
1276 +
1277 + m.u.port_action_handle.connect_component_handle =
1278 + connect_component_handle;
1279 + m.u.port_action_handle.connect_port_handle = connect_port_handle;
1280 +
1281 + ret = send_synchronous_mmal_msg(instance, &m,
1282 + sizeof(m.u.port_action_handle),
1283 + &rmsg, &rmsg_handle);
1284 + if (ret)
1285 + return ret;
1286 +
1287 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
1288 + /* got an unexpected message type in reply */
1289 + ret = -EINVAL;
1290 + goto release_msg;
1291 + }
1292 +
1293 + ret = -rmsg->u.port_action_reply.status;
1294 +
1295 + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
1296 + __func__,
1297 + ret, port->component->handle, port->handle,
1298 + port_action_type_names[action_type],
1299 + action_type, connect_component_handle, connect_port_handle);
1300 +
1301 +release_msg:
1302 + vchi_held_msg_release(&rmsg_handle);
1303 +
1304 + return ret;
1305 +}
1306 +
1307 +static int port_parameter_set(struct vchiq_mmal_instance *instance,
1308 + struct vchiq_mmal_port *port,
1309 + u32 parameter_id, void *value, u32 value_size)
1310 +{
1311 + int ret;
1312 + struct mmal_msg m;
1313 + struct mmal_msg *rmsg;
1314 + VCHI_HELD_MSG_T rmsg_handle;
1315 +
1316 + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET;
1317 +
1318 + m.u.port_parameter_set.component_handle = port->component->handle;
1319 + m.u.port_parameter_set.port_handle = port->handle;
1320 + m.u.port_parameter_set.id = parameter_id;
1321 + m.u.port_parameter_set.size = (2 * sizeof(u32)) + value_size;
1322 + memcpy(&m.u.port_parameter_set.value, value, value_size);
1323 +
1324 + ret = send_synchronous_mmal_msg(instance, &m,
1325 + (4 * sizeof(u32)) + value_size,
1326 + &rmsg, &rmsg_handle);
1327 + if (ret)
1328 + return ret;
1329 +
1330 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_SET) {
1331 + /* got an unexpected message type in reply */
1332 + ret = -EINVAL;
1333 + goto release_msg;
1334 + }
1335 +
1336 + ret = -rmsg->u.port_parameter_set_reply.status;
1337 +
1338 + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n",
1339 + __func__,
1340 + ret, port->component->handle, port->handle, parameter_id);
1341 +
1342 +release_msg:
1343 + vchi_held_msg_release(&rmsg_handle);
1344 +
1345 + return ret;
1346 +}
1347 +
1348 +static int port_parameter_get(struct vchiq_mmal_instance *instance,
1349 + struct vchiq_mmal_port *port,
1350 + u32 parameter_id, void *value, u32 *value_size)
1351 +{
1352 + int ret;
1353 + struct mmal_msg m;
1354 + struct mmal_msg *rmsg;
1355 + VCHI_HELD_MSG_T rmsg_handle;
1356 +
1357 + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET;
1358 +
1359 + m.u.port_parameter_get.component_handle = port->component->handle;
1360 + m.u.port_parameter_get.port_handle = port->handle;
1361 + m.u.port_parameter_get.id = parameter_id;
1362 + m.u.port_parameter_get.size = (2 * sizeof(u32)) + *value_size;
1363 +
1364 + ret = send_synchronous_mmal_msg(instance, &m,
1365 + sizeof(struct
1366 + mmal_msg_port_parameter_get),
1367 + &rmsg, &rmsg_handle);
1368 + if (ret)
1369 + return ret;
1370 +
1371 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_GET) {
1372 + /* got an unexpected message type in reply */
1373 + pr_err("Incorrect reply type %d\n", rmsg->h.type);
1374 + ret = -EINVAL;
1375 + goto release_msg;
1376 + }
1377 +
1378 + ret = -rmsg->u.port_parameter_get_reply.status;
1379 + /* port_parameter_get_reply.size includes the header,
1380 + * whilst *value_size doesn't.
1381 + */
1382 + rmsg->u.port_parameter_get_reply.size -= (2 * sizeof(u32));
1383 +
1384 + if (ret || rmsg->u.port_parameter_get_reply.size > *value_size) {
1385 + /* Copy only as much as we have space for
1386 + * but report true size of parameter
1387 + */
1388 + memcpy(value, &rmsg->u.port_parameter_get_reply.value,
1389 + *value_size);
1390 + *value_size = rmsg->u.port_parameter_get_reply.size;
1391 + } else {
1392 + memcpy(value, &rmsg->u.port_parameter_get_reply.value,
1393 + rmsg->u.port_parameter_get_reply.size);
1394 + }
1395 +
1396 + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__,
1397 + ret, port->component->handle, port->handle, parameter_id);
1398 +
1399 +release_msg:
1400 + vchi_held_msg_release(&rmsg_handle);
1401 +
1402 + return ret;
1403 +}
1404 +
1405 +/* disables a port and drains buffers from it */
1406 +static int port_disable(struct vchiq_mmal_instance *instance,
1407 + struct vchiq_mmal_port *port)
1408 +{
1409 + int ret;
1410 + struct list_head *q, *buf_head;
1411 + unsigned long flags = 0;
1412 +
1413 + if (!port->enabled)
1414 + return 0;
1415 +
1416 + port->enabled = false;
1417 +
1418 + ret = port_action_port(instance, port,
1419 + MMAL_MSG_PORT_ACTION_TYPE_DISABLE);
1420 + if (ret == 0) {
1421 + /*
1422 + * Drain all queued buffers on port. This should only
1423 + * apply to buffers that have been queued before the port
1424 + * has been enabled. If the port has been enabled and buffers
1425 + * passed, then the buffers should have been removed from this
1426 + * list, and we should get the relevant callbacks via VCHIQ
1427 + * to release the buffers.
1428 + */
1429 + spin_lock_irqsave(&port->slock, flags);
1430 +
1431 + list_for_each_safe(buf_head, q, &port->buffers) {
1432 + struct mmal_buffer *mmalbuf;
1433 +
1434 + mmalbuf = list_entry(buf_head, struct mmal_buffer,
1435 + list);
1436 + list_del(buf_head);
1437 + if (port->buffer_cb)
1438 + port->buffer_cb(instance,
1439 + port, 0, mmalbuf, 0, 0,
1440 + MMAL_TIME_UNKNOWN,
1441 + MMAL_TIME_UNKNOWN);
1442 + }
1443 +
1444 + spin_unlock_irqrestore(&port->slock, flags);
1445 +
1446 + ret = port_info_get(instance, port);
1447 + }
1448 +
1449 + return ret;
1450 +}
1451 +
1452 +/* enable a port */
1453 +static int port_enable(struct vchiq_mmal_instance *instance,
1454 + struct vchiq_mmal_port *port)
1455 +{
1456 + unsigned int hdr_count;
1457 + struct list_head *q, *buf_head;
1458 + int ret;
1459 +
1460 + if (port->enabled)
1461 + return 0;
1462 +
1463 + ret = port_action_port(instance, port,
1464 + MMAL_MSG_PORT_ACTION_TYPE_ENABLE);
1465 + if (ret)
1466 + goto done;
1467 +
1468 + port->enabled = true;
1469 +
1470 + if (port->buffer_cb) {
1471 + /* send buffer headers to videocore */
1472 + hdr_count = 1;
1473 + list_for_each_safe(buf_head, q, &port->buffers) {
1474 + struct mmal_buffer *mmalbuf;
1475 +
1476 + mmalbuf = list_entry(buf_head, struct mmal_buffer,
1477 + list);
1478 + ret = buffer_from_host(instance, port, mmalbuf);
1479 + if (ret)
1480 + goto done;
1481 +
1482 + list_del(buf_head);
1483 + hdr_count++;
1484 + if (hdr_count > port->current_buffer.num)
1485 + break;
1486 + }
1487 + }
1488 +
1489 + ret = port_info_get(instance, port);
1490 +
1491 +done:
1492 + return ret;
1493 +}
1494 +
1495 +/* ------------------------------------------------------------------
1496 + * Exported API
1497 + *------------------------------------------------------------------
1498 + */
1499 +
1500 +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
1501 + struct vchiq_mmal_port *port)
1502 +{
1503 + int ret;
1504 +
1505 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1506 + return -EINTR;
1507 +
1508 + ret = port_info_set(instance, port);
1509 + if (ret)
1510 + goto release_unlock;
1511 +
1512 + /* read what has actually been set */
1513 + ret = port_info_get(instance, port);
1514 +
1515 +release_unlock:
1516 + mutex_unlock(&instance->vchiq_mutex);
1517 +
1518 + return ret;
1519 +}
1520 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_set_format);
1521 +
1522 +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
1523 + struct vchiq_mmal_port *port,
1524 + u32 parameter, void *value, u32 value_size)
1525 +{
1526 + int ret;
1527 +
1528 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1529 + return -EINTR;
1530 +
1531 + ret = port_parameter_set(instance, port, parameter, value, value_size);
1532 +
1533 + mutex_unlock(&instance->vchiq_mutex);
1534 +
1535 + return ret;
1536 +}
1537 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_set);
1538 +
1539 +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
1540 + struct vchiq_mmal_port *port,
1541 + u32 parameter, void *value, u32 *value_size)
1542 +{
1543 + int ret;
1544 +
1545 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1546 + return -EINTR;
1547 +
1548 + ret = port_parameter_get(instance, port, parameter, value, value_size);
1549 +
1550 + mutex_unlock(&instance->vchiq_mutex);
1551 +
1552 + return ret;
1553 +}
1554 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_get);
1555 +
1556 +/* enable a port
1557 + *
1558 + * enables a port and queues buffers for satisfying callbacks if we
1559 + * provide a callback handler
1560 + */
1561 +int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
1562 + struct vchiq_mmal_port *port,
1563 + vchiq_mmal_buffer_cb buffer_cb)
1564 +{
1565 + int ret;
1566 +
1567 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1568 + return -EINTR;
1569 +
1570 + /* already enabled - noop */
1571 + if (port->enabled) {
1572 + ret = 0;
1573 + goto unlock;
1574 + }
1575 +
1576 + port->buffer_cb = buffer_cb;
1577 +
1578 + ret = port_enable(instance, port);
1579 +
1580 +unlock:
1581 + mutex_unlock(&instance->vchiq_mutex);
1582 +
1583 + return ret;
1584 +}
1585 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_enable);
1586 +
1587 +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
1588 + struct vchiq_mmal_port *port)
1589 +{
1590 + int ret;
1591 +
1592 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1593 + return -EINTR;
1594 +
1595 + if (!port->enabled) {
1596 + mutex_unlock(&instance->vchiq_mutex);
1597 + return 0;
1598 + }
1599 +
1600 + ret = port_disable(instance, port);
1601 +
1602 + mutex_unlock(&instance->vchiq_mutex);
1603 +
1604 + return ret;
1605 +}
1606 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_disable);
1607 +
1608 +/* ports will be connected in a tunneled manner so data buffers
1609 + * are not handled by client.
1610 + */
1611 +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
1612 + struct vchiq_mmal_port *src,
1613 + struct vchiq_mmal_port *dst)
1614 +{
1615 + int ret;
1616 +
1617 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1618 + return -EINTR;
1619 +
1620 + /* disconnect ports if connected */
1621 + if (src->connected) {
1622 + ret = port_disable(instance, src);
1623 + if (ret) {
1624 + pr_err("failed disabling src port(%d)\n", ret);
1625 + goto release_unlock;
1626 + }
1627 +
1628 + /* do not need to disable the destination port as they
1629 + * are connected and it is done automatically
1630 + */
1631 +
1632 + ret = port_action_handle(instance, src,
1633 + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT,
1634 + src->connected->component->handle,
1635 + src->connected->handle);
1636 + if (ret < 0) {
1637 + pr_err("failed disconnecting src port\n");
1638 + goto release_unlock;
1639 + }
1640 + src->connected->enabled = false;
1641 + src->connected = NULL;
1642 + }
1643 +
1644 + if (!dst) {
1645 + /* do not make new connection */
1646 + ret = 0;
1647 + pr_debug("not making new connection\n");
1648 + goto release_unlock;
1649 + }
1650 +
1651 + /* copy src port format to dst */
1652 + dst->format.encoding = src->format.encoding;
1653 + dst->es.video.width = src->es.video.width;
1654 + dst->es.video.height = src->es.video.height;
1655 + dst->es.video.crop.x = src->es.video.crop.x;
1656 + dst->es.video.crop.y = src->es.video.crop.y;
1657 + dst->es.video.crop.width = src->es.video.crop.width;
1658 + dst->es.video.crop.height = src->es.video.crop.height;
1659 + dst->es.video.frame_rate.num = src->es.video.frame_rate.num;
1660 + dst->es.video.frame_rate.den = src->es.video.frame_rate.den;
1661 +
1662 + /* set new format */
1663 + ret = port_info_set(instance, dst);
1664 + if (ret) {
1665 + pr_debug("setting port info failed\n");
1666 + goto release_unlock;
1667 + }
1668 +
1669 + /* read what has actually been set */
1670 + ret = port_info_get(instance, dst);
1671 + if (ret) {
1672 + pr_debug("read back port info failed\n");
1673 + goto release_unlock;
1674 + }
1675 +
1676 + /* connect two ports together */
1677 + ret = port_action_handle(instance, src,
1678 + MMAL_MSG_PORT_ACTION_TYPE_CONNECT,
1679 + dst->component->handle, dst->handle);
1680 + if (ret < 0) {
1681 + pr_debug("connecting port %d:%d to %d:%d failed\n",
1682 + src->component->handle, src->handle,
1683 + dst->component->handle, dst->handle);
1684 + goto release_unlock;
1685 + }
1686 + src->connected = dst;
1687 +
1688 +release_unlock:
1689 +
1690 + mutex_unlock(&instance->vchiq_mutex);
1691 +
1692 + return ret;
1693 +}
1694 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_connect_tunnel);
1695 +
1696 +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
1697 + struct vchiq_mmal_port *port,
1698 + struct mmal_buffer *buffer)
1699 +{
1700 + unsigned long flags = 0;
1701 + int ret;
1702 +
1703 + ret = buffer_from_host(instance, port, buffer);
1704 + if (ret == -EINVAL) {
1705 + /* Port is disabled. Queue for when it is enabled. */
1706 + spin_lock_irqsave(&port->slock, flags);
1707 + list_add_tail(&buffer->list, &port->buffers);
1708 + spin_unlock_irqrestore(&port->slock, flags);
1709 + }
1710 +
1711 + return 0;
1712 +}
1713 +EXPORT_SYMBOL_GPL(vchiq_mmal_submit_buffer);
1714 +
1715 +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
1716 + struct mmal_buffer *buf)
1717 +{
1718 + struct mmal_msg_context *msg_context = get_msg_context(instance);
1719 +
1720 + if (IS_ERR(msg_context))
1721 + return (PTR_ERR(msg_context));
1722 +
1723 + buf->msg_context = msg_context;
1724 + return 0;
1725 +}
1726 +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_init);
1727 +
1728 +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
1729 +{
1730 + struct mmal_msg_context *msg_context = buf->msg_context;
1731 +
1732 + if (msg_context)
1733 + release_msg_context(msg_context);
1734 + buf->msg_context = NULL;
1735 +
1736 + return 0;
1737 +}
1738 +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_cleanup);
1739 +
1740 +/* Initialise a mmal component and its ports
1741 + *
1742 + */
1743 +int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
1744 + const char *name,
1745 + struct vchiq_mmal_component **component_out)
1746 +{
1747 + int ret;
1748 + int idx; /* port index */
1749 + struct vchiq_mmal_component *component;
1750 +
1751 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1752 + return -EINTR;
1753 +
1754 + if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) {
1755 + ret = -EINVAL; /* todo is this correct error? */
1756 + goto unlock;
1757 + }
1758 +
1759 + component = &instance->component[instance->component_idx];
1760 +
1761 + ret = create_component(instance, component, name);
1762 + if (ret < 0) {
1763 + pr_err("%s: failed to create component %d (Not enough GPU mem?)\n",
1764 + __func__, ret);
1765 + goto unlock;
1766 + }
1767 +
1768 + /* ports info needs gathering */
1769 + component->control.type = MMAL_PORT_TYPE_CONTROL;
1770 + component->control.index = 0;
1771 + component->control.component = component;
1772 + spin_lock_init(&component->control.slock);
1773 + INIT_LIST_HEAD(&component->control.buffers);
1774 + ret = port_info_get(instance, &component->control);
1775 + if (ret < 0)
1776 + goto release_component;
1777 +
1778 + for (idx = 0; idx < component->inputs; idx++) {
1779 + component->input[idx].type = MMAL_PORT_TYPE_INPUT;
1780 + component->input[idx].index = idx;
1781 + component->input[idx].component = component;
1782 + spin_lock_init(&component->input[idx].slock);
1783 + INIT_LIST_HEAD(&component->input[idx].buffers);
1784 + ret = port_info_get(instance, &component->input[idx]);
1785 + if (ret < 0)
1786 + goto release_component;
1787 + }
1788 +
1789 + for (idx = 0; idx < component->outputs; idx++) {
1790 + component->output[idx].type = MMAL_PORT_TYPE_OUTPUT;
1791 + component->output[idx].index = idx;
1792 + component->output[idx].component = component;
1793 + spin_lock_init(&component->output[idx].slock);
1794 + INIT_LIST_HEAD(&component->output[idx].buffers);
1795 + ret = port_info_get(instance, &component->output[idx]);
1796 + if (ret < 0)
1797 + goto release_component;
1798 + }
1799 +
1800 + for (idx = 0; idx < component->clocks; idx++) {
1801 + component->clock[idx].type = MMAL_PORT_TYPE_CLOCK;
1802 + component->clock[idx].index = idx;
1803 + component->clock[idx].component = component;
1804 + spin_lock_init(&component->clock[idx].slock);
1805 + INIT_LIST_HEAD(&component->clock[idx].buffers);
1806 + ret = port_info_get(instance, &component->clock[idx]);
1807 + if (ret < 0)
1808 + goto release_component;
1809 + }
1810 +
1811 + instance->component_idx++;
1812 +
1813 + *component_out = component;
1814 +
1815 + mutex_unlock(&instance->vchiq_mutex);
1816 +
1817 + return 0;
1818 +
1819 +release_component:
1820 + destroy_component(instance, component);
1821 +unlock:
1822 + mutex_unlock(&instance->vchiq_mutex);
1823 +
1824 + return ret;
1825 +}
1826 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_init);
1827 +
1828 +/*
1829 + * cause a mmal component to be destroyed
1830 + */
1831 +int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
1832 + struct vchiq_mmal_component *component)
1833 +{
1834 + int ret;
1835 +
1836 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1837 + return -EINTR;
1838 +
1839 + if (component->enabled)
1840 + ret = disable_component(instance, component);
1841 +
1842 + ret = destroy_component(instance, component);
1843 +
1844 + mutex_unlock(&instance->vchiq_mutex);
1845 +
1846 + return ret;
1847 +}
1848 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_finalise);
1849 +
1850 +/*
1851 + * cause a mmal component to be enabled
1852 + */
1853 +int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,
1854 + struct vchiq_mmal_component *component)
1855 +{
1856 + int ret;
1857 +
1858 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1859 + return -EINTR;
1860 +
1861 + if (component->enabled) {
1862 + mutex_unlock(&instance->vchiq_mutex);
1863 + return 0;
1864 + }
1865 +
1866 + ret = enable_component(instance, component);
1867 + if (ret == 0)
1868 + component->enabled = true;
1869 +
1870 + mutex_unlock(&instance->vchiq_mutex);
1871 +
1872 + return ret;
1873 +}
1874 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_enable);
1875 +
1876 +/*
1877 + * cause a mmal component to be enabled
1878 + */
1879 +int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance,
1880 + struct vchiq_mmal_component *component)
1881 +{
1882 + int ret;
1883 +
1884 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1885 + return -EINTR;
1886 +
1887 + if (!component->enabled) {
1888 + mutex_unlock(&instance->vchiq_mutex);
1889 + return 0;
1890 + }
1891 +
1892 + ret = disable_component(instance, component);
1893 + if (ret == 0)
1894 + component->enabled = false;
1895 +
1896 + mutex_unlock(&instance->vchiq_mutex);
1897 +
1898 + return ret;
1899 +}
1900 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_disable);
1901 +
1902 +int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
1903 + u32 *major_out, u32 *minor_out)
1904 +{
1905 + int ret;
1906 +
1907 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1908 + return -EINTR;
1909 +
1910 + ret = get_version(instance, major_out, minor_out);
1911 +
1912 + mutex_unlock(&instance->vchiq_mutex);
1913 +
1914 + return ret;
1915 +}
1916 +EXPORT_SYMBOL_GPL(vchiq_mmal_version);
1917 +
1918 +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
1919 +{
1920 + int status = 0;
1921 +
1922 + if (!instance)
1923 + return -EINVAL;
1924 +
1925 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
1926 + return -EINTR;
1927 +
1928 + vchi_service_use(instance->handle);
1929 +
1930 + status = vchi_service_close(instance->handle);
1931 + if (status != 0)
1932 + pr_err("mmal-vchiq: VCHIQ close failed\n");
1933 +
1934 + mutex_unlock(&instance->vchiq_mutex);
1935 +
1936 + flush_workqueue(instance->bulk_wq);
1937 + destroy_workqueue(instance->bulk_wq);
1938 +
1939 + vfree(instance->bulk_scratch);
1940 +
1941 + idr_destroy(&instance->context_map);
1942 +
1943 + kfree(instance);
1944 +
1945 + return status;
1946 +}
1947 +EXPORT_SYMBOL_GPL(vchiq_mmal_finalise);
1948 +
1949 +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
1950 +{
1951 + int status;
1952 + struct vchiq_mmal_instance *instance;
1953 + static VCHI_CONNECTION_T *vchi_connection;
1954 + static VCHI_INSTANCE_T vchi_instance;
1955 + SERVICE_CREATION_T params = {
1956 + .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER),
1957 + .service_id = VC_MMAL_SERVER_NAME,
1958 + .connection = vchi_connection,
1959 + .rx_fifo_size = 0,
1960 + .tx_fifo_size = 0,
1961 + .callback = service_callback,
1962 + .callback_param = NULL,
1963 + .want_unaligned_bulk_rx = 1,
1964 + .want_unaligned_bulk_tx = 1,
1965 + .want_crc = 0
1966 + };
1967 +
1968 + /* compile time checks to ensure structure size as they are
1969 + * directly (de)serialised from memory.
1970 + */
1971 +
1972 + /* ensure the header structure has packed to the correct size */
1973 + BUILD_BUG_ON(sizeof(struct mmal_msg_header) != 24);
1974 +
1975 + /* ensure message structure does not exceed maximum length */
1976 + BUILD_BUG_ON(sizeof(struct mmal_msg) > MMAL_MSG_MAX_SIZE);
1977 +
1978 + /* mmal port struct is correct size */
1979 + BUILD_BUG_ON(sizeof(struct mmal_port) != 64);
1980 +
1981 + /* create a vchi instance */
1982 + status = vchi_initialise(&vchi_instance);
1983 + if (status) {
1984 + pr_err("Failed to initialise VCHI instance (status=%d)\n",
1985 + status);
1986 + return -EIO;
1987 + }
1988 +
1989 + status = vchi_connect(NULL, 0, vchi_instance);
1990 + if (status) {
1991 + pr_err("Failed to connect VCHI instance (status=%d)\n", status);
1992 + return -EIO;
1993 + }
1994 +
1995 + instance = kzalloc(sizeof(*instance), GFP_KERNEL);
1996 +
1997 + if (!instance)
1998 + return -ENOMEM;
1999 +
2000 + mutex_init(&instance->vchiq_mutex);
2001 +
2002 + instance->bulk_scratch = vmalloc(PAGE_SIZE);
2003 +
2004 + mutex_init(&instance->context_map_lock);
2005 + idr_init_base(&instance->context_map, 1);
2006 +
2007 + params.callback_param = instance;
2008 +
2009 + instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq",
2010 + WQ_MEM_RECLAIM);
2011 + if (!instance->bulk_wq)
2012 + goto err_free;
2013 +
2014 + status = vchi_service_open(vchi_instance, &params, &instance->handle);
2015 + if (status) {
2016 + pr_err("Failed to open VCHI service connection (status=%d)\n",
2017 + status);
2018 + goto err_close_services;
2019 + }
2020 +
2021 + vchi_service_release(instance->handle);
2022 +
2023 + *out_instance = instance;
2024 +
2025 + return 0;
2026 +
2027 +err_close_services:
2028 + vchi_service_close(instance->handle);
2029 + destroy_workqueue(instance->bulk_wq);
2030 +err_free:
2031 + vfree(instance->bulk_scratch);
2032 + kfree(instance);
2033 + return -ENODEV;
2034 +}
2035 +EXPORT_SYMBOL_GPL(vchiq_mmal_init);
2036 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
2037 +++ /dev/null
2038 @@ -1,61 +0,0 @@
2039 -/* SPDX-License-Identifier: GPL-2.0 */
2040 -/*
2041 - * Broadcom BM2835 V4L2 driver
2042 - *
2043 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2044 - *
2045 - * Authors: Vincent Sanders @ Collabora
2046 - * Dave Stevenson @ Broadcom
2047 - * (now dave.stevenson@raspberrypi.org)
2048 - * Simon Mellor @ Broadcom
2049 - * Luke Diamand @ Broadcom
2050 - *
2051 - * MMAL structures
2052 - *
2053 - */
2054 -#ifndef MMAL_COMMON_H
2055 -#define MMAL_COMMON_H
2056 -
2057 -#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))
2058 -#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
2059 -
2060 -/** Special value signalling that time is not known */
2061 -#define MMAL_TIME_UNKNOWN BIT_ULL(63)
2062 -
2063 -struct mmal_msg_context;
2064 -
2065 -/* mapping between v4l and mmal video modes */
2066 -struct mmal_fmt {
2067 - char *name;
2068 - u32 fourcc; /* v4l2 format id */
2069 - int flags; /* v4l2 flags field */
2070 - u32 mmal;
2071 - int depth;
2072 - u32 mmal_component; /* MMAL component index to be used to encode */
2073 - u32 ybbp; /* depth of first Y plane for planar formats */
2074 - bool remove_padding; /* Does the GPU have to remove padding,
2075 - * or can we do hide padding via bytesperline.
2076 - */
2077 -};
2078 -
2079 -/* buffer for one video frame */
2080 -struct mmal_buffer {
2081 - /* v4l buffer data -- must be first */
2082 - struct vb2_v4l2_buffer vb;
2083 -
2084 - /* list of buffers available */
2085 - struct list_head list;
2086 -
2087 - void *buffer; /* buffer pointer */
2088 - unsigned long buffer_size; /* size of allocated buffer */
2089 -
2090 - struct mmal_msg_context *msg_context;
2091 -};
2092 -
2093 -/* */
2094 -struct mmal_colourfx {
2095 - s32 enable;
2096 - u32 u;
2097 - u32 v;
2098 -};
2099 -#endif
2100 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h
2101 +++ /dev/null
2102 @@ -1,124 +0,0 @@
2103 -/* SPDX-License-Identifier: GPL-2.0 */
2104 -/*
2105 - * Broadcom BM2835 V4L2 driver
2106 - *
2107 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2108 - *
2109 - * Authors: Vincent Sanders @ Collabora
2110 - * Dave Stevenson @ Broadcom
2111 - * (now dave.stevenson@raspberrypi.org)
2112 - * Simon Mellor @ Broadcom
2113 - * Luke Diamand @ Broadcom
2114 - */
2115 -#ifndef MMAL_ENCODINGS_H
2116 -#define MMAL_ENCODINGS_H
2117 -
2118 -#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4')
2119 -#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3')
2120 -#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V')
2121 -#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V')
2122 -#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V')
2123 -#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3')
2124 -#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2')
2125 -#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1')
2126 -#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1')
2127 -#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ')
2128 -#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ')
2129 -#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ')
2130 -#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O')
2131 -#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K')
2132 -#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G')
2133 -
2134 -#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G')
2135 -#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ')
2136 -#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ')
2137 -#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ')
2138 -#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ')
2139 -#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ')
2140 -
2141 -#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0')
2142 -#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0')
2143 -#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2')
2144 -#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2')
2145 -#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2')
2146 -#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V')
2147 -#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U')
2148 -#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y')
2149 -#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y')
2150 -#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2')
2151 -#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1')
2152 -#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B')
2153 -#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A')
2154 -#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R')
2155 -#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A')
2156 -#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2')
2157 -#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3')
2158 -#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4')
2159 -#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2')
2160 -#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3')
2161 -#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4')
2162 -
2163 -/** SAND Video (YUVUV128) format, native format understood by VideoCore.
2164 - * This format is *not* opaque - if requested you will receive full frames
2165 - * of YUV_UV video.
2166 - */
2167 -#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D')
2168 -
2169 -/** VideoCore opaque image format, image handles are returned to
2170 - * the host but not the actual image data.
2171 - */
2172 -#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V')
2173 -
2174 -/** An EGL image handle
2175 - */
2176 -#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I')
2177 -
2178 -/* }@ */
2179 -
2180 -/** \name Pre-defined audio encodings */
2181 -/* @{ */
2182 -#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U')
2183 -#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u')
2184 -#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S')
2185 -#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's')
2186 -#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F')
2187 -#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f')
2188 -
2189 -/* Pre-defined H264 encoding variants */
2190 -
2191 -/** ISO 14496-10 Annex B byte stream format */
2192 -#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0
2193 -/** ISO 14496-15 AVC stream format */
2194 -#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1')
2195 -/** Implicitly delineated NAL units without emulation prevention */
2196 -#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ')
2197 -
2198 -/** \defgroup MmalColorSpace List of pre-defined video color spaces
2199 - * This defines a list of common color spaces. This list isn't exhaustive and
2200 - * is only provided as a convenience to avoid clients having to use FourCC
2201 - * codes directly. However components are allowed to define and use their own
2202 - * FourCC codes.
2203 - */
2204 -/* @{ */
2205 -
2206 -/** Unknown color space */
2207 -#define MMAL_COLOR_SPACE_UNKNOWN 0
2208 -/** ITU-R BT.601-5 [SDTV] */
2209 -#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1')
2210 -/** ITU-R BT.709-3 [HDTV] */
2211 -#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9')
2212 -/** JPEG JFIF */
2213 -#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I')
2214 -/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
2215 -#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C')
2216 -/** Society of Motion Picture and Television Engineers 240M (1999) */
2217 -#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0')
2218 -/** ITU-R BT.470-2 System M */
2219 -#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M')
2220 -/** ITU-R BT.470-2 System BG */
2221 -#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G')
2222 -/** JPEG JFIF, but with 16..255 luma */
2223 -#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6')
2224 -/* @} MmalColorSpace List */
2225 -
2226 -#endif /* MMAL_ENCODINGS_H */
2227 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h
2228 +++ /dev/null
2229 @@ -1,48 +0,0 @@
2230 -/* SPDX-License-Identifier: GPL-2.0 */
2231 -/*
2232 - * Broadcom BM2835 V4L2 driver
2233 - *
2234 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2235 - *
2236 - * Authors: Vincent Sanders @ Collabora
2237 - * Dave Stevenson @ Broadcom
2238 - * (now dave.stevenson@raspberrypi.org)
2239 - * Simon Mellor @ Broadcom
2240 - * Luke Diamand @ Broadcom
2241 - */
2242 -
2243 -#ifndef MMAL_MSG_COMMON_H
2244 -#define MMAL_MSG_COMMON_H
2245 -
2246 -enum mmal_msg_status {
2247 - MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */
2248 - MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */
2249 - MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */
2250 - MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */
2251 - MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */
2252 - MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */
2253 - MMAL_MSG_STATUS_ENXIO, /**< No such device or address */
2254 - MMAL_MSG_STATUS_EIO, /**< I/O error */
2255 - MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */
2256 - MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */
2257 - MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */
2258 - MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */
2259 - MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */
2260 - MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */
2261 - MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */
2262 - MMAL_MSG_STATUS_EFAULT, /**< Bad address */
2263 -};
2264 -
2265 -struct mmal_rect {
2266 - s32 x; /**< x coordinate (from left) */
2267 - s32 y; /**< y coordinate (from top) */
2268 - s32 width; /**< width */
2269 - s32 height; /**< height */
2270 -};
2271 -
2272 -struct mmal_rational {
2273 - s32 num; /**< Numerator */
2274 - s32 den; /**< Denominator */
2275 -};
2276 -
2277 -#endif /* MMAL_MSG_COMMON_H */
2278 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h
2279 +++ /dev/null
2280 @@ -1,106 +0,0 @@
2281 -/* SPDX-License-Identifier: GPL-2.0 */
2282 -/*
2283 - * Broadcom BM2835 V4L2 driver
2284 - *
2285 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2286 - *
2287 - * Authors: Vincent Sanders @ Collabora
2288 - * Dave Stevenson @ Broadcom
2289 - * (now dave.stevenson@raspberrypi.org)
2290 - * Simon Mellor @ Broadcom
2291 - * Luke Diamand @ Broadcom
2292 - */
2293 -
2294 -#ifndef MMAL_MSG_FORMAT_H
2295 -#define MMAL_MSG_FORMAT_H
2296 -
2297 -#include "mmal-msg-common.h"
2298 -
2299 -/* MMAL_ES_FORMAT_T */
2300 -
2301 -struct mmal_audio_format {
2302 - u32 channels; /* Number of audio channels */
2303 - u32 sample_rate; /* Sample rate */
2304 -
2305 - u32 bits_per_sample; /* Bits per sample */
2306 - u32 block_align; /* Size of a block of data */
2307 -};
2308 -
2309 -struct mmal_video_format {
2310 - u32 width; /* Width of frame in pixels */
2311 - u32 height; /* Height of frame in rows of pixels */
2312 - struct mmal_rect crop; /* Visible region of the frame */
2313 - struct mmal_rational frame_rate; /* Frame rate */
2314 - struct mmal_rational par; /* Pixel aspect ratio */
2315 -
2316 - /*
2317 - * FourCC specifying the color space of the video stream. See the
2318 - * MmalColorSpace "pre-defined color spaces" for some examples.
2319 - */
2320 - u32 color_space;
2321 -};
2322 -
2323 -struct mmal_subpicture_format {
2324 - u32 x_offset;
2325 - u32 y_offset;
2326 -};
2327 -
2328 -union mmal_es_specific_format {
2329 - struct mmal_audio_format audio;
2330 - struct mmal_video_format video;
2331 - struct mmal_subpicture_format subpicture;
2332 -};
2333 -
2334 -/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */
2335 -struct mmal_es_format_local {
2336 - u32 type; /* enum mmal_es_type */
2337 -
2338 - u32 encoding; /* FourCC specifying encoding of the elementary
2339 - * stream.
2340 - */
2341 - u32 encoding_variant; /* FourCC specifying the specific
2342 - * encoding variant of the elementary
2343 - * stream.
2344 - */
2345 -
2346 - union mmal_es_specific_format *es; /* Type specific
2347 - * information for the
2348 - * elementary stream
2349 - */
2350 -
2351 - u32 bitrate; /* Bitrate in bits per second */
2352 - u32 flags; /* Flags describing properties of the elementary
2353 - * stream.
2354 - */
2355 -
2356 - u32 extradata_size; /* Size of the codec specific data */
2357 - u8 *extradata; /* Codec specific data */
2358 -};
2359 -
2360 -/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */
2361 -struct mmal_es_format {
2362 - u32 type; /* enum mmal_es_type */
2363 -
2364 - u32 encoding; /* FourCC specifying encoding of the elementary
2365 - * stream.
2366 - */
2367 - u32 encoding_variant; /* FourCC specifying the specific
2368 - * encoding variant of the elementary
2369 - * stream.
2370 - */
2371 -
2372 - u32 es; /* Type specific
2373 - * information for the
2374 - * elementary stream
2375 - */
2376 -
2377 - u32 bitrate; /* Bitrate in bits per second */
2378 - u32 flags; /* Flags describing properties of the elementary
2379 - * stream.
2380 - */
2381 -
2382 - u32 extradata_size; /* Size of the codec specific data */
2383 - u32 extradata; /* Codec specific data */
2384 -};
2385 -
2386 -#endif /* MMAL_MSG_FORMAT_H */
2387 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h
2388 +++ /dev/null
2389 @@ -1,109 +0,0 @@
2390 -/* SPDX-License-Identifier: GPL-2.0 */
2391 -/*
2392 - * Broadcom BM2835 V4L2 driver
2393 - *
2394 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2395 - *
2396 - * Authors: Vincent Sanders @ Collabora
2397 - * Dave Stevenson @ Broadcom
2398 - * (now dave.stevenson@raspberrypi.org)
2399 - * Simon Mellor @ Broadcom
2400 - * Luke Diamand @ Broadcom
2401 - */
2402 -
2403 -/* MMAL_PORT_TYPE_T */
2404 -enum mmal_port_type {
2405 - MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */
2406 - MMAL_PORT_TYPE_CONTROL, /* Control port */
2407 - MMAL_PORT_TYPE_INPUT, /* Input port */
2408 - MMAL_PORT_TYPE_OUTPUT, /* Output port */
2409 - MMAL_PORT_TYPE_CLOCK, /* Clock port */
2410 -};
2411 -
2412 -/* The port is pass-through and doesn't need buffer headers allocated */
2413 -#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01
2414 -/*
2415 - *The port wants to allocate the buffer payloads.
2416 - * This signals a preference that payload allocation should be done
2417 - * on this port for efficiency reasons.
2418 - */
2419 -#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02
2420 -/*
2421 - * The port supports format change events.
2422 - * This applies to input ports and is used to let the client know
2423 - * whether the port supports being reconfigured via a format
2424 - * change event (i.e. without having to disable the port).
2425 - */
2426 -#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04
2427 -
2428 -/*
2429 - * mmal port structure (MMAL_PORT_T)
2430 - *
2431 - * most elements are informational only, the pointer values for
2432 - * interogation messages are generally provided as additional
2433 - * structures within the message. When used to set values only the
2434 - * buffer_num, buffer_size and userdata parameters are writable.
2435 - */
2436 -struct mmal_port {
2437 - u32 priv; /* Private member used by the framework */
2438 - u32 name; /* Port name. Used for debugging purposes (RO) */
2439 -
2440 - u32 type; /* Type of the port (RO) enum mmal_port_type */
2441 - u16 index; /* Index of the port in its type list (RO) */
2442 - u16 index_all; /* Index of the port in the list of all ports (RO) */
2443 -
2444 - u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */
2445 - u32 format; /* Format of the elementary stream */
2446 -
2447 - u32 buffer_num_min; /* Minimum number of buffers the port
2448 - * requires (RO). This is set by the
2449 - * component.
2450 - */
2451 -
2452 - u32 buffer_size_min; /* Minimum size of buffers the port
2453 - * requires (RO). This is set by the
2454 - * component.
2455 - */
2456 -
2457 - u32 buffer_alignment_min;/* Minimum alignment requirement for
2458 - * the buffers (RO). A value of
2459 - * zero means no special alignment
2460 - * requirements. This is set by the
2461 - * component.
2462 - */
2463 -
2464 - u32 buffer_num_recommended; /* Number of buffers the port
2465 - * recommends for optimal
2466 - * performance (RO). A value of
2467 - * zero means no special
2468 - * recommendation. This is set
2469 - * by the component.
2470 - */
2471 -
2472 - u32 buffer_size_recommended; /* Size of buffers the port
2473 - * recommends for optimal
2474 - * performance (RO). A value of
2475 - * zero means no special
2476 - * recommendation. This is set
2477 - * by the component.
2478 - */
2479 -
2480 - u32 buffer_num; /* Actual number of buffers the port will use.
2481 - * This is set by the client.
2482 - */
2483 -
2484 - u32 buffer_size; /* Actual maximum size of the buffers that
2485 - * will be sent to the port. This is set by
2486 - * the client.
2487 - */
2488 -
2489 - u32 component; /* Component this port belongs to (Read Only) */
2490 -
2491 - u32 userdata; /* Field reserved for use by the client */
2492 -
2493 - u32 capabilities; /* Flags describing the capabilities of a
2494 - * port (RO). Bitwise combination of \ref
2495 - * portcapabilities "Port capabilities"
2496 - * values.
2497 - */
2498 -};
2499 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
2500 +++ /dev/null
2501 @@ -1,406 +0,0 @@
2502 -/* SPDX-License-Identifier: GPL-2.0 */
2503 -/*
2504 - * Broadcom BM2835 V4L2 driver
2505 - *
2506 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2507 - *
2508 - * Authors: Vincent Sanders @ Collabora
2509 - * Dave Stevenson @ Broadcom
2510 - * (now dave.stevenson@raspberrypi.org)
2511 - * Simon Mellor @ Broadcom
2512 - * Luke Diamand @ Broadcom
2513 - */
2514 -
2515 -/*
2516 - * all the data structures which serialise the MMAL protocol. note
2517 - * these are directly mapped onto the recived message data.
2518 - *
2519 - * BEWARE: They seem to *assume* pointers are u32 and that there is no
2520 - * structure padding!
2521 - *
2522 - * NOTE: this implementation uses kernel types to ensure sizes. Rather
2523 - * than assigning values to enums to force their size the
2524 - * implementation uses fixed size types and not the enums (though the
2525 - * comments have the actual enum type
2526 - */
2527 -#ifndef MMAL_MSG_H
2528 -#define MMAL_MSG_H
2529 -
2530 -#define VC_MMAL_VER 15
2531 -#define VC_MMAL_MIN_VER 10
2532 -#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal")
2533 -
2534 -/* max total message size is 512 bytes */
2535 -#define MMAL_MSG_MAX_SIZE 512
2536 -/* with six 32bit header elements max payload is therefore 488 bytes */
2537 -#define MMAL_MSG_MAX_PAYLOAD 488
2538 -
2539 -#include "mmal-msg-common.h"
2540 -#include "mmal-msg-format.h"
2541 -#include "mmal-msg-port.h"
2542 -
2543 -enum mmal_msg_type {
2544 - MMAL_MSG_TYPE_QUIT = 1,
2545 - MMAL_MSG_TYPE_SERVICE_CLOSED,
2546 - MMAL_MSG_TYPE_GET_VERSION,
2547 - MMAL_MSG_TYPE_COMPONENT_CREATE,
2548 - MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */
2549 - MMAL_MSG_TYPE_COMPONENT_ENABLE,
2550 - MMAL_MSG_TYPE_COMPONENT_DISABLE,
2551 - MMAL_MSG_TYPE_PORT_INFO_GET,
2552 - MMAL_MSG_TYPE_PORT_INFO_SET,
2553 - MMAL_MSG_TYPE_PORT_ACTION, /* 10 */
2554 - MMAL_MSG_TYPE_BUFFER_FROM_HOST,
2555 - MMAL_MSG_TYPE_BUFFER_TO_HOST,
2556 - MMAL_MSG_TYPE_GET_STATS,
2557 - MMAL_MSG_TYPE_PORT_PARAMETER_SET,
2558 - MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */
2559 - MMAL_MSG_TYPE_EVENT_TO_HOST,
2560 - MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
2561 - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
2562 - MMAL_MSG_TYPE_CONSUME_MEM,
2563 - MMAL_MSG_TYPE_LMK, /* 20 */
2564 - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
2565 - MMAL_MSG_TYPE_DRM_GET_LHS32,
2566 - MMAL_MSG_TYPE_DRM_GET_TIME,
2567 - MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
2568 - MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */
2569 - MMAL_MSG_TYPE_HOST_LOG,
2570 - MMAL_MSG_TYPE_MSG_LAST
2571 -};
2572 -
2573 -/* port action request messages differ depending on the action type */
2574 -enum mmal_msg_port_action_type {
2575 - MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */
2576 - MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
2577 - MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
2578 - MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
2579 - MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */
2580 - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */
2581 - MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/
2582 -};
2583 -
2584 -struct mmal_msg_header {
2585 - u32 magic;
2586 - u32 type; /* enum mmal_msg_type */
2587 -
2588 - /* Opaque handle to the control service */
2589 - u32 control_service;
2590 -
2591 - u32 context; /* a u32 per message context */
2592 - u32 status; /* The status of the vchiq operation */
2593 - u32 padding;
2594 -};
2595 -
2596 -/* Send from VC to host to report version */
2597 -struct mmal_msg_version {
2598 - u32 flags;
2599 - u32 major;
2600 - u32 minor;
2601 - u32 minimum;
2602 -};
2603 -
2604 -/* request to VC to create component */
2605 -struct mmal_msg_component_create {
2606 - u32 client_component; /* component context */
2607 - char name[128];
2608 - u32 pid; /* For debug */
2609 -};
2610 -
2611 -/* reply from VC to component creation request */
2612 -struct mmal_msg_component_create_reply {
2613 - u32 status; /* enum mmal_msg_status - how does this differ to
2614 - * the one in the header?
2615 - */
2616 - u32 component_handle; /* VideoCore handle for component */
2617 - u32 input_num; /* Number of input ports */
2618 - u32 output_num; /* Number of output ports */
2619 - u32 clock_num; /* Number of clock ports */
2620 -};
2621 -
2622 -/* request to VC to destroy a component */
2623 -struct mmal_msg_component_destroy {
2624 - u32 component_handle;
2625 -};
2626 -
2627 -struct mmal_msg_component_destroy_reply {
2628 - u32 status; /* The component destruction status */
2629 -};
2630 -
2631 -/* request and reply to VC to enable a component */
2632 -struct mmal_msg_component_enable {
2633 - u32 component_handle;
2634 -};
2635 -
2636 -struct mmal_msg_component_enable_reply {
2637 - u32 status; /* The component enable status */
2638 -};
2639 -
2640 -/* request and reply to VC to disable a component */
2641 -struct mmal_msg_component_disable {
2642 - u32 component_handle;
2643 -};
2644 -
2645 -struct mmal_msg_component_disable_reply {
2646 - u32 status; /* The component disable status */
2647 -};
2648 -
2649 -/* request to VC to get port information */
2650 -struct mmal_msg_port_info_get {
2651 - u32 component_handle; /* component handle port is associated with */
2652 - u32 port_type; /* enum mmal_msg_port_type */
2653 - u32 index; /* port index to query */
2654 -};
2655 -
2656 -/* reply from VC to get port info request */
2657 -struct mmal_msg_port_info_get_reply {
2658 - u32 status; /* enum mmal_msg_status */
2659 - u32 component_handle; /* component handle port is associated with */
2660 - u32 port_type; /* enum mmal_msg_port_type */
2661 - u32 port_index; /* port indexed in query */
2662 - s32 found; /* unused */
2663 - u32 port_handle; /* Handle to use for this port */
2664 - struct mmal_port port;
2665 - struct mmal_es_format format; /* elementary stream format */
2666 - union mmal_es_specific_format es; /* es type specific data */
2667 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */
2668 -};
2669 -
2670 -/* request to VC to set port information */
2671 -struct mmal_msg_port_info_set {
2672 - u32 component_handle;
2673 - u32 port_type; /* enum mmal_msg_port_type */
2674 - u32 port_index; /* port indexed in query */
2675 - struct mmal_port port;
2676 - struct mmal_es_format format;
2677 - union mmal_es_specific_format es;
2678 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
2679 -};
2680 -
2681 -/* reply from VC to port info set request */
2682 -struct mmal_msg_port_info_set_reply {
2683 - u32 status;
2684 - u32 component_handle; /* component handle port is associated with */
2685 - u32 port_type; /* enum mmal_msg_port_type */
2686 - u32 index; /* port indexed in query */
2687 - s32 found; /* unused */
2688 - u32 port_handle; /* Handle to use for this port */
2689 - struct mmal_port port;
2690 - struct mmal_es_format format;
2691 - union mmal_es_specific_format es;
2692 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
2693 -};
2694 -
2695 -/* port action requests that take a mmal_port as a parameter */
2696 -struct mmal_msg_port_action_port {
2697 - u32 component_handle;
2698 - u32 port_handle;
2699 - u32 action; /* enum mmal_msg_port_action_type */
2700 - struct mmal_port port;
2701 -};
2702 -
2703 -/* port action requests that take handles as a parameter */
2704 -struct mmal_msg_port_action_handle {
2705 - u32 component_handle;
2706 - u32 port_handle;
2707 - u32 action; /* enum mmal_msg_port_action_type */
2708 - u32 connect_component_handle;
2709 - u32 connect_port_handle;
2710 -};
2711 -
2712 -struct mmal_msg_port_action_reply {
2713 - u32 status; /* The port action operation status */
2714 -};
2715 -
2716 -/* MMAL buffer transfer */
2717 -
2718 -/* Size of space reserved in a buffer message for short messages. */
2719 -#define MMAL_VC_SHORT_DATA 128
2720 -
2721 -/* Signals that the current payload is the end of the stream of data */
2722 -#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0)
2723 -/* Signals that the start of the current payload starts a frame */
2724 -#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1)
2725 -/* Signals that the end of the current payload ends a frame */
2726 -#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2)
2727 -/* Signals that the current payload contains only complete frames (>1) */
2728 -#define MMAL_BUFFER_HEADER_FLAG_FRAME \
2729 - (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \
2730 - MMAL_BUFFER_HEADER_FLAG_FRAME_END)
2731 -/* Signals that the current payload is a keyframe (i.e. self decodable) */
2732 -#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3)
2733 -/*
2734 - * Signals a discontinuity in the stream of data (e.g. after a seek).
2735 - * Can be used for instance by a decoder to reset its state
2736 - */
2737 -#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4)
2738 -/*
2739 - * Signals a buffer containing some kind of config data for the component
2740 - * (e.g. codec config data)
2741 - */
2742 -#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5)
2743 -/* Signals an encrypted payload */
2744 -#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6)
2745 -/* Signals a buffer containing side information */
2746 -#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7)
2747 -/*
2748 - * Signals a buffer which is the snapshot/postview image from a stills
2749 - * capture
2750 - */
2751 -#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8)
2752 -/* Signals a buffer which contains data known to be corrupted */
2753 -#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9)
2754 -/* Signals that a buffer failed to be transmitted */
2755 -#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10)
2756 -
2757 -struct mmal_driver_buffer {
2758 - u32 magic;
2759 - u32 component_handle;
2760 - u32 port_handle;
2761 - u32 client_context;
2762 -};
2763 -
2764 -/* buffer header */
2765 -struct mmal_buffer_header {
2766 - u32 next; /* next header */
2767 - u32 priv; /* framework private data */
2768 - u32 cmd;
2769 - u32 data;
2770 - u32 alloc_size;
2771 - u32 length;
2772 - u32 offset;
2773 - u32 flags;
2774 - s64 pts;
2775 - s64 dts;
2776 - u32 type;
2777 - u32 user_data;
2778 -};
2779 -
2780 -struct mmal_buffer_header_type_specific {
2781 - union {
2782 - struct {
2783 - u32 planes;
2784 - u32 offset[4];
2785 - u32 pitch[4];
2786 - u32 flags;
2787 - } video;
2788 - } u;
2789 -};
2790 -
2791 -struct mmal_msg_buffer_from_host {
2792 - /*
2793 - *The front 32 bytes of the buffer header are copied
2794 - * back to us in the reply to allow for context. This
2795 - * area is used to store two mmal_driver_buffer structures to
2796 - * allow for multiple concurrent service users.
2797 - */
2798 - /* control data */
2799 - struct mmal_driver_buffer drvbuf;
2800 -
2801 - /* referenced control data for passthrough buffer management */
2802 - struct mmal_driver_buffer drvbuf_ref;
2803 - struct mmal_buffer_header buffer_header; /* buffer header itself */
2804 - struct mmal_buffer_header_type_specific buffer_header_type_specific;
2805 - s32 is_zero_copy;
2806 - s32 has_reference;
2807 -
2808 - /* allows short data to be xfered in control message */
2809 - u32 payload_in_message;
2810 - u8 short_data[MMAL_VC_SHORT_DATA];
2811 -};
2812 -
2813 -/* port parameter setting */
2814 -
2815 -#define MMAL_WORKER_PORT_PARAMETER_SPACE 96
2816 -
2817 -struct mmal_msg_port_parameter_set {
2818 - u32 component_handle; /* component */
2819 - u32 port_handle; /* port */
2820 - u32 id; /* Parameter ID */
2821 - u32 size; /* Parameter size */
2822 - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
2823 -};
2824 -
2825 -struct mmal_msg_port_parameter_set_reply {
2826 - u32 status; /* enum mmal_msg_status todo: how does this
2827 - * differ to the one in the header?
2828 - */
2829 -};
2830 -
2831 -/* port parameter getting */
2832 -
2833 -struct mmal_msg_port_parameter_get {
2834 - u32 component_handle; /* component */
2835 - u32 port_handle; /* port */
2836 - u32 id; /* Parameter ID */
2837 - u32 size; /* Parameter size */
2838 -};
2839 -
2840 -struct mmal_msg_port_parameter_get_reply {
2841 - u32 status; /* Status of mmal_port_parameter_get call */
2842 - u32 id; /* Parameter ID */
2843 - u32 size; /* Parameter size */
2844 - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
2845 -};
2846 -
2847 -/* event messages */
2848 -#define MMAL_WORKER_EVENT_SPACE 256
2849 -
2850 -struct mmal_msg_event_to_host {
2851 - u32 client_component; /* component context */
2852 -
2853 - u32 port_type;
2854 - u32 port_num;
2855 -
2856 - u32 cmd;
2857 - u32 length;
2858 - u8 data[MMAL_WORKER_EVENT_SPACE];
2859 - u32 delayed_buffer;
2860 -};
2861 -
2862 -/* all mmal messages are serialised through this structure */
2863 -struct mmal_msg {
2864 - /* header */
2865 - struct mmal_msg_header h;
2866 - /* payload */
2867 - union {
2868 - struct mmal_msg_version version;
2869 -
2870 - struct mmal_msg_component_create component_create;
2871 - struct mmal_msg_component_create_reply component_create_reply;
2872 -
2873 - struct mmal_msg_component_destroy component_destroy;
2874 - struct mmal_msg_component_destroy_reply component_destroy_reply;
2875 -
2876 - struct mmal_msg_component_enable component_enable;
2877 - struct mmal_msg_component_enable_reply component_enable_reply;
2878 -
2879 - struct mmal_msg_component_disable component_disable;
2880 - struct mmal_msg_component_disable_reply component_disable_reply;
2881 -
2882 - struct mmal_msg_port_info_get port_info_get;
2883 - struct mmal_msg_port_info_get_reply port_info_get_reply;
2884 -
2885 - struct mmal_msg_port_info_set port_info_set;
2886 - struct mmal_msg_port_info_set_reply port_info_set_reply;
2887 -
2888 - struct mmal_msg_port_action_port port_action_port;
2889 - struct mmal_msg_port_action_handle port_action_handle;
2890 - struct mmal_msg_port_action_reply port_action_reply;
2891 -
2892 - struct mmal_msg_buffer_from_host buffer_from_host;
2893 -
2894 - struct mmal_msg_port_parameter_set port_parameter_set;
2895 - struct mmal_msg_port_parameter_set_reply
2896 - port_parameter_set_reply;
2897 - struct mmal_msg_port_parameter_get
2898 - port_parameter_get;
2899 - struct mmal_msg_port_parameter_get_reply
2900 - port_parameter_get_reply;
2901 -
2902 - struct mmal_msg_event_to_host event_to_host;
2903 -
2904 - u8 payload[MMAL_MSG_MAX_PAYLOAD];
2905 - } u;
2906 -};
2907 -#endif
2908 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h
2909 +++ /dev/null
2910 @@ -1,755 +0,0 @@
2911 -/* SPDX-License-Identifier: GPL-2.0 */
2912 -/*
2913 - * Broadcom BM2835 V4L2 driver
2914 - *
2915 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2916 - *
2917 - * Authors: Vincent Sanders @ Collabora
2918 - * Dave Stevenson @ Broadcom
2919 - * (now dave.stevenson@raspberrypi.org)
2920 - * Simon Mellor @ Broadcom
2921 - * Luke Diamand @ Broadcom
2922 - */
2923 -
2924 -/* common parameters */
2925 -
2926 -/** @name Parameter groups
2927 - * Parameters are divided into groups, and then allocated sequentially within
2928 - * a group using an enum.
2929 - * @{
2930 - */
2931 -
2932 -#ifndef MMAL_PARAMETERS_H
2933 -#define MMAL_PARAMETERS_H
2934 -
2935 -/** Common parameter ID group, used with many types of component. */
2936 -#define MMAL_PARAMETER_GROUP_COMMON (0 << 16)
2937 -/** Camera-specific parameter ID group. */
2938 -#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16)
2939 -/** Video-specific parameter ID group. */
2940 -#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16)
2941 -/** Audio-specific parameter ID group. */
2942 -#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16)
2943 -/** Clock-specific parameter ID group. */
2944 -#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16)
2945 -/** Miracast-specific parameter ID group. */
2946 -#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16)
2947 -
2948 -/* Common parameters */
2949 -enum mmal_parameter_common_type {
2950 - /**< Never a valid parameter ID */
2951 - MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON,
2952 -
2953 - /**< MMAL_PARAMETER_ENCODING_T */
2954 - MMAL_PARAMETER_SUPPORTED_ENCODINGS,
2955 - /**< MMAL_PARAMETER_URI_T */
2956 - MMAL_PARAMETER_URI,
2957 - /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */
2958 - MMAL_PARAMETER_CHANGE_EVENT_REQUEST,
2959 - /** MMAL_PARAMETER_BOOLEAN_T */
2960 - MMAL_PARAMETER_ZERO_COPY,
2961 - /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */
2962 - MMAL_PARAMETER_BUFFER_REQUIREMENTS,
2963 - /**< MMAL_PARAMETER_STATISTICS_T */
2964 - MMAL_PARAMETER_STATISTICS,
2965 - /**< MMAL_PARAMETER_CORE_STATISTICS_T */
2966 - MMAL_PARAMETER_CORE_STATISTICS,
2967 - /**< MMAL_PARAMETER_MEM_USAGE_T */
2968 - MMAL_PARAMETER_MEM_USAGE,
2969 - /**< MMAL_PARAMETER_UINT32_T */
2970 - MMAL_PARAMETER_BUFFER_FLAG_FILTER,
2971 - /**< MMAL_PARAMETER_SEEK_T */
2972 - MMAL_PARAMETER_SEEK,
2973 - /**< MMAL_PARAMETER_BOOLEAN_T */
2974 - MMAL_PARAMETER_POWERMON_ENABLE,
2975 - /**< MMAL_PARAMETER_LOGGING_T */
2976 - MMAL_PARAMETER_LOGGING,
2977 - /**< MMAL_PARAMETER_UINT64_T */
2978 - MMAL_PARAMETER_SYSTEM_TIME,
2979 - /**< MMAL_PARAMETER_BOOLEAN_T */
2980 - MMAL_PARAMETER_NO_IMAGE_PADDING,
2981 -};
2982 -
2983 -/* camera parameters */
2984 -
2985 -enum mmal_parameter_camera_type {
2986 - /* 0 */
2987 - /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */
2988 - MMAL_PARAMETER_THUMBNAIL_CONFIGURATION =
2989 - MMAL_PARAMETER_GROUP_CAMERA,
2990 - /**< Unused? */
2991 - MMAL_PARAMETER_CAPTURE_QUALITY,
2992 - /**< @ref MMAL_PARAMETER_INT32_T */
2993 - MMAL_PARAMETER_ROTATION,
2994 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
2995 - MMAL_PARAMETER_EXIF_DISABLE,
2996 - /**< @ref MMAL_PARAMETER_EXIF_T */
2997 - MMAL_PARAMETER_EXIF,
2998 - /**< @ref MMAL_PARAM_AWBMODE_T */
2999 - MMAL_PARAMETER_AWB_MODE,
3000 - /**< @ref MMAL_PARAMETER_IMAGEFX_T */
3001 - MMAL_PARAMETER_IMAGE_EFFECT,
3002 - /**< @ref MMAL_PARAMETER_COLOURFX_T */
3003 - MMAL_PARAMETER_COLOUR_EFFECT,
3004 - /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */
3005 - MMAL_PARAMETER_FLICKER_AVOID,
3006 - /**< @ref MMAL_PARAMETER_FLASH_T */
3007 - MMAL_PARAMETER_FLASH,
3008 - /**< @ref MMAL_PARAMETER_REDEYE_T */
3009 - MMAL_PARAMETER_REDEYE,
3010 - /**< @ref MMAL_PARAMETER_FOCUS_T */
3011 - MMAL_PARAMETER_FOCUS,
3012 - /**< Unused? */
3013 - MMAL_PARAMETER_FOCAL_LENGTHS,
3014 - /**< @ref MMAL_PARAMETER_INT32_T */
3015 - MMAL_PARAMETER_EXPOSURE_COMP,
3016 - /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */
3017 - MMAL_PARAMETER_ZOOM,
3018 - /**< @ref MMAL_PARAMETER_MIRROR_T */
3019 - MMAL_PARAMETER_MIRROR,
3020 -
3021 - /* 0x10 */
3022 - /**< @ref MMAL_PARAMETER_UINT32_T */
3023 - MMAL_PARAMETER_CAMERA_NUM,
3024 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3025 - MMAL_PARAMETER_CAPTURE,
3026 - /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */
3027 - MMAL_PARAMETER_EXPOSURE_MODE,
3028 - /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */
3029 - MMAL_PARAMETER_EXP_METERING_MODE,
3030 - /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */
3031 - MMAL_PARAMETER_FOCUS_STATUS,
3032 - /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */
3033 - MMAL_PARAMETER_CAMERA_CONFIG,
3034 - /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */
3035 - MMAL_PARAMETER_CAPTURE_STATUS,
3036 - /**< @ref MMAL_PARAMETER_FACE_TRACK_T */
3037 - MMAL_PARAMETER_FACE_TRACK,
3038 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3039 - MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS,
3040 - /**< @ref MMAL_PARAMETER_UINT32_T */
3041 - MMAL_PARAMETER_JPEG_Q_FACTOR,
3042 - /**< @ref MMAL_PARAMETER_FRAME_RATE_T */
3043 - MMAL_PARAMETER_FRAME_RATE,
3044 - /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */
3045 - MMAL_PARAMETER_USE_STC,
3046 - /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */
3047 - MMAL_PARAMETER_CAMERA_INFO,
3048 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3049 - MMAL_PARAMETER_VIDEO_STABILISATION,
3050 - /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */
3051 - MMAL_PARAMETER_FACE_TRACK_RESULTS,
3052 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3053 - MMAL_PARAMETER_ENABLE_RAW_CAPTURE,
3054 -
3055 - /* 0x20 */
3056 - /**< @ref MMAL_PARAMETER_URI_T */
3057 - MMAL_PARAMETER_DPF_FILE,
3058 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3059 - MMAL_PARAMETER_ENABLE_DPF_FILE,
3060 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3061 - MMAL_PARAMETER_DPF_FAIL_IS_FATAL,
3062 - /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */
3063 - MMAL_PARAMETER_CAPTURE_MODE,
3064 - /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */
3065 - MMAL_PARAMETER_FOCUS_REGIONS,
3066 - /**< @ref MMAL_PARAMETER_INPUT_CROP_T */
3067 - MMAL_PARAMETER_INPUT_CROP,
3068 - /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */
3069 - MMAL_PARAMETER_SENSOR_INFORMATION,
3070 - /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */
3071 - MMAL_PARAMETER_FLASH_SELECT,
3072 - /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */
3073 - MMAL_PARAMETER_FIELD_OF_VIEW,
3074 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3075 - MMAL_PARAMETER_HIGH_DYNAMIC_RANGE,
3076 - /**< @ref MMAL_PARAMETER_DRC_T */
3077 - MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION,
3078 - /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */
3079 - MMAL_PARAMETER_ALGORITHM_CONTROL,
3080 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
3081 - MMAL_PARAMETER_SHARPNESS,
3082 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
3083 - MMAL_PARAMETER_CONTRAST,
3084 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
3085 - MMAL_PARAMETER_BRIGHTNESS,
3086 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
3087 - MMAL_PARAMETER_SATURATION,
3088 -
3089 - /* 0x30 */
3090 - /**< @ref MMAL_PARAMETER_UINT32_T */
3091 - MMAL_PARAMETER_ISO,
3092 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3093 - MMAL_PARAMETER_ANTISHAKE,
3094 - /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */
3095 - MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,
3096 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3097 - MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
3098 - /** @ref MMAL_PARAMETER_UINT32_T */
3099 - MMAL_PARAMETER_CAMERA_MIN_ISO,
3100 - /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */
3101 - MMAL_PARAMETER_CAMERA_USE_CASE,
3102 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3103 - MMAL_PARAMETER_CAPTURE_STATS_PASS,
3104 - /** @ref MMAL_PARAMETER_UINT32_T */
3105 - MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG,
3106 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3107 - MMAL_PARAMETER_ENABLE_REGISTER_FILE,
3108 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3109 - MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
3110 - /** @ref MMAL_PARAMETER_CONFIGFILE_T */
3111 - MMAL_PARAMETER_CONFIGFILE_REGISTERS,
3112 - /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */
3113 - MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS,
3114 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3115 - MMAL_PARAMETER_JPEG_ATTACH_LOG,
3116 - /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */
3117 - MMAL_PARAMETER_ZERO_SHUTTER_LAG,
3118 - /**< @ref MMAL_PARAMETER_FPS_RANGE_T */
3119 - MMAL_PARAMETER_FPS_RANGE,
3120 - /**< @ref MMAL_PARAMETER_INT32_T */
3121 - MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP,
3122 -
3123 - /* 0x40 */
3124 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3125 - MMAL_PARAMETER_SW_SHARPEN_DISABLE,
3126 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3127 - MMAL_PARAMETER_FLASH_REQUIRED,
3128 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3129 - MMAL_PARAMETER_SW_SATURATION_DISABLE,
3130 - /**< Takes a @ref MMAL_PARAMETER_UINT32_T */
3131 - MMAL_PARAMETER_SHUTTER_SPEED,
3132 - /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */
3133 - MMAL_PARAMETER_CUSTOM_AWB_GAINS,
3134 -};
3135 -
3136 -struct mmal_parameter_rational {
3137 - s32 num; /**< Numerator */
3138 - s32 den; /**< Denominator */
3139 -};
3140 -
3141 -enum mmal_parameter_camera_config_timestamp_mode {
3142 - MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */
3143 - MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value
3144 - * for the frame timestamp
3145 - */
3146 - MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp
3147 - * but subtract the
3148 - * timestamp of the first
3149 - * frame sent to give a
3150 - * zero based timestamp.
3151 - */
3152 -};
3153 -
3154 -struct mmal_parameter_fps_range {
3155 - /**< Low end of the permitted framerate range */
3156 - struct mmal_parameter_rational fps_low;
3157 - /**< High end of the permitted framerate range */
3158 - struct mmal_parameter_rational fps_high;
3159 -};
3160 -
3161 -/* camera configuration parameter */
3162 -struct mmal_parameter_camera_config {
3163 - /* Parameters for setting up the image pools */
3164 - u32 max_stills_w; /* Max size of stills capture */
3165 - u32 max_stills_h;
3166 - u32 stills_yuv422; /* Allow YUV422 stills capture */
3167 - u32 one_shot_stills; /* Continuous or one shot stills captures. */
3168 -
3169 - u32 max_preview_video_w; /* Max size of the preview or video
3170 - * capture frames
3171 - */
3172 - u32 max_preview_video_h;
3173 - u32 num_preview_video_frames;
3174 -
3175 - /** Sets the height of the circular buffer for stills capture. */
3176 - u32 stills_capture_circular_buffer_height;
3177 -
3178 - /** Allows preview/encode to resume as fast as possible after the stills
3179 - * input frame has been received, and then processes the still frame in
3180 - * the background whilst preview/encode has resumed.
3181 - * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE.
3182 - */
3183 - u32 fast_preview_resume;
3184 -
3185 - /** Selects algorithm for timestamping frames if
3186 - * there is no clock component connected.
3187 - * enum mmal_parameter_camera_config_timestamp_mode
3188 - */
3189 - s32 use_stc_timestamp;
3190 -};
3191 -
3192 -enum mmal_parameter_exposuremode {
3193 - MMAL_PARAM_EXPOSUREMODE_OFF,
3194 - MMAL_PARAM_EXPOSUREMODE_AUTO,
3195 - MMAL_PARAM_EXPOSUREMODE_NIGHT,
3196 - MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
3197 - MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
3198 - MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
3199 - MMAL_PARAM_EXPOSUREMODE_SPORTS,
3200 - MMAL_PARAM_EXPOSUREMODE_SNOW,
3201 - MMAL_PARAM_EXPOSUREMODE_BEACH,
3202 - MMAL_PARAM_EXPOSUREMODE_VERYLONG,
3203 - MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
3204 - MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
3205 - MMAL_PARAM_EXPOSUREMODE_FIREWORKS,
3206 -};
3207 -
3208 -enum mmal_parameter_exposuremeteringmode {
3209 - MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
3210 - MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
3211 - MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
3212 - MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX,
3213 -};
3214 -
3215 -enum mmal_parameter_awbmode {
3216 - MMAL_PARAM_AWBMODE_OFF,
3217 - MMAL_PARAM_AWBMODE_AUTO,
3218 - MMAL_PARAM_AWBMODE_SUNLIGHT,
3219 - MMAL_PARAM_AWBMODE_CLOUDY,
3220 - MMAL_PARAM_AWBMODE_SHADE,
3221 - MMAL_PARAM_AWBMODE_TUNGSTEN,
3222 - MMAL_PARAM_AWBMODE_FLUORESCENT,
3223 - MMAL_PARAM_AWBMODE_INCANDESCENT,
3224 - MMAL_PARAM_AWBMODE_FLASH,
3225 - MMAL_PARAM_AWBMODE_HORIZON,
3226 -};
3227 -
3228 -enum mmal_parameter_imagefx {
3229 - MMAL_PARAM_IMAGEFX_NONE,
3230 - MMAL_PARAM_IMAGEFX_NEGATIVE,
3231 - MMAL_PARAM_IMAGEFX_SOLARIZE,
3232 - MMAL_PARAM_IMAGEFX_POSTERIZE,
3233 - MMAL_PARAM_IMAGEFX_WHITEBOARD,
3234 - MMAL_PARAM_IMAGEFX_BLACKBOARD,
3235 - MMAL_PARAM_IMAGEFX_SKETCH,
3236 - MMAL_PARAM_IMAGEFX_DENOISE,
3237 - MMAL_PARAM_IMAGEFX_EMBOSS,
3238 - MMAL_PARAM_IMAGEFX_OILPAINT,
3239 - MMAL_PARAM_IMAGEFX_HATCH,
3240 - MMAL_PARAM_IMAGEFX_GPEN,
3241 - MMAL_PARAM_IMAGEFX_PASTEL,
3242 - MMAL_PARAM_IMAGEFX_WATERCOLOUR,
3243 - MMAL_PARAM_IMAGEFX_FILM,
3244 - MMAL_PARAM_IMAGEFX_BLUR,
3245 - MMAL_PARAM_IMAGEFX_SATURATION,
3246 - MMAL_PARAM_IMAGEFX_COLOURSWAP,
3247 - MMAL_PARAM_IMAGEFX_WASHEDOUT,
3248 - MMAL_PARAM_IMAGEFX_POSTERISE,
3249 - MMAL_PARAM_IMAGEFX_COLOURPOINT,
3250 - MMAL_PARAM_IMAGEFX_COLOURBALANCE,
3251 - MMAL_PARAM_IMAGEFX_CARTOON,
3252 -};
3253 -
3254 -enum MMAL_PARAM_FLICKERAVOID_T {
3255 - MMAL_PARAM_FLICKERAVOID_OFF,
3256 - MMAL_PARAM_FLICKERAVOID_AUTO,
3257 - MMAL_PARAM_FLICKERAVOID_50HZ,
3258 - MMAL_PARAM_FLICKERAVOID_60HZ,
3259 - MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF
3260 -};
3261 -
3262 -struct mmal_parameter_awbgains {
3263 - struct mmal_parameter_rational r_gain; /**< Red gain */
3264 - struct mmal_parameter_rational b_gain; /**< Blue gain */
3265 -};
3266 -
3267 -/** Manner of video rate control */
3268 -enum mmal_parameter_rate_control_mode {
3269 - MMAL_VIDEO_RATECONTROL_DEFAULT,
3270 - MMAL_VIDEO_RATECONTROL_VARIABLE,
3271 - MMAL_VIDEO_RATECONTROL_CONSTANT,
3272 - MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES,
3273 - MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES
3274 -};
3275 -
3276 -enum mmal_video_profile {
3277 - MMAL_VIDEO_PROFILE_H263_BASELINE,
3278 - MMAL_VIDEO_PROFILE_H263_H320CODING,
3279 - MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE,
3280 - MMAL_VIDEO_PROFILE_H263_ISWV2,
3281 - MMAL_VIDEO_PROFILE_H263_ISWV3,
3282 - MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION,
3283 - MMAL_VIDEO_PROFILE_H263_INTERNET,
3284 - MMAL_VIDEO_PROFILE_H263_INTERLACE,
3285 - MMAL_VIDEO_PROFILE_H263_HIGHLATENCY,
3286 - MMAL_VIDEO_PROFILE_MP4V_SIMPLE,
3287 - MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE,
3288 - MMAL_VIDEO_PROFILE_MP4V_CORE,
3289 - MMAL_VIDEO_PROFILE_MP4V_MAIN,
3290 - MMAL_VIDEO_PROFILE_MP4V_NBIT,
3291 - MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE,
3292 - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE,
3293 - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA,
3294 - MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED,
3295 - MMAL_VIDEO_PROFILE_MP4V_HYBRID,
3296 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME,
3297 - MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE,
3298 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING,
3299 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE,
3300 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE,
3301 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE,
3302 - MMAL_VIDEO_PROFILE_H264_BASELINE,
3303 - MMAL_VIDEO_PROFILE_H264_MAIN,
3304 - MMAL_VIDEO_PROFILE_H264_EXTENDED,
3305 - MMAL_VIDEO_PROFILE_H264_HIGH,
3306 - MMAL_VIDEO_PROFILE_H264_HIGH10,
3307 - MMAL_VIDEO_PROFILE_H264_HIGH422,
3308 - MMAL_VIDEO_PROFILE_H264_HIGH444,
3309 - MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE,
3310 - MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF
3311 -};
3312 -
3313 -enum mmal_video_level {
3314 - MMAL_VIDEO_LEVEL_H263_10,
3315 - MMAL_VIDEO_LEVEL_H263_20,
3316 - MMAL_VIDEO_LEVEL_H263_30,
3317 - MMAL_VIDEO_LEVEL_H263_40,
3318 - MMAL_VIDEO_LEVEL_H263_45,
3319 - MMAL_VIDEO_LEVEL_H263_50,
3320 - MMAL_VIDEO_LEVEL_H263_60,
3321 - MMAL_VIDEO_LEVEL_H263_70,
3322 - MMAL_VIDEO_LEVEL_MP4V_0,
3323 - MMAL_VIDEO_LEVEL_MP4V_0b,
3324 - MMAL_VIDEO_LEVEL_MP4V_1,
3325 - MMAL_VIDEO_LEVEL_MP4V_2,
3326 - MMAL_VIDEO_LEVEL_MP4V_3,
3327 - MMAL_VIDEO_LEVEL_MP4V_4,
3328 - MMAL_VIDEO_LEVEL_MP4V_4a,
3329 - MMAL_VIDEO_LEVEL_MP4V_5,
3330 - MMAL_VIDEO_LEVEL_MP4V_6,
3331 - MMAL_VIDEO_LEVEL_H264_1,
3332 - MMAL_VIDEO_LEVEL_H264_1b,
3333 - MMAL_VIDEO_LEVEL_H264_11,
3334 - MMAL_VIDEO_LEVEL_H264_12,
3335 - MMAL_VIDEO_LEVEL_H264_13,
3336 - MMAL_VIDEO_LEVEL_H264_2,
3337 - MMAL_VIDEO_LEVEL_H264_21,
3338 - MMAL_VIDEO_LEVEL_H264_22,
3339 - MMAL_VIDEO_LEVEL_H264_3,
3340 - MMAL_VIDEO_LEVEL_H264_31,
3341 - MMAL_VIDEO_LEVEL_H264_32,
3342 - MMAL_VIDEO_LEVEL_H264_4,
3343 - MMAL_VIDEO_LEVEL_H264_41,
3344 - MMAL_VIDEO_LEVEL_H264_42,
3345 - MMAL_VIDEO_LEVEL_H264_5,
3346 - MMAL_VIDEO_LEVEL_H264_51,
3347 - MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF
3348 -};
3349 -
3350 -struct mmal_parameter_video_profile {
3351 - enum mmal_video_profile profile;
3352 - enum mmal_video_level level;
3353 -};
3354 -
3355 -/* video parameters */
3356 -
3357 -enum mmal_parameter_video_type {
3358 - /** @ref MMAL_DISPLAYREGION_T */
3359 - MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO,
3360 -
3361 - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
3362 - MMAL_PARAMETER_SUPPORTED_PROFILES,
3363 -
3364 - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
3365 - MMAL_PARAMETER_PROFILE,
3366 -
3367 - /** @ref MMAL_PARAMETER_UINT32_T */
3368 - MMAL_PARAMETER_INTRAPERIOD,
3369 -
3370 - /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */
3371 - MMAL_PARAMETER_RATECONTROL,
3372 -
3373 - /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */
3374 - MMAL_PARAMETER_NALUNITFORMAT,
3375 -
3376 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3377 - MMAL_PARAMETER_MINIMISE_FRAGMENTATION,
3378 -
3379 - /** @ref MMAL_PARAMETER_UINT32_T.
3380 - * Setting the value to zero resets to the default (one slice per
3381 - * frame).
3382 - */
3383 - MMAL_PARAMETER_MB_ROWS_PER_SLICE,
3384 -
3385 - /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */
3386 - MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION,
3387 -
3388 - /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */
3389 - MMAL_PARAMETER_VIDEO_EEDE_ENABLE,
3390 -
3391 - /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */
3392 - MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE,
3393 -
3394 - /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */
3395 - MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME,
3396 - /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */
3397 - MMAL_PARAMETER_VIDEO_INTRA_REFRESH,
3398 -
3399 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
3400 - MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT,
3401 -
3402 - /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */
3403 - MMAL_PARAMETER_VIDEO_BIT_RATE,
3404 -
3405 - /** @ref MMAL_PARAMETER_FRAME_RATE_T */
3406 - MMAL_PARAMETER_VIDEO_FRAME_RATE,
3407 -
3408 - /** @ref MMAL_PARAMETER_UINT32_T. */
3409 - MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
3410 -
3411 - /** @ref MMAL_PARAMETER_UINT32_T. */
3412 - MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
3413 -
3414 - /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */
3415 - MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL,
3416 -
3417 - MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */
3418 - /** @ref MMAL_PARAMETER_UINT32_T.
3419 - * Changing this parameter from the default can reduce frame rate
3420 - * because image buffers need to be re-pitched.
3421 - */
3422 - MMAL_PARAMETER_VIDEO_ALIGN_HORIZ,
3423 -
3424 - /** @ref MMAL_PARAMETER_UINT32_T.
3425 - * Changing this parameter from the default can reduce frame rate
3426 - * because image buffers need to be re-pitched.
3427 - */
3428 - MMAL_PARAMETER_VIDEO_ALIGN_VERT,
3429 -
3430 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
3431 - MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES,
3432 -
3433 - /** @ref MMAL_PARAMETER_UINT32_T. */
3434 - MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT,
3435 -
3436 - /**< @ref MMAL_PARAMETER_UINT32_T. */
3437 - MMAL_PARAMETER_VIDEO_ENCODE_QP_P,
3438 -
3439 - /**< @ref MMAL_PARAMETER_UINT32_T. */
3440 - MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT,
3441 -
3442 - /** @ref MMAL_PARAMETER_UINT32_T */
3443 - MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS,
3444 -
3445 - /** @ref MMAL_PARAMETER_UINT32_T. */
3446 - MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE,
3447 -
3448 - /* H264 specific parameters */
3449 -
3450 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
3451 - MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC,
3452 -
3453 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
3454 - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY,
3455 -
3456 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
3457 - MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS,
3458 -
3459 - /** @ref MMAL_PARAMETER_UINT32_T. */
3460 - MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC,
3461 -
3462 - /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */
3463 - MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE,
3464 -
3465 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3466 - MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN,
3467 -
3468 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3469 - MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP,
3470 -
3471 - /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */
3472 - MMAL_PARAMETER_VIDEO_DRM_INIT_INFO,
3473 -
3474 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3475 - MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO,
3476 -
3477 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
3478 - MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT,
3479 -
3480 - /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */
3481 - MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
3482 -
3483 - /** @ref MMAL_PARAMETER_BYTES_T */
3484 - MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
3485 -
3486 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3487 - MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
3488 -
3489 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3490 - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
3491 -
3492 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
3493 - MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
3494 -};
3495 -
3496 -/** Valid mirror modes */
3497 -enum mmal_parameter_mirror {
3498 - MMAL_PARAM_MIRROR_NONE,
3499 - MMAL_PARAM_MIRROR_VERTICAL,
3500 - MMAL_PARAM_MIRROR_HORIZONTAL,
3501 - MMAL_PARAM_MIRROR_BOTH,
3502 -};
3503 -
3504 -enum mmal_parameter_displaytransform {
3505 - MMAL_DISPLAY_ROT0 = 0,
3506 - MMAL_DISPLAY_MIRROR_ROT0 = 1,
3507 - MMAL_DISPLAY_MIRROR_ROT180 = 2,
3508 - MMAL_DISPLAY_ROT180 = 3,
3509 - MMAL_DISPLAY_MIRROR_ROT90 = 4,
3510 - MMAL_DISPLAY_ROT270 = 5,
3511 - MMAL_DISPLAY_ROT90 = 6,
3512 - MMAL_DISPLAY_MIRROR_ROT270 = 7,
3513 -};
3514 -
3515 -enum mmal_parameter_displaymode {
3516 - MMAL_DISPLAY_MODE_FILL = 0,
3517 - MMAL_DISPLAY_MODE_LETTERBOX = 1,
3518 -};
3519 -
3520 -enum mmal_parameter_displayset {
3521 - MMAL_DISPLAY_SET_NONE = 0,
3522 - MMAL_DISPLAY_SET_NUM = 1,
3523 - MMAL_DISPLAY_SET_FULLSCREEN = 2,
3524 - MMAL_DISPLAY_SET_TRANSFORM = 4,
3525 - MMAL_DISPLAY_SET_DEST_RECT = 8,
3526 - MMAL_DISPLAY_SET_SRC_RECT = 0x10,
3527 - MMAL_DISPLAY_SET_MODE = 0x20,
3528 - MMAL_DISPLAY_SET_PIXEL = 0x40,
3529 - MMAL_DISPLAY_SET_NOASPECT = 0x80,
3530 - MMAL_DISPLAY_SET_LAYER = 0x100,
3531 - MMAL_DISPLAY_SET_COPYPROTECT = 0x200,
3532 - MMAL_DISPLAY_SET_ALPHA = 0x400,
3533 -};
3534 -
3535 -/* rectangle, used lots so it gets its own struct */
3536 -struct vchiq_mmal_rect {
3537 - s32 x;
3538 - s32 y;
3539 - s32 width;
3540 - s32 height;
3541 -};
3542 -
3543 -struct mmal_parameter_displayregion {
3544 - /** Bitfield that indicates which fields are set and should be
3545 - * used. All other fields will maintain their current value.
3546 - * \ref MMAL_DISPLAYSET_T defines the bits that can be
3547 - * combined.
3548 - */
3549 - u32 set;
3550 -
3551 - /** Describes the display output device, with 0 typically
3552 - * being a directly connected LCD display. The actual values
3553 - * will depend on the hardware. Code using hard-wired numbers
3554 - * (e.g. 2) is certain to fail.
3555 - */
3556 -
3557 - u32 display_num;
3558 - /** Indicates that we are using the full device screen area,
3559 - * rather than a window of the display. If zero, then
3560 - * dest_rect is used to specify a region of the display to
3561 - * use.
3562 - */
3563 -
3564 - s32 fullscreen;
3565 - /** Indicates any rotation or flipping used to map frames onto
3566 - * the natural display orientation.
3567 - */
3568 - u32 transform; /* enum mmal_parameter_displaytransform */
3569 -
3570 - /** Where to display the frame within the screen, if
3571 - * fullscreen is zero.
3572 - */
3573 - struct vchiq_mmal_rect dest_rect;
3574 -
3575 - /** Indicates which area of the frame to display. If all
3576 - * values are zero, the whole frame will be used.
3577 - */
3578 - struct vchiq_mmal_rect src_rect;
3579 -
3580 - /** If set to non-zero, indicates that any display scaling
3581 - * should disregard the aspect ratio of the frame region being
3582 - * displayed.
3583 - */
3584 - s32 noaspect;
3585 -
3586 - /** Indicates how the image should be scaled to fit the
3587 - * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates
3588 - * that the image should fill the screen by potentially
3589 - * cropping the frames. Setting \code mode \endcode to \code
3590 - * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the
3591 - * source region should be displayed and black bars added if
3592 - * necessary.
3593 - */
3594 - u32 mode; /* enum mmal_parameter_displaymode */
3595 -
3596 - /** If non-zero, defines the width of a source pixel relative
3597 - * to \code pixel_y \endcode. If zero, then pixels default to
3598 - * being square.
3599 - */
3600 - u32 pixel_x;
3601 -
3602 - /** If non-zero, defines the height of a source pixel relative
3603 - * to \code pixel_x \endcode. If zero, then pixels default to
3604 - * being square.
3605 - */
3606 - u32 pixel_y;
3607 -
3608 - /** Sets the relative depth of the images, with greater values
3609 - * being in front of smaller values.
3610 - */
3611 - u32 layer;
3612 -
3613 - /** Set to non-zero to ensure copy protection is used on
3614 - * output.
3615 - */
3616 - s32 copyprotect_required;
3617 -
3618 - /** Level of opacity of the layer, where zero is fully
3619 - * transparent and 255 is fully opaque.
3620 - */
3621 - u32 alpha;
3622 -};
3623 -
3624 -#define MMAL_MAX_IMAGEFX_PARAMETERS 5
3625 -
3626 -struct mmal_parameter_imagefx_parameters {
3627 - enum mmal_parameter_imagefx effect;
3628 - u32 num_effect_params;
3629 - u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS];
3630 -};
3631 -
3632 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4
3633 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2
3634 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16
3635 -
3636 -struct mmal_parameter_camera_info_camera_t {
3637 - u32 port_id;
3638 - u32 max_width;
3639 - u32 max_height;
3640 - u32 lens_present;
3641 - u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN];
3642 -};
3643 -
3644 -enum mmal_parameter_camera_info_flash_type_t {
3645 - /* Make values explicit to ensure they match values in config ini */
3646 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0,
3647 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1,
3648 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2,
3649 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF
3650 -};
3651 -
3652 -struct mmal_parameter_camera_info_flash_t {
3653 - enum mmal_parameter_camera_info_flash_type_t flash_type;
3654 -};
3655 -
3656 -struct mmal_parameter_camera_info_t {
3657 - u32 num_cameras;
3658 - u32 num_flashes;
3659 - struct mmal_parameter_camera_info_camera_t
3660 - cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS];
3661 - struct mmal_parameter_camera_info_flash_t
3662 - flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES];
3663 -};
3664 -
3665 -#endif
3666 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
3667 +++ /dev/null
3668 @@ -1,166 +0,0 @@
3669 -/* SPDX-License-Identifier: GPL-2.0 */
3670 -/*
3671 - * Broadcom BM2835 V4L2 driver
3672 - *
3673 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
3674 - *
3675 - * Authors: Vincent Sanders @ Collabora
3676 - * Dave Stevenson @ Broadcom
3677 - * (now dave.stevenson@raspberrypi.org)
3678 - * Simon Mellor @ Broadcom
3679 - * Luke Diamand @ Broadcom
3680 - *
3681 - * MMAL interface to VCHIQ message passing
3682 - */
3683 -
3684 -#ifndef MMAL_VCHIQ_H
3685 -#define MMAL_VCHIQ_H
3686 -
3687 -#include "mmal-msg-format.h"
3688 -
3689 -#define MAX_PORT_COUNT 4
3690 -
3691 -/* Maximum size of the format extradata. */
3692 -#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
3693 -
3694 -struct vchiq_mmal_instance;
3695 -
3696 -enum vchiq_mmal_es_type {
3697 - MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
3698 - MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
3699 - MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
3700 - MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
3701 - MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
3702 -};
3703 -
3704 -struct vchiq_mmal_port_buffer {
3705 - unsigned int num; /* number of buffers */
3706 - u32 size; /* size of buffers */
3707 - u32 alignment; /* alignment of buffers */
3708 -};
3709 -
3710 -struct vchiq_mmal_port;
3711 -
3712 -typedef void (*vchiq_mmal_buffer_cb)(
3713 - struct vchiq_mmal_instance *instance,
3714 - struct vchiq_mmal_port *port,
3715 - int status, struct mmal_buffer *buffer,
3716 - unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
3717 -
3718 -struct vchiq_mmal_port {
3719 - bool enabled;
3720 - u32 handle;
3721 - u32 type; /* port type, cached to use on port info set */
3722 - u32 index; /* port index, cached to use on port info set */
3723 -
3724 - /* component port belongs to, allows simple deref */
3725 - struct vchiq_mmal_component *component;
3726 -
3727 - struct vchiq_mmal_port *connected; /* port conencted to */
3728 -
3729 - /* buffer info */
3730 - struct vchiq_mmal_port_buffer minimum_buffer;
3731 - struct vchiq_mmal_port_buffer recommended_buffer;
3732 - struct vchiq_mmal_port_buffer current_buffer;
3733 -
3734 - /* stream format */
3735 - struct mmal_es_format_local format;
3736 - /* elementary stream format */
3737 - union mmal_es_specific_format es;
3738 -
3739 - /* data buffers to fill */
3740 - struct list_head buffers;
3741 - /* lock to serialise adding and removing buffers from list */
3742 - spinlock_t slock;
3743 -
3744 - /* Count of buffers the VPU has yet to return */
3745 - atomic_t buffers_with_vpu;
3746 - /* callback on buffer completion */
3747 - vchiq_mmal_buffer_cb buffer_cb;
3748 - /* callback context */
3749 - void *cb_ctx;
3750 -};
3751 -
3752 -struct vchiq_mmal_component {
3753 - bool enabled;
3754 - u32 handle; /* VideoCore handle for component */
3755 - u32 inputs; /* Number of input ports */
3756 - u32 outputs; /* Number of output ports */
3757 - u32 clocks; /* Number of clock ports */
3758 - struct vchiq_mmal_port control; /* control port */
3759 - struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
3760 - struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
3761 - struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
3762 -};
3763 -
3764 -int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
3765 -int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
3766 -
3767 -/* Initialise a mmal component and its ports
3768 - *
3769 - */
3770 -int vchiq_mmal_component_init(
3771 - struct vchiq_mmal_instance *instance,
3772 - const char *name,
3773 - struct vchiq_mmal_component **component_out);
3774 -
3775 -int vchiq_mmal_component_finalise(
3776 - struct vchiq_mmal_instance *instance,
3777 - struct vchiq_mmal_component *component);
3778 -
3779 -int vchiq_mmal_component_enable(
3780 - struct vchiq_mmal_instance *instance,
3781 - struct vchiq_mmal_component *component);
3782 -
3783 -int vchiq_mmal_component_disable(
3784 - struct vchiq_mmal_instance *instance,
3785 - struct vchiq_mmal_component *component);
3786 -
3787 -/* enable a mmal port
3788 - *
3789 - * enables a port and if a buffer callback provided enque buffer
3790 - * headers as appropriate for the port.
3791 - */
3792 -int vchiq_mmal_port_enable(
3793 - struct vchiq_mmal_instance *instance,
3794 - struct vchiq_mmal_port *port,
3795 - vchiq_mmal_buffer_cb buffer_cb);
3796 -
3797 -/* disable a port
3798 - *
3799 - * disable a port will dequeue any pending buffers
3800 - */
3801 -int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
3802 - struct vchiq_mmal_port *port);
3803 -
3804 -int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
3805 - struct vchiq_mmal_port *port,
3806 - u32 parameter,
3807 - void *value,
3808 - u32 value_size);
3809 -
3810 -int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
3811 - struct vchiq_mmal_port *port,
3812 - u32 parameter,
3813 - void *value,
3814 - u32 *value_size);
3815 -
3816 -int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
3817 - struct vchiq_mmal_port *port);
3818 -
3819 -int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
3820 - struct vchiq_mmal_port *src,
3821 - struct vchiq_mmal_port *dst);
3822 -
3823 -int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
3824 - u32 *major_out,
3825 - u32 *minor_out);
3826 -
3827 -int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
3828 - struct vchiq_mmal_port *port,
3829 - struct mmal_buffer *buf);
3830 -
3831 -int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
3832 - struct mmal_buffer *buf);
3833 -int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
3834 -#endif /* MMAL_VCHIQ_H */
3835 --- /dev/null
3836 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
3837 @@ -0,0 +1,61 @@
3838 +/* SPDX-License-Identifier: GPL-2.0 */
3839 +/*
3840 + * Broadcom BM2835 V4L2 driver
3841 + *
3842 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
3843 + *
3844 + * Authors: Vincent Sanders @ Collabora
3845 + * Dave Stevenson @ Broadcom
3846 + * (now dave.stevenson@raspberrypi.org)
3847 + * Simon Mellor @ Broadcom
3848 + * Luke Diamand @ Broadcom
3849 + *
3850 + * MMAL structures
3851 + *
3852 + */
3853 +#ifndef MMAL_COMMON_H
3854 +#define MMAL_COMMON_H
3855 +
3856 +#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))
3857 +#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
3858 +
3859 +/** Special value signalling that time is not known */
3860 +#define MMAL_TIME_UNKNOWN BIT_ULL(63)
3861 +
3862 +struct mmal_msg_context;
3863 +
3864 +/* mapping between v4l and mmal video modes */
3865 +struct mmal_fmt {
3866 + char *name;
3867 + u32 fourcc; /* v4l2 format id */
3868 + int flags; /* v4l2 flags field */
3869 + u32 mmal;
3870 + int depth;
3871 + u32 mmal_component; /* MMAL component index to be used to encode */
3872 + u32 ybbp; /* depth of first Y plane for planar formats */
3873 + bool remove_padding; /* Does the GPU have to remove padding,
3874 + * or can we do hide padding via bytesperline.
3875 + */
3876 +};
3877 +
3878 +/* buffer for one video frame */
3879 +struct mmal_buffer {
3880 + /* v4l buffer data -- must be first */
3881 + struct vb2_v4l2_buffer vb;
3882 +
3883 + /* list of buffers available */
3884 + struct list_head list;
3885 +
3886 + void *buffer; /* buffer pointer */
3887 + unsigned long buffer_size; /* size of allocated buffer */
3888 +
3889 + struct mmal_msg_context *msg_context;
3890 +};
3891 +
3892 +/* */
3893 +struct mmal_colourfx {
3894 + s32 enable;
3895 + u32 u;
3896 + u32 v;
3897 +};
3898 +#endif
3899 --- /dev/null
3900 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-encodings.h
3901 @@ -0,0 +1,124 @@
3902 +/* SPDX-License-Identifier: GPL-2.0 */
3903 +/*
3904 + * Broadcom BM2835 V4L2 driver
3905 + *
3906 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
3907 + *
3908 + * Authors: Vincent Sanders @ Collabora
3909 + * Dave Stevenson @ Broadcom
3910 + * (now dave.stevenson@raspberrypi.org)
3911 + * Simon Mellor @ Broadcom
3912 + * Luke Diamand @ Broadcom
3913 + */
3914 +#ifndef MMAL_ENCODINGS_H
3915 +#define MMAL_ENCODINGS_H
3916 +
3917 +#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4')
3918 +#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3')
3919 +#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V')
3920 +#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V')
3921 +#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V')
3922 +#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3')
3923 +#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2')
3924 +#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1')
3925 +#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1')
3926 +#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ')
3927 +#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ')
3928 +#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ')
3929 +#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O')
3930 +#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K')
3931 +#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G')
3932 +
3933 +#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G')
3934 +#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ')
3935 +#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ')
3936 +#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ')
3937 +#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ')
3938 +#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ')
3939 +
3940 +#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0')
3941 +#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0')
3942 +#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2')
3943 +#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2')
3944 +#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2')
3945 +#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V')
3946 +#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U')
3947 +#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y')
3948 +#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y')
3949 +#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2')
3950 +#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1')
3951 +#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B')
3952 +#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A')
3953 +#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R')
3954 +#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A')
3955 +#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2')
3956 +#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3')
3957 +#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4')
3958 +#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2')
3959 +#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3')
3960 +#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4')
3961 +
3962 +/** SAND Video (YUVUV128) format, native format understood by VideoCore.
3963 + * This format is *not* opaque - if requested you will receive full frames
3964 + * of YUV_UV video.
3965 + */
3966 +#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D')
3967 +
3968 +/** VideoCore opaque image format, image handles are returned to
3969 + * the host but not the actual image data.
3970 + */
3971 +#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V')
3972 +
3973 +/** An EGL image handle
3974 + */
3975 +#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I')
3976 +
3977 +/* }@ */
3978 +
3979 +/** \name Pre-defined audio encodings */
3980 +/* @{ */
3981 +#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U')
3982 +#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u')
3983 +#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S')
3984 +#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's')
3985 +#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F')
3986 +#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f')
3987 +
3988 +/* Pre-defined H264 encoding variants */
3989 +
3990 +/** ISO 14496-10 Annex B byte stream format */
3991 +#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0
3992 +/** ISO 14496-15 AVC stream format */
3993 +#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1')
3994 +/** Implicitly delineated NAL units without emulation prevention */
3995 +#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ')
3996 +
3997 +/** \defgroup MmalColorSpace List of pre-defined video color spaces
3998 + * This defines a list of common color spaces. This list isn't exhaustive and
3999 + * is only provided as a convenience to avoid clients having to use FourCC
4000 + * codes directly. However components are allowed to define and use their own
4001 + * FourCC codes.
4002 + */
4003 +/* @{ */
4004 +
4005 +/** Unknown color space */
4006 +#define MMAL_COLOR_SPACE_UNKNOWN 0
4007 +/** ITU-R BT.601-5 [SDTV] */
4008 +#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1')
4009 +/** ITU-R BT.709-3 [HDTV] */
4010 +#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9')
4011 +/** JPEG JFIF */
4012 +#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I')
4013 +/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
4014 +#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C')
4015 +/** Society of Motion Picture and Television Engineers 240M (1999) */
4016 +#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0')
4017 +/** ITU-R BT.470-2 System M */
4018 +#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M')
4019 +/** ITU-R BT.470-2 System BG */
4020 +#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G')
4021 +/** JPEG JFIF, but with 16..255 luma */
4022 +#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6')
4023 +/* @} MmalColorSpace List */
4024 +
4025 +#endif /* MMAL_ENCODINGS_H */
4026 --- /dev/null
4027 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-common.h
4028 @@ -0,0 +1,48 @@
4029 +/* SPDX-License-Identifier: GPL-2.0 */
4030 +/*
4031 + * Broadcom BM2835 V4L2 driver
4032 + *
4033 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4034 + *
4035 + * Authors: Vincent Sanders @ Collabora
4036 + * Dave Stevenson @ Broadcom
4037 + * (now dave.stevenson@raspberrypi.org)
4038 + * Simon Mellor @ Broadcom
4039 + * Luke Diamand @ Broadcom
4040 + */
4041 +
4042 +#ifndef MMAL_MSG_COMMON_H
4043 +#define MMAL_MSG_COMMON_H
4044 +
4045 +enum mmal_msg_status {
4046 + MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */
4047 + MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */
4048 + MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */
4049 + MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */
4050 + MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */
4051 + MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */
4052 + MMAL_MSG_STATUS_ENXIO, /**< No such device or address */
4053 + MMAL_MSG_STATUS_EIO, /**< I/O error */
4054 + MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */
4055 + MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */
4056 + MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */
4057 + MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */
4058 + MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */
4059 + MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */
4060 + MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */
4061 + MMAL_MSG_STATUS_EFAULT, /**< Bad address */
4062 +};
4063 +
4064 +struct mmal_rect {
4065 + s32 x; /**< x coordinate (from left) */
4066 + s32 y; /**< y coordinate (from top) */
4067 + s32 width; /**< width */
4068 + s32 height; /**< height */
4069 +};
4070 +
4071 +struct mmal_rational {
4072 + s32 num; /**< Numerator */
4073 + s32 den; /**< Denominator */
4074 +};
4075 +
4076 +#endif /* MMAL_MSG_COMMON_H */
4077 --- /dev/null
4078 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-format.h
4079 @@ -0,0 +1,106 @@
4080 +/* SPDX-License-Identifier: GPL-2.0 */
4081 +/*
4082 + * Broadcom BM2835 V4L2 driver
4083 + *
4084 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4085 + *
4086 + * Authors: Vincent Sanders @ Collabora
4087 + * Dave Stevenson @ Broadcom
4088 + * (now dave.stevenson@raspberrypi.org)
4089 + * Simon Mellor @ Broadcom
4090 + * Luke Diamand @ Broadcom
4091 + */
4092 +
4093 +#ifndef MMAL_MSG_FORMAT_H
4094 +#define MMAL_MSG_FORMAT_H
4095 +
4096 +#include "mmal-msg-common.h"
4097 +
4098 +/* MMAL_ES_FORMAT_T */
4099 +
4100 +struct mmal_audio_format {
4101 + u32 channels; /* Number of audio channels */
4102 + u32 sample_rate; /* Sample rate */
4103 +
4104 + u32 bits_per_sample; /* Bits per sample */
4105 + u32 block_align; /* Size of a block of data */
4106 +};
4107 +
4108 +struct mmal_video_format {
4109 + u32 width; /* Width of frame in pixels */
4110 + u32 height; /* Height of frame in rows of pixels */
4111 + struct mmal_rect crop; /* Visible region of the frame */
4112 + struct mmal_rational frame_rate; /* Frame rate */
4113 + struct mmal_rational par; /* Pixel aspect ratio */
4114 +
4115 + /*
4116 + * FourCC specifying the color space of the video stream. See the
4117 + * MmalColorSpace "pre-defined color spaces" for some examples.
4118 + */
4119 + u32 color_space;
4120 +};
4121 +
4122 +struct mmal_subpicture_format {
4123 + u32 x_offset;
4124 + u32 y_offset;
4125 +};
4126 +
4127 +union mmal_es_specific_format {
4128 + struct mmal_audio_format audio;
4129 + struct mmal_video_format video;
4130 + struct mmal_subpicture_format subpicture;
4131 +};
4132 +
4133 +/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */
4134 +struct mmal_es_format_local {
4135 + u32 type; /* enum mmal_es_type */
4136 +
4137 + u32 encoding; /* FourCC specifying encoding of the elementary
4138 + * stream.
4139 + */
4140 + u32 encoding_variant; /* FourCC specifying the specific
4141 + * encoding variant of the elementary
4142 + * stream.
4143 + */
4144 +
4145 + union mmal_es_specific_format *es; /* Type specific
4146 + * information for the
4147 + * elementary stream
4148 + */
4149 +
4150 + u32 bitrate; /* Bitrate in bits per second */
4151 + u32 flags; /* Flags describing properties of the elementary
4152 + * stream.
4153 + */
4154 +
4155 + u32 extradata_size; /* Size of the codec specific data */
4156 + u8 *extradata; /* Codec specific data */
4157 +};
4158 +
4159 +/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */
4160 +struct mmal_es_format {
4161 + u32 type; /* enum mmal_es_type */
4162 +
4163 + u32 encoding; /* FourCC specifying encoding of the elementary
4164 + * stream.
4165 + */
4166 + u32 encoding_variant; /* FourCC specifying the specific
4167 + * encoding variant of the elementary
4168 + * stream.
4169 + */
4170 +
4171 + u32 es; /* Type specific
4172 + * information for the
4173 + * elementary stream
4174 + */
4175 +
4176 + u32 bitrate; /* Bitrate in bits per second */
4177 + u32 flags; /* Flags describing properties of the elementary
4178 + * stream.
4179 + */
4180 +
4181 + u32 extradata_size; /* Size of the codec specific data */
4182 + u32 extradata; /* Codec specific data */
4183 +};
4184 +
4185 +#endif /* MMAL_MSG_FORMAT_H */
4186 --- /dev/null
4187 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-port.h
4188 @@ -0,0 +1,109 @@
4189 +/* SPDX-License-Identifier: GPL-2.0 */
4190 +/*
4191 + * Broadcom BM2835 V4L2 driver
4192 + *
4193 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4194 + *
4195 + * Authors: Vincent Sanders @ Collabora
4196 + * Dave Stevenson @ Broadcom
4197 + * (now dave.stevenson@raspberrypi.org)
4198 + * Simon Mellor @ Broadcom
4199 + * Luke Diamand @ Broadcom
4200 + */
4201 +
4202 +/* MMAL_PORT_TYPE_T */
4203 +enum mmal_port_type {
4204 + MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */
4205 + MMAL_PORT_TYPE_CONTROL, /* Control port */
4206 + MMAL_PORT_TYPE_INPUT, /* Input port */
4207 + MMAL_PORT_TYPE_OUTPUT, /* Output port */
4208 + MMAL_PORT_TYPE_CLOCK, /* Clock port */
4209 +};
4210 +
4211 +/* The port is pass-through and doesn't need buffer headers allocated */
4212 +#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01
4213 +/*
4214 + *The port wants to allocate the buffer payloads.
4215 + * This signals a preference that payload allocation should be done
4216 + * on this port for efficiency reasons.
4217 + */
4218 +#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02
4219 +/*
4220 + * The port supports format change events.
4221 + * This applies to input ports and is used to let the client know
4222 + * whether the port supports being reconfigured via a format
4223 + * change event (i.e. without having to disable the port).
4224 + */
4225 +#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04
4226 +
4227 +/*
4228 + * mmal port structure (MMAL_PORT_T)
4229 + *
4230 + * most elements are informational only, the pointer values for
4231 + * interogation messages are generally provided as additional
4232 + * structures within the message. When used to set values only the
4233 + * buffer_num, buffer_size and userdata parameters are writable.
4234 + */
4235 +struct mmal_port {
4236 + u32 priv; /* Private member used by the framework */
4237 + u32 name; /* Port name. Used for debugging purposes (RO) */
4238 +
4239 + u32 type; /* Type of the port (RO) enum mmal_port_type */
4240 + u16 index; /* Index of the port in its type list (RO) */
4241 + u16 index_all; /* Index of the port in the list of all ports (RO) */
4242 +
4243 + u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */
4244 + u32 format; /* Format of the elementary stream */
4245 +
4246 + u32 buffer_num_min; /* Minimum number of buffers the port
4247 + * requires (RO). This is set by the
4248 + * component.
4249 + */
4250 +
4251 + u32 buffer_size_min; /* Minimum size of buffers the port
4252 + * requires (RO). This is set by the
4253 + * component.
4254 + */
4255 +
4256 + u32 buffer_alignment_min;/* Minimum alignment requirement for
4257 + * the buffers (RO). A value of
4258 + * zero means no special alignment
4259 + * requirements. This is set by the
4260 + * component.
4261 + */
4262 +
4263 + u32 buffer_num_recommended; /* Number of buffers the port
4264 + * recommends for optimal
4265 + * performance (RO). A value of
4266 + * zero means no special
4267 + * recommendation. This is set
4268 + * by the component.
4269 + */
4270 +
4271 + u32 buffer_size_recommended; /* Size of buffers the port
4272 + * recommends for optimal
4273 + * performance (RO). A value of
4274 + * zero means no special
4275 + * recommendation. This is set
4276 + * by the component.
4277 + */
4278 +
4279 + u32 buffer_num; /* Actual number of buffers the port will use.
4280 + * This is set by the client.
4281 + */
4282 +
4283 + u32 buffer_size; /* Actual maximum size of the buffers that
4284 + * will be sent to the port. This is set by
4285 + * the client.
4286 + */
4287 +
4288 + u32 component; /* Component this port belongs to (Read Only) */
4289 +
4290 + u32 userdata; /* Field reserved for use by the client */
4291 +
4292 + u32 capabilities; /* Flags describing the capabilities of a
4293 + * port (RO). Bitwise combination of \ref
4294 + * portcapabilities "Port capabilities"
4295 + * values.
4296 + */
4297 +};
4298 --- /dev/null
4299 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h
4300 @@ -0,0 +1,406 @@
4301 +/* SPDX-License-Identifier: GPL-2.0 */
4302 +/*
4303 + * Broadcom BM2835 V4L2 driver
4304 + *
4305 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4306 + *
4307 + * Authors: Vincent Sanders @ Collabora
4308 + * Dave Stevenson @ Broadcom
4309 + * (now dave.stevenson@raspberrypi.org)
4310 + * Simon Mellor @ Broadcom
4311 + * Luke Diamand @ Broadcom
4312 + */
4313 +
4314 +/*
4315 + * all the data structures which serialise the MMAL protocol. note
4316 + * these are directly mapped onto the recived message data.
4317 + *
4318 + * BEWARE: They seem to *assume* pointers are u32 and that there is no
4319 + * structure padding!
4320 + *
4321 + * NOTE: this implementation uses kernel types to ensure sizes. Rather
4322 + * than assigning values to enums to force their size the
4323 + * implementation uses fixed size types and not the enums (though the
4324 + * comments have the actual enum type
4325 + */
4326 +#ifndef MMAL_MSG_H
4327 +#define MMAL_MSG_H
4328 +
4329 +#define VC_MMAL_VER 15
4330 +#define VC_MMAL_MIN_VER 10
4331 +#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal")
4332 +
4333 +/* max total message size is 512 bytes */
4334 +#define MMAL_MSG_MAX_SIZE 512
4335 +/* with six 32bit header elements max payload is therefore 488 bytes */
4336 +#define MMAL_MSG_MAX_PAYLOAD 488
4337 +
4338 +#include "mmal-msg-common.h"
4339 +#include "mmal-msg-format.h"
4340 +#include "mmal-msg-port.h"
4341 +
4342 +enum mmal_msg_type {
4343 + MMAL_MSG_TYPE_QUIT = 1,
4344 + MMAL_MSG_TYPE_SERVICE_CLOSED,
4345 + MMAL_MSG_TYPE_GET_VERSION,
4346 + MMAL_MSG_TYPE_COMPONENT_CREATE,
4347 + MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */
4348 + MMAL_MSG_TYPE_COMPONENT_ENABLE,
4349 + MMAL_MSG_TYPE_COMPONENT_DISABLE,
4350 + MMAL_MSG_TYPE_PORT_INFO_GET,
4351 + MMAL_MSG_TYPE_PORT_INFO_SET,
4352 + MMAL_MSG_TYPE_PORT_ACTION, /* 10 */
4353 + MMAL_MSG_TYPE_BUFFER_FROM_HOST,
4354 + MMAL_MSG_TYPE_BUFFER_TO_HOST,
4355 + MMAL_MSG_TYPE_GET_STATS,
4356 + MMAL_MSG_TYPE_PORT_PARAMETER_SET,
4357 + MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */
4358 + MMAL_MSG_TYPE_EVENT_TO_HOST,
4359 + MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
4360 + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
4361 + MMAL_MSG_TYPE_CONSUME_MEM,
4362 + MMAL_MSG_TYPE_LMK, /* 20 */
4363 + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
4364 + MMAL_MSG_TYPE_DRM_GET_LHS32,
4365 + MMAL_MSG_TYPE_DRM_GET_TIME,
4366 + MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
4367 + MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */
4368 + MMAL_MSG_TYPE_HOST_LOG,
4369 + MMAL_MSG_TYPE_MSG_LAST
4370 +};
4371 +
4372 +/* port action request messages differ depending on the action type */
4373 +enum mmal_msg_port_action_type {
4374 + MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */
4375 + MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
4376 + MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
4377 + MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
4378 + MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */
4379 + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */
4380 + MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/
4381 +};
4382 +
4383 +struct mmal_msg_header {
4384 + u32 magic;
4385 + u32 type; /* enum mmal_msg_type */
4386 +
4387 + /* Opaque handle to the control service */
4388 + u32 control_service;
4389 +
4390 + u32 context; /* a u32 per message context */
4391 + u32 status; /* The status of the vchiq operation */
4392 + u32 padding;
4393 +};
4394 +
4395 +/* Send from VC to host to report version */
4396 +struct mmal_msg_version {
4397 + u32 flags;
4398 + u32 major;
4399 + u32 minor;
4400 + u32 minimum;
4401 +};
4402 +
4403 +/* request to VC to create component */
4404 +struct mmal_msg_component_create {
4405 + u32 client_component; /* component context */
4406 + char name[128];
4407 + u32 pid; /* For debug */
4408 +};
4409 +
4410 +/* reply from VC to component creation request */
4411 +struct mmal_msg_component_create_reply {
4412 + u32 status; /* enum mmal_msg_status - how does this differ to
4413 + * the one in the header?
4414 + */
4415 + u32 component_handle; /* VideoCore handle for component */
4416 + u32 input_num; /* Number of input ports */
4417 + u32 output_num; /* Number of output ports */
4418 + u32 clock_num; /* Number of clock ports */
4419 +};
4420 +
4421 +/* request to VC to destroy a component */
4422 +struct mmal_msg_component_destroy {
4423 + u32 component_handle;
4424 +};
4425 +
4426 +struct mmal_msg_component_destroy_reply {
4427 + u32 status; /* The component destruction status */
4428 +};
4429 +
4430 +/* request and reply to VC to enable a component */
4431 +struct mmal_msg_component_enable {
4432 + u32 component_handle;
4433 +};
4434 +
4435 +struct mmal_msg_component_enable_reply {
4436 + u32 status; /* The component enable status */
4437 +};
4438 +
4439 +/* request and reply to VC to disable a component */
4440 +struct mmal_msg_component_disable {
4441 + u32 component_handle;
4442 +};
4443 +
4444 +struct mmal_msg_component_disable_reply {
4445 + u32 status; /* The component disable status */
4446 +};
4447 +
4448 +/* request to VC to get port information */
4449 +struct mmal_msg_port_info_get {
4450 + u32 component_handle; /* component handle port is associated with */
4451 + u32 port_type; /* enum mmal_msg_port_type */
4452 + u32 index; /* port index to query */
4453 +};
4454 +
4455 +/* reply from VC to get port info request */
4456 +struct mmal_msg_port_info_get_reply {
4457 + u32 status; /* enum mmal_msg_status */
4458 + u32 component_handle; /* component handle port is associated with */
4459 + u32 port_type; /* enum mmal_msg_port_type */
4460 + u32 port_index; /* port indexed in query */
4461 + s32 found; /* unused */
4462 + u32 port_handle; /* Handle to use for this port */
4463 + struct mmal_port port;
4464 + struct mmal_es_format format; /* elementary stream format */
4465 + union mmal_es_specific_format es; /* es type specific data */
4466 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */
4467 +};
4468 +
4469 +/* request to VC to set port information */
4470 +struct mmal_msg_port_info_set {
4471 + u32 component_handle;
4472 + u32 port_type; /* enum mmal_msg_port_type */
4473 + u32 port_index; /* port indexed in query */
4474 + struct mmal_port port;
4475 + struct mmal_es_format format;
4476 + union mmal_es_specific_format es;
4477 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
4478 +};
4479 +
4480 +/* reply from VC to port info set request */
4481 +struct mmal_msg_port_info_set_reply {
4482 + u32 status;
4483 + u32 component_handle; /* component handle port is associated with */
4484 + u32 port_type; /* enum mmal_msg_port_type */
4485 + u32 index; /* port indexed in query */
4486 + s32 found; /* unused */
4487 + u32 port_handle; /* Handle to use for this port */
4488 + struct mmal_port port;
4489 + struct mmal_es_format format;
4490 + union mmal_es_specific_format es;
4491 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
4492 +};
4493 +
4494 +/* port action requests that take a mmal_port as a parameter */
4495 +struct mmal_msg_port_action_port {
4496 + u32 component_handle;
4497 + u32 port_handle;
4498 + u32 action; /* enum mmal_msg_port_action_type */
4499 + struct mmal_port port;
4500 +};
4501 +
4502 +/* port action requests that take handles as a parameter */
4503 +struct mmal_msg_port_action_handle {
4504 + u32 component_handle;
4505 + u32 port_handle;
4506 + u32 action; /* enum mmal_msg_port_action_type */
4507 + u32 connect_component_handle;
4508 + u32 connect_port_handle;
4509 +};
4510 +
4511 +struct mmal_msg_port_action_reply {
4512 + u32 status; /* The port action operation status */
4513 +};
4514 +
4515 +/* MMAL buffer transfer */
4516 +
4517 +/* Size of space reserved in a buffer message for short messages. */
4518 +#define MMAL_VC_SHORT_DATA 128
4519 +
4520 +/* Signals that the current payload is the end of the stream of data */
4521 +#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0)
4522 +/* Signals that the start of the current payload starts a frame */
4523 +#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1)
4524 +/* Signals that the end of the current payload ends a frame */
4525 +#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2)
4526 +/* Signals that the current payload contains only complete frames (>1) */
4527 +#define MMAL_BUFFER_HEADER_FLAG_FRAME \
4528 + (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \
4529 + MMAL_BUFFER_HEADER_FLAG_FRAME_END)
4530 +/* Signals that the current payload is a keyframe (i.e. self decodable) */
4531 +#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3)
4532 +/*
4533 + * Signals a discontinuity in the stream of data (e.g. after a seek).
4534 + * Can be used for instance by a decoder to reset its state
4535 + */
4536 +#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4)
4537 +/*
4538 + * Signals a buffer containing some kind of config data for the component
4539 + * (e.g. codec config data)
4540 + */
4541 +#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5)
4542 +/* Signals an encrypted payload */
4543 +#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6)
4544 +/* Signals a buffer containing side information */
4545 +#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7)
4546 +/*
4547 + * Signals a buffer which is the snapshot/postview image from a stills
4548 + * capture
4549 + */
4550 +#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8)
4551 +/* Signals a buffer which contains data known to be corrupted */
4552 +#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9)
4553 +/* Signals that a buffer failed to be transmitted */
4554 +#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10)
4555 +
4556 +struct mmal_driver_buffer {
4557 + u32 magic;
4558 + u32 component_handle;
4559 + u32 port_handle;
4560 + u32 client_context;
4561 +};
4562 +
4563 +/* buffer header */
4564 +struct mmal_buffer_header {
4565 + u32 next; /* next header */
4566 + u32 priv; /* framework private data */
4567 + u32 cmd;
4568 + u32 data;
4569 + u32 alloc_size;
4570 + u32 length;
4571 + u32 offset;
4572 + u32 flags;
4573 + s64 pts;
4574 + s64 dts;
4575 + u32 type;
4576 + u32 user_data;
4577 +};
4578 +
4579 +struct mmal_buffer_header_type_specific {
4580 + union {
4581 + struct {
4582 + u32 planes;
4583 + u32 offset[4];
4584 + u32 pitch[4];
4585 + u32 flags;
4586 + } video;
4587 + } u;
4588 +};
4589 +
4590 +struct mmal_msg_buffer_from_host {
4591 + /*
4592 + *The front 32 bytes of the buffer header are copied
4593 + * back to us in the reply to allow for context. This
4594 + * area is used to store two mmal_driver_buffer structures to
4595 + * allow for multiple concurrent service users.
4596 + */
4597 + /* control data */
4598 + struct mmal_driver_buffer drvbuf;
4599 +
4600 + /* referenced control data for passthrough buffer management */
4601 + struct mmal_driver_buffer drvbuf_ref;
4602 + struct mmal_buffer_header buffer_header; /* buffer header itself */
4603 + struct mmal_buffer_header_type_specific buffer_header_type_specific;
4604 + s32 is_zero_copy;
4605 + s32 has_reference;
4606 +
4607 + /* allows short data to be xfered in control message */
4608 + u32 payload_in_message;
4609 + u8 short_data[MMAL_VC_SHORT_DATA];
4610 +};
4611 +
4612 +/* port parameter setting */
4613 +
4614 +#define MMAL_WORKER_PORT_PARAMETER_SPACE 96
4615 +
4616 +struct mmal_msg_port_parameter_set {
4617 + u32 component_handle; /* component */
4618 + u32 port_handle; /* port */
4619 + u32 id; /* Parameter ID */
4620 + u32 size; /* Parameter size */
4621 + uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
4622 +};
4623 +
4624 +struct mmal_msg_port_parameter_set_reply {
4625 + u32 status; /* enum mmal_msg_status todo: how does this
4626 + * differ to the one in the header?
4627 + */
4628 +};
4629 +
4630 +/* port parameter getting */
4631 +
4632 +struct mmal_msg_port_parameter_get {
4633 + u32 component_handle; /* component */
4634 + u32 port_handle; /* port */
4635 + u32 id; /* Parameter ID */
4636 + u32 size; /* Parameter size */
4637 +};
4638 +
4639 +struct mmal_msg_port_parameter_get_reply {
4640 + u32 status; /* Status of mmal_port_parameter_get call */
4641 + u32 id; /* Parameter ID */
4642 + u32 size; /* Parameter size */
4643 + uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
4644 +};
4645 +
4646 +/* event messages */
4647 +#define MMAL_WORKER_EVENT_SPACE 256
4648 +
4649 +struct mmal_msg_event_to_host {
4650 + u32 client_component; /* component context */
4651 +
4652 + u32 port_type;
4653 + u32 port_num;
4654 +
4655 + u32 cmd;
4656 + u32 length;
4657 + u8 data[MMAL_WORKER_EVENT_SPACE];
4658 + u32 delayed_buffer;
4659 +};
4660 +
4661 +/* all mmal messages are serialised through this structure */
4662 +struct mmal_msg {
4663 + /* header */
4664 + struct mmal_msg_header h;
4665 + /* payload */
4666 + union {
4667 + struct mmal_msg_version version;
4668 +
4669 + struct mmal_msg_component_create component_create;
4670 + struct mmal_msg_component_create_reply component_create_reply;
4671 +
4672 + struct mmal_msg_component_destroy component_destroy;
4673 + struct mmal_msg_component_destroy_reply component_destroy_reply;
4674 +
4675 + struct mmal_msg_component_enable component_enable;
4676 + struct mmal_msg_component_enable_reply component_enable_reply;
4677 +
4678 + struct mmal_msg_component_disable component_disable;
4679 + struct mmal_msg_component_disable_reply component_disable_reply;
4680 +
4681 + struct mmal_msg_port_info_get port_info_get;
4682 + struct mmal_msg_port_info_get_reply port_info_get_reply;
4683 +
4684 + struct mmal_msg_port_info_set port_info_set;
4685 + struct mmal_msg_port_info_set_reply port_info_set_reply;
4686 +
4687 + struct mmal_msg_port_action_port port_action_port;
4688 + struct mmal_msg_port_action_handle port_action_handle;
4689 + struct mmal_msg_port_action_reply port_action_reply;
4690 +
4691 + struct mmal_msg_buffer_from_host buffer_from_host;
4692 +
4693 + struct mmal_msg_port_parameter_set port_parameter_set;
4694 + struct mmal_msg_port_parameter_set_reply
4695 + port_parameter_set_reply;
4696 + struct mmal_msg_port_parameter_get
4697 + port_parameter_get;
4698 + struct mmal_msg_port_parameter_get_reply
4699 + port_parameter_get_reply;
4700 +
4701 + struct mmal_msg_event_to_host event_to_host;
4702 +
4703 + u8 payload[MMAL_MSG_MAX_PAYLOAD];
4704 + } u;
4705 +};
4706 +#endif
4707 --- /dev/null
4708 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h
4709 @@ -0,0 +1,755 @@
4710 +/* SPDX-License-Identifier: GPL-2.0 */
4711 +/*
4712 + * Broadcom BM2835 V4L2 driver
4713 + *
4714 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4715 + *
4716 + * Authors: Vincent Sanders @ Collabora
4717 + * Dave Stevenson @ Broadcom
4718 + * (now dave.stevenson@raspberrypi.org)
4719 + * Simon Mellor @ Broadcom
4720 + * Luke Diamand @ Broadcom
4721 + */
4722 +
4723 +/* common parameters */
4724 +
4725 +/** @name Parameter groups
4726 + * Parameters are divided into groups, and then allocated sequentially within
4727 + * a group using an enum.
4728 + * @{
4729 + */
4730 +
4731 +#ifndef MMAL_PARAMETERS_H
4732 +#define MMAL_PARAMETERS_H
4733 +
4734 +/** Common parameter ID group, used with many types of component. */
4735 +#define MMAL_PARAMETER_GROUP_COMMON (0 << 16)
4736 +/** Camera-specific parameter ID group. */
4737 +#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16)
4738 +/** Video-specific parameter ID group. */
4739 +#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16)
4740 +/** Audio-specific parameter ID group. */
4741 +#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16)
4742 +/** Clock-specific parameter ID group. */
4743 +#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16)
4744 +/** Miracast-specific parameter ID group. */
4745 +#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16)
4746 +
4747 +/* Common parameters */
4748 +enum mmal_parameter_common_type {
4749 + /**< Never a valid parameter ID */
4750 + MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON,
4751 +
4752 + /**< MMAL_PARAMETER_ENCODING_T */
4753 + MMAL_PARAMETER_SUPPORTED_ENCODINGS,
4754 + /**< MMAL_PARAMETER_URI_T */
4755 + MMAL_PARAMETER_URI,
4756 + /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */
4757 + MMAL_PARAMETER_CHANGE_EVENT_REQUEST,
4758 + /** MMAL_PARAMETER_BOOLEAN_T */
4759 + MMAL_PARAMETER_ZERO_COPY,
4760 + /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */
4761 + MMAL_PARAMETER_BUFFER_REQUIREMENTS,
4762 + /**< MMAL_PARAMETER_STATISTICS_T */
4763 + MMAL_PARAMETER_STATISTICS,
4764 + /**< MMAL_PARAMETER_CORE_STATISTICS_T */
4765 + MMAL_PARAMETER_CORE_STATISTICS,
4766 + /**< MMAL_PARAMETER_MEM_USAGE_T */
4767 + MMAL_PARAMETER_MEM_USAGE,
4768 + /**< MMAL_PARAMETER_UINT32_T */
4769 + MMAL_PARAMETER_BUFFER_FLAG_FILTER,
4770 + /**< MMAL_PARAMETER_SEEK_T */
4771 + MMAL_PARAMETER_SEEK,
4772 + /**< MMAL_PARAMETER_BOOLEAN_T */
4773 + MMAL_PARAMETER_POWERMON_ENABLE,
4774 + /**< MMAL_PARAMETER_LOGGING_T */
4775 + MMAL_PARAMETER_LOGGING,
4776 + /**< MMAL_PARAMETER_UINT64_T */
4777 + MMAL_PARAMETER_SYSTEM_TIME,
4778 + /**< MMAL_PARAMETER_BOOLEAN_T */
4779 + MMAL_PARAMETER_NO_IMAGE_PADDING,
4780 +};
4781 +
4782 +/* camera parameters */
4783 +
4784 +enum mmal_parameter_camera_type {
4785 + /* 0 */
4786 + /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */
4787 + MMAL_PARAMETER_THUMBNAIL_CONFIGURATION =
4788 + MMAL_PARAMETER_GROUP_CAMERA,
4789 + /**< Unused? */
4790 + MMAL_PARAMETER_CAPTURE_QUALITY,
4791 + /**< @ref MMAL_PARAMETER_INT32_T */
4792 + MMAL_PARAMETER_ROTATION,
4793 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4794 + MMAL_PARAMETER_EXIF_DISABLE,
4795 + /**< @ref MMAL_PARAMETER_EXIF_T */
4796 + MMAL_PARAMETER_EXIF,
4797 + /**< @ref MMAL_PARAM_AWBMODE_T */
4798 + MMAL_PARAMETER_AWB_MODE,
4799 + /**< @ref MMAL_PARAMETER_IMAGEFX_T */
4800 + MMAL_PARAMETER_IMAGE_EFFECT,
4801 + /**< @ref MMAL_PARAMETER_COLOURFX_T */
4802 + MMAL_PARAMETER_COLOUR_EFFECT,
4803 + /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */
4804 + MMAL_PARAMETER_FLICKER_AVOID,
4805 + /**< @ref MMAL_PARAMETER_FLASH_T */
4806 + MMAL_PARAMETER_FLASH,
4807 + /**< @ref MMAL_PARAMETER_REDEYE_T */
4808 + MMAL_PARAMETER_REDEYE,
4809 + /**< @ref MMAL_PARAMETER_FOCUS_T */
4810 + MMAL_PARAMETER_FOCUS,
4811 + /**< Unused? */
4812 + MMAL_PARAMETER_FOCAL_LENGTHS,
4813 + /**< @ref MMAL_PARAMETER_INT32_T */
4814 + MMAL_PARAMETER_EXPOSURE_COMP,
4815 + /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */
4816 + MMAL_PARAMETER_ZOOM,
4817 + /**< @ref MMAL_PARAMETER_MIRROR_T */
4818 + MMAL_PARAMETER_MIRROR,
4819 +
4820 + /* 0x10 */
4821 + /**< @ref MMAL_PARAMETER_UINT32_T */
4822 + MMAL_PARAMETER_CAMERA_NUM,
4823 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4824 + MMAL_PARAMETER_CAPTURE,
4825 + /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */
4826 + MMAL_PARAMETER_EXPOSURE_MODE,
4827 + /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */
4828 + MMAL_PARAMETER_EXP_METERING_MODE,
4829 + /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */
4830 + MMAL_PARAMETER_FOCUS_STATUS,
4831 + /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */
4832 + MMAL_PARAMETER_CAMERA_CONFIG,
4833 + /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */
4834 + MMAL_PARAMETER_CAPTURE_STATUS,
4835 + /**< @ref MMAL_PARAMETER_FACE_TRACK_T */
4836 + MMAL_PARAMETER_FACE_TRACK,
4837 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4838 + MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS,
4839 + /**< @ref MMAL_PARAMETER_UINT32_T */
4840 + MMAL_PARAMETER_JPEG_Q_FACTOR,
4841 + /**< @ref MMAL_PARAMETER_FRAME_RATE_T */
4842 + MMAL_PARAMETER_FRAME_RATE,
4843 + /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */
4844 + MMAL_PARAMETER_USE_STC,
4845 + /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */
4846 + MMAL_PARAMETER_CAMERA_INFO,
4847 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4848 + MMAL_PARAMETER_VIDEO_STABILISATION,
4849 + /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */
4850 + MMAL_PARAMETER_FACE_TRACK_RESULTS,
4851 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4852 + MMAL_PARAMETER_ENABLE_RAW_CAPTURE,
4853 +
4854 + /* 0x20 */
4855 + /**< @ref MMAL_PARAMETER_URI_T */
4856 + MMAL_PARAMETER_DPF_FILE,
4857 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4858 + MMAL_PARAMETER_ENABLE_DPF_FILE,
4859 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4860 + MMAL_PARAMETER_DPF_FAIL_IS_FATAL,
4861 + /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */
4862 + MMAL_PARAMETER_CAPTURE_MODE,
4863 + /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */
4864 + MMAL_PARAMETER_FOCUS_REGIONS,
4865 + /**< @ref MMAL_PARAMETER_INPUT_CROP_T */
4866 + MMAL_PARAMETER_INPUT_CROP,
4867 + /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */
4868 + MMAL_PARAMETER_SENSOR_INFORMATION,
4869 + /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */
4870 + MMAL_PARAMETER_FLASH_SELECT,
4871 + /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */
4872 + MMAL_PARAMETER_FIELD_OF_VIEW,
4873 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4874 + MMAL_PARAMETER_HIGH_DYNAMIC_RANGE,
4875 + /**< @ref MMAL_PARAMETER_DRC_T */
4876 + MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION,
4877 + /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */
4878 + MMAL_PARAMETER_ALGORITHM_CONTROL,
4879 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
4880 + MMAL_PARAMETER_SHARPNESS,
4881 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
4882 + MMAL_PARAMETER_CONTRAST,
4883 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
4884 + MMAL_PARAMETER_BRIGHTNESS,
4885 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
4886 + MMAL_PARAMETER_SATURATION,
4887 +
4888 + /* 0x30 */
4889 + /**< @ref MMAL_PARAMETER_UINT32_T */
4890 + MMAL_PARAMETER_ISO,
4891 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4892 + MMAL_PARAMETER_ANTISHAKE,
4893 + /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */
4894 + MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,
4895 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
4896 + MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
4897 + /** @ref MMAL_PARAMETER_UINT32_T */
4898 + MMAL_PARAMETER_CAMERA_MIN_ISO,
4899 + /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */
4900 + MMAL_PARAMETER_CAMERA_USE_CASE,
4901 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4902 + MMAL_PARAMETER_CAPTURE_STATS_PASS,
4903 + /** @ref MMAL_PARAMETER_UINT32_T */
4904 + MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG,
4905 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
4906 + MMAL_PARAMETER_ENABLE_REGISTER_FILE,
4907 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
4908 + MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
4909 + /** @ref MMAL_PARAMETER_CONFIGFILE_T */
4910 + MMAL_PARAMETER_CONFIGFILE_REGISTERS,
4911 + /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */
4912 + MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS,
4913 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4914 + MMAL_PARAMETER_JPEG_ATTACH_LOG,
4915 + /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */
4916 + MMAL_PARAMETER_ZERO_SHUTTER_LAG,
4917 + /**< @ref MMAL_PARAMETER_FPS_RANGE_T */
4918 + MMAL_PARAMETER_FPS_RANGE,
4919 + /**< @ref MMAL_PARAMETER_INT32_T */
4920 + MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP,
4921 +
4922 + /* 0x40 */
4923 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4924 + MMAL_PARAMETER_SW_SHARPEN_DISABLE,
4925 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4926 + MMAL_PARAMETER_FLASH_REQUIRED,
4927 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4928 + MMAL_PARAMETER_SW_SATURATION_DISABLE,
4929 + /**< Takes a @ref MMAL_PARAMETER_UINT32_T */
4930 + MMAL_PARAMETER_SHUTTER_SPEED,
4931 + /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */
4932 + MMAL_PARAMETER_CUSTOM_AWB_GAINS,
4933 +};
4934 +
4935 +struct mmal_parameter_rational {
4936 + s32 num; /**< Numerator */
4937 + s32 den; /**< Denominator */
4938 +};
4939 +
4940 +enum mmal_parameter_camera_config_timestamp_mode {
4941 + MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */
4942 + MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value
4943 + * for the frame timestamp
4944 + */
4945 + MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp
4946 + * but subtract the
4947 + * timestamp of the first
4948 + * frame sent to give a
4949 + * zero based timestamp.
4950 + */
4951 +};
4952 +
4953 +struct mmal_parameter_fps_range {
4954 + /**< Low end of the permitted framerate range */
4955 + struct mmal_parameter_rational fps_low;
4956 + /**< High end of the permitted framerate range */
4957 + struct mmal_parameter_rational fps_high;
4958 +};
4959 +
4960 +/* camera configuration parameter */
4961 +struct mmal_parameter_camera_config {
4962 + /* Parameters for setting up the image pools */
4963 + u32 max_stills_w; /* Max size of stills capture */
4964 + u32 max_stills_h;
4965 + u32 stills_yuv422; /* Allow YUV422 stills capture */
4966 + u32 one_shot_stills; /* Continuous or one shot stills captures. */
4967 +
4968 + u32 max_preview_video_w; /* Max size of the preview or video
4969 + * capture frames
4970 + */
4971 + u32 max_preview_video_h;
4972 + u32 num_preview_video_frames;
4973 +
4974 + /** Sets the height of the circular buffer for stills capture. */
4975 + u32 stills_capture_circular_buffer_height;
4976 +
4977 + /** Allows preview/encode to resume as fast as possible after the stills
4978 + * input frame has been received, and then processes the still frame in
4979 + * the background whilst preview/encode has resumed.
4980 + * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE.
4981 + */
4982 + u32 fast_preview_resume;
4983 +
4984 + /** Selects algorithm for timestamping frames if
4985 + * there is no clock component connected.
4986 + * enum mmal_parameter_camera_config_timestamp_mode
4987 + */
4988 + s32 use_stc_timestamp;
4989 +};
4990 +
4991 +enum mmal_parameter_exposuremode {
4992 + MMAL_PARAM_EXPOSUREMODE_OFF,
4993 + MMAL_PARAM_EXPOSUREMODE_AUTO,
4994 + MMAL_PARAM_EXPOSUREMODE_NIGHT,
4995 + MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
4996 + MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
4997 + MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
4998 + MMAL_PARAM_EXPOSUREMODE_SPORTS,
4999 + MMAL_PARAM_EXPOSUREMODE_SNOW,
5000 + MMAL_PARAM_EXPOSUREMODE_BEACH,
5001 + MMAL_PARAM_EXPOSUREMODE_VERYLONG,
5002 + MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
5003 + MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
5004 + MMAL_PARAM_EXPOSUREMODE_FIREWORKS,
5005 +};
5006 +
5007 +enum mmal_parameter_exposuremeteringmode {
5008 + MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
5009 + MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
5010 + MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
5011 + MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX,
5012 +};
5013 +
5014 +enum mmal_parameter_awbmode {
5015 + MMAL_PARAM_AWBMODE_OFF,
5016 + MMAL_PARAM_AWBMODE_AUTO,
5017 + MMAL_PARAM_AWBMODE_SUNLIGHT,
5018 + MMAL_PARAM_AWBMODE_CLOUDY,
5019 + MMAL_PARAM_AWBMODE_SHADE,
5020 + MMAL_PARAM_AWBMODE_TUNGSTEN,
5021 + MMAL_PARAM_AWBMODE_FLUORESCENT,
5022 + MMAL_PARAM_AWBMODE_INCANDESCENT,
5023 + MMAL_PARAM_AWBMODE_FLASH,
5024 + MMAL_PARAM_AWBMODE_HORIZON,
5025 +};
5026 +
5027 +enum mmal_parameter_imagefx {
5028 + MMAL_PARAM_IMAGEFX_NONE,
5029 + MMAL_PARAM_IMAGEFX_NEGATIVE,
5030 + MMAL_PARAM_IMAGEFX_SOLARIZE,
5031 + MMAL_PARAM_IMAGEFX_POSTERIZE,
5032 + MMAL_PARAM_IMAGEFX_WHITEBOARD,
5033 + MMAL_PARAM_IMAGEFX_BLACKBOARD,
5034 + MMAL_PARAM_IMAGEFX_SKETCH,
5035 + MMAL_PARAM_IMAGEFX_DENOISE,
5036 + MMAL_PARAM_IMAGEFX_EMBOSS,
5037 + MMAL_PARAM_IMAGEFX_OILPAINT,
5038 + MMAL_PARAM_IMAGEFX_HATCH,
5039 + MMAL_PARAM_IMAGEFX_GPEN,
5040 + MMAL_PARAM_IMAGEFX_PASTEL,
5041 + MMAL_PARAM_IMAGEFX_WATERCOLOUR,
5042 + MMAL_PARAM_IMAGEFX_FILM,
5043 + MMAL_PARAM_IMAGEFX_BLUR,
5044 + MMAL_PARAM_IMAGEFX_SATURATION,
5045 + MMAL_PARAM_IMAGEFX_COLOURSWAP,
5046 + MMAL_PARAM_IMAGEFX_WASHEDOUT,
5047 + MMAL_PARAM_IMAGEFX_POSTERISE,
5048 + MMAL_PARAM_IMAGEFX_COLOURPOINT,
5049 + MMAL_PARAM_IMAGEFX_COLOURBALANCE,
5050 + MMAL_PARAM_IMAGEFX_CARTOON,
5051 +};
5052 +
5053 +enum MMAL_PARAM_FLICKERAVOID_T {
5054 + MMAL_PARAM_FLICKERAVOID_OFF,
5055 + MMAL_PARAM_FLICKERAVOID_AUTO,
5056 + MMAL_PARAM_FLICKERAVOID_50HZ,
5057 + MMAL_PARAM_FLICKERAVOID_60HZ,
5058 + MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF
5059 +};
5060 +
5061 +struct mmal_parameter_awbgains {
5062 + struct mmal_parameter_rational r_gain; /**< Red gain */
5063 + struct mmal_parameter_rational b_gain; /**< Blue gain */
5064 +};
5065 +
5066 +/** Manner of video rate control */
5067 +enum mmal_parameter_rate_control_mode {
5068 + MMAL_VIDEO_RATECONTROL_DEFAULT,
5069 + MMAL_VIDEO_RATECONTROL_VARIABLE,
5070 + MMAL_VIDEO_RATECONTROL_CONSTANT,
5071 + MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES,
5072 + MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES
5073 +};
5074 +
5075 +enum mmal_video_profile {
5076 + MMAL_VIDEO_PROFILE_H263_BASELINE,
5077 + MMAL_VIDEO_PROFILE_H263_H320CODING,
5078 + MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE,
5079 + MMAL_VIDEO_PROFILE_H263_ISWV2,
5080 + MMAL_VIDEO_PROFILE_H263_ISWV3,
5081 + MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION,
5082 + MMAL_VIDEO_PROFILE_H263_INTERNET,
5083 + MMAL_VIDEO_PROFILE_H263_INTERLACE,
5084 + MMAL_VIDEO_PROFILE_H263_HIGHLATENCY,
5085 + MMAL_VIDEO_PROFILE_MP4V_SIMPLE,
5086 + MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE,
5087 + MMAL_VIDEO_PROFILE_MP4V_CORE,
5088 + MMAL_VIDEO_PROFILE_MP4V_MAIN,
5089 + MMAL_VIDEO_PROFILE_MP4V_NBIT,
5090 + MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE,
5091 + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE,
5092 + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA,
5093 + MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED,
5094 + MMAL_VIDEO_PROFILE_MP4V_HYBRID,
5095 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME,
5096 + MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE,
5097 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING,
5098 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE,
5099 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE,
5100 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE,
5101 + MMAL_VIDEO_PROFILE_H264_BASELINE,
5102 + MMAL_VIDEO_PROFILE_H264_MAIN,
5103 + MMAL_VIDEO_PROFILE_H264_EXTENDED,
5104 + MMAL_VIDEO_PROFILE_H264_HIGH,
5105 + MMAL_VIDEO_PROFILE_H264_HIGH10,
5106 + MMAL_VIDEO_PROFILE_H264_HIGH422,
5107 + MMAL_VIDEO_PROFILE_H264_HIGH444,
5108 + MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE,
5109 + MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF
5110 +};
5111 +
5112 +enum mmal_video_level {
5113 + MMAL_VIDEO_LEVEL_H263_10,
5114 + MMAL_VIDEO_LEVEL_H263_20,
5115 + MMAL_VIDEO_LEVEL_H263_30,
5116 + MMAL_VIDEO_LEVEL_H263_40,
5117 + MMAL_VIDEO_LEVEL_H263_45,
5118 + MMAL_VIDEO_LEVEL_H263_50,
5119 + MMAL_VIDEO_LEVEL_H263_60,
5120 + MMAL_VIDEO_LEVEL_H263_70,
5121 + MMAL_VIDEO_LEVEL_MP4V_0,
5122 + MMAL_VIDEO_LEVEL_MP4V_0b,
5123 + MMAL_VIDEO_LEVEL_MP4V_1,
5124 + MMAL_VIDEO_LEVEL_MP4V_2,
5125 + MMAL_VIDEO_LEVEL_MP4V_3,
5126 + MMAL_VIDEO_LEVEL_MP4V_4,
5127 + MMAL_VIDEO_LEVEL_MP4V_4a,
5128 + MMAL_VIDEO_LEVEL_MP4V_5,
5129 + MMAL_VIDEO_LEVEL_MP4V_6,
5130 + MMAL_VIDEO_LEVEL_H264_1,
5131 + MMAL_VIDEO_LEVEL_H264_1b,
5132 + MMAL_VIDEO_LEVEL_H264_11,
5133 + MMAL_VIDEO_LEVEL_H264_12,
5134 + MMAL_VIDEO_LEVEL_H264_13,
5135 + MMAL_VIDEO_LEVEL_H264_2,
5136 + MMAL_VIDEO_LEVEL_H264_21,
5137 + MMAL_VIDEO_LEVEL_H264_22,
5138 + MMAL_VIDEO_LEVEL_H264_3,
5139 + MMAL_VIDEO_LEVEL_H264_31,
5140 + MMAL_VIDEO_LEVEL_H264_32,
5141 + MMAL_VIDEO_LEVEL_H264_4,
5142 + MMAL_VIDEO_LEVEL_H264_41,
5143 + MMAL_VIDEO_LEVEL_H264_42,
5144 + MMAL_VIDEO_LEVEL_H264_5,
5145 + MMAL_VIDEO_LEVEL_H264_51,
5146 + MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF
5147 +};
5148 +
5149 +struct mmal_parameter_video_profile {
5150 + enum mmal_video_profile profile;
5151 + enum mmal_video_level level;
5152 +};
5153 +
5154 +/* video parameters */
5155 +
5156 +enum mmal_parameter_video_type {
5157 + /** @ref MMAL_DISPLAYREGION_T */
5158 + MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO,
5159 +
5160 + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
5161 + MMAL_PARAMETER_SUPPORTED_PROFILES,
5162 +
5163 + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
5164 + MMAL_PARAMETER_PROFILE,
5165 +
5166 + /** @ref MMAL_PARAMETER_UINT32_T */
5167 + MMAL_PARAMETER_INTRAPERIOD,
5168 +
5169 + /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */
5170 + MMAL_PARAMETER_RATECONTROL,
5171 +
5172 + /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */
5173 + MMAL_PARAMETER_NALUNITFORMAT,
5174 +
5175 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
5176 + MMAL_PARAMETER_MINIMISE_FRAGMENTATION,
5177 +
5178 + /** @ref MMAL_PARAMETER_UINT32_T.
5179 + * Setting the value to zero resets to the default (one slice per
5180 + * frame).
5181 + */
5182 + MMAL_PARAMETER_MB_ROWS_PER_SLICE,
5183 +
5184 + /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */
5185 + MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION,
5186 +
5187 + /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */
5188 + MMAL_PARAMETER_VIDEO_EEDE_ENABLE,
5189 +
5190 + /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */
5191 + MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE,
5192 +
5193 + /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */
5194 + MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME,
5195 + /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */
5196 + MMAL_PARAMETER_VIDEO_INTRA_REFRESH,
5197 +
5198 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5199 + MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT,
5200 +
5201 + /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */
5202 + MMAL_PARAMETER_VIDEO_BIT_RATE,
5203 +
5204 + /** @ref MMAL_PARAMETER_FRAME_RATE_T */
5205 + MMAL_PARAMETER_VIDEO_FRAME_RATE,
5206 +
5207 + /** @ref MMAL_PARAMETER_UINT32_T. */
5208 + MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
5209 +
5210 + /** @ref MMAL_PARAMETER_UINT32_T. */
5211 + MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
5212 +
5213 + /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */
5214 + MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL,
5215 +
5216 + MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */
5217 + /** @ref MMAL_PARAMETER_UINT32_T.
5218 + * Changing this parameter from the default can reduce frame rate
5219 + * because image buffers need to be re-pitched.
5220 + */
5221 + MMAL_PARAMETER_VIDEO_ALIGN_HORIZ,
5222 +
5223 + /** @ref MMAL_PARAMETER_UINT32_T.
5224 + * Changing this parameter from the default can reduce frame rate
5225 + * because image buffers need to be re-pitched.
5226 + */
5227 + MMAL_PARAMETER_VIDEO_ALIGN_VERT,
5228 +
5229 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5230 + MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES,
5231 +
5232 + /** @ref MMAL_PARAMETER_UINT32_T. */
5233 + MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT,
5234 +
5235 + /**< @ref MMAL_PARAMETER_UINT32_T. */
5236 + MMAL_PARAMETER_VIDEO_ENCODE_QP_P,
5237 +
5238 + /**< @ref MMAL_PARAMETER_UINT32_T. */
5239 + MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT,
5240 +
5241 + /** @ref MMAL_PARAMETER_UINT32_T */
5242 + MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS,
5243 +
5244 + /** @ref MMAL_PARAMETER_UINT32_T. */
5245 + MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE,
5246 +
5247 + /* H264 specific parameters */
5248 +
5249 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5250 + MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC,
5251 +
5252 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5253 + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY,
5254 +
5255 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5256 + MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS,
5257 +
5258 + /** @ref MMAL_PARAMETER_UINT32_T. */
5259 + MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC,
5260 +
5261 + /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */
5262 + MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE,
5263 +
5264 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
5265 + MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN,
5266 +
5267 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
5268 + MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP,
5269 +
5270 + /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */
5271 + MMAL_PARAMETER_VIDEO_DRM_INIT_INFO,
5272 +
5273 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
5274 + MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO,
5275 +
5276 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
5277 + MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT,
5278 +
5279 + /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */
5280 + MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
5281 +
5282 + /** @ref MMAL_PARAMETER_BYTES_T */
5283 + MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
5284 +
5285 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5286 + MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
5287 +
5288 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5289 + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
5290 +
5291 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5292 + MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
5293 +};
5294 +
5295 +/** Valid mirror modes */
5296 +enum mmal_parameter_mirror {
5297 + MMAL_PARAM_MIRROR_NONE,
5298 + MMAL_PARAM_MIRROR_VERTICAL,
5299 + MMAL_PARAM_MIRROR_HORIZONTAL,
5300 + MMAL_PARAM_MIRROR_BOTH,
5301 +};
5302 +
5303 +enum mmal_parameter_displaytransform {
5304 + MMAL_DISPLAY_ROT0 = 0,
5305 + MMAL_DISPLAY_MIRROR_ROT0 = 1,
5306 + MMAL_DISPLAY_MIRROR_ROT180 = 2,
5307 + MMAL_DISPLAY_ROT180 = 3,
5308 + MMAL_DISPLAY_MIRROR_ROT90 = 4,
5309 + MMAL_DISPLAY_ROT270 = 5,
5310 + MMAL_DISPLAY_ROT90 = 6,
5311 + MMAL_DISPLAY_MIRROR_ROT270 = 7,
5312 +};
5313 +
5314 +enum mmal_parameter_displaymode {
5315 + MMAL_DISPLAY_MODE_FILL = 0,
5316 + MMAL_DISPLAY_MODE_LETTERBOX = 1,
5317 +};
5318 +
5319 +enum mmal_parameter_displayset {
5320 + MMAL_DISPLAY_SET_NONE = 0,
5321 + MMAL_DISPLAY_SET_NUM = 1,
5322 + MMAL_DISPLAY_SET_FULLSCREEN = 2,
5323 + MMAL_DISPLAY_SET_TRANSFORM = 4,
5324 + MMAL_DISPLAY_SET_DEST_RECT = 8,
5325 + MMAL_DISPLAY_SET_SRC_RECT = 0x10,
5326 + MMAL_DISPLAY_SET_MODE = 0x20,
5327 + MMAL_DISPLAY_SET_PIXEL = 0x40,
5328 + MMAL_DISPLAY_SET_NOASPECT = 0x80,
5329 + MMAL_DISPLAY_SET_LAYER = 0x100,
5330 + MMAL_DISPLAY_SET_COPYPROTECT = 0x200,
5331 + MMAL_DISPLAY_SET_ALPHA = 0x400,
5332 +};
5333 +
5334 +/* rectangle, used lots so it gets its own struct */
5335 +struct vchiq_mmal_rect {
5336 + s32 x;
5337 + s32 y;
5338 + s32 width;
5339 + s32 height;
5340 +};
5341 +
5342 +struct mmal_parameter_displayregion {
5343 + /** Bitfield that indicates which fields are set and should be
5344 + * used. All other fields will maintain their current value.
5345 + * \ref MMAL_DISPLAYSET_T defines the bits that can be
5346 + * combined.
5347 + */
5348 + u32 set;
5349 +
5350 + /** Describes the display output device, with 0 typically
5351 + * being a directly connected LCD display. The actual values
5352 + * will depend on the hardware. Code using hard-wired numbers
5353 + * (e.g. 2) is certain to fail.
5354 + */
5355 +
5356 + u32 display_num;
5357 + /** Indicates that we are using the full device screen area,
5358 + * rather than a window of the display. If zero, then
5359 + * dest_rect is used to specify a region of the display to
5360 + * use.
5361 + */
5362 +
5363 + s32 fullscreen;
5364 + /** Indicates any rotation or flipping used to map frames onto
5365 + * the natural display orientation.
5366 + */
5367 + u32 transform; /* enum mmal_parameter_displaytransform */
5368 +
5369 + /** Where to display the frame within the screen, if
5370 + * fullscreen is zero.
5371 + */
5372 + struct vchiq_mmal_rect dest_rect;
5373 +
5374 + /** Indicates which area of the frame to display. If all
5375 + * values are zero, the whole frame will be used.
5376 + */
5377 + struct vchiq_mmal_rect src_rect;
5378 +
5379 + /** If set to non-zero, indicates that any display scaling
5380 + * should disregard the aspect ratio of the frame region being
5381 + * displayed.
5382 + */
5383 + s32 noaspect;
5384 +
5385 + /** Indicates how the image should be scaled to fit the
5386 + * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates
5387 + * that the image should fill the screen by potentially
5388 + * cropping the frames. Setting \code mode \endcode to \code
5389 + * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the
5390 + * source region should be displayed and black bars added if
5391 + * necessary.
5392 + */
5393 + u32 mode; /* enum mmal_parameter_displaymode */
5394 +
5395 + /** If non-zero, defines the width of a source pixel relative
5396 + * to \code pixel_y \endcode. If zero, then pixels default to
5397 + * being square.
5398 + */
5399 + u32 pixel_x;
5400 +
5401 + /** If non-zero, defines the height of a source pixel relative
5402 + * to \code pixel_x \endcode. If zero, then pixels default to
5403 + * being square.
5404 + */
5405 + u32 pixel_y;
5406 +
5407 + /** Sets the relative depth of the images, with greater values
5408 + * being in front of smaller values.
5409 + */
5410 + u32 layer;
5411 +
5412 + /** Set to non-zero to ensure copy protection is used on
5413 + * output.
5414 + */
5415 + s32 copyprotect_required;
5416 +
5417 + /** Level of opacity of the layer, where zero is fully
5418 + * transparent and 255 is fully opaque.
5419 + */
5420 + u32 alpha;
5421 +};
5422 +
5423 +#define MMAL_MAX_IMAGEFX_PARAMETERS 5
5424 +
5425 +struct mmal_parameter_imagefx_parameters {
5426 + enum mmal_parameter_imagefx effect;
5427 + u32 num_effect_params;
5428 + u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS];
5429 +};
5430 +
5431 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4
5432 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2
5433 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16
5434 +
5435 +struct mmal_parameter_camera_info_camera_t {
5436 + u32 port_id;
5437 + u32 max_width;
5438 + u32 max_height;
5439 + u32 lens_present;
5440 + u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN];
5441 +};
5442 +
5443 +enum mmal_parameter_camera_info_flash_type_t {
5444 + /* Make values explicit to ensure they match values in config ini */
5445 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0,
5446 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1,
5447 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2,
5448 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF
5449 +};
5450 +
5451 +struct mmal_parameter_camera_info_flash_t {
5452 + enum mmal_parameter_camera_info_flash_type_t flash_type;
5453 +};
5454 +
5455 +struct mmal_parameter_camera_info_t {
5456 + u32 num_cameras;
5457 + u32 num_flashes;
5458 + struct mmal_parameter_camera_info_camera_t
5459 + cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS];
5460 + struct mmal_parameter_camera_info_flash_t
5461 + flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES];
5462 +};
5463 +
5464 +#endif
5465 --- /dev/null
5466 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
5467 @@ -0,0 +1,166 @@
5468 +/* SPDX-License-Identifier: GPL-2.0 */
5469 +/*
5470 + * Broadcom BM2835 V4L2 driver
5471 + *
5472 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5473 + *
5474 + * Authors: Vincent Sanders @ Collabora
5475 + * Dave Stevenson @ Broadcom
5476 + * (now dave.stevenson@raspberrypi.org)
5477 + * Simon Mellor @ Broadcom
5478 + * Luke Diamand @ Broadcom
5479 + *
5480 + * MMAL interface to VCHIQ message passing
5481 + */
5482 +
5483 +#ifndef MMAL_VCHIQ_H
5484 +#define MMAL_VCHIQ_H
5485 +
5486 +#include "mmal-msg-format.h"
5487 +
5488 +#define MAX_PORT_COUNT 4
5489 +
5490 +/* Maximum size of the format extradata. */
5491 +#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
5492 +
5493 +struct vchiq_mmal_instance;
5494 +
5495 +enum vchiq_mmal_es_type {
5496 + MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
5497 + MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
5498 + MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
5499 + MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
5500 + MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
5501 +};
5502 +
5503 +struct vchiq_mmal_port_buffer {
5504 + unsigned int num; /* number of buffers */
5505 + u32 size; /* size of buffers */
5506 + u32 alignment; /* alignment of buffers */
5507 +};
5508 +
5509 +struct vchiq_mmal_port;
5510 +
5511 +typedef void (*vchiq_mmal_buffer_cb)(
5512 + struct vchiq_mmal_instance *instance,
5513 + struct vchiq_mmal_port *port,
5514 + int status, struct mmal_buffer *buffer,
5515 + unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
5516 +
5517 +struct vchiq_mmal_port {
5518 + bool enabled;
5519 + u32 handle;
5520 + u32 type; /* port type, cached to use on port info set */
5521 + u32 index; /* port index, cached to use on port info set */
5522 +
5523 + /* component port belongs to, allows simple deref */
5524 + struct vchiq_mmal_component *component;
5525 +
5526 + struct vchiq_mmal_port *connected; /* port conencted to */
5527 +
5528 + /* buffer info */
5529 + struct vchiq_mmal_port_buffer minimum_buffer;
5530 + struct vchiq_mmal_port_buffer recommended_buffer;
5531 + struct vchiq_mmal_port_buffer current_buffer;
5532 +
5533 + /* stream format */
5534 + struct mmal_es_format_local format;
5535 + /* elementary stream format */
5536 + union mmal_es_specific_format es;
5537 +
5538 + /* data buffers to fill */
5539 + struct list_head buffers;
5540 + /* lock to serialise adding and removing buffers from list */
5541 + spinlock_t slock;
5542 +
5543 + /* Count of buffers the VPU has yet to return */
5544 + atomic_t buffers_with_vpu;
5545 + /* callback on buffer completion */
5546 + vchiq_mmal_buffer_cb buffer_cb;
5547 + /* callback context */
5548 + void *cb_ctx;
5549 +};
5550 +
5551 +struct vchiq_mmal_component {
5552 + bool enabled;
5553 + u32 handle; /* VideoCore handle for component */
5554 + u32 inputs; /* Number of input ports */
5555 + u32 outputs; /* Number of output ports */
5556 + u32 clocks; /* Number of clock ports */
5557 + struct vchiq_mmal_port control; /* control port */
5558 + struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
5559 + struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
5560 + struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
5561 +};
5562 +
5563 +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
5564 +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
5565 +
5566 +/* Initialise a mmal component and its ports
5567 + *
5568 + */
5569 +int vchiq_mmal_component_init(
5570 + struct vchiq_mmal_instance *instance,
5571 + const char *name,
5572 + struct vchiq_mmal_component **component_out);
5573 +
5574 +int vchiq_mmal_component_finalise(
5575 + struct vchiq_mmal_instance *instance,
5576 + struct vchiq_mmal_component *component);
5577 +
5578 +int vchiq_mmal_component_enable(
5579 + struct vchiq_mmal_instance *instance,
5580 + struct vchiq_mmal_component *component);
5581 +
5582 +int vchiq_mmal_component_disable(
5583 + struct vchiq_mmal_instance *instance,
5584 + struct vchiq_mmal_component *component);
5585 +
5586 +/* enable a mmal port
5587 + *
5588 + * enables a port and if a buffer callback provided enque buffer
5589 + * headers as appropriate for the port.
5590 + */
5591 +int vchiq_mmal_port_enable(
5592 + struct vchiq_mmal_instance *instance,
5593 + struct vchiq_mmal_port *port,
5594 + vchiq_mmal_buffer_cb buffer_cb);
5595 +
5596 +/* disable a port
5597 + *
5598 + * disable a port will dequeue any pending buffers
5599 + */
5600 +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
5601 + struct vchiq_mmal_port *port);
5602 +
5603 +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
5604 + struct vchiq_mmal_port *port,
5605 + u32 parameter,
5606 + void *value,
5607 + u32 value_size);
5608 +
5609 +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
5610 + struct vchiq_mmal_port *port,
5611 + u32 parameter,
5612 + void *value,
5613 + u32 *value_size);
5614 +
5615 +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
5616 + struct vchiq_mmal_port *port);
5617 +
5618 +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
5619 + struct vchiq_mmal_port *src,
5620 + struct vchiq_mmal_port *dst);
5621 +
5622 +int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
5623 + u32 *major_out,
5624 + u32 *minor_out);
5625 +
5626 +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
5627 + struct vchiq_mmal_port *port,
5628 + struct mmal_buffer *buf);
5629 +
5630 +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
5631 + struct mmal_buffer *buf);
5632 +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
5633 +#endif /* MMAL_VCHIQ_H */