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              "v1.0.0"                    
00040 #define DRIVER_VERSION_NUM          0x000100                    
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                      
00052 #define USB_STK_0501_PRODUCT_ID     0x0501                      
00061 #define VID_HARDWARE_STK11XX        88
00062 
00063 
00064 
00065 
00079 #define MAX_ISO_BUFS                16
00080 #define ISO_FRAMES_PER_DESC         10
00081 #define ISO_MAX_FRAME_SIZE          3 * 1024
00082 #define ISO_BUFFER_SIZE             (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
00083 
00084 
00092 #define STK11XX_MAX_IMAGES          10
00093 #define STK11XX_FRAME_SIZE          (1280 * 1024 * 4)
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00107 #define DRIVER_SUPPORT              "Syntek USB Camera : STK-1135"
00108 
00129 #ifndef CONFIG_STK11XX_DEBUG
00130 #define CONFIG_STK11XX_DEBUG            0
00131 #endif
00132 
00133 #if CONFIG_STK11XX_DEBUG
00134 
00135 #define STK_INFO(str, args...)          printk(KERN_INFO PREFIX str, ##args)
00136 #define STK_ERROR(str, args...)         printk(KERN_ERR PREFIX str, ##args)
00137 #define STK_WARNING(str, args...)       printk(KERN_WARNING PREFIX str, ##args)
00138 #define STK_DEBUG(str, args...)         printk(KERN_DEBUG PREFIX str, ##args)
00139 
00140 #else
00141 
00142 #define STK_INFO(str, args...)          printk(KERN_INFO PREFIX str, ##args)
00143 #define STK_ERROR(str, args...)         printk(KERN_ERR PREFIX str, ##args)
00144 #define STK_WARNING(str, args...)       printk(KERN_WARNING PREFIX str, ##args)
00145 #define STK_DEBUG(str, args...)         do { } while(0)
00146 
00147 #endif
00148 
00149 
00158 #ifndef CONFIG_STK11XX_DEBUG_STREAM
00159 #define CONFIG_STK11XX_DEBUG_STREAM     0
00160 #endif
00161 
00162 #if CONFIG_STK11XX_DEBUG_STREAM
00163 
00164 #define STK_STREAM(str, args...)        printk(KERN_DEBUG PREFIX str, ##args)
00165 
00166 #else
00167 
00168 #define STK_STREAM(str, args...)        do { } while(0)
00169 
00170 #endif
00171 
00172 
00173 
00177 typedef enum {
00178     SYNTEK_STK_M811 = 1,
00179     SYNTEK_STK_A311 = 2,
00180     SYNTEK_STK_A821 = 3,
00181     SYNTEK_STK_6A31 = 4
00182 } T_SYNTEK_DEVICE;
00183 
00184 
00188 typedef enum {
00189     STK11XX_VGA,                        
00190     STK11XX_SXGA,                       
00191     STK11XX_UXGA                        
00192 } T_STK11XX_VIDEOMODE;
00193 
00194 
00198 typedef enum {
00199     STK11XX_80x60,
00200     STK11XX_128x96,
00201     STK11XX_160x120,
00202     STK11XX_213x160,
00203     STK11XX_320x240,
00204     STK11XX_640x480,
00205     STK11XX_800x600,
00206     STK11XX_1024x768,
00207     STK11XX_1280x1024,
00208     STK11XX_NBR_SIZES
00209 } T_STK11XX_RESOLUTION;
00210 
00211 
00215 typedef enum {
00216     STK11XX_PALETTE_RGB24,
00217     STK11XX_PALETTE_RGB32,
00218     STK11XX_PALETTE_BGR24,
00219     STK11XX_PALETTE_BGR32
00220 } T_STK11XX_PALETTE;
00221 
00222 
00226 struct stk11xx_iso_buf {
00227     void *data;
00228     int length;
00229     int read;
00230     struct urb *urb;
00231 };
00232 
00233 
00237 struct stk11xx_frame_buf {
00238     int errors;
00239     void *data;
00240     volatile int filled;
00241     struct stk11xx_frame_buf *next;
00242 };
00243 
00244 
00248 struct stk11xx_image_buf {
00249     unsigned long offset;               
00250     int vma_use_count;                  
00251 };
00252 
00253 
00257 struct stk11xx_coord {
00258     int x;                              
00259     int y;                              
00260 };
00261 
00262 
00266 struct stk11xx_video {
00267     int fps;                            
00268     int brightness;                     
00269     int contrast;                       
00270     int whiteness;                      
00271     int colour;                         
00272     int depth;                          
00273     int palette;                        
00274     int hue;                            
00275     int hflip;                          
00276     int vflip;                          
00277 };
00278 
00279 
00283 struct usb_stk11xx {
00284     struct video_device *vdev;          
00285     struct usb_device *udev;            
00286     struct usb_interface *interface;    
00288     int release;                        
00289     int webcam_model;                   
00290     int webcam_type;                    
00292     unsigned char *int_in_buffer;       
00293     size_t int_in_size;                 
00294     __u8 int_in_endpointAddr;           
00296     size_t isoc_in_size;                
00297     __u8 isoc_in_endpointAddr;          
00299     int watchdog;                       
00301     struct stk11xx_video vsettings;     
00303     int error_status;
00304 
00305     int vopen;                          
00306     int visoc_errors;                   
00307     int vframes_error;                  
00308     int vframes_dumped;                 
00311     spinlock_t spinlock;                
00312     struct semaphore mutex;             
00313     wait_queue_head_t wait_frame;       
00316     // 1: isoc
00317     char isoc_init_ok;
00318     struct stk11xx_iso_buf isobuf[MAX_ISO_BUFS];
00319 
00320     // 2: frame
00321     int frame_size;
00322     struct stk11xx_frame_buf *framebuf;
00323     struct stk11xx_frame_buf *empty_frames, *empty_frames_tail;
00324     struct stk11xx_frame_buf *full_frames, *full_frames_tail;
00325     struct stk11xx_frame_buf *fill_frame;
00326     struct stk11xx_frame_buf *read_frame;
00327 
00328     // 3: image
00329     int image_size;
00330     void *image_data;
00331     struct stk11xx_image_buf images[STK11XX_MAX_IMAGES];
00332     int image_used[STK11XX_MAX_IMAGES];
00333     unsigned int nbuffers;
00334     unsigned int len_per_image;
00335     int image_read_pos;
00336     int fill_image;
00337     int resolution;
00338     struct stk11xx_coord view;
00339     struct stk11xx_coord image;
00340 };
00341 
00342 
00347 #define STK11XX_PERCENT(x,y) ( ((int)x * (int)y) / 100)
00348 
00349 
00354 #define to_stk11xx_dev(d) container_of(d, struct usb_stk11xx, kref)
00355 
00356 
00357 extern const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES];
00358 
00359     
00360 int usb_stk11xx_write_registry(struct usb_stk11xx *, __u16, __u16);
00361 int usb_stk11xx_read_registry(struct usb_stk11xx *, __u16, int *);
00362 int usb_stk11xx_set_feature(struct usb_stk11xx *, int);
00363 int usb_stk11xx_set_configuration(struct usb_stk11xx *);
00364 int usb_stk11xx_isoc_init(struct usb_stk11xx *);
00365 void usb_stk11xx_isoc_handler(struct urb *);
00366 void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *);
00367 
00368 int dev_stk11xx_initialize_device(struct usb_stk11xx *);
00369 int dev_stk11xx_start_stream(struct usb_stk11xx *);
00370 int dev_stk11xx_stop_stream(struct usb_stk11xx *);
00371 int dev_stk11xx_check_device(struct usb_stk11xx *, int);
00372 int dev_stk11xx_camera_on(struct usb_stk11xx *);
00373 int dev_stk11xx_camera_off(struct usb_stk11xx *);
00374 int dev_stk11xx_camera_asleep(struct usb_stk11xx *);
00375 int dev_stk11xx_init_camera(struct usb_stk11xx *);
00376 int dev_stk11xx_reconf_camera(struct usb_stk11xx *);
00377 int dev_stk11xx_camera_settings(struct usb_stk11xx *);
00378 int dev_stk11xx_set_camera_quality(struct usb_stk11xx *);
00379 int dev_stk11xx_set_camera_fps(struct usb_stk11xx *);
00380 int dev_stk11xx_watchdog_camera(struct usb_stk11xx *);
00381 
00382 int v4l_stk11xx_select_video_mode(struct usb_stk11xx *, int, int);
00383 int v4l_stk11xx_register_video_device(struct usb_stk11xx *);
00384 int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *);
00385 
00386 int stk11xx_create_sysfs_files(struct video_device *);
00387 void stk11xx_remove_sysfs_files(struct video_device *);
00388 
00389 int stk11xx_allocate_buffers(struct usb_stk11xx *);
00390 int stk11xx_reset_buffers(struct usb_stk11xx *);
00391 int stk11xx_clear_buffers(struct usb_stk11xx *);
00392 int stk11xx_free_buffers(struct usb_stk11xx *);
00393 void stk11xx_next_image(struct usb_stk11xx *);
00394 int stk11xx_next_frame(struct usb_stk11xx *);
00395 int stk11xx_handle_frame(struct usb_stk11xx *);
00396 
00397 int stk11xx_decompress(struct usb_stk11xx *);
00398 
00399 
00400 #endif 

Generated on Tue Oct 30 13:32:13 2007 for SyntekUSBVideoCamera by  doxygen 1.5.3