public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adam Nielsen <a.nielsen@shikadi.net>
To: LKML Mailinglist <linux-kernel@vger.kernel.org>
Cc: Jiri Slaby <jirislaby@gmail.com>
Subject: hid class and USB access
Date: Sun, 09 Nov 2008 09:31:01 +1000	[thread overview]
Message-ID: <49162135.50502@shikadi.net> (raw)

Hi again,

Okay, hopefully one last question.  When writing a hid driver, what's 
the best way of accessing the USB device?  Are there custom hid 
functions you should use instead of the standard USB functions?  I don't 
want to tread on the toes of the hid class driver.

There is a usbhid_submit_report() which seems to send a control message 
to the device which works well, but my device sends interrupt messages 
in response to control messages, and I'm not sure of the best way of 
receiving these.  For example, from usbmon:

3059935847 S Co:8:002:0 s 21 09 0200 0000 0005 5 = 02010101 01
3059939037 C Co:8:002:0 0 5 >
3059943035 C Ii:8:002:1 0:8 8 = 2b181515 140f000b
3059945841 S Ii:8:002:1 -115:8 8 <
3059956862 S Co:8:002:0 s 21 09 0200 0000 0005 5 = 03010101 01
3060121048 C Co:8:002:0 0 5 >
3060127044 C Ii:8:002:1 0:8 8 = 050407dc 00000000
3060131063 S Ii:8:002:1 -115:8 8 <

I can send these control messages like this:

odin_psu->report->field[0]->value[0] = 0x02;
odin_psu->report->field[0]->value[1] = 0x01;
odin_psu->report->field[0]->value[2] = 0x01;
odin_psu->report->field[0]->value[3] = 0x01;
odin_psu->report->field[0]->value[4] = 0x01;
usbhid_submit_report(odin_psu->hdev, odin_psu->report, USB_DIR_OUT);

Resulting in usbmon output like this:

3710917380 S Co:8:002:0 s 21 09 0200 0000 0005 5 = 02010101 01
3710920638 C Co:8:002:0 -71 0

3714917416 S Co:8:002:0 s 21 09 0200 0000 0005 5 = 02010101 01
3714920639 C Co:8:002:0 -71 0

Which seems to send the correct messages (I think - I'm not sure what 
the second Co line is for), but I'm not quite sure how to receive the 
Interrupt responses from within the hid framework.  Can I use 
usbhid_submit_report(), or do I need to create an URB etc.

Many thanks,
Adam.

                 reply	other threads:[~2008-11-08 23:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=49162135.50502@shikadi.net \
    --to=a.nielsen@shikadi.net \
    --cc=jirislaby@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox