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; 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) { 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_read( (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++; 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; }
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; }
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; } }