Commit graph

78 commits

Author SHA1 Message Date
Mike Frysinger
bc47e98159 UPSTREAM: presubmit: switch to cros format
Rather than use `clang-format` from $PATH (which changes between devs),
use `cros format` which has a pinned version for all people.

Add *.cpp to the include list as not all C++ files use *.cc.

Then run format on the files to fix latent issues.

BUG=None
TEST=./presubmit.sh

Change-Id: I28e167d454a7b089bb79e932b7265fa87e4c331f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6475964
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Ryan Neph <ryanneph@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>

Bug: None
Test: lunch brya-trunk_staging-userdebug && m libminigbm_gralloc
Change-Id: I23022dbb536ade53951fe61014c5056e114f4bbc
2025-06-24 17:37:57 -07:00
Jean-François Thibert
fd19358a25 Revert^2 "Merge upstream-main into main"
This reverts commit b7a9a2b7d5.

Reason for revert: Crash resolved by Ieb07b5bbc206f07f69e4afba921149f49d6fe8c4
Bug: 349870098

Change-Id: I49848f6e7311c1f44e6c988cb42107ed79da3a6b
2024-07-03 18:21:13 +00:00
Jason Macnak
b7a9a2b7d5 Revert "Merge upstream-main into main"
This reverts commit 018f7ff8fa.

Reason for revert: b/349870098

Change-Id: I942c713e4f7a24881b7ea3cff30df13a2b4a7c9c
2024-06-27 21:40:26 +00:00
Jean-Francois Thibert
018f7ff8fa Merge upstream-main into main
This includes changes I63a5352e, Ia34b7d3a, I2685813f and I07e60729

mediatek: Add MT8196
minigbm: Reduce allocation size for MT2T allocations
minigbm: #define MINIGBM_HAS_GBM_BO_GET_MAP_INFO
Add depth buffer support for virtgpu virgl

Change-Id: I125c0b751f86b217a6ffbf7ec3fd2a1ddf848461
2024-06-26 13:21:44 -04:00
Yiwei Zhang
8291bfe6f1 minigbm: format fix
BUG=n/a
TEST=./presubmit.sh

Change-Id: Ic581ebe770c648ee344cfbe20ba6655786a2088e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5505015
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Satoshi Niwa <niwa@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2024-05-01 08:09:45 +00: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
6bd32d9cbf Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/main'
... to pull in https://crrev.com/c/4897926.

Bug: b/300616292
Bug: b/300194143
Bug: b/294661992
Test: launch Cuttlefish, run SurfaceFlinger_test, inspect
      tracing around lifetime of cros_gralloc_driver
Change-Id: I72c9164c2194af87bab0800fd821b4bc0934f245
2023-09-28 10:31:23 -07:00
Jason Macnak
1f9a351e4f gralloc: Use std::shared_ptr for cros_gralloc_driver
... to ensure the lifetime of the underlying cros_gralloc_driver
matches those of the various Mapper* interfaces. Without this, the
the destruction of the static cros_gralloc_driver `s_instance`
could race with a potential CrosGralloc4Mapper user on another
thread which is still alive at the time of exit() (for example,
a buffer being cleaned up on a libhwbinder worker thread).

Bug: b/300616292
Bug: b/300194143
Bug: b/294661992
Test: launch Cuttlefish, run SurfaceFlinger_test, inspect
      tracing around lifetime of cros_gralloc_driver
Change-Id: Id8e2dbff471c03f7b663952524905a06cc03fbc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4897926
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2023-09-28 17:11:55 +00:00
Amit Pundir
21fc4f10c8 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/main'
* aosp/upstream-main: (27 commits)
  minigbm: add some validation check in cros_gralloc
  minigbm: update format of mediatek.c
  Revert "i915: Vertical align video encode buffers to macroblock size"
  minigbm: drv: Fix MINIGBM_DEBUG usage on Android
  mediatek: Add BO_USE_PROTECTED use_flag for gpu and video decoder
  i915: Vertical align video encode buffers to macroblock size
  Don't print verbose messages by default
  virgl: Store format modifier in blob's bo meta
  Fix convertToFenceHandle()
  minigbm: update drv_get_os_option() to try getenv() first
  Update usage to 64-bit
  virtgpu_cross_domain: fix prop query for mt8183 camera quirk
  virtgpu_virgl: use blobs for ABGR8888
  minigbm: move camera work-around
  mediatek: Add BO_USE_PROTECTED use_flag to support secure buffer allocation
  i915: prefer tile4 for non-linear scanout buffers
  i915: allow linear mapping for P010 scanout
  minigbm: remove `close_gem_handle`
  mediatek: Exclude MT8173's FP16 and 10-bit ABGR support
  minigbm: Use clflushopt if supported
  ...

