Path: blob/master/drivers/media/video/gspca/gspca.h
17602 views
#ifndef GSPCAV2_H1#define GSPCAV2_H23#include <linux/module.h>4#include <linux/kernel.h>5#include <linux/usb.h>6#include <linux/videodev2.h>7#include <media/v4l2-common.h>8#include <linux/mutex.h>910/* compilation option */11/*#define GSPCA_DEBUG 1*/1213#ifdef GSPCA_DEBUG14/* GSPCA our debug messages */15extern int gspca_debug;16#define PDEBUG(level, fmt, args...) \17do {\18if (gspca_debug & (level)) \19printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args); \20} while (0)21#define D_ERR 0x0122#define D_PROBE 0x0223#define D_CONF 0x0424#define D_STREAM 0x0825#define D_FRAM 0x1026#define D_PACK 0x2027#define D_USBI 0x0028#define D_USBO 0x0029#define D_V4L2 0x010030#else31#define PDEBUG(level, fmt, args...)32#endif33#undef err34#define err(fmt, args...) \35printk(KERN_ERR MODULE_NAME ": " fmt "\n", ## args)36#undef info37#define info(fmt, args...) \38printk(KERN_INFO MODULE_NAME ": " fmt "\n", ## args)39#undef warn40#define warn(fmt, args...) \41printk(KERN_WARNING MODULE_NAME ": " fmt "\n", ## args)4243#define GSPCA_MAX_FRAMES 16 /* maximum number of video frame buffers */44/* image transfers */45#define MAX_NURBS 4 /* max number of URBs */464748/* used to list framerates supported by a camera mode (resolution) */49struct framerates {50const u8 *rates;51int nrates;52};5354/* control definition */55struct gspca_ctrl {56s16 val; /* current value */57s16 def; /* default value */58s16 min, max; /* minimum and maximum values */59};6061/* device information - set at probe time */62struct cam {63const struct v4l2_pix_format *cam_mode; /* size nmodes */64const struct framerates *mode_framerates; /* must have size nmodes,65* just like cam_mode */66struct gspca_ctrl *ctrls; /* control table - size nctrls */67/* may be NULL */68u32 bulk_size; /* buffer size when image transfer by bulk */69u32 input_flags; /* value for ENUM_INPUT status flags */70u8 nmodes; /* size of cam_mode */71u8 no_urb_create; /* don't create transfer URBs */72u8 bulk_nurbs; /* number of URBs in bulk mode73* - cannot be > MAX_NURBS74* - when 0 and bulk_size != 0 means75* 1 URB and submit done by subdriver */76u8 bulk; /* image transfer by 0:isoc / 1:bulk */77u8 npkt; /* number of packets in an ISOC message78* 0 is the default value: 32 packets */79u8 reverse_alts; /* Alt settings are in high to low order */80};8182struct gspca_dev;83struct gspca_frame;8485/* subdriver operations */86typedef int (*cam_op) (struct gspca_dev *);87typedef void (*cam_v_op) (struct gspca_dev *);88typedef int (*cam_cf_op) (struct gspca_dev *, const struct usb_device_id *);89typedef int (*cam_jpg_op) (struct gspca_dev *,90struct v4l2_jpegcompression *);91typedef int (*cam_reg_op) (struct gspca_dev *,92struct v4l2_dbg_register *);93typedef int (*cam_ident_op) (struct gspca_dev *,94struct v4l2_dbg_chip_ident *);95typedef void (*cam_streamparm_op) (struct gspca_dev *,96struct v4l2_streamparm *);97typedef int (*cam_qmnu_op) (struct gspca_dev *,98struct v4l2_querymenu *);99typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,100u8 *data,101int len);102typedef int (*cam_int_pkt_op) (struct gspca_dev *gspca_dev,103u8 *data,104int len);105106struct ctrl {107struct v4l2_queryctrl qctrl;108int (*set)(struct gspca_dev *, __s32);109int (*get)(struct gspca_dev *, __s32 *);110cam_v_op set_control;111};112113/* subdriver description */114struct sd_desc {115/* information */116const char *name; /* sub-driver name */117/* controls */118const struct ctrl *ctrls; /* static control definition */119int nctrls;120/* mandatory operations */121cam_cf_op config; /* called on probe */122cam_op init; /* called on probe and resume */123cam_op start; /* called on stream on after URBs creation */124cam_pkt_op pkt_scan;125/* optional operations */126cam_op isoc_init; /* called on stream on before getting the EP */127cam_op isoc_nego; /* called when URB submit failed with NOSPC */128cam_v_op stopN; /* called on stream off - main alt */129cam_v_op stop0; /* called on stream off & disconnect - alt 0 */130cam_v_op dq_callback; /* called when a frame has been dequeued */131cam_jpg_op get_jcomp;132cam_jpg_op set_jcomp;133cam_qmnu_op querymenu;134cam_streamparm_op get_streamparm;135cam_streamparm_op set_streamparm;136#ifdef CONFIG_VIDEO_ADV_DEBUG137cam_reg_op set_register;138cam_reg_op get_register;139#endif140cam_ident_op get_chip_ident;141#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)142cam_int_pkt_op int_pkt_scan;143/* other_input makes the gspca core create gspca_dev->input even when144int_pkt_scan is NULL, for cams with non interrupt driven buttons */145u8 other_input;146#endif147};148149/* packet types when moving from iso buf to frame buf */150enum gspca_packet_type {151DISCARD_PACKET,152FIRST_PACKET,153INTER_PACKET,154LAST_PACKET155};156157struct gspca_frame {158__u8 *data; /* frame buffer */159int vma_use_count;160struct v4l2_buffer v4l2_buf;161};162163struct gspca_dev {164struct video_device vdev; /* !! must be the first item */165struct module *module; /* subdriver handling the device */166struct usb_device *dev;167struct file *capt_file; /* file doing video capture */168#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)169struct input_dev *input_dev;170char phys[64]; /* physical device path */171#endif172173struct cam cam; /* device information */174const struct sd_desc *sd_desc; /* subdriver description */175unsigned ctrl_dis; /* disabled controls (bit map) */176unsigned ctrl_inac; /* inactive controls (bit map) */177178#define USB_BUF_SZ 64179__u8 *usb_buf; /* buffer for USB exchanges */180struct urb *urb[MAX_NURBS];181#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)182struct urb *int_urb;183#endif184185__u8 *frbuf; /* buffer for nframes */186struct gspca_frame frame[GSPCA_MAX_FRAMES];187u8 *image; /* image beeing filled */188__u32 frsz; /* frame size */189u32 image_len; /* current length of image */190atomic_t fr_q; /* next frame to queue */191atomic_t fr_i; /* frame being filled */192signed char fr_queue[GSPCA_MAX_FRAMES]; /* frame queue */193char nframes; /* number of frames */194u8 fr_o; /* next frame to dequeue */195__u8 last_packet_type;196__s8 empty_packet; /* if (-1) don't check empty packets */197__u8 streaming;198199__u8 curr_mode; /* current camera mode */200__u32 pixfmt; /* current mode parameters */201__u16 width;202__u16 height;203__u32 sequence; /* frame sequence number */204205wait_queue_head_t wq; /* wait queue */206struct mutex usb_lock; /* usb exchange protection */207struct mutex queue_lock; /* ISOC queue protection */208int usb_err; /* USB error - protected by usb_lock */209u16 pkt_size; /* ISOC packet size */210#ifdef CONFIG_PM211char frozen; /* suspend - resume */212#endif213char present; /* device connected */214char nbufread; /* number of buffers for read() */215char memory; /* memory type (V4L2_MEMORY_xxx) */216__u8 iface; /* USB interface number */217__u8 alt; /* USB alternate setting */218__u8 nbalt; /* number of USB alternate settings */219u8 audio; /* presence of audio device */220};221222int gspca_dev_probe(struct usb_interface *intf,223const struct usb_device_id *id,224const struct sd_desc *sd_desc,225int dev_size,226struct module *module);227int gspca_dev_probe2(struct usb_interface *intf,228const struct usb_device_id *id,229const struct sd_desc *sd_desc,230int dev_size,231struct module *module);232void gspca_disconnect(struct usb_interface *intf);233void gspca_frame_add(struct gspca_dev *gspca_dev,234enum gspca_packet_type packet_type,235const u8 *data,236int len);237#ifdef CONFIG_PM238int gspca_suspend(struct usb_interface *intf, pm_message_t message);239int gspca_resume(struct usb_interface *intf);240#endif241int gspca_auto_gain_n_exposure(struct gspca_dev *gspca_dev, int avg_lum,242int desired_avg_lum, int deadzone, int gain_knee, int exposure_knee);243#endif /* GSPCAV2_H */244245246