static int iWriteData(unsigned int  ui4_offset, unsigned int  ui4_length, unsigned char * pinputdata)
{
   int  i4RetValue = 0;
   int  i4ResidueDataLength;
   u32 u4IncOffset = 0;
   u32 u4CurrentOffset;
   u8 * pBuff;

   CAM_CALDB("[CAM_CAL] iWriteData\n" );


   if (ui4_offset + ui4_length >= 0x2000)
   {
      CAM_CALDB("[CAM_CAL] Write Error!! S-24CS64A not supprt address >= 0x2000!! \n" );
      return -1;
   }

   i4ResidueDataLength = (int)ui4_length;
   u4CurrentOffset = ui4_offset;
   pBuff = pinputdata;   
   CAM_CALDB("[CAM_CAL] iWriteData u4CurrentOffset is %d \n",u4CurrentOffset);   
   do 
   {
       if(i4ResidueDataLength >= 6)
       {
           i4RetValue = iWriteCAM_CAL((u16)u4CurrentOffset, 6, pBuff);
           if (i4RetValue != 0)
           {
                CAM_CALDB("[CAM_CAL] I2C iWriteData failed!! \n");
                return -1;
           }           
           u4IncOffset += 6;
           i4ResidueDataLength -= 6;
           u4CurrentOffset = ui4_offset + u4IncOffset;
           pBuff = pinputdata + u4IncOffset;
       }
       else
       {
           i4RetValue = iWriteCAM_CAL((u16)u4CurrentOffset, i4ResidueDataLength, pBuff);
           if (i4RetValue != 0)
           {
                CAM_CALDB("[CAM_CAL] I2C iWriteData failed!! \n");
                return -1;
           }            
           u4IncOffset += 6;
           i4ResidueDataLength -= 6;
           u4CurrentOffset = ui4_offset + u4IncOffset;
           pBuff = pinputdata + u4IncOffset;
           //break;
       }
   }while (i4ResidueDataLength > 0);
   CAM_CALDB("[CAM_CAL] iWriteData done\n" );
 
   return 0;
}
//Burst Write Data
static int iWriteData(unsigned int  ui4_offset, unsigned int  ui4_length, unsigned char * pinputdata)
{
   int  i4RetValue = 0;
   int  i4ResidueDataLength;
   u32 u4IncOffset = 0;
   u32 u4CurrentOffset;
   u8 * pBuff;
   CAM_CALDB("[S24CAM_CAL] iWriteData\n" );

   i4ResidueDataLength = (int)ui4_length;
   u4CurrentOffset = ui4_offset;
   pBuff = pinputdata;   

   CAM_CALDB("[CAM_CAL] iWriteData u4CurrentOffset is %d \n",u4CurrentOffset);   

   do 
   {
       CAM_CALDB("[CAM_CAL][iWriteData] Write 0x%x=0x%x \n",u4CurrentOffset, pBuff[0]);
       i4RetValue = iWriteCAM_CAL((u16)u4CurrentOffset, 1, pBuff[0]);
       if (i4RetValue != 0)
       {
            CAM_CALDB("[CAM_CAL] I2C iWriteData failed!! \n");
            return -1;
       }           
       u4IncOffset ++;
       i4ResidueDataLength --;
       u4CurrentOffset = ui4_offset + u4IncOffset;
       pBuff = pinputdata + u4IncOffset;
   }while (i4ResidueDataLength > 0);
   CAM_CALDB("[S24CAM_CAL] iWriteData done\n" );
 
   return 0;
}
//go to page
static kal_uint8 IMX135_GotoPage(kal_uint8 page)
{
	kal_uint8 rdrdy_status = 0;
	kal_uint8 checktimes = 2,i = 0;
	u8  readbuff ;
	int ret;
	for(i= 0; i<checktimes;i++)
	{
		iWriteCAM_CAL(0x3b02, 1 , page);
    	iWriteCAM_CAL(0x3b00,1, 0x01);
   		mdelay(2);
    	ret = iReadCAM_CAL(0x3b01,1,&readbuff);
		rdrdy_status = readbuff;
		if( rdrdy_status == 1)
		{			
			return 1;
		}
		else
		{
			CAM_CALDB("OTP fail!\n");
		}
	}
	return 0;	
}
Пример #4
0
//Burst Write Data
static int iWriteData(u8  ui4_offset, unsigned int  ui4_length, unsigned char * pinputdata)
{
   int  i4RetValue = 0;
   int  i4ResidueDataLength;
   u32 u4IncOffset = 0;
   u32 u4CurrentOffset;
   u8 * pBuff;
   u16 i2c_id = 0;
   CAM_CALDB("[S24CAM_CAL_SUB] iWriteData\n" );

   if (get_module_type() == SUNNY_MODULE)
	i2c_id = OV5670_SUNNY_DEVICE_ID;
   else if (get_module_type() == OFILM_MODULE)
	i2c_id = OV5670_OFILM_DEVICE_ID;
   else if (get_module_type() == QTECH_MODULE)
	i2c_id = OV5670_QTECH_DEVICE_ID;

   i4ResidueDataLength = (int)ui4_length;
   u4CurrentOffset = ui4_offset;
   pBuff = pinputdata;   

   CAM_CALDB("[CAM_CAL_SUB] iWriteData u4CurrentOffset is %d \n",u4CurrentOffset);   

   do 
   {
       CAM_CALDB("[CAM_CAL_SUB][iWriteData] Write 0x%x=0x%x \n",u4CurrentOffset, pBuff[0]);
       i4RetValue = iWriteCAM_CAL((u8)u4CurrentOffset, 1, pBuff[0], i2c_id);
       if (i4RetValue != 0)
       {
            CAM_CALDB("[CAM_CAL_SUB] I2C iWriteData failed!! \n");
            return -1;
       }           
       u4IncOffset ++;
       i4ResidueDataLength --;
       u4CurrentOffset = ui4_offset + u4IncOffset;
       pBuff = pinputdata + u4IncOffset;
   }while (i4ResidueDataLength > 0);
   CAM_CALDB("[S24CAM_CAL_SUB] iWriteData done\n" );
 
   return 0;
}