summaryrefslogtreecommitdiff
path: root/sound/soc/codecs/rt1316-sdw.c
diff options
context:
space:
mode:
authorShuming Fan <shumingf@realtek.com>2022-11-09 12:12:44 +0300
committerMark Brown <broonie@kernel.org>2022-11-10 23:42:22 +0300
commit3c46b589db83db8a445924d0273005631a056aea (patch)
treef82341fe85a3b15d81f05a908b401104930fe946 /sound/soc/codecs/rt1316-sdw.c
parent5efb40b335a70010999311187be4517f5f114009 (diff)
downloadlinux-3c46b589db83db8a445924d0273005631a056aea.tar.xz
ASoC: rt1316-sdw: get BQ params property and apply them
If the machine driver level sets the BQ params into the device property, the codec driver will get the BQ params and apply them. Signed-off-by: Shuming Fan <shumingf@realtek.com> Reviewed-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Link: https://lore.kernel.org/r/20221109091244.17198-1-shumingf@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt1316-sdw.c')
-rw-r--r--sound/soc/codecs/rt1316-sdw.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sound/soc/codecs/rt1316-sdw.c b/sound/soc/codecs/rt1316-sdw.c
index ed0a11436362..2db7ee6c6d33 100644
--- a/sound/soc/codecs/rt1316-sdw.c
+++ b/sound/soc/codecs/rt1316-sdw.c
@@ -254,6 +254,17 @@ static int rt1316_read_prop(struct sdw_slave *slave)
return 0;
}
+static void rt1316_apply_bq_params(struct rt1316_sdw_priv *rt1316)
+{
+ unsigned int i, reg, data;
+
+ for (i = 0; i < rt1316->bq_params_cnt; i += 3) {
+ reg = rt1316->bq_params[i] | (rt1316->bq_params[i + 1] << 8);
+ data = rt1316->bq_params[i + 2];
+ regmap_write(rt1316->regmap, reg, data);
+ }
+}
+
static int rt1316_io_init(struct device *dev, struct sdw_slave *slave)
{
struct rt1316_sdw_priv *rt1316 = dev_get_drvdata(dev);
@@ -590,14 +601,42 @@ static struct sdw_slave_ops rt1316_slave_ops = {
.update_status = rt1316_update_status,
};
+static int rt1316_sdw_parse_dt(struct rt1316_sdw_priv *rt1316, struct device *dev)
+{
+ int ret = 0;
+
+ device_property_read_u32(dev, "realtek,bq-params-cnt", &rt1316->bq_params_cnt);
+ if (rt1316->bq_params_cnt) {
+ rt1316->bq_params = devm_kzalloc(dev, rt1316->bq_params_cnt, GFP_KERNEL);
+ if (!rt1316->bq_params) {
+ dev_err(dev, "Could not allocate bq_params memory\n");
+ ret = -ENOMEM;
+ } else {
+ ret = device_property_read_u8_array(dev, "realtek,bq-params", rt1316->bq_params, rt1316->bq_params_cnt);
+ if (ret < 0)
+ dev_err(dev, "Could not read list of realtek,bq-params\n");
+ }
+ }
+
+ dev_dbg(dev, "bq_params_cnt=%d\n", rt1316->bq_params_cnt);
+ return ret;
+}
+
static int rt1316_sdw_component_probe(struct snd_soc_component *component)
{
+ struct rt1316_sdw_priv *rt1316 = snd_soc_component_get_drvdata(component);
int ret;
+ rt1316->component = component;
+ rt1316_sdw_parse_dt(rt1316, &rt1316->sdw_slave->dev);
+
ret = pm_runtime_resume(component->dev);
if (ret < 0 && ret != -EACCES)
return ret;
+ /* apply BQ params */
+ rt1316_apply_bq_params(rt1316);
+
return 0;
}