Commit 6569e964 authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] DVB: Add static firmware compilation again

 - add Kconfig magic to select a firmware that can be compiled into the
   driver
 - add some hooks to av7110 to compile a firmware into the driver again
parent e68b286a
......@@ -13,6 +13,23 @@ config DVB_AV7110
Say Y if you own such a card and want to use it.
config DVB_AV7110_FIRMWARE
bool "Compile AV7110 firmware into the driver"
depends on DVB_AV7110
help
The AV7110 firmware is normally loaded by the firmware hotplug manager.
If you want to compile the firmware into the driver you need to say
Y here and provide the correct path of the firmware. You need this
option if you want to compile the whole driver statically into the
kernel.
All other people say N.
config DVB_AV7110_FIRMWARE_FILE
string "Full pathname of av7110 firmware file"
depends on DVB_AV7110_FIRMWARE
default "/usr/lib/hotplug/firmware/dvb-ttpci-01.fw"
config DVB_AV7110_OSD
bool "AV7110 OSD support"
depends on DVB_AV7110
......
......@@ -12,3 +12,12 @@ obj-$(CONFIG_DVB_BUDGET_PATCH) += budget-core.o budget-patch.o ttpci-eeprom.o
obj-$(CONFIG_DVB_AV7110) += dvb-ttpci.o ttpci-eeprom.o
EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
host-progs := fdump
ifdef CONFIG_DVB_AV7110_FIRMWARE
$(obj)/av7110.o: $(obj)/fdump $(obj)/av7110_firm.h
$(obj)/av7110_firm.h:
$(obj)/fdump $(CONFIG_DVB_AV7110_FIRMWARE_FILE) dvb_ttpci_fw $@
endif
......@@ -4498,9 +4498,21 @@ static u8 saa7113_init_regs[] = {
static struct saa7146_ext_vv av7110_vv_data_st;
static struct saa7146_ext_vv av7110_vv_data_c;
#ifdef CONFIG_DVB_AV7110_FIRMWARE_FILE
#include "av7110_firm.h"
#endif
static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *pci_ext)
{
#ifndef CONFIG_DVB_AV7110_FIRMWARE_FILE
const struct firmware *fw;
#else
struct firmware *fw;
#endif
struct av7110 *av7110 = NULL;
int ret = 0;
u32 crc = 0, len = 0;
......@@ -4508,12 +4520,22 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
DEB_EE(("dev: %p, av7110: %p\n",dev,av7110));
#ifndef CONFIG_DVB_AV7110_FIRMWARE_FILE
/* request the av7110 firmware, this will block until someone uploads it */
ret = request_firmware(&fw, "dvb-ttpci-01.fw", &dev->pci->dev);
if ( 0 != ret ) {
printk("dvb-ttpci: cannot request firmware!\n");
return -EINVAL;
}
#else
fw = vmalloc(sizeof(struct firmware));
if (NULL == fw) {
printk("dvb-ttpci: not enough memory\n");
return -ENOMEM;
}
fw->size = sizeof(dvb_ttpci_fw);
fw->data = dvb_ttpci_fw;
#endif
if (fw->size <= 200000) {
printk("dvb-ttpci: this firmware is way too small.\n");
......@@ -4580,6 +4602,9 @@ static int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
av7110->bin_root = ptr;
av7110->size_root = len;
#ifdef CONFIG_DVB_AV7110_FIRMWARE_FILE
vfree(fw);
#endif
/* go on with regular device initialization */
av7110->card_name = (char*)pci_ext->ext_priv;
av7110->dev=(struct saa7146_dev *)dev;
......
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char **argv)
{
unsigned char buf[8];
unsigned int i, count, bytes = 0;
FILE *fd_in, *fd_out;
if (argc != 4) {
fprintf(stderr, "\n\tusage: %s <ucode.bin> <array_name> <output_name>\n\n", argv[0]);
return -1;
}
fd_in = fopen(argv[1], "rb");
if (fd_in == NULL) {
fprintf(stderr, "firmware file '%s' not found\n", argv[1]);
return -1;
}
fd_out = fopen(argv[3], "w+");
if (fd_out == NULL) {
fprintf(stderr, "cannot create output file '%s'\n", argv[3]);
return -1;
}
fprintf(fd_out, "\n#include <asm/types.h>\n\nu8 %s [] = {", argv[2]);
while ((count = fread(buf, 1, 8, fd_in)) > 0) {
fprintf(fd_out, "\n\t");
for (i = 0; i < count; i++, bytes++)
fprintf(fd_out, "0x%02x, ", buf[i]);
}
fprintf(fd_out, "\n};\n\n");
fclose(fd_in);
fclose(fd_out);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment