indigo_express_dsp.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /************************************************************************
  2. This file is part of Echo Digital Audio's generic driver library.
  3. Copyright Echo Digital Audio Corporation (c) 1998 - 2005
  4. All rights reserved
  5. www.echoaudio.com
  6. This library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2.1 of the License, or (at your option) any later version.
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *************************************************************************
  18. Translation from C++ and adaptation for use in ALSA-Driver
  19. were made by Giuliano Pochini <pochini@shiny.it>
  20. *************************************************************************/
  21. static int set_sample_rate(struct echoaudio *chip, u32 rate)
  22. {
  23. u32 clock, control_reg, old_control_reg;
  24. if (wait_handshake(chip))
  25. return -EIO;
  26. old_control_reg = le32_to_cpu(chip->comm_page->control_register);
  27. control_reg = old_control_reg & ~INDIGO_EXPRESS_CLOCK_MASK;
  28. switch (rate) {
  29. case 32000:
  30. clock = INDIGO_EXPRESS_32000;
  31. break;
  32. case 44100:
  33. clock = INDIGO_EXPRESS_44100;
  34. break;
  35. case 48000:
  36. clock = INDIGO_EXPRESS_48000;
  37. break;
  38. case 64000:
  39. clock = INDIGO_EXPRESS_32000|INDIGO_EXPRESS_DOUBLE_SPEED;
  40. break;
  41. case 88200:
  42. clock = INDIGO_EXPRESS_44100|INDIGO_EXPRESS_DOUBLE_SPEED;
  43. break;
  44. case 96000:
  45. clock = INDIGO_EXPRESS_48000|INDIGO_EXPRESS_DOUBLE_SPEED;
  46. break;
  47. default:
  48. return -EINVAL;
  49. }
  50. control_reg |= clock;
  51. if (control_reg != old_control_reg) {
  52. dev_dbg(chip->card->dev,
  53. "set_sample_rate: %d clock %d\n", rate, clock);
  54. chip->comm_page->control_register = cpu_to_le32(control_reg);
  55. chip->sample_rate = rate;
  56. clear_handshake(chip);
  57. return send_vector(chip, DSP_VC_UPDATE_CLOCKS);
  58. }
  59. return 0;
  60. }
  61. /* This function routes the sound from a virtual channel to a real output */
  62. static int set_vmixer_gain(struct echoaudio *chip, u16 output, u16 pipe,
  63. int gain)
  64. {
  65. int index;
  66. if (snd_BUG_ON(pipe >= num_pipes_out(chip) ||
  67. output >= num_busses_out(chip)))
  68. return -EINVAL;
  69. if (wait_handshake(chip))
  70. return -EIO;
  71. chip->vmixer_gain[output][pipe] = gain;
  72. index = output * num_pipes_out(chip) + pipe;
  73. chip->comm_page->vmixer[index] = gain;
  74. dev_dbg(chip->card->dev,
  75. "set_vmixer_gain: pipe %d, out %d = %d\n", pipe, output, gain);
  76. return 0;
  77. }
  78. /* Tell the DSP to read and update virtual mixer levels in comm page. */
  79. static int update_vmixer_level(struct echoaudio *chip)
  80. {
  81. if (wait_handshake(chip))
  82. return -EIO;
  83. clear_handshake(chip);
  84. return send_vector(chip, DSP_VC_SET_VMIXER_GAIN);
  85. }
  86. static u32 detect_input_clocks(const struct echoaudio *chip)
  87. {
  88. return ECHO_CLOCK_BIT_INTERNAL;
  89. }
  90. /* The IndigoIO has no ASIC. Just do nothing */
  91. static int load_asic(struct echoaudio *chip)
  92. {
  93. return 0;
  94. }