|
@@ -1381,10 +1381,18 @@ static int lpass_cdc_wsa2_macro_config_compander(struct snd_soc_component *compo
|
|
|
dev_dbg(component->dev, "%s: event %d compander %d, enabled %d\n",
|
|
|
__func__, event, comp + 1, wsa2_priv->comp_enabled[comp]);
|
|
|
|
|
|
+ if (comp >= LPASS_CDC_WSA2_MACRO_COMP_MAX || comp < 0) {
|
|
|
+ dev_err(component->dev, "%s: Invalid compander value: %d\n",
|
|
|
+ __func__, comp);
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+
|
|
|
if (!wsa2_priv->comp_enabled[comp])
|
|
|
return 0;
|
|
|
|
|
|
mode = wsa2_priv->comp_mode[comp];
|
|
|
+ if (mode >= G_MAX_DB || mode < 0)
|
|
|
+ mode = 0;
|
|
|
comp_ctl0_reg = LPASS_CDC_WSA2_COMPANDER0_CTL0 +
|
|
|
(comp * LPASS_CDC_WSA2_MACRO_RX_COMP_OFFSET);
|
|
|
comp_ctl8_reg = LPASS_CDC_WSA2_COMPANDER0_CTL8 +
|
|
@@ -2415,7 +2423,12 @@ static int lpass_cdc_wsa2_macro_comp_mode_put(struct snd_kcontrol *kcontrol,
|
|
|
idx = LPASS_CDC_WSA2_MACRO_COMP1;
|
|
|
if (strnstr(kcontrol->id.name, "RX1", sizeof("WSA2_RX1")))
|
|
|
idx = LPASS_CDC_WSA2_MACRO_COMP2;
|
|
|
- wsa2_priv->comp_mode[idx] = ucontrol->value.integer.value[0];
|
|
|
+
|
|
|
+ if (ucontrol->value.integer.value[0] < G_MAX_DB &&
|
|
|
+ ucontrol->value.integer.value[0] >= 0)
|
|
|
+ wsa2_priv->comp_mode[idx] = ucontrol->value.integer.value[0];
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
|
|
|
dev_dbg(component->dev, "%s: comp_mode = %d\n", __func__,
|
|
|
wsa2_priv->comp_mode[idx]);
|