mirror of https://github.com/torvalds/linux.git
HID: lg-g15: Add a lg_g15_init_input_dev() helper function
Factor the input-device setup + KEY_KBD_LCD_MENU capability setting out of lg_g15_probe() into a new lg_g15_init_input_dev() helper function. This is a preparation patch for adding support for the LCD menu keys + LCD brightness control on the Logitech Z-10 speakers (with LCD) which use the same protocol as the G15 keyboards. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
ba3e054e7a
commit
614d34f8b3
|
|
@ -709,6 +709,28 @@ static int lg_g15_register_led(struct lg_g15_data *g15, int i)
|
||||||
return devm_led_classdev_register(&g15->hdev->dev, &g15->leds[i].cdev);
|
return devm_led_classdev_register(&g15->hdev->dev, &g15->leds[i].cdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Common input device init code shared between keyboards and Z-10 speaker handling */
|
||||||
|
static void lg_g15_init_input_dev(struct hid_device *hdev, struct input_dev *input,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
input->name = name;
|
||||||
|
input->phys = hdev->phys;
|
||||||
|
input->uniq = hdev->uniq;
|
||||||
|
input->id.bustype = hdev->bus;
|
||||||
|
input->id.vendor = hdev->vendor;
|
||||||
|
input->id.product = hdev->product;
|
||||||
|
input->id.version = hdev->version;
|
||||||
|
input->dev.parent = &hdev->dev;
|
||||||
|
input->open = lg_g15_input_open;
|
||||||
|
input->close = lg_g15_input_close;
|
||||||
|
|
||||||
|
/* Keys below the LCD, intended for controlling a menu on the LCD */
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
|
input_set_capability(input, EV_KEY, KEY_KBD_LCD_MENU1 + i);
|
||||||
|
}
|
||||||
|
|
||||||
static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||||
{
|
{
|
||||||
u8 gkeys_settings_output_report = 0;
|
u8 gkeys_settings_output_report = 0;
|
||||||
|
|
@ -751,6 +773,8 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||||
|
|
||||||
g15->hdev = hdev;
|
g15->hdev = hdev;
|
||||||
g15->model = id->driver_data;
|
g15->model = id->driver_data;
|
||||||
|
g15->input = input;
|
||||||
|
input_set_drvdata(input, hdev);
|
||||||
hid_set_drvdata(hdev, (void *)g15);
|
hid_set_drvdata(hdev, (void *)g15);
|
||||||
|
|
||||||
switch (g15->model) {
|
switch (g15->model) {
|
||||||
|
|
@ -822,16 +846,7 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||||
goto error_hw_stop;
|
goto error_hw_stop;
|
||||||
|
|
||||||
/* Setup and register input device */
|
/* Setup and register input device */
|
||||||
input->name = "Logitech Gaming Keyboard Gaming Keys";
|
lg_g15_init_input_dev(hdev, input, "Logitech Gaming Keyboard Gaming Keys");
|
||||||
input->phys = hdev->phys;
|
|
||||||
input->uniq = hdev->uniq;
|
|
||||||
input->id.bustype = hdev->bus;
|
|
||||||
input->id.vendor = hdev->vendor;
|
|
||||||
input->id.product = hdev->product;
|
|
||||||
input->id.version = hdev->version;
|
|
||||||
input->dev.parent = &hdev->dev;
|
|
||||||
input->open = lg_g15_input_open;
|
|
||||||
input->close = lg_g15_input_close;
|
|
||||||
|
|
||||||
/* G-keys */
|
/* G-keys */
|
||||||
for (i = 0; i < gkeys; i++)
|
for (i = 0; i < gkeys; i++)
|
||||||
|
|
@ -842,10 +857,6 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||||
input_set_capability(input, EV_KEY, KEY_MACRO_PRESET1 + i);
|
input_set_capability(input, EV_KEY, KEY_MACRO_PRESET1 + i);
|
||||||
input_set_capability(input, EV_KEY, KEY_MACRO_RECORD_START);
|
input_set_capability(input, EV_KEY, KEY_MACRO_RECORD_START);
|
||||||
|
|
||||||
/* Keys below the LCD, intended for controlling a menu on the LCD */
|
|
||||||
for (i = 0; i < 5; i++)
|
|
||||||
input_set_capability(input, EV_KEY, KEY_KBD_LCD_MENU1 + i);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* On the G510 only report headphone and mic mute keys when *not* using
|
* On the G510 only report headphone and mic mute keys when *not* using
|
||||||
* the builtin USB audio device. When the builtin audio is used these
|
* the builtin USB audio device. When the builtin audio is used these
|
||||||
|
|
@ -857,9 +868,6 @@ static int lg_g15_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||||
input_set_capability(input, EV_KEY, KEY_F20);
|
input_set_capability(input, EV_KEY, KEY_F20);
|
||||||
}
|
}
|
||||||
|
|
||||||
g15->input = input;
|
|
||||||
input_set_drvdata(input, hdev);
|
|
||||||
|
|
||||||
ret = input_register_device(input);
|
ret = input_register_device(input);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error_hw_stop;
|
goto error_hw_stop;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue