Skip to content

Commit 6dad45f

Browse files
soyersoyertiwai
authored andcommitted
ALSA: hda/tas2781: do not use regcache
There are two problems with using regcache in this module. The amplifier has 3 addressing levels (BOOK, PAGE, REG). The firmware contains blocks that must be written to BOOK 0x8C. The regcache doesn't know anything about BOOK, so regcache_sync writes invalid values to the actual BOOK. The module handles 2 or more separate amplifiers. The amplifiers have different register values, and the module uses only one regmap/regcache for all the amplifiers. The regcache_sync only writes the last amplifier used. The module successfully restores all the written register values (RC profile, program, configuration, calibration) without regcache. Remove regcache functions and set regmap cache_type to REGCACHE_NONE. Link: https://lore.kernel.org/r/21a183b5a08cb23b193af78d4b1114cc59419272.1701906455.git.soyer@irl.hu/ Fixes: 5be27f1 ("ALSA: hda/tas2781: Add tas2781 HDA driver") Acked-by: Mark Brown <[email protected]> CC: [email protected] Signed-off-by: Gergo Koteles <[email protected]> Link: https://lore.kernel.org/r/491aeed0e2eecc3b704ec856f815db21bad3ba0e.1703202126.git.soyer@irl.hu Signed-off-by: Takashi Iwai <[email protected]>
1 parent 916d051 commit 6dad45f

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

sound/pci/hda/tas2781_hda_i2c.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,6 @@ static int tas2781_runtime_suspend(struct device *dev)
717717
tas_priv->tasdevice[i].cur_conf = -1;
718718
}
719719

720-
regcache_cache_only(tas_priv->regmap, true);
721-
regcache_mark_dirty(tas_priv->regmap);
722720

723721
mutex_unlock(&tas_priv->codec_lock);
724722

@@ -730,20 +728,11 @@ static int tas2781_runtime_resume(struct device *dev)
730728
struct tasdevice_priv *tas_priv = dev_get_drvdata(dev);
731729
unsigned long calib_data_sz =
732730
tas_priv->ndev * TASDEVICE_SPEAKER_CALIBRATION_SIZE;
733-
int ret;
734731

735732
dev_dbg(tas_priv->dev, "Runtime Resume\n");
736733

737734
mutex_lock(&tas_priv->codec_lock);
738735

739-
regcache_cache_only(tas_priv->regmap, false);
740-
ret = regcache_sync(tas_priv->regmap);
741-
if (ret) {
742-
dev_err(tas_priv->dev,
743-
"Failed to restore register cache: %d\n", ret);
744-
goto out;
745-
}
746-
747736
tasdevice_prmg_load(tas_priv, tas_priv->cur_prog);
748737

749738
/* If calibrated data occurs error, dsp will still works with default
@@ -752,10 +741,9 @@ static int tas2781_runtime_resume(struct device *dev)
752741
if (tas_priv->cali_data.total_sz > calib_data_sz)
753742
tas2781_apply_calib(tas_priv);
754743

755-
out:
756744
mutex_unlock(&tas_priv->codec_lock);
757745

758-
return ret;
746+
return 0;
759747
}
760748

761749
static int tas2781_system_suspend(struct device *dev)
@@ -770,10 +758,7 @@ static int tas2781_system_suspend(struct device *dev)
770758
return ret;
771759

772760
/* Shutdown chip before system suspend */
773-
regcache_cache_only(tas_priv->regmap, false);
774761
tasdevice_tuning_switch(tas_priv, 1);
775-
regcache_cache_only(tas_priv->regmap, true);
776-
regcache_mark_dirty(tas_priv->regmap);
777762

778763
/*
779764
* Reset GPIO may be shared, so cannot reset here.

sound/soc/codecs/tas2781-comlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static const struct regmap_range_cfg tasdevice_ranges[] = {
3939
static const struct regmap_config tasdevice_regmap = {
4040
.reg_bits = 8,
4141
.val_bits = 8,
42-
.cache_type = REGCACHE_RBTREE,
42+
.cache_type = REGCACHE_NONE,
4343
.ranges = tasdevice_ranges,
4444
.num_ranges = ARRAY_SIZE(tasdevice_ranges),
4545
.max_register = 256 * 128,

0 commit comments

Comments
 (0)