From e46f9d89ede64dc52c0e933a4d0ccaeaa6e88ddb Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 24 Jul 2008 13:24:51 -0300 Subject: backport commit c466774636b3cc43c2c304b44e52974d9d53f3e0 From: Mauro Carvalho Chehab kernel-sync: Author: David Woodhouse Date: Mon Jun 23 11:41:04 2008 +0100 dabusb: use request_firmware() Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/dabusb.c | 74 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'linux/drivers/media/video/dabusb.c') diff --git a/linux/drivers/media/video/dabusb.c b/linux/drivers/media/video/dabusb.c index 72bf5868c..a73220716 100644 --- a/linux/drivers/media/video/dabusb.c +++ b/linux/drivers/media/video/dabusb.c @@ -39,9 +39,15 @@ #include #include "compat.h" #include +#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) +#include +#include +#endif #include "dabusb.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) #include "dabfirmware.h" +#endif /* * Version Information @@ -302,7 +308,12 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb) return ret; } /* --------------------------------------------------------------------- */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) static int dabusb_writemem (pdabusb_t s, int pos, unsigned char *data, int len) +#else +static int dabusb_writemem (pdabusb_t s, int pos, const unsigned char *data, + int len) +#endif { int ret; unsigned char *transfer_buffer = kmalloc (len, GFP_KERNEL); @@ -329,24 +340,63 @@ static int dabusb_8051_reset (pdabusb_t s, unsigned char reset_bit) static int dabusb_loadmem (pdabusb_t s, const char *fname) { int ret; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) PINTEL_HEX_RECORD ptr = firmware; +#else + const struct ihex_binrec *rec; + const struct firmware *fw; +#endif dbg("Enter dabusb_loadmem (internal)"); +#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) + 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; + } +#endif ret = dabusb_8051_reset (s, 1); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) while (ptr->Type == 0) { +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) dbg("dabusb_writemem: %04X %p %d)", ptr->Address, ptr->Data, ptr->Length); +#else + 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)); +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) ret = dabusb_writemem (s, ptr->Address, ptr->Data, ptr->Length); +#else + ret = dabusb_writemem(s, be32_to_cpu(rec->addr), rec->data, + be16_to_cpu(rec->len)); +#endif if (ret < 0) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) err("dabusb_writemem failed (%d %04X %p %d)", ret, ptr->Address, ptr->Data, ptr->Length); +#else + err("dabusb_writemem failed (%d %04X %p %d)", ret, + be32_to_cpu(rec->addr), rec->data, + be16_to_cpu(rec->len)); +#endif break; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) ptr++; +#endif } ret = dabusb_8051_reset (s, 0); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) +#else + release_firmware(fw); + out: +#endif dbg("dabusb_loadmem: exit"); return ret; @@ -381,9 +431,14 @@ 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); +#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) + const struct firmware *fw; +#endif unsigned int blen, n; int ret; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) unsigned char *buf = bitstream; +#endif dbg("Enter dabusb_fpga_download (internal)"); @@ -392,10 +447,22 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) return -ENOMEM; } +#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) + ret = request_firmware(&fw, "dabusb/bitstream.bin", &s->usbdev->dev); + if (ret) { + err("Failed to load \"dabusb/bitstream.bin\": %d\n", ret); + return ret; + } + +#endif b->pipe = 1; ret = dabusb_fpga_clear (s, b); mdelay (10); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) blen = buf[73] + (buf[72] << 8); +#else + blen = fw->data[73] + (fw->data[72] << 8); +#endif dbg("Bitstream len: %i", blen); @@ -407,7 +474,11 @@ 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; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) memcpy (b->data + 4, buf + 74 + n, 60); +#else + memcpy (b->data + 4, fw->data + 74 + n, 60); +#endif ret = dabusb_bulk (s, b); if (ret < 0) { err("dabusb_bulk failed."); @@ -418,6 +489,9 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) ret = dabusb_fpga_init (s, b); kfree (b); +#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) + release_firmware(fw); +#endif dbg("exit dabusb_fpga_download"); -- cgit v1.2.3 From e768886b19cdc2ba666bd52faa7797ff4151ced7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Thu, 24 Jul 2008 17:07:33 -0300 Subject: This patch fixes some kernel version checks. From: Reinhard Schwab Signed-off-by: Reinhard Schwab Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/video/dabusb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'linux/drivers/media/video/dabusb.c') diff --git a/linux/drivers/media/video/dabusb.c b/linux/drivers/media/video/dabusb.c index a73220716..f23e6b84d 100644 --- a/linux/drivers/media/video/dabusb.c +++ b/linux/drivers/media/video/dabusb.c @@ -39,7 +39,7 @@ #include #include "compat.h" #include -#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) #include #include #endif @@ -349,7 +349,7 @@ static int dabusb_loadmem (pdabusb_t s, const char *fname) dbg("Enter dabusb_loadmem (internal)"); -#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) ret = request_ihex_firmware(&fw, "dabusb/firmware.fw", &s->usbdev->dev); if (ret) { err("Failed to load \"dabusb/firmware.fw\": %d\n", ret); @@ -431,7 +431,7 @@ 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); -#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) const struct firmware *fw; #endif unsigned int blen, n; @@ -447,7 +447,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) return -ENOMEM; } -#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) ret = request_firmware(&fw, "dabusb/bitstream.bin", &s->usbdev->dev); if (ret) { err("Failed to load \"dabusb/bitstream.bin\": %d\n", ret); @@ -489,7 +489,7 @@ static int dabusb_fpga_download (pdabusb_t s, const char *fname) ret = dabusb_fpga_init (s, b); kfree (b); -#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) release_firmware(fw); #endif -- cgit v1.2.3