419 Commits

Author SHA1 Message Date
David Herrmann
589b5ce9e3 main: create vt master object
When running multiple sessions on multiple seats, we need to allocate
multiple VTs, too. Therefore, we now create a VT master connection in the
main application which we can later use to allocate new VTs for each
session.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-26 13:16:23 +02:00
David Herrmann
477542b2ba main: listen for new seats
Allocate new seat objects when a new seat occurs and remove them when a
seat goes away.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-26 13:14:20 +02:00
David Herrmann
4c85801975 main: use uterm_monitor objects
Create a global uterm_monitor object to monitor the system for new seats
and devices.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-26 13:02:05 +02:00
David Herrmann
c8ab4a2c49 uterm_vt: fix correctly passing vt data to callbacks
When emulating the VT layer we need to pass our own data to the internal
callbacks. We currently pass the user data which is really useless here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-26 07:33:34 +02:00
David Herrmann
14ab49d985 test_vt: use new uterm vt master
Use uterm vt master to allocate an VT on seat0 for testing purposes.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-26 07:24:47 +02:00
David Herrmann
233eb5c510 uterm: add VT API
The uterm VT API is designed to support new user-space implementations of
vt-master APIs. If we are on seat0 and CONFIG_VT is enabled, we use the
kernel VT API. In all other cases we currently simply fall back to a
non-op but will implement in the future dbus based APIs or similar to
support VT switching, that is multi-session, on all seats.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-25 09:45:20 +02:00
David Herrmann
68c6f68993 vt: add kmscon_vt_supported() function
If the kernel has CONFIG_VT disabled we should avoid opening VTs and
instead rely on other mechanisms for virtual terminals.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-24 19:14:51 +02:00
David Herrmann
d3257fca31 eloop: fix eloop object never being freed
We must _never_ take a reference to ourself in a constructor. Otherwise,
the refcnt will be >1 which means if the user calls *_unref() the object
will not get freed.
Therefore, do not add the counter object used for idle sources directly to
the event loop. Instead, add it when the first idle source is registered
and remove it when the last source is removed. This will slightly slow
down performance of idle-sources. However, the whole eloop is not
optimized for speed, yet, so we don't care for now.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-20 22:54:08 +02:00
David Herrmann
00ff46b701 eloop: add initial gtk-doc comments
Add gtk-doc compatible comments to most of the functions in eloop.c.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 17:58:08 +02:00
David Herrmann
0b8da0ce50 eloop: dynamically reallocate dispatch cache
We do not maintain event caches so we must make sure that every event
source gets dispatched. If we call epoll_wait() and our buffer gets
filled everytime, then there might be an event source that does not get
dispatched because it is always above the buffer range. Therefore, we now
dynamically increase the cache size when it once gets filled up.

