linux/drivers/media/usb/em28xx/em28xx-video.c

// SPDX-License-Identifier: GPL-2.0+
//
// em28xx-video.c - driver for Empia EM2800/EM2820/2840 USB
//		    video capture devices
//
// Copyright (C) 2005 Ludovico Cavedon <[email protected]>
//		      Markus Rechberger <[email protected]>
//		      Mauro Carvalho Chehab <[email protected]>
//		      Sascha Sommer <[email protected]>
// Copyright (C) 2012 Frank Schäfer <[email protected]>
//
//	Some parts based on SN9C10x PC Camera Controllers GPL driver made
//		by Luca Risolia <[email protected]>

#include "em28xx.h"

#include <linux/init.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/bitmap.h>
#include <linux/usb.h>
#include <linux/i2c.h>
#include <linux/mm.h>
#include <linux/mutex.h>
#include <linux/slab.h>

#include "em28xx-v4l.h"
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-event.h>
#include <media/drv-intf/msp3400.h>
#include <media/tuner.h>

#define DRIVER_AUTHOR

static unsigned int isoc_debug;
module_param(isoc_debug, int, 0644);
MODULE_PARM_DESC();

static unsigned int disable_vbi;
module_param(disable_vbi, int, 0644);
MODULE_PARM_DESC();

static int alt;
module_param(alt, int, 0644);
MODULE_PARM_DESC();

#define em28xx_videodbg(fmt, arg...)

#define em28xx_isocdbg(fmt, arg...)

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

#define EM25XX_FRMDATAHDR_BYTE1
#define EM25XX_FRMDATAHDR_BYTE2_STILL_IMAGE
#define EM25XX_FRMDATAHDR_BYTE2_FRAME_END
#define EM25XX_FRMDATAHDR_BYTE2_FRAME_ID
#define EM25XX_FRMDATAHDR_BYTE2_MASK

static unsigned int video_nr[] =;
static unsigned int vbi_nr[]   =;
static unsigned int radio_nr[] =;

module_param_array();
module_param_array();
module_param_array();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();

static unsigned int video_debug;
module_param(video_debug, int, 0644);
MODULE_PARM_DESC();

/* supported video standards */
static struct em28xx_fmt format[] =;

/*FIXME: maxw should be dependent of alt mode */
static inline unsigned int norm_maxw(struct em28xx *dev)
{}

static inline unsigned int norm_maxh(struct em28xx *dev)
{}

static int em28xx_vbi_supported(struct em28xx *dev)
{}

/*
 * em28xx_wake_i2c()
 * configure i2c attached devices
 */
static void em28xx_wake_i2c(struct em28xx *dev)
{}

static int em28xx_colorlevels_set_default(struct em28xx *dev)
{}

static int em28xx_set_outfmt(struct em28xx *dev)
{}

static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax,
				  u8 ymin, u8 ymax)
{}

static void em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart,
				    u16 width, u16 height)
{}

static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
{}

/* FIXME: this only function read values from dev */
static int em28xx_resolution_set(struct em28xx *dev)
{}

/* Set USB alternate setting for analog video */
static int em28xx_set_alternate(struct em28xx *dev)
{}

/*
 * DMA and thread functions
 */

/*
 * Finish the current buffer
 */
static inline void finish_buffer(struct em28xx *dev,
				 struct em28xx_buffer *buf)
{}

/*
 * Copy picture data from USB buffer to video buffer
 */
static void em28xx_copy_video(struct em28xx *dev,
			      struct em28xx_buffer *buf,
			      unsigned char *usb_buf,
			      unsigned long len)
{}

/*
 * Copy VBI data from USB buffer to video buffer
 */
static void em28xx_copy_vbi(struct em28xx *dev,
			    struct em28xx_buffer *buf,
			    unsigned char *usb_buf,
			    unsigned long len)
{}

static inline void print_err_status(struct em28xx *dev,
				    int packet, int status)
{}

/*
 * get the next available buffer from dma queue
 */
static inline struct em28xx_buffer *get_next_buf(struct em28xx *dev,
						 struct em28xx_dmaqueue *dma_q)
{}

/*
 * Finish the current buffer if completed and prepare for the next field
 */
static struct em28xx_buffer *
finish_field_prepare_next(struct em28xx *dev,
			  struct em28xx_buffer *buf,
			  struct em28xx_dmaqueue *dma_q)
{}

/*
 * Process data packet according to the em2710/em2750/em28xx frame data format
 */
static inline void process_frame_data_em28xx(struct em28xx *dev,
					     unsigned char *data_pkt,
					     unsigned int  data_len)
{}

/*
 * Process data packet according to the em25xx/em276x/7x/8x frame data format
 */
static inline void process_frame_data_em25xx(struct em28xx *dev,
					     unsigned char *data_pkt,
					     unsigned int  data_len)
{}

/* Processes and copies the URB data content (video and VBI data) */
static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb)
{}

static int get_resource(enum v4l2_buf_type f_type)
{}

/* Usage lock check functions */
static int res_get(struct em28xx *dev, enum v4l2_buf_type f_type)
{}

static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type)
{}

static void em28xx_v4l2_media_release(struct em28xx *dev)
{}

/*
 * Media Controller helper functions
 */

static int em28xx_enable_analog_tuner(struct em28xx *dev)
{}

static const char * const iname[] =;

static void em28xx_v4l2_create_entities(struct em28xx *dev)
{}

