forked from Minki/linux
Input: lkkbd - miscellaneous fixes
* Hide debugging code into #ifdef, which allows to simplify the large switch statement * Update macros to not reference variables not given as arguments Signed-off-by: Jan-Benedict Glaw <jbglaw@lug-owl.de> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
14a48b4444
commit
0aeafa7755
@ -273,11 +273,11 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = {
|
||||
[0xfb] = KEY_APOSTROPHE,
|
||||
};
|
||||
|
||||
#define CHECK_LED(LED, BITS) do { \
|
||||
if (test_bit (LED, lk->dev->led)) \
|
||||
leds_on |= BITS; \
|
||||
else \
|
||||
leds_off |= BITS; \
|
||||
#define CHECK_LED(LK, VAR_ON, VAR_OFF, LED, BITS) do { \
|
||||
if (test_bit (LED, (LK)->dev->led)) \
|
||||
VAR_ON |= BITS; \
|
||||
else \
|
||||
VAR_OFF |= BITS; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
@ -298,6 +298,42 @@ struct lkkbd {
|
||||
int ctrlclick_volume;
|
||||
};
|
||||
|
||||
#ifdef LKKBD_DEBUG
|
||||
/*
|
||||
* Responses from the keyboard and mapping back to their names.
|
||||
*/
|
||||
static struct {
|
||||
unsigned char value;
|
||||
unsigned char *name;
|
||||
} lk_response[] = {
|
||||
#define RESPONSE(x) { .value = (x), .name = #x, }
|
||||
RESPONSE (LK_STUCK_KEY),
|
||||
RESPONSE (LK_SELFTEST_FAILED),
|
||||
RESPONSE (LK_ALL_KEYS_UP),
|
||||
RESPONSE (LK_METRONOME),
|
||||
RESPONSE (LK_OUTPUT_ERROR),
|
||||
RESPONSE (LK_INPUT_ERROR),
|
||||
RESPONSE (LK_KBD_LOCKED),
|
||||
RESPONSE (LK_KBD_TEST_MODE_ACK),
|
||||
RESPONSE (LK_PREFIX_KEY_DOWN),
|
||||
RESPONSE (LK_MODE_CHANGE_ACK),
|
||||
RESPONSE (LK_RESPONSE_RESERVED),
|
||||
#undef RESPONSE
|
||||
};
|
||||
|
||||
static unsigned char *
|
||||
response_name (unsigned char value)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (lk_response); i++)
|
||||
if (lk_response[i].value == value)
|
||||
return lk_response[i].name;
|
||||
|
||||
return "<unknown>";
|
||||
}
|
||||
#endif /* LKKBD_DEBUG */
|
||||
|
||||
/*
|
||||
* Calculate volume parameter byte for a given volume.
|
||||
*/
|
||||
@ -440,38 +476,7 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
|
||||
input_report_key (lk->dev, lk->keycode[i], 0);
|
||||
input_sync (lk->dev);
|
||||
break;
|
||||
case LK_METRONOME:
|
||||
DBG (KERN_INFO "Got LK_METRONOME and don't "
|
||||
"know how to handle...\n");
|
||||
break;
|
||||
case LK_OUTPUT_ERROR:
|
||||
DBG (KERN_INFO "Got LK_OUTPUT_ERROR and don't "
|
||||
"know how to handle...\n");
|
||||
break;
|
||||
case LK_INPUT_ERROR:
|
||||
DBG (KERN_INFO "Got LK_INPUT_ERROR and don't "
|
||||
"know how to handle...\n");
|
||||
break;
|
||||
case LK_KBD_LOCKED:
|
||||
DBG (KERN_INFO "Got LK_KBD_LOCKED and don't "
|
||||
"know how to handle...\n");
|
||||
break;
|
||||
case LK_KBD_TEST_MODE_ACK:
|
||||
DBG (KERN_INFO "Got LK_KBD_TEST_MODE_ACK and don't "
|
||||
"know how to handle...\n");
|
||||
break;
|
||||
case LK_PREFIX_KEY_DOWN:
|
||||
DBG (KERN_INFO "Got LK_PREFIX_KEY_DOWN and don't "
|
||||
"know how to handle...\n");
|
||||
break;
|
||||
case LK_MODE_CHANGE_ACK:
|
||||
DBG (KERN_INFO "Got LK_MODE_CHANGE_ACK and ignored "
|
||||
"it properly...\n");
|
||||
break;
|
||||
case LK_RESPONSE_RESERVED:
|
||||
DBG (KERN_INFO "Got LK_RESPONSE_RESERVED and don't "
|
||||
"know how to handle...\n");
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
DBG (KERN_INFO "Got 0x01, scheduling re-initialization\n");
|
||||
lk->ignore_bytes = LK_NUM_IGNORE_BYTES;
|
||||
@ -479,6 +484,18 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
|
||||
schedule_work (&lk->tq);
|
||||
break;
|
||||
|
||||
case LK_METRONOME:
|
||||
case LK_OUTPUT_ERROR:
|
||||
case LK_INPUT_ERROR:
|
||||
case LK_KBD_LOCKED:
|
||||
case LK_KBD_TEST_MODE_ACK:
|
||||
case LK_PREFIX_KEY_DOWN:
|
||||
case LK_MODE_CHANGE_ACK:
|
||||
case LK_RESPONSE_RESERVED:
|
||||
DBG (KERN_INFO "Got %s and don't know how to handle...\n",
|
||||
response_name (data));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (lk->keycode[data] != KEY_RESERVED) {
|
||||
input_regs (lk->dev, regs);
|
||||
@ -509,10 +526,10 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code,
|
||||
|
||||
switch (type) {
|
||||
case EV_LED:
|
||||
CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
|
||||
CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
|
||||
CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
|
||||
CHECK_LED (LED_SLEEP, LK_LED_WAIT);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
|
||||
if (leds_on != 0) {
|
||||
lk->serio->write (lk->serio, LK_CMD_LED_ON);
|
||||
lk->serio->write (lk->serio, leds_on);
|
||||
@ -574,10 +591,10 @@ lkkbd_reinit (void *data)
|
||||
lk->serio->write (lk->serio, LK_CMD_SET_DEFAULTS);
|
||||
|
||||
/* Set LEDs */
|
||||
CHECK_LED (LED_CAPSL, LK_LED_SHIFTLOCK);
|
||||
CHECK_LED (LED_COMPOSE, LK_LED_COMPOSE);
|
||||
CHECK_LED (LED_SCROLLL, LK_LED_SCROLLLOCK);
|
||||
CHECK_LED (LED_SLEEP, LK_LED_WAIT);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_CAPSL, LK_LED_SHIFTLOCK);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_COMPOSE, LK_LED_COMPOSE);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_SCROLLL, LK_LED_SCROLLLOCK);
|
||||
CHECK_LED (lk, leds_on, leds_off, LED_SLEEP, LK_LED_WAIT);
|
||||
if (leds_on != 0) {
|
||||
lk->serio->write (lk->serio, LK_CMD_LED_ON);
|
||||
lk->serio->write (lk->serio, leds_on);
|
||||
|
Loading…
Reference in New Issue
Block a user