OSDN Git Service

android-x86/external-minigbm.git
2 years agogralloc0_register_buffer: initialize gralloc0 when needed pie-x86_intel
Mauro Rossi [Sun, 10 May 2020 10:03:49 +0000 (12:03 +0200)]
gralloc0_register_buffer: initialize gralloc0 when needed

Based on Michael Goffioul "Always initialize gralloc0 module"
considerign that !mod->initialized defines the condition when it's needed.

Original commit message:
Both mapper and allocator HIDL adapter uses the same gralloc module, but
the mapper HILD does not fully initialize the module, leaving the
allocator HIDL in limbo if the mapper HIDL is called first.

Fixes SystemUI crash on startup.

3 years agouse BOARD_USES_MINIGBM_INTEL variable
Mauro Rossi [Sun, 9 Jun 2019 22:30:52 +0000 (00:30 +0200)]
use BOARD_USES_MINIGBM_INTEL variable

BOARD_USES_MINIGBM_INTEL is used instead of BOARD_USES_MINIGBM
This will allow to avoid enabling BOARD_USES_MINIGBM in BoardConfig.mk
in this way drm_hwcomposer and drmfb-composer will built for gbm_gralloc
and not use minigbm, which is not working as well as gbm_gralloc

3 years agoDO NOT MERGE: rename module to gralloc.intel
Mauro Rossi [Sun, 28 Apr 2019 19:56:06 +0000 (21:56 +0200)]
DO NOT MERGE: rename module to gralloc.intel

In order to build intel minigbm separately from chromeos minigbm (master branch)

3 years agoamdgpu: fix redefinition building errors
Mauro Rossi [Sun, 28 Apr 2019 19:56:06 +0000 (21:56 +0200)]
amdgpu: fix redefinition building errors

Fixes the following building errors:

In file included from external/minigbm/amdgpu.c:16:
In file included from external/minigbm/dri.h:13:
external/mesa/include/GL/internal/dri_interface.h:46:22:
error: redefinition of typedef 'drm_context_t' is a C11 feature [-Werror,-Wtypedef-redefinition]
typedef unsigned int drm_context_t;
                     ^
external/libdrm/include/drm/drm.h:77:22: note: previous definition is here
typedef unsigned int drm_context_t;
                     ^

3 years agogralloc0: include errno.h
Mauro Rossi [Sun, 28 Apr 2019 19:56:06 +0000 (21:56 +0200)]
gralloc0: include errno.h

Fixes the following building error:

external/minigbm_intel/cros_gralloc/gralloc0/gralloc0.cc:123:11:
error: use of undeclared identifier 'EINVAL'
                return -EINVAL;
                        ^

3 years agoMitigate GRALLOC1_PFN_LOCK_FLEX multithread issue.
Alexey Dulaev [Fri, 5 Oct 2018 08:26:39 +0000 (11:26 +0300)]
Mitigate GRALLOC1_PFN_LOCK_FLEX multithread issue.

lockFlex fills outFlexLayout->planes with pointer to global variable
ycbcrplanes, doesn't work from multiple threads.
Workaround: change the variable to thread_local.

Jira: OAM-70143, MDP-51191
Test: check memory regions mapped from different threads don't overlap

3 years agoYf tiled and Yf tiled CCS should be set Y Tile
Lin Johnson [Mon, 10 Dec 2018 03:04:28 +0000 (11:04 +0800)]
Yf tiled and Yf tiled CCS should be set Y Tile

Otherwise it will cause sramble sceen issues in Android

Jira: None
Tests: Android UI/Video playback
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
3 years agoFix the ACRN Invalid Reference error in buffer release.
HeYue [Tue, 6 Nov 2018 06:58:38 +0000 (14:58 +0800)]
Fix the ACRN Invalid Reference error in buffer release.

Use multi method to allocate the release buffer

Jira:  https://jira01.devtools.intel.com/browse/OAM-71272
Tests: Do not have invalid reference error and DUT without other issue.
Signed-off-by: HeYue <yue.he@intel.com>
3 years agoRevert "Fix GRALLOC1_PFN_LOCK_FLEX multithread issue."
Lin Johnson [Fri, 19 Oct 2018 02:04:45 +0000 (10:04 +0800)]
Revert "Fix GRALLOC1_PFN_LOCK_FLEX multithread issue."
for it is causing android.view.cts.SurfaceViewSyncTest
regressions

Jira: https://jira01.devtools.intel.com/browse/OAM-70143

This reverts commit c6971682cf6d8fed5f6d69b3c3c6c194ac7fdf69.

3 years agoDon't advertise BGR24 as a render/texture target
renchenglei [Tue, 16 Oct 2018 03:19:26 +0000 (11:19 +0800)]
Don't advertise BGR24 as a render/texture target

Mesa drivers can't use it, in general. This patch could
fix following CTS case:
SingleLayer_ColorTest_GpuColorOutputAndSampledImage_R8G8B8_UNORM
SingleLayer_ColorTest_GpuColorOutputCpuRead_R8G8B8_UNORM
SingleLayer_ColorTest_GpuColorOutputIsRenderable_R8G8B8_UNORM
SingleLayer_ColorTest_GpuSampledImageCanBeSampled_R8G8B8_UNORM

Tracked-On: https://jira01.devtools.intel.com/browse/OAM-70130

3 years agoRemove 32bit RGB format support
renchenglei [Tue, 16 Oct 2018 02:32:51 +0000 (10:32 +0800)]
Remove 32bit RGB format support

HAL_PIXEL_FORMAT_RGBA_1010102 is added to fix CTS issue
android.hardware.cts.HardwareBufferTest#testCreate. In fact,
GL extensions should not be uesd to query for wide-gamut
support. As google has removed RGBA 10:10:10:2 format check
and HAL_PIXEL_FORMAT_RGBA_1010102 patch also cause other CTS
regression, let's remove it here.

Following case could pass with this patch
SingleLayer_ColorTest_GpuSampledImageCanBeSampled_R10G10B10A2_UNORM

CTS test case remove RGBA 10:10:10:2 format check
https://android-review.googlesource.com/c/platform/cts/+/733623

Tracked-On: https://jira01.devtools.intel.com/browse/OAM-70128

3 years agoFix GRALLOC1_PFN_LOCK_FLEX multithread issue.
Alexey Dulaev [Fri, 5 Oct 2018 08:26:39 +0000 (11:26 +0300)]
Fix GRALLOC1_PFN_LOCK_FLEX multithread issue.

lockFlex fills outFlexLayout->planes with pointer to global variable,
doesn't work from multiple threads.
Solution: rely that caller allocates needed planes structures,
just use them for output.

gralloc1.h about GRALLOC1_PFN_GET_NUM_FLEX_PLANES:
This may be used to efficiently allocate only as many plane structures as necessary before calling into lockFlex.
It means that lockFlex caller is responsible for outFlexLayout->planes allocation.

It also demand fix in GRALLOC1_PFN_GET_NUM_FLEX_PLANES:
should return 3 for HAL_PIXEL_FORMAT_NV12_TILED_INTEL.

Jira: None
Test: check memory regions mapped from different threads don't overlap

3 years agoRevert "Added Support for 64bit RGB format"
renchenglei [Thu, 11 Oct 2018 06:22:37 +0000 (14:22 +0800)]
Revert "Added Support for 64bit RGB format"
This reverts commit 47bd806579dd
The Android framework uses successful allocation of
HAL_PIXEL_FORMAT_RGBA_FP16 to test for wide-gamut capabilities.
We don't want to advertise this, so let's revert.

This revert won't cause regression on CTS test case
android.hardware.cts.HardwareBufferTest#testCreate

android.graphics.cts.BitmapColorSpaceTest#test16bitHardware
can pass if the framework falls back to RGBA8888, as is the plan.

Jira: https://jira01.devtools.intel.com/browse/OAM-68897
Tests: test16bitHardware and testCreate both pass

3 years agoRevert "Use drm gem acess userdata IOCTL for set/get interlace"
Lin Johnson [Fri, 14 Sep 2018 06:38:35 +0000 (14:38 +0800)]
Revert "Use drm gem acess userdata IOCTL for set/get interlace"

This reverts commit b3f47fbc17eb33a85ce6f0796dfa3a6d0df13cfe.

3 years agoUse drm gem acess userdata IOCTL for set/get interlace
Lin Johnson [Tue, 4 Sep 2018 14:20:18 +0000 (22:20 +0800)]
Use drm gem acess userdata IOCTL for set/get interlace
and it is potential beneficial for other IPC

Jira: None
Tests:Interlaced video playback
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
3 years agoGralloc: Add setInterlace and setProtectionInfo function
Lin Johnson [Fri, 27 Jul 2018 03:13:35 +0000 (11:13 +0800)]
Gralloc: Add setInterlace and setProtectionInfo function
SetInterface is used by MSDK for the interalce info of the buffer
SetProtectionInfo is used by MSDK for protection info for the buffer
union type added for protection info

