Lines Matching refs:rt5677_dsp

61 struct rt5677_dsp {  struct
120 struct rt5677_dsp *rt5677_dsp = in rt5677_spi_pcm_close() local
123 cancel_delayed_work_sync(&rt5677_dsp->copy_work); in rt5677_spi_pcm_close()
133 struct rt5677_dsp *rt5677_dsp = in rt5677_spi_hw_params() local
136 mutex_lock(&rt5677_dsp->dma_lock); in rt5677_spi_hw_params()
137 rt5677_dsp->substream = substream; in rt5677_spi_hw_params()
138 mutex_unlock(&rt5677_dsp->dma_lock); in rt5677_spi_hw_params()
147 struct rt5677_dsp *rt5677_dsp = in rt5677_spi_hw_free() local
150 mutex_lock(&rt5677_dsp->dma_lock); in rt5677_spi_hw_free()
151 rt5677_dsp->substream = NULL; in rt5677_spi_hw_free()
152 mutex_unlock(&rt5677_dsp->dma_lock); in rt5677_spi_hw_free()
166 struct rt5677_dsp *rt5677_dsp = in rt5677_spi_prepare() local
170 rt5677_dsp->dma_offset = 0; in rt5677_spi_prepare()
171 rt5677_dsp->avail_bytes = 0; in rt5677_spi_prepare()
180 struct rt5677_dsp *rt5677_dsp = in rt5677_spi_pcm_pointer() local
183 return bytes_to_frames(runtime, rt5677_dsp->dma_offset); in rt5677_spi_pcm_pointer()
211 static int rt5677_spi_copy_block(struct rt5677_dsp *rt5677_dsp, in rt5677_spi_copy_block() argument
214 struct snd_pcm_runtime *runtime = rt5677_dsp->substream->runtime; in rt5677_spi_copy_block()
220 dev_err(rt5677_dsp->dev, in rt5677_spi_copy_block()
239 if (rt5677_dsp->dma_offset + first_chunk_len > runtime->dma_bytes) { in rt5677_spi_copy_block()
242 first_chunk_len = runtime->dma_bytes - rt5677_dsp->dma_offset; in rt5677_spi_copy_block()
248 runtime->dma_area + rt5677_dsp->dma_offset, in rt5677_spi_copy_block()
252 rt5677_dsp->dma_offset += first_chunk_len; in rt5677_spi_copy_block()
253 if (rt5677_dsp->dma_offset == runtime->dma_bytes) in rt5677_spi_copy_block()
254 rt5677_dsp->dma_offset = 0; in rt5677_spi_copy_block()
262 rt5677_dsp->dma_offset = second_chunk_len; in rt5677_spi_copy_block()
275 static int rt5677_spi_copy(struct rt5677_dsp *rt5677_dsp, u32 amount) in rt5677_spi_copy() argument
283 target = rt5677_dsp->mic_read_offset + amount; in rt5677_spi_copy()
285 ret |= rt5677_spi_copy_block(rt5677_dsp, rt5677_dsp->mic_read_offset, in rt5677_spi_copy()
291 ret |= rt5677_spi_copy_block(rt5677_dsp, 0, target); in rt5677_spi_copy()
295 rt5677_dsp->mic_read_offset = target; in rt5677_spi_copy()
305 struct rt5677_dsp *rt5677_dsp = in rt5677_spi_copy_work() local
306 container_of(work, struct rt5677_dsp, copy_work.work); in rt5677_spi_copy_work()
314 mutex_lock(&rt5677_dsp->dma_lock); in rt5677_spi_copy_work()
315 if (!rt5677_dsp->substream) { in rt5677_spi_copy_work()
316 dev_err(rt5677_dsp->dev, "No pcm substream\n"); in rt5677_spi_copy_work()
320 runtime = rt5677_dsp->substream->runtime; in rt5677_spi_copy_work()
323 dev_err(rt5677_dsp->dev, "No mic_write_offset\n"); in rt5677_spi_copy_work()
331 if (rt5677_dsp->new_hotword) { in rt5677_spi_copy_work()
332 rt5677_dsp->new_hotword = false; in rt5677_spi_copy_work()
335 rt5677_dsp->mic_read_offset = RT5677_MIC_BUF_BYTES - in rt5677_spi_copy_work()
339 rt5677_dsp->mic_read_offset = mic_write_offset - in rt5677_spi_copy_work()
344 if (rt5677_dsp->mic_read_offset <= mic_write_offset) in rt5677_spi_copy_work()
345 new_bytes = mic_write_offset - rt5677_dsp->mic_read_offset; in rt5677_spi_copy_work()
348 - rt5677_dsp->mic_read_offset; in rt5677_spi_copy_work()
351 period_bytes = snd_pcm_lib_period_bytes(rt5677_dsp->substream); in rt5677_spi_copy_work()
354 - rt5677_dsp->avail_bytes); in rt5677_spi_copy_work()
355 ret = rt5677_spi_copy(rt5677_dsp, copy_bytes); in rt5677_spi_copy_work()
357 dev_err(rt5677_dsp->dev, "Copy failed %d\n", ret); in rt5677_spi_copy_work()
360 rt5677_dsp->avail_bytes += copy_bytes; in rt5677_spi_copy_work()
361 if (rt5677_dsp->avail_bytes >= period_bytes) { in rt5677_spi_copy_work()
362 snd_pcm_period_elapsed(rt5677_dsp->substream); in rt5677_spi_copy_work()
363 rt5677_dsp->avail_bytes = 0; in rt5677_spi_copy_work()
369 schedule_delayed_work(&rt5677_dsp->copy_work, msecs_to_jiffies(delay)); in rt5677_spi_copy_work()
371 mutex_unlock(&rt5677_dsp->dma_lock); in rt5677_spi_copy_work()
384 struct rt5677_dsp *rt5677_dsp; in rt5677_spi_pcm_probe() local
386 rt5677_dsp = devm_kzalloc(component->dev, sizeof(*rt5677_dsp), in rt5677_spi_pcm_probe()
388 if (!rt5677_dsp) in rt5677_spi_pcm_probe()
390 rt5677_dsp->dev = &g_spi->dev; in rt5677_spi_pcm_probe()
391 mutex_init(&rt5677_dsp->dma_lock); in rt5677_spi_pcm_probe()
392 INIT_DELAYED_WORK(&rt5677_dsp->copy_work, rt5677_spi_copy_work); in rt5677_spi_pcm_probe()
394 snd_soc_component_set_drvdata(component, rt5677_dsp); in rt5677_spi_pcm_probe()
583 struct rt5677_dsp *rt5677_dsp; in rt5677_spi_hotword_detected() local
588 rt5677_dsp = dev_get_drvdata(&g_spi->dev); in rt5677_spi_hotword_detected()
589 if (!rt5677_dsp) { in rt5677_spi_hotword_detected()
594 mutex_lock(&rt5677_dsp->dma_lock); in rt5677_spi_hotword_detected()
595 dev_info(rt5677_dsp->dev, "Hotword detected\n"); in rt5677_spi_hotword_detected()
596 rt5677_dsp->new_hotword = true; in rt5677_spi_hotword_detected()
597 mutex_unlock(&rt5677_dsp->dma_lock); in rt5677_spi_hotword_detected()
599 schedule_delayed_work(&rt5677_dsp->copy_work, 0); in rt5677_spi_hotword_detected()