OSDN Git Service

android-x86/external-gbm_gralloc.git
5 years agoOpen the DRM device of the primary framebuffer (fb0) android-x86-7.1-r4 android-x86-8.1-r1 android-x86-8.1-r2 android-x86-8.1-r3 android-x86-8.1-r4 android-x86-8.1-r5 android-x86-9.0-r1 android-x86-9.0-r2
Chih-Wei Huang [Mon, 14 Jan 2019 05:16:42 +0000 (13:16 +0800)]
Open the DRM device of the primary framebuffer (fb0)

With the new added drmOpenByFB function in libdrm, it's easy to find
the correct DRM device of the primary framebuffer.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
5 years agoLet gbm_free() return a value
Chih-Wei Huang [Mon, 14 Jan 2019 05:13:50 +0000 (13:13 +0800)]
Let gbm_free() return a value

So that gralloc_gbm_handle_unregister() could return correct value
required by gralloctest.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
5 years agoMerge branch 'fb' of https://github.com/lambdadroid/gbm_gralloc into oreo-x86
Chih-Wei Huang [Sun, 6 Jan 2019 06:37:19 +0000 (14:37 +0800)]
Merge branch 'fb' of https://github.com/lambdadroid/gbm_gralloc into oreo-x86

5 years agoandroid: add gralloctest
Mauro Rossi [Tue, 18 Dec 2018 06:55:12 +0000 (07:55 +0100)]
android: add gralloctest

gralloctest executable is added for Android based on minigbm/cros_gralloc commits:

b57dffc ("minigbm: move gralloctest to this repo")
2eeaf5a ("minigbm: cros_gralloc: fix -Wimplicit-function-declaration warnings in gralloctest")

Signed-off-by: Mauro Rossi <issor.oruam@gmail.com>
5 years agoMerge remote-tracking branch 'origin/master' into oreo-x86
Chih-Wei Huang [Fri, 2 Nov 2018 07:56:54 +0000 (15:56 +0800)]
Merge remote-tracking branch 'origin/master' into oreo-x86

Conflicts:
gralloc_drm_handle.h

5 years agoAdd simple framebuffer HAL implementation using drm_framebuffer
lambdadroid [Wed, 31 Oct 2018 15:46:27 +0000 (16:46 +0100)]
Add simple framebuffer HAL implementation using drm_framebuffer

5 years agoUpdate usage flag handling for hwc
Mauro Rossi [Fri, 29 Jun 2018 11:45:10 +0000 (13:45 +0200)]
Update usage flag handling for hwc

Add support for GRALLOC_USAGE_HW_COMPOSER usage flag
mapping it to GBM flags, inspired by minigbm implementation.

Fixes the artifacts issues with vulkan hal radv with the following apps
with benefit to all apps using HWC layers:
V1 - GPU Benchmark Pro (Vulkan API)
PPSSPP - PSP emulator
Sascha Willems Vulkan Examples (e.g. Vulkan Gears, Vulkan Texture)

Signed-off-by: Mauro Rossi <issor.oruam@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
5 years agoSwitch to use gralloc handle defined in libdrm
Rob Herring [Thu, 15 Feb 2018 21:59:41 +0000 (15:59 -0600)]
Switch to use gralloc handle defined in libdrm

Remove our custom handle definition and use the one defined in libdrm.

Signed-off-by: Rob Herring <robh@kernel.org>
5 years agoUse a std::unordered_map to lookup BOs from handles
Rob Herring [Thu, 15 Feb 2018 22:15:57 +0000 (16:15 -0600)]
Use a std::unordered_map to lookup BOs from handles

Remove the fragile dependency on the handle 'data' pointer and
'data_owner' flag.

This idea is stolen from the CrOS minigbm gralloc implementation.

Signed-off-by: Rob Herring <robh@kernel.org>
5 years agoRemove GRALLOC_MODULE_PERFORM_GET_USAGE
Rob Herring [Fri, 16 Feb 2018 14:07:42 +0000 (08:07 -0600)]
Remove GRALLOC_MODULE_PERFORM_GET_USAGE

This is no longer used by drm_hwc and can be removed.

Signed-off-by: Rob Herring <robh@kernel.org>
5 years agoMove gralloc_gbm_handle_t accesses into gralloc_gbm.cpp
Rob Herring [Fri, 16 Feb 2018 16:23:26 +0000 (10:23 -0600)]
Move gralloc_gbm_handle_t accesses into gralloc_gbm.cpp

The only access to the gralloc_gbm_handle_t in gralloc.cpp is to set the
stride of allocated buffers. Move this into gralloc_gbm.cpp to isolate
accesses to the struct in one place.

Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoMerge remote-tracking branch 'origin/master' into nougat-x86 android-x86-7.1-r2 android-x86-7.1-r3
Chih-Wei Huang [Mon, 2 Apr 2018 09:21:23 +0000 (17:21 +0800)]
Merge remote-tracking branch 'origin/master' into nougat-x86

Conflicts:
gralloc_drm_handle.h

6 years agoExplicitly include string.h
Rob Herring [Wed, 24 Jan 2018 14:21:50 +0000 (08:21 -0600)]
Explicitly include string.h

The master build started failing on strcmp and memset being undeclared, so
explicitly include string.h.

Change-Id: I55d042b34e55375ed50f9300ab0c3abdfa0f2631
Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoFix unused parameter 'handle' warning
Rob Herring [Wed, 29 Nov 2017 16:29:38 +0000 (10:29 -0600)]
Fix unused parameter 'handle' warning

AOSP now builds with -Werror. Fix this warning:

gralloc_drm_handle.h:90:62: error: unused parameter 'handle' [-Werror,-Wunused-parameter]

Change-Id: Ief13c01f0ca1ede2b9ef5662acbdc6d0f27f6cd4
Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoUse native_handle functions
Rob Herring [Wed, 25 Oct 2017 18:41:54 +0000 (13:41 -0500)]
Use native_handle functions

Use native_handle_{create,delete} functions instead of the C++
alloc/free. This will do the initialization for us instead of open
coding it.

Change-Id: I285292770ca756c1d2c2effa5c73e252526bae0c
Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoMerge remote-tracking branch 'origin/master' into nougat-x86 android-x86-7.1-r1
Chih-Wei Huang [Thu, 5 Oct 2017 06:57:42 +0000 (14:57 +0800)]
Merge remote-tracking branch 'origin/master' into nougat-x86

6 years agoRemove old libraries in /system
Chih-Wei Huang [Thu, 5 Oct 2017 06:54:56 +0000 (14:54 +0800)]
Remove old libraries in /system

Since commit 94559640 the libraries are moved to /vendor. But
the old libraries are not removed in an incremental build.
Therefore the new libraries may not be used.

Fixes: 94559640 ("Android: move libraries to /vendor")

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
6 years agoFix 32-bit app crashing in 64-bit Android
Chih-Wei Huang [Wed, 4 Oct 2017 07:31:02 +0000 (15:31 +0800)]
Fix 32-bit app crashing in 64-bit Android

Seemingly the 64-bit int is always aligned to 8 in LP64.
But this is not hold in LP32.

Consequently sizeof(gralloc_drm_handle_t) are different
between LP64 (which is 18 ints) and LP32 (which is 16 ints).
As a result, 32-bit apps will crash in 64-bit OS since the
checking handle->base.numInts != GRALLOC_GBM_HANDLE_NUM_INTS
is true.

Fix it by always aligning 64-bit int to 8. Besides, to avoid
additional padding, just exchange the order of data_owner
and modifier. It aligns modifier to 8 natually.
This makes gralloc_drm_handle_t fit in 16 ints perfectly.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
6 years agoAndroid: move libraries to /vendor
Rob Herring [Fri, 15 Sep 2017 13:51:29 +0000 (08:51 -0500)]
Android: move libraries to /vendor

As part of Treble project in Android O, all the device specific files have
to be located in a separate vendor partition. This is done by setting
LOCAL_PROPRIETARY_MODULE (the name is misleading). This change will not
break existing platforms without a vendor partition as it will just move
files to /system/vendor.

