From: Ian Minett <ian_minett@creativelabs.com>
To: patch@alsa-project.org
Cc: alsa-devel@alsa-project.org, Ian Minett <ian_minett@creativelabs.com>
Subject: [PATCH 6/8] ALSA: Add firmware caching to CA0132 codec
Date: Thu, 13 Sep 2012 18:15:56 -0700 [thread overview]
Message-ID: <1347585358-2403-7-git-send-email-ian_minett@creativelabs.com> (raw)
In-Reply-To: <1347585358-2403-1-git-send-email-ian_minett@creativelabs.com>
From: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 11f5910..ef66817 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -2025,6 +2025,24 @@ static int dspload_image(struct hda_codec *codec,
return status;
}
+static const struct firmware *fw_efx;
+
+static int request_firmware_cached(const struct firmware **firmware_p,
+ const char *name, struct device *device)
+{
+ if (*firmware_p)
+ return 0; /* already loaded */
+ return request_firmware(firmware_p, name, device);
+}
+
+static void release_cached_firmware(void)
+{
+ if (fw_efx) {
+ release_firmware(fw_efx);
+ fw_efx = NULL;
+ }
+}
+
static bool dspload_is_loaded(struct hda_codec *codec)
{
unsigned int data = 0;
@@ -2542,18 +2560,15 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
{
bool dsp_loaded = false;
const struct dsp_image_seg *dsp_os_image;
- const struct firmware *fw_entry;
- if (request_firmware(&fw_entry, EFX_FILE, codec->bus->card->dev) != 0)
+ if (request_firmware_cached(&fw_efx, EFX_FILE,
+ codec->bus->card->dev) != 0)
return false;
- dsp_os_image = (struct dsp_image_seg *)(fw_entry->data);
+ dsp_os_image = (struct dsp_image_seg *)(fw_efx->data);
dspload_image(codec, dsp_os_image, 0, 0, true, 0);
dsp_loaded = dspload_wait_loaded(codec);
- release_firmware(fw_entry);
-
-
return dsp_loaded;
}
@@ -2662,7 +2677,8 @@ static int __init patch_ca0132_init(void)
}
static void __exit patch_ca0132_exit(void)
-{
+{
+ release_cached_firmware();
snd_hda_delete_codec_preset(&ca0132_list);
}
--
1.7.4.1
next prev parent reply other threads:[~2012-09-14 1:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-14 1:15 [PATCH 0/8] ALSA: Add DSP firmware loader (resub) Ian Minett
2012-09-14 1:15 ` [PATCH 1/8] ALSA: Make snd_sgbuf_get_{ptr|addr}() available for non-SG cases Ian Minett
2012-09-14 1:15 ` [PATCH 2/8] ALSA: Add new DSP loader callback routines Ian Minett
2012-09-14 1:15 ` [PATCH 3/8] ALSA: Add CA0132 register definitions file Ian Minett
2012-09-14 1:15 ` [PATCH 4/8] ALSA: Add DSP firmware enums and defs to CA0132 codec Ian Minett
2012-09-14 8:40 ` Takashi Iwai
2012-09-14 1:15 ` [PATCH 5/8] ALSA: Update CA0132 codec to load DSP firmware binary Ian Minett
2012-09-14 8:51 ` Takashi Iwai
2012-09-14 8:52 ` Takashi Iwai
2012-09-14 1:15 ` Ian Minett [this message]
2012-09-14 8:57 ` [PATCH 6/8] ALSA: Add firmware caching to CA0132 codec Takashi Iwai
2012-09-14 1:15 ` [PATCH 7/8] ALSA: Add comments and descriptions to functions Ian Minett
2012-09-14 8:59 ` Takashi Iwai
2012-09-14 1:15 ` [PATCH 8/8] ALSA: Change return value for load_dsp_prepare() to -ENOSYS Ian Minett
2012-09-14 9:01 ` Takashi Iwai
2012-09-14 8:32 ` [PATCH 0/8] ALSA: Add DSP firmware loader (resub) 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=1347585358-2403-7-git-send-email-ian_minett@creativelabs.com \
--to=ian_minett@creativelabs.com \
--cc=alsa-devel@alsa-project.org \
--cc=patch@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).