}
-static int hdsp_check_for_firmware (struct hdsp *hdsp, int show_err)
+#ifdef HDSP_FW_LOADER
+static int __devinit hdsp_request_fw_loader(struct hdsp *hdsp);
+#endif
+
+static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand)
{
- if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
+ if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
+ return 0;
if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
- snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n");
hdsp->state &= ~HDSP_FirmwareLoaded;
- if (! show_err)
+ if (! load_on_demand)
return -EIO;
+ snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n");
/* try to load firmware */
- if (hdsp->state & HDSP_FirmwareCached) {
- if (snd_hdsp_load_firmware_from_cache(hdsp) != 0)
- snd_printk(KERN_ERR "Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");
- } else {
- snd_printk(KERN_ERR "Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");
+ if (! (hdsp->state & HDSP_FirmwareCached)) {
+#ifdef HDSP_FW_LOADER
+ if (! hdsp_request_fw_loader(hdsp))
+ return 0;
+#endif
+ snd_printk(KERN_ERR
+ "Hammerfall-DSP: No firmware loaded nor "
+ "cached, please upload firmware.\n");
+ return -EIO;
+ }
+ if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
+ snd_printk(KERN_ERR
+ "Hammerfall-DSP: Firmware loading from "
+ "cache failed, please upload manually.\n");
+ return -EIO;
}
- return -EIO;
}
return 0;
}
return;
}
} else {
- snd_iprintf(buffer, "No firmware loaded nor cached, please upload firmware.\n");
- return;
+ int err = -EINVAL;
+#ifdef HDSP_FW_LOADER
+ err = hdsp_request_fw_loader(hdsp);
+#endif
+ if (err < 0) {
+ snd_iprintf(buffer,
+ "No firmware loaded nor cached, "
+ "please upload firmware.\n");
+ return;
+ }
}
}
if (hdsp_check_for_iobox (hdsp))
return -EIO;
- if (hdsp_check_for_firmware(hdsp, 1))
+ if (hdsp_check_for_firmware(hdsp, 0)) /* no auto-loading in trigger */
return -EIO;
spin_lock(&hdsp->lock);