/*
 * Videobuf2 operations
 */

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

static int
buffer_prepare(struct vb2_buffer *vb)
{}

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

static void em28xx_stop_streaming(struct vb2_queue *vq)
{}

void em28xx_stop_vbi_streaming(struct vb2_queue *vq)
{}

static void
buffer_queue(struct vb2_buffer *vb)
{}

static const struct vb2_ops em28xx_video_qops =;

static int em28xx_vb2_setup(struct em28xx *dev)
{}

/*
 * v4l2 interface
 */

static void video_mux(struct em28xx *dev, int index)
{}

static void em28xx_ctrl_notify(struct v4l2_ctrl *ctrl, void *priv)
{}

static int em28xx_s_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops em28xx_ctrl_ops =;

static void size_to_scale(struct em28xx *dev,
			  unsigned int width, unsigned int height,
			unsigned int *hscale, unsigned int *vscale)
{}

static void scale_to_size(struct em28xx *dev,
			  unsigned int hscale, unsigned int vscale,
			  unsigned int *width, unsigned int *height)
{}

/*
 * IOCTL vidioc handling
 */

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

static struct em28xx_fmt *format_by_fourcc(unsigned int fourcc)
{}

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

static int em28xx_set_video_format(struct em28xx *dev, unsigned int fourcc,
				   unsigned int width, unsigned int height)
{}

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

static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm)
{}

static int vidioc_querystd(struct file *file, void *priv, v4l2_std_id *norm)
{}

static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id norm)
{}

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

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

static int vidioc_enum_input(struct file *file, void *priv,
			     struct v4l2_input *i)
{}

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)
{}

static int em28xx_fill_audio_input(struct em28xx *dev,
				   const char *s,
				   struct v4l2_audio *a,
				   unsigned int index)
{}

static int vidioc_enumaudio(struct file *file, void *fh, struct v4l2_audio *a)
{}

static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
{}

static int vidioc_s_audio(struct file *file, void *priv,
			  const struct v4l2_audio *a)
{}

static int vidioc_g_tuner(struct file *file, void *priv,
			  struct v4l2_tuner *t)
{}

static int vidioc_s_tuner(struct file *file, void *priv,
			  const struct v4l2_tuner *t)
{}

static int vidioc_g_frequency(struct file *file, void *priv,
			      struct v4l2_frequency *f)
{}

static int vidioc_s_frequency(struct file *file, void *priv,
			      const struct v4l2_frequency *f)
{}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int vidioc_g_chip_info(struct file *file, void *priv,
			      struct v4l2_dbg_chip_info *chip)
{}

static int em28xx_reg_len(int reg)
{}

static int vidioc_g_register(struct file *file, void *priv,
			     struct v4l2_dbg_register *reg)
{}

static int vidioc_s_register(struct file *file, void *priv,
			     const struct v4l2_dbg_register *reg)
{}
#endif

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_enum_framesizes(struct file *file, void *priv,
				  struct v4l2_frmsizeenum *fsize)
{}

/* RAW VBI ioctls */

static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv,
				struct v4l2_format *format)
{}

/*
 * RADIO ESPECIFIC IOCTLS
 */

static int radio_g_tuner(struct file *file, void *priv,
			 struct v4l2_tuner *t)
{}

static int radio_s_tuner(struct file *file, void *priv,
			 const struct v4l2_tuner *t)
{}

/*
 * em28xx_free_v4l2() - Free struct em28xx_v4l2
 *
 * @ref: struct kref for struct em28xx_v4l2
 *
 * Called when all users of struct em28xx_v4l2 are gone
 */
static void em28xx_free_v4l2(struct kref *ref)
{}

/*
 * em28xx_v4l2_open()
 * inits the device and starts isoc transfer
 */
static int em28xx_v4l2_open(struct file *filp)
{}

/*
 * em28xx_v4l2_fini()
 * unregisters the v4l2,i2c and usb devices
 * called when the device gets disconnected or at module unload
 */
static int em28xx_v4l2_fini(struct em28xx *dev)
{}

static int em28xx_v4l2_suspend(struct em28xx *dev)
{}

static int em28xx_v4l2_resume(struct em28xx *dev)
{}

/*
 * em28xx_v4l2_close()
 * stops streaming and deallocates all resources allocated by the v4l2
 * calls and ioctls
 */
static int em28xx_v4l2_close(struct file *filp)
{}

static const struct v4l2_file_operations em28xx_v4l_fops =;

static const struct v4l2_ioctl_ops video_ioctl_ops =;

static const struct video_device em28xx_video_template =;

static const struct v4l2_file_operations radio_fops =;

static const struct v4l2_ioctl_ops radio_ioctl_ops =;

static struct video_device em28xx_radio_template =;

/* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */
static unsigned short saa711x_addrs[] =;

static unsigned short tvp5150_addrs[] =;

static unsigned short msp3400_addrs[] =;

/******************************** usb interface ******************************/

static void em28xx_vdev_init(struct em28xx *dev,
			     struct video_device *vfd,
			     const struct video_device *template,
			     const char *type_name)
{}

static void em28xx_tuner_setup(struct em28xx *dev, unsigned short tuner_addr)
{}

static int em28xx_v4l2_init(struct em28xx *dev)
{}

static struct em28xx_ops v4l2_ops =;

static int __init em28xx_video_register(void)
{}

static void __exit em28xx_video_unregister(void)
{}

module_init();
module_exit(em28xx_video_unregister);