1
0
Fork 0
Commit graph

63 commits

Author SHA1 Message Date
Konsta
22ba81cf61 Merge remote-tracking branch 'freedesktop/main' into android-16.0 2025-11-12 22:01:44 +02:00
Su Hong Koo
406a14f111 Add atom reporting for modes on hotplugged displays
Add and use DisplayHotplugConnectModeDetectedAtomReporter, which logs
all valid modes of a hotplugged display.

Change-Id: Ie93487ad8e4936195e3d949ce46034c5ec4fda83
2025-11-12 12:31:12 -05:00
Konsta
69629f8907 Merge remote-tracking branch 'freedesktop/main' into android-16.0 2025-11-11 23:09:59 +02:00
Andrew Wolfers
e5e417b11c Cleanup includes in hwc/ per IWYU style
Change-Id: Ib5b29020b673c939e80d7a716eec25be12d9131d
2025-11-11 19:14:35 +00:00
Konsta
56cb319f29 Partially revert "drm_hwcomposer: Produce stable port IDs"
* Android Automotive configurations rely on hardcoded port ids.
  These are used on EVS camera configuration and configuring instrument
  cluster on secondary display.
* On Pi 5 the reverted commit changed the port ids for HDMI-A-1 and HDMI-A-2
  from 0 and 1 to 32 and 33, respectively.
* Doesn't produce stable ids between rpi4 and rpi5 where there are different
  number of drm cards and in different order.
* Lets keep running number from 0 for now vs. what 3/5 bit split would
  produce on rpi4 and rpi5.

  rpi4:
  card0 - HDMI-A-1, HDMI-A-2, DSI-0 & DSI-1
  000 00000 -> 0
  000 00001 -> 1
  000 00010 -> 2
  000 00011 -> 3

  rpi5:
  card1 - HDMI-A-1 & HDMI-A-2
  001 00000 -> 32
  001 00001 -> 33
  card2 - DSI-0
  010 00000 -> 64
  card3 - DSI-1
  011 00000 -> 96

* Only revert the relevant part to avoid merge conflicts.

This partially reverts commit 907a51ab1b.
2025-11-10 15:56:28 +02:00
Konsta
adcc927bd4 drm_hwcomposer: Add property to disable HDR
* It has been reported that HDR is not working properly on Raspberry Pi
  with HDMI displays that support it.

Change-Id: I31f9d7bb5a3f81eeca1f98a72c26786d97edc28d
2025-11-10 15:56:28 +02:00
Andrew Wolfers
5ee173b752 Rename DrmKmsPlan to LayerToPlaneJoiningPlan
Change-Id: I3824e57e3d890f4c59d48e1c7045cb0b7b649583
2025-11-06 18:32:13 +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
Drew Davenport
786939db2b Make Backend a member of DrmDisplayPipeline
Make Backend a member of DrmDisplayPipeline and move the creation of the
Backend to where the DrmDisplayPipeline is created.

Change-Id: Ib7b799df5a2ba16015b7072b0e5ce89a174932c3
2025-10-30 09:27:28 -06:00
Drew Davenport
b112216f38 Use new BackendManager::CreateBackendForConnector
Remove the old CreateBackendForDisplay and related functions that are
now obsolete.

Change-Id: Ic41c065b65a50e6a68ccc1e40b210e5aed6d009e
2025-10-30 09:27:28 -06:00
Andrew Wolfers
81071ba3ce Restore cached DrmKmsPlan reuse
This change restores behavior where the DrmKmsPlan cached during
ValidateStagedComposition is reused during Present. That behavior
was disabled in a prior change due to a bug where the client
layer could become stale if it were updated between the validate
and present steps, which is now resolved by this change.

Change-Id: Ibca43dc028ece2f4480e5631078ad51320c10582
2025-10-20 15:00:34 +00:00
Sasha McIntosh
1159f0e373 Fix CTM clearing bug
When all layers are client composited, the GPU may or may not apply the
color transform. If the GPU does apply the CTM, we should clear the HWC
CTM.

Remove duplicate line setting the color matrix.

Change-Id: Ib6a1a48742ee356626ea624b00be5b689323619a
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-10-16 14:58:06 -04:00
Manasi Navare
b23482b05c drm_hwcomposer: Add HDCP state tracking to request it to be enabled
This adds HDCP state tracking through Client to HwcDisplay
When Client requests HDCP to be enabled for secure layers
Hdcpstate in the corresponding HwcDisplay is set up.
This is parsed to set the Content Protection and HDCP Content Type
properties for the connector in the next commit

Change-Id: I60dd4359ee2f87faba1df83c7faf286b34af43f6
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-10-14 19:10:56 +00:00
Andrew Wolfers
9df6d57b48 Remove cached DrmKmsPlan resuse
This CL resolves visual artifacts caused when the DrmKmsPlan is
cached from ValidateDisplay and later used during PresentDisplay.
This change restores prior behavior where the plan is created and
cached during validate, but then recreated fresh during present.

Change-Id: Ifea65946d586c9020143a35455405c5e4c5479e1
2025-10-14 10:21:50 -06:00
Andrew Wolfers
68ff3baebe Add new metrics to CompositionStats
This change adds fields for counting the total number of layers
and used planes accross compositions.

Change-Id: I7c2593f66f734a4f8ec8ddf7a2f6b5c0c8dc3cc3
2025-10-08 16:44:38 +00:00
Andrew Wolfers
48f056ff82 Track stats per unique composition attributes
This change adds a new CompositionAttributes struct which
tracks information about a given composition as it is
validated and subsequently presented.

Previously CompositionStats were tracked as totals for each
display. This change splits the stats according to the
CompositionAttributes for each presented composition.

This change only affects the reporting behavior of
CompositionStatsTracker. The stats logged by DumpState are
totaled so as to not be affected.

Change-Id: I050cce7f63891971cc807b9c5150d9b5d30f1f0b
2025-10-08 16:44:33 +00:00
Andrew Wolfers
ccbe364628 Move stats accounting from validation to presentation
Some fields of the CompositionStats struct were only being updated
during validation, meaning that they would not be updated if the
validation step is skipped. This change moves the relevant updates
into presentation to correct some values which were not counted.

Change-Id: Ie537c0b5f6c18eaa71ca1fb2318fca3786d6e097
2025-10-07 14:53:49 +00:00
Andrew Wolfers
09c7c9f875 Consolidate stats collection within HwcDisplay
This change moves all modifications to the total_stats_
property out of the Backend. HwcDisplay becomes responsible
for updating its own stats based on the results of validating
and presenting a composition.

Change-Id: I54ff8c2c8f6ad983ef583e60e2e77cf8b7866e9b
2025-10-07 14:46:53 +00:00
Gil Dekel
9a76e062b6 Move EdidWrapper from DrmConnector to HwcDisplay
The EdidWrapper lifecycle was previously managed by DrmConnector,
meaning the EDID parser was initialized when the connector was created.
This approach fails for physical connectors where a display is not
attached at boot, as no EDID blob is available to parse.

When a display was subsequently hot-plugged, the system would fall back
to a generic EdidWrapper. This provided incorrect or default display
properties to userspace, causing critical bugs such as:

  * Incorrect DPI calculations, leading to improperly scaled UI in
    Android.
  * Inability to detect HDR capabilities or supported color modes.

This change moves the ownership and lifecycle management of the
EdidWrapper to HwcDisplay. By creating the parser only when a display is
actually connected, we ensure that the correct EDID is always parsed,
making hot-plug functionality work as intended.

Change-Id: I5e056e423bbac2b23a411395b4ce13ccd03c4b64
Signed-off-by: Gil Dekel <gildekel@google.com>
2025-10-06 13:44:31 -04:00
Andrew Wolfers
a51a43422d drm_hwcomposer: Use cached validated composition
This change adds caching to save the most recently
validated composition. The cached value is used where
appropriate to avoid recalculating the DrmKmsPlan or
the CompositionTypeMap from ValidateDisplay again in
PresentDisplay. The cached ValidatedComposition
replaces the previously cached DrmKmsPlan, preserving
the lifecycle management requirements.

Change-Id: I59704e26ae1a6950e750d246314b2db6af2f11a0
2025-10-03 18:56:19 +00:00
Andrew Wolfers
99f677a2ea drm_hwcomposer: Manage current_plan_ lifecycle
This change refactors the lifecycle management of
HwcDisplay::current_plan_. The purpose of the current_plan_
is to keep plane bindings in memory between calling
ValidateDisplay() and PresentDisplay(). This ensures that
bound planes will not be stolen by other CRTCs in the
interim, which could cause a validated composition to
become invalid before it can be presented.

The current_plan_ is intended to fulfill the contract
prescribed by the documentation of
Backend::ValidatedComposition::composition_plan, which
requires the plan to not be destructed until the
composition is committed.

Prior to this change, the lifetime of current_plan_ was
extraneous. Rather than being released after
PresentDisplay(), it was being unnecessarily held until
the next ValidateDisplay(). This would have the
unintended effect of holding the plane bindings after
the composition has been committed, which would prevent
other CRTCs from using the shared planes during that time.

This change updates the management of current_plan_,
still satisfying the Backend's contract, but releasing it
once it is appropriate to do so.

Change-Id: I956d3983b43302040f6ff18b5e907e2ed143c2dd
2025-10-03 13:47:00 +00:00
Su Hong Koo
87ffe73cd7 drm_hwcomposer: Update VSyncWorker::last_timestamp_ on every present 2025-10-01 06:24:44 -06:00
Sasha McIntosh
2818649164 drm_hwcomposer: Do not set color_matrix_ for 3x4 transform
When the request CTM is a 3x4 transform, we designate all layers for
client composition and do not set the plane CTM. In the DRM_OR_IGNORE
case, we do not force client composition and end up using the incomplete
transform.

This change ensures that we only set the CTM when the matrix is useable.

Change-Id: Ic7928616208b61fcdef72cc214d652cdf8a47d00
2025-10-01 04:27:51 -06:00
Sasha McIntosh
525d1aebcb drm_hwcomposer: Disable HDR for internal displays
Supported on external displays only. Update to match implementation in
QueueConfig.

Change-Id: I647935f914f33f488b28b909d847d85039986f9b
2025-09-29 02:12:29 -06:00
Su Hong Koo
7e7e0609ee drm_hwcomposer: Add tracing around validate/present paths
Add perferto tracing around validate and present paths. Specifically
around code that blocks on the main thread (e.g. commit, fence waits).
These should increase the visibility of what is blocking the
presentation hot path in perfetto traces.

Change-Id: I6db60648c5e1d5f1a666ebc52f5ae5ad57e0e82a
2025-09-24 12:11:22 -04:00
Drew Davenport
9876f33138 drm_hwcomposer: Make FlatteningController::StopThread private
There is no need for this to be public since it is called from the
destructor, and any public usage of it was immediately before
destructing the FlatteningController

Change-Id: Ice233feaa9b934e7385ac83769250fea33f9140c
2025-09-19 17:36:33 -06:00
Drew Davenport
d2ccec310e drm_hwcomposer: No-op FlatteningController cleanup
- Move member function implementations to the .cpp file.
- Rename Disable -> DisableFlattening
- Update comments for functions

Change-Id: I71eec96597a0d41f652b897c1862a34138b5be85
2025-09-19 17:36:33 -06:00
Drew Davenport
08fea937a1 drm_hwcomposer: Update flatcon in HwcDisplay
Backend can get a const reference to the FlatteningController for
checking if the scene should be flattened or not. Updating of the
FlatteningController is moved to HwcDisplay just before deferring to the
Backend during the Validate.

Change-Id: I9c7cc309bb16ea7b60187476db67fc9df1485275
2025-09-19 17:36:27 -06:00
Drew Davenport
6075ab4596 drm_hwcomposer: Use unique_ptr for FlatteningController
FlatteningController is owned by HwcDisplay, so use a unique_ptr to
better control and indicate the ownership.

Remove the CreateInstance factory method and use std::make_unique
instead.

Change-Id: I0155c602dcf5a31d27fd2677f9f96ff9696a4022
2025-09-19 16:58:58 -06:00
Drew Davenport
ce65d6c6e3 drm_hwcomposer: Make FlatteningController timeout configurable
Pass a timeout to the FlatteningController constructor. Move the
original default timeout from FlatteningController to HwcDisplay.cpp

Change-Id: I6e3f8950badc38a5ccad8ae68e1b11317c850d61
2025-09-19 16:54:55 -06:00
Su Hong Koo
a0f6ed9cc7 drm_hwcomposer: Wait for next present fence earlier in present
Currently, drm_hwcomposer has two main ways to lock up in the
composition hot path:

1. HwcDisplay::WaitForPresenttime(), where it looks at the expected
present time of the frame and sleeps until it is close to it (0.75
vsync period away from the target vsync).

2. DrmAtomicStateManager::WaitLastFrame(), where it waits on the
present fence of the last commit so that we don't call commit when
another present is pending

These are called in-order, which in certain multi-display configuration
with heterogenous refresh rates can lead to the slower display locking
up due to sleep in WaitForPresenttime().

This CL makes DrmAtomicStateManager::WaitLastFrame() public, and moves
its invocation to right before the call to
HwcDisplay::WaitForPresenttime(). This should minimize the impact of
WaitForPresenttime(), and allow drm_hwcomposer to hit more present
targets that it can hit.

Test: atest GraphicsComposerAidlCommandTest
Test: Manual testing w/ perfetto

Change-Id: Ic9c07ff0b6d00dfafce5dd109d8195886dd3094e
Signed-off-by: Su Hong Koo <sukoo@google.com>
2025-09-18 13:24:44 -06:00
Andrew Wolfers
3ceb722bc9 drm_hwcomposer: Move pixops calculation
This change moves the pixops calculation into HwcLayer. This
simplifies the logic to determine the total pixops over the
client range performed within Backend. This change also moves
the display size calculation into HwcDisplay.

Change-Id: Id7e12657a512db3aaea98d88833c818c10efef66
2025-09-10 19:41:32 +00:00
Andrew Wolfers
9255d0d10b drm_hwcomposer: Migrate to android::drm_hwcomposer namespace
Change-Id: I2859aa8f55532d88231389724956fc77b0625339
2025-09-08 18:53:00 +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
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
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