From bd058238545bc82790bd6800970d73cc8a1c7155 Mon Sep 17 00:00:00 2001 From: pbd Date: Fri, 17 May 2002 02:39:47 +0000 Subject: [PATCH] add ice1712 support to alsa driver git-svn-id: svn+ssh://jackaudio.org/trunk/jack@196 0c269be4-1314-0410-8aa9-9f06e86f4224 --- Makefile.am | 2 +- configure.in | 2 +- drivers/alsa/Makefile.am | 3 +- drivers/alsa/alsa_driver.c | 15 +++- drivers/alsa/ice1712.c | 152 +++++++++++++++++++++++++++++++++++++ jackd/Makefile.am | 2 +- 6 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 drivers/alsa/ice1712.c diff --git a/Makefile.am b/Makefile.am index aede8d1..d105587 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,4 +24,4 @@ pkgconfig_DATA = jack.pc rpm: dist rpm -ta $(distdir).tar.gz -dist-hook: dist-check-doxygen \ No newline at end of file +dist-hook: dist-check-doxygen diff --git a/configure.in b/configure.in index 305155c..528b3a3 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ AC_INIT(jackd/jackd.c) AC_CONFIG_AUX_DIR(.) JACK_MAJOR_VERSION=0 -JACK_MINOR_VERSION=31 +JACK_MINOR_VERSION=32 JACK_MICRO_VERSION=0 BETA= diff --git a/drivers/alsa/Makefile.am b/drivers/alsa/Makefile.am index 3a63b8f..0ddda2d 100644 --- a/drivers/alsa/Makefile.am +++ b/drivers/alsa/Makefile.am @@ -5,5 +5,6 @@ plugindir = $(ADDON_DIR) plugin_LTLIBRARIES = jack_alsa.la jack_alsa_la_LDFLAGS = -module -jack_alsa_la_SOURCES = alsa_driver.c hammerfall.c generic_hw.c memops.c +jack_alsa_la_SOURCES = alsa_driver.c generic_hw.c memops.c \ + hammerfall.c ice1712.c jack_alsa_la_LIBADD = -lasound $(GLIB_LIBS) -lm diff --git a/drivers/alsa/alsa_driver.c b/drivers/alsa/alsa_driver.c index a832192..fee3f28 100644 --- a/drivers/alsa/alsa_driver.c +++ b/drivers/alsa/alsa_driver.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,14 @@ alsa_driver_hammerfall_hardware (alsa_driver_t *driver) return 0; } +static int +alsa_driver_ice1712_hardware (alsa_driver_t *driver) + +{ + driver->hw = jack_alsa_ice1712_hw_new (driver); + return 0; +} + static int alsa_driver_generic_hardware (alsa_driver_t *driver) @@ -124,8 +133,12 @@ alsa_driver_hw_specific (alsa_driver_t *driver, int hw_monitoring) if ((err = alsa_driver_hammerfall_hardware (driver)) != 0) { return err; } + } else if (!strcmp(driver->alsa_driver, "ICE1712")) { + if ((err = alsa_driver_ice1712_hardware (driver)) !=0) { + return err; + } } else { - if ((err = alsa_driver_generic_hardware (driver)) != 0) { + if ((err = alsa_driver_generic_hardware (driver)) != 0) { return err; } } diff --git a/drivers/alsa/ice1712.c b/drivers/alsa/ice1712.c new file mode 100644 index 0000000..489aaa7 --- /dev/null +++ b/drivers/alsa/ice1712.c @@ -0,0 +1,152 @@ +/* + Copyright (C) 2002 Anthony Van Groningen + + Parts based on source code taken from the + "Env24 chipset (ICE1712) control utility" that is + + Copyright (C) 2000 by Jaroslav Kysela + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include +#include +#include + +static int +ice1712_hw_monitor_toggle(jack_hardware_t *hw, int idx, int onoff) + +{ + ice1712_t *h = (ice1712_t *) hw->private; + snd_ctl_elem_value_t *val; + int err; + + snd_ctl_elem_value_alloca (&val); + snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_MIXER); + if (idx >= 8) { + snd_ctl_elem_value_set_name (val, SPDIF_PLAYBACK_ROUTE_NAME); + snd_ctl_elem_value_set_index (val, idx - 8); + } else { + snd_ctl_elem_value_set_name (val, ANALOG_PLAYBACK_ROUTE_NAME); + snd_ctl_elem_value_set_index (val, idx); + } + if (onoff) { + snd_ctl_elem_value_set_enumerated (val, 0, idx + 1); + } else { + snd_ctl_elem_value_set_enumerated (val, 0, 0); + } + if ((err = snd_ctl_elem_write (h->driver->ctl_handle, val)) != 0) { + jack_error ("ALSA/ICE1712: (%d) cannot set input monitoring (%s)", + idx,snd_strerror (err)); + return -1; + } + + return 0; +} + +static int +ice1712_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask) + +{ + int idx; + ice1712_t *h = (ice1712_t *) hw->private; + + for (idx = 0; idx < 10; idx++) { + if (h->active_channels & (1<input_monitor_mask = mask; + + return 0; +} + +static int +ice1712_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode) + +{ + return -1; +} + +static void +ice1712_release (jack_hardware_t *hw) + +{ + return; +} + + + + +jack_hardware_t * +jack_alsa_ice1712_hw_new (alsa_driver_t *driver) + +{ + jack_hardware_t *hw; + ice1712_t *h; + snd_ctl_elem_value_t *val; + int err; + + hw = (jack_hardware_t *) malloc (sizeof (jack_hardware_t)); + + hw->capabilities = Cap_HardwareMonitoring; + hw->input_monitor_mask = 0; + hw->private = 0; + + hw->set_input_monitor_mask = ice1712_set_input_monitor_mask; + hw->change_sample_clock = ice1712_change_sample_clock; + hw->release = ice1712_release; + + h = (ice1712_t *) malloc (sizeof (ice1712_t)); + + h->driver = driver; + + /* Get the EEPROM (adopted from envy24control) */ + h->eeprom = (ice1712_eeprom_t *) malloc (sizeof (ice1712_eeprom_t)); + snd_ctl_elem_value_alloca (&val); + snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_CARD); + snd_ctl_elem_value_set_name (val, "ICE1712 EEPROM"); + if ((err = snd_ctl_elem_read (driver->ctl_handle, val)) < 0) { + jack_error( "ALSA/ICE1712: Unable to read EEPROM contents (%s)\n", snd_strerror (err)); + /* Recover? */ + } + memcpy(h->eeprom, snd_ctl_elem_value_get_bytes(val), 32); + + /* determine number of pro ADC's. We're asumming that there is at least one stereo pair. + Should check this first, but how? */ + switch((h->eeprom->codec & 0xCU) >> 2) { + case 0: + h->active_channels = 0x3U; + break; + case 1: + h->active_channels = 0xfU; + break; + case 2: + h->active_channels = 0x3fU; + break; + case 3: + h->active_channels = 0xffU; + break; + } + /* check for SPDIF In's */ + if (h->eeprom->spdif & 0x1U) { + h->active_channels |= 0x300U; + } + + hw->private = h; + + return hw; +} diff --git a/jackd/Makefile.am b/jackd/Makefile.am index 7257bef..4fa5626 100644 --- a/jackd/Makefile.am +++ b/jackd/Makefile.am @@ -6,7 +6,7 @@ else bin_PROGRAMS = jackd endif -AM_CFLAGS = -I.. $(JACK_CFLAGS) -DADDON_DIR=\"$(ADDON_DIR)\" $(GLIB_CFLAGS) +AM_CFLAGS = $(JACK_CFLAGS) -DADDON_DIR=\"$(ADDON_DIR)\" $(GLIB_CFLAGS) jackd_SOURCES = jackd.c engine.c jackd_LDADD = ../libjack/libjack.la