This gets critical if we handle thousands of clients or fds, however, our
use case is limited to some system resources and hence does not suffer
here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 13:47:55 +02:00
David Herrmann
56d7932523 eloop: add more comments
Add comments describing each source and the nesting features.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 13:33:05 +02:00
David Herrmann
2eb172acb4 eloop: use counter source for idle events
epoll has the great feature that the poll object is an fd itself. However,
if we want to use idle-sources, we couldn't add them to the epoll set.
Now, we use a counter source for all idle sources so if we add a single
event-loop as source to another event loop, the idle sources will get
dispatched correctly. Furthermore, we now longer block after handling idle
sources but instead now correctly run idle sources every next round
without sleeping for fd events in between.
Unregister idle sources to avoid hogging the CPU.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 13:07:12 +02:00
David Herrmann
f0b92a1366 eloop: fix not returning new counter object
We forgot to actually store the pointer to the new counter object in the
\out variable. Fix this now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 13:05:49 +02:00
David Herrmann
fb4b087bf2 eloop: forward timer HUP and I/O errors to caller
Similar to counter callbacks we now call timer callbacks with 0 as
argument on errors and disable the timer source.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 12:47:08 +02:00
David Herrmann
c9fe031cb7 eloop: forward EOF and I/O errors of counters to caller
Instead of silently dropping read() errors we now disable the counter and
call the user-supplied callback with 0 as argument so they can react on
errors.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 12:30:05 +02:00
David Herrmann
f10ca03eab eloop: allow enabling/disabling counter sources
Similar to fd and timer sources we now also support disabling counter
sources via similar functions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 12:26:55 +02:00
David Herrmann
6a0742465b eloop: allow enabling/disabling timer sources
Similar to the fd_enable/disable functions we now also allow the same
operations on timer sources.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 12:24:28 +02:00
David Herrmann
9703ee3502 eloop: correctly forward error codes
Instead of ignoring epoll errors we should forward them to the caller. The
caller can then still decide to ignore errors.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-19 12:15:51 +02:00
David Herrmann
3ca31d922b eloop: allow enabling/disabling fd sources
We sometimes want to be able to enable/disable an fd-source without
allocating memory (for a short period, for instance). Therefore, introduce
two new functions to enable and disable an fd source.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-18 17:35:18 +02:00
David Herrmann
c4f68e36c1 fbdev: add few implementation hints
fbdev is still not ready but we add some hints so implmenting it later
will be easier.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-18 16:42:32 +02:00
David Herrmann
d1870df383 eloop: move callback declarations into correct order
Use same order as the function definitions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-18 16:42:27 +02:00
David Herrmann
3219b9ccfd eloop: convert idle sources to hooks
Instead if implementing complex idle sources we now provide a hook so
other subsystems can register callbacks.

This simplifies the code a lot and doesn't drop any major functionality.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 18:35:00 +02:00
David Herrmann
83ed40f089 eloop: move code
Restructure eloop code. This puts stuff more closely together if it is
related.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 18:17:52 +02:00
David Herrmann
e37f4a9fba eloop: make timers create fd on initialization
Similar to other event sources we now initialize internal data on timer
creation instead of when the source is added to the loop.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 17:40:14 +02:00
David Herrmann
69dcfe8586 eloop: take fd argument for fd-sources at initialization
When creating a new fd-source you must supply the file descriptor
directly. You cannot delay this to the time when you add the fd to the
event loop.

This simplifies the logic and allows much smoother handling in the event
loop core.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 17:03:46 +02:00
David Herrmann
31550f3180 eloop: add counter sources
Counter sources are based on the eventfd syscall of linux. Internally, is
uses a 64bit counter which is initialized to 0 and can be increased by the
caller. Whenever the value is non-zero, the fd is marked readable and we
call our callback. We read the 64bit integer (which resets it to 0) and
pass the current value to the callback.

This can be used to implement cross-process notification methods or to
have idle-sources as valid file-descriptors in an epoll set which could be
exported to other applications that are not compliant to our event loop.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 16:48:43 +02:00
David Herrmann
32baeeec9d eloop: add ev_fd_is_bound() helper
This helper returns true if the fd is bound to an eloop object, otherwise
false is returned.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 16:33:47 +02:00
David Herrmann
bb1eee8a0f test_output: explicitely activate GL context
We now support multiple GL contexts in uterm so we need to explicitely
enable them before using them.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 16:31:38 +02:00
David Herrmann
6ae48322ed font: fix trailing newline in debug message
log_* appends newline automatically so remove it from the debug message.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-17 14:44:50 +02:00
David Herrmann
efcc519458 test_output: fix build failure
Use new uterm_video constructor. This requires hard-coding the DRM card
but this is needed until we use the uterm_monitor interface.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:49:29 +02:00
David Herrmann
3acc23c932 test_input: use new input API
Use new uterm_monitor and input API instead.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:48:15 +02:00
David Herrmann
2d2c92e6c2 uterm_monitor: correctly enumerate input devices
We are actually not interested in the main input device but rather in the
evdev interface. However, the evdev interface is a child of the input
device and therefore has no seat values specifies. This patch removes the
scan-filter for seat tags and performs seat matching in user-space by
first finding the parent of the input device.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:41:23 +02:00
David Herrmann
fd9a68ae2e uterm_monitor: refresh seats before scanning the system
We currently only scan devices in uterm_monitor_scan() but we should read
the initial seat values before even searching for devices.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:40:32 +02:00
David Herrmann
c81a83fb3a uterm_monitor: initialize list heads correctly
List heads must be initialized and cannot be set to NULL by default.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:40:01 +02:00
David Herrmann
c67b20d89e uterm_monitor: add debug messages
Be more verbose about added and removed devices. Otherwise, debugging is
not as easy as it could be.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:39:24 +02:00
David Herrmann
fcd4156ea0 uterm_input: fix initializing device list
kmscon_dlist heads must be initialized and cannot be set to NULL by
default!

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:37:21 +02:00
David Herrmann
3e905921da uterm_input_xkb: fix typo
We renamed kmscon_kbd to kbd_dev but forgot that single function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:36:23 +02:00
David Herrmann
07d94e0792 uterm_input: fix typo
The header said *_is_asleep() instead of *_is_awake().

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 22:35:43 +02:00
David Herrmann
c5f137c833 uterm_input: add xkb backend
This mainly copies the kbd_xkb.c backend into the uterm library.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 21:30:06 +02:00
David Herrmann
aa0566ba0a uterm_input: use new kbd API
Use the uterm internal kbd API instead of the kmscon kbd API.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 21:15:57 +02:00
David Herrmann
a13ac6b8e4 uterm_input: add kbd API
Internally, we use a new kbd API to handle keyboard related stuff in
uterm. It is a reimplementation of the old kbd_dumb.c backend.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 21:14:38 +02:00
David Herrmann
c7cd3bf353 uterm_input: add input layer to uterm
This is a rewrite of the input layer but integrated into uterm. It has the
same functionality but is tightly bound to the concepts behind uterm and
will soon supercede the old implementation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 20:33:27 +02:00
David Herrmann
5a5bd3a6f2 uterm_monitor: add input device support
To allow moving all input handling to uterm, too, we need to detect input
devices in the uterm-monitor like all other devices, too.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 18:21:58 +02:00
David Herrmann
d1be1d60fa uterm_video: remove hotplug awareness
To introduce the new uterm-monitor object we need to remove all the udev
handling from uterm_video. To not break "git bisect" we now remove all the
udev code from uterm_video and uterm_video_drm and make kmscon use the
static /dev/dri/card0 interface for now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 17:39:46 +02:00
David Herrmann
394879e603 uterm_video_drm: include xf86drmMode.h again
Upstream mesa fixed the missing header protection of xf86drmMode.h so we
can include it again.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 17:24:23 +02:00
David Herrmann
380868d54b uterm_monitor: add system monitor for full seat support
The new uterm_monitor watches the system for seat-changes and puts all
devices under the correct seat. This allows to run kmscon on multiple
seats in a single process. It now also correctly handles seat-changes,
that is, devices that are reattached to a different seat on runtime.

It is not integrated into the kmscon source, yet, but will soon be.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 17:16:13 +02:00
David Herrmann
23e9903f07 misc: add safe list iterator
New for-each implementation that keeps a safe pointer to the next element
so you can remove the current element from the list.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 17:14:28 +02:00
David Herrmann
f7b398a34a eloop: allow flushing an fd
Sometimes one wants to remove all pending events for an fd. The new
ev_eloop_flush_fd() call allows this in a safe way.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-05 17:13:42 +02:00
David Herrmann
335182556c uterm_video: add udev device parameter to video_new()
When triggered by seat monitor we need to be able to create uterm_video
objects on a concrete device so enable passing it in.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-03 19:24:39 +02:00
David Herrmann
60b4fb5100 build: fix build for automake 1.12
automake-1.12 complains about missing AC_PROG_AR so add it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-05-03 19:05:59 +02:00