OSDN Git Service

minigbm: cros_gralloc: fix modifier serialization/de-serialization
authorGurchetan Singh <gurchetansingh@chromium.org>
Mon, 20 Mar 2017 22:00:29 +0000 (15:00 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Fri, 31 Mar 2017 17:40:28 +0000 (10:40 -0700)
We were only filling up the first five entries of the modifier array
in the handle, and we were doing it incorrectly. Fix this.

BUG=chromium:616275
TEST=compiles

Change-Id: I435f88db1b16af919081122a502cbe7d7fc9e3d9
Reviewed-on: https://chromium-review.googlesource.com/457289
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
cros_gralloc/cros_alloc_device.cc
cros_gralloc/cros_gralloc_module.cc

index dbb409c..10f30e7 100644 (file)
@@ -79,8 +79,8 @@ static struct cros_gralloc_handle *cros_gralloc_handle_from_bo(struct bo *bo)
                hnd->sizes[p] = drv_bo_get_plane_size(bo, p);
 
                mod = drv_bo_get_plane_format_modifier(bo, p);
-               hnd->format_modifiers[p] = static_cast<uint32_t>(mod >> 32);
-               hnd->format_modifiers[p + 1] = static_cast<uint32_t>(mod);
+               hnd->format_modifiers[2 * p] = static_cast<uint32_t>(mod >> 32);
+               hnd->format_modifiers[2 * p + 1] = static_cast<uint32_t>(mod);
        }
 
        hnd->width = drv_bo_get_width(bo);
index eef3614..7123da2 100644 (file)
@@ -80,23 +80,21 @@ static int cros_gralloc_register_buffer(struct gralloc_module_t const *module,
                bo->refcount++;
        } else {
                struct drv_import_fd_data data;
-               size_t num_planes = drv_num_planes_from_format(hnd->format);
-
                data.format = hnd->format;
                data.width = hnd->width;
                data.height = hnd->height;
-               for (size_t p = 0; p < num_planes; p++) {
-                       data.fds[p] = hnd->fds[p];
-                       data.strides[p] = hnd->strides[p];
-                       data.offsets[p] = hnd->offsets[p];
-                       data.sizes[p] = hnd->sizes[p];
-                       data.format_modifiers[p] = static_cast<uint64_t>(hnd->format_modifiers[p])
-                                                  << 32;
-                       data.format_modifiers[p] |= hnd->format_modifiers[p + 1];
+
+               memcpy(data.fds, hnd->fds, sizeof(data.fds));
+               memcpy(data.strides, hnd->strides, sizeof(data.strides));
+               memcpy(data.offsets, hnd->offsets, sizeof(data.offsets));
+               memcpy(data.sizes, hnd->sizes, sizeof(data.sizes));
+               for (uint32_t p = 0; p < DRV_MAX_PLANES; p++) {
+                       data.format_modifiers[p] =
+                           static_cast<uint64_t>(hnd->format_modifiers[2 * p]) << 32;
+                       data.format_modifiers[p] |= hnd->format_modifiers[2 * p + 1];
                }
 
                bo = new cros_gralloc_bo();
-
                bo->bo = drv_bo_import(mod->drv, &data);
                if (!bo->bo) {
                        delete bo;