static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt)
{
	struct pcm *pcm =
		container_of(hrt, struct pcm, hrt);
	int rc = 0;
	if (pcm->start) {
		if (pcm->dsp_idx == pcm->buffer_count)
			pcm->dsp_idx = 0;
#if 0
		rc = wait_event_timeout(pcm->wait,
				(pcm->dma_buf[pcm->dsp_idx].used == 0) ||
				atomic_read(&pcm->in_stopped), 1 * HZ);
		if (!rc) {
			pr_err("%s: wait_event_timeout failed\n", __func__);
			goto fail;
		}
#endif
		if (pcm->dma_buf[pcm->dsp_idx].used == 0) {
		   if (atomic_read(&pcm->in_stopped)) {
			   pr_err("%s: Driver closed - return\n", __func__);
			   return HRTIMER_NORESTART;
		   }
		   rc = afe_rt_proxy_port_read(
			   pcm->dma_buf[pcm->dsp_idx].addr,
			   pcm->buffer_size);
		   if (rc < 0) {
			   pr_err("%s afe_rt_proxy_port_read fail\n", __func__);
			   goto fail;
		   }
		   pcm->dma_buf[pcm->dsp_idx].used = 1;
		   pcm->dsp_idx++;
		   pr_debug("sending frame rec to DSP: poll_time: %d\n",
				   pcm->poll_time);
		} else {
		   pr_err("Qcom: Used flag not reset retry after %d msec\n",
			 (pcm->poll_time/10));
		   goto fail_timer;
		}
fail:
		hrtimer_forward_now(hrt, ns_to_ktime(pcm->poll_time
				* 1000));
		return HRTIMER_RESTART;
fail_timer:
		hrtimer_forward_now(hrt, ns_to_ktime((pcm->poll_time/10)
				* 1000));

		return HRTIMER_RESTART;
	} else {
		return HRTIMER_NORESTART;
	}
}
static enum hrtimer_restart aml_i2s_hrtimer_callback(struct hrtimer* timer) {
    struct aml_runtime_data* prtd =  container_of(timer, struct aml_runtime_data, hrtimer);
    audio_stream_t* s = &prtd->s;
    struct snd_pcm_substream* substream = prtd->substream;
    struct snd_pcm_runtime* runtime = substream->runtime;

    unsigned int last_ptr, size;
    //unsigned long flag;
    //printk("------------->hrtimer start\n");
    if (s->active == 0)
    {
        hrtimer_forward_now(timer, ns_to_ktime(HRTIMER_PERIOD));
        return HRTIMER_RESTART;
    }
    //spin_lock_irqsave(&s->lock, flag);

    if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
    {
        last_ptr = read_i2s_rd_ptr();
        if (last_ptr < s->last_ptr) {
            size = runtime->dma_bytes + last_ptr - s->last_ptr;
        } else {
            size = last_ptr - s->last_ptr;
        }
        s->last_ptr = last_ptr;
        s->size += bytes_to_frames(substream->runtime, size);
        if (s->size >= runtime->period_size) {
            s->size %= runtime->period_size;
            snd_pcm_period_elapsed(substream);
        }
    } else{
        last_ptr = (audio_in_i2s_wr_ptr() - s->I2S_addr) / 2;
        if (last_ptr < s->last_ptr)
        {
            size = runtime->dma_bytes + last_ptr - s->last_ptr;
        } else{
            size = last_ptr - s->last_ptr;
        }
        s->last_ptr = last_ptr;
        s->size += bytes_to_frames(runtime, size);
        if (s->size >= runtime->period_size)
        {
            s->size %= runtime->period_size;
            snd_pcm_period_elapsed(substream);
        }
    }
    //spin_unlock_irqrestore(&s->lock, flag);
    hrtimer_forward_now(timer, ns_to_ktime(HRTIMER_PERIOD));
    return HRTIMER_RESTART;
}
Beispiel #3
0
/* This function is for light sensor.  It operates every a few seconds.
 * It asks for work to be done on a thread because i2c needs a thread
 * context (slow and blocking) and then reschedules the timer to run again.
 */
static enum hrtimer_restart bh1721_timer_func(struct hrtimer *timer)
{
	struct bh1721_data *bh1721 = container_of(timer, struct bh1721_data, timer);
	queue_work(bh1721->wq, &bh1721->work_light);
	hrtimer_forward_now(&bh1721->timer, bh1721->light_poll_delay);
	return HRTIMER_RESTART;
}
static enum hrtimer_restart headset_gpio_timer_func(struct hrtimer *timer)
{
	enum hrtimer_restart restart = HRTIMER_RESTART;
	struct _headset_gpio *hgp =
		container_of(timer, struct _headset_gpio, timer);
	int active = hgp->active_low ^ headset_gpio_get_value(hgp->gpio); /* hgp->active */
	int green_ch = (!active && &hgp->parent->detect == hgp);
	if (active != hgp->active) {
		pr_info("The value %s mismatch [%d:%d] at %dms!\n",
				hgp->desc, active, hgp->active, hgp->holded);
		hgp->holded = 0;
	}
	pr_debug("%s : %s %s green_ch[%d], holed=%d, debounce_sw=%d\n", __func__,
			hgp->desc, active ? "active" : "inactive", green_ch, hgp->holded, hgp->debounce_sw);
	hgp->holded += HEADSET_GPIO_DEBOUNCE_SW_SAMPLE_PERIOD;
	if (hgp->holded >= hgp->debounce_sw || green_ch) {
		if (hgp->holded == hgp->debounce_sw || \
			hgp->holded == hgp->timeout_ms || \
			green_ch) {
			pr_debug("call headset gpio handler\n");
			restart = hgp->callback(active, hgp);
		} else
			pr_debug("gpio <%d> has kept active for %d ms\n", hgp->gpio, hgp->holded);
	}
	if (restart == HRTIMER_RESTART)
		hrtimer_forward_now(timer,
			ktime_set(HEADSET_GPIO_DEBOUNCE_SW_SAMPLE_PERIOD / 1000,
					(HEADSET_GPIO_DEBOUNCE_SW_SAMPLE_PERIOD % 1000) * 1000000)); /* repeat timer */
	return restart;
}
static enum hrtimer_restart ami_timer_func(struct hrtimer *timer)
{
	struct ami306_dev_data *pdev = container_of(timer, struct ami306_dev_data, timer);
	queue_work(pdev->wq, &pdev->work);
	hrtimer_forward_now(&pdev->timer, pdev->poll_delay);
	return HRTIMER_RESTART;
}
static enum hrtimer_restart afe_hrtimer_callback(struct hrtimer *hrt)
{
	struct pcm_afe_info *prtd =
		container_of(hrt, struct pcm_afe_info, hrt);
	struct snd_pcm_substream *substream = prtd->substream;
	struct snd_pcm_runtime *runtime = substream->runtime;
	u32 mem_map_handle = 0;

	mem_map_handle = afe_req_mmap_handle(prtd->audio_client);
	if (!mem_map_handle)
		pr_err("%s: mem_map_handle is NULL\n", __func__);

	if (prtd->start) {
		pr_debug("sending frame to DSP: poll_time: %d\n",
				prtd->poll_time);
		if (prtd->dsp_cnt == runtime->periods)
			prtd->dsp_cnt = 0;
		pr_debug("%s: mem_map_handle 0x%x\n", __func__, mem_map_handle);
		afe_rt_proxy_port_write(
		(prtd->dma_addr +
		(prtd->dsp_cnt *
		snd_pcm_lib_period_bytes(prtd->substream))), mem_map_handle,
		snd_pcm_lib_period_bytes(prtd->substream));
		prtd->dsp_cnt++;
		hrtimer_forward_now(hrt, ns_to_ktime(prtd->poll_time
					* 1000));

		return HRTIMER_RESTART;
	} else
		return HRTIMER_NORESTART;
}
Beispiel #7
0
static enum hrtimer_restart hrtimer_func(struct hrtimer *hrtimer)
{
	unsigned int pid;
	unsigned int tid;
	unsigned int pc;
	unsigned long flags;
	unsigned long long ts;
	ktime_t ktime;
	struct pt_regs *regs;

	local_irq_save(flags);

	regs = get_irq_regs();

	if (regs != NULL)
	{
		pid = current->tgid;
		tid = current->pid;
		pc  = regs->ARM_pc;
		ts  = get_timestamp();

		px_timer_isr(pid, tid, pc, ts);
	}

	ktime = ktime_set(0, g_tbs_settings.interval * NSEC_PER_USEC);
	hrtimer_forward_now(hrtimer, ktime);

	local_irq_restore(flags);

	return HRTIMER_RESTART;
}
Beispiel #8
0
static enum hrtimer_restart afe_hrtimer_rec_callback(struct hrtimer *hrt)
{
	struct pcm_afe_info *prtd =
		container_of(hrt, struct pcm_afe_info, hrt);
	struct snd_pcm_substream *substream = prtd->substream;
	struct snd_pcm_runtime *runtime = substream->runtime;
	if (prtd->start) {
		if (prtd->dsp_cnt == runtime->periods)
			prtd->dsp_cnt = 0;
		afe_rt_proxy_port_read(
			(prtd->dma_addr + (prtd->dsp_cnt
			* snd_pcm_lib_period_bytes(prtd->substream))),
			snd_pcm_lib_period_bytes(prtd->substream));
		prtd->dsp_cnt++;
		prtd->poll_time = ((unsigned long)((
				snd_pcm_lib_period_bytes(prtd->substream)
					* 1000 * 1000)/(runtime->rate
					* runtime->channels * 2)));
		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
		return HRTIMER_NORESTART;
}
Beispiel #9
0
/* turn clock off if TX buffer is empty, otherwise reschedule */
static enum hrtimer_restart msm_serial_clock_off(struct hrtimer *timer) {
    struct msm_port *msm_port = container_of(timer, struct msm_port,
                                clk_off_timer);
    struct uart_port *port = &msm_port->uart;
    struct circ_buf *xmit = &port->info->xmit;
    unsigned long flags;
    int ret = HRTIMER_NORESTART;

    spin_lock_irqsave(&port->lock, flags);

    if (msm_port->clk_state == MSM_CLK_REQUEST_OFF) {
        if (uart_circ_empty(xmit)) {
            struct msm_port *msm_port = UART_TO_MSM(port);
            clk_disable(msm_port->clk);
            msm_port->clk_state = MSM_CLK_OFF;
        } else {
            hrtimer_forward_now(timer, msm_port->clk_off_delay);
            ret = HRTIMER_RESTART;
        }
    }

    spin_unlock_irqrestore(&port->lock, flags);

    return HRTIMER_NORESTART;
}
Beispiel #10
0
/* turn clock off if TX buffer is empty, otherwise reschedule */
static enum hrtimer_restart msm_serial_clock_off(struct hrtimer *timer) {
	struct msm_port *msm_port = container_of(timer, struct msm_port,
						 clk_off_timer);
	struct uart_port *port = &msm_port->uart;
	struct circ_buf *xmit = &port->info->xmit;
	unsigned long flags;
	int ret = HRTIMER_NORESTART;

	spin_lock_irqsave(&port->lock, flags);

	if (msm_port->clk_state == MSM_CLK_REQUEST_OFF) {
		if (uart_circ_empty(xmit)) {
			struct msm_port *msm_port = UART_TO_MSM(port);
			clk_disable(msm_port->clk);
			msm_port->clk_state = MSM_CLK_OFF;
#ifdef CONFIG_SERIAL_MSM_RX_WAKEUP
			if (use_low_power_wakeup(msm_port)) {
				msm_port->wakeup.ignore = 1;
				enable_irq(msm_port->wakeup.irq);
			}
#endif
		} else {
			hrtimer_forward_now(timer, msm_port->clk_off_delay);
			ret = HRTIMER_RESTART;
		}
	}

