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
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
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>
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>
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)
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
Define a ConfigId type to be used for identifying per-display configs.
Cast this to the appropriate type in each frontend.
Change-Id: I4c242fc1f22811b52e0794378234400f38ea1ca7
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
aidl Transform is not used in HwcLayer, so remove it.
Change-Id: I4d9c9d455f37dbb129cd2793635b0aad225fd067
Signed-off-by: Drew Davenport <ddavenport@google.com>
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>
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>
The latter was extracted from the former, so only minor renaming is
needed.
Change-Id: Iea3228b802ddcd16f6840adbf242be3bd61fac60
Signed-off-by: Drew Davenport <ddavenport@google.com>
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>
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>
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>
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>
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>
[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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>