OSDN Git Service

android-x86/external-drm_hwcomposer.git
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

8 years agodrm_hwcomposer: cache the framebuffers given to the GLWorker
Zach Reizner [Thu, 20 Aug 2015 21:52:12 +0000 (14:52 -0700)]
drm_hwcomposer: cache the framebuffers given to the GLWorker

This saves some work in EGL/GL that would normally get repeated every frame.
Because the same framebuffers are generally used every frame, this CL adds a
cache containing all the EGL/GL objects that correspond to the given
GraphicBuffer. The cache initially holds a strong reference while rendering,
but once glFinish is called, only a weak reference is held until rendering
to that same GraphicBuffer starts again. The weak reference is used to check
if that GraphicBuffer has been destroyed, which means the corresponding EGL/GL
resources should be destroyed.

The cache can be disabled with the following command:
$ adb shell setprop hwc.drm.use_framebuffer_cache 0

Change-Id: Iddee1efc5bad67f6c4479e7f402354e229c3b0a2

8 years agodrm_hwcomposer: add properties to disable overlays or to use HWC_FRAMEBUFFER
Zach Reizner [Fri, 14 Aug 2015 18:14:38 +0000 (11:14 -0700)]
drm_hwcomposer: add properties to disable overlays or to use HWC_FRAMEBUFFER

To use SurfaceFlinger's GL compositor, use the setprop command:
$ adb shell setprop hwc.drm.use_framebuffer_target 1

A side effect of using the above property is that drm_hwcomposer will only be
compositing one primary plane.

To disable overlays (to force the GL compositor to be used more often):
$ adb shell setprop hwc.drm.use_overlay_planes 0

The default behavior is the opposite of the above properties.

Change-Id: I86afb533c10a8caa15931e8c292f52bb94e5f6c5

8 years agodrm_hwcomposer: enhance stability using various wrapper classes
Zach Reizner [Thu, 13 Aug 2015 21:53:41 +0000 (14:53 -0700)]
drm_hwcomposer: enhance stability using various wrapper classes

This commit contains a lot of churn because it changes code to use automatic
resource lifetimes as much as possible. As more things get changed, this is
essential to maintaining stability.

In addition, this change changes how layers are passed through the compositor
API. Before each layer was passed down one at a time. Now they are passed in
all at once. This is simpler for the implementation because it makes errors
more atomic and makes decisions easier for the compositors.

Change-Id: Ic3e6b5d0089fb1631ea256adcce9910ed8f38366

8 years agodrm_hwcomposer: style fixes
Zach Reizner [Thu, 13 Aug 2015 21:32:09 +0000 (14:32 -0700)]
drm_hwcomposer: style fixes

Change-Id: Id04a088a895f8372a32623713589d43d5e0495ef

8 years agodrm_hwcomposer: duplicate buffer_handles before hwc_set returns
Zach Reizner [Fri, 7 Aug 2015 23:00:01 +0000 (16:00 -0700)]
drm_hwcomposer: duplicate buffer_handles before hwc_set returns

This is needed because SF will sometimes release buffer_handles before GL gets
to using them for composition.

Change-Id: I01db0975cc82d6b59bf4f9521a24071baf89c38a

8 years agodrm_hwcomposer: fix buffer leak when using the GL compositor inside DrmDisplayCompositor
Zach Reizner [Thu, 30 Jul 2015 15:10:14 +0000 (08:10 -0700)]
drm_hwcomposer: fix buffer leak when using the GL compositor inside DrmDisplayCompositor

Change-Id: Id3a6deea9fc0f97640b34dacb25d36f3793f2d4e

8 years agoRevert "Revert "drm_hwcomposer: remove compositor interface""
Zach Reizner [Fri, 31 Jul 2015 22:12:49 +0000 (15:12 -0700)]
Revert "Revert "drm_hwcomposer: remove compositor interface""

This reverts commit 1c5e55680d9165d8f9bb2bc6e2c4261574b5d41d.

8 years agoRevert "Revert "drm_hwcomposer: remove GLCompositor and the GLWorker thread""
Zach Reizner [Fri, 31 Jul 2015 22:12:47 +0000 (15:12 -0700)]
Revert "Revert "drm_hwcomposer: remove GLCompositor and the GLWorker thread""

This reverts commit d078e4cab78f81057cd25355199caba5a147342e.

