Commit graph

26 commits

Author SHA1 Message Date
Yiwei Zhang
854a9186df gralloc: hide AIDL metadata for gralloc0-only build if requested
This is needed for ARC-R container targets using arc-cros-gralloc.

Meanwhile, bump -std=c++14 to -std=c++17 for std::optional and others.

Bug: b/433317686
Test: chromium CI + android CI
Change-Id: Id9ed5f27f6788ca63d0bdb9566c54b3cd4030e16
2025-09-10 15:40:18 -07:00
Dominik Behr
a1e715acd8 cros_gralloc: add support for mt8186
Add build changes for mt8186.
Add ARM metadata types: compression, plane fds and data type.
Add mediatek_drm.h which is not available.

Bug: 388092228
Test: boot corsola with minigbm gralloc/mapper

Change-Id: I1f1e8a57f37e26694320c3ddee01fbad453f854b
2025-03-27 19:25:18 -07:00
Jason Macnak
92eb16bb24 gralloc: Move buffer metadata accessing into cros_gralloc_buffer
... to hide cros_gralloc_buffer_metadata from the AIDL/HIDL Apis.
No functional change expected.

Bug: b/321158178
Test: vts -m VtsHalGraphicsAllocatorAidl_TargetTest
Test: vts -m VtsHalGraphicsMapperV4_0Target
Test: vts -m VtsHalGraphicsMapperStableC_TargetTest
Change-Id: I33f17670a331385b0afe0e179cab8985b7fe78b9
2024-01-23 13:52:17 -08:00
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
49756130de Merge remote-tracking branch 'cros/main' into 'aosp/master'
Bug: 158617858
Bug: 174146421
Bug: 269565421
Test: CtsNNAPITestCases and CtsCameraTestCases
Change-Id: Ifca6fd0c2dcfcfc3426441f13cd04b8ba02b21ac
2023-02-20 22:59:22 +00:00
Dawn Han
d77e164105 minigbm: Relax the validateBufferSize check
Blob formats (aka buffers) get represented as R8 textures with height
of one and width==size. These have no particular stride requirement,
even though the host might ask for a pitch that would make sense for
a 2D R8 texture with height greater than one.

Relax the validateBufferSize check for format_blob rather than set the
stride. As blob defined: buffers of this format must have a height of
1, so height doesn't need to be checked specifically.

BUG=b:269565421
TEST=CQ

Change-Id: I7a8d4dbf292330df0c24b502abd9dbf3dceac728
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4263402
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2023-02-20 04:00:05 +00:00
Yiwei Zhang
4f31804e58 Merge remote-tracking branch 'cros/main' into 'aosp/master'
Bug: 262920670
Bug: 262928949
Test: cts
Change-Id: I63e534134c5eaffebcdd74e04bb9ede4b8c5f7f7
2022-12-18 08:13:50 +00:00
John Reck
d6fbcaac65 Add CROP to listSupportedMetadataTypes
The getter already worked, it just wasn't listed as such.

Also drop claiming SMPTE2094_40 support on IMapper5, since
it's always a no-op and only conceptually makes sense
if the setter exists (wording on the spec will be changed
to reflect this)

Test: atest VtsHalGraphicsMapperStableC_TargetTest
Change-Id: I4ee93927edc11fda6bd3983caaabf8b281c080ab
2022-12-15 16:00:17 -05:00
Jason Macnak
399fa8b592 gralloc: Remove release_fence arg from cros_gralloc_driver::flush()
... to match downstream aosp/2279448.

BUG=b:259311835
TEST=presubmit

Change-Id: I696998e627abb0d88b83d55f8fb335df3dd7576c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4073504
Commit-Queue: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-12-02 17:43:11 +00:00
John Reck
aefe9340f4 Initial implementation of IMapper 5
Test: atest VtsHalGraphicsMapperStableC_TargetTest
Change-Id: I7fd047e3b53fbf659595baa9f34eb1b979ef1f89
Merged-In: I7fd047e3b53fbf659595baa9f34eb1b979ef1f89
2022-12-01 17:38:35 +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
Jason Macnak
0e9bd65933 gralloc: Move buffer name out of cros_gralloc_handle
... and into CrosGralloc4Metadata to simplify handle
creation by avoiding variable sized handles.

BUG=b:207388558
TEST=cvd start
TEST=vts -m VtsHalGraphicsMapperV4_0Target
TEST=cvd start --gpu_mode=gfxstream
TEST=vts -m VtsHalGraphicsMapperV4_0Target

Change-Id: I2d5e37beef8b9ba6bfbd06d79131b381d3ff73da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3433595
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-02-17 07:05:56 +00:00
Jason Macnak
b4eb84da28 gralloc: Support gralloc->set(<metadata>)
... by reserving the first section in the shared memory
reserved region for a new CrosGralloc4Metadata struct.

BUG=b:207388558
TEST=cvd start
TEST=vts -m VtsHalGraphicsMapperV4_0Target
TEST=cvd start --gpu_mode=gfxstream
TEST=vts -m VtsHalGraphicsMapperV4_0Target

Change-Id: I7c59196ca747dc0fe854cdb4cbbcd21dd82e1401
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3421048
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-02-17 07:05:56 +00:00
Jason Macnak
d6d2fc5530 gralloc: Replace for-each-handle ​with for-each-buffer
... to support upcoming change where CrosGralloc4Mapper's
get(<metadata>) will want to access metadata that may be
in either the buffer's handle or the buffer's reserved
region. The for-each-[handle|buffer] methods support
dumpBuffers() where we need to iterate over all of the
buffers while holding a lock on the cros_gralloc_driver's
mutex.

BUG=b:207388558
TEST=cvd start
TEST=vts -m VtsHalGraphicsMapperV4_0Target
TEST=cvd start --gpu_mode=gfxstream
TEST=vts -m VtsHalGraphicsMapperV4_0Target

Change-Id: I674cab487d7446af722f94d796f504cf4f97de27
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3433121
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-02-17 07:05:55 +00:00
Yiwei Zhang
b7a64441ef minigbm: refactor driver helpers
1. frontends access the driver via drv.h only
2. the renamed drv_helpers and drv_array_helpers are for driver only
3. remove extern "C" from drv_helpers.h given not exposed to gralloc
4. remove all redundant includes for those helpers

BUG=b:199524294
TEST=CQ and gralloc builds on aosp

Change-Id: I3f4d33076a6a8161804f1b7c26950ff5496507e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3195651
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-01 18:35:11 +00:00
Yiwei Zhang
dfe5ac6b58 gralloc: resolve format and use_flags at cros_gralloc_driver level
This simplify the separate resolving efforts in different gralloc
frontends (including separate logic in gralloc4 mapper and allocator).

BUG=b:199524294
TEST=CtsNativeHardwareTestCases

Change-Id: I74cd19df9b06c26a124e89c3367dd76b5b57dbd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166893
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-17 13:47:55 +00:00
Yiwei Zhang
a12547b9f8 gralloc4: align the use_flag fallback logic with gralloc0
BUG=b:199524294
TEST=gralloc4 builds in aosp

Change-Id: I7cd5247d4768a108c4f7c6e2853229b030949a7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3163213
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:53 +00:00
Yiwei Zhang
61f9752a1c minigbm: refactor cros_gralloc_driver to be a singleton
Only a single cros_gralloc_driver instance is allowed to exist in a
process. However, currently when Gralloc3.0 or Gralloc4.0 is used, it's
possible for 2 independent driver instances to be created. This change
refactors cros_gralloc_driver to be a singleton and ensures the driver
initialization only happens once per process.

BUG=b:191895066
TEST=No regression of gralloc0 in ARCVM

Change-Id: I3cb8b7c3d13717cfe531b557b9d69b72efdbf3da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3002266
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Tested-by: John Stultz <john.stultz@linaro.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-07-02 18:26:18 +00:00
Jason Macnak
3dc366e2eb cros_gralloc: Handle multiple instances of CrosGralloc4Mapper
... to respect

"The imported handle must be considered valid everywhere
in the process, including in another instance of the mapper."

Bug: b/179446728
Test: vts -m VtsHalGraphicsMapperV4_0Target
Test: Camera CTS with WIP change that used multiple mapper instances
Change-Id: Id4efe09ae782f04ad58630ee8360ab3592f4eb6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2679144
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-02-06 23:36:04 +00:00
Jason Macnak
166fe14ab5 cros_gralloc: Handle failure to get prime fd
... in cros_gralloc_driver::allocate().

BUG=b:178495907
TEST=Cuttlefish CFI

Change-Id: Ibb9a5e55f2d2a4bf6be71f03dfe3f0fcd55a1b55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2658929
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-03 04:22:39 +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
Roman Stratiienko
142dd9c494 Always export DRM_FORMAT_YVU420_ANDROID as DRM_FORMAT_YVU420
Fixes video playback when gralloc0 and software video decoder are used.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I676060021806186bb3c23928d0d54af4add5120a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2589993
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2020-12-17 04:43:50 +00:00
Jason Macnak
16be5a74aa cros_gralloc: Fix PlaneLayout width/height metadata
... by using the horizontal/vertical subsampling of
each plane.

BUG=b:171019648
TEST=vts -m VtsHalGraphicsMapperV4_0TargetTest

Change-Id: I3eccfa1c0ac30394314c83b54ca50d690c679724
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2503481
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Auto-Submit: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-10-28 14:01:26 +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