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) 2006-2007 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 msAPI_CEC.c
98 /// @author MStar Semiconductor Inc.
99 /// @brief HDMI CEC API Interface
100 ///////////////////////////////////////////////////////////////////////////////////////////////////
101
102
103 //-------------------------------------------------------------------------------------------------
104 // Include Files
105 //-------------------------------------------------------------------------------------------------
106
107 #define _APICEC_C_
108
109 #ifdef MSOS_TYPE_LINUX_KERNEL
110 #include <linux/string.h>
111 #else
112 #include <string.h>
113 #endif
114 #include "MsCommon.h"
115 #include "MsVersion.h"
116 #include "MsOS.h"
117 #include "MsTypes.h"
118
119 #include "utopia.h"
120 #include "utopia_dapi.h"
121
122 #include "apiCEC.h"
123 #include "drvCEC.h"
124 #include "apiCEC_private.h"
125
126 //-------------------------------------------------------------------------------------------------
127 // Local Defines
128 //-------------------------------------------------------------------------------------------------
129 #if(defined(CONFIG_MLOG))
130 #include "ULog.h"
131
132 #define MAPI_CEC_MSG_INFO(format, args...) ULOGI("CEC", format, ##args)
133 #define MAPI_CEC_MSG_WARNING(format, args...) ULOGW("CEC", format, ##args)
134 #define MAPI_CEC_MSG_DEBUG(format, args...) ULOGD("CEC", format, ##args)
135 #define MAPI_CEC_MSG_ERROR(format, args...) ULOGE("CEC", format, ##args)
136 #define MAPI_CEC_MSG_FATAL(format, args...) ULOGF("CEC", format, ##args)
137
138 #else
139 #define MAPI_CEC_MSG_INFO(format, args...) printf(format, ##args)
140 #define MAPI_CEC_MSG_WARNING(format, args...) printf(format, ##args)
141 #define MAPI_CEC_MSG_DEBUG(format, args...) printf(format, ##args)
142 #define MAPI_CEC_MSG_ERROR(format, args...) printf(format, ##args)
143 #define MAPI_CEC_MSG_FATAL(format, args...) printf(format, ##args)
144
145 #endif
146
147
148 //-------------------------------------------------------------------------------------------------
149 // Local Structures
150 //-------------------------------------------------------------------------------------------------
151
152 //-------------------------------------------------------------------------------------------------
153 // Global Variables
154 //-------------------------------------------------------------------------------------------------
155
156 //-------------------------------------------------------------------------------------------------
157 // Local Variables
158 //-------------------------------------------------------------------------------------------------
159 static MSIF_Version _api_cec_version = {
160 .DDI = { CEC_API_VERSION },
161 };
162
163 static MS_CEC_Status _cec_status = {.bIsInitialized = FALSE, .bIsRunning = FALSE,};
164 static MS_U16 _u16CEC_DBG_SWITCH = FALSE;
165
166 void* pulCECInst;
167
168 //-------------------------------------------------------------------------------------------------
169 // Local Functions
170 //-------------------------------------------------------------------------------------------------
171
172 //-------------------------------------------------------------------------------------------------
173 // Global Functions
174 //-------------------------------------------------------------------------------------------------
175
176 //**************************************************************************
177 // [Function Name]:
178 // MApi_CEC_PortSelcet()
179 // [Description]
180 // Select CEC bank mapping
181 // [Arguments]:
182 //
183 // [Return]:
184 //
185 //**************************************************************************
MApi_CEC_PortSelcet(MsCEC_INPUT_PORT InputPort)186 void SYMBOL_WEAK MApi_CEC_PortSelcet(MsCEC_INPUT_PORT InputPort)
187 {
188 stCEC_PORT_SELECT pCECArgs = {0};
189
190 pCECArgs.InputPort = InputPort;
191
192 if(pulCECInst == NULL)
193 {
194 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
195 }
196 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_PORT_SELECT, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
197 {
198 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
199 }
200 }
201
202 //**************************************************************************
203 // [Function Name]:
204 // MApi_CEC_GetLibVer()
205 // [Description]
206 //
207 // [Arguments]:
208 //
209 // [Return]:
210 //
211 //**************************************************************************
MApi_CEC_GetLibVer(const MSIF_Version ** ppVersion)212 MS_BOOL MApi_CEC_GetLibVer(const MSIF_Version **ppVersion) ///< Get version
213 {
214 if (!ppVersion)
215 {
216 return FALSE;
217 }
218
219 *ppVersion = &_api_cec_version;
220 return TRUE;
221 }
222
223 //**************************************************************************
224 // [Function Name]:
225 // MApi_DDC2BI_GetInfo()
226 // [Description]
227 //
228 // [Arguments]:
229 //
230 // [Return]:
231 //
232 //**************************************************************************
MApi_DDC2BI_GetInfo(MS_CEC_INFO_LIST * pInfo)233 MS_BOOL MApi_DDC2BI_GetInfo(MS_CEC_INFO_LIST *pInfo)
234 {
235 stCEC_DDC2BI_GET_INFO pCECArgs = {0};
236
237 pCECArgs.eInfo = pInfo;
238 pCECArgs.bGetInfo = FALSE;
239
240 if(pulCECInst == NULL)
241 {
242 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
243 }
244 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_DDC2BI_GET_INFO, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
245 {
246 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
247 }
248
249 return pCECArgs.bGetInfo;
250 }
251
252 //**************************************************************************
253 // [Function Name]:
254 // MApi_DDC2BI_GetStatus()
255 // [Description]
256 //
257 // [Arguments]:
258 //
259 // [Return]:
260 //
261 //**************************************************************************
MApi_DDC2BI_GetStatus(MS_CEC_Status * pStatus)262 MS_BOOL MApi_DDC2BI_GetStatus(MS_CEC_Status *pStatus)
263 {
264 if (!pStatus)
265 {
266 return FALSE;
267 }
268
269 memcpy((void*)pStatus, (void*)&_cec_status, sizeof(MS_CEC_Status ));
270
271 return TRUE;
272 }
273
274 //**************************************************************************
275 // [Function Name]:
276 // MApi_DDC2BI_SetDbgLevel()
277 // [Description]
278 //
279 // [Arguments]:
280 //
281 // [Return]:
282 //
283 //**************************************************************************
MApi_DDC2BI_SetDbgLevel(MS_U16 u16DbgSwitch)284 MS_BOOL MApi_DDC2BI_SetDbgLevel(MS_U16 u16DbgSwitch)
285 {
286 _u16CEC_DBG_SWITCH = u16DbgSwitch;
287 //_u16CEC_DBG_SWITCH = _u16CEC_DBG_SWITCH;
288 return TRUE;
289 }
290
291 //**************************************************************************
292 // [Function Name]:
293 // MApi_CEC_Exit()
294 // [Description]
295 // Mask CEC interrupt and release CEC
296 // [Arguments]:
297 //
298 // [Return]:
299 //
300 //**************************************************************************
MApi_CEC_Exit(void)301 void MApi_CEC_Exit(void)
302 {
303 if(pulCECInst == NULL)
304 {
305 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
306 }
307 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_EXIT, NULL) != UTOPIA_STATUS_SUCCESS)
308 {
309 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
310 }
311 }
312
313 //**************************************************************************
314 // [Function Name]:
315 // MApi_CEC_Init()
316 // [Description]
317 // CEC initial sequence
318 // [Arguments]:
319 //
320 // [Return]:
321 //
322 //**************************************************************************
MApi_CEC_Init(MS_CEC_INIT_INFO * pCECInfo)323 void MApi_CEC_Init(MS_CEC_INIT_INFO *pCECInfo)
324 {
325 stCEC_INIT pCECArgs = {0};
326
327 pCECArgs.u32XTAL_CLK_Hz = pCECInfo->u32XTAL_CLK_Hz;
328
329 if(pulCECInst == NULL)
330 {
331 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
332 }
333 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_INIT, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
334 {
335 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
336 }
337 }
338
339 //**************************************************************************
340 // [Function Name]:
341 // MApi_CEC_InitChip()
342 // [Description]
343 // CEC chip relatived part initial (Initiation)
344 // [Arguments]:
345 //
346 // [Return]:
347 //
348 //**************************************************************************
MApi_CEC_InitChip(MS_CEC_INIT_INFO * pCECInfo)349 void MApi_CEC_InitChip(MS_CEC_INIT_INFO *pCECInfo)
350 {
351 MS_BOOL bInitialFlag = FALSE;
352 stCEC_INIT_CHIP pCECArgs = {0};
353
354 pCECArgs.u32XTAL_CLK_Hz = pCECInfo->u32XTAL_CLK_Hz;
355
356 if(pulCECInst == NULL)
357 {
358 if(UtopiaOpen(MODULE_CEC, &pulCECInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
359 {
360 MAPI_CEC_MSG_ERROR("UtopiaOpen pulCECInst failed\n");
361
362 bInitialFlag = TRUE;
363 }
364 }
365
366 if(!bInitialFlag)
367 {
368 if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_INIT_CHIP, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
369 {
370 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
371 }
372 }
373 }
374
375 //**************************************************************************
376 // [Function Name]:
377 // MApi_CEC_SetMyLogicalAddress()
378 // [Description]
379 // CEC set own logical address
380 // [Arguments]:
381 //
382 // [Return]:
383 //
384 //**************************************************************************
MApi_CEC_SetMyLogicalAddress(MsCEC_DEVICELA myLA)385 void MApi_CEC_SetMyLogicalAddress(MsCEC_DEVICELA myLA)
386 {
387 stCEC_SET_MY_LOGICAL_ADDRESS pCECArgs = {0};
388
389 pCECArgs.myLA = myLA;
390
391 if(pulCECInst == NULL)
392 {
393 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
394 }
395 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_MY_LOGICAL_ADDRESS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
396 {
397 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
398 }
399 }
400
401 //**************************************************************************
402 // [Function Name]:
403 // MApi_CEC_ChkRxBuf()
404 // [Description]
405 // Use to store CEC received messages
406 // [Arguments]:
407 //
408 // [Return]:
409 //
410 //**************************************************************************
MApi_CEC_ChkRxBuf(void)411 void MApi_CEC_ChkRxBuf(void)
412 {
413 if(pulCECInst == NULL)
414 {
415 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
416 }
417 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_CHK_RX_BUF, NULL) != UTOPIA_STATUS_SUCCESS)
418 {
419 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
420 }
421 }
422
423 //**************************************************************************
424 // [Function Name]:
425 // MApi_CEC_TxSendMsg()
426 // [Description]
427 // Use to send any CEC message by user defined
428 // If msg = E_MSG_UI_PRESS, than will send msg E_MSG_UI_RELEASE immediately
429 // [Arguments]:
430 // dst_address: destination logical address
431 // msg: CEC message
432 // cmd: message parameters
433 // len: parameter length
434 // [Return]:
435 // error_code: return status
436 //**************************************************************************
MApi_CEC_TxSendMsg(MsCEC_DEVICELA dst_address,MsCEC_MSGLIST msg,MS_U8 * cmd,MS_U8 len)437 CEC_ERROR_CODE MApi_CEC_TxSendMsg(MsCEC_DEVICELA dst_address, MsCEC_MSGLIST msg, MS_U8 *cmd, MS_U8 len)
438 {
439 stCEC_TX_SEND_MSG pCECArgs = {0};
440
441 pCECArgs.eDetAddr = dst_address;
442 pCECArgs.eMsg = msg;
443 pCECArgs.ucCmd = cmd;
444 pCECArgs.ucLen = len;
445 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
446
447 if(pulCECInst == NULL)
448 {
449 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
450 }
451 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_TX_SEND_MSG, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
452 {
453 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
454 }
455
456 return pCECArgs.eErrorCode;
457 }
458
459 //**************************************************************************
460 // [Function Name]:
461 // MApi_CEC_TxSendMsg2()
462 // [Description]
463 // Use to send any CEC message by user defined
464 // [Arguments]:
465 // dst_address: destination logical address
466 // msg: CEC message
467 // cmd: message parameters
468 // len: parameter length
469 // [Return]:
470 // error_code: return status
471 //**************************************************************************
MApi_CEC_TxSendMsg2(MsCEC_DEVICELA dst_address,MsCEC_MSGLIST msg,MS_U8 * cmd,MS_U8 len)472 CEC_ERROR_CODE MApi_CEC_TxSendMsg2(MsCEC_DEVICELA dst_address, MsCEC_MSGLIST msg, MS_U8* cmd, MS_U8 len)
473 {
474 stCEC_TX_SEND_MSG2 pCECArgs = {0};
475
476 pCECArgs.eDetAddr = dst_address;
477 pCECArgs.eMsg = msg;
478 pCECArgs.ucCmd = cmd;
479 pCECArgs.ucLen = len;
480 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
481
482 if(pulCECInst == NULL)
483 {
484 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
485 }
486 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_TX_SEND_MSG2, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
487 {
488 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
489 }
490
491 return pCECArgs.eErrorCode;
492 }
493
494 //**************************************************************************
495 // [Function Name]:
496 // MsAPI_CecTxSendPollingMsg()
497 // [Description]
498 // Use to send any CEC polling msg by user defined
499 // [Arguments]:
500 // dst_address: destination logical address
501 // [Return]:
502 // error_code: return status
503 //**************************************************************************
MsAPI_CecTxSendPollingMsg(MsCEC_DEVICELA dst_address)504 CEC_ERROR_CODE MsAPI_CecTxSendPollingMsg(MsCEC_DEVICELA dst_address)
505 {
506 stCEC_TX_SEND_POLLING_MSG pCECArgs = {0};
507
508 pCECArgs.eDetAddr = dst_address;
509 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
510
511 if(pulCECInst == NULL)
512 {
513 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
514 }
515 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_TX_SEND_POLLING_MSG, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
516 {
517 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
518 }
519
520 return pCECArgs.eErrorCode;
521 }
522
523 //**************************************************************************
524 // [Function Name]:
525 // MsAPI_CecMsg_ActiveSource()
526 // [Description]
527 // Used by a new source to indicate that it has started to transmit a stream or
528 // used in response to a <Request Active Source>
529 // [Message property]
530 // Address: Broadcast
531 // Initiator: All sources
532 // Follower: TV, CEC Switches
533 // [Arguments]:
534 //
535 // [Return]:
536 // error_code: return status
537 //**************************************************************************
MApi_CEC_Msg_ActiveSource(void)538 CEC_ERROR_CODE MApi_CEC_Msg_ActiveSource(void)
539 {
540 stCEC_TX_SEND_POLLING_MSG pCECArgs = {0};
541
542 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
543
544 if(pulCECInst == NULL)
545 {
546 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
547 }
548 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_ACTIVE_SOURCE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
549 {
550 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
551 }
552
553 return pCECArgs.eErrorCode;
554 }
555
556 //**************************************************************************
557 // [Function Name]:
558 // MsAPI_CecMsg_RoutingChange()
559 // [Description]
560 // Used by a CEC switch when it's manually switched to inform akk other devices.
561 // [Message property]
562 // Address: Broadcast
563 // Initiator: CEC switches and TV(with 2 or more HDMI inputs)
564 // Follower: CEC switches
565 // [Arguments]:
566 // orig_address: The original physicall address
567 // new_address: The new physical address
568 // [Return]:
569 // error_code: return status
570 //**************************************************************************
MApi_CEC_Msg_RoutingChange(MS_U8 * orig_address,MS_U8 * new_address)571 CEC_ERROR_CODE MApi_CEC_Msg_RoutingChange(MS_U8* orig_address, MS_U8* new_address)
572 {
573 stCEC_MSG_ROUTING_CHANGE pCECArgs = {0};
574
575 pCECArgs.ucOrigAddr = orig_address;
576 pCECArgs.ucNewAddr = new_address;
577 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
578
579 if(pulCECInst == NULL)
580 {
581 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
582 }
583 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_ROUTING_CHANGE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
584 {
585 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
586 }
587
588 return pCECArgs.eErrorCode;
589 }
590
591 //**************************************************************************
592 // [Function Name]:
593 // MsAPI_CecMsg_ReqActiveSource()
594 // [Description]
595 // Used by a new device to discover the status of the system.
596 // [Message property]
597 // Address: Broadcast
598 // Initiator:
599 // Follower: All, except for CEC Switches and devices which cannot become a source.
600 // [Arguments]:
601 //
602 // [Return]:
603 // error_code: return status
604 //**************************************************************************
MApi_CEC_Msg_ReqActiveSource(void)605 CEC_ERROR_CODE MApi_CEC_Msg_ReqActiveSource(void)
606 {
607 stCEC_MSG_REQ_ACTIVE_SOURCE pCECArgs = {0};
608
609 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
610
611 if(pulCECInst == NULL)
612 {
613 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
614 }
615 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REQ_ACTIVE_SOURCE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
616 {
617 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
618 }
619
620 return pCECArgs.eErrorCode;
621 }
622
623 //**************************************************************************
624 // [Function Name]:
625 // MsAPI_CecMsg_SetStreamPath()
626 // [Description]
627 // Used by the TV to request a streaming path from the specified physical address.
628 // [Message property]
629 // Address: Broadcast
630 // Initiator:
631 // Follower: CEC Switches
632 // [Arguments]:
633 // new_address: The new physical address
634 // [Return]:
635 // error_code: return status
636 //**************************************************************************
MApi_CEC_Msg_SetStreamPath(MS_U8 * new_address)637 CEC_ERROR_CODE MApi_CEC_Msg_SetStreamPath(MS_U8* new_address)
638 {
639 stCEC_MSG_SET_STREAM_PATH pCECArgs = {0};
640
641 pCECArgs.ucNewAddr = new_address;
642 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
643
644 if(pulCECInst == NULL)
645 {
646 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
647 }
648 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_SET_STREAM_PATH, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
649 {
650 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
651 }
652
653 return pCECArgs.eErrorCode;
654 }
655
656 //**************************************************************************
657 // [Function Name]:
658 // MsAPI_CecMsg_Standby()
659 // [Description]
660 // Use to switch one or all devices into standby mode.
661 // One device: it's specific logical address, like "E_LA_RECORDER1"
662 // All device: Use broadcast logical address, "E_LA_BROADCAST"
663 // [Message property]
664 // Address: Directly / Broadcast
665 // Initiator: TV(Broadcast Address)
666 // Follower: All
667 // [Arguments]:
668 // dst_address: destination logical address
669 // [Return]:
670 // error_code: return status
671 //**************************************************************************
MApi_CEC_Msg_Standby(MsCEC_DEVICELA dst_address)672 CEC_ERROR_CODE MApi_CEC_Msg_Standby(MsCEC_DEVICELA dst_address)
673 {
674 stCEC_MSG_STANDBY pCECArgs = {0};
675
676 pCECArgs.eDetAddr = dst_address;
677 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
678
679 if(pulCECInst == NULL)
680 {
681 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
682 }
683 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_STANDBY, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
684 {
685 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
686 }
687
688 return pCECArgs.eErrorCode;
689 }
690
691 //**************************************************************************
692 // [Function Name]:
693 // MsAPI_CecMsg_RecordOff()
694 // [Description]
695 // Requests a device to stop a recording.
696 // [Message property]
697 // Address: Directly
698 // Initiator: Device Initiating a recording
699 // Follower: Recording Device if implementing <Record On>
700 // [Arguments]:
701 // dst_address: destination logical address
702 // [Return]:
703 // error_code: return status
704 //**************************************************************************
MApi_CEC_Msg_RecordOff(MsCEC_DEVICELA dst_address)705 CEC_ERROR_CODE MApi_CEC_Msg_RecordOff(MsCEC_DEVICELA dst_address)
706 {
707 stCEC_MSG_RECORD_OFF pCECArgs = {0};
708
709 pCECArgs.eDetAddr = dst_address;
710 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
711
712 if(pulCECInst == NULL)
713 {
714 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
715 }
716 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_RECORD_OFF, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
717 {
718 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
719 }
720
721 return pCECArgs.eErrorCode;
722 }
723
724 //**************************************************************************
725 // [Function Name]:
726 // MsAPI_CecMsg_RecordOn()
727 // [Description]
728 // Attempt to record the specified source.
729 // [Message property]
730 // Address: Directly
731 // Initiator:
732 // Follower:
733 // [Arguments]:
734 // dst_address: destination logical address
735 // [Return]:
736 // error_code: return status
737 //**************************************************************************
MsAPI_CEC_Msg_RecordOn(MsCEC_DEVICELA dst_address,MsCEC_MSG_RECORD_SOURCE_TYPE cmd)738 CEC_ERROR_CODE MsAPI_CEC_Msg_RecordOn(MsCEC_DEVICELA dst_address, MsCEC_MSG_RECORD_SOURCE_TYPE cmd)
739 {
740 stCEC_MSG_RECORD_ON pCECArgs = {0};
741
742 pCECArgs.eDetAddr = dst_address;
743 pCECArgs.eCmd = cmd;
744 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
745
746 if(pulCECInst == NULL)
747 {
748 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
749 }
750 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_RECORD_ON, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
751 {
752 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
753 }
754
755 return pCECArgs.eErrorCode;
756 }
757
758 //**************************************************************************
759 // [Function Name]:
760 // MsAPI_CecMsg_ReportCECVersion()
761 // [Description]
762 // Used to indicate the supported CEC version, in response to a <Get CEC Version>
763 // [Message property]
764 // Address: Directly
765 // Initiator: All
766 // Follower: All
767 // [Arguments]:
768 // dst_address: destination logical address
769 // version: CEC version
770 // [Return]:
771 // error_code: return status
772 //**************************************************************************
MApi_CEC_Msg_ReportCECVersion(MsCEC_DEVICELA dst_address,MS_U8 version)773 CEC_ERROR_CODE MApi_CEC_Msg_ReportCECVersion(MsCEC_DEVICELA dst_address, MS_U8 version)
774 {
775 stCEC_MSG_REPORT_CEC_VERSION pCECArgs = {0};
776
777 pCECArgs.eDetAddr = dst_address;
778 pCECArgs.ucVersion = version;
779 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
780
781 if(pulCECInst == NULL)
782 {
783 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
784 }
785 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REPORT_CEC_VERSION, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
786 {
787 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
788 }
789
790 return pCECArgs.eErrorCode;
791 }
792
793 //**************************************************************************
794 // [Function Name]:
795 // MsAPI_CecMsg_ReqCECVersion()
796 // [Description]
797 // Used by a device to enquire which version of CEC the target supports
798 // [Message property]
799 // Address: Directly
800 // Initiator: All
801 // Follower: All
802 // [Arguments]:
803 // dst_address: destination logical address
804 // [Return]:
805 // error_code: return status
806 //**************************************************************************
MApi_CEC_Msg_ReqCECVersion(MsCEC_DEVICELA dst_address)807 CEC_ERROR_CODE MApi_CEC_Msg_ReqCECVersion(MsCEC_DEVICELA dst_address)
808 {
809 stCEC_MSG_REQ_CEC_VERSION pCECArgs = {0};
810
811 pCECArgs.eDetAddr = dst_address;
812 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
813
814 if(pulCECInst == NULL)
815 {
816 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
817 }
818 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REQ_CEC_VERSION, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
819 {
820 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
821 }
822
823 return pCECArgs.eErrorCode;
824 }
825
826 //**************************************************************************
827 // [Function Name]:
828 // MsAPI_CecMsg_ReportPhycalAddress()
829 // [Description]
830 // Use to inform all other devices of the mapping between physical and logical address of the initiator
831 // [Message property]
832 // Address: Broadcast
833 // Initiator: All
834 // Follower: TV
835 // [Arguments]:
836 //
837 // [Return]:
838 // error_code: return status
839 //**************************************************************************
MApi_CEC_Msg_ReportPhycalAddress(void)840 CEC_ERROR_CODE MApi_CEC_Msg_ReportPhycalAddress(void)
841 {
842 stCEC_MSG_REPORT_PHYCAL_ADDRESS pCECArgs = {0};
843
844 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
845
846 if(pulCECInst == NULL)
847 {
848 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
849 }
850 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REPORT_PHYCAL_ADDRESS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
851 {
852 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
853 }
854
855 return pCECArgs.eErrorCode;
856 }
857
858 //**************************************************************************
859 // [Function Name]:
860 // MsAPI_CecMsg_ReqPhycalAddress()
861 // [Description]
862 // A request to a device to return its physical address
863 // [Message property]
864 // Address: Directly
865 // Initiator:
866 // Follower: All, except for CEC Switches using logical address 15
867 // [Arguments]:
868 // dst_address: destination logical address
869 // [Return]:
870 // error_code: return status
871 //**************************************************************************
MApi_CEC_Msg_ReqPhycalAddress(MsCEC_DEVICELA dst_address)872 CEC_ERROR_CODE MApi_CEC_Msg_ReqPhycalAddress(MsCEC_DEVICELA dst_address)
873 {
874 stCEC_MSG_REQ_PHYCAL_ADDRESS pCECArgs = {0};
875
876 pCECArgs.eDetAddr = dst_address;
877 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
878
879 if(pulCECInst == NULL)
880 {
881 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
882 }
883 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REQ_PHYCAL_ADDRESS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
884 {
885 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
886 }
887
888 return pCECArgs.eErrorCode;
889 }
890
891 //**************************************************************************
892 // [Function Name]:
893 // MsAPI_CecMsg_DeckControl()
894 // [Description]
895 // Use to control a device's media functions
896 // [Message property]
897 // Address: Directly
898 // Initiator:
899 // Follower:
900 // [Arguments]:
901 // dst_address: destination logical address
902 // cmd: deck control mode
903 // [Return]:
904 // error_code: return status
905 //**************************************************************************
MApi_CEC_Msg_DeckControl(MsCEC_DEVICELA dst_address,MsCEC_MSG_DC_DECK_CTRL_PARM cmd)906 CEC_ERROR_CODE MApi_CEC_Msg_DeckControl(MsCEC_DEVICELA dst_address, MsCEC_MSG_DC_DECK_CTRL_PARM cmd)
907 {
908 stCEC_MSG_DECK_CONTROL pCECArgs = {0};
909
910 pCECArgs.eDetAddr = dst_address;
911 pCECArgs.eCmd = cmd;
912 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
913
914 if(pulCECInst == NULL)
915 {
916 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
917 }
918 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_DECK_CONTROL, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
919 {
920 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
921 }
922
923 return pCECArgs.eErrorCode;
924 }
925
926 //**************************************************************************
927 // [Function Name]:
928 // MsAPI_CecMsg_DeckStatus()
929 // [Description]
930 // Use to provide a device's status when received "Give Deck Status"
931 // [Message property]
932 // Address: Directly
933 // Initiator:
934 // Follower:
935 // [Arguments]:
936 // dst_address: destination logical address
937 // cmd: deck info mode
938 // [Return]:
939 // error_code: return status
940 //**************************************************************************
MApi_CEC_Msg_DecStatus(MsCEC_DEVICELA dst_address,MsCEC_MSG_DC_DECK_STATUS_PARM cmd)941 CEC_ERROR_CODE MApi_CEC_Msg_DecStatus(MsCEC_DEVICELA dst_address, MsCEC_MSG_DC_DECK_STATUS_PARM cmd)
942 {
943 stCEC_MSG_DEC_STATUS pCECArgs = {0};
944
945 pCECArgs.eDetAddr = dst_address;
946 pCECArgs.eCmd = cmd;
947 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
948
949 if(pulCECInst == NULL)
950 {
951 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
952 }
953 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_DEC_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
954 {
955 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
956 }
957
958 return pCECArgs.eErrorCode;
959 }
960
961 //**************************************************************************
962 // [Function Name]:
963 // MsAPI_CecMsg_GiveDeckStatus()
964 // [Description]
965 // Use to request device's status
966 // [Message property]
967 // Address: Directly
968 // Initiator:
969 // Follower:
970 // [Arguments]:
971 // dst_address: destination logical address
972 // cmd: status request mode
973 // [Return]:
974 // error_code: return status
975 //**************************************************************************
MApi_CEC_MSg_GiveDeckStatus(MsCEC_DEVICELA dst_address,MsCEC_MSG_STATUS_REQUEST_PARM cmd)976 CEC_ERROR_CODE MApi_CEC_MSg_GiveDeckStatus(MsCEC_DEVICELA dst_address, MsCEC_MSG_STATUS_REQUEST_PARM cmd)
977 {
978 stCEC_MSG_GIVE_DECK_STATUS pCECArgs = {0};
979
980 pCECArgs.eDetAddr = dst_address;
981 pCECArgs.eCmd = cmd;
982 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
983
984 if(pulCECInst == NULL)
985 {
986 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
987 }
988 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_GIVE_DECK_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
989 {
990 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
991 }
992
993 return pCECArgs.eErrorCode;
994 }
995
996 //**************************************************************************
997 // [Function Name]:
998 // MsAPI_CecMsg_DCPlay()
999 // [Description]
1000 // Use to control the playback behaviour of a source device
1001 // [Message property]
1002 // Address: Directly
1003 // Initiator:
1004 // Follower:
1005 // [Arguments]:
1006 // dst_address: destination logical address
1007 // cmd: play mode
1008 // [Return]:
1009 // error_code: return status
1010 //**************************************************************************
MApi_CEC_MSg_DCPlay(MsCEC_DEVICELA dst_address,MsCEC_MSG_DC_PLAY_PARM cmd)1011 CEC_ERROR_CODE MApi_CEC_MSg_DCPlay(MsCEC_DEVICELA dst_address, MsCEC_MSG_DC_PLAY_PARM cmd)
1012 {
1013 stCEC_MSG_DC_PLAY pCECArgs = {0};
1014
1015 pCECArgs.eDetAddr = dst_address;
1016 pCECArgs.eCmd = cmd;
1017 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1018
1019 if(pulCECInst == NULL)
1020 {
1021 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1022 }
1023 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_DC_PLAY, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1024 {
1025 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1026 }
1027
1028 return pCECArgs.eErrorCode;
1029 }
1030
1031 //**************************************************************************
1032 // [Function Name]:
1033 // MsAPI_CecMsg_ReqMenuStatus()
1034 // [Description]
1035 // Request from TV for a device to show/remove a menu or to query status
1036 // [Message property]
1037 // Address: Directly
1038 // Initiator:
1039 // Follower:
1040 // [Arguments]:
1041 // dst_address: destination logical address
1042 // cmd: menu request type
1043 // [Return]:
1044 // error_code: return status
1045 //**************************************************************************
MApi_CEC_Msg_ReqMenuStatus(MsCEC_DEVICELA dst_address,MsCEC_MSG_MENU_REQ_TYPE cmd)1046 CEC_ERROR_CODE MApi_CEC_Msg_ReqMenuStatus(MsCEC_DEVICELA dst_address, MsCEC_MSG_MENU_REQ_TYPE cmd)
1047 {
1048 stCEC_MSG_REQ_MENU_STATUS pCECArgs = {0};
1049
1050 pCECArgs.eDetAddr = dst_address;
1051 pCECArgs.eCmd = cmd;
1052 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1053
1054 if(pulCECInst == NULL)
1055 {
1056 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1057 }
1058 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REQ_MENU_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1059 {
1060 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1061 }
1062
1063 return pCECArgs.eErrorCode;
1064 }
1065
1066 //**************************************************************************
1067 // [Function Name]:
1068 // MsAPI_CecMsg_UserCtrlPressed()
1069 // [Description]
1070 // Use to indicated that user pressed which control button
1071 // [Message property]
1072 // Address: Directly
1073 // Initiator:
1074 // Follower:
1075 // [Arguments]:
1076 // dst_address: destination logical address
1077 // cmd: UI command
1078 // [Return]:
1079 // error_code: return status
1080 //**************************************************************************
MApi_CEC_Msg_UserCtrlPressed(MS_BOOL bUserCtrlEn,MsCEC_DEVICELA dst_address,MsCEC_MSG_USER_CTRL_PARM cmd)1081 CEC_ERROR_CODE MApi_CEC_Msg_UserCtrlPressed(MS_BOOL bUserCtrlEn, MsCEC_DEVICELA dst_address, MsCEC_MSG_USER_CTRL_PARM cmd)
1082 {
1083 stCEC_MSG_USER_CTRL_PRESSED pCECArgs = {0};
1084
1085 pCECArgs.bUserCtrlEn = bUserCtrlEn;
1086 pCECArgs.eDetAddr = dst_address;
1087 pCECArgs.eCmd = cmd;
1088 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1089
1090 if(pulCECInst == NULL)
1091 {
1092 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1093 }
1094 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_USER_CTRL_PRESSED, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1095 {
1096 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1097 }
1098
1099 return pCECArgs.eErrorCode;
1100 }
1101
1102 //**************************************************************************
1103 // [Function Name]:
1104 // MsAPI_CecMsg_UserCtrlReleased()
1105 // [Description]
1106 // Use to indicated that user released which control button
1107 // [Message property]
1108 // Address: Directly
1109 // Initiator:
1110 // Follower:
1111 // [Arguments]:
1112 // dst_address: destination logical address
1113 // [Return]:
1114 // error_code: return status
1115 //**************************************************************************
MApi_CEC_Msg_UserCtrlReleased(MsCEC_DEVICELA dst_address)1116 CEC_ERROR_CODE MApi_CEC_Msg_UserCtrlReleased(MsCEC_DEVICELA dst_address)
1117 {
1118 stCEC_MSG_USER_CTRL_RELEASED pCECArgs = {0};
1119
1120 pCECArgs.eDetAddr = dst_address;
1121 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1122
1123 if(pulCECInst == NULL)
1124 {
1125 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1126 }
1127 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_USER_CTRL_RELEASED, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1128 {
1129 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1130 }
1131
1132 return pCECArgs.eErrorCode;
1133 }
1134
1135 //**************************************************************************
1136 // [Function Name]:
1137 // MsAPI_CecMsg_ReportPowerStatus()
1138 // [Description]
1139 // Use to inform a requesting device of the current power status
1140 // [Message property]
1141 // Address: Directly
1142 // Initiator: All (except CEC switches)
1143 // Follower:
1144 // [Arguments]:
1145 // dst_address: destination logical address
1146 // [Return]:
1147 // error_code: return status
1148 //**************************************************************************
MApi_CEC_Msg_ReportPowerStatus(MsCEC_DEVICELA dst_address)1149 CEC_ERROR_CODE MApi_CEC_Msg_ReportPowerStatus(MsCEC_DEVICELA dst_address)
1150 {
1151 stCEC_MSG_REPORT_POWER_STATUS pCECArgs = {0};
1152
1153 pCECArgs.eDetAddr = dst_address;
1154 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1155
1156 if(pulCECInst == NULL)
1157 {
1158 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1159 }
1160 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REPORT_POWER_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1161 {
1162 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1163 }
1164
1165 return pCECArgs.eErrorCode;
1166 }
1167
1168 //**************************************************************************
1169 // [Function Name]:
1170 // MsAPI_CecMsg_ReqPowerStatus()
1171 // [Description]
1172 // Use to determine the current power status of a target device
1173 // [Message property]
1174 // Address: Directly
1175 // Initiator:
1176 // Follower: All (except CEC switches)
1177 // [Arguments]:
1178 // dst_address: destination logical address
1179 // [Return]:
1180 // error_code: return status
1181 //**************************************************************************
MApi_CEC_Msg_ReqPowerStatus(MsCEC_DEVICELA dst_address)1182 CEC_ERROR_CODE MApi_CEC_Msg_ReqPowerStatus(MsCEC_DEVICELA dst_address)
1183 {
1184 stCEC_MSG_REQ_POWER_STATUS pCECArgs = {0};
1185
1186 pCECArgs.eDetAddr = dst_address;
1187 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1188
1189 if(pulCECInst == NULL)
1190 {
1191 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1192 }
1193 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REQ_POWER_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1194 {
1195 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1196 }
1197
1198 return pCECArgs.eErrorCode;
1199 }
1200
1201 //**************************************************************************
1202 // [Function Name]:
1203 // MsAPI_CecMsg_FeatureAbort()
1204 // [Description]
1205 // Use to indicate that device doesn't support message type
1206 // [Message property]
1207 // Address: Directly
1208 // Initiator: Generate if a message is not supported
1209 // Follower: All
1210 // [Arguments]:
1211 // dst_address: destination logical address
1212 // msg: the requested message type
1213 // cmd: unsupport reason
1214 // [Return]:
1215 // error_code: return status
1216 //**************************************************************************
MApi_CEC_Msg_FeatureAbort(MsCEC_DEVICELA dst_address,MsCEC_MSGLIST msg,MsCEC_MSG_ABORT_REASON cmd)1217 CEC_ERROR_CODE MApi_CEC_Msg_FeatureAbort(MsCEC_DEVICELA dst_address, MsCEC_MSGLIST msg, MsCEC_MSG_ABORT_REASON cmd)
1218 {
1219 stCEC_MSG_FEATURE_ABORT pCECArgs = {0};
1220
1221 pCECArgs.eDetAddr = dst_address;
1222 pCECArgs.eMsg = msg;
1223 pCECArgs.eCmd = cmd;
1224 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1225
1226 if(pulCECInst == NULL)
1227 {
1228 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1229 }
1230 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_FEATURE_ABORT, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1231 {
1232 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1233 }
1234
1235 return pCECArgs.eErrorCode;
1236 }
1237
1238 //**************************************************************************
1239 // [Function Name]:
1240 // MsAPI_CecMsg_Abort()
1241 // [Description]
1242 // This message is reserved for testing purposes.
1243 // [Message property]
1244 // Address: Directly
1245 // Initiator:
1246 // Follower: All except for CEC switches
1247 // [Arguments]:
1248 // dst_address: destination logical address
1249 // [Return]:
1250 // error_code: return status
1251 //**************************************************************************
MApi_CEC_Msg_Abort(MsCEC_DEVICELA dst_address)1252 CEC_ERROR_CODE MApi_CEC_Msg_Abort(MsCEC_DEVICELA dst_address)
1253 {
1254 stCEC_MSG_ABORT pCECArgs = {0};
1255
1256 pCECArgs.eDetAddr = dst_address;
1257 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1258
1259 if(pulCECInst == NULL)
1260 {
1261 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1262 }
1263 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_ABORT, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1264 {
1265 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1266 }
1267
1268 return pCECArgs.eErrorCode;
1269 }
1270
1271 //**************************************************************************
1272 // [Function Name]:
1273 // MApi_CEC_Msg_SendMenuLanguage()
1274 // [Description]
1275 // Used by a CEC switch when it's manually switched language to inform akk other devices.
1276 // [Message property]
1277 // Address: Broadcast
1278 // Initiator: CEC switches and TV(with 2 or more HDMI inputs)
1279 // Follower: CEC switches
1280 // [Arguments]:
1281 // MenuLanguageCode: iso639-2 Language Code, 3 bytes
1282 // [Return]:
1283 // error_code: return status
1284 //**************************************************************************
MApi_CEC_Msg_SendMenuLanguage(MS_U8 * pu8MenuLanguageCode)1285 CEC_ERROR_CODE MApi_CEC_Msg_SendMenuLanguage(MS_U8* pu8MenuLanguageCode)
1286 {
1287 stCEC_MSG_SEND_MENU_LANGUAGE pCECArgs = {0};
1288
1289 pCECArgs.pu8MenulanguageCode = pu8MenuLanguageCode;
1290 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1291
1292 if(pulCECInst == NULL)
1293 {
1294 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1295 }
1296 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_SEND_MENU_LANGUAGE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1297 {
1298 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1299 }
1300
1301 return pCECArgs.eErrorCode;
1302 }
1303
1304 //**************************************************************************
1305 // [Function Name]:
1306 // MsAPI_CecMsg_ReqARCInitiation()
1307 // [Description]
1308 // Used by an ARC TX device to request an ARC RX device to active
1309 // the ARC functionility in ARC TX device
1310 // [Message property]
1311 // Address: Directly
1312 // Initiator:
1313 // Follower: ARC RX device
1314 // [Arguments]:
1315 // dst_address: destination logical address
1316 // [Return]:
1317 // error_code: return status
1318 //**************************************************************************
MsAPI_CecMsg_ReqARCInitiation(MsCEC_DEVICELA dst_address)1319 CEC_ERROR_CODE MsAPI_CecMsg_ReqARCInitiation(MsCEC_DEVICELA dst_address)
1320 {
1321 stCEC_MSG_REQ_ARC_INITIATION pCECArgs = {0};
1322
1323 pCECArgs.eDetAddr = dst_address;
1324 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1325
1326 if(pulCECInst == NULL)
1327 {
1328 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1329 }
1330 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REQ_ARC_INITIATION, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1331 {
1332 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1333 }
1334
1335 return pCECArgs.eErrorCode;
1336 }
1337
1338 //**************************************************************************
1339 // [Function Name]:
1340 // MsAPI_CecMsg_ReqARCTermination()
1341 // [Description]
1342 // Used by an ARC TX device to request an ARC RX device to deactive
1343 // the ARC functionility in ARC TX device
1344 // [Message property]
1345 // Address: Directly
1346 // Initiator:
1347 // Follower: ARC RX device
1348 // [Arguments]:
1349 // dst_address: destination logical address
1350 // [Return]:
1351 // error_code: return status
1352 //**************************************************************************
MsAPI_CecMsg_ReqARCTermination(MsCEC_DEVICELA dst_address)1353 CEC_ERROR_CODE MsAPI_CecMsg_ReqARCTermination(MsCEC_DEVICELA dst_address)
1354 {
1355 stCEC_MSG_REQ_ARC_TERMINATION pCECArgs = {0};
1356
1357 pCECArgs.eDetAddr = dst_address;
1358 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1359
1360 if(pulCECInst == NULL)
1361 {
1362 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1363 }
1364 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REQ_ARC_TERMINATION, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1365 {
1366 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1367 }
1368
1369 return pCECArgs.eErrorCode;
1370 }
1371
1372 //**************************************************************************
1373 // [Function Name]:
1374 // MsAPI_CecMsg_AudioModeReq()
1375 // [Description]
1376 // A device implementing System Audio Control and which has volume control
1377 // RC buttons request to use System Audio Mode to the Amplifier
1378 // [Message property]
1379 // Address: Directly
1380 // Initiator:
1381 // Follower:
1382 // [Arguments]:
1383 // dst_address: destination logical address
1384 // amp_switch: 1: unmute amplifier. 0: mute amplifier
1385 // my_address: source to be used is the device specified at this address
1386 // [Return]:
1387 // error_code: return status
1388 //**************************************************************************
MsAPI_CecMsg_AudioModeReq(MsCEC_DEVICELA dst_address,MS_BOOL amp_switch,MS_U8 * my_address)1389 CEC_ERROR_CODE MsAPI_CecMsg_AudioModeReq(MsCEC_DEVICELA dst_address, MS_BOOL amp_switch, MS_U8* my_address )
1390 {
1391 stCEC_MSG_AUDIO_MODE_REQ pCECArgs = {0};
1392
1393 pCECArgs.eDetAddr = dst_address;
1394 pCECArgs.bAmpSwitch = amp_switch;
1395 pCECArgs.ucMyAddress = my_address;
1396 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1397
1398 if(pulCECInst == NULL)
1399 {
1400 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1401 }
1402 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_AUDIO_MODE_REQ, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1403 {
1404 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1405 }
1406
1407 return pCECArgs.eErrorCode;
1408 }
1409
1410 //**************************************************************************
1411 // [Function Name]:
1412 // MApi_CEC_Msg_GiveAudioStatus()
1413 // [Description]
1414 // Use to request an Amplifier to send its volume and mute status
1415 // [Message property]
1416 // Address: Directly
1417 // Initiator: All (except CEC switches)
1418 // Follower:
1419 // [Arguments]:
1420 // dst_address: destination logical address
1421 // [Return]:
1422 // error_code: return status
1423 //**************************************************************************
MApi_CEC_Msg_GiveAudioStatus(MsCEC_DEVICELA dst_address)1424 CEC_ERROR_CODE MApi_CEC_Msg_GiveAudioStatus(MsCEC_DEVICELA dst_address)
1425 {
1426 stCEC_MSG_GIVE_AUDIO_STATUS pCECArgs = {0};
1427
1428 pCECArgs.eDetAddr = dst_address;
1429 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
1430
1431 if(pulCECInst == NULL)
1432 {
1433 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1434 }
1435 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_GIVE_AUDIO_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1436 {
1437 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1438 }
1439
1440 return pCECArgs.eErrorCode;
1441 }
1442
1443 //**************************************************************************
1444 // [Function Name]:
1445 // MApi_CEC_Get_Header()
1446 // [Description]
1447 //
1448 // [Arguments]:
1449 //
1450 // [Return]:
1451 //
1452 //**************************************************************************
MApi_CEC_Get_Header(void)1453 MS_U8 MApi_CEC_Get_Header(void)
1454 {
1455 stCEC_GET_HEADER pCECArgs = {0};
1456
1457 pCECArgs.ucValue = 0;
1458
1459 if(pulCECInst == NULL)
1460 {
1461 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1462 }
1463 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_HEADER, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1464 {
1465 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1466 }
1467
1468 return pCECArgs.ucValue;
1469 }
1470
1471 //**************************************************************************
1472 // [Function Name]:
1473 // MApi_CEC_Get_OpCode()
1474 // [Description]
1475 //
1476 // [Arguments]:
1477 //
1478 // [Return]:
1479 //
1480 //**************************************************************************
MApi_CEC_Get_OpCode(void)1481 MS_U8 MApi_CEC_Get_OpCode(void)
1482 {
1483 stCEC_GET_OPCODE pCECArgs = {0};
1484
1485 pCECArgs.ucValue = 0;
1486
1487 if(pulCECInst == NULL)
1488 {
1489 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1490 }
1491 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_OPCODE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1492 {
1493 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1494 }
1495
1496 return pCECArgs.ucValue;
1497 }
1498
1499 //**************************************************************************
1500 // [Function Name]:
1501 // MApi_CEC_Get_Para()
1502 // [Description]
1503 //
1504 // [Arguments]:
1505 //
1506 // [Return]:
1507 //
1508 //**************************************************************************
MApi_CEC_Get_Para(MS_U8 u8Idx)1509 MS_U8 MApi_CEC_Get_Para(MS_U8 u8Idx)
1510 {
1511 stCEC_GET_PARA pCECArgs = {0};
1512
1513 pCECArgs.ucIdx = u8Idx;
1514 pCECArgs.ucValue = 0;
1515
1516 if(pulCECInst == NULL)
1517 {
1518 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1519 }
1520 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_PARA, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1521 {
1522 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1523 }
1524
1525 return pCECArgs.ucValue;
1526 }
1527
1528 //**************************************************************************
1529 // [Function Name]:
1530 // MApi_CEC_GetCmdLen()
1531 // [Description]
1532 //
1533 // [Arguments]:
1534 //
1535 // [Return]:
1536 //
1537 //**************************************************************************
MApi_CEC_GetCmdLen(void)1538 MS_U8 MApi_CEC_GetCmdLen(void)
1539 {
1540 stCEC_GET_CMD_LEN pCECArgs = {0};
1541
1542 pCECArgs.ucValue = 0;
1543
1544 if(pulCECInst == NULL)
1545 {
1546 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1547 }
1548 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_CMD_LEN, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1549 {
1550 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1551 }
1552
1553 return pCECArgs.ucValue;
1554 }
1555
1556 //**************************************************************************
1557 // [Function Name]:
1558 // MApi_CEC_SetActiveLogicalAddress()
1559 // [Description]
1560 //
1561 // [Arguments]:
1562 //
1563 // [Return]:
1564 //
1565 //**************************************************************************
MApi_CEC_SetActiveLogicalAddress(MsCEC_DEVICELA Addr)1566 void MApi_CEC_SetActiveLogicalAddress(MsCEC_DEVICELA Addr)
1567 {
1568 stCEC_SET_ACTIVE_LOGICAL_ADDRESS pCECArgs = {0};
1569
1570 pCECArgs.eAddr = Addr;
1571
1572 if(pulCECInst == NULL)
1573 {
1574 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1575 }
1576 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_ACTIVE_LOGICAL_ADDRESS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1577 {
1578 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1579 }
1580 }
1581
1582 //**************************************************************************
1583 // [Function Name]:
1584 // MApi_CEC_GetActiveLogicalAddress()
1585 // [Description]
1586 //
1587 // [Arguments]:
1588 //
1589 // [Return]:
1590 //
1591 //**************************************************************************
MApi_CEC_GetActiveLogicalAddress(void)1592 MsCEC_DEVICELA MApi_CEC_GetActiveLogicalAddress(void)
1593 {
1594 stCEC_GET_ACTIVE_LOGICAL_ADDRESS pCECArgs = {0};
1595
1596 pCECArgs.eAddr = E_LA_UNREGISTERED;
1597
1598 if(pulCECInst == NULL)
1599 {
1600 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1601 }
1602 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_ACTIVE_LOGICAL_ADDRESS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1603 {
1604 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1605 }
1606
1607 return pCECArgs.eAddr;
1608 }
1609
1610 //**************************************************************************
1611 // [Function Name]:
1612 // MApi_CEC_GetPowerStatus()
1613 // [Description]
1614 //
1615 // [Arguments]:
1616 //
1617 // [Return]:
1618 //
1619 //**************************************************************************
MApi_CEC_GetPowerStatus(void)1620 MsCEC_MSG_POWER_STATUS_PARM MApi_CEC_GetPowerStatus(void)
1621 {
1622 stCEC_GET_POWER_STATUS pCECArgs = {0};
1623
1624 pCECArgs.ePowerStatus = E_MSG_PWRSTA_UNKNOW;
1625
1626 if(pulCECInst == NULL)
1627 {
1628 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1629 }
1630 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_POWER_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1631 {
1632 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1633 }
1634
1635 return pCECArgs.ePowerStatus;
1636 }
1637
1638 //**************************************************************************
1639 // [Function Name]:
1640 // MApi_CEC_GetFifoIdx()
1641 // [Description]
1642 //
1643 // [Arguments]:
1644 //
1645 // [Return]:
1646 //
1647 //**************************************************************************
MApi_CEC_GetFifoIdx(void)1648 MS_U8 MApi_CEC_GetFifoIdx(void)
1649 {
1650 stCEC_GET_FIFO_IDX pCECArgs = {0};
1651
1652 pCECArgs.ucFifoIdx = 0;
1653
1654 if(pulCECInst == NULL)
1655 {
1656 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1657 }
1658 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_FIFO_IDX, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1659 {
1660 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1661 }
1662
1663 return pCECArgs.ucFifoIdx;
1664 }
1665
1666 //**************************************************************************
1667 // [Function Name]:
1668 // MApi_CEC_SetFifoIdx()
1669 // [Description]
1670 //
1671 // [Arguments]:
1672 //
1673 // [Return]:
1674 //
1675 //**************************************************************************
MApi_CEC_SetFifoIdx(MS_U8 u8Idx)1676 void MApi_CEC_SetFifoIdx(MS_U8 u8Idx)
1677 {
1678 stCEC_SET_FIFO_IDX pCECArgs = {0};
1679
1680 pCECArgs.ucIdx = u8Idx;
1681
1682 if(pulCECInst == NULL)
1683 {
1684 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1685 }
1686 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_FIFO_IDX, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1687 {
1688 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1689 }
1690 }
1691
1692 //**************************************************************************
1693 // [Function Name]:
1694 // MApi_CEC_SetActivePowerStatus()
1695 // [Description]
1696 //
1697 // [Arguments]:
1698 //
1699 // [Return]:
1700 //
1701 //**************************************************************************
MApi_CEC_SetActivePowerStatus(MsCEC_MSG_POWER_STATUS_PARM Status)1702 void MApi_CEC_SetActivePowerStatus(MsCEC_MSG_POWER_STATUS_PARM Status)
1703 {
1704 stCEC_SET_ACTIVE_POWER_STATUS pCECArgs = {0};
1705
1706 pCECArgs.eStatus = Status;
1707
1708 if(pulCECInst == NULL)
1709 {
1710 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1711 }
1712 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_ACTIVE_POWER_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1713 {
1714 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1715 }
1716 }
1717
1718 //**************************************************************************
1719 // [Function Name]:
1720 // MApi_CEC_GetActivePowerStatus()
1721 // [Description]
1722 //
1723 // [Arguments]:
1724 //
1725 // [Return]:
1726 //
1727 //**************************************************************************
MApi_CEC_GetActivePowerStatus(void)1728 MsCEC_MSG_POWER_STATUS_PARM MApi_CEC_GetActivePowerStatus(void)
1729 {
1730 stCEC_GET_ACTIVE_POWER_STATUS pCECArgs = {0};
1731
1732 pCECArgs.ePowerStatus = E_MSG_PWRSTA_UNKNOW;
1733
1734 if(pulCECInst == NULL)
1735 {
1736 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1737 }
1738 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_ACTIVE_POWER_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1739 {
1740 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1741 }
1742
1743 return pCECArgs.ePowerStatus;
1744 }
1745
1746 //**************************************************************************
1747 // [Function Name]:
1748 // MApi_CEC_SetActivePhysicalAddress()
1749 // [Description]
1750 //
1751 // [Arguments]:
1752 //
1753 // [Return]:
1754 //
1755 //**************************************************************************
MApi_CEC_SetActivePhysicalAddress(MS_U8 u8Para1,MS_U8 u8Para2)1756 void MApi_CEC_SetActivePhysicalAddress(MS_U8 u8Para1, MS_U8 u8Para2)
1757 {
1758 stCEC_SET_ACTIVE_PHYSICAL_ADDRESS pCECArgs = {0};
1759
1760 pCECArgs.ucPara1 = u8Para1;
1761 pCECArgs.ucPara2 = u8Para2;
1762
1763 if(pulCECInst == NULL)
1764 {
1765 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1766 }
1767 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_ACTIVE_PHYSICAL_ADDRESS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1768 {
1769 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1770 }
1771 }
1772
1773 //**************************************************************************
1774 // [Function Name]:
1775 // MApi_CEC_SetActiveDeviceCECVersion()
1776 // [Description]
1777 //
1778 // [Arguments]:
1779 //
1780 // [Return]:
1781 //
1782 //**************************************************************************
MApi_CEC_SetActiveDeviceCECVersion(MS_U8 u8Ver)1783 void MApi_CEC_SetActiveDeviceCECVersion(MS_U8 u8Ver)
1784 {
1785 stCEC_SET_ACTIVE_DEVICE_CEC_VERSION pCECArgs = {0};
1786
1787 pCECArgs.ucVer = u8Ver;
1788
1789 if(pulCECInst == NULL)
1790 {
1791 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1792 }
1793 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_ACTIVE_DEVICE_CEC_VERSION, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1794 {
1795 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1796 }
1797 }
1798
1799 //**************************************************************************
1800 // [Function Name]:
1801 // MApi_CEC_SetActiveDeviceType()
1802 // [Description]
1803 //
1804 // [Arguments]:
1805 //
1806 // [Return]:
1807 //
1808 //**************************************************************************
MApi_CEC_SetActiveDeviceType(MsCEC_DEVICE_TYPE Type)1809 void MApi_CEC_SetActiveDeviceType(MsCEC_DEVICE_TYPE Type)
1810 {
1811 stCEC_SET_ACTIVE_DEVICE_TYPE pCECArgs = {0};
1812
1813 pCECArgs.eType = Type;
1814
1815 if(pulCECInst == NULL)
1816 {
1817 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1818 }
1819 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_ACTIVE_DEVICE_TYPE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1820 {
1821 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1822 }
1823 }
1824
1825 //**************************************************************************
1826 // [Function Name]:
1827 // MApi_CEC_GetMsgCnt()
1828 // [Description]
1829 //
1830 // [Arguments]:
1831 //
1832 // [Return]:
1833 //
1834 //**************************************************************************
MApi_CEC_GetMsgCnt(void)1835 MS_U8 MApi_CEC_GetMsgCnt(void)
1836 {
1837 stCEC_GET_MSG_CNT pCECArgs = {0};
1838
1839 pCECArgs.ucMsgCnt = 0;
1840
1841 if(pulCECInst == NULL)
1842 {
1843 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1844 }
1845 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_MSG_CNT, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1846 {
1847 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1848 }
1849
1850 return pCECArgs.ucMsgCnt;
1851 }
1852
1853 //**************************************************************************
1854 // [Function Name]:
1855 // MApi_CEC_SetMsgCnt()
1856 // [Description]
1857 //
1858 // [Arguments]:
1859 //
1860 // [Return]:
1861 //
1862 //**************************************************************************
MApi_CEC_SetMsgCnt(MS_U8 u8Cnt)1863 void MApi_CEC_SetMsgCnt(MS_U8 u8Cnt)
1864 {
1865 stCEC_SET_MSG_CNT pCECArgs = {0};
1866
1867 pCECArgs.ucCnt = u8Cnt;
1868
1869 if(pulCECInst == NULL)
1870 {
1871 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1872 }
1873 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_MSG_CNT, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1874 {
1875 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1876 }
1877 }
1878
1879 //**************************************************************************
1880 // [Function Name]:
1881 // MApi_CEC_GetRxData()
1882 // [Description]
1883 //
1884 // [Arguments]:
1885 //
1886 // [Return]:
1887 //
1888 //**************************************************************************
MApi_CEC_GetRxData(MS_U8 u8Fifoidx,MS_U8 u8Idx)1889 MS_U8 MApi_CEC_GetRxData(MS_U8 u8Fifoidx, MS_U8 u8Idx)
1890 {
1891 stCEC_GET_RX_DATA pCECArgs = {0};
1892
1893 pCECArgs.ucFifoIdx = u8Fifoidx;
1894 pCECArgs.ucIdx = u8Idx;
1895 pCECArgs.ucRxData = 0;
1896
1897 if(pulCECInst == NULL)
1898 {
1899 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1900 }
1901 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_RX_DATA, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1902 {
1903 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1904 }
1905
1906 return pCECArgs.ucRxData;
1907 }
1908
1909 //**************************************************************************
1910 // [Function Name]:
1911 // MApi_CEC_CheckFrame()
1912 // [Description]
1913 //
1914 // [Arguments]:
1915 //
1916 // [Return]:
1917 //
1918 //**************************************************************************
MApi_CEC_CheckFrame(MsCEC_MSG_TRANS_TYPE msg_type,MS_U8 ucLen)1919 MS_BOOL MApi_CEC_CheckFrame(MsCEC_MSG_TRANS_TYPE msg_type, MS_U8 ucLen)
1920 {
1921 stCEC_CHECK_FRAME pCECArgs = {0};
1922
1923 pCECArgs.eMsgType = msg_type;
1924 pCECArgs.ucLen = ucLen;
1925 pCECArgs.bValid = FALSE;
1926
1927 if(pulCECInst == NULL)
1928 {
1929 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1930 }
1931 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_CHECK_FRAME, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
1932 {
1933 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1934 }
1935
1936 return pCECArgs.bValid;
1937 }
1938
1939 //**************************************************************************
1940 // [Function Name]:
1941 // MApi_CEC_CheckExistDevices()
1942 // [Description]
1943 //
1944 // [Arguments]:
1945 //
1946 // [Return]:
1947 //
1948 //**************************************************************************
MApi_CEC_CheckExistDevices(void)1949 void MApi_CEC_CheckExistDevices(void)
1950 {
1951 if(pulCECInst == NULL)
1952 {
1953 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1954 }
1955 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_CHECK_EXIST_DEVICES, NULL) != UTOPIA_STATUS_SUCCESS)
1956 {
1957 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1958 }
1959 }
1960
1961 //**************************************************************************
1962 // [Function Name]:
1963 // MApi_CEC_ConfigWakeUp()
1964 // [Description]
1965 //
1966 // [Arguments]:
1967 //
1968 // [Return]:
1969 //
1970 //**************************************************************************
MApi_CEC_ConfigWakeUp(void)1971 void MApi_CEC_ConfigWakeUp(void)
1972 {
1973 if(pulCECInst == NULL)
1974 {
1975 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
1976 }
1977 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_CONFIG_WAKEUP, NULL) != UTOPIA_STATUS_SUCCESS)
1978 {
1979 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
1980 }
1981 }
1982
1983 //**************************************************************************
1984 // [Function Name]:
1985 // MApi_CEC_Enabled()
1986 // [Description]
1987 //
1988 // [Arguments]:
1989 //
1990 // [Return]:
1991 //
1992 //**************************************************************************
MApi_CEC_Enabled(MS_BOOL bEnableFlag)1993 void MApi_CEC_Enabled(MS_BOOL bEnableFlag)
1994 {
1995 stCEC_ENABLED pCECArgs = {0};
1996
1997 pCECArgs.bEnableFlag = bEnableFlag;
1998
1999 if(pulCECInst == NULL)
2000 {
2001 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2002 }
2003 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_ENABLED, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2004 {
2005 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2006 }
2007 }
2008
2009 //**************************************************************************
2010 // [Function Name]:
2011 // MApi_CEC_SetMyPhysicalAddress()
2012 // [Description]
2013 //
2014 // [Arguments]:
2015 //
2016 // [Return]:
2017 //
2018 //**************************************************************************
MApi_CEC_SetMyPhysicalAddress(MS_U8 * pdata)2019 void MApi_CEC_SetMyPhysicalAddress(MS_U8 *pdata)
2020 {
2021 stCEC_SET_MY_PHYSICAL_ADDRESS pCECArgs = {0};
2022
2023 pCECArgs.ucData = pdata;
2024
2025 if(pulCECInst == NULL)
2026 {
2027 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2028 }
2029 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_MY_PHYSICAL_ADDRESS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2030 {
2031 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2032 }
2033 }
2034
2035 #if ENABLE_CEC_MULTIPLE
2036 //**************************************************************************
2037 // [Function Name]:
2038 // MApi_CEC_SetMyLogicalAddress2()
2039 // [Description]
2040 //
2041 // [Arguments]:
2042 //
2043 // [Return]:
2044 //
2045 //**************************************************************************
MApi_CEC_SetMyLogicalAddress2(MsCEC_DEVICELA myLA)2046 void MApi_CEC_SetMyLogicalAddress2(MsCEC_DEVICELA myLA)
2047 {
2048 stCEC_SET_MY_LOGICAL_ADDRESS2 pCECArgs = {0};
2049
2050 pCECArgs.myLA = myLA;
2051
2052 if(pulCECInst == NULL)
2053 {
2054 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2055 }
2056 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_MY_LOGICAL_ADDRESS2, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2057 {
2058 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2059 }
2060 }
2061
2062 //**************************************************************************
2063 // [Function Name]:
2064 // MApi_CEC_Msg_ReportPhycalAddress2()
2065 // [Description]
2066 //
2067 // [Arguments]:
2068 //
2069 // [Return]:
2070 //
2071 //**************************************************************************
MApi_CEC_Msg_ReportPhycalAddress2(void)2072 CEC_ERROR_CODE MApi_CEC_Msg_ReportPhycalAddress2(void)
2073 {
2074 stCEC_MSG_REPORT_PHYCAL_ADDRESS2 pCECArgs = {0};
2075
2076 pCECArgs.eErrorCode = E_CEC_FEATURE_ABORT;
2077
2078 if(pulCECInst == NULL)
2079 {
2080 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2081 }
2082 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_MSG_REPORT_PHYCAL_ADDRESS2, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2083 {
2084 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2085 }
2086
2087 return pCECArgs.eErrorCode;
2088 }
2089
2090 //**************************************************************************
2091 // [Function Name]:
2092 // MApi_CEC_SetMyPhysicalAddress2()
2093 // [Description]
2094 //
2095 // [Arguments]:
2096 //
2097 // [Return]:
2098 //
2099 //**************************************************************************
MApi_CEC_SetMyPhysicalAddress2(MS_U8 * pdata)2100 void MApi_CEC_SetMyPhysicalAddress2(MS_U8 *pdata)
2101 {
2102 stCEC_SET_MY_PHYSICAL_ADDRESS2 pCECArgs = {0};
2103
2104 pCECArgs.ucData = pdata;
2105
2106 if(pulCECInst == NULL)
2107 {
2108 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2109 }
2110 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_MY_PHYSICAL_ADDRESS2, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2111 {
2112 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2113 }
2114 }
2115
2116 //**************************************************************************
2117 // [Function Name]:
2118 // MApi_CEC_SetInitiator()
2119 // [Description]
2120 //
2121 // [Arguments]:
2122 //
2123 // [Return]:
2124 //
2125 //**************************************************************************
MApi_CEC_SetInitiator(MsCEC_DEVICELA IniLA)2126 void MApi_CEC_SetInitiator(MsCEC_DEVICELA IniLA)
2127 {
2128 stCEC_SET_INITIATOR pCECArgs = {0};
2129
2130 pCECArgs.eIniLa = IniLA;
2131
2132 if(pulCECInst == NULL)
2133 {
2134 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2135 }
2136 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_INITIATOR, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2137 {
2138 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2139 }
2140 }
2141
2142 #endif
2143
2144 //**************************************************************************
2145 // [Function Name]:
2146 // MApi_CEC_GetTxStatus()
2147 // [Description]
2148 //
2149 // [Arguments]:
2150 //
2151 // [Return]:
2152 //
2153 //**************************************************************************
MApi_CEC_GetTxStatus(void)2154 MS_U8 MApi_CEC_GetTxStatus(void)
2155 {
2156 stCEC_GET_TX_STATUS pCECArgs = {0};
2157
2158 pCECArgs.ucTxStatus = 0;
2159
2160 if(pulCECInst == NULL)
2161 {
2162 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2163 }
2164 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_TX_STATUS, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2165 {
2166 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2167 }
2168
2169 return pCECArgs.ucTxStatus;
2170 }
2171
2172 //**************************************************************************
2173 // [Function Name]:
2174 // MApi_CEC_SetPowerState()
2175 // [Description]
2176 //
2177 // [Arguments]:
2178 //
2179 // [Return]:
2180 //
2181 //**************************************************************************
MApi_CEC_SetPowerState(EN_POWER_MODE u16PowerState)2182 MS_U32 MApi_CEC_SetPowerState(EN_POWER_MODE u16PowerState)
2183 {
2184 stCEC_SET_POWER_STATE pCECArgs = {0};
2185
2186 pCECArgs.ePowerState = u16PowerState;
2187 pCECArgs.u32Status = 0;
2188
2189 if(pulCECInst == NULL)
2190 {
2191 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2192 }
2193 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_POWER_STATE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2194 {
2195 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2196 }
2197
2198 return pCECArgs.u32Status;
2199 }
2200
2201 //**************************************************************************
2202 // [Function Name]:
2203 // MApi_CEC_SetRetryCount()
2204 // [Description]
2205 //
2206 // [Arguments]:
2207 //
2208 // [Return]:
2209 //
2210 //**************************************************************************
MApi_CEC_SetRetryCount(MS_U8 u8RetryCount)2211 void MApi_CEC_SetRetryCount(MS_U8 u8RetryCount)
2212 {
2213 stCEC_SET_RETRY_COUNT pCECArgs = {0};
2214
2215 pCECArgs.ucRetryCount = u8RetryCount;
2216
2217 if(pulCECInst == NULL)
2218 {
2219 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2220 }
2221 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_SET_RETRY_COUNT, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2222 {
2223 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2224 }
2225 }
2226
2227 //**************************************************************************
2228 // [Function Name]:
2229 // MApi_CEC_ConfigWakeupInfoVendorID()
2230 // [Description]
2231 //
2232 // [Arguments]:
2233 //
2234 // [Return]:
2235 //
2236 //**************************************************************************
MApi_CEC_ConfigWakeupInfoVendorID(MS_U8 * u8CecVendorID)2237 void MApi_CEC_ConfigWakeupInfoVendorID(MS_U8 *u8CecVendorID)
2238 {
2239 stCEC_CONFIG_WAKEUP_INFO_VENDOR_ID pCECArgs = {0};
2240
2241 pCECArgs.ucVendorID = u8CecVendorID;
2242
2243 if(pulCECInst == NULL)
2244 {
2245 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2246 }
2247 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_CONFIG_WAKEUP_INFO_VENDOR_ID, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2248 {
2249 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2250 }
2251 }
2252
2253 //**************************************************************************
2254 // [Function Name]:
2255 // MApi_CEC_NextDevice()
2256 // [Description]
2257 // Set logical address to next active device
2258 // [Arguments]:
2259 //
2260 // [Return]:
2261 // Next CEC active device's logical address
2262 //**************************************************************************
MApi_CEC_NextDevice(void)2263 MsCEC_DEVICELA MApi_CEC_NextDevice(void)
2264 {
2265 stCEC_NEXT_DEVICE pCECArgs = {0};
2266
2267 pCECArgs.eNextDeviceLA = E_LA_UNREGISTERED;
2268
2269 if(pulCECInst == NULL)
2270 {
2271 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2272 }
2273 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_NEXT_DEVICE, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2274 {
2275 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2276 }
2277
2278 return pCECArgs.eNextDeviceLA;
2279 }
2280
2281 //**************************************************************************
2282 // [Function Name]:
2283 // MApi_CEC_IsRxBufEmpty()
2284 // [Description]
2285 //
2286 // [Arguments]:
2287 //
2288 // [Return]:
2289 //
2290 //**************************************************************************
MApi_CEC_IsRxBufEmpty(void)2291 MS_BOOL MApi_CEC_IsRxBufEmpty(void)
2292 {
2293 stCEC_IS_RX_BUF_EMPTY pCECArgs = {0};
2294
2295 pCECArgs.bEmpty = FALSE;
2296
2297 if(pulCECInst == NULL)
2298 {
2299 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2300 }
2301 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_IS_RX_BUF_EMPTY, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2302 {
2303 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2304 }
2305
2306 return pCECArgs.bEmpty;
2307 }
2308
2309 //**************************************************************************
2310 // [Function Name]:
2311 // MApi_CEC_CheckDeviceIsTx()
2312 // [Description]
2313 //
2314 // [Arguments]:
2315 //
2316 // [Return]:
2317 //
2318 //**************************************************************************
MApi_CEC_CheckDeviceIsTx(void)2319 MS_BOOL MApi_CEC_CheckDeviceIsTx(void)
2320 {
2321 stCEC_DEVICE_IS_TX pCECArgs = {0};
2322
2323 pCECArgs.bIsTx = FALSE;
2324
2325 if(pulCECInst == NULL)
2326 {
2327 MAPI_CEC_MSG_WARNING("[%s,%5d]No instance existed, please get an instance by calling mapi_cec_initchip() first\n",__FUNCTION__,__LINE__);
2328 }
2329 else if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_CHECK_DEVICE_IS_TX, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2330 {
2331 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2332 }
2333
2334 return pCECArgs.bIsTx;
2335 }
2336
2337 //**************************************************************************
2338 // [Function Name]:
2339 // MApi_CEC_AttachDriverISR()
2340 // [Description]
2341 //
2342 // [Arguments]:
2343 //
2344 // [Return]:
2345 //
2346 //**************************************************************************
MApi_CEC_AttachDriverISR(MS_BOOL bAttachDrvFlag)2347 void MApi_CEC_AttachDriverISR(MS_BOOL bAttachDrvFlag)
2348 {
2349 MS_BOOL bInitialFlag = FALSE;
2350 stCEC_ATTACH_DRIVER_ISR pCECArgs = {0};
2351
2352 pCECArgs.bAttachDrvFlag = bAttachDrvFlag;
2353
2354 if(pulCECInst == NULL)
2355 {
2356 if(UtopiaOpen(MODULE_CEC, &pulCECInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
2357 {
2358 MAPI_CEC_MSG_ERROR("UtopiaOpen pulCECInst failed\n");
2359
2360 bInitialFlag = TRUE;
2361 }
2362 }
2363
2364 if(!bInitialFlag)
2365 {
2366 if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_ATTACH_DRIVER_ISR, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2367 {
2368 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2369 }
2370 }
2371 }
2372
2373 //**************************************************************************
2374 // [Function Name]:
2375 // MApi_CEC_Ctrl()
2376 // [Description]
2377 //
2378 // [Arguments]:
2379 //
2380 // [Return]:
2381 //
2382 //**************************************************************************
MApi_CEC_Ctrl(MS_U32 u32Cmd,void * pBuf,MS_U32 u32BufSize)2383 MS_BOOL MApi_CEC_Ctrl(MS_U32 u32Cmd, void *pBuf, MS_U32 u32BufSize)
2384 {
2385 MS_BOOL bret = FALSE;
2386
2387 switch(u32Cmd)
2388 {
2389 case E_CEC_CMD_ATTACH_DRIVER_ISR:
2390 {
2391 if(u32BufSize == sizeof(stCMD_CEC_ATTACH_DRIVER_ISR))
2392 {
2393 MApi_CEC_AttachDriverISR(((stCMD_CEC_ATTACH_DRIVER_ISR *)pBuf)->bAttachDrvFlag);
2394
2395 bret = TRUE;
2396 }
2397 }
2398 break;
2399
2400 default:
2401 pBuf = pBuf;
2402 u32BufSize = u32BufSize;
2403 bret = FALSE;
2404 break;
2405 }
2406
2407 return bret;
2408 }
2409
2410 //**************************************************************************
2411 // [Function Name]:
2412 // mapi_CEC_GetConfig()
2413 // [Description]
2414 // CEC get init config
2415 // [Arguments]:
2416 //
2417 // [Return]:
2418 //
2419 //**************************************************************************
mapi_CEC_GetConfig(stCEC_INITIAL_CONFIG * stInitialConfig)2420 MS_U32 mapi_CEC_GetConfig(stCEC_INITIAL_CONFIG *stInitialConfig)
2421 {
2422 MS_BOOL bInitialFlag = FALSE;
2423 MS_U32 ulReturnValue = UTOPIA_STATUS_ERR_NOT_AVAIL;
2424 stCEC_GET_CONFIGURATION pCECArgs;
2425
2426 pCECArgs.stInitialConfigInfo.ulReturnValue = UTOPIA_STATUS_ERR_NOT_AVAIL;
2427
2428 if(pulCECInst == NULL)
2429 {
2430 if(UtopiaOpen(MODULE_CEC, &pulCECInst, 0, NULL) != UTOPIA_STATUS_SUCCESS)
2431 {
2432 MAPI_CEC_MSG_ERROR("UtopiaOpen pulCECInst failed\n");
2433
2434 bInitialFlag = TRUE;
2435 }
2436 }
2437
2438 if(!bInitialFlag)
2439 {
2440 if(UtopiaIoctl(pulCECInst, MAPI_CMD_CEC_GET_CONFIGURATION, (void*)&pCECArgs) != UTOPIA_STATUS_SUCCESS)
2441 {
2442 MAPI_CEC_MSG_ERROR("Obtain CEC engine fail\n");
2443 }
2444 else
2445 {
2446 stInitialConfig->bAttachDrvISR = pCECArgs.stInitialConfigInfo.bAttachDrvISR;
2447 stInitialConfig->ulXTAL_CLK_Hz = pCECArgs.stInitialConfigInfo.ulXTAL_CLK_Hz;
2448
2449 ulReturnValue = pCECArgs.stInitialConfigInfo.ulReturnValue;
2450 }
2451 }
2452
2453 return ulReturnValue;
2454 }
2455
2456