1
0
Fork 0
Commit graph

1034 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
Drew Davenport
bd61cdab1f drm_hwcomposer: Make CleanFailedCommit private
This is only called from DrmAtomicStateManager so make it private.

Change-Id: I2ad884875514e910fc664e74fc546dbb51821f7e
2025-09-05 14:57:05 -06:00
Drew Davenport
5c7f0d6e53 drm_hwcomposer: const-correctness
Make AtomicCommitArgs const in the different helper functions to build
the AtomicRequest. Additionally, reorder the parameters to reflect the
convention that input parameters are listed first, and out parameters
are listed after.

Change-Id: I0277ec4129fbcd6312e6df9ae3f15600e9755520
2025-09-05 14:57:03 -06:00
Drew Davenport
9e59a16a2c drm_hwcomposer: Don't reset writeback fence
It's not necessary to close the fence after waiting.

Change-Id: I6cfa4dc9e2cfa9fff8a2d40a50b4badf8cb7ce1f
2025-09-05 14:55:26 -06:00
Drew Davenport
faab5a4912 drm_hwcomposer: Make some structs private
Move structs definitions that are only used inside the
DrmAtomicStateManager class to private.

Change-Id: I6f3c48cf14645dae721d0e4f9d9b1e5767f08914
2025-09-05 14:55:24 -06:00
Drew Davenport
c4c008f63a drm_hwcomposer: Use AtomicRequest struct
Add AtomicRequest struct to wrap the pending DrmModeAtomicReq and
related kms objects and state for the pending atomic commit.

After the AtomicRequest's property set has been committed, update the
internal DrmAtomicStateManager state to reflect what has been committed.

Change-Id: I49d39649eb957d69f724b53b91577a347a75527e
2025-09-05 14:54:55 -06:00
Drew Davenport
88527cddf2 drm_hwcomposer: Clear new frame state
Rather than initializing the state associated with a new frame by
copying committed_frame_state_, check committed_frame_state_ directly
when needed.

Change-Id: I62043e15e70669ce6a8ac4635101d13d8efd7f15
2025-09-05 13:42:58 -06:00
Andrew Wolfers
9e75410677 drm_hwcomposer: Fix cursor positioning
In some cases, the position of the cursor is controlled by the src rect.
For example, this is done when the cursor extends beyond the top or left
edges of the screen. This is not compatible with the hw cursor plane
however, because scaling and panning are both disallowed. As a workaround,
the position of the dst rect needs to be adjusted in the opposite
direction (in some cases taking a negative-valued position,) which
will correctly position the cursor while also assigning an acceptible
value to the src rect.

Change-Id: Ide7f75e01481bcd602a33d222d1ae6862703a1cd
2025-08-28 17:32:50 +00:00
Sasha McIntosh
9ad5a95efc drm_hwcomposer: Disable non-native color modes
drm_hwc currently does not support tone mapping. This causes a visual
color flickers when switching between CLIENT and DEVICE composition.
Temporarily disable non-native color modes until tone mapping work is
completed.

Change-Id: I114a12c474990a5a81181c52307469c7b139a2b0
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-08-27 17:31:18 -04:00
Drew Davenport
a9e13211a6 drm_hwcomposer: Start making HwcDisplay const in Backend
Add some const correctness to HwcDisplay. Narrow the public
interface of HwcDisplay to avoid exposing non-const members
unnecessarily.

Change-Id: I691c9e0025065085ca1e2045bb1d6614535fdbdc
2025-08-27 13:01:59 -06:00
Drew Davenport
67a09e278f drm_hwcomposer: Use PRId64 format
Address compiler warning on some toolchains.

Change-Id: I72a83d09e53e72909ecdcb0b15eff829a2299eed
2025-08-27 12:21:49 -06:00
Drew Davenport
df0954ca7d drm_hwcomposer: Rename CreateComposition->CommitComposition
Since CreateComposition is only being used in the present path, rename
it to CommitComposition to indicate that it's going to commit the
composition that was previously created during Validate.

Change-Id: Ia4627ff1e32b655273421510f8e1b844c6dd5e06
2025-08-26 09:27:21 -06: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
eb46a0dae5 drm_hwcomposer: Move client_layer.Populate to present
The client layer may be updated as part of Present, since the Client
doesn't know if the client layer is used or not until after Validate is
complete.

Move PopulateLayerData call out of CreateFrameUpdateCommit so that
CreateFrameUpdateCommit doesn't modify HwcDisplay state.

Change-Id: I0a78075f9476e0d27111b860b6a39fb46814b235
2025-08-26 09:27:21 -06:00
Drew Davenport
c75316c28e drm_hwcomposer: Return DrmKmsPlan from Backend
DrmKmsPlan lifetime is used to manage ownership of drm planes that have
affinity for multiple crtcs. As such, the DrmKmsPlan lifetime needs to
persist from a Validate call to when the composition is Presented to
ensure that such planes aren't stolen by another display.

Rather than stashing the DrmKmsPlan as part of TestComposition, return
the DrmKmsPlan as part of the Backend's Validate. HwcDisplay::Validate
then becomes responsible for lifetime management of the resulting
DrmKmsPlan as before.

Change-Id: I14ae115b2eed5c9b27e70f0b695fbbc4f3a4faa6
2025-08-26 09:27:21 -06:00
Drew Davenport
b288993101 drm_hwcomposer: Extract CreateFrameUpdateCommit
Extract the functionality to create the AtomicCommitArgs for a frame
update and call this from the TestComposition and CreateComposition
paths.

Change-Id: Ibb0695fd37e9f43eb8f97b3fd901109839d0f9ea
2025-08-26 09:27:11 -06:00
Drew Davenport
eaf305ebc2 drm_hwcomposer: Move state update to new function
Extract the parts of HwcDisplay that update HwcDisplay state post-commit
into a new function.

Change-Id: I2d5e69bb86f84b7b897ad71ea719480302f60f56
2025-08-25 16:50:24 -06:00
Drew Davenport
0fee963917 drm_hwcomposer: Use a_args.mode for state update
Rather than using next_config to determine if there was a config change
during the frame update, check the a_args.

Change-Id: Ib71dd3d542d7915e1fbfba0045c1d604382b1aab
2025-08-22 14:19:18 -06:00
Drew Davenport
7f8cf905cd drm_hwcomposer: Make CreateComposition private
This is only called internally from HwcDisplay, so make it private.

Change-Id: I8abb7ac313a450d56a2085738a2ece58350e8b8f
2025-08-22 14:15:52 -06:00
Drew Davenport
f20d3cc4da drm_hwcomposer: Move state update to the end
Change-Id: I47871438b08db3eafe53cd151d41ca904f59dd26
2025-08-22 14:15:46 -06:00
Drew Davenport
a120b869df drm_hwcomposer: Calcuate better estimate for refresh_time_ns
QueueConfig allows for a seamless refresh rate change to be queued at
some arbitrary point in the future.

Previous behavior was to report `desired_time` as the time to request
a new frame from the client to apply the refresh rate change. Since
`desired_time` could be any arbitrary point in time, this may not align
with the current refresh rate.

This change addresses a failure in
SetActiveConfigWithConstraints_Delayed exposed by the previous change to
avoid setting the active_config_id until a full commit.

Change-Id: I92888cd1a6a330455f9e7e496d6900d494605248
2025-08-22 12:11:07 -06:00
Drew Davenport
9587a01f71 drm_hwcomposer: Don't set active_mode for test commit
HwcDisplay internal tracking state should only be modified for the
commit, not for the test commit

Change-Id: Idd63e300e724ff1b6986362d2b47e7b024346e05
2025-08-21 10:55:16 -06:00
Andrew Wolfers
8674bc34a4 drm_hwcomposer: Enforce type consistency in Backend
This change cleans up some typing within Backend around data which
was inconsistently being handled as int, uint32_t, or size_t. This
change resolves an instance of integer underflow.

Change-Id: I4a2aa352b6cb4d1ff74929eb67c7edfc907cdb0c
2025-08-20 11:58:44 -06:00
Deborah Brouwer
a59c50f641 drm_hwcomposer: CI: Update CTS test names
In Android 16, some CtsGraphicsTestCases test names have changed which
causes the module to fail. Update the test names.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 15:22:58 -07:00
Deborah Brouwer
d1b819b89d drm_hwcomposer: CI: Add CTS skips file
Android 16 added a new test, GetSupportedRefreshRatesIsDivisorRate,
which will fail when CI is updated to Android 16.

Add the ability to skip a CTS test and skip this test for now.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 15:22:58 -07:00
Deborah Brouwer
1771c8fd66 drm_hwcomposer: CI: Update container tags
Force all containers to rebuild to implement the Android 16 changes.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 15:22:58 -07:00
Deborah Brouwer
bf2035bc2f drm_hwcomposer: CI: Update launch-cvd for Android 16
Update the commands for launching cuttlefish, since they changed slightly
between Android 15 and Android 16.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 15:22:58 -07:00
Deborah Brouwer
4c03575eb0 drm_hwcomposer: CI: Android: Use Android 16
Update the android container to include all of the packages, tools, and
tests that are up-to-date with Android 16.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 15:22:58 -07:00
Deborah Brouwer
abdb5fa5b8 drm_hwcomposer: CI: aospless: Use Android 16
Update the aospless container to work with the Android 16 repositories.
This ensures that aospless can still be used to build drm-hwcomposer
binaries for Android 16.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 15:22:58 -07:00
Deborah Brouwer
5d47be1918 drm_hwcomposer: CI: cuttlefish: Use Android 16
Build the cuttlefish device for Android 16. This keeps CI coverage
as complete and up-to-date as possible.

Since Android 16 deprecates builds with make, temporarily stop using mesa
libraries with the intention of adding a Soong build of mesa in the
future.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 15:19:03 -07:00
Deborah Brouwer
ea5689b295 drm_hwcomposer: CI: Update to Android 16
In preparation for rebuilding all CI containers to use Android 16,
update CI/build variables to use Android 16 and Android SDK 36.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 14:52:08 -07:00
Deborah Brouwer
3312d98b61 drm_hwcomposer: CI: Save CTS failure logs
When $FDO_CI_BASH_HELPERS was added, it included an ERR trap that is
triggered when a cts failure is found in the invocation summary. This
prevents the full cts logs from being saved in the job results.

Revise the cts failure check to avoid triggering the trap on error and
allow the full cts logs to be saved.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 14:52:08 -07:00
Deborah Brouwer
91403abf73 drm_hwcomposer: Add Meson dependency on base
Since libbase is now part of hwcomposer.drm_defaults, meson builds also
need the `base` dependency to avoid linking errors.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-08-19 12:23:31 -07: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
ae70ed5bf1 drm_hwcomposer: Add HwcDisplay::TestComposition
Call this from the Backend when testing a composition. Future commit
will make this a const function to indicate that it doesn't change
HwcDisplay internal state.

Change-Id: I9bd6962e213acd76d13afbdc620418bd1ff95557
2025-08-19 09:16:22 -06:00
Drew Davenport
4a84e27035 drm_hwcomposer: Make HwcLayer const in Backend
Backend shouldn't directly mutate HwcLayer state, so make HwcLayer
const. Make a few other related functions const correct as well.

Change-Id: Id7f8e255e9e72b756399b1a4dabc3db779d64bc9
2025-08-19 09:16:22 -06:00
Drew Davenport
728701adba drm_hwcomposer: Rename Backend::MarkValidated
Rename to GetCompositionTypes to reflect that the function is no longer
setting HwcLayer state (marking). Also make the input |layers| const
since it's no longer being modified.

Change-Id: I53702a6df680b9a138bb16191a3cac0b17e4b632
2025-08-19 09:16:22 -06:00
Drew Davenport
b29c974d70 drm_hwcomposer: Return composition decision from backend
Rather than setting the ValidatedType on the layers directly from the
Backend, return the per-layer composition type decisions from the
Backend and let the HwcDisplay set it.

This is a step towards the goal of not setting HwcLayer state directly
from the Backend.

Change-Id: I8e2d1e7c6fb0d9071d5dca101ddb455b95535bd0
2025-08-19 09:16:22 -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
3a403db8d3 drm_hwcomposer: clang-format: Derive pointer alignment
Explicitly set DerivePointerAlignment: true to avoid spurious
clang-format corrections and keep the project consistent with itself.

Change-Id: I2928adebf8c56743ffe910f5026d501beda8941f
2025-08-19 09:16:22 -06:00
Drew Davenport
704a0b9398 drm_hwcomposer: Set value for hdrOutputType for fake config
GetDisplayConfigurations_hasHdrType fails for headless displays since
the hdrOutputType is not initialized for fake modes. Set fake modes to
kSystem instead of kInvalid.

Change-Id: I051dc742b4786bbb0bf8a9384a6d3cde536eebce
2025-08-15 14:42:11 -06:00
Drew Davenport
b800732193 drm_hwcomposer: Handle headless display in IsWritebackSupported
IsWriteBackSupported is called on a display as part of
getReadbackBufferAttributes. If this is called on a headless display,
then it will result in a null ptr dereference.

Check for headless display and return 'false' in this case.

Change-Id: Ia492dec338ab65457670e3b22c2e8582031aa129
2025-08-15 14:42:11 -06:00
Gil Dekel
860b363563 drm_hwcomposer: Defer display rect update to prevent state pollution
A test commit or failed modesets, particularly when with modes of a
different resolution, would cause all subsequent pafe-flip commits to
fail.

The root cause was a premature state update within
SetDisplayModeIfNeeded. The `whole_display_rect_` member was being
modified during the commit preparation phase. This polluted the state
manager's internal view of the active display size, causing subsequent
frame compositions to be built with incorrect dimensions, which were
then rejected by the kernel on certain drivers that cannot handle
scaling on the fly.

This change fixes the issue by deferring the state update until after a
commit is successfully applied:

1. `whole_display_rect_` is now only updated inside `CommitFrame` after
   a modesetting commit has been successfully applied to hardware.

2. `SetCompositionIfNeeded` is updated to use the dimensions from the
   incoming `args.display_mode`, if available, when preparing a modeset.
   Otherwise it will use the existing size in `whole_display_rect_`.
   This ensures the plane is correctly configured for either the
   requested mode, or the currently active one (for page-flips).

This prevents test-only operations from having side effects and ensures
the state manager's internal state remains consistent. It also prevents
state pollution on failed modesets.

Change-Id: Icf08b32c13879d394f883f34e6fed3d96a748a4f
Co-authored-by: Lucas Berthou <berlu@google.com>
Signed-off-by: Gil Dekel <gildekel@google.com>
2025-08-13 13:09:01 -04:00
Andrew Wolfers
f693821f25 drm_hwcomposer: Remove cursor condition from CalcPixOps
CalcPixOps determines the cost of GPU-composition over a range
of layers. This change removes cursor-specific logic that was
accounting for behavior that only applies when the cursor is
not GPU-composited. This change restores the standard logic,
so that the cost of GPU-compositing the cursor layer is corrected.

Change-Id: I310fd35e2cd4f4df6d334ae0d989f2298267323a
2025-07-31 13:00:16 +00:00
Deborah Brouwer
5223ac611e drm_hwcomposer: Skip seamless test when headless
Currently the seamless modeset test will segfault when attempting to
access the connector for a display running in headless mode.

Skip the seamless test if the display is running in headless mode.

Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
2025-07-30 14:55:45 -07:00
Gil Dekel
3b2050b7f2 drm_hwcomposer: Re-enable MRR on AL devices
Configuration groups for the Multiple Refresh Rate (MRR) feature support
is currently disabled in DRM HWComposer. This is because it is
insufficient to group modes solely based on their active region size.

The primary reasons for this insufficiency are:
1. drm-hwc clients may assume they can seamlessly switch between
   configurations within the same group to support variable refresh
   rates.
2. Not all System-on-a-Chip (SoC) architectures support seamless mode
   transitions.
3. For SoCs that do support seamless switching, transitions often depend
   on other hardware-specific properties like matching blanking periods.
4. A fallback to a non-seamless (blocking) modeset is unacceptable for
   internal displays if a seamless transition fails, as this causes
   flickering. The current framework does not handle such failures
   gracefully.

To Resolve these challenges and re-enable seamless Multiple Refresh-Rate
transitions on internal panels, we add logic to validate all configs
against the preferred initial active config. This validation preforms a
seamless modeset test on each available config against the config that
was set during the display initialization. Configs that fail the
screening are assigned new group IDs.

Caveats:
1. Currently, this is only implemented for internal panels. External
   display seamless transition between variable refresh rates is not
   support. However this work can be extended to support seamless
   transitions on external displays as well.
2. Grouping is only preformed for the preffered/active config at the
   time of display init, and is valid only for the duration of the
   current full modeset commit. No other groups are not created (since
   they cannot be validated), and any new full commits will not honor
   the guarantee provided by the check. This work can be extended to
   refresh and validate all configs within the same group ID of any
   incoming full modeset commit.

Change-Id: Ie2661e74bd3ff704b40c8c7ef50c56e604e5e8df
Signed-off-by: Gil Dekel <gildekel@google.com>
2025-07-29 16:14:12 -04: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
Gil Dekel
109a3d3553 drm_hwcomposer: Return bool for CommitFrame and ExecuteAtomicCommit
Error codes are never checked and working with errors as booleans
results in somewhat counter-intuitive logic.

Change CommitFrame() and ExecuteAtomicCommit() to return bools instead.

Change-Id: I5e8041fd4ddc99ef06184081a7f6def028bbe356
Signed-off-by: Gil Dekel <gildekel@google.com>
2025-07-29 14:47:47 -04:00