From 0ee3d4d53e4e170e9a9a70214de54b9f5d18d30c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 11 Mar 2013 06:45:14 -0300 Subject: [PATCH] [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: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/go7007/go7007-driver.c | 4 +- drivers/staging/media/go7007/go7007-loader.c | 131 +++++++----------- drivers/staging/media/go7007/go7007-usb.c | 22 +-- drivers/staging/media/go7007/saa7134-go7007.c | 3 +- 4 files changed, 68 insertions(+), 92 deletions(-) diff --git a/drivers/staging/media/go7007/go7007-driver.c b/drivers/staging/media/go7007/go7007-driver.c index 0fd3f108be12..4378223d8bb8 100644 --- a/drivers/staging/media/go7007/go7007-driver.c +++ b/drivers/staging/media/go7007/go7007-driver.c @@ -90,7 +90,7 @@ EXPORT_SYMBOL(go7007_read_addr); static int go7007_load_encoder(struct go7007 *go) { const struct firmware *fw_entry; - char fw_name[] = "go7007fw.bin"; + char fw_name[] = "go7007/go7007fw.bin"; void *bounce; int fw_len, rv = 0; u16 intr_val, intr_data; @@ -126,7 +126,7 @@ static int go7007_load_encoder(struct go7007 *go) return rv; } -MODULE_FIRMWARE("go7007fw.bin"); +MODULE_FIRMWARE("go7007/go7007fw.bin"); /* * Boot the encoder and register the I2C adapter if requested. Do the diff --git a/drivers/staging/media/go7007/go7007-loader.c b/drivers/staging/media/go7007/go7007-loader.c index 730a4f8a3e07..4ce53d6e8528 100644 --- a/drivers/staging/media/go7007/go7007-loader.c +++ b/drivers/staging/media/go7007/go7007-loader.c @@ -22,86 +22,67 @@ #include #include -#define S2250_LOADER_FIRMWARE "s2250_loader.fw" -#define S2250_FIRMWARE "2250.fw" - -typedef struct device_extension_s { - struct kref kref; - 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); +struct fw_config { + u16 vendor; + u16 product; + const char * const fw_name1; + const char * const fw_name2; +}; -#define to_go7007_loader_dev_common(d) container_of(d, device_extension_t, kref) -static void go7007_loader_delete(struct kref *kref) -{ - pdevice_extension_t s = to_go7007_loader_dev_common(kref); - go7007_dev_table[s->minor] = NULL; - kfree(s); -} +struct fw_config fw_configs[] = { + { 0x1943, 0xa250, "go7007/s2250-1.fw", "go7007/s2250-2.fw" }, + { 0x093b, 0xa002, "go7007/px-m402u.fw", NULL }, + { 0x093b, 0xa004, "go7007/px-tv402u.fw", NULL }, + { 0x0eb1, 0x6666, "go7007/lr192.fw", NULL }, + { 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, const struct usb_device_id *id) { struct usb_device *usbdev; - int minor, ret; - pdevice_extension_t s = NULL; const struct firmware *fw; + u16 vendor, product; + const char *fw1, *fw2; + int ret; + int i; usbdev = usb_get_dev(interface_to_usbdev(interface)); - if (!usbdev) { - dev_err(&interface->dev, "Enter go7007_loader_probe failed\n"); - 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) + goto failed2; if (usbdev->descriptor.bNumConfigurations != 1) { dev_err(&interface->dev, "can't handle multiple config\n"); - return -1; - } - mutex_lock(&go7007_dev_table_mutex); - - for (minor = 0; minor < MAX_DEVICES; minor++) { - if (go7007_dev_table[minor] == NULL) - break; + return -ENODEV; } - if (minor < 0 || minor >= MAX_DEVICES) { - dev_err(&interface->dev, "Invalid minor: %d\n", minor); - goto failed; - } - - /* Allocate dev data structure */ - s = kmalloc(sizeof(device_extension_t), GFP_KERNEL); - if (s == NULL) - goto failed; - - go7007_dev_table[minor] = s; + vendor = le16_to_cpu(usbdev->descriptor.idVendor); + product = le16_to_cpu(usbdev->descriptor.idProduct); - dev_info(&interface->dev, - "Device %d on Bus %d Minor %d\n", - usbdev->devnum, usbdev->bus->busnum, minor); + for (i = 0; fw_configs[i].fw_name1; i++) + if (fw_configs[i].vendor == vendor && + fw_configs[i].product == product) + break; - memset(s, 0, sizeof(device_extension_t)); - s->usbdev = usbdev; - dev_info(&interface->dev, "loading go7007-loader\n"); + /* Should never happen */ + if (fw_configs[i].fw_name1 == NULL) + 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, - "unable to load firmware from file \"%s\"\n", - S2250_LOADER_FIRMWARE); + "unable to load firmware from file \"%s\"\n", fw1); goto failed2; } ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2); @@ -111,10 +92,12 @@ static int go7007_loader_probe(struct usb_interface *interface, 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, - "unable to load firmware from file \"%s\"\n", - S2250_FIRMWARE); + "unable to load firmware from file \"%s\"\n", fw2); goto failed2; } ret = usbv2_cypress_load_firmware(usbdev, fw, CYPRESS_FX2); @@ -123,31 +106,25 @@ static int go7007_loader_probe(struct usb_interface *interface, dev_err(&interface->dev, "firmware download failed\n"); goto failed2; } - - usb_set_intfdata(interface, s); return 0; -failed: - mutex_unlock(&go7007_dev_table_mutex); failed2: - if (s) - kref_put(&(s->kref), go7007_loader_delete); - dev_err(&interface->dev, "probe failed\n"); - return -1; + return -ENODEV; } static void go7007_loader_disconnect(struct usb_interface *interface) { - pdevice_extension_t s; dev_info(&interface->dev, "disconnect\n"); - s = usb_get_intfdata(interface); usb_set_intfdata(interface, NULL); - kref_put(&(s->kref), go7007_loader_delete); } 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 */ }; @@ -163,7 +140,5 @@ static struct usb_driver go7007_loader_driver = { module_usb_driver(go7007_loader_driver); MODULE_AUTHOR(""); -MODULE_DESCRIPTION("firmware loader for go7007 USB devices"); +MODULE_DESCRIPTION("firmware loader for go7007-usb"); MODULE_LICENSE("GPL v2"); -MODULE_FIRMWARE(S2250_LOADER_FIRMWARE); -MODULE_FIRMWARE(S2250_FIRMWARE); diff --git a/drivers/staging/media/go7007/go7007-usb.c b/drivers/staging/media/go7007/go7007-usb.c index 2a1cda22118d..bd23d7d3e067 100644 --- a/drivers/staging/media/go7007/go7007-usb.c +++ b/drivers/staging/media/go7007/go7007-usb.c @@ -76,7 +76,7 @@ struct go7007_usb { static struct go7007_usb_board board_matrix_ii = { .flags = GO7007_USB_EZUSB, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_HAS_AUDIO | GO7007_BOARD_USE_ONBOARD_I2C, .audio_flags = GO7007_AUDIO_I2S_MODE_1 | @@ -117,7 +117,7 @@ static struct go7007_usb_board board_matrix_ii = { static struct go7007_usb_board board_matrix_reload = { .flags = GO7007_USB_EZUSB, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_HAS_AUDIO | GO7007_BOARD_USE_ONBOARD_I2C, .audio_flags = GO7007_AUDIO_I2S_MODE_1 | @@ -155,7 +155,7 @@ static struct go7007_usb_board board_matrix_reload = { static struct go7007_usb_board board_star_trek = { .flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_HAS_AUDIO, /* | GO7007_BOARD_HAS_TUNER, */ .sensor_flags = GO7007_SENSOR_656 | @@ -203,7 +203,7 @@ static struct go7007_usb_board board_star_trek = { static struct go7007_usb_board board_px_tv402u = { .flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_HAS_AUDIO | GO7007_BOARD_HAS_TUNER, .sensor_flags = GO7007_SENSOR_656 | @@ -278,7 +278,7 @@ static struct go7007_usb_board board_px_tv402u = { static struct go7007_usb_board board_xmen = { .flags = 0, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_USE_ONBOARD_I2C, .hpi_buffer_cap = 0, .sensor_flags = GO7007_SENSOR_VREF_POLAR, @@ -313,7 +313,7 @@ static struct go7007_usb_board board_xmen = { static struct go7007_usb_board board_matrix_revolution = { .flags = GO7007_USB_EZUSB, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_HAS_AUDIO | GO7007_BOARD_USE_ONBOARD_I2C, .audio_flags = GO7007_AUDIO_I2S_MODE_1 | @@ -351,7 +351,7 @@ static struct go7007_usb_board board_matrix_revolution = { static struct go7007_usb_board board_lifeview_lr192 = { .flags = GO7007_USB_EZUSB, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_HAS_AUDIO | GO7007_BOARD_USE_ONBOARD_I2C, .audio_flags = GO7007_AUDIO_I2S_MODE_1 | @@ -379,7 +379,7 @@ static struct go7007_usb_board board_lifeview_lr192 = { static struct go7007_usb_board board_endura = { .flags = 0, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = 0, .audio_flags = GO7007_AUDIO_I2S_MODE_1 | GO7007_AUDIO_I2S_MASTER | @@ -404,7 +404,7 @@ static struct go7007_usb_board board_endura = { static struct go7007_usb_board board_adlink_mpg24 = { .flags = 0, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = GO7007_BOARD_USE_ONBOARD_I2C, .audio_flags = GO7007_AUDIO_I2S_MODE_1 | GO7007_AUDIO_I2S_MASTER | @@ -437,7 +437,7 @@ static struct go7007_usb_board board_adlink_mpg24 = { static struct go7007_usb_board board_sensoray_2250 = { .flags = GO7007_USB_EZUSB | GO7007_USB_EZUSB_I2C, .main_info = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .audio_flags = GO7007_AUDIO_I2S_MODE_1 | GO7007_AUDIO_I2S_MASTER | GO7007_AUDIO_WORD_16, @@ -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[] = { { diff --git a/drivers/staging/media/go7007/saa7134-go7007.c b/drivers/staging/media/go7007/saa7134-go7007.c index 752f1bd6b5a1..d56f4fc44a93 100644 --- a/drivers/staging/media/go7007/saa7134-go7007.c +++ b/drivers/staging/media/go7007/saa7134-go7007.c @@ -65,7 +65,7 @@ struct saa7134_go7007 { }; static struct go7007_board_info board_voyager = { - .firmware = "go7007tv.bin", + .firmware = "go7007/go7007tv.bin", .flags = 0, .sensor_flags = GO7007_SENSOR_656 | GO7007_SENSOR_VALID_ENABLE | @@ -430,6 +430,7 @@ static struct go7007_hpi_ops saa7134_go7007_hpi_ops = { .send_firmware = saa7134_go7007_send_firmware, .send_command = saa7134_go7007_send_command, }; +MODULE_FIRMWARE("go7007/go7007tv.bin"); /********************* Add/remove functions *********************/ -- 2.20.1