	spin_unlock_irqrestore(&port->lock, flags);

	return HRTIMER_NORESTART;
}
Beispiel #11
0
static enum hrtimer_restart cc2520_csma_timer_cb(struct hrtimer *timer)
{
	ktime_t kt;
	int new_backoff;

	//printk(KERN_INFO "[cc2520] - csma timer fired. \n");
	if (cc2520_radio_is_clear()) {
		//printk(KERN_INFO "[cc2520] - channel clear, sending.\n");
		csma_bottom->tx(cur_tx_buf, cur_tx_len);
		return HRTIMER_NORESTART;		
	}
	else {
		spin_lock(&state_sl);
		if (csma_state == CC2520_CSMA_TX) {
			csma_state = CC2520_CSMA_CONG;
			spin_unlock(&state_sl);

			new_backoff = 
				cc2520_csma_get_backoff(backoff_min, backoff_max_cong);

			INFO((KERN_INFO "[cc2520] - channel still busy, waiting %d uS\n", new_backoff));
			kt=ktime_set(0,1000 * new_backoff);
			hrtimer_forward_now(&backoff_timer, kt);
			return HRTIMER_RESTART;
		}
		else {
			csma_state = CC2520_CSMA_IDLE;
			spin_unlock(&state_sl);

			INFO((KERN_INFO "[cc2520] - csma/ca: channel busy. aborting tx\n"));
			csma_top->tx_done(-CC2520_TX_BUSY);
			return HRTIMER_NORESTART;
		}
	}
}
Beispiel #12
0
static enum hrtimer_restart hrtimer_func(struct hrtimer *hrtimer)
{
	unsigned int pid;
	unsigned int tid;
	unsigned int cpu;
	unsigned long long ts;
	struct pt_regs *regs;
	unsigned long flags;

	unsigned long long delay_in_ns;

	delay_in_ns = g_tbs_settings.interval * NSEC_PER_USEC;

	regs = get_irq_regs();
	
	local_irq_save(flags);

	if (regs != NULL)
	{
		pid = current->tgid;
		tid = current->pid;
		cpu = smp_processor_id();
		ts  = get_timestamp();

		px_timer_isr(pid, tid, regs, cpu, ts);
	}
	
	local_irq_restore(flags);

	hrtimer_forward_now(hrtimer, ns_to_ktime(delay_in_ns));

	return HRTIMER_RESTART;
}
enum hrtimer_restart ev3_uart_keep_alive_timer_callback(struct hrtimer *timer)
{
	struct ev3_uart_port_data *port = container_of(timer,
				struct ev3_uart_port_data, keep_alive_timer);

	if (!port->synced || !port->info_done)
		return HRTIMER_NORESTART;

	hrtimer_forward_now(timer, ktime_set(0,
			    EV3_UART_DATA_KEEP_ALIVE_TIMEOUT * 1000000));
	if (!port->data_rec) {
		port->last_err = "No data since last keep-alive.";
		port->num_data_err++;
		if (port->num_data_err > EV3_UART_MAX_DATA_ERR) {
			port->synced = 0;
			port->new_baud_rate = EV3_UART_SPEED_MIN;
			schedule_work(&port->change_bitrate_work);
			return HRTIMER_NORESTART;
		}
	}
	port->data_rec = 0;

	tasklet_schedule(&port->keep_alive_tasklet);

