Instead of having a dedicated vsync worker for each display, factor out
the drm fd wait from the set workers into a global event worker. This
worker will dispatch vsync() callbacks to SurfaceFlinger, as well as
unblock the appropriate set worker when flips complete.
Change-Id: I169132b2a93a2c9feabcab116aab4e61861166e1
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Move drm fb object creation to the importer.
In NV importer, use GRALLOC_MODULE_PERFORM_SET_IMPORTER_PRIVATE
and GRALLOC_MODULE_PERFORM_GET_IMPORTER_PRIVATE to cache the hwc_drm_bo
in the gralloc buffer. This avoids the need to recreate fb objects
again each frame, and also greatly simplifies managing the lifetime of
the gem handles.
The drm_gralloc importer does not support caching at this point. In an
attempt to keep it somewhat working, add hwc_import_bo_release function
that hwc calls when it's ok to rm fb. If hwc_import_bo_release returns
true, then hwc will clean up gem handles as it did before.
We should consider doing a follow-up patch that adds fb/gem caching to
drm_gralloc importer also. Then some of the code that is kept in this
patch for backwards compatibility can be removed.
Change-Id: I92857dcaddf8cea219ebc041e16ef76087a1b696
Reviewed-on: https://chrome-internal-review.googlesource.com/200895
Reviewed-by: Stéphane Marchesin <marcheu@google.com>
Commit-Queue: Stéphane Marchesin <marcheu@google.com>
Tested-by: Stéphane Marchesin <marcheu@google.com>
Initialize timeline_next to 1, because point 0 will be the very first
set operation. Since we increment every time set() is called,
initializing to 0 would cause an off-by-one error where
surfaceflinger would always composite on the front buffer.
Change-Id: I1e67c36864716595eb489286a7db3f1dcb04f67e
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Reviewed-on: https://chrome-internal-review.googlesource.com/200735
Tested-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Allen Martin <amartin@nvidia.com>
Reviewed-by: Sean Paul <seanpaul@google.com>
Initialize timeline_next to 0
Change-Id: I5d9f051ac659b06be19f5e5eaaab8a665f10832c
Reviewed-on: https://chrome-internal-review.googlesource.com/200646
Reviewed-by: Sean Paul <seanpaul@google.com>
Commit-Queue: Sean Paul <seanpaul@google.com>
Tested-by: Sean Paul <seanpaul@google.com>
Move drmModeAddFB2 and drmModeRmFB to ensure a reference to the gem
handles are taken while the buffer is in use.
Change-Id: Ib9afdb91144850480ecaac9d73601d887af5fa12
Reviewed-on: https://chrome-internal-review.googlesource.com/200686
Reviewed-by: Stéphane Marchesin <marcheu@google.com>
Commit-Queue: Stéphane Marchesin <marcheu@google.com>
Tested-by: Stéphane Marchesin <marcheu@google.com>
Fix an issue where if the same gem handle was queued twice we would
close the handle when the first one came out of the queue, leading to
a failure when calling drmModeAddFB2() on the second buffer.
Change-Id: I0bd35158215f74b51111d2e259bca3ba5125b203
Reviewed-on: https://chrome-internal-review.googlesource.com/200715
Tested-by: Allen Martin <amartin@nvidia.com>
Reviewed-by: Stéphane Marchesin <marcheu@google.com>
When using an Nvidia gralloc implementation, ask Nvidia gralloc to import the
buffer_handle_t to the hwcomposer's drm device.
Arguably, the code to perform the import would more naturally belong to
drm_hwcomposer than Nvidia gralloc. But letting Nvidia gralloc do it has two
advantages. First, drm_hwcomposer doesn't need to include vendor headers or
link against vendor libraries. This means that it's easy to support both
drm_gralloc and Nvidia gralloc from the same default build of drm_hwcomposer.
Second, Nvidia gralloc will take care of properly setting up any vendor
specific metadata (such as tiling parameters) of the imported GEM handle.
Change-Id: I0f77fb301e7e0bff2a8cd7befeae4bc4892220ad
Reviewed-on: https://chrome-internal-review.googlesource.com/195115
Reviewed-by: Stéphane Marchesin <marcheu@google.com>
Commit-Queue: Stéphane Marchesin <marcheu@google.com>
Tested-by: Stéphane Marchesin <marcheu@google.com>
Hwcomposer is responsible for closing the acquire fences passed
in during hwc_set. Make sure that it does so, even if there is
an error condition.
Change-Id: I5c9096804c2613ec317c306dd361cb5f1a2ba5b2
Signed-off-by: Lauri Peltonen <lpeltonen@nvidia.com>
Reviewed-on: https://chrome-internal-review.googlesource.com/198356
Tested-by: Stéphane Marchesin <marcheu@google.com>
Commit-Queue: Stéphane Marchesin <marcheu@google.com>
Reviewed-by: Stéphane Marchesin <marcheu@google.com>
Now that gralloc is using a render node, we can remove
this call. This allows us to run as a non-root user as
well.
Change-Id: I46c9c16c7a9a169378e567d4973172f8392d441b
Signed-off-by: Sean Paul <seanpaul@chromium.org>
We shouldn't wait for surfaceflinger to set active config, initialize
the display with a config. For now we just choose the first config in
the list. This should change to a more sane choice, such as the preferred
mode or something similar.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: Ib063080c282cec28c9b0218c0ba5151d48b367ce
surfaceflinger will send in NULL display_contents in prepare/set,
make sure we don't blow up.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: Ia5085d4bd5e5928b52d81d14d027d0a162995946
Short circuit getting the configs for connectors which are disconnected.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: Ieabbf08f4d4a6c8b03f948399113e3ad04a2d93a
Since the config indices can change out from under us, store the
actual mode instead of an index. This avoids having to
reset active_config when we get a new list from the driver.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I09a1ffbdde16c44ccc8a1d2865f09a5da22c2e26
Always do a setcrtc on the first set(), this ensures things
are set up the way we expect them to be.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I4279d4de64339e72f0e7f9b315b2b9695704c78c
Adds a new worker to handle events requested by eventControl.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I6d63bb43b5f112e2efb0c426e7fd59910fc98953
This reduces the amount of time set will block on the
worker.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: If5d110ce78e98642265ffa7dcc25710bc227330b
Instead of just using a front and back buffer, use a queue buffer
to allow more than one pending set.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I451acbcb08fac5191b76ec2e372fe612d227167c
Add the concept of an importer so we can plug in different
sources of bo.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I4f741ef4fa7c44e9cb31db61a146aed273854a69
Adds a new set thread to wait on acquire fence, flip the bo,
and wait for it to be presented on screen.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: Ia931a7cbe287f4c744068fc80e476f81880bf608
This adds a very basic hwcomposer implementation on top of
libdrm.
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I472feb9bc08a4c4cd9849370c849d266ea58da9c