Logo Search packages:      
Sourcecode: alsa-driver version File versions  Download package

short HpiDspCode_Open ( u32  nAdapter,
struct dsp_code psDspCode,
u32 *  pdwOsErrorCode 
)

Prepare *psDspCode to refer to the requuested adapter. Searches the file, or selects the appropriate linked array

Returns:
0 for success, or error code if requested code is not available
Parameters:
nAdapter  Adapter family Pointer to DSP code control structure
psDspCode  Pointer to dword to receive OS specific error code

Definition at line 65 of file hpidspcd.c.

References code_header::adapter, code_header::crc, dsp_code::dwBlockLength, dsp_code::dwCrc, dsp_code::dwVersion, dsp_code::dwWordCount, HPI_ERROR_DSP_FILE_NOT_FOUND, dsp_code::psDev, dsp_code::psFirmware, code_header::size, and code_header::version.

{
      const struct firmware *psFirmware = psDspCode->psFirmware;
      struct code_header header;
      char fw_name[20];
      int err;

      sprintf(fw_name, "asihpi/dsp%04x.bin", nAdapter);
      HPI_DEBUG_LOG(INFO, "Requesting firmware for %s\n", fw_name);

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2 , 5 , 0))
      err = request_firmware(&psFirmware, fw_name,
            psDspCode->psDev->slot_name);
#else
      err = request_firmware(&psFirmware, fw_name, &psDspCode->psDev->dev);
#endif
      if (err != 0) {
            HPI_DEBUG_LOG(ERROR, "%d, request_firmware failed for  %s\n",
                  err, fw_name);
            goto error1;
      }
      if (psFirmware->size < sizeof(header)) {
            HPI_DEBUG_LOG(ERROR, "Header size too small %s\n", fw_name);
            goto error2;
      }
      memcpy(&header, psFirmware->data, sizeof(header));
      if (header.adapter != nAdapter) {
            HPI_DEBUG_LOG(ERROR, "Adapter type incorrect %4x != %4x\n",
                  header.adapter, nAdapter);
            goto error2;
      }
      if (header.size != psFirmware->size) {
            HPI_DEBUG_LOG(ERROR, "Code size wrong  %d != %ld\n",
                  header.size, (unsigned long)psFirmware->size);
            goto error2;
      }

      if (header.version != HPI_VER_DECIMAL) {
            HPI_DEBUG_LOG(WARNING,
                  "Version mismatch  DSP image %d != Driver %d\n",
                  header.version, HPI_VER_DECIMAL);
            /* goto error2;  still allow driver to load */
      }

      HPI_DEBUG_LOG(INFO, "Dsp code %s opened\n", fw_name);
      psDspCode->psFirmware = psFirmware;
      psDspCode->dwBlockLength = header.size / sizeof(u32);
      psDspCode->dwWordCount = sizeof(header) / sizeof(u32);
      psDspCode->dwVersion = header.version;
      psDspCode->dwCrc = header.crc;
      return 0;

error2:
      release_firmware(psFirmware);
error1:
      psDspCode->psFirmware = NULL;
      psDspCode->dwBlockLength = 0;
      return (HPI_ERROR_DSP_FILE_NOT_FOUND);
}


Generated by  Doxygen 1.6.0   Back to index