OSDN Git Service

android-x86/external-drm_hwcomposer.git
7 years agoForce framebuffer target marshmallow-x86 android-x86-6.0-r1 android-x86-6.0-r2 android-x86-6.0-r3
Rob Herring [Wed, 13 Jan 2016 03:00:51 +0000 (21:00 -0600)]
Force framebuffer target

GL compositing doesn't want to work, so force disable it.

Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoHACK: Add HDMI connector as built-in
Rob Herring [Tue, 12 Jan 2016 21:41:53 +0000 (15:41 -0600)]
HACK: Add HDMI connector as built-in

Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoHACK: disable gralloc buffer usage call
Rob Herring [Fri, 8 Jan 2016 22:07:22 +0000 (16:07 -0600)]
HACK: disable gralloc buffer usage call

No signs of any gralloc implementation supporting this.

Signed-off-by: Rob Herring <robh@kernel.org>
7 years agoHACK: add rotation defines
Rob Herring [Thu, 4 Feb 2016 20:01:49 +0000 (14:01 -0600)]
HACK: add rotation defines

These should come from kernel headers

8 years agodrm_hwcomposer: Don't composite over protected layers
Sean Paul [Mon, 18 Apr 2016 19:53:36 +0000 (15:53 -0400)]
drm_hwcomposer: Don't composite over protected layers

This patch changes two things with respect to protected layers:

1- It provisions the HW plane in the correct position. ie: if
   the background layer is slated for a HW plane, it will be
   placed on the primary layer and the protected layer will be
   placed on top of it.
2- It punches a hole through the precomposite and squash layers
   such that when they are placed on top of the protected layer,
   they do not obstruct it.

BUG=b/27502957
TEST=Tested on smaug with multi-window with a variety of different
     layouts and visible layers

Change-Id: Ie30939f2bb750dbe3faa558ddb094b677f41f45e
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agoMerge "drm_hwcomposer: remove unnecessary gralloc_drm_bo_t dependency"
Sean Paul [Fri, 1 Apr 2016 20:32:09 +0000 (20:32 +0000)]
Merge "drm_hwcomposer: remove unnecessary gralloc_drm_bo_t dependency"

8 years agodrm_hwcomposer: remove unnecessary gralloc_drm_bo_t dependency
Rob Herring [Fri, 1 Apr 2016 15:06:54 +0000 (10:06 -0500)]
drm_hwcomposer: remove unnecessary gralloc_drm_bo_t dependency

gralloc_bo is not used anywhere and depending on it pulls in unnecessary
dependencies from drm_gralloc, so remove it.

Change-Id: I81b9dc88124ea6a0e66e188656d44215e735d177
Signed-off-by: Rob Herring <robh@kernel.org>
8 years agodrm_hwcomposer: Fix build warnings
Sean Paul [Tue, 29 Mar 2016 17:55:35 +0000 (13:55 -0400)]
drm_hwcomposer: Fix build warnings

A cleanup patch to fix the build warnings that have surfaced
from the new build system.

BUG=None
TEST=Builds without warnings

Change-Id: I2ad898e627d451f87705d2bdf06a315b8e1c7a1c
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Add hotplug event handler
Sean Paul [Mon, 26 Oct 2015 19:37:06 +0000 (15:37 -0400)]
drm_hwcomposer: Add hotplug event handler

Add a hotplug event handler to handle hotplug events. Upon
hotplug, the handler is responsible for finding and setting
the preferred mode of the new display.

BUG=chrome-os-partner:41682
TEST=Tested on ryu with DP

Change-Id: Ide57382624c7839ed81a712bc29ea2e1cc19dcae
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Set DPMS ON when setting active config
Sean Paul [Tue, 29 Mar 2016 14:51:38 +0000 (10:51 -0400)]
drm_hwcomposer: Set DPMS ON when setting active config

Ensure we turn the connector on after we set the active mode.

BUG=chrome-os-partner:41682
TEST=Tested on smaug with DP

Change-Id: I3410a1ac261fb0848d668c5baef2d77eb860017b
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Add DrmEventListener worker
Sean Paul [Tue, 28 Jul 2015 18:15:42 +0000 (14:15 -0400)]
drm_hwcomposer: Add DrmEventListener worker

This patch adds a worker which listens to drm events. If the
drm event has a handler associated with it, the listener will
call the handler.

BUG=chrome-os-partner:41682
TEST=Tested on ryu with DP

Change-Id: I5d691d191425604766a00be3e72111095d025d06
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Protect autofd.h with #ifdef/#define
Sean Paul [Thu, 24 Mar 2016 18:50:53 +0000 (14:50 -0400)]
drm_hwcomposer: Protect autofd.h with #ifdef/#define

So we don't end up redeclaring its classes.

BUG=None
TEST=Compiles

Change-Id: Ic15ba4412f11bad8ef7ec4f68af6ad87e0d674cc
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Add connection state to DrmConnector
Sean Paul [Mon, 26 Oct 2015 19:36:37 +0000 (15:36 -0400)]
drm_hwcomposer: Add connection state to DrmConnector

So we can determine if it's connected or not.

BUG=chrome-os-partner:41682
TEST=Tested on ryu with DP

Change-Id: Ie0dadb2737d3a98257fb6e4fa02f17d7dae44f6c
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Convert to upstream DRM atomic interfaces
Rob Herring [Thu, 4 Feb 2016 20:01:24 +0000 (14:01 -0600)]
drm_hwcomposer: Convert to upstream DRM atomic interfaces

drm_hwcomposer is currently using preliminary version of the atomic API.
The final version merged upstream is slightly different. Convert it to the
upstream API.

The most significant change is positive return values for
drmModeAtomicAddProperty are not a failure, so we need to test for
negative return values instead of non-zero.

BUG=none
TEST=Tested with 4.4 kernel on virtio-gpu and freedreno

