Syntek USB Video Camera
stk11xx.h
Go to the documentation of this file.
1
34#ifndef STK11XX_H
35#define STK11XX_H
36
37#define DRIVER_NAME "stk11xx"
38#define DRIVER_VERSION "v3.0.0"
39#define DRIVER_VERSION_NUM 0x030000
40#define DRIVER_YEAR 2012
41#define DRIVER_DESC "Syntek USB Video Camera"
42#define DRIVER_AUTHOR "Nicolas VIVIEN"
43#define PREFIX DRIVER_NAME ": "
44#define DRIVER_URL \
45 "http://sourceforge.net/projects/syntekdriver/"
47#define USB_SYNTEK1_VENDOR_ID 0x174f
48#define USB_SYNTEK2_VENDOR_ID 0x05e1
50#define USB_STK_A311_PRODUCT_ID 0xa311
51#define USB_STK_A821_PRODUCT_ID 0xa821
52#define USB_STK_AA11_PRODUCT_ID 0xaa11
53#define USB_STK_6A31_PRODUCT_ID 0x6a31
54#define USB_STK_6A33_PRODUCT_ID 0x6a33
55#define USB_STK_6A51_PRODUCT_ID 0x6a51
56#define USB_STK_6A54_PRODUCT_ID 0x6a54
57#define USB_STK_6D51_PRODUCT_ID 0x6d51
59#define USB_STK_0408_PRODUCT_ID 0x0408
60#define USB_STK_0500_PRODUCT_ID 0x0500
61#define USB_STK_0501_PRODUCT_ID 0x0501
70#define VID_HARDWARE_STK11XX 88
71
72
73
74
88#define MAX_ISO_BUFS 16
89#define ISO_FRAMES_PER_DESC 10
90#define ISO_MAX_FRAME_SIZE 3 * 1024
91#define ISO_BUFFER_SIZE (ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
92
93
105#define STK11XX_MAX_IMAGES 10
106#define STK11XX_FRAME_SIZE (1280 * 1024 * 4)
107
108
109
110
111
112
113
120#define DRIVER_SUPPORT "Syntek USB Camera : STK-1135"
121
142#ifndef CONFIG_STK11XX_DEBUG
143#define CONFIG_STK11XX_DEBUG 0
144#endif
145
146#if CONFIG_STK11XX_DEBUG
147
148#define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
149#define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
150#define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
151#define STK_DEBUG(str, args...) printk(KERN_DEBUG PREFIX str, ##args)
152
153#else
154
155#define STK_INFO(str, args...) printk(KERN_INFO PREFIX str, ##args)
156#define STK_ERROR(str, args...) printk(KERN_ERR PREFIX str, ##args)
157#define STK_WARNING(str, args...) printk(KERN_WARNING PREFIX str, ##args)
158#define STK_DEBUG(str, args...) do { } while(0)
159
160#endif
161
162
171#ifndef CONFIG_STK11XX_DEBUG_STREAM
172#define CONFIG_STK11XX_DEBUG_STREAM 0
173#endif
174
175#if CONFIG_STK11XX_DEBUG_STREAM
176
177#define STK_STREAM(str, args...) printk(KERN_DEBUG PREFIX str, ##args)
178
179#else
180
181#define STK_STREAM(str, args...) do { } while(0)
182
183#endif
184
185
186
190typedef enum {
191 SYNTEK_STK_M811 = 1,
192 SYNTEK_STK_A311 = 2,
193 SYNTEK_STK_A821 = 3,
194 SYNTEK_STK_6A31 = 4,
195 SYNTEK_STK_6A33 = 5,
196 SYNTEK_STK_6A51 = 6,
197 SYNTEK_STK_6A54 = 7,
198 SYNTEK_STK_6D51 = 8,
199 SYNTEK_STK_0500 = 9,
200 SYNTEK_STK_0408 = 10,
201 SYNTEK_STK_AA11 = 11,
203
204
214
215
219typedef enum {
220 STK11XX_80x60,
221 STK11XX_128x96,
222 STK11XX_160x120,
223 STK11XX_213x160,
224 STK11XX_320x240,
225 STK11XX_640x480,
226 STK11XX_720x576,
227 STK11XX_800x600,
228 STK11XX_1024x768,
229 STK11XX_1280x1024,
230 STK11XX_NBR_SIZES
232
233
237typedef enum {
238 STK11XX_PALETTE_RGB24,
239 STK11XX_PALETTE_RGB32,
240 STK11XX_PALETTE_BGR24,
241 STK11XX_PALETTE_BGR32,
242 STK11XX_PALETTE_UYVY,
243 STK11XX_PALETTE_YUYV
245
246
251 void *data;
252 int length;
253 int read;
254 struct urb *urb;
255};
256
257
262 int errors;
263 void *data;
264 volatile bool odd;
265 volatile int filled;
266 struct stk11xx_frame_buf *next;
267};
268
269
274 unsigned long offset;
276};
277
278
283 int x;
284 int y;
285};
286
287
292 int fps;
296 int colour;
297 int depth;
299 int hue;
300 int hflip;
301 int vflip;
302 int input;
303 int norm;
305 // default values for the device. Above are *current* values
306 int default_brightness;
307 int default_contrast;
308 int default_colour;
309 int default_whiteness;
310 int default_hflip;
311 int default_vflip;
312};
313
314
320 struct usb_device *udev;
327 unsigned char *int_in_buffer;
328 size_t int_in_size;
338 int error_status;
339
340 int vopen;
344 int vsync;
351 struct mutex modlock;
354 // 1: isoc
355 char isoc_init_ok;
356 struct stk11xx_iso_buf isobuf[MAX_ISO_BUFS];
357
358 // 2: frame
359 int frame_size;
360 struct stk11xx_frame_buf *framebuf;
361 struct stk11xx_frame_buf *empty_frames, *empty_frames_tail;
362 struct stk11xx_frame_buf *full_frames, *full_frames_tail;
363 struct stk11xx_frame_buf *fill_frame;
364 struct stk11xx_frame_buf *read_frame;
365
366 // 3: image
367 int view_size;
368 int image_size;
369 void *image_data;
371 int image_used[STK11XX_MAX_IMAGES];
372 unsigned int nbuffers;
373 unsigned int len_per_image;
374 int image_read_pos;
375 int fill_image;
376 int resolution;
377 struct stk11xx_coord view;
378 struct stk11xx_coord image;
379};
380
381
386#define STK11XX_PERCENT(x,y) ( ((int)x * (int)y) / 100)
387
388
393#define to_stk11xx_dev(d) container_of(d, struct usb_stk11xx, kref)
394
395
396extern const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES];
397
398
400int usb_stk11xx_read_registry(struct usb_stk11xx *, __u16, int *);
401int usb_stk11xx_set_feature(struct usb_stk11xx *, int);
404void usb_stk11xx_isoc_handler(struct urb *);
406
411int dev_stk11xx_check_device(struct usb_stk11xx *, int);
421
422int v4l_stk11xx_select_video_mode(struct usb_stk11xx *, int, int);
425
428
433void stk11xx_next_image(struct usb_stk11xx *);
434int stk11xx_next_frame(struct usb_stk11xx *);
436
437int stk11xx_decompress(struct usb_stk11xx *);
438
439
440#endif
static int fps
int usb_stk11xx_isoc_init(struct usb_stk11xx *)
Initilize an isochronous pipe.
T_STK11XX_PALETTE
Definition stk11xx.h:237
int dev_stk11xx_stop_stream(struct usb_stk11xx *)
This function sets the device to stop the stream.
T_STK11XX_RESOLUTION
Definition stk11xx.h:219
int dev_stk11xx_check_device(struct usb_stk11xx *, int)
This function permits to check the device in reading the register 0x0201.
int dev_stk11xx_decompress(struct usb_stk11xx *)
Decompress/convert a frame from the video stream.
int dev_stk11xx_set_camera_fps(struct usb_stk11xx *)
This function permits to modify the fps of the camera.
int dev_stk11xx_camera_asleep(struct usb_stk11xx *)
Wake-up the camera.
int dev_stk11xx_initialize_device(struct usb_stk11xx *)
This function permits to initialize the device.
Definition stk11xx-dev.c:63
int stk11xx_next_frame(struct usb_stk11xx *)
Prepare the next frame.
int stk11xx_clear_buffers(struct usb_stk11xx *)
Clear current buffers.
int dev_stk11xx_start_stream(struct usb_stk11xx *)
This function sets the device to start the stream.
int dev_stk11xx_reconf_camera(struct usb_stk11xx *)
Reconfigure the camera before the stream.
T_STK11XX_VIDEOMODE
Definition stk11xx.h:208
@ STK11XX_SXGA
Definition stk11xx.h:210
@ STK11XX_VGA
Definition stk11xx.h:209
@ STK11XX_UXGA
Definition stk11xx.h:212
@ STK11XX_PAL
Definition stk11xx.h:211
int stk11xx_handle_frame(struct usb_stk11xx *)
Handler frame.
int stk11xx_free_buffers(struct usb_stk11xx *)
Release all buffers.
int dev_stk11xx_camera_off(struct usb_stk11xx *)
This function switchs off the camera.
int stk11xx_create_sysfs_files(struct video_device *)
Create the 'sys' entries.
int dev_stk11xx_set_camera_quality(struct usb_stk11xx *)
This function permits to modify the quality video of the camera.
int stk11xx_allocate_buffers(struct usb_stk11xx *)
Allocate all ISOC buffers.
int dev_stk11xx_watchdog_camera(struct usb_stk11xx *)
A espece of software watchdog.
int v4l_stk11xx_unregister_video_device(struct usb_stk11xx *)
Unregister the video device.
void usb_stk11xx_isoc_cleanup(struct usb_stk11xx *)
Clean-up all the ISOC buffers.
const struct stk11xx_coord stk11xx_image_sizes[STK11XX_NBR_SIZES]
Definition stk11xx-v4l.c:59
T_SYNTEK_DEVICE
Definition stk11xx.h:190
int dev_stk11xx_camera_on(struct usb_stk11xx *)
This function switchs on the camera.
int usb_stk11xx_set_feature(struct usb_stk11xx *, int)
Send the message SET_FEATURE and choose the interface.
#define MAX_ISO_BUFS
Definition stk11xx.h:88
#define STK11XX_MAX_IMAGES
Definition stk11xx.h:105
void usb_stk11xx_isoc_handler(struct urb *)
ISOC handler.
int usb_stk11xx_write_registry(struct usb_stk11xx *, __u16, __u16)
Write a 16-bits value to a 16-bits register.
int dev_stk11xx_camera_settings(struct usb_stk11xx *)
This function permits to modify the settings of the camera.
void stk11xx_remove_sysfs_files(struct video_device *)
Remove the 'sys' entries.
int stk11xx_reset_buffers(struct usb_stk11xx *)
Reset all ISOC buffers.
int usb_stk11xx_set_configuration(struct usb_stk11xx *)
Send the message SET_CONFIGURATION.
void stk11xx_next_image(struct usb_stk11xx *)
Prepare the next image.
int usb_stk11xx_read_registry(struct usb_stk11xx *, __u16, int *)
Read a 16-bits value from a 16-bits register.
int v4l_stk11xx_register_video_device(struct usb_stk11xx *)
Register the video device.
int stk11xx_decompress(struct usb_stk11xx *)
Decompress a frame.
int v4l_stk11xx_select_video_mode(struct usb_stk11xx *, int, int)
Select a video mode.
int dev_stk11xx_init_camera(struct usb_stk11xx *)
This function initializes the device for the stream.
unsigned long offset
Definition stk11xx.h:274
struct video_device * vdev
Definition stk11xx.h:319
struct stk11xx_video vsettings
Definition stk11xx.h:336
struct usb_interface * interface
Definition stk11xx.h:321
int vframes_error
Definition stk11xx.h:342
size_t int_in_size
Definition stk11xx.h:328
int visoc_errors
Definition stk11xx.h:341
spinlock_t spinlock
Definition stk11xx.h:348
int webcam_type
Definition stk11xx.h:325
struct semaphore mutex
Definition stk11xx.h:349
int release
Definition stk11xx.h:323
int v1st_cap
Definition stk11xx.h:345
__u8 isoc_in_endpointAddr
Definition stk11xx.h:332
__u8 int_in_endpointAddr
Definition stk11xx.h:329
size_t isoc_in_size
Definition stk11xx.h:331
int watchdog
Definition stk11xx.h:334
struct mutex modlock
Definition stk11xx.h:351
int webcam_model
Definition stk11xx.h:324
struct usb_device * udev
Definition stk11xx.h:320
wait_queue_head_t wait_frame
Definition stk11xx.h:350
unsigned char * int_in_buffer
Definition stk11xx.h:327
int vframes_dumped
Definition stk11xx.h:343