diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-15 15:42:12 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-15 15:42:12 -0200 |
commit | d0375b60939435efcb77522782c226e3a695d7ba (patch) | |
tree | f613ddb1f341d96fb729b2f8a7b56eee0a360ddd /v4l2-apps/util | |
parent | 6c960a5f6ca8df030653648f416116e635fb4589 (diff) | |
download | mediapointer-dvb-s2-d0375b60939435efcb77522782c226e3a695d7ba.tar.gz mediapointer-dvb-s2-d0375b60939435efcb77522782c226e3a695d7ba.tar.bz2 |
Add a --dump option for listing the firmware hexadecimal values
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/util')
-rw-r--r-- | v4l2-apps/util/xc3028-firmware/firmware-tool.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/v4l2-apps/util/xc3028-firmware/firmware-tool.c b/v4l2-apps/util/xc3028-firmware/firmware-tool.c index 28ae70bb2..eb8e02dff 100644 --- a/v4l2-apps/util/xc3028-firmware/firmware-tool.c +++ b/v4l2-apps/util/xc3028-firmware/firmware-tool.c @@ -511,7 +511,8 @@ void list_firmware_desc(FILE *fp, struct firmware_description *desc) fprintf(fp, "size: %u\n", desc->size); } -void list_firmware(struct firmware *f) { +void list_firmware(struct firmware *f, unsigned int dump) +{ unsigned int i = 0; printf("firmware name:\t%s\n", f->name); @@ -521,6 +522,21 @@ void list_firmware(struct firmware *f) { for(i = 0; i < f->nr_desc; ++i) { printf("Firmware %2u, ", i); list_firmware_desc(stdout, &f->desc[i]); + if (dump) { + printf("\t"); + unsigned j, k = 0; + for (j = 0; j < f->desc[i].size; j++) { + printf("%02x", f->desc[i].data[j]); + + k++; + if (k >= 32) { + printf("\n\t"); + k = 0; + } else if (!(k % 2)) + printf(" "); + } + printf("\n"); + } } } @@ -845,7 +861,7 @@ void seek_firmware(struct firmware *f, char *seek_file, char *write_file) { void print_usage(void) { printf("firmware-tool usage:\n"); - printf("\t firmware-tool --list <firmware-file>\n"); + printf("\t firmware-tool --list [--dump] <firmware-file>\n"); printf("\t firmware-tool --add <firmware-dump> <firmware-file>\n"); printf("\t firmware-tool --delete <index> <firmware-file>\n"); printf("\t firmware-tool --type <type> --index <i> <firmware-file>\n"); @@ -857,7 +873,7 @@ int main(int argc, char* argv[]) { int c; int nr_args; - unsigned int action = 0; + unsigned int action = 0, dump = 0; char* firmware_file, *file = NULL, *nr_str = NULL, *index_str = NULL; char *seek_file = NULL, *write_file = NULL; struct firmware *f; @@ -873,6 +889,7 @@ int main(int argc, char* argv[]) {"index", required_argument, 0, 'i'}, {"seek", required_argument, 0, 'k'}, {"write", required_argument , 0, 'w'}, + {"dump", no_argument, 0, 'm'}, {0, 0, 0, 0} }; int option_index = 0; @@ -891,6 +908,9 @@ int main(int argc, char* argv[]) } action |= LIST_ACTION; break; + case 'm': + dump = 1; + break; case 'a': puts("add action\n"); if(action != 0) { @@ -965,7 +985,7 @@ int main(int argc, char* argv[]) switch(action) { case LIST_ACTION: - list_firmware(f); + list_firmware(f, dump); break; case ADD_ACTION: |