On Wed, 13 Oct 2010 19:23:52 -0400 Alan Ott <alan@xxxxxxxxxxx> wrote: > On 10/13/2010 06:54 PM, Antonio Ospite wrote: > > Sony Sixaxis wants output reports on the control endpoint rather than > > interrupt endpoint, so override usbhid_output_raw_report in order to > > force this behaviour. > > > > Signed-off-by: Antonio Ospite<ospite@xxxxxxxxxxxxxxxxx> > > --- [...] > > +static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, > > + size_t count, unsigned char report_type) > > +{ > > + struct usb_interface *intf = to_usb_interface(hid->dev.parent); > > + struct usb_device *dev = interface_to_usbdev(intf); > > + struct usb_host_interface *interface = intf->cur_altsetting; > > + > > + int ret; > > + int skipped_report_id = 0; > > + int report_id = buf[0]; > > + > > + printk(KERN_DEBUG "%s: Overriding usbhid_output_raw_report\n", __func__); > > + > > + if (buf[0] == 0x0) { > > + /* Don't send the Report ID */ > > + buf++; > > + count--; > > + skipped_report_id = 1; > > + } > > + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), > > + HID_REQ_SET_REPORT, > > + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, > > + ((report_type + 1)<< 8) | report_id, > > + interface->desc.bInterfaceNumber, buf, count, > > + USB_CTRL_SET_TIMEOUT); > > + /* count also the report id, if this was a numbered report. */ > > + if (ret> 0&& skipped_report_id) > > + ret++; > > + > > + return ret; > > +} > > + [...] > > I think as far as code duplication goes, you can get rid of the > skipped_report stuff and the buf[0] = 0x0 section (since you _know_ the > sixaxis uses numbered reports). Once you've done that, you're basically > down to one function call. > That's right thanks a lot. > I think maybe I'm confused a bit. Is this patch against Jiri's hid tree > in the for-next branch[1]? If so is there another patch which is > required for this to make sense (I looked in linux-input, but didn't see > any appropriate ones)? In Jiri's tree, sixaxis_set_operational_usb() > already calls usb_control_msg() instead of hid_output_raw_report(), so I > clearly must be looking at the wrong thing. Please help me understand > what I'm supposed to be looking at. > I am working on linus tree with some patches applied, namely your hidraw feature report patches and this one from Jiri's hid/for-next branch: http://git.kernel.org/?p=linux/kernel/git/jikos/hid.git;a=commit;h=816651a7d4a32664261e5f9f88ad0d558faed4cc The point about overriding hid_output_raw_report() is not about sixaxis_set_operational_usb() sending a control message, but about any _output_ (not feature) report the user would like to send via hidraw_write(), the sixaxis will accept those only if sent on the control endpoint (it will discard them if sent on the interrupt ep, like the current usbhid code does) maybe I didn't state that clearly, sorry. About sixaxis_set_operational_usb(), I don't remember _any_ change to it except its name, but I guess we can very well make it call hid_output_raw_report(), just only after your hidraw feature report patches land to mainline. Regards, Antonio -- Antonio Ospite http://ao2.it PGP public key ID: 0x4553B001 A: Because it messes up the order in which people normally read text. See http://en.wikipedia.org/wiki/Posting_style Q: Why is top-posting such a bad thing?
Attachment:
pgpKoUq6Tr2AA.pgp
Description: PGP signature