OSDN Git Service
Roman Stratiienko [Sat, 20 Feb 2021 11:59:55 +0000 (13:59 +0200)]
drm_hwcomposer: Rework autofd
Motivation:
Current implementation of UniqueFd can be used in a different ways,
making analytical tracking of FD lifecycle much harder than it may be.
Keep this part clean is very important, since any wrong code may open
a hard-to-detect runtime bugs and fd leaks, which may accidentally slip
into the production.
Implementation:
1. Combine UniqueFd anf OutputFd into single class.
2. Reduce the API to be minimal and sufficient.
3. Document the API and use cases.
4. Move to utils/UniqueFd.h.
5. dup(fd) was replaced with fcntl(fd, F_DUPFD_CLOEXEC)) to
address clang-tidy findings. Find more information at [1]
[1]: https://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-dup.html
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Wed, 10 Feb 2021 12:59:52 +0000 (14:59 +0200)]
drm_hwcomposer: cleanup hwcutils
Remove DrmHwcBuffer class. Wrap remaining logic into
DrmHwcLayer class.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Wed, 10 Feb 2021 10:11:16 +0000 (12:11 +0200)]
drm_hwcomposer: Stop importing native_handle_t into the mapper
Composer service is already importing buffers from binder pipe
into the mapper and caches them making native handles valid
for a whole composition processing cycle.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Tue, 9 Feb 2021 15:49:55 +0000 (17:49 +0200)]
drm_hwcomposer: Tracking of the DRM FB objects using RAII
DRM framebuffer objects must be kept registered in DRM/KMS
while used for scanning-out (After atomic commit applied
for processing by display controller and until next atomic
commit is applied for processing).
Existing logic for tracking current state is overcomplicated and
needs to be redesigned. Also further developing of drm_hwc will
require migration to asynchronous atomic commit, so additional
asynchronous FB cleanup logic must be created.
Buffer caching logic will also benefit from this.
With the RAII all further changes will be less painful and more robust.
By this commit I also renamed DrmGenericImporter to DrmFbImporter:
'Fb' word is present in most of existing composers (android and linux)
so it will be easier to compare different implementations.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Benjamin Li [Sun, 9 May 2021 16:01:38 +0000 (09:01 -0700)]
drm_hwcomposer: update README for clang-format-diff-11 and touch up formatting
The README.md is out of date -- clang-format-diff-5.0 is not what runs on
CI anymore. To help contributors better test their changes locally before
submitting a merge request, update to the actual linting command being run
in CI.
Signed-off-by: Benjamin Li <benl@squareup.com>
Benjamin Li [Sun, 9 May 2021 15:52:35 +0000 (08:52 -0700)]
drm_hwcomposer: remove unused variable blend
The first tuple element returned by GetEnumValueWithName is just the index
of that enum, which is not useful.
Signed-off-by: Benjamin Li <benl@squareup.com>
Benjamin Li [Sun, 9 May 2021 15:52:18 +0000 (08:52 -0700)]
drm_hwcomposer: reject rotations reported as unsupported by hardware
Currently we only check for the presence of any rotation support -- but
hardware may choose to, say, only support 180 degree rotation. Respect
the specific rotation capabilities reported through DRM properties.
Signed-off-by: Benjamin Li <benl@squareup.com>
Benjamin Li [Wed, 5 May 2021 16:23:15 +0000 (09:23 -0700)]
drm_hwcomposer: add DRM_PROPERTY_TYPE_BITMASK
Bitmask properties are integers that additionally have strings associated
with each bit. For example, the "rotation" property's bits are described
as "rotate-90", "reflect-x", and so on.
The bitmask integer is not actually passed to us -- instead, the interface
for enums is used, except that more than one value can be set. This means we
must query using the associated strings, rather than use bit index mappings
provided as constants in the public kernel header drm_mode.h.
Signed-off-by: Benjamin Li <benl@squareup.com>
Matvii Zorin [Mon, 26 Apr 2021 14:24:56 +0000 (17:24 +0300)]
drm_hwcomposer: Fix regression after composition creation cleanup
During rebasing of the local integration branch, one code chunk was not
updated accidentally and the client range was not selected properly which
leads to jank frames appearance.
The issue has been already fixed by the commit
3f89182bb9df
("drm_hwcomposer: Fix client range selection logic").
Issue: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/53
Fixes:
b3b15166f9da ("drm_hwcomposer: Add GetExtraClientRange method")
Suggested-by: Roman Stratiienko <r.stratiienko@gmail.com>
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Sun, 31 Jan 2021 12:45:05 +0000 (14:45 +0200)]
drm_hwcomposer: Move ValidatePlane method into DrmPlane
It is more common to validate the layer for the proper object.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Roman Kovalivskyi [Sun, 24 Jan 2021 18:32:37 +0000 (20:32 +0200)]
drm_hwcomposer: Remove useless setters from DrmHwcLayer
SetDisplayFrame and SetSourceCrop methods are unnecessary in
the DrmHwcLayer structure without any private members.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Fri, 29 Jan 2021 16:32:06 +0000 (18:32 +0200)]
drm_hwcomposer: Add GetOrderLayersByZPos method
The GetOrderLayersByZPos copies an ordered list of layer pointers.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Fri, 29 Jan 2021 14:45:25 +0000 (16:45 +0200)]
drm_hwcomposer: Move HardwareSupportsLayerType into Backend
The HardwareSupportsLayerType function is used only for display validation
which is implemented in the generic backend.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Fri, 29 Jan 2021 14:40:25 +0000 (16:40 +0200)]
drm_hwcomposer: Move MarkValidated into Backend
The MarkValidated function is used only for display validation which is
implemented in the generic backend.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Fri, 29 Jan 2021 13:48:20 +0000 (15:48 +0200)]
drm_hwcomposer: Add GetExtraClientRange method
Separate the correction of client range into the separate method.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Fri, 29 Jan 2021 13:39:55 +0000 (15:39 +0200)]
drm_hwcomposer: Move CalcPixOps into Backend
The CalcPixOps is used only for display validation which is implemented
in the generic backend.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Mon, 18 Jan 2021 13:54:22 +0000 (15:54 +0200)]
drm_hwcomposer: Remove ctrc from DrmCompositionPlane
CRTC is set at CreateComposition function and it matches the current
display.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Tue, 12 Jan 2021 09:06:56 +0000 (11:06 +0200)]
drm_hwcomposer: Remove SquashState class declaration
There is no use of SquashState class, so the declaration could be removed
in the scope of cleanup.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Tue, 12 Jan 2021 08:53:08 +0000 (10:53 +0200)]
drm_hwcomposer: Remove DrmCompositionDisplayLayersMap
The structure is used only at the CreateComposition function.
Data consolidation is unnecessary in this case.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Tue, 12 Jan 2021 08:40:44 +0000 (10:40 +0200)]
drm_hwcomposer: Remove DrmCompositionRegion struct
The structure is currently unused.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Fri, 8 Jan 2021 10:55:45 +0000 (12:55 +0200)]
drm_hwcomposer: Cleanup DrmDisplayComposition initialization
Remove unused members (drm, importer, frame_no). Move initialization
from the proper function to the constructor.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Roman Stratiienko [Tue, 9 Mar 2021 19:56:50 +0000 (21:56 +0200)]
drm_hwcomposer: CI: Increase coverage
Add the following files to the build:
backend/BackendClient.cpp
backend/Backend.cpp
backend/BackendManager.cpp
backend/BackendRCarDu.cpp
bufferinfo/legacy/BufferInfoImagination.cpp
bufferinfo/legacy/BufferInfoLibdrm.cpp
bufferinfo/legacy/BufferInfoMaliHisi.cpp
bufferinfo/legacy/BufferInfoMaliMediatek.cpp
bufferinfo/legacy/BufferInfoMaliMeson.cpp
bufferinfo/legacy/BufferInfoMinigbm.cpp
compositor/DrmDisplayComposition.cpp
compositor/DrmDisplayCompositor.cpp
compositor/Planner.cpp
drm/DrmGenericImporter.cpp
DrmHwcTwo.cpp
drm/ResourceManager.cpp
drm/VSyncWorker.cpp
tests/worker_test.cpp
utils/autolock.cpp
Files 'bufferinfo/BufferInfoMapperMetadata.cpp' and 'utils/hwcutils.cpp' require
a lot of additional headers, therefore move them out of the scope of this commit.
'utils/gralloc.h' isn't planned to use in pure-linux builds, therefore remove
it from 'utils' and put it into '.ci/android_headers/hardware/'
Fix minor tidy fails.
Fix linux build fails (missing includes) due to differences between libc and
bionic.
Comment-out some sections in 'tests/test_include' which aren't used by drm_hwc
but causing build failures for CI due to missing dependencies.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Matvii Zorin <matvii.zorin@globallogic.com>
Roman Stratiienko [Fri, 2 Apr 2021 14:19:54 +0000 (17:19 +0300)]
drm_hwcomposer: CI: Pull headers from the AOSPv11
The goal is to check compilation and clang-tidy at CI stage.
For both compile and tidy all dependent headers are required.
Compilation and tidy-check enabled by the next commit.
Done by invoking the following bash commands:
cp system/core/libcutils/include/cutils/native_handle.h \
system/core/libcutils/include/cutils/compiler.h \
system/core/libcutils/include/cutils/trace.h \
external/drm_hwcomposer/.ci/android_headers/cutils/
cp external/libdrm/android/gralloc_handle.h \
external/drm_hwcomposer/.ci/android_headers/gralloc_handle.h
cp hardware/libhardware/include/hardware/gralloc.h \
hardware/libhardware/include/hardware/hardware.h \
hardware/libhardware/include/hardware/hwcomposer.h \
hardware/libhardware/include/hardware/hwcomposer2.h \
hardware/libhardware/include/hardware/hwcomposer_defs.h \
external/drm_hwcomposer/.ci/android_headers/hardware/
cp system/core/libsync/include/sync/sync.h \
external/drm_hwcomposer/.ci/android_headers/sync/sync.h
cp system/core/libsync/include/ndk/sync.h \
external/drm_hwcomposer/.ci/android_headers/ndk/sync.h
cp system/core/libsystem/include/system/graphics-base-v1.0.h \
system/core/libsystem/include/system/graphics-base-v1.1.h \
system/core/libsystem/include/system/graphics-base-v1.2.h \
system/core/libsystem/include/system/graphics-base.h \
system/core/libsystem/include/system/graphics-sw.h \
system/core/libsystem/include/system/graphics.h \
external/drm_hwcomposer/.ci/android_headers/system/
cp frameworks/native/libs/ui/include/ui/GraphicBuffer.h \
external/drm_hwcomposer/.ci/android_headers/ui/GraphicBuffer.h
cp system/core/libutils/include/utils/Trace.h \
external/drm_hwcomposer/.ci/android_headers/utils/Trace.h
Turn off clang-format check for these files.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Reviewed-by: Matvii Zorin <matvii.zorin@globallogic.com>
Roman Stratiienko [Thu, 1 Apr 2021 12:52:54 +0000 (15:52 +0300)]
drm_hwcomposer: Fix client range selection logic
Original change aimed to fix clang-tidy checks, but
accidentally it caused wrong client range selection.
Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/53
Fixes:
e2f2c929243f ("drm_hwcomposer: enable code analysis using clang-tidy")
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Fri, 5 Feb 2021 14:32:47 +0000 (16:32 +0200)]
drm_hwcomposer: Remove writeback-based flattening logic
Writeback Pros:
a. Very tiny reduction in power consumption required for
rendering the composition compared to CLIENT-based flattening.
Writeback Cons:
a. A lot of extra code. High maintenance cost(effort).
Nobody tests it as for now.
b. Writeback isn't implemented by the set of KMS drivers
c. Require separate memory buffer to be allocated
Part of: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/47
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Riadh Ghaddab [Fri, 5 Feb 2021 12:06:50 +0000 (12:06 +0000)]
drm_hwcomposer: add missing HAL pixel format
using Android-11 (android-11.0.0_r27 )on i500 MediaTek SoC we can
see some log floods with the following trace:
E hwc-platform-drm-generic: Cannot convert hal format to drm format 43
Adding the conversion of this format : HAL_PIXEL_FORMAT_RGBA_1010102
resolves the log flood
Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
Roman Stratiienko [Fri, 26 Feb 2021 15:49:40 +0000 (17:49 +0200)]
drm_hwcomposer: CI: Add more source files to the build
Build bufferinfo/BufferInfoGetter.cpp and drm/DrmPlane.cpp
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Mon, 15 Feb 2021 11:44:19 +0000 (13:44 +0200)]
drm_hwcomposer: clang-tidy: enable cppcoreguidelines-* checks
Our code isn't ready for the following checks therefore keep disabled
-cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-pro-bounds-constant-array-index
-cppcoreguidelines-pro-bounds-pointer-arithmetic
-cppcoreguidelines-pro-type-cstyle-cast
-cppcoreguidelines-pro-type-vararg
-cppcoreguidelines-avoid-magic-numbers
-cppcoreguidelines-macro-usage
-cppcoreguidelines-avoid-c-arrays
+ fixed existing tidy warnings for these checks.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Mon, 15 Feb 2021 09:25:23 +0000 (11:25 +0200)]
drm_hwcomposer: clang-tidy: enable clang-analyzer-* checks
+ fixed existing tidy warnings for these checks.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Sat, 13 Feb 2021 08:57:47 +0000 (10:57 +0200)]
drm_hwcomposer: enable code analysis using clang-tidy
Drm hwcomposer project has some code-style inconsistencies.
This is the initial step to unify code-style of the code.
Clang-tidy is a great tool which can not only suggest correct styling,
but also allow predicting the errors in the code and suggest correct
coding approaches to avoid potential weaknesses.
CI was tuned to check clang-tidy recommendation for some part of the
code which is ready ATM (can be built outside AOSP tree).
For this part a limited set of clang-tidy checks has applied (coarse check).
Header files aren't checked at all.
Starting from now new code files must be included into the list that is
checked by almost all clang-tidy checks (fine checklist). New header files
should be also included into this list.
See '.gitlab-ci-clang-tidy-fine.sh'.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Sat, 27 Feb 2021 20:08:51 +0000 (22:08 +0200)]
drm_hwcomposer: CI: Use bpfmt to check Android.bp files style
Fix available errors by executing:
$ find -name "*.bp" -exec bpfmt -d -s -w {} \;
Suggested-by: Marijn Suijten <marijn.suijten@somainline.org>
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Thu, 25 Feb 2021 17:15:14 +0000 (19:15 +0200)]
drm_hwcomposer: CI: Initial build and clang-tidy checks
Build android-agnostic code in linux environment.
Enable static code analysis using clang-tidy.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Thu, 25 Feb 2021 16:33:26 +0000 (18:33 +0200)]
drm_hwcomposer: CI: Use clang-11 for the CI
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Mon, 15 Feb 2021 13:41:53 +0000 (15:41 +0200)]
drm_hwcomposer: Create make target to test filegroups
Android.bp contains filegroups that are not built by default
(e.g. using $ mmma external/drm_hwcomposer)
Fix it.
To ensure build will work on wide range of Android versions,
pull depended headers from AOSP-11 tree:
1. Mali: "device/linaro/hikey/gralloc960"
2. Imagination: "hardware/ti/am57x/libhwcomposer"
and put it into ./tests/test_include directory.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
John Stultz [Tue, 2 Feb 2021 01:34:45 +0000 (01:34 +0000)]
drm_hwcomposer: Fix drmSetMaster() usage
After commit
3b24cd911ebf ("drm_hwcomposer: Ensure composer has
master access to DRM/KMS") was merged I started seeing failures
on 5.4 based kernels.
Diggin into it, it seemed on those kernels drmSetMaster() was
always returning -EACCES, due to the following upstream kernel
change not being present:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=
45bc3d26c95a8fc63a7d8668ca9e57ef0883351c
That change landed around 5.6, so for older kernels we need to
make sure older kernels without this patch still work. So this
patch, as suggested by Roman Stratiienko, reworks the logic
so we call drmSetMaster() and then check drmIsMaster(), rather
then failing due to the return value.
With this patch, things are back to working on both hikey960
and db845c with 5.4 based kernels.
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I7f2adba3ddbd36169b6d26baf49299046efcf906
Roman Stratiienko [Sun, 27 Sep 2020 19:48:08 +0000 (22:48 +0300)]
drm_hwcomposer: Initial composer@2.4 HAL support
Enough to boot Android with composer@2.4 enabled.
VTS at this point:
============================================
================= Results ==================
arm64-v8a VtsHalGraphicsComposerV2_4TargetTest: 34s
armeabi-v7a VtsHalGraphicsComposerV2_4TargetTest: 31s
=============== Summary ===============
2/2 modules completed
Total Tests : 46
PASSED : 44
FAILED : 2
============================================
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Matvii Zorin [Tue, 8 Sep 2020 13:12:51 +0000 (16:12 +0300)]
drm_hwcomposer: Add support for color encoding and range properties
Starting from the linux-v4.17, the DRM module has support for different
non-RGB color encodings that are controlled through plane-specific
COLOR_ENCODING and COLOR_RANGE properties.
This patch creates a matching between the HWC layer dataspace which is
supported by DRM driver and DRM plane properties.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Roman Stratiienko [Sun, 13 Dec 2020 15:41:04 +0000 (17:41 +0200)]
drm_hwcomposer: Add minigbm video and format_modifier support
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Fri, 8 Jan 2021 16:30:31 +0000 (18:30 +0200)]
drm_hwcomposer: Support unique fd for every YUV plane
Fixes video playback on DEVICE while using minigbm gralloc[0,3,4],
and other grallocs that have more than 1 prime_fd for YUV buffers.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Wed, 13 Jan 2021 08:32:04 +0000 (10:32 +0200)]
drm_hwcomposer: Ensure composer has master access to DRM/KMS
Allocator service is always loaded before Composer service.
Kernel will assign master access to the first client that
opened /dev/dri/cardX node.
Allocator should immediately execute drmDropMaster() to
allow Composer service to acquire master privileges.
If this does not happen, the composer should gracefully exit,
otherwise a lot of DRM ioctls will fail without displaying anything
on the UI.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Fri, 20 Nov 2020 14:21:55 +0000 (16:21 +0200)]
drm_hwcomposer: Reorganize modifiers handling logic
Reasons for this change:
1. Remove redundant code lines.
2. Workaround for cases when DRM_FORMAT_MOD_INVALID is set by gralloc.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Fri, 30 Oct 2020 11:53:00 +0000 (13:53 +0200)]
drm_hwcomposer: libdrmgetter: fix RGB565 format translation
FOSS graphic components (gbm_gralloc, mesa3d) are translating
HAL_PIXEL_FORMAT_RGB_565 to DRM_FORMAT_RGB565 without swapping
the R and B components. Same must be done here.
Fixes wrong colors in some games (i.e. Pixel Wheels).
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Jason Macnak [Mon, 2 Nov 2020 15:04:11 +0000 (07:04 -0800)]
drm_hwcomposer: check ConvertBoInfo errors before importing
Signed-off-by: Jason Macnak <natsu@google.com>
Dennis Tsiang [Fri, 30 Oct 2020 08:43:33 +0000 (08:43 +0000)]
drm_hwcomposer: implement Gralloc 4 BufferInfoMapperMetadata
Implements the BufferInfoMapperMetadata that uses the
GraphicBufferMapper to set the fields of the hwc_drm_bo_t struct.
New class function GetFds created to obtain the file descriptors from
the native_handle_t. Function is marked weak so that vendors can
override it to match their system if required.
Change-Id: I74445487dec6bda2915b21f4b63804832bfead23
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Fri, 23 Oct 2020 19:28:38 +0000 (22:28 +0300)]
drm_hwcomposer: stop using pixel_stride
pixel_stride is used only to validate buffer when importing using
GraphicBufferMapper::importBuffer() method.
The problem is we can't always get this value from buffer_handle_t.
Libdrm and MapperMetadata getters can only calculate this value based
on byte stride and buffer format. But this calculation isn't always
possible, which causes importBuffer() to fail.
Instead we can use GrallocMapper::importBuffer() method,
which doesn't require to validate the buffer.
This commit is not compatible with Android-P.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Sat, 10 Oct 2020 20:06:36 +0000 (23:06 +0300)]
drm_hwcomposer: Set correct source crop for the client layer
Android supports limiting client buffer size using system properties:
"ro.surface_flinger.max_graphics_width"
"ro.surface_flinger.max_graphics_height"
If properties are set, client layer buffer size can no longer be equal to the
display size, which causes composition with CLIENT buffer to fail.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Sat, 3 Oct 2020 07:52:36 +0000 (10:52 +0300)]
drm_hwcomposer: refactor platform directory
Motivation:
Platform term meaning used in drm_hwcomposer does not correspond to the
content of the platform directory. Platform directory consists of:
1. Buffer information getters for different gralloc (currently called platform).
2. Composition planner logic (which has flaws and should be reworked into
layer->plane mapping during validation stage logic).
3. DrmGenericImpoter with reference counting logic.
Android-11 IMapper@4 metadata API offers a generic way to access buffer
information which makes other gralloc buffer information getters obsolete.
Legacy getters should be maintained for some time until all known users
will migrate to Mapper@4 API.
Implementation:
1. Split 'PlatformImporter' logic to 'Importer' only and 'Buffer Getter' logic.
a. Remove buffer_handle_t parameter from ImportBuffer(). Instead user should
get BufferInfo using ConvertBoInfo to struct hwc_drm_bo_t, then use it for
ImportBuffer().
b. Move DrmGenericImporter.{cpp/h} into the drm directory.
2. Isolate planner code in single file and move it to compositor directory as
compositor/Planner.{cpp/h}
3. Rename platform definition
a. Rename platform directory to bufferinfo.
b. Rename/move bufferinfo/platorm*.{cpp,h} getters to
bufferinfo/legacy/BufferInfo*.{cpp,h}. Align class names/includes.
4. Split legacy/metadata getters logic.
a. Apply existing bufferinfogetter base class only for legacy getters.
b. Combine legacy/generic gettera under new base class.
c. Create a placeholder for generic(metadata) getter.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Fri, 2 Oct 2020 16:01:10 +0000 (19:01 +0300)]
drm_hwcomposer: extract platform-libdrm code from platform-generic
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Sun, 4 Oct 2020 20:56:46 +0000 (23:56 +0300)]
drm_hwcomposer: Check parameter range in SetColorMode()
Fix GraphicsComposerHidlTest#SetColorModeBadParameter VTS test.
Fixes:
27d2ed670bb34 ("drm_hwcomposer: Fix SetColorMode() and SetColorModeWithIntent()")
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Sat, 26 Sep 2020 20:59:19 +0000 (23:59 +0300)]
drm_hwcomposer: Fix SetColorMode() and SetColorModeWithIntent()
SetColorMode() should return HWC2_ERROR_UNSUPPORTED [1]
SetColorModeWithIntent() should return HWC2_ERROR_UNSUPPORTED [2]
Parameters range shoud be also checked to pass VTS.
Fixes VtsHalGraphicsComposerV2_2TargetTest:
- PerInstance/GraphicsComposerHidlTest#SetColorMode_2_2*
============================================
================= Results ==================
arm64-v8a VtsHalGraphicsComposerV2_2TargetTest: 39s
armeabi-v7a VtsHalGraphicsComposerV2_2TargetTest: 36s
=============== Summary ===============
2/2 modules completed
Total Tests : 78
PASSED : 78
FAILED : 0
============================================
[1] - https://cs.android.com/android/platform/superproject/+/master:hardware/libhardware/include/hardware/hwcomposer2.h;l=1925;drc=
d5f2f67cd2ae63abeccabd0d5339dacd469569cd
[2] - https://cs.android.com/android/platform/superproject/+/master:hardware/libhardware/include/hardware/hwcomposer2.h;l=1952;drc=
d5f2f67cd2ae63abeccabd0d5339dacd469569cd
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Stratiienko [Fri, 25 Sep 2020 23:08:41 +0000 (02:08 +0300)]
drm_hwcomposer: Fix RegisterCallback() function
- Fixes segfault during client switch.
- Allows to run VTS on Android-11.
VTS Results:
============================================
arm64-v8a VtsHalGraphicsComposerV2_1TargetTest: [53 tests / 42808 msec]
armeabi-v7a VtsHalGraphicsComposerV2_1TargetTest: [53 tests / 33353 msec]
=============== Summary ===============
2/2 modules completed
Total Tests : 106
PASSED : 106
FAILED : 0
============================================
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Marijn Suijten [Sat, 19 Sep 2020 10:12:03 +0000 (12:12 +0200)]
drm_hwcomposer: Return error from GetEdidBlob if blob is null
drmModeGetPropertyBlob can return NULL blobs resulting in a segfault in
GetDisplayIdentificationData which expects blob to be set to a valid
pointer when GetEdidBlob returns 0.
Fixes:
adc5d8229b9ce25f1bf0e4d02bb838eae62b89fc
Signed-off-by: Marijn Suijten <marijns95@gmail.com>
Roman Stratiienko [Wed, 23 Sep 2020 08:51:12 +0000 (11:51 +0300)]
drm_hwcomposer: fix build error after
fbf5c0ca45b3
'warning' preprocessor directive is interpreted as build error.
Replace it with ALOGW.
Fixes:
fbf5c0ca45b3 ("drm_hwcomposer: libdrm gralloc_handle: modifiers and YUV support")
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Roman Kovalivskyi [Thu, 10 Sep 2020 09:07:37 +0000 (12:07 +0300)]
drm_hwcomposer: Add check for format support during plane validation
Some layers have pixel format that aren't supported by a hardware. In
such case it is better to reject plane that doesn't supports such
format, so we could handle it in future, rather than accepting it,
passing to the kernel side and failing whole composition.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Thu, 26 Mar 2020 03:03:39 +0000 (05:03 +0200)]
drm_hwcomposer: Add supported formats list to DrmPlane
There are some use-cases for checking formats supported by given
plane. drmModePlane already contains reqired data, so it simply could
be saved into DrmPlane, no need to query any additional stuff.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Mattijs Korpershoek [Tue, 22 Sep 2020 15:52:06 +0000 (17:52 +0200)]
drm_hwcomposer: add drm-mediatek to client-backend list
Since mediatek-drm has no support for premultiplied alpha buffers, we
can have issues with transparency.
Disable off-loading by adding "mediatek-drm" to the
client-backend list.
Change-Id: I12b034ecd5ae961264d01b6effaa4f4010036ac9
Suggested-by: Roman Stratiienko <r.stratiienko@gmail.com>
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Mattijs Korpershoek [Mon, 21 Sep 2020 11:03:35 +0000 (11:03 +0000)]
drm_hwcomposer: Add MediaTek platform support
This platform handler is dedicated for the i500 MediaTek SoC [1].
i500 has a Mali-G72 MP3 GPU.
OpenGL/Mali integration is based on ARM Gralloc module, version
BX304L01B-SW-99005-r20p0-01rel0, without additional patches.
This platformmediatek is based on platformmeson, without the additional
usage flag in the private_handle_t.
AFBC support has also been removed as it's unsupported.
External Android.bp file should be created in order to build this
module:
```
cc_library_shared {
name: "hwcomposer.drm_mediatek",
defaults: ["hwcomposer.drm_defaults"],
srcs: [":drm_hwcomposer_platformmediatek"],
whole_static_libs: ["drm_hwcomposer"],
}
```
[1] https://www.mediatek.com/products/AIoT/i500
Change-Id: I3ea7a980d76ba5c5ff583b5d4f21e1989875bafb
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Roman Stratiienko [Sat, 29 Aug 2020 19:28:07 +0000 (22:28 +0300)]
drm_hwcomposer: remove vendor.hwc.drm.exclude_non_hwfb_imports property
This property was used to force composition on 'client' side.
After adding Backends support, it can be replaced with more straightforward
property definition: 'vendor.hwc.backend_override=client'.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I896da41abe8b777166a485c06a11c163ceaeb3f0
Roman Stratiienko [Sat, 29 Aug 2020 19:16:21 +0000 (22:16 +0300)]
drm_hwcomposer: always use PlanStageGreedy
Only PlatformHisi has custom planner. It doesn't makes much sense since
for HISI all composition is done on client side and planner should never
get buffers with usage flag other than GRALLOC_USAGE_HW_FB.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I3db3f96165f4c3aacb8bc43c8ee3ebc877163e1b
Andrii Chepurnyi [Fri, 10 Jul 2020 13:07:03 +0000 (16:07 +0300)]
drm_hwcomposer: Fix EDID fetch from DRM
EDID fetch procedure consist of two steps:
1) get appropriate blob_id
2) fetch EDID blob using blob_id
Those steps should be done sequentially, in
other case drivers can update EDID and blob_id
won't be actual.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Roman Stratiienko [Sat, 29 Aug 2020 18:35:39 +0000 (21:35 +0300)]
drm_hwcomposer: use CamelCase in source/header files related to class
Main goal is to increase readability of file names.
AOSP uses camelcase for files in many projects.
Lets do the same for drm_hwcomposer.
Keep platform/ directory as is, since class names is different from file names.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I7e992357851c2a86711f4da1241c4d507359e56b
Roman Stratiienko [Sat, 29 Aug 2020 08:26:16 +0000 (11:26 +0300)]
drm_hwcomposer: move header files into source directory
... to improve navigation between source/header file.
Unnecessary dependencies also removed.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I2c3bf993b8c5f356490433fd94e90011487a1276
Roman Stratiienko [Mon, 24 Aug 2020 08:27:48 +0000 (11:27 +0300)]
drm_hwcomposer: libdrm gralloc_handle: modifiers and YUV support
1. Import DRM modifier field from libdrm's gralloc_habdle.
2. Recently lock_ycrcb() was added to gbm_gralloc() [1], mesa3d uses
this function to obtain CrCb plane data (offsets, strides).
Use the same alhorythm in drm_hwcomposer. This allows GPU offloading
during video playback. (Tested using Gallery app and SkyTube).
[1] - https://github.com/robherring/gbm_gralloc/pull/15
[2] - https://gitlab.freedesktop.org/mesa/mesa/-/blob/
68957a82562d13b3f0d21a04ce633ffd236e6036/src/egl/drivers/dri2/platform_android.c#L202
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I8ec177ac782f27174443cebcb6e773070c1505cc
Roman Stratiienko [Tue, 1 Sep 2020 10:39:17 +0000 (13:39 +0300)]
drm_hwcomposer: fix incorrect layer_count usage
According to [1] DRM YCrCb planes is not the same as gralloc layers.
DRMHWC2 has no information about number of layers used in the buffer.
Also supplying value other than 1 will allways fail validation on
passthrough MapperHal@2.1 and probably other passthrough implementations [2].
[1] - https://cs.android.com/android/platform/superproject/+/master:hardware/libhardware/include/hardware/gralloc1.h;l=467;drc=
1155c41d016a118801fe97b55af9918e531f7f84
[2] - https://cs.android.com/android/platform/superproject/+/master:hardware/interfaces/graphics/mapper/2.1/utils/passthrough/include/mapper-passthrough/2.1/Gralloc0Hal.h;l=40;drc=
e308ceb1e9940d1d90a11177782a7cfe8630bb95
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: Idbfea8eaa74a557b98ecdff728e6c67aeea9cea6
Matvii Zorin [Tue, 11 Aug 2020 12:33:03 +0000 (15:33 +0300)]
drm_hwcomposer: Add rcar-du display backend
ABGR8888 pixel format and layer scaling are unsupported for rcar-du
platform.
Handle and filter out the layers by overriding the IsClientLayer method
for additional checks. That will force layers that require scaling or have
the unsupported pixel format to be merged by GPU, and allow other layers
to be merged by DRM.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Tue, 11 Aug 2020 12:29:21 +0000 (15:29 +0300)]
drm_hwcomposer: Add composition skipping backend
This display backend may be chosen by setting the hwc.backend_override
system property to the "client" value.
Suggested-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Tue, 11 Aug 2020 12:15:44 +0000 (15:15 +0300)]
drm_hwcomposer: Add backend-dependent validation for HwcDisplay class
Different DRM/KMS backends have a variable set of limitations, which is
not always exposed via DRM ioctls.
This implementation of backend-dependent validation provides a register
of platform-specific inherited backend class to the map by BackendManager
class. ValidateDisplay function is moved to generic backend
implementantion and separated into 2 additional methods.
The map key is a string that contains the corresponding DRM driver name.
During DrmHwcTwo class initialization the vendor.hwc.backend_override
system property and driver name will be checked and a backend will be set
for the appropriate display. If the map does not have any backend for the
named driver, the generic backend will be used.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Tue, 11 Aug 2020 11:05:12 +0000 (14:05 +0300)]
drm_hwcomposer: Expand access to HwcDisplay class members
Move the private methods and Stats structure into the public section
to have access outside the class. Create get functions for private
members. Access changing is needed to move display validation to
the Backend class.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Mon, 27 Jul 2020 15:35:39 +0000 (18:35 +0300)]
drm_hwcomposer: Move DrmHwcTwo internal classes outside private section
Making backend-validation for HwcDisplay is required access to
the internal class outside DrmHwcTwo. There is no need to keep other
internal classes in the private section in this case.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Mon, 27 Jul 2020 15:29:15 +0000 (18:29 +0300)]
drm_hwcomposer: Add include guard into drmhwctwo.h
Include guard was missed for the file.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Jason Macnak [Thu, 20 Aug 2020 18:49:51 +0000 (11:49 -0700)]
drm_hwcomposer: Move properties into vendor namespace
... to fix VTS VtsTrebleSysProp#testVendorPropertyNames.
Signed-off-by: Jason Macnak <natsu@google.com>
Matvii Zorin [Fri, 17 Jul 2020 09:08:45 +0000 (12:08 +0300)]
drm_hwcomposer: Add feature to search for KMS DRI card
Most modern SOCs have separate IP cores for GPU and Display Unit (KMS).
Also, there is no warranty that the KMS card will always have
/dev/dri/card0 path and GPU - /dev/dri/card1, but drm_hwcomposer should
open only KMS device. The order can depend on many factors. For example:
on the rpi4 board, it was observed that enabling the WIFI kernel module
swapping the card order. Therefore searching for the KMS card is the only
efficient solution.
The IsKMSDev function returns true when the file descriptor on the path
is successfully opened, the drmlib function is returned resources and
the target device has at least one CTRC, connector, and encoder. Also,
the patch enables finding KMS devices in the case of the absence of
the system property specification.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I8874a50188207833389fadd4815b42a80bf69240
Andrii Chepurnyi [Fri, 3 Jul 2020 08:21:33 +0000 (11:21 +0300)]
drm_hwcomposer: Implement *DisplayBrightness* stubs
Implement *DisplayBrightness* stub to be able boot
Android 11 using android.hardware.graphics.composer@2.3-service.
This change caused by error during boot:
failed to get hwcomposer2 function 61
61 is equal to SetDisplayBrightness.
GetDisplayBrightnessSupport is a companion of it.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Idacb32abdcf7ac399ef989f24ab7a360248466f9
Andrii Chepurnyi [Wed, 29 Apr 2020 20:15:28 +0000 (23:15 +0300)]
drm_hwcomposer: Implement SetColorModeWithIntent stub
Fix VTS test GraphicsComposerHidlTest.SetColorMode_2_2BadParameter.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Ia8ae6c0d7cb2a6bf09c205a04963ed359c5126a3
Andrii Chepurnyi [Fri, 24 Apr 2020 11:20:24 +0000 (14:20 +0300)]
drm_hwcomposer: Implement GetRenderIntents stub
Fix VTS test GraphicsComposerHidlTest.GetRenderIntentsBadDisplay.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I5ceec735b5684581178070e75d96f5961b774f5f
Liviu Dudau [Mon, 15 Jun 2020 16:08:33 +0000 (17:08 +0100)]
drm_hwcomposer: Fix ValidateDisplay() when lowest z-order is nonzero
ValidateDisplay()'s algorithm for achieving minimal GPU load assumes
that the lowest z-order is zero and that layers have sequential z-orders.
CalcPixOps() and MarkValidated() are also written with the same assumption.
However, there is no such guarantee provided by SurfaceFlinger and VTS
tests like PRESENT_DISPLAY_NO_LAYER_STATE_CHANGES fail as they only have
one layer with z-order of 10.
Normalise the mapping between layers and z-order so that the algorithm works
as intended.
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Fixes commit
b7b81cfba252 ("drm_hwcomposer: Choose client layer range to
achieve minimal GPU load")
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I71b76b9d151bf506ad6026f5b1f9de6b6c0dc7c1
Matvii Zorin [Mon, 6 Apr 2020 16:03:03 +0000 (19:03 +0300)]
drm_hwcomposer: Run test commit only when it actually needed
Composition testing is expensive. We do not need to spend CPU time when:
* All layers are marked as a client.
The patch skips CommitFrame function called by the ValidateDisplay
method in this case.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Paul Howgego [Tue, 9 Jun 2020 17:21:45 +0000 (18:21 +0100)]
drm_hwcomposer: Fix invalid buffer_handle_t pointer
In Android 11, at boot time, I see the following sequence of
calls from SurfaceFlinger that trigger this:
// Composition type for layer is saved in DRM HWC Layer validated_type_
validateDisplay()
// Layer composition type saved in DRM HWC Layer sf_type_
acceptDisplayChanges()
// Composition type in Layer sf_type_ is now "client" so DRM HWC doesn't
// update the Layer buffer pointer
setLayerBuffer()
// DRM HWC Layer sf_type_ is now changed back to "device"
setLayerCompositionType()
// DRM HWC iterates through the layers and finds that Layer composition
// type in sf_type_ is "device" so thinks it is fine to calls
// importBuffer() but this Layer now has an invalid pointer as the
// setLayerBuffer() was ignored.
validateDisplay()
Thus this patch, changes the logic to always update the
buffer_handle_t pointer in setLayerBuffer regardless of
composition type rather than keeping the invalid buffer_handle_t
in the Layer obect. The composition type may be changed back to
device composition by setLayerCompositionType at which point the
Layer object needs to have saved the buffer_handle_t.
Not sure how we could reproduce the same sequence of calls on
another Android version.
Signed-off-by: Paul Howgego <paul.howgego@arm.com>
[jstultz: Reword and add context from merge request to the commit message]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I88a11ee2fee742d6154a482455a8532a95e681d3
Andrii Chepurnyi [Thu, 23 Apr 2020 17:48:13 +0000 (20:48 +0300)]
drm_hwcomposer: Propagate PLATFORM_SDK_VERSION to cflags
PLATFORM_SDK_VERSION is needed for already present
code (GetDisplayIdentificationData/GetDisplayCapabilities),
which implements some of the android.hardware.graphics.composer@2.3 API.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I1a5019e9d8ae327db41f55cee0ba3636f913928f
Andrii Chepurnyi [Tue, 14 Apr 2020 10:03:57 +0000 (13:03 +0300)]
drm_hwcomposer: Fix GetDisplayIdentificationData
Fix GetDisplayIdentificationData, introduced
by commit:
b3d817815fad.
Edid data should be copied instead of assign.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
John Stultz [Fri, 21 Feb 2020 05:56:34 +0000 (05:56 +0000)]
drm_hwcomposer: Relax failure when no EDID property is found
Crosvm doesn't implement EDID virtio cmd, so when commit
b3d817815fad ("drm_hwcomposer: Add GetDisplayCapabilities
and getDisplayIdentificationData") landed, it broke crosvm
targets using --gpu_mode=drm_virgl
This patch tries to ease that restriction, so a lack of EDID
isn't considered fatal.
Change-Id: I8ce899fc71d2b1187d364918328473ef1890d52d
Signed-off-by: John Stultz <john.stultz@linaro.org>
Peter Collingbourne [Wed, 19 Feb 2020 19:25:08 +0000 (11:25 -0800)]
drm_hwcomposer: Improve error messages.
- Don't negate errno before passing to strerror, at least on
bionic this results in "Unknown error -x" instead of the actual
error.
- Fix another error message to print strerror(errno) instead of the
returned fd which will always be -1.
- Fix another error message to call strerror for consistency.
Signed-off-by: Peter Collingbourne <pcc@google.com>
Roman Kovalivskyi [Mon, 3 Feb 2020 16:13:57 +0000 (18:13 +0200)]
drm_hwcomposer: Add statistics on flattening to dump message
We need some way to verify that current composition is not failed to
compose, but instead sent to flatten on GPU.
Dump message shows current flattening state. It also displays how
often do compositor switches into flattening.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Thu, 30 Jan 2020 18:20:47 +0000 (20:20 +0200)]
drm_hwcomposer: Add fallback to client for layers flattening
Google recommends to delegate composition to GLES instead of HWC when
screen isn't updating to conserve power, as stated on page
https://source.android.com/devices/graphics/implement-hwc.
Current implementation of hwcomposer has flattening of layers if after
some time there were no updates of frames, but it uses writeback
connector. Not every device has a support of writeback feature, so
some sort of fallback should be provided.
It is possible to fallback to client composition in case if writeback
isn't available. This is used to reduce power consumption since
squashing layers into a single layer on GPU and then using that buffer
is more efficient than loading drm device.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Stratiienko [Fri, 20 Dec 2019 15:04:01 +0000 (17:04 +0200)]
drm_hwcomposer: Add property that allows disabling of hardware scaling
Set `hwc.drm.scale_with_gpu` property to 1 in case composer hardware
do not have scaling support.
That will force layers that require scaling to be merged by GPU,
and allow other layers to be merged by DRM.
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
John Stultz [Fri, 7 Feb 2020 21:31:08 +0000 (21:31 +0000)]
drm_hwcomposer: Try to fix build with older Android Pie releases
Try to fix build regressions for P that were introduced with
commit
b3d81781 ("drm_hwcomposer: Add GetDisplayCapabilities and
getDisplayIdentificationData") as noted in issue #30
https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/issues/30
Change-Id: I4bfeb952cff19d4c3511ead69df1186d3a04cc87
Signed-off-by: John Stultz <john.stultz@linaro.org>
Roman Stratiienko [Thu, 23 Jan 2020 16:17:41 +0000 (18:17 +0200)]
drm_hwcomposer: Extract more BO data by Imagination importer v2
Fields bo->hal_format and bo->pixel_stride should be set to pass validation
by Mapper HAL v2.1 and v3.0. Otherwise UI is missing and the following
message appears in the logcat:
```
2576 E GraphicBufferMapper: validateBufferSize(0xe663b3637400) failed: 7
2576 E hwc-drm-utils: Failed to import buffer handle err: 7
2576 E hwc-drm-two: Failed to import layer, ret=7
```
Fixes:
e3ed48d728aa ("drm_hwcomposer: Add Imagination platform support")
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
John Stultz [Tue, 4 Feb 2020 21:53:13 +0000 (21:53 +0000)]
drm_hwcomposer: Revert "drm_hwcomposer: Extract more BO data by Imagination importer"
This reverts commit
b2f2baeb9db0d0f4cbc0cac3184058d3fce85ea6.
I'm trying to utilize a policy of lighter reviews w/ quick reverts
when there are issues to keep things moving. So with that in mind
I'm reverting "Extract more BO data by Imagination importer" since
its breaking the build in AOSP.
See:
https://android-review.googlesource.com/c/platform/external/drm_hwcomposer/+/
1225155/-1..1#message-
828f83ed7fa89b3bdfff7b0b5b1dd7364c822892
https://android-review.googlesource.com/c/platform/external/drm_hwcomposer/+/
1225916
This breakage is due to the importer code being tightly tied to
the gralloc private handle definitions, which is a common problem
as the gralloc and drm_hwcomposers are separately maintained.
The beagle_x15 gralloc is apparently older, and doesn't have
the newly utilized fields.
So for now, revert this to stay in sync w/ AOSP. I'm happy to
re-apply as soon as a fix is in place which adds some sort of
versioning checks so hopefully drm_hwc can work with different
versions of the gralloc code.
Once users of the old gralloc code are updated, we can remove
such version checks if needed.
Change-Id: Ie72561061ea12cb58d3ba9616a62d05f4ffe78b0
Signed-off-by: John Stultz <john.stultz@linaro.org>
Roman Stratiienko [Thu, 23 Jan 2020 16:17:41 +0000 (18:17 +0200)]
drm_hwcomposer: Extract more BO data by Imagination importer
Fields bo->hal_format and bo->pixel_stride should be set to pass validation
by Mapper HAL v2.1 and v3.0. Otherwise UI is missing and the following
message appears in the logcat:
```
2576 E GraphicBufferMapper: validateBufferSize(0xe663b3637400) failed: 7
2576 E hwc-drm-utils: Failed to import buffer handle err: 7
2576 E hwc-drm-two: Failed to import layer, ret=7
```
Also copy suballocs data for future usage.
Fixes:
e3ed48d728aa ("drm_hwcomposer: Add Imagination platform support")
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Kovalivskyi [Thu, 21 Nov 2019 15:15:02 +0000 (17:15 +0200)]
drm_hwcomposer: Remove redundant hotplug call
Initial hotplug state is reported back during callback registration,
but during VTS tests we've noticed error that is caused by calling
hotplug with same display twice.
HandleInitialHotplugState calls hotplug function for each connected
display, so it covers HWC_DISPLAY_PRIMARY too, therefore first call
should be removed, as it is redundant and causes minor error.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Fri, 3 Jan 2020 18:26:45 +0000 (20:26 +0200)]
drm_hwcomposer: Add check to vsync routine to avoid crash on callback
Vsync could be disabled during routine being running and this could
potentially lead to crash on callback invocation. Crash happens if
VSyncControl(false) was called when Routine has cached callback and
unlocked mutex but haven't callback yet. At this point we can't be
sure that callback is still valid so invoking it is incorrect
behaviour.
Second check if vsync is enabled drastically shortens window when we
could go into invalid state, from the whole vblank invocation to
several machine instructions between check and invocation.
Please note that we can't check against cached value in this case,
therefore operations on this flag should be atomic instead.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Lowry Li (Arm Technology China) [Wed, 18 Dec 2019 06:28:22 +0000 (14:28 +0800)]
drm_hwcomposer: Add GetDisplayCapabilities and getDisplayIdentificationData
Implement GetDisplayCapabilities() to get a list of supported capabilities.
The drm core doesn't support layer CTM property yet and CRTC not having the
CTM property member neither. So for this patch, we just return 0 for now.
It can fix the segment fault while booting the Android on HWC2.3, caused by
lack of this API.
Implement getDisplayIdentificationData() to get the EDID blob data
along with the size and port.
Add edid property in DrmConnector.
Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
Roman Stratiienko [Fri, 6 Dec 2019 10:30:28 +0000 (12:30 +0200)]
drm_hwcomposer: Extract ConvertBoInfo() from ImportBuffer() method
To check either BO could be imported on validation stage, we need to
get more information regarding buffer (format, size, etc.)
This extraction also allows us to make ImportBuffer() and CanImport()
methods generic for all platforms.
In case BO can't be imported due to already existant checks in ImportBuffer(),
validator only marks single layer to be elaborated by GPU instead of whole
composition.
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Stratiienko [Fri, 13 Dec 2019 17:28:56 +0000 (19:28 +0200)]
drm_hwcomposer: Choose client layer range to achieve minimal GPU load
1. Allow CLIENT layer at any position.
2. Check all possible layer combination and choose most efficient
based on total pixel operations value.
Use case 1 - Layer count is greater than available planes
Table shows difference before and after this commit for 4 or 2 planes cases:
```
z_order layer size pixels before(4) after(4) before(2) after(2)
-
0 Wallpaper 1960x1080 2MiP CLIENT DEVICE CLIENT DEVICE
1 Launcher 1960x1080 2MiP CLIENT DEVICE CLIENT CLIENT
2 Status bar 1960x80 0.15MiP DEVICE DEVICE CLIENT CLIENT
3 Nav. bar 1960x80 0.15MiP DEVICE CLIENT CLIENT CLIENT
4 Cursor 24x24 576P DEVICE CLIENT DEVICE CLIENT
Total pixels merged by CLIENT (GPU) 4MiP -> 0.15MiP 4.3MiP -> 2.3MiP
```
Use case 2 - Unsupported layer type in the middle (Dim layer, etc):
Table shows difference before and after this commit for 4 or 2 planes cases:
```
z_order layer size pixels before(4) after(4) before(2) after(2)
-
0 App 1960x1080 2MiP CLIENT DEVICE CLIENT DEVICE
1 Status bar 1960x80 0.15MiP CLIENT DEVICE CLIENT CLIENT
2 Nav. bar 1960x80 0.15MiP CLIENT DEVICE CLIENT CLIENT
3 Dim layer 1960x1080 2MiP CLIENT CLIENT CLIENT CLIENT
4 Dialog 1000x500 0.5MiP DEVICE CLIENT DEVICE CLIENT
Total pixels merged by CLIENT (GPU) 4.3MiP -> 2.5MiP 4.3MiP -> 2.8MiP
```
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Kovalivskyi [Wed, 11 Dec 2019 17:09:51 +0000 (19:09 +0200)]
drm_hwcomposer: Add simplistic SetColorTransform implementation
VTS tests for SET_COLOR_TRANSFORM fails for now since
SetColorTransform is marked as unsupported function. this commit tries
to address this issue. We can't make complete implementation of those
features for our platform for now, so we'd just save arguments for
future use and force client composition if any color transformation is
requested. This is perfectly acceptable way to pass VTS testcase for
SET_COLOR_TRANSFORM.
Commit
da5839cf9258 ("drm_hwcomposer: Add support for GetColorModes &
SetCursorPosition") implements GetColorModes and SetCursorPosition
simply by adding fields that store this values for future
uses. Therefore we assume that it is okay to use this approach to at
least support interface part.
Please note that if transform hint is identity then no
transformation should be applied. If hint is arbitrary matrix then
given matrix should be applier after composition, though for now we'd
just force client composition instead. This behavior is required by
HAL interface as stated in
hardware/interfaces/graphics/composer/2.1/IComposerClient.hal, line
738 from repository
https://android.googlesource.com/platform/hardware/interfaces, tag
android-10.0.0_r14
Please note that color transform matrix argument is an array that has
16 elements by contract, as it is 4x4 matrix. This is why
MATRIX_SIZE has such value.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Wed, 11 Dec 2019 15:48:44 +0000 (17:48 +0200)]
drm_hwcomposer: Add simplistic SetLayerColor implementation
VTS tests for SET_LAYER_COLOR fails for now since SetLayerColor is
unsupported function. Tis commit tries to address this issue. We can't
fully implement it for now, therefore simplistic implementation that
just saves argument for future uses and satisfies the interface could
be used instead, for now.
Commit
da5839cf9258 ("drm_hwcomposer: Add support for GetColorModes &
SetCursorPosition") implements GetColorModes and SetCursorPosition in
the same fashion, simply by adding fields that store this values for
future uses, therefore we assume that it is okay to use this approach
here too.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Vincent Donnefort [Fri, 2 Aug 2019 10:18:35 +0000 (11:18 +0100)]
drm_hwcomposer: Add refcount for GEM handle
The linux kernel doesn't provide reference counting for the handle
returned by FD_TO_HANDLE ioctl. It means that if the same Gralloc buffer
is imported twice, the first GEM_CLOSE will destroy the handle even if it
is still in use by another import.
Remedy this issue by doing the reference counting directly in the DRM
generic platform support: ImportHandle() will increase the reference,
while ReleaseHandle() will decrease and close it, if necessary.
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Roman Stratiienko [Thu, 28 Nov 2019 15:51:16 +0000 (17:51 +0200)]
drm_hwcomposer: Introduce dumpsys metrics
To make optimal performance/power consumption ratio we want to use composing by
dedicated hardware to merge as much as possible composition cases.
We are going to continuously optimize and improve drm_hwcomposer HAL, that
makes high demand on formal validation process.
Introduce "pixel operation" definition. It should be in direct ratio with power
consumption, but currently it roughly calculated as sum of pixels merged by
each layer.
In some future we should apply some average gains depending of operation type
to calculate pixops more precisely. (e.g. scaling should take more pixops than
blending, and blending should take more that copying, etc.).
Using pixops could be very helpful when drm_hwc HAL have a choice which layer
sets to merge by GPU, making possible minimal energy model based planning.
Create statistics of the following events:
1. Total frames count
2. Total pixel operations
3. Pixel operations validated to use GPU (CLIENT)
4. Calculate composer efficiency: DEVICE/TOTAL operations ratio
5. Failed atomic validation commits count
6. Failed atomic presenting commits count
Usage:
- $ adb shell dumpsys SurfaceFlinger
Statistics will be shown at the end of the dump in 2 forms:
1. Since system launched
2. Since last dumpsys command called
Using statistics for the regression slope monitoring example:
1. Boot the board without the change
2. Use touch or keyboard (avoid using of mouse pointer) to do some predefined
actions (open application, start video, etc.)
3. Save the metrics
4. Boot the board with the change
5. Do exactly the same actions as in (2)
6. Save the metrics
7. Use metrics before and after change to indicate regression slope
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Matteo Franchin [Tue, 3 Dec 2019 17:10:38 +0000 (17:10 +0000)]
drm_hwcomposer: Fix returned fence in PresentDisplay
DrmHwcTwo::HwcDisplay::PresentDisplay was always returning -1 as the
present fence. This commits ensures the fence fd is correctly retrieved
after doing the commit-frame operation. It also updates outdated logic
that caused PresentDisplay to return the retire fence rather than the
present fence.
DrmHwcTwo::HwcDisplay::AddFenceToPresentFence is also changed so that
it assumes it is given ownership of the file descriptor it receives as
argument. This function was indeed called consistently with this
behaviour, which meant the dup led to leakage of file descriptors.
With the changes above this patch fixes a failure in the CTS test
dEQP-VK.wsi.android.display_timing.fifo.display_timing (for example
running Android 10 on HiKey960). The test failed with the error
"Unexpectedly received invalid timestamp." reported multiple times in
the logcat output.
Change-Id: If662e5239895b8b0e2ea31fd99747855f901a427
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Roman Kovalivskyi [Mon, 25 Nov 2019 17:17:53 +0000 (19:17 +0200)]
drm_hwcomposer: Add safe guard for unknown connector type
There is potential possibility that new connector type will be added
into DRM and it won't be handled by drm_hwcomposer immediately so it's
better to be safe and report error via logcat than crash with
out-of-bounds.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>