Change-Id: I0e863d55406b3e2457bbaded818e7fd4f19f064a
Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoConvert gralloc_gbm_bo_t to gbm user data
Rob Herring [Wed, 30 Aug 2017 13:41:45 +0000 (08:41 -0500)]
Convert gralloc_gbm_bo_t to gbm user data

Instead of wrapping struct gbm_bo with our own BO struct, make the
struct GBM BO userdata instead. This makes things clearer as to what a
BO is.

Signed-off-by: Rob Herring <robh@kernel.org>
6 years agokill off gralloc_gbm_get_pid
Rob Herring [Wed, 30 Aug 2017 00:23:35 +0000 (19:23 -0500)]
kill off gralloc_gbm_get_pid

Caching getpid() calls seems pointless, so remove the added
complexity and just use getpid() directly when needed.

Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoRework handle register/unregister calls
Rob Herring [Wed, 30 Aug 2017 00:14:21 +0000 (19:14 -0500)]
Rework handle register/unregister calls

What validate_handle() did was ambiguous and broken for binderized
gralloc. Reusing the existing BO pointer for gralloc_gbm_handle_register
is broken because the BO may get freed. It is necessary to always import
the buffer. So split validate handle into separate functions to retrieve
the BO ptr and import the buffer.

Change-Id: I4ea18aa0ded2d201c8f71f4e33a8fc893240d109
Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoremove handle from BO
Rob Herring [Tue, 29 Aug 2017 23:00:50 +0000 (18:00 -0500)]
remove handle from BO

Pass the handle to internal functions instead of the BO pointer, then we
can always get the BO from the handle and never need to get the handle
from the BO.

Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoRework unregister/free code
Rob Herring [Tue, 29 Aug 2017 23:43:12 +0000 (18:43 -0500)]
Rework unregister/free code

It is not necessary to track imported buffers nor ref count them and
doing so is broken when native handles are cloned. So remove all the
related code and separate the unregister and free code paths.

Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoDon't close fds on imported buffers
Rob Herring [Thu, 24 Aug 2017 14:38:25 +0000 (09:38 -0500)]
Don't close fds on imported buffers

The fds should only be closed if we allocated the handle.

Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoRevert "Add libgralloc_drm library to export headers to mesa"
Chih-Wei Huang [Tue, 18 Jul 2017 06:41:38 +0000 (14:41 +0800)]
Revert "Add libgralloc_drm library to export headers to mesa"

This reverts commit 77f32995cb6e0193878b4b4147201b701076cee8.

6 years agogbm_import: fix missing gbm_import_fd_modifier_data initialization
Rob Herring [Tue, 11 Jul 2017 23:13:57 +0000 (18:13 -0500)]
gbm_import: fix missing gbm_import_fd_modifier_data initialization

With gbm_import_fd_modifier_data, some fields are not getting
initialized and in particular offset[0] is not which causes import
failures. Add memset to ensure all fields are initialized.

Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Aleksander Morgado <aleksander@aleksander.es>
Signed-off-by: Rob Herring <robh@kernel.org>
6 years agoSync with the gbm API to import FD with modifier
Aleksander Morgado [Tue, 4 Jul 2017 21:08:27 +0000 (23:08 +0200)]
Sync with the gbm API to import FD with modifier

Commit 4026744fcb31f1d27c1b32e6945aadd4da415c6d in mesa introduced an
updated `struct gbm_import_fd_modifier_data' with arrays for fds,
strides and offsets, instead of single values.

Fix just by specifying one single item in the arrays.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
6 years agoAdd support for modifiers
Robert Foss [Thu, 1 Jun 2017 00:39:58 +0000 (20:39 -0400)]
Add support for modifiers

Modifiers are used to describe buffer metadata like if and how they are
compressed or if tiling is used.

This is needed to allow different devices to communicate about buffers
that have these properties.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
6 years agoAdd description of GRALLOC_MODULE_PERFORM_GET_DRM_FD
Robert Foss [Tue, 16 May 2017 16:27:58 +0000 (12:27 -0400)]
Add description of GRALLOC_MODULE_PERFORM_GET_DRM_FD

Add description of the perform call GRALLOC_MODULE_PERFORM_GET_DRM_FD.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
6 years agoChange #include guard to reflect filename
Robert Foss [Thu, 11 May 2017 21:32:56 +0000 (17:32 -0400)]
Change #include guard to reflect filename

Signed-off-by: Robert Foss <robert.foss@collabora.com>
6 years agoAdd libgralloc_drm library to export headers to mesa
Rob Herring [Thu, 8 Jun 2017 20:45:53 +0000 (15:45 -0500)]
Add libgralloc_drm library to export headers to mesa

Mesa mainline depends on libgralloc_drm shared library for importing
include paths. Add a dummy library for this purpose. This gets mesa master
building without any additional patches. Patches are still needed for
proper functioning.

Change-Id: Ib9577d0b7af028091f0c6f61d8dd2340cc8425d0
Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoFix missing 0 init of alloc_device_t
Rob Herring [Thu, 13 Apr 2017 18:54:36 +0000 (13:54 -0500)]
Fix missing 0 init of alloc_device_t

This fixes a crash of "dumpsys SurfaceFlinger" because the dump() pointer
is not NULL.

Change-Id: If4c1f71fd532e21bb246c1b815b8b9ca00bb405b
Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoQuiet log prints changing them to verbose level
Rob Herring [Thu, 13 Apr 2017 18:53:26 +0000 (13:53 -0500)]
Quiet log prints changing them to verbose level

Quiet down various informational tracing messages switching them to
verbose log level

Change-Id: I0a78a9bcb1f807dc2db060ab1551cd5f62fa3f2d
Signed-off-by: Rob Herring <robh@kernel.org>
7 years agogbm_gralloc: Remove the invalid int cast and assignment in gbm_mod_perform()
John Stultz [Wed, 29 Mar 2017 03:48:36 +0000 (20:48 -0700)]
gbm_gralloc: Remove the invalid int cast and assignment in gbm_mod_perform()

In gbm_mod_perform(), for the cmd GRALLOC_MODULE_PERFORM_GET_USAGE,
the code takes the third argument, casts it as an int* and then writes
a zero into what the pointer points to.

The problem with this is that the third argument to that function is
actually a native_handle_t, so writing zero to the first int in that
structure ends up overwriting the version value, causing the
native_handle_t code to see the value as corrupt.

This results in lots of warnings and leaked fds.

Change-Id: If64770c164557b467f76ca97ddc182565730d394
Cc: Rob Herring <rob.herring@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Vishal Bhoj <vishal.bhoj@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoChange module name to gralloc.gbm
Rob Herring [Wed, 22 Mar 2017 16:45:29 +0000 (11:45 -0500)]
Change module name to gralloc.gbm

Originally, the intent was to make GBM gralloc a drop-in replacement for
DRM gralloc, but this isn't really happening or needed. Change the name
so both can coexist.

Change-Id: I4eff839523213cc76c56746275d8ba7534ba9c12
Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoFix mapping for non-zero starting coordinates
Rob Herring [Tue, 13 Dec 2016 15:37:06 +0000 (09:37 -0600)]
Fix mapping for non-zero starting coordinates

While the gralloc API allows for specifying the starting coordinates (L,T),
it seems this doesn't really work. No other gralloc implementations found
use the rectangle bounds. Not exactly sure how this ever worked, but it
broke recently with AOSP master.

Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoAdd YV12 pixel format support
Rob Herring [Thu, 8 Sep 2016 22:45:03 +0000 (17:45 -0500)]
Add YV12 pixel format support

GBM doesn't support YV12 and we need a single buffer, so request GR88 from
GBM instead and adjust the width and height. GR88 also ensures (hopefully)
that the GPU texture alignment requirements are met.

Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoRemove unused gralloc_drm_handle_t::name
Rob Herring [Tue, 19 Jul 2016 03:06:03 +0000 (22:06 -0500)]
Remove unused gralloc_drm_handle_t::name

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
[robh: keep the name member for now for ABI/API compatibility with mesa]
Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoUse alternative GRALLOC_GBM_HANDLE_MAGIC
Emil Velikov [Mon, 18 Jul 2016 15:10:26 +0000 (16:10 +0100)]
Use alternative GRALLOC_GBM_HANDLE_MAGIC

Using 0x5f47424d ("_GBM") is less likely to colide than the generic
0x12345678.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
7 years agoOpen the device node with O_CLOEXEC
Emil Velikov [Mon, 18 Jul 2016 15:51:12 +0000 (16:51 +0100)]
Open the device node with O_CLOEXEC

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
---
Not 100% sure it is supported on Android.

7 years agoDon't leak the FD in the gbm_dev_create error path
Emil Velikov [Mon, 18 Jul 2016 15:47:54 +0000 (16:47 +0100)]
Don't leak the FD in the gbm_dev_create error path

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
7 years agoKill off unused variable
Emil Velikov [Mon, 18 Jul 2016 15:46:51 +0000 (16:46 +0100)]
Kill off unused variable

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
7 years agoMerge pull request #2 from robertfoss/master
Rob Herring [Tue, 25 Oct 2016 21:52:01 +0000 (16:52 -0500)]
Merge pull request #2 from robertfoss/master

GRALLOC_MODULE_PERFORM_GET_USAGE stub and compiler warning fix

7 years agoStub out GRALLOC_MODULE_PERFORM_GET_USAGE
Robert Foss [Fri, 16 Sep 2016 21:21:11 +0000 (17:21 -0400)]
Stub out GRALLOC_MODULE_PERFORM_GET_USAGE

This implements an initial stub for GRALLOC_MODULE_PERFORM_GET_USAGE

Signed-off-by: Robert Foss <robert.foss@collabora.com>
7 years agoSilence compiler type narrowing errors
Robert Foss [Fri, 16 Sep 2016 22:28:26 +0000 (18:28 -0400)]
Silence compiler type narrowing errors

Add static_cast to op, to prevent compiler warnings.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
7 years agoFix RGB565 pixel format type
Rob Herring [Wed, 1 Jun 2016 21:30:34 +0000 (16:30 -0500)]
Fix RGB565 pixel format type

The component ordering was wrong causing GBM allocation failures.

Signed-off-by: Rob Herring <robh@kernel.org>
8 years agoClean-up of unused code
Rob Herring [Fri, 22 Apr 2016 17:54:14 +0000 (12:54 -0500)]
Clean-up of unused code

Remove some unused code throwing warnings.

Signed-off-by: Rob Herring <robh@kernel.org>
8 years agogbm_map: update to revised gbm_bo_map API
Rob Herring [Fri, 22 Apr 2016 17:52:45 +0000 (12:52 -0500)]
gbm_map: update to revised gbm_bo_map API

Add stride return parameter and properly pass usage flags.

Signed-off-by: Rob Herring <robh@kernel.org>
8 years agoUpdate usage flag handling
Rob Herring [Fri, 22 Apr 2016 17:50:35 +0000 (12:50 -0500)]
Update usage flag handling

Add missing support for GRALLOC_USAGE_SW_READ_OFTEN,
GRALLOC_USAGE_SW_WRITE_OFTEN, GRALLOC_USAGE_HW_TEXTURE, and
GRALLOC_USAGE_CURSOR usage flags mapping them to GBM flags.

For now, cursor flag is commented out because the Android side doesn't seem
to honor a larger stride.

Signed-off-by: Rob Herring <robh@kernel.org>
8 years agoInitial GBM based gralloc
Rob Herring [Sun, 12 Jun 2011 08:21:30 +0000 (16:21 +0800)]
Initial GBM based gralloc

Based on drm_gralloc. Some remants of drm_gralloc remain to be
compatible with mesa and drm_hwcomposer.

Signed-off-by: Rob Herring <robh@kernel.org>