Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | |
| 3 | Copyright Echo Digital Audio Corporation (c) 1998 - 2004 |
| 4 | All rights reserved |
| 5 | www.echoaudio.com |
| 6 | |
| 7 | This file is part of Echo Digital Audio's generic driver library. |
| 8 | |
| 9 | Echo Digital Audio's generic driver library is free software; |
| 10 | you can redistribute it and/or modify it under the terms of |
| 11 | the GNU General Public License as published by the Free Software |
| 12 | Foundation. |
| 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., 59 Temple Place - Suite 330, Boston, |
| 22 | MA 02111-1307, USA. |
| 23 | |
| 24 | ************************************************************************* |
| 25 | |
| 26 | Translation from C++ and adaptation for use in ALSA-Driver |
| 27 | were made by Giuliano Pochini <pochini@shiny.it> |
| 28 | |
| 29 | ****************************************************************************/ |
| 30 | |
| 31 | static int load_asic(struct echoaudio *chip); |
| 32 | static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode); |
| 33 | static int set_digital_mode(struct echoaudio *chip, u8 mode); |
| 34 | static int check_asic_status(struct echoaudio *chip); |
| 35 | static int set_sample_rate(struct echoaudio *chip, u32 rate); |
| 36 | static int set_input_clock(struct echoaudio *chip, u16 clock); |
| 37 | static int set_professional_spdif(struct echoaudio *chip, char prof); |
| 38 | static int set_phantom_power(struct echoaudio *chip, char on); |
| 39 | static int write_control_reg(struct echoaudio *chip, u32 ctl, u32 frq, |
| 40 | char force); |
| 41 | |
Adrian Bunk | 579c84a | 2007-01-23 19:22:26 +0100 | [diff] [blame] | 42 | #include <linux/interrupt.h> |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 43 | |
| 44 | static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id) |
| 45 | { |
| 46 | int err; |
| 47 | |
| 48 | local_irq_enable(); |
Takashi Iwai | da3cec3 | 2008-08-08 17:12:14 +0200 | [diff] [blame] | 49 | if (snd_BUG_ON((subdevice_id & 0xfff0) != ECHO3G)) |
| 50 | return -ENODEV; |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 51 | |
| 52 | if ((err = init_dsp_comm_page(chip))) { |
Sudip Mukherjee | b5b4a41 | 2014-11-03 16:04:13 +0530 | [diff] [blame] | 53 | dev_err(chip->card->dev, |
| 54 | "init_hw - could not initialize DSP comm page\n"); |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 55 | return err; |
| 56 | } |
| 57 | |
| 58 | chip->comm_page->e3g_frq_register = |
Harvey Harrison | e930e99 | 2009-02-11 14:49:30 -0800 | [diff] [blame] | 59 | cpu_to_le32((E3G_MAGIC_NUMBER / 48000) - 2); |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 60 | chip->device_id = device_id; |
| 61 | chip->subdevice_id = subdevice_id; |
Mark Brown | 3f6175e | 2015-08-10 13:02:53 +0100 | [diff] [blame] | 62 | chip->bad_board = true; |
| 63 | chip->has_midi = true; |
Giuliano Pochini | 19b5006 | 2010-02-14 18:15:34 +0100 | [diff] [blame] | 64 | chip->dsp_code_to_load = FW_ECHO3G_DSP; |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 65 | |
| 66 | /* Load the DSP code and the ASIC on the PCI card and get |
| 67 | what type of external box is attached */ |
| 68 | err = load_firmware(chip); |
| 69 | |
| 70 | if (err < 0) { |
| 71 | return err; |
| 72 | } else if (err == E3G_GINA3G_BOX_TYPE) { |
| 73 | chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL | |
| 74 | ECHO_CLOCK_BIT_SPDIF | |
| 75 | ECHO_CLOCK_BIT_ADAT; |
| 76 | chip->card_name = "Gina3G"; |
| 77 | chip->px_digital_out = chip->bx_digital_out = 6; |
| 78 | chip->px_analog_in = chip->bx_analog_in = 14; |
| 79 | chip->px_digital_in = chip->bx_digital_in = 16; |
| 80 | chip->px_num = chip->bx_num = 24; |
Mark Brown | 3f6175e | 2015-08-10 13:02:53 +0100 | [diff] [blame] | 81 | chip->has_phantom_power = true; |
| 82 | chip->hasnt_input_nominal_level = true; |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 83 | } else if (err == E3G_LAYLA3G_BOX_TYPE) { |
| 84 | chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL | |
| 85 | ECHO_CLOCK_BIT_SPDIF | |
| 86 | ECHO_CLOCK_BIT_ADAT | |
| 87 | ECHO_CLOCK_BIT_WORD; |
| 88 | chip->card_name = "Layla3G"; |
| 89 | chip->px_digital_out = chip->bx_digital_out = 8; |
| 90 | chip->px_analog_in = chip->bx_analog_in = 16; |
| 91 | chip->px_digital_in = chip->bx_digital_in = 24; |
| 92 | chip->px_num = chip->bx_num = 32; |
| 93 | } else { |
| 94 | return -ENODEV; |
| 95 | } |
| 96 | |
| 97 | chip->digital_modes = ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA | |
| 98 | ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL | |
| 99 | ECHOCAPS_HAS_DIGITAL_MODE_ADAT; |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 100 | |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 101 | return err; |
| 102 | } |
| 103 | |
| 104 | |
| 105 | |
Giuliano Pochini | ad3499f | 2010-02-14 18:15:59 +0100 | [diff] [blame] | 106 | static int set_mixer_defaults(struct echoaudio *chip) |
| 107 | { |
| 108 | chip->digital_mode = DIGITAL_MODE_SPDIF_RCA; |
Mark Brown | 3f6175e | 2015-08-10 13:02:53 +0100 | [diff] [blame] | 109 | chip->professional_spdif = false; |
| 110 | chip->non_audio_spdif = false; |
| 111 | chip->bad_board = false; |
| 112 | chip->phantom_power = false; |
Giuliano Pochini | ad3499f | 2010-02-14 18:15:59 +0100 | [diff] [blame] | 113 | return init_line_levels(chip); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | |
Giuliano Pochini | dd7b254 | 2006-06-28 13:53:41 +0200 | [diff] [blame] | 118 | static int set_phantom_power(struct echoaudio *chip, char on) |
| 119 | { |
| 120 | u32 control_reg = le32_to_cpu(chip->comm_page->control_register); |
| 121 | |
| 122 | if (on) |
| 123 | control_reg |= E3G_PHANTOM_POWER; |
| 124 | else |
| 125 | control_reg &= ~E3G_PHANTOM_POWER; |
| 126 | |
| 127 | chip->phantom_power = on; |
| 128 | return write_control_reg(chip, control_reg, |
| 129 | le32_to_cpu(chip->comm_page->e3g_frq_register), |
| 130 | 0); |
| 131 | } |