SyntekUSBVideoCamera
stk11xx-dev-6a54.c
Go to the documentation of this file.
1 
34 #include <linux/module.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/version.h>
38 #include <linux/errno.h>
39 #include <linux/slab.h>
40 #include <linux/kref.h>
41 
42 #include <linux/usb.h>
43 #include <media/v4l2-common.h>
44 #include <media/v4l2-ioctl.h>
45 
46 #include "stk11xx.h"
47 #include "stk11xx-dev.h"
48 
49 
50 //=============================================================================
51 //
52 // STK-6A54 API
53 //
54 //=============================================================================
55 
56 
71 {
72  int retok;
73  int value;
74 
75  STK_INFO("Initialize USB2.0 Syntek Camera\n");
76 
77  usb_stk11xx_write_registry(dev, 0x0000, 0x00e0);
78  usb_stk11xx_write_registry(dev, 0x0002, 0x00f8);
79  usb_stk11xx_write_registry(dev, 0x0002, 0x0078);
80  usb_stk11xx_write_registry(dev, 0x0000, 0x0020);
81 
83  retok = dev_stk11xx_check_device(dev, 65);
84  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
85  usb_stk11xx_read_registry(dev, 0x02ff, &value);
86  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
87  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
88  usb_stk11xx_write_registry(dev, 0x0208, 0x000a);
89  usb_stk11xx_write_registry(dev, 0x0200, 0x0020);
90  retok = dev_stk11xx_check_device(dev, 65);
91  usb_stk11xx_read_registry(dev, 0x0209, &value);
92  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
93  usb_stk11xx_read_registry(dev, 0x02ff, &value);
94  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
95  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
96  usb_stk11xx_write_registry(dev, 0x0208, 0x000b);
97  usb_stk11xx_write_registry(dev, 0x0200, 0x0020);
98  retok = dev_stk11xx_check_device(dev, 65);
99  usb_stk11xx_read_registry(dev, 0x0209, &value);
100  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
101  usb_stk11xx_read_registry(dev, 0x02ff, &value);
102  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
103  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
104  usb_stk11xx_write_registry(dev, 0x0208, 0x001c);
105  usb_stk11xx_write_registry(dev, 0x0200, 0x0020);
106  retok = dev_stk11xx_check_device(dev, 65);
107  usb_stk11xx_read_registry(dev, 0x0209, &value);
108  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
109  usb_stk11xx_read_registry(dev, 0x02ff, &value);
110  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
111  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
112  usb_stk11xx_write_registry(dev, 0x0208, 0x001d);
113  usb_stk11xx_write_registry(dev, 0x0200, 0x0020);
114  retok = dev_stk11xx_check_device(dev, 65);
115  usb_stk11xx_read_registry(dev, 0x0209, &value);
116  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
117  usb_stk11xx_write_registry(dev, 0x0000, 0x00e0);
118  usb_stk11xx_write_registry(dev, 0x0002, 0x00f8);
119  usb_stk11xx_write_registry(dev, 0x0002, 0x0078);
120  usb_stk11xx_write_registry(dev, 0x0000, 0x0020);
121  usb_stk11xx_write_registry(dev, 0x0100, 0x0021);
122  usb_stk11xx_read_registry(dev, 0x0000, &value);
123  usb_stk11xx_write_registry(dev, 0x0000, 0x004b);
124 
125 
127 
128  usb_stk11xx_set_feature(dev, 0);
129 
130  // Device is initialized and is ready !!!
131  STK_INFO("Syntek USB2.0 Camera is ready\n");
132 
133  return 0;
134 }
135 
136 
150 int dev_stk6a54_configure_device(struct usb_stk11xx *dev, int step)
151 {
152  int value;
153 
154  // 0, 1
155  static const int values_001B[] = {
156  0x0e, 0x0e
157  };
158  static const int values_001C[] = {
159  0x46, 0x46
160  };
161  static const int values_0202[] = {
162  0x1e, 0x1e
163  };
164  static const int values_0110[] = {
165  0x00, 0x00
166  };
167  static const int values_0112[] = {
168  0x00, 0x00
169  };
170  static const int values_0114[] = {
171  0x00, 0x00
172  };
173  static const int values_0115[] = {
174  0x00, 0x05
175  };
176  static const int values_0116[] = {
177  0x00, 0xe0
178  };
179  static const int values_0117[] = {
180  0x00, 0x01
181  };
182  static const int values_0100[] = {
183  0x21, 0x21
184  };
185 
186 
187  STK_DEBUG("dev_stk6a54_configure_device : %d\n", step);
188 
189  usb_stk11xx_write_registry(dev, 0x0000, 0x0024);
190  usb_stk11xx_write_registry(dev, 0x0002, 0x0078);
191  usb_stk11xx_write_registry(dev, 0x0003, 0x0080);
192  usb_stk11xx_write_registry(dev, 0x0005, 0x0000);
193 
194  usb_stk11xx_write_registry(dev, 0x0007, 0x0003);
195  usb_stk11xx_write_registry(dev, 0x000d, 0x0000);
196  usb_stk11xx_write_registry(dev, 0x000f, 0x0002);
197  usb_stk11xx_write_registry(dev, 0x0300, 0x0012);
198  usb_stk11xx_write_registry(dev, 0x0350, 0x0041);
199 
200  usb_stk11xx_write_registry(dev, 0x0351, 0x0000);
201  usb_stk11xx_write_registry(dev, 0x0352, 0x0000);
202  usb_stk11xx_write_registry(dev, 0x0353, 0x0000);
203  usb_stk11xx_write_registry(dev, 0x0018, 0x0010);
204  usb_stk11xx_write_registry(dev, 0x0019, 0x0000);
205 
206  usb_stk11xx_write_registry(dev, 0x001b, values_001B[step]);
207  usb_stk11xx_write_registry(dev, 0x001c, values_001C[step]);
208  usb_stk11xx_write_registry(dev, 0x0300, 0x0080);
209  usb_stk11xx_write_registry(dev, 0x001a, 0x0004);
210  usb_stk11xx_write_registry(dev, 0x0202, values_0202[step]);
211 
212  usb_stk11xx_write_registry(dev, 0x0110, values_0110[step]);
213  usb_stk11xx_write_registry(dev, 0x0111, 0x0000);
214  usb_stk11xx_write_registry(dev, 0x0112, values_0112[step]);
215  usb_stk11xx_write_registry(dev, 0x0113, 0x0000);
216  usb_stk11xx_write_registry(dev, 0x0114, values_0114[step]);
217 
218  usb_stk11xx_write_registry(dev, 0x0115, values_0115[step]);
219  usb_stk11xx_write_registry(dev, 0x0116, values_0116[step]);
220  usb_stk11xx_write_registry(dev, 0x0117, values_0117[step]);
221 
222  usb_stk11xx_read_registry(dev, 0x0100, &value);
223  usb_stk11xx_write_registry(dev, 0x0100, values_0100[step]);
224 
225  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
226 
227 
228  switch (step) {
229  case 0:
230  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
231 
232  usb_stk11xx_read_registry(dev, 0x02ff, &value);
233  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
234 
235  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
236 
237  usb_stk11xx_write_registry(dev, 0x0204, 0x00ff);
238  usb_stk11xx_write_registry(dev, 0x0205, 0x0001);
239 
240  usb_stk11xx_write_registry(dev, 0x0200, 0x0001);
241 
242  break;
243 
244  case 1:
245  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
246 
248 
249  usb_stk11xx_read_registry(dev, 0x0209, &value);
250  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
251 
252  break;
253  }
254 
255  return 0;
256 }
257 
258 
269 {
270  int value;
271 
272  usb_stk11xx_read_registry(dev, 0x0104, &value);
273  usb_stk11xx_read_registry(dev, 0x0105, &value);
274  usb_stk11xx_read_registry(dev, 0x0106, &value);
275 
276  usb_stk11xx_write_registry(dev, 0x0100, 0x0021);
277  usb_stk11xx_write_registry(dev, 0x0116, 0x0000);
278  usb_stk11xx_write_registry(dev, 0x0117, 0x0000);
279  usb_stk11xx_write_registry(dev, 0x0018, 0x0000);
280 
281  usb_stk11xx_read_registry(dev, 0x0000, &value);
282  usb_stk11xx_write_registry(dev, 0x0000, 0x0049);
283 
284  return 0;
285 }
286 
287 
299 {
300  return 0;
301 }
302 
303 
315 {
316  int i;
317  int retok;
318  int value;
319 
320  int asize;
321 
322  static const int values_204[] = {
323  0xff, 0x12, 0xff, 0x2c, 0x2e, 0xff, 0x3c, 0x11, 0x09, 0x04,
324  0x13, 0x14, 0x2c, 0x33, 0x3a, 0x3b, 0x3e, 0x43, 0x16, 0x39,
325  0x35, 0x22, 0x37, 0x23, 0x34, 0x36, 0x06, 0x07, 0x0d, 0x0e,
326  0x4c, 0x4a, 0x21, 0x24, 0x25, 0x26, 0x5c, 0x63, 0x46, 0x0c,
327  0x61, 0x62, 0x7c, 0x20, 0x28, 0x6c, 0x6d, 0x6e, 0x70, 0x71,
328  0x73, 0x3d, 0x5a, 0x4f, 0x50, 0xff, 0xe5, 0xf9, 0x41, 0xe0,
329  0x76, 0x33, 0x42, 0x43, 0x4c, 0x87, 0x88, 0xd7, 0xd9, 0xd3,
330  0xc8, 0xc9, 0x7c, 0x7d, 0x7c, 0x7d, 0x7d, 0x7c, 0x7d, 0x7d,
331  0x7d, 0x90, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91,
332  0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x92, 0x93,
333  0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93,
334  0x93, 0x93, 0x96, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97,
335  0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0xc3, 0xa4, 0xa8, 0xc5,
336  0xc6, 0xbf, 0xc7, 0xb6, 0xb8, 0xb7, 0xb9, 0xb3, 0xb4, 0xb5,
337  0xb0, 0xb1, 0xb2, 0xc4, 0xc0, 0xc1, 0x86, 0x50, 0x51, 0x52,
338  0x53, 0x54, 0x55, 0x57, 0x5a, 0x5b, 0x5c, 0xc3, 0x7f, 0xda,
339  0xd7, 0xe5, 0xe1, 0xe0, 0xdd, 0x05, 0xff, 0x12, 0x11, 0x17,
340  0x18, 0x19, 0x1a, 0x32, 0x37, 0x4f, 0x50, 0x5a, 0x6d, 0x3d,
341  0x39, 0x35, 0x22, 0x37, 0x23, 0x34, 0x36, 0x06, 0x07, 0x0d,
342  0x0e, 0x4c, 0xff, 0xe0, 0xc0, 0xc1, 0x8c, 0x86, 0x50, 0x51,
343  0x52, 0x53, 0x54, 0x55, 0x5a, 0x5b, 0x5c, 0xd3, 0xe0, 0xff,
344  0xe0, 0xc0, 0xc1, 0x8c, 0x86, 0x50, 0x51, 0x52, 0x53, 0x54,
345  0x55, 0x5a, 0x5b, 0x5c, 0xd3, 0xe0, 0xff, 0xff, 0x04, 0xff,
346  0xff, 0xff, 0x7c, 0x7d, 0x7c, 0x7c, 0x7d, 0x7c, 0x7d, 0x7c,
347  0xff, 0x7c, 0x7d, 0x7c, 0x7d, 0x7c, 0xff, 0x7c, 0x7d, 0x7c,
348  0x7d, 0x7c, 0x7d, 0x7c, 0x7c, 0xff, 0x7c, 0x7d, 0x7c, 0x7d,
349  0x7c, 0x7d, 0xff, 0x92, 0x93, 0xff, 0x90, 0x91, 0x91, 0x91,
350  0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91,
351  0x91, 0x91, 0x91, 0xff, 0xc3, 0xc7, 0xce, 0xcc, 0xcd, 0xff,
352  0x04, 0xff, 0x04
353  };
354 
355  static const int values_205[] = {
356  0x01, 0x80, 0x00, 0xff, 0xdf, 0x01, 0x32, 0x00, 0x02, 0x28,
357  0xe5, 0x48, 0x0c, 0x78, 0x33, 0xfb, 0x00, 0x11, 0x10, 0x02,
358  0x88, 0x0a, 0x40, 0x00, 0xa0, 0x1a, 0x02, 0xc0, 0xb7, 0x01,
359  0x00, 0x81, 0x99, 0x40, 0x38, 0x82, 0x00, 0x00, 0x3f, 0x3c,
360  0x70, 0x80, 0x05, 0x80, 0x30, 0x00, 0x80, 0x00, 0x02, 0x94,
361  0xc1, 0x34, 0x57, 0xbb, 0x9c, 0x00, 0x7f, 0xc0, 0x24, 0x14,
362  0xff, 0xa0, 0x20, 0x18, 0x00, 0xd0, 0x3f, 0x03, 0x10, 0x82,
363  0x08, 0x80, 0x00, 0x00, 0x03, 0x48, 0x48, 0x08, 0x20, 0x10,
364  0x0e, 0x00, 0x0e, 0x1a, 0x31, 0x5a, 0x69, 0x75, 0x7e, 0x88,
365  0x8f, 0x96, 0xa3, 0xaf, 0xc4, 0xd7, 0xe8, 0x20, 0x00, 0x06,
366  0xe3, 0x05, 0x05, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
367  0x00, 0x00, 0x00, 0x08, 0x19, 0x02, 0x0c, 0x24, 0x30, 0x28,
368  0x26, 0x02, 0x98, 0x80, 0x00, 0x00, 0xed, 0x00, 0x00, 0x11,
369  0x51, 0x80, 0x10, 0x66, 0xa5, 0x64, 0x7c, 0xaf, 0x97, 0xff,
370  0xc5, 0x94, 0x0f, 0x5c, 0xc8, 0x96, 0x3d, 0x00, 0x90, 0x18,
371  0x00, 0x00, 0x88, 0x00, 0x90, 0x18, 0x05, 0xed, 0x00, 0x00,
372  0x01, 0x1f, 0x67, 0x00, 0xff, 0x00, 0x01, 0x40, 0x00, 0x11,
373  0x43, 0x00, 0x4b, 0x09, 0xc0, 0xca, 0xa8, 0x23, 0x00, 0x38,
374  0x12, 0xda, 0x1a, 0xc3, 0x00, 0xc0, 0x1a, 0x88, 0xc0, 0x87,
375  0x41, 0x00, 0x00, 0x04, 0x64, 0x4b, 0x00, 0x1d, 0x00, 0xc8,
376  0x96, 0x00, 0x00, 0x00, 0xc8, 0x96, 0x00, 0x82, 0x00, 0x00,
377  0x04, 0x64, 0x4b, 0x00, 0x3d, 0x00, 0xc8, 0x96, 0x00, 0x00,
378  0x00, 0xa0, 0x78, 0x00, 0x82, 0x00, 0x00, 0x01, 0xfa, 0x01,
379  0x00, 0x00, 0x00, 0x04, 0x0a, 0x09, 0x16, 0x0a, 0x06, 0x09,
380  0x00, 0x00, 0x04, 0x08, 0x28, 0x08, 0x00, 0x00, 0x05, 0x01,
381  0x7f, 0x02, 0x00, 0x0a, 0x05, 0x00, 0x00, 0x07, 0x03, 0x4d,
382  0x04, 0x4d, 0x00, 0x01, 0xc5, 0x00, 0x00, 0x00, 0x23, 0x3c,
383  0x50, 0x63, 0x73, 0x83, 0x92, 0xa0, 0xad, 0xba, 0xc6, 0xd2,
384  0xde, 0xe9, 0xf5, 0x01, 0x0c, 0x00, 0x80, 0x80, 0x80, 0x01,
385  0xfa, 0x01, 0xfa
386  };
387 
388  asize = ARRAY_SIZE(values_204);
389 
390  for(i=0; i<asize; i++) {
391  usb_stk11xx_read_registry(dev, 0x02ff, &value);
392  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
393 
394  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
395 
396  usb_stk11xx_write_registry(dev, 0x0204, values_204[i]);
397  usb_stk11xx_write_registry(dev, 0x0205, values_205[i]);
398  usb_stk11xx_write_registry(dev, 0x0200, 0x0001);
399 
400  retok = dev_stk11xx_check_device(dev, 500);
401 
402  if (retok != 1) {
403  STK_ERROR("Load default sensor settings fail !\n");
404  return -1;
405  }
406 
407  usb_stk11xx_write_registry(dev, 0x02ff, 0x0000);
408  }
409 
410  usb_stk11xx_read_registry(dev, 0x02ff, &value);
411 
412  usb_stk11xx_write_registry(dev, 0x0203, 0x0060);
413 
414  usb_stk11xx_write_registry(dev, 0x0208, 0x0004);
415 
416  usb_stk11xx_write_registry(dev, 0x0200, 0x0020);
417 
418  retok = dev_stk11xx_check_device(dev, 500);
419 
420  return 0;
421 }
422 
423 
438 {
439  return 0;
440 }
441 
442 
457 {
458  return 0;
459 }
460 
461 
472 {
473  return 0;
474 }
475 
476 
488 {
489  return 0;
490 }
491 
492 
503 {
505 
506  return 0;
507 }
508 
509 
521 {
522  return 0;
523 }
524 
525 
dev_stk6a54_configure_device
int dev_stk6a54_configure_device(struct usb_stk11xx *dev, int step)
This function permits to configure the device.
Definition: stk11xx-dev-6a54.c:150
dev_stk6a54_set_camera_quality
int dev_stk6a54_set_camera_quality(struct usb_stk11xx *dev)
This function permits to modify the settings of the camera.
Definition: stk11xx-dev-6a54.c:456
dev_stk6a54_init_camera
int dev_stk6a54_init_camera(struct usb_stk11xx *dev)
This function initializes the device for the stream.
Definition: stk11xx-dev-6a54.c:298
stk11xx.h
Driver for Syntek USB video camera.
dev_stk6a54_start_stream
int dev_stk6a54_start_stream(struct usb_stk11xx *dev)
This function sets the device to start the stream.
Definition: stk11xx-dev-6a54.c:487
STK_DEBUG
#define STK_DEBUG(str, args...)
Definition: stk11xx.h:149
dev_stk6a54_initialize_device
int dev_stk6a54_initialize_device(struct usb_stk11xx *dev)
This function permits to initialize the device.
Definition: stk11xx-dev-6a54.c:70
dev_stk6a54_camera_settings
int dev_stk6a54_camera_settings(struct usb_stk11xx *dev)
This function permits to modify the settings of the camera.
Definition: stk11xx-dev-6a54.c:437
STK_ERROR
#define STK_ERROR(str, args...)
Definition: stk11xx.h:147
dev_stk11xx_camera_settings
int dev_stk11xx_camera_settings(struct usb_stk11xx *dev)
This function permits to modify the settings of the camera.
Definition: stk11xx-dev.c:342
usb_stk11xx_set_feature
int usb_stk11xx_set_feature(struct usb_stk11xx *dev, int index)
Send the message SET_FEATURE and choose the interface.
Definition: stk11xx-usb.c:474
usb_stk11xx_write_registry
int usb_stk11xx_write_registry(struct usb_stk11xx *dev, __u16 index, __u16 value)
Write a 16-bits value to a 16-bits register.
Definition: stk11xx-usb.c:540
dev_stk6a54_set_camera_fps
int dev_stk6a54_set_camera_fps(struct usb_stk11xx *dev)
This function permits to modify the settings of the camera.
Definition: stk11xx-dev-6a54.c:471
usb_stk11xx_read_registry
int usb_stk11xx_read_registry(struct usb_stk11xx *dev, __u16 index, int *value)
Read a 16-bits value from a 16-bits register.
Definition: stk11xx-usb.c:572
dev_stk6a54_reconf_camera
int dev_stk6a54_reconf_camera(struct usb_stk11xx *dev)
Reconfigure the camera before the stream.
Definition: stk11xx-dev-6a54.c:502
dev_stk6a54_sensor_settings
int dev_stk6a54_sensor_settings(struct usb_stk11xx *dev)
This function permits to set default sensor settings.
Definition: stk11xx-dev-6a54.c:314
STK_INFO
#define STK_INFO(str, args...)
Definition: stk11xx.h:146
dev_stk6a54_stop_stream
int dev_stk6a54_stop_stream(struct usb_stk11xx *dev)
This function sets the device to stop the stream.
Definition: stk11xx-dev-6a54.c:520
usb_stk11xx
Definition: stk11xx.h:301
stk11xx-dev.h
Driver for Syntek USB video camera.
dev_stk11xx_check_device
int dev_stk11xx_check_device(struct usb_stk11xx *dev, int nbr)
This function permits to check the device in reading the register 0x0201.
Definition: stk11xx-dev.c:170
dev_stk6a54_camera_asleep
int dev_stk6a54_camera_asleep(struct usb_stk11xx *dev)
Wake-up the camera.
Definition: stk11xx-dev-6a54.c:268