~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
JACK/drivers/alsa/ice1712.c


** Warning: Cannot open xref database.

1 /* 2 Copyright (C) 2002 Anthony Van Groningen 3 4 Parts based on source code taken from the 5 "Env24 chipset (ICE1712) control utility" that is 6 7 Copyright (C) 2000 by Jaroslav Kysela <perex@suse.cz> 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 2 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 */ 23 24 #include <jack/hardware.h> 25 #include "alsa_driver.h" 26 #include "ice1712.h" 27 #include <jack/internal.h> 28 29 static int 30 ice1712_hw_monitor_toggle(jack_hardware_t *hw, int idx, int onoff) 31 32 { 33 ice1712_t *h = (ice1712_t *) hw->private; 34 snd_ctl_elem_value_t *val; 35 int err; 36 37 snd_ctl_elem_value_alloca (&val); 38 snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_MIXER); 39 if (idx >= 8) { 40 snd_ctl_elem_value_set_name (val, SPDIF_PLAYBACK_ROUTE_NAME); 41 snd_ctl_elem_value_set_index (val, idx - 8); 42 } else { 43 snd_ctl_elem_value_set_name (val, ANALOG_PLAYBACK_ROUTE_NAME); 44 snd_ctl_elem_value_set_index (val, idx); 45 } 46 if (onoff) { 47 snd_ctl_elem_value_set_enumerated (val, 0, idx + 1); 48 } else { 49 snd_ctl_elem_value_set_enumerated (val, 0, 0); 50 } 51 if ((err = snd_ctl_elem_write (h->driver->ctl_handle, val)) != 0) { 52 jack_error ("ALSA/ICE1712: (%d) cannot set input monitoring (%s)", 53 idx,snd_strerror (err)); 54 return -1; 55 } 56 57 return 0; 58 } 59 60 static int 61 ice1712_set_input_monitor_mask (jack_hardware_t *hw, unsigned long mask) 62 63 { 64 int idx; 65 ice1712_t *h = (ice1712_t *) hw->private; 66 67 for (idx = 0; idx < 10; idx++) { 68 if (h->active_channels & (1<<idx)) { 69 ice1712_hw_monitor_toggle (hw, idx, mask & (1<<idx) ? 1 : 0); 70 } 71 } 72 hw->input_monitor_mask = mask; 73 74 return 0; 75 } 76 77 static int 78 ice1712_change_sample_clock (jack_hardware_t *hw, SampleClockMode mode) 79 80 { 81 return -1; 82 } 83 84 static void 85 ice1712_release (jack_hardware_t *hw) 86 87 { 88 return; 89 } 90 91 92 93 94 jack_hardware_t * 95 jack_alsa_ice1712_hw_new (alsa_driver_t *driver) 96 97 { 98 jack_hardware_t *hw; 99 ice1712_t *h; 100 snd_ctl_elem_value_t *val; 101 int err; 102 103 hw = (jack_hardware_t *) malloc (sizeof (jack_hardware_t)); 104 105 hw->capabilities = Cap_HardwareMonitoring; 106 hw->input_monitor_mask = 0; 107 hw->private = 0; 108 109 hw->set_input_monitor_mask = ice1712_set_input_monitor_mask; 110 hw->change_sample_clock = ice1712_change_sample_clock; 111 hw->release = ice1712_release; 112 113 h = (ice1712_t *) malloc (sizeof (ice1712_t)); 114 115 h->driver = driver; 116 117 /* Get the EEPROM (adopted from envy24control) */ 118 h->eeprom = (ice1712_eeprom_t *) malloc (sizeof (ice1712_eeprom_t)); 119 snd_ctl_elem_value_alloca (&val); 120 snd_ctl_elem_value_set_interface (val, SND_CTL_ELEM_IFACE_CARD); 121 snd_ctl_elem_value_set_name (val, "ICE1712 EEPROM"); 122 if ((err = snd_ctl_elem_read (driver->ctl_handle, val)) < 0) { 123 jack_error( "ALSA/ICE1712: Unable to read EEPROM contents (%s)\n", snd_strerror (err)); 124 /* Recover? */ 125 } 126 memcpy(h->eeprom, snd_ctl_elem_value_get_bytes(val), 32); 127 128 /* determine number of pro ADC's. We're asumming that there is at least one stereo pair. 129 Should check this first, but how? */ 130 switch((h->eeprom->codec & 0xCU) >> 2) { 131 case 0: 132 h->active_channels = 0x3U; 133 break; 134 case 1: 135 h->active_channels = 0xfU; 136 break; 137 case 2: 138 h->active_channels = 0x3fU; 139 break; 140 case 3: 141 h->active_channels = 0xffU; 142 break; 143 } 144 /* check for SPDIF In's */ 145 if (h->eeprom->spdif & 0x1U) { 146 h->active_channels |= 0x300U; 147 } 148 149 hw->private = h; 150 151 return hw; 152 } 153

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.