From 811263d9f15dd845d0c2bb1d34bb02776ff1ad28 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 20 Dec 2004 11:32:34 +0000 Subject: [PATCH] Hotplug firmware loader support New configure options, --disable-hotplug, --disable-loader and --with-hotplug-dir. As default, the firmware files will be installed to the paths for both hotplug and ALSA fw loaders. --- README | 36 +++++++++++++++++++-- configure.in | 18 +++++++++++ mixartloader/Makefile.am | 20 ++++++++++-- vxloader/Makefile.am | 34 +++++++++++++++++--- vxloader/toxlx.c | 68 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 167 insertions(+), 9 deletions(-) create mode 100644 vxloader/toxlx.c diff --git a/README b/README index 719013f..683de59 100644 --- a/README +++ b/README @@ -1,5 +1,37 @@ +GENERAL +======= + This package contains the firmware binaries for each loader program -included in alsa-tools package. Specify the same prefix option given -to the alsa-tools configure script, too, in order to keep the +included in alsa-tools package. The firmware data can be used by each +ALSA firmware loader program like vxloader, or passed through the +hotplug firmware-loading mechanism. + + +HOTPLUG FIRMWARE LOADER SUPPORT +=============================== + +The recent ALSA driver supports the hotplug firmware loader. +As default, the package will install firmware data to the places for +both the old ALSA fw loader and the hotplug fw loader. To disable +the installation of old ALSA fw loader data (if both ALSA and hotplug +fw loaders are available), pass --disable-loader to configure. +Similarly, to disable the hotplug fw loader data, pass +--disable-hotplug option. + +For the old ALSA fw loader, specify the same prefix option given to +the alsa-tools configure script, too, in order to keep the installation directories consistent. +The default directory for hotplug firmware data files is +/usr/lib/hotplug/firmware. You can change to another path via +--with-hotplug-dir option. + + +LICENSE AND COPYRIGHT +===================== + +The files contained in this package is regarded as the example data +for each alsa-tools program. Hence, their copyright and license +follow basically to the definition of alsa-tools programs. The +detailed license and copyright is found in README of each +subdirectory. diff --git a/configure.in b/configure.in index 1f5e020..f8269f7 100644 --- a/configure.in +++ b/configure.in @@ -7,6 +7,24 @@ AC_HEADER_STDC echo $VERSION > $srcdir/version +AC_ARG_ENABLE(loader, + [ --disable-loader Disable the old ALSA fw loader support], + [loader="$enableval"],[loader=yes]) +AC_ARG_ENABLE(hotplug, + [ --disable-hotplug Disable the hotplug fw loader support], + [hotplug="$enableval"],[hotplug=yes]) + +AM_CONDITIONAL(USE_LOADER, test "$loader" = "yes") +AM_CONDITIONAL(USE_HOTPLUG, test "$hotplug" = "yes") + +AC_ARG_WITH(hotplug-dir, + [ --with-hotplug-dir Specify the hotplug firmware directory], + [hotplugfwdir="$withval"], + [hotplugfwdir="/usr/lib/hotplug/firmware"]) +HOTPLUGFWDIR="$hotplugfwdir" +AC_SUBST(HOTPLUGFWDIR) + + AC_OUTPUT(Makefile \ hdsploader/Makefile \ mixartloader/Makefile \ diff --git a/mixartloader/Makefile.am b/mixartloader/Makefile.am index 10213ee..41538d4 100644 --- a/mixartloader/Makefile.am +++ b/mixartloader/Makefile.am @@ -1,11 +1,25 @@ MYNAME = mixartloader -cfg_files = miXart.conf \ +cfg_files = miXart.conf +dsp_files = \ miXart8AES.xlx \ miXart8.elf \ miXart8.xlx -EXTRA_DIST = $(cfg_files) +EXTRA_DIST = $(cfg_files) $(dsp_files) +if USE_LOADER firmwaredir = $(datadir)/alsa/firmware/$(MYNAME) -firmware_DATA = $(cfg_files) +firmware_DATA = $(cfg_files) $(dsp_files) +else +firmwaredir = +firmware_DATA = +endif + +if USE_HOTPLUG +hotplugfwdir = @HOTPLUGFWDIR@/mixart +hotplugfw_DATA = $(dsp_files) +else +hotplugfwdir = +hotplugfw_DATA = +endif diff --git a/vxloader/Makefile.am b/vxloader/Makefile.am index 7d0c1b1..ca21494 100644 --- a/vxloader/Makefile.am +++ b/vxloader/Makefile.am @@ -1,6 +1,8 @@ MYNAME = vxloader -cfg_files = vx222.conf vxboard.conf vxpocket.conf vxp440.conf \ +cfg_files = vx222.conf vxboard.conf vxpocket.conf vxp440.conf + +dsp_files = \ bd56002.boot \ bd563s3.boot \ bd563v2.boot \ @@ -9,13 +11,37 @@ cfg_files = vx222.conf vxboard.conf vxpocket.conf vxp440.conf \ l_1_v22.d56 \ l_1_vx2.d56 \ l_1_vxp.d56 \ - l_1_vp4.d56 \ + l_1_vp4.d56 + +rbt_files = \ x1_2_v22.rbt \ x1_1_vx2.rbt \ x1_1_vxp.rbt \ x1_1_vp4.rbt -EXTRA_DIST = $(cfg_files) +xlx_files = $(rbt_files:%.rbt=%.xlx) + +noinst_PROGRAMS = toxlx +toxlx_SOURCES = toxlx.c +EXTRA_DIST = $(cfg_files) $(dsp_files) $(rbt_files) toxlx.c +CLEANFILES = $(xlx_files) + +if USE_LOADER firmwaredir = $(datadir)/alsa/firmware/$(MYNAME) -firmware_DATA = $(cfg_files) +firmware_DATA = $(cfg_files) $(dsp_files) $(rbt_files) +else +firmwaredir = +firmware_DATA = +endif + +if USE_HOTPLUG +hotplugfwdir = @HOTPLUGFWDIR@/vx +hotplugfw_DATA = $(dsp_files) $(xlx_files) +else +hotplugfwdir = +hotplugfw_DATA = +endif + +%.xlx: %.rbt toxlx + ./toxlx < $< > $@ diff --git a/vxloader/toxlx.c b/vxloader/toxlx.c new file mode 100644 index 0000000..807b9ac --- /dev/null +++ b/vxloader/toxlx.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +int main() +{ + char buf[256]; + int data, c, idx, length; + unsigned char *imgbuf = NULL; + char *p; + + c = 0; + data = 0; + idx = 0; + length = 0; + while (fgets(buf, sizeof(buf), stdin)) { + if (strncmp(buf, "Bits:", 5) == 0) { + for (p = buf + 5; *p && isspace(*p); p++) + ; + if (! *p) { + fprintf(stderr, "corrupted file in Bits line\n"); + return 1; + } + length = atoi(p); + length /= 8; + if (length <= 0) { + fprintf(stderr, "corrupted file, detected length = %d\n", length); + return 1; + } + imgbuf = malloc(length); + if (! imgbuf) { + fprintf(stderr, "cannot alloc %d bytes\n", length); + return 1; + } + continue; + } + if (buf[0] != '0' && buf[1] != '1') + continue; + if (length <= 0) { + fprintf(stderr, "corrupted file, starting without Bits line\n"); + return 1; + } + for (p = buf; *p == '0' || *p == '1'; p++) { + data |= (*p - '0') << c; + c++; + if (c >= 8) { + imgbuf[idx] = data; + data = 0; + c = 0; + idx++; + if (idx >= length) + break; + } + } + } + if (c) + imgbuf[idx++] = data; + if (idx != length) { + fprintf(stderr, "length doesn't match: %d != %d\n", idx, length); + return 1; + } + + for (idx = 0; idx < length; idx++) + putchar(imgbuf[idx]); + + return 0; +} -- 2.47.1