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 /// file apiMHL.c
81 /// @author MStar Semiconductor Inc.
82 /// @brief MHL driver Function
83 ///////////////////////////////////////////////////////////////////////////////////////////////////
84
85 #ifndef _API_MHL_C_
86 #define _API_MHL_C_
87
88 //-------------------------------------------------------------------------------------------------
89 // Include Files
90 //-------------------------------------------------------------------------------------------------
91 // Common Definition
92 #include "MsCommon.h"
93 #include "MsVersion.h"
94 #ifdef MSOS_TYPE_LINUX_KERNEL
95 #include <linux/string.h>
96 #else
97 #include <string.h>
98 #endif
99
100 #include "utopia.h"
101 #include "utopia_dapi.h"
102
103 #include "mdrv_mhl_st.h"
104 #include "apiMHL.h"
105 #include "halMHL.h"
106 #include "drvMHL.h"
107 #include "apiMHL_private.h"
108
109 //-------------------------------------------------------------------------------------------------
110 // Local Defines
111 //-------------------------------------------------------------------------------------------------
112 #if(defined(CONFIG_MLOG))
113 #include "ULog.h"
114
115 #define MAPI_MHL_MSG_INFO(format, args...) ULOGI("MHL", format, ##args)
116 #define MAPI_MHL_MSG_WARNING(format, args...) ULOGW("MHL", format, ##args)
117 #define MAPI_MHL_MSG_DEBUG(format, args...) ULOGD("MHL", format, ##args)
118 #define MAPI_MHL_MSG_ERROR(format, args...) ULOGE("MHL", format, ##args)
119 #define MAPI_MHL_MSG_FATAL(format, args...) ULOGF("MHL", format, ##args)
120
121 #else
122 #define MAPI_MHL_MSG_INFO(format, args...) printf(format, ##args)
123 #define MAPI_MHL_MSG_WARNING(format, args...) printf(format, ##args)
124 #define MAPI_MHL_MSG_DEBUG(format, args...) printf(format, ##args)
125 #define MAPI_MHL_MSG_ERROR(format, args...) printf(format, ##args)
126 #define MAPI_MHL_MSG_FATAL(format, args...) printf(format, ##args)
127
128 #endif
129
130 //-------------------------------------------------------------------------------------------------
131 // Local Structures
132 //-------------------------------------------------------------------------------------------------
133
134 //-------------------------------------------------------------------------------------------------
135 // Global Variables
136 //-------------------------------------------------------------------------------------------------
137
138 //-------------------------------------------------------------------------------------------------
139 // Local Variables
140 //-------------------------------------------------------------------------------------------------
141 link_cbus_event_handle_func pfRCPCallBackFunction = NULL;
142 link_cbus_event_handle_func pfRAPCallBackFunction = NULL;
143 link_cbus_event_handle_func pfUCPCallBackFunction = NULL;
144 link_cbus_event_handle_func pfATTCallBackFunction = NULL;
145 link_cbus_event_handle_func pfRBPCallBackFunction = NULL;
146
147 void* pulMHLInst;
148
149 //-------------------------------------------------------------------------------------------------
150 // Local Functions
151 //-------------------------------------------------------------------------------------------------
152
153 //**************************************************************************
154 // [Function Name]:
155 // _mapi_mhl_MSGCallBackProc()
156 // [Description]
157 //
158 // [Arguments]:
159 //
160 // [Return]:
161 //
162 //**************************************************************************
_mapi_mhl_MSGCallBackProc(MS_U8 ucSubCommand,MS_U8 ucKeyCode)163 void _mapi_mhl_MSGCallBackProc(MS_U8 ucSubCommand, MS_U8 ucKeyCode)
164 {
165 MS_U8 ucStatus = 0;
166
167 switch(ucSubCommand)
168 {
169 case MSC_MSG_RCP:
170 if(pfRCPCallBackFunction != NULL)
171 {
172 ucStatus = pfRCPCallBackFunction(ucKeyCode);
173
174 MAPI_MHL_MSG_INFO("** MHL RCP callback function keycode %x status %d\r\n", ucKeyCode, ucStatus);
175 }
176
177 break;
178
179 case MSC_MSG_RAP:
180 if(pfRAPCallBackFunction != NULL)
181 {
182 ucStatus = pfRAPCallBackFunction(ucKeyCode);
183
184 MAPI_MHL_MSG_INFO("** MHL RAP callback function keycode %x status %d\r\n", ucKeyCode, ucStatus);
185 }
186
187 break;
188
189 case MSC_MSG_UCP:
190 if(pfUCPCallBackFunction != NULL)
191 {
192 ucStatus = pfUCPCallBackFunction(ucKeyCode);
193
194 MAPI_MHL_MSG_INFO("** MHL UCP callback function keycode %x status %d\r\n", ucKeyCode, ucStatus);
195 }
196
197 break;
198
199 case MSC_MSG_ATT:
200 if(pfATTCallBackFunction != NULL)
201 {
202 ucStatus = pfATTCallBackFunction(ucKeyCode);
203
204 MAPI_MHL_MSG_INFO("** MHL ATT callback function keycode %x status %d\r\n", ucKeyCode, ucStatus);
205 }
206
207 break;
208
209 case MSC_MSG_RBP:
210 if(pfRBPCallBackFunction != NULL)
211 {
212 ucStatus = pfRBPCallBackFunction(ucKeyCode);
213
214 MAPI_MHL_MSG_INFO("** MHL RBP callback function keycode %x status %d\r\n", ucKeyCode, ucStatus);
215 }
216
217 break;
218
219 default:
220
221 break;
222 };
223 }
224
225 //-------------------------------------------------------------------------------------------------
226 // Global Functions
227 //-------------------------------------------------------------------------------------------------
228
229 //**************************************************************************
230 // [Function Name]:
231 // mapi_mhl_MHLSupportPath()
232 // [Description]
233 // MHL support path
234 // [Arguments]:
235 //
236 // [Return]:
237 //
238 //**************************************************************************
mapi_mhl_MHLSupportPath(MS_U8 ucSelect)239 void mapi_mhl_MHLSupportPath(MS_U8 ucSelect)
240 {
241 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
242 mdrv_mhl_MHLSupportPath(ucSelect);
243
244 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
245 MS_BOOL bInitialFlag = FALSE;
246 stMHL_SET_SUPPORT_PATH pMHLArgs = {0};
247
248 pMHLArgs.ucSupportPath = ucSelect;
249
250 if(pulMHLInst == NULL)
251 {
252 if(UtopiaOpen(MODULE_MHL, &pulMHLInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
253 {
254 MAPI_MHL_MSG_ERROR("UtopiaOpen pulMHLInst failed\n");
255
256 bInitialFlag = TRUE;
257 }
258 }
259
260 if(!bInitialFlag)
261 {
262 if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SUPPORT_PATH, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
263 {
264 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
265 }
266 }
267
268 #endif
269 }
270
271 //**************************************************************************
272 // [Function Name]:
273 // mapi_mhl_Init()
274 // [Description]
275 // MHL init
276 // [Arguments]:
277 //
278 // [Return]:
279 //
280 //**************************************************************************
mapi_mhl_init(MS_U8 * edid,MS_U8 * DevCap)281 void mapi_mhl_init(MS_U8 *edid, MS_U8 *DevCap)
282 {
283 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
284 mdrv_mhl_Initial(edid, DevCap);
285
286 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
287 MS_BOOL bInitialFlag = FALSE;
288 stMHL_INITIAL_SETTING pMHLArgs = {0};
289
290 pMHLArgs.ucEDIDTable = edid;
291 pMHLArgs.ucDevcapTable = DevCap;
292
293 if(pulMHLInst == NULL)
294 {
295 if(UtopiaOpen(MODULE_MHL, &pulMHLInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
296 {
297 MAPI_MHL_MSG_ERROR("UtopiaOpen pulMHLInst failed\n");
298
299 bInitialFlag = TRUE;
300 }
301 }
302
303 if(!bInitialFlag)
304 {
305 if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_INITIAL, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
306 {
307 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
308 }
309 }
310
311 #endif
312 }
313
314 //**************************************************************************
315 // [Function Name]:
316 // mapi_mhl_handler()
317 // [Description]
318 // MHL handler
319 // [Arguments]:
320 //
321 // [Return]:
322 //
323 //**************************************************************************
mapi_mhl_handler(void)324 void mapi_mhl_handler(void)
325 {
326 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
327 MS_U16 usMSGKeyInfo = 0;
328
329 usMSGKeyInfo = mdrv_mhl_Handler();
330
331 if(usMSGKeyInfo != 0)
332 {
333 _mapi_mhl_MSGCallBackProc((usMSGKeyInfo >> 8), (usMSGKeyInfo &BMASK(7:0)));
334 }
335
336 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
337 stMHL_POLLING_HANDLER pMHLArgs = {0};
338
339 pMHLArgs.usMSGKeyInfo = 0;
340
341 if(pulMHLInst == NULL)
342 {
343 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
344 }
345 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_HANDLER, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
346 {
347 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
348 }
349
350 if(pMHLArgs.usMSGKeyInfo != 0)
351 {
352 _mapi_mhl_MSGCallBackProc((pMHLArgs.usMSGKeyInfo >> 8), (pMHLArgs.usMSGKeyInfo &BMASK(7:0)));
353 }
354
355 #endif
356 }
357
358 //**************************************************************************
359 // [Function Name]:
360 // mapi_mhl_AutoSwitchHandler()
361 // [Description]
362 //
363 // [Arguments]:
364 //
365 // [Return]:
366 //
367 //**************************************************************************
mapi_mhl_AutoSwitchHandler(MS_BOOL bReset,MS_U8 * ucCbusPath)368 MS_BOOL mapi_mhl_AutoSwitchHandler(MS_BOOL bReset, MS_U8 *ucCbusPath)
369 {
370 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
371 return mdrv_mhl_AutoSwitchHandler(bReset, ucCbusPath);
372
373 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
374 stMHL_AUTO_SWITCH_HANDLER pMHLArgs = {0};
375
376 pMHLArgs.bAutoSwitchFlag = FALSE;
377 pMHLArgs.bResetFlag = bReset;
378 pMHLArgs.ucCbusPath = ucCbusPath;
379
380 if(pulMHLInst == NULL)
381 {
382 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
383 }
384 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_AUTO_SWITCH, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
385 {
386 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
387 }
388
389 return pMHLArgs.bAutoSwitchFlag;
390
391 #endif
392 }
393
394 //**************************************************************************
395 // [Function Name]:
396 // mapi_mhl_SetPowerState()
397 // [Description]
398 //
399 // [Arguments]:
400 //
401 // [Return]:
402 //
403 //**************************************************************************
mapi_mhl_SetPowerState(EN_POWER_MODE usPowerState)404 MS_U32 mapi_mhl_SetPowerState(EN_POWER_MODE usPowerState)
405 {
406 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
407 return mdrv_mhl_SetPowerState(usPowerState);
408
409 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
410 stMHL_SET_POWER_STATE pMHLArgs = {0};
411
412 pMHLArgs.ulFailFlag = 1;
413 pMHLArgs.usPowerState = usPowerState;
414
415 if(pulMHLInst == NULL)
416 {
417 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
418 }
419 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SET_POWER_STATE, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
420 {
421 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
422 }
423
424 return pMHLArgs.ulFailFlag;
425
426 #endif
427 }
428
429 //**************************************************************************
430 // [Function Name]:
431 // mapi_mhl_CbusControl()
432 // [Description]
433 //
434 // [Arguments]:
435 //
436 // [Return]:
437 //
438 //**************************************************************************
mapi_mhl_CbusControl(MS_U8 ucState)439 void mapi_mhl_CbusControl(MS_U8 ucState)
440 {
441 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
442 mdrv_mhl_CbusControl(ucState);
443
444 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
445 stMHL_CBUS_CONTROL pMHLArgs = {0};
446
447 pMHLArgs.ucState = ucState;
448
449 if(pulMHLInst == NULL)
450 {
451 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
452 }
453 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_CBUS_CONTROL, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
454 {
455 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
456 }
457
458 #endif
459 }
460
461 //**************************************************************************
462 // [Function Name]:
463 // mapi_mhl_LoadEDID()
464 // [Description]
465 //
466 // [Arguments]:
467 //
468 // [Return]:
469 //
470 //**************************************************************************
mapi_mhl_LoadEDID(MS_U8 * edid)471 void mapi_mhl_LoadEDID(MS_U8 *edid)
472 {
473 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
474 mdrv_mhl_LoadEDID(edid);
475
476 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
477 stMHL_LOAD_EDID pMHLArgs = {0};
478
479 pMHLArgs.ucEDIDTable = edid;
480
481 if(pulMHLInst == NULL)
482 {
483 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
484 }
485 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_LOAD_EDID, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
486 {
487 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
488 }
489
490 #endif
491 }
492
493 //**************************************************************************
494 // [Function Name]:
495 // mapi_mhl_ReadEDID()
496 // [Description]
497 //
498 // [Arguments]:
499 //
500 // [Return]:
501 //
502 //**************************************************************************
mapi_mhl_ReadEDID(MS_U16 usSize,MS_U8 * edid)503 void mapi_mhl_ReadEDID(MS_U16 usSize, MS_U8 *edid)
504 {
505 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
506 mdrv_mhl_ReadEDID(usSize, edid);
507
508 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
509 stMHL_READ_EDID pMHLArgs = {0};
510
511 pMHLArgs.ucEDIDSize = usSize;
512 pMHLArgs.ucEDIDTable = edid;
513
514 if(pulMHLInst == NULL)
515 {
516 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
517 }
518 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_READ_EDID, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
519 {
520 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
521 }
522
523 #endif
524 }
525
526 //**************************************************************************
527 // [Function Name]:
528 // mapi_mhl_LoadDeviceCapability()
529 // [Description]
530 //
531 // [Arguments]:
532 //
533 // [Return]:
534 //
535 //**************************************************************************
mapi_mhl_LoadDeviceCapability(MS_U8 * devcap)536 void mapi_mhl_LoadDeviceCapability(MS_U8 *devcap)
537 {
538 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
539 mdrv_mhl_LoadDeviceCapability(devcap);
540
541 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
542 stMHL_LOAD_DEVCAP pMHLArgs = {0};
543
544 pMHLArgs.ucDevcapTable = devcap;
545
546 if(pulMHLInst == NULL)
547 {
548 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
549 }
550 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_LOAD_DEVCAP, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
551 {
552 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
553 }
554
555 #endif
556 }
557
558 //**************************************************************************
559 // [Function Name]:
560 // mapi_mhl_SetVenderID()
561 // [Description]
562 //
563 // [Arguments]:
564 //
565 // [Return]:
566 //
567 //**************************************************************************
mapi_mhl_SetVenderID(MS_U8 ucVenderID)568 void mapi_mhl_SetVenderID(MS_U8 ucVenderID)
569 {
570 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
571 mdrv_mhl_SetVenderID(ucVenderID);
572
573 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
574 stMHL_SET_VENDER_ID pMHLArgs = {0};
575
576 pMHLArgs.ucVenderID = ucVenderID;
577
578 if(pulMHLInst == NULL)
579 {
580 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
581 }
582 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SET_VENDER_ID, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
583 {
584 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
585 }
586
587 #endif
588 }
589
590 //**************************************************************************
591 // [Function Name]:
592 // mapi_mhl_InvertCableDetect()
593 // [Description]
594 //
595 // [Arguments]:
596 //
597 // [Return]:
598 //
599 //**************************************************************************
mapi_mhl_InvertCableDetect(MS_BOOL bCableDetectInvert)600 void mapi_mhl_InvertCableDetect(MS_BOOL bCableDetectInvert)
601 {
602 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
603 mdrv_mhl_InvertCableDetect(bCableDetectInvert);
604
605 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
606 stMHL_SET_CABLE_DETECT_INVERT pMHLArgs = {0};
607
608 pMHLArgs.bCableDetectInvert = bCableDetectInvert;
609
610 if(pulMHLInst == NULL)
611 {
612 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
613 }
614 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SET_CABLE_DETECT_INVERT, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
615 {
616 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
617 }
618
619 #endif
620 }
621
622 //**************************************************************************
623 // [Function Name]:
624 // mapi_mhl_VbusConfigSetting()
625 // [Description]
626 //
627 // [Arguments]:
628 //
629 // [Return]:
630 //
631 //**************************************************************************
mapi_mhl_VbusConfigSetting(MS_U8 ucState)632 void mapi_mhl_VbusConfigSetting(MS_U8 ucState)
633 {
634 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
635 mdrv_mhl_VbusConfigSetting(ucState);
636
637 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
638 stMHL_VBUS_CONFIG_SETTING pMHLArgs = {0};
639
640 pMHLArgs.ucConfigMode = ucState;
641
642 if(pulMHLInst == NULL)
643 {
644 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
645 }
646 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_VBUS_CONFIG_SETTING, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
647 {
648 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
649 }
650
651 #endif
652 }
653
654 //**************************************************************************
655 // [Function Name]:
656 // mapi_mhl_AdjustSettingIControl()
657 // [Description]
658 //
659 // [Arguments]:
660 //
661 // [Return]:
662 //
663 //**************************************************************************
mapi_mhl_AdjustSettingIControl(MS_U8 ucIControl)664 void mapi_mhl_AdjustSettingIControl(MS_U8 ucIControl)
665 {
666 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
667 mdrv_mhl_AdjustSettingIControl(ucIControl);
668
669 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
670 stMHL_ADJUST_I_CONTROL pMHLArgs = {0};
671
672 pMHLArgs.ucIControlValue = ucIControl;
673
674 if(pulMHLInst == NULL)
675 {
676 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
677 }
678 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_ADJUST_I_CONTROL, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
679 {
680 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
681 }
682
683 #endif
684 }
685
686 //**************************************************************************
687 // [Function Name]:
688 // mapi_mhl_AdjustImpedanceSetting()
689 // [Description]
690 //
691 // [Arguments]:
692 //
693 // [Return]:
694 //
695 //**************************************************************************
mapi_mhl_AdjustImpedanceSetting(MS_U8 ucImpedance)696 void mapi_mhl_AdjustImpedanceSetting(MS_U8 ucImpedance)
697 {
698 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
699 mdrv_mhl_AdjustImpedanceSetting(ucImpedance);
700
701 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
702 stMHL_ADJUST_IMPEDANCE pMHLArgs = {0};
703
704 pMHLArgs.ucImpedanceValue = ucImpedance;
705
706 if(pulMHLInst == NULL)
707 {
708 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
709 }
710 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_ADJUST_IMPEDANCE, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
711 {
712 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
713 }
714
715 #endif
716 }
717
718 //**************************************************************************
719 // [Function Name]:
720 // mapi_mhl_CableDetect()
721 // [Description]
722 // Get MHL cable detection flag
723 // [Arguments]:
724 //
725 // [Return]:
726 //
727 //**************************************************************************
mapi_mhl_CableDetect(void)728 MS_BOOL mapi_mhl_CableDetect(void)
729 {
730 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
731 return mdrv_mhl_GetCableDetectFlag();
732
733 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
734 stMHL_CABLE_DETECT_FLAG pMHLArgs = {0};
735
736 pMHLArgs.bCableDetectFlag = FALSE;
737
738 if(pulMHLInst == NULL)
739 {
740 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
741 }
742 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_CABLE_DETECT_FLAG, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
743 {
744 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
745 }
746
747 return pMHLArgs.bCableDetectFlag;
748
749 #endif
750 }
751
752 //**************************************************************************
753 // [Function Name]:
754 // mapi_mhl_CbusStatus()
755 // [Description]
756 // Get MHL CBUS connetion flag
757 // [Arguments]:
758 //
759 // [Return]:
760 //
761 //**************************************************************************
mapi_mhl_CbusStatus(void)762 MS_BOOL mapi_mhl_CbusStatus(void)
763 {
764 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
765 return mdrv_mhl_GetCbusConnectFlag();
766
767 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
768 stMHL_CBUS_CONNECT_FLAG pMHLArgs = {0};
769
770 pMHLArgs.bCbusConnectFlag = FALSE;
771
772 if(pulMHLInst == NULL)
773 {
774 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
775 }
776 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_CBUS_CONNECT_FLAG, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
777 {
778 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
779 }
780
781 return pMHLArgs.bCbusConnectFlag;
782
783 #endif
784 }
785
786 //**************************************************************************
787 // [Function Name]:
788 // mapi_mhl_CbusWakeupIntFlag()
789 // [Description]
790 //
791 // [Arguments]:
792 //
793 // [Return]:
794 //
795 //**************************************************************************
mapi_mhl_CbusWakeupIntFlag(void)796 MS_BOOL mapi_mhl_CbusWakeupIntFlag(void)
797 {
798 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
799 return mdrv_mhl_CbusWakeupIntFlag();
800
801 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
802 stMHL_CBUS_WAKEUP_INT_FLAG pMHLArgs = {0};
803
804 pMHLArgs.bCbusWakeupFlag = FALSE;
805
806 if(pulMHLInst == NULL)
807 {
808 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
809 }
810 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_CBUS_WAKEUP_INT_FLAG, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
811 {
812 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
813 }
814
815 return pMHLArgs.bCbusWakeupFlag;
816
817 #endif
818 }
819
820 //**************************************************************************
821 // [Function Name]:
822 // mapi_mhl_SrcRCPSupportFlag()
823 // [Description]
824 //
825 // [Arguments]:
826 //
827 // [Return]:
828 //
829 //**************************************************************************
mapi_mhl_SrcRCPSupportFlag(void)830 MS_BOOL mapi_mhl_SrcRCPSupportFlag(void)
831 {
832 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
833 return mdrv_mhl_SrcRCPSupportFlag();
834
835 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
836 stMHL_SOURCE_SUPPORT_RCP pMHLArgs = {0};
837
838 pMHLArgs.bSourceSupportRCP = FALSE;
839
840 if(pulMHLInst == NULL)
841 {
842 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
843 }
844 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SOURCE_SUPPORT_RCP, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
845 {
846 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
847 }
848
849 return pMHLArgs.bSourceSupportRCP;
850
851 #endif
852 }
853
854 //**************************************************************************
855 // [Function Name]:
856 // mapi_mhl_SrcRAPSupportFlag()
857 // [Description]
858 //
859 // [Arguments]:
860 //
861 // [Return]:
862 //
863 //**************************************************************************
mapi_mhl_SrcRAPSupportFlag(void)864 MS_BOOL mapi_mhl_SrcRAPSupportFlag(void)
865 {
866 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
867 return mdrv_mhl_SrcRAPSupportFlag();
868
869 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
870 stMHL_SOURCE_SUPPORT_RAP pMHLArgs = {0};
871
872 pMHLArgs.bSourceSupportRAP = FALSE;
873
874 if(pulMHLInst == NULL)
875 {
876 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
877 }
878 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SOURCE_SUPPORT_RAP, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
879 {
880 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
881 }
882
883 return pMHLArgs.bSourceSupportRAP;
884
885 #endif
886 }
887
888 //**************************************************************************
889 // [Function Name]:
890 // mapi_mhl_CbusGetStatusFlag()
891 // [Description]
892 //
893 // [Arguments]:
894 //
895 // [Return]:
896 //
897 //**************************************************************************
mapi_mhl_CbusGetStatusFlag(MS_U8 ucState)898 MS_BOOL mapi_mhl_CbusGetStatusFlag(MS_U8 ucState)
899 {
900 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
901 return mdrv_mhl_CbusGetStatusFlag(ucState);
902
903 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
904 stMHL_GET_STATUS_FLAG pMHLArgs = {0};
905
906 pMHLArgs.bStatusFlag = FALSE;
907 pMHLArgs.ucStatusType = ucState;
908
909 if(pulMHLInst == NULL)
910 {
911 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
912 }
913 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_GET_STATUS_FLAG, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
914 {
915 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
916 }
917
918 return pMHLArgs.bStatusFlag;
919
920 #endif
921 }
922
923 //**************************************************************************
924 // [Function Name]:
925 // mapi_mhl_SendRAPCmd
926 // [Description]
927 // MHL Cbus MSC Send RAP Command
928 // [Arguments]:
929 //
930 // [Return]:
931 // TRUE: success
932 // FALSE: fail
933 //**************************************************************************
mapi_mhl_SendRAPCmd(MS_U8 databuf)934 MS_BOOL mapi_mhl_SendRAPCmd(MS_U8 databuf)
935 {
936 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
937 return mdrv_mhl_SendRAPCommand(databuf);
938
939 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
940 stMHL_SEND_RAP_COMMAND pMHLArgs = {0};
941
942 pMHLArgs.bSendFlag = FALSE;
943 pMHLArgs.ucKeyCode = databuf;
944
945 if(pulMHLInst == NULL)
946 {
947 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
948 }
949 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SEND_RAP_COMMAND, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
950 {
951 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
952 }
953
954 return pMHLArgs.bSendFlag;
955
956 #endif
957 }
958
959 //**************************************************************************
960 // [Function Name]:
961 // mapi_mhl_SendRCPAutoReleaseCmd
962 // [Description]
963 // MHL Cbus MSC Send RCP Command
964 // [Arguments]:
965 //
966 // [Return]:
967 // TRUE: success
968 // FALSE: fail
969 //**************************************************************************
mapi_mhl_SendRCPAutoReleaseCmd(MS_U8 ucKeyCode)970 MS_BOOL mapi_mhl_SendRCPAutoReleaseCmd(MS_U8 ucKeyCode)
971 {
972 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
973 return mdrv_mhl_SendRCPAutoReleaseCmd(ucKeyCode);
974
975 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
976 stMHL_SEND_RCP_COMMAND pMHLArgs = {0};
977
978 pMHLArgs.bSendFlag = FALSE;
979 pMHLArgs.ucKeyCode = ucKeyCode;
980
981 if(pulMHLInst == NULL)
982 {
983 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
984 }
985 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SEND_RCP_COMMAND, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
986 {
987 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
988 }
989
990 return pMHLArgs.bSendFlag;
991
992 #endif
993 }
994
995 //**************************************************************************
996 // [Function Name]:
997 // mapi_mhl_SendUCPCmd
998 // [Description]
999 // MHL Cbus MSC Send UCP Command
1000 // [Arguments]:
1001 //
1002 // [Return]:
1003 // TRUE: success
1004 // FALSE: fail
1005 //**************************************************************************
mapi_mhl_SendUCPCmd(MS_U8 databuf)1006 MS_BOOL mapi_mhl_SendUCPCmd(MS_U8 databuf)
1007 {
1008 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1009 return mdrv_mhl_SendUCPCommand(databuf);
1010
1011 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1012 stMHL_SEND_UCP_COMMAND pMHLArgs = {0};
1013
1014 pMHLArgs.bSendFlag = FALSE;
1015 pMHLArgs.ucKeyCode = databuf;
1016
1017 if(pulMHLInst == NULL)
1018 {
1019 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1020 }
1021 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SEND_UCP_COMMAND, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1022 {
1023 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1024 }
1025
1026 return pMHLArgs.bSendFlag;
1027
1028 #endif
1029 }
1030
1031 //**************************************************************************
1032 // [Function Name]:
1033 // mapi_mhl_SendWriteBurst
1034 // [Description]
1035 //
1036 // [Arguments]:
1037 //
1038 // [Return]:
1039 // TRUE: success
1040 // FALSE: fail
1041 //**************************************************************************
mapi_mhl_SendWriteBurst(MS_U8 ucAddr,MS_U8 ucLength,MS_U8 * buffer)1042 MS_BOOL mapi_mhl_SendWriteBurst(MS_U8 ucAddr, MS_U8 ucLength, MS_U8 *buffer)
1043 {
1044 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1045 return mdrv_mhl_SendWriteBurst(ucAddr, ucLength, buffer);
1046
1047 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1048 stMHL_SEND_WRITE_BURST pMHLArgs = {0};
1049
1050 pMHLArgs.bSendFlag = FALSE;
1051 pMHLArgs.ucAddress = ucAddr;
1052 pMHLArgs.ucLength = ucLength;
1053 pMHLArgs.ucData = buffer;
1054
1055 if(pulMHLInst == NULL)
1056 {
1057 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1058 }
1059 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SEND_WRITE_BURST, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1060 {
1061 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1062 }
1063
1064 return pMHLArgs.bSendFlag;
1065
1066 #endif
1067 }
1068
1069 //**************************************************************************
1070 // [Function Name]:
1071 // mapi_mhl_CbusSendUserWriteBurst
1072 // [Description]
1073 //
1074 // [Arguments]:
1075 //
1076 // [Return]:
1077 // TRUE: success
1078 // FALSE: fail
1079 //**************************************************************************
mapi_mhl_CbusSendUserWriteBurst(MS_U8 ucLength,MS_U8 * pBuffer)1080 MS_BOOL SYMBOL_WEAK mapi_mhl_CbusSendUserWriteBurst(MS_U8 ucLength, MS_U8 *pBuffer)
1081 {
1082 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1083 return mdrv_mhl_CbusSendUserWriteBurst(ucLength, pBuffer);
1084
1085 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1086 stMHL_SEND_USER_WRITE_BURST pMHLArgs = {0};
1087
1088 pMHLArgs.bSendFlag = FALSE;
1089 pMHLArgs.ucLength = ucLength;
1090 pMHLArgs.ucData = pBuffer;
1091
1092 if(pulMHLInst == NULL)
1093 {
1094 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1095 }
1096 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_SEND_USER_WRITE_BURST, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1097 {
1098 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1099 }
1100
1101 return pMHLArgs.bSendFlag;
1102
1103 #endif
1104 }
1105
1106 //**************************************************************************
1107 // [Function Name]:
1108 // mapi_mhl_GetDeviceCapacibility
1109 // [Description]
1110 //
1111 // [Arguments]:
1112 //
1113 // [Return]:
1114 //
1115 //**************************************************************************
mapi_mhl_GetDeviceCapacibility(MS_U16 usDevcapMask,MS_U8 * ucDevcap)1116 MS_BOOL mapi_mhl_GetDeviceCapacibility(MS_U16 usDevcapMask, MS_U8 *ucDevcap)
1117 {
1118 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1119 return mdrv_mhl_GetDeviceCapability(usDevcapMask, ucDevcap);
1120
1121 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1122 stMHL_GET_DEVICE_CAPABILITY pMHLArgs = {0};
1123
1124 pMHLArgs.bObtainFlag = FALSE;
1125 pMHLArgs.usDevcapMask = usDevcapMask;
1126 pMHLArgs.ucDeviceCapability = ucDevcap;
1127
1128 if(pulMHLInst == NULL)
1129 {
1130 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1131 }
1132 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_GET_DEVICE_CAPABILITY, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1133 {
1134 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1135 }
1136
1137 return pMHLArgs.bObtainFlag;
1138
1139 #endif
1140 }
1141
1142 //**************************************************************************
1143 // [Function Name]:
1144 // mapi_mhl_GetExtendDeviceCapacibility
1145 // [Description]
1146 //
1147 // [Arguments]:
1148 //
1149 // [Return]:
1150 //
1151 //**************************************************************************
mapi_mhl_GetExtendDeviceCapacibility(MS_U16 usExtendDevcapMask,MS_U8 * ucExtendDevcap)1152 MS_BOOL SYMBOL_WEAK mapi_mhl_GetExtendDeviceCapacibility(MS_U16 usExtendDevcapMask, MS_U8 *ucExtendDevcap)
1153 {
1154 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1155 return mdrv_mhl_GetExtendDeviceCapability(usExtendDevcapMask, ucExtendDevcap);
1156
1157 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1158 stMHL_GET_EXTEND_DEVICE_CAPABILITY pMHLArgs = {0};
1159
1160 pMHLArgs.bObtainFlag = FALSE;
1161 pMHLArgs.usExtendDevcapMask = usExtendDevcapMask;
1162 pMHLArgs.ucExtendDeviceCapability = ucExtendDevcap;
1163
1164 if(pulMHLInst == NULL)
1165 {
1166 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1167 }
1168 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_GET_EXTEND_DEVICE_CAPABILITY, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1169 {
1170 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1171 }
1172
1173 return pMHLArgs.bObtainFlag;
1174
1175 #endif
1176 }
1177
1178 //**************************************************************************
1179 // [Function Name]:
1180 // mapi_mhl_GetDeviceVenderID
1181 // [Description]
1182 //
1183 // [Arguments]:
1184 //
1185 // [Return]:
1186 //
1187 //**************************************************************************
mapi_mhl_GetDeviceVenderID(MS_U8 * ucVenderID)1188 MS_BOOL mapi_mhl_GetDeviceVenderID(MS_U8 *ucVenderID)
1189 {
1190 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1191 return mdrv_mhl_GetDeviceVenderID(ucVenderID);
1192
1193 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1194 stMHL_GET_VENDER_ID pMHLArgs = {0};
1195
1196 pMHLArgs.bObtainFlag = FALSE;
1197 pMHLArgs.ucVenderID = ucVenderID;
1198
1199 if(pulMHLInst == NULL)
1200 {
1201 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1202 }
1203 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_GET_VENDER_ID, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1204 {
1205 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1206 }
1207
1208 return pMHLArgs.bObtainFlag;
1209
1210 #endif
1211 }
1212
1213 //**************************************************************************
1214 // [Function Name]:
1215 // mapi_mhl_GetWriteBurstData
1216 // [Description]
1217 //
1218 // [Arguments]:
1219 //
1220 // [Return]:
1221 //
1222 //**************************************************************************
mapi_mhl_GetWriteBurstData(MS_U8 * ucData)1223 MS_BOOL mapi_mhl_GetWriteBurstData(MS_U8 *ucData)
1224 {
1225 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1226 return mdrv_mhl_GetWriteBurstData(ucData);
1227
1228 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1229 stMHL_GET_WRITE_BURST_DATA pMHLArgs = {0};
1230
1231 pMHLArgs.bObtainFlag = FALSE;
1232 pMHLArgs.ucWriteBurstData = ucData;
1233
1234 if(pulMHLInst == NULL)
1235 {
1236 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1237 }
1238 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_GET_WRITE_BURST_DATA, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1239 {
1240 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1241 }
1242
1243 return pMHLArgs.bObtainFlag;
1244
1245 #endif
1246 }
1247
1248 //**************************************************************************
1249 // [Function Name]:
1250 // mapi_mhl_RegisterCallBackFunctions()
1251 // [Description]
1252 // RCP &RAP call back
1253 // [Arguments]:
1254 //
1255 // [Return]:
1256 //
1257 //**************************************************************************
mapi_mhl_RegisterCallBackFunctions(link_cbus_event_handle_func rcp,link_cbus_event_handle_func rap)1258 void mapi_mhl_RegisterCallBackFunctions(link_cbus_event_handle_func rcp, link_cbus_event_handle_func rap)
1259 {
1260 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1261 MS_BOOL bRCPfunctionFlag = FALSE;
1262 MS_BOOL bRAPfunctionFlag = FALSE;
1263
1264 if(rcp != NULL)
1265 {
1266 bRCPfunctionFlag = TRUE;
1267
1268 pfRCPCallBackFunction = rcp;
1269 }
1270
1271 if(rap != NULL)
1272 {
1273 bRAPfunctionFlag = TRUE;
1274
1275 pfRAPCallBackFunction = rap;
1276 }
1277
1278 mdrv_mhl_RegisterCallBackFunctions(bRCPfunctionFlag, bRAPfunctionFlag);
1279
1280 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1281 stMHL_CALL_BACK_FUNCTION pMHLArgs = {0};
1282
1283 if(rcp == NULL)
1284 {
1285 pMHLArgs.bRCPfunctionFlag = FALSE;
1286 }
1287 else
1288 {
1289 pMHLArgs.bRCPfunctionFlag = TRUE;
1290
1291 pfRCPCallBackFunction = rcp;
1292 }
1293
1294 if(rap == NULL)
1295 {
1296 pMHLArgs.bRAPfunctionFlag = FALSE;
1297 }
1298 else
1299 {
1300 pMHLArgs.bRAPfunctionFlag = TRUE;
1301
1302 pfRAPCallBackFunction = rap;
1303 }
1304
1305 if(pulMHLInst == NULL)
1306 {
1307 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1308 }
1309 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_CALL_BACK_FUNCTION, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1310 {
1311 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1312 }
1313
1314 #endif
1315 }
1316
1317 //**************************************************************************
1318 // [Function Name]:
1319 // mapi_mhl_RegisterRcpCallBackFunction()
1320 // [Description]
1321 // RCP call back
1322 // [Arguments]:
1323 //
1324 // [Return]:
1325 //
1326 //**************************************************************************
mapi_mhl_RegisterRcpCallBackFunction(link_cbus_event_handle_func rcp)1327 void mapi_mhl_RegisterRcpCallBackFunction(link_cbus_event_handle_func rcp)
1328 {
1329 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1330 MS_BOOL bRCPfunctionFlag = FALSE;
1331
1332 if(rcp != NULL)
1333 {
1334 bRCPfunctionFlag = TRUE;
1335
1336 pfRCPCallBackFunction = rcp;
1337 }
1338
1339 mdrv_mhl_RegisterRcpCallBackFunction(bRCPfunctionFlag);
1340
1341 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1342 stMHL_RCP_CALL_BACK_FUNCTION pMHLArgs = {0};
1343
1344 if(rcp == NULL)
1345 {
1346 pMHLArgs.bRCPfunctionFlag = FALSE;
1347 }
1348 else
1349 {
1350 pMHLArgs.bRCPfunctionFlag = TRUE;
1351
1352 pfRCPCallBackFunction = rcp;
1353 }
1354
1355 if(pulMHLInst == NULL)
1356 {
1357 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1358 }
1359 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_RCP_CALL_BACK_FUNCTION, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1360 {
1361 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1362 }
1363
1364 #endif
1365 }
1366
1367 //**************************************************************************
1368 // [Function Name]:
1369 // mapi_mhl_RegisterRapCallBackFunction()
1370 // [Description]
1371 // RAP call back
1372 // [Arguments]:
1373 //
1374 // [Return]:
1375 //
1376 //**************************************************************************
mapi_mhl_RegisterRapCallBackFunction(link_cbus_event_handle_func rap)1377 void mapi_mhl_RegisterRapCallBackFunction(link_cbus_event_handle_func rap)
1378 {
1379 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1380 MS_BOOL bRAPfunctionFlag = FALSE;
1381
1382 if(rap != NULL)
1383 {
1384 bRAPfunctionFlag = TRUE;
1385
1386 pfRCPCallBackFunction = rap;
1387 }
1388
1389 mdrv_mhl_RegisterRapCallBackFunction(bRAPfunctionFlag);
1390
1391 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1392 stMHL_RAP_CALL_BACK_FUNCTION pMHLArgs = {0};
1393
1394 if(rap == NULL)
1395 {
1396 pMHLArgs.bRAPfunctionFlag = FALSE;
1397 }
1398 else
1399 {
1400 pMHLArgs.bRAPfunctionFlag = TRUE;
1401
1402 pfRAPCallBackFunction = rap;
1403 }
1404
1405 if(pulMHLInst == NULL)
1406 {
1407 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1408 }
1409 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_RAP_CALL_BACK_FUNCTION, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1410 {
1411 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1412 }
1413
1414 #endif
1415 }
1416
1417 //**************************************************************************
1418 // [Function Name]:
1419 // mapi_mhl_RegisterUcpCallBackFunction()
1420 // [Description]
1421 // UCP call back
1422 // [Arguments]:
1423 //
1424 // [Return]:
1425 //
1426 //**************************************************************************
mapi_mhl_RegisterUcpCallBackFunction(link_cbus_event_handle_func Ucp)1427 void mapi_mhl_RegisterUcpCallBackFunction(link_cbus_event_handle_func Ucp)
1428 {
1429 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1430 MS_BOOL bUCPfunctionFlag = FALSE;
1431
1432 if(Ucp != NULL)
1433 {
1434 bUCPfunctionFlag = TRUE;
1435
1436 pfRCPCallBackFunction = Ucp;
1437 }
1438
1439 mdrv_mhl_RegisterUcpCallBackFunction(bUCPfunctionFlag);
1440
1441 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1442 stMHL_UCP_CALL_BACK_FUNCTION pMHLArgs = {0};
1443
1444 if(Ucp == NULL)
1445 {
1446 pMHLArgs.bUCPfunctionFlag = FALSE;
1447 }
1448 else
1449 {
1450 pMHLArgs.bUCPfunctionFlag = TRUE;
1451
1452 pfUCPCallBackFunction = Ucp;
1453 }
1454
1455 if(pulMHLInst == NULL)
1456 {
1457 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1458 }
1459 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_UCP_CALL_BACK_FUNCTION, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1460 {
1461 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1462 }
1463
1464 #endif
1465 }
1466
1467 //**************************************************************************
1468 // [Function Name]:
1469 // mapi_mhl_RegisterAttCallBackFunction()
1470 // [Description]
1471 // ATT call back
1472 // [Arguments]:
1473 //
1474 // [Return]:
1475 //
1476 //**************************************************************************
mapi_mhl_RegisterAttCallBackFunction(link_cbus_event_handle_func Att)1477 void SYMBOL_WEAK mapi_mhl_RegisterAttCallBackFunction(link_cbus_event_handle_func Att)
1478 {
1479 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1480 MS_BOOL bATTfunctionFlag = FALSE;
1481
1482 if(Att != NULL)
1483 {
1484 bATTfunctionFlag = TRUE;
1485
1486 pfRCPCallBackFunction = Att;
1487 }
1488
1489 mdrv_mhl_RegisterAttCallBackFunction(bATTfunctionFlag);
1490
1491 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1492 stMHL_ATT_CALL_BACK_FUNCTION pMHLArgs = {0};
1493
1494 if(Att == NULL)
1495 {
1496 pMHLArgs.bATTfunctionFlag = FALSE;
1497 }
1498 else
1499 {
1500 pMHLArgs.bATTfunctionFlag = TRUE;
1501
1502 pfATTCallBackFunction = Att;
1503 }
1504
1505 if(pulMHLInst == NULL)
1506 {
1507 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1508 }
1509 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_ATT_CALL_BACK_FUNCTION, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1510 {
1511 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1512 }
1513
1514 #endif
1515 }
1516
1517 //**************************************************************************
1518 // [Function Name]:
1519 // mapi_mhl_RegisterRbpCallBackFunction()
1520 // [Description]
1521 // RBP call back
1522 // [Arguments]:
1523 //
1524 // [Return]:
1525 //
1526 //**************************************************************************
mapi_mhl_RegisterRbpCallBackFunction(link_cbus_event_handle_func Rbp)1527 void SYMBOL_WEAK mapi_mhl_RegisterRbpCallBackFunction(link_cbus_event_handle_func Rbp)
1528 {
1529 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1530 MS_BOOL bRBPfunctionFlag = FALSE;
1531
1532 if(Rbp != NULL)
1533 {
1534 bRBPfunctionFlag = TRUE;
1535
1536 pfRCPCallBackFunction = Rbp;
1537 }
1538
1539 mdrv_mhl_RegisterRbpCallBackFunction(bRBPfunctionFlag);
1540
1541 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1542 stMHL_RBP_CALL_BACK_FUNCTION pMHLArgs = {0};
1543
1544 if(Rbp == NULL)
1545 {
1546 pMHLArgs.bRBPfunctionFlag = FALSE;
1547 }
1548 else
1549 {
1550 pMHLArgs.bRBPfunctionFlag = TRUE;
1551
1552 pfRBPCallBackFunction = Rbp;
1553 }
1554
1555 if(pulMHLInst == NULL)
1556 {
1557 MAPI_MHL_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_mhl_init() first\n",__FUNCTION__,__LINE__);
1558 }
1559 else if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_RBP_CALL_BACK_FUNCTION, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1560 {
1561 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1562 }
1563
1564 #endif
1565 }
1566
1567 //**************************************************************************
1568 // [Function Name]:
1569 // mapi_mhl_GetConfig()
1570 // [Description]
1571 // MHL get init config
1572 // [Arguments]:
1573 //
1574 // [Return]:
1575 //
1576 //**************************************************************************
mapi_mhl_GetConfig(stMHL_INITIAL_CONFIG * stInitialConfig)1577 MS_U32 mapi_mhl_GetConfig(stMHL_INITIAL_CONFIG *stInitialConfig)
1578 {
1579 MS_U8 uctemp = 0;
1580 MS_U32 ulReturnValue = UTOPIA_STATUS_ERR_NOT_AVAIL;
1581
1582 #if(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_10)
1583 stMHL_INITIAL_CONFIG_INFO stInitialConfigInfo;
1584
1585 stInitialConfigInfo = mdrv_mhl_GetConfiguration();
1586
1587 stInitialConfig->ucSupportPath = stInitialConfigInfo.ucMHLSupportPath;
1588 stInitialConfig->ucEDIDTable = NULL;
1589
1590 if(stInitialConfig->ucDevcapTable != NULL)
1591 {
1592 for(uctemp = 0; uctemp < (MHL_DEVICE_CAPABILITY_SIZE +MHL_XDEVICE_CAPABILITY_SIZE); uctemp++)
1593 {
1594 stInitialConfig->ucDevcapTable[uctemp] = stInitialConfigInfo.ucDeviceCapabilityTable[uctemp];
1595 }
1596 }
1597
1598 ulReturnValue = stInitialConfigInfo.ulReturnValue;
1599
1600 #elif(MHL_USE_UTOPIA_VERSION == MHL_UTOPIA_VERSION_20)
1601 MS_BOOL bInitialFlag = FALSE;
1602 stMHL_GET_CONFIGURATION pMHLArgs;
1603
1604 pMHLArgs.stInitialConfigInfo.ulReturnValue = UTOPIA_STATUS_ERR_NOT_AVAIL;
1605
1606 if(pulMHLInst == NULL)
1607 {
1608 if(UtopiaOpen(MODULE_MHL, &pulMHLInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
1609 {
1610 MAPI_MHL_MSG_ERROR("UtopiaOpen pulMHLInst failed\n");
1611
1612 bInitialFlag = TRUE;
1613 }
1614 }
1615
1616 if(!bInitialFlag)
1617 {
1618 if(UtopiaIoctl(pulMHLInst, MAPI_CMD_MHL_GET_CONFIGURATION, (void*)&pMHLArgs) != UTOPIA_STATUS_SUCCESS)
1619 {
1620 MAPI_MHL_MSG_ERROR("Obtain MHL engine fail\n");
1621 }
1622 else
1623 {
1624 stInitialConfig->ucSupportPath = pMHLArgs.stInitialConfigInfo.ucMHLSupportPath;
1625 stInitialConfig->ucEDIDTable = NULL;
1626
1627 if(stInitialConfig->ucDevcapTable != NULL)
1628 {
1629 for(uctemp = 0; uctemp < (MHL_DEVICE_CAPABILITY_SIZE +MHL_XDEVICE_CAPABILITY_SIZE); uctemp++)
1630 {
1631 stInitialConfig->ucDevcapTable[uctemp] = pMHLArgs.stInitialConfigInfo.ucDeviceCapabilityTable[uctemp];
1632 }
1633 }
1634
1635 ulReturnValue = pMHLArgs.stInitialConfigInfo.ulReturnValue;
1636 }
1637 }
1638
1639 #endif
1640
1641 return ulReturnValue;
1642 }
1643
1644 //**************************************************************************
1645 // [Function Name]:
1646 // mapi_mhl_Send3DInformation()
1647 // [Description]
1648 //
1649 // [Arguments]:
1650 //
1651 // [Return]:
1652 //
1653 //**************************************************************************
mapi_mhl_Send3DInformation(void)1654 void mapi_mhl_Send3DInformation(void)
1655 {
1656 // Remove
1657 }
1658
1659 //**************************************************************************
1660 // [Function Name]:
1661 // mapi_mhl_CbusWakeupIntSetting()
1662 // [Description]
1663 //
1664 // [Arguments]:
1665 //
1666 // [Return]:
1667 //
1668 //**************************************************************************
mapi_mhl_CbusWakeupIntSetting(void)1669 void mapi_mhl_CbusWakeupIntSetting(void)
1670 {
1671 // Remove
1672 }
1673
1674 //**************************************************************************
1675 // [Function Name]:
1676 // mapi_mhl_PowerCtrl()
1677 // [Description]
1678 //
1679 // [Arguments]:
1680 //
1681 // [Return]:
1682 //
1683 //**************************************************************************
mapi_mhl_PowerCtrl(E_MHL_POWERCTRL_Mode pctrl)1684 void mapi_mhl_PowerCtrl(E_MHL_POWERCTRL_Mode pctrl)
1685 {
1686 // Remove
1687 pctrl = E_MHL_POWER_DOWN;
1688 }
1689
1690 #endif // _MAPI_MHL_C_
1691