Example #1
0
/* Kirby: add new-style driver {*/
static int AF_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    int i4RetValue = 0;

    LOG_INF("Start\n");

    /* Kirby: add new-style driver { */
    g_pstAF_I2Cclient = client;

    g_pstAF_I2Cclient->addr = I2C_SLAVE_ADDRESS;

    g_pstAF_I2Cclient->addr = g_pstAF_I2Cclient->addr >> 1;

    //Register char driver
    i4RetValue = Register_AF_CharDrv();

    if(i4RetValue){

        LOG_INF(" register char device failed!\n");

        return i4RetValue;
    }

    spin_lock_init(&g_AF_SpinLock);

    LOG_INF("Attached!! \n");

    return 0;
}
/* Q1 : Try release multiple times. */
int BU6424AF_Release(struct inode *a_pstInode, struct file *a_pstFile)
{
	LOG_INF("Start\n");

	if (*g_pAF_Opened == 2) {
		char puSendCmd[2];

		puSendCmd[0] = (char)(0x00);
		puSendCmd[1] = (char)(0x00);
		i2c_master_send(g_pstAF_I2Cclient, puSendCmd, 2);
		LOG_INF("Wait\n");
		/*s4AF_WriteReg(200);
		msleep(20);
		s4AF_WriteReg(100);
		msleep(20);*/
	}

	if (*g_pAF_Opened) {
		LOG_INF("Free\n");

		spin_lock(g_pAF_SpinLock);
		*g_pAF_Opened = 0;
		spin_unlock(g_pAF_SpinLock);
	}

	LOG_INF("End\n");

	return 0;
}
Example #3
0
int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data *const cfg)
{
	u8_t ep_idx = EP_ADDR2IDX(cfg->ep_addr);

	if ((cfg->ep_type == USB_DC_EP_CONTROL) && ep_idx) {
		LOG_ERR("invalid endpoint configuration");
		return -1;
	}

	if (ep_idx >= NUM_OF_EP_MAX) {
		LOG_ERR("endpoint index/address out of range");
		return -1;
	}

	if (ep_idx & BIT(0)) {
		if (EP_ADDR2DIR(cfg->ep_addr) != USB_EP_DIR_IN) {
			LOG_INF("pre-selected as IN endpoint");
			return -1;
		}
	} else {
		if (EP_ADDR2DIR(cfg->ep_addr) != USB_EP_DIR_OUT) {
			LOG_INF("pre-selected as OUT endpoint");
			return -1;
		}
	}

	return 0;
}
//  *****************************************************
//  **** Read from the Peripheral register < 82h >
//  **** ------------------------------------------------
//  **** CL_UBYTE    adr    Peripheral Address
//  **** CL_UWORD    dat    Read data
//  *****************************************************
static CL_UWORD    I2C_read__FBAF( CL_UBYTE u08_adr )
{
        int  i4RetValue = 0;
    char pBuff[1] = {(char)(u08_adr & 0xFF)};
    CL_UWORD vRcvBuff=0;
        spin_lock(&g_AF_SpinLock);
    g_pstAF_I2Cclient->addr = (I2C_SLAVE_ADDRESS >> 1);
         g_pstAF_I2Cclient->ext_flag = (g_pstAF_I2Cclient->ext_flag)&(~I2C_DMA_FLAG);
        spin_unlock(&g_AF_SpinLock);

    i4RetValue = i2c_master_send(g_pstAF_I2Cclient, pBuff, 1);
    if (i4RetValue < 0 )
    {
        LOG_INF("[CAMERA SENSOR] read I2C send failed!!\n");
        return i4RetValue;
    }

    i4RetValue = i2c_master_recv(g_pstAF_I2Cclient, (u8*)&vRcvBuff, 2);
    if (i4RetValue != 2)
    {
        LOG_INF("[CAMERA SENSOR] I2C read failed!! \n");
        return i4RetValue;
    }
    //vRcvBuff=    ((vRcvBuff&0xFF) <<8) + ((vRcvBuff>> 8)&0xFF) ;
      vRcvBuff=((vRcvBuff<<8)&0xff00)|((vRcvBuff>>8)&0x00ff);

    LOG_INF("I2C r2 (%x %x) \n",u08_adr,vRcvBuff);

    return vRcvBuff;

}
Example #5
0
/**
 * Constructor for the combi combiroutes
 * @param n		number of combi combiroutes to be created
 * @exception		Calls exit if no RAM available
 */
