96 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/***********************************************************************/3/*4 5 AudioScience HPI driver6 Copyright (C) 1997-2011 AudioScience Inc. <support@audioscience.com>7 8 9\file10Functions for reading DSP code to load into DSP11 12*/13/***********************************************************************/14#ifndef _HPIDSPCD_H_15#define _HPIDSPCD_H_16 17#include "hpi_internal.h"18 19/** Header structure for dsp firmware file20 This structure must match that used in s2bin.c for generation of asidsp.bin21 */22/*#ifndef DISABLE_PRAGMA_PACK1 */23/*#pragma pack(push, 1) */24/*#endif */25struct code_header {26 /** Size in bytes including header */27 u32 size;28 /** File type tag "CODE" == 0x45444F43 */29 u32 type;30 /** Adapter model number */31 u32 adapter;32 /** Firmware version*/33 u32 version;34 /** Data checksum */35 u32 checksum;36};37/*#ifndef DISABLE_PRAGMA_PACK1 */38/*#pragma pack(pop) */39/*#endif */40 41/*? Don't need the pragmas? */42compile_time_assert((sizeof(struct code_header) == 20), code_header_size);43 44/** Descriptor for dspcode from firmware loader */45struct dsp_code {46 /** copy of file header */47 struct code_header header;48 /** Expected number of words in the whole dsp code,INCL header */49 u32 block_length;50 /** Number of words read so far */51 u32 word_count;52 53 /** internal state of DSP code reader */54 struct dsp_code_private *pvt;55};56 57/** Prepare *psDspCode to refer to the requested adapter's firmware.58Code file name is obtained from HpiOs_GetDspCodePath59 60\return 0 for success, or error code if requested code is not available61*/62short 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 */68 u32 *pos_error_code);69 70/** Close the DSP code file */71void hpi_dsp_code_close(struct dsp_code *ps_dsp_code);72 73/** Rewind to the beginning of the DSP code file (for verify) */74void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code);75 76/** Read one word from the dsp code file77 \return 0 for success, or error code if eof, or block length exceeded78*/79short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code,80 /**< DSP code descriptor */81 u32 *pword /**< Where to store the read word */82 );83 84/** Get a block of dsp code into an internal buffer, and provide a pointer to85that buffer. (If dsp code is already an array in memory, it is referenced,86not copied.)87 88\return Error if requested number of words are not available89*/90short hpi_dsp_code_read_block(size_t words_requested,91 struct dsp_code *ps_dsp_code,92 /* Pointer to store (Pointer to code buffer) */93 u32 **ppblock);94 95#endif96