Skip site navigation (1)Skip section navigation (2)
Date:      13 Jul 2003 20:01:57 +0200
From:      Martin <nakal@web.de>
To:        freebsd-hackers@freebsd.org
Subject:   USB device programming with ugen
Message-ID:  <1058119316.547.22.camel@klotz.local>

next in thread | raw e-mail | index | archive | help
Hi all,

I have started to write a small video capture application for my webcam
(the first few steps). I am using /dev/ugen0 to talk to the webcam and
it seems to work. I can reset the webcam and hear a beep. It is correct
so far.

The problem is, I can only start my application on the text terminal.
If I try to access it through xterm, gnome-terminal or konsole, it will
freeze the whole system.

While experimenting on the text terminal, I noticed that the commands
(ioctls) are being sent correctly (don't return -1), but it takes long
time till they return (approx 5 seconds). While an ioctl-command is
being executed the system is not responding until it finishes
successfully.

Perhaps I am doing something wrong that's why I want to show you what I
send to the webcam. Here a small part (there are 5 or 6 ioctls, but
they look all same; I will not paste the error checking code, only the
essential part):

/* *** */

fdout=open("/dev/ugen0", O_RDWR, 0);

memset(&ur, 0, sizeof(struct usb_ctl_request)); /* paranoid */
ur.ucr_addr=0; /* ignored */
ur.ucr_data=NULL;
ur.ucr_actlen=0;
ur.ucr_flags=0;
ur.ucr_request.bmRequestType=UT_WRITE_VENDOR_DEVICE;
ur.ucr_request.bRequest=0;
USETW(ur.ucr_request.wValue,0xff00);
USETW(ur.ucr_request.wIndex,0x00);
USETW(ur.ucr_request.wLength,0);
ioctl(fdout,USB_DO_REQUEST,&ur);

...

close(fdout);
/* *** */

I am executing it on current (compiled yesterday). I have same behavior
on older 5.1-kernels and it's freezing stable no matter if I start it
in X or on text terminal (even in single-user).

Further details about my system: P3 500MHz, Intel 440BX, 256MB, only 1
USB device attached (Creative Video Blaster Webcam Go)

dmesg:

uhci0: <Intel 82371AB/EB (PIIX4) USB controller> port 0xc000-0xc01f at
device 7.2 on pci0
pci_cfgintr: 0:7 INTD routed to irq 11
usb0: <Intel 82371AB/EB (PIIX4) USB controller> on uhci0
usb0: USB revision 1.0
uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
ugen0: WINBOND W9967CF, rev 1.10/1.10, addr 2

I would like to know if I am doing something wrong accessing the
USB-device. In my opinion, it should not freeze the system at least.

Thanks in advance,
Martin




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1058119316.547.22.camel>