Lines Matching +full:fiq +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0+
2 // imx-pcm-fiq.c -- ALSA Soc Audio Layer
6 // This code is based on code copyrighted by Freescale,
12 #include <linux/dma-mapping.h>
26 #include <asm/fiq.h>
28 #include <linux/platform_data/asoc-imx-ssi.h>
30 #include "imx-ssi.h"
31 #include "imx-pcm.h"
48 struct snd_pcm_substream *substream = iprtd->substream; in snd_hrtimer_callback()
51 if (!atomic_read(&iprtd->playing) && !atomic_read(&iprtd->capturing)) in snd_hrtimer_callback()
56 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_hrtimer_callback()
57 iprtd->offset = regs.ARM_r8 & 0xffff; in snd_hrtimer_callback()
59 iprtd->offset = regs.ARM_r9 & 0xffff; in snd_hrtimer_callback()
63 hrtimer_forward_now(hrt, ns_to_ktime(iprtd->poll_time_ns)); in snd_hrtimer_callback()
76 struct snd_pcm_runtime *runtime = substream->runtime; in snd_imx_pcm_hw_params()
77 struct imx_pcm_runtime_data *iprtd = runtime->private_data; in snd_imx_pcm_hw_params()
79 iprtd->periods = params_periods(params); in snd_imx_pcm_hw_params()
80 iprtd->period = params_period_bytes(params); in snd_imx_pcm_hw_params()
81 iprtd->offset = 0; in snd_imx_pcm_hw_params()
82 iprtd->poll_time_ns = 1000000000 / params_rate(params) * in snd_imx_pcm_hw_params()
91 struct snd_pcm_runtime *runtime = substream->runtime; in snd_imx_pcm_prepare()
92 struct imx_pcm_runtime_data *iprtd = runtime->private_data; in snd_imx_pcm_prepare()
96 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_imx_pcm_prepare()
97 regs.ARM_r8 = (iprtd->period * iprtd->periods - 1) << 16; in snd_imx_pcm_prepare()
99 regs.ARM_r9 = (iprtd->period * iprtd->periods - 1) << 16; in snd_imx_pcm_prepare()
111 struct snd_pcm_runtime *runtime = substream->runtime; in snd_imx_pcm_trigger()
112 struct imx_pcm_runtime_data *iprtd = runtime->private_data; in snd_imx_pcm_trigger()
118 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_imx_pcm_trigger()
119 atomic_set(&iprtd->playing, 1); in snd_imx_pcm_trigger()
121 atomic_set(&iprtd->capturing, 1); in snd_imx_pcm_trigger()
122 hrtimer_start(&iprtd->hrt, ns_to_ktime(iprtd->poll_time_ns), in snd_imx_pcm_trigger()
130 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_imx_pcm_trigger()
131 atomic_set(&iprtd->playing, 0); in snd_imx_pcm_trigger()
133 atomic_set(&iprtd->capturing, 0); in snd_imx_pcm_trigger()
134 if (!atomic_read(&iprtd->playing) && in snd_imx_pcm_trigger()
135 !atomic_read(&iprtd->capturing)) in snd_imx_pcm_trigger()
140 return -EINVAL; in snd_imx_pcm_trigger()
150 struct snd_pcm_runtime *runtime = substream->runtime; in snd_imx_pcm_pointer()
151 struct imx_pcm_runtime_data *iprtd = runtime->private_data; in snd_imx_pcm_pointer()
153 return bytes_to_frames(substream->runtime, iprtd->offset); in snd_imx_pcm_pointer()
175 struct snd_pcm_runtime *runtime = substream->runtime; in snd_imx_open()
181 return -ENOMEM; in snd_imx_open()
182 runtime->private_data = iprtd; in snd_imx_open()
184 iprtd->substream = substream; in snd_imx_open()
186 atomic_set(&iprtd->playing, 0); in snd_imx_open()
187 atomic_set(&iprtd->capturing, 0); in snd_imx_open()
188 hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in snd_imx_open()
189 iprtd->hrt.function = snd_hrtimer_callback; in snd_imx_open()
191 ret = snd_pcm_hw_constraint_integer(substream->runtime, in snd_imx_open()
205 struct snd_pcm_runtime *runtime = substream->runtime; in snd_imx_close()
206 struct imx_pcm_runtime_data *iprtd = runtime->private_data; in snd_imx_close()
208 hrtimer_cancel(&iprtd->hrt); in snd_imx_close()
217 struct snd_card *card = rtd->card->snd_card; in imx_pcm_new()
218 struct snd_pcm *pcm = rtd->pcm; in imx_pcm_new()
221 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); in imx_pcm_new()
226 pcm->card->dev, in imx_pcm_new()
235 struct snd_pcm *pcm = rtd->pcm; in snd_imx_pcm_new()
243 substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; in snd_imx_pcm_new()
245 struct snd_dma_buffer *buf = &substream->dma_buffer; in snd_imx_pcm_new()
247 imx_ssi_fiq_tx_buffer = (unsigned long)buf->area; in snd_imx_pcm_new()
250 substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; in snd_imx_pcm_new()
252 struct snd_dma_buffer *buf = &substream->dma_buffer; in snd_imx_pcm_new()
254 imx_ssi_fiq_rx_buffer = (unsigned long)buf->area; in snd_imx_pcm_new()
258 &imx_ssi_fiq_end - &imx_ssi_fiq_start); in snd_imx_pcm_new()
288 dev_err(&pdev->dev, "failed to claim fiq: %d", ret); in imx_pcm_fiq_init()
292 mxc_set_irq_fiq(params->irq, 1); in imx_pcm_fiq_init()
293 ssi_irq = params->irq; in imx_pcm_fiq_init()
295 imx_pcm_fiq = params->irq; in imx_pcm_fiq_init()
297 imx_ssi_fiq_base = (unsigned long)params->base; in imx_pcm_fiq_init()
299 params->dma_params_tx->maxburst = 4; in imx_pcm_fiq_init()
300 params->dma_params_rx->maxburst = 6; in imx_pcm_fiq_init()
302 ret = devm_snd_soc_register_component(&pdev->dev, &imx_soc_component_fiq, in imx_pcm_fiq_init()
322 MODULE_DESCRIPTION("Freescale i.MX PCM FIQ handler");