History log of /frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d7f49c5e93a554c2f0e85e279a765f92fb1e66f1 27-Jul-2017 Steven Thomas <steventhomas@google.com> Use a separate hwcomposer hidl instance for vr flinger

Improve robustness of vr flinger <--> surface flinger switching by
having vr flinger use a separate hardware composer hidl instance instead
of sharing the instance with surface flinger. Sharing the hardware
composer instance has proven to be error prone, with situations where
both the vr flinger thread and surface flinger main thread would write
to the composer at the same time, causing hard to diagnose
crashes (b/62925812).

Instead of sharing the hardware composer instance, when switching to vr
flinger we now delete the existing instance, create a new instance
directed to the vr hardware composer shim, and vr flinger creates its
own composer instance connected to the real hardware composer. By
creating a separate composer instance for vr flinger, crashes like the
ones found in b/62925812 are no longer impossible.

Most of the changes in this commit are related to enabling surface
flinger to delete HWComposer instances cleanly. In particular:

- Previously the hardware composer callbacks (which come in on a
hwbinder thread) would land in HWC2::Device and bubble up to the
SurfaceFlinger object. But with the new behavior the HWC2::Device
might be dead or in the process of being destroyed, so instead we have
SurfaceFlinger receive the composer callbacks directly, and forward
them to HWComposer and HWC2::Device. We include a composer id field in
the callbacks so surface flinger can ignore stale callbacks from dead
composer instances.

- Object ownership for HWC2::Display and HWC2::Layer was shared by
passing around shared_ptrs to these objects. This was problematic
because they referenced and used the HWC2::Device, which can now be
destroyed when switching to vr flinger. Simplify the ownership model
by having HWC2::Device own (via unique_ptr<>) instances of
HWC2::Display, which owns (again via unique_ptr<>) instances of
HWC2::Layer. In cases where we previously passed std::shared_ptr<> to
HWC2::Display or HWC2::Layer, instead pass non-owning HWC2::Display*
and HWC2::Layer* pointers. This ensures clean composer instance
teardown with no stale references to the deleted HWC2::Device.

- When the hardware composer instance is destroyed and the HWC2::Layers
are removed, notify the android::Layer via a callback, so it can
remove the HWC2::Layer from its internal table of hardware composer
layers. This removes the burden to explicitly clear out all hardware
composer layers when switching to vr flinger, which has been a source
of bugs.

- We were missing an mStateLock lock in
SurfaceFlinger::setVsyncEnabled(), which was necessary to ensure we
were setting vsync on the correct hardware composer instance. Once
that lock was added, surface flinger would sometimes deadlock when
transitioning to vr flinger, because the surface flinger main thread
would acquire mStateLock and then EventControlThread::mMutex, whereas
the event control thread would acquire the locks in the opposite
order. The changes in EventControlThread.cpp are to ensure it doesn't
hold a lock on EventControlThread::mMutex while calling
setVsyncEnabled(), to avoid the deadlock.

I found that without a composer callback registered in vr flinger the
vsync_event file wasn't getting vsync timestamps written, so vr flinger
would get stuck in an infinite loop trying to parse a vsync
timestamp. Since we need to have a callback anyway I changed the code in
hardware_composer.cpp to get the vsync timestamp from the callback, as
surface flinger does. I confirmed the timestamps are the same with
either method, and this lets us remove some extra code for extracting
the vsync timestamp that (probably) wasn't compatible with all devices
we want to run on anyway. I also added a timeout to the vysnc wait so
we'll see an error message in the log if we fail to wait for vsync,
instead of looping forever.

Bug: 62925812

Test: - Confirmed surface flinger <--> vr flinger switching is robust by
switching devices on and off hundreds of times and observing no
hardware composer related issues, surface flinger crashes, or
hardware composer service crashes.

- Confirmed 2d in vr works as before by going through the OOBE flow on a
standalone. This also exercises virtual display creation and usage
through surface flinger.

- Added logs to confirm perfect layer/display cleanup when destroying
hardware composer instances.

- Tested normal 2d phone usage to confirm basic layer create/destroy
functionality works as before.

- Monitored surface flinger file descriptor usage across dozens of
surface flinger <--> vr flinger transitions and observed no file
descriptor leaks.

- Confirmed the HWC1 code path still compiles.

- Ran the surface flinger tests and confirmed there are no new test
failures.

- Ran the hardware composer hidl in passthrough mode on a Marlin and
confirmed it works.

- Ran CTS tests for virtual displays and confirmed they all pass.

- Tested Android Auto and confirmed basic graphics functionality still
works.

Change-Id: I17dc0e060bfb5cb447ffbaa573b279fc6d2d8bd1
Merged-In: I17dc0e060bfb5cb447ffbaa573b279fc6d2d8bd1
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
49cdc635a222a495b5b5e17962c31a308003e23d 22-Jun-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: discard stale commands" into oc-dev
am: f8ca9a0875

Change-Id: Ief69f6fcf0c738612b14b94d65b3ae1555973d6c
0c6ce4608fc022608537162dd919e7f729b9cb77 22-Jun-2017 Chia-I Wu <olv@google.com> surfaceflinger: discard stale commands

When we skip validate, we may have stale commands on the command
buffer. They should be discarded.

Bug: 62906801
Test: manual
Change-Id: Ie7921ba75ab2252b834cda6924e1fcfdf236f759
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
8976c6ae3710f3f524150f07be870075c9b1de9d 22-Jun-2017 Fabien Sanglard <sanglardf@google.com> Skip Validate
am: 249c0ae80a

Change-Id: I336fce473d21e5fdfb80ad8eb48f1df5a24497d8
249c0ae80a6e5690d091294c4447cb3facafbc37 20-Jun-2017 Fabien Sanglard <sanglardf@google.com> Skip Validate

b/37474580
b/62806392

Test: marlin, ryu

Change-Id: I09e0c52cb7c914dcd883dc771d97a365c89f7037
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
c988ee4c4c21331e2a33467dc899ebb561035b0b 01-Jun-2017 Courtney Goeltzenleuchter <courtneygo@google.com> Remove redundent layer setDataspace calls.

Cache the layer's dataspace in hwc2 and only send
to the HAL when it changes. Allows HAL to optimize
use of layer.

Bug: 38396128
Test: Manually checked systraces on Pixel
Change-Id: Ia94bebe7de9f79d01ae19b9917591837d865fea9
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
d8ac4fd17a71b8b523121186b8a03212cd5122fe 25-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Delete SurfaceFlinger BYPASS codepath" into oc-dev
5b3cf0576d91358cb850945d89382938ff8dc5ed 04-May-2017 Fabien Sanglard <sanglardf@google.com> Delete SurfaceFlinger BYPASS codepath

Test: AUPT, Manual
Change-Id: I8d6139fbb8a3ec113d7cb973420a5874d3e31030
Merged-Id: I8d6139fbb8a3ec113d7cb973420a5874d3e31030
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
d497cdcb7f04f648b11b1bde13beb8e07a38bb5f 18-May-2017 Chia-I Wu <olv@google.com> Merge "surfaceflinger: fix a release fence leak" into oc-dev am: 5c580eaeb6
am: 4a09c8fb5e

Change-Id: Ie0df74a1390d880735ed05887dbc7a653e0dc7ee
5e74c65a55e2297228e1c8cf7885420d6a946e80 17-May-2017 Chia-I Wu <olv@google.com> surfaceflinger: fix a release fence leak

We leak release fence fds when we believe hwcomposer2 gives us any
invalid layer and return early.

Bug: 38151478
Test: boots
Change-Id: I299721eca8bc7927052170fe87ee51e9b91006aa
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
831d48ed282e7e5095895c8d1896881ff36947f7 04-May-2017 Fabien Sanglard <sanglardf@google.com> Delete SurfaceFlinger BYPASS codepath

Test: AUPT, Manual
Change-Id: I8d6139fbb8a3ec113d7cb973420a5874d3e31030
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
6d957ec3732dd1c30b00e738ebb38d01118f9fd6 12-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge changes Ia1fa4a32,I2a4c3d9f into oc-dev

* changes:
hwc2: Remove Display::{mIsVirtual,setVirtual}
hwc2: Cache display type at construction
ceb67d1f8f61e15e2c752d15c4077e5194118d1c 11-Apr-2017 Chris Forbes <chrisforbes@google.com> hwc2: Remove Display::{mIsVirtual,setVirtual}

Trivial cleanup.

Now that mType is available, we don't need a separate flag for whether
the display is virtual. The remaining effect of setVirtual was to set
the display connected, so just use setConnected.

Bug: b/36597125
Test: build
Change-Id: Ia1fa4a324cc07b0d6c124f4f50966c8b0cbe4827
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
016d73c2d8f8fae544f09a6eebe827791f499470 11-Apr-2017 Chris Forbes <chrisforbes@google.com> hwc2: Cache display type at construction

The display type is constant for the life of the display. Query it
upfront to avoid the binder transaction later.

V2: fixup HWC1 path

Test: boot to launcher on bullhead; build on fugu for HWC1 path
Bug: b/36597125
Change-Id: I2a4c3d9ff449960957376afef78f424261fcc282
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
1f42e3a02c4f9a1ba1916a2f0e47082bedb73e41 10-Apr-2017 Daniel Nicoara <dnicoara@google.com> VR: Update VR HWC to use buffer metadata passed by SurfaceFlinger

Without gralloc1 support, need to pass buffer metadata in order to
import native buffers and used them as graphic buffers.

Bug: 36481301
Test: Compiled and ran on device; Verified VR Window Manager properly
displays SurfaceFlinger buffers.

Change-Id: I8426be1d79dcc2fbd631c399427ae03cb2afc21d
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
5a423eaa86f4c990afcef8c55e3949d0872068b4 16-Feb-2017 Dan Stoza <stoza@google.com> Move FloatRect from libgfx to libui

Moves FloatRect from libgfx (which is being disintegrated) to libui

Test: Builds and sailfish boots
Change-Id: I68c1b7d86a363066fe4d6f0c038ca9d92d7ab9c7
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
87670ffe26079eb50b62f698eb0f7bfa8ee51deb 01-Feb-2017 Hendrik Wagenaar <hendrikw@google.com> Allow surfaceflinger to run vrflinger

* Allows surface flinger to switch in and out of vr mode

Bug: None
Test: Manually ran various vr test programs.
Change-Id: I15fbba0eb67cbcffeef41be31429550448a1db9c
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
06d63de03cb2a551ca99608f5aa0c4f3e200b0fc 04-Jan-2017 Chia-I Wu <olv@google.com> surfaceflinger: cache HWC client targets and buffers

Remember HWC client targets and buffers, and make sure we send each
unique slot/handle pair only once. This allows the composer to
clone/register/retain each buffer only once.

Test: builds and boots
Change-Id: Ib485189043a9c132031e82d4d7380ace3bf9453d
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
2f5f8a51f5994cf14837030d4b3b252a9d1b950b 20-Dec-2016 Daniel Nicoara <dnicoara@google.com> VR: Add ability to pass layer info through SurfaceFlinger

Updates SurfaceFlinger to connect to the VR HWC service and pass
additional layer information.

For now VR mode is enabled at build time.

Bug: 33297385
Test: Ran on device and verified the IVrComposerClient::setLayerInfo()
call is done successfully.

Change-Id: I9dea2451a3a2aa1919395d3785ae00446ba51f26
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
847650b5d89a1667f78fa0fa67429377cd3bf37a 17-Jun-2016 Naseer Ahmed <naseer@codeaurora.org> HWC2: Initialize retire fence to -1

