1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for loading USB isight firmware
5 * Copyright (C) 2008 Matthew Garrett <mjg@redhat.com>
7 * The USB isight cameras in recent Apples are roughly compatible with the USB
8 * video class specification, and can be driven by uvcvideo. However, they
9 * need firmware to be loaded beforehand. After firmware loading, the device
10 * detaches from the USB bus and reattaches with a new device ID. It can then
11 * be claimed by the uvc driver.
13 * The firmware is non-free and must be extracted by the user. Tools to do this
14 * are available at http://bersace03.free.fr/ift/
16 * The isight firmware loading was reverse engineered by Johannes Berg
17 * <johannes@sipsolutions.de>, and this driver is based on code by Ronald
18 * Bultje <rbultje@ronald.bitfreak.net>
21 #include <linux/usb.h>
22 #include <linux/firmware.h>
23 #include <linux/errno.h>
24 #include <linux/module.h>
25 #include <linux/slab.h>
27 static const struct usb_device_id id_table
[] = {
28 {USB_DEVICE(0x05ac, 0x8300)},
32 MODULE_DEVICE_TABLE(usb
, id_table
);
34 static int isight_firmware_load(struct usb_interface
*intf
,
35 const struct usb_device_id
*id
)
37 struct usb_device
*dev
= interface_to_usbdev(intf
);
38 int llen
, len
, req
, ret
= 0;
39 const struct firmware
*firmware
;
40 unsigned char *buf
= kmalloc(50, GFP_KERNEL
);
41 unsigned char data
[4];
47 if (request_firmware(&firmware
, "isight.fw", &dev
->dev
) != 0) {
48 printk(KERN_ERR
"Unable to load isight firmware\n");
57 (dev
, usb_sndctrlpipe(dev
, 0), 0xa0, 0x40, 0xe600, 0, buf
, 1,
60 "Failed to initialise isight firmware loader\n");
65 while (ptr
+4 <= firmware
->data
+firmware
->size
) {
67 len
= (data
[0] << 8 | data
[1]);
68 req
= (data
[2] << 8 | data
[3]);
76 for (; len
> 0; req
+= 50) {
79 if (ptr
+llen
> firmware
->data
+firmware
->size
) {
81 "Malformed isight firmware");
85 memcpy(buf
, ptr
, llen
);
90 (dev
, usb_sndctrlpipe(dev
, 0), 0xa0, 0x40, req
, 0,
91 buf
, llen
, 300) != llen
) {
93 "Failed to load isight firmware\n");
103 (dev
, usb_sndctrlpipe(dev
, 0), 0xa0, 0x40, 0xe600, 0, buf
, 1,
105 printk(KERN_ERR
"isight firmware loading completion failed\n");
111 release_firmware(firmware
);
115 MODULE_FIRMWARE("isight.fw");
117 static void isight_firmware_disconnect(struct usb_interface
*intf
)
121 static struct usb_driver isight_firmware_driver
= {
122 .name
= "isight_firmware",
123 .probe
= isight_firmware_load
,
124 .disconnect
= isight_firmware_disconnect
,
125 .id_table
= id_table
,
128 module_usb_driver(isight_firmware_driver
);
130 MODULE_LICENSE("GPL");
131 MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");