Commit graph

99 commits

Author SHA1 Message Date
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
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
50c42dfdc3 minigbm: fix a racing in mapping destruction and a hashtable leak
drv_mapping_destroy needs to be protected by the driver_lock while it
isn't at drv_bo_destroy.

Current drv->buffer_table won't clean up those BO plane buffers whose
refcnt has reached zero.

BUG=b:201110412
TEST=CQ

Change-Id: I917dc60f95ec35e0cea320c8d8914274ed6ddb39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3183472
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:20 +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
Jason Macnak
2ce35775fd virtgpu: Support P010
Enable basic 10-bit YUV P010 buffer support for use
with camera and image readers.

This is upstreaming aosp/1576366

BUG=b:147711411
TEST=Camera CTS

Change-Id: Ieaeda7189b528ec603390ff1b2012f582c627eae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2946769
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-06-16 18:48:17 +00:00
Gurchetan Singh
695125c0b3 minigbm: add drv_resolve_format_helper
Removes duplicated code.

BUG=none
TEST=CQ

Change-Id: Iea59cc6ca20e13756b6121db7f5294855cc6cfcd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2672509
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-04 19:14:50 +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
Drew Davenport
b65708a918 helpers: Use backend num_planes_from_modifier only when modifier set
If modifiers are not set, or if only linear modifier is set, just return
the number of planes based on the format. If there are other modifiers
set, then query the backend.

BUG=b:172830088
TEST=Start camera on zork after mesa uprev

Change-Id: I130e9ef3730b35f6e8777ce9c1919de2eb466733
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2528204
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Drew Davenport <ddavenport@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2020-11-13 08:46:56 +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
David Stevens
b42624c3e6 virtgpu: improve blob support on ARCVM
This change expands the types of buffers which use blob allocation, to
cover decoder/encoder bitstream buffers. It also adds tiling to the
exported buffer metadata, so that flush/invalidate are properly skipped
on imported blob buffers.

BUG=None
TEST=tast run ARCVM-DUT arc.VideoDecodeAccel.*

Change-Id: I460f4448db9e1bd2f7458f3180c4e92ff3b3d74f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2400839
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-09-17 01:13:16 +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
Jason Macnak
778e21ddb3 Fix YV12 dumb buffer plane sizes
Allocating a 1280x720 YUV420 (YV12) buffer results in
calling the create dumb ioctl with 1280x1080 and results
in a file with size 1384448
(1280 * 1080 = 1382400, ALIGN(1382400, 4096) = 1384448).

The existing code calls drv_bo_from_format with the
aligned height of 768 which results in oversized planes
totaling a size of 1474560 bytes. This ultimately leads
to segfaults when running past the end of the mapped
file.

Because the dumb buffer iotcl height is computed using
the buffer's unaligned height (bo->meta.height), the
call to drv_bo_from_format should use the unaligned
height as well.

BUG=b:146515640
TEST=cts android.media.cts.EncodeDecodeTest

Change-Id: I40893cf92caa9d35a89d21a3512604f361822222
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2171157
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-05-01 23:02:30 +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
Gurchetan Singh
28e5ea0f88 minigbm: remove KMS dependency
Adds unneeded complication and extra kernel patches.
Hopefully with Chrome using modifiers we can remove this.

BUG=b:145747132
TEST=compile and run

Change-Id: I557bbd50828d7e39848c315a44a24587c9e2ce3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1976277
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
2020-02-18 22:37:26 +00:00
Hirokazu Honda
2a2bfc25bb mediatek: Allocate a buffer expected by encoder if BO_USE_HW_VIDEO_ENCODER
MediaTek driver expects 16 aligned width and 32 aligned height for an input
buffer on encoding [1]. Besides, there is an extra data between planes.
This changes the minigbm allocation to match the expectation though width
is aligned by 64 for the AMD cache-width optimization.

