284 Commits

Author SHA1 Message Date
David Herrmann
83dc28fcc7 Fix time calculations
eloop.c and log.c use struct timeval to calculate time-diffs but
incorrectly use "-" instead of "+" as the value is already negative.
They also use unsigned integers so fix both occurences.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 18:27:29 +01:00
David Herrmann
5a865fc39b build: add conf.c to build
conf.c was recently added so add it to the build-script now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 18:26:50 +01:00
David Herrmann
5f1f1710f9 eloop: correctly set ->exit
When exiting a child eloop we should forward the exit to the parent. Also,
we should reset ->exit on ev_eloop_run() otherwise we cannot run multiple
times.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:58:19 +01:00
David Herrmann
42631efa2c eloop: add debug messages
Add two debug messages to track eloop behavior.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:57:53 +01:00
David Herrmann
6d63b55d6f conf: add --switchvt
--switchvt enables kmscon to automatically switch to the new VT that was
opened by kmscon. If this is the current VT, then this has obviously no
effect.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:42:39 +01:00
David Herrmann
c8b247785c conf: fix --help handling
Handle --help same way as -h.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:41:52 +01:00
David Herrmann
a4bd71cd0c conf: remove unneeded global initialization
Global variables are initialized to 0 automatically. So remove the
initialization.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:40:56 +01:00
David Herrmann
205ab68ff9 eloop: add ev_eloop_run() function
ev_eloop_run() runs the eloop for a given fixed time. If the dispatcher
returns and the timeout isn't reached, then the dispatcher is called
again.
This also adds the *_exit() function which allows to exit the main-loop
and can be called from anywhere (including the callbacks).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:32:45 +01:00
David Herrmann
14b0035f50 eloop: several fixes
Fix parameter validation, fix log_* statements, fix indentation and print
messages on HUP/ERR.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 17:13:01 +01:00
David Herrmann
563492a0c8 eloop: remove fd from epoll-set on HUP
If a handler does not correctly remove itself on HUP, the epoll-loop will
never sleep again because the fd will always be notified as HUP.
Therefore, remove the fd from the epoll-set directly on HUP. This doesn't
change application behavior so it is safe here.

This also allows other subsystems to ignore HUP/ERR events if they are not
fatal. The FD won't be readded but that may not bother.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 16:59:42 +01:00
David Herrmann
56659ce429 eloop: remove ev_eloop_get_fd()
This function was never used so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 16:46:22 +01:00
David Herrmann
cfca84f250 vt: fix callback enum type
We should use the enum type instead of plain "int" to be more verbose
here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 16:42:04 +01:00
David Herrmann
d19f7ec2f1 conf: add configuration subsystem
The conf-subsystem is used throughout the whole source and provides a
global static read-only configuration. The configuration is read on
startup from the command-line and filesystem and then provided to the
other subsystems.

This is no database, that is, the data is not written to a file on
shutdown!

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 16:13:50 +01:00
David Herrmann
be8fe301f9 eloop: allow an eloop to be an event source
This allows to add one eloop object into another eloop. This is useful if
we want to run a single event source isolated (for instance VT on exit).

