1
0
Fork 0
Commit graph

191 commits

Author SHA1 Message Date
Andrew Wolfers
5337905df6 Cleanup includes in hwc2_device/ per IWYU style
Change-Id: If7440aa7796ea8d48cb2767ae3a57d853d535135
2025-11-11 19:14:30 +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
Drew Davenport
f119d34769 Rename Backend to CompositionPlanner
With the Backend concept expanding to also include the initial display
configuration and creation of DrmDisplayPipeline, rename the Backend
class to more precisely reflect its purpose.

Change-Id: I8a9a0d49242771e5df6e80cd50f0b2b0670c2de2
2025-10-30 12:07:09 -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
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
Gil Dekel
a4016556d0 drm_hwcomposer: GetDisplayConfigs prunes disabled configs
At some point, probably when migrating to hwc3 and creating/refactoring
HwcDisplay, we stopped pruning disabled configs before returning them
via GetDisplayConfigs().

Ensure disabled configs are pruned if disabled.

Change-Id: Iae3600d5e9b84cb3bb724949da82d42d5b801acd
Signed-off-by: Gil Dekel <gildekel@google.com>
2025-07-29 16:14:12 -04:00
Gil Dekel
fb39c8c899 drm_hwcomposer: Prefer seamless configs, fallback to blocking
The `future_config` feature is not currently used, and incoming changes
will most likely dub it obsolete. Removing it and making QueueConfig
always seamless makes more sense.