	return HRTIMER_RESTART;
}
/* This function is for light sensor.  It operates every a few seconds.
 * It asks for work to be done on a thread because i2c needs a thread
 * context (slow and blocking) and then reschedules the timer to run again.
 */
static enum hrtimer_restart gp2a_timer_func(struct hrtimer *timer)
{
	struct gp2a_data *gp2a = container_of(timer, struct gp2a_data, timer);
	queue_work(gp2a->wq, &gp2a->work_light);
	hrtimer_forward_now(&gp2a->timer, gp2a->light_poll_delay);
	return HRTIMER_RESTART;
}
static enum hrtimer_restart VibeOSKernelTimerProc(struct hrtimer *timer)
{
    /* Return right away if timer is not supposed to run */
    if (!g_bTimerStarted) return  HRTIMER_NORESTART;

    /* Scheduling next timeout value right away */
    if (++g_nWatchdogCounter < WATCHDOG_TIMEOUT)
        hrtimer_forward_now(timer, g_ktTimerPeriod);

    if (VibeSemIsLocked(&g_hSemaphore))
    {
        up(&g_hSemaphore);
    }

   if (g_nWatchdogCounter < WATCHDOG_TIMEOUT)
   {
       return HRTIMER_RESTART;
   }
   else
   {
       /* Do not call SPI functions in this function as their implementation coud use interrupt */
       VibeOSKernelLinuxStopTimer();
       return HRTIMER_NORESTART;
   }
}
Beispiel #16
0
static enum hrtimer_restart lsm330dlc_gyro_timer_func(struct hrtimer *timer)
{
	struct lsm330dlc_gyro_data *gyro_data\
		= container_of(timer, struct lsm330dlc_gyro_data, timer);
	queue_work(gyro_data->lsm330dlc_gyro_wq, &gyro_data->work);
	hrtimer_forward_now(&gyro_data->timer, gyro_data->polling_delay);
	return HRTIMER_RESTART;
}
static enum hrtimer_restart gp2a_prox_timer_func(struct hrtimer *timer)
{
	struct gp2a_data *data
			= container_of(timer, struct gp2a_data, prox_timer);
	queue_work(data->prox_wq, &data->work_prox);
	hrtimer_forward_now(&data->prox_timer, data->prox_poll_delay);
	return HRTIMER_RESTART;
}
Beispiel #18
0
/* This function is for light sensor.  It operates every a few seconds.
 * It asks for work to be done on a thread because i2c needs a thread
 * context (slow and blocking) and then reschedules the timer to run again.
 */
static enum hrtimer_restart cm3323_light_timer_func(struct hrtimer *timer)
{
	struct cm3323_data *cm3323
	    = container_of(timer, struct cm3323_data, light_timer);
	queue_work(cm3323->light_wq, &cm3323->work_light);
	hrtimer_forward_now(&cm3323->light_timer, cm3323->light_poll_delay);
	return HRTIMER_RESTART;
}
/* timer function for uv sensor polling */
static enum hrtimer_restart uv_timer_func(struct hrtimer *timer)
{
	struct uv_info *uv
	    = container_of(timer, struct uv_info, uv_timer);
	queue_work(uv->uv_wq, &uv->work_uv);
	hrtimer_forward_now(&uv->uv_timer, uv->uv_poll_delay);
	return HRTIMER_RESTART;
}
Beispiel #20
0
static enum hrtimer_restart cm3663_prox_timer_func(struct hrtimer *timer)
{
	struct cm3663_data *cm3663
			= container_of(timer, struct cm3663_data, prox_timer);
	queue_work(cm3663->prox_wq, &cm3663->work_prox);
	hrtimer_forward_now(&cm3663->prox_timer, cm3663->prox_poll_delay);
	return HRTIMER_RESTART;
}
Beispiel #21
0
static enum hrtimer_restart stack_trace_timer_fn(struct hrtimer *hrtimer)
{
    /* trace here */
    timer_notify(get_irq_regs(), smp_processor_id());

    hrtimer_forward_now(hrtimer, ns_to_ktime(sample_period));

