Browse Source

Plan 9 from Bell Labs 2004-11-07

David du Colombier 19 years ago
parent
commit
e1d50f833c

+ 42 - 29
dist/replica/_plan9.db

@@ -2818,7 +2818,7 @@ mail/fs - 20000000555 upas upas 952639473 0
 mail/lib - 20000000775 upas upas 1016731571 0
 mail/lib/blocked - 664 upas upas 956777853 460
 mail/lib/classify.re - 664 upas upas 1063950966 80082
-mail/lib/ignore - 664 upas upas 1039659117 148
+mail/lib/ignore - 664 upas upas 1099760392 169
 mail/lib/isspam.rc - 775 upas upas 1063950954 600
 mail/lib/justqmail - 775 upas upas 960055415 100
 mail/lib/kickqueue - 775 upas upas 960106166 89
@@ -5017,7 +5017,7 @@ sys/man/4/tapefs - 664 sys sys 944959699 1731
 sys/man/4/telco - 664 sys sys 1015024814 4359
 sys/man/4/u9fs - 664 sys sys 1043769139 4748
 sys/man/4/upasfs - 664 sys sys 1034348505 6212
-sys/man/4/usb - 664 sys sys 1091287633 3428
+sys/man/4/usb - 664 sys sys 1099760451 3518
 sys/man/4/usbd - 664 sys sys 1018386778 731
 sys/man/4/vacfs - 664 sys sys 1084333062 1545
 sys/man/4/webcookies - 664 sys sys 1019828742 3525
@@ -5348,7 +5348,7 @@ sys/src/9/pc/dat.h - 664 sys sys 1091904418 6281
 sys/src/9/pc/devarch.c - 664 sys sys 1096379063 18517
 sys/src/9/pc/devether.c - 664 sys sys 1078928204 10183
 sys/src/9/pc/devfloppy.c - 664 sys sys 1055689885 20024
-sys/src/9/pc/devi82365.c - 664 sys sys 1086406910 19989
+sys/src/9/pc/devi82365.c - 664 sys sys 1099761153 20505
 sys/src/9/pc/devlm78.c - 664 sys sys 1091129037 6255
 sys/src/9/pc/devlml.c - 664 sys sys 1026847636 7486
 sys/src/9/pc/devlml.h - 664 sys sys 1026847636 2948
@@ -5356,7 +5356,7 @@ sys/src/9/pc/devlpt.c - 664 sys sys 1015014514 4420
 sys/src/9/pc/devpccard.c - 664 sys sys 1089299187 40138
 sys/src/9/pc/devrtc.c - 664 sys sys 1015014515 7167
 sys/src/9/pc/devtv.c - 664 sys sys 1091734484 45725
-sys/src/9/pc/devusb.c - 664 sys sys 1063857423 18352
+sys/src/9/pc/devusb.c - 664 sys sys 1099760881 18371
 sys/src/9/pc/devvga.c - 664 sys sys 1063857412 8714
 sys/src/9/pc/dma.c - 664 sys sys 1015014515 4736
 sys/src/9/pc/errstr.h - 664 sys sys 1075069582 2137
@@ -5391,7 +5391,7 @@ sys/src/9/pc/i8253.c - 664 sys sys 1096379063 6279
 sys/src/9/pc/i8259.c - 664 sys sys 1015014519 4423
 sys/src/9/pc/init9.c - 664 sys sys 1040002518 94
 sys/src/9/pc/initcode.s - 664 sys sys 1015014519 282
-sys/src/9/pc/io.h - 664 sys sys 1087657448 8029
+sys/src/9/pc/io.h - 664 sys sys 1099761152 8095
 sys/src/9/pc/kbd.c - 664 sys sys 1079617269 11655
 sys/src/9/pc/l.s - 664 sys sys 1091733374 23055
 sys/src/9/pc/main.c - 664 sys sys 1089046997 14677
@@ -5413,7 +5413,7 @@ sys/src/9/pc/pcf - 664 sys sys 1079575654 1462
 sys/src/9/pc/pcfl - 664 sys sys 1042004821 1563
 sys/src/9/pc/pcflop - 664 sys sys 1067722894 1383
 sys/src/9/pc/pci.c - 664 sys sys 1096379063 25817
-sys/src/9/pc/pcmciamodem.c - 664 sys sys 1048635123 1545
+sys/src/9/pc/pcmciamodem.c - 664 sys sys 1099761153 1586
 sys/src/9/pc/piix4smbus.c - 664 sys sys 1091129037 5230
 sys/src/9/pc/plan9l.s - 664 sys sys 1015014521 910
 sys/src/9/pc/psaux.c - 664 sys sys 1026847650 915
@@ -5432,8 +5432,8 @@ sys/src/9/pc/sdscsi.c - 664 sys sys 1077033661 7487
 sys/src/9/pc/trap.c - 664 sys sys 1092080705 20458
 sys/src/9/pc/uarti8250.c - 664 sys sys 1067722686 13859
 sys/src/9/pc/uartpci.c - 664 sys sys 1096379063 2891
-sys/src/9/pc/usb.h - 664 sys sys 1063857246 3566
-sys/src/9/pc/usbuhci.c - 664 sys sys 1091287613 30721
+sys/src/9/pc/usb.h - 664 sys sys 1099760881 3650
+sys/src/9/pc/usbuhci.c - 664 sys sys 1099760881 30955
 sys/src/9/pc/vga.c - 664 sys sys 1039753497 4963
 sys/src/9/pc/vga3dfx.c - 664 sys sys 1071247360 4867
 sys/src/9/pc/vgaark2000pv.c - 664 sys sys 1015014524 3416
@@ -5467,7 +5467,7 @@ sys/src/9/port/allocb.c - 664 sys sys 1067722759 3200
 sys/src/9/port/auth.c - 664 sys sys 1055688251 2308
 sys/src/9/port/cache.c - 664 sys sys 1055688274 9241
 sys/src/9/port/chan.c - 664 sys sys 1072704672 29140
-sys/src/9/port/cis.c - 664 sys sys 1055688285 8082
+sys/src/9/port/cis.c - 664 sys sys 1099761153 9248
 sys/src/9/port/debugalloc.c - 664 sys sys 1014931171 10402
 sys/src/9/port/dev.c - 664 sys sys 1077896125 8247
 sys/src/9/port/devaudio.c - 664 sys sys 1067722761 21130
@@ -5481,9 +5481,9 @@ sys/src/9/port/devfs.c - 664 sys sys 1081864735 10779
 sys/src/9/port/devkbmap.c - 644 sys sys 1079463756 2774
 sys/src/9/port/devkprof.c - 664 sys sys 1014931173 3111
 sys/src/9/port/devloopback.c - 664 sys sys 1076612248 14573
-sys/src/9/port/devmnt.c - 664 sys sys 1086406908 21595
+sys/src/9/port/devmnt.c - 664 sys sys 1099760932 21561
 sys/src/9/port/devmntstats.c - 664 sys sys 1014931173 4039
-sys/src/9/port/devmouse.c - 664 sys sys 1099176878 12404
+sys/src/9/port/devmouse.c - 664 sys sys 1099760452 12504
 sys/src/9/port/devnmouse.c - 664 sys sys 1036812999 3738
 sys/src/9/port/devpipe.c - 664 sys sys 1077055016 5825
 sys/src/9/port/devpnp.c - 664 sys sys 1088560907 13624
@@ -5497,7 +5497,7 @@ sys/src/9/port/devssl.c - 664 sys sys 1045063590 26100
 sys/src/9/port/devtinyfs.c - 664 sys sys 1015278339 15347
 sys/src/9/port/devtls.c - 664 sys sys 1086406907 45225
 sys/src/9/port/devuart.c - 664 sys sys 1077055016 11683
-sys/src/9/port/edf.c - 664 sys sys 1084475128 12684
+sys/src/9/port/edf.c - 664 sys sys 1099760881 12742
 sys/src/9/port/edf.h - 664 sys sys 1084475128 1156
 sys/src/9/port/error.h - 664 sys sys 1055700517 2630
 sys/src/9/port/fault.c - 664 sys sys 1067722722 6628
@@ -5529,7 +5529,7 @@ sys/src/9/port/portdat.h - 664 sys sys 1091904422 22118
 sys/src/9/port/portfns.h - 664 sys sys 1091904430 11426
 sys/src/9/port/portmkfile - 664 sys sys 1091733856 2087
 sys/src/9/port/print.c - 664 sys sys 1014931178 227
-sys/src/9/port/proc.c - 664 sys sys 1094293852 28200
+sys/src/9/port/proc.c - 664 sys sys 1099760501 28207
 sys/src/9/port/qio.c - 664 sys sys 1070287837 23562
 sys/src/9/port/qlock.c - 664 sys sys 1067722765 3196
 sys/src/9/port/rdb.c - 664 sys sys 1018721202 1698
@@ -7070,7 +7070,7 @@ sys/src/cmd/aux/na/na.h - 775 sys sys 955036627 267
 sys/src/cmd/aux/na/na.y - 775 sys sys 1015008889 25158
 sys/src/cmd/aux/nfsmount.c - 664 sys sys 1045589268 6202
 sys/src/cmd/aux/olefs.c - 664 sys sys 1071245775 9853
-sys/src/cmd/aux/pcmcia.c - 664 sys sys 1065397225 8366
+sys/src/cmd/aux/pcmcia.c - 664 sys sys 1099761153 9213
 sys/src/cmd/aux/portmap.c - 664 sys sys 1049776133 3617
 sys/src/cmd/aux/rdwr.c - 664 sys sys 1016833876 811
 sys/src/cmd/aux/reboot.c - 664 sys sys 1014925091 1411
@@ -7356,7 +7356,7 @@ sys/src/cmd/diff/diff.h - 664 sys sys 1014925333 769
 sys/src/cmd/diff/diffdir.c - 664 sys sys 1014925333 1791
 sys/src/cmd/diff/diffio.c - 664 sys sys 1014925334 5031
 sys/src/cmd/diff/diffreg.c - 664 sys sys 1014925334 8825
-sys/src/cmd/diff/main.c - 664 sys sys 1077133741 4300
+sys/src/cmd/diff/main.c - 664 sys sys 1099755545 4312
 sys/src/cmd/diff/mkfile - 664 sys sys 944960882 141
 sys/src/cmd/disk - 20000000775 sys sys 1018468546 0
 sys/src/cmd/disk/9660 - 20000000775 sys sys 1017681443 0
@@ -9371,7 +9371,7 @@ sys/src/cmd/gs/zlib/zlib.h - 664 sys sys 1015035350 36326
 sys/src/cmd/gs/zlib/zlib.rc - 644 sys sys 1015035349 879
 sys/src/cmd/gs/zlib/zutil.c - 664 sys sys 1015035350 5015
 sys/src/cmd/gs/zlib/zutil.h - 664 sys sys 1015035350 4945
-sys/src/cmd/gview.c - 664 sys sys 1087829737 50641
+sys/src/cmd/gview.c - 664 sys sys 1099760990 50655
 sys/src/cmd/gzip - 20000000775 sys sys 984789976 0
 sys/src/cmd/gzip/gunzip.c - 664 sys sys 1014924864 6039
 sys/src/cmd/gzip/gzip.c - 664 sys sys 1014924864 3646
@@ -10243,7 +10243,7 @@ sys/src/cmd/rio/wctl.c - 664 sys sys 1023206837 8808
 sys/src/cmd/rio/wind.c - 664 sys sys 1097973839 32996
 sys/src/cmd/rio/xfid.c - 664 sys sys 1032061723 17424
 sys/src/cmd/rm.c - 664 sys sys 1014926615 1563
-sys/src/cmd/rx.c - 664 sys sys 1071155928 4188
+sys/src/cmd/rx.c - 664 sys sys 1099760378 4382
 sys/src/cmd/sam - 20000000775 sys sys 944961629 0
 sys/src/cmd/sam/address.c - 664 sys sys 944961628 3985
 sys/src/cmd/sam/buff.c - 664 sys sys 1014926937 5161
@@ -10512,10 +10512,10 @@ sys/src/cmd/test.c - 664 sys sys 1079372543 5409
 sys/src/cmd/time.c - 664 sys sys 1014926662 1546
 sys/src/cmd/tlsclient.c - 664 sys sys 1024375149 1631
 sys/src/cmd/tlssrv.c - 664 sys sys 1087829606 3411
-sys/src/cmd/touch.c - 664 sys sys 1018387005 893
+sys/src/cmd/touch.c - 664 sys sys 1099760670 899
 sys/src/cmd/tprof.c - 664 sys sys 1063858806 2716
 sys/src/cmd/tr.c - 664 sys sys 944961464 6008
-sys/src/cmd/trace.c - 664 sys sys 1089299188 17772
+sys/src/cmd/trace.c - 664 sys sys 1099760769 17947
 sys/src/cmd/troff - 20000000775 sys sys 944961294 0
 sys/src/cmd/troff/FIXES - 644 sys sys 944961293 24982
 sys/src/cmd/troff/README - 644 sys sys 944961293 1168
@@ -10929,24 +10929,24 @@ sys/src/cmd/upas/vf/mkfile - 664 sys sys 1064393881 241
 sys/src/cmd/upas/vf/vf.c - 664 sys sys 1087829630 17442
 sys/src/cmd/usb - 20000000775 sys sys 1017802022 0
 sys/src/cmd/usb/audio - 20000000775 sys sys 1017802021 0
-sys/src/cmd/usb/audio/audiofs.c - 664 sys sys 1091204980 18166
-sys/src/cmd/usb/audio/audiosub.c - 664 sys sys 1091204980 6967
+sys/src/cmd/usb/audio/audiofs.c - 664 sys sys 1099760452 18231
+sys/src/cmd/usb/audio/audiosub.c - 664 sys sys 1099760453 13512
 sys/src/cmd/usb/audio/mkfile - 664 sys sys 1091204980 349
-sys/src/cmd/usb/audio/usbaudio.c - 664 sys sys 1091243258 9824
-sys/src/cmd/usb/audio/usbaudio.h - 664 sys sys 1091204979 1861
-sys/src/cmd/usb/audio/usbaudioctl.c - 664 sys sys 1091204980 17278
-sys/src/cmd/usb/audio/usbaudioctl.h - 664 sys sys 1091204980 600
+sys/src/cmd/usb/audio/usbaudio.c - 664 sys sys 1099760452 15571
+sys/src/cmd/usb/audio/usbaudio.h - 664 sys sys 1099760452 1911
+sys/src/cmd/usb/audio/usbaudioctl.c - 664 sys sys 1099760452 42236
+sys/src/cmd/usb/audio/usbaudioctl.h - 664 sys sys 1099760453 2120
 sys/src/cmd/usb/lib - 20000000775 sys sys 1018369393 0
-sys/src/cmd/usb/lib/device.c - 664 sys sys 1091204978 2854
-sys/src/cmd/usb/lib/dump.c - 664 sys sys 1091204978 12457
+sys/src/cmd/usb/lib/device.c - 664 sys sys 1099760882 2968
+sys/src/cmd/usb/lib/dump.c - 664 sys sys 1099760882 12704
 sys/src/cmd/usb/lib/fmt.c - 664 sys sys 1091204978 291
 sys/src/cmd/usb/lib/mkfile - 664 sys sys 1091204979 204
 sys/src/cmd/usb/lib/setup.c - 664 sys sys 1091204978 1953
-sys/src/cmd/usb/lib/usb.h - 664 sys sys 1091204978 6703
+sys/src/cmd/usb/lib/usb.h - 664 sys sys 1099760882 6816
 sys/src/cmd/usb/lib/util.c - 664 sys sys 1091204978 523
 sys/src/cmd/usb/misc - 20000000775 sys sys 1091205037 0
 sys/src/cmd/usb/misc/mkfile - 664 sys sys 1091205037 274
-sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1091282306 3056
+sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1099760451 3451
 sys/src/cmd/usb/misc/usbprint - 775 sys sys 1091205037 234
 sys/src/cmd/usb/mkfile - 664 sys sys 1091327562 354
 sys/src/cmd/usb/mouse - 20000000775 sys sys 1017802022 0
@@ -12392,3 +12392,16 @@ usr/glenda/lib/profile - 664 glenda glenda 1021580005 847
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
+386/9pccpu - 775 sys sys 1099800621 1477040
+386/9pcdisk - 775 sys sys 1099800625 2024653
+386/9pcf - 775 sys sys 1099800630 2356296
+386/bin/diff - 775 sys sys 1099800611 81711
+386/bin/usb/usbaudio - 775 sys sys 1099800617 206890
+386/bin/usb/usbd - 775 sys sys 1099800617 127661
+386/bin/usb/usbmouse - 775 sys sys 1099800618 138206
+386/bin/rx - 775 sys sys 1099800614 80016
+386/bin/aux/pcmcia - 775 sys sys 1099800610 46870
+386/bin/gview - 775 sys sys 1099800613 235167
+386/bin/touch - 775 sys sys 1099800615 61724
+386/bin/trace - 775 sys sys 1099800616 178695
+sys/src/9/bitsy/devpcmcia.c - 664 sys sys 1099801570 12977

+ 42 - 42
dist/replica/plan9.db

@@ -5,11 +5,11 @@
 386/9loadlitedebug - 775 sys sys 1097744361 194456
 386/9pc - 775 sys sys 1099545481 1820993
 386/9pc.gz - 664 sys sys 1077049336 635727
-386/9pccpu - 775 sys sys 1099545485 1477015
+386/9pccpu - 775 sys sys 1099800621 1477040
 386/9pccpu.gz - 664 sys sys 1077049387 519909
-386/9pcdisk - 775 sys sys 1099545489 2023599
+386/9pcdisk - 775 sys sys 1099800625 2024653
 386/9pcdisk.gz - 664 sys sys 1040006345 703136
-386/9pcf - 775 sys sys 1099545494 2355242
+386/9pcf - 775 sys sys 1099800630 2356296
 386/9pcf.gz - 664 sys sys 1077049490 872650
 386/9pxeload - 775 sys sys 1097716797 208292
 386/_9pcdisk.gz - 664 sys sys 1039764191 695837
@@ -122,7 +122,7 @@
 386/bin/aux/nfsserver - 775 sys sys 1089257529 183491
 386/bin/aux/olefs - 775 sys sys 1089397310 141220
 386/bin/aux/p9bitpost - 775 sys sys 1085077001 127286
-386/bin/aux/pcmcia - 775 sys sys 1085077001 46277
+386/bin/aux/pcmcia - 775 sys sys 1099800610 46870
 386/bin/aux/pcnfsd - 775 sys sys 1089257529 127413
 386/bin/aux/portmap - 775 sys sys 1085077002 141765
 386/bin/aux/portmapper - 775 sys sys 1089257529 126299
@@ -194,7 +194,7 @@
 386/bin/dial/expect - 775 sys sys 1085077029 58049
 386/bin/dial/pass - 775 sys sys 1085077030 38786
 386/bin/dict - 775 sys sys 1085077031 183178
-386/bin/diff - 775 sys sys 1085077032 81776
+386/bin/diff - 775 sys sys 1099800611 81711
 386/bin/disk - 20000000775 sys sys 984788664 0
 386/bin/disk/dump9660 - 775 sys sys 1085077032 150298
 386/bin/disk/exsort - 775 sys sys 1085077033 58245
@@ -251,7 +251,7 @@
 386/bin/grep - 775 sys sys 1092021261 77012
 386/bin/gs - 775 sys sys 1094040110 11124993
 386/bin/gunzip - 775 sys sys 1085077061 78252
-386/bin/gview - 775 sys sys 1098158506 235151
+386/bin/gview - 775 sys sys 1099800613 235167
 386/bin/gzip - 775 sys sys 1085077061 82899
 386/bin/hayes - 775 sys sys 1085077062 62579
 386/bin/hget - 775 sys sys 1091156987 230376
@@ -372,7 +372,7 @@
 386/bin/resample - 775 sys sys 1085077093 119901
 386/bin/rio - 775 sys sys 1098536528 306778
 386/bin/rm - 775 sys sys 1085077094 59308
-386/bin/rx - 775 sys sys 1085077094 79893
+386/bin/rx - 775 sys sys 1099800614 80016
 386/bin/sam - 775 sys sys 1085077095 155916
 386/bin/scat - 775 sys sys 1085077095 281706
 386/bin/scp - 775 sys sys 1094218814 149872
@@ -415,10 +415,10 @@
 386/bin/toico - 775 sys sys 1085077106 121674
 386/bin/topng - 775 sys sys 1085077107 137101
 386/bin/toppm - 775 sys sys 1085077107 164405
-386/bin/touch - 775 sys sys 1085077107 61742
+386/bin/touch - 775 sys sys 1099800615 61724
 386/bin/tprof - 775 sys sys 1091936096 253053
 386/bin/tr - 775 sys sys 1085077108 60009
-386/bin/trace - 775 sys sys 1089397319 178457
+386/bin/trace - 775 sys sys 1099800616 178695
 386/bin/troff - 775 sys sys 1094040114 357714
 386/bin/troff2html - 775 sys sys 1085077109 80041
 386/bin/tweak - 775 sys sys 1098158514 189711
@@ -458,9 +458,9 @@
 386/bin/upas/unspam - 775 sys sys 1064598367 38
 386/bin/upas/vf - 775 sys sys 1087873352 90619
 386/bin/usb - 20000000775 sys sys 1019538890 0
-386/bin/usb/usbaudio - 775 sys sys 1091331846 183070
-386/bin/usb/usbd - 775 sys sys 1091242967 127455
-386/bin/usb/usbmouse - 775 sys sys 1091331846 137865
+386/bin/usb/usbaudio - 775 sys sys 1099800617 206890
+386/bin/usb/usbd - 775 sys sys 1099800617 127661
+386/bin/usb/usbmouse - 775 sys sys 1099800618 138206
 386/bin/usb/usbprinter - 775 sys sys 1089408719 222
 386/bin/vac - 775 sys sys 1085077119 167554
 386/bin/vacfs - 775 sys sys 1085077120 172959
@@ -2818,7 +2818,7 @@ mail/fs - 20000000555 upas upas 952639473 0
 mail/lib - 20000000775 upas upas 1016731571 0
 mail/lib/blocked - 664 upas upas 956777853 460
 mail/lib/classify.re - 664 upas upas 1063950966 80082
-mail/lib/ignore - 664 upas upas 1039659117 148
+mail/lib/ignore - 664 upas upas 1099760392 169
 mail/lib/isspam.rc - 775 upas upas 1063950954 600
 mail/lib/justqmail - 775 upas upas 960055415 100
 mail/lib/kickqueue - 775 upas upas 960106166 89
@@ -5017,7 +5017,7 @@ sys/man/4/tapefs - 664 sys sys 944959699 1731
 sys/man/4/telco - 664 sys sys 1015024814 4359
 sys/man/4/u9fs - 664 sys sys 1043769139 4748
 sys/man/4/upasfs - 664 sys sys 1034348505 6212
-sys/man/4/usb - 664 sys sys 1091287633 3428
+sys/man/4/usb - 664 sys sys 1099760451 3518
 sys/man/4/usbd - 664 sys sys 1018386778 731
 sys/man/4/vacfs - 664 sys sys 1084333062 1545
 sys/man/4/webcookies - 664 sys sys 1019828742 3525
@@ -5211,7 +5211,7 @@ sys/src/9/bitsy/dat.h - 664 sys sys 1091904418 5790
 sys/src/9/bitsy/defont.c - 664 sys sys 1017695511 21570
 sys/src/9/bitsy/devether.c - 664 sys sys 1037029002 10675
 sys/src/9/bitsy/devflash.c - 664 sys sys 1018386999 16832
-sys/src/9/bitsy/devpcmcia.c - 664 sys sys 1071245513 12963
+sys/src/9/bitsy/devpcmcia.c - 664 sys sys 1099801570 12977
 sys/src/9/bitsy/devpenmouse.c - 664 sys sys 1067722592 9296
 sys/src/9/bitsy/devuda1341.c - 664 sys sys 1071245420 30346
 sys/src/9/bitsy/devµc.c - 664 sys sys 1068393562 8125
@@ -5348,7 +5348,7 @@ sys/src/9/pc/dat.h - 664 sys sys 1091904418 6281
 sys/src/9/pc/devarch.c - 664 sys sys 1096379063 18517
 sys/src/9/pc/devether.c - 664 sys sys 1078928204 10183
 sys/src/9/pc/devfloppy.c - 664 sys sys 1055689885 20024
-sys/src/9/pc/devi82365.c - 664 sys sys 1086406910 19989
+sys/src/9/pc/devi82365.c - 664 sys sys 1099761153 20505
 sys/src/9/pc/devlm78.c - 664 sys sys 1091129037 6255
 sys/src/9/pc/devlml.c - 664 sys sys 1026847636 7486
 sys/src/9/pc/devlml.h - 664 sys sys 1026847636 2948
@@ -5356,7 +5356,7 @@ sys/src/9/pc/devlpt.c - 664 sys sys 1015014514 4420
 sys/src/9/pc/devpccard.c - 664 sys sys 1089299187 40138
 sys/src/9/pc/devrtc.c - 664 sys sys 1015014515 7167
 sys/src/9/pc/devtv.c - 664 sys sys 1091734484 45725
-sys/src/9/pc/devusb.c - 664 sys sys 1063857423 18352
+sys/src/9/pc/devusb.c - 664 sys sys 1099760881 18371
 sys/src/9/pc/devvga.c - 664 sys sys 1063857412 8714
 sys/src/9/pc/dma.c - 664 sys sys 1015014515 4736
 sys/src/9/pc/errstr.h - 664 sys sys 1075069582 2137
@@ -5391,7 +5391,7 @@ sys/src/9/pc/i8253.c - 664 sys sys 1096379063 6279
 sys/src/9/pc/i8259.c - 664 sys sys 1015014519 4423
 sys/src/9/pc/init9.c - 664 sys sys 1040002518 94
 sys/src/9/pc/initcode.s - 664 sys sys 1015014519 282
-sys/src/9/pc/io.h - 664 sys sys 1087657448 8029
+sys/src/9/pc/io.h - 664 sys sys 1099761152 8095
 sys/src/9/pc/kbd.c - 664 sys sys 1079617269 11655
 sys/src/9/pc/l.s - 664 sys sys 1091733374 23055
 sys/src/9/pc/main.c - 664 sys sys 1089046997 14677
@@ -5413,7 +5413,7 @@ sys/src/9/pc/pcf - 664 sys sys 1079575654 1462
 sys/src/9/pc/pcfl - 664 sys sys 1042004821 1563
 sys/src/9/pc/pcflop - 664 sys sys 1067722894 1383
 sys/src/9/pc/pci.c - 664 sys sys 1096379063 25817
-sys/src/9/pc/pcmciamodem.c - 664 sys sys 1048635123 1545
+sys/src/9/pc/pcmciamodem.c - 664 sys sys 1099761153 1586
 sys/src/9/pc/piix4smbus.c - 664 sys sys 1091129037 5230
 sys/src/9/pc/plan9l.s - 664 sys sys 1015014521 910
 sys/src/9/pc/psaux.c - 664 sys sys 1026847650 915
@@ -5432,8 +5432,8 @@ sys/src/9/pc/sdscsi.c - 664 sys sys 1077033661 7487
 sys/src/9/pc/trap.c - 664 sys sys 1092080705 20458
 sys/src/9/pc/uarti8250.c - 664 sys sys 1067722686 13859
 sys/src/9/pc/uartpci.c - 664 sys sys 1096379063 2891
-sys/src/9/pc/usb.h - 664 sys sys 1063857246 3566
-sys/src/9/pc/usbuhci.c - 664 sys sys 1091287613 30721
+sys/src/9/pc/usb.h - 664 sys sys 1099760881 3650
+sys/src/9/pc/usbuhci.c - 664 sys sys 1099760881 30955
 sys/src/9/pc/vga.c - 664 sys sys 1039753497 4963
 sys/src/9/pc/vga3dfx.c - 664 sys sys 1071247360 4867
 sys/src/9/pc/vgaark2000pv.c - 664 sys sys 1015014524 3416
@@ -5467,7 +5467,7 @@ sys/src/9/port/allocb.c - 664 sys sys 1067722759 3200
 sys/src/9/port/auth.c - 664 sys sys 1055688251 2308
 sys/src/9/port/cache.c - 664 sys sys 1055688274 9241
 sys/src/9/port/chan.c - 664 sys sys 1072704672 29140
-sys/src/9/port/cis.c - 664 sys sys 1055688285 8082
+sys/src/9/port/cis.c - 664 sys sys 1099761153 9248
 sys/src/9/port/debugalloc.c - 664 sys sys 1014931171 10402
 sys/src/9/port/dev.c - 664 sys sys 1077896125 8247
 sys/src/9/port/devaudio.c - 664 sys sys 1067722761 21130
@@ -5481,9 +5481,9 @@ sys/src/9/port/devfs.c - 664 sys sys 1081864735 10779
 sys/src/9/port/devkbmap.c - 644 sys sys 1079463756 2774
 sys/src/9/port/devkprof.c - 664 sys sys 1014931173 3111
 sys/src/9/port/devloopback.c - 664 sys sys 1076612248 14573
-sys/src/9/port/devmnt.c - 664 sys sys 1086406908 21595
+sys/src/9/port/devmnt.c - 664 sys sys 1099760932 21561
 sys/src/9/port/devmntstats.c - 664 sys sys 1014931173 4039
-sys/src/9/port/devmouse.c - 664 sys sys 1099176878 12404
+sys/src/9/port/devmouse.c - 664 sys sys 1099760452 12504
 sys/src/9/port/devnmouse.c - 664 sys sys 1036812999 3738
 sys/src/9/port/devpipe.c - 664 sys sys 1077055016 5825
 sys/src/9/port/devpnp.c - 664 sys sys 1088560907 13624
@@ -5497,7 +5497,7 @@ sys/src/9/port/devssl.c - 664 sys sys 1045063590 26100
 sys/src/9/port/devtinyfs.c - 664 sys sys 1015278339 15347
 sys/src/9/port/devtls.c - 664 sys sys 1086406907 45225
 sys/src/9/port/devuart.c - 664 sys sys 1077055016 11683
-sys/src/9/port/edf.c - 664 sys sys 1084475128 12684
+sys/src/9/port/edf.c - 664 sys sys 1099760881 12742
 sys/src/9/port/edf.h - 664 sys sys 1084475128 1156
 sys/src/9/port/error.h - 664 sys sys 1055700517 2630
 sys/src/9/port/fault.c - 664 sys sys 1067722722 6628
@@ -5529,7 +5529,7 @@ sys/src/9/port/portdat.h - 664 sys sys 1091904422 22118
 sys/src/9/port/portfns.h - 664 sys sys 1091904430 11426
 sys/src/9/port/portmkfile - 664 sys sys 1091733856 2087
 sys/src/9/port/print.c - 664 sys sys 1014931178 227
-sys/src/9/port/proc.c - 664 sys sys 1094293852 28200
+sys/src/9/port/proc.c - 664 sys sys 1099760501 28207
 sys/src/9/port/qio.c - 664 sys sys 1070287837 23562
 sys/src/9/port/qlock.c - 664 sys sys 1067722765 3196
 sys/src/9/port/rdb.c - 664 sys sys 1018721202 1698
@@ -7070,7 +7070,7 @@ sys/src/cmd/aux/na/na.h - 775 sys sys 955036627 267
 sys/src/cmd/aux/na/na.y - 775 sys sys 1015008889 25158
 sys/src/cmd/aux/nfsmount.c - 664 sys sys 1045589268 6202
 sys/src/cmd/aux/olefs.c - 664 sys sys 1071245775 9853
-sys/src/cmd/aux/pcmcia.c - 664 sys sys 1065397225 8366
+sys/src/cmd/aux/pcmcia.c - 664 sys sys 1099761153 9213
 sys/src/cmd/aux/portmap.c - 664 sys sys 1049776133 3617
 sys/src/cmd/aux/rdwr.c - 664 sys sys 1016833876 811
 sys/src/cmd/aux/reboot.c - 664 sys sys 1014925091 1411
@@ -7356,7 +7356,7 @@ sys/src/cmd/diff/diff.h - 664 sys sys 1014925333 769
 sys/src/cmd/diff/diffdir.c - 664 sys sys 1014925333 1791
 sys/src/cmd/diff/diffio.c - 664 sys sys 1014925334 5031
 sys/src/cmd/diff/diffreg.c - 664 sys sys 1014925334 8825
-sys/src/cmd/diff/main.c - 664 sys sys 1077133741 4300
+sys/src/cmd/diff/main.c - 664 sys sys 1099755545 4312
 sys/src/cmd/diff/mkfile - 664 sys sys 944960882 141
 sys/src/cmd/disk - 20000000775 sys sys 1018468546 0
 sys/src/cmd/disk/9660 - 20000000775 sys sys 1017681443 0
@@ -9371,7 +9371,7 @@ sys/src/cmd/gs/zlib/zlib.h - 664 sys sys 1015035350 36326
 sys/src/cmd/gs/zlib/zlib.rc - 644 sys sys 1015035349 879
 sys/src/cmd/gs/zlib/zutil.c - 664 sys sys 1015035350 5015
 sys/src/cmd/gs/zlib/zutil.h - 664 sys sys 1015035350 4945
-sys/src/cmd/gview.c - 664 sys sys 1087829737 50641
+sys/src/cmd/gview.c - 664 sys sys 1099760990 50655
 sys/src/cmd/gzip - 20000000775 sys sys 984789976 0
 sys/src/cmd/gzip/gunzip.c - 664 sys sys 1014924864 6039
 sys/src/cmd/gzip/gzip.c - 664 sys sys 1014924864 3646
@@ -10243,7 +10243,7 @@ sys/src/cmd/rio/wctl.c - 664 sys sys 1023206837 8808
 sys/src/cmd/rio/wind.c - 664 sys sys 1097973839 32996
 sys/src/cmd/rio/xfid.c - 664 sys sys 1032061723 17424
 sys/src/cmd/rm.c - 664 sys sys 1014926615 1563
-sys/src/cmd/rx.c - 664 sys sys 1071155928 4188
+sys/src/cmd/rx.c - 664 sys sys 1099760378 4382
 sys/src/cmd/sam - 20000000775 sys sys 944961629 0
 sys/src/cmd/sam/address.c - 664 sys sys 944961628 3985
 sys/src/cmd/sam/buff.c - 664 sys sys 1014926937 5161
@@ -10512,10 +10512,10 @@ sys/src/cmd/test.c - 664 sys sys 1079372543 5409
 sys/src/cmd/time.c - 664 sys sys 1014926662 1546
 sys/src/cmd/tlsclient.c - 664 sys sys 1024375149 1631
 sys/src/cmd/tlssrv.c - 664 sys sys 1087829606 3411
-sys/src/cmd/touch.c - 664 sys sys 1018387005 893
+sys/src/cmd/touch.c - 664 sys sys 1099760670 899
 sys/src/cmd/tprof.c - 664 sys sys 1063858806 2716
 sys/src/cmd/tr.c - 664 sys sys 944961464 6008
-sys/src/cmd/trace.c - 664 sys sys 1089299188 17772
+sys/src/cmd/trace.c - 664 sys sys 1099760769 17947
 sys/src/cmd/troff - 20000000775 sys sys 944961294 0
 sys/src/cmd/troff/FIXES - 644 sys sys 944961293 24982
 sys/src/cmd/troff/README - 644 sys sys 944961293 1168
@@ -10929,24 +10929,24 @@ sys/src/cmd/upas/vf/mkfile - 664 sys sys 1064393881 241
 sys/src/cmd/upas/vf/vf.c - 664 sys sys 1087829630 17442
 sys/src/cmd/usb - 20000000775 sys sys 1017802022 0
 sys/src/cmd/usb/audio - 20000000775 sys sys 1017802021 0
-sys/src/cmd/usb/audio/audiofs.c - 664 sys sys 1091204980 18166
-sys/src/cmd/usb/audio/audiosub.c - 664 sys sys 1091204980 6967
+sys/src/cmd/usb/audio/audiofs.c - 664 sys sys 1099760452 18231
+sys/src/cmd/usb/audio/audiosub.c - 664 sys sys 1099760453 13512
 sys/src/cmd/usb/audio/mkfile - 664 sys sys 1091204980 349
-sys/src/cmd/usb/audio/usbaudio.c - 664 sys sys 1091243258 9824
-sys/src/cmd/usb/audio/usbaudio.h - 664 sys sys 1091204979 1861
-sys/src/cmd/usb/audio/usbaudioctl.c - 664 sys sys 1091204980 17278
-sys/src/cmd/usb/audio/usbaudioctl.h - 664 sys sys 1091204980 600
+sys/src/cmd/usb/audio/usbaudio.c - 664 sys sys 1099760452 15571
+sys/src/cmd/usb/audio/usbaudio.h - 664 sys sys 1099760452 1911
+sys/src/cmd/usb/audio/usbaudioctl.c - 664 sys sys 1099760452 42236
+sys/src/cmd/usb/audio/usbaudioctl.h - 664 sys sys 1099760453 2120
 sys/src/cmd/usb/lib - 20000000775 sys sys 1018369393 0
-sys/src/cmd/usb/lib/device.c - 664 sys sys 1091204978 2854
-sys/src/cmd/usb/lib/dump.c - 664 sys sys 1091204978 12457
+sys/src/cmd/usb/lib/device.c - 664 sys sys 1099760882 2968
+sys/src/cmd/usb/lib/dump.c - 664 sys sys 1099760882 12704
 sys/src/cmd/usb/lib/fmt.c - 664 sys sys 1091204978 291
 sys/src/cmd/usb/lib/mkfile - 664 sys sys 1091204979 204
 sys/src/cmd/usb/lib/setup.c - 664 sys sys 1091204978 1953
-sys/src/cmd/usb/lib/usb.h - 664 sys sys 1091204978 6703
+sys/src/cmd/usb/lib/usb.h - 664 sys sys 1099760882 6816
 sys/src/cmd/usb/lib/util.c - 664 sys sys 1091204978 523
 sys/src/cmd/usb/misc - 20000000775 sys sys 1091205037 0
 sys/src/cmd/usb/misc/mkfile - 664 sys sys 1091205037 274
-sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1091282306 3056
+sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1099760451 3451
 sys/src/cmd/usb/misc/usbprint - 775 sys sys 1091205037 234
 sys/src/cmd/usb/mkfile - 664 sys sys 1091327562 354
 sys/src/cmd/usb/mouse - 20000000775 sys sys 1017802022 0

+ 42 - 0
dist/replica/plan9.log

@@ -16972,3 +16972,45 @@
 1099546212 2 c 386/9pcdisk - 775 sys sys 1099545489 2023599
 1099546212 3 c 386/9pcf - 775 sys sys 1099545494 2355242
 1099546212 4 c 386/bin/acme - 775 sys sys 1099545477 425223
+1099756853 0 c sys/src/cmd/diff/main.c - 664 sys sys 1099755545 4312
+1099760453 0 c mail/lib/ignore - 664 upas upas 1099760392 169
+1099760453 1 c sys/man/4/usb - 664 sys sys 1099760451 3518
+1099760453 2 c sys/src/9/port/devmouse.c - 664 sys sys 1099760452 12504
+1099760453 3 c sys/src/cmd/usb/audio/audiofs.c - 664 sys sys 1099760452 18231
+1099760453 4 c sys/src/cmd/usb/audio/audiosub.c - 664 sys sys 1099760453 13512
+1099760453 5 c sys/src/cmd/usb/audio/usbaudio.c - 664 sys sys 1099760452 15571
+1099760453 6 c sys/src/cmd/usb/audio/usbaudio.h - 664 sys sys 1099760452 1911
+1099760453 7 c sys/src/cmd/usb/audio/usbaudioctl.c - 664 sys sys 1099760452 42236
+1099760453 8 c sys/src/cmd/usb/audio/usbaudioctl.h - 664 sys sys 1099760453 2120
+1099760453 9 c sys/src/cmd/usb/misc/usbmouse.c - 664 sys sys 1099760451 3451
+1099760453 10 c sys/src/cmd/rx.c - 664 sys sys 1099760378 4382
+1099762254 0 c sys/src/9/pc/devi82365.c - 664 sys sys 1099761153 20505
+1099762254 1 c sys/src/9/pc/devusb.c - 664 sys sys 1099760881 18371
+1099762254 2 c sys/src/9/pc/io.h - 664 sys sys 1099761152 8095
+1099762254 3 c sys/src/9/pc/pcmciamodem.c - 664 sys sys 1099761153 1586
+1099762254 4 c sys/src/9/pc/usb.h - 664 sys sys 1099760881 3650
+1099762254 5 c sys/src/9/pc/usbuhci.c - 664 sys sys 1099760881 30955
+1099762254 6 c sys/src/9/port/cis.c - 664 sys sys 1099761153 9248
+1099762254 7 c sys/src/9/port/devmnt.c - 664 sys sys 1099760932 21561
+1099762254 8 c sys/src/9/port/edf.c - 664 sys sys 1099760881 12742
+1099762254 9 c sys/src/9/port/proc.c - 664 sys sys 1099760501 28207
+1099762254 10 c sys/src/cmd/aux/pcmcia.c - 664 sys sys 1099761153 9213
+1099762254 11 c sys/src/cmd/gview.c - 664 sys sys 1099760990 50655
+1099762254 12 c sys/src/cmd/touch.c - 664 sys sys 1099760670 899
+1099762254 13 c sys/src/cmd/usb/lib/device.c - 664 sys sys 1099760882 2968
+1099762254 14 c sys/src/cmd/usb/lib/dump.c - 664 sys sys 1099760882 12704
+1099762254 15 c sys/src/cmd/usb/lib/usb.h - 664 sys sys 1099760882 6816
+1099762254 16 c sys/src/cmd/trace.c - 664 sys sys 1099760769 17947
+1099801861 0 c 386/9pccpu - 775 sys sys 1099800621 1477040
+1099801861 1 c 386/9pcdisk - 775 sys sys 1099800625 2024653
+1099801861 2 c 386/9pcf - 775 sys sys 1099800630 2356296
+1099801861 3 c 386/bin/diff - 775 sys sys 1099800611 81711
+1099801861 4 c 386/bin/usb/usbaudio - 775 sys sys 1099800617 206890
+1099801861 5 c 386/bin/usb/usbd - 775 sys sys 1099800617 127661
+1099801861 6 c 386/bin/usb/usbmouse - 775 sys sys 1099800618 138206
+1099801861 7 c 386/bin/rx - 775 sys sys 1099800614 80016
+1099801861 8 c 386/bin/aux/pcmcia - 775 sys sys 1099800610 46870
+1099801861 9 c 386/bin/gview - 775 sys sys 1099800613 235167
+1099801861 10 c 386/bin/touch - 775 sys sys 1099800615 61724
+1099801861 11 c 386/bin/trace - 775 sys sys 1099800616 178695
+1099801861 12 c sys/src/9/bitsy/devpcmcia.c - 664 sys sys 1099801570 12977

+ 1 - 0
mail/lib/ignore

@@ -13,3 +13,4 @@ Organization:
 User-Agent:
 In-Reply-To:
 Delivered-To:
+DomainKey-Signature:

+ 13 - 6
sys/man/4/usb

