1 From abd417b71f4b157cb183cab26620d08c303ce805 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Mon, 24 Sep 2018 16:30:37 +0100
4 Subject: [PATCH 267/703] staging: vc04_services: Split vchiq-mmal into a
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 - spinlock_t context_map_lock;
284 - /* component to use next */
286 - struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
288 - /* ordered workqueue to process all bulk operations */
289 - struct workqueue_struct *bulk_wq;
292 -static struct mmal_msg_context *
293 -get_msg_context(struct vchiq_mmal_instance *instance)
295 - struct mmal_msg_context *msg_context;
298 - /* todo: should this be allocated from a pool to avoid kzalloc */
299 - msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
302 - return ERR_PTR(-ENOMEM);
304 - /* Create an ID that will be passed along with our message so
305 - * that when we service the VCHI reply, we can look up what
306 - * message is being replied to.
308 - spin_lock(&instance->context_map_lock);
309 - handle = idr_alloc(&instance->context_map, msg_context,
311 - spin_unlock(&instance->context_map_lock);
314 - kfree(msg_context);
315 - return ERR_PTR(handle);
318 - msg_context->instance = instance;
319 - msg_context->handle = handle;
321 - return msg_context;
324 -static struct mmal_msg_context *
325 -lookup_msg_context(struct vchiq_mmal_instance *instance, int handle)
327 - return idr_find(&instance->context_map, handle);
331 -release_msg_context(struct mmal_msg_context *msg_context)
333 - struct vchiq_mmal_instance *instance = msg_context->instance;
335 - spin_lock(&instance->context_map_lock);
336 - idr_remove(&instance->context_map, msg_context->handle);
337 - spin_unlock(&instance->context_map_lock);
338 - kfree(msg_context);
341 -/* deals with receipt of event to host message */
342 -static void event_to_host_cb(struct vchiq_mmal_instance *instance,
343 - struct mmal_msg *msg, u32 msg_len)
345 - pr_debug("unhandled event\n");
346 - pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n",
347 - msg->u.event_to_host.client_component,
348 - msg->u.event_to_host.port_type,
349 - msg->u.event_to_host.port_num,
350 - msg->u.event_to_host.cmd, msg->u.event_to_host.length);
353 -/* workqueue scheduled callback
355 - * we do this because it is important we do not call any other vchiq
356 - * sync calls from witin the message delivery thread
358 -static void buffer_work_cb(struct work_struct *work)
360 - struct mmal_msg_context *msg_context =
361 - container_of(work, struct mmal_msg_context, u.bulk.work);
363 - atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu);
365 - msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
366 - msg_context->u.bulk.port,
367 - msg_context->u.bulk.status,
368 - msg_context->u.bulk.buffer,
369 - msg_context->u.bulk.buffer_used,
370 - msg_context->u.bulk.mmal_flags,
371 - msg_context->u.bulk.dts,
372 - msg_context->u.bulk.pts);
375 -/* workqueue scheduled callback to handle receiving buffers
377 - * VCHI will allow up to 4 bulk receives to be scheduled before blocking.
378 - * If we block in the service_callback context then we can't process the
379 - * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked
380 - * vchi_bulk_queue_receive() call to complete.
382 -static void buffer_to_host_work_cb(struct work_struct *work)
384 - struct mmal_msg_context *msg_context =
385 - container_of(work, struct mmal_msg_context,
386 - u.bulk.buffer_to_host_work);
387 - struct vchiq_mmal_instance *instance = msg_context->instance;
388 - unsigned long len = msg_context->u.bulk.buffer_used;
392 - /* Dummy receive to ensure the buffers remain in order */
394 - /* queue the bulk submission */
395 - vchi_service_use(instance->handle);
396 - ret = vchi_bulk_queue_receive(instance->handle,
397 - msg_context->u.bulk.buffer->buffer,
398 - /* Actual receive needs to be a multiple
402 - VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE |
403 - VCHI_FLAGS_BLOCK_UNTIL_QUEUED,
406 - vchi_service_release(instance->handle);
409 - pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n",
410 - __func__, msg_context, ret);
413 -/* enqueue a bulk receive for a given message context */
414 -static int bulk_receive(struct vchiq_mmal_instance *instance,
415 - struct mmal_msg *msg,
416 - struct mmal_msg_context *msg_context)
418 - unsigned long rd_len;
420 - rd_len = msg->u.buffer_from_host.buffer_header.length;
422 - if (!msg_context->u.bulk.buffer) {
423 - pr_err("bulk.buffer not configured - error in buffer_from_host\n");
425 - /* todo: this is a serious error, we should never have
426 - * committed a buffer_to_host operation to the mmal
427 - * port without the buffer to back it up (underflow
428 - * handling) and there is no obvious way to deal with
429 - * this - how is the mmal servie going to react when
430 - * we fail to do the xfer and reschedule a buffer when
431 - * it arrives? perhaps a starved flag to indicate a
432 - * waiting bulk receive?
438 - /* ensure we do not overrun the available buffer */
439 - if (rd_len > msg_context->u.bulk.buffer->buffer_size) {
440 - rd_len = msg_context->u.bulk.buffer->buffer_size;
441 - pr_warn("short read as not enough receive buffer space\n");
442 - /* todo: is this the correct response, what happens to
443 - * the rest of the message data?
448 - msg_context->u.bulk.buffer_used = rd_len;
449 - msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts;
450 - msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts;
452 - queue_work(msg_context->instance->bulk_wq,
453 - &msg_context->u.bulk.buffer_to_host_work);
458 -/* data in message, memcpy from packet into output buffer */
459 -static int inline_receive(struct vchiq_mmal_instance *instance,
460 - struct mmal_msg *msg,
461 - struct mmal_msg_context *msg_context)
463 - memcpy(msg_context->u.bulk.buffer->buffer,
464 - msg->u.buffer_from_host.short_data,
465 - msg->u.buffer_from_host.payload_in_message);
467 - msg_context->u.bulk.buffer_used =
468 - msg->u.buffer_from_host.payload_in_message;
473 -/* queue the buffer availability with MMAL_MSG_TYPE_BUFFER_FROM_HOST */
475 -buffer_from_host(struct vchiq_mmal_instance *instance,
476 - struct vchiq_mmal_port *port, struct mmal_buffer *buf)
478 - struct mmal_msg_context *msg_context;
482 - if (!port->enabled)
485 - pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
488 - if (!buf->msg_context) {
489 - pr_err("%s: msg_context not allocated, buf %p\n", __func__,
493 - msg_context = buf->msg_context;
495 - /* store bulk message context for when data arrives */
496 - msg_context->u.bulk.instance = instance;
497 - msg_context->u.bulk.port = port;
498 - msg_context->u.bulk.buffer = buf;
499 - msg_context->u.bulk.buffer_used = 0;
501 - /* initialise work structure ready to schedule callback */
502 - INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb);
503 - INIT_WORK(&msg_context->u.bulk.buffer_to_host_work,
504 - buffer_to_host_work_cb);
506 - atomic_inc(&port->buffers_with_vpu);
508 - /* prep the buffer from host message */
509 - memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */
511 - m.h.type = MMAL_MSG_TYPE_BUFFER_FROM_HOST;
512 - m.h.magic = MMAL_MAGIC;
513 - m.h.context = msg_context->handle;
516 - /* drvbuf is our private data passed back */
517 - m.u.buffer_from_host.drvbuf.magic = MMAL_MAGIC;
518 - m.u.buffer_from_host.drvbuf.component_handle = port->component->handle;
519 - m.u.buffer_from_host.drvbuf.port_handle = port->handle;
520 - m.u.buffer_from_host.drvbuf.client_context = msg_context->handle;
522 - /* buffer header */
523 - m.u.buffer_from_host.buffer_header.cmd = 0;
524 - m.u.buffer_from_host.buffer_header.data =
525 - (u32)(unsigned long)buf->buffer;
526 - m.u.buffer_from_host.buffer_header.alloc_size = buf->buffer_size;
527 - m.u.buffer_from_host.buffer_header.length = 0; /* nothing used yet */
528 - m.u.buffer_from_host.buffer_header.offset = 0; /* no offset */
529 - m.u.buffer_from_host.buffer_header.flags = 0; /* no flags */
530 - m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN;
531 - m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN;
533 - /* clear buffer type sepecific data */
534 - memset(&m.u.buffer_from_host.buffer_header_type_specific, 0,
535 - sizeof(m.u.buffer_from_host.buffer_header_type_specific));
537 - /* no payload in message */
538 - m.u.buffer_from_host.payload_in_message = 0;
540 - vchi_service_use(instance->handle);
542 - ret = vchi_queue_kernel_message(instance->handle,
544 - sizeof(struct mmal_msg_header) +
545 - sizeof(m.u.buffer_from_host));
547 - vchi_service_release(instance->handle);
552 -/* deals with receipt of buffer to host message */
553 -static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
554 - struct mmal_msg *msg, u32 msg_len)
556 - struct mmal_msg_context *msg_context;
559 - pr_debug("%s: instance:%p msg:%p msg_len:%d\n",
560 - __func__, instance, msg, msg_len);
562 - if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) {
563 - handle = msg->u.buffer_from_host.drvbuf.client_context;
564 - msg_context = lookup_msg_context(instance, handle);
566 - if (!msg_context) {
567 - pr_err("drvbuf.client_context(%u) is invalid\n",
572 - pr_err("MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n");
576 - msg_context->u.bulk.mmal_flags =
577 - msg->u.buffer_from_host.buffer_header.flags;
579 - if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) {
580 - /* message reception had an error */
581 - pr_warn("error %d in reply\n", msg->h.status);
583 - msg_context->u.bulk.status = msg->h.status;
585 - } else if (msg->u.buffer_from_host.buffer_header.length == 0) {
587 - if (msg->u.buffer_from_host.buffer_header.flags &
588 - MMAL_BUFFER_HEADER_FLAG_EOS) {
589 - msg_context->u.bulk.status =
590 - bulk_receive(instance, msg, msg_context);
591 - if (msg_context->u.bulk.status == 0)
592 - return; /* successful bulk submission, bulk
593 - * completion will trigger callback
596 - /* do callback with empty buffer - not EOS though */
597 - msg_context->u.bulk.status = 0;
598 - msg_context->u.bulk.buffer_used = 0;
600 - } else if (msg->u.buffer_from_host.payload_in_message == 0) {
601 - /* data is not in message, queue a bulk receive */
602 - msg_context->u.bulk.status =
603 - bulk_receive(instance, msg, msg_context);
604 - if (msg_context->u.bulk.status == 0)
605 - return; /* successful bulk submission, bulk
606 - * completion will trigger callback
609 - /* failed to submit buffer, this will end badly */
610 - pr_err("error %d on bulk submission\n",
611 - msg_context->u.bulk.status);
613 - } else if (msg->u.buffer_from_host.payload_in_message <=
614 - MMAL_VC_SHORT_DATA) {
615 - /* data payload within message */
616 - msg_context->u.bulk.status = inline_receive(instance, msg,
619 - pr_err("message with invalid short payload\n");
622 - msg_context->u.bulk.status = -EINVAL;
623 - msg_context->u.bulk.buffer_used =
624 - msg->u.buffer_from_host.payload_in_message;
627 - /* schedule the port callback */
628 - schedule_work(&msg_context->u.bulk.work);
631 -static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
632 - struct mmal_msg_context *msg_context)
634 - msg_context->u.bulk.status = 0;
636 - /* schedule the port callback */
637 - schedule_work(&msg_context->u.bulk.work);
640 -static void bulk_abort_cb(struct vchiq_mmal_instance *instance,
641 - struct mmal_msg_context *msg_context)
643 - pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
645 - msg_context->u.bulk.status = -EINTR;
647 - schedule_work(&msg_context->u.bulk.work);
650 -/* incoming event service callback */
651 -static void service_callback(void *param,
652 - const VCHI_CALLBACK_REASON_T reason,
655 - struct vchiq_mmal_instance *instance = param;
658 - struct mmal_msg *msg;
659 - VCHI_HELD_MSG_T msg_handle;
660 - struct mmal_msg_context *msg_context;
663 - pr_err("Message callback passed NULL instance\n");
668 - case VCHI_CALLBACK_MSG_AVAILABLE:
669 - status = vchi_msg_hold(instance->handle, (void **)&msg,
670 - &msg_len, VCHI_FLAGS_NONE, &msg_handle);
672 - pr_err("Unable to dequeue a message (%d)\n", status);
676 - DBG_DUMP_MSG(msg, msg_len, "<<< reply message");
678 - /* handling is different for buffer messages */
679 - switch (msg->h.type) {
680 - case MMAL_MSG_TYPE_BUFFER_FROM_HOST:
681 - vchi_held_msg_release(&msg_handle);
684 - case MMAL_MSG_TYPE_EVENT_TO_HOST:
685 - event_to_host_cb(instance, msg, msg_len);
686 - vchi_held_msg_release(&msg_handle);
690 - case MMAL_MSG_TYPE_BUFFER_TO_HOST:
691 - buffer_to_host_cb(instance, msg, msg_len);
692 - vchi_held_msg_release(&msg_handle);
696 - /* messages dependent on header context to complete */
697 - if (!msg->h.context) {
698 - pr_err("received message context was null!\n");
699 - vchi_held_msg_release(&msg_handle);
703 - msg_context = lookup_msg_context(instance,
705 - if (!msg_context) {
706 - pr_err("received invalid message context %u!\n",
708 - vchi_held_msg_release(&msg_handle);
712 - /* fill in context values */
713 - msg_context->u.sync.msg_handle = msg_handle;
714 - msg_context->u.sync.msg = msg;
715 - msg_context->u.sync.msg_len = msg_len;
717 - /* todo: should this check (completion_done()
718 - * == 1) for no one waiting? or do we need a
719 - * flag to tell us the completion has been
720 - * interrupted so we can free the message and
721 - * its context. This probably also solves the
722 - * message arriving after interruption todo
726 - /* complete message so caller knows it happened */
727 - complete(&msg_context->u.sync.cmplt);
733 - case VCHI_CALLBACK_BULK_RECEIVED:
734 - bulk_receive_cb(instance, bulk_ctx);
737 - case VCHI_CALLBACK_BULK_RECEIVE_ABORTED:
738 - bulk_abort_cb(instance, bulk_ctx);
741 - case VCHI_CALLBACK_SERVICE_CLOSED:
742 - /* TODO: consider if this requires action if received when
743 - * driver is not explicitly closing the service
748 - pr_err("Received unhandled message reason %d\n", reason);
753 -static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
754 - struct mmal_msg *msg,
755 - unsigned int payload_len,
756 - struct mmal_msg **msg_out,
757 - VCHI_HELD_MSG_T *msg_handle_out)
759 - struct mmal_msg_context *msg_context;
761 - unsigned long timeout;
763 - /* payload size must not cause message to exceed max size */
765 - (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) {
766 - pr_err("payload length %d exceeds max:%d\n", payload_len,
767 - (int)(MMAL_MSG_MAX_SIZE -
768 - sizeof(struct mmal_msg_header)));
772 - msg_context = get_msg_context(instance);
773 - if (IS_ERR(msg_context))
774 - return PTR_ERR(msg_context);
776 - init_completion(&msg_context->u.sync.cmplt);
778 - msg->h.magic = MMAL_MAGIC;
779 - msg->h.context = msg_context->handle;
782 - DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len),
783 - ">>> sync message");
785 - vchi_service_use(instance->handle);
787 - ret = vchi_queue_kernel_message(instance->handle,
789 - sizeof(struct mmal_msg_header) +
792 - vchi_service_release(instance->handle);
795 - pr_err("error %d queuing message\n", ret);
796 - release_msg_context(msg_context);
800 - timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt,
802 - if (timeout == 0) {
803 - pr_err("timed out waiting for sync completion\n");
805 - /* todo: what happens if the message arrives after aborting */
806 - release_msg_context(msg_context);
810 - *msg_out = msg_context->u.sync.msg;
811 - *msg_handle_out = msg_context->u.sync.msg_handle;
812 - release_msg_context(msg_context);
817 -static void dump_port_info(struct vchiq_mmal_port *port)
819 - pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled);
821 - pr_debug("buffer minimum num:%d size:%d align:%d\n",
822 - port->minimum_buffer.num,
823 - port->minimum_buffer.size, port->minimum_buffer.alignment);
825 - pr_debug("buffer recommended num:%d size:%d align:%d\n",
826 - port->recommended_buffer.num,
827 - port->recommended_buffer.size,
828 - port->recommended_buffer.alignment);
830 - pr_debug("buffer current values num:%d size:%d align:%d\n",
831 - port->current_buffer.num,
832 - port->current_buffer.size, port->current_buffer.alignment);
834 - pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n",
836 - port->format.encoding, port->format.encoding_variant);
838 - pr_debug(" bitrate:%d flags:0x%x\n",
839 - port->format.bitrate, port->format.flags);
841 - if (port->format.type == MMAL_ES_TYPE_VIDEO) {
843 - ("es video format: width:%d height:%d colourspace:0x%x\n",
844 - port->es.video.width, port->es.video.height,
845 - port->es.video.color_space);
847 - pr_debug(" : crop xywh %d,%d,%d,%d\n",
848 - port->es.video.crop.x,
849 - port->es.video.crop.y,
850 - port->es.video.crop.width, port->es.video.crop.height);
851 - pr_debug(" : framerate %d/%d aspect %d/%d\n",
852 - port->es.video.frame_rate.num,
853 - port->es.video.frame_rate.den,
854 - port->es.video.par.num, port->es.video.par.den);
858 -static void port_to_mmal_msg(struct vchiq_mmal_port *port, struct mmal_port *p)
860 - /* todo do readonly fields need setting at all? */
861 - p->type = port->type;
862 - p->index = port->index;
864 - p->is_enabled = port->enabled;
865 - p->buffer_num_min = port->minimum_buffer.num;
866 - p->buffer_size_min = port->minimum_buffer.size;
867 - p->buffer_alignment_min = port->minimum_buffer.alignment;
868 - p->buffer_num_recommended = port->recommended_buffer.num;
869 - p->buffer_size_recommended = port->recommended_buffer.size;
871 - /* only three writable fields in a port */
872 - p->buffer_num = port->current_buffer.num;
873 - p->buffer_size = port->current_buffer.size;
874 - p->userdata = (u32)(unsigned long)port;
877 -static int port_info_set(struct vchiq_mmal_instance *instance,
878 - struct vchiq_mmal_port *port)
882 - struct mmal_msg *rmsg;
883 - VCHI_HELD_MSG_T rmsg_handle;
885 - pr_debug("setting port info port %p\n", port);
888 - dump_port_info(port);
890 - m.h.type = MMAL_MSG_TYPE_PORT_INFO_SET;
892 - m.u.port_info_set.component_handle = port->component->handle;
893 - m.u.port_info_set.port_type = port->type;
894 - m.u.port_info_set.port_index = port->index;
896 - port_to_mmal_msg(port, &m.u.port_info_set.port);
898 - /* elementary stream format setup */
899 - m.u.port_info_set.format.type = port->format.type;
900 - m.u.port_info_set.format.encoding = port->format.encoding;
901 - m.u.port_info_set.format.encoding_variant =
902 - port->format.encoding_variant;
903 - m.u.port_info_set.format.bitrate = port->format.bitrate;
904 - m.u.port_info_set.format.flags = port->format.flags;
906 - memcpy(&m.u.port_info_set.es, &port->es,
907 - sizeof(union mmal_es_specific_format));
909 - m.u.port_info_set.format.extradata_size = port->format.extradata_size;
910 - memcpy(&m.u.port_info_set.extradata, port->format.extradata,
911 - port->format.extradata_size);
913 - ret = send_synchronous_mmal_msg(instance, &m,
914 - sizeof(m.u.port_info_set),
915 - &rmsg, &rmsg_handle);
919 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_SET) {
920 - /* got an unexpected message type in reply */
925 - /* return operation status */
926 - ret = -rmsg->u.port_info_get_reply.status;
928 - pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret,
929 - port->component->handle, port->handle);
932 - vchi_held_msg_release(&rmsg_handle);
937 -/* use port info get message to retrieve port information */
938 -static int port_info_get(struct vchiq_mmal_instance *instance,
939 - struct vchiq_mmal_port *port)
943 - struct mmal_msg *rmsg;
944 - VCHI_HELD_MSG_T rmsg_handle;
946 - /* port info time */
947 - m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET;
948 - m.u.port_info_get.component_handle = port->component->handle;
949 - m.u.port_info_get.port_type = port->type;
950 - m.u.port_info_get.index = port->index;
952 - ret = send_synchronous_mmal_msg(instance, &m,
953 - sizeof(m.u.port_info_get),
954 - &rmsg, &rmsg_handle);
958 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_GET) {
959 - /* got an unexpected message type in reply */
964 - /* return operation status */
965 - ret = -rmsg->u.port_info_get_reply.status;
966 - if (ret != MMAL_MSG_STATUS_SUCCESS)
969 - if (rmsg->u.port_info_get_reply.port.is_enabled == 0)
970 - port->enabled = false;
972 - port->enabled = true;
974 - /* copy the values out of the message */
975 - port->handle = rmsg->u.port_info_get_reply.port_handle;
977 - /* port type and index cached to use on port info set because
978 - * it does not use a port handle
980 - port->type = rmsg->u.port_info_get_reply.port_type;
981 - port->index = rmsg->u.port_info_get_reply.port_index;
983 - port->minimum_buffer.num =
984 - rmsg->u.port_info_get_reply.port.buffer_num_min;
985 - port->minimum_buffer.size =
986 - rmsg->u.port_info_get_reply.port.buffer_size_min;
987 - port->minimum_buffer.alignment =
988 - rmsg->u.port_info_get_reply.port.buffer_alignment_min;
990 - port->recommended_buffer.alignment =
991 - rmsg->u.port_info_get_reply.port.buffer_alignment_min;
992 - port->recommended_buffer.num =
993 - rmsg->u.port_info_get_reply.port.buffer_num_recommended;
995 - port->current_buffer.num = rmsg->u.port_info_get_reply.port.buffer_num;
996 - port->current_buffer.size =
997 - rmsg->u.port_info_get_reply.port.buffer_size;
999 - /* stream format */
1000 - port->format.type = rmsg->u.port_info_get_reply.format.type;
1001 - port->format.encoding = rmsg->u.port_info_get_reply.format.encoding;
1002 - port->format.encoding_variant =
1003 - rmsg->u.port_info_get_reply.format.encoding_variant;
1004 - port->format.bitrate = rmsg->u.port_info_get_reply.format.bitrate;
1005 - port->format.flags = rmsg->u.port_info_get_reply.format.flags;
1007 - /* elementary stream format */
1009 - &rmsg->u.port_info_get_reply.es,
1010 - sizeof(union mmal_es_specific_format));
1011 - port->format.es = &port->es;
1013 - port->format.extradata_size =
1014 - rmsg->u.port_info_get_reply.format.extradata_size;
1015 - memcpy(port->format.extradata,
1016 - rmsg->u.port_info_get_reply.extradata,
1017 - port->format.extradata_size);
1019 - pr_debug("received port info\n");
1020 - dump_port_info(port);
1024 - pr_debug("%s:result:%d component:0x%x port:%d\n",
1025 - __func__, ret, port->component->handle, port->handle);
1027 - vchi_held_msg_release(&rmsg_handle);
1032 -/* create comonent on vc */
1033 -static int create_component(struct vchiq_mmal_instance *instance,
1034 - struct vchiq_mmal_component *component,
1038 - struct mmal_msg m;
1039 - struct mmal_msg *rmsg;
1040 - VCHI_HELD_MSG_T rmsg_handle;
1042 - /* build component create message */
1043 - m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE;
1044 - m.u.component_create.client_component = (u32)(unsigned long)component;
1045 - strncpy(m.u.component_create.name, name,
1046 - sizeof(m.u.component_create.name));
1048 - ret = send_synchronous_mmal_msg(instance, &m,
1049 - sizeof(m.u.component_create),
1050 - &rmsg, &rmsg_handle);
1054 - if (rmsg->h.type != m.h.type) {
1055 - /* got an unexpected message type in reply */
1060 - ret = -rmsg->u.component_create_reply.status;
1061 - if (ret != MMAL_MSG_STATUS_SUCCESS)
1064 - /* a valid component response received */
1065 - component->handle = rmsg->u.component_create_reply.component_handle;
1066 - component->inputs = rmsg->u.component_create_reply.input_num;
1067 - component->outputs = rmsg->u.component_create_reply.output_num;
1068 - component->clocks = rmsg->u.component_create_reply.clock_num;
1070 - pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n",
1071 - component->handle,
1072 - component->inputs, component->outputs, component->clocks);
1075 - vchi_held_msg_release(&rmsg_handle);
1080 -/* destroys a component on vc */
1081 -static int destroy_component(struct vchiq_mmal_instance *instance,
1082 - struct vchiq_mmal_component *component)
1085 - struct mmal_msg m;
1086 - struct mmal_msg *rmsg;
1087 - VCHI_HELD_MSG_T rmsg_handle;
1089 - m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY;
1090 - m.u.component_destroy.component_handle = component->handle;
1092 - ret = send_synchronous_mmal_msg(instance, &m,
1093 - sizeof(m.u.component_destroy),
1094 - &rmsg, &rmsg_handle);
1098 - if (rmsg->h.type != m.h.type) {
1099 - /* got an unexpected message type in reply */
1104 - ret = -rmsg->u.component_destroy_reply.status;
1108 - vchi_held_msg_release(&rmsg_handle);
1113 -/* enable a component on vc */
1114 -static int enable_component(struct vchiq_mmal_instance *instance,
1115 - struct vchiq_mmal_component *component)
1118 - struct mmal_msg m;
1119 - struct mmal_msg *rmsg;
1120 - VCHI_HELD_MSG_T rmsg_handle;
1122 - m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE;
1123 - m.u.component_enable.component_handle = component->handle;
1125 - ret = send_synchronous_mmal_msg(instance, &m,
1126 - sizeof(m.u.component_enable),
1127 - &rmsg, &rmsg_handle);
1131 - if (rmsg->h.type != m.h.type) {
1132 - /* got an unexpected message type in reply */
1137 - ret = -rmsg->u.component_enable_reply.status;
1140 - vchi_held_msg_release(&rmsg_handle);
1145 -/* disable a component on vc */
1146 -static int disable_component(struct vchiq_mmal_instance *instance,
1147 - struct vchiq_mmal_component *component)
1150 - struct mmal_msg m;
1151 - struct mmal_msg *rmsg;
1152 - VCHI_HELD_MSG_T rmsg_handle;
1154 - m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE;
1155 - m.u.component_disable.component_handle = component->handle;
1157 - ret = send_synchronous_mmal_msg(instance, &m,
1158 - sizeof(m.u.component_disable),
1159 - &rmsg, &rmsg_handle);
1163 - if (rmsg->h.type != m.h.type) {
1164 - /* got an unexpected message type in reply */
1169 - ret = -rmsg->u.component_disable_reply.status;
1173 - vchi_held_msg_release(&rmsg_handle);
1178 -/* get version of mmal implementation */
1179 -static int get_version(struct vchiq_mmal_instance *instance,
1180 - u32 *major_out, u32 *minor_out)
1183 - struct mmal_msg m;
1184 - struct mmal_msg *rmsg;
1185 - VCHI_HELD_MSG_T rmsg_handle;
1187 - m.h.type = MMAL_MSG_TYPE_GET_VERSION;
1189 - ret = send_synchronous_mmal_msg(instance, &m,
1190 - sizeof(m.u.version),
1191 - &rmsg, &rmsg_handle);
1195 - if (rmsg->h.type != m.h.type) {
1196 - /* got an unexpected message type in reply */
1201 - *major_out = rmsg->u.version.major;
1202 - *minor_out = rmsg->u.version.minor;
1205 - vchi_held_msg_release(&rmsg_handle);
1210 -/* do a port action with a port as a parameter */
1211 -static int port_action_port(struct vchiq_mmal_instance *instance,
1212 - struct vchiq_mmal_port *port,
1213 - enum mmal_msg_port_action_type action_type)
1216 - struct mmal_msg m;
1217 - struct mmal_msg *rmsg;
1218 - VCHI_HELD_MSG_T rmsg_handle;
1220 - m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
1221 - m.u.port_action_port.component_handle = port->component->handle;
1222 - m.u.port_action_port.port_handle = port->handle;
1223 - m.u.port_action_port.action = action_type;
1225 - port_to_mmal_msg(port, &m.u.port_action_port.port);
1227 - ret = send_synchronous_mmal_msg(instance, &m,
1228 - sizeof(m.u.port_action_port),
1229 - &rmsg, &rmsg_handle);
1233 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
1234 - /* got an unexpected message type in reply */
1239 - ret = -rmsg->u.port_action_reply.status;
1241 - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n",
1243 - ret, port->component->handle, port->handle,
1244 - port_action_type_names[action_type], action_type);
1247 - vchi_held_msg_release(&rmsg_handle);
1252 -/* do a port action with handles as parameters */
1253 -static int port_action_handle(struct vchiq_mmal_instance *instance,
1254 - struct vchiq_mmal_port *port,
1255 - enum mmal_msg_port_action_type action_type,
1256 - u32 connect_component_handle,
1257 - u32 connect_port_handle)
1260 - struct mmal_msg m;
1261 - struct mmal_msg *rmsg;
1262 - VCHI_HELD_MSG_T rmsg_handle;
1264 - m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
1266 - m.u.port_action_handle.component_handle = port->component->handle;
1267 - m.u.port_action_handle.port_handle = port->handle;
1268 - m.u.port_action_handle.action = action_type;
1270 - m.u.port_action_handle.connect_component_handle =
1271 - connect_component_handle;
1272 - m.u.port_action_handle.connect_port_handle = connect_port_handle;
1274 - ret = send_synchronous_mmal_msg(instance, &m,
1275 - sizeof(m.u.port_action_handle),
1276 - &rmsg, &rmsg_handle);
1280 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
1281 - /* got an unexpected message type in reply */
1286 - ret = -rmsg->u.port_action_reply.status;
1288 - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
1290 - ret, port->component->handle, port->handle,
1291 - port_action_type_names[action_type],
1292 - action_type, connect_component_handle, connect_port_handle);
1295 - vchi_held_msg_release(&rmsg_handle);
1300 -static int port_parameter_set(struct vchiq_mmal_instance *instance,
1301 - struct vchiq_mmal_port *port,
1302 - u32 parameter_id, void *value, u32 value_size)
1305 - struct mmal_msg m;
1306 - struct mmal_msg *rmsg;
1307 - VCHI_HELD_MSG_T rmsg_handle;
1309 - m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET;
1311 - m.u.port_parameter_set.component_handle = port->component->handle;
1312 - m.u.port_parameter_set.port_handle = port->handle;
1313 - m.u.port_parameter_set.id = parameter_id;
1314 - m.u.port_parameter_set.size = (2 * sizeof(u32)) + value_size;
1315 - memcpy(&m.u.port_parameter_set.value, value, value_size);
1317 - ret = send_synchronous_mmal_msg(instance, &m,
1318 - (4 * sizeof(u32)) + value_size,
1319 - &rmsg, &rmsg_handle);
1323 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_SET) {
1324 - /* got an unexpected message type in reply */
1329 - ret = -rmsg->u.port_parameter_set_reply.status;
1331 - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n",
1333 - ret, port->component->handle, port->handle, parameter_id);
1336 - vchi_held_msg_release(&rmsg_handle);
1341 -static int port_parameter_get(struct vchiq_mmal_instance *instance,
1342 - struct vchiq_mmal_port *port,
1343 - u32 parameter_id, void *value, u32 *value_size)
1346 - struct mmal_msg m;
1347 - struct mmal_msg *rmsg;
1348 - VCHI_HELD_MSG_T rmsg_handle;
1350 - m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET;
1352 - m.u.port_parameter_get.component_handle = port->component->handle;
1353 - m.u.port_parameter_get.port_handle = port->handle;
1354 - m.u.port_parameter_get.id = parameter_id;
1355 - m.u.port_parameter_get.size = (2 * sizeof(u32)) + *value_size;
1357 - ret = send_synchronous_mmal_msg(instance, &m,
1359 - mmal_msg_port_parameter_get),
1360 - &rmsg, &rmsg_handle);
1364 - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_GET) {
1365 - /* got an unexpected message type in reply */
1366 - pr_err("Incorrect reply type %d\n", rmsg->h.type);
1371 - ret = -rmsg->u.port_parameter_get_reply.status;
1372 - /* port_parameter_get_reply.size includes the header,
1373 - * whilst *value_size doesn't.
1375 - rmsg->u.port_parameter_get_reply.size -= (2 * sizeof(u32));
1377 - if (ret || rmsg->u.port_parameter_get_reply.size > *value_size) {
1378 - /* Copy only as much as we have space for
1379 - * but report true size of parameter
1381 - memcpy(value, &rmsg->u.port_parameter_get_reply.value,
1383 - *value_size = rmsg->u.port_parameter_get_reply.size;
1385 - memcpy(value, &rmsg->u.port_parameter_get_reply.value,
1386 - rmsg->u.port_parameter_get_reply.size);
1389 - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__,
1390 - ret, port->component->handle, port->handle, parameter_id);
1393 - vchi_held_msg_release(&rmsg_handle);
1398 -/* disables a port and drains buffers from it */
1399 -static int port_disable(struct vchiq_mmal_instance *instance,
1400 - struct vchiq_mmal_port *port)
1403 - struct list_head *q, *buf_head;
1404 - unsigned long flags = 0;
1406 - if (!port->enabled)
1409 - port->enabled = false;
1411 - ret = port_action_port(instance, port,
1412 - MMAL_MSG_PORT_ACTION_TYPE_DISABLE);
1415 - * Drain all queued buffers on port. This should only
1416 - * apply to buffers that have been queued before the port
1417 - * has been enabled. If the port has been enabled and buffers
1418 - * passed, then the buffers should have been removed from this
1419 - * list, and we should get the relevant callbacks via VCHIQ
1420 - * to release the buffers.
1422 - spin_lock_irqsave(&port->slock, flags);
1424 - list_for_each_safe(buf_head, q, &port->buffers) {
1425 - struct mmal_buffer *mmalbuf;
1427 - mmalbuf = list_entry(buf_head, struct mmal_buffer,
1429 - list_del(buf_head);
1430 - if (port->buffer_cb)
1431 - port->buffer_cb(instance,
1432 - port, 0, mmalbuf, 0, 0,
1433 - MMAL_TIME_UNKNOWN,
1434 - MMAL_TIME_UNKNOWN);
1437 - spin_unlock_irqrestore(&port->slock, flags);
1439 - ret = port_info_get(instance, port);
1445 -/* enable a port */
1446 -static int port_enable(struct vchiq_mmal_instance *instance,
1447 - struct vchiq_mmal_port *port)
1449 - unsigned int hdr_count;
1450 - struct list_head *q, *buf_head;
1453 - if (port->enabled)
1456 - ret = port_action_port(instance, port,
1457 - MMAL_MSG_PORT_ACTION_TYPE_ENABLE);
1461 - port->enabled = true;
1463 - if (port->buffer_cb) {
1464 - /* send buffer headers to videocore */
1466 - list_for_each_safe(buf_head, q, &port->buffers) {
1467 - struct mmal_buffer *mmalbuf;
1469 - mmalbuf = list_entry(buf_head, struct mmal_buffer,
1471 - ret = buffer_from_host(instance, port, mmalbuf);
1475 - list_del(buf_head);
1477 - if (hdr_count > port->current_buffer.num)
1482 - ret = port_info_get(instance, port);
1488 -/* ------------------------------------------------------------------
1490 - *------------------------------------------------------------------
1493 -int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
1494 - struct vchiq_mmal_port *port)
1498 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1501 - ret = port_info_set(instance, port);
1503 - goto release_unlock;
1505 - /* read what has actually been set */
1506 - ret = port_info_get(instance, port);
1509 - mutex_unlock(&instance->vchiq_mutex);
1514 -int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
1515 - struct vchiq_mmal_port *port,
1516 - u32 parameter, void *value, u32 value_size)
1520 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1523 - ret = port_parameter_set(instance, port, parameter, value, value_size);
1525 - mutex_unlock(&instance->vchiq_mutex);
1530 -int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
1531 - struct vchiq_mmal_port *port,
1532 - u32 parameter, void *value, u32 *value_size)
1536 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1539 - ret = port_parameter_get(instance, port, parameter, value, value_size);
1541 - mutex_unlock(&instance->vchiq_mutex);
1548 - * enables a port and queues buffers for satisfying callbacks if we
1549 - * provide a callback handler
1551 -int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
1552 - struct vchiq_mmal_port *port,
1553 - vchiq_mmal_buffer_cb buffer_cb)
1557 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1560 - /* already enabled - noop */
1561 - if (port->enabled) {
1566 - port->buffer_cb = buffer_cb;
1568 - ret = port_enable(instance, port);
1571 - mutex_unlock(&instance->vchiq_mutex);
1576 -int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
1577 - struct vchiq_mmal_port *port)
1581 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1584 - if (!port->enabled) {
1585 - mutex_unlock(&instance->vchiq_mutex);
1589 - ret = port_disable(instance, port);
1591 - mutex_unlock(&instance->vchiq_mutex);
1596 -/* ports will be connected in a tunneled manner so data buffers
1597 - * are not handled by client.
1599 -int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
1600 - struct vchiq_mmal_port *src,
1601 - struct vchiq_mmal_port *dst)
1605 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1608 - /* disconnect ports if connected */
1609 - if (src->connected) {
1610 - ret = port_disable(instance, src);
1612 - pr_err("failed disabling src port(%d)\n", ret);
1613 - goto release_unlock;
1616 - /* do not need to disable the destination port as they
1617 - * are connected and it is done automatically
1620 - ret = port_action_handle(instance, src,
1621 - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT,
1622 - src->connected->component->handle,
1623 - src->connected->handle);
1625 - pr_err("failed disconnecting src port\n");
1626 - goto release_unlock;
1628 - src->connected->enabled = false;
1629 - src->connected = NULL;
1633 - /* do not make new connection */
1635 - pr_debug("not making new connection\n");
1636 - goto release_unlock;
1639 - /* copy src port format to dst */
1640 - dst->format.encoding = src->format.encoding;
1641 - dst->es.video.width = src->es.video.width;
1642 - dst->es.video.height = src->es.video.height;
1643 - dst->es.video.crop.x = src->es.video.crop.x;
1644 - dst->es.video.crop.y = src->es.video.crop.y;
1645 - dst->es.video.crop.width = src->es.video.crop.width;
1646 - dst->es.video.crop.height = src->es.video.crop.height;
1647 - dst->es.video.frame_rate.num = src->es.video.frame_rate.num;
1648 - dst->es.video.frame_rate.den = src->es.video.frame_rate.den;
1650 - /* set new format */
1651 - ret = port_info_set(instance, dst);
1653 - pr_debug("setting port info failed\n");
1654 - goto release_unlock;
1657 - /* read what has actually been set */
1658 - ret = port_info_get(instance, dst);
1660 - pr_debug("read back port info failed\n");
1661 - goto release_unlock;
1664 - /* connect two ports together */
1665 - ret = port_action_handle(instance, src,
1666 - MMAL_MSG_PORT_ACTION_TYPE_CONNECT,
1667 - dst->component->handle, dst->handle);
1669 - pr_debug("connecting port %d:%d to %d:%d failed\n",
1670 - src->component->handle, src->handle,
1671 - dst->component->handle, dst->handle);
1672 - goto release_unlock;
1674 - src->connected = dst;
1678 - mutex_unlock(&instance->vchiq_mutex);
1683 -int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
1684 - struct vchiq_mmal_port *port,
1685 - struct mmal_buffer *buffer)
1687 - unsigned long flags = 0;
1690 - ret = buffer_from_host(instance, port, buffer);
1691 - if (ret == -EINVAL) {
1692 - /* Port is disabled. Queue for when it is enabled. */
1693 - spin_lock_irqsave(&port->slock, flags);
1694 - list_add_tail(&buffer->list, &port->buffers);
1695 - spin_unlock_irqrestore(&port->slock, flags);
1701 -int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
1702 - struct mmal_buffer *buf)
1704 - struct mmal_msg_context *msg_context = get_msg_context(instance);
1706 - if (IS_ERR(msg_context))
1707 - return (PTR_ERR(msg_context));
1709 - buf->msg_context = msg_context;
1713 -int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
1715 - struct mmal_msg_context *msg_context = buf->msg_context;
1718 - release_msg_context(msg_context);
1719 - buf->msg_context = NULL;
1724 -/* Initialise a mmal component and its ports
1727 -int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
1729 - struct vchiq_mmal_component **component_out)
1732 - int idx; /* port index */
1733 - struct vchiq_mmal_component *component;
1735 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1738 - if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) {
1739 - ret = -EINVAL; /* todo is this correct error? */
1743 - component = &instance->component[instance->component_idx];
1745 - ret = create_component(instance, component, name);
1747 - pr_err("%s: failed to create component %d (Not enough GPU mem?)\n",
1752 - /* ports info needs gathering */
1753 - component->control.type = MMAL_PORT_TYPE_CONTROL;
1754 - component->control.index = 0;
1755 - component->control.component = component;
1756 - spin_lock_init(&component->control.slock);
1757 - INIT_LIST_HEAD(&component->control.buffers);
1758 - ret = port_info_get(instance, &component->control);
1760 - goto release_component;
1762 - for (idx = 0; idx < component->inputs; idx++) {
1763 - component->input[idx].type = MMAL_PORT_TYPE_INPUT;
1764 - component->input[idx].index = idx;
1765 - component->input[idx].component = component;
1766 - spin_lock_init(&component->input[idx].slock);
1767 - INIT_LIST_HEAD(&component->input[idx].buffers);
1768 - ret = port_info_get(instance, &component->input[idx]);
1770 - goto release_component;
1773 - for (idx = 0; idx < component->outputs; idx++) {
1774 - component->output[idx].type = MMAL_PORT_TYPE_OUTPUT;
1775 - component->output[idx].index = idx;
1776 - component->output[idx].component = component;
1777 - spin_lock_init(&component->output[idx].slock);
1778 - INIT_LIST_HEAD(&component->output[idx].buffers);
1779 - ret = port_info_get(instance, &component->output[idx]);
1781 - goto release_component;
1784 - for (idx = 0; idx < component->clocks; idx++) {
1785 - component->clock[idx].type = MMAL_PORT_TYPE_CLOCK;
1786 - component->clock[idx].index = idx;
1787 - component->clock[idx].component = component;
1788 - spin_lock_init(&component->clock[idx].slock);
1789 - INIT_LIST_HEAD(&component->clock[idx].buffers);
1790 - ret = port_info_get(instance, &component->clock[idx]);
1792 - goto release_component;
1795 - instance->component_idx++;
1797 - *component_out = component;
1799 - mutex_unlock(&instance->vchiq_mutex);
1804 - destroy_component(instance, component);
1806 - mutex_unlock(&instance->vchiq_mutex);
1812 - * cause a mmal component to be destroyed
1814 -int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
1815 - struct vchiq_mmal_component *component)
1819 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1822 - if (component->enabled)
1823 - ret = disable_component(instance, component);
1825 - ret = destroy_component(instance, component);
1827 - mutex_unlock(&instance->vchiq_mutex);
1833 - * cause a mmal component to be enabled
1835 -int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,
1836 - struct vchiq_mmal_component *component)
1840 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1843 - if (component->enabled) {
1844 - mutex_unlock(&instance->vchiq_mutex);
1848 - ret = enable_component(instance, component);
1850 - component->enabled = true;
1852 - mutex_unlock(&instance->vchiq_mutex);
1858 - * cause a mmal component to be enabled
1860 -int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance,
1861 - struct vchiq_mmal_component *component)
1865 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1868 - if (!component->enabled) {
1869 - mutex_unlock(&instance->vchiq_mutex);
1873 - ret = disable_component(instance, component);
1875 - component->enabled = false;
1877 - mutex_unlock(&instance->vchiq_mutex);
1882 -int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
1883 - u32 *major_out, u32 *minor_out)
1887 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1890 - ret = get_version(instance, major_out, minor_out);
1892 - mutex_unlock(&instance->vchiq_mutex);
1897 -int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
1904 - if (mutex_lock_interruptible(&instance->vchiq_mutex))
1907 - vchi_service_use(instance->handle);
1909 - status = vchi_service_close(instance->handle);
1911 - pr_err("mmal-vchiq: VCHIQ close failed\n");
1913 - mutex_unlock(&instance->vchiq_mutex);
1915 - flush_workqueue(instance->bulk_wq);
1916 - destroy_workqueue(instance->bulk_wq);
1918 - vfree(instance->bulk_scratch);
1920 - idr_destroy(&instance->context_map);
1927 -int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
1930 - struct vchiq_mmal_instance *instance;
1931 - static VCHI_CONNECTION_T *vchi_connection;
1932 - static VCHI_INSTANCE_T vchi_instance;
1933 - SERVICE_CREATION_T params = {
1934 - .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER),
1935 - .service_id = VC_MMAL_SERVER_NAME,
1936 - .connection = vchi_connection,
1937 - .rx_fifo_size = 0,
1938 - .tx_fifo_size = 0,
1939 - .callback = service_callback,
1940 - .callback_param = NULL,
1941 - .want_unaligned_bulk_rx = 1,
1942 - .want_unaligned_bulk_tx = 1,
1946 - /* compile time checks to ensure structure size as they are
1947 - * directly (de)serialised from memory.
1950 - /* ensure the header structure has packed to the correct size */
1951 - BUILD_BUG_ON(sizeof(struct mmal_msg_header) != 24);
1953 - /* ensure message structure does not exceed maximum length */
1954 - BUILD_BUG_ON(sizeof(struct mmal_msg) > MMAL_MSG_MAX_SIZE);
1956 - /* mmal port struct is correct size */
1957 - BUILD_BUG_ON(sizeof(struct mmal_port) != 64);
1959 - /* create a vchi instance */
1960 - status = vchi_initialise(&vchi_instance);
1962 - pr_err("Failed to initialise VCHI instance (status=%d)\n",
1967 - status = vchi_connect(NULL, 0, vchi_instance);
1969 - pr_err("Failed to connect VCHI instance (status=%d)\n", status);
1973 - instance = kzalloc(sizeof(*instance), GFP_KERNEL);
1978 - mutex_init(&instance->vchiq_mutex);
1980 - instance->bulk_scratch = vmalloc(PAGE_SIZE);
1982 - spin_lock_init(&instance->context_map_lock);
1983 - idr_init_base(&instance->context_map, 1);
1985 - params.callback_param = instance;
1987 - instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq",
1989 - if (!instance->bulk_wq)
1992 - status = vchi_service_open(vchi_instance, ¶ms, &instance->handle);
1994 - pr_err("Failed to open VCHI service connection (status=%d)\n",
1996 - goto err_close_services;
1999 - vchi_service_release(instance->handle);
2001 - *out_instance = instance;
2005 -err_close_services:
2006 - vchi_service_close(instance->handle);
2007 - destroy_workqueue(instance->bulk_wq);
2009 - vfree(instance->bulk_scratch);
2014 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
2016 +// SPDX-License-Identifier: GPL-2.0
2018 + * Broadcom BM2835 V4L2 driver
2020 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
2022 + * Authors: Vincent Sanders @ Collabora
2023 + * Dave Stevenson @ Broadcom
2024 + * (now dave.stevenson@raspberrypi.org)
2025 + * Simon Mellor @ Broadcom
2026 + * Luke Diamand @ Broadcom
2028 + * V4L2 driver MMAL vchiq interface code
2031 +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2033 +#include <linux/errno.h>
2034 +#include <linux/kernel.h>
2035 +#include <linux/module.h>
2036 +#include <linux/mutex.h>
2037 +#include <linux/mm.h>
2038 +#include <linux/slab.h>
2039 +#include <linux/completion.h>
2040 +#include <linux/vmalloc.h>
2041 +#include <asm/cacheflush.h>
2042 +#include <media/videobuf2-vmalloc.h>
2044 +#include "mmal-common.h"
2045 +#include "mmal-vchiq.h"
2046 +#include "mmal-msg.h"
2048 +#define USE_VCHIQ_ARM
2049 +#include "interface/vchi/vchi.h"
2051 +MODULE_DESCRIPTION("BCM2835 MMAL VCHIQ interface");
2052 +MODULE_AUTHOR("Dave Stevenson, <dave.stevenson@raspberrypi.org>");
2053 +MODULE_LICENSE("GPL");
2054 +MODULE_VERSION("0.0.1");
2056 +/* maximum number of components supported */
2057 +#define VCHIQ_MMAL_MAX_COMPONENTS 4
2059 +/*#define FULL_MSG_DUMP 1*/
2062 +static const char *const msg_type_names[] = {
2067 + "COMPONENT_CREATE",
2068 + "COMPONENT_DESTROY",
2069 + "COMPONENT_ENABLE",
2070 + "COMPONENT_DISABLE",
2074 + "BUFFER_FROM_HOST",
2077 + "PORT_PARAMETER_SET",
2078 + "PORT_PARAMETER_GET",
2080 + "GET_CORE_STATS_FOR_PORT",
2081 + "OPAQUE_ALLOCATOR",
2084 + "OPAQUE_ALLOCATOR_DESC",
2087 + "BUFFER_FROM_HOST_ZEROLEN",
2093 +static const char *const port_action_type_names[] = {
2100 + "SET_REQUIREMENTS",
2104 +#if defined(FULL_MSG_DUMP)
2105 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
2107 + pr_debug(TITLE" type:%s(%d) length:%d\n", \
2108 + msg_type_names[(MSG)->h.type], \
2109 + (MSG)->h.type, (MSG_LEN)); \
2110 + print_hex_dump(KERN_DEBUG, "<<h: ", DUMP_PREFIX_OFFSET, \
2112 + sizeof(struct mmal_msg_header), 1); \
2113 + print_hex_dump(KERN_DEBUG, "<<p: ", DUMP_PREFIX_OFFSET, \
2115 + ((u8 *)(MSG)) + sizeof(struct mmal_msg_header),\
2116 + (MSG_LEN) - sizeof(struct mmal_msg_header), 1); \
2119 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \
2121 + pr_debug(TITLE" type:%s(%d) length:%d\n", \
2122 + msg_type_names[(MSG)->h.type], \
2123 + (MSG)->h.type, (MSG_LEN)); \
2127 +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE)
2130 +struct vchiq_mmal_instance;
2132 +/* normal message context */
2133 +struct mmal_msg_context {
2134 + struct vchiq_mmal_instance *instance;
2136 + /* Index in the context_map idr so that we can find the
2137 + * mmal_msg_context again when servicing the VCHI reply.
2143 + /* work struct for buffer_cb callback */
2144 + struct work_struct work;
2145 + /* work struct for deferred callback */
2146 + struct work_struct buffer_to_host_work;
2147 + /* mmal instance */
2148 + struct vchiq_mmal_instance *instance;
2150 + struct vchiq_mmal_port *port;
2151 + /* actual buffer used to store bulk reply */
2152 + struct mmal_buffer *buffer;
2153 + /* amount of buffer used */
2154 + unsigned long buffer_used;
2155 + /* MMAL buffer flags */
2157 + /* Presentation and Decode timestamps */
2161 + int status; /* context status */
2163 + } bulk; /* bulk data */
2166 + /* message handle to release */
2167 + VCHI_HELD_MSG_T msg_handle;
2168 + /* pointer to received message */
2169 + struct mmal_msg *msg;
2170 + /* received message length */
2172 + /* completion upon reply */
2173 + struct completion cmplt;
2174 + } sync; /* synchronous response */
2179 +struct vchiq_mmal_instance {
2180 + VCHI_SERVICE_HANDLE_T handle;
2182 + /* ensure serialised access to service */
2183 + struct mutex vchiq_mutex;
2185 + /* vmalloc page to receive scratch bulk xfers into */
2186 + void *bulk_scratch;
2188 + struct idr context_map;
2189 + spinlock_t context_map_lock;
2191 + /* component to use next */
2192 + int component_idx;
2193 + struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS];
2195 + /* ordered workqueue to process all bulk operations */
2196 + struct workqueue_struct *bulk_wq;
2199 +static struct mmal_msg_context *
2200 +get_msg_context(struct vchiq_mmal_instance *instance)
2202 + struct mmal_msg_context *msg_context;
2205 + /* todo: should this be allocated from a pool to avoid kzalloc */
2206 + msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
2209 + return ERR_PTR(-ENOMEM);
2211 + /* Create an ID that will be passed along with our message so
2212 + * that when we service the VCHI reply, we can look up what
2213 + * message is being replied to.
2215 + spin_lock(&instance->context_map_lock);
2216 + handle = idr_alloc(&instance->context_map, msg_context,
2217 + 0, 0, GFP_KERNEL);
2218 + spin_unlock(&instance->context_map_lock);
2221 + kfree(msg_context);
2222 + return ERR_PTR(handle);
2225 + msg_context->instance = instance;
2226 + msg_context->handle = handle;
2228 + return msg_context;
2231 +static struct mmal_msg_context *
2232 +lookup_msg_context(struct vchiq_mmal_instance *instance, int handle)
2234 + return idr_find(&instance->context_map, handle);
2238 +release_msg_context(struct mmal_msg_context *msg_context)
2240 + struct vchiq_mmal_instance *instance = msg_context->instance;
2242 + spin_lock(&instance->context_map_lock);
2243 + idr_remove(&instance->context_map, msg_context->handle);
2244 + spin_unlock(&instance->context_map_lock);
2245 + kfree(msg_context);
2248 +/* deals with receipt of event to host message */
2249 +static void event_to_host_cb(struct vchiq_mmal_instance *instance,
2250 + struct mmal_msg *msg, u32 msg_len)
2252 + pr_debug("unhandled event\n");
2253 + pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n",
2254 + msg->u.event_to_host.client_component,
2255 + msg->u.event_to_host.port_type,
2256 + msg->u.event_to_host.port_num,
2257 + msg->u.event_to_host.cmd, msg->u.event_to_host.length);
2260 +/* workqueue scheduled callback
2262 + * we do this because it is important we do not call any other vchiq
2263 + * sync calls from witin the message delivery thread
2265 +static void buffer_work_cb(struct work_struct *work)
2267 + struct mmal_msg_context *msg_context =
2268 + container_of(work, struct mmal_msg_context, u.bulk.work);
2270 + atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu);
2272 + msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance,
2273 + msg_context->u.bulk.port,
2274 + msg_context->u.bulk.status,
2275 + msg_context->u.bulk.buffer,
2276 + msg_context->u.bulk.buffer_used,
2277 + msg_context->u.bulk.mmal_flags,
2278 + msg_context->u.bulk.dts,
2279 + msg_context->u.bulk.pts);
2282 +/* workqueue scheduled callback to handle receiving buffers
2284 + * VCHI will allow up to 4 bulk receives to be scheduled before blocking.
2285 + * If we block in the service_callback context then we can't process the
2286 + * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked
2287 + * vchi_bulk_queue_receive() call to complete.
2289 +static void buffer_to_host_work_cb(struct work_struct *work)
2291 + struct mmal_msg_context *msg_context =
2292 + container_of(work, struct mmal_msg_context,
2293 + u.bulk.buffer_to_host_work);
2294 + struct vchiq_mmal_instance *instance = msg_context->instance;
2295 + unsigned long len = msg_context->u.bulk.buffer_used;
2299 + /* Dummy receive to ensure the buffers remain in order */
2301 + /* queue the bulk submission */
2302 + vchi_service_use(instance->handle);
2303 + ret = vchi_bulk_queue_receive(instance->handle,
2304 + msg_context->u.bulk.buffer->buffer,
2305 + /* Actual receive needs to be a multiple
2309 + VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE |
2310 + VCHI_FLAGS_BLOCK_UNTIL_QUEUED,
2313 + vchi_service_release(instance->handle);
2316 + pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n",
2317 + __func__, msg_context, ret);
2320 +/* enqueue a bulk receive for a given message context */
2321 +static int bulk_receive(struct vchiq_mmal_instance *instance,
2322 + struct mmal_msg *msg,
2323 + struct mmal_msg_context *msg_context)
2325 + unsigned long rd_len;
2327 + rd_len = msg->u.buffer_from_host.buffer_header.length;
2329 + if (!msg_context->u.bulk.buffer) {
2330 + pr_err("bulk.buffer not configured - error in buffer_from_host\n");
2332 + /* todo: this is a serious error, we should never have
2333 + * committed a buffer_to_host operation to the mmal
2334 + * port without the buffer to back it up (underflow
2335 + * handling) and there is no obvious way to deal with
2336 + * this - how is the mmal servie going to react when
2337 + * we fail to do the xfer and reschedule a buffer when
2338 + * it arrives? perhaps a starved flag to indicate a
2339 + * waiting bulk receive?
2345 + /* ensure we do not overrun the available buffer */
2346 + if (rd_len > msg_context->u.bulk.buffer->buffer_size) {
2347 + rd_len = msg_context->u.bulk.buffer->buffer_size;
2348 + pr_warn("short read as not enough receive buffer space\n");
2349 + /* todo: is this the correct response, what happens to
2350 + * the rest of the message data?
2354 + /* store length */
2355 + msg_context->u.bulk.buffer_used = rd_len;
2356 + msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts;
2357 + msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts;
2359 + queue_work(msg_context->instance->bulk_wq,
2360 + &msg_context->u.bulk.buffer_to_host_work);
2365 +/* data in message, memcpy from packet into output buffer */
2366 +static int inline_receive(struct vchiq_mmal_instance *instance,
2367 + struct mmal_msg *msg,
2368 + struct mmal_msg_context *msg_context)
2370 + memcpy(msg_context->u.bulk.buffer->buffer,
2371 + msg->u.buffer_from_host.short_data,
2372 + msg->u.buffer_from_host.payload_in_message);
2374 + msg_context->u.bulk.buffer_used =
2375 + msg->u.buffer_from_host.payload_in_message;
2380 +/* queue the buffer availability with MMAL_MSG_TYPE_BUFFER_FROM_HOST */
2382 +buffer_from_host(struct vchiq_mmal_instance *instance,
2383 + struct vchiq_mmal_port *port, struct mmal_buffer *buf)
2385 + struct mmal_msg_context *msg_context;
2386 + struct mmal_msg m;
2389 + if (!port->enabled)
2392 + pr_debug("instance:%p buffer:%p\n", instance->handle, buf);
2395 + if (!buf->msg_context) {
2396 + pr_err("%s: msg_context not allocated, buf %p\n", __func__,
2400 + msg_context = buf->msg_context;
2402 + /* store bulk message context for when data arrives */
2403 + msg_context->u.bulk.instance = instance;
2404 + msg_context->u.bulk.port = port;
2405 + msg_context->u.bulk.buffer = buf;
2406 + msg_context->u.bulk.buffer_used = 0;
2408 + /* initialise work structure ready to schedule callback */
2409 + INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb);
2410 + INIT_WORK(&msg_context->u.bulk.buffer_to_host_work,
2411 + buffer_to_host_work_cb);
2413 + atomic_inc(&port->buffers_with_vpu);
2415 + /* prep the buffer from host message */
2416 + memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */
2418 + m.h.type = MMAL_MSG_TYPE_BUFFER_FROM_HOST;
2419 + m.h.magic = MMAL_MAGIC;
2420 + m.h.context = msg_context->handle;
2423 + /* drvbuf is our private data passed back */
2424 + m.u.buffer_from_host.drvbuf.magic = MMAL_MAGIC;
2425 + m.u.buffer_from_host.drvbuf.component_handle = port->component->handle;
2426 + m.u.buffer_from_host.drvbuf.port_handle = port->handle;
2427 + m.u.buffer_from_host.drvbuf.client_context = msg_context->handle;
2429 + /* buffer header */
2430 + m.u.buffer_from_host.buffer_header.cmd = 0;
2431 + m.u.buffer_from_host.buffer_header.data =
2432 + (u32)(unsigned long)buf->buffer;
2433 + m.u.buffer_from_host.buffer_header.alloc_size = buf->buffer_size;
2434 + m.u.buffer_from_host.buffer_header.length = 0; /* nothing used yet */
2435 + m.u.buffer_from_host.buffer_header.offset = 0; /* no offset */
2436 + m.u.buffer_from_host.buffer_header.flags = 0; /* no flags */
2437 + m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN;
2438 + m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN;
2440 + /* clear buffer type sepecific data */
2441 + memset(&m.u.buffer_from_host.buffer_header_type_specific, 0,
2442 + sizeof(m.u.buffer_from_host.buffer_header_type_specific));
2444 + /* no payload in message */
2445 + m.u.buffer_from_host.payload_in_message = 0;
2447 + vchi_service_use(instance->handle);
2449 + ret = vchi_queue_kernel_message(instance->handle,
2451 + sizeof(struct mmal_msg_header) +
2452 + sizeof(m.u.buffer_from_host));
2454 + vchi_service_release(instance->handle);
2459 +/* deals with receipt of buffer to host message */
2460 +static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,
2461 + struct mmal_msg *msg, u32 msg_len)
2463 + struct mmal_msg_context *msg_context;
2466 + pr_debug("%s: instance:%p msg:%p msg_len:%d\n",
2467 + __func__, instance, msg, msg_len);
2469 + if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) {
2470 + handle = msg->u.buffer_from_host.drvbuf.client_context;
2471 + msg_context = lookup_msg_context(instance, handle);
2473 + if (!msg_context) {
2474 + pr_err("drvbuf.client_context(%u) is invalid\n",
2479 + pr_err("MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n");
2483 + msg_context->u.bulk.mmal_flags =
2484 + msg->u.buffer_from_host.buffer_header.flags;
2486 + if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) {
2487 + /* message reception had an error */
2488 + pr_warn("error %d in reply\n", msg->h.status);
2490 + msg_context->u.bulk.status = msg->h.status;
2492 + } else if (msg->u.buffer_from_host.buffer_header.length == 0) {
2493 + /* empty buffer */
2494 + if (msg->u.buffer_from_host.buffer_header.flags &
2495 + MMAL_BUFFER_HEADER_FLAG_EOS) {
2496 + msg_context->u.bulk.status =
2497 + bulk_receive(instance, msg, msg_context);
2498 + if (msg_context->u.bulk.status == 0)
2499 + return; /* successful bulk submission, bulk
2500 + * completion will trigger callback
2503 + /* do callback with empty buffer - not EOS though */
2504 + msg_context->u.bulk.status = 0;
2505 + msg_context->u.bulk.buffer_used = 0;
2507 + } else if (msg->u.buffer_from_host.payload_in_message == 0) {
2508 + /* data is not in message, queue a bulk receive */
2509 + msg_context->u.bulk.status =
2510 + bulk_receive(instance, msg, msg_context);
2511 + if (msg_context->u.bulk.status == 0)
2512 + return; /* successful bulk submission, bulk
2513 + * completion will trigger callback
2516 + /* failed to submit buffer, this will end badly */
2517 + pr_err("error %d on bulk submission\n",
2518 + msg_context->u.bulk.status);
2520 + } else if (msg->u.buffer_from_host.payload_in_message <=
2521 + MMAL_VC_SHORT_DATA) {
2522 + /* data payload within message */
2523 + msg_context->u.bulk.status = inline_receive(instance, msg,
2526 + pr_err("message with invalid short payload\n");
2528 + /* signal error */
2529 + msg_context->u.bulk.status = -EINVAL;
2530 + msg_context->u.bulk.buffer_used =
2531 + msg->u.buffer_from_host.payload_in_message;
2534 + /* schedule the port callback */
2535 + schedule_work(&msg_context->u.bulk.work);
2538 +static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
2539 + struct mmal_msg_context *msg_context)
2541 + msg_context->u.bulk.status = 0;
2543 + /* schedule the port callback */
2544 + schedule_work(&msg_context->u.bulk.work);
2547 +static void bulk_abort_cb(struct vchiq_mmal_instance *instance,
2548 + struct mmal_msg_context *msg_context)
2550 + pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
2552 + msg_context->u.bulk.status = -EINTR;
2554 + schedule_work(&msg_context->u.bulk.work);
2557 +/* incoming event service callback */
2558 +static void service_callback(void *param,
2559 + const VCHI_CALLBACK_REASON_T reason,
2562 + struct vchiq_mmal_instance *instance = param;
2565 + struct mmal_msg *msg;
2566 + VCHI_HELD_MSG_T msg_handle;
2567 + struct mmal_msg_context *msg_context;
2570 + pr_err("Message callback passed NULL instance\n");
2575 + case VCHI_CALLBACK_MSG_AVAILABLE:
2576 + status = vchi_msg_hold(instance->handle, (void **)&msg,
2577 + &msg_len, VCHI_FLAGS_NONE, &msg_handle);
2579 + pr_err("Unable to dequeue a message (%d)\n", status);
2583 + DBG_DUMP_MSG(msg, msg_len, "<<< reply message");
2585 + /* handling is different for buffer messages */
2586 + switch (msg->h.type) {
2587 + case MMAL_MSG_TYPE_BUFFER_FROM_HOST:
2588 + vchi_held_msg_release(&msg_handle);
2591 + case MMAL_MSG_TYPE_EVENT_TO_HOST:
2592 + event_to_host_cb(instance, msg, msg_len);
2593 + vchi_held_msg_release(&msg_handle);
2597 + case MMAL_MSG_TYPE_BUFFER_TO_HOST:
2598 + buffer_to_host_cb(instance, msg, msg_len);
2599 + vchi_held_msg_release(&msg_handle);
2603 + /* messages dependent on header context to complete */
2604 + if (!msg->h.context) {
2605 + pr_err("received message context was null!\n");
2606 + vchi_held_msg_release(&msg_handle);
2610 + msg_context = lookup_msg_context(instance,
2612 + if (!msg_context) {
2613 + pr_err("received invalid message context %u!\n",
2615 + vchi_held_msg_release(&msg_handle);
2619 + /* fill in context values */
2620 + msg_context->u.sync.msg_handle = msg_handle;
2621 + msg_context->u.sync.msg = msg;
2622 + msg_context->u.sync.msg_len = msg_len;
2624 + /* todo: should this check (completion_done()
2625 + * == 1) for no one waiting? or do we need a
2626 + * flag to tell us the completion has been
2627 + * interrupted so we can free the message and
2628 + * its context. This probably also solves the
2629 + * message arriving after interruption todo
2633 + /* complete message so caller knows it happened */
2634 + complete(&msg_context->u.sync.cmplt);
2640 + case VCHI_CALLBACK_BULK_RECEIVED:
2641 + bulk_receive_cb(instance, bulk_ctx);
2644 + case VCHI_CALLBACK_BULK_RECEIVE_ABORTED:
2645 + bulk_abort_cb(instance, bulk_ctx);
2648 + case VCHI_CALLBACK_SERVICE_CLOSED:
2649 + /* TODO: consider if this requires action if received when
2650 + * driver is not explicitly closing the service
2655 + pr_err("Received unhandled message reason %d\n", reason);
2660 +static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance,
2661 + struct mmal_msg *msg,
2662 + unsigned int payload_len,
2663 + struct mmal_msg **msg_out,
2664 + VCHI_HELD_MSG_T *msg_handle_out)
2666 + struct mmal_msg_context *msg_context;
2668 + unsigned long timeout;
2670 + /* payload size must not cause message to exceed max size */
2672 + (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) {
2673 + pr_err("payload length %d exceeds max:%d\n", payload_len,
2674 + (int)(MMAL_MSG_MAX_SIZE -
2675 + sizeof(struct mmal_msg_header)));
2679 + msg_context = get_msg_context(instance);
2680 + if (IS_ERR(msg_context))
2681 + return PTR_ERR(msg_context);
2683 + init_completion(&msg_context->u.sync.cmplt);
2685 + msg->h.magic = MMAL_MAGIC;
2686 + msg->h.context = msg_context->handle;
2687 + msg->h.status = 0;
2689 + DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len),
2690 + ">>> sync message");
2692 + vchi_service_use(instance->handle);
2694 + ret = vchi_queue_kernel_message(instance->handle,
2696 + sizeof(struct mmal_msg_header) +
2699 + vchi_service_release(instance->handle);
2702 + pr_err("error %d queuing message\n", ret);
2703 + release_msg_context(msg_context);
2707 + timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt,
2709 + if (timeout == 0) {
2710 + pr_err("timed out waiting for sync completion\n");
2712 + /* todo: what happens if the message arrives after aborting */
2713 + release_msg_context(msg_context);
2717 + *msg_out = msg_context->u.sync.msg;
2718 + *msg_handle_out = msg_context->u.sync.msg_handle;
2719 + release_msg_context(msg_context);
2724 +static void dump_port_info(struct vchiq_mmal_port *port)
2726 + pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled);
2728 + pr_debug("buffer minimum num:%d size:%d align:%d\n",
2729 + port->minimum_buffer.num,
2730 + port->minimum_buffer.size, port->minimum_buffer.alignment);
2732 + pr_debug("buffer recommended num:%d size:%d align:%d\n",
2733 + port->recommended_buffer.num,
2734 + port->recommended_buffer.size,
2735 + port->recommended_buffer.alignment);
2737 + pr_debug("buffer current values num:%d size:%d align:%d\n",
2738 + port->current_buffer.num,
2739 + port->current_buffer.size, port->current_buffer.alignment);
2741 + pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n",
2742 + port->format.type,
2743 + port->format.encoding, port->format.encoding_variant);
2745 + pr_debug(" bitrate:%d flags:0x%x\n",
2746 + port->format.bitrate, port->format.flags);
2748 + if (port->format.type == MMAL_ES_TYPE_VIDEO) {
2750 + ("es video format: width:%d height:%d colourspace:0x%x\n",
2751 + port->es.video.width, port->es.video.height,
2752 + port->es.video.color_space);
2754 + pr_debug(" : crop xywh %d,%d,%d,%d\n",
2755 + port->es.video.crop.x,
2756 + port->es.video.crop.y,
2757 + port->es.video.crop.width, port->es.video.crop.height);
2758 + pr_debug(" : framerate %d/%d aspect %d/%d\n",
2759 + port->es.video.frame_rate.num,
2760 + port->es.video.frame_rate.den,
2761 + port->es.video.par.num, port->es.video.par.den);
2765 +static void port_to_mmal_msg(struct vchiq_mmal_port *port, struct mmal_port *p)
2767 + /* todo do readonly fields need setting at all? */
2768 + p->type = port->type;
2769 + p->index = port->index;
2771 + p->is_enabled = port->enabled;
2772 + p->buffer_num_min = port->minimum_buffer.num;
2773 + p->buffer_size_min = port->minimum_buffer.size;
2774 + p->buffer_alignment_min = port->minimum_buffer.alignment;
2775 + p->buffer_num_recommended = port->recommended_buffer.num;
2776 + p->buffer_size_recommended = port->recommended_buffer.size;
2778 + /* only three writable fields in a port */
2779 + p->buffer_num = port->current_buffer.num;
2780 + p->buffer_size = port->current_buffer.size;
2781 + p->userdata = (u32)(unsigned long)port;
2784 +static int port_info_set(struct vchiq_mmal_instance *instance,
2785 + struct vchiq_mmal_port *port)
2788 + struct mmal_msg m;
2789 + struct mmal_msg *rmsg;
2790 + VCHI_HELD_MSG_T rmsg_handle;
2792 + pr_debug("setting port info port %p\n", port);
2795 + dump_port_info(port);
2797 + m.h.type = MMAL_MSG_TYPE_PORT_INFO_SET;
2799 + m.u.port_info_set.component_handle = port->component->handle;
2800 + m.u.port_info_set.port_type = port->type;
2801 + m.u.port_info_set.port_index = port->index;
2803 + port_to_mmal_msg(port, &m.u.port_info_set.port);
2805 + /* elementary stream format setup */
2806 + m.u.port_info_set.format.type = port->format.type;
2807 + m.u.port_info_set.format.encoding = port->format.encoding;
2808 + m.u.port_info_set.format.encoding_variant =
2809 + port->format.encoding_variant;
2810 + m.u.port_info_set.format.bitrate = port->format.bitrate;
2811 + m.u.port_info_set.format.flags = port->format.flags;
2813 + memcpy(&m.u.port_info_set.es, &port->es,
2814 + sizeof(union mmal_es_specific_format));
2816 + m.u.port_info_set.format.extradata_size = port->format.extradata_size;
2817 + memcpy(&m.u.port_info_set.extradata, port->format.extradata,
2818 + port->format.extradata_size);
2820 + ret = send_synchronous_mmal_msg(instance, &m,
2821 + sizeof(m.u.port_info_set),
2822 + &rmsg, &rmsg_handle);
2826 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_SET) {
2827 + /* got an unexpected message type in reply */
2832 + /* return operation status */
2833 + ret = -rmsg->u.port_info_get_reply.status;
2835 + pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret,
2836 + port->component->handle, port->handle);
2839 + vchi_held_msg_release(&rmsg_handle);
2844 +/* use port info get message to retrieve port information */
2845 +static int port_info_get(struct vchiq_mmal_instance *instance,
2846 + struct vchiq_mmal_port *port)
2849 + struct mmal_msg m;
2850 + struct mmal_msg *rmsg;
2851 + VCHI_HELD_MSG_T rmsg_handle;
2853 + /* port info time */
2854 + m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET;
2855 + m.u.port_info_get.component_handle = port->component->handle;
2856 + m.u.port_info_get.port_type = port->type;
2857 + m.u.port_info_get.index = port->index;
2859 + ret = send_synchronous_mmal_msg(instance, &m,
2860 + sizeof(m.u.port_info_get),
2861 + &rmsg, &rmsg_handle);
2865 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_GET) {
2866 + /* got an unexpected message type in reply */
2871 + /* return operation status */
2872 + ret = -rmsg->u.port_info_get_reply.status;
2873 + if (ret != MMAL_MSG_STATUS_SUCCESS)
2876 + if (rmsg->u.port_info_get_reply.port.is_enabled == 0)
2877 + port->enabled = false;
2879 + port->enabled = true;
2881 + /* copy the values out of the message */
2882 + port->handle = rmsg->u.port_info_get_reply.port_handle;
2884 + /* port type and index cached to use on port info set because
2885 + * it does not use a port handle
2887 + port->type = rmsg->u.port_info_get_reply.port_type;
2888 + port->index = rmsg->u.port_info_get_reply.port_index;
2890 + port->minimum_buffer.num =
2891 + rmsg->u.port_info_get_reply.port.buffer_num_min;
2892 + port->minimum_buffer.size =
2893 + rmsg->u.port_info_get_reply.port.buffer_size_min;
2894 + port->minimum_buffer.alignment =
2895 + rmsg->u.port_info_get_reply.port.buffer_alignment_min;
2897 + port->recommended_buffer.alignment =
2898 + rmsg->u.port_info_get_reply.port.buffer_alignment_min;
2899 + port->recommended_buffer.num =
2900 + rmsg->u.port_info_get_reply.port.buffer_num_recommended;
2902 + port->current_buffer.num = rmsg->u.port_info_get_reply.port.buffer_num;
2903 + port->current_buffer.size =
2904 + rmsg->u.port_info_get_reply.port.buffer_size;
2906 + /* stream format */
2907 + port->format.type = rmsg->u.port_info_get_reply.format.type;
2908 + port->format.encoding = rmsg->u.port_info_get_reply.format.encoding;
2909 + port->format.encoding_variant =
2910 + rmsg->u.port_info_get_reply.format.encoding_variant;
2911 + port->format.bitrate = rmsg->u.port_info_get_reply.format.bitrate;
2912 + port->format.flags = rmsg->u.port_info_get_reply.format.flags;
2914 + /* elementary stream format */
2916 + &rmsg->u.port_info_get_reply.es,
2917 + sizeof(union mmal_es_specific_format));
2918 + port->format.es = &port->es;
2920 + port->format.extradata_size =
2921 + rmsg->u.port_info_get_reply.format.extradata_size;
2922 + memcpy(port->format.extradata,
2923 + rmsg->u.port_info_get_reply.extradata,
2924 + port->format.extradata_size);
2926 + pr_debug("received port info\n");
2927 + dump_port_info(port);
2931 + pr_debug("%s:result:%d component:0x%x port:%d\n",
2932 + __func__, ret, port->component->handle, port->handle);
2934 + vchi_held_msg_release(&rmsg_handle);
2939 +/* create comonent on vc */
2940 +static int create_component(struct vchiq_mmal_instance *instance,
2941 + struct vchiq_mmal_component *component,
2945 + struct mmal_msg m;
2946 + struct mmal_msg *rmsg;
2947 + VCHI_HELD_MSG_T rmsg_handle;
2949 + /* build component create message */
2950 + m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE;
2951 + m.u.component_create.client_component = (u32)(unsigned long)component;
2952 + strncpy(m.u.component_create.name, name,
2953 + sizeof(m.u.component_create.name));
2955 + ret = send_synchronous_mmal_msg(instance, &m,
2956 + sizeof(m.u.component_create),
2957 + &rmsg, &rmsg_handle);
2961 + if (rmsg->h.type != m.h.type) {
2962 + /* got an unexpected message type in reply */
2967 + ret = -rmsg->u.component_create_reply.status;
2968 + if (ret != MMAL_MSG_STATUS_SUCCESS)
2971 + /* a valid component response received */
2972 + component->handle = rmsg->u.component_create_reply.component_handle;
2973 + component->inputs = rmsg->u.component_create_reply.input_num;
2974 + component->outputs = rmsg->u.component_create_reply.output_num;
2975 + component->clocks = rmsg->u.component_create_reply.clock_num;
2977 + pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n",
2978 + component->handle,
2979 + component->inputs, component->outputs, component->clocks);
2982 + vchi_held_msg_release(&rmsg_handle);
2987 +/* destroys a component on vc */
2988 +static int destroy_component(struct vchiq_mmal_instance *instance,
2989 + struct vchiq_mmal_component *component)
2992 + struct mmal_msg m;
2993 + struct mmal_msg *rmsg;
2994 + VCHI_HELD_MSG_T rmsg_handle;
2996 + m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY;
2997 + m.u.component_destroy.component_handle = component->handle;
2999 + ret = send_synchronous_mmal_msg(instance, &m,
3000 + sizeof(m.u.component_destroy),
3001 + &rmsg, &rmsg_handle);
3005 + if (rmsg->h.type != m.h.type) {
3006 + /* got an unexpected message type in reply */
3011 + ret = -rmsg->u.component_destroy_reply.status;
3015 + vchi_held_msg_release(&rmsg_handle);
3020 +/* enable a component on vc */
3021 +static int enable_component(struct vchiq_mmal_instance *instance,
3022 + struct vchiq_mmal_component *component)
3025 + struct mmal_msg m;
3026 + struct mmal_msg *rmsg;
3027 + VCHI_HELD_MSG_T rmsg_handle;
3029 + m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE;
3030 + m.u.component_enable.component_handle = component->handle;
3032 + ret = send_synchronous_mmal_msg(instance, &m,
3033 + sizeof(m.u.component_enable),
3034 + &rmsg, &rmsg_handle);
3038 + if (rmsg->h.type != m.h.type) {
3039 + /* got an unexpected message type in reply */
3044 + ret = -rmsg->u.component_enable_reply.status;
3047 + vchi_held_msg_release(&rmsg_handle);
3052 +/* disable a component on vc */
3053 +static int disable_component(struct vchiq_mmal_instance *instance,
3054 + struct vchiq_mmal_component *component)
3057 + struct mmal_msg m;
3058 + struct mmal_msg *rmsg;
3059 + VCHI_HELD_MSG_T rmsg_handle;
3061 + m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE;
3062 + m.u.component_disable.component_handle = component->handle;
3064 + ret = send_synchronous_mmal_msg(instance, &m,
3065 + sizeof(m.u.component_disable),
3066 + &rmsg, &rmsg_handle);
3070 + if (rmsg->h.type != m.h.type) {
3071 + /* got an unexpected message type in reply */
3076 + ret = -rmsg->u.component_disable_reply.status;
3080 + vchi_held_msg_release(&rmsg_handle);
3085 +/* get version of mmal implementation */
3086 +static int get_version(struct vchiq_mmal_instance *instance,
3087 + u32 *major_out, u32 *minor_out)
3090 + struct mmal_msg m;
3091 + struct mmal_msg *rmsg;
3092 + VCHI_HELD_MSG_T rmsg_handle;
3094 + m.h.type = MMAL_MSG_TYPE_GET_VERSION;
3096 + ret = send_synchronous_mmal_msg(instance, &m,
3097 + sizeof(m.u.version),
3098 + &rmsg, &rmsg_handle);
3102 + if (rmsg->h.type != m.h.type) {
3103 + /* got an unexpected message type in reply */
3108 + *major_out = rmsg->u.version.major;
3109 + *minor_out = rmsg->u.version.minor;
3112 + vchi_held_msg_release(&rmsg_handle);
3117 +/* do a port action with a port as a parameter */
3118 +static int port_action_port(struct vchiq_mmal_instance *instance,
3119 + struct vchiq_mmal_port *port,
3120 + enum mmal_msg_port_action_type action_type)
3123 + struct mmal_msg m;
3124 + struct mmal_msg *rmsg;
3125 + VCHI_HELD_MSG_T rmsg_handle;
3127 + m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
3128 + m.u.port_action_port.component_handle = port->component->handle;
3129 + m.u.port_action_port.port_handle = port->handle;
3130 + m.u.port_action_port.action = action_type;
3132 + port_to_mmal_msg(port, &m.u.port_action_port.port);
3134 + ret = send_synchronous_mmal_msg(instance, &m,
3135 + sizeof(m.u.port_action_port),
3136 + &rmsg, &rmsg_handle);
3140 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
3141 + /* got an unexpected message type in reply */
3146 + ret = -rmsg->u.port_action_reply.status;
3148 + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n",
3150 + ret, port->component->handle, port->handle,
3151 + port_action_type_names[action_type], action_type);
3154 + vchi_held_msg_release(&rmsg_handle);
3159 +/* do a port action with handles as parameters */
3160 +static int port_action_handle(struct vchiq_mmal_instance *instance,
3161 + struct vchiq_mmal_port *port,
3162 + enum mmal_msg_port_action_type action_type,
3163 + u32 connect_component_handle,
3164 + u32 connect_port_handle)
3167 + struct mmal_msg m;
3168 + struct mmal_msg *rmsg;
3169 + VCHI_HELD_MSG_T rmsg_handle;
3171 + m.h.type = MMAL_MSG_TYPE_PORT_ACTION;
3173 + m.u.port_action_handle.component_handle = port->component->handle;
3174 + m.u.port_action_handle.port_handle = port->handle;
3175 + m.u.port_action_handle.action = action_type;
3177 + m.u.port_action_handle.connect_component_handle =
3178 + connect_component_handle;
3179 + m.u.port_action_handle.connect_port_handle = connect_port_handle;
3181 + ret = send_synchronous_mmal_msg(instance, &m,
3182 + sizeof(m.u.port_action_handle),
3183 + &rmsg, &rmsg_handle);
3187 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) {
3188 + /* got an unexpected message type in reply */
3193 + ret = -rmsg->u.port_action_reply.status;
3195 + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n",
3197 + ret, port->component->handle, port->handle,
3198 + port_action_type_names[action_type],
3199 + action_type, connect_component_handle, connect_port_handle);
3202 + vchi_held_msg_release(&rmsg_handle);
3207 +static int port_parameter_set(struct vchiq_mmal_instance *instance,
3208 + struct vchiq_mmal_port *port,
3209 + u32 parameter_id, void *value, u32 value_size)
3212 + struct mmal_msg m;
3213 + struct mmal_msg *rmsg;
3214 + VCHI_HELD_MSG_T rmsg_handle;
3216 + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET;
3218 + m.u.port_parameter_set.component_handle = port->component->handle;
3219 + m.u.port_parameter_set.port_handle = port->handle;
3220 + m.u.port_parameter_set.id = parameter_id;
3221 + m.u.port_parameter_set.size = (2 * sizeof(u32)) + value_size;
3222 + memcpy(&m.u.port_parameter_set.value, value, value_size);
3224 + ret = send_synchronous_mmal_msg(instance, &m,
3225 + (4 * sizeof(u32)) + value_size,
3226 + &rmsg, &rmsg_handle);
3230 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_SET) {
3231 + /* got an unexpected message type in reply */
3236 + ret = -rmsg->u.port_parameter_set_reply.status;
3238 + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n",
3240 + ret, port->component->handle, port->handle, parameter_id);
3243 + vchi_held_msg_release(&rmsg_handle);
3248 +static int port_parameter_get(struct vchiq_mmal_instance *instance,
3249 + struct vchiq_mmal_port *port,
3250 + u32 parameter_id, void *value, u32 *value_size)
3253 + struct mmal_msg m;
3254 + struct mmal_msg *rmsg;
3255 + VCHI_HELD_MSG_T rmsg_handle;
3257 + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET;
3259 + m.u.port_parameter_get.component_handle = port->component->handle;
3260 + m.u.port_parameter_get.port_handle = port->handle;
3261 + m.u.port_parameter_get.id = parameter_id;
3262 + m.u.port_parameter_get.size = (2 * sizeof(u32)) + *value_size;
3264 + ret = send_synchronous_mmal_msg(instance, &m,
3266 + mmal_msg_port_parameter_get),
3267 + &rmsg, &rmsg_handle);
3271 + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_GET) {
3272 + /* got an unexpected message type in reply */
3273 + pr_err("Incorrect reply type %d\n", rmsg->h.type);
3278 + ret = -rmsg->u.port_parameter_get_reply.status;
3279 + /* port_parameter_get_reply.size includes the header,
3280 + * whilst *value_size doesn't.
3282 + rmsg->u.port_parameter_get_reply.size -= (2 * sizeof(u32));
3284 + if (ret || rmsg->u.port_parameter_get_reply.size > *value_size) {
3285 + /* Copy only as much as we have space for
3286 + * but report true size of parameter
3288 + memcpy(value, &rmsg->u.port_parameter_get_reply.value,
3290 + *value_size = rmsg->u.port_parameter_get_reply.size;
3292 + memcpy(value, &rmsg->u.port_parameter_get_reply.value,
3293 + rmsg->u.port_parameter_get_reply.size);
3296 + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__,
3297 + ret, port->component->handle, port->handle, parameter_id);
3300 + vchi_held_msg_release(&rmsg_handle);
3305 +/* disables a port and drains buffers from it */
3306 +static int port_disable(struct vchiq_mmal_instance *instance,
3307 + struct vchiq_mmal_port *port)
3310 + struct list_head *q, *buf_head;
3311 + unsigned long flags = 0;
3313 + if (!port->enabled)
3316 + port->enabled = false;
3318 + ret = port_action_port(instance, port,
3319 + MMAL_MSG_PORT_ACTION_TYPE_DISABLE);
3322 + * Drain all queued buffers on port. This should only
3323 + * apply to buffers that have been queued before the port
3324 + * has been enabled. If the port has been enabled and buffers
3325 + * passed, then the buffers should have been removed from this
3326 + * list, and we should get the relevant callbacks via VCHIQ
3327 + * to release the buffers.
3329 + spin_lock_irqsave(&port->slock, flags);
3331 + list_for_each_safe(buf_head, q, &port->buffers) {
3332 + struct mmal_buffer *mmalbuf;
3334 + mmalbuf = list_entry(buf_head, struct mmal_buffer,
3336 + list_del(buf_head);
3337 + if (port->buffer_cb)
3338 + port->buffer_cb(instance,
3339 + port, 0, mmalbuf, 0, 0,
3340 + MMAL_TIME_UNKNOWN,
3341 + MMAL_TIME_UNKNOWN);
3344 + spin_unlock_irqrestore(&port->slock, flags);
3346 + ret = port_info_get(instance, port);
3352 +/* enable a port */
3353 +static int port_enable(struct vchiq_mmal_instance *instance,
3354 + struct vchiq_mmal_port *port)
3356 + unsigned int hdr_count;
3357 + struct list_head *q, *buf_head;
3360 + if (port->enabled)
3363 + ret = port_action_port(instance, port,
3364 + MMAL_MSG_PORT_ACTION_TYPE_ENABLE);
3368 + port->enabled = true;
3370 + if (port->buffer_cb) {
3371 + /* send buffer headers to videocore */
3373 + list_for_each_safe(buf_head, q, &port->buffers) {
3374 + struct mmal_buffer *mmalbuf;
3376 + mmalbuf = list_entry(buf_head, struct mmal_buffer,
3378 + ret = buffer_from_host(instance, port, mmalbuf);
3382 + list_del(buf_head);
3384 + if (hdr_count > port->current_buffer.num)
3389 + ret = port_info_get(instance, port);
3395 +/* ------------------------------------------------------------------
3397 + *------------------------------------------------------------------
3400 +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
3401 + struct vchiq_mmal_port *port)
3405 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3408 + ret = port_info_set(instance, port);
3410 + goto release_unlock;
3412 + /* read what has actually been set */
3413 + ret = port_info_get(instance, port);
3416 + mutex_unlock(&instance->vchiq_mutex);
3420 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_set_format);
3422 +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
3423 + struct vchiq_mmal_port *port,
3424 + u32 parameter, void *value, u32 value_size)
3428 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3431 + ret = port_parameter_set(instance, port, parameter, value, value_size);
3433 + mutex_unlock(&instance->vchiq_mutex);
3437 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_set);
3439 +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
3440 + struct vchiq_mmal_port *port,
3441 + u32 parameter, void *value, u32 *value_size)
3445 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3448 + ret = port_parameter_get(instance, port, parameter, value, value_size);
3450 + mutex_unlock(&instance->vchiq_mutex);
3454 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_get);
3458 + * enables a port and queues buffers for satisfying callbacks if we
3459 + * provide a callback handler
3461 +int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance,
3462 + struct vchiq_mmal_port *port,
3463 + vchiq_mmal_buffer_cb buffer_cb)
3467 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3470 + /* already enabled - noop */
3471 + if (port->enabled) {
3476 + port->buffer_cb = buffer_cb;
3478 + ret = port_enable(instance, port);
3481 + mutex_unlock(&instance->vchiq_mutex);
3485 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_enable);
3487 +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
3488 + struct vchiq_mmal_port *port)
3492 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3495 + if (!port->enabled) {
3496 + mutex_unlock(&instance->vchiq_mutex);
3500 + ret = port_disable(instance, port);
3502 + mutex_unlock(&instance->vchiq_mutex);
3506 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_disable);
3508 +/* ports will be connected in a tunneled manner so data buffers
3509 + * are not handled by client.
3511 +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
3512 + struct vchiq_mmal_port *src,
3513 + struct vchiq_mmal_port *dst)
3517 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3520 + /* disconnect ports if connected */
3521 + if (src->connected) {
3522 + ret = port_disable(instance, src);
3524 + pr_err("failed disabling src port(%d)\n", ret);
3525 + goto release_unlock;
3528 + /* do not need to disable the destination port as they
3529 + * are connected and it is done automatically
3532 + ret = port_action_handle(instance, src,
3533 + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT,
3534 + src->connected->component->handle,
3535 + src->connected->handle);
3537 + pr_err("failed disconnecting src port\n");
3538 + goto release_unlock;
3540 + src->connected->enabled = false;
3541 + src->connected = NULL;
3545 + /* do not make new connection */
3547 + pr_debug("not making new connection\n");
3548 + goto release_unlock;
3551 + /* copy src port format to dst */
3552 + dst->format.encoding = src->format.encoding;
3553 + dst->es.video.width = src->es.video.width;
3554 + dst->es.video.height = src->es.video.height;
3555 + dst->es.video.crop.x = src->es.video.crop.x;
3556 + dst->es.video.crop.y = src->es.video.crop.y;
3557 + dst->es.video.crop.width = src->es.video.crop.width;
3558 + dst->es.video.crop.height = src->es.video.crop.height;
3559 + dst->es.video.frame_rate.num = src->es.video.frame_rate.num;
3560 + dst->es.video.frame_rate.den = src->es.video.frame_rate.den;
3562 + /* set new format */
3563 + ret = port_info_set(instance, dst);
3565 + pr_debug("setting port info failed\n");
3566 + goto release_unlock;
3569 + /* read what has actually been set */
3570 + ret = port_info_get(instance, dst);
3572 + pr_debug("read back port info failed\n");
3573 + goto release_unlock;
3576 + /* connect two ports together */
3577 + ret = port_action_handle(instance, src,
3578 + MMAL_MSG_PORT_ACTION_TYPE_CONNECT,
3579 + dst->component->handle, dst->handle);
3581 + pr_debug("connecting port %d:%d to %d:%d failed\n",
3582 + src->component->handle, src->handle,
3583 + dst->component->handle, dst->handle);
3584 + goto release_unlock;
3586 + src->connected = dst;
3590 + mutex_unlock(&instance->vchiq_mutex);
3594 +EXPORT_SYMBOL_GPL(vchiq_mmal_port_connect_tunnel);
3596 +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
3597 + struct vchiq_mmal_port *port,
3598 + struct mmal_buffer *buffer)
3600 + unsigned long flags = 0;
3603 + ret = buffer_from_host(instance, port, buffer);
3604 + if (ret == -EINVAL) {
3605 + /* Port is disabled. Queue for when it is enabled. */
3606 + spin_lock_irqsave(&port->slock, flags);
3607 + list_add_tail(&buffer->list, &port->buffers);
3608 + spin_unlock_irqrestore(&port->slock, flags);
3613 +EXPORT_SYMBOL_GPL(vchiq_mmal_submit_buffer);
3615 +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
3616 + struct mmal_buffer *buf)
3618 + struct mmal_msg_context *msg_context = get_msg_context(instance);
3620 + if (IS_ERR(msg_context))
3621 + return (PTR_ERR(msg_context));
3623 + buf->msg_context = msg_context;
3626 +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_init);
3628 +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf)
3630 + struct mmal_msg_context *msg_context = buf->msg_context;
3633 + release_msg_context(msg_context);
3634 + buf->msg_context = NULL;
3638 +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_cleanup);
3640 +/* Initialise a mmal component and its ports
3643 +int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
3645 + struct vchiq_mmal_component **component_out)
3648 + int idx; /* port index */
3649 + struct vchiq_mmal_component *component;
3651 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3654 + if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) {
3655 + ret = -EINVAL; /* todo is this correct error? */
3659 + component = &instance->component[instance->component_idx];
3661 + ret = create_component(instance, component, name);
3663 + pr_err("%s: failed to create component %d (Not enough GPU mem?)\n",
3668 + /* ports info needs gathering */
3669 + component->control.type = MMAL_PORT_TYPE_CONTROL;
3670 + component->control.index = 0;
3671 + component->control.component = component;
3672 + spin_lock_init(&component->control.slock);
3673 + INIT_LIST_HEAD(&component->control.buffers);
3674 + ret = port_info_get(instance, &component->control);
3676 + goto release_component;
3678 + for (idx = 0; idx < component->inputs; idx++) {
3679 + component->input[idx].type = MMAL_PORT_TYPE_INPUT;
3680 + component->input[idx].index = idx;
3681 + component->input[idx].component = component;
3682 + spin_lock_init(&component->input[idx].slock);
3683 + INIT_LIST_HEAD(&component->input[idx].buffers);
3684 + ret = port_info_get(instance, &component->input[idx]);
3686 + goto release_component;
3689 + for (idx = 0; idx < component->outputs; idx++) {
3690 + component->output[idx].type = MMAL_PORT_TYPE_OUTPUT;
3691 + component->output[idx].index = idx;
3692 + component->output[idx].component = component;
3693 + spin_lock_init(&component->output[idx].slock);
3694 + INIT_LIST_HEAD(&component->output[idx].buffers);
3695 + ret = port_info_get(instance, &component->output[idx]);
3697 + goto release_component;
3700 + for (idx = 0; idx < component->clocks; idx++) {
3701 + component->clock[idx].type = MMAL_PORT_TYPE_CLOCK;
3702 + component->clock[idx].index = idx;
3703 + component->clock[idx].component = component;
3704 + spin_lock_init(&component->clock[idx].slock);
3705 + INIT_LIST_HEAD(&component->clock[idx].buffers);
3706 + ret = port_info_get(instance, &component->clock[idx]);
3708 + goto release_component;
3711 + instance->component_idx++;
3713 + *component_out = component;
3715 + mutex_unlock(&instance->vchiq_mutex);
3720 + destroy_component(instance, component);
3722 + mutex_unlock(&instance->vchiq_mutex);
3726 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_init);
3729 + * cause a mmal component to be destroyed
3731 +int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
3732 + struct vchiq_mmal_component *component)
3736 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3739 + if (component->enabled)
3740 + ret = disable_component(instance, component);
3742 + ret = destroy_component(instance, component);
3744 + mutex_unlock(&instance->vchiq_mutex);
3748 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_finalise);
3751 + * cause a mmal component to be enabled
3753 +int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance,
3754 + struct vchiq_mmal_component *component)
3758 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3761 + if (component->enabled) {
3762 + mutex_unlock(&instance->vchiq_mutex);
3766 + ret = enable_component(instance, component);
3768 + component->enabled = true;
3770 + mutex_unlock(&instance->vchiq_mutex);
3774 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_enable);
3777 + * cause a mmal component to be enabled
3779 +int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance,
3780 + struct vchiq_mmal_component *component)
3784 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3787 + if (!component->enabled) {
3788 + mutex_unlock(&instance->vchiq_mutex);
3792 + ret = disable_component(instance, component);
3794 + component->enabled = false;
3796 + mutex_unlock(&instance->vchiq_mutex);
3800 +EXPORT_SYMBOL_GPL(vchiq_mmal_component_disable);
3802 +int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
3803 + u32 *major_out, u32 *minor_out)
3807 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3810 + ret = get_version(instance, major_out, minor_out);
3812 + mutex_unlock(&instance->vchiq_mutex);
3816 +EXPORT_SYMBOL_GPL(vchiq_mmal_version);
3818 +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
3825 + if (mutex_lock_interruptible(&instance->vchiq_mutex))
3828 + vchi_service_use(instance->handle);
3830 + status = vchi_service_close(instance->handle);
3832 + pr_err("mmal-vchiq: VCHIQ close failed\n");
3834 + mutex_unlock(&instance->vchiq_mutex);
3836 + flush_workqueue(instance->bulk_wq);
3837 + destroy_workqueue(instance->bulk_wq);
3839 + vfree(instance->bulk_scratch);
3841 + idr_destroy(&instance->context_map);
3847 +EXPORT_SYMBOL_GPL(vchiq_mmal_finalise);
3849 +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
3852 + struct vchiq_mmal_instance *instance;
3853 + static VCHI_CONNECTION_T *vchi_connection;
3854 + static VCHI_INSTANCE_T vchi_instance;
3855 + SERVICE_CREATION_T params = {
3856 + .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER),
3857 + .service_id = VC_MMAL_SERVER_NAME,
3858 + .connection = vchi_connection,
3859 + .rx_fifo_size = 0,
3860 + .tx_fifo_size = 0,
3861 + .callback = service_callback,
3862 + .callback_param = NULL,
3863 + .want_unaligned_bulk_rx = 1,
3864 + .want_unaligned_bulk_tx = 1,
3868 + /* compile time checks to ensure structure size as they are
3869 + * directly (de)serialised from memory.
3872 + /* ensure the header structure has packed to the correct size */
3873 + BUILD_BUG_ON(sizeof(struct mmal_msg_header) != 24);
3875 + /* ensure message structure does not exceed maximum length */
3876 + BUILD_BUG_ON(sizeof(struct mmal_msg) > MMAL_MSG_MAX_SIZE);
3878 + /* mmal port struct is correct size */
3879 + BUILD_BUG_ON(sizeof(struct mmal_port) != 64);
3881 + /* create a vchi instance */
3882 + status = vchi_initialise(&vchi_instance);
3884 + pr_err("Failed to initialise VCHI instance (status=%d)\n",
3889 + status = vchi_connect(NULL, 0, vchi_instance);
3891 + pr_err("Failed to connect VCHI instance (status=%d)\n", status);
3895 + instance = kzalloc(sizeof(*instance), GFP_KERNEL);
3900 + mutex_init(&instance->vchiq_mutex);
3902 + instance->bulk_scratch = vmalloc(PAGE_SIZE);
3904 + spin_lock_init(&instance->context_map_lock);
3905 + idr_init_base(&instance->context_map, 1);
3907 + params.callback_param = instance;
3909 + instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq",
3911 + if (!instance->bulk_wq)
3914 + status = vchi_service_open(vchi_instance, ¶ms, &instance->handle);
3916 + pr_err("Failed to open VCHI service connection (status=%d)\n",
3918 + goto err_close_services;
3921 + vchi_service_release(instance->handle);
3923 + *out_instance = instance;
3927 +err_close_services:
3928 + vchi_service_close(instance->handle);
3929 + destroy_workqueue(instance->bulk_wq);
3931 + vfree(instance->bulk_scratch);
3935 +EXPORT_SYMBOL_GPL(vchiq_mmal_init);
3936 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h
3939 -/* SPDX-License-Identifier: GPL-2.0 */
3941 - * Broadcom BM2835 V4L2 driver
3943 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
3945 - * Authors: Vincent Sanders @ Collabora
3946 - * Dave Stevenson @ Broadcom
3947 - * (now dave.stevenson@raspberrypi.org)
3948 - * Simon Mellor @ Broadcom
3949 - * Luke Diamand @ Broadcom
3954 -#ifndef MMAL_COMMON_H
3955 -#define MMAL_COMMON_H
3957 -#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))
3958 -#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
3960 -/** Special value signalling that time is not known */
3961 -#define MMAL_TIME_UNKNOWN BIT_ULL(63)
3963 -struct mmal_msg_context;
3965 -/* mapping between v4l and mmal video modes */
3968 - u32 fourcc; /* v4l2 format id */
3969 - int flags; /* v4l2 flags field */
3972 - u32 mmal_component; /* MMAL component index to be used to encode */
3973 - u32 ybbp; /* depth of first Y plane for planar formats */
3974 - bool remove_padding; /* Does the GPU have to remove padding,
3975 - * or can we do hide padding via bytesperline.
3979 -/* buffer for one video frame */
3980 -struct mmal_buffer {
3981 - /* v4l buffer data -- must be first */
3982 - struct vb2_v4l2_buffer vb;
3984 - /* list of buffers available */
3985 - struct list_head list;
3987 - void *buffer; /* buffer pointer */
3988 - unsigned long buffer_size; /* size of allocated buffer */
3990 - struct mmal_msg_context *msg_context;
3994 -struct mmal_colourfx {
4000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h
4003 -/* SPDX-License-Identifier: GPL-2.0 */
4005 - * Broadcom BM2835 V4L2 driver
4007 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4009 - * Authors: Vincent Sanders @ Collabora
4010 - * Dave Stevenson @ Broadcom
4011 - * (now dave.stevenson@raspberrypi.org)
4012 - * Simon Mellor @ Broadcom
4013 - * Luke Diamand @ Broadcom
4015 -#ifndef MMAL_ENCODINGS_H
4016 -#define MMAL_ENCODINGS_H
4018 -#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4')
4019 -#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3')
4020 -#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V')
4021 -#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V')
4022 -#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V')
4023 -#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3')
4024 -#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2')
4025 -#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1')
4026 -#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1')
4027 -#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ')
4028 -#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ')
4029 -#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ')
4030 -#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O')
4031 -#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K')
4032 -#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G')
4034 -#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G')
4035 -#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ')
4036 -#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ')
4037 -#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ')
4038 -#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ')
4039 -#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ')
4041 -#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0')
4042 -#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0')
4043 -#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2')
4044 -#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2')
4045 -#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2')
4046 -#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V')
4047 -#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U')
4048 -#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y')
4049 -#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y')
4050 -#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2')
4051 -#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1')
4052 -#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B')
4053 -#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A')
4054 -#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R')
4055 -#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A')
4056 -#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2')
4057 -#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3')
4058 -#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4')
4059 -#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2')
4060 -#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3')
4061 -#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4')
4063 -/** SAND Video (YUVUV128) format, native format understood by VideoCore.
4064 - * This format is *not* opaque - if requested you will receive full frames
4065 - * of YUV_UV video.
4067 -#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D')
4069 -/** VideoCore opaque image format, image handles are returned to
4070 - * the host but not the actual image data.
4072 -#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V')
4074 -/** An EGL image handle
4076 -#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I')
4080 -/** \name Pre-defined audio encodings */
4082 -#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U')
4083 -#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u')
4084 -#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S')
4085 -#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's')
4086 -#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F')
4087 -#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f')
4089 -/* Pre-defined H264 encoding variants */
4091 -/** ISO 14496-10 Annex B byte stream format */
4092 -#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0
4093 -/** ISO 14496-15 AVC stream format */
4094 -#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1')
4095 -/** Implicitly delineated NAL units without emulation prevention */
4096 -#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ')
4098 -/** \defgroup MmalColorSpace List of pre-defined video color spaces
4099 - * This defines a list of common color spaces. This list isn't exhaustive and
4100 - * is only provided as a convenience to avoid clients having to use FourCC
4101 - * codes directly. However components are allowed to define and use their own
4106 -/** Unknown color space */
4107 -#define MMAL_COLOR_SPACE_UNKNOWN 0
4108 -/** ITU-R BT.601-5 [SDTV] */
4109 -#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1')
4110 -/** ITU-R BT.709-3 [HDTV] */
4111 -#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9')
4113 -#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I')
4114 -/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
4115 -#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C')
4116 -/** Society of Motion Picture and Television Engineers 240M (1999) */
4117 -#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0')
4118 -/** ITU-R BT.470-2 System M */
4119 -#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M')
4120 -/** ITU-R BT.470-2 System BG */
4121 -#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G')
4122 -/** JPEG JFIF, but with 16..255 luma */
4123 -#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6')
4124 -/* @} MmalColorSpace List */
4126 -#endif /* MMAL_ENCODINGS_H */
4127 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h
4130 -/* SPDX-License-Identifier: GPL-2.0 */
4132 - * Broadcom BM2835 V4L2 driver
4134 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4136 - * Authors: Vincent Sanders @ Collabora
4137 - * Dave Stevenson @ Broadcom
4138 - * (now dave.stevenson@raspberrypi.org)
4139 - * Simon Mellor @ Broadcom
4140 - * Luke Diamand @ Broadcom
4143 -#ifndef MMAL_MSG_COMMON_H
4144 -#define MMAL_MSG_COMMON_H
4146 -enum mmal_msg_status {
4147 - MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */
4148 - MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */
4149 - MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */
4150 - MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */
4151 - MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */
4152 - MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */
4153 - MMAL_MSG_STATUS_ENXIO, /**< No such device or address */
4154 - MMAL_MSG_STATUS_EIO, /**< I/O error */
4155 - MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */
4156 - MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */
4157 - MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */
4158 - MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */
4159 - MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */
4160 - MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */
4161 - MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */
4162 - MMAL_MSG_STATUS_EFAULT, /**< Bad address */
4166 - s32 x; /**< x coordinate (from left) */
4167 - s32 y; /**< y coordinate (from top) */
4168 - s32 width; /**< width */
4169 - s32 height; /**< height */
4172 -struct mmal_rational {
4173 - s32 num; /**< Numerator */
4174 - s32 den; /**< Denominator */
4177 -#endif /* MMAL_MSG_COMMON_H */
4178 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h
4181 -/* SPDX-License-Identifier: GPL-2.0 */
4183 - * Broadcom BM2835 V4L2 driver
4185 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4187 - * Authors: Vincent Sanders @ Collabora
4188 - * Dave Stevenson @ Broadcom
4189 - * (now dave.stevenson@raspberrypi.org)
4190 - * Simon Mellor @ Broadcom
4191 - * Luke Diamand @ Broadcom
4194 -#ifndef MMAL_MSG_FORMAT_H
4195 -#define MMAL_MSG_FORMAT_H
4197 -#include "mmal-msg-common.h"
4199 -/* MMAL_ES_FORMAT_T */
4201 -struct mmal_audio_format {
4202 - u32 channels; /* Number of audio channels */
4203 - u32 sample_rate; /* Sample rate */
4205 - u32 bits_per_sample; /* Bits per sample */
4206 - u32 block_align; /* Size of a block of data */
4209 -struct mmal_video_format {
4210 - u32 width; /* Width of frame in pixels */
4211 - u32 height; /* Height of frame in rows of pixels */
4212 - struct mmal_rect crop; /* Visible region of the frame */
4213 - struct mmal_rational frame_rate; /* Frame rate */
4214 - struct mmal_rational par; /* Pixel aspect ratio */
4217 - * FourCC specifying the color space of the video stream. See the
4218 - * MmalColorSpace "pre-defined color spaces" for some examples.
4223 -struct mmal_subpicture_format {
4228 -union mmal_es_specific_format {
4229 - struct mmal_audio_format audio;
4230 - struct mmal_video_format video;
4231 - struct mmal_subpicture_format subpicture;
4234 -/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */
4235 -struct mmal_es_format_local {
4236 - u32 type; /* enum mmal_es_type */
4238 - u32 encoding; /* FourCC specifying encoding of the elementary
4241 - u32 encoding_variant; /* FourCC specifying the specific
4242 - * encoding variant of the elementary
4246 - union mmal_es_specific_format *es; /* Type specific
4247 - * information for the
4248 - * elementary stream
4251 - u32 bitrate; /* Bitrate in bits per second */
4252 - u32 flags; /* Flags describing properties of the elementary
4256 - u32 extradata_size; /* Size of the codec specific data */
4257 - u8 *extradata; /* Codec specific data */
4260 -/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */
4261 -struct mmal_es_format {
4262 - u32 type; /* enum mmal_es_type */
4264 - u32 encoding; /* FourCC specifying encoding of the elementary
4267 - u32 encoding_variant; /* FourCC specifying the specific
4268 - * encoding variant of the elementary
4272 - u32 es; /* Type specific
4273 - * information for the
4274 - * elementary stream
4277 - u32 bitrate; /* Bitrate in bits per second */
4278 - u32 flags; /* Flags describing properties of the elementary
4282 - u32 extradata_size; /* Size of the codec specific data */
4283 - u32 extradata; /* Codec specific data */
4286 -#endif /* MMAL_MSG_FORMAT_H */
4287 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h
4290 -/* SPDX-License-Identifier: GPL-2.0 */
4292 - * Broadcom BM2835 V4L2 driver
4294 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4296 - * Authors: Vincent Sanders @ Collabora
4297 - * Dave Stevenson @ Broadcom
4298 - * (now dave.stevenson@raspberrypi.org)
4299 - * Simon Mellor @ Broadcom
4300 - * Luke Diamand @ Broadcom
4303 -/* MMAL_PORT_TYPE_T */
4304 -enum mmal_port_type {
4305 - MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */
4306 - MMAL_PORT_TYPE_CONTROL, /* Control port */
4307 - MMAL_PORT_TYPE_INPUT, /* Input port */
4308 - MMAL_PORT_TYPE_OUTPUT, /* Output port */
4309 - MMAL_PORT_TYPE_CLOCK, /* Clock port */
4312 -/* The port is pass-through and doesn't need buffer headers allocated */
4313 -#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01
4315 - *The port wants to allocate the buffer payloads.
4316 - * This signals a preference that payload allocation should be done
4317 - * on this port for efficiency reasons.
4319 -#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02
4321 - * The port supports format change events.
4322 - * This applies to input ports and is used to let the client know
4323 - * whether the port supports being reconfigured via a format
4324 - * change event (i.e. without having to disable the port).
4326 -#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04
4329 - * mmal port structure (MMAL_PORT_T)
4331 - * most elements are informational only, the pointer values for
4332 - * interogation messages are generally provided as additional
4333 - * structures within the message. When used to set values only the
4334 - * buffer_num, buffer_size and userdata parameters are writable.
4337 - u32 priv; /* Private member used by the framework */
4338 - u32 name; /* Port name. Used for debugging purposes (RO) */
4340 - u32 type; /* Type of the port (RO) enum mmal_port_type */
4341 - u16 index; /* Index of the port in its type list (RO) */
4342 - u16 index_all; /* Index of the port in the list of all ports (RO) */
4344 - u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */
4345 - u32 format; /* Format of the elementary stream */
4347 - u32 buffer_num_min; /* Minimum number of buffers the port
4348 - * requires (RO). This is set by the
4352 - u32 buffer_size_min; /* Minimum size of buffers the port
4353 - * requires (RO). This is set by the
4357 - u32 buffer_alignment_min;/* Minimum alignment requirement for
4358 - * the buffers (RO). A value of
4359 - * zero means no special alignment
4360 - * requirements. This is set by the
4364 - u32 buffer_num_recommended; /* Number of buffers the port
4365 - * recommends for optimal
4366 - * performance (RO). A value of
4367 - * zero means no special
4368 - * recommendation. This is set
4369 - * by the component.
4372 - u32 buffer_size_recommended; /* Size of buffers the port
4373 - * recommends for optimal
4374 - * performance (RO). A value of
4375 - * zero means no special
4376 - * recommendation. This is set
4377 - * by the component.
4380 - u32 buffer_num; /* Actual number of buffers the port will use.
4381 - * This is set by the client.
4384 - u32 buffer_size; /* Actual maximum size of the buffers that
4385 - * will be sent to the port. This is set by
4389 - u32 component; /* Component this port belongs to (Read Only) */
4391 - u32 userdata; /* Field reserved for use by the client */
4393 - u32 capabilities; /* Flags describing the capabilities of a
4394 - * port (RO). Bitwise combination of \ref
4395 - * portcapabilities "Port capabilities"
4399 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h
4402 -/* SPDX-License-Identifier: GPL-2.0 */
4404 - * Broadcom BM2835 V4L2 driver
4406 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4408 - * Authors: Vincent Sanders @ Collabora
4409 - * Dave Stevenson @ Broadcom
4410 - * (now dave.stevenson@raspberrypi.org)
4411 - * Simon Mellor @ Broadcom
4412 - * Luke Diamand @ Broadcom
4416 - * all the data structures which serialise the MMAL protocol. note
4417 - * these are directly mapped onto the recived message data.
4419 - * BEWARE: They seem to *assume* pointers are u32 and that there is no
4420 - * structure padding!
4422 - * NOTE: this implementation uses kernel types to ensure sizes. Rather
4423 - * than assigning values to enums to force their size the
4424 - * implementation uses fixed size types and not the enums (though the
4425 - * comments have the actual enum type
4430 -#define VC_MMAL_VER 15
4431 -#define VC_MMAL_MIN_VER 10
4432 -#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal")
4434 -/* max total message size is 512 bytes */
4435 -#define MMAL_MSG_MAX_SIZE 512
4436 -/* with six 32bit header elements max payload is therefore 488 bytes */
4437 -#define MMAL_MSG_MAX_PAYLOAD 488
4439 -#include "mmal-msg-common.h"
4440 -#include "mmal-msg-format.h"
4441 -#include "mmal-msg-port.h"
4443 -enum mmal_msg_type {
4444 - MMAL_MSG_TYPE_QUIT = 1,
4445 - MMAL_MSG_TYPE_SERVICE_CLOSED,
4446 - MMAL_MSG_TYPE_GET_VERSION,
4447 - MMAL_MSG_TYPE_COMPONENT_CREATE,
4448 - MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */
4449 - MMAL_MSG_TYPE_COMPONENT_ENABLE,
4450 - MMAL_MSG_TYPE_COMPONENT_DISABLE,
4451 - MMAL_MSG_TYPE_PORT_INFO_GET,
4452 - MMAL_MSG_TYPE_PORT_INFO_SET,
4453 - MMAL_MSG_TYPE_PORT_ACTION, /* 10 */
4454 - MMAL_MSG_TYPE_BUFFER_FROM_HOST,
4455 - MMAL_MSG_TYPE_BUFFER_TO_HOST,
4456 - MMAL_MSG_TYPE_GET_STATS,
4457 - MMAL_MSG_TYPE_PORT_PARAMETER_SET,
4458 - MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */
4459 - MMAL_MSG_TYPE_EVENT_TO_HOST,
4460 - MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
4461 - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
4462 - MMAL_MSG_TYPE_CONSUME_MEM,
4463 - MMAL_MSG_TYPE_LMK, /* 20 */
4464 - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
4465 - MMAL_MSG_TYPE_DRM_GET_LHS32,
4466 - MMAL_MSG_TYPE_DRM_GET_TIME,
4467 - MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
4468 - MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */
4469 - MMAL_MSG_TYPE_HOST_LOG,
4470 - MMAL_MSG_TYPE_MSG_LAST
4473 -/* port action request messages differ depending on the action type */
4474 -enum mmal_msg_port_action_type {
4475 - MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */
4476 - MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
4477 - MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
4478 - MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
4479 - MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */
4480 - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */
4481 - MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/
4484 -struct mmal_msg_header {
4486 - u32 type; /* enum mmal_msg_type */
4488 - /* Opaque handle to the control service */
4489 - u32 control_service;
4491 - u32 context; /* a u32 per message context */
4492 - u32 status; /* The status of the vchiq operation */
4496 -/* Send from VC to host to report version */
4497 -struct mmal_msg_version {
4504 -/* request to VC to create component */
4505 -struct mmal_msg_component_create {
4506 - u32 client_component; /* component context */
4508 - u32 pid; /* For debug */
4511 -/* reply from VC to component creation request */
4512 -struct mmal_msg_component_create_reply {
4513 - u32 status; /* enum mmal_msg_status - how does this differ to
4514 - * the one in the header?
4516 - u32 component_handle; /* VideoCore handle for component */
4517 - u32 input_num; /* Number of input ports */
4518 - u32 output_num; /* Number of output ports */
4519 - u32 clock_num; /* Number of clock ports */
4522 -/* request to VC to destroy a component */
4523 -struct mmal_msg_component_destroy {
4524 - u32 component_handle;
4527 -struct mmal_msg_component_destroy_reply {
4528 - u32 status; /* The component destruction status */
4531 -/* request and reply to VC to enable a component */
4532 -struct mmal_msg_component_enable {
4533 - u32 component_handle;
4536 -struct mmal_msg_component_enable_reply {
4537 - u32 status; /* The component enable status */
4540 -/* request and reply to VC to disable a component */
4541 -struct mmal_msg_component_disable {
4542 - u32 component_handle;
4545 -struct mmal_msg_component_disable_reply {
4546 - u32 status; /* The component disable status */
4549 -/* request to VC to get port information */
4550 -struct mmal_msg_port_info_get {
4551 - u32 component_handle; /* component handle port is associated with */
4552 - u32 port_type; /* enum mmal_msg_port_type */
4553 - u32 index; /* port index to query */
4556 -/* reply from VC to get port info request */
4557 -struct mmal_msg_port_info_get_reply {
4558 - u32 status; /* enum mmal_msg_status */
4559 - u32 component_handle; /* component handle port is associated with */
4560 - u32 port_type; /* enum mmal_msg_port_type */
4561 - u32 port_index; /* port indexed in query */
4562 - s32 found; /* unused */
4563 - u32 port_handle; /* Handle to use for this port */
4564 - struct mmal_port port;
4565 - struct mmal_es_format format; /* elementary stream format */
4566 - union mmal_es_specific_format es; /* es type specific data */
4567 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */
4570 -/* request to VC to set port information */
4571 -struct mmal_msg_port_info_set {
4572 - u32 component_handle;
4573 - u32 port_type; /* enum mmal_msg_port_type */
4574 - u32 port_index; /* port indexed in query */
4575 - struct mmal_port port;
4576 - struct mmal_es_format format;
4577 - union mmal_es_specific_format es;
4578 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
4581 -/* reply from VC to port info set request */
4582 -struct mmal_msg_port_info_set_reply {
4584 - u32 component_handle; /* component handle port is associated with */
4585 - u32 port_type; /* enum mmal_msg_port_type */
4586 - u32 index; /* port indexed in query */
4587 - s32 found; /* unused */
4588 - u32 port_handle; /* Handle to use for this port */
4589 - struct mmal_port port;
4590 - struct mmal_es_format format;
4591 - union mmal_es_specific_format es;
4592 - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
4595 -/* port action requests that take a mmal_port as a parameter */
4596 -struct mmal_msg_port_action_port {
4597 - u32 component_handle;
4599 - u32 action; /* enum mmal_msg_port_action_type */
4600 - struct mmal_port port;
4603 -/* port action requests that take handles as a parameter */
4604 -struct mmal_msg_port_action_handle {
4605 - u32 component_handle;
4607 - u32 action; /* enum mmal_msg_port_action_type */
4608 - u32 connect_component_handle;
4609 - u32 connect_port_handle;
4612 -struct mmal_msg_port_action_reply {
4613 - u32 status; /* The port action operation status */
4616 -/* MMAL buffer transfer */
4618 -/* Size of space reserved in a buffer message for short messages. */
4619 -#define MMAL_VC_SHORT_DATA 128
4621 -/* Signals that the current payload is the end of the stream of data */
4622 -#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0)
4623 -/* Signals that the start of the current payload starts a frame */
4624 -#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1)
4625 -/* Signals that the end of the current payload ends a frame */
4626 -#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2)
4627 -/* Signals that the current payload contains only complete frames (>1) */
4628 -#define MMAL_BUFFER_HEADER_FLAG_FRAME \
4629 - (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \
4630 - MMAL_BUFFER_HEADER_FLAG_FRAME_END)
4631 -/* Signals that the current payload is a keyframe (i.e. self decodable) */
4632 -#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3)
4634 - * Signals a discontinuity in the stream of data (e.g. after a seek).
4635 - * Can be used for instance by a decoder to reset its state
4637 -#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4)
4639 - * Signals a buffer containing some kind of config data for the component
4640 - * (e.g. codec config data)
4642 -#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5)
4643 -/* Signals an encrypted payload */
4644 -#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6)
4645 -/* Signals a buffer containing side information */
4646 -#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7)
4648 - * Signals a buffer which is the snapshot/postview image from a stills
4651 -#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8)
4652 -/* Signals a buffer which contains data known to be corrupted */
4653 -#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9)
4654 -/* Signals that a buffer failed to be transmitted */
4655 -#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10)
4657 -struct mmal_driver_buffer {
4659 - u32 component_handle;
4661 - u32 client_context;
4664 -/* buffer header */
4665 -struct mmal_buffer_header {
4666 - u32 next; /* next header */
4667 - u32 priv; /* framework private data */
4680 -struct mmal_buffer_header_type_specific {
4691 -struct mmal_msg_buffer_from_host {
4693 - *The front 32 bytes of the buffer header are copied
4694 - * back to us in the reply to allow for context. This
4695 - * area is used to store two mmal_driver_buffer structures to
4696 - * allow for multiple concurrent service users.
4698 - /* control data */
4699 - struct mmal_driver_buffer drvbuf;
4701 - /* referenced control data for passthrough buffer management */
4702 - struct mmal_driver_buffer drvbuf_ref;
4703 - struct mmal_buffer_header buffer_header; /* buffer header itself */
4704 - struct mmal_buffer_header_type_specific buffer_header_type_specific;
4706 - s32 has_reference;
4708 - /* allows short data to be xfered in control message */
4709 - u32 payload_in_message;
4710 - u8 short_data[MMAL_VC_SHORT_DATA];
4713 -/* port parameter setting */
4715 -#define MMAL_WORKER_PORT_PARAMETER_SPACE 96
4717 -struct mmal_msg_port_parameter_set {
4718 - u32 component_handle; /* component */
4719 - u32 port_handle; /* port */
4720 - u32 id; /* Parameter ID */
4721 - u32 size; /* Parameter size */
4722 - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
4725 -struct mmal_msg_port_parameter_set_reply {
4726 - u32 status; /* enum mmal_msg_status todo: how does this
4727 - * differ to the one in the header?
4731 -/* port parameter getting */
4733 -struct mmal_msg_port_parameter_get {
4734 - u32 component_handle; /* component */
4735 - u32 port_handle; /* port */
4736 - u32 id; /* Parameter ID */
4737 - u32 size; /* Parameter size */
4740 -struct mmal_msg_port_parameter_get_reply {
4741 - u32 status; /* Status of mmal_port_parameter_get call */
4742 - u32 id; /* Parameter ID */
4743 - u32 size; /* Parameter size */
4744 - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
4747 -/* event messages */
4748 -#define MMAL_WORKER_EVENT_SPACE 256
4750 -struct mmal_msg_event_to_host {
4751 - u32 client_component; /* component context */
4758 - u8 data[MMAL_WORKER_EVENT_SPACE];
4759 - u32 delayed_buffer;
4762 -/* all mmal messages are serialised through this structure */
4765 - struct mmal_msg_header h;
4768 - struct mmal_msg_version version;
4770 - struct mmal_msg_component_create component_create;
4771 - struct mmal_msg_component_create_reply component_create_reply;
4773 - struct mmal_msg_component_destroy component_destroy;
4774 - struct mmal_msg_component_destroy_reply component_destroy_reply;
4776 - struct mmal_msg_component_enable component_enable;
4777 - struct mmal_msg_component_enable_reply component_enable_reply;
4779 - struct mmal_msg_component_disable component_disable;
4780 - struct mmal_msg_component_disable_reply component_disable_reply;
4782 - struct mmal_msg_port_info_get port_info_get;
4783 - struct mmal_msg_port_info_get_reply port_info_get_reply;
4785 - struct mmal_msg_port_info_set port_info_set;
4786 - struct mmal_msg_port_info_set_reply port_info_set_reply;
4788 - struct mmal_msg_port_action_port port_action_port;
4789 - struct mmal_msg_port_action_handle port_action_handle;
4790 - struct mmal_msg_port_action_reply port_action_reply;
4792 - struct mmal_msg_buffer_from_host buffer_from_host;
4794 - struct mmal_msg_port_parameter_set port_parameter_set;
4795 - struct mmal_msg_port_parameter_set_reply
4796 - port_parameter_set_reply;
4797 - struct mmal_msg_port_parameter_get
4798 - port_parameter_get;
4799 - struct mmal_msg_port_parameter_get_reply
4800 - port_parameter_get_reply;
4802 - struct mmal_msg_event_to_host event_to_host;
4804 - u8 payload[MMAL_MSG_MAX_PAYLOAD];
4808 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h
4811 -/* SPDX-License-Identifier: GPL-2.0 */
4813 - * Broadcom BM2835 V4L2 driver
4815 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
4817 - * Authors: Vincent Sanders @ Collabora
4818 - * Dave Stevenson @ Broadcom
4819 - * (now dave.stevenson@raspberrypi.org)
4820 - * Simon Mellor @ Broadcom
4821 - * Luke Diamand @ Broadcom
4824 -/* common parameters */
4826 -/** @name Parameter groups
4827 - * Parameters are divided into groups, and then allocated sequentially within
4828 - * a group using an enum.
4832 -#ifndef MMAL_PARAMETERS_H
4833 -#define MMAL_PARAMETERS_H
4835 -/** Common parameter ID group, used with many types of component. */
4836 -#define MMAL_PARAMETER_GROUP_COMMON (0 << 16)
4837 -/** Camera-specific parameter ID group. */
4838 -#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16)
4839 -/** Video-specific parameter ID group. */
4840 -#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16)
4841 -/** Audio-specific parameter ID group. */
4842 -#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16)
4843 -/** Clock-specific parameter ID group. */
4844 -#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16)
4845 -/** Miracast-specific parameter ID group. */
4846 -#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16)
4848 -/* Common parameters */
4849 -enum mmal_parameter_common_type {
4850 - /**< Never a valid parameter ID */
4851 - MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON,
4853 - /**< MMAL_PARAMETER_ENCODING_T */
4854 - MMAL_PARAMETER_SUPPORTED_ENCODINGS,
4855 - /**< MMAL_PARAMETER_URI_T */
4856 - MMAL_PARAMETER_URI,
4857 - /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */
4858 - MMAL_PARAMETER_CHANGE_EVENT_REQUEST,
4859 - /** MMAL_PARAMETER_BOOLEAN_T */
4860 - MMAL_PARAMETER_ZERO_COPY,
4861 - /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */
4862 - MMAL_PARAMETER_BUFFER_REQUIREMENTS,
4863 - /**< MMAL_PARAMETER_STATISTICS_T */
4864 - MMAL_PARAMETER_STATISTICS,
4865 - /**< MMAL_PARAMETER_CORE_STATISTICS_T */
4866 - MMAL_PARAMETER_CORE_STATISTICS,
4867 - /**< MMAL_PARAMETER_MEM_USAGE_T */
4868 - MMAL_PARAMETER_MEM_USAGE,
4869 - /**< MMAL_PARAMETER_UINT32_T */
4870 - MMAL_PARAMETER_BUFFER_FLAG_FILTER,
4871 - /**< MMAL_PARAMETER_SEEK_T */
4872 - MMAL_PARAMETER_SEEK,
4873 - /**< MMAL_PARAMETER_BOOLEAN_T */
4874 - MMAL_PARAMETER_POWERMON_ENABLE,
4875 - /**< MMAL_PARAMETER_LOGGING_T */
4876 - MMAL_PARAMETER_LOGGING,
4877 - /**< MMAL_PARAMETER_UINT64_T */
4878 - MMAL_PARAMETER_SYSTEM_TIME,
4879 - /**< MMAL_PARAMETER_BOOLEAN_T */
4880 - MMAL_PARAMETER_NO_IMAGE_PADDING,
4883 -/* camera parameters */
4885 -enum mmal_parameter_camera_type {
4887 - /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */
4888 - MMAL_PARAMETER_THUMBNAIL_CONFIGURATION =
4889 - MMAL_PARAMETER_GROUP_CAMERA,
4891 - MMAL_PARAMETER_CAPTURE_QUALITY,
4892 - /**< @ref MMAL_PARAMETER_INT32_T */
4893 - MMAL_PARAMETER_ROTATION,
4894 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4895 - MMAL_PARAMETER_EXIF_DISABLE,
4896 - /**< @ref MMAL_PARAMETER_EXIF_T */
4897 - MMAL_PARAMETER_EXIF,
4898 - /**< @ref MMAL_PARAM_AWBMODE_T */
4899 - MMAL_PARAMETER_AWB_MODE,
4900 - /**< @ref MMAL_PARAMETER_IMAGEFX_T */
4901 - MMAL_PARAMETER_IMAGE_EFFECT,
4902 - /**< @ref MMAL_PARAMETER_COLOURFX_T */
4903 - MMAL_PARAMETER_COLOUR_EFFECT,
4904 - /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */
4905 - MMAL_PARAMETER_FLICKER_AVOID,
4906 - /**< @ref MMAL_PARAMETER_FLASH_T */
4907 - MMAL_PARAMETER_FLASH,
4908 - /**< @ref MMAL_PARAMETER_REDEYE_T */
4909 - MMAL_PARAMETER_REDEYE,
4910 - /**< @ref MMAL_PARAMETER_FOCUS_T */
4911 - MMAL_PARAMETER_FOCUS,
4913 - MMAL_PARAMETER_FOCAL_LENGTHS,
4914 - /**< @ref MMAL_PARAMETER_INT32_T */
4915 - MMAL_PARAMETER_EXPOSURE_COMP,
4916 - /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */
4917 - MMAL_PARAMETER_ZOOM,
4918 - /**< @ref MMAL_PARAMETER_MIRROR_T */
4919 - MMAL_PARAMETER_MIRROR,
4922 - /**< @ref MMAL_PARAMETER_UINT32_T */
4923 - MMAL_PARAMETER_CAMERA_NUM,
4924 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4925 - MMAL_PARAMETER_CAPTURE,
4926 - /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */
4927 - MMAL_PARAMETER_EXPOSURE_MODE,
4928 - /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */
4929 - MMAL_PARAMETER_EXP_METERING_MODE,
4930 - /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */
4931 - MMAL_PARAMETER_FOCUS_STATUS,
4932 - /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */
4933 - MMAL_PARAMETER_CAMERA_CONFIG,
4934 - /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */
4935 - MMAL_PARAMETER_CAPTURE_STATUS,
4936 - /**< @ref MMAL_PARAMETER_FACE_TRACK_T */
4937 - MMAL_PARAMETER_FACE_TRACK,
4938 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4939 - MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS,
4940 - /**< @ref MMAL_PARAMETER_UINT32_T */
4941 - MMAL_PARAMETER_JPEG_Q_FACTOR,
4942 - /**< @ref MMAL_PARAMETER_FRAME_RATE_T */
4943 - MMAL_PARAMETER_FRAME_RATE,
4944 - /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */
4945 - MMAL_PARAMETER_USE_STC,
4946 - /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */
4947 - MMAL_PARAMETER_CAMERA_INFO,
4948 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4949 - MMAL_PARAMETER_VIDEO_STABILISATION,
4950 - /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */
4951 - MMAL_PARAMETER_FACE_TRACK_RESULTS,
4952 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4953 - MMAL_PARAMETER_ENABLE_RAW_CAPTURE,
4956 - /**< @ref MMAL_PARAMETER_URI_T */
4957 - MMAL_PARAMETER_DPF_FILE,
4958 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4959 - MMAL_PARAMETER_ENABLE_DPF_FILE,
4960 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4961 - MMAL_PARAMETER_DPF_FAIL_IS_FATAL,
4962 - /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */
4963 - MMAL_PARAMETER_CAPTURE_MODE,
4964 - /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */
4965 - MMAL_PARAMETER_FOCUS_REGIONS,
4966 - /**< @ref MMAL_PARAMETER_INPUT_CROP_T */
4967 - MMAL_PARAMETER_INPUT_CROP,
4968 - /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */
4969 - MMAL_PARAMETER_SENSOR_INFORMATION,
4970 - /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */
4971 - MMAL_PARAMETER_FLASH_SELECT,
4972 - /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */
4973 - MMAL_PARAMETER_FIELD_OF_VIEW,
4974 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4975 - MMAL_PARAMETER_HIGH_DYNAMIC_RANGE,
4976 - /**< @ref MMAL_PARAMETER_DRC_T */
4977 - MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION,
4978 - /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */
4979 - MMAL_PARAMETER_ALGORITHM_CONTROL,
4980 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4981 - MMAL_PARAMETER_SHARPNESS,
4982 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4983 - MMAL_PARAMETER_CONTRAST,
4984 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4985 - MMAL_PARAMETER_BRIGHTNESS,
4986 - /**< @ref MMAL_PARAMETER_RATIONAL_T */
4987 - MMAL_PARAMETER_SATURATION,
4990 - /**< @ref MMAL_PARAMETER_UINT32_T */
4991 - MMAL_PARAMETER_ISO,
4992 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
4993 - MMAL_PARAMETER_ANTISHAKE,
4994 - /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */
4995 - MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,
4996 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
4997 - MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
4998 - /** @ref MMAL_PARAMETER_UINT32_T */
4999 - MMAL_PARAMETER_CAMERA_MIN_ISO,
5000 - /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */
5001 - MMAL_PARAMETER_CAMERA_USE_CASE,
5002 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5003 - MMAL_PARAMETER_CAPTURE_STATS_PASS,
5004 - /** @ref MMAL_PARAMETER_UINT32_T */
5005 - MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG,
5006 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5007 - MMAL_PARAMETER_ENABLE_REGISTER_FILE,
5008 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5009 - MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
5010 - /** @ref MMAL_PARAMETER_CONFIGFILE_T */
5011 - MMAL_PARAMETER_CONFIGFILE_REGISTERS,
5012 - /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */
5013 - MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS,
5014 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5015 - MMAL_PARAMETER_JPEG_ATTACH_LOG,
5016 - /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */
5017 - MMAL_PARAMETER_ZERO_SHUTTER_LAG,
5018 - /**< @ref MMAL_PARAMETER_FPS_RANGE_T */
5019 - MMAL_PARAMETER_FPS_RANGE,
5020 - /**< @ref MMAL_PARAMETER_INT32_T */
5021 - MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP,
5024 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5025 - MMAL_PARAMETER_SW_SHARPEN_DISABLE,
5026 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5027 - MMAL_PARAMETER_FLASH_REQUIRED,
5028 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5029 - MMAL_PARAMETER_SW_SATURATION_DISABLE,
5030 - /**< Takes a @ref MMAL_PARAMETER_UINT32_T */
5031 - MMAL_PARAMETER_SHUTTER_SPEED,
5032 - /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */
5033 - MMAL_PARAMETER_CUSTOM_AWB_GAINS,
5036 -struct mmal_parameter_rational {
5037 - s32 num; /**< Numerator */
5038 - s32 den; /**< Denominator */
5041 -enum mmal_parameter_camera_config_timestamp_mode {
5042 - MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */
5043 - MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value
5044 - * for the frame timestamp
5046 - MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp
5047 - * but subtract the
5048 - * timestamp of the first
5049 - * frame sent to give a
5050 - * zero based timestamp.
5054 -struct mmal_parameter_fps_range {
5055 - /**< Low end of the permitted framerate range */
5056 - struct mmal_parameter_rational fps_low;
5057 - /**< High end of the permitted framerate range */
5058 - struct mmal_parameter_rational fps_high;
5061 -/* camera configuration parameter */
5062 -struct mmal_parameter_camera_config {
5063 - /* Parameters for setting up the image pools */
5064 - u32 max_stills_w; /* Max size of stills capture */
5066 - u32 stills_yuv422; /* Allow YUV422 stills capture */
5067 - u32 one_shot_stills; /* Continuous or one shot stills captures. */
5069 - u32 max_preview_video_w; /* Max size of the preview or video
5072 - u32 max_preview_video_h;
5073 - u32 num_preview_video_frames;
5075 - /** Sets the height of the circular buffer for stills capture. */
5076 - u32 stills_capture_circular_buffer_height;
5078 - /** Allows preview/encode to resume as fast as possible after the stills
5079 - * input frame has been received, and then processes the still frame in
5080 - * the background whilst preview/encode has resumed.
5081 - * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE.
5083 - u32 fast_preview_resume;
5085 - /** Selects algorithm for timestamping frames if
5086 - * there is no clock component connected.
5087 - * enum mmal_parameter_camera_config_timestamp_mode
5089 - s32 use_stc_timestamp;
5092 -enum mmal_parameter_exposuremode {
5093 - MMAL_PARAM_EXPOSUREMODE_OFF,
5094 - MMAL_PARAM_EXPOSUREMODE_AUTO,
5095 - MMAL_PARAM_EXPOSUREMODE_NIGHT,
5096 - MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
5097 - MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
5098 - MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
5099 - MMAL_PARAM_EXPOSUREMODE_SPORTS,
5100 - MMAL_PARAM_EXPOSUREMODE_SNOW,
5101 - MMAL_PARAM_EXPOSUREMODE_BEACH,
5102 - MMAL_PARAM_EXPOSUREMODE_VERYLONG,
5103 - MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
5104 - MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
5105 - MMAL_PARAM_EXPOSUREMODE_FIREWORKS,
5108 -enum mmal_parameter_exposuremeteringmode {
5109 - MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
5110 - MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
5111 - MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
5112 - MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX,
5115 -enum mmal_parameter_awbmode {
5116 - MMAL_PARAM_AWBMODE_OFF,
5117 - MMAL_PARAM_AWBMODE_AUTO,
5118 - MMAL_PARAM_AWBMODE_SUNLIGHT,
5119 - MMAL_PARAM_AWBMODE_CLOUDY,
5120 - MMAL_PARAM_AWBMODE_SHADE,
5121 - MMAL_PARAM_AWBMODE_TUNGSTEN,
5122 - MMAL_PARAM_AWBMODE_FLUORESCENT,
5123 - MMAL_PARAM_AWBMODE_INCANDESCENT,
5124 - MMAL_PARAM_AWBMODE_FLASH,
5125 - MMAL_PARAM_AWBMODE_HORIZON,
5128 -enum mmal_parameter_imagefx {
5129 - MMAL_PARAM_IMAGEFX_NONE,
5130 - MMAL_PARAM_IMAGEFX_NEGATIVE,
5131 - MMAL_PARAM_IMAGEFX_SOLARIZE,
5132 - MMAL_PARAM_IMAGEFX_POSTERIZE,
5133 - MMAL_PARAM_IMAGEFX_WHITEBOARD,
5134 - MMAL_PARAM_IMAGEFX_BLACKBOARD,
5135 - MMAL_PARAM_IMAGEFX_SKETCH,
5136 - MMAL_PARAM_IMAGEFX_DENOISE,
5137 - MMAL_PARAM_IMAGEFX_EMBOSS,
5138 - MMAL_PARAM_IMAGEFX_OILPAINT,
5139 - MMAL_PARAM_IMAGEFX_HATCH,
5140 - MMAL_PARAM_IMAGEFX_GPEN,
5141 - MMAL_PARAM_IMAGEFX_PASTEL,
5142 - MMAL_PARAM_IMAGEFX_WATERCOLOUR,
5143 - MMAL_PARAM_IMAGEFX_FILM,
5144 - MMAL_PARAM_IMAGEFX_BLUR,
5145 - MMAL_PARAM_IMAGEFX_SATURATION,
5146 - MMAL_PARAM_IMAGEFX_COLOURSWAP,
5147 - MMAL_PARAM_IMAGEFX_WASHEDOUT,
5148 - MMAL_PARAM_IMAGEFX_POSTERISE,
5149 - MMAL_PARAM_IMAGEFX_COLOURPOINT,
5150 - MMAL_PARAM_IMAGEFX_COLOURBALANCE,
5151 - MMAL_PARAM_IMAGEFX_CARTOON,
5154 -enum MMAL_PARAM_FLICKERAVOID_T {
5155 - MMAL_PARAM_FLICKERAVOID_OFF,
5156 - MMAL_PARAM_FLICKERAVOID_AUTO,
5157 - MMAL_PARAM_FLICKERAVOID_50HZ,
5158 - MMAL_PARAM_FLICKERAVOID_60HZ,
5159 - MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF
5162 -struct mmal_parameter_awbgains {
5163 - struct mmal_parameter_rational r_gain; /**< Red gain */
5164 - struct mmal_parameter_rational b_gain; /**< Blue gain */
5167 -/** Manner of video rate control */
5168 -enum mmal_parameter_rate_control_mode {
5169 - MMAL_VIDEO_RATECONTROL_DEFAULT,
5170 - MMAL_VIDEO_RATECONTROL_VARIABLE,
5171 - MMAL_VIDEO_RATECONTROL_CONSTANT,
5172 - MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES,
5173 - MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES
5176 -enum mmal_video_profile {
5177 - MMAL_VIDEO_PROFILE_H263_BASELINE,
5178 - MMAL_VIDEO_PROFILE_H263_H320CODING,
5179 - MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE,
5180 - MMAL_VIDEO_PROFILE_H263_ISWV2,
5181 - MMAL_VIDEO_PROFILE_H263_ISWV3,
5182 - MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION,
5183 - MMAL_VIDEO_PROFILE_H263_INTERNET,
5184 - MMAL_VIDEO_PROFILE_H263_INTERLACE,
5185 - MMAL_VIDEO_PROFILE_H263_HIGHLATENCY,
5186 - MMAL_VIDEO_PROFILE_MP4V_SIMPLE,
5187 - MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE,
5188 - MMAL_VIDEO_PROFILE_MP4V_CORE,
5189 - MMAL_VIDEO_PROFILE_MP4V_MAIN,
5190 - MMAL_VIDEO_PROFILE_MP4V_NBIT,
5191 - MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE,
5192 - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE,
5193 - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA,
5194 - MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED,
5195 - MMAL_VIDEO_PROFILE_MP4V_HYBRID,
5196 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME,
5197 - MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE,
5198 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING,
5199 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE,
5200 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE,
5201 - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE,
5202 - MMAL_VIDEO_PROFILE_H264_BASELINE,
5203 - MMAL_VIDEO_PROFILE_H264_MAIN,
5204 - MMAL_VIDEO_PROFILE_H264_EXTENDED,
5205 - MMAL_VIDEO_PROFILE_H264_HIGH,
5206 - MMAL_VIDEO_PROFILE_H264_HIGH10,
5207 - MMAL_VIDEO_PROFILE_H264_HIGH422,
5208 - MMAL_VIDEO_PROFILE_H264_HIGH444,
5209 - MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE,
5210 - MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF
5213 -enum mmal_video_level {
5214 - MMAL_VIDEO_LEVEL_H263_10,
5215 - MMAL_VIDEO_LEVEL_H263_20,
5216 - MMAL_VIDEO_LEVEL_H263_30,
5217 - MMAL_VIDEO_LEVEL_H263_40,
5218 - MMAL_VIDEO_LEVEL_H263_45,
5219 - MMAL_VIDEO_LEVEL_H263_50,
5220 - MMAL_VIDEO_LEVEL_H263_60,
5221 - MMAL_VIDEO_LEVEL_H263_70,
5222 - MMAL_VIDEO_LEVEL_MP4V_0,
5223 - MMAL_VIDEO_LEVEL_MP4V_0b,
5224 - MMAL_VIDEO_LEVEL_MP4V_1,
5225 - MMAL_VIDEO_LEVEL_MP4V_2,
5226 - MMAL_VIDEO_LEVEL_MP4V_3,
5227 - MMAL_VIDEO_LEVEL_MP4V_4,
5228 - MMAL_VIDEO_LEVEL_MP4V_4a,
5229 - MMAL_VIDEO_LEVEL_MP4V_5,
5230 - MMAL_VIDEO_LEVEL_MP4V_6,
5231 - MMAL_VIDEO_LEVEL_H264_1,
5232 - MMAL_VIDEO_LEVEL_H264_1b,
5233 - MMAL_VIDEO_LEVEL_H264_11,
5234 - MMAL_VIDEO_LEVEL_H264_12,
5235 - MMAL_VIDEO_LEVEL_H264_13,
5236 - MMAL_VIDEO_LEVEL_H264_2,
5237 - MMAL_VIDEO_LEVEL_H264_21,
5238 - MMAL_VIDEO_LEVEL_H264_22,
5239 - MMAL_VIDEO_LEVEL_H264_3,
5240 - MMAL_VIDEO_LEVEL_H264_31,
5241 - MMAL_VIDEO_LEVEL_H264_32,
5242 - MMAL_VIDEO_LEVEL_H264_4,
5243 - MMAL_VIDEO_LEVEL_H264_41,
5244 - MMAL_VIDEO_LEVEL_H264_42,
5245 - MMAL_VIDEO_LEVEL_H264_5,
5246 - MMAL_VIDEO_LEVEL_H264_51,
5247 - MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF
5250 -struct mmal_parameter_video_profile {
5251 - enum mmal_video_profile profile;
5252 - enum mmal_video_level level;
5255 -/* video parameters */
5257 -enum mmal_parameter_video_type {
5258 - /** @ref MMAL_DISPLAYREGION_T */
5259 - MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO,
5261 - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
5262 - MMAL_PARAMETER_SUPPORTED_PROFILES,
5264 - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
5265 - MMAL_PARAMETER_PROFILE,
5267 - /** @ref MMAL_PARAMETER_UINT32_T */
5268 - MMAL_PARAMETER_INTRAPERIOD,
5270 - /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */
5271 - MMAL_PARAMETER_RATECONTROL,
5273 - /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */
5274 - MMAL_PARAMETER_NALUNITFORMAT,
5276 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5277 - MMAL_PARAMETER_MINIMISE_FRAGMENTATION,
5279 - /** @ref MMAL_PARAMETER_UINT32_T.
5280 - * Setting the value to zero resets to the default (one slice per
5283 - MMAL_PARAMETER_MB_ROWS_PER_SLICE,
5285 - /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */
5286 - MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION,
5288 - /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */
5289 - MMAL_PARAMETER_VIDEO_EEDE_ENABLE,
5291 - /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */
5292 - MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE,
5294 - /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */
5295 - MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME,
5296 - /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */
5297 - MMAL_PARAMETER_VIDEO_INTRA_REFRESH,
5299 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5300 - MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT,
5302 - /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */
5303 - MMAL_PARAMETER_VIDEO_BIT_RATE,
5305 - /** @ref MMAL_PARAMETER_FRAME_RATE_T */
5306 - MMAL_PARAMETER_VIDEO_FRAME_RATE,
5308 - /** @ref MMAL_PARAMETER_UINT32_T. */
5309 - MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
5311 - /** @ref MMAL_PARAMETER_UINT32_T. */
5312 - MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
5314 - /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */
5315 - MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL,
5317 - MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */
5318 - /** @ref MMAL_PARAMETER_UINT32_T.
5319 - * Changing this parameter from the default can reduce frame rate
5320 - * because image buffers need to be re-pitched.
5322 - MMAL_PARAMETER_VIDEO_ALIGN_HORIZ,
5324 - /** @ref MMAL_PARAMETER_UINT32_T.
5325 - * Changing this parameter from the default can reduce frame rate
5326 - * because image buffers need to be re-pitched.
5328 - MMAL_PARAMETER_VIDEO_ALIGN_VERT,
5330 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5331 - MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES,
5333 - /** @ref MMAL_PARAMETER_UINT32_T. */
5334 - MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT,
5336 - /**< @ref MMAL_PARAMETER_UINT32_T. */
5337 - MMAL_PARAMETER_VIDEO_ENCODE_QP_P,
5339 - /**< @ref MMAL_PARAMETER_UINT32_T. */
5340 - MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT,
5342 - /** @ref MMAL_PARAMETER_UINT32_T */
5343 - MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS,
5345 - /** @ref MMAL_PARAMETER_UINT32_T. */
5346 - MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE,
5348 - /* H264 specific parameters */
5350 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5351 - MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC,
5353 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5354 - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY,
5356 - /** @ref MMAL_PARAMETER_BOOLEAN_T. */
5357 - MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS,
5359 - /** @ref MMAL_PARAMETER_UINT32_T. */
5360 - MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC,
5362 - /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */
5363 - MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE,
5365 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5366 - MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN,
5368 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5369 - MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP,
5371 - /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */
5372 - MMAL_PARAMETER_VIDEO_DRM_INIT_INFO,
5374 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5375 - MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO,
5377 - /** @ref MMAL_PARAMETER_BOOLEAN_T */
5378 - MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT,
5380 - /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */
5381 - MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
5383 - /** @ref MMAL_PARAMETER_BYTES_T */
5384 - MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
5386 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5387 - MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
5389 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5390 - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
5392 - /**< @ref MMAL_PARAMETER_BOOLEAN_T */
5393 - MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
5396 -/** Valid mirror modes */
5397 -enum mmal_parameter_mirror {
5398 - MMAL_PARAM_MIRROR_NONE,
5399 - MMAL_PARAM_MIRROR_VERTICAL,
5400 - MMAL_PARAM_MIRROR_HORIZONTAL,
5401 - MMAL_PARAM_MIRROR_BOTH,
5404 -enum mmal_parameter_displaytransform {
5405 - MMAL_DISPLAY_ROT0 = 0,
5406 - MMAL_DISPLAY_MIRROR_ROT0 = 1,
5407 - MMAL_DISPLAY_MIRROR_ROT180 = 2,
5408 - MMAL_DISPLAY_ROT180 = 3,
5409 - MMAL_DISPLAY_MIRROR_ROT90 = 4,
5410 - MMAL_DISPLAY_ROT270 = 5,
5411 - MMAL_DISPLAY_ROT90 = 6,
5412 - MMAL_DISPLAY_MIRROR_ROT270 = 7,
5415 -enum mmal_parameter_displaymode {
5416 - MMAL_DISPLAY_MODE_FILL = 0,
5417 - MMAL_DISPLAY_MODE_LETTERBOX = 1,
5420 -enum mmal_parameter_displayset {
5421 - MMAL_DISPLAY_SET_NONE = 0,
5422 - MMAL_DISPLAY_SET_NUM = 1,
5423 - MMAL_DISPLAY_SET_FULLSCREEN = 2,
5424 - MMAL_DISPLAY_SET_TRANSFORM = 4,
5425 - MMAL_DISPLAY_SET_DEST_RECT = 8,
5426 - MMAL_DISPLAY_SET_SRC_RECT = 0x10,
5427 - MMAL_DISPLAY_SET_MODE = 0x20,
5428 - MMAL_DISPLAY_SET_PIXEL = 0x40,
5429 - MMAL_DISPLAY_SET_NOASPECT = 0x80,
5430 - MMAL_DISPLAY_SET_LAYER = 0x100,
5431 - MMAL_DISPLAY_SET_COPYPROTECT = 0x200,
5432 - MMAL_DISPLAY_SET_ALPHA = 0x400,
5435 -/* rectangle, used lots so it gets its own struct */
5436 -struct vchiq_mmal_rect {
5443 -struct mmal_parameter_displayregion {
5444 - /** Bitfield that indicates which fields are set and should be
5445 - * used. All other fields will maintain their current value.
5446 - * \ref MMAL_DISPLAYSET_T defines the bits that can be
5451 - /** Describes the display output device, with 0 typically
5452 - * being a directly connected LCD display. The actual values
5453 - * will depend on the hardware. Code using hard-wired numbers
5454 - * (e.g. 2) is certain to fail.
5458 - /** Indicates that we are using the full device screen area,
5459 - * rather than a window of the display. If zero, then
5460 - * dest_rect is used to specify a region of the display to
5465 - /** Indicates any rotation or flipping used to map frames onto
5466 - * the natural display orientation.
5468 - u32 transform; /* enum mmal_parameter_displaytransform */
5470 - /** Where to display the frame within the screen, if
5471 - * fullscreen is zero.
5473 - struct vchiq_mmal_rect dest_rect;
5475 - /** Indicates which area of the frame to display. If all
5476 - * values are zero, the whole frame will be used.
5478 - struct vchiq_mmal_rect src_rect;
5480 - /** If set to non-zero, indicates that any display scaling
5481 - * should disregard the aspect ratio of the frame region being
5486 - /** Indicates how the image should be scaled to fit the
5487 - * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates
5488 - * that the image should fill the screen by potentially
5489 - * cropping the frames. Setting \code mode \endcode to \code
5490 - * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the
5491 - * source region should be displayed and black bars added if
5494 - u32 mode; /* enum mmal_parameter_displaymode */
5496 - /** If non-zero, defines the width of a source pixel relative
5497 - * to \code pixel_y \endcode. If zero, then pixels default to
5502 - /** If non-zero, defines the height of a source pixel relative
5503 - * to \code pixel_x \endcode. If zero, then pixels default to
5508 - /** Sets the relative depth of the images, with greater values
5509 - * being in front of smaller values.
5513 - /** Set to non-zero to ensure copy protection is used on
5516 - s32 copyprotect_required;
5518 - /** Level of opacity of the layer, where zero is fully
5519 - * transparent and 255 is fully opaque.
5524 -#define MMAL_MAX_IMAGEFX_PARAMETERS 5
5526 -struct mmal_parameter_imagefx_parameters {
5527 - enum mmal_parameter_imagefx effect;
5528 - u32 num_effect_params;
5529 - u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS];
5532 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4
5533 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2
5534 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16
5536 -struct mmal_parameter_camera_info_camera_t {
5541 - u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN];
5544 -enum mmal_parameter_camera_info_flash_type_t {
5545 - /* Make values explicit to ensure they match values in config ini */
5546 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0,
5547 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1,
5548 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2,
5549 - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF
5552 -struct mmal_parameter_camera_info_flash_t {
5553 - enum mmal_parameter_camera_info_flash_type_t flash_type;
5556 -struct mmal_parameter_camera_info_t {
5559 - struct mmal_parameter_camera_info_camera_t
5560 - cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS];
5561 - struct mmal_parameter_camera_info_flash_t
5562 - flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES];
5566 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
5569 -/* SPDX-License-Identifier: GPL-2.0 */
5571 - * Broadcom BM2835 V4L2 driver
5573 - * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5575 - * Authors: Vincent Sanders @ Collabora
5576 - * Dave Stevenson @ Broadcom
5577 - * (now dave.stevenson@raspberrypi.org)
5578 - * Simon Mellor @ Broadcom
5579 - * Luke Diamand @ Broadcom
5581 - * MMAL interface to VCHIQ message passing
5584 -#ifndef MMAL_VCHIQ_H
5585 -#define MMAL_VCHIQ_H
5587 -#include "mmal-msg-format.h"
5589 -#define MAX_PORT_COUNT 4
5591 -/* Maximum size of the format extradata. */
5592 -#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
5594 -struct vchiq_mmal_instance;
5596 -enum vchiq_mmal_es_type {
5597 - MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
5598 - MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
5599 - MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
5600 - MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
5601 - MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
5604 -struct vchiq_mmal_port_buffer {
5605 - unsigned int num; /* number of buffers */
5606 - u32 size; /* size of buffers */
5607 - u32 alignment; /* alignment of buffers */
5610 -struct vchiq_mmal_port;
5612 -typedef void (*vchiq_mmal_buffer_cb)(
5613 - struct vchiq_mmal_instance *instance,
5614 - struct vchiq_mmal_port *port,
5615 - int status, struct mmal_buffer *buffer,
5616 - unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
5618 -struct vchiq_mmal_port {
5621 - u32 type; /* port type, cached to use on port info set */
5622 - u32 index; /* port index, cached to use on port info set */
5624 - /* component port belongs to, allows simple deref */
5625 - struct vchiq_mmal_component *component;
5627 - struct vchiq_mmal_port *connected; /* port conencted to */
5630 - struct vchiq_mmal_port_buffer minimum_buffer;
5631 - struct vchiq_mmal_port_buffer recommended_buffer;
5632 - struct vchiq_mmal_port_buffer current_buffer;
5634 - /* stream format */
5635 - struct mmal_es_format_local format;
5636 - /* elementary stream format */
5637 - union mmal_es_specific_format es;
5639 - /* data buffers to fill */
5640 - struct list_head buffers;
5641 - /* lock to serialise adding and removing buffers from list */
5644 - /* Count of buffers the VPU has yet to return */
5645 - atomic_t buffers_with_vpu;
5646 - /* callback on buffer completion */
5647 - vchiq_mmal_buffer_cb buffer_cb;
5648 - /* callback context */
5652 -struct vchiq_mmal_component {
5654 - u32 handle; /* VideoCore handle for component */
5655 - u32 inputs; /* Number of input ports */
5656 - u32 outputs; /* Number of output ports */
5657 - u32 clocks; /* Number of clock ports */
5658 - struct vchiq_mmal_port control; /* control port */
5659 - struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
5660 - struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
5661 - struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
5664 -int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
5665 -int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
5667 -/* Initialise a mmal component and its ports
5670 -int vchiq_mmal_component_init(
5671 - struct vchiq_mmal_instance *instance,
5673 - struct vchiq_mmal_component **component_out);
5675 -int vchiq_mmal_component_finalise(
5676 - struct vchiq_mmal_instance *instance,
5677 - struct vchiq_mmal_component *component);
5679 -int vchiq_mmal_component_enable(
5680 - struct vchiq_mmal_instance *instance,
5681 - struct vchiq_mmal_component *component);
5683 -int vchiq_mmal_component_disable(
5684 - struct vchiq_mmal_instance *instance,
5685 - struct vchiq_mmal_component *component);
5687 -/* enable a mmal port
5689 - * enables a port and if a buffer callback provided enque buffer
5690 - * headers as appropriate for the port.
5692 -int vchiq_mmal_port_enable(
5693 - struct vchiq_mmal_instance *instance,
5694 - struct vchiq_mmal_port *port,
5695 - vchiq_mmal_buffer_cb buffer_cb);
5699 - * disable a port will dequeue any pending buffers
5701 -int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
5702 - struct vchiq_mmal_port *port);
5704 -int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
5705 - struct vchiq_mmal_port *port,
5710 -int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
5711 - struct vchiq_mmal_port *port,
5716 -int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
5717 - struct vchiq_mmal_port *port);
5719 -int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
5720 - struct vchiq_mmal_port *src,
5721 - struct vchiq_mmal_port *dst);
5723 -int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
5727 -int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
5728 - struct vchiq_mmal_port *port,
5729 - struct mmal_buffer *buf);
5731 -int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
5732 - struct mmal_buffer *buf);
5733 -int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
5734 -#endif /* MMAL_VCHIQ_H */
5736 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h
5738 +/* SPDX-License-Identifier: GPL-2.0 */
5740 + * Broadcom BM2835 V4L2 driver
5742 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5744 + * Authors: Vincent Sanders @ Collabora
5745 + * Dave Stevenson @ Broadcom
5746 + * (now dave.stevenson@raspberrypi.org)
5747 + * Simon Mellor @ Broadcom
5748 + * Luke Diamand @ Broadcom
5753 +#ifndef MMAL_COMMON_H
5754 +#define MMAL_COMMON_H
5756 +#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))
5757 +#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
5759 +/** Special value signalling that time is not known */
5760 +#define MMAL_TIME_UNKNOWN BIT_ULL(63)
5762 +struct mmal_msg_context;
5764 +/* mapping between v4l and mmal video modes */
5767 + u32 fourcc; /* v4l2 format id */
5768 + int flags; /* v4l2 flags field */
5771 + u32 mmal_component; /* MMAL component index to be used to encode */
5772 + u32 ybbp; /* depth of first Y plane for planar formats */
5773 + bool remove_padding; /* Does the GPU have to remove padding,
5774 + * or can we do hide padding via bytesperline.
5778 +/* buffer for one video frame */
5779 +struct mmal_buffer {
5780 + /* v4l buffer data -- must be first */
5781 + struct vb2_v4l2_buffer vb;
5783 + /* list of buffers available */
5784 + struct list_head list;
5786 + void *buffer; /* buffer pointer */
5787 + unsigned long buffer_size; /* size of allocated buffer */
5789 + struct mmal_msg_context *msg_context;
5793 +struct mmal_colourfx {
5800 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-encodings.h
5802 +/* SPDX-License-Identifier: GPL-2.0 */
5804 + * Broadcom BM2835 V4L2 driver
5806 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5808 + * Authors: Vincent Sanders @ Collabora
5809 + * Dave Stevenson @ Broadcom
5810 + * (now dave.stevenson@raspberrypi.org)
5811 + * Simon Mellor @ Broadcom
5812 + * Luke Diamand @ Broadcom
5814 +#ifndef MMAL_ENCODINGS_H
5815 +#define MMAL_ENCODINGS_H
5817 +#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4')
5818 +#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3')
5819 +#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V')
5820 +#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V')
5821 +#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V')
5822 +#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3')
5823 +#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2')
5824 +#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1')
5825 +#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1')
5826 +#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ')
5827 +#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ')
5828 +#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ')
5829 +#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O')
5830 +#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K')
5831 +#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G')
5833 +#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G')
5834 +#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ')
5835 +#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ')
5836 +#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ')
5837 +#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ')
5838 +#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ')
5840 +#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0')
5841 +#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0')
5842 +#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2')
5843 +#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2')
5844 +#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2')
5845 +#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V')
5846 +#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U')
5847 +#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y')
5848 +#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y')
5849 +#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2')
5850 +#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1')
5851 +#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B')
5852 +#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A')
5853 +#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R')
5854 +#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A')
5855 +#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2')
5856 +#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3')
5857 +#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4')
5858 +#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2')
5859 +#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3')
5860 +#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4')
5862 +/** SAND Video (YUVUV128) format, native format understood by VideoCore.
5863 + * This format is *not* opaque - if requested you will receive full frames
5864 + * of YUV_UV video.
5866 +#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D')
5868 +/** VideoCore opaque image format, image handles are returned to
5869 + * the host but not the actual image data.
5871 +#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V')
5873 +/** An EGL image handle
5875 +#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I')
5879 +/** \name Pre-defined audio encodings */
5881 +#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U')
5882 +#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u')
5883 +#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S')
5884 +#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's')
5885 +#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F')
5886 +#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f')
5888 +/* Pre-defined H264 encoding variants */
5890 +/** ISO 14496-10 Annex B byte stream format */
5891 +#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0
5892 +/** ISO 14496-15 AVC stream format */
5893 +#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1')
5894 +/** Implicitly delineated NAL units without emulation prevention */
5895 +#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ')
5897 +/** \defgroup MmalColorSpace List of pre-defined video color spaces
5898 + * This defines a list of common color spaces. This list isn't exhaustive and
5899 + * is only provided as a convenience to avoid clients having to use FourCC
5900 + * codes directly. However components are allowed to define and use their own
5905 +/** Unknown color space */
5906 +#define MMAL_COLOR_SPACE_UNKNOWN 0
5907 +/** ITU-R BT.601-5 [SDTV] */
5908 +#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1')
5909 +/** ITU-R BT.709-3 [HDTV] */
5910 +#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9')
5912 +#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I')
5913 +/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
5914 +#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C')
5915 +/** Society of Motion Picture and Television Engineers 240M (1999) */
5916 +#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0')
5917 +/** ITU-R BT.470-2 System M */
5918 +#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M')
5919 +/** ITU-R BT.470-2 System BG */
5920 +#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G')
5921 +/** JPEG JFIF, but with 16..255 luma */
5922 +#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6')
5923 +/* @} MmalColorSpace List */
5925 +#endif /* MMAL_ENCODINGS_H */
5927 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-common.h
5929 +/* SPDX-License-Identifier: GPL-2.0 */
5931 + * Broadcom BM2835 V4L2 driver
5933 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5935 + * Authors: Vincent Sanders @ Collabora
5936 + * Dave Stevenson @ Broadcom
5937 + * (now dave.stevenson@raspberrypi.org)
5938 + * Simon Mellor @ Broadcom
5939 + * Luke Diamand @ Broadcom
5942 +#ifndef MMAL_MSG_COMMON_H
5943 +#define MMAL_MSG_COMMON_H
5945 +enum mmal_msg_status {
5946 + MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */
5947 + MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */
5948 + MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */
5949 + MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */
5950 + MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */
5951 + MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */
5952 + MMAL_MSG_STATUS_ENXIO, /**< No such device or address */
5953 + MMAL_MSG_STATUS_EIO, /**< I/O error */
5954 + MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */
5955 + MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */
5956 + MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */
5957 + MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */
5958 + MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */
5959 + MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */
5960 + MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */
5961 + MMAL_MSG_STATUS_EFAULT, /**< Bad address */
5965 + s32 x; /**< x coordinate (from left) */
5966 + s32 y; /**< y coordinate (from top) */
5967 + s32 width; /**< width */
5968 + s32 height; /**< height */
5971 +struct mmal_rational {
5972 + s32 num; /**< Numerator */
5973 + s32 den; /**< Denominator */
5976 +#endif /* MMAL_MSG_COMMON_H */
5978 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-format.h
5980 +/* SPDX-License-Identifier: GPL-2.0 */
5982 + * Broadcom BM2835 V4L2 driver
5984 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5986 + * Authors: Vincent Sanders @ Collabora
5987 + * Dave Stevenson @ Broadcom
5988 + * (now dave.stevenson@raspberrypi.org)
5989 + * Simon Mellor @ Broadcom
5990 + * Luke Diamand @ Broadcom
5993 +#ifndef MMAL_MSG_FORMAT_H
5994 +#define MMAL_MSG_FORMAT_H
5996 +#include "mmal-msg-common.h"
5998 +/* MMAL_ES_FORMAT_T */
6000 +struct mmal_audio_format {
6001 + u32 channels; /* Number of audio channels */
6002 + u32 sample_rate; /* Sample rate */
6004 + u32 bits_per_sample; /* Bits per sample */
6005 + u32 block_align; /* Size of a block of data */
6008 +struct mmal_video_format {
6009 + u32 width; /* Width of frame in pixels */
6010 + u32 height; /* Height of frame in rows of pixels */
6011 + struct mmal_rect crop; /* Visible region of the frame */
6012 + struct mmal_rational frame_rate; /* Frame rate */
6013 + struct mmal_rational par; /* Pixel aspect ratio */
6016 + * FourCC specifying the color space of the video stream. See the
6017 + * MmalColorSpace "pre-defined color spaces" for some examples.
6022 +struct mmal_subpicture_format {
6027 +union mmal_es_specific_format {
6028 + struct mmal_audio_format audio;
6029 + struct mmal_video_format video;
6030 + struct mmal_subpicture_format subpicture;
6033 +/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */
6034 +struct mmal_es_format_local {
6035 + u32 type; /* enum mmal_es_type */
6037 + u32 encoding; /* FourCC specifying encoding of the elementary
6040 + u32 encoding_variant; /* FourCC specifying the specific
6041 + * encoding variant of the elementary
6045 + union mmal_es_specific_format *es; /* Type specific
6046 + * information for the
6047 + * elementary stream
6050 + u32 bitrate; /* Bitrate in bits per second */
6051 + u32 flags; /* Flags describing properties of the elementary
6055 + u32 extradata_size; /* Size of the codec specific data */
6056 + u8 *extradata; /* Codec specific data */
6059 +/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */
6060 +struct mmal_es_format {
6061 + u32 type; /* enum mmal_es_type */
6063 + u32 encoding; /* FourCC specifying encoding of the elementary
6066 + u32 encoding_variant; /* FourCC specifying the specific
6067 + * encoding variant of the elementary
6071 + u32 es; /* Type specific
6072 + * information for the
6073 + * elementary stream
6076 + u32 bitrate; /* Bitrate in bits per second */
6077 + u32 flags; /* Flags describing properties of the elementary
6081 + u32 extradata_size; /* Size of the codec specific data */
6082 + u32 extradata; /* Codec specific data */
6085 +#endif /* MMAL_MSG_FORMAT_H */
6087 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-port.h
6089 +/* SPDX-License-Identifier: GPL-2.0 */
6091 + * Broadcom BM2835 V4L2 driver
6093 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6095 + * Authors: Vincent Sanders @ Collabora
6096 + * Dave Stevenson @ Broadcom
6097 + * (now dave.stevenson@raspberrypi.org)
6098 + * Simon Mellor @ Broadcom
6099 + * Luke Diamand @ Broadcom
6102 +/* MMAL_PORT_TYPE_T */
6103 +enum mmal_port_type {
6104 + MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */
6105 + MMAL_PORT_TYPE_CONTROL, /* Control port */
6106 + MMAL_PORT_TYPE_INPUT, /* Input port */
6107 + MMAL_PORT_TYPE_OUTPUT, /* Output port */
6108 + MMAL_PORT_TYPE_CLOCK, /* Clock port */
6111 +/* The port is pass-through and doesn't need buffer headers allocated */
6112 +#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01
6114 + *The port wants to allocate the buffer payloads.
6115 + * This signals a preference that payload allocation should be done
6116 + * on this port for efficiency reasons.
6118 +#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02
6120 + * The port supports format change events.
6121 + * This applies to input ports and is used to let the client know
6122 + * whether the port supports being reconfigured via a format
6123 + * change event (i.e. without having to disable the port).
6125 +#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04
6128 + * mmal port structure (MMAL_PORT_T)
6130 + * most elements are informational only, the pointer values for
6131 + * interogation messages are generally provided as additional
6132 + * structures within the message. When used to set values only the
6133 + * buffer_num, buffer_size and userdata parameters are writable.
6136 + u32 priv; /* Private member used by the framework */
6137 + u32 name; /* Port name. Used for debugging purposes (RO) */
6139 + u32 type; /* Type of the port (RO) enum mmal_port_type */
6140 + u16 index; /* Index of the port in its type list (RO) */
6141 + u16 index_all; /* Index of the port in the list of all ports (RO) */
6143 + u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */
6144 + u32 format; /* Format of the elementary stream */
6146 + u32 buffer_num_min; /* Minimum number of buffers the port
6147 + * requires (RO). This is set by the
6151 + u32 buffer_size_min; /* Minimum size of buffers the port
6152 + * requires (RO). This is set by the
6156 + u32 buffer_alignment_min;/* Minimum alignment requirement for
6157 + * the buffers (RO). A value of
6158 + * zero means no special alignment
6159 + * requirements. This is set by the
6163 + u32 buffer_num_recommended; /* Number of buffers the port
6164 + * recommends for optimal
6165 + * performance (RO). A value of
6166 + * zero means no special
6167 + * recommendation. This is set
6168 + * by the component.
6171 + u32 buffer_size_recommended; /* Size of buffers the port
6172 + * recommends for optimal
6173 + * performance (RO). A value of
6174 + * zero means no special
6175 + * recommendation. This is set
6176 + * by the component.
6179 + u32 buffer_num; /* Actual number of buffers the port will use.
6180 + * This is set by the client.
6183 + u32 buffer_size; /* Actual maximum size of the buffers that
6184 + * will be sent to the port. This is set by
6188 + u32 component; /* Component this port belongs to (Read Only) */
6190 + u32 userdata; /* Field reserved for use by the client */
6192 + u32 capabilities; /* Flags describing the capabilities of a
6193 + * port (RO). Bitwise combination of \ref
6194 + * portcapabilities "Port capabilities"
6199 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h
6201 +/* SPDX-License-Identifier: GPL-2.0 */
6203 + * Broadcom BM2835 V4L2 driver
6205 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6207 + * Authors: Vincent Sanders @ Collabora
6208 + * Dave Stevenson @ Broadcom
6209 + * (now dave.stevenson@raspberrypi.org)
6210 + * Simon Mellor @ Broadcom
6211 + * Luke Diamand @ Broadcom
6215 + * all the data structures which serialise the MMAL protocol. note
6216 + * these are directly mapped onto the recived message data.
6218 + * BEWARE: They seem to *assume* pointers are u32 and that there is no
6219 + * structure padding!
6221 + * NOTE: this implementation uses kernel types to ensure sizes. Rather
6222 + * than assigning values to enums to force their size the
6223 + * implementation uses fixed size types and not the enums (though the
6224 + * comments have the actual enum type
6229 +#define VC_MMAL_VER 15
6230 +#define VC_MMAL_MIN_VER 10
6231 +#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal")
6233 +/* max total message size is 512 bytes */
6234 +#define MMAL_MSG_MAX_SIZE 512
6235 +/* with six 32bit header elements max payload is therefore 488 bytes */
6236 +#define MMAL_MSG_MAX_PAYLOAD 488
6238 +#include "mmal-msg-common.h"
6239 +#include "mmal-msg-format.h"
6240 +#include "mmal-msg-port.h"
6242 +enum mmal_msg_type {
6243 + MMAL_MSG_TYPE_QUIT = 1,
6244 + MMAL_MSG_TYPE_SERVICE_CLOSED,
6245 + MMAL_MSG_TYPE_GET_VERSION,
6246 + MMAL_MSG_TYPE_COMPONENT_CREATE,
6247 + MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */
6248 + MMAL_MSG_TYPE_COMPONENT_ENABLE,
6249 + MMAL_MSG_TYPE_COMPONENT_DISABLE,
6250 + MMAL_MSG_TYPE_PORT_INFO_GET,
6251 + MMAL_MSG_TYPE_PORT_INFO_SET,
6252 + MMAL_MSG_TYPE_PORT_ACTION, /* 10 */
6253 + MMAL_MSG_TYPE_BUFFER_FROM_HOST,
6254 + MMAL_MSG_TYPE_BUFFER_TO_HOST,
6255 + MMAL_MSG_TYPE_GET_STATS,
6256 + MMAL_MSG_TYPE_PORT_PARAMETER_SET,
6257 + MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */
6258 + MMAL_MSG_TYPE_EVENT_TO_HOST,
6259 + MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
6260 + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
6261 + MMAL_MSG_TYPE_CONSUME_MEM,
6262 + MMAL_MSG_TYPE_LMK, /* 20 */
6263 + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
6264 + MMAL_MSG_TYPE_DRM_GET_LHS32,
6265 + MMAL_MSG_TYPE_DRM_GET_TIME,
6266 + MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
6267 + MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */
6268 + MMAL_MSG_TYPE_HOST_LOG,
6269 + MMAL_MSG_TYPE_MSG_LAST
6272 +/* port action request messages differ depending on the action type */
6273 +enum mmal_msg_port_action_type {
6274 + MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */
6275 + MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
6276 + MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
6277 + MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
6278 + MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */
6279 + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */
6280 + MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/
6283 +struct mmal_msg_header {
6285 + u32 type; /* enum mmal_msg_type */
6287 + /* Opaque handle to the control service */
6288 + u32 control_service;
6290 + u32 context; /* a u32 per message context */
6291 + u32 status; /* The status of the vchiq operation */
6295 +/* Send from VC to host to report version */
6296 +struct mmal_msg_version {
6303 +/* request to VC to create component */
6304 +struct mmal_msg_component_create {
6305 + u32 client_component; /* component context */
6307 + u32 pid; /* For debug */
6310 +/* reply from VC to component creation request */
6311 +struct mmal_msg_component_create_reply {
6312 + u32 status; /* enum mmal_msg_status - how does this differ to
6313 + * the one in the header?
6315 + u32 component_handle; /* VideoCore handle for component */
6316 + u32 input_num; /* Number of input ports */
6317 + u32 output_num; /* Number of output ports */
6318 + u32 clock_num; /* Number of clock ports */
6321 +/* request to VC to destroy a component */
6322 +struct mmal_msg_component_destroy {
6323 + u32 component_handle;
6326 +struct mmal_msg_component_destroy_reply {
6327 + u32 status; /* The component destruction status */
6330 +/* request and reply to VC to enable a component */
6331 +struct mmal_msg_component_enable {
6332 + u32 component_handle;
6335 +struct mmal_msg_component_enable_reply {
6336 + u32 status; /* The component enable status */
6339 +/* request and reply to VC to disable a component */
6340 +struct mmal_msg_component_disable {
6341 + u32 component_handle;
6344 +struct mmal_msg_component_disable_reply {
6345 + u32 status; /* The component disable status */
6348 +/* request to VC to get port information */
6349 +struct mmal_msg_port_info_get {
6350 + u32 component_handle; /* component handle port is associated with */
6351 + u32 port_type; /* enum mmal_msg_port_type */
6352 + u32 index; /* port index to query */
6355 +/* reply from VC to get port info request */
6356 +struct mmal_msg_port_info_get_reply {
6357 + u32 status; /* enum mmal_msg_status */
6358 + u32 component_handle; /* component handle port is associated with */
6359 + u32 port_type; /* enum mmal_msg_port_type */
6360 + u32 port_index; /* port indexed in query */
6361 + s32 found; /* unused */
6362 + u32 port_handle; /* Handle to use for this port */
6363 + struct mmal_port port;
6364 + struct mmal_es_format format; /* elementary stream format */
6365 + union mmal_es_specific_format es; /* es type specific data */
6366 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */
6369 +/* request to VC to set port information */
6370 +struct mmal_msg_port_info_set {
6371 + u32 component_handle;
6372 + u32 port_type; /* enum mmal_msg_port_type */
6373 + u32 port_index; /* port indexed in query */
6374 + struct mmal_port port;
6375 + struct mmal_es_format format;
6376 + union mmal_es_specific_format es;
6377 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
6380 +/* reply from VC to port info set request */
6381 +struct mmal_msg_port_info_set_reply {
6383 + u32 component_handle; /* component handle port is associated with */
6384 + u32 port_type; /* enum mmal_msg_port_type */
6385 + u32 index; /* port indexed in query */
6386 + s32 found; /* unused */
6387 + u32 port_handle; /* Handle to use for this port */
6388 + struct mmal_port port;
6389 + struct mmal_es_format format;
6390 + union mmal_es_specific_format es;
6391 + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
6394 +/* port action requests that take a mmal_port as a parameter */
6395 +struct mmal_msg_port_action_port {
6396 + u32 component_handle;
6398 + u32 action; /* enum mmal_msg_port_action_type */
6399 + struct mmal_port port;
6402 +/* port action requests that take handles as a parameter */
6403 +struct mmal_msg_port_action_handle {
6404 + u32 component_handle;
6406 + u32 action; /* enum mmal_msg_port_action_type */
6407 + u32 connect_component_handle;
6408 + u32 connect_port_handle;
6411 +struct mmal_msg_port_action_reply {
6412 + u32 status; /* The port action operation status */
6415 +/* MMAL buffer transfer */
6417 +/* Size of space reserved in a buffer message for short messages. */
6418 +#define MMAL_VC_SHORT_DATA 128
6420 +/* Signals that the current payload is the end of the stream of data */
6421 +#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0)
6422 +/* Signals that the start of the current payload starts a frame */
6423 +#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1)
6424 +/* Signals that the end of the current payload ends a frame */
6425 +#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2)
6426 +/* Signals that the current payload contains only complete frames (>1) */
6427 +#define MMAL_BUFFER_HEADER_FLAG_FRAME \
6428 + (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \
6429 + MMAL_BUFFER_HEADER_FLAG_FRAME_END)
6430 +/* Signals that the current payload is a keyframe (i.e. self decodable) */
6431 +#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3)
6433 + * Signals a discontinuity in the stream of data (e.g. after a seek).
6434 + * Can be used for instance by a decoder to reset its state
6436 +#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4)
6438 + * Signals a buffer containing some kind of config data for the component
6439 + * (e.g. codec config data)
6441 +#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5)
6442 +/* Signals an encrypted payload */
6443 +#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6)
6444 +/* Signals a buffer containing side information */
6445 +#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7)
6447 + * Signals a buffer which is the snapshot/postview image from a stills
6450 +#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8)
6451 +/* Signals a buffer which contains data known to be corrupted */
6452 +#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9)
6453 +/* Signals that a buffer failed to be transmitted */
6454 +#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10)
6456 +struct mmal_driver_buffer {
6458 + u32 component_handle;
6460 + u32 client_context;
6463 +/* buffer header */
6464 +struct mmal_buffer_header {
6465 + u32 next; /* next header */
6466 + u32 priv; /* framework private data */
6479 +struct mmal_buffer_header_type_specific {
6490 +struct mmal_msg_buffer_from_host {
6492 + *The front 32 bytes of the buffer header are copied
6493 + * back to us in the reply to allow for context. This
6494 + * area is used to store two mmal_driver_buffer structures to
6495 + * allow for multiple concurrent service users.
6497 + /* control data */
6498 + struct mmal_driver_buffer drvbuf;
6500 + /* referenced control data for passthrough buffer management */
6501 + struct mmal_driver_buffer drvbuf_ref;
6502 + struct mmal_buffer_header buffer_header; /* buffer header itself */
6503 + struct mmal_buffer_header_type_specific buffer_header_type_specific;
6505 + s32 has_reference;
6507 + /* allows short data to be xfered in control message */
6508 + u32 payload_in_message;
6509 + u8 short_data[MMAL_VC_SHORT_DATA];
6512 +/* port parameter setting */
6514 +#define MMAL_WORKER_PORT_PARAMETER_SPACE 96
6516 +struct mmal_msg_port_parameter_set {
6517 + u32 component_handle; /* component */
6518 + u32 port_handle; /* port */
6519 + u32 id; /* Parameter ID */
6520 + u32 size; /* Parameter size */
6521 + uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
6524 +struct mmal_msg_port_parameter_set_reply {
6525 + u32 status; /* enum mmal_msg_status todo: how does this
6526 + * differ to the one in the header?
6530 +/* port parameter getting */
6532 +struct mmal_msg_port_parameter_get {
6533 + u32 component_handle; /* component */
6534 + u32 port_handle; /* port */
6535 + u32 id; /* Parameter ID */
6536 + u32 size; /* Parameter size */
6539 +struct mmal_msg_port_parameter_get_reply {
6540 + u32 status; /* Status of mmal_port_parameter_get call */
6541 + u32 id; /* Parameter ID */
6542 + u32 size; /* Parameter size */
6543 + uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
6546 +/* event messages */
6547 +#define MMAL_WORKER_EVENT_SPACE 256
6549 +struct mmal_msg_event_to_host {
6550 + u32 client_component; /* component context */
6557 + u8 data[MMAL_WORKER_EVENT_SPACE];
6558 + u32 delayed_buffer;
6561 +/* all mmal messages are serialised through this structure */
6564 + struct mmal_msg_header h;
6567 + struct mmal_msg_version version;
6569 + struct mmal_msg_component_create component_create;
6570 + struct mmal_msg_component_create_reply component_create_reply;
6572 + struct mmal_msg_component_destroy component_destroy;
6573 + struct mmal_msg_component_destroy_reply component_destroy_reply;
6575 + struct mmal_msg_component_enable component_enable;
6576 + struct mmal_msg_component_enable_reply component_enable_reply;
6578 + struct mmal_msg_component_disable component_disable;
6579 + struct mmal_msg_component_disable_reply component_disable_reply;
6581 + struct mmal_msg_port_info_get port_info_get;
6582 + struct mmal_msg_port_info_get_reply port_info_get_reply;
6584 + struct mmal_msg_port_info_set port_info_set;
6585 + struct mmal_msg_port_info_set_reply port_info_set_reply;
6587 + struct mmal_msg_port_action_port port_action_port;
6588 + struct mmal_msg_port_action_handle port_action_handle;
6589 + struct mmal_msg_port_action_reply port_action_reply;
6591 + struct mmal_msg_buffer_from_host buffer_from_host;
6593 + struct mmal_msg_port_parameter_set port_parameter_set;
6594 + struct mmal_msg_port_parameter_set_reply
6595 + port_parameter_set_reply;
6596 + struct mmal_msg_port_parameter_get
6597 + port_parameter_get;
6598 + struct mmal_msg_port_parameter_get_reply
6599 + port_parameter_get_reply;
6601 + struct mmal_msg_event_to_host event_to_host;
6603 + u8 payload[MMAL_MSG_MAX_PAYLOAD];
6608 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h
6610 +/* SPDX-License-Identifier: GPL-2.0 */
6612 + * Broadcom BM2835 V4L2 driver
6614 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6616 + * Authors: Vincent Sanders @ Collabora
6617 + * Dave Stevenson @ Broadcom
6618 + * (now dave.stevenson@raspberrypi.org)
6619 + * Simon Mellor @ Broadcom
6620 + * Luke Diamand @ Broadcom
6623 +/* common parameters */
6625 +/** @name Parameter groups
6626 + * Parameters are divided into groups, and then allocated sequentially within
6627 + * a group using an enum.
6631 +#ifndef MMAL_PARAMETERS_H
6632 +#define MMAL_PARAMETERS_H
6634 +/** Common parameter ID group, used with many types of component. */
6635 +#define MMAL_PARAMETER_GROUP_COMMON (0 << 16)
6636 +/** Camera-specific parameter ID group. */
6637 +#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16)
6638 +/** Video-specific parameter ID group. */
6639 +#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16)
6640 +/** Audio-specific parameter ID group. */
6641 +#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16)
6642 +/** Clock-specific parameter ID group. */
6643 +#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16)
6644 +/** Miracast-specific parameter ID group. */
6645 +#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16)
6647 +/* Common parameters */
6648 +enum mmal_parameter_common_type {
6649 + /**< Never a valid parameter ID */
6650 + MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON,
6652 + /**< MMAL_PARAMETER_ENCODING_T */
6653 + MMAL_PARAMETER_SUPPORTED_ENCODINGS,
6654 + /**< MMAL_PARAMETER_URI_T */
6655 + MMAL_PARAMETER_URI,
6656 + /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */
6657 + MMAL_PARAMETER_CHANGE_EVENT_REQUEST,
6658 + /** MMAL_PARAMETER_BOOLEAN_T */
6659 + MMAL_PARAMETER_ZERO_COPY,
6660 + /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */
6661 + MMAL_PARAMETER_BUFFER_REQUIREMENTS,
6662 + /**< MMAL_PARAMETER_STATISTICS_T */
6663 + MMAL_PARAMETER_STATISTICS,
6664 + /**< MMAL_PARAMETER_CORE_STATISTICS_T */
6665 + MMAL_PARAMETER_CORE_STATISTICS,
6666 + /**< MMAL_PARAMETER_MEM_USAGE_T */
6667 + MMAL_PARAMETER_MEM_USAGE,
6668 + /**< MMAL_PARAMETER_UINT32_T */
6669 + MMAL_PARAMETER_BUFFER_FLAG_FILTER,
6670 + /**< MMAL_PARAMETER_SEEK_T */
6671 + MMAL_PARAMETER_SEEK,
6672 + /**< MMAL_PARAMETER_BOOLEAN_T */
6673 + MMAL_PARAMETER_POWERMON_ENABLE,
6674 + /**< MMAL_PARAMETER_LOGGING_T */
6675 + MMAL_PARAMETER_LOGGING,
6676 + /**< MMAL_PARAMETER_UINT64_T */
6677 + MMAL_PARAMETER_SYSTEM_TIME,
6678 + /**< MMAL_PARAMETER_BOOLEAN_T */
6679 + MMAL_PARAMETER_NO_IMAGE_PADDING,
6682 +/* camera parameters */
6684 +enum mmal_parameter_camera_type {
6686 + /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */
6687 + MMAL_PARAMETER_THUMBNAIL_CONFIGURATION =
6688 + MMAL_PARAMETER_GROUP_CAMERA,
6690 + MMAL_PARAMETER_CAPTURE_QUALITY,
6691 + /**< @ref MMAL_PARAMETER_INT32_T */
6692 + MMAL_PARAMETER_ROTATION,
6693 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6694 + MMAL_PARAMETER_EXIF_DISABLE,
6695 + /**< @ref MMAL_PARAMETER_EXIF_T */
6696 + MMAL_PARAMETER_EXIF,
6697 + /**< @ref MMAL_PARAM_AWBMODE_T */
6698 + MMAL_PARAMETER_AWB_MODE,
6699 + /**< @ref MMAL_PARAMETER_IMAGEFX_T */
6700 + MMAL_PARAMETER_IMAGE_EFFECT,
6701 + /**< @ref MMAL_PARAMETER_COLOURFX_T */
6702 + MMAL_PARAMETER_COLOUR_EFFECT,
6703 + /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */
6704 + MMAL_PARAMETER_FLICKER_AVOID,
6705 + /**< @ref MMAL_PARAMETER_FLASH_T */
6706 + MMAL_PARAMETER_FLASH,
6707 + /**< @ref MMAL_PARAMETER_REDEYE_T */
6708 + MMAL_PARAMETER_REDEYE,
6709 + /**< @ref MMAL_PARAMETER_FOCUS_T */
6710 + MMAL_PARAMETER_FOCUS,
6712 + MMAL_PARAMETER_FOCAL_LENGTHS,
6713 + /**< @ref MMAL_PARAMETER_INT32_T */
6714 + MMAL_PARAMETER_EXPOSURE_COMP,
6715 + /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */
6716 + MMAL_PARAMETER_ZOOM,
6717 + /**< @ref MMAL_PARAMETER_MIRROR_T */
6718 + MMAL_PARAMETER_MIRROR,
6721 + /**< @ref MMAL_PARAMETER_UINT32_T */
6722 + MMAL_PARAMETER_CAMERA_NUM,
6723 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6724 + MMAL_PARAMETER_CAPTURE,
6725 + /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */
6726 + MMAL_PARAMETER_EXPOSURE_MODE,
6727 + /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */
6728 + MMAL_PARAMETER_EXP_METERING_MODE,
6729 + /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */
6730 + MMAL_PARAMETER_FOCUS_STATUS,
6731 + /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */
6732 + MMAL_PARAMETER_CAMERA_CONFIG,
6733 + /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */
6734 + MMAL_PARAMETER_CAPTURE_STATUS,
6735 + /**< @ref MMAL_PARAMETER_FACE_TRACK_T */
6736 + MMAL_PARAMETER_FACE_TRACK,
6737 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6738 + MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS,
6739 + /**< @ref MMAL_PARAMETER_UINT32_T */
6740 + MMAL_PARAMETER_JPEG_Q_FACTOR,
6741 + /**< @ref MMAL_PARAMETER_FRAME_RATE_T */
6742 + MMAL_PARAMETER_FRAME_RATE,
6743 + /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */
6744 + MMAL_PARAMETER_USE_STC,
6745 + /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */
6746 + MMAL_PARAMETER_CAMERA_INFO,
6747 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6748 + MMAL_PARAMETER_VIDEO_STABILISATION,
6749 + /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */
6750 + MMAL_PARAMETER_FACE_TRACK_RESULTS,
6751 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6752 + MMAL_PARAMETER_ENABLE_RAW_CAPTURE,
6755 + /**< @ref MMAL_PARAMETER_URI_T */
6756 + MMAL_PARAMETER_DPF_FILE,
6757 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6758 + MMAL_PARAMETER_ENABLE_DPF_FILE,
6759 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6760 + MMAL_PARAMETER_DPF_FAIL_IS_FATAL,
6761 + /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */
6762 + MMAL_PARAMETER_CAPTURE_MODE,
6763 + /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */
6764 + MMAL_PARAMETER_FOCUS_REGIONS,
6765 + /**< @ref MMAL_PARAMETER_INPUT_CROP_T */
6766 + MMAL_PARAMETER_INPUT_CROP,
6767 + /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */
6768 + MMAL_PARAMETER_SENSOR_INFORMATION,
6769 + /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */
6770 + MMAL_PARAMETER_FLASH_SELECT,
6771 + /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */
6772 + MMAL_PARAMETER_FIELD_OF_VIEW,
6773 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6774 + MMAL_PARAMETER_HIGH_DYNAMIC_RANGE,
6775 + /**< @ref MMAL_PARAMETER_DRC_T */
6776 + MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION,
6777 + /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */
6778 + MMAL_PARAMETER_ALGORITHM_CONTROL,
6779 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6780 + MMAL_PARAMETER_SHARPNESS,
6781 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6782 + MMAL_PARAMETER_CONTRAST,
6783 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6784 + MMAL_PARAMETER_BRIGHTNESS,
6785 + /**< @ref MMAL_PARAMETER_RATIONAL_T */
6786 + MMAL_PARAMETER_SATURATION,
6789 + /**< @ref MMAL_PARAMETER_UINT32_T */
6790 + MMAL_PARAMETER_ISO,
6791 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6792 + MMAL_PARAMETER_ANTISHAKE,
6793 + /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */
6794 + MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,
6795 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
6796 + MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
6797 + /** @ref MMAL_PARAMETER_UINT32_T */
6798 + MMAL_PARAMETER_CAMERA_MIN_ISO,
6799 + /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */
6800 + MMAL_PARAMETER_CAMERA_USE_CASE,
6801 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6802 + MMAL_PARAMETER_CAPTURE_STATS_PASS,
6803 + /** @ref MMAL_PARAMETER_UINT32_T */
6804 + MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG,
6805 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
6806 + MMAL_PARAMETER_ENABLE_REGISTER_FILE,
6807 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
6808 + MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
6809 + /** @ref MMAL_PARAMETER_CONFIGFILE_T */
6810 + MMAL_PARAMETER_CONFIGFILE_REGISTERS,
6811 + /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */
6812 + MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS,
6813 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6814 + MMAL_PARAMETER_JPEG_ATTACH_LOG,
6815 + /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */
6816 + MMAL_PARAMETER_ZERO_SHUTTER_LAG,
6817 + /**< @ref MMAL_PARAMETER_FPS_RANGE_T */
6818 + MMAL_PARAMETER_FPS_RANGE,
6819 + /**< @ref MMAL_PARAMETER_INT32_T */
6820 + MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP,
6823 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6824 + MMAL_PARAMETER_SW_SHARPEN_DISABLE,
6825 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6826 + MMAL_PARAMETER_FLASH_REQUIRED,
6827 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
6828 + MMAL_PARAMETER_SW_SATURATION_DISABLE,
6829 + /**< Takes a @ref MMAL_PARAMETER_UINT32_T */
6830 + MMAL_PARAMETER_SHUTTER_SPEED,
6831 + /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */
6832 + MMAL_PARAMETER_CUSTOM_AWB_GAINS,
6835 +struct mmal_parameter_rational {
6836 + s32 num; /**< Numerator */
6837 + s32 den; /**< Denominator */
6840 +enum mmal_parameter_camera_config_timestamp_mode {
6841 + MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */
6842 + MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value
6843 + * for the frame timestamp
6845 + MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp
6846 + * but subtract the
6847 + * timestamp of the first
6848 + * frame sent to give a
6849 + * zero based timestamp.
6853 +struct mmal_parameter_fps_range {
6854 + /**< Low end of the permitted framerate range */
6855 + struct mmal_parameter_rational fps_low;
6856 + /**< High end of the permitted framerate range */
6857 + struct mmal_parameter_rational fps_high;
6860 +/* camera configuration parameter */
6861 +struct mmal_parameter_camera_config {
6862 + /* Parameters for setting up the image pools */
6863 + u32 max_stills_w; /* Max size of stills capture */
6865 + u32 stills_yuv422; /* Allow YUV422 stills capture */
6866 + u32 one_shot_stills; /* Continuous or one shot stills captures. */
6868 + u32 max_preview_video_w; /* Max size of the preview or video
6871 + u32 max_preview_video_h;
6872 + u32 num_preview_video_frames;
6874 + /** Sets the height of the circular buffer for stills capture. */
6875 + u32 stills_capture_circular_buffer_height;
6877 + /** Allows preview/encode to resume as fast as possible after the stills
6878 + * input frame has been received, and then processes the still frame in
6879 + * the background whilst preview/encode has resumed.
6880 + * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE.
6882 + u32 fast_preview_resume;
6884 + /** Selects algorithm for timestamping frames if
6885 + * there is no clock component connected.
6886 + * enum mmal_parameter_camera_config_timestamp_mode
6888 + s32 use_stc_timestamp;
6891 +enum mmal_parameter_exposuremode {
6892 + MMAL_PARAM_EXPOSUREMODE_OFF,
6893 + MMAL_PARAM_EXPOSUREMODE_AUTO,
6894 + MMAL_PARAM_EXPOSUREMODE_NIGHT,
6895 + MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
6896 + MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
6897 + MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
6898 + MMAL_PARAM_EXPOSUREMODE_SPORTS,
6899 + MMAL_PARAM_EXPOSUREMODE_SNOW,
6900 + MMAL_PARAM_EXPOSUREMODE_BEACH,
6901 + MMAL_PARAM_EXPOSUREMODE_VERYLONG,
6902 + MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
6903 + MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
6904 + MMAL_PARAM_EXPOSUREMODE_FIREWORKS,
6907 +enum mmal_parameter_exposuremeteringmode {
6908 + MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
6909 + MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
6910 + MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
6911 + MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX,
6914 +enum mmal_parameter_awbmode {
6915 + MMAL_PARAM_AWBMODE_OFF,
6916 + MMAL_PARAM_AWBMODE_AUTO,
6917 + MMAL_PARAM_AWBMODE_SUNLIGHT,
6918 + MMAL_PARAM_AWBMODE_CLOUDY,
6919 + MMAL_PARAM_AWBMODE_SHADE,
6920 + MMAL_PARAM_AWBMODE_TUNGSTEN,
6921 + MMAL_PARAM_AWBMODE_FLUORESCENT,
6922 + MMAL_PARAM_AWBMODE_INCANDESCENT,
6923 + MMAL_PARAM_AWBMODE_FLASH,
6924 + MMAL_PARAM_AWBMODE_HORIZON,
6927 +enum mmal_parameter_imagefx {
6928 + MMAL_PARAM_IMAGEFX_NONE,
6929 + MMAL_PARAM_IMAGEFX_NEGATIVE,
6930 + MMAL_PARAM_IMAGEFX_SOLARIZE,
6931 + MMAL_PARAM_IMAGEFX_POSTERIZE,
6932 + MMAL_PARAM_IMAGEFX_WHITEBOARD,
6933 + MMAL_PARAM_IMAGEFX_BLACKBOARD,
6934 + MMAL_PARAM_IMAGEFX_SKETCH,
6935 + MMAL_PARAM_IMAGEFX_DENOISE,
6936 + MMAL_PARAM_IMAGEFX_EMBOSS,
6937 + MMAL_PARAM_IMAGEFX_OILPAINT,
6938 + MMAL_PARAM_IMAGEFX_HATCH,
6939 + MMAL_PARAM_IMAGEFX_GPEN,
6940 + MMAL_PARAM_IMAGEFX_PASTEL,
6941 + MMAL_PARAM_IMAGEFX_WATERCOLOUR,
6942 + MMAL_PARAM_IMAGEFX_FILM,
6943 + MMAL_PARAM_IMAGEFX_BLUR,
6944 + MMAL_PARAM_IMAGEFX_SATURATION,
6945 + MMAL_PARAM_IMAGEFX_COLOURSWAP,
6946 + MMAL_PARAM_IMAGEFX_WASHEDOUT,
6947 + MMAL_PARAM_IMAGEFX_POSTERISE,
6948 + MMAL_PARAM_IMAGEFX_COLOURPOINT,
6949 + MMAL_PARAM_IMAGEFX_COLOURBALANCE,
6950 + MMAL_PARAM_IMAGEFX_CARTOON,
6953 +enum MMAL_PARAM_FLICKERAVOID_T {
6954 + MMAL_PARAM_FLICKERAVOID_OFF,
6955 + MMAL_PARAM_FLICKERAVOID_AUTO,
6956 + MMAL_PARAM_FLICKERAVOID_50HZ,
6957 + MMAL_PARAM_FLICKERAVOID_60HZ,
6958 + MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF
6961 +struct mmal_parameter_awbgains {
6962 + struct mmal_parameter_rational r_gain; /**< Red gain */
6963 + struct mmal_parameter_rational b_gain; /**< Blue gain */
6966 +/** Manner of video rate control */
6967 +enum mmal_parameter_rate_control_mode {
6968 + MMAL_VIDEO_RATECONTROL_DEFAULT,
6969 + MMAL_VIDEO_RATECONTROL_VARIABLE,
6970 + MMAL_VIDEO_RATECONTROL_CONSTANT,
6971 + MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES,
6972 + MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES
6975 +enum mmal_video_profile {
6976 + MMAL_VIDEO_PROFILE_H263_BASELINE,
6977 + MMAL_VIDEO_PROFILE_H263_H320CODING,
6978 + MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE,
6979 + MMAL_VIDEO_PROFILE_H263_ISWV2,
6980 + MMAL_VIDEO_PROFILE_H263_ISWV3,
6981 + MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION,
6982 + MMAL_VIDEO_PROFILE_H263_INTERNET,
6983 + MMAL_VIDEO_PROFILE_H263_INTERLACE,
6984 + MMAL_VIDEO_PROFILE_H263_HIGHLATENCY,
6985 + MMAL_VIDEO_PROFILE_MP4V_SIMPLE,
6986 + MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE,
6987 + MMAL_VIDEO_PROFILE_MP4V_CORE,
6988 + MMAL_VIDEO_PROFILE_MP4V_MAIN,
6989 + MMAL_VIDEO_PROFILE_MP4V_NBIT,
6990 + MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE,
6991 + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE,
6992 + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA,
6993 + MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED,
6994 + MMAL_VIDEO_PROFILE_MP4V_HYBRID,
6995 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME,
6996 + MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE,
6997 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING,
6998 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE,
6999 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE,
7000 + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE,
7001 + MMAL_VIDEO_PROFILE_H264_BASELINE,
7002 + MMAL_VIDEO_PROFILE_H264_MAIN,
7003 + MMAL_VIDEO_PROFILE_H264_EXTENDED,
7004 + MMAL_VIDEO_PROFILE_H264_HIGH,
7005 + MMAL_VIDEO_PROFILE_H264_HIGH10,
7006 + MMAL_VIDEO_PROFILE_H264_HIGH422,
7007 + MMAL_VIDEO_PROFILE_H264_HIGH444,
7008 + MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE,
7009 + MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF
7012 +enum mmal_video_level {
7013 + MMAL_VIDEO_LEVEL_H263_10,
7014 + MMAL_VIDEO_LEVEL_H263_20,
7015 + MMAL_VIDEO_LEVEL_H263_30,
7016 + MMAL_VIDEO_LEVEL_H263_40,
7017 + MMAL_VIDEO_LEVEL_H263_45,
7018 + MMAL_VIDEO_LEVEL_H263_50,
7019 + MMAL_VIDEO_LEVEL_H263_60,
7020 + MMAL_VIDEO_LEVEL_H263_70,
7021 + MMAL_VIDEO_LEVEL_MP4V_0,
7022 + MMAL_VIDEO_LEVEL_MP4V_0b,
7023 + MMAL_VIDEO_LEVEL_MP4V_1,
7024 + MMAL_VIDEO_LEVEL_MP4V_2,
7025 + MMAL_VIDEO_LEVEL_MP4V_3,
7026 + MMAL_VIDEO_LEVEL_MP4V_4,
7027 + MMAL_VIDEO_LEVEL_MP4V_4a,
7028 + MMAL_VIDEO_LEVEL_MP4V_5,
7029 + MMAL_VIDEO_LEVEL_MP4V_6,
7030 + MMAL_VIDEO_LEVEL_H264_1,
7031 + MMAL_VIDEO_LEVEL_H264_1b,
7032 + MMAL_VIDEO_LEVEL_H264_11,
7033 + MMAL_VIDEO_LEVEL_H264_12,
7034 + MMAL_VIDEO_LEVEL_H264_13,
7035 + MMAL_VIDEO_LEVEL_H264_2,
7036 + MMAL_VIDEO_LEVEL_H264_21,
7037 + MMAL_VIDEO_LEVEL_H264_22,
7038 + MMAL_VIDEO_LEVEL_H264_3,
7039 + MMAL_VIDEO_LEVEL_H264_31,
7040 + MMAL_VIDEO_LEVEL_H264_32,
7041 + MMAL_VIDEO_LEVEL_H264_4,
7042 + MMAL_VIDEO_LEVEL_H264_41,
7043 + MMAL_VIDEO_LEVEL_H264_42,
7044 + MMAL_VIDEO_LEVEL_H264_5,
7045 + MMAL_VIDEO_LEVEL_H264_51,
7046 + MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF
7049 +struct mmal_parameter_video_profile {
7050 + enum mmal_video_profile profile;
7051 + enum mmal_video_level level;
7054 +/* video parameters */
7056 +enum mmal_parameter_video_type {
7057 + /** @ref MMAL_DISPLAYREGION_T */
7058 + MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO,
7060 + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
7061 + MMAL_PARAMETER_SUPPORTED_PROFILES,
7063 + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
7064 + MMAL_PARAMETER_PROFILE,
7066 + /** @ref MMAL_PARAMETER_UINT32_T */
7067 + MMAL_PARAMETER_INTRAPERIOD,
7069 + /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */
7070 + MMAL_PARAMETER_RATECONTROL,
7072 + /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */
7073 + MMAL_PARAMETER_NALUNITFORMAT,
7075 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7076 + MMAL_PARAMETER_MINIMISE_FRAGMENTATION,
7078 + /** @ref MMAL_PARAMETER_UINT32_T.
7079 + * Setting the value to zero resets to the default (one slice per
7082 + MMAL_PARAMETER_MB_ROWS_PER_SLICE,
7084 + /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */
7085 + MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION,
7087 + /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */
7088 + MMAL_PARAMETER_VIDEO_EEDE_ENABLE,
7090 + /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */
7091 + MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE,
7093 + /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */
7094 + MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME,
7095 + /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */
7096 + MMAL_PARAMETER_VIDEO_INTRA_REFRESH,
7098 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7099 + MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT,
7101 + /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */
7102 + MMAL_PARAMETER_VIDEO_BIT_RATE,
7104 + /** @ref MMAL_PARAMETER_FRAME_RATE_T */
7105 + MMAL_PARAMETER_VIDEO_FRAME_RATE,
7107 + /** @ref MMAL_PARAMETER_UINT32_T. */
7108 + MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
7110 + /** @ref MMAL_PARAMETER_UINT32_T. */
7111 + MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
7113 + /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */
7114 + MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL,
7116 + MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */
7117 + /** @ref MMAL_PARAMETER_UINT32_T.
7118 + * Changing this parameter from the default can reduce frame rate
7119 + * because image buffers need to be re-pitched.
7121 + MMAL_PARAMETER_VIDEO_ALIGN_HORIZ,
7123 + /** @ref MMAL_PARAMETER_UINT32_T.
7124 + * Changing this parameter from the default can reduce frame rate
7125 + * because image buffers need to be re-pitched.
7127 + MMAL_PARAMETER_VIDEO_ALIGN_VERT,
7129 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7130 + MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES,
7132 + /** @ref MMAL_PARAMETER_UINT32_T. */
7133 + MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT,
7135 + /**< @ref MMAL_PARAMETER_UINT32_T. */
7136 + MMAL_PARAMETER_VIDEO_ENCODE_QP_P,
7138 + /**< @ref MMAL_PARAMETER_UINT32_T. */
7139 + MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT,
7141 + /** @ref MMAL_PARAMETER_UINT32_T */
7142 + MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS,
7144 + /** @ref MMAL_PARAMETER_UINT32_T. */
7145 + MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE,
7147 + /* H264 specific parameters */
7149 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7150 + MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC,
7152 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7153 + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY,
7155 + /** @ref MMAL_PARAMETER_BOOLEAN_T. */
7156 + MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS,
7158 + /** @ref MMAL_PARAMETER_UINT32_T. */
7159 + MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC,
7161 + /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */
7162 + MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE,
7164 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7165 + MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN,
7167 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7168 + MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP,
7170 + /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */
7171 + MMAL_PARAMETER_VIDEO_DRM_INIT_INFO,
7173 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7174 + MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO,
7176 + /** @ref MMAL_PARAMETER_BOOLEAN_T */
7177 + MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT,
7179 + /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */
7180 + MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
7182 + /** @ref MMAL_PARAMETER_BYTES_T */
7183 + MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
7185 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
7186 + MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
7188 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
7189 + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
7191 + /**< @ref MMAL_PARAMETER_BOOLEAN_T */
7192 + MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
7195 +/** Valid mirror modes */
7196 +enum mmal_parameter_mirror {
7197 + MMAL_PARAM_MIRROR_NONE,
7198 + MMAL_PARAM_MIRROR_VERTICAL,
7199 + MMAL_PARAM_MIRROR_HORIZONTAL,
7200 + MMAL_PARAM_MIRROR_BOTH,
7203 +enum mmal_parameter_displaytransform {
7204 + MMAL_DISPLAY_ROT0 = 0,
7205 + MMAL_DISPLAY_MIRROR_ROT0 = 1,
7206 + MMAL_DISPLAY_MIRROR_ROT180 = 2,
7207 + MMAL_DISPLAY_ROT180 = 3,
7208 + MMAL_DISPLAY_MIRROR_ROT90 = 4,
7209 + MMAL_DISPLAY_ROT270 = 5,
7210 + MMAL_DISPLAY_ROT90 = 6,
7211 + MMAL_DISPLAY_MIRROR_ROT270 = 7,
7214 +enum mmal_parameter_displaymode {
7215 + MMAL_DISPLAY_MODE_FILL = 0,
7216 + MMAL_DISPLAY_MODE_LETTERBOX = 1,
7219 +enum mmal_parameter_displayset {
7220 + MMAL_DISPLAY_SET_NONE = 0,
7221 + MMAL_DISPLAY_SET_NUM = 1,
7222 + MMAL_DISPLAY_SET_FULLSCREEN = 2,
7223 + MMAL_DISPLAY_SET_TRANSFORM = 4,
7224 + MMAL_DISPLAY_SET_DEST_RECT = 8,
7225 + MMAL_DISPLAY_SET_SRC_RECT = 0x10,
7226 + MMAL_DISPLAY_SET_MODE = 0x20,
7227 + MMAL_DISPLAY_SET_PIXEL = 0x40,
7228 + MMAL_DISPLAY_SET_NOASPECT = 0x80,
7229 + MMAL_DISPLAY_SET_LAYER = 0x100,
7230 + MMAL_DISPLAY_SET_COPYPROTECT = 0x200,
7231 + MMAL_DISPLAY_SET_ALPHA = 0x400,
7234 +/* rectangle, used lots so it gets its own struct */
7235 +struct vchiq_mmal_rect {
7242 +struct mmal_parameter_displayregion {
7243 + /** Bitfield that indicates which fields are set and should be
7244 + * used. All other fields will maintain their current value.
7245 + * \ref MMAL_DISPLAYSET_T defines the bits that can be
7250 + /** Describes the display output device, with 0 typically
7251 + * being a directly connected LCD display. The actual values
7252 + * will depend on the hardware. Code using hard-wired numbers
7253 + * (e.g. 2) is certain to fail.
7257 + /** Indicates that we are using the full device screen area,
7258 + * rather than a window of the display. If zero, then
7259 + * dest_rect is used to specify a region of the display to
7264 + /** Indicates any rotation or flipping used to map frames onto
7265 + * the natural display orientation.
7267 + u32 transform; /* enum mmal_parameter_displaytransform */
7269 + /** Where to display the frame within the screen, if
7270 + * fullscreen is zero.
7272 + struct vchiq_mmal_rect dest_rect;
7274 + /** Indicates which area of the frame to display. If all
7275 + * values are zero, the whole frame will be used.
7277 + struct vchiq_mmal_rect src_rect;
7279 + /** If set to non-zero, indicates that any display scaling
7280 + * should disregard the aspect ratio of the frame region being
7285 + /** Indicates how the image should be scaled to fit the
7286 + * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates
7287 + * that the image should fill the screen by potentially
7288 + * cropping the frames. Setting \code mode \endcode to \code
7289 + * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the
7290 + * source region should be displayed and black bars added if
7293 + u32 mode; /* enum mmal_parameter_displaymode */
7295 + /** If non-zero, defines the width of a source pixel relative
7296 + * to \code pixel_y \endcode. If zero, then pixels default to
7301 + /** If non-zero, defines the height of a source pixel relative
7302 + * to \code pixel_x \endcode. If zero, then pixels default to
7307 + /** Sets the relative depth of the images, with greater values
7308 + * being in front of smaller values.
7312 + /** Set to non-zero to ensure copy protection is used on
7315 + s32 copyprotect_required;
7317 + /** Level of opacity of the layer, where zero is fully
7318 + * transparent and 255 is fully opaque.
7323 +#define MMAL_MAX_IMAGEFX_PARAMETERS 5
7325 +struct mmal_parameter_imagefx_parameters {
7326 + enum mmal_parameter_imagefx effect;
7327 + u32 num_effect_params;
7328 + u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS];
7331 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4
7332 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2
7333 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16
7335 +struct mmal_parameter_camera_info_camera_t {
7340 + u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN];
7343 +enum mmal_parameter_camera_info_flash_type_t {
7344 + /* Make values explicit to ensure they match values in config ini */
7345 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0,
7346 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1,
7347 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2,
7348 + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF
7351 +struct mmal_parameter_camera_info_flash_t {
7352 + enum mmal_parameter_camera_info_flash_type_t flash_type;
7355 +struct mmal_parameter_camera_info_t {
7358 + struct mmal_parameter_camera_info_camera_t
7359 + cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS];
7360 + struct mmal_parameter_camera_info_flash_t
7361 + flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES];
7366 +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
7368 +/* SPDX-License-Identifier: GPL-2.0 */
7370 + * Broadcom BM2835 V4L2 driver
7372 + * Copyright © 2013 Raspberry Pi (Trading) Ltd.
7374 + * Authors: Vincent Sanders @ Collabora
7375 + * Dave Stevenson @ Broadcom
7376 + * (now dave.stevenson@raspberrypi.org)
7377 + * Simon Mellor @ Broadcom
7378 + * Luke Diamand @ Broadcom
7380 + * MMAL interface to VCHIQ message passing
7383 +#ifndef MMAL_VCHIQ_H
7384 +#define MMAL_VCHIQ_H
7386 +#include "mmal-msg-format.h"
7388 +#define MAX_PORT_COUNT 4
7390 +/* Maximum size of the format extradata. */
7391 +#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
7393 +struct vchiq_mmal_instance;
7395 +enum vchiq_mmal_es_type {
7396 + MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
7397 + MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
7398 + MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
7399 + MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
7400 + MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
7403 +struct vchiq_mmal_port_buffer {
7404 + unsigned int num; /* number of buffers */
7405 + u32 size; /* size of buffers */
7406 + u32 alignment; /* alignment of buffers */
7409 +struct vchiq_mmal_port;
7411 +typedef void (*vchiq_mmal_buffer_cb)(
7412 + struct vchiq_mmal_instance *instance,
7413 + struct vchiq_mmal_port *port,
7414 + int status, struct mmal_buffer *buffer,
7415 + unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
7417 +struct vchiq_mmal_port {
7420 + u32 type; /* port type, cached to use on port info set */
7421 + u32 index; /* port index, cached to use on port info set */
7423 + /* component port belongs to, allows simple deref */
7424 + struct vchiq_mmal_component *component;
7426 + struct vchiq_mmal_port *connected; /* port conencted to */
7429 + struct vchiq_mmal_port_buffer minimum_buffer;
7430 + struct vchiq_mmal_port_buffer recommended_buffer;
7431 + struct vchiq_mmal_port_buffer current_buffer;
7433 + /* stream format */
7434 + struct mmal_es_format_local format;
7435 + /* elementary stream format */
7436 + union mmal_es_specific_format es;
7438 + /* data buffers to fill */
7439 + struct list_head buffers;
7440 + /* lock to serialise adding and removing buffers from list */
7443 + /* Count of buffers the VPU has yet to return */
7444 + atomic_t buffers_with_vpu;
7445 + /* callback on buffer completion */
7446 + vchiq_mmal_buffer_cb buffer_cb;
7447 + /* callback context */
7451 +struct vchiq_mmal_component {
7453 + u32 handle; /* VideoCore handle for component */
7454 + u32 inputs; /* Number of input ports */
7455 + u32 outputs; /* Number of output ports */
7456 + u32 clocks; /* Number of clock ports */
7457 + struct vchiq_mmal_port control; /* control port */
7458 + struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
7459 + struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
7460 + struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
7463 +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
7464 +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
7466 +/* Initialise a mmal component and its ports
7469 +int vchiq_mmal_component_init(
7470 + struct vchiq_mmal_instance *instance,
7472 + struct vchiq_mmal_component **component_out);
7474 +int vchiq_mmal_component_finalise(
7475 + struct vchiq_mmal_instance *instance,
7476 + struct vchiq_mmal_component *component);
7478 +int vchiq_mmal_component_enable(
7479 + struct vchiq_mmal_instance *instance,
7480 + struct vchiq_mmal_component *component);
7482 +int vchiq_mmal_component_disable(
7483 + struct vchiq_mmal_instance *instance,
7484 + struct vchiq_mmal_component *component);
7486 +/* enable a mmal port
7488 + * enables a port and if a buffer callback provided enque buffer
7489 + * headers as appropriate for the port.
7491 +int vchiq_mmal_port_enable(
7492 + struct vchiq_mmal_instance *instance,
7493 + struct vchiq_mmal_port *port,
7494 + vchiq_mmal_buffer_cb buffer_cb);
7498 + * disable a port will dequeue any pending buffers
7500 +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
7501 + struct vchiq_mmal_port *port);
7503 +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
7504 + struct vchiq_mmal_port *port,
7509 +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
7510 + struct vchiq_mmal_port *port,
7515 +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
7516 + struct vchiq_mmal_port *port);
7518 +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
7519 + struct vchiq_mmal_port *src,
7520 + struct vchiq_mmal_port *dst);
7522 +int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
7526 +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
7527 + struct vchiq_mmal_port *port,
7528 + struct mmal_buffer *buf);
7530 +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance,
7531 + struct mmal_buffer *buf);
7532 +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf);
7533 +#endif /* MMAL_VCHIQ_H */