diff options
author | Brian Norris <briannorris@chromium.org> | 2022-01-13 17:21:40 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-07 04:56:47 +0000 |
commit | 365e5b4a9efe758236bc7bd43262bc32508c4171 (patch) | |
tree | 511435097262966b4839e6bd8a8ae664394403b8 | |
parent | d73fa7ff377919d94d4ed675cc91a070f0631548 (diff) | |
download | minigbm-365e5b4a9efe758236bc7bd43262bc32508c4171.tar.gz |
minigbm: rockchip: Support upstream AFBC modifier
BUG=b:214459790
TEST=boot to ui
TEST=null_platform_test, with modifications for choosing CRTC (big VOP)
and AFBC modifier; e.g.,:
`null_platform_test \
--crtc_index 1 \
--modifier \
'DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16|AFBC_FORMAT_MOD_SPARSE|AFBC_FORMAT_MOD_YTR)'`
Change-Id: I771d223ada1d7e6254855d28d998c01e455e72ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3462927
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Commit-Queue: Brian Norris <briannorris@chromium.org>
-rw-r--r-- | rockchip.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -6,6 +6,7 @@ #ifdef DRV_ROCKCHIP +#include <drm_fourcc.h> #include <errno.h> #include <inttypes.h> #include <rockchip_drm.h> @@ -18,6 +19,10 @@ #include "drv_priv.h" #include "util.h" +#define DRM_FORMAT_MOD_ROCKCHIP_AFBC \ + DRM_FORMAT_MOD_ARM_AFBC(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE | \ + AFBC_FORMAT_MOD_YTR) + struct rockchip_private_map_data { void *cached_addr; void *gem_addr; @@ -30,7 +35,8 @@ static const uint32_t scanout_render_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORM static const uint32_t texture_only_formats[] = { DRM_FORMAT_NV12, DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID }; -static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, uint32_t format) +static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, + uint64_t modifier) { /* We've restricted ourselves to four bytes per pixel. */ const uint32_t pixel_size = 4; @@ -69,7 +75,7 @@ static int afbc_bo_from_format(struct bo *bo, uint32_t width, uint32_t height, u bo->meta.total_size = total_size; - bo->meta.format_modifier = DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC; + bo->meta.format_modifier = modifier; return 0; } @@ -113,6 +119,14 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint int ret; size_t plane; struct drm_rockchip_gem_create gem_create = { 0 }; + uint64_t afbc_modifier; + + if (drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_ROCKCHIP_AFBC)) + afbc_modifier = DRM_FORMAT_MOD_ROCKCHIP_AFBC; + else if (drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC)) + afbc_modifier = DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC; + else + afbc_modifier = 0; if (format == DRM_FORMAT_NV12) { uint32_t w_mbs = DIV_ROUND_UP(width, 16); @@ -127,12 +141,10 @@ static int rockchip_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint * driver to store motion vectors. */ bo->meta.total_size += w_mbs * h_mbs * 128; - } else if (width <= 2560 && - drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC) && - bo->drv->compression) { + } else if (width <= 2560 && afbc_modifier && bo->drv->compression) { /* If the caller has decided they can use AFBC, always * pick that */ - afbc_bo_from_format(bo, width, height, format); + afbc_bo_from_format(bo, width, height, format, afbc_modifier); } else { if (!drv_has_modifier(modifiers, count, DRM_FORMAT_MOD_LINEAR)) { errno = EINVAL; @@ -188,7 +200,8 @@ static void *rockchip_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint3 /* We can only map buffers created with SW access flags, which should * have no modifiers (ie, not AFBC). */ - if (bo->meta.format_modifier == DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC) + if (bo->meta.format_modifier == DRM_FORMAT_MOD_CHROMEOS_ROCKCHIP_AFBC || + bo->meta.format_modifier == DRM_FORMAT_MOD_ROCKCHIP_AFBC) return MAP_FAILED; gem_map.handle = bo->handles[0].u32; |