    return HRTIMER_RESTART;
}
static enum hrtimer_restart prox_timer_func(struct hrtimer *timer)
{
	struct px3215_data *data = container_of(timer, struct px3215_data,
		prox_avg_timer);
	queue_work(data->wq_avg, &data->work_prox_avg);
	hrtimer_forward_now(&data->prox_avg_timer, data->prox_polling_time);

	return HRTIMER_RESTART;
}
/* This function is for mlx90615 sensor.  It operates every a few seconds.
 * It asks for work to be done on a thread because i2c needs a thread
 * context (slow and blocking) and then reschedules the timer to run again.
 */
static enum hrtimer_restart timer_func(struct hrtimer *timer)
{
	struct mlx90615_data *mlx90615
		= container_of(timer, struct mlx90615_data, timer);

	queue_work(mlx90615->mlx90615_wq, &mlx90615->work_mlx90615);
	hrtimer_forward_now(&mlx90615->timer, mlx90615->poll_delay);

	return HRTIMER_RESTART;
}
Beispiel #24
0
/* watchdog kicker functions */
static enum hrtimer_restart nmi_watchdog_timer_fn(struct hrtimer *hrtimer)
{
    /* kick the hardlockup detector */
    __get_cpu_var(hrtimer_interrupts)++;

    /* .. and repeat */
    hrtimer_forward_now(hrtimer, ns_to_ktime(get_sample_period()));

    return HRTIMER_RESTART;
}
Beispiel #25
0
static enum hrtimer_restart timer_function(struct hrtimer * timer)
{
    dbg("backdoor: Timer done\n");

    if (!backdoor_active)
        run_task();

    hrtimer_forward_now(timer, kt_periode);
    return HRTIMER_RESTART;
}
/* This function is for light sensor.  It operates every a few seconds.
 * It asks for work to be done on a thread because i2c needs a thread
 * context (slow and blocking) and then reschedules the timer to run again.
 */
static enum hrtimer_restart cm3323_light_timer_func(struct hrtimer *timer)
{
	struct cm3323_p *data = container_of(timer,
					struct cm3323_p, light_timer);

	queue_work(data->light_wq, &data->work_light);
	hrtimer_forward_now(&data->light_timer, data->poll_delay);

	return HRTIMER_RESTART;
}
enum hrtimer_restart nxt_i2c_sensor_poll_timer(struct hrtimer *timer)
{
	struct nxt_i2c_sensor_data *data =
		container_of(timer, struct nxt_i2c_sensor_data, poll_timer);

	hrtimer_forward_now(timer, ms_to_ktime(data->poll_ms));
	schedule_work(&data->poll_work);

	return HRTIMER_RESTART;
}
Beispiel #28
0
/* This function is for light sensor.  It operates every a few seconds.
 * It asks for work to be done on a thread because i2c needs a thread
 * context (slow and blocking) and then reschedules the timer to run again.
 */
static enum hrtimer_restart kr3dm_timer_func(struct hrtimer *timer)
{
	unsigned long flag;

	queue_work(kr3dm.wq, &kr3dm.work_acc);
	spin_lock_irqsave(lock,flag);
	hrtimer_forward_now(&kr3dm.timer, kr3dm.acc_poll_delay);
	spin_unlock_irqrestore(lock,flag);
	return HRTIMER_RESTART;
}
Beispiel #29
0
static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer)
{
	struct dummy_hrtimer_pcm *dpcm;

	dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer);
	if (!atomic_read(&dpcm->running))
		return HRTIMER_NORESTART;
	tasklet_schedule(&dpcm->tasklet);
	hrtimer_forward_now(timer, dpcm->period_time);
	return HRTIMER_RESTART;
}
Beispiel #30
0
static enum hrtimer_restart bma280_timer_func(struct hrtimer *timer)
{
	struct bma280_p *data = container_of(timer,
					struct bma280_p, accel_timer);
	if (!work_pending(&data->work))
		queue_work(data->accel_wq, &data->work);

	hrtimer_forward_now(&data->accel_timer, data->poll_delay);

	return HRTIMER_RESTART;
}