1
0
Fork 0
Commit graph

28 commits

Author SHA1 Message Date
Andrew Wolfers
5337905df6 Cleanup includes in hwc2_device/ per IWYU style
Change-Id: If7440aa7796ea8d48cb2767ae3a57d853d535135
2025-11-11 19:14:30 +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
Andrew Wolfers
9255d0d10b drm_hwcomposer: Migrate to android::drm_hwcomposer namespace
Change-Id: I2859aa8f55532d88231389724956fc77b0625339
2025-09-08 18:53:00 +00: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
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
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
Manasi Navare
3f0c01a98a drm_hwcomposer: Plumb link status BAD to OnHotplugEvent composer callback
This updates the Uevent handler to handle the hotplug events
sent by the kernel for link training failure.
Adds support in hotplug handler in resourcemanager to read connector
properties and read the value of link-status property.
If this is set to DRM_MODE_LINK_STATUS_BAD, then invoke
the OnHotplugEvent() composer callback with the BAD CABLE
DisplayHotplugEvent to notify the Surfaceflinger about link training
failure.

Currently this uses the ERROR_INCOMPATIBLE_CABLE field of the
DisplayHotplugEvent callback. The longer term would be to define
a new field in this enum to indicate MODESET_RETRY and use this
INCOMPATIBLE_CABLE for the terminal link train failure state.

Change-Id: I823d7570dd08e476d0c887e350bce3f8f0069afb
Signed-off-by: Manasi Navare <navaremanasi@chromium.org>
2024-10-15 21:17:27 +00:00
Drew Davenport
93443188b7 drm_hwcomposer: Extract DrmHwc abstract base class
DrmHwc holds implementation details that can be shared between hwc2 and
hwc3. It exposes abstract functions for implementing callbacks to hwc
clients.

Leave the HWC2 specific implementation details in the DrmHwcTwo class, such
as the client callback implementation, and implement the DrmHwc abstract
functions in terms of hwc2.

DrmHwc is based on the DrmHwcInterface extracted in
(drm_hwcomposer: Connect ComposerClient with HwcDisplay) from !238

Co-authored-by: Dennis Tsiang <dennis.tsiang@arm.com>
Co-authored-by: Normunds Rieksts <normunds.rieksts@arm.com>
Signed-off-by: Drew Davenport <ddavenport@chromium.org>
2024-08-12 12:27:10 -06:00
Drew Davenport
4520df1643 drm_hwcomposer: Use bool value for hotplug
Interpret the |connected| parameter in SendHotplugEventToClient as a
bool, rather than comparing it to DRM_MODE_CONNECTED.

Signed-off-by: Drew Davenport <ddavenport@chromium.org>
2024-08-09 15:32:49 -06:00
Sean Paul
468a7548bf drm_hwcomposer: Replace LOG_TAG with drmhwc
It's a pain to use logcat filters for drm_hwcomposer since each file has a different tag necessitating one to specify each tag for the logcat filter or use a regex.

Use one tag for all of drm_hwcomposer to simplify this.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
2024-07-19 17:42:41 +00:00
Roman Stratiienko
f2c060f8be drm_hwcomposer: Virtual display acceleration support
Some platforms like RaspberryPI-4 can benefit from Display Blender IP Core's
ability to write back the composition into RAM, offloading the GPU in cases
where the display content needs to be used (screen record, remote display,
etc.).

To enable this feature the following system property must be enabled:

    PRODUCT_VENDOR_PROPERTIES += debug.sf.enable_hwc_vds=1

The feature was requested by the Tesla Android project to improve UI
performance.

Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/4
Change-Id: I643f94551408bf218a0b889f1a031598646242f1
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-10-01 15:00:59 +03:00
Roman Stratiienko
63762a9d5d drm_hwcomposer: Use shared pointer type for the pipeline_ variable
The change will help with resource management in further patches.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-10-01 15:00:59 +03:00
Roman Stratiienko
9e2a2cd313 drm_hwcomposer: Make main mutex recursive
It allows to remove redundant unlock/lock pair from the code,
and should make it a little bit more race-proof.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-01-04 16:30:40 +02:00
Roman Stratiienko
d2cc73874c drm_hwcomposer: Rework VSyncWorker to work without utils/worker
utils/worker just complicates the logic without providing any benefit.

Change-Id: I7b3c91aee9c0507d9ca35792d24ba6c8c3870033
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2022-12-28 19:18:29 +02:00
Roman Stratiienko
6b40505a7e drm_hwcomposer: Use __ANDROID_API__ instead of PLATFORM_SDK_VERSION
__ANDROID_API__ definition is available by default in AOSP and NDK.

It also exported by standard system clang when the user sets
the '-target <ARCH>-linux-android<LEVEL>' compiler flag.

Reason for this change is integration of meson build script, where
otherwise the user has to provide the API level manually.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2022-12-11 21:19:43 +02:00
Roman Stratiienko
d0494d9b80 drm_hwcomposer: Fixes for display hotplug / headless mode
Further testing showed that several issues is still present:
1. Boot without display doesn't work.
2. Unplug/plug primary display has some flaws due to incomplete
   HwcDisplay disposal.
3. In case creation of the pipeline fails, hwcomposer crashes.

This commit aims to address them.

Fixes: bb594baa1c ("drm_hwcomposer: Rework HwcDisplay disposal to avoid races")
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-03-28 15:47:49 +03:00
Roman Stratiienko
bb594baa1c drm_hwcomposer: Rework HwcDisplay disposal to avoid races
The code prior to this commit has a flaw:

    HwcDisplay::~HwcDisplay() {
      ...
      auto &main_lock = hwc2_->GetResMan().GetMainLock();
      /* Unlock to allow pending vsync callbacks to finish */
      main_lock.unlock();

At this point display is no longer in displays_[] list. After
lock is released, hwc2 API thread starts to process transactions
which may fail with BAD_SIAPLAY responce and cause SF to crash.

      vsync_worker_.VSyncControl(false);
      vsync_worker_.Exit();
      main_lock.lock();
    }

1. Rework the logic in order to avoid such scenariuos:
1.a. Temporary switch non-primary unplugged displays to headless state
     allowing remaining transactions to succeed without impacting the
     pipeline.
1.b. Give 100mSec delay before destroying / removing display from the
     displays_[] list to allow all pending hwc2 transactions to complete.

2. Support hotswap of the DrmDisplayPipeline, which makes primary display
   reattaching process smoother.
   Now SF should be able to gracefully remove all layers.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-18 18:45:06 +02:00
Roman Stratiienko
d0c035b44a drm_hwcomposer: Implement SetActiveConfigWithConstraints
Enough to get 100% passes in Composer 2.4 VTS.
Some SOCs require a VTS fix to pass [1]

[1]: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1954544
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-04 11:16:32 +02:00
Roman Stratiienko
099c31156d drm_hwcomposer: Use single VSyncWorker per display
Composer 2.4 will require another vsyncworker callback to send
VsyncPeriodTimingChanged event. It makes sence to use single
VSyncWorker and flags to indicate which actions are required
to perform. This should also save some runtime resources.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-04 11:16:05 +02:00
Roman Stratiienko
3dacd47d13 drm_hwcomposer: Dynamic DrmDisplayPipeline to HwcDisplay bindings
The following use scenarios are now possible:

1. When no display connected, primary HwcDisplay is created in headless
   mode.

2. When user connects first display, it binds to primary slot, replacing
   headless HwcDisplay.

3. When user connects another display it binds to the new HwcDisplay
   slot, creating new display for the framework.

4. When user disconnects first (Primary) display, drm_hwc detaches
   second display and attaches it to the Primary slot. In this case
   framework is notified as Primary display resolution updated
   (Plugged->Plugged transition). And second display is disconnected
   (Plugged->Unplugged transition).

DrmDisplayPipeline is now created on demand (after hotplug event).

HwcDisplay class is now destructed on connector unplug, which will give
us ability to destroy any resource caches (will be required for FB
caching logic).

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-02 12:57:32 +02:00
Roman Stratiienko
19c162fe79 drm_hwcomposer: Initialize HwcDisplay using DrmDisplayPIpeline
HwcDisplay can now take all necessary objects from DrmDisplayPipeline.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-02-02 12:57:32 +02:00
Roman Stratiienko
7d89911c32 drm_hwcomposer: Tidy-up DrmDevice class
1. Move drm/DrmConnector.h to Normal clang-tidy checks list by fixing
   clang-tidy findings.

2. Remove DrmDevice self-reference.

3. Replace shared_ptr reference to DrmDevice in DrmFbImporter with a
   pointer, making ResourceManager only owner of DrmDevice and its
   chilren.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:48:40 +02:00
Roman Stratiienko
650299a235 drm_hwcomposer: Tidy-up DrmConnector class
Implement DrmConnector instantiation through CreateInstance() static method,
which helps to reduce complexity of DrmDevice::Init() function.

Move Connector-to-CRTC binding information to the DrmDevice class.

Move drm/DrmConnector.h to Normal clang-tidy checks list by fixing
clang-tidy findings.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:48:40 +02:00
Roman Stratiienko
b671fab16a drm_hwcomposer: Tidy-up DrmPlane class
This allow to throw away few lines from DrmDevice::Init() making it less
complicated.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-31 21:31:31 +02:00
Roman Stratiienko
f0c507f16b drm_hwcomposer: Add headless mode support
Headless mode required to keep SurfaceFlinger alive when all displays are
disconnected, Without headless mode Android will continuously crash.
Only single internal (primary) display is required to be in HEADLESS mode
to prevent the crash. See [1].

[1]: https://source.android.com/devices/graphics/hotplug#handling-common-scenarios
Closes: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/issues/57
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-20 17:21:46 +02:00
Roman Stratiienko
7492358698 drm_hwcomposer: Introduce main lock
Further development will require more asynchronous processing.
Introduce project-wide single mutex for these purposes.
Use it instead for callback handling instead of callback_lock.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-20 17:21:46 +02:00
Roman Stratiienko
3e1689054d drm_hwcomposer: Move DrmHwcTwo.{cpp|h} to hwc2_device/ directory
To keep all frontend-related files in a single directory.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-12 11:27:09 +02:00
Renamed from DrmHwcTwo.cpp (Browse further)