首先向Sensor Vendor确认对应的setting,MTK平台对setting的要求:
确认好之后做如下测试:
adb root
adb shell sentest
会打印出如下所示的所有sensorlist:
[main]sizeof long : 8
[show_Sensors]sensorNum 3
[show_Sensors]name:SENSOR_DRVNAME_IMX135_MIPI_RAW type:0
[show_Sensors]index:0, SensorDevIdx:1
[show_Sensors]name:SENSOR_DRVNAME_S5K5E8YX_MIPI_RAW type:0
[show_Sensors]index:1, SensorDevIdx:2
[show_Sensors]name:SENSOR_DRVNAME_BF2253L_MIPI_RAW type:0
[show_Sensors]index:2, SensorDevIdx:4
[main]Param: 1
[main] : main(1), Sub(2), Main2(4), sub2(8), main3(16)
[main] : Pre(0), Cap(1), VD(2), slim1(3), slim2(4)
若未打印出来需要porting的sensor name,请自行check上电、i2c等配置。
开启Log的cmd:
adb shell setprop vendor.debug.seninf.log 1
然后执行如下命令:
adb shell sentest arg1 arg2//arg1: 指定sensor
main sensor (arg1 = 1)
sub sensor (arg1 = 2)//arg2:指定sensor mode
preview (arg2 = 0)
capture (arg2 = 1)
video (arg2 = 2)
hs video (arg2 = 3)
slim video (arg2 = 4)
若是针对main camera 的preview mode做测试,如下:
adb shell sentest 1 0
[main]sizeof long : 8
[main]argc num:3
[test_SensorInterface]name:SENSOR_DRVNAME_IMX135_MIPI_RAW type:0
[test_SensorInterface]index:0, SensorDevIdx:1
[test_SensorInterface]Sensor index:0, scenarioId:0
[test_SensorInterface]crop w:2096, h:1552
[test_SensorInterface]pHalSensor->powerOn start[test_SensorInterface]main/atv-Continous=1
[test_SensorInterface]main/atv-BypassSensorScenario=0[test_SensorInterface]TgInfo[0] = 1
[test_SensorInterface]pixelMode[0] = 1
[test_SensorInterface]mipi rate = 225000000[test_SensorInterface]---------------------------------------------------
[test_SensorInterface]seninf_mux1 horizontal valid count 0x0, horzontal blanking count 0x0
[test_SensorInterface]blanking valid count 0x0, blanking blanking count 0x0, fps =30[test_SensorInterface]---------------------------------------------------
[test_SensorInterface]seninf_mux1 horizontal valid count 0x817, horzontal blanking count 0x992
[test_SensorInterface]blanking valid count 0x6be78c, blanking blanking count 0x522aa, fps =30
[test_SensorInterface]mipi_pixel_rate = 224.928288Mpps
[test_SensorInterface]vertical_blanking = 1.514335ms
[test_SensorInterface]horizontal_blanking = 0.011024ms
[test_SensorInterface]line time = 0.020342ms [test_SensorInterface]---------------------------------------------------
[test_SensorInterface]seninf_mux1 horizontal valid count 0x816, horzontal blanking count 0x991
[test_SensorInterface]blanking valid count 0x6be78d, blanking blanking count 0x522aa, fps =30
[test_SensorInterface]mipi_pixel_rate = 225.036979Mpps
[test_SensorInterface]vertical_blanking = 1.514334ms
[test_SensorInterface]horizontal_blanking = 0.011019ms
[test_SensorInterface]line time = 0.020333ms [test_SensorInterface]---------------------------------------------------
[test_SensorInterface]seninf_mux1 horizontal valid count 0x817, horzontal blanking count 0x991
[test_SensorInterface]blanking valid count 0x6be78c, blanking blanking count 0x522aa, fps =30
[test_SensorInterface]mipi_pixel_rate = 224.928288Mpps
[test_SensorInterface]vertical_blanking = 1.514335ms
[test_SensorInterface]horizontal_blanking = 0.011019ms
[test_SensorInterface]line time = 0.020338ms
如上打印的是从sensor driver中query出来的配置信息,sensor index:0代表是main camera,Scenario id:0代表preview mode,grab window size为2096*1552。
其中mipi_pixel_rate代表sensor实际的mipi_pixel_rate,请check是否与sensor driver中配置的一致,同时确认sensor吐data的实际Vertical_blanking是否满足平台要求。
如果打印出来的值大多是0x00,一般原因是sensor没有search到或者sensor吐出的data有问题,平台没有收到任何数据。
//vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/common/v1/test/main_sensor.cppvoid show_Sensors()
{IHalSensorList*const pHalSensorList = IHalSensorList::get();if(pHalSensorList) {pHalSensorList->searchSensors();unsigned int const sensorNum = pHalSensorList->queryNumberOfSensors();PRINT_MSG("sensorNum %d \n",sensorNum);for( unsigned int i = 0; i < sensorNum; i++) {int sensorIndexDual = 0;sensorIndexDual = pHalSensorList->querySensorDevIdx(i);int sensorIndex = i;PRINT_MSG("name:%s type:%d \n", pHalSensorList->queryDriverName(sensorIndex), pHalSensorList->queryType(sensorIndex));PRINT_MSG("index:%d, SensorDevIdx:%d \n", sensorIndex, pHalSensorList->querySensorDevIdx(sensorIndex));}}
}void test_SensorInterface(int sendev, int scenario, int input_fps)
{unsigned int i;char const *const szCallerName = "R1";IHalSensor *pHalSensor = NULL;IHalSensor::ConfigParam configParam;SensorStaticInfo sensorStaticInfo;SensorDynamicInfo sensorDynamicInfo;int width = 0;int height = 0;int fps = 0;IHalSensorList*const pHalSensorList = IHalSensorList::get();pHalSensorList->searchSensors();unsigned int const sensorNum = pHalSensorList->queryNumberOfSensors();for(i = 0; i < sensorNum; i++) {int sensorIndexDual = pHalSensorList->querySensorDevIdx(i);if(sendev & sensorIndexDual) {int sensorIndex = i;PRINT_MSG("name:%s type:%d \n", pHalSensorList->queryDriverName(sensorIndex), pHalSensorList->queryType(sensorIndex));PRINT_MSG("index:%d, SensorDevIdx:%d \n", sensorIndex, pHalSensorList->querySensorDevIdx(sensorIndex));pHalSensorList->querySensorStaticInfo(sensorIndexDual, &sensorStaticInfo);switch(scenario) {case SENSOR_SCENARIO_ID_NORMAL_PREVIEW:width = sensorStaticInfo.previewWidth;height = sensorStaticInfo.previewHeight;fps = sensorStaticInfo.previewFrameRate;break;case SENSOR_SCENARIO_ID_NORMAL_CAPTURE:width = sensorStaticInfo.captureWidth;height = sensorStaticInfo.captureHeight;fps = sensorStaticInfo.captureFrameRate;break;case SENSOR_SCENARIO_ID_NORMAL_VIDEO:width = sensorStaticInfo.videoWidth;height = sensorStaticInfo.videoHeight;fps = sensorStaticInfo.videoFrameRate;break;case SENSOR_SCENARIO_ID_SLIM_VIDEO1:width = sensorStaticInfo.video1Width;height = sensorStaticInfo.video1Height;fps = sensorStaticInfo.video1FrameRate;break;case SENSOR_SCENARIO_ID_SLIM_VIDEO2:width = sensorStaticInfo.video2Width;height = sensorStaticInfo.video2Height;fps = sensorStaticInfo.video2FrameRate;break;case SENSOR_SCENARIO_ID_CUSTOM1:width = sensorStaticInfo.SensorCustom1Width;height = sensorStaticInfo.SensorCustom1Height;fps = sensorStaticInfo.custom1FrameRate;break;case SENSOR_SCENARIO_ID_CUSTOM2:width = sensorStaticInfo.SensorCustom2Width;height = sensorStaticInfo.SensorCustom2Height;fps = sensorStaticInfo.custom2FrameRate;break;case SENSOR_SCENARIO_ID_CUSTOM3:width = sensorStaticInfo.SensorCustom3Width;height = sensorStaticInfo.SensorCustom3Height;fps = sensorStaticInfo.custom3FrameRate;break;case SENSOR_SCENARIO_ID_CUSTOM4:width = sensorStaticInfo.SensorCustom4Width;height = sensorStaticInfo.SensorCustom4Height;fps = sensorStaticInfo.custom4FrameRate;break;case SENSOR_SCENARIO_ID_CUSTOM5:width = sensorStaticInfo.SensorCustom5Width;height = sensorStaticInfo.SensorCustom5Height;fps = sensorStaticInfo.custom5FrameRate;break;default:break;}PRINT_MSG("Sensor index:%d, scenarioId:%d\n", sensorIndex, scenario);PRINT_MSG("crop w:%d, h:%d\n", width, height);pHalSensor = pHalSensorList->createSensor(szCallerName, sensorIndex);if(!pHalSensor){PRINT_ERR("createSensor fail");return;}PRINT_MSG("pHalSensor->powerOn start\n");pHalSensor->powerOn(szCallerName, 1, (MUINT *)&sensorIndex);configParam ={.index = (MUINT)sensorIndex,.crop = MSize(width, height),.scenarioId = (MUINT)scenario,.isBypassScenario = 0,.isContinuous = 1,};if(input_fps != 0) {configParam.framerate = input_fps;fps = input_fps *10;}MUINT32 mipi_rate = 0;pHalSensor->configure(1, &configParam);pHalSensor->sendCommand(sensorIndexDual, SENSOR_CMD_SET_STREAMING_RESUME, 0, 0, 0);pHalSensor->sendCommand(sensorIndexDual, SENSOR_CMD_GET_MIPI_PIXEL_RATE, (MUINTPTR)&scenario,(MUINTPTR)&mipi_rate, (MUINTPTR)&fps);PRINT_MSG("main/atv-Continous=%u\n\n", configParam.isContinuous);PRINT_MSG("main/atv-BypassSensorScenario=%u\n\n", configParam.isBypassScenario);// Only can get current sensor information.pHalSensor->querySensorDynamicInfo(pHalSensorList->querySensorDevIdx(sensorIndex), &sensorDynamicInfo);PRINT_MSG("TgInfo[%d] = %d\n", sensorIndex, sensorDynamicInfo.TgInfo);PRINT_MSG("pixelMode[%d] = %d\n", sensorIndex, sensorDynamicInfo.pixelMode);PRINT_MSG("mipi rate = %d\n", mipi_rate);}}while(1) {unsigned int meter[4]= {0};double d_meter[4]= {0};double d_width = width;double d_fps = fps;if(pHalSensor != NULL)pHalSensor->sendCommand(IMGSENSOR_SENSOR_IDX_MAIN, SENSOR_CMD_DEBUG_GET_SENINF_METER, (MUINTPTR)meter, 0, 0);PRINT_MSG("---------------------------------------------------\n");PRINT_MSG("seninf_mux1 horizontal valid count 0x%x, horzontal blanking count 0x%x\n", meter[0], meter[1]);PRINT_MSG("blanking valid count 0x%x, blanking blanking count 0x%x, fps =%d\n\n", meter[2], meter[3], fps/10);d_meter[0] = meter[0];d_meter[1] = meter[1];d_meter[2] = meter[2];d_meter[3] = meter[3];if(meter[0] && meter[1] && meter[2] && meter[3] && fps) {double mipi_pixel_rate =d_width/((d_meter[0]/(d_meter[2]+d_meter[3]))*(10/d_fps));PRINT_MSG("mipi_pixel_rate = %fMpps \n",mipi_pixel_rate/1000000);double vertical_blanking = (d_meter[3]/(d_meter[2]+d_meter[3]))*(10/d_fps);double horizontal_blanking = (d_meter[1]/(d_meter[2]+d_meter[3]))*(10/d_fps);double line_time = ((d_meter[1]+d_meter[0])/(d_meter[2]+d_meter[3]))*(10/d_fps);PRINT_MSG("vertical_blanking = %fms \n", vertical_blanking*1000);PRINT_MSG("horizontal_blanking = %fms \n", horizontal_blanking*1000);PRINT_MSG("line time = %fms \n", line_time*1000);}if(fps != 0)usleep((10000000/fps)*10);//update each 10 frames}
}/******************************************************************************** Main Function********************************************************************************/
int main(int argc, char** argv)
{int ret = 0;int sensorDev = 0,scenario =0, fps = 0;PRINT_MSG("sizeof long : %d\n", (int)sizeof(long));if (argc < 2) {show_Sensors();PRINT_MSG("Param: 1 \n");PRINT_MSG(" : main(1), Sub(2), Main2(4), sub2(8), main3(16)\n");PRINT_MSG(" : Pre(%d), Cap(%d), VD(%d), slim1(%d), slim2(%d)\n",\SENSOR_SCENARIO_ID_NORMAL_PREVIEW, SENSOR_SCENARIO_ID_NORMAL_CAPTURE,\SENSOR_SCENARIO_ID_NORMAL_VIDEO, SENSOR_SCENARIO_ID_SLIM_VIDEO1, SENSOR_SCENARIO_ID_SLIM_VIDEO2);return -1;}if(argc > 1)sensorDev = atoi(argv[1]);if(argc > 2)scenario = atoi(argv[2]);if(argc > 3)fps = atoi(argv[3]);PRINT_MSG("argc num:%d\n",argc);test_SensorInterface(sensorDev, scenario, fps);return ret;
}