47 Commits

Author SHA1 Message Date
David Herrmann
3aad1107d8 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>
2011-12-02 15:27:01 +01:00
David Herrmann
9b88fe87e2 test_output: Use new log API
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-02 15:16:14 +01:00
David Herrmann
ed79aeccef 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>
2011-12-02 15:15:05 +01:00
David Herrmann
9093189f2f 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>
2011-12-02 15:10:07 +01:00
David Herrmann
41c56410ee 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>
2011-12-02 14:35:33 +01:00
David Herrmann
ca409fb0c5 Update documentation about autotools
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-02 13:31:12 +01:00
David Herrmann
0d1acc526f 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>
2011-12-02 13:23:22 +01:00
David Herrmann
6072bf445f 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>
2011-12-01 18:33:49 +01:00
David Herrmann
0b6a81d901 Update TODO
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-01 18:20:54 +01:00
Ran Benita
aacb342092 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>
2011-12-01 16:39:06 +01:00
Ran Benita
25b85f5f26 Output: Fix warning -Wall complains about
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-01 16:27:15 +01:00
Ran Benita
062dd2875d gitignore: add all the build stuff
Signed-off-by: Ran Benita <ran234@gmail.com>
2011-12-01 16:25:11 +01:00
Ran Benita
6d451a2015 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>
2011-12-01 16:21:37 +01:00
David Herrmann
77963ec305 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>
2011-11-27 19:31:26 +01:00
David Herrmann
798276dea9 Add kmscon_char_set() helper
This helper allows to copy one char into another.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-27 16:10:11 +01:00
David Herrmann
0cf9a7a03c Add cursor movement helpers
Add functions to move the cursor of a console.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-27 15:50:59 +01:00
David Herrmann
89634f3f13 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>
2011-11-26 17:59:49 +01:00
David Herrmann
264fff909e 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>
2011-11-26 17:54:56 +01:00
David Herrmann
9e2c14a7ca 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>
2011-11-26 17:53:45 +01:00
David Herrmann
c4d6c554fd 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>
2011-11-26 17:12:17 +01:00
David Herrmann
607a5eed54 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>
2011-11-26 17:04:52 +01:00
David Herrmann
e5de20a22a 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>
2011-11-26 16:55:25 +01:00
David Herrmann
7149b5dd37 Draw console
Properly draw all cells of a console on redraw.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:54:40 +01:00
David Herrmann
c8855d47b2 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>
2011-11-26 16:48:59 +01:00
David Herrmann
c455d8f9f0 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>
2011-11-26 16:47:50 +01:00
David Herrmann
8b93b07db3 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>
2011-11-26 16:46:44 +01:00
David Herrmann
27047fddbf 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>
2011-11-26 16:43:17 +01:00
David Herrmann
27807e913e 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>
2011-11-26 16:33:06 +01:00
David Herrmann
a33f9f589c 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>
2011-11-26 15:29:39 +01:00
David Herrmann
a12cf0aa7f Add kmscon_char_dup()
Add helper function to duplicate a kmscon_char object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 15:27:10 +01:00
David Herrmann
f66f1f5798 Add gitignore file
Ignore swap files and binaries.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 18:27:44 +01:00
David Herrmann
bab0068bed 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>
2011-11-20 18:25:59 +01:00
David Herrmann
9a853a796f 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>
2011-11-20 18:21:41 +01:00
David Herrmann
0b5d1932df Compile all sources into tests
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 18:18:22 +01:00
David Herrmann
5af1381ea3 Update TODO list with console subsystem
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 18:02:28 +01:00
David Herrmann
8cd898bb58 Add console subsystem to README
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 17:58:32 +01:00
David Herrmann
bfc6975baf 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>
2011-11-20 17:55:57 +01:00
David Herrmann
173d38c0f5 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>
2011-11-20 17:49:21 +01:00
David Herrmann
cfdbaeb50e 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>
2011-11-20 15:47:23 +01:00
David Herrmann
6c19c352bc 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>
2011-11-20 15:46:22 +01:00
David Herrmann
731091a70a 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>
2011-11-20 14:44:39 +01:00
David Herrmann
f85eb100f9 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>
2011-11-20 00:41:15 +01:00
David Herrmann
259fcfa12d Add TODO list
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-20 00:28:53 +01:00
David Herrmann
71ffc2bda3 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>
2011-11-20 00:21:49 +01:00
David Herrmann
9847437735 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>
2011-11-20 00:16:27 +01:00
David Herrmann
85d7391cda 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>
2011-11-20 00:09:39 +01:00
David Herrmann
fca8681dfc 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>
2011-11-19 23:05:38 +01:00