hardware/libhardware
Revisión | e5818bab949cba422e54fac1753826a4237ca11f (tree) |
---|---|
Tiempo | 2010-04-16 19:36:19 |
Autor | Yi Sun <beyounn@gmai...> |
Commiter | 黃志偉 |
fixed one deadlock in init_pmem_area
Also add a hack to make the gralloc to use ashmem.
@@ -134,7 +134,12 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, | ||
134 | 134 | // If we have only one buffer, we never use page-flipping. Instead, |
135 | 135 | // we return a regular buffer which will be memcpy'ed to the main |
136 | 136 | // screen when post is called. |
137 | - int newUsage = (usage & ~GRALLOC_USAGE_HW_FB) | GRALLOC_USAGE_HW_2D; | |
137 | + /* | |
138 | + * Yi added: | |
139 | + * This is only a hack to make the alloc_buffer function to use | |
140 | + * ashmem,since pmem is not available for now | |
141 | + */ | |
142 | + int newUsage = (usage & ~GRALLOC_USAGE_HW_FB);// | GRALLOC_USAGE_HW_2D; | |
138 | 143 | return gralloc_alloc_buffer(dev, bufferSize, newUsage, pHandle); |
139 | 144 | } |
140 | 145 |
@@ -168,11 +173,8 @@ static int gralloc_alloc_framebuffer_locked(alloc_device_t* dev, | ||
168 | 173 | static int gralloc_alloc_framebuffer(alloc_device_t* dev, |
169 | 174 | size_t size, int usage, buffer_handle_t* pHandle) |
170 | 175 | { |
171 | - private_module_t* m = reinterpret_cast<private_module_t*>( | |
172 | - dev->common.module); | |
173 | - pthread_mutex_lock(&m->lock); | |
176 | + | |
174 | 177 | int err = gralloc_alloc_framebuffer_locked(dev, size, usage, pHandle); |
175 | - pthread_mutex_unlock(&m->lock); | |
176 | 178 | return err; |
177 | 179 | } |
178 | 180 |
@@ -214,7 +216,6 @@ static int init_pmem_area_locked(private_module_t* m) | ||
214 | 216 | |
215 | 217 | static int init_pmem_area(private_module_t* m) |
216 | 218 | { |
217 | - pthread_mutex_lock(&m->lock); | |
218 | 219 | int err = m->pmem_master; |
219 | 220 | if (err == -1) { |
220 | 221 | // first time, try to initialize pmem |
@@ -228,7 +229,6 @@ static int init_pmem_area(private_module_t* m) | ||
228 | 229 | // pmem OK |
229 | 230 | err = 0; |
230 | 231 | } |
231 | - pthread_mutex_unlock(&m->lock); | |
232 | 232 | return err; |
233 | 233 | } |
234 | 234 |
@@ -390,12 +390,15 @@ static int gralloc_alloc(alloc_device_t* dev, | ||
390 | 390 | } |
391 | 391 | |
392 | 392 | int err; |
393 | + private_module_t* m = reinterpret_cast<private_module_t*>( | |
394 | + dev->common.module); | |
395 | + pthread_mutex_lock(&m->lock); | |
393 | 396 | if (usage & GRALLOC_USAGE_HW_FB) { |
394 | 397 | err = gralloc_alloc_framebuffer(dev, size, usage, pHandle); |
395 | 398 | } else { |
396 | 399 | err = gralloc_alloc_buffer(dev, size, usage, pHandle); |
397 | 400 | } |
398 | - | |
401 | + pthread_mutex_unlock(&m->lock); | |
399 | 402 | if (err < 0) { |
400 | 403 | return err; |
401 | 404 | } |