@@ -7,7 +7,10 @@ usbprinter
 .SH SYNOPSIS
 .B usb/usbmouse
 [
-.B -f
+.B \-s
+] [
+[
+.B \-f
 ] [
 .I ctrlno
 .I n
@@ -15,15 +18,15 @@ usbprinter
 .PP
 .B usb/usbaudio
 [
-.B -V
+.B \-V
 ] [
-.B -v
+.B \-v
 .I volume
 ] [
-.B -m
+.B \-m
 .I mountpoint
 ] [
-.B -s
+.B \-s
 .I srvname
 ] [
 .I ctrlno
@@ -49,7 +52,11 @@ and uses the first one it finds.  A pair of numeric arguments overrides this sea
 with a specific USB controller and device.
 .PP
 The
-.B -f
+.B \-s
+flag enables scroll-wheel or scroll-button, if present.
+.PP
+The
+.B \-f
 flag runs
 .B usbmouse
 in the foreground.

+ 2 - 2
sys/src/9/bitsy/devpcmcia.c

@@ -388,9 +388,9 @@ pcmctlwrite(char *p, long n, ulong, PCMslot *sp)
 				error("bad configuration index");
 			index = i;
 		}
-		if(sp->cpresent & (1<<Rconfig)){
+		if(sp->cfg[0].cpresent & (1<<Rconfig)){
 			cp = sp->attr;
-			cp += sp->caddr + Rconfig;
+			cp += sp->cfg[0].caddr + Rconfig;
 			*cp = index;
 		}
 

+ 30 - 9
sys/src/9/pc/devi82365.c

@@ -83,6 +83,12 @@ enum
 	Rconfig=	0,
 	 Creset=	 (1<<7),	/*  reset device */
 	 Clevel=	 (1<<6),	/*  level sensitive interrupt line */
+	 Cirq=		 (1<<2),	/*  IRQ enable */
+	 Cdecode=	 (1<<1),	/*  address decode */
+	 Cfunc=		 (1<<0),	/*  function enable */
+	Riobase0=	5,
+	Riobase1=	6,
+	Riosize=	9,
 };
 
 #define MAP(x,o)	(Rmap + (x)*0x8 + o)
@@ -180,7 +186,7 @@ slotena(PCMslot *pp)
 	wrreg(pp, Rigc, 0);
 	delay(100);
 	wrreg(pp, Rigc, Fnotreset);
-	delay(500);
+	delay(5000);
 
 	/* get configuration */
 	slotinfo(pp);
@@ -922,8 +928,8 @@ pcmio(int slotno, ISAConf *isa)
 			return -1;
 		ct = &pp->ctab[index];
 	}
+
 	if(ct == 0){
-	
 		/* assume default is right */
 		if(pp->def)
 			ct = pp->def;
@@ -992,7 +998,7 @@ pcmio(int slotno, ISAConf *isa)
 	wrreg(pp, Riotop0lo, i);
 	wrreg(pp, Riotop0hi, i>>8);
 	we |= 1<<6;
-	if(ct->nio == 2 && ct->io[1].start){
+	if(ct->nio >= 2 && ct->io[1].start){
 		wrreg(pp, Riobtm1lo, ct->io[1].start);
 		wrreg(pp, Riobtm1hi, ct->io[1].start>>8);
 		i = ct->io[1].start+ct->io[1].len-1;
@@ -1003,10 +1009,10 @@ pcmio(int slotno, ISAConf *isa)
 	wrreg(pp, Rwe, we);
 
 	/* only touch Rconfig if it is present */
-	if(pp->cpresent & (1<<Rconfig)){
+	m = pcmmap(slotno, pp->cfg[0].caddr + Rconfig, 0x20, 1);
+	p = KADDR(m->isa + pp->cfg[0].caddr - m->ca);
+	if(pp->cfg[0].cpresent & (1<<Rconfig)){
 		/*  Reset adapter */
-		m = pcmmap(slotno, pp->caddr + Rconfig, 1, 1);
-		p = KADDR(m->isa + pp->caddr + Rconfig - m->ca);
 
 		/*  set configuration and interrupt type.
 		 *  if level is possible on the card, use it.
@@ -1014,10 +1020,25 @@ pcmio(int slotno, ISAConf *isa)
 		x = ct->index;
 		if(ct->irqtype & 0x20)
 			x |= Clevel;
-		*p = x;
-		delay(5);
 
-		pcmunmap(slotno, m);
+		/*  enable the device, enable address decode and
+		 *  irq enable.
+		 */
+		x |= Cfunc|Cdecode|Cirq;
+
+		p[0] = x;
+		//delay(5);
+		microdelay(40);
 	}
+
+	if(pp->cfg[0].cpresent & (1<<Riobase0)){
+		/* set up the iobase 0 */
+		p[Riobase0 << 1] = isa->port;
+		p[Riobase1 << 1] = isa->port >> 8;
+	}
+
+	if(pp->cfg[0].cpresent & (1<<Riosize))
+		p[Riosize << 1] = ct->io[0].len;
+	pcmunmap(slotno, m);
 	return 0;
 }

+ 5 - 5
sys/src/9/pc/devusb.c

@@ -653,11 +653,11 @@ usbread(Chan *c, void *a, long n, vlong offset)
 		if(t == 0) {
 			if(e->iso)
 				error(Egreg);
-			e->data01 = 1;
+ 			e->rdata01 = 1;
 			n = uh->read(uh, e, a, n, 0LL);
 			if(e->setin){
 				e->setin = 0;
-				e->data01 = 1;
+				e->wdata01 = 1;
 				uh->write(uh, e, "", 0, 0LL, TokOUT);
 			}
 			return n;
@@ -778,7 +778,7 @@ usbwrite(Chan *c, void *a, long n, vlong offset)
 			if(i < 0 || i >= nelem(d->ep) || d->ep[i] == nil)
 				error(Ebadusbmsg);
 			e = d->ep[i];
-			e->data01 = strtoul(cb->f[2], nil, 0) != 0;
+			e->wdata01 = e->rdata01 = strtoul(cb->f[2], nil, 0) != 0;
 			break;
 		case CMmaxpkt:
 			i = strtoul(cb->f[1], nil, 0);
@@ -905,10 +905,10 @@ usbwrite(Chan *c, void *a, long n, vlong offset)
 		if(n < 8)
 			error(Eio);
 		nw = *(uchar*)a & RD2H;
-		e->data01 = 0;
+		e->wdata01 = 0;
 		n = uh->write(uh, e, a, n, 0LL, TokSETUP);
 		if(nw == 0) {	/* host to device: use IN[DATA1] to ack */
-			e->data01 = 1;
+			e->rdata01 = 1;
 			nw = uh->read(uh, e, cmd, 0LL, 8);
 			if(nw != 0)
 				error(Eio);	/* could provide more status */

+ 6 - 3
sys/src/9/pc/io.h

@@ -306,11 +306,14 @@ struct PCMslot
 	/* cis info */
 	ulong	msec;		/* time of last slotinfo call */
 	char	verstr[512];	/* version string */
-	uchar	cpresent;	/* config registers present */
-	ulong	caddr;		/* relative address of config registers */
+	int	ncfg;		/* number of configurations */
+	struct {
+		ushort	cpresent;	/* config registers present */
+		ulong	caddr;		/* relative address of config registers */
+	} cfg[8];
 	int	nctab;		/* number of config table entries */
 	PCMconftab	ctab[8];
-	PCMconftab	*def;		/* default conftab */
+	PCMconftab	*def;	/* default conftab */
 
 	/* memory maps */
 	Lock	mlock;		/* lock down the maps */

+ 1 - 1
sys/src/9/pc/pcmciamodem.c

@@ -29,6 +29,7 @@ static char* modems[] = {
 	"GSM/GPRS",
 	"AirCard 555",
 	"Gold Card Global",		/* Psion V90 Gold card */
+	"Merlin UMTS Modem",		/* Novatel card */
 	0,
 };
 
@@ -61,7 +62,6 @@ pcmciamodemlink(void)
 			} else
 				break;
 		}
-
 		slot = pcmspecial(modems[j], &isa);
 		if(slot >= 0){
 			if(usingcom2)

+ 19 - 18
sys/src/9/pc/usb.h

@@ -39,42 +39,43 @@ struct Endpt
 {
 	Ref;
 	Lock;
-	int		x;		/* index in Udev.ep */
-	int		id;		/* hardware endpoint address */
-	int		maxpkt;	/* maximum packet size (from endpoint descriptor) */
-	int		data01;	/* 0=DATA0, 1=DATA1 */
+	int	x;		/* index in Udev.ep */
+	int	id;		/* hardware endpoint address */
+	int	maxpkt;		/* maximum packet size (from endpoint descriptor) */
+ 	uchar	wdata01;	/* 0=DATA0, 1=DATA1 for output direction */
+ 	uchar	rdata01;	/* 0=DATA0, 1=DATA1 for input direction */
 	uchar	eof;
 	ulong	csp;
-	uchar	mode;	/* OREAD, OWRITE, ORDWR */
-	uchar	nbuf;	/* number of buffers allowed */
+	uchar	mode;		/* OREAD, OWRITE, ORDWR */
+	uchar	nbuf;		/* number of buffers allowed */
 	uchar	iso;
 	uchar	debug;
-	uchar	active;	/* listed for examination by interrupts */
-	int		setin;
+	uchar	active;		/* listed for examination by interrupts */
+	int	setin;
 	/* ISO related: */
-	int		hz;
-	int		remain;	/* for packet size calculations */
-	int		samplesz;
-	int		sched;	/* schedule index; -1 if undefined or aperiodic */
-	int		pollms;	/* polling interval in msec */
-	int		psize;	/* (remaining) size of this packet */
-	int		off;		/* offset into packet */
+	int	hz;
+	int	remain;		/* for packet size calculations */
+	int	samplesz;
+	int	sched;		/* schedule index; -1 if undefined or aperiodic */
+	int	pollms;		/* polling interval in msec */
+	int	psize;		/* (remaining) size of this packet */
+	int	off;		/* offset into packet */
 	/* Real-time iso stuff */
 	ulong	foffset;	/* file offset (to detect seeks) */
 	ulong	poffset;	/* offset of next packet to be queued */
 	ulong	toffset;	/* offset associated with time */
 	vlong	time;		/* timeassociated with offset */
-	int		buffered;	/* bytes captured but unread, or written but unsent */
+	int	buffered;	/* bytes captured but unread, or written but unsent */
 	/* end ISO stuff */
 
-	Udev*	dev;	/* owning device */
+	Udev*	dev;		/* owning device */
 
 	ulong	nbytes;
 	ulong	nblocks;
 
 	void	*private;
 
-	// all the rest could (should?) move to the driver private structure; except perhaps err
+	/* all the rest could (should?) move to the driver private structure; except perhaps err */
 	QLock	rlock;
 	Rendez	rr;
 	Queue*	rq;

+ 15 - 6
sys/src/9/pc/usbuhci.c

@@ -294,7 +294,7 @@ alloctde(Ctlr *ctlr, Endpt *e, int pid, int n)
 	t = alloctd(ctlr);
 	id = (e->x<<7)|(e->dev->x&0x7F);
 	tog = 0;
-	if(e->data01 && pid != TokSETUP)
+	if((pid == TokOUT && e->wdata01) || (pid == TokIN && e->rdata01))
 		tog = IsDATA1;
 	t->ep = e;
 	t->status = ErrLimit3 | Active | IOC;	/* or put IOC only on last? */
@@ -342,7 +342,7 @@ dumpqh(QH *q)
 	q0 = q;
 	for(i = 0; q != nil && i < 10; i++){
 		XPRINT("qh %8.8lux: %8.8lux %8.8lux\n", q, q->head, q->entries);
-		if((q->entries & Terminate) == 0)
+		if((q->entries & (IsQH|Terminate)) == 0)
 			dumptd(TFOL(q->entries), 1);
 		if(q->head & Terminate)
 			break;
@@ -1259,7 +1259,7 @@ read(Usbhost *uh, Endpt *e, void *a, long n, vlong offset)
 			error(e->err);
 		qrcv(ctlr, e);
 		if(!e->iso)
-			e->data01 ^= 1;
+			e->rdata01 ^= 1;
 		sleep(&e->rr, eptinput, e);
 		if(e->err)
 			error(e->err);
@@ -1336,7 +1336,7 @@ write(Usbhost *uh, Endpt *e, void *a, long n, vlong offset, int tok)
 		poperror();
 		qh = qxmit(ctlr, e, b, tok);
 		tok = TokOUT;
-		e->data01 ^= 1;
+		e->wdata01 ^= 1;
 		if(e->ntd >= e->nbuf) {
 XPRINT("qh %s: q=%p first=%p last=%p entries=%.8lux\n",
  "writeusb sleep", qh, qh->first, qh->last, qh->entries);
@@ -1385,9 +1385,18 @@ scanpci(void)
 		 * Find UHCI controllers.  Class = 12 (serial controller),
 		 * Sub-class = 3 (USB) and Programming Interface = 0.
 		 */
-		if(p->ccrb != 0x0C || p->ccru != 0x03 || p->ccrp != 0x00)
+		if(p->ccrb != 0x0C || p->ccru != 0x03)
 			continue;
-		io = p->mem[4].bar & ~0x0F;
+		switch(p->ccrp){
+		case 0x00:
+			io = p->mem[4].bar & ~0x0F;
+			break;
+		case 0x10:
+			print("usbohci: %x/%x port 0x%lux size 0x%x irq %d\n",
+				p->vid, p->did, p->mem[0].bar & ~0x0F, p->mem[0].size, p->intl);
+		default:
+			continue;
+		}
 		if(io == 0) {
 			print("usbuhci: failed to map registers\n");
 			continue;

+ 71 - 4
sys/src/9/port/cis.c

@@ -6,6 +6,10 @@
 #include "../port/error.h"
 #include "io.h"
 
+enum{
+	Linktarget = 0x13,
+};
+	
 /*
  *  read and crack the card information structure enough to set
  *  important parameters like power
@@ -21,6 +25,7 @@ typedef struct Cisdat {
 static void	tcfig(PCMslot*, Cisdat*, int);
 static void	tentry(PCMslot*, Cisdat*, int);
 static void	tvers1(PCMslot*, Cisdat*, int);
+static void	tlonglnkmfc(PCMslot*, Cisdat*, int);
 
 static int
 readc(Cisdat *cis, uchar *x)
@@ -106,8 +111,8 @@ pcmcisread(PCMslot *pp)
 	uchar type, link;
 
 	memset(pp->ctab, 0, sizeof(pp->ctab));
-	pp->caddr = 0;
-	pp->cpresent = 0;
+	pp->ncfg = 0;
+	memset(pp->cfg, 0, sizeof(pp->cfg));
 	pp->configed = 0;
 	pp->nctab = 0;
 	pp->verstr[0] = 0;
@@ -137,6 +142,9 @@ pcmcisread(PCMslot *pp)
 		switch(type){
 		default:
 			break;
+		case 6:
+			tlonglnkmfc(pp, &cis, type);
+			break;
 		case 0x15:
 			tvers1(pp, &cis, type);
 			break;
@@ -183,8 +191,15 @@ tcfig(PCMslot *pp, Cisdat *cis, int )
 	rmsize = ((size>>2)&0xf) + 1;
 	if(readc(cis, &last) != 1)
 		return;
-	pp->caddr = getlong(cis, rasize);
-	pp->cpresent = getlong(cis, rmsize);
+
+	if(pp->ncfg >= 8){
+		print("tcfig: too many configuration registers\n");
+		return;
+	}
+	
+	pp->cfg[pp->ncfg].caddr = getlong(cis, rasize);
+	pp->cfg[pp->ncfg].cpresent = getlong(cis, rmsize);
+	pp->ncfg++;
 }
 
 static ulong vexp[8] =
@@ -470,3 +485,55 @@ tvers1(PCMslot *pp, Cisdat *cis, int )
 	}
 	pp->verstr[i] = 0;
 }
+
+static void
+tlonglnkmfc(PCMslot *pp, Cisdat *cis, int)
+{
+	int i, npos, opos;
+	uchar nfn, space, expect, type, this, link;
+
+	readc(cis, &nfn);
+	for(i = 0; i < nfn; i++){
+		readc(cis, &space);
+		npos        = getlong(cis, 4);
+		opos        = cis->cispos;
+		cis->cispos = npos;
+		expect      = Linktarget;
+
+		while(1){
+			this = cis->cispos;
+			if(readc(cis, &type) != 1)
+				break;
+			if(type == 0xFF)
+				break;
+			if(readc(cis, &link) != 1)
+				break;
+
+			if(expect && expect != type){
+				print("tlonglnkmfc: expected %X found %X\n",
+					expect, type);
+				break;
+			}
+			expect = 0;
+
+			switch(type){
+			default:
+				break;
+			case 0x15:
+				tvers1(pp, cis, type);
+				break;
+			case 0x1A:
+				tcfig(pp, cis, type);
+				break;
+			case 0x1B:
+				tentry(pp, cis, type);
+				break;
+			}
+
+			if(link == 0xFF)
+				break;
+			cis->cispos = this + (2+link);
+		}
+		cis->cispos = opos;
+	}
+}

+ 0 - 1
sys/src/9/port/devmnt.c

@@ -55,7 +55,6 @@ struct Mntalloc
 	ulong	tagmask[NMASK];
 }mntalloc;
 
-void	mattach(Mnt*, Chan*, char*);
 Mnt*	mntchk(Chan*);
 void	mntdirfix(uchar*, Chan*);
 Mntrpc*	mntflushalloc(Mntrpc*, ulong);

+ 9 - 2
sys/src/9/port/devmouse.c

@@ -11,6 +11,13 @@
 #include	<cursor.h>
 #include	"screen.h"
 
+enum {
+	ScrollUp = 0x08,
+	ScrollDown = 0x10,
+	ScrollLeft = 0x20,
+	ScrollRight = 0x40,
+};
+
 typedef struct Mouseinfo	Mouseinfo;
 typedef struct Mousestate	Mousestate;
 
@@ -648,8 +655,8 @@ m5mouseputc(Queue*, int c)
 			(msg[0] & 0x10) >> (mouseshifted ? 3 : 2)
 			| (msg[0] & 0x20) >> 5
 			| ( msg[3] == 0x10 ? 0x02 :
-			    msg[3] == 0x0f ? 0x08 :
-			    msg[3] == 0x01 ? 0x10 : 0 );
+			    msg[3] == 0x0f ? ScrollUp :
+			    msg[3] == 0x01 ? ScrollDown : 0 );
 		mousetrack(dx, dy, newbuttons, TK2MS(MACHP(0)->ticks));
 		nb = 0;
 	}

+ 3 - 0
sys/src/9/port/edf.c

@@ -375,7 +375,10 @@ edfadmit(Proc *p)
 			DPRINT("%t edfadmit other %lud[%s], release now: r=%t d=%t t=%t\n",
 				now, p->pid, statename[p->state], e->r, e->d, e->t);
 			p->ta = p;
+			edfunlock();
+			qunlock(&edfschedlock);
 			releaseintr(nil, p);
+			return nil;
 		}
 	}else{
 		/* Release in synch to something else */

+ 1 - 1
sys/src/9/port/proc.c

@@ -780,7 +780,7 @@ sleep(Rendez *r, int (*f)(void*), void *arg)
 	splx(s);
 }
 
-int
+static int
 tfn(void *arg)
 {
 	return up->trend == nil || up->tfn(arg);

+ 64 - 7
sys/src/cmd/aux/pcmcia.c

@@ -3,6 +3,8 @@
 
 enum
 {
+	Linktarget = 0x13,
+	Funcid = 0x21,
 	End =	0xff,
 };
 
@@ -10,17 +12,21 @@ int fd;
 int pos;
 
 void	tdevice(int, int);
+void	tlonglnkmfc(int, int);
+void	tfuncid(int, int);
 void	tcfig(int, int);
 void	tentry(int, int);
 void	tvers1(int, int);
 
 void (*parse[256])(int, int) =
 {
-[1]	tdevice,
-[0x15]	tvers1,
-[0x17]	tdevice,
-[0x1A]	tcfig,
-[0x1B]	tentry,
+[1]		tdevice,
+[6]		tlonglnkmfc,
+[0x15]		tvers1,
+[0x17]		tdevice,
+[0x1A]		tcfig,
+[0x1B]		tentry,
+[Funcid]	tfuncid,
 };
 
 int hex;
@@ -52,7 +58,7 @@ readc(void *x)
 }
 
 int
-tuple(int next)
+tuple(int next, int expect)
 {
 	uchar link;
 	uchar type;
@@ -62,6 +68,14 @@ tuple(int next)
 		return -1;
 	if(type == 0xff)
 		return -1;
+print("type %.2uX\n", type & 0xff);
+
+	if(expect && expect != type){
+		print("expected %.2uX found %.2uX\n", 
+			expect, type);
+		return -1;
+	}
+
 	if(readc(&link) != 1)
 		return -1;
 	if(parse[type])
@@ -94,7 +108,7 @@ main(int argc, char *argv[])
 		fatal("opening %s: %r", file);
 
 	for(next = 0; next >= 0;)
-		next = tuple(next);
+		next = tuple(next, 0);
 }
 
 ulong speedtab[16] =
@@ -226,6 +240,49 @@ tdevice(int ttype, int len)
 	}
 }
 
+void
+tlonglnkmfc(int, int)
+{
+	int i, opos;
+	uchar nfn, space, expect;
+	int addr;
+
+	readc(&nfn);
+	for(i = 0; i < nfn; i++){
+		readc(&space);
+		addr = getlong(4);
+		opos = pos;
+		expect = Linktarget;
+		while(addr > 0){
+			addr = tuple(addr, expect);
+			expect = 0;
+		}
+		pos = opos;
+	}
+}
+
+static char *funcids[] = {
+	"MULTI",
+	"MEMORY",
+	"SERIAL",
+	"PARALLEL",
+	"FIXED",
+	"VIDEO",
+	"NETWORK",
+	"AIMS",
+	"SCSI",
+};
+
+void
+tfuncid(int, int)
+{
+	uchar func;
+
+	readc(&func);
+	print("Function %s\n", 
+		(func >= nelem(funcids))? "unknown function": funcids[func]);
+}
+
 void
 tvers1(int ttype, int len)
 {

+ 5 - 5
sys/src/cmd/diff/main.c

@@ -136,10 +136,10 @@ diff(char *f, char *t, int level)
 	Dir *fsb, *tsb;
 
 	if ((fp = statfile(f, &fsb)) == 0)
-		return;
+		goto Return;
 	if ((tp = statfile(t, &tsb)) == 0){
 		free(fsb);
-		return;
+		goto Return;
 	}
 	if (DIRECTORY(fsb) && DIRECTORY(tsb)) {
 		if (rflag || level == 0)
@@ -170,6 +170,8 @@ diff(char *f, char *t, int level)
 	}
 	free(fsb);
 	free(tsb);
+Return:
+	rmtmpfiles();
 }
 
 void
@@ -231,10 +233,8 @@ main(int argc, char *argv[])
 		free(fsb);
 	}
 	free(tsb);
-	for (i = 0; i < argc-1; i++) {
+	for (i = 0; i < argc-1; i++)
 		diff(argv[i], argv[argc-1], 0);
-		rmtmpfiles();
-	}
 	done(anychange);
 	/*NOTREACHED*/
 }

+ 1 - 1
sys/src/cmd/gview.c

@@ -1994,7 +1994,7 @@ void main(int argc, char *argv[])
 			fprintf(stderr,"Cannot read input file %s\n", *argv);
 			exits("no valid input file");
 		} else if (e > 0) {
-			fprintf(stderr,"Bad syntax at line %d of file %s\n", e, *argv);
+			fprintf(stderr,"Bad syntax at line %d of file %s\n", e, *argv ? *argv : "-");
 			exits("bad syntax in input");
 		}
 	} while (*argv && *++argv);

+ 22 - 6
sys/src/cmd/rx.c

@@ -15,7 +15,7 @@ int	call(char *, char*, char*, char**);
 char	*buildargs(char*[]);
 int	send(int);
 void	error(char*, char*);
-void	sshexec(char *host, char *cmd);
+void	sshexec(char*, char*);
 
 void
 usage(void)
@@ -120,17 +120,18 @@ rex(int fd, char *cmd, char *proto)
 void
 tcpexec(int fd, char *addr, char *cmd)
 {
-	char *cp, *ep, *u, buf[4096];
+	char *cp, *ep, *u, *ru, buf[4096];
 	int kid, n;
-	char *r;
 
 	/*
 	 *  do the ucb authentication and send command
 	 */
 	u = getuser();
-	r = ruser ? ruser : u;
+	ru = ruser;
+	if(ru == nil)
+		ru = u;
 	if(write(fd, "", 1)<0 || write(fd, u, strlen(u)+1)<0
-	|| write(fd, r, strlen(r)+1)<0 || write(fd, cmd, strlen(cmd)+1)<0){
+	|| write(fd, ru, strlen(ru)+1)<0 || write(fd, cmd, strlen(cmd)+1)<0){
 		close(fd);
 		error("can't authenticate to", addr);
 	}
@@ -181,7 +182,22 @@ tcpexec(int fd, char *addr, char *cmd)
 void
 sshexec(char *host, char *cmd)
 {
-	execl("/bin/ssh", "ssh", "-iCm", host, cmd, 0);
+	char *argv[10];
+	int n;
+
+	n = 0;
+	argv[n++] = "ssh";
+	argv[n++] = "-iCm";
+	if(!returns)
+		argv[n++] = "-r";
+	if(ruser){
+		argv[n++] = "-l";
+		argv[n++] = ruser;
+	}
+	argv[n++] = host;
+	argv[n++] = cmd;
+	argv[n] = 0;
+	exec("/bin/ssh", argv);
 }
 
 int

+ 1 - 1
sys/src/cmd/touch.c

@@ -51,7 +51,7 @@ touch(int nocreate, char *name)
 		fprint(2, "touch: %s: cannot wstat: %r\n", name);
 		return 1;
 	}
-	if ((fd = create(name, OREAD, 0666)) < 0) {
+	if ((fd = create(name, OREAD|OEXCL, 0666)) < 0) {
 		fprint(2, "touch: %s: cannot create: %r\n", name);
 		return 1;
 	}

+ 11 - 4
sys/src/cmd/trace.c

@@ -116,7 +116,7 @@ struct {
 	{	S(1000),	S(500),		S(100),		100},
 };
 
-int ntasks, verbose;
+int ntasks, verbose, triggerproc, paused;
 Task *tasks;
 Image *cols[Ncolor][4];
 Font *mediumfont, *tinyfont;
@@ -126,7 +126,7 @@ char*profdev = "/proc/trace";
 static void
 usage(void)
 {
-	fprint(2, "Usage: %s [-d profdev] [-w] [-v] [processes]\n", argv0);
+	fprint(2, "Usage: %s [-d profdev] [-w] [-v] [-t triggerproc] [processes]\n", argv0);
 	exits(nil);
 }
 
@@ -147,6 +147,9 @@ threadmain(int argc, char **argv)
 	case 'w':
 		newwin++;
 		break;
+	case 't':
+		triggerproc = (int)strtol(EARGF(usage()), nil, 0);
+		break;
 	default:
 		usage();
 	}
@@ -362,12 +365,17 @@ redraw(int scaleno)
 			case SEdf:
 				sx = time2x(e->time);
 				ex = time2x(e->etime);
+				if(ex == sx)
+					ex++;
 
 				r = Rect(sx, topmargin + 8, ex, Height - lineht);
 				r = rectaddpt(r, p);
 
 				draw(screen, r, cols[n % Ncolor][e->etype==SRun?1:3], nil, ZP);
 
+				if(t->pid == triggerproc && ex < Width)
+					paused ^= 1;
+
 				for(j = 0; j < t->nevents; j++){
 					_e = &t->events[j];
 					switch(_e->etype & 0xffff){
@@ -552,7 +560,6 @@ drawtrace(void)
 	int wfd, logfd;
 	Mousectl *mousectl;
 	Keyboardctl *keyboardctl;
-	int paused;
 	int scaleno;
 	Rune r;
 	int i, n;
@@ -655,7 +662,7 @@ drawtrace(void)
 				break;
 
 			case 'p':
-				paused = (paused + 1) & 1;
+				paused ^= 1;
 				prevts = 0;
 				break;
 

+ 4 - 4
sys/src/cmd/usb/audio/audiofs.c

@@ -22,7 +22,7 @@ typedef struct Worker Worker;
 struct Audioctldata
 {
 	long		offoff;			// offset of the offset for audioctl
-	long		values[2][Ncontrol][8];	// last values transmitted
+	long		values[2][Ncontrol][9];	// last values transmitted, K.Okamoto
 	char	*	s;
 	int		ns;
 };
@@ -373,7 +373,7 @@ allocaudioctldata(void)
 	a = emallocz(sizeof(Audioctldata), 1);
 	for (i = 0; i < 2; i++)
 		for(j=0; j < Ncontrol; j++)
-			for(k=0; k < 8; k++)
+			for(k=0; k < 9; k++)		/* K.Okamoto */
 			a->values[i][j][k] = Undef;
 	return a;
 }
@@ -450,8 +450,8 @@ makeaudioctldata(Fid *f)
 			c = &controls[rec][ctl];
 			different = 0;
 			if (c->chans){
-				for (i = 1; i < 8; i++)
-					if ((c->chans & 1<<i) && c->value[i] != a->values[rec][ctl][i])
+				for (i = 1; i < 9; i++)		/* K.Okamoto */
+					if ((c->chans & 1<<(i-1)) && c->value[i] != a->values[rec][ctl][i])	/* K.Okamoto */
 						different = 1;
 			}else
 				if (c->value[0] != a->values[rec][ctl][0])

+ 175 - 37
sys/src/cmd/usb/audio/audiosub.c

@@ -8,21 +8,46 @@
 Namelist terminal_types[] = {
 	{	0x100, "USB Terminal, undefined type"},
 	{	0x101, "USB Streaming"},
+	{	0x201, "Microphone"},
 	{	0x301, "Speaker"},
-	{	0x603, "Line connector"},
+	{	0x302, "Headphones"},
+	{	0x401, "Handset"},			/* bi-directional */
+	{	0x501, "Phone Line"},			/* analog telephone line jack */
+	{	0x601, "Analog connector"},
+	{	0x602, "Digital audio interface"},
+	{	0x603, "Line connector"},		/* 3.5mm jack */
+	{	0x604, "Legacy audio connector"},	/* input, connected to audio OUT */
+	{	0x605, "S/PDIF"},
+	{	0x606, "1394 DA stream"},
+	{	0x607, "1394 DV stream soundtrack"},
+	{	0x703, "CD player"},
+	{	0x704, "DAT"},
+	{	0x706, "Minidisk"},
+	{	0x70b, "DVD Audio"},
+	{	0x713, "Synthesizer"},
 	{	0, nil }
 };
 
-units[2][8];	/* rec and play units */
-nunits[2];		/* number in use */
+/* units[8][16] stores rec and play and other unit's id,  K.Okamoto
+	8: one of Play, Record, masterRecAGC, masterRecMute, LRRecVol, 
+		LRPlayVol, masterPlayMute, masterPlayVol
+	8: unit's ID
+	1: unit attribute of readable, settable, chans, value[9] and min, max, step
+*/
+FeatureAttr units[8][16];
+int nunits[8];		/* number in use for individual Unit's type K.Okamoto */
+int nf;		/* current total number of featurelist K.Okamoto */
 
 static int
 findunit(int nr)
 {
 	int rec, i;
+
+	if (nr == 12)		/* bSourceID == Mixer */
+		return Play;	/* K.Okamoto */
 	for (rec = 0; rec < 2; rec++)
 		for (i = 0; i < nunits[rec]; i++)
-			if (units[rec][i] == nr)
+			if (units[rec][i].id == nr)
 				return rec;
 	return -1;
 }
@@ -30,7 +55,7 @@ findunit(int nr)
 void
 audio_interface(Device *d, int n, ulong csp, void *bb, int nb) {
 	byte *b = bb;
-	int ctl, ch, u, x;
+	int ctl, ch, u, x, nbchan, bmc;
 	byte *p;
 	int class, subclass, ifc, dalt;
 	Audioalt *aa;
@@ -44,66 +69,90 @@ audio_interface(Device *d, int n, ulong csp, void *bb, int nb) {
 	switch (subclass) {
 	case 1:	// control
 		switch (b[2]) {
-		case 0x01:
+		case 0x01:	/* class-specific AC interface header */
 			if (debug & Dbginfo){
 				fprint(2, "Class-Specific AC Interface Header Descriptor\n");
-				fprint(2, "\tAudioDeviceClass release (bcd)%c%c%c%c, TotalLength %d, InCollection %d aInterfaceNr %d\n",
+				fprint(2, "\tAudioDeviceClass release (bcd)%c%c%c%c, TotalLength %d, InCollection %d aInterfaceNr %d %d",
 					'0'+((b[4]>>4)&0xf), '0'+(b[4]&0xf),
 					'0'+((b[3]>>4)&0xf), '0'+(b[3]&0xf),
-					b[5]|(b[6]<<8), b[7], b[8]);
+					b[5]|(b[6]<<8), b[7], 1, b[8]);
+				if(b[7]-1)		/* K.Okamoto */
+					for(ctl=1;ctl<b[7];ctl++) 
+						fprint(2,", aInterfaceNr%d %d", ctl+1, b[8+ctl]);
+				fprint(2, "\n");
 			}
 			break;
 		case 0x02:	// input
 			if (debug & Dbginfo){
 				fprint(2, "Audio Input Terminal Descriptor\n");
-				fprint(2, "\tbTerminalId %d, wTerminalType 0x%x (%s), bAssocTerminal %d bNrChannels %d, wChannelConfig %d, iChannelNames %d iTerminal %d\n",
+				fprint(2, "\tbTerminalId %d, wTerminalType 0x%x (%s), bAssocTerminal %d bNrChannels %d, wChannelConfig 0x%x, iChannelNames %d iTerminal %d\n",
 					b[3], b[4]|(b[5]<<8),
 					namefor(terminal_types, b[4]|(b[5]<<8)),
 					b[6], b[7], b[8]|(b[9]<<8), b[10], b[11]);
 			}
-			if ((b[4]|b[5]<<8) == 0x101){
+			if ((b[4]|b[5]<<8) == 0x101){	/* b[4]|b[5]<<8 = wTerminalType */
 				if (verbose)
 					fprint(2, "Audio output unit %d\n", b[3]);
 				/* USB streaming input: play interface */
-				units[Play][nunits[Play]++] = b[3];
+				units[Play][nunits[Play]++].id = b[3];	/* b[3] = bTerminalId */
 			}else{
 				if (verbose)
 					fprint(2, "Device can record from %s\n",
 						namefor(terminal_types, b[4]|(b[5]<<8)));
 				/* Non-USB input: record interface */
-				units[Record][nunits[Record]++] = b[3];
+				units[Record][nunits[Record]++].id = b[3];
 			}
 			break;
 		case 0x03:	// output
-			if (debug & Dbginfo){
+			if(debug & Dbginfo){
 				fprint(2, "Audio Output Terminal Descriptor\n");
 				fprint(2, "\tbTerminalId %d, wTerminalType 0x%x (%s), bAssocTerminal %d bSourceId %d, iTerminal %d\n",
 					b[3], b[4]|(b[5]<<8),
 					namefor(terminal_types, b[4]|(b[5]<<8)),
 					b[6], b[7], b[8]);
 			}
-			if ((b[4]|b[5]<<8) == 0x101){
+			if((b[4]|b[5]<<8) == 0x101){
 				if (verbose)
 					fprint(2, "Audio input unit %d\n", b[3]);
 				/* USB streaming output: record interface */
-				units[Record][nunits[Record]++] = b[3];
+				units[Record][nunits[Record]++].id = b[3];
+			}else{
 				if (verbose)
 					fprint(2, "Device can play to %s\n",
 						namefor(terminal_types, b[4]|(b[5]<<8)));
 				/* Non-USB output: play interface */
-				units[Play][nunits[Play]++] = b[3];
+				units[Play][nunits[Play]++].id = b[3];
 			}
 			break;
-		case 0x04:
+		case 0x04:	/* mixer */
+			if (debug & Dbginfo){			/* K.Okamoto */
+				fprint(2, "Audio Mixer Unit %d\n", b[3]);
+				fprint(2, "\tbNrInPins %d, ", b[4]);
+				for(ctl = 1;ctl <= b[4]; ctl++)
+					fprint(2, "Input Pin %d's UnitID %d, ", ctl, b[4+ctl]);
+				ctl--;
+				nbchan = b[5+ctl];
+				fprint(2, "bNrChannels %d, ", nbchan);
+				fprint(2, "wChannelConfig 0x%x, ", b[6+ctl]|b[7+ctl]<<8);
+				fprint(2, "iChannelNames %d, ", b[8+ctl]);
+				bmc = 9 + ctl;
+				fprint(2, "bmControls 0x%x", b[bmc++]);
+				nbchan = b[0]-bmc-1;
+				if(nbchan > 1)
+					while(nbchan--) fprint(2, "%x", b[bmc++]);
+				fprint(2, ", iMixer %d\n", b[bmc]);
+			}
 			if (verbose)
 				fprint(2, "Audio Mixer Unit %d\n", b[3]);
+			mixerid = b[3];
 			break;
-		case 0x05:
-			if (verbose)
+		case 0x05:	/* selector */
+			if(verbose)
 				fprint(2, "Audio Selector Unit %d\n", b[3]);
-			if (debug & Dbginfo)
+			if(debug & Dbginfo)
 				fprint(2, "\tbUnitId %d, bNrInPins %d", b[3], b[4]);
-			if (b[4]){
+			selector = b[3];		/* K.Okamoto */
+			if(b[4]){	/* number of Pins >=1, K.Okamoto */
 				if (debug & Dbginfo) fprint(2, ", baSourceIDs: [%d", b[5]);
 				u = findunit(b[5]);
 				for (ctl = 1; ctl < b[4]; ctl++){
@@ -115,14 +164,17 @@ audio_interface(Device *d, int n, ulong csp, void *bb, int nb) {
 				}
 				if (debug & Dbginfo) fprint(2, "]\n");
 				if (u >= 0){
-					units[u][nunits[u]++] = b[3];
 					if (selectorid[u] >= 0)
 						fprint(2, "Second selector (%d, %d) on %s\n", selectorid[u], b[3], u?"record":"playback");
 					selectorid[u] = b[3];
 				}
 			}
 			break;
-		case 0x06:	// feature
+		case 0x06:
+			/* feature, b[6]: master channel, b[7]: logical channel 1, 2, 3, .. -->
+			 * b[5]: byte size of individual element data size
+			 * b[3] id number, b[4]: source ID, 
+			 */
 			if (verbose) fprint(2, "Audio Feature Unit %d", b[3]);
 			if (debug & Dbginfo)
 				fprint(2, "\tbUnitId %d, bSourceId %d, bControlSize %d\n",
@@ -130,39 +182,125 @@ audio_interface(Device *d, int n, ulong csp, void *bb, int nb) {
 			u = findunit(b[4]);
 			if (u >= 0){
 				if (verbose) fprint(2, " for %s\n", u?"Record":"Playback");
-				units[u][nunits[u]++] = b[3];
+//				units[u][nunits[u]++].id = b[3];
 				if (featureid[u] >= 0)
 					if (verbose) fprint(2, "Second feature unit (%d, %d) on %s\n", featureid[u], b[3], u?"record":"playback");
 				featureid[u] = b[3];
 			}else
 				if (verbose) fprint(2, ", not known what for\n");
-			p = b + 6;
-			for (ctl = 1; ctl < 0x0b; ctl++)
-				if ((1<<(ctl-1)) & (b[6] | ((b[5]>1)?(b[7]<<8):0))) {
-					if (verbose)
-						fprint(2, "\t%s control on master channel\n",
-							controls[0][ctl].name);
-					if (u >= 0){
+			p = b + 6;	/* p: each logical channel data */
+			/* check first for master channel */
+			for(ctl = 1; ctl < 0x0b; ctl++){
+				if((1<<(ctl-1)) & (b[6] | ((b[5]>1)?(b[7]<<8):0))){
+					/* b[6]: master channel control,
+					 * D0: Mute, D1: Volume, D2: Bass, D3: Mid, 
+					 * D4: Treble, D5: Equalizer, D6: Agc, D7: Delay,
+					 * D8: Bass Boost, D9: Loudness ...
+					 */
+					if (ctl == 1 && u == Record){
+						units[masterRecMute][nunits[masterRecMute]].id = b[3];
+						units[masterRecMute][nunits[masterRecMute]].readable =1;
+						units[masterRecMute][nunits[masterRecMute]].settable = 1;
+						units[masterRecMute][nunits[masterRecMute]++].chans = 0;
+						controls[u][ctl].readable = 1;
+						controls[u][ctl].settable = 1;
+						controls[u][ctl].chans = 0;
+					} else if (ctl == 1 && u == Play) {
+						units[masterPlayMute][nunits[masterPlayMute]].id = b[3];
+						units[masterPlayMute][nunits[masterPlayMute]].readable = 1;
+						units[masterPlayMute][nunits[masterPlayMute]].settable = 1;
+						units[masterPlayMute][nunits[masterPlayMute]++].chans = 0;
+						controls[u][ctl].readable = 1;
+						controls[u][ctl].settable = 1;
+						controls[u][ctl].chans = 0;
+					} else if (ctl == 2 && u == Play) {
+						units[masterPlayVol][nunits[masterPlayVol]].id = b[3];
+						units[masterPlayVol][nunits[masterPlayVol]].readable = 1;
+						units[masterPlayVol][nunits[masterPlayVol]].settable = 1;
+						units[masterPlayVol][nunits[masterPlayVol]++].chans = 0;
+						controls[u][ctl].readable = 1;
+						controls[u][ctl].settable = 1;
+						controls[u][ctl].chans = 0;
+					} else if (ctl == 7 && u == Record){ 	/* K.Okamoto for CM106/F */
+						units[masterRecAGC][nunits[masterRecAGC]].id = b[3];
+						units[masterRecAGC][nunits[masterRecAGC]].readable = 1;
+						units[masterRecAGC][nunits[masterRecAGC]].settable = 1;
+						units[masterRecAGC][nunits[masterRecAGC]++].chans = 0;
 						controls[u][ctl].readable = 1;
 						controls[u][ctl].settable = 1;
 						controls[u][ctl].chans = 0;
 					}
+					if (verbose)
+						fprint(2, "\t%s control on master channel\n",
+							controls[0][ctl].name);
 				}
+			}
+			/* Now going to check each logical channel */
 			p += (b[5]>1)?2:1;
 			for (ch = 0; ch < (nb - 8)/b[5]; ch++) {
-				for (ctl = 1; ctl < 0x0b; ctl++)
+				for (ctl = 1; ctl < 0x0b; ctl++) {
+					/* p[0]: each channel control,
+					 * D0: Mute, D1: Volume, D2: Bass, D3: Mid, 
+					 * D4: Treble, D5: Equalizer, D6: Agc, D7: Delay,
+					 * D8: Bass Boost, D9: Loudness ...
+					 */
 					if ((1<<(ctl-1)) & (p[0] | ((b[5]>1)?(p[1]<<8):0))) {
+						if (ctl == 2 && u == Play ) {
+							if (!ch) {
+								units[LRPlayVol][nunits[LRPlayVol]].id = b[3];
+								units[LRPlayVol][nunits[LRPlayVol]].readable = 1;
+								units[LRPlayVol][nunits[LRPlayVol]].settable = 1;
+							}
+							units[LRPlayVol][nunits[LRPlayVol]].chans |= 1<<ch;
+						}
+						else if (ctl == 2 && u == Record) {
+							if (!ch) {
+								units[LRRecVol][nunits[LRRecVol]].id = b[3];
+								units[LRRecVol][nunits[LRRecVol]].readable = 1;
+								units[LRRecVol][nunits[LRRecVol]].settable = 1;
+							}
+							units[LRRecVol][nunits[LRRecVol]].chans |= 1<<ch;
+						}
+
+/* Why we have to set these flags? K.Okamoto */
+						controls[u][ctl].readable = 1;
+						controls[u][ctl].settable = 1;
+						controls[u][ctl].chans |= 1<<ch;
+/**/
 						if (verbose)
 							fprint(2, "\t%s control on channel %d\n",
 								controls[0][ctl].name, ch+1);
-						if (u >= 0){
-							controls[u][ctl].readable = 1;
-							controls[u][ctl].settable = 1;
-							controls[u][ctl].chans |= 1 <<(ch+1);
-						}
 					}
+				}
 				p += (b[5]>1)?2:1;
 			}
+			if (units[LRRecVol][nunits[LRRecVol]].id) nunits[LRRecVol]++;
+			if (units[LRPlayVol][nunits[LRPlayVol]].id) nunits[LRPlayVol]++;
+			if (debug & Dbginfo) {	/* K.Okamoto */
+				fprint(2, "Number of Play Units = %d, and consists of ", nunits[Play]);
+				for(x=0; x<nunits[Play]; x++) fprint(2, "%d, ", units[Play][x].id);
+				fprint(2, "\nNumber of Record Units = %d, and consists of ", nunits[Record]);
+				for(x=0; x<nunits[Record]; x++) fprint(2, "%d, ", units[Record][x].id);
+				fprint(2, "\nNumber of masterRecAGC Units = %d, and consists of ", nunits[masterRecAGC]);
+				for(x=0; x<nunits[masterRecAGC]; x++) 
+					if (units[masterRecAGC][x].id) fprint(2, "%d, ", units[masterRecAGC][x].id);
+				fprint(2, "\nNumber of masterRecMute Units = %d, and consists of ", nunits[masterRecMute]);
+				for(x=0; x<nunits[masterRecMute]; x++) 
+					if (units[masterRecMute][x].id) fprint(2, "%d, ", units[masterRecMute][x].id);
+				fprint(2, "\nNumber of LRRecVol Units = %d, and consists of ", nunits[LRRecVol]);
+				for(x=0; x<nunits[LRRecVol]; x++) 
+					if (units[LRRecVol][x].id) fprint(2, "%d, ", units[LRRecVol][x].id);
+				fprint(2, "\nNumber of masterPlayMute Units = %d, and consists of ", nunits[masterPlayMute]);
+				for(x=0; x<nunits[masterPlayMute]; x++) 
+					if (units[masterPlayMute][x].id) fprint(2, "%d, ", units[masterPlayMute][x].id);
+				fprint(2, "\nNumber of masterPlayVol Units = %d, and consists of ", nunits[masterPlayVol]);
+				for(x=0; x<nunits[masterPlayVol]; x++)
+					if (units[masterPlayVol][x].id) fprint(2, "%d, ", units[masterPlayVol][x].id);
+				fprint(2, "\nNumber of LRPlayVol Units = %d, and consists of ", nunits[LRPlayVol]);
+				for(x=0; x<nunits[LRPlayVol]; x++) 
+					if (units[LRPlayVol][x].id) fprint(2, "%d, ", units[LRPlayVol][x].id);
+				fprint(2, "\n");
+			}
 			break;
 		default:
 			pcs_raw("audio control unknown", bb, nb);

+ 184 - 64
sys/src/cmd/usb/audio/usbaudio.c

@@ -13,13 +13,20 @@
 
 extern char* srvpost;
 char * mntpt;
-
+extern MasterVol masterplayvol;	/* K.Okamoto */
+extern int mixerid;			/* K.Okamoto */
+extern int selector;		/* K.Okamoto */
+int vendor;		/* K.Okamoto */
+int product;		/* K.Okamoto */
 Channel *controlchan;
 
 char audstr[]		= "Enabled 0x000101\n";	/* audio.control.0 */
 
 int defaultspeed[2] = {44100, 44100};
 
+extern FeatureAttr units[8][16];		/* K.Okamoto */
+extern int nunits[8];
+
 static void
 audio_endpoint(Device *d, int c, ulong csp, void *bb, int n)
 {
@@ -99,7 +106,7 @@ controlproc(void *)
 	int i, nf;
 	char *req, *args[8];
 	Audiocontrol *c;
-	long value[8];
+	long value[9];
 	Channel *replchan;
 
 	while(req = recvp(controlchan)){
@@ -126,6 +133,7 @@ controlproc(void *)
 			if (strcmp(args[1], c->name) == 0)
 				break;
 		}
+
 		if (i == Ncontrol){
 			if (debug) fprint(2, "Illegal control name: %s", args[1]);
 			if (replchan) chanprint(replchan, "Illegal control name: %s", args[1]);
@@ -146,13 +154,34 @@ controlproc(void *)
 			if (debug & Dbginfo)
 				fprint(2, "controlproc: setcontrol %s %s %s\n",
 					rec?"in":"out", args[1], args[3]);
-			if (setcontrol(rec, args[1], value) < 0){
-				if (replchan)
-					chanprint(replchan, "setting %s %s failed", args[1], args[2]);
-			}else{
-				if (replchan) chanprint(replchan, "ok");
+			if (rec == Play) {		/* most messy part, K.Okamoto */
+				if (vendor == 0xd8c && product== 0x6) {	/* for C-Media CM-106/F chip */
+					if (setcontrol(rec, args[1], value, 0) < 0){	/* units[masterPlayVol][0]: #13 Unit */
+						if (replchan)
+							chanprint(replchan, "setting %s %s failed", args[1], args[2]);
+					}else{
+						if (replchan) chanprint(replchan, "ok");
+					}
+				} else {
+					if (setcontrol(rec, args[1], value, 0) < 0){	/* replace the '0' to another */
+						if (replchan)
+							chanprint(replchan, "setting %s %s failed", args[1], args[2]);
+					}else{
+						if (replchan) chanprint(replchan, "ok");
+					}
+				}
+			} else
+			if (rec == Record && !strcmp(args[1], "volume")) {
+				if (vendor == 0xd8c && product== 0x6) {	/* for C-Media CM-106/F chip */
+					if (setcontrol(rec, args[1], value, 2) < 0){	/* units[LRRecVol][2]: #2 Unit */
+						if (replchan)
+							chanprint(replchan, "setting %s %s failed", args[1], args[2]);
+					}else{
+						if (replchan) chanprint(replchan, "ok");
+					}
+				}
+				ctlevent();
 			}
-			ctlevent();
 		}
 		free(req);
 	}
@@ -163,7 +192,7 @@ buttonproc(void *) {
 	int	i, fd, b;
 	char fname[64], err[32];
 	byte buf[1];
-	Audiocontrol *c;
+	Audiocontrol *c, *cm;
 
 	sprint(fname, "/dev/usb%d/%d/ep%ddata", ad->ctlrno, ad->id, buttonendpt);
 	if (debug & Dbginfo) fprint(2, "buttonproc opening %s\n", fname);
@@ -171,6 +200,9 @@ buttonproc(void *) {
 		sysfatal("Can't open %s: %r", fname);
 
 	c = &controls[Play][Volume_control];
+	cm = &controls[Play][Mute_control];
+	if (vendor == 0xd8c && product== 0x6)		/* for C-Media CM-106/F chip */
+		cm->value[0] = units[masterPlayMute][0].value[0];	/* K.Okamoto, messy! */
 	for (;;) {
 		if ((b = read(fd, buf, 1)) < 0){
 			rerrstr(err, sizeof err);
@@ -182,22 +214,24 @@ buttonproc(void *) {
 		}
 		if (b == 0 || buf[0] == 0){
 			continue;
-		}else if (buf[0] == 1){
-			if (c->chans == 0)
-				c->value[0] += c->step;
-			else
-				for (i = 1; i < 8; i++)
-					if (c->chans & 1 << i)
-						c->value[i] += c->step;
+		}else if (buf[0] == 1){		/* increase volume */
+			c->chans = 0;
+			c->value[0] += c->step;
 			chanprint(controlchan, "0 volume playback %A", c);
-		}else if (buf[0] == 2){
-			if (c->chans == 0)
-				c->value[0] -= c->step;
-			else
-				for (i = 1; i < 8; i++)
-					if (c->chans & 1 << i)
-						c->value[i] -= c->step;
+		}else if (buf[0] == 2){		/* decrease volume */
+			c->chans = 0;
+			c->value[0] -= c->step;
 			chanprint(controlchan, "0 volume playback %A", c);
+		}else if (buf[0] == 4){		/* Play mute On/Off control K.Okamoto */
+			cm->chans = 0;
+			if (cm->value[0] == 0)
+				cm->value[0] = 1;
+			else
+				cm->value[0] = 0;
+			chanprint(controlchan, "0 mute playback %A", cm);
+		}else if (buf[0] == 0x70){		/* Onkyo SE-U55X IrDA */
+			// not implemented yet
+			continue;
 		}else if (debug & Dbginfo){
 			fprint(2, "button");
 			for (i = 0; i < b; i++)
@@ -222,7 +256,7 @@ findendpoints(void)
 		case CSP(CL_AUDIO, 2, 0):
 			if (ep->iface == nil)
 				break;
-			rec = (ep->iface->addr &  0x80)?1:0;
+			rec = (ep->addr &  0x80)?1:0;
 			if (verbose)
 				fprint(2, "%s on endpoint %d\n", rec?"Record":"Playback", i);
 			endpt[rec] = i;
@@ -240,27 +274,29 @@ findendpoints(void)
 void
 usage(void)
 {
-	fprint(2, "usage: usbaudio [-V] [-v volume[%%]] [-m mountpoint] [-s srvname] [ctrlno id]\n");
+	fprint(2, "usage: usbaudio [-V] [-v volume[%%]] [-m mountpoint] [-r recording device] [-s srvname] [ctrlno id]\n");
 	threadexitsall("usage");
 }
 
 void
 threadmain(int argc, char **argv)
 {
-	int ctlrno, id, i, sfd;
-	long value[8];
-	long volume[8];
-	Audiocontrol *c;
+	int ctlrno, id, i, j, sfd, select;
+	long value[9];
+	long volume[9];
+	long mastervol;		/* K.Okamoto */
 	char buf[32], *p, line[256];
 
 	ctlrno = -1;
 	id = -1;
-	volume[0] = Undef;
-	for (i = 0; i<8; i++)
+	volume[0] = 50;		/* default volume is 50% */
+	select = 4;				/* Mixer input default, must be checked for other devices K.Okamoto */
+	for (i = 0; i<9; i++)		/* K.Okamoto */
 		value[i] = 0;
 	fmtinstall('A', Aconv);
 	quotefmtinstall();
 
+	mastervol = 0;		/* K.Okamoto */
 	ARGBEGIN{
 	case 'V':
 		verbose++;
@@ -271,13 +307,16 @@ threadmain(int argc, char **argv)
 		verbose++;
 		break;
 	case 'v':
-		volume[0] = strtol(ARGF(), &p, 0);
-		for(i = 1; i < 8; i++)
-			volume[i] = volume[0];
+		mastervol = strtol(ARGF(), &p, 0);;		/* K.Okamoto */
+		for(i = 0; i < 9; i++)
+			volume[i] = mastervol;			/* K.Okamoto */
 		break;
 	case 'm':
 		mntpt = ARGF();
 		break;
+	case 'r':
+		select = atoi(ARGF());
+		break;
 	case 's':
 		srvpost = ARGF();
 		break;
@@ -318,6 +357,9 @@ threadmain(int argc, char **argv)
 	if (describedevice(ad) < 0)
 		sysfatal("describedevice");
 
+	vendor = ad->vid;
+	product = ad->did;
+
 	for(i=0; i<ad->nconf; i++) {
 		if (ad->config[i] == nil)
 			ad->config[i] = mallocz(sizeof(*ad->config[i]),1);
@@ -329,18 +371,32 @@ threadmain(int argc, char **argv)
 	findendpoints();
 
 	if (endpt[Play] >= 0){
-		if(findalt(Play, 2, 16, defaultspeed[Play]) < 0){
-			if(findalt(Play, 2, 16, 48000) < 0)
-				sysfatal("Can't configure playout for %d or %d Hz", defaultspeed[Play], 48000);
-			fprint(2, "Warning, can't configure playout for %d Hz, configuring for %d Hz instead\n",
-				defaultspeed[Play], 48000);
-			defaultspeed[Play] = 48000;
+		if (vendor == 0xd8c && product == 0x6) {		/* C-Media CM-106F chip K.Okamoto */
+			if(findalt(Play, 8, 16, defaultspeed[Play]) < 0){
+				if(findalt(Play, 8, 16, 48000) < 0)
+					sysfatal("Can't configure playout for %d or %d Hz", defaultspeed[Play], 48000);
+				fprint(2, "Warning, can't configure playout for %d Hz, configuring for %d Hz instead\n",
+					defaultspeed[Play], 48000);
+				defaultspeed[Play] = 48000;
+			}
+		} else {
+			if(findalt(Play, 2, 16, defaultspeed[Play]) < 0){
+				if(findalt(Play, 2, 16, 48000) < 0)
+					sysfatal("Can't configure playout for %d or %d Hz", defaultspeed[Play], 48000);
+				fprint(2, "Warning, can't configure playout for %d Hz, configuring for %d Hz instead\n",
+					defaultspeed[Play], 48000);
+				defaultspeed[Play] = 48000;
+			}
 		}
-		value[0] = 2;
-		if (setcontrol(Play, "channels", value) == Undef)
+		/* K.Okamoto choose feature 4 (connected from Mixer) for Output to USB Stream */
+		if (selector >0)
+			if( setselector(select) == Undef)
+				sysfatal("Failed to set selector\n");
+		value[0] = 8;			/* K.Okamoto */
+		if (setcontrol(Play, "channels", value, featureid[Play]) == Undef)
 			sysfatal("Can't set play channels\n");
 		value[0] = 16;
-		if (setcontrol(Play, "resolution", value) == Undef)
+		if (setcontrol(Play, "resolution", value, featureid[Play]) == Undef)
 			sysfatal("Can't set play resolution\n");
 	}
 
@@ -352,39 +408,103 @@ threadmain(int argc, char **argv)
 				defaultspeed[Record], 48000);
 			defaultspeed[Record] = 48000;
 		}
+		/* K.Okamoto choose all the controls for Mixer inputs */
+		if (mixerid >0)
+			if (initmixer() == Undef)		/* K.Okamoto, set all the channels alive on the mixer */
+				sysfatal("Failed to set MIXER all live\n");
 		value[0] = 2;
-		if (setcontrol(Record, "channels", value) == Undef)
+		if (setcontrol(Record, "channels", value, featureid[Record]) == Undef)
 			sysfatal("Can't set record channels\n");
 		value[0] = 16;
-		if (setcontrol(Record, "resolution", value) == Undef)
+		if (setcontrol(Record, "resolution", value, featureid[Record]) == Undef)
 			sysfatal("Can't set record resolution\n");
 	}
 
-	getcontrols();	/* Get the initial value of all controls */
+	if(debugdebug) fprint(2, "\n=======Start of listing default values of feature units=======\n");	/*.K.Okamoto */
+	getcontrols();
+	if(debugdebug) fprint(2, "\n=======Start of setting values of feature units=======\n");	/*.K.Okamoto */
 	value[0] = defaultspeed[Play];
-	if (endpt[Play] >= 0 && setcontrol(Play, "speed", value) < 0)
+	if (endpt[Play] >= 0 && setcontrol(Play, "speed", value, featureid[Play]) < 0)
 		sysfatal("Can't set play speed\n");
 	value[0] = defaultspeed[Record];
-	if (endpt[Record] >= 0 && setcontrol(Record, "speed", value) < 0)
+	if (endpt[Record] >= 0 && setcontrol(Record, "speed", value, featureid[Record]) < 0)
 		sysfatal("Can't set record speed\n");
-	value[0] = 0;
-	setcontrol(Play, "mute", value);
-
-	if (volume[0] != Undef){
-		c = &controls[Play][Volume_control];
-		if (*p == '%' && c->min != Undef)
-			for (i = 0; i < 8; i++)
-				volume[i] = (volume[i]*c->max + (100-volume[i])*c->min)/100;
-		if (c->settable)
-			setcontrol(Play, "volume", volume);
-		c = &controls[Record][Volume_control];
-		if (c->settable)
-			setcontrol(Record, "volume", volume);
-	}
-
+	/* here, 'i' is the n-th turn of multiple Units for this purpose, 
+		'i' does not equals to Unit number itself */
+	if (nunits[masterRecMute])
+		for(i=0; i<nunits[masterRecMute]; i++) {
+			value[0] = 0;			/* set master Record Mute OFF K.Okamoto */
+			setcontrol(Record, "mute", value, i);
+		}
+	if (nunits[masterPlayMute])
+		for (i=0; i<nunits[masterPlayMute]; i++) {
+			value[0] = 0;			/* set master Play Mute OFF K.Okamoto */
+			setcontrol(Play, "mute", value, i);
+		}
+	if (nunits[masterRecAGC])
+		for (i=0; i<nunits[masterRecAGC]; i++) {
+			value[0]=1;						/* set AGC ON, K.Okamoto */
+			setcontrol(Record, "agc", value, i);		/* K.Okamoto */
+		}
+	if (nunits[LRRecVol])
+		for (i=0; i<nunits[LRRecVol]; i++) {
+			if (argc >=1 && *p == '%') {
+				for (j = 0; j < 9; j++) {
+					volume[j] = mastervol*(units[LRRecVol][i].max - units[LRRecVol][i].min)/100	+ units[LRRecVol][i].min;
+					if (debug &  Dbgcontrol) fprint(2, "Unit#%d's ,  c->max, c->min= 0x%lx, 0x%lx\n", 
+						units[LRRecVol][i].id, units[LRRecVol][i].max, units[LRRecVol][i].min);
+					if (debug & Dbgcontrol) fprint(2, "volume[%d] = 0x%lx\n", j, volume[j]);
+				}
+			} else {
+				for (j = 0; j < 9; j++) {
+					volume[j] = 50*(units[LRRecVol][i].max - units[LRRecVol][i].min)/100	+ 
+						units[LRRecVol][i].min;
+					if (debug & Dbgcontrol) fprint(2, "Unit#%d's ,  c->max, c->min= 0x%lx, 0x%lx\n", 
+						units[LRRecVol][i].id, units[LRRecVol][i].max, units[LRRecVol][i].min);
+					if (debug & Dbgcontrol) fprint(2, "volume[%d] = 0x%lx\n", j, volume[j]);
+				}
+			}
+			if (units[LRRecVol][i].settable)
+				setcontrol(Record, "volume", volume, i);
+		}
+	if (nunits[LRPlayVol])
+		for (i=0; i<nunits[LRPlayVol]; i++) {
+			if (argc >=1 && *p == '%') {
+				for (j = 0; j < 9; j++) {
+					volume[j] = mastervol*(units[LRPlayVol][i].max - units[LRPlayVol][i].min)/100	+ 
+						units[LRPlayVol][i].min;
+					if (debug & Dbgcontrol) fprint(2, "Unit#%d's ,  c->max, c->min= 0x%lx, 0x%lx\n", 
+						units[LRPlayVol][i].id, units[LRPlayVol][i].max, units[LRPlayVol][i].min);
+					if (debug & Dbgcontrol) fprint(2, "volume[%d] = 0x%lx\n", j, volume[j]);
+				}
+			} else {
+				for (j = 0; j < 9; j++) {
+					volume[j] = 50*(units[LRPlayVol][i].max - units[LRPlayVol][i].min)/100	+ 
+						units[LRPlayVol][i].min;
+					if (debug & Dbgcontrol) fprint(2, "Unit#%d's ,  c->max, c->min= 0x%lx, 0x%lx\n", 
+						units[LRPlayVol][i].id, units[LRPlayVol][i].max, units[LRPlayVol][i].min);
+					if (debug & Dbgcontrol) fprint(2, "volume[%d] = 0x%lx\n", j, volume[j]);
+				}
+			}
+			if (units[LRPlayVol][i].settable)
+				setcontrol(Play, "volume", volume, i);
+		}
+	if (nunits[masterPlayVol])
+		for (i=0; i<nunits[masterPlayVol]; i++) {
+			if (argc >=1)
+				volume[0] = mastervol*(masterplayvol.max - masterplayvol.min)/100+ masterplayvol.min;
+			else
+				volume[0] = 50*(masterplayvol.max - masterplayvol.min)/100+ masterplayvol.min;
+			volume[1] = 0;
+			if (debug & Dbgcontrol) fprint(2, "masterplayvol.max = %ld\n", masterplayvol.max);
+			if (debug & Dbgcontrol) fprint(2, "masterplayvol.min = %ld\n", masterplayvol.min);
+			if (debug & Dbgcontrol) fprint(2, "master Play volume[0] = %ld\n", volume[0]);
+			if (units[masterPlayVol][i].settable)
+				setcontrol(Play, "volume", volume, i);
+		}
 	if (buttonendpt > 0){
 		sprint(buf, "ep %d bulk r 1 1", buttonendpt);
-		if (debug) fprint(2, "sending `%s' to /dev/usb/%d/ctl\n", buf, id);
+		if (debug) fprint(2, "sending `%s' to /dev/usb%d/%d/ctl\n", buf, ad->ctlrno, id);
 		if (write(ad->ctl, buf, strlen(buf)) > 0)
 			proccreate(buttonproc, nil, STACKSIZE);
 		else

+ 4 - 3
sys/src/cmd/usb/audio/usbaudio.h

@@ -2,7 +2,7 @@
 enum {
 	master_chan		= 0x00,
 	Speed_control		= 0x00,
-	/* Items below are  defined by USB standard: */
+	/* Items below are  defined for feature controls by USB standard: */
 	Mute_control		= 0x01,
 	Volume_control		= 0x02,
 	Bass_control		= 0x03,
@@ -18,6 +18,8 @@ enum {
 	Resolution_control	= 0x0c,
 	Ncontrol,
 	sampling_freq_control	= 0x01,
+	/* Sreaming terminal control by USB standard K.Okamoto */
+	pitch_control	=	0x02,
 };
 
 
@@ -62,8 +64,7 @@ void	audio_interface(Device *d, int n, ulong csp, void *bb, int nb);
 void	setalt(Device *d, int endpt, int value);
 int	getalt(Device *d, int endpt);
 int	setspeed(int rec, int speed);
-int	setcontrol(int rec, char *name, long *value);
-int	getspecialcontrol(int rec, int ctl, int req, long *value);
+int	setcontrol(int rec, char *name, long *value, int unit);
 int	getcontrol(int rec, char *name, long *value);
 int	findalt(int rec, int nchan, int res, int speed);
 void	getcontrols(void);

File diff suppressed because it is too large
+ 647 - 137
sys/src/cmd/usb/audio/usbaudioctl.c


+ 41 - 6
sys/src/cmd/usb/audio/usbaudioctl.h

@@ -1,29 +1,64 @@
 enum{
 	Undef = 0x80000000,
-	Play = 0,
-	Record = 1,
+	Play = 0,	/* for USB Streaming Terminal K.Okamoto */
+	Record = 1,	/* for USB Streaming Terminal K.Okamoto */
+	masterRecAGC,	/* feature ID for master record AGC function K.Okamoto */
+	masterRecMute,	/* feature IDs for master record mute function K.Okamoto */
+	LRRecVol,	/* feature ID for master record L/R volume for Mic, LineIN */
+	LRPlayVol,	/* Left/Right volume for speaker, no master volume */
+	masterPlayMute,	/* feature ID for master play mute for Speaker, K.Okamoto */
+	masterPlayVol,	/* feature ID for master play volume control function */
 };
 
 typedef struct Audiocontrol Audiocontrol;
 
 struct Audiocontrol {
-	char		*name;
+	char	*name;
 	uchar	readable;
 	uchar	settable;
 	uchar	chans;		/* 0 is master, non-zero is bitmap */
-	long		value[8];		/* 0 is master; value[0] == Undef -> all values Undef */
-	long		min, max, step;
+	long	value[9];	/* 0 is master; value[0] == Undef -> all values Undef */
+	long	min, max, step;
 };
 
+typedef struct FeatureAttr FeatureAttr;	/* K.Okamoto */
+
+struct FeatureAttr {
+	int		id;
+	uchar	readable;
+	uchar	settable;
+	uchar	chans;
+	long value[9];
+	long	min, max, step;
+};
+
+typedef struct MasterVol MasterVol;	/* K.Okamoto */
+
+struct MasterVol {			/* K.Okamoto */
+	long	min;
+	long max;
+	long step;
+	long value;		
+};
 
 extern Audiocontrol controls[2][Ncontrol];
 extern int endpt[2];
 extern int interface[2];
-extern int featureid[2];
+extern int featureid[2];		/* current Play/Record Feature ID */
 extern int selectorid[2];
+extern int selector;			/* K.Okamoto */
+extern int mixerid;			/* K.Okamoto */
 extern int buttonendpt;
 
 int	ctlparse(char *s, Audiocontrol *c, long *v);
 void	ctlevent(void);
+int	getspecialcontrol(Audiocontrol *c, int rec, int ctl, int req, long *value);
+int	setselector(int);		/* added by K.Okamoto */
+int	initmixer(void);	/* added by K.Okamoto */
+int	getmasterValue(int, int, int, int, int, long*);	/* added by K.Okamoto */
+int	getchannelVol(int, int, int, int, int, uchar, long*);	/* added by K.okamoto */
+int	setmasterValue(Audiocontrol*, int, int, int, int, int, long*);	/* K.Okamoto */
+int	setchannelVol(Audiocontrol*, int, int, int, int, int, long*);	/* K.Okamoto */
+int	printValue(Audiocontrol*, int req, long*);			/* K.Okamoto */
 
 #pragma	varargck	type	"A"	Audiocontrol*

+ 6 - 1
sys/src/cmd/usb/lib/device.c

@@ -135,13 +135,18 @@ int
 loadconfig(Device *d, int n)
 {
 	byte buf[1023];
-	int nr;
+	int nr, len;
 
 	if (setupreq(d->ep[0], RD2H|Rstandard|Rdevice, GET_DESCRIPTOR, (CONFIGURATION<<8)|n, 0, sizeof(buf)) < 0 ||
 	   (nr = setupreply(d->ep[0], buf, sizeof(buf))) < 1) {
 		fprint(2, "usb: error reading configuration descriptor\n");
 		return -1;
 	}
+	if (buf[1] == CONFIGURATION) {
+		len = GET2(((DConfig*)buf)->wTotalLength);
+		if (len < nr)
+			nr = len;
+	}
 	/* extract gubbins */
 	pdesc(d, n, -1, buf, nr);
 	return 0;

+ 11 - 2
sys/src/cmd/usb/lib/dump.c

@@ -387,6 +387,7 @@ pdesc(Device *d, int c, ulong csp, byte *b, int n)
 	DConfig *dc;
 	DInterface *di;
 	DEndpoint *de;
+	int i;
 
 	class = Class(csp);
 
@@ -489,16 +490,24 @@ pdesc(Device *d, int c, ulong csp, byte *b, int n)
 				sysfatal("d->config[c]->iface[ifc] == nil");
 			if (d->config[c]->iface[ifc]->dalt[dalt] == nil)
 				d->config[c]->iface[ifc]->dalt[dalt] = mallocz(sizeof(Dalt),1);
-			d->config[c]->iface[ifc]->addr = de->bEndpointAddress;
-			d->config[c]->iface[ifc]->dalt[dalt]->maxpkt = GET2(de->wMaxPacketSize);
 			d->config[c]->iface[ifc]->dalt[dalt]->attrib = de->bmAttributes;
 			d->config[c]->iface[ifc]->dalt[dalt]->interval = de->bInterval;
 			ep = de->bEndpointAddress & 0xf;
 			if (d->ep[ep] == nil)
 				d->ep[ep] = newendpt(d, ep, class);
+			d->ep[ep]->maxpkt = GET2(de->wMaxPacketSize);
+			d->ep[ep]->addr = de->bEndpointAddress;
 			d->ep[ep]->csp = csp;
 			d->ep[ep]->conf = d->config[c];
 			d->ep[ep]->iface = d->config[c]->iface[ifc];
+			for(i = 0; i < nelem(d->config[c]->iface[ifc]->endpt); i++){
+				if(d->config[c]->iface[ifc]->endpt[i] == nil){
+					d->config[c]->iface[ifc]->endpt[i] = d->ep[ep];
+					break;
+				}
+			}
+			if(i == nelem(d->config[c]->iface[ifc]->endpt))
+				fprint(2, "Too many endpoints\n");
 			if (d->nif <= ep) d->nif = ep+1;
 			break;
 		default:

+ 44 - 40
sys/src/cmd/usb/lib/usb.h

@@ -172,16 +172,21 @@ enum
 	CL_COMMS = 2,
 	CL_HID = 3,
 	CL_PRINTER = 7,
+	CL_STORAGE = 8,
 	CL_HUB = 9,
 	CL_DATA = 10,
 };
 
 struct Endpt
 {
-	int		id;
-	int		class;
+	uchar	addr;		/* endpoint address, 0-15 */
+	uchar	dir;		/* direction, Ein/Eout */
+	uchar	type;		/* Econtrol, Eiso, Ebulk, Eintr */
+	uchar	isotype;	/* Eunknown, Easync, Eadapt, Esync */
+	int	id;
+	int	class;
 	ulong	csp;
-	int		maxpkt;
+	int	maxpkt;
 	Device*	dev;
 	Dconf*	conf;
 	Dinf*	iface;
@@ -189,28 +194,27 @@ struct Endpt
 
 struct Dalt
 {
-	int		maxpkt;	/* max packet size */
-	int		attrib;
-	int		interval;
+	int	attrib;
+	int	interval;
 	void*	devspec;	/* device specific settings */
 };
 
 struct Dinf
 {
-	int 		interface;	/* interface number */
-	int		addr;	/* endpoint number */
+	int 	interface;	/* interface number */
 	ulong	csp;		/* USB class/subclass/proto */
-	Dalt*		dalt[16];
+	Dalt*	dalt[16];
+	Endpt*	endpt[16];
 };
 
 struct Dconf
 {
-	ulong	csp;			/* USB class/subclass/proto */
-	int		nif;			/* number of interfaces */
-	int		cval;			/* value for set configuration */
-	int		attrib;
-	int		milliamps;		/* maximum power in this configuration */
-	Dinf*	iface[16];		/* up to 16 interfaces */
+	ulong	csp;		/* USB class/subclass/proto */
+	int	nif;		/* number of interfaces */
+	int	cval;		/* value for set configuration */
+	int	attrib;
+	int	milliamps;	/* maximum power in this configuration */
+	Dinf*	iface[16];	/* up to 16 interfaces */
 };
 
 /* Dconf.attrib */
@@ -224,20 +228,20 @@ enum
 struct Device
 {
 	Ref;
-	int		ctlrno;
-	int		ctl;
-	int		setup;
-	int		status;
-	int		state;
-	int		id;
-	int		class;
-	int		npt;
-	int		ls;			/* low speed */
+	int	ctlrno;
+	int	ctl;
+	int	setup;
+	int	status;
+	int	state;
+	int	id;
+	int	class;
+	int	npt;
+	int	ls;		/* low speed */
 	ulong	csp;		/* USB class/subclass/proto */
-	int		nconf;
-	int		nif;		/* number of interfaces (sum of per-conf `nif's) */
-	int		vid;		/* vendor id */
-	int		did;		/* product (device) id */
+	int	nconf;
+	int	nif;		/* number of interfaces (sum of per-conf `nif's) */
+	int	vid;		/* vendor id */
+	int	did;		/* product (device) id */
 	Dconf*	config[16];
 	Endpt*	ep[Nendpt];
 };
@@ -360,19 +364,19 @@ void	pcs_raw(char *tag, byte *b, int n);
 /*
  * interface
  */
-void		usbfmtinit(void);
+void	usbfmtinit(void);
 Device*	opendev(int, int);
-void		closedev(Device*);
-int		describedevice(Device*);
-int		loadconfig(Device *d, int n);
+void	closedev(Device*);
+int	describedevice(Device*);
+int	loadconfig(Device *d, int n);
 Endpt *	newendpt(Device *d, int id, ulong csp);
-int		setupcmd(Endpt*, int, int, int, int, byte*, int);
-int		setupreq(Endpt*, int, int, int, int, int);
-int		setupreply(Endpt*, void*, int);
-void		setdevclass(Device *d, int n);
-void	*	emalloc(ulong);
-void	*	emallocz(ulong, int);
-
-char	*	namefor(Namelist *, int);
+int	setupcmd(Endpt*, int, int, int, int, byte*, int);
+int	setupreq(Endpt*, int, int, int, int, int);
+int	setupreply(Endpt*, void*, int);
+void	setdevclass(Device *d, int n);
+void *	emalloc(ulong);
+void *	emallocz(ulong, int);
+
+char *	namefor(Namelist *, int);
 
 #pragma	varargck	type  "D"	Device*

+ 26 - 8
sys/src/cmd/usb/misc/usbmouse.c

@@ -5,18 +5,20 @@
 
 int mousefd, ctlfd, mousein;
 
-char hbm[]			= "Enabled 0x020103\n";
+char hbm[]		= "Enabled 0x020103\n";
 char *mouseinfile	= "#m/mousein";
 char *statfmt		= "#U/usb%d/%d/status";
 char *ctlfmt		= "#U/usb%d/%d/ctl";
 char *msefmt		= "#U/usb%d/%d/ep1data";
-char *ctlstr		= "ep 1 bulk r 3 32";
+char *ctl3str		= "ep 1 bulk r 3 32";
+char *ctl5str		= "ep 1 bulk r 5 32";
 char ctlfile[32];
 char msefile[32];
 
 int verbose;
 int nofork;
 int accel;
+int scroll;
 int maxacc = 3;
 int debug;
 
@@ -90,6 +92,9 @@ threadmain(int argc, char *argv[])
 	char line[256];
 
 	ARGBEGIN{
+	case 's':
+		scroll=1;
+		break;
 	case 'v':
 		verbose=1;
 		break;
@@ -136,8 +141,8 @@ threadmain(int argc, char *argv[])
 	if ((ctlfd = open(ctlfile, OWRITE)) < 0)
 		sysfatal("%s: %r", ctlfile);
 	if (verbose)
-		fprint(2, "Send %s to %s\n", ctlstr, ctlfile);
-	write(ctlfd, ctlstr, strlen(ctlstr));
+		fprint(2, "Send %s to %s\n", scroll?ctl5str:ctl3str, ctlfile);
+	write(ctlfd, scroll?ctl5str:ctl3str, scroll?strlen(ctl5str):strlen(ctl3str));
 	close(ctlfd);
 	if ((mousefd = open(msefile, OREAD)) < 0)
 		sysfatal("%s: %r", msefile);
@@ -155,11 +160,24 @@ threadmain(int argc, char *argv[])
 
 void
 work(void *){
-	char buf[4];
-	int x, y;
+	char buf[6];
+	int x, y, buts;
 
 	for (;;) {
-		switch (robustread(mousefd, buf, 3)) {
+		buts = 0;
+		switch (robustread(mousefd, buf, scroll?5:3)) {
+		case 4:
+			if(buf[3] == 1)
+				buts |= 0x08;
+			else if(buf[3] == -1)
+				buts |= 0x10;
+			/* Fall through */
+		case 5:
+			if(buf[3] > 10)
+				buts |= 0x08;
+			else if(buf[3] < -10)
+				buts |= 0x10;
+			/* Fall through */
 		case 3:
 			if (accel) {
 				x = scale(buf[1]);
@@ -168,7 +186,7 @@ work(void *){
 				x = buf[1];
 				y = buf[2];
 			}
-			fprint(mousein, "m%11d %11d %11d", x, y, maptab[buf[0]&0x7]);
+			fprint(mousein, "m%11d %11d %11d", x, y, buts | maptab[buf[0]&0x7]);
 			break;
 		case -1:
 			sysfatal("read error: %r");

Some files were not shown because too many files changed in this diff