Outputs x8..x0 of the qt2160 can have leds attached to it. This patch handles those outputs using EV_LED events. Signed-off-by: Javier Martin <javier.martin@xxxxxxxxxxxxxxxxx> --- drivers/input/keyboard/qt2160.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c index 73ea4b0..7070372 100644 --- a/drivers/input/keyboard/qt2160.c +++ b/drivers/input/keyboard/qt2160.c @@ -39,6 +39,7 @@ #define QT2160_CMD_GPIOS 6 #define QT2160_CMD_SUBVER 7 #define QT2160_CMD_CALIBRATE 10 +#define QT2160_CMD_LEDS 70 #define QT2160_CYCLE_INTERVAL (2*HZ) @@ -217,6 +218,30 @@ static int __devinit qt2160_write(struct i2c_client *client, u8 reg, u8 data) return ret; } +static int qt2160_event(struct input_dev *dev, + unsigned int type, unsigned int code, int value) +{ + struct qt2160_data *qt2160 = input_get_drvdata(dev); + struct i2c_client *client = qt2160->client; + u32 val; + + switch (type) { + case EV_LED: + val = qt2160_read(qt2160->client, QT2160_CMD_LEDS); + if (value) + val |= (1 << code); + else + val &= ~(1 << code); + qt2160_write(qt2160->client, QT2160_CMD_LEDS, val); + break; + default: + dev_err(&client->dev, "%s: Got type %d, code %d, value %d\n", + __func__, type, code, value); + return -1; + } + + return 0; +} static bool __devinit qt2160_identify(struct i2c_client *client) { @@ -290,8 +315,21 @@ static int __devinit qt2160_probe(struct i2c_client *client, input->keycodesize = sizeof(qt2160->keycodes[0]); input->keycodemax = ARRAY_SIZE(qt2160_key2code); + input->event = qt2160_event; + + input_set_drvdata(input, qt2160); + __set_bit(EV_KEY, input->evbit); __clear_bit(EV_REP, input->evbit); + __set_bit(EV_LED, input->evbit); + __set_bit(LED_NUML, input->ledbit); + __set_bit(LED_CAPSL, input->ledbit); + __set_bit(LED_SCROLLL, input->ledbit); + __set_bit(LED_COMPOSE, input->ledbit); + __set_bit(LED_KANA, input->ledbit); + __set_bit(LED_SLEEP, input->ledbit); + __set_bit(LED_SUSPEND, input->ledbit); + __set_bit(LED_MUTE, input->ledbit); for (i = 0; i < ARRAY_SIZE(qt2160_key2code); i++) { qt2160->keycodes[i] = qt2160_key2code[i]; __set_bit(qt2160_key2code[i], input->keybit); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html