Initializing to zero will cause us to inadvertently close fd 0.
While fd 0 (stdout) isn't used in the surfaceflinger process,
if we close it, the fd becomes available for other usages, such
as fences and ion buffers. Using it becomes problematic for some
drivers which may treat it as an invalid value.

Bug: 28640429
Test: Fixes GPU driver seeing fd of 0 and erroring
Change-Id: Ifa06472d24476edb27a4306d946eb616a15aee7a
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
71bded513d37a6c1260b4a62c69ecc0d24be95f7 19-Oct-2016 Dan Stoza <stoza@google.com> Create libgfx, starting with FloatRect

Creates libgfx, the future home of everything currently in libui and
libgui, which will be rigorously checked with -Weverything (with a few
common-sense exceptions) and clang-tidy and formatted using the included
.clang-format file.

Starts by moving FloatRect out of services/surfaceflinger since it will
be used by other libgfx primitives later.

Test: m
Change-Id: I5045ac089020e6ee380e81e8735117c500264b37
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
67e376d6564f8b9f996a347c9402bdc9da789321 19-Dec-2016 Chia-I Wu <olv@google.com> Replace non-const references by pointers

Use pointers for outputs to be consistent with the rest of
libui/libsurfaceflinger.

Remove assignFromHidlVec now that hidl_vec can be casted to std::vector.

Test: builds and boots
Change-Id: I656367028302e7b877a766eaf6aa2431fe07643b
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
cd8d7f08fe26645f74e540365b1a8a38e602088d 16-Nov-2016 Chia-I Wu <olv@google.com> surfaceflinger: update for IComposer changes

The new IComposer introduces IComposerClient to manage resources and
replaces most state changing functions by a "command buffer" to batch
calls.

Test: builds and boots
Change-Id: Idd1060f83fab28330e7119ff0f5a5bda5429811a
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
11d0fc38ad8d2e5bb5bc0a282336cabe28dbf9d6 02-Dec-2016 Fabien Sanglard <sanglardf@google.com> Rename "retire" to "present" for consistency

The HWC2 model has no concept of retire fence beyond HWC2to1Adapter
All references to "retire" fence should be called "present"

Change-Id: I26540aad9e65f138a4df60a34eaee030f1c17567
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
b7432cc57cd957fb18f68d7976c5829b3a3a7751 11-Nov-2016 Fabien Sanglard <sanglardf@google.com> Fix HWC2to1Adapter crashing dragon at startup

Some devices such a dragon(ryu) do not start with a valid active
configuration id (e.g: -1). This is unexpected from HWC2to1Adapter
and resulted in crash at startup when switching the device from HWC1
to HWC2 with adapter.

This patch detects this at startup and put the device in an expected
configutation using the first configuration index (0).

Test: Tested on ryu
Change-Id: If2bb258d12636f1b2ebe8c7b167708dbf572fbe8
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
aab99f576b205114eaa5399c8f97b9e175a1c698 04-Oct-2016 Chia-I Wu <olv@google.com> surfaceflinger: add support for android.hardware.graphics

This adds a new path to HWC2 to use
android.hardware.graphics.composer@2.1::IComposer instead of hwcomposer2.
Which path to use is determined by whether BYPASS_IHWC is set at compile
time. When it is set, the old path, kept for HWC2On1Adapter, is used.
When it is not set, the new path is taken.

BYPASS_IHWC2 is set when TARGET_USES_HWC2 is not.

Test: Maps, Camera, YouTube, etc.
Change-Id: I37aceafd1733fa9f76e7f7db4f59ad4776415306
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
28f24d0ab481bd9c6fd5618414fee694e837c5c6 12-Jul-2016 Michael Wright <michaelwr@google.com> Color transforms are now color modes.

