summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/video/dabusb.c74
1 files changed, 74 insertions, 0 deletions
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 <linux/usb.h>
#include "compat.h"
#include <linux/mutex.h>
+#if LINUX_VERSION_CODE => KERNEL_VERSION(2,6,27)
+#include <linux/firmware.h>
+#include <linux/ihex.h>
+#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");