Ejemplo n.º 1
0
static int rtc_read(char *page, char **start, off_t off, int count, int *eof, void *data)
{
	int len = 0;
	u32 rtc_time = YWPANEL_FP_GetTime(); // UTC

	if (NULL != page)
	{
		len = sprintf(page,"%u\n", rtc_time - rtc_offset);
	}
	return len;
}
Ejemplo n.º 2
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.º 3
0
static int AOTOMdev_ioctl(struct inode *Inode, struct file *File, unsigned int cmd, unsigned long arg)
{
    static int mode = 0;
    struct aotom_ioctl_data * aotom = (struct aotom_ioctl_data *) arg;
    int res = 0;

    dprintk(5, "%s > 0x%.8x\n", __func__, cmd);

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

    switch (cmd) {
	case VFDSETMODE:
	    mode = aotom->u.mode.compat;
	    break;
	case VFDSETLED:
	{
	    if (mode_digit != DIGITNO) res = YWPANEL_VFD_SetLed(aotom->u.led.led_nr, aotom->u.led.on);
	    break;
	}
	case VFDICONDISPLAYONOFF:
	{
//	    printk("aotom -->> %d = %d\n", aotom->u.icon.icon_nr, aotom->u.icon.on);
	    if (mode_digit == DIGIT8) {
		res = aotomSetIcon(aotom->u.icon.icon_nr, aotom->u.icon.on);
	    }
	    if (mode_digit == DIGIT4) {
		switch (aotom->u.icon.icon_nr) {
//		    case 0:
//		    {
//			struct vfd_ioctl_data * vfd = (struct vfd_ioctl_data *) arg;
//			if (5 == vfd->length) {
//			    if ((0x1e & 0xf) == vfd->data[0]) {
//				res = YWPANEL_VFD_SetLed(0, vfd->data[4]);
//			    }
//			}
//			break;
//		    }
		    case 35:
			res = YWPANEL_VFD_SetLed(1, aotom->u.led.on);
			break;
		    default:
			break;
		}
	    }
	    mode = 0;
	    break;
	}
	case VFDSTANDBY:
	{
	    if (mode_digit != DIGITNO) {
		u32 uTime = 0;
		u32 uStandByKey = 0;
		u32 uPowerOnTime = 0;
		get_user(uTime, (int *) arg);
		//printk("uTime = %d\n", uTime);

		uPowerOnTime = YWPANEL_FP_GetPowerOnTime();
		//printk("1uPowerOnTime = %d\n", uPowerOnTime);

		YWPANEL_FP_SetPowerOnTime(uTime);

		uPowerOnTime = YWPANEL_FP_GetPowerOnTime();
		//printk("2uPowerOnTime = %d\n", uPowerOnTime);
#if 0
		uStandByKey = YWPANEL_FP_GetStandByKey(0);
		printk("uStandByKey = %d\n", uStandByKey);
		uStandByKey = YWPANEL_FP_GetStandByKey(1);
		printk("uStandByKey = %d\n", uStandByKey);
		uStandByKey = YWPANEL_FP_GetStandByKey(2);
		printk("uStandByKey = %d\n", uStandByKey);
		uStandByKey = YWPANEL_FP_GetStandByKey(3);
		printk("uStandByKey = %d\n", uStandByKey);
		uStandByKey = YWPANEL_FP_GetStandByKey(4);
		printk("uStandByKey = %d\n", uStandByKey);
#endif
		YWPANEL_FP_ControlTimer(true);
		YWPANEL_FP_SetCpuStatus(0x02);
	    }
	    break;
	}
	case VFDSETTIME:
	    res = aotomSetTime((char *) arg);
	    break;
	case VFDGETTIME:
	{
	    if (mode_digit != DIGITNO) {
		u32 uTime = 0;
		char cTime[5];
		uTime = YWPANEL_FP_GetTime();
		//printk("uTime = %d\n", uTime);
		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);
	    }
	    mode = 0;
	    break;
	case VFDDISPLAYCLR:
	    vfd_data.length = 0;
	    res = run_draw_thread(&vfd_data);
	    break;
	case 0x5305:
	    if (mode_digit == DIGIT4) {
		dprintk(0, "unknown IOCTL 0x%x\n", cmd);
		mode = 0;
	    }
	    break;
	case VFDBRIGHTNESS:
	    if (mode_digit == DIGIT8) YWPANEL_VFD_SetBrightness(aotom->u.brightness.level);
	    break;
	case VFDGETWAKEUPMODE:
	case VFDDISPLAYWRITEONOFF:
	case 0x5401:
	    break;
	default:
	    dprintk(0, "unknown IOCTL 0x%x\n", cmd);
	    mode = 0;
	    break;
    }

    up(&write_sem);

    dprintk(5, "%s <\n", __func__);
    return res;
}
Ejemplo n.º 4
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;
}