📄 sn9cxxx.h
字号:
case SENSOR_HV7131R: hv7131R_InitSensor(spca50x); break; case SENSOR_MI0360: mi0360_InitSensor(spca50x); break; } sonixRegWrite(dev,0x08,0xc0,0x0000,C0,6); sonixRegWrite(dev,0x08,0xca,0x0000,CA,4); sonixRegWrite(dev,0x08,0xce,0x0000,CE,4);//?? {0x1e,0xdd,0x2d,0xe7} // here change size mode 0 -> VGA; 1 -> CIF data = 0x40 | sn9c1xx[0x18] | (spca50x->mode << 4 ); sonixRegWrite(dev,0x08,0x18,0x0000,&data,1); sonixRegWrite(dev,0x08,0x100,0x0000,qtable3,0x40); sonixRegWrite(dev,0x08,0x140,0x0000,qtable3+0x40,0x40); data = sn9c1xx[0x18] |(spca50x->mode << 4 ); sonixRegWrite(dev,0x08,0x18,0x0000,&data,1); data = 0x02;//0x42 sonixRegWrite(dev,0x08,0x01,0x0000,&data,1); data = 0x61;//0x61 sonixRegWrite(dev,0x08,0x17,0x0000,&data,1); if (spca50x->mode) data = 0x06; //320 06clk 12Mhz else { if(spca50x->sensor == SENSOR_MI0360){ data = 0x65;//0x61 sonixRegWrite(dev,0x08,0x17,0x0000,&data,1); } data = 0x46; //640 clk 24Mz 46 } // enable video on sonixRegWrite(dev,0x08,0x01,0x0000,&data,1); err = sn9cxxx_setbrightness(spca50x); if(spca50x->sensor == SENSOR_MI0360){ /*FIXME Need to be in the brightness exposure setting */ sn9c102p_i2cwritebuf (dev,gain); // sn9c102p_i2cwritebuf (dev,expo); sn9c102p_i2cwritebuf (dev,doit); sn9c102p_i2cwritebuf (dev,sensorgo); } //sn9c102p_i2cwritebuf (dev,PreAInit); //sn9c102p_i2cwritebuf (dev,RInit);}static unsigned int sn9cxxx_getexposure(struct usb_spca50x *spca50x){ __u8 expo[] = {0,0,0,0,0}; int err = 0; switch (spca50x->sensor){ case SENSOR_HV7131R: err += sn9c102p_i2cread (spca50x,0x25, expo ,5); //read sensor exposure return (unsigned int) (expo[0] << 16 | expo[1] << 8 | expo[2]); break; case SENSOR_MI0360: err += sn9c102p_i2cread (spca50x,0x09, expo ,5); //read sensor exposure return (unsigned int) (expo[0] << 8 | expo[1] ); break; } return 0;}static unsigned int sn9cxxx_setexposure(struct usb_spca50x *spca50x,unsigned int expo){ __u8 Expodoit[] = { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 }; __u8 doit[] = { 0xB1,0x5D,0x07,0x00,0x03,0x00,0x00,0x10 }; //update sensor __u8 sensorgo[] ={ 0xB1,0x5D,0x07,0x00,0x02,0x00,0x00,0x10 }; //sensor on __u8 expoMi[]={ 0xB1,0x5D,0x09,0x06,0x35,0x00,0x00,0x10 };// exposure 0x0635 -> 4 fp/s unsigned int expotimes = expo; unsigned int expotimesret = 0; switch(spca50x->sensor){ case SENSOR_HV7131R: Expodoit[3] = (expotimes >> 16) & 0xff; Expodoit[4] = (expotimes >> 8) & 0xff; Expodoit[5] = (expotimes & 0xff) ; sn9c102p_i2cwritebuf (spca50x->dev,Expodoit); wait_ms(10); expotimesret = sn9cxxx_getexposure(spca50x); PDEBUG(3,"Exposure set %d ret %d ", expotimes,expotimesret); return expotimesret; break; case SENSOR_MI0360: if ( expo > 0x0635) expo = 0x0635; if ( expo < 0x0100) expo = 0x0100; expoMi[3]= (expo >> 8) & 0xFF; expoMi[4] = expo & 0xff; sn9c102p_i2cwritebuf (spca50x->dev,expoMi); sn9c102p_i2cwritebuf (spca50x->dev,doit); sn9c102p_i2cwritebuf (spca50x->dev,sensorgo); expotimesret = sn9cxxx_getexposure(spca50x); PDEBUG(3,"Exposure set %d ret %d ", expotimes,expotimesret); return expotimesret; break; } return 0;} static __u16 sn9cxxx_setbrightness(struct usb_spca50x *spca50x){ unsigned int expo,expotimesret ; __u8 k2; switch(spca50x->sensor){ case SENSOR_HV7131R: expo = spca50x->brightness << 4; if (expo > 0x002dc6c0) expo = 0x002dc6c0; if (expo < 0x02a0) expo = 0x02a0; expotimesret = sn9cxxx_setexposure(spca50x,expo); break; case SENSOR_MI0360: expo = spca50x->brightness >> 4; expotimesret = sn9cxxx_setexposure(spca50x,expo); break; } k2 = spca50x->brightness >> 10; sonixRegWrite(spca50x->dev,0x08,0x96,0x0000,&k2,1);return 0;}static __u16 sn9cxxx_getbrightness(struct usb_spca50x *spca50x){ /* hardcoded registers seem not readable */ return spca50x->brightness = 0x7fff;}static __u16 sn9cxxx_setcontrast(struct usb_spca50x *spca50x){ __u8 k2; __u8 contrast[] = {0x14,0x00,0x28,0x00,0x07,0x00}; k2 = spca50x->contrast >> 8; if (k2 > 0x7f) k2 = 0x7f; contrast[2] = k2; contrast[0] = (k2+1) >> 1; contrast[4] = (k2+1) / 5 ; sonixRegWrite(spca50x->dev,0x08,0x84,0x0000,contrast,6); return 0;}static __u16 sn9cxxx_getcontrast(struct usb_spca50x *spca50x){ /* hardcoded registers seem not readable */ spca50x->contrast = 0x28 << 8;return 0;}static void set_sonixVGA(struct usb_spca50x *spca50x ){ memset (spca50x->mode_cam, 0x00, TOTMODE * sizeof(struct mwebcam)); spca50x->mode_cam[VGA].width = 640; spca50x->mode_cam[VGA].height = 480; spca50x->mode_cam[VGA].t_palette = P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; if(spca50x->customid == SN9C102P || spca50x->customid == SN9C105 || spca50x->customid == SN9C120) spca50x->mode_cam[VGA].t_palette |= P_JPEG; spca50x->mode_cam[VGA].pipe = 1023; spca50x->mode_cam[VGA].method = 0; spca50x->mode_cam[VGA].mode = 0; spca50x->mode_cam[PAL].width = 384; spca50x->mode_cam[PAL].height = 288; spca50x->mode_cam[PAL].t_palette = P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[PAL].pipe = 1023; spca50x->mode_cam[PAL].method = 1; spca50x->mode_cam[PAL].mode = 0; spca50x->mode_cam[SIF].width = 352; spca50x->mode_cam[SIF].height = 288; spca50x->mode_cam[SIF].t_palette = P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[SIF].pipe = 1023; spca50x->mode_cam[SIF].method = 1; spca50x->mode_cam[SIF].mode = 0; spca50x->mode_cam[CIF].width = 320; spca50x->mode_cam[CIF].height = 240; spca50x->mode_cam[CIF].t_palette = P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; if(spca50x->customid == SN9C102P || spca50x->customid == SN9C105 || spca50x->customid == SN9C120) spca50x->mode_cam[CIF].t_palette |= P_JPEG; spca50x->mode_cam[CIF].pipe = 1023; spca50x->mode_cam[CIF].method = 0; spca50x->mode_cam[CIF].mode = 1; spca50x->mode_cam[QPAL].width = 192; spca50x->mode_cam[QPAL].height = 144; spca50x->mode_cam[QPAL].t_palette = P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[QPAL].pipe = 1023; spca50x->mode_cam[QPAL].method = 1; spca50x->mode_cam[QPAL].mode = 1; spca50x->mode_cam[QSIF].width = 176; spca50x->mode_cam[QSIF].height = 144; spca50x->mode_cam[QSIF].t_palette = P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[QSIF].pipe = 1023; spca50x->mode_cam[QSIF].method = 1; spca50x->mode_cam[QSIF].mode = 1; if(spca50x->customid == SN9C101 || spca50x->customid == SN9C102 || spca50x->customid == SN9C103){ spca50x->mode_cam[QCIF].width = 160; spca50x->mode_cam[QCIF].height = 120; spca50x->mode_cam[QCIF].t_palette = P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[QCIF].pipe = 1023; spca50x->mode_cam[QCIF].method = 0; spca50x->mode_cam[QCIF].mode = 2; }}static void set_sonixSIF(struct usb_spca50x *spca50x ){ memset (spca50x->mode_cam, 0x00, TOTMODE * sizeof(struct mwebcam)); spca50x->mode_cam[SIF].width = 352; spca50x->mode_cam[SIF].height = 288; spca50x->mode_cam[SIF].t_palette = P_RAW |P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[SIF].pipe = 1023; spca50x->mode_cam[SIF].method = 0; spca50x->mode_cam[SIF].mode = 0; spca50x->mode_cam[CIF].width = 320; spca50x->mode_cam[CIF].height = 240; spca50x->mode_cam[CIF].t_palette = P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[CIF].pipe = 1023; spca50x->mode_cam[CIF].method = 1; spca50x->mode_cam[CIF].mode = 0; spca50x->mode_cam[QPAL].width = 192; spca50x->mode_cam[QPAL].height = 144; spca50x->mode_cam[QPAL].t_palette = P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[QPAL].pipe = 1023; spca50x->mode_cam[QPAL].method = 1; spca50x->mode_cam[QPAL].mode = 0; spca50x->mode_cam[QSIF].width = 176; spca50x->mode_cam[QSIF].height = 144; spca50x->mode_cam[QSIF].t_palette = P_RAW |P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[QSIF].pipe = 1023; spca50x->mode_cam[QSIF].method = 0; spca50x->mode_cam[QSIF].mode = 1; spca50x->mode_cam[QCIF].width = 160; spca50x->mode_cam[QCIF].height = 120; spca50x->mode_cam[QCIF].t_palette = P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[QCIF].pipe = 1023; spca50x->mode_cam[QCIF].method = 1; spca50x->mode_cam[QCIF].mode = 1;}static int sonix_config(struct usb_spca50x *spca50x){ switch(spca50x->sensor){ case SENSOR_OV7630: case SENSOR_TAS5130C: case SENSOR_HV7131R: case SENSOR_MI0360: case SENSOR_PAS202: set_sonixVGA(spca50x); break; case SENSOR_PAS106: case SENSOR_TAS5110: set_sonixSIF(spca50x); break; default: return -EINVAL; break; }return 0;}#if 0static void sn9cxxx_setAutobright (struct usb_spca50x *spca50x){ // GRR avg_lum from the header seem wrong set exposure on brightness instead // FIXME where is the avg luma value ?? unsigned int expotimes=0; unsigned int expotimesret = 0; __u8 luma_mean = 110; __u8 luma_delta = 20; __u8 spring = 4; // 4 choice so the gain registers follow with a little retard int delta; spin_lock_irq(&spca50x->v4l_lock); delta = spca50x->avg_lum ; spin_unlock_irq(&spca50x->v4l_lock); //PDEBUG(0,"Error setting exposure delta %d",delta); if((delta < (luma_mean - luma_delta)) || (delta > (luma_mean + luma_delta))){ expotimes = sn9cxxx_getexposure(spca50x); expotimes += ((luma_mean - delta) >> spring); expotimesret = sn9cxxx_setexposure(spca50x,expotimes); if (expotimes != expotimesret) PDEBUG(0,"Error setting exposure !"); } }static void sn9cxxx_shutdown(struct usb_spca50x *spca50x){}#endif#endif //SONIXJPGUSB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -