1 From 0243782f98be0fe65ec38e6102e06c02df9fe8ec 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 264/782] staging: vc04_services: Split vchiq-mmal into a
7 In preparation for adding a video codec V4L2 module which also
8 wants to use vchiq-mmal functions, split it out into an
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.
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
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 +++++++
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 +++++++++++++++++++
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%)
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"
49 source "drivers/staging/vc04_services/bcm2835-camera/Kconfig"
50 +source "drivers/staging/vc04_services/vchiq-mmal/Kconfig"
54 --- a/drivers/staging/vc04_services/Makefile
55 +++ b/drivers/staging/vc04_services/Makefile
56 @@ -12,6 +12,7 @@ vchiq-objs := \
58 obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/
59 obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/
60 +obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += vchiq-mmal/
62 ccflags-y += -Idrivers/staging/vc04_services -D__VCCOREVER__=0x04000000
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
75 --- a/drivers/staging/vc04_services/bcm2835-camera/Makefile
76 +++ b/drivers/staging/vc04_services/bcm2835-camera/Makefile
78 # SPDX-License-Identifier: GPL-2.0
79 bcm2835-v4l2-$(CONFIG_VIDEO_BCM2835) := \
85 obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-v4l2.o
88 -Idrivers/staging/vc04_services \
89 + -Idrivers/staging/vc04_services/vchiq-mmal \
90 -D__VCCOREVER__=0x04000000
92 +++ b/drivers/staging/vc04_services/vchiq-mmal/Kconfig
94 +config BCM2835_VCHIQ_MMAL
95 + tristate "BCM2835 MMAL VCHIQ service"
96 + depends on (ARCH_BCM2835 || COMPILE_TEST)
97 + select BCM2835_VCHIQ
99 + Enables the MMAL API over VCHIQ as used for the
100 + majority of the multimedia services on VideoCore.
102 +++ b/drivers/staging/vc04_services/vchiq-mmal/Makefile
104 +# SPDX-License-Identifier: GPL-2.0
105 +bcm2835-mmal-vchiq-objs := mmal-vchiq.o
107 +obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += bcm2835-mmal-vchiq.o
110 + -Idrivers/staging/vc04_services \
111 + -D__VCCOREVER__=0x04000000
112 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
115 -// SPDX-License-Identifier: GPL-2.0
117 - * Broadcom BM2835 V4L2 driver
119 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
121 - * Authors: Vincent Sanders @ Collabora
122 - * Dave Stevenson @ Broadcom
123 - * (now dave.stevenson@raspberrypi.org)
124 - * Simon Mellor @ Broadcom
125 - * Luke Diamand @ Broadcom
127 - * V4L2 driver MMAL vchiq interface code
130 -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
132 -#include <linux/errno.h>
133 -#include <linux/kernel.h>
134 -#include <linux/mutex.h>
135 -#include <linux/mm.h>
136 -#include <linux/slab.h>
137 -#include <linux/completion.h>
138 -#include <linux/vmalloc.h>
139 -#include <asm/cacheflush.h>
140 -#include <media/videobuf2-vmalloc.h>
142 -#include "mmal-common.h"
143 -#include "mmal-vchiq.h"
144 -#include "mmal-msg.h"
146 -#define USE_VCHIQ_ARM
147 -#include "interface/vchi/vchi.h"
149 -/* maximum number of components supported */
150 -#define VCHIQ_MMAL_MAX_COMPONENTS 4
152 -/*#define FULL_MSG_DUMP 1*/
155 -static const char *const msg_type_names[] = {
160 - "COMPONENT_CREATE",
161 - "COMPONENT_DESTROY",
162 - "COMPONENT_ENABLE",
163 - "COMPONENT_DISABLE",
167 - "BUFFER_FROM_HOST",
170 - "PORT_PARAMETER_SET",
171 - "PORT_PARAMETER_GET",
173 - "GET_CORE_STATS_FOR_PORT",
174 - "OPAQUE_ALLOCATOR",
177 - "OPAQUE_ALLOCATOR_DESC",
180 - "BUFFER_FROM_HOST_ZEROLEN",
186 -static const char *const port_action_type_names[] = {
193 - "SET_REQUIREMENTS",
197 -#if defined(FULL_MSG_DUMP)
198 -#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
200 - pr_debug(TITLE" type:%s(%d) length:%d\n", \
201 - msg_type_names[(MSG)->h.type], \
202 - (MSG)->h.type, (MSG_LEN)); \
203 - print_hex_dump(KERN_DEBUG, "<<h: ", DUMP_PREFIX_OFFSET, \
205 - sizeof(struct mmal_msg_header), 1); \
206 - print_hex_dump(KERN_DEBUG, "<<p: ", DUMP_PREFIX_OFFSET, \
208 - ((u8 *)(MSG)) + sizeof(struct mmal_msg_header),\
209 - (MSG_LEN) - sizeof(struct mmal_msg_header), 1); \
212 -#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
214 - pr_debug(TITLE" type:%s(%d) length:%d\n", \
215 - msg_type_names[(MSG)->h.type], \
216 - (MSG)->h.type, (MSG_LEN)); \
220 -#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE)
223 -struct vchiq_mmal_instance;
225 -/* normal message context */
226 -struct mmal_msg_context {
227 - struct vchiq_mmal_instance *instance;
229 - /* Index in the context_map idr so that we can find the
230 - * mmal_msg_context again when servicing the VCHI reply.
236 - /* work struct for buffer_cb callback */
237 - struct work_struct work;
238 - /* work struct for deferred callback */
239 - struct work_struct buffer_to_host_work;
240 - /* mmal instance */
241 - struct vchiq_mmal_instance *instance;
243 - struct vchiq_mmal_port *port;
244 - /* actual buffer used to store bulk reply */
245 - struct mmal_buffer *buffer;
246 - /* amount of buffer used */
247 - unsigned long buffer_used;
248 - /* MMAL buffer flags */
250 - /* Presentation and Decode timestamps */
254 - int status; /* context status */
256 - } bulk; /* bulk data */
259 - /* message handle to release */
260 - VCHI_HELD_MSG_T msg_handle;
261 - /* pointer to received message */
262 - struct mmal_msg *msg;
263 - /* received message length */
265 - /* completion upon reply */
266 - struct completion cmplt;
267 - } sync; /* synchronous response */
272 -struct vchiq_mmal_instance {
273 - VCHI_SERVICE_HANDLE_T handle;
275 - /* ensure serialised access to service */
276 - struct mutex vchiq_mutex;
278 - /* vmalloc page to receive scratch bulk xfers into */
279 - void *bulk_scratch;
281 - struct idr context_map;
282 - /* protect accesses to context_map */
283 - struct mutex context_map_lock;
285 - /* component to use next */
287 - struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
289 - /* ordered workqueue to process all bulk operations */
290 - struct workqueue_struct *bulk_wq;
293 -static struct mmal_msg_context *
294 -get_msg_context(struct vchiq_mmal_instance *instance)
296 - struct mmal_msg_context *msg_context;
299 - /* todo: should this be allocated from a pool to avoid kzalloc */
300 - msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
303 - return ERR_PTR(-ENOMEM);
305 - /* Create an ID that will be passed along with our message so
306 - * that when we service the VCHI reply, we can look up what
307 - * message is being replied to.
309 - mutex_lock(&instance->context_map_lock);
310 - handle = idr_alloc(&instance->context_map, msg_context,
312 - mutex_unlock(&instance->context_map_lock);
315 - kfree(msg_context);
316 - return ERR_PTR(handle);
319 - msg_context->instance = instance;
320 - msg_context->handle = handle;
322 - return msg_context;
325 -static struct mmal_msg_context *
326 -lookup_msg_context(struct vchiq_mmal_instance *instance, int handle)
328 - return idr_find(&instance->context_map, handle);
332 -release_msg_context(struct mmal_msg_context *msg_context)
334 - struct vchiq_mmal_instance *instance = msg_context->instance;
336 - mutex_lock(&instance->context_map_lock);
337 - idr_remove(&instance->context_map, msg_context->handle);
338 - mutex_unlock(&instance->context_map_lock);
339 - kfree(msg_context);
342 -/* deals with receipt of event to host message */
343 -static void event_to_host_cb(struct vchiq_mmal_instance *instance,
344 - struct mmal_msg *msg, u32 msg_len)
346 - pr_debug("unhandled event\n");
347 - pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n",
348 - msg->u.event_to_host.client_component,
349 - msg->u.event_to_host.port_type,
350 - msg->u.event_to_host.port_num,
351 - msg->u.event_to_host.cmd, msg->u.event_to_host.length);
354 -/* workqueue scheduled callback
356 - * we do this because it is important we do not call any other vchiq
357 - * sync calls from witin the message delivery thread
359 -static void buffer_work_cb(struct work_struct *work)
361 - struct mmal_msg_context *msg_context =
362 - container_of(work, struct mmal_msg_context, u.bulk.work);
364 - atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu);
366 - msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
367 - msg_context->u.bulk.port,
368 - msg_context->u.bulk.status,
369 - msg_context->u.bulk.buffer,
370 - msg_context->u.bulk.buffer_used,
371 - msg_context->u.bulk.mmal_flags,
372 - msg_context->u.bulk.dts,
373 - msg_context->u.bulk.pts);
376 -/* workqueue scheduled callback to handle receiving buffers
378 - * VCHI will allow up to 4 bulk receives to be scheduled before blocking.
379 - * If we block in the service_callback context then we can't process the
380 - * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked
381 - * vchi_bulk_queue_receive() call to complete.
383 -static void buffer_to_host_work_cb(struct work_struct *work)
385 - struct mmal_msg_context *msg_context =
386 - container_of(work, struct mmal_msg_context,
387 - u.bulk.buffer_to_host_work);
388 - struct vchiq_mmal_instance *instance = msg_context->instance;
389 - unsigned long len = msg_context->u.bulk.buffer_used;
393 - /* Dummy receive to ensure the buffers remain in order */
395 - /* queue the bulk submission */
396 - vchi_service_use(instance->handle);
397 - ret = vchi_bulk_queue_receive(instance->handle,
398 - msg_context->u.bulk.buffer->buffer,
399 - /* Actual receive needs to be a multiple
403 - VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE |
404 - VCHI_FLAGS_BLOCK_UNTIL_QUEUED,
407 - vchi_service_release(instance->handle);
410 - pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n",
411 - __func__, msg_context, ret);
414 -/* enqueue a bulk receive for a given message context */
415 -static int bulk_receive(struct vchiq_mmal_instance *instance,
416 - struct mmal_msg *msg,
417 - struct mmal_msg_context *msg_context)
419 - unsigned long rd_len;
421 - rd_len = msg->u.buffer_from_host.buffer_header.length;
423 - if (!msg_context->u.bulk.buffer) {
424 - pr_err("bulk.buffer not configured - error in buffer_from_host\n");
426 - /* todo: this is a serious error, we should never have
427 - * committed a buffer_to_host operation to the mmal
428 - * port without the buffer to back it up (underflow
429 - * handling) and there is no obvious way to deal with
430 - * this - how is the mmal servie going to react when
431 - * we fail to do the xfer and reschedule a buffer when
432 - * it arrives? perhaps a starved flag to indicate a
433 - * waiting bulk receive?
439 - /* ensure we do not overrun the available buffer */
440 - if (rd_len > msg_context->u.bulk.buffer->buffer_size) {
441 - rd_len = msg_context->u.bulk.buffer->buffer_size;
442 - pr_warn("short read as not enough receive buffer space\n");
443 - /* todo: is this the correct response, what happens to
444 - * the rest of the message data?
449 - msg_context->u.bulk.buffer_used = rd_len;
450 - msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts;
451 - msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts;
453 - queue_work(msg_context->instance->bulk_wq,
454 - &msg_context->u.bulk.buffer_to_host_work);
459 -/* data in message, memcpy from packet into output buffer */
460 -static int inline_receive(struct vchiq_mmal_instance *instance,
461 - struct mmal_msg *msg,
462 - struct mmal_msg_context *msg_context)
464 - memcpy(msg_context->u.bulk.buffer->buffer,
465 - msg->u.buffer_from_host.short_data,
466 - msg->u.buffer_from_host.payload_in_message);
468 - msg_context->u.bulk.buffer_used =
469 - msg->u.buffer_from_host.payload_in_message;
474 -/* queue the buffer availability with MMAL_MSG_TYPE_BUFFER_FROM_HOST */
476 -buffer_from_host(struct vchiq_mmal_instance *instance,
477 - struct vchiq_mmal_port *port, struct mmal_buffer *buf)
479 - struct mmal_msg_context *msg_context;
483 - if (!port->enabled)
486 - pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
489 - if (!buf->msg_context) {
490 - pr_err("%s: msg_context not allocated, buf %p\n", __func__,
494 - msg_context = buf->msg_context;
496 - /* store bulk message context for when data arrives */
497 - msg_context->u.bulk.instance = instance;
498 - msg_context->u.bulk.port = port;
499 - msg_context->u.bulk.buffer = buf;
500 - msg_context->u.bulk.buffer_used = 0;
502 - /* initialise work structure ready to schedule callback */
503 - INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb);
504 - INIT_WORK(&msg_context->u.bulk.buffer_to_host_work,
505 - buffer_to_host_work_cb);
507 - atomic_inc(&port->buffers_with_vpu);
509 - /* prep the buffer from host message */
510 - memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */
512 - m.h.type = MMAL_MSG_TYPE_BUFFER_FROM_HOST;
513 - m.h.magic = MMAL_MAGIC;
514 - m.h.context = msg_context->handle;
517 - /* drvbuf is our private data passed back */
518 - m.u.buffer_from_host.drvbuf.magic = MMAL_MAGIC;
519 - m.u.buffer_from_host.drvbuf.component_handle = port->component->handle;
520 - m.u.buffer_from_host.drvbuf.port_handle = port->handle;
521 - m.u.buffer_from_host.drvbuf.client_context = msg_context->handle;
523 - /* buffer header */
524 - m.u.buffer_from_host.buffer_header.cmd = 0;
525 - m.u.buffer_from_host.buffer_header.data =
526 - (u32)(unsigned long)buf->buffer;
527 - m.u.buffer_from_host.buffer_header.alloc_size = buf->buffer_size;
528 - m.u.buffer_from_host.buffer_header.length = 0; /* nothing used yet */
529 - m.u.buffer_from_host.buffer_header.offset = 0; /* no offset */
530 - m.u.buffer_from_host.buffer_header.flags = 0; /* no flags */
531 - m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN;
532 - m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN;
534 - /* clear buffer type sepecific data */
535 - memset(&m.u.buffer_from_host.buffer_header_type_specific, 0,
536 - sizeof(m.u.buffer_from_host.buffer_header_type_specific));
538 - /* no payload in message */
539 - m.u.buffer_from_host.payload_in_message = 0;
541 - vchi_service_use(instance->handle);
543 - ret = vchi_queue_kernel_message(instance->handle,
545 - sizeof(struct mmal_msg_header) +
546 - sizeof(m.u.buffer_from_host));
548 - vchi_service_release(instance->handle);
553 -/* deals with receipt of buffer to host message */
554 -static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
555 - struct mmal_msg *msg, u32 msg_len)
557 - struct mmal_msg_context *msg_context;
560 - pr_debug("%s: instance:%p msg:%p msg_len:%d\n",
561 - __func__, instance, msg, msg_len);
563 - if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) {
564 - handle = msg->u.buffer_from_host.drvbuf.client_context;
565 - msg_context = lookup_msg_context(instance, handle);
567 - if (!msg_context) {
568 - pr_err("drvbuf.client_context(%u) is invalid\n",
573 - pr_err("MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n");
577 - msg_context->u.bulk.mmal_flags =
578 - msg->u.buffer_from_host.buffer_header.flags;
580 - if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) {
581 - /* message reception had an error */
582 - pr_warn("error %d in reply\n", msg->h.status);
584 - msg_context->u.bulk.status = msg->h.status;
586 - } else if (msg->u.buffer_from_host.buffer_header.length == 0) {
588 - if (msg->u.buffer_from_host.buffer_header.flags &
589 - MMAL_BUFFER_HEADER_FLAG_EOS) {
590 - msg_context->u.bulk.status =
591 - bulk_receive(instance, msg, msg_context);
592 - if (msg_context->u.bulk.status == 0)
593 - return; /* successful bulk submission, bulk
594 - * completion will trigger callback
597 - /* do callback with empty buffer - not EOS though */
598 - msg_context->u.bulk.status = 0;
599 - msg_context->u.bulk.buffer_used = 0;
601 - } else if (msg->u.buffer_from_host.payload_in_message == 0) {
602 - /* data is not in message, queue a bulk receive */
603 - msg_context->u.bulk.status =
604 - bulk_receive(instance, msg, msg_context);
605 - if (msg_context->u.bulk.status == 0)
606 - return; /* successful bulk submission, bulk
607 - * completion will trigger callback
610 - /* failed to submit buffer, this will end badly */
611 - pr_err("error %d on bulk submission\n",
612 - msg_context->u.bulk.status);
614 - } else if (msg->u.buffer_from_host.payload_in_message <=
615 - MMAL_VC_SHORT_DATA) {
616 - /* data payload within message */
617 - msg_context->u.bulk.status = inline_receive(instance, msg,
620 - pr_err("message with invalid short payload\n");
623 - msg_context->u.bulk.status = -EINVAL;
624 - msg_context->u.bulk.buffer_used =
625 - msg->u.buffer_from_host.payload_in_message;
628 - /* schedule the port callback */
629 - schedule_work(&msg_context->u.bulk.work);
632 -static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
633 - struct mmal_msg_context *msg_context)
635 - msg_context->u.bulk.status = 0;
637 - /* schedule the port callback */
638 - schedule_work(&msg_context->u.bulk.work);
641 -static void bulk_abort_cb(struct vchiq_mmal_instance *instance,
642 - struct mmal_msg_context *msg_context)
644 - pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
646 - msg_context->u.bulk.status = -EINTR;
648 - schedule_work(&msg_context->u.bulk.work);
651 -/* incoming event service callback */
652 -static void service_callback(void *param,
653 - const VCHI_CALLBACK_REASON_T reason,
656 - struct vchiq_mmal_instance *instance = param;
659 - struct mmal_msg *msg;
660 - VCHI_HELD_MSG_T msg_handle;
661 - struct mmal_msg_context *msg_context;
664 - pr_err("Message callback passed NULL instance\n");
669 - case VCHI_CALLBACK_MSG_AVAILABLE:
670 - status = vchi_msg_hold(instance->handle, (void **)&msg,
671 - &msg_len, VCHI_FLAGS_NONE, &msg_handle);
673 - pr_err("Unable to dequeue a message (%d)\n", status);
677 - DBG_DUMP_MSG(msg, msg_len, "<<< reply message");
679 - /* handling is different for buffer messages */
680 - switch (msg->h.type) {
681 - case MMAL_MSG_TYPE_BUFFER_FROM_HOST:
682 - vchi_held_msg_release(&msg_handle);
685 - case MMAL_MSG_TYPE_EVENT_TO_HOST:
686 - event_to_host_cb(instance, msg, msg_len);
687 - vchi_held_msg_release(&msg_handle);
691 - case MMAL_MSG_TYPE_BUFFER_TO_HOST:
692 - buffer_to_host_cb(instance, msg, msg_len);
693 - vchi_held_msg_release(&msg_handle);
697 - /* messages dependent on header context to complete */
698 - if (!msg->h.context) {
699 - pr_err("received message context was null!\n");
700 - vchi_held_msg_release(&msg_handle);
704 - msg_context = lookup_msg_context(instance,
706 - if (!msg_context) {
707 - pr_err("received invalid message context %u!\n",
709 - vchi_held_msg_release(&msg_handle);
713 - /* fill in context values */
714 - msg_context->u.sync.msg_handle = msg_handle;
715 - msg_context->u.sync.msg = msg;
716 - msg_context->u.sync.msg_len = msg_len;
718 - /* todo: should this check (completion_done()
719 - * == 1) for no one waiting? or do we need a
720 - * flag to tell us the completion has been
721 - * interrupted so we can free the message and
722 - * its context. This probably also solves the
723 - * message arriving after interruption todo
727 - /* complete message so caller knows it happened */
728 - complete(&msg_context->u.sync.cmplt);
734 - case VCHI_CALLBACK_BULK_RECEIVED:
735 - bulk_receive_cb(instance, bulk_ctx);
738 - case VCHI_CALLBACK_BULK_RECEIVE_ABORTED:
739 - bulk_abort_cb(instance, bulk_ctx);
742 - case VCHI_CALLBACK_SERVICE_CLOSED:
743 - /* TODO: consider if this requires action if received when
744 - * driver is not explicitly closing the service
749 - pr_err("Received unhandled message reason %d\n", reason);
754 -static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
755 - struct mmal_msg *msg,
756 - unsigned int payload_len,
757 - struct mmal_msg **msg_out,
758 - VCHI_HELD_MSG_T *msg_handle_out)
760 - struct mmal_msg_context *msg_context;
762 - unsigned long timeout;
764 - /* payload size must not cause message to exceed max size */
766 - (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) {
767 - pr_err("payload length %d exceeds max:%d\n", payload_len,
768 - (int)(MMAL_MSG_MAX_SIZE -
769 - sizeof(struct mmal_msg_header)));
773 - msg_context = get_msg_context(instance);
774 - if (IS_ERR(msg_context))
775 - return PTR_ERR(msg_context);
777 - init_completion(&msg_context->u.sync.cmplt);
779 - msg->h.magic = MMAL_MAGIC;
780 - msg->h.context = msg_context->handle;
783 - DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len),
784 - ">>> sync message");
786 - vchi_service_use(instance->handle);
788 - ret = vchi_queue_kernel_message(instance->handle,
790 - sizeof(struct mmal_msg_header) +
793 - vchi_service_release(instance->handle);
796 - pr_err("error %d queuing message\n", ret);
797 - release_msg_context(msg_context);
801 - timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt,
803 - if (timeout == 0) {
804 - pr_err("timed out waiting for sync completion\n");
806 - /* todo: what happens if the message arrives after aborting */
807 - release_msg_context(msg_context);
811 - *msg_out = msg_context->u.sync.msg;
812 - *msg_handle_out = msg_context->u.sync.msg_handle;
813 - release_msg_context(msg_context);
818 -static void dump_port_info(struct vchiq_mmal_port *port)
820 - pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled);
822 - pr_debug("buffer minimum num:%d size:%d align:%d\n",
823 - port->minimum_buffer.num,
824 - port->minimum_buffer.size, port->minimum_buffer.alignment);
826 - pr_debug("buffer recommended num:%d size:%d align:%d\n",
827 - port->recommended_buffer.num,
828 - port->recommended_buffer.size,
829 - port->recommended_buffer.alignment);
831 - pr_debug("buffer current values num:%d size:%d align:%d\n",
832 - port->current_buffer.num,
833 - port->current_buffer.size, port->current_buffer.alignment);
835 - pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n",
837 - port->format.encoding, port->format.encoding_variant);
839 - pr_debug(" bitrate:%d flags:0x%x\n",
840 - port->format.bitrate, port->format.flags);
842 - if (port->format.type == MMAL_ES_TYPE_VIDEO) {
844 - ("es video format: width:%d height:%d colourspace:0x%x\n",
845 - port->es.video.width, port->es.video.height,
846 - port->es.video.color_space);
848 - pr_debug(" : crop xywh %d,%d,%d,%d\n",
849 - port->es.video.crop.x,
850 - port->es.video.crop.y,
851 - port->es.video.crop.width, port->es.video.crop.height);
852 - pr_debug(" : framerate %d/%d aspect %d/%d\n",
853 - port->es.video.frame_rate.num,
854 - port->es.video.frame_rate.den,
855 - port->es.video.par.num, port->es.video.par.den);
859 -static void port_to_mmal_msg(struct vchiq_mmal_port *port, struct mmal_port *p)
861 - /* todo do readonly fields need setting at all? */
862 - p->type = port->type;
863 - p->index = port->index;
865 - p->is_enabled = port->enabled;
866 - p->buffer_num_min = port->minimum_buffer.num;
867 - p->buffer_size_min = port->minimum_buffer.size;
868 - p->buffer_alignment_min = port->minimum_buffer.alignment;
869 - p->buffer_num_recommended = port->recommended_buffer.num;
870 - p->buffer_size_recommended = port->recommended_buffer.size;
872 - /* only three writable fields in a port */
873 - p->buffer_num = port->current_buffer.num;
874 - p->buffer_size = port->current_buffer.size;
875 - p->userdata = (u32)(unsigned long)port;
878 -static int port_info_set(struct vchiq_mmal_instance *instance,
879 - struct vchiq_mmal_port *port)
883 - struct mmal_msg *rmsg;
884 - VCHI_HELD_MSG_T rmsg_handle;
886 - pr_debug("setting port info port %p\n", port);
889 - dump_port_info(port);
891 - m.h.type = MMAL_MSG_TYPE_PORT_INFO_SET;
893 - m.u.port_info_set.component_handle = port->component->handle;
894 - m.u.port_info_set.port_type = port->type;
895 - m.u.port_info_set.port_index = port->index;
897 - port_to_mmal_msg(port, &m.u.port_info_set.port);
899 - /* elementary stream format setup */
900 - m.u.port_info_set.format.type = port->format.type;
901 - m.u.port_info_set.format.encoding = port->format.encoding;
902 - m.u.port_info_set.format.encoding_variant =
903 - port->format.encoding_variant;
904 - m.u.port_info_set.format.bitrate = port->format.bitrate;
905 - m.u.port_info_set.format.flags = port->format.flags;
907 - memcpy(&m.u.port_info_set.es, &port->es,
908 - sizeof(union mmal_es_specific_format));
910 - m.u.port_info_set.format.extradata_size = port->format.extradata_size;
911 - memcpy(&m.u.port_info_set.extradata, port->format.extradata,
912 - port->format.extradata_size);
914 - ret = send_synchronous_mmal_msg(instance, &m,
915 - sizeof(m.u.port_info_set),
916 - &rmsg, &rmsg_handle);
920 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_SET) {
921 - /* got an unexpected message type in reply */
926 - /* return operation status */
927 - ret = -rmsg->u.port_info_get_reply.status;
929 - pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret,
930 - port->component->handle, port->handle);
933 - vchi_held_msg_release(&rmsg_handle);
938 -/* use port info get message to retrieve port information */
939 -static int port_info_get(struct vchiq_mmal_instance *instance,
940 - struct vchiq_mmal_port *port)
944 - struct mmal_msg *rmsg;
945 - VCHI_HELD_MSG_T rmsg_handle;
947 - /* port info time */
948 - m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET;
949 - m.u.port_info_get.component_handle = port->component->handle;
950 - m.u.port_info_get.port_type = port->type;
951 - m.u.port_info_get.index = port->index;
953 - ret = send_synchronous_mmal_msg(instance, &m,
954 - sizeof(m.u.port_info_get),
955 - &rmsg, &rmsg_handle);
959 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_GET) {
960 - /* got an unexpected message type in reply */
965 - /* return operation status */
966 - ret = -rmsg->u.port_info_get_reply.status;
967 - if (ret != MMAL_MSG_STATUS_SUCCESS)
970 - if (rmsg->u.port_info_get_reply.port.is_enabled == 0)
971 - port->enabled = false;
973 - port->enabled = true;
975 - /* copy the values out of the message */
976 - port->handle = rmsg->u.port_info_get_reply.port_handle;
978 - /* port type and index cached to use on port info set because
979 - * it does not use a port handle
981 - port->type = rmsg->u.port_info_get_reply.port_type;
982 - port->index = rmsg->u.port_info_get_reply.port_index;
984 - port->minimum_buffer.num =
985 - rmsg->u.port_info_get_reply.port.buffer_num_min;
986 - port->minimum_buffer.size =
987 - rmsg->u.port_info_get_reply.port.buffer_size_min;
988 - port->minimum_buffer.alignment =
989 - rmsg->u.port_info_get_reply.port.buffer_alignment_min;
991 - port->recommended_buffer.alignment =
992 - rmsg->u.port_info_get_reply.port.buffer_alignment_min;
993 - port->recommended_buffer.num =
994 - rmsg->u.port_info_get_reply.port.buffer_num_recommended;
996 - port->current_buffer.num = rmsg->u.port_info_get_reply.port.buffer_num;
997 - port->current_buffer.size =
998 - rmsg->u.port_info_get_reply.port.buffer_size;
1000 - /* stream format */
1001 - port->format.type = rmsg->u.port_info_get_reply.format.type;
1002 - port->format.encoding = rmsg->u.port_info_get_reply.format.encoding;
1003 - port->format.encoding_variant =
1004 - rmsg->u.port_info_get_reply.format.encoding_variant;
1005 - port->format.bitrate = rmsg->u.port_info_get_reply.format.bitrate;
1006 - port->format.flags = rmsg->u.port_info_get_reply.format.flags;
1008 - /* elementary stream format */
1010 - &rmsg->u.port_info_get_reply.es,
1011 - sizeof(union mmal_es_specific_format));
1012 - port->format.es = &port->es;
1014 - port->format.extradata_size =
1015 - rmsg->u.port_info_get_reply.format.extradata_size;
1016 - memcpy(port->format.extradata,
1017 - rmsg->u.port_info_get_reply.extradata,
1018 - port->format.extradata_size);
1020 - pr_debug("received port info\n");
1021 - dump_port_info(port);
1025 - pr_debug("%s:result:%d component:0x%x port:%d\n",
1026 - __func__, ret, port->component->handle, port->handle);
1028 - vchi_held_msg_release(&rmsg_handle);
1033 -/* create comonent on vc */
1034 -static int create_component(struct vchiq_mmal_instance *instance,
1035 - struct vchiq_mmal_component *component,
1039 - struct mmal_msg m;
1040 - struct mmal_msg *rmsg;
1041 - VCHI_HELD_MSG_T rmsg_handle;
1043 - /* build component create message */
1044 - m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE;
1045 - m.u.component_create.client_component = (u32)(unsigned long)component;
1046 - strncpy(m.u.component_create.name, name,
1047 - sizeof(m.u.component_create.name));
1049 - ret = send_synchronous_mmal_msg(instance, &m,
1050 - sizeof(m.u.component_create),
1051 - &rmsg, &rmsg_handle);
1055 - if (rmsg->h.type != m.h.type) {
1056 - /* got an unexpected message type in reply */
1061 - ret = -rmsg->u.component_create_reply.status;
1062 - if (ret != MMAL_MSG_STATUS_SUCCESS)
1065 - /* a valid component response received */
1066 - component->handle = rmsg->u.component_create_reply.component_handle;
1067 - component->inputs = rmsg->u.component_create_reply.input_num;
1068 - component->outputs = rmsg->u.component_create_reply.output_num;
1069 - component->clocks = rmsg->u.component_create_reply.clock_num;
1071 - pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n",
1072 - component->handle,
1073 - component->inputs, component->outputs, component->clocks);
1076 - vchi_held_msg_release(&rmsg_handle);
1081 -/* destroys a component on vc */
1082 -static int destroy_component(struct vchiq_mmal_instance *instance,
1083 - struct vchiq_mmal_component *component)
1086 - struct mmal_msg m;
1087 - struct mmal_msg *rmsg;
1088 - VCHI_HELD_MSG_T rmsg_handle;
1090 - m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY;
1091 - m.u.component_destroy.component_handle = component->handle;
1093 - ret = send_synchronous_mmal_msg(instance, &m,
1094 - sizeof(m.u.component_destroy),
1095 - &rmsg, &rmsg_handle);
1099 - if (rmsg->h.type != m.h.type) {
1100 - /* got an unexpected message type in reply */
1105 - ret = -rmsg->u.component_destroy_reply.status;
1109 - vchi_held_msg_release(&rmsg_handle);
1114 -/* enable a component on vc */
1115 -static int enable_component(struct vchiq_mmal_instance *instance,
1116 - struct vchiq_mmal_component *component)
1119 - struct mmal_msg m;
1120 - struct mmal_msg *rmsg;
1121 - VCHI_HELD_MSG_T rmsg_handle;
1123 - m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE;
1124 - m.u.component_enable.component_handle = component->handle;
1126 - ret = send_synchronous_mmal_msg(instance, &m,
1127 - sizeof(m.u.component_enable),
1128 - &rmsg, &rmsg_handle);
1132 - if (rmsg->h.type != m.h.type) {
1133 - /* got an unexpected message type in reply */
1138 - ret = -rmsg->u.component_enable_reply.status;
1141 - vchi_held_msg_release(&rmsg_handle);
1146 -/* disable a component on vc */
1147 -static int disable_component(struct vchiq_mmal_instance *instance,
1148 - struct vchiq_mmal_component *component)
1151 - struct mmal_msg m;
1152 - struct mmal_msg *rmsg;
1153 - VCHI_HELD_MSG_T rmsg_handle;
1155 - m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE;
1156 - m.u.component_disable.component_handle = component->handle;
1158 - ret = send_synchronous_mmal_msg(instance, &m,
1159 - sizeof(m.u.component_disable),
1160 - &rmsg, &rmsg_handle);
1164 - if (rmsg->h.type != m.h.type) {
1165 - /* got an unexpected message type in reply */
1170 - ret = -rmsg->u.component_disable_reply.status;
1174 - vchi_held_msg_release(&rmsg_handle);
1179 -/* get version of mmal implementation */
1180 -static int get_version(struct vchiq_mmal_instance *instance,
1181 - u32 *major_out, u32 *minor_out)
1184 - struct mmal_msg m;
1185 - struct mmal_msg *rmsg;
1186 - VCHI_HELD_MSG_T rmsg_handle;
1188 - m.h.type = MMAL_MSG_TYPE_GET_VERSION;
1190 - ret = send_synchronous_mmal_msg(instance, &m,
1191 - sizeof(m.u.version),
1192 - &rmsg, &rmsg_handle);
1196 - if (rmsg->h.type != m.h.type) {
1197 - /* got an unexpected message type in reply */
1202 - *major_out = rmsg->u.version.major;
1203 - *minor_out = rmsg->u.version.minor;
1206 - vchi_held_msg_release(&rmsg_handle);
1211 -/* do a port action with a port as a parameter */
1212 -static int port_action_port(struct vchiq_mmal_instance *instance,
1213 - struct vchiq_mmal_port *port,
1214 - enum mmal_msg_port_action_type action_type)
1217 - struct mmal_msg m;
1218 - struct mmal_msg *rmsg;
1219 - VCHI_HELD_MSG_T rmsg_handle;
1221 - m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
1222 - m.u.port_action_port.component_handle = port->component->handle;
1223 - m.u.port_action_port.port_handle = port->handle;
1224 - m.u.port_action_port.action = action_type;
1226 - port_to_mmal_msg(port, &m.u.port_action_port.port);
1228 - ret = send_synchronous_mmal_msg(instance, &m,
1229 - sizeof(m.u.port_action_port),
1230 - &rmsg, &rmsg_handle);
1234 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
1235 - /* got an unexpected message type in reply */
1240 - ret = -rmsg->u.port_action_reply.status;
1242 - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n",
1244 - ret, port->component->handle, port->handle,
1245 - port_action_type_names[action_type], action_type);
1248 - vchi_held_msg_release(&rmsg_handle);
1253 -/* do a port action with handles as parameters */
1254 -static int port_action_handle(struct vchiq_mmal_instance *instance,
1255 - struct vchiq_mmal_port *port,
1256 - enum mmal_msg_port_action_type action_type,
1257 - u32 connect_component_handle,
1258 - u32 connect_port_handle)
1261 - struct mmal_msg m;
1262 - struct mmal_msg *rmsg;
1263 - VCHI_HELD_MSG_T rmsg_handle;
1265 - m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
1267 - m.u.port_action_handle.component_handle = port->component->handle;
1268 - m.u.port_action_handle.port_handle = port->handle;
1269 - m.u.port_action_handle.action = action_type;
1271 - m.u.port_action_handle.connect_component_handle =
1272 - connect_component_handle;
1273 - m.u.port_action_handle.connect_port_handle = connect_port_handle;
1275 - ret = send_synchronous_mmal_msg(instance, &m,
1276 - sizeof(m.u.port_action_handle),
1277 - &rmsg, &rmsg_handle);
1281 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
1282 - /* got an unexpected message type in reply */
1287 - ret = -rmsg->u.port_action_reply.status;
1289 - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
1291 - ret, port->component->handle, port->handle,
1292 - port_action_type_names[action_type],
1293 - action_type, connect_component_handle, connect_port_handle);
1296 - vchi_held_msg_release(&rmsg_handle);
1301 -static int port_parameter_set(struct vchiq_mmal_instance *instance,
1302 - struct vchiq_mmal_port *port,
1303 - u32 parameter_id, void *value, u32 value_size)
1306 - struct mmal_msg m;
1307 - struct mmal_msg *rmsg;
1308 - VCHI_HELD_MSG_T rmsg_handle;
1310 - m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET;
1312 - m.u.port_parameter_set.component_handle = port->component->handle;
1313 - m.u.port_parameter_set.port_handle = port->handle;
1314 - m.u.port_parameter_set.id = parameter_id;
1315 - m.u.port_parameter_set.size = (2 * sizeof(u32)) + value_size;
1316 - memcpy(&m.u.port_parameter_set.value, value, value_size);
1318 - ret = send_synchronous_mmal_msg(instance, &m,
1319 - (4 * sizeof(u32)) + value_size,
1320 - &rmsg, &rmsg_handle);
1324 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_SET) {
1325 - /* got an unexpected message type in reply */
1330 - ret = -rmsg->u.port_parameter_set_reply.status;
1332 - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n",
1334 - ret, port->component->handle, port->handle, parameter_id);
1337 - vchi_held_msg_release(&rmsg_handle);
1342 -static int port_parameter_get(struct vchiq_mmal_instance *instance,
1343 - struct vchiq_mmal_port *port,
1344 - u32 parameter_id, void *value, u32 *value_size)
1347 - struct mmal_msg m;
1348 - struct mmal_msg *rmsg;
1349 - VCHI_HELD_MSG_T rmsg_handle;
1351 - m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET;
1353 - m.u.port_parameter_get.component_handle = port->component->handle;
1354 - m.u.port_parameter_get.port_handle = port->handle;
1355 - m.u.port_parameter_get.id = parameter_id;
1356 - m.u.port_parameter_get.size = (2 * sizeof(u32)) + *value_size;
1358 - ret = send_synchronous_mmal_msg(instance, &m,
1360 - mmal_msg_port_parameter_get),
1361 - &rmsg, &rmsg_handle);
1365 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_GET) {
1366 - /* got an unexpected message type in reply */
1367 - pr_err("Incorrect reply type %d\n", rmsg->h.type);
1372 - ret = -rmsg->u.port_parameter_get_reply.status;
1373 - /* port_parameter_get_reply.size includes the header,
1374 - * whilst *value_size doesn't.
1376 - rmsg->u.port_parameter_get_reply.size -= (2 * sizeof(u32));
1378 - if (ret || rmsg->u.port_parameter_get_reply.size > *value_size) {
1379 - /* Copy only as much as we have space for
1380 - * but report true size of parameter
1382 - memcpy(value, &rmsg->u.port_parameter_get_reply.value,
1384 - *value_size = rmsg->u.port_parameter_get_reply.size;
1386 - memcpy(value, &rmsg->u.port_parameter_get_reply.value,
1387 - rmsg->u.port_parameter_get_reply.size);
1390 - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__,
1391 - ret, port->component->handle, port->handle, parameter_id);
1394 - vchi_held_msg_release(&rmsg_handle);
1399 -/* disables a port and drains buffers from it */
1400 -static int port_disable(struct vchiq_mmal_instance *instance,
1401 - struct vchiq_mmal_port *port)
1404 - struct list_head *q, *buf_head;
1405 - unsigned long flags = 0;
1407 - if (!port->enabled)
1410 - port->enabled = false;
1412 - ret = port_action_port(instance, port,
1413 - MMAL_MSG_PORT_ACTION_TYPE_DISABLE);
1416 - * Drain all queued buffers on port. This should only
1417 - * apply to buffers that have been queued before the port
1418 - * has been enabled. If the port has been enabled and buffers
1419 - * passed, then the buffers should have been removed from this
1420 - * list, and we should get the relevant callbacks via VCHIQ
1421 - * to release the buffers.
1423 - spin_lock_irqsave(&port->slock, flags);
1425 - list_for_each_safe(buf_head, q, &port->buffers) {
1426 - struct mmal_buffer *mmalbuf;
1428 - mmalbuf = list_entry(buf_head, struct mmal_buffer,
1430 - list_del(buf_head);
1431 - if (port->buffer_cb)
1432 - port->buffer_cb(instance,
1433 - port, 0, mmalbuf, 0, 0,
1434 - MMAL_TIME_UNKNOWN,
1435 - MMAL_TIME_UNKNOWN);
1438 - spin_unlock_irqrestore(&port->slock, flags);
1440 - ret = port_info_get(instance, port);
1446 -/* enable a port */
1447 -static int port_enable(struct vchiq_mmal_instance *instance,
1448 - struct vchiq_mmal_port *port)
1450 - unsigned int hdr_count;
1451 - struct list_head *q, *buf_head;
1454 - if (port->enabled)
1457 - ret = port_action_port(instance, port,
1458 - MMAL_MSG_PORT_ACTION_TYPE_ENABLE);
1462 - port->enabled = true;
1464 - if (port->buffer_cb) {
1465 - /* send buffer headers to videocore */
1467 - list_for_each_safe(buf_head, q, &port->buffers) {
1468 - struct mmal_buffer *mmalbuf;
1470 - mmalbuf = list_entry(buf_head, struct mmal_buffer,
1472 - ret = buffer_from_host(instance, port, mmalbuf);
1476 - list_del(buf_head);
1478 - if (hdr_count > port->current_buffer.num)
1483 - ret = port_info_get(instance, port);
1489 -/* ------------------------------------------------------------------
1491 - *------------------------------------------------------------------
1494 -int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
1495 - struct vchiq_mmal_port *port)
1499 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1502 - ret = port_info_set(instance, port);
1504 - goto release_unlock;
1506 - /* read what has actually been set */
1507 - ret = port_info_get(instance, port);
1510 - mutex_unlock(&instance->vchiq_mutex);
1515 -int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
1516 - struct vchiq_mmal_port *port,
1517 - u32 parameter, void *value, u32 value_size)
1521 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1524 - ret = port_parameter_set(instance, port, parameter, value, value_size);
1526 - mutex_unlock(&instance->vchiq_mutex);
1531 -int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
1532 - struct vchiq_mmal_port *port,
1533 - u32 parameter, void *value, u32 *value_size)
1537 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1540 - ret = port_parameter_get(instance, port, parameter, value, value_size);
1542 - mutex_unlock(&instance->vchiq_mutex);
1549 - * enables a port and queues buffers for satisfying callbacks if we
1550 - * provide a callback handler
1552 -int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
1553 - struct vchiq_mmal_port *port,
1554 - vchiq_mmal_buffer_cb buffer_cb)
1558 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1561 - /* already enabled - noop */
1562 - if (port->enabled) {
1567 - port->buffer_cb = buffer_cb;
1569 - ret = port_enable(instance, port);
1572 - mutex_unlock(&instance->vchiq_mutex);
1577 -int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
1578 - struct vchiq_mmal_port *port)
1582 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1585 - if (!port->enabled) {
1586 - mutex_unlock(&instance->vchiq_mutex);
1590 - ret = port_disable(instance, port);
1592 - mutex_unlock(&instance->vchiq_mutex);
1597 -/* ports will be connected in a tunneled manner so data buffers
1598 - * are not handled by client.
1600 -int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
1601 - struct vchiq_mmal_port *src,
1602 - struct vchiq_mmal_port *dst)
1606 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1609 - /* disconnect ports if connected */
1610 - if (src->connected) {
1611 - ret = port_disable(instance, src);
1613 - pr_err("failed disabling src port(%d)\n", ret);
1614 - goto release_unlock;
1617 - /* do not need to disable the destination port as they
1618 - * are connected and it is done automatically
1621 - ret = port_action_handle(instance, src,
1622 - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT,
1623 - src->connected->component->handle,
1624 - src->connected->handle);
1626 - pr_err("failed disconnecting src port\n");
1627 - goto release_unlock;
1629 - src->connected->enabled = false;
1630 - src->connected = NULL;
1634 - /* do not make new connection */
1636 - pr_debug("not making new connection\n");
1637 - goto release_unlock;
1640 - /* copy src port format to dst */
1641 - dst->format.encoding = src->format.encoding;
1642 - dst->es.video.width = src->es.video.width;
1643 - dst->es.video.height = src->es.video.height;
1644 - dst->es.video.crop.x = src->es.video.crop.x;
1645 - dst->es.video.crop.y = src->es.video.crop.y;
1646 - dst->es.video.crop.width = src->es.video.crop.width;
1647 - dst->es.video.crop.height = src->es.video.crop.height;
1648 - dst->es.video.frame_rate.num = src->es.video.frame_rate.num;
1649 - dst->es.video.frame_rate.den = src->es.video.frame_rate.den;
1651 - /* set new format */
1652 - ret = port_info_set(instance, dst);
1654 - pr_debug("setting port info failed\n");
1655 - goto release_unlock;
1658 - /* read what has actually been set */
1659 - ret = port_info_get(instance, dst);
1661 - pr_debug("read back port info failed\n");
1662 - goto release_unlock;
1665 - /* connect two ports together */
1666 - ret = port_action_handle(instance, src,
1667 - MMAL_MSG_PORT_ACTION_TYPE_CONNECT,
1668 - dst->component->handle, dst->handle);
1670 - pr_debug("connecting port %d:%d to %d:%d failed\n",
1671 - src->component->handle, src->handle,
1672 - dst->component->handle, dst->handle);
1673 - goto release_unlock;
1675 - src->connected = dst;
1679 - mutex_unlock(&instance->vchiq_mutex);
1684 -int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
1685 - struct vchiq_mmal_port *port,
1686 - struct mmal_buffer *buffer)
1688 - unsigned long flags = 0;
1691 - ret = buffer_from_host(instance, port, buffer);
1692 - if (ret == -EINVAL) {
1693 - /* Port is disabled. Queue for when it is enabled. */
1694 - spin_lock_irqsave(&port->slock, flags);
1695 - list_add_tail(&buffer->list, &port->buffers);
1696 - spin_unlock_irqrestore(&port->slock, flags);
1702 -int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
1703 - struct mmal_buffer *buf)
1705 - struct mmal_msg_context *msg_context = get_msg_context(instance);
1707 - if (IS_ERR(msg_context))
1708 - return (PTR_ERR(msg_context));
1710 - buf->msg_context = msg_context;
1714 -int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
1716 - struct mmal_msg_context *msg_context = buf->msg_context;
1719 - release_msg_context(msg_context);
1720 - buf->msg_context = NULL;
1725 -/* Initialise a mmal component and its ports
1728 -int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
1730 - struct vchiq_mmal_component **component_out)
1733 - int idx; /* port index */
1734 - struct vchiq_mmal_component *component;
1736 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1739 - if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) {
1740 - ret = -EINVAL; /* todo is this correct error? */
1744 - component = &instance->component[instance->component_idx];
1746 - ret = create_component(instance, component, name);
1748 - pr_err("%s: failed to create component %d (Not enough GPU mem?)\n",
1753 - /* ports info needs gathering */
1754 - component->control.type = MMAL_PORT_TYPE_CONTROL;
1755 - component->control.index = 0;
1756 - component->control.component = component;
1757 - spin_lock_init(&component->control.slock);
1758 - INIT_LIST_HEAD(&component->control.buffers);
1759 - ret = port_info_get(instance, &component->control);
1761 - goto release_component;
1763 - for (idx = 0; idx < component->inputs; idx++) {
1764 - component->input[idx].type = MMAL_PORT_TYPE_INPUT;
1765 - component->input[idx].index = idx;
1766 - component->input[idx].component = component;
1767 - spin_lock_init(&component->input[idx].slock);
1768 - INIT_LIST_HEAD(&component->input[idx].buffers);
1769 - ret = port_info_get(instance, &component->input[idx]);
1771 - goto release_component;
1774 - for (idx = 0; idx < component->outputs; idx++) {
1775 - component->output[idx].type = MMAL_PORT_TYPE_OUTPUT;
1776 - component->output[idx].index = idx;
1777 - component->output[idx].component = component;
1778 - spin_lock_init(&component->output[idx].slock);
1779 - INIT_LIST_HEAD(&component->output[idx].buffers);
1780 - ret = port_info_get(instance, &component->output[idx]);
1782 - goto release_component;
1785 - for (idx = 0; idx < component->clocks; idx++) {
1786 - component->clock[idx].type = MMAL_PORT_TYPE_CLOCK;
1787 - component->clock[idx].index = idx;
1788 - component->clock[idx].component = component;
1789 - spin_lock_init(&component->clock[idx].slock);
1790 - INIT_LIST_HEAD(&component->clock[idx].buffers);
1791 - ret = port_info_get(instance, &component->clock[idx]);
1793 - goto release_component;
1796 - instance->component_idx++;
1798 - *component_out = component;
1800 - mutex_unlock(&instance->vchiq_mutex);
1805 - destroy_component(instance, component);
1807 - mutex_unlock(&instance->vchiq_mutex);
1813 - * cause a mmal component to be destroyed
1815 -int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
1816 - struct vchiq_mmal_component *component)
1820 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1823 - if (component->enabled)
1824 - ret = disable_component(instance, component);
1826 - ret = destroy_component(instance, component);
1828 - mutex_unlock(&instance->vchiq_mutex);
1834 - * cause a mmal component to be enabled
1836 -int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,
1837 - struct vchiq_mmal_component *component)
1841 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1844 - if (component->enabled) {
1845 - mutex_unlock(&instance->vchiq_mutex);
1849 - ret = enable_component(instance, component);
1851 - component->enabled = true;
1853 - mutex_unlock(&instance->vchiq_mutex);
1859 - * cause a mmal component to be enabled
1861 -int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance,
1862 - struct vchiq_mmal_component *component)
1866 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1869 - if (!component->enabled) {
1870 - mutex_unlock(&instance->vchiq_mutex);
1874 - ret = disable_component(instance, component);
1876 - component->enabled = false;
1878 - mutex_unlock(&instance->vchiq_mutex);
1883 -int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
1884 - u32 *major_out, u32 *minor_out)
1888 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1891 - ret = get_version(instance, major_out, minor_out);
1893 - mutex_unlock(&instance->vchiq_mutex);
1898 -int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
1905 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1908 - vchi_service_use(instance->handle);
1910 - status = vchi_service_close(instance->handle);
1912 - pr_err("mmal-vchiq: VCHIQ close failed\n");
1914 - mutex_unlock(&instance->vchiq_mutex);
1916 - flush_workqueue(instance->bulk_wq);
1917 - destroy_workqueue(instance->bulk_wq);
1919 - vfree(instance->bulk_scratch);
1921 - idr_destroy(&instance->context_map);
1928 -int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
1931 - struct vchiq_mmal_instance *instance;
1932 - static VCHI_CONNECTION_T *vchi_connection;
1933 - static VCHI_INSTANCE_T vchi_instance;
1934 - SERVICE_CREATION_T params = {
1935 - .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER),
1936 - .service_id = VC_MMAL_SERVER_NAME,
1937 - .connection = vchi_connection,
1938 - .rx_fifo_size = 0,
1939 - .tx_fifo_size = 0,
1940 - .callback = service_callback,
1941 - .callback_param = NULL,
1942 - .want_unaligned_bulk_rx = 1,
1943 - .want_unaligned_bulk_tx = 1,
1947 - /* compile time checks to ensure structure size as they are
1948 - * directly (de)serialised from memory.
1951 - /* ensure the header structure has packed to the correct size */
1952 - BUILD_BUG_ON(sizeof(struct mmal_msg_header) != 24);
1954 - /* ensure message structure does not exceed maximum length */
1955 - BUILD_BUG_ON(sizeof(struct mmal_msg) > MMAL_MSG_MAX_SIZE);
1957 - /* mmal port struct is correct size */
1958 - BUILD_BUG_ON(sizeof(struct mmal_port) != 64);
1960 - /* create a vchi instance */
1961 - status = vchi_initialise(&vchi_instance);
1963 - pr_err("Failed to initialise VCHI instance (status=%d)\n",
1968 - status = vchi_connect(NULL, 0, vchi_instance);
1970 - pr_err("Failed to connect VCHI instance (status=%d)\n", status);
1974 - instance = kzalloc(sizeof(*instance), GFP_KERNEL);
1979 - mutex_init(&instance->vchiq_mutex);
1981 - instance->bulk_scratch = vmalloc(PAGE_SIZE);
1983 - mutex_init(&instance->context_map_lock);
1984 - idr_init_base(&instance->context_map, 1);
1986 - params.callback_param = instance;
1988 - instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq",
1990 - if (!instance->bulk_wq)
1993 - status = vchi_service_open(vchi_instance, ¶ms, &instance->handle);
1995 - pr_err("Failed to open VCHI service connection (status=%d)\n",
1997 - goto err_close_services;
2000 - vchi_service_release(instance->handle);
2002 - *out_instance = instance;
2006 -err_close_services:
2007 - vchi_service_close(instance->handle);
2008 - destroy_workqueue(instance->bulk_wq);
2010 - vfree(instance->bulk_scratch);
2015 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
2017 +// SPDX-License-Identifier: GPL-2.0
2019 + * Broadcom BM2835 V4L2 driver
2021 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2023 + * Authors: Vincent Sanders @ Collabora
2024 + * Dave Stevenson @ Broadcom
2025 + * (now dave.stevenson@raspberrypi.org)
2026 + * Simon Mellor @ Broadcom
2027 + * Luke Diamand @ Broadcom
2029 + * V4L2 driver MMAL vchiq interface code
2032 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2034 +#include <linux/errno.h>
2035 +#include <linux/kernel.h>
2036 +#include <linux/module.h>
2037 +#include <linux/mutex.h>
2038 +#include <linux/mm.h>
2039 +#include <linux/slab.h>
2040 +#include <linux/completion.h>
2041 +#include <linux/vmalloc.h>
2042 +#include <asm/cacheflush.h>
2043 +#include <media/videobuf2-vmalloc.h>
2045 +#include "mmal-common.h"
2046 +#include "mmal-vchiq.h"
2047 +#include "mmal-msg.h"
2049 +#define USE_VCHIQ_ARM
2050 +#include "interface/vchi/vchi.h"
2052 +MODULE_DESCRIPTION("BCM2835 MMAL VCHIQ interface");
2053 +MODULE_AUTHOR("Dave Stevenson, <dave.stevenson@raspberrypi.org>");
2054 +MODULE_LICENSE("GPL");
2055 +MODULE_VERSION("0.0.1");
2057 +/* maximum number of components supported */
2058 +#define VCHIQ_MMAL_MAX_COMPONENTS 4
2060 +/*#define FULL_MSG_DUMP 1*/
2063 +static const char *const msg_type_names[] = {
2068 + "COMPONENT_CREATE",
2069 + "COMPONENT_DESTROY",
2070 + "COMPONENT_ENABLE",
2071 + "COMPONENT_DISABLE",
2075 + "BUFFER_FROM_HOST",
2078 + "PORT_PARAMETER_SET",
2079 + "PORT_PARAMETER_GET",
2081 + "GET_CORE_STATS_FOR_PORT",
2082 + "OPAQUE_ALLOCATOR",
2085 + "OPAQUE_ALLOCATOR_DESC",
2088 + "BUFFER_FROM_HOST_ZEROLEN",
2094 +static const char *const port_action_type_names[] = {
2101 + "SET_REQUIREMENTS",
2105 +#if defined(FULL_MSG_DUMP)
2106 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
2108 + pr_debug(TITLE" type:%s(%d) length:%d\n", \
2109 + msg_type_names[(MSG)->h.type], \
2110 + (MSG)->h.type, (MSG_LEN)); \
2111 + print_hex_dump(KERN_DEBUG, "<<h: ", DUMP_PREFIX_OFFSET, \
2113 + sizeof(struct mmal_msg_header), 1); \
2114 + print_hex_dump(KERN_DEBUG, "<<p: ", DUMP_PREFIX_OFFSET, \
2116 + ((u8 *)(MSG)) + sizeof(struct mmal_msg_header),\
2117 + (MSG_LEN) - sizeof(struct mmal_msg_header), 1); \
2120 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
2122 + pr_debug(TITLE" type:%s(%d) length:%d\n", \
2123 + msg_type_names[(MSG)->h.type], \
2124 + (MSG)->h.type, (MSG_LEN)); \
2128 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE)
2131 +struct vchiq_mmal_instance;
2133 +/* normal message context */
2134 +struct mmal_msg_context {
2135 + struct vchiq_mmal_instance *instance;
2137 + /* Index in the context_map idr so that we can find the
2138 + * mmal_msg_context again when servicing the VCHI reply.
2144 + /* work struct for buffer_cb callback */
2145 + struct work_struct work;
2146 + /* work struct for deferred callback */
2147 + struct work_struct buffer_to_host_work;
2148 + /* mmal instance */
2149 + struct vchiq_mmal_instance *instance;
2151 + struct vchiq_mmal_port *port;
2152 + /* actual buffer used to store bulk reply */
2153 + struct mmal_buffer *buffer;
2154 + /* amount of buffer used */
2155 + unsigned long buffer_used;
2156 + /* MMAL buffer flags */
2158 + /* Presentation and Decode timestamps */
2162 + int status; /* context status */
2164 + } bulk; /* bulk data */
2167 + /* message handle to release */
2168 + VCHI_HELD_MSG_T msg_handle;
2169 + /* pointer to received message */
2170 + struct mmal_msg *msg;
2171 + /* received message length */
2173 + /* completion upon reply */
2174 + struct completion cmplt;
2175 + } sync; /* synchronous response */
2180 +struct vchiq_mmal_instance {
2181 + VCHI_SERVICE_HANDLE_T handle;
2183 + /* ensure serialised access to service */
2184 + struct mutex vchiq_mutex;
2186 + /* vmalloc page to receive scratch bulk xfers into */
2187 + void *bulk_scratch;
2189 + struct idr context_map;
2190 + /* protect accesses to context_map */
2191 + struct mutex context_map_lock;
2193 + /* component to use next */
2194 + int component_idx;
2195 + struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
2197 + /* ordered workqueue to process all bulk operations */
2198 + struct workqueue_struct *bulk_wq;
2201 +static struct mmal_msg_context *
2202 +get_msg_context(struct vchiq_mmal_instance *instance)
2204 + struct mmal_msg_context *msg_context;
2207 + /* todo: should this be allocated from a pool to avoid kzalloc */
2208 + msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
2211 + return ERR_PTR(-ENOMEM);
2213 + /* Create an ID that will be passed along with our message so
2214 + * that when we service the VCHI reply, we can look up what
2215 + * message is being replied to.
2217 + mutex_lock(&instance->context_map_lock);
2218 + handle = idr_alloc(&instance->context_map, msg_context,
2219 + 0, 0, GFP_KERNEL);
2220 + mutex_unlock(&instance->context_map_lock);
2223 + kfree(msg_context);
2224 + return ERR_PTR(handle);
2227 + msg_context->instance = instance;
2228 + msg_context->handle = handle;
2230 + return msg_context;
2233 +static struct mmal_msg_context *
2234 +lookup_msg_context(struct vchiq_mmal_instance *instance, int handle)
2236 + return idr_find(&instance->context_map, handle);
2240 +release_msg_context(struct mmal_msg_context *msg_context)
2242 + struct vchiq_mmal_instance *instance = msg_context->instance;
2244 + mutex_lock(&instance->context_map_lock);
2245 + idr_remove(&instance->context_map, msg_context->handle);
2246 + mutex_unlock(&instance->context_map_lock);
2247 + kfree(msg_context);
2250 +/* deals with receipt of event to host message */
2251 +static void event_to_host_cb(struct vchiq_mmal_instance *instance,
2252 + struct mmal_msg *msg, u32 msg_len)
2254 + pr_debug("unhandled event\n");
2255 + pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n",
2256 + msg->u.event_to_host.client_component,
2257 + msg->u.event_to_host.port_type,
2258 + msg->u.event_to_host.port_num,
2259 + msg->u.event_to_host.cmd, msg->u.event_to_host.length);
2262 +/* workqueue scheduled callback
2264 + * we do this because it is important we do not call any other vchiq
2265 + * sync calls from witin the message delivery thread
2267 +static void buffer_work_cb(struct work_struct *work)
2269 + struct mmal_msg_context *msg_context =
2270 + container_of(work, struct mmal_msg_context, u.bulk.work);
2272 + atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu);
2274 + msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
2275 + msg_context->u.bulk.port,
2276 + msg_context->u.bulk.status,
2277 + msg_context->u.bulk.buffer,
2278 + msg_context->u.bulk.buffer_used,
2279 + msg_context->u.bulk.mmal_flags,
2280 + msg_context->u.bulk.dts,
2281 + msg_context->u.bulk.pts);
2284 +/* workqueue scheduled callback to handle receiving buffers
2286 + * VCHI will allow up to 4 bulk receives to be scheduled before blocking.
2287 + * If we block in the service_callback context then we can't process the
2288 + * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked
2289 + * vchi_bulk_queue_receive() call to complete.
2291 +static void buffer_to_host_work_cb(struct work_struct *work)
2293 + struct mmal_msg_context *msg_context =
2294 + container_of(work, struct mmal_msg_context,
2295 + u.bulk.buffer_to_host_work);
2296 + struct vchiq_mmal_instance *instance = msg_context->instance;
2297 + unsigned long len = msg_context->u.bulk.buffer_used;
2301 + /* Dummy receive to ensure the buffers remain in order */
2303 + /* queue the bulk submission */
2304 + vchi_service_use(instance->handle);
2305 + ret = vchi_bulk_queue_receive(instance->handle,
2306 + msg_context->u.bulk.buffer->buffer,
2307 + /* Actual receive needs to be a multiple
2311 + VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE |
2312 + VCHI_FLAGS_BLOCK_UNTIL_QUEUED,
2315 + vchi_service_release(instance->handle);
2318 + pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n",
2319 + __func__, msg_context, ret);
2322 +/* enqueue a bulk receive for a given message context */
2323 +static int bulk_receive(struct vchiq_mmal_instance *instance,
2324 + struct mmal_msg *msg,
2325 + struct mmal_msg_context *msg_context)
2327 + unsigned long rd_len;
2329 + rd_len = msg->u.buffer_from_host.buffer_header.length;
2331 + if (!msg_context->u.bulk.buffer) {
2332 + pr_err("bulk.buffer not configured - error in buffer_from_host\n");
2334 + /* todo: this is a serious error, we should never have
2335 + * committed a buffer_to_host operation to the mmal
2336 + * port without the buffer to back it up (underflow
2337 + * handling) and there is no obvious way to deal with
2338 + * this - how is the mmal servie going to react when
2339 + * we fail to do the xfer and reschedule a buffer when
2340 + * it arrives? perhaps a starved flag to indicate a
2341 + * waiting bulk receive?
2347 + /* ensure we do not overrun the available buffer */
2348 + if (rd_len > msg_context->u.bulk.buffer->buffer_size) {
2349 + rd_len = msg_context->u.bulk.buffer->buffer_size;
2350 + pr_warn("short read as not enough receive buffer space\n");
2351 + /* todo: is this the correct response, what happens to
2352 + * the rest of the message data?
2356 + /* store length */
2357 + msg_context->u.bulk.buffer_used = rd_len;
2358 + msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts;
2359 + msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts;
2361 + queue_work(msg_context->instance->bulk_wq,
2362 + &msg_context->u.bulk.buffer_to_host_work);
2367 +/* data in message, memcpy from packet into output buffer */
2368 +static int inline_receive(struct vchiq_mmal_instance *instance,
2369 + struct mmal_msg *msg,
2370 + struct mmal_msg_context *msg_context)
2372 + memcpy(msg_context->u.bulk.buffer->buffer,
2373 + msg->u.buffer_from_host.short_data,
2374 + msg->u.buffer_from_host.payload_in_message);
2376 + msg_context->u.bulk.buffer_used =
2377 + msg->u.buffer_from_host.payload_in_message;
2382 +/* queue the buffer availability with MMAL_MSG_TYPE_BUFFER_FROM_HOST */
2384 +buffer_from_host(struct vchiq_mmal_instance *instance,
2385 + struct vchiq_mmal_port *port, struct mmal_buffer *buf)
2387 + struct mmal_msg_context *msg_context;
2388 + struct mmal_msg m;
2391 + if (!port->enabled)
2394 + pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
2397 + if (!buf->msg_context) {
2398 + pr_err("%s: msg_context not allocated, buf %p\n", __func__,
2402 + msg_context = buf->msg_context;
2404 + /* store bulk message context for when data arrives */
2405 + msg_context->u.bulk.instance = instance;
2406 + msg_context->u.bulk.port = port;
2407 + msg_context->u.bulk.buffer = buf;
2408 + msg_context->u.bulk.buffer_used = 0;
2410 + /* initialise work structure ready to schedule callback */
2411 + INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb);
2412 + INIT_WORK(&msg_context->u.bulk.buffer_to_host_work,
2413 + buffer_to_host_work_cb);
2415 + atomic_inc(&port->buffers_with_vpu);
2417 + /* prep the buffer from host message */
2418 + memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */
2420 + m.h.type = MMAL_MSG_TYPE_BUFFER_FROM_HOST;
2421 + m.h.magic = MMAL_MAGIC;
2422 + m.h.context = msg_context->handle;
2425 + /* drvbuf is our private data passed back */
2426 + m.u.buffer_from_host.drvbuf.magic = MMAL_MAGIC;
2427 + m.u.buffer_from_host.drvbuf.component_handle = port->component->handle;
2428 + m.u.buffer_from_host.drvbuf.port_handle = port->handle;
2429 + m.u.buffer_from_host.drvbuf.client_context = msg_context->handle;
2431 + /* buffer header */
2432 + m.u.buffer_from_host.buffer_header.cmd = 0;
2433 + m.u.buffer_from_host.buffer_header.data =
2434 + (u32)(unsigned long)buf->buffer;
2435 + m.u.buffer_from_host.buffer_header.alloc_size = buf->buffer_size;
2436 + m.u.buffer_from_host.buffer_header.length = 0; /* nothing used yet */
2437 + m.u.buffer_from_host.buffer_header.offset = 0; /* no offset */
2438 + m.u.buffer_from_host.buffer_header.flags = 0; /* no flags */
2439 + m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN;
2440 + m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN;
2442 + /* clear buffer type sepecific data */
2443 + memset(&m.u.buffer_from_host.buffer_header_type_specific, 0,
2444 + sizeof(m.u.buffer_from_host.buffer_header_type_specific));
2446 + /* no payload in message */
2447 + m.u.buffer_from_host.payload_in_message = 0;
2449 + vchi_service_use(instance->handle);
2451 + ret = vchi_queue_kernel_message(instance->handle,
2453 + sizeof(struct mmal_msg_header) +
2454 + sizeof(m.u.buffer_from_host));
2456 + vchi_service_release(instance->handle);
2461 +/* deals with receipt of buffer to host message */
2462 +static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
2463 + struct mmal_msg *msg, u32 msg_len)
2465 + struct mmal_msg_context *msg_context;
2468 + pr_debug("%s: instance:%p msg:%p msg_len:%d\n",
2469 + __func__, instance, msg, msg_len);
2471 + if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) {
2472 + handle = msg->u.buffer_from_host.drvbuf.client_context;
2473 + msg_context = lookup_msg_context(instance, handle);
2475 + if (!msg_context) {
2476 + pr_err("drvbuf.client_context(%u) is invalid\n",
2481 + pr_err("MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n");
2485 + msg_context->u.bulk.mmal_flags =
2486 + msg->u.buffer_from_host.buffer_header.flags;
2488 + if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) {
2489 + /* message reception had an error */
2490 + pr_warn("error %d in reply\n", msg->h.status);
2492 + msg_context->u.bulk.status = msg->h.status;
2494 + } else if (msg->u.buffer_from_host.buffer_header.length == 0) {
2495 + /* empty buffer */
2496 + if (msg->u.buffer_from_host.buffer_header.flags &
2497 + MMAL_BUFFER_HEADER_FLAG_EOS) {
2498 + msg_context->u.bulk.status =
2499 + bulk_receive(instance, msg, msg_context);
2500 + if (msg_context->u.bulk.status == 0)
2501 + return; /* successful bulk submission, bulk
2502 + * completion will trigger callback
2505 + /* do callback with empty buffer - not EOS though */
2506 + msg_context->u.bulk.status = 0;
2507 + msg_context->u.bulk.buffer_used = 0;
2509 + } else if (msg->u.buffer_from_host.payload_in_message == 0) {
2510 + /* data is not in message, queue a bulk receive */
2511 + msg_context->u.bulk.status =
2512 + bulk_receive(instance, msg, msg_context);
2513 + if (msg_context->u.bulk.status == 0)
2514 + return; /* successful bulk submission, bulk
2515 + * completion will trigger callback
2518 + /* failed to submit buffer, this will end badly */
2519 + pr_err("error %d on bulk submission\n",
2520 + msg_context->u.bulk.status);
2522 + } else if (msg->u.buffer_from_host.payload_in_message <=
2523 + MMAL_VC_SHORT_DATA) {
2524 + /* data payload within message */
2525 + msg_context->u.bulk.status = inline_receive(instance, msg,
2528 + pr_err("message with invalid short payload\n");
2530 + /* signal error */
2531 + msg_context->u.bulk.status = -EINVAL;
2532 + msg_context->u.bulk.buffer_used =
2533 + msg->u.buffer_from_host.payload_in_message;
2536 + /* schedule the port callback */
2537 + schedule_work(&msg_context->u.bulk.work);
2540 +static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
2541 + struct mmal_msg_context *msg_context)
2543 + msg_context->u.bulk.status = 0;
2545 + /* schedule the port callback */
2546 + schedule_work(&msg_context->u.bulk.work);
2549 +static void bulk_abort_cb(struct vchiq_mmal_instance *instance,
2550 + struct mmal_msg_context *msg_context)
2552 + pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
2554 + msg_context->u.bulk.status = -EINTR;
2556 + schedule_work(&msg_context->u.bulk.work);
2559 +/* incoming event service callback */
2560 +static void service_callback(void *param,
2561 + const VCHI_CALLBACK_REASON_T reason,
2564 + struct vchiq_mmal_instance *instance = param;
2567 + struct mmal_msg *msg;
2568 + VCHI_HELD_MSG_T msg_handle;
2569 + struct mmal_msg_context *msg_context;
2572 + pr_err("Message callback passed NULL instance\n");
2577 + case VCHI_CALLBACK_MSG_AVAILABLE:
2578 + status = vchi_msg_hold(instance->handle, (void **)&msg,
2579 + &msg_len, VCHI_FLAGS_NONE, &msg_handle);
2581 + pr_err("Unable to dequeue a message (%d)\n", status);
2585 + DBG_DUMP_MSG(msg, msg_len, "<<< reply message");
2587 + /* handling is different for buffer messages */
2588 + switch (msg->h.type) {
2589 + case MMAL_MSG_TYPE_BUFFER_FROM_HOST:
2590 + vchi_held_msg_release(&msg_handle);
2593 + case MMAL_MSG_TYPE_EVENT_TO_HOST:
2594 + event_to_host_cb(instance, msg, msg_len);
2595 + vchi_held_msg_release(&msg_handle);
2599 + case MMAL_MSG_TYPE_BUFFER_TO_HOST:
2600 + buffer_to_host_cb(instance, msg, msg_len);
2601 + vchi_held_msg_release(&msg_handle);
2605 + /* messages dependent on header context to complete */
2606 + if (!msg->h.context) {
2607 + pr_err("received message context was null!\n");
2608 + vchi_held_msg_release(&msg_handle);
2612 + msg_context = lookup_msg_context(instance,
2614 + if (!msg_context) {
2615 + pr_err("received invalid message context %u!\n",
2617 + vchi_held_msg_release(&msg_handle);
2621 + /* fill in context values */
2622 + msg_context->u.sync.msg_handle = msg_handle;
2623 + msg_context->u.sync.msg = msg;
2624 + msg_context->u.sync.msg_len = msg_len;
2626 + /* todo: should this check (completion_done()
2627 + * == 1) for no one waiting? or do we need a
2628 + * flag to tell us the completion has been
2629 + * interrupted so we can free the message and
2630 + * its context. This probably also solves the
2631 + * message arriving after interruption todo
2635 + /* complete message so caller knows it happened */
2636 + complete(&msg_context->u.sync.cmplt);
2642 + case VCHI_CALLBACK_BULK_RECEIVED:
2643 + bulk_receive_cb(instance, bulk_ctx);
2646 + case VCHI_CALLBACK_BULK_RECEIVE_ABORTED:
2647 + bulk_abort_cb(instance, bulk_ctx);
2650 + case VCHI_CALLBACK_SERVICE_CLOSED:
2651 + /* TODO: consider if this requires action if received when
2652 + * driver is not explicitly closing the service
2657 + pr_err("Received unhandled message reason %d\n", reason);
2662 +static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
2663 + struct mmal_msg *msg,
2664 + unsigned int payload_len,
2665 + struct mmal_msg **msg_out,
2666 + VCHI_HELD_MSG_T *msg_handle_out)
2668 + struct mmal_msg_context *msg_context;
2670 + unsigned long timeout;
2672 + /* payload size must not cause message to exceed max size */
2674 + (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) {
2675 + pr_err("payload length %d exceeds max:%d\n", payload_len,
2676 + (int)(MMAL_MSG_MAX_SIZE -
2677 + sizeof(struct mmal_msg_header)));
2681 + msg_context = get_msg_context(instance);
2682 + if (IS_ERR(msg_context))
2683 + return PTR_ERR(msg_context);
2685 + init_completion(&msg_context->u.sync.cmplt);
2687 + msg->h.magic = MMAL_MAGIC;
2688 + msg->h.context = msg_context->handle;
2689 + msg->h.status = 0;
2691 + DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len),
2692 + ">>> sync message");
2694 + vchi_service_use(instance->handle);
2696 + ret = vchi_queue_kernel_message(instance->handle,
2698 + sizeof(struct mmal_msg_header) +
2701 + vchi_service_release(instance->handle);
2704 + pr_err("error %d queuing message\n", ret);
2705 + release_msg_context(msg_context);
2709 + timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt,
2711 + if (timeout == 0) {
2712 + pr_err("timed out waiting for sync completion\n");
2714 + /* todo: what happens if the message arrives after aborting */
2715 + release_msg_context(msg_context);
2719 + *msg_out = msg_context->u.sync.msg;
2720 + *msg_handle_out = msg_context->u.sync.msg_handle;
2721 + release_msg_context(msg_context);
2726 +static void dump_port_info(struct vchiq_mmal_port *port)
2728 + pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled);
2730 + pr_debug("buffer minimum num:%d size:%d align:%d\n",
2731 + port->minimum_buffer.num,
2732 + port->minimum_buffer.size, port->minimum_buffer.alignment);
2734 + pr_debug("buffer recommended num:%d size:%d align:%d\n",
2735 + port->recommended_buffer.num,
2736 + port->recommended_buffer.size,
2737 + port->recommended_buffer.alignment);
2739 + pr_debug("buffer current values num:%d size:%d align:%d\n",
2740 + port->current_buffer.num,
2741 + port->current_buffer.size, port->current_buffer.alignment);
2743 + pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n",
2744 + port->format.type,
2745 + port->format.encoding, port->format.encoding_variant);
2747 + pr_debug(" bitrate:%d flags:0x%x\n",
2748 + port->format.bitrate, port->format.flags);
2750 + if (port->format.type == MMAL_ES_TYPE_VIDEO) {
2752 + ("es video format: width:%d height:%d colourspace:0x%x\n",
2753 + port->es.video.width, port->es.video.height,
2754 + port->es.video.color_space);
2756 + pr_debug(" : crop xywh %d,%d,%d,%d\n",
2757 + port->es.video.crop.x,
2758 + port->es.video.crop.y,
2759 + port->es.video.crop.width, port->es.video.crop.height);
2760 + pr_debug(" : framerate %d/%d aspect %d/%d\n",
2761 + port->es.video.frame_rate.num,
2762 + port->es.video.frame_rate.den,
2763 + port->es.video.par.num, port->es.video.par.den);
2767 +static void port_to_mmal_msg(struct vchiq_mmal_port *port, struct mmal_port *p)
2769 + /* todo do readonly fields need setting at all? */
2770 + p->type = port->type;
2771 + p->index = port->index;
2773 + p->is_enabled = port->enabled;
2774 + p->buffer_num_min = port->minimum_buffer.num;
2775 + p->buffer_size_min = port->minimum_buffer.size;
2776 + p->buffer_alignment_min = port->minimum_buffer.alignment;
2777 + p->buffer_num_recommended = port->recommended_buffer.num;
2778 + p->buffer_size_recommended = port->recommended_buffer.size;
2780 + /* only three writable fields in a port */
2781 + p->buffer_num = port->current_buffer.num;
2782 + p->buffer_size = port->current_buffer.size;
2783 + p->userdata = (u32)(unsigned long)port;
2786 +static int port_info_set(struct vchiq_mmal_instance *instance,
2787 + struct vchiq_mmal_port *port)
2790 + struct mmal_msg m;
2791 + struct mmal_msg *rmsg;
2792 + VCHI_HELD_MSG_T rmsg_handle;
2794 + pr_debug("setting port info port %p\n", port);
2797 + dump_port_info(port);
2799 + m.h.type = MMAL_MSG_TYPE_PORT_INFO_SET;
2801 + m.u.port_info_set.component_handle = port->component->handle;
2802 + m.u.port_info_set.port_type = port->type;
2803 + m.u.port_info_set.port_index = port->index;
2805 + port_to_mmal_msg(port, &m.u.port_info_set.port);
2807 + /* elementary stream format setup */
2808 + m.u.port_info_set.format.type = port->format.type;
2809 + m.u.port_info_set.format.encoding = port->format.encoding;
2810 + m.u.port_info_set.format.encoding_variant =
2811 + port->format.encoding_variant;
2812 + m.u.port_info_set.format.bitrate = port->format.bitrate;
2813 + m.u.port_info_set.format.flags = port->format.flags;
2815 + memcpy(&m.u.port_info_set.es, &port->es,
2816 + sizeof(union mmal_es_specific_format));
2818 + m.u.port_info_set.format.extradata_size = port->format.extradata_size;
2819 + memcpy(&m.u.port_info_set.extradata, port->format.extradata,
2820 + port->format.extradata_size);
2822 + ret = send_synchronous_mmal_msg(instance, &m,
2823 + sizeof(m.u.port_info_set),
2824 + &rmsg, &rmsg_handle);
2828 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_SET) {
2829 + /* got an unexpected message type in reply */
2834 + /* return operation status */
2835 + ret = -rmsg->u.port_info_get_reply.status;
2837 + pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret,
2838 + port->component->handle, port->handle);
2841 + vchi_held_msg_release(&rmsg_handle);
2846 +/* use port info get message to retrieve port information */
2847 +static int port_info_get(struct vchiq_mmal_instance *instance,
2848 + struct vchiq_mmal_port *port)
2851 + struct mmal_msg m;
2852 + struct mmal_msg *rmsg;
2853 + VCHI_HELD_MSG_T rmsg_handle;
2855 + /* port info time */
2856 + m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET;
2857 + m.u.port_info_get.component_handle = port->component->handle;
2858 + m.u.port_info_get.port_type = port->type;
2859 + m.u.port_info_get.index = port->index;
2861 + ret = send_synchronous_mmal_msg(instance, &m,
2862 + sizeof(m.u.port_info_get),
2863 + &rmsg, &rmsg_handle);
2867 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_GET) {
2868 + /* got an unexpected message type in reply */
2873 + /* return operation status */
2874 + ret = -rmsg->u.port_info_get_reply.status;
2875 + if (ret != MMAL_MSG_STATUS_SUCCESS)
2878 + if (rmsg->u.port_info_get_reply.port.is_enabled == 0)
2879 + port->enabled = false;
2881 + port->enabled = true;
2883 + /* copy the values out of the message */
2884 + port->handle = rmsg->u.port_info_get_reply.port_handle;
2886 + /* port type and index cached to use on port info set because
2887 + * it does not use a port handle
2889 + port->type = rmsg->u.port_info_get_reply.port_type;
2890 + port->index = rmsg->u.port_info_get_reply.port_index;
2892 + port->minimum_buffer.num =
2893 + rmsg->u.port_info_get_reply.port.buffer_num_min;
2894 + port->minimum_buffer.size =
2895 + rmsg->u.port_info_get_reply.port.buffer_size_min;
2896 + port->minimum_buffer.alignment =
2897 + rmsg->u.port_info_get_reply.port.buffer_alignment_min;
2899 + port->recommended_buffer.alignment =
2900 + rmsg->u.port_info_get_reply.port.buffer_alignment_min;
2901 + port->recommended_buffer.num =
2902 + rmsg->u.port_info_get_reply.port.buffer_num_recommended;
2904 + port->current_buffer.num = rmsg->u.port_info_get_reply.port.buffer_num;
2905 + port->current_buffer.size =
2906 + rmsg->u.port_info_get_reply.port.buffer_size;
2908 + /* stream format */
2909 + port->format.type = rmsg->u.port_info_get_reply.format.type;
2910 + port->format.encoding = rmsg->u.port_info_get_reply.format.encoding;
2911 + port->format.encoding_variant =
2912 + rmsg->u.port_info_get_reply.format.encoding_variant;
2913 + port->format.bitrate = rmsg->u.port_info_get_reply.format.bitrate;
2914 + port->format.flags = rmsg->u.port_info_get_reply.format.flags;
2916 + /* elementary stream format */
2918 + &rmsg->u.port_info_get_reply.es,
2919 + sizeof(union mmal_es_specific_format));
2920 + port->format.es = &port->es;
2922 + port->format.extradata_size =
2923 + rmsg->u.port_info_get_reply.format.extradata_size;
2924 + memcpy(port->format.extradata,
2925 + rmsg->u.port_info_get_reply.extradata,
2926 + port->format.extradata_size);
2928 + pr_debug("received port info\n");
2929 + dump_port_info(port);
2933 + pr_debug("%s:result:%d component:0x%x port:%d\n",
2934 + __func__, ret, port->component->handle, port->handle);
2936 + vchi_held_msg_release(&rmsg_handle);
2941 +/* create comonent on vc */
2942 +static int create_component(struct vchiq_mmal_instance *instance,
2943 + struct vchiq_mmal_component *component,
2947 + struct mmal_msg m;
2948 + struct mmal_msg *rmsg;
2949 + VCHI_HELD_MSG_T rmsg_handle;
2951 + /* build component create message */
2952 + m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE;
2953 + m.u.component_create.client_component = (u32)(unsigned long)component;
2954 + strncpy(m.u.component_create.name, name,
2955 + sizeof(m.u.component_create.name));
2957 + ret = send_synchronous_mmal_msg(instance, &m,
2958 + sizeof(m.u.component_create),
2959 + &rmsg, &rmsg_handle);
2963 + if (rmsg->h.type != m.h.type) {
2964 + /* got an unexpected message type in reply */
2969 + ret = -rmsg->u.component_create_reply.status;
2970 + if (ret != MMAL_MSG_STATUS_SUCCESS)
2973 + /* a valid component response received */
2974 + component->handle = rmsg->u.component_create_reply.component_handle;
2975 + component->inputs = rmsg->u.component_create_reply.input_num;
2976 + component->outputs = rmsg->u.component_create_reply.output_num;
2977 + component->clocks = rmsg->u.component_create_reply.clock_num;
2979 + pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n",
2980 + component->handle,
2981 + component->inputs, component->outputs, component->clocks);
2984 + vchi_held_msg_release(&rmsg_handle);
2989 +/* destroys a component on vc */
2990 +static int destroy_component(struct vchiq_mmal_instance *instance,
2991 + struct vchiq_mmal_component *component)
2994 + struct mmal_msg m;
2995 + struct mmal_msg *rmsg;
2996 + VCHI_HELD_MSG_T rmsg_handle;
2998 + m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY;
2999 + m.u.component_destroy.component_handle = component->handle;
3001 + ret = send_synchronous_mmal_msg(instance, &m,
3002 + sizeof(m.u.component_destroy),
3003 + &rmsg, &rmsg_handle);
3007 + if (rmsg->h.type != m.h.type) {
3008 + /* got an unexpected message type in reply */
3013 + ret = -rmsg->u.component_destroy_reply.status;
3017 + vchi_held_msg_release(&rmsg_handle);
3022 +/* enable a component on vc */
3023 +static int enable_component(struct vchiq_mmal_instance *instance,
3024 + struct vchiq_mmal_component *component)
3027 + struct mmal_msg m;
3028 + struct mmal_msg *rmsg;
3029 + VCHI_HELD_MSG_T rmsg_handle;
3031 + m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE;
3032 + m.u.component_enable.component_handle = component->handle;
3034 + ret = send_synchronous_mmal_msg(instance, &m,
3035 + sizeof(m.u.component_enable),
3036 + &rmsg, &rmsg_handle);
3040 + if (rmsg->h.type != m.h.type) {
3041 + /* got an unexpected message type in reply */
3046 + ret = -rmsg->u.component_enable_reply.status;
3049 + vchi_held_msg_release(&rmsg_handle);
3054 +/* disable a component on vc */
3055 +static int disable_component(struct vchiq_mmal_instance *instance,
3056 + struct vchiq_mmal_component *component)
3059 + struct mmal_msg m;
3060 + struct mmal_msg *rmsg;
3061 + VCHI_HELD_MSG_T rmsg_handle;
3063 + m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE;
3064 + m.u.component_disable.component_handle = component->handle;
3066 + ret = send_synchronous_mmal_msg(instance, &m,
3067 + sizeof(m.u.component_disable),
3068 + &rmsg, &rmsg_handle);
3072 + if (rmsg->h.type != m.h.type) {
3073 + /* got an unexpected message type in reply */
3078 + ret = -rmsg->u.component_disable_reply.status;
3082 + vchi_held_msg_release(&rmsg_handle);
3087 +/* get version of mmal implementation */
3088 +static int get_version(struct vchiq_mmal_instance *instance,
3089 + u32 *major_out, u32 *minor_out)
3092 + struct mmal_msg m;
3093 + struct mmal_msg *rmsg;
3094 + VCHI_HELD_MSG_T rmsg_handle;
3096 + m.h.type = MMAL_MSG_TYPE_GET_VERSION;
3098 + ret = send_synchronous_mmal_msg(instance, &m,
3099 + sizeof(m.u.version),
3100 + &rmsg, &rmsg_handle);
3104 + if (rmsg->h.type != m.h.type) {
3105 + /* got an unexpected message type in reply */
3110 + *major_out = rmsg->u.version.major;
3111 + *minor_out = rmsg->u.version.minor;
3114 + vchi_held_msg_release(&rmsg_handle);
3119 +/* do a port action with a port as a parameter */
3120 +static int port_action_port(struct vchiq_mmal_instance *instance,
3121 + struct vchiq_mmal_port *port,
3122 + enum mmal_msg_port_action_type action_type)
3125 + struct mmal_msg m;
3126 + struct mmal_msg *rmsg;
3127 + VCHI_HELD_MSG_T rmsg_handle;
3129 + m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
3130 + m.u.port_action_port.component_handle = port->component->handle;
3131 + m.u.port_action_port.port_handle = port->handle;
3132 + m.u.port_action_port.action = action_type;
3134 + port_to_mmal_msg(port, &m.u.port_action_port.port);
3136 + ret = send_synchronous_mmal_msg(instance, &m,
3137 + sizeof(m.u.port_action_port),
3138 + &rmsg, &rmsg_handle);
3142 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
3143 + /* got an unexpected message type in reply */
3148 + ret = -rmsg->u.port_action_reply.status;
3150 + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n",
3152 + ret, port->component->handle, port->handle,
3153 + port_action_type_names[action_type], action_type);
3156 + vchi_held_msg_release(&rmsg_handle);
3161 +/* do a port action with handles as parameters */
3162 +static int port_action_handle(struct vchiq_mmal_instance *instance,
3163 + struct vchiq_mmal_port *port,
3164 + enum mmal_msg_port_action_type action_type,
3165 + u32 connect_component_handle,
3166 + u32 connect_port_handle)
3169 + struct mmal_msg m;
3170 + struct mmal_msg *rmsg;
3171 + VCHI_HELD_MSG_T rmsg_handle;
3173 + m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
3175 + m.u.port_action_handle.component_handle = port->component->handle;
3176 + m.u.port_action_handle.port_handle = port->handle;
3177 + m.u.port_action_handle.action = action_type;
3179 + m.u.port_action_handle.connect_component_handle =
3180 + connect_component_handle;
3181 + m.u.port_action_handle.connect_port_handle = connect_port_handle;
3183 + ret = send_synchronous_mmal_msg(instance, &m,
3184 + sizeof(m.u.port_action_handle),
3185 + &rmsg, &rmsg_handle);
3189 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
3190 + /* got an unexpected message type in reply */
3195 + ret = -rmsg->u.port_action_reply.status;
3197 + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
3199 + ret, port->component->handle, port->handle,
3200 + port_action_type_names[action_type],
3201 + action_type, connect_component_handle, connect_port_handle);
3204 + vchi_held_msg_release(&rmsg_handle);
3209 +static int port_parameter_set(struct vchiq_mmal_instance *instance,
3210 + struct vchiq_mmal_port *port,
3211 + u32 parameter_id, void *value, u32 value_size)
3214 + struct mmal_msg m;
3215 + struct mmal_msg *rmsg;
3216 + VCHI_HELD_MSG_T rmsg_handle;
3218 + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET;
3220 + m.u.port_parameter_set.component_handle = port->component->handle;
3221 + m.u.port_parameter_set.port_handle = port->handle;
3222 + m.u.port_parameter_set.id = parameter_id;
3223 + m.u.port_parameter_set.size = (2 * sizeof(u32)) + value_size;
3224 + memcpy(&m.u.port_parameter_set.value, value, value_size);
3226 + ret = send_synchronous_mmal_msg(instance, &m,
3227 + (4 * sizeof(u32)) + value_size,
3228 + &rmsg, &rmsg_handle);
3232 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_SET) {
3233 + /* got an unexpected message type in reply */
3238 + ret = -rmsg->u.port_parameter_set_reply.status;
3240 + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n",
3242 + ret, port->component->handle, port->handle, parameter_id);
3245 + vchi_held_msg_release(&rmsg_handle);
3250 +static int port_parameter_get(struct vchiq_mmal_instance *instance,
3251 + struct vchiq_mmal_port *port,
3252 + u32 parameter_id, void *value, u32 *value_size)
3255 + struct mmal_msg m;
3256 + struct mmal_msg *rmsg;
3257 + VCHI_HELD_MSG_T rmsg_handle;
3259 + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET;
3261 + m.u.port_parameter_get.component_handle = port->component->handle;
3262 + m.u.port_parameter_get.port_handle = port->handle;
3263 + m.u.port_parameter_get.id = parameter_id;
3264 + m.u.port_parameter_get.size = (2 * sizeof(u32)) + *value_size;
3266 + ret = send_synchronous_mmal_msg(instance, &m,
3268 + mmal_msg_port_parameter_get),
3269 + &rmsg, &rmsg_handle);
3273 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_GET) {
3274 + /* got an unexpected message type in reply */
3275 + pr_err("Incorrect reply type %d\n", rmsg->h.type);
3280 + ret = -rmsg->u.port_parameter_get_reply.status;
3281 + /* port_parameter_get_reply.size includes the header,
3282 + * whilst *value_size doesn't.
3284 + rmsg->u.port_parameter_get_reply.size -= (2 * sizeof(u32));
3286 + if (ret || rmsg->u.port_parameter_get_reply.size > *value_size) {
3287 + /* Copy only as much as we have space for
3288 + * but report true size of parameter
3290 + memcpy(value, &rmsg->u.port_parameter_get_reply.value,
3292 + *value_size = rmsg->u.port_parameter_get_reply.size;
3294 + memcpy(value, &rmsg->u.port_parameter_get_reply.value,
3295 + rmsg->u.port_parameter_get_reply.size);
3298 + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__,
3299 + ret, port->component->handle, port->handle, parameter_id);
3302 + vchi_held_msg_release(&rmsg_handle);
3307 +/* disables a port and drains buffers from it */
3308 +static int port_disable(struct vchiq_mmal_instance *instance,
3309 + struct vchiq_mmal_port *port)
3312 + struct list_head *q, *buf_head;
3313 + unsigned long flags = 0;
3315 + if (!port->enabled)
3318 + port->enabled = false;
3320 + ret = port_action_port(instance, port,
3321 + MMAL_MSG_PORT_ACTION_TYPE_DISABLE);
3324 + * Drain all queued buffers on port. This should only
3325 + * apply to buffers that have been queued before the port
3326 + * has been enabled. If the port has been enabled and buffers
3327 + * passed, then the buffers should have been removed from this
3328 + * list, and we should get the relevant callbacks via VCHIQ
3329 + * to release the buffers.
3331 + spin_lock_irqsave(&port->slock, flags);
3333 + list_for_each_safe(buf_head, q, &port->buffers) {
3334 + struct mmal_buffer *mmalbuf;
3336 + mmalbuf = list_entry(buf_head, struct mmal_buffer,
3338 + list_del(buf_head);
3339 + if (port->buffer_cb)
3340 + port->buffer_cb(instance,
3341 + port, 0, mmalbuf, 0, 0,
3342 + MMAL_TIME_UNKNOWN,
3343 + MMAL_TIME_UNKNOWN);
3346 + spin_unlock_irqrestore(&port->slock, flags);
3348 + ret = port_info_get(instance, port);
3354 +/* enable a port */
3355 +static int port_enable(struct vchiq_mmal_instance *instance,
3356 + struct vchiq_mmal_port *port)
3358 + unsigned int hdr_count;
3359 + struct list_head *q, *buf_head;
3362 + if (port->enabled)
3365 + ret = port_action_port(instance, port,
3366 + MMAL_MSG_PORT_ACTION_TYPE_ENABLE);
3370 + port->enabled = true;
3372 + if (port->buffer_cb) {
3373 + /* send buffer headers to videocore */
3375 + list_for_each_safe(buf_head, q, &port->buffers) {
3376 + struct mmal_buffer *mmalbuf;
3378 + mmalbuf = list_entry(buf_head, struct mmal_buffer,
3380 + ret = buffer_from_host(instance, port, mmalbuf);
3384 + list_del(buf_head);
3386 + if (hdr_count > port->current_buffer.num)
3391 + ret = port_info_get(instance, port);
3397 +/* ------------------------------------------------------------------
3399 + *------------------------------------------------------------------
3402 +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
3403 + struct vchiq_mmal_port *port)
3407 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3410 + ret = port_info_set(instance, port);
3412 + goto release_unlock;
3414 + /* read what has actually been set */
3415 + ret = port_info_get(instance, port);
3418 + mutex_unlock(&instance->vchiq_mutex);
3422 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_set_format);
3424 +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
3425 + struct vchiq_mmal_port *port,
3426 + u32 parameter, void *value, u32 value_size)
3430 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3433 + ret = port_parameter_set(instance, port, parameter, value, value_size);
3435 + mutex_unlock(&instance->vchiq_mutex);
3439 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_set);
3441 +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
3442 + struct vchiq_mmal_port *port,
3443 + u32 parameter, void *value, u32 *value_size)
3447 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3450 + ret = port_parameter_get(instance, port, parameter, value, value_size);
3452 + mutex_unlock(&instance->vchiq_mutex);
3456 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_get);
3460 + * enables a port and queues buffers for satisfying callbacks if we
3461 + * provide a callback handler
3463 +int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
3464 + struct vchiq_mmal_port *port,
3465 + vchiq_mmal_buffer_cb buffer_cb)
3469 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3472 + /* already enabled - noop */
3473 + if (port->enabled) {
3478 + port->buffer_cb = buffer_cb;
3480 + ret = port_enable(instance, port);
3483 + mutex_unlock(&instance->vchiq_mutex);
3487 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_enable);
3489 +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
3490 + struct vchiq_mmal_port *port)
3494 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3497 + if (!port->enabled) {
3498 + mutex_unlock(&instance->vchiq_mutex);
3502 + ret = port_disable(instance, port);
3504 + mutex_unlock(&instance->vchiq_mutex);
3508 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_disable);
3510 +/* ports will be connected in a tunneled manner so data buffers
3511 + * are not handled by client.
3513 +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
3514 + struct vchiq_mmal_port *src,
3515 + struct vchiq_mmal_port *dst)
3519 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3522 + /* disconnect ports if connected */
3523 + if (src->connected) {
3524 + ret = port_disable(instance, src);
3526 + pr_err("failed disabling src port(%d)\n", ret);
3527 + goto release_unlock;
3530 + /* do not need to disable the destination port as they
3531 + * are connected and it is done automatically
3534 + ret = port_action_handle(instance, src,
3535 + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT,
3536 + src->connected->component->handle,
3537 + src->connected->handle);
3539 + pr_err("failed disconnecting src port\n");
3540 + goto release_unlock;
3542 + src->connected->enabled = false;
3543 + src->connected = NULL;
3547 + /* do not make new connection */
3549 + pr_debug("not making new connection\n");
3550 + goto release_unlock;
3553 + /* copy src port format to dst */
3554 + dst->format.encoding = src->format.encoding;
3555 + dst->es.video.width = src->es.video.width;
3556 + dst->es.video.height = src->es.video.height;
3557 + dst->es.video.crop.x = src->es.video.crop.x;
3558 + dst->es.video.crop.y = src->es.video.crop.y;
3559 + dst->es.video.crop.width = src->es.video.crop.width;
3560 + dst->es.video.crop.height = src->es.video.crop.height;
3561 + dst->es.video.frame_rate.num = src->es.video.frame_rate.num;
3562 + dst->es.video.frame_rate.den = src->es.video.frame_rate.den;
3564 + /* set new format */
3565 + ret = port_info_set(instance, dst);
3567 + pr_debug("setting port info failed\n");
3568 + goto release_unlock;
3571 + /* read what has actually been set */
3572 + ret = port_info_get(instance, dst);
3574 + pr_debug("read back port info failed\n");
3575 + goto release_unlock;
3578 + /* connect two ports together */
3579 + ret = port_action_handle(instance, src,
3580 + MMAL_MSG_PORT_ACTION_TYPE_CONNECT,
3581 + dst->component->handle, dst->handle);
3583 + pr_debug("connecting port %d:%d to %d:%d failed\n",
3584 + src->component->handle, src->handle,
3585 + dst->component->handle, dst->handle);
3586 + goto release_unlock;
3588 + src->connected = dst;
3592 + mutex_unlock(&instance->vchiq_mutex);
3596 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_connect_tunnel);
3598 +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
3599 + struct vchiq_mmal_port *port,
3600 + struct mmal_buffer *buffer)
3602 + unsigned long flags = 0;
3605 + ret = buffer_from_host(instance, port, buffer);
3606 + if (ret == -EINVAL) {
3607 + /* Port is disabled. Queue for when it is enabled. */
3608 + spin_lock_irqsave(&port->slock, flags);
3609 + list_add_tail(&buffer->list, &port->buffers);
3610 + spin_unlock_irqrestore(&port->slock, flags);
3615 +EXPORT_SYMBOL_GPL(vchiq_mmal_submit_buffer);
3617 +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
3618 + struct mmal_buffer *buf)
3620 + struct mmal_msg_context *msg_context = get_msg_context(instance);
3622 + if (IS_ERR(msg_context))
3623 + return (PTR_ERR(msg_context));
3625 + buf->msg_context = msg_context;
3628 +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_init);
3630 +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
3632 + struct mmal_msg_context *msg_context = buf->msg_context;
3635 + release_msg_context(msg_context);
3636 + buf->msg_context = NULL;
3640 +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_cleanup);
3642 +/* Initialise a mmal component and its ports
3645 +int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
3647 + struct vchiq_mmal_component **component_out)
3650 + int idx; /* port index */
3651 + struct vchiq_mmal_component *component;
3653 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3656 + if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) {
3657 + ret = -EINVAL; /* todo is this correct error? */
3661 + component = &instance->component[instance->component_idx];
3663 + ret = create_component(instance, component, name);
3665 + pr_err("%s: failed to create component %d (Not enough GPU mem?)\n",
3670 + /* ports info needs gathering */
3671 + component->control.type = MMAL_PORT_TYPE_CONTROL;
3672 + component->control.index = 0;
3673 + component->control.component = component;
3674 + spin_lock_init(&component->control.slock);
3675 + INIT_LIST_HEAD(&component->control.buffers);
3676 + ret = port_info_get(instance, &component->control);
3678 + goto release_component;
3680 + for (idx = 0; idx < component->inputs; idx++) {
3681 + component->input[idx].type = MMAL_PORT_TYPE_INPUT;
3682 + component->input[idx].index = idx;
3683 + component->input[idx].component = component;
3684 + spin_lock_init(&component->input[idx].slock);
3685 + INIT_LIST_HEAD(&component->input[idx].buffers);
3686 + ret = port_info_get(instance, &component->input[idx]);
3688 + goto release_component;
3691 + for (idx = 0; idx < component->outputs; idx++) {
3692 + component->output[idx].type = MMAL_PORT_TYPE_OUTPUT;
3693 + component->output[idx].index = idx;
3694 + component->output[idx].component = component;
3695 + spin_lock_init(&component->output[idx].slock);
3696 + INIT_LIST_HEAD(&component->output[idx].buffers);
3697 + ret = port_info_get(instance, &component->output[idx]);
3699 + goto release_component;
3702 + for (idx = 0; idx < component->clocks; idx++) {
3703 + component->clock[idx].type = MMAL_PORT_TYPE_CLOCK;
3704 + component->clock[idx].index = idx;
3705 + component->clock[idx].component = component;
3706 + spin_lock_init(&component->clock[idx].slock);
3707 + INIT_LIST_HEAD(&component->clock[idx].buffers);
3708 + ret = port_info_get(instance, &component->clock[idx]);
3710 + goto release_component;
3713 + instance->component_idx++;
3715 + *component_out = component;
3717 + mutex_unlock(&instance->vchiq_mutex);
3722 + destroy_component(instance, component);
3724 + mutex_unlock(&instance->vchiq_mutex);
3728 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_init);
3731 + * cause a mmal component to be destroyed
3733 +int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
3734 + struct vchiq_mmal_component *component)
3738 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3741 + if (component->enabled)
3742 + ret = disable_component(instance, component);
3744 + ret = destroy_component(instance, component);
3746 + mutex_unlock(&instance->vchiq_mutex);
3750 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_finalise);
3753 + * cause a mmal component to be enabled
3755 +int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,
3756 + struct vchiq_mmal_component *component)
3760 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3763 + if (component->enabled) {
3764 + mutex_unlock(&instance->vchiq_mutex);
3768 + ret = enable_component(instance, component);
3770 + component->enabled = true;
3772 + mutex_unlock(&instance->vchiq_mutex);
3776 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_enable);
3779 + * cause a mmal component to be enabled
3781 +int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance,
3782 + struct vchiq_mmal_component *component)
3786 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3789 + if (!component->enabled) {
3790 + mutex_unlock(&instance->vchiq_mutex);
3794 + ret = disable_component(instance, component);
3796 + component->enabled = false;
3798 + mutex_unlock(&instance->vchiq_mutex);
3802 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_disable);
3804 +int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
3805 + u32 *major_out, u32 *minor_out)
3809 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3812 + ret = get_version(instance, major_out, minor_out);
3814 + mutex_unlock(&instance->vchiq_mutex);
3818 +EXPORT_SYMBOL_GPL(vchiq_mmal_version);
3820 +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
3827 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3830 + vchi_service_use(instance->handle);
3832 + status = vchi_service_close(instance->handle);
3834 + pr_err("mmal-vchiq: VCHIQ close failed\n");
3836 + mutex_unlock(&instance->vchiq_mutex);
3838 + flush_workqueue(instance->bulk_wq);
3839 + destroy_workqueue(instance->bulk_wq);
3841 + vfree(instance->bulk_scratch);
3843 + idr_destroy(&instance->context_map);
3849 +EXPORT_SYMBOL_GPL(vchiq_mmal_finalise);
3851 +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
3854 + struct vchiq_mmal_instance *instance;
3855 + static VCHI_CONNECTION_T *vchi_connection;
3856 + static VCHI_INSTANCE_T vchi_instance;
3857 + SERVICE_CREATION_T params = {
3858 + .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER),
3859 + .service_id = VC_MMAL_SERVER_NAME,
3860 + .connection = vchi_connection,
3861 + .rx_fifo_size = 0,
3862 + .tx_fifo_size = 0,
3863 + .callback = service_callback,
3864 + .callback_param = NULL,
3865 + .want_unaligned_bulk_rx = 1,
3866 + .want_unaligned_bulk_tx = 1,
3870 + /* compile time checks to ensure structure size as they are
3871 + * directly (de)serialised from memory.
3874 + /* ensure the header structure has packed to the correct size */
3875 + BUILD_BUG_ON(sizeof(struct mmal_msg_header) != 24);
3877 + /* ensure message structure does not exceed maximum length */
3878 + BUILD_BUG_ON(sizeof(struct mmal_msg) > MMAL_MSG_MAX_SIZE);
3880 + /* mmal port struct is correct size */
3881 + BUILD_BUG_ON(sizeof(struct mmal_port) != 64);
3883 + /* create a vchi instance */
3884 + status = vchi_initialise(&vchi_instance);
3886 + pr_err("Failed to initialise VCHI instance (status=%d)\n",
3891 + status = vchi_connect(NULL, 0, vchi_instance);
3893 + pr_err("Failed to connect VCHI instance (status=%d)\n", status);
3897 + instance = kzalloc(sizeof(*instance), GFP_KERNEL);
3902 + mutex_init(&instance->vchiq_mutex);
3904 + instance->bulk_scratch = vmalloc(PAGE_SIZE);
3906 + mutex_init(&instance->context_map_lock);
3907 + idr_init_base(&instance->context_map, 1);
3909 + params.callback_param = instance;
3911 + instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq",
3913 + if (!instance->bulk_wq)
3916 + status = vchi_service_open(vchi_instance, ¶ms, &instance->handle);
3918 + pr_err("Failed to open VCHI service connection (status=%d)\n",
3920 + goto err_close_services;
3923 + vchi_service_release(instance->handle);
3925 + *out_instance = instance;
3929 +err_close_services:
3930 + vchi_service_close(instance->handle);
3931 + destroy_workqueue(instance->bulk_wq);
3933 + vfree(instance->bulk_scratch);
3937 +EXPORT_SYMBOL_GPL(vchiq_mmal_init);
3938 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
3941 -/* SPDX-License-Identifier: GPL-2.0 */
3943 - * Broadcom BM2835 V4L2 driver
3945 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
3947 - * Authors: Vincent Sanders @ Collabora
3948 - * Dave Stevenson @ Broadcom
3949 - * (now dave.stevenson@raspberrypi.org)
3950 - * Simon Mellor @ Broadcom
3951 - * Luke Diamand @ Broadcom
3956 -#ifndef MMAL_COMMON_H
3957 -#define MMAL_COMMON_H
3959 -#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))
3960 -#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
3962 -/** Special value signalling that time is not known */
3963 -#define MMAL_TIME_UNKNOWN BIT_ULL(63)
3965 -struct mmal_msg_context;
3967 -/* mapping between v4l and mmal video modes */
3970 - u32 fourcc; /* v4l2 format id */
3971 - int flags; /* v4l2 flags field */
3974 - u32 mmal_component; /* MMAL component index to be used to encode */
3975 - u32 ybbp; /* depth of first Y plane for planar formats */
3976 - bool remove_padding; /* Does the GPU have to remove padding,
3977 - * or can we do hide padding via bytesperline.
3981 -/* buffer for one video frame */
3982 -struct mmal_buffer {
3983 - /* v4l buffer data -- must be first */
3984 - struct vb2_v4l2_buffer vb;
3986 - /* list of buffers available */
3987 - struct list_head list;
3989 - void *buffer; /* buffer pointer */
3990 - unsigned long buffer_size; /* size of allocated buffer */
3992 - struct mmal_msg_context *msg_context;
3996 -struct mmal_colourfx {
4002 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h
4005 -/* SPDX-License-Identifier: GPL-2.0 */
4007 - * Broadcom BM2835 V4L2 driver
4009 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4011 - * Authors: Vincent Sanders @ Collabora
4012 - * Dave Stevenson @ Broadcom
4013 - * (now dave.stevenson@raspberrypi.org)
4014 - * Simon Mellor @ Broadcom
4015 - * Luke Diamand @ Broadcom
4017 -#ifndef MMAL_ENCODINGS_H
4018 -#define MMAL_ENCODINGS_H
4020 -#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4')
4021 -#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3')
4022 -#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V')
4023 -#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V')
4024 -#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V')
4025 -#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3')
4026 -#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2')
4027 -#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1')
4028 -#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1')
4029 -#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ')
4030 -#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ')
4031 -#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ')
4032 -#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O')
4033 -#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K')
4034 -#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G')
4036 -#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G')
4037 -#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ')
4038 -#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ')
4039 -#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ')
4040 -#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ')
4041 -#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ')
4043 -#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0')
4044 -#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0')
4045 -#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2')
4046 -#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2')
4047 -#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2')
4048 -#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V')
4049 -#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U')
4050 -#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y')
4051 -#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y')
4052 -#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2')
4053 -#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1')
4054 -#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B')
4055 -#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A')
4056 -#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R')
4057 -#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A')
4058 -#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2')
4059 -#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3')
4060 -#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4')
4061 -#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2')
4062 -#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3')
4063 -#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4')
4065 -/** SAND Video (YUVUV128) format, native format understood by VideoCore.
4066 - * This format is *not* opaque - if requested you will receive full frames
4067 - * of YUV_UV video.
4069 -#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D')
4071 -/** VideoCore opaque image format, image handles are returned to
4072 - * the host but not the actual image data.
4074 -#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V')
4076 -/** An EGL image handle
4078 -#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I')
4082 -/** \name Pre-defined audio encodings */
4084 -#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U')
4085 -#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u')
4086 -#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S')
4087 -#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's')
4088 -#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F')
4089 -#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f')
4091 -/* Pre-defined H264 encoding variants */
4093 -/** ISO 14496-10 Annex B byte stream format */
4094 -#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0
4095 -/** ISO 14496-15 AVC stream format */
4096 -#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1')
4097 -/** Implicitly delineated NAL units without emulation prevention */
4098 -#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ')
4100 -/** \defgroup MmalColorSpace List of pre-defined video color spaces
4101 - * This defines a list of common color spaces. This list isn't exhaustive and
4102 - * is only provided as a convenience to avoid clients having to use FourCC
4103 - * codes directly. However components are allowed to define and use their own
4108 -/** Unknown color space */
4109 -#define MMAL_COLOR_SPACE_UNKNOWN 0
4110 -/** ITU-R BT.601-5 [SDTV] */
4111 -#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1')
4112 -/** ITU-R BT.709-3 [HDTV] */
4113 -#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9')
4115 -#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I')
4116 -/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
4117 -#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C')
4118 -/** Society of Motion Picture and Television Engineers 240M (1999) */
4119 -#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0')
4120 -/** ITU-R BT.470-2 System M */
4121 -#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M')
4122 -/** ITU-R BT.470-2 System BG */
4123 -#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G')
4124 -/** JPEG JFIF, but with 16..255 luma */
4125 -#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6')
4126 -/* @} MmalColorSpace List */
4128 -#endif /* MMAL_ENCODINGS_H */
4129 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h
4132 -/* SPDX-License-Identifier: GPL-2.0 */
4134 - * Broadcom BM2835 V4L2 driver
4136 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4138 - * Authors: Vincent Sanders @ Collabora
4139 - * Dave Stevenson @ Broadcom
4140 - * (now dave.stevenson@raspberrypi.org)
4141 - * Simon Mellor @ Broadcom
4142 - * Luke Diamand @ Broadcom
4145 -#ifndef MMAL_MSG_COMMON_H
4146 -#define MMAL_MSG_COMMON_H
4148 -enum mmal_msg_status {
4149 - MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */
4150 - MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */
4151 - MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */
4152 - MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */
4153 - MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */
4154 - MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */
4155 - MMAL_MSG_STATUS_ENXIO, /**< No such device or address */
4156 - MMAL_MSG_STATUS_EIO, /**< I/O error */
4157 - MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */
4158 - MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */
4159 - MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */
4160 - MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */
4161 - MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */
4162 - MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */
4163 - MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */
4164 - MMAL_MSG_STATUS_EFAULT, /**< Bad address */
4168 - s32 x; /**< x coordinate (from left) */
4169 - s32 y; /**< y coordinate (from top) */
4170 - s32 width; /**< width */
4171 - s32 height; /**< height */
4174 -struct mmal_rational {
4175 - s32 num; /**< Numerator */
4176 - s32 den; /**< Denominator */
4179 -#endif /* MMAL_MSG_COMMON_H */
4180 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h
4183 -/* SPDX-License-Identifier: GPL-2.0 */
4185 - * Broadcom BM2835 V4L2 driver
4187 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4189 - * Authors: Vincent Sanders @ Collabora
4190 - * Dave Stevenson @ Broadcom
4191 - * (now dave.stevenson@raspberrypi.org)
4192 - * Simon Mellor @ Broadcom
4193 - * Luke Diamand @ Broadcom
4196 -#ifndef MMAL_MSG_FORMAT_H
4197 -#define MMAL_MSG_FORMAT_H
4199 -#include "mmal-msg-common.h"
4201 -/* MMAL_ES_FORMAT_T */
4203 -struct mmal_audio_format {
4204 - u32 channels; /* Number of audio channels */
4205 - u32 sample_rate; /* Sample rate */
4207 - u32 bits_per_sample; /* Bits per sample */
4208 - u32 block_align; /* Size of a block of data */
4211 -struct mmal_video_format {
4212 - u32 width; /* Width of frame in pixels */
4213 - u32 height; /* Height of frame in rows of pixels */
4214 - struct mmal_rect crop; /* Visible region of the frame */
4215 - struct mmal_rational frame_rate; /* Frame rate */
4216 - struct mmal_rational par; /* Pixel aspect ratio */
4219 - * FourCC specifying the color space of the video stream. See the
4220 - * MmalColorSpace "pre-defined color spaces" for some examples.
4225 -struct mmal_subpicture_format {
4230 -union mmal_es_specific_format {
4231 - struct mmal_audio_format audio;
4232 - struct mmal_video_format video;
4233 - struct mmal_subpicture_format subpicture;
4236 -/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */
4237 -struct mmal_es_format_local {
4238 - u32 type; /* enum mmal_es_type */
4240 - u32 encoding; /* FourCC specifying encoding of the elementary
4243 - u32 encoding_variant; /* FourCC specifying the specific
4244 - * encoding variant of the elementary
4248 - union mmal_es_specific_format *es; /* Type specific
4249 - * information for the
4250 - * elementary stream
4253 - u32 bitrate; /* Bitrate in bits per second */
4254 - u32 flags; /* Flags describing properties of the elementary
4258 - u32 extradata_size; /* Size of the codec specific data */
4259 - u8 *extradata; /* Codec specific data */
4262 -/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */
4263 -struct mmal_es_format {
4264 - u32 type; /* enum mmal_es_type */
4266 - u32 encoding; /* FourCC specifying encoding of the elementary
4269 - u32 encoding_variant; /* FourCC specifying the specific
4270 - * encoding variant of the elementary
4274 - u32 es; /* Type specific
4275 - * information for the
4276 - * elementary stream
4279 - u32 bitrate; /* Bitrate in bits per second */
4280 - u32 flags; /* Flags describing properties of the elementary
4284 - u32 extradata_size; /* Size of the codec specific data */
4285 - u32 extradata; /* Codec specific data */
4288 -#endif /* MMAL_MSG_FORMAT_H */
4289 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h
4292 -/* SPDX-License-Identifier: GPL-2.0 */
4294 - * Broadcom BM2835 V4L2 driver
4296 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4298 - * Authors: Vincent Sanders @ Collabora
4299 - * Dave Stevenson @ Broadcom
4300 - * (now dave.stevenson@raspberrypi.org)
4301 - * Simon Mellor @ Broadcom
4302 - * Luke Diamand @ Broadcom
4305 -/* MMAL_PORT_TYPE_T */
4306 -enum mmal_port_type {
4307 - MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */
4308 - MMAL_PORT_TYPE_CONTROL, /* Control port */
4309 - MMAL_PORT_TYPE_INPUT, /* Input port */
4310 - MMAL_PORT_TYPE_OUTPUT, /* Output port */
4311 - MMAL_PORT_TYPE_CLOCK, /* Clock port */
4314 -/* The port is pass-through and doesn't need buffer headers allocated */
4315 -#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01
4317 - *The port wants to allocate the buffer payloads.
4318 - * This signals a preference that payload allocation should be done
4319 - * on this port for efficiency reasons.
4321 -#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02
4323 - * The port supports format change events.
4324 - * This applies to input ports and is used to let the client know
4325 - * whether the port supports being reconfigured via a format
4326 - * change event (i.e. without having to disable the port).
4328 -#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04
4331 - * mmal port structure (MMAL_PORT_T)
4333 - * most elements are informational only, the pointer values for
4334 - * interogation messages are generally provided as additional
4335 - * structures within the message. When used to set values only the
4336 - * buffer_num, buffer_size and userdata parameters are writable.
4339 - u32 priv; /* Private member used by the framework */
4340 - u32 name; /* Port name. Used for debugging purposes (RO) */
4342 - u32 type; /* Type of the port (RO) enum mmal_port_type */
4343 - u16 index; /* Index of the port in its type list (RO) */
4344 - u16 index_all; /* Index of the port in the list of all ports (RO) */
4346 - u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */
4347 - u32 format; /* Format of the elementary stream */
4349 - u32 buffer_num_min; /* Minimum number of buffers the port
4350 - * requires (RO). This is set by the
4354 - u32 buffer_size_min; /* Minimum size of buffers the port
4355 - * requires (RO). This is set by the
4359 - u32 buffer_alignment_min;/* Minimum alignment requirement for
4360 - * the buffers (RO). A value of
4361 - * zero means no special alignment
4362 - * requirements. This is set by the
4366 - u32 buffer_num_recommended; /* Number of buffers the port
4367 - * recommends for optimal
4368 - * performance (RO). A value of
4369 - * zero means no special
4370 - * recommendation. This is set
4371 - * by the component.
4374 - u32 buffer_size_recommended; /* Size of buffers the port
4375 - * recommends for optimal
4376 - * performance (RO). A value of
4377 - * zero means no special
4378 - * recommendation. This is set
4379 - * by the component.
4382 - u32 buffer_num; /* Actual number of buffers the port will use.
4383 - * This is set by the client.
4386 - u32 buffer_size; /* Actual maximum size of the buffers that
4387 - * will be sent to the port. This is set by
4391 - u32 component; /* Component this port belongs to (Read Only) */
4393 - u32 userdata; /* Field reserved for use by the client */
4395 - u32 capabilities; /* Flags describing the capabilities of a
4396 - * port (RO). Bitwise combination of \ref
4397 - * portcapabilities "Port capabilities"
4401 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
4404 -/* SPDX-License-Identifier: GPL-2.0 */
4406 - * Broadcom BM2835 V4L2 driver
4408 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4410 - * Authors: Vincent Sanders @ Collabora
4411 - * Dave Stevenson @ Broadcom
4412 - * (now dave.stevenson@raspberrypi.org)
4413 - * Simon Mellor @ Broadcom
4414 - * Luke Diamand @ Broadcom
4418 - * all the data structures which serialise the MMAL protocol. note
4419 - * these are directly mapped onto the recived message data.
4421 - * BEWARE: They seem to *assume* pointers are u32 and that there is no
4422 - * structure padding!
4424 - * NOTE: this implementation uses kernel types to ensure sizes. Rather
4425 - * than assigning values to enums to force their size the
4426 - * implementation uses fixed size types and not the enums (though the
4427 - * comments have the actual enum type
4432 -#define VC_MMAL_VER 15
4433 -#define VC_MMAL_MIN_VER 10
4434 -#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal")
4436 -/* max total message size is 512 bytes */
4437 -#define MMAL_MSG_MAX_SIZE 512
4438 -/* with six 32bit header elements max payload is therefore 488 bytes */
4439 -#define MMAL_MSG_MAX_PAYLOAD 488
4441 -#include "mmal-msg-common.h"
4442 -#include "mmal-msg-format.h"
4443 -#include "mmal-msg-port.h"
4445 -enum mmal_msg_type {
4446 - MMAL_MSG_TYPE_QUIT = 1,
4447 - MMAL_MSG_TYPE_SERVICE_CLOSED,
4448 - MMAL_MSG_TYPE_GET_VERSION,
4449 - MMAL_MSG_TYPE_COMPONENT_CREATE,
4450 - MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */
4451 - MMAL_MSG_TYPE_COMPONENT_ENABLE,
4452 - MMAL_MSG_TYPE_COMPONENT_DISABLE,
4453 - MMAL_MSG_TYPE_PORT_INFO_GET,
4454 - MMAL_MSG_TYPE_PORT_INFO_SET,
4455 - MMAL_MSG_TYPE_PORT_ACTION, /* 10 */
4456 - MMAL_MSG_TYPE_BUFFER_FROM_HOST,
4457 - MMAL_MSG_TYPE_BUFFER_TO_HOST,
4458 - MMAL_MSG_TYPE_GET_STATS,
4459 - MMAL_MSG_TYPE_PORT_PARAMETER_SET,
4460 - MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */
4461 - MMAL_MSG_TYPE_EVENT_TO_HOST,
4462 - MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
4463 - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
4464 - MMAL_MSG_TYPE_CONSUME_MEM,
4465 - MMAL_MSG_TYPE_LMK, /* 20 */
4466 - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
4467 - MMAL_MSG_TYPE_DRM_GET_LHS32,
4468 - MMAL_MSG_TYPE_DRM_GET_TIME,
4469 - MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
4470 - MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */
4471 - MMAL_MSG_TYPE_HOST_LOG,
4472 - MMAL_MSG_TYPE_MSG_LAST
4475 -/* port action request messages differ depending on the action type */
4476 -enum mmal_msg_port_action_type {
4477 - MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */
4478 - MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
4479 - MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
4480 - MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
4481 - MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */
4482 - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */
4483 - MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/
4486 -struct mmal_msg_header {
4488 - u32 type; /* enum mmal_msg_type */
4490 - /* Opaque handle to the control service */
4491 - u32 control_service;
4493 - u32 context; /* a u32 per message context */
4494 - u32 status; /* The status of the vchiq operation */
4498 -/* Send from VC to host to report version */
4499 -struct mmal_msg_version {
4506 -/* request to VC to create component */
4507 -struct mmal_msg_component_create {
4508 - u32 client_component; /* component context */
4510 - u32 pid; /* For debug */
4513 -/* reply from VC to component creation request */
4514 -struct mmal_msg_component_create_reply {
4515 - u32 status; /* enum mmal_msg_status - how does this differ to
4516 - * the one in the header?
4518 - u32 component_handle; /* VideoCore handle for component */
4519 - u32 input_num; /* Number of input ports */
4520 - u32 output_num; /* Number of output ports */
4521 - u32 clock_num; /* Number of clock ports */
4524 -/* request to VC to destroy a component */
4525 -struct mmal_msg_component_destroy {
4526 - u32 component_handle;
4529 -struct mmal_msg_component_destroy_reply {
4530 - u32 status; /* The component destruction status */
4533 -/* request and reply to VC to enable a component */
4534 -struct mmal_msg_component_enable {
4535 - u32 component_handle;
4538 -struct mmal_msg_component_enable_reply {
4539 - u32 status; /* The component enable status */
4542 -/* request and reply to VC to disable a component */
4543 -struct mmal_msg_component_disable {
4544 - u32 component_handle;
4547 -struct mmal_msg_component_disable_reply {
4548 - u32 status; /* The component disable status */
4551 -/* request to VC to get port information */
4552 -struct mmal_msg_port_info_get {
4553 - u32 component_handle; /* component handle port is associated with */
4554 - u32 port_type; /* enum mmal_msg_port_type */
4555 - u32 index; /* port index to query */
4558 -/* reply from VC to get port info request */
4559 -struct mmal_msg_port_info_get_reply {
4560 - u32 status; /* enum mmal_msg_status */
4561 - u32 component_handle; /* component handle port is associated with */
4562 - u32 port_type; /* enum mmal_msg_port_type */
4563 - u32 port_index; /* port indexed in query */
4564 - s32 found; /* unused */
4565 - u32 port_handle; /* Handle to use for this port */
4566 - struct mmal_port port;
4567 - struct mmal_es_format format; /* elementary stream format */
4568 - union mmal_es_specific_format es; /* es type specific data */
4569 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */
4572 -/* request to VC to set port information */
4573 -struct mmal_msg_port_info_set {
4574 - u32 component_handle;
4575 - u32 port_type; /* enum mmal_msg_port_type */
4576 - u32 port_index; /* port indexed in query */
4577 - struct mmal_port port;
4578 - struct mmal_es_format format;
4579 - union mmal_es_specific_format es;
4580 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
4583 -/* reply from VC to port info set request */
4584 -struct mmal_msg_port_info_set_reply {
4586 - u32 component_handle; /* component handle port is associated with */
4587 - u32 port_type; /* enum mmal_msg_port_type */
4588 - u32 index; /* port indexed in query */
4589 - s32 found; /* unused */
4590 - u32 port_handle; /* Handle to use for this port */
4591 - struct mmal_port port;
4592 - struct mmal_es_format format;
4593 - union mmal_es_specific_format es;
4594 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
4597 -/* port action requests that take a mmal_port as a parameter */
4598 -struct mmal_msg_port_action_port {
4599 - u32 component_handle;
4601 - u32 action; /* enum mmal_msg_port_action_type */
4602 - struct mmal_port port;
4605 -/* port action requests that take handles as a parameter */
4606 -struct mmal_msg_port_action_handle {
4607 - u32 component_handle;
4609 - u32 action; /* enum mmal_msg_port_action_type */
4610 - u32 connect_component_handle;
4611 - u32 connect_port_handle;
4614 -struct mmal_msg_port_action_reply {
4615 - u32 status; /* The port action operation status */
4618 -/* MMAL buffer transfer */
4620 -/* Size of space reserved in a buffer message for short messages. */
4621 -#define MMAL_VC_SHORT_DATA 128
4623 -/* Signals that the current payload is the end of the stream of data */
4624 -#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0)
4625 -/* Signals that the start of the current payload starts a frame */
4626 -#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1)
4627 -/* Signals that the end of the current payload ends a frame */
4628 -#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2)
4629 -/* Signals that the current payload contains only complete frames (>1) */
4630 -#define MMAL_BUFFER_HEADER_FLAG_FRAME \
4631 - (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \
4632 - MMAL_BUFFER_HEADER_FLAG_FRAME_END)
4633 -/* Signals that the current payload is a keyframe (i.e. self decodable) */
4634 -#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3)
4636 - * Signals a discontinuity in the stream of data (e.g. after a seek).
4637 - * Can be used for instance by a decoder to reset its state
4639 -#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4)
4641 - * Signals a buffer containing some kind of config data for the component
4642 - * (e.g. codec config data)
4644 -#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5)
4645 -/* Signals an encrypted payload */
4646 -#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6)
4647 -/* Signals a buffer containing side information */
4648 -#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7)
4650 - * Signals a buffer which is the snapshot/postview image from a stills
4653 -#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8)
4654 -/* Signals a buffer which contains data known to be corrupted */
4655 -#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9)
4656 -/* Signals that a buffer failed to be transmitted */
4657 -#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10)
4659 -struct mmal_driver_buffer {
4661 - u32 component_handle;
4663 - u32 client_context;
4666 -/* buffer header */
4667 -struct mmal_buffer_header {
4668 - u32 next; /* next header */
4669 - u32 priv; /* framework private data */
4682 -struct mmal_buffer_header_type_specific {
4693 -struct mmal_msg_buffer_from_host {
4695 - *The front 32 bytes of the buffer header are copied
4696 - * back to us in the reply to allow for context. This
4697 - * area is used to store two mmal_driver_buffer structures to
4698 - * allow for multiple concurrent service users.
4700 - /* control data */
4701 - struct mmal_driver_buffer drvbuf;
4703 - /* referenced control data for passthrough buffer management */
4704 - struct mmal_driver_buffer drvbuf_ref;
4705 - struct mmal_buffer_header buffer_header; /* buffer header itself */
4706 - struct mmal_buffer_header_type_specific buffer_header_type_specific;
4708 - s32 has_reference;
4710 - /* allows short data to be xfered in control message */
4711 - u32 payload_in_message;
4712 - u8 short_data[MMAL_VC_SHORT_DATA];
4715 -/* port parameter setting */
4717 -#define MMAL_WORKER_PORT_PARAMETER_SPACE 96
4719 -struct mmal_msg_port_parameter_set {
4720 - u32 component_handle; /* component */
4721 - u32 port_handle; /* port */
4722 - u32 id; /* Parameter ID */
4723 - u32 size; /* Parameter size */
4724 - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
4727 -struct mmal_msg_port_parameter_set_reply {
4728 - u32 status; /* enum mmal_msg_status todo: how does this
4729 - * differ to the one in the header?
4733 -/* port parameter getting */
4735 -struct mmal_msg_port_parameter_get {
4736 - u32 component_handle; /* component */
4737 - u32 port_handle; /* port */
4738 - u32 id; /* Parameter ID */
4739 - u32 size; /* Parameter size */
4742 -struct mmal_msg_port_parameter_get_reply {
4743 - u32 status; /* Status of mmal_port_parameter_get call */
4744 - u32 id; /* Parameter ID */
4745 - u32 size; /* Parameter size */
4746 - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
4749 -/* event messages */
4750 -#define MMAL_WORKER_EVENT_SPACE 256
4752 -struct mmal_msg_event_to_host {
4753 - u32 client_component; /* component context */
4760 - u8 data[MMAL_WORKER_EVENT_SPACE];
4761 - u32 delayed_buffer;
4764 -/* all mmal messages are serialised through this structure */
4767 - struct mmal_msg_header h;
4770 - struct mmal_msg_version version;
4772 - struct mmal_msg_component_create component_create;
4773 - struct mmal_msg_component_create_reply component_create_reply;
4775 - struct mmal_msg_component_destroy component_destroy;
4776 - struct mmal_msg_component_destroy_reply component_destroy_reply;
4778 - struct mmal_msg_component_enable component_enable;
4779 - struct mmal_msg_component_enable_reply component_enable_reply;
4781 - struct mmal_msg_component_disable component_disable;
4782 - struct mmal_msg_component_disable_reply component_disable_reply;
4784 - struct mmal_msg_port_info_get port_info_get;
4785 - struct mmal_msg_port_info_get_reply port_info_get_reply;
4787 - struct mmal_msg_port_info_set port_info_set;
4788 - struct mmal_msg_port_info_set_reply port_info_set_reply;
4790 - struct mmal_msg_port_action_port port_action_port;
4791 - struct mmal_msg_port_action_handle port_action_handle;
4792 - struct mmal_msg_port_action_reply port_action_reply;
4794 - struct mmal_msg_buffer_from_host buffer_from_host;
4796 - struct mmal_msg_port_parameter_set port_parameter_set;
4797 - struct mmal_msg_port_parameter_set_reply
4798 - port_parameter_set_reply;
4799 - struct mmal_msg_port_parameter_get
4800 - port_parameter_get;
4801 - struct mmal_msg_port_parameter_get_reply
4802 - port_parameter_get_reply;
4804 - struct mmal_msg_event_to_host event_to_host;
4806 - u8 payload[MMAL_MSG_MAX_PAYLOAD];
4810 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h
4813 -/* SPDX-License-Identifier: GPL-2.0 */
4815 - * Broadcom BM2835 V4L2 driver
4817 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4819 - * Authors: Vincent Sanders @ Collabora
4820 - * Dave Stevenson @ Broadcom
4821 - * (now dave.stevenson@raspberrypi.org)
4822 - * Simon Mellor @ Broadcom
4823 - * Luke Diamand @ Broadcom
4826 -/* common parameters */
4828 -/** @name Parameter groups
4829 - * Parameters are divided into groups, and then allocated sequentially within
4830 - * a group using an enum.
4834 -#ifndef MMAL_PARAMETERS_H
4835 -#define MMAL_PARAMETERS_H
4837 -/** Common parameter ID group, used with many types of component. */
4838 -#define MMAL_PARAMETER_GROUP_COMMON (0 << 16)
4839 -/** Camera-specific parameter ID group. */
4840 -#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16)
4841 -/** Video-specific parameter ID group. */
4842 -#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16)
4843 -/** Audio-specific parameter ID group. */
4844 -#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16)
4845 -/** Clock-specific parameter ID group. */
4846 -#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16)
4847 -/** Miracast-specific parameter ID group. */
4848 -#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16)
4850 -/* Common parameters */
4851 -enum mmal_parameter_common_type {
4852 - /**< Never a valid parameter ID */
4853 - MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON,
4855 - /**< MMAL_PARAMETER_ENCODING_T */
4856 - MMAL_PARAMETER_SUPPORTED_ENCODINGS,
4857 - /**< MMAL_PARAMETER_URI_T */
4858 - MMAL_PARAMETER_URI,
4859 - /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */
4860 - MMAL_PARAMETER_CHANGE_EVENT_REQUEST,
4861 - /** MMAL_PARAMETER_BOOLEAN_T */
4862 - MMAL_PARAMETER_ZERO_COPY,
4863 - /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */
4864 - MMAL_PARAMETER_BUFFER_REQUIREMENTS,
4865 - /**< MMAL_PARAMETER_STATISTICS_T */
4866 - MMAL_PARAMETER_STATISTICS,
4867 - /**< MMAL_PARAMETER_CORE_STATISTICS_T */
4868 - MMAL_PARAMETER_CORE_STATISTICS,
4869 - /**< MMAL_PARAMETER_MEM_USAGE_T */
4870 - MMAL_PARAMETER_MEM_USAGE,
4871 - /**< MMAL_PARAMETER_UINT32_T */
4872 - MMAL_PARAMETER_BUFFER_FLAG_FILTER,
4873 - /**< MMAL_PARAMETER_SEEK_T */
4874 - MMAL_PARAMETER_SEEK,
4875 - /**< MMAL_PARAMETER_BOOLEAN_T */
4876 - MMAL_PARAMETER_POWERMON_ENABLE,
4877 - /**< MMAL_PARAMETER_LOGGING_T */
4878 - MMAL_PARAMETER_LOGGING,
4879 - /**< MMAL_PARAMETER_UINT64_T */
4880 - MMAL_PARAMETER_SYSTEM_TIME,
4881 - /**< MMAL_PARAMETER_BOOLEAN_T */
4882 - MMAL_PARAMETER_NO_IMAGE_PADDING,
4885 -/* camera parameters */
4887 -enum mmal_parameter_camera_type {
4889 - /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */
4890 - MMAL_PARAMETER_THUMBNAIL_CONFIGURATION =
4891 - MMAL_PARAMETER_GROUP_CAMERA,
4893 - MMAL_PARAMETER_CAPTURE_QUALITY,
4894 - /**< @ref MMAL_PARAMETER_INT32_T */
4895 - MMAL_PARAMETER_ROTATION,
4896 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4897 - MMAL_PARAMETER_EXIF_DISABLE,
4898 - /**< @ref MMAL_PARAMETER_EXIF_T */
4899 - MMAL_PARAMETER_EXIF,
4900 - /**< @ref MMAL_PARAM_AWBMODE_T */
4901 - MMAL_PARAMETER_AWB_MODE,
4902 - /**< @ref MMAL_PARAMETER_IMAGEFX_T */
4903 - MMAL_PARAMETER_IMAGE_EFFECT,
4904 - /**< @ref MMAL_PARAMETER_COLOURFX_T */
4905 - MMAL_PARAMETER_COLOUR_EFFECT,
4906 - /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */
4907 - MMAL_PARAMETER_FLICKER_AVOID,
4908 - /**< @ref MMAL_PARAMETER_FLASH_T */
4909 - MMAL_PARAMETER_FLASH,
4910 - /**< @ref MMAL_PARAMETER_REDEYE_T */
4911 - MMAL_PARAMETER_REDEYE,
4912 - /**< @ref MMAL_PARAMETER_FOCUS_T */
4913 - MMAL_PARAMETER_FOCUS,
4915 - MMAL_PARAMETER_FOCAL_LENGTHS,
4916 - /**< @ref MMAL_PARAMETER_INT32_T */
4917 - MMAL_PARAMETER_EXPOSURE_COMP,
4918 - /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */
4919 - MMAL_PARAMETER_ZOOM,
4920 - /**< @ref MMAL_PARAMETER_MIRROR_T */
4921 - MMAL_PARAMETER_MIRROR,
4924 - /**< @ref MMAL_PARAMETER_UINT32_T */
4925 - MMAL_PARAMETER_CAMERA_NUM,
4926 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4927 - MMAL_PARAMETER_CAPTURE,
4928 - /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */
4929 - MMAL_PARAMETER_EXPOSURE_MODE,
4930 - /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */
4931 - MMAL_PARAMETER_EXP_METERING_MODE,
4932 - /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */
4933 - MMAL_PARAMETER_FOCUS_STATUS,
4934 - /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */
4935 - MMAL_PARAMETER_CAMERA_CONFIG,
4936 - /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */
4937 - MMAL_PARAMETER_CAPTURE_STATUS,
4938 - /**< @ref MMAL_PARAMETER_FACE_TRACK_T */
4939 - MMAL_PARAMETER_FACE_TRACK,
4940 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4941 - MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS,
4942 - /**< @ref MMAL_PARAMETER_UINT32_T */
4943 - MMAL_PARAMETER_JPEG_Q_FACTOR,
4944 - /**< @ref MMAL_PARAMETER_FRAME_RATE_T */
4945 - MMAL_PARAMETER_FRAME_RATE,
4946 - /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */
4947 - MMAL_PARAMETER_USE_STC,
4948 - /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */
4949 - MMAL_PARAMETER_CAMERA_INFO,
4950 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4951 - MMAL_PARAMETER_VIDEO_STABILISATION,
4952 - /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */
4953 - MMAL_PARAMETER_FACE_TRACK_RESULTS,
4954 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4955 - MMAL_PARAMETER_ENABLE_RAW_CAPTURE,
4958 - /**< @ref MMAL_PARAMETER_URI_T */
4959 - MMAL_PARAMETER_DPF_FILE,
4960 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4961 - MMAL_PARAMETER_ENABLE_DPF_FILE,
4962 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4963 - MMAL_PARAMETER_DPF_FAIL_IS_FATAL,
4964 - /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */
4965 - MMAL_PARAMETER_CAPTURE_MODE,
4966 - /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */
4967 - MMAL_PARAMETER_FOCUS_REGIONS,
4968 - /**< @ref MMAL_PARAMETER_INPUT_CROP_T */
4969 - MMAL_PARAMETER_INPUT_CROP,
4970 - /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */
4971 - MMAL_PARAMETER_SENSOR_INFORMATION,
4972 - /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */
4973 - MMAL_PARAMETER_FLASH_SELECT,
4974 - /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */
4975 - MMAL_PARAMETER_FIELD_OF_VIEW,
4976 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4977 - MMAL_PARAMETER_HIGH_DYNAMIC_RANGE,
4978 - /**< @ref MMAL_PARAMETER_DRC_T */
4979 - MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION,
4980 - /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */
4981 - MMAL_PARAMETER_ALGORITHM_CONTROL,
4982 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4983 - MMAL_PARAMETER_SHARPNESS,
4984 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4985 - MMAL_PARAMETER_CONTRAST,
4986 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4987 - MMAL_PARAMETER_BRIGHTNESS,
4988 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4989 - MMAL_PARAMETER_SATURATION,
4992 - /**< @ref MMAL_PARAMETER_UINT32_T */
4993 - MMAL_PARAMETER_ISO,
4994 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4995 - MMAL_PARAMETER_ANTISHAKE,
4996 - /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */
4997 - MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,
4998 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
4999 - MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
5000 - /** @ref MMAL_PARAMETER_UINT32_T */
5001 - MMAL_PARAMETER_CAMERA_MIN_ISO,
5002 - /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */
5003 - MMAL_PARAMETER_CAMERA_USE_CASE,
5004 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5005 - MMAL_PARAMETER_CAPTURE_STATS_PASS,
5006 - /** @ref MMAL_PARAMETER_UINT32_T */
5007 - MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG,
5008 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5009 - MMAL_PARAMETER_ENABLE_REGISTER_FILE,
5010 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5011 - MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
5012 - /** @ref MMAL_PARAMETER_CONFIGFILE_T */
5013 - MMAL_PARAMETER_CONFIGFILE_REGISTERS,
5014 - /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */
5015 - MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS,
5016 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5017 - MMAL_PARAMETER_JPEG_ATTACH_LOG,
5018 - /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */
5019 - MMAL_PARAMETER_ZERO_SHUTTER_LAG,
5020 - /**< @ref MMAL_PARAMETER_FPS_RANGE_T */
5021 - MMAL_PARAMETER_FPS_RANGE,
5022 - /**< @ref MMAL_PARAMETER_INT32_T */
5023 - MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP,
5026 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5027 - MMAL_PARAMETER_SW_SHARPEN_DISABLE,
5028 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5029 - MMAL_PARAMETER_FLASH_REQUIRED,
5030 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5031 - MMAL_PARAMETER_SW_SATURATION_DISABLE,
5032 - /**< Takes a @ref MMAL_PARAMETER_UINT32_T */
5033 - MMAL_PARAMETER_SHUTTER_SPEED,
5034 - /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */
5035 - MMAL_PARAMETER_CUSTOM_AWB_GAINS,
5038 -struct mmal_parameter_rational {
5039 - s32 num; /**< Numerator */
5040 - s32 den; /**< Denominator */
5043 -enum mmal_parameter_camera_config_timestamp_mode {
5044 - MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */
5045 - MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value
5046 - * for the frame timestamp
5048 - MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp
5049 - * but subtract the
5050 - * timestamp of the first
5051 - * frame sent to give a
5052 - * zero based timestamp.
5056 -struct mmal_parameter_fps_range {
5057 - /**< Low end of the permitted framerate range */
5058 - struct mmal_parameter_rational fps_low;
5059 - /**< High end of the permitted framerate range */
5060 - struct mmal_parameter_rational fps_high;
5063 -/* camera configuration parameter */
5064 -struct mmal_parameter_camera_config {
5065 - /* Parameters for setting up the image pools */
5066 - u32 max_stills_w; /* Max size of stills capture */
5068 - u32 stills_yuv422; /* Allow YUV422 stills capture */
5069 - u32 one_shot_stills; /* Continuous or one shot stills captures. */
5071 - u32 max_preview_video_w; /* Max size of the preview or video
5074 - u32 max_preview_video_h;
5075 - u32 num_preview_video_frames;
5077 - /** Sets the height of the circular buffer for stills capture. */
5078 - u32 stills_capture_circular_buffer_height;
5080 - /** Allows preview/encode to resume as fast as possible after the stills
5081 - * input frame has been received, and then processes the still frame in
5082 - * the background whilst preview/encode has resumed.
5083 - * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE.
5085 - u32 fast_preview_resume;
5087 - /** Selects algorithm for timestamping frames if
5088 - * there is no clock component connected.
5089 - * enum mmal_parameter_camera_config_timestamp_mode
5091 - s32 use_stc_timestamp;
5094 -enum mmal_parameter_exposuremode {
5095 - MMAL_PARAM_EXPOSUREMODE_OFF,
5096 - MMAL_PARAM_EXPOSUREMODE_AUTO,
5097 - MMAL_PARAM_EXPOSUREMODE_NIGHT,
5098 - MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
5099 - MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
5100 - MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
5101 - MMAL_PARAM_EXPOSUREMODE_SPORTS,
5102 - MMAL_PARAM_EXPOSUREMODE_SNOW,
5103 - MMAL_PARAM_EXPOSUREMODE_BEACH,
5104 - MMAL_PARAM_EXPOSUREMODE_VERYLONG,
5105 - MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
5106 - MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
5107 - MMAL_PARAM_EXPOSUREMODE_FIREWORKS,
5110 -enum mmal_parameter_exposuremeteringmode {
5111 - MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
5112 - MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
5113 - MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
5114 - MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX,
5117 -enum mmal_parameter_awbmode {
5118 - MMAL_PARAM_AWBMODE_OFF,
5119 - MMAL_PARAM_AWBMODE_AUTO,
5120 - MMAL_PARAM_AWBMODE_SUNLIGHT,
5121 - MMAL_PARAM_AWBMODE_CLOUDY,
5122 - MMAL_PARAM_AWBMODE_SHADE,
5123 - MMAL_PARAM_AWBMODE_TUNGSTEN,
5124 - MMAL_PARAM_AWBMODE_FLUORESCENT,
5125 - MMAL_PARAM_AWBMODE_INCANDESCENT,
5126 - MMAL_PARAM_AWBMODE_FLASH,
5127 - MMAL_PARAM_AWBMODE_HORIZON,
5130 -enum mmal_parameter_imagefx {
5131 - MMAL_PARAM_IMAGEFX_NONE,
5132 - MMAL_PARAM_IMAGEFX_NEGATIVE,
5133 - MMAL_PARAM_IMAGEFX_SOLARIZE,
5134 - MMAL_PARAM_IMAGEFX_POSTERIZE,
5135 - MMAL_PARAM_IMAGEFX_WHITEBOARD,
5136 - MMAL_PARAM_IMAGEFX_BLACKBOARD,
5137 - MMAL_PARAM_IMAGEFX_SKETCH,
5138 - MMAL_PARAM_IMAGEFX_DENOISE,
5139 - MMAL_PARAM_IMAGEFX_EMBOSS,
5140 - MMAL_PARAM_IMAGEFX_OILPAINT,
5141 - MMAL_PARAM_IMAGEFX_HATCH,
5142 - MMAL_PARAM_IMAGEFX_GPEN,
5143 - MMAL_PARAM_IMAGEFX_PASTEL,
5144 - MMAL_PARAM_IMAGEFX_WATERCOLOUR,
5145 - MMAL_PARAM_IMAGEFX_FILM,
5146 - MMAL_PARAM_IMAGEFX_BLUR,
5147 - MMAL_PARAM_IMAGEFX_SATURATION,
5148 - MMAL_PARAM_IMAGEFX_COLOURSWAP,
5149 - MMAL_PARAM_IMAGEFX_WASHEDOUT,
5150 - MMAL_PARAM_IMAGEFX_POSTERISE,
5151 - MMAL_PARAM_IMAGEFX_COLOURPOINT,
5152 - MMAL_PARAM_IMAGEFX_COLOURBALANCE,
5153 - MMAL_PARAM_IMAGEFX_CARTOON,
5156 -enum MMAL_PARAM_FLICKERAVOID_T {
5157 - MMAL_PARAM_FLICKERAVOID_OFF,
5158 - MMAL_PARAM_FLICKERAVOID_AUTO,
5159 - MMAL_PARAM_FLICKERAVOID_50HZ,
5160 - MMAL_PARAM_FLICKERAVOID_60HZ,
5161 - MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF
5164 -struct mmal_parameter_awbgains {
5165 - struct mmal_parameter_rational r_gain; /**< Red gain */
5166 - struct mmal_parameter_rational b_gain; /**< Blue gain */
5169 -/** Manner of video rate control */
5170 -enum mmal_parameter_rate_control_mode {
5171 - MMAL_VIDEO_RATECONTROL_DEFAULT,
5172 - MMAL_VIDEO_RATECONTROL_VARIABLE,
5173 - MMAL_VIDEO_RATECONTROL_CONSTANT,
5174 - MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES,
5175 - MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES
5178 -enum mmal_video_profile {
5179 - MMAL_VIDEO_PROFILE_H263_BASELINE,
5180 - MMAL_VIDEO_PROFILE_H263_H320CODING,
5181 - MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE,
5182 - MMAL_VIDEO_PROFILE_H263_ISWV2,
5183 - MMAL_VIDEO_PROFILE_H263_ISWV3,
5184 - MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION,
5185 - MMAL_VIDEO_PROFILE_H263_INTERNET,
5186 - MMAL_VIDEO_PROFILE_H263_INTERLACE,
5187 - MMAL_VIDEO_PROFILE_H263_HIGHLATENCY,
5188 - MMAL_VIDEO_PROFILE_MP4V_SIMPLE,
5189 - MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE,
5190 - MMAL_VIDEO_PROFILE_MP4V_CORE,
5191 - MMAL_VIDEO_PROFILE_MP4V_MAIN,
5192 - MMAL_VIDEO_PROFILE_MP4V_NBIT,
5193 - MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE,
5194 - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE,
5195 - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA,
5196 - MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED,
5197 - MMAL_VIDEO_PROFILE_MP4V_HYBRID,
5198 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME,
5199 - MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE,
5200 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING,
5201 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE,
5202 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE,
5203 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE,
5204 - MMAL_VIDEO_PROFILE_H264_BASELINE,
5205 - MMAL_VIDEO_PROFILE_H264_MAIN,
5206 - MMAL_VIDEO_PROFILE_H264_EXTENDED,
5207 - MMAL_VIDEO_PROFILE_H264_HIGH,
5208 - MMAL_VIDEO_PROFILE_H264_HIGH10,
5209 - MMAL_VIDEO_PROFILE_H264_HIGH422,
5210 - MMAL_VIDEO_PROFILE_H264_HIGH444,
5211 - MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE,
5212 - MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF
5215 -enum mmal_video_level {
5216 - MMAL_VIDEO_LEVEL_H263_10,
5217 - MMAL_VIDEO_LEVEL_H263_20,
5218 - MMAL_VIDEO_LEVEL_H263_30,
5219 - MMAL_VIDEO_LEVEL_H263_40,
5220 - MMAL_VIDEO_LEVEL_H263_45,
5221 - MMAL_VIDEO_LEVEL_H263_50,
5222 - MMAL_VIDEO_LEVEL_H263_60,
5223 - MMAL_VIDEO_LEVEL_H263_70,
5224 - MMAL_VIDEO_LEVEL_MP4V_0,
5225 - MMAL_VIDEO_LEVEL_MP4V_0b,
5226 - MMAL_VIDEO_LEVEL_MP4V_1,
5227 - MMAL_VIDEO_LEVEL_MP4V_2,
5228 - MMAL_VIDEO_LEVEL_MP4V_3,
5229 - MMAL_VIDEO_LEVEL_MP4V_4,
5230 - MMAL_VIDEO_LEVEL_MP4V_4a,
5231 - MMAL_VIDEO_LEVEL_MP4V_5,
5232 - MMAL_VIDEO_LEVEL_MP4V_6,
5233 - MMAL_VIDEO_LEVEL_H264_1,
5234 - MMAL_VIDEO_LEVEL_H264_1b,
5235 - MMAL_VIDEO_LEVEL_H264_11,
5236 - MMAL_VIDEO_LEVEL_H264_12,
5237 - MMAL_VIDEO_LEVEL_H264_13,
5238 - MMAL_VIDEO_LEVEL_H264_2,
5239 - MMAL_VIDEO_LEVEL_H264_21,
5240 - MMAL_VIDEO_LEVEL_H264_22,
5241 - MMAL_VIDEO_LEVEL_H264_3,
5242 - MMAL_VIDEO_LEVEL_H264_31,
5243 - MMAL_VIDEO_LEVEL_H264_32,
5244 - MMAL_VIDEO_LEVEL_H264_4,
5245 - MMAL_VIDEO_LEVEL_H264_41,
5246 - MMAL_VIDEO_LEVEL_H264_42,
5247 - MMAL_VIDEO_LEVEL_H264_5,
5248 - MMAL_VIDEO_LEVEL_H264_51,
5249 - MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF
5252 -struct mmal_parameter_video_profile {
5253 - enum mmal_video_profile profile;
5254 - enum mmal_video_level level;
5257 -/* video parameters */
5259 -enum mmal_parameter_video_type {
5260 - /** @ref MMAL_DISPLAYREGION_T */
5261 - MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO,
5263 - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
5264 - MMAL_PARAMETER_SUPPORTED_PROFILES,
5266 - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
5267 - MMAL_PARAMETER_PROFILE,
5269 - /** @ref MMAL_PARAMETER_UINT32_T */
5270 - MMAL_PARAMETER_INTRAPERIOD,
5272 - /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */
5273 - MMAL_PARAMETER_RATECONTROL,
5275 - /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */
5276 - MMAL_PARAMETER_NALUNITFORMAT,
5278 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5279 - MMAL_PARAMETER_MINIMISE_FRAGMENTATION,
5281 - /** @ref MMAL_PARAMETER_UINT32_T.
5282 - * Setting the value to zero resets to the default (one slice per
5285 - MMAL_PARAMETER_MB_ROWS_PER_SLICE,
5287 - /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */
5288 - MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION,
5290 - /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */
5291 - MMAL_PARAMETER_VIDEO_EEDE_ENABLE,
5293 - /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */
5294 - MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE,
5296 - /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */
5297 - MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME,
5298 - /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */
5299 - MMAL_PARAMETER_VIDEO_INTRA_REFRESH,
5301 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5302 - MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT,
5304 - /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */
5305 - MMAL_PARAMETER_VIDEO_BIT_RATE,
5307 - /** @ref MMAL_PARAMETER_FRAME_RATE_T */
5308 - MMAL_PARAMETER_VIDEO_FRAME_RATE,
5310 - /** @ref MMAL_PARAMETER_UINT32_T. */
5311 - MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
5313 - /** @ref MMAL_PARAMETER_UINT32_T. */
5314 - MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
5316 - /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */
5317 - MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL,
5319 - MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */
5320 - /** @ref MMAL_PARAMETER_UINT32_T.
5321 - * Changing this parameter from the default can reduce frame rate
5322 - * because image buffers need to be re-pitched.
5324 - MMAL_PARAMETER_VIDEO_ALIGN_HORIZ,
5326 - /** @ref MMAL_PARAMETER_UINT32_T.
5327 - * Changing this parameter from the default can reduce frame rate
5328 - * because image buffers need to be re-pitched.
5330 - MMAL_PARAMETER_VIDEO_ALIGN_VERT,
5332 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5333 - MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES,
5335 - /** @ref MMAL_PARAMETER_UINT32_T. */
5336 - MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT,
5338 - /**< @ref MMAL_PARAMETER_UINT32_T. */
5339 - MMAL_PARAMETER_VIDEO_ENCODE_QP_P,
5341 - /**< @ref MMAL_PARAMETER_UINT32_T. */
5342 - MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT,
5344 - /** @ref MMAL_PARAMETER_UINT32_T */
5345 - MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS,
5347 - /** @ref MMAL_PARAMETER_UINT32_T. */
5348 - MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE,
5350 - /* H264 specific parameters */
5352 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5353 - MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC,
5355 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5356 - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY,
5358 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5359 - MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS,
5361 - /** @ref MMAL_PARAMETER_UINT32_T. */
5362 - MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC,
5364 - /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */
5365 - MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE,
5367 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5368 - MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN,
5370 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5371 - MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP,
5373 - /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */
5374 - MMAL_PARAMETER_VIDEO_DRM_INIT_INFO,
5376 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5377 - MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO,
5379 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5380 - MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT,
5382 - /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */
5383 - MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
5385 - /** @ref MMAL_PARAMETER_BYTES_T */
5386 - MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
5388 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5389 - MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
5391 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5392 - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
5394 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5395 - MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
5398 -/** Valid mirror modes */
5399 -enum mmal_parameter_mirror {
5400 - MMAL_PARAM_MIRROR_NONE,
5401 - MMAL_PARAM_MIRROR_VERTICAL,
5402 - MMAL_PARAM_MIRROR_HORIZONTAL,
5403 - MMAL_PARAM_MIRROR_BOTH,
5406 -enum mmal_parameter_displaytransform {
5407 - MMAL_DISPLAY_ROT0 = 0,
5408 - MMAL_DISPLAY_MIRROR_ROT0 = 1,
5409 - MMAL_DISPLAY_MIRROR_ROT180 = 2,
5410 - MMAL_DISPLAY_ROT180 = 3,
5411 - MMAL_DISPLAY_MIRROR_ROT90 = 4,
5412 - MMAL_DISPLAY_ROT270 = 5,
5413 - MMAL_DISPLAY_ROT90 = 6,
5414 - MMAL_DISPLAY_MIRROR_ROT270 = 7,
5417 -enum mmal_parameter_displaymode {
5418 - MMAL_DISPLAY_MODE_FILL = 0,
5419 - MMAL_DISPLAY_MODE_LETTERBOX = 1,
5422 -enum mmal_parameter_displayset {
5423 - MMAL_DISPLAY_SET_NONE = 0,
5424 - MMAL_DISPLAY_SET_NUM = 1,
5425 - MMAL_DISPLAY_SET_FULLSCREEN = 2,
5426 - MMAL_DISPLAY_SET_TRANSFORM = 4,
5427 - MMAL_DISPLAY_SET_DEST_RECT = 8,
5428 - MMAL_DISPLAY_SET_SRC_RECT = 0x10,
5429 - MMAL_DISPLAY_SET_MODE = 0x20,
5430 - MMAL_DISPLAY_SET_PIXEL = 0x40,
5431 - MMAL_DISPLAY_SET_NOASPECT = 0x80,
5432 - MMAL_DISPLAY_SET_LAYER = 0x100,
5433 - MMAL_DISPLAY_SET_COPYPROTECT = 0x200,
5434 - MMAL_DISPLAY_SET_ALPHA = 0x400,
5437 -/* rectangle, used lots so it gets its own struct */
5438 -struct vchiq_mmal_rect {
5445 -struct mmal_parameter_displayregion {
5446 - /** Bitfield that indicates which fields are set and should be
5447 - * used. All other fields will maintain their current value.
5448 - * \ref MMAL_DISPLAYSET_T defines the bits that can be
5453 - /** Describes the display output device, with 0 typically
5454 - * being a directly connected LCD display. The actual values
5455 - * will depend on the hardware. Code using hard-wired numbers
5456 - * (e.g. 2) is certain to fail.
5460 - /** Indicates that we are using the full device screen area,
5461 - * rather than a window of the display. If zero, then
5462 - * dest_rect is used to specify a region of the display to
5467 - /** Indicates any rotation or flipping used to map frames onto
5468 - * the natural display orientation.
5470 - u32 transform; /* enum mmal_parameter_displaytransform */
5472 - /** Where to display the frame within the screen, if
5473 - * fullscreen is zero.
5475 - struct vchiq_mmal_rect dest_rect;
5477 - /** Indicates which area of the frame to display. If all
5478 - * values are zero, the whole frame will be used.
5480 - struct vchiq_mmal_rect src_rect;
5482 - /** If set to non-zero, indicates that any display scaling
5483 - * should disregard the aspect ratio of the frame region being
5488 - /** Indicates how the image should be scaled to fit the
5489 - * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates
5490 - * that the image should fill the screen by potentially
5491 - * cropping the frames. Setting \code mode \endcode to \code
5492 - * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the
5493 - * source region should be displayed and black bars added if
5496 - u32 mode; /* enum mmal_parameter_displaymode */
5498 - /** If non-zero, defines the width of a source pixel relative
5499 - * to \code pixel_y \endcode. If zero, then pixels default to
5504 - /** If non-zero, defines the height of a source pixel relative
5505 - * to \code pixel_x \endcode. If zero, then pixels default to
5510 - /** Sets the relative depth of the images, with greater values
5511 - * being in front of smaller values.
5515 - /** Set to non-zero to ensure copy protection is used on
5518 - s32 copyprotect_required;
5520 - /** Level of opacity of the layer, where zero is fully
5521 - * transparent and 255 is fully opaque.
5526 -#define MMAL_MAX_IMAGEFX_PARAMETERS 5
5528 -struct mmal_parameter_imagefx_parameters {
5529 - enum mmal_parameter_imagefx effect;
5530 - u32 num_effect_params;
5531 - u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS];
5534 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4
5535 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2
5536 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16
5538 -struct mmal_parameter_camera_info_camera_t {
5543 - u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN];
5546 -enum mmal_parameter_camera_info_flash_type_t {
5547 - /* Make values explicit to ensure they match values in config ini */
5548 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0,
5549 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1,
5550 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2,
5551 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF
5554 -struct mmal_parameter_camera_info_flash_t {
5555 - enum mmal_parameter_camera_info_flash_type_t flash_type;
5558 -struct mmal_parameter_camera_info_t {
5561 - struct mmal_parameter_camera_info_camera_t
5562 - cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS];
5563 - struct mmal_parameter_camera_info_flash_t
5564 - flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES];
5568 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
5571 -/* SPDX-License-Identifier: GPL-2.0 */
5573 - * Broadcom BM2835 V4L2 driver
5575 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5577 - * Authors: Vincent Sanders @ Collabora
5578 - * Dave Stevenson @ Broadcom
5579 - * (now dave.stevenson@raspberrypi.org)
5580 - * Simon Mellor @ Broadcom
5581 - * Luke Diamand @ Broadcom
5583 - * MMAL interface to VCHIQ message passing
5586 -#ifndef MMAL_VCHIQ_H
5587 -#define MMAL_VCHIQ_H
5589 -#include "mmal-msg-format.h"
5591 -#define MAX_PORT_COUNT 4
5593 -/* Maximum size of the format extradata. */
5594 -#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
5596 -struct vchiq_mmal_instance;
5598 -enum vchiq_mmal_es_type {
5599 - MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
5600 - MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
5601 - MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
5602 - MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
5603 - MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
5606 -struct vchiq_mmal_port_buffer {
5607 - unsigned int num; /* number of buffers */
5608 - u32 size; /* size of buffers */
5609 - u32 alignment; /* alignment of buffers */
5612 -struct vchiq_mmal_port;
5614 -typedef void (*vchiq_mmal_buffer_cb)(
5615 - struct vchiq_mmal_instance *instance,
5616 - struct vchiq_mmal_port *port,
5617 - int status, struct mmal_buffer *buffer,
5618 - unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
5620 -struct vchiq_mmal_port {
5623 - u32 type; /* port type, cached to use on port info set */
5624 - u32 index; /* port index, cached to use on port info set */
5626 - /* component port belongs to, allows simple deref */
5627 - struct vchiq_mmal_component *component;
5629 - struct vchiq_mmal_port *connected; /* port conencted to */
5632 - struct vchiq_mmal_port_buffer minimum_buffer;
5633 - struct vchiq_mmal_port_buffer recommended_buffer;
5634 - struct vchiq_mmal_port_buffer current_buffer;
5636 - /* stream format */
5637 - struct mmal_es_format_local format;
5638 - /* elementary stream format */
5639 - union mmal_es_specific_format es;
5641 - /* data buffers to fill */
5642 - struct list_head buffers;
5643 - /* lock to serialise adding and removing buffers from list */
5646 - /* Count of buffers the VPU has yet to return */
5647 - atomic_t buffers_with_vpu;
5648 - /* callback on buffer completion */
5649 - vchiq_mmal_buffer_cb buffer_cb;
5650 - /* callback context */
5654 -struct vchiq_mmal_component {
5656 - u32 handle; /* VideoCore handle for component */
5657 - u32 inputs; /* Number of input ports */
5658 - u32 outputs; /* Number of output ports */
5659 - u32 clocks; /* Number of clock ports */
5660 - struct vchiq_mmal_port control; /* control port */
5661 - struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
5662 - struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
5663 - struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
5666 -int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
5667 -int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
5669 -/* Initialise a mmal component and its ports
5672 -int vchiq_mmal_component_init(
5673 - struct vchiq_mmal_instance *instance,
5675 - struct vchiq_mmal_component **component_out);
5677 -int vchiq_mmal_component_finalise(
5678 - struct vchiq_mmal_instance *instance,
5679 - struct vchiq_mmal_component *component);
5681 -int vchiq_mmal_component_enable(
5682 - struct vchiq_mmal_instance *instance,
5683 - struct vchiq_mmal_component *component);
5685 -int vchiq_mmal_component_disable(
5686 - struct vchiq_mmal_instance *instance,
5687 - struct vchiq_mmal_component *component);
5689 -/* enable a mmal port
5691 - * enables a port and if a buffer callback provided enque buffer
5692 - * headers as appropriate for the port.
5694 -int vchiq_mmal_port_enable(
5695 - struct vchiq_mmal_instance *instance,
5696 - struct vchiq_mmal_port *port,
5697 - vchiq_mmal_buffer_cb buffer_cb);
5701 - * disable a port will dequeue any pending buffers
5703 -int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
5704 - struct vchiq_mmal_port *port);
5706 -int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
5707 - struct vchiq_mmal_port *port,
5712 -int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
5713 - struct vchiq_mmal_port *port,
5718 -int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
5719 - struct vchiq_mmal_port *port);
5721 -int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
5722 - struct vchiq_mmal_port *src,
5723 - struct vchiq_mmal_port *dst);
5725 -int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
5729 -int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
5730 - struct vchiq_mmal_port *port,
5731 - struct mmal_buffer *buf);
5733 -int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
5734 - struct mmal_buffer *buf);
5735 -int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
5736 -#endif /* MMAL_VCHIQ_H */
5738 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
5740 +/* SPDX-License-Identifier: GPL-2.0 */
5742 + * Broadcom BM2835 V4L2 driver
5744 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5746 + * Authors: Vincent Sanders @ Collabora
5747 + * Dave Stevenson @ Broadcom
5748 + * (now dave.stevenson@raspberrypi.org)
5749 + * Simon Mellor @ Broadcom
5750 + * Luke Diamand @ Broadcom
5755 +#ifndef MMAL_COMMON_H
5756 +#define MMAL_COMMON_H
5758 +#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))
5759 +#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
5761 +/** Special value signalling that time is not known */
5762 +#define MMAL_TIME_UNKNOWN BIT_ULL(63)
5764 +struct mmal_msg_context;
5766 +/* mapping between v4l and mmal video modes */
5769 + u32 fourcc; /* v4l2 format id */
5770 + int flags; /* v4l2 flags field */
5773 + u32 mmal_component; /* MMAL component index to be used to encode */
5774 + u32 ybbp; /* depth of first Y plane for planar formats */
5775 + bool remove_padding; /* Does the GPU have to remove padding,
5776 + * or can we do hide padding via bytesperline.
5780 +/* buffer for one video frame */
5781 +struct mmal_buffer {
5782 + /* v4l buffer data -- must be first */
5783 + struct vb2_v4l2_buffer vb;
5785 + /* list of buffers available */
5786 + struct list_head list;
5788 + void *buffer; /* buffer pointer */
5789 + unsigned long buffer_size; /* size of allocated buffer */
5791 + struct mmal_msg_context *msg_context;
5795 +struct mmal_colourfx {
5802 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-encodings.h
5804 +/* SPDX-License-Identifier: GPL-2.0 */
5806 + * Broadcom BM2835 V4L2 driver
5808 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5810 + * Authors: Vincent Sanders @ Collabora
5811 + * Dave Stevenson @ Broadcom
5812 + * (now dave.stevenson@raspberrypi.org)
5813 + * Simon Mellor @ Broadcom
5814 + * Luke Diamand @ Broadcom
5816 +#ifndef MMAL_ENCODINGS_H
5817 +#define MMAL_ENCODINGS_H
5819 +#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4')
5820 +#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3')
5821 +#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V')
5822 +#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V')
5823 +#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V')
5824 +#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3')
5825 +#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2')
5826 +#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1')
5827 +#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1')
5828 +#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ')
5829 +#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ')
5830 +#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ')
5831 +#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O')
5832 +#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K')
5833 +#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G')
5835 +#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G')
5836 +#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ')
5837 +#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ')
5838 +#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ')
5839 +#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ')
5840 +#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ')
5842 +#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0')
5843 +#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0')
5844 +#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2')
5845 +#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2')
5846 +#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2')
5847 +#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V')
5848 +#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U')
5849 +#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y')
5850 +#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y')
5851 +#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2')
5852 +#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1')
5853 +#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B')
5854 +#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A')
5855 +#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R')
5856 +#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A')
5857 +#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2')
5858 +#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3')
5859 +#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4')
5860 +#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2')
5861 +#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3')
5862 +#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4')
5864 +/** SAND Video (YUVUV128) format, native format understood by VideoCore.
5865 + * This format is *not* opaque - if requested you will receive full frames
5866 + * of YUV_UV video.
5868 +#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D')
5870 +/** VideoCore opaque image format, image handles are returned to
5871 + * the host but not the actual image data.
5873 +#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V')
5875 +/** An EGL image handle
5877 +#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I')
5881 +/** \name Pre-defined audio encodings */
5883 +#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U')
5884 +#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u')
5885 +#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S')
5886 +#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's')
5887 +#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F')
5888 +#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f')
5890 +/* Pre-defined H264 encoding variants */
5892 +/** ISO 14496-10 Annex B byte stream format */
5893 +#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0
5894 +/** ISO 14496-15 AVC stream format */
5895 +#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1')
5896 +/** Implicitly delineated NAL units without emulation prevention */
5897 +#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ')
5899 +/** \defgroup MmalColorSpace List of pre-defined video color spaces
5900 + * This defines a list of common color spaces. This list isn't exhaustive and
5901 + * is only provided as a convenience to avoid clients having to use FourCC
5902 + * codes directly. However components are allowed to define and use their own
5907 +/** Unknown color space */
5908 +#define MMAL_COLOR_SPACE_UNKNOWN 0
5909 +/** ITU-R BT.601-5 [SDTV] */
5910 +#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1')
5911 +/** ITU-R BT.709-3 [HDTV] */
5912 +#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9')
5914 +#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I')
5915 +/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
5916 +#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C')
5917 +/** Society of Motion Picture and Television Engineers 240M (1999) */
5918 +#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0')
5919 +/** ITU-R BT.470-2 System M */
5920 +#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M')
5921 +/** ITU-R BT.470-2 System BG */
5922 +#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G')
5923 +/** JPEG JFIF, but with 16..255 luma */
5924 +#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6')
5925 +/* @} MmalColorSpace List */
5927 +#endif /* MMAL_ENCODINGS_H */
5929 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-common.h
5931 +/* SPDX-License-Identifier: GPL-2.0 */
5933 + * Broadcom BM2835 V4L2 driver
5935 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5937 + * Authors: Vincent Sanders @ Collabora
5938 + * Dave Stevenson @ Broadcom
5939 + * (now dave.stevenson@raspberrypi.org)
5940 + * Simon Mellor @ Broadcom
5941 + * Luke Diamand @ Broadcom
5944 +#ifndef MMAL_MSG_COMMON_H
5945 +#define MMAL_MSG_COMMON_H
5947 +enum mmal_msg_status {
5948 + MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */
5949 + MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */
5950 + MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */
5951 + MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */
5952 + MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */
5953 + MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */
5954 + MMAL_MSG_STATUS_ENXIO, /**< No such device or address */
5955 + MMAL_MSG_STATUS_EIO, /**< I/O error */
5956 + MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */
5957 + MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */
5958 + MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */
5959 + MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */
5960 + MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */
5961 + MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */
5962 + MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */
5963 + MMAL_MSG_STATUS_EFAULT, /**< Bad address */
5967 + s32 x; /**< x coordinate (from left) */
5968 + s32 y; /**< y coordinate (from top) */
5969 + s32 width; /**< width */
5970 + s32 height; /**< height */
5973 +struct mmal_rational {
5974 + s32 num; /**< Numerator */
5975 + s32 den; /**< Denominator */
5978 +#endif /* MMAL_MSG_COMMON_H */
5980 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-format.h
5982 +/* SPDX-License-Identifier: GPL-2.0 */
5984 + * Broadcom BM2835 V4L2 driver
5986 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5988 + * Authors: Vincent Sanders @ Collabora
5989 + * Dave Stevenson @ Broadcom
5990 + * (now dave.stevenson@raspberrypi.org)
5991 + * Simon Mellor @ Broadcom
5992 + * Luke Diamand @ Broadcom
5995 +#ifndef MMAL_MSG_FORMAT_H
5996 +#define MMAL_MSG_FORMAT_H
5998 +#include "mmal-msg-common.h"
6000 +/* MMAL_ES_FORMAT_T */
6002 +struct mmal_audio_format {
6003 + u32 channels; /* Number of audio channels */
6004 + u32 sample_rate; /* Sample rate */
6006 + u32 bits_per_sample; /* Bits per sample */
6007 + u32 block_align; /* Size of a block of data */
6010 +struct mmal_video_format {
6011 + u32 width; /* Width of frame in pixels */
6012 + u32 height; /* Height of frame in rows of pixels */
6013 + struct mmal_rect crop; /* Visible region of the frame */
6014 + struct mmal_rational frame_rate; /* Frame rate */
6015 + struct mmal_rational par; /* Pixel aspect ratio */
6018 + * FourCC specifying the color space of the video stream. See the
6019 + * MmalColorSpace "pre-defined color spaces" for some examples.
6024 +struct mmal_subpicture_format {
6029 +union mmal_es_specific_format {
6030 + struct mmal_audio_format audio;
6031 + struct mmal_video_format video;
6032 + struct mmal_subpicture_format subpicture;
6035 +/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */
6036 +struct mmal_es_format_local {
6037 + u32 type; /* enum mmal_es_type */
6039 + u32 encoding; /* FourCC specifying encoding of the elementary
6042 + u32 encoding_variant; /* FourCC specifying the specific
6043 + * encoding variant of the elementary
6047 + union mmal_es_specific_format *es; /* Type specific
6048 + * information for the
6049 + * elementary stream
6052 + u32 bitrate; /* Bitrate in bits per second */
6053 + u32 flags; /* Flags describing properties of the elementary
6057 + u32 extradata_size; /* Size of the codec specific data */
6058 + u8 *extradata; /* Codec specific data */
6061 +/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */
6062 +struct mmal_es_format {
6063 + u32 type; /* enum mmal_es_type */
6065 + u32 encoding; /* FourCC specifying encoding of the elementary
6068 + u32 encoding_variant; /* FourCC specifying the specific
6069 + * encoding variant of the elementary
6073 + u32 es; /* Type specific
6074 + * information for the
6075 + * elementary stream
6078 + u32 bitrate; /* Bitrate in bits per second */
6079 + u32 flags; /* Flags describing properties of the elementary
6083 + u32 extradata_size; /* Size of the codec specific data */
6084 + u32 extradata; /* Codec specific data */
6087 +#endif /* MMAL_MSG_FORMAT_H */
6089 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-port.h
6091 +/* SPDX-License-Identifier: GPL-2.0 */
6093 + * Broadcom BM2835 V4L2 driver
6095 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6097 + * Authors: Vincent Sanders @ Collabora
6098 + * Dave Stevenson @ Broadcom
6099 + * (now dave.stevenson@raspberrypi.org)
6100 + * Simon Mellor @ Broadcom
6101 + * Luke Diamand @ Broadcom
6104 +/* MMAL_PORT_TYPE_T */
6105 +enum mmal_port_type {
6106 + MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */
6107 + MMAL_PORT_TYPE_CONTROL, /* Control port */
6108 + MMAL_PORT_TYPE_INPUT, /* Input port */
6109 + MMAL_PORT_TYPE_OUTPUT, /* Output port */
6110 + MMAL_PORT_TYPE_CLOCK, /* Clock port */
6113 +/* The port is pass-through and doesn't need buffer headers allocated */
6114 +#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01
6116 + *The port wants to allocate the buffer payloads.
6117 + * This signals a preference that payload allocation should be done
6118 + * on this port for efficiency reasons.
6120 +#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02
6122 + * The port supports format change events.
6123 + * This applies to input ports and is used to let the client know
6124 + * whether the port supports being reconfigured via a format
6125 + * change event (i.e. without having to disable the port).
6127 +#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04
6130 + * mmal port structure (MMAL_PORT_T)
6132 + * most elements are informational only, the pointer values for
6133 + * interogation messages are generally provided as additional
6134 + * structures within the message. When used to set values only the
6135 + * buffer_num, buffer_size and userdata parameters are writable.
6138 + u32 priv; /* Private member used by the framework */
6139 + u32 name; /* Port name. Used for debugging purposes (RO) */
6141 + u32 type; /* Type of the port (RO) enum mmal_port_type */
6142 + u16 index; /* Index of the port in its type list (RO) */
6143 + u16 index_all; /* Index of the port in the list of all ports (RO) */
6145 + u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */
6146 + u32 format; /* Format of the elementary stream */
6148 + u32 buffer_num_min; /* Minimum number of buffers the port
6149 + * requires (RO). This is set by the
6153 + u32 buffer_size_min; /* Minimum size of buffers the port
6154 + * requires (RO). This is set by the
6158 + u32 buffer_alignment_min;/* Minimum alignment requirement for
6159 + * the buffers (RO). A value of
6160 + * zero means no special alignment
6161 + * requirements. This is set by the
6165 + u32 buffer_num_recommended; /* Number of buffers the port
6166 + * recommends for optimal
6167 + * performance (RO). A value of
6168 + * zero means no special
6169 + * recommendation. This is set
6170 + * by the component.
6173 + u32 buffer_size_recommended; /* Size of buffers the port
6174 + * recommends for optimal
6175 + * performance (RO). A value of
6176 + * zero means no special
6177 + * recommendation. This is set
6178 + * by the component.
6181 + u32 buffer_num; /* Actual number of buffers the port will use.
6182 + * This is set by the client.
6185 + u32 buffer_size; /* Actual maximum size of the buffers that
6186 + * will be sent to the port. This is set by
6190 + u32 component; /* Component this port belongs to (Read Only) */
6192 + u32 userdata; /* Field reserved for use by the client */
6194 + u32 capabilities; /* Flags describing the capabilities of a
6195 + * port (RO). Bitwise combination of \ref
6196 + * portcapabilities "Port capabilities"
6201 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h
6203 +/* SPDX-License-Identifier: GPL-2.0 */
6205 + * Broadcom BM2835 V4L2 driver
6207 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6209 + * Authors: Vincent Sanders @ Collabora
6210 + * Dave Stevenson @ Broadcom
6211 + * (now dave.stevenson@raspberrypi.org)
6212 + * Simon Mellor @ Broadcom
6213 + * Luke Diamand @ Broadcom
6217 + * all the data structures which serialise the MMAL protocol. note
6218 + * these are directly mapped onto the recived message data.
6220 + * BEWARE: They seem to *assume* pointers are u32 and that there is no
6221 + * structure padding!
6223 + * NOTE: this implementation uses kernel types to ensure sizes. Rather
6224 + * than assigning values to enums to force their size the
6225 + * implementation uses fixed size types and not the enums (though the
6226 + * comments have the actual enum type
6231 +#define VC_MMAL_VER 15
6232 +#define VC_MMAL_MIN_VER 10
6233 +#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal")
6235 +/* max total message size is 512 bytes */
6236 +#define MMAL_MSG_MAX_SIZE 512
6237 +/* with six 32bit header elements max payload is therefore 488 bytes */
6238 +#define MMAL_MSG_MAX_PAYLOAD 488
6240 +#include "mmal-msg-common.h"
6241 +#include "mmal-msg-format.h"
6242 +#include "mmal-msg-port.h"
6244 +enum mmal_msg_type {
6245 + MMAL_MSG_TYPE_QUIT = 1,
6246 + MMAL_MSG_TYPE_SERVICE_CLOSED,
6247 + MMAL_MSG_TYPE_GET_VERSION,
6248 + MMAL_MSG_TYPE_COMPONENT_CREATE,
6249 + MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */
6250 + MMAL_MSG_TYPE_COMPONENT_ENABLE,
6251 + MMAL_MSG_TYPE_COMPONENT_DISABLE,
6252 + MMAL_MSG_TYPE_PORT_INFO_GET,
6253 + MMAL_MSG_TYPE_PORT_INFO_SET,
6254 + MMAL_MSG_TYPE_PORT_ACTION, /* 10 */
6255 + MMAL_MSG_TYPE_BUFFER_FROM_HOST,
6256 + MMAL_MSG_TYPE_BUFFER_TO_HOST,
6257 + MMAL_MSG_TYPE_GET_STATS,
6258 + MMAL_MSG_TYPE_PORT_PARAMETER_SET,
6259 + MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */
6260 + MMAL_MSG_TYPE_EVENT_TO_HOST,
6261 + MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
6262 + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
6263 + MMAL_MSG_TYPE_CONSUME_MEM,
6264 + MMAL_MSG_TYPE_LMK, /* 20 */
6265 + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
6266 + MMAL_MSG_TYPE_DRM_GET_LHS32,
6267 + MMAL_MSG_TYPE_DRM_GET_TIME,
6268 + MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
6269 + MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */
6270 + MMAL_MSG_TYPE_HOST_LOG,
6271 + MMAL_MSG_TYPE_MSG_LAST
6274 +/* port action request messages differ depending on the action type */
6275 +enum mmal_msg_port_action_type {
6276 + MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */
6277 + MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
6278 + MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
6279 + MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
6280 + MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */
6281 + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */
6282 + MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/
6285 +struct mmal_msg_header {
6287 + u32 type; /* enum mmal_msg_type */
6289 + /* Opaque handle to the control service */
6290 + u32 control_service;
6292 + u32 context; /* a u32 per message context */
6293 + u32 status; /* The status of the vchiq operation */
6297 +/* Send from VC to host to report version */
6298 +struct mmal_msg_version {
6305 +/* request to VC to create component */
6306 +struct mmal_msg_component_create {
6307 + u32 client_component; /* component context */
6309 + u32 pid; /* For debug */
6312 +/* reply from VC to component creation request */
6313 +struct mmal_msg_component_create_reply {
6314 + u32 status; /* enum mmal_msg_status - how does this differ to
6315 + * the one in the header?
6317 + u32 component_handle; /* VideoCore handle for component */
6318 + u32 input_num; /* Number of input ports */
6319 + u32 output_num; /* Number of output ports */
6320 + u32 clock_num; /* Number of clock ports */
6323 +/* request to VC to destroy a component */
6324 +struct mmal_msg_component_destroy {
6325 + u32 component_handle;
6328 +struct mmal_msg_component_destroy_reply {
6329 + u32 status; /* The component destruction status */
6332 +/* request and reply to VC to enable a component */
6333 +struct mmal_msg_component_enable {
6334 + u32 component_handle;
6337 +struct mmal_msg_component_enable_reply {
6338 + u32 status; /* The component enable status */
6341 +/* request and reply to VC to disable a component */
6342 +struct mmal_msg_component_disable {
6343 + u32 component_handle;
6346 +struct mmal_msg_component_disable_reply {
6347 + u32 status; /* The component disable status */
6350 +/* request to VC to get port information */
6351 +struct mmal_msg_port_info_get {
6352 + u32 component_handle; /* component handle port is associated with */
6353 + u32 port_type; /* enum mmal_msg_port_type */
6354 + u32 index; /* port index to query */
6357 +/* reply from VC to get port info request */
6358 +struct mmal_msg_port_info_get_reply {
6359 + u32 status; /* enum mmal_msg_status */
6360 + u32 component_handle; /* component handle port is associated with */
6361 + u32 port_type; /* enum mmal_msg_port_type */
6362 + u32 port_index; /* port indexed in query */
6363 + s32 found; /* unused */
6364 + u32 port_handle; /* Handle to use for this port */
6365 + struct mmal_port port;
6366 + struct mmal_es_format format; /* elementary stream format */
6367 + union mmal_es_specific_format es; /* es type specific data */
6368 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */
6371 +/* request to VC to set port information */
6372 +struct mmal_msg_port_info_set {
6373 + u32 component_handle;
6374 + u32 port_type; /* enum mmal_msg_port_type */
6375 + u32 port_index; /* port indexed in query */
6376 + struct mmal_port port;
6377 + struct mmal_es_format format;
6378 + union mmal_es_specific_format es;
6379 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
6382 +/* reply from VC to port info set request */
6383 +struct mmal_msg_port_info_set_reply {
6385 + u32 component_handle; /* component handle port is associated with */
6386 + u32 port_type; /* enum mmal_msg_port_type */
6387 + u32 index; /* port indexed in query */
6388 + s32 found; /* unused */
6389 + u32 port_handle; /* Handle to use for this port */
6390 + struct mmal_port port;
6391 + struct mmal_es_format format;
6392 + union mmal_es_specific_format es;
6393 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
6396 +/* port action requests that take a mmal_port as a parameter */
6397 +struct mmal_msg_port_action_port {
6398 + u32 component_handle;
6400 + u32 action; /* enum mmal_msg_port_action_type */
6401 + struct mmal_port port;
6404 +/* port action requests that take handles as a parameter */
6405 +struct mmal_msg_port_action_handle {
6406 + u32 component_handle;
6408 + u32 action; /* enum mmal_msg_port_action_type */
6409 + u32 connect_component_handle;
6410 + u32 connect_port_handle;
6413 +struct mmal_msg_port_action_reply {
6414 + u32 status; /* The port action operation status */
6417 +/* MMAL buffer transfer */
6419 +/* Size of space reserved in a buffer message for short messages. */
6420 +#define MMAL_VC_SHORT_DATA 128
6422 +/* Signals that the current payload is the end of the stream of data */
6423 +#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0)
6424 +/* Signals that the start of the current payload starts a frame */
6425 +#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1)
6426 +/* Signals that the end of the current payload ends a frame */
6427 +#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2)
6428 +/* Signals that the current payload contains only complete frames (>1) */
6429 +#define MMAL_BUFFER_HEADER_FLAG_FRAME \
6430 + (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \
6431 + MMAL_BUFFER_HEADER_FLAG_FRAME_END)
6432 +/* Signals that the current payload is a keyframe (i.e. self decodable) */
6433 +#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3)
6435 + * Signals a discontinuity in the stream of data (e.g. after a seek).
6436 + * Can be used for instance by a decoder to reset its state
6438 +#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4)
6440 + * Signals a buffer containing some kind of config data for the component
6441 + * (e.g. codec config data)
6443 +#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5)
6444 +/* Signals an encrypted payload */
6445 +#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6)
6446 +/* Signals a buffer containing side information */
6447 +#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7)
6449 + * Signals a buffer which is the snapshot/postview image from a stills
6452 +#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8)
6453 +/* Signals a buffer which contains data known to be corrupted */
6454 +#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9)
6455 +/* Signals that a buffer failed to be transmitted */
6456 +#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10)
6458 +struct mmal_driver_buffer {
6460 + u32 component_handle;
6462 + u32 client_context;
6465 +/* buffer header */
6466 +struct mmal_buffer_header {
6467 + u32 next; /* next header */
6468 + u32 priv; /* framework private data */
6481 +struct mmal_buffer_header_type_specific {
6492 +struct mmal_msg_buffer_from_host {
6494 + *The front 32 bytes of the buffer header are copied
6495 + * back to us in the reply to allow for context. This
6496 + * area is used to store two mmal_driver_buffer structures to
6497 + * allow for multiple concurrent service users.
6499 + /* control data */
6500 + struct mmal_driver_buffer drvbuf;
6502 + /* referenced control data for passthrough buffer management */
6503 + struct mmal_driver_buffer drvbuf_ref;
6504 + struct mmal_buffer_header buffer_header; /* buffer header itself */
6505 + struct mmal_buffer_header_type_specific buffer_header_type_specific;
6507 + s32 has_reference;
6509 + /* allows short data to be xfered in control message */
6510 + u32 payload_in_message;
6511 + u8 short_data[MMAL_VC_SHORT_DATA];
6514 +/* port parameter setting */
6516 +#define MMAL_WORKER_PORT_PARAMETER_SPACE 96
6518 +struct mmal_msg_port_parameter_set {
6519 + u32 component_handle; /* component */
6520 + u32 port_handle; /* port */
6521 + u32 id; /* Parameter ID */
6522 + u32 size; /* Parameter size */
6523 + uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
6526 +struct mmal_msg_port_parameter_set_reply {
6527 + u32 status; /* enum mmal_msg_status todo: how does this
6528 + * differ to the one in the header?
6532 +/* port parameter getting */
6534 +struct mmal_msg_port_parameter_get {
6535 + u32 component_handle; /* component */
6536 + u32 port_handle; /* port */
6537 + u32 id; /* Parameter ID */
6538 + u32 size; /* Parameter size */
6541 +struct mmal_msg_port_parameter_get_reply {
6542 + u32 status; /* Status of mmal_port_parameter_get call */
6543 + u32 id; /* Parameter ID */
6544 + u32 size; /* Parameter size */
6545 + uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
6548 +/* event messages */
6549 +#define MMAL_WORKER_EVENT_SPACE 256
6551 +struct mmal_msg_event_to_host {
6552 + u32 client_component; /* component context */
6559 + u8 data[MMAL_WORKER_EVENT_SPACE];
6560 + u32 delayed_buffer;
6563 +/* all mmal messages are serialised through this structure */
6566 + struct mmal_msg_header h;
6569 + struct mmal_msg_version version;
6571 + struct mmal_msg_component_create component_create;
6572 + struct mmal_msg_component_create_reply component_create_reply;
6574 + struct mmal_msg_component_destroy component_destroy;
6575 + struct mmal_msg_component_destroy_reply component_destroy_reply;
6577 + struct mmal_msg_component_enable component_enable;
6578 + struct mmal_msg_component_enable_reply component_enable_reply;
6580 + struct mmal_msg_component_disable component_disable;
6581 + struct mmal_msg_component_disable_reply component_disable_reply;
6583 + struct mmal_msg_port_info_get port_info_get;
6584 + struct mmal_msg_port_info_get_reply port_info_get_reply;
6586 + struct mmal_msg_port_info_set port_info_set;
6587 + struct mmal_msg_port_info_set_reply port_info_set_reply;
6589 + struct mmal_msg_port_action_port port_action_port;
6590 + struct mmal_msg_port_action_handle port_action_handle;
6591 + struct mmal_msg_port_action_reply port_action_reply;
6593 + struct mmal_msg_buffer_from_host buffer_from_host;
6595 + struct mmal_msg_port_parameter_set port_parameter_set;
6596 + struct mmal_msg_port_parameter_set_reply
6597 + port_parameter_set_reply;
6598 + struct mmal_msg_port_parameter_get
6599 + port_parameter_get;
6600 + struct mmal_msg_port_parameter_get_reply
6601 + port_parameter_get_reply;
6603 + struct mmal_msg_event_to_host event_to_host;
6605 + u8 payload[MMAL_MSG_MAX_PAYLOAD];
6610 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h
6612 +/* SPDX-License-Identifier: GPL-2.0 */
6614 + * Broadcom BM2835 V4L2 driver
6616 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6618 + * Authors: Vincent Sanders @ Collabora
6619 + * Dave Stevenson @ Broadcom
6620 + * (now dave.stevenson@raspberrypi.org)
6621 + * Simon Mellor @ Broadcom
6622 + * Luke Diamand @ Broadcom
6625 +/* common parameters */
6627 +/** @name Parameter groups
6628 + * Parameters are divided into groups, and then allocated sequentially within
6629 + * a group using an enum.
6633 +#ifndef MMAL_PARAMETERS_H
6634 +#define MMAL_PARAMETERS_H
6636 +/** Common parameter ID group, used with many types of component. */
6637 +#define MMAL_PARAMETER_GROUP_COMMON (0 << 16)
6638 +/** Camera-specific parameter ID group. */
6639 +#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16)
6640 +/** Video-specific parameter ID group. */
6641 +#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16)
6642 +/** Audio-specific parameter ID group. */
6643 +#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16)
6644 +/** Clock-specific parameter ID group. */
6645 +#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16)
6646 +/** Miracast-specific parameter ID group. */
6647 +#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16)
6649 +/* Common parameters */
6650 +enum mmal_parameter_common_type {
6651 + /**< Never a valid parameter ID */
6652 + MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON,
6654 + /**< MMAL_PARAMETER_ENCODING_T */
6655 + MMAL_PARAMETER_SUPPORTED_ENCODINGS,
6656 + /**< MMAL_PARAMETER_URI_T */
6657 + MMAL_PARAMETER_URI,
6658 + /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */
6659 + MMAL_PARAMETER_CHANGE_EVENT_REQUEST,
6660 + /** MMAL_PARAMETER_BOOLEAN_T */
6661 + MMAL_PARAMETER_ZERO_COPY,
6662 + /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */
6663 + MMAL_PARAMETER_BUFFER_REQUIREMENTS,
6664 + /**< MMAL_PARAMETER_STATISTICS_T */
6665 + MMAL_PARAMETER_STATISTICS,
6666 + /**< MMAL_PARAMETER_CORE_STATISTICS_T */
6667 + MMAL_PARAMETER_CORE_STATISTICS,
6668 + /**< MMAL_PARAMETER_MEM_USAGE_T */
6669 + MMAL_PARAMETER_MEM_USAGE,
6670 + /**< MMAL_PARAMETER_UINT32_T */
6671 + MMAL_PARAMETER_BUFFER_FLAG_FILTER,
6672 + /**< MMAL_PARAMETER_SEEK_T */
6673 + MMAL_PARAMETER_SEEK,
6674 + /**< MMAL_PARAMETER_BOOLEAN_T */
6675 + MMAL_PARAMETER_POWERMON_ENABLE,
6676 + /**< MMAL_PARAMETER_LOGGING_T */
6677 + MMAL_PARAMETER_LOGGING,
6678 + /**< MMAL_PARAMETER_UINT64_T */
6679 + MMAL_PARAMETER_SYSTEM_TIME,
6680 + /**< MMAL_PARAMETER_BOOLEAN_T */
6681 + MMAL_PARAMETER_NO_IMAGE_PADDING,
6684 +/* camera parameters */
6686 +enum mmal_parameter_camera_type {
6688 + /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */
6689 + MMAL_PARAMETER_THUMBNAIL_CONFIGURATION =
6690 + MMAL_PARAMETER_GROUP_CAMERA,
6692 + MMAL_PARAMETER_CAPTURE_QUALITY,
6693 + /**< @ref MMAL_PARAMETER_INT32_T */
6694 + MMAL_PARAMETER_ROTATION,
6695 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6696 + MMAL_PARAMETER_EXIF_DISABLE,
6697 + /**< @ref MMAL_PARAMETER_EXIF_T */
6698 + MMAL_PARAMETER_EXIF,
6699 + /**< @ref MMAL_PARAM_AWBMODE_T */
6700 + MMAL_PARAMETER_AWB_MODE,
6701 + /**< @ref MMAL_PARAMETER_IMAGEFX_T */
6702 + MMAL_PARAMETER_IMAGE_EFFECT,
6703 + /**< @ref MMAL_PARAMETER_COLOURFX_T */
6704 + MMAL_PARAMETER_COLOUR_EFFECT,
6705 + /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */
6706 + MMAL_PARAMETER_FLICKER_AVOID,
6707 + /**< @ref MMAL_PARAMETER_FLASH_T */
6708 + MMAL_PARAMETER_FLASH,
6709 + /**< @ref MMAL_PARAMETER_REDEYE_T */
6710 + MMAL_PARAMETER_REDEYE,
6711 + /**< @ref MMAL_PARAMETER_FOCUS_T */
6712 + MMAL_PARAMETER_FOCUS,
6714 + MMAL_PARAMETER_FOCAL_LENGTHS,
6715 + /**< @ref MMAL_PARAMETER_INT32_T */
6716 + MMAL_PARAMETER_EXPOSURE_COMP,
6717 + /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */
6718 + MMAL_PARAMETER_ZOOM,
6719 + /**< @ref MMAL_PARAMETER_MIRROR_T */
6720 + MMAL_PARAMETER_MIRROR,
6723 + /**< @ref MMAL_PARAMETER_UINT32_T */
6724 + MMAL_PARAMETER_CAMERA_NUM,
6725 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6726 + MMAL_PARAMETER_CAPTURE,
6727 + /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */
6728 + MMAL_PARAMETER_EXPOSURE_MODE,
6729 + /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */
6730 + MMAL_PARAMETER_EXP_METERING_MODE,
6731 + /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */
6732 + MMAL_PARAMETER_FOCUS_STATUS,
6733 + /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */
6734 + MMAL_PARAMETER_CAMERA_CONFIG,
6735 + /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */
6736 + MMAL_PARAMETER_CAPTURE_STATUS,
6737 + /**< @ref MMAL_PARAMETER_FACE_TRACK_T */
6738 + MMAL_PARAMETER_FACE_TRACK,
6739 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6740 + MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS,
6741 + /**< @ref MMAL_PARAMETER_UINT32_T */
6742 + MMAL_PARAMETER_JPEG_Q_FACTOR,
6743 + /**< @ref MMAL_PARAMETER_FRAME_RATE_T */
6744 + MMAL_PARAMETER_FRAME_RATE,
6745 + /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */
6746 + MMAL_PARAMETER_USE_STC,
6747 + /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */
6748 + MMAL_PARAMETER_CAMERA_INFO,
6749 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6750 + MMAL_PARAMETER_VIDEO_STABILISATION,
6751 + /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */
6752 + MMAL_PARAMETER_FACE_TRACK_RESULTS,
6753 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6754 + MMAL_PARAMETER_ENABLE_RAW_CAPTURE,
6757 + /**< @ref MMAL_PARAMETER_URI_T */
6758 + MMAL_PARAMETER_DPF_FILE,
6759 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6760 + MMAL_PARAMETER_ENABLE_DPF_FILE,
6761 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6762 + MMAL_PARAMETER_DPF_FAIL_IS_FATAL,
6763 + /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */
6764 + MMAL_PARAMETER_CAPTURE_MODE,
6765 + /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */
6766 + MMAL_PARAMETER_FOCUS_REGIONS,
6767 + /**< @ref MMAL_PARAMETER_INPUT_CROP_T */
6768 + MMAL_PARAMETER_INPUT_CROP,
6769 + /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */
6770 + MMAL_PARAMETER_SENSOR_INFORMATION,
6771 + /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */
6772 + MMAL_PARAMETER_FLASH_SELECT,
6773 + /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */
6774 + MMAL_PARAMETER_FIELD_OF_VIEW,
6775 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6776 + MMAL_PARAMETER_HIGH_DYNAMIC_RANGE,
6777 + /**< @ref MMAL_PARAMETER_DRC_T */
6778 + MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION,
6779 + /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */
6780 + MMAL_PARAMETER_ALGORITHM_CONTROL,
6781 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6782 + MMAL_PARAMETER_SHARPNESS,
6783 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6784 + MMAL_PARAMETER_CONTRAST,
6785 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6786 + MMAL_PARAMETER_BRIGHTNESS,
6787 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6788 + MMAL_PARAMETER_SATURATION,
6791 + /**< @ref MMAL_PARAMETER_UINT32_T */
6792 + MMAL_PARAMETER_ISO,
6793 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6794 + MMAL_PARAMETER_ANTISHAKE,
6795 + /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */
6796 + MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,
6797 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
6798 + MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
6799 + /** @ref MMAL_PARAMETER_UINT32_T */
6800 + MMAL_PARAMETER_CAMERA_MIN_ISO,
6801 + /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */
6802 + MMAL_PARAMETER_CAMERA_USE_CASE,
6803 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6804 + MMAL_PARAMETER_CAPTURE_STATS_PASS,
6805 + /** @ref MMAL_PARAMETER_UINT32_T */
6806 + MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG,
6807 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
6808 + MMAL_PARAMETER_ENABLE_REGISTER_FILE,
6809 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
6810 + MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
6811 + /** @ref MMAL_PARAMETER_CONFIGFILE_T */
6812 + MMAL_PARAMETER_CONFIGFILE_REGISTERS,
6813 + /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */
6814 + MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS,
6815 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6816 + MMAL_PARAMETER_JPEG_ATTACH_LOG,
6817 + /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */
6818 + MMAL_PARAMETER_ZERO_SHUTTER_LAG,
6819 + /**< @ref MMAL_PARAMETER_FPS_RANGE_T */
6820 + MMAL_PARAMETER_FPS_RANGE,
6821 + /**< @ref MMAL_PARAMETER_INT32_T */
6822 + MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP,
6825 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6826 + MMAL_PARAMETER_SW_SHARPEN_DISABLE,
6827 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6828 + MMAL_PARAMETER_FLASH_REQUIRED,
6829 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6830 + MMAL_PARAMETER_SW_SATURATION_DISABLE,
6831 + /**< Takes a @ref MMAL_PARAMETER_UINT32_T */
6832 + MMAL_PARAMETER_SHUTTER_SPEED,
6833 + /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */
6834 + MMAL_PARAMETER_CUSTOM_AWB_GAINS,
6837 +struct mmal_parameter_rational {
6838 + s32 num; /**< Numerator */
6839 + s32 den; /**< Denominator */
6842 +enum mmal_parameter_camera_config_timestamp_mode {
6843 + MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */
6844 + MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value
6845 + * for the frame timestamp
6847 + MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp
6848 + * but subtract the
6849 + * timestamp of the first
6850 + * frame sent to give a
6851 + * zero based timestamp.
6855 +struct mmal_parameter_fps_range {
6856 + /**< Low end of the permitted framerate range */
6857 + struct mmal_parameter_rational fps_low;
6858 + /**< High end of the permitted framerate range */
6859 + struct mmal_parameter_rational fps_high;
6862 +/* camera configuration parameter */
6863 +struct mmal_parameter_camera_config {
6864 + /* Parameters for setting up the image pools */
6865 + u32 max_stills_w; /* Max size of stills capture */
6867 + u32 stills_yuv422; /* Allow YUV422 stills capture */
6868 + u32 one_shot_stills; /* Continuous or one shot stills captures. */
6870 + u32 max_preview_video_w; /* Max size of the preview or video
6873 + u32 max_preview_video_h;
6874 + u32 num_preview_video_frames;
6876 + /** Sets the height of the circular buffer for stills capture. */
6877 + u32 stills_capture_circular_buffer_height;
6879 + /** Allows preview/encode to resume as fast as possible after the stills
6880 + * input frame has been received, and then processes the still frame in
6881 + * the background whilst preview/encode has resumed.
6882 + * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE.
6884 + u32 fast_preview_resume;
6886 + /** Selects algorithm for timestamping frames if
6887 + * there is no clock component connected.
6888 + * enum mmal_parameter_camera_config_timestamp_mode
6890 + s32 use_stc_timestamp;
6893 +enum mmal_parameter_exposuremode {
6894 + MMAL_PARAM_EXPOSUREMODE_OFF,
6895 + MMAL_PARAM_EXPOSUREMODE_AUTO,
6896 + MMAL_PARAM_EXPOSUREMODE_NIGHT,
6897 + MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
6898 + MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
6899 + MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
6900 + MMAL_PARAM_EXPOSUREMODE_SPORTS,
6901 + MMAL_PARAM_EXPOSUREMODE_SNOW,
6902 + MMAL_PARAM_EXPOSUREMODE_BEACH,
6903 + MMAL_PARAM_EXPOSUREMODE_VERYLONG,
6904 + MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
6905 + MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
6906 + MMAL_PARAM_EXPOSUREMODE_FIREWORKS,
6909 +enum mmal_parameter_exposuremeteringmode {
6910 + MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
6911 + MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
6912 + MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
6913 + MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX,
6916 +enum mmal_parameter_awbmode {
6917 + MMAL_PARAM_AWBMODE_OFF,
6918 + MMAL_PARAM_AWBMODE_AUTO,
6919 + MMAL_PARAM_AWBMODE_SUNLIGHT,
6920 + MMAL_PARAM_AWBMODE_CLOUDY,
6921 + MMAL_PARAM_AWBMODE_SHADE,
6922 + MMAL_PARAM_AWBMODE_TUNGSTEN,
6923 + MMAL_PARAM_AWBMODE_FLUORESCENT,
6924 + MMAL_PARAM_AWBMODE_INCANDESCENT,
6925 + MMAL_PARAM_AWBMODE_FLASH,
6926 + MMAL_PARAM_AWBMODE_HORIZON,
6929 +enum mmal_parameter_imagefx {
6930 + MMAL_PARAM_IMAGEFX_NONE,
6931 + MMAL_PARAM_IMAGEFX_NEGATIVE,
6932 + MMAL_PARAM_IMAGEFX_SOLARIZE,
6933 + MMAL_PARAM_IMAGEFX_POSTERIZE,
6934 + MMAL_PARAM_IMAGEFX_WHITEBOARD,
6935 + MMAL_PARAM_IMAGEFX_BLACKBOARD,
6936 + MMAL_PARAM_IMAGEFX_SKETCH,
6937 + MMAL_PARAM_IMAGEFX_DENOISE,
6938 + MMAL_PARAM_IMAGEFX_EMBOSS,
6939 + MMAL_PARAM_IMAGEFX_OILPAINT,
6940 + MMAL_PARAM_IMAGEFX_HATCH,
6941 + MMAL_PARAM_IMAGEFX_GPEN,
6942 + MMAL_PARAM_IMAGEFX_PASTEL,
6943 + MMAL_PARAM_IMAGEFX_WATERCOLOUR,
6944 + MMAL_PARAM_IMAGEFX_FILM,
6945 + MMAL_PARAM_IMAGEFX_BLUR,
6946 + MMAL_PARAM_IMAGEFX_SATURATION,
6947 + MMAL_PARAM_IMAGEFX_COLOURSWAP,
6948 + MMAL_PARAM_IMAGEFX_WASHEDOUT,
6949 + MMAL_PARAM_IMAGEFX_POSTERISE,
6950 + MMAL_PARAM_IMAGEFX_COLOURPOINT,
6951 + MMAL_PARAM_IMAGEFX_COLOURBALANCE,
6952 + MMAL_PARAM_IMAGEFX_CARTOON,
6955 +enum MMAL_PARAM_FLICKERAVOID_T {
6956 + MMAL_PARAM_FLICKERAVOID_OFF,
6957 + MMAL_PARAM_FLICKERAVOID_AUTO,
6958 + MMAL_PARAM_FLICKERAVOID_50HZ,
6959 + MMAL_PARAM_FLICKERAVOID_60HZ,
6960 + MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF
6963 +struct mmal_parameter_awbgains {
6964 + struct mmal_parameter_rational r_gain; /**< Red gain */
6965 + struct mmal_parameter_rational b_gain; /**< Blue gain */
6968 +/** Manner of video rate control */
6969 +enum mmal_parameter_rate_control_mode {
6970 + MMAL_VIDEO_RATECONTROL_DEFAULT,
6971 + MMAL_VIDEO_RATECONTROL_VARIABLE,
6972 + MMAL_VIDEO_RATECONTROL_CONSTANT,
6973 + MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES,
6974 + MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES
6977 +enum mmal_video_profile {
6978 + MMAL_VIDEO_PROFILE_H263_BASELINE,
6979 + MMAL_VIDEO_PROFILE_H263_H320CODING,
6980 + MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE,
6981 + MMAL_VIDEO_PROFILE_H263_ISWV2,
6982 + MMAL_VIDEO_PROFILE_H263_ISWV3,
6983 + MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION,
6984 + MMAL_VIDEO_PROFILE_H263_INTERNET,
6985 + MMAL_VIDEO_PROFILE_H263_INTERLACE,
6986 + MMAL_VIDEO_PROFILE_H263_HIGHLATENCY,
6987 + MMAL_VIDEO_PROFILE_MP4V_SIMPLE,
6988 + MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE,
6989 + MMAL_VIDEO_PROFILE_MP4V_CORE,
6990 + MMAL_VIDEO_PROFILE_MP4V_MAIN,
6991 + MMAL_VIDEO_PROFILE_MP4V_NBIT,
6992 + MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE,
6993 + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE,
6994 + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA,
6995 + MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED,
6996 + MMAL_VIDEO_PROFILE_MP4V_HYBRID,
6997 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME,
6998 + MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE,
6999 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING,
7000 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE,
7001 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE,
7002 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE,
7003 + MMAL_VIDEO_PROFILE_H264_BASELINE,
7004 + MMAL_VIDEO_PROFILE_H264_MAIN,
7005 + MMAL_VIDEO_PROFILE_H264_EXTENDED,
7006 + MMAL_VIDEO_PROFILE_H264_HIGH,
7007 + MMAL_VIDEO_PROFILE_H264_HIGH10,
7008 + MMAL_VIDEO_PROFILE_H264_HIGH422,
7009 + MMAL_VIDEO_PROFILE_H264_HIGH444,
7010 + MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE,
7011 + MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF
7014 +enum mmal_video_level {
7015 + MMAL_VIDEO_LEVEL_H263_10,
7016 + MMAL_VIDEO_LEVEL_H263_20,
7017 + MMAL_VIDEO_LEVEL_H263_30,
7018 + MMAL_VIDEO_LEVEL_H263_40,
7019 + MMAL_VIDEO_LEVEL_H263_45,
7020 + MMAL_VIDEO_LEVEL_H263_50,
7021 + MMAL_VIDEO_LEVEL_H263_60,
7022 + MMAL_VIDEO_LEVEL_H263_70,
7023 + MMAL_VIDEO_LEVEL_MP4V_0,
7024 + MMAL_VIDEO_LEVEL_MP4V_0b,
7025 + MMAL_VIDEO_LEVEL_MP4V_1,
7026 + MMAL_VIDEO_LEVEL_MP4V_2,
7027 + MMAL_VIDEO_LEVEL_MP4V_3,
7028 + MMAL_VIDEO_LEVEL_MP4V_4,
7029 + MMAL_VIDEO_LEVEL_MP4V_4a,
7030 + MMAL_VIDEO_LEVEL_MP4V_5,
7031 + MMAL_VIDEO_LEVEL_MP4V_6,
7032 + MMAL_VIDEO_LEVEL_H264_1,
7033 + MMAL_VIDEO_LEVEL_H264_1b,
7034 + MMAL_VIDEO_LEVEL_H264_11,
7035 + MMAL_VIDEO_LEVEL_H264_12,
7036 + MMAL_VIDEO_LEVEL_H264_13,
7037 + MMAL_VIDEO_LEVEL_H264_2,
7038 + MMAL_VIDEO_LEVEL_H264_21,
7039 + MMAL_VIDEO_LEVEL_H264_22,
7040 + MMAL_VIDEO_LEVEL_H264_3,
7041 + MMAL_VIDEO_LEVEL_H264_31,
7042 + MMAL_VIDEO_LEVEL_H264_32,
7043 + MMAL_VIDEO_LEVEL_H264_4,
7044 + MMAL_VIDEO_LEVEL_H264_41,
7045 + MMAL_VIDEO_LEVEL_H264_42,
7046 + MMAL_VIDEO_LEVEL_H264_5,
7047 + MMAL_VIDEO_LEVEL_H264_51,
7048 + MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF
7051 +struct mmal_parameter_video_profile {
7052 + enum mmal_video_profile profile;
7053 + enum mmal_video_level level;
7056 +/* video parameters */
7058 +enum mmal_parameter_video_type {
7059 + /** @ref MMAL_DISPLAYREGION_T */
7060 + MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO,
7062 + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
7063 + MMAL_PARAMETER_SUPPORTED_PROFILES,
7065 + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
7066 + MMAL_PARAMETER_PROFILE,
7068 + /** @ref MMAL_PARAMETER_UINT32_T */
7069 + MMAL_PARAMETER_INTRAPERIOD,
7071 + /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */
7072 + MMAL_PARAMETER_RATECONTROL,
7074 + /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */
7075 + MMAL_PARAMETER_NALUNITFORMAT,
7077 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7078 + MMAL_PARAMETER_MINIMISE_FRAGMENTATION,
7080 + /** @ref MMAL_PARAMETER_UINT32_T.
7081 + * Setting the value to zero resets to the default (one slice per
7084 + MMAL_PARAMETER_MB_ROWS_PER_SLICE,
7086 + /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */
7087 + MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION,
7089 + /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */
7090 + MMAL_PARAMETER_VIDEO_EEDE_ENABLE,
7092 + /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */
7093 + MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE,
7095 + /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */
7096 + MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME,
7097 + /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */
7098 + MMAL_PARAMETER_VIDEO_INTRA_REFRESH,
7100 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7101 + MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT,
7103 + /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */
7104 + MMAL_PARAMETER_VIDEO_BIT_RATE,
7106 + /** @ref MMAL_PARAMETER_FRAME_RATE_T */
7107 + MMAL_PARAMETER_VIDEO_FRAME_RATE,
7109 + /** @ref MMAL_PARAMETER_UINT32_T. */
7110 + MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
7112 + /** @ref MMAL_PARAMETER_UINT32_T. */
7113 + MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
7115 + /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */
7116 + MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL,
7118 + MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */
7119 + /** @ref MMAL_PARAMETER_UINT32_T.
7120 + * Changing this parameter from the default can reduce frame rate
7121 + * because image buffers need to be re-pitched.
7123 + MMAL_PARAMETER_VIDEO_ALIGN_HORIZ,
7125 + /** @ref MMAL_PARAMETER_UINT32_T.
7126 + * Changing this parameter from the default can reduce frame rate
7127 + * because image buffers need to be re-pitched.
7129 + MMAL_PARAMETER_VIDEO_ALIGN_VERT,
7131 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7132 + MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES,
7134 + /** @ref MMAL_PARAMETER_UINT32_T. */
7135 + MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT,
7137 + /**< @ref MMAL_PARAMETER_UINT32_T. */
7138 + MMAL_PARAMETER_VIDEO_ENCODE_QP_P,
7140 + /**< @ref MMAL_PARAMETER_UINT32_T. */
7141 + MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT,
7143 + /** @ref MMAL_PARAMETER_UINT32_T */
7144 + MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS,
7146 + /** @ref MMAL_PARAMETER_UINT32_T. */
7147 + MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE,
7149 + /* H264 specific parameters */
7151 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7152 + MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC,
7154 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7155 + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY,
7157 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7158 + MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS,
7160 + /** @ref MMAL_PARAMETER_UINT32_T. */
7161 + MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC,
7163 + /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */
7164 + MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE,
7166 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7167 + MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN,
7169 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7170 + MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP,
7172 + /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */
7173 + MMAL_PARAMETER_VIDEO_DRM_INIT_INFO,
7175 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7176 + MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO,
7178 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7179 + MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT,
7181 + /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */
7182 + MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
7184 + /** @ref MMAL_PARAMETER_BYTES_T */
7185 + MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
7187 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
7188 + MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
7190 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
7191 + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
7193 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
7194 + MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
7197 +/** Valid mirror modes */
7198 +enum mmal_parameter_mirror {
7199 + MMAL_PARAM_MIRROR_NONE,
7200 + MMAL_PARAM_MIRROR_VERTICAL,
7201 + MMAL_PARAM_MIRROR_HORIZONTAL,
7202 + MMAL_PARAM_MIRROR_BOTH,
7205 +enum mmal_parameter_displaytransform {
7206 + MMAL_DISPLAY_ROT0 = 0,
7207 + MMAL_DISPLAY_MIRROR_ROT0 = 1,
7208 + MMAL_DISPLAY_MIRROR_ROT180 = 2,
7209 + MMAL_DISPLAY_ROT180 = 3,
7210 + MMAL_DISPLAY_MIRROR_ROT90 = 4,
7211 + MMAL_DISPLAY_ROT270 = 5,
7212 + MMAL_DISPLAY_ROT90 = 6,
7213 + MMAL_DISPLAY_MIRROR_ROT270 = 7,
7216 +enum mmal_parameter_displaymode {
7217 + MMAL_DISPLAY_MODE_FILL = 0,
7218 + MMAL_DISPLAY_MODE_LETTERBOX = 1,
7221 +enum mmal_parameter_displayset {
7222 + MMAL_DISPLAY_SET_NONE = 0,
7223 + MMAL_DISPLAY_SET_NUM = 1,
7224 + MMAL_DISPLAY_SET_FULLSCREEN = 2,
7225 + MMAL_DISPLAY_SET_TRANSFORM = 4,
7226 + MMAL_DISPLAY_SET_DEST_RECT = 8,
7227 + MMAL_DISPLAY_SET_SRC_RECT = 0x10,
7228 + MMAL_DISPLAY_SET_MODE = 0x20,
7229 + MMAL_DISPLAY_SET_PIXEL = 0x40,
7230 + MMAL_DISPLAY_SET_NOASPECT = 0x80,
7231 + MMAL_DISPLAY_SET_LAYER = 0x100,
7232 + MMAL_DISPLAY_SET_COPYPROTECT = 0x200,
7233 + MMAL_DISPLAY_SET_ALPHA = 0x400,
7236 +/* rectangle, used lots so it gets its own struct */
7237 +struct vchiq_mmal_rect {
7244 +struct mmal_parameter_displayregion {
7245 + /** Bitfield that indicates which fields are set and should be
7246 + * used. All other fields will maintain their current value.
7247 + * \ref MMAL_DISPLAYSET_T defines the bits that can be
7252 + /** Describes the display output device, with 0 typically
7253 + * being a directly connected LCD display. The actual values
7254 + * will depend on the hardware. Code using hard-wired numbers
7255 + * (e.g. 2) is certain to fail.
7259 + /** Indicates that we are using the full device screen area,
7260 + * rather than a window of the display. If zero, then
7261 + * dest_rect is used to specify a region of the display to
7266 + /** Indicates any rotation or flipping used to map frames onto
7267 + * the natural display orientation.
7269 + u32 transform; /* enum mmal_parameter_displaytransform */
7271 + /** Where to display the frame within the screen, if
7272 + * fullscreen is zero.
7274 + struct vchiq_mmal_rect dest_rect;
7276 + /** Indicates which area of the frame to display. If all
7277 + * values are zero, the whole frame will be used.
7279 + struct vchiq_mmal_rect src_rect;
7281 + /** If set to non-zero, indicates that any display scaling
7282 + * should disregard the aspect ratio of the frame region being
7287 + /** Indicates how the image should be scaled to fit the
7288 + * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates
7289 + * that the image should fill the screen by potentially
7290 + * cropping the frames. Setting \code mode \endcode to \code
7291 + * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the
7292 + * source region should be displayed and black bars added if
7295 + u32 mode; /* enum mmal_parameter_displaymode */
7297 + /** If non-zero, defines the width of a source pixel relative
7298 + * to \code pixel_y \endcode. If zero, then pixels default to
7303 + /** If non-zero, defines the height of a source pixel relative
7304 + * to \code pixel_x \endcode. If zero, then pixels default to
7309 + /** Sets the relative depth of the images, with greater values
7310 + * being in front of smaller values.
7314 + /** Set to non-zero to ensure copy protection is used on
7317 + s32 copyprotect_required;
7319 + /** Level of opacity of the layer, where zero is fully
7320 + * transparent and 255 is fully opaque.
7325 +#define MMAL_MAX_IMAGEFX_PARAMETERS 5
7327 +struct mmal_parameter_imagefx_parameters {
7328 + enum mmal_parameter_imagefx effect;
7329 + u32 num_effect_params;
7330 + u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS];
7333 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4
7334 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2
7335 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16
7337 +struct mmal_parameter_camera_info_camera_t {
7342 + u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN];
7345 +enum mmal_parameter_camera_info_flash_type_t {
7346 + /* Make values explicit to ensure they match values in config ini */
7347 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0,
7348 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1,
7349 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2,
7350 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF
7353 +struct mmal_parameter_camera_info_flash_t {
7354 + enum mmal_parameter_camera_info_flash_type_t flash_type;
7357 +struct mmal_parameter_camera_info_t {
7360 + struct mmal_parameter_camera_info_camera_t
7361 + cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS];
7362 + struct mmal_parameter_camera_info_flash_t
7363 + flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES];
7368 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
7370 +/* SPDX-License-Identifier: GPL-2.0 */
7372 + * Broadcom BM2835 V4L2 driver
7374 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
7376 + * Authors: Vincent Sanders @ Collabora
7377 + * Dave Stevenson @ Broadcom
7378 + * (now dave.stevenson@raspberrypi.org)
7379 + * Simon Mellor @ Broadcom
7380 + * Luke Diamand @ Broadcom
7382 + * MMAL interface to VCHIQ message passing
7385 +#ifndef MMAL_VCHIQ_H
7386 +#define MMAL_VCHIQ_H
7388 +#include "mmal-msg-format.h"
7390 +#define MAX_PORT_COUNT 4
7392 +/* Maximum size of the format extradata. */
7393 +#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
7395 +struct vchiq_mmal_instance;
7397 +enum vchiq_mmal_es_type {
7398 + MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
7399 + MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
7400 + MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
7401 + MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
7402 + MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
7405 +struct vchiq_mmal_port_buffer {
7406 + unsigned int num; /* number of buffers */
7407 + u32 size; /* size of buffers */
7408 + u32 alignment; /* alignment of buffers */
7411 +struct vchiq_mmal_port;
7413 +typedef void (*vchiq_mmal_buffer_cb)(
7414 + struct vchiq_mmal_instance *instance,
7415 + struct vchiq_mmal_port *port,
7416 + int status, struct mmal_buffer *buffer,
7417 + unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
7419 +struct vchiq_mmal_port {
7422 + u32 type; /* port type, cached to use on port info set */
7423 + u32 index; /* port index, cached to use on port info set */
7425 + /* component port belongs to, allows simple deref */
7426 + struct vchiq_mmal_component *component;
7428 + struct vchiq_mmal_port *connected; /* port conencted to */
7431 + struct vchiq_mmal_port_buffer minimum_buffer;
7432 + struct vchiq_mmal_port_buffer recommended_buffer;
7433 + struct vchiq_mmal_port_buffer current_buffer;
7435 + /* stream format */
7436 + struct mmal_es_format_local format;
7437 + /* elementary stream format */
7438 + union mmal_es_specific_format es;
7440 + /* data buffers to fill */
7441 + struct list_head buffers;
7442 + /* lock to serialise adding and removing buffers from list */
7445 + /* Count of buffers the VPU has yet to return */
7446 + atomic_t buffers_with_vpu;
7447 + /* callback on buffer completion */
7448 + vchiq_mmal_buffer_cb buffer_cb;
7449 + /* callback context */
7453 +struct vchiq_mmal_component {
7455 + u32 handle; /* VideoCore handle for component */
7456 + u32 inputs; /* Number of input ports */
7457 + u32 outputs; /* Number of output ports */
7458 + u32 clocks; /* Number of clock ports */
7459 + struct vchiq_mmal_port control; /* control port */
7460 + struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
7461 + struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
7462 + struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
7465 +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
7466 +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
7468 +/* Initialise a mmal component and its ports
7471 +int vchiq_mmal_component_init(
7472 + struct vchiq_mmal_instance *instance,
7474 + struct vchiq_mmal_component **component_out);
7476 +int vchiq_mmal_component_finalise(
7477 + struct vchiq_mmal_instance *instance,
7478 + struct vchiq_mmal_component *component);
7480 +int vchiq_mmal_component_enable(
7481 + struct vchiq_mmal_instance *instance,
7482 + struct vchiq_mmal_component *component);
7484 +int vchiq_mmal_component_disable(
7485 + struct vchiq_mmal_instance *instance,
7486 + struct vchiq_mmal_component *component);
7488 +/* enable a mmal port
7490 + * enables a port and if a buffer callback provided enque buffer
7491 + * headers as appropriate for the port.
7493 +int vchiq_mmal_port_enable(
7494 + struct vchiq_mmal_instance *instance,
7495 + struct vchiq_mmal_port *port,
7496 + vchiq_mmal_buffer_cb buffer_cb);
7500 + * disable a port will dequeue any pending buffers
7502 +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
7503 + struct vchiq_mmal_port *port);
7505 +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
7506 + struct vchiq_mmal_port *port,
7511 +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
7512 + struct vchiq_mmal_port *port,
7517 +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
7518 + struct vchiq_mmal_port *port);
7520 +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
7521 + struct vchiq_mmal_port *src,
7522 + struct vchiq_mmal_port *dst);
7524 +int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
7528 +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
7529 + struct vchiq_mmal_port *port,
7530 + struct mmal_buffer *buf);
7532 +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
7533 + struct mmal_buffer *buf);
7534 +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
7535 +#endif /* MMAL_VCHIQ_H */