summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2010-01-06 14:49:40 +0530
committerLaxman Dewangan <ldewangan@nvidia.com>2010-01-07 11:55:31 +0530
commit06369de60fa4746471a58d3d716483b466dbc13f (patch)
tree4a91ef3fecc055a0d5a52d86c1b92d1eb2b74b0e
parentdbfedf55361225e34b53a29c979b1ef53e53c2db (diff)
hid: add a config to force all usb keyboards to return the same name.
Registering usb keyboard as the input device with common name defined in the Kconfig variable CONFIG_USB_KEYBOARD_COMMON_NAME. This behavior is controlled by variable CONFIG_USB_KEYBOARD_USES_COMMON_NAME by setting it to y in the config files. Bug 627123 improve USB key layout support Bug 637759 [firefly2/Harmony]Caps lock of Usb keyboard is not functional. Bug 637320 [Harmony/USB_keyboard]ESC key of USB keyboard is not working. Change-id: I9e3fac88b8f4c2517af322a428892831be4ec205
-rw-r--r--arch/arm/configs/tegra_harmony_android_defconfig1
-rw-r--r--arch/arm/configs/tegra_whistler_android_defconfig1
-rw-r--r--drivers/hid/Kconfig20
-rw-r--r--drivers/hid/hid-input.c26
4 files changed, 47 insertions, 1 deletions
diff --git a/arch/arm/configs/tegra_harmony_android_defconfig b/arch/arm/configs/tegra_harmony_android_defconfig
index e628293f031a..400e2746005c 100644
--- a/arch/arm/configs/tegra_harmony_android_defconfig
+++ b/arch/arm/configs/tegra_harmony_android_defconfig
@@ -1006,6 +1006,7 @@ CONFIG_USB_HID=y
#
# Special HID drivers
#
+CONFIG_USB_KEYBOARD_USES_COMMON_NAME=y
CONFIG_HID_COMPAT=y
# CONFIG_HID_A4TECH is not set
# CONFIG_HID_APPLE is not set
diff --git a/arch/arm/configs/tegra_whistler_android_defconfig b/arch/arm/configs/tegra_whistler_android_defconfig
index 49d8788b36c8..3152524f3346 100644
--- a/arch/arm/configs/tegra_whistler_android_defconfig
+++ b/arch/arm/configs/tegra_whistler_android_defconfig
@@ -996,6 +996,7 @@ CONFIG_USB_HID=y
#
# Special HID drivers
#
+CONFIG_USB_KEYBOARD_USES_COMMON_NAME=y
CONFIG_HID_COMPAT=y
# CONFIG_HID_A4TECH is not set
# CONFIG_HID_APPLE is not set
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index e85c8fe9ffcf..67e4578155da 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -70,6 +70,26 @@ source "drivers/hid/usbhid/Kconfig"
menu "Special HID drivers"
depends on HID
+config USB_KEYBOARD_USES_COMMON_NAME
+ bool "Use a common name for all USB keyboards"
+ default n
+ depends on HID
+ ---help---
+ Enabling this option will cause the kernel to report a common name
+ for all attached USB keyboards, for userspaces which rely on the
+ keyboard name for determining run-time behavior.
+
+ If you are unsure, say N here.
+
+config USB_KEYBOARD_COMMON_NAME
+ string "Common name returned for USB keyboards"
+ depends on USB_KEYBOARD_USES_COMMON_NAME
+ default "usb_keyboard_us102"
+ ---help---
+ Set this to the name which you would like to return for USB keyboard
+ input devices. It should probably be based on the keyboard layout you
+ expect to be most often attached to your system.
+
config HID_COMPAT
bool "Load all HID drivers on hid core load"
default y
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 7f183b7147e1..40be180d97e2 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -58,6 +58,11 @@ static const struct {
__s32 y;
} hid_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
+#ifdef CONFIG_USB_KEYBOARD_USES_COMMON_NAME
+/* The name of the input driver for the usb keyboard */
+static const char *usb_keyboard_name_string = CONFIG_USB_KEYBOARD_COMMON_NAME;
+#endif
+
#define map_abs(c) hid_map_usage(hidinput, usage, &bit, &max, EV_ABS, (c))
#define map_rel(c) hid_map_usage(hidinput, usage, &bit, &max, EV_REL, (c))
#define map_key(c) hid_map_usage(hidinput, usage, &bit, &max, EV_KEY, (c))
@@ -707,9 +712,21 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
struct input_dev *input_dev;
int i, j, k;
int max_report_type = HID_OUTPUT_REPORT;
-
+#ifdef CONFIG_USB_KEYBOARD_USES_COMMON_NAME
+ int is_keyboard_type = 0;
+#endif
INIT_LIST_HEAD(&hid->inputs);
+#ifdef CONFIG_USB_KEYBOARD_USES_COMMON_NAME
+ for (i = 0; i < hid->maxcollection; i++) {
+ struct hid_collection *col = &hid->collection[i];
+ if (col->type == HID_COLLECTION_APPLICATION &&
+ (col->usage & HID_USAGE_PAGE) == HID_UP_GENDESK) {
+ is_keyboard_type = ((col->usage & 0xffff) == 0x6);
+ break;
+ }
+ }
+#endif
if (!force) {
for (i = 0; i < hid->maxcollection; i++) {
struct hid_collection *col = &hid->collection[i];
@@ -750,7 +767,14 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
input_dev->setkeycode = hidinput_setkeycode;
input_dev->getkeycode = hidinput_getkeycode;
+#ifdef CONFIG_USB_KEYBOARD_USES_COMMON_NAME
+ if (is_keyboard_type)
+ input_dev->name = usb_keyboard_name_string;
+ else
+ input_dev->name = hid->name;
+#else
input_dev->name = hid->name;
+#endif
input_dev->phys = hid->phys;
input_dev->uniq = hid->uniq;
input_dev->id.bustype = hid->bus;