I'm trying to play with the vt(4) framebuffer console. To this end I want to query the adapter info with the mentioned ioctl(). The ultimate goal is to mmap the framebuffer's start address and then modify pixels. I've run into a brick wall and need your help. While some ioctls work when the file descriptor is from opening /dev/ttyv0, this does not work for FBIO_ADPINFO. I get the feeling I need to open a different device file, but nothing in my /dev directory looks or acts like a framebuffer device. Do I need to tune a sysctl first to see it? Anyway, here's my program:
Compile with "cc -o fb fb.c" and run with one argument for the device, "./fb /dev/ttyv0" (not under X11 but on the console). All I get is "ioctl FBIO_ADPINFO: Inappropriate ioctl for device".
What am I missing?
C:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/fbio.h>
int main(int argc, char **argv) {
int sc;
int fd = 1;
if (argv[1] != NULL)
fd = open(argv[1], O_RDWR);
/* This works for /dev/ttyv0 */
struct fbtype fb;
sc = ioctl(fd, FBIOGTYPE, &fb);
if (sc != 0) {
perror("ioctl FBIOGTYPE");
exit(1);
}
printf("fb_type %d\n", fb.fb_type);
printf("fb_height %d\n", fb.fb_height);
printf("fb_width %d\n", fb.fb_width);
printf("fb_depth %d\n", fb.fb_depth);
printf("fb_cmsize %d\n", fb.fb_cmsize);
printf("fb_size %d\n", fb.fb_size);
/* This doesn't. */
struct video_adapter_info info;
sc = ioctl(fd, FBIO_ADPINFO, &info);
if (sc != 0) {
perror("ioctl FBIO_ADPINFO");
exit(1);
}
printf("d = %p\n", (void *) info.va_window);
return EXIT_SUCCESS;
}
Compile with "cc -o fb fb.c" and run with one argument for the device, "./fb /dev/ttyv0" (not under X11 but on the console). All I get is "ioctl FBIO_ADPINFO: Inappropriate ioctl for device".
What am I missing?