1
0
Fork 0
Commit graph

1140 commits

Author SHA1 Message Date
Drew Davenport
6443ccecc2 drm_hwcomposer: Remove main_lock and protect shared state
Remove the usage of main_lock_ and ensure that mutex_ is held for no
larger a scope than is necessary.

Reorder some class members to keep protected members together.

Change-Id: Iaf29cf53e11d692fb3779b61b147abfcacf95746
2025-06-12 01:39:23 +00:00
Drew Davenport
457c6b2520 drm_hwcomposer: Use queue for tracked KmsObjects
The distinction between active/staged isn't important for state
tracking, so simplify management of these by using a std::queue.

Change-Id: I1871d3c2f5c6e6686baa9b6473bbbb7072077efc
2025-06-12 01:39:23 +00:00
Drew Davenport
9715b7c9e9 drm_hwcomposer: Separate KmsState and KmsObjects
Since the helper thread doesn't need to access KmsState, and we are only
using the most recently committed state, track the KmsState separately
from the KmsObjects.

The tracked KmsState doesn't need to be synchronized with the helper
thread.

Change-Id: Ic62e0753ee11d3870eb31892f18023688558ff9a
2025-06-12 01:39:23 +00:00
Drew Davenport
c75973027a drm_hwcomposer: Use most recently committed state
When preparing the properties for a commit, the state for the currently
active frame is used, rather than the last committed frame. This is
incorrect and could lead to a scenario such as:

- Frame N: commit enables plane 1
- Frame N+1: commit uses plane 1, 2, 3
- Frame N+2: if executed before staged_frame_state_ is moved to
    active_frame_state_, the new KmsState::used_framebuffers will be
    initialized to {1}
  - commit uses planes 1, 2
  - plane 3 is not disabled by the unused_planes code in CommitFrame

A similar problem exists for the KmsState::crtc_active_state.

To avoid this issue, always use the last committed state, regardless of
whether the previous frame has been presented or not.

Change-Id: I840b5b0ca3a3cf477882cacf6b1d5c0313ae80cf
2025-06-12 01:39:23 +00:00
Drew Davenport
80d7c469d5 drm_hwcomposer: Gather kms objects for a commit in a struct
Define DrmAtomicStateManager::KmsObjects struct to distinguish between
objects that are tracked for lifetime management and state that is
tracked for the purpose of preparing subsequent commits.

Change-Id: I5402959f17298102a904b83fbbf01577ae673e48
2025-06-12 01:39:23 +00:00
Drew Davenport
cdf3401f1d drm_hwcomposer: Remove unused struct member
This is not used anywhere, so remove it.

Change-Id: Ic6a885d523d2c0f6b1b725110bf0ca4fb896a95f
2025-06-12 01:39:23 +00:00
Drew Davenport
b9e2bdb8f3 drm_hwcomposer: Add thread annotations for DrmAtomicStateManager
Shared state is protected by a combination of the local mutex_ and the
global lock. This change attempts to document and enforce that more
clearly using clang-tidy thread annotations.

Change unique_lock usage to lock_guard for cases that do not require
release of the mutex such as when using a condition variable.

Temporarily add a main_lock_ mutex which mirrors how
the global lock is being used for synchronization. Lock this at the
entry point to all public methods. This lock will be removed as a part
of subsequent refactoring and it used to more cleanly break up the
following changes in this series.

Some state is not properly protected by any lock, so temporarily disable
the warnings around access to that state until the synchronization is
resolved in subsequent changes.

Change-Id: I6f4f30c4e97f266146b0879c5255d6f2432f12a3
2025-06-12 01:39:23 +00:00
Drew Davenport
19c5d5e973 drm_hwcomposer: Reorder some class members
Ensure that the std::lock is declared early so that it can be referenced
by clang thread annotations.

Change-Id: I64e7290cc6ff6fcdebb119dc2ec7537387f4ae5c
2025-06-12 01:39:23 +00:00
Drew Davenport
6be6ee958d drm_hwcomposer: Use android-base/thread_annotations.h
This file already exists in android-base, so use this instead of
duplicating the macros in this project.

Since the copy in android-base provides a helper class to assist with
std::unique_lock, use that instead of disabling the warnings.

Change-Id: Ib1724045e3eea29946799fb99b3fbcfcc14a5013
2025-06-12 01:39:23 +00:00
Drew Davenport
5623570a56 drm_hwcomposer: Move atom reporter dependency
Some downstream projects use hwcomposer.drm_defaults and define their
own .so with downstream logic.

Move the drm_hwcomposer_atom_reporter dependency into
hwcomposer.drm_defaults to avoid link errors when building such an .so

Change-Id: Ie3ad0d2c923fba1f2f47b4c7b5cdef3e66436c26
2025-06-11 22:36:26 +00:00
Deborah Brouwer
b6f7bd4fec drm_hwcomposer: CI: Stop duplicate pipelines
When a developer pushes changes to a merge request, the current workflow
rules will create two pipelines: one on the developer's fork and another
in the project namespace for the merge request.

To avoid this duplication, only run the pipeline in the project namespace
if a merge-request is open.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-06-10 14:25:29 -07:00
Drew Davenport
3e4b0758a2 drm_hwcomposer: Use atom reporter for HWC3
When initializing the ComposerClient, create a
CompositionStatsAtomReporter and poll the DrmHwc periodically for
stats to send.

By default, the stub reporter is used

Change-Id: I864a3cc8e148b03cc6e693d141d2dcbf6d5c70d3
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-06-10 06:59:57 +00:00
Drew Davenport
129d12f38a drm_hwcomposer: Report composition stats as vendor atoms
The IStats service provides an interface for reporting metrics from
vendor processes through the IStats::reportVendorAtom interface.

The type and ordering of the data in a VendorAtom are determined by a
proto definition which is typically OEM-specific. The code to construct
the VendorAtom is generated from the proto definition.

Add a soong config variable in the DRMHWC config namespace to enable the
atom reporting. Currently there is only one such implementation.
  atom_reporter: Set this to configure OEM-specific atom reporting.

With the config variable omitted, reporting will be disabled and a stub
implementation is used, ensuring no build or runtime dependency or usage
of the IStats service.

Change-Id: I832adbd42412db1ab4c9403c1da60fa075443caa
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-06-10 06:59:51 +00:00
Sean Paul
6f1f89a2c0 drm_hwcomposer: Handle empty damage vector
Unset the damage property in DRM when receiving an empty vector from SF.
The previous behavior was to retain the damage on empty vector, but this
is not HAL compliant behavior.
2025-05-28 16:07:32 -04:00
Drew Davenport
23e05e0b85 drm_hwcomposer: Move common files out of hwc2_device directory
HwcDisplay etc. are shared between frontends and shouldn't live in the
hwc2_device directory.

Change-Id: I4bf3845f6cf7adde5f625a736cc1dffea27e5168
2025-05-23 09:01:32 -06:00
Drew Davenport
9d3be012fd drm_hwcomposer: Remove hwc2 usage from common code
No longer need to #include the hwcomposer2 headers in common code.

Pull the hwc2 specific files into a different filegroup. There is no
need to build these for hwc3. Additionally, no need for hwc2-specific
CPPFLAGS in common or hwc3 code.

Change-Id: Ie194e9dc4b0d8f7b900227bd5d3b73efc692d975
2025-05-23 09:01:32 -06:00
Drew Davenport
d34c094030 drm_hwcomposer: Remove obsolete HWC2<->HWC3 conversion functions
With removal of HWC2 usage from internal layers, these functions are no
longer needed.

Change-Id: Id57bd56307a0e5c078e1a10c3b592e8a8e781c97
2025-05-23 09:01:32 -06:00
Drew Davenport
b9549d9bdc drm_hwcomposer: Remove hwc2_config_id
Define a ConfigId type to be used for identifying per-display configs.
Cast this to the appropriate type in each frontend.

Change-Id: I4c242fc1f22811b52e0794378234400f38ea1ca7
2025-05-23 09:01:32 -06:00
Drew Davenport
ca711e95bf drm_hwcomposer: Remove hwc2_display_t
Add DisplayHandle which is a typedef for int64_t. Use this type instead
of the HWC2 hwc2_display_t type.

Additionally, rename variable names to prefer `display_handle` over
`display_id`, since "DisplayId" is overloaded and carries a different
meaning in the Android framework.

Change-Id: I2a8ecce3b2c19fcd5e945d6c645f83d6a7d27a42
2025-05-23 09:01:26 -06:00
Sasha McIntosh
3b548894ac drm_hwcomposer: Remove SetColorTransform GetHdrCapabilities HWC2 API
Remove HWC2 errors from HwcDisplay::SetOutputType and
SetHdrOutputMetadata.

Change-Id: I67333210abcc4ab9f320cc8d4451564e59db777e
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-22 13:35:37 -04: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
93132f482c drm_hwcomposer: Change HWC2::Error return value to bool
All errors from HwcDisplay::CreateComposition are handled the same way,
so just return a bool. There is no need for a finer grained return code.

Change-Id: I5a10cf2672d377efa715fba8f8eb50cd4c41316f
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-20 12:06:02 -06:00
Drew Davenport
72bd456349 drm_hwcomposer: Remove error handling from PresentStagedComposition
BadLayer could be returned in a few cases:
  1. Client Layer is not usable for device composition
  2. Some layer tagged for DEVICE composition is not usable for device
     composition
  3. Writeback layer is not usable for device composition

In the Validate phase, these errors are handled by falling back to GPU
composition. In the present phase, these are real errors.

The check was supposed to gracefully handle a case where the Client does
a validate/present cycle without having created any layers. This case is
handled by checking for empty layers and returning early, as described
in
https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/merge_requests/354

Any other as-yet-unknown cases where there are no layers to present should not
fail silently and raise an error.

Change-Id: Ie5fc2202936209a80ca8af5c3325520a1897b2e5
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-20 12:06:02 -06:00
Sasha McIntosh
80ffcad89a drm_hwcomposer: Remove Signed-off-by commit requirement.
Change-Id: If4940337f4ad86fed80b33845b441b958334852f
2025-05-20 13:36:18 -04:00
Sasha McIntosh
c469d14a19 drm_hwcomposer: Fixup downstream cherry-picks
Wrap Android16 APIs in an if block to prevent breaking Android15
integration.

s/AidlHdcpLevels/drm::HdcpLevels

Add support for external HDR displays (dropped in previous cleanup).

clang-format-diff-19 nits

Change-Id: I897e0b42e0065a61ecfe28c280094b6c375d8a72
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-20 13:36:18 -04:00
Sasha McIntosh
447858ca48 drm_hwcomposer: Set min bpc on modeset
When HDR10 is the desired output type for the display mode, request a minimum
bpc of 8 from the connector. This ensures the quality of the HDR content and
allows the caller to retry with SDR if there is insufficient bandwidth.

Change-Id: I897e0b42e0065a61ecfe28c280094b6c375d8a72
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-20 13:36:18 -04:00
Sasha McIntosh
7472126b18 drm_hwcomposer: Provide default value for hdrOutputType
Set hdrOutputType to SYSTEM for all configs provided by drm_hwcomposer.

Change-Id: I219d70731be058b85117b63eeed769ecc31e614d
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-20 13:36:18 -04:00
Sally Qi
cb9f3a9742 drm_hwcomposer: add getLuts() aidl interface
This is internal for now due to getLuts() AIDL interface not being public yet and will be submitted together with AIDL change.

And the getLuts() interface is to get luts of input buffer handles.

Change-Id: I8af97262cb31e78318d44370f31f5b9890113183
Signed-off-by: Sally Qi <sallyqi@google.com>
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-20 13:36:18 -04:00
Huihong Luo
85eb9e0ed0 drm_hwcomposer: Sync with new API to start HDCP
When SurfaceFlinger detects a secure surface, it can call this
api to inform HWC to start HDCP negotiations.

