/****************************************************************************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****************************************************************************/293031static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,32int gain);33static int update_vmixer_level(struct echoaudio *chip);343536static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)37{38int err;3940if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_IO))41return -ENODEV;4243err = init_dsp_comm_page(chip);44if (err) {45dev_err(chip->card->dev,46"init_hw - could not initialize DSP comm page\n");47return err;48}4950chip->device_id = device_id;51chip->subdevice_id = subdevice_id;52chip->bad_board = true;53chip->dsp_code_to_load = FW_INDIGO_IO_DSP;54/* Since this card has no ASIC, mark it as loaded so everything55works OK */56chip->asic_loaded = true;57chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;5859err = load_firmware(chip);60if (err < 0)61return err;62chip->bad_board = false;6364return err;65}66676869static int set_mixer_defaults(struct echoaudio *chip)70{71return init_line_levels(chip);72}73747576static u32 detect_input_clocks(const struct echoaudio *chip)77{78return ECHO_CLOCK_BIT_INTERNAL;79}80818283/* The IndigoIO has no ASIC. Just do nothing */84static int load_asic(struct echoaudio *chip)85{86return 0;87}88899091static int set_sample_rate(struct echoaudio *chip, u32 rate)92{93if (wait_handshake(chip))94return -EIO;9596chip->sample_rate = rate;97chip->comm_page->sample_rate = cpu_to_le32(rate);98clear_handshake(chip);99return send_vector(chip, DSP_VC_UPDATE_CLOCKS);100}101102103104/* This function routes the sound from a virtual channel to a real output */105static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,106int gain)107{108int index;109110if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||111output >= num_busses_out(chip)))112return -EINVAL;113114if (wait_handshake(chip))115return -EIO;116117chip->vmixer_gain[output][pipe] = gain;118index = output * num_pipes_out(chip) + pipe;119chip->comm_page->vmixer[index] = gain;120121dev_dbg(chip->card->dev,122"set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain);123return 0;124}125126127128/* Tell the DSP to read and update virtual mixer levels in comm page. */129static int update_vmixer_level(struct echoaudio *chip)130{131if (wait_handshake(chip))132return -EIO;133clear_handshake(chip);134return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);135}136137138139