Although it wasn't actually using ihex records before, we use the Intel
HEX record format for this firmware -- because that gives us a simple
way to split it into separate chunks internally as we need, without
loading each part as a separate file.
Signed-off-by: Jaswinder Singh <jaswinder@infradead.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Since it had various regions to be loaded to separate addresses, and it
wanted to do them in fairly small chunks anyway, switch it to use the
new ihex code. Encode the start address in the first record.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Chas Williams <chas@cmf.nrl.navy.mil>
Some drivers could do with using records like Intel HEX, but with each
record being larger than 256 bytes. This has been possible in the binary
representation (struct ihex_binrec) in the kernel since the beginning --
at least of the the current version of history. But we haven't been able
to represent that in the .HEX files which get converted to .fw files.
This adds a '-w' option to ihex2fw to make it interpret the first _two_
bytes of each line as the record length, instead of only one byte. And
adds makefile rules for %.H16->%.fw which use that.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Not the straight conversion to binary which objcopy can do for us, but
actually representing each record with its original {addr, length},
because some drivers need that information preserved.
Fix up 'firmware_install' to be able to build $(hostprogs-y) too.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Provide a helper to load the file and validate it in one call, to
simplify error handling in the drivers which are going to use it.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Some devices need their firmware as a set of {address, len, data...}
records in some specific order rather than a simple blob.
The normal way of doing this kind of thing is 'ihex', which is a text
format and not entirely suitable for use in the kernel.
This provides a binary representation which is very similar, but much
more compact -- and a helper routine to skip to the next record,
because the alignment constraints mean that everybody will screw it up
for themselves otherwise.
Also a helper function which can verify that a 'struct firmware'
contains a valid set of ihex records, and that following them won't run
off the end of the loaded data.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
For 'make modules_install', install any firmware required by
the modules which are being installed.
Also add a 'make firmware_install' target which doesn't depend on the
configuration, but installs _all_ available in-kernel-tree firmware into
$(INSTALL_FW_PATH), which defaults to /lib/firmware. This is intended
for distributors to make arch-independent (and config-independent)
packages containing firmware.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This will control whether we build firmware into the kernel image for
_every_ driver which we convert to request_firmware(), to avoid a
proliferation of 'CONFIG_XXX_FIRMWARE' options for each one.
Default to 'y' for now, which is the wrong thing to do but people seem
to be insisting on it and refusing to even review patches until it's
done. And it does preserve the existing behaviour for built-in drivers.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
This allows arbitrary firmware files to be included in the static kernel
where the firmware loader can find them without requiring userspace to
be alive.
(Updated and CONFIG_EXTRA_FIRMWARE_DIR added with lots of help from
Johannes Berg).
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Some drivers have their own hacks to bypass the kernel's firmware loader
and build their firmware into the kernel; this renders those unnecessary.
Other drivers don't use the firmware loader at all, because they always
want the firmware to be available. This allows them to start using the
firmware loader.
A third set of drivers already use the firmware loader, but can't be
used without help from userspace, which sometimes requires an initrd.
This allows them to work in a static kernel.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
In preparation for supporting firmware files linked into the static
kernel, make fw->data const to ensure that users aren't modifying it (so
that we can pass a pointer to the original in-kernel copy, rather than
having to copy it).
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Fix a const pointer usage warning in the Digigram miXart soundcard driver. A
const pointer is being passed to copy_from_user() to load the firmware into.
This is okay in this case because the function has allocated the firmware
struct itself, but the const qualifier is part of the firmware struct - so the
patch casts the const away.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Fix a const pointer usage warning in the Digigram pcxhr compatible soundcard
driver. A const pointer is being passed to copy_from_user() to load the
firmware into. This is okay in this case because the function has allocated
the firmware struct itself, but the const qualifier is part of the firmware
struct - so the patch casts the const away.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Fix a const pointer to non-const pointer assignment error in the Conexant
cx23418 MPEG encoder driver.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Fix an assignment of a const pointer to a non-const pointer in moxa_load_fw().
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Fix a const pointer usage warning in the Digigram VX soundcard driver. A
const pointer is being passed to copy_from_user() to load the firmware into.
This is okay in this case because the function has allocated the firmware
struct itself, but the const qualifier will be part of the firmware
struct - so the patch casts the const away.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Standardise both in-kernel and loaded firmware to be stored as
little-endian instead of host-endian.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
The maestro3 driver is byte-swapping its firmware to be host-endian in
advance, when it doesn't seem to be necessary -- we could just use
le16_to_cpu() as we load it.
Doing that means that we need to switch the in-tree firmware to be
little-endian too.
Take the least intrusive way of doing this, which is to switch the
existing snd_m3_convert_from_le() function to convert _to_ little-endian
instead, and use it on the in-tree firmware instead of the loaded
firmware. It's a bit suboptimal but doesn't matter much right now
because we're about to remove the special cases for the in-tree version
anyway.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
...which means allocating our own copy when we want to modify it.
(stupid thinko fixed by mkrufky)
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>