/* * The LoCoMo keyboard only generates interrupts when a key is pressed. * So when a key is pressed, we enable a timer. This timer scans the * keyboard, and this is how we detect when the key is released.
*/
/* Scan the hardware keyboard and push any changes up through the input layer */ staticvoid locomokbd_scankeyboard(struct locomokbd *locomokbd)
{ unsignedint row, col, rowd; unsignedint num_pressed; unsignedlong membase = locomokbd->base;
guard(spinlock_irqsave)(&locomokbd->lock);
locomokbd_charge_all(membase);
num_pressed = 0; for (col = 0; col < KB_COLS; col++) {
input_report_key(locomokbd->input, key, pressed); if (likely(!pressed)) continue;
num_pressed++;
/* The "Cancel/ESC" key is labeled "On/Off" on * Collie and Poodle and should suspend the device
* if it was pressed for more than a second. */ if (unlikely(key == KEY_ESC)) { if (!time_after(jiffies,
locomokbd->suspend_jiffies + HZ)) continue; if (locomokbd->count_cancel++
!= (HZ/SCAN_INTERVAL + 1)) continue;
input_event(locomokbd->input, EV_PWR,
KEY_SUSPEND, 1);
locomokbd->suspend_jiffies = jiffies;
} else
locomokbd->count_cancel = 0;
}
locomokbd_reset_col(membase, col);
}
locomokbd_activate_all(membase);
input_sync(locomokbd->input);
/* if any keys are pressed, enable the timer */ if (num_pressed)
mod_timer(&locomokbd->timer, jiffies + SCAN_INTERVAL); else
locomokbd->count_cancel = 0;
}
memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); for (i = 0; i < LOCOMOKBD_NUMKEYS; i++)
set_bit(locomokbd->keycode[i], input_dev->keybit);
clear_bit(0, input_dev->keybit);
/* attempt to get the interrupt */
err = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); if (err) {
printk(KERN_ERR "locomokbd: Can't get irq for keyboard\n"); goto err_release_region;
}
err = input_register_device(locomokbd->input); if (err) goto err_free_irq;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.