Path: blob/master/sound/pci/echoaudio/indigodj_dsp.c
10818 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****************************************************************************/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;3940DE_INIT(("init_hw() - Indigo DJ\n"));41if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_DJ))42return -ENODEV;4344if ((err = init_dsp_comm_page(chip))) {45DE_INIT(("init_hw - could not initialize DSP comm page\n"));46return err;47}4849chip->device_id = device_id;50chip->subdevice_id = subdevice_id;51chip->bad_board = TRUE;52chip->dsp_code_to_load = FW_INDIGO_DJ_DSP;53/* Since this card has no ASIC, mark it as loaded so everything54works OK */55chip->asic_loaded = TRUE;56chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;5758if ((err = load_firmware(chip)) < 0)59return err;60chip->bad_board = FALSE;6162DE_INIT(("init_hw done\n"));63return err;64}65666768static int set_mixer_defaults(struct echoaudio *chip)69{70return init_line_levels(chip);71}72737475static u32 detect_input_clocks(const struct echoaudio *chip)76{77return ECHO_CLOCK_BIT_INTERNAL;78}79808182/* The IndigoDJ has no ASIC. Just do nothing */83static int load_asic(struct echoaudio *chip)84{85return 0;86}87888990static int set_sample_rate(struct echoaudio *chip, u32 rate)91{92u32 control_reg;9394switch (rate) {95case 96000:96control_reg = MIA_96000;97break;98case 88200:99control_reg = MIA_88200;100break;101case 48000:102control_reg = MIA_48000;103break;104case 44100:105control_reg = MIA_44100;106break;107case 32000:108control_reg = MIA_32000;109break;110default:111DE_ACT(("set_sample_rate: %d invalid!\n", rate));112return -EINVAL;113}114115/* Set the control register if it has changed */116if (control_reg != le32_to_cpu(chip->comm_page->control_register)) {117if (wait_handshake(chip))118return -EIO;119120chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP */121chip->comm_page->control_register = cpu_to_le32(control_reg);122chip->sample_rate = rate;123124clear_handshake(chip);125return send_vector(chip, DSP_VC_UPDATE_CLOCKS);126}127return 0;128}129130131132/* This function routes the sound from a virtual channel to a real output */133static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,134int gain)135{136int index;137138if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||139output >= num_busses_out(chip)))140return -EINVAL;141142if (wait_handshake(chip))143return -EIO;144145chip->vmixer_gain[output][pipe] = gain;146index = output * num_pipes_out(chip) + pipe;147chip->comm_page->vmixer[index] = gain;148149DE_ACT(("set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain));150return 0;151}152153154155/* Tell the DSP to read and update virtual mixer levels in comm page. */156static int update_vmixer_level(struct echoaudio *chip)157{158if (wait_handshake(chip))159return -EIO;160clear_handshake(chip);161return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);162}163164165166