8 years agoRevert "Revert "drm_hwcomposer: have DrmDisplayCompositor do its own OpenGL composition""
Zach Reizner [Fri, 31 Jul 2015 22:12:44 +0000 (15:12 -0700)]
Revert "Revert "drm_hwcomposer: have DrmDisplayCompositor do its own OpenGL composition""

This reverts commit cbe9c01336e23a63259db65d22d63d6a697b8813.

8 years agoRevert "drm_hwcomposer: have DrmDisplayCompositor do its own OpenGL composition"
Puneet Kumar [Thu, 30 Jul 2015 03:38:11 +0000 (03:38 +0000)]
Revert "drm_hwcomposer: have DrmDisplayCompositor do its own OpenGL composition"

This reverts commit 2317bb19d8663efc31e6fcd8cf7fd2a73577253d.

For now until we figure out a more stable SF/hwc

Change-Id: Ia5ca089610a487bf036a1ddd5fb62e504e02ad98

8 years agoMerge "Revert "drm_hwcomposer: remove GLCompositor and the GLWorker thread"" into...
Sean Paul [Thu, 30 Jul 2015 13:18:30 +0000 (13:18 +0000)]
Merge "Revert "drm_hwcomposer: remove GLCompositor and the GLWorker thread"" into mnc-dr-dev

8 years agoRevert "drm_hwcomposer: remove GLCompositor and the GLWorker thread"
Puneet Kumar [Thu, 30 Jul 2015 03:36:46 +0000 (03:36 +0000)]
Revert "drm_hwcomposer: remove GLCompositor and the GLWorker thread"

This reverts commit abebc7a78fe8a4df6495c8e5064719dc92b04004.

For now until we figure out a more stable solution for SF/hwc

Change-Id: I7a505fc67873f943704e8b48db4167b9beca7691

8 years agoRevert "drm_hwcomposer: remove compositor interface"
Puneet Kumar [Thu, 30 Jul 2015 03:35:38 +0000 (03:35 +0000)]
Revert "drm_hwcomposer: remove compositor interface"

This reverts commit 7912438911de042dc035cf1ea39daaf4e56bf9f3.

For now until we can get back to a stable SF/compositor.

Change-Id: I2ba7cab4f1cccfe44b3d35fb18c7784125e88fd6

8 years agodrm_hwcomposer: limit maximum depth of display composition queue
Zach Reizner [Tue, 28 Jul 2015 22:33:07 +0000 (15:33 -0700)]
drm_hwcomposer: limit maximum depth of display composition queue

SurfaceFlinger will destroy our layer handles if we don't use them after about
a second. To get around this issue, we block SurfaceFlinger on hwc_set if the
display composition queue is getting too large. This often happens during
the init of the GLWorker or during heavy GPU usage.

Change-Id: Idb4a3a81e0d3a2caf7f94e5515a19ec16a1c67e3

8 years agodrm_hwcomposer: remove compositor interface
Zach Reizner [Wed, 22 Jul 2015 22:01:37 +0000 (15:01 -0700)]
drm_hwcomposer: remove compositor interface

The compositor interface had only one implementation and one user. The
compositor interface also needs to change to accomodate some changes for
fences to work optimally.

Change-Id: I02d21b0a0e86fa21b3c5f4ad84ff571611643994

8 years agodrm_hwcomposer: remove GLCompositor and the GLWorker thread
Zach Reizner [Tue, 21 Jul 2015 22:06:16 +0000 (15:06 -0700)]
drm_hwcomposer: remove GLCompositor and the GLWorker thread

They are dead code now that DrmDisplayCompositor uses GL directly.

Change-Id: Ie4beeab60440a51bd87486847b5453e20288d1d8

8 years agoMerge "drm_hwcomposer: Populate retireFenceFd" into mnc-dr-dev
Sean Paul [Wed, 22 Jul 2015 10:45:40 +0000 (10:45 +0000)]
Merge "drm_hwcomposer: Populate retireFenceFd" into mnc-dr-dev

8 years agodrm_hwcomposer: Populate retireFenceFd
Sean Paul [Thu, 16 Jul 2015 19:59:24 +0000 (15:59 -0400)]
drm_hwcomposer: Populate retireFenceFd

Join all layer releaseFenceFd fences together to get the
retireFenceFd for the display.

Change-Id: I431ee227a62397b1900adb0caaf8b16b319a99cd
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: have DrmDisplayCompositor do its own OpenGL composition
Zach Reizner [Thu, 16 Jul 2015 17:14:26 +0000 (10:14 -0700)]
drm_hwcomposer: have DrmDisplayCompositor do its own OpenGL composition

To accomplish this a few things changed:
- DrmComposition::GetRemainingLayers always returns the number of planes needed
- DrmComposition::AddLayer succeeds even if no DrmPlane was found for it
- DrmDisplayComposition::AddLayer has overload that imports the given buffer
- GLWorkerCompositor has a function to finish its composite before returning

Put together this change makes DrmComposition always accepts all layers given to
it even if it means some of those layers are assigned a NULL DrmPlane. The
DrmDisplayCompositor will scan its given layers for any that are missing planes.
In such a case, a DrmPlane is stolen from the last layer to receive a plane.
Then all layers in the DrmDisplayComposition that have no planes (including the
one stolen from) are composited synchronously using a GLWorkerCompositor and a
new layer is generated from the results. That layer is added to the
DrmDisplayComposition using the new import AddLayer function and the stolen
DrmPlane. DrmDisplayCompostior then continues as usual.

Change-Id: Ia6477c210c8f1307a4e537bec46889110d79ca18

8 years agodrm_hwcomposer: make sure all fences are released for DrmDisplayComposition
Zach Reizner [Fri, 17 Jul 2015 21:13:28 +0000 (14:13 -0700)]
drm_hwcomposer: make sure all fences are released for DrmDisplayComposition

This change will release the layers passed back to SurfaceFlinger even on an
error in the compositor thread.

Change-Id: I22f622855c8c953a058b4a08d0af1ae427e4cbbd

8 years agodrm_hwcomposer: clang-format style and gcc warning fixes
Zach Reizner [Fri, 17 Jul 2015 21:10:03 +0000 (14:10 -0700)]
drm_hwcomposer: clang-format style and gcc warning fixes

The warning I fixed was unitialized rotation variable. The check for error
followed by a break satisfied the compiler.

Change-Id: Ia1a1a01da252a10aa245e45d588b3aeb91ebf58a

8 years agoMerge "drm_hwcomposer: add transform support to OpenGL compositor" into mnc-dr-dev
Zach Reizner [Fri, 17 Jul 2015 00:22:59 +0000 (00:22 +0000)]
Merge "drm_hwcomposer: add transform support to OpenGL compositor" into mnc-dr-dev

8 years agodrm_hwcomposer: add transform support to OpenGL compositor
Zach Reizner [Thu, 16 Jul 2015 23:53:41 +0000 (16:53 -0700)]
drm_hwcomposer: add transform support to OpenGL compositor

The GL compositor will respect the layer.transform enum. However, using a
non-identity transform with source cropping is untested, and the documentation
is unclear on what the expected results should be anyways.

Change-Id: I10007743d5b17c611671b647e8f404fdbe1ab4a5

8 years agoMerge "drm_hwcomposer: style fixes with clang-format" into mnc-dr-dev
Zach Reizner [Thu, 16 Jul 2015 21:45:44 +0000 (21:45 +0000)]
Merge "drm_hwcomposer: style fixes with clang-format" into mnc-dr-dev

8 years agoMerge "drm_hwcomposer: make the gl worker compositor not nested" into mnc-dr-dev
Zach Reizner [Thu, 16 Jul 2015 21:45:10 +0000 (21:45 +0000)]
Merge "drm_hwcomposer: make the gl worker compositor not nested" into mnc-dr-dev

8 years agodrm_hwcomposer: Add rotation support for hw planes
Sean Paul [Tue, 14 Jul 2015 19:51:52 +0000 (15:51 -0400)]
drm_hwcomposer: Add rotation support for hw planes

This patch adds support for transformed layers by using the
rotation property on drm planes.

Bug: chrome-os-partner:42093
Test: On smaug using
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:<R>

Change-Id: I86bb8ef2f77b5d046a5fddd57db4b87070b5801f
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: style fixes with clang-format
Zach Reizner [Thu, 16 Jul 2015 16:45:59 +0000 (09:45 -0700)]
drm_hwcomposer: style fixes with clang-format

Change-Id: I020072a782dde7551ae940d12f3925b8680ba0af

8 years agodrm_hwcomposer: make the gl worker compositor not nested
Zach Reizner [Thu, 16 Jul 2015 01:44:37 +0000 (18:44 -0700)]
drm_hwcomposer: make the gl worker compositor not nested

Change-Id: I06b75644408a570044499a9f603a478f3199661f

8 years agoMerge "drm_hwcomposer: Dump active composition plane/crtc/dimension info" into mnc...
Sean Paul [Wed, 15 Jul 2015 19:19:40 +0000 (19:19 +0000)]
Merge "drm_hwcomposer: Dump active composition plane/crtc/dimension info" into mnc-dr-dev

8 years agodrm_hwcomposer: Convert src_x,src_y to 16.16 fixed
Sean Paul [Wed, 15 Jul 2015 16:36:48 +0000 (12:36 -0400)]
drm_hwcomposer: Convert src_x,src_y to 16.16 fixed

We convert src_w,src_h, but failed to convert src_x.src_y. This
has the effect of never indexing into fb's properly.

Bug: chrome-os-parter:42311
Test: On smaug, open up the add google account screen, it should
      not be shifted

Change-Id: Ic5cf654d93ea6c89c2cbd23c1d847fbc412a7d19
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Dump active composition plane/crtc/dimension info
Sean Paul [Mon, 13 Jul 2015 16:41:37 +0000 (12:41 -0400)]
drm_hwcomposer: Dump active composition plane/crtc/dimension info

Should help with debugging if we can compare the SF layer info with
what drm_hwc is doing.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I333848b2141dff4c533f6dc22194826fdcf25dff

8 years agoMerge "drm_hwcomposer: Print fps as float in dump()" into mnc-dr-dev
Stéphane Marchesin [Mon, 13 Jul 2015 23:40:12 +0000 (23:40 +0000)]
Merge "drm_hwcomposer: Print fps as float in dump()" into mnc-dr-dev

8 years agoMerge "drm_hwcomposer: Convert v_refresh() to float" into mnc-dr-dev
Stéphane Marchesin [Mon, 13 Jul 2015 23:39:52 +0000 (23:39 +0000)]
Merge "drm_hwcomposer: Convert v_refresh() to float" into mnc-dr-dev

8 years agoam e850fa2e: (-s ours) drm_hwcomposer: Process DPMS requests through compositor
Sean Paul [Mon, 13 Jul 2015 23:00:14 +0000 (23:00 +0000)]
am e850fa2e: (-s ours) drm_hwcomposer: Process DPMS requests through compositor

* commit 'e850fa2e39da03695e03c1824a08f8be9b4cfdbf':
  drm_hwcomposer: Process DPMS requests through compositor
  drm_hwcomposer: Free failed composition in QueueComposition

8 years agoam 1abf5c3f: (-s ours) drm_hwcomposer: Add composition type to DrmComposition
Sean Paul [Mon, 13 Jul 2015 22:53:58 +0000 (22:53 +0000)]
am 1abf5c3f: (-s ours) drm_hwcomposer: Add composition type to DrmComposition

* commit '1abf5c3fd61c1698e1ef7f9794cac5e22609a58c':
  drm_hwcomposer: Add composition type to DrmComposition

8 years agoam e86fcfbb: (-s ours) drm_hwcomposer: Split the drm compositor into per-display...
Sean Paul [Mon, 13 Jul 2015 22:42:09 +0000 (22:42 +0000)]
am e86fcfbb: (-s ours) drm_hwcomposer: Split the drm compositor into per-display threads

* commit 'e86fcfbb5c3f857efbcccb335c9a1a72a7a101cb':
  drm_hwcomposer: Split the drm compositor into per-display threads

8 years agodrm_hwcomposer: Print fps as float in dump()
Stéphane Marchesin [Mon, 13 Jul 2015 19:35:41 +0000 (12:35 -0700)]
drm_hwcomposer: Print fps as float in dump()

This is more accurate than using ints which helps with profiling work.

Change-Id: I9ba8cc8a2b0e9c1fa02bc217444d4001f0e19009

8 years agodrm_hwcomposer: Convert v_refresh() to float
Stéphane Marchesin [Sun, 5 Jul 2015 09:00:08 +0000 (02:00 -0700)]
drm_hwcomposer: Convert v_refresh() to float

We convert v_refresh() to return a float and instead of storing it,
compute it on the fly from the pixel clock + htotal/vtotal. This makes
the synthetic vblank computation much more accurate.

Change-Id: I2a0becf75eaca8ace30d176fdc813f3b57ba23a5

8 years agodrm_hwcomposer: Use vector for overlay planes
Sean Paul [Thu, 9 Jul 2015 21:51:50 +0000 (17:51 -0400)]
drm_hwcomposer: Use vector for overlay planes

For two reasons:
1- Because we don't need to use deque
2- Because we'll need to erase from the middle in the future,
   and deque makes that difficult while iterating

