@@ -2025,6 +2025,24 @@ static int dspload_image(struct hda_codec *codec,
2025
2025
return status ;
2026
2026
}
2027
2027
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
+
2028
2046
static bool dspload_is_loaded (struct hda_codec * codec )
2029
2047
{
2030
2048
unsigned int data = 0 ;
@@ -2542,18 +2560,15 @@ static bool ca0132_download_dsp_images(struct hda_codec *codec)
2542
2560
{
2543
2561
bool dsp_loaded = false;
2544
2562
const struct dsp_image_seg * dsp_os_image ;
2545
- const struct firmware * fw_entry ;
2546
2563
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 )
2548
2566
return false;
2549
2567
2550
- dsp_os_image = (struct dsp_image_seg * )(fw_entry -> data );
2568
+ dsp_os_image = (struct dsp_image_seg * )(fw_efx -> data );
2551
2569
dspload_image (codec , dsp_os_image , 0 , 0 , true, 0 );
2552
2570
dsp_loaded = dspload_wait_loaded (codec );
2553
2571
2554
- release_firmware (fw_entry );
2555
-
2556
-
2557
2572
return dsp_loaded ;
2558
2573
}
2559
2574
@@ -2665,6 +2680,7 @@ static int __init patch_ca0132_init(void)
2665
2680
2666
2681
static void __exit patch_ca0132_exit (void )
2667
2682
{
2683
+ release_cached_firmware ();
2668
2684
snd_hda_delete_codec_preset (& ca0132_list );
2669
2685
}
2670
2686
0 commit comments