Commit Graph

290 Commits

Author SHA1 Message Date
Chris Michael 2f10ce1055 ecore-drm2: Add internal functions to get backlight values
Small patch to add an internal function which can be used to retrieve
backlight values on output creation.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-06-06 10:37:01 -04:00
Derek Foreman e24670b1e2 ecore_drm2: Fix error handling in _output_dpms_atomic_set
This was skipping the error path on failure and setting some state as if
it was successful.  Then the next attempt at a page flip was actually
setting this state.

So _output_dpms_atomic_set (which has always been broken) wasn't actually
the function that successfully disabled dpms.

This is confounding attempts to debug why dpms isn't coming back on
properly.

Now it won't turn *off* either, because it really never should have.

Ref T5462
2017-06-05 16:25:14 -05:00
Derek Foreman 280c82fdd4 ecore_drm2: Don't try to disable all devices when session deactivates
We get this callback after we've lost the drm device to logind, so
deactivating stuff here will just generate a lot of ERR messages
and break our internal book-keeping.

Instead, we just turn on DPMS on session activation instead of trying
to go through the output enable path (that will bail if it's already
enabled)

This could potentially result in a display that's enabled and DPMS
off being switched back on during session activation - if that's a real
problem we can restore the previous dpms state instead...

@fix T5483
2017-06-02 15:50:09 -05:00
Derek Foreman 9d583b3fdb ecore_drm2: Fix dpms shutdown while disabling outputs
We need to set output->enabled to disabled *after* dpms takes place or set
it to enabled *before* dpms takes place.  We can't just set it at the
start of the function or one of enable/disable will hit the dpms path
with a disabled display.
2017-06-02 15:50:08 -05:00
Derek Foreman 0df7299526 ecore_drm2: Properly release buffers on output disable
Give back all buffers, and do it through the release mechanism that can
fire a callback into the engine.

Previously we just leaked one and left the rest.
2017-06-02 15:50:08 -05:00
Derek Foreman df0595ebc0 ecore_drm2: Rename _release_buffer and make it private instead of static
Other files in ecore_drm2 need to release buffers too.
2017-06-02 15:50:08 -05:00
Chris Michael dc3da87139 ecore-drm2: Don't free output plane states if not using atomic
If atomic support is not enabled (kernel or env var), then we will not
be filling output plane_states, so no need to free them (if non-atomic).

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-30 15:57:07 -04:00
Chris Michael f2a0e5ae4c ecore-drm2: Minor formatting fix
NB: No functional changes

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-30 15:56:51 -04:00
Chris Michael bd189f69f2 ecore-drm2: Don't fill device atomic state if atomic is disabled
If atomic support is disabled (via kernel or env var), then we do not
need to fill device atomic state as it will not be used anyway.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-30 11:01:22 -04:00
Chris Michael ba4042da1e ecore-drm2: Don't fill output atomic states if not using atomic
If atomic support is not enabled (kernel or env var), then we should
not be filling in output atomic state

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-30 11:00:20 -04:00
Chris Michael ac2c82b871 ecore-drm2: Remove useless return
This 'return' statement here is just useless as the code can fall
through and the function will return 0 anwyay.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-30 10:59:25 -04:00
Mike Blumenkrantz ed4e54ebe2 wayland/drm: create evas_devices and add device pointer to input events
this is still semi-broken if a seat has many pointer-ish type devices since
pointer devices in ecore-evas were never correctly implemented to be 1:1 with
seat:cursor relationships

@feature
2017-05-26 16:27:43 -04:00
Mike Blumenkrantz 737f64b822 ecore-drm2: simplify output name checking on device change
eina_streq handles null and stringshare params
2017-05-26 16:27:43 -04:00
Mike Blumenkrantz b09c6f1f3e elput: start elput_device_ and elput_seat_ namespaces, rename some functions 2017-05-26 16:27:43 -04:00
Mike Blumenkrantz e8fe0bcc47 elput/drm: redo xkb context/keymap setting
context and keymap need to be set at the same time in order to effectively
update keyboard state, and active group should be accessible through api
as well

preserve old function ABI to ensure old binaries don't crash
2017-05-26 16:27:42 -04:00
Chris Michael e0a1e63072 ecore-drm2: Don't call fb_flip until output is enabled
When calling ecore_drm2_output_enabled_set, we cannot initiate a
pageflip until the output has been enabled, so remove call to fb_flip
here. The dpms_set function will handle issueing the pageflip anyway.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-19 11:33:19 -04:00
Chris Michael 851a2c72af ecore-drm2: Cleanup output_enabled_set function code
If we are using atomic, we don't need to set the crtc active values
here as they will be set in output_dpms_set function anyway.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-19 11:32:20 -04:00
Chris Michael 7a3c658759 ecore-drm2: Fix atomic dpms setting (round 2)
As it turns out, we still need to enable/disable the output crtc when
we enable/disable dpms in order for the screen itself to turn off, so
this patch "should" finally fix atomic dpms setting.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-19 11:29:47 -04:00
Chris Michael 76806fda80 ecore-drm2: Update connector state dpms value if setting works
If we successfully set dpms via atomic state, we should also update
the connector state dpms value

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-18 12:22:27 -04:00
Chris Michael 892b58fbf2 ecore-drm2: Fix setting dpms level using atomic state
The property we need to change during an atomic dpms change is
actually from the output connector state (not crtc state). This fix
should make dpms work when using atomic

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-18 12:14:01 -04:00
Derek Foreman 12260dabb9 ecore_drm2: Better handle flip failure round 2
If the buffer being flipped to is the one already on screen then
releasing it on flip failure will leave it on scanout with no
references.  The next time a buffer is queued it will be removed
from scanout and deleted.

Not good.

Fix T5462
2017-05-17 17:31:13 -05:00
Derek Foreman 2c58d77ba9 ecore_drm2: Better handle flip failure
We need to release the buffer we couldn't flip to when a flip fails.

This makes whatever bug is causing a page flip to happen right after
dpms blanks the screen, which was leading to a failure to ever wake
from dpms because the flip left a pending buffer that never completed.

Fix T5462
2017-05-17 15:01:54 -05:00
Derek Foreman 88f328efd2 ecore_drm2: Clear next fb if we use it
Fixes a race that's either really hard to hit if you're a developer
or really easy to hit if you're a user.

Thanks to ApB for the debug assistance.

Fix T5484
2017-05-15 16:22:12 -05:00
Derek Foreman 51f5f43d43 ecore_drm2: Fix use after free
In trying to clean up some code and fix a hypothetical buffer leak, I added
a use after free error that can break rendering on the drm and gl_drm
evas engines.

Coverity did the heavy lifting for me on this one.

Fix Coverity CID 1375047
Fix T5484
2017-05-14 13:13:34 -05:00
Derek Foreman 44b57b5dfa ecore_drm2: Add some safety checks for accessing dead fbs
Accessing an fb after discarding it is bad karma, so we should log something
if it ever happens.
2017-05-12 17:51:34 -05:00
Derek Foreman edcbff59b7 ecore_drm2: refcount fbs
Removes the previous "busy" flag, as now we might have an fb attached to
multiple outputs at once, and need to be careful to destroy them only
after they've been removed from all outputs.

Removed the old "busy_set" API which nothing used, and renames fb_destroy
to fb_discard to make it more clear that it's not immediately destroyed.

It's all beta api, so I can do this.
2017-05-12 17:51:34 -05:00
Chris Michael af587c01cb ecore-drm2: Add start of refcounting for FB objects
Small patch which starts to implement refcounting on framebuffer
objects. This will be needed so that we do not free FB objects while
they are on the screen.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-09 11:47:04 -04:00
Derek Foreman 544cffaa19 ecore_drm2: Move test for atomic_req into atomic flip path
We ended up doing an occasional atomic ioctl when we shouldn't.
This should be a harmless failure, but it's also a pointless one.
2017-05-09 10:34:33 -05:00
Derek Foreman 8067b0146a ecore_drm2: Fix dmabuf fb destroy
I missed the fact that it'd run through the existing non-gbm path on
destroy, resulting in a (probably harmless) bad ioctl
2017-05-09 10:34:33 -05:00
Derek Foreman 18af247ab2 ecore_drm2: Add checks for using a plane after death
We keep planes on the plane list to ensure a released plane is removed
from display - however this means that if a caller starts messing with
a plane after release, that it could potentially reposition a plane it
doesn't own anymore.

Use EINA_SAFETY macros to prevent this.
2017-05-05 12:53:25 -05:00
Derek Foreman c722466a60 ecore_drm2: Replace plane state release flag with plane dead flag
The release flag is actually less useful than the existing in_use flag
for determining if a plane is unused.  If a new plane is assigned before
the next flip cleans up released planes, then it can point to a released
plane state, and both it and the previous user will be freed on the next
commit, leaking a plane.

Putting the flag in the plane structure fixes this while still allowing us
to keep released planes around to ensure a recently released plane is
cleared from atomic state.
2017-05-05 12:53:25 -05:00
Derek Foreman 1071c9f3a8 ecore_drm2: Call flip test in plane release
If we don't do a flip test, the atomic state isn't updated.  This fixes
a potential problem where the last operation in state preparation is
a release - the following commit wouldn't include state from the release.
2017-05-05 12:53:25 -05:00
Derek Foreman 7628977fbf ecore_drm2: Fix flip test error handling
We need to free the atomic req if commit fails, so let's merge these
failure paths and simplify code a bit.
2017-05-05 12:53:25 -05:00
Derek Foreman 699ed066ea ecore_drm2: Require x and y value in plane assign
Saves us a flip test, and gaurantees that we're always testing with a
reasonable x, y and not something leftover from a previous assignment.
2017-05-05 12:53:25 -05:00
Chris Michael 1d3ad70888 ecore-drm2: Release any marked planes during atomic commit
This patch fixes plane_state values during atomic flip test for any
planes marked for release. When the fb_flip actually completes, we
will remove the marked plane(s) from the output.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:24 -05:00
Chris Michael 0c0f525d9a ecore-drm2: Add 'release' flag for planes
As we cannot immediately remove a plane from an output, due to needing
an atomic commit to actually remove the plane from screen, we can use
a 'release' flag to indicate that a given plane needs removal from the
screen during our next atomic commit.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:24 -05:00
Chris Michael bd4ccfa0f5 ecore-drm2: Don't remove plane from output list on release
As we need to be able to commit a new plane state for any released
planes, we should not be removing them from the output list just yet.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:24 -05:00
Chris Michael 7a50010536 ecore-drm2: Fix formatting
NB: No functional changes

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:24 -05:00
Chris Michael 373e4b0684 ecore-drm2: Don't assign plane to output list if test fails
There is little point in assigning a plane to the output list if the
atomic flip test fails.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:24 -05:00
Derek Foreman 0aac2db93a ecore_drm2: Use stricter cursor plane size check
Unfortunately the plane sized returned from the cursor plane query isn't
a limit, it's an exact size.  Sometimes you can use a different size,
but that's completely hardware dependent - so stick to the advertised
size.
2017-05-05 12:53:24 -05:00
Derek Foreman ab8ec5ed5f ecore_drm2: Add API to update the fb for a plane 2017-05-05 12:53:23 -05:00
Derek Foreman c98a9b06c6 ecore_drm2: Rebuild atomic state from plane_destination_set
Call a test commit to rebuild the atomic_req
2017-05-05 12:53:23 -05:00
Derek Foreman 6b9a6a8bed ecore_drm2: Fix atomic flip with no new buffer
We don't have an atomic state, so we need to create one before the flip
2017-05-05 12:53:23 -05:00
Derek Foreman 9223b0d535 ecore_drm2: Pass user data to atomic flip
We need the user_data to come back to us in the flip handler like it does
in the non atomic flip.
2017-05-05 12:53:23 -05:00
Derek Foreman b6f67124e4 ecore_drm2: Add some atomic state tracking
I think we're now at the point where the two paths are merged.

Still no atomic functionality because nothing assigned the primary plane,
so we have no atomic state to commit.  The machinery should be in place
though.
2017-05-05 12:53:23 -05:00
Derek Foreman ba4d41ff63 ecore_drm2: Handle atomic state in _release_buffer
Further merging of atomic and non-atomic paths
2017-05-05 12:53:23 -05:00
Derek Foreman b902ef7c69 ecore_drm2: Make _release_buffer take a state struct instead of fb
Lets us push the NULL set into _release_buffer for some clean up
2017-05-05 12:53:23 -05:00
Derek Foreman 89630ddeb1 ecore_drm2: Refactor common code from non-atomic path
We'll need to perform all this for atomic operations as well.
2017-05-05 12:53:23 -05:00
Derek Foreman 8d72a2cf46 ecore_drm2: Fix typo in comment 2017-05-05 12:53:23 -05:00
Derek Foreman e7a494ba87 ecore_drm2: treat atomic flip without a req as an error
We should use the safety macro here instead of silently continuing so we
can get something in the log if this happens.
2017-05-05 12:53:22 -05:00
Derek Foreman 9da0f52642 ecore_drm2: remove fb parameter from _fb_flip()
Time to start smashing the atomic and non-atomic paths together.
2017-05-05 12:53:22 -05:00
Derek Foreman 8143abff2c ecore_drm2: Replace output fbs with state structs
next, pending, and current are going to have to deal with atomic state
instead of just fbs soon
2017-05-05 12:53:22 -05:00
Derek Foreman 63dbf061a9 ecore_drm2: Move atomic state into an output state struct
This should make it easier to share code paths between atomic and non
atomic operations.
2017-05-05 12:53:22 -05:00
Derek Foreman 6482367aa2 ecore_drm2: Perform test flip during plane assignment
Make sure we can commit that plane at assign time so when we hook up to
the scene graph it knows when it can safely use a plane.
2017-05-05 12:53:22 -05:00
Derek Foreman 8d42d7d50a ecore_drm2: Drop static from _fb_atomic_flip_test()
We're going to need this one in plane assign to test commits
2017-05-05 12:53:22 -05:00
Derek Foreman f1d779da06 ecore_drm2: remove flip test from commit path
We'll be doing tests as we build up plane state assignment.  it's too late
to do anything about it if we fail here - failed tests will block plane
assignment in the first place so the scene graph knows it still has to
render those visual elements.
2017-05-05 12:53:22 -05:00
Derek Foreman ba2275b7ec ecore_drm2: Add ecore_drm2_plane_release to release planes
Opposite of plane assign.
2017-05-05 12:53:22 -05:00
Derek Foreman 014e84d8fa ecore_drm2: Store output in plane structure
This will simplify a bunch of API that would otherwise have to pass in
both output and plane - and in some cases we might not have the output
handy anyway.
2017-05-05 12:53:21 -05:00
Derek Foreman aae1c50dd3 ecore_drm2: Remove next, current, pending from plane state
These will be output state eventually
2017-05-05 12:53:21 -05:00
Derek Foreman 308a11cfd6 ecore_drm2: Assign planes in ecore_drm2_plane_assign
Don't just test, allocate the resource, and then prevent further
assignments from trying to use it as well.
2017-05-05 12:53:21 -05:00
Derek Foreman 7dd8d6d163 ecore_drm2: Don't use drmModeAtomicMerge
We're creating the entire state from scratch already - trying to merge
with the old state will likely bring in state we just tried to replace.
2017-05-05 12:53:21 -05:00
Derek Foreman eb305727d0 ecore_drm2: Remove extra #ifdef
It's the same as the previous one, so combine them.
2017-05-05 12:53:21 -05:00
Derek Foreman 63bc30dd5b ecore_drm2: Fix typo in error message
Stop printing "commit test failed" from non-test commits.
2017-05-05 12:53:21 -05:00
Derek Foreman 950df19c67 ecore_drm2: Add an env var to disable atomic pageflips
Allows testing non-atomic paths without a reboot or a rebuild.
2017-05-05 12:53:21 -05:00
Chris Michael 0595e70b22 ecore-drm2: Do atomic commits per-output
In cases where output monitors have different frequencies, we need to
be doing atomic commits on a per-output basis. This patch modifies the
ecore_drm2_fb_flip function to support doing atomic commits per output.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:21 -05:00
Chris Michael 2ba64a4c0a ecore-drm2: Free output atomic request on destruction
When we free an output, make sure we cleanup any existing atomic
commit requests

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Chris Michael 03cb02fa74 ecore-drm2: Remove newly added atomic API functions
As we need to do atomic commits on a per-output basis, these 2 newly
added API functions can go because these functions did one atomic
commit for all outputs

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Chris Michael e5de325e90 ecore-drm2: Remove #ifdef for HAVE_ATOMIC in plane_assign function
As there is nothing inside this function which requires any Atomic API
calls, this #ifdef can be removed and the function can then still be
used to assign Primary planes for non-atomic use cases.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Chris Michael b9f4641762 ecore-drm2: Minor formatting fix
NB: No functional changes

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Chris Michael 86bd42884a ecore-drm2: Fill output states regardless if atomic
This commit fills in various output 'state' structures during creation
so that those state structures can be reused for pageflip handling
even if Atomic support is not enabled.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Chris Michael f07f2e6e4e ecore-drm2: Enable filling state structures without atomic support
This commit enables the ability to fill our state structures even if
atomic support is not enabled. This will allow us to reuse those state
structures for dealing with pageflip in both the atomic & non-atomic
use cases.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Chris Michael e1b26f6320 ecore-drm2: Enable reuse of existing state structures for non-atomic
As there is nothing 'atomic' specific in these structures, we can move
them outside the atomic ifdef and make use of them for handling
pageflip for both atomic and non-atomic use cases.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Chris Michael eb1ed0fc0a ecore-drm2: Minor formatting fix
NB: No functional changes

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-05-05 12:53:20 -05:00
Derek Foreman 05e8d76021 ecore_drm2: Fix ticking when atomic mode set is enabled
Putting the PAGE_FLIP_EVENT flag on the set rotation request resulted
in an extra event on the drm device fd that screwed up page flipping
badly from that point on.

@fix
2017-04-21 16:39:19 -05:00
Chris Michael c4b22eb59c ecore-drm2: Iterate plane formats properly
This patch addresses an issue where plane formats were not being
properly copied into our Plane State structure and causing any usage
of our atomic code paths to crash and burn

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-19 14:58:11 -04:00
Chris Michael e2a6ee29f0 ecore-drm2: Add fields to plane structure for current, next, pending
FBOs

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael d3d9ab2296 ecore-drm2: Free any previous atomic request
If we fail the atomic request merge, cleanup any previous request and
just use the new one.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 345fefd3ef ecore-drm2: Add API functions for atomic commit test and commit
This patch adds 2 new API functions, one which we can use to test atomic
commits before actually applying them, and another which does the
actual Atomic commit.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 9d5c76e0d5 ecore-drm2: Add library symlink to merge atomic commit requests
Small commit to symlink to drmModeAtomicMerge function so we can use
that for atomic commit tests.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 9e07d37320 ecore-drm2: Add API function to set plane destination
When we do an atomic commit, we need to know where to place a given
plane (in the case of overlays) in relation to the CRTC, so provide an
API function that can be used for that purpose.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 44d5c855e0 ecore-drm2: Store plane src values on assign
As we will need the plane state source values when we do an atomic
commit, we can store them when plane_assign is called as we already
have the FBO available.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 19da4706f3 ecore-drm2: Add hardware plane functions
This patch adds a new file where we can store any additional functions
we may need to work with hardware planes. Currently the file contains
a public function that can be used to assign a given Ecore_Drm2_Fb to
a hardware plane

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael f1525ecf35 ecore-drm2: Cleanup list of output planes on output_destroy
Small patch to make sure we free memory previously allocated for
hardware planes when we destroy an output

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 9dbf54e2f6 ecore-drm2: Move defines for CAP_CURSOR sizes to private header
As we may need these defines in other files, move them to the private
header so there is access to them.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 205c829a11 ecore-drm2: Store cursor size on device
As we will need these values later to determine if an FBO can go onto
the cursor plane, we should store this in the device structure to
avoid having to refetch them later.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 980ed70eb9 ecore-drm2: Support multiple planes on a given output
Various hardware can support multiple planes on a given output. As
such, we need to be able to store multiple plane states per-output.
This small patch adds support for that.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 4f8f41299f ecore-drm2: Add support for plane formats
Small patch to store supported formats on a given plane state. This
will be used for assigning dmabuf clients to a hardware plane based on
size and supported format.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 0a647f9fce ecore-drm2: Remove old atomic flipping code
As we are refactoring the usage of hardware planes and atomic commits,
we need to remove the old usage of atomic flipping for ecore_drm2_fb
because atomic flipping will be handled differently.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 43104a7268 ecore-drm2: Add opaque structure to represent a hardware plane
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Chris Michael 554883c048 ecore-drm2: Disable driver whitelist tests
While having the ability to test for specific driver and kernel
versions is nice to ensure that Atomic is supported, it quickly can
get out of hand trying to maintain this whitelist so (for now) disable
it and rely on the kernel results from drmSetCap.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-04-18 07:55:10 -04:00
Derek Foreman 61f40d58f7 ecore_drm2: Add ecore_drm2_fb_dmabuf_import
Imports a set of dmabuf buffers as a single Ecore_Drm2_Fb
2017-04-18 07:55:10 -04:00
Derek Foreman f0fc86516d ecore_drm2: store 4 handles, strides, and planes
We're going to support multi-planar formats soon.

It'll be great, you'll love it.
2017-04-18 07:55:10 -04:00
Derek Foreman 45e173d186 ecore_drm2: Use library function instead of ioctl for addfb2
Minor clean up.
2017-04-18 07:55:10 -04:00
Derek Foreman e5dd8327ba ecore_drm2: Use correct drm context version
We should be setting this to the context version we understand, not
the highest version supported by the library.

From Daniel Stone's recent intel-gpu-tools commit fixing the same bug:
With libdrm 2.4.78, setting a higher context version than 2 will attempt
to call the page_flip_handler2 vfunc if it was non-NULL, which being a
random chunk of stack memory, it might well have been.
2017-04-07 09:09:56 -05:00
Chris Michael 1a3bae8133 ecore-drm2: Remove unused field in Output structure
The 'planes' field in Ecore_Drm2_Output structure is unused and can
thus be removed here.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-03-24 08:54:52 -04:00
Derek Foreman ae5d002466 ecore_drm2: ERR once when page flip fails with EBUSY
On systems where this happens it'll probably happen a lot, so
we don't want to continuously log this, but since it's definitely
showing a bug somewhere (efl or kernel) it probably should be an ERR.
2017-02-15 09:53:43 -06:00
Chris Michael 0001240120 ecore-drm2: Fix debug messages to use proper type
Small patch which fixes some FB flipping messages to use the proper
type (ie: some messages were ERR when should be DBG or WRN, etc).

NB: No functional changes

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-02-13 09:45:20 -05:00
Chris Michael c126ce2e70 ecore-drm2: Add API function to set output rotation
This patch adds a new API function that can be called from
Enlightenment wl_drm module to enable output rotation.

NB: Only works if Atomic support is enabled as it rotates the hardware
plane directly...and we don't support planes without Atomic enabled.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-01-18 11:29:14 -05:00
Chris Michael ca194584d5 ecore-drm2: Add API function to return supported rotations of an output
Small patch to add an API function which can be used to return the
supported rotations of a given output. This is used inside the
Enlightenment wl_drm module to determine if rotations is supported on
an output.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-01-18 10:38:01 -05:00
Chris Michael f32268ad1b ecore-drm2: Expose Ecore_Drm2_Rotation enum
As we will need these values when doing rotation checks inside wl_drm
module (for randr rotation support), let's move them out of the
private header and expose them in Ecore_Drm2.h

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-01-18 10:06:20 -05:00
Chris Michael 7c829d1669 ecore-drm2: Minor formatting fix
NB: No functional changes, just formatting

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-01-18 10:05:13 -05:00
Chris Michael 639ad420aa ecore-drm2: Add API to determine if a device prefers shadow buffers
Small patch to add a new API function that can be called to determine
if a given drm device prefers the use of shadow buffers. This API
will be used later to provide some optimizations on various platforms.

NB: Requested by Derek

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2017-01-18 09:48:01 -05:00
Carsten Haitzler 46a1bc2d22 ecore_drm2 - work with broken kernels that EBUSY on drm page flip
so thelatest rpi kernels available e.g. in raspbian contain no fixes
for this yet so thatmeans basically ALL users would be affected, so
best to have a small workaround in ecore_drm2 to try the page flip a
few times until it works. this actually works. i try a usleep for 100
then try again. up to 500 times max then give up. actual numbers show
that betwee 1 to about 60 tries gets the flip to happen when these
glitches happen. log an error when this happens so we know it's
happening and a workaround is kicking in.

technically this would be much nicer if swapping had a dedicated
thread that could stall in this case and keep trying, but the odd
times it happens (seems to happen on average maybe once every 30
seconds) it wouldnt stall the mainloop or rendering and JUSt stall a
dedicated swapper thread. this requires a lot mor work to implement
though and we'd have to then ensure swaps ARe async with the swap
result coming back as an event etc... so a lot more work.

this at least makes rendering on the rpi stable and i can dig into
other issues like libproxy throws exceptions and causes a whole
process abort() as a result, or the latest mesa pkgs have totally
broken partial gl rnedering with all non-rendered areas being black
(it used to work though... until i updated).

@fix
2017-01-07 13:23:02 +09:00
Derek Foreman 515362efe2 ecore_drm2: Make ecore_drm2_fb_release return status
We need to use this to free up gbm buffers on a surface release, so it
has to report when it successfully frees a buffer.
2016-12-07 11:30:03 -06:00
Chris Michael 6b350fc696 ecore-drm2: Add API function to allow setting gamma of a given output
Small patch to add an API function which will allow setting the gamma
level of a given output.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-29 09:15:07 -05:00
Chris Michael 4b4201584f ecore-drm2: Add symlink to gamma setting function
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-29 09:14:31 -05:00
Chris Michael e0b61a35c5 ecore-drm2: Add API function to return screen dpi
This patch adds a new API function which will be called from
Ecore_Evas to return the screen dpi

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-28 10:09:41 -05:00
Derek Foreman aa3479570d ecore_drm2: Add a panic mode to drm2_fb_release
Previously we'd call this only when we absolutely needed to, so it made
sense to always attempt to free a buffer, including ones on scanout or
pending flip.

However, it's useful to have a way to release the "next" only, so we can
do that before starting a render to free up the buffer that's never going
to be scanned out.
2016-11-18 09:41:52 -06:00
Derek Foreman 168a127c8c ecore_drm2: Make sure something's on screen after dpms wake
Flip to the previous buffer on dpms wake to make sure we show something
2016-11-16 15:05:40 -06:00
Chris Michael cd0c1d9857 ecore-drm2: Symlink to drmModePageFlip function
Somehow this got missed in initial commit, so fix to symlink to
drmModePageFlip function.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-15 11:44:12 -05:00
Chris Michael f5a5a9df44 ecore-drm2: Remove unused structure
As we don't ever use drmVersionBroken structure in this code, remove it

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-15 09:14:50 -05:00
Chris Michael 491c059620 ecore-drm2: Add copyright information from included headers
Small patch to reorganize defines & structures from included files,
and to add copyright information related to each file where defines &
structures were borrowed from.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-15 09:12:53 -05:00
Chris Michael fbc58c3424 ecore-drm2: Add API function for drmHandleEvent
As we are not compile-time linking to libdrm anymore, Ecore_Evas_Drm
needs to be able to call drmHandleEvent, so add an API function to
Ecore_Drm2 that can be used there.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-15 08:42:07 -05:00
Chris Michael 8421a37313 ecore-drm2: Make calls to symlink'd libdrm functions
Instead of linking to libdrm and calling drmMode functions, we will
instead symlink the functions we need during runtime and call those
symlinks.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-15 08:42:07 -05:00
Chris Michael 0a2c06fc58 ecore-drm2: Symlink to libdrm functions during init time
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-15 08:42:07 -05:00
Chris Michael b820ad3676 ecore-drm2: Add structure definitions and function symlinks for libdrm
As we are moving away from linking to libdrm during compile time, and
instead dlsym to things we need at runtime, we need to include copies
of the libdrm structures that we will be using along with function
declarations that we symlink to.

@feature

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-11-15 08:42:07 -05:00
Derek Foreman 8368f6e1d2 ecore_drm2: Follow direct crtc sets with a page flip
Now that the bugs generating extra ticks are fixed, we need to make sure
we can actually generate one here.
2016-11-14 16:39:03 -06:00
Chris Michael aba152a8be ecore-drm2: Free Output modes on destroy
When we destroy outputs, we should be freeing the Output's Modes also
as that was previously allocated memory.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-10-11 11:30:49 -04:00
Chris Michael fb112b8fab ecore-drm2: Use Atomic Modesetting for resolution changes
Since we have atomic properties now, we can use those to set given
Output modes (resolutions).

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-10-11 11:30:49 -04:00
Chris Michael bcf311ae3c ecore-drm2: Use Atomic State to enable/disable an output
If Atomic Modesetting is supported, we can use that to enable/disable
a given output.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-23 08:53:32 -04:00
Chris Michael 1abed3dcaf ecore-drm2: Remove useless if check for atomic_modeset flag
As we always set this flag in the drm2_fb_flip function, having this
check here is now pointless.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-23 08:51:35 -04:00
Derek Foreman af82abb57a drm: Fix typoe
DRM_MODE_ATOMIC_ALLOW_MODSET should have been _MODESET
2016-09-22 14:52:14 -05:00
Derek Foreman de5305e224 ecore-drm2: Merge initial modesetting with atomic flip code 2016-09-22 14:24:56 -04:00
Chris Michael 84cb88fe8c ecore-drm2: Use just DRM_MODE_ATOMIC_ALLOW_MODESET for initial setting
of mode

This fixes an issue where gl_drm engine would end up flickering
everytime a frame was being set.

Thanks derek ;)

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 3c243c3ebb ecore-drm2: Add support for Atomic Pageflips
This patch modifies our ecore_drm2_fb_flip code to use Atomic/Nuclear
pageflips.

NB: Works perfectly under software drm engine .. some flickering with the
gl_drm engine that needs investigating.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael bfff91bac5 ecore-drm2: Add code to support setting DPMS levels via Atomic
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael a262629282 ecore-drm2: Add code to use Atomic for Edid if available
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 2bda227304 ecore-drm2: Add code to setup Plane Atomic state for Outputs
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael a76eae227a ecore-drm2: Add code to setup Connector Atomic state for Outputs
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 3ca7e72bce ecore-drm2: Add code to setup Crtc Atomic state for Outputs
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael ecc000d84c ecore-drm2: Add code to free Atomic state on shutdown
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael f8e28f37dc ecore-drm2: Add code to fill Plane Atomic state
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 91739d10b0 ecore-drm2: Add code to fill Connector Atomic state
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 7041202a0a ecore-drm2: Add code to fill Atomic Crtc State
This patch adds code to enable Atomic Modesetting support (via ioctl)
and to fill in Atomic Crtc state during startup.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 541be05bf2 ecore-drm2: Add code to check if Atomic Modesettting is usable
This code will detect the drm driver name and check that the kernel
itself is new enough to use Atomic Modesetting. This is needed as some
drivers (i915) do not handle Atomic Modesetting propertly without a
new enough kernel.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 7770bc17bb ecore-drm2: Add private structures to support Atomic Modesetting
Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-22 14:20:24 -04:00
Chris Michael 45ce4c8008 ecore-drm2: Rename output_fb_release to just fb_release
As this function releases FBOs on a given output, lets just shorten
the API function name so it can stay grouped into the ecore_drm2_fb.c
file ... leaving it as ecore_drm2_output_fb_release reads like it
should have gone into the ecore_drm2_output.c file...

