hpidspcd.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /***********************************************************************/
  2. /**
  3. AudioScience HPI driver
  4. Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of version 2 of the GNU General Public License as
  7. published by the Free Software Foundation;
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. \file
  16. Functions for reading DSP code to load into DSP
  17. */
  18. /***********************************************************************/
  19. #ifndef _HPIDSPCD_H_
  20. #define _HPIDSPCD_H_
  21. #include "hpi_internal.h"
  22. /** Header structure for dsp firmware file
  23. This structure must match that used in s2bin.c for generation of asidsp.bin
  24. */
  25. /*#ifndef DISABLE_PRAGMA_PACK1 */
  26. /*#pragma pack(push, 1) */
  27. /*#endif */
  28. struct code_header {
  29. /** Size in bytes including header */
  30. u32 size;
  31. /** File type tag "CODE" == 0x45444F43 */
  32. u32 type;
  33. /** Adapter model number */
  34. u32 adapter;
  35. /** Firmware version*/
  36. u32 version;
  37. /** Data checksum */
  38. u32 checksum;
  39. };
  40. /*#ifndef DISABLE_PRAGMA_PACK1 */
  41. /*#pragma pack(pop) */
  42. /*#endif */
  43. /*? Don't need the pragmas? */
  44. compile_time_assert((sizeof(struct code_header) == 20), code_header_size);
  45. /** Descriptor for dspcode from firmware loader */
  46. struct dsp_code {
  47. /** copy of file header */
  48. struct code_header header;
  49. /** Expected number of words in the whole dsp code,INCL header */
  50. u32 block_length;
  51. /** Number of words read so far */
  52. u32 word_count;
  53. /** internal state of DSP code reader */
  54. struct dsp_code_private *pvt;
  55. };
  56. /** Prepare *psDspCode to refer to the requested adapter's firmware.
  57. Code file name is obtained from HpiOs_GetDspCodePath
  58. \return 0 for success, or error code if requested code is not available
  59. */
  60. short hpi_dsp_code_open(
  61. /** Code identifier, usually adapter family */
  62. u32 adapter, void *pci_dev,
  63. /** Pointer to DSP code control structure */
  64. struct dsp_code *ps_dsp_code,
  65. /** Pointer to dword to receive OS specific error code */
  66. u32 *pos_error_code);
  67. /** Close the DSP code file */
  68. void hpi_dsp_code_close(struct dsp_code *ps_dsp_code);
  69. /** Rewind to the beginning of the DSP code file (for verify) */
  70. void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code);
  71. /** Read one word from the dsp code file
  72. \return 0 for success, or error code if eof, or block length exceeded
  73. */
  74. short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code,
  75. /**< DSP code descriptor */
  76. u32 *pword /**< Where to store the read word */
  77. );
  78. /** Get a block of dsp code into an internal buffer, and provide a pointer to
  79. that buffer. (If dsp code is already an array in memory, it is referenced,
  80. not copied.)
  81. \return Error if requested number of words are not available
  82. */
  83. short hpi_dsp_code_read_block(size_t words_requested,
  84. struct dsp_code *ps_dsp_code,
  85. /* Pointer to store (Pointer to code buffer) */
  86. u32 **ppblock);
  87. #endif