00001
00034 #ifndef STK11XX_H
00035 #define STK11XX_H
00036
00037
00038 #define DRIVER_NAME "stk11xx"
00039 #define DRIVER_VERSION "v1.3.1"
00040 #define DRIVER_VERSION_NUM 0x010301
00041 #define DRIVER_DESC "Syntek USB Video Camera"
00042 #define DRIVER_AUTHOR "Nicolas VIVIEN"
00043 #define PREFIX DRIVER_NAME ": "
00045 #define USB_SYNTEK1_VENDOR_ID 0x174f
00046 #define USB_SYNTEK2_VENDOR_ID 0x05e1
00048 #define USB_STK_A311_PRODUCT_ID 0xa311
00049 #define USB_STK_A821_PRODUCT_ID 0xa821
00050 #define USB_STK_6A31_PRODUCT_ID 0x6a31
00051 #define USB_STK_6A33_PRODUCT_ID 0x6a33
00052 #define USB_STK_6A51_PRODUCT_ID 0x6a51
00053 #define USB_STK_6A54_PRODUCT_ID 0x6a54
00055 #define USB_STK_0501_PRODUCT_ID 0x0501
00064 #define VID_HARDWARE_STK11XX 88
00065
00066
00067
00068
00082 #define MAX_ISO_BUFS 16
00083 #define ISO_FRAMES_PER_DESC 10
00084 #define ISO_MAX_FRAME_SIZE 3 * 1024
00085 #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
00086
00087
00095 #define STK11XX_MAX_IMAGES 10
00096 #define STK11XX_FRAME_SIZE (1280 * 1024 * 4)
00097
00098
00099
00100
00101
00102
00103
00110 #define DRIVER_SUPPORT "Syntek USB Camera : STK-1135"
00111
00132 #ifndef CONFIG_STK11XX_DEBUG
00133 #define CONFIG_STK11XX_DEBUG 0
00134 #endif
00135
00136 #if CONFIG_STK11XX_DEBUG
00137
00138 #define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
00139 #define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
00140 #define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
00141 #define STK_DEBUG(str, args...) printk(KERN_DEBUG PREFIX str, ##args)
00142
00143 #else
00144
00145 #define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
00146 #define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
00147 #define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
00148 #define STK_DEBUG(str, args...) do { } while(0)
00149
00150 #endif
00151
00152
00161 #ifndef CONFIG_STK11XX_DEBUG_STREAM
00162 #define CONFIG_STK11XX_DEBUG_STREAM 0
00163 #endif
00164
00165 #if CONFIG_STK11XX_DEBUG_STREAM
00166
00167 #define STK_STREAM(str, args...) printk(KERN_DEBUG PREFIX str, ##args)
00168
00169 #else
00170
00171 #define STK_STREAM(str, args...) do { } while(0)
00172
00173 #endif
00174
00175
00176
00180 typedef enum {
00181 SYNTEK_STK_M811 = 1,
00182 SYNTEK_STK_A311 = 2,
00183 SYNTEK_STK_A821 = 3,
00184 SYNTEK_STK_6A31 = 4,
00185 SYNTEK_STK_6A33 = 5,
00186 SYNTEK_STK_6A51 = 6,
00187 SYNTEK_STK_6A54 = 7
00188 } T_SYNTEK_DEVICE;
00189
00190
00194 typedef enum {
00195 STK11XX_VGA,
00196 STK11XX_SXGA,
00197 STK11XX_UXGA
00198 } T_STK11XX_VIDEOMODE;
00199
00200
00204 typedef enum {
00205 STK11XX_80x60,
00206 STK11XX_128x96,
00207 STK11XX_160x120,
00208 STK11XX_213x160,
00209 STK11XX_320x240,
00210 STK11XX_640x480,
00211 STK11XX_800x600,
00212 STK11XX_1024x768,
00213 STK11XX_1280x1024,
00214 STK11XX_NBR_SIZES
00215 } T_STK11XX_RESOLUTION;
00216
00217
00221 typedef enum {
00222 STK11XX_PALETTE_RGB24,
00223 STK11XX_PALETTE_RGB32,
00224 STK11XX_PALETTE_BGR24,
00225 STK11XX_PALETTE_BGR32,
00226 STK11XX_PALETTE_UYVY,
00227 STK11XX_PALETTE_YUYV
00228 } T_STK11XX_PALETTE;
00229
00230
00234 struct stk11xx_iso_buf {
00235 void *data;
00236 int length;
00237 int read;
00238 struct urb *urb;
00239 };
00240
00241
00245 struct stk11xx_frame_buf {
00246 int errors;
00247 void *data;
00248 volatile int filled;
00249 struct stk11xx_frame_buf *next;
00250 };
00251
00252
00256 struct stk11xx_image_buf {
00257 unsigned long offset;
00258 int vma_use_count;
00259 };
00260
00261
00265 struct stk11xx_coord {
00266 int x;
00267 int y;
00268 };
00269
00270
00274 struct stk11xx_video {
00275 int fps;
00276 int brightness;
00277 int contrast;
00278 int whiteness;
00279 int colour;
00280 int depth;
00281 int palette;
00282 int hue;
00283 int hflip;
00284 int vflip;
00285 };
00286
00287
00291 struct usb_stk11xx {
00292 struct video_device *vdev;
00293 struct usb_device *udev;
00294 struct usb_interface *interface;
00296 int release;
00297 int webcam_model;
00298 int webcam_type;
00300 unsigned char *int_in_buffer;
00301 size_t int_in_size;
00302 __u8 int_in_endpointAddr;
00304 size_t isoc_in_size;
00305 __u8 isoc_in_endpointAddr;
00307 int watchdog;
00309 struct stk11xx_video vsettings;
00311 int error_status;
00312
00313 int vopen;
00314 int visoc_errors;
00315 int vframes_error;
00316 int vframes_dumped;
00319 spinlock_t spinlock;
00320 struct semaphore mutex;
00321 wait_queue_head_t wait_frame;
00324
00325 char isoc_init_ok;
00326 struct stk11xx_iso_buf isobuf[MAX_ISO_BUFS];
00327
00328
00329 int frame_size;
00330 struct stk11xx_frame_buf *framebuf;
00331 struct stk11xx_frame_buf *empty_frames, *empty_frames_tail;
00332 struct stk11xx_frame_buf *full_frames, *full_frames_tail;
00333 struct stk11xx_frame_buf *fill_frame;
00334 struct stk11xx_frame_buf *read_frame;
00335
00336
00337 int view_size;
00338 int image_size;
00339 void *image_data;
00340 struct stk11xx_image_buf images[STK11XX_MAX_IMAGES];
00341 int image_used[STK11XX_MAX_IMAGES];
00342 unsigned int nbuffers;
00343 unsigned int len_per_image;
00344 int image_read_pos;
00345 int fill_image;
00346 int resolution;
00347 struct stk11xx_coord view;
00348 struct stk11xx_coord image;
00349 };
00350
00351
00356 #define STK11XX_PERCENT(x,y) ( ((int)x * (int)y) / 100)
00357
00358
00363 #define to_stk11xx_dev(d) container_of(d, struct usb_stk11xx, kref)
00364
00365
00366 extern const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES];
00367
00368
00369 int usb_stk11xx_write_registry(struct usb_stk11xx *, __u16, __u16);
00370 int usb_stk11xx_read_registry(struct usb_stk11xx *, __u16, int *);
00371 int usb_stk11xx_set_feature(struct usb_stk11xx *, int);
00372 int usb_stk11xx_set_configuration(struct usb_stk11xx *);
00373 int usb_stk11xx_isoc_init(struct usb_stk11xx *);
00374 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
00375 void usb_stk11xx_isoc_handler(struct urb *, struct pt_regs *);
00376 #else
00377 void usb_stk11xx_isoc_handler(struct urb *);
00378 #endif
00379 void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *);
00380
00381 int dev_stk11xx_initialize_device(struct usb_stk11xx *);
00382 int dev_stk11xx_start_stream(struct usb_stk11xx *);
00383 int dev_stk11xx_stop_stream(struct usb_stk11xx *);
00384 int dev_stk11xx_check_device(struct usb_stk11xx *, int);
00385 int dev_stk11xx_camera_on(struct usb_stk11xx *);
00386 int dev_stk11xx_camera_off(struct usb_stk11xx *);
00387 int dev_stk11xx_camera_asleep(struct usb_stk11xx *);
00388 int dev_stk11xx_init_camera(struct usb_stk11xx *);
00389 int dev_stk11xx_reconf_camera(struct usb_stk11xx *);
00390 int dev_stk11xx_camera_settings(struct usb_stk11xx *);
00391 int dev_stk11xx_set_camera_quality(struct usb_stk11xx *);
00392 int dev_stk11xx_set_camera_fps(struct usb_stk11xx *);
00393 int dev_stk11xx_watchdog_camera(struct usb_stk11xx *);
00394
00395 int v4l_stk11xx_select_video_mode(struct usb_stk11xx *, int, int);
00396 int v4l_stk11xx_register_video_device(struct usb_stk11xx *);
00397 int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *);
00398
00399 int stk11xx_create_sysfs_files(struct video_device *);
00400 void stk11xx_remove_sysfs_files(struct video_device *);
00401
00402 int stk11xx_allocate_buffers(struct usb_stk11xx *);
00403 int stk11xx_reset_buffers(struct usb_stk11xx *);
00404 int stk11xx_clear_buffers(struct usb_stk11xx *);
00405 int stk11xx_free_buffers(struct usb_stk11xx *);
00406 void stk11xx_next_image(struct usb_stk11xx *);
00407 int stk11xx_next_frame(struct usb_stk11xx *);
00408 int stk11xx_handle_frame(struct usb_stk11xx *);
00409
00410 int stk11xx_decompress(struct usb_stk11xx *);
00411
00412
00413 #endif