0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef STKWEBCAM_H
0010 #define STKWEBCAM_H
0011
0012 #include <linux/usb.h>
0013 #include <media/v4l2-device.h>
0014 #include <media/v4l2-ctrls.h>
0015 #include <media/v4l2-common.h>
0016
0017 #define DRIVER_VERSION "v0.0.1"
0018 #define DRIVER_VERSION_NUM 0x000001
0019
0020 #define MAX_ISO_BUFS 3
0021 #define ISO_FRAMES_PER_DESC 16
0022 #define ISO_MAX_FRAME_SIZE 3 * 1024
0023 #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
0024
0025 struct stk_iso_buf {
0026 void *data;
0027 int length;
0028 int read;
0029 struct urb *urb;
0030 };
0031
0032
0033 struct stk_sio_buffer {
0034 struct v4l2_buffer v4lbuf;
0035 char *buffer;
0036 int mapcount;
0037 struct stk_camera *dev;
0038 struct list_head list;
0039 };
0040
0041 enum stk_mode {MODE_VGA, MODE_SXGA, MODE_CIF, MODE_QVGA, MODE_QCIF};
0042
0043 struct stk_video {
0044 enum stk_mode mode;
0045 __u32 palette;
0046 int hflip;
0047 int vflip;
0048 };
0049
0050 enum stk_status {
0051 S_PRESENT = 1,
0052 S_INITIALISED = 2,
0053 S_MEMALLOCD = 4,
0054 S_STREAMING = 8,
0055 };
0056 #define is_present(dev) ((dev)->status & S_PRESENT)
0057 #define is_initialised(dev) ((dev)->status & S_INITIALISED)
0058 #define is_streaming(dev) ((dev)->status & S_STREAMING)
0059 #define is_memallocd(dev) ((dev)->status & S_MEMALLOCD)
0060 #define set_present(dev) ((dev)->status = S_PRESENT)
0061 #define unset_present(dev) ((dev)->status &= \
0062 ~(S_PRESENT|S_INITIALISED|S_STREAMING))
0063 #define set_initialised(dev) ((dev)->status |= S_INITIALISED)
0064 #define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED)
0065 #define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD)
0066 #define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD)
0067 #define set_streaming(dev) ((dev)->status |= S_STREAMING)
0068 #define unset_streaming(dev) ((dev)->status &= ~S_STREAMING)
0069
0070 struct regval {
0071 unsigned reg;
0072 unsigned val;
0073 };
0074
0075 struct stk_camera {
0076 struct v4l2_device v4l2_dev;
0077 struct v4l2_ctrl_handler hdl;
0078 struct video_device vdev;
0079 struct usb_device *udev;
0080 struct usb_interface *interface;
0081 int webcam_model;
0082 struct file *owner;
0083 struct mutex lock;
0084 int first_init;
0085
0086 u8 isoc_ep;
0087
0088
0089 atomic_t urbs_used;
0090
0091 struct stk_video vsettings;
0092
0093 enum stk_status status;
0094
0095 spinlock_t spinlock;
0096 wait_queue_head_t wait_frame;
0097
0098 struct stk_iso_buf *isobufs;
0099
0100 int frame_size;
0101
0102 int reading;
0103 unsigned int n_sbufs;
0104 struct stk_sio_buffer *sio_bufs;
0105 struct list_head sio_avail;
0106 struct list_head sio_full;
0107 unsigned sequence;
0108
0109 u8 read_reg_scratch;
0110 };
0111
0112 #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
0113
0114 int stk_camera_write_reg(struct stk_camera *, u16, u8);
0115 int stk_camera_read_reg(struct stk_camera *, u16, u8 *);
0116
0117 int stk_sensor_init(struct stk_camera *);
0118 int stk_sensor_configure(struct stk_camera *);
0119 int stk_sensor_sleep(struct stk_camera *dev);
0120 int stk_sensor_wakeup(struct stk_camera *dev);
0121 int stk_sensor_set_brightness(struct stk_camera *dev, int br);
0122
0123 #endif