源码平台:rk3399
该文件在hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp 中的camera_get_number_of_cameras函数获取摄像头数量的时候会解析,camera_board_profiles::getInstance();
770
771 memset(&camInfoTmp[0],0x00,sizeof(rk_cam_info_t));
772 memset(&camInfoTmp[1],0x00,sizeof(rk_cam_info_t));
773
774 profiles = camera_board_profiles::getInstance();
775 nCamDev = profiles->mDevieVector.size();
776 LOGE("board profiles cam num %d\n", nCamDev);
777 //if uvc got 2 , ignore csi
camera_board_profiles::getInstance()在hardware/rockchip/camera/CameraHal/CameraHal_board_xml_parse.cpp
1061 }
1062
1063 camera_board_profiles* camera_board_profiles::getInstance()
1064 {
1065 camera_board_profiles *profiles = createInstance();
1066
1067 return profiles;
1068 }
1069
接着看createInstance()
1003 camera_board_profiles* camera_board_profiles::createInstance()
1004 {
1005 FILE *fp = NULL;
1006
1007 camera_board_profiles *profiles = new camera_board_profiles();
1008
1009 fp = fopen(RK_BOARD_XML_PATH, "r");
1010 if(!fp){
1011 LOGD("This machine have not dvp/mipi camera!!\n");
1012 return profiles;
1013 }
1014
1015 LOGD("open xml file(%s) success\n", RK_BOARD_XML_PATH);
1016
1017 XML_Parser parser = XML_ParserCreate(NULL);
1018 if(parser==NULL){
1019 ALOGE("XML_ParserCreate failed\n");
1020 return NULL;
1021 }
1022
1023 XML_SetUserData(parser, profiles);
1024 XML_SetElementHandler(parser, StartElementHandler, NULL);
1025
1026 const int BUFF_SIZE = 512;
1027 for (;;) {
1028 void *buff = ::XML_GetBuffer(parser, BUFF_SIZE);
1029 if (buff == NULL) {
1030 ALOGE("failed to in call to XML_GetBuffer()");
1031 goto exit;
1032 }
1033
1034 int bytes_read = ::fread(buff, 1, BUFF_SIZE, fp);
1035 if (bytes_read < 0) {
1036 ALOGE("failed in call to read");
1037 goto exit;
1038 }
1039
1040 int res = XML_ParseBuffer(parser, bytes_read, bytes_read == 0);
1041