static void intrpt_routine(struct work_struct *unused) { static u32 psu_status = 1; // default high, psu fail 時會 low u8 val = 0; if ((board_idx != 4) && (board_idx != 5) && (board_idx != 6)){ val = PCH_6_gpio_read_bit(57); // PSU_FAIL gpio if(psu_status != val) { // default high, psu fail 時會 low if(val == 1) { sprintf(Message, "PSU_FAIL OFF\n"); } else { sprintf(Message, "PSU_FAIL ON\n"); } psu_status = val; wake_up_interruptible(&thecus_event_queue); } } if(PCH_6_gpio_read_bit(72)==0) { // mute button kd_mksound(0 * 440, 0); keep_BUZZER = BUZZER_OFF; } // If cleanup wants us to die if (module_die == 0) queue_delayed_work(my_workqueue, &Task, dyn_work_queue_timer); }
int speakup_thread(void *data) { unsigned long flags; int should_break; struct bleep our_sound; our_sound.active = 0; our_sound.freq = 0; our_sound.jiffies = 0; mutex_lock(&spk_mutex); while (1) { DEFINE_WAIT(wait); while (1) { spin_lock_irqsave(&speakup_info.spinlock, flags); our_sound = spk_unprocessed_sound; spk_unprocessed_sound.active = 0; prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); should_break = kthread_should_stop() || our_sound.active || (synth && synth->catch_up && synth->alive && (speakup_info.flushing || !synth_buffer_empty())); spin_unlock_irqrestore(&speakup_info.spinlock, flags); if (should_break) break; mutex_unlock(&spk_mutex); schedule(); mutex_lock(&spk_mutex); } finish_wait(&speakup_event, &wait); if (kthread_should_stop()) break; if (our_sound.active) kd_mksound(our_sound.freq, our_sound.jiffies); if (synth && synth->catch_up && synth->alive) { /* It is up to the callee to take the lock, so that it * can sleep whenever it likes */ synth->catch_up(synth); } speakup_start_ttys(); } mutex_unlock(&spk_mutex); return 0; }
static void beep(unsigned int freq) { if (sound) kd_mksound(freq, HZ/10); }
static ssize_t proc_thecus_io_write(struct file *file, const char __user * buf, size_t length, loff_t * ppos) { char *buffer, buf1[20]; int i, err, v1, v2; u8 val; if (!buf || length > PAGE_SIZE) return -EINVAL; err = -ENOMEM; buffer = (char *) __get_free_page(GFP_KERNEL); if (!buffer) goto out2; err = -EFAULT; if (copy_from_user(buffer, buf, length)) goto out; err = -EINVAL; if (length < PAGE_SIZE) { buffer[length] = '\0'; #define LF 0xA if (length > 0 && buffer[length - 1] == LF) buffer[length - 1] = '\0'; } else if (buffer[PAGE_SIZE - 1]) goto out; memset(buf1, 0, sizeof(buf1)); /* * Usage: echo "S_LED 1-16 0|1|2" >/proc/thecus_io //2:Blink * LED SATA 1-16 ERROR led * Usage: echo "U_LED 0|1|2" >/proc/thecus_io //2:Blink * USB BUSY led * Usage: echo "UF_LED 0|1|2" >/proc/thecus_io //2:Blink * USB ERROR led * Usage: echo "Fail 0|1" >/proc/thecus_io * LED System Fail * Usage: echo "Busy 0|1" >/proc/thecus_io * LED System Busy * Usage: echo "Buzzer 0|1" >/proc/thecus_io * Buzzer * Usage: echo "RESET_PIC" >/proc/thecus_io * RESET_PIC */ if (!strncmp(buffer, "S_LED", strlen("S_LED"))) { i = sscanf(buffer + strlen("S_LED"), "%d %d\n", &v1, &v2); if (i == 2) //two input { if (v2 == 0) //input 0: want to turn off val = LED_OFF; else if (v2 == 1) //turn on val = LED_ON; else val = LED_BLINK1; if (v1 >= 1 && v1 <= 16) { v1 = v1 - 1; if((board_idx == 0) || (board_idx == 3) || (board_idx == 7)) { // only for N8900 back board, it's error led begin 8~15 if(v1 >= 0 && v1 <= 7) pca9532_set_led(v1+8, val); else pca9532_set_led(v1, val); } else { pca9532_set_led(v1, val); } } } } else if (!strncmp(buffer, "UF_LED", strlen("UF_LED"))) { i = sscanf(buffer + strlen("UF_LED"), "%d\n", &v1); if (i == 1) //only one input { _DBG(1, "UF_LED %d\n", v1); if (v1 == 0) //input 0: want to turn off val = LED_OFF; else if (v1 == 1) //turn on val = LED_ON; else val = LED_BLINK1; led_usb_err = val; pca9532_id_set_led(11, val); } } else if (!strncmp(buffer, "U_LED", strlen("U_LED"))) { i = sscanf(buffer + strlen("U_LED"), "%d\n", &v1); if (i == 1) //only one input { _DBG(1, "U_LED %d\n", v1); if (v1 == 0) //input 0: want to turn off val = LED_OFF; else if (v1 == 1) //turn on val = LED_ON; else val = LED_BLINK1; led_usb_busy = val; pca9532_id_set_led(12, val); } } else if (!strncmp(buffer, "PWR_LED", strlen("PWR_LED"))) { i = sscanf(buffer + strlen("PWR_LED"), "%d\n", &v1); if (i == 1) //only one input { _DBG(1, "PWR_LED %d\n", v1); if (v1 == 0) //input 0: want to turn off val = LED_OFF; else if (v1 == 1) //turn on val = LED_ON; else val = LED_BLINK1; led_sys_power = val; pca9532_id_set_led(13, val); } } else if (!strncmp(buffer, "Busy", strlen("Busy"))) { i = sscanf(buffer + strlen("Busy"), "%d\n", &v1); if (i == 1) //only one input { _DBG(1, "Busy %d\n", v1); if (v1 == 0) //input 0: want to turn off val = LED_OFF; else if (v1 == 1) //turn on val = LED_ON; else val = LED_BLINK1; led_sys_busy = val; pca9532_id_set_led(14, val); } } else if (!strncmp(buffer, "Fail", strlen("Fail"))) { i = sscanf(buffer + strlen("Fail"), "%d\n", &v1); if (i == 1) //only one input { _DBG(1, "Fail %d\n", v1); if (v1 == 0) //input 0: want to turn off val = LED_OFF; else if (v1 == 1) //turn on val = LED_ON; else val = LED_BLINK1; led_sys_err = val; pca9532_id_set_led(15, val); } /* } else if (!strncmp(buffer, "GPIO2", strlen("GPIO2"))) { i = sscanf(buffer + strlen("GPIO2"), "%d\n", &v1); if (i == 1) //only one input { printk("GPIO2 %d\n", v1); PCH_6_gpio_write_bit(2,v1); } } else if (!strncmp(buffer, "GPIO3", strlen("GPIO3"))) { i = sscanf(buffer + strlen("GPIO3"), "%d\n", &v1); if (i == 1) //only one input { printk("GPIO3 %d\n", v1); PCH_6_gpio_write_bit(3,v1); } */ } else if (!strncmp(buffer, "Buzzer", strlen("Buzzer"))) { i = sscanf(buffer + strlen("Buzzer"), "%d\n", &v1); if (i == 1) //only one input { _DBG(1, "Buzzer %d\n", v1); if (v1 == 0) //input 0: want to turn off val = BUZZER_OFF; else val = BUZZER_ON; keep_BUZZER = val; kd_mksound(val * 440, 0); } } else if (!strncmp(buffer, "RESET_PIC", strlen("RESET_PIC"))) { reset_pic(); } err = length; out: free_page((unsigned long) buffer); out2: *ppos = 0; return err; }
static int kbd_ioctl (struct inode *i, struct file *f, unsigned int cmd, unsigned long arg) { unsigned char c; unsigned char leds = 0; int value; switch (cmd){ case KIOCTYPE: /* return keyboard type */ put_user_ret(sunkbd_type, (int *) arg, -EFAULT); break; case KIOCGTRANS: put_user_ret(TR_UNTRANS_EVENT, (int *) arg, -EFAULT); break; case KIOCTRANS: get_user_ret(value, (int *) arg, -EFAULT); if (value != TR_UNTRANS_EVENT) return -EINVAL; break; case KIOCLAYOUT: put_user_ret(sunkbd_layout, (int *) arg, -EFAULT); break; case KIOCSDIRECT: #ifndef CODING_NEW_DRIVER get_user_ret(value, (int *) arg, -EFAULT); if(value) kbd_redirected = fg_console + 1; else kbd_redirected = 0; kbd_table [fg_console].kbdmode = kbd_redirected ? VC_RAW : VC_XLATE; #endif break; case KIOCCMD: get_user_ret(value, (int *) arg, -EFAULT); c = (unsigned char) value; switch (c) { case SKBDCMD_CLICK: case SKBDCMD_NOCLICK: send_cmd(c); return 0; case SKBDCMD_BELLON: kd_mksound(1,0); return 0; case SKBDCMD_BELLOFF: kd_mksound(0,0); return 0; default: return -EINVAL; } case KIOCSLED: get_user_ret(c, (unsigned char *) arg, -EFAULT); if (c & LED_SCRLCK) leds |= (1 << VC_SCROLLOCK); if (c & LED_NLOCK) leds |= (1 << VC_NUMLOCK); if (c & LED_CLOCK) leds |= (1 << VC_CAPSLOCK); compose_led_on = !!(c & LED_CMPOSE); sun_setledstate(kbd_table + fg_console, leds); break; case KIOCGLED: put_user_ret(vcleds_to_sunkbd(getleds()), (unsigned char *) arg, -EFAULT); break; case KIOCGRATE: { struct kbd_rate rate; rate.delay = kbd_delay_ticks; if (kbd_rate_ticks) rate.rate = HZ / kbd_rate_ticks; else rate.rate = 0; copy_to_user_ret((struct kbd_rate *)arg, &rate, sizeof(struct kbd_rate), -EFAULT); return 0; } case KIOCSRATE: { struct kbd_rate rate; if (verify_area(VERIFY_READ, (void *)arg, sizeof(struct kbd_rate))) return -EFAULT; copy_from_user(&rate, (struct kbd_rate *)arg, sizeof(struct kbd_rate)); if (rate.rate > 50) return -EINVAL; if (rate.rate == 0) kbd_rate_ticks = 0; else kbd_rate_ticks = HZ / rate.rate; kbd_delay_ticks = rate.delay; return 0; } case FIONREAD: /* return number of bytes in kbd queue */ { int count; count = kbd_head - kbd_tail; put_user_ret((count < 0) ? KBD_QSIZE - count : count, (int *) arg, -EFAULT); return 0; } default: printk ("Unknown Keyboard ioctl: %8.8x\n", cmd); return -EINVAL; } return 0; }