[1] https://chromium.googlesource.com/chromiumos/third_party/kernel/+/3c551224d8600b956ed53097520501d58f31cf59/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c#278
BUG=b:144135251
TEST=ARC++ encoder on kukui
Change-Id: Id330a8a6b0a40040098920427e6e29f05fcb64d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1855520
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Tested-by: Hirokazu Honda <hiroh@chromium.org>
Auto-Submit: Hirokazu Honda <hiroh@chromium.org>
Commit-Queue: Hsu Wei-Cheng <mojahsu@chromium.org>
2019-12-25 08:26:11 +00:00
Dominik Behr
6e6dc49707 minigbm: virtio: restrict formats supported without 3D
Upstream virtio drm commit "drm/virtio: fix DRM_FORMAT_* handling" severely
restricts supported formats and strictly enforces 32bpp dumb buffers.
Therefore now we only support XRGB8888 for scanout, ARGB8888 for cursor,
ARGB8888 for rendering. Also, we pretend all buffers are 32bpp when allocating
as dumb buffers.

BUG=none
TEST=tast run 127.0.0.1:9222 webrtc.RTCPeerConnection.vp8

Change-Id: I6225a9cb3c49f0850c6d94b2d12efaf9a33b149e
Signed-off-by: Dominik Behr <dbehr@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1849773
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-12-12 06:36:24 +00:00
Jasmine Chen
c7aa974dd3 Add MediaTek private format for reprocessing
In this CL, we add DRM_FORMAT_MTISP_SXYZW10, a 10-bit private bayer
format for private reprocessing on MediaTek ISP P1. We change the logic
around resolving the DRM format for IMPLEMENTATION_DEFINED buffers. When
CAMERA_READ usage flag is present, we consider it to be a buffer for
reprocessing and resolve the format to our private format.

BUG=b:130851309
TEST=Emerge and deploy minigbm cros-camera-libcbm cros-camera
cros-camera-hal-mtk, then verify that ZSL is working.

Change-Id: I8d9fd4e6a20c284751915e136bef0b4ceb143d78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1753902
Tested-by: Jasmine Chen <lnishan@google.com>
Auto-Submit: Jasmine Chen <lnishan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Jasmine Chen <lnishan@google.com>
2019-12-05 07:56:40 +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
Gurchetan Singh
dc9b120451 minigbm: rockchip/mediatek: remove R8 as texture source on Mali/Bifrost
EGL can't import this format on Mali/Bifrost.

BUG=chromium:969044
TEST=Ozone unit test

Change-Id: I356ec2bd35030af600b268bf39565e30e16465f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/1643677
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Commit-Queue: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
2019-09-19 16:59:17 +00:00
Nataraj Deshpande
586e2d6f3a minigbm: Add support for RGBA_1010102 and RGBA_FP16
The CL adds support for HAL_PIXEL_FORMAT_RGBA_1010102 and
HAL_PIXEL_FORMAT_RGBA_FP16 in order to supplement Android
framework's VkFormats: VK_FORMAT_A2B10G10R10_UNORM_PACK32
and VK_FORMAT_R16G16B16A16_SFLOAT.

Fixes following dEQP failures on eve-arcnext.
dEQP-VK.wsi.android.swapchain.create#image_format
dEQP-VK.wsi.android.swapchain.simulate_oom#image_format
dEQP-VK.wsi.android.colorspace#basic
dEQP-VK.wsi.android.incremental_present.*

BUG=b:139890132
TEST=Run dEQP-VK.wsi.android.* tests on eve-arcnext.

Change-Id: I0b52d9f970d34fe69e1b8c31a1f096365a74d8ec
Signed-off-by: Nataraj Deshpande <nataraj.deshpande@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/1769261
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-09-17 16:59:30 -07:00
Greg Hartman
4a0fecf12f Fix potential uninitialed read
BUG=none
Test=can compile crosvm
Change-Id: I65577ca08f4d41ff6a7b6d2a2af42f82798608bf
Tested-by: ghartman@google.com
Reviewed-by: adelva@google.com
Reviewed-on: https://android-review.googlesource.com/c/platform/external/minigbm/+/1056177
Reviewed-on: https://chromium-review.googlesource.com/1707385
Tested-by: Greg Hartman <ghartman@google.com>
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-24 00:33:00 -07:00
Ludovico de Nittis
1cbcbfd5f9 minigbm: fix uninitialized variable error
To fix the maybe uninitialized error we assign plane_type a starting
value.
The number zero corresponds to DRM_PLANE_TYPE_OVERLAY, so instead we
initialize plane_type to UINT64_MAX.

Bug: chromium:968030
Change-Id: I4fe119c1491926227151742041a73207971f56f0
Reviewed-on: https://chromium-review.googlesource.com/1634771
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Stéphane Marchesin <marcheu@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-06-12 15:56:42 -07:00
Miguel Casas
055a6aa3e8 Add support for DRM_FORMAT_P010
Test: Tested with chrome's ozone_gl_unittests: crrev.com/c/1561136
Bug: 911754
Change-Id: I8a9a28ba1c3a1186fd88b43c85098a5550fa1c8b
Reviewed-on: https://chromium-review.googlesource.com/1590464
Commit-Ready: Miguel Casas <mcasas@chromium.org>
Tested-by: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2019-05-02 16:12:39 -07:00
Fritz Koenig
1b9b5b93fd minigbm: mediatek: Implement bo_create_with_modifiers
Mediatek MT8183 only supports DRM_FORMAT_MOD_LINEAR.

BUG=b:123042223, b:129645475
TEST=null_platform_test -m DRM_FORMAT_MOD_LINEAR

Change-Id: I1938e52a9b221f25b62ddd27916a2222be8c0a46
Reviewed-on: https://chromium-review.googlesource.com/1529226
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Fritz Koenig <frkoenig@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-04-02 11:09:54 -07:00
Stéphane Marchesin
6ac299f3d3 minigbm: Fix consistency in return values
minigbm functions don't use errno; however drmIoctl does. So we need
to return -errno instead of returning exactly what drmIoctl returns.

BUG=none
TEST=builds

Change-Id: I20e00141782ac1407133ee72259fe43381954d26
Reviewed-on: https://chromium-review.googlesource.com/1534878
Commit-Ready: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-03-26 04:43:19 -07:00
Gurchetan Singh
86ddfdc267 minigbm: use drv_add_combination when adding a single combination
We defined the function, but it's since gone unused.

Change-Id: I23e7e57413c4a7c82d9da302b79e6b9c5068654d
Reviewed-on: https://chromium-review.googlesource.com/1229438
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2018-09-21 00:51:14 -07:00
Gurchetan Singh
2fdb721c35 minigbm: delete unused functions and definitions
Change-Id: Ie5f8b148e3f051edde08b0b46ab22a80f034ff80
Reviewed-on: https://chromium-review.googlesource.com/1229437
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2018-09-21 00:51:13 -07:00
Gurchetan Singh
2b1d689b0c minigbm: run clang-format
Change-Id: I9b5c3db33bd0c7914a214e2181d655aec84632c5
Reviewed-on: https://chromium-review.googlesource.com/1229436
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-09-18 14:03:55 -07:00
Keiichi Watanabe
d706a8c4f9 minigbm: move height adjustments to helper function
Because HAL_PIXEL_FORMAT_YV12 requires that height is not aligned,
adjustments are needed when the format is DRM_FORMAT_YVU420_ANDROID.
This adjustment was done in each driver, but it can be moved to the
helper function.

BUG=None
TEST=VDA test in import mode on Cheza

Change-Id: I23a8a6e674664e80c30ea66b75d79e10edc28d5d
Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1172262
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-08-14 02:13:27 -07:00
Keiichi Watanabe
79155d7822 minigbm: run clang-format
Though presubmit.sh requires formatting by clang-format, some files
are not formatted.

