bcm2835: add v4l2 camera device

- 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

Signed-off-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Luke Diamand <luked@broadcom.com>

V4L2: Fixes from 6by9

V4L2: Fix EV values. Add manual shutter speed control

V4L2 EV values should be in units of 1/1000. Corrected.
Add support for V4L2_CID_EXPOSURE_ABSOLUTE which should
give manual shutter control. Requires manual exposure mode
to be selected first.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Correct JPEG Q-factor range

Should be 1-100, not 0-100

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Fix issue of driver jamming if STREAMON failed.

Fix issue where the driver was left in a partially enabled
state if STREAMON failed, and would then reject many IOCTLs
as it thought it was streaming.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Fix ISO controls.

Driver was passing the index to the GPU, and not the desired
ISO value.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add flicker avoidance controls

Add support for V4L2_CID_POWER_LINE_FREQUENCY to set flicker
avoidance frequencies.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add support for frame rate control.

Add support for frame rate (or time per frame as V4L2
inverts it) control via s_parm.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Improve G_FBUF handling so we pass conformance

Return some sane numbers for get framebuffer so that
we pass conformance.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Fix information advertised through g_vidfmt

Width and height were being stored based on incorrect
values.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add support for inline H264 headers

Add support for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER
to control H264 inline headers.
Requires firmware fix to work correctly, otherwise format
has to be set to H264 before this parameter is set.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Fix JPEG timestamp issue

JPEG images were coming through from the GPU with timestamp
of 0. Detect this and give current system time instead
of some invalid value.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Fix issue when switching down JPEG resolution.

JPEG buffer size calculation is based on input resolution.
Input resolution was being configured after output port
format. Caused failures if switching from one JPEG resolution
to a smaller one.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Enable MJPEG encoding

Requires GPU firmware update to support MJPEG encoder.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Correct flag settings for compressed formats

Set flags field correctly on enum_fmt_vid_cap for compressed
image formats.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: H264 profile & level ctrls, FPS control and auto exp pri

Several control handling updates.
H264 profile and level controls.
Timeperframe/FPS reworked to add V4L2_CID_EXPOSURE_AUTO_PRIORITY to
select whether AE is allowed to override the framerate specified.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Correct BGR24 to RGB24 in format table

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add additional pixel formats. Correct colourspace

Adds the other flavours of YUYV, and NV12.
Corrects the overlay advertised colourspace.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Drop logging msg from info to debug

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Initial pass at scene modes.

Only supports exposure mode and metering modes.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add manual white balance control.

Adds support for V4L2_CID_RED_BALANCE and
V4L2_CID_BLUE_BALANCE. Only has an effect if
V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE has
V4L2_WHITE_BALANCE_MANUAL selected.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

config: Enable V4L / MMAL driver

V4L2: Increase the MMAL timeout to 3sec

MJPEG codec flush is now taking longer and results
in a kernel panic if the driver has stopped waiting for
the result when it finally completes.
Increase the timeout value from 1 to 3secs.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add support for setting H264_I_PERIOD

Adds support for the parameter V4L2_CID_MPEG_VIDEO_H264_I_PERIOD
to set the frequency with which I frames are produced.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Enable GPU function for removing padding from images.

GPU can now support arbitrary strides, although may require
additional processing to achieve it. Enable this feature
so that the images delivered are the size requested.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add support for V4L2_PIX_FMT_BGR32

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Set the colourspace to avoid odd YUV-RGB conversions

Removes the amiguity from the conversion routines and stops
them dropping back to the SD vs HD choice of coeffs.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Make video/still threshold a run-time param

Move the define for at what resolution the driver
switches from a video mode capture to a stills mode
capture to module parameters.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Fix incorrect pool sizing

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add option to disable enum_framesizes.

Gstreamer's handling of a driver that advertises
V4L2_FRMSIZE_TYPE_STEPWISE to define the supported
resolutions is broken. See bug
https://bugzilla.gnome.org/show_bug.cgi?id=726521

Optional parameter of gst_v4l2src_is_broken added.
If non-zero, the driver claims not to support that
ioctl, and gstreamer should be happy again (it
guesses a set of defaults for itself).

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Add support for more image formats

Adds YVU420 (YV12), YVU420SP (NV21), and BGR888.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

V4L2: Extend range for V4L2_CID_MPEG_VIDEO_H264_I_PERIOD

Request to extend the range from the fairly arbitrary
1000 frames (33 seconds at 30fps). Extend out to the
max range supported (int32 value).
Also allow 0, which is handled by the codec as only
send an I-frame on the first frame and never again.
There may be an exception if it detects a significant
scene change, but there's no easy way around that.

Signed-off-by: Dave Stevenson <dsteve@broadcom.com>

bcm2835-camera: stop_streaming now has a void return

BCM2835-V4L2: Fix compliance test failures

VIDIOC_TRY_FMT and VIDIOC_S_FMT tests were faling due
to reporting V4L2_COLORSPACE_JPEG when the colour
format wasn't V4L2_PIX_FMT_JPEG.
Now reports V4L2_COLORSPACE_SMPTE170M for YUV formats.

bcm2835 camera planar/packed stride length

Added a field to the mmal_fmt struct used to compute the bytes per line
when using a particular format. This results in the correct stride being
calculated even when the format is planar.

Signed-off-by: Garrett Wilson <g@floft.net>

bcm2835: camera: check for scene not being found

static analysis by cppcheck detected some potential NULL pointer
dereference issues:

[drivers/media/platform/bcm2835/controls.c:854]: (error) Possible null
  pointer dereference: scene
  (and lines 858, 859 too)

it is possible that scene is not found because of an invalue ctrl->val
and is therefore NULL and hence causing a null pointer dereference.

Signed-off-by: Colin Ian King <colin.king@canonical.com>

bcm2835: memcpy port data to m rather than rmsg

static analysis by cppcheck detected a memcpy to rmsg which is
not actually initialized at that point.  The memcpy should be copying
to variable m instead.

Signed-off-by: Colin Ian King <colin.king@canonical.com>

BCM2835-V4L2: Return buffers to videobuf2 on shutdown

https://github.com/raspberrypi/linux/issues/817
Fixes the kernel warning from videobuf2 as buffers
are now returned as they are being flushed on
stop_streaming.

squash: Fixup bcm2835-camera for changes in kernel 4.4 api
This commit is contained in:
Vincent Sanders
2013-01-30 12:45:18 +00:00
committed by popcornmix
parent 38d73b7fc1
commit f7f28b9800
17 changed files with 6960 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
BCM2835 (aka Raspberry Pi) V4L2 driver
======================================
1. Copyright
============
Copyright © 2013 Raspberry Pi (Trading) Ltd.
2. License
==========
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3. Quick Start
==============
You need a version 1.0 or later of v4l2-ctl, available from:
git://git.linuxtv.org/v4l-utils.git
$ sudo modprobe bcm2835-v4l2
Turn on the overlay:
$ v4l2-ctl --overlay=1
Turn off the overlay:
$ v4l2-ctl --overlay=0
Set the capture format for video:
$ v4l2-ctl --set-fmt-video=width=1920,height=1088,pixelformat=4
(Note: 1088 not 1080).
Capture:
$ v4l2-ctl --stream-mmap=3 --stream-count=100 --stream-to=somefile.h264
Stills capture:
$ v4l2-ctl --set-fmt-video=width=2592,height=1944,pixelformat=3
$ v4l2-ctl --stream-mmap=3 --stream-count=1 --stream-to=somefile.jpg
List of available formats:
$ v4l2-ctl --list-formats

View File

@@ -11,6 +11,8 @@ menuconfig V4L_PLATFORM_DRIVERS
if V4L_PLATFORM_DRIVERS if V4L_PLATFORM_DRIVERS
source "drivers/media/platform/bcm2835/Kconfig"
source "drivers/media/platform/marvell-ccic/Kconfig" source "drivers/media/platform/marvell-ccic/Kconfig"
config VIDEO_VIA_CAMERA config VIDEO_VIA_CAMERA

View File

@@ -2,6 +2,8 @@
# Makefile for the video capture/playback device drivers. # Makefile for the video capture/playback device drivers.
# #
obj-$(CONFIG_VIDEO_BCM2835) += bcm2835/
obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o
obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o

View File

@@ -0,0 +1,25 @@
# Broadcom VideoCore IV v4l2 camera support
config VIDEO_BCM2835
bool "Broadcom BCM2835 camera interface driver"
depends on VIDEO_V4L2 && (ARCH_BCM2708 || ARCH_BCM2709 || ARCH_BCM2835)
---help---
Say Y here to enable camera host interface devices for
Broadcom BCM2835 SoC. This operates over the VCHIQ interface
to a service running on VideoCore.
if VIDEO_BCM2835
config VIDEO_BCM2835_MMAL
tristate "Broadcom BM2835 MMAL camera interface driver"
depends on BCM2708_VCHIQ
select VIDEOBUF2_VMALLOC
---help---
This is a V4L2 driver for the Broadcom BCM2835 MMAL camera host interface
To compile this driver as a module, choose M here: the
module will be called bcm2835-v4l2.o
endif # VIDEO_BM2835

View File

@@ -0,0 +1,5 @@
bcm2835-v4l2-objs := bcm2835-camera.o controls.o mmal-vchiq.o
obj-$(CONFIG_VIDEO_BCM2835_MMAL) += bcm2835-v4l2.o
ccflags-$(CONFIG_VIDEO_BCM2835) += -Idrivers/misc/vc04_services -Idrivers/misc/vc04_services/interface/vcos/linuxkernel -D__VCCOREVER__=0x04000000

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,126 @@
/*
* 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 28 /* 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;
/* 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;
};
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); \
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
/*
* 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;
};

View File

@@ -0,0 +1,127 @@
/*
* 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 */

View File

@@ -0,0 +1,50 @@
/*
* 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 */

View File

@@ -0,0 +1,81 @@
/*
* 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 */

View File

@@ -0,0 +1,107 @@
/*
* 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.
*/
};

View File

@@ -0,0 +1,404 @@
/*
* 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>
*/
/* all the data structures which serialise the MMAL protocol. note
* these are directly mapped onto the recived message data.
*
* BEWARE: They seem to *assume* pointers are u32 and that there is no
* structure padding!
*
* NOTE: this implementation uses kernel types to ensure sizes. Rather
* than assigning values to enums to force their size the
* implementation uses fixed size types and not the enums (though the
* comments have the actual enum type
*/
#define VC_MMAL_VER 15
#define VC_MMAL_MIN_VER 10
#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal")
/* max total message size is 512 bytes */
#define MMAL_MSG_MAX_SIZE 512
/* with six 32bit header elements max payload is therefore 488 bytes */
#define MMAL_MSG_MAX_PAYLOAD 488
#include "mmal-msg-common.h"
#include "mmal-msg-format.h"
#include "mmal-msg-port.h"
enum mmal_msg_type {
MMAL_MSG_TYPE_QUIT = 1,
MMAL_MSG_TYPE_SERVICE_CLOSED,
MMAL_MSG_TYPE_GET_VERSION,
MMAL_MSG_TYPE_COMPONENT_CREATE,
MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */
MMAL_MSG_TYPE_COMPONENT_ENABLE,
MMAL_MSG_TYPE_COMPONENT_DISABLE,
MMAL_MSG_TYPE_PORT_INFO_GET,
MMAL_MSG_TYPE_PORT_INFO_SET,
MMAL_MSG_TYPE_PORT_ACTION, /* 10 */
MMAL_MSG_TYPE_BUFFER_FROM_HOST,
MMAL_MSG_TYPE_BUFFER_TO_HOST,
MMAL_MSG_TYPE_GET_STATS,
MMAL_MSG_TYPE_PORT_PARAMETER_SET,
MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */
MMAL_MSG_TYPE_EVENT_TO_HOST,
MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
MMAL_MSG_TYPE_CONSUME_MEM,
MMAL_MSG_TYPE_LMK, /* 20 */
MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
MMAL_MSG_TYPE_DRM_GET_LHS32,
MMAL_MSG_TYPE_DRM_GET_TIME,
MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */
MMAL_MSG_TYPE_HOST_LOG,
MMAL_MSG_TYPE_MSG_LAST
};
/* port action request messages differ depending on the action type */
enum mmal_msg_port_action_type {
MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unkown action */
MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */
MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */
MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */
MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */
MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */
MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/
};
struct mmal_msg_header {
u32 magic;
u32 type; /** enum mmal_msg_type */
/* Opaque handle to the control service */
struct mmal_control_service *control_service;
struct mmal_msg_context *context; /** a u32 per message context */
u32 status; /** The status of the vchiq operation */
u32 padding;
};
/* Send from VC to host to report version */
struct mmal_msg_version {
u32 flags;
u32 major;
u32 minor;
u32 minimum;
};
/* request to VC to create component */
struct mmal_msg_component_create {
void *client_component; /* component context */
char name[128];
u32 pid; /* For debug */
};
/* reply from VC to component creation request */
struct mmal_msg_component_create_reply {
u32 status; /** enum mmal_msg_status - how does this differ to
* the one in the header?
*/
u32 component_handle; /* VideoCore handle for component */
u32 input_num; /* Number of input ports */
u32 output_num; /* Number of output ports */
u32 clock_num; /* Number of clock ports */
};
/* request to VC to destroy a component */
struct mmal_msg_component_destroy {
u32 component_handle;
};
struct mmal_msg_component_destroy_reply {
u32 status; /** The component destruction status */
};
/* request and reply to VC to enable a component */
struct mmal_msg_component_enable {
u32 component_handle;
};
struct mmal_msg_component_enable_reply {
u32 status; /** The component enable status */
};
/* request and reply to VC to disable a component */
struct mmal_msg_component_disable {
u32 component_handle;
};
struct mmal_msg_component_disable_reply {
u32 status; /** The component disable status */
};
/* request to VC to get port information */
struct mmal_msg_port_info_get {
u32 component_handle; /* component handle port is associated with */
u32 port_type; /* enum mmal_msg_port_type */
u32 index; /* port index to query */
};
/* reply from VC to get port info request */
struct mmal_msg_port_info_get_reply {
u32 status; /** enum mmal_msg_status */
u32 component_handle; /* component handle port is associated with */
u32 port_type; /* enum mmal_msg_port_type */
u32 port_index; /* port indexed in query */
s32 found; /* unused */
u32 port_handle; /**< Handle to use for this port */
struct mmal_port port;
struct mmal_es_format format; /* elementry stream format */
union mmal_es_specific_format es; /* es type specific data */
u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */
};
/* request to VC to set port information */
struct mmal_msg_port_info_set {
u32 component_handle;
u32 port_type; /* enum mmal_msg_port_type */
u32 port_index; /* port indexed in query */
struct mmal_port port;
struct mmal_es_format format;
union mmal_es_specific_format es;
u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
};
/* reply from VC to port info set request */
struct mmal_msg_port_info_set_reply {
u32 status;
u32 component_handle; /* component handle port is associated with */
u32 port_type; /* enum mmal_msg_port_type */
u32 index; /* port indexed in query */
s32 found; /* unused */
u32 port_handle; /**< Handle to use for this port */
struct mmal_port port;
struct mmal_es_format format;
union mmal_es_specific_format es;
u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
};
/* port action requests that take a mmal_port as a parameter */
struct mmal_msg_port_action_port {
u32 component_handle;
u32 port_handle;
u32 action; /* enum mmal_msg_port_action_type */
struct mmal_port port;
};
/* port action requests that take handles as a parameter */
struct mmal_msg_port_action_handle {
u32 component_handle;
u32 port_handle;
u32 action; /* enum mmal_msg_port_action_type */
u32 connect_component_handle;
u32 connect_port_handle;
};
struct mmal_msg_port_action_reply {
u32 status; /** The port action operation status */
};
/* MMAL buffer transfer */
/** Size of space reserved in a buffer message for short messages. */
#define MMAL_VC_SHORT_DATA 128
/** Signals that the current payload is the end of the stream of data */
#define MMAL_BUFFER_HEADER_FLAG_EOS (1<<0)
/** Signals that the start of the current payload starts a frame */
#define MMAL_BUFFER_HEADER_FLAG_FRAME_START (1<<1)
/** Signals that the end of the current payload ends a frame */
#define MMAL_BUFFER_HEADER_FLAG_FRAME_END (1<<2)
/** Signals that the current payload contains only complete frames (>1) */
#define MMAL_BUFFER_HEADER_FLAG_FRAME \
(MMAL_BUFFER_HEADER_FLAG_FRAME_START|MMAL_BUFFER_HEADER_FLAG_FRAME_END)
/** Signals that the current payload is a keyframe (i.e. self decodable) */
#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME (1<<3)
/** Signals a discontinuity in the stream of data (e.g. after a seek).
* Can be used for instance by a decoder to reset its state */
#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY (1<<4)
/** Signals a buffer containing some kind of config data for the component
* (e.g. codec config data) */
#define MMAL_BUFFER_HEADER_FLAG_CONFIG (1<<5)
/** Signals an encrypted payload */
#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED (1<<6)
/** Signals a buffer containing side information */
#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO (1<<7)
/** Signals a buffer which is the snapshot/postview image from a stills
* capture
*/
#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT (1<<8)
/** Signals a buffer which contains data known to be corrupted */
#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED (1<<9)
/** Signals that a buffer failed to be transmitted */
#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED (1<<10)
struct mmal_driver_buffer {
u32 magic;
u32 component_handle;
u32 port_handle;
void *client_context;
};
/* buffer header */
struct mmal_buffer_header {
struct mmal_buffer_header *next; /* next header */
void *priv; /* framework private data */
u32 cmd;
void *data;
u32 alloc_size;
u32 length;
u32 offset;
u32 flags;
s64 pts;
s64 dts;
void *type;
void *user_data;
};
struct mmal_buffer_header_type_specific {
union {
struct {
u32 planes;
u32 offset[4];
u32 pitch[4];
u32 flags;
} video;
} u;
};
struct mmal_msg_buffer_from_host {
/* The front 32 bytes of the buffer header are copied
* back to us in the reply to allow for context. This
* area is used to store two mmal_driver_buffer structures to
* allow for multiple concurrent service users.
*/
/* control data */
struct mmal_driver_buffer drvbuf;
/* referenced control data for passthrough buffer management */
struct mmal_driver_buffer drvbuf_ref;
struct mmal_buffer_header buffer_header; /* buffer header itself */
struct mmal_buffer_header_type_specific buffer_header_type_specific;
s32 is_zero_copy;
s32 has_reference;
/** allows short data to be xfered in control message */
u32 payload_in_message;
u8 short_data[MMAL_VC_SHORT_DATA];
};
/* port parameter setting */
#define MMAL_WORKER_PORT_PARAMETER_SPACE 96
struct mmal_msg_port_parameter_set {
u32 component_handle; /* component */
u32 port_handle; /* port */
u32 id; /* Parameter ID */
u32 size; /* Parameter size */
uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
};
struct mmal_msg_port_parameter_set_reply {
u32 status; /** enum mmal_msg_status todo: how does this
* differ to the one in the header?
*/
};
/* port parameter getting */
struct mmal_msg_port_parameter_get {
u32 component_handle; /* component */
u32 port_handle; /* port */
u32 id; /* Parameter ID */
u32 size; /* Parameter size */
};
struct mmal_msg_port_parameter_get_reply {
u32 status; /* Status of mmal_port_parameter_get call */
u32 id; /* Parameter ID */
u32 size; /* Parameter size */
uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE];
};
/* event messages */
#define MMAL_WORKER_EVENT_SPACE 256
struct mmal_msg_event_to_host {
void *client_component; /* component context */
u32 port_type;
u32 port_num;
u32 cmd;
u32 length;
u8 data[MMAL_WORKER_EVENT_SPACE];
struct mmal_buffer_header *delayed_buffer;
};
/* all mmal messages are serialised through this structure */
struct mmal_msg {
/* header */
struct mmal_msg_header h;
/* payload */
union {
struct mmal_msg_version version;
struct mmal_msg_component_create component_create;
struct mmal_msg_component_create_reply component_create_reply;
struct mmal_msg_component_destroy component_destroy;
struct mmal_msg_component_destroy_reply component_destroy_reply;
struct mmal_msg_component_enable component_enable;
struct mmal_msg_component_enable_reply component_enable_reply;
struct mmal_msg_component_disable component_disable;
struct mmal_msg_component_disable_reply component_disable_reply;
struct mmal_msg_port_info_get port_info_get;
struct mmal_msg_port_info_get_reply port_info_get_reply;
struct mmal_msg_port_info_set port_info_set;
struct mmal_msg_port_info_set_reply port_info_set_reply;
struct mmal_msg_port_action_port port_action_port;
struct mmal_msg_port_action_handle port_action_handle;
struct mmal_msg_port_action_reply port_action_reply;
struct mmal_msg_buffer_from_host buffer_from_host;
struct mmal_msg_port_parameter_set port_parameter_set;
struct mmal_msg_port_parameter_set_reply
port_parameter_set_reply;
struct mmal_msg_port_parameter_get
port_parameter_get;
struct mmal_msg_port_parameter_get_reply
port_parameter_get_reply;
struct mmal_msg_event_to_host event_to_host;
u8 payload[MMAL_MSG_MAX_PAYLOAD];
} u;
};

