2 * Broadcom BM2835 V4L2 driver
4 * Copyright © 2013 Raspberry Pi (Trading) Ltd.
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
10 * Authors: Vincent Sanders <vincent.sanders@collabora.co.uk>
11 * Dave Stevenson <dsteve@broadcom.com>
12 * Simon Mellor <simellor@broadcom.com>
13 * Luke Diamand <luked@broadcom.com>
15 * MMAL interface to VCHIQ message passing
21 #include "mmal-msg-format.h"
23 #define MAX_PORT_COUNT 4
25 /* Maximum size of the format extradata. */
26 #define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
28 struct vchiq_mmal_instance;
30 enum vchiq_mmal_es_type {
31 MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
32 MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
33 MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
34 MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
35 MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
38 /* rectangle, used lots so it gets its own struct */
39 struct vchiq_mmal_rect {
46 struct vchiq_mmal_port_buffer {
47 unsigned int num; /* number of buffers */
48 u32 size; /* size of buffers */
49 u32 alignment; /* alignment of buffers */
52 struct vchiq_mmal_port;
54 typedef void (*vchiq_mmal_buffer_cb)(
55 struct vchiq_mmal_instance *instance,
56 struct vchiq_mmal_port *port,
57 int status, struct mmal_buffer *buffer,
58 unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
60 struct vchiq_mmal_port {
63 u32 type; /* port type, cached to use on port info set */
64 u32 index; /* port index, cached to use on port info set */
66 /* component port belongs to, allows simple deref */
67 struct vchiq_mmal_component *component;
69 struct vchiq_mmal_port *connected; /* port conencted to */
72 struct vchiq_mmal_port_buffer minimum_buffer;
73 struct vchiq_mmal_port_buffer recommended_buffer;
74 struct vchiq_mmal_port_buffer current_buffer;
77 struct mmal_es_format_local format;
78 /* elementary stream format */
79 union mmal_es_specific_format es;
81 /* data buffers to fill */
82 struct list_head buffers;
83 /* lock to serialise adding and removing buffers from list */
85 /* count of how many buffer header refils have failed because
86 * there was no buffer to satisfy them
89 /* callback on buffer completion */
90 vchiq_mmal_buffer_cb buffer_cb;
91 /* callback context */
95 struct vchiq_mmal_component {
97 u32 handle; /* VideoCore handle for component */
98 u32 inputs; /* Number of input ports */
99 u32 outputs; /* Number of output ports */
100 u32 clocks; /* Number of clock ports */
101 struct vchiq_mmal_port control; /* control port */
102 struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
103 struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
104 struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
107 int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
108 int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
110 /* Initialise a mmal component and its ports
113 int vchiq_mmal_component_init(
114 struct vchiq_mmal_instance *instance,
116 struct vchiq_mmal_component **component_out);
118 int vchiq_mmal_component_finalise(
119 struct vchiq_mmal_instance *instance,
120 struct vchiq_mmal_component *component);
122 int vchiq_mmal_component_enable(
123 struct vchiq_mmal_instance *instance,
124 struct vchiq_mmal_component *component);
126 int vchiq_mmal_component_disable(
127 struct vchiq_mmal_instance *instance,
128 struct vchiq_mmal_component *component);
130 /* enable a mmal port
132 * enables a port and if a buffer callback provided enque buffer
133 * headers as apropriate for the port.
135 int vchiq_mmal_port_enable(
136 struct vchiq_mmal_instance *instance,
137 struct vchiq_mmal_port *port,
138 vchiq_mmal_buffer_cb buffer_cb);
142 * disable a port will dequeue any pending buffers
144 int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
145 struct vchiq_mmal_port *port);
147 int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
148 struct vchiq_mmal_port *port,
153 int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
154 struct vchiq_mmal_port *port,
159 int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
160 struct vchiq_mmal_port *port);
162 int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
163 struct vchiq_mmal_port *src,
164 struct vchiq_mmal_port *dst);
166 int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
170 int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
171 struct vchiq_mmal_port *port,
172 struct mmal_buffer *buf);
174 #endif /* MMAL_VCHIQ_H */