Jira: None
Test: Compile pass on Android

3 years agoAdd support of Yf tile
Lin Johnson [Fri, 20 Jul 2018 06:14:21 +0000 (14:14 +0800)]
Add support of Yf tile

Yf Tile is not required to set Y tile
but it has its dimension alignment requirements

Jira: None
Test: Yf tile can be allocate and fb generated

4 years agoMerge pull request #60 from jennycao/jennycao/update-for-compile-warning
JSLin [Mon, 11 Jun 2018 01:38:59 +0000 (09:38 +0800)]
Merge pull request #60 from jennycao/jennycao/update-for-compile-warning

update for avoid compile warning

4 years agoDrop unused variable
Kevin Strasser [Thu, 17 May 2018 23:37:08 +0000 (16:37 -0700)]
Drop unused variable

outReleaseFence is never used, just drop it.

Jira: GSE-1597
Test: Build and boot on Android

Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
4 years agoClose fd if we aren't going to use it
Kevin Strasser [Thu, 17 May 2018 20:45:03 +0000 (13:45 -0700)]
Close fd if we aren't going to use it

File descriptors are left open and forgotten.
Make sure to clean up fds after use.

Jira: GSE-1595
Test: Build and boot on Android

Signed-off-by: Kevin Strasser <kevin.strasser@intel.com>
4 years agoAdd getPrime API to support media
Badiuzzaman Iskhandar [Mon, 14 May 2018 02:42:01 +0000 (10:42 +0800)]
Add getPrime API to support media

Jira: https://jira01.devtools.intel.com/browse/OAM-62657
Tests: None
Signed-off-by: Khairul Anuar Romli <khairul.anuar.romli@intel.com>
4 years agoFix build.
Mingwei Wang [Fri, 18 May 2018 01:42:08 +0000 (18:42 -0700)]
Fix build.

This is caused by strick checking of compiler.

Jira: None.
Test: Build passes on Android.

Signed-off-by: Mingwei Wang <mingwei.wang@intel.com>
Signed-off-by: Randy Xu <randy.xu@intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
Signed-off-by: Chen, Yu <yu.y.chen@intel.com>
4 years agoAdd fourcc defines.
Kalyan Kondapally [Thu, 17 May 2018 07:06:06 +0000 (00:06 -0700)]
Add fourcc defines.

This removes need to carry extra patches in libdrm side.

Jira: None.
Test: Build passes on Android and Linux.

Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
4 years agoupdate for avoid compile warning
jenny.q.cao [Tue, 3 Apr 2018 07:37:03 +0000 (15:37 +0800)]
update for avoid compile warning

update for avoid compile warning "Deprecated: don't include cutils/log.h, use either android/log.h or log/log.h" [-W#warnings]

Jira: https://jira01.devtools.intel.com/browse/GSE-1141
Tests:compile on Android IVI
Signed-off-by: Cao Jenny <jenny.q.cao@intel.com>
4 years agoAdd RGB565 with Camera Usage
Lin Johnson [Wed, 28 Mar 2018 01:28:07 +0000 (09:28 +0800)]
Add RGB565 with Camera Usage

New Android Cammera API require it

Jira: https://jira01.devtools.intel.com/browse/OAM-52077
Tests: None
Signed-off-by: Lin Johnson <johnson.lin@intel.com>
4 years agoAdd getByteStride to support Media
Kishore Kadiyala [Tue, 9 Jan 2018 09:01:39 +0000 (14:31 +0530)]
Add getByteStride to support Media

Jira: https://jira01.devtools.intel.com/browse/OAM-58889
Signed-off-by: Kishore Kadiyala <kishore.kadiyala@intel.com>
4 years agoAdd Support for 32bit RGB format
pyn1 [Wed, 28 Feb 2018 09:06:41 +0000 (14:36 +0530)]
Add Support for 32bit RGB format

i.e. To add support for HAL_PIXEL_FORMAT_RGBA_1010102

Jira: https://jira01.devtools.intel.com/browse/OAM-58928
Tests: Test Passes for the intended format
Signed-off-by: Poornima <poornima.y.n@intel.com>
4 years agoRevert "Revert "Add support to query tiling mode.""
Kalyan Kondapally [Thu, 1 Feb 2018 08:56:05 +0000 (00:56 -0800)]
Revert "Revert "Add support to query tiling mode.""

This reverts commit 7b767e105fa63154c19cb92f16f3b447ebb485ee.

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

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

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

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

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