Commit graph

134 commits

Author SHA1 Message Date
Roman Stratiienko
4f7758ffa1 minigbm: Use dmabuf inode as unique buffer id instead of handle
Handle has some limits and can't be used as unique buffer ID on systems
where display controller can scanout from CMA but GPU can work with both
CMA and VRAM.

Such systems have DRM/KMS and DRM/GPU drivers separated.
GBM frontend is always expecting handle for DRM/KMS driver.
In such system any attempt of importing the buffer with more
than 1 contiguous chunk into DRM/KMS driver will fail.

Using dma-buf inode as unique buffer ID is a common practice for
a last several years starting from [this kernel patch][1].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed63bb1d1f8469586006a9ca63c42344401aa2ab
Change-Id: Ic3a69010d5da2f866a2252fc7e9eb29d67f8e1ed
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2026-07-16 00:53:22 -04:00
Roman Stratiienko
446588514a minigbm: Add drv_bo_get_pixel_stride function
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>
2026-07-15 22:36:25 -04:00
Roman Stratiienko
529b476a9e minigbm: Add bo_get_plane_fd backend hook
Non-DRM drivers shouldn't rely on handles and DRM API.
Add hook to allow drivers create custom implementation.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I458dae38f80697184070019606b125992a9aa01d
2026-07-15 22:36:25 -04:00
Roman Stratiienko
37858e5143 minigbm: Add external driver support
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
2026-07-15 22:36:25 -04:00
Carlos Santa
3ab89b0247 xe: add initial Xe kmd support for gen12 xelp
Adds a new intel backend for interfacing with the Xe kernel driver.
Currently only tested on gen12 (Xe1; e.g. TGL, ADL, MTL).

Test 1: drm-tests (natively): stop ui and then run:
	- mapped_texture_test
	- null_platform_test -m [I915_FORMAT_MOD_X_TILED|I915_FORMAT_MOD_Y_TILED]
	- plane_test (by default it uses NV12)

Test 2: full OS: boot to UI, execute webGL and/or YouTube successfully and watch
the terminal: TERM=xterm watch -n1 -d cat /sys/kernel/debug/dri/0/i915_display_info
for color formats and display plane usage

v1: Carlos Santa <carlos.santa@intel.corp-partner.google.com>
v2: Ryan Neph <ryanneph@google.com>
  - formatting fixes
  - remove deprecated #ifdef I915_SCANOUT_Y_TILED conditional compilation
  - add missing backend_xe implementations
  - mimic i915_add_combinations
    - Match formatting, order of operations, and add the missing combo for
      YVU420_ANDROID + USE_CAMERA_WRITE.
    - In a future CL, we'll factor this into a common function called by both
      backends.
  - simplify xe_bo_map()
    - The conditional body is always taken, so remove the conditional entirely.
  - mark late-gen12 as mtl_or_newer until proper version handling is used.

BUG=b:358427077
TEST=drm-tests (see above)

Change-Id: I1eaa1dcce6cee706a421b3c4d6a532a6b83f8564
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6245159
Tested-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Matt Turner <msturner@google.com>
Reviewed-by: Lina Versace <linyaa@google.com>
2025-02-10 11:07:50 -08: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
e950d82ae2 drv: Use __func__ instead of __FILE__
... to avoid needing a basename() which is dropped from string.h
in musl.

Bug: b/328316038
Test: android build
Change-Id: Ib619b9c45a30ce69be30270fe7da0f13421179be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5352313
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Auto-Submit: Jason Macnak <natsu@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
2024-03-12 00:27:45 +00:00
Rob Clark
958cd774ae minigbm: Add an API to return cache attributes
Crosvm currently makes the simplistic assumption that if driver==i915
then cached mappings to guest should be used for minigbm allocated
buffers.  But this may not always be the correct choice.  And other
drivers can do cached mappings to, in certain cases.  But on ARM devices
in particular, we should be consistent in cachability when it comes to
CPU mappings.  So add a new minigbm API which crosvm can use to
determine how to map to guest.

BUG=b:239718180, b:306548532
TEST=no artifact in Camera FOV Calibration of CtsVerifier on rex

Change-Id: I5c9b6346270f6a2eb83e6637a911f2153f6120ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3777567
Tested-by: Chia-I Wu <olv@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2024-02-01 17:40:19 +00:00
dawnhan
56f157bb8a minigbm: add unit test for minigbm public apis
This is the first change to add unit tests for the public APIs in
minigbm.
Only tests 3 APIs here for now, and just added some very simple input
for each api testing.

The ultimate goal would be cover more APIs and the input combinations.

BUG=b:304380938
TEST=cros_workon_make --board=guybrush minigbm --test
TEST=cros_run_unit_tests --board guybrush --packages "minigbm"
TEST=CQ

Change-Id: Id15806b7bc6cd9c4764bf08becec6546d72bb117
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4923791
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
2024-01-30 20:59:57 +00:00
Chia-I Wu
48a3e34e16 drv: add support for bo logging
When MINIGBM_DEBUG=log_bos is set, log all bos created/imported.

BUG=none
TEST=add MINIGBM_DEBUG=log_bos to /etc/chrome_dev.conf and
     see logs in /var/log/ui/ui.LATEST

Change-Id: Ib2b2d5c3181862b557dbc5499fef84f2c9ac8122
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5014198
Commit-Queue: ChromeOS Auto Retry <chromeos-auto-retry@chromeos-bot.iam.gserviceaccount.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
Tested-by: Chia-I Wu <olv@google.com>
2023-11-15 01:58:57 +00:00
Lina Versace
c445362dbf drv: Do not send log msgs to stdout
On non-Android, minigbm sent error messages to stderr, and all other log
messages to stdout. Logging should NEVER go to stdout, because it
corrupts the output of programs that send structured output to stdout,
such as vulkaninfo.

BUG=none
TEST=build

Change-Id: Ia36285af50e3a2fa0fdf91f1e12a6c64ebc13944
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4756817
Auto-Submit: Lina Versace <linyaa@google.com>
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Tested-by: Lina Versace <linyaa@google.com>
Reviewed-by: Dawn Han <dawnhan@google.com>
Commit-Queue: Lina Versace <linyaa@google.com>
2023-08-09 00:29:07 +00:00
Amit Pundir
1376622a9b minigbm: drv: Fix MINIGBM_DEBUG usage on Android
MINIGBM_DEBUG usage in drv_get_os_option() is broken on
Cuttlefish at the moment and we run into following selinux
denial.

W libc    : Access denied finding property "MINIGBM_DEBUG".
I auditd  : type=1400 audit(0.0:39): avc:  denied  { read } \
for  comm="android.hardwar" name="u:object_r:default_prop:s0" \
dev="tmpfs" ino=184 scontext=u:r:hal_graphics_allocator_default:s0 \
tcontext=u:object_r:default_prop:s0 tclass=file permissive=0

On Android builds, MINIGBM_DEBUG can translate to a vendor
property if not used as an env variable. To fix that property
usage on Android, we start with using the proper (lowercase)
Android property nomenclature. This will sadly break the usage
of MINIGBM_DEBUG env variable on Android builds and will
force users to use vendor.minigbm.debug property instead.

Change-Id: I05a6213d2460cf5f7d20d3d04a014965ca03bebe
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4630128
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-07-05 20:29:28 +00:00
Dawn Han
3940cbd883 minigbm: move camera work-around
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>
2023-05-02 21:06:13 +00:00
Dawn Han
84b3a09ef0 minigbm: clean up bo.handles
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>
2023-04-09 18:57:40 +00:00
Dawn Han
ecbc89179e minigbm: Remove plane in bo_map
Remove the parameter to align with upstream gbm.
For some places that use the number of planes. The number is 1. The
multi-planar formats are being allocated into a single plane, and
minigbm exynos backend is dropped. So we can just set the plane
index to 0 if needed.

Fixed the format in i915.c.

Bug=b:266776512
TEST=camera works after deploying the change #strongbad
TEST=camera works after deploying the change #corsola

Change-Id: I0880917754c01b9d0f27d21f3c42d87f00a09f50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4249501
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2023-02-27 19:34:38 +00:00
Chia-I Wu
bf1f37f516 drv: add drv_preload
It can be used to preload a backend, currently only used to preload
amdgpu.

BUG=b:269664560
TEST="grep radeonsi /proc/$(pidof zygote)/maps" on grunt

Change-Id: I30d9f701f1da3bc243a9c81326a1ba0c5e0562de
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4262034
Commit-Queue: Chia-I Wu <olv@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Chia-I Wu <olv@google.com>
2023-02-21 19:57:34 +00:00
Chen-Yu Tsai
dd9c86425b minigbm: Add more dumb drivers
Add dumb drivers for Allwinner (sun4i-drm), MediaTek, and Rockchip
platforms. The latter two are only built and used if their respective
drivers are not selected.

BUG=b:258331312
TEST=Build Chromium VDA tests with crrev.com/c/3380427 and
     GbmDeviceWrapper using /dev/dri/card* and use_v4l2_codec=true
     Run VDA tests on RK3399 or Allwinner H6 decoding VP8 using legacy
     decoder should pass tests
     `emerge-kevin minigbm` and `emerge-cherry minigbm` should not fail

Change-Id: I82fb8815d5282f6a252a4d530eb764abb7c8c496
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4060691
Reviewed-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Miguel Casas <mcasas@google.com>
Commit-Queue: Chen-Yu Tsai <wenst@chromium.org>
Auto-Submit: Chen-Yu Tsai <wenst@chromium.org>
2022-12-07 14:36:24 +00:00
Yiwei Zhang
0495473b90 minigbm: deprecate drv_log to favor log level
TEST=build

Change-Id: I3f0021bfd05eb1ab7c3b35ae2f31d806bc0a58dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761446
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-19 04:16:15 +00:00
Yiwei Zhang
7b3cbeabbb drv/virtgpu: add log level for logging
Harmless initialization logging should be info instead of error.

TEST=build and check logcat
BUG=b:234143058

Change-Id: I41ff39b428feb85d01663eec74b3f826007337c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3759415
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-14 08:48:27 +00:00
Bas Nieuwenhuizen
631d9e4d65 drv: Add new bo_release driver callback.
The current bo_destroy callback only gets called if the bo has the
last references to the GEM BOs, and otherwise plain free gets
called.

However, this is an issue if bo->priv contains something per bo that
needs to be cleaned up. To solve this we introduce a new callback
to clean up things per bo instance.

BUG=b:185869479
TEST=none for this patch. See follow-on patch making use of this.

Change-Id: I9d48b3b5a70264adbc4de55a5c7b18e1a2209553
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3270683
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2021-11-12 14:06:34 +00:00
Yiwei Zhang
dc74898d1c minigbm: cleanup exynos backend leftovers
BUG=b:199524294
TEST=CQ

Change-Id: I9a82304247bd506b24e08219fc359874f39fd221
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3214692
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-12 02:45:09 +00:00
Yiwei Zhang
8bc35bf9cc drv: check if a bo has lost all references in a 2nd pass
The same buffer can back multiple planes with different offsets. Thus
when we dereference the bo, we have to check again after all planes are
dereferenced.

This change also adds a missing unlock on an asserted return pass in
drv_bo_mapping_destroy.

BUG=b:201767377
TEST=atest android.media.cts.DecodeAccuracyTest#testGLViewDecodeAccuracy

Change-Id: I9dabf2f9b7ed33c9ed2f45b8ae498e98bfb0fc03
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3203235
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2021-10-05 06:25:36 +00:00
Yiwei Zhang
b8ad7b88ca minigbm: refactor to add unified resolve_format_and_use_flags helper
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>
2021-10-05 03:43:18 +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
Jason Macnak
04c8f51144 drv: fix unused variable
external/minigbm/drv.c:404:7: error: unused variable 'ret'
                int ret = drv_bo_mapping_destroy(bo);
                    ^

BUG=b:201325625
TEST=build latest in AOSP

Change-Id: I4070419aeae4054ed3eda084b810a3143a41b74f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3194819
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-30 09:06:10 +00:00
Jason Macnak
336fd05c8a drv: add support to query backend for max texture size
BUG=b:194426249
TEST=launch Cuttlefish w/ 2D mode
TEST=launch Cuttlefish w/ 3D mode

Change-Id: Iee5f7b88a73b9e5b8cf89de1d8b67308a696083f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3194813
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-30 07:58:13 +00:00
Yiwei Zhang
84236dd5a2 drv: split driver_lock into buffer_table_lock and mappings_lock
Reduce unnecessary lock contention.

BUG=b:201110412
TEST=CQ

Change-Id: I88264285ef993fccec671a6c955b5ccac0db8f4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3188472
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:24 +00: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
Yiwei Zhang
7fae5d05e6 minigbm: refactor bo refcount and mapping destruction
1. internalize drv specific helpers into drv.c
2. simplify bo ref counting and clean up
3. refactor drv_bo_mapping_destroy

BUG=b:201110412
TEST=CQ

Change-Id: If297ef7007c1d14a69ae467b6d1c67c4edf5b177
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3188470
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-29 01:31:21 +00:00
Yiwei Zhang
9420ffe3db virtgpu_virgl: strip scanout if necessary in resolve_use_flags
For guest running 3d virtgpu_virgl atop 2d virtgpu_virgl as host gbm
backend. Common and required scanout capable formats on the guest side
will fail virgl_supports_combination_natively check, resulting in
advertising no scanout support to the guest.

This change adds the same logic to resolve_use_flags before checking
support or asking for allocation to accommodate accordingly. Then
whether to strip scanout use_flag can align with native support on those
guest side scanout capable formats.

Advertising scanout for NV12 needs to go through virgl_add_combination
as well for the native support check. This is fixed by this CL.

The logic to strip scanout needs to be scanout use_flag specific to
avoid accidentally stripping scanout when the format fails texture check
but later passes the emulation check because scanout has been stripped.
This is also fixed by this CL.

BUG=b:200969382
TEST=CQ and camera interop works

Change-Id: I9126773a1ee49d4cdaf1f7186612d5f4f5c6200e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3180981
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-25 03:56:22 +00:00
Yiwei Zhang
c1413ea43a minigbm: conditionally fallback to strip scanout use_flag
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>
2021-09-22 19:47:06 +00:00
Yiwei Zhang
9f390d92a4 minigbm: remove redundant drv param in resolve_format
BUG=b:199524294
TEST=build

Change-Id: I53eaa20847afc6e80ae957b746248468420c30b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3174312
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-22 19:47:05 +00:00
Yiwei Zhang
01b697472e minigbm: populate errno for all code path of drv_bo_create
Error code triaging from drv_bo_create relies on errno. This patch fixes
the missing generation of errno, so that cros_gralloc_driver::allocate
can return the errno on failure.

BUG=b:199524294
TEST=CtsNativeHardwareTestCases

Change-Id: Ie6bf374d1a1c68800463b17ab00a08d859755641
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3163927
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-17 13:47:53 +00:00
Yiwei Zhang
1f9b9000b7 minigbm: completely hide bo->meta from cros_gralloc
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>
2021-09-17 13:47:51 +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
Nathan Hebert
5141a19052 minigbm: Remove Tegra support.
Background:
Tegra K1 (nyan) boards are not longer supported by ChromeOS. The last
compatible device stopped receiving updates after 2020-08-01.

ChromeOS code developed for this board can be removed.

Changes:
* Remove Tegra minigbm handler and plumbing.

Bug: b/180870522
Change-Id: I288b292fa8c85c17e9df1e65b0bf3295b56cb8a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2782243
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Fritz Koenig <frkoenig@chromium.org>
2021-03-25 17:17:21 +00:00
Gurchetan Singh
73c141e48e minigbm: virtgpu/cross_domain: next generation virtgpu backend
This change provides a route to the host side "cross domain"
allocator, which is specialized for resource sharing across domain
boundaries.  It uses the upcoming CONTEXT_INIT ioctl to initialize
the backend when available, and multiple timelines to perform
metadata queries.

While it would be awesome to use the revolutionary Address Space
Graphics (ASG) algorithm for metadata queries, it would be
non-trivial to pull off in minigbm.

Key aspects of the cross-domain allocator are:

* Intelligently falls back to OpenGL texture allocation host-side
  when external memory is not available.  The fallback path is
  named "virgl", even though it encompasses gfxstream and 2D mode.
  More refactorings will be added in the future for further
  clarity.

* Uses host Vulkan or minigbm to perform metadata query, and uses
  a cache to minimize vmexits.

* No shadow memory.  Only zero-copy blobs will be supported if the
  blob is mappable.  Shareable blobs may be compressed or tiled if
  not mappable.

* A commitment to sharing code across Google projects and
  cross-platform GPU virtualization.

The main goal here is to enable faster interation/testing, so this
code is just a prototype.  It should be fine to merge via minigbm,
since the project has a very chill philosophy and even proudly
accepts code that doesn't make any sense (crrev.com/c/2583188)
[so long as existing users are not broken].

BUG=b:173630595
TEST=launch virtual machine with 2D mode
TEST=launch virtual machine with 3D mode

Change-Id: Ie33a46f19e5cdd82a2ac03bcf2351f4a8f294970
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2691716
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-17 07:25:37 +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
Gurchetan Singh
52155b4b57 minigbm: format_modifiers[0] -> format_modifier
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>
2021-01-29 22:47:35 +00:00
François-Denis Gonthier
cea0b84e41 Add vkms support
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>
2020-12-11 18:12:07 +00:00
Pilar Molina Lopez
28cf2f1d70 minigbm: add buffer bandwidth compression flag to gbm device
Read MINIGBM_DEBUG env var when creating a gbm driver
Store value as a flag inside driver
Avoid allocating compressed buffers in the backends
when the flag disables compression

BUG=b:172215587

Change-Id: Idbd6f0aebc1782c1bf5921a6438310a87212d1f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2535658
Tested-by: Pilar Molina Lopez <pmolinalopez@google.com>
Commit-Queue: Pilar Molina Lopez <pmolinalopez@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
2020-12-04 20:12:34 +00:00
Gurchetan Singh
238001ffd0 minigbm: add back in udl/evdi
These drivers are still in use for MIMO displays.

BUG=b:171725208
TEST=enterprise_RemoraRequisitionDisplayUsage

Change-Id: Idecc686e7977a1739943ccb01df849552e40f979
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2505738
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-29 03:44:07 +00:00
Anders Dellien
e5bef53ed2 minigbm: komeda: Refactor the 'dumb' drivers and add Komeda support
Several drivers are very similar in that they only use the 'dumb'
operations. This patch puts all such drivers into a single file and
also adds a driver to support the Arm Komeda/D71 display processor.

TEST=Boot Android and verify that we reach the home screen

Change-Id: If39605deaef446adf8d6693d760a16c2c3f84649
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2429952
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-22 03:01:29 +00:00
Gurchetan Singh
9964438dbb minigbm: reduce use of memset
Also run presubmit.sh.

BUG=none
TEST=compile

Change-Id: I6f5d2afca41c4228a4f8eb40f3670b39bce7b641
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2459529
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-12 21:56:58 +00:00
Gurchetan Singh
ec9bbc28aa minigbm: remove vgem from minigbm (take 2)
In theory, vgem is only used on Android, and nothing
should fail. In theory.  Otherwise, we can just revert
again.

BUG=b:141278896
TEST=compile

Change-Id: I998cb83d5342e454b876f4b74274df96b4951882
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2412903
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-09-29 20:46:17 +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
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
Leona Chou
8f708a18e6 minigbm: add synaptics gbm driver
Change the ozone platform from cast to drm
add synaptics gbm driver for buffer management.

BUG=b:152384632
TEST=use chromecast ui to verify drm
TEST=use ozone_demo app to verify drm

Change-Id: I9dff03e6b522ee84e34cbbcb28a40ca7857c4168
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2108458
Reviewed-by: Daniel Nicoara <dnicoara@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Daniel Nicoara <dnicoara@chromium.org>
Commit-Queue: Daniel Nicoara <dnicoara@chromium.org>
2020-03-26 18:46:05 +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