diff options
author | etobi <git@e-tobi.net> | 2013-09-03 09:48:38 +0200 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:38 +0200 |
commit | 6e40287e2f39a80fc72bd8d0fbc1a8334d688c2d (patch) | |
tree | 024bef311226653bdd1da4fa588becf5098bcff7 /util/ttusb_dec_reset | |
download | linux-dvb-apps-6e40287e2f39a80fc72bd8d0fbc1a8334d688c2d.tar.gz |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'util/ttusb_dec_reset')
-rw-r--r-- | util/ttusb_dec_reset/Makefile | 17 | ||||
-rw-r--r-- | util/ttusb_dec_reset/README | 28 | ||||
-rw-r--r-- | util/ttusb_dec_reset/ttusb_dec_reset.c | 53 |
3 files changed, 98 insertions, 0 deletions
diff --git a/util/ttusb_dec_reset/Makefile b/util/ttusb_dec_reset/Makefile new file mode 100644 index 0000000..cde7de5 --- /dev/null +++ b/util/ttusb_dec_reset/Makefile @@ -0,0 +1,17 @@ +CC = gcc +RM = rm -f +CFLAGS = -g -Wall -O2 +LFLAGS = -g -Wall +LDFLAGS = -lusb + +OBJS = ttusb_dec_reset.o +TARGET = ttusb_dec_reset + +$(TARGET): $(OBJS) + $(CC) $(LFLAGS) $(LDFLAGS) -o $(TARGET) $(OBJS) + +.c.o: + $(CC) $(CFLAGS) -c $< -o $@ + +clean: + $(RM) *.o $(TARGET) diff --git a/util/ttusb_dec_reset/README b/util/ttusb_dec_reset/README new file mode 100644 index 0000000..50db265 --- /dev/null +++ b/util/ttusb_dec_reset/README @@ -0,0 +1,28 @@ +Hello, + +In theory the driver could be made to send the DEC the reset sequence when +all devices were closed. However, due to the awkwardness of switching +between slave and stand-alone mode, I've decided against this. Hence this +application, which I hope provides the user a nice compromise between +control and ease-of-use. + +ttusb_dec_reset is a small utility for resetting a ttusb-dec device to +stand-alone mode after use. It requires libusb, which can be found here: + +http://libusb.sourceforge.net/ + +There is probably a package for it included with your linux distribution +though. + +For the utility to reset a device, it must have permission to access the usb +device, and the device must not be claimed by anything else. That means that +the ttusb-dec module must be rmmoded before using this utility. You probably +want to have turned off any hotplug mechanisms before running the utility +or the device will likely get taken over again once it comes back up. Or you +could just yank the usb cable out. + +The utility takes no arguments, you just run it: +./ttusb_dec_reset + +Cheers, +Alex diff --git a/util/ttusb_dec_reset/ttusb_dec_reset.c b/util/ttusb_dec_reset/ttusb_dec_reset.c new file mode 100644 index 0000000..51ddfc7 --- /dev/null +++ b/util/ttusb_dec_reset/ttusb_dec_reset.c @@ -0,0 +1,53 @@ +#include <stdio.h> +#include <usb.h> + +void dec_reset(struct usb_device *dev) +{ + char message[] = {0xaa, 0x00, 0xf1, 0x01, 0x00}; + usb_dev_handle *handle = usb_open(dev); + + printf("Device found.\n"); + + if (handle) { + if (!usb_claim_interface(handle, 0)) { + int result; + printf("Reseting device.. "); + result = usb_bulk_write(handle, 3, message, + sizeof(message), 1000); + if (result >= 0) + printf("succeeded.\n"); + else + printf("failed. (Error code: %d)\n", result); + } else { + printf("Couldn't claim interface.\n"); + } + usb_close(handle); + } +} + +int main() +{ + struct usb_bus *busses; + struct usb_bus *bus; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + busses = usb_get_busses(); + + for (bus = busses; bus; bus = bus->next) { + struct usb_device *dev; + + for (dev = bus->devices; dev; dev = dev->next) { + if (dev->descriptor.idVendor == 0x0b48 && + (dev->descriptor.idProduct == 0x1006 || + dev->descriptor.idProduct == 0x1008 || + dev->descriptor.idProduct == 0x1009)) { + dec_reset(dev); + } + } + } + + return 0; +} |