M-Audio Transit experiments

Stefan Ehmann shoesoft at gmx.net
Sat Mar 17 12:05:17 UTC 2007


On Saturday 17 March 2007 12:57:01 Stefan Ehmann wrote:
> Anyway, if you want to play around, the patch is attached. Forget about the
> autotools stuff for now and simply compile the madfuload.c file.

This time for real:

--- madfuload-1.2.orig/madfuload.c	Sun Mar  5 22:00:08 2006
+++ madfuload-1.2/madfuload.c	Sat Mar 17 12:40:06 2007
@@ -4,9 +4,13 @@
  * For legal details, see the LICENSE file.
  */
 
+#define PACKAGE "madfuload"
+#define VERSION "1.2"
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <stdarg.h>
 #include <errno.h>
 #include <time.h>
@@ -16,7 +20,9 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <syslog.h>
-#include <linux/ioctl.h>
+#include <sys/ioctl.h>
+
+#include <dev/usb/usb.h>
 
 /* USB stuff -- we can't rely on all Linux headers being there */
 
@@ -132,23 +138,30 @@
 		       unsigned short value, unsigned short index,
 		       unsigned short length, void *data)
 {
-	struct usbdevfs_ctrltransfer ct;
+	struct usb_ctl_request req;
 	int retries, err;
 
-	ct.bRequestType = request_type;
-	ct.bRequest = request;
-	ct.wValue = value;
-	ct.wIndex = index;
-	ct.wLength = length;
-	ct.timeout = 500;
-	ct.data = data;
-	for (retries = 0; retries < 3; ++retries) {
-		err = ioctl(device, USBDEVFS_CONTROL, &ct);
-		if (err >= 0)
-			break;
-		warning("control transfer failed: (%d) %s", errno, strerror(errno));
+	req.ucr_request.bmRequestType = request_type;
+	req.ucr_request.bRequest = request;
+	USETW(req.ucr_request.wValue, value);
+	USETW(req.ucr_request.wIndex, index);
+	USETW(req.ucr_request.wLength, length);
+
+	req.ucr_data = data;
+	req.ucr_flags = USBD_SHORT_XFER_OK;
+
+	int timeout = 500;
+	err = ioctl(device, USB_SET_TIMEOUT, &timeout);
+	if (err < 0) {
+		warning("timeout failed: (%d) %s", errno, strerror(errno));
 	}
-	return err;
+
+	err = ioctl(device, USB_DO_REQUEST, &req);
+	if (err < 0)
+		warning("ioctl failed: (%d) %s", errno, strerror(errno));
+
+	return UGETW(req.ucr_request.wLength);
+
 }
 
 static int usb_claim_interface(unsigned int interface)
@@ -158,7 +171,8 @@
 
 static int usb_reset(void)
 {
-	return ioctl(device, USBDEVFS_RESET, NULL);
+	//return ioctl(device, USBDEVFS_RESET, NULL);
+	return 0;
 }
 
 static void load_firmware(char *filename)
@@ -285,8 +299,8 @@
 	if (device == -1)
 		fatal("cannot open %s: %s", device_file, strerror(errno));
 	parse_descriptors();
-	if (usb_claim_interface(interface) == -1)
-		fatal("cannot claim interface %d: (%d) %s", interface, errno, 
strerror(errno));
+	// if (usb_claim_interface(interface) == -1)
+	// 	fatal("cannot claim interface %d: (%d) %s", interface, errno, 
strerror(errno));
 
 	for (pos = 0; pos < firmware_length; pos += transfer_size) {
 		if (firmware_length - pos > transfer_size)


More information about the freebsd-multimedia mailing list