Commit 0ee3d4d5 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] go7007-loader: add support for the other devices and move fw files

Add support for the other devices that need to load the boot firmware.
All firmware files are now placed in a single go7007 directory.
Also remove the device_extension_s stuff: this is clearly a left-over from
the olden days.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e129c974
...@@ -90,7 +90,7 @@ EXPORT_SYMBOL(go7007_read_addr); ...@@ -90,7 +90,7 @@ EXPORT_SYMBOL(go7007_read_addr);
static int go7007_load_encoder(struct go7007 *go) static int go7007_load_encoder(struct go7007 *go)
{ {
const struct firmware *fw_entry; const struct firmware *fw_entry;
char fw_name[] = "go7007fw.bin"; char fw_name[] = "go7007/go7007fw.bin";
void *bounce; void *bounce;
int fw_len, rv = 0; int fw_len, rv = 0;
u16 intr_val, intr_data; u16 intr_val, intr_data;
...@@ -126,7 +126,7 @@ static int go7007_load_encoder(struct go7007 *go) ...@@ -126,7 +126,7 @@ static int go7007_load_encoder(struct go7007 *go)
return rv; return rv;
} }
MODULE_FIRMWARE("go7007fw.bin"); MODULE_FIRMWARE("go7007/go7007fw.bin");
/* /*
* Boot the encoder and register the I2C adapter if requested. Do the * Boot the encoder and register the I2C adapter if requested. Do the
......
...@@ -22,86 +22,67 @@ ...@@ -22,86 +22,67 @@
#include <linux/firmware.h> #include <linux/firmware.h>
#include <cypress_firmware.h> #include <cypress_firmware.h>
#define S2250_LOADER_FIRMWARE "s2250_loader.fw" struct fw_config {
#define S2250_FIRMWARE "2250.fw" u16 vendor;
u16 product;
typedef struct device_extension_s { const char * const fw_name1;
struct kref kref; const char * const fw_name2;
int minor; };
struct usb_device *usbdev;
} device_extension_t, *pdevice_extension_t;
#define USB_go7007_loader_MAJOR 240
#define USB_go7007_loader_MINOR_BASE 0
#define MAX_DEVICES 256
static pdevice_extension_t go7007_dev_table[MAX_DEVICES];
static DEFINE_MUTEX(go7007_dev_table_mutex);
#define to_go7007_loader_dev_common(d) container_of(d, device_extension_t, kref) struct fw_config fw_configs[] = {
static void go7007_loader_delete(struct kref *kref) { 0x1943, 0xa250, "go7007/s2250-1.fw", "go7007/s2250-2.fw" },
{ { 0x093b, 0xa002, "go7007/px-m402u.fw", NULL },
pdevice_extension_t s = to_go7007_loader_dev_common(kref); { 0x093b, 0xa004, "go7007/px-tv402u.fw", NULL },
go7007_dev_table[s->minor] = NULL; { 0x0eb1, 0x6666, "go7007/lr192.fw", NULL },
kfree(s); { 0x0eb1, 0x6668, "go7007/wis-startrek.fw", NULL },
} { 0, 0, NULL, NULL }
};
MODULE_FIRMWARE("go7007/s2250-1.fw");
MODULE_FIRMWARE("go7007/s2250-2.fw");
MODULE_FIRMWARE("go7007/px-m402u.fw");
MODULE_FIRMWARE("go7007/px-tv402u.fw");
MODULE_FIRMWARE("go7007/lr192.fw");
MODULE_FIRMWARE("go7007/wis-startrek.fw");
static int go7007_loader_probe(struct usb_interface *interface, static int go7007_loader_probe(struct usb_interface *interface,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
struct usb_device *usbdev; struct usb_device *usbdev;
int minor, ret;
pdevice_extension_t s = NULL;
const struct firmware *fw; const struct firmware *fw;
u16 vendor, product;
const char *fw1, *fw2;
int ret;
int i;
usbdev = usb_get_dev(interface_to_usbdev(interface)); usbdev = usb_get_dev(interface_to_usbdev(interface));
if (!usbdev) { if (!usbdev)
dev_err(&interface->dev, "Enter go7007_loader_probe failed\n"); goto failed2;
return -1;
}
dev_info(&interface->dev, "vendor id 0x%x, device id 0x%x devnum:%d\n",
usbdev->descriptor.idVendor, usbdev->descriptor.idProduct,
usbdev->devnum);
if (usbdev->descriptor.bNumConfigurations != 1) { if (usbdev->descriptor.bNumConfigurations != 1) {
dev_err(&interface->dev, "can't handle multiple config\n"); dev_err(&interface->dev, "can't handle multiple config\n");
return -1; return -ENODEV;
}
mutex_lock(&go7007_dev_table_mutex);
for (minor = 0; minor < MAX_DEVICES; minor++) {
if (go7007_dev_table[minor] == NULL)
break;
} }
if (minor < 0 || minor >= MAX_DEVICES) { vendor = le16_to_cpu(usbdev->descriptor.idVendor);
dev_err(&interface->dev, "Invalid minor: %d\n", minor); product = le16_to_cpu(usbdev->descriptor.idProduct);
goto failed;
}
/* Allocate dev data structure */
s = kmalloc(sizeof(device_extension_t), GFP_KERNEL);
if (s == NULL)
goto failed;
go7007_dev_table[minor] = s;
dev_info(&interface->dev, for (i = 0; fw_configs[i].fw_name1; i++)
"Device %d on Bus %d Minor %d\n", if (fw_configs[i].vendor == vendor &&
usbdev->devnum, usbdev->bus->busnum, minor); fw_configs[i].product == product)
break;
memset(s, 0, sizeof(device_extension_t)); /* Should never happen */
s->usbdev = usbdev; if (fw_configs[i].fw_name1 == NULL)
dev_info(&interface->dev, "loading go7007-loader\n"); goto failed2;
kref_init(&(s->kref)); fw1 = fw_configs[i].fw_name1;
fw2 = fw_configs[i].fw_name2;
mutex_unlock(&go7007_dev_table_mutex); dev_info(&interface->dev, "loading firmware %s\n", fw1);
if (request_firmware(&fw, S2250_LOADER_FIRMWARE, &usbdev->dev)) { if (request_firmware(&fw, fw1, &usbdev->dev)) {
dev_err(&interface->dev, dev_err(&interface->dev,
"unable to load firmware from file \"%s\"\n", "unable to load firmware from file \"%s\"\n", fw1);
S2250_LOADER_FIRMWARE);
goto failed2; goto failed2;
} }
ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2); ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
...@@ -111,10 +92,12 @@ static int go7007_loader_probe(struct usb_interface *interface, ...@@ -111,10 +92,12 @@ static int go7007_loader_probe(struct usb_interface *interface,
goto failed2; goto failed2;
} }
if (request_firmware(&fw, S2250_FIRMWARE, &usbdev->dev)) { if (fw2 == NULL)
return 0;
if (request_firmware(&fw, fw2, &usbdev->dev)) {
dev_err(&interface->dev, dev_err(&interface->dev,
"unable to load firmware from file \"%s\"\n", "unable to load firmware from file \"%s\"\n", fw2);
S2250_FIRMWARE);
goto failed2; goto failed2;
} }
ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2); ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2);
...@@ -123,31 +106,25 @@ static int go7007_loader_probe(struct usb_interface *interface, ...@@ -123,31 +106,25 @@ static int go7007_loader_probe(struct usb_interface *interface,
dev_err(&interface->dev, "firmware download failed\n"); dev_err(&interface->dev, "firmware download failed\n");
goto failed2; goto failed2;
} }
usb_set_intfdata(interface, s);
return 0; return 0;
failed:
mutex_unlock(&go7007_dev_table_mutex);
failed2: failed2:
if (s)
kref_put(&(s->kref), go7007_loader_delete);
dev_err(&interface->dev, "probe failed\n"); dev_err(&interface->dev, "probe failed\n");
return -1; return -ENODEV;
} }
static void go7007_loader_disconnect(struct usb_interface *interface) static void go7007_loader_disconnect(struct usb_interface *interface)
{ {
pdevice_extension_t s;
dev_info(&interface->dev, "disconnect\n"); dev_info(&interface->dev, "disconnect\n");
s = usb_get_intfdata(interface);
usb_set_intfdata(interface, NULL); usb_set_intfdata(interface, NULL);
kref_put(&(s->kref), go7007_loader_delete);
} }
static const struct usb_device_id go7007_loader_ids[] = { static const struct usb_device_id go7007_loader_ids[] = {
{USB_DEVICE(0x1943, 0xa250)}, { USB_DEVICE(0x1943, 0xa250) },
{ USB_DEVICE(0x093b, 0xa002) },
{ USB_DEVICE(0x093b, 0xa004) },
{ USB_DEVICE(0x0eb1, 0x6666) },
{ USB_DEVICE(0x0eb1, 0x6668) },
{} /* Terminating entry */ {} /* Terminating entry */
}; };
...@@ -163,7 +140,5 @@ static struct usb_driver go7007_loader_driver = { ...@@ -163,7 +140,5 @@ static struct usb_driver go7007_loader_driver = {
module_usb_driver(go7007_loader_driver); module_usb_driver(go7007_loader_driver);
MODULE_AUTHOR(""); MODULE_AUTHOR("");
MODULE_DESCRIPTION("firmware loader for go7007 USB devices"); MODULE_DESCRIPTION("firmware loader for go7007-usb");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_FIRMWARE(S2250_LOADER_FIRMWARE);
MODULE_FIRMWARE(S2250_FIRMWARE);
...@@ -76,7 +76,7 @@ struct go7007_usb { ...@@ -76,7 +76,7 @@ struct go7007_usb {
static struct go7007_usb_board board_matrix_ii = { static struct go7007_usb_board board_matrix_ii = {
.flags = GO7007_USB_EZUSB, .flags = GO7007_USB_EZUSB,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_HAS_AUDIO | .flags = GO7007_BOARD_HAS_AUDIO |
GO7007_BOARD_USE_ONBOARD_I2C, GO7007_BOARD_USE_ONBOARD_I2C,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 | .audio_flags = GO7007_AUDIO_I2S_MODE_1 |
...@@ -117,7 +117,7 @@ static struct go7007_usb_board board_matrix_ii = { ...@@ -117,7 +117,7 @@ static struct go7007_usb_board board_matrix_ii = {
static struct go7007_usb_board board_matrix_reload = { static struct go7007_usb_board board_matrix_reload = {
.flags = GO7007_USB_EZUSB, .flags = GO7007_USB_EZUSB,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_HAS_AUDIO | .flags = GO7007_BOARD_HAS_AUDIO |
GO7007_BOARD_USE_ONBOARD_I2C, GO7007_BOARD_USE_ONBOARD_I2C,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 | .audio_flags = GO7007_AUDIO_I2S_MODE_1 |
...@@ -155,7 +155,7 @@ static struct go7007_usb_board board_matrix_reload = { ...@@ -155,7 +155,7 @@ static struct go7007_usb_board board_matrix_reload = {
static struct go7007_usb_board board_star_trek = { static struct go7007_usb_board board_star_trek = {
.flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C, .flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_HAS_AUDIO, /* | .flags = GO7007_BOARD_HAS_AUDIO, /* |
GO7007_BOARD_HAS_TUNER, */ GO7007_BOARD_HAS_TUNER, */
.sensor_flags = GO7007_SENSOR_656 | .sensor_flags = GO7007_SENSOR_656 |
...@@ -203,7 +203,7 @@ static struct go7007_usb_board board_star_trek = { ...@@ -203,7 +203,7 @@ static struct go7007_usb_board board_star_trek = {
static struct go7007_usb_board board_px_tv402u = { static struct go7007_usb_board board_px_tv402u = {
.flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C, .flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_HAS_AUDIO | .flags = GO7007_BOARD_HAS_AUDIO |
GO7007_BOARD_HAS_TUNER, GO7007_BOARD_HAS_TUNER,
.sensor_flags = GO7007_SENSOR_656 | .sensor_flags = GO7007_SENSOR_656 |
...@@ -278,7 +278,7 @@ static struct go7007_usb_board board_px_tv402u = { ...@@ -278,7 +278,7 @@ static struct go7007_usb_board board_px_tv402u = {
static struct go7007_usb_board board_xmen = { static struct go7007_usb_board board_xmen = {
.flags = 0, .flags = 0,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_USE_ONBOARD_I2C, .flags = GO7007_BOARD_USE_ONBOARD_I2C,
.hpi_buffer_cap = 0, .hpi_buffer_cap = 0,
.sensor_flags = GO7007_SENSOR_VREF_POLAR, .sensor_flags = GO7007_SENSOR_VREF_POLAR,
...@@ -313,7 +313,7 @@ static struct go7007_usb_board board_xmen = { ...@@ -313,7 +313,7 @@ static struct go7007_usb_board board_xmen = {
static struct go7007_usb_board board_matrix_revolution = { static struct go7007_usb_board board_matrix_revolution = {
.flags = GO7007_USB_EZUSB, .flags = GO7007_USB_EZUSB,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_HAS_AUDIO | .flags = GO7007_BOARD_HAS_AUDIO |
GO7007_BOARD_USE_ONBOARD_I2C, GO7007_BOARD_USE_ONBOARD_I2C,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 | .audio_flags = GO7007_AUDIO_I2S_MODE_1 |
...@@ -351,7 +351,7 @@ static struct go7007_usb_board board_matrix_revolution = { ...@@ -351,7 +351,7 @@ static struct go7007_usb_board board_matrix_revolution = {
static struct go7007_usb_board board_lifeview_lr192 = { static struct go7007_usb_board board_lifeview_lr192 = {
.flags = GO7007_USB_EZUSB, .flags = GO7007_USB_EZUSB,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_HAS_AUDIO | .flags = GO7007_BOARD_HAS_AUDIO |
GO7007_BOARD_USE_ONBOARD_I2C, GO7007_BOARD_USE_ONBOARD_I2C,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 | .audio_flags = GO7007_AUDIO_I2S_MODE_1 |
...@@ -379,7 +379,7 @@ static struct go7007_usb_board board_lifeview_lr192 = { ...@@ -379,7 +379,7 @@ static struct go7007_usb_board board_lifeview_lr192 = {
static struct go7007_usb_board board_endura = { static struct go7007_usb_board board_endura = {
.flags = 0, .flags = 0,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = 0, .flags = 0,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 | .audio_flags = GO7007_AUDIO_I2S_MODE_1 |
GO7007_AUDIO_I2S_MASTER | GO7007_AUDIO_I2S_MASTER |
...@@ -404,7 +404,7 @@ static struct go7007_usb_board board_endura = { ...@@ -404,7 +404,7 @@ static struct go7007_usb_board board_endura = {
static struct go7007_usb_board board_adlink_mpg24 = { static struct go7007_usb_board board_adlink_mpg24 = {
.flags = 0, .flags = 0,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = GO7007_BOARD_USE_ONBOARD_I2C, .flags = GO7007_BOARD_USE_ONBOARD_I2C,
.audio_flags = GO7007_AUDIO_I2S_MODE_1 | .audio_flags = GO7007_AUDIO_I2S_MODE_1 |
GO7007_AUDIO_I2S_MASTER | GO7007_AUDIO_I2S_MASTER |
...@@ -437,7 +437,7 @@ static struct go7007_usb_board board_adlink_mpg24 = { ...@@ -437,7 +437,7 @@ static struct go7007_usb_board board_adlink_mpg24 = {
static struct go7007_usb_board board_sensoray_2250 = { static struct go7007_usb_board board_sensoray_2250 = {
.flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C, .flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C,
.main_info = { .main_info = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.audio_flags = GO7007_AUDIO_I2S_MODE_1 | .audio_flags = GO7007_AUDIO_I2S_MODE_1 |
GO7007_AUDIO_I2S_MASTER | GO7007_AUDIO_I2S_MASTER |
GO7007_AUDIO_WORD_16, GO7007_AUDIO_WORD_16,
...@@ -486,7 +486,7 @@ static struct go7007_usb_board board_sensoray_2250 = { ...@@ -486,7 +486,7 @@ static struct go7007_usb_board board_sensoray_2250 = {
}, },
}; };
MODULE_FIRMWARE("go7007tv.bin"); MODULE_FIRMWARE("go7007/go7007tv.bin");
static const struct usb_device_id go7007_usb_id_table[] = { static const struct usb_device_id go7007_usb_id_table[] = {
{ {
......
...@@ -65,7 +65,7 @@ struct saa7134_go7007 { ...@@ -65,7 +65,7 @@ struct saa7134_go7007 {
}; };
static struct go7007_board_info board_voyager = { static struct go7007_board_info board_voyager = {
.firmware = "go7007tv.bin", .firmware = "go7007/go7007tv.bin",
.flags = 0, .flags = 0,
.sensor_flags = GO7007_SENSOR_656 | .sensor_flags = GO7007_SENSOR_656 |
GO7007_SENSOR_VALID_ENABLE | GO7007_SENSOR_VALID_ENABLE |
...@@ -430,6 +430,7 @@ static struct go7007_hpi_ops saa7134_go7007_hpi_ops = { ...@@ -430,6 +430,7 @@ static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
.send_firmware = saa7134_go7007_send_firmware, .send_firmware = saa7134_go7007_send_firmware,
.send_command = saa7134_go7007_send_command, .send_command = saa7134_go7007_send_command,
}; };
MODULE_FIRMWARE("go7007/go7007tv.bin");
/********************* Add/remove functions *********************/ /********************* Add/remove functions *********************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment