Skip to content

Commit

Permalink
HID: move monterey quirks
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Slaby <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
  • Loading branch information
jirislaby authored and Jiri Kosina committed Oct 14, 2008
1 parent 1e76253 commit 3b8006e
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 38 deletions.
7 changes: 7 additions & 0 deletions drivers/hid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ config HID_MICROSOFT
Support for some Microsoft devices which breaks less or more
HID specification.

config HID_MONTEREY
tristate "Monterey"
default m
depends on USB_HID
---help---
Support for Monterey Genius KB29E.

config HID_PETALYNX
tristate "Petalynx"
default m
Expand Down
1 change: 1 addition & 0 deletions drivers/hid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o
obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o
obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o

Expand Down
1 change: 1 addition & 0 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ static const struct hid_device_id hid_blacklist[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
{ HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
{ HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },

Expand Down
3 changes: 3 additions & 0 deletions drivers/hid/hid-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ static int __init hid_dummy_init(void)
#ifdef CONFIG_HID_MICROSOFT_MODULE
HID_COMPAT_CALL_DRIVER(microsoft);
#endif
#ifdef CONFIG_HID_MONTEREY_MODULE
HID_COMPAT_CALL_DRIVER(monterey);
#endif
#ifdef CONFIG_HID_PETALYNX_MODULE
HID_COMPAT_CALL_DRIVER(petalynx);
#endif
Expand Down
23 changes: 0 additions & 23 deletions drivers/hid/hid-input-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,9 @@ static int quirk_gyration_remote(struct hid_usage *usage,
return 1;
}

static int quirk_cherry_genius_29e(struct hid_usage *usage,
struct hid_input *hidinput, unsigned long **bit, int *max)
{
if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
return 0;

switch (usage->hid & HID_USAGE) {
case 0x156: map_key_clear(KEY_WORDPROCESSOR); break;
case 0x157: map_key_clear(KEY_SPREADSHEET); break;
case 0x158: map_key_clear(KEY_PRESENTATION); break;
case 0x15c: map_key_clear(KEY_STOP); break;

default:
return 0;
}
return 1;
}

#define VENDOR_ID_GYRATION 0x0c16
#define DEVICE_ID_GYRATION_REMOTE 0x0002

#define VENDOR_ID_MONTEREY 0x0566
#define DEVICE_ID_GENIUS_KB29E 0x3004

static const struct hid_input_blacklist {
__u16 idVendor;
__u16 idProduct;
Expand All @@ -74,8 +53,6 @@ static const struct hid_input_blacklist {
} hid_input_blacklist[] = {
{ VENDOR_ID_GYRATION, DEVICE_ID_GYRATION_REMOTE, quirk_gyration_remote },

{ VENDOR_ID_MONTEREY, DEVICE_ID_GENIUS_KB29E, quirk_cherry_genius_29e },

{ 0, 0, NULL }
};

Expand Down
82 changes: 82 additions & 0 deletions drivers/hid/hid-monterey.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* HID driver for some monterey "special" devices
*
* Copyright (c) 1999 Andreas Gal
* Copyright (c) 2000-2005 Vojtech Pavlik <[email protected]>
* Copyright (c) 2005 Michael Haboustak <[email protected]> for Concept2, Inc
* Copyright (c) 2006-2007 Jiri Kosina
* Copyright (c) 2007 Paul Walmsley
* Copyright (c) 2008 Jiri Slaby
*/

/*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*/

#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>

#include "hid-ids.h"

static void mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int rsize)
{
if (rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
dev_info(&hdev->dev, "fixing up button/consumer in HID report "
"descriptor\n");
rdesc[30] = 0x0c;
}
}

#define mr_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
EV_KEY, (c))
static int mr_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
{
if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
return 0;

switch (usage->hid & HID_USAGE) {
case 0x156: mr_map_key_clear(KEY_WORDPROCESSOR); break;
case 0x157: mr_map_key_clear(KEY_SPREADSHEET); break;
case 0x158: mr_map_key_clear(KEY_PRESENTATION); break;
case 0x15c: mr_map_key_clear(KEY_STOP); break;
default:
return 0;
}
return 1;
}

static const struct hid_device_id mr_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
{ }
};
MODULE_DEVICE_TABLE(hid, mr_devices);

static struct hid_driver mr_driver = {
.name = "monterey",
.id_table = mr_devices,
.report_fixup = mr_report_fixup,
.input_mapping = mr_input_mapping,
};

static int mr_init(void)
{
return hid_register_driver(&mr_driver);
}

static void mr_exit(void)
{
hid_unregister_driver(&mr_driver);
}

module_init(mr_init);
module_exit(mr_exit);
MODULE_LICENSE("GPL");

HID_COMPAT_LOAD_DRIVER(monterey);
14 changes: 0 additions & 14 deletions drivers/hid/usbhid/hid-quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ static const struct hid_rdesc_blacklist {
__u16 idProduct;
__u32 quirks;
} hid_rdesc_blacklist[] = {
{ USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER },

{ USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_RDESC_SAMSUNG_REMOTE },

{ 0, 0 }
Expand Down Expand Up @@ -337,20 +335,8 @@ static void usbhid_fixup_samsung_irda_descriptor(unsigned char *rdesc,
}
}

static void usbhid_fixup_button_consumer_descriptor(unsigned char *rdesc, int rsize)
{
if (rsize >= 30 && rdesc[29] == 0x05
&& rdesc[30] == 0x09) {
printk(KERN_INFO "Fixing up button/consumer in HID report descriptor\n");
rdesc[30] = 0x0c;
}
}

static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize)
{
if (quirks & HID_QUIRK_RDESC_BUTTON_CONSUMER)
usbhid_fixup_button_consumer_descriptor(rdesc, rsize);

if (quirks & HID_QUIRK_RDESC_SAMSUNG_REMOTE)
usbhid_fixup_samsung_irda_descriptor(rdesc, rsize);
}
Expand Down
1 change: 0 additions & 1 deletion include/linux/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ struct hid_item {
* Separate quirks for runtime report descriptor fixup
*/

#define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020
#define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040

/*
Expand Down

0 comments on commit 3b8006e

Please sign in to comment.