BUG=None
TEST=compile

Change-Id: I828dd85536cb94dc98cd11e83ec86af53a425070
Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1172241
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-08-14 02:13:26 -07:00
Keiichi Watanabe
af94db9f0a minigbm: adjust height of NV12 buffer in helper
When the format is NV12, additional buffer is required for the UV plane.
Though size adjustment for this requirement is currently implemented
only in the msm driver, it is not specific to this device.

This commit moves the adjustment to helper function
'drv_dumb_bo_create', which is called from each driver.

BUG=chromium:852302
TEST=video playback on msm

Change-Id: I690f79ccc6a2c99e680b0d293ffa6002f74ae6bf
Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1163582
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-08-14 02:13:26 -07:00
Satyajit Sahu
a047d4113f minigbm: increment ref count in drv_bo_import
increment the reference count of gem handle in
drv_bo_import instead of backend.

BUG=b:111378370
TEST=graphics autotest suite

Change-Id: I68bc64e421f8505be5cd46874f02ab5c32805f04
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1134720
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-07-13 02:22:29 -07:00
Gurchetan Singh
6bd7885bcf minigbm: run clang-format
It's good to do this now and again.

BUG=none
TEST=none

Change-Id: Ie96486b5d34c99a4b00cdfd8488a0468188d35bd
Reviewed-on: https://chromium-review.googlesource.com/1089492
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-06-07 23:33:11 -07:00
Gurchetan Singh
767c538889 Revert "minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16"
This reverts commit 292da5365a.

Reason for revert: The Android framework uses successful allocation of HAL_PIXEL_FORMAT_RGBA_FP16 to test for wide-gamut capabilities.  We don't want to advertise this, so let's revert.

android.graphics.cts.BitmapColorSpaceTest#test16bitHardware

can pass if the framework falls back to RGBA8888, as is the plan.

Original change's description:
> minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16
>
> This is needed to support the following CTS test:
>
> android.graphics.cts.BitmapColorSpaceTest#test16bitHardware
>
> There have been some rumblings about adding 64-bit formats to <drm_fourcc.h>:
>
> https://lists.freedesktop.org/archives/intel-gvt-dev/2017-July/001469.html
>
> However, nothing has landed, so let's just define our own format
> for the time being.
>
> BUG=b:77973662
> TEST=Compile for kevin and kevin-arcnext
>      Unfortunately, my P setup refuses to work, so let the lab
>      test.
>
> Change-Id: I1fea16400ba6632a8ef17105e27bc7799d2af515
> Reviewed-on: https://chromium-review.googlesource.com/1029355
> Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>

Bug: b:77973662
Change-Id: I9e4b79b06dd565189a2e783e8453f08af173d84c
Reviewed-on: https://chromium-review.googlesource.com/1045805
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-05-08 21:15:47 -07:00
Kristian H. Kristensen
222919005b minigbm: Drop drv_bo_get_stride_in_pixels() helper
Computing "stride in pixels" assumes the pixel size divides the
stride, which isn't always the case.  This is only used for the
cros_gralloc implementation, so lets move the calculation there
instead of providing a generic helper for an unhealthy concept.

BUG=822346
TEST=test_that graphics_Gbm

Change-Id: Iab7a363c5471e4bacef7df7095ef77723adf5e93
Reviewed-on: https://chromium-review.googlesource.com/996645
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-05-04 03:02:36 -07:00
Gurchetan Singh
292da5365a minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16
This is needed to support the following CTS test:

android.graphics.cts.BitmapColorSpaceTest#test16bitHardware

There have been some rumblings about adding 64-bit formats to <drm_fourcc.h>:

https://lists.freedesktop.org/archives/intel-gvt-dev/2017-July/001469.html

However, nothing has landed, so let's just define our own format
for the time being.

BUG=b:77973662
TEST=Compile for kevin and kevin-arcnext
     Unfortunately, my P setup refuses to work, so let the lab
     test.

Change-Id: I1fea16400ba6632a8ef17105e27bc7799d2af515
Reviewed-on: https://chromium-review.googlesource.com/1029355
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-04-27 12:22:38 -07:00
Kristian H. Kristensen
478343f363 minigbm: Consolidate format info in new struct planar_layout
This consolidates the relevant information about the planar layouts we
support in one place.

Change-Id: I6fbfd59f5d56777f612e4cc44e634ed193a435ad
Reviewed-on: https://chromium-review.googlesource.com/996646
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-04-18 19:55:40 -07:00
Alistair Strachan
0cfaaa5adb Use Android log system in helpers.c.
This code might be loaded by a daemonized process now, so the existing
logging to stderr goes nowhere. It's better to use the Android logger.

Change-Id: I19f088b8f049f07c9c6839038d2971fad1a0e852
Reviewed-on: https://chromium-review.googlesource.com/971360
Commit-Ready: Alistair Strachan <astrachan@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2018-03-21 23:23:37 -07:00
Gurchetan Singh
d118a0e746 Revert "Revert "minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR""
This reverts commit 9ad07155dd.

Reason for revert: We haven't seen improvements in the graphs after the speculative
revert that landed in 10292.0.0:

https://chromeperf.appspot.com/group_report?keys=agxzfmNocm9tZXBlcmZyFAsSB0Fub21hbHkYgICQ6IzqogoM

Original change's description:
> Revert "minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR"
>
> This reverts commit 9927d78669.
>
> BUG=chromium:799639
> TEST=run graphics_GLMark2
>
> Change-Id: Idcf25de31fe2a17cc28900558e19145ca33dbff5
> Reviewed-on: https://chromium-review.googlesource.com/853223
> Commit-Ready: Dominik Behr <dbehr@chromium.org>
> Tested-by: Dominik Behr <dbehr@chromium.org>
> Reviewed-by: Robert Tarasov <tutankhamen@chromium.org>

Bug: chromium:799639
Change-Id: I100b93e41f43c026181eef0777f76b5c2cd93d6c
Reviewed-on: https://chromium-review.googlesource.com/865773
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
2018-01-18 03:44:38 +00:00
Dominik Behr
9ad07155dd Revert "minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR"
This reverts commit 9927d78669.

BUG=chromium:799639
TEST=run graphics_GLMark2

Change-Id: Idcf25de31fe2a17cc28900558e19145ca33dbff5
Reviewed-on: https://chromium-review.googlesource.com/853223
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Robert Tarasov <tutankhamen@chromium.org>
2018-01-08 17:22:58 -08:00
Gurchetan Singh
9927d78669 minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR
CL:737409 replaced DRM_FORMAT_MOD_NONE with DRM_FORMAT_MOD_INVALID in
struct kms_item. We use drv_query_kms() to add the scanout flag to most
buffer combinations. That means anything with DRM_FORMAT_MOD_LINEAR
will not get the scanout flag, since drv_query_kms returns combinations
with DRM_FORMAT_MOD_INVALID. This leads to artifacts in the zero latency
app, since we end up picking a X-tiled buffer since we don't advertise
a linear buffer with scanout.

Since all hardware can scanout linear buffers, replace DRM_FORMAT_MOD_INVALID
with DRM_FORMAT_MOD_LINEAR.

BUG=chromium:762324
TEST=no overlay artifacts running Zero latency app

Change-Id: Ib8a33b9e8dde3767337b9cd32c5b2849f9c8aa04
Reviewed-on: https://chromium-review.googlesource.com/823258
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2017-12-13 03:08:52 -08:00
Gurchetan Singh
bc9a87d54c minigbm: use drv_array for combinations and kms_items
This de-deuplicates the various dynamic arrays we use.

BUG=chromium:764871
TEST=gbmtest passes

Change-Id: I94c8cf7c71fdb98b931aab00c5381853e2ae0d3f
Reviewed-on: https://chromium-review.googlesource.com/758149
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2017-11-16 13:52:02 -08:00
Gurchetan Singh
d300145b09 minigbm: make drv_add_combinations return nothing
Two reasons for this:

	1) We can use drv_array for driver combinations (see next patch)
	2) It's less verbose.

BUG=chromium:764871
TEST=gbmtest passes

Change-Id: I39bea6e2e9e4c76d2ca78566926a79bdc17f11d0
Reviewed-on: https://chromium-review.googlesource.com/758148
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2017-11-16 13:52:02 -08:00
Gurchetan Singh
ee43c301c2 minigbm: use struct vma for (*bo_map)/(*bo_unmap) callbacks
This sets better expectations for what we expect from the
backends.

BUG=chromium:764871
TEST=mmap_test

Change-Id: I7fb815b58fae8e9fbd73bf7c0263c7db44488844
Reviewed-on: https://chromium-review.googlesource.com/770519
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Joe Kniss <djmk@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2017-11-16 10:46:57 -08:00
Gurchetan Singh
cfedbcc8d4 minigbm: use drv_array for mappings
Let's start allowing multiple mappings of the same buffer when
different map flags are passed in.

BUG=chromium:764871
TEST=mmap_test -g on Kevin, gbmtest

Change-Id: I4eb0b6f4c3572a92001696c2720d5a5f7d9d73a4
Reviewed-on: https://chromium-review.googlesource.com/758146
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Joe Kniss <djmk@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2017-11-14 03:22:34 -08:00
Gurchetan Singh
47e629b70d minigbm: refactor and rename mapping struct
Since some drivers (AMDGPU, Tegra) may have to do expensive tiling
and detiling operations, we should try to take advantage of the
access regions passed in by gralloc and gbm. Let's refactor struct
map_data so we can separate the actual mapping and access region.

Here is the Coccinelle rule used in this change:

@@ struct map_info *M; @@
-   (M)
+   M->vma

In addition, struct map_data was also renamed to struct mapping.

BUG=chromium:764871
TEST= mmap_test -g on Kevin

Change-Id: Idb094aa3b5f81e45ce3a2f4fb2d9bf8fba32bf29
Reviewed-on: https://chromium-review.googlesource.com/758144
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Joe Kniss <djmk@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
2017-11-08 22:21:56 -08:00
Kristian H. Kristensen
6061eab812 minigbm/i915: Implement bo_create_with_modifiers
This implements the bo_create_with_modifiers driver functions, which
enables the gbm_bo_create_with_modifiers() entry point. This will
allow ozone to allocate with the modifiers it queries from KMS.

BUG=chromium:763760
TEST=Allocates Y-tiled scanout on SKL+

Change-Id: Id770e571a51aef4d753b30e12cd67d935c5228b7
Reviewed-on: https://chromium-review.googlesource.com/729279
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2017-10-26 13:45:03 -07:00
Kristian H. Kristensen
bc8c5930f7 minigbm: Use more descriptive modifier names
DRM_FORMAT_MOD_NONE means that the buffer layout is "not modified", as
opposed to "no modifier present". In other words, linear, since the
assumption is that that's the starting point.  This was later
clarified by introducing the DRM_FORMAT_MOD_LINEAR as a alias for
DRM_FORMAT_MOD_NONE and DRM_FORMAT_MOD_INVALID as a NULL-like value
for modifiers.

This commit replaces DRM_FORMAT_MOD_NONE with DRM_FORMAT_MOD_LINEAR
where we mean linear (which is most places) and DRM_FORMAT_MOD_INVALID
where we want to indicate "no modifier" (in struct kms_item).

BUG=chromium:763760
TEST=Intel GPU board boots and has X-tiled framebuffers.

Change-Id: I93e1419e1ab4c04ad6ef3d48ada19487b880886d
Reviewed-on: https://chromium-review.googlesource.com/737409
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2017-10-26 11:30:36 -07:00