From patchwork Thu Nov 12 16:25:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon@mungewell.org X-Patchwork-Id: 7603651 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B7D6A9F1D3 for ; Thu, 12 Nov 2015 16:27:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8D7820814 for ; Thu, 12 Nov 2015 16:27:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED56420810 for ; Thu, 12 Nov 2015 16:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932336AbbKLQZv (ORCPT ); Thu, 12 Nov 2015 11:25:51 -0500 Received: from host18.canaca.com ([66.49.204.205]:38120 "EHLO host18.canaca.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932186AbbKLQZt (ORCPT ); Thu, 12 Nov 2015 11:25:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mungewell.org; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=nOWb5QUp+z26f0Y2kh6Dtf1gxZ4jCyJK8xoX1VTQf1E=; b=EqswClxEixNqGj 5EGyX0vDBDrgRFzdPfqHQ4ju70E2H46JDzEpXBX8oVtXGb9PMeB8vHXaE5mVspdUJCojKx46dpSyb BzSqwmeFV9jdd0G0Ra+gnwycpnYimpNZlL3iYjY7F3H4L6fj5//qoPVb4Ra12Tqlq26L4kCZdIul9 ol2l9KAjP/Dey8aoN+Ok7MLXkctfg2E6Aly6XWHYSdn3UlYaBJIb6KjrHedcN/2s1t1sIb5sqHWF9 rP4g0SWQy0TBUWgBCqISi+Dr+ZGtpYdfTPaIWVccFzCl+qQM7tTkTjYm5W7kIL4Y6a+AfNOsB/A3G QY/GRS3RtTHepNCSGSrA==; Received: from [208.75.119.66] (port=34612 helo=localhost.localdomain) by host18.canaca.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.86) (envelope-from ) id 1Zwuh3-0007P1-GM; Thu, 12 Nov 2015 11:25:49 -0500 From: Simon Wood To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Kosina , Edwin , =?UTF-8?q?Michal=20Mal=C3=BD?= , elias vanderstuyft , Benjamin Tissoires , Simon Wood Subject: [Patch-V2 1/6] INPUT: xpad: Add minimal support for Logitech G920 Wheel Date: Thu, 12 Nov 2015 09:25:30 -0700 Message-Id: <1447345535-2912-2-git-send-email-simon@mungewell.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447345535-2912-1-git-send-email-simon@mungewell.org> References: <1447345535-2912-1-git-send-email-simon@mungewell.org> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host18.canaca.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mungewell.org X-Get-Message-Sender-Via: host18.canaca.com: authenticated_id: gitsend@mungewell.org X-Authenticated-Sender: host18.canaca.com: gitsend@mungewell.org X-Source: X-Source-Args: X-Source-Dir: Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When plugged in the Logitech G920 wheel starts with USBID 046d:c261 and behaviors as a vendor specific class. If a 'magic' byte sequence is sent the wheel will detach and reconnect as a HID device with the USBID 046d:c262. Signed-off-by: Simon Wood Acked-by: Dmitry Torokhov --- drivers/input/joystick/xpad.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index fd4100d..338a3a4 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -93,6 +93,7 @@ #define MAP_STICKS_TO_NULL (1 << 2) #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \ MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL) +#define SWITCH_G920_TO_HID_MODE (1 << 3) #define XTYPE_XBOX 0 #define XTYPE_XBOX360 1 @@ -134,6 +135,7 @@ static const struct xpad_device { { 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 }, { 0x046d, 0xc21f, "Logitech Gamepad F710", 0, XTYPE_XBOX360 }, { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, + { 0x046d, 0xc261, "Logitech G920 Driving Force Racing Wheel", SWITCH_G920_TO_HID_MODE, XTYPE_XBOXONE }, { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX }, { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX }, @@ -299,6 +301,7 @@ static struct usb_device_id xpad_table[] = { XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */ XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */ + XPAD_XBOXONE_VENDOR(0x046d), /* Logitech X-Box One style controllers */ XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */ { USB_DEVICE(0x0738, 0x4540) }, /* Mad Catz Beat Pad */ XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */ @@ -1048,6 +1051,19 @@ static int xpad_open(struct input_dev *dev) if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) return -EIO; + /* Logitect G920 wheel starts in XBOX mode, but is reconfigured to be HID */ + /* device with USBID of 046D:C262. Wheel will detach when 'magic' is sent. */ + if (xpad->mapping & SWITCH_G920_TO_HID_MODE) { + xpad->odata[0] = 0x0F; + xpad->odata[1] = 0x00; + xpad->odata[2] = 0x01; + xpad->odata[3] = 0x01; + xpad->odata[4] = 0x42; + xpad->irq_out->transfer_buffer_length = 5; + + return usb_submit_urb(xpad->irq_out, GFP_KERNEL); + } + if (xpad->xtype == XTYPE_XBOXONE) { /* Xbox one controller needs to be initialized. */ xpad->odata[0] = 0x05;