1
0
Fork 0
Commit graph

34 commits

Author SHA1 Message Date
Roman Stratiienko
780f7dacf9 drm_hwcomposer: CI: Upgrade to clang-13 && clang-tidy-13
+ address new clang-tidy findings.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-20 17:21:46 +02:00
Roman Stratiienko
d37b308299 drm_hwcomposer: Use DPMS property to configure display pipeline
Some of KMS drivers like kirin are sensitive to display pipeline
configuration, modern kernel will configure the pipeline correctly
when user sets DPMS property.

To be more precise current compositor logic will not attach primary
plane to the CRTC, while kirin relies on it internally.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-13 16:43:57 +02:00
Roman Stratiienko
f815d38c2a drm_hwcomposer: Raise clang-tidy level of some files to NORMAL
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-12 10:47:23 +02:00
Roman Stratiienko
753d107896 drm_hwcomposer: Make Planner class fully static
clang-tidy suggested to make all methods of Planner static,
since they don't use any instance members.

This makes creation of Planner instances unnecessary, therefore
remove all such cases.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-12 10:33:55 +02:00
Roman Stratiienko
fc014f5792 drm_hwcomposer: CI: Set clang-tidy level to NORMAL for some files
Some of files require small adjustments to move into NORMAL checks list.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-12 10:33:55 +02:00
Roman Stratiienko
5d1f5572dd drm_hwcomposer: Modify source_layers_ to be integer instead of array
It isn't used as an array. Simplify the logic.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Tested-by: Martin Juecker <martin.juecker@gmail.com>
Reviewed-by: Matvii Zorin <matvii.zorin@globallogic.com>
2021-12-29 18:06:09 +02:00
Roman Stratiienko
67cebf5c75 drm_hwcomposer: Handle unused planes by DrmDisplayCompositor
Rationale:
1. Cleanup/Simplify DrmDisplayComposition class
2. Prepare for shared planes support

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Tested-by: Martin Juecker <martin.juecker@gmail.com>
Reviewed-by: Matvii Zorin <matvii.zorin@globallogic.com>
2021-12-29 18:03:15 +02:00
Roman Stratiienko
32685ba1e6 drm_hwcomposer: Rework KMS state tracking
1. Store only FrameBuffer shared handle to keep buffer alive while
it is a part of active composition.
2. Store used planes to allow clearing of the composition.

Before this both of mentioned above was a part of DrmDisplayComposition.
Any external modification DrmDisplayComposition caused framebuffer object
to be destroyed, which forced screen to go blank.

We want to modify DrmDisplayComposition, to allow re-using previous
composition data.

This change will also help us tracking STAGED frame state and
migrate to non-blocking atomic commit.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Tested-by: Martin Juecker <martin.juecker@gmail.com>
Reviewed-by: Matvii Zorin <matvii.zorin@globallogic.com>
2021-12-29 18:03:11 +02:00
Roman Stratiienko
5f2f3ce3bc drm_hwcomposer: CI: Tune clang-tidy coarse checks
1. Switch to "enable all then disable unwanted" strategy
2. Enable checks that causes small number of failes, marking
   corresponding lines as NOLINT, so we won't introduce
   new such cases unintentionally.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-12-22 16:05:31 +02:00
Roman Stratiienko
dccc6fb4f3 drm_hwcomposer: Make single atomic function for all atomic commit ops.
... to allow precise control on atomic commit operations.

This should also help to implement dynamic modechange, readback and
other useful features.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-28 21:43:01 +03:00
Roman Stratiienko
40b374b140 drm_hwcomposer: Move CreateModeBlob to DrmMode class
CreateModeBlob doesn't architecturally belongs to DrmDisplayCompositor.
+ align DrmMode internal types with libdrm types to avoid compilation errors.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-23 20:13:05 +03:00
Roman Stratiienko
13f61b8bed drm_hwcomposer: Remove DrmDisplayCompositor::GetActiveModeResolution()
DrmDisplayCompositor::GetActiveModeResolution() isn't used, remove it.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-23 20:13:05 +03:00
Roman Stratiienko
36a7f28516 drm_hwcomposer: Rework display Mode Setting and DPMS handling
1. Remove DPMS logic. As stated in KMS kernel docs: CRTC "activate"
   property was implemented as a simplified atomic replacement of DPMS.
   And kernel internally will just update "activate" on DPMS setting.

2. Add SetDisplayActivate(bool state) method to compositor class,
   which is now replacement for SetDpmsMode().

3. Move mode settings out of DrmComposition class to DrmCompositor class.
   From now on DrmComposition describes only layer-to-plane composition
   as it should be.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-23 06:42:58 +03:00
