#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <string.h>
#include <errno.h>
#include <linux/fb.h>
const char ver[] = "blank v1.0 2004(C) Dojip Kim\n";
#define FB_DEV "/dev/fb0"
typedef enum {
OFF = 0,
ON
} bl_mode_t;
static int blank(unsigned long arg);
int main(int argc, char **argv)
{
bl_mode_t mode = ON;
printf("%s", ver);
if (argc > 1) {
if (strncmp(argv[1], "-on", 3) == 0)
mode = ON;
if (strncmp(argv[1], "-off", 4) == 0)
mode = OFF;
} else {
printf("usage: blank -on/-off\n");
exit(1);
}
switch (mode) {
case OFF:
blank(VESA_POWERDOWN);
break;
case ON:
blank(VESA_NO_BLANKING);
break;
default:
}
return 0;
}
static int blank(unsigned long arg)
{
int fd = -1;
fd = open(FB_DEV, O_RDWR);
if (fd < 0) {
fprintf(stderr, strerror(errno));
return -1;
}
ioctl(fd, FBIOBLANK, arg);
close(fd);
return 0;
}