diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-18 21:13:20 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-18 21:13:20 +0200 |
commit | f6dc8ccaab6d8f63cbae1e6c73fe972b26f5376c (patch) | |
tree | c5643fcdc884a8d0bfc3f1bc28039cab7394e5bc /drivers/media/video/dabusb.c | |
parent | 323ec001c6bb98eeabb5abbdbb8c8055d9496554 (diff) | |
parent | 5b664cb235e97afbf34db9c4d77f08ebd725335e (diff) |
Merge branch 'linus' into core/generic-dma-coherent
Conflicts:
kernel/Makefile
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/media/video/dabusb.c')
-rw-r--r-- | drivers/media/video/dabusb.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c index 8d1f8ee2a53..48f4b92a8f8 100644 --- a/drivers/media/video/dabusb.c +++ b/drivers/media/video/dabusb.c @@ -38,9 +38,10 @@ #include <linux/delay.h> #include <linux/usb.h> #include <linux/mutex.h> +#include <linux/firmware.h> +#include <linux/ihex.h> #include "dabusb.h" -#include "dabfirmware.h" /* * Version Information @@ -297,7 +298,8 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb) return ret; } /* --------------------------------------------------------------------- */ -static int dabusb_writemem (pdabusb_t s, int pos, unsigned char *data, int len) +static int dabusb_writemem (pdabusb_t s, int pos, const unsigned char *data, + int len) { int ret; unsigned char *transfer_buffer = kmalloc (len, GFP_KERNEL); @@ -324,24 +326,35 @@ static int dabusb_8051_reset (pdabusb_t s, unsigned char reset_bit) static int dabusb_loadmem (pdabusb_t s, const char *fname) { int ret; - PINTEL_HEX_RECORD ptr = firmware; + const struct ihex_binrec *rec; + const struct firmware *fw; dbg("Enter dabusb_loadmem (internal)"); + ret = request_ihex_firmware(&fw, "dabusb/firmware.fw", &s->usbdev->dev); + if (ret) { + err("Failed to load \"dabusb/firmware.fw\": %d\n", ret); + goto out; + } ret = dabusb_8051_reset (s, 1); - while (ptr->Type == 0) { - dbg("dabusb_writemem: %04X %p %d)", ptr->Address, ptr->Data, ptr->Length); + for (rec = (const struct ihex_binrec *)fw->data; rec; + rec = ihex_next_binrec(rec)) { + dbg("dabusb_writemem: %04X %p %d)", be32_to_cpu(rec->addr), + rec->data, be16_to_cpu(rec->len)); - ret = dabusb_writemem (s, ptr->Address, ptr->Data, ptr->Length); + ret = dabusb_writemem(s, be32_to_cpu(rec->addr), rec->data, + be16_to_cpu(rec->len)); if (ret < 0) { - err("dabusb_writemem failed (%d %04X %p %d)", ret, ptr->Address, ptr->Data, ptr->Length); + err("dabusb_writemem failed (%d %04X %p %d)", ret, + be32_to_cpu(rec->addr), rec->data, + be16_to_cpu(rec->len)); break; } - ptr++; } ret = dabusb_8051_reset (s, 0); - + release_firmware(fw); + out: dbg("dabusb_loadmem: exit"); return ret; @@ -376,9 +389,9 @@ static int dabusb_fpga_init (pdabusb_t s, pbulk_transfer_t b) static int dabusb_fpga_download (pdabusb_t s, const char *fname) { pbulk_transfer_t b = kmalloc (sizeof (bulk_transfer_t), GFP_KERNEL); + const struct firmware *fw; unsigned int blen, n; int ret; - unsigned char *buf = bitstream; dbg("Enter dabusb_fpga_download (internal)"); @@ -387,10 +400,16 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) return -ENOMEM; } + ret = request_firmware(&fw, "dabusb/bitstream.bin", &s->usbdev->dev); + if (ret) { + err("Failed to load \"dabusb/bitstream.bin\": %d\n", ret); + return ret; + } + b->pipe = 1; ret = dabusb_fpga_clear (s, b); mdelay (10); - blen = buf[73] + (buf[72] << 8); + blen = fw->data[73] + (fw->data[72] << 8); dbg("Bitstream len: %i", blen); @@ -402,7 +421,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) for (n = 0; n <= blen + 60; n += 60) { // some cclks for startup b->size = 64; - memcpy (b->data + 4, buf + 74 + n, 60); + memcpy (b->data + 4, fw->data + 74 + n, 60); ret = dabusb_bulk (s, b); if (ret < 0) { err("dabusb_bulk failed."); @@ -413,6 +432,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) ret = dabusb_fpga_init (s, b); kfree (b); + release_firmware(fw); dbg("exit dabusb_fpga_download"); |