|
|
I have one of these http://www.mixman.com/products/dm2.html and I'm
trying to write a driver for it. After much struggle (and more still
to come, I'm sure) with the density of the USB spec, I've figured out
this:
-input interrupts are supposed to come from endpoint 1, which is
/dev/ugen1.01 for me
-output (to control the LEDs) goes to endpoint 2, which is
/dev/ugen1.02, and appearently uses bulk interrupts.
Output (`echo abcd > /dev/ugen1.02`) works like a synch, but input
(`cat /dev/ugen1.01`) hangs forever.
I've written a program to investigate, which is below, but all I get
are hangs. I've even tried the equivalent code from libusb and it has
the same result.
The only difference that non-blocking makes is that it doesn't block,
I still never get any data out of it.
I've talked with the person who implemented the OS X driver for this
thing and he says (I think) it doesn't need me to send anything to it
for initialization, so now I come to you fine people to ask: how am I
misusing ugen(4)?
The port is lowspeed, and apparently that was an issue for the Linux
driver, could it be an issue here?
#include <sys/ioctl.h>
#include <dev/usb/usb.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
void main()
{
int d = open("/dev/ugen1.01", O_NONBLOCK, 0);
if(d == -1) {
perror("unable to open bus");
return;
} else
printf("Opened\n");
int timeout = 0;
printf("Setting timeout to %d...", timeout);
if(ioctl(d, USB_SET_TIMEOUT, &timeout) == -1)
perror("couldn't set timeout");
printf("Timeout set.\n");
int shrt = 1;
printf("Setting short xfer to %d...", shrt);
if(ioctl(d, USB_SET_SHORT_XFER, &shrt) == -1)
perror("couldn't set short_xfer");
printf("Shortxfer set\n");
while(1) {
char buf[10];
if(read(d, &buf, 10) != -1)
printf("Reply: |%c|%c|\n", buf[0], buf[1]);
else
printf("No reply\n");
if(close(d)==-1)
perror("unable to close file because");
}
OpenBSD 4.3 (GENERIC.MP) #1582: Wed Mar 12 11:16:45 MDT 2008
deraadt@xxxxxxxxxxxxxxxxx:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 2114547712 (2016MB)
avail mem = 2041602048 (1947MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xe0000 (37 entries)
bios0: vendor Apple Inc. version "MB21.88Z.00A5.B07.0706270922" date 06/27/07
bios0: Apple Inc. MacBook2,1
acpi0 at bios0: rev 0
acpi0: tables DSDT HPET APIC MCFG ASF! SBST ECDT FACP SSDT SSDT SSDT
acpi0: wakeup devices ADP1(S3) LID0(S3) PXS1(S4) PXS2(S4) USB1(S3)
USB2(S3) USB3(S3) USB4(S3) USB7(S3) EC__(S3)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 14318179 Hz
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz, 2161.61 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu0: 4MB 64b/line 16-way L2 cache
cpu0: apic clock running at 166MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz, 2161.25 MHz
cpu1:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,SBF,SSE3,MWAIT,DS-CPL,VMX,EST,TM2,CX16,xTPR,NXE,LONG
cpu1: 4MB 64b/line 16-way L2 cache
ioapic0 at mainbus0 apid 1 pa 0xfec00000, version 20, 24 pins
ioapic0: misconfigured as apic 0, remapped to apid 1
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (RP01)
acpiprt2 at acpi0: bus 2 (RP02)
acpiprt3 at acpi0: bus 3 (PCIB)
acpiec0 at acpi0
acpicpu0 at acpi0: C3, C2
acpicpu1 at acpi0: C3, C2
acpiac0 at acpi0: AC unit offline
acpibtn0 at acpi0: LID0
acpibtn1 at acpi0: PWRB
acpibtn2 at acpi0: SLPB
acpibat0 at acpi0: BAT0 model "AS" type LI oem "DP"
cpu0: unknown Enhanced SpeedStep CPU, msr 0x06130d2906000b23
cpu0: using only highest, current and lowest power states
cpu0: Enhanced SpeedStep 1833 MHz (1260 mV): speeds: 2167, 1833, 1000 MHz
pci0 at mainbus0 bus 0: configuration mode 1
pchb0 at pci0 dev 0 function 0 "Intel 82945GM Host" rev 0x03
agp0 at pchb0: aperture at 0x80000000, size 0x10000000
vga1 at pci0 dev 2 function 0 "Intel 82945GM Video" rev 0x03
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
"Intel 82945GM Video" rev 0x03 at pci0 dev 2 function 1 not configured
vendor "Intel", unknown product 0x27a3 (class DASP subclass Time and
Frequency, rev 0x03) at pci0 dev 7 function 0 not configured
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02:
apic 1 int 22 (irq 10)
azalia0: codec[s]: Sigmatel STAC9221
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 82801GB PCIE" rev 0x02: apic 1
int 17 (irq 11)
pci1 at ppb0 bus 1
mskc0 at pci1 dev 0 function 0 "Marvell Yukon 88E8053" rev 0x22,
Yukon-2 EC rev. A3 (0x2): apic 1 int 16 (irq 11)
msk0 at mskc0 port A: address 00:1b:63:33:2f:65
eephy0 at msk0 phy 0: Marvell 88E1111 Gigabit PHY, rev. 2
ppb1 at pci0 dev 28 function 1 "Intel 82801GB PCIE" rev 0x02: apic 1
int 16 (irq 11)
pci2 at ppb1 bus 2
ath0 at pci2 dev 0 function 0 "Atheros AR5418" rev 0x01: apic 1 int 17 (irq 11)
ath_hal_attach: unable to init EEPROM
ath0: unable to attach hardware; HAL status 22
uhci0 at pci0 dev 29 function 0 "Intel 82801GB USB" rev 0x02: apic 1
int 21 (irq 11)
uhci1 at pci0 dev 29 function 1 "Intel 82801GB USB" rev 0x02: apic 1
int 19 (irq 11)
uhci2 at pci0 dev 29 function 2 "Intel 82801GB USB" rev 0x02: apic 1
int 18 (irq 11)
uhci3 at pci0 dev 29 function 3 "Intel 82801GB USB" rev 0x02: apic 1
int 16 (irq 11)
ehci0 at pci0 dev 29 function 7 "Intel 82801GB USB" rev 0x02: apic 1
int 21 (irq 11)
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb2 at pci0 dev 30 function 0 "Intel 82801BAM Hub-to-PCI" rev 0xe2
pci3 at ppb2 bus 3
"AT&T/Lucent FW322 1394" rev 0x61 at pci3 dev 3 function 0 not configured
pcib0 at pci0 dev 31 function 0 "Intel 82801GBM LPC" rev 0x02
pciide0 at pci0 dev 31 function 1 "Intel 82801GB IDE" rev 0x02: DMA,
channel 0 configured to compatibility, channel 1 configured to
compatibility
atapiscsi0 at pciide0 channel 0 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <MATSHITA, DVD-R UJ-857E, ZB0E> SCSI0
5/cdrom removable
cd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 4
pciide0: channel 1 disabled (no drives)
pciide1 at pci0 dev 31 function 2 "Intel 82801GBM SATA" rev 0x02: DMA,
channel 0 configured to native-PCI, channel 1 configured to native-PCI
pciide1: using apic 1 int 19 (irq 11) for native-PCI interrupt
wd0 at pciide1 channel 0 drive 1: <WDC WD2500BEVS-22UST0>
wd0: 16-sector PIO, LBA48, 238475MB, 488397168 sectors
wd0(pciide1:0:1): using PIO mode 4, Ultra-DMA mode 5
ichiic0 at pci0 dev 31 function 3 "Intel 82801GB SMBus" rev 0x02: apic
1 int 19 (irq 11)
iic0 at ichiic0
iic0: addr 0x48 00=3a 01=00 02=4b 03=50 words 00=3a80 01=00ff 02=4b00
03=5000 04=ffff 05=ffff 06=ffff 07=ffff 08=ffff 09=ffff 0a=ffff
0b=ffff 0c=ffff 0d=ffff 0e=ffff 0f=ffff
spdmem0 at iic0 addr 0x50: 1GB DDR2 SDRAM non-parity PC2-5300CL5 SO-DIMM
spdmem1 at iic0 addr 0x52: 1GB DDR2 SDRAM non-parity PC2-5300CL5 SO-DIMM
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci3: USB revision 1.0
uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at pcib0
isadma0 at isa0
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <PC speaker>
spkr0 at pcppi0
ugen0 at uhub0 port 4 "Apple Computer Bluetooth" rev 2.00/0.0c addr 2
ugen1 at uhub1 port 1 "vendor 0x0665 product 0x0301" rev 1.10/0.03 addr 2
uhidev0 at uhub4 port 1 configuration 1 interface 0 "Apple Computer
ADB device" rev 2.00/19.65 addr 2
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 modifier keys, 6 key codes
wskbd0 at ukbd0: console keyboard, using wsdisplay0
uhidev1 at uhub4 port 1 configuration 1 interface 1 "Apple Computer
ADB device" rev 2.00/19.65 addr 2
uhidev1: iclass 3/1
ums0 at uhidev1: 5 buttons
wsmouse0 at ums0 mux 0
uhidev2 at uhub3 port 2 configuration 1 interface 0 "Apple Computer,
Inc. IR Receiver" rev 2.00/1.10 addr 2
uhidev2: iclass 3/0, 38 report ids
uhid0 at uhidev2 reportid 36: input=4, output=0, feature=0
uhid1 at uhidev2 reportid 37: input=4, output=0, feature=0
uhid2 at uhidev2 reportid 38: input=4, output=0, feature=0
uhidev3 at uhub1 port 2 configuration 1 interface 0 "Apple Computer
Apple Internal Keyboard / Trackpad" rev 2.00/0.16 addr 3
uhidev3: iclass 3/1
ukbd1 at uhidev3: 8 modifier keys, 5 key codes, country code 33
wskbd1 at ukbd1 mux 1
wskbd1: connecting to wsdisplay0
uhidev4 at uhub1 port 2 configuration 1 interface 1 "Apple Computer
Apple Internal Keyboard / Trackpad" rev 2.00/0.16 addr 3
uhidev4: iclass 3/1, 5 report ids
ums1 at uhidev4 reportid 2: 3 buttons
wsmouse1 at ums1 mux 0
ums2 at uhidev4 reportid 5
ums2: mouse has no X report
uhidev5 at uhub1 port 2 configuration 1 interface 2 "Apple Computer
Apple Internal Keyboard / Trackpad" rev 2.00/0.16 addr 3
uhidev5: iclass 3/0
uhid3 at uhidev5: input=1, output=0, feature=0
softraid0 at root
root on wd0a swap on wd0b dump on wd0b
kqemu: kqemu version 0x00010300 loaded, max locked mem=1032492kB
DDB symbols added: 399816 bytes
ugen1 detached
ugen1 at uhub1 port 1 "vendor 0x0665 product 0x0301" rev 1.10/0.03 addr 2
ugen1 detached
ugen1 at uhub2 port 1 "vendor 0x0665 product 0x0301" rev 1.10/0.03 addr 2
ugen1 detached
ugen1 at uhub1 port 1 "vendor 0x0665 product 0x0301" rev 1.10/0.03 addr 2
ugen1 detached
ugen1 at uhub2 port 1 "vendor 0x0665 product 0x0301" rev 1.10/0.03 addr 2
|
|