qdsp5: audio: Update encoder drivers to use preproc driver functions
All the preproc(pre processing) functions have been moved to
preproc driver. Update encoder drivers to call preproc driver
functions to establish recording session.
Change-Id: Icca721b37ae84d3959681fea2b53e12c7ba271f8
Signed-off-by: Manish Dewangan <manish@codeaurora.org>
diff --git a/arch/arm/mach-msm/qdsp5/audio_amrnb_in.c b/arch/arm/mach-msm/qdsp5/audio_amrnb_in.c
index 39578c1..05ad373 100644
--- a/arch/arm/mach-msm/qdsp5/audio_amrnb_in.c
+++ b/arch/arm/mach-msm/qdsp5/audio_amrnb_in.c
@@ -114,8 +114,6 @@
uint32_t out_frame_cnt;
struct msm_adsp_module *audrec;
- struct msm_adsp_module *audpre;
-
/* configuration to use on next enable */
uint32_t samp_rate;
@@ -154,6 +152,7 @@
struct ion_client *client;
struct ion_handle *input_buff_handle;
+ struct audrec_session_info session_info; /*audrec session info*/
};
struct audio_frame {
@@ -232,6 +231,30 @@
}
}
+/* ------------------- dsp --------------------- */
+static void audpre_dsp_event(void *data, unsigned id, void *event_data)
+{
+
+ uint16_t *msg = event_data;
+
+ if (!msg)
+ return;
+
+ switch (id) {
+ case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
+ MM_DBG("type %d, status_flag %d\n",\
+ msg[0], msg[1]);
+ break;
+ case AUDPREPROC_MSG_ERROR_MSG_ID:
+ MM_INFO("err_index %d\n", msg[0]);
+ break;
+ case ADSP_MESSAGE_ID:
+ MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
+ break;
+ default:
+ MM_ERR("unknown event %d\n", id);
+ }
+}
/* must be called with audio->lock held */
static int audamrnb_in_enable(struct audio_amrnb_in *audio)
{
@@ -252,16 +275,23 @@
if (rc < 0)
return rc;
- if (msm_adsp_enable(audio->audpre)) {
+ if (audpreproc_enable(audio->enc_id,
+ &audpre_dsp_event, audio)) {
+ MM_ERR("msm_adsp_enable(audpreproc) failed\n");
audmgr_disable(&audio->audmgr);
- MM_ERR("msm_adsp_enable(audpre) failed\n");
return -ENODEV;
}
+ /*update aurec session info in audpreproc layer*/
+ audio->session_info.session_id = audio->enc_id;
+ audio->session_info.sampling_freq =
+ convert_samp_index(audio->samp_rate);
+ audpreproc_update_audrec_info(&audio->session_info);
}
+
if (msm_adsp_enable(audio->audrec)) {
if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
+ audpreproc_disable(audio->enc_id, audio);
audmgr_disable(&audio->audmgr);
- msm_adsp_disable(audio->audpre);
}
MM_ERR("msm_adsp_enable(audrec) failed\n");
return -ENODEV;
@@ -286,35 +316,17 @@
audio->running == 0, 1*HZ);
msm_adsp_disable(audio->audrec);
if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
- msm_adsp_disable(audio->audpre);
+ /*reset the sampling frequency information at
+ audpreproc layer*/
+ audio->session_info.sampling_freq = 0;
+ audpreproc_update_audrec_info(&audio->session_info);
+ audpreproc_disable(audio->enc_id, audio);
audmgr_disable(&audio->audmgr);
}
}
return 0;
}
-/* ------------------- dsp --------------------- */
-static void audpre_dsp_event(void *data, unsigned id, size_t len,
- void (*getevent)(void *ptr, size_t len))
-{
- uint16_t msg[2];
- getevent(msg, sizeof(msg));
-
- switch (id) {
- case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
- MM_DBG("type %d, status_flag %d\n", msg[0], msg[1]);
- break;
- case AUDPREPROC_MSG_ERROR_MSG_ID:
- MM_ERR("err_index %d\n", msg[0]);
- break;
- case ADSP_MESSAGE_ID:
- MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
- break;
- default:
- MM_ERR("unknown event %d\n", id);
- }
-}
-
static void audamrnb_in_get_dsp_frames(struct audio_amrnb_in *audio)
{
struct audio_frame *frame;
@@ -555,10 +567,6 @@
}
}
-struct msm_adsp_ops audpre_amrnb_adsp_ops = {
- .event = audpre_dsp_event,
-};
-
struct msm_adsp_ops audrec_amrnb_adsp_ops = {
.event = audrec_dsp_event,
};
@@ -1201,12 +1209,8 @@
audamrnb_in_flush(audio);
msm_adsp_put(audio->audrec);
- if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
- msm_adsp_put(audio->audpre);
-
audpreproc_aenc_free(audio->enc_id);
audio->audrec = NULL;
- audio->audpre = NULL;
audio->opened = 0;
if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) && \
(audio->out_data)) {
@@ -1304,15 +1308,6 @@
goto done;
}
- if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
- rc = msm_adsp_get("AUDPREPROCTASK", &audio->audpre,
- &audpre_amrnb_adsp_ops, audio);
- if (rc) {
- msm_adsp_put(audio->audrec);
- audpreproc_aenc_free(audio->enc_id);
- goto done;
- }
- }
audio->dsp_cnt = 0;
audio->stopped = 0;
audio->wflush = 0;
@@ -1414,8 +1409,6 @@
dma_free_coherent(NULL, dma_size, audio->data, audio->phys);
evt_error:
msm_adsp_put(audio->audrec);
- if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
- msm_adsp_put(audio->audpre);
audpreproc_aenc_free(audio->enc_id);
mutex_unlock(&audio->lock);