2 Copyright (C) 2002 Anthony Van Groningen
4 Parts based on source code taken from the
5 "Env24 chipset (ICE1712) control utility" that is
7 Copyright (C) 2000 by Jaroslav Kysela <perex@suse.cz>
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.
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.
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.
25 #include "alsa_driver.h"
27 #include "JackError.h"
30 ice1712_hw_monitor_toggle(jack_hardware_t
*hw
, int idx
, int onoff
)
32 ice1712_t
*h
= (ice1712_t
*) hw
->private_hw
;
33 snd_ctl_elem_value_t
*val
;
36 snd_ctl_elem_value_alloca (&val
);
37 snd_ctl_elem_value_set_interface (val
, SND_CTL_ELEM_IFACE_MIXER
);
39 snd_ctl_elem_value_set_name (val
, SPDIF_PLAYBACK_ROUTE_NAME
);
40 snd_ctl_elem_value_set_index (val
, idx
- 8);
42 snd_ctl_elem_value_set_name (val
, ANALOG_PLAYBACK_ROUTE_NAME
);
43 snd_ctl_elem_value_set_index (val
, idx
);
46 snd_ctl_elem_value_set_enumerated (val
, 0, idx
+ 1);
48 snd_ctl_elem_value_set_enumerated (val
, 0, 0);
50 if ((err
= snd_ctl_elem_write (h
->driver
->ctl_handle
, val
)) != 0) {
51 jack_error ("ALSA/ICE1712: (%d) cannot set input monitoring (%s)",
52 idx
,snd_strerror (err
));
60 ice1712_set_input_monitor_mask (jack_hardware_t
*hw
, unsigned long mask
)
63 ice1712_t
*h
= (ice1712_t
*) hw
->private_hw
;
65 for (idx
= 0; idx
< 10; idx
++) {
66 if (h
->active_channels
& (1<<idx
)) {
67 ice1712_hw_monitor_toggle (hw
, idx
, mask
& (1<<idx
) ? 1 : 0);
70 hw
->input_monitor_mask
= mask
;
76 ice1712_change_sample_clock (jack_hardware_t
*hw
, SampleClockMode mode
)
82 ice1712_release (jack_hardware_t
*hw
)
84 ice1712_t
*h
= (ice1712_t
*) hw
->private_hw
;
97 jack_alsa_ice1712_hw_new (alsa_driver_t
*driver
)
101 snd_ctl_elem_value_t
*val
;
104 hw
= (jack_hardware_t
*) malloc (sizeof (jack_hardware_t
));
106 hw
->capabilities
= Cap_HardwareMonitoring
;
107 hw
->input_monitor_mask
= 0;
110 hw
->set_input_monitor_mask
= ice1712_set_input_monitor_mask
;
111 hw
->change_sample_clock
= ice1712_change_sample_clock
;
112 hw
->release
= ice1712_release
;
114 h
= (ice1712_t
*) malloc (sizeof (ice1712_t
));
118 /* Get the EEPROM (adopted from envy24control) */
119 h
->eeprom
= (ice1712_eeprom_t
*) malloc (sizeof (ice1712_eeprom_t
));
120 snd_ctl_elem_value_alloca (&val
);
121 snd_ctl_elem_value_set_interface (val
, SND_CTL_ELEM_IFACE_CARD
);
122 snd_ctl_elem_value_set_name (val
, "ICE1712 EEPROM");
123 if ((err
= snd_ctl_elem_read (driver
->ctl_handle
, val
)) < 0) {
124 jack_error( "ALSA/ICE1712: Unable to read EEPROM contents (%s)\n", snd_strerror (err
));
127 memcpy(h
->eeprom
, snd_ctl_elem_value_get_bytes(val
), 32);
129 /* determine number of pro ADC's. We're asumming that there is at least one stereo pair.
130 Should check this first, but how? */
131 switch((h
->eeprom
->codec
& 0xCU
) >> 2) {
133 h
->active_channels
= 0x3U
;
136 h
->active_channels
= 0xfU
;
139 h
->active_channels
= 0x3fU
;
142 h
->active_channels
= 0xffU
;
145 /* check for SPDIF In's */
146 if (h
->eeprom
->spdif
& 0x1U
) {
147 h
->active_channels
|= 0x300U
;