diff options
-rw-r--r-- | sys/dev/microcode/neomagic/Makefile | 23 | ||||
-rw-r--r-- | sys/dev/microcode/neomagic/build.c | 45 | ||||
-rw-r--r-- | sys/dev/microcode/neomagic/neo-coeff.h | 4 | ||||
-rw-r--r-- | sys/dev/microcode/neomagic/neo-license | 27 | ||||
-rw-r--r-- | sys/dev/pci/neo.c | 23 |
5 files changed, 115 insertions, 7 deletions
diff --git a/sys/dev/microcode/neomagic/Makefile b/sys/dev/microcode/neomagic/Makefile new file mode 100644 index 00000000000..6f762f25781 --- /dev/null +++ b/sys/dev/microcode/neomagic/Makefile @@ -0,0 +1,23 @@ +# $OpenBSD: Makefile,v 1.1 2004/11/22 04:29:06 deraadt Exp $ + +NOPROG= +NOMAN= + +.if (${MACHINE} == "i386") + +FIRM= neo-coefficients + +CLEANFILES+= ${FIRM} build + +all: build + ${.OBJDIR}/build + +afterinstall: + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ + ${FIRM} ${DESTDIR}/etc/firmware + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ + ${.CURDIR}/neo-license ${DESTDIR}/etc/firmware +.endif + +.include <bsd.prog.mk> + diff --git a/sys/dev/microcode/neomagic/build.c b/sys/dev/microcode/neomagic/build.c new file mode 100644 index 00000000000..8b76aa39502 --- /dev/null +++ b/sys/dev/microcode/neomagic/build.c @@ -0,0 +1,45 @@ +/* $OpenBSD: build.c,v 1.1 2004/11/22 04:29:06 deraadt Exp $ */ + +/* + * Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include <sys/types.h> +#include <fcntl.h> +#include <dev/pci/neoreg.h> + +#include "neo-coeff.h" + +#define FILENAME "neo-coefficients" + +int +main(int argc, char *argv[]) +{ + struct neo_firmware nf; + int fd, i; + + fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644); + if (fd == -1) + err(1, FILENAME); + + bcopy(coefficientSizes, &nf.coefficientSizes, + sizeof nf.coefficientSizes); + bcopy(coefficients, &nf.coefficients, + sizeof nf.coefficients); + + write(fd, &nf, sizeof nf); + printf("created %s length %d\n", FILENAME, sizeof nf); + close(fd); + return (0); +} diff --git a/sys/dev/microcode/neomagic/neo-coeff.h b/sys/dev/microcode/neomagic/neo-coeff.h index adcb5811df8..fb5f77b6e59 100644 --- a/sys/dev/microcode/neomagic/neo-coeff.h +++ b/sys/dev/microcode/neomagic/neo-coeff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: neo-coeff.h,v 1.1 2001/06/18 19:27:19 deraadt Exp $ */ +/* $OpenBSD: neo-coeff.h,v 1.2 2004/11/22 04:29:06 deraadt Exp $ */ /* * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> @@ -4630,7 +4630,7 @@ static const char coefficients[NM_TOTAL_COEFF_COUNT * 4] = { }; static const u_int16_t -coefficientSizes[] = { +coefficientSizes[NM_COEFF_SIZES] = { /* Playback */ 0x00C0, 0x5000, 0x0060, 0x2800, 0x0040, 0x0060, 0x1400, 0x0000, /* Record */ diff --git a/sys/dev/microcode/neomagic/neo-license b/sys/dev/microcode/neomagic/neo-license new file mode 100644 index 00000000000..0946695c97d --- /dev/null +++ b/sys/dev/microcode/neomagic/neo-license @@ -0,0 +1,27 @@ + * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> + * All rights reserved. + * + * Derived from the public domain Linux driver + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF + * SUCH DAMAGE. + +This license applies to the neo-coefficient file. diff --git a/sys/dev/pci/neo.c b/sys/dev/pci/neo.c index 1009d3e90d8..102d3047eb4 100644 --- a/sys/dev/pci/neo.c +++ b/sys/dev/pci/neo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neo.c,v 1.16 2003/04/27 11:22:53 ho Exp $ */ +/* $OpenBSD: neo.c,v 1.17 2004/11/22 04:29:06 deraadt Exp $ */ /* * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> @@ -48,7 +48,7 @@ #include <dev/ic/ac97.h> #include <dev/pci/neoreg.h> -#include <dev/microcode/neomagic/neo-coeff.h> +//#include <dev/microcode/neomagic/neo-coeff.h> /* -------------------------------------------------------------------- */ /* @@ -159,6 +159,8 @@ struct neo_softc { void *powerhook; }; +static struct neo_firmware *nf; + /* -------------------------------------------------------------------- */ /* @@ -393,15 +395,26 @@ nm_loadcoeff(struct neo_softc *sc, int dir, int num) int ofs, sz, i; u_int32_t addr; + if (nf == NULL) { + size_t buflen; + u_char *buf; + int error; + + error = loadfirmware("neo-coefficients", &buf, &buflen); + if (error) + return (error); + nf = (struct neo_firmware *)buf; + } + addr = (dir == AUMODE_PLAY)? 0x01c : 0x21c; if (dir == AUMODE_RECORD) num += 8; - sz = coefficientSizes[num]; + sz = nf->coefficientSizes[num]; ofs = 0; while (num-- > 0) - ofs+= coefficientSizes[num]; + ofs+= nf->coefficientSizes[num]; for (i = 0; i < sz; i++) - nm_wrbuf(sc, sc->cbuf + i, coefficients[ofs + i], 1); + nm_wrbuf(sc, sc->cbuf + i, nf->coefficients[ofs + i], 1); nm_wr(sc, addr, sc->cbuf, 4); if (dir == AUMODE_PLAY) sz--; |