Change-Id: Ifce48821ba32c35567d608064c977ecc08fdd5b7
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-20 13:36:17 -04:00
Brian Lindahl
fe82813f55 drm_hwcomposer: Add unsupported stubs for IComposerClient getMaxLayerPictureProfiles
Change-Id: I8623aee6d2f09bf8abeb8ad66de1186346fd5bb6
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-20 13:36:17 -04:00
Sasha McIntosh
094b09d976 drm_hwcomposer: Use latest available composer3 API
This will allow us to cherry-pick downstream changes from Android16
without breaking those using the Android15 source tree.

Add Android15 target to CXXFLAGS so that Android16 APIs are
ignored on CI.

Add ANDROID_SDK_VERSION to ci builds.

Change-Id: I4e37e5ce5b2c2b5dc5134dc8c33f284fe26d4019
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-05-20 13:36:11 -04:00
Deborah Brouwer
851738b8cb drm_hwcomposer: CI: use dev fork to build container
If a contributor is a member of an upstream project, then the built-in
GitLab variable CI_PROJECT_URL points to the upstream project. This
means that a developer's fork in a merge request can't be used to build
a container.

Replace CI_PROJECT_URL and point to the developer's fork repository
instead.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-05-20 09:04:54 -07:00
Drew Davenport
1194dcca56 drm_hwcomposer: Check display type in DestroyVirtualDisplay
Ensure that the display handle to destroy refers to a virtual display
before deleting the display.

Change-Id: I7c284aabdc17cef92051c47d12e4b31ef02ebc9b
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-16 14:01:49 -06:00
Drew Davenport
1cca58e9e3 drm_hwcomposer: Remove HWC2 hooks for Virtual Displays
Change the Create/Destroy virtual display functions on DrmHwc to remove
HWC2 API stuff. Implement the corresponding functions in the HWC3 and
HWC2 frontends in terms of these functions.

Change-Id: I410da9347ccb2cd008cc94b746c2b5604969b57e
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-16 14:01:41 -06: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
Manasi Navare
2d4621a7c3 drm_hwcomposer: Teardown the pipeline and DRM resources on disconnect
This commit properly tears down the display pieline when the
display is disconnected. This frees up the DRM CRTC and other
resources used by the connector. This ensures that the
consecutive hotplugs work correctly to reallocate the CRTCs
when new displays are connected.

This was verified by ensuring the CRTCs, mode, connectors
are freed up in modetest.

This fixes the issue of display not coming back after
screen timeout and fixes the Android VTS SetPowerMode(Off) failures

Fixes: 025ea5bfbb ("drm_hwcomposer: Teardown the pipeline and DRM
resources on disconnect")
Change-Id: Icdca56433b5cd565d1658b1a415565adc7980088
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-05-15 17:22:28 +00:00
Drew Davenport
3ea1c36308 drm_hwcomposer: Remove obsolete function declaration
It looks like this function was removed at some point but the
declaration is still there. Remove it.

Change-Id: Ia75f6a9312aeaeca24a078714ebafdacaabdc160
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-05 14:53:01 -06:00
Drew Davenport
be12e81b02 drm_hwcomposer: Remove HWC2 from HwcDisplayConfigs
Change Update function to return a bool to indicate success rather than
a HWC2::Error.

Remove the hwc2 #include since it's no longer necessary

Change-Id: I7896d9e6ede68cd4052f2c942fa0b6637ecaa390
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-05 14:53:01 -06:00
Drew Davenport
eb6fe09ca1 drm_hwcomposer: Remove unnecessary #include
aidl Transform is not used in HwcLayer, so remove it.

Change-Id: I4d9c9d455f37dbb129cd2793635b0aad225fd067
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-05 14:53:01 -06:00
Drew Davenport
7e573a50c9 drm_hwcomposer: Remove HWC2 CompositionType
Remove HWC2 CompositionType from midlayers. Define a new
HwcLayer::CompositionType enum to capture all composition types
supported by drm-hwcomposer.

HWC2 and HWC3 frontends do the necessary conversion to/from
HwcLayer::Composition type.

Since the last HWC2 usage has been removed from HwcLayer, remove the
hwc2 #include.

Change-Id: I00d579d699599f0918d114b35080933348aa513b
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-05-05 14:52:56 -06:00
Drew Davenport
3b62014b4a drm_hwcomposer: Refactor dumpsys handling
Add a CompositionStatsTracker to DrmHwc which queries the displays'
stats, and keeps track of their deltas.

Extract the output formatting from HwcDisplay into DrmHwc.cpp

Change-Id: Ie3c586b18549564bcc3a05d27b0d1fba0297f0ef
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-29 14:13:04 -06:00
Drew Davenport
771eacda69 drm_hwcomposer: Replace HwcDisplay::Stats with CompositionStats
The latter was extracted from the former, so only minor renaming is
needed.

Change-Id: Iea3228b802ddcd16f6840adbf242be3bd61fac60
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-29 14:13:04 -06:00
Drew Davenport
98360f9e0c drm_hwcomposer: Add CompositionStats
CompositionStats struct is a copy of HwcDisplay::Stats and is extracted
from HwcDisplay as a prestep for supporting stats reporting beyond
dumpsys.

CompositionStatsProvider interface can be implemented by a class that
will poll all displays and return a display->CompositionStats map for
the cumulative stats for each display.

CompositionStatsTracker is a helper class that tracks the state of the
last queried stats and calculates the delta between the last stats and
the currently pulled stats. A Callback function can be passed into the
Report function which will be called for each display, with the
cumulative and delta stats as arguments.

Change-Id: I4200df5b41a4dbc612160aec038c83336b68bc4b
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-29 14:12:59 -06:00
Drew Davenport
aeaddd3233 drm_hwcomposer: Remove HWC2 Dump interface
Rewrite DrmHwc::Dump to return a string, rather than directly
implementing the HWC2 interface.

Rewrite the HWC3 frontend Dump implementation to return this string.
Rewrite the HWC2 frontend Dump implementation to cache the string in the
frontend so that the dump string size/contents can be fetched
separately.

Change-Id: I9c286f047bb67a05ced4f0e9778679c32175084c
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-29 11:28:08 -06:00
Deborah Brouwer
6066d0a628 drm_hwcomposer: CI: run VtsHalGraphicsComposer3_TargetTest
Add a new job to run VtsHalGraphicsComposer3_TargetTest on newly
built drm-hwcomposer.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-04-23 13:09:43 -07:00
Deborah Brouwer
e6fed773a2 drm_hwcomposer: CI: run CtsDisplayTestCases
Add a job to run CtsDisplayTestCases on newly built drm-hwcomposer.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-04-23 13:09:43 -07:00
Deborah Brouwer
399f97fb89 drm_hwcomposer: CI: run CtsGraphicsTestCases
Add a job to run a subset of relevant tests from CtsGraphicsTestCases on
newly built drm-hwcomposer.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-04-23 13:09:43 -07:00
Deborah Brouwer
9cd6b239ff drm_hwcomposer: CI: Add script to launch cuttlefish
Add a script to launch cuttlefish and run drm-hwcomposer in it.

This script expects that the compressed cuttlefish image and the
drm-hwcomposer binaries will be provided to it as artifacts earlier in
the CI pipeline.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-04-23 13:09:43 -07:00
Deborah Brouwer
a9336a9499 drm_hwcomposer: CI: Add job to make cuttlefish artifacts
Add a new job `use-debian/x86_64_cuttlefish` to extract the compressed
cuttlefish image from the cuttlefish container and make it available as
a short-lived artifact for use by subsequent jobs in the pipeline.

The cuttlefish images need to be accessed as artifacts because the
cuttlefish container itself does not include all of the android tools
and tests needed to run cts and vts jobs.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-04-23 13:09:43 -07:00