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
Jason Macnak
aac2a172e9 Revert "Revert "UPSTREAM: cros_gralloc: Avoid using masks in han..."
Revert submission 3309719-revert-3308804-MZCJYQCOVW

Reason for revert: initial cause of b/361574971 believed to be fixed with ag/29881064 and aosp/3309046 

Reverted changes: /q/submissionid:3309719-revert-3308804-MZCJYQCOVW

Change-Id: I60894baab0a773fdceb34601d8b05b54a6dd34f3
2024-10-16 19:19:47 +00:00
Jason Macnak
3068d2b441 Revert "UPSTREAM: cros_gralloc: Avoid using masks in handle_usage()"
Revert submission 3308804

Reason for revert: b/373667975

Reverted changes: /q/submissionid:3308804

Change-Id: I601a93f9a36c41327a703d4347ef6de63d4a8365
2024-10-15 20:15:13 +00:00
Jason Macnak
3b405c8fdf UPSTREAM: cros_gralloc: Avoid using masks in handle_usage()
After https://crrev.com/c/5907583, handle_usage() tries to match
the entire value. An allocation with usage 0x100000203 from

  BufferUsage::GPU_RENDER_TARGET |
  BufferUsage::CPU_READ_OFTEN |
  BufferUsage::FRONT_BUFFER

would fail to match the combined BUFFER_USAGE_FRONT_RENDERING_MASK
(`1U << 28 | 1ULL << 32`) because the allocation only sets a
single usage bit `BUFFER_USAGE_FRONT_RENDERING` (`1ULL << 32`)
and not the combined mask.

Bug: b/373474508
Test: vts -m VtsHalGraphicsAllocatorAidl_TargetTest
Change-Id: I926789a7aab937f2c2092475cb40ad9666b4f95f
2024-10-14 16:39:48 -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
John Reck
892756e97f Update usage to 64-bit
Bug: 284333373
Test: Mapper5 VTS GetUsage64
Change-Id: I28f10be812039f4129d32572895d20b26d11c1fe
2023-05-26 16:52:45 -04:00
Yiwei Zhang
9f1fb038de gralloc: adopt BufferUsage::FRONT_BUFFER
BUG=N/A
TEST=build

Change-Id: I9ffceb16f1a7fd93981ca9eaf72ba68baff5d24b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3852310
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-09-09 17:52:58 +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
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
53749c99a7 gralloc: merge types.h into helpers.h
BUG=b:199524294
TEST=build

Change-Id: I03f982fab307f7b55344ddb224f1cdced8df73ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166894
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-18 00:06:56 +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
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
1de7f6655d cros_gralloc: Adds gralloc 3.0 support
Implements the allocator 3.0 and mapper 3.0 interfaces
which:

 - Implements HIDL interface directly (older versions
   are wrapped in a passthrough HIDL interface)

 - Adds isSupported() to allow checking for format and
   usage combination support before allocating.

Adds emulated multi-planar buffer support to virtio
backend for non gbm enabled hosts.

Updates cros_gralloc_handle to use uint64_t instead of
two uint32_t for some members.

Updates cros_gralloc_handle to have a single format
modifier.

Replaces Android makefiles with Android bp files.

BUG=b:146515640
TEST=run Cuttlefish w/ gralloc3 and run CTS tests

Change-Id: I43ed9788a2413201bddce17ffb69b76006ef39fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2273554
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-07-08 01:08:59 +00:00
Gurchetan Singh
767c538889 Revert "minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16"
This reverts commit 292da5365a.

Reason for revert: The Android framework uses successful allocation of HAL_PIXEL_FORMAT_RGBA_FP16 to test for wide-gamut capabilities.  We don't want to advertise this, so let's revert.

android.graphics.cts.BitmapColorSpaceTest#test16bitHardware

can pass if the framework falls back to RGBA8888, as is the plan.

