Commit 311e70a4 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] hdsp - Fix auto-updating of firmware

Fixed the auto-updating of firmware if the breakout box was switched
off/on.  The firmware binary itself was already cached but it wasn't
loaded properly.  Also, request_firmware() is issued if the box was
with firmware at module loading time but later it's erased.
The auto-update is triggered at each PCM action (open, prepare, etc)
and at opening proc files.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent ea543f1e
...@@ -726,23 +726,37 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp) ...@@ -726,23 +726,37 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
} }
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) { if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n");
hdsp->state &= ~HDSP_FirmwareLoaded; hdsp->state &= ~HDSP_FirmwareLoaded;
if (! show_err) if (! load_on_demand)
return -EIO; return -EIO;
snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n");
/* try to load firmware */ /* try to load firmware */
if (hdsp->state & HDSP_FirmwareCached) { if (! (hdsp->state & HDSP_FirmwareCached)) {
if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) #ifdef HDSP_FW_LOADER
snd_printk(KERN_ERR "Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n"); if (! hdsp_request_fw_loader(hdsp))
} else { return 0;
snd_printk(KERN_ERR "Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n"); #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 0;
} }
...@@ -3181,10 +3195,18 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) ...@@ -3181,10 +3195,18 @@ snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
return; return;
} }
} else { } else {
snd_iprintf(buffer, "No firmware loaded nor cached, please upload firmware.\n"); 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; return;
} }
} }
}
status = hdsp_read(hdsp, HDSP_statusRegister); status = hdsp_read(hdsp, HDSP_statusRegister);
status2 = hdsp_read(hdsp, HDSP_status2Register); status2 = hdsp_read(hdsp, HDSP_status2Register);
...@@ -3851,7 +3873,7 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd) ...@@ -3851,7 +3873,7 @@ static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd)
if (hdsp_check_for_iobox (hdsp)) if (hdsp_check_for_iobox (hdsp))
return -EIO; return -EIO;
if (hdsp_check_for_firmware(hdsp, 1)) if (hdsp_check_for_firmware(hdsp, 0)) /* no auto-loading in trigger */
return -EIO; return -EIO;
spin_lock(&hdsp->lock); spin_lock(&hdsp->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment