You are not logged in.

#1 2015-07-24 23:03:41

dank
Member
Registered: 2015-07-24
Posts: 9

[Solved] virtual consoles 2-6 unusable, different resolution?

Hi,

I'm working on an Asus zenbook UX301L, with the 4.1.2-2-ARCH kernel.
Sometime fairly recently (weeks ago) I noticed that virtual consoles 2-6 were not working properly for me.
However, I'm not sure exactly what version I was at when the change occurred, as I use the VCs infrequently.

Virtual console 1 works, but virtual consoles 2-6 are illegible, with what look like wierd graphics characters replacing the textual characters.  However, something else may be going on.

Reading the first two bytes of /dev/vcsa1 shows a virtual console text screen resolution of 65 rows and 213 columns.  On the other hand, reading from /dev/vcsa2 through /dev/vcsa6 shows a virtual console text screen resolution of 90 rows and 64 columns.

$ sudo ./vcs 1 1 0
mask = 0x0000
lines=65, cols=213, x=14, y=3
ch='A' (0x041) attrib=0x07
$ sudo ./vcs 2 1 0
mask = 0x0000
lines=90, cols=64, x=14, y=3
ch=' ' (0x020) attrib=0x07
$ sudo ./vcs 3 1 0
mask = 0x0000
lines=90, cols=64, x=14, y=3
ch=' ' (0x020) attrib=0x07
$ sudo ./vcs 4 1 0
mask = 0x0000
lines=90, cols=64, x=14, y=3
ch=' ' (0x020) attrib=0x07
$ sudo ./vcs 5 1 0
mask = 0x0000
lines=90, cols=64, x=14, y=3
ch=' ' (0x020) attrib=0x07
$ sudo ./vcs 6 1 0
mask = 0x0000
lines=90, cols=64, x=14, y=3
ch=' ' (0x020) attrib=0x07

where the 'vcs' program is compiled from vcs.c below.

Any idea what might be going on, or how to fix it? My knowledge of virtual consoles is limited to 'man vcs'...

Thanks,
- Dan

vcs.c
-------

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/vt.h>

void usage (char *prog)
{
    fprintf(stderr, "Usage: %s  DEVNUM ROW COL\n"
            "   where DEVNUM is in the range 1 .. 6\n", prog);
    exit(1);
}

int
main(int argc, char **argv)
{
    int fd;
    char device[32];
    char console[32];
    struct {unsigned char lines, cols, x, y;} scrn;
    unsigned short s;
    unsigned short mask;
    unsigned char ch, attrib;
    int devnum;
    int row, col;

    if (argc != 4)
        usage(argv[0]);

    devnum = atoi(argv[1]);
    if (devnum < 1 || devnum > 6)
    {
        fprintf(stderr, "Device number out of range [1..6]\n");
        exit(1);
    }
    row = atoi(argv[2]);
    col = atoi(argv[3]);

    snprintf (device, sizeof(device), "/dev/vcsa%d", devnum);
    snprintf (console, sizeof(console), "/dev/tty%d", devnum);

    fd = open(console, O_RDWR);
    if (fd < 0) {
        perror(console);
        exit(EXIT_FAILURE);
    }
    if (ioctl(fd, VT_GETHIFONTMASK, &mask) < 0) {
        perror("VT_GETHIFONTMASK");
        exit(EXIT_FAILURE);
    }
    printf("mask = 0x%04x\n", mask);
    (void) close(fd);
    fd = open(device, O_RDWR);
    if (fd < 0) {
        perror(device);
        exit(EXIT_FAILURE);
    }
    (void) read(fd, &scrn, 4);
    printf ("lines=%u, cols=%u, x=%u, y=%u\n",
            scrn.lines, scrn.cols, scrn.x, scrn.y);

    if (row < 0 || col < 0 || row >= scrn.lines || col >= scrn.cols)
    {
        fprintf(stderr, "ROW or COL was out of range\n");
        exit(1);
    }

    (void) lseek(fd, 4 + 2*(row*scrn.cols + col), 0);

    (void) read(fd, &s, 2);
    ch = s & 0xff;
    if (s & mask)
        ch |= 0x100;
    attrib = ((s & ~mask) >> 8);
    printf("ch='%c' (0x%03x) attrib=0x%02x\n", ch, ch, attrib);

    exit(EXIT_SUCCESS);
}

Last edited by dank (2015-09-04 01:35:13)

Offline

#2 2015-07-24 23:14:01

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,572
Website

Re: [Solved] virtual consoles 2-6 unusable, different resolution?

Hi Dan, welcome to the Arch Linux forums.

Please edit your post to add code tags around your terminal output and code. It makes it much easier to read.

https://wiki.archlinux.org/index.php/Fo … s_and_code


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2015-07-24 23:18:15

dank
Member
Registered: 2015-07-24
Posts: 9

Re: [Solved] virtual consoles 2-6 unusable, different resolution?

Done.

Offline

#4 2015-08-24 19:58:56

dank
Member
Registered: 2015-07-24
Posts: 9

Re: [Solved] virtual consoles 2-6 unusable, different resolution?

Now on kernel 4.1.6-1-ARCH.   The problem seems to have been fixed at some point.

Offline

#5 2015-08-24 20:50:33

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [Solved] virtual consoles 2-6 unusable, different resolution?

Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB