Commit graph

1853 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
cce8dc57df Add missing mediatek gralloc4 init .rc file
The gbm_mesa cherry-pick series added a mediatek gralloc@4.0 service
definition but the corresponding init .rc file was missing from the
aosp/android-16.0_r3 branch. Create it from the msm template.

Copyright (C) 2026 Brendan Szymanski <hello@bscubed.dev>
2026-07-15 22:46:56 -04:00
dvab-sarma
0367f79617 reverting
since these constraints are not applicable to Rockchip SoCs, removing them
2026-07-15 22:37:40 -04:00
Konsta
a261650432 gbm_mesa: Disable verbose logging
Change-Id: Ia0bbc7f6e2301392ec631508785052573b73bdd7
2026-07-15 22:37:40 -04:00
Konsta
bd1b4e1aea gbm_mesa: Add constraints for hardware video decoder & encoder
Change-Id: I41d2987b30f7a54b481cabb8be8ddab5c68eff63
2026-07-15 22:37:40 -04:00
Konsta
5e001f8239 gbm_mesa: Change mapper name 2026-07-15 22:37:40 -04:00
Konsta
d500d5ee8d gbm_mesa: Add android makefiles and init/vintf fragments
* APEX is based on cuttlefish implementation [1].

[1]: https://android.googlesource.com/device/google/cuttlefish/+/refs/tags/android-16.0.0_r1/guest/hals/gralloc/
2026-07-15 22:37:40 -04:00
Roman Stratiienko
e297f9bacd minigbm: Add gbm_mesa backend
This is adaptation of the Rob Herring's gbm_gralloc HAL [1] to work
as minigbm backend, optimised to work in modern Android conditions.

gbm_gralloc has a huge potential and can provide more-or-less optimal
allocation by using mesa3d allocation APIs. It should work out of the
box for the all hardware mesa3d is supported.

Limitations:
This backend doesn't care of any other SOC-specific graphical components
such as camera, hardware video codecs, etc.

Differences between gbm_gralloc:
1. Designed to distinguish between Allocator and Mapper-sphal users.
   For Allocator gbm driver is initialized using standalone KMS card
   node (but only if 'lima', 'panfrost' or 'v3d' GPU was detected).
   For Mapper requests driver is initialized only using GPU render node.
   (which require less permissions for regular apps but suffitient
    for mapping).
