On Fri, Dec 20, 2002, Luca <[EMAIL PROTECTED]> wrote:
> I am trying to write a driver for my usb camera.
> The problem is that i can't understand what goes wrong every time the driver
> tries to write to a register to send a command (no data on return). This is
> the function:
>
> static int my_set_reg(struct usb_device *udev, __u16 value, __u16 index)
> {
> int err;
>
> err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
> 0,
> USB_TYPE_VENDOR | USB_DIR_OUT,
> value, index, NULL, 0, HZ);
>
> if (err)
> printk(KERN_DEBUG "MY_DRIVER: my_set_reg() failed "
> "(value %04X, index %02X).\n", value, index);
>
> return err;
> }
> A tipical call is my_set_reg(0x0010, 0x0000);
>
> Can someone explain me what values the third parameter can *exactly* assume?
> I think "0" means something like "set control transfer".
It's going to be whatever the documentation for the command you want to
execute says.
> Since i don't want data on return, Is NULL right (4th parameter) ?
You mean 7th parameter? If you don't need to send a payload, then NULL
is fine.
> Is "size" parameter right too?
If there's nothing to send, sure.
> I tried everything but the function always fails, and the kernel disconnects()
> and probes() again without any reason (weird):
>
> usb-uhci.c: interrupt, status 2, frame# 862
> MY_DRIVER: my_set_reg() failed (value 0010, index 00).
> hub.c: already running port 1 disabled by hub (EMI?), re-enabling...
> usb.c: USB disconnect on device 00:07.2-1 address 20
> MY_DRIVER: disconnect() called.
> hub.c: new USB device 00:07.2-1, assigned address 21
> usb.c: USB device not accepting new address=21 (error=-110)
> hub.c: new USB device 00:07.2-1, assigned address 22
> MY_DEVICE: probe() called.
Perhaps you can print what the value of err is? It will probably give
some insight to why it failed.
You may also want to change your check if there is a failure. A positive
value returned from usb_control_msg is not a failure, only negative.
JE
-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players, XBox Games, Flying Saucers, WebCams, Smart Putty.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel