{
struct _tbm_surface *surf;
tbm_bo_handle bo_handles[4];
+ int num_bos = 0;
+ tbm_bo bos[4];
+ int planes_bo_idx[TBM_SURF_PLANE_MAX];
int i, j;
_tbm_surface_mutex_lock();
info->size = surf->info.size;
info->num_planes = surf->info.num_planes;
+ for (i = 0; i < surf->info.num_planes; i++) {
+ info->planes[i].size = surf->info.planes[i].size;
+ info->planes[i].offset = surf->info.planes[i].offset;
+ info->planes[i].stride = surf->info.planes[i].stride;
+ planes_bo_idx[i] = surf->planes_bo_idx[i];
+ }
+
+ for (i = 0; i < surf->num_bos; i++)
+ bos[i] = surf->bos[i];
+
+ num_bos = surf->num_bos;
+
if (map == 1) {
- for (i = 0; i < surf->num_bos; i++) {
- _tbm_surface_mutex_unlock();
- bo_handles[i] = tbm_bo_map(surf->bos[i], TBM_DEVICE_CPU, opt);
- _tbm_surface_mutex_lock();
+ _tbm_surface_mutex_unlock();
+ for (i = 0; i < num_bos; i++) {
+ bo_handles[i] = tbm_bo_map(bos[i], TBM_DEVICE_CPU, opt);
if (bo_handles[i].ptr == NULL) {
for (j = 0; j < i; j++)
- tbm_bo_unmap(surf->bos[j]);
+ tbm_bo_unmap(bos[j]);
TBM_LOG_E("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
- _tbm_surface_mutex_unlock();
return 0;
}
}
+ _tbm_surface_mutex_lock();
} else {
- for (i = 0; i < surf->num_bos; i++) {
- bo_handles[i] = tbm_bo_get_handle(surf->bos[i], TBM_DEVICE_CPU);
+ for (i = 0; i < num_bos; i++) {
+ bo_handles[i] = tbm_bo_get_handle(bos[i], TBM_DEVICE_CPU);
if (bo_handles[i].ptr == NULL) {
TBM_LOG_E("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
_tbm_surface_mutex_unlock();
}
}
- for (i = 0; i < surf->info.num_planes; i++) {
- info->planes[i].size = surf->info.planes[i].size;
- info->planes[i].offset = surf->info.planes[i].offset;
- info->planes[i].stride = surf->info.planes[i].stride;
-
- if (bo_handles[surf->planes_bo_idx[i]].ptr)
- info->planes[i].ptr = bo_handles[surf->planes_bo_idx[i]].ptr +
- surf->info.planes[i].offset;
+ for (i = 0; i < info->num_planes; i++) {
+ if (bo_handles[planes_bo_idx[i]].ptr)
+ info->planes[i].ptr = bo_handles[planes_bo_idx[i]].ptr + info->planes[i].offset;
}
TBM_TRACE("tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
QUEUE_NODE_TYPE_ACQUIRE)) {
_tbm_surf_queue_mutex_unlock();
pthread_cond_wait(&surface_queue->free_cond, &surface_queue->lock);
- _tbm_surf_queue_mutex_lock();
-
- if (!_tbm_surface_queue_is_valid(surface_queue)) {
- TBM_LOG_E("surface_queue:%p is invalid", surface_queue);
- pthread_mutex_unlock(&surface_queue->lock);
- _tbm_surf_queue_mutex_unlock();
- return 0;
- }
-
pthread_mutex_unlock(&surface_queue->lock);
- _tbm_surf_queue_mutex_unlock();
return 1;
}
QUEUE_NODE_TYPE_DEQUEUE)) {
_tbm_surf_queue_mutex_unlock();
pthread_cond_wait(&surface_queue->dirty_cond, &surface_queue->lock);
- _tbm_surf_queue_mutex_lock();
-
- if (!_tbm_surface_queue_is_valid(surface_queue)) {
- TBM_LOG_E("surface_queue:%p is invalid", surface_queue);
- pthread_mutex_unlock(&surface_queue->lock);
- _tbm_surf_queue_mutex_unlock();
- return 0;
- }
-
pthread_mutex_unlock(&surface_queue->lock);
- _tbm_surf_queue_mutex_unlock();
return 1;
}