aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/misc/Kconfig11
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/isight_firmware.c131
3 files changed, 143 insertions, 0 deletions
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index a53db1d4e07a..eb6c06979f3b 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -269,3 +269,14 @@ config USB_TEST
269 See <http://www.linux-usb.org/usbtest/> for more information, 269 See <http://www.linux-usb.org/usbtest/> for more information,
270 including sample test device firmware and "how to use it". 270 including sample test device firmware and "how to use it".
271 271
272config USB_ISIGHTFW
273 tristate "iSight firmware loading support"
274 depends on USB
275 help
276 This driver loads firmware for USB Apple iSight cameras, allowing
277 them to be driven by the USB video class driver available at
278 http://linux-uvc.berlios.de
279
280 The firmware for this driver must be extracted from the MacOS
281 driver beforehand. Tools for doing so are available at
282 http://bersace03.free.fr
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index b68e6b774f1a..aba091cb5ec0 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_EMI62) += emi62.o
14obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o 14obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
15obj-$(CONFIG_USB_IDMOUSE) += idmouse.o 15obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
16obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o 16obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o
17obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
17obj-$(CONFIG_USB_LCD) += usblcd.o 18obj-$(CONFIG_USB_LCD) += usblcd.o
18obj-$(CONFIG_USB_LD) += ldusb.o 19obj-$(CONFIG_USB_LD) += ldusb.o
19obj-$(CONFIG_USB_LED) += usbled.o 20obj-$(CONFIG_USB_LED) += usbled.o
diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c
new file mode 100644
index 000000000000..390e04885536
--- /dev/null
+++ b/drivers/usb/misc/isight_firmware.c
@@ -0,0 +1,131 @@
1/*
2 * Driver for loading USB isight firmware
3 *
4 * Copyright (C) 2008 Matthew Garrett <mjg@redhat.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, version 2.
9 *
10 * The USB isight cameras in recent Apples are roughly compatible with the USB
11 * video class specification, and can be driven by uvcvideo. However, they
12 * need firmware to be loaded beforehand. After firmware loading, the device
13 * detaches from the USB bus and reattaches with a new device ID. It can then
14 * be claimed by the uvc driver.
15 *
16 * The firmware is non-free and must be extracted by the user. Tools to do this
17 * are available at http://bersace03.free.fr/ift/
18 *
19 * The isight firmware loading was reverse engineered by Johannes Berg
20 * <johannes@sipsolutions.de>, and this driver is based on code by Ronald
21 * Bultje <rbultje@ronald.bitfreak.net>
22 */
23
24#include <linux/usb.h>
25#include <linux/firmware.h>
26#include <linux/errno.h>
27#include <linux/module.h>
28
29static struct usb_device_id id_table[] = {
30 {USB_DEVICE(0x05ac, 0x8300)},
31 {},
32};
33
34MODULE_DEVICE_TABLE(usb, id_table);
35
36static int isight_firmware_load(struct usb_interface *intf,
37 const struct usb_device_id *id)
38{
39 struct usb_device *dev = interface_to_usbdev(intf);
40 int llen, len, req, ret = 0;
41 const struct firmware *firmware;
42 unsigned char *buf;
43 unsigned char data[4];
44 char *ptr;
45
46 if (request_firmware(&firmware, "isight.fw", &dev->dev) != 0) {
47 printk(KERN_ERR "Unable to load isight firmware\n");
48 return -ENODEV;
49 }
50
51 ptr = firmware->data;
52
53 if (usb_control_msg
54 (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, "\1", 1,
55 300) != 1) {
56 printk(KERN_ERR
57 "Failed to initialise isight firmware loader\n");
58 ret = -ENODEV;
59 goto out;
60 }
61
62 while (1) {
63 memcpy(data, ptr, 4);
64 len = (data[0] << 8 | data[1]);
65 req = (data[2] << 8 | data[3]);
66 ptr += 4;
67
68 if (len == 0x8001)
69 break; /* success */
70 else if (len == 0)
71 continue;
72
73 for (; len > 0; req += 50) {
74 llen = len > 50 ? 50 : len;
75 len -= llen;
76
77 buf = kmalloc(llen, GFP_KERNEL);
78 memcpy(buf, ptr, llen);
79
80 ptr += llen;
81
82 if (usb_control_msg
83 (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, req, 0,
84 buf, llen, 300) != llen) {
85 printk(KERN_ERR
86 "Failed to load isight firmware\n");
87 kfree(buf);
88 ret = -ENODEV;
89 goto out;
90 }
91
92 kfree(buf);
93 }
94 }
95 if (usb_control_msg
96 (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, "\0", 1,
97 300) != 1) {
98 printk(KERN_ERR "isight firmware loading completion failed\n");
99 ret = -ENODEV;
100 }
101out:
102 release_firmware(firmware);
103 return ret;
104}
105
106static void isight_firmware_disconnect(struct usb_interface *intf)
107{
108}
109
110static struct usb_driver isight_firmware_driver = {
111 .name = "isight_firmware",
112 .probe = isight_firmware_load,
113 .disconnect = isight_firmware_disconnect,
114 .id_table = id_table,
115};
116
117static int __init isight_firmware_init(void)
118{
119 return usb_register(&isight_firmware_driver);
120}
121
122static void __exit isight_firmware_exit(void)
123{
124 usb_deregister(&isight_firmware_driver);
125}
126
127module_init(isight_firmware_init);
128module_exit(isight_firmware_exit);
129
130MODULE_LICENSE("GPL");
131MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");