Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 189956
b: refs/heads/master
c: 43a3cec
h: refs/heads/master
v: v3
  • Loading branch information
Sascha Hauer authored and Mark Brown committed Apr 8, 2010
1 parent e1e508f commit c346823
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 671999cb5d8817611f865f3877f5a5b81372f61e
refs/heads/master: 43a3cec01354573517f1348383e0ab6e6067076b
45 changes: 21 additions & 24 deletions trunk/sound/soc/imx/imx-pcm-fiq.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,17 @@ struct imx_pcm_runtime_data {
unsigned long offset;
unsigned long last_offset;
unsigned long size;
struct timer_list timer;
int poll_time;
struct hrtimer hrt;
int poll_time_ns;
struct snd_pcm_substream *substream;
};

static inline void imx_ssi_set_next_poll(struct imx_pcm_runtime_data *iprtd)
static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
{
iprtd->timer.expires = jiffies + iprtd->poll_time;
}

static void imx_ssi_timer_callback(unsigned long data)
{
struct snd_pcm_substream *substream = (void *)data;
struct imx_pcm_runtime_data *iprtd =
container_of(hrt, struct imx_pcm_runtime_data, hrt);
struct snd_pcm_substream *substream = iprtd->substream;
struct snd_pcm_runtime *runtime = substream->runtime;
struct imx_pcm_runtime_data *iprtd = runtime->private_data;
struct pt_regs regs;
unsigned long delta;

Expand All @@ -71,16 +68,14 @@ static void imx_ssi_timer_callback(unsigned long data)

/* If we've transferred at least a period then report it and
* reset our poll time */
if (delta >= runtime->period_size) {
if (delta >= iprtd->period) {
snd_pcm_period_elapsed(substream);
iprtd->last_offset = iprtd->offset;

imx_ssi_set_next_poll(iprtd);
}

/* Restart the timer; if we didn't report we'll run on the next tick */
add_timer(&iprtd->timer);
hrtimer_forward_now(hrt, ns_to_ktime(iprtd->poll_time_ns));

return HRTIMER_RESTART;
}

static struct fiq_handler fh = {
Expand All @@ -98,8 +93,8 @@ static int snd_imx_pcm_hw_params(struct snd_pcm_substream *substream,
iprtd->period = params_period_bytes(params) ;
iprtd->offset = 0;
iprtd->last_offset = 0;
iprtd->poll_time = HZ / (params_rate(params) / params_period_size(params));

iprtd->poll_time_ns = 1000000000 / params_rate(params) *
params_period_size(params);
snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);

return 0;
Expand Down Expand Up @@ -134,8 +129,8 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
imx_ssi_set_next_poll(iprtd);
add_timer(&iprtd->timer);
hrtimer_start(&iprtd->hrt, ns_to_ktime(iprtd->poll_time_ns),
HRTIMER_MODE_REL);
if (++fiq_enable == 1)
enable_fiq(imx_pcm_fiq);

Expand All @@ -144,7 +139,7 @@ static int snd_imx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
del_timer(&iprtd->timer);
hrtimer_cancel(&iprtd->hrt);
if (--fiq_enable == 0)
disable_fiq(imx_pcm_fiq);

Expand Down Expand Up @@ -193,9 +188,10 @@ static int snd_imx_open(struct snd_pcm_substream *substream)
iprtd = kzalloc(sizeof(*iprtd), GFP_KERNEL);
runtime->private_data = iprtd;

init_timer(&iprtd->timer);
iprtd->timer.data = (unsigned long)substream;
iprtd->timer.function = imx_ssi_timer_callback;
iprtd->substream = substream;

hrtimer_init(&iprtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
iprtd->hrt.function = snd_hrtimer_callback;

ret = snd_pcm_hw_constraint_integer(substream->runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
Expand All @@ -211,7 +207,8 @@ static int snd_imx_close(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime;
struct imx_pcm_runtime_data *iprtd = runtime->private_data;

del_timer_sync(&iprtd->timer);
hrtimer_cancel(&iprtd->hrt);

kfree(iprtd);

return 0;
Expand Down

0 comments on commit c346823

Please sign in to comment.