From patchwork Sun Feb 20 17:26:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 575961 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1KHRDlB016053 for ; Sun, 20 Feb 2011 17:27:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754702Ab1BTR1N (ORCPT ); Sun, 20 Feb 2011 12:27:13 -0500 Received: from smtp208.alice.it ([82.57.200.104]:49672 "EHLO smtp208.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754656Ab1BTR1M (ORCPT ); Sun, 20 Feb 2011 12:27:12 -0500 Received: from jcn (87.10.137.95) by smtp208.alice.it (8.5.124.08) id 4C1A2716127D074D; Sun, 20 Feb 2011 18:27:05 +0100 Received: from ao2 by jcn with local (Exim 4.72) (envelope-from ) id 1PrD3n-000542-9m; Sun, 20 Feb 2011 18:27:03 +0100 From: Antonio Ospite To: linux-input@vger.kernel.org Cc: Antonio Ospite , linux-bluetooth@vger.kernel.org, Jiri Kosina , Marcel Holtmann , "Gustavo F. Padovan" , Bastien Nocera , Alan Ott , Jim Paris , "pascal@pabr.org" Subject: [PATCH 1/2] hid-sony.c: Fix sending Output reports to the Sixaxis Date: Sun, 20 Feb 2011 18:26:45 +0100 Message-Id: <1298222806-19433-2-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1298222806-19433-1-git-send-email-ospite@studenti.unina.it> References: <1298222806-19433-1-git-send-email-ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 20 Feb 2011 17:27:14 +0000 (UTC) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 68d7b36..93819a0 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -46,6 +46,16 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, return rdesc; } +/* + * The Sony Sixaxis does not handle HID Output Reports on the Interrupt EP + * like it should according to usbhid/hid-core.c::usbhid_output_raw_report() + * so we need to override that forcing HID Output Reports on the Control EP. + * + * There is also another issue about HID Output Reports via USB, the Sixaxis + * does not want the report_id as part of the data packet, so we have to + * discard buf[0] when sending the actual control message, even for numbered + * reports, humpf! + */ static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count, unsigned char report_type) { @@ -55,6 +65,12 @@ static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, int report_id = buf[0]; int ret; + if (report_type == HID_OUTPUT_REPORT) { + /* Don't send the Report ID */ + buf++; + count--; + } + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), HID_REQ_SET_REPORT, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, @@ -62,6 +78,10 @@ static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, interface->desc.bInterfaceNumber, buf, count, USB_CTRL_SET_TIMEOUT); + /* Count also the Report ID, in case of an Output report. */ + if (ret > 0 && report_type == HID_OUTPUT_REPORT) + ret++; + return ret; }