aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunita Nadampalli2014-11-17 14:00:48 -0600
committerSunita Nadampalli2014-11-17 14:00:48 -0600
commit02907e6c0b25f3abbb90f762681a9b13abe29477 (patch)
tree83183f247f564db4507bc8a29b800676f8073cd3 /libdce_android.c
parent5693201c37da9070928a751d79cbfed6bb8dd051 (diff)
downloadrepo-libdce-02907e6c0b25f3abbb90f762681a9b13abe29477.tar.gz
repo-libdce-02907e6c0b25f3abbb90f762681a9b13abe29477.tar.xz
repo-libdce-02907e6c0b25f3abbb90f762681a9b13abe29477.zip
libdce[Android]: Added support for DRM based Android memplugin
This patch adds memplugin implementation for GEM allocator and dce buffer locking via MmRPC for Android builds. Android memplugin implement memplugin interface for buffers with and without memheaders. This implementation is for DRM/GEM buffer allocations. And libdce_android implements GEM buffer registration and unregistration with MmRPC. Change-Id: Ie72c988a37f987446f7d7c1d97225295de73d305 Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
Diffstat (limited to 'libdce_android.c')
-rw-r--r--libdce_android.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/libdce_android.c b/libdce_android.c
new file mode 100644
index 0000000..300c311
--- /dev/null
+++ b/libdce_android.c
@@ -0,0 +1,96 @@
1/*
2 * Copyright (c) 2014, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <stdlib.h>
34#include <string.h>
35#include <stdio.h>
36
37#include <ti/ipc/mm/MmRpc.h>
38#include "dce_priv.h"
39#include "libdce.h"
40#include "dce_rpc.h"
41#include "memplugin.h"
42
43
44extern MmRpc_Handle MmRpcHandle[];
45
46int dce_buf_lock(int num, size_t *handle)
47{
48 int i;
49 MmRpc_BufDesc *desc = NULL;
50 dce_error_status eError = DCE_EOK;
51
52 _ASSERT(num > 0, DCE_EINVALID_INPUT);
53
54 desc = malloc(num * sizeof(MmRpc_BufDesc));
55 _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY);
56
57 for( i = 0; i < num; i++ ) {
58 desc[i].handle = handle[i];
59 }
60
61 eError = MmRpc_use(MmRpcHandle[IPU], MmRpc_BufType_Handle, num, desc);
62
63 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
64EXIT:
65 if( desc ) {
66 free(desc);
67 }
68 return (eError);
69}
70
71int dce_buf_unlock(int num, size_t *handle)
72{
73 int i;
74 MmRpc_BufDesc *desc = NULL;
75 dce_error_status eError = DCE_EOK;
76
77 _ASSERT(num > 0, DCE_EINVALID_INPUT);
78
79 desc = malloc(num * sizeof(MmRpc_BufDesc));
80 _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY);
81
82 for( i = 0; i < num; i++ ) {
83 desc[i].handle = handle[i];
84 }
85
86 eError = MmRpc_release(MmRpcHandle[IPU], MmRpc_BufType_Handle, num, desc);
87
88 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
89EXIT:
90 if( desc ) {
91 free(desc);
92 }
93 return (eError);
94}
95
96