void combiroutes(const unsigned short nr)
{
	unsigned short		i, j;
	struct sCombiroute *	pCombiroute;

	LOG_INF("started");
	
	m_nrCombiroutes = nr;
	m_pCombiroutes = malloc(m_nrCombiroutes * sizeof(struct sCombiroute));
	if(NULL == m_pCombiroutes) 
	{
		/* error allocating */
		LOG_ERR("cannot allocate RAM of train combiroutes");
		exit(EXIT_FAILURE);
	}
	pCombiroute = m_pCombiroutes;
	for(i = 0; i < m_nrCombiroutes; i++)
	{
		pCombiroute->name[0]	= '\0';
		pCombiroute->start	= NULL;
		pCombiroute->dest	= NULL;
		pCombiroute->partsAddPosition	= 0;

		for(j = 0; j < NRCOMBIPARTS; j++)
		{
			pCombiroute->pRoute[j]	= NULL;
		}

		pCombiroute++;
	}

	LOG_INF("ended");
}
/*************************************************************************************************
* Function    :  otp_wb_update
* Description :  Update WB correction
* Return      :  [bool] 0 : OTP data fail
                        1 : otp_WB update success
**************************************************************************************************/
bool otp_wb_update(BYTE zone)
{
    USHORT golden_g, current_g;


    if(!get_otp_wb(zone))  // get wb data from otp
    {
        LOG_INF("Get OTP WB data Err!\n");
        return 0;
    }

    golden_g = (golden_gr + golden_gb) / 2;
    current_g = (current_gr + current_gb) / 2;

    if(!golden_g || !current_g || !golden_r || !golden_b || !current_r || !current_b)
    {
        LOG_INF("WB update Err !\n");
        return 0;
    }

    r_ratio = 512 * golden_r * current_g /( golden_g * current_r );
    b_ratio = 512 * golden_b * current_g /( golden_g * current_b );

    wb_gain_set();

    LOG_INF("OTP WB update finished! \n");

    return 1;
}
Example #7
0
//Main jobs:
// 1.check for device-specified errors, device not ready.
// 2.Initialize the device if it is opened for the first time.
// 3.Update f_op pointer.
// 4.Fill data structures into private_data
//CAM_RESET
static int AF_Open(struct inode * a_pstInode, struct file * a_pstFile)
{
    LOG_INF("Start \n");


    if(g_s4AF_Opened)
    {
        LOG_INF("The device is opened \n");
        return -EBUSY;
    }

    spin_lock(&g_AF_SpinLock);
    g_s4AF_Opened = 1;
    spin_unlock(&g_AF_SpinLock);
    I2C_func_POFF_____( );                    // reset the IC
    I2C_func_PON______( );                    // Power ON

    func_INITIALIZE( );                        // initialize the IC
    func_ReLOAD_FACT_DATA( );                // ReLoad Adjustment Data
    I2C_func_DSP_START( );                    // CLAF Function Enable

    EQ_CONTROL( 0x0004 );

    LOG_INF("End \n");
    return 0;
}
Example #8
0
//Main jobs:
// 1.Deallocate anything that "open" allocated in private_data.
// 2.Shut down the device on last close.
// 3.Only called once on last time.
// Q1 : Try release multiple times.
static int AF_Release(struct inode * a_pstInode, struct file * a_pstFile)
{
    LOG_INF("Start \n");

    if (g_s4AF_Opened == 2)
    {
        g_sr = 5;
        s4AF_WriteReg(200);
        msleep(10);
        s4AF_WriteReg(100);
        msleep(10);
    }

    if (g_s4AF_Opened)
    {
        LOG_INF("Free \n");

        spin_lock(&g_AF_SpinLock);
        g_s4AF_Opened = 0;
         g_sr = 5;
        spin_unlock(&g_AF_SpinLock);
    }    

    LOG_INF("End \n");

    return 0;
}
Example #9
0
/**
 * Constructor for the sections
 * @param nr		number of sections to be created
 * @exception       Calls exit if no RAM available
 */
