1
0
Fork 0
Commit graph

50 commits

Author SHA1 Message Date
Andrew Wolfers
5a9cc2cba3 Cleanup includes in drm/ per IWYU style
Change-Id: I613cb6656d887aab5221be3d3b2923f1f4ba9ab9
2025-11-11 19:14:37 +00:00
Andrew Wolfers
1e0e2ca0a5 Move implementations out of headers
This change moves some non-trivial implementations out of header
files in drm/. This will enable some includes to be converted to
forward declarations in future changes.

Change-Id: I7b1248657e0fa27e3c0c0157abe4f6b918e13a29
2025-11-11 17:01:13 +00:00
Andrew Wolfers
84892ec611 drm_hwcomposer: Cleanup includes for test target
Change-Id: I1332873df0109347a91e729955ba5f84cf8c7fec
2025-10-02 15:06:12 +00:00
Manasi Navare
d341024047 drm_hwcomposer: Clear connectors and CRTCs on Init
When DRM HWC starts, it resets all the connectors
and CRTCs to avoid the mimatch between drm hwc tracked
state and actual HW state programmed by the firmware
for the splash screen.

This fixes the MST connected boot issue.

Change-Id: I0773541b6bb227a2880d8442cc46411dc4c0127a
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-09-18 15:00:19 -06:00
Andrew Wolfers
9255d0d10b drm_hwcomposer: Migrate to android::drm_hwcomposer namespace
Change-Id: I2859aa8f55532d88231389724956fc77b0625339
2025-09-08 18:53:00 +00:00
Manasi Navare
c40f27b6ea drm_hwcomposer: Refresh connectors on every Uevent to add MST connectors
Earlier only the physical connectors were added on init
to the connectors_ vector and then hotplug handler
only operated on these cached connectors. But in case of MST
when new sinks are hotplugged to the downstream ports, new
dynamic connectors get added. So refresh the list of connectors
to remove the stale connectors and add new connectors
on every uevent.

This enables MST connectors hotplugged after boot.

Change-Id: I9163c6a892c3604ad8e49be94d32b30af7a6dc88
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-05-15 17:25:58 +00:00
Drew Davenport
b277be5675 Revert "drm_hwcomposer: Refresh connectors on every Uevent to add MST connectors"
This reverts commit 7be759ccf5.

Change-Id: I2c5e169465785df315140aad1a60fcda06d125db
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-21 11:42:50 -06:00
Manasi Navare
7be759ccf5 drm_hwcomposer: Refresh connectors on every Uevent to add MST connectors
Earlier only the physical connectors were added on init
to the connectors_ vector and then hotplug handler
only operated on these cached connectors. But in case of MST
when new sinks are hotplugged to the downstream ports, new
dynamic connectors get added. So refresh the list of connectors
to remove the stale connectors and add new connectors
on every uevent.

This enables MST connectors hotplugged after boot.

Change-Id: I9163c6a892c3604ad8e49be94d32b30af7a6dc88
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-04-14 21:36:02 +00:00
Mark Yacoub
385b47c876 drm_hwcomposer: Implement display readback using writeback connectors
[Why]
Android requires a readback mechanism to validate display output,
especially in automated testing environments. This implementation is
particularly beneficial for writing automated tests with VKMS, as it
provides a reliable way to directly validate the rendered output.

[How]
Implement support for display readback using DRM/KMS writeback
connectors. This patch:
- Adds buffer management for readback operations
- Implements proper fence handling for both input and output operations
- Integrates with DRM atomic interface to configure writeback connectors
- Provides buffer readiness signaling to client applications

The implementation verifies hardware compatibility by finding matching
writeback connectors for displays and handles all resource lifecycle
management including buffer replacement and cleanup. This allows
tests to directly capture and verify the rendered output, ensuring
correctness and stability.

Test: VtsHalGraphicsComposer3_ReadbackTest
Change-Id: I12ec3d696b95bba79cbc560c525f573271a501bb
Signed-off-by: Mark Yacoub <markyacoub@google.com>
2025-04-11 17:33:23 -04:00
Andrew Wolfers
9777fbabb4 drm_hwcomposer: Add DRM_CURSOR_CAP to DrmDevice
This change reads the DRM_CURSOR_CAP_{WIDTH|HEIGHT} capabilities of
DrmDevice, and exposes their values. These values can be used to
convey a reasonable cursor plane size [1].

[1] https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html#c.DRM_CAP_CURSOR_WIDTH

Change-Id: Iecf01d00a9562656c6d5b5aa8e0ac49b1dc739e5
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-02-27 14:19:13 +00:00
Andrew Wolfers
e778d038e2 drm_hwcomposer: Add blob support to DrmProperty
This changes adds support for accessing blob data of DrmProperties with
type casting. When invoked, the data corresponding to the blob id
indicated by the property value is read from the device, and returned
as a vector with the provided template typing.

This change adds the fd as an additional init parameter for DrmProperty,
which is required in order to read the blob data.

Change-Id: I9531d0e7e2f13a4fd2840564783859d1dec1efd5
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-02-25 14:50:11 +00:00
Gil Dekel
907a51ab1b drm_hwcomposer: Produce stable port IDs
Currently, port IDs are generated by returning a monotonically
increasing value (uint64_t hwc2_display_t). This is problematic for
two reasons:

hwc2_display_t is a 64bit value, and the returned port is 8bit.
clients of drm-hwc cannot rely on port ID consistency between
re-plugs to the same connector.

This patch provides a more stable approach to producing port IDs. We
combine the index of the DRM device in the device list, with the
index of the connector within a DRM device in a 3/5 bit split. This will
allow us to support up to 8 DRM devices, each with 32 independent
connectors (ports). If more support is required in the future, we will
have to extend the API to return uint16_t port values instead.

Signed-off-by: Gil Dekel <gildekel@google.com>
2025-02-15 23:23:52 -05:00
Roman Stratiienko
2290dc6d39 drm_hwcomposer: Use DUMB buffer for modeset
Now, as the LayerProperties struct accepts BufferInfo and BufferInfo can
carry the RAII-wrapped dmabuf FD, it has become elementary to use dumb
buffer for a modeset.

There are two benefits compared to using the gralloc:

1. We aim to make the DRM composer backend Android-agnostic.
2. Not every gralloc may support mapping the HWFB buffer.

Change-Id: I661c88be276de8f068d3af1e44da2740b1bec60d
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-13 20:05:33 +02:00
Sean Paul
468a7548bf drm_hwcomposer: Replace LOG_TAG with drmhwc
It's a pain to use logcat filters for drm_hwcomposer since each file has a different tag necessitating one to specify each tag for the logcat filter or use a regex.

Use one tag for all of drm_hwcomposer to simplify this.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
2024-07-19 17:42:41 +00:00
Roman Stratiienko
f2c060f8be drm_hwcomposer: Virtual display acceleration support
Some platforms like RaspberryPI-4 can benefit from Display Blender IP Core's
ability to write back the composition into RAM, offloading the GPU in cases
where the display content needs to be used (screen record, remote display,
etc.).

To enable this feature the following system property must be enabled:

    PRODUCT_VENDOR_PROPERTIES += debug.sf.enable_hwc_vds=1

The feature was requested by the Tesla Android project to improve UI
performance.

Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/4
Change-Id: I643f94551408bf218a0b889f1a031598646242f1
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-10-01 15:00:59 +03:00
Roman Stratiienko
76892784ac drm_hwcomposer: Introduce SharedFd, use standard c++ RAII for UniqueFd
We use too much dup() system calls for present fence propagating.
Also when propagating acquire fence we use additional logic for
skipping such propagation for the validate/test cycle.

Both issues can be solved by introducing SharedFd, which will track
reference count of fd object.

