blob: b22881122f196c4e4f84fecccfd20838cd842558 [file] [log] [blame]
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +02001/***********************************************************************/
2/**
3
4 AudioScience HPI driver
Eliot Blennerhassett95a4c6e2011-07-22 15:52:42 +12005 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +02006
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
21Functions for reading DSP code to load into DSP
22
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020023*/
24/***********************************************************************/
25#ifndef _HPIDSPCD_H_
26#define _HPIDSPCD_H_
27
28#include "hpi_internal.h"
29
Eliot Blennerhassett95a4c6e2011-07-22 15:52:42 +120030/** Code header version is decimal encoded e.g. 4.06.10 is 40601 */
31#define HPI_VER_DECIMAL ((int)(HPI_VER_MAJOR(HPI_VER) * 10000 + \
32HPI_VER_MINOR(HPI_VER) * 100 + HPI_VER_RELEASE(HPI_VER)))
33
34/** Header structure for dsp firmware file
35 This structure must match that used in s2bin.c for generation of asidsp.bin
36 */
37/*#ifndef DISABLE_PRAGMA_PACK1 */
38/*#pragma pack(push, 1) */
39/*#endif */
40struct code_header {
41 /** Size in bytes including header */
42 u32 size;
43 /** File type tag "CODE" == 0x45444F43 */
44 u32 type;
45 /** Adapter model number */
46 u32 adapter;
47 /** Firmware version*/
48 u32 version;
49 /** Data checksum */
50 u32 checksum;
51};
52/*#ifndef DISABLE_PRAGMA_PACK1 */
53/*#pragma pack(pop) */
54/*#endif */
55
56/*? Don't need the pragmas? */
57compile_time_assert((sizeof(struct code_header) == 20), code_header_size);
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020058
59/** Descriptor for dspcode from firmware loader */
60struct dsp_code {
Eliot Blennerhassett95a4c6e2011-07-22 15:52:42 +120061 /** copy of file header */
62 struct code_header header;
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020063 /** Expected number of words in the whole dsp code,INCL header */
Eliot Blennerhassett95a4c6e2011-07-22 15:52:42 +120064 u32 block_length;
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020065 /** Number of words read so far */
Eliot Blennerhassett95a4c6e2011-07-22 15:52:42 +120066 u32 word_count;
67
68 /** internal state of DSP code reader */
69 struct dsp_code_private *pvt;
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020070};
71
Eliot Blennerhassett95a4c6e2011-07-22 15:52:42 +120072/** Prepare *psDspCode to refer to the requested adapter's firmware.
73Code file name is obtained from HpiOs_GetDspCodePath
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020074
75\return 0 for success, or error code if requested code is not available
76*/
77short hpi_dsp_code_open(
78 /** Code identifier, usually adapter family */
Eliot Blennerhassett95a4c6e2011-07-22 15:52:42 +120079 u32 adapter, void *pci_dev,
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020080 /** Pointer to DSP code control structure */
81 struct dsp_code *ps_dsp_code,
82 /** Pointer to dword to receive OS specific error code */
83 u32 *pos_error_code);
84
85/** Close the DSP code file */
86void hpi_dsp_code_close(struct dsp_code *ps_dsp_code);
87
88/** Rewind to the beginning of the DSP code file (for verify) */
89void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code);
90
91/** Read one word from the dsp code file
92 \return 0 for success, or error code if eof, or block length exceeded
93*/
94short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code,
95 /**< DSP code descriptor */
Eliot Blennerhassett1d595d22011-02-10 17:26:08 +130096 u32 *pword /**< Where to store the read word */
Eliot Blennerhassett719f82d2010-04-21 18:17:39 +020097 );
98
99/** Get a block of dsp code into an internal buffer, and provide a pointer to
100that buffer. (If dsp code is already an array in memory, it is referenced,
101not copied.)
102
103\return Error if requested number of words are not available
104*/
105short hpi_dsp_code_read_block(size_t words_requested,
106 struct dsp_code *ps_dsp_code,
107 /* Pointer to store (Pointer to code buffer) */
108 u32 **ppblock);
109
110#endif