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))
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_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 Indigo 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     u32 control_reg;
0095 
0096     switch (rate) {
0097     case 96000:
0098         control_reg = MIA_96000;
0099         break;
0100     case 88200:
0101         control_reg = MIA_88200;
0102         break;
0103     case 48000:
0104         control_reg = MIA_48000;
0105         break;
0106     case 44100:
0107         control_reg = MIA_44100;
0108         break;
0109     case 32000:
0110         control_reg = MIA_32000;
0111         break;
0112     default:
0113         dev_err(chip->card->dev,
0114             "set_sample_rate: %d invalid!\n", rate);
0115         return -EINVAL;
0116     }
0117 
0118     /* Set the control register if it has changed */
0119     if (control_reg != le32_to_cpu(chip->comm_page->control_register)) {
0120         if (wait_handshake(chip))
0121             return -EIO;
0122 
0123         chip->comm_page->sample_rate = cpu_to_le32(rate);   /* ignored by the DSP */
0124         chip->comm_page->control_register = cpu_to_le32(control_reg);
0125         chip->sample_rate = rate;
0126 
0127         clear_handshake(chip);
0128         return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
0129     }
0130     return 0;
0131 }
0132 
0133 
0134 
0135 /* This function routes the sound from a virtual channel to a real output */
0136 static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
0137                int gain)
0138 {
0139     int index;
0140 
0141     if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
0142                output >= num_busses_out(chip)))
0143         return -EINVAL;
0144 
0145     if (wait_handshake(chip))
0146         return -EIO;
0147 
0148     chip->vmixer_gain[output][pipe] = gain;
0149     index = output * num_pipes_out(chip) + pipe;
0150     chip->comm_page->vmixer[index] = gain;
0151 
0152     dev_dbg(chip->card->dev,
0153         "set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain);
0154     return 0;
0155 }
0156 
0157 
0158 
0159 /* Tell the DSP to read and update virtual mixer levels in comm page. */
0160 static int update_vmixer_level(struct echoaudio *chip)
0161 {
0162     if (wait_handshake(chip))
0163         return -EIO;
0164     clear_handshake(chip);
0165     return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
0166 }
0167