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