OSDN Git Service

minigbm: Use the stride value returned by mapImage
authorSatyajit Sahu <satyajit.sahu@amd.com>
Thu, 3 May 2018 11:05:24 +0000 (16:35 +0530)
committerchrome-bot <chrome-bot@chromium.org>
Thu, 10 May 2018 22:09:50 +0000 (15:09 -0700)
mapImage can return a different stride value. This value must be
used for the mapped address.

BUG=b:38152101 b:79346377
TEST=graphics_Sanity autotest passed

Change-Id: Ie0eb716291366ae6a047d704f66d24ec41738713
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1041369
Commit-Ready: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
dri.c
drv.c
drv.h
gbm.c

diff --git a/dri.c b/dri.c
index 8ca00c6..ae491bb 100644 (file)
--- a/dri.c
+++ b/dri.c
@@ -260,11 +260,11 @@ int dri_bo_destroy(struct bo *bo)
 void *dri_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags)
 {
        struct dri_driver *dri = bo->drv->priv;
-       int stride;
 
        /* GBM flags and DRI flags are the same. */
-       vma->addr = dri->image_extension->mapImage(dri->context, bo->priv, 0, 0, bo->width,
-                                                  bo->height, map_flags, &stride, &vma->priv);
+       vma->addr =
+           dri->image_extension->mapImage(dri->context, bo->priv, 0, 0, bo->width, bo->height,
+                                          map_flags, (int *)&vma->map_strides[plane], &vma->priv);
        if (!vma->addr)
                return MAP_FAILED;
 
diff --git a/drv.c b/drv.c
index f6420e5..bc1f782 100644 (file)
--- a/drv.c
+++ b/drv.c
@@ -440,6 +440,7 @@ void *drv_bo_map(struct bo *bo, const struct rectangle *rect, uint32_t map_flags
        }
 
        mapping.vma = calloc(1, sizeof(*mapping.vma));
+       memcpy(mapping.vma->map_strides, bo->strides, sizeof(mapping.vma->map_strides));
        addr = bo->drv->backend->bo_map(bo, mapping.vma, plane, map_flags);
        if (addr == MAP_FAILED) {
                *map_data = NULL;
diff --git a/drv.h b/drv.h
index 67d763e..9ca77d3 100644 (file)
--- a/drv.h
+++ b/drv.h
@@ -84,6 +84,7 @@ struct vma {
        uint32_t handle;
        uint32_t map_flags;
        int32_t refcount;
+       uint32_t map_strides[DRV_MAX_PLANES];
        void *priv;
 };
 
diff --git a/gbm.c b/gbm.c
index a720461..c12c269 100644 (file)
--- a/gbm.c
+++ b/gbm.c
@@ -233,7 +233,6 @@ PUBLIC void *gbm_bo_map(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t widt
        if (!bo || width == 0 || height == 0 || !stride || !map_data)
                return NULL;
 
-       *stride = gbm_bo_get_plane_stride(bo, plane);
        map_flags = (transfer_flags & GBM_BO_TRANSFER_READ) ? BO_MAP_READ : BO_MAP_NONE;
        map_flags |= (transfer_flags & GBM_BO_TRANSFER_WRITE) ? BO_MAP_WRITE : BO_MAP_NONE;
 
@@ -241,7 +240,9 @@ PUBLIC void *gbm_bo_map(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t widt
        if (addr == MAP_FAILED)
                return MAP_FAILED;
 
-       offset = gbm_bo_get_plane_stride(bo, plane) * rect.y;
+       *stride = ((struct mapping *)*map_data)->vma->map_strides[plane];
+
+       offset = *stride * rect.y;
        offset += drv_stride_from_format(bo->gbm_format, rect.x, plane);
        return (void *)((uint8_t *)addr + offset);
 }