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
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
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
Backend shouldn't directly mutate HwcLayer state, so make HwcLayer
const. Make a few other related functions const correct as well.
Change-Id: Id7f8e255e9e72b756399b1a4dabc3db779d64bc9
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>
This change adds per-plane damage info to atomic commit.
Change-Id: I55e6285a0b83fac6342fd736342b3950c488b508
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
drm atomic test will fail if the source crop exceeds the size of the
buffer. This case could happen due to bugs in surfaceflinger.
To avoid an atomic test failure leading to scene flattening, check the
source crop before configuring the drm properties.
Change-Id: Ife33af8cd0dd0983ae9278945d653043a29e649d
Signed-off-by: Drew Davenport <ddavenport@google.com>
This change adds special handling for buffers that may be committed to the
cursor plane. Some drivers may enforce size constraints on cursor plane
commits, which can be satisfied by padding the buffer beyond its nominal
width and height. This change adds behavior to extract that padding
(i.e. the aligned dimensions) by analyzing the buffer pitch, size, and
format.
When the cursor usage flag is set on a buffer, the aligned dimensions
should be used in place of the nominal dimensions for creating the
framebuffer, checking compatibility to the cursor plane, and for setting
the display and crop rects during commit.
Change-Id: I1cc2aa2f9cd23173cae87ae6e486c3b140b78ad5
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
This change adds a check to DrmPlane::IsValidForLayer which
checks cursor-plane-specific requirements that the layer's
buffer has an acceptable size according to either the plane's
SIZE_HINTS or the device's DRM_CAP_CURSOR_{WIDTH|HEIGHT}
properties.
Change-Id: Ic88699996c6616e8da7a4527b03a12c12422fb8f
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
This change reads and parses the SIZE_HINTS drm plane property. Once
parsed successfully, the size hints indicate recommended sizes to
use with cursor planes, in order of preference [1]. The property is
not populated on planes which do not have DRM_PLANE_TYPE_CURSOR.
[1] https://drmdb.emersion.fr/properties/4008636142/SIZE_HINTS
Change-Id: Ia98a45ab5f279573f61394a357eccc90952528c5
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
This change resolves mispellings in DrmPlane.
Change-Id: I0eaa8963bbb24c3faa800b4cb31645ab78c0d7d3
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
This change fixes a check which determines whether a layer's alpha
is set to opaque. The PresentInfo::alpha property was recently
converted to float, but the check in DrmPlane::IsValidForLayer was
still comparing it to the integer value.
Change-Id: Ie1a8304d7302d1d646d0542be92795e93f57e0d9
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
0.0-1.0F range is a natural way to store alpha value internally,
to be converted later to DRM-specific 0-0xFFFF fixed point type at
DRM layer.
Change-Id: Iedf2b11e53bf38efd08cd4eda1346647b9ff721f
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
This commit introduces two improvements:
1. Introduces frontend-agnostic structures for rects.
2. Support default values in them so that the backend can handle
cases where rects are not specified by the client, like
the client layer display frame, etc.
This reduces the complexity of the Internal layer, making it
feasible to use a single Frontend<->Internal layer API for
regular layers, as well as for the Client and Output layers.
Change-Id: Iab5030ad523d36ea4c5af142f6f628952467d6ab
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
When mirroring, this message spams the logs since we loop over the
device planes for multiple CRTCs and print this message for the primary
planes of each active CRTC.
The case this is avoiding (avoid sharing primary planes) is still valid,
afaict, so leave the return statement.
Change-Id: I14afce4918baa5652ec16a3610fe374cccf72422
Signed-off-by: Sean Paul <seanpaul@chromium.org>
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>
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>
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>
Some DRM driver such as omap_drm allow sharing primary plane between CRTCs.
drm_hwcomposer isn't ready for such a scenarios and fails with an error:
Found more than 1 primary plane for CRTC
Don't report multiple primary planes for single CRTC to satisfy the drm_hwc.
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
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>
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>
Implement DrmCrtc instantiation through CreateInstance() static method,
which helps to reduce complexity of DrmDevice::Init() function.
Move CRTC-to-Display binding information to the DrmDevice class.
Move drm/DrmCrtc.h to Normal clang-tidy checks list by fixing
clang-tidy findings.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
This allow to throw away few lines from DrmDevice::Init() making it less
complicated.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
In addition move logging to GetPlaneProperty(), which allow to reduce
number of LoC by ~50 LoC and increase readability.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
This logic was removed accidentaly during cleanup. Restore it.
Enables hardware-accelerated composition on raspberry-pi 4.
Fixes: 5063d53ddf ("drm_hwcomposer: Improve handling of blending mode")
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Benefits:
1. Improve readability.
2. Less logic in runtime slightly reduces overhead on CPU.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
1. Convert to DrmHwcBlending inside HWC hook.
2. Use map for enum_values for cleaner atomic commit preparation.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
Part of "frontend" isolation activities.
Also allows to additionally simplify atomic commit.
Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
The first tuple element returned by GetEnumValueWithName is just the index
of that enum, which is not useful.
Signed-off-by: Benjamin Li <benl@squareup.com>
Currently we only check for the presence of any rotation support -- but
hardware may choose to, say, only support 180 degree rotation. Respect
the specific rotation capabilities reported through DRM properties.
Signed-off-by: Benjamin Li <benl@squareup.com>
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>
Build android-agnostic code in linux environment.
Enable static code analysis using clang-tidy.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>