2. GBM driver is initialized and bo is imported into gbm_mesa only
   if Mapper imports bo with software usage flags.
   (no time wasted in case SW access isn't required)
3. gbm_gralloc supported only HAL_PIXEL_FORMAT_YV12 video format. This
   driver aims to support more formats (using linear modifier only).

* NOTE:
This may also require:
1. Adding secomp rule into the mediaswcodec.policy file
"sched_getaffinity: 1"
2. Adding records to selinux vendor/file_contexts file
"/vendor/lib{64}?/libgbm_mesa_wrapper.so
 u:object_r:same_process_hal_file:s0"
"/vendor/bin/hw/android\.hardware\.graphics\.allocator@4\.0-service\.minigbm_gbm_mesa
 u:object_r:hal_graphics_allocator_default_exec:s0"
3. Kernel v5.3+ for using fstat(dma-buf)->inode as unique buffer id

[1]: https://github.com/robherring/gbm_gralloc

v2:
- Fixed incorrect size calculations for NV12 buffers
- Add etnaviv, freedreno and vc4 to gpus list which require kmsro entry
- Rebased

v3:
Squashed local fix commits:
- RPI4: Add alignment for CSI camera
- gbm_mesa: Handle DRM_FORMAT_R8 format to handle BLOBS
- gbm_mesa: Always use DRM_FORMAT_R8 for buffers that unsupported by GBM
- gbm_mesa: Add RGB888 format support for CPU access
- gbm_mesa: Remove incorrect negation
- gbm_mesa: Fallback COMPOSER buffers into VRAM
- gbm_mesa: Add combinations to support external camera

v4:
- Use dlopen/dlsym to access gbm_wrapper
- Add fallback allocation for unsupported by mesa3d formats

v5:
- Obtain map-time stride and report it to Android as pixel-stride.
  Map-time strides are different after gbm_create and gbm_import.
  Use map stride after gbm_import.
  This fixes artifacts on Intel and Nouveau.
- GBM wrapper has been converted from cpp to c
- Code refactor and cleanup
- Licence headers added

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: If0f3dac42bea74f97a87e5a682380c33f4ff6837
2026-07-15 22:36:25 -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
4e28ceda1c minigbm: Add const to the backend::name
... to avoid compile-time error on C++:

   error: ISO C++11 does not allow conversion from string
   literal to 'char *' [-Werror,-Wwritable-strings]

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I176eb657f72e92d6b5c7c3b25c78c56f776c20ab
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
710cfdaae9 Drop DRM master after opening card node so the composer can master it
Change-Id: I6e40ed8fbfec788bc8f5382338d573057f230f79
2026-07-12 14:31:15 -04:00
Android Build Coastguard Worker
b7c93249f6 Snap for 14087972 from c96cdaec99 to 25Q4-release
Change-Id: I7de54aadcb8ba91e73301d040a9fc80c6064e4e1
2025-09-11 16:13:43 -07:00
Treehugger Robot
c96cdaec99 Merge "UPSTREAM: add pciids to support wildcatlake" into main 2025-09-11 11:29:38 -07:00
George D Sworo
4f3c903d81 UPSTREAM: add pciids to support wildcatlake
Bug: b:444260542
Test: Builds, CQ
Change-Id: I544c58d57529696c313601aafce2d75f133b874c
Signed-off-by: George D Sworo <george.d.sworo@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6932115
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Miguel Quintero <miguelquintero@google.com>
Commit-Queue: Miguel Quintero <miguelquintero@google.com>
Tested-by: Ryan Neph <ryanneph@google.com>
2025-09-11 16:46:40 +00:00
Yiwei Zhang
854a9186df gralloc: hide AIDL metadata for gralloc0-only build if requested
This is needed for ARC-R container targets using arc-cros-gralloc.

Meanwhile, bump -std=c++14 to -std=c++17 for std::optional and others.

Bug: b/433317686
Test: chromium CI + android CI
Change-Id: Id9ed5f27f6788ca63d0bdb9566c54b3cd4030e16
2025-09-10 15:40:18 -07:00
Android Build Coastguard Worker
974ed40e5b Snap for 13894195 from 6f6b9e3c6f to 25Q4-release
Change-Id: I9ec50cf5ee24a52af97aca7032a4f4b52d64549d
2025-08-06 17:49:55 -07:00
Andrew Wolfers
6f6b9e3c6f ANDROID: Add CfVkmsCursorTest to desktop-presubmit TEST_MAPPING
Bug: 416728882
Change-Id: Icf53d8887dce8d2f48375513dd3fa96bd4a5c87b
2025-07-31 14:44:18 +00:00
Android Build Coastguard Worker
b097d6a581 Snap for 13825504 from a3dd421100 to 25Q4-release
Change-Id: Ibd6333bbfc8249ccb558a304e2b3025002495779
2025-07-23 16:15:31 -07:00
Hirokazu Honda
a3dd421100 mediatek: Open restricted_mtk_cma in O_RDONLY
The write permission for restricted_mtk_cma is unnecessary.

Bug: 433330646
Test: allocate a buffer with GRALLOC_USAGE_PROTECTED usage
Flag: EXEMPT: desktop-only change
Change-Id: Id99a0e03f2e1c7cbb9f15596316dd21aaebdf4a3
2025-07-22 18:40:05 -07:00
Hirokazu Honda
c785301bd3 cros_gralloc: Map GRALLOC_USAGE_PROTECTED to BO_USE_PROTECTED on API 35+
Bug: 433330646
Test: allocate a buffer with GRALLOC_USAGE_PROTECTED usage
Flag: EXEMPT: desktop-only change
Change-Id: I9a47dbb13655b141bfeaa9820632428647e7419b
2025-07-21 21:57:03 -07:00
Android Build Coastguard Worker
7a3ceeda34 Snap for 13722806 from 9f2c22f6e9 to 25Q4-release
Change-Id: I2bf636cb476563a9e57f3b05058b99a91e24e87b
2025-07-01 16:12:26 -07:00
Android Build Coastguard Worker
eb721b438b Snap for 13715904 from e714ab660b to 25Q4-release
Change-Id: Id417d3ef1041e62d914bbe14c1b13404f0d5017c
2025-06-30 16:12:54 -07:00
Yiwei Zhang
9f2c22f6e9 ANDROID: drop arcvm targets from blueprint
...since generic is the one to use going forward.

Bug: N/A
Test: presubmit
Change-Id: Idd427e4619ef44e126c6b8c245571df5cc02f1e5
2025-06-30 23:08:29 +00:00
Yiwei Zhang
6f379aae87 UPSTREAM: virtgpu_virgl: default to enable blob mem for compatible cases
All of virgl, venus and gfxstream have long been able to handle the
limited blob mem usage in the legacy backend.

BUG=b:327668289
TEST=AHB cts passing with Venus on Cuttlefish on ANV

Change-Id: Ie6a26c2e5e74faac6f8db060ffcfbb2364610d41
2025-06-30 22:58:00 +00:00
Andrew Wolfers
e714ab660b Merge "virtio: Add USE_CURSOR buffer padding" into main 2025-06-30 06:47:43 -07:00
Andrew Wolfers
34fcb9cbe2 virtio: Add USE_CURSOR buffer padding
This change modifies buffer allocation to include necessary padding
for buffers with the BO_USE_CURSOR flag. This behavior mirrors
identical logic in the i915, xe, and mtk implementations.

Bug: b/426503691
Change-Id: Ic572a970dcde0606fa9ec5844c57d3136c5d0b84
(cherry picked from commit f13b0faac8501a3bf3eb90f2fd07107728576876)
2025-06-27 17:20:40 +00:00
Android Build Coastguard Worker
1aea2d6c4d Snap for 13701173 from 7b8d54b37b to 25Q4-release
Change-Id: I46bd23b020587939a0f5d91caedff7522a8fa5aa
2025-06-26 16:14:16 -07:00
Treehugger Robot
7b8d54b37b Merge "UPSTREAM: presubmit: switch to cros format" into main 2025-06-25 17:07:06 -07:00
Android Build Coastguard Worker
5337b2bb1d Snap for 13697098 from 035900982f to 25Q4-release
Change-Id: I0433d9f8119b9557e39d42d4edd1779c6fb3d71e
2025-06-25 16:14:22 -07:00
Mike Frysinger
bc47e98159 UPSTREAM: presubmit: switch to cros format
Rather than use `clang-format` from $PATH (which changes between devs),
use `cros format` which has a pinned version for all people.

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

Then run format on the files to fix latent issues.

BUG=None
TEST=./presubmit.sh

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

Bug: None
Test: lunch brya-trunk_staging-userdebug && m libminigbm_gralloc
Change-Id: I23022dbb536ade53951fe61014c5056e114f4bbc
2025-06-24 17:37:57 -07:00
Dominik Behr
035900982f remove mediatek suffix entries
Everything now builds under the same minigbm name for all platforms.

Bug: 388092228
Test: Boot corsola to desktop
Flag: EXEMPT: desktop-only change

Change-Id: I00708383151f832bcccec1aad8091f422dfcf2c3
2025-06-18 17:20:32 -07:00
Android Build Coastguard Worker
4ca4aadc20 Snap for 13613609 from ce30391748 to 25Q4-release
Change-Id: I565ee5b58cb7e109fd7b9f35c8d10ed33deee8b0
2025-06-07 14:12:30 -07:00
Andrew Wolfers
ce30391748 mtk: Add USE_CURSOR buffer padding
This change modifies buffer allocation to include necessary padding
for buffers with the BO_USE_CURSOR flag. This behavior mirrors
identical logic in the i915 and xe implementations.

Bug: b/420919101
Change-Id: I113162cf400116e2627b2a6bb20b560207117cf3
2025-06-03 13:34:24 +00:00
Android Build Coastguard Worker
e09c88148e Snap for 13580881 from 6af751e128 to 25Q4-release
Change-Id: Ib2a0787def05c4e89fd3e3479a2cf3caf74c71d9
2025-05-31 14:11:09 -07:00
Android Build Coastguard Worker
0abba512e5 Snap for 13547578 from a4f32f9172 to 25Q4-release
Change-Id: Iae80a25af57419e55d95dfc95f3dd51843be1252
2025-05-24 14:13:45 -07:00
Yiwei Zhang
6af751e128 cros_gralloc: fallback to check ro.board.platform for SS VK
For bringup purpose, SS VK might be used to boot the system. To ease the
runtime vulkan icd switch, normally we preset TARGET_BOARD_PLATFORM to
pastel, so that to leave ro.hardware.vulkan unset post boot. At runtime,
we can push a real hw driver and set ro.hardware.vulkan to switch to it,
which can be safely reset after reboot.

Bug: b/417259528
Test: boot to ui with SS VK chosen by TARGET_BOARD_PLATFORM
Change-Id: I37212fadaf007c2c2d054b878f0a4f411f1a6fe8
2025-05-24 05:54:09 +00:00
Android Build Coastguard Worker
9a305c521a Snap for 13513381 from 1159d2a4d7 to 25Q4-release
Change-Id: I20e855b5c5cc9b9af24098f257c10713724bd2b1
2025-05-17 14:11:39 -07:00
Andrew Wolfers
a4f32f9172 xe: Add CURSOR_USAGE buffer padding
This change modifies buffer allocation to include necessary padding
for buffers with the BO_USE_CURSOR flag. This behavior mirrors
identical logic in the i915 implementation.

Bug: b/417750580
Change-Id: I3358678fd194eff24fad2cb3749ca59bac33afb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6546486
Commit-Queue: Andrew Wolfers <aswolfers@chromium.org>
Tested-by: Andrew Wolfers <aswolfers@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Drew Davenport <ddavenport@chromium.org>
2025-05-15 19:39:14 +00:00
Treehugger Robot
1159d2a4d7 Merge "Move hwc3 to goldfish" into main 2025-05-14 17:25:30 -07:00
Roman Kiryanov
ba24dd28c2 Move hwc3 to goldfish
goldfish-opengl will be retired

Bug: 416327221
Test: presubmit
Change-Id: Ie7250187d9604f9c6f9d368a513493dc72aa5c58
Signed-off-by: Roman Kiryanov <rkir@google.com>
2025-05-14 22:29:41 +00:00
Dominik Behr
2548d3f434 mediatek: add gpu data buffer support
for all render/scanout formats and R8 and non YUV image source formats.

Bug: 414820115
Test: run dEQP-VK.image.swapchain_mutable.android.2d_array

Change-Id: I074f84b75f9096a77c9db90e66fcbd98672372ea
2025-05-13 14:29:41 -07:00
Android Build Coastguard Worker
77c1fc375a Snap for 13476683 from 07dac8aaa3 to 25Q4-release
Change-Id: I9de3f00e5d064b7201b1b3a2bb9c4263ebc214e1
2025-05-10 14:11:55 -07:00
Dominik Behr
60aa3a0304 add dma-heap.h to external
and use it instead of system headers

Bug: 411474910
Test: mm ccdec in system/cros-codecs
Change-Id: I7a58acaa610e1678a379a4c28886938075e39037
2025-05-09 14:05:18 -07:00
Yiwei Zhang
07dac8aaa3 minigbm: add a CleanSpec
so that to avoid any residual init, vintf, libs, etc when switching
gralloc backends for incremental builds.

Bug: N/A
Test: toggle between gralloc version and m and check
Change-Id: I2c19aa115b584de938e2364e40a52c56c901adda
2025-05-03 02:34:02 +00:00
Android Build Coastguard Worker
531e794179 Snap for 13412669 from 9596b87800 to 25Q4-release
Change-Id: Ia158bf7a3d76d775bf80636b30c2fcf1c17d6e39
2025-04-26 14:11:01 -07:00
Juston Li
9596b87800 Merge "UPSTREAM: xe: support BO_USE_GPU_DATA_BUFFER for image storage formats" into main 2025-04-23 10:15:39 -07:00
Juston Li
724084e75f UPSTREAM: xe: support BO_USE_GPU_DATA_BUFFER for image storage formats
Android gralloc via AIDL allows use of AHB-backed external memory for
storage images with usage AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFER; its
equivalents are VK_IMAGE_USAGE_STORAGE_BIT/BO_USE_GPU_DATA_BUFFER.

On older interfaces before gralloc 4.1/AIDL, BO_USE_GPU_DATA_BUFFER
is only allowed for BLOB formats; this adds it to combinations with
non-BLOB formats for the newer interfaces.

The image_storage_formats list is a subset of the formats being used
that support VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT which for anv is
power-of-two formats; here it ends up excluding the YCbCr formats.

Bug: 397763052
Test: dEQP-VK.wsi.android.[display_timing.*/ swapchain*]

Change-Id: I6b034790fa77f15fb341acfae4a45255231a5a14
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6442090
Commit-Queue: Juston Li <justonli@google.com>
Commit-Queue: ChromeOS Auto Runner <chromeos-auto-runner@chromeos-bot.iam.gserviceaccount.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: Juston Li <justonli@google.com>
(cherry picked from commit db68fa51e4b7ed19546c80806da9f462c3b5c8d7)
2025-04-22 22:34:30 +00:00
Dominik Behr
1a29f8b3da cros_gralloc: AIDL fixes for pixelformats and getMetadata
- fix return values for getArmMetadata
- add some understanding of new AIDL pixelformats

Bug: b/388092228, b/397712115, b/377616165
Test: boot corsola with AIDL gralloc/stable c mapper
Flag: EXEMPT desktop-only

Change-Id: I66b2ec6af7227cfb4c92e9459aeeee00aaa14b8f
2025-04-21 16:47:40 -07:00