xref: /utopia/UTPA2-700.0.x/modules/hdmi/api/cec/apiCEC_v2.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ///////////////////////////////////////////////////////////////////////////////////////////////////
79 ///
80 /// file    apiMHL.c
81 /// @author MStar Semiconductor Inc.
82 /// @brief  MHL driver Function
83 ///////////////////////////////////////////////////////////////////////////////////////////////////
84 
85 #ifndef _API_CEC_V2_C_
86 #define _API_CEC_V2_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 "MsOS.h"
101 #include "utopia.h"
102 #include "utopia_dapi.h"
103 #include "apiCEC_private.h"
104 #include "apiCEC.h"
105 #include "drvCEC.h"
106 
107 //-------------------------------------------------------------------------------------------------
108 //  Local Defines
109 //-------------------------------------------------------------------------------------------------
110 #if(defined(CONFIG_MLOG))
111 #include "ULog.h"
112 
113 #define MAPI_CEC_MSG_INFO(format, args...)      ULOGI("CEC", format, ##args)
114 #define MAPI_CEC_MSG_WARNING(format, args...)   ULOGW("CEC", format, ##args)
115 #define MAPI_CEC_MSG_DEBUG(format, args...)     ULOGD("CEC", format, ##args)
116 #define MAPI_CEC_MSG_ERROR(format, args...)     ULOGE("CEC", format, ##args)
117 #define MAPI_CEC_MSG_FATAL(format, args...)     ULOGF("CEC", format, ##args)
118 
119 #else
120 #define MAPI_CEC_MSG_INFO(format, args...)      printf(format, ##args)
121 #define MAPI_CEC_MSG_WARNING(format, args...)   printf(format, ##args)
122 #define MAPI_CEC_MSG_DEBUG(format, args...)     printf(format, ##args)
123 #define MAPI_CEC_MSG_ERROR(format, args...)     printf(format, ##args)
124 #define MAPI_CEC_MSG_FATAL(format, args...)     printf(format, ##args)
125 
126 #endif
127 
128 //-------------------------------------------------------------------------------------------------
129 //  Local Structures
130 //-------------------------------------------------------------------------------------------------
131 
132 //-------------------------------------------------------------------------------------------------
133 //  Global Variables
134 //-------------------------------------------------------------------------------------------------
135 
136 //-------------------------------------------------------------------------------------------------
137 //  Local Variables
138 //-------------------------------------------------------------------------------------------------
139 
140 //-------------------------------------------------------------------------------------------------
141 //  Local Functions
142 //-------------------------------------------------------------------------------------------------
143 
144 //-------------------------------------------------------------------------------------------------
145 //  Global Functions
146 //-------------------------------------------------------------------------------------------------
147 
148 //**************************************************************************
149 //  [Function Name]:
150 //                  CECOpen()
151 //  [Description]
152 //
153 //  [Arguments]:
154 //
155 //  [Return]:
156 //
157 //**************************************************************************
158 MS_U32 CECOpen(void** ppInstance, const void* const pAttribute)
159 {
160     CEC_INSTANT_PRIVATE *psCECInstPri = NULL;
161 
162     //UTOPIA_TRACE(MS_UTOPIA_DB_LEVEL_TRACE,printf("enter %s %d\n",__FUNCTION__,__LINE__));
163     // instance is allocated here, also can allocate private for internal use, ex, BDMA_INSTANT_PRIVATE
164     UtopiaInstanceCreate(sizeof(CEC_INSTANT_PRIVATE), ppInstance);
165     // setup func in private and assign the calling func in func ptr in instance private
166     UtopiaInstanceGetPrivate(*ppInstance, (void**)&psCECInstPri);
167 
168     psCECInstPri->fpDDC2BIGetInfo= (IOCTL_DDC2BI_GET_INFO)MDrv_CEC_DDC2BI_GetInfo;
169     psCECInstPri->fpCECInitChip = (IOCTL_CEC_INIT_CHIP)MDrv_CEC_InitChip;
170     psCECInstPri->fpCECPortSelect = (IOCTL_CEC_PORT_SELECT)MDrv_CEC_PortSelect;
171     psCECInstPri->fpCECExit = (IOCTL_CEC_EXIT)MDrv_CEC_Exit;
172     psCECInstPri->fpCECSetMyLogicalAddress = (IOCTL_CEC_SET_MY_LOGICAL_ADDRESS)MDrv_CEC_SetMyLogicalAddress;
173     psCECInstPri->fpCECInit = (IOCTL_CEC_INIT)MDrv_CEC_Init;
174     psCECInstPri->fpCECCheckExistDevices= (IOCTL_CEC_EXIT)MDrv_CEC_CheckExistDevices;
175     psCECInstPri->fpCECNextDevice = (IOCTL_CEC_NEXT_DEVICE)MDrv_CEC_NextDevice;
176     psCECInstPri->fpCECChkRxBuf = (IOCTL_CEC_CHK_RX_BUF)MDrv_CEC_ChkRxBuf;
177     psCECInstPri->fpCECTxSendMsg = (IOCTL_CEC_TX_SEND_MSG)MDrv_CEC_TxSendMsg;
178     psCECInstPri->fpCECTxSendMsg2 = (IOCTL_CEC_TX_SEND_MSG2)MDrv_CEC_TxSendMsg2;
179     psCECInstPri->fpCECTxSendPollingMsg = (IOCTL_CEC_TX_SEND_POLLING_MSG)MDrv_CecTxSendPollingMsg;
180     psCECInstPri->fpCECMsgActiveSource = (IOCTL_CEC_MSG_ACTIVE_SOURCE)MDrv_CEC_Msg_ActiveSource;
181     psCECInstPri->fpCECMsgRoutingChange = (IOCTL_CEC_MSG_ROUTING_CHANGE)MDrv_CEC_Msg_RoutingChange;
182     psCECInstPri->fpCECMsgReqActiveSource = (IOCTL_CEC_MSG_REQ_ACTIVE_SOURCE)MDrv_CEC_Msg_ReqActiveSource;
183     psCECInstPri->fpCECMsgSetStreamPath = (IOCTL_CEC_MSG_SET_STREAM_PATH)MDrv_CEC_Msg_SetStreamPath;
184     psCECInstPri->fpCECMsgStandby = (IOCTL_CEC_MSG_STANDBY)MDrv_CEC_Msg_Standby;
185     psCECInstPri->fpCECMsgRecordOff= (IOCTL_CEC_MSG_RECORD_OFF)MDrv_CEC_Msg_RecordOff;
186     psCECInstPri->fpCECMsgRecordOn= (IOCTL_CEC_MSG_RECORD_ON)MDrv_CEC_Msg_RecordOn;
187     psCECInstPri->fpCECMsgReportCECVersion = (IOCTL_CEC_MSG_REPORT_CEC_VERSION)MDrv_CEC_Msg_ReportCECVersion;
188     psCECInstPri->fpCECMsgReqCECVersion = (IOCTL_CEC_MSG_REQ_CEC_VERSION)MDrv_CEC_Msg_ReqCECVersion;
189     psCECInstPri->fpCECMsgReportPhycalAddress = (IOCTL_CEC_MSG_REPORT_PHYCAL_ADDRESS)MDrv_CEC_Msg_ReportPhycalAddress;
190     psCECInstPri->fpCECMsgReqPhycalAddress = (IOCTL_CEC_MSG_REQ_PHYCAL_ADDRESS)MDrv_CEC_Msg_ReqPhycalAddress;
191     psCECInstPri->fpCECMsgDeckControl = (IOCTL_CEC_MSG_DECK_CONTROL)MDrv_CEC_Msg_DeckControl;
192     psCECInstPri->fpCECMsgDecStatus = (IOCTL_CEC_MSG_DEC_STATUS)MDrv_CEC_Msg_DecStatus;
193     psCECInstPri->fpCECMsgGiveDeckStatus = (IOCTL_CEC_MSG_GIVE_DECK_STATUS)MDrv_CEC_MSg_GiveDeckStatus;
194     psCECInstPri->fpCECMsgDCPlay = (IOCTL_CEC_MSG_DC_PLAY)MDrv_CEC_MSg_DCPlay;
195     psCECInstPri->fpCECMsgReqMenuStatus = (IOCTL_CEC_MSG_REQ_MENU_STATUS)MDrv_CEC_Msg_ReqMenuStatus;
196     psCECInstPri->fpCECMsgUserCtrlPressed = (IOCTL_CEC_MSG_USER_CTRL_PRESSED)MDrv_CEC_Msg_UserCtrlPressed;
197     psCECInstPri->fpCECMsgUserCtrlReleased = (IOCTL_CEC_MSG_USER_CTRL_RELEASED)MDrv_CEC_Msg_UserCtrlReleased;
198     psCECInstPri->fpCECMsgGiveAudioStatus = (IOCTL_CEC_MSG_GIVE_AUDIO_STATUS)MDrv_CEC_Msg_GiveAudioStatus;
199     psCECInstPri->fpCECMsgReportPowerStatus = (IOCTL_CEC_MSG_REPORT_POWER_STATUS)MDrv_CEC_Msg_ReportPowerStatus;
200     psCECInstPri->fpCECMsgReqPowerStatus = (IOCTL_CEC_MSG_REQ_POWER_STATUS)MDrv_CEC_Msg_ReqPowerStatus;
201     psCECInstPri->fpCECMsgFeatureAbort = (IOCTL_CEC_MSG_FEATURE_ABORT)MDrv_CEC_Msg_FeatureAbort;
202     psCECInstPri->fpCECMsgAbort = (IOCTL_CEC_MSG_ABORT)MDrv_CEC_Msg_Abort;
203     psCECInstPri->fpCECMsgSendMenuLanguage = (IOCTL_CEC_MSG_SEND_MENU_LANGUAGE)MDrv_CEC_Msg_SendMenuLanguage;
204     psCECInstPri->fpCECMsgReqARCInitiation = (IOCTL_CEC_MSG_REQ_ARC_INITIATION)MDrv_CecMsg_ReqARCInitiation;
205     psCECInstPri->fpCECMsgReqARCTermination = (IOCTL_CEC_MSG_REQ_ARC_INITIATION)MDrv_CecMsg_ReqARCTermination;
206     psCECInstPri->fpCECMsgAudioModeReq = (IOCTL_CEC_MSG_AUDIO_MODE_REQ)MDrv_CecMsg_AudioModeReq;
207     psCECInstPri->fpCECCheckFrame = (IOCTL_CEC_CHECK_FRAME)MDrv_CEC_CheckFrame;
208     psCECInstPri->fpCECConfigWakeUp = (IOCTL_CEC_CONFIG_WAKE_UP)MDrv_CEC_ConfigWakeUp;
209     psCECInstPri->fpCECEnabled = (IOCTL_CEC_ENABLED)MDrv_CEC_Enabled;
210     psCECInstPri->fpCECGetTxStatus = (IOCTL_CEC_GET_TX_STATUS)MDrv_CEC_TxStatus;
211     psCECInstPri->fpCECDeviceIsTx = (IOCTL_CEC_DEVICE_IS_TX)MDrv_CEC_CheckDeviceIsTx;
212     psCECInstPri->fpCECSetPowerState = (IOCTL_CEC_SET_POWER_STATE)MDrv_CEC_SetPowerState;
213 #if ENABLE_CEC_MULTIPLE
214     psCECInstPri->fpCECSetMyLogicalAddress2 = (IOCTL_CEC_SET_MY_LOGICAL_ADDRESS2)MDrv_CEC_SetMyLogicalAddress2;
215     psCECInstPri->fpCECMsgReportPhycalAddress2 = (IOCTL_CEC_MSG_REPORT_PHYCAL_ADDRESS2)MDrv_CEC_Msg_ReportPhycalAddress2;
216     psCECInstPri->fpCECSetMyPhysicalAddress2= (IOCTL_CEC_SET_MY_PHYSICAL_ADDRESS2)MDrv_CEC_SetMyPhysicalAddress2;
217     psCECInstPri->fpCECSetInitiator = (IOCTL_CEC_SET_INITIATOR)MDrv_CEC_SetInitiator;
218 #endif
219     psCECInstPri->fpCECGetHeader = (IOCTL_CEC_GET_HEADER)MDrv_CEC_Get_Header;
220     psCECInstPri->fpCECGetOpCode = (IOCTL_CEC_GET_OPCODE)MDrv_CEC_Get_OpCode;
221     psCECInstPri->fpCECGetPara = (IOCTL_CEC_GET_PARA)MDrv_CEC_Get_Para;
222     psCECInstPri->fpCECGetCmdLen = (IOCTL_CEC_GET_CMD_LEN)MDrv_CEC_GetCmdLen;
223     psCECInstPri->fpCECIsRxBufEmpty = (IOCTL_CEC_IS_RX_BUF_EMPTY)MDrv_CEC_IsRxBufEmpty;
224     psCECInstPri->fpCECSetActiveLogicalAddress = (IOCTL_CEC_SET_ACTIVE_LOGICAL_ADDRESS)MDrv_CEC_SetActiveLogicalAddress;
225     psCECInstPri->fpCECGetActiveLogicalAddress = (IOCTL_CEC_GET_ACTIVE_LOGICAL_ADDRESS)MDrv_CEC_GetActiveLogicalAddress;
226     psCECInstPri->fpCECGetPowerStatus = (IOCTL_CEC_GET_POWER_STATUS)MDrv_CEC_GetPowerStatus;
227     psCECInstPri->fpCECGetFifoIdx = (IOCTL_CEC_GET_FIFO_IDX)MDrv_CEC_GetFifoIdx;
228     psCECInstPri->fpCECSetFifoIdx = (IOCTL_CEC_SET_FIFO_IDX)MDrv_CEC_SetFifoIdx;
229     psCECInstPri->fpCECSetActivePowerStatus = (IOCTL_CEC_SET_ACTIVE_POWER_STATUS)MDrv_CEC_SetActivePowerStatus;
230     psCECInstPri->fpCECGetActivePowerStatus = (IOCTL_CEC_GET_ACTIVE_POWER_STATUS)MDrv_CEC_GetActivePowerStatus;
231     psCECInstPri->fpCECSetActivePhysicalAddress = (IOCTL_CEC_SET_ACTIVE_PHYSICAL_ADDRESS)MDrv_CEC_SetActivePhysicalAddress;
232     psCECInstPri->fpCECSetActiveDeviceCECVersion = (IOCTL_CEC_SET_ACTIVE_DEVICE_CEC_VERSION)MDrv_CEC_SetActiveDeviceCECVersion;
233     psCECInstPri->fpCECSetActiveDeviceType = (IOCTL_CEC_SET_ACTIVE_DEVICE_TYPE)MDrv_CEC_SetActiveDeviceType;
234     psCECInstPri->fpCECGetMsgCnt = (IOCTL_CEC_GET_MSG_CNT)MDrv_CEC_GetMsgCnt;
235     psCECInstPri->fpCECSetMsgCnt = (IOCTL_CEC_SET_MSG_CNT)MDrv_CEC_SetMsgCnt;
236     psCECInstPri->fpCECGetRxData = (IOCTL_CEC_GET_RX_DATA)MDrv_CEC_GetRxData;
237     psCECInstPri->fpCECSetMyPhysicalAddress = (IOCTL_CEC_SET_MY_PHYSICAL_ADDRESS)MDrv_CEC_SetMyPhysicalAddress;
238     psCECInstPri->fpCECConfigWakeUpInfoVendorID = (IOCTL_CEC_CONFIG_WAKEUP_INFO_VENDOR_ID)MDrv_CEC_ConfigWakeupInfoVendorID;
239     psCECInstPri->fpCECSetRetryCount = (IOCTL_CEC_SET_RETRY_COUNT)MDrv_CEC_SetRetryCount;
240     psCECInstPri->fpCECAttachDriverISR = (IOCTL_CEC_ATTACH_DRIVER_ISR)MDrv_CEC_AttachDriverISR;
241     psCECInstPri->fpCECGetConfiguration = (IOCTL_CEC_GET_CONFIGURATION)MDrv_CEC_GetConfiguration;
242 
243     return UTOPIA_STATUS_SUCCESS;
244 }
245 
246 //**************************************************************************
247 //  [Function Name]:
248 //                  CECIoctl()
249 //  [Description]
250 //
251 //  [Arguments]:
252 //
253 //  [Return]:
254 //
255 //**************************************************************************
256 MS_U32 CECIoctl(void* pInstance, MS_U32 u32Cmd, void* pArgs)
257 {
258     void* pModule = NULL;
259     MS_U32 ulReturnValue = UTOPIA_STATUS_SUCCESS;
260     CEC_INSTANT_PRIVATE* psCECInstPri = NULL;
261 
262     UtopiaInstanceGetModule(pInstance, &pModule);
263     UtopiaInstanceGetPrivate(pInstance, (void**)&psCECInstPri);
264 
265     switch(u32Cmd)
266     {
267         case MAPI_CMD_DDC2BI_GET_INFO:
268             {
269                 pstCEC_DDC2BI_GET_INFO pCECArgs = (pstCEC_DDC2BI_GET_INFO)pArgs;
270                 pCECArgs->bGetInfo = psCECInstPri->fpDDC2BIGetInfo(pInstance, pCECArgs->eInfo);
271             }
272             break;
273 
274         case MAPI_CMD_CEC_INIT_CHIP:
275             {
276                 pstCEC_INIT_CHIP pCECArgs = (pstCEC_INIT_CHIP)pArgs;
277                 psCECInstPri->fpCECInitChip(pInstance, pCECArgs->u32XTAL_CLK_Hz);
278             }
279             break;
280 
281         case MAPI_CMD_CEC_PORT_SELECT:
282             {
283                 pstCEC_PORT_SELECT pCECArgs = (pstCEC_PORT_SELECT)pArgs;
284                 psCECInstPri->fpCECPortSelect(pInstance, pCECArgs->InputPort);
285             }
286             break;
287 
288         case MAPI_CMD_CEC_EXIT:
289             {
290                 psCECInstPri->fpCECExit(pInstance);
291             }
292             break;
293 
294         case MAPI_CMD_CEC_SET_MY_LOGICAL_ADDRESS:
295             {
296                 pstCEC_SET_MY_LOGICAL_ADDRESS pCECArgs = (pstCEC_SET_MY_LOGICAL_ADDRESS)pArgs;
297                 psCECInstPri->fpCECSetMyLogicalAddress(pInstance, pCECArgs->myLA);
298             }
299             break;
300 
301         case MAPI_CMD_CEC_INIT:
302             {
303                 pstCEC_INIT pCECArgs = (pstCEC_INIT)pArgs;
304                 psCECInstPri->fpCECInit(pInstance, pCECArgs->u32XTAL_CLK_Hz);
305             }
306             break;
307 
308         case MAPI_CMD_CEC_CHECK_EXIST_DEVICES:
309             {
310                 psCECInstPri->fpCECCheckExistDevices(pInstance);
311             }
312             break;
313 
314         case MAPI_CMD_CEC_NEXT_DEVICE:
315             {
316                 pstCEC_NEXT_DEVICE pCECArgs = (pstCEC_NEXT_DEVICE)pArgs;
317                 pCECArgs->eNextDeviceLA = psCECInstPri->fpCECNextDevice(pInstance);
318             }
319             break;
320 
321         case MAPI_CMD_CEC_CHK_RX_BUF:
322             {
323                 psCECInstPri->fpCECChkRxBuf(pInstance);
324             }
325             break;
326 
327         case MAPI_CMD_CEC_TX_SEND_MSG:
328             {
329                 pstCEC_TX_SEND_MSG pCECArgs = (pstCEC_TX_SEND_MSG)pArgs;
330                 pCECArgs->eErrorCode = psCECInstPri->fpCECTxSendMsg(pInstance, pCECArgs->eDetAddr, pCECArgs->eMsg, pCECArgs->ucCmd, pCECArgs->ucLen);
331             }
332             break;
333 
334         case MAPI_CMD_CEC_TX_SEND_MSG2:
335             {
336                 pstCEC_TX_SEND_MSG2 pCECArgs = (pstCEC_TX_SEND_MSG2)pArgs;
337                 pCECArgs->eErrorCode = psCECInstPri->fpCECTxSendMsg2(pInstance, pCECArgs->eDetAddr, pCECArgs->eMsg, pCECArgs->ucCmd, pCECArgs->ucLen);
338             }
339             break;
340 
341         case MAPI_CMD_CEC_TX_SEND_POLLING_MSG:
342             {
343                 pstCEC_TX_SEND_POLLING_MSG pCECArgs = (pstCEC_TX_SEND_POLLING_MSG)pArgs;
344                 pCECArgs->eErrorCode = psCECInstPri->fpCECTxSendPollingMsg(pInstance, pCECArgs->eDetAddr);
345             }
346             break;
347 
348         case MAPI_CMD_CEC_MSG_ACTIVE_SOURCE:
349             {
350                 pstCEC_MSG_ACTIVE_SOURCE pCECArgs = (pstCEC_MSG_ACTIVE_SOURCE)pArgs;
351                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgActiveSource(pInstance);
352             }
353             break;
354 
355         case MAPI_CMD_CEC_MSG_ROUTING_CHANGE:
356             {
357                 pstCEC_MSG_ROUTING_CHANGE pCECArgs = (pstCEC_MSG_ROUTING_CHANGE)pArgs;
358                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgRoutingChange(pInstance, pCECArgs->ucOrigAddr, pCECArgs->ucNewAddr);
359             }
360             break;
361 
362         case MAPI_CMD_CEC_MSG_REQ_ACTIVE_SOURCE:
363             {
364                 pstCEC_MSG_REQ_ACTIVE_SOURCE pCECArgs = (pstCEC_MSG_REQ_ACTIVE_SOURCE)pArgs;
365                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReqActiveSource(pInstance);
366             }
367             break;
368 
369         case MAPI_CMD_CEC_MSG_SET_STREAM_PATH:
370             {
371                 pstCEC_MSG_SET_STREAM_PATH pCECArgs = (pstCEC_MSG_SET_STREAM_PATH)pArgs;
372                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgSetStreamPath(pInstance, pCECArgs->ucNewAddr);
373             }
374             break;
375 
376         case MAPI_CMD_CEC_MSG_STANDBY:
377             {
378                 pstCEC_MSG_STANDBY pCECArgs = (pstCEC_MSG_STANDBY)pArgs;
379                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgStandby(pInstance, pCECArgs->eDetAddr);
380             }
381             break;
382 
383         case MAPI_CMD_CEC_MSG_RECORD_OFF:
384             {
385                 pstCEC_MSG_RECORD_OFF pCECArgs = (pstCEC_MSG_RECORD_OFF)pArgs;
386                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgRecordOff(pInstance, pCECArgs->eDetAddr);
387             }
388             break;
389 
390         case MAPI_CMD_CEC_MSG_RECORD_ON:
391             {
392                 pstCEC_MSG_RECORD_ON pCECArgs = (pstCEC_MSG_RECORD_ON)pArgs;
393                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgRecordOn(pInstance, pCECArgs->eDetAddr, pCECArgs->eCmd);
394             }
395             break;
396 
397         case MAPI_CMD_CEC_MSG_REPORT_CEC_VERSION:
398             {
399                 pstCEC_MSG_REPORT_CEC_VERSION pCECArgs = (pstCEC_MSG_REPORT_CEC_VERSION)pArgs;
400                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReportCECVersion(pInstance, pCECArgs->eDetAddr, pCECArgs->ucVersion);
401             }
402             break;
403 
404         case MAPI_CMD_CEC_MSG_REQ_CEC_VERSION:
405             {
406                 pstCEC_MSG_REQ_CEC_VERSION pCECArgs = (pstCEC_MSG_REQ_CEC_VERSION)pArgs;
407                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReqCECVersion(pInstance, pCECArgs->eDetAddr);
408             }
409             break;
410 
411         case MAPI_CMD_CEC_MSG_REPORT_PHYCAL_ADDRESS:
412             {
413                 pstCEC_MSG_REPORT_PHYCAL_ADDRESS pCECArgs = (pstCEC_MSG_REPORT_PHYCAL_ADDRESS)pArgs;
414                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReportPhycalAddress(pInstance);
415             }
416             break;
417 
418         case MAPI_CMD_CEC_MSG_REQ_PHYCAL_ADDRESS:
419             {
420                 pstCEC_MSG_REQ_PHYCAL_ADDRESS pCECArgs = (pstCEC_MSG_REQ_PHYCAL_ADDRESS)pArgs;
421                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReqPhycalAddress(pInstance, pCECArgs->eDetAddr);
422             }
423             break;
424 
425         case MAPI_CMD_CEC_MSG_DECK_CONTROL:
426             {
427                 pstCEC_MSG_DECK_CONTROL pCECArgs = (pstCEC_MSG_DECK_CONTROL)pArgs;
428                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgDeckControl(pInstance, pCECArgs->eDetAddr, pCECArgs->eCmd);
429             }
430             break;
431 
432         case MAPI_CMD_CEC_MSG_DEC_STATUS:
433             {
434                 pstCEC_MSG_DEC_STATUS pCECArgs = (pstCEC_MSG_DEC_STATUS)pArgs;
435                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgDecStatus(pInstance, pCECArgs->eDetAddr, pCECArgs->eCmd);
436             }
437             break;
438 
439         case MAPI_CMD_CEC_MSG_GIVE_DECK_STATUS:
440             {
441                 pstCEC_MSG_GIVE_DECK_STATUS pCECArgs = (pstCEC_MSG_GIVE_DECK_STATUS)pArgs;
442                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgGiveDeckStatus(pInstance, pCECArgs->eDetAddr, pCECArgs->eCmd);
443             }
444             break;
445 
446         case MAPI_CMD_CEC_MSG_DC_PLAY:
447             {
448                 pstCEC_MSG_DC_PLAY pCECArgs = (pstCEC_MSG_DC_PLAY)pArgs;
449                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgDCPlay(pInstance, pCECArgs->eDetAddr, pCECArgs->eCmd);
450             }
451             break;
452 
453         case MAPI_CMD_CEC_MSG_REQ_MENU_STATUS:
454             {
455                 pstCEC_MSG_REQ_MENU_STATUS pCECArgs = (pstCEC_MSG_REQ_MENU_STATUS)pArgs;
456                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReqMenuStatus(pInstance, pCECArgs->eDetAddr, pCECArgs->eCmd);
457             }
458             break;
459 
460         case MAPI_CMD_CEC_MSG_USER_CTRL_PRESSED:
461             {
462                 pstCEC_MSG_USER_CTRL_PRESSED pCECArgs = (pstCEC_MSG_USER_CTRL_PRESSED)pArgs;
463                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgUserCtrlPressed(pInstance, pCECArgs->bUserCtrlEn, pCECArgs->eDetAddr, pCECArgs->eCmd);
464             }
465             break;
466 
467         case MAPI_CMD_CEC_MSG_USER_CTRL_RELEASED:
468             {
469                 pstCEC_MSG_USER_CTRL_RELEASED pCECArgs = (pstCEC_MSG_USER_CTRL_RELEASED)pArgs;
470                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgUserCtrlReleased(pInstance, pCECArgs->eDetAddr);
471             }
472             break;
473 
474         case MAPI_CMD_CEC_MSG_GIVE_AUDIO_STATUS:
475             {
476                 pstCEC_MSG_GIVE_AUDIO_STATUS pCECArgs = (pstCEC_MSG_GIVE_AUDIO_STATUS)pArgs;
477                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgGiveAudioStatus(pInstance, pCECArgs->eDetAddr);
478             }
479             break;
480 
481         case MAPI_CMD_CEC_MSG_REPORT_POWER_STATUS:
482             {
483                 pstCEC_MSG_REPORT_POWER_STATUS pCECArgs = (pstCEC_MSG_REPORT_POWER_STATUS)pArgs;
484                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReportPowerStatus(pInstance, pCECArgs->eDetAddr);
485             }
486             break;
487 
488         case MAPI_CMD_CEC_MSG_REQ_POWER_STATUS:
489             {
490                 pstCEC_MSG_REQ_POWER_STATUS pCECArgs = (pstCEC_MSG_REQ_POWER_STATUS)pArgs;
491                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReqPowerStatus(pInstance, pCECArgs->eDetAddr);
492             }
493             break;
494 
495         case MAPI_CMD_CEC_MSG_FEATURE_ABORT:
496             {
497                 pstCEC_MSG_FEATURE_ABORT pCECArgs = (pstCEC_MSG_FEATURE_ABORT)pArgs;
498                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgFeatureAbort(pInstance, pCECArgs->eDetAddr, pCECArgs->eMsg, pCECArgs->eCmd);
499             }
500             break;
501 
502         case MAPI_CMD_CEC_MSG_ABORT:
503             {
504                 pstCEC_MSG_ABORT pCECArgs = (pstCEC_MSG_ABORT)pArgs;
505                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgAbort(pInstance, pCECArgs->eDetAddr);
506             }
507             break;
508 
509         case MAPI_CMD_CEC_MSG_SEND_MENU_LANGUAGE:
510             {
511                 pstCEC_MSG_SEND_MENU_LANGUAGE pCECArgs = (pstCEC_MSG_SEND_MENU_LANGUAGE)pArgs;
512                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgSendMenuLanguage(pInstance, pCECArgs->pu8MenulanguageCode);
513             }
514             break;
515 
516         case MAPI_CMD_CEC_MSG_REQ_ARC_INITIATION:
517             {
518                 pstCEC_MSG_REQ_ARC_INITIATION pCECArgs = (pstCEC_MSG_REQ_ARC_INITIATION)pArgs;
519                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReqARCInitiation(pInstance, pCECArgs->eDetAddr);
520             }
521             break;
522 
523         case MAPI_CMD_CEC_MSG_REQ_ARC_TERMINATION:
524             {
525                 pstCEC_MSG_REQ_ARC_TERMINATION pCECArgs = (pstCEC_MSG_REQ_ARC_TERMINATION)pArgs;
526                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReqARCTermination(pInstance, pCECArgs->eDetAddr);
527             }
528             break;
529 
530         case MAPI_CMD_CEC_MSG_AUDIO_MODE_REQ:
531             {
532                 pstCEC_MSG_AUDIO_MODE_REQ pCECArgs = (pstCEC_MSG_AUDIO_MODE_REQ)pArgs;
533                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgAudioModeReq(pInstance, pCECArgs->eDetAddr, pCECArgs->bAmpSwitch, pCECArgs->ucMyAddress);
534             }
535             break;
536 
537         case MAPI_CMD_CEC_MSG_REPORT_PHYCAL_ADDRESS2:
538             {
539                 pstCEC_MSG_REPORT_PHYCAL_ADDRESS2 pCECArgs = (pstCEC_MSG_REPORT_PHYCAL_ADDRESS2)pArgs;
540                 pCECArgs->eErrorCode = psCECInstPri->fpCECMsgReportPhycalAddress2(pInstance);
541             }
542             break;
543 
544         case MAPI_CMD_CEC_CHECK_FRAME:
545             {
546                 pstCEC_CHECK_FRAME pCECArgs = (pstCEC_CHECK_FRAME)pArgs;
547                 pCECArgs->bValid = psCECInstPri->fpCECCheckFrame(pInstance, pCECArgs->eMsgType, pCECArgs->ucLen);
548             }
549             break;
550 
551         case MAPI_CMD_CEC_CONFIG_WAKEUP:
552             {
553                 psCECInstPri->fpCECConfigWakeUp(pInstance);
554             }
555             break;
556 
557         case MAPI_CMD_CEC_ENABLED:
558             {
559                 pstCEC_ENABLED pCECArgs = (pstCEC_ENABLED)pArgs;
560                 psCECInstPri->fpCECEnabled(pInstance, pCECArgs->bEnableFlag);
561             }
562             break;
563 
564         case MAPI_CMD_CEC_GET_TX_STATUS:
565             {
566                 pstCEC_GET_TX_STATUS pCECArgs = (pstCEC_GET_TX_STATUS)pArgs;
567                 pCECArgs->ucTxStatus = psCECInstPri->fpCECGetTxStatus(pInstance);
568             }
569             break;
570 
571         case MAPI_CMD_CEC_CHECK_DEVICE_IS_TX:
572             {
573                 pstCEC_DEVICE_IS_TX pCECArgs = (pstCEC_DEVICE_IS_TX)pArgs;
574                 pCECArgs->bIsTx = psCECInstPri->fpCECDeviceIsTx(pInstance);
575             }
576             break;
577 
578         case MAPI_CMD_CEC_SET_POWER_STATE:
579             {
580                 pstCEC_SET_POWER_STATE pCECArgs = (pstCEC_SET_POWER_STATE)pArgs;
581                 pCECArgs->u32Status = psCECInstPri->fpCECSetPowerState(pInstance, pCECArgs->ePowerState);
582             }
583             break;
584 
585         case MAPI_CMD_CEC_SET_MY_LOGICAL_ADDRESS2:
586             {
587                 pstCEC_SET_MY_LOGICAL_ADDRESS2 pCECArgs = (pstCEC_SET_MY_LOGICAL_ADDRESS2)pArgs;
588                 psCECInstPri->fpCECSetMyLogicalAddress2(pInstance, pCECArgs->myLA);
589             }
590             break;
591 
592         case MAPI_CMD_CEC_GET_HEADER:
593             {
594                 pstCEC_GET_HEADER pCECArgs = (pstCEC_GET_HEADER)pArgs;
595                 pCECArgs->ucValue = psCECInstPri->fpCECGetHeader(pInstance);
596             }
597             break;
598 
599         case MAPI_CMD_CEC_GET_OPCODE:
600             {
601                 pstCEC_GET_OPCODE pCECArgs = (pstCEC_GET_OPCODE)pArgs;
602                 pCECArgs->ucValue = psCECInstPri->fpCECGetOpCode(pInstance);
603             }
604             break;
605 
606         case MAPI_CMD_CEC_GET_PARA:
607             {
608                 pstCEC_GET_PARA pCECArgs = (pstCEC_GET_PARA)pArgs;
609                 pCECArgs->ucValue = psCECInstPri->fpCECGetPara(pInstance, pCECArgs->ucIdx);
610             }
611             break;
612 
613         case MAPI_CMD_CEC_GET_CMD_LEN:
614             {
615                 pstCEC_GET_CMD_LEN pCECArgs = (pstCEC_GET_CMD_LEN)pArgs;
616                 pCECArgs->ucValue = psCECInstPri->fpCECGetCmdLen(pInstance);
617             }
618             break;
619 
620         case MAPI_CMD_CEC_IS_RX_BUF_EMPTY:
621             {
622                 pstCEC_IS_RX_BUF_EMPTY pCECArgs = (pstCEC_IS_RX_BUF_EMPTY)pArgs;
623                 pCECArgs->bEmpty = psCECInstPri->fpCECIsRxBufEmpty(pInstance);
624             }
625             break;
626 
627         case MAPI_CMD_CEC_SET_ACTIVE_LOGICAL_ADDRESS:
628             {
629                 pstCEC_SET_ACTIVE_LOGICAL_ADDRESS pCECArgs = (pstCEC_SET_ACTIVE_LOGICAL_ADDRESS)pArgs;
630                 psCECInstPri->fpCECSetActiveLogicalAddress(pInstance, pCECArgs->eAddr);
631             }
632             break;
633 
634         case MAPI_CMD_CEC_GET_ACTIVE_LOGICAL_ADDRESS:
635             {
636                 pstCEC_GET_ACTIVE_LOGICAL_ADDRESS pCECArgs = (pstCEC_GET_ACTIVE_LOGICAL_ADDRESS)pArgs;
637                 pCECArgs->eAddr = psCECInstPri->fpCECGetActiveLogicalAddress(pInstance);
638             }
639             break;
640 
641         case MAPI_CMD_CEC_GET_POWER_STATUS:
642             {
643                 pstCEC_GET_POWER_STATUS pCECArgs = (pstCEC_GET_POWER_STATUS)pArgs;
644                 pCECArgs->ePowerStatus = psCECInstPri->fpCECGetPowerStatus(pInstance);
645             }
646             break;
647 
648         case MAPI_CMD_CEC_GET_FIFO_IDX:
649             {
650                 pstCEC_GET_FIFO_IDX pCECArgs = (pstCEC_GET_FIFO_IDX)pArgs;
651                 pCECArgs->ucFifoIdx = psCECInstPri->fpCECGetFifoIdx(pInstance);
652             }
653             break;
654 
655         case MAPI_CMD_CEC_SET_FIFO_IDX:
656             {
657                 pstCEC_SET_FIFO_IDX pCECArgs = (pstCEC_SET_FIFO_IDX)pArgs;
658                 psCECInstPri->fpCECSetFifoIdx(pInstance, pCECArgs->ucIdx);
659             }
660             break;
661 
662         case MAPI_CMD_CEC_SET_ACTIVE_POWER_STATUS:
663             {
664                 pstCEC_SET_ACTIVE_POWER_STATUS pCECArgs = (pstCEC_SET_ACTIVE_POWER_STATUS)pArgs;
665                 psCECInstPri->fpCECSetActivePowerStatus(pInstance, pCECArgs->eStatus);
666             }
667             break;
668 
669         case MAPI_CMD_CEC_GET_ACTIVE_POWER_STATUS:
670             {
671                 pstCEC_GET_ACTIVE_POWER_STATUS pCECArgs = (pstCEC_GET_ACTIVE_POWER_STATUS)pArgs;
672                 pCECArgs->ePowerStatus = psCECInstPri->fpCECGetActivePowerStatus(pInstance);
673             }
674             break;
675 
676         case MAPI_CMD_CEC_SET_ACTIVE_PHYSICAL_ADDRESS:
677             {
678                 pstCEC_SET_ACTIVE_PHYSICAL_ADDRESS pCECArgs = (pstCEC_SET_ACTIVE_PHYSICAL_ADDRESS)pArgs;
679                 psCECInstPri->fpCECSetActivePhysicalAddress(pInstance, pCECArgs->ucPara1, pCECArgs->ucPara2);
680             }
681             break;
682 
683         case MAPI_CMD_CEC_SET_ACTIVE_DEVICE_CEC_VERSION:
684             {
685                 pstCEC_SET_ACTIVE_DEVICE_CEC_VERSION pCECArgs = (pstCEC_SET_ACTIVE_DEVICE_CEC_VERSION)pArgs;
686                 psCECInstPri->fpCECSetActiveDeviceCECVersion(pInstance, pCECArgs->ucVer);
687             }
688             break;
689 
690         case MAPI_CMD_CEC_SET_ACTIVE_DEVICE_TYPE:
691             {
692                 pstCEC_SET_ACTIVE_DEVICE_TYPE pCECArgs = (pstCEC_SET_ACTIVE_DEVICE_TYPE)pArgs;
693                 psCECInstPri->fpCECSetActiveDeviceType(pInstance, pCECArgs->eType);
694             }
695             break;
696 
697         case MAPI_CMD_CEC_GET_MSG_CNT:
698             {
699                 pstCEC_GET_MSG_CNT pCECArgs = (pstCEC_GET_MSG_CNT)pArgs;
700                 pCECArgs->ucMsgCnt = psCECInstPri->fpCECGetMsgCnt(pInstance);
701             }
702             break;
703 
704         case MAPI_CMD_CEC_SET_MSG_CNT:
705             {
706                 pstCEC_SET_MSG_CNT pCECArgs = (pstCEC_SET_MSG_CNT)pArgs;
707                 psCECInstPri->fpCECSetMsgCnt(pInstance, pCECArgs->ucCnt);
708             }
709             break;
710 
711         case MAPI_CMD_CEC_GET_RX_DATA:
712             {
713                 pstCEC_GET_RX_DATA pCECArgs = (pstCEC_GET_RX_DATA)pArgs;
714                 pCECArgs->ucRxData = psCECInstPri->fpCECGetRxData(pInstance, pCECArgs->ucFifoIdx, pCECArgs->ucIdx);
715             }
716             break;
717 
718         case MAPI_CMD_CEC_SET_MY_PHYSICAL_ADDRESS:
719             {
720                 pstCEC_SET_MY_PHYSICAL_ADDRESS pCECArgs = (pstCEC_SET_MY_PHYSICAL_ADDRESS)pArgs;
721                 psCECInstPri->fpCECSetMyPhysicalAddress(pInstance, pCECArgs->ucData);
722             }
723             break;
724 
725         case MAPI_CMD_CEC_SET_MY_PHYSICAL_ADDRESS2:
726             {
727                 pstCEC_SET_MY_PHYSICAL_ADDRESS2 pCECArgs = (pstCEC_SET_MY_PHYSICAL_ADDRESS2)pArgs;
728                 psCECInstPri->fpCECSetMyPhysicalAddress2(pInstance, pCECArgs->ucData);
729             }
730             break;
731 
732         case MAPI_CMD_CEC_SET_INITIATOR:
733             {
734                 pstCEC_SET_INITIATOR pCECArgs = (pstCEC_SET_INITIATOR)pArgs;
735                 psCECInstPri->fpCECSetInitiator(pInstance, pCECArgs->eIniLa);
736             }
737             break;
738 
739         case MAPI_CMD_CEC_CONFIG_WAKEUP_INFO_VENDOR_ID:
740             {
741                 pstCEC_CONFIG_WAKEUP_INFO_VENDOR_ID pCECArgs = (pstCEC_CONFIG_WAKEUP_INFO_VENDOR_ID)pArgs;
742                 psCECInstPri->fpCECConfigWakeUpInfoVendorID(pInstance, pCECArgs->ucVendorID);
743             }
744             break;
745 
746         case MAPI_CMD_CEC_SET_RETRY_COUNT:
747             {
748                 pstCEC_SET_RETRY_COUNT pCECArgs = (pstCEC_SET_RETRY_COUNT)pArgs;
749                 psCECInstPri->fpCECSetRetryCount(pInstance, pCECArgs->ucRetryCount);
750             }
751             break;
752 
753         case MAPI_CMD_CEC_ATTACH_DRIVER_ISR:
754             {
755                  pstCEC_ATTACH_DRIVER_ISR pCECArgs = (pstCEC_ATTACH_DRIVER_ISR)pArgs;
756                  psCECInstPri->fpCECAttachDriverISR(pInstance, pCECArgs->bAttachDrvFlag);
757             }
758             break;
759 
760         case MAPI_CMD_CEC_GET_CONFIGURATION:
761             {
762                 pstCEC_GET_CONFIGURATION pCECArgs = (pstCEC_GET_CONFIGURATION)pArgs;
763                 pCECArgs->stInitialConfigInfo = psCECInstPri->fpCECGetConfiguration(pInstance);
764             }
765             break;
766 
767         default:
768             ulReturnValue = UTOPIA_STATUS_FAIL;
769             break;
770     };
771 
772     return ulReturnValue;
773 }
774 
775 //**************************************************************************
776 //  [Function Name]:
777 //                  CECClose()
778 //  [Description]
779 //
780 //  [Arguments]:
781 //
782 //  [Return]:
783 //
784 //**************************************************************************
785 MS_U32 CECClose(void* pInstance)
786 {
787     UtopiaInstanceDelete(pInstance);
788 
789     return TRUE;
790 }
791 
792 //**************************************************************************
793 //  [Function Name]:
794 //                  CECSTR()
795 //  [Description]
796 //
797 //  [Arguments]:
798 //
799 //  [Return]:
800 //
801 //**************************************************************************
802 MS_U32 CECSTR(MS_U32 ulPowerState, void* pModule)
803 {
804     MS_U32 ulReturnValue = UTOPIA_STATUS_FAIL;
805 
806     ulReturnValue = mdrv_CEC_STREventProc(pModule, (EN_POWER_MODE)ulPowerState);
807 
808     return ulReturnValue;
809 }
810 
811 #ifdef CONFIG_UTOPIA_PROC_DBG_SUPPORT
812 //**************************************************************************
813 //  [Function Name]:
814 //                  CECMdbIoctl()
815 //  [Description]
816 //
817 //  [Arguments]:
818 //
819 //  [Return]:
820 //
821 //**************************************************************************
822 MS_U32 CECMdbIoctl(MS_U32 cmd, const void* const pArgs)
823 {
824     void* pInstance = NULL;
825     MS_U32 ulReturnValue = UTOPIA_STATUS_SUCCESS;
826     MDBCMD_CMDLINE_PARAMETER *paraCmdLine;
827     MDBCMD_GETINFO_PARAMETER *paraGetInfo;
828 
829     pInstance = UtopiaModuleGetLocalInstantList(MODULE_CEC, pInstance);
830 
831     switch(cmd)
832     {
833         case MDBCMD_CMDLINE:
834             paraCmdLine = (MDBCMD_CMDLINE_PARAMETER *)pArgs;
835             MdbPrint(paraCmdLine->u64ReqHdl,"u32CmdSize: %d\n", paraCmdLine->u32CmdSize);
836             mdrv_CEC_MDCMDEchoCommand(pInstance, paraCmdLine->u64ReqHdl, paraCmdLine->pcCmdLine);
837             paraCmdLine->result = MDBRESULT_SUCCESS_FIN;
838             break;
839 
840         case MDBCMD_GETINFO:
841             paraGetInfo = (MDBCMD_GETINFO_PARAMETER *)pArgs;
842             mdrv_CEC_MDCMDGetInfo(pInstance, paraGetInfo->u64ReqHdl);
843             paraGetInfo->result = MDBRESULT_SUCCESS_FIN;
844             break;
845 
846         default:
847             paraGetInfo = (MDBCMD_GETINFO_PARAMETER *)pArgs;
848             MdbPrint(paraGetInfo->u64ReqHdl,"unknown cmd\n", __LINE__);
849             break;
850     };
851 
852     return ulReturnValue;
853 }
854 #endif
855 
856 //**************************************************************************
857 //  [Function Name]:
858 //                  CECRegisterToUtopia()
859 //  [Description]
860 //
861 //  [Arguments]:
862 //
863 //  [Return]:
864 //
865 //**************************************************************************
866 void CECRegisterToUtopia(FUtopiaOpen ModuleType)
867 {
868     void* pUtopiaModule = NULL;
869     void* psResource = NULL;
870 
871     // 1. deal with module
872     UtopiaModuleCreate(MODULE_CEC, 0, &pUtopiaModule);
873     UtopiaModuleRegister(pUtopiaModule);
874     // register func for module, after register here, then ap call UtopiaOpen/UtopiaIoctl/UtopiaClose can call to these registered standard func
875     UtopiaModuleSetupFunctionPtr(pUtopiaModule, (FUtopiaOpen)CECOpen, (FUtopiaClose)CECClose, (FUtopiaIOctl)CECIoctl);
876 
877 #if(defined(MSOS_TYPE_LINUX_KERNEL))
878     UtopiaModuleSetupSTRFunctionPtr(pUtopiaModule, (FUtopiaSTR)CECSTR);
879 #endif
880 
881 #ifdef CONFIG_UTOPIA_PROC_DBG_SUPPORT
882     UtopiaModuleRegisterMdbNode("CEC", (FUtopiaMdbIoctl)CECMdbIoctl);
883 #endif
884 
885     // 2. deal with resource
886     // start func to add res, call once will create 2 access in resource. Also can declare BDMA_POOL_ID_BDMA1 for another channel depend on driver owner.
887     UtopiaModuleAddResourceStart(pUtopiaModule, CEC_POOL);
888     // resource can alloc private for internal use, ex, BDMA_RESOURCE_PRIVATE
889     UtopiaResourceCreate("CEC", sizeof(CEC_RESOURCE_PRIVATE), &psResource);
890     // func to reg res
891     UtopiaResourceRegister(pUtopiaModule, psResource, CEC_POOL);
892 
893     UtopiaModuleAddResourceEnd(pUtopiaModule, CEC_POOL);
894 }
895 
896 #endif // _API_CEC_V2_C_