From fa53b9fbfb00a3ee49f51e79ae6a1aede83cdcc4 Mon Sep 17 00:00:00 2001 From: Laxminath Kasam Date: Thu, 22 Sep 2011 15:14:18 +0530 Subject: [PATCH] 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 --- sound/soc/msm/msm-pcm-afe.c | 43 +++++++++++++++++++------------------ sound/soc/msm/msm-pcm-afe.h | 2 +- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sound/soc/msm/msm-pcm-afe.c b/sound/soc/msm/msm-pcm-afe.c index 7e48af15153..a34b7747953 100644 --- a/sound/soc/msm/msm-pcm-afe.c +++ b/sound/soc/msm/msm-pcm-afe.c @@ -64,8 +64,8 @@ static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt) 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 @@ static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt) 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 @@ static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt) * 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 @@ static void pcm_afe_process_tx_pkt(uint32_t opcode, 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 @@ static void pcm_afe_process_rx_pkt(uint32_t opcode, 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 12643b78a33..7a60a73efe1 100644 --- a/sound/soc/msm/msm-pcm-afe.h +++ b/sound/soc/msm/msm-pcm-afe.h @@ -29,7 +29,7 @@ struct pcm_afe_info { int32_t mmap_flag; int prepared; struct hrtimer hrt; - int poll_time_ns; + int poll_time; };