OSDN Git Service

android-x86/external-minigbm.git
6 years agominigbm/i915: Add support for I915_FORMAT_MOD_Y_TILED_CCS.
Yuanjun Huang [Tue, 23 Jan 2018 07:56:19 +0000 (15:56 +0800)]
minigbm/i915: Add support for I915_FORMAT_MOD_Y_TILED_CCS.

This adds support for allocating buffers with the
I915_FORMAT_MOD_Y_TILED_CCS modifier, which enables Intels render
buffer compression.

Jira: https://jira01.devtools.intel.com/browse/AREQ-23273
Test: Build passes and validates with hwcomposer testlayer APP.
Signed-off-by: Yuanjun Huang <yuanjun.huang@intel.com>
6 years agoUpstream: minigbm: i915: Use NV12 as the main YUV format, including camera output
Tomasz Figa [Thu, 22 Jun 2017 07:52:43 +0000 (16:52 +0900)]
Upstream: 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 agoAdded Support for 64bit RGB format
Poornima [Mon, 22 Jan 2018 04:57:26 +0000 (10:27 +0530)]
Added Support for 64bit RGB format

Jira: https://jira01.devtools.intel.com/browse/OAM-52530
Tests: Test Passes
Signed-off-by: Poornima <poornima.y.n@intel.com>
6 years agoRevert "Add support to query tiling mode."
Kishore Kadiyala [Mon, 8 Jan 2018 08:06:09 +0000 (13:36 +0530)]
Revert "Add support to query tiling mode."

This reverts commit 311ab3c38550652b52c559722460c9bb6284d6fa.

Jira: None
Test: Video playback should be PASS
Signed-off-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
6 years agoRemove the reject checking for HAL_PIXEL_FORMAT_YCbCr_420_888
Lin Johnson [Thu, 14 Dec 2017 00:50:59 +0000 (08:50 +0800)]
Remove the reject checking for HAL_PIXEL_FORMAT_YCbCr_420_888

This format is used in VTS tests
VTS use it as default color format

Jira: https://jira01.devtools.intel.com/browse/OAM-49221
Test: None
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
6 years agoAdd support to query tiling mode.
xue.yifei [Wed, 15 Nov 2017 03:29:15 +0000 (11:29 +0800)]
Add support to query tiling mode.

Jira: None.
Test: Build should pass
Signed-off-by: xue.yifei <yifei.xue@intel.com>
6 years agoExtend the search scope of c header files
Chen Yu Y [Tue, 21 Nov 2017 08:13:48 +0000 (16:13 +0800)]
Extend the search scope of c header files

When VNDK enabled, system strict the header file search
scope, this patch extend the c includes search scope

Change-Id: I9f71870287f64e3a3d90a03eca9316041440663a
Jira: None.
Test: Build should pass
Signed-off-by: Chen Yu Y <yu.y.chen@intel.com>
6 years agoSuppress compile warnings unused-parameter and unused-value
renchenglei [Tue, 21 Nov 2017 08:34:48 +0000 (16:34 +0800)]
Suppress compile warnings unused-parameter and unused-value

Jira: None.
Test: Build passes on Android and no warnings reported.

Signed-off-by: renchenglei <chenglei.ren@intel.com>
6 years agoRevert "Remove unused formats."
Kalyan Kondapally [Mon, 20 Nov 2017 08:19:19 +0000 (00:19 -0800)]
Revert "Remove unused formats."

This reverts commit c9cbdb3f42f9d4cfdd9a529ecb9d556a09bbd51c.

6 years agoAdd DRM_FORMAT_RGB888 and BGR888.
Lin Johnson [Fri, 10 Nov 2017 07:19:41 +0000 (15:19 +0800)]
Add DRM_FORMAT_RGB888 and BGR888.

They are need by CTS test
android.hardware.cts.HardwareBufferTest.testCreate

Jira: https://jira01.devtools.intel.com/browse/OAM-51993
Tests: None
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
6 years agoRemove unused formats.
Kalyan Kondapally [Mon, 13 Nov 2017 01:26:24 +0000 (17:26 -0800)]
Remove unused formats.

Jira: None.
Tets: Build passes on Android.
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
6 years agoAdd API to set Modifier.
Kalyan Kondapally [Mon, 13 Nov 2017 01:20:41 +0000 (17:20 -0800)]
Add API to set Modifier.

This will be needed to pass prefered modifier from user space
and get rid of all custom enums we have. Also, would help enable
RBC support.

Jira: None.
Test: No regressions on Android.

6 years agoCorrect the header file reference
Mingwei Shi [Thu, 2 Nov 2017 05:59:23 +0000 (13:59 +0800)]
Correct the header file reference

1. Add errno.h
2. Ensure everything is exported to vendor/

Jira: None.
Test: Build passes on Android.
Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
6 years agoFix errors after rebase.
Lin Johnson [Wed, 1 Nov 2017 08:27:37 +0000 (16:27 +0800)]
Fix errors after rebase.

1) Bring sizes field back to gralloc_handle for binary consistancy.
2) Add missing P010 changes.
3) Change Android.mk to add libnativewindow.

Revert 1 once we have all dependent components re-compiled against
the new version.

Jira: None
Test: Video playback h2.64 and 10 bit HEVC
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
6 years agoSuppress compile warnings on Android
renchenglei [Mon, 30 Oct 2017 05:34:30 +0000 (13:34 +0800)]
Suppress compile warnings on Android

Jira: None.
Test: Build passes on Android and no warnings reported.

6 years agoAdd P010 support
Lin Johnson [Wed, 11 Oct 2017 08:55:00 +0000 (16:55 +0800)]
Add P010 support

P010 is 10bit 2 planes YUV420 format
which can be used by HEVC 10 bit

Change-Id: I0fc3c56e8a09fca0640c34699c3c149772c978a0
Jira: https://jira01.devtools.intel.com/browse/OAM-50293
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
6 years agoAdd BO_USAGE_RENDERING to YUYV/VYUY formats
Xiaosong Wei [Mon, 11 Sep 2017 16:44:01 +0000 (00:44 +0800)]
Add BO_USAGE_RENDERING to YUYV/VYUY formats

This is needed for overlay input with YUYV/VYUY formats.

Signed-off-by: Xiaosong Wei <xiaosong.wei@intel.com>
6 years agoAndroid-IA: Add support to easily add new formats.
Kalyan Kondapally [Wed, 30 Aug 2017 21:36:55 +0000 (14:36 -0700)]
Android-IA: Add support to easily add new formats.

Camera, Media use cases seem to need lot of custom
formats depending on hardware support. This patch
squashes earlies work done for NV12, NV12 tiled etc
into one and also makes it easy to isolate these
custom formats into i915_private_* files, rather
than spreading them over whole code base.

Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
Signed-off-by: Jeevaka Prabu Badrappan <jeevaka.badrappan@intel.com>
Signed-off-by: Yaodong Li <yaodong.li@intel.com>
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
Signed-off-by: Lin Johnson <lin.johnson@intel.com>
Signed-off-by: Yin Zhiye <zhiyex.yin@intel.com>
6 years agoAndroidIA: Add information required for media.
Harish Krupo [Thu, 7 Sep 2017 00:31:44 +0000 (17:31 -0700)]
AndroidIA: Add information required for media.

Change-Id: Ib818412df9a752835ba2bc91568fb602f33a2a75
Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
6 years agoAndroidIA: On Android M Surfaceflinger passes fb0 for name
Harish Krupo [Thu, 3 Aug 2017 18:05:50 +0000 (11:05 -0700)]
AndroidIA: On Android M Surfaceflinger passes fb0 for name

On Android M Surfaceflinger opens the gralloc module with
the name fb0

Change-Id: I1fe1dd24a64add8036675381bc6ee73ffe64f963
Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
6 years agoAndroidIA: Added support for Travis CI
nkumarch [Mon, 17 Jul 2017 08:54:24 +0000 (14:24 +0530)]
AndroidIA: Added support for Travis CI

Change-Id: I66944f82a884b52ab8a727c01379de7a5373eb26
Signed-off-by: nkumarch <naveen.kumar.chaudhary@intel.com>
6 years agoAndroidIA: Fix Include and pc exports.
Kalyan Kondapally [Mon, 26 Jun 2017 22:59:23 +0000 (18:59 -0400)]
AndroidIA: Fix Include and pc exports.

Change-Id: Ief1816cde950050cb605a2d6f7280ee64891b2d3
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
6 years agoAndroidIA: Replace pthread locks with spin lock.
Kalyan Kondapally [Sat, 17 Jun 2017 12:36:22 +0000 (05:36 -0700)]
AndroidIA: Replace pthread locks with spin lock.

Seems to make system more responsive and recover from
crashes.

Change-Id: Id4b2377fd506d0df62252033489342def6a43ced
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
6 years agoANDROIDIA: Add Gralloc1.0 support
Kalyan Kondapally [Mon, 5 Jun 2017 01:14:13 +0000 (18:14 -0700)]
ANDROIDIA: Add Gralloc1.0 support

This is disabled for now.

Jira: None.
Test: Build passes on Android.

Change-Id: Iad7d2960a78eb6f044d4ba1dee232df9dd951871
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
Signed-off-by: Munish Bhardwaj <munishx.bhardwaj@intel.com>
Signed-off-by: Harish Krupo <harish.krupo.kps@intel.com>
Signed-off-by: Jeevaka Prabu Badrappan <jeevaka.badrappan@intel.com>
6 years agoANDROIDIA: Misc build fixes
Kalyan Kondapally [Fri, 21 Apr 2017 14:31:22 +0000 (07:31 -0700)]
ANDROIDIA: Misc build fixes

Jira: None.
Test: Build passes on Android.

Change-Id: I275b9bdc46a30ebe5925b2146e2f85cd13b31421
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
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>
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>