Change-Id: I0b1f4bcd7766a3053a484f55e01c8b2ba56d716d
Signed-off-by: Rob Herring <robh@kernel.org>
8 years agoMerge "drm_hwcomposer: Add support for virtual connectors"
Sean Paul [Wed, 10 Feb 2016 22:35:25 +0000 (22:35 +0000)]
Merge "drm_hwcomposer: Add support for virtual connectors"

8 years agodrm_hwcomposer: Add support for virtual connectors
Rob Herring [Fri, 4 Dec 2015 23:14:31 +0000 (17:14 -0600)]
drm_hwcomposer: Add support for virtual connectors

Allow virtual connector type in order to support virtio-gpu.

BUG=none
TEST=Tested with virtio-gpu on QEMU

Change-Id: I7ae5091d3587bcae75da6bff23d7bc85aa6164f1
Signed-off-by: Rob Herring <robh@kernel.org>
8 years agodrm_hwcomposer: Increase fence timeout upto 5x
David Ung [Wed, 20 Jan 2016 01:24:49 +0000 (17:24 -0800)]
drm_hwcomposer: Increase fence timeout upto 5x

Increase the fence wait value each time by a factor of 2.

Bug: chrome-os-partner:48289
Test: Run apps and see no frame drops

Change-Id: I9b7b910e5a8c9d287ea69b13dca0d4c1194ac86c
Signed-off-by: David Ung <davidu@nvidia.com>
8 years agodrm_hwcomposer: Add OWNERS file
Sean Paul [Thu, 14 Jan 2016 18:38:22 +0000 (10:38 -0800)]
drm_hwcomposer: Add OWNERS file

So people know who to bug for reviews.

BUG=None
TEST=None

Change-Id: I20bb80929a7fac59ca2137b415c9d0e000d79c54
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Always call PrepareFrame() for compositions
Sean Paul [Mon, 30 Nov 2015 19:35:45 +0000 (14:35 -0500)]
drm_hwcomposer: Always call PrepareFrame() for compositions

Previously this was not called for compositions which were known to
fail the atomic test. Unfortunately this left the composition in a
state which could not be processed by SquashFrame (only one layer and
source_layer was still set to kSourceSquash).

So call PrepareFrame() on every composition so SquashFrame stays happy.

Change-Id: I976e344ce4970370d9ca4307c2f2c45025199b64
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Save the atomic_test result between tests
Sean Paul [Wed, 25 Nov 2015 16:04:25 +0000 (11:04 -0500)]
drm_hwcomposer: Save the atomic_test result between tests

Previously, we would only test the first frame when the geometry
changed. However, if SF sent us the same composition with different
FBs, we could end up sending invalid frames to the kernel.

This change saves the result of the atomic_test between geometry
changes so we avoid using hw composition for all invalid frames.

Bug: 25866352
Test: Tested on smaug, observed squashes between geometry changes

Change-Id: I3b5d9e83a870481bf2e6869900eafaf0ca66a0d5
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: only check the composition after a geometry change
Haixia Shi [Tue, 24 Nov 2015 20:42:45 +0000 (12:42 -0800)]
drm_hwcomposer: only check the composition after a geometry change

Do not check the composition with kernel for every frame. We are currently
using synchronous atomic ioctl calls, so all test-only calls are serialized
with the actual commits.

BUG=25866352
TEST=same test procedure as crosbug.com/p/47206

Change-Id: Ia423243c279fc677ff6213115a8f20efa40c235e

8 years agoMerge "drm_hwcomposer: Skip layers which aren't on-screen" into mnc-dr-dev
Sean Paul [Tue, 24 Nov 2015 18:13:42 +0000 (18:13 +0000)]
Merge "drm_hwcomposer: Skip layers which aren't on-screen" into mnc-dr-dev

8 years agodrm_hwcomposer: Skip layers which aren't on-screen
Sean Paul [Tue, 24 Nov 2015 16:52:37 +0000 (11:52 -0500)]
drm_hwcomposer: Skip layers which aren't on-screen

Don't composite layers whose bounds are entirely off screen, or
which have width or height of 0.

Bug: chrome-os-partner:47938
Test: Swipe between videos in Google Photos

Change-Id: I29671db6763caf3cb764b06d1ff955276ebecd80
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: set blending mode to kPreMult for GL output
Haixia Shi [Mon, 23 Nov 2015 19:34:36 +0000 (11:34 -0800)]
drm_hwcomposer: set blending mode to kPreMult for GL output

The correct blending mode for the GL output is actually premult, because
regardless of the original layer blending mode, the result RGB components
are always pre-multiplied with alpha already.

This prevents the result of a SquashAll() from getting multiplied by
alpha twice.

BUG=25838542
TEST=verify the blinking is fixed on the status bar icons

Change-Id: Ie5bbc53110c342576b81818da6069cba201db609

8 years agoMerge "drm_hwcomposer: Check the composition before sending to frame worker" into...
David Riley [Fri, 20 Nov 2015 22:24:09 +0000 (22:24 +0000)]
Merge "drm_hwcomposer: Check the composition before sending to frame worker" into mnc-dr-dev

8 years agoMerge "drm_hwcomposer: Allow for multiple transforms at once" into mnc-dr-dev
Sean Paul [Fri, 20 Nov 2015 21:42:15 +0000 (21:42 +0000)]
Merge "drm_hwcomposer: Allow for multiple transforms at once" into mnc-dr-dev

8 years agodrm_hwcomposer: Allow for multiple transforms at once
Sean Paul [Fri, 20 Nov 2015 02:46:11 +0000 (21:46 -0500)]
drm_hwcomposer: Allow for multiple transforms at once

Because sometimes one just ain't enough, allow more than
one transform at a time.

Bug: chrome-os-partner:46710
Test: Tested with the CTS Verifier "Camera Orientation" test

