Loading sound/soc/codecs/rt5514-spi.c +15 −2 Original line number Original line Diff line number Diff line Loading @@ -145,9 +145,8 @@ static void rt5514_spi_copy_work(struct work_struct *work) mutex_unlock(&rt5514_dsp->dma_lock); mutex_unlock(&rt5514_dsp->dma_lock); } } static irqreturn_t rt5514_spi_irq(int irq, void *data) static void rt5514_schedule_copy(struct rt5514_dsp *rt5514_dsp) { { struct rt5514_dsp *rt5514_dsp = data; u8 buf[8]; u8 buf[8]; rt5514_dsp->get_size = 0; rt5514_dsp->get_size = 0; Loading Loading @@ -180,6 +179,13 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data) if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit && if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit && rt5514_dsp->buf_rp && rt5514_dsp->buf_size) rt5514_dsp->buf_rp && rt5514_dsp->buf_size) schedule_delayed_work(&rt5514_dsp->copy_work, 0); schedule_delayed_work(&rt5514_dsp->copy_work, 0); } static irqreturn_t rt5514_spi_irq(int irq, void *data) { struct rt5514_dsp *rt5514_dsp = data; rt5514_schedule_copy(rt5514_dsp); return IRQ_HANDLED; return IRQ_HANDLED; } } Loading @@ -199,12 +205,19 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, struct rt5514_dsp *rt5514_dsp = struct rt5514_dsp *rt5514_dsp = snd_soc_platform_get_drvdata(rtd->platform); snd_soc_platform_get_drvdata(rtd->platform); int ret; int ret; u8 buf[8]; mutex_lock(&rt5514_dsp->dma_lock); mutex_lock(&rt5514_dsp->dma_lock); ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, params_buffer_bytes(hw_params)); params_buffer_bytes(hw_params)); rt5514_dsp->substream = substream; rt5514_dsp->substream = substream; rt5514_dsp->dma_offset = 0; rt5514_dsp->dma_offset = 0; /* Read IRQ status and schedule copy accordingly. */ rt5514_spi_burst_read(RT5514_IRQ_CTRL, (u8 *)&buf, sizeof(buf)); if (buf[0] & RT5514_IRQ_STATUS_BIT) rt5514_schedule_copy(rt5514_dsp); mutex_unlock(&rt5514_dsp->dma_lock); mutex_unlock(&rt5514_dsp->dma_lock); return ret; return ret; Loading sound/soc/codecs/rt5514-spi.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,9 @@ #define RT5514_BUFFER_VOICE_BASE 0x18000200 #define RT5514_BUFFER_VOICE_BASE 0x18000200 #define RT5514_BUFFER_VOICE_LIMIT 0x18000204 #define RT5514_BUFFER_VOICE_LIMIT 0x18000204 #define RT5514_BUFFER_VOICE_WP 0x1800020c #define RT5514_BUFFER_VOICE_WP 0x1800020c #define RT5514_IRQ_CTRL 0x18002094 #define RT5514_IRQ_STATUS_BIT (0x1 << 5) /* SPI Command */ /* SPI Command */ enum { enum { Loading sound/soc/codecs/rt5514.c +0 −63 Original line number Original line Diff line number Diff line Loading @@ -338,39 +338,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, fw = NULL; 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 */ /* DSP run */ regmap_write(rt5514->i2c_regmap, 0x18002f00, regmap_write(rt5514->i2c_regmap, 0x18002f00, 0x00055148); 0x00055148); Loading @@ -385,34 +352,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, return 0; 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[] = { static const struct snd_kcontrol_new rt5514_snd_controls[] = { SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST, SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST, RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv), RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv), Loading @@ -424,8 +363,6 @@ static const struct snd_kcontrol_new rt5514_snd_controls[] = { adc_vol_tlv), adc_vol_tlv), SOC_SINGLE_EXT("DSP Voice Wake Up", SND_SOC_NOPM, 0, 1, 0, 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), 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*/ /* ADC Mixer*/ Loading sound/soc/codecs/rt5514.h +0 −3 Original line number Original line Diff line number Diff line Loading @@ -255,7 +255,6 @@ #define RT5514_FIRMWARE1 "rt5514_dsp_fw1.bin" #define RT5514_FIRMWARE1 "rt5514_dsp_fw1.bin" #define RT5514_FIRMWARE2 "rt5514_dsp_fw2.bin" #define RT5514_FIRMWARE2 "rt5514_dsp_fw2.bin" #define RT5514_FIRMWARE3 "rt5514_dsp_fw3.bin" /* System Clock Source */ /* System Clock Source */ enum { enum { Loading @@ -282,8 +281,6 @@ struct rt5514_priv { int pll_in; int pll_in; int pll_out; int pll_out; int dsp_enabled; int dsp_enabled; u8 *model_buf; unsigned int model_len; }; }; #endif /* __RT5514_H__ */ #endif /* __RT5514_H__ */ sound/soc/codecs/rt5616.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -98,7 +98,7 @@ static const struct reg_default rt5616_reg[] = { { 0x8e, 0x0004 }, { 0x8e, 0x0004 }, { 0x8f, 0x1100 }, { 0x8f, 0x1100 }, { 0x90, 0x0000 }, { 0x90, 0x0000 }, { 0x91, 0x0000 }, { 0x91, 0x0c00 }, { 0x92, 0x0000 }, { 0x92, 0x0000 }, { 0x93, 0x2000 }, { 0x93, 0x2000 }, { 0x94, 0x0200 }, { 0x94, 0x0200 }, Loading Loading
sound/soc/codecs/rt5514-spi.c +15 −2 Original line number Original line Diff line number Diff line Loading @@ -145,9 +145,8 @@ static void rt5514_spi_copy_work(struct work_struct *work) mutex_unlock(&rt5514_dsp->dma_lock); mutex_unlock(&rt5514_dsp->dma_lock); } } static irqreturn_t rt5514_spi_irq(int irq, void *data) static void rt5514_schedule_copy(struct rt5514_dsp *rt5514_dsp) { { struct rt5514_dsp *rt5514_dsp = data; u8 buf[8]; u8 buf[8]; rt5514_dsp->get_size = 0; rt5514_dsp->get_size = 0; Loading Loading @@ -180,6 +179,13 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data) if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit && if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit && rt5514_dsp->buf_rp && rt5514_dsp->buf_size) rt5514_dsp->buf_rp && rt5514_dsp->buf_size) schedule_delayed_work(&rt5514_dsp->copy_work, 0); schedule_delayed_work(&rt5514_dsp->copy_work, 0); } static irqreturn_t rt5514_spi_irq(int irq, void *data) { struct rt5514_dsp *rt5514_dsp = data; rt5514_schedule_copy(rt5514_dsp); return IRQ_HANDLED; return IRQ_HANDLED; } } Loading @@ -199,12 +205,19 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, struct rt5514_dsp *rt5514_dsp = struct rt5514_dsp *rt5514_dsp = snd_soc_platform_get_drvdata(rtd->platform); snd_soc_platform_get_drvdata(rtd->platform); int ret; int ret; u8 buf[8]; mutex_lock(&rt5514_dsp->dma_lock); mutex_lock(&rt5514_dsp->dma_lock); ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, ret = snd_pcm_lib_alloc_vmalloc_buffer(substream, params_buffer_bytes(hw_params)); params_buffer_bytes(hw_params)); rt5514_dsp->substream = substream; rt5514_dsp->substream = substream; rt5514_dsp->dma_offset = 0; rt5514_dsp->dma_offset = 0; /* Read IRQ status and schedule copy accordingly. */ rt5514_spi_burst_read(RT5514_IRQ_CTRL, (u8 *)&buf, sizeof(buf)); if (buf[0] & RT5514_IRQ_STATUS_BIT) rt5514_schedule_copy(rt5514_dsp); mutex_unlock(&rt5514_dsp->dma_lock); mutex_unlock(&rt5514_dsp->dma_lock); return ret; return ret; Loading
sound/soc/codecs/rt5514-spi.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,9 @@ #define RT5514_BUFFER_VOICE_BASE 0x18000200 #define RT5514_BUFFER_VOICE_BASE 0x18000200 #define RT5514_BUFFER_VOICE_LIMIT 0x18000204 #define RT5514_BUFFER_VOICE_LIMIT 0x18000204 #define RT5514_BUFFER_VOICE_WP 0x1800020c #define RT5514_BUFFER_VOICE_WP 0x1800020c #define RT5514_IRQ_CTRL 0x18002094 #define RT5514_IRQ_STATUS_BIT (0x1 << 5) /* SPI Command */ /* SPI Command */ enum { enum { Loading
sound/soc/codecs/rt5514.c +0 −63 Original line number Original line Diff line number Diff line Loading @@ -338,39 +338,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, fw = NULL; 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 */ /* DSP run */ regmap_write(rt5514->i2c_regmap, 0x18002f00, regmap_write(rt5514->i2c_regmap, 0x18002f00, 0x00055148); 0x00055148); Loading @@ -385,34 +352,6 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, return 0; 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[] = { static const struct snd_kcontrol_new rt5514_snd_controls[] = { SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST, SOC_DOUBLE_TLV("MIC Boost Volume", RT5514_ANA_CTRL_MICBST, RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv), RT5514_SEL_BSTL_SFT, RT5514_SEL_BSTR_SFT, 8, 0, bst_tlv), Loading @@ -424,8 +363,6 @@ static const struct snd_kcontrol_new rt5514_snd_controls[] = { adc_vol_tlv), adc_vol_tlv), SOC_SINGLE_EXT("DSP Voice Wake Up", SND_SOC_NOPM, 0, 1, 0, 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), 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*/ /* ADC Mixer*/ Loading
sound/soc/codecs/rt5514.h +0 −3 Original line number Original line Diff line number Diff line Loading @@ -255,7 +255,6 @@ #define RT5514_FIRMWARE1 "rt5514_dsp_fw1.bin" #define RT5514_FIRMWARE1 "rt5514_dsp_fw1.bin" #define RT5514_FIRMWARE2 "rt5514_dsp_fw2.bin" #define RT5514_FIRMWARE2 "rt5514_dsp_fw2.bin" #define RT5514_FIRMWARE3 "rt5514_dsp_fw3.bin" /* System Clock Source */ /* System Clock Source */ enum { enum { Loading @@ -282,8 +281,6 @@ struct rt5514_priv { int pll_in; int pll_in; int pll_out; int pll_out; int dsp_enabled; int dsp_enabled; u8 *model_buf; unsigned int model_len; }; }; #endif /* __RT5514_H__ */ #endif /* __RT5514_H__ */
sound/soc/codecs/rt5616.c +1 −1 Original line number Original line Diff line number Diff line Loading @@ -98,7 +98,7 @@ static const struct reg_default rt5616_reg[] = { { 0x8e, 0x0004 }, { 0x8e, 0x0004 }, { 0x8f, 0x1100 }, { 0x8f, 0x1100 }, { 0x90, 0x0000 }, { 0x90, 0x0000 }, { 0x91, 0x0000 }, { 0x91, 0x0c00 }, { 0x92, 0x0000 }, { 0x92, 0x0000 }, { 0x93, 0x2000 }, { 0x93, 0x2000 }, { 0x94, 0x0200 }, { 0x94, 0x0200 }, Loading