From ecbc89179e0ddc86a37e9ef13e0708c0ca6536de Mon Sep 17 00:00:00 2001 From: Dawn Han Date: Tue, 14 Feb 2023 19:40:55 +0000 Subject: [PATCH] minigbm: Remove plane in bo_map Remove the parameter to align with upstream gbm. For some places that use the number of planes. The number is 1. The multi-planar formats are being allocated into a single plane, and minigbm exynos backend is dropped. So we can just set the plane index to 0 if needed. Fixed the format in i915.c. Bug=b:266776512 TEST=camera works after deploying the change #strongbad TEST=camera works after deploying the change #corsola Change-Id: I0880917754c01b9d0f27d21f3c42d87f00a09f50 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4249501 Commit-Queue: Dawn Han Tested-by: Dawn Han Reviewed-by: Yiwei Zhang Reviewed-by: Chia-I Wu --- amdgpu.c | 6 +++--- drv.c | 2 +- drv_helpers.c | 7 +++---- drv_helpers.h | 2 +- drv_priv.h | 2 +- i915.c | 10 +++++----- mediatek.c | 2 +- msm.c | 2 +- rockchip.c | 2 +- vc4.c | 2 +- virtgpu_cross_domain.c | 2 +- virtgpu_virgl.c | 8 ++++---- 12 files changed, 23 insertions(+), 24 deletions(-) diff --git a/amdgpu.c b/amdgpu.c index bcd215c..6db84c7 100644 --- a/amdgpu.c +++ b/amdgpu.c @@ -663,19 +663,19 @@ static int amdgpu_destroy_bo(struct bo *bo) return drv_gem_bo_destroy(bo); } -static void *amdgpu_map_bo(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *amdgpu_map_bo(struct bo *bo, struct vma *vma, uint32_t map_flags) { void *addr = MAP_FAILED; int ret; union drm_amdgpu_gem_mmap gem_map = { { 0 } }; struct drm_amdgpu_gem_create_in bo_info = { 0 }; struct drm_amdgpu_gem_op gem_op = { 0 }; - uint32_t handle = bo->handles[plane].u32; + uint32_t handle = bo->handles[0].u32; struct amdgpu_linear_vma_priv *priv = NULL; struct amdgpu_priv *drv_priv; if (bo->priv) - return dri_bo_map(bo, vma, plane, map_flags); + return dri_bo_map(bo, vma, 0, map_flags); drv_priv = bo->drv->priv; gem_op.handle = handle; diff --git a/drv.c b/drv.c index 9a6def5..cbd7b4b 100644 --- a/drv.c +++ b/drv.c @@ -523,7 +523,7 @@ void *drv_bo_map(struct bo *bo, const struct rectangle *rect, uint32_t map_flags } memcpy(mapping.vma->map_strides, bo->meta.strides, sizeof(mapping.vma->map_strides)); - addr = drv->backend->bo_map(bo, mapping.vma, plane, map_flags); + addr = drv->backend->bo_map(bo, mapping.vma, map_flags); if (addr == MAP_FAILED) { *map_data = NULL; free(mapping.vma); diff --git a/drv_helpers.c b/drv_helpers.c index f4df4df..3cb694f 100644 --- a/drv_helpers.c +++ b/drv_helpers.c @@ -459,14 +459,14 @@ int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data) return 0; } -void *drv_dumb_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +void *drv_dumb_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret; size_t i; struct drm_mode_map_dumb map_dumb; memset(&map_dumb, 0, sizeof(map_dumb)); - map_dumb.handle = bo->handles[plane].u32; + map_dumb.handle = bo->handles[0].u32; ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MODE_MAP_DUMB, &map_dumb); if (ret) { @@ -475,8 +475,7 @@ void *drv_dumb_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map } for (i = 0; i < bo->meta.num_planes; i++) - if (bo->handles[i].u32 == bo->handles[plane].u32) - vma->length += bo->meta.sizes[i]; + vma->length += bo->meta.sizes[i]; return mmap(0, vma->length, drv_get_prot(map_flags), MAP_SHARED, bo->drv->fd, map_dumb.offset); diff --git a/drv_helpers.h b/drv_helpers.h index edb69bf..c4a9e2d 100644 --- a/drv_helpers.h +++ b/drv_helpers.h @@ -31,7 +31,7 @@ int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32 int drv_dumb_bo_destroy(struct bo *bo); int drv_gem_bo_destroy(struct bo *bo); int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data); -void *drv_dumb_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags); +void *drv_dumb_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags); int drv_bo_munmap(struct bo *bo, struct vma *vma); int drv_get_prot(uint32_t map_flags); void drv_add_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata, diff --git a/drv_priv.h b/drv_priv.h index 719e392..8650c24 100644 --- a/drv_priv.h +++ b/drv_priv.h @@ -91,7 +91,7 @@ struct backend { /* Called on free if this bo is the last object referencing the contained GEM BOs */ int (*bo_destroy)(struct bo *bo); int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data); - void *(*bo_map)(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags); + void *(*bo_map)(struct bo *bo, struct vma *vma, uint32_t map_flags); int (*bo_unmap)(struct bo *bo, struct vma *vma); int (*bo_invalidate)(struct bo *bo, struct mapping *mapping); int (*bo_flush)(struct bo *bo, struct mapping *mapping); diff --git a/i915.c b/i915.c index 2f6d07b..9fd992c 100644 --- a/i915.c +++ b/i915.c @@ -813,7 +813,7 @@ static int i915_bo_import(struct bo *bo, struct drv_import_fd_data *data) return 0; } -static void *i915_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *i915_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret; void *addr = MAP_FAILED; @@ -833,8 +833,8 @@ static void *i915_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t /* Get the fake offset back */ ret = drmIoctl(bo->drv->fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &gem_map); if (ret == 0) - addr = mmap(0, bo->meta.total_size, drv_get_prot(map_flags), MAP_SHARED, - bo->drv->fd, gem_map.offset); + addr = mmap(0, bo->meta.total_size, drv_get_prot(map_flags), + MAP_SHARED, bo->drv->fd, gem_map.offset); } else { struct drm_i915_gem_mmap gem_map = { 0 }; /* TODO(b/118799155): We don't seem to have a good way to @@ -846,8 +846,8 @@ static void *i915_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t * Renderscript and camera use cases, as they're * performance-sensitive. */ if ((bo->meta.use_flags & BO_USE_SCANOUT) && - !(bo->meta.use_flags & - (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))) + !(bo->meta.use_flags & + (BO_USE_RENDERSCRIPT | BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE))) gem_map.flags = I915_MMAP_WC; gem_map.handle = bo->handles[0].u32; diff --git a/mediatek.c b/mediatek.c index f161b7d..00dab88 100644 --- a/mediatek.c +++ b/mediatek.c @@ -266,7 +266,7 @@ static int mediatek_bo_create(struct bo *bo, uint32_t width, uint32_t height, ui ARRAY_SIZE(modifiers)); } -static void *mediatek_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *mediatek_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret, prime_fd; struct drm_mtk_gem_map_off gem_map = { 0 }; diff --git a/msm.c b/msm.c index 3a02f5d..17650dd 100644 --- a/msm.c +++ b/msm.c @@ -352,7 +352,7 @@ static int msm_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_ return msm_bo_create_for_modifier(bo, width, height, format, combo->metadata.modifier); } -static void *msm_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *msm_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret; struct drm_msm_gem_info req = { 0 }; diff --git a/rockchip.c b/rockchip.c index 17478f3..97ede89 100644 --- a/rockchip.c +++ b/rockchip.c @@ -192,7 +192,7 @@ static int rockchip_bo_create(struct bo *bo, uint32_t width, uint32_t height, ui ARRAY_SIZE(modifiers)); } -static void *rockchip_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *rockchip_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret; struct rockchip_private_map_data *priv; diff --git a/vc4.c b/vc4.c index 48f0870..430e818 100644 --- a/vc4.c +++ b/vc4.c @@ -105,7 +105,7 @@ static int vc4_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint32_t return vc4_bo_create_for_modifier(bo, width, height, format, modifier); } -static void *vc4_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *vc4_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret; struct drm_vc4_mmap_bo bo_map = { 0 }; diff --git a/virtgpu_cross_domain.c b/virtgpu_cross_domain.c index b94a4ae..45b5580 100644 --- a/virtgpu_cross_domain.c +++ b/virtgpu_cross_domain.c @@ -410,7 +410,7 @@ static int cross_domain_bo_create(struct bo *bo, uint32_t width, uint32_t height return 0; } -static void *cross_domain_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *cross_domain_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret; struct drm_virtgpu_map gem_map = { 0 }; diff --git a/virtgpu_virgl.c b/virtgpu_virgl.c index 8f476b5..f3e55c7 100644 --- a/virtgpu_virgl.c +++ b/virtgpu_virgl.c @@ -504,7 +504,7 @@ static int virgl_3d_bo_create(struct bo *bo, uint32_t width, uint32_t height, ui return 0; } -static void *virgl_3d_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *virgl_3d_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { int ret; struct drm_virtgpu_map gem_map = { 0 }; @@ -796,12 +796,12 @@ static int virgl_bo_destroy(struct bo *bo) return drv_dumb_bo_destroy(bo); } -static void *virgl_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags) +static void *virgl_bo_map(struct bo *bo, struct vma *vma, uint32_t map_flags) { if (params[param_3d].value) - return virgl_3d_bo_map(bo, vma, plane, map_flags); + return virgl_3d_bo_map(bo, vma, map_flags); else - return drv_dumb_bo_map(bo, vma, plane, map_flags); + return drv_dumb_bo_map(bo, vma, map_flags); } static bool is_arc_screen_capture_bo(struct bo *bo)