void* TestThreadFunc(void *arg) { ::prctl(PR_SET_NAME,"TestThread", 0, 0, 0); MUINT32 sensorId = reinterpret_cast<MUINT32>(arg); // uint32_t sensorArray[1]; IHalSensorList* const pHalSensorList = IHalSensorList::get(); IHalSensor* pSensorHalObj = pHalSensorList->createSensor(LOG_TAG, sensorId); if(pSensorHalObj == NULL) { MY_LOGE("mpSensorHalObj is NULL"); } // sensorArray[0] = sensorId; pSensorHalObj->powerOn(LOG_TAG, 1, &sensorArray[0]); // IHal3A* pHal3a = IHal3A::createInstance(IHal3A::E_Camera_1, sensorId, LOG_TAG); sp<ICamAdapter> pAdapter = createMtkDefaultCamAdapter(String8("Default"), sensorId, NULL); // MY_LOGD("init (%d)", sensorId); pAdapter->init(); MY_LOGD("startPreview (%d)", sensorId); pAdapter->startPreview(); // ::sem_wait(&g_semTestThreadStart); // usleep(10000000); // MY_LOGD("stopPreview (%d)", sensorId); pAdapter->stopPreview(); MY_LOGD("uninit (%d)", sensorId); pAdapter->uninit(); // ::sem_post(&g_semTestThreadEnd); // pHal3a->destroyInstance(LOG_TAG); // if(pSensorHalObj) { pSensorHalObj->powerOff(LOG_TAG, 1, &sensorArray[0]); pSensorHalObj->destroyInstance(LOG_TAG); pSensorHalObj = NULL; } return NULL; }
int test_pip_preview(int argc, char** argv) { int ret = 0; if( argc < 2 ) { printf("Usage: camtest 1(PIP preview) <open_id>\n"); printf("open_id: 0(main->sub), 1(sub->main) \n"); return -1; } // MY_LOGD("Sensor:list get"); uint32_t sensorArray[1]; IHalSensorList* const pHalSensorList = IHalSensorList::get(); MY_LOGD("Sensor:search"); pHalSensorList->searchSensors(); // MUINT32 sensorId = atoi(argv[1]); // IHalSensor* pSensorHalObj = pHalSensorList->createSensor(LOG_TAG, sensorId); if(pSensorHalObj == NULL) { MY_LOGE("mpSensorHalObj is NULL"); } // sensorArray[0] = sensorId; pSensorHalObj->powerOn(LOG_TAG, 1, &sensorArray[0]); // IHal3A* pHal3a = IHal3A::createInstance(IHal3A::E_Camera_1, sensorId, LOG_TAG); // sp<ICamAdapter> pAdapter = createMtkDefaultCamAdapter(String8("Default"), sensorId, NULL); // sem_init(&g_semTestThreadStart, 0, 0); sem_init(&g_semTestThreadEnd, 0, 0); pthread_attr_t const attr = {0, NULL, 1024 * 1024, 4096, SCHED_RR, 90}; pthread_create(&g_TestThread, &attr, TestThreadFunc, (sensorId == 0) ? (void*)1 : (void*)0); // MY_LOGD("init (%d)", sensorId); pAdapter->init(); MY_LOGD("startPreview (%d)", sensorId); pAdapter->startPreview(); // ::sem_post(&g_semTestThreadStart); // usleep(10000000); // ::sem_wait(&g_semTestThreadEnd); // MY_LOGD("stopPreview (%d)", sensorId); pAdapter->stopPreview(); MY_LOGD("uninit (%d)", sensorId); pAdapter->uninit(); // pHal3a->destroyInstance(LOG_TAG); // if(pSensorHalObj) { pSensorHalObj->powerOff(LOG_TAG, 1, &sensorArray[0]); pSensorHalObj->destroyInstance(LOG_TAG); pSensorHalObj = NULL; } // return ret; }
/******************************************************************************* * only support 1 pixel mode, so we should revise halsensor.control.cpp ********************************************************************************/ int ef_test() { LOG_INF("+"); int ret=0; int resultIdx=0; // //1. create sensor object int i=0; SensorStaticInfo sensorStaticInfo[3]; SensorDynamicInfo sensorDynamicInfo[3]; MUINT32 sensorArray[1] = {0}, sensorArray2[1] = {1}; IHalSensor::ConfigParam configParam[2]; char const*const szCallerName = "ef_test"; MUINT32 sensorDevId = SENSOR_DEV_MAIN; IHalSensor* pHalSensor = NULL; IHalSensorList*const pHalSensorList = IHalSensorList::get(); //search sensor pHalSensorList->searchSensors(); MUINT const sensorNum = pHalSensorList->queryNumberOfSensors(); LOG_INF("sensorNum(%d)", sensorNum);//debug for (i = 0; i < sensorNum; i++) { LOG_INF(" i(%d),name:%s type:%d", i,pHalSensorList->queryDriverName(i), pHalSensorList->queryType(i));//debug LOG_INF(" SensorDevIdx:%d", pHalSensorList->querySensorDevIdx(i));//debug } //power on pHalSensor = pHalSensorList->createSensor(szCallerName, 1, &sensorArray[0]);//modify if ( ! pHalSensor ) { LOG_ERR("createSensor fail"); } pHalSensor->powerOn(szCallerName, 1, &sensorArray[0]); usleep(5000); pHalSensorList->querySensorStaticInfo(SENSOR_DEV_MAIN,&sensorStaticInfo[0]); LOG_INF(" Main preview width = %d, height = %d\n",sensorStaticInfo[0].previewWidth,sensorStaticInfo[0].previewHeight); LOG_INF(" Main capture width = %d, height = %d\n",sensorStaticInfo[0].captureWidth,sensorStaticInfo[0].captureHeight); pHalSensor->querySensorDynamicInfo(SENSOR_DEV_MAIN, &sensorDynamicInfo[0]); LOG_INF("TgInfo[0] = %d\n", sensorDynamicInfo[0].TgInfo, sensorDynamicInfo[1].TgInfo, sensorDynamicInfo[2].TgInfo); LOG_INF("pixelMode[0] = %d\n", sensorDynamicInfo[0].pixelMode, sensorDynamicInfo[1].pixelMode, sensorDynamicInfo[2].pixelMode); MUINT32 u4BitDepth = sensorStaticInfo[0].rawSensorBit; MUINT32 u4Order = sensorStaticInfo[0].sensorFormatOrder; MUINT32 sensorFmt; switch(u4BitDepth) { case 0 : sensorFmt = eImgFmt_BAYER8; break; case 1 : sensorFmt = eImgFmt_BAYER10; break; case 2 : sensorFmt = eImgFmt_BAYER12; break; case 3 : sensorFmt = eImgFmt_BAYER12; //To do : raw 14 bit break; default : sensorFmt = eImgFmt_UNKNOWN; LOG_ERR("unknown raw image bit depth(%u)",u4BitDepth); } //2. pass1 object and port information ICamIOPipe *m_pICamIOPipe; m_pICamIOPipe = ICamIOPipe::createInstance(eScenarioID_VSS, eScenarioFmt_RAW); if(MTRUE != (m_pICamIOPipe->init())) { LOG_ERR("m_pICamIOPipe init fail !!!!!!!!!!!!!!"); return -1; } PortInfo m_tgi; PortInfo m_imgo; NSImageio::NSIspio::PortID mPortID; QBufInfo rQBufInfo; IMemDrv* mpImemDrv=NULL; mpImemDrv=IMemDrv::createInstance(); mpImemDrv->init(); IspDrv* mpIspDrv=NULL; mpIspDrv=IspDrv::createInstance(); mpIspDrv->init(); IMEM_BUF_INFO imgo_buf[3]; QTimeStampBufInfo rQTSBufInfo; //3. run each cases int stride=0; for(int q=0;q<BD_SEG_NUM;q++) { LOG_INF("i(%d)",q); //reset mpIspDrv->reset(); LOG_INF("reset done"); // resultIdx=q; //config sensor, TG grab window configParam[0] = { index : 0, //modify crop : MSize(efTable[q].TG_grabW,TG_grabH), //FIXME scenarioId : SENSOR_SCENARIO_ID_NORMAL_CAPTURE, isBypassScenario : 0, isContinuous : 1, HDRMode : 0, framerate : 0, //default frame rate twopixelOn : 0, debugMode : 1,//test model }; pHalSensor->configure(1, &configParam[0]); #if 1 MINT32 u32Enable = 1; MINT32 err = pHalSensor->sendCommand(SENSOR_DEV_MAIN, SENSOR_CMD_SET_TEST_PATTERN_OUTPUT, (MUINTPTR)&u32Enable, 0, 0); #endif //port TG //m_tgi.ePxlMode = ePxlMode_One_Single; //no need in D2 m_tgi.index = NSImageio::NSIspio::EPortIndex_TG1I; //main sensor m_tgi.eImgFmt = (EImageFormat)sensorFmt; // Image Pixel Format m_tgi.eRawPxlID = (ERawPxlID)u4Order; m_tgi.u4ImgWidth = efTable[q].TG_grabW; // Image Width m_tgi.u4ImgHeight = TG_grabH; // Image Height //m_tgi.u4PureRaw = 1; //no need in D2 //m_tgi.u4PureRawPak = 1;//no need in D2 m_tgi.type = EPortType_Sensor; // EPortType m_tgi.inout =EPortDirection_In; // 0:in/1:out //imgo m_imgo.index = EPortIndex_IMGO; m_imgo.eImgFmt = m_tgi.eImgFmt; // Image Pixel Format //m_imgo.u4PureRaw = 0; //no need in D2 m_imgo.u4ImgWidth = m_tgi.u4ImgWidth; // Image Width m_imgo.u4ImgHeight = m_tgi.u4ImgHeight; // Image Height m_imgo.crop.y = 0; m_imgo.crop.floatY = 0; m_imgo.crop.w = m_imgo.u4ImgWidth; // Image Width m_imgo.crop.h = m_imgo.u4ImgHeight; m_imgo.u4Stride[ESTRIDE_1ST_PLANE] = efTable[q].TG_grabW; //unit is pixel when using 82 camera 1 driver; m_imgo.u4Stride[ESTRIDE_2ND_PLANE] = 0; m_imgo.u4Stride[ESTRIDE_3RD_PLANE] = 0; m_imgo.type = EPortType_Memory; // EPortType m_imgo.index = EPortIndex_IMGO; // port index m_imgo.inout = EPortDirection_Out; // 0:in/1:out //set CQ first before pipe config m_pICamIOPipe->sendCommand(EPIPECmd_SET_CQ_CHANNEL,(MINTPTR)CAM_ISP_CQ0,0,0); //single trigger & config m_pICamIOPipe->sendCommand(EPIPECmd_SET_CQ_TRIGGER_MODE,(MINTPTR)EPIPE_PASS1_CQ0,(MINTPTR)EPIPECQ_TRIGGER_SINGLE_IMMEDIATE,(MINTPTR)EPIPECQ_TRIG_BY_START); //config pipe g_vCamIOInPorts.at(0) = &m_tgi; g_vCamIOIOutPorts.resize(1); g_vCamIOIOutPorts.at(0) = &m_imgo; LOG_INF("start m_pICamIOPipe->configPipe()"); if(MTRUE != m_pICamIOPipe->configPipe(g_vCamIOInPorts, g_vCamIOIOutPorts)) { LOG_ERR("m_pICamIOPipe->configPipe() fail"); return -1; } //enque pass1 output buffer rQBufInfo.vBufInfo.resize(1); // rQBufInfo.vBufInfo[0].header = NULL; //no need in D2 for(int j=0;j<3;j++) { //allocate memory imgo_buf[j].size=m_imgo.u4Stride[ESTRIDE_1ST_PLANE]*m_imgo.u4ImgHeight; LOG_INF("w/h/stride/size (%d/%d/%d/%d)",m_imgo.u4ImgWidth,m_imgo.u4ImgHeight,m_imgo.u4Stride[ESTRIDE_1ST_PLANE],imgo_buf[j].size); mpImemDrv->allocVirtBuf(&(imgo_buf[j])); mpImemDrv->mapPhyAddr(&(imgo_buf[j])); mPortID.index = EPortIndex_IMGO; rQBufInfo.vBufInfo[0].memID = imgo_buf[j].memID; rQBufInfo.vBufInfo[0].u4BufSize = imgo_buf[j].size; //bytes rQBufInfo.vBufInfo[0].u4BufVA = imgo_buf[j].virtAddr; rQBufInfo.vBufInfo[0].u4BufPA = imgo_buf[j].phyAddr; //rQBufInfo.vBufInfo[0].mBufIdx=j; //no need in D2 LOG_INF("IMGO m_pICamIOPipe->enqueOutBuf[%d].u4BufPA(%x).size(0x%x)",j,rQBufInfo.vBufInfo[0].u4BufVA,rQBufInfo.vBufInfo[0].u4BufSize); m_pICamIOPipe->enqueOutBuf(mPortID, rQBufInfo); } //force to enable TM_EN in seninf MUINT32 valuee=mpIspDrv->readReg(0x8208); LOG_INF("DAMN valuee(0x%x)\n",valuee); printf("DAMN valuee(0x%x)\n",valuee); mpIspDrv->writeReg(0x8208,(valuee|0x1)); valuee=mpIspDrv->readReg(0x8208); LOG_INF("DAMN valuee_2(0x%x)",valuee); printf("DAMN valuee_2(0x%x)\n",valuee); LOG_INF("set current buffer()"); m_pICamIOPipe->sendCommand((MINT32)EPIPECmd_SET_CURRENT_BUFFER, (MINTPTR)EPortIndex_IMGO,0,0); // LOG_INF("startCQ0()"); m_pICamIOPipe->startCQ0(); //continuous mode m_pICamIOPipe->sendCommand(EPIPECmd_SET_CQ_CHANNEL,(MINTPTR)CAM_ISP_CQ_NONE,0,0); //wait VD to align LOG_INF("wati VD to sync()"); m_pICamIOPipe->irq(EPipePass_PASS1_TG1,EPIPEIRQ_VSYNC); valuee=mpIspDrv->readReg(0x8208); LOG_INF("DAMN valuee3(0x%x)\n",valuee); printf("DAMN valuee3(0x%x)\n",valuee); mpIspDrv->writeReg(0x8208,(valuee|0x1)); valuee=mpIspDrv->readReg(0x8208); LOG_INF("DAMN valuee_4(0x%x)",valuee); printf("DAMN valuee_4(0x%x)\n",valuee); m_pICamIOPipe->irq(EPipePass_PASS1_TG1,EPIPEIRQ_VSYNC); //start m_pICamIOPipe->start(); //dequeue pass1 OUT buffer LOG_INF("start to Deque()"); mPortID.index = NSImageio::NSIspio::EPortIndex_IMGO; ret=m_pICamIOPipe->dequeOutBuf(mPortID, rQTSBufInfo); if((rQTSBufInfo.vBufInfo.size() == 0) || ret==0) { printf("(%d), %s_ISP FAIL!!!!!!!!!!!!!\n",resultIdx,efTable[resultIdx].resultStr); LOG_ERR("(%d), %s_ISP FAIL!!!!!!!!!!",resultIdx,efTable[resultIdx].resultStr); resultIdx=resultIdx-1; //real pass segment is the previous one printf("get failllllllllllllllllllllllll, enter while\n"); LOG_INF("resultIdx, ret(%d/%d)",resultIdx,ret); LOG_INF("BONDING RESULT: %s",efTable[resultIdx].resultStr); LOG_INF("enter while for debuggggg"); while(1); goto EXIT; } //save file if pass char filename[256]; sprintf(filename, "/data/EFUSE_%d_imgo_%dx%d.raw",q, m_imgo.u4ImgWidth,m_imgo.u4ImgHeight); saveBufToFile(filename, reinterpret_cast<MUINT8*>(imgo_buf[0].virtAddr), imgo_buf[0].size); LOG_INF("stop()"); //stop if(MTRUE != m_pICamIOPipe->stop()) { LOG_ERR("m_pICamIOPipe->stop() fail"); } // LOG_INF("%s pass",efTable[q].resultStr); //free memory for(int j=0;j<3;j++) { mpImemDrv->unmapPhyAddr(&(imgo_buf[j])); mpImemDrv->freeVirtBuf(&(imgo_buf[j])); } } EXIT: LOG_INF("resultIdx, ret(%d/%d)",resultIdx,ret); LOG_INF("BONDING RESULT: %s",efTable[resultIdx].resultStr); if(!ret) { //debug printf("get fail, enter while\n"); LOG_INF("enter while for debug"); while(1); } pHalSensor->powerOff(szCallerName, 1, &sensorArray[0]); if(m_pICamIOPipe != NULL) { m_pICamIOPipe->uninit(); m_pICamIOPipe->destroyInstance(); m_pICamIOPipe = NULL; } if(mpImemDrv!=NULL) { mpImemDrv->uninit(); mpImemDrv->destroyInstance(); mpImemDrv=NULL; } if(mpIspDrv!=NULL) { mpIspDrv->uninit(); mpIspDrv->destroyInstance(); mpIspDrv=NULL; } LOG_INF("TEST DONE!!!!"); return ret; }