Original change's description:
> minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16
>
> This is needed to support the following CTS test:
>
> android.graphics.cts.BitmapColorSpaceTest#test16bitHardware
>
> There have been some rumblings about adding 64-bit formats to <drm_fourcc.h>:
>
> https://lists.freedesktop.org/archives/intel-gvt-dev/2017-July/001469.html
>
> However, nothing has landed, so let's just define our own format
> for the time being.
>
> BUG=b:77973662
> TEST=Compile for kevin and kevin-arcnext
>      Unfortunately, my P setup refuses to work, so let the lab
>      test.
>
> Change-Id: I1fea16400ba6632a8ef17105e27bc7799d2af515
> Reviewed-on: https://chromium-review.googlesource.com/1029355
> Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>

Bug: b:77973662
Change-Id: I9e4b79b06dd565189a2e783e8453f08af173d84c
Reviewed-on: https://chromium-review.googlesource.com/1045805
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-05-08 21:15:47 -07:00
Gurchetan Singh
292da5365a minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16
This is needed to support the following CTS test:

android.graphics.cts.BitmapColorSpaceTest#test16bitHardware

There have been some rumblings about adding 64-bit formats to <drm_fourcc.h>:

https://lists.freedesktop.org/archives/intel-gvt-dev/2017-July/001469.html

However, nothing has landed, so let's just define our own format
for the time being.

BUG=b:77973662
TEST=Compile for kevin and kevin-arcnext
     Unfortunately, my P setup refuses to work, so let the lab
     test.

Change-Id: I1fea16400ba6632a8ef17105e27bc7799d2af515
Reviewed-on: https://chromium-review.googlesource.com/1029355
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-04-27 12:22:38 -07:00
Alistair Strachan
0cfaaa5adb Use Android log system in helpers.c.
This code might be loaded by a daemonized process now, so the existing
logging to stderr goes nowhere. It's better to use the Android logger.

Change-Id: I19f088b8f049f07c9c6839038d2971fad1a0e852
Reviewed-on: https://chromium-review.googlesource.com/971360
Commit-Ready: Alistair Strachan <astrachan@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-03-21 23:23:37 -07:00
Gurchetan Singh
4b5d0bf2ab minigbm: cros_gralloc: support GRALLOC_MODULE_API_VERSION_0_3
Let's support GRALLOC_MODULE_API_VERSION_0_3. This will more closely
mirror what gralloc1 and HIDL gralloc does.

We have the option to asychronously unlock with this version of the API,
but decided the added complexity wouldn't lead to any performance benefits.

We'll just set the release fence pointer to be -1, indicating the
the buffer is ready to use after the (*unlock_Async) call.

BUG=b:62069164
TEST=Android boots, play Youtube app, ./gralloctest all passes

Change-Id: Ia21a11b541796c4b36003c50cd8627d189b4bc56
Reviewed-on: https://chromium-review.googlesource.com/422661
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
2017-07-29 02:44:06 -07:00
Gurchetan Singh
d6b8b03b91 minigbm: cros_gralloc: refactor for future HALs
We want the ability to support gralloc0, gralloc1 and HIDL
gralloc in this repo. This commit moves gralloc0 specific code
to the gralloc0 subdirectory, and refactors the rest of the code
so it can be eventually used by whichever APIs we choose to
implement.

In addition, all of the data by the module is now handled by
managed pointers instead of process data, since we get a number
of crash reports when we try to access data in gralloc_close().

BUG=b:62069164, b:62221166
TEST=gralloctest all, Android boots, Youtube videos, 5-10
     CTS tests

Change-Id: Ic29a777573936216d99498d0b814ea50015fd435
Reviewed-on: https://chromium-review.googlesource.com/521794
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2017-06-28 21:50:52 -07:00
Gurchetan Singh
989873c44c minigbm: cros_gralloc: fix incorrect handle calculations
We were including native handle size in our numInts calculations.
Fix this.

BUG=b:62060380
TEST=gralloc related ASAN errors go away

Change-Id: I9ae66655f9e40d82a9cd3fe91ddca9f300fda911
Reviewed-on: https://chromium-review.googlesource.com/517279
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Luis Hector Chavez <lhchavez@chromium.org>
2017-05-31 02:15:28 -07:00
Gurchetan Singh
b7538e29a4 minigbm: cros_gralloc: remove constexpr functions
There's no reason to have these as functions. Also eliminate
sw_write() and sw_read(), the only reason I added them because
I was hitting the 80 column limit (we're 100 columns wide now).

BUG=chromium:616275
TEST=compiles

Change-Id: If0d406df64dc760f2c007eeecf79874c1deb3ec7
Reviewed-on: https://chromium-review.googlesource.com/457288
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2017-03-31 10:40:28 -07:00
Gurchetan Singh
1b1d56ae40 minigbm: add clang-format and presubmit hooks
Running the presubmit.sh script will apply our rules to every file in
the repo. Exclude gbm.h from the formatting requirements since this file
was taken from other open-source projects, and diffing will be easier
without our formatting rules.

In addition, special case drivers where the order of includes matters.

BUG=none
TEST=Verified the following commands succeed:

emerge-cyan minigbm/arc-cros-gralloc
emerge-oak minigbm/arc-cros-gralloc
emerge-veyron_minnie-cheets minigbm/arc-cros-gralloc
emerge-peach_pi minigbm
emerge-nyan_big minigbm
emerge-jadeite minigbm

Change-Id: I6ce93fb1930da254d13d5017766c17341870ccc9
Reviewed-on: https://chromium-review.googlesource.com/447319
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2017-03-31 10:40:27 -07:00
Gurchetan Singh
54150e89f4 minigbm: cros_gralloc: modify error statements
The error statements now look like what's printed in
Chrome's /var/log/ui/ui.LATEST, which I think looks nice.

BUG=chromium:616275
TEST=None
CQ-DEPEND=CL:416397

Change-Id: Ide3eb381ac710f016e9d002e4dd5f9e5ab8eda7f
Reviewed-on: https://chromium-review.googlesource.com/416398
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2016-12-12 18:34:18 -08:00
Gurchetan Singh
c67f9e422c minigbm: flatten gralloc handle
Many GL drivers assume that first value in the native_handle data
array is the fd associated with the graphics buffer, i.e,

int prime_fd = handle->data[0];

This in our case until 4bfc7401. We added 64-bit modifiers in
our import data, so all values in the drv_import_fd_data struct get
8-byte aligned. In our cros_gralloc_handle, 4 bytes of padding
are added between native_handle_t and drv_import_fd_data to make
the alignment work. To counter-act this, we can stop embedding
drv_import_fd_data in cros_gralloc_handle.

BUG=chromium:616275
TEST=Mali driver doesn't return an error when running cros_gralloc
CQ-DEPEND=CL:414585

Change-Id: Ib6c165e98126468b96fa7119d5ca13eebee1655c
Reviewed-on: https://chromium-review.googlesource.com/414536
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2016-12-09 03:30:16 -08:00
Gurchetan Singh
f3b22da397 minigbm: Switch to <drm_fourcc.h>
We were duplicating formats.  The original rationale behind this was
DRV_FORMAT_* would be a superset of Android and DRM formats.  However,
there are only 2 HAL flexible formats not defined by DRM, and we can
deal with these easily.  The DRM format namespace is large enough to
handle any additions we may need.

BUG=NONE
TEST=Ran graphics_Gbm,
     arc-cros-gralloc still builds

Change-Id: Ie173eee6ac6926947a3b98c3ae809e38a0ea8014
Reviewed-on: https://chromium-review.googlesource.com/405790
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2016-11-28 23:59:30 -08:00
Gurchetan Singh
2e786ad600 minigbm: Implemented cros_gralloc
It is desirable to have a gralloc implementation based on the same
drivers we use for minigbm. This will help synchronize the code between
CrOS and the Android container.

BUG=chromium:616275
TEST=Ran the gralloc unit test:

test_that -b veyron_minnie-cheets $IP1 graphics_Gralloc

Verified it succeeded.

CQ-DEPEND=CL:395066

Change-Id: Iff11eba3a92268327ef00eb12b4eabe6fc190cf3
Reviewed-on: https://chromium-review.googlesource.com/362062
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2016-10-17 12:54:56 -07:00