void sections(const unsigned short nr) 
{
	unsigned short	i, j;
	struct sSection *	ptr;

	LOG_INF("started");
	
	m_nrSection = nr;
	m_pSection = malloc(m_nrSection * sizeof(struct sSection));
	if(NULL == m_pSection) 
	{
		/* error allocating */
		LOG_ERR("cannot allocate RAM of sections");
		exit(EXIT_FAILURE);
	}
	ptr = m_pSection;
	for(i = 0; i < m_nrSection; i++)
	{
		ptr->name[0]	= '\0';
		ptr->BI_occDetector	= NONEVALUE;
		ptr->DuoledAddPosition	= 0;
		ptr->line	= neutral;
		ptr->linePrev	= neutral;
		ptr->free	= false;
		ptr->wasFree	= false;
		ptr->route	= false;
		ptr->wasRoute	= false;
		for(j = 0; j < NRBLOCKPL; j++)
		{
			ptr->pDuoled[j] = NULL;
		}
		ptr++;
	}		
	LOG_INF("ended");
}
Example #10
0
void commInit(void) 
{
	LOG_INF("started");
	sockKill = false;
	pthread_create(& sockThread, NULL, sockFunction, (void *) sock);

	LOG_INF("ended");
}
Example #11
0
//-----------------------------------------------------------------------------
MBOOL TdriMgrImp::uninit(void)
{
    MBOOL Result = MTRUE;
    int i;
    //
    GLOBAL_PROFILING_LOG_PRINT(__func__);
    GLOBAL_PROFILING_LOG_PRINT("Uninit TdriMgr");
    //
    Mutex::Autolock lock(mLock);
    //
    LOG_INF("mInitCount(%d)",mInitCount);
    //
    android_atomic_dec(&mInitCount);
    //
    if(mInitCount > 0) {
        goto EXIT;
    }


    for(i=TPIPE_DRV_CQ01; i<=TPIPE_DRV_CQ02; i++) {
        if(i == TPIPE_DRV_CQ01) {
            pIspDrv->lockSemaphoreCq1();
            tdriMgrInfo[i].pDescriptorArray = NULL;
            tdriMgrInfo[i].pDesriptorNum = 0;
            tdriMgrInfo[i].pTopCtlEn1 = 0;
            tdriMgrInfo[i].pTopCtlEn2 = 0;
            tdriMgrInfo[i].pTopCtlDma = 0;
            pIspDrv->unlockSemaphoreCq1();
        } else if (i == TPIPE_DRV_CQ02) {
            pIspDrv->lockSemaphoreCq2();
            tdriMgrInfo[i].pDescriptorArray = NULL;
            tdriMgrInfo[i].pDesriptorNum = 0;
            tdriMgrInfo[i].pTopCtlEn1 = 0;
            tdriMgrInfo[i].pTopCtlEn2 = 0;
            tdriMgrInfo[i].pTopCtlDma = 0;
            pIspDrv->unlockSemaphoreCq2();
        } else {
            LOG_ERR("[ERROR]not support this tdri cq(%d) number \n");
        }
    }


    //tpipe driver
    pTdriDri->uninit();
    pTdriDri->destroyInstance();
    pTdriDri = NULL;

    //isp drv
    pIspDrv->setCallbacks(NULL, NULL);
    pIspDrv->uninit();
    pIspDrv->destroyInstance();
    pIspDrv = NULL;

    LOG_INF("Release\n");

EXIT:
    return Result;
}
Example #12
0
//-----------------------------------------------------------------------------
MBOOL
TdriMgrImp::
flushSetting(
    ISP_DRV_CQ_ENUM ispCq
)
{
    LOCAL_PROFILING_LOG_AUTO_START(Event_TdriMgr);
    LOCAL_PROFILING_LOG_PRINT("flushSetting");

    LOG_INF("E:Cq(%d)",ispCq);
    //
    if(tdriMgrCqMap[ispCq].tdriMgrCQ == TPIPE_DRV_CQ01) {
        pIspDrv->lockSemaphoreCq1();
        // flush setting
        ::memset((char*)&tdriMgrInfo[TPIPE_DRV_CQ01].tdriTurningSetting, 0x00, sizeof(TDRI_MGR_TPIPE_TABLE_TURNING));
        ::memset((char*)&tdriMgrInfo[TPIPE_DRV_CQ01].tdriMgrCfg, 0x00, sizeof(TdriDrvCfg));
        tdriMgrInfo[TPIPE_DRV_CQ01].tdriMgrCfg.updateTdri.updateType = TPIPE_DRV_UPDATE_TYPE_CQ1_TURNING_SAVE;
        refreshTableSetting(TPIPE_DRV_CQ01, 0xffffffff);  // refresh all setting
        tdriMgrInfo[TPIPE_DRV_CQ01].tdriMgrCfg.updateTdri.partUpdateFlag = 0xffffffff; // clean Tpipe update flag
        handleTpipeTable(TPIPE_DRV_CQ01);

        pIspDrv->setTurnTopEn1(ISP_DRV_CQ01, ISP_DRV_TURNING_TOP_RESET);
        pIspDrv->setTurnTopEn2(ISP_DRV_CQ01, ISP_DRV_TURNING_TOP_RESET);
        pIspDrv->setTurnTopDma(ISP_DRV_CQ01, ISP_DRV_TURNING_TOP_RESET);
        pIspDrv->flushTurnCqTable(ISP_DRV_CQ01);
        //
        pIspDrv->unlockSemaphoreCq1();
    }
    else if(tdriMgrCqMap[ispCq].tdriMgrCQ == TPIPE_DRV_CQ02) {
        pIspDrv->lockSemaphoreCq2();
        // flush setting
        ::memset((char*)&tdriMgrInfo[TPIPE_DRV_CQ02].tdriTurningSetting, 0x00, sizeof(TDRI_MGR_TPIPE_TABLE_TURNING));
        ::memset((char*)&tdriMgrInfo[TPIPE_DRV_CQ02].tdriMgrCfg, 0x00, sizeof(TdriDrvCfg));
        tdriMgrInfo[TPIPE_DRV_CQ02].tdriMgrCfg.updateTdri.updateType = TPIPE_DRV_UPDATE_TYPE_CQ2_TURNING_SAVE;
        refreshTableSetting(TPIPE_DRV_CQ02, 0xffffffff);  // refresh all setting
        tdriMgrInfo[TPIPE_DRV_CQ02].tdriMgrCfg.updateTdri.partUpdateFlag = 0xffffffff; // clean Tpipe update flag
        handleTpipeTable(TPIPE_DRV_CQ02);


        pIspDrv->setTurnTopEn1(ISP_DRV_CQ02, ISP_DRV_TURNING_TOP_RESET);
        pIspDrv->setTurnTopEn2(ISP_DRV_CQ02, ISP_DRV_TURNING_TOP_RESET);
        pIspDrv->setTurnTopDma(ISP_DRV_CQ02, ISP_DRV_TURNING_TOP_RESET);
        pIspDrv->flushTurnCqTable(ISP_DRV_CQ02);
        //
        pIspDrv->unlockSemaphoreCq2();
    }
    else {
        LOG_WRN("not support this tMgrCq(%d) for flush",tdriMgrCqMap[ispCq].tdriMgrCQ);
        return MFALSE;
    }

    LOG_INF("X\n",ispCq);
    LOCAL_PROFILING_LOG_PRINT("End flushSetting");

    return MTRUE;

}
/*************************************************************************************************
* Function    :  otp_update()
* Description :  update otp data from otp , it otp data is valid,
                 it include get ID and WB update function
* Return      :  [bool] 0 : update fail
                        1 : update success
**************************************************************************************************/
bool otp_update(BYTE update_sensor_otp_awb, BYTE update_sensor_otp_lsc)
{
    BYTE zone = 0x01;
    BYTE FLG  = 0x00;
    BYTE MID = 0x00;
    int i;

    LOG_INF("update_sensor_otp_awb: %d, update_sensor_otp_lsc: %d\n", update_sensor_otp_awb, update_sensor_otp_lsc );

    for(i=0;i<3;i++)
    {
        FLG = get_otp_flag(zone);
        if(FLG == VALID_OTP)
            break;
        else
            zone++;
    }
    if(i==3)
    {
        LOG_INF("No OTP Data or OTP data is invalid!!!\n");
        return 0;
    }

    MID =     get_otp_module_id(zone);
#ifdef DEBUG_IMX135_OTP
    get_otp_lens_id(zone);
    get_otp_vcm_id(zone);
#endif

    if(MID != TRULY_ID) //Select
    {
        LOG_INF("No Truly Module !!!!\n");
        return 0;
    }

    if(0 != update_sensor_otp_awb && _otp_awb_set == 0) {
        if(otp_wb_update(zone)){
  		    spin_lock(&imx135_otp_lock);
            _otp_awb_set = 1;
            spin_unlock(&imx135_otp_lock);
        }
    }


    if(0 != update_sensor_otp_lsc && _otp_lsc_set == 0)
    {
        if(!otp_lenc_update())
        {
            LOG_INF("OTP Update LSC Err\n");
            return 0;
        }
		spin_lock(&imx135_otp_lock);
        _otp_lsc_set = 1;
     	spin_unlock(&imx135_otp_lock);
    }
    return 1;
}
Example #14
0
/** 
 * Destructor. 
 *
 * To free the allocated RAM, call this function before terminating the program.
 */
void duoledDestroy(void) 
{
	LOG_INF("started");
	free(m_pDuoled);
	m_pDuoled = NULL;
	m_nrDuoled = 0;
	m_DuoledAddPosition = 0;
	LOG_INF("ended");
}
Example #15
0
MdpMgr *MdpMgr::createInstance()
{
    LOG_INF("+");

    DBG_LOG_CONFIG(imageio, mdpmgr);
    static MdpMgrImp singleton;

    LOG_INF("-");    
    return &singleton;
}
Example #16
0
void
display_windows_ce_infos (void)
{
  Uint32 i;
  char *param;
  WCHAR wparam[PARAMAX_LEN + 1];
  OSVERSIONINFO vinfo;
  static const char *action_names[] = {
    "SPI_GETPLATFORMMANUFACTURER",
    "SPI_GETPLATFORMNAME",
    "SPI_GETPLATFORMTYPE"
  };
  static const Uint32 actions[] = {
    SPI_GETPLATFORMMANUFACTURER,
    SPI_GETPLATFORMNAME,
    SPI_GETPLATFORMTYPE
  };
  for (i = 0; i < sizeof (actions) / sizeof (Uint32); i++)
    {
      if (SystemParametersInfo (actions[i], PARAMAX_LEN, wparam, 0) == FALSE)
        {
          LOG_ERR ("SystemParametersInfo(%s) "
                   "failed (error %i)", action_names[i], GetLastError ());
          continue;
        }
      param = wide_char_to_bytes (wparam, 0, CP_ACP);
      if (param == NULL)
        {
          continue;
        }
      LOG_INF ("%s %s", action_names[i], param);
      free_memory (param);
    }

  if (GetVersionEx (&vinfo) == FALSE)
    {
      LOG_ERR ("GetVersionEx() " "failed (error %i)", GetLastError ());
    }
  else
    {
      if (vinfo.dwPlatformId != VER_PLATFORM_WIN32_CE)
        {
          LOG_ERR ("this system is not a Windows Embedded CE OS");
        }
      else
        {
          LOG_INF ("Windows Mobile %i.%i", vinfo.dwMajorVersion,
                   vinfo.dwMinorVersion);
        }
    }

  LOG_INF ("SM_CXSCREEN: %i; SM_CYSCREEN: %i",
           GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN));
}
Example #17
0
void commDestroy(void) 
{
	void * ptr;
	
	LOG_INF("started");
	sockKill = true;
	pthread_join(sockThread, & ptr);
	free(pOutString);
	free(pInString);
	LOG_INF("ended");
}
Example #18
0
/**
 * Init function for the sections
 *
 * Here, all sections are initialised according to the state of the occupancy
 * detectors.
 */
void sectionsInit(void) 
{
	struct sSection *		ptr = m_pSection;  
	struct sDuoled *	pDuoled;
	unsigned short 		i;
	unsigned short 		j;
	LOG_INF("started");
	
	/* Note: all vars are initialised, also the ones which are not
	 * used anymore, e.g. slave sections
	 */
	assert(NULL != ptr);
	for (i = 0; i < m_nrSection; i++) 
	{
		ptr->route         = false;
		ptr->wasRoute      = false;
		ptr->line          = neutral;
		ptr->linePrev      = neutral;
		j = 0;
		while(NULL != (pDuoled = sectionGetDuoled(ptr, j)))
		{
			duoledSetMode(pDuoled, ledOff);
			j++;
		}
		/* check if there are occupied sections and set the color on the 
		 * desk accordingly
		 */
		if(registerBitGet(ptr->BI_occDetector)) 
		{
			ptr->free = false;
			ptr->wasFree = false;
			j = 0;
			while(NULL != (pDuoled = sectionGetDuoled(ptr, j)))
			{
				duoledSetOccupied(pDuoled, true);
				j++;
			}
		}
		else 
		{
			ptr->free = true;
			ptr->wasFree = true;
			j = 0;
			while(NULL != (pDuoled = sectionGetDuoled(ptr, j)))
			{
				duoledSetOccupied(pDuoled, false);
				j++;
			}
		}
		ptr++;
	}
	LOG_INF("ended"); 
}
/*************************************************************************************************
* Function    :  get_otp_lens_id
* Description :  get otp LENS_ID value
* Parameters  :  [BYTE] zone : OTP PAGE index , 0x00~0x0f
* Return      :  [BYTE] 0 : OTP data fail
                 other value : LENS ID data
**************************************************************************************************/
BYTE get_otp_lens_id(BYTE zone)
{
    BYTE lens_id = 0;
    if(!start_read_otp(zone))
    {
        LOG_INF("Start read Page %d Fail!\n", zone);
        return 0;
    }
    lens_id = read_cmos_sensor(0x3B09);
    LOG_INF("OTP_Lens ID: 0x%02x.\n",lens_id);
    return lens_id;
}
/*************************************************************************************************
* Function    :  get_light_id
* Description :  get otp environment light temperature value
* Parameters  :  [BYTE] zone : OTP PAGE index , 0x00~0x0f
* Return      :  [BYTE] 0 : OTP data fail
                        other value : driver ID data
                        BIT0:D65(6500K) EN
                        BIT1:D50(5100K) EN
                        BIT2:CWF(4000K) EN
                        BIT3:A Light(2800K) EN
**************************************************************************************************/
BYTE get_light_id(BYTE zone)
{
    BYTE light_id = 0;
    if(!start_read_otp(zone))
    {
        LOG_INF("Start read Page %d Fail!\n", zone);
        return 0;
    }
    light_id = read_cmos_sensor(0x3B0C);
    LOG_INF("OTP_Light ID: 0x%02x.\n",light_id);
    return light_id;
}
/*************************************************************************************************
* Function    :  get_otp_driver_id
* Description :  get otp driver id value
* Parameters  :  [BYTE] zone : OTP PAGE index , 0x00~0x0f
* Return      :  [BYTE] 0 : OTP data fail
                 other value : driver ID data
**************************************************************************************************/
BYTE get_otp_driver_id(BYTE zone)
{
    BYTE driver_id = 0;
    if(!start_read_otp(zone))
    {
        LOG_INF("Start read Page %d Fail!\n", zone);
        return 0;
    }
    driver_id = read_cmos_sensor(0x3B0B);
    LOG_INF("OTP_Driver ID: 0x%02x.\n",driver_id);
    return driver_id;
}
/*************************************************************************************************
* Function    :  get_otp_vcm_id
* Description :  get otp VCM_ID value
* Parameters  :  [BYTE] zone : OTP PAGE index , 0x00~0x0f
* Return      :  [BYTE] 0 : OTP data fail
                 other value : VCM ID data
**************************************************************************************************/
BYTE get_otp_vcm_id(BYTE zone)
{
    BYTE vcm_id = 0;
    if(!start_read_otp(zone))
    {
        LOG_INF("Start read Page %d Fail!\n", zone);
        return 0;
    }
    vcm_id = read_cmos_sensor(0x3B0A);
    LOG_INF("OTP_VCM ID: 0x%02x.\n",vcm_id);
    return vcm_id;
}
/*************************************************************************************************
* Function    :  get_otp_module_id
* Description :  get otp MID value
* Parameters  :  [BYTE] zone : OTP PAGE index , 0x00~0x0f
* Return      :  [BYTE] 0 : OTP data fail
                 other value : module ID data , TRULY ID is 0x0001
**************************************************************************************************/
BYTE get_otp_module_id(BYTE zone)
{
    BYTE module_id = 0;
    if(!start_read_otp(zone))
    {
        LOG_INF("OTP Start read Page %d Fail!\n", zone);
        return 0;
    }
    module_id = read_cmos_sensor(0x3B05);
    LOG_INF("OTP_Module ID: 0x%02x.\n",module_id);
    return module_id;
}
static inline int moveAF(unsigned long a_u4Position)
{
	int ret = 0;

	if ((a_u4Position > g_u4AF_MACRO) || (a_u4Position < g_u4AF_INF)) {
		LOG_INF("out of range\n");
		return -EINVAL;
	}

	if (*g_pAF_Opened == 1) {
		unsigned short InitPos;

		ret = s4AF_ReadReg(&InitPos);

		if (ret == 0) {
			LOG_INF("Init Pos %6d\n", InitPos);

			spin_lock(g_pAF_SpinLock);
			g_u4CurrPosition = (unsigned long)InitPos;
			spin_unlock(g_pAF_SpinLock);

		} else {
			spin_lock(g_pAF_SpinLock);
			g_u4CurrPosition = 0;
			spin_unlock(g_pAF_SpinLock);
		}

		spin_lock(g_pAF_SpinLock);
		*g_pAF_Opened = 2;
		spin_unlock(g_pAF_SpinLock);
	}

	if (g_u4CurrPosition == a_u4Position)
		return 0;

	spin_lock(g_pAF_SpinLock);
	g_u4TargetPosition = a_u4Position;
	spin_unlock(g_pAF_SpinLock);

	/* LOG_INF("move [curr] %d [target] %d\n", g_u4CurrPosition, g_u4TargetPosition); */


	if (s4AF_WriteReg((unsigned short)g_u4TargetPosition) == 0) {
		spin_lock(g_pAF_SpinLock);
		g_u4CurrPosition = (unsigned long)g_u4TargetPosition;
		spin_unlock(g_pAF_SpinLock);
	} else {
		LOG_INF("set I2C failed when moving the motor\n");
	}

	return 0;
}
Example #25
0
/**
 * Destructor for the train combiroutes
 */
void combiroutesDestroy(void) 
{
	LOG_INF("started");
	if(NULL == m_pCombiroutes) 
	{
		LOG_INF("zero pointer, terminate");
		return;
	}
	LOG_INF("release RAM of train combiroutes");
	free(m_pCombiroutes);
	m_pCombiroutes = NULL;
	LOG_INF("ended");
}
/*************************************************************************************************
* Function    :  get_lsc_flag
* Description :  get LSC WRITTEN_FLAG
* Return      :  [BYTE], if 0x40 , this type has valid lsc data, otherwise, invalid otp data
**************************************************************************************************/
BYTE get_lsc_flag()
{
    BYTE flag = 0;
    if(!start_read_otp(0x0B))
    {
        LOG_INF("Start read Page 0x0B Fail!\n");
        return 0;
    }
    flag = read_cmos_sensor(0x3B43);
    flag = flag & 0xc0;
    LOG_INF("OTP Flag:0x%02x",flag );
    return flag;
}
Example #27
0
/**
 * Destructor for the sections
 */
void sectionsDestroy(void) 
{
	LOG_INF("started");
	if(NULL == m_pSection) 
	{
		LOG_INF("zero pointer, terminate");
		return;
	}
	LOG_INF("release RAM of sections");
	free(m_pSection);
	m_pSection = NULL;
	LOG_INF("ended");
}
/*************************************************************************************************
* Function    :  get_otp_flag
* Description :  get otp WRITTEN_FLAG
* Parameters  :  [BYTE] zone : OTP PAGE index , 0x00~0x0f
* Return      :  [BYTE], if 0x40 , this type has valid otp data, otherwise, invalid otp data
**************************************************************************************************/
BYTE get_otp_flag(BYTE zone)
{
    BYTE flag = 0;
    if(!start_read_otp(zone))
    {
        LOG_INF("Start read Page %d Fail!\n", zone);
        return 0;
    }
    flag = read_cmos_sensor(0x3B04);
    flag = flag & 0xc0;
    LOG_INF("OTP Flag:0x%02x\n",flag );
    return flag;
}
Example #29
0
MdpMgrImp::MdpMgrImp()
            :MdpMgr()
            ,mUser(0)            
{
    LOG_INF("+");
    
    for(MINT32 i = 0; i < DPSTREAM_NUM; i++)
    {
        m_pCq1DpStream[i] = NULL;
        m_pCq2DpStream[i] = NULL;
    }

    LOG_INF("-");
}
Example #30
0
inline static void Unregister_AF_CharDrv(void)
{
    LOG_INF("Start\n");

    //Release char driver
    cdev_del(g_pAF_CharDrv);

    unregister_chrdev_region(g_AF_devno, 1);

    device_destroy(actuator_class, g_AF_devno);

    class_destroy(actuator_class);

    LOG_INF("End\n");
}