Path: blob/master/sound/pci/echoaudio/darla20_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****************************************************************************/293031static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)32{33int err;3435DE_INIT(("init_hw() - Darla20\n"));36if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA20))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_DARLA20_DSP;48chip->spdif_status = GD_SPDIF_STATUS_UNDEF;49chip->clock_state = GD_CLOCK_UNDEF;50/* Since this card has no ASIC, mark it as loaded so everything51works OK */52chip->asic_loaded = TRUE;53chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;5455if ((err = load_firmware(chip)) < 0)56return err;57chip->bad_board = FALSE;5859DE_INIT(("init_hw done\n"));60return err;61}62636465static int set_mixer_defaults(struct echoaudio *chip)66{67return init_line_levels(chip);68}69707172/* The Darla20 has no external clock sources */73static u32 detect_input_clocks(const struct echoaudio *chip)74{75return ECHO_CLOCK_BIT_INTERNAL;76}77787980/* The Darla20 has no ASIC. Just do nothing */81static int load_asic(struct echoaudio *chip)82{83return 0;84}85868788static int set_sample_rate(struct echoaudio *chip, u32 rate)89{90u8 clock_state, spdif_status;9192if (wait_handshake(chip))93return -EIO;9495switch (rate) {96case 44100:97clock_state = GD_CLOCK_44;98spdif_status = GD_SPDIF_STATUS_44;99break;100case 48000:101clock_state = GD_CLOCK_48;102spdif_status = GD_SPDIF_STATUS_48;103break;104default:105clock_state = GD_CLOCK_NOCHANGE;106spdif_status = GD_SPDIF_STATUS_NOCHANGE;107break;108}109110if (chip->clock_state == clock_state)111clock_state = GD_CLOCK_NOCHANGE;112if (spdif_status == chip->spdif_status)113spdif_status = GD_SPDIF_STATUS_NOCHANGE;114115chip->comm_page->sample_rate = cpu_to_le32(rate);116chip->comm_page->gd_clock_state = clock_state;117chip->comm_page->gd_spdif_status = spdif_status;118chip->comm_page->gd_resampler_state = 3; /* magic number - should always be 3 */119120/* Save the new audio state if it changed */121if (clock_state != GD_CLOCK_NOCHANGE)122chip->clock_state = clock_state;123if (spdif_status != GD_SPDIF_STATUS_NOCHANGE)124chip->spdif_status = spdif_status;125chip->sample_rate = rate;126127clear_handshake(chip);128return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);129}130131132