Skip to content

Commit c3b4eea

Browse files
ikminetttiwai
authored andcommitted
ALSA: hda - Add firmware caching to CA0132 codec
Signed-off-by: Ian Minett <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent 01ef7db commit c3b4eea

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

sound/pci/hda/patch_ca0132.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,24 @@ static int dspload_image(struct hda_codec *codec,
20252025
return status;
20262026
}
20272027

2028+
static const struct firmware *fw_efx;
2029+
2030+
static int request_firmware_cached(const struct firmware **firmware_p,
2031+
const char *name, struct device *device)
2032+
{
2033+
if (*firmware_p)
2034+
return 0; /* already loaded */
2035+
return request_firmware(firmware_p, name, device);
2036+
}
2037+
2038+
static void release_cached_firmware(void)
2039+
{
2040+
if (fw_efx) {
2041+
release_firmware(fw_efx);
2042+
fw_efx = NULL;
2043+
}
2044+
}
2045+
20282046
static bool dspload_is_loaded(struct hda_codec *codec)
20292047
{
20302048
unsigned int data = 0;
@@ -2542,18 +2560,15 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
25422560
{
25432561
bool dsp_loaded = false;
25442562
const struct dsp_image_seg *dsp_os_image;
2545-
const struct firmware *fw_entry;
25462563

2547-
if (request_firmware(&fw_entry, EFX_FILE, codec->bus->card->dev) != 0)
2564+
if (request_firmware_cached(&fw_efx, EFX_FILE,
2565+
codec->bus->card->dev) != 0)
25482566
return false;
25492567

2550-
dsp_os_image = (struct dsp_image_seg *)(fw_entry->data);
2568+
dsp_os_image = (struct dsp_image_seg *)(fw_efx->data);
25512569
dspload_image(codec, dsp_os_image, 0, 0, true, 0);
25522570
dsp_loaded = dspload_wait_loaded(codec);
25532571

2554-
release_firmware(fw_entry);
2555-
2556-
25572572
return dsp_loaded;
25582573
}
25592574

@@ -2665,6 +2680,7 @@ static int __init patch_ca0132_init(void)
26652680

26662681
static void __exit patch_ca0132_exit(void)
26672682
{
2683+
release_cached_firmware();
26682684
snd_hda_delete_codec_preset(&ca0132_list);
26692685
}
26702686

0 commit comments

Comments
 (0)