/* Typically we're done in fewer than 10 iterations */ #define LOOP_TIMEOUT 1000
staticvoid fm07keys_poll(struct input_dev *input)
{
uint8_t k; int i;
/* Flush output buffer */
i = 0; while (inb(PORT_CMD) & 0x01) { if (++i >= LOOP_TIMEOUT) goto timeout;
inb(PORT_DATA);
}
/* Send request and wait for write completion */
outb(EC_CMD_READ, PORT_CMD);
i = 0; while (inb(PORT_CMD) & 0x02) if (++i >= LOOP_TIMEOUT) goto timeout;
outb(EC_ADDR_KEYS, PORT_DATA);
i = 0; while (inb(PORT_CMD) & 0x02) if (++i >= LOOP_TIMEOUT) goto timeout;
/* Wait for data ready */
i = 0; while (!(inb(PORT_CMD) & 0x01)) if (++i >= LOOP_TIMEOUT) goto timeout;
k = inb(PORT_DATA);
/* Notify of new key states */ for (i = 0; i < NUM_KEYS; i++) {
input_report_key(input, BASE_KEY + i, (~k) & 1);
k >>= 1;
}
for (i = 0; i < NUM_KEYS; i++)
__set_bit(BASE_KEY + i, input->keybit);
ret = input_setup_polling(input, fm07keys_poll); if (ret) {
dev_err(dev, "unable to set up polling, err=%d\n", ret); return ret;
}
/* These are silicone buttons. They can't be pressed in rapid * succession too quickly, and 50 Hz seems to be an adequate * sampling rate without missing any events when tested.
*/
input_set_poll_interval(input, 20);
ret = input_register_device(input); if (ret) {
dev_err(dev, "unable to register polled device, err=%d\n",
ret); return ret;
}
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.