Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7477
b: refs/heads/master
c: 948e12f
h: refs/heads/master
i:
  7475: 0ae6477
v: v3
  • Loading branch information
Richard Purdie authored and Linus Torvalds committed Sep 7, 2005
1 parent f4fc83d commit e42a301
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8240a4a4bc95814502da522d5ee929fe0f0dc679
refs/heads/master: 948e12f0bd51db439659fed857971e22fbdd7527
61 changes: 28 additions & 33 deletions trunk/drivers/input/keyboard/corgikbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/* zero code, 124 scancodes + 3 hinge combinations */
#define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 +3 )
#define SCAN_INTERVAL (HZ/10)
#define CORGIKBD_PRESSED 1

#define HINGE_SCAN_INTERVAL (HZ/4)

Expand Down Expand Up @@ -74,32 +73,14 @@ struct corgikbd {
struct input_dev input;
char phys[32];

unsigned char state[ARRAY_SIZE(corgikbd_keycode)];
spinlock_t lock;

struct timer_list timer;
struct timer_list htimer;

unsigned int suspended;
unsigned long suspend_jiffies;
};

static void handle_scancode(unsigned int pressed,unsigned int scancode, struct corgikbd *corgikbd_data)
{
if (pressed && !(corgikbd_data->state[scancode] & CORGIKBD_PRESSED)) {
corgikbd_data->state[scancode] |= CORGIKBD_PRESSED;
input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], 1);
if ((corgikbd_data->keycode[scancode] == CORGI_KEY_OFF)
&& time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) {
input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1);
corgikbd_data->suspend_jiffies=jiffies;
}
} else if (!pressed && corgikbd_data->state[scancode] & CORGIKBD_PRESSED) {
corgikbd_data->state[scancode] &= ~CORGIKBD_PRESSED;
input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], 0);
}
}

#define KB_DISCHARGE_DELAY 10
#define KB_ACTIVATE_DELAY 10

Expand All @@ -112,36 +93,36 @@ static void handle_scancode(unsigned int pressed,unsigned int scancode, struct c
*/
static inline void corgikbd_discharge_all(void)
{
// STROBE All HiZ
/* STROBE All HiZ */
GPCR2 = CORGI_GPIO_ALL_STROBE_BIT;
GPDR2 &= ~CORGI_GPIO_ALL_STROBE_BIT;
}

static inline void corgikbd_activate_all(void)
{
// STROBE ALL -> High
/* STROBE ALL -> High */
GPSR2 = CORGI_GPIO_ALL_STROBE_BIT;
GPDR2 |= CORGI_GPIO_ALL_STROBE_BIT;

udelay(KB_DISCHARGE_DELAY);

// Clear any interrupts we may have triggered when altering the GPIO lines
/* Clear any interrupts we may have triggered when altering the GPIO lines */
GEDR1 = CORGI_GPIO_HIGH_SENSE_BIT;
GEDR2 = CORGI_GPIO_LOW_SENSE_BIT;
}

static inline void corgikbd_activate_col(int col)
{
// STROBE col -> High, not col -> HiZ
/* STROBE col -> High, not col -> HiZ */
GPSR2 = CORGI_GPIO_STROBE_BIT(col);
GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col);
}

static inline void corgikbd_reset_col(int col)
{
// STROBE col -> Low
/* STROBE col -> Low */
GPCR2 = CORGI_GPIO_STROBE_BIT(col);
// STROBE col -> out, not col -> HiZ
/* STROBE col -> out, not col -> HiZ */
GPDR2 = (GPDR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(col);
}

Expand All @@ -156,7 +137,7 @@ static inline void corgikbd_reset_col(int col)
/* Scan the hardware keyboard and push any changes up through the input layer */
static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs *regs)
{
unsigned int row, col, rowd, scancode;
unsigned int row, col, rowd;
unsigned long flags;
unsigned int num_pressed;

Expand All @@ -183,10 +164,21 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs

rowd = GET_ROWS_STATUS(col);
for (row = 0; row < KB_ROWS; row++) {
unsigned int scancode, pressed;

scancode = SCANCODE(row, col);
handle_scancode((rowd & KB_ROWMASK(row)), scancode, corgikbd_data);
if (rowd & KB_ROWMASK(row))
pressed = rowd & KB_ROWMASK(row);

input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], pressed);

if (pressed)
num_pressed++;

if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF)
&& time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) {
input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1);
corgikbd_data->suspend_jiffies=jiffies;
}
}
corgikbd_reset_col(col);
}
Expand Down Expand Up @@ -231,8 +223,11 @@ static void corgikbd_timer_callback(unsigned long data)
* The hinge switches generate no interrupt so they need to be
* monitored by a timer.
*
* When we detect changes, we debounce it and then pass the three
* positions the system can take as keypresses to the input system.
* We debounce the switches and pass them to the input system.
*
* gprr == 0x00 - Keyboard with Landscape Screen
* 0x08 - No Keyboard with Portrait Screen
* 0x0c - Keyboard and Screen Closed
*/

#define HINGE_STABLE_COUNT 2
Expand All @@ -254,9 +249,9 @@ static void corgikbd_hinge_timer(unsigned long data)
if (hinge_count >= HINGE_STABLE_COUNT) {
spin_lock_irqsave(&corgikbd_data->lock, flags);

handle_scancode((sharpsl_hinge_state == 0x00), 125, corgikbd_data); /* Keyboard with Landscape Screen */
handle_scancode((sharpsl_hinge_state == 0x08), 126, corgikbd_data); /* No Keyboard with Portrait Screen */
handle_scancode((sharpsl_hinge_state == 0x0c), 127, corgikbd_data); /* Keyboard and Screen Closed */
input_report_key(&corgikbd_data->input, corgikbd_data->keycode[125], (sharpsl_hinge_state == 0x00));
input_report_key(&corgikbd_data->input, corgikbd_data->keycode[126], (sharpsl_hinge_state == 0x08));
input_report_key(&corgikbd_data->input, corgikbd_data->keycode[127], (sharpsl_hinge_state == 0x0c));
input_sync(&corgikbd_data->input);

spin_unlock_irqrestore(&corgikbd_data->lock, flags);
Expand Down

0 comments on commit e42a301

Please sign in to comment.