• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "mipi_csi_core.h"
10 #include "hdf_log.h"
11 
12 #define HDF_LOG_TAG mipi_csi_core
13 
14 struct MipiCsiHandle {
15     struct MipiCsiCntlr *cntlr;
16     struct OsalMutex lock;
17     void *priv;
18 };
19 
20 static struct MipiCsiHandle g_mipiCsihandle[MAX_CNTLR_CNT];
21 
MipiCsiRegisterCntlr(struct MipiCsiCntlr * cntlr,struct HdfDeviceObject * device)22 int32_t MipiCsiRegisterCntlr(struct MipiCsiCntlr *cntlr, struct HdfDeviceObject *device)
23 {
24     HDF_LOGI("MipiCsiRegisterCntlr: enter!");
25     if (cntlr == NULL) {
26         HDF_LOGE("MipiCsiRegisterCntlr: cntlr is null!");
27         return HDF_ERR_INVALID_OBJECT;
28     }
29     if (cntlr->devNo >= MAX_CNTLR_CNT) {
30         HDF_LOGE("MipiCsiRegisterCntlr: cntlr->devNo is error!");
31         return HDF_ERR_INVALID_PARAM;
32     }
33     if (device == NULL) {
34         HDF_LOGE("MipiCsiRegisterCntlr: device is null!");
35         return HDF_ERR_INVALID_OBJECT;
36     }
37 
38     if (g_mipiCsihandle[cntlr->devNo].cntlr == NULL) {
39         (void)OsalMutexInit(&g_mipiCsihandle[cntlr->devNo].lock);
40         (void)OsalMutexInit(&(cntlr->lock));
41 
42         g_mipiCsihandle[cntlr->devNo].cntlr = cntlr;
43         g_mipiCsihandle[cntlr->devNo].priv = NULL;
44         cntlr->device = device;
45         device->service = &(cntlr->service);
46         cntlr->priv = NULL;
47         HDF_LOGI("MipiCsiRegisterCntlr: success!");
48 
49         return HDF_SUCCESS;
50     }
51 
52     HDF_LOGE("MipiCsiRegisterCntlr: cntlr already exists!");
53     return HDF_FAILURE;
54 }
55 
MipiCsiUnregisterCntlr(struct MipiCsiCntlr * cntlr)56 void MipiCsiUnregisterCntlr(struct MipiCsiCntlr *cntlr)
57 {
58     if (cntlr == NULL) {
59         HDF_LOGE("MipiCsiUnregisterCntlr: cntlr is null!");
60         return;
61     }
62 
63     (void)OsalMutexDestroy(&(cntlr->lock));
64     (void)OsalMutexDestroy(&(g_mipiCsihandle[cntlr->devNo].lock));
65 
66     HDF_LOGI("MipiCsiUnregisterCntlr: success!");
67     return;
68 }
69 
MipiCsiCntlrFromDevice(const struct HdfDeviceObject * device)70 struct MipiCsiCntlr *MipiCsiCntlrFromDevice(const struct HdfDeviceObject *device)
71 {
72     return (device == NULL) ? NULL : (struct MipiCsiCntlr *)device->service;
73 }
74 
MipiCsiCntlrGet(uint8_t number)75 struct MipiCsiCntlr *MipiCsiCntlrGet(uint8_t number)
76 {
77     struct MipiCsiCntlr *cntlr = NULL;
78     HDF_LOGI("MipiCsiCntlrGet: enter!");
79 
80     if (number >= MAX_CNTLR_CNT) {
81         HDF_LOGE("MipiCsiCntlrGet: invalid number!");
82         return NULL;
83     }
84     if (g_mipiCsihandle[number].cntlr == NULL) {
85         HDF_LOGE("MipiCsiCntlrGet: g_mipiCsihandle[number].cntlr is null!");
86         return NULL;
87     }
88 
89     (void)OsalMutexLock(&(g_mipiCsihandle[number].lock));
90     g_mipiCsihandle[number].cntlr->devNo = number;
91     cntlr = g_mipiCsihandle[number].cntlr;
92     (void)OsalMutexUnlock(&(g_mipiCsihandle[number].lock));
93 
94     return cntlr;
95 }
96 
MipiCsiCntlrPut(const struct MipiCsiCntlr * cntlr)97 void MipiCsiCntlrPut(const struct MipiCsiCntlr *cntlr)
98 {
99     uint8_t number;
100 
101     if (cntlr == NULL) {
102         HDF_LOGE("MipiCsiCntlrPut: cntlr is null!");
103         return;
104     }
105 
106     number = cntlr->devNo;
107     if (number >= MAX_CNTLR_CNT) {
108         HDF_LOGE("MipiCsiCntlrPut: invalid number!");
109         return;
110     }
111 
112     HDF_LOGI("MipiCsiCntlrPut: success!");
113 }
114 
MipiCsiCntlrSetComboDevAttr(struct MipiCsiCntlr * cntlr,ComboDevAttr * pAttr)115 int32_t MipiCsiCntlrSetComboDevAttr(struct MipiCsiCntlr *cntlr, ComboDevAttr *pAttr)
116 {
117     int32_t ret;
118     HDF_LOGI("MipiCsiCntlrSetComboDevAttr: enter!");
119 
120     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
121         HDF_LOGE("MipiCsiCntlrSetComboDevAttr: cntlr or ops is null!");
122         return HDF_ERR_INVALID_OBJECT;
123     }
124     if (pAttr == NULL) {
125         HDF_LOGE("MipiCsiCntlrSetComboDevAttr: pAttr is null!");
126         return HDF_ERR_INVALID_OBJECT;
127     }
128     if (cntlr->ops->setComboDevAttr == NULL) {
129         HDF_LOGE("MipiCsiCntlrSetComboDevAttr: setComboDevAttr is null!");
130         return HDF_ERR_NOT_SUPPORT;
131     }
132 
133     (void)OsalMutexLock(&(cntlr->lock));
134     ret = cntlr->ops->setComboDevAttr(cntlr, pAttr);
135     (void)OsalMutexUnlock(&(cntlr->lock));
136 
137     if (ret == HDF_SUCCESS) {
138         HDF_LOGI("MipiCsiCntlrSetComboDevAttr: success!");
139     } else {
140         HDF_LOGE("MipiCsiCntlrSetComboDevAttr: fail!");
141     }
142 
143     return ret;
144 }
145 
MipiCsiCntlrSetPhyCmvmode(struct MipiCsiCntlr * cntlr,uint8_t devno,PhyCmvMode cmvMode)146 int32_t MipiCsiCntlrSetPhyCmvmode(struct MipiCsiCntlr *cntlr, uint8_t devno, PhyCmvMode cmvMode)
147 {
148     int32_t ret;
149     HDF_LOGI("MipiCsiCntlrSetPhyCmvmode: enter!");
150 
151     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
152         HDF_LOGE("MipiCsiCntlrSetPhyCmvmode: cntlr or ops is null!");
153         return HDF_ERR_INVALID_OBJECT;
154     }
155     if (cntlr->ops->setPhyCmvmode == NULL) {
156         HDF_LOGE("MipiCsiCntlrSetPhyCmvmode: setPhyCmvmode is null!");
157         return HDF_ERR_NOT_SUPPORT;
158     }
159 
160     (void)OsalMutexLock(&(cntlr->lock));
161     ret = cntlr->ops->setPhyCmvmode(cntlr, devno, cmvMode);
162     (void)OsalMutexUnlock(&(cntlr->lock));
163 
164     if (ret == HDF_SUCCESS) {
165         HDF_LOGI("MipiCsiCntlrSetPhyCmvmode: success!");
166     } else {
167         HDF_LOGE("MipiCsiCntlrSetPhyCmvmode: fail!");
168     }
169 
170     return ret;
171 }
172 
MipiCsiCntlrSetExtDataType(struct MipiCsiCntlr * cntlr,ExtDataType * dataType)173 int32_t MipiCsiCntlrSetExtDataType(struct MipiCsiCntlr *cntlr, ExtDataType* dataType)
174 {
175     int32_t ret;
176     HDF_LOGI("MipiCsiCntlrSetExtDataType: enter!");
177 
178     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
179         HDF_LOGE("MipiCsiCntlrSetExtDataType: cntlr or ops is null!");
180         return HDF_ERR_INVALID_OBJECT;
181     }
182     if (dataType == NULL) {
183         HDF_LOGE("MipiCsiCntlrSetExtDataType: dataType is null!");
184         return HDF_FAILURE;
185     }
186     if (cntlr->ops->setExtDataType == NULL) {
187         HDF_LOGE("MipiCsiCntlrSetExtDataType: setExtDataType is null!");
188         return HDF_ERR_NOT_SUPPORT;
189     }
190 
191     (void)OsalMutexLock(&(cntlr->lock));
192     ret = cntlr->ops->setExtDataType(cntlr, dataType);
193     (void)OsalMutexUnlock(&(cntlr->lock));
194 
195     if (ret == HDF_SUCCESS) {
196         HDF_LOGI("MipiCsiCntlrSetExtDataType: success!");
197     } else {
198         HDF_LOGE("MipiCsiCntlrSetExtDataType: fail!");
199     }
200 
201     return ret;
202 }
203 
MipiCsiCntlrSetHsMode(struct MipiCsiCntlr * cntlr,LaneDivideMode laneDivideMode)204 int32_t MipiCsiCntlrSetHsMode(struct MipiCsiCntlr *cntlr, LaneDivideMode laneDivideMode)
205 {
206     int32_t ret;
207     HDF_LOGI("MipiCsiCntlrSetHsMode: enter!");
208 
209     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
210         HDF_LOGE("MipiCsiCntlrSetHsMode: cntlr or ops is null!");
211         return HDF_ERR_INVALID_OBJECT;
212     }
213     if (cntlr->ops->setHsMode == NULL) {
214         HDF_LOGE("MipiCsiCntlrSetHsMode: setHsMode is null!");
215         return HDF_ERR_NOT_SUPPORT;
216     }
217 
218     (void)OsalMutexLock(&(cntlr->lock));
219     ret = cntlr->ops->setHsMode(cntlr, laneDivideMode);
220     (void)OsalMutexUnlock(&(cntlr->lock));
221 
222     if (ret == HDF_SUCCESS) {
223         HDF_LOGI("MipiCsiCntlrSetHsMode: success!");
224     } else {
225         HDF_LOGE("MipiCsiCntlrSetHsMode: fail!");
226     }
227 
228     return ret;
229 }
230 
MipiCsiCntlrEnableClock(struct MipiCsiCntlr * cntlr,uint8_t comboDev)231 int32_t MipiCsiCntlrEnableClock(struct MipiCsiCntlr *cntlr, uint8_t comboDev)
232 {
233     int32_t ret;
234     HDF_LOGI("MipiCsiCntlrEnableClock: enter!");
235 
236     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
237         HDF_LOGE("MipiCsiCntlrEnableClock: cntlr or ops is null!");
238         return HDF_ERR_INVALID_OBJECT;
239     }
240     if (cntlr->ops->enableClock == NULL) {
241         HDF_LOGE("MipiCsiCntlrEnableClock: enableClock is null!");
242         return HDF_ERR_NOT_SUPPORT;
243     }
244 
245     (void)OsalMutexLock(&(cntlr->lock));
246     ret = cntlr->ops->enableClock(cntlr, comboDev);
247     (void)OsalMutexUnlock(&(cntlr->lock));
248 
249     if (ret == HDF_SUCCESS) {
250         HDF_LOGI("MipiCsiCntlrEnableClock: success!");
251     } else {
252         HDF_LOGE("MipiCsiCntlrEnableClock: fail!");
253     }
254 
255     return ret;
256 }
257 
MipiCsiCntlrDisableClock(struct MipiCsiCntlr * cntlr,uint8_t comboDev)258 int32_t MipiCsiCntlrDisableClock(struct MipiCsiCntlr *cntlr, uint8_t comboDev)
259 {
260     int32_t ret;
261     HDF_LOGI("MipiCsiCntlrDisableClock: enter!");
262 
263     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
264         HDF_LOGE("MipiCsiCntlrDisableClock: cntlr or ops is null!");
265         return HDF_ERR_INVALID_OBJECT;
266     }
267     if (cntlr->ops->disableClock == NULL) {
268         HDF_LOGE("MipiCsiCntlrDisableClock: disableClock is null!");
269         return HDF_ERR_NOT_SUPPORT;
270     }
271 
272     (void)OsalMutexLock(&(cntlr->lock));
273     ret = cntlr->ops->disableClock(cntlr, comboDev);
274     (void)OsalMutexUnlock(&(cntlr->lock));
275 
276     if (ret == HDF_SUCCESS) {
277         HDF_LOGI("MipiCsiCntlrDisableClock: success!");
278     } else {
279         HDF_LOGE("MipiCsiCntlrDisableClock: fail!");
280     }
281 
282     return ret;
283 }
284 
MipiCsiCntlrResetRx(struct MipiCsiCntlr * cntlr,uint8_t comboDev)285 int32_t MipiCsiCntlrResetRx(struct MipiCsiCntlr *cntlr, uint8_t comboDev)
286 {
287     int32_t ret;
288     HDF_LOGI("MipiCsiCntlrResetRx: enter!");
289 
290     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
291         HDF_LOGE("MipiCsiCntlrResetRx: cntlr or ops is null!");
292         return HDF_ERR_INVALID_OBJECT;
293     }
294     if (cntlr->ops->resetRx == NULL) {
295         HDF_LOGE("MipiCsiCntlrResetRx: resetRx is null!");
296         return HDF_ERR_NOT_SUPPORT;
297     }
298 
299     (void)OsalMutexLock(&(cntlr->lock));
300     ret = cntlr->ops->resetRx(cntlr, comboDev);
301     (void)OsalMutexUnlock(&(cntlr->lock));
302 
303     if (ret == HDF_SUCCESS) {
304         HDF_LOGI("MipiCsiCntlrResetRx: success!");
305     } else {
306         HDF_LOGE("MipiCsiCntlrResetRx: fail!");
307     }
308 
309     return ret;
310 }
311 
MipiCsiCntlrUnresetRx(struct MipiCsiCntlr * cntlr,uint8_t comboDev)312 int32_t MipiCsiCntlrUnresetRx(struct MipiCsiCntlr *cntlr, uint8_t comboDev)
313 {
314     int32_t ret;
315     HDF_LOGI("MipiCsiCntlrUnresetRx: enter!");
316 
317     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
318         HDF_LOGE("MipiCsiCntlrUnresetRx: cntlr or ops is null!");
319         return HDF_ERR_INVALID_OBJECT;
320     }
321     if (cntlr->ops->unresetRx == NULL) {
322         HDF_LOGE("MipiCsiCntlrUnresetRx: unresetRx is null!");
323         return HDF_ERR_NOT_SUPPORT;
324     }
325 
326     (void)OsalMutexLock(&(cntlr->lock));
327     ret = cntlr->ops->unresetRx(cntlr, comboDev);
328     (void)OsalMutexUnlock(&(cntlr->lock));
329 
330     if (ret == HDF_SUCCESS) {
331         HDF_LOGI("MipiCsiCntlrUnresetRx: success!");
332     } else {
333         HDF_LOGE("MipiCsiCntlrUnresetRx: fail!");
334     }
335 
336     return ret;
337 }
338 
MipiCsiCntlrEnableSensorClock(struct MipiCsiCntlr * cntlr,uint8_t snsClkSource)339 int32_t MipiCsiCntlrEnableSensorClock(struct MipiCsiCntlr *cntlr, uint8_t snsClkSource)
340 {
341     int32_t ret;
342     HDF_LOGI("MipiCsiCntlrEnableSensorClock: enter!");
343 
344     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
345         HDF_LOGE("MipiCsiCntlrEnableSensorClock: cntlr or ops is null!");
346         return HDF_ERR_INVALID_OBJECT;
347     }
348     if (cntlr->ops->enableSensorClock == NULL) {
349         HDF_LOGE("MipiCsiCntlrEnableSensorClock: enableSensorClock is null!");
350         return HDF_ERR_NOT_SUPPORT;
351     }
352 
353     (void)OsalMutexLock(&(cntlr->lock));
354     ret = cntlr->ops->enableSensorClock(cntlr, snsClkSource);
355     (void)OsalMutexUnlock(&(cntlr->lock));
356 
357     if (ret == HDF_SUCCESS) {
358         HDF_LOGI("MipiCsiCntlrEnableSensorClock: success!");
359     } else {
360         HDF_LOGE("MipiCsiCntlrEnableSensorClock: fail!");
361     }
362 
363     return ret;
364 }
365 
MipiCsiCntlrDisableSensorClock(struct MipiCsiCntlr * cntlr,uint8_t snsClkSource)366 int32_t MipiCsiCntlrDisableSensorClock(struct MipiCsiCntlr *cntlr, uint8_t snsClkSource)
367 {
368     int32_t ret;
369     HDF_LOGI("MipiCsiCntlrDisableSensorClock: enter!");
370 
371     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
372         HDF_LOGE("MipiCsiCntlrDisableSensorClock: cntlr or ops is null!");
373         return HDF_ERR_INVALID_OBJECT;
374     }
375     if (cntlr->ops->disableSensorClock == NULL) {
376         HDF_LOGE("MipiCsiCntlrDisableSensorClock: disableSensorClock is null!");
377         return HDF_ERR_NOT_SUPPORT;
378     }
379 
380     (void)OsalMutexLock(&(cntlr->lock));
381     ret = cntlr->ops->disableSensorClock(cntlr, snsClkSource);
382     (void)OsalMutexUnlock(&(cntlr->lock));
383 
384     if (ret == HDF_SUCCESS) {
385         HDF_LOGI("MipiCsiCntlrDisableSensorClock: success!");
386     } else {
387         HDF_LOGE("MipiCsiCntlrDisableSensorClock: fail!");
388     }
389 
390     return ret;
391 }
392 
MipiCsiCntlrResetSensor(struct MipiCsiCntlr * cntlr,uint8_t snsResetSource)393 int32_t MipiCsiCntlrResetSensor(struct MipiCsiCntlr *cntlr, uint8_t snsResetSource)
394 {
395     int32_t ret;
396     HDF_LOGI("MipiCsiCntlrResetSensor: enter!");
397 
398     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
399         HDF_LOGE("MipiCsiCntlrResetSensor: cntlr or ops is null!");
400         return HDF_ERR_INVALID_OBJECT;
401     }
402     if (cntlr->ops->resetSensor == NULL) {
403         HDF_LOGE("MipiCsiCntlrResetSensor: resetSensor is null!");
404         return HDF_ERR_NOT_SUPPORT;
405     }
406 
407     (void)OsalMutexLock(&(cntlr->lock));
408     ret = cntlr->ops->resetSensor(cntlr, snsResetSource);
409     (void)OsalMutexUnlock(&(cntlr->lock));
410 
411     if (ret == HDF_SUCCESS) {
412         HDF_LOGI("MipiCsiCntlrResetSensor: success!");
413     } else {
414         HDF_LOGE("MipiCsiCntlrResetSensor: fail!");
415     }
416 
417     return ret;
418 }
419 
MipiCsiCntlrUnresetSensor(struct MipiCsiCntlr * cntlr,uint8_t snsResetSource)420 int32_t MipiCsiCntlrUnresetSensor(struct MipiCsiCntlr *cntlr, uint8_t snsResetSource)
421 {
422     int32_t ret;
423     HDF_LOGI("MipiCsiCntlrUnresetSensor: enter!");
424 
425     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
426         HDF_LOGE("MipiCsiCntlrUnresetSensor: cntlr or ops is null!");
427         return HDF_ERR_INVALID_OBJECT;
428     }
429     if (cntlr->ops->unresetSensor == NULL) {
430         HDF_LOGE("MipiCsiCntlrUnresetSensor: unresetSensor is null!");
431         return HDF_ERR_NOT_SUPPORT;
432     }
433 
434     (void)OsalMutexLock(&(cntlr->lock));
435     ret = cntlr->ops->unresetSensor(cntlr, snsResetSource);
436     (void)OsalMutexUnlock(&(cntlr->lock));
437 
438     if (ret == HDF_SUCCESS) {
439         HDF_LOGI("MipiCsiCntlrUnresetSensor: success!");
440     } else {
441         HDF_LOGE("MipiCsiCntlrUnresetSensor: fail!");
442     }
443 
444     return ret;
445 }
446 
MipiCsiCntlrSetDrvData(struct MipiCsiCntlr * cntlr,void * drvData)447 int32_t MipiCsiCntlrSetDrvData(struct MipiCsiCntlr *cntlr, void *drvData)
448 {
449     int32_t ret;
450 
451     if ((cntlr == NULL) || (cntlr->ops == NULL)) {
452         HDF_LOGE("MipiCsiCntlrSetDrvData: cntlr or ops is null!");
453         return HDF_ERR_INVALID_OBJECT;
454     }
455 
456     if (cntlr->ops->setDrvData == NULL) {
457         HDF_LOGE("MipiCsiCntlrSetDrvData: setDrvData is null!");
458         return HDF_ERR_NOT_SUPPORT;
459     }
460 
461     (void)OsalMutexLock(&(cntlr->lock));
462     ret = cntlr->ops->setDrvData(cntlr, drvData);
463     (void)OsalMutexUnlock(&(cntlr->lock));
464 
465     if (ret == HDF_SUCCESS) {
466         HDF_LOGI("MipiCsiCntlrSetDrvData: success!");
467     } else {
468         HDF_LOGE("MipiCsiCntlrSetDrvData: fail!");
469     }
470 
471     return ret;
472 }
473 
MipiCsiDebugGetMipiDevCtx(struct MipiCsiCntlr * cntlr,MipiDevCtx * ctx)474 int32_t MipiCsiDebugGetMipiDevCtx(struct MipiCsiCntlr *cntlr, MipiDevCtx *ctx)
475 {
476     if (cntlr == NULL) {
477         HDF_LOGE("MipiCsiDebugGetMipiDevCtx: cntlr is null!");
478         return HDF_ERR_INVALID_OBJECT;
479     }
480     if (cntlr->debugs == NULL) {
481         HDF_LOGE("MipiCsiDebugGetMipiDevCtx: debugs is null!");
482         return HDF_ERR_NOT_SUPPORT;
483     }
484     if (cntlr->debugs->getMipiDevCtx == NULL) {
485         HDF_LOGE("MipiCsiDebugGetMipiDevCtx: getMipiDevCtx is null!");
486         return HDF_ERR_NOT_SUPPORT;
487     }
488     if (ctx == NULL) {
489         HDF_LOGE("MipiCsiDebugGetMipiDevCtx: ctx is null!");
490         return HDF_ERR_INVALID_OBJECT;
491     }
492 
493     (void)OsalMutexLock(&(cntlr->lock));
494     cntlr->debugs->getMipiDevCtx(cntlr, ctx);
495     (void)OsalMutexUnlock(&(cntlr->lock));
496     HDF_LOGI("MipiCsiDebugGetMipiDevCtx: success!");
497 
498     return HDF_SUCCESS;
499 }
500 
MipiCsiDebugGetPhyErrIntCnt(struct MipiCsiCntlr * cntlr,unsigned int phyId,PhyErrIntCnt * errInfo)501 int32_t MipiCsiDebugGetPhyErrIntCnt(struct MipiCsiCntlr *cntlr, unsigned int phyId, PhyErrIntCnt *errInfo)
502 {
503     if (cntlr == NULL) {
504         HDF_LOGE("MipiCsiDebugGetPhyErrIntCnt: cntlr is null!");
505         return HDF_ERR_INVALID_OBJECT;
506     }
507     if (cntlr->debugs == NULL) {
508         HDF_LOGE("MipiCsiDebugGetPhyErrIntCnt: debugs is null!");
509         return HDF_ERR_NOT_SUPPORT;
510     }
511     if (cntlr->debugs->getPhyErrIntCnt == NULL) {
512         HDF_LOGE("MipiCsiDebugGetPhyErrIntCnt: getPhyErrIntCnt is null!");
513         return HDF_ERR_NOT_SUPPORT;
514     }
515     if (errInfo == NULL) {
516         HDF_LOGE("MipiCsiDebugGetPhyErrIntCnt: errInfo is null!");
517         return HDF_ERR_INVALID_OBJECT;
518     }
519 
520     (void)OsalMutexLock(&(cntlr->lock));
521     cntlr->debugs->getPhyErrIntCnt(cntlr, phyId, errInfo);
522     (void)OsalMutexUnlock(&(cntlr->lock));
523     HDF_LOGI("MipiCsiDebugGetPhyErrIntCnt: success!");
524 
525     return HDF_SUCCESS;
526 }
527 
MipiCsiDebugGetMipiErrInt(struct MipiCsiCntlr * cntlr,unsigned int phyId,MipiErrIntCnt * errInfo)528 int32_t MipiCsiDebugGetMipiErrInt(struct MipiCsiCntlr *cntlr, unsigned int phyId, MipiErrIntCnt *errInfo)
529 {
530     if (cntlr == NULL) {
531         HDF_LOGE("MipiCsiDebugGetMipiErrInt: cntlr is null!");
532         return HDF_ERR_INVALID_OBJECT;
533     }
534     if (cntlr->debugs == NULL) {
535         HDF_LOGE("MipiCsiDebugGetMipiErrInt: debugs is null!");
536         return HDF_ERR_NOT_SUPPORT;
537     }
538     if (cntlr->debugs->getMipiErrInt == NULL) {
539         HDF_LOGE("MipiCsiDebugGetMipiErrInt: getMipiErrInt is null!");
540         return HDF_ERR_NOT_SUPPORT;
541     }
542     if (errInfo == NULL) {
543         HDF_LOGE("MipiCsiDebugGetMipiErrInt: errInfo is null!");
544         return HDF_ERR_INVALID_OBJECT;
545     }
546 
547     (void)OsalMutexLock(&(cntlr->lock));
548     cntlr->debugs->getMipiErrInt(cntlr, phyId, errInfo);
549     (void)OsalMutexUnlock(&(cntlr->lock));
550     HDF_LOGI("MipiCsiDebugGetMipiErrInt: success!");
551 
552     return HDF_SUCCESS;
553 }
554 
MipiCsiDebugGetLvdsErrIntCnt(struct MipiCsiCntlr * cntlr,unsigned int phyId,LvdsErrIntCnt * errInfo)555 int32_t MipiCsiDebugGetLvdsErrIntCnt(struct MipiCsiCntlr *cntlr, unsigned int phyId, LvdsErrIntCnt *errInfo)
556 {
557     if (cntlr == NULL) {
558         HDF_LOGE("MipiCsiDebugGetLvdsErrIntCnt: cntlr is null!");
559         return HDF_ERR_INVALID_OBJECT;
560     }
561     if (cntlr->debugs == NULL) {
562         HDF_LOGE("MipiCsiDebugGetLvdsErrIntCnt: debugs is null!");
563         return HDF_ERR_NOT_SUPPORT;
564     }
565     if (cntlr->debugs->getLvdsErrIntCnt == NULL) {
566         HDF_LOGE("MipiCsiDebugGetLvdsErrIntCnt: getLvdsErrIntCnt is null!");
567         return HDF_ERR_NOT_SUPPORT;
568     }
569     if (errInfo == NULL) {
570         HDF_LOGE("MipiCsiDebugGetLvdsErrIntCnt: errInfo is null!");
571         return HDF_ERR_INVALID_OBJECT;
572     }
573 
574     (void)OsalMutexLock(&(cntlr->lock));
575     cntlr->debugs->getLvdsErrIntCnt(cntlr, phyId, errInfo);
576     (void)OsalMutexUnlock(&(cntlr->lock));
577     HDF_LOGI("MipiCsiDebugGetLvdsErrIntCnt: success!");
578 
579     return HDF_SUCCESS;
580 }
581 
MipiCsiDebugGetAlignErrIntCnt(struct MipiCsiCntlr * cntlr,unsigned int phyId,AlignErrIntCnt * errInfo)582 int32_t MipiCsiDebugGetAlignErrIntCnt(struct MipiCsiCntlr *cntlr, unsigned int phyId, AlignErrIntCnt *errInfo)
583 {
584     if (cntlr == NULL) {
585         HDF_LOGE("MipiCsiDebugGetAlignErrIntCnt: cntlr is null!");
586         return HDF_ERR_INVALID_OBJECT;
587     }
588     if (cntlr->debugs == NULL) {
589         HDF_LOGE("MipiCsiDebugGetAlignErrIntCnt: debugs is null!");
590         return HDF_ERR_NOT_SUPPORT;
591     }
592     if (cntlr->debugs->getAlignErrIntCnt == NULL) {
593         HDF_LOGE("MipiCsiDebugGetAlignErrIntCnt: getAlignErrIntCnt is null!");
594         return HDF_ERR_NOT_SUPPORT;
595     }
596     if (errInfo == NULL) {
597         HDF_LOGE("MipiCsiDebugGetAlignErrIntCnt: errInfo is null!");
598         return HDF_ERR_INVALID_OBJECT;
599     }
600 
601     (void)OsalMutexLock(&(cntlr->lock));
602     cntlr->debugs->getAlignErrIntCnt(cntlr, phyId, errInfo);
603     (void)OsalMutexUnlock(&(cntlr->lock));
604     HDF_LOGI("MipiCsiDebugGetAlignErrIntCnt: success!");
605 
606     return HDF_SUCCESS;
607 }
608 
MipiCsiDebugGetPhyData(struct MipiCsiCntlr * cntlr,int phyId,int laneId,unsigned int * laneData)609 int32_t MipiCsiDebugGetPhyData(struct MipiCsiCntlr *cntlr, int phyId, int laneId, unsigned int *laneData)
610 {
611     if (cntlr == NULL) {
612         HDF_LOGE("MipiCsiDebugGetPhyData: cntlr is null!");
613         return HDF_ERR_INVALID_OBJECT;
614     }
615     if (cntlr->debugs == NULL) {
616         HDF_LOGE("MipiCsiDebugGetPhyData: debugs is null!");
617         return HDF_ERR_NOT_SUPPORT;
618     }
619     if (cntlr->debugs->getPhyData == NULL) {
620         HDF_LOGE("MipiCsiDebugGetPhyData: getPhyData is null!");
621         return HDF_ERR_NOT_SUPPORT;
622     }
623     if (laneData == NULL) {
624         HDF_LOGE("MipiCsiDebugGetPhyData: laneData is null!");
625         return HDF_ERR_INVALID_OBJECT;
626     }
627 
628     (void)OsalMutexLock(&(cntlr->lock));
629     cntlr->debugs->getPhyData(cntlr, phyId, laneId, laneData);
630     (void)OsalMutexUnlock(&(cntlr->lock));
631     HDF_LOGI("MipiCsiDebugGetPhyData: success!");
632 
633     return HDF_SUCCESS;
634 }
635 
MipiCsiDebugGetPhyMipiLinkData(struct MipiCsiCntlr * cntlr,int phyId,int laneId,unsigned int * laneData)636 int32_t MipiCsiDebugGetPhyMipiLinkData(struct MipiCsiCntlr *cntlr, int phyId, int laneId, unsigned int *laneData)
637 {
638     if (cntlr == NULL) {
639         HDF_LOGE("MipiCsiDebugGetPhyMipiLinkData: cntlr is null!");
640         return HDF_ERR_INVALID_OBJECT;
641     }
642     if (cntlr->debugs == NULL) {
643         HDF_LOGE("MipiCsiDebugGetPhyMipiLinkData: debugs is null!");
644         return HDF_ERR_NOT_SUPPORT;
645     }
646     if (cntlr->debugs->getPhyMipiLinkData == NULL) {
647         HDF_LOGE("MipiCsiDebugGetPhyMipiLinkData: getPhyMipiLinkData is null!");
648         return HDF_ERR_NOT_SUPPORT;
649     }
650     if (laneData == NULL) {
651         HDF_LOGE("MipiCsiDebugGetPhyMipiLinkData: laneData is null!");
652         return HDF_ERR_INVALID_OBJECT;
653     }
654 
655     (void)OsalMutexLock(&(cntlr->lock));
656     cntlr->debugs->getPhyMipiLinkData(cntlr, phyId, laneId, laneData);
657     (void)OsalMutexUnlock(&(cntlr->lock));
658     HDF_LOGI("MipiCsiDebugGetPhyMipiLinkData: success!");
659 
660     return HDF_SUCCESS;
661 }
662 
MipiCsiDebugGetPhyLvdsLinkData(struct MipiCsiCntlr * cntlr,int phyId,int laneId,unsigned int * laneData)663 int32_t MipiCsiDebugGetPhyLvdsLinkData(struct MipiCsiCntlr *cntlr, int phyId, int laneId, unsigned int *laneData)
664 {
665     if (cntlr == NULL) {
666         HDF_LOGE("MipiCsiDebugGetPhyLvdsLinkData: cntlr is null!");
667         return HDF_ERR_INVALID_OBJECT;
668     }
669     if (cntlr->debugs == NULL) {
670         HDF_LOGE("MipiCsiDebugGetPhyLvdsLinkData: debugs is null!");
671         return HDF_ERR_NOT_SUPPORT;
672     }
673     if (cntlr->debugs->getPhyLvdsLinkData == NULL) {
674         HDF_LOGE("MipiCsiDebugGetPhyLvdsLinkData: getPhyLvdsLinkData is null!");
675         return HDF_ERR_NOT_SUPPORT;
676     }
677     if (laneData == NULL) {
678         HDF_LOGE("MipiCsiDebugGetPhyLvdsLinkData: laneData is null!");
679         return HDF_ERR_INVALID_OBJECT;
680     }
681 
682     (void)OsalMutexLock(&(cntlr->lock));
683     cntlr->debugs->getPhyLvdsLinkData(cntlr, phyId, laneId, laneData);
684     (void)OsalMutexUnlock(&(cntlr->lock));
685     HDF_LOGI("MipiCsiDebugGetPhyLvdsLinkData: success!");
686 
687     return HDF_SUCCESS;
688 }
689 
MipiCsiDebugGetMipiImgsizeStatis(struct MipiCsiCntlr * cntlr,uint8_t devno,short vc,ImgSize * pSize)690 int32_t MipiCsiDebugGetMipiImgsizeStatis(struct MipiCsiCntlr *cntlr, uint8_t devno, short vc, ImgSize *pSize)
691 {
692     if (cntlr == NULL) {
693         HDF_LOGE("MipiCsiDebugGetMipiImgsizeStatis: cntlr is null!");
694         return HDF_ERR_INVALID_OBJECT;
695     }
696     if (cntlr->debugs == NULL) {
697         HDF_LOGE("MipiCsiDebugGetMipiImgsizeStatis: debugs is null!");
698         return HDF_ERR_NOT_SUPPORT;
699     }
700     if (cntlr->debugs->getMipiImgsizeStatis == NULL) {
701         HDF_LOGE("MipiCsiDebugGetMipiImgsizeStatis: getMipiImgsizeStatis is null!");
702         return HDF_ERR_NOT_SUPPORT;
703     }
704     if (pSize == NULL) {
705         HDF_LOGE("MipiCsiDebugGetMipiImgsizeStatis: pSize is null!");
706         return HDF_ERR_INVALID_OBJECT;
707     }
708 
709     (void)OsalMutexLock(&(cntlr->lock));
710     cntlr->debugs->getMipiImgsizeStatis(cntlr, devno, vc, pSize);
711     (void)OsalMutexUnlock(&(cntlr->lock));
712     HDF_LOGI("MipiCsiDebugGetMipiImgsizeStatis: success!");
713 
714     return HDF_SUCCESS;
715 }
716 
MipiCsiDebugGetLvdsImgsizeStatis(struct MipiCsiCntlr * cntlr,uint8_t devno,short vc,ImgSize * pSize)717 int32_t MipiCsiDebugGetLvdsImgsizeStatis(struct MipiCsiCntlr *cntlr, uint8_t devno, short vc, ImgSize *pSize)
718 {
719     if (cntlr == NULL) {
720         HDF_LOGE("MipiCsiDebugGetLvdsImgsizeStatis: cntlr is null!");
721         return HDF_ERR_INVALID_OBJECT;
722     }
723     if (cntlr->debugs == NULL) {
724         HDF_LOGE("MipiCsiDebugGetLvdsImgsizeStatis: debugs is null!");
725         return HDF_ERR_NOT_SUPPORT;
726     }
727     if (cntlr->debugs->getLvdsImgsizeStatis == NULL) {
728         HDF_LOGE("MipiCsiDebugGetLvdsImgsizeStatis: getLvdsImgsizeStatis is null!");
729         return HDF_ERR_NOT_SUPPORT;
730     }
731     if (pSize == NULL) {
732         HDF_LOGE("MipiCsiDebugGetLvdsImgsizeStatis: pSize is null!");
733         return HDF_ERR_INVALID_OBJECT;
734     }
735 
736     (void)OsalMutexLock(&(cntlr->lock));
737     cntlr->debugs->getLvdsImgsizeStatis(cntlr, devno, vc, pSize);
738     (void)OsalMutexUnlock(&(cntlr->lock));
739     HDF_LOGI("MipiCsiDebugGetLvdsImgsizeStatis: success!");
740 
741     return HDF_SUCCESS;
742 }
743 
MipiCsiDebugGetLvdsLaneImgsizeStatis(struct MipiCsiCntlr * cntlr,uint8_t devno,short lane,ImgSize * pSize)744 int32_t MipiCsiDebugGetLvdsLaneImgsizeStatis(struct MipiCsiCntlr *cntlr, uint8_t devno, short lane, ImgSize *pSize)
745 {
746     if (cntlr == NULL) {
747         HDF_LOGE("MipiCsiDebugGetLvdsLaneImgsizeStatis: cntlr is null!");
748         return HDF_ERR_INVALID_OBJECT;
749     }
750     if (cntlr->debugs == NULL) {
751         HDF_LOGE("MipiCsiDebugGetLvdsLaneImgsizeStatis: debugs is null!");
752         return HDF_ERR_NOT_SUPPORT;
753     }
754     if (cntlr->debugs->getLvdsLaneImgsizeStatis == NULL) {
755         HDF_LOGE("MipiCsiDebugGetLvdsLaneImgsizeStatis: getLvdsLaneImgsizeStatis is null!");
756         return HDF_ERR_NOT_SUPPORT;
757     }
758     if (pSize == NULL) {
759         HDF_LOGE("MipiCsiDebugGetLvdsLaneImgsizeStatis: pSize is null!");
760         return HDF_ERR_INVALID_OBJECT;
761     }
762 
763     (void)OsalMutexLock(&(cntlr->lock));
764     cntlr->debugs->getLvdsLaneImgsizeStatis(cntlr, devno, lane, pSize);
765     (void)OsalMutexUnlock(&(cntlr->lock));
766     HDF_LOGI("MipiCsiDebugGetLvdsLaneImgsizeStatis: success!");
767 
768     return HDF_SUCCESS;
769 }