3 # UsbTab -- encapsulate modules.usbmap
4 # Copyright (C) 2005 Erik van Konijnenburg
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 # # usb module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info
31 # bfusb 0x0003 0x057c 0x2200 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
32 # bcm203x 0x0003 0x0a5c 0x2033 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
35 if (defined ($usbList)) {
39 my $name = Conf::get('usbMap');
40 if (! open (IN, "<", "$name")) {
41 Base::fatal ("can't open usb module list $name");
43 while (defined (my $line = <IN>)) {
48 next if ($line eq "");
49 my @fields = split (/\s+/, $line, 999);
51 Base::fatal ("malformed line in usb module list $name");
53 push @{$usbList}, UsbMapEntry->new (
55 match_flags => hex ($fields[1]),
56 idVendor => hex ($fields[2]),
57 idProduct => hex ($fields[3]),
58 bcdDevice_lo => hex ($fields[4]),
59 bcdDevice_hi => hex ($fields[5]),
60 bDeviceClass => hex ($fields[6]),
61 bDeviceSubClass => hex ($fields[7]),
62 bDeviceProtocol => hex ($fields[8]),
63 bInterfaceClass => hex ($fields[9]),
64 bInterfaceSubClass => hex ($fields[10]),
65 bInterfaceProtocol => hex ($fields[11]),
66 driver_info => hex ($fields[12]),
70 Base::fatal ("could not read usb module list $name");
79 # given pathname in devices tree, return list of matching modules.
83 for my $ume (@{UsbTab::all()}) {
84 if ($ume->matches ($dev)) {
85 push @result, $ume->module;