linux/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Broadcom BCM2835 V4L2 driver
 *
 * Copyright © 2013 Raspberry Pi (Trading) Ltd.
 *
 * Authors: Vincent Sanders @ Collabora
 *          Dave Stevenson @ Broadcom
 *		(now [email protected])
 *          Simon Mellor @ Broadcom
 *          Luke Diamand @ Broadcom
 */

#include <linux/dma-mapping.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <media/videobuf2-vmalloc.h>
#include <media/videobuf2-dma-contig.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-event.h>
#include <media/v4l2-common.h>
#include <linux/delay.h>

#include "../interface/vchiq_arm/vchiq_bus.h"
#include "../vchiq-mmal/mmal-common.h"
#include "../vchiq-mmal/mmal-encodings.h"
#include "../vchiq-mmal/mmal-vchiq.h"
#include "../vchiq-mmal/mmal-msg.h"
#include "../vchiq-mmal/mmal-parameters.h"
#include "bcm2835-camera.h"

#define MIN_WIDTH
#define MIN_HEIGHT
#define MIN_BUFFER_SIZE

#define MAX_VIDEO_MODE_WIDTH
#define MAX_VIDEO_MODE_HEIGHT

#define MAX_BCM2835_CAMERAS

int bcm2835_v4l2_debug;
module_param_named(debug, bcm2835_v4l2_debug, int, 0644);
MODULE_PARM_DESC();

#define UNSET
static int video_nr[] =;
module_param_array();
MODULE_PARM_DESC();

static int max_video_width =;
static int max_video_height =;
module_param(max_video_width, int, 0644);
MODULE_PARM_DESC();
module_param(max_video_height, int, 0644);
MODULE_PARM_DESC();

/* camera instance counter */
static atomic_t camera_instance =;

/* global device data array */
static struct bcm2835_mmal_dev *gdev[MAX_BCM2835_CAMERAS];

#define FPS_MIN
#define FPS_MAX

/* timeperframe: min/max and default */
static const struct v4l2_fract
	tpf_min     =,
	tpf_max     =,
	tpf_default =;

/* Container for MMAL and VB2 buffers*/
struct vb2_mmal_buffer {};

/* video formats */
static struct mmal_fmt formats[] =;

static struct mmal_fmt *get_format(struct v4l2_format *f)
{}

/* ------------------------------------------------------------------
 *	Videobuf queue operations
 * ------------------------------------------------------------------
 */

static int queue_setup(struct vb2_queue *vq,
		       unsigned int *nbuffers, unsigned int *nplanes,
		       unsigned int sizes[], struct device *alloc_ctxs[])
{}

static int buffer_init(struct vb2_buffer *vb)
{}

static int buffer_prepare(struct vb2_buffer *vb)
{}

static void buffer_cleanup(struct vb2_buffer *vb)
{}

static inline bool is_capturing(struct bcm2835_mmal_dev *dev)
{}

static void buffer_cb(struct vchiq_mmal_instance *instance,
		      struct vchiq_mmal_port *port,
		      int status,
		      struct mmal_buffer *mmal_buf)
{}

static int enable_camera(struct bcm2835_mmal_dev *dev)
{}

static int disable_camera(struct bcm2835_mmal_dev *dev)
{}

static void buffer_queue(struct vb2_buffer *vb)
{}

static int start_streaming(struct vb2_queue *vq, unsigned int count)
{}

/* abort streaming and wait for last buffer */
static void stop_streaming(struct vb2_queue *vq)
{}

static const struct vb2_ops bcm2835_mmal_video_qops =;

/* ------------------------------------------------------------------
 *	IOCTL operations
 * ------------------------------------------------------------------
 */

static int set_overlay_params(struct bcm2835_mmal_dev *dev,
			      struct vchiq_mmal_port *port)
{}

/* overlay ioctl */
static int vidioc_enum_fmt_vid_overlay(struct file *file, void *priv,
				       struct v4l2_fmtdesc *f)
{}

static int vidioc_g_fmt_vid_overlay(struct file *file, void *priv,
				    struct v4l2_format *f)
{}

static int vidioc_try_fmt_vid_overlay(struct file *file, void *priv,
				      struct v4l2_format *f)
{}

static int vidioc_s_fmt_vid_overlay(struct file *file, void *priv,
				    struct v4l2_format *f)
{}

static int vidioc_overlay(struct file *file, void *f, unsigned int on)
{}

static int vidioc_g_fbuf(struct file *file, void *fh,
			 struct v4l2_framebuffer *a)
{}

/* input ioctls */
static int vidioc_enum_input(struct file *file, void *priv,
			     struct v4l2_input *inp)
{}

static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
{}

static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
{}

/* capture ioctls */
static int vidioc_querycap(struct file *file, void *priv,
			   struct v4l2_capability *cap)
{}

static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
				   struct v4l2_fmtdesc *f)
{}

static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{}

static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
				  struct v4l2_format *f)
{}

static int mmal_setup_video_component(struct bcm2835_mmal_dev *dev,
				      struct v4l2_format *f)
{}

static int mmal_setup_encode_component(struct bcm2835_mmal_dev *dev,
				       struct v4l2_format *f,
				       struct vchiq_mmal_port *port,
				       struct vchiq_mmal_port *camera_port,
				       struct vchiq_mmal_component *component)
{}

static int mmal_setup_components(struct bcm2835_mmal_dev *dev,
				 struct v4l2_format *f)
{}

static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
				struct v4l2_format *f)
{}

static int vidioc_enum_framesizes(struct file *file, void *fh,
				  struct v4l2_frmsizeenum *fsize)
{}

/* timeperframe is arbitrary and continuous */
static int vidioc_enum_frameintervals(struct file *file, void *priv,
				      struct v4l2_frmivalenum *fival)
{}

static int vidioc_g_parm(struct file *file, void *priv,
			 struct v4l2_streamparm *parm)
{}

static int vidioc_s_parm(struct file *file, void *priv,
			 struct v4l2_streamparm *parm)
{}

static const struct v4l2_ioctl_ops camera0_ioctl_ops =;

/* ------------------------------------------------------------------
 *	Driver init/finalise
 * ------------------------------------------------------------------
 */

static const struct v4l2_file_operations camera0_fops =;

static const struct video_device vdev_template =;

/* Returns the number of cameras, and also the max resolution supported
 * by those cameras.
 */
static int get_num_cameras(struct vchiq_mmal_instance *instance,
			   unsigned int resolutions[][2], int num_resolutions)
{}

static int set_camera_parameters(struct vchiq_mmal_instance *instance,
				 struct vchiq_mmal_component *camera,
				 struct bcm2835_mmal_dev *dev)
{}

#define MAX_SUPPORTED_ENCODINGS

/* MMAL instance and component init */
static int mmal_init(struct bcm2835_mmal_dev *dev)
{}

static int bcm2835_mmal_init_device(struct bcm2835_mmal_dev *dev, struct video_device *vfd)
{}

static void bcm2835_cleanup_instance(struct bcm2835_mmal_dev *dev)
{}

static struct v4l2_format default_v4l2_format =;

static int bcm2835_mmal_probe(struct vchiq_device *device)
{}

static void bcm2835_mmal_remove(struct vchiq_device *device)
{}

static const struct vchiq_device_id device_id_table[] =;
MODULE_DEVICE_TABLE(vchiq, device_id_table);

static struct vchiq_driver bcm2835_camera_driver =;

module_vchiq_driver()

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();