Ejemplo n.º 1
0
// Proc for accessing quick control of aotom (by skl)
// String format: fxy
// f is "l" (for led) or "i" (for icons)
// x is 0/1 and indicates if the led/icon must be off or on
// y is the led/icon number (between 0 and LASTLED-1 for leds; between 1 and 46, for icons, with y==46, all the icons are set)
static int aotom_write(struct file *file, const char __user *buf, unsigned long count, void *data)
{
	char *page;
	int which, on;
	int ret = -ENOMEM;

	page = (char *)__get_free_page(GFP_KERNEL);
	if (page)
	{
		ret = -EFAULT;

		if (copy_from_user(page, buf, count) == 0)
		{
			page[count - 1] = '\0';

			if (count > 3)
			{
				which = (int)simple_strtol(page + 2, NULL, 10);
				on = (page[1] == '0') ? 0 : 1;

				switch (page[0])
				{
					case 'l':
					{
						if ((which >= 0) && (which < LASTLED))
						{
							YWPANEL_FP_SetLed(which, on);
						}
						break;
					}
					case 'i':
					{
						if (which == ICON_ALL)
						{
							VFD_set_all_icons(on);
						}
						else if ((fp_type == FP_VFD && ((which >= ICON_FIRST) && (which <= ICON_SPINNER)))
						|| (fp_type == FP_DVFD && ((which >= ICON_SPINNER) && (which <= DICON_LAST))))
						{
							aotomSetIcon(which, on);
						}
						break;
					}
				}
			}
			ret = count;
		}
		free_page((unsigned long)page);
	}
	return ret;
}
Ejemplo n.º 2
0
int aotomSetIcon(int which, int on)
{
	int  res = 0;

	dprintk(5, "%s > %d, %d\n", __func__, which, on);
	if (which < 1 || which > 46)
	{
		printk("VFD/AOTOM icon number out of range %d\n", which);
		return -EINVAL;
	}

	if (which == 46) {
		VFD_set_all_icons(on);
	}
	else {
		which-=1;
		res = VFD_Show_Icon(((which/15)+11)*16+(which%15)+1, on);
	}


	dprintk(10, "%s <\n", __func__);

	return res;
}
Ejemplo n.º 3
0
static int AOTOMdev_ioctl(struct inode *Inode, struct file *File, unsigned int cmd, unsigned long arg)
{
	static int mode = 0;
	int res = -EINVAL;
	dprintk(5, "%s > 0x%.8x\n", __func__, cmd);

	if(down_interruptible (&write_sem))
		return -ERESTARTSYS;

	switch(cmd) {
	case VFDSETMODE:
	case VFDSETLED:
	case VFDICONDISPLAYONOFF:
	case VFDSETTIME:
	case VFDBRIGHTNESS:
	case VFDGETSTBYKEY:
	case VFDSETSTBYKEY:
	case VFDGETBLUEKEY:
	case VFDSETBLUEKEY:
		if (copy_from_user(&aotom_data, (void *) arg, sizeof(aotom_data)))
			return -EFAULT;
	}

	switch(cmd) {
	case VFDSETMODE:
		mode = aotom_data.u.mode.compat;
		break;
	case VFDSETLED:
		if (aotom_data.u.led.led_nr > -1 && aotom_data.u.led.led_nr < LED_MAX) {
			switch (aotom_data.u.led.on) {
			case LOG_OFF:
			case LOG_ON:
				res = YWPANEL_VFD_SetLed(aotom_data.u.led.led_nr, aotom_data.u.led.on);
				led_state[aotom_data.u.led.led_nr].state = aotom_data.u.led.on;
				break;
			default: // toggle for aotom_data.u.led.on * 10 ms
				flashLED(aotom_data.u.led.led_nr, aotom_data.u.led.on * 10);
				res = 0;
			}
		}
		break;
	case VFDBRIGHTNESS:
		if (aotom_data.u.brightness.level < 0)
			aotom_data.u.brightness.level = 0;
		else if (aotom_data.u.brightness.level > 7)
			aotom_data.u.brightness.level = 7;
		res = YWPANEL_VFD_SetBrightness(aotom_data.u.brightness.level);
		break;
	case VFDICONDISPLAYONOFF:
		switch (panel_version.DisplayInfo) {
		case YWPANEL_FP_DISPTYPE_LED:
			switch (aotom_data.u.icon.icon_nr) {
			case 0:
				res = YWPANEL_VFD_SetLed(LED_RED, aotom_data.u.icon.on);
				led_state[LED_RED].state = aotom_data.u.icon.on;
				break;
			case 35:
				res = YWPANEL_VFD_SetLed(LED_GREEN, aotom_data.u.icon.on);
				led_state[LED_GREEN].state = aotom_data.u.icon.on;
				break;
			case 46:
				led_state[LED_RED].state = aotom_data.u.icon.on;
				led_state[LED_GREEN].state = aotom_data.u.icon.on;
				YWPANEL_VFD_SetLed(LED_RED, aotom_data.u.icon.on);
				res = YWPANEL_VFD_SetLed(LED_GREEN, aotom_data.u.icon.on);
				break;
			}
			break;
			default:
			{
				int icon_nr = aotom_data.u.icon.icon_nr;
				if(icon_nr & ~0xff)
				{
					icon_nr >>= 8;
					switch (icon_nr)
					{
					case 0x11:
						icon_nr = 0x0E; //widescreen
						break;
					case 0x13:
						icon_nr = 0x0B; //CA
						break;
					case 0x15:
						icon_nr = 0x19; //mp3
						break;
					case 0x17:
						icon_nr = 0x1A; //ac3
						break;
					case 0x1A:
						icon_nr = 0x03; //play
						break;
					case 0x1e:
						icon_nr = 0x07; //record
						break;
					case 38:
						break; //cd part1
					case 39:
						break; //cd part2
					case 40:
						break; //cd part3
					case 41:
						break; //cd part4
					default:
						icon_nr = -1; //no additional symbols at the moment
						break;
					}
				}
				switch (icon_nr)
				{
				case 46:
					VFD_set_all_icons(aotom_data.u.icon.on);
					res = 0;
					case -1:
					break;
					default:
					res = aotomSetIcon(icon_nr, aotom_data.u.icon.on);
				}
			}
			mode = 0;
			break;
		}
		break;
	case VFDSETPOWERONTIME:
	{
		u32 uTime = 0;
		get_user(uTime, (int *) arg);
		YWPANEL_FP_SetPowerOnTime(uTime);
		res = 0;
		break;
	}
	case VFDPOWEROFF:
		clear_display();
		YWPANEL_FP_ControlTimer(true);
		YWPANEL_FP_SetCpuStatus(YWPANEL_CPUSTATE_STANDBY);
		res = 0;
		break;
	case VFDSTANDBY:
	{
		u32 uTime = 0;
		get_user(uTime, (int *) arg);
		YWPANEL_FP_SetPowerOnTime(uTime);
		clear_display();
		YWPANEL_FP_ControlTimer(true);
		YWPANEL_FP_SetCpuStatus(YWPANEL_CPUSTATE_STANDBY);
		res = 0;
		break;
	}
	case VFDSETTIME2:
	{
		u32 uTime = 0;
		res = get_user(uTime, (int *)arg);
		if (! res)
		{
			res = YWPANEL_FP_SetTime(uTime);
			YWPANEL_FP_ControlTimer(true);
		}
		break;
	}
	case VFDSETTIME:
		res = aotomSetTime(aotom_data.u.time.time);
		break;
	case VFDGETTIME:
	{
		u32 uTime = 0;
		uTime = YWPANEL_FP_GetTime();
		//printk("uTime = %d\n", uTime);
		res = put_user(uTime, (int *) arg);
		break;
	}
	case VFDDISPLAYCHARS:
		if (mode == 0)
		{
			if (copy_from_user(&vfd_data, (void *) arg, sizeof(vfd_data)))
				return -EFAULT;
			if (vfd_data.length > sizeof(vfd_data.data))
				vfd_data.length = sizeof(vfd_data.data);
			while ((vfd_data.length > 0) && (vfd_data.data[vfd_data.length - 1 ] == '\n'))
				vfd_data.length--;
				res = run_draw_thread(&vfd_data);
		} else
			mode = 0;
		break;
	case VFDDISPLAYCLR:
		vfd_data.length = 0;
		res = run_draw_thread(&vfd_data);
		break;
	case VFDGETWAKEUPMODE:
	case VFDDISPLAYWRITEONOFF:
		res = 0;
		break;
	case VFDGETSTARTUPSTATE:
	{
		YWPANEL_STARTUPSTATE_t State;
		if (YWPANEL_FP_GetStartUpState(&State))
			res = put_user(State, (int *) arg);
		break;
	}
	case VFDSETLOOPSTATE:
	{
		YWPANEL_LOOPSTATE_t State = YWPANEL_LOOPSTATE_UNKNOWN;
		res = get_user(State, (int *)arg);
		if (!res)
			res = YWPANEL_FP_SetLoopState(State);
		break;
	}
	case VFDGETLOOPSTATE:
	{
		YWPANEL_LOOPSTATE_t State;
		if (YWPANEL_FP_GetLoopState(&State))
			res = put_user(State, (int *) arg);
		break;
	}
	case VFDGETVERSION:
	{
		YWPANEL_Version_t panel_version;
		memset(&panel_version, 0, sizeof(YWPANEL_Version_t));
		if (YWPANEL_FP_GetVersion(&panel_version))
			res = put_user (panel_version.DisplayInfo, (int *)arg);
		break;
	}
	case VFDGETBLUEKEY:
	case VFDGETSTBYKEY:
	{
		if (YWPANEL_FP_GetKey(cmd == VFDGETBLUEKEY, aotom_data.u.key.key_nr, &aotom_data.u.key.key))
			res = copy_to_user((void *) arg, &aotom_data, sizeof(aotom_data));
		break;
	}
	case VFDSETBLUEKEY:
	case VFDSETSTBYKEY:
		res = !YWPANEL_FP_SetKey(cmd == VFDSETBLUEKEY, aotom_data.u.key.key_nr, aotom_data.u.key.key);
		break;
	default:
		printk("VFD/AOTOM: unknown IOCTL 0x%x\n", cmd);
	case 0x5305:
	case 0x5401:
		mode = 0;
		break;
	}
Ejemplo n.º 4
0
static void VFD_clr(void)
{
	YWPANEL_VFD_ShowTimeOff();
	clear_display();
	VFD_set_all_icons(LOG_OFF);
}
Ejemplo n.º 5
0
static int AOTOMdev_ioctl(struct inode *Inode, struct file *File, unsigned int cmd, unsigned long arg)
{
	int icon_nr = 0;
	static int mode = 0;
	int res = -EINVAL;
	dprintk(5, "%s > 0x%.8x\n", __func__, cmd);

	if(down_interruptible (&write_sem))
		return -ERESTARTSYS;

	switch(cmd) {
	case VFDSETMODE:
	case VFDSETLED:
	case VFDICONDISPLAYONOFF:
	case VFDSETTIME:
	case VFDBRIGHTNESS:
		if (copy_from_user(&aotom_data, (void *) arg, sizeof(aotom_data)))
			return -EFAULT;
	}

	switch(cmd) {
	case VFDSETMODE:
		mode = aotom_data.u.mode.compat;
		break;
	case VFDSETLED:
#if defined(SPARK) || defined(SPARK7162)
		if (aotom_data.u.led.led_nr > -1 && aotom_data.u.led.led_nr < LED_MAX) {
			switch (aotom_data.u.led.on) {
			case LOG_OFF:
			case LOG_ON:
				res = YWPANEL_VFD_SetLed(aotom_data.u.led.led_nr, aotom_data.u.led.on);
				led_state[aotom_data.u.led.led_nr].state = aotom_data.u.led.on;
				break;
			default: // toggle (for aotom_data.u.led.on * 10) ms
				flashLED(aotom_data.u.led.led_nr, aotom_data.u.led.on * 10);
			}
		}
#endif
		break;
	case VFDBRIGHTNESS:
		if (aotom_data.u.brightness.level < 0)
			aotom_data.u.brightness.level = 0;
		else if (aotom_data.u.brightness.level > 7)
			aotom_data.u.brightness.level = 7;
		res = YWPANEL_VFD_SetBrightness(aotom_data.u.brightness.level);
		break;
	case VFDICONDISPLAYONOFF:
	{
#if defined(SPARK)
		switch (aotom_data.u.icon.icon_nr) {
		case 0:
			res = YWPANEL_VFD_SetLed(LED_RED, aotom_data.u.icon.on);
			led_state[LED_RED].state = aotom_data.u.icon.on;
			break;
		case 35:
			res = YWPANEL_VFD_SetLed(LED_GREEN, aotom_data.u.icon.on);
			led_state[LED_GREEN].state = aotom_data.u.icon.on;
			break;
		default:
			break;
		}
#endif
#if defined(SPARK7162)
		icon_nr = aotom_data.u.icon.icon_nr;
		//e2 icons workarround
		//printk("icon_nr = %d\n", icon_nr);
		if (icon_nr >= 256) {
			icon_nr = icon_nr / 256;
			switch (icon_nr) {
			case 0x11:
				icon_nr = 0x0E; //widescreen
				break;
			case 0x13:
				icon_nr = 0x0B; //CA
				break;
			case 0x15:
				icon_nr = 0x19; //mp3
				break;
			case 0x17:
				icon_nr = 0x1A; //ac3
				break;
			case 0x1A:
				icon_nr = 0x03; //play
				break;
			case 0x1e:
				icon_nr = 0x07; //record
				break;
			case 38:
				break; //cd part1
			case 39:
				break; //cd part2
			case 40:
				break; //cd part3
			case 41:
				break; //cd part4
			default:
				icon_nr = 0; //no additional symbols at the moment
				break;
			}
		}
		if (aotom_data.u.icon.on != 0)
			aotom_data.u.icon.on = 1;
		if (icon_nr > 0 && icon_nr <= 45 )
			res = aotomSetIcon(icon_nr, aotom_data.u.icon.on);
		if (icon_nr == 46){
			switch (aotom_data.u.icon.on){
			case 1:
				VFD_set_all_icons();
				res = 0;
				break;
			case 0:
				VFD_clear_all_icons();
				res = 0;
				break;
			default:
				break;
			}
		}
#endif
		mode = 0;
		break;
	}

	case VFDSTANDBY:
	{
#if defined(SPARK) || defined(SPARK7162)
		u32 uTime = 0;
		get_user(uTime, (int *) arg);

		YWPANEL_FP_SetPowerOnTime(uTime);

		clear_display();
		YWPANEL_FP_ControlTimer(true);
		YWPANEL_FP_SetCpuStatus(YWPANEL_CPUSTATE_STANDBY);
		res = 0;
#endif
		break;
	}
	case VFDSETTIME2:
	{
		u32 uTime = 0;
		res = get_user(uTime, (int *)arg);
		if (! res)
		{
			res = YWPANEL_FP_SetTime(uTime);
			YWPANEL_FP_ControlTimer(true);
		}
		break;
	}
	case VFDSETTIME:
		res = aotomSetTime(aotom_data.u.time.time);
		break;
	case VFDGETTIME:
	{
#if defined(SPARK) || defined(SPARK7162)
		u32 uTime = 0;
		uTime = YWPANEL_FP_GetTime();
		//printk("uTime = %d\n", uTime);
		res = put_user(uTime, (int *) arg);
#endif
		break;
	}
	case VFDGETWAKEUPMODE:
		break;
	case VFDDISPLAYCHARS:
		if (mode == 0)
		{
			if (copy_from_user(&vfd_data, (void *) arg, sizeof(vfd_data)))
				return -EFAULT;
			if (vfd_data.length > sizeof(vfd_data.data))
				vfd_data.length = sizeof(vfd_data.data);
			while ((vfd_data.length > 0) && (vfd_data.data[vfd_data.length - 1 ] == '\n'))
				vfd_data.length--;
				res = run_draw_thread(&vfd_data);
		} else
			mode = 0;
		break;
	case VFDDISPLAYWRITEONOFF:
		break;
	case VFDDISPLAYCLR:
		vfd_data.length = 0;
		res = run_draw_thread(&vfd_data);
		break;
#if defined(SPARK)
	case 0x5305:
		res = 0;
		break;
#endif
	case 0x5401:
		res = 0;
		break;
	case VFDGETSTARTUPSTATE:
	{
		YWPANEL_STARTUPSTATE_t State;
		if (YWPANEL_FP_GetStartUpState(&State))
			res = put_user(State, (int *) arg);
		break;
	}
	case VFDGETVERSION:
	{
		YWPANEL_Version_t panel_version;
		memset(&panel_version, 0, sizeof(YWPANEL_Version_t));
		if (YWPANEL_FP_GetVersion(&panel_version))
			res = put_user (panel_version.DisplayInfo, (int *)arg);
		break;
	}

	default:
		printk("VFD/AOTOM: unknown IOCTL 0x%x\n", cmd);
		mode = 0;
		break;
	}

	up(&write_sem);

	dprintk(5, "%s <\n", __func__);
	return res;
}