static ssize_t AOTOMdev_write(struct file *filp, const char *buff, size_t len, loff_t *off) { char* kernel_buf; int minor, vLoop, res = 0; struct vfd_ioctl_data data; dprintk(5, "%s > (len %d, offs %d)\n", __func__, len, (int) *off); minor = -1; for (vLoop = 0; vLoop < LASTMINOR; vLoop++) { if (FrontPanelOpen[vLoop].fp == filp) { minor = vLoop; } } if (minor == -1) { dprintk(0, "Error Bad Minor\n"); return -ENODEV; } dprintk(1, "minor = %d\n", minor); if (minor == FRONTPANEL_MINOR_RC) return -EOPNOTSUPP; if (down_interruptible(&write_sem)) return -ERESTARTSYS; data.length = len; if (data.length > VFD_DATA_LEN) data.length = VFD_DATA_LEN; // get rid of trailing endline. could be if echo command used if ((data.length > 0) && (buff[data.length - 1] == '\n')) data.length--; if (data.length < 0) { res = -1; dprintk(2, "empty string\n"); } else { if (copy_from_user(data.data, buff, data.length)) res = -EFAULT; else res = run_draw_thread(&data); } up(&write_sem); dprintk(10, "%s < res %d len %d\n", __func__, res, data.length); if (res < 0) return res; else return len; }
static ssize_t AOTOMdev_write(struct file *filp, const char *buff, size_t len, loff_t *off) { char* kernel_buf; int res = 0; struct vfd_ioctl_data data; dprintk(5, "%s > (len %d, offs %d)\n", __func__, len, (int) *off); //printk("buff = %s\n", buff); if (((tFrontPanelOpen *)(filp->private_data))->minor != FRONTPANEL_MINOR_VFD) { printk("Error Bad Minor\n"); return -EOPNOTSUPP; } kernel_buf = kmalloc(len + 1, GFP_KERNEL); memset(kernel_buf, 0, len + 1); memset(&data, 0, sizeof(struct vfd_ioctl_data)); if (kernel_buf == NULL) { printk("%s return no mem<\n", __func__); return -ENOMEM; } copy_from_user(kernel_buf, buff, len); if (len > sizeof(data.data)) data.length = sizeof(data.data); else data.length = len; while ((data.length > 0) && (kernel_buf[data.length - 1 ] == '\n')) data.length--; if (data.length > sizeof(data.data)) len = data.length = sizeof(data.data); memcpy(data.data, kernel_buf, data.length); res = run_draw_thread(&data); kfree(kernel_buf); dprintk(10, "%s < res %d len %d\n", __func__, res, len); if (res < 0) return res; return len; }
static ssize_t AOTOMdev_write(struct file *filp, const char *buff, size_t len, loff_t *off) { char* kernel_buf; int res = 0; struct vfd_ioctl_data data; dprintk(5, "%s > (len %d, offs %d)\n", __func__, len, (int) *off); kernel_buf = kmalloc(len, GFP_KERNEL); if (kernel_buf == NULL) { printk("%s return no mem<\n", __func__); return -ENOMEM; } copy_from_user(kernel_buf, buff, len); if (len > sizeof(data.data)) data.length = sizeof(data.data); else data.length = len; while ((data.length > 0) && (kernel_buf[data.length - 1 ] == '\n')) data.length--; if (data.length > sizeof(data.data)) len = data.length = sizeof(data.data); memcpy(data.data, kernel_buf, data.length); res = run_draw_thread(&data); kfree(kernel_buf); dprintk(10, "%s < res %d len %d\n", __func__, res, len); if (res < 0) return res; return len; }
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; }
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; }
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; }