SyntekUSBVideoCamera
stk11xx.h
Go to the documentation of this file.
1 
34 #ifndef STK11XX_H
35 #define STK11XX_H
36 
37 
38 #define DRIVER_NAME "stk11xx"
39 #define DRIVER_VERSION "v2.0.0"
40 #define DRIVER_VERSION_NUM 0x020000
41 #define DRIVER_DESC "Syntek USB Video Camera"
42 #define DRIVER_AUTHOR "Nicolas VIVIEN"
43 #define PREFIX DRIVER_NAME ": "
45 #define USB_SYNTEK1_VENDOR_ID 0x174f
46 #define USB_SYNTEK2_VENDOR_ID 0x05e1
48 #define USB_STK_A311_PRODUCT_ID 0xa311
49 #define USB_STK_A821_PRODUCT_ID 0xa821
50 #define USB_STK_6A31_PRODUCT_ID 0x6a31
51 #define USB_STK_6A33_PRODUCT_ID 0x6a33
52 #define USB_STK_6A51_PRODUCT_ID 0x6a51
53 #define USB_STK_6A54_PRODUCT_ID 0x6a54
54 #define USB_STK_6D51_PRODUCT_ID 0x6d51
56 #define USB_STK_0501_PRODUCT_ID 0x0501
65 #define VID_HARDWARE_STK11XX 88
66 
67 
68 
69 
83 #define MAX_ISO_BUFS 16
84 #define ISO_FRAMES_PER_DESC 10
85 #define ISO_MAX_FRAME_SIZE 3 * 1024
86 #define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
87 
88 
96 #define STK11XX_MAX_IMAGES 10
97 #define STK11XX_FRAME_SIZE (1280 * 1024 * 4)
98 
99 
100 
101 
102 
103 
104 
111 #define DRIVER_SUPPORT "Syntek USB Camera : STK-1135"
112 
133 #ifndef CONFIG_STK11XX_DEBUG
134 #define CONFIG_STK11XX_DEBUG 0
135 #endif
136 
137 #if CONFIG_STK11XX_DEBUG
138 
139 #define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
140 #define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
141 #define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
142 #define STK_DEBUG(str, args...) printk(KERN_DEBUG PREFIX str, ##args)
143 
144 #else
145 
146 #define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
147 #define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
148 #define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
149 #define STK_DEBUG(str, args...) do { } while(0)
150 
151 #endif
152 
153 
162 #ifndef CONFIG_STK11XX_DEBUG_STREAM
163 #define CONFIG_STK11XX_DEBUG_STREAM 0
164 #endif
165 
166 #if CONFIG_STK11XX_DEBUG_STREAM
167 
168 #define STK_STREAM(str, args...) printk(KERN_DEBUG PREFIX str, ##args)
169 
170 #else
171 
172 #define STK_STREAM(str, args...) do { } while(0)
173 
174 #endif
175 
176 
177 
181 typedef enum {
182  SYNTEK_STK_M811 = 1,
183  SYNTEK_STK_A311 = 2,
184  SYNTEK_STK_A821 = 3,
185  SYNTEK_STK_6A31 = 4,
186  SYNTEK_STK_6A33 = 5,
187  SYNTEK_STK_6A51 = 6,
188  SYNTEK_STK_6A54 = 7,
189  SYNTEK_STK_6D51 = 8
191 
192 
196 typedef enum {
199  STK11XX_UXGA
201 
202 
206 typedef enum {
207  STK11XX_80x60,
208  STK11XX_128x96,
209  STK11XX_160x120,
210  STK11XX_213x160,
211  STK11XX_320x240,
212  STK11XX_640x480,
213  STK11XX_800x600,
214  STK11XX_1024x768,
215  STK11XX_1280x1024,
216  STK11XX_NBR_SIZES
218 
219 
223 typedef enum {
224  STK11XX_PALETTE_RGB24,
225  STK11XX_PALETTE_RGB32,
226  STK11XX_PALETTE_BGR24,
227  STK11XX_PALETTE_BGR32,
228  STK11XX_PALETTE_UYVY,
229  STK11XX_PALETTE_YUYV
231 
232 
237  void *data;
238  int length;
239  int read;
240  struct urb *urb;
241 };
242 
243 
248  int errors;
249  void *data;
250  volatile int filled;
251  struct stk11xx_frame_buf *next;
252 };
253 
254 
259  unsigned long offset;
261 };
262 
263 
268  int x;
269  int y;
270 };
271 
272 
277  int fps;
279  int contrast;
280  int whiteness;
281  int colour;
282  int depth;
283  int palette;
284  int hue;
285  int hflip;
286  int vflip;
288  // default values for the device. Above are *current* values
289  int default_brightness;
290  int default_contrast;
291  int default_colour;
292  int default_whiteness;
293  int default_hflip;
294  int default_vflip;
295 };
296 
297 
301 struct usb_stk11xx {
302  struct video_device *vdev;
303  struct usb_device *udev;
304  struct usb_interface *interface;
306  int release;
310  unsigned char *int_in_buffer;
311  size_t int_in_size;
314  size_t isoc_in_size;
317  int watchdog;
319  struct stk11xx_video vsettings;
321  int error_status;
322 
323  int vopen;
329  spinlock_t spinlock;
330  struct semaphore mutex;
331  wait_queue_head_t wait_frame;
332  struct mutex modlock;
335  // 1: isoc
336  char isoc_init_ok;
337  struct stk11xx_iso_buf isobuf[MAX_ISO_BUFS];
338 
339  // 2: frame
340  int frame_size;
341  struct stk11xx_frame_buf *framebuf;
342  struct stk11xx_frame_buf *empty_frames, *empty_frames_tail;
343  struct stk11xx_frame_buf *full_frames, *full_frames_tail;
344  struct stk11xx_frame_buf *fill_frame;
345  struct stk11xx_frame_buf *read_frame;
346 
347  // 3: image
348  int view_size;
349  int image_size;
350  void *image_data;
351  struct stk11xx_image_buf images[STK11XX_MAX_IMAGES];
352  int image_used[STK11XX_MAX_IMAGES];
353  unsigned int nbuffers;
354  unsigned int len_per_image;
355  int image_read_pos;
356  int fill_image;
357  int resolution;
358  struct stk11xx_coord view;
359  struct stk11xx_coord image;
360 };
361 
362 
367 #define STK11XX_PERCENT(x,y) ( ((int)x * (int)y) / 100)
368 
369 
374 #define to_stk11xx_dev(d) container_of(d, struct usb_stk11xx, kref)
375 
376 
377 extern const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES];
378 
379 
380 int usb_stk11xx_write_registry(struct usb_stk11xx *, __u16, __u16);
381 int usb_stk11xx_read_registry(struct usb_stk11xx *, __u16, int *);
382 int usb_stk11xx_set_feature(struct usb_stk11xx *, int);
384 int usb_stk11xx_isoc_init(struct usb_stk11xx *);
385 void usb_stk11xx_isoc_handler(struct urb *);
387 
391 int dev_stk11xx_check_device(struct usb_stk11xx *, int);
392 int dev_stk11xx_camera_on(struct usb_stk11xx *);
393 int dev_stk11xx_camera_off(struct usb_stk11xx *);
401 
402 int v4l_stk11xx_select_video_mode(struct usb_stk11xx *, int, int);
405 
406 int stk11xx_create_sysfs_files(struct video_device *);
407 void stk11xx_remove_sysfs_files(struct video_device *);
408 
410 int stk11xx_reset_buffers(struct usb_stk11xx *);
411 int stk11xx_clear_buffers(struct usb_stk11xx *);
412 int stk11xx_free_buffers(struct usb_stk11xx *);
413 void stk11xx_next_image(struct usb_stk11xx *);
414 int stk11xx_next_frame(struct usb_stk11xx *);
415 int stk11xx_handle_frame(struct usb_stk11xx *);
416 
417 int stk11xx_decompress(struct usb_stk11xx *);
418 
419 
420 #endif
stk11xx_reset_buffers
int stk11xx_reset_buffers(struct usb_stk11xx *)
Reset all ISOC buffers.
Definition: stk11xx-buf.c:221
usb_stk11xx::udev
struct usb_device * udev
Definition: stk11xx.h:303
usb_stk11xx::vframes_dumped
int vframes_dumped
Definition: stk11xx.h:326
stk11xx_video::hue
int hue
Definition: stk11xx.h:284
stk11xx_video::hflip
int hflip
Definition: stk11xx.h:285
stk11xx_image_buf
Definition: stk11xx.h:258
usb_stk11xx::int_in_buffer
unsigned char * int_in_buffer
Definition: stk11xx.h:310
v4l_stk11xx_unregister_video_device
int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *)
Unregister the video device.
Definition: stk11xx-v4l.c:1486
stk11xx_video::brightness
int brightness
Definition: stk11xx.h:278
dev_stk11xx_camera_settings
int dev_stk11xx_camera_settings(struct usb_stk11xx *)
This function permits to modify the settings of the camera.
Definition: stk11xx-dev.c:342
stk11xx_coord
Definition: stk11xx.h:267
stk11xx_coord::x
int x
Definition: stk11xx.h:268
T_STK11XX_PALETTE
T_STK11XX_PALETTE
Definition: stk11xx.h:223
usb_stk11xx::int_in_endpointAddr
__u8 int_in_endpointAddr
Definition: stk11xx.h:312
usb_stk11xx::int_in_size
size_t int_in_size
Definition: stk11xx.h:311
v4l_stk11xx_select_video_mode
int v4l_stk11xx_select_video_mode(struct usb_stk11xx *, int, int)
Select a video mode.
Definition: stk11xx-v4l.c:146
usb_stk11xx_read_registry
int usb_stk11xx_read_registry(struct usb_stk11xx *, __u16, int *)
Read a 16-bits value from a 16-bits register.
Definition: stk11xx-usb.c:572
T_STK11XX_VIDEOMODE
T_STK11XX_VIDEOMODE
Definition: stk11xx.h:196
dev_stk11xx_watchdog_camera
int dev_stk11xx_watchdog_camera(struct usb_stk11xx *)
A espece of software watchdog.
Definition: stk11xx-dev.c:218
stk11xx_next_image
void stk11xx_next_image(struct usb_stk11xx *)
Prepare the next image.
Definition: stk11xx-buf.c:334
stk11xx_frame_buf
Definition: stk11xx.h:247
stk11xx_video::colour
int colour
Definition: stk11xx.h:281
stk11xx_iso_buf
Definition: stk11xx.h:236
dev_stk11xx_set_camera_fps
int dev_stk11xx_set_camera_fps(struct usb_stk11xx *)
This function permits to modify the fps of the camera.
Definition: stk11xx-dev.c:449
stk11xx_free_buffers
int stk11xx_free_buffers(struct usb_stk11xx *)
Release all buffers.
Definition: stk11xx-buf.c:287
usb_stk11xx_set_configuration
int usb_stk11xx_set_configuration(struct usb_stk11xx *)
Send the message SET_CONFIGURATION.
Definition: stk11xx-usb.c:506
STK11XX_MAX_IMAGES
#define STK11XX_MAX_IMAGES
Definition: stk11xx.h:96
usb_stk11xx::watchdog
int watchdog
Definition: stk11xx.h:317
usb_stk11xx::webcam_type
int webcam_type
Definition: stk11xx.h:308
usb_stk11xx::release
int release
Definition: stk11xx.h:306
dev_stk11xx_camera_on
int dev_stk11xx_camera_on(struct usb_stk11xx *)
This function switchs on the camera.
Definition: stk11xx-dev.c:241
stk11xx_next_frame
int stk11xx_next_frame(struct usb_stk11xx *)
Prepare the next frame.
Definition: stk11xx-buf.c:352
usb_stk11xx::mutex
struct semaphore mutex
Definition: stk11xx.h:330
stk11xx_video::vflip
int vflip
Definition: stk11xx.h:286
usb_stk11xx::interface
struct usb_interface * interface
Definition: stk11xx.h:304
usb_stk11xx_isoc_handler
void usb_stk11xx_isoc_handler(struct urb *)
ISOC handler.
Definition: stk11xx-usb.c:243
STK11XX_VGA
@ STK11XX_VGA
Definition: stk11xx.h:197
stk11xx_create_sysfs_files
int stk11xx_create_sysfs_files(struct video_device *)
Create the 'sys' entries.
Definition: stk11xx-sysfs.c:502
stk11xx_clear_buffers
int stk11xx_clear_buffers(struct usb_stk11xx *)
Clear current buffers.
Definition: stk11xx-buf.c:270
stk11xx_image_buf::offset
unsigned long offset
Definition: stk11xx.h:259
usb_stk11xx::webcam_model
int webcam_model
Definition: stk11xx.h:307
usb_stk11xx_isoc_cleanup
void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *)
Clean-up all the ISOC buffers.
Definition: stk11xx-usb.c:431
usb_stk11xx::isoc_in_size
size_t isoc_in_size
Definition: stk11xx.h:314
usb_stk11xx::isoc_in_endpointAddr
__u8 isoc_in_endpointAddr
Definition: stk11xx.h:315
stk11xx_remove_sysfs_files
void stk11xx_remove_sysfs_files(struct video_device *)
Remove the 'sys' entries.
Definition: stk11xx-sysfs.c:530
usb_stk11xx::vdev
struct video_device * vdev
Definition: stk11xx.h:302
dev_stk11xx_reconf_camera
int dev_stk11xx_reconf_camera(struct usb_stk11xx *)
Reconfigure the camera before the stream.
Definition: stk11xx-dev.c:552
stk11xx_video::palette
int palette
Definition: stk11xx.h:283
usb_stk11xx_write_registry
int usb_stk11xx_write_registry(struct usb_stk11xx *, __u16, __u16)
Write a 16-bits value to a 16-bits register.
Definition: stk11xx-usb.c:540
dev_stk11xx_set_camera_quality
int dev_stk11xx_set_camera_quality(struct usb_stk11xx *)
This function permits to modify the quality video of the camera.
Definition: stk11xx-dev.c:397
dev_stk11xx_camera_off
int dev_stk11xx_camera_off(struct usb_stk11xx *)
This function switchs off the camera.
Definition: stk11xx-dev.c:264
STK11XX_SXGA
@ STK11XX_SXGA
Definition: stk11xx.h:198
usb_stk11xx::vopen
int vopen
Definition: stk11xx.h:323
dev_stk11xx_camera_asleep
int dev_stk11xx_camera_asleep(struct usb_stk11xx *)
Wake-up the camera.
Definition: stk11xx-dev.c:287
usb_stk11xx::vframes_error
int vframes_error
Definition: stk11xx.h:325
stk11xx_video::depth
int depth
Definition: stk11xx.h:282
dev_stk11xx_stop_stream
int dev_stk11xx_stop_stream(struct usb_stk11xx *)
This function sets the device to stop the stream.
Definition: stk11xx-dev.c:604
stk11xx_decompress
int stk11xx_decompress(struct usb_stk11xx *)
Decompress a frame.
Definition: stk11xx-bayer.c:155
stk11xx_video::fps
int fps
Definition: stk11xx.h:277
usb_stk11xx::wait_frame
wait_queue_head_t wait_frame
Definition: stk11xx.h:331
dev_stk11xx_check_device
int dev_stk11xx_check_device(struct usb_stk11xx *, int)
This function permits to check the device in reading the register 0x0201.
Definition: stk11xx-dev.c:170
usb_stk11xx_isoc_init
int usb_stk11xx_isoc_init(struct usb_stk11xx *)
Initilize an isochronous pipe.
Definition: stk11xx-usb.c:124
stk11xx_image_sizes
const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES]
Definition: stk11xx-v4l.c:59
stk11xx_handle_frame
int stk11xx_handle_frame(struct usb_stk11xx *)
Handler frame.
Definition: stk11xx-buf.c:407
T_SYNTEK_DEVICE
T_SYNTEK_DEVICE
Definition: stk11xx.h:181
T_STK11XX_RESOLUTION
T_STK11XX_RESOLUTION
Definition: stk11xx.h:206
stk11xx_video
Definition: stk11xx.h:276
stk11xx_allocate_buffers
int stk11xx_allocate_buffers(struct usb_stk11xx *)
Allocate all ISOC buffers.
Definition: stk11xx-buf.c:128
stk11xx_video::contrast
int contrast
Definition: stk11xx.h:279
v4l_stk11xx_register_video_device
int v4l_stk11xx_register_video_device(struct usb_stk11xx *)
Register the video device.
Definition: stk11xx-v4l.c:1453
usb_stk11xx
Definition: stk11xx.h:301
usb_stk11xx::vsettings
struct stk11xx_video vsettings
Definition: stk11xx.h:319
usb_stk11xx::visoc_errors
int visoc_errors
Definition: stk11xx.h:324
STK11XX_UXGA
@ STK11XX_UXGA
Definition: stk11xx.h:199
stk11xx_video::whiteness
int whiteness
Definition: stk11xx.h:280
stk11xx_coord::y
int y
Definition: stk11xx.h:269
usb_stk11xx::spinlock
spinlock_t spinlock
Definition: stk11xx.h:329
usb_stk11xx_set_feature
int usb_stk11xx_set_feature(struct usb_stk11xx *, int)
Send the message SET_FEATURE and choose the interface.
Definition: stk11xx-usb.c:474
usb_stk11xx::modlock
struct mutex modlock
Definition: stk11xx.h:332
dev_stk11xx_start_stream
int dev_stk11xx_start_stream(struct usb_stk11xx *)
This function sets the device to start the stream.
Definition: stk11xx-dev.c:501
stk11xx_image_buf::vma_use_count
int vma_use_count
Definition: stk11xx.h:260
dev_stk11xx_initialize_device
int dev_stk11xx_initialize_device(struct usb_stk11xx *)
This function permits to initialize the device.
Definition: stk11xx-dev.c:63
MAX_ISO_BUFS
#define MAX_ISO_BUFS
Definition: stk11xx.h:83
dev_stk11xx_init_camera
int dev_stk11xx_init_camera(struct usb_stk11xx *)
This function initializes the device for the stream.
Definition: stk11xx-dev.c:115