From: Adam Nielsen <a.nielsen@shikadi.net>
To: Jiri Kosina <jkosina@suse.cz>
Cc: LKML Mailinglist <linux-kernel@vger.kernel.org>
Subject: Re: usbhid: How to wait for response after submitting report
Date: Tue, 30 Mar 2010 22:21:56 +1000 [thread overview]
Message-ID: <4BB1ECE4.5070606@shikadi.net> (raw)
In-Reply-To: <alpine.LNX.2.00.1003301407320.24576@pobox.suse.cz>
>> Basically I have a USB HID device, and it works by submitting a HID report,
>> then waiting until it replies with (I assume) another HID report. The
>> messages are all proprietary. I can send the reports fine, but half the time
>> I get garbage coming back, which I assume is because I'm not getting the
>> message quickly enough and processing whatever was in the buffer instead.
>>
>> If you're able to point me in the direction of an example showing how to set
>> up and use a completion handler, hopefully I can change my code to work like
>> that instead.
>
> Well this is rather more USB-related question than HID related question,
> I'd say.
Well originally I was going to write a USB driver, but as it's a HID device
and there's a HID class in the kernel, I thought it would be better to use the
functions provided by the USB HID device class.
> Basically you prepare URB, along with specifying which routine should be
> called by USB core as completion handler, and then submit the URB.
Can I do this without conflicting with the HID "layer"? I assumed that
drivers appearing in the HID class should only use HID functions, and those
functions would take care of the USB side of things. I don't really want to
reimplement all the standard HID communication code when it has already been
implemented in the USB HID driver/class.
> USB HID implementation is working like this (and zillions of other USB
> drivers which are in kernel do as well) -- just look at initialization of
> control URB in usbhid_start(), and the completion handler (for control
> URBs) in hid_ctrl().
At the moment I am calling functions like hid_hw_start and
usbhid_submit_report, which (I think) take care of all this for me. There's
not a lot of documentation about how the HID class works, and only a handful
of drivers unfortunately, since it's a standard USB device class - you only
need to write a driver for nonstandard hardware, which means all the existing
HID drivers are all very different!
Because usbhid_submit_report takes the raw data to be packaged up inside a USB
HID message, I don't have an opportunity to set any sort of completion
handler. I imagine the HID class takes care of it, but I don't know how to
figure out whether the completion handler has been called and there's data to
read.
Thanks,
Adam.
prev parent reply other threads:[~2010-03-30 12:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-13 3:10 usbhid: How to wait for response after submitting report Adam Nielsen
2010-03-15 16:07 ` Jiri Kosina
2010-03-27 11:52 ` Adam Nielsen
2010-03-30 12:10 ` Jiri Kosina
2010-03-30 12:21 ` Adam Nielsen [this message]
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=4BB1ECE4.5070606@shikadi.net \
--to=a.nielsen@shikadi.net \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.