Back to home page

OSCL-LXR

 
 

    


0001 /****************************************************************************
0002 
0003    Copyright Echo Digital Audio Corporation (c) 1998 - 2004
0004    All rights reserved
0005    www.echoaudio.com
0006 
0007    This file is part of Echo Digital Audio's generic driver library.
0008 
0009    Echo Digital Audio's generic driver library is free software;
0010    you can redistribute it and/or modify it under the terms of
0011    the GNU General Public License as published by the Free Software
0012    Foundation.
0013 
0014    This program is distributed in the hope that it will be useful,
0015    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017    GNU General Public License for more details.
0018 
0019    You should have received a copy of the GNU General Public License
0020    along with this program; if not, write to the Free Software
0021    Foundation, Inc., 59 Temple Place - Suite 330, Boston,
0022    MA  02111-1307, USA.
0023 
0024    *************************************************************************
0025 
0026  Translation from C++ and adaptation for use in ALSA-Driver
0027  were made by Giuliano Pochini <pochini@shiny.it>
0028 
0029 ****************************************************************************/
0030 
0031 
0032 static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
0033                int gain);
0034 static int update_vmixer_level(struct echoaudio *chip);
0035 
0036 
0037 static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
0038 {
0039     int err;
0040 
0041     if (snd_BUG_ON((subdevice_id & 0xfff0) != INDIGO_IO))
0042         return -ENODEV;
0043 
0044     err = init_dsp_comm_page(chip);
0045     if (err) {
0046         dev_err(chip->card->dev,
0047             "init_hw - could not initialize DSP comm page\n");
0048         return err;
0049     }
0050 
0051     chip->device_id = device_id;
0052     chip->subdevice_id = subdevice_id;
0053     chip->bad_board = true;
0054     chip->dsp_code_to_load = FW_INDIGO_IO_DSP;
0055     /* Since this card has no ASIC, mark it as loaded so everything
0056        works OK */
0057     chip->asic_loaded = true;
0058     chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
0059 
0060     err = load_firmware(chip);
0061     if (err < 0)
0062         return err;
0063     chip->bad_board = false;
0064 
0065     return err;
0066 }
0067 
0068 
0069 
0070 static int set_mixer_defaults(struct echoaudio *chip)
0071 {
0072     return init_line_levels(chip);
0073 }
0074 
0075 
0076 
0077 static u32 detect_input_clocks(const struct echoaudio *chip)
0078 {
0079     return ECHO_CLOCK_BIT_INTERNAL;
0080 }
0081 
0082 
0083 
0084 /* The IndigoIO has no ASIC. Just do nothing */
0085 static int load_asic(struct echoaudio *chip)
0086 {
0087     return 0;
0088 }
0089 
0090 
0091 
0092 static int set_sample_rate(struct echoaudio *chip, u32 rate)
0093 {
0094     if (wait_handshake(chip))
0095         return -EIO;
0096 
0097     chip->sample_rate = rate;
0098     chip->comm_page->sample_rate = cpu_to_le32(rate);
0099     clear_handshake(chip);
0100     return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
0101 }
0102 
0103 
0104 
0105 /* This function routes the sound from a virtual channel to a real output */
0106 static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
0107                int gain)
0108 {
0109     int index;
0110 
0111     if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
0112                output >= num_busses_out(chip)))
0113         return -EINVAL;
0114 
0115     if (wait_handshake(chip))
0116         return -EIO;
0117 
0118     chip->vmixer_gain[output][pipe] = gain;
0119     index = output * num_pipes_out(chip) + pipe;
0120     chip->comm_page->vmixer[index] = gain;
0121 
0122     dev_dbg(chip->card->dev,
0123         "set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain);
0124     return 0;
0125 }
0126 
0127 
0128 
0129 /* Tell the DSP to read and update virtual mixer levels in comm page. */
0130 static int update_vmixer_level(struct echoaudio *chip)
0131 {
0132     if (wait_handshake(chip))
0133         return -EIO;
0134     clear_handshake(chip);
0135     return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
0136 }
0137