* It has been reported that HDR is not working properly on Raspberry Pi
with HDMI displays that support it.
Change-Id: I31f9d7bb5a3f81eeca1f98a72c26786d97edc28d
* 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
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>
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>
Move the implementations for properties related functions on non-Android
platforms into properties.cpp
Change-Id: I91fce6a618445ea3021ef1013228285c99d819bd
Add Properties::GetBackendOverride to query the sysprop, and handle the
default in BackendManager.
Change-Id: Ifc01a23d64a5406ba5c9f065b7d5967b42b1b5d5
This file already exists in android-base, so use this instead of
duplicating the macros in this project.
Since the copy in android-base provides a helper class to assist with
std::unique_lock, use that instead of disabling the warnings.
Change-Id: Ib1724045e3eea29946799fb99b3fbcfcc14a5013
Add generic API for Set/GetColorMode and move HWC2 specific behavior to
hwc2_device.
Remove HwcDisplay::SetColorModeWithIntent, as the only supported intent
is colormetric.
Rename Colormode to ColorMode.
Fix contract between color mode and render intent. All supported color
modes should have a supported render intent (COLORMETRIC at least).
Change-Id: Ic1002b630f925e1ea75cb6ad7822b1384010143e
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
These were only used in the legacy GetDisplayAttribute, which is now
moved to the HWC2 frontend and implemented in the same way as the HWC3
frontend, which uses GetBoundsMm.
Change-Id: I841a8da7763a72c8a8956cd7daf1393c61f5e587
Signed-off-by: Drew Davenport <ddavenport@google.com>
The unary `std::string` constructor calls `strlen` on its input; in this
code there is no guarantee that `buffer` is NUL-terminated, and the
result is this (under hwasan):
```
Abort message: '==android.hardware.graphics.composer@2.1-service==4919==ERROR: HWAddressSanitizer: tag-mismatch on address 0x0077e05a36b0 at pc 0x0077ec51bc6c
READ of size 1040 at 0x0077e05a36b0 tags: 82/00 (ptr/mem) in thread T3
Invalid access starting at offset 1024
#0 SigTrap<47U> in [hwasan_rtl]:3
-> __hwasan_memcpy in out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/hwasan/hwasan_memintrinsics.cpp:33:3
#1 memcpy(void*, void const* pass_object_size0, unsigned long) in out/soong/.intermediates/bionic/libc/libc/android_vendor.34_arm64_armv8-a_shared/gen/include/bits/fortify/string.h:61:12
-> std::__1::char_traits<char>::copy(char*, char const*, unsigned long) in external/libcxx/include/__string:226:50
-> std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::__init(char const*, unsigned long) in external/libcxx/include/string:1799:5
-> std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::basic_string<std::nullptr_t>(char const*) in external/libcxx/include/string:822:7
-> android::UEvent::ReadNext() in external/drm_hwcomposer/utils/UEvent.h:77:12
#2 android::UEventListener::Routine() in external/drm_hwcomposer/drm/UEventListener.cpp:45:32
#3 android::Worker::InternalRoutine() in external/drm_hwcomposer/utils/Worker.cpp:90:5
#4 decltype(*std::__1::forward<android::Worker*>(fp0).*fp()) std::__1::__invoke<void (android::Worker::*)(), android::Worker*, void>(void (android::Worker::*&&)(), android::Worker*&&) in external/libcxx/include/type_traits:4294:1
-> void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (android::Worker::*)(), android::Worker*, 2ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (android::Worker::*)(), android::Worker*>&, std::__1::__tuple_indices<2ul>) in external/libcxx/include/thread:342:5
-> void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (android::Worker::*)(), android::Worker*>>(void*) in external/libcxx/include/thread:352:5
#5 __pthread_start(void*) in bionic/libc/bionic/pthread_create.cpp:382:18
#6 __start_thread in bionic/libc/bionic/clone.cpp:53:16
Cause: stack tag-mismatch
Address 0x0077e05a36b0 is located in stack of thread T3
Thread: T3 0x006e0000e000 stack: [0x0077e04aa000,0x0077e05a3c70) sz: 1023088 tls: [0x0077e05a3f80,0x0077e05a7000)
Potentially referenced stack object:
0 bytes inside a variable "buffer" in stack frame of function "ReadNext"
at external/drm_hwcomposer/utils/UEvent.h:60
```
Thus pass an explicit length.
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
We add build property vendor.hwc.drm.internal_display_names to contain
displays we want to make INTERNAL, while check the property in
GetDisplayConnectionType.
If the property is set, we decide INTERNAL/EXTERNAL based on the
included displays.
Currently it's specific for CF/desktop usage.
Change-Id: I3d607b6646ac47497b9770966d4e880f5e5c0ca6
Signed-off-by: Linjiao Zhao <ruki@google.com>
Remove const qualifiers from luminance data variables.
Set an empty HDR_OUTPUT_METADATA blob to ensure the property is
cleared when switching color modes.
Change-Id: I15d1477a98a1f4e103ef0202c157b8dfb5af8f86
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
See https://clang.llvm.org/docs/ThreadSafetyAnalysis.html for details.
Define thread annotation macros according to the example provided in the
documentation, and use these to annotate VSyncWorker members that can be
accessed from multiple threads.
Thread safety analysis does not yet work with std::unique_lock, so
disable the warnings when it is used.
Change-Id: I8b3b503fbaf0923588fbe3d0180f6fe6ec228350
Signed-off-by: Drew Davenport <ddavenport@google.com>
Edid are not the most reliable when it comes to panel size, however it
seems like preferred DTD are slightly more reliable. This change moves
from the drm parse edid display size to the first preferred DTD to try
improve dpi accuracy.
If no preferred DTD is available we still fallback to the display size.
Change-Id: Ibcc95da9f38ba74e9b95b9d68587b38efbed8de2
signed-off-by: Lucas Berthou <berlu@google.com>
When config groups are enabled, the framework uses the Multiple Refresh
Rate feature, which causes blank screen issues on some devices, making
them unusable.
This is a temporary solution until we find a reliable way to query the
driver if a seamless mode change is supported.
Discussion can be found [here][1]
[1]: https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/-/merge_requests/295#note_2770300
Change-Id: If17c29de9f2cd853887ece5fe050e4ceee5ddb65
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Retrieve color and HDR information from the EDID.
Change-Id: I1aac27644d5c4fd5d5f295ca32b69ed69e94e0c6
Signed-off-by: Sasha McIntosh <sashamcintosh@google.com>
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>
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>
To clean things up and unify the usage of properties.
Change-Id: I0e034ed309f5f8a0d4fc9be7a4a3edcb39050e7f
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Android framework will change between configs in the same config group
dynamically, to support the Multiple refresh rate [1] feature. If the
display driver does not support changing modes seamlessly, there will be
visible artifacts (blank screen) when changing refresh rates.
Add a property to disable config grouping on devices that do not support
seamless mode changes. Set the default value to enable config grouping.
[1] https://source.android.com/docs/core/graphics/multiple-refresh-rate
Change-Id: Iec5927ea3af063669f6f7b7aa430e541c1c35428
Signed-off-by: Drew Davenport <ddavenport@google.com>
Check the "Present Not Reliable" property to determine if the capability
PRESENT_FENCE_IS_NOT_RELIABLE should be enabled or not.
The virtio gpu module sends frames to the host as fast as possible and
does not emulate "real display timing". Devices using the virtio gpu
module (for example, the virtual Android device Cuttlefish) should set
the following property to "true" to enable the capability:
ro.vendor.hwc.drm.present_not_reliable.enabled
For example, in an Android BoardConfig.mk:
PRODUCT_VENDOR_PROPERTIES += \
vendor.hwc.drm.present_not_reliable.enabled=true
Signed-off-by: Tim Van Patten <timvp@google.com>
Commit e11f723f ("drm_hwcomposer: Query property when checking virtual
displays availability") introduced a call to
android::base::GetBoolProperty, which is only available in Android.
This caused the test "hwcomposer.filegroups_build_test" to fail because
the code was no longer compiling for Linux-native targets.
Fix that by replacing "android::base::GetBoolProperty" with a new
function "property_get_bool," and define the function for both Android
and non-Android targets:
For Android, utilize the existing function from <cutils/properties.h>
For other targets, a new implementation is provided in
utils/properties.h.
Fixes: e11f723f ("drm_hwcomposer: Query property when checking virtual
displays availability")
Signed-off-by: Paz Zcharya <pazz@google.com>
When the ResourceManager is destructed, the UEvent thread continues to
run in the background.
Change the blocking read call to poll, and create an eventfd on which to
poll as well. When ResourceManager is destructed, write to the eventfd
to wake the UEvent thread, which can then exit cleanly.
Reported-by: Normunds Rieksts <normunds.rieksts@arm.com>
Change-Id: I18d92173165f31fcd01570e65a6ffd840c8cd138
Signed-off-by: Drew Davenport <ddavenport@google.com>
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>
utils/worker is no longer used and can be removed.
Change-Id: I5fc9bd2b3b8b0375622ee2446044d3b893756b30
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Some of existing include guards were copy-pasted without modification,
therefore have incorrect name. Switch to 'pragma once' in order to fix
it and avoid such copy-paste issues in the future.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
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>
1. Move BlendMode, ColorSpace, SampleRange fields to the struct BufferInfo,
allowing extraction of the data from native_handle using Metadata@4 API.
Use it when data from HWC2 API can't be used (Currently it's a BlendMode
case for CLIENT layer)
2. Rename DrmHwcLayer to LayerData and move it to compositor/ directory.
(I was confused in the past because of similarity of names DrmHwcLayer
vs HwcLayer, so this step should meke it easier for newcomers to
understand the code)
3. Allow clonning of the LayerData to propagate it through the composition
pipeline. Thus LayerData can be used by both HwcLayer to track state
and by the compositor.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
This is a bit of code modernization. Further changes will require indication
that buffer_info is valid, and using std::optional is the most correct
approach to do that.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
GetReleaseFences() should return release fence for the prior buffer
(not for the one assigned to layer at the moment of GetReleaseFences call).
Once not provided, old front buffer can be damaged before new buffer
presented. (Such issues start to appear once we started using
non-blocking DRM/KMS commits).
Using present (out) fence is a perfect solution, since it is
signaled once old buffer replaced with the new one.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Additionally:
1. Fix new clang-tidy findings
2. Disable readability-identifier-length check for all tidy levels
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Dumping uevents is useful for debugging purposes.
1. Extract logic related to uevent socket into utils/UEvent.h class.
2. Use it by both UEventListener.cpp and tests/uevent_print.cpp.
Bump clang-tidy level of UEventListener.cpp to normal.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Bad implementation was found during code surfing.
At this moment function is used only as a stub for CI.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
- Enabling readability-ientifier-naming tidy check does require to specify
MacroDefinitionIgnoredRegexp key, which is available only in clang-tidy-12.
- Clang-12 isn't available on ubuntu 20.10, therefore upgrade to 21.04.
- "DEBIAN_FRONTEND: noninteractive" is required to prevent ubuntu 21.04
from hanging, presumably due to waiting for the user input.
- A positive side effect of upgrading to clang-12 is new clang-tidy-12,
which exposed new issues in the code which is also fixed by this commit,
e.g:
Failed cppcoreguidelines-narrowing-conversions check with error:
error: narrowing conversion from 'uint32_t' (aka 'unsigned int') to 'float'
require explicit casting to pass the check, while some of such fails are caused
by incorrect variable type and fixed by changing the type to correct one.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Motivation:
Current implementation of UniqueFd can be used in a different ways,
making analytical tracking of FD lifecycle much harder than it may be.
Keep this part clean is very important, since any wrong code may open
a hard-to-detect runtime bugs and fd leaks, which may accidentally slip
into the production.
Implementation:
1. Combine UniqueFd anf OutputFd into single class.
2. Reduce the API to be minimal and sufficient.
3. Document the API and use cases.
4. Move to utils/UniqueFd.h.
5. dup(fd) was replaced with fcntl(fd, F_DUPFD_CLOEXEC)) to
address clang-tidy findings. Find more information at [1]
[1]: https://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-dup.html
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>