darla20_dsp.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /***************************************************************************
  2. Copyright Echo Digital Audio Corporation (c) 1998 - 2004
  3. All rights reserved
  4. www.echoaudio.com
  5. This file is part of Echo Digital Audio's generic driver library.
  6. Echo Digital Audio's generic driver library is free software;
  7. you can redistribute it and/or modify it under the terms of
  8. the GNU General Public License as published by the Free Software
  9. Foundation.
  10. This program 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
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  17. MA 02111-1307, USA.
  18. *************************************************************************
  19. Translation from C++ and adaptation for use in ALSA-Driver
  20. were made by Giuliano Pochini <pochini@shiny.it>
  21. ****************************************************************************/
  22. static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
  23. {
  24. int err;
  25. DE_INIT(("init_hw() - Darla20\n"));
  26. if (snd_BUG_ON((subdevice_id & 0xfff0) != DARLA20))
  27. return -ENODEV;
  28. if ((err = init_dsp_comm_page(chip))) {
  29. DE_INIT(("init_hw - could not initialize DSP comm page\n"));
  30. return err;
  31. }
  32. chip->device_id = device_id;
  33. chip->subdevice_id = subdevice_id;
  34. chip->bad_board = TRUE;
  35. chip->dsp_code_to_load = FW_DARLA20_DSP;
  36. chip->spdif_status = GD_SPDIF_STATUS_UNDEF;
  37. chip->clock_state = GD_CLOCK_UNDEF;
  38. /* Since this card has no ASIC, mark it as loaded so everything
  39. works OK */
  40. chip->asic_loaded = TRUE;
  41. chip->input_clock_types = ECHO_CLOCK_BIT_INTERNAL;
  42. if ((err = load_firmware(chip)) < 0)
  43. return err;
  44. chip->bad_board = FALSE;
  45. DE_INIT(("init_hw done\n"));
  46. return err;
  47. }
  48. static int set_mixer_defaults(struct echoaudio *chip)
  49. {
  50. return init_line_levels(chip);
  51. }
  52. /* The Darla20 has no external clock sources */
  53. static u32 detect_input_clocks(const struct echoaudio *chip)
  54. {
  55. return ECHO_CLOCK_BIT_INTERNAL;
  56. }
  57. /* The Darla20 has no ASIC. Just do nothing */
  58. static int load_asic(struct echoaudio *chip)
  59. {
  60. return 0;
  61. }
  62. static int set_sample_rate(struct echoaudio *chip, u32 rate)
  63. {
  64. u8 clock_state, spdif_status;
  65. if (wait_handshake(chip))
  66. return -EIO;
  67. switch (rate) {
  68. case 44100:
  69. clock_state = GD_CLOCK_44;
  70. spdif_status = GD_SPDIF_STATUS_44;
  71. break;
  72. case 48000:
  73. clock_state = GD_CLOCK_48;
  74. spdif_status = GD_SPDIF_STATUS_48;
  75. break;
  76. default:
  77. clock_state = GD_CLOCK_NOCHANGE;
  78. spdif_status = GD_SPDIF_STATUS_NOCHANGE;
  79. break;
  80. }
  81. if (chip->clock_state == clock_state)
  82. clock_state = GD_CLOCK_NOCHANGE;
  83. if (spdif_status == chip->spdif_status)
  84. spdif_status = GD_SPDIF_STATUS_NOCHANGE;
  85. chip->comm_page->sample_rate = cpu_to_le32(rate);
  86. chip->comm_page->gd_clock_state = clock_state;
  87. chip->comm_page->gd_spdif_status = spdif_status;
  88. chip->comm_page->gd_resampler_state = 3; /* magic number - should always be 3 */
  89. /* Save the new audio state if it changed */
  90. if (clock_state != GD_CLOCK_NOCHANGE)
  91. chip->clock_state = clock_state;
  92. if (spdif_status != GD_SPDIF_STATUS_NOCHANGE)
  93. chip->spdif_status = spdif_status;
  94. chip->sample_rate = rate;
  95. clear_handshake(chip);
  96. return send_vector(chip, DSP_VC_SET_GD_AUDIO_STATE);
  97. }