Change-Id: Ie5f9bbbc7c89964feafc78150e18512861c85b69
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Check the composition before sending to frame worker
Sean Paul [Thu, 19 Nov 2015 18:55:48 +0000 (13:55 -0500)]
drm_hwcomposer: Check the composition before sending to frame worker

Before we send a composition to the frame worker and display, run it
through the kernel to test whether it can be put on hardware. If the
kernel rejects the composition, use the squashing code to flatten it
on one layer and send the result to the frame worker.

Bug: 25379136
Test: Tested on smaug, frames were squashed, fun was had

Change-Id: Icac3c034d0eb4c0becbdc0f8ace1de75ab8ae2b8
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Split DrmDisplayCompositor::SquashAll()
Sean Paul [Wed, 18 Nov 2015 19:12:51 +0000 (14:12 -0500)]
drm_hwcomposer: Split DrmDisplayCompositor::SquashAll()

Split the SquashAll function into SquashAll and SquashFrame. This
will allow us to squash arbitrary compositions without using the
active composition or applying it to the screen.

Bug: 25379136
Test: Tested on smaug

Change-Id: I1767f731e14f36540151556ce07373848b604030
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Add test_only mode to CommitFrame
Sean Paul [Tue, 17 Nov 2015 21:38:10 +0000 (16:38 -0500)]
drm_hwcomposer: Add test_only mode to CommitFrame

Allow the caller of CommitFrame to run the commit in "test only" mode
which will send the frame to the kernel, but won't actually change any
registers.

Bug: 25379136
Test: Tested on smaug

Change-Id: I831b5f17d433bc60d9f107689feb1d7672c100a9
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Create mode blob on modeset queue
Sean Paul [Tue, 17 Nov 2015 19:46:56 +0000 (14:46 -0500)]
drm_hwcomposer: Create mode blob on modeset queue

Instead of creating the mode blob right before doing the modeset,
create it as soon as the modeset is queued. This will allow us to
use the blob for both atomic test as well as commit.

In addition to keeping the blob around, store the blob's id while
the mode is active so we don't need to look it up when/if the next
modeset comes in.

Bug: 25379136
Test: Tested on smaug

Change-Id: I60e6f83310ea0601388bb31b63d25c6fd7b8fc4d
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: during SquashAll, skip layers with kSourceNone
Zach Reizner [Wed, 18 Nov 2015 21:54:31 +0000 (13:54 -0800)]
drm_hwcomposer: during SquashAll, skip layers with kSourceNone

This complicates returning layers to the active composition on failure. They
will not go back in the correct order and this will confuse all subsequent
attempts to use the active composition.

Change-Id: Iab6fae7b4a88f97206bac08237d574ff1bfd802f

8 years agoMerge "drm_hwcomposer: composite down to a primary plane after a timeout" into mnc...
Zachary Reizner [Tue, 17 Nov 2015 18:21:00 +0000 (18:21 +0000)]
Merge "drm_hwcomposer: composite down to a primary plane after a timeout" into mnc-dr-dev

8 years agoMerge "drm_hwcomposer: avoid creating release fences for invalid OutputFd" into mnc...
Zachary Reizner [Tue, 17 Nov 2015 18:20:00 +0000 (18:20 +0000)]
Merge "drm_hwcomposer: avoid creating release fences for invalid OutputFd" into mnc-dr-dev

8 years agoMerge "drm_hwcomposer: add AutoLock to automatically handle pthread_mutex_lock" into...
Zachary Reizner [Tue, 17 Nov 2015 18:19:45 +0000 (18:19 +0000)]
Merge "drm_hwcomposer: add AutoLock to automatically handle pthread_mutex_lock" into mnc-dr-dev

8 years agodrm_hwcomposer: composite down to a primary plane after a timeout
Zach Reizner [Mon, 16 Nov 2015 19:08:46 +0000 (11:08 -0800)]
drm_hwcomposer: composite down to a primary plane after a timeout

DrmDisplayCompositor::SquashAll is triggered after a constant timeout in
DrmCompositorWorker::Routine. It will not be triggered more than one time
between genuine hwc_set calls. SquashAll has no effect if there are protected
layers, only one layer, or any errors. On success, SquashAll produces a new
DrmDisplayComposition that owns the layers in the planes of the active
composition and makes that the new active composition. SquashAll has no effect
on SquashState.

Change-Id: I975edb21847dcf2d93245f92a6e53a4e366c6a3b

8 years agodrm_hwcomposer: Increase the virtual display compositor's fence timeout
Sean Paul [Mon, 16 Nov 2015 18:47:19 +0000 (13:47 -0500)]
drm_hwcomposer: Increase the virtual display compositor's fence timeout

50ms isn't enough time for some CTS tests (namely testSetLocalFocus). Increase
the timeout to 3 seconds, since we're not too worried about recovery time
from fence timeouts any longer.

Bug: 24362649
Test: Run cts test in a loop, ensuring the virtual compositor doesn't time out:
        run cts --loop  --class android.view.cts.WindowTest --method testSetLocalFocus --disable-reboot --min-loop-time 100 --max-random-loop-time 200

Change-Id: I5552ece3f6fe95d78a4e0770c1e30c96f2e75313
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: avoid creating release fences for invalid OutputFd
Zach Reizner [Sat, 14 Nov 2015 00:11:37 +0000 (16:11 -0800)]
drm_hwcomposer: avoid creating release fences for invalid OutputFd

This change also adds a check for OutputFd to see if it is valid.

Change-Id: If992d523c707cc5e6e660de721938a26f27477d8

8 years agodrm_hwcomposer: add AutoLock to automatically handle pthread_mutex_lock
Zach Reizner [Sat, 14 Nov 2015 00:09:39 +0000 (16:09 -0800)]
drm_hwcomposer: add AutoLock to automatically handle pthread_mutex_lock

