// ============================================================================ // camerap_CheckProductId // ---------------------------------------------------------------------------- /// read sensor id,compare with define sensor id /// @return #TRUE, #FALSE // ============================================================================ PRIVATE BOOL camerap_CheckProductId() { UINT8 cameraID=0; camerap_Reserve(NULL); #ifdef I2C_BASED_ON_GPIO gpio_i2c_open(); #else g_camdI2cBusId = tgt_GetCamdConfig()->i2cBusId; hal_I2cOpen(g_camdI2cBusId); #endif HAL_CAMERA_CFG_T CamConfig = {0,}; CamConfig.rstActiveH = FALSE; CamConfig.pdnActiveH = TRUE; CamConfig.dropFrame = FALSE; CamConfig.camClkDiv = 6; // 156MHz/6 = 26MHz CamConfig.endianess = NO_SWAP;//BYTE_SWAP;// CamConfig.colRatio= COL_RATIO_1_1; CamConfig.rowRatio= ROW_RATIO_1_1; CamConfig.camId = camera_GetCameraID(); hal_CameraOpen(&CamConfig); hal_CameraReset(TRUE); // set reset to low // Enable Camera LDO pmd_EnablePower(PMD_POWER_CAMERA,TRUE); hal_TimDelay(819); // delay 5ms for stable reset low signal hal_CameraPowerDown(FALSE); if (gSensorInfo.snrrst) { } else { hal_CameraReset(FALSE); } //before read,must delay for sensor camerap_Delay(20); cameraID=camerap_GetId(); // Disable Camera Interface Module hal_CameraClose(); // Disable I2C #ifdef I2C_BASED_ON_GPIO gpio_i2c_close(); #else hal_I2cClose(g_camdI2cBusId); #endif // Disable the LDO for the camera pmd_EnablePower(PMD_POWER_CAMERA,FALSE); SXS_TRACE(TSTDOUT,"byd3703(0x%02x): read id is 0x%02x", CAM_BYD3703_ID, cameraID); if(cameraID == CAM_BYD3703_ID) return TRUE; else return FALSE; }
VOID I2C_Open(VOID) { #ifdef I2C_BASED_ON_GPIO gpio_i2c_open(); #else g_btdI2cBusId = tgt_GetBtdConfig()->i2cBusId; hal_I2cOpen(g_btdI2cBusId); #endif return; }
// The camera will be powered on in a particular mode specified here // Later, when the video capture or image capture is 'prepared', the frame buffer size // must correspond to the size here unless the format is changed. PRIVATE void camerap_PowerOn(CAM_SIZE_T CamOutSize, UINT16 IspOutWidth, UINT16 IspOutHeight, CAM_FORMAT_T Format) { // Turn on any power required for camera // Enable the Camera Interface Module // Turn on the Camera // Reset & initialize the Camera HAL_CAMERA_CFG_T CamConfig = {0,}; HAL_CAMERA_IRQ_CAUSE_T mask = {0,0,0,0}; UINT16 camOutWidth = 0, camOutHeight = 0; if (CamOutSize == CAM_NPIX_VGA) { camOutWidth = 640; camOutHeight = 480; } else if (CamOutSize == CAM_NPIX_QVGA) { camOutWidth = 320; camOutHeight = 240; } else if (CamOutSize == CAM_NPIX_QQVGA) { camOutWidth = 160; camOutHeight = 120; } else { SXS_TRACE(TSTDOUT,"DRV_CAM: Unsupported CAM Out Size"); return; } if ((camOutWidth < IspOutWidth) || (camOutHeight < IspOutHeight)) { SXS_TRACE(TSTDOUT,"DRV_CAM: ISP out is larger than Cam Out"); return; } s_camOpened = FALSE; #ifdef I2C_BASED_ON_GPIO gpio_i2c_open(); #else g_camdI2cBusId = tgt_GetCamdConfig()->i2cBusId; hal_I2cOpen(g_camdI2cBusId); #endif CamConfig.rstActiveH = FALSE; CamConfig.pdnActiveH = TRUE; CamConfig.dropFrame = FALSE; CamConfig.camClkDiv = 6; // 156MHz/6 = 26MHz CamConfig.endianess = NO_SWAP;//BYTE_SWAP;// CamConfig.camId = camera_GetCameraID(); CamConfig.cropEnable = FALSE; #if CAM_ISP_FUNC if ((camOutWidth > IspOutWidth) || (camOutHeight > IspOutHeight)) { CamConfig.dstWinColStart = ((camOutWidth - IspOutWidth)/2)&0xFFF; CamConfig.dstWinColEnd = (CamConfig.dstWinColStart + IspOutWidth - 1)&0xFFF; CamConfig.dstWinRowStart = ((camOutHeight - IspOutHeight)/2)&0xFFF; CamConfig.dstWinRowEnd = (CamConfig.dstWinRowStart + IspOutHeight - 1)&0xFFF; CamConfig.cropEnable = TRUE; } CamConfig.colRatio= COL_RATIO_1_1; CamConfig.rowRatio= ROW_RATIO_1_1; #else UINT32 ratioCol = camOutWidth / IspOutWidth; UINT32 ratioRow = camOutHeight / IspOutHeight; if ((ratioCol*IspOutWidth == camOutWidth) && (ratioRow*IspOutHeight == camOutHeight)) { CamConfig.colRatio= ratioCol - 1; CamConfig.rowRatio= ratioRow - 1; if (ratioCol != 1 && ratioRow != 1) CamConfig.reOrder = 4; } else { SXS_TRACE(TSTDOUT, "DRV_CAM: failed to set decimation, %d, %d, %d, %d", camOutWidth, IspOutWidth, camOutHeight, IspOutHeight); //hal_HstSendEvent(0x20); return; } #endif // Enable Camera LDO pmd_EnablePower(PMD_POWER_CAMERA, TRUE); hal_CameraOpen(&CamConfig); s_camOpened = TRUE; hal_CameraIrqSetMask(mask); hal_CameraPowerDown(FALSE); if (gSensorInfo.snrrst) { // Toggle the reset bit } else { // Just bring the sensor out of reset // hal_CameraReset(TRUE, FALSE); hal_CameraReset(FALSE); } // Should use CamOutSize and Format to decide which sequence to use // CamOutSize and Format may be changed later but the camera and IFC need // to be stopped and the IFC and camera re-enabled in the correct order // Power On seq // After this, the camera will start sending data to the camera module. The IFC will // need to be started at the correct time (typically after the end of frame interrupt // so the data will be properly synchronized in the buffer if (CamOutSize == CAM_NPIX_VGA) { camerap_SendRgSeq(RG_InitPowerOnVga, (sizeof(RG_InitPowerOnVga) / sizeof(CAM_REG_T))); #ifdef TGT_GALLITE_G800 if(CamConfig.camId==1) { //for t800 camerap_WriteOneReg( 0x0f , 0x92); camerap_WriteOneReg( 0x45 , 0x25); camerap_WriteOneReg( 0x47 , 0x24); } else { //for t800 camerap_WriteOneReg( 0x0f , 0x82); camerap_WriteOneReg( 0x45 , 0x24); camerap_WriteOneReg( 0x47 , 0x20); } #endif } else if(CamOutSize == CAM_NPIX_QVGA) { camerap_SendRgSeq(RG_InitPowerOnQvga, (sizeof(RG_InitPowerOnQvga) / sizeof(CAM_REG_T))); } else { camerap_SendRgSeq(RG_InitPowerOnQqvga, (sizeof(RG_InitPowerOnQqvga) / sizeof(CAM_REG_T))); #ifdef TGT_GALLITE_G800 if(CamConfig.camId==1) { //for t800 camerap_WriteOneReg( 0x0f , 0x92); camerap_WriteOneReg( 0x45 , 0x25); camerap_WriteOneReg( 0x47 , 0x24); } else { //for t800 camerap_WriteOneReg( 0x0f , 0x82); camerap_WriteOneReg( 0x45 , 0x90); camerap_WriteOneReg( 0x47 , 0x20); } #endif } // Sensor Init seq }
PUBLIC FMD_ERR_T fmd_Open(CONST TGT_FMD_CONFIG_T* fmdTgtCfg, FMD_BAND_T band, FMD_CALLBACK_T* callback, FMD_INIT_T* initValues) { UINT8 dacVol; UINT32 chan; // Check if already opened // ----------------------- if (g_band != FMD_BAND_QTY) { return FMD_ERR_ALREADY_OPENED; } // Check the parameters and store them // ----------------------------------- switch (band) { case FMD_BAND_US_EUROPE: case FMD_BAND_JAPAN: case FMD_BAND_WORLD: case FMD_BAND_EAST_EUROPE: g_band = band; break; default: // this chip has limited band support... return FMD_ERR_BAD_PARAMETER; } if (fmdTgtCfg == NULL) { g_band = FMD_BAND_QTY; // close marker return FMD_ERR_BAD_PARAMETER; } g_fmdConfig = fmdTgtCfg; g_callback = callback; // default : mute , stereo, no bass boost dacVol = 0; chan = 0; // set the required initial state // ------------------------------ if (initValues != NULL) { // set given parameters dacVol = g_fmdConfig->volumeVal[initValues->volume]; chan = (initValues->freqKHz) ; } SXS_TRACE(TSTDOUT,"fmd_Open chanfreqKHz:%d ",chan); // Sets the PowerDown if(g_fmdConfig->pinPdn.type==HAL_GPIO_TYPE_IO) { hal_GpioSetOut(g_fmdConfig->pinPdn.gpioId); } hal_GpioSet(g_fmdConfig->pinPdn); #ifdef I2C_BASED_ON_GPIO gpio_i2c_open(); #else //xiaoyifeng for atv //for IIC pull up pmd_EnablePower(PMD_POWER_CAMERA,TRUE); g_atvdI2cBusId = tgt_GetAtvdConfig()->i2cBusId; hal_I2cOpen(g_atvdI2cBusId); #endif #ifdef RDA5888_FM_26MCRYSTAL_ENABLE { hal_SysAuxClkOut(TRUE); } #endif RDA5888FM_Init(); //open 32k here #ifdef RDA5888_32KFMMODE_ENALBE #ifdef RDA5888_FM_26MCRYSTAL_ENABLE { hal_SysAuxClkOut(FALSE); } #endif { RDA_Open32KOnChip(); } #endif //set volume about dacVol if (dacVol == FMD_ANA_MUTE) { // fmd_Write(0x10,0xc500); // close adac } else { //fmd_Write(0x10,0x8500); // open adac } // sxr_Sleep(10 MILLI_SECONDS); // fmd_FieldWrite(0x125, 0xff80, dacVol); // sxr_Sleep(50 MILLI_SECONDS); return FMD_ERR_NO; }