diff options
author | Saurabh Bipin Chandra | 2013-09-05 05:16:56 -0500 |
---|---|---|
committer | Saurabh Bipin Chandra | 2013-09-05 10:44:04 -0500 |
commit | a502de00cbe7e704379f6ddbdf6ee3cc2c4f4274 (patch) | |
tree | bf587610df3f43149016a713d59b1f19c8f73c25 | |
parent | 2cf99e4c810f3fe1eddd1e02469643384002079f (diff) | |
download | hardware-ti-libdce-a502de00cbe7e704379f6ddbdf6ee3cc2c4f4274.tar.gz hardware-ti-libdce-a502de00cbe7e704379f6ddbdf6ee3cc2c4f4274.tar.xz hardware-ti-libdce-a502de00cbe7e704379f6ddbdf6ee3cc2c4f4274.zip |
[LINUX] Moving Linux specific functions to new c file
This patch moves Linux specific functions to
libdce_linux.c.
It also takes in the DRM Initialization cleanup
changes in dce_init from:
https://gerrit.ext.ti.com/gerrit/omap/#/c/12888
Change-Id: I570341c8dfbe1d120bc89071a86020b6ba5d4cac
Signed-off-by: Saurabh Bipin Chandra <a0131926@ti.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | libdce.c | 103 | ||||
-rw-r--r-- | libdce.h | 3 | ||||
-rw-r--r-- | libdce_linux.c | 133 | ||||
-rw-r--r-- | memplugin_linux.c | 4 |
5 files changed, 138 insertions, 107 deletions
diff --git a/Makefile.am b/Makefile.am index 5869713..0a0a6b9 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -15,7 +15,7 @@ CE_CFLAGS = \ | |||
15 | -Wno-pointer-to-int-cast | 15 | -Wno-pointer-to-int-cast |
16 | 16 | ||
17 | 17 | ||
18 | libdce_la_SOURCES = libdce.c memplugin_linux.c | 18 | libdce_la_SOURCES = libdce.c memplugin_linux.c libdce_linux.c |
19 | libdce_la_CFLAGS = $(WARN_CFLAGS) $(CE_CFLAGS) $(DRM_CFLAGS) $(X11_CFLAGS) $(WAYLAND_CFLAGS) | 19 | libdce_la_CFLAGS = $(WARN_CFLAGS) $(CE_CFLAGS) $(DRM_CFLAGS) $(X11_CFLAGS) $(WAYLAND_CFLAGS) |
20 | libdce_la_LDFLAGS = -no-undefined -version-info 1:0:0 | 20 | libdce_la_LDFLAGS = -no-undefined -version-info 1:0:0 |
21 | libdce_la_LIBADD = $(DRM_LIBS) $(X11_LIBS) $(WAYLAND_LIBS) $(MMRPC_LIBS) | 21 | libdce_la_LIBADD = $(DRM_LIBS) $(X11_LIBS) $(WAYLAND_LIBS) $(MMRPC_LIBS) |
@@ -71,12 +71,6 @@ | |||
71 | 71 | ||
72 | #include <xdc/std.h> | 72 | #include <xdc/std.h> |
73 | 73 | ||
74 | #if defined(BUILDOS_LINUX) | ||
75 | #include <xf86drm.h> | ||
76 | #include <omap_drm.h> | ||
77 | #include <omap_drmif.h> | ||
78 | #endif /* BUILDOS_LINUX */ | ||
79 | |||
80 | /* IPC Headers */ | 74 | /* IPC Headers */ |
81 | #include <MmRpc.h> | 75 | #include <MmRpc.h> |
82 | 76 | ||
@@ -87,11 +81,6 @@ | |||
87 | #include "memplugin.h" | 81 | #include "memplugin.h" |
88 | 82 | ||
89 | 83 | ||
90 | #if defined(BUILDOS_LINUX) | ||
91 | int fd = -1; | ||
92 | #endif /* BUILDOS_LINUX */ | ||
93 | |||
94 | |||
95 | /********************* GLOBALS ***********************/ | 84 | /********************* GLOBALS ***********************/ |
96 | /* Hande used for Remote Communication */ | 85 | /* Hande used for Remote Communication */ |
97 | static MmRpc_Handle MmRpcHandle = NULL; | 86 | static MmRpc_Handle MmRpcHandle = NULL; |
@@ -156,98 +145,6 @@ void dce_free(void *ptr) | |||
156 | memplugin_free(ptr, TILER_1D_BUFFER); | 145 | memplugin_free(ptr, TILER_1D_BUFFER); |
157 | } | 146 | } |
158 | 147 | ||
159 | /***************** FUNCTIONS SPECIFIC TO LINUX *******************/ | ||
160 | #if defined(BUILDOS_LINUX) | ||
161 | void *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 | |||
180 | EXIT: | ||
181 | return ((void *)OmapDev); | ||
182 | } | ||
183 | |||
184 | void dce_deinit(void *dev) | ||
185 | { | ||
186 | omap_device_del(dev); | ||
187 | dev = NULL; | ||
188 | close(fd); | ||
189 | fd = -1; | ||
190 | |||
191 | return; | ||
192 | } | ||
193 | |||
194 | int dce_buf_lock(int num, size_t *handle) | ||
195 | { | ||
196 | int i; | ||
197 | MmRpc_BufDesc *desc = NULL; | ||
198 | dce_error_status eError = DCE_EOK; | ||
199 | |||
200 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | ||
201 | |||
202 | desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER); | ||
203 | _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY); | ||
204 | |||
205 | for( i = 0; i < num; i++ ) { | ||
206 | desc[i].handle = handle[i]; | ||
207 | } | ||
208 | |||
209 | eError = MmRpc_use(MmRpcHandle, MmRpc_BufType_Handle, num, desc); | ||
210 | |||
211 | _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); | ||
212 | EXIT: | ||
213 | return (eError); | ||
214 | } | ||
215 | |||
216 | int dce_buf_unlock(int num, size_t *handle) | ||
217 | { | ||
218 | int i; | ||
219 | MmRpc_BufDesc *desc = NULL; | ||
220 | dce_error_status eError = DCE_EOK; | ||
221 | |||
222 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | ||
223 | |||
224 | desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER); | ||
225 | _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY); | ||
226 | |||
227 | for( i = 0; i < num; i++ ) { | ||
228 | desc[i].handle = handle[i]; | ||
229 | } | ||
230 | |||
231 | eError = MmRpc_release(MmRpcHandle, MmRpc_BufType_Handle, num, desc); | ||
232 | |||
233 | _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); | ||
234 | EXIT: | ||
235 | return (eError); | ||
236 | } | ||
237 | |||
238 | /* Incase of X11 or Wayland the fd can be shared to libdce using this call */ | ||
239 | void dce_set_fd(int dce_fd) | ||
240 | { | ||
241 | fd = dce_fd; | ||
242 | } | ||
243 | |||
244 | int dce_get_fd(void) | ||
245 | { | ||
246 | return (fd); | ||
247 | } | ||
248 | |||
249 | #endif /* BUILDOS_LINUX */ | ||
250 | |||
251 | /*=====================================================================================*/ | 148 | /*=====================================================================================*/ |
252 | /** dce_ipc_init : Initialize MmRpc. This function is called within Engine_open(). | 149 | /** dce_ipc_init : Initialize MmRpc. This function is called within Engine_open(). |
253 | * | 150 | * |
@@ -53,7 +53,8 @@ typedef enum dce_error_status { | |||
53 | DCE_EXDM_UNSUPPORTED = -3, | 53 | DCE_EXDM_UNSUPPORTED = -3, |
54 | DCE_EIPC_CREATE_FAIL = -4, | 54 | DCE_EIPC_CREATE_FAIL = -4, |
55 | DCE_EIPC_CALL_FAIL = -5, | 55 | DCE_EIPC_CALL_FAIL = -5, |
56 | DCE_EINVALID_INPUT = -6 | 56 | DCE_EINVALID_INPUT = -6, |
57 | DCE_EOMAPDRM_FAIL = -7 | ||
57 | } dce_error_status; | 58 | } dce_error_status; |
58 | 59 | ||
59 | 60 | ||
diff --git a/libdce_linux.c b/libdce_linux.c new file mode 100644 index 0000000..99c8b8d --- /dev/null +++ b/libdce_linux.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2013, 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 | #include <xdc/std.h> | ||
37 | |||
38 | #include <xf86drm.h> | ||
39 | #include <omap_drm.h> | ||
40 | #include <omap_drmif.h> | ||
41 | |||
42 | #include <MmRpc.h> | ||
43 | #include "dce_priv.h" | ||
44 | |||
45 | #define INVALID_DRM_FD (-1) | ||
46 | |||
47 | int OmapDrm_FD = INVALID_DRM_FD; | ||
48 | |||
49 | void *dce_init(void) | ||
50 | { | ||
51 | struct omap_device *OmapDev = NULL; | ||
52 | dce_error_status eError = DCE_EOK; | ||
53 | |||
54 | printf(" >> dce_init\n"); | ||
55 | |||
56 | /* Open omapdrm device */ | ||
57 | if( !OmapDrm_FD && OmapDrm_FD == INVALID_DRM_FD ) { | ||
58 | printf("Open omapdrm device \n"); | ||
59 | OmapDrm_FD = drmOpen("omapdrm", "platform:omapdrm:00"); | ||
60 | _ASSERT(OmapDrm_FD > 0, DCE_EOMAPDRM_FAIL); | ||
61 | } | ||
62 | OmapDev = omap_device_new(OmapDrm_FD); | ||
63 | _ASSERT(OmapDev != NULL, DCE_EOMAPDRM_FAIL); | ||
64 | |||
65 | EXIT: | ||
66 | return ((void *)OmapDev); | ||
67 | } | ||
68 | |||
69 | void dce_deinit(void *dev) | ||
70 | { | ||
71 | omap_device_del(dev); | ||
72 | dev = NULL; | ||
73 | close(OmapDrm_FD); | ||
74 | OmapDrm_FD = INVALID_DRM_FD; | ||
75 | |||
76 | return; | ||
77 | } | ||
78 | |||
79 | int dce_buf_lock(int num, size_t *handle) | ||
80 | { | ||
81 | int i; | ||
82 | MmRpc_BufDesc *desc = NULL; | ||
83 | dce_error_status eError = DCE_EOK; | ||
84 | |||
85 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | ||
86 | |||
87 | desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER); | ||
88 | _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY); | ||
89 | |||
90 | for( i = 0; i < num; i++ ) { | ||
91 | desc[i].handle = handle[i]; | ||
92 | } | ||
93 | |||
94 | eError = MmRpc_use(MmRpcHandle, MmRpc_BufType_Handle, num, desc); | ||
95 | |||
96 | _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); | ||
97 | EXIT: | ||
98 | return (eError); | ||
99 | } | ||
100 | |||
101 | int dce_buf_unlock(int num, size_t *handle) | ||
102 | { | ||
103 | int i; | ||
104 | MmRpc_BufDesc *desc = NULL; | ||
105 | dce_error_status eError = DCE_EOK; | ||
106 | |||
107 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | ||
108 | |||
109 | desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER); | ||
110 | _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY); | ||
111 | |||
112 | for( i = 0; i < num; i++ ) { | ||
113 | desc[i].handle = handle[i]; | ||
114 | } | ||
115 | |||
116 | eError = MmRpc_release(MmRpcHandle, MmRpc_BufType_Handle, num, desc); | ||
117 | |||
118 | _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL); | ||
119 | EXIT: | ||
120 | return (eError); | ||
121 | } | ||
122 | |||
123 | /* Incase of X11 or Wayland the fd can be shared to libdce using this call */ | ||
124 | void dce_set_fd(int dce_fd) | ||
125 | { | ||
126 | OmapDrm_FD = dce_fd; | ||
127 | } | ||
128 | |||
129 | int dce_get_fd(void) | ||
130 | { | ||
131 | return (OmapDrm_FD); | ||
132 | } | ||
133 | |||
diff --git a/memplugin_linux.c b/memplugin_linux.c index 47f03fc..db04f4c 100644 --- a/memplugin_linux.c +++ b/memplugin_linux.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include "memplugin.h" | 33 | #include "memplugin.h" |
34 | #include "dce_priv.h" | 34 | #include "dce_priv.h" |
35 | 35 | ||
36 | extern struct omap_device *dev; | 36 | extern struct omap_device *OmapDev; |
37 | 37 | ||
38 | 38 | ||
39 | /* memplugin_alloc - allocates omap_bo buffer with a header above it. | 39 | /* memplugin_alloc - allocates omap_bo buffer with a header above it. |
@@ -45,7 +45,7 @@ extern struct omap_device *dev; | |||
45 | void *memplugin_alloc(int sz, int height, mem_type memory_type) | 45 | void *memplugin_alloc(int sz, int height, mem_type memory_type) |
46 | { | 46 | { |
47 | MemHeader *h; | 47 | MemHeader *h; |
48 | struct omap_bo *bo = omap_bo_new(dev, sz + sizeof(MemHeader), OMAP_BO_CACHED); | 48 | struct omap_bo *bo = omap_bo_new(OmapDev, sz + sizeof(MemHeader), OMAP_BO_CACHED); |
49 | 49 | ||
50 | if( !bo ) { | 50 | if( !bo ) { |
51 | return (NULL); | 51 | return (NULL); |