Commit 7b3ad5ab authored by Eric Anholt's avatar Eric Anholt Committed by Greg Kroah-Hartman

staging: Import the BCM2835 MMAL-based V4L2 camera driver.

- Supports raw YUV capture, preview, JPEG and H264.
- Uses videobuf2 for data transfer, using dma_buf.
- Uses 3.6.10 timestamping
- Camera power based on use
- Uses immutable input mode on video encoder

This code comes from the Raspberry Pi kernel tree (rpi-4.9.y) as of
a15ba877dab4e61ea3fc7b006e2a73828b083c52.
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 50e66ccb
This diff is collapsed.
/*
* 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>
*
* core driver device
*/
#define V4L2_CTRL_COUNT 29 /* number of v4l controls */
enum {
MMAL_COMPONENT_CAMERA = 0,
MMAL_COMPONENT_PREVIEW,
MMAL_COMPONENT_IMAGE_ENCODE,
MMAL_COMPONENT_VIDEO_ENCODE,
MMAL_COMPONENT_COUNT
};
enum {
MMAL_CAMERA_PORT_PREVIEW = 0,
MMAL_CAMERA_PORT_VIDEO,
MMAL_CAMERA_PORT_CAPTURE,
MMAL_CAMERA_PORT_COUNT
};
#define PREVIEW_LAYER 2
extern int bcm2835_v4l2_debug;
struct bm2835_mmal_dev {
/* v4l2 devices */
struct v4l2_device v4l2_dev;
struct video_device vdev;
struct mutex mutex;
/* controls */
struct v4l2_ctrl_handler ctrl_handler;
struct v4l2_ctrl *ctrls[V4L2_CTRL_COUNT];
enum v4l2_scene_mode scene_mode;
struct mmal_colourfx colourfx;
int hflip;
int vflip;
int red_gain;
int blue_gain;
enum mmal_parameter_exposuremode exposure_mode_user;
enum v4l2_exposure_auto_type exposure_mode_v4l2_user;
/* active exposure mode may differ if selected via a scene mode */
enum mmal_parameter_exposuremode exposure_mode_active;
enum mmal_parameter_exposuremeteringmode metering_mode;
unsigned int manual_shutter_speed;
bool exp_auto_priority;
bool manual_iso_enabled;
uint32_t iso;
/* allocated mmal instance and components */
struct vchiq_mmal_instance *instance;
struct vchiq_mmal_component *component[MMAL_COMPONENT_COUNT];
int camera_use_count;
struct v4l2_window overlay;
struct {
unsigned int width; /* width */
unsigned int height; /* height */
unsigned int stride; /* stride */
unsigned int buffersize; /* buffer size with padding */
struct mmal_fmt *fmt;
struct v4l2_fract timeperframe;
/* H264 encode bitrate */
int encode_bitrate;
/* H264 bitrate mode. CBR/VBR */
int encode_bitrate_mode;
/* H264 profile */
enum v4l2_mpeg_video_h264_profile enc_profile;
/* H264 level */
enum v4l2_mpeg_video_h264_level enc_level;
/* JPEG Q-factor */
int q_factor;
struct vb2_queue vb_vidq;
/* VC start timestamp for streaming */
s64 vc_start_timestamp;
/* Kernel start timestamp for streaming */
struct timeval kernel_start_ts;
struct vchiq_mmal_port *port; /* port being used for capture */
/* camera port being used for capture */
struct vchiq_mmal_port *camera_port;
/* component being used for encode */
struct vchiq_mmal_component *encode_component;
/* number of frames remaining which driver should capture */
unsigned int frame_count;
/* last frame completion */
struct completion frame_cmplt;
} capture;
unsigned int camera_num;
unsigned int max_width;
unsigned int max_height;
unsigned int rgb_bgr_swapped;
};
int bm2835_mmal_init_controls(
struct bm2835_mmal_dev *dev,
struct v4l2_ctrl_handler *hdl);
int bm2835_mmal_set_all_camera_controls(struct bm2835_mmal_dev *dev);
int set_framerate_params(struct bm2835_mmal_dev *dev);
/* Debug helpers */
#define v4l2_dump_pix_format(level, debug, dev, pix_fmt, desc) \
{ \
v4l2_dbg(level, debug, dev, \
"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n", \
desc == NULL ? "" : desc, \
(pix_fmt)->width, (pix_fmt)->height, (pix_fmt)->field, \
(pix_fmt)->pixelformat, (pix_fmt)->bytesperline, \
(pix_fmt)->sizeimage, (pix_fmt)->colorspace, (pix_fmt)->priv); \
}
#define v4l2_dump_win_format(level, debug, dev, win_fmt, desc) \
{ \
v4l2_dbg(level, debug, dev, \
"%s: w %u h %u l %u t %u field %u chromakey %06X clip %p " \
"clipcount %u bitmap %p\n", \
desc == NULL ? "" : desc, \
(win_fmt)->w.width, (win_fmt)->w.height, \
(win_fmt)->w.left, (win_fmt)->w.top, \
(win_fmt)->field, \
(win_fmt)->chromakey, \
(win_fmt)->clips, (win_fmt)->clipcount, \
(win_fmt)->bitmap); \
}
This diff is collapsed.
/*
* 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 structures
*
*/
#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24))
#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l')
/** Special value signalling that time is not known */
#define MMAL_TIME_UNKNOWN (1LL<<63)
/* mapping between v4l and mmal video modes */
struct mmal_fmt {
char *name;
u32 fourcc; /* v4l2 format id */
int flags; /* v4l2 flags field */
u32 mmal;
int depth;
u32 mmal_component; /* MMAL component index to be used to encode */
u32 ybbp; /* depth of first Y plane for planar formats */
};
/* buffer for one video frame */
struct mmal_buffer {
/* v4l buffer data -- must be first */
struct vb2_v4l2_buffer vb;
/* list of buffers available */
struct list_head list;
void *buffer; /* buffer pointer */
unsigned long buffer_size; /* size of allocated buffer */
};
/* */
struct mmal_colourfx {
s32 enable;
u32 u;
u32 v;
};
/*
* 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>
*/
#ifndef MMAL_ENCODINGS_H
#define MMAL_ENCODINGS_H
#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4')
#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3')
#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V')
#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V')
#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V')
#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3')
#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2')
#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1')
#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1')
#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ')
#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ')
#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ')
#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O')
#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K')
#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G')
#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G')
#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ')
#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ')
#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ')
#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ')
#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ')
#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0')
#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0')
#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2')
#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2')
#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2')
#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V')
#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U')
#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y')
#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y')
#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2')
#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1')
#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B')
#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A')
#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R')
#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A')
#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2')
#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3')
#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4')
#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2')
#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3')
#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4')
/** SAND Video (YUVUV128) format, native format understood by VideoCore.
* This format is *not* opaque - if requested you will receive full frames
* of YUV_UV video.
*/
#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D')
/** VideoCore opaque image format, image handles are returned to
* the host but not the actual image data.
*/
#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V')
/** An EGL image handle
*/
#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I')
/* }@ */
/** \name Pre-defined audio encodings */
/* @{ */
#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U')
#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u')
#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S')
#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's')
#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F')
#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f')
/* Pre-defined H264 encoding variants */
/** ISO 14496-10 Annex B byte stream format */
#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0
/** ISO 14496-15 AVC stream format */
#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1')
/** Implicitly delineated NAL units without emulation prevention */
#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ')
/** \defgroup MmalColorSpace List of pre-defined video color spaces
* This defines a list of common color spaces. This list isn't exhaustive and
* is only provided as a convenience to avoid clients having to use FourCC
* codes directly. However components are allowed to define and use their own
* FourCC codes.
*/
/* @{ */
/** Unknown color space */
#define MMAL_COLOR_SPACE_UNKNOWN 0
/** ITU-R BT.601-5 [SDTV] */
#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1')
/** ITU-R BT.709-3 [HDTV] */
#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9')
/** JPEG JFIF */
#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I')
/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */
#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C')
/** Society of Motion Picture and Television Engineers 240M (1999) */
#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0')
/** ITU-R BT.470-2 System M */
#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M')
/** ITU-R BT.470-2 System BG */
#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G')
/** JPEG JFIF, but with 16..255 luma */
#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6')
/* @} MmalColorSpace List */
#endif /* MMAL_ENCODINGS_H */
/*
* 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>
*/
#ifndef MMAL_MSG_COMMON_H
#define MMAL_MSG_COMMON_H
enum mmal_msg_status {
MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */
MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */
MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */
MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */
MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */
MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */
MMAL_MSG_STATUS_ENXIO, /**< No such device or address */
MMAL_MSG_STATUS_EIO, /**< I/O error */
MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */
MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */
MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */
MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */
MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */
MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */
MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */
MMAL_MSG_STATUS_EFAULT, /**< Bad address */
};
struct mmal_rect {
s32 x; /**< x coordinate (from left) */
s32 y; /**< y coordinate (from top) */
s32 width; /**< width */
s32 height; /**< height */
};
struct mmal_rational {
s32 num; /**< Numerator */
s32 den; /**< Denominator */
};
#endif /* MMAL_MSG_COMMON_H */
/*
* 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>
*/
#ifndef MMAL_MSG_FORMAT_H
#define MMAL_MSG_FORMAT_H
#include "mmal-msg-common.h"
/* MMAL_ES_FORMAT_T */
struct mmal_audio_format {
u32 channels; /**< Number of audio channels */
u32 sample_rate; /**< Sample rate */
u32 bits_per_sample; /**< Bits per sample */
u32 block_align; /**< Size of a block of data */
};
struct mmal_video_format {
u32 width; /**< Width of frame in pixels */
u32 height; /**< Height of frame in rows of pixels */
struct mmal_rect crop; /**< Visible region of the frame */
struct mmal_rational frame_rate; /**< Frame rate */
struct mmal_rational par; /**< Pixel aspect ratio */
/* FourCC specifying the color space of the video stream. See the
* \ref MmalColorSpace "pre-defined color spaces" for some examples.
*/
u32 color_space;
};
struct mmal_subpicture_format {
u32 x_offset;
u32 y_offset;
};
union mmal_es_specific_format {
struct mmal_audio_format audio;
struct mmal_video_format video;
struct mmal_subpicture_format subpicture;
};
/** Definition of an elementary stream format (MMAL_ES_FORMAT_T) */
struct mmal_es_format {
u32 type; /* enum mmal_es_type */
u32 encoding; /* FourCC specifying encoding of the elementary stream.*/
u32 encoding_variant; /* FourCC specifying the specific
* encoding variant of the elementary
* stream.
*/
union mmal_es_specific_format *es; /* TODO: pointers in
* message serialisation?!?
*/
/* Type specific
* information for the
* elementary stream
*/
u32 bitrate; /**< Bitrate in bits per second */
u32 flags; /**< Flags describing properties of the elementary stream. */
u32 extradata_size; /**< Size of the codec specific data */
u8 *extradata; /**< Codec specific data */
};
#endif /* MMAL_MSG_FORMAT_H */
/*
* 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_PORT_TYPE_T */
enum mmal_port_type {
MMAL_PORT_TYPE_UNKNOWN = 0, /**< Unknown port type */
MMAL_PORT_TYPE_CONTROL, /**< Control port */
MMAL_PORT_TYPE_INPUT, /**< Input port */
MMAL_PORT_TYPE_OUTPUT, /**< Output port */
MMAL_PORT_TYPE_CLOCK, /**< Clock port */
};
/** The port is pass-through and doesn't need buffer headers allocated */
#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01
/** The port wants to allocate the buffer payloads.
* This signals a preference that payload allocation should be done
* on this port for efficiency reasons. */
#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02
/** The port supports format change events.
* This applies to input ports and is used to let the client know
* whether the port supports being reconfigured via a format
* change event (i.e. without having to disable the port). */
#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04
/* mmal port structure (MMAL_PORT_T)
*
* most elements are informational only, the pointer values for
* interogation messages are generally provided as additional
* strucures within the message. When used to set values only teh
* buffer_num, buffer_size and userdata parameters are writable.
*/
struct mmal_port {
void *priv; /* Private member used by the framework */
const char *name; /* Port name. Used for debugging purposes (RO) */
u32 type; /* Type of the port (RO) enum mmal_port_type */
u16 index; /* Index of the port in its type list (RO) */
u16 index_all; /* Index of the port in the list of all ports (RO) */
u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */
struct mmal_es_format *format; /* Format of the elementary stream */
u32 buffer_num_min; /* Minimum number of buffers the port
* requires (RO). This is set by the
* component.
*/
u32 buffer_size_min; /* Minimum size of buffers the port
* requires (RO). This is set by the
* component.
*/
u32 buffer_alignment_min; /* Minimum alignment requirement for
* the buffers (RO). A value of
* zero means no special alignment
* requirements. This is set by the
* component.
*/
u32 buffer_num_recommended; /* Number of buffers the port
* recommends for optimal
* performance (RO). A value of
* zero means no special
* recommendation. This is set
* by the component.
*/
u32 buffer_size_recommended; /* Size of buffers the port
* recommends for optimal
* performance (RO). A value of
* zero means no special
* recommendation. This is set
* by the component.
*/
u32 buffer_num; /* Actual number of buffers the port will use.
* This is set by the client.
*/
u32 buffer_size; /* Actual maximum size of the buffers that
* will be sent to the port. This is set by
* the client.
*/
void *component; /* Component this port belongs to (Read Only) */
void *userdata; /* Field reserved for use by the client */
u32 capabilities; /* Flags describing the capabilities of a
* port (RO). Bitwise combination of \ref
* portcapabilities "Port capabilities"
* values.
*/
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* 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 format;
/* elementry 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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment