summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincenttew <vincenttew@google.com>2022-05-25 00:45:28 +0800
committerVincent Tew <vincenttew@google.com>2022-05-27 10:05:47 +0000
commitb2b99f296410c0e91c6459e924a63a63c39f649f (patch)
tree279e019d84b4484e20ddb155b33e10241e7092cc
parent47f06688de339d990f326d65a9c6798d18318ed9 (diff)
downloadamplifiers-b2b99f296410c0e91c6459e924a63a63c39f649f.tar.gz
cs35l41: update current peak to register
Bug: 228796239 Signed-off-by: vincenttew <vincenttew@google.com> Change-Id: I38b50eda84106187f29a129e54be501af896d4e7 (cherry picked from commit 3c7c36e348481910a9d98a1881da11a418b86621)
-rw-r--r--cs35l41/cs35l41.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/cs35l41/cs35l41.c b/cs35l41/cs35l41.c
index dc9594f..c29230b 100644
--- a/cs35l41/cs35l41.c
+++ b/cs35l41/cs35l41.c
@@ -322,9 +322,11 @@ static int cs35l41_bp_current_limit_get(struct snd_kcontrol *kcontrol,
snd_soc_kcontrol_component(kcontrol);
struct cs35l41_private *cs35l41 =
snd_soc_component_get_drvdata(component);
+ struct soc_enum *soc_enum = (struct soc_enum *)kcontrol->private_value;
+ int value = 0;
- ucontrol->value.integer.value[0] =
- (long)(((cs35l41->pdata.bst_ipk - 1600) / 50) + 0x10);
+ regmap_read(cs35l41->regmap, soc_enum->reg, (int *)&value);
+ ucontrol->value.integer.value[0] = (long)(value & CS35L41_BST_IPK_MASK);
return 0;
}
@@ -336,11 +338,22 @@ static int cs35l41_bp_current_limit_put(struct snd_kcontrol *kcontrol,
snd_soc_kcontrol_component(kcontrol);
struct cs35l41_private *cs35l41 =
snd_soc_component_get_drvdata(component);
+ int ret = 0;
cs35l41->pdata.bst_ipk =
((int)ucontrol->value.integer.value[0] - 0x10) * 50 + 1600;
- dev_info(cs35l41->dev, "%s: value %d\n",
+
+ ret = regmap_update_bits(cs35l41->regmap, CS35L41_BSTCVRT_PEAK_CUR,
+ CS35L41_BST_IPK_MASK,
+ ((int)ucontrol->value.integer.value[0] << CS35L41_BST_IPK_SHIFT));
+
+ if (ret) {
+ dev_err(cs35l41->dev, "Failed to write peak current limit\n");
+ return ret;
+ } else {
+ dev_info(cs35l41->dev, "%s: value %d\n",
__func__, cs35l41->pdata.bst_ipk);
+ }
return 0;
}