summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2006-02-25 21:57:42 -0600
committerMike Isely <isely@pobox.com>2006-02-25 21:57:42 -0600
commitbecf9b027438240f4e8dde0de7c04c38cd68e489 (patch)
treec03844cd8b2348440150d77575918409e32f4260
parentcda6f34be9282b1ff7bd7651998479a4e60e194a (diff)
downloadmediapointer-dvb-s2-becf9b027438240f4e8dde0de7c04c38cd68e489.tar.gz
mediapointer-dvb-s2-becf9b027438240f4e8dde0de7c04c38cd68e489.tar.bz2
Change firmware file names in pvrusb2 to conform to v4l standards
From: Mike Isely <isely@pobox.com> Signed-off-by: Mike Isely <isely@pobox.com>
-rw-r--r--v4l_experimental/pvrusb2/pvrusb2-hdw.c139
1 files changed, 93 insertions, 46 deletions
diff --git a/v4l_experimental/pvrusb2/pvrusb2-hdw.c b/v4l_experimental/pvrusb2/pvrusb2-hdw.c
index a2620e421..c88da5417 100644
--- a/v4l_experimental/pvrusb2/pvrusb2-hdw.c
+++ b/v4l_experimental/pvrusb2/pvrusb2-hdw.c
@@ -70,10 +70,6 @@ MODULE_PARM_DESC(tolerance,"specify stream error tolerance");
/* size of a firmware chunk */
#define FIRMWARE_CHUNK_SIZE 0x2000
-/* Various files we will load with firmware_entry */
-#define FIRMWARE1_FILE "pvrusb2.f1"
-#define FIRMWARE2_FILE "pvrusb2.f2"
-
typedef int (*pvr2_ctl_set_func)(struct pvr2_hdw *,int ctl_id,int val);
typedef int (*pvr2_ctl_get_func)(struct pvr2_hdw *,int ctl_id);
@@ -421,6 +417,63 @@ int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
}
+/* Attempt to locate one of the given set of files. Messages are logged
+ appropriate to what has been found. The return value will be 0 or
+ greater on success (it will be the index of the file name found) and
+ fw_entry will be filled in. Otherwise a negative error is returned on
+ failure. If the return value is -ENOENT then no viable firmware file
+ could be located. */
+static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
+ const struct firmware **fw_entry,
+ const char *fwtypename,
+ unsigned int fwcount,
+ const char *fwnames[])
+{
+ unsigned int idx;
+ int ret = -EINVAL;
+ for (idx = 0; idx < fwcount; idx++) {
+ ret = request_firmware(fw_entry,
+ fwnames[idx],
+ &hdw->usb_dev->dev);
+ if (!ret) {
+ trace_firmware("Located %s firmware: %s;"
+ " uploading...",
+ fwtypename,
+ fwnames[idx]);
+ return idx;
+ }
+ if (ret == -ENOENT) continue;
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware fatal error with code=%d",ret);
+ return ret;
+ }
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "***WARNING***"
+ " Device %s firmware"
+ " seems to be missing.",
+ fwtypename);
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Did you install the pvrusb2 firmware files"
+ " in their proper location?");
+ if (fwcount == 1) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware unable to locate %s file %s",
+ fwtypename,fwnames[0]);
+ } else {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware unable to locate"
+ " one of the following %s files:",
+ fwtypename);
+ for (idx = 0; idx < fwcount; idx++) {
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "request_firmware: Failed to find %s",
+ fwnames[idx]);
+ }
+ }
+ return ret;
+}
+
+
/*
* pvr2_upload_firmware1().
*
@@ -438,27 +491,26 @@ int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
unsigned int pipe;
int ret;
u16 address;
- const char *firmware_file = FIRMWARE1_FILE;
+ static const char *fw_files[] = {
+ "v4l-fx2-pvrusb2.fw",
+ };
hdw->fw1_state = FW1_STATE_FAILED; // default result
trace_firmware("pvr2_upload_firmware1");
+ ret = pvr2_locate_firmware(hdw,&fw_entry,"fx2 controller",
+ sizeof(fw_files)/sizeof(fw_files[0]),
+ fw_files);
+ if (ret < 0) {
+ if (ret == -ENOENT) hdw->fw1_state = FW1_STATE_MISSING;
+ return ret;
+ }
+
usb_settoggle(hdw->usb_dev, 0 & 0xf, !(0 & USB_DIR_IN), 0);
usb_clear_halt(hdw->usb_dev, usb_sndbulkpipe(hdw->usb_dev, 0 & 0x7f));
pipe = usb_sndctrlpipe(hdw->usb_dev, 0);
- ret = request_firmware(&fw_entry, firmware_file, &hdw->usb_dev->dev);
-
- if (ret) {
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "request_firmware failed for '%s' code=%d",
- firmware_file,ret);
- if (ret == -ENOENT) {
- hdw->fw1_state = FW1_STATE_MISSING;
- }
- return ret;
- }
if (fw_entry->size != 0x2000){
pvr2_trace(PVR2_TRACE_ERROR_LEGS,"wrong fx2 firmware size");
@@ -519,9 +571,20 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
unsigned int pipe, fw_len, fw_done;
int actual_length;
int ret = 0;
+ int fwidx;
+ static const char *fw_files[] = {
+ "v4l-cx2341x-enc.fw",
+ };
trace_firmware("pvr2_upload_firmware2");
+ ret = pvr2_locate_firmware(hdw,&fw_entry,"encoder",
+ sizeof(fw_files)/sizeof(fw_files[0]),
+ fw_files);
+ if (ret < 0) return ret;
+ fwidx = ret;
+ ret = 0;
+
/* First prepare firmware loading */
ret |= pvr2_hdw_cmd_soft_reset(hdw);
ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/
@@ -546,34 +609,19 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
if (ret) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"firmware2 upload prep failed, ret=%d",ret);
+ release_firmware(fw_entry);
return ret;
}
/* Now send firmware */
- ret = request_firmware(&fw_entry, FIRMWARE2_FILE, &hdw->usb_dev->dev);
-
- if (ret) {
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "request_firmware failed for '%s'", FIRMWARE2_FILE);
- if (ret == -ENOENT) {
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "***WARNING***"
- " Device encoder firmware"
- " seems to be missing.");
- pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "Did you install the pvrusb2 firmware files"
- " in their proper location?");
- }
- return ret;
- }
-
fw_len = fw_entry->size;
if (fw_len % FIRMWARE_CHUNK_SIZE) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS,
- "size of %s must be a multiple of 8192B",
- FIRMWARE2_FILE);
+ "size of %s firmware"
+ " must be a multiple of 8192B",
+ fw_files[fwidx]);
release_firmware(fw_entry);
return -1;
}
@@ -603,7 +651,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
}
trace_firmware("upload of %s : %i / %i ",
- FIRMWARE2_FILE,fw_done,fw_len);
+ fw_files[fwidx],fw_done,fw_len);
kfree(fw_ptr);
release_firmware(fw_entry);
@@ -1068,21 +1116,17 @@ int pvr2_hdw_setup(struct pvr2_hdw *hdw)
" and reconnect.");
break;
}
+ pvr2_trace(
+ PVR2_TRACE_ERROR_LEGS,
+ "Device initialization was not successful.");
if (hdw->fw1_state == FW1_STATE_MISSING) {
pvr2_trace(
PVR2_TRACE_ERROR_LEGS,
- "***WARNING***"
- " Device microcontroller firmware"
- " seems to be missing.");
- pvr2_trace(
- PVR2_TRACE_ERROR_LEGS,
- "Did you install the pvrusb2 firmware"
- " files in their proper location?");
+ "Giving up since device"
+ " microcontroller firmware"
+ " appears to be missing.");
break;
}
- pvr2_trace(
- PVR2_TRACE_ERROR_LEGS,
- "Device initialization was not successful.");
}
if (procreload) {
pvr2_trace(
@@ -1108,6 +1152,7 @@ int pvr2_hdw_setup(struct pvr2_hdw *hdw)
" in order to recover.");
}
} while (0); LOCK_GIVE(hdw->big_lock);
+ pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_setup(hdw=%p) end",hdw);
return hdw->flag_init_ok;
}
@@ -2019,6 +2064,8 @@ int pvr2_send_request(struct pvr2_hdw *hdw,
if (hdw->ctl_timeout_flag) {
status = -ETIMEDOUT;
+ pvr2_trace(PVR2_TRACE_ERROR_LEGS,
+ "Timed out control-write");
goto done;
}