Some drivers may copy/convert the buffer during mapping and
in some cases stride of copied image can be different from
original. Android uses pixel_stride for CPU access and need
map_time stride instead of original stride in this cases.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Allow backends with custom DRM probing logic or
backends that does not rely on DRM (dma-heap, ION).
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I7bcaf10205ca051eb109d6e220b8a2af38267442
For bringup purpose, SS VK might be used to boot the system. To ease the
runtime vulkan icd switch, normally we preset TARGET_BOARD_PLATFORM to
pastel, so that to leave ro.hardware.vulkan unset post boot. At runtime,
we can push a real hw driver and set ro.hardware.vulkan to switch to it,
which can be safely reset after reboot.
Bug: b/417259528
Test: boot to ui with SS VK chosen by TARGET_BOARD_PLATFORM
Change-Id: I37212fadaf007c2c2d054b878f0a4f411f1a6fe8
... except when running with software rendering as apps do not
know that they would need to request additional CPU_* usage
for GPU_* usage.
Bug: b/356845188
Test: cts -m CtsNativeHardwareTestCases
Change-Id: I3536d80469d2187550558e9d02795896de4f9827
... 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>
Move mt8183_camera_quirk_ into struct cross_domain_private.
Add a helper `drv_get_os_option` in `drv_helper` to query os option.
Advertise DRM_FORMAT_MTISP_SXYZW10 as supported format in virtgpu_cross_domain.c.
Implement cross domain's own resolve_format_and_use_flags entry point.
BUG=b:269982880
TEST=tested on a kukui machine after applying the change. Camera and
screen recording works fine.
Change-Id: Ia0d6e2cc701477aa6b9542de84e24f8aeb5a29e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4304961
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
The multi-planar formats are being allocated into a single plane,
and the minigbm exynos backend is dropped. So we can use `handle` instead of handles as of now.
Remove some of the helper functions that calculate the number of planes.
There is no need to check if there is more than one kernel buffer per buffer object.
Added a new function `drv_gem_close` in `drv_helpers` that can be used by `drv_gem_bo_destroy` and `drv_prime_bo_import`. It can be used to clean the unused gem_handle.
Bug=b:266776512
TEST=camera and screenshot work fine after deploying the change #strongbad
TEST=camera and screenshot work fine after deploying the change #kukui-arc-r
TEST=camera and screenshot work fine after deploying the change, tested a couple of apps in the Google Play Store, and checked file `dma_buf/bufinfo` to see there's no object leaking. #guybrush
Change-Id: Ib63559504e4cb8f1a32ae90170925146613d694f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4297873
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
Correct the formats in cros_gralloc_driver.
Bug=N/A
TEST=N/A
Change-Id: I59bc09ee04dd05ffbd83243d6c071eb018facab2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4324140
Tested-by: Dawn Han <dawnhan@google.com>
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Add support for the MT8183 private camera format to gralloc. This is
done as a vendor specific workaround that bypasses the normal minigbm
format resolution, targeting kukui+ARCVM.
This is aimed at working around the fact that the virtgpu cross domain
backend needs to directly resolve formats itself. Proper support for
involving the host when resolving formats would be cleaner. However,
that would be a substantial amount of work for what is (hopefully) a
one-off situation.
BUG=b:158617858
TEST=testBasicOpaqueToJpegReprocessing on kukui-arc-r DUT
Change-Id: I8e1d74aac0a16babd7d7e2e630ff8affb3104e8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4258986
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
... so that devices that have API level 31 but do not have the
system dmabuf heap installed (as it is not required) do not spam
error logs before falling back to memfd.
BUG=b:227375257
TEST=build Cuttlefish with aosp/2051732
TEST=cvd start
TEST=vts -m VtsHalGraphicsMapperV4_0Target
Change-Id: I7ab79ce472b1e3d84ffa8bb06044ecc933847656
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3563512
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
"Prefer to use a struct instead of a pair or a tuple
whenever the elements can have meaningful names."
BUG=b:207388558
TEST=cvd start
TEST=vts -m VtsHalGraphicsMapperV4_0Target
Change-Id: I688267a4c40f0260476029c0d70bc8bb19943e21
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3481955
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
... as interacting with a cloned handle should not
succeed until it is imported:
```
native_handle_t handle1;
gralloc->alloc(..., &handle1);
native_handle_t handle2 = native_handle_clone(handle1);
gralloc->lock(handle2) <--- should fail!
```
This is a partial revert of crrev.com/c/3433118
BUG=b:207388558
BUG=b:220537482
TEST=cvd start
TEST=vts -m VtsHalGraphicsMapperV4_0Target
Change-Id: Ia9a9f91fca14ea9f30017fb934c5c48064090d43
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3481795
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
... for reserved region / metadata as dmabuf heaps are the hot new
thing replacing ion.
Also, Android already has sepolicy in place for passing around
dmabufs (see `dmabuf_system_heap_device:chr_file` references in
system/sepolicy) while memfds require manual additions (see
aosp/1960673).
BUG=b:207388558
TEST=cvd start
TEST=vts -m VtsHalGraphicsMapperV4_0Target
Change-Id: I9acb30a10afb1f9f273ceb17dd44a9ac96da1a97
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3449613
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
... 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>
... 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>
... to that of SwiftShader + ANGLE (SwANGLE). With SwANGLE,
GL_MAX_TEXTURE_SIZE comes from a combination of
VkPhysicalDeviceLimits::maxFramebufferWidth and
VkPhysicalDeviceLimits::maxImageDimension2Dcomes to meet GLES 3.1
requirements (see https://crrev.com/c/1917130).
BUG=b:194426249
TEST=`cts -m CtsNativeHardwareTestCases` with aosp/1845813
Change-Id: Ia14f241b59742c1bb864ef8f6e19de82bbe8fba4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3208931
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
It makes more sense to resovle the format and use_flags together to
avoid duplicates.
Add the helper to vc4 and dumb_driver backends since that's missed
from prior frontend refactoring.
Split the resolve helper in virtgpu_virgl for the 3d and 2d paths to
make code logic cleaner.
BUG=b:199524294
TEST=CQ
Change-Id: I89b633ea484f0fc5bb9b4e0548cad017b9970cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200143
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
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>
Only 2d virtgpu backend needs to fallback here because virtio primary
plane only allows DRM_FORMAT_XRGB8888.
Most our platforms cannot display YV12 (except msm), thus the fallback
is required for the converted DRM_FORMAT_YVU420_ANDROID. For virgl
backend, additionally append a BO_USE_LINEAR as a replacement for the
hack inside compute_virgl_bind_flags.
BUG=b:199524294
TEST=CQ
TEST=gralloctest alloc_combinations
TEST=android.media.cts.VideoDecoderRotationTest
Change-Id: Ic87838ea2aae2b0abf87ed898ad75a3d7e556471
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166775
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>
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>
This refactoring is to prepare for later unifying use_flags resolution
for all gralloc frontends, so that all fallbacks and special handlings
can be placed in the centralized private helper.
BUG=b:199524294
TEST=CtsNativeHardwareTestCases
Change-Id: I6e37822b7dbaa123c6956ff31bcef6a35a171f74
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3163215
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>
This change also stores the final use_flags used for bo allocation into
hnd->use_flags.
BUG=b:199524294
TEST=build
Change-Id: I0f4e3fbeb90acdd3852ede98e0a42620a757cb74
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3163206
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>
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>
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>
We were previously mismatching bytes and ints in this calculation. With
the current version of the code this seems to be harmless resulting
in allocating a larger native_handle than necessary, but prior to
commit 166fe14ab5 this miscalculation led to a buffer overflow when
cloning the handle, resulting in a failed uaccess when MTE was enabled.
Bug: b:178231152
Change-Id: I70cf86c0eb2dfe1bf343eb143db973a94d7e8b13
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2703833
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
- 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>
The early version of the modifier assumed per plane modifiers.
The current version is only one modifier per buffer object.
BUG=none
TEST=compile
Change-Id: Ic3899118d44cb172ee2e4eae346e98cdf8328cf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2654590
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
ARM-based SOCs usually have a separate display controller unit (IP core)
which has its own kernel driver and capabilities.
In most cases display controllers can handle only contiguous buffers
which require to reserve CMA region for them.
GPU itself usually has embedded MMU and can handle non-contiguous buffers.
In this hardware configuration it makes sense to allocate contiguous
memory for the buffers which will be used by display controller, and
non-contiguous memory for buffers which will be used by GPU only,
thus reducing minimum required CMA reserved region size.
Once a buffer is allocated in a non-contiguous region, any attempt of
importing it to the KMS driver using drmPrimeFDToHandle() will fail
with -EINVAL.
BO Handle was used as a unique per-buffer key, where 'id' field can be
used as well. As a positive side effect of this change number of system
calls is also reduced.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I030849ede744b3d6aea04639c9a13d2fe1ccd71c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2637641
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
The vkms driver is used to get the Android to work on the BeagleBone
Black. Only a minimum amount of support is needed but the driver can
only be recognized by looking at card DRM nodes. The vkms driver does
not publish a render node.
We refactored the cros_gralloc_driver::init to test both the render
nodes and the card nodes.
Change-Id: Ie750aa45fc359ba7917919904693b1ab8088ad16
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2213742
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This change expands the types of buffers which use blob allocation, to
cover decoder/encoder bitstream buffers. It also adds tiling to the
exported buffer metadata, so that flush/invalidate are properly skipped
on imported blob buffers.
BUG=None
TEST=tast run ARCVM-DUT arc.VideoDecodeAccel.*
Change-Id: I460f4448db9e1bd2f7458f3180c4e92ff3b3d74f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2400839
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
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>