diff options
-rw-r--r-- | libdce_linux.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libdce_linux.c b/libdce_linux.c index 85dc517..3de2e0a 100644 --- a/libdce_linux.c +++ b/libdce_linux.c | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <string.h> | 34 | #include <string.h> |
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | #include <pthread.h> | ||
38 | |||
37 | #include <xf86drm.h> | 39 | #include <xf86drm.h> |
38 | #include <omap_drm.h> | 40 | #include <omap_drm.h> |
39 | #include <omap_drmif.h> | 41 | #include <omap_drmif.h> |
@@ -51,12 +53,19 @@ int bDrmOpenedByDce = FALSE; | |||
51 | struct omap_device *OmapDev = NULL; | 53 | struct omap_device *OmapDev = NULL; |
52 | extern MmRpc_Handle MmRpcHandle[]; | 54 | extern MmRpc_Handle MmRpcHandle[]; |
53 | 55 | ||
56 | extern pthread_mutex_t ipc_mutex; | ||
57 | |||
54 | void *dce_init(void) | 58 | void *dce_init(void) |
55 | { | 59 | { |
56 | dce_error_status eError = DCE_EOK; | 60 | dce_error_status eError = DCE_EOK; |
57 | 61 | ||
58 | DEBUG(" >> dce_init"); | 62 | DEBUG(" >> dce_init"); |
59 | 63 | ||
64 | pthread_mutexattr_t attr; | ||
65 | pthread_mutexattr_init(&attr); | ||
66 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); | ||
67 | pthread_mutex_init(&ipc_mutex, &attr); | ||
68 | |||
60 | /* Open omapdrm device */ | 69 | /* Open omapdrm device */ |
61 | if( OmapDrm_FD == INVALID_DRM_FD ) { | 70 | if( OmapDrm_FD == INVALID_DRM_FD ) { |
62 | DEBUG("Open omapdrm device"); | 71 | DEBUG("Open omapdrm device"); |
@@ -90,6 +99,8 @@ int dce_buf_lock(int num, size_t *handle) | |||
90 | MmRpc_BufDesc *desc = NULL; | 99 | MmRpc_BufDesc *desc = NULL; |
91 | dce_error_status eError = DCE_EOK; | 100 | dce_error_status eError = DCE_EOK; |
92 | 101 | ||
102 | pthread_mutex_lock(&ipc_mutex); | ||
103 | |||
93 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | 104 | _ASSERT(num > 0, DCE_EINVALID_INPUT); |
94 | 105 | ||
95 | desc = malloc(num * sizeof(MmRpc_BufDesc)); | 106 | desc = malloc(num * sizeof(MmRpc_BufDesc)); |
@@ -106,6 +117,9 @@ EXIT: | |||
106 | if( desc ) { | 117 | if( desc ) { |
107 | free(desc); | 118 | free(desc); |
108 | } | 119 | } |
120 | |||
121 | pthread_mutex_unlock(&ipc_mutex); | ||
122 | |||
109 | return (eError); | 123 | return (eError); |
110 | } | 124 | } |
111 | 125 | ||
@@ -115,6 +129,8 @@ int dce_buf_unlock(int num, size_t *handle) | |||
115 | MmRpc_BufDesc *desc = NULL; | 129 | MmRpc_BufDesc *desc = NULL; |
116 | dce_error_status eError = DCE_EOK; | 130 | dce_error_status eError = DCE_EOK; |
117 | 131 | ||
132 | pthread_mutex_lock(&ipc_mutex); | ||
133 | |||
118 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | 134 | _ASSERT(num > 0, DCE_EINVALID_INPUT); |
119 | 135 | ||
120 | desc = malloc(num * sizeof(MmRpc_BufDesc)); | 136 | desc = malloc(num * sizeof(MmRpc_BufDesc)); |
@@ -131,6 +147,9 @@ EXIT: | |||
131 | if( desc ) { | 147 | if( desc ) { |
132 | free(desc); | 148 | free(desc); |
133 | } | 149 | } |
150 | |||
151 | pthread_mutex_unlock(&ipc_mutex); | ||
152 | |||
134 | return (eError); | 153 | return (eError); |
135 | } | 154 | } |
136 | 155 | ||
@@ -156,6 +175,8 @@ int dsp_dce_buf_lock(int num, size_t *handle) | |||
156 | MmRpc_BufDesc *desc = NULL; | 175 | MmRpc_BufDesc *desc = NULL; |
157 | dce_error_status eError = DCE_EOK; | 176 | dce_error_status eError = DCE_EOK; |
158 | 177 | ||
178 | pthread_mutex_lock(&ipc_mutex); | ||
179 | |||
159 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | 180 | _ASSERT(num > 0, DCE_EINVALID_INPUT); |
160 | 181 | ||
161 | desc = malloc(num * sizeof(MmRpc_BufDesc)); | 182 | desc = malloc(num * sizeof(MmRpc_BufDesc)); |
@@ -172,6 +193,9 @@ EXIT: | |||
172 | if( desc ) { | 193 | if( desc ) { |
173 | free(desc); | 194 | free(desc); |
174 | } | 195 | } |
196 | |||
197 | pthread_mutex_unlock(&ipc_mutex); | ||
198 | |||
175 | return (eError); | 199 | return (eError); |
176 | } | 200 | } |
177 | 201 | ||
@@ -181,6 +205,8 @@ int dsp_dce_buf_unlock(int num, size_t *handle) | |||
181 | MmRpc_BufDesc *desc = NULL; | 205 | MmRpc_BufDesc *desc = NULL; |
182 | dce_error_status eError = DCE_EOK; | 206 | dce_error_status eError = DCE_EOK; |
183 | 207 | ||
208 | pthread_mutex_lock(&ipc_mutex); | ||
209 | |||
184 | _ASSERT(num > 0, DCE_EINVALID_INPUT); | 210 | _ASSERT(num > 0, DCE_EINVALID_INPUT); |
185 | 211 | ||
186 | desc = malloc(num * sizeof(MmRpc_BufDesc)); | 212 | desc = malloc(num * sizeof(MmRpc_BufDesc)); |
@@ -197,6 +223,8 @@ EXIT: | |||
197 | if( desc ) { | 223 | if( desc ) { |
198 | free(desc); | 224 | free(desc); |
199 | } | 225 | } |
226 | |||
227 | pthread_mutex_unlock(&ipc_mutex); | ||
200 | return (eError); | 228 | return (eError); |
201 | } | 229 | } |
202 | /* Incase of X11 or Wayland the fd can be shared to libdce using this call */ | 230 | /* Incase of X11 or Wayland the fd can be shared to libdce using this call */ |