OSDN Git Service

android-x86/external-minigbm.git
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>
6 years agominigbm: cros_gralloc: fix initialization race condition
Gurchetan Singh [Tue, 1 Aug 2017 22:02:24 +0000 (15:02 -0700)]
minigbm: cros_gralloc: fix initialization race condition

On Android M, since we don't hold a lock during cros_gralloc_driver::init(),
another thread would sometimes access data before the driver was initialized.
This would lead to dEQP crashes. We don't experience this issue on Android
N since the framework has it's own layer of locks in the Gralloc1On0Adapter.

This patch makes the module initialization during (*registerBuffer) and
gralloc_open re-entrant.

BUG=b:63511976
TEST=run cts --package com.drawelements.deqp.gles2 on veyron_tiger has no
     crashes

Change-Id: I2b72f2f8ed5e4a5afbacb291ed8cd928beb2a3b3
Reviewed-on: https://chromium-review.googlesource.com/597015
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: i915: Add necessary padding to Android YV12 buffers
Tomasz Figa [Sat, 29 Jul 2017 06:47:54 +0000 (15:47 +0900)]
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>
6 years agominigbm: i915: Align chroma planes of planar formats properly
Tomasz Figa [Sat, 29 Jul 2017 06:37:58 +0000 (15:37 +0900)]
minigbm: i915: Align chroma planes of planar formats properly

Mesa handles planar formats with separate surface for each plane. Each
linear surface has certain width and height alignment restrictions.
However minigbm's i915 backend currently does not account for chroma plane
subsampling when calculating the alignments, so that only the luma plane
gets enough alignment. Fix this by multiplying luma plane alignment by
chroma subsampling factor, both horizonal and vertical for 3-plane
formats and only the latter for 2-plane formats.

Fixes following CTS tests on Intel platforms:
android.media.cts.VideoEncoderTest#testGoogVP8FlexArbitraryH
android.media.cts.VideoEncoderTest#testGoogVP8FlexArbitraryW
android.media.cts.VideoEncoderTest#testGoogVP8FlexNearMaxMin
android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryH
android.media.cts.VideoEncoderTest#testGoogVP8SurfArbitraryW
android.media.cts.VideoEncoderTest#testGoogVP8SurfNearMaxMin

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

Change-Id: I8459b0f5f22ba9f9936fa987a13dd99d6b245560
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/592989
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: cros_gralloc/buffer: Do not read from output array
Tomasz Figa [Fri, 28 Jul 2017 08:23:56 +0000 (17:23 +0900)]
minigbm: cros_gralloc/buffer: Do not read from output array

Even though it does not currently imply any technical issues, it is not
very elegant for the code to assign buffer map base to addr[0] first and
then modify it in a loop by adding a plan address. Let's just store the
map base in a local variable and use it in plane address calculation.

BUG=b:38250067
TEST=android.media.cts.DecoderTest on veyron_minnie

Change-Id: If2e95086385d96ced760cc94c8c747bffd0c6f55
Reviewed-on: https://chromium-review.googlesource.com/592988
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: cros_gralloc/buffer: Initialize plane address array
Tomasz Figa [Fri, 28 Jul 2017 08:19:44 +0000 (17:19 +0900)]
minigbm: cros_gralloc/buffer: Initialize plane address array

Before we return to userspace, we should clear the output array of
pointer values, so that it doesn't contain some spurious data.
Furthermore, if zero flags are given, the lock method itself
dereferences addr[0] before assigning any value there.

BUG=b:38250067
TEST=android.media.cts.DecoderTest on veyron_minnie

Change-Id: I58284477b3813265188f1714f00b1fb7003ed2a3
Reviewed-on: https://chromium-review.googlesource.com/592987
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: cros_gralloc: support GRALLOC_MODULE_API_VERSION_0_3
Gurchetan Singh [Fri, 23 Jun 2017 01:38:37 +0000 (18:38 -0700)]
minigbm: cros_gralloc: support GRALLOC_MODULE_API_VERSION_0_3

Let's support GRALLOC_MODULE_API_VERSION_0_3. This will more closely
mirror what gralloc1 and HIDL gralloc does.

We have the option to asychronously unlock with this version of the API,
but decided the added complexity wouldn't lead to any performance benefits.

We'll just set the release fence pointer to be -1, indicating the
the buffer is ready to use after the (*unlock_Async) call.

BUG=b:62069164
TEST=Android boots, play Youtube app, ./gralloctest all passes

Change-Id: Ia21a11b541796c4b36003c50cd8627d189b4bc56
Reviewed-on: https://chromium-review.googlesource.com/422661
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: cros_gralloc: Use standard error codes
Tomasz Figa [Fri, 21 Jul 2017 08:54:05 +0000 (17:54 +0900)]
minigbm: cros_gralloc: Use standard error codes

Since we decided not to support gralloc1 and gralloc0 requires standard
errno-based error codes to be returned to callers, remove the custom
error code enumeration and use standard codes everywhere in
cros_gralloc.

BUG=b:63915090
TEST=Play store starts on Eve

Change-Id: I4f466e8cac6323554f29a7da5c2c00ab47b0abf2
Reviewed-on: https://chromium-review.googlesource.com/580735
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoRevert "minigbm: rockchip: align NV12 planes to 64 bytes"
Pin-chih Lin [Tue, 25 Jul 2017 08:06:26 +0000 (08:06 +0000)]
Revert "minigbm: rockchip: align NV12 planes to 64 bytes"

This reverts commit 33cca93af658650b655b4b5dcfb18a3235a100cf.

Reason for revert:

Many CTS tests are failed by the change, and video playback is corrupted on Youtube/Netflix app.

Original change's description:
> minigbm: rockchip: align NV12 planes to 64 bytes
>
> When running the mapped_texture_test with the Mali EGL implementation
> compiled with debug symbols, Mali complains that the NV12 planes are
> not sufficiently aligned (specifically, mali_cobj_surface.c line 1806).
> Fix this.
>
> BUG=b:63910596
> TEST=run Youtube App video on Kevin, at fullscreen and at normal size
>
> Change-Id: Ia204360c3aebe2bbd545ac7be0f6d095b0412f9d
> Reviewed-on: https://chromium-review.googlesource.com/556540
> Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Reviewed-by: Stphane Marchesin <marcheu@chromium.org>

Bug: b:63999659
Test: 1) run CTS on minnie: CtsVideoTestCases android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual0720x0480, which fails on ToT and passes with the revert.
2) Play a video (size:426x240) on Youtube app. Video is corrupted on ToT and good with the revert.

Change-Id: I3418d0065733b4e0f99d1ab8c3cd416f7f454bc0
Reviewed-on: https://chromium-review.googlesource.com/583696
Commit-Ready: Pin-chih Lin <johnylin@chromium.org>
Tested-by: Pin-chih Lin <johnylin@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
6 years agominigbm: i965: Add 64-byte padding at the end of linear buffers
Tomasz Figa [Sun, 23 Jul 2017 06:02:19 +0000 (15:02 +0900)]
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>
6 years agominigbm: rockchip: align NV12 planes to 64 bytes
Gurchetan Singh [Wed, 28 Jun 2017 21:01:00 +0000 (14:01 -0700)]
minigbm: rockchip: align NV12 planes to 64 bytes

When running the mapped_texture_test with the Mali EGL implementation
compiled with debug symbols, Mali complains that the NV12 planes are
not sufficiently aligned (specifically, mali_cobj_surface.c line 1806).
Fix this.

BUG=b:63910596
TEST=run Youtube App video on Kevin, at fullscreen and at normal size

Change-Id: Ia204360c3aebe2bbd545ac7be0f6d095b0412f9d
Reviewed-on: https://chromium-review.googlesource.com/556540
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 GBM_BO_USE_CAMERA_{READ,WRITE} usage flags
Tomasz Figa [Thu, 6 Jul 2017 06:40:05 +0000 (15:40 +0900)]
minigbm: Add GBM_BO_USE_CAMERA_{READ,WRITE} usage flags

Add a new GBM usage flag for buffers used a output for camera subsystem.
It corresponds to Android GRALLOC_USAGE_HW_CAMERA_{READ,WRITE} flags and
translates to the same BO_USE_HW_CAMERA_{READ,WRITE} flags of drv.

BUG=b:62358788
TEST=compile

Change-Id: Ib7063437e39d1e08f643763c6ce383ce8657f5ce
Reviewed-on: https://chromium-review.googlesource.com/560935
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Ricky Liang <jcliang@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: Remove _HW_ from BO_USE_HW_CAMERA_* usage flags
Tomasz Figa [Tue, 11 Jul 2017 09:28:02 +0000 (18:28 +0900)]
minigbm: Remove _HW_ from BO_USE_HW_CAMERA_* usage flags

Camera is supposed to mean camera hardware and the superfluous _HW_ does
not give us anything other than making the names longer.

BUG=b:62358788
TEST=compile

Change-Id: I3608470f17efe700fa43901167fa614ff9eac09c
Reviewed-on: https://chromium-review.googlesource.com/566774
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: gralloc0: Fix invalid cast from integer to pointer
Tomasz Figa [Tue, 11 Jul 2017 09:07:11 +0000 (18:07 +0900)]
minigbm: gralloc0: Fix invalid cast from integer to pointer

We should be casting a pointer to the fourcc to a char * pointer,
instead of casting the fourcc value itself (which unluckily happens to
be of the same size as pointer, so compilator fails to detect it).

BUG=b:62358788
TEST=Try to allocate with invalid usage

Change-Id: I2bb94d145dc3765d5193712aad7682c0fb383dd8
Reviewed-on: https://chromium-review.googlesource.com/566791
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: gralloc0: Remove BO_USE_HW_CAMERA_ZSL
Tomasz Figa [Thu, 6 Jul 2017 09:06:23 +0000 (18:06 +0900)]
minigbm: gralloc0: Remove BO_USE_HW_CAMERA_ZSL

In gralloc0, the flag GRALLOC_USAGE_HW_CAMERA_ZSL is defined to be a
bitwise OR of GRALLOC_USAGE_HW_CAMERA_WRITE and
GRALLOC_USAGE_HW_CAMERA_READ. So it is incorrect to treat it as a
separate usage flag, not even thinking about using it with the bitwise
AND operator for conditional tests.

Fix the current broken state by removing BO_USE_HW_CAMERA_ZSL, which
does not have any reason to exist.

BUG=b:62358788
TEST=Camera preview renders correctly on Poppy.

Change-Id: I883713f7e1c82c7747b20ac2000fb2edd5207616
Reviewed-on: https://chromium-review.googlesource.com/561034
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Ricky Liang <jcliang@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoPlumb buffer map permissions through gbm.
Joe Kniss [Thu, 29 Jun 2017 22:02:46 +0000 (15:02 -0700)]
Plumb buffer map permissions through gbm.

Map read/write permissions were being ignored by minigbm.  This can
cause segfaults or failed mappings if the device FD permissions are not
rw.

Also adds bounds checking in tegra.c for tile/untile transfers.

BUG=chromium:737328
TEST=cyan, nyan graphicsSanity with read only on device

Change-Id: I8fccaed4e908cda3ff7d7cf451d0ad75d65039e6
Reviewed-on: https://chromium-review.googlesource.com/556980
Commit-Ready: Joe Kniss <djmk@google.com>
Tested-by: Joe Kniss <djmk@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: gralloc0: Allow lock_ycbcr for HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
Tomasz Figa [Wed, 5 Jul 2017 08:50:18 +0000 (17:50 +0900)]
minigbm: gralloc0: Allow lock_ycbcr for HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED

We can use lock_ycbcr as a way to partially work around the format resolve
problem - with the assumption that if lock_ycbcr succeeds, the
android_ycbcr struct returned describes a YCbCr 4:2:0 image, we can
query gralloc for the format instead of hardcoding one statically.

BUG=b:32077885
TEST=Camera preview renders correctly on Poppy.

Change-Id: Ic20f5aa89809bf89941f3b4851c0d28965da54ac
Reviewed-on: https://chromium-review.googlesource.com/544487
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: gralloc0: Fix error handling in lock_ycbcr
Tomasz Figa [Wed, 5 Jul 2017 08:50:18 +0000 (17:50 +0900)]
minigbm: gralloc0: Fix error handling in lock_ycbcr

cros_gralloc_lock_ycbcr() obtains the mapping first and then fills in
the android_ycbcr struct. However the last step can fail if the backing
format is not included in the switch statement. In this case the function
returns without releasing the mapping.

