Skip to content

Commit a9d6729

Browse files
bebarinodtor
authored andcommitted
HID: google: Add support for vivaldi to hid-hammer
Add support to the hammer driver to parse vivaldi keyboard layouts and expose them to userspace. This allows hammer devices to use vivaldi function row keys while also supporting the other features this driver supports, like the CBAS (chrome base attached switch) and a keyboard backlight. Signed-off-by: Stephen Boyd <swboyd@chromium.org> Tested-by: Stephen Boyd <swboyd@chromium.org> # coachz, wormdingler Link: https://lore.kernel.org/r/20220228075446.466016-5-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 33bbe04 commit a9d6729

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/hid/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ config HID_VIVALDI_COMMON
412412

413413
config HID_GOOGLE_HAMMER
414414
tristate "Google Hammer Keyboard"
415+
select HID_VIVALDI_COMMON
416+
select INPUT_VIVALDIFMAP
415417
depends on USB_HID && LEDS_CLASS && CROS_EC
416418
help
417419
Say Y here if you have a Google Hammer device.

drivers/hid/hid-google-hammer.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <linux/acpi.h>
1717
#include <linux/hid.h>
18+
#include <linux/input/vivaldi-fmap.h>
1819
#include <linux/leds.h>
1920
#include <linux/module.h>
2021
#include <linux/of.h>
@@ -25,6 +26,7 @@
2526
#include <asm/unaligned.h>
2627

2728
#include "hid-ids.h"
29+
#include "hid-vivaldi-common.h"
2830

2931
/*
3032
* C(hrome)B(ase)A(ttached)S(witch) - switch exported by Chrome EC and reporting
@@ -501,8 +503,15 @@ static void hammer_stop(void *hdev)
501503
static int hammer_probe(struct hid_device *hdev,
502504
const struct hid_device_id *id)
503505
{
506+
struct vivaldi_data *vdata;
504507
int error;
505508

509+
vdata = devm_kzalloc(&hdev->dev, sizeof(*vdata), GFP_KERNEL);
510+
if (!vdata)
511+
return -ENOMEM;
512+
513+
hid_set_drvdata(hdev, vdata);
514+
506515
error = hid_parse(hdev);
507516
if (error)
508517
return error;
@@ -598,6 +607,8 @@ static struct hid_driver hammer_driver = {
598607
.id_table = hammer_devices,
599608
.probe = hammer_probe,
600609
.remove = hammer_remove,
610+
.feature_mapping = vivaldi_feature_mapping,
611+
.input_configured = vivaldi_input_configured,
601612
.input_mapping = hammer_input_mapping,
602613
.event = hammer_event,
603614
};

0 commit comments

Comments
 (0)