1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76
77 ///////////////////////////////////////////////////////////////////////////////
78 ///
79 /// file pcmcia_wrapper.c
80 /// @brief PCMCIA wrapper for backward compatible
81 /// @author MStar Semiconductor Inc.
82 ///////////////////////////////////////////////////////////////////////////////
83
84 /*****************************************************************************/
85 /* Header Files */
86 /*****************************************************************************/
87 #include "MsCommon.h"
88 #include "utopia.h"
89 #include "drvPCMCIA.h"
90 #include "pcmcia.h"
91 #ifdef MSOS_TYPE_LINUX_KERNEL
92 #include <linux/string.h>
93 #else
94 #include <string.h>
95 #endif
96
97
98 /*****************************************************************************/
99 /* Define */
100 /*****************************************************************************/
101
102 /*****************************************************************************/
103 /* Global Variables */
104 /*****************************************************************************/
105 void* pInstant = NULL;
106 /*****************************************************************************/
107 /* Macro */
108 /*****************************************************************************/
109
110 /*****************************************************************************/
111 /* Local Variables */
112 /*****************************************************************************/
113
114 /*****************************************************************************/
115 /* Local Functions */
116 /*****************************************************************************/
117
118 /*****************************************************************************/
119 /* Global Functions */
120 /*****************************************************************************/
121
MDrv_PCMCIA_Init(MS_BOOL bCD_Reverse)122 void MDrv_PCMCIA_Init(MS_BOOL bCD_Reverse)
123 {
124 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
125 if(NULL == pInstant)
126 {
127 if(UTOPIA_STATUS_FAIL == UtopiaOpen(MODULE_CI, &pInstant, 0, NULL))
128 {
129 ULOGE("PCMCIA", "%s, open MODULE_PCMCIA failed\n", __FUNCTION__);
130 return;
131 }
132 }
133
134 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Init, &bCD_Reverse);
135 if(UTOPIA_STATUS_SUCCESS != u32Ret)
136 {
137 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
138 }
139 }
140
MDrv_PCMCIA_Exit(void)141 void MDrv_PCMCIA_Exit( void )
142 {
143 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
144 if(NULL == pInstant)
145 return;
146
147 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Exit, NULL);
148 if(UTOPIA_STATUS_SUCCESS != u32Ret)
149 {
150 ULOGE("PCMCIA", "[%s][%d]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, __LINE__, (unsigned int)u32Ret);
151 }
152
153 u32Ret = UtopiaClose(pInstant);
154 if(UTOPIA_STATUS_SUCCESS != u32Ret)
155 {
156 ULOGE("PCMCIA", "[%s][%d]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, __LINE__, (unsigned int)u32Ret);
157 }
158 pInstant = NULL;
159 }
160
MDrv_PCMCIA_DetectV2(PCMCIA_MODULE eModule)161 MS_BOOL MDrv_PCMCIA_DetectV2( PCMCIA_MODULE eModule )
162 {
163 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
164 PCM_DETECT stPcmDetect;
165
166 if(NULL == pInstant)
167 return FALSE;
168
169 stPcmDetect.eModule = eModule;
170 stPcmDetect.bDetected = FALSE;
171
172 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Detect, &stPcmDetect);
173
174 if(UTOPIA_STATUS_SUCCESS != u32Ret)
175 {
176 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
177 return FALSE;
178 }
179 else
180 {
181 return stPcmDetect.bDetected;
182 }
183 }
184
MDrv_PCMCIA_PollingV2(PCMCIA_MODULE eModule)185 MS_BOOL MDrv_PCMCIA_PollingV2( PCMCIA_MODULE eModule )
186 {
187 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
188 PCM_POLL stPcmPoll;
189
190 if(NULL == pInstant)
191 return FALSE;
192
193 stPcmPoll.eModule = eModule;
194 stPcmPoll.bChanged = FALSE;
195
196 UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Polling, &stPcmPoll);
197 if(UTOPIA_STATUS_SUCCESS != u32Ret)
198 {
199 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
200 return FALSE;
201 }
202 else
203 {
204 return stPcmPoll.bChanged;
205 }
206 }
207
MDrv_PCMCIA_Set_HW_ResetDuration(MS_U8 u8HW_ResetDuration)208 void MDrv_PCMCIA_Set_HW_ResetDuration( MS_U8 u8HW_ResetDuration )
209 {
210 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
211 if(NULL == pInstant)
212 return;
213
214 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Set_HW_ResetDuration, &u8HW_ResetDuration);
215 if(UTOPIA_STATUS_SUCCESS != u32Ret)
216 {
217 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
218 }
219 }
220
MDrv_PCMCIA_ResetHW_V2(PCMCIA_MODULE eModule)221 void MDrv_PCMCIA_ResetHW_V2( PCMCIA_MODULE eModule)
222 {
223 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
224 if(NULL == pInstant)
225 return;
226
227 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_ResetHW, &eModule);
228 if(UTOPIA_STATUS_SUCCESS != u32Ret)
229 {
230 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
231 }
232
233 }
234
MDrv_PCMCIA_WriteAttribMemV2(PCMCIA_MODULE eModule,MS_U16 u16Addr,MS_U8 u8Value)235 void MDrv_PCMCIA_WriteAttribMemV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 u8Value)
236 {
237 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
238 PCM_WRITE_ATTRIB_MEM stWrite;
239 if(NULL == pInstant)
240 return;
241
242 stWrite.eModule = eModule;
243 stWrite.u16Addr = u16Addr;
244 stWrite.u8Value = u8Value;
245 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_WriteAttribMem, &stWrite);
246 if(UTOPIA_STATUS_SUCCESS != u32Ret)
247 {
248 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
249 }
250 }
251
MDrv_PCMCIA_ReadAttribMemV2(PCMCIA_MODULE eModule,MS_U16 u16Addr,MS_U8 * pDest)252 void MDrv_PCMCIA_ReadAttribMemV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 *pDest )
253 {
254 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
255 PCM_READ_ATTRIB_MEM stRead;
256 if(NULL == pInstant)
257 return;
258
259 stRead.eModule = eModule;
260 stRead.u16Addr = u16Addr;
261 stRead.u8Data = (MS_U8)-1;
262
263 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_ReadAttribMem, &stRead);
264 if(UTOPIA_STATUS_SUCCESS != u32Ret)
265 {
266 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
267 *pDest = 0xFF;
268 }
269 else
270 {
271 *pDest = stRead.u8Data;
272 }
273 }
274
MDrv_PCMCIA_WriteIOMemV2(PCMCIA_MODULE eModule,MS_U16 u16Addr,MS_U8 u8Value)275 void MDrv_PCMCIA_WriteIOMemV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 u8Value)
276 {
277 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
278 PCM_WRITE_IO_MEM stWrite;
279 if(NULL == pInstant)
280 return;
281
282 stWrite.eModule = eModule;
283 stWrite.u16Addr = u16Addr;
284 stWrite.u8Value = u8Value;
285 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_WriteIOMem, &stWrite);
286
287 if(UTOPIA_STATUS_SUCCESS != u32Ret)
288 {
289 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
290 }
291 }
292
MDrv_PCMCIA_WriteIOMemLongV2(PCMCIA_MODULE eModule,MS_U16 u16Addr,MS_U8 u8Value,MS_U16 u16DataLen,MS_U8 * u8pWriteBuffer)293 void MDrv_PCMCIA_WriteIOMemLongV2( PCMCIA_MODULE eModule, MS_U16 u16Addr, MS_U8 u8Value, MS_U16 u16DataLen, MS_U8* u8pWriteBuffer)
294 {
295 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
296
297 PCM_WRITE_IO_MEM_LONG stWrite;
298 if(NULL == pInstant)
299 return;
300
301 stWrite.eModule = eModule;
302 stWrite.u16Addr = u16Addr;
303 stWrite.u8Value = u8Value;
304 stWrite.u16DataLen = u16DataLen;
305 stWrite.pu8WriteBuffer = u8pWriteBuffer;
306
307 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_WriteIOMemLong, &stWrite);
308 if(UTOPIA_STATUS_SUCCESS != u32Ret)
309 {
310 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
311 }
312 }
313
MDrv_PCMCIA_ReadIOMemV2(PCMCIA_MODULE eModule,MS_U16 u16Addr)314 MS_U8 MDrv_PCMCIA_ReadIOMemV2( PCMCIA_MODULE eModule, MS_U16 u16Addr )
315 {
316 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
317 PCM_READ_IO_MEM stRead;
318 if(NULL == pInstant)
319 return (MS_U8)-1;
320
321 stRead.eModule = eModule;
322 stRead.u16Addr = u16Addr;
323 stRead.u8Data = (MS_U8)-1;
324
325 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_ReadIOMem, &stRead);
326 if(UTOPIA_STATUS_SUCCESS != u32Ret)
327 {
328 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
329 return FALSE;
330 }
331 else
332 {
333 return stRead.u8Data;
334 }
335 }
336
MDrv_PCMCIA_IsModuleStillPluggedV2(PCMCIA_MODULE eModule)337 MS_BOOL MDrv_PCMCIA_IsModuleStillPluggedV2( PCMCIA_MODULE eModule )
338 {
339 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
340 PCM_MODULE_PLUGIN stPlug;
341 memset(&stPlug, 0, sizeof(PCM_MODULE_PLUGIN));
342 if(NULL == pInstant)
343 return FALSE;
344
345 stPlug.eModule = eModule;
346
347 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_IsModuleStillPlugged, &stPlug);
348 if(UTOPIA_STATUS_SUCCESS != u32Ret)
349 {
350 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
351 return FALSE;
352 }
353 else
354 {
355 return stPlug.bPlugIn;
356 }
357 }
358
MDrv_PCMCIA_Set_Detect_Trigger(MS_BOOL bHighActive)359 void MDrv_PCMCIA_Set_Detect_Trigger( MS_BOOL bHighActive )
360 {
361 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
362 if(NULL == pInstant)
363 return;
364
365 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Set_Detect_Trigger, &bHighActive);
366 if(UTOPIA_STATUS_SUCCESS != u32Ret)
367 {
368 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
369 }
370 }
371
MDrv_PCMCIA_Set_Detect_Enable(MS_BOOL bEnable)372 void MDrv_PCMCIA_Set_Detect_Enable( MS_BOOL bEnable )
373 {
374 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
375 if(NULL == pInstant)
376 return;
377
378 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Set_Detect_Enable, &bEnable);
379 if(UTOPIA_STATUS_SUCCESS != u32Ret)
380 {
381 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
382 }
383 }
384
MDrv_PCMCIA_Get_CD_IntervalV2(PCMCIA_MODULE eModule)385 MS_U32 MDrv_PCMCIA_Get_CD_IntervalV2( PCMCIA_MODULE eModule )
386 {
387 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
388
389 PCM_GET_CD_INTERVAL stInterval;
390 if(NULL == pInstant)
391 return (MS_U32)-1;
392
393 stInterval.eModule = eModule;
394 stInterval.u32Interval = (MS_U32)-1;
395
396 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Get_CD_Interval, &stInterval);
397 if(UTOPIA_STATUS_SUCCESS != u32Ret)
398 {
399 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
400 return (MS_U32)-1;
401 }
402 else
403 {
404 return stInterval.u32Interval;
405 }
406 }
407
MDrv_PCMCIA_ParseAttribMem(MS_U8 * pAttribMem,MS_U16 dwLen,PCMCIA_INFO * pInfo)408 void MDrv_PCMCIA_ParseAttribMem( MS_U8 *pAttribMem, MS_U16 dwLen, PCMCIA_INFO *pInfo )
409 {
410 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
411 PCM_PARSE_ATTRIBUTE stParse;
412 if(NULL == pInstant)
413 return;
414
415 stParse.pu8AttribMem = pAttribMem;
416 stParse.u16DwLen = dwLen;
417 stParse.pInfo = pInfo;
418 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_ParseAttribMem, &stParse);
419 if(UTOPIA_STATUS_SUCCESS != u32Ret)
420 {
421 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
422 }
423 }
424
MDrv_PCMCIA_SetCommandBitV2(PCMCIA_MODULE eModule,MS_U8 u8CommandBit,MS_BOOL bValue)425 void MDrv_PCMCIA_SetCommandBitV2( PCMCIA_MODULE eModule, MS_U8 u8CommandBit, MS_BOOL bValue )
426 {
427 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
428 PCM_SETCOMMANDBIT stCmdBit;
429 if(NULL == pInstant)
430 return;
431
432 stCmdBit.eModule = eModule;
433 stCmdBit.u8CmdBit = u8CommandBit;
434 stCmdBit.bValue = bValue;
435
436 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_SetCommandBit, &stCmdBit);
437 if(UTOPIA_STATUS_SUCCESS != u32Ret)
438 {
439 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
440 }
441 }
442
MDrv_PCMCIA_ResetInterfaceV2(PCMCIA_MODULE eModule)443 MS_BOOL MDrv_PCMCIA_ResetInterfaceV2( PCMCIA_MODULE eModule )
444 {
445 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
446 PCM_RESET_INTERFACE stRst;
447 if(NULL == pInstant)
448 return FALSE;
449
450 stRst.eModule = eModule;
451
452 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_ResetInterface, &stRst);
453 if(UTOPIA_STATUS_SUCCESS != u32Ret)
454 {
455 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
456 return FALSE;
457 }
458 else
459 {
460 return TRUE;
461 }
462 }
463
MDrv_PCMCIA_IsDataAvailableV2(PCMCIA_MODULE eModule)464 MS_BOOL MDrv_PCMCIA_IsDataAvailableV2( PCMCIA_MODULE eModule )
465 {
466 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
467 PCM_DATA_AVAILABLE stData;
468 if(NULL == pInstant)
469 return FALSE;
470
471 stData.eModule = eModule;
472 stData.bDA = FALSE;
473
474 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_IsDataAvailable, &stData);
475 if(UTOPIA_STATUS_SUCCESS != u32Ret)
476 {
477 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
478 return FALSE;
479 }
480 else
481 {
482 return stData.bDA;
483 }
484 }
485
MDrv_PCMCIA_ReadDataV2(PCMCIA_MODULE eModule,MS_U8 * u8pReadBuffer,MS_U16 u16ReadBufferSize)486 MS_U16 MDrv_PCMCIA_ReadDataV2( PCMCIA_MODULE eModule, MS_U8* u8pReadBuffer, MS_U16 u16ReadBufferSize )
487 {
488 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
489 PCM_READ_DATA stRead;
490 if(NULL == pInstant)
491 return (MS_U16)-1;
492
493 stRead.eModule = eModule;
494 stRead.pu8ReadBuffer = u8pReadBuffer;
495 stRead.u16ReadBufferSize = u16ReadBufferSize;
496 stRead.u16SizeRead = 0;
497
498 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_ReadData, &stRead);
499 if(UTOPIA_STATUS_SUCCESS != u32Ret)
500 {
501 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
502 }
503
504 return stRead.u16SizeRead;
505 }
506
MDrv_PCMCIA_WriteDataV2(PCMCIA_MODULE eModule,MS_U8 * u8pWriteBuffer,MS_U16 u16DataLen)507 MS_BOOL MDrv_PCMCIA_WriteDataV2( PCMCIA_MODULE eModule, MS_U8* u8pWriteBuffer, MS_U16 u16DataLen )
508 {
509 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
510 PCM_WRITE_DATA stWrite;
511 if(NULL == pInstant)
512 return FALSE;
513
514 stWrite.eModule = eModule;
515 stWrite.pu8WriteBuffer = u8pWriteBuffer;
516 stWrite.u16DataLen = u16DataLen;
517
518 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_WriteData, &stWrite);
519 if(UTOPIA_STATUS_SUCCESS != u32Ret)
520 {
521 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
522 return FALSE;
523 }
524 else
525 {
526 return TRUE;
527 }
528 }
529
MDrv_PCMCIA_SwitchToIOmodeV2(PCMCIA_MODULE eModule,PCMCIA_INFO * pInfo)530 MS_BOOL MDrv_PCMCIA_SwitchToIOmodeV2( PCMCIA_MODULE eModule, PCMCIA_INFO *pInfo )
531 {
532 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
533 PCM_SWITCH_TO_IOMODE stCmd;
534 if(NULL == pInstant)
535 return FALSE;
536
537 stCmd.eModule = eModule;
538 stCmd.pInfo = pInfo;
539
540 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_SwitchToIOmode, &stCmd);
541 if(UTOPIA_STATUS_SUCCESS != u32Ret)
542 {
543 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
544 return FALSE;
545 }
546 else
547 {
548 return TRUE;
549 }
550 }
551
MDrv_PCMCIA_NegotiateBufferSizeV2(PCMCIA_MODULE eModule,PCMCIA_INFO * pInfo)552 MS_U16 MDrv_PCMCIA_NegotiateBufferSizeV2( PCMCIA_MODULE eModule, PCMCIA_INFO *pInfo )
553 {
554 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
555 PCM_NETOTIAGE_BUFSIZE stArgs;
556 if(NULL == pInstant)
557 return (MS_U16)-1;
558
559 stArgs.eModule = eModule;
560 stArgs.pInfo = pInfo;
561 stArgs.u16BufSize = (MS_U16)-1;
562
563 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_NegotiateBufferSize, &stArgs);
564 if(UTOPIA_STATUS_SUCCESS != u32Ret)
565 {
566 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
567 return 0xFF;
568 }
569 else
570 {
571 return stArgs.u16BufSize;
572 }
573 }
574
MDrv_PCMCIA_WriteBufferSizeV2(PCMCIA_MODULE eModule,MS_U16 u16BufferSize)575 void MDrv_PCMCIA_WriteBufferSizeV2( PCMCIA_MODULE eModule, MS_U16 u16BufferSize )
576 {
577 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
578 PCM_WRITE_BUF_SIZE stArgs;
579 if(NULL == pInstant)
580 return;
581
582 stArgs.eModule = eModule;
583 stArgs.u16BufferSize = u16BufferSize;
584
585 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_WriteBufferSize, &stArgs);
586 if(UTOPIA_STATUS_SUCCESS != u32Ret)
587 {
588 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
589 }
590 }
591
MDrv_PCMCIA_GetLibVer(const MSIF_Version ** ppVersion)592 MS_BOOL MDrv_PCMCIA_GetLibVer( const MSIF_Version **ppVersion )
593 {
594 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
595
596 if(NULL == pInstant)
597 return FALSE;
598
599 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_GetLibVer, ppVersion);
600 if(UTOPIA_STATUS_SUCCESS != u32Ret)
601 {
602 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
603 }
604 return TRUE;
605 }
606
MDrv_PCMCIA_Enable_InterruptV2(PCMCIA_MODULE eModule,MS_BOOL bEnable)607 void MDrv_PCMCIA_Enable_InterruptV2( PCMCIA_MODULE eModule, MS_BOOL bEnable )
608 {
609 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
610 PCM_ENABLE_INT stArgs;
611 if(NULL == pInstant)
612 return;
613
614 stArgs.eModule = eModule;
615 stArgs.bEnable = bEnable;
616
617 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Enable_Interrupt, &stArgs);
618 if(UTOPIA_STATUS_SUCCESS != u32Ret)
619 {
620 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
621 }
622 }
623
MDrv_PCMCIA_Set_InterruptStatusV2(PCMCIA_MODULE eModule,MS_BOOL Status)624 void MDrv_PCMCIA_Set_InterruptStatusV2( PCMCIA_MODULE eModule, MS_BOOL Status )
625 {
626 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
627 PCM_SET_INTR_STATUS stArgs;
628 if(NULL == pInstant)
629 return;
630
631 stArgs.eModule = eModule;
632 stArgs.bStatus = Status;
633
634 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Set_InterruptStatus, &stArgs);
635 if(UTOPIA_STATUS_SUCCESS != u32Ret)
636 {
637 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
638 }
639 }
640
MDrv_PCMCIA_Get_InterruptStatusV2(PCMCIA_MODULE eModule)641 MS_BOOL MDrv_PCMCIA_Get_InterruptStatusV2( PCMCIA_MODULE eModule )
642 {
643 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
644 PCM_GET_INT_STATUS stArgs;
645 if(NULL == pInstant)
646 return FALSE;
647
648 stArgs.eModule = eModule;
649 stArgs.bIntStatus = FALSE;
650
651 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_Get_InterruptStatus, &stArgs);
652 if(UTOPIA_STATUS_SUCCESS != u32Ret)
653 {
654 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
655 return FALSE;
656 }
657 else
658 {
659 return stArgs.bIntStatus;
660 }
661 }
662
MDrv_PCMCIA_InstarllIsrCallbackV2(PCMCIA_MODULE eModule,IsrCallback fnIsrCallback)663 void MDrv_PCMCIA_InstarllIsrCallbackV2( PCMCIA_MODULE eModule, IsrCallback fnIsrCallback )
664 {
665 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
666 PCM_INSTCB stArgs;
667 if(NULL == pInstant)
668 return;
669
670 stArgs.eModule = eModule;
671 stArgs.pfcb = fnIsrCallback;
672
673 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_InstallIsrCallback, &stArgs);
674 if(UTOPIA_STATUS_SUCCESS != u32Ret)
675 {
676 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
677 }
678 }
679
MDrv_PCMCIA_WaitForStatusBitV2(PCMCIA_MODULE eModule,MS_U8 u8StatusBit)680 MS_BOOL MDrv_PCMCIA_WaitForStatusBitV2( PCMCIA_MODULE eModule, MS_U8 u8StatusBit )
681 {
682 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
683 PCM_WAIT_STATUS stArgs;
684 if(NULL == pInstant)
685 return FALSE;
686
687 stArgs.eModule = eModule;
688 stArgs.u8StatusBit = u8StatusBit;
689
690 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_WaitForStatusBit, &stArgs);
691 if(UTOPIA_STATUS_SUCCESS != u32Ret)
692 {
693 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
694 return FALSE;
695 }
696 else
697 {
698 return TRUE;
699 }
700 }
701
MDrv_PCMCIA_SetPowerState(EN_POWER_MODE u16PowerState)702 MS_U32 MDrv_PCMCIA_SetPowerState(EN_POWER_MODE u16PowerState)
703 {
704 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
705 if(NULL == pInstant)
706 return FALSE;
707
708 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_SetPowerState, (void* const)&u16PowerState);
709 if(UTOPIA_STATUS_SUCCESS != u32Ret)
710 {
711 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
712 return FALSE;
713 }
714 else
715 {
716 return TRUE;
717 }
718 }
719
MDrv_PCMCIA_GetConfig(MS_BOOL * bCD_Reverse)720 MS_BOOL MDrv_PCMCIA_GetConfig(MS_BOOL* bCD_Reverse)
721 {
722 MS_U32 u32Ret = UTOPIA_STATUS_SUCCESS;
723 if(NULL == pInstant)
724 {
725 if(UTOPIA_STATUS_FAIL == UtopiaOpen(MODULE_CI, &pInstant, 0, NULL))
726 {
727 ULOGE("PCMCIA", "%s, open MODULE_PCMCIA failed\n", __FUNCTION__);
728 return FALSE;
729 }
730 }
731
732 u32Ret = UtopiaIoctl(pInstant, E_MDRV_CMD_PCM_GetConfig, bCD_Reverse);
733 if(UTOPIA_STATUS_SUCCESS != u32Ret)
734 {
735 ULOGE("PCMCIA", "[%s]ERROR : UtopiaIoctl return value 0x%x\n", __FUNCTION__, (unsigned int)u32Ret);
736 return FALSE;
737 }
738 else
739 {
740 return TRUE;
741 }
742 }