linux/drivers/media/test-drivers/vim2m.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * A virtual v4l2-mem2mem example device.
 *
 * This is a virtual device driver for testing mem-to-mem vb2 framework.
 * It simulates a device that uses memory buffers for both source and
 * destination, processes the data and issues an "irq" (simulated by a delayed
 * workqueue).
 * The device is capable of multi-instance, multi-buffer-per-transaction
 * operation (via the mem2mem framework).
 *
 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
 * Pawel Osciak, <[email protected]>
 * Marek Szyprowski, <[email protected]>
 */
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/slab.h>

#include <linux/platform_device.h>
#include <media/v4l2-mem2mem.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <media/videobuf2-vmalloc.h>

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_VERSION();
MODULE_ALIAS();

static unsigned int debug;
module_param(debug, uint, 0644);
MODULE_PARM_DESC();

/* Default transaction time in msec */
static unsigned int default_transtime =; /* Max 25 fps */
module_param(default_transtime, uint, 0644);
MODULE_PARM_DESC();

#define MIN_W
#define MIN_H
#define MAX_W
#define MAX_H

/* Pixel alignment for non-bayer formats */
#define WIDTH_ALIGN
#define HEIGHT_ALIGN

/* Pixel alignment for bayer formats */
#define BAYER_WIDTH_ALIGN
#define BAYER_HEIGHT_ALIGN

/* Flags that indicate a format can be used for capture/output */
#define MEM2MEM_CAPTURE
#define MEM2MEM_OUTPUT

#define MEM2MEM_NAME

/* Per queue */
#define MEM2MEM_DEF_NUM_BUFS
/* In bytes, per queue */
#define MEM2MEM_VID_MEM_LIMIT

/* Flags that indicate processing mode */
#define MEM2MEM_HFLIP
#define MEM2MEM_VFLIP

#define dprintk(dev, lvl, fmt, arg...)

static void vim2m_dev_release(struct device *dev)
{}

static struct platform_device vim2m_pdev =;

struct vim2m_fmt {};

static struct vim2m_fmt formats[] =;

#define NUM_FORMATS

/* Per-queue, driver-specific private data */
struct vim2m_q_data {};

enum {};

#define V4L2_CID_TRANS_TIME_MSEC
#define V4L2_CID_TRANS_NUM_BUFS

static struct vim2m_fmt *find_format(u32 fourcc)
{}

static void get_alignment(u32 fourcc,
			  unsigned int *walign, unsigned int *halign)
{}

struct vim2m_dev {};

struct vim2m_ctx {};

static inline struct vim2m_ctx *file2ctx(struct file *file)
{}

static struct vim2m_q_data *get_q_data(struct vim2m_ctx *ctx,
				       enum v4l2_buf_type type)
{}

static const char *type_name(enum v4l2_buf_type type)
{}

#define CLIP(__color)

static void copy_line(struct vim2m_q_data *q_data_out,
		      u8 *src, u8 *dst, bool reverse)
{}

static void copy_two_pixels(struct vim2m_q_data *q_data_in,
			    struct vim2m_q_data *q_data_out,
			    u8 *src[2], u8 **dst, int ypos, bool reverse)
{}

static int device_process(struct vim2m_ctx *ctx,
			  struct vb2_v4l2_buffer *in_vb,
			  struct vb2_v4l2_buffer *out_vb)
{}

/*
 * mem2mem callbacks
 */

/*
 * job_ready() - check whether an instance is ready to be scheduled to run
 */
static int job_ready(void *priv)
{}

static void job_abort(void *priv)
{}

/* device_run() - prepares and starts the device
 *
 * This simulates all the immediate preparations required before starting
 * a device. This will be called by the framework when it decides to schedule
 * a particular instance.
 */
static void device_run(void *priv)
{}

static void device_work(struct work_struct *w)
{}

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

static int enum_fmt(struct v4l2_fmtdesc *f, u32 type)
{}

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

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

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

static int vidioc_g_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f)
{}

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

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

static int vidioc_try_fmt(struct v4l2_format *f, struct vim2m_fmt *fmt)
{}

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

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

static int vidioc_s_fmt(struct vim2m_ctx *ctx, struct v4l2_format *f)
{}

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

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

static int vim2m_s_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops vim2m_ctrl_ops =;

static const struct v4l2_ioctl_ops vim2m_ioctl_ops =;

/*
 * Queue operations
 */

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

static int vim2m_buf_out_validate(struct vb2_buffer *vb)
{}

static int vim2m_buf_prepare(struct vb2_buffer *vb)
{}

static void vim2m_buf_queue(struct vb2_buffer *vb)
{}

static int vim2m_start_streaming(struct vb2_queue *q, unsigned int count)
{}

static void vim2m_stop_streaming(struct vb2_queue *q)
{}

static void vim2m_buf_request_complete(struct vb2_buffer *vb)
{}

static const struct vb2_ops vim2m_qops =;

static int queue_init(void *priv, struct vb2_queue *src_vq,
		      struct vb2_queue *dst_vq)
{}

static struct v4l2_ctrl_config vim2m_ctrl_trans_time_msec =;

static const struct v4l2_ctrl_config vim2m_ctrl_trans_num_bufs =;

/*
 * File operations
 */
static int vim2m_open(struct file *file)
{}

static int vim2m_release(struct file *file)
{}

static void vim2m_device_release(struct video_device *vdev)
{}

static const struct v4l2_file_operations vim2m_fops =;

static const struct video_device vim2m_videodev =;

static const struct v4l2_m2m_ops m2m_ops =;

static const struct media_device_ops m2m_media_ops =;

static int vim2m_probe(struct platform_device *pdev)
{}

static void vim2m_remove(struct platform_device *pdev)
{}

static struct platform_driver vim2m_pdrv =;

static void __exit vim2m_exit(void)
{}

static int __init vim2m_init(void)
{}

module_init();
module_exit(vim2m_exit);