ASoC: rt5514: Revert Hotword Model control
authorHsin-Yu Chao <hychao@chromium.org>
Fri, 15 Sep 2017 04:32:00 +0000 (12:32 +0800)
committerMark Brown <broonie@kernel.org>
Fri, 15 Sep 2017 16:39:01 +0000 (09:39 -0700)
This reverts commit eb33869c7206 ("ASoC: rt5514: Guard Hotword Model bytes
loading") and commit d18420b0a0b8 ("ASoC: rt5514: expose Hotword Model
control")

It is discouraged to use SND_SOC_BYTES_TLV to load arbitrary bytes from
userspace to driver. Removing the 'Hotword Model' control until we have
a good way to verify the content of hotword model blobs.

Signed-off-by: Hsin-Yu Chao <hychao@chromium.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt5514.c
sound/soc/codecs/rt5514.h

index 0945d212b8dca9d34d19b273d9075977075964e1..d7956ababd11775b0b9d04552faa68f2fadd2545 100644 (file)
@@ -338,39 +338,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
                                fw = NULL;
                        }
 
-                       if (rt5514->model_buf && rt5514->model_len) {
-#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
-                               int ret;
-
-                               ret = rt5514_spi_burst_write(0x4ff80000,
-                                       rt5514->model_buf,
-                                       ((rt5514->model_len / 8) + 1) * 8);
-                               if (ret) {
-                                       dev_err(codec->dev,
-                                               "Model load failed %d\n", ret);
-                                       return ret;
-                               }
-#else
-                               dev_err(codec->dev,
-                                       "No SPI driver for loading firmware\n");
-#endif
-                       } else {
-                               request_firmware(&fw, RT5514_FIRMWARE3,
-                                                codec->dev);
-                               if (fw) {
-#if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI)
-                                       rt5514_spi_burst_write(0x4ff80000,
-                                               fw->data,
-                                               ((fw->size/8)+1)*8);
-#else
-                                       dev_err(codec->dev,
-                                               "No SPI driver to load fw\n");
-#endif
-                                       release_firmware(fw);
-                                       fw = NULL;
-                               }
-                       }
-
                        /* DSP run */
                        regmap_write(rt5514->i2c_regmap, 0x18002f00,
                                0x00055148);
@@ -385,34 +352,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static int rt5514_hotword_model_put(struct snd_kcontrol *kcontrol,
-               const unsigned int __user *bytes, unsigned int size)
-{
-       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
-       struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
-       struct snd_soc_codec *codec = rt5514->codec;
-       int ret = 0;
-
-       if (rt5514->model_buf || rt5514->model_len < size) {
-               if (rt5514->model_buf)
-                       devm_kfree(codec->dev, rt5514->model_buf);
-               rt5514->model_buf = devm_kmalloc(codec->dev, size, GFP_KERNEL);
-               if (!rt5514->model_buf) {
-                       ret = -ENOMEM;
-                       goto done;
-               }
-       }
-
-       /* Skips the TLV header. */
-       bytes += 2;
-
-       if (copy_from_user(rt5514->model_buf, bytes, size))
-               ret = -EFAULT;
-done:
-       rt5514->model_len = (ret ? 0 : size);
-       return ret;
-}
-
 static const struct snd_kcontrol_new rt5514_snd_controls[] = {
        SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST,
                RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv),
@@ -424,8 +363,6 @@ static const struct snd_kcontrol_new rt5514_snd_controls[] = {
                adc_vol_tlv),
        SOC_SINGLE_EXT("DSP Voice Wake Up", SND_SOC_NOPM, 0, 1, 0,
                rt5514_dsp_voice_wake_up_get, rt5514_dsp_voice_wake_up_put),
-       SND_SOC_BYTES_TLV("Hotword Model", 0x8504,
-               NULL, rt5514_hotword_model_put),
 };
 
 /* ADC Mixer*/
index 803311cb7e2a075aa405847a673b31cac66afc6a..2dc40e6d8b3f69835ded69ac71012cb765ac0a36 100644 (file)
 
 #define RT5514_FIRMWARE1       "rt5514_dsp_fw1.bin"
 #define RT5514_FIRMWARE2       "rt5514_dsp_fw2.bin"
-#define RT5514_FIRMWARE3       "rt5514_dsp_fw3.bin"
 
 /* System Clock Source */
 enum {
@@ -282,8 +281,6 @@ struct rt5514_priv {
        int pll_in;
        int pll_out;
        int dsp_enabled;
-       u8 *model_buf;
-       unsigned int model_len;
 };
 
 #endif /* __RT5514_H__ */