Skip to content

Commit

Permalink
dabusb: use request_firmware()
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
dwmw2 authored and David Woodhouse committed Jul 14, 2008
1 parent 04a33e4 commit c466774
Show file tree
Hide file tree
Showing 6 changed files with 1,461 additions and 1,427 deletions.
1,415 changes: 0 additions & 1,415 deletions drivers/media/video/dabfirmware.h

This file was deleted.

44 changes: 32 additions & 12 deletions drivers/media/video/dabusb.c
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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)");

Expand All @@ -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);

Expand All @@ -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.");
Expand All @@ -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");

Expand Down
3 changes: 3 additions & 0 deletions firmware/Makefile
Expand Up @@ -29,6 +29,9 @@ fw-shipped-$(CONFIG_SND_MAESTRO3) += ess/maestro3_assp_kernel.fw \
ess/maestro3_assp_minisrc.fw
fw-shipped-$(CONFIG_SND_YMFPCI) += yamaha/ds1_ctrl.fw yamaha/ds1_dsp.fw \
yamaha/ds1e_ctrl.fw
fw-shipped-$(CONFIG_TIGON3) += tigon/tg3.bin tigon/tg3_tso.bin \
tigon/tg3_tso5.bin
fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin
fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \
emi26/bitstream.fw
fw-shipped-$(CONFIG_USB_EMI62) += emi62/loader.fw emi62/bitstream.fw \
Expand Down
16 changes: 16 additions & 0 deletions firmware/WHENCE
Expand Up @@ -249,3 +249,19 @@ Licence: Allegedly GPLv2+, but no source visible. Marked:
Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: DABUSB -- Digital Audio Broadcasting (DAB) Receiver for USB and Linux

File: dabusb/firmware.fw
File: dabusb/bitstream.bin

Licence: Distributable

* Copyright (C) 1999 BayCom GmbH
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that redistributions of source
* code retain the above copyright notice and this comment without
* modification.

--------------------------------------------------------------------------

0 comments on commit c466774

Please sign in to comment.