#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>

#define S3C2410_FBIO_SETBRIGHTNESS	_IOW('F', 0x50, int)

#define FB_DEVICE	"/dev/fb/0"
#define DEFAULT_LEVEL	1


int main(int argc, char **argv)
{
	int level;
	int fd;
	
	fd=open(FB_DEVICE,O_RDWR);
	if (fd<=0) {
		perror("Unable to open the frame buffer device");
		return 1;
	}

	if (argc != 2)
		level=DEFAULT_LEVEL;
	else
		level=atoi(argv[1]);
		
	printf("Setting brightness to level %d\n",level);
	if (ioctl(fd,S3C2410_FBIO_SETBRIGHTNESS,&level)<0)
	{
		perror("Error with S3C2410_FBIO_SETBRIGHTNESS");
		close(fd);
		return 1;
	}
	
	close(fd);
	return 0;
}
