14
14
#include <linux/regmap.h>
15
15
#include <linux/slab.h>
16
16
#include <sound/core.h>
17
+ #include <sound/cs-amp-lib.h>
17
18
#include <sound/hda_codec.h>
18
19
#include <sound/tlv.h>
19
20
#include "cirrus_scodec.h"
@@ -547,6 +548,22 @@ static void cs35l56_hda_add_dsp_controls(struct cs35l56_hda *cs35l56)
547
548
hda_cs_dsp_add_controls (& cs35l56 -> cs_dsp , & info );
548
549
}
549
550
551
+ static void cs35l56_hda_apply_calibration (struct cs35l56_hda * cs35l56 )
552
+ {
553
+ int ret ;
554
+
555
+ if (!cs35l56 -> base .cal_data_valid || cs35l56 -> base .secured )
556
+ return ;
557
+
558
+ ret = cs_amp_write_cal_coeffs (& cs35l56 -> cs_dsp ,
559
+ & cs35l56_calibration_controls ,
560
+ & cs35l56 -> base .cal_data );
561
+ if (ret < 0 )
562
+ dev_warn (cs35l56 -> base .dev , "Failed to write calibration: %d\n" , ret );
563
+ else
564
+ dev_info (cs35l56 -> base .dev , "Calibration applied\n" );
565
+ }
566
+
550
567
static int cs35l56_hda_fw_load (struct cs35l56_hda * cs35l56 )
551
568
{
552
569
const struct firmware * coeff_firmware = NULL ;
@@ -618,12 +635,8 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
618
635
if (coeff_filename )
619
636
dev_dbg (cs35l56 -> base .dev , "Loaded Coefficients: %s\n" , coeff_filename );
620
637
621
- if (!firmware_missing ) {
622
- ret = cs35l56_mbox_send (& cs35l56 -> base , CS35L56_MBOX_CMD_AUDIO_REINIT );
623
- if (ret )
624
- goto err_powered_up ;
625
- } else if (wmfw_firmware || coeff_firmware ) {
626
- /* If we downloaded firmware, reset the device and wait for it to boot */
638
+ /* If we downloaded firmware, reset the device and wait for it to boot */
639
+ if (firmware_missing && (wmfw_firmware || coeff_firmware )) {
627
640
cs35l56_system_reset (& cs35l56 -> base , false);
628
641
regcache_mark_dirty (cs35l56 -> base .regmap );
629
642
ret = cs35l56_wait_for_firmware_boot (& cs35l56 -> base );
@@ -646,6 +659,11 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56)
646
659
if (ret )
647
660
dev_dbg (cs35l56 -> base .dev , "%s: cs_dsp_run ret %d\n" , __func__ , ret );
648
661
662
+ cs35l56_hda_apply_calibration (cs35l56 );
663
+ ret = cs35l56_mbox_send (& cs35l56 -> base , CS35L56_MBOX_CMD_AUDIO_REINIT );
664
+ if (ret )
665
+ cs_dsp_stop (& cs35l56 -> cs_dsp );
666
+
649
667
err_powered_up :
650
668
if (!cs35l56 -> base .fw_patched )
651
669
cs_dsp_power_down (& cs35l56 -> cs_dsp );
@@ -953,6 +971,8 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int id)
953
971
goto err ;
954
972
}
955
973
974
+ cs35l56 -> base .cal_index = cs35l56 -> index ;
975
+
956
976
cs35l56_init_cs_dsp (& cs35l56 -> base , & cs35l56 -> cs_dsp );
957
977
cs35l56 -> cs_dsp .client_ops = & cs35l56_hda_client_ops ;
958
978
@@ -990,6 +1010,10 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int id)
990
1010
if (ret )
991
1011
goto err ;
992
1012
1013
+ ret = cs35l56_get_calibration (& cs35l56 -> base );
1014
+ if (ret )
1015
+ goto err ;
1016
+
993
1017
ret = cs_dsp_halo_init (& cs35l56 -> cs_dsp );
994
1018
if (ret ) {
995
1019
dev_err_probe (cs35l56 -> base .dev , ret , "cs_dsp_halo_init failed\n" );
@@ -1064,10 +1088,11 @@ const struct dev_pm_ops cs35l56_hda_pm_ops = {
1064
1088
EXPORT_SYMBOL_NS_GPL (cs35l56_hda_pm_ops , SND_HDA_SCODEC_CS35L56 );
1065
1089
1066
1090
MODULE_DESCRIPTION ("CS35L56 HDA Driver" );
1091
+ MODULE_IMPORT_NS (FW_CS_DSP );
1067
1092
MODULE_IMPORT_NS (SND_HDA_CIRRUS_SCODEC );
1068
1093
MODULE_IMPORT_NS (SND_HDA_CS_DSP_CONTROLS );
1069
1094
MODULE_IMPORT_NS (SND_SOC_CS35L56_SHARED );
1095
+ MODULE_IMPORT_NS (SND_SOC_CS_AMP_LIB );
1070
1096
MODULE_AUTHOR (
"Richard Fitzgerald <[email protected] >" );
1071
1097
MODULE_AUTHOR (
"Simon Trimmer <[email protected] >" );
1072
1098
MODULE_LICENSE ("GPL" );
1073
- MODULE_IMPORT_NS (FW_CS_DSP );
0 commit comments