Rename color transforms to color modes for all interfaces exposed to
surfaceflinger clients. Also split it out to be a separate
configuration value from display modes.

Bug: 29044347

Change-Id: I87e937f7c954a50c946e8e2c606797caa416c5d8
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
9f26a9c8be6f00f55cbc30b93adf4895c6a093aa 22-Jun-2016 Dan Stoza <stoza@google.com> SF/HWC2: Add support for color transforms

Adds support for color transforms using the setColorTransform method
of HWC2.

This means that instead of always falling back to client composition
when applying a transform, SurfaceFlinger will allow the device to
make that decision. If all layers fall back to client composition, the
SKIP_CLIENT_COLOR_TRANSFORM capability allows the device greater
control over whether SF should apply the transform or whether it
should allow the device to apply it to the client target buffer.

Bug: 19539930
Change-Id: I47a3d5453a3c47a8dd105ab77cce7f9c9687e925
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
38628986f2bb3b392dd4b519aacb9354320e409f 14-Jul-2016 Dan Stoza <stoza@google.com> HWC2: Fix virtual displays

Close the output buffer release fence per the contract in
hwcomposer2.h.

Also changes the HWC2 device to hold a weak pointer to the display,
which allows it to properly remove it when it gets torn down.

Bug: 29945684
Change-Id: Ib1b5d81e42a63d0e65b189f7c6c62e661e0ab6ae
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
5cf424bc129f01ee12c7a4fbea1664276d29f970 20-May-2016 Dan Stoza <stoza@google.com> HWC2: Fix breakage from header change

Updates the shim and adapter to handle the header changes introduced
by "HWC2: Add format to VD create, surface damage" in libhardware.

Bug: 22767098
Change-Id: I8142301c121d9b5602a4455f3fbadefefd685cf0
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
076ac670262e448c531e6db7727cfade325866ca 14-Mar-2016 Dan Stoza <stoza@google.com> HWC2: Add support for color modes

Adds support for setting color modes through HWC2On1Adapter and the
HWC2 C++ shim

Bug: 22767098
Change-Id: I0b7300093ab427be7105a2535fc9db4953b8af1c
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
5df2a86063c6a83813fc1aa3d8938a82f7ff8f14 25-Mar-2016 Dan Stoza <stoza@google.com> HWC2: Hook up setColorTransform/setLayerDataspace

Plumbs the setColorTransform and setLayerDataspace calls through the
HWC2 C++ shim and implements a trivial versions in the adapter,
which drops non-HAL_DATASPACE_UNKNOWN layers to client composition,
and which drops all layers to client composition if a color transform
is applied.

Bug: 22767098
Change-Id: Ifffd19b77cf3b33ec86fde3f72257f6b97b4dd79
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
09e7a27fabde3da99ba6dfd2fd20be7d1425a9ad 14-Apr-2016 Dan Stoza <stoza@google.com> HWC2: Check SidebandStream capability on load

Checks whether the HWC2 device has the SidebandStream capability
before attempting to load the corresponding function pointer

Bug: 28161394
Change-Id: I6407d61a1b23138781e57213bcb868be46609018
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
7d7ae7345abfb91be55c4aed6c9be9d09a144e4c 16-Mar-2016 Dan Stoza <stoza@google.com> HWC2: Add getHdrCapabilities to C++ shim

Adds support for the getHdrCapabilities call to the HWC2 C++ shim.

Bug: 25684127
Change-Id: Ib4635ee437a06b48945e7f0328492c1e74e27aaa
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp
651bf314a6a1a77e4cbb66ffb81221200f918290 24-Oct-2015 Dan Stoza <stoza@google.com> SF: HWC2 C++ shim

Provides an object-based C++ interface to the HWC 2.0 HAL

Change-Id: Ie1a7bfd2f6faa548bc45da845a4f50f1915b5806
/frameworks/native/services/surfaceflinger/DisplayHardware/HWC2.cpp