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
81 ///////////////////////////////////////////////////////////////////////////////
82 ///
83 /// file pcmcia.c
84 /// @brief PCMCIA Driver Utopia2.0 Interface
85 /// @author MStar Semiconductor Inc.
86 ///////////////////////////////////////////////////////////////////////////////
87
88 /*****************************************************************************/
89 /* Header Files */
90 /*****************************************************************************/
91 // Common Definition
92 #include "MsTypes.h"
93 #include "utopia_dapi.h"
94 #include "utopia.h"
95 #include <stdio.h>
96 #include <string.h>
97 #include "pcmcia.h"
98 #include "pcmcia_private.h"
99
100 #include "drvPCMCIA.h"
101 #include "regPCMCIA.h"
102 #include "halPCMCIA.h"
103 #include "MsOS.h"
104 /*****************************************************************************/
105 /* Define */
106 /*****************************************************************************/
107 #define CI_DBG 0
108 /*****************************************************************************/
109 /* Global Variables */
110 /*****************************************************************************/
111 void* pModulePcm = NULL;
112 void* psResource = NULL;
113 PCMCIA_RESOURCE_PRIVATE* pPcmEnv = NULL;
114
115 #if CI_DBG
116 static const char *aCmdStr[E_MDRV_CMD_PCM_MAX] = {"E_MDRV_CMD_PCM_Init",
117 "E_MDRV_CMD_PCM_Detect",
118 "E_MDRV_CMD_PCM_Enable_Interrupt",
119 "E_MDRV_CMD_PCM_Exit",
120 "E_MDRV_CMD_PCM_Get_CD_Interval",
121 "E_MDRV_CMD_PCM_Get_InterruptStatus",
122 "E_MDRV_CMD_PCM_GetLibVer",
123 "E_MDRV_CMD_PCM_InstallIsrCallback",
124 "E_MDRV_CMD_PCM_IsDataAvailable",
125 "E_MDRV_CMD_PCM_IsModuleStillPlugged",
126 "E_MDRV_CMD_PCM_NegotiateBufferSize",
127 "E_MDRV_CMD_PCM_ParseAttribMem",
128 "E_MDRV_CMD_PCM_Polling",
129 "E_MDRV_CMD_PCM_ReadAttribMem",
130 "E_MDRV_CMD_PCM_ReadData",
131 "E_MDRV_CMD_PCM_ReadIOMem",
132 "E_MDRV_CMD_PCM_ResetHW",
133 "E_MDRV_CMD_PCM_ResetInterface",
134 "E_MDRV_CMD_PCM_Set_Detect_Enable",
135 "E_MDRV_CMD_PCM_Set_Detect_Trigger",
136 "E_MDRV_CMD_PCM_Set_HW_ResetDuration",
137 "E_MDRV_CMD_PCM_Set_InterruptStatus",
138 "E_MDRV_CMD_PCM_SetCommandBit",
139 "E_MDRV_CMD_PCM_SwitchToIOmode",
140 "E_MDRV_CMD_PCM_WaitForStatusBit",
141 "E_MDRV_CMD_PCM_WriteAttribMem",
142 "E_MDRV_CMD_PCM_WriteBufferSize",
143 "E_MDRV_CMD_PCM_WriteData",
144 "E_MDRV_CMD_PCM_WriteIOMem",
145 "E_MDRV_CMD_PCM_WriteIOMemLong",
146 "E_MDRV_CMD_PCM_SetPowerState"};
147 #endif
148 /*****************************************************************************/
149 /* Macro */
150 /*****************************************************************************/
151 #define PCM_ASSERT_RETURN(x, y) if(!(x)) {ULOGE("PCMCIA", "Assert Fail : %s, %d\n", __FUNCTION__, __LINE__); return y;}
152
153 #if CI_DBG
154 #define PCM_PRINT(x, a...) ULOGD("PCMCIA", x, ##a)
155 #else
156 #define PCM_PRINT(x, a...)
157 #endif
158
159 /*****************************************************************************/
160 /* Local Variables */
161 /*****************************************************************************/
162
163 /*****************************************************************************/
164 /* Local Functions */
165 /*****************************************************************************/
166
CIRegisterToUtopia(FUtopiaOpen ModuleType)167 void CIRegisterToUtopia(FUtopiaOpen ModuleType)
168 {
169 PCMCIA_RESOURCE_PRIVATE * pResPri = NULL;
170
171 // 1. deal with module
172 if(UtopiaModuleCreate(MODULE_CI, 8, &pModulePcm) == UTOPIA_STATUS_FAIL)
173 {
174 ULOGE("PCMCIA", "[%s] create module CI failed\n", __FUNCTION__);
175 return;
176 }
177
178 UtopiaModuleRegister(pModulePcm);
179 UtopiaModuleSetupFunctionPtr(pModulePcm, (FUtopiaOpen)PCMCIAOpen, (FUtopiaClose)PCMCIAClose, (FUtopiaIOctl)PCMCIAIoctl);
180
181 // 2. deal with resource
182 psResource = NULL;
183
184 if(UtopiaResourceCreate("PCMCIA", sizeof(PCMCIA_RESOURCE_PRIVATE), &psResource) == UTOPIA_STATUS_FAIL)
185 {
186 ULOGE("PCMCIA", "[%s] create resource CI failed\n", __FUNCTION__);
187 }
188 UtopiaResourceRegister(pModulePcm, psResource, E_PCMCIA_RESOURCE);
189
190 UtopiaModuleAddResourceEnd(pModulePcm, E_PCMCIA_RESOURCE);
191
192 if(UtopiaResourceObtain(pModulePcm, E_PCMCIA_RESOURCE, &psResource) == UTOPIA_STATUS_FAIL)
193 {
194 ULOGE("PCMCIA", "[%s][%d]UtopiaResourceObtain PCMCIA fail\n", __FUNCTION__, __LINE__);
195 return;
196 }
197
198 UtopiaResourceGetPrivate(psResource, (void**)&pResPri);
199 pPcmEnv = pResPri;
200 if(pResPri->u32Magic != MAGIC_NUM)
201 {
202 // not regiser yet
203 pResPri->u32Magic = MAGIC_NUM;
204 pResPri->bInited_Drv = FALSE;
205
206 pResPri->u8PCMCIACurModule = PCMCIA_DEFAULT_MODULE;
207 }
208
209 UtopiaResourceRelease(psResource);
210 }
211
212
PCMCIAOpen(void ** ppInstantTmp,const void * const pAttribute)213 MS_U32 PCMCIAOpen(void** ppInstantTmp, const void* const pAttribute)
214 {
215 //UTOPIA_TRACE(MS_UTOPIA_DB_LEVEL_TRACE,ULOGD("PCMCIA", "enter %s %d\n",__FUNCTION__,__LINE__));
216 void** ppInstant = ppInstantTmp;
217 UtopiaInstanceCreate(sizeof(PCMCIA_INSTANT_PRIVATE), ppInstant);
218
219 //PCMCIA_INSTANT_PRIVATE* psPcmInstPri = (PCMCIA_INSTANT_PRIVATE*)UtopiaInstantGetPrivate(*pInstant);
220
221
222 //UTOPIA_TRACE(MS_UTOPIA_DB_LEVEL_TRACE,ULOGD("PCMCIA", "leave %s %d\n",__FUNCTION__,__LINE__));
223 return UTOPIA_STATUS_SUCCESS;
224 }
225
PCMCIAIoctl(void * pInstantTmp,MS_U32 u32Cmd,void * const pu32Args)226 MS_U32 PCMCIAIoctl(void* pInstantTmp, MS_U32 u32Cmd, void* const pu32Args)
227 {
228 PCMCIA_MODULE eMod = PCMCIA_DEFAULT_MODULE;
229 MS_U32 u32Ret = UTOPIA_STATUS_FAIL;
230 //psResource = NULL;
231 PCMCIA_RESOURCE_PRIVATE * pResPri = NULL;
232
233 PCM_ASSERT_RETURN(u32Cmd < E_MDRV_CMD_PCM_MAX, UTOPIA_STATUS_FAIL);
234 #if CI_DBG
235 PCM_PRINT("%s cmd : %s\n", __FUNCTION__, aCmdStr[u32Cmd]);
236 #endif
237
238 //UtopiaResourceObtain(pModulePcm, E_PCMCIA_RESOURCE, &psResource);
239 PCM_ASSERT_RETURN((psResource != NULL), UTOPIA_STATUS_FAIL);
240
241 UtopiaResourceGetPrivate(psResource, (void**)&pResPri);
242
243 switch(u32Cmd)
244 {
245 case E_MDRV_CMD_PCM_Init:
246 {
247 if(pu32Args == NULL)
248 break;
249
250 MS_BOOL bActiveLevel = *(MS_BOOL*)pu32Args;
251 _MDrv_PCMCIA_InitSW(bActiveLevel);
252 pResPri->bCD_Reverse = bActiveLevel;
253 if(pResPri->bInited_Drv == FALSE)
254 {
255 _MDrv_PCMCIA_InitHW(FALSE);
256 pResPri->bInited_Drv = TRUE;
257 }
258 u32Ret = UTOPIA_STATUS_SUCCESS;
259 }
260 break;
261
262 case E_MDRV_CMD_PCM_Detect:
263 {
264 if(pu32Args == NULL)
265 break;
266
267 PCM_DETECT* pDetect = (PCM_DETECT*)pu32Args;
268 pDetect->bDetected = (MS_BOOL)_MDrv_PCMCIA_DetectV2(pDetect->eModule);
269 u32Ret = UTOPIA_STATUS_SUCCESS;
270 }
271 break;
272
273 case E_MDRV_CMD_PCM_Enable_Interrupt:
274 {
275 if(pu32Args == NULL)
276 break;
277
278 PCM_ENABLE_INT* pstEnableInt = (PCM_ENABLE_INT*)pu32Args;
279 _MDrv_PCMCIA_Enable_InterruptV2(pstEnableInt->eModule,
280 pstEnableInt->bEnable);
281 u32Ret = UTOPIA_STATUS_SUCCESS;
282 }
283 break;
284 case E_MDRV_CMD_PCM_Exit:
285 _MDrv_PCMCIA_Exit(FALSE);
286 pResPri->bInited_Drv = FALSE;
287 u32Ret = UTOPIA_STATUS_SUCCESS;
288 break;
289 case E_MDRV_CMD_PCM_Get_CD_Interval:
290 {
291 if(pu32Args == NULL)
292 break;
293
294 PCM_GET_CD_INTERVAL* pstCDInterval = (PCM_GET_CD_INTERVAL*)pu32Args;
295 pstCDInterval->u32Interval = _MDrv_PCMCIA_Get_CD_IntervalV2(pstCDInterval->eModule);
296 u32Ret = UTOPIA_STATUS_SUCCESS;
297 }
298 break;
299 case E_MDRV_CMD_PCM_Get_InterruptStatus:
300 {
301 if(pu32Args == NULL)
302 break;
303
304 PCM_GET_INT_STATUS* pstIntStatus = (PCM_GET_INT_STATUS*)pu32Args;
305 pstIntStatus->bIntStatus = _MDrv_PCMCIA_Get_InterruptStatusV2(pstIntStatus->eModule);
306 u32Ret = UTOPIA_STATUS_SUCCESS;
307 }
308 break;
309 case E_MDRV_CMD_PCM_GetLibVer:
310 {
311 if(pu32Args == NULL)
312 break;
313
314 const MSIF_Version** ppVersion = (const MSIF_Version**)pu32Args;
315 if(_MDrv_PCMCIA_GetLibVer(ppVersion) == TRUE)
316 {
317 u32Ret = UTOPIA_STATUS_SUCCESS;
318 }
319 else
320 {
321 u32Ret = UTOPIA_STATUS_FAIL;
322 }
323 }
324 break;
325
326 case E_MDRV_CMD_PCM_InstallIsrCallback:
327 {
328 if(pu32Args == NULL)
329 break;
330
331 PCM_INSTCB *pstInstCB = (PCM_INSTCB*)pu32Args;
332 _MDrv_PCMCIA_InstarllIsrCallbackV2(pstInstCB->eModule,
333 pstInstCB->pfcb);
334 u32Ret = UTOPIA_STATUS_SUCCESS;
335 }
336 break;
337
338 case E_MDRV_CMD_PCM_IsDataAvailable:
339 {
340 if(pu32Args == NULL)
341 break;
342
343 PCM_DATA_AVAILABLE* pstAvailable = (PCM_DATA_AVAILABLE*)pu32Args;
344 pstAvailable->bDA = _MDrv_PCMCIA_IsDataAvailableV2(pstAvailable->eModule);
345 u32Ret = UTOPIA_STATUS_SUCCESS;
346 }
347 break;
348 case E_MDRV_CMD_PCM_IsModuleStillPlugged:
349 {
350 if(pu32Args == NULL)
351 break;
352
353 PCM_MODULE_PLUGIN* pstPlugIn = (PCM_MODULE_PLUGIN*)pu32Args;
354 pstPlugIn->bPlugIn = (MS_U32)_MDrv_PCMCIA_IsModuleStillPluggedV2(pstPlugIn->eModule);
355 u32Ret = UTOPIA_STATUS_SUCCESS;
356 }
357 break;
358 case E_MDRV_CMD_PCM_NegotiateBufferSize:
359 {
360 if(pu32Args == NULL)
361 break;
362
363 PCM_NETOTIAGE_BUFSIZE* pstNegoBufSize = (PCM_NETOTIAGE_BUFSIZE*)pu32Args;
364 pstNegoBufSize->u16BufSize = _MDrv_PCMCIA_NegotiateBufferSizeV2(pstNegoBufSize->eModule,
365 pstNegoBufSize->pInfo);
366 u32Ret = UTOPIA_STATUS_SUCCESS;
367 }
368 break;
369 case E_MDRV_CMD_PCM_ParseAttribMem:
370 {
371 if(pu32Args == NULL)
372 break;
373
374 PCM_PARSE_ATTRIBUTE* pstParseAttrib = (PCM_PARSE_ATTRIBUTE*)pu32Args;
375 _MDrv_PCMCIA_ParseAttribMem(pstParseAttrib->pu8AttribMem,
376 pstParseAttrib->u16DwLen,
377 pstParseAttrib->pInfo);
378 u32Ret = UTOPIA_STATUS_SUCCESS;
379 }
380 break;
381 case E_MDRV_CMD_PCM_Polling:
382 {
383 if(pu32Args == NULL)
384 break;
385
386 PCM_POLL* pstPoll = (PCM_POLL*)pu32Args;
387 pstPoll->bChanged = _MDrv_PCMCIA_PollingV2(pstPoll->eModule);
388 u32Ret = UTOPIA_STATUS_SUCCESS;
389 }
390 break;
391
392 case E_MDRV_CMD_PCM_ReadAttribMem:
393 {
394 if(pu32Args == NULL)
395 break;
396
397 PCM_READ_ATTRIB_MEM* pstRead = (PCM_READ_ATTRIB_MEM*)pu32Args;
398 _MDrv_PCMCIA_ReadAttribMemV2(pstRead->eModule, pstRead->u16Addr, &pstRead->u8Data);
399 u32Ret = UTOPIA_STATUS_SUCCESS;
400 }
401 break;
402
403 case E_MDRV_CMD_PCM_ReadData:
404 {
405 if(pu32Args == NULL)
406 break;
407
408 PCM_READ_DATA* pstRead = (PCM_READ_DATA*)pu32Args;
409 pstRead->u16SizeRead = (MS_U32)_MDrv_PCMCIA_ReadDataV2(pstRead->eModule,
410 pstRead->pu8ReadBuffer,
411 pstRead->u16ReadBufferSize);
412 u32Ret = UTOPIA_STATUS_SUCCESS;
413 }
414 break;
415 case E_MDRV_CMD_PCM_ReadIOMem:
416 {
417 if(pu32Args == NULL)
418 break;
419
420 PCM_READ_IO_MEM* pstReadIO = (PCM_READ_IO_MEM*)pu32Args;
421 pstReadIO->u8Data = (MS_U8)_MDrv_PCMCIA_ReadIOMemV2(pstReadIO->eModule,
422 pstReadIO->u16Addr);
423 u32Ret = UTOPIA_STATUS_SUCCESS;
424 }
425 break;
426 case E_MDRV_CMD_PCM_ResetHW:
427 if(pu32Args == NULL)
428 break;
429
430 eMod = *(PCMCIA_MODULE*)pu32Args;
431 _MDrv_PCMCIA_ResetHW_V2(eMod);
432 u32Ret = UTOPIA_STATUS_SUCCESS;
433 break;
434
435 case E_MDRV_CMD_PCM_ResetInterface:
436 {
437 if(pu32Args == NULL)
438 break;
439
440 PCM_RESET_INTERFACE* pstReset = (PCM_RESET_INTERFACE*)pu32Args;
441
442 if(TRUE == _MDrv_PCMCIA_ResetInterfaceV2(pstReset->eModule))
443 {
444 u32Ret = UTOPIA_STATUS_SUCCESS;
445 }
446 }
447 break;
448 case E_MDRV_CMD_PCM_Set_Detect_Enable:
449 {
450 if(pu32Args == NULL)
451 break;
452
453 MS_BOOL bEnable = *(MS_BOOL*)pu32Args;
454 _MDrv_PCMCIA_Set_Detect_Enable(bEnable);
455 u32Ret = UTOPIA_STATUS_SUCCESS;
456 }
457 break;
458 case E_MDRV_CMD_PCM_Set_Detect_Trigger:
459 {
460 if(pu32Args == NULL)
461 break;
462
463 MS_BOOL bHighActive = *(MS_BOOL*)pu32Args;
464 _MDrv_PCMCIA_Set_Detect_Trigger(bHighActive);
465 u32Ret = UTOPIA_STATUS_SUCCESS;
466 }
467 break;
468 case E_MDRV_CMD_PCM_Set_HW_ResetDuration:
469 {
470 if(pu32Args == NULL)
471 break;
472
473 MS_U8 u8Duration = *(MS_U8*)pu32Args;
474 _MDrv_PCMCIA_Set_HW_ResetDuration(u8Duration);
475 u32Ret = UTOPIA_STATUS_SUCCESS;
476 }
477 break;
478 case E_MDRV_CMD_PCM_Set_InterruptStatus:
479 {
480 if(pu32Args == NULL)
481 break;
482
483 PCM_SET_INTR_STATUS* pstStatus = (PCM_SET_INTR_STATUS*)pu32Args;
484 _MDrv_PCMCIA_Set_InterruptStatusV2(pstStatus->eModule,
485 pstStatus->bStatus);
486 u32Ret = UTOPIA_STATUS_SUCCESS;
487 }
488 break;
489 case E_MDRV_CMD_PCM_SetCommandBit:
490 {
491 if(pu32Args == NULL)
492 break;
493
494 PCM_SETCOMMANDBIT* pstSetCmdBit = (PCM_SETCOMMANDBIT*)pu32Args;
495 _MDrv_PCMCIA_SetCommandBitV2(pstSetCmdBit->eModule,
496 pstSetCmdBit->u8CmdBit,
497 pstSetCmdBit->bValue);
498 u32Ret = UTOPIA_STATUS_SUCCESS;
499 }
500 break;
501 case E_MDRV_CMD_PCM_SwitchToIOmode:
502 {
503 if(pu32Args == NULL)
504 break;
505
506 PCM_SWITCH_TO_IOMODE* pstSwitchIOMode = (PCM_SWITCH_TO_IOMODE*)pu32Args;
507 if(TRUE == _MDrv_PCMCIA_SwitchToIOmodeV2(pstSwitchIOMode->eModule,
508 pstSwitchIOMode->pInfo))
509 {
510 u32Ret = UTOPIA_STATUS_SUCCESS;
511 }
512 }
513 break;
514 case E_MDRV_CMD_PCM_WaitForStatusBit:
515 {
516 if(pu32Args == NULL)
517 break;
518
519 PCM_WAIT_STATUS* pstWaitStatus = (PCM_WAIT_STATUS*)pu32Args;
520 if(TRUE == _MDrv_PCMCIA_WaitForStatusBitV2(pstWaitStatus->eModule,
521 pstWaitStatus->u8StatusBit))
522 {
523 u32Ret = UTOPIA_STATUS_SUCCESS;
524 }
525 }
526 break;
527 case E_MDRV_CMD_PCM_WriteAttribMem:
528 {
529 if(pu32Args == NULL)
530 break;
531
532 PCM_WRITE_ATTRIB_MEM* pstWrite = (PCM_WRITE_ATTRIB_MEM*)pu32Args;
533 _MDrv_PCMCIA_WriteAttribMemV2(pstWrite->eModule,
534 pstWrite->u16Addr,
535 pstWrite->u8Value);
536 u32Ret = UTOPIA_STATUS_SUCCESS;
537 }
538 break;
539 case E_MDRV_CMD_PCM_WriteBufferSize:
540 {
541 if(pu32Args == NULL)
542 break;
543
544 PCM_WRITE_BUF_SIZE* pstBufSize = (PCM_WRITE_BUF_SIZE*)pu32Args;
545 _MDrv_PCMCIA_WriteBufferSizeV2(pstBufSize->eModule,
546 pstBufSize->u16BufferSize);
547 u32Ret = UTOPIA_STATUS_SUCCESS;
548 }
549 break;
550 case E_MDRV_CMD_PCM_WriteData:
551 {
552 if(pu32Args == NULL)
553 break;
554
555 PCM_WRITE_DATA* pstWriteData = (PCM_WRITE_DATA*)pu32Args;
556 if(TRUE == _MDrv_PCMCIA_WriteDataV2(pstWriteData->eModule,
557 pstWriteData->pu8WriteBuffer,
558 pstWriteData->u16DataLen))
559 {
560 u32Ret = UTOPIA_STATUS_SUCCESS;
561 }
562 }
563 break;
564 case E_MDRV_CMD_PCM_WriteIOMem:
565 {
566 if(pu32Args == NULL)
567 break;
568
569 PCM_WRITE_IO_MEM* pstWriteIO = (PCM_WRITE_IO_MEM*)pu32Args;
570 _MDrv_PCMCIA_WriteIOMemV2(pstWriteIO->eModule,
571 pstWriteIO->u16Addr,
572 pstWriteIO->u8Value);
573 u32Ret = UTOPIA_STATUS_SUCCESS;
574 }
575 break;
576 case E_MDRV_CMD_PCM_WriteIOMemLong:
577 {
578 if(pu32Args == NULL)
579 break;
580
581 PCM_WRITE_IO_MEM_LONG* pstWriteIOLong = (PCM_WRITE_IO_MEM_LONG*)pu32Args;
582 _MDrv_PCMCIA_WriteIOMemLongV2(pstWriteIOLong->eModule,
583 pstWriteIOLong->u16Addr,
584 pstWriteIOLong->u8Value,
585 pstWriteIOLong->u16DataLen,
586 pstWriteIOLong->pu8WriteBuffer);
587 u32Ret = UTOPIA_STATUS_SUCCESS;
588 }
589 break;
590 case E_MDRV_CMD_PCM_SetPowerState:
591 {
592 if(pu32Args == NULL)
593 break;
594
595 _MDrv_PCMCIA_SetPowerState(*(EN_POWER_MODE*)pu32Args);
596 u32Ret = UTOPIA_STATUS_SUCCESS;
597 }
598 break;
599 case E_MDRV_CMD_PCM_GetConfig:
600 {
601 if(pu32Args == NULL)
602 break;
603
604 if(pResPri->bInited_Drv == TRUE)
605 {
606 *(MS_BOOL*)pu32Args = pResPri->bCD_Reverse;
607 u32Ret = UTOPIA_STATUS_SUCCESS;
608 }
609 }
610 break;
611 default :
612 ULOGE("PCMCIA", "[PCMCIA] unknown IOCTL 0x%x\n", (int)u32Cmd);
613 break;
614 }
615
616 //UtopiaResourceRelease(psResource);
617 return u32Ret;
618 }
619
PCMCIAClose(void * pInstant)620 MS_U32 PCMCIAClose(void* pInstant)
621 {
622 if(pInstant == NULL)
623 {
624 return UTOPIA_STATUS_FAIL;
625 }
626 else
627 {
628 UtopiaInstanceDelete(pInstant);
629 return UTOPIA_STATUS_SUCCESS;
630 }
631 }
632
633