Move .pc files to ./docs/pc/

We want only C-source files in ./src and the documents ./docs directory is
meant to contain any other sources.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: replace gpu selection modes with new --gpu option

Instead of using one option for each selection mode, we now provide a new
option --gpus. It takes as argument the selection mode to use.

We also remove the --video-devices option as it doesn't fit into the big
picture. Instead, we should provide a blacklist and users would then use
--gpu=all --blacklist-video=<blacklist> instead.

However, blacklisting is also required for input devices and until we
figure it out, we will provide no blacklisting at all.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: introduce new --listen mode

Instead of configuring everything for every kind of situation, we now
split kmscon into two modes: default-mode and listen-mode

In default-mode we run on the given seats once until we encounter a HUP or
until we are closed. It's a perfect replacement for agetty.

In listen-mode, we run only on non-VT seats and provide the full kmscon
functionality. We run as system daemon and wait for new seats and close
seats if they are destroyed. We simply provide a full system-console on
all seats.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: prevent --no-listen in combination with --cdev-session

cdev sessions should only be used in listen-mode to avoid stacking cdev
sessions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: run only on VT-less seats in listen-mode

If we run in listen mode, we are supposed to take over a seat. If a seat
supports VTs (like kernel VTs or kmscon cdev fake VTs) we assume that
there is some manager for these VTs (the one who created them). Therefore,
there is no need to run kmscon in listen mode on these seats. Instead, you
should run kmscon in default mode on these seats.

We enforce this limitation because if the VT-master on those seats dies
and causes a HUP, they have no way to notify us when they startup again.
Therefore, this kind of setup is broken. Furthermore, no-one would every
want such setups.

Instead use the startup mechanism of the VT/seat-manager to start kmscon
in default mode on those seats.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
uterm: vt: use current VT if it is unused

If we autoselect a VT and the current VT is unused, use it. This is
similar to the behavior of Weston and X-Server.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
cdev: do not hardcode TTY major

Use TTY_MAJOR instead of hardcoding the literal 4.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: ignore SIGPIPE

Ignore SIGPIPE globally. We handle HUP correctly everywhere and this
signal is just annoying.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
cdev: change TODO item to check for CAP_KILL

CAP_KILL will be documented in kmscon manuals, but we should actually
check for the capability during startup.

However, this requires linking with libcap or libcap-ng and we currently
want to avoid that for such a simple task.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
uterm: fix compilation of builds where fbdev is the only output

Declare helpers as "static inline" as they might get included but not
used.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Add manpage infrastructure and kmscon.1 manpage

Add a very basic man-page infrastructure so we can easily add new
docbook-style manpages.

Also add kmscon.1 man-page with a basic overview.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
seat: pass allowed VTs from caller

We should handle everything --listen related in kmscon_main so pass in the
allowed-VTs mask from the caller.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: set uterm-seat data in seat-creation

If we want to be able to destroy seats from anywhere, not just
uterm-monitor callbacks, we need to be able to reset the monitor-event
seat-data so we no longer access the seat memory.
Hence, move the seat-data set/reset logic into the actual seat
creation/destroy functions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: move video-device uterm-monitor handling

Same as previous commit: Move uterm-monitor device-data handling into the
real device create/destroy functions to allow dynamic device removal.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: remove unused 'out' arguments

We don't use the newly created objects so no need to return them.
Furthermore, we want the functions to already perform actions on the
objects so there is no guarantee the objects are still alive after
function return. Thus, simply return nothing.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
seat: start hotplugged seats if --switchvt is given

We currently only start seats (switch to their VT) during startup but we
should also do that for hotplugged seats. Therefore, move that logic into
kmscon_seat and perform the startup after the seat is fully set up.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon: remove broken vt_eloop concept

We tried to avoid running unused code during shutdown by moving VT
handling into a separate eloop and run it exclusively. However, with
delayed VT switching, we need to run other event-handlers to make the VT
switch work. Therefore, run all of this during shutdown and remove the
vt_eloop event-loop.

This means that we might create new seats, displays, etc. during shutdown.
This is valid and doesn't harm kmscon, but we want to avoid doing stuff
that is undone few miliseconds later. Therefore, we set a "exiting" flag
and check that before initiating most of the big handlers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
seat: always activate fake-VTs during startup

Instead of relying on --switchvt, we should always activate fake-VTs
during startup. Otherwise, we might end up with dead seats as there is no
way to wake up kmscon later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>