1
0
Fork 0
Commit graph

36 commits

Author SHA1 Message Date
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
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
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
84892ec611 drm_hwcomposer: Cleanup includes for test target
Change-Id: I1332873df0109347a91e729955ba5f84cf8c7fec
2025-10-02 15:06:12 +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
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
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
f9062b6964 drm_hwcomposer: Set HDR metadata on the connector
Implement a function to set HDR metadata on the connector. Support HDR10
and HLG, which are common HDR types.

Change-Id: Id3dbe8eea2ee6b8ba700af23845a43e2070dd14e
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-01-30 23:09:52 -05:00
Sasha McIntosh
f8c14115ec drm_hwcomposer: Add wrapper for EDID parsing
Use libdisplay-info to parse display EDID. Wrap the parsing logic in a
class to extract specific EDID information.

Change-Id: I20376eb96ebcd0073155cedf1e8f055bbf8dfb49
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-01-30 15:55:22 -05:00
Sasha McIntosh
da080fe82d drm_hwcomposer: Add method GetOptionalConnectorProperty
Add conveniece method GetOptionalConnectorProperty to reduce boilerplate
/*true=*/ notation.

Change-Id: I888be527dfbecc5c7ccfdd7661e3aeb4a9af04c7
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2025-01-30 13:30:17 -05:00
Yongqin Liu
1f41ac783c drm_hwcomposer: Fix DrmConnector log build failure
This fix is the same as the previous commit on DrmProperty:
    2c36651af0 ("drm_hwcomposer: Fix DrmProperty log build failure")

So copy the commit message of it here for reference convenience.

DrmConnector logs the uint64_t property value if it is unrecognized.
However, this type can be represented multiple ways:

* unsigned long (%lu)
* unsigned long long (%llu)

This generates build errors when the wrong type is used.

The correct way to log the value is with |PRIu64|.

Change-Id: Ie59ac6930919f77c16c064f3d5becfa794ed37a3
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2024-10-29 09:30:13 +08:00
Tim Van Patten
a2f3efa162 drm_hwcomposer: Implement getDisplayPhysicalOrientation()
Implement ComposerClient::getDisplayPhysicalOrientation() by querying
the DRM display panel orientation property and translating the result to
the correct common::Transform enum value.

The result is used by SurfaceFlinger to correctly rotate the image
before displaying it to the user.

Signed-off-by: Tim Van Patten <timvp@google.com>
2024-10-22 12:05:49 -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
Sasha McIntosh
5294f095f6 drm_hwcomposer: Add getter/setter for Colorspace
Optionally, get the Colorspace drm property and populate an enum mapping
for the property types. Add implementation to HwcDisplay::SetColorMode
to set this property and map between HAL_COLOR_MODE types to Colorspace
formats.

Change-Id: Id532e94207c1b1a2623b7d77db239735df18b30f
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2024-10-14 17:32:43 -04:00
Sasha McIntosh
173247b007 drm_hwcomposer: Add getter/setter for content_type
Optionally, get the content_type drm property. Add implementation to
HwcDisplay::SetContentType to set this property.

Change-Id: I910e064876d13205abc7caaac342daaff8f38599
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
2024-10-14 15:12:57 -04: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
Lingkai Dong
63ed8076ad drm_hwcomposer: Treat unknown connector as internal display
The code determines if a display is internal or external based on the
display connector type, and at least one internal display must exist
which is used as the primary display. Because the FVP Base RevC does
not model any connector hardware, the reported connector type is none/
unknown, so we need to treat unknown as an internal connector.

Change-Id: Ifa603f903d74ccad6c7e9da13042994a5fdffe32
Signed-off-by: Lingkai Dong <lingkai.dong@arm.com>
2024-01-30 09:49:42 +00:00
Roman Stratiienko
76892784ac drm_hwcomposer: Introduce SharedFd, use standard c++ RAII for UniqueFd
We use too much dup() system calls for present fence propagating.
Also when propagating acquire fence we use additional logic for
skipping such propagation for the validate/test cycle.

Both issues can be solved by introducing SharedFd, which will track
reference count of fd object.

After that the UniqueFd is used very rarely and can be simplified by
wrapping it into std::unique_ptr without caring too much of adding
an extra malloc/free operation.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2023-01-16 20:13:58 +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
abd8e534d9 drm_hwcomposer: Rework DrmProperty class
Simplify code and raise-up clang-tidy level of DrmProperty class
to 'normal'.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2022-12-11 21:19:43 +02:00
Roman Stratiienko
a7913de518 drm_hwcomposer: CI: Bump-up clang toolchain to v15
Address new clang-tidy findings, in most cases 'misc-const-correctness'
check was addressed by adding 'const' modifier, or in some cases changed
to 'auto' (where it's better for formatting).

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2022-10-20 14:14:33 +03: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
780f7dacf9 drm_hwcomposer: CI: Upgrade to clang-13 && clang-tidy-13
+ address new clang-tidy findings.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-20 17:21:46 +02:00
Roman Stratiienko
ad29ee9e5c drm_hwcomposer: Fix missing connector state assignment
It was accidentally removed by my previous commit. Restore it.

Fixes: a148f21336 ("drm_hwcomposer: Rework display modes handling")
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2022-01-18 10:52:23 +02:00
Yongqin Liu
cdee4f2b3d drm_hwcomposer: support more connector types
according to the drm_connector_enum_list defined
in the kernel file drivers/gpu/drm/drm_connector.c

Otherwise for the new connector type, the connector
name will be "None" to be printed  in the logcat, like this:
    12-13 05:38:06.263   383   383 I hwc-backend: Backend 'generic' for 'None' and driver 'omapdrm' was successfully set
with this change, it will be fixed with the connector type like this:
    12-13 06:01:57.672   342   342 I hwc-backend: Backend 'generic' for 'DPI-1' and driver 'omapdrm' was successfully set

Also updated the internal() and external() functions
to make the newly added SPI and USB are valid types

Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
2021-12-20 21:09:22 +08:00
Roman Stratiienko
a148f21336 drm_hwcomposer: Rework display modes handling
Android likes to adapt display output frequency to match window context
frequency. Unfortunately platform code has some limitations, therefore
hwcomposer HAL should be careful with reporting supported display modes.

Known platform limitations:
1: Framework doesn't distinguish between interlaced/progressive modes.
2. Framework will not switch display frequency in case margin in FPS rate
   is very small (<1FPS or so). Not a big issue, but that is causing
   some CTS tests to fail.

In addition to that VRR technology (or seamless mode switching) require
hwcomposer to group modes which tells the framework that seamless mode
configuration change is supported within a group of display modes.

By this commit do the following:
1. Group modes by the resolution:
   E.g.

    Group 1:
    1024x768i@60
    1024x768i@90
    1024x768@50
    1024x768@50.1

    Group 2:
    1920x1080@60
    1920x1080@24.3
    1920x1080i@60
    1920x1080i@120

2. Disable modes in a way that each group keeps only interlaced or proressive
   modes enabled. In case KMS reported preferred mode is interlaced - prefer
   interlaced for the whole group, otherwise prefer progressive.

3. Disable mode in case different mode in the same group has similar frequency
   with delta less than 1FPS.

4. Report only modes which remain enabled to the framework.

Test: atest CtsGraphicsTestCases

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-12-02 14:35:08 +02:00
Roman Stratiienko
3e8ce57ada drm_hwcomposer: Wrap libdrm drmMode*{Get|Free}* into RAII
This should elliminate chance of any leaks in the future.
Fix drmModePropertyBlobPtr leak in DrmHwcTwo.cpp.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
2021-09-29 12:46:28 +03:00
Roman Stratiienko
b3b5c1e937 drm_hwcomposer: clang-tidy: enable cppcoreguidelines-* checks
Our code isn't ready for the following checks therefore keep disabled
-cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-pro-bounds-constant-array-index
-cppcoreguidelines-pro-bounds-pointer-arithmetic
-cppcoreguidelines-pro-type-cstyle-cast
-cppcoreguidelines-pro-type-vararg
-cppcoreguidelines-avoid-magic-numbers
-cppcoreguidelines-macro-usage
-cppcoreguidelines-avoid-c-arrays

+ fixed existing tidy warnings for these checks.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-03-03 16:12:22 +02:00
Roman Stratiienko
6a10c4ce1f drm_hwcomposer: clang-tidy: enable clang-analyzer-* checks
+ fixed existing tidy warnings for these checks.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-03-03 16:12:14 +02:00
Roman Stratiienko
e2f2c92924 drm_hwcomposer: enable code analysis using clang-tidy
Drm hwcomposer project has some code-style inconsistencies.
This is the initial step to unify code-style of the code.

Clang-tidy is a great tool which can not only suggest correct styling,
but also allow predicting the errors in the code and suggest correct
coding approaches to avoid potential weaknesses.

CI was tuned to check clang-tidy recommendation for some part of the
code which is ready ATM (can be built outside AOSP tree).
For this part a limited set of clang-tidy checks has applied (coarse check).
Header files aren't checked at all.

Starting from now new code files must be included into the list that is
checked by almost all clang-tidy checks (fine checklist). New header files
should be also included into this list.
See '.gitlab-ci-clang-tidy-fine.sh'.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-03-03 16:07:25 +02:00
Roman Stratiienko
d518a0594a drm_hwcomposer: CI: Initial build and clang-tidy checks
Build android-agnostic code in linux environment.
Enable static code analysis using clang-tidy.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
2021-03-03 12:14:13 +02:00
Marijn Suijten
25ddbc44ac drm_hwcomposer: Return error from GetEdidBlob if blob is null
drmModeGetPropertyBlob can return NULL blobs resulting in a segfault in
GetDisplayIdentificationData which expects blob to be set to a valid
pointer when GetEdidBlob returns 0.

Fixes: adc5d8229b

Signed-off-by: Marijn Suijten <marijns95@gmail.com>
2020-09-26 22:43:15 +02:00
Andrii Chepurnyi
adc5d8229b drm_hwcomposer: Fix EDID fetch from DRM
EDID fetch procedure consist of two steps:
1) get appropriate blob_id
2) fetch EDID blob using blob_id
Those steps should be done sequentially, in
other case drivers can update EDID and blob_id
won't be actual.

Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
2020-09-11 16:00:02 +03:00
Roman Stratiienko
13cc3666c6 drm_hwcomposer: use CamelCase in source/header files related to class
Main goal is to increase readability of file names.
AOSP uses camelcase for files in many projects.
Lets do the same for drm_hwcomposer.

Keep platform/ directory as is, since class names is different from file names.

Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I7e992357851c2a86711f4da1241c4d507359e56b
2020-09-08 22:34:52 +03:00
Renamed from drm/drmconnector.cpp (Browse further)