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 }