staging: delete non-required instances of include <linux/init.h>
[deliverable/linux.git] / drivers / staging / media / go7007 / go7007-loader.c
CommitLineData
b11869db
PE
1/*
2 * Copyright (C) 2008 Sensoray Company Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */
17
18#include <linux/module.h>
5a0e3ad6 19#include <linux/slab.h>
b11869db 20#include <linux/usb.h>
c046981f
HV
21#include <linux/firmware.h>
22#include <cypress_firmware.h>
b11869db 23
0ee3d4d5
HV
24struct fw_config {
25 u16 vendor;
26 u16 product;
27 const char * const fw_name1;
28 const char * const fw_name2;
29};
b11869db 30
0ee3d4d5
HV
31struct fw_config fw_configs[] = {
32 { 0x1943, 0xa250, "go7007/s2250-1.fw", "go7007/s2250-2.fw" },
33 { 0x093b, 0xa002, "go7007/px-m402u.fw", NULL },
34 { 0x093b, 0xa004, "go7007/px-tv402u.fw", NULL },
35 { 0x0eb1, 0x6666, "go7007/lr192.fw", NULL },
36 { 0x0eb1, 0x6668, "go7007/wis-startrek.fw", NULL },
37 { 0, 0, NULL, NULL }
38};
39MODULE_FIRMWARE("go7007/s2250-1.fw");
40MODULE_FIRMWARE("go7007/s2250-2.fw");
41MODULE_FIRMWARE("go7007/px-m402u.fw");
42MODULE_FIRMWARE("go7007/px-tv402u.fw");
43MODULE_FIRMWARE("go7007/lr192.fw");
44MODULE_FIRMWARE("go7007/wis-startrek.fw");
b11869db 45
e129c974 46static int go7007_loader_probe(struct usb_interface *interface,
b11869db
PE
47 const struct usb_device_id *id)
48{
49 struct usb_device *usbdev;
b11869db 50 const struct firmware *fw;
0ee3d4d5
HV
51 u16 vendor, product;
52 const char *fw1, *fw2;
53 int ret;
54 int i;
b11869db
PE
55
56 usbdev = usb_get_dev(interface_to_usbdev(interface));
0ee3d4d5
HV
57 if (!usbdev)
58 goto failed2;
b11869db
PE
59
60 if (usbdev->descriptor.bNumConfigurations != 1) {
b11558a3 61 dev_err(&interface->dev, "can't handle multiple config\n");
0ee3d4d5 62 return -ENODEV;
b11869db
PE
63 }
64
0ee3d4d5
HV
65 vendor = le16_to_cpu(usbdev->descriptor.idVendor);
66 product = le16_to_cpu(usbdev->descriptor.idProduct);
b11869db 67
0ee3d4d5
HV
68 for (i = 0; fw_configs[i].fw_name1; i++)
69 if (fw_configs[i].vendor == vendor &&
70 fw_configs[i].product == product)
71 break;
b11869db 72
0ee3d4d5
HV
73 /* Should never happen */
74 if (fw_configs[i].fw_name1 == NULL)
75 goto failed2;
b11869db 76
0ee3d4d5
HV
77 fw1 = fw_configs[i].fw_name1;
78 fw2 = fw_configs[i].fw_name2;
b11869db 79
0ee3d4d5 80 dev_info(&interface->dev, "loading firmware %s\n", fw1);
b11869db 81
0ee3d4d5 82 if (request_firmware(&fw, fw1, &usbdev->dev)) {
b11558a3 83 dev_err(&interface->dev,
0ee3d4d5 84 "unable to load firmware from file \"%s\"\n", fw1);
b11869db
PE
85 goto failed2;
86 }
79a63c60 87 ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
b11869db
PE
88 release_firmware(fw);
89 if (0 != ret) {
b11558a3 90 dev_err(&interface->dev, "loader download failed\n");
b11869db
PE
91 goto failed2;
92 }
93
0ee3d4d5
HV
94 if (fw2 == NULL)
95 return 0;
96
97 if (request_firmware(&fw, fw2, &usbdev->dev)) {
b11558a3 98 dev_err(&interface->dev,
0ee3d4d5 99 "unable to load firmware from file \"%s\"\n", fw2);
b11869db
PE
100 goto failed2;
101 }
79a63c60 102 ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
b11869db
PE
103 release_firmware(fw);
104 if (0 != ret) {
e129c974 105 dev_err(&interface->dev, "firmware download failed\n");
b11869db
PE
106 goto failed2;
107 }
b11869db
PE
108 return 0;
109
b11869db 110failed2:
b11558a3 111 dev_err(&interface->dev, "probe failed\n");
0ee3d4d5 112 return -ENODEV;
b11869db
PE
113}
114
e129c974 115static void go7007_loader_disconnect(struct usb_interface *interface)
b11869db 116{
e129c974 117 dev_info(&interface->dev, "disconnect\n");
b11869db 118 usb_set_intfdata(interface, NULL);
b11869db
PE
119}
120
e129c974 121static const struct usb_device_id go7007_loader_ids[] = {
0ee3d4d5
HV
122 { USB_DEVICE(0x1943, 0xa250) },
123 { USB_DEVICE(0x093b, 0xa002) },
124 { USB_DEVICE(0x093b, 0xa004) },
125 { USB_DEVICE(0x0eb1, 0x6666) },
126 { USB_DEVICE(0x0eb1, 0x6668) },
b11869db
PE
127 {} /* Terminating entry */
128};
129
e129c974 130MODULE_DEVICE_TABLE(usb, go7007_loader_ids);
b11869db 131
e129c974
HV
132static struct usb_driver go7007_loader_driver = {
133 .name = "go7007-loader",
134 .probe = go7007_loader_probe,
135 .disconnect = go7007_loader_disconnect,
136 .id_table = go7007_loader_ids,
b11869db
PE
137};
138
e129c974 139module_usb_driver(go7007_loader_driver);
832b6a89
PE
140
141MODULE_AUTHOR("");
0ee3d4d5 142MODULE_DESCRIPTION("firmware loader for go7007-usb");
832b6a89 143MODULE_LICENSE("GPL v2");
This page took 0.409599 seconds and 5 git commands to generate.