Back to home page

OSCL-LXR

 
 

    


0001 /****************************************************************************
0002 
0003    Copyright Echo Digital Audio Corporation (c) 1998 - 2004
0004    All rights reserved
0005    www.echoaudio.com
0006 
0007    This file is part of Echo Digital Audio's generic driver library.
0008 
0009    Echo Digital Audio's generic driver library is free software;
0010    you can redistribute it and/or modify it under the terms of
0011    the GNU General Public License as published by the Free Software
0012    Foundation.
0013 
0014    This program is distributed in the hope that it will be useful,
0015    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017    GNU General Public License for more details.
0018 
0019    You should have received a copy of the GNU General Public License
0020    along with this program; if not, write to the Free Software
0021    Foundation, Inc., 59 Temple Place - Suite 330, Boston,
0022    MA  02111-1307, USA.
0023 
0024    *************************************************************************
0025 
0026  Translation from C++ and adaptation for use in ALSA-Driver
0027  were made by Giuliano Pochini <pochini@shiny.it>
0028 
0029 ****************************************************************************/
0030 
0031 static int load_asic(struct echoaudio *chip);
0032 static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode);
0033 static int set_digital_mode(struct echoaudio *chip, u8 mode);
0034 static int check_asic_status(struct echoaudio *chip);
0035 static int set_sample_rate(struct echoaudio *chip, u32 rate);
0036 static int set_input_clock(struct echoaudio *chip, u16 clock);
0037 static int set_professional_spdif(struct echoaudio *chip, char prof);
0038 static int set_phantom_power(struct echoaudio *chip, char on);
0039 static int write_control_reg(struct echoaudio *chip, u32 ctl, u32 frq,
0040                  char force);
0041 
0042 #include <linux/interrupt.h>
0043 
0044 static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
0045 {
0046     int err;
0047 
0048     local_irq_enable();
0049     if (snd_BUG_ON((subdevice_id & 0xfff0) != ECHO3G))
0050         return -ENODEV;
0051 
0052     err = init_dsp_comm_page(chip);
0053     if (err) {
0054         dev_err(chip->card->dev,
0055             "init_hw - could not initialize DSP comm page\n");
0056         return err;
0057     }
0058 
0059     chip->comm_page->e3g_frq_register =
0060         cpu_to_le32((E3G_MAGIC_NUMBER / 48000) - 2);
0061     chip->device_id = device_id;
0062     chip->subdevice_id = subdevice_id;
0063     chip->bad_board = true;
0064     chip->has_midi = true;
0065     chip->dsp_code_to_load = FW_ECHO3G_DSP;
0066 
0067     /* Load the DSP code and the ASIC on the PCI card and get
0068     what type of external box is attached */
0069     err = load_firmware(chip);
0070 
0071     if (err < 0) {
0072         return err;
0073     } else if (err == E3G_GINA3G_BOX_TYPE) {
0074         chip->input_clock_types =   ECHO_CLOCK_BIT_INTERNAL |
0075                         ECHO_CLOCK_BIT_SPDIF |
0076                         ECHO_CLOCK_BIT_ADAT;
0077         chip->card_name = "Gina3G";
0078         chip->px_digital_out = chip->bx_digital_out = 6;
0079         chip->px_analog_in = chip->bx_analog_in = 14;
0080         chip->px_digital_in = chip->bx_digital_in = 16;
0081         chip->px_num = chip->bx_num = 24;
0082         chip->has_phantom_power = true;
0083         chip->hasnt_input_nominal_level = true;
0084     } else if (err == E3G_LAYLA3G_BOX_TYPE) {
0085         chip->input_clock_types =   ECHO_CLOCK_BIT_INTERNAL |
0086                         ECHO_CLOCK_BIT_SPDIF |
0087                         ECHO_CLOCK_BIT_ADAT |
0088                         ECHO_CLOCK_BIT_WORD;
0089         chip->card_name = "Layla3G";
0090         chip->px_digital_out = chip->bx_digital_out = 8;
0091         chip->px_analog_in = chip->bx_analog_in = 16;
0092         chip->px_digital_in = chip->bx_digital_in = 24;
0093         chip->px_num = chip->bx_num = 32;
0094     } else {
0095         return -ENODEV;
0096     }
0097 
0098     chip->digital_modes =   ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
0099                 ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
0100                 ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
0101 
0102     return err;
0103 }
0104 
0105 
0106 
0107 static int set_mixer_defaults(struct echoaudio *chip)
0108 {
0109     chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
0110     chip->professional_spdif = false;
0111     chip->non_audio_spdif = false;
0112     chip->bad_board = false;
0113     chip->phantom_power = false;
0114     return init_line_levels(chip);
0115 }
0116 
0117 
0118 
0119 static int set_phantom_power(struct echoaudio *chip, char on)
0120 {
0121     u32 control_reg = le32_to_cpu(chip->comm_page->control_register);
0122 
0123     if (on)
0124         control_reg |= E3G_PHANTOM_POWER;
0125     else
0126         control_reg &= ~E3G_PHANTOM_POWER;
0127 
0128     chip->phantom_power = on;
0129     return write_control_reg(chip, control_reg,
0130                  le32_to_cpu(chip->comm_page->e3g_frq_register),
0131                  0);
0132 }