Roman Stratiienko
6ede4667f1 drm_hwcomposer: Rework UserPropertyBlob to use RAII
Makes code simpler and leak-free.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-23 04:47:33 +03:00
Roman Stratiienko
d3a2cf4d1b drm_hwcomposer: Remove unused {DrmComposition,DrmCompositor}::Dump()
Both DrmCompositor and DrmComposition have to be reworked to account
for shared DRM planes, asynchronous atomic commit, dynamic modechange and
composition reusing between Validate/Present steps.

Current dump logic will be obsolate anyway and keeping/supporting it will
slow-down reworking process. It make sense to remove it now and create
from scrach if needed.

Test: mmma external/drm_hwcomposer

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-23 04:47:33 +03:00
Roman Stratiienko
e8c06798e9 drm_hwcomposer: Move client flattening closer to the frontend
Remove unnecessary code from DrmCompositor.
Drops ~100 LoC.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-23 04:47:33 +03:00
Roman Stratiienko
863a3c207e drm_hwcomposer: Handle all HWC2 callbacks in DrmHwcTwo.{h,cpp}
Part of frontend isolation activities.
1. Use HWC2 HAL types only inside DrmHwcTwo.{h,cpp}.
2. Use single lock for all callbacks.
3. Communicate with other drm_dwc components using std::function
   without any locking.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-09-29 13:00:29 +03:00
Roman Stratiienko
0dbe639438 drm_hwcomposer: Move plane-related atomic commit logic to DrmPlane class
Remove unnecessary property getter/setters from DrmPlane class.

As result: Removed ~50 unnecessary LoC. Improved readability.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-09-29 12:47:16 +03:00
Roman Stratiienko
7fd8f88c55 drm_hwcomposer: Cleanup DRM atomic commit
Create and use DrmPlane::AtomicSet() wrapper.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-09-29 12:46:54 +03:00
Roman Stratiienko
3e8ce57ada drm_hwcomposer: Wrap libdrm drmMode*{Get|Free}* into RAII
This should elliminate chance of any leaks in the future.
Fix drmModePropertyBlobPtr leak in DrmHwcTwo.cpp.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-09-29 12:46:28 +03:00
Roman Stratiienko
d26619b5d0 drm_hwcomposer: CI: Upgrade clang-* to v12
- Enabling readability-ientifier-naming tidy check does require to specify
MacroDefinitionIgnoredRegexp key, which is available only in clang-tidy-12.

- Clang-12 isn't available on ubuntu 20.10, therefore upgrade to 21.04.

- "DEBIAN_FRONTEND: noninteractive" is required to prevent ubuntu 21.04
from hanging, presumably due to waiting for the user input.

- A positive side effect of upgrading to clang-12 is new clang-tidy-12,
which exposed new issues in the code which is also fixed by this commit,
e.g:

    Failed cppcoreguidelines-narrowing-conversions check with error:
    error: narrowing conversion from 'uint32_t' (aka 'unsigned int') to 'float'

require explicit casting to pass the check, while some of such fails are caused
by incorrect variable type and fixed by changing the type to correct one.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-08-29 15:54:17 +03:00
Roman Stratiienko
0fade37afd 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>
2021-07-24 17:59:09 +03:00
Roman Stratiienko
5128715b42 drm_hwcomposer: cleanup hwcutils
Remove DrmHwcBuffer class. Wrap remaining logic into
DrmHwcLayer class.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-05-19 19:31:29 +03:00
Roman Stratiienko
8666dc9c58 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>
2021-05-19 19:31:29 +03:00
Matvii Zorin
f0757c21ec 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>
2021-04-06 12:46:22 +03:00
Matvii Zorin
704ea0e8fb 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>
2021-04-06 12:46:22 +03:00
Roman Stratiienko
d21071f7d5 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>
2021-04-06 12:12:17 +03:00
Roman Stratiienko
747747127f 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>
2021-03-19 15:35:15 +02:00
Roman Stratiienko
b3b5c1e937 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>
2021-03-03 16:12:22 +02:00
Roman Stratiienko
6a10c4ce1f drm_hwcomposer: clang-tidy: enable clang-analyzer-* checks
+ fixed existing tidy warnings for these checks.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-03-03 16:12:14 +02:00
Roman Stratiienko
e2f2c92924 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>
2021-03-03 16:07:25 +02:00
Matvii Zorin
8338c34a39 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>
2021-01-30 15:50:41 +02:00
Roman Stratiienko
2370109af7 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>
2020-09-28 15:21:29 +03:00
Roman Stratiienko
13cc3666c6 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
2020-09-08 22:34:52 +03:00
Renamed from compositor/drmdisplaycompositor.cpp (Browse further)