NB: No real function changes here, just an API rename.

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-09 15:10:47 -04:00
Chris Michael 50aa37790f ecore-drm2: Add missing EINA_SAFETY checks for public facing API
functions

Signed-off-by: Chris Michael <cp.michael@samsung.com>
2016-09-09 15:05:00 -04:00
Derek Foreman 21ad56aa32 ecore_drm2: Add ecore_drm2_output_fb_release way to force buffer release
Adds an api to attempt to release an fb from an output.  This will try
to first free any queued but not display buffers, which may harmlessly
give us a render target.

However, if that fails it will try to get buffers that have been sent to
scanout, which can lead to tearing.
2016-09-09 13:39:05 -05:00
Derek Foreman 30d14779a6 ecore_drm2: Add release handlers for buffers
Allow the engine to register a callback for buffer release.  This lets us
do appropriate buffer bookkeeping (for example, gbm locking) in the
engine.
2016-09-09 13:39:05 -05:00
Derek Foreman 0722eae960 ecore_drm2: Store gbm_bo for Fbs and add a getter function for it
This will aid with proper locking in gl_drm later
2016-09-09 13:39:05 -05:00
Derek Foreman 255b990055 ecore_drm2: Remove get/set for next fb
We no longer needs these at all.
2016-09-08 13:55:25 -05:00
Derek Foreman cc29a25c47 ecore_drm2: simplify API to get latest FB
What we've always wanted when getting the "current" FB is to get
the most recently submit one - this may be current, next, or pending.

Replace ecore_drm2_output_current_fb_get() with a function that gets the
most recent one - ecore_drm2_output_latest_fb_get().  Now callers don't
have to check the next buffer themselves first, and we don't have to
add an API for pending.
2016-09-08 13:55:25 -05:00
Derek Foreman b4cbf860b9 ecore_drm2: Add a page flip completion call
Add a function for ecore_evas_drm to call after a page flip happens so
ecore_drm2 can track busy status for fbs itself (including for the fb
that's currently being flipped to scanout)

Also, call the completion function from ecore_evas_drm
2016-09-08 13:55:24 -05:00
Derek Foreman 33043ff1eb ecore_drm2: distinguish real flip failure from flip deferral
If we try to flip too soon we get EBUSY and should queue up the buffer
for later presentation.  Only the other errors need to be dealt with
elsewhere.
2016-09-08 13:55:24 -05:00
Derek Foreman 3be2630a30 ecore_drm2: make flip to NULL buffer mean something
When triple buffering we'll have a buffer in ecore_drm2's "next" position.
Until now we've had to query it from the engine then try to re post it.

Also, when generating ticks we need to flip to the current buffer when no
changes have been made to get another callback.

Now a NULL fb to fb_flip will either flip to next, if available, or current
if there's nothing new to flip to.
2016-09-08 13:55:24 -05:00
Derek Foreman ce7991b993 ecore_drm2: Implicitly set buffer busy status when flipping
This simplifies other code that shouldn't need to deal with this.
2016-09-08 13:55:23 -05:00
Derek Foreman 3d39c1e9b8 ecore_drm2: Add a function to set the pageflip callback data once
Instead of passing the user data for the page flip callback every time,
set it just once.

This will make it easier to push tick logic into ecore_evas_drm, as there
will be a transitional period where page flips are driven in two places
that don't have access to the same pointers.
2016-09-08 13:55:23 -05:00
Derek Foreman d8c9f8ef17 ecore_drm2: Add busy status to ecore_drm2_fb
We've been tracking this in the outbuf code, but that logic is going to
be moved into ecore_evas_drm to use the new ticking paradigm.
2016-09-08 13:55:23 -05:00
Derek Foreman 871a9cff03 ecore_drm2: Fix a condition where no outputs are enabled
If the first output we test is disconnected but has the crtc of
the primary display assigned then we'll fail to assign the crtc
to the connector it's really connected to later.

This is a quick hack as trying to sort this out properly may be
too invasive for the upcoming 1.18 and isn't really important until
1.19 supports multihead anyway.
2016-08-02 13:29:09 -05:00