summaryrefslogtreecommitdiff
path: root/v4l2-apps/util
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-12-31 11:12:50 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-12-31 11:12:50 -0200
commitda37b1fc270b1ec30e5b91f3d669d6b2162fa935 (patch)
treea94656e999655521e8d82eab174a1d53c77a394b /v4l2-apps/util
parentb147ad1360afb6524fb2639d6cf5e5f1e151675b (diff)
downloadmediapointer-dvb-s2-da37b1fc270b1ec30e5b91f3d669d6b2162fa935.tar.gz
mediapointer-dvb-s2-da37b1fc270b1ec30e5b91f3d669d6b2162fa935.tar.bz2
Improve method 1
From: Mauro Carvalho Chehab <mchehab@infradead.org> Xceive firmwares seem to use Big Endian for encoding size, delay and reset. Kernel drivers uses Little Endian. Before this patch, method 1 were fixing endian only for size. This patch changes the behavior to change endian also for delay and reset. With this change, with HVR12x0 file, method (1) works for all firmwares. This produces a very optimized script. The seek method is known to work with firmwares version 2.7 and 2.5. However, drivers with firmware version 1.x have a different internal format. So, another seek method will be required to allow the script to work on those firmwares. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/util')
-rw-r--r--v4l2-apps/util/xc3028-firmware/extract_head.h11
-rw-r--r--v4l2-apps/util/xc3028-firmware/firmware-tool.c37
2 files changed, 22 insertions, 26 deletions
diff --git a/v4l2-apps/util/xc3028-firmware/extract_head.h b/v4l2-apps/util/xc3028-firmware/extract_head.h
index 9ca83377b..0bc0d19f9 100644
--- a/v4l2-apps/util/xc3028-firmware/extract_head.h
+++ b/v4l2-apps/util/xc3028-firmware/extract_head.h
@@ -83,7 +83,6 @@ char *extract_header = "#!/usr/bin/perl\n"
" my $out = get_hunk($offset, $length);\n"
"\n"
" printf \"(len %d) \",$length if ($debug);\n"
-// " write_le16($length);\n"
"\n"
" for (my $i=0;$i<$length;$i++) {\n"
" printf \"%02x \",ord(substr($out,$i,1)) if ($debug);\n"
@@ -99,8 +98,6 @@ char *extract_header = "#!/usr/bin/perl\n"
" my $out = get_hunk($offset, $length);\n"
"\n"
" printf \"(len_fix %d) \",$length if ($debug);\n"
-//"syswrite(OUTFILE, \"0123456789ABCDEF\");\n"
-// " write_le16($length);\n"
"\n"
" for (my $i=0;$i<$length;$i++) {\n"
" printf \"%02x \",ord(substr($out,$i,1)) if ($debug);\n"
@@ -113,10 +110,12 @@ char *extract_header = "#!/usr/bin/perl\n"
" syswrite(OUTFILE, substr($out,$i+1,1));\n"
" syswrite(OUTFILE, substr($out,$i,1));\n"
" $i+=2;\n"
- " for (my $j=0;$j<$size;$j++) {\n"
- " syswrite(OUTFILE, substr($out,$j+$i,1));\n"
+ " if ($size>0 && $size <0x8000) {\n"
+ " for (my $j=0;$j<$size;$j++) {\n"
+ " syswrite(OUTFILE, substr($out,$j+$i,1));\n"
+ " }\n"
+ " $i+=$size;\n"
" }\n"
- " $i+=$size;\n"
" }\n"
"}\n"
"\n"
diff --git a/v4l2-apps/util/xc3028-firmware/firmware-tool.c b/v4l2-apps/util/xc3028-firmware/firmware-tool.c
index c0003ddff..b48495aa4 100644
--- a/v4l2-apps/util/xc3028-firmware/firmware-tool.c
+++ b/v4l2-apps/util/xc3028-firmware/firmware-tool.c
@@ -585,7 +585,6 @@ int seek_chunks(struct chunk_hunk *hunk,
break;
}
if (p2 == endf) {
- printf("Firmware found at %ld\n", p - seek);
hunk->data = NULL;
hunk->pos = p - seek;
hunk->size = endf - fdata;
@@ -601,15 +600,15 @@ int seek_chunks(struct chunk_hunk *hunk,
memcpy(temp_data, fdata, fsize);
/* Try again, changing endian */
- for (p2 = temp_data; p2 < temp_data + fsize; p2++) {
+ for (p2 = temp_data; p2 < temp_data + fsize;) {
+ unsigned char c;
int size = *p2 + (*(p2 + 1) << 8);
- if ((size > 0) && (size < 0x8000)) {
- unsigned char c = *p2;
- *p2 = *(p2 + 1);
- *(p2 + 1) = c;
- p2 += size + 1;
-
- }
+ c = *p2;
+ *p2 = *(p2 + 1);
+ *(p2 + 1) = c;
+ p2+=2;
+ if ((size > 0) && (size < 0x8000))
+ p2 += size;
}
/* Method 1b: Seek for a complete firmware with changed endians */
@@ -620,8 +619,6 @@ int seek_chunks(struct chunk_hunk *hunk,
break;
}
if (p2 == temp_data + fsize) {
- printf("Firmware found at %ld (fix_endian)\n",
- p - seek);
hunk->data = NULL;
hunk->pos = p - seek;
hunk->size = endf - fdata;
@@ -666,8 +663,6 @@ int seek_chunks(struct chunk_hunk *hunk,
hunk->next = calloc(1, sizeof(hunk));
hunk->need_fix_endian = 0;
hunk = hunk->next;
- printf("Firmware hunk found at %ld \n",
- p - seek);
break;
}
@@ -679,15 +674,14 @@ int seek_chunks(struct chunk_hunk *hunk,
}
}
- printf ("Firmware found by using method 3\n");
- return 1;
+ return 2;
not_found:
- printf("method 2 couldn't find firmware\n");
+ printf("Couldn't find firmware\n");
return 0;
/* Method 3: Seek for first firmware chunks */
-
+#if 0
seek_next:
for (p = seek; p < endp; p++) {
fpos = p;
@@ -723,6 +717,7 @@ seek_next:
printf ("NOT FOUND: %02x\n", *fdata);
fdata++;
goto seek_next;
+#endif
}
void seek_firmware(struct firmware *f, char *seek_file, char *write_file) {
@@ -777,11 +772,13 @@ void seek_firmware(struct firmware *f, char *seek_file, char *write_file) {
seek, endp, f->desc[i].data, endp2);
if (!found) {
- printf("Firmware %d Not found: ", i);
+ printf("NOT FOUND: Firmware %d ", i);
+ list_firmware_desc(stdout, &f->desc[i]);
+ } else {
+ nfound++;
+ printf("Found with method %d: Firmware %d ", found, i);
list_firmware_desc(stdout, &f->desc[i]);
}
-
- nfound += found;
}
printf ("Found %d complete firmwares\n", nfound);