BUG=chrome-os-parter:42311
TEST=Tested on smaug, turned on/off bunch of times, no dup icons

Change-Id: I306bdea15d7165f63afeb3b1e06774e2e9a1785f
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Disable unused planes
Sean Paul [Thu, 9 Jul 2015 21:22:22 +0000 (17:22 -0400)]
drm_hwcomposer: Disable unused planes

Right before queuing up a composition, go through the
list of unused planes and add disable markers such
that they don't remain active when the new frame is
posted.

BUG=chrome-os-parter:42311
TEST=Tested on smaug, turned on/off bunch of times, no dup icons

Change-Id: Ic2e5e210873efb6dc41fd43682fe00db33c2a28e
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Process DPMS requests through compositor
Sean Paul [Thu, 25 Jun 2015 01:46:05 +0000 (18:46 -0700)]
drm_hwcomposer: Process DPMS requests through compositor

This patch changes the behavior of DPMS in hwcomposer from
applying asynchronously/immediately, to queuing in the
compositor and being processed in order. This is desirable
for a couple of reasons:
  1- It ensures all frames set before set_power_mode are
     shown on the screen before it turns off
  2- We make sure we don't rmfb a framebuffer that is
     currently applied to a disabled crtc.

The second reason above can cause the display to turn back
off once it's on since the fb will dereference to zero in
the kernel and it will disable the pipe without notifying
us.

Change-Id: I2aab9ee0353b12fecced46766ed2dbb64f0aef4b
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Free failed composition in QueueComposition
Sean Paul [Fri, 10 Jul 2015 20:43:06 +0000 (16:43 -0400)]
drm_hwcomposer: Free failed composition in QueueComposition

Rather than maintaining ownership of the composition in the
caller, free the DrmComposition in QueueComposition on failure.

Change-Id: Id70e98ae1a8eef400bc29460bfc5a89c4707d617
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Add composition type to DrmComposition
Sean Paul [Thu, 25 Jun 2015 01:43:01 +0000 (18:43 -0700)]
drm_hwcomposer: Add composition type to DrmComposition

This allows us to have different types of compositions. This will
enable injection of non-frame related compositions such as dpms
and mode.

Change-Id: Ia62421c114c0c6bebccef3ce6ae936366b6aafe2
Signed-off-by: Sean Paul <seanpaul@chromium.org>
8 years agodrm_hwcomposer: Split the drm compositor into per-display threads
Sean Paul [Wed, 24 Jun 2015 21:38:49 +0000 (14:38 -0700)]
drm_hwcomposer: Split the drm compositor into per-display threads

This patch splits out the current single drm compositor with
per-display compositors, each with their own thread.

The per-display compositors are hidden behind a singleton
drm compositor. This allows us to maintain a whole-world view
of all displays involved in a frame. This becomes useful if
we start switching up crtcs/encoders for the displays.
This also allows us to issue one DrmComposition when the
frame is being assembled.

The single DrmComposition handles the plane allocation (since they
might switch between displays), and contains per-display compositions
which are used to store the layer->plane/crtc information for each
frame. The display compositors use the per-display compositions to
display the frame on their output.

Each display compositor receives a shared pointer to the frame's
DrmComposition on QueueComposition. As a result, both the composition,
and the per-display compositions, live for as long as any one
display is still using it. While this is sub-optimal (since a display
might never update again), this is probably fine for now.

Finally, splitting things up per-display will allow us to inject
non-compositing jobs into the composite queue. An example would be
turning the display off, or setting the mode. This ensures that all
frames in the composite queue are displayed before the mode changes
or the display is disabled.

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I8a233ea64710b238f70acbcde1f6d771e297b069

8 years agodrm_hwcomposer: Process DPMS requests through compositor
Sean Paul [Thu, 25 Jun 2015 01:46:05 +0000 (18:46 -0700)]
drm_hwcomposer: Process DPMS requests through compositor

This patch changes the behavior of DPMS in hwcomposer from
applying asynchronously/immediately, to queuing in the
compositor and being processed in order. This is desirable
for a couple of reasons:
  1- It ensures all frames set before set_power_mode are
     shown on the screen before it turns off
  2- We make sure we don't rmfb a framebuffer that is
     currently applied to a disabled crtc.

The second reason above can cause the display to turn back
off once it's on since the fb will dereference to zero in
the kernel and it will disable the pipe without notifying
us.

Change-Id: I2aab9ee0353b12fecced46766ed2dbb64f0aef4b
Signed-off-by: Sean Paul <seanpaul@chromium.org>