Commit graph

29 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
6f3f6cb93a minigbm: refactor the logic in import_into_minigbm
Multi-planer formats are being allocated into a single plane,
so `dmabuf_sizes[DRV_MAX_PLANES]` is no longer needed. There
is only one `dmabuf_size` now.

And use bo->handles[0] only. In the clean-up function, close
handle[0] if it's not empty.

Bug=b:266776512
TEST=camera and screenshot work fine after deploying the
change #kukui-arc-ri

Change-Id: I068bcafbfbaf1b2be543aec3a4d87e1870a10d23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4338596
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
2023-04-09 18:57:38 +00:00
Chia-I Wu
b9d5d6c10a dri: add dri_dlopen and dri_dlclose
They will be used for preloading.

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

Change-Id: I6134e00bf9e046889aea7e471b7f7bcf3972604c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4262033
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
Tested-by: Chia-I Wu <olv@google.com>
2023-02-21 19:57:32 +00:00
Yiwei Zhang
cd1339fc80 minigbm: fix formating
BUG=N/A
TEST=./presubmit.sh

Change-Id: Ibfb97e37d991bcf50f27f54ca9fd4a9afb5e881f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4133685
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
2023-01-03 22:33:49 +00:00
Ikshwaku Chauhan
0b46921a79 minigbm: dri: Enabled useInvalidate for buffer invalidation.
The drivers now require a loader with a working useInvalidate hook.
If not enabled then "createNewScreen2" call will fail in mesa-22.2.0 onwards.

BUG=b:245687387
TEST= screenshot --internal /tmp/test.png
      tast run <IP> graphics.GLBench

Signed-off-by: Ikshwaku Chauhan <ikshwaku.chauhan@amd.corp-partner.google.com>
Change-Id: I0f7319fb7193be6ea938209413e8fbfe3b7f0c93
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3941506
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
2022-10-25 16:05:09 +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
Robert Mader
d73fa7ff37 minigbm: amdgpu: Update plane count in bo_import
This is required for importing multi-plane modifiers where the
format plane count is lower (usually `1`). It will be used
by Exo for v3/4 of the `zwp_linux_dmabuf_v1` Wayland potocol,
allowing Wayland clients (and thus all clients that build on
the Wayland support) to use explicit modifiers which again
can increase performance on many GPUs.

Also add another fallback path to `dri_num_planes_from_modifier()`
for cases when `queryDmaBufFormatModifierAttribs()` fails and do
some refactoring there. Without this, some test apparently fail.

This includes the amdgpu part of
commit 1a733377e9, partially reverting
commit 853b8542fb.

Bug🅱️224580219
Change-Id: I93b64123420b39f3b83ff1bbbb9c59ddf4bc6105
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3568489
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Robert Mader <robert.mader@collabora.com>
Commit-Queue: Robert Mader <robert.mader@collabora.com>
2022-05-04 08:47:25 +00:00
Dominik Behr
26a83b58f7 dri: use unsigned char instead of GLboolean
GL datatypes have been removed in upstream mesa dri_interface.h

BUG=none
TEST=Build minigbm with amdgpu enabled.

Change-Id: I31a89ad806b52352433d055982eff83bd0aeac39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3352528
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Dominik Behr <dbehr@chromium.org>
2022-02-12 07:40:42 +00:00
Bas Nieuwenhuizen
136d9228c0 amdgpu: Use bo_release to free DRI images.
Previously these would get leaked if we had multiple bo structs
pointing to the same image/GEM BO as each has their own DRI image,
but bo_destroy only gets called on the last struct.

To mitigate this we have a new callback for every struct where we
can free the DRI image.

BUG=b:185869479
TEST=Repeatedly open/close camera app on Grunt.

Change-Id: I6188346b5bf9e5cbbbbf32a3db621a3fe0276d4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3270684
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:35 +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
Bas Nieuwenhuizen
4c0371bacf amdgpu: Always allocate bo with modifier on GFX9+.
For virtualization purposes we always want to have a modifier. With
radeonsi that means allocating with modifiers. This has the
complication that the structure of modifiers isn't trivial.

Three implementation options:

1) Add dri-flag to create bo with valid modifier
2) Figure out scanout capable modifiers in minigbm
3) Take scanout capable modifiers from kernel.

3 is an issue because the card node is often behind a video group
on desktop linux and we don't want to create something that won't
work on desktop linux.

For 2 I figured out that the structure is actually fairly simple if
we assume that the DRI driver doesn't provide useless modifiers.

For 1 we'd end up having to do the same work as 2 + define the
DRI interface + maybe have to deal with older somewhat buggy kernels.

So I ended up selecting 2.

Note that this also removes CURSOR usage in the old path with DRI
On AMD we only allow linear for the cursor so this gets handled
in the linear path.

BUG=b:192390822
TEST=Run vkcube on zork-arc-r.

Change-Id: Ibde0e2ec761e293486c8ee71cfd88d9846ba09da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3086527
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2021-08-26 22:53:18 +00:00
Bas Nieuwenhuizen
fba0aca4d1 dri: Use correct attribute for plane count.
We were using the wrong attribute resulting in an error ...

BUG=b:192390822
TEST=Run vkcube on zork-arc-r

Change-Id: Id1bcfc08497ae215c821b4c8b9060390fdf08b7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3118294
Reviewed-by: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
2021-08-26 22:53:17 +00:00
Bas Nieuwenhuizen
03af6f6b13 dri: Fix memory leak.
The string gets allocated in libdrm with strdup so it is the callers
responsibility to free. While at it, also add a proper NULL check, as
NULL can be returned (e.g. when the file doesn't exist in a container).

Found by inspection.

BUG=none
TEST=compile and confirm the UI still starts on Zork.

Change-Id: Ib8701f7a15f030458885eade0effe5c8fe09dc83
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3017875
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-07-12 19:57:05 +00:00
Lepton Wu
c83116f67d minigbm:amdgpu: Add ABGR16161616F format
Virgl are expecting host gpm can handle this format, so just
enable this for amdgpu.

BUG=b:177032502
TEST=manual - run CtsNativeHardwareTestCases on zork-arc-r

Change-Id: I574d3bfda5a86a6a42790cd02edc137f0e367471
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2850989
Tested-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2021-04-27 19:13:41 +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
Roman Stratiienko
142dd9c494 Always export DRM_FORMAT_YVU420_ANDROID as DRM_FORMAT_YVU420
Fixes video playback when gralloc0 and software video decoder are used.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I676060021806186bb3c23928d0d54af4add5120a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2589993
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2020-12-17 04:43:50 +00:00
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
Bas Nieuwenhuizen
457fb69ecc dri: Complete the 10-bits formats.
They were added to the AMDGPU driver but only half of the formats
were in the mapping table.

Fixes: b16076b "amdgpu: Add 10-bit color formats."

BUG=b:161136516
TEST=run graphics_Gbm on Grunt

Change-Id: I445da2df7b049e3c18456b978a79b28d5b7d008a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2297423
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Drew Davenport <ddavenport@chromium.org>
2020-07-15 16:35:21 +00:00
Bas Nieuwenhuizen
912c4c33a9 minigbm: dri: Set the plane sizes on bo creation.
I cut a corner here on a previous patch and apparently it is used.

Since DRI does not give us useful horizontal & vertical strides
(especially considering things like auxiliary surfaces), do this
calculation based on offsets & buffer strides.

BUG=1061315
TEST=test_that graphics_Gbm on Zork.

Change-Id: Idbca7ce42f4f8a692129a2f8ab5d9c3ccd796496
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2100795
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Ilja H. Friedel <ihf@chromium.org>
2020-03-14 03:32:21 +00:00
ChromeOS Developer
9b367b3efe minigbm: dri,amdgpu: Modifier support.
This adds modifier support to minigbm in the amdgpu driver.

This includes

(a) creation of images with modifiers
(b) imports
  - Had to distinguish between legacy and non-legacy.
(c) Support for planes > format planes

BUG=b:149819940
TEST=Login on a Zork device + play a YT video.

Change-Id: If58ada081aa254932e299536c48c18937266c2e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2093212
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-03-10 15:39:10 +00:00
ChromeOS Developer
44588bb282 minigbm: dri: Support 2+ planes query for modifiers.
If the driver does not implement the new function, or
if modifier is INVALID this should return exactly the
same as before.

For LINEAR, DRI should return exactly the same as
minigbm for all the YUV formats.

BUG=b:149819940
TEST=Use with followup patch and login on a Zork device + play a YT
video.

Change-Id: I6ea3b5827876844e510794b85212be51e5dfd68f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2093211
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-03-10 15:39:09 +00:00
Bas Nieuwenhuizen
7119d33191 minigbm: Set modifiers for amdgpu/dri.
I tried kernel with modifier support and userspace without and it
failed due to having a linear (which is 0) modifier for the tiled
textures. Set the modifier explicitly.

BUG=b:144023522
TEST=Chrome shows the login screen on zork (with some other bugfixes)

Change-Id: I806d3bb744e52d094e5b852679057cea3f0bcad0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2043848
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-02-18 13:45:31 +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
Satyajit Sahu
faeb009164 minigbm: Opening new fd for dri backend
Dri backend is not used for the all use flags. When same fd is
shared between dri backend and the minigbm drv, they end up using the
same kernel DRI context.

BUG=b:111081134
TEST=cheets_SurfaceComposition
     graphics_Gbm
     graphics_Gralloc

Change-Id: I47ae12391acfc9c947e8281de11472fcdf5dec5b
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1164972
Tested-by: Deepak Sharma <deepak.sharma@amd.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-08-09 22:04:25 -07:00
Satyajit Sahu
a8a38957d9 minigbm: close bo handle in bo destroy
In dri path the bo handle is not closed in bo destroy. This was
resulting in memory leak. Closed the bo handle in bo destroy.

BUG=b:80546783
TEST=graphis autotest suite

Change-Id: I8d9c7fbc87fd80d03be7d9a98ac8aa95f0d175ed
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1117975
Commit-Ready: Martin Roth <martinroth@chromium.org>
Tested-by: Martin Roth <martinroth@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-06-29 14:16:32 -07:00
Satyajit Sahu
77b7055a16 minigbm: Use the stride value returned by mapImage
mapImage can return a different stride value. This value must be
used for the mapped address.

BUG=b:38152101 b:79346377
TEST=graphics_Sanity autotest passed

Change-Id: Ie0eb716291366ae6a047d704f66d24ec41738713
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1041369
Commit-Ready: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-05-10 15:09:50 -07:00
Satyajit Sahu
a0e602b84f minigbm: For BO_USE_SW usage buffer need not be linear
It is incorrect to force linear for BO_USE_SW usage as mapImage
in dri_bo_map converts tiled data and returns linear.

BUG=b:78200321
TEST=drm_cursor_test completes within 20 seconds.

Change-Id: Ifa3ca2218cee9ff52b049a984a70a54f4899965d
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1041448
Commit-Ready: Drew Davenport <ddavenport@chromium.org>
Tested-by: Deepak Sharma <deepak.sharma@amd.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-05-04 20:37:33 -07:00
Satyajit
cdcebd879c minigbm: using dri extensions
addrlib dependency removed. dri extensions are called instead.
dri.c/dri.h implements the generic dri extensions call.
amdgpu.c implements amdgpu specific.

BUG=b:72972511
TEST=Chrome booted to UI and passed graphics_Gbm autotest

Change-Id: Ia0edec7752a258fe2f70bc4838dac6398d46def2
Signed-off-by: Satyajit <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/863723
Commit-Ready: Satyajit Sahu <satyajit.sahu@amd.com>
Tested-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-04-16 09:20:20 -07:00