1
0
Fork 0
Commit graph

106 commits

Author SHA1 Message Date
Andrew Wolfers
185f909299 Cleanup includes in compositor/ per IWYU style
Change-Id: I4362a5ff4228b1a30812ec564f6a0c81e1f5cf08
2025-11-11 19:14:32 +00:00
Andrew Wolfers
5ee173b752 Rename DrmKmsPlan to LayerToPlaneJoiningPlan
Change-Id: I3824e57e3d890f4c59d48e1c7045cb0b7b649583
2025-11-06 18:32:13 +00:00
Andrew Wolfers
6c2df0cbdd Move CompositionPlanner from backend/ to compositor/
Change-Id: Iebd4a4d0e15c5171aa20fafe3686b7bc8c08a175
2025-11-06 18:32:05 +00:00
Andrew Wolfers
a890ccd62f Add atom reporting for flattening controller state
Change-Id: I09f60c95519d844359d5f1c70b940b47f756da21
2025-11-06 15:30:45 +00:00
Manasi Navare
b23482b05c drm_hwcomposer: Add HDCP state tracking to request it to be enabled
This adds HDCP state tracking through Client to HwcDisplay
When Client requests HDCP to be enabled for secure layers
Hdcpstate in the corresponding HwcDisplay is set up.
This is parsed to set the Content Protection and HDCP Content Type
properties for the connector in the next commit

Change-Id: I60dd4359ee2f87faba1df83c7faf286b34af43f6
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-10-14 19:10:56 +00:00
Drew Davenport
f61371b260 drm_hwcomposer: Don't reset callbacks in FlatteningController
Make cbks_ const as set in the constructor. Add a new kExitThread state
to indicate that the thread should exit.

This reduces the amount of state that needs to be synchronized across
threads and the amount of member variables that control state flow.

Change-Id: Ic99dd7ab153939bfa2d971985799413b212a999e
2025-09-19 17:36:33 -06:00
Drew Davenport
9876f33138 drm_hwcomposer: Make FlatteningController::StopThread private
There is no need for this to be public since it is called from the
destructor, and any public usage of it was immediately before
destructing the FlatteningController

Change-Id: Ice233feaa9b934e7385ac83769250fea33f9140c
2025-09-19 17:36:33 -06:00
Drew Davenport
d2ccec310e drm_hwcomposer: No-op FlatteningController cleanup
- Move member function implementations to the .cpp file.
- Rename Disable -> DisableFlattening
- Update comments for functions

Change-Id: I71eec96597a0d41f652b897c1862a34138b5be85
2025-09-19 17:36:33 -06:00
Drew Davenport
6075ab4596 drm_hwcomposer: Use unique_ptr for FlatteningController
FlatteningController is owned by HwcDisplay, so use a unique_ptr to
better control and indicate the ownership.

Remove the CreateInstance factory method and use std::make_unique
instead.

Change-Id: I0155c602dcf5a31d27fd2677f9f96ff9696a4022
2025-09-19 16:58:58 -06:00
Drew Davenport
23e38a1033 drm_hwcomposer: Refactor state tracking in FlatteningController
Use an enum to track the different possible states of the
FlatteningController rather than a collection of bools.

Change-Id: I6136fd8f57a4033a10798f932a952951a01707b7
2025-09-19 16:58:46 -06:00
Drew Davenport
ccd7ca17c5 drm_hwcomposer: Add thread annotations to FlatteningController
Annotate the state that is access across multiple threads. Add locks in
appropriate scopes as necessary.

Change-Id: I05ca1054b4836b72c6efb3fd2bf241d4958e3252
2025-09-19 16:57:31 -06:00
Drew Davenport
c50f6851d6 drm_hwcomposer: Add tests for FlatteningController
Add gtest unittests to validate expected behaviour of
FlatteningController.

Change-Id: Ia40d232c7a72912df9480bd82adfe3315baaa493
2025-09-19 16:57:30 -06:00
Drew Davenport
2432cb0dfa drm_hwcomposer: Update FlatteningController behavior
Under the previous behavior, NewFrame both updated the internal state
tracking to indicate that the scene is not idle, as well as returning a
bool to indicate whether the scene should be flattened or not.
ShouldFlatten was not being used, and would return `true` during the
interval between the refresh callback being triggered and the next
NewFrame, which would be in response to the refresh callback. Subsequent
calls to ShouldFlatten would return `false` even though the scene
remains idle.

This commit updates NewFrame to only update the internal state. Callers
should call ShouldFlatten to check whether the controller has detected
that the scene should be flattened.

After the callback is triggered, ShouldFlatten returns true. It will
continue to return true after the first NewFrame, which would be in
response to the refresh callback. Subsequent NewFrame calls will reset
the idle detection.

Change-Id: I8b11a55bb6b101bb2ce473a844f5b9795a027956
2025-09-19 16:56:55 -06:00
Drew Davenport
ce65d6c6e3 drm_hwcomposer: Make FlatteningController timeout configurable
Pass a timeout to the FlatteningController constructor. Move the
original default timeout from FlatteningController to HwcDisplay.cpp

Change-Id: I6e3f8950badc38a5ccad8ae68e1b11317c850d61
2025-09-19 16:54:55 -06:00
Drew Davenport
38045be8af drm_hwcomposer: Add FlatteningController constructor args
Add a constructor that takes the callbacks and initialize the callbacks
in the constructor.

Change-Id: Id7a64fc23819e913a75753035f18fca2c81ce034
2025-09-19 16:54:54 -06:00
Andrew Wolfers
2261f81762 drm_hwcomposer: Add Rect utility type
This change refactors the IRect and FRect types into a single
templated type Rect<T>, which allows the implementation to be
shared across both variants. This change also adds convenience
getters for the rect widths and heights, and updates callsites
accordingly.

Change-Id: I38509631d57706266186a7b7fa21bd43c0860890
2025-09-10 13:41:51 +00:00
Andrew Wolfers
9255d0d10b drm_hwcomposer: Migrate to android::drm_hwcomposer namespace
Change-Id: I2859aa8f55532d88231389724956fc77b0625339
2025-09-08 18:53:00 +00:00
Andrew Wolfers
d4ab368f7f drm_hwcomposer: Add missing namespaces
Change-Id: I2ac3580664018cf63dc14e9f8025c2e60f843e3c
2025-09-08 18:52:59 +00:00
Drew Davenport
bf4210c17e drm_hwcomposer: Make TestComposition const
Making TestComposition const ensures that the Backend can't modify any
HwcDisplay state while creating and validating a composition.

Also make a bunch of other stuff const-correct since there is a const
version of GetPipe()

Change-Id: Ib7769d290148ce496b0165b64806dbd0a601b213
2025-08-26 09:27:21 -06:00
Drew Davenport
a5fb437d37 drm_hwcomposer: Move CompositionType out of HwcLayer struct
Moving this paves the way for reducing dependency on HwcLayer from the
Backend class

Change-Id: I62f057a0efcb7afc3c9a04cff3bd53b5c56c5ad9
2025-08-19 09:16:22 -06:00
Drew Davenport
199e090920 drm_hwcomposer: Join FlatteningController in destructor
Ensure that the thread has stopped and has stopped executing before
destructing the FlatteningController.

Change-Id: I32c631cbbfffc99dbd6c6b65bf1e86b670eca171
2025-07-16 17:49:31 -06:00
Andrew Wolfers
7f7fb03cc1 drm_hwcomposer: Update DrmKmsPlan to position cursor plane with highest z-pos
Cursor composition was previously developed under the mistaken assumption
that the z-pos property of the cursor plane was immutable. The DrmKmsPlan
would always place the cursor plane at the lowest z-position, but the
immutability made that aspect moot.

This change updates plan creation to instead place the cursor plane at the
highest z-position, which fixes cursor positioning on hardware where the
cursor plane z-pos is mutable.

Change-Id: Idfd390e0eb3de8ff6125722cda9f5ce73e983a02
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-06-25 13:14:34 +00:00
Sasha McIntosh
9624a8ea11 drm_hwcomposer: Remove SetColorTransform HWC2 API
Instead, reuse generic API SetColorTransformMatrix. The only valid hints
are abitrary and identity. Convert color_transform_hint_ member variable
to a bool.

Change-Id: Iac05c54394bee67637caa3edd3cde4e2097f6e1f
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-22 13:35:37 -04:00
Sasha McIntosh
574a22f721 drm_hwcomposer: Remove SetColorMode HWC2 API
Add generic API for Set/GetColorMode and move HWC2 specific behavior to
hwc2_device.

Remove HwcDisplay::SetColorModeWithIntent, as the only supported intent
is colormetric.

Rename Colormode to ColorMode.

Fix contract between color mode and render intent. All supported color
modes should have a supported render intent (COLORMETRIC at least).

Change-Id: Ic1002b630f925e1ea75cb6ad7822b1384010143e
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-22 13:35:33 -04:00
Drew Davenport
de1b4f40c3 Revert "drm_hwcomposer: Implement setContentType in hwc3"
This reverts commit 95beff230b

Change-Id: Ic626ea8f8e2bf2586992bf7ec424e82126e4f16c
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-11 16:58:15 -06:00
Sasha McIntosh
95beff230b drm_hwcomposer: Implement setContentType in hwc3
Internal ContentType and ContentType.aidl both match the HDMI 1.4 specification exactly.

Change-Id: If345a794a10c967b7fdb513f9056de39c7260678
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-04-10 15:07:23 -04:00
Andrew Wolfers
a2a1092e33 drm_hwcomposer: Plumb damage into Hwc layer data
This change adds a damage property to LayerData which is populated
from the damage provided via the layer command.

Change-Id: Ie6c069a1c2c81a8dc588a518f553ff087b0299dd
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-04-08 15:31:28 +00:00
Andrew Wolfers
0312c9e2a0 drm_hwcomposer: Fix cursor-related composition fallback
This change fixes an issue during display validation where
cursor layer failures would trigger a fallback that forces
all other layers to be client composited.

Prior to this fix, if the cursor layer could not match to
the cursor plane, DrmKmsPlan would attempt to match it to
another plane. This could result in the number of layers
exceeding the number of available planes, which causes the
composition to fail into the client-composition fallback
behavior.

This fix changes the first-level fallback behavior, so
that when the cursor layer doesn't match to the cursor
plane, the client range will be recaluclated in order to
reserve an additional plane for device composition. Then
the cursor layer is converted to device composition and
the composition is retried.

Change-Id: Id704e182b7cc1dc66270de45a986a29e4b71a5a8
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-04-04 19:49:46 +00:00
Drew Davenport
2d71839c8a drm_hwcomposer: Remove HWC2 SetContentType
Add a new function to set the HDMI content type, and call this from the
frontend.

Change-Id: I338a00b7a142c6d2e2c3a727e8e7df7d24c1594d
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-02 17:51:09 -06:00
Andrew Wolfers
5c53083f60 drm_hwcomposer: Presentation to cursor plane
This change adds support for presenting to the cursor plane.
Logic is added to match cursor layers with cursor planes during
composition, plus additional test commit logic with backoff
behavior. Prior to this change, cursor planes were never
considered during composition. After this change, cursor
planes are available to be matched with compatible layers and
then used for presentation.

Change-Id: I3acd131cd210de46ff19af5a8960b07a82f462b2
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-03-14 13:33:39 +00:00
Andrew Wolfers
7979d2ae8c drm_hwcomposer: Cursor plane binding
This change adds cursor plane binding into DrmDisplayPipeline.
The signature of DrmDisplayPipeline::GetUsablePlanes is updated
to return a pair where the second element points to the bound
cursor plane (if it exists), and the first element points to
all other planes.

Change-Id: Ic6a623b10383b7dd0a0c2e79fc2d87329ebc6214
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-02-27 14:52:57 +00:00
Roman Stratiienko
ee6d843ef8 drm_hwcomposer: Rework CreateLayer/DestroyLayer
- Make HwcDisplay CreateLayer/DestroyLayer frontend-agnostic.
- Provide LayerId as an input for CreateLayer. It is necessary to add
  the HWC3 LayerLifecycleBatchCommand feature, where layer ID is
  generated by the client.

Change-Id: I317dcf22461fe4390ced9f0c0c780cffaa3b8f5d
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-18 22:58:58 +02:00
Roman Stratiienko
fb9fed5389 drm_hwcomposer: Use float type to store alpha internally
0.0-1.0F range is a natural way to store alpha value internally,
to be converted later to DRM-specific 0-0xFFFF fixed point type at
DRM layer.

Change-Id: Iedf2b11e53bf38efd08cd4eda1346647b9ff721f
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-05 22:39:35 +02:00
Roman Stratiienko
4e15bfc948 drm_hwcomposer: Support default values for Rect structures
This commit introduces two improvements:
1. Introduces frontend-agnostic structures for rects.
2. Support default values in them so that the backend can handle
   cases where rects are not specified by the client, like
   the client layer display frame, etc.
   This reduces the complexity of the Internal layer, making it
   feasible to use a single Frontend<->Internal layer API for
   regular layers, as well as for the Client and Output layers.

Change-Id: Iab5030ad523d36ea4c5af142f6f628952467d6ab
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-05 22:39:35 +02:00
Sasha McIntosh
851ea4dc26 drm_hwcomposer: Implement getHdrCapabilities and getColorModes
Retrieve color and HDR information from the EDID.

Change-Id: I1aac27644d5c4fd5d5f295ca32b69ed69e94e0c6
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-01-31 13:21:15 -05:00
Roman Stratiienko
da2fcf6676 drm_hwcomposer: Simplify LayerTransform
Fixes clang-analyzer-optin.core.EnumCastOutOfRange clang tidy check.

Change-Id: I0a88d1ef084848c924198e8bd3831533b6578675
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-01-24 23:33:35 +02:00
Drew Davenport
8998f8b04a drm_hwcomposer: Deprecate usage of HWC2 setActiveConfig*
Setting a config is currently implemented by queuing a config change to
take effect at the next vsync. Add HwcDisplay::QueueConfig to support
this functionality, which is implemented using the HWC2
setActiveConfigWithConstraints and setActiveConfigInternal as a
reference.

Implement HWC3 setActiveConfig and setActiveConfigWithConstraints in
terms of HwcDisplay::QueueConfig.

Change-Id: I127f569fe889e7370de1987137345b5b75ff04b6
Signed-off-by: Drew Davenport <ddavenport@google.com>
2024-10-31 10:23:20 -06:00
Tim Van Patten
a2f3efa162 drm_hwcomposer: Implement getDisplayPhysicalOrientation()
Implement ComposerClient::getDisplayPhysicalOrientation() by querying
the DRM display panel orientation property and translating the result to
the correct common::Transform enum value.

The result is used by SurfaceFlinger to correctly rotate the image
before displaying it to the user.

Signed-off-by: Tim Van Patten <timvp@google.com>
2024-10-22 12:05:49 -06:00
Sasha McIntosh
5294f095f6 drm_hwcomposer: Add getter/setter for Colorspace
Optionally, get the Colorspace drm property and populate an enum mapping
for the property types. Add implementation to HwcDisplay::SetColorMode
to set this property and map between HAL_COLOR_MODE types to Colorspace
formats.

Change-Id: Id532e94207c1b1a2623b7d77db239735df18b30f
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2024-10-14 17:32:43 -04:00
Normunds Rieksts
92801fe06c drm_hwcomposer: Disable flattening controller at instance creation time
Disable flattening controller at creation time. Without disabling the
flattening controller, it could result in refresh event being set to
composer clients early before the display is validated which can result
in VTS test failures as it checks for invalid refresh events at
test teardown.

Change-Id: I4a91032fdce1be0a7ee0d26b52914992a95842b5
Signed-off-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Drew Davenport <ddavenport@google.com>
2024-08-30 22:15:14 +00: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
b9bd2712fb drm_hwcomposer: Fix DRM and HWC rotation direction misalignment
[DRM API][1] uses a counter-clockwise direction, while [HWC API][2] uses
a clockwise.

[1]: https://elixir.bootlin.com/linux/v6.5.7/source/include/uapi/drm/drm_mode.h#L172
[2]: https://cs.android.com/android/platform/superproject/main/+/main:hardware/libhardware/include_all/hardware/hwcomposer_defs.h;l=96;drc=e9d7337d9d1edc0d8e3ece246ecde747e345e876
Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/78
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-10-15 02:16:45 +03:00
Roman Stratiienko
22fe9617da drm_hwcomposer: Make flattening thread-based instead of vsync-based
Using vsync means consume some CPU time every frame for
IRQ -> Kernel_Thread -> UserSpace_listener thread transitions.

Framework tries to reduce vsync usage to the minimum, by using timelines
instead.

New flattening controller thread wakes-up only once per second.

This commit also removes flattening info from dumpsys. Practice shows
that it is almost useless. Instead debugging can be done using ALOGV
dumps.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-01-18 19:25:08 +02:00
Roman Stratiienko
359a9d3971 drm_hwcomposer: Propagate acquire fence for test/validate cycle as well
Since acquire_fence is now std::shared_ptr, struct LayerData has default
copy constructor and LayerData::Clone() function is no longer required.
Also we can now remove 'test' argument from HwcLayer::PopulateLayerData
function, since copy operation for acquire_fence is now available.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-01-18 14:59:55 +02: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
bde95666cf drm_hwcomposer: Use pragma once instead of include guards
Some of existing include guards were copy-pasted without modification,
therefore have incorrect name. Switch to 'pragma once' in order to fix
it and avoid such copy-paste issues in the future.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2022-12-10 20:37:34 +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
4b2cc484f9 drm_hwcomposer: Reorganize struct DrmHwcLayer
1. Move BlendMode, ColorSpace, SampleRange fields to the struct BufferInfo,
   allowing extraction of the data from native_handle using Metadata@4 API.
   Use it when data from HWC2 API can't be used (Currently it's a BlendMode
   case for CLIENT layer)

2. Rename DrmHwcLayer to LayerData and move it to compositor/ directory.
   (I was confused in the past because of similarity of names DrmHwcLayer
    vs HwcLayer, so this step should meke it easier for newcomers to
    understand the code)

3. Allow clonning of the LayerData to propagate it through the composition
   pipeline. Thus LayerData can be used by both HwcLayer to track state
   and by the compositor.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-05-17 11:20:44 +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
ef5348b7a5 drm_hwcomposer: Remove AtomicCommitArgs::clear_active_composition field
Now we can use empty DrmKmsPlan to achieve the same goal.

+ Remove unused HwcDisplay::ClearDisplay()

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-09 17:21:32 +02:00