Subject: Re: wscon question - 50 line mode
To: Mirian Crzig Lennox <mirian@xensei.com>
From: None <drochner@zel459.zel.kfa-juelich.de>
List: port-i386
Date: 12/22/1998 18:48:23
mirian@xensei.com said:
> Is there any way to make wscon do 50 line mode?  I played with it for
> a bit with no luck.  It's the one feature I miss from pcvt. 

Almost all code is there, it needs only some glue and
userland support for configuration.
Twu things are needed:
1. switch the graphics card to 50-line mode
2. load an 8x8 font

The "vga" driver already offers the "80x50" screen type,
only the wscons code always uses the first offered
type, which is the standard "80x25".
If you want to play with this: there is a line
scr = scrdata->screens[0];
in wsdisplay_common_attach(). The "0" forces the first
offered type, the allowed indices are from 0 to
(scrdata->nscreens - 1). With the vga driver the "1"
will pick the "80x25" mode. (These are no magic numbers
btw, scr->name contains the name string so that a
configuration utility can deal with nice strings.)

If you change this for one or all of the screens allocated
in the loop just below the cited line, the card should
switch to 50-line mode as soon as you switch to a
corresponding VT.
You still need the font. There is an ioctl "WSDISPLAYIO_SFONT"
to load it. I'll append a small program which can be used to
load an 8-line font. (Change HEIGHT to 16 if you want to
load a font to a normal screen.) Make sure DEV corresponds
to the right screen.

The encoding is not handled properly yet. The vga driver assumes
that its font is IBM encoded. If you load an ISO font, the upper
128 chars will not look as wanted.

best regards
Matthias

#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <err.h>
#include <malloc.h>

#include <dev/wscons/wsconsio.h>

#define DEV "/dev/ttyE1"
#define HEIGHT 8

main(argc, argv)
	int argc;
	char **argv;
{
	int wsfd, ffd, b;
	void *buf;
	struct wsdisplay_font f;

	if (argc != 2)
		errx(1, "... font file");

	wsfd = open(DEV, O_RDWR, 0);
	if (wsfd < 0)
		err(1, "open ws");

	ffd = open(argv[1], O_RDONLY, 0);
	if (wsfd < 0)
		err(1, "open font");

	buf = malloc(HEIGHT * 256 * 1);
	b = read(ffd, buf, HEIGHT * 256 * 1);
	if (b != HEIGHT * 256 * 1)
		err(1, "read font");

	f.fontwidth = 8;
	f.fontheight = HEIGHT;
	f.firstchar = 0;
	f.numchars = 256;
	f.stride = 1;
	f.data = buf;

	b = ioctl(wsfd, WSDISPLAYIO_SFONT, &f);
	if (b < 0)
		err(1, "ioctl");
}