Fix it by calling mod->drv->unlock() before returning, when the format
is unsupported. Also do not attempt to fill in the struct if the earlier
mod->drv->lock(() fails.

BUG=b:32077885
TEST=lock_ycbcr() fails properly for HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
 when it is backed by a RGBX_8888 buffer on Poppy.

Change-Id: I0b8cf91c578595a1b6ddc6e21009a8a84b8ac4de
Reviewed-on: https://chromium-review.googlesource.com/544486
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: Add support for buffers required by new camera subsystem
Tomasz Figa [Wed, 5 Jul 2017 08:50:18 +0000 (17:50 +0900)]
minigbm: i915: Add support for buffers required by new camera subsystem

The new camera subsystem on ChromeOS (introduced with selected KBL
boards) requires following Android pixel formats to be supported:
 - HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
 - HAL_PIXEL_FORMAT_YCbCr_420_888,
 - HAL_PIXEL_FORMAT_BLOB (JPEG binary data).

The first two need to map to DRM_FORMAT_NV12, if used with camera, so
adjust .resolve_format() callback to choose this format when camera
usage bits are specified. Also add respective combinations.

The last one is used specifically for JPEG binary data and the
cros_gralloc layer maps it into DRM_FORMAT_R8, so we need to add it to
the list of combinations for camera usage.

Note that the new usage flags are used only be the new camera subsystem
and do not affect existing boards. They will be migrated later, with the
initial objective to support NV12, so the combinations should remain
valid.

BUG=b:37615277
TEST=Camera preview renders correctly on Poppy.

Change-Id: Ib1081374ed82df9ae1cf543d85a2f5c50ff23371
Reviewed-on: https://chromium-review.googlesource.com/559315
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: Determine tiling based on the combinations
Tomasz Figa [Fri, 23 Jun 2017 09:04:02 +0000 (18:04 +0900)]
minigbm: i915: Determine tiling based on the combinations

We already have the combinations infrastructure, which contains all the
information about supported tiling modes for given usage. Instead of
hardcoding this in i915_bo_create() one more time, let's just query for
the best available combination.

BUG=b:37615277
TEST=test_that reef graphics_Drm.bvt

Change-Id: I320da6419d001a41e965df00595de2fe17bd60f8
Reviewed-on: https://chromium-review.googlesource.com/544488
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: Fix handling of format modifiers
Tomasz Figa [Sat, 8 Jul 2017 06:53:11 +0000 (15:53 +0900)]
minigbm: i915: Fix handling of format modifiers

As of today, drv_query_kms() does not report available format modifiers
and all returned items have DRM_FORMAT_MOD_NONE. The i915 backend has
a hack that adds KMS usage flags to X-tiled combinations even for items
without a modifier. However it is incorrect, as it adds cursor usage
flag, even though it isn't supported. On top of that, it is written in
a very convoluted way that hides the original problem.

Make i915_add_combinations() always set metadata.modifier (since we
already have the knowledge about mapping between I915 modifiers and
tiling modes) and use it to match combinations with KMS items. Add an
explicit special case for DRM_FORMAT_MOD_NONE and I915_TILING_X, which
adds KMS usage flags (other than cursor) to matched combinations.

BUG=b:37615277
TEST=test_that reef graphics_Drm.bvt

Change-Id: Ia7573a330ccc35c3d9868ba1aa45d73bda2f691b
Reviewed-on: https://chromium-review.googlesource.com/564187
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: Resolve format based on BO usage flags
Tomasz Figa [Wed, 5 Jul 2017 09:15:06 +0000 (18:15 +0900)]
minigbm: Resolve format based on BO usage flags

On certain platforms, depending on buffer usage, the preference for
implementation defined or flexible YUV formats might be different.
For example, the camera subsystem on Poppy (i915) requires NV12 for
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, but it can't be used in place
of RGBX as a render target.

Allow this by extending the .resolve_format driver callback to take BO
flags as argument and let the driver include this in the format
selection logic.

BUG=b:37615277
TEST=compile

Change-Id: Ieb44c294584ab25f106a92f406353212989d0724
Reviewed-on: https://chromium-review.googlesource.com/487553
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agocall drv_gem_bo_destroy from i915_bo_import
Joe Kniss [Thu, 29 Jun 2017 18:54:22 +0000 (11:54 -0700)]
call drv_gem_bo_destroy from i915_bo_import

... when returning on error to close open gem handles.

BUG=chromium:738113
TEST=graphicsSanity on cyan

Change-Id: I19e30abc57349655b1f1c28d38aee67a39482cc6
Reviewed-on: https://chromium-review.googlesource.com/556402
Commit-Ready: Joe Kniss <djmk@google.com>
Tested-by: Joe Kniss <djmk@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: add GBM_BO_USE_TEXTURING
Dongseong Hwang [Fri, 23 Jun 2017 23:11:50 +0000 (16:11 -0700)]
minigbm: add GBM_BO_USE_TEXTURING

Chromium passes in no flags to gbm_bo_create() to indicate the buffer will be
used as a texture. This convention has caused confusion in the past.

CL:448251 introduced BO_USE_TEXTURE, so it makes sense to match the more
explicit internal semantics.

TEST=run mapped_texture_test -f NV12 of drm-tests package on amd64-generic
BUG=chromium:683347

Change-Id: I40782763d125e640b4bb6a157035b17ebc32cc8c
Reviewed-on: https://chromium-review.googlesource.com/546884
Commit-Ready: Dongseong Hwang <dongseong.hwang@intel.com>
Tested-by: Dongseong Hwang <dongseong.hwang@intel.com>
Reviewed-by: Dongseong Hwang <dongseong.hwang@intel.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoAdd tegra_bo_import to query tile format.
Joe Kniss [Wed, 28 Jun 2017 21:06:24 +0000 (14:06 -0700)]
Add tegra_bo_import to query tile format.

When a buffer is imported, knowledge of tiling is needed for later calls
to map.  Add this functionality for tegra gpus.

The Tegra display engine only knows about 3 compression schemes, of
which we only use two (NV_MEM_KIND_C32_2CRA and NV_MEM_KIND_PITCH), these
are correlated to DRM_TEGRA_GEM_TILING_MODE_BLOCK and
DRM_TEGRA_GEM_TILING_MODE_PITCH respectively in the tegra drm driver.

BUG=chromium:653283, b:38152101
TEST=graphicsSanity on nyan_big

Change-Id: Ie28212494ad109bd8caa929a9271fc4c55c5c977
Reviewed-on: https://chromium-review.googlesource.com/553517
Commit-Ready: Joe Kniss <djmk@google.com>
Tested-by: Joe Kniss <djmk@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: cros_gralloc: refactor for future HALs
Gurchetan Singh [Wed, 31 May 2017 21:31:31 +0000 (14:31 -0700)]
minigbm: cros_gralloc: refactor for future HALs

We want the ability to support gralloc0, gralloc1 and HIDL
gralloc in this repo. This commit moves gralloc0 specific code
to the gralloc0 subdirectory, and refactors the rest of the code
so it can be eventually used by whichever APIs we choose to
implement.

In addition, all of the data by the module is now handled by
managed pointers instead of process data, since we get a number
of crash reports when we try to access data in gralloc_close().

BUG=b:62069164, b:62221166
TEST=gralloctest all, Android boots, Youtube videos, 5-10
     CTS tests

Change-Id: Ic29a777573936216d99498d0b814ea50015fd435
Reviewed-on: https://chromium-review.googlesource.com/521794
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: i915: add NV12 for EGLImage.
Dongseong Hwang [Wed, 7 Jun 2017 22:17:25 +0000 (15:17 -0700)]
minigbm: i915: add NV12 for EGLImage.

GPU decoder will use it. Unfortunately, IA doesn't support NV12 scanout plane
yet.

TEST=run mapped_texture_test -f NV12 of drm-tests package on amd64-generic
BUG=chromium:683347

Change-Id: If83f961d59fff1d174926df0d96b665aef8b6048
Reviewed-on: https://chromium-review.googlesource.com/527701
Commit-Ready: Dongseong Hwang <dongseong.hwang@intel.com>
Tested-by: Dongseong Hwang <dongseong.hwang@intel.com>
Reviewed-by: Dongseong Hwang <dongseong.hwang@intel.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: Ensure DRM_FORMAT_YVU420_ANDROID meets Android requirements.
Owen Lin [Mon, 5 Jun 2017 06:33:08 +0000 (14:33 +0800)]
minigbm: Ensure DRM_FORMAT_YVU420_ANDROID meets Android requirements.

For HAL_PIXEL_FORMAT_YV12 (mapped to DRM_FORMAT_YVU420_ANDROID), it
needs to meet the following requirements:
 - The vertical stride must equal to the buffer's height.
 - The chroma stride is 16-byte aligned.

As a result, stop mapping DRM_FORMAT_FLEX_YCbCr_420_888 to
DRM_FORMAT_YVU420_ANDROID. The format is used for hardware decoding,
It has more restrictions on the alignments of the width or height.

Bug: b:31479749
Test: Run the testOtherVP8ImageReader and testGoogH264ImageReader of
      android.media.cts.ImageReaderDecoderTest.

Change-Id: Id37f51115ed8b1937ca7d6e48abd809235b43fe4
Reviewed-on: https://chromium-review.googlesource.com/526758
Commit-Ready: Owen Lin <owenlin@chromium.org>
Tested-by: Owen Lin <owenlin@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: pass the right size to drv_add_combinations().
Dongseong Hwang [Wed, 14 Jun 2017 17:47:11 +0000 (10:47 -0700)]
minigbm: i915: pass the right size to drv_add_combinations().

TEST=run drm-tests on amd64-generic

Change-Id: I7e1f99b4475b48f5cc2b0688dec9935ea2908d71
Reviewed-on: https://chromium-review.googlesource.com/535019
Commit-Ready: Dongseong Hwang <dongseong.hwang@intel.com>
Tested-by: Dongseong Hwang <dongseong.hwang@intel.com>
Reviewed-by: Dongseong Hwang <dongseong.hwang@intel.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: amdgpu: enable handling of NV12 & NV21 format
Shirish S [Tue, 18 Apr 2017 10:51:59 +0000 (16:21 +0530)]
minigbm: amdgpu: enable handling of NV12 & NV21 format

This patch does the below:
1. Adds DRM_FORMAT_NV12 & DRM_FORMAT_NV21
   to the list of formats supported by amdgpu driver
2. bo_create() updates parameter's of video planes
   appropriately.
3. add DRM_FORMAT_NV21 in drv.c & helpers.c

This patch is a step towards enabling overlay based video rendering
capability available in hardware.

BUG=b:37526302
TEST=emerge-kahlee media-libs/minigbm
TEST=Boots to UI on jadeite & kahlee
TEST=With all the changes in kernel(not upstreamed) execute below:
     plane_test --format AR24 --size 500x50 -p --format NV12 --size 500x500
     plane_test --format AR24 --size 500x50 -p --format NV12 --size 1280x720
     plane_test --format AR24 --size 500x50 -p --format NV12 --size 1366x768
     plane_test --format AR24 --size 500x50 -p --format NV21 --size 1366x768
TEST=displays same colored layers on video and RGB plane.

Change-Id: If75a4586b636b600a5b4b2d909f10bcf03613cc2
Signed-off-by: Shirish S <shirish.s@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/479043
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: cros_gralloc: fix incorrect handle calculations
Gurchetan Singh [Fri, 26 May 2017 17:04:29 +0000 (10:04 -0700)]
minigbm: cros_gralloc: fix incorrect handle calculations

We were including native handle size in our numInts calculations.
Fix this.

BUG=b:62060380
TEST=gralloc related ASAN errors go away

Change-Id: I9ae66655f9e40d82a9cd3fe91ddca9f300fda911
Reviewed-on: https://chromium-review.googlesource.com/517279
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Luis Hector Chavez <lhchavez@chromium.org>
6 years agominigbm: remove BO_USE_RENDERING from certain formats
Gurchetan Singh [Mon, 15 May 2017 16:34:22 +0000 (09:34 -0700)]
minigbm: remove BO_USE_RENDERING from certain formats

We can't use GR88, R8, YV12, NV12, UYVY, YUYV buffers as render
targets, so let's remove the BO_USE_RENDERING flag from these
formats. However, we can sample from these formats (though this
feature still needs to be enabled in our drivers), so the
BO_USE_TEXTURE flag remains set.

Also, change our interpretation of the GRALLOC_USAGE_HW_COMPOSER
flag such that it implies BO_USE_SCANOUT | BO_USE_TEXTURE. This
is because the OpenGL fallback textures from the buffer if
can't be scanned-out, not renders to it.

BUG=none
TEST=run Youtube app on Kevin

Change-Id: I9ea8452279e110bc1a9579f162abe1c72192eb40
Reviewed-on: https://chromium-review.googlesource.com/506812
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: Do not lock gralloc_close
Daniel Kurtz [Fri, 12 May 2017 11:20:06 +0000 (19:20 +0800)]
minigbm: cros_gralloc: Do not lock gralloc_close

cros_gralloc implements Gralloc Module API 0.2.  Android framework's
libui uses a Gralloc1On0Adapter adapter on top of gralloc modules < 1.0.

The Gralloc1On0Adapter is a singleton object that calls gralloc_close in
its destructor.  cros_gralloc implements gralloc_close() as
cros_gralloc_close().

In other words cros_gralloc_close() is called at process exit during
__cxa_finalize, which is not a safe place to do std::mutex operations.
In fact, the lock_guard() sometimes hangs while trying to aquire the
lock resulting in a non-responsive app.

Fix this by removing the lock_guard in cros_gralloc_close().

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
BUG=b/38016927
TEST=Use cherry to run 1 dEQP test.
 => No anr crash after 30 seconds in com.drawelements.deqp:testercore

Change-Id: I469516b8b3a7d8ac6b89e571f137935f097c9af9
Reviewed-on: https://chromium-review.googlesource.com/504429
Commit-Ready: Ilja H. Friedel <ihf@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: fix typo in PRESUBMIT.cfg
Gurchetan Singh [Mon, 15 May 2017 21:33:16 +0000 (14:33 -0700)]
minigbm: fix typo in PRESUBMIT.cfg

Now clang-format will be run everytime a committer runs repo upload
with the --no-verify option. The committer will have to resolve
differences, i.e:

1) add clang-format off / clang-format on.
2) change files such that clang-format does not complain.

Since our version of clang-format was updated (in the LLVM ebuild), I had to
resolve a few conflicts in rockchip.c and tegra.c.

BUG=none
TEST=none

Change-Id: Ia32d3c47243957f2d674f142bda9daf7917aab0b
Reviewed-on: https://chromium-review.googlesource.com/506508
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: Use pkg-config for LIBS
Tomasz Figa [Tue, 9 May 2017 14:07:01 +0000 (23:07 +0900)]
minigbm: cros_gralloc: Use pkg-config for LIBS

This changes the Makefile to use pkg-config to query for necessary
library paths and names instead of hardcoding -ldrm.

BUG=b:36540057
TEST=emerge-reef arc-cros-gralloc with multilib patches
CQ-DEPEND=CL:505794

Change-Id: Id223203506d71b3966e9730f92badb461eb6cb1b
Reviewed-on: https://chromium-review.googlesource.com/499971
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Luis Hector Chavez <lhchavez@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
6 years agominigbm: cros_gralloc: Use pkg-config
Luis Hector Chavez [Wed, 3 May 2017 22:14:41 +0000 (15:14 -0700)]
minigbm: cros_gralloc: Use pkg-config

This change uses pkg-config to find the libdrm headers instead of
relying on the arc-toolchain sysroot.

BUG=b:26864637
TEST=reef compiles, surfaceflinger is happy
CQ-DEPEND=CL:494886

Change-Id: Ic6142424ff5593ab5552dd61b8ae4b7dc38497fc
Reviewed-on: https://chromium-review.googlesource.com/495267
Commit-Ready: Luis Hector Chavez <lhchavez@chromium.org>
Tested-by: Luis Hector Chavez <lhchavez@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agoAdd HAL_PIXEL_FORMAT_BLOB format in cros gralloc
Heng-Ruey Hsu [Thu, 27 Apr 2017 03:33:35 +0000 (11:33 +0800)]
Add HAL_PIXEL_FORMAT_BLOB format in cros gralloc

We convert HAL_PIXEL_FORMAT_BLOB to DRM_FORMAT_R8 for camera picture
taking. Choose DRM_FORMAT_R8 because <system/graphics.h> requires the
buffers with a format HAL_PIXEL_FORMAT_BLOB have a height of 1, and
width equal to their size in bytes.

BUG=b:37692495
TEST=open camera app and take a picture.

Change-Id: I11a82b057b7c1174dd946e0b7d3cbde9c1d630d9
Reviewed-on: https://chromium-review.googlesource.com/487552
Commit-Ready: Heng-ruey Hsu <henryhsu@google.com>
Tested-by: Heng-ruey Hsu <henryhsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
6 years agominigbm: i915: use explicit cache flush to maintain coherency
Gurchetan Singh [Wed, 18 Jan 2017 21:48:11 +0000 (13:48 -0800)]
minigbm: i915: use explicit cache flush to maintain coherency

The Intel last level cache (LLC) acts a coherency controller on
hardware that has it. Use I915_PARAM_HAS_LLC to determine if the
hardware has LLC.

We can maintain coherency by doing a clflush on non-LLC platforms, like the
Vulkan driver in Mesa does.

BUG=none
TEST=gbmtest on Cyan, Chrome boots, Android boots, mmap_test -g, 5-10 CTS
tests. No regressions.

CQ-DEPEND=CL:425716

Change-Id: I054e69c23016cd3336c2de1d07b49bb2c3709389
Reviewed-on: https://chromium-review.googlesource.com/454105
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: i915: use DRM_IOCTL_I915_GEM_MMAP when needed
Gurchetan Singh [Fri, 6 Jan 2017 04:39:31 +0000 (20:39 -0800)]
minigbm: i915: use DRM_IOCTL_I915_GEM_MMAP when needed

The following three CTS tests fail with an i915 backend:

EncodeVirtualDisplayWithCompositionTest#testRendering800x480Locally
EncodeVirtualDisplayWithCompositionTest#testRenderingMaxResolutionRemotely
EncodeVirtualDisplayWithCompositionTest#testVirtualDisplayRecycles

The reason for the failures is the bo_map() function calls
DRM_IOCTL_I915_GEM_MMAP_GTT with untiled buffers, leading to
Surface::dequeueBuffer not completing in time.

Note the final form of unmap will be a clfush.

BUG=none
TEST=The 3 CTS tests pass.
CQ-DEPEND=CL:454104

Change-Id: I60826d0006da345eceb89f26543e1cc436bbf312
Reviewed-on: https://chromium-review.googlesource.com/425716
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: i915: libdrm-ize backend"
Gurchetan Singh [Wed, 18 Jan 2017 00:15:25 +0000 (16:15 -0800)]
Revert "minigbm: i915: libdrm-ize backend"

As per offline discussion, libdrm_intel doesn't maintain cache coherency
correctly for a number of edge cases.

The plan is to:

1) Revert the libdrm CL.
2) Use simpler mmap/unmap logic to deal CTS failures.
3) Use explicit flush to deal with coherency.

CQ-DEPEND=CL:454105

This reverts commit 82a8eedaa5d01dea4c244be751e950566dcd274e.
Conflicts: i915.c

Change-Id: I6c0bf746b71ea08f5cf4f1aa80d17d28b26ec4c6
Reviewed-on: https://chromium-review.googlesource.com/454104
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
7 years agominigbm: cros_gralloc: Fix type mismatch on 64-bit builds
Tomasz Figa [Wed, 26 Apr 2017 08:26:04 +0000 (17:26 +0900)]
minigbm: cros_gralloc: Fix type mismatch on 64-bit builds

For some reason GCC does not like using %llu print format for uint64_t, which
maps to unsigned long on Linux x86_64. However on Linux i386 unsigned
long is a 32-bit type and uint64_t maps effectively to unsigned long
long and we need to use %llu. To work this around, simply cast the value
to unsigned long long.

BUG=b:36540057
TEST=emerge-reef arc-cros-gralloc with multilib patches applied

Change-Id: Ic585d40d690346babc280a04111fc8aedf8a30cd
Reviewed-on: https://chromium-review.googlesource.com/487766
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: Add a LICENSE file
Casey Dahlin [Wed, 19 Apr 2017 22:52:21 +0000 (15:52 -0700)]
minigbm: Add a LICENSE file

Minigbm is under the Chromium OS LICENSE

TEST=None
BUG=None

Change-Id: Iec28c6f793b40867d01c2b445d8f94ba4a2a2e04
Reviewed-on: https://chromium-review.googlesource.com/482408
Commit-Ready: Casey Dahlin <sadmac@google.com>
Tested-by: Casey Dahlin <sadmac@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: virtio-gpu: add more supported formats
Gurchetan Singh [Sat, 8 Apr 2017 00:15:34 +0000 (17:15 -0700)]
minigbm: virtio-gpu: add more supported formats

There is a desire to use virtio-gpu + Android with kernel v4.4. Let's
make it like the vgem backend, which aligns widths and heights to
64-pixel boundaries to support LLVM requirements.

BUG=chromium:616275
TEST=no crashes when running Android with amd64-generic-cheets

Change-Id: I5640a0f9cc84260d30eecddd84307170fa41d2ce
Reviewed-on: https://chromium-review.googlesource.com/471879
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: disable default Chromium style checks
Gurchetan Singh [Tue, 4 Apr 2017 16:09:27 +0000 (09:09 -0700)]
minigbm: disable default Chromium style checks

Adding these hook overrides disables all of the default ChromiumOS
source style checks. This way repo upload . should just run
our presubmit script.

BUG=none
TEST=none

Change-Id: I18803f5a94ef4c17043dcb12c817e8cf78b64d66
Reviewed-on: https://chromium-review.googlesource.com/467646
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: vgem: add more supported formats
Gurchetan Singh [Tue, 4 Apr 2017 15:51:23 +0000 (08:51 -0700)]
minigbm: vgem: add more supported formats

The VM-tests in the Android PFQ require this now.

BUG=chromium:616275
TEST=-cheets_CTSHelper.smoke doesn't crash in a VM

