OSDN Git Service

android-x86/external-minigbm.git
5 years agoi915: Add GBM_BO_USE_HW_VIDEO_DECODER use flag
Kristian H. Kristensen [Wed, 4 Apr 2018 23:10:42 +0000 (16:10 -0700)]
i915: Add GBM_BO_USE_HW_VIDEO_DECODER use flag

This flag is used to indicate that the platform video decoder will be
writing into this buffer and that it should be allocated
accordingly. On Intel, this means that we have to allocate y-tiled
NV12 for libva to be able to decode to the buffer.

We force gralloc NV12 allocations to be linear for now, since ARC++
doesn't properly pass modifiers to ChromeOS.

BUG=822346
TEST=test_that graphics_Gbm

Change-Id: I840c30d22355d26816df718b49717407e2e4620f
Reviewed-on: https://chromium-review.googlesource.com/996648
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@chromium.org>
5 years agominigbm: remove addrlib dependency for arc-cros-gralloc
Satyajit Sahu [Wed, 16 May 2018 08:52:48 +0000 (14:22 +0530)]
minigbm: remove addrlib dependency for arc-cros-gralloc

addrlib is not required now. Removing the dependency

BUG=b:72972511
TEST=Chrome boots to UI and android play store comes up

Change-Id: If0ddfe8bee2bb74bf898479f7e263ae731e8bea9
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1060935
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
5 years agominigbm: Update Android.mk to export the include path
Daniel Nicoara [Thu, 10 May 2018 21:58:03 +0000 (17:58 -0400)]
minigbm: Update Android.mk to export the include path

Allows other applications depending on it to pick up minigbm headers
without explicitly specifying the path.

BUG=b:78869504
TEST=Compiled application depending on minigbm

Change-Id: Ie1681579145620ba330721393f0ad71a00109102
Reviewed-on: https://chromium-review.googlesource.com/1054615
Commit-Ready: Daniel Nicoara <dnicoara@chromium.org>
Tested-by: Daniel Nicoara <dnicoara@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
5 years agominigbm: Use the stride value returned by mapImage
Satyajit Sahu [Thu, 3 May 2018 11:05:24 +0000 (16:35 +0530)]
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>
5 years agominigbm: amdgpu: switch BO allocation domain to GTT from VRAM
Deepak Sharma [Tue, 1 May 2018 19:11:27 +0000 (12:11 -0700)]
minigbm: amdgpu: switch BO allocation domain to GTT from VRAM

With SG feature enabled, will move all bo allocation to GTT.

BUG=b:69941535
TEST=boot Grunt, run graphics_Stress.tabopenclose

Change-Id: If424709315e36e29bc99400d9333df72d5979aa0
Signed-off-by: Deepak Sharma <Deepak.Sharma@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/1037914
Commit-Ready: Deepak Sharma <deepak.sharma@amd.com>
Tested-by: Deepak Sharma <deepak.sharma@amd.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
5 years agoRevert "minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16"
Gurchetan Singh [Sat, 5 May 2018 00:42:12 +0000 (00:42 +0000)]
Revert "minigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16"

This reverts commit 292da5365a373a8e1eed603fc3aa16e3595d8252.

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>
5 years agoi915: Align stride and offset per plane
Kristian H. Kristensen [Wed, 4 Apr 2018 21:21:41 +0000 (14:21 -0700)]
i915: Align stride and offset per plane

Current code over-aligns the Y-plane dimensions by a factor of two, so
as to make sure alignment requirements are still satisfied when the
subsampled plane stride and height are divided by two. Instead, this
commit changes the approach to align each plane separately after
computing the plane width and height. We stop using
drv_bo_from_format(), which divides the stride and instead loop
through the planes ourselves.

BUG=822346
TEST=test_that graphics_Gbm

Change-Id: I1ea8f2fb8b1780686d4086f51e9bab759f724d78
Reviewed-on: https://chromium-review.googlesource.com/996647
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
5 years agominigbm: For BO_USE_SW usage buffer need not be linear
Satyajit Sahu [Thu, 3 May 2018 10:40:11 +0000 (16:10 +0530)]
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>
5 years agoRevert "minigbm: i915: Add necessary padding to Android YV12 buffers"
Kristian H. Kristensen [Thu, 3 May 2018 20:40:47 +0000 (20:40 +0000)]
Revert "minigbm: i915: Add necessary padding to Android YV12 buffers"

This reverts commit d846de667cba72121ec579912d0854729f013731.

When mesa switched to isl internally, dma-buf import regressed in a
few cases where isl was overly strict.  One issue was enforcing slice
alignment in calculating the minimum size of a buffer.  The alignment
is required for the slice placement, but not the size.  We worked
around it in commit d846de667cba72121ec579912d0854729f013731, but mesa
commit 4d27c6095e8385cccd225993452baad4d2e35420 fixes the problem and
we can now revert the minigbm bandaid.

The revert leaves the change to drv_bo_from_format() in place where it
was modified to look at the passed in format argument instead of
bo->format.

Original change's description:
> minigbm: i915: Add necessary padding to Android YV12 buffers
>
> All the regular formats are already aligned by current code, except
> Android YV12, which requires height of planes to be unchanged. However
> Mesa requires each plane to have at least certain required padding
> between planes. Work around this by calculating total BO size with
> aligned height to allow padding space to overlap with further planes
> and making sure that padding of last plane fits in the buffer. This is
> okay, since Mesa requirement seems to indicate that data of the padding
> area should not be affected and padding is only needed to satisfy GPU
> cache requests.
>
> Fixes following CTS tests on Intel platforms:
> android.media.cts.VideoEncoderTest#testGoogH264FlexArbitraryH
> android.media.cts.VideoEncoderTest#testGoogH264FlexNearMaxMin
> android.media.cts.VideoEncoderTest#testGoogH264SurfArbitraryH
> android.media.cts.VideoEncoderTest#testGoogH264SurfNearMaxMin
>
> BUG=b:63957026
> TEST=./cts-tradefed run cts -m CtsMediaTestCases -t
>  android.media.cts.VideoEncoderTest
>
> Change-Id: I46d44178ba983c0038b630b13b9b281251393f8f
> Reviewed-on: https://chromium-review.googlesource.com/592990
> Commit-Ready: Tomasz Figa <tfiga@chromium.org>
> Tested-by: Tomasz Figa <tfiga@chromium.org>
> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>

Bug: b:63957026
Change-Id: I9a0db4f01a7ec206375f8a0ba5219b5c5d9a4c0e
Reviewed-on: https://chromium-review.googlesource.com/1042746
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
5 years agoRevert "minigbm: i965: Add 64-byte padding at the end of linear buffers"
Tomasz Figa [Wed, 2 Aug 2017 05:35:52 +0000 (05:35 +0000)]
Revert "minigbm: i965: Add 64-byte padding at the end of linear buffers"

This reverts commit 581f3a5e3089cfd5bb38432eb2874d9a5b132a17.

Reason for revert: It looks like the requirements are being
removed from Mesa, due to the kernel driver being expected to
provide certain guaranties over how it manages the GPU address
space, so that they are satisfied (see CL:597567).

With this, we can stop overallocating and simplify minigbm code.

Original change's description:
> minigbm: i965: Add 64-byte padding at the end of linear buffers
>
> According to the ISL library used now by Mesa i965 driver to manage
> surfaces, linear surfaces must have 64-byte padding added at the end,
> due to the way how the GPU issues cache requests.
>
> BUG=b:63957026
> TEST=./cts-tradefed run cts --skip-preconditions --skip-device-info -m
>   CtsCameraTestCases -t
>   android.hardware.camera2.cts.MultiViewTest#testDualTextureViewAndImageReaderPreview
>   on Eve
>
> Change-Id: I4887449a8e6e090b5ab7925b6f5c764cedd7589f
> Reviewed-on: https://chromium-review.googlesource.com/582253
> Commit-Ready: Tomasz Figa <tfiga@chromium.org>
> Tested-by: Tomasz Figa <tfiga@chromium.org>
> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>

BUG=b:63957026
TEST=./cts-tradefed run cts -m CtsCameraTestCases
 -t android.hardware.camera2.cts.MultiViewTest
TEST=./cts-tradefed run cts -m CtsMediaTestCases
 -t android.media.cts.VideoEncoderTest

Change-Id: Id17d65fd9fe81e0152e37e92e8eda39c0fceebf1
Reviewed-on: https://chromium-review.googlesource.com/597529
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
5 years agominigbm: Drop drv_bo_get_stride_in_pixels() helper
Kristian H. Kristensen [Wed, 4 Apr 2018 20:40:47 +0000 (13:40 -0700)]
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>
6 years agominigbm: add support for HAL_PIXEL_FORMAT_RGBA_FP16
Gurchetan Singh [Thu, 26 Apr 2018 00:36:59 +0000 (17:36 -0700)]
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>
6 years agominigbm: cros_gralloc: fix -Wimplicit-function-declaration warnings in gralloctest
Gurchetan Singh [Wed, 25 Apr 2018 22:29:32 +0000 (15:29 -0700)]
minigbm: cros_gralloc: fix -Wimplicit-function-declaration warnings in gralloctest

The arcnext compiler seems to throw more warnings.

BUG=none
TEST=compile for kevin arc-next

Change-Id: Ib7b0518d675db06549312a2e7b814093d75424f5
Reviewed-on: https://chromium-review.googlesource.com/1029354
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: Consolidate format info in new struct planar_layout
Kristian H. Kristensen [Wed, 4 Apr 2018 21:02:50 +0000 (14:02 -0700)]
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>
6 years agoBuild fix against latest AOSP master.
Alistair Strachan [Tue, 10 Apr 2018 01:50:30 +0000 (18:50 -0700)]
Build fix against latest AOSP master.

Move away from using the deprecated header paths in AOSP master. Add
explicit dependencies on the header modules and library modules being
used.

Change-Id: Ifaf159129dd34d2b99f7ee86f6e5fde9276d0aea
Reviewed-on: https://chromium-review.googlesource.com/1005720
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoFix -Wcast-qual warnings.
Alistair Strachan [Tue, 10 Apr 2018 01:49:51 +0000 (18:49 -0700)]
Fix -Wcast-qual warnings.

The Android.mk file enables -Wcast-qual and clang finds problems in
gralloc0.cc where the constness of a pointer is being cast away. AOSP
master is setting -Werror, so these warnings break the build. Fix them.

Change-Id: I8820efab34a15d0653b89303d5390fb9f3eee12d
Reviewed-on: https://chromium-review.googlesource.com/1005719
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: using dri extensions
Satyajit [Fri, 12 Jan 2018 09:19:05 +0000 (14:49 +0530)]
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>
6 years agoi915: Allow allocating ARGB buffers for scanout
Kristian H. Kristensen [Wed, 11 Apr 2018 22:55:13 +0000 (15:55 -0700)]
i915: Allow allocating ARGB buffers for scanout

CL:991261 changed our primary framebuffer format from XRGB to ARGB. We
still only scanout as XRGB where the display controller doesn't
support ARGB, but minigbm doesn't know that. As a result, when we try
to allocate an ARGB buffer with the SCANOUT useflag, we get a linear
buffer.  This breaks PSR and regresses performance and, in general,
just isn't what we want.

This CL enables SCANOUT for all ARGB formats where the corresponding
XRGB formats supports scanout. In the end, it's up to the caller to
make sure a format works for scanout anyway.

BUG=827188,830969
TEST=test_that graphics_Idle on samus

Change-Id: Iab428e5b21abedcac7cee86fccc8df50dab3f471
Reviewed-on: https://chromium-review.googlesource.com/1008867
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: virtio_gpu: select dumb/virgl at runtime.
Lepton Wu [Thu, 5 Apr 2018 19:50:03 +0000 (12:50 -0700)]
minigbm: virtio_gpu: select dumb/virgl at runtime.

For using same image on legacy-qemu and virgl enabled qemu. We need
to handle dumb and virgl code path at run time. Just merge them to
one driver.

BUG=b:77302150
TEST=manual - run novato image under qemu with gl=on/off.

Change-Id: Ia12140fba16a350fe13f4258d25333ecfe8352b3
Reviewed-on: https://chromium-review.googlesource.com/998631
Commit-Ready: Lepton Wu <lepton@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoUpdate Android.mk for amlogic
Albert Chaulk [Thu, 5 Apr 2018 20:56:53 +0000 (16:56 -0400)]
Update Android.mk for amlogic

This adds a separate app-linkable libminigbm target that disables
the gralloc code and links in the gbm api. Adds support for meson
buildflag.

Bug: b/76099793
Test: amlogic test tool, drawframe
Change-Id: I7aba3ec65fa39cabbb8c96c44d6d59b8225956a9
Reviewed-on: https://chromium-review.googlesource.com/998758
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: drv_bo_flush --> drv_bo_flush_or_unmap
Gurchetan Singh [Thu, 29 Mar 2018 23:34:53 +0000 (16:34 -0700)]
minigbm: drv_bo_flush --> drv_bo_flush_or_unmap

There's no flush or invalidate mechnaism with the DRI interface,
so we'll have to support mapping and unmapping.

BUG=b:72972511
TEST=gbmtest passes in CQ

Change-Id: If3aef651f8549544ed4ed499e17f7f99c597974c
Reviewed-on: https://chromium-review.googlesource.com/990892
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-by: Joe Kniss <djmk@google.com>
Reviewed-by: Satyajit Sahu <satyajit.sahu@amd.com>
6 years agominigbm: Enable vc4 driver
Jeremy Grosser [Fri, 30 Mar 2018 08:19:41 +0000 (01:19 -0700)]
minigbm: Enable vc4 driver

BUG=None
TEST=graphics_Gbm on target board

Change-Id: Id92466354e644f9237f8c19aebd0534c1b23bbc0
Reviewed-on: https://chromium-review.googlesource.com/989301
Commit-Ready: Jeremy Grosser <jeremy@synack.me>
Tested-by: Jeremy Grosser <jeremy@synack.me>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: amdgpu: Disable explicit synchronization when possible.
Bas Nieuwenhuizen [Fri, 23 Mar 2018 16:21:37 +0000 (17:21 +0100)]
minigbm: amdgpu: Disable explicit synchronization when possible.

With drm minor 21 both radv and mesa can do all the explicit
synchornization extensions and hence explicit synchronization gets
used.

However, as implicit synchronization is not disabled we can get
surprises like cyclic dependencies if producer and consumer are too
far out of sync with each other.

Therefore this disables implicit synchronization if the kernel is
new enough for explicit synchronization to get used.

v2: - Fix up compile errors
    - Actually set priv->addrlib

BUG=b:76135512
TEST=Run dEQP-VK.wsi.android.swapchain.render.basic 10 times on
     Kahlee.

Change-Id: I6e5389793e82b167e025b7d94958effad278c361
Reviewed-on: https://chromium-review.googlesource.com/978166
Commit-Ready: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoUse Android log system in helpers.c.
Alistair Strachan [Mon, 19 Mar 2018 21:03:23 +0000 (14:03 -0700)]
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>
6 years agoAndroid: Support building the virtio_virgl backend.
Alistair Strachan [Tue, 20 Mar 2018 22:55:20 +0000 (15:55 -0700)]
Android: Support building the virtio_virgl backend.

Enabled automatically if BOARD_GPU_DRIVERS=virgl. If you leave this
unset, the build will still include support for virtio_dumb.

Change-Id: I2cfeab8fb3a0be7b3c1874fa036d433ff57567cd
Reviewed-on: https://chromium-review.googlesource.com/972449
Commit-Ready: Alistair Strachan <astrachan@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoFix minigbm against older kernel DRM versions.
Alistair Strachan [Tue, 20 Mar 2018 18:10:51 +0000 (11:10 -0700)]
Fix minigbm against older kernel DRM versions.

In 4.4, the DRM implementation only allowed DRM_CLOEXEC to be specified to
drmPrimeHandleToFD(), but it gave you a read/write mapping when mmap'ed.

In newer kernels the DRM_RDWR flag needs to be specified to get a
read/write mapping.

Try the new way, and if that fails, try the old way. If the handle
conversion fails for any reason other than this flag check, it'll
still fail.

Change-Id: I7fabb6a0d23e7b9b70f970aad0bc243a76583e33
Reviewed-on: https://chromium-review.googlesource.com/971461
Commit-Ready: Alistair Strachan <astrachan@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoFix the build against AOSP master.
Alistair Strachan [Mon, 19 Mar 2018 21:06:39 +0000 (14:06 -0700)]
Fix the build against AOSP master.

Clear out some bitrot and use the new mechanism for including headers.

Change-Id: I3b74a5472209c7632e7aab757ef88365141c9525
Reviewed-on: https://chromium-review.googlesource.com/971359
Commit-Ready: Alistair Strachan <astrachan@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoBuild fix for older libdrm versions.
Alistair Strachan [Mon, 19 Mar 2018 21:04:23 +0000 (14:04 -0700)]
Build fix for older libdrm versions.

When building against an older libdrm, the DRM_FORMAT_MOD_LINEAR enum
will be missing. It's OK to use DRM_FORMAT_MOD_NONE instead, because
this older libdrm has limited DRM_FORMAT_MOD_xx support and not all of
the backends actually need it.

Change-Id: I0c289c50de4ad1fe5a9b0848961f5bcb75bd4bf8
Reviewed-on: https://chromium-review.googlesource.com/971358
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: virtio_gpu: set vma->length when mmap.
Tao Wu [Tue, 13 Mar 2018 01:07:43 +0000 (18:07 -0700)]
minigbm: virtio_gpu: set vma->length when mmap.

Othewise bo_unmap won't work. Also add a ifdef guard for PAGE_SIZE
to make it also compile under ARC++.

BUG=b:70179880
TEST=Run /usr/local/autotest/bin/screenshot.py with qemu+virgl
TEST=Run Android App under ARC++ with qemu+virgl

Change-Id: I586446c56da091dd82d9bc9c1010d9b4ee4d92ee
Reviewed-on: https://chromium-review.googlesource.com/959527
Commit-Ready: Lepton Wu <lepton@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoRename amlogic backend in minigbm into meson
Sergey Volk [Tue, 6 Mar 2018 21:29:32 +0000 (13:29 -0800)]
Rename amlogic backend in minigbm into meson

The name of Amlogic DRM driver in kernel is "meson", so rename it in
minigbm to match that.

BUG=internal b/74248568
TEST=run ozone_demo on device

Change-Id: If2ef376715231f0b3c9fe320177d0e82d94214f0
Reviewed-on: https://chromium-review.googlesource.com/951912
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Alex Sakhartchouk <alexst@chromium.org>
Tested-by: Sergey Volk <servolk@chromium.org>
6 years agomsm: Align buffer dimensions for llvmpipe
Stéphane Marchesin [Thu, 1 Mar 2018 00:37:46 +0000 (16:37 -0800)]
msm: Align buffer dimensions for llvmpipe

While we are using llvmpipe, we should align the buffer dimensions
to a tile size.

Change-Id: Ia0da10851886a2c25f8a4bff779fe890ec86baef
Reviewed-on: https://chromium-review.googlesource.com/942346
Commit-Ready: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: amdgpu: support DRM_FORMAT_YVU420_ANDROID
Deepak Sharma [Tue, 20 Feb 2018 22:58:26 +0000 (14:58 -0800)]
minigbm: amdgpu: support DRM_FORMAT_YVU420_ANDROID

Add support for DRM_FORMAT_YVU_420 for CTS.

BUG=b:70373715
TEST=build cros-gralloc and run ctsMediaTestcases.

Change-Id: I09f0a3da5ba56a5f275f33348fdb4d61e2fde7db
Signed-off-by: Deepak Sharma <Deepak.Sharma@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/935491
Commit-Ready: Deepak Sharma <deepak.sharma@amd.com>
Tested-by: Deepak Sharma <deepak.sharma@amd.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoi915: Always set the modifier when allocating BOs
Kristian H. Kristensen [Thu, 8 Feb 2018 00:10:06 +0000 (16:10 -0800)]
i915: Always set the modifier when allocating BOs

With CL:907756 we now pass modifiers around when export to and
importing from the rest of Chrome and we need to give the right answer
when ozone queries the modifier of a bo allocated with use flags.

Bug: 809670, 809666
Change-Id: Iab5ea62d5e0da9ddd90013f559f802270de1e420
Reviewed-on: https://chromium-review.googlesource.com/907848
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: Add minimal buffer allocation support for msm
Rajesh Yadav [Mon, 22 Jan 2018 12:59:06 +0000 (18:29 +0530)]
minigbm: Add minimal buffer allocation support for msm

Add minimal buffer allocation support using dumb_bo
for early enablement till the minigbm backend
implementation is avaialble for msm drv using
gem ioctls.

See CL:898422 for getting the DRV_MSM define in.

BUG=chromium:795946, b:72483556
TEST=Boot and see some graphics

Change-Id: Ieeb05923d756a3e4581a38cf6ce5cf406e2d197b
Reviewed-on: https://chromium-review.googlesource.com/897729
Commit-Ready: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: i915: Use NV12 as the main YUV format, including camera output
Tomasz Figa [Thu, 22 Jun 2017 07:52:43 +0000 (16:52 +0900)]
minigbm: i915: Use NV12 as the main YUV format, including camera output

On SKL and newer, the display controller supports NV12 natively for
overlays. Moreover it's the only output format supported by the camera
subsystem. Since it shouldn't matter for other uses cases if we use NV12
or YVU420, let's just switch everything to NV12 for simplicity.

BUG=b:32077885
TEST=Play a video in Android YouTube app on Cyan and Reef

Change-Id: I5cfcdec2b0e2020a3ae1e8364b60df3585838807
Reviewed-on: https://chromium-review.googlesource.com/544489
Commit-Ready: Owen Lin <owenlin@chromium.org>
Tested-by: Owen Lin <owenlin@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: remove gma500
Gurchetan Singh [Tue, 9 Jan 2018 22:22:04 +0000 (14:22 -0800)]
minigbm: remove gma500

We don't support this driver anymore.

BUG=none
TEST=none

Change-Id: Ib9f03a48e8825e3ac1f359e8fd75a68599790a14
Reviewed-on: https://chromium-review.googlesource.com/858169
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agoRevert "Revert "minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR""
Gurchetan Singh [Fri, 12 Jan 2018 23:31:50 +0000 (23:31 +0000)]
Revert "Revert "minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR""

This reverts commit 9ad07155dd9e5370e507d266766a8bcfbb4fa4d7.

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 9927d78669f67c2446888aa32a3e9f9c71f7228b.
>
> 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>
6 years agominigbm: fix amlogic
Gurchetan Singh [Fri, 12 Jan 2018 23:22:53 +0000 (15:22 -0800)]
minigbm: fix amlogic

Commit 080523 ("minigbm: add amlogic backend") forgot to declare the
backend external variable.

BUG=None
TEST=None

Change-Id: I69c89645023e1cf45d7b4d480bdb85f3b838e276
Reviewed-on: https://chromium-review.googlesource.com/865771
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: add amlogic backend
Gurchetan Singh [Thu, 11 Jan 2018 23:42:36 +0000 (15:42 -0800)]
minigbm: add amlogic backend

Add dumb amlogic backend based on udl.

BUG=none
TEST=emerge-falco minigbm

Change-Id: I435d0924d8206b4058b76bf403175f9b2cbb1291
Reviewed-on: https://chromium-review.googlesource.com/861865
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Sergey Volk <servolk@chromium.org>
6 years agoRevert "minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR"
Dominik Behr [Fri, 5 Jan 2018 22:15:15 +0000 (14:15 -0800)]
Revert "minigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR"

This reverts commit 9927d78669f67c2446888aa32a3e9f9c71f7228b.

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>
6 years agominigbm: replace DRM_FORMAT_MOD_INVALID with DRM_FORMAT_MOD_LINEAR
Gurchetan Singh [Tue, 12 Dec 2017 22:38:09 +0000 (14:38 -0800)]
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>
6 years agominigbm: amdgpu: use VRAM only for cursor and scanouts
Dominik Behr [Thu, 30 Nov 2017 20:23:06 +0000 (12:23 -0800)]
minigbm: amdgpu: use VRAM only for cursor and scanouts

Everything else should use GTT (USWC preferably). We should also switch
scanouts to GTT after we enable display VM.

BUG=b:69941535,b:69647975
TEST=run WebGL Aquarium on Kahlee

Change-Id: I939b159551305f74102ba47eb551e2bed2e32e06
Signed-off-by: Dominik Behr <dbehr@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/801797
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: virtio_gpu: use resource create ioctl for rendering
Zach Reizner [Wed, 4 Oct 2017 20:15:57 +0000 (13:15 -0700)]
minigbm: virtio_gpu: use resource create ioctl for rendering

In the virtio_gpu kernel driver, there is a flag for each BO indicating
if the buffer was made with the dumb buffer create ioctl. If that flag
is set, the kernel will request a transfer to host on page flip, even if
the dumb buffer is used in host side rendering. In the case of host side
rendering, the transfer will wipe out the rendering because the transfer
copies from guest side backing memory which was never used.

To prevent that issue, the virtgpu resource create ioctl is used to
prevent the dumb flag from being set. Simple mmap'ed framebuffers will
not display properly unless they use gbm's mmap/munmap which includes a
transfer to/from the host on mmap/munmap with this change.

TEST=null_platform_test;
     mmap_test -g renders correctly but we get ENOSYS
     (function not implemented) from DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST.
     (DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST succeeds though)

That'll have to be fixed ..
BUG=None

Change-Id: Id36080f597efd00a96e625ee4301ebf26d9f19af
Reviewed-on: https://chromium-review.googlesource.com/701354
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: rockchip/mediatek: invalidate shadow buffers
Gurchetan Singh [Wed, 29 Nov 2017 00:56:17 +0000 (16:56 -0800)]
minigbm: rockchip/mediatek: invalidate shadow buffers

In the case where process A is writing to the buffer, and process
B is reading from the buffer via a shadow buffer, we should update
the shadow buffer.

This issue seems to only pop on renderscript tests on Mediatek devices,
but that's due the various differences between 3D driver implementations.
Let's modify rockchip for correctness as well.

BUG=b:69700010
TEST=run cts -m CtsViewTestCases -t android.view.cts.SurfaceViewSyncTests
     passes on Oak

Change-Id: Id551027a2093f5423ee380d8935637d6256d2295
Reviewed-on: https://chromium-review.googlesource.com/795038
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agoAdd a missing include for asserts.
Tomasz Mikolajewski [Fri, 17 Nov 2017 11:30:56 +0000 (20:30 +0900)]
Add a missing include for asserts.

The missing include would cause image builders fail on
-arcnext builds.

BUG=chromium:764871
TEST=emerge arc-cros-gralloc and minigbm on -arcnext.

Change-Id: Ifde30bcde72a1fae4d13c95b17273880512cafe2
Reviewed-on: https://chromium-review.googlesource.com/776640
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: add GBM_BO_USE_SW_{READ,WRITE}_{OFTEN,RARELY} usage flags
Shirish S [Fri, 13 Oct 2017 04:24:03 +0000 (09:54 +0530)]
minigbm: add GBM_BO_USE_SW_{READ,WRITE}_{OFTEN,RARELY} usage flags

Need for these flags has arisen because buffer's allocated
BO_USE_SCANOUT flag is not mmapable in amd, whereas going further
for ensuring atomictity related operations are functional, one
needs buffer to be mmap'd.

These flags shall be used to strike balance in enabling
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED on amd and mmap X-tiled buffers
on Intel platforms.

BUG=b:65297611, chromium:777706
TEST=On Kahlee,
     UI comes up.
     GLMark2 & GLbench autotests show no performance regression
     atomictest -t multiplanes passes
     WebGL Aquarium

Change-Id: I582452d331f4a05106939447784a76eba06d13c2
Reviewed-on: https://chromium-review.googlesource.com/758618
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agoRevert "minigbm: Revert "minigbm: flush buffer instead of unmapping""
Gurchetan Singh [Tue, 10 Oct 2017 19:11:16 +0000 (12:11 -0700)]
Revert "minigbm: Revert "minigbm: flush buffer instead of unmapping""

The reason the tests weren't passing is because DRM_IOCTL_I915_GEM_SET_DOMAIN
is required on x86 platforms when calling (*lock). A previous CLs added this.

BUG=b:67073097, b:67331142
TEST=

android.view.cts.SurfaceViewSyncTests
android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual0720x0480
android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual1280x0720
android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual1920x1080
android.media.cts.EncodeDecodeTest#testVP8EncodeDecodeVideoFromSurfaceToSurface720p
android.media.cts.EncodeDecodeTest#testEncodeDecodeVideoFromPersistentSurfaceToSurface720p
android.media.cts.EncodeDecodeTest#testVP8EncodeDecodeVideoFromPersistentSurfaceToSurface720p

pass on Eve.

This reverts commit 14033e0013b5cc0ffc5af59dda7c377d46ec761d.

v2: Make lock_data[0] null after last (*unlock)(), because user may specify different
    access regions in the next (*lock)().

Change-Id: Ia56ecd57acc4471b026c852b178d8bc0f189dec7
Reviewed-on: https://chromium-review.googlesource.com/710324
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: use drv_array for combinations and kms_items
Gurchetan Singh [Sat, 4 Nov 2017 00:17:35 +0000 (17:17 -0700)]
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>
6 years agominigbm: make drv_add_combinations return nothing
Gurchetan Singh [Sat, 4 Nov 2017 00:18:36 +0000 (17:18 -0700)]
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>
6 years agominigbm: plumb buffer access region
Gurchetan Singh [Mon, 6 Nov 2017 19:07:52 +0000 (11:07 -0800)]
minigbm: plumb buffer access region

This will allow drivers to tile or detile only the regions requested
by the user. Note that the gralloc spec states that:

"This address will represent the top-left corner of the entire buffer,
even if accessRegion does not begin at the top-left corner."

(see hardware/interfaces/graphics/mapper/2.0/IMapper.hal in AOSP)

Also, the gralloc API makes it difficult to maintain two mappings of
the same buffer.  For example, say you have two access regions:

module->lock(mod, handle1, 0, 0, 5, 5, &addr);
module->lock(mod, handle1, 5, 5, 10, 10, &addr);

module->unlock(mod, handle1); // which access region should be unlocked?

In practice, this scenario never happens on Android.

It's not exactly clear what gbm should return.  Let's just return the
top left of the access region because that's what we where doing before.

BUG=chromium:764871
TEST=gbmtest, mmap_test -g, the following CTS tests:

android.view.cts.SurfaceViewSyncTests
android.media.cts.EncodeDecodeTest
android.video.cts.VideoEncoderDecoderTest

Change-Id: I7ca0713871e03928b1d4402aa161588990c7e775
Reviewed-on: https://chromium-review.googlesource.com/758147
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: use struct vma for (*bo_map)/(*bo_unmap) callbacks
Gurchetan Singh [Wed, 15 Nov 2017 02:20:27 +0000 (18:20 -0800)]
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>
6 years agominigbm: use drv_array for mappings
Gurchetan Singh [Fri, 3 Nov 2017 00:32:00 +0000 (17:32 -0700)]
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>
6 years agominigbm: amdgpu: add supported formats for camera
Ricky Liang [Fri, 10 Nov 2017 01:17:17 +0000 (09:17 +0800)]
minigbm: amdgpu: add supported formats for camera

Set the CAMERA_{READ|WRITE} flags for formats that are used by the
camera stack.

BUG=b:69109002
TEST=Verify that camera works on Kahlee.

Change-Id: I4c9aacdc71d3b18188783007f8c88da37ed28dca
Reviewed-on: https://chromium-review.googlesource.com/762687
Commit-Ready: Ricky Liang <jcliang@chromium.org>
Tested-by: Justin TerAvest <teravest@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: introduce drv_array
Gurchetan Singh [Thu, 2 Nov 2017 23:42:49 +0000 (16:42 -0700)]
minigbm: introduce drv_array

We want to allow multiple mappings of a single buffer with different
map flags. To do this, we'll need some sort of linked list or dynamic
array of mappings. We already use dynamic arrays in minigbm, so let's
centralize that functionality and use it.

BUG=chromium:764871
TEST=emerge-kevin {minigbm, arc-cros-gralloc}

Change-Id: I2b391d6e8e690eac6368b1404a806b2bfbbcdf44
Reviewed-on: https://chromium-review.googlesource.com/758145
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: refactor and rename mapping struct
Gurchetan Singh [Thu, 2 Nov 2017 21:07:18 +0000 (14:07 -0700)]
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>
6 years agominigbm: fix map time assertions
Gurchetan Singh [Wed, 8 Nov 2017 01:21:58 +0000 (17:21 -0800)]
minigbm: fix map time assertions

We should assert when the refcount is equal to zero as well.

BUG=chromium:764871
TEST=gbmtest passes

Change-Id: Iaf8b5bd4bf51472ad7c564341b42a7079b58bd6e
Reviewed-on: https://chromium-review.googlesource.com/758143
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: re-const-ify driver backends
Gurchetan Singh [Tue, 31 Oct 2017 17:36:25 +0000 (10:36 -0700)]
minigbm: re-const-ify driver backends

minigbm driver creation needs to be re-entrant (see CL:674528). Let's
re-constify to make this behavior explicit.

BUG=none
TEST=emerge-eve {minigbm, arc-cros-gralloc}

Change-Id: I037966199d4aa6de60432127e10fea1fb602694b
Reviewed-on: https://chromium-review.googlesource.com/758142
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: amdgpu: Add ABGR8888 to supported render target formats
Alec Thilenius [Tue, 31 Oct 2017 20:39:16 +0000 (14:39 -0600)]
minigbm: amdgpu: Add ABGR8888 to supported render target formats

Added DRM_FORMAT_ABGR8888 to the list of supported
render_target_formats.

BUG=b:67707215
TEST=teravest@chromium.org confirmed that this worked.

Change-Id: I0d1578f9a0ca98f28ebf60d396d1dbdae25435f1
Reviewed-on: https://chromium-review.googlesource.com/747723
Commit-Ready: Alec Thilenius <athilenius@chromium.org>
Tested-by: Alec Thilenius <athilenius@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: remove cirrus driver
Gurchetan Singh [Tue, 31 Oct 2017 17:39:43 +0000 (10:39 -0700)]
minigbm: remove cirrus driver

Nobody should use this anymore -- virtio_gpu is the future.

BUG=chromium:710629
TEST=Should already be unused, CQ will check

Change-Id: I8e4184875140e0c74d886c20fcf2d1c9664fa44c
Reviewed-on: https://chromium-review.googlesource.com/747983
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: amdgpu: Add RGB565 to supported render target formats
Alec Thilenius [Thu, 26 Oct 2017 16:23:46 +0000 (10:23 -0600)]
minigbm: amdgpu: Add RGB565 to supported render target formats

Added DRM_FORMAT_RGB565 to the list of supported render_target_formats.

BUG=b:67914863
TEST=On Kahlee, sample Android GL application renders a red triangle correctly
using the RGB565 render target format.

Change-Id: I79c6cafebfb111bb75182fc48ce0216f1bc789fd
Reviewed-on: https://chromium-review.googlesource.com/739758
Commit-Ready: Alec Thilenius <athilenius@chromium.org>
Tested-by: Alec Thilenius <athilenius@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm/i915: Implement bo_create_with_modifiers
Kristian H. Kristensen [Tue, 3 Oct 2017 20:53:19 +0000 (13:53 -0700)]
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>
6 years agominigbm: Use more descriptive modifier names
Kristian H. Kristensen [Wed, 25 Oct 2017 01:36:32 +0000 (18:36 -0700)]
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>
6 years agominigbm: amdgpu: make AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED default
Shirish S [Thu, 19 Oct 2017 06:20:34 +0000 (11:50 +0530)]
minigbm: amdgpu: make AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED default

AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED is required for mmapping
buffers in the amdgpu kernel driver.

This patch makes it default for all buffers on create.

However it should be noted that in case we find any performance related
regression in an un-tested scenario this patch needs to be reverted.

BUG=b:65297611
TEST=On Kahlee,
     UI comes up.
     GLMark2 & GLbench.bvt autotests pass
     atomictest -t multiplanes passes
     WebGL Aquarium

Change-Id: Ic82b25de63e66aac7aa04b4b255eb432c10c911b
Signed-off-by: Shirish S <shirish.s@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/727824
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: Link amdgpuaddr for DRV_AMDGPU.
Justin TerAvest [Wed, 18 Oct 2017 17:27:33 +0000 (11:27 -0600)]
minigbm: Link amdgpuaddr for DRV_AMDGPU.

The amdgpu driver requires functions provided by amdgpuaddr:
  * AddrComputeSurfaceInfo
  * AddrConvertTileInfoToHW
  * AddrCreate
  * AddrDestroy

We need to link against amdgpuaddr when using this driver.

BUG=b:64515630
TEST=Built modified arc-cros-gralloc, got ARC++ graphics on AMD

Change-Id: I5bfa32f0c912ac5d3a19ab4f337614a1d91a6328
Reviewed-on: https://chromium-review.googlesource.com/726364
Commit-Ready: Justin TerAvest <teravest@chromium.org>
Tested-by: Justin TerAvest <teravest@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: add XR30 and XB30 formats.
Daniele Castagna [Wed, 18 Oct 2017 20:15:44 +0000 (16:15 -0400)]
minigbm: i915: add XR30 and XB30 formats.

i915 supports 30bit per component formats.
This CL adds XR30 and XB30 to minigbm i915 backend.

This CL also sorts render_target_formats alphabetically.

BUG=chromium:776093
TEST=Ran a modifier version of null_platform_test that will be
uploaded soon.

Change-Id: If4f2f74cb10a0534023b9b6142ee84ced0ed8a38
Reviewed-on: https://chromium-review.googlesource.com/726318
Commit-Ready: Daniele Castagna <dcastagna@chromium.org>
Tested-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: Allow protected allocations
Tomasz Figa [Fri, 4 Aug 2017 03:50:03 +0000 (12:50 +0900)]
minigbm: i915: Allow protected allocations

Allow allocations with BO_USE_PROTECTED.
Moreover, disallow mapping of such BOs, as for GBM/Gralloc API callers
it should not be mappable and considered as metadata alone, without
usable content.

BUG=b:64323695
TEST=emerge-eve arc-cros-gralloc

Change-Id: I1dd1846a2042f97eee2fcc7581a91a60854e62cc
Reviewed-on: https://chromium-review.googlesource.com/607808
Commit-Ready: Pawel Osciak <posciak@chromium.org>
Tested-by: Pawel Osciak <posciak@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: call DRM_IOCTL_I915_GEM_SET_DOMAIN when invalidating
Gurchetan Singh [Tue, 10 Oct 2017 21:12:46 +0000 (14:12 -0700)]
minigbm: i915: call DRM_IOCTL_I915_GEM_SET_DOMAIN when invalidating

In the kernel, the i915_gem_set_domain_ioctl function calls these
functions:

- i915_gem_object_set_to_gtt_domain
- i915_gem_object_set_to_cpu_domain

These functions do various interesting things with caches, and some
CTS tests require this to pass.

BUG=b:67073097, b:67331142, chromium:764871
TEST=The following tests:

android.view.cts.SurfaceViewSyncTests
android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual0720x0480
android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual1280x0720
android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual1920x1080
android.media.cts.EncodeDecodeTest#testVP8EncodeDecodeVideoFromSurfaceToSurface720p
android.media.cts.EncodeDecodeTest#testEncodeDecodeVideoFromPersistentSurfaceToSurface720p
android.media.cts.EncodeDecodeTest#testVP8EncodeDecodeVideoFromPersistentSurfaceToSurface720p

passes on Eve with the next patch applied.

Change-Id: I9acc14580f65eab6039d8b354bfbf51c31dfcf14
Reviewed-on: https://chromium-review.googlesource.com/710323
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: add buffer invalidation function
Gurchetan Singh [Tue, 10 Oct 2017 00:59:47 +0000 (17:59 -0700)]
minigbm: add buffer invalidation function

We may need to invalidate a buffer before reading it. Some use
cases are:

- DRM_IOCTL_I915_GEM_SET_DOMAIN
        - DMA_BUF_IOCTL_SYNC with the SYNC_START option
        - DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST

This patch adds the function hook.

BUG=chromium:764871
TEST=compiles

Change-Id: I85811407252b859a12294381c65ff3545424636b
Reviewed-on: https://chromium-review.googlesource.com/710322
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: amdgpu: make bo's created with SCANOUT flag mmapable
Shirish S [Fri, 13 Oct 2017 04:24:03 +0000 (09:54 +0530)]
minigbm: amdgpu: make bo's created with SCANOUT flag mmapable

amdgpu kenrel driver can mmap a 'bo' only if it has
AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED  flag set.
This flag was not set in case if the 'bo' is used as a SCANOUT buffer,
for several reasons like it might impact performance etc.
But due to several requirements realted testing drm functionalitites
like atomicity, multi-planes etc., this restriction needs to be
removed.
Several known tests related to performance have been done after making
this change and none have shown glaring performance regressions.

However it should be noted that in case we find any performance related
regression in an un-tested scenario this patch needs to be reverted.

BUG=b:65297611
TEST=On Kahlee,
     UI comes up.
     GLMark2 & GLbench autotests show no performance regression
     atomictest -t multiplanes passes
     WebGL Aquarium

Change-Id: If629b64f3a14f843972b25d393a0a16058b3044e
Signed-off-by: Shirish S <shirish.s@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/715037
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: respect map_flags in all cases
Gurchetan Singh [Thu, 5 Oct 2017 21:52:24 +0000 (14:52 -0700)]
minigbm: respect map_flags in all cases

When the map flags do not feature BO_TRANSFER_WRITE, we should
not copy back any shadow buffers we maintain.

BUG=b:67434931
TEST=android.view.cts.SurfaceViewSyncTests on Mediatek/Rockchip

Change-Id: I7078bfc5a8d770a52949d43ea68efc4a870e9227
Reviewed-on: https://chromium-review.googlesource.com/703875
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>

6 years agominigbm: move gralloctest to this repo
Gurchetan Singh [Tue, 3 Oct 2017 17:39:13 +0000 (10:39 -0700)]
minigbm: move gralloctest to this repo

The autotest eclass has issues when compiling for multilib, and plus
we can keep the test with the source code.

BUG=b:63610343
TEST=emerge-eve arc-cros-gralloc
CQ-DEPEND=CL:699675, CL:699734

Change-Id: I9ec3185f7e18f4717ef560e599e635f03b0a999d
Reviewed-on: https://chromium-review.googlesource.com/699676
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: add validation during import
Gurchetan Singh [Fri, 29 Sep 2017 17:18:59 +0000 (10:18 -0700)]
minigbm: add validation during import

A common cause of bugs and security exploits are out-of-bounds
memory accesses. Let's add some validation when importing the
buffer to protect against this.

BUG=b:65566935
TEST=Boot Android and play games on Eve

Change-Id: I557f9b9849f267f5c87bb29648119b1c29695cd3
Reviewed-on: https://chromium-review.googlesource.com/692624
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agoRevert "minigbm: align multi-planar formats to 16"
Daniel Charles [Tue, 26 Sep 2017 16:40:42 +0000 (09:40 -0700)]
Revert "minigbm: align multi-planar formats to 16"

This reverts commit 6a8828492f4252a7c125a984823599bd65e3cb03.

Revert reason:  intel-vaapi-driver can relax height alignment

alignment is only enforced on tiled surfaced, after confirming
minigbm will provide linear surfaces, surfaces height needs
to be 4 bit aligned.

BUG=b/65272348
TEST="intel-vaapi-driver regular testing, VAVDA, VAVEA, VAJDA"
TEST="minigbm media tests within container"
TEST="tests mentioned in the bug"
CQ-DEPEND=CL:671650

Change-Id: Ifdccca9d7f85be0cbb504c0c0a2b4712aed99826
Signed-off-by: Daniel Charles <daniel.charles@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/685296
Tested-by: Ricky Liang <jcliang@chromium.org>
Reviewed-by: Ricky Liang <jcliang@chromium.org>
6 years agominigbm: Revert "minigbm: flush buffer instead of unmapping"
Gurchetan Singh [Wed, 4 Oct 2017 15:16:42 +0000 (08:16 -0700)]
minigbm: Revert "minigbm: flush buffer instead of unmapping"

It looks like munmap is probably necessary for i915 and serves
some important function. Let's revert until we can figure
out what's going on.

BUG=b:67073097
TEST=android.view.cts.SurfaceViewSyncTests#testVideoSurfaceViewCornerCoverage

This reverts commit 254dbb19c49fad4ab4f28b2d1f2982bd10bb7c0b.

Change-Id: Idac50930f9f13b4867110a31fadb1a2547d05d07
Reviewed-on: https://chromium-review.googlesource.com/699802
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: pass in map flags to (*bo_map) callback
Gurchetan Singh [Fri, 29 Sep 2017 00:14:50 +0000 (17:14 -0700)]
minigbm: pass in map flags to (*bo_map) callback

Some eagle-eyed observers have commented that we lose some
potentially useful information for the (*bo_map) callback when
we convert our map flags to page protection flags. Let's not
lose this information, so pass in the map flags. We can convert
to page protection flags using a helper function.

BUG=chromium:764871
TEST=Boot Android and play games on Eve

Change-Id: Ie2cf395109eb5a8de663dfb97a343d20ff0df30c
Reviewed-on: https://chromium-review.googlesource.com/691425
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: standardize naming of map flags
Gurchetan Singh [Fri, 29 Sep 2017 00:02:12 +0000 (17:02 -0700)]
minigbm: standardize naming of map flags

It's helpful to differentiate map flags from normal buffer creation
flags. Note gralloc doesn't differentiate between map flags and buffer
creation flags. However, since flags are passed in with gralloc
(*lock)(), we can use a separate conversion function there.

BUG=chromium:764871
TEST=Boot Android and play games on Eve

Change-Id: Ic8aee84d9ac945abf93d9a9bda78fe3f77711cc3
Reviewed-on: https://chromium-review.googlesource.com/691424
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: amdgpu: Add formats R8, GR88
Deepak Sharma [Mon, 2 Oct 2017 20:37:29 +0000 (13:37 -0700)]
minigbm: amdgpu: Add formats R8, GR88

Add R8 and GR88 format for dma_bufs in amdgpu.
Required to support native GMB video playback.
If native GMB is enbaled,chrome transcodes NV12 to
RGB by importing Y plane as R8 EGLImage and the UV plane as GR88 EGLImage.

BUG=b:65302612
TEST=Boot Kahlee with --enable-native-gpu-memory-buffers and play youtube.

Change-Id: Ifa7e50959bb5417088357a0c0aa3ac874ecf6fc9
Signed-off-by: Deepak Sharma <deepak.sharma@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/695850
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: standardize naming of buffer creation flags
Gurchetan Singh [Thu, 28 Sep 2017 23:40:52 +0000 (16:40 -0700)]
minigbm: standardize naming of buffer creation flags

We use the terms "flags" and "usage" interchangeably in this repo,
since they essentally mean the same thing.  However, let's be a
little more consistent since it's kind of confusing, especially
when buffer map flags come to play. Let's:

- refer to everything in the drv_* layer as use_flags
- refer to everything in the gbm/gralloc layers as
  usages

BUG=chromium:764871
TEST=emerge-eve {arc-cros-gralloc, minigbm}

Change-Id: If987d72369b895f38cde87e50ce1080f78f2a084
Reviewed-on: https://chromium-review.googlesource.com/691423
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: pass in buffer creation flags of the right size
Gurchetan Singh [Thu, 28 Sep 2017 23:25:12 +0000 (16:25 -0700)]
minigbm: pass in buffer creation flags of the right size

The buffer creation flags are uint64_t, not uint32_t.

BUG=none
TEST=emerge-eve {minigbm, arc-cros-gralloc}

Change-Id: Id94911c5e19c00d47f2fbdca570a6a08fc92b82e
Reviewed-on: https://chromium-review.googlesource.com/691422
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: remove buffer sizes when importing
Gurchetan Singh [Thu, 28 Sep 2017 22:21:53 +0000 (15:21 -0700)]
minigbm: remove buffer sizes when importing

CL:662919 started using lseek() and the buffer offsets when importing,
so let's remove buffer sizes here.

BUG=b:65566935
TEST=emerge-eve {minigbm, arc-cros-gralloc}

Change-Id: I43fda28bfe530139e8e0d68c6b9c213489077b4c
Reviewed-on: https://chromium-review.googlesource.com/691421
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: clang-format and various nits
Gurchetan Singh [Thu, 28 Sep 2017 22:12:01 +0000 (15:12 -0700)]
minigbm: clang-format and various nits

BUG=NONE
TEST=emerge-eve {minigbm, arc-cros-gralloc}

Change-Id: I3418680828e7b69c6b5e1c56dcdba171aba92473
Reviewed-on: https://chromium-review.googlesource.com/691420
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: use I915_MMAP_WC in certain cases
Gurchetan Singh [Tue, 19 Sep 2017 22:10:58 +0000 (15:10 -0700)]
minigbm: i915: use I915_MMAP_WC in certain cases

The Zero Latency Ink app is scanned out while the buffer is being
updated (by design). The buffer update is racy with the display,
leading to artifacts. Calling clflush on the buffer, even only on
the rectangle specified by gralloc (*lock), makes no difference. As
a result, let's map the buffer as uncached when it's being scanned
out (we do the same thing on ARM). Let's make sure not affect
renderscript buffers, since certain renderscript CTS tests require
caching.

BUG=chromium:762324
TEST=no overlay artifacts while using Zero Latency Ink app
     on Eve.

Change-Id: I6f79dc8e48deee441790f737aba79c7f79ca4cb9
Reviewed-on: https://chromium-review.googlesource.com/665390
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: David Reveman <reveman@chromium.org>
6 years agominigbm: flush buffer instead of unmapping
Gurchetan Singh [Thu, 14 Sep 2017 22:16:15 +0000 (15:16 -0700)]
minigbm: flush buffer instead of unmapping

As an optimization, let's call:
- drv_bo_flush when calling (*unlock).
- drv_bo_flush during gbm_bo_unmap()

CL:441916 makes sure that the buffer is unmapped before the
buffer destroy ioctl is called, so we will not be leaking
mappings in any case.

BUG=chromium:764871
TEST=Android boots, 8 CTS tests, and Youtube app works on Eve
     gbmtest, mmap_test -g

Change-Id: I429739a8c6435a434dac41ad125761364a3775d0
Reviewed-on: https://chromium-review.googlesource.com/668220
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: add (*bo_flush) implementations
Gurchetan Singh [Thu, 14 Sep 2017 21:18:43 +0000 (14:18 -0700)]
minigbm: add (*bo_flush) implementations

Let's take the flush and writeback steps in the driver unmap
functions and move them to the (*bo_flush) callback.

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

Change-Id: Iecccafc25642b120bc84f2d1b8538303c8ce36eb
Reviewed-on: https://chromium-review.googlesource.com/668219
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: add drv_bo_flush
Gurchetan Singh [Thu, 14 Sep 2017 00:54:36 +0000 (17:54 -0700)]
minigbm: add drv_bo_flush

As an optimization, we would like to separate buffer flush/writeback
and unmap. This patch adds the appropriate entry point in our
internal driver API. Overall, the proposed flow is:

- drv_bo_map(..) creates a mapping and associated metadata
- drv_bo_flush(..) writes memory from any cache or temporary
          buffer back to memory
        - drv_bo_unmap(..) flushes, and frees the mapping and
  associated metadata.

The drv_bo_flush function just does some sanity checks on
the map data at this point, but otherwise is a no-op.

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

Change-Id: If306f066a76bc5e0943c1170e2d6933fa5630eff
Reviewed-on: https://chromium-review.googlesource.com/668218
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: unmap right before buffer destruction
Gurchetan Singh [Tue, 24 Jan 2017 21:30:06 +0000 (13:30 -0800)]
minigbm: unmap right before buffer destruction

Regardless of the allocator, we want to make sure any mappings
we create are eventually freed. This patch adds logic to
drv_bo_destroy to free any mappings before the GEM close
ioctl is called.

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

Change-Id: I8f4edb4bc01ff6e1d71a60e0309e77e9fc3840f4
Reviewed-on: https://chromium-review.googlesource.com/441916
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>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: add a default (*bo_unmap) implementation
Gurchetan Singh [Mon, 18 Sep 2017 22:29:47 +0000 (15:29 -0700)]
minigbm: add a default (*bo_unmap) implementation

The (*bo_unmap) function is responsible for unmapping the buffer
and cleaning up any data allocated during (*bo_map). Previously,
we called munmap in drv_bo_unmap(), which caused some confusion.
This method is cleaner.

BUG=chromium:764871
TEST=emerge-betty minigbm

Change-Id: I4dc20cd6b15e79bce21d33f03ebc84480c582981
Reviewed-on: https://chromium-review.googlesource.com/671693
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Joe Kniss <djmk@google.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: rockchip: Add support for buffers required by new camera subsystem
Jeffy Chen [Tue, 19 Sep 2017 09:15:30 +0000 (17:15 +0800)]
minigbm: rockchip: Add support for buffers required by new camera subsystem

It's much the same as what we did for i915 in:
d30c0a5 (minigbm: i915: Add support for buffers required by new camera subsystem)
https://chromium-review.googlesource.com/559315

BUG=b:65390035
TEST=test arc_camera3_test on scarlet, no more this error:
[0905/104926:ERROR:camera3_test_gralloc.cc (76)] Can't detect flexible YUV 420 format

Change-Id: Ib99687ff2aaaca0233fa950abbe8581bc3572b74
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/670888
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: Store usage in driver data flags
Satyajit Sahu [Thu, 21 Sep 2017 09:44:46 +0000 (15:14 +0530)]
minigbm: Store usage in driver data flags

Storing usage flag  in drv_data.flags in gbm_bo_import method.

BUG=b:38152101
TEST=Tested by running graphics_Sanity autotest and mmap_test.

Change-Id: I8d1bd8473f8aa6c63da014f86ddcec42e250998a
Signed-off-by: Satyajit Sahu <satyajit.sahu@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/676554
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoAvoid freeing then accessing driver backend format and usage combinations
Ege Mihmanli [Wed, 20 Sep 2017 03:13:26 +0000 (20:13 -0700)]
Avoid freeing then accessing driver backend format and usage combinations

Due to USB flakiness issues, sometimes udl devices suddenly disconnect
then reconnect. In such cases, we see that drv_create runs before drv_destroy
can destroy the driver belonging to the disconnected udl device. Once
drv_destroy runs, it frees structs frequently used by the newly created
driver, most importantly drv->backend->combos->data which stores
format and usage combinations for creating BOs.

By nature, drv_destroy should not destroy data belonging to backend. Further,
BO format and usage combinations are hardcoded in driver _init, so there is
no point in it being freed in drv_destroy.

This fix moves the combos array to struct drv so a new combos array can be
created and destroyed in drv_create and drv_destroy. This eliminates the
race condition by avoiding using the shared resource.

BUG=crbug.com/766831
TEST=Boot up CfM, make sure ui and chrome logs are not complaining
about scanout and framebuffer failures. Play around with Mimo touchscreen
to make sure the display is not flickering.

Change-Id: I53d57693574daeb5486cd5daca71f660ada635ef
Reviewed-on: https://chromium-review.googlesource.com/674528
Commit-Ready: Ege Mihmanli <egemih@google.com>
Tested-by: Ege Mihmanli <egemih@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: calculate plane size by offset of next plane or lseek
Daniel Hung-yu Wu [Tue, 12 Sep 2017 12:05:08 +0000 (20:05 +0800)]
minigbm: calculate plane size by offset of next plane or lseek

While importing a foreign object, calculate each plane size according
to the offset of next plane or lseek result. Otherwise, an object that
has been created with aligned height will be mapped to a smaller
region and accessing the last bytes of last plane causes segmentation
faults.

BUG=b:65566935
TEST=checked that b:65566935 was not reproducible with this patch and
the size of mapped region is the same as allocated size
CQ-DEPEND=CL:669752

Change-Id: I294f6a816a3172df630c223fe8f338a9036e71bd
Reviewed-on: https://chromium-review.googlesource.com/662919
Commit-Ready: Hung-yu Wu <hywu@chromium.org>
Tested-by: Hung-yu Wu <hywu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: move tegra_bo_import to be above tegra_bo_map, and run clang-format
Gurchetan Singh [Thu, 14 Sep 2017 20:04:11 +0000 (13:04 -0700)]
minigbm: move tegra_bo_import to be above tegra_bo_map, and run clang-format

IMO this looks nicer.

BUG=chromium:764871
TEST=gbmtest on Tegra

Change-Id: I7839b5a348f95f38385a555a8fe3ab0982d3533f
Reviewed-on: https://chromium-review.googlesource.com/668217
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: cros_gralloc: fix mis-named variable
Gurchetan Singh [Thu, 14 Sep 2017 21:49:03 +0000 (14:49 -0700)]
minigbm: cros_gralloc: fix mis-named variable

BUG=none
TEST=none

Change-Id: I1f7419fa5d44dcf3eaee178f0a619cfd42689351
Reviewed-on: https://chromium-review.googlesource.com/668216
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: align multi-planar formats to 16
Alexandre Courbot [Wed, 30 Aug 2017 05:37:36 +0000 (14:37 +0900)]
minigbm: align multi-planar formats to 16

libva 1.8.3 makes it a hard requirement that multi-planar surfaces are
vertically aligned to 16. Enforce this rule at allocation time.

BUG=b:65084476
TEST=checked that b:65084476 was not reproducible with this patch and
that all multi-planar surfaces are aligned to 16.

Change-Id: Id31055df81ba43130f3f45282db104753fb6e700
Reviewed-on: https://chromium-review.googlesource.com/642429
Commit-Ready: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: Make sure no mappings remain when closing a GEM handle
Tomasz Figa [Tue, 8 Aug 2017 08:59:41 +0000 (17:59 +0900)]
minigbm: Make sure no mappings remain when closing a GEM handle

If we release the last reference and close the GEM handle, but we still
have an entry in the mapping map with such handle as the key, we can
experience a case when a new GEM is obtains the handle we just released
and next map attempt for the new GEM leads to the map entry for the old
buffer being used and wrong mappings being returned.

We ignore the nonsense gralloc API requirement to avoid crashing the
process in such case and simply assert() no mappings remaining when
last reference to the GEM is being dropped.

BUG=b:38250067
TEST=run cts -m CtsMediaTestCases on veyron_minnie without CL:*426529

Change-Id: Id36f55292bbded626af8cba56f4d8bf0603742fb
Reviewed-on: https://chromium-review.googlesource.com/605339
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: gralloc0: Fix coding style error
Tomasz Figa [Wed, 2 Aug 2017 10:35:40 +0000 (19:35 +0900)]
minigbm: gralloc0: Fix coding style error

There is a missing whitespace error in gralloc0.cc, which is
automatically corrected by some git hook, so let's fix it finally. Since
the original style issue seems to be caused by a bug in clang-format
used in ChromeOS chroot (and corrected by any other, not broken,
clang-format), just annotate the line to have clang-format bypassed.

BUG=none
TEST=compile

Change-Id: I6df1963eedc3b908d4a0abaffb2db9081eaba043
Reviewed-on: https://chromium-review.googlesource.com/597330
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: rockchip/mediatek: keep a local cached mapping of the buffer
Gurchetan Singh [Fri, 4 Aug 2017 01:17:34 +0000 (18:17 -0700)]
minigbm: rockchip/mediatek: keep a local cached mapping of the buffer

All GEM mappings are write-combined by default. This leads to
performance issues with renderscript CTS tests on ARM boards.
Let's keep a local copy of the buffer in the hopes of improving
the test's performance.

BUG=b:38097499
TEST=run cts -m CtsViewTestCases -t android.view.cts.SurfaceViewSyncTests
     passes on 9776.0.0 veyron_minnie

Change-Id: I74da770f42524e66ca643adfbe9475362ee397cc
Reviewed-on: https://chromium-review.googlesource.com/602736
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: add the BO_USE_RENDERSCRIPT flag back in
Gurchetan Singh [Fri, 4 Aug 2017 01:34:05 +0000 (18:34 -0700)]
minigbm: add the BO_USE_RENDERSCRIPT flag back in

Previously, we mapped BO_USE_RENDERSCRIPT to BO_USE_LINEAR,
which made sense at the moment. However, we know have a case
where we need to special things with renderscript buffers on
ARM boards. Let's add back in the flag so we can differentiate
between normal linear buffers and renderscript buffers at map
and unmap time.

BUG=b:38097499
TEST=run cts -m CtsViewTestCases -t android.view.cts.SurfaceViewSyncTests
     passes on 9776.0.0 veyron_minnie

Change-Id: I7f1ee76735280ab6495a2d4af332cce5bc1c1727
Reviewed-on: https://chromium-review.googlesource.com/602735
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agominigbm: store BO_USE_* flags in buffer object
Gurchetan Singh [Fri, 4 Aug 2017 01:23:27 +0000 (18:23 -0700)]
minigbm: store BO_USE_* flags in buffer object

Currently, minigbm only cares about the buffer use flags during buffer
creation.  We would like to use cached renderscript buffers, so we need
knowledge about how the buffer was created at map time. Let's add this
to the buffer object struct.

BUG=b:38097499
TEST=run cts -m CtsViewTestCases -t android.view.cts.SurfaceViewSyncTests
     passes on 9776.0.0 veyron_minnie

Change-Id: I73943dae309e60038affb78385aef4b6d3b678ed
Reviewed-on: https://chromium-review.googlesource.com/602734
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
6 years agoAdded radeon backend for minigbm
giri [Wed, 2 Aug 2017 16:01:33 +0000 (12:01 -0400)]
Added radeon backend for minigbm

This is useful for amd/radeon cards
based on gpu architecture preceding GCN 1.2

BUG=none
TEST=none

Change-Id: I54f1c84157ce691da1b595cb859dfca357d0b171
Reviewed-on: https://chromium-review.googlesource.com/593634
Commit-Ready: Stéphane Marchesin <marcheu@chromium.org>
Tested-by: Giri Kumar <giri@flintos.io>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>