Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | /*
* Broadcom BM2835 V4L2 driver
*
* Copyright © 2013 Raspberry Pi (Trading) Ltd.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
* for more details.
*
* Authors: Vincent Sanders <vincent.sanders@collabora.co.uk>
* Dave Stevenson <dsteve@broadcom.com>
* Simon Mellor <simellor@broadcom.com>
* Luke Diamand <luked@broadcom.com>
*
* MMAL interface to VCHIQ message passing
*/
#ifndef MMAL_VCHIQ_H
#define MMAL_VCHIQ_H
#include "mmal-msg-format.h"
#define MAX_PORT_COUNT 4
/* Maximum size of the format extradata. */
#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
struct vchiq_mmal_instance;
enum vchiq_mmal_es_type {
MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */
MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */
MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */
MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */
MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */
};
/* rectangle, used lots so it gets its own struct */
struct vchiq_mmal_rect {
s32 x;
s32 y;
s32 width;
s32 height;
};
struct vchiq_mmal_port_buffer {
unsigned int num; /* number of buffers */
u32 size; /* size of buffers */
u32 alignment; /* alignment of buffers */
};
struct vchiq_mmal_port;
typedef void (*vchiq_mmal_buffer_cb)(
struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port,
int status, struct mmal_buffer *buffer,
unsigned long length, u32 mmal_flags, s64 dts, s64 pts);
struct vchiq_mmal_port {
bool enabled;
u32 handle;
u32 type; /* port type, cached to use on port info set */
u32 index; /* port index, cached to use on port info set */
/* component port belongs to, allows simple deref */
struct vchiq_mmal_component *component;
struct vchiq_mmal_port *connected; /* port conencted to */
/* buffer info */
struct vchiq_mmal_port_buffer minimum_buffer;
struct vchiq_mmal_port_buffer recommended_buffer;
struct vchiq_mmal_port_buffer current_buffer;
/* stream format */
struct mmal_es_format_local format;
/* elementary stream format */
union mmal_es_specific_format es;
/* data buffers to fill */
struct list_head buffers;
/* lock to serialise adding and removing buffers from list */
spinlock_t slock;
/* count of how many buffer header refils have failed because
* there was no buffer to satisfy them
*/
int buffer_underflow;
/* callback on buffer completion */
vchiq_mmal_buffer_cb buffer_cb;
/* callback context */
void *cb_ctx;
};
struct vchiq_mmal_component {
bool enabled;
u32 handle; /* VideoCore handle for component */
u32 inputs; /* Number of input ports */
u32 outputs; /* Number of output ports */
u32 clocks; /* Number of clock ports */
struct vchiq_mmal_port control; /* control port */
struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */
struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */
struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */
};
int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance);
int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance);
/* Initialise a mmal component and its ports
*
*/
int vchiq_mmal_component_init(
struct vchiq_mmal_instance *instance,
const char *name,
struct vchiq_mmal_component **component_out);
int vchiq_mmal_component_finalise(
struct vchiq_mmal_instance *instance,
struct vchiq_mmal_component *component);
int vchiq_mmal_component_enable(
struct vchiq_mmal_instance *instance,
struct vchiq_mmal_component *component);
int vchiq_mmal_component_disable(
struct vchiq_mmal_instance *instance,
struct vchiq_mmal_component *component);
/* enable a mmal port
*
* enables a port and if a buffer callback provided enque buffer
* headers as apropriate for the port.
*/
int vchiq_mmal_port_enable(
struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port,
vchiq_mmal_buffer_cb buffer_cb);
/* disable a port
*
* disable a port will dequeue any pending buffers
*/
int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port);
int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port,
u32 parameter,
void *value,
u32 value_size);
int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port,
u32 parameter,
void *value,
u32 *value_size);
int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port);
int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *src,
struct vchiq_mmal_port *dst);
int vchiq_mmal_version(struct vchiq_mmal_instance *instance,
u32 *major_out,
u32 *minor_out);
int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,
struct vchiq_mmal_port *port,
struct mmal_buffer *buf);
#endif /* MMAL_VCHIQ_H */
|