Commit 90060d32 authored by Mike Isely's avatar Mike Isely Committed by Mauro Carvalho Chehab

V4L/DVB (5212): Pvrusb2: Be more forgiving about encoder firmware size

The pvrusb2 driver previously rejected encoder firmware whose size was
not a multiple of 8192.  But this is a false check because it's
possible to find cx23416 firmware whose size doesn't conform to this
limit.  So change the firmware loader implementation to be more
forgiving of the image size.
Signed-off-by: default avatarMike Isely <isely@pobox.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 201779f5
...@@ -1209,7 +1209,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) ...@@ -1209,7 +1209,7 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
{ {
const struct firmware *fw_entry = NULL; const struct firmware *fw_entry = NULL;
void *fw_ptr; void *fw_ptr;
unsigned int pipe, fw_len, fw_done; unsigned int pipe, fw_len, fw_done, bcnt, icnt;
int actual_length; int actual_length;
int ret = 0; int ret = 0;
int fwidx; int fwidx;
...@@ -1265,11 +1265,11 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) ...@@ -1265,11 +1265,11 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
fw_len = fw_entry->size; fw_len = fw_entry->size;
if (fw_len % FIRMWARE_CHUNK_SIZE) { if (fw_len % sizeof(u32)) {
pvr2_trace(PVR2_TRACE_ERROR_LEGS, pvr2_trace(PVR2_TRACE_ERROR_LEGS,
"size of %s firmware" "size of %s firmware"
" must be a multiple of 8192B", " must be a multiple of %u bytes",
fw_files[fwidx]); fw_files[fwidx],sizeof(u32));
release_firmware(fw_entry); release_firmware(fw_entry);
return -1; return -1;
} }
...@@ -1284,18 +1284,21 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) ...@@ -1284,18 +1284,21 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT); pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT);
for (fw_done = 0 ; (fw_done < fw_len) && !ret ; fw_done = 0;
fw_done += FIRMWARE_CHUNK_SIZE ) { for (fw_done = 0; fw_done < fw_len;) {
int i; bcnt = fw_len - fw_done;
memcpy(fw_ptr, fw_entry->data + fw_done, FIRMWARE_CHUNK_SIZE); if (bcnt > FIRMWARE_CHUNK_SIZE) bcnt = FIRMWARE_CHUNK_SIZE;
memcpy(fw_ptr, fw_entry->data + fw_done, bcnt);
/* Usbsnoop log shows that we must swap bytes... */ /* Usbsnoop log shows that we must swap bytes... */
for (i = 0; i < FIRMWARE_CHUNK_SIZE/4 ; i++) for (icnt = 0; icnt < bcnt/4 ; icnt++)
((u32 *)fw_ptr)[i] = ___swab32(((u32 *)fw_ptr)[i]); ((u32 *)fw_ptr)[icnt] =
___swab32(((u32 *)fw_ptr)[icnt]);
ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr, ret |= usb_bulk_msg(hdw->usb_dev, pipe, fw_ptr,bcnt,
FIRMWARE_CHUNK_SIZE,
&actual_length, HZ); &actual_length, HZ);
ret |= (actual_length != FIRMWARE_CHUNK_SIZE); ret |= (actual_length != bcnt);
if (ret) break;
fw_done += bcnt;
} }
trace_firmware("upload of %s : %i / %i ", trace_firmware("upload of %s : %i / %i ",
......
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