1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00
Commit Graph

72 Commits

Author SHA1 Message Date
David Herrmann
6a15ce2b3e terminal/grdev: simplify DRM event parsing
Coverity complained about this code and is partially right. We are not
really protected against integer overflows. Sure, unlikely, but lets just
avoid any overflows and properly protect our parser loop.
2014-10-03 15:57:00 +02:00
David Herrmann
f1f5b2a3bd terminal: make utf8 decoder return length
Lets return the parsed length in term_utf8_decode() instead of a buffer
pointer. Store the pointer in the passed argument.

This makes it adhere to the systemd coding-style, were we always avoid
returning pointers, but store them in output arguments. In this case, the
storage is not allocated, so it doesn't fit 100% to this idiom, but still
looks much nicer.
2014-10-03 15:57:00 +02:00
David Herrmann
db1a606610 terminal: fix back-buffer selection on DRM page-flip
We currently select front-buffers as new back-buffer if they happen to be
the last buffer in our framebuffer-array. Fix this by never selecting a
new front buffer as back buffer.
2014-10-03 15:57:00 +02:00
David Herrmann
dda57d9143 terminal: add helpers to retrieve page dimensions
Allow term users to retrieve the page dimensions of a terminal screen.
This is needed to properly calculate the grid dimensions when rendering.
2014-10-02 08:40:43 +02:00
David Herrmann
a30f142513 terminal: add term.h header for library users
Like all the other parts of libsystemd-terminal, split API of
term-internal.h into term.h so we can use it from systemd-consoled.
2014-10-02 08:40:43 +02:00
David Herrmann
056e86ee7f terminal: move unifont-map to datadir
Lets avoid putting stuff into /usr/shared/unifont/, but keep it in
/usr/share/systemd/. Upstream lacks interest in this, so don't bother for
now.
2014-10-02 08:40:43 +02:00
David Herrmann
fa96534573 terminal: add unifont_get_width/height()
Allow unifont users to retrieve the width and height of unifont glyphs. In
version 1 this is hard-coded as 8/16, but may be changed in the future.
2014-10-02 08:40:43 +02:00
David Herrmann
c2977e5cb8 terminal: move unifont-internal.h to unifont.h
All the definitions are for outside users, so drop the -internal suffix.
Internal definitions are in unifont-def.h and unifont.c, no need to share
those.
2014-10-02 08:40:43 +02:00
David Herrmann
bfd6d8a322 terminal: add helper to retrieve the seat of a session
Allow sysview users to retrieve the seat that a session is assigned to.
2014-09-29 15:37:32 +02:00
David Herrmann
1c7830cc10 terminal: add sysview_seat_switch_to()
Add helper to perform session switches on a specific seat whenever we
retrieve a VT-switch keyboard event.
2014-09-29 15:37:31 +02:00
David Herrmann
158c1e3e0c terminal: provide display dimensions to API users
Allow users to query the display dimensions of a grdev_display. This is
required to properly resize the objects to be rendered.
2014-09-23 20:05:45 +02:00
David Herrmann
a908d21355 terminal: verify kernel-returned DRM events are not truncated
Make sure the kernel always returns events properly. This is guaranteed
right now, otherwise, we do something really wrong. But lets be sure and
verify the received values properly. This also silences some coverity
warnings.
2014-09-23 20:05:45 +02:00
David Herrmann
c5e6bfc6bc terminal: verify grdev tiles are correctly linked
We used to set "pipe->tile = tile" inside of the leaf allocation. We no
longer do that. Verify that "out" is non-NULL, otherwise we'd leak memory.

This is currently always given, but make sure to add an assert(), so
coverity does not complain.
2014-09-23 20:05:45 +02:00
David Herrmann
b4170aed36 terminal: fix tile-offset calculation
Binary operators with two pointers as arguments always operate on
object-size, not bytes. That is, "int *a, *b", (a - b) calculates the
number of integers between b and a, not the number of bytes.

