blob: aab7b1987d3d8baa87a1b0c218f62fd78995f674 [file] [log] [blame]
Harmandeep Singhe5ddfe32012-05-26 09:39:25 -07001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12*/
13
14#include <linux/module.h>
15#include <linux/fs.h>
16#include <linux/miscdevice.h>
17#include <linux/uaccess.h>
18#include <linux/sched.h>
19#include <linux/wait.h>
20#include <linux/dma-mapping.h>
21#include <linux/slab.h>
22#include <asm/atomic.h>
23#include <asm/ioctls.h>
24#include "audio_utils_aio.h"
25
26void q6_audio_cb(uint32_t opcode, uint32_t token,
27 uint32_t *payload, void *priv)
28{
29 struct q6audio_aio *audio = (struct q6audio_aio *)priv;
30
31 pr_debug("%s:opcode = %x token = 0x%x\n", __func__, opcode, token);
32 switch (opcode) {
33 case ASM_DATA_EVENT_WRITE_DONE_V2:
34 case ASM_DATA_EVENT_READ_DONE_V2:
35 case ASM_DATA_EVENT_RENDERED_EOS:
36 case ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2:
37 case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
38 case ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY:
39 case ASM_DATA_EVENT_ENC_SR_CM_CHANGE_NOTIFY:
40 audio_aio_cb(opcode, token, payload, audio);
41 break;
42 default:
43 pr_debug("%s:Unhandled event = 0x%8x\n", __func__, opcode);
44 break;
45 }
46}
47
48void audio_aio_cb(uint32_t opcode, uint32_t token,
49 uint32_t *payload, void *priv/*struct q6audio_aio *audio*/)
50{
51 struct q6audio_aio *audio = (struct q6audio_aio *)priv;
52 union msm_audio_event_payload e_payload;
53
54 switch (opcode) {
55 case ASM_DATA_EVENT_WRITE_DONE_V2:
56 pr_debug("%s[%p]:ASM_DATA_EVENT_WRITE_DONE token = 0x%x\n",
57 __func__, audio, token);
58 audio_aio_async_write_ack(audio, token, payload);
59 break;
60 case ASM_DATA_EVENT_READ_DONE_V2:
61 pr_debug("%s[%p]:ASM_DATA_EVENT_READ_DONE token = 0x%x\n",
62 __func__, audio, token);
63 audio_aio_async_read_ack(audio, token, payload);
64 break;
65 case ASM_DATA_EVENT_RENDERED_EOS:
66 /* EOS Handle */
67 pr_debug("%s[%p]:ASM_DATA_CMDRSP_EOS\n", __func__, audio);
68 if (audio->feedback) { /* Non-Tunnel mode */
69 audio->eos_rsp = 1;
70 /* propagate input EOS i/p buffer,
71 after receiving DSP acknowledgement */
72 if (audio->eos_flag &&
73 (audio->eos_write_payload.aio_buf.buf_addr)) {
74 audio_aio_post_event(audio,
75 AUDIO_EVENT_WRITE_DONE,
76 audio->eos_write_payload);
77 memset(&audio->eos_write_payload , 0,
78 sizeof(union msm_audio_event_payload));
79 audio->eos_flag = 0;
80 }
81 } else { /* Tunnel mode */
82 audio->eos_rsp = 1;
83 wake_up(&audio->write_wait);
84 wake_up(&audio->cmd_wait);
85 }
86 break;
87 case ASM_DATA_CMD_MEDIA_FMT_UPDATE_V2:
88 case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
89 pr_debug("%s[%p]:payload0[%x] payloa1d[%x]opcode= 0x%x\n",
90 __func__, audio, payload[0], payload[1], opcode);
91 break;
92 case ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY:
93 case ASM_DATA_EVENT_ENC_SR_CM_CHANGE_NOTIFY:
94
95 pr_debug("%s[%p]: ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY, payload[0]-sr = %d, payload[1]-chl = %d, payload[2] = %d, payload[3] = %d\n",
96 __func__, audio, payload[0],
97 payload[1], payload[2], payload[3]);
98
99 pr_debug("%s[%p]: ASM_DATA_EVENT_SR_CM_CHANGE_NOTIFY, sr(prev) = %d, chl(prev) = %d,",
100 __func__, audio, audio->pcm_cfg.sample_rate,
101 audio->pcm_cfg.channel_count);
102
103 audio->pcm_cfg.sample_rate = payload[0];
104 audio->pcm_cfg.channel_count = payload[1] & 0xFFFF;
105 e_payload.stream_info.chan_info = audio->pcm_cfg.channel_count;
106 e_payload.stream_info.sample_rate = audio->pcm_cfg.sample_rate;
107 audio_aio_post_event(audio, AUDIO_EVENT_STREAM_INFO, e_payload);
108 break;
109 default:
110 break;
111 }
112}