OSDN Git Service
Matvii Zorin [Mon, 27 Jul 2020 15:35:39 +0000 (18:35 +0300)]
drm_hwcomposer: Move DrmHwcTwo internal classes outside private section
Making backend-validation for HwcDisplay is required access to
the internal class outside DrmHwcTwo. There is no need to keep other
internal classes in the private section in this case.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Matvii Zorin [Mon, 27 Jul 2020 15:29:15 +0000 (18:29 +0300)]
drm_hwcomposer: Add include guard into drmhwctwo.h
Include guard was missed for the file.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Jason Macnak [Thu, 20 Aug 2020 18:49:51 +0000 (11:49 -0700)]
drm_hwcomposer: Move properties into vendor namespace
... to fix VTS VtsTrebleSysProp#testVendorPropertyNames.
Signed-off-by: Jason Macnak <natsu@google.com>
Matvii Zorin [Fri, 17 Jul 2020 09:08:45 +0000 (12:08 +0300)]
drm_hwcomposer: Add feature to search for KMS DRI card
Most modern SOCs have separate IP cores for GPU and Display Unit (KMS).
Also, there is no warranty that the KMS card will always have
/dev/dri/card0 path and GPU - /dev/dri/card1, but drm_hwcomposer should
open only KMS device. The order can depend on many factors. For example:
on the rpi4 board, it was observed that enabling the WIFI kernel module
swapping the card order. Therefore searching for the KMS card is the only
efficient solution.
The IsKMSDev function returns true when the file descriptor on the path
is successfully opened, the drmlib function is returned resources and
the target device has at least one CTRC, connector, and encoder. Also,
the patch enables finding KMS devices in the case of the absence of
the system property specification.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I8874a50188207833389fadd4815b42a80bf69240
Andrii Chepurnyi [Fri, 3 Jul 2020 08:21:33 +0000 (11:21 +0300)]
drm_hwcomposer: Implement *DisplayBrightness* stubs
Implement *DisplayBrightness* stub to be able boot
Android 11 using android.hardware.graphics.composer@2.3-service.
This change caused by error during boot:
failed to get hwcomposer2 function 61
61 is equal to SetDisplayBrightness.
GetDisplayBrightnessSupport is a companion of it.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Idacb32abdcf7ac399ef989f24ab7a360248466f9
Andrii Chepurnyi [Wed, 29 Apr 2020 20:15:28 +0000 (23:15 +0300)]
drm_hwcomposer: Implement SetColorModeWithIntent stub
Fix VTS test GraphicsComposerHidlTest.SetColorMode_2_2BadParameter.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: Ia8ae6c0d7cb2a6bf09c205a04963ed359c5126a3
Andrii Chepurnyi [Fri, 24 Apr 2020 11:20:24 +0000 (14:20 +0300)]
drm_hwcomposer: Implement GetRenderIntents stub
Fix VTS test GraphicsComposerHidlTest.GetRenderIntentsBadDisplay.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I5ceec735b5684581178070e75d96f5961b774f5f
Liviu Dudau [Mon, 15 Jun 2020 16:08:33 +0000 (17:08 +0100)]
drm_hwcomposer: Fix ValidateDisplay() when lowest z-order is nonzero
ValidateDisplay()'s algorithm for achieving minimal GPU load assumes
that the lowest z-order is zero and that layers have sequential z-orders.
CalcPixOps() and MarkValidated() are also written with the same assumption.
However, there is no such guarantee provided by SurfaceFlinger and VTS
tests like PRESENT_DISPLAY_NO_LAYER_STATE_CHANGES fail as they only have
one layer with z-order of 10.
Normalise the mapping between layers and z-order so that the algorithm works
as intended.
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Fixes commit
b7b81cfba252 ("drm_hwcomposer: Choose client layer range to
achieve minimal GPU load")
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I71b76b9d151bf506ad6026f5b1f9de6b6c0dc7c1
Matvii Zorin [Mon, 6 Apr 2020 16:03:03 +0000 (19:03 +0300)]
drm_hwcomposer: Run test commit only when it actually needed
Composition testing is expensive. We do not need to spend CPU time when:
* All layers are marked as a client.
The patch skips CommitFrame function called by the ValidateDisplay
method in this case.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
Paul Howgego [Tue, 9 Jun 2020 17:21:45 +0000 (18:21 +0100)]
drm_hwcomposer: Fix invalid buffer_handle_t pointer
In Android 11, at boot time, I see the following sequence of
calls from SurfaceFlinger that trigger this:
// Composition type for layer is saved in DRM HWC Layer validated_type_
validateDisplay()
// Layer composition type saved in DRM HWC Layer sf_type_
acceptDisplayChanges()
// Composition type in Layer sf_type_ is now "client" so DRM HWC doesn't
// update the Layer buffer pointer
setLayerBuffer()
// DRM HWC Layer sf_type_ is now changed back to "device"
setLayerCompositionType()
// DRM HWC iterates through the layers and finds that Layer composition
// type in sf_type_ is "device" so thinks it is fine to calls
// importBuffer() but this Layer now has an invalid pointer as the
// setLayerBuffer() was ignored.
validateDisplay()
Thus this patch, changes the logic to always update the
buffer_handle_t pointer in setLayerBuffer regardless of
composition type rather than keeping the invalid buffer_handle_t
in the Layer obect. The composition type may be changed back to
device composition by setLayerCompositionType at which point the
Layer object needs to have saved the buffer_handle_t.
Not sure how we could reproduce the same sequence of calls on
another Android version.
Signed-off-by: Paul Howgego <paul.howgego@arm.com>
[jstultz: Reword and add context from merge request to the commit message]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I88a11ee2fee742d6154a482455a8532a95e681d3
Andrii Chepurnyi [Thu, 23 Apr 2020 17:48:13 +0000 (20:48 +0300)]
drm_hwcomposer: Propagate PLATFORM_SDK_VERSION to cflags
PLATFORM_SDK_VERSION is needed for already present
code (GetDisplayIdentificationData/GetDisplayCapabilities),
which implements some of the android.hardware.graphics.composer@2.3 API.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I1a5019e9d8ae327db41f55cee0ba3636f913928f
Andrii Chepurnyi [Tue, 14 Apr 2020 10:03:57 +0000 (13:03 +0300)]
drm_hwcomposer: Fix GetDisplayIdentificationData
Fix GetDisplayIdentificationData, introduced
by commit:
b3d817815fad.
Edid data should be copied instead of assign.
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
John Stultz [Fri, 21 Feb 2020 05:56:34 +0000 (05:56 +0000)]
drm_hwcomposer: Relax failure when no EDID property is found
Crosvm doesn't implement EDID virtio cmd, so when commit
b3d817815fad ("drm_hwcomposer: Add GetDisplayCapabilities
and getDisplayIdentificationData") landed, it broke crosvm
targets using --gpu_mode=drm_virgl
This patch tries to ease that restriction, so a lack of EDID
isn't considered fatal.
Change-Id: I8ce899fc71d2b1187d364918328473ef1890d52d
Signed-off-by: John Stultz <john.stultz@linaro.org>
Peter Collingbourne [Wed, 19 Feb 2020 19:25:08 +0000 (11:25 -0800)]
drm_hwcomposer: Improve error messages.
- Don't negate errno before passing to strerror, at least on
bionic this results in "Unknown error -x" instead of the actual
error.
- Fix another error message to print strerror(errno) instead of the
returned fd which will always be -1.
- Fix another error message to call strerror for consistency.
Signed-off-by: Peter Collingbourne <pcc@google.com>
Roman Kovalivskyi [Mon, 3 Feb 2020 16:13:57 +0000 (18:13 +0200)]
drm_hwcomposer: Add statistics on flattening to dump message
We need some way to verify that current composition is not failed to
compose, but instead sent to flatten on GPU.
Dump message shows current flattening state. It also displays how
often do compositor switches into flattening.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Thu, 30 Jan 2020 18:20:47 +0000 (20:20 +0200)]
drm_hwcomposer: Add fallback to client for layers flattening
Google recommends to delegate composition to GLES instead of HWC when
screen isn't updating to conserve power, as stated on page
https://source.android.com/devices/graphics/implement-hwc.
Current implementation of hwcomposer has flattening of layers if after
some time there were no updates of frames, but it uses writeback
connector. Not every device has a support of writeback feature, so
some sort of fallback should be provided.
It is possible to fallback to client composition in case if writeback
isn't available. This is used to reduce power consumption since
squashing layers into a single layer on GPU and then using that buffer
is more efficient than loading drm device.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Stratiienko [Fri, 20 Dec 2019 15:04:01 +0000 (17:04 +0200)]
drm_hwcomposer: Add property that allows disabling of hardware scaling
Set `hwc.drm.scale_with_gpu` property to 1 in case composer hardware
do not have scaling support.
That will force layers that require scaling to be merged by GPU,
and allow other layers to be merged by DRM.
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
John Stultz [Fri, 7 Feb 2020 21:31:08 +0000 (21:31 +0000)]
drm_hwcomposer: Try to fix build with older Android Pie releases
Try to fix build regressions for P that were introduced with
commit
b3d81781 ("drm_hwcomposer: Add GetDisplayCapabilities and
getDisplayIdentificationData") as noted in issue #30
https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/issues/30
Change-Id: I4bfeb952cff19d4c3511ead69df1186d3a04cc87
Signed-off-by: John Stultz <john.stultz@linaro.org>
Roman Stratiienko [Thu, 23 Jan 2020 16:17:41 +0000 (18:17 +0200)]
drm_hwcomposer: Extract more BO data by Imagination importer v2
Fields bo->hal_format and bo->pixel_stride should be set to pass validation
by Mapper HAL v2.1 and v3.0. Otherwise UI is missing and the following
message appears in the logcat:
```
2576 E GraphicBufferMapper: validateBufferSize(0xe663b3637400) failed: 7
2576 E hwc-drm-utils: Failed to import buffer handle err: 7
2576 E hwc-drm-two: Failed to import layer, ret=7
```
Fixes:
e3ed48d728aa ("drm_hwcomposer: Add Imagination platform support")
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
John Stultz [Tue, 4 Feb 2020 21:53:13 +0000 (21:53 +0000)]
drm_hwcomposer: Revert "drm_hwcomposer: Extract more BO data by Imagination importer"
This reverts commit
b2f2baeb9db0d0f4cbc0cac3184058d3fce85ea6.
I'm trying to utilize a policy of lighter reviews w/ quick reverts
when there are issues to keep things moving. So with that in mind
I'm reverting "Extract more BO data by Imagination importer" since
its breaking the build in AOSP.
See:
https://android-review.googlesource.com/c/platform/external/drm_hwcomposer/+/
1225155/-1..1#message-
828f83ed7fa89b3bdfff7b0b5b1dd7364c822892
https://android-review.googlesource.com/c/platform/external/drm_hwcomposer/+/
1225916
This breakage is due to the importer code being tightly tied to
the gralloc private handle definitions, which is a common problem
as the gralloc and drm_hwcomposers are separately maintained.
The beagle_x15 gralloc is apparently older, and doesn't have
the newly utilized fields.
So for now, revert this to stay in sync w/ AOSP. I'm happy to
re-apply as soon as a fix is in place which adds some sort of
versioning checks so hopefully drm_hwc can work with different
versions of the gralloc code.
Once users of the old gralloc code are updated, we can remove
such version checks if needed.
Change-Id: Ie72561061ea12cb58d3ba9616a62d05f4ffe78b0
Signed-off-by: John Stultz <john.stultz@linaro.org>
Roman Stratiienko [Thu, 23 Jan 2020 16:17:41 +0000 (18:17 +0200)]
drm_hwcomposer: Extract more BO data by Imagination importer
Fields bo->hal_format and bo->pixel_stride should be set to pass validation
by Mapper HAL v2.1 and v3.0. Otherwise UI is missing and the following
message appears in the logcat:
```
2576 E GraphicBufferMapper: validateBufferSize(0xe663b3637400) failed: 7
2576 E hwc-drm-utils: Failed to import buffer handle err: 7
2576 E hwc-drm-two: Failed to import layer, ret=7
```
Also copy suballocs data for future usage.
Fixes:
e3ed48d728aa ("drm_hwcomposer: Add Imagination platform support")
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Kovalivskyi [Thu, 21 Nov 2019 15:15:02 +0000 (17:15 +0200)]
drm_hwcomposer: Remove redundant hotplug call
Initial hotplug state is reported back during callback registration,
but during VTS tests we've noticed error that is caused by calling
hotplug with same display twice.
HandleInitialHotplugState calls hotplug function for each connected
display, so it covers HWC_DISPLAY_PRIMARY too, therefore first call
should be removed, as it is redundant and causes minor error.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Fri, 3 Jan 2020 18:26:45 +0000 (20:26 +0200)]
drm_hwcomposer: Add check to vsync routine to avoid crash on callback
Vsync could be disabled during routine being running and this could
potentially lead to crash on callback invocation. Crash happens if
VSyncControl(false) was called when Routine has cached callback and
unlocked mutex but haven't callback yet. At this point we can't be
sure that callback is still valid so invoking it is incorrect
behaviour.
Second check if vsync is enabled drastically shortens window when we
could go into invalid state, from the whole vblank invocation to
several machine instructions between check and invocation.
Please note that we can't check against cached value in this case,
therefore operations on this flag should be atomic instead.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Lowry Li (Arm Technology China) [Wed, 18 Dec 2019 06:28:22 +0000 (14:28 +0800)]
drm_hwcomposer: Add GetDisplayCapabilities and getDisplayIdentificationData
Implement GetDisplayCapabilities() to get a list of supported capabilities.
The drm core doesn't support layer CTM property yet and CRTC not having the
CTM property member neither. So for this patch, we just return 0 for now.
It can fix the segment fault while booting the Android on HWC2.3, caused by
lack of this API.
Implement getDisplayIdentificationData() to get the EDID blob data
along with the size and port.
Add edid property in DrmConnector.
Signed-off-by: Lowry Li (Arm Technology China) <lowry.li@arm.com>
Roman Stratiienko [Fri, 6 Dec 2019 10:30:28 +0000 (12:30 +0200)]
drm_hwcomposer: Extract ConvertBoInfo() from ImportBuffer() method
To check either BO could be imported on validation stage, we need to
get more information regarding buffer (format, size, etc.)
This extraction also allows us to make ImportBuffer() and CanImport()
methods generic for all platforms.
In case BO can't be imported due to already existant checks in ImportBuffer(),
validator only marks single layer to be elaborated by GPU instead of whole
composition.
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Stratiienko [Fri, 13 Dec 2019 17:28:56 +0000 (19:28 +0200)]
drm_hwcomposer: Choose client layer range to achieve minimal GPU load
1. Allow CLIENT layer at any position.
2. Check all possible layer combination and choose most efficient
based on total pixel operations value.
Use case 1 - Layer count is greater than available planes
Table shows difference before and after this commit for 4 or 2 planes cases:
```
z_order layer size pixels before(4) after(4) before(2) after(2)
-
0 Wallpaper 1960x1080 2MiP CLIENT DEVICE CLIENT DEVICE
1 Launcher 1960x1080 2MiP CLIENT DEVICE CLIENT CLIENT
2 Status bar 1960x80 0.15MiP DEVICE DEVICE CLIENT CLIENT
3 Nav. bar 1960x80 0.15MiP DEVICE CLIENT CLIENT CLIENT
4 Cursor 24x24 576P DEVICE CLIENT DEVICE CLIENT
Total pixels merged by CLIENT (GPU) 4MiP -> 0.15MiP 4.3MiP -> 2.3MiP
```
Use case 2 - Unsupported layer type in the middle (Dim layer, etc):
Table shows difference before and after this commit for 4 or 2 planes cases:
```
z_order layer size pixels before(4) after(4) before(2) after(2)
-
0 App 1960x1080 2MiP CLIENT DEVICE CLIENT DEVICE
1 Status bar 1960x80 0.15MiP CLIENT DEVICE CLIENT CLIENT
2 Nav. bar 1960x80 0.15MiP CLIENT DEVICE CLIENT CLIENT
3 Dim layer 1960x1080 2MiP CLIENT CLIENT CLIENT CLIENT
4 Dialog 1000x500 0.5MiP DEVICE CLIENT DEVICE CLIENT
Total pixels merged by CLIENT (GPU) 4.3MiP -> 2.5MiP 4.3MiP -> 2.8MiP
```
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Kovalivskyi [Wed, 11 Dec 2019 17:09:51 +0000 (19:09 +0200)]
drm_hwcomposer: Add simplistic SetColorTransform implementation
VTS tests for SET_COLOR_TRANSFORM fails for now since
SetColorTransform is marked as unsupported function. this commit tries
to address this issue. We can't make complete implementation of those
features for our platform for now, so we'd just save arguments for
future use and force client composition if any color transformation is
requested. This is perfectly acceptable way to pass VTS testcase for
SET_COLOR_TRANSFORM.
Commit
da5839cf9258 ("drm_hwcomposer: Add support for GetColorModes &
SetCursorPosition") implements GetColorModes and SetCursorPosition
simply by adding fields that store this values for future
uses. Therefore we assume that it is okay to use this approach to at
least support interface part.
Please note that if transform hint is identity then no
transformation should be applied. If hint is arbitrary matrix then
given matrix should be applier after composition, though for now we'd
just force client composition instead. This behavior is required by
HAL interface as stated in
hardware/interfaces/graphics/composer/2.1/IComposerClient.hal, line
738 from repository
https://android.googlesource.com/platform/hardware/interfaces, tag
android-10.0.0_r14
Please note that color transform matrix argument is an array that has
16 elements by contract, as it is 4x4 matrix. This is why
MATRIX_SIZE has such value.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Wed, 11 Dec 2019 15:48:44 +0000 (17:48 +0200)]
drm_hwcomposer: Add simplistic SetLayerColor implementation
VTS tests for SET_LAYER_COLOR fails for now since SetLayerColor is
unsupported function. Tis commit tries to address this issue. We can't
fully implement it for now, therefore simplistic implementation that
just saves argument for future uses and satisfies the interface could
be used instead, for now.
Commit
da5839cf9258 ("drm_hwcomposer: Add support for GetColorModes &
SetCursorPosition") implements GetColorModes and SetCursorPosition in
the same fashion, simply by adding fields that store this values for
future uses, therefore we assume that it is okay to use this approach
here too.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Vincent Donnefort [Fri, 2 Aug 2019 10:18:35 +0000 (11:18 +0100)]
drm_hwcomposer: Add refcount for GEM handle
The linux kernel doesn't provide reference counting for the handle
returned by FD_TO_HANDLE ioctl. It means that if the same Gralloc buffer
is imported twice, the first GEM_CLOSE will destroy the handle even if it
is still in use by another import.
Remedy this issue by doing the reference counting directly in the DRM
generic platform support: ImportHandle() will increase the reference,
while ReleaseHandle() will decrease and close it, if necessary.
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Roman Stratiienko [Thu, 28 Nov 2019 15:51:16 +0000 (17:51 +0200)]
drm_hwcomposer: Introduce dumpsys metrics
To make optimal performance/power consumption ratio we want to use composing by
dedicated hardware to merge as much as possible composition cases.
We are going to continuously optimize and improve drm_hwcomposer HAL, that
makes high demand on formal validation process.
Introduce "pixel operation" definition. It should be in direct ratio with power
consumption, but currently it roughly calculated as sum of pixels merged by
each layer.
In some future we should apply some average gains depending of operation type
to calculate pixops more precisely. (e.g. scaling should take more pixops than
blending, and blending should take more that copying, etc.).
Using pixops could be very helpful when drm_hwc HAL have a choice which layer
sets to merge by GPU, making possible minimal energy model based planning.
Create statistics of the following events:
1. Total frames count
2. Total pixel operations
3. Pixel operations validated to use GPU (CLIENT)
4. Calculate composer efficiency: DEVICE/TOTAL operations ratio
5. Failed atomic validation commits count
6. Failed atomic presenting commits count
Usage:
- $ adb shell dumpsys SurfaceFlinger
Statistics will be shown at the end of the dump in 2 forms:
1. Since system launched
2. Since last dumpsys command called
Using statistics for the regression slope monitoring example:
1. Boot the board without the change
2. Use touch or keyboard (avoid using of mouse pointer) to do some predefined
actions (open application, start video, etc.)
3. Save the metrics
4. Boot the board with the change
5. Do exactly the same actions as in (2)
6. Save the metrics
7. Use metrics before and after change to indicate regression slope
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Matteo Franchin [Tue, 3 Dec 2019 17:10:38 +0000 (17:10 +0000)]
drm_hwcomposer: Fix returned fence in PresentDisplay
DrmHwcTwo::HwcDisplay::PresentDisplay was always returning -1 as the
present fence. This commits ensures the fence fd is correctly retrieved
after doing the commit-frame operation. It also updates outdated logic
that caused PresentDisplay to return the retire fence rather than the
present fence.
DrmHwcTwo::HwcDisplay::AddFenceToPresentFence is also changed so that
it assumes it is given ownership of the file descriptor it receives as
argument. This function was indeed called consistently with this
behaviour, which meant the dup led to leakage of file descriptors.
With the changes above this patch fixes a failure in the CTS test
dEQP-VK.wsi.android.display_timing.fifo.display_timing (for example
running Android 10 on HiKey960). The test failed with the error
"Unexpectedly received invalid timestamp." reported multiple times in
the logcat output.
Change-Id: If662e5239895b8b0e2ea31fd99747855f901a427
Signed-off-by: Matteo Franchin <matteo.franchin@arm.com>
Roman Kovalivskyi [Mon, 25 Nov 2019 17:17:53 +0000 (19:17 +0200)]
drm_hwcomposer: Add safe guard for unknown connector type
There is potential possibility that new connector type will be added
into DRM and it won't be handled by drm_hwcomposer immediately so it's
better to be safe and report error via logcat than crash with
out-of-bounds.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Mon, 25 Nov 2019 17:13:05 +0000 (19:13 +0200)]
drm_hwcomposer: Fix compilation issues with Android 9
It appears that class template argument deduction is unavailable on
all target platform compilers, therefore it would be better to come
back to explicit template parameters.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Stratiienko [Wed, 27 Nov 2019 17:23:03 +0000 (19:23 +0200)]
drm_hwcomposer: Fix missing definition build error on P and earlier
DRM_FORMAT_INVALID was introduced after libdrm-2.4.94, and does not exists in
Android-P and earlier.
Fixes:
f63726cabf3f ("drm_hwcomposer: avoid using signed errno on uint32 type")
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Kovalivskyi [Mon, 4 Nov 2019 15:54:31 +0000 (17:54 +0200)]
drm_hwcomposer: Add property hwc.drm.primary_display_order
There are cases when primary display lookup order should be
overriden. This could be achieved with adding system property
hwc.drm.primary_display_order.
Example of primary_display_order property usage:
hwc.drm.primary_display_order=HDMI-A-2,HDMI-A-1,...
This means that first priority goes to HDMI-A-2 connector, then
HDMI-A-1 connector, then everything else. Internal connectors have
higher priority than any other connectors not mentioned in property.
Connected connector with highest priority would be selected as a
primary display.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Kovalivskyi [Mon, 4 Nov 2019 15:43:40 +0000 (17:43 +0200)]
drm_hwcomposer: Add DrmConnector::name function
Connectors usually are referred by names, but libdrm stores type and
id only as a numbers so for more convenience conversion function from
integerst to string should be added.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Roman Stratiienko [Fri, 8 Nov 2019 15:16:11 +0000 (17:16 +0200)]
drm_hwcomposer: Apply same logic for 'CURSOR' layers as for 'DEVICE'
Cursor usually is most top layer. Since it validates as CLIENT, it causes
remain layers to be validated as CLIENT, resulting performance dropping.
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Stratiienko [Wed, 20 Nov 2019 23:58:35 +0000 (01:58 +0200)]
drm_hwcomposer: Fix mixed layer composition
Fix cases when mixed layer composition require non-device layer in the middle:
'''
Layer z_order - SF type - validated type before - validated type fixed
0 - DEVICE - CLIENT - CLIENT
1 - DEVICE - DEVICE - CLIENT
2 - DEVICE - DEVICE - CLIENT
3 - SOLIDCOLOR - CLIENT - CLIENT
4 - DEVICE - DEVICE - DEVICE
'''
In such composition SF will merge layers 0 and 3 and hwcomposer will
merge <SF>,1,2,4 that results incorrect merging order.
Issue was observed on the rcar3 (imagination importer), db845c and allwinner H3
(Generic importer) platforms.
Reproduces with compositions that requires 'cursor' or 'dim' layers.
How to reproduce:
1. Connect USB mouse when on home screen, you should see mouse cursor
under icons (Tested with Launcher3QuickStep desktop)
2. Go to Settings -> WIFI -> Connect to the AP, then you should see
password dialog under AP list.
Solution:
1. Mark intermediate layers as CLIENT to ensure CLIENT section is in range
from bottom layer to most top CLIENT layer.
2. Use this layer composition to validate if DRM can handle it.
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Stratiienko [Thu, 17 Oct 2019 14:42:36 +0000 (17:42 +0300)]
drm_hwcomposer: Add Imagination platform support
External Android.bp file should be created in order to build this module:
```
cc_library_shared {
name: "hwcomposer.drm_imagination",
defaults: ["hwcomposer.drm_defaults"],
srcs: [":drm_hwcomposer_platformimagination"],
whole_static_libs: ["drm_hwcomposer"],
shared_libs: ["libion"],
include_dirs: [
"path/to/imgtec/include/files",
],
}
```
libion is needed to make ion.h header visible `linux/ion.h`.
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Roman Stratiienko [Wed, 6 Nov 2019 13:03:12 +0000 (15:03 +0200)]
drm_hwcomposer: avoid using signed errno on uint32 type
DrmGenericImporter::ConvertHalFormatToDrm() should not return negative values.
- Use DRM_FORMAT_INVALID instead of -EINVAL
- Check DrmGenericImporter::ConvertHalFormatToDrm() result value in
DrmGenericImporter::ImportBuffer()
Signed-off-by: Roman Stratiienko <roman.stratiienko@globallogic.com>
Vincent Donnefort [Wed, 9 Oct 2019 14:43:43 +0000 (15:43 +0100)]
drm_hwcomposer: HWC2: Handle bad layer_handle
HWC2 can issue a command with an incorrect layer handle. Making sure a such
error is caught with the expected HWC2 error code BadLayer
This can be verified with the VTS test:
* GraphicsComposerHidlTest.DestroyLayerBadLayerError
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Vincent Donnefort [Wed, 9 Oct 2019 13:23:42 +0000 (14:23 +0100)]
drm_hwcomposer: HWC2: Handle bad display_handle
HWC2 can issue a command with an incorrect display handle. Making sure a such
error is caught with the right HWC2 error code BadDisplay.
This can be verified with the VTS tests:
* GraphicsComposerHidlTest.DestroyLayerBadDisplay
* GraphicsComposerHidlTest.CreateLayerBadDisplay
* GraphicsComposerHidlTest.GetActiveConfigBadDisplay
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Vincent Donnefort [Wed, 9 Oct 2019 14:53:56 +0000 (15:53 +0100)]
drm_hwcomposer: HWC2: Align SetColorMode Error with Android VTS
Android VTS tests expect to get BadParameter error for an unknown color
mode.
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Vincent Donnefort [Wed, 9 Oct 2019 10:39:28 +0000 (11:39 +0100)]
drm_hwcomposer: HWC2: Align SetPowerMode Errors with Android VTS
Android VTS tests expect to get Unsupported error for Doze and DozeSuspend
modes and BadParameter for the rest.
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Neil Armstrong [Thu, 10 Oct 2019 09:35:57 +0000 (09:35 +0000)]
drm_hwcomposer: platformmeson: fix AFBC 32x8 feature support
Since MALI_GRALLOC_INTFMT_AFBC_BASIC is mandatory even
to enable 32x8 block size, do not OR 32x8 and 16x16
overwise the final modifier will be invalid.
Change-Id: Ifa20a29e9c012b8ce0ec598d76e26514a61b52c8
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Mykhailo Sopiha [Thu, 11 Jul 2019 11:31:09 +0000 (14:31 +0300)]
drm_hwcomposer: add LCD panel support
This commit adds support for LCD panel as internal
connector.
Change-Id: Iccb96526ee11bc4a9b53fc8dcd9ba0ea218d41b6
Signed-off-by: Mykhailo Sopiha <mykhailo.sopiha@linaro.org>
Mykhailo Sopiha [Mon, 8 Jul 2019 15:28:56 +0000 (18:28 +0300)]
drm_hwcomposer: add non hwfb import filter
This patch adds non hwfb filter to generic drm importer
with additional property "hwc.drm.exclude_non_hwfb_imports".
By default this is set to false, and no logic changes are
happening. On setting this option to 1 the filter is being
activated on Init() function.
Change-Id: I7a718a66cb6214c051335a4589d60b5833e5c545
Signed-off-by: Mykhailo Sopiha <mykhailo.sopiha@linaro.org>
Neil Armstrong [Thu, 20 Jun 2019 09:00:21 +0000 (09:00 +0000)]
drm_hwcomposer: pre-filter modes provided to HWC2
Currently LocalDisplayAdapter in AOSP filters out similar modes based
on their currently limited supported attributes: width/height/refresh.
This leads to a situation where important modes are discarded, like the
preferred mode and/or the active mode, leading SurfaceFlinger to select
an unwanted and potentially invalid mode in the list provided by
drm-hwcomposer to HWC2.
Let's pre-filter the modes provided to HWC2 by :
- systematically adding the preferred mode
- systematically adding the current active mode, if different
from preferred mode
- keeping the interlaced modes filtering-out if no other non-interlace
modes with same widthXheight exists (for HD-Ready 1080i TVs or CVBS)
- discarding modes if a similar mode with same widthXheight@refresh was
already selected for HWC2
This mimics the behavior of LocalDisplayAdapter filtering algorithm,
but keeps the important modes from the DRM Point Of View and drops the
duplicate modes while keeping the mode ordering from DRM in account.
This local filtering should ultimately go out when HWC2 can actually
handle mode Attributes to describe Preferred mode, Interlaced, 3D...
and LocalDisplayAdapter uses these Attributes for filtering duplicate
modes.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: John Stultz <john.stultz@linaro.org>
Sean Paul [Tue, 2 Apr 2019 20:57:20 +0000 (16:57 -0400)]
drm_hwcomposer: Organize files into subdirs
This is way overdue
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I1bcbd8fdb0bb03feafd76bc41f6f11c03cdf9c25
Neil Armstrong [Thu, 25 Apr 2019 15:17:22 +0000 (15:17 +0000)]
drm_hwcomposer: Add platformmeson for Amlogic SoC support
This specific platform handler is dedicated for the Amlogic SoC,
and more precisely for the Amlogic G12A family.
OpenGL/Mali allocation is done via a slightly modified ARM Gralloc
module, thus needing a custom platform handler to handle the custom
private_handle_t structure.
This platformmeson is based on platformhisi without the AFBC YUV
management (not handled by the Amlogic SoCs).
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Change-Id: I1a1d20b0a84b0e17aa3417c8e9633712f258523d
Neil Armstrong [Tue, 4 Jun 2019 14:48:02 +0000 (14:48 +0000)]
drm_hwcomposer: Drop modes with DRM_MODE_FLAG_INTERLACE to HWC2
HWC2 has currently no support for interlaced modes, and will conflict
with non-interlaced modes for now.
Drop them in DrmHwcTwo::HwcDisplay::GetDisplayConfigs(), correctly
handling the two phase calls to GetDisplayConfigs() giving a valid
num_configs without the interlaced modes.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Mykhailo Sopiha [Thu, 6 Jun 2019 11:45:27 +0000 (14:45 +0300)]
drm_hwcomposer: clean Importer inherited classes
Move some common logic from Importer class implementations
into DrmGenericImporter class:
- reused generic constructors and destructors for derived
classes
- formed common Init() logic for all derived classes
- removed unused gralloc_ and drm_ variables from derived
classes
- made drm_ protected for base class to be reused in derived
Signed-off-by: Mykhailo Sopiha <mykhailo.sopiha@linaro.org>
Neil Armstrong [Tue, 4 Jun 2019 14:37:51 +0000 (14:37 +0000)]
drm_hwcomposer: recalculate vrefresh from clock + resolution
For DMT modes and HDMI modes with 1000/1001 variations, the kernel
reports the vrefresh in integer, rounded up, thus 59.94Hz or 23.97Hz
are reported as 60Hz and 24Hz to userspace.
To solve this, recalculate the vrefresh from clock + resolution.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Victor Chong [Thu, 11 Apr 2019 05:23:28 +0000 (06:23 +0100)]
drm_hwcomposer: platformhisi: extend conditional of AFBC support
The AFBC modifiers in [1] are defined in aosp bionic's drm headers only
if it has been updated to v4.19 kernel headers [2]. If the version used
is older, drm_hwcomposer build will fail, so we extend the conditional
of the AFBC logic to include one of these modifiers.
[1]
cc5fca4f ("drm_hwcomposer: Add support for Arm Framebuffer Compression (AFBC) modifiers.")
[2] https://android.googlesource.com/platform/bionic/+/
9ce28844db7cf80ee8cf7c88dab23b666eaab739
Signed-off-by: Victor Chong <victor.chong@linaro.org>
Colin Cross [Fri, 29 Mar 2019 17:27:23 +0000 (10:27 -0700)]
drm_hwcomposer: Move hwcomposer.drm_hikey and hwcomposer.drm_hikey960
Prevent external/drm_hwcomposer from referencing device/linaro/hikey,
which may not exist in all trees, by compiling most of drm_hwcomposer
as a static library and then compiling just the source files that
are affected by device-specific #defines and #includes in
device/linary/hikey/gralloc*.
Fixes:
129543119
Test: m hwcomposer.drm_hikey hwcomposer.drm_hikey960 MODULES-IN-external-drm_hwcomposer
Change-Id: I800b147a40c4e368ce1a74273728f5941f6b63c4
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Colin Cross [Fri, 22 Mar 2019 20:13:12 +0000 (13:13 -0700)]
drm_hwcomposer: Convert external/drm_hwcomposer to Android.bp
See build/soong/README.md for more information.
This replaces the product and BoardConfig.mk variable conditionals
with different versions of the HAL for each product, which will
also allow checkbuild to verify that they build even on products
that don't use them.
Fixes:
122332597
Test: mma
Change-Id: I8d2c8ac1bb58dcbc81ae75c2bb2c97d4485909b4
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
John Stultz [Thu, 28 Mar 2019 22:18:53 +0000 (15:18 -0700)]
drm_hwcomposer: Remove unnecessary parentheses in the conditional
As requested by Sean, remove unnecessary parens around the
!preferred_mode_found check.
Change-Id: Ibca46c104ab54be894b860373fc42ec047afd337
Signed-off-by: John Stultz <john.stultz@linaro.org>
John Stultz [Wed, 27 Mar 2019 04:11:31 +0000 (21:11 -0700)]
drm_hwcomposer: Tweak mode selection to pick the first DRM_MODE_TYPE_PREFERRED mode
With commit
1b1e35eb ("drm_hwcomposer: Chose preferred mode with
type DRM_MODE_TYPE_PREFERRED"), we now pick a preferred mode
rather then just the first mode to use.
However, on some systems there may erroniously be multiple modes
marked as DRM_MODE_TYPE_PREFERRED. In this case, the logic added
in that commit ends up selecting the *last* preferred mode.
This seems less likely to be the desired choice, compared to
what we had before (which picked first mode provided).
So this patch alters the selection logic to only use the first
DRM_MODE_TYPE_PREFERRED mode found, rather than the last.
Change-Id: Ieb3e5d946b96099f14c1c5a287ca8113360a39d1
Signed-off-by: John Stultz <john.stultz@linaro.org>
Sean Paul [Tue, 19 Mar 2019 16:47:35 +0000 (12:47 -0400)]
Revert "drm_hwcomposer: platformgeneric: Fix build"
This reverts commit
112903781ca34a39320d99bc68bd9f971182aa27.
Per discussion in !47 [1], this is not needed.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
[1]- https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/merge_requests/47
Alexandru Gheorghe [Tue, 8 Jan 2019 17:21:08 +0000 (19:21 +0200)]
drm_hwcomposer: Set zpos relative to the minimum possible value
Current implementation doesn't handle properly the cases where zpos
range starts from 1.
See https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/issues/19#note_100622
Fixes:
ea1c5e5a ("drm_hwcomposer: Add z order support")
Signed-off-by: Alexandru Gheorghe <alexc.g1.ro@gmail.com>
[seanpaul converted to std::tuple return type]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I35dc2c1cfd0e38ca3a47cf4e668eeb5f3c470ddb
Sean Paul [Wed, 13 Mar 2019 18:36:52 +0000 (14:36 -0400)]
drm_hwcomposer: Rename DrmProperty::immutable()
To be a little more precise, add an 'is_' prefix
Change-Id: Idd8fe45a4dfba1cd778b4ed6b761ec489697c31a
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Sean Paul [Wed, 6 Mar 2019 14:48:42 +0000 (09:48 -0500)]
drm_hwcomposer: Change return type of DrmProperty::value() to tuple
To keep consistent with other functions
Change-Id: I11ba07eabcee08f3db09b3a5422bc480482a62c1
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Sean Paul [Fri, 15 Mar 2019 19:18:46 +0000 (15:18 -0400)]
drm_hwcomposer: Use proper commit for author/committer check
The script uses the author/committer of HEAD instead of the commit it is
inspecting. This fails when a patch set has different authors/committers
(such as https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/merge_requests/46)
Change-Id: I0fcd724cf372fad435c7614777f13e015c204c3d
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Andrii Chepurnyi [Wed, 6 Mar 2019 13:01:59 +0000 (15:01 +0200)]
drm_hwcomposer: platformgeneric: Fix build
Propagate correct include path for gralloc_handle.h
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Andrii Chepurnyi [Tue, 19 Feb 2019 19:38:13 +0000 (21:38 +0200)]
drm_hwcomposer: Chose preferred mode with type DRM_MODE_TYPE_PREFERRED
According to the Linux Kernel: "DRM_MODE_TYPE_PREFERRED: Preferred mode,
usually the native resolution of an LCD panel. There should only be
one preferred mode per connector at any given time."
Will use it during preferred mode choice.
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Andrii Chepurnyi [Wed, 1 Aug 2018 14:42:56 +0000 (17:42 +0300)]
drm_hwcomposer: Added hotplug support of the external display
Unplug of the main display will not work because of
Activity Manager code(ActivityStackSupervisor.java:handleDisplayRemoved).
Only one display can be connected as an external
display (see SurfaceFlinger::determineDisplayType).
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
Andrii Chepurnyi [Fri, 27 Jul 2018 12:14:37 +0000 (15:14 +0300)]
drm_hwcomposer: Fix VSYNC control
Use HWC2_VSYNC_ENABLE for correct state recognition.
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
John Stultz [Thu, 28 Feb 2019 05:35:03 +0000 (21:35 -0800)]
drm_hwcomposer: Initialize buffer_ pointer to NULL
In some cases, we've seen drm_hwcomposer start to try to
compose frames before anything has called SetClientTarget().
This seems to be some sort of a race, which for some reason
we only see with certain dummy HDMI dongles (which provide
fake EDID data) which allow our lab machines to run headless.
I'm still trying to understand more about why this happens
only in this case.
The net of the issue is we see CreateComposition() being called,
which adds the client_layer_ to the zmap. Then it creates the
DrmHwcLayers copying the non-initialized buffer_ value as the
sf_handle.
This then later causes a crash in ImportBuffer() when we
traverse the non-null (but invalid) hnd value.
Thus, this patch simply initilizes the buffer_ pointer to NULL
so that we error out properly in the case of the race.
Reported-by: YongQin Liu <yongqin.liu@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I5fde3fccde86519edb04e61cbc2842eda395ade4
John Stultz [Thu, 28 Feb 2019 07:34:53 +0000 (23:34 -0800)]
drm_hwcomposer: platformhisi: Conditionalize some of the AFBC support
Unfortunately with the AFBC support patches, I validated with
the hikey960 (which has a gralloc that supports AFBC), but not
with the original hikey board (which does not support AFBC).
Since we use the same importer for both boards, conditionalize
the AFBC logic if those values are not defined.
This patch will also need a tweak to the hikey gralloc to add
support for the handle->internal_format reference (which doesn't
currently exist on hikey's gralloc).
Change-Id: I31aea82b321ff7dd7608c6a3522cbc93bb629319
Signed-off-by: John Stultz <john.stultz@linaro.org>
Ayan Kumar Halder [Mon, 14 Jan 2019 12:47:12 +0000 (12:47 +0000)]
drm_hwcomposer: Add support for Arm Framebuffer Compression (AFBC) modifiers.
One needs to translate the Gralloc buffer flags for AFBC (eg
MALI_GRALLOC_INTFMT_AFBC_BASIC) to the corresponding linux kernel drm modifiers.
This gets passed to libdrm via drmModeAddFB2WithModifiers.
Changes from v1:-
- Moved ConvertGrallocFormatToDrmModifiers() and IsDrmFormatRgb() from 'DrmGenericImporter'
to 'HisiImporter' as suggested by Sean paul
- Check if the format is rgb and set AFBC_FORMAT_MOD_YTR only if any of the AFBC related
Gralloc flags are set.
Changes from v2:-
- Changed ConvertGrallocFormatToDrmModifiers() and IsDrmFormatRgb() from 'public' to 'private'
(suggested by Sean Paul)
Changes from v3:-
- Reordered the members of 'class HisiImporter'. Functions should go above member variables.
(suggested by Sean Paul)
Changes from v4:-
- Rebased and some style changes (as suggested by gitlab-ci-checkcommit.sh)
Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
/-- Note for reviewer
I was able to get this working for hikey960 with aosp/master for kernel 4.14. The libdrm
headers need to be updated as the AFBC modifiers are missing in the aosp/master's external/libdrm.
--/
Change-Id: I66abaa08d19ce88169cc40522b167dfe5efc7036
Sean Paul [Wed, 30 Jan 2019 14:45:21 +0000 (09:45 -0500)]
drm_hwcomposer: Fix check commit script to ignore case and extra spaces
Job 93709 [1] failed with missing committer sign-off. Ayan has their
committer string set to "Ayan kumar halder <ayan.halder@arm.com>", and
the Signed-off-by line on the commit was
"Signed-off-by: Ayan Kumar Halder <ayan.halder@arm.com>". So grep did
what we asked it to do and did not find the SoB since the case was
incorrect.
This patch changes to case-insensitive search and while we're at it,
trims excess whitespace from both the commit body and the
committer/author name.
Finally, I've improved the error message so it's hopefully more clear
why things fail in the future.
[1]- https://gitlab.freedesktop.org/ayan.halder/drm-hwcomposer/-/jobs/93709
Signed-off-by: Sean Paul <seanpaul@chromium.org>
John Stultz [Wed, 9 Jan 2019 22:54:52 +0000 (14:54 -0800)]
drm_hwcomposer: Rework ValidateDisplay layer check to use if statement rather then switch
AOSP's toolchain throws errors on un-annotated switch case
fallthroughs. Rather then adding [[fallthrough]] annotations,
which would add C++17 syntax, switch to using a if statement
instead.
Change-Id: Id0b2bf6d365d50e637569f0c4353ceb4fda21c16
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2: Rework conditional to be more readable as suggested by seanpaul
Jorge E. Moreira [Wed, 19 Sep 2018 22:34:07 +0000 (15:34 -0700)]
drm_hwcomposer: Complete rename of DrmResources to DrmDevice
In AOSP/master, there was a structure renamed, so try to sync
AOSP/master's build fix change to freedesktop/master.
NOTE: I'm not sure how to best submit this, as the upstream
freedesktop/master may have users outside of AOSP/master. But
I'm not sure what devices on an official release are using
drm_hwc so it seems like this would be more useful then not.
Bug:
116154944
Test: builds
Change-Id: I244bd049afae6ba8310f6b6bf2d3b1ee2e891de3
Signed-off-by: John Stultz <john.stultz@linaro.org>
Alexey Firago [Tue, 27 Nov 2018 11:17:55 +0000 (14:17 +0300)]
drm_hwcomposer: platformhisi: Remove fake-importing
With CanImportBuffer() in place we don't need fake importing
anymore. Buffers should be checked before supplied to ImportBuffer()
and plane planner.
Instead of fake importing return -EINVAL for non HW_FB buffers in
ImportBuffer() and skip non HW_FB in planner. Additionally, return
error from planner if we didn't emplace any layer to force client
compositing.
Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
Alexey Firago [Wed, 21 Nov 2018 20:47:05 +0000 (23:47 +0300)]
drm_hwcomposer: Add checking if we can import a buffer
Add CanImportBuffer() function to the Importer interface.
Platform specific importer should check in this function if it can
import given buffer_handle_t. For example platformhisi will return
false for buffers without GRALLOC_USAGE_HW_FB.
This function should be used on ValidateDisplay step to avoid the
need of 'fake-importing' of buffers.
Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
Alexandru Gheorghe [Mon, 17 Sep 2018 09:48:54 +0000 (10:48 +0100)]
drm_hwcomposer: Add z order support
Currently, the planner just pops the first available drm plane and if
that can't be used for the DrmHwcLayer it just returns error.
This proposes a slighlty smarter way to do that by trying to see if
any of the DrmPlane can be used for the DrmHwcLayer in question.
More, if the drm_plane doesn't have a fix zorder then we could re-add
him to the list of unused planes, so it could be used for hosting
other less demanding DrmHwcLayers.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Tue, 9 Oct 2018 15:25:28 +0000 (16:25 +0100)]
drm_hwcomposer: Propagate PlanStage error
All existing stage planers(PlanStageGreedy, PlanStageProtected,
PlanStageHiSi) silently ignore if they couldn't allocate a drmplane
for a drmhwclayer and return success.
That doesn't go well with the assumptions from ValidateDisplay,
where if the atomic check succeeds we just assume that we could do
Device composition for a maximum of num_of_drm_planes layers. But,
since we silently dropped some drmhwclayer we never put those in the
atomic check and we won't put it in the final atomic commit, so we end
up with a wrong composition on the screen.
What this proposes is propagating the error, which will make
ValidateDisplay to fallback on client composition.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Sean Paul [Tue, 4 Sep 2018 19:32:26 +0000 (15:32 -0400)]
drm_hwcomposer: Add commit message validation to CI
Check the subject prefix starts with "drm_hwcomposer: " and we have
Signed-off-by tags for both author and committer.
Change-Id: Ib26b8e5cbeae2156014f2bbfb8703545bdc1decb
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Sean Paul [Tue, 4 Sep 2018 19:30:29 +0000 (15:30 -0400)]
drm_hwcomposer: Pull CI check into dedicated script
This will be useful for adding more functionality to it. It's not very
practical to script inside the yml.
Change-Id: I71aa6b40d282f750eb9bce65dd2cfd9e2828905b
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Lowry Li [Tue, 28 Aug 2018 09:58:21 +0000 (17:58 +0800)]
drm_hwcomposer: Add support for pixel blend mode property
The upstream version of pixel blend mode property will be added
to the DRM core. So added support for pixel blend mode property
to the DrmPlane.
Created ValidatePlane() function in Planner to do the blend check,
and also moved rotation and plane alpha property check there.
Fixed the Emplace() call in platformhisi.cpp as was done with the
other planner implementations.
Change-Id: I7e6714699cf7c222a83de472060d4625e1e6945a
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Signed-off-by: Lowry Li <lowry.li@arm.com>
Tested-by: John Stultz <john.stultz@linaro.org>
Andrii Chepurnyi [Mon, 3 Sep 2018 11:19:40 +0000 (14:19 +0300)]
Fix actual clang-format version in readme
Current .clang-format requires clang-format 5.0
Signed-off-by: Andrii Chepurnyi <andrii_chepurnyi@epam.com>
John Stultz [Tue, 21 Aug 2018 18:21:56 +0000 (11:21 -0700)]
drm_hwcomposer: Add support for P+ environments
Originally-by: Alistair Strachan <astrachan@google.com>
With Android P, the GraphicBufferMapper ImportBuffer interface
has changed, which breaks the current drm_hwcomposer master
branch:
https://android.googlesource.com/platform/frameworks/native/+/
dbbe33b95336efa74e8bb4ebcf6cba50919aa247
Alistair has updated the AOSP/master branch of drm_hwcomposer to
make it build:
https://android.googlesource.com/platform/external/drm_hwcomposer/+/
4f73630dcdab6604a3f4b3e7d59068633d923745%5E2..
4f73630dcdab6604a3f4b3e7d59068633d923745/
But since we need to keep older users working, so I've forward
ported and conditionalized the code so both new and old users
can properly build.
Change-Id: I2089c1105a7074ff13b5ddfe2d2eb7129917794f
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2:
* Fix up LOCAL_CPPFLAGS typeo and unsued variable errors
both found thanks to Alexandru Gheorghe
v3:
* Reordered so this patch comes last
* Squish layer_count calculation patch into this one
John Stultz [Fri, 24 Aug 2018 23:27:36 +0000 (16:27 -0700)]
drm_hwcomposer: Store pixel_stride in the hwc_drm_bo
The new GraphicBufferMapper ImportBuffer takes a pixel_stride
as an argument, so we need to caluclate that and store it in
the hwc_drm_bo at import so we can use it here.
I'd still welcome better ideas to calculate pixel_stride for
generic drm importer.
Change-Id: Iea2c483f3750dd5bed38740802b560911bc54ef2
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v2:
* Utilized pixel stride values already in some gralloc handle
implementations
* Fixed embarasing bit/byte math snafu (preserving bits per
pixel since YUV conversions using bytes doesn't seem sane)
- Extra review still would be appreciated here!
v3:
* Renamed to use Drm... instead of DRM...
John Stultz [Fri, 24 Aug 2018 23:08:57 +0000 (16:08 -0700)]
drm_hwcomposer: Store the HAL_PIXEL_FORMAT_* in the hwc_drm_bo
The new GraphicBufferMapper ImportBuffer takes a format
as an argument, but I believe it wants the HAL_PIXEL_FORMAT_*
and not the DRM_FORMAT value.
So stash the HAL_PIXEL_FORMAT_* into the hwc_drm_bo so we
can pass it along when needed.
Change-Id: Id5b8e0d8c624e26c2c6307f85489665c88a9e75d
Signed-off-by: John Stultz <john.stultz@linaro.org>
John Stultz [Mon, 27 Aug 2018 17:53:07 +0000 (10:53 -0700)]
drm_hwcomposer: Add HWC_DRM_BO_MAX_PLANES constant
Add HWC_DRM_BO_MAX_PLANES to avoid open coded num_gem_handles
calculations.
Change-Id: Iebdaa67518e75f5b7f4445d92b97ca72e625c04b
Signed-off-by: John Stultz <john.stultz@linaro.org>
John Stultz [Tue, 28 Aug 2018 05:24:40 +0000 (22:24 -0700)]
drm_hwcomposer: Fixup Sean's HiSi dummy planner
The dummy HiSi Planner is careful to not try to emplace layers
that aren't HW_FB. However, in some cases we might have a single
layer to draw. In that case the dummy importer will pretend it
imported the buffer, and the planner will skip over it and not
emplace it. Since there were no errors and the layers_ count is
the same as the available planes, we won't force client
composition, and will try to do device composition for the
buffer we didn't really import.
This results in the drm layer going a bit wonky.
Thus, this patch tries to fix this by erroring out if we try to
plan only a single layer, but don't emplace anything. This
results in the CreateComposition() function failing, which will
force client rendering, making it work (with only minimal logcat
noise - only in the single layer case).
Change-Id: I563dbba3c2adce5617fae61cb0440368053e5bff
Signed-off-by: John Stultz <john.stultz@linaro.org>
Sean Paul [Fri, 24 Aug 2018 20:58:35 +0000 (16:58 -0400)]
drm_hwcomposer: Fix HiSi import fail log spam
hikey can only display layers which do not have gralloc usage HW_FB
(hint: that leaves just the client target layer). As such, there's no
benefit trying to import them since it'll just fail. So if we encounter
a layer such as this, fake the import (the release will be a noop since
gem_handles will be 0).
Also, as a belt-and-suspenders move, replace the greedy planner with one
that only displays (usage != HW_FB) to be doubly sure that we don't try
to display the no-op layers
Change-Id: I7bf88cfb7bda1dd5f47b741709619494431558a2
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Sean Paul [Mon, 27 Aug 2018 17:59:08 +0000 (13:59 -0400)]
drm_hwcomposer: Reformat using clang-format-5.0
Run the new clang-format style over the codebase to make things
compatible.
Change-Id: I267d5070929aaa7965d58655da841402debdcb6c
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Sean Paul [Fri, 13 Jul 2018 16:51:42 +0000 (12:51 -0400)]
drm_hwcomposer: Update clang-format to 5.0
Updating clang-format to 5.0 to get a bit more control over our
styling. Two things that will be beneficial:
- Alphabeticalize headers
- More control around line breaking, especially preferring
val = SomeFunction(arg1,
arg2);
vs:
val =
SomeFunction(arg1, arg2);
It's still not perfect, but it seems greatly improved.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Alexandru Gheorghe [Tue, 27 Mar 2018 15:10:55 +0000 (16:10 +0100)]
drm_hwcomposer: add scene flattening
Flattening of a scene is triggered if it doesn't change for a while.
As of now there is a separate thread which triggers flattening if the
scene did not change in last 60 vsyncs.
There are two options for flattening a scene:
* Serial, by using a writeback connector attached to the same crtc as
the one driving the display. This happens only if possible_clones
mask reports that the display encoder and writeback encoder could
work simultaneously.
The steps for achieving this are:
1. Build a commit that enables writeback connector, we don't need to
build a commit that contains the entire active_composition, just
set the writeback specific properties a let the kernel duplicate
the rest of the state.
2. Commit and wait for writeback_fence to fire.
3. Setup a composition with just one plane enabled.
4. Apply the composition if a new one has not been applied meanwhile.
* Concurrent, by comitting the scene to a new unused crtc (state !=
DRM_MODE_CONNECTED) and getting the result back through a writeback
connector.
The steps for achieving this are:
1. Copy layers from active composition.
2. Plan layers of copy on the unused crtc. This is realized by using a
newly created DrmDisplayCompositor object.
3. Commit copy to the unsed crtc and get the result as a drmhwclayer.
4. Setup a composition with just one plane enabled. Re-importing the
buffers might be needed since we might have been using a different
dri node.
5. Apply the composition if a new one has not been applied while doing
the flattening
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Thu, 29 Mar 2018 13:38:21 +0000 (14:38 +0100)]
drm_hwcomposer: Fix race in ApplyFrame
ApplyFrame holds the lock just when it swaps the value of
active_composition_, in a multithread context we could end up in a
situation where something is shown on the screen, but something else
is set in active_composition_. Fix it by holding the lock during
CommitFrame.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Wed, 21 Mar 2018 14:19:58 +0000 (14:19 +0000)]
drm_hwcomposer: Handle writeback connectors
When writeback connectors are available assign them to displays, in
order to be able to use them for flattening of the current displayed
scene. The pipeline for each display will look like this:
CRTC ---- encoder ------------ display connector.
|------- writeback enc ------ writeback connector.
However, the writeback connector will be later used/enabled only if
one of the following conditions are met:
- Could be a clone of the display connector, as pointed by the
possible_clones property.
- The display_connector is disconnected, so we are safe to use it for
flattening the scene that's already presented on another display.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Thu, 22 Mar 2018 11:31:29 +0000 (11:31 +0000)]
drm_hwcomposer: Parse and store possible_clones information
drmModeEncoder has a field called possible_clones. It's a bit mask
which tells if the encoder could be simultaneously connected, to the
same CRTC, with the encoders specified in the possible_clones mask.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Wed, 21 Mar 2018 12:06:20 +0000 (12:06 +0000)]
drm_hwcomposer: Add display field to Drmencoder
In the current implementation TryEncoderForDisplay just looks
at the crtc linked to the display, if that's not assigned to
a display it means the encoder could be used, otherwise iterate
to the list of possible_crtcs and find one which is not used.
This logic works fine when you have just one encoder connected to a
crtc but with two or more, like is the case when we attach a writeback
connector, we need to know if we already assigned the encoder to a
display.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Wed, 21 Mar 2018 11:40:01 +0000 (11:40 +0000)]
drm_hwcomposer: Add writeback connector support
Writeback connector is a special case of connector, which can be
linked to a CRTC in order to get the result of the composition back to
a memory buffer. This had not been merged to the mainline kernel yet,
latest version of the kernel patches could be found here [1].
[1] https://lists.freedesktop.org/archives/dri-devel/2018-February/167703.html
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Reviewed-by: Sean Paul <seanpaul at chromium.org>
Alexandru Gheorghe [Fri, 11 May 2018 10:40:53 +0000 (11:40 +0100)]
drm_hwcomposer: Purge drm_ from drmdisplaycompositor
Having DrmDevice as a member in DrmDisplayCompositor is redundant,
since that could be always retrieved by calling:
resource_manager_->GetDrmDevice(display_)
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Tue, 1 May 2018 16:25:48 +0000 (17:25 +0100)]
drm_hwcomposer: Pass resource manager to drmdisplaycompositor
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Tue, 27 Mar 2018 14:52:02 +0000 (15:52 +0100)]
drm_hwcomposer: Add resource manager support
Add a resource manager class that is responsible for detecting all
kms devices and allocates unique display numbers for every detected
display.
This is controlled by the value of hwc.drm.device property, if it ends
with a %, it will try to open minor devices until an error is detected.
E.g: /dev/dri/card%
Additionally, this will be used for finding an available writeback
connector that will be used for the flattening of the currently
displayed scene.
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
Alexandru Gheorghe [Tue, 1 May 2018 13:37:10 +0000 (14:37 +0100)]
drm_hwcomposer: Rename DrmResources to DrmDevice
DrmDevice is a better name to reflect the fact that DrmResources/
DrmDevice can handle just one dri node.
Suggested here [1] by Sean Paul.
[1] https://lists.freedesktop.org/archives/dri-devel/2018-April/173290.html
Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
John Stultz [Wed, 11 Jul 2018 18:28:40 +0000 (11:28 -0700)]
drm_hwcomposer: Drop -Wno-unused-* build options and remove unused variables
This patch drops the -Wno-unused-* build options and removes
the currently unused variables that would keep things from
building.
Signed-off-by: John Stultz <john.stultz@linaro.org>