Version:  2.0.40 2.2.26 2.4.37 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16

Linux/drivers/staging/media/go7007/go7007-loader.c

  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>
 19 #include <linux/slab.h>
 20 #include <linux/usb.h>
 21 #include <linux/firmware.h>
 22 #include <cypress_firmware.h>
 23 
 24 struct fw_config {
 25         u16 vendor;
 26         u16 product;
 27         const char * const fw_name1;
 28         const char * const fw_name2;
 29 };
 30 
 31 static struct 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 };
 39 MODULE_FIRMWARE("go7007/s2250-1.fw");
 40 MODULE_FIRMWARE("go7007/s2250-2.fw");
 41 MODULE_FIRMWARE("go7007/px-m402u.fw");
 42 MODULE_FIRMWARE("go7007/px-tv402u.fw");
 43 MODULE_FIRMWARE("go7007/lr192.fw");
 44 MODULE_FIRMWARE("go7007/wis-startrek.fw");
 45 
 46 static int go7007_loader_probe(struct usb_interface *interface,
 47                                 const struct usb_device_id *id)
 48 {
 49         struct usb_device *usbdev;
 50         const struct firmware *fw;
 51         u16 vendor, product;
 52         const char *fw1, *fw2;
 53         int ret;
 54         int i;
 55 
 56         usbdev = usb_get_dev(interface_to_usbdev(interface));
 57         if (!usbdev)
 58                 goto failed2;
 59 
 60         if (usbdev->descriptor.bNumConfigurations != 1) {
 61                 dev_err(&interface->dev, "can't handle multiple config\n");
 62                 goto failed2;
 63         }
 64 
 65         vendor = le16_to_cpu(usbdev->descriptor.idVendor);
 66         product = le16_to_cpu(usbdev->descriptor.idProduct);
 67 
 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;
 72 
 73         /* Should never happen */
 74         if (fw_configs[i].fw_name1 == NULL)
 75                 goto failed2;
 76 
 77         fw1 = fw_configs[i].fw_name1;
 78         fw2 = fw_configs[i].fw_name2;
 79 
 80         dev_info(&interface->dev, "loading firmware %s\n", fw1);
 81 
 82         if (request_firmware(&fw, fw1, &usbdev->dev)) {
 83                 dev_err(&interface->dev,
 84                         "unable to load firmware from file \"%s\"\n", fw1);
 85                 goto failed2;
 86         }
 87         ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
 88         release_firmware(fw);
 89         if (0 != ret) {
 90                 dev_err(&interface->dev, "loader download failed\n");
 91                 goto failed2;
 92         }
 93 
 94         if (fw2 == NULL)
 95                 return 0;
 96 
 97         if (request_firmware(&fw, fw2, &usbdev->dev)) {
 98                 dev_err(&interface->dev,
 99                         "unable to load firmware from file \"%s\"\n", fw2);
100                 goto failed2;
101         }
102         ret = cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
103         release_firmware(fw);
104         if (0 != ret) {
105                 dev_err(&interface->dev, "firmware download failed\n");
106                 goto failed2;
107         }
108         return 0;
109 
110 failed2:
111         usb_put_dev(usbdev);
112         dev_err(&interface->dev, "probe failed\n");
113         return -ENODEV;
114 }
115 
116 static void go7007_loader_disconnect(struct usb_interface *interface)
117 {
118         dev_info(&interface->dev, "disconnect\n");
119         usb_put_dev(interface_to_usbdev(interface));
120         usb_set_intfdata(interface, NULL);
121 }
122 
123 static const struct usb_device_id go7007_loader_ids[] = {
124         { USB_DEVICE(0x1943, 0xa250) },
125         { USB_DEVICE(0x093b, 0xa002) },
126         { USB_DEVICE(0x093b, 0xa004) },
127         { USB_DEVICE(0x0eb1, 0x6666) },
128         { USB_DEVICE(0x0eb1, 0x6668) },
129         {}                          /* Terminating entry */
130 };
131 
132 MODULE_DEVICE_TABLE(usb, go7007_loader_ids);
133 
134 static struct usb_driver go7007_loader_driver = {
135         .name           = "go7007-loader",
136         .probe          = go7007_loader_probe,
137         .disconnect     = go7007_loader_disconnect,
138         .id_table       = go7007_loader_ids,
139 };
140 
141 module_usb_driver(go7007_loader_driver);
142 
143 MODULE_AUTHOR("");
144 MODULE_DESCRIPTION("firmware loader for go7007-usb");
145 MODULE_LICENSE("GPL v2");
146 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us