Commit Graph

6043 Commits

Author SHA1 Message Date
Pekka Paalanen d72bad2f53 libweston: unexport weston_output_update_matrix()
Only used internally in core. Needs to happen automatically when
something changes, so there should no need to call it from outside.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-07-25 16:08:41 +03:00
Pekka Paalanen f9681b564d libweston: unexport weston_compositor_add_output()
Only used by weston_output_enable().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-07-25 16:08:41 +03:00
Pekka Paalanen ee16ea95bc libweston: two more weston_output docs
Document two more functions of the weston_output API.

Exported functions marked internal are meant for backends only.
Exported functions not marked internal are meant for libweston users.

v2: talk about "list of enabled outputs".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-07-25 16:08:41 +03:00
Pekka Paalanen f0ca79639e libweston: let add/remove_output handle the lists
A weston_output available to the compositor should always be either in
the list of pending outputs or the list of enabled outputs. Let
weston_compositor_add_output() and weston_compositor_remove_output()
handle the moves between the lists.

This way weston_output_enable() does not need to remove and
oops-it-failed-add-it-back. weston_output_disable() does not need to
manually re-add the output back to the pending list.

To make everything nicely symmetric and fix any unbalancing caused by
this:
- weston_output_destroy() explicitly wl_list_remove()s
- weston_compositor_add_pending_output() first removes then inserts, as
we have the assumption that the link is always valid, even if empty.

Update the documentations, too.

v2:
- talk about "list of enabled outputs"
- keep wl_list_remove in weston_compositor_remove_output in its old
  place

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-07-25 16:08:34 +03:00
Pekka Paalanen bccda71c78 libweston: use helper var in weston_compositor_remove_output
To shorten lines.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-07-25 16:08:34 +03:00
Pekka Paalanen e6ac4fcbc9 libweston: untangle weston_compositor_remove_output doc
Trying to make it more readable. Things that happen in the same step are
kept in the same paragraph.

v2: talk about "list of enabled outputs"

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-07-25 16:08:16 +03:00
Michael Teyfel d2535d7614 ivi-shell: Fixed broken link to wiki page in ivi-layout header file
Signed-off-by: Michael Teyfel <mteyfel@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-07-25 13:41:52 +03:00
Ucan, Emre (ADITG/SW1) 57ac260c5d ivi-shell: remove orientation calculation
Dead code as orientation cannot be changed anymore, see patches:
ivi-shell: remove layer_set_orientation API
ivi-shell: remove surface_set_orientation API

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
[Pekka: added commit message]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-07-24 13:33:05 +03:00
Ucan, Emre (ADITG/SW1) 6e423ed996 ivi-shell: remove layer_set_orientation API
This API is used to rotate the contents of
application's buffer, which are in the render
order list of the layer. But this API is not
needed because an application can rotate
its buffers with set_buffer_transform request
of wl_surface interface

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-07-24 13:33:00 +03:00
Ucan, Emre (ADITG/SW1) 9337197f82 ivi-shell: remove surface_set_orientation API
This API is used to rotate the contents of
application's buffer. But it is not needed
because an application can rotate its buffers
with set_buffer_transform request of
wl_surface interface.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-07-24 13:32:48 +03:00
Ucan, Emre (ADITG/SW1) deee858b0b ivi-shell: add_screen_remove_layer API
It is analagous to layer_remove_surface API.
The API removes a layer from the render order
of the screen.

v3:
add the new vfunc at the end of
the ivi_layout_interface struct.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Eugen Friedrich <friedrix@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-07-24 13:13:37 +03:00
Ilia Bozhinov 3e5303daf4
xwm: update override-redirect surface's position upon configure_notify
When we receive configure_notify we should update the surface's
position by calling xwayland_api->set_xwayland(). Otherwise some surfaces
like dnd surfaces from xwayland views are "stuck" at one place. When
setting XWAYLAND state though we should always call view_set_position(),
not just the first time we set this state.

Signed-off-by: Ilia Bozhinov <ammen99@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-07-21 17:38:01 +02:00
Quentin Glidic 749637a8a3
libweston-desktop/xdg-shell: Properly handle ack_configure
Now we keep track of serial->state association and we discard the states
that the client ignored.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2017-07-20 10:51:15 +02:00
Quentin Glidic ac394a10bc
libweston-desktop/xdg-shell: Check surface size against acknowledged size
We were checking against the pending size, which lead some clients
(simple-egl) to crash because they sent a buffer before acknowledging
the latest configure event.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2017-07-18 13:12:30 +02:00
Quentin Glidic 19d1f6effe
libweston-desktop/xdg-shell: Add pending/next/current structs
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
2017-07-12 11:28:13 +02:00
Quentin Glidic 218126d992
libweston-desktop/xdg-shell: Rename requested_ to pending_
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
2017-07-12 11:28:08 +02:00
Bryce Harrington 1170c66305 configure.ac: bump to version 2.99.91 for the alpha release 2017-07-11 19:16:40 -07:00
Derek Foreman 65d3464ec6 configure: Stop printing libxkbcommon in configure results
Cosmetic leftovers I missed when removing the configure
option to --disable-xkbcommon

Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-07-03 14:36:50 -05:00
Derek Foreman bbc206e948 dmabuf: Don't crash clients by sending version inappropriate events
We need to make sure the client bound dmabuf with a high enough
version to receive modifier events before sending them or the
client will crash.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-07-03 16:42:06 +01:00
Derek Foreman cd052a6214 linux-dmabuf: Fix crash with no valid modifiers
We shouldn't free &modifier_invalid because it wasn't allocated
with malloc()

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-07-03 16:41:57 +01:00
Derek Foreman 12968e3756 gl-renderer: Fix some missing newlines in log messages
Some log messages weren't terminated with a newline.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-07-03 16:41:46 +01:00
Derek Foreman 185d1585eb input: Remove --disable-xkbcommon
It looks like there are some code paths where this has been forgotten, so
it likely doesn't work as is.  It's probable that nobody has actually
used this in a very long time, so it's not worth the maintenance burden
of keeping xkbcommon vs raw keyboard code anymore.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-07-03 16:41:38 +01:00
Quentin Glidic d51f826c0b
libweston-desktop/xdg-shell: Consolidate configure event sending
When switching a state twice in a row, we were overwriting the old value
without setting it back, sending a wrong state to the client.

Now we update our requested state, then check if we need to schedule a
configure event, if we have one scheduled already or even if we can
cancel it.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-26 00:20:11 +02:00
Quentin Glidic c84423baea
libweston-desktop/xdg_shell_v6: Send error on wrongly-sized buffer
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-26 00:08:11 +02:00
Varad Gautam ee58911912 clients/simple-dmabuf-drm: import with dmabuf modifiers
mesa's freedreno driver supports importing dmabufs with format
DRM_FORMAT_NV12 and DRM_FORMAT_MOD_SAMSUNG_64_32_TILE modifier.
demonstrate weston modifier advertising and import path using this
combination when run with --import-format=NV12.

v2:
 - hard code format if platform doesn't implement
   EGL_EXT_image_dma_buf_import_modifiers and cannot advertise
   format/modifier support.
 - squash using valid frame data to fill dmabuf planes

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:39:01 +01:00
Varad Gautam f7b3a39625 clients/simple-dmabuf-drm: add freedreno support alongside intel
abstract drm specific bits to struct drm_device and support running on
freedreno. introduce 'modifier' event.

v2: rebase to master, deprecate 'format' event.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:38:03 +01:00
Varad Gautam f9dec67990 clients/simple-dmabuf-intel: rename to simple-dmabuf-drm
this will allow adding other drm backends later.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:37:38 +01:00
Varad Gautam c32e05bbf3 gl-renderer: allow importing fourth dmabuf plane
EGL_EXT_image_dma_buf_import_modifiers supports importing upto four dmabuf
planes into an EGLImage.

v2: correct PLANE3_PITCH token (Daniel Stone)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:37:15 +01:00
Varad Gautam f7da8b3139 gl-renderer: allow importing dmabufs with format modifiers
pass over the modifier attributes to EGL.

v2: ensure same modifier is passed for all planes (Daniel Stone)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:36:44 +01:00
Varad Gautam 41b4b8f492 linux-dmabuf: advertise supported formats and modifiers
implement 'modifier' event to communicate available formats and modifiers
to the client and support zwp_linux_dmabuf_v1 interface version 3.

v2: handle zero modifiers case, deprecate 'format' event.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:36:31 +01:00
Varad Gautam 0775cd116f gl-renderer: support format and modifier queries
EGL_EXT_image_dma_buf_import_modifiers allows querying the formats
and modifiers supported by the platform. expose these to the compositor.

