From: Tim Blechmann <tim@klingt.org>
To: alsa-devel@alsa-project.org
Subject: [PATCH] ALSA: hdsp - poll for iobox
Date: Fri, 20 Feb 2009 19:30:35 +0100 [thread overview]
Message-ID: <20090220193035.61928f71@thinkpad> (raw)
sleeping for 2 seconds before checking for the iobox is not enough
on some systems.
this patch increases the timeout, but polls the card during that
time. it thus speeds up the module loading when the card has already
been initialized, while being more robust on systems, which require
a higher timeout than the predefined 2 seconds.
Signed-off-by: Tim Blechmann <tim@klingt.org>
---
sound/pci/rme9652/hdsp.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 44d0c15..a586a80 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -653,7 +653,6 @@ static unsigned int hdsp_read(struct hdsp *hdsp, int reg)
static int hdsp_check_for_iobox (struct hdsp *hdsp)
{
-
if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0;
if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError) {
snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n");
@@ -661,7 +660,27 @@ static int hdsp_check_for_iobox (struct hdsp *hdsp)
return -EIO;
}
return 0;
+}
+static int hdsp_wait_for_iobox (struct hdsp *hdsp, unsigned int loops, unsigned int delay)
+{
+ unsigned int i;
+
+ if (hdsp->io_type == H9652 || hdsp->io_type == H9632)
+ return 0;
+
+ for (i = 0; i != loops; ++i) {
+ if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_ConfigError)
+ msleep(delay);
+ else {
+ snd_printd ("Hammerfall-DSP: iobox found after %ums!\n", i * delay);
+ return 0;
+ }
+ }
+
+ snd_printk ("Hammerfall-DSP: no Digiface or Multiface connected!\n");
+ hdsp->state &= ~HDSP_FirmwareLoaded;
+ return -EIO;
}
static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
@@ -5055,10 +5074,9 @@ static int __devinit snd_hdsp_create(struct snd_card *card,
return err;
if (!is_9652 && !is_9632) {
- /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
- ssleep(2);
+ /* we wait a maximum of 10 seconds to let freshly inserted cardbus cards do their hardware init */
+ err = hdsp_wait_for_iobox(hdsp, 1000, 10);
- err = hdsp_check_for_iobox(hdsp);
if (err < 0)
return err;
--
1.6.1.2
next reply other threads:[~2009-02-20 18:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-20 18:30 Tim Blechmann [this message]
2009-02-23 8:58 ` [PATCH] ALSA: hdsp - poll for iobox Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090220193035.61928f71@thinkpad \
--to=tim@klingt.org \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.