From: David Herrmann <dh.herrmann@googlemail.com>
To: linux-input@vger.kernel.org
Cc: jkosina@suse.cz, padovan@profusion.mobi,
David Herrmann <dh.herrmann@googlemail.com>
Subject: [RFC 05/12] HID: wiimote: Add extension initializer stubs
Date: Tue, 4 Oct 2011 15:36:46 +0200 [thread overview]
Message-ID: <1317735413-17299-6-git-send-email-dh.herrmann@googlemail.com> (raw)
In-Reply-To: <1317735413-17299-1-git-send-email-dh.herrmann@googlemail.com>
Add stub functions to read and identify extensions and then initialize all
connected extensions.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
drivers/hid/hid-wiimote-ext.c | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/drivers/hid/hid-wiimote-ext.c b/drivers/hid/hid-wiimote-ext.c
index 1def9bc..a3d7a5a 100644
--- a/drivers/hid/hid-wiimote-ext.c
+++ b/drivers/hid/hid-wiimote-ext.c
@@ -34,14 +34,52 @@ enum wiiext_type {
WIIEXT_NUNCHUCK, /* Nintendo nunchuck controller */
};
+/* diable all extensions */
+static void ext_disable(struct wiimote_ext *ext)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&ext->wdata->state.lock, flags);
+ ext->motionp = false;
+ ext->ext_type = WIIEXT_NONE;
+ spin_unlock_irqrestore(&ext->wdata->state.lock, flags);
+}
+
+static bool motionp_read(struct wiimote_ext *ext)
+{
+ return false;
+}
+
+static __u8 ext_read(struct wiimote_ext *ext)
+{
+ return WIIEXT_NONE;
+}
+
+static void ext_enable(struct wiimote_ext *ext, bool motionp, __u8 ext_type)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&ext->wdata->state.lock, flags);
+ ext->motionp = motionp;
+ ext->ext_type = ext_type;
+ spin_unlock_irqrestore(&ext->wdata->state.lock, flags);
+}
+
static void wiiext_worker(struct work_struct *work)
{
struct wiimote_ext *ext = container_of(work, struct wiimote_ext,
worker);
+ bool motionp;
+ __u8 ext_type;
/* fresh worker needs no reschedule so reset schedule count */
atomic_set(&ext->schedule, 1);
+ ext_disable(ext);
+ motionp = motionp_read(ext);
+ ext_type = ext_read(ext);
+ ext_enable(ext, motionp, ext_type);
+
/* worker done; check for reschedule */
if (!atomic_dec_and_test(&ext->schedule))
schedule_work(work);
--
1.7.7
next prev parent reply other threads:[~2011-10-04 13:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-04 13:36 [RFC 00/12] Wiimote: Extension Support David Herrmann
2011-10-04 13:36 ` [RFC 01/12] HID: wiimote: Rename driver to allow multiple source files David Herrmann
2011-10-04 13:36 ` [RFC 02/12] HID: wiimote: Move common symbols into header David Herrmann
2011-10-04 13:36 ` [RFC 03/12] HID: wiimote: Add read-mem helpers David Herrmann
2011-10-04 13:36 ` [RFC 04/12] HID: wiimote: Add extension support stub David Herrmann
2011-10-04 13:36 ` David Herrmann [this message]
2011-10-04 13:36 ` [RFC 06/12] HID: wiimote: Add extension initializers David Herrmann
2011-10-04 13:36 ` [RFC 07/12] HID: wiimote: Add extension sysfs attribute David Herrmann
2011-10-04 13:36 ` [RFC 08/12] HID: wiimote: Register input devices for extensions David Herrmann
2011-10-04 13:36 ` [RFC 09/12] HID: wiimote: Add extension handler stubs David Herrmann
2011-10-04 13:36 ` [RFC 10/12] HID: wiimote: Parse motion+ data David Herrmann
2011-10-04 13:36 ` [RFC 11/12] HID: wiimote: Parse nunchuck data David Herrmann
2011-10-04 13:36 ` [RFC 12/12] HID: wiimote: Parse classic controller data David Herrmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1317735413-17299-6-git-send-email-dh.herrmann@googlemail.com \
--to=dh.herrmann@googlemail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=padovan@profusion.mobi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).