From patchwork Thu Mar 28 03:34:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 10874451 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3478715AC for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C931288AF for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CC022874B; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 931142874B for ; Thu, 28 Mar 2019 03:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727146AbfC1Dek (ORCPT ); Wed, 27 Mar 2019 23:34:40 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:40047 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfC1Dek (ORCPT ); Wed, 27 Mar 2019 23:34:40 -0400 Received: by mail-io1-f67.google.com with SMTP id d201so16009602iof.7 for ; Wed, 27 Mar 2019 20:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pwAZ3PPoAb6xM2IQgZ56+ZyvX9ZNdjYluDCaHYm3XPk=; b=nrZZ2EGmIYOh+n+EFZLdRpivY2bxpxITnhXNFV/VKCA+P69aLlcagnx+ZtpFneKf29 VChTklFlFxsOJ1cn0r/2Ju+hwZ8oqqE4pfJuKCQuqtPfMQ0qxME2Ip34Q7AkQcu3ecd+ zLvLcNC6OsucGj54pd6UzC9dY898SoBo5MD9oZWv5D5QslEvv1ZCBFwNI7COougvT64J n5tnPOj8V4imwdbpbQGkuiwTzmk7I54f6Dp85MmV4opW8C/X29KOBYNqikjFZRZvW8d0 tFBoOu/hZwYh3jbLNDgLXSAGMMXww1/In1YuQALHSMURzsqDW8rudoJc94Hm8pIGr1cf GkOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pwAZ3PPoAb6xM2IQgZ56+ZyvX9ZNdjYluDCaHYm3XPk=; b=fLaq4DmG36h6BGj+OUOIkR8hY9PQDW4ORfOqQYj4CpJZFpZ7V+G0xDYyB4xFoEP9ul xjkFj0fJdJxES2i15EAtPui8f29dUA/EJVtMSrM6ukHdl6ZePpztGg6iTG3EPqDN2PWG XqPugOJe995s2YIs0ICsI5NOgFzJNAeeSON96TfwNwMYWyMaBnP6QneDI0YDKx9Pj1Jn 6UG9XAgFwYEiTUxuCaCFb7v0vmqgkvGCRMMgDV9End/q530Bw4M2cqg4wtasZ3kuKyfw 1uUBXVL/4oEFZ08F+kptQ5cWPTs/IQnWglRhFWgLRtpQ123dPXsggHQ8XGaq6MNVICP3 EKtA== X-Gm-Message-State: APjAAAUw5DxBc+7Z9HGkY3+w3zxWUDo677x93X4fs34R2CaUpxkq+OGA otQiH1VyBrNbQS3BgTr3MLAEQOwF X-Google-Smtp-Source: APXvYqw7gb6Kd1abtBuAuS152URzV0v0RdVhYBpg1zioSlcGIwuEAKc8btCMlYjypqaL7hyPYeJjIA== X-Received: by 2002:a5e:d803:: with SMTP id l3mr3428180iok.229.1553744078531; Wed, 27 Mar 2019 20:34:38 -0700 (PDT) Received: from xavier.hsd1.ut.comcast.net ([2601:681:4100:375e:f2d5:bfff:fecd:8741]) by smtp.gmail.com with ESMTPSA id t25sm10164732ioc.37.2019.03.27.20.34.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 20:34:37 -0700 (PDT) From: Alex Henrie To: linux-input@vger.kernel.org, jikos@kernel.org, benjamin.tissoires@redhat.com, dmlambea@gmail.com Cc: Alex Henrie Subject: [PATCH 1/2] HID: macally: Add support for Macally ikey keyboard Date: Wed, 27 Mar 2019 21:34:34 -0600 Message-Id: <20190328033435.17931-1-alexhenrie24@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This enables the power and equals keys on the Macally ikey keyboard. Based on the Cougar gaming keyboard HID driver, which uses the same vendor ID. Signed-off-by: Alex Henrie --- drivers/hid/Kconfig | 10 +++++++++ drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-macally.c | 47 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 drivers/hid/hid-macally.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 6ca8d322b487..aef4a2a690e1 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -230,6 +230,16 @@ config HID_COUGAR Supported devices: - Cougar 500k Gaming Keyboard +config HID_MACALLY + tristate "Macally devices" + depends on HID + help + Support for Macally devices that are not fully compliant with the + HID standard. + + supported devices: + - Macally ikey keyboard + config HID_PRODIKEYS tristate "Prodikeys PC-MIDI Keyboard support" depends on HID && SND diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 170163b41303..44b9caea46a7 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -65,6 +65,7 @@ obj-$(CONFIG_HID_LENOVO) += hid-lenovo.o obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o obj-$(CONFIG_HID_LOGITECH_DJ) += hid-logitech-dj.o obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o +obj-$(CONFIG_HID_MACALLY) += hid-macally.o obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o obj-$(CONFIG_HID_MALTRON) += hid-maltron.o obj-$(CONFIG_HID_MAYFLASH) += hid-mf.o diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index b6d93f4ad037..aacc7534b076 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1034,6 +1034,7 @@ #define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008 #define USB_VENDOR_ID_SOLID_YEAR 0x060b +#define USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD 0x0001 #define USB_DEVICE_ID_COUGAR_500K_GAMING_KEYBOARD 0x500a #define USB_DEVICE_ID_COUGAR_700K_GAMING_KEYBOARD 0x700a diff --git a/drivers/hid/hid-macally.c b/drivers/hid/hid-macally.c new file mode 100644 index 000000000000..6f62f059b795 --- /dev/null +++ b/drivers/hid/hid-macally.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * HID driver for Macally devices + * + * Copyright (c) 2019 Alex Henrie + */ + +#include +#include + +#include "hid-ids.h" + +MODULE_AUTHOR("Alex Henrie "); +MODULE_DESCRIPTION("Macally devices"); +MODULE_LICENSE("GPL"); + +/* + * The Macally ikey keyboard says that its logical and usage maximums are both + * 101, but the power key is 102 and the equals key is 103 + */ +static __u8 *macally_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int *rsize) +{ + if (hdev->product == USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD) { + if (*rsize >= 60 && rdesc[53] == 0x65 && rdesc[59] == 0x65) { + hid_info(hdev, + "fixing up Macally ikey keyboard report descriptor\n"); + rdesc[53] = rdesc[59] = 0x67; + } + } + return rdesc; +} + +static struct hid_device_id macally_id_table[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR, + USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD) }, + { } +}; +MODULE_DEVICE_TABLE(hid, macally_id_table); + +static struct hid_driver macally_driver = { + .name = "macally", + .id_table = macally_id_table, + .report_fixup = macally_report_fixup, +}; + +module_hid_driver(macally_driver); From patchwork Thu Mar 28 03:34:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 10874453 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D091B1390 for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDC202874B for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0F85288D2; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C5C82874B for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbfC1Del (ORCPT ); Wed, 27 Mar 2019 23:34:41 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:52517 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfC1Del (ORCPT ); Wed, 27 Mar 2019 23:34:41 -0400 Received: by mail-it1-f194.google.com with SMTP id g17so3727532ita.2 for ; Wed, 27 Mar 2019 20:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RSLeKtUHujUH0wIjEbHHFy+t3VZrcyVtR9w41AyjSWo=; b=djuAhO02ijHiiAO+Vrrc/Nx9utUAuqqJ6QARnnj+RAuHKfQZjsryZKqBz+qtR0DUQz Av+DMPyhIghmXuYog3dNF5NIY9TWqaH7E4Y6F9qy9Q1i8PEOi0x5t5tpGoxdSJztZDQ2 W9NFA7GyrhCN/Ri122Oii5kaJYX2xlLL/SXI77CA/xND9gUQfJEUN10gkmpmImYOqnYH z4I9bUeaamEIgl9FWAJOiZ1ZrjlvjV7PJni7HxnhSGDhnYnmSAPh3eZhav7OI2PmWfNW vaGBwDS0tkPa3G59JclnkTBKe/dUX1TWvj+w5Ib0T39hcNsvE0RzhTRGfPK9r023dSAH FKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RSLeKtUHujUH0wIjEbHHFy+t3VZrcyVtR9w41AyjSWo=; b=Jnih/RpROwF4qsl9vBLale2xF5pmezD0DqlvD6QugFStEqGZSyzMunifmziWNwrSlG TU4dgb2iG9iDH3duJzmgPRy+tM/fic63hZfdzhYlXc8ykl8ASa1z+yudC7HjsTUpD6oP x6Hna7YOtnM7i0/bgb4ybbRJIE1wwIGiuy6qxPZ7rP6IBTaeGWnSf6EvWvDBFBdbJ/k9 Xqzl+LVfcWDtdcfVNYB4ZPmeQKAiVcJJiIXiPqI31m29AQ8/MColLm6YiLBiyKfoz8Ej MfU0JjkeLrpjYaBYB33DYB+1zo1Myoo1UN7Lt8d6WXt6fOiTjycen7k3Dnk0TBG/ZAt7 xeXg== X-Gm-Message-State: APjAAAXuyFfuvD7Rxzp3A7zlTmT5J4uBQO8XSw1/1eua6SZeYHAENk5M 5O8L/Ny7LnhVNIm9MwklvmVOdyHo X-Google-Smtp-Source: APXvYqxJohqJkrY758Z63b1jOntrC/LRkeFRjvwakJKTXiRXTAiBcoBhWn0FFJ5+2Vs570P9P6qM6g== X-Received: by 2002:a24:703:: with SMTP id f3mr6243420itf.164.1553744079992; Wed, 27 Mar 2019 20:34:39 -0700 (PDT) Received: from xavier.hsd1.ut.comcast.net ([2601:681:4100:375e:f2d5:bfff:fecd:8741]) by smtp.gmail.com with ESMTPSA id t25sm10164732ioc.37.2019.03.27.20.34.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 20:34:39 -0700 (PDT) From: Alex Henrie To: linux-input@vger.kernel.org, jikos@kernel.org, benjamin.tissoires@redhat.com, dmlambea@gmail.com Cc: Alex Henrie Subject: [PATCH 2/2] HID: macally: Add support for Macally QKEY keyboard Date: Wed, 27 Mar 2019 21:34:35 -0600 Message-Id: <20190328033435.17931-2-alexhenrie24@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190328033435.17931-1-alexhenrie24@gmail.com> References: <20190328033435.17931-1-alexhenrie24@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This enables the brightness-down and brightness-up keys on the Macally QKEY keyboard. Similar workarounds are probably needed for quite a few Macally keyboard models. Based on the key translation code in the Apple keyboard driver. Signed-off-by: Alex Henrie --- drivers/hid/Kconfig | 1 + drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-macally.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index aef4a2a690e1..082900477df5 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -239,6 +239,7 @@ config HID_MACALLY supported devices: - Macally ikey keyboard + - Macally QKEY keyboard config HID_PRODIKEYS tristate "Prodikeys PC-MIDI Keyboard support" diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index aacc7534b076..5afc3b7fe8ca 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -776,6 +776,9 @@ #define USB_DEVICE_ID_CRYSTALTOUCH 0x0006 #define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007 +#define USB_VENDOR_ID_MACALLY 0x2222 +#define USB_DEVICE_ID_MACALLY_QKEY_KEYBOARD 0x0039 + #define USB_VENDOR_ID_MADCATZ 0x0738 #define USB_DEVICE_ID_MADCATZ_BEATPAD 0x4540 #define USB_DEVICE_ID_MADCATZ_RAT5 0x1705 diff --git a/drivers/hid/hid-macally.c b/drivers/hid/hid-macally.c index 6f62f059b795..2567babe8200 100644 --- a/drivers/hid/hid-macally.c +++ b/drivers/hid/hid-macally.c @@ -31,9 +31,64 @@ static __u8 *macally_report_fixup(struct hid_device *hdev, __u8 *rdesc, return rdesc; } +struct macally_key_translation +{ + u16 from; + u16 to; +}; + +static const struct macally_key_translation qkey_brightness_keys[] = +{ + { KEY_SCROLLLOCK, KEY_BRIGHTNESSDOWN }, + { KEY_PAUSE, KEY_BRIGHTNESSUP }, + { } +}; + +static int macally_event(struct hid_device *hdev, struct hid_field *field, + struct hid_usage *usage, __s32 value) +{ + const struct macally_key_translation *trans; + + switch (hdev->product) { + case USB_DEVICE_ID_MACALLY_QKEY_KEYBOARD: + trans = qkey_brightness_keys; + break; + default: + trans = NULL; + } + + if (trans) { + while (trans->from) { + if (trans->from == usage->code) { + input_event(field->hidinput->input, usage->type, + trans->to, value); + return 1; + } + trans++; + } + } + + return 0; +} + +static int macally_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + const struct macally_key_translation *trans; + + /* Enable all needed keys */ + for (trans = qkey_brightness_keys; trans->from; trans++) + set_bit(trans->to, hi->input->keybit); + + return 0; +} + static struct hid_device_id macally_id_table[] = { { HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR, USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MACALLY, + USB_DEVICE_ID_MACALLY_QKEY_KEYBOARD) }, { } }; MODULE_DEVICE_TABLE(hid, macally_id_table); @@ -42,6 +97,8 @@ static struct hid_driver macally_driver = { .name = "macally", .id_table = macally_id_table, .report_fixup = macally_report_fixup, + .event = macally_event, + .input_mapping = macally_input_mapping, }; module_hid_driver(macally_driver);