OSDN Git Service

gralloc0_register_buffer: initialize gralloc0 when needed
[android-x86/external-minigbm.git] / cros_gralloc / cros_gralloc_buffer.cc
index b6da605..c1c8764 100644 (file)
@@ -7,11 +7,12 @@
 #include "cros_gralloc_buffer.h"
 
 #include <assert.h>
+#include <errno.h>
 #include <sys/mman.h>
 
-cros_gralloc_buffer::cros_gralloc_buffer(uint32_t id, struct bo *acquirebo_,
+cros_gralloc_buffer::cros_gralloc_buffer(uint32_t id, struct bo *acquire_bo,
                                         struct cros_gralloc_handle *acquire_handle)
-    : id_(id), bo_(acquirebo_), hnd_(acquire_handle), refcount_(1), lockcount_(0)
+    : id_(id), bo_(acquire_bo), hnd_(acquire_handle), refcount_(1), lockcount_(0)
 {
        assert(bo_);
        num_planes_ = drv_bo_get_num_planes(bo_);
@@ -44,7 +45,7 @@ int32_t cros_gralloc_buffer::decrease_refcount()
        return --refcount_;
 }
 
-int32_t cros_gralloc_buffer::lock(uint64_t flags, uint8_t *addr[DRV_MAX_PLANES])
+int32_t cros_gralloc_buffer::lock(uint32_t map_flags, uint8_t *addr[DRV_MAX_PLANES])
 {
        void *vaddr = nullptr;
 
@@ -59,12 +60,13 @@ int32_t cros_gralloc_buffer::lock(uint64_t flags, uint8_t *addr[DRV_MAX_PLANES])
                return -EINVAL;
        }
 
-       if (flags) {
+       if (map_flags) {
                if (lock_data_[0]) {
+                       drv_bo_invalidate(bo_, lock_data_[0]);
                        vaddr = lock_data_[0]->addr;
                } else {
                        vaddr = drv_bo_map(bo_, 0, 0, drv_bo_get_width(bo_), drv_bo_get_height(bo_),
-                                          BO_TRANSFER_READ_WRITE, &lock_data_[0], 0);
+                                          map_flags, &lock_data_[0], 0);
                }
 
                if (vaddr == MAP_FAILED) {