summaryrefslogtreecommitdiff
path: root/packages/slutils/slutils-0.1.0/slfb/slfb.c
blob: 9cb72d12d26a05adcc41acf8f42cffd31f217782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>

int main(int argc, char ** argv) {
  int fd = open("/dev/fb0", O_WRONLY|O_NONBLOCK );
  int on;
  int res = 0;

  if (argc != 2) {
    printf("You must specify on or off\n");
    return 0;
  }

  on = !strncmp(argv[1], "on", (strlen(argv[1]) > 1 ? 2 : 1));

  printf((on ? "on\n" : "off\n"));

  if ( fd )
    {
      int ioctlnum = 0x4611;
      int vesaMode = on ? 0 : 3;
      res = ioctl ( fd, ioctlnum, vesaMode );
      printf("%i\n", res);
      close ( fd );
    }
  else
    {
      printf("failed\n");
    }
  return res;
}