1
0
Fork 0
Commit graph

102 commits

Author SHA1 Message Date
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
Deborah Brouwer
f83c13fd0c drm_hwcomposer: Silence clang-tidy warnings
Currently the clang-tidy CI job is ignoring code guarded by
`__ANDROID_API__ >= 36` so some readability warnings slipped through.

In preparation for updating the ANDROID_SDK_VERSION to 36, silence these
warnings:

  * error: invalid case style for parameter 'maxProfiles'
  * error: all parameters should be named in a function

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 12:23:31 -07: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
Sasha McIntosh
8a7f263bb0 drm_hwcomposer: Replace uint32t with OutputType
Add OutputType enum to DisplayInfo and use throughout.

Change-Id: If90deb5b19e7f61b7d74b9016221f35d09986678
2025-07-23 18:55:52 -04:00
Deborah Brouwer
7aa4c98eb8 drm_hwcomposer: Return error for unsupported DPI
A virtual display provided by vkms does not report a physical width and so
does not support DPI. Currently a missing dpi will returning -1, but this
causes the VTS test GetDisplayConfigsIsSubsetOfGetDisplayConfigurations to
fail. Instead, return a kUnsupported error which the test recognizes.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-07-11 12:37:36 -07: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
7e66322389 Revert "drm_hwcomposer: Initialize stats asynchronously"
This reverts commit e5f755f842.

IStats initialization will be revisited in a follow-up commit. Threaded
initialization will no longer be necessary.
2025-06-25 08:06:32 -06:00
Drew Davenport
e5f755f842 drm_hwcomposer: Initialize stats asynchronously
Since stats reporter may need to wait for the IStats service to start
up, initialize the stats reporter and poller on a helper thread to avoid
blocking ComposerClient::Init, which is run early in boot.

Change-Id: I48949809d33f9aff0fab97822da34d76b7ce8dd9
2025-06-19 15:06:48 -06: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
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
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
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
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
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
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
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
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
Drew Davenport
47c69989c6 drm_hwcomposer: Fix deadlock with flattening
FlatteningController acquires its internal lock first, and then acquires
the global lock in DrmHwcThree::SendRefreshEventToClient.

During normal validate/present, the thread acquires the global lock
first, and will acquire the FlatteningController internal lock in
NewFrame.

Move the "must_validate" flag out of Hwc3Display to remove the need to
acquire the global lock in the SendRefreshEventToClient callback.
Add a std::set to track which displays must be validated, and protect
access to this set with a different mutex to avoid deadlocks.

Change-Id: I62d59252107f9f16a4b8bb43f850115bf327a127
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-11 16:00:37 -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
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
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
Drew Davenport
44a3351102 drm_hwcomposer: Remove HWC2 SetVsyncEnabled
Add a function to enable/disable vsync callbacks to HwcDisplay and
implement the HWC APIs in the frontend by calling into this new
function.

Change-Id: Id4506c870a8488bdd8d25ad025e246a3bcc6619e
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-02 17:51:09 -06:00
Drew Davenport
cfcdbbfa1f drm_hwcomposer: Remove GetDisplayConnectionType and GetDisplayType
GetDisplayType is not used for hwc3, so no frontend work is
required to remove it.

A display can be physical or virtual. A physical display can be internal
or external. Create an enum to cover these three cases (virtual,
internal, external), and add a function GetDisplayType.

Implement related functionality in the respective frontends in terms of
this new function.

Change-Id: I72b0b66d22bc91a7e6d0450469f4c140b2cb91c4
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-02 17:51:09 -06:00
Drew Davenport
931fae3f45 drm_hwcomposer: Remove HWC2 GetDisplayIdentificationData
Expose functions on HwcDisplay to get the edid bytes and port, and
implement the HWC API in terms of those in the frontend.

Change-Id: I74131b165332eb39f2d77fcdd687d231f9ad504f
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-02 17:51:09 -06:00
Drew Davenport
56efeea57b drm_hwcomposer: Remove HWC2 GetDisplayCapabilities
drm-hwc currently only supports one capability
(SKIP_CLIENT_COLOR_TRANSFORM). With recent changes to handle 4x3 CTMs,
this capability is no longer dependent on any display capabilities.

Extract the logic for checking this capability out of HwcDisplay and
into the frontend.

Remove the obsolete HWC2 GetDisplayCapabilities from HwcDisplay and
related conversion helpers.

Change-Id: I7255d52376c390d99246d8dd5eb9642b5d3e2554
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-04-02 17:51:09 -06:00
Sasha McIntosh
12d302c4ab drm_hwcomposer: Remove CTM property check for SKIP_CLIENT_COLOR_TRANSFORM
CTM property does not support 4x4 matrices. Allow client composition in
these cases.

Ensure that when all layers are client composited, we clear DRM CTM.

Change-Id: Id922afff7c2b7a4786ee36c1094892e0ef27fd57
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-03-20 13:54:15 -04:00
Drew Davenport
f638348b22 drm_hwcomposer: Support DisplayCommand.expectedPresentTime
DisplayCommand.expectedPresentTime indicates that the HWC should present
the composition as close to the desired time as possible. It may be that
the desired time is some number of vsync periods in the future.

A drm atomic commit will always present at the next vsync, and there is
no mechanism for userspace to indicate a desired present time.

Lacking a kernel uAPI to support this, an alternative is to sleep in
userspace until the next expected vsync aligns with the expected present
time.

Change-Id: Iad703eed9b0e459194f895339dd604990875f157
Signed-off-by: Drew Davenport <ddavenport@google.com>
2025-03-14 11:38:40 -06:00
Roman Stratiienko
28ec9ee7ec drm_hwcomposer: Support cases where BI is not available
Some legacy grallocs may not provide correct buffer information
for regular buffers. In this case, we should not return an error
and allow the composer to delegate the composition of such layers
to the client.

Change-Id: I69f6923f6c7bf517d8a0bbb473dcc64bbe74f673
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-19 13:42:04 +02:00
Roman Stratiienko
45cdacc21d drm_hwcomposer: Allow skipping round-trip to SF before presenting
PresentOrValidateDisplay feature allows to present composition without
a round trip to Surface Flinger in case the client layer does not have
to be updated. This saves some CPU time.

Change-Id: I7969f90a45525b2d9dfdc12a0006cd9b36ac98ba
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-18 23:52:55 +02:00
Roman Stratiienko
6a765203ab drm_hwcomposer: HWC3: Support batched commands for layer create/destroy
This feature aims to reduce CPU time by reducing the number of SF<->HWC
binder transactions.

See [this SF commit][1] for more information.

[1]: https://android.googlesource.com/platform/frameworks/native/+/96f866c272765474f0f28b4090e15092f55796d8
Change-Id: I5eb1934b614ffabffed077d925c64946fae09050
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-18 22:58:58 +02: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
67b85a625a drm_hwcomposer: Check for error when importing into the mapper
To be more verbose in case of fail.

Change-Id: Ic16bdd4b33e43bdff6f4284082cd83fed58200c4
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2025-02-18 22:31:37 +02:00
Lucas Berthou
30808a20bb drm_hwcomposer: uses edid DTD to get better estimate of dpi
Edid are not the most reliable when it comes to panel size, however it
seems like preferred DTD are slightly more reliable. This change moves
from the drm parse edid display size to the first preferred DTD to try
improve dpi accuracy.
If no preferred DTD is available we still fallback to the display size.

Change-Id: Ibcc95da9f38ba74e9b95b9d68587b38efbed8de2
signed-off-by: Lucas Berthou <berlu@google.com>
2025-02-18 17:19:38 +00:00