For functions that need to hold locks and also handle errors, using AutoLock
will make them much simpler and less prone to mutex handling errors.

Change-Id: Ida6545850e89186c552e3d58b2973c14852494ad

8 years agodrm_hwcomposer: add optional timeout for WaitForSignalOrExitLocked
Zach Reizner [Tue, 10 Nov 2015 23:18:08 +0000 (15:18 -0800)]
drm_hwcomposer: add optional timeout for WaitForSignalOrExitLocked

Change-Id: I5beef0833cc0a384aa76e821694183e024a8850c

8 years agodrm_hwcomposer: always put protected layers on hardware planes
Zach Reizner [Tue, 27 Oct 2015 23:18:06 +0000 (16:18 -0700)]
drm_hwcomposer: always put protected layers on hardware planes

Protected layers will not work inside of the GLWorker, so we are forced to put
them into planes directly.

Because we can now receive display contents which can never be properly
composited (e.g. 4 protected layers on hardware with only 3 planes), some
compromises had to be made for the composition planning algorithm. First all
protected layers are given a plane. Then the remaining planes are used by the
remaining layers, pre-composite buffer, and squash buffer. In the case where
there are too few planes for both a pre-composite buffer and squash buffer,
everything gets pushed into the pre-composite buffer and the squash buffer
will not be composited onto the screen. Another major limitation is that any
unprotected layers appearing behind a protected layer will actually appear on
top of that protected layer.

BUG=chrome-os-partner:43674
TEST=run protected content with lots of other layers

Change-Id: I94620d93f68ca14dc1966422dc89035ab84e3ff4

8 years agodrm_hwcomposer: fix spelling of "separate".
Haixia Shi [Mon, 2 Nov 2015 18:54:29 +0000 (10:54 -0800)]
drm_hwcomposer: fix spelling of "separate".

It is spelled "separate", not "seperate".

Change-Id: Id92d12aba42989a8a72e4596d425b2a9eea4e5ec

8 years agodrm_hwcomposer: filter out empty or invalid rects.
Haixia Shi [Mon, 2 Nov 2015 18:04:49 +0000 (10:04 -0800)]
drm_hwcomposer: filter out empty or invalid rects.

We can safely ignore zero-area rects because they do not affect the outcome
of the separate_rects() function. Furthermore the line sweep algorithm would
break when two identical START or END events are added to the same set.

Additionally any rect with |left| greater than |right| or |top| greater than
|bottom| is invalid and shall be ignored.

Added test cases with empty and invalid rects. This case would have crashed (or
failed the assert in a debug build) without this fix.

BUG=chrome-os-partner:47103
TEST=verify no crash with Photos app

Change-Id: I80950ef376390a14a892c58b563eb3c0f79db71c

8 years agodrm_hwcomposer: Handle HWC_SKIP_LAYER properly
Sean Paul [Thu, 29 Oct 2015 19:00:17 +0000 (15:00 -0400)]
drm_hwcomposer: Handle HWC_SKIP_LAYER properly

Instead of ignoring skip layers, set all layers between the first
and last skip layer as HWC_FRAMEBUFFER in prepare(). In set(), substitute
the HWC_FRAMEBUFFER_TARGET in place of those layers.

Bug: 25366235
Test: Tested with gmail modal and rotation

Change-Id: Ife0fd569caf505263b00e5d0e8217a339aa09031
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: add ATRACE_CALL.
Haixia Shi [Thu, 29 Oct 2015 21:33:37 +0000 (14:33 -0700)]
drm_hwcomposer: add ATRACE_CALL.

The DrmDisplayCompositor::CommitFrame() has been moved to a separate
worker thread so it's helpful to add it to systrace.

Change-Id: I82031f56ddc0587266f9a213208134f045f66b9a

8 years agodrm_hwcomposer: update #include's for drm_hwcomposer.h
Zach Reizner [Thu, 29 Oct 2015 17:11:16 +0000 (10:11 -0700)]
drm_hwcomposer: update #include's for drm_hwcomposer.h

That's the second most important part of renaming a file.

Change-Id: If9280f3b360389ef17b798e162a9c3b0c0a3133b

8 years agodrm_hwcomposer: rename file with underscore to not use underscore
Zach Reizner [Thu, 29 Oct 2015 02:12:13 +0000 (19:12 -0700)]
drm_hwcomposer: rename file with underscore to not use underscore

Change-Id: Icbaef79cb224b45e500ac3a0e3f987de24151d6a

8 years agodrm_hwcomposer: polish for old DRM wrapper code
Zach Reizner [Thu, 29 Oct 2015 02:08:45 +0000 (19:08 -0700)]
drm_hwcomposer: polish for old DRM wrapper code

- deleted private copy constructors
- replace delete with unique_ptr
- use in-class assignment
- remove default constructors/destructors when no longer needed
- remove most iterators used in for loops
- move UniqueFd to its own header so drmresources can use it

Change-Id: Ib20cc0949cf4d381a58548b8156c5cb368ca3efe

8 years agoMerge "drm_hwcomposer: Use mode vrefresh if provided" into mnc-dr-dev
Sean Paul [Wed, 28 Oct 2015 20:45:42 +0000 (20:45 +0000)]
Merge "drm_hwcomposer: Use mode vrefresh if provided" into mnc-dr-dev

8 years agodrm_hwcomposer: Use mode vrefresh if provided
Sean Paul [Wed, 28 Oct 2015 19:56:23 +0000 (15:56 -0400)]
drm_hwcomposer: Use mode vrefresh if provided

Instead of always calculating the vrefresh from clock + resolution,
use vrefresh from the mode if its provided.

Bug: 25319209
Test: Tested on smaug, refresh reports 60Hz

Change-Id: I963ccb153d1856f5e45e4a1aa6fbd20b105d4a84
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: C++ coding style cleanup, no functional changes.
Haixia Shi [Tue, 27 Oct 2015 17:40:48 +0000 (10:40 -0700)]
drm_hwcomposer: C++ coding style cleanup, no functional changes.

Apply "override" keyword and remove redundant "virtual" keyword.
Ran clang-format on all files.

Change-Id: I76730296aa8f52e555137d4b5973fa27d38f0aa6

8 years agodrm_hwcomposer: move atomic modeset calls into a separate worker
Haixia Shi [Fri, 23 Oct 2015 01:12:49 +0000 (18:12 -0700)]
drm_hwcomposer: move atomic modeset calls into a separate worker

We are currently using synchronous (blocking) atomic modeset calls
which unnecessarily delays GL.

BUG=25126188
TEST=check timestamp of SignalPreCompDone relative to hwc_set

Change-Id: Iba70c1c9591e467c1627516af123a43206da99fd

8 years agodrm_hwcomposer: get gralloc buffer usage during hwc_set
Zach Reizner [Tue, 20 Oct 2015 17:58:19 +0000 (10:58 -0700)]
drm_hwcomposer: get gralloc buffer usage during hwc_set

This is needed during the layer composition planning phase to determine if a
layer is protected and therefore needs to be in its own overlay.

BUG=chrome-os-partner:43674

Change-Id: I33510a5a56b57aaaf55732149ae3e3d2f92ada79

8 years agodrm_hwcomposer: remove unused and confusing HWC_FB_BUFFERS definition.
Haixia Shi [Thu, 22 Oct 2015 17:50:33 +0000 (10:50 -0700)]
drm_hwcomposer: remove unused and confusing HWC_FB_BUFFERS definition.

BUG=none
TEST=builds

Change-Id: I5f143f93ebb82405320d4f0aaf03db4201380f8e

8 years agodrm_hwcomposer: implement squashing
Zach Reizner [Sat, 17 Oct 2015 02:06:31 +0000 (19:06 -0700)]
drm_hwcomposer: implement squashing

Change-Id: Ifd4feaa0de303ddfd519d4415ab31d2a72f26022

8 years agoMerge "drm_hwcomposer: lazily generate shaders for GLWorkerCompositor" into mnc-dr-dev
Zachary Reizner [Fri, 23 Oct 2015 22:15:55 +0000 (22:15 +0000)]
Merge "drm_hwcomposer: lazily generate shaders for GLWorkerCompositor" into mnc-dr-dev

8 years agodrm_hwcomposer: lazily generate shaders for GLWorkerCompositor
Zach Reizner [Fri, 23 Oct 2015 20:26:43 +0000 (13:26 -0700)]
drm_hwcomposer: lazily generate shaders for GLWorkerCompositor

This still generates the first shader at GLWorkerCompositor::Init() to check
for shader generation errors. It's the only time that shader compilation errors
will be shown on the log.

This change shortens GL initialization time from 2.8 seconds to about 450
milliseconds. Besides improving boot time by 2.3 seconds, less fence timeouts
should happen at boot time due to HWC blocking.

TEST=run and see no display glitches or glworker related errors in logs
BUG=chrome-os-partner:46739

Change-Id: Ia264e3f73a0ebe8558165ae3c215777ef6339ecc

8 years agodrm_hwcomposer: use latest patchset of "separate C compliant header file."
Zach Reizner [Thu, 22 Oct 2015 23:34:49 +0000 (16:34 -0700)]
drm_hwcomposer: use latest patchset of "separate C compliant header file."

Revert "drm_hwcomposer: separate C compliant header file."

This reverts commit e7eff73fb428d53c5488ef470d9e401949eb1b00.

drm_hwcomposer: separate C compliant header file.

Creating C compliant header file drmhwcgralloc.h.
gralloc.tegra uses C compiler and depends only on code in drmhwcgralloc.h.
The module doesn't depend on anything present in new drm_hwcomposer.h.
This is required to fix the compile error.

Change-Id: If7188a20a7c4ef90eb7598f0cb7733b3a45ace51

8 years agodrm_hwcomposer: Remove hwc.drm.use_framebuffer_target property
Sean Paul [Thu, 22 Oct 2015 00:05:05 +0000 (20:05 -0400)]
drm_hwcomposer: Remove hwc.drm.use_framebuffer_target property

Remove the redundant property hwc.drm.use_framebuffer_target from
drm_hwcomposer. The same can be achieved by using the "Disable HW
overlays" toggle in Developer Options.

Change-Id: I3283a8931d84113d8dc63cc818598a7f9556a171
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: separate C compliant header file.
Niranjan Artal [Mon, 19 Oct 2015 22:16:17 +0000 (15:16 -0700)]
drm_hwcomposer: separate C compliant header file.

Creating C compliant header file drm_hwc.h.
gralloc.tegra uses C compiler and depends only on code in drm_hwc.h.
The module doesn't depend on anything present in new hwcomposer.h.
This is required to fix the compile error.

Change-Id: Ib668334c03168aa4b72ad9e793eff323bd2e88fa

8 years agodrm_hwcomposer: Add sanity check on display in SetLayers
Sean Paul [Wed, 21 Oct 2015 23:11:58 +0000 (19:11 -0400)]
drm_hwcomposer: Add sanity check on display in SetLayers

Ensure that the displays given to SetLayers are actually drm displays
before referencing them in the composition_map_.

Change-Id: I87819cdb8f68ed09bf71b95dff149d5043931ffb
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: fix missing assignment of premult flag
Haixia Shi [Fri, 16 Oct 2015 17:48:15 +0000 (10:48 -0700)]
drm_hwcomposer: fix missing assignment of premult flag

This was somehow dropped due to the recent squash ground work CL.

BUG=24791071
TEST=verify bug is fixed

Change-Id: If5f2b61104d47a2d70d3c3b34149c1d62ec82659

