Path: blob/master/sound/pci/echoaudio/echo3g_dsp.c
10820 views
/****************************************************************************12Copyright Echo Digital Audio Corporation (c) 1998 - 20043All rights reserved4www.echoaudio.com56This file is part of Echo Digital Audio's generic driver library.78Echo Digital Audio's generic driver library is free software;9you can redistribute it and/or modify it under the terms of10the GNU General Public License as published by the Free Software11Foundation.1213This program is distributed in the hope that it will be useful,14but WITHOUT ANY WARRANTY; without even the implied warranty of15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16GNU General Public License for more details.1718You should have received a copy of the GNU General Public License19along with this program; if not, write to the Free Software20Foundation, Inc., 59 Temple Place - Suite 330, Boston,21MA 02111-1307, USA.2223*************************************************************************2425Translation from C++ and adaptation for use in ALSA-Driver26were made by Giuliano Pochini <[email protected]>2728****************************************************************************/2930static int load_asic(struct echoaudio *chip);31static int dsp_set_digital_mode(struct echoaudio *chip, u8 mode);32static int set_digital_mode(struct echoaudio *chip, u8 mode);33static int check_asic_status(struct echoaudio *chip);34static int set_sample_rate(struct echoaudio *chip, u32 rate);35static int set_input_clock(struct echoaudio *chip, u16 clock);36static int set_professional_spdif(struct echoaudio *chip, char prof);37static int set_phantom_power(struct echoaudio *chip, char on);38static int write_control_reg(struct echoaudio *chip, u32 ctl, u32 frq,39char force);4041#include <linux/interrupt.h>4243static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)44{45int err;4647local_irq_enable();48DE_INIT(("init_hw() - Echo3G\n"));49if (snd_BUG_ON((subdevice_id & 0xfff0) != ECHO3G))50return -ENODEV;5152if ((err = init_dsp_comm_page(chip))) {53DE_INIT(("init_hw - could not initialize DSP comm page\n"));54return err;55}5657chip->comm_page->e3g_frq_register =58cpu_to_le32((E3G_MAGIC_NUMBER / 48000) - 2);59chip->device_id = device_id;60chip->subdevice_id = subdevice_id;61chip->bad_board = TRUE;62chip->has_midi = TRUE;63chip->dsp_code_to_load = FW_ECHO3G_DSP;6465/* Load the DSP code and the ASIC on the PCI card and get66what type of external box is attached */67err = load_firmware(chip);6869if (err < 0) {70return err;71} else if (err == E3G_GINA3G_BOX_TYPE) {72chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |73ECHO_CLOCK_BIT_SPDIF |74ECHO_CLOCK_BIT_ADAT;75chip->card_name = "Gina3G";76chip->px_digital_out = chip->bx_digital_out = 6;77chip->px_analog_in = chip->bx_analog_in = 14;78chip->px_digital_in = chip->bx_digital_in = 16;79chip->px_num = chip->bx_num = 24;80chip->has_phantom_power = TRUE;81chip->hasnt_input_nominal_level = TRUE;82} else if (err == E3G_LAYLA3G_BOX_TYPE) {83chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |84ECHO_CLOCK_BIT_SPDIF |85ECHO_CLOCK_BIT_ADAT |86ECHO_CLOCK_BIT_WORD;87chip->card_name = "Layla3G";88chip->px_digital_out = chip->bx_digital_out = 8;89chip->px_analog_in = chip->bx_analog_in = 16;90chip->px_digital_in = chip->bx_digital_in = 24;91chip->px_num = chip->bx_num = 32;92} else {93return -ENODEV;94}9596chip->digital_modes = ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |97ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |98ECHOCAPS_HAS_DIGITAL_MODE_ADAT;99100DE_INIT(("init_hw done\n"));101return err;102}103104105106static int set_mixer_defaults(struct echoaudio *chip)107{108chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;109chip->professional_spdif = FALSE;110chip->non_audio_spdif = FALSE;111chip->bad_board = FALSE;112chip->phantom_power = FALSE;113return init_line_levels(chip);114}115116117118static int set_phantom_power(struct echoaudio *chip, char on)119{120u32 control_reg = le32_to_cpu(chip->comm_page->control_register);121122if (on)123control_reg |= E3G_PHANTOM_POWER;124else125control_reg &= ~E3G_PHANTOM_POWER;126127chip->phantom_power = on;128return write_control_reg(chip, control_reg,129le32_to_cpu(chip->comm_page->e3g_frq_register),1300);131}132133134