[BACK]Return to keypad.c CVS log [TXT][DIR] Up to [local] / prex-old / dev / arm / gba

Diff for /prex-old/dev/arm/gba/keypad.c between version 1.1.1.1 and 1.1.1.1.2.1

version 1.1.1.1, 2008/06/03 10:38:41 version 1.1.1.1.2.1, 2008/08/13 17:12:22
Line 33 
Line 33 
   
 #include <driver.h>  #include <driver.h>
 #include <prex/keycode.h>  #include <prex/keycode.h>
   #include "keypad.h"
   
 /* Parameters */  /* Parameters */
 #define KEYQ_SIZE       32  #define KEYQ_SIZE       32
Line 105 
Line 106 
 #define KEY_MAX (sizeof(key_map) / sizeof(u_char))  #define KEY_MAX (sizeof(key_map) / sizeof(u_char))
   
 static device_t keypad_dev;     /* Device object */  static device_t keypad_dev;     /* Device object */
 static int keypad_irq;          /* Handle for keyboard irq */  static irq_t keypad_irq;        /* Handle for keyboard irq */
 static int nr_open;             /* Open count */  static int nr_open;             /* Open count */
 static struct event io_event = EVENT_INIT(io_event, "keypad");  static struct event keypad_event;
   
 static u_char keyq[KEYQ_SIZE];  /* Queue for ascii character */  static u_char keyq[KEYQ_SIZE];  /* Queue for ascii character */
 static int q_tail;  static int q_tail;
Line 133 
Line 134 
         if (input_handler)          if (input_handler)
                 input_handler(c);                  input_handler(c);
         else {          else {
                 sched_wakeup(&io_event);                  sched_wakeup(&keypad_event);
                 if (keyq_full())                  if (keyq_full())
                         return;                          return;
                 keyq[q_tail] = c;                  keyq[q_tail] = c;
Line 227 
Line 228 
 static int  static int
 keypad_read(device_t dev, char *buf, size_t *nbyte, int blkno)  keypad_read(device_t dev, char *buf, size_t *nbyte, int blkno)
 {  {
         int rc;          int rc, c;
         size_t count;          size_t count;
   
         if (input_handler)          if (input_handler)
Line 235 
Line 236 
         if (*nbyte == 0)          if (*nbyte == 0)
                 return 0;                  return 0;
         if (keyq_empty()) {          if (keyq_empty()) {
                 rc = sched_sleep(&io_event);                  rc = sched_sleep(&keypad_event);
                 if (rc == SLP_INTR)                  if (rc == SLP_INTR)
                         return EINTR;                          return EINTR;
         }          }
         for (count = 0; count < *nbyte; count++) {          for (count = 0; count < *nbyte; count++) {
                 if (keyq_empty())                  if (keyq_empty())
                         break;                          break;
                 *buf = keyq_dequeue();                  c = keyq_dequeue();
                   if (umem_copyout(&c, buf, 1))
                           return EFAULT;
                 buf++;                  buf++;
         }          }
         *nbyte = count;          *nbyte = count;
Line 273 
Line 276 
         keypad_dev = device_create(&keypad_io, "keypad", DF_CHR);          keypad_dev = device_create(&keypad_io, "keypad", DF_CHR);
         ASSERT(keypad_dev);          ASSERT(keypad_dev);
   
           event_init(&keypad_event, "keypad");
   
         /* Disable keypad interrupt */          /* Disable keypad interrupt */
         REG_KEYCNT = 0;          REG_KEYCNT = 0;
   
         /* Setup isr */          /* Setup isr */
         keypad_irq = irq_attach(KEYPAD_IRQ, IPL_INPUT, 0, keypad_isr, NULL);          keypad_irq = irq_attach(KEYPAD_IRQ, IPL_INPUT, 0, keypad_isr, NULL);
         ASSERT(keypad_irq != -1);          ASSERT(keypad_irq != IRQ_NULL);
   
         /* Enable interrupt for all key */          /* Enable interrupt for all key */
         REG_KEYCNT = KEY_ALL | KEYIRQ_EN;          REG_KEYCNT = KEY_ALL | KEYIRQ_EN;

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.1.2.1

CVSweb