aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-07-01 03:35:26 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:24:03 -0400
commit1fbc3caff47785aca67b4bd5b29c04f3f20c770e (patch)
treeb38dcff717a23bba119e04397ea1acc70a083134 /drivers/media/dvb
parentb1d8f9f5b8036b61a7ec562dfb86361f5b18e8f2 (diff)
V4L/DVB (8311): sms1xxx: support device-specific firmware filenames on stellar usb1 sticks
Add the capability to define device-specific firmware filenames for the SMS1010, with a mechanism to fall back to the generic firmware if the device-specific firmware is not present. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/siano/smsusb.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c
index 9a2144c547ab..c10b1849c6a3 100644
--- a/drivers/media/dvb/siano/smsusb.c
+++ b/drivers/media/dvb/siano/smsusb.c
@@ -184,22 +184,39 @@ static char *smsusb1_fw_lkup[] = {
184 "dvbt_bda_stellar_usb.inp", 184 "dvbt_bda_stellar_usb.inp",
185}; 185};
186 186
187static int smsusb1_load_firmware(struct usb_device *udev, int id) 187static inline char *sms_get_fw_name(int mode, int board_id)
188{
189 char **fw = sms_get_board(board_id)->fw;
190 return (fw && fw[mode]) ? fw[mode] : smsusb1_fw_lkup[mode];
191}
192
193static int smsusb1_load_firmware(struct usb_device *udev, int id, int board_id)
188{ 194{
189 const struct firmware *fw; 195 const struct firmware *fw;
190 u8 *fw_buffer; 196 u8 *fw_buffer;
191 int rc, dummy; 197 int rc, dummy;
198 char *fw_filename;
192 199
193 if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) { 200 if (id < DEVICE_MODE_DVBT || id > DEVICE_MODE_DVBT_BDA) {
194 sms_err("invalid firmware id specified %d", id); 201 sms_err("invalid firmware id specified %d", id);
195 return -EINVAL; 202 return -EINVAL;
196 } 203 }
197 204
198 rc = request_firmware(&fw, smsusb1_fw_lkup[id], &udev->dev); 205 fw_filename = sms_get_fw_name(id, board_id);
206
207 rc = request_firmware(&fw, fw_filename, &udev->dev);
199 if (rc < 0) { 208 if (rc < 0) {
200 sms_err("failed to open \"%s\" mode %d", 209 sms_warn("failed to open \"%s\" mode %d, "
201 smsusb1_fw_lkup[id], id); 210 "trying again with default firmware", fw_filename, id);
202 return rc; 211
212 fw_filename = smsusb1_fw_lkup[id];
213 rc = request_firmware(&fw, fw_filename, &udev->dev);
214 if (rc < 0) {
215 sms_warn("failed to open \"%s\" mode %d",
216 fw_filename, id);
217
218 return rc;
219 }
203 } 220 }
204 221
205 fw_buffer = kmalloc(fw->size, GFP_KERNEL); 222 fw_buffer = kmalloc(fw->size, GFP_KERNEL);
@@ -216,7 +233,7 @@ static int smsusb1_load_firmware(struct usb_device *udev, int id)
216 sms_err("failed to allocate firmware buffer"); 233 sms_err("failed to allocate firmware buffer");
217 rc = -ENOMEM; 234 rc = -ENOMEM;
218 } 235 }
219 sms_info("read FW %s, size=%zd", smsusb1_fw_lkup[id], fw->size); 236 sms_info("read FW %s, size=%zd", fw_filename, fw->size);
220 237
221 release_firmware(fw); 238 release_firmware(fw);
222 239
@@ -401,7 +418,8 @@ static int smsusb_probe(struct usb_interface *intf,
401 udev->bus->busnum, udev->devpath); 418 udev->bus->busnum, udev->devpath);
402 sms_info("stellar device was found."); 419 sms_info("stellar device was found.");
403 return smsusb1_load_firmware( 420 return smsusb1_load_firmware(
404 udev, smscore_registry_getmode(devpath)); 421 udev, smscore_registry_getmode(devpath),
422 id->driver_info);
405 } 423 }
406 424
407 rc = smsusb_init_device(intf, id->driver_info); 425 rc = smsusb_init_device(intf, id->driver_info);