/*
 * Sample code to use kernel ioctl for enable and disable keylight leds.
 *
 * (C) 2006 Stefan Schmidt <stefan@datenfreihafen.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 * 
 */ 

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

/* A780 keylight ioctls */
#define KEYLIGHT_MAIN_ON    0xf0
#define KEYLIGHT_AUX_ON     0xf1
#define KEYLIGHT_MAIN_OFF   0xf2
#define KEYLIGHT_AUX_OFF    0xf3

int main () {
		int light;

		/* Open keylight device */
		light = open("/dev/keylight", O_RDONLY | O_NONBLOCK);

		printf("Power keylight on for 10 seconds.");
		ioctl(light, KEYLIGHT_AUX_ON, 0);
		sleep(10);
		
		printf("Power keylight off.");
		ioctl(light, KEYLIGHT_AUX_OFF, 0);
		
		close(light);
		return 0;
}

