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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>