2008-01-12 09:48:14 +00:00
|
|
|
/*
|
|
|
|
* stk-webcam.h : Driver for Syntek 1125 USB webcam controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Nicolas VIVIEN
|
|
|
|
* Copyright 2007-2008 Jaime Velasco Juan <jsagarribay@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef STKWEBCAM_H
|
|
|
|
#define STKWEBCAM_H
|
|
|
|
|
|
|
|
#include <linux/usb.h>
|
2013-02-04 11:17:42 +00:00
|
|
|
#include <media/v4l2-device.h>
|
2013-02-04 11:53:11 +00:00
|
|
|
#include <media/v4l2-ctrls.h>
|
2008-01-12 09:48:14 +00:00
|
|
|
#include <media/v4l2-common.h>
|
|
|
|
|
|
|
|
#define DRIVER_VERSION "v0.0.1"
|
|
|
|
#define DRIVER_VERSION_NUM 0x000001
|
|
|
|
|
|
|
|
#define MAX_ISO_BUFS 3
|
|
|
|
#define ISO_FRAMES_PER_DESC 16
|
|
|
|
#define ISO_MAX_FRAME_SIZE 3 * 1024
|
|
|
|
#define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
|
|
|
|
|
|
|
|
struct stk_iso_buf {
|
|
|
|
void *data;
|
|
|
|
int length;
|
|
|
|
int read;
|
|
|
|
struct urb *urb;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Streaming IO buffers */
|
|
|
|
struct stk_sio_buffer {
|
|
|
|
struct v4l2_buffer v4lbuf;
|
|
|
|
char *buffer;
|
|
|
|
int mapcount;
|
|
|
|
struct stk_camera *dev;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum stk_mode {MODE_VGA, MODE_SXGA, MODE_CIF, MODE_QVGA, MODE_QCIF};
|
|
|
|
|
|
|
|
struct stk_video {
|
|
|
|
enum stk_mode mode;
|
|
|
|
__u32 palette;
|
|
|
|
int hflip;
|
|
|
|
int vflip;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum stk_status {
|
|
|
|
S_PRESENT = 1,
|
|
|
|
S_INITIALISED = 2,
|
|
|
|
S_MEMALLOCD = 4,
|
|
|
|
S_STREAMING = 8,
|
|
|
|
};
|
|
|
|
#define is_present(dev) ((dev)->status & S_PRESENT)
|
|
|
|
#define is_initialised(dev) ((dev)->status & S_INITIALISED)
|
|
|
|
#define is_streaming(dev) ((dev)->status & S_STREAMING)
|
|
|
|
#define is_memallocd(dev) ((dev)->status & S_MEMALLOCD)
|
|
|
|
#define set_present(dev) ((dev)->status = S_PRESENT)
|
|
|
|
#define unset_present(dev) ((dev)->status &= \
|
|
|
|
~(S_PRESENT|S_INITIALISED|S_STREAMING))
|
|
|
|
#define set_initialised(dev) ((dev)->status |= S_INITIALISED)
|
2008-01-27 15:24:59 +00:00
|
|
|
#define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED)
|
2008-01-12 09:48:14 +00:00
|
|
|
#define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD)
|
|
|
|
#define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD)
|
|
|
|
#define set_streaming(dev) ((dev)->status |= S_STREAMING)
|
|
|
|
#define unset_streaming(dev) ((dev)->status &= ~S_STREAMING)
|
|
|
|
|
|
|
|
struct regval {
|
|
|
|
unsigned reg;
|
|
|
|
unsigned val;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stk_camera {
|
2013-02-04 11:17:42 +00:00
|
|
|
struct v4l2_device v4l2_dev;
|
2013-02-04 11:53:11 +00:00
|
|
|
struct v4l2_ctrl_handler hdl;
|
2008-01-12 09:48:14 +00:00
|
|
|
struct video_device vdev;
|
|
|
|
struct usb_device *udev;
|
|
|
|
struct usb_interface *interface;
|
|
|
|
int webcam_model;
|
|
|
|
struct file *owner;
|
2013-02-04 12:27:32 +00:00
|
|
|
struct mutex lock;
|
2013-02-04 12:08:41 +00:00
|
|
|
int first_init;
|
2008-01-12 09:48:14 +00:00
|
|
|
|
|
|
|
u8 isoc_ep;
|
|
|
|
|
|
|
|
/* Not sure if this is right */
|
|
|
|
atomic_t urbs_used;
|
|
|
|
|
|
|
|
struct stk_video vsettings;
|
|
|
|
|
|
|
|
enum stk_status status;
|
|
|
|
|
|
|
|
spinlock_t spinlock;
|
|
|
|
wait_queue_head_t wait_frame;
|
|
|
|
|
|
|
|
struct stk_iso_buf *isobufs;
|
|
|
|
|
|
|
|
int frame_size;
|
|
|
|
/* Streaming buffers */
|
2013-02-06 07:23:01 +00:00
|
|
|
int reading;
|
2008-01-12 09:48:14 +00:00
|
|
|
unsigned int n_sbufs;
|
|
|
|
struct stk_sio_buffer *sio_bufs;
|
|
|
|
struct list_head sio_avail;
|
|
|
|
struct list_head sio_full;
|
|
|
|
unsigned sequence;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
|
|
|
|
|
|
|
|
int stk_camera_write_reg(struct stk_camera *, u16, u8);
|
2016-11-16 11:11:54 +00:00
|
|
|
int stk_camera_read_reg(struct stk_camera *, u16, u8 *);
|
2008-01-12 09:48:14 +00:00
|
|
|
|
|
|
|
int stk_sensor_init(struct stk_camera *);
|
|
|
|
int stk_sensor_configure(struct stk_camera *);
|
|
|
|
int stk_sensor_sleep(struct stk_camera *dev);
|
|
|
|
int stk_sensor_wakeup(struct stk_camera *dev);
|
|
|
|
int stk_sensor_set_brightness(struct stk_camera *dev, int br);
|
|
|
|
|
|
|
|
#endif
|