Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp642234ybx; Wed, 30 Oct 2019 02:41:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNBkqTZAefgffxMJOF2gSuGcIL4PFt2an7Z3/FZx+jZYi3YVlaw2hXXRnSpGYqsOWoR/HQ X-Received: by 2002:a17:906:4d45:: with SMTP id b5mr7885854ejv.157.1572428508960; Wed, 30 Oct 2019 02:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572428508; cv=none; d=google.com; s=arc-20160816; b=XCTeHWdXEkPb/Y4GuMr/GzTUBzqoC+Z2cvRg1xJONLCDwiJPql+/ZoYF5kKvlbelzD gqvbyw//s+2CHdz5begqkfCj41ySr/EL35iXZ7sNsT4fiFxlzyuDCxOPq5xWekKE/D9/ 4tWEl+oWFCvQzVxdWWR5CTHjfSEXP5XaGhZQFT/4BsMzDxUX3qdtb/o7N0rBH9vYi4Bk dkor/1eq9KPvdWVmekS/6ma0dhKRvW2qlKh+fZVbnXC3CJVbRvCNIhEY95F7/eiLTgwu yoZapr3k15C07aMf4sT2tUZvnnFnb1HyRBzKKBQBAI0Q1qBqdO2z9NI2EzmH539BPxUP vhxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=1YGXo/SF75Yt2VzSc2ZhTmUHp1jTQNYYmgSwhHo/iHE=; b=pRYcfvUQUIKD0jESzQz/DXZ0aWALXssYH98rAzLBAkmRlZ7JCYCezAFI0WVh6ahqdW 9dxElAdUxkP5Zo40at7WUE1F8/eaZQcE6Q8i0j5wXXAubS9wnnDDuK+8UFal0s8gfyWF 4fFJR1Lajd64VSNU2S//I1AIlUqk6ZKxloFvEpYeAJZGkewGAFwoLLVOvlVH1dfIOKCb 57AYY9X2gTOcddESXE9dF42onNI0iTZHT/hdbEKVJIXPUwbMk4QuWCW4yJ+sNHlvjXVI P7B4xqFTJFrHi9UbCZQG6uT/HNir8/GIAQeqqZj19IwS64n2eRb6+HDSdeXOJ9baTNb9 aCAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=T01tsbGO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si1012604eda.167.2019.10.30.02.41.25; Wed, 30 Oct 2019 02:41:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=T01tsbGO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726384AbfJ3JjS (ORCPT + 99 others); Wed, 30 Oct 2019 05:39:18 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:37613 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726063AbfJ3JjS (ORCPT ); Wed, 30 Oct 2019 05:39:18 -0400 Received: by mail-pl1-f196.google.com with SMTP id p13so742500pll.4; Wed, 30 Oct 2019 02:39:17 -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=1YGXo/SF75Yt2VzSc2ZhTmUHp1jTQNYYmgSwhHo/iHE=; b=T01tsbGOKACg8rjHZVgIdjsyfJausHFmH+b2g77sqkgKM7KmQxZx70eFw3IbyIobfb MH5Z+VSbM1Asv23w19JsyWwD2RzIr2tBjJiaPmNRI2j2gnU6iEXAHdzDClI0KIpJBnwi 9Y6QKPx9aH9HCago4K9+pCkbx+5gtTGuFtcROqyPHrHbG9LSKRBmD92dXiPzrHpKOHZE gr2DkSaYyFWTw18zLL1jdwglNRx0ZcgAm1vV+dptbCmCz9eQt42+jd9Ec4nFIW4uOUbr yZ8t8g8lwRon4e3zydIetmoQQ62dwAjzQuZ/2chUofLPFp+ZC/p2HXrsHk0WRkjoRG4t SM5Q== 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=1YGXo/SF75Yt2VzSc2ZhTmUHp1jTQNYYmgSwhHo/iHE=; b=KAcsjuwDCTSoXRBiJDM1L4mQ0j03mM9j9hKQ/Ak9ZpShu1KZee9Cz7VilBJCM0zM65 eW33qBVsXZXc8LRIHvQcevQC58lABiWgz6cny+icWW7lKJPKIK3lu2r9BP1WwvK7gGmL QSQVhPhc2eT28CsaaOYXxEiof17EK89y6DabbWaVrdW3/uIshacqIauztuXXkq5+F+fT Ht0e5yPvkU3TtaWwpmhzCWYByra8dDe4P7qUkMGUPUwA9qJRyUw7WMLhmDdsnlzpYBR7 VkAT3SPqcxHAlgdwB/8VTmYXXuAb6Ebb26k4LQ0N4mFOBDkvSUA9+ReWcX5hVhuy+VEU oOAA== X-Gm-Message-State: APjAAAV/6S99R+Z9T4SHHpHoy6IA75n874/wFT/8EkrHaDBIcvEJIca5 RUUZ0gaWP08hg0BlypMqjyw= X-Received: by 2002:a17:902:a609:: with SMTP id u9mr3503407plq.180.1572428356669; Wed, 30 Oct 2019 02:39:16 -0700 (PDT) Received: from archlinux.GovzHome.Local ([2407:7000:aa08:9602:1f09:3b2d:1861:4613]) by smtp.gmail.com with ESMTPSA id i17sm1876190pfo.106.2019.10.30.02.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2019 02:39:16 -0700 (PDT) From: sanjay.govind9@gmail.com Cc: sanjay.govind9@gmail.com, Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: sony: Add support for Guitar Hero Guitars Date: Wed, 30 Oct 2019 22:29:56 +1300 Message-Id: <20191030092956.17934-1-sanjay.govind9@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sanjay Govind Guitar Hero Guitars use the accelerometer x axis for tilt. Currently, they are treated as a regular HID device, and this does not allow the usage of the accelerometer. Add in support for both the PS3 and the PC guitars (they are the same guitars, with different vids and pids). Signed-off-by: Sanjay Govind --- drivers/hid/hid-ids.h | 5 +++++ drivers/hid/hid-sony.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 447e8db21174..1d640f94c5bc 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -40,6 +40,9 @@ #define USB_VENDOR_ID_ACTIONSTAR 0x2101 #define USB_DEVICE_ID_ACTIONSTAR_1011 0x1011 +#define USB_VENDOR_ID_ACTIVISION 0x1430 +#define USB_DEVICE_ID_ACTIVISION_GUITAR 0x474c + #define USB_VENDOR_ID_ADS_TECH 0x06e1 #define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155 @@ -1031,6 +1034,7 @@ #define USB_VENDOR_ID_SONY 0x054c +#define USB_VENDOR_ID_SONY2 0x12BA #define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b #define USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE 0x0374 #define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306 @@ -1042,6 +1046,7 @@ #define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f #define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002 #define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000 +#define USB_DEVICE_ID_SONY_GUITAR_CONTROLLER 0x0100 #define USB_VENDOR_ID_SINO_LITE 0x1345 #define USB_DEVICE_ID_SINO_LITE_CONTROLLER 0x3008 diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 4c6ed6ef31f1..410c855fb830 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -56,6 +56,7 @@ #define NSG_MR5U_REMOTE_BT BIT(14) #define NSG_MR7U_REMOTE_BT BIT(15) #define SHANWAN_GAMEPAD BIT(16) +#define GH_GUITAR_CONTROLLER BIT(17) #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT) #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT) @@ -507,6 +508,8 @@ struct motion_output_report_02 { #define SIXAXIS_INPUT_REPORT_ACC_X_OFFSET 41 #define SIXAXIS_ACC_RES_PER_G 113 +#define GUITAR_TILT_USAGE 44 + static DEFINE_SPINLOCK(sony_dev_list_lock); static LIST_HEAD(sony_device_list); static DEFINE_IDA(sony_device_id_allocator); @@ -757,6 +760,20 @@ static int navigation_mapping(struct hid_device *hdev, struct hid_input *hi, return -1; } +static int guitar_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_MSVENDOR) { + unsigned int abs = usage->hid & HID_USAGE; + + if (abs == GUITAR_TILT_USAGE) { + hid_map_usage_clear(hi, usage, bit, max, EV_ABS, ABS_RY); + return 1; + } + } + return 0; +} static int sixaxis_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, @@ -1340,6 +1357,9 @@ static int sony_mapping(struct hid_device *hdev, struct hid_input *hi, if (sc->quirks & SIXAXIS_CONTROLLER) return sixaxis_mapping(hdev, hi, field, usage, bit, max); + if (sc->quirks & GH_GUITAR_CONTROLLER) + return guitar_mapping(hdev, hi, field, usage, bit, max); + if (sc->quirks & DUALSHOCK4_CONTROLLER) return ds4_mapping(hdev, hi, field, usage, bit, max); @@ -2950,6 +2970,12 @@ static int sony_resume(struct hid_device *hdev) #endif static const struct hid_device_id sony_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_ACTIVISION, USB_DEVICE_ID_ACTIVISION_GUITAR), + .driver_data = GH_GUITAR_CONTROLLER }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY2, USB_DEVICE_ID_SONY_GUITAR_CONTROLLER), + .driver_data = GH_GUITAR_CONTROLLER }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), + .driver_data = SIXAXIS_CONTROLLER_USB }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), .driver_data = SIXAXIS_CONTROLLER_USB }, { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER), -- 2.23.0