Change-Id: Icd062210852810036ab349af10b350507e1b560b
Reviewed-on: https://chromium-review.googlesource.com/467626
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: cros_gralloc: fix modifier serialization/de-serialization
Gurchetan Singh [Mon, 20 Mar 2017 22:00:29 +0000 (15:00 -0700)]
minigbm: cros_gralloc: fix modifier serialization/de-serialization

We were only filling up the first five entries of the modifier array
in the handle, and we were doing it incorrectly. Fix this.

BUG=chromium:616275
TEST=compiles

Change-Id: I435f88db1b16af919081122a502cbe7d7fc9e3d9
Reviewed-on: https://chromium-review.googlesource.com/457289
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: cros_gralloc: remove constexpr functions
Gurchetan Singh [Mon, 20 Mar 2017 21:45:39 +0000 (14:45 -0700)]
minigbm: cros_gralloc: remove constexpr functions

There's no reason to have these as functions. Also eliminate
sw_write() and sw_read(), the only reason I added them because
I was hitting the 80 column limit (we're 100 columns wide now).

BUG=chromium:616275
TEST=compiles

Change-Id: If0d406df64dc760f2c007eeecf79874c1deb3ec7
Reviewed-on: https://chromium-review.googlesource.com/457288
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: cros_gralloc: remove memsets
Gurchetan Singh [Mon, 20 Mar 2017 21:05:16 +0000 (14:05 -0700)]
minigbm: cros_gralloc: remove memsets

The C++ standard says value initialization results in
zero initialization for structs, so our memsets are
unecessary.

BUG=chromium:616275
TEST=compiles

Change-Id: I1744b237790cb79d2a8be92beffdb2ee9829f4e2
Reviewed-on: https://chromium-review.googlesource.com/457287
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>
7 years agominigbm: fix long lines missed by clang-format
Gurchetan Singh [Mon, 20 Mar 2017 20:05:49 +0000 (13:05 -0700)]
minigbm: fix long lines missed by clang-format

We have 100-lines to work with now.

BUG=none
TEST=compiles

Change-Id: I08f41a42d8841ac82c5a6defbcbc712722179fce
Reviewed-on: https://chromium-review.googlesource.com/457286
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: add clang-format and presubmit hooks
Gurchetan Singh [Sat, 11 Mar 2017 00:25:23 +0000 (16:25 -0800)]
minigbm: add clang-format and presubmit hooks

Running the presubmit.sh script will apply our rules to every file in
the repo. Exclude gbm.h from the formatting requirements since this file
was taken from other open-source projects, and diffing will be easier
without our formatting rules.

In addition, special case drivers where the order of includes matters.

BUG=none
TEST=Verified the following commands succeed:

emerge-cyan minigbm/arc-cros-gralloc
emerge-oak minigbm/arc-cros-gralloc
emerge-veyron_minnie-cheets minigbm/arc-cros-gralloc
emerge-peach_pi minigbm
emerge-nyan_big minigbm
emerge-jadeite minigbm

Change-Id: I6ce93fb1930da254d13d5017766c17341870ccc9
Reviewed-on: https://chromium-review.googlesource.com/447319
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: rockchip: align to 128 bytes
Gurchetan Singh [Fri, 24 Mar 2017 01:47:06 +0000 (18:47 -0700)]
minigbm: rockchip: align to 128 bytes

cmemp_heap_partition in the mali driver checks if every plane is
64-byte aligned. Since we expose a fd for every plane in the
cros gralloc handle, we hit this case. We need to enforce this
alignment on our YV12 allocations.

BUG=chromium:616275
TEST=
android.media.cts.VideoEncoderTest#testGoogH264FlexArbitraryH

passes on veyron_minnie-cheets.

Change-Id: If6375eddd18fd216e7f07eb2cc47090d838f82ab
Reviewed-on: https://chromium-review.googlesource.com/459104
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: work with strides, not widths
Gurchetan Singh [Wed, 29 Mar 2017 15:23:40 +0000 (08:23 -0700)]
minigbm: work with strides, not widths

When doing alignment, many times we get the bytes per pixel, try
to align to a certain boundary, and then pass in the "aligned width"
to drv_bo_from_format. This back and forth is confusing and error
prone. Let's change our drivers and helpers to eliminate this, and
try to work in strides as soon as possible.

Additionally, let's make drv_bpp_from_format a static function. This
is because bits per pixel is ill-defined for YUV formats, and we should
work in strides whenever possible.

BUG=none
TEST=graphics_Gbm runs successfully on Cyan, ui boots

Change-Id: I207ce6fd5eaac472b7b82f0d952b46697e325498
Reviewed-on: https://chromium-review.googlesource.com/462479
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: add bytes per pixel function
Gurchetan Singh [Thu, 23 Mar 2017 18:29:26 +0000 (11:29 -0700)]
minigbm: add bytes per pixel function

We were using the drv_stride_from_format as a shorthand to calculate
bytes per pixel. This is incorrect with the addition of
DRM_FORMAT_YVU420_ANDROID, which always aligns to 16 bytes.

Let's have a separate bytes_per_pixel function to better express what
we want.

BUG=chromium:616275
TEST=android.media.cts.DecodeAccuracyTest
     #testVP9GLViewLargerHeightVideoDecode

passes on veyron_minnie-cheets.

Change-Id: I2d740828d66031c3a032932c09d79dbce21b8986
Reviewed-on: https://chromium-review.googlesource.com/458978
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: fix stride logic
Gurchetan Singh [Wed, 29 Mar 2017 19:37:01 +0000 (12:37 -0700)]
minigbm: fix stride logic

We shouldn't round up to the nearest byte. This way we can represent
formats like Y41P.  Makes no difference currently since
drv_bpp_from_format only returns numbers divisible by eight.

Change-Id: I57bcab383f1661ea11e9aa1d30e18750574143e2
Reviewed-on: https://chromium-review.googlesource.com/462478
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: rockchip: add NV12 back in as supported format
Gurchetan Singh [Tue, 21 Mar 2017 23:18:34 +0000 (16:18 -0700)]
minigbm: rockchip: add NV12 back in as supported format

CL:448252 inadvertently removed this format.

BUG=none
TEST=play video via Youtube app

Change-Id: Ia57c66ffdd6f9ebb401c09dab5ea82eba2fe1893
Reviewed-on: https://chromium-review.googlesource.com/457756
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agovgem: support DRM_FORMAT_YVU420_ANDROID
Gurchetan Singh [Thu, 16 Mar 2017 20:05:45 +0000 (13:05 -0700)]
vgem: support DRM_FORMAT_YVU420_ANDROID

drv_dumb_bo_create function only allocates single-plane formats at the
moment, even though the vgem driver has a resolve format hook that
leads to DRM_FORMAT_YVU420_ANDROID. Let's allocate a single buffer
that's big enough to support DRM_FORMAT_YVU420_ANDROID, as drm_gralloc
does. Note videos don't work with Android emulation, but they never
did with drm_gralloc and that's a separate problem.

BUG=chromium:616275
TEST=no regressions with gbmtest when running qemu + trybots

Change-Id: I9b081dbe553fe1159feaa7eed104ac340c59e41b
Reviewed-on: https://chromium-review.googlesource.com/456404
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: i915: align YV12 to HW requirements
Gurchetan Singh [Thu, 16 Mar 2017 20:14:30 +0000 (13:14 -0700)]
minigbm: i915: align YV12 to HW requirements

As per drm_gralloc we need to:

 (1) align the Y plane to 128 bytes so the chroma planes would be
     aligned to 64 bytes boundaries.
 (2) Have no tiling with YV12.

BUG=chromium:616275
TEST=DecodeEditEncodeTest#testVideoEdit720p

passes on cyan. Run YT app.

Change-Id: I339163c94d4481991702b8bfd232a70f3a275506
Reviewed-on: https://chromium-review.googlesource.com/456403
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: add DRM_FORMAT_YVU420_ANDROID
Gurchetan Singh [Wed, 8 Feb 2017 23:21:14 +0000 (15:21 -0800)]
minigbm: add DRM_FORMAT_YVU420_ANDROID

YV12 in <system/graphics.h> in the Android tree defines the
HAL_PIXEL_FORMAT_YV12 as:

     * y_size = stride * height
     * c_stride = ALIGN(stride/2, 16)
     * c_size = c_stride * height/2
     * size = y_size + c_size * 2
     * cr_offset = y_size
     * cb_offset = y_size + c_size

Let's add a special format DRM_FORMAT_YVU420_ANDROID that adheres to these
requirements.

Previously, our y_size on Intel not adhere to the spec. We should
change drv_bo_from_format to calculate the size of plane not based on the
aligned height, but the height that outside world sees.

BUG=chromium:616275
TEST=
ImageReaderDecoderTest#testGoogH264ImageReader

passes on cyan. Run YT app.

Change-Id: I4906300a0775cf561c4b05bf6d973cf4e82470bc
Reviewed-on: https://chromium-review.googlesource.com/441913
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: deal with ArcCodec use case by exposing struct map_info
Gurchetan Singh [Wed, 15 Feb 2017 01:47:02 +0000 (17:47 -0800)]
minigbm: deal with ArcCodec use case by exposing struct map_info

Let's keep a count of how many times a buffer has been locked, since
we have special lock_ycbcr() behavior that returns the offsets and
strides of a YUV buffer when an usage of zero is passed in. This behavior
is used by the ArcCodec. We have to take care not to call drv_bo_unmap
if we didn't map anything.

We also have to expose struct map_info so we can return the address if
we have mapped data, rather than incrementing the drv map count.

Additionally, the gralloc.h says:

"THREADING CONSIDERATIONS
It is legal for several different threads to lock a buffer from
read access, none of the threads are blocked."

This implies recursive locking, which this commit implements.

BUG=b:34419220
TEST=
android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Qual0320x0240

Change-Id: Ibbe7dd5349594117aaaecca9647ad45264448575
Reviewed-on: https://chromium-review.googlesource.com/442835
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: fix renderscipt allocation
Gurchetan Singh [Fri, 3 Feb 2017 18:07:01 +0000 (10:07 -0800)]
minigbm: fix renderscipt allocation

A few CTS tests are failing due to incompatible usage flags.
Specifically, these combinations are passed in:

{ format: HAL_PIXEL_FORMAT_YCbCr_420_888,
  HAL flags: GRALLOC_USAGE_RENDERSCRIPT |
     GRALLOC_USAGE_SW_READ_OFTEN |
     GRALLOC_USAGE_SW_WRITE_OFTEN }

Let's set the renderscript flag to BO_USE_LINEAR since in our
case renderscript code is executed on the CPU.
Change drivers to make sure linear flags are available.

BUG=b:34422476
TEST=

run cts --package android.security
run cts -m CtsRenderscriptTestCases --skip-device-info
run cts --package android.widget

don't crash due to createGraphicBuffer failures.

Change-Id: I47a97118ae5b6a732e6d5c1f090aa7c3a7cc95a5
Reviewed-on: https://chromium-review.googlesource.com/441915
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: cros_gralloc: make HW_FB a no-op
Gurchetan Singh [Wed, 15 Mar 2017 22:14:56 +0000 (15:14 -0700)]
minigbm: cros_gralloc: make HW_FB a no-op

GRALLOC_USAGE_HW_FB is a legacy flag, and doesn't make
sense in our setup.

BUG=chromium:616275
TEST=compiles

Change-Id: If39634a12ad325b4d28afbd3db335e6ee9e287f6
Reviewed-on: https://chromium-review.googlesource.com/455282
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: rework flag API
Gurchetan Singh [Thu, 2 Mar 2017 04:14:39 +0000 (20:14 -0800)]
minigbm: rework flag API

We've been back and forth on the semantics of the flag API many
times, and the current situation is confusing.

Change the drivers so every combination defines a distinct type of
buffer. That means if the same format is in the combination list three
times, the tiling or format modifiers of one of those combinations must
be different from the other two.

Let's add a priority variable in struct supported_combination that
breaks ties. For example, if a consumer specifies BO_USE_TEXTURE,
we of course can texture from both linear and tiled buffers, but
because a tiled buffer's priority is greater, it will be chosen.

If a consumer specifies BO_USE_TEXTURE | BO_USE_SW_WRITE_OFTEN, the
tiled combination won't have the BO_USE_SW_WRITE_OFTEN flag and the
linear combination will be chosen.

We expect drivers to modify the combinations after querying KMS.
This is clunky using linked lists, so get rid of list.h and use arrays.

BUG=chromium:616275
TEST=all the following compiles:

emerge-cyan minigbm/arc-cros-gralloc
emerge-oak minigbm/arc-cros-gralloc
emerge-veyron_minnie-cheets minigbm/arc-cros-gralloc
emerge-peach_pi minigbm
emerge-nyan_big minigbm
emerge-jadeite minigbm

Tested with gbmtest on cyan, checked if Chrome boots

Change-Id: Ib3fccf6f0cb86c8ded45924297df3c06f8e49271
Reviewed-on: https://chromium-review.googlesource.com/448252
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: cros_gralloc: back out of scanout flag with more clarity
Gurchetan Singh [Thu, 9 Mar 2017 01:28:28 +0000 (17:28 -0800)]
minigbm: cros_gralloc: back out of scanout flag with more clarity

We interpret the following flags as GRALLOC_USAGE_HW_COMPOSER
as BO_USE_SCANOUT | BO_USE_RENDERING:

If the combination is not supported by the driver, let's check if
the gralloc flag is present before we back out for clarity.

BUG=chromium:616275
TEST=compiles

Change-Id: If546ce653f1088cbb1d31cf2f90aba0621ed8b4a
Reviewed-on: https://chromium-review.googlesource.com/451978
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: add BO_USE_TEXTURE
Gurchetan Singh [Thu, 2 Mar 2017 17:48:49 +0000 (09:48 -0800)]
minigbm: add BO_USE_TEXTURE

Many people have requested re-adding BO_USE_TEXTURE as a flag
since:

BO_USE_RENDERING means the buffer will be used as a render target.
BO_USE_TEXTURE means the buffer will be textured from.

BUG=chromium:616275
TEST=minigbm/arc-cros-gralloc compiles

Change-Id: I63be6682cf4e2415dc42c78b2cab3ad694bcd818
Reviewed-on: https://chromium-review.googlesource.com/448251
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agoAdd support to build with Android.
Kalyan Kondapally [Sat, 4 Feb 2017 20:10:50 +0000 (12:10 -0800)]
Add support to build with Android.

BUG=None
TEST=Able to build Minigbm in a pure Android environment
     i.e. Android IA.

Change-Id: Ib12e8411b4ba42b8dd83974fc372bf4884ed6e41
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/448841
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: align first plane to 64 bytes
Gurchetan Singh [Wed, 8 Feb 2017 23:09:13 +0000 (15:09 -0800)]
minigbm: align first plane to 64 bytes

The chroma stride of Android YV12 buffers is required to be
aligned to 16 bytes (see <system/graphics.h>).

Additionally, the size of the ARM L1 cache line is 64-bytes
(see chrome-os-partner:45777).

Let's always align the first plane to 64 bytes. The chroma strides
will be aligned to 32 bytes in that case.

BUG=chromium:616275
TEST=

ImageReaderDecoderTest#testGoogH264ImageReader

passes on veyron_minnie-cheets.

Change-Id: I87a309ce0612bf8c5be8f8e47dad3da10d61a081
Reviewed-on: https://chromium-review.googlesource.com/441912
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
7 years agominigbm: add map_info to proper table
Gurchetan Singh [Mon, 13 Feb 2017 18:29:32 +0000 (10:29 -0800)]
minigbm: add map_info to proper table

The map_info data allocated drv_bo_map() should be added to the
map_table, not the buffer_table.

BUG=b:34580741, b:34528332
TEST=
android.uirendering.cts.testclasses.InfrastructureTests#testScreenshot

passes on Cyan.

Change-Id: I14a70df8fb174bc572ef3488f14c494808bab0e0
Reviewed-on: https://chromium-review.googlesource.com/441911
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
7 years agominigbm: rockchip: use height to calculate h_mbs
Gurchetan Singh [Mon, 23 Jan 2017 15:58:59 +0000 (07:58 -0800)]
minigbm: rockchip: use height to calculate h_mbs

The block height should be calculated from the height,
not the width.

BUG=none
TEST=none

Change-Id: Ica4bca0831c12a2594e16c06c42074592a8fd560
Reviewed-on: https://chromium-review.googlesource.com/441910
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
7 years agominigbm: Add VC4 backend
Niklas Schulze [Wed, 8 Feb 2017 14:29:21 +0000 (15:29 +0100)]
minigbm: Add VC4 backend

BUG=None
TEST=None

Change-Id: I6cece89a42ea41066cd8c4e2fc332898d5edb60a
Reviewed-on: https://chromium-review.googlesource.com/439448
Commit-Ready: Niklas Schulze <me@jns.io>
Tested-by: Niklas Schulze <me@jns.io>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agorockchip: Don't enable AFBC if width > 2560
Kristian H. Kristensen [Tue, 7 Feb 2017 06:16:55 +0000 (22:16 -0800)]
rockchip: Don't enable AFBC if width > 2560

BUG=chrome-os-partner:62585
TEST=Plug in monitor with native resolution over 2560 (eg 4k monitor)
and verify the output looks correct.

Change-Id: Iec925f54d74be19342d710313e5ac4ddca529e62
Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-on: https://chromium-review.googlesource.com/438831
Commit-Ready: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: support YV12 with frequent software access
Gurchetan Singh [Thu, 19 Jan 2017 18:43:44 +0000 (10:43 -0800)]
minigbm: support YV12 with frequent software access

android.media and android.mediastresss use this combination a lot.

BUG=b:34422476
TEST=run cts -c android.media.cts.AdaptivePlaybackTest -m testH263_adaptiveDrc
     passes on cyan

Change-Id: I906c601f24b8454ab98e7297ac663bfe85f55589
Reviewed-on: https://chromium-review.googlesource.com/430200
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agoamdgpu: Send correct flags to AMDGPU_GEM_CREATE
Akshu Agrawal [Mon, 9 Jan 2017 09:10:32 +0000 (14:40 +0530)]
amdgpu: Send correct flags to AMDGPU_GEM_CREATE

On the basis of gbm flags, send proper flags to AMDGPU_GEM_CREATE

BUG:chrome-os-partner:61504
TEST: With CL:418518 drm_cursor_test passess

Change-Id: Ia1c55a6494ceebe9446d68cdc2cd70eb5d290529
Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
Reviewed-on: https://chromium-review.googlesource.com/427482
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: i915: libdrm-ize backend
Gurchetan Singh [Tue, 3 Jan 2017 21:01:37 +0000 (13:01 -0800)]
minigbm: i915: libdrm-ize backend

With cros_gralloc enabled, the following three CTS tests fail with an i915
backend:

EncodeVirtualDisplayWithCompositionTest#testRendering800x480Locally
EncodeVirtualDisplayWithCompositionTest#testRenderingMaxResolutionRemotely
EncodeVirtualDisplayWithCompositionTest#testVirtualDisplayRecycles

The reason for the failures is the bo_map() function calls
DRM_IOCTL_I915_GEM_MMAP_GTT with untiled buffers, leading to
Surface::dequeueBuffer not completing in time.

In addition, we never set the domain when we map, which can lead to
cache coherency issues.

libdrm already has functions for regular and GTT mapppings, so let's just
add it here rather than duplicating the logic.

TEST=Chrome boots and container boots
     gbmtest, tiled_bo_test, all CTS tests specified in go/arc++gfx pass
BUG=chromium:616275
CQ-DEPEND=CL:424674

Change-Id: I68943367205abd3b470adb0597109fe30aa3e381
Reviewed-on: https://chromium-review.googlesource.com/424832
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: i915: group helper functions
Gurchetan Singh [Tue, 3 Jan 2017 21:36:13 +0000 (13:36 -0800)]
minigbm: i915: group helper functions

Looks slightly better.

TEST=none
BUG=none

Change-Id: I9820e52e5360e2a6a9de26e1a84a1260311d2129
Reviewed-on: https://chromium-review.googlesource.com/424792
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: add bo import callback
Gurchetan Singh [Wed, 4 Jan 2017 00:49:56 +0000 (16:49 -0800)]
minigbm: add bo import callback

Some drivers may want to import their own private data,
so let's add a driver callback.

BUG=none
TEST=minigbm builds, gbmtest

Change-Id: I96c06a84446c9be4ac3f5f858094c500d43a077f
Reviewed-on: https://chromium-review.googlesource.com/424934
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: amdgpu: Add mmap implementation for amdgpu
Pratik Vishwakarma [Mon, 12 Dec 2016 08:52:10 +0000 (14:22 +0530)]
minigbm: amdgpu: Add mmap implementation for amdgpu

BUG=chrome-os-partner:61504
TEST=graphics_Gbm

Change-Id: I4ad23fa5b55a249e75ec44fe499c499052f687e0
Reviewed-on: https://chromium-review.googlesource.com/418425
Commit-Ready: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com>
Tested-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: cros_gralloc: don't fail BO_USE_SW_*_OFTEN | BO_USE_RENDERING allocation
Gurchetan Singh [Tue, 27 Dec 2016 18:25:18 +0000 (10:25 -0800)]
minigbm: cros_gralloc: don't fail BO_USE_SW_*_OFTEN | BO_USE_RENDERING allocation

Some camera CTS tests pass down the following usage:

GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_SW_WRITE_OFTEN,

which we convert. Since we generally want to create a tiled buffer when
GRALLOC_USAGE_HW_TEXTURE is specified and tiled buffers are inefficient for
frequent software access, many drivers don't support this combination.

When this occurs, let's drop the BO_USE_RENDERING flag and try the allocation again
with different flags.

BUG=chromium:616275
TEST=run cts --disable-reboot --class android.hardware.camera2.cts.MultiViewTest
passes on kevin

Change-Id: Id3364edb849fe92d4710c765ed664e8aa4a4738d
Reviewed-on: https://chromium-review.googlesource.com/424318
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agorockchip: Add support for AFBC buffers
Kristian H. Kristensen [Tue, 6 Sep 2016 18:43:26 +0000 (11:43 -0700)]
rockchip: Add support for AFBC buffers

This adds support for allocating AFBC (ARM FrameBuffer Compression)
buffers with minigbm for Rockchip SoCs. AFBC buffers are allocated
through the new gbm_bo_create_with_modifiers() entry point. Callers are
responsible for determining which modifiers are valid for the intended
use case and pass in that list. gbm will then pick the optimal modifier
and allocate a buffer with that layout.  The chosen modifier can be
queries through gbm_bo_get_format_modifier().

Callers of the new entry point are expected to forward the modifier when
using the buffer with other APIs (EGL, KMS etc). The old gbm_bo_create()
entry point continues to work as before and won't allocate AFBC buffers.

BUG=chrome-os-partner:56407
TEST=drm-tests null_platform_test with AFBC support

Change-Id: I1aa345b0d79c4545b7bfc17e9699ef6ad57c68e2
Reviewed-on: https://chromium-review.googlesource.com/386318
Commit-Ready: Kristian H. Kristensen <hoegsberg@chromium.org>
Tested-by: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: fix size_t type not found
Heng-Ruey Hsu [Wed, 21 Dec 2016 05:59:20 +0000 (13:59 +0800)]
minigbm: fix size_t type not found

BUG=b:24674340
TEST=build pass on kevin

Change-Id: Idd780ee5e99e864ed0f97503e7b38673761201e8
Reviewed-on: https://chromium-review.googlesource.com/422808
Commit-Ready: Heng-ruey Hsu <henryhsu@chromium.org>
Tested-by: Heng-ruey Hsu <henryhsu@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: consolidate flags
Gurchetan Singh [Mon, 19 Dec 2016 23:14:18 +0000 (15:14 -0800)]
minigbm: consolidate flags

Let's try to organize the flags such that one entry in the supported
combination list implies a certain type of buffer. For example, we only
create linear buffers in our Mediatek, so the following entries are
equivalent:

{DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
BO_USE_RENDERING | BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY},

{DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN |
BO_USE_SW_WRITE_OFTEN},

Since they both translate into a XRGB8888 linear buffer on Mediatek, let's merge
the two entries. Do similiar operations for every driver.

BUG=none
TEST=try-bots

Change-Id: I0be97c2deec5310f426632f85d1525a1345498e6
Reviewed-on: https://chromium-review.googlesource.com/421499
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: tegra: add blocklinear detiling logic
Gurchetan Singh [Wed, 14 Dec 2016 16:51:28 +0000 (08:51 -0800)]
minigbm: tegra: add blocklinear detiling logic

With CL:397941, hshi@ figured out how to detile blocklinear buffers
for tegra. Let's add that logic to our tegra map()/unmap() functions.
This can be useful for various tests.

BUG=chromium:673570
TEST=tiled_bo_test draws ellipse texture on Tegra (there are artifacts
     due another bug though)

Change-Id: I7c2e7222ba67457ffd3641ba42a775ac4a667ec8
Reviewed-on: https://chromium-review.googlesource.com/421279
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Haixia Shi <hshi@chromium.org>
7 years agominigbm: Remove (c) from copyright notice.
Daniele Castagna [Fri, 16 Dec 2016 22:32:30 +0000 (17:32 -0500)]
minigbm: Remove (c) from copyright notice.

The pre-submit hook script checks that copyright messages don't
contain "(c)".

This CL removes "(c)" from all the copyrights header in minigbm
that still have it.

BUG=None
TEST=emerge-$BOARD minigbm.

Change-Id: I1922d9d29b78d124302d497310fe1c1cfd6fc695
Reviewed-on: https://chromium-review.googlesource.com/421588
Commit-Ready: David Reveman <reveman@chromium.org>
Commit-Ready: Daniele Castagna <dcastagna@chromium.org>
Tested-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: Add dumb buffer 'nouveau' backend.
Daniele Castagna [Fri, 16 Dec 2016 21:24:06 +0000 (16:24 -0500)]
minigbm: Add dumb buffer 'nouveau' backend.

Adding a nouveau backend to minigbm can be useful to test ozone code
on our workstations.

This CL adds a nouveau backend that uses dumb buffers.
This is enough to run ozone_gl_unittests and ozone_demo on our
workstations.

BUG=None
TEST='Ran ozone_demo on my workstation.'

Change-Id: I4e690192c9d9944b9907e64253205a94605a76eb
Reviewed-on: https://chromium-review.googlesource.com/421606
Commit-Ready: David Reveman <reveman@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: tegra: align linear buffers to 64-byte boundaries
Gurchetan Singh [Fri, 16 Dec 2016 23:51:46 +0000 (15:51 -0800)]
minigbm: tegra: align linear buffers to 64-byte boundaries

Tegra20 and Tegra30 both required the buffer line stride to be aligned
on 8 byte boundaries. Tegra114 and Tegra124 increased the alignment to
64 bytes.

The kernel automatically does this for us for dumb buffers, but since the
tegra gem create API doesn't return the stride, we'll have to do it here.

BUG=chromium:673570
TEST=tiled_bo_test succeeds

Change-Id: I2222f033813a31d3eed1a6794fbf044fba33eec0
Reviewed-on: https://chromium-review.googlesource.com/421278
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Haixia Shi <hshi@chromium.org>
7 years agominigbm: Move c99 flag from CPPFLAGS to CFLAGS
Stéphane Marchesin [Tue, 29 Nov 2016 23:22:04 +0000 (15:22 -0800)]
minigbm: Move c99 flag from CPPFLAGS to CFLAGS

It has nothing to do with the preprocessor.

BUG=none
TEST=builds

Change-Id: Ib5c851b0127d36bf52cce1e5c81cfed0eb3b541d
Reviewed-on: https://chromium-review.googlesource.com/415112
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
7 years agominigbm: add width and height in dumb create
Gurchetan Singh [Tue, 6 Dec 2016 23:43:17 +0000 (15:43 -0800)]
minigbm: add width and height in dumb create

We never set the width and height in drv_dumb_bo_create.
We really should do this.

TEST=none
BUG=none

Change-Id: I630866bcf5086fbb3679f772fe0f2857d37f22c2
Reviewed-on: https://chromium-review.googlesource.com/417164
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: cros_gralloc: remove unnecessary information from handle
Gurchetan Singh [Mon, 5 Dec 2016 19:02:55 +0000 (11:02 -0800)]
minigbm: cros_gralloc: remove unnecessary information from handle

Only include information needed to import in the handle. We
were previously including the address space of another process in
the handle, which is a potential security risk.

BUG=chromium:616275
TEST=arc-cros-gralloc works on oak, minnie, cyan
CQ-DEPEND=CL:416399

Change-Id: I10230053e305865db0dde26a596403ec0b9e4f4c
Reviewed-on: https://chromium-review.googlesource.com/416400
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: cros_gralloc: Don't build gbm
Gurchetan Singh [Mon, 5 Dec 2016 17:47:45 +0000 (09:47 -0800)]
minigbm: cros_gralloc: Don't build gbm

Reduces binary size by 4.5 KB.

BUG=chromium:616275
TEST=arc-cros-gralloc builds
CQ-DEPEND=CL:416398

Change-Id: I0d73373657076ce540726225993e1b6c5bb12ae2
Reviewed-on: https://chromium-review.googlesource.com/416399
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: cros_gralloc: modify error statements
Gurchetan Singh [Sat, 3 Dec 2016 02:28:38 +0000 (18:28 -0800)]
minigbm: cros_gralloc: modify error statements

The error statements now look like what's printed in
Chrome's /var/log/ui/ui.LATEST, which I think looks nice.

BUG=chromium:616275
TEST=None
CQ-DEPEND=CL:416397

Change-Id: Ide3eb381ac710f016e9d002e4dd5f9e5ab8eda7f
Reviewed-on: https://chromium-review.googlesource.com/416398
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: cros_gralloc: fix rendernode query
Gurchetan Singh [Sat, 3 Dec 2016 02:15:35 +0000 (18:15 -0800)]
minigbm: cros_gralloc: fix rendernode query

If the vgem driver and a hardware driver are both present on
a machine, and if the vgem driver corresponds to a lower
number rendernode, we'll end up picking the vgem driver. This is
not the desired behavior, so let's fix it.

BUG=chromium:616275
TEST=mediatek driver loads
CQ-DEPEND=CL:416396

Change-Id: Ib2647f4dbaf3c45fab97bbbcbb94e09c1daa6d5d
Reviewed-on: https://chromium-review.googlesource.com/416397
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: mediatek: add support HAL_PIXEL_FORMAT_YV12
Gurchetan Singh [Sat, 3 Dec 2016 01:54:09 +0000 (17:54 -0800)]
minigbm: mediatek: add support HAL_PIXEL_FORMAT_YV12

For some reason, we use HAL_PIXEL_FORMAT_YV12 instead of
HAL_PIXEL_FORMAT_YCbCr_420_888 as our YUV format on mediatek
based boards. We also pass down a different use flags. Since
mediatek only supports linear buffers the moment, just lump all
the flags together for our YUV supported combination.

BUG=chromium:616275
TEST=Played Youtube video in Oak ARC++ container
CQ-DEPEND=CL:416292

Change-Id: Iac4797517048981235cd17ad464eb1e3852c4072
Reviewed-on: https://chromium-review.googlesource.com/416396
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: vgem: add a few more supported formats
Gurchetan Singh [Fri, 2 Dec 2016 20:32:16 +0000 (12:32 -0800)]
minigbm: vgem: add a few more supported formats

While running Android in QEMU, I encountered a few crashes
due to unsupported formats. Add them here.

BUG=chromium:616275
TEST=Run arc-cros-gralloc in QEMU
CQ-DEPEND=CL:416291

Change-Id: Ie9a9dee0cba7c8b83592c40a3249ebcb30391346
Reviewed-on: https://chromium-review.googlesource.com/416292
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: vgem: align to llvm tile size
Gurchetan Singh [Wed, 30 Nov 2016 04:36:13 +0000 (20:36 -0800)]
minigbm: vgem: align to llvm tile size

We're planning on using Mesa with llvmpipe when running
the Android container in a virtual machine. It's faster
than softpipe. llvmpipe requires alignment to a 64-byte
tile size, so add it here.  This is the analogue to
norvez@'s drm_gralloc commiti (ag/1599269).

BUG=b:28802929, chromium:616275
TEST=run arc-cros-gralloc in QEMU

CQ-DEPEND=CL:414537

Change-Id: If4160d376447ce218df3bc410a8427b284de74fd
Reviewed-on: https://chromium-review.googlesource.com/416291
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: tweak cros-gralloc flags
Gurchetan Singh [Tue, 29 Nov 2016 22:45:46 +0000 (14:45 -0800)]
minigbm: tweak cros-gralloc flags

The Play Store wants a ABGR8888 HW cursor, and we can't in
general support this, so let's ignore the cursor flag rather
than fail the allocation.

We also interpret GRALLOC_USAGE_HW_COMPOSER as BO_USE_SCANOUT
| BO_USE_RENDERING. This fails with YV12, since we can't scanout
from it on Intel/Mediatek. Let's first try to allocate with the
scanout flag enabled and then fall-back to rendering if it's
not supported (i.e, first try overlay but then try OpenGL).

In addition, let's interpret GRALLOC_USAGE_HW_FB the same as
GRALLOC_USAGE_HW_COMPOSER since the framebuffer device
(Chrome in our case) wants to scanout but can also fall back.

BUG=chromium:616275
TEST=run cts --package com.drawelements.deqp.egl on minnie
CQ-DEPEND=CL:414536

Change-Id: I57cd681ca8ff0186698bd0a046c3a7b346f3e434
Reviewed-on: https://chromium-review.googlesource.com/414537
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
7 years agominigbm: flatten gralloc handle
Gurchetan Singh [Mon, 28 Nov 2016 23:25:26 +0000 (15:25 -0800)]
minigbm: flatten gralloc handle

Many GL drivers assume that first value in the native_handle data
array is the fd associated with the graphics buffer, i.e,

int prime_fd = handle->data[0];

This in our case until 4bfc7401. We added 64-bit modifiers in
our import data, so all values in the drv_import_fd_data struct get
8-byte aligned. In our cros_gralloc_handle, 4 bytes of padding
are added between native_handle_t and drv_import_fd_data to make
the alignment work. To counter-act this, we can stop embedding
drv_import_fd_data in cros_gralloc_handle.

BUG=chromium:616275
TEST=Mali driver doesn't return an error when running cros_gralloc
CQ-DEPEND=CL:414585

Change-Id: Ib6c165e98126468b96fa7119d5ca13eebee1655c
Reviewed-on: https://chromium-review.googlesource.com/414536
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>