View File

@@ -0,0 +1,656 @@
/*
* 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>
*/
/* common parameters */
/** @name Parameter groups
* Parameters are divided into groups, and then allocated sequentially within
* a group using an enum.
* @{
*/
/** Common parameter ID group, used with many types of component. */
#define MMAL_PARAMETER_GROUP_COMMON (0<<16)
/** Camera-specific parameter ID group. */
#define MMAL_PARAMETER_GROUP_CAMERA (1<<16)
/** Video-specific parameter ID group. */
#define MMAL_PARAMETER_GROUP_VIDEO (2<<16)
/** Audio-specific parameter ID group. */
#define MMAL_PARAMETER_GROUP_AUDIO (3<<16)
/** Clock-specific parameter ID group. */
#define MMAL_PARAMETER_GROUP_CLOCK (4<<16)
/** Miracast-specific parameter ID group. */
#define MMAL_PARAMETER_GROUP_MIRACAST (5<<16)
/* Common parameters */
enum mmal_parameter_common_type {
MMAL_PARAMETER_UNUSED /**< Never a valid parameter ID */
= MMAL_PARAMETER_GROUP_COMMON,
MMAL_PARAMETER_SUPPORTED_ENCODINGS, /**< MMAL_PARAMETER_ENCODING_T */
MMAL_PARAMETER_URI, /**< MMAL_PARAMETER_URI_T */
/** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */
MMAL_PARAMETER_CHANGE_EVENT_REQUEST,
/** MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_ZERO_COPY,
/**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */
MMAL_PARAMETER_BUFFER_REQUIREMENTS,
MMAL_PARAMETER_STATISTICS, /**< MMAL_PARAMETER_STATISTICS_T */
MMAL_PARAMETER_CORE_STATISTICS, /**< MMAL_PARAMETER_CORE_STATISTICS_T */
MMAL_PARAMETER_MEM_USAGE, /**< MMAL_PARAMETER_MEM_USAGE_T */
MMAL_PARAMETER_BUFFER_FLAG_FILTER, /**< MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_SEEK, /**< MMAL_PARAMETER_SEEK_T */
MMAL_PARAMETER_POWERMON_ENABLE, /**< MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_LOGGING, /**< MMAL_PARAMETER_LOGGING_T */
MMAL_PARAMETER_SYSTEM_TIME, /**< MMAL_PARAMETER_UINT64_T */
MMAL_PARAMETER_NO_IMAGE_PADDING /**< MMAL_PARAMETER_BOOLEAN_T */
};
/* camera parameters */
enum mmal_parameter_camera_type {
/* 0 */
/** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */
MMAL_PARAMETER_THUMBNAIL_CONFIGURATION
= MMAL_PARAMETER_GROUP_CAMERA,
MMAL_PARAMETER_CAPTURE_QUALITY, /**< Unused? */
MMAL_PARAMETER_ROTATION, /**< @ref MMAL_PARAMETER_INT32_T */
MMAL_PARAMETER_EXIF_DISABLE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_EXIF, /**< @ref MMAL_PARAMETER_EXIF_T */
MMAL_PARAMETER_AWB_MODE, /**< @ref MMAL_PARAM_AWBMODE_T */
MMAL_PARAMETER_IMAGE_EFFECT, /**< @ref MMAL_PARAMETER_IMAGEFX_T */
MMAL_PARAMETER_COLOUR_EFFECT, /**< @ref MMAL_PARAMETER_COLOURFX_T */
MMAL_PARAMETER_FLICKER_AVOID, /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */
MMAL_PARAMETER_FLASH, /**< @ref MMAL_PARAMETER_FLASH_T */
MMAL_PARAMETER_REDEYE, /**< @ref MMAL_PARAMETER_REDEYE_T */
MMAL_PARAMETER_FOCUS, /**< @ref MMAL_PARAMETER_FOCUS_T */
MMAL_PARAMETER_FOCAL_LENGTHS, /**< Unused? */
MMAL_PARAMETER_EXPOSURE_COMP, /**< @ref MMAL_PARAMETER_INT32_T */
MMAL_PARAMETER_ZOOM, /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */
MMAL_PARAMETER_MIRROR, /**< @ref MMAL_PARAMETER_MIRROR_T */
/* 0x10 */
MMAL_PARAMETER_CAMERA_NUM, /**< @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_CAPTURE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_EXPOSURE_MODE, /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */
MMAL_PARAMETER_EXP_METERING_MODE, /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */
MMAL_PARAMETER_FOCUS_STATUS, /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */
MMAL_PARAMETER_CAMERA_CONFIG, /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */
MMAL_PARAMETER_CAPTURE_STATUS, /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */
MMAL_PARAMETER_FACE_TRACK, /**< @ref MMAL_PARAMETER_FACE_TRACK_T */
MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_JPEG_Q_FACTOR, /**< @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_FRAME_RATE, /**< @ref MMAL_PARAMETER_FRAME_RATE_T */
MMAL_PARAMETER_USE_STC, /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */
MMAL_PARAMETER_CAMERA_INFO, /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */
MMAL_PARAMETER_VIDEO_STABILISATION, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_FACE_TRACK_RESULTS, /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */
MMAL_PARAMETER_ENABLE_RAW_CAPTURE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
/* 0x20 */
MMAL_PARAMETER_DPF_FILE, /**< @ref MMAL_PARAMETER_URI_T */
MMAL_PARAMETER_ENABLE_DPF_FILE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_DPF_FAIL_IS_FATAL, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_CAPTURE_MODE, /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */
MMAL_PARAMETER_FOCUS_REGIONS, /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */
MMAL_PARAMETER_INPUT_CROP, /**< @ref MMAL_PARAMETER_INPUT_CROP_T */
MMAL_PARAMETER_SENSOR_INFORMATION, /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */
MMAL_PARAMETER_FLASH_SELECT, /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */
MMAL_PARAMETER_FIELD_OF_VIEW, /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */
MMAL_PARAMETER_HIGH_DYNAMIC_RANGE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION, /**< @ref MMAL_PARAMETER_DRC_T */
MMAL_PARAMETER_ALGORITHM_CONTROL, /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */
MMAL_PARAMETER_SHARPNESS, /**< @ref MMAL_PARAMETER_RATIONAL_T */
MMAL_PARAMETER_CONTRAST, /**< @ref MMAL_PARAMETER_RATIONAL_T */
MMAL_PARAMETER_BRIGHTNESS, /**< @ref MMAL_PARAMETER_RATIONAL_T */
MMAL_PARAMETER_SATURATION, /**< @ref MMAL_PARAMETER_RATIONAL_T */
/* 0x30 */
MMAL_PARAMETER_ISO, /**< @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_ANTISHAKE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
/** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */
MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_CAMERA_BURST_CAPTURE,
/** @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_CAMERA_MIN_ISO,
/** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */
MMAL_PARAMETER_CAMERA_USE_CASE,
/**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_CAPTURE_STATS_PASS,
/** @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_ENABLE_REGISTER_FILE,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL,
/** @ref MMAL_PARAMETER_CONFIGFILE_T */
MMAL_PARAMETER_CONFIGFILE_REGISTERS,
/** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */
MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS,
MMAL_PARAMETER_JPEG_ATTACH_LOG, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_ZERO_SHUTTER_LAG, /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */
MMAL_PARAMETER_FPS_RANGE, /**< @ref MMAL_PARAMETER_FPS_RANGE_T */
MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP, /**< @ref MMAL_PARAMETER_INT32_T */
/* 0x40 */
MMAL_PARAMETER_SW_SHARPEN_DISABLE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_FLASH_REQUIRED, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_SW_SATURATION_DISABLE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_SHUTTER_SPEED, /**< Takes a @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_CUSTOM_AWB_GAINS, /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */
};
struct mmal_parameter_rational {
s32 num; /**< Numerator */
s32 den; /**< Denominator */
};
enum mmal_parameter_camera_config_timestamp_mode {
MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */
MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value
* for the frame timestamp
*/
MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp
* but subtract the
* timestamp of the first
* frame sent to give a
* zero based timestamp.
*/
};
struct mmal_parameter_fps_range {
/**< Low end of the permitted framerate range */
struct mmal_parameter_rational fps_low;
/**< High end of the permitted framerate range */
struct mmal_parameter_rational fps_high;
};
/* camera configuration parameter */
struct mmal_parameter_camera_config {
/* Parameters for setting up the image pools */
u32 max_stills_w; /* Max size of stills capture */
u32 max_stills_h;
u32 stills_yuv422; /* Allow YUV422 stills capture */
u32 one_shot_stills; /* Continuous or one shot stills captures. */
u32 max_preview_video_w; /* Max size of the preview or video
* capture frames
*/
u32 max_preview_video_h;
u32 num_preview_video_frames;
/** Sets the height of the circular buffer for stills capture. */
u32 stills_capture_circular_buffer_height;
/** Allows preview/encode to resume as fast as possible after the stills
* input frame has been received, and then processes the still frame in
* the background whilst preview/encode has resumed.
* Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE.
*/
u32 fast_preview_resume;
/** Selects algorithm for timestamping frames if
* there is no clock component connected.
* enum mmal_parameter_camera_config_timestamp_mode
*/
s32 use_stc_timestamp;
};
enum mmal_parameter_exposuremode {
MMAL_PARAM_EXPOSUREMODE_OFF,
MMAL_PARAM_EXPOSUREMODE_AUTO,
MMAL_PARAM_EXPOSUREMODE_NIGHT,
MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW,
MMAL_PARAM_EXPOSUREMODE_BACKLIGHT,
MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT,
MMAL_PARAM_EXPOSUREMODE_SPORTS,
MMAL_PARAM_EXPOSUREMODE_SNOW,
MMAL_PARAM_EXPOSUREMODE_BEACH,
MMAL_PARAM_EXPOSUREMODE_VERYLONG,
MMAL_PARAM_EXPOSUREMODE_FIXEDFPS,
MMAL_PARAM_EXPOSUREMODE_ANTISHAKE,
MMAL_PARAM_EXPOSUREMODE_FIREWORKS,
};
enum mmal_parameter_exposuremeteringmode {
MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE,
MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT,
MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT,
MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX,
};
enum mmal_parameter_awbmode {
MMAL_PARAM_AWBMODE_OFF,
MMAL_PARAM_AWBMODE_AUTO,
MMAL_PARAM_AWBMODE_SUNLIGHT,
MMAL_PARAM_AWBMODE_CLOUDY,
MMAL_PARAM_AWBMODE_SHADE,
MMAL_PARAM_AWBMODE_TUNGSTEN,
MMAL_PARAM_AWBMODE_FLUORESCENT,
MMAL_PARAM_AWBMODE_INCANDESCENT,
MMAL_PARAM_AWBMODE_FLASH,
MMAL_PARAM_AWBMODE_HORIZON,
};
enum mmal_parameter_imagefx {
MMAL_PARAM_IMAGEFX_NONE,
MMAL_PARAM_IMAGEFX_NEGATIVE,
MMAL_PARAM_IMAGEFX_SOLARIZE,
MMAL_PARAM_IMAGEFX_POSTERIZE,
MMAL_PARAM_IMAGEFX_WHITEBOARD,
MMAL_PARAM_IMAGEFX_BLACKBOARD,
MMAL_PARAM_IMAGEFX_SKETCH,
MMAL_PARAM_IMAGEFX_DENOISE,
MMAL_PARAM_IMAGEFX_EMBOSS,
MMAL_PARAM_IMAGEFX_OILPAINT,
MMAL_PARAM_IMAGEFX_HATCH,
MMAL_PARAM_IMAGEFX_GPEN,
MMAL_PARAM_IMAGEFX_PASTEL,
MMAL_PARAM_IMAGEFX_WATERCOLOUR,
MMAL_PARAM_IMAGEFX_FILM,
MMAL_PARAM_IMAGEFX_BLUR,
MMAL_PARAM_IMAGEFX_SATURATION,
MMAL_PARAM_IMAGEFX_COLOURSWAP,
MMAL_PARAM_IMAGEFX_WASHEDOUT,
MMAL_PARAM_IMAGEFX_POSTERISE,
MMAL_PARAM_IMAGEFX_COLOURPOINT,
MMAL_PARAM_IMAGEFX_COLOURBALANCE,
MMAL_PARAM_IMAGEFX_CARTOON,
};
enum MMAL_PARAM_FLICKERAVOID_T {
MMAL_PARAM_FLICKERAVOID_OFF,
MMAL_PARAM_FLICKERAVOID_AUTO,
MMAL_PARAM_FLICKERAVOID_50HZ,
MMAL_PARAM_FLICKERAVOID_60HZ,
MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF
};
struct mmal_parameter_awbgains {
struct mmal_parameter_rational r_gain; /**< Red gain */
struct mmal_parameter_rational b_gain; /**< Blue gain */
};
/** Manner of video rate control */
enum mmal_parameter_rate_control_mode {
MMAL_VIDEO_RATECONTROL_DEFAULT,
MMAL_VIDEO_RATECONTROL_VARIABLE,
MMAL_VIDEO_RATECONTROL_CONSTANT,
MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES,
MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES
};
enum mmal_video_profile {
MMAL_VIDEO_PROFILE_H263_BASELINE,
MMAL_VIDEO_PROFILE_H263_H320CODING,
MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE,
MMAL_VIDEO_PROFILE_H263_ISWV2,
MMAL_VIDEO_PROFILE_H263_ISWV3,
MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION,
MMAL_VIDEO_PROFILE_H263_INTERNET,
MMAL_VIDEO_PROFILE_H263_INTERLACE,
MMAL_VIDEO_PROFILE_H263_HIGHLATENCY,
MMAL_VIDEO_PROFILE_MP4V_SIMPLE,
MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE,
MMAL_VIDEO_PROFILE_MP4V_CORE,
MMAL_VIDEO_PROFILE_MP4V_MAIN,
MMAL_VIDEO_PROFILE_MP4V_NBIT,
MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE,
MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE,
MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA,
MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED,
MMAL_VIDEO_PROFILE_MP4V_HYBRID,
MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME,
MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE,
MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING,
MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE,
MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE,
MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE,
MMAL_VIDEO_PROFILE_H264_BASELINE,
MMAL_VIDEO_PROFILE_H264_MAIN,
MMAL_VIDEO_PROFILE_H264_EXTENDED,
MMAL_VIDEO_PROFILE_H264_HIGH,
MMAL_VIDEO_PROFILE_H264_HIGH10,
MMAL_VIDEO_PROFILE_H264_HIGH422,
MMAL_VIDEO_PROFILE_H264_HIGH444,
MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE,
MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF
};
enum mmal_video_level {
MMAL_VIDEO_LEVEL_H263_10,
MMAL_VIDEO_LEVEL_H263_20,
MMAL_VIDEO_LEVEL_H263_30,
MMAL_VIDEO_LEVEL_H263_40,
MMAL_VIDEO_LEVEL_H263_45,
MMAL_VIDEO_LEVEL_H263_50,
MMAL_VIDEO_LEVEL_H263_60,
MMAL_VIDEO_LEVEL_H263_70,
MMAL_VIDEO_LEVEL_MP4V_0,
MMAL_VIDEO_LEVEL_MP4V_0b,
MMAL_VIDEO_LEVEL_MP4V_1,
MMAL_VIDEO_LEVEL_MP4V_2,
MMAL_VIDEO_LEVEL_MP4V_3,
MMAL_VIDEO_LEVEL_MP4V_4,
MMAL_VIDEO_LEVEL_MP4V_4a,
MMAL_VIDEO_LEVEL_MP4V_5,
MMAL_VIDEO_LEVEL_MP4V_6,
MMAL_VIDEO_LEVEL_H264_1,
MMAL_VIDEO_LEVEL_H264_1b,
MMAL_VIDEO_LEVEL_H264_11,
MMAL_VIDEO_LEVEL_H264_12,
MMAL_VIDEO_LEVEL_H264_13,
MMAL_VIDEO_LEVEL_H264_2,
MMAL_VIDEO_LEVEL_H264_21,
MMAL_VIDEO_LEVEL_H264_22,
MMAL_VIDEO_LEVEL_H264_3,
MMAL_VIDEO_LEVEL_H264_31,
MMAL_VIDEO_LEVEL_H264_32,
MMAL_VIDEO_LEVEL_H264_4,
MMAL_VIDEO_LEVEL_H264_41,
MMAL_VIDEO_LEVEL_H264_42,
MMAL_VIDEO_LEVEL_H264_5,
MMAL_VIDEO_LEVEL_H264_51,
MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF
};
struct mmal_parameter_video_profile {
enum mmal_video_profile profile;
enum mmal_video_level level;
};
/* video parameters */
enum mmal_parameter_video_type {
/** @ref MMAL_DISPLAYREGION_T */
MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO,
/** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
MMAL_PARAMETER_SUPPORTED_PROFILES,
/** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */
MMAL_PARAMETER_PROFILE,
/** @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_INTRAPERIOD,
/** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */
MMAL_PARAMETER_RATECONTROL,
/** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */
MMAL_PARAMETER_NALUNITFORMAT,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_MINIMISE_FRAGMENTATION,
/** @ref MMAL_PARAMETER_UINT32_T.
* Setting the value to zero resets to the default (one slice per frame).
*/
MMAL_PARAMETER_MB_ROWS_PER_SLICE,
/** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */
MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION,
/** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */
MMAL_PARAMETER_VIDEO_EEDE_ENABLE,
/** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */
MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE,
/** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */
MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME,
/** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */
MMAL_PARAMETER_VIDEO_INTRA_REFRESH,
/** @ref MMAL_PARAMETER_BOOLEAN_T. */
MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT,
/** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */
MMAL_PARAMETER_VIDEO_BIT_RATE,
/** @ref MMAL_PARAMETER_FRAME_RATE_T */
MMAL_PARAMETER_VIDEO_FRAME_RATE,
/** @ref MMAL_PARAMETER_UINT32_T. */
MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
/** @ref MMAL_PARAMETER_UINT32_T. */
MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
/** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */
MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL,
MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */
/** @ref MMAL_PARAMETER_UINT32_T.
* Changing this parameter from the default can reduce frame rate
* because image buffers need to be re-pitched.
*/
MMAL_PARAMETER_VIDEO_ALIGN_HORIZ,
/** @ref MMAL_PARAMETER_UINT32_T.
* Changing this parameter from the default can reduce frame rate
* because image buffers need to be re-pitched.
*/
MMAL_PARAMETER_VIDEO_ALIGN_VERT,
/** @ref MMAL_PARAMETER_BOOLEAN_T. */
MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES,
/** @ref MMAL_PARAMETER_UINT32_T. */
MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT,
/**< @ref MMAL_PARAMETER_UINT32_T. */
MMAL_PARAMETER_VIDEO_ENCODE_QP_P,
/**< @ref MMAL_PARAMETER_UINT32_T. */
MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT,
/** @ref MMAL_PARAMETER_UINT32_T */
MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS,
/** @ref MMAL_PARAMETER_UINT32_T. */
MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE,
/* H264 specific parameters */
/** @ref MMAL_PARAMETER_BOOLEAN_T. */
MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC,
/** @ref MMAL_PARAMETER_BOOLEAN_T. */
MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY,
/** @ref MMAL_PARAMETER_BOOLEAN_T. */
MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS,
/** @ref MMAL_PARAMETER_UINT32_T. */
MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC,
/** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */
MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP,
/** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */
MMAL_PARAMETER_VIDEO_DRM_INIT_INFO,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO,
/** @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT,
/** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */
MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER,
/** @ref MMAL_PARAMETER_BYTES_T */
MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3,
/**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS,
/**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG,
/**< @ref MMAL_PARAMETER_BOOLEAN_T */
MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER
};
/** Valid mirror modes */
enum mmal_parameter_mirror {
MMAL_PARAM_MIRROR_NONE,
MMAL_PARAM_MIRROR_VERTICAL,
MMAL_PARAM_MIRROR_HORIZONTAL,
MMAL_PARAM_MIRROR_BOTH,
};
enum mmal_parameter_displaytransform {
MMAL_DISPLAY_ROT0 = 0,
MMAL_DISPLAY_MIRROR_ROT0 = 1,
MMAL_DISPLAY_MIRROR_ROT180 = 2,
MMAL_DISPLAY_ROT180 = 3,
MMAL_DISPLAY_MIRROR_ROT90 = 4,
MMAL_DISPLAY_ROT270 = 5,
MMAL_DISPLAY_ROT90 = 6,
MMAL_DISPLAY_MIRROR_ROT270 = 7,
};
enum mmal_parameter_displaymode {
MMAL_DISPLAY_MODE_FILL = 0,
MMAL_DISPLAY_MODE_LETTERBOX = 1,
};
enum mmal_parameter_displayset {
MMAL_DISPLAY_SET_NONE = 0,
MMAL_DISPLAY_SET_NUM = 1,
MMAL_DISPLAY_SET_FULLSCREEN = 2,
MMAL_DISPLAY_SET_TRANSFORM = 4,
MMAL_DISPLAY_SET_DEST_RECT = 8,
MMAL_DISPLAY_SET_SRC_RECT = 0x10,
MMAL_DISPLAY_SET_MODE = 0x20,
MMAL_DISPLAY_SET_PIXEL = 0x40,
MMAL_DISPLAY_SET_NOASPECT = 0x80,
MMAL_DISPLAY_SET_LAYER = 0x100,
MMAL_DISPLAY_SET_COPYPROTECT = 0x200,
MMAL_DISPLAY_SET_ALPHA = 0x400,
};
struct mmal_parameter_displayregion {
/** Bitfield that indicates which fields are set and should be
* used. All other fields will maintain their current value.
* \ref MMAL_DISPLAYSET_T defines the bits that can be
* combined.
*/
u32 set;
/** Describes the display output device, with 0 typically
* being a directly connected LCD display. The actual values
* will depend on the hardware. Code using hard-wired numbers
* (e.g. 2) is certain to fail.
*/
u32 display_num;
/** Indicates that we are using the full device screen area,
* rather than a window of the display. If zero, then
* dest_rect is used to specify a region of the display to
* use.
*/
s32 fullscreen;
/** Indicates any rotation or flipping used to map frames onto
* the natural display orientation.
*/
u32 transform; /* enum mmal_parameter_displaytransform */
/** Where to display the frame within the screen, if
* fullscreen is zero.
*/
struct vchiq_mmal_rect dest_rect;
/** Indicates which area of the frame to display. If all
* values are zero, the whole frame will be used.
*/
struct vchiq_mmal_rect src_rect;
/** If set to non-zero, indicates that any display scaling
* should disregard the aspect ratio of the frame region being
* displayed.
*/
s32 noaspect;
/** Indicates how the image should be scaled to fit the
* display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates
* that the image should fill the screen by potentially
* cropping the frames. Setting \code mode \endcode to \code
* MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the
* source region should be displayed and black bars added if
* necessary.
*/
u32 mode; /* enum mmal_parameter_displaymode */
/** If non-zero, defines the width of a source pixel relative
* to \code pixel_y \endcode. If zero, then pixels default to
* being square.
*/
u32 pixel_x;
/** If non-zero, defines the height of a source pixel relative
* to \code pixel_x \endcode. If zero, then pixels default to
* being square.
*/
u32 pixel_y;
/** Sets the relative depth of the images, with greater values
* being in front of smaller values.
*/
u32 layer;
/** Set to non-zero to ensure copy protection is used on
* output.
*/
s32 copyprotect_required;
/** Level of opacity of the layer, where zero is fully
* transparent and 255 is fully opaque.
*/
u32 alpha;
};
#define MMAL_MAX_IMAGEFX_PARAMETERS 5
struct mmal_parameter_imagefx_parameters {
enum mmal_parameter_imagefx effect;
u32 num_effect_params;
u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS];
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,178 @@
/*
* 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 */