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