In addition, try to always queue a seamless config first, adding it to
the next pageflip commit to reduce jank. If seamless is not allowed (no
active mode or the new config is not within the same group_id, fallback
to a full blocking modeset commit.

Change-Id: I64dec41a93ba4f29bee501f7227b6f6961c9eb44
Signed-off-by: Gil Dekel <gildekel@google.com>
2025-07-29 16:14:05 -04:00
Sasha McIntosh
3ebd9367db drm_hwcomposer: Cleanup ANDROID_API references
Target version is now 35 and set in .gitlab-ci.yml. Remove API check for
version 35 and lower.

Change-Id: I083e5e347749e79f628c839d61fe997ed0c9bef2
2025-07-25 13:41:23 -04:00
Manasi Navare
277f1dfd9a drm_hwcomposer: Return an error corresponding to EX_CONFIG_FAILED for config failure
This commit adds a new ConfigError::kConfigFailed corresponding to the new
exception EX_CONFIG_FAILED.
SetConfig() should return this error if the requested config fails to be
committed.

Bug: b/391891910
Test: m drm_hwcomposer

Change-Id: Ie2ca26ff870324dc9016d32ffeb4382608f4d140
Signed-off-by: Manasi Navare <navaremanasi@google.com>
(cherry picked from commit 23bcfb7bc598f187380179b20695b648be3ff015)
2025-07-02 01:35:08 +00: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
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
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
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
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
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
Drew Davenport
9de3f5cdd3 drm_hwcomposer: Clean up Backend interface
Backend::Validate function signature reflects the corresponding HWC2
function signature. The return value and arguments are redundant.

- Remove the return value, since Validate never fails and it wasn't used
  anyways.
- Remove the out params, since the same information can be (and is)
  determined by comparing the SfType and ValidatedType for each layer

Change-Id: I659f7e0b03f183c38ca0a6996c0546eb263e7b99
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-17 15:07:00 +00:00
Drew Davenport
9d43873b2b drm_hwcomposer: Remove legacy GetDisplayName
Remove the HWC2 GetDisplayName hook from HwcDisplay and replace it with
a function that simply returns the std::string.

Implement the HWC2 and HWC3 frontends in terms of the new
HwcDisplay::GetDisplayName.

Change-Id: I8230294bb7195b6d011ea450fafb80db8c9c5f50
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-15 12:16:43 -06:00
Drew Davenport
0113d20d46 drm_hwcomposer: Remove HWC2 LegacyGetDisplayConfigs
This was only used by the HWC2 frontend. Move the function to
hwc2_device.

Change-Id: I4b539e9a37ea09bd577eadd44c205e17230a5a6b
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-15 12:16:43 -06:00
Drew Davenport
2600a3d487 drm_hwcomposer: Remove HWC2 GetDisplayAttribute
This was only used by legacy HWC2. Move it to hwc2_device with the
implementation based on that in ComposerClient.

Change-Id: I645210ef11cd6c452549aef3c893f0edba21fd88
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-15 12:16:43 -06: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
Drew Davenport
c8ace00f91 drm_hwcomposer: Remove HWC2 SetActiveConfig
Move the function to the HWC2 frontend, and implement the function in
terms of HwcDisplay::QueueConfig

Change-Id: Ia47503ac7463041c36ed4e6ad5374b3491019c2d
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-10 13:46:04 -06:00
Drew Davenport
44111f0af7 drm_hwcomposer: Use blocking config for Init
This ensures that the display has been configured successfully before
returning from Init. Currently any configuration error is just logged.

Change-Id: I35c807892e013e366b2f4068713ccf45df7c6595
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-10 13:46:04 -06:00
Drew Davenport
7efc0f1c1d drm_hwcomposer: Handle headless display in SetConfig
For the headless display case, set the active config and early out to
avoid accessing a null pipeline.

Change-Id: I064b23e65dc227592dda75e888b294b8a25f6cf2
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-10 13:46:04 -06:00
Drew Davenport
b08814ab3c drm_hwcomposer: Remove ChosePreferredConfig
This is only called from Init, so move the implementation to there.
Additionally, move it to the end of Init, which is fine since there is
no interdependency between ChosePreferredConfig and the rest of the Init
function.

With the logic moved to the end of the function, refactor the
conditionals to simplify, while ensuring that SetActiveConfig doesn't
get called when updating the configs fails.

Change-Id: I2cb5964f562413df70005666529ae2c820a1e5f9
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-10 13:46:04 -06:00
Drew Davenport
0e81fcc60d drm_hwcomposer: Remove SetActiveConfigInternal
This is only used from SetActiveConfig, so there's no need for a
separate function.

Change-Id: Ib2131bb98048010d22331654659ee5daef8fde1d
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-10 13:46:04 -06:00
Drew Davenport
52c8fd71d7 drm_hwcomposer: Change HwcDisplay::Init return value
Rather than a HWC2::Error, return a bool to indicate success or failure.
Additionally, check the return value in SetPipeline and log when Init
has failed.

Change-Id: I9918284f101281a98165eca7c1aef13a251f84d4
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-10 13:46:04 -06:00
Drew Davenport
f25f015033 drm_hwcomposer: Don't import fb when headless
Headless displays don't have a pipeline, so don't attempt to import the
framebuffer when slots are updated.

Change-Id: Ifbcb8d81bb9761d412aafadf35b10cdd78bfcf09
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-09 13:38:41 -06: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
Drew Davenport
e83714e737 drm_hwcomposer: Call PopulateLayerData earlier
Call PopulateLayerData in ValidateStagedComposition before calling into
the Backend. This allows the Backend to use the LayerData when deciding
the layer->plane mapping.

The client layer still needs to be populated lazily, since it may not
have a valid buffer set until a subsequent Present.

Change-Id: I5886506b6b82547cdf813fae82dfe77779cb9b2b
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-07 16:24:37 -06:00
Drew Davenport
928d2a81de drm_hwcomposer: Import framebuffer when slot is updated
Import the framebuffer when a buffer slot is added/updated. Simplify the
logic around buffer import, since it's no longer dependent on the active
slot.

Drop buffer_import_failed_ and check whether the slot's fb handle is
null instead.

Change-Id: I81a8d8509db3590bbde6ef2cae6e469cbdfba40d
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-07 16:24:37 -06:00
Andrew Wolfers
3aa544e249 drm_hwcomposer: Add cursor stats
This change adds stats for commits that use the cursor plane.
The failed_kms_cursor_validate_ stat is incremented whenever a
test commit fails which attempted to match a layer to the cursor
plane. This event was previously being tracked by the
broader failed_kms_validate_ stat, but this change disentangles
the two events to help with debugging.

This change also adds a stat which tracks the number of frames
which successfully commit to the cursor plane.

Change-Id: I3f23e3e1d4bfd5ac70d2ceb1d768a2ded8ee034b
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-04-07 18:05:34 +00:00
Drew Davenport
9805b1bac1 drm_hwcomposer: Handle empty and cursor-only composition
It's possible for the client may validate/present a composition without
any layers. Early out in this case. This avoids a spurious
failed_kms_validate_ when CreateComposition returns an error in this
case.

Reduce the error in HwcDisplay::CreateComposition to a warning, since
the rest of the code should work even if an empty DrmKmsPlan is created.

Additionally, the error in HwcDisplay::CreateComposition did not
handle the case where the only layer is the cursor. This case is now
handled by checking for an empty composition at the higher level.

This case is hit in GraphicsComposerAidlCommandTest#PresentDisplay.

Change-Id: I03e5accc3ccda18426908d7d163f23d81c3145ea
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-04 11:22:39 -06:00
Drew Davenport
12bca98c92 drm_hwcomposer: Remove HWC2 SetPowerMode
drm-hwc only supports setting power mode on and off. Add a new function
to HwcDisplay to enable/disable the display, and implement the HWC API
in the frontends in terms of this.

Change-Id: I7a3d92140f4b98bbed9000489e06b8011546ce7e
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-02 17:51:09 -06:00