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 format
;
78 /* elementry 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 */
108 int vchiq_mmal_init(struct vchiq_mmal_instance
**out_instance
);
109 int vchiq_mmal_finalise(struct vchiq_mmal_instance
*instance
);
111 /* Initialise a mmal component and its ports
114 int vchiq_mmal_component_init(
115 struct vchiq_mmal_instance
*instance
,
117 struct vchiq_mmal_component
**component_out
);
119 int vchiq_mmal_component_finalise(
120 struct vchiq_mmal_instance
*instance
,
121 struct vchiq_mmal_component
*component
);
123 int vchiq_mmal_component_enable(
124 struct vchiq_mmal_instance
*instance
,
125 struct vchiq_mmal_component
*component
);
127 int vchiq_mmal_component_disable(
128 struct vchiq_mmal_instance
*instance
,
129 struct vchiq_mmal_component
*component
);
133 /* enable a mmal port
135 * enables a port and if a buffer callback provided enque buffer
136 * headers as apropriate for the port.
138 int vchiq_mmal_port_enable(
139 struct vchiq_mmal_instance
*instance
,
140 struct vchiq_mmal_port
*port
,
141 vchiq_mmal_buffer_cb buffer_cb
);
145 * disable a port will dequeue any pending buffers
147 int vchiq_mmal_port_disable(struct vchiq_mmal_instance
*instance
,
148 struct vchiq_mmal_port
*port
);
151 int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance
*instance
,
152 struct vchiq_mmal_port
*port
,
157 int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance
*instance
,
158 struct vchiq_mmal_port
*port
,
163 int vchiq_mmal_port_set_format(struct vchiq_mmal_instance
*instance
,
164 struct vchiq_mmal_port
*port
);
166 int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance
*instance
,
167 struct vchiq_mmal_port
*src
,
168 struct vchiq_mmal_port
*dst
);
170 int vchiq_mmal_version(struct vchiq_mmal_instance
*instance
,
174 int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance
*instance
,
175 struct vchiq_mmal_port
*port
,
176 struct mmal_buffer
*buf
);
178 #endif /* MMAL_VCHIQ_H */