From patchwork Thu Jul 28 16:08:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 1016792 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6SG9Bxm018984 for ; Thu, 28 Jul 2011 16:09:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754907Ab1G1QJJ (ORCPT ); Thu, 28 Jul 2011 12:09:09 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:62287 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754308Ab1G1QJI (ORCPT ); Thu, 28 Jul 2011 12:09:08 -0400 Received: by mail-fx0-f46.google.com with SMTP id 19so1400084fxh.19 for ; Thu, 28 Jul 2011 09:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=/O8s1GU1BGPRv2DD9iH4e5kOW8Etuq6IbwJEApBBXNo=; b=NkmDupXrTZuN+a7cuQYt0RtDt++IrJJ3/JZ5cyzXCpIBQ1Ed6SMfBKh8ctv+zWZQF4 NiOzeTTuGcyq1v9SBaNyjAskMwRw6K7GMMu3YTpyK73NAjf69XzTVNVh8yDsbUACF7Fn GEmncUQWBm+hdSwMEx62/SNvqk2fpny2kID5M= Received: by 10.223.72.149 with SMTP id m21mr244138faj.52.1311869348152; Thu, 28 Jul 2011 09:09:08 -0700 (PDT) Received: from localhost.localdomain (stgt-5f739959.pool.mediaWays.net [95.115.153.89]) by mx.google.com with ESMTPS id a2sm240315fak.1.2011.07.28.09.09.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 09:09:07 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, padovan@profusion.mobi, dh.herrmann@googlemail.com Subject: [PATCH 04/16] HID: wiimote: Add status and return request handlers Date: Thu, 28 Jul 2011 18:08:24 +0200 Message-Id: <1311869316-17128-5-git-send-email-dh.herrmann@googlemail.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1311869316-17128-1-git-send-email-dh.herrmann@googlemail.com> References: <1311869316-17128-1-git-send-email-dh.herrmann@googlemail.com> 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 (demeter2.kernel.org [140.211.167.43]); Thu, 28 Jul 2011 16:09:11 +0000 (UTC) The wiimote resets the current drm when an extension is plugged in. Fortunately, it also sends a status report in this situation so we just reset the drm on every status report to keep the drm consistent. Also handle return reports from the wiimote which indicate success and failure of requests that we've sent. Signed-off-by: David Herrmann --- drivers/hid/hid-wiimote.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c index dfb8707..859950e 100644 --- a/drivers/hid/hid-wiimote.c +++ b/drivers/hid/hid-wiimote.c @@ -59,6 +59,8 @@ enum wiiproto_reqs { WIIPROTO_REQ_RUMBLE = 0x10, WIIPROTO_REQ_LED = 0x11, WIIPROTO_REQ_DRM = 0x12, + WIIPROTO_REQ_STATUS = 0x20, + WIIPROTO_REQ_RETURN = 0x22, WIIPROTO_REQ_DRM_K = 0x30, }; @@ -381,6 +383,26 @@ static void handler_keys(struct wiimote_data *wdata, const __u8 *payload) input_sync(wdata->input); } +static void handler_status(struct wiimote_data *wdata, const __u8 *payload) +{ + handler_keys(wdata, payload); + + /* on status reports the drm is reset so we need to resend the drm */ + wiiproto_req_drm(wdata, 0); +} + +static void handler_return(struct wiimote_data *wdata, const __u8 *payload) +{ + __u8 err = payload[3]; + __u8 cmd = payload[2]; + + handler_keys(wdata, payload); + + if (err) + hid_warn(wdata->hdev, "Remote error %hhu on req %hhu\n", err, + cmd); +} + struct wiiproto_handler { __u8 id; size_t size; @@ -388,6 +410,8 @@ struct wiiproto_handler { }; static struct wiiproto_handler handlers[] = { + { .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status }, + { .id = WIIPROTO_REQ_RETURN, .size = 4, .func = handler_return }, { .id = WIIPROTO_REQ_DRM_K, .size = 2, .func = handler_keys }, { .id = 0 } };