v2:
 - change calloc args (Daniel Stone)
 - check for modifier support before querying formats (Daniel Stone)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:35:55 +01:00
Varad Gautam 48be0be7a3 clients/simple-dmabuf-intel: request no-roundtrip dmabuf import
request immediate dmabuf import when run with "immed" arg.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:35:39 +01:00
Varad Gautam 65c94b8804 linux-dmabuf: implement immediate dmabuf import
handle create_immed() dmabuf import requests and support
zwp_linux_dmabuf_v1_interface version 2.

v2: terminate client with INVALID_WL_BUFFER when reason
    for create_immed failure is unknown.

[daniels: Bump wayland-protocols dependency.]

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12 10:32:46 +01:00
Oliver Smith a5066e00e8
compositor-fbdev: Instead of less than 1 Hz use default refresh rate
I ran Weston on a Nexus 4 mobile phone, with a native GNU/Linux userland,
and the latest Android kernel for that device from LineageOS [1].

calculate_refresh_rate() returned 1 (mHz), which gets rounded to 0 Hz later
and results in nothing being drawn to the screen.

This patch makes sure, that there is at least a refresh rate of 1 Hz, because
it returns the default refresh rate of 60 Hz otherwise.

[1]: https://github.com/LineageOS/lge-kernel-mako

Signed-off-by: Oliver Smith <ollieparanoid@bitmessage.ch>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-05-23 11:30:27 +02:00
Lyude Paul 47bbdc7296
weston: Add support for "--foo bar" style options
A little earlier today I ended up spending a lot of time trying to
figure out why weston wasn't managing to launch over SSH and telling me
that I did not have a --tty option specified, despite me passing the
option strings ["--tty", "3"]. Turns out weston just doesn't support
that.

So, add support for this kind of format in addition to "--foo=bar" to
save others from making the same mistake I did.

Changes since v1:
 - Add comment about unreachable boolean check in long_option_with_arg()
 - Convert boolean check in long_option_with_arg() to assert

Signed-off-by: Lyude <lyude@redhat.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-05-23 11:19:27 +02:00
Derek Foreman dbfd248da4 libweston: Allow compositor-wayland to use wl_surface_damage_buffer
wl_surface_damage_buffer landed ages ago, but in order for GL to
use it the client must bind a wl_compositor version >= 4 (the
version where damage_buffer was introduced).

This patch updates the bind version and allows
eglSwapBuffersWithDamage to actually use the provided damage
rectangles instead of performing full surface damage.

Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-05-19 16:44:03 -05:00
Derek Foreman 6156d675f4 clients: Allow simple-egl to use wl_surface_damage_buffer
wl_surface_damage_buffer landed ages ago, but in order for GL to
use it the client must bind a wl_compositor version >= 4 (the
version where damage_buffer was introduced).

This patch updates the bind version and allows
eglSwapBuffersWithDamage to actually use the provided damage
rectangles instead of performing full surface damage.

This log is much longer than the patch.

Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-05-19 16:43:55 -05:00
Olivier Fourdan 9e07d25a1b xwm: Don't change focus on focus events from grabs
xwm would not let X clients change the focus behind the compositor's
back, reverting focus where it's supposed to be when this occurs.

However, X11 grab also issue focus in events, on which some clients
rely and reverting focus in this case braks the client logic (e.g.
combobox menu in gtk+ using the X11 backend).

Check if the focus event is actually coming from a grab or ungrab and
do not revert focus in this case, to avoid breaking clients logic.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-05-18 11:16:56 +01:00
Daniel Stone eca5cca561 Account for very large repaint window misses
At the bottom of weston_output_finish_frame(), code exists to account
for flips which have missed the repaint window, by shifting them to lock
on to the next repaint window rather than repainting immediately.

This code only accounted for flips which missed their target by one
repaint window. If they miss by multiples of the repaint window, adjust
them until the next repaint timestamp is in the future. This will only
happen in fairly extreme situations, such as Weston being scheduled out
for a punitively long period of time. Nevertheless, try to help recovery
by still aiming for more predictable timings.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-05-02 19:18:38 +01:00
Bryce Harrington 9ad4de1f7a
desktop-shell: Enable per-output fade animations
Instead of creating a single global fade surface across all outputs,
create a separate surface for each output.  This will permit
e.g. individual fades for each output (or blocking the fade-outs if
inhibiting idling as will come in a later patch.)

This also fixes a potential issue if on multihead layout spanning a
desktop wider than 8096 (or higher than 8096), the fade animation may
not completely cover all surfaces.

This assumes the output geometry doesn't change to become larger during
the course of the fade animation.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-04-21 10:24:17 +02:00
Derek Foreman 2cd87fe8d7 compositor-drm: Fix disabling cursor plane
commit a7cba1d4cd changed the way
the cursor plane is setup.  Previously it was pre-emptively set
disabled for the next frame, and that would be changed at next
frame time if the cursor plane was to be used.  It was changed
to be disabled at plane assignment time.

We disable the use of planes entirely by setting disable_planes to
a non-zero value, which bypasses all calls to assign_planes - so
if the plane was set-up in the previous frame it will retain its
state post-disable.

This leads to desktop zoom leaving the cursor plane in place when
it sets disable_planes.

This patch clears any stale cursor plane state from the redraw
handler if disable_planes is set so drm_output_set_cursor()
will do the right thing.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Reported-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
2017-04-13 15:40:30 -05:00
Pekka Paalanen 5f93b9f640 libweston-desktop/xwayland: react to geometry changes
Fix up the window position whenever the geometry info changes.

If the window geometry changes, we want to keep the input-responding
content anchored to top-left. It is done by manipulating the dx,dy
arguments originating from a wl_surface.attach request.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-04-13 11:37:25 +01:00
Pekka Paalanen 7ace831ca6 xwm: use _XWAYLAND_ALLOW_COMMITS
This patch uses the new feature proposed for Xwayland in the patch
series https://patchwork.freedesktop.org/series/16610/ .

When the frame window is created, immediately forbid Xwayland commits on
it. This prevents commits before the decorations have been drawn and the
initial pending state has been set. Commits are enabled right after
drawing and setting.

This ensures that the decorations are fully drawn when a window is
mapped. This also solves the initial commit/pending race, but the race
is on again after mapping.

If Xwayland does not implement the needed support, we are just setting a
window property with no effect.

This patch is the final piece for solving T7622, excluding the
_NET_WM_SYNC_REQUEST handling.

Task: https://phabricator.freedesktop.org/T7622
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-04-13 11:35:02 +01:00
Pekka Paalanen ad0da4596d xwm: do not draw decor twice on map
Normal windows enter the MapRequest handler, which schedules drawing the
decorations. Then Xwayland realizes the window, which ends with a call
to xserver_map_shell_surface(). The decorations are already drawn, no
need to draw them a second time. However, MapRequest handler could not
set the pending state because the weston_surface did not exist at the
time, because it gets created only when Xwayland realizes the window,
which happens after XWM has forwarded the MapWindow in MapRequest
handler. Therefore set the pending state explicitly at the end.
Scheduling had it done much later anyway.

Now that the pending state is set much earlier, it seems to be more
likely that it gets set before Xwayland's first commit is handled. This
means that -geometry command line option of X11 apps already takes the
geometry (decorations) into account. I do not think it is reliable yet,
though.

There is still the race between Xwayland committing and XWM setting the
pending state assuming the very next commit latches it in appropriately.
The race exists not because of Wayland, but because WL_SURFACE_ID comes
via X11, and could be processed after wl_compositor.create_surface and
wl_surface.commit. That commit/pending race is solved by a following patch.

For override-redirect windows weston_wm_window_schedule_repaint()
reduced into a call to weston_wm_window_set_pending_state_OR(), so we
can just call that directly. It should not matter that the call is moved
to the end of the function.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Daniel Stone <daniels@collabora.com>
2017-04-13 11:34:36 +01:00
Philipp Zabel 552e4c4309 libweston: fix pixel-format helpers compilation on non-X11 EGL platforms
Since building libweston includes EGL/egl.h from pixel-formats.c,
EGL_CFLAGS must be added to libweston_CFLAGS, as on some platforms that
contains -DMESA_EGL_NO_X11_HEADERS, and fails to compile without it:

  CC       libweston/libweston_3_la-pixel-formats.lo
In file included from [...]/usr/include/EGL/egl.h:39:0,
                 from libweston/pixel-formats.c:39:
[...]/usr/include/EGL/eglplatform.h:119:22:
fatal error: X11/Xlib.h: No such file or directory

Fixes: 903721a621 ("libweston: Add pixel-format helpers")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-04-12 14:58:13 +01:00
Pekka Paalanen c65df6403a libweston: improve weston_output_disable() comments
Reorder some paragraphs to be more logically ordered. Rewrite the
description of the backend-specific disable function to explain the
semantics instead of the mechanics. Remove the paragraph about
pending_output_list as unnecessary details.

Add a big fat comment on why we call output->disable() always instead of
only for actually enabled outputs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
2017-04-11 15:35:12 +03:00
Daniel Stone 08d4edf20d compositor-drm: Rename drm_sprite to drm_plane
We make the differentiation where planes are an abstract framebuffer
with a position within a CRTC/output, and sprites are special cases of
planes that are neither the primary (base/framebuffer) nor cursor plane.

drm_sprite, OTOH, contains nothing that's actually specific to sprites,
and we end up duplicating a lot of code to deal with them, especially
when we come to use an entirely plane-based interface with atomic
modesetting.

Rename drm_sprite to drm_plane, to reflect that it's actually generic.

No functional changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
[Pekka: dropped the removal of an unrelated comment]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-04-10 14:01:00 +03:00
Daniel Stone 205c0a018c compositor-drm: Clean up page_flip_pending path
page_flip_pending is only be set when do a pageflip to a newly-rendered
buffer; if the flag is not set, we have landed in the start_repaint_loop
path where the vblank query fails, and thus we must pageflip to the same
buffer.

This test was not sufficient for what it was supposed to guard:
releasing framebuffers back. When using client-supplied framebuffers, it
is possible to reuse the same buffer multiple times, and we would send a
framebuffer-release event too early.

However, since we have a properly reference-counted drm_fb now, we can
just drop this test, and rely on the reference counting to prevent
too-early release of client framebuffers.

page_flip_pending now becomes exactly what the name suggests: a flag
which indicates whether or not we are expecting a pageflip event. Add
asserts here to verify that we never receive a pageflip event we weren't
expecting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-04-10 13:56:12 +03:00
Daniel Stone 65d87d071f compositor-drm: Turn vblank_pending from bool to refcount
vblank_pending is currently a bool, which is reset on every vblank
requests (i.e. sprite pageflip). This can occur more than once per
frame, so turn it into a callback, so we only fire frame-done when we've
collected all the events.

This fixes unexpected behaviour when multiple views per output have been
promoted to DRM planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-04-10 13:55:50 +03:00
Daniel Stone f30a18c1c3 compositor-drm: Introduce fb_last member
Previously, framebuffers were stored as fb_current and fb_pending.
In this scheme, current was the last buffer that the kernel/hardware had
acknowledged displaying: a framebuffer would be created, set as
fb_pending, and Weston would request the kernel display it. When the
kernel signals that the request was completed and the hardware had made
the buffer current (i.e. page_flip_handler / vblank_handler), we would
unreference the old fb_current, and promote fb_pending to fb_current.

In other words, the view is 'which buffer has turned to light?'.

This patch changes them to a tristate of fb_last, fb_current and
fb_pending, based around the kernel's view of the current state.
fb_pending is used purely as a staging area for request construction;
when the kernel acknowledges a request (e.g. drmModePageFlip returns 0),
the previous buffer is moved to fb_last, and this new buffer to
fb_current. When the kernel signals that the request has completed and
the hardware has made the buffer current, we simply unreference and
clear fb_last, without touching fb_current/fb_pending.

The view here is now 'which state is current in the kernel?'.

As all state changes are incremental on the last state submitted to the
kernel, even if the hardware has not yet been able to make it current,
this simplifies state tracking: all state submissions will always be
relative to fb_current, rather than the previous
(fb_pending) ? fb_pending : fb_current.

The use of fb_pending is strictly bounded between a repaint cycle
(including a grouped set of repaints) beginning, and those repaints
being flushed to the kernel.

fb_current will always be valid between an output's first repaint
flush, and when a disable/destroy request has been processed. For a
plane, it will be valid when a repaint cycle enabling that plane has
been flushed, and when a repaint cycle disabling that plane has been
flushed.

fb_last is only present when a repaint request for the output/plane has
been submitted, but not yet completed by the hardware.

This is the same set of constructs which will be used for storing
plane/output state objects in future patches.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-04-10 13:55:25 +03:00