The internal epoll-descriptor allows polling so this is a fairly
straightforward implementation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 16:10:53 +01:00
David Herrmann
af31f251f3 console: merge console_cell.c into console.c
We currently have too much layers in the console subsystem. This reduces
performance and produces ugly hacks like our "*_clear_region" function. We
now merge both files so we can directly access the buffer-structure.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 14:34:55 +01:00
David Herrmann
650c7077f1 Remove old output subsystem
This subsystem is no longer used so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 14:29:25 +01:00
David Herrmann
096f0cadc7 Move to new uterm infrastructure
This fixes all compositor/output/context/etc. uses and replaces them by
the new uterm API.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 14:18:50 +01:00
David Herrmann
911d635e6e gl: add viewport helper
This helper correctly sets the viewport to the size of a screen.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 14:18:28 +01:00
David Herrmann
1dd7198216 test_output: use new uterm/log/etc. subsystems
Convert the test_output test to use the new subsystems.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 13:35:02 +01:00
David Herrmann
a8562c7a5c uterm_video: add *_screen_height/width() helpers
A screen may have a different size than the displays so add these two
hooks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 13:34:20 +01:00
David Herrmann
564d42fde9 build: define LOG_ENABLE_DEBUG if debugging
Define LOG_ENABLE_DEBUG if we enabled debugging. The log subsystem uses
this to enable the log_debug() statements.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 13:30:36 +01:00
David Herrmann
253ef4850f gl: add debug statements
Add messages about new shader objects.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 13:30:05 +01:00
David Herrmann
4cc8eadd40 uterm_video: take ref-cnt of display in screen object
Inside a screen object we are independent of the lifetime of the displays
so we need to correctly keep references to them.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 12:53:59 +01:00
David Herrmann
25f41f84f7 gl: add GL subsystem
The GL subsystem is copied from the old output_context subsystem and now
provides shader and GL-math. It will replace the old output_context subs
soon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 12:50:35 +01:00
David Herrmann
50e0cdbec8 uterm_video: include GLES2 headers instead of GL
We use GLES2 for drawing. There is currently no reason to provide full GL
inside kmscon as we use the basic operations only.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 11:49:17 +01:00
David Herrmann
62a3db3e9c uterm_video: add dummy fbdev backend
The fbdev backend is non-functional, but we add it for documentational
purposes. It is not built as part of kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 11:46:39 +01:00
David Herrmann
95e434eddb uterm_video: add DRM backend
uterm_video can work with any backend so we need a DRM backend to get the
same functionality as our previous compositor/output API.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 11:45:49 +01:00
David Herrmann
8e2af97038 uterm: new video backend
Our old backend was hacked together and hadn't have any structure. This is
a new approach to create the uterm-library inside kmscon. The
uterm-library will contain everything that is needed to run an application
on Linux DRM devices without X11 or Wayland support.

The idea is to move the input subsystem to uterm, too. No other stuff is
currently planned to be included in uterm.

Although uterm is supposed to be a separate library, we do not build it as
such library. We currently include the log-subsystem and the
eloop-handlers in the library so we cannot build it as stand-alone
library. However, we try to keep it separate so if we ever need to export
it, then it should be a one-hour job to do it so.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 11:26:04 +01:00
David Herrmann
7eafca0e9f log: rewrite log subsystem
The new logger is much more powerful, allows online log-filter
modifications and precise debugging. We still avoid heavy file-operations
as we rely on the caller to forward stderr to a log-file and perform
log-rotations. However, we now provide a simple way to perform this
forward inside the application.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 11:11:46 +01:00
David Herrmann
4790d9f7ab eloop: move prefix to "ev_" instead of "kmscon_"
The long "kmscon_" prefix is horrible so move everything to "ev_" now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:08:29 +01:00
David Herrmann
e7e0744e6e eloop: rename from kmscon_ to ev_
We don't need the long kmscon_ prefix so make it shorter.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:01:28 +01:00
Ran Benita
7b7e8c950d vte: constify global tables
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:01:04 +01:00
Ran Benita
5811fee0da input: test for LED feature and use it
Add probing for LEDs in the input devices, and move the ioctl for the
LEDs state from the keyboard backends to the input subsystem itself
(thus not exposing the device's file descriptor unnecessarily).

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:00:54 +01:00
Ran Benita
6b7265447e input: add features mechanism
This commit discards the simplistic udev check for the ID_KEYBOARD
property in favor of a more direct "feature" probing. This is done for
the following reasons:

- We will need to use input devices which are not necessarily keyboards,
  for example the PC speaker to sound the bell.

- To differentiate between keyboard with certain capabilities, such as
  LEDs (indicators). We can then perform actions on devices according to
  their feature bits.

- We check directly for what we need, i.e. the ability to send/receive
  certain evdev events, without relying on logic in udev. This also
  reduces our dependency on udev if we ever want to make it optional.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:00:45 +01:00
Ran Benita
d8cf293c94 build: implicitly include config.h
config.h is meant to be around in all files, as it contains stuff like
_GNU_SOURCE, NDEBUG and HAVE_*.

Make these definitions available without needing to #include config.h
every single time.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:00:16 +01:00
David Herrmann
1c909c930c Fix copyright year
Add 2012 to copyright and remove University of Tuebingen from new files as
copyright holder. It will still remain in the old files, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 18:56:51 +01:00
David Herrmann
32cb165e40 vte: improve docs
Add parser-links to the docs and add summary comment to the vte.c source file.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 18:56:32 +01:00
David Herrmann
c343e6cef2 vte: add 8bit C1 7bit equivalents (dummy)
Many 8bit C1 codes have 7bit escape sequences as equivalents. This adds handlers
for all of them with comments what they are supposed to do. They are dummies for
now but they will be implemented later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-29 17:21:53 +01:00
David Herrmann
ea81381be5 vte: add 8-bit C1 code handlers (dummy)
Add handlers for C1 codes with a description what they are supposed to do. They
are not yet implemented and are no-ops.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-29 17:11:25 +01:00
David Herrmann
44fdd29e6c vte: new state machine implementation
This is now a fully vt500-series compliant state machine that parses escape
sequences. See vt100.net/emu for information on this state-machine. This is
written from scratch, though.

It now handles all kind of escape sequences that we every want to support. It
correctly ignores all unsupported ones right now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-29 15:25:53 +01:00
David Herrmann
acc32351be kbd_xkb: use new xkbcommon version
The header file moved and the xkb_keycode_t type was introduced.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-27 17:49:15 +01:00
David Herrmann
2b066f173c output: drop drm-master on open() to avoid Xserver bugs
The xserver currently crashes if we switch to its VT and it cannot claim
drm-master. This normally does not happen as we drop drm-master on
VT-leave. However, after calling open() on the drm char-dev we are
automatically drm-master so we should drop it right away as our VT is
not guaranteed to be opened at this time.

There is currently no way to call open() on the drm char-dev without
getting drm-master so there is still a short time-period when we have no
active VT but are drm-master. Switching to X in this short time-period
will still kill the X-server but we are not responsible for horrible
X-server bugs so we ignore this 10ms time-span.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 18:40:31 +01:00
David Herrmann
06286da4ef vte: extend CSI debug message
Print the CSI command in debug messages so we can better understand what
escape commands were sent.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 16:03:13 +01:00
David Herrmann
cdb3d112a6 vte: implement backspace control
Add new helper to console subsystem which performs a backspace
operation. We must take care of auto-wrap mode so we cannot simply use
the *_move_left() function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 16:02:21 +01:00
David Herrmann
5f0d151bb7 vte: implement basic cursor movement CSI
The A, B, C and D CSIs are used to move the cursor in the scroll-region
without scrolling the buffer when reaching the margins.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 16:01:12 +01:00
David Herrmann
dcfbbc3e1d vte: implement CSI-J
The J CSI is used to erase parts of the screen.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:56:34 +01:00
David Herrmann
a5a357e012 vte: implement CSI-K
The K CSI is used to erase parts of the current line.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:52:34 +01:00
David Herrmann
9b058b1f90 vte: implement basic cursor-movement controls
This adds support for line-feed and carriage-return controls. The two
special line-feed controls which are not \n do not take care NL-mode so
they must be handled separately.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:51:10 +01:00
David Herrmann
7c8eb3b108 console: fix bug in buffer-erase helper
We didn't check for NULL line so we got segfaults when erasing empty
lines. Fix this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:44:20 +01:00
David Herrmann
d3951da865 console: add helper to erase current position
This helper erases the current cursor position.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-05 15:14:45 +01:00