1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /***********************************************************************/
5 AudioScience HPI driver
6 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>
10 Functions for reading DSP code to load into DSP
13 /***********************************************************************/
17 #include "hpi_internal.h"
19 /** Header structure for dsp firmware file
20 This structure must match that used in s2bin.c for generation of asidsp.bin
22 /*#ifndef DISABLE_PRAGMA_PACK1 */
23 /*#pragma pack(push, 1) */
26 /** Size in bytes including header */
28 /** File type tag "CODE" == 0x45444F43 */
30 /** Adapter model number */
32 /** Firmware version*/
37 /*#ifndef DISABLE_PRAGMA_PACK1 */
38 /*#pragma pack(pop) */
41 /*? Don't need the pragmas? */
42 compile_time_assert((sizeof(struct code_header) == 20), code_header_size);
44 /** Descriptor for dspcode from firmware loader */
46 /** copy of file header */
47 struct code_header header;
48 /** Expected number of words in the whole dsp code,INCL header */
50 /** Number of words read so far */
53 /** internal state of DSP code reader */
54 struct dsp_code_private *pvt;
57 /** Prepare *psDspCode to refer to the requested adapter's firmware.
58 Code file name is obtained from HpiOs_GetDspCodePath
60 \return 0 for success, or error code if requested code is not available
62 short hpi_dsp_code_open(
63 /** Code identifier, usually adapter family */
64 u32 adapter, void *pci_dev,
65 /** Pointer to DSP code control structure */
66 struct dsp_code *ps_dsp_code,
67 /** Pointer to dword to receive OS specific error code */
70 /** Close the DSP code file */
71 void hpi_dsp_code_close(struct dsp_code *ps_dsp_code);
73 /** Rewind to the beginning of the DSP code file (for verify) */
74 void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code);
76 /** Read one word from the dsp code file
77 \return 0 for success, or error code if eof, or block length exceeded
79 short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code,
80 /**< DSP code descriptor */
81 u32 *pword /**< Where to store the read word */
84 /** Get a block of dsp code into an internal buffer, and provide a pointer to
85 that buffer. (If dsp code is already an array in memory, it is referenced,
88 \return Error if requested number of words are not available
90 short hpi_dsp_code_read_block(size_t words_requested,
91 struct dsp_code *ps_dsp_code,
92 /* Pointer to store (Pointer to code buffer) */