From: Takashi Iwai Subject: Re: [PATCH 6/8] ALSA: Add firmware caching to CA0132 codec Date: Fri, 14 Sep 2012 10:57:26 +0200 Message-ID: References: <1347585358-2403-1-git-send-email-ian_minett@creativelabs.com> <1347585358-2403-7-git-send-email-ian_minett@creativelabs.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 9A462265CD1 for ; Fri, 14 Sep 2012 10:57:26 +0200 (CEST) In-Reply-To: <1347585358-2403-7-git-send-email-ian_minett@creativelabs.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Ian Minett Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Thu, 13 Sep 2012 18:15:56 -0700, Ian Minett wrote: > > From: Ian Minett FWIW, the 3.7 kernel will have a firmware cache infrastructure, so this patch can be converted with it later. BTW, what about the firmware loading upon PM resume? I guess at least S4 requires the firmware loading. Does the firmware on chip survive after S3? Takashi > > > Signed-off-by: Ian Minett > > 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 >