]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/media/platform/bcm2835/mmal-vchiq.h
bcm2835: add v4l2 camera device
[mirror_ubuntu-zesty-kernel.git] / drivers / media / platform / bcm2835 / mmal-vchiq.h
1 /*
2 * Broadcom BM2835 V4L2 driver
3 *
4 * Copyright © 2013 Raspberry Pi (Trading) Ltd.
5 *
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
8 * for more details.
9 *
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>
14 *
15 * MMAL interface to VCHIQ message passing
16 */
17
18 #ifndef MMAL_VCHIQ_H
19 #define MMAL_VCHIQ_H
20
21 #include "mmal-msg-format.h"
22
23 #define MAX_PORT_COUNT 4
24
25 /* Maximum size of the format extradata. */
26 #define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
27
28 struct vchiq_mmal_instance;
29
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 */
36 };
37
38 /* rectangle, used lots so it gets its own struct */
39 struct vchiq_mmal_rect {
40 s32 x;
41 s32 y;
42 s32 width;
43 s32 height;
44 };
45
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 */
50 };
51
52 struct vchiq_mmal_port;
53
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);
59
60 struct vchiq_mmal_port {
61 bool enabled;
62 u32 handle;
63 u32 type; /* port type, cached to use on port info set */
64 u32 index; /* port index, cached to use on port info set */
65
66 /* component port belongs to, allows simple deref */
67 struct vchiq_mmal_component *component;
68
69 struct vchiq_mmal_port *connected; /* port conencted to */
70
71 /* buffer info */
72 struct vchiq_mmal_port_buffer minimum_buffer;
73 struct vchiq_mmal_port_buffer recommended_buffer;
74 struct vchiq_mmal_port_buffer current_buffer;
75
76 /* stream format */
77 struct mmal_es_format format;
78 /* elementry stream format */
79 union mmal_es_specific_format es;
80
81 /* data buffers to fill */
82 struct list_head buffers;
83 /* lock to serialise adding and removing buffers from list */
84 spinlock_t slock;
85 /* count of how many buffer header refils have failed because
86 * there was no buffer to satisfy them
87 */
88 int buffer_underflow;
89 /* callback on buffer completion */
90 vchiq_mmal_buffer_cb buffer_cb;
91 /* callback context */
92 void *cb_ctx;
93 };
94
95 struct vchiq_mmal_component {
96 bool enabled;
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 */
105 };
106
107
108 int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
109 int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
110
111 /* Initialise a mmal component and its ports
112 *
113 */
114 int vchiq_mmal_component_init(
115 struct vchiq_mmal_instance *instance,
116 const char *name,
117 struct vchiq_mmal_component **component_out);
118
119 int vchiq_mmal_component_finalise(
120 struct vchiq_mmal_instance *instance,
121 struct vchiq_mmal_component *component);
122
123 int vchiq_mmal_component_enable(
124 struct vchiq_mmal_instance *instance,
125 struct vchiq_mmal_component *component);
126
127 int vchiq_mmal_component_disable(
128 struct vchiq_mmal_instance *instance,
129 struct vchiq_mmal_component *component);
130
131
132
133 /* enable a mmal port
134 *
135 * enables a port and if a buffer callback provided enque buffer
136 * headers as apropriate for the port.
137 */
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);
142
143 /* disable a port
144 *
145 * disable a port will dequeue any pending buffers
146 */
147 int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
148 struct vchiq_mmal_port *port);
149
150
151 int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
152 struct vchiq_mmal_port *port,
153 u32 parameter,
154 void *value,
155 u32 value_size);
156
157 int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
158 struct vchiq_mmal_port *port,
159 u32 parameter,
160 void *value,
161 u32 *value_size);
162
163 int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
164 struct vchiq_mmal_port *port);
165
166 int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
167 struct vchiq_mmal_port *src,
168 struct vchiq_mmal_port *dst);
169
170 int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
171 u32 *major_out,
172 u32 *minor_out);
173
174 int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
175 struct vchiq_mmal_port *port,
176 struct mmal_buffer *buf);
177
178 #endif /* MMAL_VCHIQ_H */