Fix our cache-offset calculation to not use sizeof() with full-ptr
arithmetic.
2014-09-23 20:05:44 +02:00
David Herrmann
ce540a24d5 Silence some "unchecked return-value" warnings
This adds some log-messages to ioctl() calls where we don't really care
for the return value. It isn't strictly necessary to look for those, but
lets be sure and print warnings. This silences gcc and coverity, and also
makes sure we get reports in case something goes wrong and we didn't
expect it to fail that way.
2014-09-23 20:05:44 +02:00
Zbigniew Jędrzejewski-Szmek
0508a4dfb8 terminal: fix spelling mistake 2014-09-23 09:22:33 -04:00
David Herrmann
c17091b797 terminal: signal object removal during sysview_context_stop()
Now that we no longer propagate callback return values, we can safely call
into user-callbacks during sysview_context_stop(). This way, users can
rely on all objects to be removed via callbacks (except if they failed
during object creation). This avoids duplicating any object hashtables on
the users' side and reduces memory consumption.
2014-09-22 18:14:44 +02:00
David Herrmann
ed3a9f6a30 terminal: handle callback errors in sysview instead of propagating them
We cannot sanely propagate error codes if we call into user-callbacks
multiple times for multiple objects. There is no way to merge those errors
or somehow propagate them.

However, we can just act similar to sd-event and print a log-message while
discarding the values. This way, we allow error-returns, but can properly
continue working on our objects.
2014-09-22 18:14:44 +02:00
David Herrmann
f2a15d86cc terminal: allow user-context to be retrieved/stored
Add "userdata" storage to a bunch of external objects, namely displays and
sessions. Furthermore, add some property retrieval helpers.

This is required if we want external API users to not duplicate our own
object hashtables, but retrieve context from the objects themselves.
2014-09-22 18:14:44 +02:00
David Herrmann
5d301b8aec terminal: make evdev logind-matches per session
Instead of adding matches per device, we now add logind matches per
session. This reduces the number of matches considerably and saves
resources.
2014-09-22 18:14:44 +02:00
David Herrmann
f6e3ee1493 terminal: raise sysview DEVICE_CHANGE events per attachment
Instead of raising DEVICE_CHANGE only per device, we now raise it per
device-session attachment. This is what we want for all sysview users,
anyway, as sessions are meant to be independent of each other. Lets avoid
any external session iterators and just do that in sysview itself.
2014-09-22 14:27:02 +02:00
David Herrmann
89febb631a terminal: forward evdev RESYNC events to linked devices
Whenever we resync an evdev device (or disable it), we should send RESYNC
events to the linked upper layers. This allows to disable key-repeat and
assume some events got dropped.
2014-09-22 14:27:02 +02:00
David Herrmann
6022343476 terminal: always call _enable/_disable on evdev devices
The current pause/resume logic kinda intertwines the resume/pause and
enable/disable functions. Lets avoid that non-obvious behavior and always
make resume call into enable, and pause call into disable, if appropriate.
2014-09-22 14:27:02 +02:00
David Herrmann
4c4e4128f3 terminal: print RESYNC state in evcat
Whenever a key-event is part of a RESYNC, we should print that verbosely
as those events are out-of-order.
2014-09-22 14:27:02 +02:00
David Herrmann
0fbd4d113e terminal: fix mode sync for connectors
The GETXY ioctls of DRM are usually called twice by libdrm: Once to
retrieve the number of objects, a second time with suitably sized buffers
to actually retrieve all objects. In grdrm, we avoid these excessive calls
and instead just call ioctls with cached buffers and resize them if they
were too small.

However, connectors need to read the mode list via EDID, which is horribly
slow. As the kernel still cannot do that asynchronously (seriously, we
need to fix this!), it has a hack to only do it if count_modes==0. This is
fine with libdrm, as it calls every ioctl twice, anyway. However, we fail
horribly with this as we usually never pass 0.

Fix this by calling into GETCONNECTOR ioctls twice in case we received an
hotplug event. Only in those cases, we need to re-read modes, so this
should be totally fine.
2014-09-20 11:46:49 +02:00
David Herrmann
f919ad9d3d terminal: restructure some logging calls in grdrm
Multiple issues here:
 1) Don't print excessive card dumps on each resync. Disable it and make
    developers add it themselves.
 2) Ignore EINVAL on page-flips. Some cards don't support page-flips, so
    we'd print it on each frame. Maybe, at some point, the kernel will add
    support to retrieve capabilities for that. Until then, simply ignore
    it.
 3) Replace the now dropped card-dump with a short message about resyncing
    the card.
2014-09-20 11:46:49 +02:00
David Herrmann
7b12a45b2d terminal: grdev: schedule virtual frame events if hw doesn't support it
Whenever we cannot use hardware frame events, we now schedule a virtual
frame event to make sure applications don't have to do this. Usually,
applications render only on data changes, but we can further reduce
render-time by also limiting rendering to vsyncs.
2014-09-20 11:46:49 +02:00
David Herrmann
3ec19e5d91 terminal: grdev: raise frame event after DISPLAY_ADD/CHANGE
Whenever a display is added or changed, we suppressed any frame events.
Make sure to raise them manually so we can avoid rendering when handling
anything but FRAME events.
2014-09-20 11:46:49 +02:00
David Herrmann
95dbf6b19e terminal: split grdrm_crtc_commit() apart
This helper is quite huge, split it apart to make it easier to follow.
2014-09-20 11:46:49 +02:00
David Herrmann
6221d249d1 terminal: grdev: refresh device state on hotplug events
Whenever we get udev hotplug events, re-read the device state so we
properly detect any changed in the display setups.
2014-09-20 11:46:49 +02:00
David Herrmann
a3eabec96b terminal: grdev: treat udev-devices without devnum as hotplug
If we get udev-device events via sysview, but they lack devnum
annotations, we know it cannot be a DRM card. Look through it's parents
and treat it as hotplug event in case we find such a card.

This will treat any new/removed connectors as sub-devices of the real
card, instead of as devices on its own.
2014-09-20 11:46:49 +02:00
David Herrmann
46c9a12780 terminal: modeset: forward DEVICE_CHANGE events into grdev
Properly forward DEVICE_CHANGE events into grdev so we can react to
changing display setups.
2014-09-20 11:46:49 +02:00
David Herrmann
39cf40e846 terminal: reduce speed of morphing colors in modeset test
The high frequency of the color-morphing is kinda irritating. Reduce it
to a much lower frequency so you can actually look at it longer than few
seconds.
2014-09-20 11:46:49 +02:00
David Herrmann
c1102405c1 terminal: make drm-connectors first-level devices
So far, we only forward DRM cards via sysview APIs. However, with MST,
connectors can be hotplugged, too. Forward the connectors as first-level
devices via sysview so API users can react to changing DRM connectors.
2014-09-20 11:46:49 +02:00
David Herrmann
965f7a3f9b terminal: forward DEVICE_CHANGE events via sysview
Whe need to react to "change" events on devices, but we want to avoid
duplicating udev-monitors everywhere. Therefore, make sysview forward
change events to the sysview controllers, which can then properly react
to it.
2014-09-20 11:46:49 +02:00
David Herrmann
3e7f6cf956 terminal: parse ID_SEAT not only for parents but the device itself
When deciding what seat a device is on, we have to traverse all parents
to find one with an ID_SEAT tag, otherwise, input devices plugged on a
seated USB-hub are not automatically attached to the right seat. But any
tags on the main device still overwrite the tags of the childs, so fix our
logic to check the device itself first, before traversing the parents.
2014-09-20 11:46:49 +02:00
David Herrmann
810626a80d terminal: add systemd-modeset debugging tool
The systemd-modeset tool is meant to debug grdev issues. It simply
displays morphing colors on any found display. This is pretty handy to
look for tearing in the backends and debug hotplug issues.

Note that this tool requires systemd-logind to be compiled from git
(there're important fixes that haven't been released, yet).
2014-09-19 14:48:54 +02:00
David Herrmann
f22e0bce37 terminal: add grdev DRM backend
The grdev-drm backend manages DRM cards for grdev. Any DRM card with
DUMB_BUFFER support can be used. So far, our policy is to configure all
available connectors, but keep pipes inactive as long as users don't
enable the displays on top.

We hard-code double-buffering so far, but can easily support
single-buffering or n-buffering. We also require XRGB8888 as format as
this is required to be supported by all DRM drivers and it is what VTs
use. This allows us to switch from VTs to grdev via page-flips instead of
deep modesets.

There is still a lot room for improvements in this backend, but it works
smoothly so far so more enhanced features can be added later.
2014-09-19 14:13:06 +02:00
David Herrmann
650c544427 terminal: add graphics interface
The grdev layer provides graphics-device access via the
libsystemd-terminal library. It will be used by all terminal helpers to
actually access display hardware.

Like idev, the grdev layer is built around session objects. On each
session object you add/remove graphics devices as they appear and vanish.
Any device type can be supported via specific card-backends. The exported
grdev API hides any device details.

Graphics devices are represented by "cards". Those are hidden in the
session and any pipe-configuration is automatically applied. Out of those,
we configure displays which are then exported to the API user. Displays
are meant as lowest hardware entity available outside of grdev. The
underlying pipe configuration is fully hidden and not accessible from the
outside. The grdev tiling layer allows almost arbitrary setups out of
multiple pipes, but so far we only use a small subset of this. More will
follow.

A grdev-display is meant to represent real connected displays/monitors.
The upper level screen arrangements are user policy and not controlled by
grdev. Applications are free to apply any policy they want.

Real card-backends will follow in later patches.
2014-09-19 14:05:52 +02:00
David Herrmann
1164e944d9 terminal: remove dead code checking O_WRONLY
We only reject evdev FDs that are O_WRONLY as they're currently pretty
useless. The following check for O_WRONLY is thus never excercised so drop
it.
Thanks to Thomas Andersen (via coverity)!
2014-09-16 23:01:48 +02:00
Thomas Hindoe Paaboel Andersen
9169b9a8cc terminal: sd_bus_error_get_errno returns positive errno
The 3 calls to sd_bus_error_get_errno appear to expect a negative
return value.

This patch negates the returned value so it matches the other error
cases in the 3 functions where sd_bus_error_get_errno is used.
2014-09-16 21:31:15 +02:00
David Herrmann
440046e922 terminal: fix missing hashmap_new() conversions
hashmap_new() now takes *_ops instead of individual functions. Fix up any
missing invokations of it that haven't been converted already.
2014-09-15 17:12:41 +02:00
David Herrmann
21978bc3c9 terminal: fix uninitialized variable in strerror() log message
We currently print weird error-messages if xkbcommon fails (which cannot
fail so far, but might in the future). Fix the uninitialized variable
warnings by setting 'r' correctly.
Thanks to Philippe De Swert for catching this (via coverity).
2014-09-11 17:20:11 +02:00
David Herrmann
393a5ba09f terminal: drop redundant assertion
This assertion is already there two lines down. Drop the redundant
assertion.
2014-09-11 15:30:56 +02:00
David Herrmann
667b60341f terminal: fix wrong return value in idev if fcntl() fails
This might cause >=0 to be returned, even though the method failed. Fix
this and return -errno.
2014-09-11 15:29:58 +02:00
David Herrmann
c600022303 terminal: enable sessions in evcat after taking control
If we enable a session, any probed device might get immediately enabled.
This might cause TakeDevice() messages to be sent before we call
TakeControl(). Therefore, enable sessions *after* sending TakeControl() so
we always succeed if TakeControl() succeeds.
2014-09-11 15:28:37 +02:00
David Herrmann
1f3752c81a terminal: remove unused set.h inclusion in idev
We don't use set.h so no need to include it. We used to include it for
temporary refs on all idev devices of a session, but that never was pushed
upstream.
2014-09-11 15:27:56 +02:00
David Herrmann
2e1dd622ee terminal: remove redundant "struct" prefixes
We define typedefs for all internal types so drop the redundant "struct"
prefix.
2014-09-11 15:22:16 +02:00
David Herrmann
98b7fe2ad4 terminal: discard async read() errors for evdev
If read() fails on evdev devices, we deal with this in idev_evdev_hup().
It is very likely this is an async revoke, therefore, we must not abort.
Fix our io helper to discard such errors after passing them to
idev_evdev_hup(), so we don't bail out of the event loop.
2014-09-11 15:22:16 +02:00
Ruben Kerkhof
06b643e7f5 Fix a few more typos 2014-08-30 13:46:07 -04:00