| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | /*****************************************************************************
 | 
					
						
							|  |  |  |    hardware.c - Hardware Settings | 
					
						
							| 
									
										
										
										
											2007-10-15 10:25:36 +02:00
										 |  |  |    Copyright (C) 2000 by Jaroslav Kysela <perex@perex.cz> | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  |     | 
					
						
							|  |  |  |    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 | 
					
						
							| 
									
										
										
										
											2017-11-14 14:46:35 +01:00
										 |  |  |    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | ******************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "envy24control.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | static snd_ctl_elem_value_t *internal_clock; | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | static snd_ctl_elem_value_t *internal_clock_default; | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | static snd_ctl_elem_value_t *word_clock_sync; | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | static snd_ctl_elem_value_t *rate_locking; | 
					
						
							|  |  |  | static snd_ctl_elem_value_t *rate_reset; | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | static snd_ctl_elem_value_t *volume_rate; | 
					
						
							|  |  |  | static snd_ctl_elem_value_t *spdif_input; | 
					
						
							|  |  |  | static snd_ctl_elem_value_t *spdif_output; | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | static snd_ctl_elem_value_t *analog_input_select; | 
					
						
							|  |  |  | static snd_ctl_elem_value_t *breakbox_led; | 
					
						
							|  |  |  | static snd_ctl_elem_value_t *spdif_on_off; | 
					
						
							|  |  |  | static snd_ctl_elem_value_t *phono_input; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | static inline int is_update_needed(void); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | #define toggle_set(widget, state) \
 | 
					
						
							|  |  |  | 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), state); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int is_active(GtkWidget *widget) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void master_clock_update(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | 	int err, rate, need_default_update; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_read(ctl, internal_clock)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read Internal Clock state: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_read(ctl, internal_clock_default)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read Internal Clock Default state: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2004-02-19 10:44:53 +00:00
										 |  |  | 	if (card_eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010 || | 
					
						
							|  |  |  | 	    card_eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010LT) { | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 		if ((err = snd_ctl_elem_read(ctl, word_clock_sync)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			g_print("Unable to read word clock sync selection: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	if (snd_ctl_elem_value_get_enumerated(internal_clock, 0) == 13) { | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 		if (snd_ctl_elem_value_get_boolean(word_clock_sync, 0)) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			toggle_set(hw_master_clock_word_radio, TRUE); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			toggle_set(hw_master_clock_spdif_radio, TRUE); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | //		toggle_set(hw_master_clock_xtal_radio, TRUE);
 | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | 		need_default_update = !is_update_needed() ? 1 : 0; | 
					
						
							|  |  |  | 		if (need_default_update) { | 
					
						
							|  |  |  | 			rate = snd_ctl_elem_value_get_enumerated(internal_clock_default, 0); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			rate = snd_ctl_elem_value_get_enumerated(internal_clock, 0); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 		switch (rate) { | 
					
						
							|  |  |  | 		case 5: toggle_set(hw_master_clock_xtal_22050, TRUE); break; | 
					
						
							|  |  |  | 		case 7: toggle_set(hw_master_clock_xtal_32000, TRUE); break; | 
					
						
							|  |  |  | 		case 8: toggle_set(hw_master_clock_xtal_44100, TRUE); break; | 
					
						
							|  |  |  | 		case 9: toggle_set(hw_master_clock_xtal_48000, TRUE); break; | 
					
						
							|  |  |  | 		case 11: toggle_set(hw_master_clock_xtal_88200, TRUE); break; | 
					
						
							|  |  |  | 		case 12: toggle_set(hw_master_clock_xtal_96000, TRUE); break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			    g_print("Error in rate: %d\n", rate); | 
					
						
							|  |  |  | 			    break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-12-03 17:10:35 +00:00
										 |  |  | 	internal_clock_status_timeout_callback(NULL); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	master_clock_status_timeout_callback(NULL); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void master_clock_word_select(int on) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-02-19 10:44:53 +00:00
										 |  |  | 	if (card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTA1010 && | 
					
						
							|  |  |  | 	    card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTA1010LT) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_set_boolean(word_clock_sync, 0, on ? 1 : 0); | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_write(ctl, word_clock_sync)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to write word clock sync selection: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | static void internal_clock_set(int xrate) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	master_clock_word_select(0); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_enumerated(internal_clock, 0, xrate); | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_write(ctl, internal_clock)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to write internal clock rate: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void internal_clock_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	char *what = (char *) data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	if (!strcmp(what, "22050")) { | 
					
						
							|  |  |  | 		internal_clock_set(5); | 
					
						
							|  |  |  | 	} else if (!strcmp(what, "32000")) { | 
					
						
							|  |  |  | 		internal_clock_set(7); | 
					
						
							|  |  |  | 	} else if (!strcmp(what, "44100")) { | 
					
						
							|  |  |  | 		internal_clock_set(8); | 
					
						
							|  |  |  | 	} else if (!strcmp(what, "48000")) { | 
					
						
							|  |  |  | 		internal_clock_set(9); | 
					
						
							|  |  |  | 	} else if (!strcmp(what, "88200")) { | 
					
						
							|  |  |  | 		internal_clock_set(11); | 
					
						
							|  |  |  | 	} else if (!strcmp(what, "96000")) { | 
					
						
							|  |  |  | 		internal_clock_set(12); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(what, "SPDIF")) { | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 		internal_clock_set(13); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(what, "WordClock")) { | 
					
						
							| 
									
										
										
										
											2006-02-08 08:19:42 +00:00
										 |  |  | 		internal_clock_set(13); // 13 should be considered '!internal'
 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		master_clock_word_select(1); | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 		g_print("internal_clock_toggled: %s ???\n", what); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-12-03 17:10:35 +00:00
										 |  |  | static int is_rate_locked(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_read(ctl, rate_locking)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read rate locking state: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	return snd_ctl_elem_value_get_boolean(rate_locking, 0) ? 1 : 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int is_rate_reset(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_read(ctl, rate_reset)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read rate reset state: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	return snd_ctl_elem_value_get_boolean(rate_reset, 0) ? 1 : 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline int is_update_needed(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return (is_rate_locked() || !is_rate_reset()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | gint master_clock_status_timeout_callback(gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_t *sw; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	int err; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2006-02-10 08:43:45 +00:00
										 |  |  | 	if (card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTA1010 && card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTA1010LT) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return FALSE; | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_alloca(&sw); | 
					
						
							| 
									
										
										
										
											2005-11-28 18:15:09 +00:00
										 |  |  | 	snd_ctl_elem_value_set_interface(sw, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_set_name(sw, "Word Clock Status"); | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_read(ctl, sw)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to determine word clock status: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	gtk_label_set_text(GTK_LABEL(hw_master_clock_status_label), | 
					
						
							| 
									
										
										
										
											2006-01-02 14:25:53 +00:00
										 |  |  | 			   snd_ctl_elem_value_get_boolean(sw, 0) ? "No signal" : "Locked"); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	return TRUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-12-03 17:10:35 +00:00
										 |  |  | gint internal_clock_status_timeout_callback(gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err, rate, need_update; | 
					
						
							|  |  |  | 	char *label; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_read(ctl, internal_clock)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read Internal Clock state: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_read(ctl, internal_clock_default)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read Internal Clock Default state: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2004-02-19 10:44:53 +00:00
										 |  |  | 	if (card_eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010 || | 
					
						
							|  |  |  | 	    card_eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010LT) { | 
					
						
							| 
									
										
										
										
											2002-12-03 17:10:35 +00:00
										 |  |  | 		if ((err = snd_ctl_elem_read(ctl, word_clock_sync)) < 0) | 
					
						
							|  |  |  | 			g_print("Unable to read word clock sync selection: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	need_update = is_update_needed() ? 1 : 0; | 
					
						
							|  |  |  | 	if (snd_ctl_elem_value_get_enumerated(internal_clock, 0) == 13) { | 
					
						
							|  |  |  | 		if (snd_ctl_elem_value_get_boolean(word_clock_sync, 0)) { | 
					
						
							|  |  |  | 			label = "Word Clock"; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			label = "S/PDIF"; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | //		toggle_set(hw_master_clock_xtal_radio, TRUE);
 | 
					
						
							|  |  |  | 		rate = snd_ctl_elem_value_get_enumerated(internal_clock, 0); | 
					
						
							|  |  |  | //		g_print("Rate: %d need_update: %d\n", rate, need_update); // for debug
 | 
					
						
							|  |  |  | 		switch (rate) { | 
					
						
							|  |  |  | 		case 0: label = "8000"; break; | 
					
						
							|  |  |  | 		case 1: label = "9600"; break; | 
					
						
							|  |  |  | 		case 2: label = "11025"; break; | 
					
						
							|  |  |  | 		case 3: label = "12000"; break; | 
					
						
							|  |  |  | 		case 4: label = "16000"; break; | 
					
						
							|  |  |  | 		case 5: label = "22050"; | 
					
						
							|  |  |  | 			if (need_update) | 
					
						
							|  |  |  | 			toggle_set(hw_master_clock_xtal_22050, TRUE); break; | 
					
						
							|  |  |  | 		case 6: label = "24000"; break; | 
					
						
							|  |  |  | 		case 7: label = "32000"; | 
					
						
							|  |  |  | 			if (need_update) | 
					
						
							|  |  |  | 			toggle_set(hw_master_clock_xtal_32000, TRUE); break; | 
					
						
							|  |  |  | 		case 8: label = "44100"; | 
					
						
							|  |  |  | 			if (need_update) | 
					
						
							|  |  |  | 			toggle_set(hw_master_clock_xtal_44100, TRUE); break; | 
					
						
							|  |  |  | 		case 9: label = "48000"; | 
					
						
							|  |  |  | 			if (need_update) | 
					
						
							|  |  |  | 			toggle_set(hw_master_clock_xtal_48000, TRUE); break; | 
					
						
							|  |  |  | 		case 10: label = "64000"; break; | 
					
						
							|  |  |  | 		case 11: label = "88200"; | 
					
						
							|  |  |  | 			if (need_update) | 
					
						
							|  |  |  | 			toggle_set(hw_master_clock_xtal_88200, TRUE); break; | 
					
						
							|  |  |  | 		case 12: label = "96000"; | 
					
						
							|  |  |  | 			if (need_update) | 
					
						
							|  |  |  | 			toggle_set(hw_master_clock_xtal_96000, TRUE); break; | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			    label = "ERROR"; | 
					
						
							|  |  |  | 			    g_print("Error in rate: %d\n", rate); | 
					
						
							|  |  |  | 			    break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | 		if (!need_update) {	//default clock need update
 | 
					
						
							|  |  |  | 			rate = snd_ctl_elem_value_get_enumerated(internal_clock_default, 0); | 
					
						
							|  |  |  | 			switch (rate) { | 
					
						
							|  |  |  | 			case 5: toggle_set(hw_master_clock_xtal_22050, TRUE); break; | 
					
						
							|  |  |  | 			case 7: toggle_set(hw_master_clock_xtal_32000, TRUE); break; | 
					
						
							|  |  |  | 			case 8: toggle_set(hw_master_clock_xtal_44100, TRUE); break; | 
					
						
							|  |  |  | 			case 9: toggle_set(hw_master_clock_xtal_48000, TRUE); break; | 
					
						
							|  |  |  | 			case 11: toggle_set(hw_master_clock_xtal_88200, TRUE); break; | 
					
						
							|  |  |  | 			case 12: toggle_set(hw_master_clock_xtal_96000, TRUE); break; | 
					
						
							|  |  |  | 			default: | 
					
						
							|  |  |  | 				g_print("Error in rate: %d\n", rate); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-12-03 17:10:35 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	gtk_label_set_text(GTK_LABEL(hw_master_clock_actual_rate_label), label); | 
					
						
							|  |  |  | 	return TRUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | gint rate_locking_status_timeout_callback(gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int state; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (is_active(hw_rate_locking_check) != (state = is_rate_locked())) { | 
					
						
							|  |  |  | 	toggle_set(hw_rate_locking_check, state ? TRUE : FALSE); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return TRUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | gint rate_reset_status_timeout_callback(gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int state; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (is_active(hw_rate_reset_check) != (state = is_rate_reset())) { | 
					
						
							|  |  |  | 	toggle_set(hw_rate_reset_check, state ? TRUE : FALSE); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return TRUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | void rate_locking_update(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_read(ctl, rate_locking)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read rate locking state: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	if (snd_ctl_elem_value_get_boolean(rate_locking, 0)) | 
					
						
							|  |  |  | 			toggle_set(hw_rate_locking_check, TRUE); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void rate_reset_update(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_read(ctl, rate_reset)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read rate reset state: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	if (snd_ctl_elem_value_get_boolean(rate_reset, 0)) | 
					
						
							|  |  |  | 			toggle_set(hw_rate_reset_check, TRUE); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void rate_locking_set(int on) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_boolean(rate_locking, 0, on ? 1 : 0); | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_write(ctl, rate_locking)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to write rate locking state: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void rate_reset_set(int on) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_boolean(rate_reset, 0, on ? 1 : 0); | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_write(ctl, rate_reset)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to write rate reset state: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void rate_locking_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *what = (char *) data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!is_active(togglebutton)) { | 
					
						
							|  |  |  | 		rate_locking_set(0); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!strcmp(what, "locked")) { | 
					
						
							|  |  |  | 		rate_locking_set(1); | 
					
						
							| 
									
										
										
										
											2002-12-03 17:10:35 +00:00
										 |  |  | 		internal_clock_status_timeout_callback(NULL); | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	} else { | 
					
						
							|  |  |  | 		g_print("rate_locking_toggled: %s ???\n", what); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void rate_reset_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *what = (char *) data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!is_active(togglebutton)) { | 
					
						
							|  |  |  | 		rate_reset_set(0); | 
					
						
							| 
									
										
										
										
											2002-12-03 17:10:35 +00:00
										 |  |  | 		internal_clock_status_timeout_callback(NULL); | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (!strcmp(what, "reset")) { | 
					
						
							|  |  |  | 		rate_reset_set(1); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		g_print("rate_reset_toggled: %s ???\n", what); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | void volume_change_rate_update(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_read(ctl, volume_rate)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to read volume change rate: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	gtk_adjustment_set_value(GTK_ADJUSTMENT(hw_volume_change_adj), | 
					
						
							|  |  |  | 				 snd_ctl_elem_value_get_integer(volume_rate, 0)); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void volume_change_rate_adj(GtkAdjustment *adj, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_set_integer(volume_rate, 0, adj->value); | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_write(ctl, volume_rate)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to write volume change rate: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void spdif_output_update(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	int err; | 
					
						
							|  |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_read(ctl, spdif_output)) < 0) { | 
					
						
							|  |  |  | 		if (err == -ENOENT) | 
					
						
							|  |  |  | 			return; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to read Delta S/PDIF output state: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958); | 
					
						
							|  |  |  | 	if (!(iec958.status[0] & IEC958_AES0_PROFESSIONAL)) {		/* consumer */ | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		toggle_set(hw_spdif_consumer_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		if (iec958.status[0] & IEC958_AES0_CON_NOT_COPYRIGHT) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			toggle_set(hw_consumer_copyright_off_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			toggle_set(hw_consumer_copyright_on_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		if ((iec958.status[0] & IEC958_AES0_CON_EMPHASIS) != IEC958_AES0_CON_EMPHASIS_5015) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			toggle_set(hw_consumer_emphasis_none_radio, TRUE); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			toggle_set(hw_consumer_emphasis_5015_radio, TRUE); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		switch (iec958.status[1] & IEC958_AES1_CON_CATEGORY) { | 
					
						
							|  |  |  | 		case IEC958_AES1_CON_MAGNETIC_ID: toggle_set(hw_consumer_category_dat_radio, TRUE); break; | 
					
						
							|  |  |  | 		case IEC958_AES1_CON_DIGDIGCONV_ID: toggle_set(hw_consumer_category_pcm_radio, TRUE); break; | 
					
						
							|  |  |  | 		case IEC958_AES1_CON_GENERAL: toggle_set(hw_consumer_category_general_radio, TRUE); break; | 
					
						
							|  |  |  | 		case IEC958_AES1_CON_LASEROPT_ID: | 
					
						
							|  |  |  | 		default: toggle_set(hw_consumer_category_cd_radio, TRUE); break; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		if (iec958.status[1] & IEC958_AES1_CON_ORIGINAL) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			toggle_set(hw_consumer_copy_original_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			toggle_set(hw_consumer_copy_1st_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		toggle_set(hw_spdif_professional_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		if (!(iec958.status[0] & IEC958_AES0_NONAUDIO)) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			toggle_set(hw_spdif_profi_audio_radio, TRUE); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			toggle_set(hw_spdif_profi_nonaudio_radio, TRUE); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		switch (iec958.status[0] & IEC958_AES0_PRO_EMPHASIS) { | 
					
						
							|  |  |  | 		case IEC958_AES0_PRO_EMPHASIS_CCITT: toggle_set(hw_profi_emphasis_ccitt_radio, TRUE); break; | 
					
						
							|  |  |  | 		case IEC958_AES0_PRO_EMPHASIS_NONE: toggle_set(hw_profi_emphasis_none_radio, TRUE); break; | 
					
						
							|  |  |  | 		case IEC958_AES0_PRO_EMPHASIS_5015: toggle_set(hw_profi_emphasis_5015_radio, TRUE); break; | 
					
						
							|  |  |  | 		case IEC958_AES0_PRO_EMPHASIS_NOTID: | 
					
						
							|  |  |  | 		default: toggle_set(hw_profi_emphasis_notid_radio, TRUE); break; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		if ((iec958.status[1] & IEC958_AES1_PRO_MODE) == IEC958_AES1_PRO_MODE_STEREOPHONIC) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			toggle_set(hw_profi_stream_stereo_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			toggle_set(hw_profi_stream_notid_radio, TRUE); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void spdif_output_write(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_write(ctl, spdif_output)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to write Delta S/PDIF Output Defaults: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void profi_data_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	if (!(iec958.status[0] & IEC958_AES0_PROFESSIONAL)) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	if (!strcmp(str, "Audio")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] &= ~IEC958_AES0_NONAUDIO; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "Non-audio")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES0_NONAUDIO; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	spdif_output_write(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void profi_stream_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958); | 
					
						
							|  |  |  | 	if (!(iec958.status[0] & IEC958_AES0_PROFESSIONAL)) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	iec958.status[1] &= ~IEC958_AES1_PRO_MODE; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!strcmp(str, "NOTID")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES1_PRO_MODE_STEREOPHONIC; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "Stereo")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES1_PRO_MODE_NOTID; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	spdif_output_write(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void profi_emphasis_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	if (!(iec958.status[0] & IEC958_AES0_PROFESSIONAL)) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	iec958.status[0] &= ~IEC958_AES0_PRO_EMPHASIS; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!strcmp(str, "CCITT")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES0_PRO_EMPHASIS_CCITT; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "No")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES0_PRO_EMPHASIS_NONE; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "5015")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES0_PRO_EMPHASIS_5015; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "NOTID")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES0_PRO_EMPHASIS_NOTID; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	spdif_output_write(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void consumer_copyright_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958);	 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	if (iec958.status[0] & IEC958_AES0_PROFESSIONAL) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	if (!strcmp(str, "Copyright")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] &= ~IEC958_AES0_CON_NOT_COPYRIGHT; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "Permitted")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[1] |= IEC958_AES0_CON_NOT_COPYRIGHT; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	spdif_output_write(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void consumer_copy_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958);	 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	if (iec958.status[0] & IEC958_AES0_PROFESSIONAL) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	if (!strcmp(str, "1st")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES1_CON_ORIGINAL; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "Original")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[1] &= ~IEC958_AES1_CON_ORIGINAL; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	spdif_output_write(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void consumer_emphasis_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958);	 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	if (iec958.status[0] & IEC958_AES0_PROFESSIONAL) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	iec958.status[0] &= ~IEC958_AES0_CON_EMPHASIS; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!strcmp(str, "No")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES0_CON_EMPHASIS_NONE; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "5015")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[1] |= ~IEC958_AES0_CON_EMPHASIS_5015; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	spdif_output_write(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void consumer_category_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_get_iec958(spdif_output, &iec958);	 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	if (iec958.status[0] & IEC958_AES0_PROFESSIONAL) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	iec958.status[0] &= ~IEC958_AES1_CON_CATEGORY; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	if (!strcmp(str, "DAT")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES1_CON_DAT; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "PCM")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES1_CON_PCM_CODER; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "CD")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES1_CON_IEC908_CD; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} else if (!strcmp(str, "General")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		iec958.status[0] |= IEC958_AES1_CON_GENERAL; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	spdif_output_write(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void spdif_output_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 	snd_aes_iec958_t iec958; | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	int page; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (is_active(togglebutton)) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 		snd_ctl_elem_value_get_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		if (!strcmp(str, "Professional")) { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 			if (!(iec958.status[0] & IEC958_AES0_PROFESSIONAL)) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 				/* default setup: audio, no emphasis */ | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 				memset(&iec958, 0, sizeof(iec958)); | 
					
						
							|  |  |  | 				iec958.status[0] = IEC958_AES0_PROFESSIONAL | IEC958_AES0_PRO_EMPHASIS_NONE | IEC958_AES0_PRO_FS_48000; | 
					
						
							|  |  |  | 				iec958.status[1] = IEC958_AES1_PRO_MODE_STEREOPHONIC; | 
					
						
							|  |  |  | 				snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			page = 0; | 
					
						
							|  |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 			if (iec958.status[0] & IEC958_AES0_PROFESSIONAL) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 				/* default setup: no emphasis, PCM encoder */ | 
					
						
							| 
									
										
										
										
											2002-11-09 13:12:54 +00:00
										 |  |  | 				memset(&iec958, 0, sizeof(iec958)); | 
					
						
							|  |  |  | 				iec958.status[0] = IEC958_AES0_CON_EMPHASIS_NONE; | 
					
						
							|  |  |  | 				iec958.status[1] = IEC958_AES1_CON_PCM_CODER | IEC958_AES1_CON_ORIGINAL; | 
					
						
							|  |  |  | 				iec958.status[3] = IEC958_AES3_CON_FS_48000; | 
					
						
							|  |  |  | 				snd_ctl_elem_value_set_iec958(spdif_output, &iec958); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			page = 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		spdif_output_write(); | 
					
						
							|  |  |  | 		gtk_notebook_set_page(GTK_NOTEBOOK(hw_spdif_output_notebook), page); | 
					
						
							|  |  |  | 		spdif_output_update(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void spdif_input_update(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  | 	int digoptical = FALSE; | 
					
						
							|  |  |  | 	int diginternal = FALSE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-02 16:13:06 +00:00
										 |  |  | 	if ((card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTADIO2496) && | 
					
						
							|  |  |  | 	    ! card_is_dmx6fire) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_read(ctl, spdif_input)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to read S/PDIF input switch: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  | 	if (snd_ctl_elem_value_get_boolean(spdif_input, 0)) | 
					
						
							|  |  |  | 		digoptical = TRUE; | 
					
						
							| 
									
										
										
										
											2006-01-02 16:13:06 +00:00
										 |  |  | 	if (card_is_dmx6fire) { | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  |         	if ((err = snd_ctl_elem_read(ctl, spdif_on_off)) < 0) | 
					
						
							|  |  |  | 			g_print("Unable to read S/PDIF on/off switch: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	      	if (!(snd_ctl_elem_value_get_boolean(spdif_on_off, 0))) | 
					
						
							|  |  |  | 			diginternal = TRUE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (digoptical) { | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		toggle_set(hw_spdif_input_optical_radio, TRUE); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		toggle_set(hw_spdif_input_coaxial_radio, TRUE); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  | 	if (diginternal) | 
					
						
							|  |  |  | 		toggle_set(hw_spdif_switch_off_radio, TRUE); | 
					
						
							|  |  |  |  } | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void spdif_input_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 	char *str = (char *)data; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!is_active(togglebutton)) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  | 	if (!strcmp(str, "Off")) | 
					
						
							|  |  |  |                	snd_ctl_elem_value_set_boolean(spdif_on_off, 0, 0); | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		snd_ctl_elem_value_set_boolean(spdif_on_off, 0, 1); | 
					
						
							|  |  |  | 		if (!strcmp(str, "Optical")) | 
					
						
							|  |  |  | 			snd_ctl_elem_value_set_boolean(spdif_input, 0, 1); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			if (!strcmp(str, "Coaxial")) | 
					
						
							|  |  |  | 				snd_ctl_elem_value_set_boolean(spdif_input, 0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_write(ctl, spdif_on_off)) < 0) | 
					
						
							|  |  |  |                g_print("Unable to write S/PDIF on/off switch: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	if ((err = snd_ctl_elem_write(ctl, spdif_input)) < 0) | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 		g_print("Unable to write S/PDIF input switch: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | void analog_input_select_update(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err, input_interface; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-02 16:13:06 +00:00
										 |  |  | 	if (! card_is_dmx6fire) | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	if ((err = snd_ctl_elem_read(ctl, analog_input_select)) < 0) | 
					
						
							|  |  |  | 		g_print("Unable to read analog input switch: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | 	input_interface = snd_ctl_elem_value_get_enumerated(analog_input_select, 0); | 
					
						
							|  |  |  | 	switch (input_interface) { | 
					
						
							|  |  |  | 	case 0: toggle_set(input_interface_internal, TRUE); break; | 
					
						
							|  |  |  | 	case 1: toggle_set(input_interface_front_input, TRUE); break; | 
					
						
							|  |  |  | 	case 2: toggle_set(input_interface_rear_input, TRUE); break; | 
					
						
							|  |  |  | 	case 3: toggle_set(input_interface_wavetable, TRUE); break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		g_print("Error in analogue input: %d\n", input_interface); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void analog_input_select_set(int value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         snd_ctl_elem_value_set_enumerated(analog_input_select, 0, value); | 
					
						
							|  |  |  |         if ((err = snd_ctl_elem_write(ctl, analog_input_select)) < 0) | 
					
						
							|  |  |  |                 g_print("Unable to write analog input selection: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void analog_input_select_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *what = (char *) data; | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  |        int err; | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (!is_active(togglebutton)) | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |         if (!strcmp(what, "Internal")) { | 
					
						
							|  |  |  |                 analog_input_select_set(0); | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  |                snd_ctl_elem_value_set_boolean(breakbox_led, 0, 0); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  |         } else if (!strcmp(what, "Front Input")) { | 
					
						
							|  |  |  |                 analog_input_select_set(1); | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  |                snd_ctl_elem_value_set_boolean(breakbox_led, 0, 1); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  |         } else if (!strcmp(what, "Rear Input")) { | 
					
						
							|  |  |  |                 analog_input_select_set(2); | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  |                snd_ctl_elem_value_set_boolean(breakbox_led, 0, 0); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  |         } else if (!strcmp(what, "Wave Table")) { | 
					
						
							|  |  |  |                 analog_input_select_set(3); | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  |                snd_ctl_elem_value_set_boolean(breakbox_led, 0, 0); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  |         } else { | 
					
						
							|  |  |  |                 g_print("analog_input_select_toggled: %s ???\n", what); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2005-12-05 21:03:06 +00:00
										 |  |  |        if ((err = snd_ctl_elem_write(ctl, breakbox_led)) < 0) | 
					
						
							|  |  |  |                g_print("Unable to write breakbox LED switch: %s\n", snd_strerror(err)); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void phono_input_update(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |         int err; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-01-02 16:13:06 +00:00
										 |  |  |         if (! card_is_dmx6fire) | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  |                 return; | 
					
						
							|  |  |  |         if ((err = snd_ctl_elem_read(ctl, phono_input)) < 0) | 
					
						
							|  |  |  |                 g_print("Unable to read phono input switch: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  |         if (snd_ctl_elem_value_get_boolean(phono_input, 0)) { | 
					
						
							|  |  |  |                 toggle_set(hw_phono_input_on_radio, TRUE); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |                 toggle_set(hw_phono_input_off_radio, TRUE); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void phono_input_toggled(GtkWidget *togglebutton, gpointer data) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |         int err; | 
					
						
							|  |  |  |         char *str = (char *) data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (!is_active(togglebutton)) | 
					
						
							|  |  |  |                 return; | 
					
						
							| 
									
										
										
										
											2003-11-03 18:20:53 +00:00
										 |  |  |         if (!strcmp(str, "Phono")) | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  |                 snd_ctl_elem_value_set_boolean(phono_input, 0, 1); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |                 snd_ctl_elem_value_set_boolean(phono_input, 0, 0); | 
					
						
							|  |  |  |         if ((err = snd_ctl_elem_write(ctl, phono_input)) < 0) | 
					
						
							|  |  |  |                 g_print("Unable to write phono input switch: %s\n", snd_strerror(err)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | void hardware_init(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	if (snd_ctl_elem_value_malloc(&internal_clock) < 0 || | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | 	    snd_ctl_elem_value_malloc(&internal_clock_default) < 0 || | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	    snd_ctl_elem_value_malloc(&word_clock_sync) < 0 || | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	    snd_ctl_elem_value_malloc(&rate_locking) < 0 || | 
					
						
							|  |  |  | 	    snd_ctl_elem_value_malloc(&rate_reset) < 0 || | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	    snd_ctl_elem_value_malloc(&volume_rate) < 0 || | 
					
						
							|  |  |  | 	    snd_ctl_elem_value_malloc(&spdif_input) < 0 || | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | 	    snd_ctl_elem_value_malloc(&spdif_output) < 0 || | 
					
						
							|  |  |  | 	    snd_ctl_elem_value_malloc(&analog_input_select) < 0 || | 
					
						
							|  |  |  | 	    snd_ctl_elem_value_malloc(&breakbox_led) < 0 || | 
					
						
							|  |  |  | 	    snd_ctl_elem_value_malloc(&spdif_on_off) < 0 || | 
					
						
							|  |  |  | 	    snd_ctl_elem_value_malloc(&phono_input) < 0) { | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 		g_print("Cannot allocate memory\n"); | 
					
						
							|  |  |  | 		exit(1); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	snd_ctl_elem_value_set_interface(internal_clock, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(internal_clock, "Multi Track Internal Clock"); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-04-16 13:09:35 +00:00
										 |  |  | 	snd_ctl_elem_value_set_interface(internal_clock_default, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(internal_clock_default, "Multi Track Internal Clock Default"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-28 18:15:09 +00:00
										 |  |  | 	snd_ctl_elem_value_set_interface(word_clock_sync, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_set_name(word_clock_sync, "Word Clock Sync"); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	snd_ctl_elem_value_set_interface(rate_locking, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(rate_locking, "Multi Track Rate Locking"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_interface(rate_reset, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(rate_reset, "Multi Track Rate Reset"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-13 18:41:38 +00:00
										 |  |  | 	snd_ctl_elem_value_set_interface(volume_rate, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_set_name(volume_rate, "Multi Track Volume Rate"); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-10-09 12:30:14 +02:00
										 |  |  | 	if (card_is_dmx6fire) { | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | 		snd_ctl_elem_value_set_interface(spdif_input, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 		snd_ctl_elem_value_set_name(spdif_input, "Optical Digital Input Switch"); | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2006-01-02 16:13:06 +00:00
										 |  |  | 		snd_ctl_elem_value_set_interface(spdif_input, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 		snd_ctl_elem_value_set_name(spdif_input, "IEC958 Input Optical"); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-06 13:58:01 +00:00
										 |  |  | 	snd_ctl_elem_value_set_interface(spdif_output, SND_CTL_ELEM_IFACE_PCM); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(spdif_output, "IEC958 Playback Default"); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_interface(analog_input_select, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(analog_input_select, "Analog Input Select"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_interface(breakbox_led, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(breakbox_led, "Breakbox LED"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_interface(spdif_on_off, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(spdif_on_off, "Front Digital Input Switch"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_interface(phono_input, SND_CTL_ELEM_IFACE_MIXER); | 
					
						
							|  |  |  | 	snd_ctl_elem_value_set_name(phono_input, "Phono Analog Input Switch"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void hardware_postinit(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	master_clock_update(); | 
					
						
							| 
									
										
										
										
											2002-11-14 11:22:19 +00:00
										 |  |  | 	rate_locking_update(); | 
					
						
							|  |  |  | 	rate_reset_update(); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | 	volume_change_rate_update(); | 
					
						
							|  |  |  | 	spdif_input_update(); | 
					
						
							|  |  |  | 	spdif_output_update(); | 
					
						
							| 
									
										
										
										
											2003-10-30 15:09:04 +00:00
										 |  |  | 	analog_input_select_update(); | 
					
						
							|  |  |  | 	phono_input_update(); | 
					
						
							| 
									
										
										
										
											2000-10-29 21:51:51 +00:00
										 |  |  | } |