aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaurabh Bipin Chandra2013-09-02 23:04:10 -0500
committerSaurabh Bipin Chandra2013-09-05 10:43:34 -0500
commit2cf99e4c810f3fe1eddd1e02469643384002079f (patch)
tree0b596827382e4c563581d1fd7e906e8238e87308 /libdce.c
parentfde931439600e9be8f4556960230f6b62a474ade (diff)
downloadrepo-libdce-2cf99e4c810f3fe1eddd1e02469643384002079f.tar.gz
repo-libdce-2cf99e4c810f3fe1eddd1e02469643384002079f.tar.xz
repo-libdce-2cf99e4c810f3fe1eddd1e02469643384002079f.zip
[LINUX] Expose dce_init and dce_deinit calls to user
This patch changes the declaration of dce_init() and dce_deinit() to what is expected by Gstreamer for GLP and exposes it. This involves returning a struct omap_device pointer as void * during dce_init() and receiving a struct omap_device during dce_deinit(). The IPC initialization/deinitialization has been separated out of dce_init()/dce_deinit() into two static functions dce_ipc_init(), dce_ipc_deinit(). These functions are now included within Engine_open(), Engine_close() for all OSs. Change-Id: I86f4778cbd80f0a83aa3c39d8183bb3155a2a391 Signed-off-by: Saurabh Bipin Chandra <a0131926@ti.com>
Diffstat (limited to 'libdce.c')
-rw-r--r--libdce.c115
1 files changed, 64 insertions, 51 deletions
diff --git a/libdce.c b/libdce.c
index b734f94..1c4ecb1 100644
--- a/libdce.c
+++ b/libdce.c
@@ -88,9 +88,7 @@
88 88
89 89
90#if defined(BUILDOS_LINUX) 90#if defined(BUILDOS_LINUX)
91int fd = -1; 91int fd = -1;
92struct omap_device *dev = 0;
93uint32_t dce_debug = 3;
94#endif /* BUILDOS_LINUX */ 92#endif /* BUILDOS_LINUX */
95 93
96 94
@@ -146,8 +144,8 @@ static inline void Fill_MmRpc_fxnCtx_Xlt_Array(MmRpc_Xlt *mmrpc_xlt, int index,
146} 144}
147 145
148/************************ FUNCTIONS **************************/ 146/************************ FUNCTIONS **************************/
149/* Interface for QNX for parameter buffer allocation */ 147/* Interface for QNX for parameter buffer allocation */
150/* These interfaces are implemented to maintain Backward Compatability */ 148/* These interfaces are implemented to maintain Backward Compatability */
151void *dce_alloc(int sz) 149void *dce_alloc(int sz)
152{ 150{
153 return (memplugin_alloc(sz, 0, TILER_1D_BUFFER)); 151 return (memplugin_alloc(sz, 0, TILER_1D_BUFFER));
@@ -158,7 +156,41 @@ void dce_free(void *ptr)
158 memplugin_free(ptr, TILER_1D_BUFFER); 156 memplugin_free(ptr, TILER_1D_BUFFER);
159} 157}
160 158
159/***************** FUNCTIONS SPECIFIC TO LINUX *******************/
161#if defined(BUILDOS_LINUX) 160#if defined(BUILDOS_LINUX)
161void *dce_init(void)
162{
163 struct omap_device *OmapDev = NULL;
164 dce_error_status eError = DCE_EOK;
165
166 printf(" >> dce_init\n");
167
168 /* Open omapdrm device */
169 if( fd == -1 ) {
170 printf("Open omapdrm device \n");
171 fd = drmOpen("omapdrm", "platform:omapdrm:00");
172 }
173 if( fd >= 0 ) {
174 OmapDev = omap_device_new(fd);
175 } else {
176 printf("Error opening omapdrm : drmOpen failed");
177 goto EXIT;
178 }
179
180EXIT:
181 return ((void *)OmapDev);
182}
183
184void dce_deinit(void *dev)
185{
186 omap_device_del(dev);
187 dev = NULL;
188 close(fd);
189 fd = -1;
190
191 return;
192}
193
162int dce_buf_lock(int num, size_t *handle) 194int dce_buf_lock(int num, size_t *handle)
163{ 195{
164 int i; 196 int i;
@@ -203,15 +235,30 @@ EXIT:
203 return (eError); 235 return (eError);
204} 236}
205 237
238/* Incase of X11 or Wayland the fd can be shared to libdce using this call */
239void dce_set_fd(int dce_fd)
240{
241 fd = dce_fd;
242}
243
244int dce_get_fd(void)
245{
246 return (fd);
247}
248
206#endif /* BUILDOS_LINUX */ 249#endif /* BUILDOS_LINUX */
207 250
208/*************** Startup/Shutdown Functions ***********************/ 251/*=====================================================================================*/
209static int dce_init(void) 252/** dce_ipc_init : Initialize MmRpc. This function is called within Engine_open().
253 *
254 * @ return : Error Status.
255 */
256static int dce_ipc_init(void)
210{ 257{
211 dce_error_status eError = DCE_EOK;
212 MmRpc_Params args; 258 MmRpc_Params args;
259 dce_error_status eError = DCE_EOK;
213 260
214 printf(" >> dce_init\n"); 261 printf(" >> dce_ipc_init\n");
215 262
216 pthread_mutex_lock(&mutex); 263 pthread_mutex_lock(&mutex);
217 264
@@ -228,28 +275,16 @@ static int dce_init(void)
228 275
229 printf("open(/dev/" DCE_DEVICE_NAME ") -> 0x%x\n", (int)MmRpcHandle); 276 printf("open(/dev/" DCE_DEVICE_NAME ") -> 0x%x\n", (int)MmRpcHandle);
230 277
231#if defined(BUILDOS_LINUX)
232 /* Open omapdrm device */
233
234 if( fd == -1 ) {
235 printf("Open omapdrm device \n");
236 fd = drmOpen("omapdrm", "platform:omapdrm:00");
237 }
238 if( fd >= 0 ) {
239 dev = omap_device_new(fd);
240 } else {
241 printf("Error opening omapdrm : drmOpen failed");
242 goto EXIT;
243 }
244#endif /* BUILDOS_LINUX */
245
246
247EXIT: 278EXIT:
248 pthread_mutex_unlock(&mutex); 279 pthread_mutex_unlock(&mutex);
249 return (eError); 280 return (eError);
250} 281}
251 282
252static void dce_deinit(void) 283/*=====================================================================================*/
284/** dce_ipc_deinit : DeInitialize MmRpc. This function is called within
285 * Engine_close().
286 */
287static void dce_ipc_deinit()
253{ 288{
254 pthread_mutex_lock(&mutex); 289 pthread_mutex_lock(&mutex);
255 290
@@ -263,33 +298,11 @@ static void dce_deinit(void)
263 } 298 }
264 MmRpcHandle = NULL; 299 MmRpcHandle = NULL;
265 300
266#if defined(BUILDOS_LINUX)
267 omap_device_del(dev);
268 dev = NULL;
269 close(fd);
270 fd = -1;
271#endif /* BUILDOS_LINUX */
272
273
274EXIT: 301EXIT:
275 pthread_mutex_unlock(&mutex); 302 pthread_mutex_unlock(&mutex);
276 return; 303 return;
277} 304}
278 305
279/* Incase of X11 or Wayland the fd can be shared to libdce using this call */
280#if defined(BUILDOS_LINUX)
281void dce_set_fd(int dce_fd)
282{
283 fd = dce_fd;
284}
285
286int dce_get_fd(void)
287{
288 return (fd);
289}
290
291#endif /* BUILDOS_LINUX */
292
293/*===============================================================*/ 306/*===============================================================*/
294/** Engine_open : Open Codec Engine. 307/** Engine_open : Open Codec Engine.
295 * 308 *
@@ -309,8 +322,8 @@ Engine_Handle Engine_open(String name, Engine_Attrs *attrs, Engine_Error *ec)
309 322
310 _ASSERT(name != '\0', DCE_EINVALID_INPUT); 323 _ASSERT(name != '\0', DCE_EINVALID_INPUT);
311 324
312 /* Initialize DCE and IPC. In case of Error Deinitialize them */ 325 /* Initialize IPC. In case of Error Deinitialize them */
313 _ASSERT_AND_EXECUTE(dce_init() == DCE_EOK, DCE_EIPC_CREATE_FAIL, dce_deinit()); 326 _ASSERT_AND_EXECUTE(dce_ipc_init() == DCE_EOK, DCE_EIPC_CREATE_FAIL, dce_ipc_deinit());
314 327
315 printf(">> Engine_open Params::name = %s size = %d\n", name, strlen(name)); 328 printf(">> Engine_open Params::name = %s size = %d\n", name, strlen(name));
316 /* Allocate Shared memory for the engine_open rpc msg structure*/ 329 /* Allocate Shared memory for the engine_open rpc msg structure*/
@@ -373,7 +386,7 @@ Void Engine_close(Engine_Handle engine)
373 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); 386 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
374 387
375EXIT: 388EXIT:
376 dce_deinit(); 389 dce_ipc_deinit();
377 return; 390 return;
378} 391}
379 392