View | Details | Raw Unified | Return to bug 135860 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-1 / +3 lines)
Lines 60-65 OPTIONS= ARTSWRAPPER "Suid wrapper for a Link Here
60
60
61
.if ${OSVERSION} < 800069
61
.if ${OSVERSION} < 800069
62
LIB_DEPENDS+=	usb-0.1:${PORTSDIR}/devel/libusb
62
LIB_DEPENDS+=	usb-0.1:${PORTSDIR}/devel/libusb
63
.else
64
EXTRA_PATCHES+=	${FILESDIR}/extrapatch-libusb20
63
.endif
65
.endif
64
66
65
.if !defined(WITHOUT_ARTSWRAPPER)
67
.if !defined(WITHOUT_ARTSWRAPPER)
Lines 71-77 RUN_DEPENDS+= htdig:${PORTSDIR}/textproc Link Here
71
.endif
73
.endif
72
74
73
.if !defined(WITHOUT_HAL)
75
.if !defined(WITHOUT_HAL)
74
EXTRA_PATCHES=	${FILESDIR}/extrapatch-kioslave_media_mediamanager-halbackend.cpp \
76
EXTRA_PATCHES+=	${FILESDIR}/extrapatch-kioslave_media_mediamanager-halbackend.cpp \
75
		${FILESDIR}/extrapatch-kioslave_media_mediamanager-halbackend.h
77
		${FILESDIR}/extrapatch-kioslave_media_mediamanager-halbackend.h
76
LIB_DEPENDS+=	dbus-qt-1.1:${PORTSDIR}/devel/dbus-qt3 \
78
LIB_DEPENDS+=	dbus-qt-1.1:${PORTSDIR}/devel/dbus-qt3 \
77
		hal.1:${PORTSDIR}/sysutils/hal
79
		hal.1:${PORTSDIR}/sysutils/hal
(-)files/extrapatch-libusb20 (+166 lines)
Added Link Here
1
--- usbdevices.h.orig	2006-07-22 10:15:22.000000000 +0200
2
+++ usbdevices.h	2009-06-20 13:19:42.000000000 +0200
3
@@ -17,7 +17,9 @@
4
 #include <qptrlist.h>
5
 
6
 #ifdef Q_OS_FREEBSD
7
-#include <dev/usb/usb.h>
8
+#include <libusb20.h>
9
+#include <dev/usb/usb_ioctl.h>
10
+#include <dev/usb/usb_revision.h>
11
 #endif
12
 
13
 class USBDB;
14
@@ -66,7 +68,7 @@
15
   unsigned int _vendorID, _prodID, _revMajor, _revMinor;
16
 
17
 #ifdef Q_OS_FREEBSD
18
-  void collectData( int fd, int level, usb_device_info &di, int parent );
19
+  void collectData(struct libusb20_backend *, struct libusb20_device *);
20
   QStringList _devnodes;
21
 #endif
22
 };
23
--- usbdevices.cpp.orig	2009-06-20 13:19:47.000000000 +0200
24
+++ usbdevices.cpp	2009-06-20 13:38:34.000000000 +0200
25
@@ -318,17 +318,25 @@
26
 
27
 /*
28
  * FreeBSD support by Markus Brueffer <markus@brueffer.de>
29
+ * libusb20 support by Hans Petter Selasky <hselasky@freebsd.org>
30
  *
31
  * Basic idea and some code fragments were taken from FreeBSD's usbdevs(8), 
32
  * originally developed for NetBSD, so this code should work with no or 
33
  * only little modification on NetBSD.
34
  */
35
 
36
-void USBDevice::collectData( int fd, int level, usb_device_info &di, int parent)
37
+void USBDevice::collectData(struct libusb20_backend *pbe,
38
+    struct libusb20_device *pdev)
39
 {
40
+	char tempbuf[32];
41
+	struct usb_device_info di;
42
+
43
+	if (libusb20_dev_get_info(pdev, &di))
44
+		memset(&di, 0, sizeof(di));
45
+
46
 	// determine data for this device
47
-	_level        = level;
48
-	_parent       = parent;
49
+	_level        = 0;
50
+	_parent       = 0;
51
 	
52
 	_bus          = di.udi_bus;
53
 	_device       = di.udi_addr;
54
@@ -345,87 +353,49 @@
55
 	_channels     = di.udi_nports;
56
 	
57
 	// determine the speed
58
-#if __FreeBSD_version > 490102
59
 	switch (di.udi_speed) {
60
 		case USB_SPEED_LOW:  _speed = 1.5;   break;
61
 		case USB_SPEED_FULL: _speed = 12.0;  break;
62
 		case USB_SPEED_HIGH: _speed = 480.0; break;
63
+		case USB_SPEED_VARIABLE: _speed = 480.0; break;
64
+		case USB_SPEED_SUPER: _speed = 4800.0; break;
65
+		default: _speed = 480.0; break;
66
 	}
67
-#else
68
-	_speed = di.udi_lowspeed ? 1.5 : 12.0;
69
-#endif
70
 
71
 	// Get all attached devicenodes
72
-	for ( int i = 0; i < USB_MAX_DEVNAMES; ++i )
73
-		if ( di.udi_devnames[i][0] )
74
-			_devnodes << di.udi_devnames[i];
75
+	for (int i = 0; i < 32; ++i) {
76
+	    if (libusb20_dev_get_iface_desc(pdev, i, tempbuf, sizeof(tempbuf)) == 0) {
77
+		_devnodes << tempbuf;
78
+	    } else {
79
+		break;
80
+	    }
81
+	}
82
 
83
 	// For compatibility, split the revision number
84
 	sscanf( di.udi_release, "%x.%x", &_revMajor, &_revMinor );
85
 
86
-	// Cycle through the attached devices if there are any
87
-	for ( int p = 0; p < di.udi_nports; ++p ) {
88
-		// Get data for device
89
-		struct usb_device_info di2;
90
-
91
-		di2.udi_addr = di.udi_ports[p];
92
-		
93
-		if ( di2.udi_addr >= USB_MAX_DEVICES )
94
-			continue;
95
-			
96
-		if ( ioctl(fd, USB_DEVICEINFO, &di2) == -1 )
97
-			continue;
98
-
99
-		// Only add the device if we didn't detect it, yet
100
-		if (!find( di2.udi_bus, di2.udi_addr ) )
101
-		{
102
-			USBDevice *device = new USBDevice();
103
-			device->collectData( fd, level + 1, di2, di.udi_addr );
104
-		}
105
-	}
106
 }
107
 
108
-
109
-
110
 bool USBDevice::parse(QString fname)
111
 {
112
-	static bool showErrorMessage = true;
113
-	bool error = false;
114
+	struct libusb20_backend *pbe;
115
+	struct libusb20_device *pdev;
116
+
117
 	_devices.clear();
118
 	
119
-	QFile controller("/dev/usb0");
120
-	int i = 1;
121
-	while ( controller.exists() )
122
-	{
123
-		// If the devicenode exists, continue with further inspection
124
-		if ( controller.open(IO_ReadOnly) )
125
-		{
126
-			for ( int addr = 1; addr < USB_MAX_DEVICES; ++addr ) 
127
-			{
128
-				struct usb_device_info di;
129
-				
130
-				di.udi_addr = addr;
131
-				if ( ioctl(controller.handle(), USB_DEVICEINFO, &di) != -1 )
132
-				{
133
-					if (!find( di.udi_bus, di.udi_addr ) )
134
-					{
135
-						USBDevice *device = new USBDevice();
136
-						device->collectData( controller.handle(), 0, di, 0);
137
-					}
138
-				}
139
-			}
140
-			controller.close();
141
-		} else {
142
-			error = true;
143
-		}
144
-		controller.setName( QString::fromLocal8Bit("/dev/usb%1").arg(i++) );
145
-	}
146
-	
147
-	if ( showErrorMessage && error ) {
148
-		showErrorMessage = false;
149
-		KMessageBox::error( 0, i18n("Could not open one or more USB controller. Make sure, you have read access to all USB controllers that should be listed here."));
150
+	pbe = libusb20_be_alloc_default();
151
+	if (pbe == NULL)
152
+	    return (false);
153
+
154
+	pdev = NULL;
155
+
156
+	while ((pdev = libusb20_be_device_foreach(pbe, pdev))) {
157
+	    USBDevice *device = new USBDevice();
158
+	    device->collectData(pbe, pdev);
159
 	}
160
-	
161
+
162
+	libusb20_be_free(pbe);
163
+
164
 	return true;
165
 }
166
 #endif
(-)files/patch-kcontrol-usbview-usbdevices.h (-18 lines)
Removed Link Here
1
Patch included below. FreeBSD_version is approximate.
2
3
--- kcontrol/usbview/usbdevices.h.orig	2006-07-22 10:15:22.000000000 +0200
4
+++ kcontrol/usbview/usbdevices.h	2009-03-15 23:24:38.000000000 +0100
5
@@ -17,8 +17,13 @@
6
 #include <qptrlist.h>
7
 
8
 #ifdef Q_OS_FREEBSD
9
+#include <osreldate.h>
10
+#if __FreeBSD_version >= 800069
11
+#include <legacy/dev/usb/usb.h>
12
+#else
13
 #include <dev/usb/usb.h>
14
 #endif
15
+#endif
16
 
17
 class USBDB;
18
 

Return to bug 135860