提交 02aea4fb 编写于 作者: M Michael Krufky 提交者: Mauro Carvalho Chehab

V4L/DVB (8301): sms1xxx: add capability to define device-specific firmware filenames

Add the capability to define device-specific firmware filenames for the SMS1150,
with a mechanism to fall back to the generic firmware if the device-specific
firmware is not present.
Signed-off-by: NMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 2708e888
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#define SMS1XXX_BOARD_SIANO_VEGA 5 #define SMS1XXX_BOARD_SIANO_VEGA 5
struct sms_board { struct sms_board {
char *name;
enum sms_device_type_st type; enum sms_device_type_st type;
char *name, *fw[DEVICE_MODE_MAX];
}; };
struct sms_board *sms_get_board(int id); struct sms_board *sms_get_board(int id);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/firmware.h> #include <linux/firmware.h>
#include "smscoreapi.h" #include "smscoreapi.h"
#include "sms-cards.h"
int sms_debug; int sms_debug;
module_param_named(debug, sms_debug, int, 0644); module_param_named(debug, sms_debug, int, 0644);
...@@ -600,7 +601,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev, ...@@ -600,7 +601,7 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
sms_info("failed to open \"%s\"", filename); sms_info("failed to open \"%s\"", filename);
return rc; return rc;
} }
sms_info("read FW %s, size=%d\"", filename, fw->size); sms_info("read FW %s, size=%d", filename, fw->size);
fw_buffer = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT), fw_buffer = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
GFP_KERNEL | GFP_DMA); GFP_KERNEL | GFP_DMA);
if (fw_buffer) { if (fw_buffer) {
...@@ -736,6 +737,12 @@ static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = { ...@@ -736,6 +737,12 @@ static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
{"none", "none", "none", "cmmb_vega_12mhz.inp"} {"none", "none", "none", "cmmb_vega_12mhz.inp"}
}; };
static inline char *sms_get_fw_name(struct smscore_device_t *coredev,
int mode, enum sms_device_type_st type)
{
char **fw = sms_get_board(smscore_get_board_id(coredev))->fw;
return (fw && fw[mode]) ? fw[mode] : smscore_fw_lkup[mode][type];
}
/** /**
* calls device handler to change mode of operation * calls device handler to change mode of operation
...@@ -776,12 +783,26 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode) ...@@ -776,12 +783,26 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
} }
if (!(coredev->modes_supported & (1 << mode))) { if (!(coredev->modes_supported & (1 << mode))) {
char *fw_filename;
type = smscore_registry_gettype(coredev->devpath); type = smscore_registry_gettype(coredev->devpath);
rc = smscore_load_firmware_from_file( fw_filename = sms_get_fw_name(coredev, mode, type);
coredev, smscore_fw_lkup[mode][type], NULL);
rc = smscore_load_firmware_from_file(coredev,
fw_filename, NULL);
if (rc < 0) { if (rc < 0) {
sms_err("load firmware failed %d", rc); sms_err("error %d loading firmware: %s, "
return rc; "trying again with default firmware",
rc, fw_filename);
/* try again with the default firmware */
rc = smscore_load_firmware_from_file(coredev,
smscore_fw_lkup[mode][type], NULL);
if (rc < 0) {
sms_err("load firmware failed %d", rc);
return rc;
}
} }
} else } else
sms_info("mode %d supported by running " sms_info("mode %d supported by running "
......
...@@ -216,6 +216,7 @@ static int smsusb1_load_firmware(struct usb_device *udev, int id) ...@@ -216,6 +216,7 @@ static int smsusb1_load_firmware(struct usb_device *udev, int id)
sms_err("failed to allocate firmware buffer"); sms_err("failed to allocate firmware buffer");
rc = -ENOMEM; rc = -ENOMEM;
} }
sms_info("read FW %s, size=%d", smsusb1_fw_lkup[id], fw->size);
release_firmware(fw); release_firmware(fw);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册