xref: /utopia/UTPA2-700.0.x/modules/xc/utopia_adaption/xc/XC_PCMonitor_adp.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 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// file    XC_PCMONITOR_adp.c
80 /// @brief  Scaler API layer Interface.
81 /// @author MStar Semiconductor Inc.
82 ////////////////////////////////////////////////////////////////////////////////
83 
84 #ifndef _XC_PCMONITOR_ADP_C_
85 #define _XC_PCMONITOR_ADP_C_
86 
87 //------------------------------------------------------------------------------
88 //  Include Files
89 //------------------------------------------------------------------------------
90 // Common Definition
91 #include <linux/kernel.h>
92 #include <linux/sched.h>
93 #include <linux/string.h>
94 #include <linux/slab.h>
95 #include "MsTypes.h"
96 #include "utopia.h"
97 #include "utopia_adp.h"
98 #include "MsOS.h"
99 
100 // Internal Definition
101 #include "drvXC_IOPort.h"
102 #include "apiXC.h"
103 #include "apiXC_PCMonitor.h"
104 #include "apiXC_PCMonitor_v2.h"
105 #include "apiXC_v2.h"
106 #include "XC_PCMonitor_adp.h"
107 #include "XC_adp.h"
108 
109 //------------------------------------------------------------------------------
110 //  Driver Compiler Options
111 //------------------------------------------------------------------------------
112 
113 //------------------------------------------------------------------------------
114 //  Local Defines
115 //------------------------------------------------------------------------------
116 
117 //------------------------------------------------------------------------------
118 //  Local Structurs
119 //------------------------------------------------------------------------------
120 
121 //------------------------------------------------------------------------------
122 //  Global Variables
123 //------------------------------------------------------------------------------
124 
125 //------------------------------------------------------------------------------
126 //  Local Variables
127 //------------------------------------------------------------------------------
128 
129 //Function parameter
130 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_INIT[5];
131 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_RESTART[5];
132 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_SETTIMINGCOUNT[5];
133 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR[5];
134 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GETCURRENTSTATE[5];
135 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GETSYNCSTATUS[5];
136 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GET_HFREQX10[5];
137 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GET_HFREQX1K[5];
138 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GET_VFREQX10[5];
139 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GET_VFREQX1K[5];
140 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GET_VTOTAL[5];
141 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_GET_DVI_HDMI_DE_INFO[5];
142 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_SYNCLOSS[5];
143 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_INVALIDTIMINGDETECT[5];
144 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_SETTIMINGCOUNTEX[5];
145 
146 //Function parameter's pointer
147 UADP_STRUCT_POINTER_TABLE spt_XC_PCMONITOR_MS_WINDOW_TYPE[5];
148 
149 //------------------------------------------------------------------------------
150 //  Debug Functions
151 //------------------------------------------------------------------------------
152 
153 //------------------------------------------------------------------------------
154 //  Local Functions
155 //------------------------------------------------------------------------------
156 
157 //------------------------------------------------------------------------------
158 //  Global Functions
159 //------------------------------------------------------------------------------
XC_PCMONITOR_adp_Init(void)160 MS_U32 XC_PCMONITOR_adp_Init(void)
161 {
162 
163 //set table
164     MS_U32 temp=0;
165 
166     //Function parameter
167     //pstXC_PCMONITOR_INIT                  pXC_PCMONITOR_INIT                 = (pstXC_PCMONITOR_INIT)temp;
168     //pstXC_PCMONITOR_RESTART               pXC_PCMONITOR_RESTART              = (pstXC_PCMONITOR_RESTART)temp;
169     //pstXC_PCMONITOR_SETTIMINGCOUNT        pXC_PCMONITOR_SETTIMINGCOUNT       = (pstXC_PCMONITOR_SETTIMINGCOUNT)temp;
170     //pstXC_PCMONITOR                       pXC_PCMONITOR                      = (pstXC_PCMONITOR)temp;
171     //pstXC_PCMONITOR_GETCURRENTSTATE       pXC_PCMONITOR_GETCURRENTSTATE      = (pstXC_PCMONITOR_GETCURRENTSTATE)temp;
172     //pstXC_PCMONITOR_GETSYNCSTATUS         pXC_PCMONITOR_GETSYNCSTATUS        = (pstXC_PCMONITOR_GETSYNCSTATUS)temp;
173     //pstXC_PCMONITOR_GET_HFREQX10          pXC_PCMONITOR_GET_HFREQX10         = (pstXC_PCMONITOR_GET_HFREQX10)temp;
174     //pstXC_PCMONITOR_GET_HFREQX1K          pXC_PCMONITOR_GET_HFREQX1K         = (pstXC_PCMONITOR_GET_HFREQX1K)temp;
175     //pstXC_PCMONITOR_GET_VFREQX10          pXC_PCMONITOR_GET_VFREQX10         = (pstXC_PCMONITOR_GET_VFREQX10)temp;
176     //pstXC_PCMONITOR_GET_VFREQX1K          pXC_PCMONITOR_GET_VFREQX1K         = (pstXC_PCMONITOR_GET_VFREQX1K)temp;
177     //pstXC_PCMONITOR_GET_VTOTAL            pXC_PCMONITOR_GET_VTOTAL           = (pstXC_PCMONITOR_GET_VTOTAL)temp;
178     pstXC_PCMONITOR_GET_DVI_HDMI_DE_INFO  pXC_PCMONITOR_GET_DVI_HDMI_DE_INFO = (pstXC_PCMONITOR_GET_DVI_HDMI_DE_INFO)temp;
179     //pstXC_PCMONITOR_SYNCLOSS              pXC_PCMONITOR_SYNCLOSS             = (pstXC_PCMONITOR_SYNCLOSS)temp;
180     //pstXC_PCMONITOR_INVALIDTIMINGDETECT   pXC_PCMONITOR_INVALIDTIMINGDETECT  = (pstXC_PCMONITOR_INVALIDTIMINGDETECT)temp;
181     //pstXC_PCMONITOR_SETTIMINGCOUNTEX      pXC_PCMONITOR_SETTIMINGCOUNTEX     = (pstXC_PCMONITOR_SETTIMINGCOUNTEX)temp;
182 
183 
184 	//Function parameter's pointer
185     //MS_WINDOW_TYPE*        pXC_PCMOTITOR_msWin     = (MS_WINDOW_TYPE*)temp;
186 
187     //Function parameter's pointer
188     UADPBypassSetSPT(&spt_XC_PCMONITOR_MS_WINDOW_TYPE[0],UADP_SPT_SELF_SIZE,0, sizeof(MS_WINDOW_TYPE));
189     UADPBypassSetSPT(&spt_XC_PCMONITOR_MS_WINDOW_TYPE[1],UADP_SPT_END , 0, 0);
190 
191     //Function parameter
192     UADPBypassSetSPT(&spt_XC_PCMONITOR_INIT[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_INIT));
193     UADPBypassSetSPT(&spt_XC_PCMONITOR_INIT[1],UADP_SPT_END , 0, 0);
194 
195     UADPBypassSetSPT(&spt_XC_PCMONITOR_RESTART[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_RESTART));
196     UADPBypassSetSPT(&spt_XC_PCMONITOR_RESTART[1],UADP_SPT_END , 0, 0);
197 
198     UADPBypassSetSPT(&spt_XC_PCMONITOR_SETTIMINGCOUNT[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_SETTIMINGCOUNT));
199     UADPBypassSetSPT(&spt_XC_PCMONITOR_SETTIMINGCOUNT[1],UADP_SPT_END , 0, 0);
200 
201     UADPBypassSetSPT(&spt_XC_PCMONITOR[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR));
202     UADPBypassSetSPT(&spt_XC_PCMONITOR[1],UADP_SPT_END , 0, 0);
203 
204 	UADPBypassSetSPT(&spt_XC_PCMONITOR_GETCURRENTSTATE[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GETCURRENTSTATE));
205     UADPBypassSetSPT(&spt_XC_PCMONITOR_GETCURRENTSTATE[1],UADP_SPT_END , 0, 0);
206 
207     UADPBypassSetSPT(&spt_XC_PCMONITOR_GETSYNCSTATUS[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GETSYNCSTATUS));
208     UADPBypassSetSPT(&spt_XC_PCMONITOR_GETSYNCSTATUS[1],UADP_SPT_END , 0, 0);
209 
210     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_HFREQX10[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GET_HFREQX10));
211     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_HFREQX10[1],UADP_SPT_END , 0, 0);
212 
213     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_HFREQX1K[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GET_HFREQX1K));
214     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_HFREQX1K[1],UADP_SPT_END , 0, 0);
215 
216     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_VFREQX10[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GET_VFREQX10));
217     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_VFREQX10[1],UADP_SPT_END , 0, 0);
218 
219     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_VFREQX1K[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GET_VFREQX1K));
220     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_VFREQX1K[1],UADP_SPT_END , 0, 0);
221 
222     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_VTOTAL[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GET_VTOTAL));
223     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_VTOTAL[1],UADP_SPT_END , 0, 0);
224 
225     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_DVI_HDMI_DE_INFO[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_GET_DVI_HDMI_DE_INFO));
226     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_DVI_HDMI_DE_INFO[1],UADP_SPT_POINTER_TO_NEXT,
227         ((unsigned long)(&(pXC_PCMONITOR_GET_DVI_HDMI_DE_INFO->msWin)) - (unsigned long)pXC_PCMONITOR_GET_DVI_HDMI_DE_INFO), (unsigned long)spt_XC_PCMONITOR_MS_WINDOW_TYPE);
228     UADPBypassSetSPT(&spt_XC_PCMONITOR_GET_DVI_HDMI_DE_INFO[2],UADP_SPT_END , 0, 0);
229 
230     UADPBypassSetSPT(&spt_XC_PCMONITOR_SYNCLOSS[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_SYNCLOSS));
231     UADPBypassSetSPT(&spt_XC_PCMONITOR_SYNCLOSS[1],UADP_SPT_END , 0, 0);
232 
233     UADPBypassSetSPT(&spt_XC_PCMONITOR_INVALIDTIMINGDETECT[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_INVALIDTIMINGDETECT));
234     UADPBypassSetSPT(&spt_XC_PCMONITOR_INVALIDTIMINGDETECT[1],UADP_SPT_END , 0, 0);
235 
236     UADPBypassSetSPT(&spt_XC_PCMONITOR_SETTIMINGCOUNTEX[0],UADP_SPT_SELF_SIZE,0, sizeof(stXC_PCMONITOR_SETTIMINGCOUNTEX));
237     UADPBypassSetSPT(&spt_XC_PCMONITOR_SETTIMINGCOUNTEX[1],UADP_SPT_END , 0, 0);
238 
239 
240     return 0;
241 
242 }
243 
XC_PCMONITOR_adp_Ioctl(void * pInstanceTmp,MS_U32 u32Cmd,void * const pArgs)244 MS_U32 XC_PCMONITOR_adp_Ioctl(void* pInstanceTmp, MS_U32 u32Cmd, void* const pArgs)
245 {
246     MS_U32 u32Ret;
247     char buffer_arg[2];
248 
249     switch(u32Cmd)
250     {
251 
252         case E_XC_PCMONITOR_CMD_INIT :
253         {
254             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_INIT, spt_XC_PCMONITOR_INIT,buffer_arg,sizeof(buffer_arg));
255             break;
256         }
257 
258         case E_XC_PCMONITOR_CMD_RESTART:
259         {
260             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_RESTART, NULL,buffer_arg,sizeof(buffer_arg));
261             break;
262         }
263 
264         case E_XC_PCMONITOR_CMD_SETTIMINGCOUNT:
265         {
266             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_SETTIMINGCOUNT, NULL,buffer_arg,sizeof(buffer_arg));
267             break;
268         }
269 
270         case E_XC_PCMONITOR_CMD:
271         {
272             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR, spt_XC_PCMONITOR,buffer_arg,sizeof(buffer_arg));
273             break;
274         }
275 
276         case E_XC_PCMONITOR_CMD_GETCURRENTSTATE:
277         {
278             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GETCURRENTSTATE, spt_XC_PCMONITOR_GETCURRENTSTATE,buffer_arg,sizeof(buffer_arg));
279             break;
280         }
281 
282         case E_XC_PCMONITOR_CMD_GETSYNCSTATUS:
283         {
284             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GETSYNCSTATUS,spt_XC_PCMONITOR_GETSYNCSTATUS,buffer_arg,sizeof(buffer_arg));
285             break;
286         }
287 
288         case E_XC_PCMONITOR_CMD_GET_HFREQX10:
289         {
290             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GET_HFREQX10,spt_XC_PCMONITOR_GET_HFREQX10,buffer_arg,sizeof(buffer_arg));
291             break;
292         }
293 
294         case E_XC_PCMONITOR_CMD_GET_HFREQX1K:
295         {
296             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GET_HFREQX1K,spt_XC_PCMONITOR_GET_HFREQX1K,buffer_arg,sizeof(buffer_arg));
297             break;
298         }
299 
300         case E_XC_PCMONITOR_CMD_GET_VFREQX10:
301         {
302             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GET_VFREQX10,spt_XC_PCMONITOR_GET_VFREQX10,buffer_arg,sizeof(buffer_arg));
303             break;
304         }
305 
306         case E_XC_PCMONITOR_CMD_GET_VFREQX1K:
307         {
308             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GET_VFREQX1K,spt_XC_PCMONITOR_GET_VFREQX1K,buffer_arg,sizeof(buffer_arg));
309             break;
310         }
311 
312         case E_XC_PCMONITOR_CMD_GET_VTOTAL:
313         {
314             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GET_VTOTAL,spt_XC_PCMONITOR_GET_VTOTAL,buffer_arg,sizeof(buffer_arg));
315             break;
316         }
317 
318 		case E_XC_PCMONITOR_CMD_GET_DVI_HDMI_DE_INFO:
319         {
320             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_GET_DVI_HDMI_DE_INFO,spt_XC_PCMONITOR_GET_DVI_HDMI_DE_INFO,buffer_arg,sizeof(buffer_arg));
321             break;
322         }
323 
324         case E_XC_PCMONITOR_CMD_SYNCLOSS:
325         {
326             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_SYNCLOSS,spt_XC_PCMONITOR_SYNCLOSS,buffer_arg,sizeof(buffer_arg));
327             break;
328         }
329 
330         case E_XC_PCMONITOR_CMD_INVALIDTIMINGDETECT:
331         {
332             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_INVALIDTIMINGDETECT,spt_XC_PCMONITOR_INVALIDTIMINGDETECT,buffer_arg,sizeof(buffer_arg));
333             break;
334         }
335 
336         case E_XC_PCMONITOR_CMD_SETTIMINGCOUNTEX:
337         {
338             u32Ret = UADPBypassIoctl(pInstanceTmp,u32Cmd,pArgs,spt_XC_PCMONITOR_SETTIMINGCOUNTEX,spt_XC_PCMONITOR_SETTIMINGCOUNTEX,buffer_arg,sizeof(buffer_arg));
339             break;
340         }
341 
342         case E_XC_PCMONITOR_CMD_NONE:
343         case E_XC_PCMONITOR_CMD_MAX:
344         default:
345         {
346             printf("Command %ld is not existed\n",u32Cmd);
347             u32Ret = UTOPIA_STATUS_ERR_INVALID_HANDLE;
348             break;
349         }
350 
351     }
352 
353 	return u32Ret;
354    // return UtopiaIoctl(pModuleDDI->pInstant,u32Cmd,arg);
355 }
356 
357 #endif
358 
359 
360