📄 spca501_init.h
字号:
{0x02, 0xa048, 0x0000}, {0x02, 0xc002, 0x0001}, {0x02, 0x000f, 0x0005}, {0x02, 0xa048, 0x0000}, {0x05, 0x0022, 0x0004}, {0x05, 0x0025, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0026, 0x0001}, {0x05, 0x0001, 0x0000}, {0x05, 0x0027, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0001, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0021, 0x0001}, {0x05, 0x00d2, 0x0000}, {0x05, 0x0020, 0x0001}, {0x05, 0x0000, 0x0000}, {0x00, 0x0090, 0x0005}, {0x01, 0x00a6, 0x0000}, {0x05, 0x0026, 0x0001}, {0x05, 0x0001, 0x0000}, {0x05, 0x0027, 0x0001}, {0x05, 0x001e, 0x0000}, {0x01, 0x0003, 0x003f}, {0x01, 0x0001, 0x0056}, {0x01, 0x0011, 0x0008}, {0x01, 0x0032, 0x0009}, {0x01, 0xfffd, 0x000a}, {0x01, 0x0023, 0x000b}, {0x01, 0xffea, 0x000c}, {0x01, 0xfff4, 0x000d}, {0x01, 0xfffc, 0x000e}, {0x01, 0xffe3, 0x000f}, {0x01, 0x001f, 0x0010}, {0x01, 0x00a8, 0x0001}, {0x01, 0x0067, 0x0007}, {0x01, 0x0042, 0x0051}, {0x01, 0x0051, 0x0053}, {0x01, 0x000a, 0x0003}, {0x02, 0xc002, 0x0001}, {0x02, 0x0007, 0x0005}, {0x01, 0x0042, 0x0051}, {0x01, 0x0051, 0x0053}, {0x05, 0x0026, 0x0001}, {0x05, 0x0001, 0x0000}, {0x05, 0x0027, 0x0001}, {0x05, 0x002d, 0x0000}, {0x01, 0x0003, 0x003f}, {0x01, 0x0001, 0x0056}, {0x02, 0xc000, 0x0001}, {0x02, 0x0000, 0x0005}, {0x00, 0x0000, 0x0000}};/* Unknow camera from Ori Usbid 0x0000:0x0000 */static __u16 spca501c_mysterious_open_data[][3] = { /* Based on snoops from Ori Cohen */ {0x02, 0x000f, 0x0005}, {0x02, 0xa048, 0x0000}, {0x05, 0x0022, 0x0004},/* DSP Registers */ {0x01, 0x0016, 0x0011}, //RGB offset {0x01, 0x0000, 0x0012}, {0x01, 0x0006, 0x0013}, {0x01, 0x0078, 0x0051}, {0x01, 0x0040, 0x0052}, {0x01, 0x0046, 0x0053}, {0x01, 0x0040, 0x0054}, {0x00, 0x0025, 0x0000},//{0x00, 0x0000, 0x0000 },/* Part 2 *//* TG Registers */ {0x00, 0x0026, 0x0000}, {0x00, 0x0001, 0x0000}, {0x00, 0x0027, 0x0000}, {0x00, 0x008a, 0x0000}, {0x02, 0x0007, 0x0005}, {0x02, 0x2000, 0x0000}, {0x05, 0x0022, 0x0004}, {0x05, 0x0015, 0x0001}, {0x05, 0x00ea, 0x0000}, {0x05, 0x0021, 0x0001}, {0x05, 0x00d2, 0x0000}, {0x05, 0x0023, 0x0001}, {0x05, 0x0003, 0x0000}, {0x05, 0x0030, 0x0001}, {0x05, 0x002b, 0x0000}, {0x05, 0x0031, 0x0001}, {0x05, 0x0023, 0x0000}, {0x05, 0x0032, 0x0001}, {0x05, 0x0023, 0x0000}, {0x05, 0x0033, 0x0001}, {0x05, 0x0023, 0x0000}, {0x05, 0x0034, 0x0001}, {0x05, 0x0002, 0x0000}, {0x05, 0x0050, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0051, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0052, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0054, 0x0001}, {0x05, 0x0001, 0x0000}, {0, 0, 0}};static __u16 spca501c_mysterious_init_data[][3] = { /* Based on snoops from Ori Cohen *//* Part 3 *//* TG registers *///{0x00, 0x0000, 0x0000 }, {0x00, 0x0000, 0x0001}, {0x00, 0x0000, 0x0002}, {0x00, 0x0006, 0x0003}, {0x00, 0x0000, 0x0004}, {0x00, 0x0090, 0x0005}, {0x00, 0x0000, 0x0006}, {0x00, 0x0040, 0x0007}, {0x00, 0x00c0, 0x0008}, {0x00, 0x004a, 0x0009}, {0x00, 0x0000, 0x000a}, {0x00, 0x0000, 0x000b}, {0x00, 0x0001, 0x000c}, {0x00, 0x0001, 0x000d}, {0x00, 0x0000, 0x000e}, {0x00, 0x0002, 0x000f}, {0x00, 0x0001, 0x0010}, {0x00, 0x0000, 0x0011}, {0x00, 0x0001, 0x0012}, {0x00, 0x0002, 0x0020}, {0x00, 0x0080, 0x0021}, //640 {0x00, 0x0001, 0x0022}, {0x00, 0x00e0, 0x0023}, //480 {0x00, 0x0000, 0x0024}, // Offset H hight {0x00, 0x00d3, 0x0025}, // low {0x00, 0x0000, 0x0026}, // Offset V {0x00, 0x000d, 0x0027}, // low {0x00, 0x0000, 0x0046}, {0x00, 0x0000, 0x0047}, {0x00, 0x0000, 0x0048}, {0x00, 0x0000, 0x0049}, {0x00, 0x0008, 0x004a},/* DSP Registers */ {0x01, 0x00a6, 0x0000}, {0x01, 0x0028, 0x0001}, {0x01, 0x0000, 0x0002}, {0x01, 0x000a, 0x0003}, // Level Calc bit7 ->1 Auto {0x01, 0x0040, 0x0004}, {0x01, 0x0066, 0x0007}, {0x01, 0x000f, 0x0008}, // A11 Color correction coeff {0x01, 0x002d, 0x0009}, // A12 {0x01, 0x0005, 0x000a}, // A13 {0x01, 0x0023, 0x000b}, // A21 {0x01, 0x00e0, 0x000c}, // A22 {0x01, 0x00fd, 0x000d}, // A23 {0x01, 0x00f4, 0x000e}, // A31 {0x01, 0x00e4, 0x000f}, // A32 {0x01, 0x0028, 0x0010}, // A33 {0x01, 0x00ff, 0x0015}, // Reserved {0x01, 0x0001, 0x0016}, // Reserved {0x01, 0x0032, 0x0017}, // Win1 Start begin {0x01, 0x0023, 0x0018}, {0x01, 0x00ce, 0x0019}, {0x01, 0x0023, 0x001a}, {0x01, 0x0032, 0x001b}, {0x01, 0x008d, 0x001c}, {0x01, 0x00ce, 0x001d}, {0x01, 0x008d, 0x001e}, {0x01, 0x0000, 0x001f}, {0x01, 0x0000, 0x0020}, //Win1 Start end {0x01, 0x00ff, 0x003e}, //Reserved begin {0x01, 0x0002, 0x003f}, {0x01, 0x0000, 0x0040}, {0x01, 0x0035, 0x0041}, {0x01, 0x0053, 0x0042}, {0x01, 0x0069, 0x0043}, {0x01, 0x007c, 0x0044}, {0x01, 0x008c, 0x0045}, {0x01, 0x009a, 0x0046}, {0x01, 0x00a8, 0x0047}, {0x01, 0x00b4, 0x0048}, {0x01, 0x00bf, 0x0049}, {0x01, 0x00ca, 0x004a}, {0x01, 0x00d4, 0x004b}, {0x01, 0x00dd, 0x004c}, {0x01, 0x00e7, 0x004d}, {0x01, 0x00ef, 0x004e}, {0x01, 0x00f8, 0x004f}, {0x01, 0x00ff, 0x0050}, {0x01, 0x0003, 0x0056}, // Reserved end {0x01, 0x0060, 0x0057}, //Edge Gain {0x01, 0x0040, 0x0058}, // {0x01, 0x0011, 0x0059}, //Edge Bandwidth {0x01, 0x0001, 0x005a}, // {0x02, 0x0007, 0x0005}, {0x02, 0xa048, 0x0000}, {0x02, 0x0007, 0x0005}, {0x02, 0x0015, 0x0006}, {0x02, 0x200a, 0x0007}, {0x02, 0xa048, 0x0000}, {0x02, 0xc000, 0x0001}, {0x02, 0x000f, 0x0005}, {0x02, 0xa048, 0x0000}, {0x05, 0x0022, 0x0004}, {0x05, 0x0025, 0x0001}, {0x05, 0x0000, 0x0000},/* Part 4 */ {0x05, 0x0026, 0x0001}, {0x05, 0x0001, 0x0000}, {0x05, 0x0027, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0001, 0x0001}, {0x05, 0x0000, 0x0000}, {0x05, 0x0021, 0x0001}, {0x05, 0x00d2, 0x0000}, {0x05, 0x0020, 0x0001}, {0x05, 0x0000, 0x0000}, {0x00, 0x0090, 0x0005}, {0x01, 0x00a6, 0x0000}, {0x02, 0x0000, 0x0005}, {0x05, 0x0026, 0x0001}, {0x05, 0x0001, 0x0000}, {0x05, 0x0027, 0x0001}, {0x05, 0x004e, 0x0000},/* Part 5 */ {0x01, 0x0003, 0x003f}, {0x01, 0x0001, 0x0056}, {0x01, 0x000f, 0x0008}, {0x01, 0x002d, 0x0009}, {0x01, 0x0005, 0x000a}, {0x01, 0x0023, 0x000b}, {0x01, 0xffe0, 0x000c}, {0x01, 0xfffd, 0x000d}, {0x01, 0xfff4, 0x000e}, {0x01, 0xffe4, 0x000f}, {0x01, 0x0028, 0x0010}, {0x01, 0x00a8, 0x0001}, {0x01, 0x0066, 0x0007}, {0x01, 0x0032, 0x0017}, {0x01, 0x0023, 0x0018}, {0x01, 0x00ce, 0x0019}, {0x01, 0x0023, 0x001a}, {0x01, 0x0032, 0x001b}, {0x01, 0x008d, 0x001c}, {0x01, 0x00ce, 0x001d}, {0x01, 0x008d, 0x001e}, {0x01, 0x00c8, 0x0015}, //c8 Poids fort Luma {0x01, 0x0032, 0x0016}, //32 {0x01, 0x0016, 0x0011}, //R 00 {0x01, 0x0016, 0x0012}, //G 00 {0x01, 0x0016, 0x0013}, //B 00 {0x01, 0x000a, 0x0003}, {0x02, 0xc002, 0x0001}, {0x02, 0x0007, 0x0005}, {0, 0, 0}};/**************** Old code from spca50x *******************************//********************************************************************** * Get average luminance **********************************************************************/static inline __u8 get_avg_lum(struct usb_spca50x *spca50x){ __u8 luminance; //The average luminance from camera switch (spca50x->bridge) { case BRIDGE_SPCA501: luminance = spca50x_reg_read(spca50x->dev, SPCA501_REG_CCDSP, 0x26, 2) >> 8; break;#ifdef SPCA50X_ENABLE_EXP_BRIGHTNESS case BRIDGE_SPCA561: case BRIDGE_SPCA508: luminance = spca50x_reg_read(spca50x->dev, 0, 0x8621, 1); break;#endif /* SPCA50X_ENABLE_EXP_BRIGHTNESS */ default: luminance = 0; break; } return luminance;}/********************************************************************** * Get average R-G and B-G **********************************************************************/static inline __u8 get_avg_RG(struct usb_spca50x *spca50x){ __u8 rg; //The average R-G for window5 switch (spca50x->bridge) { case BRIDGE_SPCA501: rg = spca50x_reg_read(spca50x->dev, SPCA501_REG_CCDSP, 0x30, 2) >> 8; break; default: rg = 0; break; } return rg;}/********************************************************************** * Get average B-G **********************************************************************/static inline __u8 get_avg_BG(struct usb_spca50x *spca50x){ __u8 bg; //The average B-G for window5 switch (spca50x->bridge) { case BRIDGE_SPCA501: bg = spca50x_reg_read(spca50x->dev, SPCA501_REG_CCDSP, 0x2f, 2) >> 8; break; default: bg = 0; break; } return bg;}/*********************************************************************** spca50x_get_whiteness* Function reads the "whiteness parameter" from the camera* Actually "whiteness" is a parameter that close to brighness* but currently ununderstanded* Receives the pointer to the description structure* returns the value of whiteness**********************************************************************/static inline __u16 spca50x_get_whiteness(struct usb_spca50x *spca50x){#ifdef SPCA50X_ENABLE_EXPERIMENTAL __u16 whiteness = 0; //the "whiteness" parameter __u16 br = 0; //the brightness value int i; // just an index variable __u16 mask; //the bit mask to set bit in p.contrast __u8 br_table[] = { 128, 64, 32, 16, 0 }; //the brightness table //this parameter is known for spca501 only if (spca50x->bridge != BRIDGE_SPCA501) return 0; /* Getting "whiteness" (strange parameters in TG 0x0D */ br = spca50x_reg_read(spca50x->dev, 0x0, 0x0d, 2); for (i = 0, mask = 1; br_table[i]; i++, mask <<= 1) { if (br & br_table[i]) whiteness |= mask; } whiteness <<= 4; return whiteness;#else /* SPCA50X_ENABLE_EXPERIMENTAL */ return 0;#endif /* SPCA50X_ENABLE_EXPERIMENTAL */}/*********************************************************************** spca50x_set_whiteness* Function sets the "whiteness parameter" from the camera* Actually "whiteness" is a parameter that close to brighness* but currently ununderstanded* Receives the pointer to the description structure * and whiteness value**********************************************************************/static inline voidspca50x_set_whiteness(struct usb_spca50x *spca50x, __u8 whiteness){#ifdef SPCA50X_ENABLE_EXPERIMENTAL __u8 br_high = 0; //the contrast value __u8 br_out = 0; // contrast output value int i; // just an index variable __u16 mask; //the bit mask to set bit in contrast __u8 br_table[] = { 128, 64, 32, 16, 0 }; //the brightness table //this parameter is known for spca501 only if (spca50x->bridge != BRIDGE_SPCA501) return; PDEBUG(3, "Setting whiteness %d", whiteness); br_high = whiteness >> 4; for (i = 0, mask = 1; br_table[i]; i++, mask <<= 1) { if (br_high & mask) br_out |= br_table[i]; } PDEBUG(3, "Writing whiteness %d", br_out); spca50x_reg_write(spca50x->dev, 0x0, 0x0d, br_out);#else /* SPCA50X_ENABLE_EXPERIMENTAL */ return;#endif /* SPCA50X_ENABLE_EXPERIMENTAL */}/*********************************************************************** autobrightness* Function tries to control brightness* Receives the pointer to camera descriptor and * target average luminance***********************************************************************/static inline void autobrightness(struct usb_spca50x *spca50x){ __u8 cur_lum = 0; //The current luminance __u8 brightness = 0; char br_set = 0; //If the brightness should be set __u8 lum = spca50x->lum_level; //The desired luminance level __u8 delta = lum >> 3; //overshooting that we shouldn't care#ifdef SPCA50X_ENABLE_EXPERIMENTAL __u8 whiteness = 0; //whiteness level char wh_set = 0; //If whiteness must be set#endif /* SPCA50X_ENABLE_EXPERIMENTAL */ if (in_interrupt()) { PDEBUG(2, "In intr"); return; } //// /* * This algorithm may be dangerous. We MUST be sure that the * !spca50x->streaming will be set to 0 BEFORE kfree(spca50x) */ //// if (!spca50x->streaming) //No isoc return; cur_lum = get_avg_lum(spca50x); brightness = spca50x->brightness >> 8; if (cur_lum < (lum - delta)) { if (brightness < 255) { brightness++; br_set = 1; }#ifdef SPCA50X_ENABLE_EXPERIMENTAL else { whiteness = spca50x->whiteness >> 12; if (whiteness < 15) { whiteness++; wh_set = 1; } }#endif /* SPCA50X_ENABLE_EXPERIMENTAL */ } if (cur_lum > (lum + delta) && brightness > 0) { brightness--; br_set = 1; }#ifdef SPCA50X_ENABLE_EXPERIMENTAL if ((spca50x->nstable == NSTABLE_MAX || spca50x->nunstable == NUNSTABLE_MAX) && brightness < MIN_BRIGHTNESS) { whiteness = spca50x->whiteness >> 12; if (whiteness > 0) { whiteness--; wh_set = 1; } } if (wh_set) { spca50x_set_whiteness(spca50x, whiteness << 4); spca50x->whiteness = whiteness << 12; spca50x->nstable = 0; spca50x->nunstable = 0; return; //if we have set whiteness, we needn't care about brightness }#endif /* SPCA50X_ENABLE_EXPERIMENTAL */ if (br_set) { // spca50x_set_brightness (spca50x, brightness); spca50x->brightness = brightness << 8;#ifdef SPCA50X_ENABLE_EXPERIMENTAL if (spca50x->nunstable < NUNSTABLE_MAX) spca50x->nunstable++; spca50x->nstable = 0;#endif /* SPCA50X_ENABLE_EXPERIMENTAL */ }#ifdef SPCA50X_ENABLE_EXPERIMENTAL else { if (spca50x->nstable < NSTABLE_MAX) spca50x->nstable++; else spca50x->nunstable = 0; }#endif /* SPCA50X_ENABLE_EXPERIMENTAL */}#endif /* SPCA501_INIT_H *///eof
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -