xref: /utopia/UTPA2-700.0.x/modules/msos/utopia_core/utopia_dapi.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1*53ee8cc1Swenshuai.xi #ifndef _UTOPIA_DAPI_H_
2*53ee8cc1Swenshuai.xi #define _UTOPIA_DAPI_H_
3*53ee8cc1Swenshuai.xi 
4*53ee8cc1Swenshuai.xi #include "MsTypes.h"
5*53ee8cc1Swenshuai.xi /* driver owners need not include this explicitly */
6*53ee8cc1Swenshuai.xi #include "utopia_driver_id.h"
7*53ee8cc1Swenshuai.xi #include "MsCommon.h"
8*53ee8cc1Swenshuai.xi 
9*53ee8cc1Swenshuai.xi /*
10*53ee8cc1Swenshuai.xi  * for develop: block on error
11*53ee8cc1Swenshuai.xi  * for ut: don't block on error
12*53ee8cc1Swenshuai.xi  */
13*53ee8cc1Swenshuai.xi #define BLOCK_ON_ERROR 1
14*53ee8cc1Swenshuai.xi #if BLOCK_ON_ERROR
15*53ee8cc1Swenshuai.xi #define RET_OR_BLOCK(ret) MS_PANIC(0); return ret; /* fix compiling warning */
16*53ee8cc1Swenshuai.xi #else
17*53ee8cc1Swenshuai.xi #define RET_OR_BLOCK(ret) return ret
18*53ee8cc1Swenshuai.xi #endif
19*53ee8cc1Swenshuai.xi 
20*53ee8cc1Swenshuai.xi /* print method */
21*53ee8cc1Swenshuai.xi #if defined(ANDROID)
22*53ee8cc1Swenshuai.xi #include <cutils/log.h>
23*53ee8cc1Swenshuai.xi #define printu ALOGI
24*53ee8cc1Swenshuai.xi #elif defined(MSOS_TYPE_LINUX_KERNEL)
25*53ee8cc1Swenshuai.xi #define printu printk
26*53ee8cc1Swenshuai.xi #else
27*53ee8cc1Swenshuai.xi #define printu printf
28*53ee8cc1Swenshuai.xi #endif
29*53ee8cc1Swenshuai.xi 
30*53ee8cc1Swenshuai.xi /*
31*53ee8cc1Swenshuai.xi  * type converter
32*53ee8cc1Swenshuai.xi  */
33*53ee8cc1Swenshuai.xi #define TO_MODULE_PTR(pTmp) ((UTOPIA_MODULE*)pTmp)
34*53ee8cc1Swenshuai.xi #define TO_MODULE_SHM_PTR(pTmp) ((UTOPIA_MODULE_SHM*)pTmp)
35*53ee8cc1Swenshuai.xi // FIXME: this macro doesn't consider synchronization problem, just for tmp use
36*53ee8cc1Swenshuai.xi #define MODULE_PTR_TO_RPOOL_PTR(pModule) \
37*53ee8cc1Swenshuai.xi 	((UTOPIA_RESOURCE_POOL*)shmid2va(pModule->psModuleShm->shmid_rpool_head.ID))
38*53ee8cc1Swenshuai.xi 
39*53ee8cc1Swenshuai.xi #define TO_RESOURCE_PTR(pTmp) ((UTOPIA_RESOURCE*)pTmp)
40*53ee8cc1Swenshuai.xi // FIXME: this macro doesn't consider synchronization problem, just for tmp use
41*53ee8cc1Swenshuai.xi #define RESOURCE_PTR_TO_RPOOL_PTR(pResource) \
42*53ee8cc1Swenshuai.xi 	((UTOPIA_RESOURCE_POOL*)shmid2va(pResource->shmid_rpool.ID))
43*53ee8cc1Swenshuai.xi 
44*53ee8cc1Swenshuai.xi #define TO_INSTANCE_PTR(pTmp) ((UTOPIA_INSTANCE*)pTmp)
45*53ee8cc1Swenshuai.xi #define TO_RPOOL_PTR(pTmp) ((UTOPIA_RESOURCE_POOL*)pTmp)
46*53ee8cc1Swenshuai.xi 
47*53ee8cc1Swenshuai.xi 
48*53ee8cc1Swenshuai.xi typedef enum{
49*53ee8cc1Swenshuai.xi     CMD_USIGNAL_PROCESS_KILL =(int) 0xFFFF0001,
50*53ee8cc1Swenshuai.xi }UTOPIA_SYSYEM_IOCTL;
51*53ee8cc1Swenshuai.xi 
52*53ee8cc1Swenshuai.xi typedef enum{
53*53ee8cc1Swenshuai.xi     MDBCMD_CMDLINE = 0x0,
54*53ee8cc1Swenshuai.xi     MDBCMD_GETINFO
55*53ee8cc1Swenshuai.xi }UTOPIA_MDBCMD;
56*53ee8cc1Swenshuai.xi 
57*53ee8cc1Swenshuai.xi typedef enum{
58*53ee8cc1Swenshuai.xi     MDBRESULT_SUCCESS_FIN = 0x0,
59*53ee8cc1Swenshuai.xi     MDBRESULT_SUCCESS_NOT_FIN,
60*53ee8cc1Swenshuai.xi     MDBRESULT_NOT_AVALIBALE
61*53ee8cc1Swenshuai.xi }UTOPIA_MDBRESULT;
62*53ee8cc1Swenshuai.xi 
63*53ee8cc1Swenshuai.xi #define MDB_NODE_NAME_MAX 32
64*53ee8cc1Swenshuai.xi #define MDB_CMDLINE_MAX 255
65*53ee8cc1Swenshuai.xi #define MDB_FPIOCTL_LIST_MAX 128
66*53ee8cc1Swenshuai.xi typedef struct
67*53ee8cc1Swenshuai.xi {
68*53ee8cc1Swenshuai.xi     MS_U64* u64ReqHdl;
69*53ee8cc1Swenshuai.xi     MS_U32 u32CmdSize;
70*53ee8cc1Swenshuai.xi     char pcCmdLine[MDB_CMDLINE_MAX];
71*53ee8cc1Swenshuai.xi     UTOPIA_MDBRESULT result;
72*53ee8cc1Swenshuai.xi } MDBCMD_CMDLINE_PARAMETER;
73*53ee8cc1Swenshuai.xi 
74*53ee8cc1Swenshuai.xi typedef struct
75*53ee8cc1Swenshuai.xi {
76*53ee8cc1Swenshuai.xi     MS_U64* u64ReqHdl;
77*53ee8cc1Swenshuai.xi     UTOPIA_MDBRESULT result;
78*53ee8cc1Swenshuai.xi } MDBCMD_GETINFO_PARAMETER;
79*53ee8cc1Swenshuai.xi 
80*53ee8cc1Swenshuai.xi /*
81*53ee8cc1Swenshuai.xi  * instance functions
82*53ee8cc1Swenshuai.xi  */
83*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceCreate(MS_U32 u32PrivateSize, void** ppInstance);
84*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceDelete(void* pInstant);
85*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceGetPrivate(void* pInstance, void** ppPrivate);
86*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceGetModule(void* pInstance, void** ppModule);
87*53ee8cc1Swenshuai.xi /* We hope, we can support poly, ex: JPD and JPD3D as different Module */
88*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceGetModuleID(void* pInstance, MS_U32* pu32ModuleID);
89*53ee8cc1Swenshuai.xi /* We hope, we can support poly, ex: JPD and JPD3D as different Module */
90*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceGetModuleVersion(void* pInstant, MS_U32* pu32Version);
91*53ee8cc1Swenshuai.xi /* We hope we can support interface version mantain */
92*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceGetAppRequiredModuleVersion(void* pInstance,
93*53ee8cc1Swenshuai.xi 		MS_U32* pu32ModuleVersion);
94*53ee8cc1Swenshuai.xi MS_U32 UtopiaInstanceGetPid(void* pInstance);
95*53ee8cc1Swenshuai.xi 
96*53ee8cc1Swenshuai.xi /*
97*53ee8cc1Swenshuai.xi  * module functions
98*53ee8cc1Swenshuai.xi  */
99*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleCreate(MS_U32 u32ModuleID,
100*53ee8cc1Swenshuai.xi 		MS_U32 u32PrivateSize, void** ppModule);
101*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleGetPrivate(void* pModule, void** ppPrivate);
102*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleSetSTRPrivate(void* pModule, MS_U32 u32STRPrivateSize);
103*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleGetSTRPrivate(void* pModule, void** ppPrivate);
104*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleRegister(void* pModule);
105*53ee8cc1Swenshuai.xi #ifdef CONFIG_UTOPIA_PROC_DBG_SUPPORT
106*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleRegisterMdbNode(char sMdbNodeName[MDB_NODE_NAME_MAX], FUtopiaMdbIoctl fpMdbIoctl);
107*53ee8cc1Swenshuai.xi MS_U32 UtopiaCreateMdbNode(void);
108*53ee8cc1Swenshuai.xi void* UtopiaModuleGetLocalInstantList(MS_U32 u32ModuleID, void* pLastInstance);
109*53ee8cc1Swenshuai.xi #endif
110*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleSetupFunctionPtr(void* pModule, FUtopiaOpen fpOpen,
111*53ee8cc1Swenshuai.xi 		FUtopiaClose fpClose, FUtopiaIOctl fpIoctl);
112*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleSetupSTRFunctionPtr(void* pModuleTmp, FUtopiaSTR fpSTR);
113*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleSuspend(void);
114*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleResume(void);
115*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleSetVersion(void* pModule, MS_U32 u32Version);
116*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleGetDebugLevel(void* pInstance, MS_U32* pu32DebugLevel);
117*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleGetPtr(MS_U32 u32ModuleID, void** ppModule);
118*53ee8cc1Swenshuai.xi 
119*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleQueryMode(MS_U32 u32ModuleID);
120*53ee8cc1Swenshuai.xi 
121*53ee8cc1Swenshuai.xi 
122*53ee8cc1Swenshuai.xi /*
123*53ee8cc1Swenshuai.xi  * resource functions
124*53ee8cc1Swenshuai.xi  */
125*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceCreate(char* u8ResourceName,
126*53ee8cc1Swenshuai.xi 		MS_U32 u32PrivateSize, void** ppResource);
127*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceGetPrivate(void* pResource, void** ppPrivate);
128*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceRegister(void* pModule, void* pResouce, MS_U32 u32PoolID);
129*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceObtain(void* pInstant,
130*53ee8cc1Swenshuai.xi 		MS_U32 u32PoolID, void** ppResource);
131*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceTryObtain(void* pInstant,
132*53ee8cc1Swenshuai.xi 		MS_U32 u32PoolID, void** ppResource);
133*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceRelease(void* pResource);
134*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceGetPid(void* pResource);
135*53ee8cc1Swenshuai.xi MS_U32 UtopiaResourceGetNext(void* pModTmp, void** ppResource);
136*53ee8cc1Swenshuai.xi 
137*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleAddResourceStart(void* psModule, MS_U32 u32PoolID);
138*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleAddResourceEnd(void* psModule, MS_U32 u32PoolID);
139*53ee8cc1Swenshuai.xi MS_U32 UtopiaModuleResetPool(void* pModuleTmp, MS_U32 u32RPoolID);
140*53ee8cc1Swenshuai.xi 
141*53ee8cc1Swenshuai.xi MS_U32 UtopiaStrWaitCondition(const char* u8ModuleName, MS_U32 u32Mode, MS_U32 u32Stage);
142*53ee8cc1Swenshuai.xi MS_U32 UtopiaStrSendCondition(const char* u8ModuleName, MS_U32 u32Mode, MS_U32 u32Stage);
143*53ee8cc1Swenshuai.xi 
144*53ee8cc1Swenshuai.xi MS_U32 UtopiaStrSetData(char *key, char *value);
145*53ee8cc1Swenshuai.xi MS_U32 UtopiaStrGetData(char *key, char *value);
146*53ee8cc1Swenshuai.xi 
147*53ee8cc1Swenshuai.xi #endif /* _UTOPIA_DAPI_H_ */
148