After that the UniqueFd is used very rarely and can be simplified by
wrapping it into std::unique_ptr without caring too much of adding
an extra malloc/free operation.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-01-16 20:13:58 +02:00
Roman Stratiienko
a7913de518 drm_hwcomposer: CI: Bump-up clang toolchain to v15
Address new clang-tidy findings, in most cases 'misc-const-correctness'
check was addressed by adding 'const' modifier, or in some cases changed
to 'auto' (where it's better for formatting).

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2022-10-20 14:14:33 +03:00
Roman Stratiienko
dd21494e00 drm_hwcomposer: Fix HwcLayer::GetReleaseFences()
GetReleaseFences() should return release fence for the prior buffer
(not for the one assigned to layer at the moment of GetReleaseFences call).

Once not provided, old front buffer can be damaged before new buffer
presented. (Such issues start to appear once we started using
non-blocking DRM/KMS commits).

Using present (out) fence is a perfect solution, since it is
signaled once old buffer replaced with the new one.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-05-10 11:17:32 +03:00
Roman Stratiienko
5f21dbc6f3 drm_hwcomposer: Allow accessing ResourceManager from DrmDevce
This is useful for accessing the main lock from drm / compositor
related code blocks.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-05-09 18:19:45 +03:00
Roman Stratiienko
4e994055a3 drm_hwcomposer: Rename DrmDisplayCompositor->DrmAtomicStateManager
Primary responsibilities of this class are:

1. Send composition/mode/active state over DRM atomic commit IOCTL
   to the kernel
2. Track commit state and keep planes owned by the Pipeline while they
   are either displayed or staged for displaying.
3. Keep framebuffers alive while they are in use or staged.

Not much related to composition itself, therefore rename it to
DrmAtomicStateManager and move it to drm folder.

Bump clang-tidy level of DrmAtomicStateManager.c to normal by fixing
minor clang-tidy findings.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-09 17:40:35 +02:00
Roman Stratiienko
3dacd47d13 drm_hwcomposer: Dynamic DrmDisplayPipeline to HwcDisplay bindings
The following use scenarios are now possible:

1. When no display connected, primary HwcDisplay is created in headless
   mode.

2. When user connects first display, it binds to primary slot, replacing
   headless HwcDisplay.

3. When user connects another display it binds to the new HwcDisplay
   slot, creating new display for the framework.

4. When user disconnects first (Primary) display, drm_hwc detaches
   second display and attaches it to the Primary slot. In this case
   framework is notified as Primary display resolution updated
   (Plugged->Plugged transition). And second display is disconnected
   (Plugged->Unplugged transition).

DrmDisplayPipeline is now created on demand (after hotplug event).

HwcDisplay class is now destructed on connector unplug, which will give
us ability to destroy any resource caches (will be required for FB
caching logic).

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-02 12:57:32 +02:00
Roman Stratiienko
19c162fe79 drm_hwcomposer: Initialize HwcDisplay using DrmDisplayPIpeline
HwcDisplay can now take all necessary objects from DrmDisplayPipeline.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-02 12:57:32 +02:00
Roman Stratiienko
cad8e0ca57 drm_hwcomposer: Introduce DrmDisplayPipeline class
Create systematic way of binding DRM objects (Crtc,Encoder,Planes...)
to the pipeline using RAII. Use it to create the pipeline.

+ Allow pipeline creation to fail.

Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/14
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:48:40 +02:00
Roman Stratiienko
7d89911c32 drm_hwcomposer: Tidy-up DrmDevice class
1. Move drm/DrmConnector.h to Normal clang-tidy checks list by fixing
   clang-tidy findings.

2. Remove DrmDevice self-reference.

3. Replace shared_ptr reference to DrmDevice in DrmFbImporter with a
   pointer, making ResourceManager only owner of DrmDevice and its
   chilren.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:48:40 +02:00
Roman Stratiienko
650299a235 drm_hwcomposer: Tidy-up DrmConnector class
Implement DrmConnector instantiation through CreateInstance() static method,
which helps to reduce complexity of DrmDevice::Init() function.

Move Connector-to-CRTC binding information to the DrmDevice class.

Move drm/DrmConnector.h to Normal clang-tidy checks list by fixing
clang-tidy findings.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:48:40 +02:00
Roman Stratiienko
027987b1fe drm_hwcomposer: Tidy-up DrmEncoder class
Implement DrmEncoder instantiation through CreateInstance() static method,
which helps to reduce complexity of DrmDevice::Init() function.

Move Encoder-to-CRTC binding information to the DrmDevice class.

Move drm/DrmEncoder.h to Normal clang-tidy checks list by fixing
clang-tidy findings.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:31:32 +02:00
Roman Stratiienko
10be875de0 drm_hwcomposer: Tidy-up DrmCrtc class
Implement DrmCrtc instantiation through CreateInstance() static method,
which helps to reduce complexity of DrmDevice::Init() function.

Move CRTC-to-Display binding information to the DrmDevice class.

Move drm/DrmCrtc.h to Normal clang-tidy checks list by fixing
clang-tidy findings.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:31:32 +02:00
Roman Stratiienko
edb97ed8b5 drm_hwcomposer: Remove ability to prioritize primary display
This feature isn't correctly fits hwc2 and SF requirements.

Primary display prioritization shall be done by introducing ability to
override internal/external connector type for any connector.

'vendor.hwc.drm.primary_display_order' property is no longer relevant.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:31:32 +02:00
Roman Stratiienko
b671fab16a drm_hwcomposer: Tidy-up DrmPlane class
This allow to throw away few lines from DrmDevice::Init() making it less
complicated.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:31:31 +02:00
Roman Stratiienko
8df7498290 drm_hwcomposer: Remove write-back related helpers from DrmDevice class
Remove unused functionality.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-20 17:21:46 +02:00
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
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
24a7fc43eb drm_hwcomposer: CI: Process every file with clang-tidy.
Currently part of header files isn't processed by CI.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-12 10:33:55 +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
1e053b4e19 drm_hwcomposer: Make uevent listener standalone
1. DRM event listener doesn't work in this conditions, uevent blocks
   the thread and non-blocking select() doesn't make any sense.
   Remove DRM event handling for now.

2. UEvent listeren is common for all DrmDevices, therefore put it into
   ResourceManager class.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-11-10 19:30:24 +02: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
0b06388081 drm_hwcomposer: Move GetPlaneProperty into DrmPlane class
In addition move logging to GetPlaneProperty(), which allow to reduce
number of LoC by ~50 LoC and increase readability.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-10-23 04:47:33 +03:00
Roman Stratiienko
56f4adcc9a drm_hwcomposer: Move IsKMSDev to DrmDevice
IsKMSDev() is a DRM device helper, therefore DrmDevice class
is better home for it.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-09-29 12:47:12 +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
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
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
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
Roman Stratiienko
d518a0594a 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>
2021-03-03 12:14:13 +02:00
John Stultz
fa0023394b drm_hwcomposer: Fix drmSetMaster() usage
After commit 3b24cd911e ("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
2021-02-11 20:52:13 +00:00
Roman Stratiienko
3b24cd911e 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>
2021-01-13 12:06:24 +02:00
Roman Stratiienko
b2e9fe23cd 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>
2020-10-20 23:19:42 +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 drm/drmdevice.cpp (Browse further)