echoaudio, fw_writer
PATCH 1/1 echoaudio, fw_writer
After a talk with Richard Stallman, who said it is not correct to link a binary image into a GPL program even if is just dumped onto disk, here you are this patch that makes fw_writer to load and parse the C sources containing the images instead of including them at compile time. It supports both the "sources" that are already part of alsa-firmware and the original files downloadable from the Echoaudio web site.
Change the fw_writer utility so it does not #include the binary images anymore. It loads them from disk instead.
echoaudio/fw_writer.c renamed from echoaudio/fw_writer.c__orig +88 -67
@@ -17,6 +17,7 @@*/ #include <stdio.h> +#include <sys/stat.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h>
@@ -24,53 +25,74 @@#include <string.h> #include <errno.h> -typedef uint8_t u8 ; -typedef uint16_t u16 ; -#include "DSP/LoaderDSP.c" -#include "DSP/Darla20DSP.c" -#include "DSP/Gina20DSP.c" -#include "DSP/Layla20DSP.c" -#include "ASIC/LaylaASIC.c" -#include "DSP/Darla24DSP.c" -#include "ASIC/Gina24ASIC.c" -#include "ASIC/Gina24ASIC_361.c" -#include "DSP/Gina24DSP.c" -#include "DSP/Gina24_361DSP.c" -#include "DSP/Layla24DSP.c" -#include "ASIC/Layla24_1ASIC.c" -#include "ASIC/Layla24_2A_ASIC.c" -#include "ASIC/Layla24_2S_ASIC.c" -#include "DSP/MonaDSP.c" -#include "DSP/Mona361DSP.c" -#include "ASIC/Mona1ASIC48.c" -#include "ASIC/Mona1ASIC96.c" -#include "ASIC/Mona1ASIC48_361.c" -#include "ASIC/Mona1ASIC96_361.c" -#include "ASIC/Mona2ASIC.c" -#include "DSP/MiaDSP.c" -#include "DSP/Echo3gDSP.c" -#include "ASIC/3G_ASIC.c" -#include "DSP/IndigoDSP.c" -#include "DSP/IndigoIODSP.c" -#include "DSP/IndigoDJDSP.c" +char *next_number (char *c) +{ +while (1 ) { + c++; +if (*c==0 || *c =='}' ) +return NULL ; +if (c[0 ]=='0' && c[1 ]=='x' ) +return c; + } +} -int write_fw (const char *name,void *fw,ssize_t size) + +int write_fw (const char *dest,const char *src) { -int fd, n; +uint16_t d16; +uint8_t d8; +int fd; +struct stat stbuf; +char *buf, *c; -if ((fd =open (name,O_WRONLY |O_CREAT |O_TRUNC ,0644 )) <0 ) { -printf ("Open error: %s\n" ,strerror (fd)); -return fd; +if ((fd =open (src,O_RDONLY )) <0 ) { +printf ("%s: %s\n" , src,strerror (errno)); +exit (errno); } - n =write (fd, fw, size); -if (n <0 ) -printf ("Error writing %s: %s\n" , name,strerror (fd)); -else if (n < size) -printf ("Error writing %s: file is incomplete (%s)\n" , name,strerror (fd)); +if (fstat (fd, &stbuf) <0 ) { +printf ("%s: %s\n" , src,strerror (errno)); +exit (errno); + } +if (!(buf =malloc (stbuf.st_size +1 ))) { +puts ("Out of memory." ); +exit (ENOMEM ); + } +if (read (fd, buf, stbuf.st_size) < stbuf.st_size) { +puts ("Read error." ); +exit (EIO ); + } +close (fd); + buf[stbuf.st_size] =0 ; +if ((fd =open (dest,O_WRONLY |O_CREAT |O_TRUNC ,0644 )) <0 ) { +printf ("%s: %s\n" , dest,strerror (errno)); +exit (errno); + } +if ((c =strstr (buf,"u8 " )) || (c =strstr (buf,"BYTE " ))) { +while (c =next_number (c)) { + d8 =strtol (c,NULL ,16 ); +if (write (fd, &d8,1 ) <1 ) { +printf ("Error writing %s\n" , dest); +exit (EIO ); + } + } + }else if ((c =strstr (buf,"u16 " )) || (c =strstr (buf,"WORD " ))) { +while (c =next_number (c)) { + d16 =strtol (c,NULL ,16 ); +if (write (fd, &d16,2 ) <2 ) { +printf ("Error writing %s\n" , dest); +exit (EIO ); + } + } + }else { +printf ("%s currupted ?\n" , src); +exit (EINVAL ); + }close (fd); +free (buf); +return 0 ; }
@@ -78,33 +100,32 @@ int write_fw(const char *name, void *fw,int main (void ) { -write_fw ("loader_dsp.fw" , LoaderDSP,sizeof (LoaderDSP)); -write_fw ("darla20_dsp.fw" , Darla20DSP,sizeof (Darla20DSP)); -write_fw ("gina20_dsp.fw" , Gina20DSP,sizeof (Gina20DSP)); -write_fw ("layla20_dsp.fw" , Layla20DSP,sizeof (Layla20DSP)); -write_fw ("layla20_asic.fw" , LaylaASIC,sizeof (LaylaASIC)); -write_fw ("darla24_dsp.fw" , Darla24DSP,sizeof (Darla24DSP)); -write_fw ("gina24_301_dsp.fw" , Gina24DSP,sizeof (Gina24DSP)); -write_fw ("gina24_301_asic.fw" , Gina24ASIC,sizeof (Gina24ASIC)); -write_fw ("gina24_361_dsp.fw" , Gina24_361DSP,sizeof (Gina24_361DSP)); -write_fw ("gina24_361_asic.fw" , Gina24ASIC_361,sizeof (Gina24ASIC_361)); -write_fw ("layla24_dsp.fw" , Layla24DSP,sizeof (Layla24DSP)); -write_fw ("layla24_1_asic.fw" , Layla24_1ASIC,sizeof (Layla24_1ASIC)); -write_fw ("layla24_2A_asic.fw" , Layla24_2A_ASIC,sizeof (Layla24_2A_ASIC)); -write_fw ("layla24_2S_asic.fw" , Layla24_2S_ASIC,sizeof (Layla24_2S_ASIC)); -write_fw ("mona_301_dsp.fw" , MonaDSP,sizeof (MonaDSP)); -write_fw ("mona_301_1_asic_48.fw" , Mona1ASIC48,sizeof (Mona1ASIC48)); -write_fw ("mona_301_1_asic_96.fw" , Mona1ASIC96,sizeof (Mona1ASIC96)); -write_fw ("mona_361_dsp.fw" , Mona361DSP,sizeof (Mona361DSP)); -write_fw ("mona_361_1_asic_48.fw" , Mona1ASIC48_361,sizeof (Mona1ASIC48_361)); -write_fw ("mona_361_1_asic_96.fw" , Mona1ASIC96_361,sizeof (Mona1ASIC96_361)); -write_fw ("mona_2_asic.fw" , Mona2ASIC,sizeof (Mona2ASIC)); -write_fw ("mia_dsp.fw" , MiaDSP,sizeof (MiaDSP)); -write_fw ("echo3g_dsp.fw" , Echo3gDSP,sizeof (Echo3gDSP)); -write_fw ("3g_asic.fw" , echo3g_asic,sizeof (echo3g_asic)); -write_fw ("indigo_dsp.fw" , IndigoDSP,sizeof (IndigoDSP)); -write_fw ("indigo_io_dsp.fw" , IndigoioDSP,sizeof (IndigoioDSP)); -write_fw ("indigo_dj_dsp.fw" , IndigodjDSP,sizeof (IndigodjDSP)); +write_fw ("loader_dsp.fw" ,"DSP/LoaderDSP.c" ); +write_fw ("darla20_dsp.fw" ,"DSP/Darla20DSP.c" ); +write_fw ("gina20_dsp.fw" ,"DSP/Gina20DSP.c" ); +write_fw ("layla20_dsp.fw" ,"DSP/Layla20DSP.c" ); +write_fw ("layla20_asic.fw" ,"ASIC/LaylaASIC.c" ); +write_fw ("darla24_dsp.fw" ,"DSP/Darla24DSP.c" ); +write_fw ("gina24_301_dsp.fw" ,"DSP/Gina24DSP.c" ); +write_fw ("gina24_301_asic.fw" ,"ASIC/Gina24ASIC.c" ); +write_fw ("gina24_361_dsp.fw" ,"DSP/Gina24_361DSP.c" ); +write_fw ("gina24_361_asic.fw" ,"ASIC/Gina24ASIC_361.c" ); +write_fw ("layla24_dsp.fw" ,"DSP/Layla24DSP.c" ); +write_fw ("layla24_1_asic.fw" ,"ASIC/Layla24_1ASIC.c" ); +write_fw ("layla24_2A_asic.fw" ,"ASIC/Layla24_2A_ASIC.c" ); +write_fw ("layla24_2S_asic.fw" ,"ASIC/Layla24_2S_ASIC.c" ); +write_fw ("mona_301_dsp.fw" ,"DSP/MonaDSP.c" ); +write_fw ("mona_301_1_asic_48.fw" ,"ASIC/Mona1ASIC48.c" ); +write_fw ("mona_301_1_asic_96.fw" ,"ASIC/Mona1ASIC96.c" ); +write_fw ("mona_361_dsp.fw" ,"DSP/Mona361DSP.c" ); +write_fw ("mona_361_1_asic_48.fw" ,"ASIC/Mona1ASIC48_361.c" ); +write_fw ("mona_361_1_asic_96.fw" ,"ASIC/Mona1ASIC96_361.c" ); +write_fw ("mona_2_asic.fw" ,"ASIC/Mona2ASIC.c" ); +write_fw ("mia_dsp.fw" ,"DSP/MiaDSP.c" ); +write_fw ("echo3g_dsp.fw" ,"DSP/Echo3gDSP.c" ); +write_fw ("3g_asic.fw" ,"ASIC/3G_ASIC.c" ); +write_fw ("indigo_dsp.fw" ,"DSP/IndigoDSP.c" ); +write_fw ("indigo_io_dsp.fw" ,"DSP/IndigoIODSP.c" ); +write_fw ("indigo_dj_dsp.fw" ,"DSP/IndigoDJDSP.c" );return 0 ; } -
--
Giuliano.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 6 lines · Giuliano Pochini
After a talk with Richard Stallman, who said it is not correct to link a binary image into a GPL program even if is just dumped onto disk, here you are this patch that makes
fw_writerto load and parse the C sources containing the images instead of including them at compile time. It supports both the "sources" that are already part of alsa-firmware and the original files downloadable from the Echoaudio web site.
I dunno where the fw_writer.c comes from, but relicensing it if possible seems like a saner option ;)
johannes
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
Quoted 7 lines · Giuliano Pochini
After a talk with Richard Stallman, who said it is not correct to link a binary image into a GPL program even if is just dumped onto disk, here you are this patch that makes
fw_writerto load and parse the C sources containing the images instead of including them at compile time. It supports both the "sources" that are already part of alsa-firmware and the original files downloadable from the Echoaudio web site.
What is the problem exactly?
All the files DSP/LoaderDSP.c etc. have a GPL license on them. I don't see what the problem is, unless you have wrongly attached the GPL license to them?
James
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 9 lines · On 18-Jul-2006 James Courtier-Dutton wrote:
Quoted 7 lines · Giuliano Pochini
After a talk with Richard Stallman, who said it is not correct to link a binary image into a GPL program even if is just dumped onto disk, here you are this patch that makes
fw_writerto load and parse the C sources containing the images instead of including them at compile time. It supports both the "sources" that are already part of alsa-firmware and the original files downloadable from the Echoaudio web site.
Quoted 4 lines
What is the problem exactly?
All the filesDSP/LoaderDSP.cetc. have a GPL license on them. I don't see what the problem is, unless you have wrongly attached the GPL license to them?
fw_loader.c #include's those files. The licence says the author permits the inclusion of the firmwares in a GPL project. But rms says it is misleading because the GPL requires the firmwares to be in source form.
I do not completely agree with that, but this patch solves the issue (and fw_loader.c is 200 bytes shorter 8D).
--
Giuliano.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 2 lines · Giuliano Pochini
I do not completely agree with that, but this patch solves the issue (and
fw_loader.cis 200 bytes shorter 8D).
Now you don't have to include each C file, you could make fw_loader.c into universal c to fw converter by getting the parameters for
+ write_fw("loader_dsp.fw", "DSP/LoaderDSP.c");
from the commandline?
Making it easier to build just one firmware, or a new firmware without updating firmware.c. And making the program shorter too...
Script or makefile executes
# fw_writer DSP/LoaderDSP.c loader_dsp.fw
-- Eliot
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 8 lines · On Thu, 20 Jul 2006 11:26:29 +1200 Eliot Blennerhassett…
Quoted 2 lines · Giuliano Pochini
I do not completely agree with that, but this patch solves the issue (and
fw_loader.cis 200 bytes shorter 8D).Now you don't have to include each C file, you could make
fw_loader.cinto universal c to fw converter by getting the parameters for
Quoted 6 lines
+ write_fw("loader_dsp.fw", "
DSP/LoaderDSP.c");from the commandline?
Making it easier to build just one firmware, or a new firmware without updating
firmware.c. And making the program shorter too...
Sure. It is useful for the emu driver other than mine.
--
Giuliano.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Quoted 6 lines · On Thu, 20 Jul 2006 11:26:29 +1200 Eliot Blennerhassett…
Now you don't have to include each C file, you could make
fw_loader.cinto universal c to fw converter by getting the parameters for+ write_fw("loader_dsp.fw", "
DSP/LoaderDSP.c");from the commandline?
Here you are. This patch is against the current HG version.
Change the fw_writer utility so it does not #include the binary images anymore. It loads them from disk instead.
echoaudio/Makefile.am renamed from echoaudio/Makefile.am__orig +26 -1
@@ -70,4 +70,29 @@ hotplugfw_DATA = endif $(firmware_files): fw_writer - ./fw_writer + ./fw_writer DSP/Darla20DSP.c darla20_dsp.fw + ./fw_writer DSP/Gina20DSP.c gina20_dsp.fw + ./fw_writer DSP/Layla20DSP.c layla20_dsp.fw + ./fw_writer ASIC/LaylaASIC.c layla20_asic.fw + ./fw_writer DSP/Darla24DSP.c darla24_dsp.fw + ./fw_writer DSP/Gina24DSP.c gina24_301_dsp.fw + ./fw_writer ASIC/Gina24ASIC.c gina24_301_asic.fw + ./fw_writer DSP/Gina24_361DSP.c gina24_361_dsp.fw + ./fw_writer ASIC/Gina24ASIC_361.c gina24_361_asic.fw + ./fw_writer DSP/Layla24DSP.c layla24_dsp.fw + ./fw_writer ASIC/Layla24_1ASIC.c layla24_1_asic.fw + ./fw_writer ASIC/Layla24_2A_ASIC.c layla24_2A_asic.fw + ./fw_writer ASIC/Layla24_2S_ASIC.c layla24_2S_asic.fw + ./fw_writer DSP/MonaDSP.c mona_301_dsp.fw + ./fw_writer ASIC/Mona1ASIC48.c mona_301_1_asic_48.fw + ./fw_writer ASIC/Mona1ASIC96.c mona_301_1_asic_96.fw + ./fw_writer DSP/Mona361DSP.c mona_361_dsp.fw + ./fw_writer ASIC/Mona1ASIC48_361.c mona_361_1_asic_48.fw + ./fw_writer ASIC/Mona1ASIC96_361.c mona_361_1_asic_96.fw + ./fw_writer ASIC/Mona2ASIC.c mona_2_asic.fw + ./fw_writer DSP/MiaDSP.c mia_dsp.fw + ./fw_writer DSP/Echo3gDSP.c echo3g_dsp.fw + ./fw_writer ASIC/3G_ASIC.c 3g_asic.fw + ./fw_writer DSP/IndigoDSP.c indigo_dsp.fw + ./fw_writer DSP/IndigoIODSP.c indigo_io_dsp.fw + ./fw_writer DSP/IndigoDJDSP.c indigo_dj_dsp.fw
echoaudio/fw_writer.c renamed from echoaudio/fw_writer.c__orig +67 -68
160 lines not on this page · raw message
--
Giuliano.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
At Sun, 23 Jul 2006 17:39:37 +0200,
Quoted 11 lines · Giuliano Pochini
Quoted 6 lines · On Thu, 20 Jul 2006 11:26:29 +1200 Eliot Blennerhassett…
Now you don't have to include each C file, you could make
fw_loader.cinto universal c to fw converter by getting the parameters for+ write_fw("loader_dsp.fw", "
DSP/LoaderDSP.c");from the commandline?
Quoted 8 lines
Here you are. This patch is against the current HG version.
Signed-off-by Giuliano Pochini <[email protected]>Change the
fw_writerutility so it does not #include the binary images anymore. It loads them from disk instead.
Thanks, it's on HG repo now.
Takashi
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV