ASoC: increase timer sensitivity to support variable period size.
Change the timer value to support at usecs range instead of
msecs. This allows to have different period sizes for a
given frequency.
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
diff --git a/sound/soc/msm/msm-pcm-afe.c b/sound/soc/msm/msm-pcm-afe.c
index 7e48af1..a34b774 100644
--- a/sound/soc/msm/msm-pcm-afe.c
+++ b/sound/soc/msm/msm-pcm-afe.c
@@ -64,8 +64,8 @@
struct snd_pcm_runtime *runtime = substream->runtime;
if (prtd->start) {
snd_pcm_period_elapsed(prtd->substream);
- pr_debug("sending frame to DSP: poll_time_ns: %d\n",
- prtd->poll_time_ns);
+ pr_debug("sending frame to DSP: poll_time: %d\n",
+ prtd->poll_time);
if (prtd->dsp_cnt == runtime->periods)
prtd->dsp_cnt = 0;
afe_rt_proxy_port_write(
@@ -74,12 +74,12 @@
snd_pcm_lib_period_bytes(prtd->substream))),
snd_pcm_lib_period_bytes(prtd->substream));
prtd->dsp_cnt++;
- prtd->poll_time_ns = ((unsigned long)((
+ prtd->poll_time = ((unsigned long)((
snd_pcm_lib_period_bytes(prtd->substream)
- * 1000)/(runtime->rate
+ * 1000 * 1000)/(runtime->rate
* runtime->channels * 2)));
- hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time_ns
- * 1000 * 1000));
+ hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time
+ * 1000));
return HRTIMER_RESTART;
} else
@@ -99,14 +99,14 @@
* snd_pcm_lib_period_bytes(prtd->substream))),
snd_pcm_lib_period_bytes(prtd->substream));
prtd->dsp_cnt++;
- prtd->poll_time_ns = ((unsigned long)((
+ prtd->poll_time = ((unsigned long)((
snd_pcm_lib_period_bytes(prtd->substream)
- * 1000)/(runtime->rate
+ * 1000 * 1000)/(runtime->rate
* runtime->channels * 2)));
- pr_debug("sending frame rec to DSP: poll_time_ns: %d\n",
- prtd->poll_time_ns);
- hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time_ns
- * 1000 * 1000));
+ pr_debug("sending frame rec to DSP: poll_time: %d\n",
+ prtd->poll_time);
+ hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time
+ * 1000));
return HRTIMER_RESTART;
} else
@@ -134,15 +134,16 @@
switch (event) {
case AFE_EVENT_RTPORT_START: {
prtd->dsp_cnt = 0;
- prtd->poll_time_ns = ((unsigned long)((
+ prtd->poll_time = ((unsigned long)((
snd_pcm_lib_period_bytes
- (prtd->substream) * 1000)/
+ (prtd->substream) *
+ 1000 * 1000)/
(runtime->rate *
runtime->channels * 2)));
- pr_info("prtd->poll_time_ns : %d",
- prtd->poll_time_ns);
+ pr_info("prtd->poll_time: %d",
+ prtd->poll_time);
hrtimer_start(&prtd->hrt,
- ns_to_ktime(prtd->poll_time_ns * 1000 * 1000),
+ ns_to_ktime(prtd->poll_time * 1000),
HRTIMER_MODE_REL);
break;
}
@@ -202,14 +203,14 @@
switch (event) {
case AFE_EVENT_RTPORT_START: {
prtd->dsp_cnt = 0;
- prtd->poll_time_ns = ((unsigned long)((
+ prtd->poll_time = ((unsigned long)((
snd_pcm_lib_period_bytes(prtd->substream)
- * 1000)/(runtime->rate
+ * 1000 * 1000)/(runtime->rate
* runtime->channels * 2)));
hrtimer_start(&prtd->hrt,
- ns_to_ktime(prtd->poll_time_ns * 1000 * 1000),
+ ns_to_ktime(prtd->poll_time * 1000),
HRTIMER_MODE_REL);
- pr_info("prtd->poll_time_ns : %d", prtd->poll_time_ns);
+ pr_info("prtd->poll_time : %d", prtd->poll_time);
break;
}
case AFE_EVENT_RTPORT_STOP:
diff --git a/sound/soc/msm/msm-pcm-afe.h b/sound/soc/msm/msm-pcm-afe.h
index 12643b7..7a60a73 100644
--- a/sound/soc/msm/msm-pcm-afe.h
+++ b/sound/soc/msm/msm-pcm-afe.h
@@ -29,7 +29,7 @@
int32_t mmap_flag;
int prepared;
struct hrtimer hrt;
- int poll_time_ns;
+ int poll_time;
};