From 065923bf1b3448e5330c2d83c93607e17fd3b4c1 Mon Sep 17 00:00:00 2001 From: Vaibhav Raut Date: Tue, 20 Dec 2022 15:54:10 +0530 Subject: [PATCH] asoc: wsa881x: Fix to set the correct volume level To avoid mismatch volume level on WSA8810, update the enum. Change-Id: I01f592d0817d83a1e0ea7b736c0c101e6903cceb Signed-off-by: Shashi Kant Maurya --- asoc/codecs/wsa881x-analog.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/asoc/codecs/wsa881x-analog.c b/asoc/codecs/wsa881x-analog.c index 50ba75bfea6c..57615c414ba8 100755 --- a/asoc/codecs/wsa881x-analog.c +++ b/asoc/codecs/wsa881x-analog.c @@ -75,6 +75,7 @@ struct wsa881x_pdata { int clk_cnt; int enable_cnt; int version; + int wsa881x_id; struct mutex bg_lock; struct mutex res_lock; struct delayed_work ocp_ctl_work; @@ -91,6 +92,10 @@ enum { WSA881X_STATUS_I2C, }; +enum { + WSA8810, + WSA8815, +}; #define WSA881X_OCP_CTL_TIMER_SEC 2 #define WSA881X_OCP_CTL_TEMP_CELSIUS 25 #define WSA881X_OCP_CTL_POLL_TIMER_SEC 60 @@ -119,9 +124,14 @@ static int wsa881x_i2c_addr = -1; static int wsa881x_probing_count; static int wsa881x_presence_count; +/* Gain value maximum of 18dBv supported on WSA8815 +* and maximum of 13.5dBv on WSA8810 +*/ static const char * const wsa881x_spk_pa_gain_text[] = { -"POS_13P5_DB", "POS_12_DB", "POS_10P5_DB", "POS_9_DB", "POS_7P5_DB", -"POS_6_DB", "POS_4P5_DB", "POS_3_DB", "POS_1P5_DB", "POS_0_DB"}; +"POS_18_DB", "POS_16P5_DB", "POS_15_DB", "POS_13P5_DB", +"POS_12_DB", "POS_10P5_DB", "POS_9_DB", "POS_7P5_DB", +"POS_6_DB", "POS_4P5_DB", "POS_3_DB", "POS_1P5_DB", +"POS_0_DB"}; static const struct soc_enum wsa881x_spk_pa_gain_enum[] = { SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(wsa881x_spk_pa_gain_text), @@ -158,6 +168,12 @@ static int wsa881x_spk_pa_gain_put(struct snd_kcontrol *kcontrol, __func__, ucontrol->value.integer.value[0]); return -EINVAL; } + if (ucontrol->value.integer.value[0] < 3 && + wsa881x->wsa881x_id == WSA8810) { + dev_err(component->dev, "%s: Unsupported gain val %ld for WSA8810\n", + __func__, ucontrol->value.integer.value[0]); + return -EINVAL; + } wsa881x->spk_pa_gain = ucontrol->value.integer.value[0]; dev_dbg(component->dev, "%s: ucontrol->value.integer.value[0] = %ld\n", __func__, ucontrol->value.integer.value[0]); @@ -1538,6 +1554,14 @@ static int wsa881x_i2c_probe(struct i2c_client *client, pdata->regmap[WSA881X_DIGITAL_SLAVE], WSA881X_DIGITAL_SLAVE); } + pdata->wsa881x_id = wsa881x_i2c_read_device(pdata, + WSA881X_OTP_REG_0); + if (pdata->wsa881x_id & 0x01) { + pdata->wsa881x_id = WSA8815; + } else { + pdata->wsa881x_id = WSA8810; + } + pr_debug("%s: wsa881x_id : %d\n", __func__, pdata->wsa881x_id); wsa881x_presence_count++; wsa881x_probing_count++;