platform/upstream/kmscon.git
12 years agoAdd config.h.in~ to gitignore
David Herrmann [Wed, 14 Dec 2011 17:09:03 +0000 (18:09 +0100)]
Add config.h.in~ to gitignore

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agobuild: set in NDEBUG instead of DEBUG in configure
Ran Benita [Mon, 12 Dec 2011 20:37:07 +0000 (22:37 +0200)]
build: set in NDEBUG instead of DEBUG in configure

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agovt: add support for automatic VT switching
Ran Benita [Sat, 10 Dec 2011 23:56:48 +0000 (01:56 +0200)]
vt: add support for automatic VT switching

Add two functions to enter/leave our VT object. This allows to
implement to expected behavior of automatically switching to the kmscon
when it is running on a new tty, and switching back to the tty we came
from when the program finishes. Presumably this behavior will be
controlled by a config variable or command line argument later on (like
Xorg's -novtswitch).

There's a bit of a subtlety in this because of VT_PROCESS. We need
permission from ourselves to switch in/out of out VT; this is done when
processing SIGUSR[12] in the eloop. We therefore must dispatch the loop
at least once after switching out. The usual case is demonstrated in
test_vt.c.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd K_OFF to vt-TODO
David Herrmann [Wed, 14 Dec 2011 14:38:26 +0000 (15:38 +0100)]
Add K_OFF to vt-TODO

See https://github.com/dvdhrm/kmscon/pull/3 for a discussion of K_OFF in the VT
subsystem. We cannot apply it now but we have to reconsider it when the input
subsystem has been written.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agobuild: a few fixes to configure script
Ran Benita [Fri, 2 Dec 2011 12:01:12 +0000 (14:01 +0200)]
build: a few fixes to configure script

- Use C99 and gnu extensions.
- Explicitly link against libdrm (more strict linkers like gold would
  complain).
- Consistently use *_CPPFLAGS where due.
- Clear the default CFLAGS.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoConsole: Add buffer object
David Herrmann [Sun, 4 Dec 2011 16:56:43 +0000 (17:56 +0100)]
Console: Add buffer object

The buffer object manages the cells and scrollback buffer. It is optimized for
speed: fast rotations, fast resize, etc.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoConsole: Simplify character handling
David Herrmann [Sat, 3 Dec 2011 17:09:41 +0000 (18:09 +0100)]
Console: Simplify character handling

We add a new helper to initialize a new character directly to avoid two
allocations. This also refactors the character code and simplifies it alot.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_console: Use new eloop and VT subsystem
David Herrmann [Sat, 3 Dec 2011 15:49:44 +0000 (16:49 +0100)]
test_console: Use new eloop and VT subsystem

The test_console application now supports VT-switching and monitor-hotplug. New
monitors are detected when switching VTs. Full hotplug-support will be added
later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoOutput: Correctly acquire/release DRM master
David Herrmann [Sat, 3 Dec 2011 15:39:06 +0000 (16:39 +0100)]
Output: Correctly acquire/release DRM master

If we switch VT, we must release DRM master to allow other applications to
access the DRM. When waking up the compositor we try to acquire the master again
to access the DRM.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoEloop: Fix function name typo
David Herrmann [Sat, 3 Dec 2011 15:38:14 +0000 (16:38 +0100)]
Eloop: Fix function name typo

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoFix gitignore
David Herrmann [Sat, 3 Dec 2011 14:14:38 +0000 (15:14 +0100)]
Fix gitignore

We currently ignore all test sources. Restrict the filter to the root directory
so only the binaries are affected.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd VT test
David Herrmann [Sat, 3 Dec 2011 14:14:18 +0000 (15:14 +0100)]
Add VT test

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoEloop: Add debug statements
David Herrmann [Sat, 3 Dec 2011 14:09:10 +0000 (15:09 +0100)]
Eloop: Add debug statements

Add some more debug statements to allow easier eloop monitoring.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd VT handling
David Herrmann [Sat, 3 Dec 2011 14:08:18 +0000 (15:08 +0100)]
Add VT handling

As long as we are run in a VT we need to correctly handle VT-switches to avoid
blocking the crtc/input.

This is copied from wayland-compositor demos and modified to fit to our needs.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoEloop: Pass mask argument to fd callbacks
David Herrmann [Sat, 3 Dec 2011 11:22:36 +0000 (12:22 +0100)]
Eloop: Pass mask argument to fd callbacks

fd-callbacks are pretty useless if we do not pass a mask argument with the
current flags.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoEloop: Add idle-event support
David Herrmann [Sat, 3 Dec 2011 11:04:29 +0000 (12:04 +0100)]
Eloop: Add idle-event support

Idle events are dispatched everytime kmscon_eloop_dispatch() is called. To allow
the callbacks to add/remove/modify all current idle events (including themself),
we need to keep a pointer to the currently dispatched event.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd event loop
David Herrmann [Sat, 3 Dec 2011 10:42:41 +0000 (11:42 +0100)]
Add event loop

Add event loop implementation with support for fd's and signal's through
signalfd.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_output: Use log API
David Herrmann [Fri, 2 Dec 2011 14:33:52 +0000 (15:33 +0100)]
test_output: Use log API

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoOutput: Choose sane default mode
David Herrmann [Fri, 2 Dec 2011 14:27:01 +0000 (15:27 +0100)]
Output: Choose sane default mode

We currently use the first mode in the list if no mode is explicitely specified
by the caller. However, this is most often the lowest available resolution
reported by the kernel.

This patch adds a new pointer to every output which remembers a sane default.
This is currently the first mode reported by the kernel but may later be
optimized to choose a better default mode.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_output: Use new log API
David Herrmann [Fri, 2 Dec 2011 14:16:14 +0000 (15:16 +0100)]
test_output: Use new log API

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd log API
David Herrmann [Fri, 2 Dec 2011 14:15:05 +0000 (15:15 +0100)]
Add log API

We simply forward all log messages to stderr. We use syslog/prink-like severity
prefixes. Use systemd or alike to forward stderr to syslog, kernel-log or
similar.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_output: Catch SIGINT and SIGTERM
David Herrmann [Fri, 2 Dec 2011 14:10:07 +0000 (15:10 +0100)]
test_output: Catch SIGINT and SIGTERM

Correctly handle SIGINT and SIGTERM. This will also reset the crtc so it won't
stay black if the application is killed.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agotest_console: React on SIGINT
David Herrmann [Fri, 2 Dec 2011 13:35:33 +0000 (14:35 +0100)]
test_console: React on SIGINT

Correctly terminate the application on SIGINT so the CRTC gets reset.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoUpdate documentation about autotools
David Herrmann [Fri, 2 Dec 2011 12:31:12 +0000 (13:31 +0100)]
Update documentation about autotools

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoChange license to MIT license
David Herrmann [Fri, 2 Dec 2011 12:23:22 +0000 (13:23 +0100)]
Change license to MIT license

Further commits will need a Signed-off-by line, otherwise I cannot accept them.
MIT license is compatible with GPL so we still can switch to GPL in the future
if we want.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoConsole: Fix cell-selection when drawing glyphs
David Herrmann [Thu, 1 Dec 2011 17:33:49 +0000 (18:33 +0100)]
Console: Fix cell-selection when drawing glyphs

We didn't calculate the correct cell number when drawing a cell. Fix that.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoUpdate TODO
David Herrmann [Thu, 1 Dec 2011 17:20:54 +0000 (18:20 +0100)]
Update TODO

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agooutput: save and restore crtc upon (de)activation
Ran Benita [Mon, 28 Nov 2011 22:27:30 +0000 (00:27 +0200)]
output: save and restore crtc upon (de)activation

The crtc is saved from kmscon_output_activate, and restored from
kmscon_output_deactivate.
This means that when the program exits, the screen is back to what it
was - we don't need to switch back VTs if we started the program from an
fbcon, etc.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoOutput: Fix warning -Wall complains about
Ran Benita [Sun, 27 Nov 2011 17:09:26 +0000 (19:09 +0200)]
Output: Fix warning -Wall complains about

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agogitignore: add all the build stuff
Ran Benita [Sun, 27 Nov 2011 17:08:36 +0000 (19:08 +0200)]
gitignore: add all the build stuff

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agobuild: use gnu autotools
Ran Benita [Sun, 27 Nov 2011 16:54:53 +0000 (18:54 +0200)]
build: use gnu autotools

This commit adds basic autoconf + automake files to build the project.
It also adds a main.c stub in order to simulate the main binary.

The configure script uses pkg-config to find the libraries. The usual
stuff should work. The only additional option right now is:
        ./configure --enable-debug [To enable debugging symbols]
The Makefile should also support the standard stuff:
        make [To build the kmscon binary]
        make check [To build the test_* binaries]
        make dist [To create a tarball]
        make clean
        make install
        etc.

To start from a clean tree (e.g. git clean -dfx), do something like the
following:
        ./autogen.sh
        ./configure --enable-debug CFLAGS=-O0
        make

It all should work well enough for now.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd kmscon_console_write() function
David Herrmann [Sun, 27 Nov 2011 18:31:26 +0000 (19:31 +0100)]
Add kmscon_console_write() function

This function can be used to change the content of the current cell. It
automatically moves the cursor to the next cell.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd kmscon_char_set() helper
David Herrmann [Sun, 27 Nov 2011 15:10:11 +0000 (16:10 +0100)]
Add kmscon_char_set() helper

This helper allows to copy one char into another.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd cursor movement helpers
David Herrmann [Sun, 27 Nov 2011 14:50:59 +0000 (15:50 +0100)]
Add cursor movement helpers

Add functions to move the cursor of a console.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoUpdate TODO
David Herrmann [Sat, 26 Nov 2011 16:59:49 +0000 (17:59 +0100)]
Update TODO

Similar to libvte we could speed up font-drawing by using cairo_scaled_font_t to
bypass pango entirely if a glyph is already in the hash-table.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoSupport glyph string caching
David Herrmann [Sat, 26 Nov 2011 16:54:56 +0000 (17:54 +0100)]
Support glyph string caching

To avoid redrawing the whole layout every time, we now support caching a single
glyph-string if it consists of only one run.

This should speed up drawing considerably. We still support drawing the whole
layout as fall-back method.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoFix glyph caching
David Herrmann [Sat, 26 Nov 2011 16:53:45 +0000 (17:53 +0100)]
Fix glyph caching

We need to use memcmp() not memcpy() to compare two kmscon_char's.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoCalculate font size properly
David Herrmann [Sat, 26 Nov 2011 16:12:17 +0000 (17:12 +0100)]
Calculate font size properly

We set the font size to the absolute size we have per cell instead of using a
fixed font-size.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoSet console resolution to 800x600 by default
David Herrmann [Sat, 26 Nov 2011 16:04:52 +0000 (17:04 +0100)]
Set console resolution to 800x600 by default

This sets the console resolution to 800x600 on startup. We no longer have a
console with an invalid resolution after startup so we now can start calculating
font sizes properly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoFix test_console
David Herrmann [Sat, 26 Nov 2011 15:55:25 +0000 (16:55 +0100)]
Fix test_console

Correctly set locale on startup and sleep for one second after each redraw to
reduce CPU consumption.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoDraw console
David Herrmann [Sat, 26 Nov 2011 15:54:40 +0000 (16:54 +0100)]
Draw console

Properly draw all cells of a console on redraw.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoReset cairo surface when drawing console
David Herrmann [Sat, 26 Nov 2011 15:48:59 +0000 (16:48 +0100)]
Reset cairo surface when drawing console

We must use SOURCE operator to reset the surface. Otherwise, we end up doing
nothing here because our alpha value is 0.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoSet each cell to '?' for testing purposes
David Herrmann [Sat, 26 Nov 2011 15:47:50 +0000 (16:47 +0100)]
Set each cell to '?' for testing purposes

Each cell of a console is initialized to '?' to allow testing the glyph
operations.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoRefresh texture when redrawing console
David Herrmann [Sat, 26 Nov 2011 15:46:44 +0000 (16:46 +0100)]
Refresh texture when redrawing console

We need to refresh the GL texture data when redrawing the console. Otherwise, we
always end up with the first frame mapped onto the GL quad object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoCreate font when resizing console
David Herrmann [Sat, 26 Nov 2011 15:43:17 +0000 (16:43 +0100)]
Create font when resizing console

When resizing a kmscon_console object we automatically create a new font because
all cached objects get invalid now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd kmscon_font type
David Herrmann [Sat, 26 Nov 2011 15:33:06 +0000 (16:33 +0100)]
Add kmscon_font type

A kmscon_font object is used to store the current font information. It allows to
draw any kind of UTF-8 string to the screen. Internally, it uses kmscon_glyph to
store glyph information for every character that has been drawn so redrawing it
is much faster.

Currently, we only support GLYPH_LAYOUT as caching method which is quite slow.
However, it supports any kind of input and always works. Better and faster
caching algorithms like cairo_scaled_font_t will be added later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd pango dependency
David Herrmann [Sat, 26 Nov 2011 14:29:39 +0000 (15:29 +0100)]
Add pango dependency

We use pango to draw fonts. This requires glib and cairo support, too.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd kmscon_char_dup()
David Herrmann [Sat, 26 Nov 2011 14:27:10 +0000 (15:27 +0100)]
Add kmscon_char_dup()

Add helper function to duplicate a kmscon_char object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd gitignore file
David Herrmann [Sun, 20 Nov 2011 17:27:44 +0000 (18:27 +0100)]
Add gitignore file

Ignore swap files and binaries.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoSet default console size to 80x24
David Herrmann [Sun, 20 Nov 2011 17:25:59 +0000 (18:25 +0100)]
Set default console size to 80x24

Create for every new console a default cell-size of 80x24.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd cells to console objects
David Herrmann [Sun, 20 Nov 2011 17:21:41 +0000 (18:21 +0100)]
Add cells to console objects

A console has a fixed line and column count. Each entry is represented by a
kmscon_cell object. The console can be resized on the fly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoCompile all sources into tests
David Herrmann [Sun, 20 Nov 2011 17:18:22 +0000 (18:18 +0100)]
Compile all sources into tests

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoUpdate TODO list with console subsystem
David Herrmann [Sun, 20 Nov 2011 17:02:28 +0000 (18:02 +0100)]
Update TODO list with console subsystem

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd console subsystem to README
David Herrmann [Sun, 20 Nov 2011 16:58:32 +0000 (17:58 +0100)]
Add console subsystem to README

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd console test
David Herrmann [Sun, 20 Nov 2011 16:55:57 +0000 (17:55 +0100)]
Add console test

This test application prints a console on all connected outputs. It does not
emulate any terminal but instead just prints the test-console.

It can be used to test the console subsystem in connection with the DRM/KMS
output subsystem.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd console drawing-logic
David Herrmann [Sun, 20 Nov 2011 16:49:21 +0000 (17:49 +0100)]
Add console drawing-logic

A console may be displayed on multiple outputs. We allow different screen
resolutions on these outputs so we need a way to map the console image onto
different outputs.

We simply render the console image into a cairo surface with a user-given
resolution. This should be set to the highest resultion of the used outputs. The
application can now map this image onto the different framebuffers. This will
scale the image if the target framebuffer is smaller than the cairo surface.

We also do not clear the framebuffer. This should be done by the user. This
allows us to draw with alpha values and blend the console on top of the current
framebuffer. We do not have to care for background images and the application
has full control of where the console is shown.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoFix kmscon_console_unref name
David Herrmann [Sun, 20 Nov 2011 14:47:23 +0000 (15:47 +0100)]
Fix kmscon_console_unref name

The name of the unref function was wrong. Fix this from kmscon_con_unref to
kmscon_console_unref.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAvoid refreshing twice in output test
David Herrmann [Sun, 20 Nov 2011 14:46:22 +0000 (15:46 +0100)]
Avoid refreshing twice in output test

Waking up the compositor automatically refreshed the output list. Therefore,
avoid refreshing it manually again.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd kmscon_char type
David Herrmann [Sun, 20 Nov 2011 13:44:39 +0000 (14:44 +0100)]
Add kmscon_char type

Every cell of the console contains one single printable character. We want to be
Unicode compatible so we must support combined characters. Hence, each cell
consists of a UTF-8 string that can be drawn by pango as a single glyph.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd console subsystem dummy
David Herrmann [Sat, 19 Nov 2011 23:41:15 +0000 (00:41 +0100)]
Add console subsystem dummy

Add dummy files for the console subsystem. This subsystem will be used to draw a
console to a framebuffer. It uses pango and cairo for text-rendering and will
provide all required modification functions that the terminal emulation will
require.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd TODO list
David Herrmann [Sat, 19 Nov 2011 23:28:53 +0000 (00:28 +0100)]
Add TODO list

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd temporary Makefile
David Herrmann [Sat, 19 Nov 2011 23:21:49 +0000 (00:21 +0100)]
Add temporary Makefile

This makefile can be used to build kmscon and the test suite. It is quite rough
and will later or sooner be replaced by a proper build-tool like autotools.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd output test-script
David Herrmann [Sat, 19 Nov 2011 23:16:27 +0000 (00:16 +0100)]
Add output test-script

The test_output application is an example how to use the output subsystem. It
lists all connected monitors/DRM-outputs and draws with OpenGL on the selected
framebuffers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoAdd output subsystem
David Herrmann [Sat, 19 Nov 2011 23:09:39 +0000 (00:09 +0100)]
Add output subsystem

The output subsystem manages the connected monitors, provides framebuffers and
OpenGL contexts and handles all DRM/DRI/KMS related functionality.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
12 years agoNew kmscon project
David Herrmann [Sat, 19 Nov 2011 22:05:38 +0000 (23:05 +0100)]
New kmscon project

The kmscon application is a terminal emulator which runs on a native linux DRI
device. It uses linux KMS and DRI to get a working OpenGL context without the
need of an X-Server, Wayland or similar.

It is an attempt to replace the in-kernel VT emulator with a full userspace
console.

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