InitCamera

 

 1 //hardware/interfaces/camera/provider/2.4/default/service.cpp
 2 int main()
 3 {
 4  ALOGI("CameraProvider@2.4 legacy service is starting.");
 5  // The camera HAL may communicate to other vendor components via
 6  // /dev/vndbinder
 7  android::ProcessState::initWithDriver("/dev/vndbinder");
 8  status_t status;
 9  if (kLazyService) status = 
10 defaultLazyPassthroughServiceImplementation<ICameraProvider>("legacy/0", 
11 /*maxThreads*/ 6);
12  else status = 
13 defaultPassthroughServiceImplementation<ICameraProvider>("legacy/0", 
14 /*maxThreads*/ 6);
15  return status;
16 }
service.cpp/main
 1 //vendor/qcom/proprietary/camx/src/core/hal/camxhal3.cpp
 2 static int get_number_of_cameras(void)
 3 {
 4  CAMX_ENTRYEXIT_SCOPE(CamxLogGroupHAL, 
 5 SCOPEEventHAL3GetNumberOfCameras);
 6  UINT32 currentPID;
 7  currentPID = OsUtils::GetProcessID();
 8  CamxPerfLockManager* pPerfLockManager = NULL; ///< PerfLock Manager 
 9 instance
10  pPerfLockManager = CamxPerfLockManager::Create();
11  if (NULL == pPerfLockManager)
12  {
13  CAMX_LOG_ERROR(CamxLogGroupHAL, "Failed to create perflock 
14 manager");
15  }
16  if (currentPID != g_pid)
17  {
18  g_pid = currentPID;
19  if (NULL != pPerfLockManager)
20  {
21  pPerfLockManager->AcquirePerfLock(CamxPerfLockType::
22 PERF_LOCK_OPEN_PROVIDER, 2000);
23  }
24  }
25  INT numCameras;
26  numCameras = static_cast<int>(HAL3Module::GetInstance()-
27 >GetNumCameras());
28  // Need to close perflock instance.
29  if (NULL != pPerfLockManager)
30  {
31  pPerfLockManager->Destroy();
32  pPerfLockManager = NULL;
33  }
34  return numCameras;
35 }
camxhal3.cpp/get_number_of_cameras
1 //vendor/qcom/proprietary/camx/src/core/hal/camxhal3module.cpp
2 UINT32 HAL3Module::GetNumCameras() const
3 {
4  return m_numFwCameras;
5 }
camxhal3module.cpp/HAL3Module::GetNumCameras
 1 //vendor/qcom/proprietary/camx/src/core/camxhwenvironment.cpp
 2 CamxResult HwEnvironment::Initialize()
 3 {
 4  CamxResult result = CamxResultSuccess;
 5  CSLInitializeParams params = { 0 };
 6  SettingsManager* pStaticSettingsManager = SettingsManager::
 7 Create(NULL);
 8  ExternalComponentInfo* pExternalComponent = 
 9 GetExternalComponent();
10  m_pHWEnvLock = Mutex::Create("HwEnvLock");
11  CAMX_ASSERT(NULL != m_pHWEnvLock);
12  CAMX_ASSERT(NULL != pStaticSettingsManager);
13  if (NULL != pStaticSettingsManager)
14  {
15  const StaticSettings* pStaticSettings = pStaticSettingsManager-
16 >GetStaticSettings();
17  CAMX_ASSERT(NULL != pStaticSettings);
18  if (NULL != pStaticSettings)
19  {
20  params.mode = 
21 pStaticSettings->CSLMode;
22  params.emulatedSensorParams.enableSensorSimulation = 
23 pStaticSettings->enableSensorEmulation;
24  params.emulatedSensorParams.dumpSensorEmulationOutput = 
25 pStaticSettings->dumpSensorEmulationOutput;
26  OsUtils::StrLCpy(params.emulatedSensorParams.
27 sensorEmulatorPath,
28  pStaticSettings->sensorEmulatorPath,
29  sizeof(pStaticSettings->sensorEmulatorPath));
30  OsUtils::StrLCpy(params.emulatedSensorParams.sensorEmulator,
31  pStaticSettings->sensorEmulator,
32  sizeof(pStaticSettings->sensorEmulator));
33  result = CSLInitialize(&params);
34  if (CamxResultSuccess == result)
35  {
36  // Query the camera platform
37  result = QueryHwContextStaticEntryMethods();
38  }
39  if (CamxResultSuccess == result)
40  {
41  m_pHwFactory = m_staticEntryMethods.CreateHwFactory();
42  if (NULL == m_pHwFactory)
43  {
44  CAMX_ASSERT_ALWAYS_MESSAGE("Failed to create the HW 
45 factory");
46  result = CamxResultEFailed;
47  }
48  }
49  if (CamxResultSuccess == result)
50  {
51  m_pSettingsManager = m_pHwFactory->CreateSettingsManager();
52  if (NULL == m_pSettingsManager)
53  {
54  CAMX_ASSERT_ALWAYS_MESSAGE("Failed to create the HW 
55 settings manager");
56  result = CamxResultEFailed;
57  }
58  }
59  if (CamxResultSuccess == result)
60  {
61  m_staticEntryMethods.GetHWBugWorkarounds(&m_workarounds);
62  }
63  }
64  pStaticSettingsManager->Destroy();
65  pStaticSettingsManager = NULL;
66  }
67  CAMX_ASSERT(NULL != pExternalComponent);
68  if ((CamxResultSuccess == result) && (NULL != pExternalComponent))
69  {
70  result = ProbeChiComponents(pExternalComponent, 
71 &m_numExternalComponent);
72  }
73  if (CamxResultSuccess == result)
74  {
75  // Load the OEM sensor capacity customization functions
76  CAMXCustomizeCAMXInterface camxInterface;
77  camxInterface.pGetHWEnvironment = HwEnvironment::GetInstance;
78  CAMXCustomizeEntry(&m_pOEMInterface, &camxInterface);
79  }
80  if (CamxResultSuccess != result)
81  {
82  CAMX_LOG_ERROR(CamxLogGroupCore, "FATAL ERROR: Raise SigAbort. 
83 HwEnvironment initialization failed");
84  m_numberSensors = 0;
85  OsUtils::RaiseSignalAbort();
86  }
87  else
88  {
89  m_initCapsStatus = InitCapsInitialize;
90  }
91  return result;
92 }
camxhwenvironment.cpp/HwEnvironment::Initialize
 1 //vendor/qcom/proprietary/camx/src/csl/camxcsl.cpp
 2 CamxResult CSLInitialize(CSLInitializeParams* pInitializeParams)
 3 {
 4  CAMX_ENTRYEXIT_SCOPE(CamxLogGroupCSL, CamX::SCOPEEventCSLInitialize);
 5  CAMX_STATIC_ASSERT(static_cast<INT>(CSLMode::CSLHwEnabled) ==
 6  static_cast<INT>(CamX::CSLModeType::
 7 CSLModeHardware));
 8  CAMX_STATIC_ASSERT(static_cast<INT>(CSLMode::CSLIFHEnabled) ==
 9  static_cast<INT>(CamX::CSLModeType::CSLModeIFH));
10  CAMX_STATIC_ASSERT(static_cast<INT>(CSLMode::CSLPresilEnabled) ==
11  static_cast<INT>(CamX::CSLModeType::CSLModePresil));
12  CAMX_STATIC_ASSERT(static_cast<INT>(CSLMode::CSLPresilRUMIEnabled) ==
13  static_cast<INT>(CamX::CSLModeType::
14 CSLModePresilRUMI));
15  if (NULL != g_pCSLModeManager)
16  {
17  CAMX_DELETE g_pCSLModeManager;
18  g_pCSLModeManager = NULL;
19  }
20  g_pCSLModeManager = CAMX_NEW CSLModeManager(pInitializeParams);
21  // Check g_pCSLModeManager before de-referencing it.
22  if (NULL != g_pCSLModeManager)
23  {
24  CSLJumpTable* pJumpTable = g_pCSLModeManager->GetJumpTable();
25  return pJumpTable->CSLInitialize();
26  }
27  else
28  {
29  CAMX_LOG_ERROR(CamxLogGroupCSL, "CSL not initialized");
30  return CamxResultEFailed;
31  }
32 }
camxcsl.cpp/CSLInitialize
1 //vendor/qcom/proprietary/camx/src/core/camxhwfactory.cpp
2 SettingsManager* HwFactory::CreateSettingsManager() const
3 {
4  // Virtual call to derived HWL settings manager creation function
5  return HwCreateSettingsManager();
6 }
camxhwfactory.cpp/HwFactory::CreateSettingsManager
  1 //vendor/qcom/proprietary/camx/src/core/chi/camxchicomponent.cpp
  2 CamxResult ProbeChiComponents(
  3  ExternalComponentInfo* pExternalComponentInfo,
  4  UINT* pNumExternalComponent)
  5 {
  6  CamxResult result = CamxResultSuccess;
  7  UINT16 fileCountTypeNode = 0;
  8  UINT16 fileCountTypeStats = 0;
  9  UINT16 fileCountTypeOverride = 0;
 10  UINT16 fileCountTypeHvx = 0;
 11  UINT16 index = 0;
 12  CHAR soFilesName[MaxExternalComponents][FILENAME_MAX];
 13  static const UINT NumCHIOverrideModules = 2;
 14  CHAR chiOverrideSoFileName
 15 [NumCHIOverrideModules*FILENAME_MAX];
 16  CHAR outTokenString[FILENAME_MAX];
 17  PFCHINODEENTRY pNodeEntry;
 18  static const CHAR HistToken[] = "LOCALHISTOGRAM";
 19  static const CHAR AECToken[] = "AEC";
 20  static const CHAR AFToken[] = "AF";
 21  static const CHAR AWBToken[] = "AWB";
 22  static const CHAR AFDToken[] = "AFD";
 23  static const CHAR ASDToken[] = "ASD";
 24  static const CHAR TrackerToken[] = "TRACKER";
 25  static const CHAR PDToken[] = "PDLIB";
 26  CSLCameraPlatform CSLPlatform = {};
 27  result = CSLQueryCameraPlatform(&CSLPlatform);
 28  CAMX_ASSERT(CamxResultSuccess == result);
 29  switch (CSLPlatform.socId)
 30  {
 31  case CSLCameraTitanSocSM6350:
 32 #if defined(_LP64)
 33  fileCountTypeOverride = OsUtils::GetFilesFromPath("/vendor
 34 /lib64/camera/oem/bitra",
 35  FILENAME_MAX,
 36  
 37 &chiOverrideSoFileName[0],
 38  "*",
 39  "chi",
 40  "*",
 41  
 42 &SharedLibraryExtension[0]);
 43  if (0 == fileCountTypeOverride)
 44  {
 45  fileCountTypeOverride = OsUtils::GetFilesFromPath("/vendor
 46 /lib64/camera/qti/bitra",
 47  
 48 FILENAME_MAX,
 49  
 50 &chiOverrideSoFileName[0],
 51  "*",
 52  "chi",
 53  "*",
 54  
 55 &SharedLibraryExtension[0]);
 56  }
 57 #else // using LP32
 58  fileCountTypeOverride = OsUtils::GetFilesFromPath("/vendor/lib
 59 /camera/oem/bitra",
 60  FILENAME_MAX,
 61  
 62 &chiOverrideSoFileName[0],
 63  "*",
 64  "chi",
 65  "*",
 66  
 67 &SharedLibraryExtension[0]);
 68  if (0 == fileCountTypeOverride)
 69  {
 70  fileCountTypeOverride = OsUtils::GetFilesFromPath("/vendor
 71 /lib/camera/qti/bitra",
 72  
 73 FILENAME_MAX,
 74  
 75 &chiOverrideSoFileName[0],
 76  "*",
 77  "chi",
 78  "*",
 79  
 80 &SharedLibraryExtension[0]);
 81  }
 82 #endif // _LP64
 83  if (0 == fileCountTypeOverride)
 84  {
 85  fileCountTypeOverride = OsUtils::GetFilesFromPath
 86 (CHIOverrideModulePath,
 87  
 88 FILENAME_MAX,
 89  
 90 &chiOverrideSoFileName[0],
 91  "*",
 92  "chi",
 93  "*",
 94  
 95 &SharedLibraryExtension[0]);
 96  }
 97  break;
 98  default:
 99  fileCountTypeOverride = OsUtils::GetFilesFromPath
100 (CHIOverrideModulePath,
101  FILENAME_MAX,
102  
103 &chiOverrideSoFileName[0],
104  "*",
105  "chi",
106  "*",
107  
108 &SharedLibraryExtension[0]);
109  break;
110  }
111  fileCountTypeNode = OsUtils::GetFilesFromPath(ExtCompPath,
112  FILENAME_MAX,
113  &soFilesName[0][0],
114  "*",
115  "node",
116  "*",
117  &SharedLibraryExtension
118 [0]);
119  fileCountTypeStats = OsUtils::GetFilesFromPath(ExtCompPath,
120  FILENAME_MAX,
121  &soFilesName
122 [fileCountTypeNode][0],
123  "*",
124  "stats",
125  "*",
126  &SharedLibraryExtension
127 [0]);
128  fileCountTypeHvx = OsUtils::GetFilesFromPath(ExtCompPath,
129  FILENAME_MAX,
130  &soFilesName
131 [fileCountTypeNode+fileCountTypeStats][0],
132  "*",
133  "hvx",
134  "*",
135  &SharedLibraryExtension
136 [0]);
137  g_componentVendorTagsInfo.numVendorTagInfo = 0;
138  g_componentVendorTagsInfo.pVendorTagInfoArray =
139  static_cast<VendorTagInfo*>(CAMX_CALLOC(sizeof(VendorTagInfo) *
140  (fileCountTypeOverride + fileCountTypeNode + 
141 fileCountTypeStats)));
142  CAMX_ASSERT(NULL != g_componentVendorTagsInfo.pVendorTagInfoArray);
143  if (NULL != pNumExternalComponent)
144  {
145  *pNumExternalComponent = fileCountTypeNode + fileCountTypeStats + 
146 fileCountTypeHvx;
147  }
148  while (index < fileCountTypeNode + fileCountTypeStats + 
149 fileCountTypeHvx)
150  {
151  CamX::OSLIBRARYHANDLE handle = CamX::OsUtils::LibMap(&soFilesName
152 [index][0]);
153  if (index < fileCountTypeNode)
154  {
155  pNodeEntry = reinterpret_cast<PFCHINODEENTRY>(CamX::OsUtils::
156 LibGetAddr(handle, "ChiNodeEntry"));
157  CAMX_ASSERT(NULL != pNodeEntry);
158  pExternalComponentInfo[index].nodeCallbacks.size = sizeof
159 (ChiNodeCallbacks);
160  if (NULL != pNodeEntry)
161  {
162  pNodeEntry(&pExternalComponentInfo[index].nodeCallbacks);
163  }
164  if (NULL != pExternalComponentInfo[index].nodeCallbacks.
165 pQueryVendorTag)
166  {
167  GetComponentTag(pExternalComponentInfo[index].
168 nodeCallbacks.pQueryVendorTag);
169  }
170  pExternalComponentInfo[index].nodeAlgoType = 
171 ExternalComponentNodeAlgo::COMPONENTNODE;
172  }
173  else if (index < (fileCountTypeNode+fileCountTypeStats))
174  {
175  pExternalComponentInfo[index].nodeAlgoType = 
176 ExternalComponentNodeAlgo::COMPONENTALGORITHM;
177  if (OsUtils::GetFileNameToken(&soFilesName[index][0], 4, 
178 outTokenString, FILENAME_MAX) == TRUE)
179  {
180  CAMX_LOG_VERBOSE(CamxLogGroupStats, "index %d, sofile: %s 
181 , outTokenString : %s ",
182  index, soFilesName[index], outTokenString);
183  if (0 == OsUtils::StrNICmp(outTokenString, AECToken, 
184 OsUtils::StrLen(AECToken)))
185  {
186  GetAECAlgorithmCallback(&soFilesName[index][0], 
187 pExternalComponentInfo, index);
188  pExternalComponentInfo[index].statsAlgo = 
189 ExternalComponentStatsAlgo::ALGOAEC;
190  }
191  else if (0 == OsUtils::StrNICmp(outTokenString, AFDToken, 
192 OsUtils::StrLen(AFDToken)))
193  {
194  GetAFDAlgorithmCallback(&soFilesName[index][0], 
195 pExternalComponentInfo, index);
196  pExternalComponentInfo[index].statsAlgo = 
197 ExternalComponentStatsAlgo::ALGOAFD;
198  }
199  else if (0 == OsUtils::StrNICmp(outTokenString, AFToken, 
200 OsUtils::StrLen(AFToken)))
201  {
202  GetAFAlgorithmCallback(&soFilesName[index][0], 
203 pExternalComponentInfo, index);
204  pExternalComponentInfo[index].statsAlgo = 
205 ExternalComponentStatsAlgo::ALGOAF;
206  }
207  else if (0 == OsUtils::StrNICmp(outTokenString, AWBToken, 
208 OsUtils::StrLen(AWBToken)))
209  {
210  GetAWBAlgorithmCallback(&soFilesName[index][0], 
211 pExternalComponentInfo, index);
212  pExternalComponentInfo[index].statsAlgo = 
213 ExternalComponentStatsAlgo::ALGOAWB;
214  }
215  else if (0 == OsUtils::StrNICmp(outTokenString, ASDToken, 
216 OsUtils::StrLen(ASDToken)))
217  {
218  GetASDAlgorithmCallback(&soFilesName[index][0], 
219 pExternalComponentInfo, index);
220  pExternalComponentInfo[index].statsAlgo = 
221 ExternalComponentStatsAlgo::ALGOASD;
222  }
223  else if (0 == OsUtils::StrNICmp(outTokenString, 
224 TrackerToken, OsUtils::StrLen(TrackerToken)))
225  {
226  GetTrackerAlgorithmCallback(&soFilesName[index][0], 
227 pExternalComponentInfo, index);
228  pExternalComponentInfo[index].statsAlgo = 
229 ExternalComponentStatsAlgo::ALGOTRACK;
230  }
231  else if (0 == OsUtils::StrNICmp(outTokenString, PDToken, 
232 OsUtils::StrLen(PDToken)))
233  {
234  GetPDLibraryCallback(&soFilesName[index][0], 
235 pExternalComponentInfo, index);
236  pExternalComponentInfo[index].statsAlgo = 
237 ExternalComponentStatsAlgo::ALGOPD;
238  }
239  else if (0 == OsUtils::StrNICmp(outTokenString, HistToken, 
240 OsUtils::StrLen(HistToken)))
241  {
242  GetHistAlgorithmCallback(&soFilesName[index][0], 
243 pExternalComponentInfo, index);
244  pExternalComponentInfo[index].statsAlgo = 
245 ExternalComponentStatsAlgo::ALGOHIST;
246  }
247  }
248  }
249  else
250  {
251  pExternalComponentInfo[index].nodeAlgoType = 
252 ExternalComponentNodeAlgo::COMPONENTHVX;
253  GetHVXAlgorithmCallback(&soFilesName[index][0], 
254 pExternalComponentInfo, index);
255  }
256  SIZE_T srcComponentNameLen = OsUtils::StrLen(&soFilesName[index]
257 [0]);
258  pExternalComponentInfo[index].pComponentName = static_cast<CHAR*>
259 (CAMX_CALLOC(srcComponentNameLen + 1));
260  const CHAR* pFileName = OsUtils::GetFileName(&soFilesName[index]
261 [0]);
262  CAMX_ASSERT(NULL != pFileName);
263  CAMX_ASSERT(NULL != pExternalComponentInfo[index].pComponentName);
264  if (NULL != pExternalComponentInfo[index].pComponentName)
265  {
266  OsUtils::StrLCpy(pExternalComponentInfo[index].pComponentName, 
267 pFileName, srcComponentNameLen + 1);
268  }
269  pExternalComponentInfo[index].inUse = 1;
270  index = index + 1;
271  }
272  if (0 < fileCountTypeOverride)
273  {
274  const CHAR* pD = NULL;
275  INT fileIndexMoorea = FILENAME_MAX;
276  INT fileIndex = 0;
277  pD = OsUtils::StrStr(&chiOverrideSoFileName
278 [0], "moorea");
279  PFNCHIQUERYVENDORTAG pQueryVendorTag;
280  // pD is NULL if Moorea is not present in first file index
281  if (pD != NULL)
282  {
283  fileIndexMoorea = 0;
284  fileIndex = FILENAME_MAX;
285  }
286  if (CSLPlatform.socId == CSLCameraTitanSocSM7150 || CSLPlatform.
287 socId == CSLCameraTitanSocSM7150P)
288  {
289  pQueryVendorTag = reinterpret_cast<PFNCHIQUERYVENDORTAG>(CamX::
290 OsUtils::LibGetAddr(
291  CamX::OsUtils::LibMap(&chiOverrideSoFileName
292 [fileIndexMoorea]), "chi_hal_query_vendertag"));
293  }
294  else
295  {
296  pQueryVendorTag = reinterpret_cast<PFNCHIQUERYVENDORTAG>(CamX::
297 OsUtils::LibGetAddr(
298  CamX::OsUtils::LibMap(&chiOverrideSoFileName
299 [fileIndex]), "chi_hal_query_vendertag"));
300  }
301  if (NULL != pQueryVendorTag)
302  {
303  GetComponentTag(pQueryVendorTag);
304  }
305  }
306  return result;
307 }
camxchicomponent.cpp/ProbeChiComponents

 

posted @ 2023-03-13 00:05  归江渡鸟泅白浪  阅读(98)  评论(0)    收藏  举报