Change-Id: I38fb3f2c699205f73633e07d1824c4fd48dac5f5
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2023-07-21 10:11:44 +05:30
dawnhan
a13a4ccde3 minigbm: add some validation check in cros_gralloc
1. Check if the buffer handle
   - Validate if the handle is null or not
   - Check the size of the handle to make sure it will not cause oob read/write
2. Check num_planes to make sure it matches with numFds
3. Created b/291606090 for the follow up about updating cros_gralloc_driver level api to take cros_gralloc_handle_t

BUG=b:289303132
TEST=patch the change on rvc-arc and tested with ARCVM

Change-Id: Id03ec45f928fe6db62bb1722ee0dbc6c8831fd46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4674736
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
2023-07-18 07:13:59 +00:00
Yiwei Zhang
9c34d76be0 Merge remote-tracking branch 'cros/main' into 'aosp/master'
Test: build
Change-Id: I281daffb82b7e959cadd1073b15b45f8f0ec7722
2022-07-25 18:32:51 +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
72c3089009 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to pull in support for `gralloc->set(<metadata>)` for Cuttlefish
from https://crrev.com/c/3421048 and the related changes in the chain.

Bug: b/219757060
Test: cvd start
Test: cts dEQP-VK.api.external.memory.android_hardware_buffer.*
Test: vts -m VtsHalGraphicsMapperV4_0Target

Test: cvd start --gpu_mode=gfxstream
Test: cts dEQP-VK.api.external.memory.android_hardware_buffer.*
Test: vts -m VtsHalGraphicsMapperV4_0Target
Change-Id: I541d479da3b208c25666fcc50f89c790c361f1f6
2022-03-01 12:40:58 -08:00
Jason Macnak
6235f17371 gralloc: cros_gralloc_buffer always owns a cros_gralloc_handle
... to make it easier handle ownership (no more conditional
ownership if the buffer was allocated versus imported).

This also helps avoid a deadlock in CrosGralloc4Mapper's
dumpBuffers() in an upcoming change where CrosGralloc4Mapper
wants to interact with both metadata in the handle and
metadata in the cros_gralloc_buffer's reserved region. By
having the cros_gralloc_buffer always have a handle, the
CrosGralloc4Mapper can have access to all metadata when it
has a cros_gralloc_buffer parameter.

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

Change-Id: I56fffbbfacf8436db165a961bec8ce546b4acc6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3433118
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:52 +00:00
Jason Macnak
42669faa70 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to update Minigbm for Cuttlefish to pull in https://crrev.com/c/3208931
to restrict 2D allocs to max supported SwiftShader size.

Bug: b/194426249
Test: `cts -m CtsNativeHardwareTestCases` with aosp/1845813
Change-Id: I9f538e48a72ec699617b9e653812f2b785c5e39a
2021-10-07 08:49:05 -07: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
Jason Macnak
e300b83aaa Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to update Minigbm for Cuttlefish to pull in clean ups for
supported combinations and to pull in restricting 2D allocs to
max supported SwiftShader/llvmpipe size.

Bug: b/201325625
Bug: b/194426249
Test: launch_cvd --gpu_mode=guest_swiftshader
Test: launch_cvd --gpu_mode=gfxstream
Change-Id: I11c71b95987cedbb27515e85559e00c5df8c0dd9
2021-09-30 09:47:06 -07:00
Yiwei Zhang
afdf87dcd4 minigbm: add more error handling especially for oom
This change also fixes a potential prime_fd leak in mediatek backend.

BUG=b:201110412
TEST=CQ

Change-Id: Ia3e10c94b536f83ecfb6580666103fe654bbc616
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3188852
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2021-09-29 07:08:22 +00:00
Jason Macnak
0c07f404ee gralloc0: Fix sign comparison
... to address:

external/minigbm/cros_gralloc/gralloc0/gralloc0.cc:284:26: error:
comparison of integers of different signs: 'uint32_t' (aka 'unsigned
int') and 'int' [-Werror,-Wsign-compare]

BUG=b:201325625
TEST=build inside of AOSP

Change-Id: Ie4f93b8dd82752e6dcf1234627e4d25756af2736
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3188653
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Auto-Submit: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-09-28 23:51:16 +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
f58616e0e3 gralloc0: resource_info to return the correct strides and offsets
When format plane is single, it's still possible for the host image
memory to have multiple planes for auxiliary planes for non-linear
modifiers.

Relying on the non-zero stride to retrieve the actual strides and
offsets info.

BUG=b:197899093
TEST=run Vulkan apps on zork-arc-r
TEST=run guest video/camera apps
TEST=CtsNativeHardwareTestCases and related CtsGraphicsTestCases

Change-Id: Id80f143de114bbe9252c40b46dcfb835085c754d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3120411
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-22 22:42:36 +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
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
Jason Macnak
46e34f0a08 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to pull in crrev.com/c/3015656 to handle potential allocator
service startup failures for Cuttlefish.

Bug: b/187802138
Test: launch_cvd
Change-Id: Ibf547f86bda0046cafa6eb273c507a81954e9a88
2021-07-13 07:30:04 -07: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
John Stultz
8b8ab7854c Merge remote-tracking branch 'aosp/upstream-main' into HEAD
Update minigbm to CrOS upstream main branch

This includes fixes to address interactions between
gralloc4 and gralloc0 logic.

* aosp/upstream-main:
  dri: Fix memory leak.
  minigbm: map BO_USE_FRONT_RENDERING to VIRGL_BIND_LINEAR
  virtgpu: Fix RGBA_1010102 unhandled format error
  minigbm: refactor cros_gralloc_driver to be a singleton
  minigbm: support GPU_DATA_BUFFER in gralloc virtgpu_virgl backend
  amdgpu: Remove 256 alignment workaround
  amdgpu: Do not support mapping tiled buffers on android
  i915: Run clang-format
  virtgpu: Support P010
  i915: Enable Render Buffer compression for Gen11

Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Id4a6e11e1e794a95cf6b6ac88c81dbc15b2bdf76
2021-07-12 22:22:36 +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
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
Jason Macnak
20e8ce7d5f Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to update Minigbm for Cuttlefish to pull in
crrev.com/c/2946768 to support PixelFormat::RGBA_1010102.

Bug: b/179501410
Test: cts -m CtsMediaV2TestCases
Change-Id: I97fe4578436b574cfe4844cfb91ee5b93494f1c2
2021-06-10 07:32:43 -07:00
Yiwei Zhang
5a031c6c14 minigbm: zero init cros_gralloc0_buffer_info
This change ensures no garbage data in the untouched stride and offset.
We need this because cros_gralloc0_buffer_info doesn't have num_planes,
and num_fds can sometimes be (num_planes + 1). So the client needs to
rely on stride being non-zero to retrieve the num_planes.

TEST=check the stride and offset data

Change-Id: Iccc9bb3d3dd6a9eea80c1e859116cbb96cd44d32
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2940203
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-06-04 15:43:29 +00:00
Yiwei Zhang
ca1a5a6d50 minigbm: fix cros gralloc0 racing
"gralloc0_open" is only called on the allocator service(the unique
gralloc HAL service for allocation), which will additionally do
"module->common.methods->open(...)" to open the allocator device. For
other clients of cros gralloc, they just opened the gralloc library in
sp-hal as a helper library. Mesa is one of the clients here. All the
gralloc helpers relying on the underlying driver existence should ensure
the driver gets initialized before doing any driver ops.

This patch adds the minimal init required for the sane ops.

BUG=b:190010929
TEST=racing fixed

Change-Id: Ia662f68dccec0d0179d679d2e57b8b3975661506
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2935981
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: John Stultz <john.stultz@linaro.org>
2021-06-04 08:11:40 +00:00
Jason Macnak
cab396632e Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
... to update Minigbm for Cuttlefish to pull in cross domain virtgpu
backend.

Bug: b/189133053
Test: launch_cvd
Test: launch_cvd --gpu_mode=gfxstream
Test: CtsGraphicsTestCases
Change-Id: I8ce1c8b0574bb0ccefc8fd119ffc9a6e410fa3dc
2021-05-26 10:24:18 -07:00
Yiwei Zhang
cd6e63c123 minigbm: add GRALLOC_DRM_GET_USAGE query
Low-latency stylus support requires EGL_KHR_mutable_render_buffer, and
front rendering support in mesa requires the bo to be shared between gpu
and composer simultaneously. Either BO_USE_FRONT_RENDERING or forcing
linear with BO_USE_LINEAR is needed upon bo allocation. This change adds
a way for the client to inform gralloc of such info so that the minigbm
backend can choose the proper bo use flags upon allocation.

BUG=b:183507528
TEST=dEQP-EGL.functional.mutable_render_buffer.*
TEST=tast run $DUT arc.Gralloc.vm

Change-Id: Id7da33cea7d62aa9ae035ee3a6767f87874cb6ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2895370
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-05-24 19:52:23 +00:00
Yiwei Zhang
a1e93fd6f1 minibgm: update GRALLOC_DRM_GET_BUFFER_INFO query
Vulkan on Android relis on VkImageDrmFormatModifierExplicitCreateInfoEXT
to import the gralloc allocated buffer, which requires buffer info of
the host storage.

BUG=b:186679287
TEST=venus wsi on arcvm and egl/gles
TEST=CtsNativeHardwareTestCases and related CtsGraphicsTestCases

Change-Id: I7ab0e80ab67a2daae9ea547a8d5abe9417af17d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2862161
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-05-05 07:58:40 +00:00
Jason Macnak
f01311b9a6 Merge remote-tracking branch 'aosp/upstream-main' into 'aosp/master'
to pull in http://crrev.com/c/2658929 for Cuttlefish.

Bug: b/178495907
Test: launch_cvd --gpu_mode=guest_swiftshader
Test: launch_cvd --gpu_mode=gfxstream
Change-Id: I542a496a412a940986af572bb480f085498a171a
2021-02-03 16:45:07 +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
David Stevens
150b496881 gralloc0: drop encoder use flag for YV12 buffers
The ARC encoder components do not submit YV12 buffers to the hardware,
instead converting and copying the content to NV12 buffers. Because
of this, we can clear the HW_VIDEO_ENCODER flag from any YV12 buffers.

BUG=b:162796596
TEST=revert ag/12467634 and arc.VideoEncodeAccel.h264_192p_i420_vm

Change-Id: I170f7c51d7ff18e75f720db2c2af8c79f29a0423
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2589173
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-12-16 06:07:58 +00:00
Jason Macnak
42ca6159e5 Merge 'aosp/upstream-master' into HEAD
... to pull in PlaneLayout metadata fix http://crrev.com/c/2503481

Bug: b/171019648
Test: launch_cvd
Test: launch_cvd --gpu_mode=gfxstream
Change-Id: I9c2a52e2eca3339c024154840cb91f65bb7ed577
2020-10-28 13:27:30 -07:00
Jason Macnak
96edf3270e Sync aosp and internal minigbm
The merge in aosp/1431491 did not re-apply many of the changes
from aosp/1431490 as intended.

Bug: b/171019648
Test: launch_cvd
Test: launch_cvd --gpu_mode=gfxstream
Merged-In: Id5222980cc2e7c284a846259c808bf79cf5f2a75
Change-Id: I3a0136b6303a1b1c5e27f7e225466438e3de0616
2020-10-28 12:10:27 -07:00
David Stevens
dfb45b0b5c gralloctest: update test for ARCVM
On ARCVM, the stride obtained from GRALLOC_DRM_GET_STRIDE is the host
stride, and may be larger than the guest stride.

This change also moves the line which prints the next test to execute to
before the test actually runs, so it appears before test failures.

BUG=b:155238003
TEST=tast run DUT arc.Gralloc*

Change-Id: I4594f352fba585fa4bdbaff609f198888b99c8f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2500971
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
2020-10-28 02:54:48 +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
Kristian H. Kristensen
ff5ffe6d5c cros_gralloc: Add new perform op for getting buffer info
This perform op gives us all the underlying info about the BO, which
lets us import multiplane BOs (such as Intel compressed BOs). This
eliminates a lot of guessing and fudging in EGL and wayland_service
when trying to determine this info from the Android handle.

This generalizes the GET_MODIFIER op, which nothing was using yet.

BUG=b:145579089, b:79682290. b:163562363
TEST=arc++ apps using non-linear format layouts

Change-Id: I821e14477d35794b7247fab59649f564e8ff6985
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2353750
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
2020-08-18 09:13:58 +00:00
Kristian H. Kristensen
e77c32c578 cros_gralloc: Add perform action for getting the modifier
BUG=b:145579089, b:79682290
TEST=arc++ apps using non-linear format layouts

Change-Id: I9d71852b52b984d89428a07fad5c82d61150e8a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2316523
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
2020-07-28 10:57:12 +00:00
Jason Macnak
b337d757c9 Merge 'aosp/upstream-master' into 'aosp/master'
... to update Minigbm for Cuttlefish to support Gralloc3
on Minigbm.

Bug: b/157902551
Test: m && launch_cvd --gpu_mode=gfxstream
Test: m && launch_cvd --gpu_mode=drm_virgl
Merged-In: I27f020b4f661890bcc2817deb09ffb9af1c76f1b
Change-Id: Ic96add709a99005ff7aa6c7d886e3069b827e4bc
2020-07-08 12:03:20 -07: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
Jason Macnak
01b2926cf7 Merge 'aosp/upstream-master' into 'aosp/master'
... to merge in http://crrev.com/c/2171157 which
is needed for Cuttlefish on Minigbm Gralloc 4.

Also adds OWNERS.android to avoid merge conflicts
with upstream OWNERS file.

Bug: b/146515640
Test: launch_cvd
Test: launch_cvd --gpu_mode=drm_virgl
Change-Id: I6dafb814cc47e3193439cc10af74a0099962813e
2020-05-18 12:11:50 -07:00
Jason Macnak
a03926ece6 minigbm: Fix cast to avoid null pointer arithmetic
'external/minigbm/cros_gralloc/gralloc0/gralloc0.cc:417:50:
error: arithmetic on a null pointer treated as a cast from
integer to pointer is a GNU extension'

BUG=b:146515640
TEST=m gralloc.minigbm

Change-Id: I2e86b676224657bdb656a45db4cfa49e84b61c2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2202518
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-05-16 02:08:37 +00:00
Gurchetan Singh
bc4f023bfc minigbm: add resource_info callback for virtio-gpu
In ARC++, the wayland sevice and the video stack rely on
GRALLOC_DRM_GET_STRIDE and (*lock_ycbcr) with zero flags to return
the metadata associated with the buffer.

In the past, we've simply returned the metadata that was calculated
during allocation.

Since the current virtio-gpu API relies on shadow buffers, there's
actually two different sets of metadata:

1) The metadata of the shadow buffer --> useful for mapping
2) The metadata of the host resource --> useful for passing to Chrome

For the wayland_service and video stack, we want to return (2).
For the Android framework, we want to return (1).

BUG=b:132939420
TEST=compile

Change-Id: I1134d651396ba68e064eaf2e3cad3cb3225d7c5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1681383
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2020-03-26 21:48:47 +00:00
Gurchetan Singh
8d88474891 minigbm: run presubmit.sh, modify OWNERs
BUG=none
TEST=none

Change-Id: I07ae6fa603117f16dee39b1b7e9ca3162daa0c97
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2118462
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2020-03-24 21:02:36 +00:00