SyntekUSBVideoCamera
|
00001 00034 #include <linux/module.h> 00035 #include <linux/init.h> 00036 #include <linux/kernel.h> 00037 #include <linux/version.h> 00038 #include <linux/errno.h> 00039 #include <linux/slab.h> 00040 #include <linux/kref.h> 00041 00042 #include <linux/usb.h> 00043 #include <media/v4l2-common.h> 00044 #include <media/v4l2-ioctl.h> 00045 00046 #include "stk11xx.h" 00047 #include "stk11xx-dev.h" 00048 00049 00050 //============================================================================= 00051 // 00052 // STK-6A54 API 00053 // 00054 //============================================================================= 00055 00056 00070 int dev_stk6a54_initialize_device(struct usb_stk11xx *dev) 00071 { 00072 int value; 00073 00074 STK_INFO("Initialize USB2.0 Syntek Camera\n"); 00075 00076 usb_stk11xx_write_registry(dev, 0x0000, 0x00e0); 00077 usb_stk11xx_write_registry(dev, 0x0002, 0x00f8); 00078 usb_stk11xx_write_registry(dev, 0x0002, 0x0078); 00079 usb_stk11xx_write_registry(dev, 0x0000, 0x0020); 00080 00081 dev_stk6a54_configure_device(dev, 0); 00082 dev_stk11xx_check_device(dev, 65); 00083 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00084 usb_stk11xx_read_registry(dev, 0x02ff, &value); 00085 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00086 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00087 usb_stk11xx_write_registry(dev, 0x0208, 0x000a); 00088 usb_stk11xx_write_registry(dev, 0x0200, 0x0020); 00089 dev_stk11xx_check_device(dev, 65); 00090 usb_stk11xx_read_registry(dev, 0x0209, &value); 00091 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00092 usb_stk11xx_read_registry(dev, 0x02ff, &value); 00093 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00094 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00095 usb_stk11xx_write_registry(dev, 0x0208, 0x000b); 00096 usb_stk11xx_write_registry(dev, 0x0200, 0x0020); 00097 dev_stk11xx_check_device(dev, 65); 00098 usb_stk11xx_read_registry(dev, 0x0209, &value); 00099 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00100 usb_stk11xx_read_registry(dev, 0x02ff, &value); 00101 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00102 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00103 usb_stk11xx_write_registry(dev, 0x0208, 0x001c); 00104 usb_stk11xx_write_registry(dev, 0x0200, 0x0020); 00105 dev_stk11xx_check_device(dev, 65); 00106 usb_stk11xx_read_registry(dev, 0x0209, &value); 00107 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00108 usb_stk11xx_read_registry(dev, 0x02ff, &value); 00109 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00110 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00111 usb_stk11xx_write_registry(dev, 0x0208, 0x001d); 00112 usb_stk11xx_write_registry(dev, 0x0200, 0x0020); 00113 dev_stk11xx_check_device(dev, 65); 00114 usb_stk11xx_read_registry(dev, 0x0209, &value); 00115 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00116 usb_stk11xx_write_registry(dev, 0x0000, 0x00e0); 00117 usb_stk11xx_write_registry(dev, 0x0002, 0x00f8); 00118 usb_stk11xx_write_registry(dev, 0x0002, 0x0078); 00119 usb_stk11xx_write_registry(dev, 0x0000, 0x0020); 00120 usb_stk11xx_write_registry(dev, 0x0100, 0x0021); 00121 usb_stk11xx_read_registry(dev, 0x0000, &value); 00122 usb_stk11xx_write_registry(dev, 0x0000, 0x004b); 00123 00124 00125 dev_stk6a54_configure_device(dev, 1); 00126 00127 usb_stk11xx_set_feature(dev, 0); 00128 00129 // Device is initialized and is ready !!! 00130 STK_INFO("Syntek USB2.0 Camera is ready\n"); 00131 00132 return 0; 00133 } 00134 00135 00149 int dev_stk6a54_configure_device(struct usb_stk11xx *dev, int step) 00150 { 00151 int value; 00152 00153 // 0, 1 00154 static const int values_001B[] = { 00155 0x0e, 0x0e 00156 }; 00157 static const int values_001C[] = { 00158 0x46, 0x46 00159 }; 00160 static const int values_0202[] = { 00161 0x1e, 0x1e 00162 }; 00163 static const int values_0110[] = { 00164 0x00, 0x00 00165 }; 00166 static const int values_0112[] = { 00167 0x00, 0x00 00168 }; 00169 static const int values_0114[] = { 00170 0x00, 0x00 00171 }; 00172 static const int values_0115[] = { 00173 0x00, 0x05 00174 }; 00175 static const int values_0116[] = { 00176 0x00, 0xe0 00177 }; 00178 static const int values_0117[] = { 00179 0x00, 0x01 00180 }; 00181 static const int values_0100[] = { 00182 0x21, 0x21 00183 }; 00184 00185 00186 STK_DEBUG("dev_stk6a54_configure_device : %d\n", step); 00187 00188 usb_stk11xx_write_registry(dev, 0x0000, 0x0024); 00189 usb_stk11xx_write_registry(dev, 0x0002, 0x0078); 00190 usb_stk11xx_write_registry(dev, 0x0003, 0x0080); 00191 usb_stk11xx_write_registry(dev, 0x0005, 0x0000); 00192 00193 usb_stk11xx_write_registry(dev, 0x0007, 0x0003); 00194 usb_stk11xx_write_registry(dev, 0x000d, 0x0000); 00195 usb_stk11xx_write_registry(dev, 0x000f, 0x0002); 00196 usb_stk11xx_write_registry(dev, 0x0300, 0x0012); 00197 usb_stk11xx_write_registry(dev, 0x0350, 0x0041); 00198 00199 usb_stk11xx_write_registry(dev, 0x0351, 0x0000); 00200 usb_stk11xx_write_registry(dev, 0x0352, 0x0000); 00201 usb_stk11xx_write_registry(dev, 0x0353, 0x0000); 00202 usb_stk11xx_write_registry(dev, 0x0018, 0x0010); 00203 usb_stk11xx_write_registry(dev, 0x0019, 0x0000); 00204 00205 usb_stk11xx_write_registry(dev, 0x001b, values_001B[step]); 00206 usb_stk11xx_write_registry(dev, 0x001c, values_001C[step]); 00207 usb_stk11xx_write_registry(dev, 0x0300, 0x0080); 00208 usb_stk11xx_write_registry(dev, 0x001a, 0x0004); 00209 usb_stk11xx_write_registry(dev, 0x0202, values_0202[step]); 00210 00211 usb_stk11xx_write_registry(dev, 0x0110, values_0110[step]); 00212 usb_stk11xx_write_registry(dev, 0x0111, 0x0000); 00213 usb_stk11xx_write_registry(dev, 0x0112, values_0112[step]); 00214 usb_stk11xx_write_registry(dev, 0x0113, 0x0000); 00215 usb_stk11xx_write_registry(dev, 0x0114, values_0114[step]); 00216 00217 usb_stk11xx_write_registry(dev, 0x0115, values_0115[step]); 00218 usb_stk11xx_write_registry(dev, 0x0116, values_0116[step]); 00219 usb_stk11xx_write_registry(dev, 0x0117, values_0117[step]); 00220 00221 usb_stk11xx_read_registry(dev, 0x0100, &value); 00222 usb_stk11xx_write_registry(dev, 0x0100, values_0100[step]); 00223 00224 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00225 00226 00227 switch (step) { 00228 case 0: 00229 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00230 00231 usb_stk11xx_read_registry(dev, 0x02ff, &value); 00232 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00233 00234 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00235 00236 usb_stk11xx_write_registry(dev, 0x0204, 0x00ff); 00237 usb_stk11xx_write_registry(dev, 0x0205, 0x0001); 00238 00239 usb_stk11xx_write_registry(dev, 0x0200, 0x0001); 00240 00241 break; 00242 00243 case 1: 00244 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00245 00246 dev_stk6a54_sensor_settings(dev); 00247 00248 usb_stk11xx_read_registry(dev, 0x0209, &value); 00249 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00250 00251 break; 00252 } 00253 00254 return 0; 00255 } 00256 00257 00267 int dev_stk6a54_camera_asleep(struct usb_stk11xx *dev) 00268 { 00269 int value; 00270 00271 usb_stk11xx_read_registry(dev, 0x0104, &value); 00272 usb_stk11xx_read_registry(dev, 0x0105, &value); 00273 usb_stk11xx_read_registry(dev, 0x0106, &value); 00274 00275 usb_stk11xx_write_registry(dev, 0x0100, 0x0021); 00276 usb_stk11xx_write_registry(dev, 0x0116, 0x0000); 00277 usb_stk11xx_write_registry(dev, 0x0117, 0x0000); 00278 usb_stk11xx_write_registry(dev, 0x0018, 0x0000); 00279 00280 usb_stk11xx_read_registry(dev, 0x0000, &value); 00281 usb_stk11xx_write_registry(dev, 0x0000, 0x0049); 00282 00283 return 0; 00284 } 00285 00286 00297 int dev_stk6a54_init_camera(struct usb_stk11xx *dev) 00298 { 00299 return 0; 00300 } 00301 00302 00313 int dev_stk6a54_sensor_settings(struct usb_stk11xx *dev) 00314 { 00315 int i; 00316 int retok; 00317 int value; 00318 00319 int asize; 00320 00321 static const int values_204[] = { 00322 0xff, 0x12, 0xff, 0x2c, 0x2e, 0xff, 0x3c, 0x11, 0x09, 0x04, 00323 0x13, 0x14, 0x2c, 0x33, 0x3a, 0x3b, 0x3e, 0x43, 0x16, 0x39, 00324 0x35, 0x22, 0x37, 0x23, 0x34, 0x36, 0x06, 0x07, 0x0d, 0x0e, 00325 0x4c, 0x4a, 0x21, 0x24, 0x25, 0x26, 0x5c, 0x63, 0x46, 0x0c, 00326 0x61, 0x62, 0x7c, 0x20, 0x28, 0x6c, 0x6d, 0x6e, 0x70, 0x71, 00327 0x73, 0x3d, 0x5a, 0x4f, 0x50, 0xff, 0xe5, 0xf9, 0x41, 0xe0, 00328 0x76, 0x33, 0x42, 0x43, 0x4c, 0x87, 0x88, 0xd7, 0xd9, 0xd3, 00329 0xc8, 0xc9, 0x7c, 0x7d, 0x7c, 0x7d, 0x7d, 0x7c, 0x7d, 0x7d, 00330 0x7d, 0x90, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 00331 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x92, 0x93, 00332 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 00333 0x93, 0x93, 0x96, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 00334 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0xc3, 0xa4, 0xa8, 0xc5, 00335 0xc6, 0xbf, 0xc7, 0xb6, 0xb8, 0xb7, 0xb9, 0xb3, 0xb4, 0xb5, 00336 0xb0, 0xb1, 0xb2, 0xc4, 0xc0, 0xc1, 0x86, 0x50, 0x51, 0x52, 00337 0x53, 0x54, 0x55, 0x57, 0x5a, 0x5b, 0x5c, 0xc3, 0x7f, 0xda, 00338 0xd7, 0xe5, 0xe1, 0xe0, 0xdd, 0x05, 0xff, 0x12, 0x11, 0x17, 00339 0x18, 0x19, 0x1a, 0x32, 0x37, 0x4f, 0x50, 0x5a, 0x6d, 0x3d, 00340 0x39, 0x35, 0x22, 0x37, 0x23, 0x34, 0x36, 0x06, 0x07, 0x0d, 00341 0x0e, 0x4c, 0xff, 0xe0, 0xc0, 0xc1, 0x8c, 0x86, 0x50, 0x51, 00342 0x52, 0x53, 0x54, 0x55, 0x5a, 0x5b, 0x5c, 0xd3, 0xe0, 0xff, 00343 0xe0, 0xc0, 0xc1, 0x8c, 0x86, 0x50, 0x51, 0x52, 0x53, 0x54, 00344 0x55, 0x5a, 0x5b, 0x5c, 0xd3, 0xe0, 0xff, 0xff, 0x04, 0xff, 00345 0xff, 0xff, 0x7c, 0x7d, 0x7c, 0x7c, 0x7d, 0x7c, 0x7d, 0x7c, 00346 0xff, 0x7c, 0x7d, 0x7c, 0x7d, 0x7c, 0xff, 0x7c, 0x7d, 0x7c, 00347 0x7d, 0x7c, 0x7d, 0x7c, 0x7c, 0xff, 0x7c, 0x7d, 0x7c, 0x7d, 00348 0x7c, 0x7d, 0xff, 0x92, 0x93, 0xff, 0x90, 0x91, 0x91, 0x91, 00349 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 00350 0x91, 0x91, 0x91, 0xff, 0xc3, 0xc7, 0xce, 0xcc, 0xcd, 0xff, 00351 0x04, 0xff, 0x04 00352 }; 00353 00354 static const int values_205[] = { 00355 0x01, 0x80, 0x00, 0xff, 0xdf, 0x01, 0x32, 0x00, 0x02, 0x28, 00356 0xe5, 0x48, 0x0c, 0x78, 0x33, 0xfb, 0x00, 0x11, 0x10, 0x02, 00357 0x88, 0x0a, 0x40, 0x00, 0xa0, 0x1a, 0x02, 0xc0, 0xb7, 0x01, 00358 0x00, 0x81, 0x99, 0x40, 0x38, 0x82, 0x00, 0x00, 0x3f, 0x3c, 00359 0x70, 0x80, 0x05, 0x80, 0x30, 0x00, 0x80, 0x00, 0x02, 0x94, 00360 0xc1, 0x34, 0x57, 0xbb, 0x9c, 0x00, 0x7f, 0xc0, 0x24, 0x14, 00361 0xff, 0xa0, 0x20, 0x18, 0x00, 0xd0, 0x3f, 0x03, 0x10, 0x82, 00362 0x08, 0x80, 0x00, 0x00, 0x03, 0x48, 0x48, 0x08, 0x20, 0x10, 00363 0x0e, 0x00, 0x0e, 0x1a, 0x31, 0x5a, 0x69, 0x75, 0x7e, 0x88, 00364 0x8f, 0x96, 0xa3, 0xaf, 0xc4, 0xd7, 0xe8, 0x20, 0x00, 0x06, 00365 0xe3, 0x05, 0x05, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 00366 0x00, 0x00, 0x00, 0x08, 0x19, 0x02, 0x0c, 0x24, 0x30, 0x28, 00367 0x26, 0x02, 0x98, 0x80, 0x00, 0x00, 0xed, 0x00, 0x00, 0x11, 00368 0x51, 0x80, 0x10, 0x66, 0xa5, 0x64, 0x7c, 0xaf, 0x97, 0xff, 00369 0xc5, 0x94, 0x0f, 0x5c, 0xc8, 0x96, 0x3d, 0x00, 0x90, 0x18, 00370 0x00, 0x00, 0x88, 0x00, 0x90, 0x18, 0x05, 0xed, 0x00, 0x00, 00371 0x01, 0x1f, 0x67, 0x00, 0xff, 0x00, 0x01, 0x40, 0x00, 0x11, 00372 0x43, 0x00, 0x4b, 0x09, 0xc0, 0xca, 0xa8, 0x23, 0x00, 0x38, 00373 0x12, 0xda, 0x1a, 0xc3, 0x00, 0xc0, 0x1a, 0x88, 0xc0, 0x87, 00374 0x41, 0x00, 0x00, 0x04, 0x64, 0x4b, 0x00, 0x1d, 0x00, 0xc8, 00375 0x96, 0x00, 0x00, 0x00, 0xc8, 0x96, 0x00, 0x82, 0x00, 0x00, 00376 0x04, 0x64, 0x4b, 0x00, 0x3d, 0x00, 0xc8, 0x96, 0x00, 0x00, 00377 0x00, 0xa0, 0x78, 0x00, 0x82, 0x00, 0x00, 0x01, 0xfa, 0x01, 00378 0x00, 0x00, 0x00, 0x04, 0x0a, 0x09, 0x16, 0x0a, 0x06, 0x09, 00379 0x00, 0x00, 0x04, 0x08, 0x28, 0x08, 0x00, 0x00, 0x05, 0x01, 00380 0x7f, 0x02, 0x00, 0x0a, 0x05, 0x00, 0x00, 0x07, 0x03, 0x4d, 00381 0x04, 0x4d, 0x00, 0x01, 0xc5, 0x00, 0x00, 0x00, 0x23, 0x3c, 00382 0x50, 0x63, 0x73, 0x83, 0x92, 0xa0, 0xad, 0xba, 0xc6, 0xd2, 00383 0xde, 0xe9, 0xf5, 0x01, 0x0c, 0x00, 0x80, 0x80, 0x80, 0x01, 00384 0xfa, 0x01, 0xfa 00385 }; 00386 00387 asize = ARRAY_SIZE(values_204); 00388 00389 for(i=0; i<asize; i++) { 00390 usb_stk11xx_read_registry(dev, 0x02ff, &value); 00391 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00392 00393 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00394 00395 usb_stk11xx_write_registry(dev, 0x0204, values_204[i]); 00396 usb_stk11xx_write_registry(dev, 0x0205, values_205[i]); 00397 usb_stk11xx_write_registry(dev, 0x0200, 0x0001); 00398 00399 retok = dev_stk11xx_check_device(dev, 500); 00400 00401 if (retok != 1) { 00402 STK_ERROR("Load default sensor settings fail !\n"); 00403 return -1; 00404 } 00405 00406 usb_stk11xx_write_registry(dev, 0x02ff, 0x0000); 00407 } 00408 00409 usb_stk11xx_read_registry(dev, 0x02ff, &value); 00410 00411 usb_stk11xx_write_registry(dev, 0x0203, 0x0060); 00412 00413 usb_stk11xx_write_registry(dev, 0x0208, 0x0004); 00414 00415 usb_stk11xx_write_registry(dev, 0x0200, 0x0020); 00416 00417 retok = dev_stk11xx_check_device(dev, 500); 00418 00419 return 0; 00420 } 00421 00422 00436 int dev_stk6a54_camera_settings(struct usb_stk11xx *dev) 00437 { 00438 return 0; 00439 } 00440 00441 00455 int dev_stk6a54_set_camera_quality(struct usb_stk11xx *dev) 00456 { 00457 return 0; 00458 } 00459 00460 00470 int dev_stk6a54_set_camera_fps(struct usb_stk11xx *dev) 00471 { 00472 return 0; 00473 } 00474 00475 00486 int dev_stk6a54_start_stream(struct usb_stk11xx *dev) 00487 { 00488 return 0; 00489 } 00490 00491 00501 int dev_stk6a54_reconf_camera(struct usb_stk11xx *dev) 00502 { 00503 dev_stk11xx_camera_settings(dev); 00504 00505 return 0; 00506 } 00507 00508 00519 int dev_stk6a54_stop_stream(struct usb_stk11xx *dev) 00520 { 00521 return 0; 00522 } 00523 00524