forked from asdfzz/P500_CM9_Patches
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path0001-Build-libgenlock-and-libgralloc-for-msm7x27.patch
303 lines (284 loc) · 10.9 KB
/
0001-Build-libgenlock-and-libgralloc-for-msm7x27.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
From 12ec685783480ea9125618d20f91778dc6c0df90 Mon Sep 17 00:00:00 2001
From: Adam Farden <[email protected]>
Date: Mon, 2 Apr 2012 17:36:10 +0200
Subject: [PATCH] Build libgenlock and libgralloc for msm7x27
Change-Id: Iaf5c9339186580233b033598e5d170a67bd734c6
---
libgenlock/Android.mk | 8 ++-
libgenlock/genlock.cpp | 180 ++++++++++++++++++--------------------
libgralloc/alloc_controller.cpp | 3 +-
libgralloc/gr.h | 3 +-
4 files changed, 94 insertions(+), 100 deletions(-)
diff --git a/libgenlock/Android.mk b/libgenlock/Android.mk
index 95ae4c9..2ac565e 100644
--- a/libgenlock/Android.mk
+++ b/libgenlock/Android.mk
@@ -4,9 +4,15 @@ include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_C_INCLUDES := hardware/qcom/display/libgralloc
+LOCAL_C_INCLUDES += hardware/qcom/display/libgralloc
LOCAL_SRC_FILES := genlock.cpp
LOCAL_CFLAGS:= -DLOG_TAG=\"libgenlock\"
LOCAL_MODULE_TAGS := optional
+
+ifeq ($(BOARD_USES_GENLOCK),true)
+ LOCAL_CFLAGS += -DUSE_GENLOCK
+endif
+
LOCAL_MODULE := libgenlock
include $(BUILD_SHARED_LIBRARY)
+
diff --git a/libgenlock/genlock.cpp b/libgenlock/genlock.cpp
index 429b467..2aa709a 100644
--- a/libgenlock/genlock.cpp
+++ b/libgenlock/genlock.cpp
@@ -38,10 +38,6 @@
#define GENLOCK_DEVICE "/dev/genlock"
-#ifndef USE_GENLOCK
-#define USE_GENLOCK
-#endif
-
namespace {
/* Internal function to map the userspace locks to the kernel lock types */
int get_kernel_lock_type(genlock_lock_type lockType)
@@ -70,27 +66,25 @@ namespace {
}
private_handle_t *hnd = reinterpret_cast<private_handle_t*>(buffer_handle);
- if ((hnd->flags & private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED) == 0) {
- if (hnd->genlockPrivFd < 0) {
- LOGE("%s: the lock has not been created, or has not been attached",
- __FUNCTION__);
- return GENLOCK_FAILURE;
- }
-
- genlock_lock lock;
- lock.op = lockType;
- lock.flags = 0;
- lock.timeout = timeout;
- lock.fd = hnd->genlockHandle;
-
- if (ioctl(hnd->genlockPrivFd, GENLOCK_IOC_LOCK, &lock)) {
- LOGE("%s: GENLOCK_IOC_LOCK failed (lockType0x%x, err=%s fd=%d)", __FUNCTION__,
- lockType, strerror(errno), hnd->fd);
- if (ETIMEDOUT == errno)
- return GENLOCK_TIMEDOUT;
-
- return GENLOCK_FAILURE;
- }
+ if (hnd->genlockPrivFd < 0) {
+ LOGE("%s: the lock has not been created, or has not been attached",
+ __FUNCTION__);
+ return GENLOCK_FAILURE;
+ }
+
+ genlock_lock lock;
+ lock.op = lockType;
+ lock.flags = 0;
+ lock.timeout = timeout;
+ lock.fd = hnd->genlockHandle;
+
+ if (ioctl(hnd->genlockPrivFd, GENLOCK_IOC_LOCK, &lock)) {
+ LOGE("%s: GENLOCK_IOC_LOCK failed (lockType0x%x, err=%s fd=%d)", __FUNCTION__,
+ lockType, strerror(errno), hnd->fd);
+ if (ETIMEDOUT == errno)
+ return GENLOCK_TIMEDOUT;
+
+ return GENLOCK_FAILURE;
}
return GENLOCK_NO_ERROR;
}
@@ -127,40 +121,36 @@ genlock_status_t genlock_create_lock(native_handle_t *buffer_handle)
private_handle_t *hnd = reinterpret_cast<private_handle_t*>(buffer_handle);
#ifdef USE_GENLOCK
- if ((hnd->flags & private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED) == 0) {
- // Open the genlock device
- int fd = open(GENLOCK_DEVICE, O_RDWR);
- if (fd < 0) {
- LOGE("%s: open genlock device failed (err=%s)", __FUNCTION__,
- strerror(errno));
- return GENLOCK_FAILURE;
- }
+ // Open the genlock device
+ int fd = open(GENLOCK_DEVICE, O_RDWR);
+ if (fd < 0) {
+ LOGE("%s: open genlock device failed (err=%s)", __FUNCTION__,
+ strerror(errno));
+ return GENLOCK_FAILURE;
+ }
- // Create a new lock
- genlock_lock lock;
- if (ioctl(fd, GENLOCK_IOC_NEW, NULL)) {
- LOGE("%s: GENLOCK_IOC_NEW failed (error=%s)", __FUNCTION__,
+ // Create a new lock
+ genlock_lock lock;
+ if (ioctl(fd, GENLOCK_IOC_NEW, NULL)) {
+ LOGE("%s: GENLOCK_IOC_NEW failed (error=%s)", __FUNCTION__,
+ strerror(errno));
+ close_genlock_fd_and_handle(fd, lock.fd);
+ ret = GENLOCK_FAILURE;
+ }
+
+ // Export the lock for other processes to be able to use it.
+ if (GENLOCK_FAILURE != ret) {
+ if (ioctl(fd, GENLOCK_IOC_EXPORT, &lock)) {
+ LOGE("%s: GENLOCK_IOC_EXPORT failed (error=%s)", __FUNCTION__,
strerror(errno));
close_genlock_fd_and_handle(fd, lock.fd);
ret = GENLOCK_FAILURE;
}
-
- // Export the lock for other processes to be able to use it.
- if (GENLOCK_FAILURE != ret) {
- if (ioctl(fd, GENLOCK_IOC_EXPORT, &lock)) {
- LOGE("%s: GENLOCK_IOC_EXPORT failed (error=%s)", __FUNCTION__,
- strerror(errno));
- close_genlock_fd_and_handle(fd, lock.fd);
- ret = GENLOCK_FAILURE;
- }
- }
-
- // Store the lock params in the handle.
- hnd->genlockPrivFd = fd;
- hnd->genlockHandle = lock.fd;
- } else {
- hnd->genlockHandle = 0;
}
+
+ // Store the lock params in the handle.
+ hnd->genlockPrivFd = fd;
+ hnd->genlockHandle = lock.fd;
#else
hnd->genlockHandle = 0;
#endif
@@ -184,15 +174,19 @@ genlock_status_t genlock_release_lock(native_handle_t *buffer_handle)
}
private_handle_t *hnd = reinterpret_cast<private_handle_t*>(buffer_handle);
- if ((hnd->flags & private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED) == 0) {
- if (hnd->genlockPrivFd < 0) {
- LOGE("%s: the lock is invalid", __FUNCTION__);
- return GENLOCK_FAILURE;
- }
+ if (hnd->genlockPrivFd < 0) {
+ LOGE("%s: the lock is invalid", __FUNCTION__);
+ return GENLOCK_FAILURE;
+ }
- // Close the fd and reset the parameters.
- close_genlock_fd_and_handle(hnd->genlockPrivFd, hnd->genlockHandle);
+ if (ioctl(hnd->genlockPrivFd, GENLOCK_IOC_RELEASE, NULL)) {
+ LOGE("%s: GENLOCK_IOC_RELEASE failed (err=%s)", __FUNCTION__,
+ strerror(errno));
+ ret = GENLOCK_FAILURE;
}
+
+ // Close the fd and reset the parameters.
+ close_genlock_fd_and_handle(hnd->genlockPrivFd, hnd->genlockHandle);
#endif
return ret;
}
@@ -213,29 +207,27 @@ genlock_status_t genlock_attach_lock(native_handle_t *buffer_handle)
return GENLOCK_FAILURE;
}
- private_handle_t *hnd = reinterpret_cast<private_handle_t*>(buffer_handle);
- if ((hnd->flags & private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED) == 0) {
- // Open the genlock device
- int fd = open(GENLOCK_DEVICE, O_RDWR);
- if (fd < 0) {
- LOGE("%s: open genlock device failed (err=%s)", __FUNCTION__,
- strerror(errno));
- return GENLOCK_FAILURE;
- }
-
- // Attach the local handle to an existing lock
- genlock_lock lock;
- lock.fd = hnd->genlockHandle;
- if (ioctl(fd, GENLOCK_IOC_ATTACH, &lock)) {
- LOGE("%s: GENLOCK_IOC_ATTACH failed (err=%s)", __FUNCTION__,
- strerror(errno));
- close_genlock_fd_and_handle(fd, lock.fd);
- ret = GENLOCK_FAILURE;
- }
+ // Open the genlock device
+ int fd = open(GENLOCK_DEVICE, O_RDWR);
+ if (fd < 0) {
+ LOGE("%s: open genlock device failed (err=%s)", __FUNCTION__,
+ strerror(errno));
+ return GENLOCK_FAILURE;
+ }
- // Store the relavant information in the handle
- hnd->genlockPrivFd = fd;
+ // Attach the local handle to an existing lock
+ private_handle_t *hnd = reinterpret_cast<private_handle_t*>(buffer_handle);
+ genlock_lock lock;
+ lock.fd = hnd->genlockHandle;
+ if (ioctl(fd, GENLOCK_IOC_ATTACH, &lock)) {
+ LOGE("%s: GENLOCK_IOC_ATTACH failed (err=%s)", __FUNCTION__,
+ strerror(errno));
+ close_genlock_fd_and_handle(fd, lock.fd);
+ ret = GENLOCK_FAILURE;
}
+
+ // Store the relavant information in the handle
+ hnd->genlockPrivFd = fd;
#endif
return ret;
}
@@ -307,22 +299,20 @@ genlock_status_t genlock_wait(native_handle_t *buffer_handle, int timeout) {
}
private_handle_t *hnd = reinterpret_cast<private_handle_t*>(buffer_handle);
- if ((hnd->flags & private_handle_t::PRIV_FLAGS_UNSYNCHRONIZED) == 0) {
- if (hnd->genlockPrivFd < 0) {
- LOGE("%s: the lock is invalid", __FUNCTION__);
- return GENLOCK_FAILURE;
- }
+ if (hnd->genlockPrivFd < 0) {
+ LOGE("%s: the lock is invalid", __FUNCTION__);
+ return GENLOCK_FAILURE;
+ }
- if (0 == timeout)
- LOGW("%s: timeout = 0", __FUNCTION__);
+ if (0 == timeout)
+ LOGW("%s: timeout = 0", __FUNCTION__);
- genlock_lock lock;
- lock.fd = hnd->genlockHandle;
- lock.timeout = timeout;
- if (ioctl(hnd->genlockPrivFd, GENLOCK_IOC_WAIT, &lock)) {
- LOGE("%s: GENLOCK_IOC_WAIT failed (err=%s)", __FUNCTION__, strerror(errno));
- return GENLOCK_FAILURE;
- }
+ genlock_lock lock;
+ lock.fd = hnd->genlockHandle;
+ lock.timeout = timeout;
+ if (ioctl(hnd->genlockPrivFd, GENLOCK_IOC_WAIT, &lock)) {
+ LOGE("%s: GENLOCK_IOC_WAIT failed (err=%s)", __FUNCTION__, strerror(errno));
+ return GENLOCK_FAILURE;
}
#endif
return GENLOCK_NO_ERROR;
diff --git a/libgralloc/alloc_controller.cpp b/libgralloc/alloc_controller.cpp
index a00cae7..3b1a694 100644
--- a/libgralloc/alloc_controller.cpp
+++ b/libgralloc/alloc_controller.cpp
@@ -332,8 +332,7 @@ sp<IMemAlloc> PmemAshmemController::getAllocator(int flags)
return memalloc;
}
-size_t getBufferSizeAndDimensions(int width, int height, int format,
- int& alignedw, int &alignedh)
+size_t getBufferSizeAndDimensions(int width, int height, int format, int &alignedw, int &alignedh)
{
size_t size;
diff --git a/libgralloc/gr.h b/libgralloc/gr.h
index cc36d9a..8bd5530 100644
--- a/libgralloc/gr.h
+++ b/libgralloc/gr.h
@@ -50,8 +50,7 @@ inline size_t ALIGN(size_t x, size_t align) {
int mapFrameBufferLocked(struct private_module_t* module);
int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd);
-size_t getBufferSizeAndDimensions(int width, int height, int format,
- int& alignedw, int &alignedh);
+size_t getBufferSizeAndDimensions(int width, int height, int format, int &alignedw, int &alignedh);
int decideBufferHandlingMechanism(int format, const char *compositionUsed,
int hasBlitEngine, int *needConversion,
--
1.7.5.4