xref: /utopia/UTPA2-700.0.x/modules/xc/drv/xc/apiXC_Adc.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 //
93 ////////////////////////////////////////////////////////////////////////////////
94 
95 ///////////////////////////////////////////////////////////////////////////////////////////////////
96 ///
97 /// file  apiXC_Adc.c
98 /// brief  Scaler API layer Interface
99 /// author MStar Semiconductor Inc.
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101 
102 #ifndef _API_XC_ADC_C_
103 #define _API_XC_ADC_C_
104 
105 //-------------------------------------------------------------------------------------------------
106 //  Include Files
107 //-------------------------------------------------------------------------------------------------
108 // Common Definition
109 
110 // Common
111 #include "MsCommon.h"
112 #include "utopia.h"
113 #include "utopia_dapi.h"
114 #include "mhal_xc_chip_config.h"
115 #include "drvXC_IOPort.h"
116 #include "apiXC.h"
117 
118 #include "apiXC_Adc.h"
119 #include "apiXC_Auto.h"
120 #include "drv_sc_display.h"
121 #include "drv_sc_isr.h"
122 #include "apiXC_PCMonitor.h"
123 #include "apiXC_ModeParse.h"
124 #include "drvXC_HDMI_if.h"
125 #include "mvideo_context.h"
126 #if (LD_ENABLE==1)
127 #include "mdrv_ld.h"
128 #include "mdrv_ldalgo.h"
129 #endif
130 #include "mdrv_sc_3d.h"
131 #include "drv_sc_menuload.h"
132 #include "drvXC_ADC_Internal.h"
133 #include "drv_sc_ip.h"
134 #include "mhal_sc.h"
135 #if FRC_INSIDE
136 #include "mdrv_frc.h"
137 #include "mhal_frc.h"
138 #endif
139 #include "XC_private.h"
140 #include "apiXC_v2.h"
141 #include "apiXC_Adc_v2.h"
142 #include "xc_hwreg_utility2.h"
143 
144 // Internal Definition
145 
146 //-------------------------------------------------------------------------------------------------
147 //  Driver Compiler Options
148 //-------------------------------------------------------------------------------------------------
149 
150 
151 //-------------------------------------------------------------------------------------------------
152 //  Local Defines
153 //-------------------------------------------------------------------------------------------------
154 
155 //-------------------------------------------------------------------------------------------------
156 //  Local Structurs
157 //-------------------------------------------------------------------------------------------------
158 
159 
160 //-------------------------------------------------------------------------------------------------
161 //  Global Variables
162 //-------------------------------------------------------------------------------------------------
163 
164 //-------------------------------------------------------------------------------------------------
165 //  Local Variables
166 //-------------------------------------------------------------------------------------------------
167 
168 //-------------------------------------------------------------------------------------------------
169 //  Debug Functions
170 //-------------------------------------------------------------------------------------------------
171 
172 //-------------------------------------------------------------------------------------------------
173 //  Local Functions
174 //-------------------------------------------------------------------------------------------------
175 
176 //******************************************************************************
177 /// Enable and Disable CVBS out. This will setup ADC part for CVBS out (monitor out).
178 /// @param bEnable \b IN Enable CVBS Out
179 /// @param enInputPortType \b IN The source need to monitor out.
180 /// @param isDigitalSource \b IN Tell the driver current source is digital source or not. (ex. If internal VIF used in ATV, it will be digital source)
181 //******************************************************************************
MApi_XC_ADC_SetCVBSOut_U2(void * pInstance,MS_BOOL bEnable,E_DEST_TYPE enOutputType,INPUT_SOURCE_TYPE_t enInputPortType,MS_BOOL isDigitalSource)182 void MApi_XC_ADC_SetCVBSOut_U2(void* pInstance, MS_BOOL bEnable, E_DEST_TYPE enOutputType , INPUT_SOURCE_TYPE_t enInputPortType, MS_BOOL isDigitalSource)
183 {
184     E_ADC_CVBSOUT_TYPE enCVBSoutType = ADC_CVBSOUT_DISABLE_1;
185     XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
186     UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
187     XC_RESOURCE_PRIVATE* pXCResourcePrivate = NULL;
188     E_XC_SOURCE_TO_VE eSourceToVE = E_XC_NONE;
189 /*
190     printf("====>CVBS out is %s", (bEnable) ?("ENABLE"):("DISABLE"));
191     printf(" and Output is from =%s(%x), eSourceToVE=%x, enInputPortType=%u\n", (enOutputType==20)?("CVBS_OUT1"):
192                                                     (enOutputType==21)?("CVBS_OUT2"):("Others"), enOutputType, gSrcInfo[MAIN_WINDOW].Status2.eSourceToVE, enInputPortType);
193 */
194     if ( bEnable )
195     {
196         if ( enOutputType == OUTPUT_CVBS1)
197         {
198             _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
199             UtopiaResourceGetPrivate(g_pXCResource[_XC_SELECT_INTERNAL_VARIABLE(psXCInstPri->u32DeviceID)],(void**)(&pXCResourcePrivate));
200 			eSourceToVE = gSrcInfo[MAIN_WINDOW].Status2.eSourceToVE;
201             _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
202             if (IsSrcTypeDTV(enInputPortType) ||
203                 ( eSourceToVE!= E_XC_NONE))
204             {
205                 //IP/DI/OP2 to VE case, need goes with VIF_VE path
206                 enCVBSoutType = ADC_CVBSOUT_VIF_VE_1;
207             }
208             else if ( IsSrcTypeATV(enInputPortType) && isDigitalSource )
209             {
210                 enCVBSoutType = ADC_CVBSOUT_VIF_VIF_1;  // VIF source.
211             }
212             else if ( IsSrcTypeSV(enInputPortType) )
213             {
214                 enCVBSoutType = ADC_CVBSOUT_SV_ON_1;
215             }
216             else
217             {
218                 enCVBSoutType = ADC_CVBSOUT_CVBS_ON_1;
219             }
220         }
221         else if ( enOutputType == OUTPUT_CVBS2)
222         {
223             _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
224             UtopiaResourceGetPrivate(g_pXCResource[_XC_SELECT_INTERNAL_VARIABLE(psXCInstPri->u32DeviceID)],(void**)(&pXCResourcePrivate));
225 			eSourceToVE = gSrcInfo[MAIN_WINDOW].Status2.eSourceToVE;
226             _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
227 
228             if (IsSrcTypeDTV(enInputPortType) ||
229                 (eSourceToVE != E_XC_NONE))
230             {
231                 //IP/DI/OP2 to VE case, need goes with VIF_VE path
232                 enCVBSoutType = ADC_CVBSOUT_VIF_VE_2;
233             }
234             else if ( IsSrcTypeATV(enInputPortType) && isDigitalSource )
235             {
236                 enCVBSoutType = ADC_CVBSOUT_VIF_VIF_2;  // VIF source.
237             }
238             else if ( IsSrcTypeSV(enInputPortType) )
239             {
240                 enCVBSoutType = ADC_CVBSOUT_SV_ON_2;
241             }
242             else
243             {
244                 enCVBSoutType = ADC_CVBSOUT_CVBS_ON_2;
245             }
246         }
247     }
248     else
249     {
250         if ( enOutputType == OUTPUT_CVBS1)
251         {
252             enCVBSoutType = ADC_CVBSOUT_DISABLE_1;
253         }
254         else if ( enOutputType == OUTPUT_CVBS2)
255         {
256             enCVBSoutType = ADC_CVBSOUT_DISABLE_2;
257         }
258     }
259     _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
260     _XC_ENTRY(pInstance);
261     MDrv_XC_ADC_set_cvbs_out(pInstance, enCVBSoutType );
262     _XC_RETURN(pInstance);
263     _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
264 
265 }
266 
MApi_XC_ADC_SetCVBSOut(MS_BOOL bEnable,E_DEST_TYPE enOutputType,INPUT_SOURCE_TYPE_t enInputPortType,MS_BOOL isDigitalSource)267 void MApi_XC_ADC_SetCVBSOut(MS_BOOL bEnable, E_DEST_TYPE enOutputType , INPUT_SOURCE_TYPE_t enInputPortType, MS_BOOL isDigitalSource)
268 {
269     if (pu32XCInst == NULL)
270     {
271         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
272         return;
273     }
274 
275     stXC_ADC_SETCVBSOUT XCArgs;
276     XCArgs.bEnable = bEnable;
277     XCArgs.enOutputType = enOutputType;
278     XCArgs.enInputPortType = enInputPortType;
279     XCArgs.isDigitalSource = isDigitalSource;
280 
281     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETCVBSOUT, (void*)&XCArgs) != 0)
282     {
283         printf("Obtain XC engine fail\n");
284         return;
285     }
286     else
287     {
288         return;
289     }
290 }
291 
MApi_XC_ADC_IsCVBSOutEnabled_U2(void * pInstance,E_DEST_TYPE enOutputType)292 MS_BOOL MApi_XC_ADC_IsCVBSOutEnabled_U2(void* pInstance, E_DEST_TYPE enOutputType)
293 {
294     if (enOutputType == OUTPUT_CVBS1 || enOutputType == OUTPUT_CVBS2)
295     {
296         return MDrv_XC_ADC_Is_cvbs_out_enabled(pInstance, enOutputType);
297     }
298     else
299         return FALSE;
300 
301 }
302 
MApi_XC_ADC_IsCVBSOutEnabled(E_DEST_TYPE enOutputType)303 MS_BOOL MApi_XC_ADC_IsCVBSOutEnabled(E_DEST_TYPE enOutputType)
304 {
305     if (pu32XCInst == NULL)
306     {
307         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
308         return FALSE;
309     }
310 
311     stXC_ADC_ISCVBSOUTENABLED XCArgs;
312     XCArgs.enOutputType = enOutputType;
313     XCArgs.bReturnValue = FALSE;
314 
315     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_ISCVBSOUTENABLED, (void*)&XCArgs) != 0)
316     {
317         printf("Obtain XC engine fail\n");
318         return FALSE;
319     }
320     else
321     {
322         return XCArgs.bReturnValue;
323     }
324 }
325 
326 /******************************************************************************/
327 /// Set ADC Sample clock
328 /// @param u16Value \b IN value need to be set.
329 /******************************************************************************/
MApi_XC_ADC_SetPcClock_U2(void * pInstance,MS_U16 u16Value)330 void MApi_XC_ADC_SetPcClock_U2( void* pInstance, MS_U16 u16Value )
331 {
332     //add for  mantis 0513674
333     _XC_ENTRY(pInstance);
334     MDrv_XC_wait_input_vsync(pInstance, 1, 50, MAIN_WINDOW);
335     _XC_RETURN(pInstance);
336 
337     MDrv_XC_ADC_SetPcClock(pInstance, u16Value);
338 }
339 
MApi_XC_ADC_SetPcClock(MS_U16 u16Value)340 void MApi_XC_ADC_SetPcClock( MS_U16 u16Value )
341 {
342     if (pu32XCInst == NULL)
343     {
344         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
345         return;
346     }
347 
348     stXC_ADC_SETPCCLOCK XCArgs;
349     XCArgs.u16Value = u16Value;
350 
351     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETPCCLOCK, (void*)&XCArgs) != 0)
352     {
353         printf("Obtain XC engine fail\n");
354         return;
355     }
356     else
357     {
358         return;
359     }
360 }
361 
362 /******************************************************************************/
363 /// Set ADC Phase, pls use MApi_XC_ADC_SetPhaseEx instead
364 /// @param u8Value \b IN The adc phase need to be update
365 /******************************************************************************/
MApi_XC_ADC_SetPhase_U2(void * pInstance,MS_U8 u8Value)366 void MApi_XC_ADC_SetPhase_U2(void* pInstance, MS_U8 u8Value)
367 {
368     MDrv_XC_ADC_SetPhaseWithVSync(pInstance, (MS_U16)u8Value);
369 }
370 
MApi_XC_ADC_SetPhase(MS_U8 u8Value)371 void MApi_XC_ADC_SetPhase(MS_U8 u8Value)
372 {
373     if (pu32XCInst == NULL)
374     {
375         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
376         return;
377     }
378 
379     stXC_ADC_SETPHASE XCArgs;
380     XCArgs.u8Value = u8Value;
381 
382     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETPHASE, (void*)&XCArgs) != 0)
383     {
384         printf("Obtain XC engine fail\n");
385         return;
386     }
387     else
388     {
389         return;
390     }
391 }
392 
393 
394 /******************************************************************************/
395 /// Set ADC Phase Ex
396 /// @param u16Value \b IN The adc phase need to be update
397 /******************************************************************************/
MApi_XC_ADC_SetPhaseEx_U2(void * pInstance,MS_U16 u16Value)398 void MApi_XC_ADC_SetPhaseEx_U2( void* pInstance, MS_U16 u16Value )
399 {
400     MDrv_XC_ADC_SetPhaseWithVSync(pInstance, u16Value);
401 }
402 
MApi_XC_ADC_SetPhaseEx(MS_U16 u16Value)403 void MApi_XC_ADC_SetPhaseEx( MS_U16 u16Value )
404 {
405     if (pu32XCInst == NULL)
406     {
407         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
408         return;
409     }
410 
411     stXC_ADC_SETPHASEEX XCArgs;
412     XCArgs.u16Value = u16Value;
413 
414     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETPHASEEX, (void*)&XCArgs) != 0)
415     {
416         printf("Obtain XC engine fail\n");
417         return;
418     }
419     else
420     {
421         return;
422     }
423 }
424 
425 //******************************************************************************
426 /// Get current ADC Phase set
427 /// @return Current Phase
428 //******************************************************************************
MApi_XC_ADC_GetPhaseRange_U2(void * pInstance)429 MS_U16 MApi_XC_ADC_GetPhaseRange_U2( void* pInstance )
430 {
431     return MDrv_XC_ADC_GetPhaseRange(pInstance);
432 }
433 
MApi_XC_ADC_GetPhaseRange(void)434 MS_U16 MApi_XC_ADC_GetPhaseRange( void )
435 {
436     if (pu32XCInst == NULL)
437     {
438         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
439         return 0;
440     }
441 
442     stXC_ADC_GETPHASERANGE XCArgs;
443     XCArgs.u16ReturnValue = 0;
444 
445     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETPHASERANGE, (void*)&XCArgs) != 0)
446     {
447         printf("Obtain XC engine fail\n");
448         return 0;
449     }
450     else
451     {
452         return XCArgs.u16ReturnValue;
453     }
454 }
455 
456 //******************************************************************************
457 /// Get current ADC Phase set
458 /// @return Current Phase
459 //******************************************************************************
MApi_XC_ADC_GetPhase_U2(void * pInstance)460 MS_U8 MApi_XC_ADC_GetPhase_U2( void* pInstance )
461 {
462     return MDrv_XC_ADC_GetPhase(pInstance);
463 }
464 
MApi_XC_ADC_GetPhase(void)465 MS_U8 MApi_XC_ADC_GetPhase( void )
466 {
467     if (pu32XCInst == NULL)
468     {
469         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
470         return 0;
471     }
472 
473     stXC_ADC_GETPHASE XCArgs;
474     XCArgs.u8ReturnValue = 0;
475 
476     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETPHASE, (void*)&XCArgs) != 0)
477     {
478         printf("Obtain XC engine fail\n");
479         return 0;
480     }
481     else
482     {
483         return XCArgs.u8ReturnValue;
484     }
485 }
486 
MApi_XC_ADC_GetPhaseEx_U2(void * pInstance)487 MS_U16 MApi_XC_ADC_GetPhaseEx_U2( void* pInstance )
488 {
489     return MDrv_XC_ADC_GetPhaseEx(pInstance);
490 }
491 
MApi_XC_ADC_GetPhaseEx(void)492 MS_U16 MApi_XC_ADC_GetPhaseEx( void )
493 {
494     if (pu32XCInst == NULL)
495     {
496         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
497         return 0;
498     }
499 
500     stXC_ADC_GETPHASEEX XCArgs;
501     XCArgs.u16ReturnValue = 0;
502 
503     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETPHASEEX, (void*)&XCArgs) != 0)
504     {
505         printf("Obtain XC engine fail\n");
506         return 0;
507     }
508     else
509     {
510         return XCArgs.u16ReturnValue;
511     }
512 }
513 
514 
MApi_XC_ADC_IsScartRGB_U2(void * pInstance)515 MS_BOOL MApi_XC_ADC_IsScartRGB_U2(void* pInstance)
516 {
517     return MDrv_XC_ADC_IsScartRGB(pInstance);
518 }
519 
MApi_XC_ADC_IsScartRGB(void)520 MS_BOOL MApi_XC_ADC_IsScartRGB(void)
521 {
522     if (pu32XCInst == NULL)
523     {
524         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
525         return FALSE;
526     }
527 
528     stXC_ADC_ISSCARTRGB XCArgs;
529     XCArgs.bReturnValue = FALSE;
530 
531     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_ISSCARTRGB, (void*)&XCArgs) != 0)
532     {
533         printf("Obtain XC engine fail\n");
534         return FALSE;
535     }
536     else
537     {
538         return XCArgs.bReturnValue;
539     }
540 }
541 
542 
MApi_XC_ADC_GetPcClock_U2(void * pInstance)543 MS_U16 MApi_XC_ADC_GetPcClock_U2(void* pInstance)
544 {
545     return MDrv_XC_ADC_GetPcClock(pInstance);
546 }
547 
MApi_XC_ADC_GetPcClock(void)548 MS_U16 MApi_XC_ADC_GetPcClock(void)
549 {
550     if (pu32XCInst == NULL)
551     {
552         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
553         return 0;
554     }
555 
556     stXC_ADC_GETPCCLOCK XCArgs;
557     XCArgs.u16ReturnValue = 0;
558 
559     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETPCCLOCK, (void*)&XCArgs) != 0)
560     {
561         printf("Obtain XC engine fail\n");
562         return 0;
563     }
564     else
565     {
566         return XCArgs.u16ReturnValue;
567     }
568 }
569 
570 /******************************************************************************/
571 ///Get SOG level range
572 ///@param u32Min \b OUT: min of SOG level
573 ///@param u32Max \b OUT: max of SOG level
574 ///@param u32Recommend_value \b OUT: recommend value
575 /******************************************************************************/
MApi_XC_ADC_GetSoGLevelRange_U2(void * pInstance,MS_U32 * u32min,MS_U32 * u32max,MS_U32 * u32Recommend_value)576 void MApi_XC_ADC_GetSoGLevelRange_U2(void* pInstance, MS_U32 *u32min, MS_U32 *u32max, MS_U32 *u32Recommend_value)
577 {
578     MDrv_XC_ADC_GetSoGLevelRange(pInstance, u32min, u32max, u32Recommend_value);
579 }
580 
MApi_XC_ADC_GetSoGLevelRange(MS_U32 * u32min,MS_U32 * u32max,MS_U32 * u32Recommend_value)581 void MApi_XC_ADC_GetSoGLevelRange(MS_U32 *u32min, MS_U32 *u32max, MS_U32 *u32Recommend_value)
582 {
583     if (pu32XCInst == NULL)
584     {
585         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
586         return;
587     }
588 
589     stXC_ADC_GETSOGLEVELRANGE XCArgs;
590     XCArgs.u32min = u32min;
591     XCArgs.u32max = u32max;
592     XCArgs.u32Recommend_value = u32Recommend_value;
593 
594     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETSOGLEVELRANGE, (void*)&XCArgs) != 0)
595     {
596         printf("Obtain XC engine fail\n");
597         return;
598     }
599     else
600     {
601         return;
602     }
603 }
604 
605 
606 /******************************************************************************/
607 ///Set SOG level
608 ///@param u32Min \b IN: set SOG level
609 /******************************************************************************/
MApi_XC_ADC_SetSoGLevel_U2(void * pInstance,MS_U32 u32Value)610 void MApi_XC_ADC_SetSoGLevel_U2(void* pInstance, MS_U32 u32Value)
611 {
612     MDrv_XC_ADC_SetSoGLevel(pInstance, u32Value);
613 }
614 
MApi_XC_ADC_SetSoGLevel(MS_U32 u32Value)615 void MApi_XC_ADC_SetSoGLevel(MS_U32 u32Value)
616 {
617     if (pu32XCInst == NULL)
618     {
619         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
620         return;
621     }
622 
623     stXC_ADC_SETSOGLEVEL XCArgs;
624     XCArgs.u32Value = u32Value;
625 
626     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETSOGLEVEL, (void*)&XCArgs) != 0)
627     {
628         printf("Obtain XC engine fail\n");
629         return;
630     }
631     else
632     {
633         return;
634     }
635 }
636 
637 //******************************************************************************
638 /// Turn off ADC
639 //******************************************************************************
MApi_XC_ADC_PowerOff_U2(void * pInstance)640 void MApi_XC_ADC_PowerOff_U2(void* pInstance)
641 {
642     MDrv_XC_ADC_PowerOff(pInstance);
643 }
644 
MApi_XC_ADC_PowerOff(void)645 void MApi_XC_ADC_PowerOff(void)
646 {
647     if (pu32XCInst == NULL)
648     {
649         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
650         return;
651     }
652 
653     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_POWEROFF, NULL) != 0)
654     {
655         printf("Obtain XC engine fail\n");
656         return;
657     }
658     else
659     {
660         return;
661     }
662 }
663 
664 
665 //******************************************************************************
666 /// Get ADC Default gain / offset by referring input structure.
667 /// @param eSource \b IN The input source
668 /// @param pstADCSetting \b IN gain / offset need to be set
669 //******************************************************************************
MApi_XC_ADC_GetDefaultGainOffset_U2(void * pInstance,INPUT_SOURCE_TYPE_t enSource,APIXC_AdcGainOffsetSetting * pstADCSetting)670 void MApi_XC_ADC_GetDefaultGainOffset_U2(void* pInstance, INPUT_SOURCE_TYPE_t enSource , APIXC_AdcGainOffsetSetting* pstADCSetting)
671 {
672     MDrv_XC_ADC_GetDefaultGainOffset(pInstance, enSource, pstADCSetting);
673 }
674 
MApi_XC_ADC_GetDefaultGainOffset(INPUT_SOURCE_TYPE_t enSource,APIXC_AdcGainOffsetSetting * pstADCSetting)675 void MApi_XC_ADC_GetDefaultGainOffset(INPUT_SOURCE_TYPE_t enSource , APIXC_AdcGainOffsetSetting* pstADCSetting)
676 {
677     if (pu32XCInst == NULL)
678     {
679         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
680         return;
681     }
682 
683     stXC_ADC_GETDEFAULTGAINOFFSET XCArgs;
684     XCArgs.enSource = enSource;
685     XCArgs.pstADCSetting = pstADCSetting;
686 
687     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETDEFAULTGAINOFFSET, (void*)&XCArgs) != 0)
688     {
689         printf("Obtain XC engine fail\n");
690         return;
691     }
692     else
693     {
694         return;
695     }
696 }
697 
698 //******************************************************************************
699 /// get maximal value of offset
700 /// @param
701 /// @return maximal value of offset
702 //******************************************************************************
MApi_XC_ADC_GetMaximalOffsetValue_U2(void * pInstance)703 MS_U16 MApi_XC_ADC_GetMaximalOffsetValue_U2(void* pInstance)
704 {
705     return MDrv_XC_ADC_GetMaximalOffsetValue(pInstance);
706 }
707 
MApi_XC_ADC_GetMaximalOffsetValue(void)708 MS_U16 MApi_XC_ADC_GetMaximalOffsetValue(void)
709 {
710     if (pu32XCInst == NULL)
711     {
712         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
713         return 0;
714     }
715 
716     stXC_ADC_GETMAXIMALOFFSETVALUE XCArgs;
717     XCArgs.u16ReturnValue = 0;
718 
719     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETMAXIMALOFFSETVALUE, (void*)&XCArgs) != 0)
720     {
721         printf("Obtain XC engine fail\n");
722         return 0;
723     }
724     else
725     {
726         return XCArgs.u16ReturnValue;
727     }
728 }
729 
730 
731 //******************************************************************************
732 /// get maximal value of gain
733 /// @param
734 /// @return maximal value of gain
735 //******************************************************************************
MApi_XC_ADC_GetMaximalGainValue_U2(void * pInstance)736 MS_U16 MApi_XC_ADC_GetMaximalGainValue_U2(void* pInstance)
737 {
738     return MDrv_XC_ADC_GetMaximalGainValue(pInstance);
739 }
740 
MApi_XC_ADC_GetMaximalGainValue(void)741 MS_U16 MApi_XC_ADC_GetMaximalGainValue(void)
742 {
743     if (pu32XCInst == NULL)
744     {
745         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
746         return 0;
747     }
748 
749     stXC_ADC_GETMAXIMALGAINVALUE XCArgs;
750     XCArgs.u16ReturnValue = 0;
751 
752     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETMAXIMALGAINVALUE, (void*)&XCArgs) != 0)
753     {
754         printf("Obtain XC engine fail\n");
755         return 0;
756     }
757     else
758     {
759         return XCArgs.u16ReturnValue;
760     }
761 
762 }
763 
764 //******************************************************************************
765 /// get HW center Gain value
766 /// @param
767 /// @return HW default Gain value
768 //******************************************************************************
MApi_XC_ADC_GetCenterGain_U2(void * pInstance)769 MS_U16 MApi_XC_ADC_GetCenterGain_U2(void* pInstance)
770 {
771     return MDrv_XC_ADC_GetCenterGain(pInstance);
772 }
773 
MApi_XC_ADC_GetCenterGain(void)774 MS_U16 MApi_XC_ADC_GetCenterGain(void)
775 {
776     if (pu32XCInst == NULL)
777     {
778         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
779         return 0;
780     }
781 
782     stXC_ADC_GETCENTERGAIN XCArgs;
783     XCArgs.u16ReturnValue = 0;
784 
785     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETCENTERGAIN, (void*)&XCArgs) != 0)
786     {
787         printf("Obtain XC engine fail\n");
788         return 0;
789     }
790     else
791     {
792         return XCArgs.u16ReturnValue;
793     }
794 }
795 
796 //******************************************************************************
797 /// get HW center Gain value
798 /// @param
799 /// @return HW default Gain value
800 //******************************************************************************
MApi_XC_ADC_GetCenterOffset_U2(void * pInstance)801 MS_U16 MApi_XC_ADC_GetCenterOffset_U2(void* pInstance)
802 {
803     return MDrv_XC_ADC_GetCenterOffset(pInstance);
804 }
805 
MApi_XC_ADC_GetCenterOffset(void)806 MS_U16 MApi_XC_ADC_GetCenterOffset(void)
807 {
808     if (pu32XCInst == NULL)
809     {
810         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
811         return 0;
812     }
813 
814     stXC_ADC_GETCENTEROFFSET XCArgs;
815     XCArgs.u16ReturnValue = 0;
816 
817     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GETCENTEROFFSET, (void*)&XCArgs) != 0)
818     {
819         printf("Obtain XC engine fail\n");
820         return 0;
821     }
822     else
823     {
824         return XCArgs.u16ReturnValue;
825     }
826 }
827 
828 //******************************************************************************
829 /// Set Gain value
830 /// @param u8color \b IN The channel type need to be set
831 /// @param u16value \b IN The value need to be set.
832 //******************************************************************************
MApi_XC_ADC_SetGain_U2(void * pInstance,MS_U8 u8Color,MS_U16 u16Value)833 void MApi_XC_ADC_SetGain_U2(void* pInstance, MS_U8 u8Color, MS_U16 u16Value)
834 {
835     MDrv_XC_ADC_SetGain(pInstance, u8Color, u16Value);
836 }
837 
MApi_XC_ADC_SetGain(MS_U8 u8Color,MS_U16 u16Value)838 void MApi_XC_ADC_SetGain(MS_U8 u8Color, MS_U16 u16Value)
839 {
840     if (pu32XCInst == NULL)
841     {
842         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
843         return;
844     }
845 
846     stXC_ADC_SETGAIN XCArgs;
847     XCArgs.u8Color = u8Color;
848     XCArgs.u16Value = u16Value;
849 
850     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETGAIN, (void*)&XCArgs) != 0)
851     {
852         printf("Obtain XC engine fail\n");
853         return;
854     }
855     else
856     {
857         return;
858     }
859 }
860 
861 //******************************************************************************
862 /// Set offset value
863 /// @param u8color \b IN The channel type need to be set
864 /// @param u16Value \b IN The value need to be set.
865 //******************************************************************************
MApi_XC_ADC_SetOffset_U2(void * pInstance,MS_U8 u8Color,MS_U16 u16Value)866 void MApi_XC_ADC_SetOffset_U2(void* pInstance, MS_U8 u8Color, MS_U16 u16Value)
867 {
868     MDrv_XC_ADC_SetOffset(pInstance, u8Color, u16Value);
869 }
870 
MApi_XC_ADC_SetOffset(MS_U8 u8Color,MS_U16 u16Value)871 void MApi_XC_ADC_SetOffset(MS_U8 u8Color, MS_U16 u16Value)
872 {
873     if (pu32XCInst == NULL)
874     {
875         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
876         return;
877     }
878 
879     stXC_ADC_SETOFFSET XCArgs;
880     XCArgs.u8Color = u8Color;
881     XCArgs.u16Value = u16Value;
882 
883     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETOFFSET, (void*)&XCArgs) != 0)
884     {
885         printf("Obtain XC engine fail\n");
886         return;
887     }
888     else
889     {
890         return;
891     }
892 }
893 
894 //******************************************************************************
895 /// Set ADC gain / offset by referring input structure.
896 /// @param pstADCSetting \b IN gain / offset need to be set
897 //******************************************************************************
MApi_XC_ADC_AdjustGainOffset_U2(void * pInstance,APIXC_AdcGainOffsetSetting * pstADCSetting)898 void MApi_XC_ADC_AdjustGainOffset_U2(void* pInstance, APIXC_AdcGainOffsetSetting* pstADCSetting)
899 {
900     if(pstADCSetting == NULL)
901     {
902         return;
903     }
904     _XC_ENTRY(pInstance);
905     MDrv_XC_ADC_SetOffsetSetting(pInstance, pstADCSetting);
906     MDrv_XC_ADC_SetGainSetting(pInstance, pstADCSetting);
907     _XC_RETURN(pInstance);
908 }
909 
MApi_XC_ADC_AdjustGainOffset(APIXC_AdcGainOffsetSetting * pstADCSetting)910 void MApi_XC_ADC_AdjustGainOffset(APIXC_AdcGainOffsetSetting* pstADCSetting)
911 {
912     if (pu32XCInst == NULL)
913     {
914         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
915         return;
916     }
917 
918     stXC_ADC_ADJUSTGAINOFFSET XCArgs;
919     XCArgs.pstADCSetting = pstADCSetting;
920 
921     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_ADJUSTGAINOFFSET, (void*)&XCArgs) != 0)
922     {
923         printf("Obtain XC engine fail\n");
924         return;
925     }
926     else
927     {
928         return;
929     }
930 }
931 
932 //******************************************************************************
933 /// Set ADC calibration for each input source
934 /// @param enInputSource \b IN The source array.
935 //******************************************************************************
MApi_XC_ADC_Source_Calibrate_U2(void * pInstance,INPUT_SOURCE_TYPE_t enInputSourceType)936 void MApi_XC_ADC_Source_Calibrate_U2(void* pInstance, INPUT_SOURCE_TYPE_t enInputSourceType)
937 {
938     XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
939     UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
940     _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
941     MDrv_XC_ADC_Source_Calibrate(pInstance, MDrv_XC_ADC_ConvertSrcToADCSrc(pInstance, enInputSourceType));
942     _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
943 }
944 
MApi_XC_ADC_Source_Calibrate(INPUT_SOURCE_TYPE_t enInputSourceType)945 void MApi_XC_ADC_Source_Calibrate(INPUT_SOURCE_TYPE_t enInputSourceType)
946 {
947     if (pu32XCInst == NULL)
948     {
949         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
950         return;
951     }
952 
953     stXC_ADC_SOURCE_CALIBRATE XCArgs;
954     XCArgs.enInputSourceType = enInputSourceType;
955 
956     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SOURCE_CALIBRATE, (void*)&XCArgs) != 0)
957     {
958         printf("Obtain XC engine fail\n");
959         return;
960     }
961     else
962     {
963         return;
964     }
965 }
966 
967 /******************************************************************************/
968 ///Set SOG level
969 /******************************************************************************/
MApi_XC_ADC_SetSoGCal_U2(void * pInstance)970 void MApi_XC_ADC_SetSoGCal_U2(void* pInstance)
971 {
972     MDrv_XC_ADC_SetSoGCal(pInstance);
973 }
974 
MApi_XC_ADC_SetSoGCal(void)975 void MApi_XC_ADC_SetSoGCal(void)
976 {
977     if (pu32XCInst == NULL)
978     {
979         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
980         return;
981     }
982 
983     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETSOGCAL, NULL) != 0)
984     {
985         printf("Obtain XC engine fail\n");
986         return;
987     }
988     else
989     {
990         return;
991     }
992 }
993 
MApi_XC_ADC_SetRGB_PIPE_Delay_U2(void * pInstance,MS_U8 u8Value)994 void MApi_XC_ADC_SetRGB_PIPE_Delay_U2(void* pInstance, MS_U8 u8Value)
995 {
996     MDrv_XC_ADC_SetRGB_PIPE_Delay(pInstance, u8Value);
997 }
998 
MApi_XC_ADC_SetRGB_PIPE_Delay(MS_U8 u8Value)999 void MApi_XC_ADC_SetRGB_PIPE_Delay(MS_U8 u8Value)
1000 {
1001     if (pu32XCInst == NULL)
1002     {
1003         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1004         return;
1005     }
1006 
1007     stXC_ADC_SETRGB_PIPE_DELAY XCArgs;
1008     XCArgs.u8Value = u8Value;
1009 
1010     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETRGB_PIPE_DELAY, (void*)&XCArgs) != 0)
1011     {
1012         printf("Obtain XC engine fail\n");
1013         return;
1014     }
1015     else
1016     {
1017         return;
1018     }
1019 }
1020 
MApi_XC_ADC_ScartRGB_SOG_ClampDelay_U2(void * pInstance,MS_U16 u16Clpdly,MS_U16 u16Caldur)1021 void MApi_XC_ADC_ScartRGB_SOG_ClampDelay_U2(void* pInstance, MS_U16 u16Clpdly, MS_U16 u16Caldur)
1022 {
1023     MDrv_XC_ADC_ScartRGB_SOG_ClampDelay(pInstance, u16Clpdly, u16Caldur);
1024 }
1025 
MApi_XC_ADC_ScartRGB_SOG_ClampDelay(MS_U16 u16Clpdly,MS_U16 u16Caldur)1026 void MApi_XC_ADC_ScartRGB_SOG_ClampDelay(MS_U16 u16Clpdly, MS_U16 u16Caldur)
1027 {
1028     if (pu32XCInst == NULL)
1029     {
1030         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1031         return;
1032     }
1033 
1034     stXC_ADC_SCARTRGB_SOG_CLAMPDELAY XCArgs;
1035     XCArgs.u16Clpdly = u16Clpdly;
1036     XCArgs.u16Caldur = u16Caldur;
1037 
1038     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SCARTRGB_SOG_CLAMPDELAY, (void*)&XCArgs) != 0)
1039     {
1040         printf("Obtain XC engine fail\n");
1041         return;
1042     }
1043     else
1044     {
1045         return;
1046     }
1047 }
1048 
MApi_XC_ADC_Set_YPbPrLooseLPF_U2(void * pInstance,MS_BOOL bEnable)1049 void MApi_XC_ADC_Set_YPbPrLooseLPF_U2(void* pInstance, MS_BOOL bEnable)
1050 {
1051     XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
1052     UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
1053     _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
1054     MDrv_XC_ADC_Set_YPbPrLooseLPF(pInstance, bEnable);
1055     _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
1056 }
1057 
MApi_XC_ADC_Set_YPbPrLooseLPF(MS_BOOL bEnable)1058 void MApi_XC_ADC_Set_YPbPrLooseLPF(MS_BOOL bEnable)
1059 {
1060     if (pu32XCInst == NULL)
1061     {
1062         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1063         return;
1064     }
1065 
1066     stXC_ADC_SET_YPBPRLOOSELPF XCArgs;
1067     XCArgs.bEnable = bEnable;
1068 
1069     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SET_YPBPRLOOSELPF, (void*)&XCArgs) != 0)
1070     {
1071         printf("Obtain XC engine fail\n");
1072         return;
1073     }
1074     else
1075     {
1076         return;
1077     }
1078 }
1079 
MApi_XC_ADC_Set_SOGBW_U2(void * pInstance,MS_U16 u16Value)1080 void MApi_XC_ADC_Set_SOGBW_U2(void* pInstance, MS_U16 u16Value)
1081 {
1082     _XC_ENTRY(pInstance);
1083     MDrv_XC_ADC_Set_SOGBW(pInstance, u16Value);
1084     _XC_RETURN(pInstance);
1085 }
1086 
MApi_XC_ADC_Set_SOGBW(MS_U16 u16Value)1087 void MApi_XC_ADC_Set_SOGBW(MS_U16 u16Value)
1088 {
1089     if (pu32XCInst == NULL)
1090     {
1091         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1092         return;
1093     }
1094 
1095     stXC_ADC_SET_SOGBW XCArgs;
1096     XCArgs.u16Value = u16Value;
1097 
1098     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SET_SOGBW, (void*)&XCArgs) != 0)
1099     {
1100         printf("Obtain XC engine fail\n");
1101         return;
1102     }
1103     else
1104     {
1105         return;
1106     }
1107 }
1108 
MApi_XC_ADC_SetClampDuration_U2(void * pInstance,MS_U16 u16Value)1109 void MApi_XC_ADC_SetClampDuration_U2(void* pInstance, MS_U16 u16Value)
1110 {
1111     MDrv_XC_ADC_SetClampDuration(pInstance, u16Value);
1112 }
1113 
MApi_XC_ADC_SetClampDuration(MS_U16 u16Value)1114 void MApi_XC_ADC_SetClampDuration(MS_U16 u16Value)
1115 {
1116     if (pu32XCInst == NULL)
1117     {
1118         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1119         return;
1120     }
1121 
1122     stXC_ADC_SETCLAMPDURATION XCArgs;
1123     XCArgs.u16Value = u16Value;
1124 
1125     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SETCLAMPDURATION, (void*)&XCArgs) != 0)
1126     {
1127         printf("Obtain XC engine fail\n");
1128         return;
1129     }
1130     else
1131     {
1132         return;
1133     }
1134 }
1135 
1136 
MApi_XC_ADC_EnableHWCalibration_U2(void * pInstance,MS_BOOL bEnable)1137 MS_BOOL MApi_XC_ADC_EnableHWCalibration_U2(void* pInstance, MS_BOOL bEnable)
1138 {
1139     XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
1140     UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
1141     _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
1142     MDrv_XC_ADC_EnableHWCalibration(pInstance, bEnable);
1143     _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
1144     return TRUE;
1145 }
1146 
MApi_XC_ADC_EnableHWCalibration(MS_BOOL bEnable)1147 MS_BOOL MApi_XC_ADC_EnableHWCalibration(MS_BOOL bEnable)
1148 {
1149     if (pu32XCInst == NULL)
1150     {
1151         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1152         return FALSE;
1153     }
1154 
1155     stXC_ADC_ENABLEHWCALIBRATION XCArgs;
1156     XCArgs.bEnable = bEnable;
1157 	XCArgs.bReturnValue = FALSE;
1158 
1159     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_ENABLEHWCALIBRATION, (void*)&XCArgs) != 0)
1160     {
1161         printf("Obtain XC engine fail\n");
1162         return FALSE;
1163     }
1164     else
1165     {
1166         return XCArgs.bReturnValue;
1167     }
1168 }
1169 
MApi_XC_ADC_SetIdacCurrentMode_U2(void * pInstance,ADC_DacCurrentMode_t eMode)1170 MS_BOOL MApi_XC_ADC_SetIdacCurrentMode_U2(void* pInstance, ADC_DacCurrentMode_t eMode)
1171 {
1172     XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
1173     UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
1174     MS_BOOL bReturn = FALSE;
1175 
1176     _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
1177     bReturn = MDrv_XC_ADC_SetIdacCurrentMode(pInstance, eMode);
1178     _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
1179 
1180     return  bReturn;
1181 }
1182 
MApi_XC_ADC_SetIdacCurrentMode(ADC_DacCurrentMode_t eMode)1183 MS_BOOL MApi_XC_ADC_SetIdacCurrentMode(ADC_DacCurrentMode_t eMode)
1184 {
1185     if (pu32XCInst == NULL)
1186     {
1187         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1188         return FALSE;
1189     }
1190 
1191     stXC_ADC_SETIDACCURRENTMODE XCArgs;
1192     XCArgs.eMode = eMode;
1193     XCArgs.bReturnValue = FALSE;
1194 
1195     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_SET_IDACCURRENTMODE, (void*)&XCArgs) != 0)
1196     {
1197         printf("Obtain XC engine fail\n");
1198         return FALSE;
1199     }
1200     else
1201     {
1202         return XCArgs.bReturnValue;
1203     }
1204 }
1205 
MApi_XC_ADC_GetIdacCurrentMode_U2(void * pInstance)1206 ADC_DacCurrentMode_t MApi_XC_ADC_GetIdacCurrentMode_U2(void* pInstance)
1207 {
1208     ADC_DacCurrentMode_t eReturnMode = E_ADC_IDAC_FULL_MODE;
1209     XC_INSTANCE_PRIVATE *psXCInstPri = NULL;
1210     UtopiaInstanceGetPrivate(pInstance, (void**)&psXCInstPri);
1211     _XC_SEMAPHORE_ENTRY(pInstance,E_XC_ID_VAR);
1212     eReturnMode = MDrv_XC_ADC_GetIdacCurrentMode(pInstance);
1213     _XC_SEMAPHORE_RETURN(pInstance,E_XC_ID_VAR);
1214 
1215     return eReturnMode;
1216 }
1217 
MApi_XC_ADC_GetIdacCurrentMode(void)1218 ADC_DacCurrentMode_t MApi_XC_ADC_GetIdacCurrentMode(void)
1219 {
1220     if (pu32XCInst == NULL)
1221     {
1222         printf("[%s,%5d]No instance existed, please get an instance by calling MApi_XC_Init() first\n",__FUNCTION__,__LINE__);
1223         return FALSE;
1224     }
1225 
1226     stXC_ADC_GETIDACCURRENTMODE XCArgs;
1227     XCArgs.eReturnMode = E_ADC_IDAC_FULL_MODE;
1228 
1229     if(UtopiaIoctl(pu32XCInst, E_XC_ADC_CMD_GET_IDACCURRENTMODE, (void*)&XCArgs) != 0)
1230     {
1231         printf("Obtain XC engine fail\n");
1232         return FALSE;
1233     }
1234     else
1235     {
1236         return XCArgs.eReturnMode;
1237     }
1238 }
1239 
1240 #undef _API_XC_ADC_C_
1241 #endif  // _API_XC_ADC_C_
1242