📄 sp5xxfw2.h
字号:
static __u16 sp5xxfw2_getcolors(struct usb_spca50x *spca50x){switch (spca50x->bridge) { case BRIDGE_SPCA533: case BRIDGE_SPCA504B: case BRIDGE_SPCA504: case BRIDGE_SPCA504C: spca50x->colour = spca50x_reg_read (spca50x->dev, 0x0, 0x21ae, 2) << 7; break; case BRIDGE_SPCA536: spca50x->colour = spca50x_reg_read (spca50x->dev, 0x0, 0x20f6, 2) << 7; break; }return spca50x->colour;}static int sp5xxfw2_config(struct usb_spca50x *spca50x){ switch (spca50x->bridge){ case BRIDGE_SPCA504B: case BRIDGE_SPCA504: case BRIDGE_SPCA536: 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_JPEG | P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[VGA].pipe = 1023; spca50x->mode_cam[VGA].method = 0; spca50x->mode_cam[VGA].mode = 1; 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 = 1; 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 = 1; spca50x->mode_cam[CIF].width = 320; spca50x->mode_cam[CIF].height = 240; spca50x->mode_cam[CIF].t_palette = P_JPEG | P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[CIF].pipe = 896; spca50x->mode_cam[CIF].method = 0; spca50x->mode_cam[CIF].mode = 2; 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 = 896; spca50x->mode_cam[QPAL].method = 1; spca50x->mode_cam[QPAL].mode = 2; 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 = 896; spca50x->mode_cam[QSIF].method = 1; spca50x->mode_cam[QSIF].mode = 2; break; case BRIDGE_SPCA533: memset (spca50x->mode_cam, 0x00, TOTMODE * sizeof(struct mwebcam)); spca50x->mode_cam[CUSTOM].width = 464; spca50x->mode_cam[CUSTOM].height = 480; spca50x->mode_cam[CUSTOM].t_palette = P_JPEG | P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[CUSTOM].pipe = 1023; spca50x->mode_cam[CUSTOM].method = 0; spca50x->mode_cam[CUSTOM].mode = 1; 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 = 1; 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 = 1; spca50x->mode_cam[CIF].width = 320; spca50x->mode_cam[CIF].height = 240; spca50x->mode_cam[CIF].t_palette = P_JPEG | P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[CIF].pipe = 1023; spca50x->mode_cam[CIF].method = 0; spca50x->mode_cam[CIF].mode = 2; 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 = 2; 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 = 2; break; case BRIDGE_SPCA504C: 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_JPEG | P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[VGA].pipe = 1023; spca50x->mode_cam[VGA].method = 0; spca50x->mode_cam[VGA].mode = 1; 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 = 1; spca50x->mode_cam[SIF].width = 352; spca50x->mode_cam[SIF].height = 288; spca50x->mode_cam[SIF].t_palette = P_JPEG | 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 = 2; spca50x->mode_cam[CIF].width = 320; spca50x->mode_cam[CIF].height = 240; spca50x->mode_cam[CIF].t_palette = P_JPEG | P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[CIF].pipe = 896; spca50x->mode_cam[CIF].method = 0; spca50x->mode_cam[CIF].mode = 3; 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 = 896; spca50x->mode_cam[QPAL].method = 1; spca50x->mode_cam[QPAL].mode = 3; spca50x->mode_cam[QSIF].width = 176; spca50x->mode_cam[QSIF].height = 144; spca50x->mode_cam[QSIF].t_palette = P_JPEG | P_RAW | P_YUV420 | P_RGB32 | P_RGB24 | P_RGB16; spca50x->mode_cam[QSIF].pipe = 768; spca50x->mode_cam[QSIF].method = 0; spca50x->mode_cam[QSIF].mode = 4; break; }return 0;}/****************************************************************************************/static voidspca504B_SetSizeType(struct usb_spca50x *spca50x ){ __u8 Size ; __u8 Type ; int rc; Size = spca50x->mode; Type = 0; switch (spca50x->bridge) { case BRIDGE_SPCA533: { spca5xxRegWrite(spca50x->dev,0x31,0 ,0 ,NULL ,0 ); spca504B_WaitCmdStatus(spca50x); rc = spca504B_PollingDataReady(spca50x->dev); spca50x_GetFirmware( spca50x ); Type = 2; spca5xxRegWrite(spca50x->dev,0x24,0 ,8 ,&Type ,1 ); spca5xxRegRead(spca50x->dev,0x24,0 ,8 ,&Type ,1 ); spca5xxRegWrite(spca50x->dev,0x25,0 ,4 ,&Size ,1 ); spca5xxRegRead(spca50x->dev,0x25,0 ,4 ,&Size ,1 ); rc = spca504B_PollingDataReady(spca50x->dev ); /* Init the cam width height with some values get on init ?*/ spca5xxRegWrite(spca50x->dev,0x31,0 ,4 ,NULL ,0 ); spca504B_WaitCmdStatus( spca50x ); rc = spca504B_PollingDataReady(spca50x->dev ); } break; case BRIDGE_SPCA504B: case BRIDGE_SPCA536: { Type = 6; spca5xxRegWrite(spca50x->dev,0x25,0 ,4 ,&Size ,1 ); spca5xxRegRead(spca50x->dev,0x25,0 ,4 ,&Size ,1 ); spca5xxRegWrite(spca50x->dev,0x27,0 ,0 ,&Type ,1 ); spca5xxRegRead(spca50x->dev,0x27,0 ,0 ,&Type ,1 ); rc = spca504B_PollingDataReady ( spca50x->dev ); } break; case BRIDGE_SPCA504: Size += 3; if (spca50x->desc == AiptekMiniPenCam13) { /* spca504a aiptek */ spca504A_acknowledged_command (spca50x, 0x8, Size, 0, (0x80 | (Size & 0x0F)), 1); spca504A_acknowledged_command (spca50x, 1, 3, 0, 0x9F, 0); } else { spca504_acknowledged_command (spca50x, 0x8, Size, 0); } break; case BRIDGE_SPCA504C: spca50x_reg_write (spca50x->dev, 0xa0, (0x0500 | (Size & 0x0F)), 0x0); // capture mode spca50x_reg_write (spca50x->dev, 0x20, 0x1, (0x0500 | (Size & 0x0F))); break; } return ;}static voidspca504_acknowledged_command(struct usb_spca50x *spca50x, __u16 reg, __u16 idx, __u16 val) { __u8 notdone = 0; spca50x_reg_write(spca50x->dev,reg,idx,val); notdone=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1); spca50x_reg_write(spca50x->dev,reg,idx,val); PDEBUG(5,"before wait 0x%x",notdone); wait_ms(200); notdone=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1); PDEBUG(5,"after wait 0x%x",notdone); return;}static voidspca504A_acknowledged_command(struct usb_spca50x *spca50x, __u16 reg, __u16 idx, __u16 val, __u8 stat, __u8 count) { __u8 status ; __u8 endcode; spca50x_reg_write(spca50x->dev,reg,idx,val); status=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1); endcode = stat ; PDEBUG(5,"Status 0x%x Need 0x%x",status, stat); if (count) { while (1){ wait_ms(10); /* gsmart mini2 write a each wait setting 1 ms is enought*/ //spca50x_reg_write(spca50x->dev,reg,idx,val); status=spca50x_reg_read(spca50x->dev, 0x01, 0x0001, 1); if (status == endcode) { PDEBUG(5,"status 0x%x after wait 0x%x",status,count); break; } count++; if(count > 200) break; } } return;}static voidspca504_wait_status(struct usb_spca50x *spca50x){ int ret = 256; do { /* With this we get the status, when return 0 it's all ok */ ret = spca50x_reg_read(spca50x->dev, 0x06, 0x00, 1); } while(ret--);}static voidspca50x_GetFirmware(struct usb_spca50x *spca50x){ __u8 FW[5] = {0,0,0,0,0}; __u8 ProductInfo[64]; spca5xxRegRead(spca50x->dev,0x20 ,0 ,0 ,FW ,5); PDEBUG(0, "FirmWare : %d %d %d %d %d ", FW[0],FW[1],FW[2],FW[3],FW[4] ); spca5xxRegRead(spca50x->dev,0x23 ,0 ,0 ,ProductInfo ,64); spca5xxRegRead(spca50x->dev,0x23 ,0 ,1 ,ProductInfo ,64); return ;}static intspca504B_PollingDataReady(struct usb_device *dev) { __u8 DataReady = 0 ; int count = 0; while(1) { spca5xxRegRead(dev,0x21,0, 0, &DataReady,1); if ( (DataReady & 0x01) == 0) break; wait_ms(10); count++; if (count > 10) break; } return DataReady;}static voidspca504B_WaitCmdStatus(struct usb_spca50x *spca50x){ __u8 DataReady = 0; int ReqDone; int count = 0; while (1) { spca5xxRegRead(spca50x->dev,0x21,0, 1, &DataReady,1); if ( DataReady ) { DataReady = 0; spca5xxRegWrite(spca50x->dev,0x21,0, 1, &DataReady, 1); spca5xxRegRead(spca50x->dev,0x21,0, 1, &DataReady, 1); ReqDone = spca504B_PollingDataReady(spca50x->dev); break ; } wait_ms (10); count++; if (count > 50) break; } return ;}static voidspca504B_setQtable ( struct usb_spca50x *spca50x ){ __u8 Data = 3 ; int rc ; spca5xxRegWrite(spca50x->dev,0x26,0 ,0 ,&Data ,1 ); spca5xxRegRead(spca50x->dev,0x26 ,0 ,0 , &Data ,1); rc = spca504B_PollingDataReady ( spca50x->dev ); return ;}static void sp5xx_initContBrigHueRegisters (struct usb_spca50x *spca50x){ int rc; int pollreg =1; switch (spca50x->bridge){ case BRIDGE_SPCA504: case BRIDGE_SPCA504C: pollreg = 0; case BRIDGE_SPCA533: case BRIDGE_SPCA504B: spca5xxRegWrite(spca50x->dev,0 ,0 ,0x21a7 ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0x20 ,0x21a8 ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0 ,0x21ad ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,1 ,0x21ac ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0x20 ,0x21ae ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0 ,0x21a3 ,NULL ,0 ); break; case BRIDGE_SPCA536: spca5xxRegWrite(spca50x->dev,0 ,0 ,0x20f0 ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0x21 ,0x20f1 ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0x40 ,0x20f5 ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,1 ,0x20f4 ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0x40 ,0x20f6 ,NULL ,0 ); spca5xxRegWrite(spca50x->dev,0 ,0 ,0x2089 ,NULL ,0 ); break; } if (pollreg) rc = spca504B_PollingDataReady( spca50x->dev ); return ;}#endif //SP5XXFW2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -