1
0
Fork 0
Commit graph

249 commits

Author SHA1 Message Date
fbaba3b2b4 Dedupe near-identical EDID modes by resolution and refresh rate 2026-07-13 14:36:44 -04:00
Konsta
22ba81cf61 Merge remote-tracking branch 'freedesktop/main' into android-16.0 2025-11-12 22:01:44 +02:00
Su Hong Koo
680790982c Add atom reporting for refresh rate changes
Add DisplayRefreshRatesChangedAtomReporter, which reports the changed
refresh rates of all the active displays managed by drm_hwcomposer.

Change-Id: I03a81c667c44160dc319a899a3bd9a8bc527a382
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
5a9cc2cba3 Cleanup includes in drm/ per IWYU style
Change-Id: I613cb6656d887aab5221be3d3b2923f1f4ba9ab9
2025-11-11 19:14:37 +00:00
Andrew Wolfers
185f909299 Cleanup includes in compositor/ per IWYU style
Change-Id: I4362a5ff4228b1a30812ec564f6a0c81e1f5cf08
2025-11-11 19:14:32 +00:00
Andrew Wolfers
1e0e2ca0a5 Move implementations out of headers
This change moves some non-trivial implementations out of header
files in drm/. This will enable some includes to be converted to
forward declarations in future changes.

Change-Id: I7b1248657e0fa27e3c0c0157abe4f6b918e13a29
2025-11-11 17:01:13 +00:00
Konsta
e2e9c8cff7 drm_hwcomposer: Add property to force display mode
* Display resolution and refresh rate can be forced using a property.
  Other modes reported as supported by the display are ignored when forcing
  a specific mode.
* Force resolution and refresh rate for headless mode as well.

This is based on following 4 commits with further updates.

Author: Chih-Wei Huang <cwhuang@linux.org.tw>
Date:   Wed Sep 19 22:57:32 2018 +0800

    drm_hwcomposer: allow to force mode by a property

    The desired resolution could be set by property debug.drm.mode.force.
    The other modes are ignored.

Author: Konsta <konsta09@gmail.com>
Date:   Sun Dec 5 15:40:40 2021 +0200

    drm_hwcomposer: use first refresh rate reported by the display

    * Android can switch between different refresh rates which
      can lead to display changing modes in some cases.
    * Use the first refresh rate reported by the display when
      forcing the resolution unless specified otherwise.

Author: Konsta <konsta09@gmail.com>
Date:   Tue Jan 25 17:46:33 2022 +0200

    drm_hwcomposer: Default to 1920x1080 resolution for headless mode

Author: Konsta <konsta09@gmail.com>
Date:   Tue Feb 1 17:40:43 2022 +0200

    drm_hwcomposer: Allow setting resolution for headless mode
2025-11-10 15:56:19 +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
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
0f5244ef78 Create DrmDisplayPipeline through BackendManager
Additionally, move the creation of the Backend into BackendManager so
that it the Backend is created along with the DrmDisplayPipeline

Change-Id: I24dc19cadb324429f229fe7751b60b70ab512265
2025-10-30 09:27:28 -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
Manasi Navare
caa94f923e drm_hwcomposer: Update Content Protection prop on Uevents
Kernel sends Uevents when Content Protection changes its value
from Desired -> Enabled on HDCP enabling or when it changes
from Enabled->Desired on HDCP termination.

This patch updates the content protection property value
on Uevents to capture the change in its state by the kernel.

Change-Id: I7003f0e498f1d1ffa3cbe37406c0b44c5813a3d1
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-10-30 00:11:39 +00: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
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
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
8940921be7 drm_hwcomposer: Add GetUsablePlanes tests to DrmDisplayPipelineTest
Change-Id: I02391c51ba392795bc39b3d918b5b86e5f4079bd
2025-10-02 15:06:23 +00:00
Andrew Wolfers
a95aa3b1c7 drm_hwcomposer: Add CreatePipeline tests to DrmDisplayPipelineTest
Change-Id: If105c7773e7f4adaa9c0ab7e6f410d9cc09f476e
2025-10-02 15:06:21 +00:00
Andrew Wolfers
086a6f1fc4 drm_hwcomposer: Add drm object fakes for DrmDisplayPipelineTest
Change-Id: I1ffbf45a787bac8ce414ef03701bc544835da3a7
2025-10-02 15:06:19 +00:00
Andrew Wolfers
ec00b3dc25 drm_hwcomposer: Add PipelineBindable unit tests
Change-Id: Iada6f16cb3b72f38cbaad1b71b38c8ef201c4722
2025-10-02 15:06:16 +00:00
Andrew Wolfers
84892ec611 drm_hwcomposer: Cleanup includes for test target
Change-Id: I1332873df0109347a91e729955ba5f84cf8c7fec
2025-10-02 15:06:12 +00:00
Andrew Wolfers
ff954db228 drm_hwcomposer: Add buildflag guards around libsync deps
This change adds the buildflag HAS_LIBSYNC for managing
availability of libsync. This is necessary for the
unittests target for which libsync doesn't provide the
necessary variant.

DrmAtomicStateManager.cpp is the only file which depends
on libsync. Guards have been added using the HAS_LIBSYNC
flag, such that any method which would depend on libsync
is now stubbed when it is unavailable.

Change-Id: I101083074a9fad98e1c40c27b55f2eddf1c53581
2025-10-02 15:06:06 +00:00
Su Hong Koo
87ffe73cd7 drm_hwcomposer: Update VSyncWorker::last_timestamp_ on every present 2025-10-01 06:24:44 -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
ac727c57ae drm_hwcomposer: Fix used_plane state tracking
Ensure that the next frame's list of used_planes is correct. The list of
used planes for the new frame is initialized to the previous frame's
list of planes when creating the AtomicRequest. If there is a
composition as a part of this request, the list should be cleared before
creating the new composition, since the list will be re-populated.

Neglecting to clear this left planes on the list when they shouldn't
have been, or the same plane multiple times. This led to some spurious
commit and validation failures on single display configurations, but on
multiple display configurations also resulted in highly visible stuttering.

Change-Id: Ie3fa1fc120fde13ee80f9a144c459526be2822cb
2025-09-19 10:20:08 -06:00
Manasi Navare
d341024047 drm_hwcomposer: Clear connectors and CRTCs on Init
When DRM HWC starts, it resets all the connectors
and CRTCs to avoid the mimatch between drm hwc tracked
state and actual HW state programmed by the firmware
for the splash screen.

This fixes the MST connected boot issue.

Change-Id: I0773541b6bb227a2880d8442cc46411dc4c0127a
Signed-off-by: Manasi Navare <navaremanasi@google.com>
2025-09-18 15:00:19 -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
Drew Davenport
5a1d68b1f8 drm_hwcomposer: Preserve DrmAtomicStateManager state
The next frame's state needs to be initialized with the current frame's
state to ensure that it doesn't get reset incorrectly.

Change-Id: I00caab6ad4116dceba67cbd945b83c4d45277a39
2025-09-12 10:15:36 -06:00
Andrew Wolfers
ee0b06e40c drm_hwcomposer: Preserve cursor scaling during commit
This change modifies cursor behavior during atomic commit
so that the scaling factor is preserved. Previously, the
src rect was being overwritten to match the dimensions of
the dst rect, because it was assumed that scaling is not
permitted with the cursor plane. The new behavior will
preserve any existing scaling factor while resizing the
src rect. For hardware that cannot use scaling on the
cursor plane, this behavior should now be caught during
test commit, and trigger the appropriate fallback. For
hardware that can use scaling on the cursor plane, the
behavior is fixed such that the cursor will now appear
with the correct sizing.

Change-Id: I1d3e01441bdc5d7076b15d66b1a7a1a498ea64a9
2025-09-11 13:17:00 +00: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
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
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
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
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
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
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
Drew Davenport
677e72987b drm_hwcomposer: Remove sleep in unplug handling
SurfaceFlinger should now be handling this race condition more robustly
and it is find to return BAD_DISPLAY in this case. Additionally, there
is no other thread which might be holding a resource resulting in a
deadlock or race during teardown.

Change-Id: I45740febccf2efae2fa470fdbdbe050daadb053b
2025-07-16 17:49:31 -06:00
Drew Davenport
5cdddc176e drm_hwcomposer: Join UEventListener thread on exit
Ensure that the UEventListener has cleanly stopped and joined in the
destructor.

Change-Id: I8e5068b67fcdc235870a8fdbbeb09d1dd8f25520
2025-07-16 17:49:31 -06:00
Lucas Berthou
446c229f98 drm_hwcomposer: refactor drmAtomicStateManager
This is a prerequisit to allow for multi-display commit at once.
It also removes the cognitive complexity of CommitFrame through addition
of helpers for all drm properties to be set.

Change-Id: Ifad7e574c9ea6ced09c677923868ce29656f33f3
Signed-off-by: Lucas Berthou <berlu@google.com>
2025-07-15 21:50:01 +00:00
Andrew Wolfers
f35210964c drm_hwcomposer: Remove cursor buffor validity check
This change removes a check in DrmPlane::IsValidForLayer which would
verify that the buffer size matches known accepted values from the
DRM_CAP_CURSOR or SIZE_HINTS properties. Those properties are required
to return valid buffer sizes for committing to the cursor plane, but
they are not meant to be exhaustive. As a result, this check was
returning false negatives, and forcing the cursor into client
composition unnecessarily. The intended usage is that these props
should be checked during buffer allocation, not during composition.
Instead, test commits are sufficient for detecting whether a buffer
is valid for the cursor plane, and triggering fallback logic as needed.

Change-Id: Iae14436a6f50e45a113a4d18de67e73810b2a83e
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
2025-06-20 15:43:33 +00:00
Drew Davenport
f4cebdbec7 drm_hwcomposer: Move device path to Properties
Add Properties::GetDevicePath to query the value of the
vendor.hwc.drm.device sysprop.

Change-Id: I8c2f9e6f06f3d7f11f03051e21b885413da81c47
2025-06-12 01:51:29 +00:00