2 * stk-webcam.h : Driver for Syntek 1125 USB webcam controller
4 * Copyright (C) 2006 Nicolas VIVIEN
5 * Copyright 2007 Jaime Velasco Juan <jsagarribay@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <linux/usb.h>
26 #include <media/v4l2-common.h>
28 #define DRIVER_VERSION "v0.0.1"
29 #define DRIVER_VERSION_NUM 0x000001
31 #define MAX_ISO_BUFS 3
32 #define ISO_FRAMES_PER_DESC 16
33 #define ISO_MAX_FRAME_SIZE 3 * 1024
34 #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
37 #ifndef CONFIG_STK11XX_DEBUG
38 #define CONFIG_STK11XX_DEBUG 0
41 /*#define STK_PARTIAL_FRAMES*/
43 #define PREFIX "stkwebcam: "
44 #define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
45 #define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
46 #define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
48 #if CONFIG_STK11XX_DEBUG
49 # define STK_DEBUG(str, args...) printk(KERN_DEBUG PREFIX str, ##args)
51 # define STK_DEBUG(str, args...) do { } while(0)
61 /* Streaming IO buffers */
62 struct stk_sio_buffer
{
63 struct v4l2_buffer v4lbuf
;
66 struct stk_camera
*dev
;
67 struct list_head list
;
70 enum stk_mode
{MODE_VGA
, MODE_SXGA
, MODE_CIF
, MODE_QVGA
, MODE_QCIF
};
86 #define is_present(dev) ((dev)->status & S_PRESENT)
87 #define is_initialised(dev) ((dev)->status & S_INITIALISED)
88 #define is_streaming(dev) ((dev)->status & S_STREAMING)
89 #define is_memallocd(dev) ((dev)->status & S_MEMALLOCD)
90 #define set_present(dev) ((dev)->status = S_PRESENT)
91 #define unset_present(dev) ((dev)->status &= \
92 ~(S_PRESENT|S_INITIALISED|S_STREAMING))
93 #define set_initialised(dev) ((dev)->status |= S_INITIALISED)
94 #define unset_initialised(dev) ((dev)->status &= ~S_INITIALISED)
95 #define set_memallocd(dev) ((dev)->status |= S_MEMALLOCD)
96 #define unset_memallocd(dev) ((dev)->status &= ~S_MEMALLOCD)
97 #define set_streaming(dev) ((dev)->status |= S_STREAMING)
98 #define unset_streaming(dev) ((dev)->status &= ~S_STREAMING)
106 struct video_device vdev
;
107 struct usb_device
*udev
;
108 struct usb_interface
*interface
;
115 /* Not sure if this is right */
118 struct stk_video vsettings
;
120 enum stk_status status
;
123 wait_queue_head_t wait_frame
;
125 struct stk_iso_buf
*isobufs
;
128 /* Streaming buffers */
129 unsigned int n_sbufs
;
130 struct stk_sio_buffer
*sio_bufs
;
131 struct list_head sio_avail
;
132 struct list_head sio_full
;
136 #define to_stk_camera(d) container_of(d, struct stk_camera, kref)
137 #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)
139 void stk_camera_delete(struct kref
*);
140 int stk_camera_write_reg(struct stk_camera
*, u16
, u8
);
141 int stk_camera_read_reg(struct stk_camera
*, u16
, int *);
143 int stk_sensor_outb(struct stk_camera
*dev
, u8 reg
, u8 val
);
144 int stk_sensor_inb(struct stk_camera
*dev
, u8 reg
, u8
*val
);
145 int stk_sensor_init(struct stk_camera
*);
146 int stk_sensor_configure(struct stk_camera
*);
147 int stk_sensor_dump_registers(struct stk_camera
*dev
, u8 f
, u8 l
);
148 int stk_sensor_sleep(struct stk_camera
*dev
);
149 int stk_sensor_wakeup(struct stk_camera
*dev
);
150 int stk_sensor_set_brightness(struct stk_camera
*dev
, int br
);