8 years agoMerge "drm_hwcomposer: Use layer alpha to blend planes" into mnc-dr-dev
Sean Paul [Fri, 16 Oct 2015 13:52:42 +0000 (13:52 +0000)]
Merge "drm_hwcomposer: Use layer alpha to blend planes" into mnc-dr-dev

8 years agodrm_hwcomposer: do not queue layers map for virtual display
Haixia Shi [Thu, 15 Oct 2015 23:21:48 +0000 (16:21 -0700)]
drm_hwcomposer: do not queue layers map for virtual display

It is invalid to add a DrmCompositionDisplayLayersMap for the virtual
display because the corresponding physical display resources (such as
crtc, connector, etc.) do not exist.

BUG=24985282
TEST=verify that no crash occurs

Change-Id: I24a6671e7f94032a38104ae7ed3eb0da79479601

8 years agodrm_hwcomposer: add missing break statement
Zach Reizner [Thu, 15 Oct 2015 21:41:41 +0000 (14:41 -0700)]
drm_hwcomposer: add missing break statement

By a stroke of luck, the fall through case had a break statement.

Change-Id: I29cb1206d114f31ec58a603cd9dcb986764d8344

8 years agodrm_hwcomposer: Use layer alpha to blend planes
Sean Paul [Thu, 15 Oct 2015 19:17:31 +0000 (15:17 -0400)]
drm_hwcomposer: Use layer alpha to blend planes

Send the layer alpha to the drm plane's alpha property to
properly blend layers.

BUG=b/24821110
TEST=Tested on smaug with Downloads/About windows, blend properly

Change-Id: If96eb28d65d018863c39bc5a3554daef0264144b
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: reimplement Dump for DrmDisplayCompositor
Zach Reizner [Wed, 14 Oct 2015 04:12:48 +0000 (21:12 -0700)]
drm_hwcomposer: reimplement Dump for DrmDisplayCompositor

Also fixes hwc_dump sometimes failing to null terminate its output buffer.

TEST=dumpsys SurfaceFlinger

Change-Id: Ibf93cfd496a07a9375d78a8b239c2c7876aff986

8 years agoMerge "drm_hwcomposer: ground work for squashing" into mnc-dr-dev
Zachary Reizner [Thu, 15 Oct 2015 18:41:58 +0000 (18:41 +0000)]
Merge "drm_hwcomposer: ground work for squashing" into mnc-dr-dev

8 years agodrm_hwcomposer: Do not close duplicate gem handles in nvimporter
Isaac Simha [Wed, 14 Oct 2015 18:40:29 +0000 (11:40 -0700)]
drm_hwcomposer: Do not close duplicate gem handles in nvimporter

When closing gem handles in ReleaseBufferImpl, do not try to close
the same one more than once.

BUG=chrome-os-partner:46443
TEST=Play youtube video, minimize.  Observe no "Failed to close
gem handle" messages in logcat.

Change-Id: I06598f304e3bd167a77f105eb2be86595ada8f4d
Signed-off-by: Isaac Simha <isimha@nvidia.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: ground work for squashing
Zach Reizner [Tue, 13 Oct 2015 00:47:13 +0000 (17:47 -0700)]
drm_hwcomposer: ground work for squashing

This patch rearranges things to make squashing possible.
The high-level changes:
  - A new Plan phase that happens in QueueComposition. This is where the
    overlay allocation is moved to. It's also the only safe time that
    the composition can try to plan squashing. This is because squashing
    depends on the exact ordering of compositions.
  - GLWorker now renders regions rather than layers. A region in this case is
    a clipping rectange and set of layers that are to be rendered in that
    rectangle. This is always what GLWorker did in the end, but now the work
    to seperate layers into regions is done externally. This was changed
    because the output of SquashState is a list of stable regions that need to
    be put through GLWorker

The Plan methods of the Compositions are responsible for updating per-display
SquashState and for allocation regions/layers to squashing, pre-composition, or
hardware overlay. Because of the drastic changes to how composition planning
works, it was necessary to bundle it with the GLWorker change.

This change also includes plenty of other refactorings that were deemed to
be too painful to try and seperate into another change.

Change-Id: Ie7bfe077067e936a0862a07cbe87b525eab8d4f8

8 years agoMerge "drm_hwcomposer: Disable planes on frame failure" into mnc-dr-dev
Sean Paul [Wed, 14 Oct 2015 15:26:43 +0000 (15:26 +0000)]
Merge "drm_hwcomposer: Disable planes on frame failure" into mnc-dr-dev

8 years agodrm_hwcomposer: name the texture samplers individually and unroll loop
Haixia Shi [Tue, 13 Oct 2015 20:52:55 +0000 (13:52 -0700)]
drm_hwcomposer: name the texture samplers individually and unroll loop

Per GLSL spec: when aggregated into arrays within a shader, samplers can
only be indexed with a "dynamically uniform integra expression", other-
wise results are undefined.

The current fragment shader is not spec compliant because it evaluates
the sampler array in a non-uniform flow control, where the loop may exit
early in a "break" statement depending on the per-pixel alpha value.

BUG=24718688
BUG=chrome-os-partner:46348
TEST=follow bug report and verify GLWorker composites 5 layers correctly

Change-Id: I3a4c4b5aa847a1b5ec32f58f0e8c0b349289f5f5

8 years agoMerge "drm_hwcomposer: fix logic error in premult blending" into mnc-dr-dev
Haixia Shi [Wed, 14 Oct 2015 01:31:29 +0000 (01:31 +0000)]
Merge "drm_hwcomposer: fix logic error in premult blending" into mnc-dr-dev

8 years agodrm_hwcomposer: fix logic error in premult blending
Haixia Shi [Wed, 14 Oct 2015 01:27:10 +0000 (18:27 -0700)]
drm_hwcomposer: fix logic error in premult blending

In case of premult blending, the tex.rgb is premultiplied with tex.a,
but it still needs to be multiplied by the plane alpha.

BUG=24914993
TEST=verify the blending artifacts are fixed

Change-Id: I9135f91d52b2d256a71895e13caf2158286de992

8 years agodrm_hwcomposer: set the composition map's display field
Zach Reizner [Wed, 14 Oct 2015 01:19:26 +0000 (18:19 -0700)]
drm_hwcomposer: set the composition map's display field

Change-Id: I67842cdfd0afab67a81448c1b64da47d2f933db3

8 years agoMerge "drm_hwcomposer: Increase failure time for acquire fences" into mnc-dr-dev
Sean Paul [Tue, 13 Oct 2015 20:24:49 +0000 (20:24 +0000)]
Merge "drm_hwcomposer: Increase failure time for acquire fences" into mnc-dr-dev

8 years agodrm_hwcomposer: Disable planes on frame failure
Sean Paul [Tue, 13 Oct 2015 19:47:22 +0000 (15:47 -0400)]
drm_hwcomposer: Disable planes on frame failure

When a frame fails, disable all active planes for the display
and signal the release fences. This avoids the situation where
we might end up frozen b/c someone is waiting for the active
fences to signal.

BUG=chrome-os-partner:46301
TEST=Tested on smaug with a kernel that fails every 1000 frames

Change-Id: I3cd4ad4f22801068465b2c6278e96027b5a7e3c5
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Increase failure time for acquire fences
Sean Paul [Tue, 13 Oct 2015 19:44:45 +0000 (15:44 -0400)]
drm_hwcomposer: Increase failure time for acquire fences

Increase the acquire timeout to effectively 500ms before failing
a frame. Also log every 100ms so we're still able to track long
fence waits.

BUG=chrome-os-partner:46301
TEST=Tested on smaug with cts test, saw timeout messages, but not
     failures

Change-Id: I28ec8bbf95f4a70bd3e99ea7a3333166c6080788
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: improve logging and reliability of some error paths
Zach Reizner [Mon, 12 Oct 2015 22:20:33 +0000 (15:20 -0700)]
drm_hwcomposer: improve logging and reliability of some error paths

Change-Id: I4a955c6261a9674009eec2264eb2ef4a161da9c4

8 years agodrm_hwcomposer: fix small class consistency issues
Zach Reizner [Fri, 9 Oct 2015 20:02:55 +0000 (13:02 -0700)]
drm_hwcomposer: fix small class consistency issues

This also fixes a typo in an error message.

Change-Id: Ie6c369f5eb2496ac3ebb342dbdcdd70f3a176495

8 years agodrm_hwcomposer: small feature/style enhancements for seperate_rects
Zach Reizner [Fri, 9 Oct 2015 17:02:54 +0000 (10:02 -0700)]
drm_hwcomposer: small feature/style enhancements for seperate_rects

With C++11, we can condense the double angle brackets.

This commit also includes an integer version of seperate_rects and some
convenience functions for rectangles.

Change-Id: Ide2a6b930cdf30c0f7a58d4199e02c06df492776

8 years agodrm_hwcomposer: use in-class member initializers for AutoEGLDisplayImage
Zach Reizner [Fri, 9 Oct 2015 16:54:42 +0000 (09:54 -0700)]
drm_hwcomposer: use in-class member initializers for AutoEGLDisplayImage

Change-Id: Id78a646d264eb3fab833f279f30570ddc89fadb7

8 years agodrm_hwcomposer: support the PREMULT blending mode in glworker
Haixia Shi [Fri, 9 Oct 2015 22:48:47 +0000 (15:48 -0700)]
drm_hwcomposer: support the PREMULT blending mode in glworker

BUG=24791071
TEST=verify notification icon shade is consistent with or without glworker

Change-Id: Ib7db1ece2e1dd327fdc1ffdbd44c360bd63f76b9

8 years agodrm_hwcomposer: Fix EGL_BAD_DISPLAY errors
Season Li [Thu, 8 Oct 2015 00:47:55 +0000 (17:47 -0700)]
drm_hwcomposer: Fix EGL_BAD_DISPLAY errors

Dont call eglDestroyImageKHR in move construtor
since image_ and display_ are not initialized.

Google Issue: 44452

Change-Id: Ie20be3b021d4562f2cd8a89d2666307afcde1cf2

8 years agodrm_hwcomposer: support virtual displays
Haixia Shi [Mon, 5 Oct 2015 21:35:09 +0000 (14:35 -0700)]
drm_hwcomposer: support virtual displays

Virtual display support is mandatory for HWC version 1.4.

As a minimal implementation, we use frambuffer target and let SF take care of
GLES composition. We still need to handle the acquire and release fences for
both the virtual display and all layers in a separate worker thread.

BUG=24609829
TEST=screen casting to chromecast

Change-Id: Idb962f4b5bb852c9ec9ebcaa1679a653c01737fb

8 years agoMerge "drm_hwcomposer: fill hwc_display_contents retireFenceFd" into mnc-dr-dev
Zachary Reizner [Wed, 7 Oct 2015 22:11:51 +0000 (22:11 +0000)]
Merge "drm_hwcomposer: fill hwc_display_contents retireFenceFd" into mnc-dr-dev

8 years agodrm_hwcomposer: fill hwc_display_contents retireFenceFd
Zach Reizner [Tue, 6 Oct 2015 22:39:09 +0000 (15:39 -0700)]
drm_hwcomposer: fill hwc_display_contents retireFenceFd

This restores the behavior of "drm_hwcomposer: Populate retireFenceFd"

The retire fence is triggered when all releaseFenceFd's of the display's
layers are triggered.

Change-Id: Id06f2df03dcb9638ccbae23f46c42b05551fae6d

8 years agodrm_hwcomposer: Bump the acquire fence timeout to 83ms
Sean Paul [Thu, 1 Oct 2015 17:20:02 +0000 (13:20 -0400)]
drm_hwcomposer: Bump the acquire fence timeout to 83ms

To accomodate peak usage situations.

Change-Id: I46031ce394abf1ec09177089508dd625d7c17aaa
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Process modesets via compositor
Sean Paul [Sat, 19 Sep 2015 13:14:34 +0000 (09:14 -0400)]
drm_hwcomposer: Process modesets via compositor

This patch queues modeset in the compositor for application on
the next frame. This allows us to perform the modeset atomically
with the first frame that comes in after the mode is changed.

Change-Id: I6bb9edd17bbdd6dbee5c0474f2e43599781cc7a7
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: fix crash in hwc_set()
Haixia Shi [Wed, 30 Sep 2015 17:57:54 +0000 (10:57 -0700)]
drm_hwcomposer: fix crash in hwc_set()

For each display context we need to unconditionally call emplace_back()
on layers_indices to ensure that entries in layers_indices correspond to
the correct display.

BUG=24506167
TEST=still builds and boots ok
Change-Id: I6bc0858471c9ec51615c8ed7d8613529f77cb1ab

8 years agodrm_hwcomposer: Set timeouts for fence waits
Sean Paul [Tue, 29 Sep 2015 04:56:00 +0000 (00:56 -0400)]
drm_hwcomposer: Set timeouts for fence waits

Instead of waiting forever for fences, set some reasonable timeouts
so we can move on with life if a fence doesn't signal.

BUG=chrome-os-partner:45868
TEST=Tested on smaug with osmos, recovered from fence timeouts

Change-Id: I7f18d684d483d789f228cbad8d5a3e43ac898a43
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: use GL_TEXTURE_EXTERNAL_OES target for src textures
Haixia Shi [Fri, 25 Sep 2015 18:49:44 +0000 (11:49 -0700)]
drm_hwcomposer: use GL_TEXTURE_EXTERNAL_OES target for src textures

The GL_TEXTURE_EXTERNAL_OES supports format conversion for YUV external
textures, whereas GL_TEXTURE_2D does not.

Convert crop rects to normalized coordinates.

BUG=chrome-os-partner:45761
TEST=run netflix and observe corruption is fixed during animation transition

Change-Id: Iad9a187faad6b58f1c4b1d19edd0d2a5cbc9a561

8 years agodrm_hwcomposer: implement the safe handling of layers
Zach Reizner [Fri, 11 Sep 2015 01:30:54 +0000 (18:30 -0700)]
drm_hwcomposer: implement the safe handling of layers

This is a sweeping change to discard our usage of struct hwc_layer_t outside
hwcomposer.cpp. That was a dangerous struct that was a source of many of our
errors. Replacing it with safer RAII-style classes reduces the amount and
complexity of our code.

Change-Id: I580cafdf89bd1e7e6583f3073858b8e78e6018ba

8 years agoMerge "drm_hwcomposer: limit maximum depth of display composition queue" into mnc...
Sean Paul [Tue, 22 Sep 2015 17:48:30 +0000 (17:48 +0000)]
Merge "drm_hwcomposer: limit maximum depth of display composition queue" into mnc-dr-dev

8 years agodrm_hwcomposer: Make gl worker log tag consistent with rest of hwc
Sean Paul [Mon, 21 Sep 2015 14:05:19 +0000 (10:05 -0400)]
drm_hwcomposer: Make gl worker log tag consistent with rest of hwc

For easy logcat grepping.

Change-Id: I79b82f4d359268a6e116f602f2ffb90885cdb3dd
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Plumb frame number through display composition
Sean Paul [Mon, 21 Sep 2015 14:04:02 +0000 (10:04 -0400)]
drm_hwcomposer: Plumb frame number through display composition

Having frame number in the composition is very useful for
debugging transient issues, plumb it through the drm compositor
stack.

Change-Id: Ibc7555c89bea79c580b3201b11db4ced6360efb9
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: correctly handle rotation + cropping
Haixia Shi [Thu, 10 Sep 2015 22:16:47 +0000 (15:16 -0700)]
drm_hwcomposer: correctly handle rotation + cropping

BUG=chrome-os-partner:44741
TEST=ryu, window transition animation (10x slowdown) in all orientations

Change-Id: Ibeb880a60ecf168e9d15e2f16b5f0b5642d85f1c

8 years agodrm_hwcomposer: use HWC_FRAMEBUFFER_TARGET if all HWC_OVERLAY layers are skipped
Haixia Shi [Wed, 9 Sep 2015 19:08:20 +0000 (12:08 -0700)]
drm_hwcomposer: use HWC_FRAMEBUFFER_TARGET if all HWC_OVERLAY layers are skipped

Apparently there are cases (such as during rotation) where SF will put content
in framebuffer target and set HWC_SKIP_LAYER on all other layers. In this case
we need to use the HWC_FRAMEBUFFER_TARGET layer.

BUG=23936827
TEST=verify on ryu that rotation works

Change-Id: Ice8ee5a023a92fc286dbf837a822fa6f6c0fde6b

8 years agodrm_hwcomposer: Allow NULL crtcs in display composition
Sean Paul [Fri, 4 Sep 2015 05:33:06 +0000 (01:33 -0400)]
drm_hwcomposer: Allow NULL crtcs in display composition

In cases where we have displays which do not have a mode,
the crtc will be NULL. This shouldn't fail the composition
initialization.

Change-Id: I1a6acb72cd3f614b5a7c854ba61be1539efa4bea
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Allow layer transforms
Stéphane Marchesin [Tue, 25 Aug 2015 07:08:10 +0000 (00:08 -0700)]
drm_hwcomposer: Allow layer transforms

They are very much valid now. I think this is just leftover?

BUG=chrome-os-partner:42717
TEST=test rotation, it doesn't lock up

Change-Id: I4cd96ae91c91452ef2be3cb3b07c123ce38ed576