SyntekUSBVideoCamera

stk11xx.h

Go to the documentation of this file.
00001 
00034 #ifndef STK11XX_H
00035 #define STK11XX_H
00036 
00037 
00038 #define DRIVER_NAME                 "stk11xx"                   
00039 #define DRIVER_VERSION              "v2.2.0"                    
00040 #define DRIVER_VERSION_NUM          0x020200                    
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_AA11_PRODUCT_ID     0xaa11                      
00051 #define USB_STK_6A31_PRODUCT_ID     0x6a31                      
00052 #define USB_STK_6A33_PRODUCT_ID     0x6a33                      
00053 #define USB_STK_6A51_PRODUCT_ID     0x6a51                      
00054 #define USB_STK_6A54_PRODUCT_ID     0x6a54                      
00055 #define USB_STK_6D51_PRODUCT_ID     0x6d51                      
00057 #define USB_STK_0408_PRODUCT_ID     0x0408                      
00058 #define USB_STK_0500_PRODUCT_ID     0x0500                      
00059 #define USB_STK_0501_PRODUCT_ID     0x0501                      
00068 #define VID_HARDWARE_STK11XX        88
00069 
00070 
00071 
00072 
00086 #define MAX_ISO_BUFS                16
00087 #define ISO_FRAMES_PER_DESC         10
00088 #define ISO_MAX_FRAME_SIZE          3 * 1024
00089 #define ISO_BUFFER_SIZE             (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
00090 
00091 
00103 #define STK11XX_MAX_IMAGES          10
00104 #define STK11XX_FRAME_SIZE          (1280 * 1024 * 4)
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00118 #define DRIVER_SUPPORT              "Syntek USB Camera : STK-1135"
00119 
00140 #ifndef CONFIG_STK11XX_DEBUG
00141 #define CONFIG_STK11XX_DEBUG            0
00142 #endif
00143 
00144 #if CONFIG_STK11XX_DEBUG
00145 
00146 #define STK_INFO(str, args...)          printk(KERN_INFO PREFIX str, ##args)
00147 #define STK_ERROR(str, args...)         printk(KERN_ERR PREFIX str, ##args)
00148 #define STK_WARNING(str, args...)       printk(KERN_WARNING PREFIX str, ##args)
00149 #define STK_DEBUG(str, args...)         printk(KERN_DEBUG PREFIX str, ##args)
00150 
00151 #else
00152 
00153 #define STK_INFO(str, args...)          printk(KERN_INFO PREFIX str, ##args)
00154 #define STK_ERROR(str, args...)         printk(KERN_ERR PREFIX str, ##args)
00155 #define STK_WARNING(str, args...)       printk(KERN_WARNING PREFIX str, ##args)
00156 #define STK_DEBUG(str, args...)         do { } while(0)
00157 
00158 #endif
00159 
00160 
00169 #ifndef CONFIG_STK11XX_DEBUG_STREAM
00170 #define CONFIG_STK11XX_DEBUG_STREAM     0
00171 #endif
00172 
00173 #if CONFIG_STK11XX_DEBUG_STREAM
00174 
00175 #define STK_STREAM(str, args...)        printk(KERN_DEBUG PREFIX str, ##args)
00176 
00177 #else
00178 
00179 #define STK_STREAM(str, args...)        do { } while(0)
00180 
00181 #endif
00182 
00183 
00184 
00188 typedef enum {
00189     SYNTEK_STK_M811 = 1,
00190     SYNTEK_STK_A311 = 2,
00191     SYNTEK_STK_A821 = 3,
00192     SYNTEK_STK_6A31 = 4,
00193     SYNTEK_STK_6A33 = 5,
00194     SYNTEK_STK_6A51 = 6,
00195     SYNTEK_STK_6A54 = 7,
00196     SYNTEK_STK_6D51 = 8,
00197     SYNTEK_STK_0500 = 9,
00198     SYNTEK_STK_0408 = 10,
00199     SYNTEK_STK_AA11 = 11,
00200 } T_SYNTEK_DEVICE;
00201 
00202 
00206 typedef enum {
00207     STK11XX_VGA,                        
00208     STK11XX_SXGA,                       
00209     STK11XX_PAL,                        
00210     STK11XX_UXGA                        
00211 } T_STK11XX_VIDEOMODE;
00212 
00213 
00217 typedef enum {
00218     STK11XX_80x60,
00219     STK11XX_128x96,
00220     STK11XX_160x120,
00221     STK11XX_213x160,
00222     STK11XX_320x240,
00223     STK11XX_640x480,
00224     STK11XX_720x576,
00225     STK11XX_800x600,
00226     STK11XX_1024x768,
00227     STK11XX_1280x1024,
00228     STK11XX_NBR_SIZES
00229 } T_STK11XX_RESOLUTION;
00230 
00231 
00235 typedef enum {
00236     STK11XX_PALETTE_RGB24,
00237     STK11XX_PALETTE_RGB32,
00238     STK11XX_PALETTE_BGR24,
00239     STK11XX_PALETTE_BGR32,
00240     STK11XX_PALETTE_UYVY,
00241     STK11XX_PALETTE_YUYV
00242 } T_STK11XX_PALETTE;
00243 
00244 
00248 struct stk11xx_iso_buf {
00249     void *data;
00250     int length;
00251     int read;
00252     struct urb *urb;
00253 };
00254 
00255 
00259 struct stk11xx_frame_buf {
00260     int errors;
00261     void *data;
00262     volatile bool odd;
00263     volatile int filled;
00264     struct stk11xx_frame_buf *next;
00265 };
00266 
00267 
00271 struct stk11xx_image_buf {
00272     unsigned long offset;               
00273     int vma_use_count;                  
00274 };
00275 
00276 
00280 struct stk11xx_coord {
00281     int x;                              
00282     int y;                              
00283 };
00284 
00285 
00289 struct stk11xx_video {
00290     int fps;                            
00291     int brightness;                     
00292     int contrast;                       
00293     int whiteness;                      
00294     int colour;                         
00295     int depth;                          
00296     int palette;                        
00297     int hue;                            
00298     int hflip;                          
00299     int vflip;                          
00300     int input;                          
00301     int norm;                           
00302 };
00303 
00304 
00308 struct usb_stk11xx {
00309     struct video_device *vdev;          
00310     struct usb_device *udev;            
00311     struct usb_interface *interface;    
00313     int release;                        
00314     int webcam_model;                   
00315     int webcam_type;                    
00317     unsigned char *int_in_buffer;       
00318     size_t int_in_size;                 
00319     __u8 int_in_endpointAddr;           
00321     size_t isoc_in_size;                
00322     __u8 isoc_in_endpointAddr;          
00324     int watchdog;                       
00326     struct stk11xx_video vsettings;     
00328     int error_status;
00329 
00330     int vopen;                          
00331     int visoc_errors;                   
00332     int vframes_error;                  
00333     int vframes_dumped;                 
00334     int vsync;                          
00335     int v1st_cap;                       
00338     spinlock_t spinlock;                
00339     struct semaphore mutex;             
00340     wait_queue_head_t wait_frame;       
00341     struct mutex modlock;               
00344     // 1: isoc
00345     char isoc_init_ok;
00346     struct stk11xx_iso_buf isobuf[MAX_ISO_BUFS];
00347 
00348     // 2: frame
00349     int frame_size;
00350     struct stk11xx_frame_buf *framebuf;
00351     struct stk11xx_frame_buf *empty_frames, *empty_frames_tail;
00352     struct stk11xx_frame_buf *full_frames, *full_frames_tail;
00353     struct stk11xx_frame_buf *fill_frame;
00354     struct stk11xx_frame_buf *read_frame;
00355 
00356     // 3: image
00357     int view_size;
00358     int image_size;
00359     void *image_data;
00360     struct stk11xx_image_buf images[STK11XX_MAX_IMAGES];
00361     int image_used[STK11XX_MAX_IMAGES];
00362     unsigned int nbuffers;
00363     unsigned int len_per_image;
00364     int image_read_pos;
00365     int fill_image;
00366     int resolution;
00367     struct stk11xx_coord view;
00368     struct stk11xx_coord image;
00369 };
00370 
00371 
00376 #define STK11XX_PERCENT(x,y) ( ((int)x * (int)y) / 100)
00377 
00378 
00383 #define to_stk11xx_dev(d) container_of(d, struct usb_stk11xx, kref)
00384 
00385 
00386 extern const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES];
00387 
00388     
00389 int usb_stk11xx_write_registry(struct usb_stk11xx *, __u16, __u16);
00390 int usb_stk11xx_read_registry(struct usb_stk11xx *, __u16, int *);
00391 int usb_stk11xx_set_feature(struct usb_stk11xx *, int);
00392 int usb_stk11xx_set_configuration(struct usb_stk11xx *);
00393 int usb_stk11xx_isoc_init(struct usb_stk11xx *);
00394 void usb_stk11xx_isoc_handler(struct urb *);
00395 void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *);
00396 
00397 int dev_stk11xx_decompress(struct usb_stk11xx *);
00398 int dev_stk11xx_initialize_device(struct usb_stk11xx *);
00399 int dev_stk11xx_start_stream(struct usb_stk11xx *);
00400 int dev_stk11xx_stop_stream(struct usb_stk11xx *);
00401 int dev_stk11xx_check_device(struct usb_stk11xx *, int);
00402 int dev_stk11xx_camera_on(struct usb_stk11xx *);
00403 int dev_stk11xx_camera_off(struct usb_stk11xx *);
00404 int dev_stk11xx_camera_asleep(struct usb_stk11xx *);
00405 int dev_stk11xx_init_camera(struct usb_stk11xx *);
00406 int dev_stk11xx_reconf_camera(struct usb_stk11xx *);
00407 int dev_stk11xx_camera_settings(struct usb_stk11xx *);
00408 int dev_stk11xx_set_camera_quality(struct usb_stk11xx *);
00409 int dev_stk11xx_set_camera_fps(struct usb_stk11xx *);
00410 int dev_stk11xx_watchdog_camera(struct usb_stk11xx *);
00411 
00412 int v4l_stk11xx_select_video_mode(struct usb_stk11xx *, int, int);
00413 int v4l_stk11xx_register_video_device(struct usb_stk11xx *);
00414 int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *);
00415 
00416 int stk11xx_create_sysfs_files(struct video_device *);
00417 void stk11xx_remove_sysfs_files(struct video_device *);
00418 
00419 int stk11xx_allocate_buffers(struct usb_stk11xx *);
00420 int stk11xx_reset_buffers(struct usb_stk11xx *);
00421 int stk11xx_clear_buffers(struct usb_stk11xx *);
00422 int stk11xx_free_buffers(struct usb_stk11xx *);
00423 void stk11xx_next_image(struct usb_stk11xx *);
00424 int stk11xx_next_frame(struct usb_stk11xx *);
00425 int stk11xx_handle_frame(struct usb_stk11xx *);
00426 
00427 int stk11xx_decompress(struct usb_stk11xx *);
00428 
00429 
00430 #endif