Path: blob/master/sound/pci/echoaudio/darla24_dsp.c
10817 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 init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)32{33int err;3435DE_INIT(("init_hw() - Darla24\n"));36if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA24))37return -ENODEV;3839if ((err = init_dsp_comm_page(chip))) {40DE_INIT(("init_hw - could not initialize DSP comm page\n"));41return err;42}4344chip->device_id = device_id;45chip->subdevice_id = subdevice_id;46chip->bad_board = TRUE;47chip->dsp_code_to_load = FW_DARLA24_DSP;48/* Since this card has no ASIC, mark it as loaded so everything49works OK */50chip->asic_loaded = TRUE;51chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL |52ECHO_CLOCK_BIT_ESYNC;5354if ((err = load_firmware(chip)) < 0)55return err;56chip->bad_board = FALSE;5758DE_INIT(("init_hw done\n"));59return err;60}61626364static int set_mixer_defaults(struct echoaudio *chip)65{66return init_line_levels(chip);67}68697071static u32 detect_input_clocks(const struct echoaudio *chip)72{73u32 clocks_from_dsp, clock_bits;7475/* Map the DSP clock detect bits to the generic driver clock76detect bits */77clocks_from_dsp = le32_to_cpu(chip->comm_page->status_clocks);7879clock_bits = ECHO_CLOCK_BIT_INTERNAL;8081if (clocks_from_dsp & GLDM_CLOCK_DETECT_BIT_ESYNC)82clock_bits |= ECHO_CLOCK_BIT_ESYNC;8384return clock_bits;85}86878889/* The Darla24 has no ASIC. Just do nothing */90static int load_asic(struct echoaudio *chip)91{92return 0;93}94959697static int set_sample_rate(struct echoaudio *chip, u32 rate)98{99u8 clock;100101switch (rate) {102case 96000:103clock = GD24_96000;104break;105case 88200:106clock = GD24_88200;107break;108case 48000:109clock = GD24_48000;110break;111case 44100:112clock = GD24_44100;113break;114case 32000:115clock = GD24_32000;116break;117case 22050:118clock = GD24_22050;119break;120case 16000:121clock = GD24_16000;122break;123case 11025:124clock = GD24_11025;125break;126case 8000:127clock = GD24_8000;128break;129default:130DE_ACT(("set_sample_rate: Error, invalid sample rate %d\n",131rate));132return -EINVAL;133}134135if (wait_handshake(chip))136return -EIO;137138DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock));139chip->sample_rate = rate;140141/* Override the sample rate if this card is set to Echo sync. */142if (chip->input_clock == ECHO_CLOCK_ESYNC)143clock = GD24_EXT_SYNC;144145chip->comm_page->sample_rate = cpu_to_le32(rate); /* ignored by the DSP ? */146chip->comm_page->gd_clock_state = clock;147clear_handshake(chip);148return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);149}150151152153static int set_input_clock(struct echoaudio *chip, u16 clock)154{155if (snd_BUG_ON(clock != ECHO_CLOCK_INTERNAL &&156clock != ECHO_CLOCK_ESYNC))157return -EINVAL;158chip->input_clock = clock;159return set_sample_rate(chip, chip->sample_rate);160}161162163164