Commit graph

19 commits

Author SHA1 Message Date
Jason Macnak
bd616875b5 gralloc: Move buffer metadata initialization into common layer
... to dedup and support upcoming change to metadata initialization.

Bug: b/321158178
Test: vts -m VtsHalGraphicsAllocatorAidl_TargetTest
Test: vts -m VtsHalGraphicsMapperV4_0Target
Test: vts -m VtsHalGraphicsMapperStableC_TargetTest
Change-Id: Ib00873babcb2ec8816b0d319e675d6884594f618
2024-01-23 13:52:14 -08:00
Jason Macnak
966d073388 UPSTREAM: cros_gralloc: fix convertToFenceHandle()
... to not return address to local stack variable.

Upstream review: https://crrev.com/c/4615434

Bug: b/287536665
Test: cvd start && vts -m VtsHalGraphicsMapperV4_0Target
Change-Id: I1f8b5e12fc77fb30bfca8dbf712efa925f45f537
2023-06-16 09:35:00 -07:00
Yiwei Zhang
a07201ce2e gralloc4: fix plane layout mapping for DRM_FORMAT_YVU420
In fact, the resolved format is always DRM_FORMAT_YVU420_ANDROID at
gralloc frontend upon metadata query.

DRM_FORMAT_YVU420 is only returned upon filling fourcc in native handle.

Do the fix anyway for sanity and prepare for later code cleanup.

TEST=build

Change-Id: I4c9a96d317bb458cf715364f68f1a0daead1a077
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3789650
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
2022-07-28 21:31:05 +00:00
Yiwei Zhang
bfb3c781a4 gralloc: use ALOGE instead of drv_log
TEST=build

Change-Id: I78b123f395fef8853f310a567ac0341b6958c535
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761445
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-15 06:50:52 +00:00
Zhang Bo
7e669ca947 gralloc:fix incorrect plane layout of DRM_FORMAT_XBGR8888
The format DRM_FORMAT_XBGR8888 playe layout should be aligned with linux DRM
driver definition.

Signed-off-by: Zhang Bo <bo.zhang@nxp.com>
Change-Id: I8f8b025a99a7503eb27eda96bcbdf3373b011a8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3414504
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-01-27 01:40:38 +00:00
Jason Macnak
f48d8bc6ca gralloc: Fix plane layout for RGB565
BUG=n/a
TEST=n/a

Change-Id: Id3254d66a83460618e994ab54673c51d56d00aec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3291697
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-11-30 04:04:16 +00:00
Jason Macnak
547f29cb2f gralloc: Fix a HAL_PIXEL_FORMAT to DRM_FORMAT mapping
DRM and pixel formats have the order flipped.

HAL_PIXEL_FORMAT_RGB_888 -> DRM_FORMAT_BGR888

BUG=b:191096118
TEST=CtsNativeHardwareTestCases on Cuttlefish

Change-Id: I88315730075b6289463963a9c9071bd4f089447e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3291554
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-11-23 19:09:48 +00:00
Yiwei Zhang
b73dd1deac gralloc: add cros_gralloc_convert_map_usage
This is to unify map usage conversion for gralloc frontends.

BUG=b:199524294
TEST=build

Change-Id: I488213ca889a98f39a86e0340a315052cb8f624f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3171104
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-23 02:18:18 +00:00
Yiwei Zhang
6aad135952 gralloc: unify gralloc frontends to use cros_gralloc_convert_format
Reordered the cases to align with actual enum value for the hal formats,
and added 3 more formats support to align with gralloc4 support:
1. Y8
2. Y16
3. YCBCR_P010

BUG=b:199524294
TEST=CtsNativeHardwareTestCases
TEST=gralloc4 builds in aosp

Change-Id: I7a6743524c024d46ab2a7a6d973f431ea2721c49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3160131
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-18 04:51:54 +00:00
Yiwei Zhang
3c8db48195 gralloc4: use generated enum type helper functions
There're already auto-generated helpers functions which also handles
unknown cases properly.

BUG=b:199524294
TEST=gralloc4 builds on aosp

Change-Id: Ic488494812c455bfd01ca0e2b60091f21ca8fd96
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3161221
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-17 21:02:39 +00:00
Yiwei Zhang
6b894b1d96 gralloc: add cros_gralloc_convert_usage to unify usage resolution
The current gralloc0 specific usage conversion is already a superset.
This change also fixes a misalignment on video encoder mapping due to
the original fix missing to hit gralloc4.

BUG=b:199524294
TEST=CtsNativeHardwareTestCases
TEST=gralloc4 builds on aosp

Change-Id: Ib1e37ba09deb50b754863b261423e201ab6b4910
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166892
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-17 13:47:54 +00:00
Yiwei Zhang
b03d02136a minigbm: resolve front rendering usage for gralloc3+
TEST=no regression in ARCVM low latency stylus demo

Change-Id: I8b7983664779d05fc1463edc1ef813de2bcc6540
Reported-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3012235
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-07-13 00:32:51 +00:00
Yiwei Zhang
bb9d4af452 minigbm: support GPU_DATA_BUFFER in gralloc virtgpu_virgl backend
VK_ANDROID_external_memory_android_hardware_buffer spec requires gralloc
to support AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER. This patch adds a new
BO_USE_GPU_DATA_BUFFER flag accordingly and maps the new flag to
VIRGL_BIND_LINEAR, which aligns with the workarounds carried by existing
implementations as well as still going through the blob resource path to
be correctly mappable at the guest side.

BUG=b:191591725
TEST=AHardwareBuffer_allocate with AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER
TEST=CtsNativeHardwareTestCases
TEST=dEQP-VK.api.external.memory.android_hardware_buffer.*

Change-Id: Ib0d9b1cb90e3b7ff614d556954b6abb9018c92a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2974800
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-06-25 21:02:35 +00:00
Gurchetan Singh
cadc54fe5d minigbm: consistent style
- Sometimes were return -1 and sometimes -errno.  Prefer -errno
  wherever possible.
- No braces for single line if/else statements.  This does not
  apply gralloc3/gralloc4, since that directory follows AOSP
  style.

BUG=b:178495907
TEST=Cuttlefish CFI

Change-Id: I4c35768e015109730772a972b4b18e8d2c3cbb9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2665001
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-03 04:22:38 +00:00
Jason Macnak
07f6209f74 cros_gralloc: Report layerCount > 1 as unsupported
... to handle AHardwareBufferNativeTests#MultipleLayers_*
tests.

BUG=b:168577830
BUG=b:172409958
TEST=cts -m CtsNativeHardwareTestCases
Change-Id: I40a55d05011a94057d877e228b4b3587dfc48fcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2585945
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-12-11 17:43:50 +00:00
Gurchetan Singh
b7edf5dfd8 minigbm: cros_gralloc: map protected flag to linear
This should be fine since the dummy fd was never used
with the encoder / decoders, so it doesn't need to be
tiled.

BUG=b/171018855
TEST=GtsExoPlayerTestCases / GtsMediaTestCases

Change-Id: I1309a641e19a9196e0aed05f4820e0d2672fafa0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2481223
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-20 03:16:06 +00:00
Gurchetan Singh
bbba9dde65 minigbm: stop faking the protected buffers
With real HW protection on the horizon, let's repurpose the
protection flag to mean that.

Currently, our protected buffer scheme on the Android side
allocates a dummy fd, which is sent to Chrome.  Chrome
associates that dummy fd with an unmappable shared memory
buffer.  In the entire process, minigbm doesn't really do
anything.

We prevent buffers allocated with the protected
flag from being mapped, but since it's a dummy fd it's not
really useful.

Chrome doesn't use the protected flag yet, but hopefully will
so in the future, but with real HW protection.

BUG=
TEST=

Change-Id: I57be26926539471f062ffeff33b523a3899c35f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2466958
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-14 04:32:55 +00:00
Gurchetan Singh
2d482e05f7 minigbm: cros_gralloc: simplify getting the drm format string
Can we do this.

BUG=none
TEST=compile

Change-Id: If9488038f1eb77b92e37d6daa99c8bea495315c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2451522
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-09 03:54:24 +00:00
Jason Macnak
2a77d942ae minigbm: Adds Gralloc 4 support
Implements the Allocator 4.0 and Mapper 4.0 interfaces.

Some notable features of the 4.0 interface:
- buffer metadata getter/setters
- buffer flushing
- buffer debugging (buffer listing and buffer id)

BUG=b:161909468
TEST=build and launch Cuttlefish with Gralloc4

Change-Id: I63bdc76604207e1fcfe0135c9b64fa62bfba5b27
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2404601
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-09-17 01:07:54 +00:00