X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=cros_gralloc%2Fcros_gralloc_driver.cc;h=615cb6152cbf1045cfbd17df7e9a6726944cf2b5;hb=311ab3c38550652b52c559722460c9bb6284d6fa;hp=946098d507a1f4f5061a81b68262f156bb23e2db;hpb=590edb2a8e942904b37c814e7eef2854ce76fc9a;p=android-x86%2Fexternal-minigbm.git diff --git a/cros_gralloc/cros_gralloc_driver.cc b/cros_gralloc/cros_gralloc_driver.cc index 946098d..615cb61 100644 --- a/cros_gralloc/cros_gralloc_driver.cc +++ b/cros_gralloc/cros_gralloc_driver.cc @@ -7,6 +7,8 @@ #include "cros_gralloc_driver.h" #include "../util.h" +#include "i915_private_android.h" + #include #include #include @@ -95,8 +97,13 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto struct cros_gralloc_handle *hnd; resolved_format = drv_resolve_format(drv_, descriptor->drm_format, descriptor->use_flags); - bo = drv_bo_create(drv_, descriptor->width, descriptor->height, resolved_format, - descriptor->use_flags); + if (descriptor->modifier == 0) { + bo = drv_bo_create(drv_, descriptor->width, descriptor->height, resolved_format, + descriptor->use_flags); + } else { + bo = drv_bo_create_with_modifiers(drv_, descriptor->width, descriptor->height, + resolved_format, &descriptor->modifier, 1); + } if (!bo) { cros_gralloc_error("Failed to create bo."); return -ENOMEM; @@ -124,6 +131,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto hnd->fds[plane] = drv_bo_get_plane_fd(bo, plane); hnd->strides[plane] = drv_bo_get_plane_stride(bo, plane); hnd->offsets[plane] = drv_bo_get_plane_offset(bo, plane); + hnd->sizes[plane] = drv_bo_get_plane_size(bo, plane); mod = drv_bo_get_plane_format_modifier(bo, plane); hnd->format_modifiers[2 * plane] = static_cast(mod >> 32); @@ -133,11 +141,16 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto hnd->width = drv_bo_get_width(bo); hnd->height = drv_bo_get_height(bo); hnd->format = drv_bo_get_format(bo); + hnd->tiling_mode = drv_bo_get_stride_or_tiling(bo); hnd->use_flags[0] = static_cast(descriptor->use_flags >> 32); hnd->use_flags[1] = static_cast(descriptor->use_flags); hnd->pixel_stride = drv_bo_get_stride_in_pixels(bo); hnd->magic = cros_gralloc_magic; - hnd->droid_format = descriptor->droid_format; + int32_t format = i915_private_invert_format(hnd->format); + if (format == 0) { + format = descriptor->droid_format; + } + hnd->droid_format = format; hnd->usage = descriptor->producer_usage; hnd->producer_usage = descriptor->producer_usage; hnd->consumer_usage = descriptor->consumer_usage; @@ -145,7 +158,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto id = drv_bo_get_plane_handle(bo, 0).u32; auto buffer = new cros_gralloc_buffer(id, bo, hnd); - std::lock_guard lock(mutex_); + SCOPED_SPIN_LOCK(mutex_); buffers_.emplace(id, buffer); handles_.emplace(hnd, std::make_pair(buffer, 1)); *out_handle = &hnd->base; @@ -155,7 +168,7 @@ int32_t cros_gralloc_driver::allocate(const struct cros_gralloc_buffer_descripto int32_t cros_gralloc_driver::retain(buffer_handle_t handle) { uint32_t id; - std::lock_guard lock(mutex_); + SCOPED_SPIN_LOCK(mutex_); auto hnd = cros_gralloc_convert_handle(handle); if (!hnd) { @@ -212,7 +225,7 @@ int32_t cros_gralloc_driver::retain(buffer_handle_t handle) int32_t cros_gralloc_driver::release(buffer_handle_t handle) { - std::lock_guard lock(mutex_); + SCOPED_SPIN_LOCK(mutex_); auto hnd = cros_gralloc_convert_handle(handle); if (!hnd) { @@ -244,7 +257,7 @@ int32_t cros_gralloc_driver::lock(buffer_handle_t handle, int32_t acquire_fence, if (ret) return ret; - std::lock_guard lock(mutex_); + SCOPED_SPIN_LOCK(mutex_); auto hnd = cros_gralloc_convert_handle(handle); if (!hnd) { cros_gralloc_error("Invalid handle."); @@ -262,7 +275,7 @@ int32_t cros_gralloc_driver::lock(buffer_handle_t handle, int32_t acquire_fence, int32_t cros_gralloc_driver::unlock(buffer_handle_t handle, int32_t *release_fence) { - std::lock_guard lock(mutex_); + SCOPED_SPIN_LOCK(mutex_);; auto hnd = cros_gralloc_convert_handle(handle); if (!hnd) { @@ -288,7 +301,7 @@ int32_t cros_gralloc_driver::unlock(buffer_handle_t handle, int32_t *release_fen int32_t cros_gralloc_driver::get_backing_store(buffer_handle_t handle, uint64_t *out_store) { - std::lock_guard lock(mutex_); + SCOPED_SPIN_LOCK(mutex_); auto hnd = cros_gralloc_convert_handle(handle); if (!hnd) {