|
Packit Service |
f0277f |
/*
|
|
Packit Service |
f0277f |
* firmware writer for ESS Maestro3/Allegro (ES1988) sound cards
|
|
Packit Service |
f0277f |
* Copyright (c) 2006 Clemens Ladisch <clemens@ladisch.de>
|
|
Packit Service |
f0277f |
*
|
|
Packit Service |
f0277f |
*
|
|
Packit Service |
f0277f |
* Permission to use, copy, modify, and distribute this software for any
|
|
Packit Service |
f0277f |
* purpose with or without fee is hereby granted, provided that the above
|
|
Packit Service |
f0277f |
* copyright notice and this permission notice appear in all copies.
|
|
Packit Service |
f0277f |
*
|
|
Packit Service |
f0277f |
* The software is provided "as is" and the author disclaims all warranties
|
|
Packit Service |
f0277f |
* with regard to this software including all implied warranties of
|
|
Packit Service |
f0277f |
* merchantability and fitness. In no event shall the author be liable for
|
|
Packit Service |
f0277f |
* any special, direct, indirect, or consequential damages or any damages
|
|
Packit Service |
f0277f |
* whatsoever resulting from loss of use, data or profits, whether in an
|
|
Packit Service |
f0277f |
* action of contract, negligence or other tortious action, arising out of
|
|
Packit Service |
f0277f |
* or in connection with the use or performance of this software.
|
|
Packit Service |
f0277f |
*/
|
|
Packit Service |
f0277f |
|
|
Packit Service |
f0277f |
#include <stdio.h>
|
|
Packit Service |
f0277f |
#include <stdlib.h>
|
|
Packit Service |
f0277f |
|
|
Packit Service |
f0277f |
#define ARRAY_SIZE(a) (sizeof(a) / sizeof *(a))
|
|
Packit Service |
f0277f |
|
|
Packit Service |
f0277f |
typedef unsigned short u16;
|
|
Packit Service |
f0277f |
|
|
Packit Service |
f0277f |
#include "maestro3.h"
|
|
Packit Service |
f0277f |
|
|
Packit Service |
f0277f |
static void write_file(const char *filename,
|
|
Packit Service |
f0277f |
const unsigned short data[], size_t size)
|
|
Packit Service |
f0277f |
{
|
|
Packit Service |
f0277f |
FILE *f;
|
|
Packit Service |
f0277f |
size_t i;
|
|
Packit Service |
f0277f |
|
|
Packit Service |
f0277f |
fprintf(stderr, "writing %s ...\n", filename);
|
|
Packit Service |
f0277f |
f = fopen(filename, "wb");
|
|
Packit Service |
f0277f |
if (!f) {
|
|
Packit Service |
f0277f |
perror("cannot create file");
|
|
Packit Service |
f0277f |
exit(EXIT_FAILURE);
|
|
Packit Service |
f0277f |
}
|
|
Packit Service |
f0277f |
for (i = 0; i < size; ++i) {
|
|
Packit Service |
f0277f |
/* write as little-endian 16-bit values */
|
|
Packit Service |
f0277f |
if (fputc(data[i] & 0xff, f) == EOF ||
|
|
Packit Service |
f0277f |
fputc((data[i] >> 8) & 0xff, f) == EOF)
|
|
Packit Service |
f0277f |
break;
|
|
Packit Service |
f0277f |
}
|
|
Packit Service |
f0277f |
if (ferror(f) || fclose(f) == EOF) {
|
|
Packit Service |
f0277f |
perror("cannot write");
|
|
Packit Service |
f0277f |
exit(EXIT_FAILURE);
|
|
Packit Service |
f0277f |
}
|
|
Packit Service |
f0277f |
}
|
|
Packit Service |
f0277f |
|
|
Packit Service |
f0277f |
int main(void)
|
|
Packit Service |
f0277f |
{
|
|
Packit Service |
f0277f |
write_file("maestro3_assp_kernel.fw",
|
|
Packit Service |
f0277f |
assp_kernel_image, ARRAY_SIZE(assp_kernel_image));
|
|
Packit Service |
f0277f |
write_file("maestro3_assp_minisrc.fw",
|
|
Packit Service |
f0277f |
assp_minisrc_image, ARRAY_SIZE(assp_minisrc_image));
|
|
Packit Service |
f0277f |
return 0;
|
|
Packit Service |
f0277f |
}
|