I'd like you to test the following piece of code using vesafb with 16bit color
depth. Normally, your screen should go pink. If it doesn't, please tell me what
graphics card you use.

I said vesafb, not atyfb or matroxfb. You can try them, though, but I'm pretty
sure that it will only work in very special situations... Normally, mmap()ing
should fail on anything other than vesafb. Thanks in advance.

The code:


#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/fb.h>

#define croak(x) do {\
        perror(x);\
        exit(1);\
} while (0)
        
int main(void) {
        int fd;
        char *foo;
        struct fb_fix_screeninfo x;
        struct fb_var_screeninfo v;
        size_t screensize;

        fd = open("/dev/fb0", O_RDWR);

        if (fd == -1)
                croak("open failed");

        if (ioctl(fd, FBIOGET_VSCREENINFO, &v))
                croak("ioctl FBIOGET_VSCREENINFO failed");
        
        if (ioctl(fd, FBIOGET_FSCREENINFO, &x))
                croak("ioctl FBIOGET_FSCREENINFO failed");

        screensize = v.xres * v.yres * v.bits_per_pixel / 8;

        foo = mmap(x.mmio_start, screensize, PROT_WRITE, MAP_SHARED, fd, 0);

        if (foo == MAP_FAILED)
                croak("mmap failed");

        fprintf(stderr,"Success\n");

        memset(foo, 0xaa, screensize);

        sleep(5);
        munmap(foo, screensize);
        close(fd);
        return 0;
}

-- 
fg

"You can tune a filesystem but you can't tuna fish" (HP/UX' tunefs manpage)


Reply via email to