Commit graph

121 commits

Author SHA1 Message Date
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
David Stevens
26fe682306 Reland "minigbm: introduce test allocation"
This reverts commit 08d8dbf094.

The original change returned early from drv_bo_create_with_modifiers,
which broke reference counting. This must have hit some race condition
in the tests, as they no longer flake after fixing reference counting.

Original change's description:
> Revert "minigbm: introduce test allocation"
>
> This reverts commit f0e607c7d4.
>
> Reason for revert: caused flaky regressions across the board.
>
> BUG=b:150997559
> Exempt-From-Owner-Approval: revert.
>
> Original change's description:
> > minigbm: introduce test allocation
> >
> > This change introduces a GBM_TEST_ALLOC flag to minigbm, which allows
> > for the creation of fake buffers that can be used to determine buffer
> > metadata without actually allocating a full buffer. The new flag is
> > supported by the i915 backends. This flag also alleviates the need to
> > cache buffers when virtio_gpu queries metadata properties.
> >
> > BUG=b:145994510
> > TEST=play youtube with arcvm demo image plus this and virgl change
> >
> > Change-Id: I9c6819aa3b5b674e4bb33b0656f2a9f155b0884e
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1980688
> > Tested-by: David Stevens <stevensd@chromium.org>
> > Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
> > Commit-Queue: David Stevens <stevensd@chromium.org>
>
> Bug: b:145994510
> Change-Id: I50079b7f0aabf38e1f373cac0f28c0e057eed760
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2093923
> Commit-Queue: Ilja H. Friedel <ihf@chromium.org>
> Tested-by: Ilja H. Friedel <ihf@chromium.org>
> Reviewed-by: Ilja H. Friedel <ihf@chromium.org>

Bug: b:150997559, b:145994510
Change-Id: If0f02a4701bb6960b6413d6b0c00b481146914d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2094068
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
2020-03-10 04:17:30 +00:00
Ilja H. Friedel
08d8dbf094 Revert "minigbm: introduce test allocation"
This reverts commit f0e607c7d4.

Reason for revert: caused flaky regressions across the board.

BUG=b:150997559
Exempt-From-Owner-Approval: revert.

Original change's description:
> minigbm: introduce test allocation
>
> This change introduces a GBM_TEST_ALLOC flag to minigbm, which allows
> for the creation of fake buffers that can be used to determine buffer
> metadata without actually allocating a full buffer. The new flag is
> supported by the i915 backends. This flag also alleviates the need to
> cache buffers when virtio_gpu queries metadata properties.
>
> BUG=b:145994510
> TEST=play youtube with arcvm demo image plus this and virgl change
>
> Change-Id: I9c6819aa3b5b674e4bb33b0656f2a9f155b0884e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1980688
> Tested-by: David Stevens <stevensd@chromium.org>
> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>

Bug: b:145994510
Change-Id: I50079b7f0aabf38e1f373cac0f28c0e057eed760
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2093923
Commit-Queue: Ilja H. Friedel <ihf@chromium.org>
Tested-by: Ilja H. Friedel <ihf@chromium.org>
Reviewed-by: Ilja H. Friedel <ihf@chromium.org>
2020-03-08 09:17:47 +00:00
David Stevens
f0e607c7d4 minigbm: introduce test allocation
This change introduces a GBM_TEST_ALLOC flag to minigbm, which allows
for the creation of fake buffers that can be used to determine buffer
metadata without actually allocating a full buffer. The new flag is
supported by the i915 backends. This flag also alleviates the need to
cache buffers when virtio_gpu queries metadata properties.

BUG=b:145994510
TEST=play youtube with arcvm demo image plus this and virgl change

Change-Id: I9c6819aa3b5b674e4bb33b0656f2a9f155b0884e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1980688
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-03-05 03:12:45 +00:00
Junichi Uekawa
d441f4ec33 minigbm: Reformat with clang-format.
Touching the files seem to cause reformatting.

BUG=None
TEST=None

Change-Id: I31d2fbb01f4ee803da2b740dea036971e861bf60
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2027288
Tested-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2020-02-03 06:12:15 +00:00
Gurchetan Singh
e32ec0be67 minigbm: gbm.h: organize our downstream patches
This patch series is not bisectable.

BUG=b:145747113
TEST=compile

Change-Id: I447e554f27e55e43a4f5d3ca8f1725eda46852fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1963001
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-01-17 02:58:14 +00:00
Jason Macnak
0907d821cc Make drv_mapping_destroy() be called in release builds
The entire assert statement is currently being dropped when NDEBUG is defined
which causes mappings to never be cleaned up on bo destruction. When mappings
are not cleaned up, a new buffer that gets a recycled handle may find an old
mapping in drv_bo_map() which is not valid for the new buffer.

BUG=b:123764798
TEST=built and ran with cuttlefish locally

Change-Id: Ib7147c3f5ed3a2b84793dfc2b17236ee0d92ac13
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1912760
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
2019-11-16 19:34:52 +00:00
Gurchetan Singh
298b757913 minigbm: factor out metadata from struct bo
Generated using coccinelle:

@@
struct bo *B;
@@

- B->width
+ B->width

BUG=chromium:924405
TEST=compile

Change-Id: I4da1731a650d198ce7f2bda3031a47b2f9c3041c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1815566
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
2019-09-24 17:23:42 +00:00
Kazuhiro Inaba
5b91ec0481 Revert "minigbm: remove vgem backend"
This reverts commit d014ed5b4c.

Reason for revert: broke video tests on rockchip devices b/141093122
Bug: 141278896
Bug: 141093122

Original change's description:
> minigbm: remove vgem backend
> 
> It's not used anymore, or atleast shouldn't be.
> 
> BUG=none
> TEST=CQ will test
> 
> Change-Id: Ib9232a7704bd39e59a8e2a5bc2ece62c5dd8e9c1
> Reviewed-on: https://chromium-review.googlesource.com/1643676
> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
> Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

Bug: none
Change-Id: I6645e9b32ebc6dcd97d126cc40523f516a201a05
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1812540
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Kazuhiro Inaba <kinaba@chromium.org>
Auto-Submit: Kazuhiro Inaba <kinaba@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
2019-09-19 14:47:01 +00:00
Gurchetan Singh
d014ed5b4c minigbm: remove vgem backend
It's not used anymore, or atleast shouldn't be.

BUG=none
TEST=CQ will test

Change-Id: Ib9232a7704bd39e59a8e2a5bc2ece62c5dd8e9c1
Reviewed-on: https://chromium-review.googlesource.com/1643676
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2019-09-13 10:48:32 -07:00
Gurchetan Singh
62a7f2ef51 minigbm: clang format
It's good to run this once and a while.

Change-Id: I69b6f9252455360b6d326a3ec89fe51517abda2f
Reviewed-on: https://chromium-review.googlesource.com/1719976
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-07-26 18:25:19 -07:00
Gurchetan Singh
0d44d48d52 minigbm: modify resolve format hooks a bit
Plumb the driver backend to the resolve format hook.

BUG=b:132939420
TEST=compile

Change-Id: I3ac10f5c986bc5dae5b34cd70654676d4ad289ea
Reviewed-on: https://chromium-review.googlesource.com/1645879
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
2019-07-03 02:02:15 -07:00
Gurchetan Singh
39490e9e3f minigbm: run presubmit.sh and add OWNERS file
This now apparently is required.

Change-Id: I28b19684d207aad50493974dc71d8249bc82ca21
Reviewed-on: https://chromium-review.googlesource.com/1633452
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2019-05-30 22:02:07 -07:00
Tomasz Figa
90f8bb08f4 minigbm: Fix some clang-format issues
No functional changs.

BUG=none
TEST=compile

Change-Id: I6b302e9bbf9d46489bfaa03d3b5cf2b070cb1d24
Reviewed-on: https://chromium-review.googlesource.com/1356697
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-12-23 19:19:33 -08:00