From patchwork Thu Oct 1 20:57:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Rojtberg X-Patchwork-Id: 7311421 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 A8D8B9F4DC for ; Thu, 1 Oct 2015 20:58:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 680042076F for ; Thu, 1 Oct 2015 20:58:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65E80207F1 for ; Thu, 1 Oct 2015 20:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757188AbbJAU5r (ORCPT ); Thu, 1 Oct 2015 16:57:47 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:34982 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757196AbbJAU5q (ORCPT ); Thu, 1 Oct 2015 16:57:46 -0400 Received: by wicge5 with SMTP id ge5so6801877wic.0 for ; Thu, 01 Oct 2015 13:57:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ff7Eu3M8YOwPfjjofRuhRz8ypf5t0vostVeK7GgsmBo=; b=gw61HDTiocjxGNnO4wu8vgB8y2AKpfMaBso7uPgLySoIsiA08N4FBKgQNN/jpFAFY5 mfIKaL5ANYx3g+UWpHpGZHZBannYQxhlSYHgTCq6rKN4XWJPc+Q1cUJzK4uP4sKKWwxa 8MLy0vWNEeCMbVhJE+qvRIaRyDYL/qmKtG7IB0USEp7GqOalXNdidtn1d+me36UkOSiX jU8fkyIKb6SoWstMKgxgKoX7RF/CCuEhQmTVMk3h4ubpgCcSTyDqu9pvVRcNO+hgpNM8 5vL2qMUIRLqcaN+tS/71Oom2unnlB2XRoyrzlcfN9WtN3dvUavIXuyd19jECoxrJLZYb 08JQ== X-Received: by 10.194.19.169 with SMTP id g9mr12068228wje.64.1443733065552; Thu, 01 Oct 2015 13:57:45 -0700 (PDT) Received: from deepwhite.fritz.box (p5790B98A.dip0.t-ipconnect.de. [87.144.185.138]) by smtp.gmail.com with ESMTPSA id lb10sm7989698wjc.9.2015.10.01.13.57.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Oct 2015 13:57:45 -0700 (PDT) From: Pavel Rojtberg X-Google-Original-From: Pavel Rojtberg < rojtberg@gmail.com > To: linux-input@vger.kernel.org, pgriffais@valvesoftware.com, dmitry.torokhov@gmail.com, gregkh@linuxfoundation.org Cc: Pavel Rojtberg Subject: [PATCH 08/15] Input: xpad: query Wireless controller state at init Date: Thu, 1 Oct 2015 22:57:19 +0200 Message-Id: <1443733046-29610-9-git-send-email-rojtberg@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443733046-29610-1-git-send-email-rojtberg@gmail.com> References: <1443733046-29610-1-git-send-email-rojtberg@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Pavel Rojtberg When we initialize the driver/device, we really don't know how many controllers are connected. So send a "query presence" command to the base-station. (Command discovered by Zachary Lund) presence packet taken from: https://github.com/computerquip/xpad5 Signed-off-by: Pavel Rojtberg --- drivers/input/joystick/xpad.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 43490ea..7d66d77 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1236,6 +1236,30 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id usb_kill_urb(xpad->irq_in); goto fail4; } + + /* + * send presence packet + * This will force the controller to resend connection packets. + * This is useful in the case we activate the module after the + * adapter has been plugged in, as it won't automatically + * send us info about the controllers. + */ + mutex_lock(&xpad->odata_mutex); + xpad->odata[0] = 0x08; + xpad->odata[1] = 0x00; + xpad->odata[2] = 0x0F; + xpad->odata[3] = 0xC0; + xpad->odata[4] = 0x00; + xpad->odata[5] = 0x00; + xpad->odata[6] = 0x00; + xpad->odata[7] = 0x00; + xpad->odata[8] = 0x00; + xpad->odata[9] = 0x00; + xpad->odata[10] = 0x00; + xpad->odata[11] = 0x00; + xpad->irq_out->transfer_buffer_length = 12; + usb_submit_urb(xpad->irq_out, GFP_KERNEL); + mutex_unlock(&xpad->odata_mutex); } xpad->pad_present = 1; error = xpad_init_input(xpad);