blob: 468aba8a9f1ecc9cf2f8f0271d29689ae49c63b8 [file] [log] [blame]
Helen Zeng4e531942011-12-17 21:14:40 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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#ifndef __QDSP6VOICE_H__
13#define __QDSP6VOICE_H__
14
15#include <mach/qdsp6v2/apr.h>
Helen Zeng6e64dba2012-03-08 18:30:11 -080016#include <linux/ion.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017
Helen Zeng2095e572011-08-15 18:30:43 -070018#define MAX_VOC_PKT_SIZE 642
Satish Babu Patakokila75645ce2012-06-20 15:01:02 +053019#define SESSION_NAME_LEN 21
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070020
Helen Zenge3d716a2011-10-14 16:32:16 -070021#define VOC_REC_UPLINK 0x00
22#define VOC_REC_DOWNLINK 0x01
23#define VOC_REC_BOTH 0x02
24
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025struct voice_header {
26 uint32_t id;
27 uint32_t data_len;
28};
29
30struct voice_init {
31 struct voice_header hdr;
32 void *cb_handle;
33};
34
35/* Device information payload structure */
36
37struct device_data {
38 uint32_t volume; /* in index */
39 uint32_t mute;
40 uint32_t sample;
41 uint32_t enabled;
42 uint32_t dev_id;
43 uint32_t port_id;
44};
45
46struct voice_dev_route_state {
47 u16 rx_route_flag;
48 u16 tx_route_flag;
49};
50
Helen Zenge3d716a2011-10-14 16:32:16 -070051struct voice_rec_route_state {
52 u16 ul_flag;
53 u16 dl_flag;
54};
55
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070056enum {
57 VOC_INIT = 0,
58 VOC_RUN,
59 VOC_CHANGE,
60 VOC_RELEASE,
Venkat Sudhire65fa412012-05-15 01:42:31 -070061 VOC_STANDBY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070062};
63
Helen Zeng29eb7442011-06-20 11:06:29 -070064/* Common */
Helen Zengbb49c702011-09-06 14:09:13 -070065#define VSS_ICOMMON_CMD_SET_UI_PROPERTY 0x00011103
66/* Set a UI property */
Helen Zeng29eb7442011-06-20 11:06:29 -070067#define VSS_ICOMMON_CMD_MAP_MEMORY 0x00011025
68#define VSS_ICOMMON_CMD_UNMAP_MEMORY 0x00011026
69/* General shared memory; byte-accessible, 4 kB-aligned. */
70#define VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL 3
71
72struct vss_icommon_cmd_map_memory_t {
73 uint32_t phys_addr;
74 /* Physical address of a memory region; must be at least
75 * 4 kB aligned.
76 */
77
78 uint32_t mem_size;
79 /* Number of bytes in the region; should be a multiple of 32. */
80
81 uint16_t mem_pool_id;
82 /* Type of memory being provided. The memory ID implicitly defines
83 * the characteristics of the memory. The characteristics might include
84 * alignment type, permissions, etc.
85 * Memory pool ID. Possible values:
86 * 3 -- VSS_ICOMMON_MEM_TYPE_SHMEM8_4K_POOL.
87 */
88} __packed;
89
90struct vss_icommon_cmd_unmap_memory_t {
91 uint32_t phys_addr;
92 /* Physical address of a memory region; must be at least
93 * 4 kB aligned.
94 */
95} __packed;
96
97struct vss_map_memory_cmd {
98 struct apr_hdr hdr;
99 struct vss_icommon_cmd_map_memory_t vss_map_mem;
100} __packed;
101
102struct vss_unmap_memory_cmd {
103 struct apr_hdr hdr;
104 struct vss_icommon_cmd_unmap_memory_t vss_unmap_mem;
105} __packed;
106
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700107/* TO MVM commands */
108#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x000110FF
109/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
110
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700111#define VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL 0x00011327
112/*
113 * VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL
114 * Description: This command is required to let MVM know
115 * who is in control of session.
116 * Payload: Defined by vss_imvm_cmd_set_policy_dual_control_t.
117 * Result: Wait for APRV2_IBASIC_RSP_RESULT response.
118 */
119
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700120#define VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110FE
121/* Create a new full control MVM session. */
122
123#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
124/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
125
126#define VSS_IMVM_CMD_ATTACH_STREAM 0x0001123C
127/* Attach a stream to the MVM. */
128
129#define VSS_IMVM_CMD_DETACH_STREAM 0x0001123D
130/* Detach a stream from the MVM. */
131
Helen Zeng69b00962011-07-08 11:38:36 -0700132#define VSS_IMVM_CMD_ATTACH_VOCPROC 0x0001123E
133/* Attach a vocproc to the MVM. The MVM will symmetrically connect this vocproc
134 * to all the streams currently attached to it.
135 */
136
137#define VSS_IMVM_CMD_DETACH_VOCPROC 0x0001123F
138/* Detach a vocproc from the MVM. The MVM will symmetrically disconnect this
139 * vocproc from all the streams to which it is currently attached.
140*/
141
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142#define VSS_IMVM_CMD_START_VOICE 0x00011190
Venkat Sudhire65fa412012-05-15 01:42:31 -0700143/*
144 * Start Voice call command.
145 * Wait for APRV2_IBASIC_RSP_RESULT response.
146 * No pay load.
147 */
148
149#define VSS_IMVM_CMD_STANDBY_VOICE 0x00011191
150/* No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700151
152#define VSS_IMVM_CMD_STOP_VOICE 0x00011192
153/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
154
155#define VSS_ISTREAM_CMD_ATTACH_VOCPROC 0x000110F8
156/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
157
158#define VSS_ISTREAM_CMD_DETACH_VOCPROC 0x000110F9
159/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
160
161
162#define VSS_ISTREAM_CMD_SET_TTY_MODE 0x00011196
163/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
164
165#define VSS_ICOMMON_CMD_SET_NETWORK 0x0001119C
166/* Set the network type. */
167
168#define VSS_ICOMMON_CMD_SET_VOICE_TIMING 0x000111E0
169/* Set the voice timing parameters. */
170
Helen Zeng44d4d272011-08-10 14:49:20 -0700171#define VSS_IWIDEVOICE_CMD_SET_WIDEVOICE 0x00011243
172/* Enable/disable WideVoice */
173
Laxminath Kasam481d4982012-04-04 20:54:30 +0530174enum msm_audio_voc_rate {
175 VOC_0_RATE, /* Blank frame */
176 VOC_8_RATE, /* 1/8 rate */
177 VOC_4_RATE, /* 1/4 rate */
178 VOC_2_RATE, /* 1/2 rate */
179 VOC_1_RATE /* Full rate */
180};
181
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700182struct vss_istream_cmd_set_tty_mode_t {
183 uint32_t mode;
184 /**<
185 * TTY mode.
186 *
187 * 0 : TTY disabled
188 * 1 : HCO
189 * 2 : VCO
190 * 3 : FULL
191 */
192} __packed;
193
194struct vss_istream_cmd_attach_vocproc_t {
195 uint16_t handle;
196 /**< Handle of vocproc being attached. */
197} __packed;
198
199struct vss_istream_cmd_detach_vocproc_t {
200 uint16_t handle;
201 /**< Handle of vocproc being detached. */
202} __packed;
203
204struct vss_imvm_cmd_attach_stream_t {
205 uint16_t handle;
206 /* The stream handle to attach. */
207} __packed;
208
209struct vss_imvm_cmd_detach_stream_t {
210 uint16_t handle;
211 /* The stream handle to detach. */
212} __packed;
213
214struct vss_icommon_cmd_set_network_t {
215 uint32_t network_id;
216 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
217} __packed;
218
219struct vss_icommon_cmd_set_voice_timing_t {
220 uint16_t mode;
221 /*
222 * The vocoder frame synchronization mode.
223 *
224 * 0 : No frame sync.
225 * 1 : Hard VFR (20ms Vocoder Frame Reference interrupt).
226 */
227 uint16_t enc_offset;
228 /*
229 * The offset in microseconds from the VFR to deliver a Tx vocoder
230 * packet. The offset should be less than 20000us.
231 */
232 uint16_t dec_req_offset;
233 /*
234 * The offset in microseconds from the VFR to request for an Rx vocoder
235 * packet. The offset should be less than 20000us.
236 */
237 uint16_t dec_offset;
238 /*
239 * The offset in microseconds from the VFR to indicate the deadline to
240 * receive an Rx vocoder packet. The offset should be less than 20000us.
241 * Rx vocoder packets received after this deadline are not guaranteed to
242 * be processed.
243 */
244} __packed;
245
Helen Zeng69b00962011-07-08 11:38:36 -0700246struct vss_imvm_cmd_create_control_session_t {
247 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700248 /*
249 * A variable-sized stream name.
250 *
251 * The stream name size is the payload size minus the size of the other
252 * fields.
253 */
254} __packed;
255
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700256
257struct vss_imvm_cmd_set_policy_dual_control_t {
258 bool enable_flag;
259 /* Set to TRUE to enable modem state machine control */
260} __packed;
261
Helen Zeng44d4d272011-08-10 14:49:20 -0700262struct vss_iwidevoice_cmd_set_widevoice_t {
263 uint32_t enable;
264 /* WideVoice enable/disable; possible values:
265 * - 0 -- WideVoice disabled
266 * - 1 -- WideVoice enabled
267 */
268} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700269
270struct mvm_attach_vocproc_cmd {
271 struct apr_hdr hdr;
272 struct vss_istream_cmd_attach_vocproc_t mvm_attach_cvp_handle;
273} __packed;
274
275struct mvm_detach_vocproc_cmd {
276 struct apr_hdr hdr;
277 struct vss_istream_cmd_detach_vocproc_t mvm_detach_cvp_handle;
278} __packed;
279
Helen Zeng69b00962011-07-08 11:38:36 -0700280struct mvm_create_ctl_session_cmd {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700281 struct apr_hdr hdr;
Helen Zeng69b00962011-07-08 11:38:36 -0700282 struct vss_imvm_cmd_create_control_session_t mvm_session;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283} __packed;
284
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700285struct mvm_modem_dual_control_session_cmd {
286 struct apr_hdr hdr;
287 struct vss_imvm_cmd_set_policy_dual_control_t voice_ctl;
288} __packed;
289
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700290struct mvm_set_tty_mode_cmd {
291 struct apr_hdr hdr;
292 struct vss_istream_cmd_set_tty_mode_t tty_mode;
293} __packed;
294
295struct mvm_attach_stream_cmd {
296 struct apr_hdr hdr;
297 struct vss_imvm_cmd_attach_stream_t attach_stream;
298} __packed;
299
300struct mvm_detach_stream_cmd {
301 struct apr_hdr hdr;
302 struct vss_imvm_cmd_detach_stream_t detach_stream;
303} __packed;
304
305struct mvm_set_network_cmd {
306 struct apr_hdr hdr;
307 struct vss_icommon_cmd_set_network_t network;
308} __packed;
309
310struct mvm_set_voice_timing_cmd {
311 struct apr_hdr hdr;
312 struct vss_icommon_cmd_set_voice_timing_t timing;
313} __packed;
314
Helen Zeng44d4d272011-08-10 14:49:20 -0700315struct mvm_set_widevoice_enable_cmd {
316 struct apr_hdr hdr;
317 struct vss_iwidevoice_cmd_set_widevoice_t vss_set_wv;
318} __packed;
319
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700320/* TO CVS commands */
321#define VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x00011140
322/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
323
324#define VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110F7
325/* Create a new full control stream session. */
326
327#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
328
329#define VSS_ISTREAM_CMD_SET_MUTE 0x00011022
330
Helen Zeng29eb7442011-06-20 11:06:29 -0700331#define VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA 0x00011279
332
333#define VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA 0x0001127A
334
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700335#define VSS_ISTREAM_CMD_SET_MEDIA_TYPE 0x00011186
336/* Set media type on the stream. */
337
338#define VSS_ISTREAM_EVT_SEND_ENC_BUFFER 0x00011015
339/* Event sent by the stream to its client to provide an encoded packet. */
340
341#define VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER 0x00011017
342/* Event sent by the stream to its client requesting for a decoder packet.
343 * The client should respond with a VSS_ISTREAM_EVT_SEND_DEC_BUFFER event.
344 */
345
346#define VSS_ISTREAM_EVT_SEND_DEC_BUFFER 0x00011016
347/* Event sent by the client to the stream in response to a
348 * VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER event, providing a decoder packet.
349 */
350
351#define VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE 0x0001113E
352/* Set AMR encoder rate. */
353
354#define VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE 0x0001113F
355/* Set AMR-WB encoder rate. */
356
357#define VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE 0x00011019
358/* Set encoder minimum and maximum rate. */
359
360#define VSS_ISTREAM_CMD_SET_ENC_DTX_MODE 0x0001101D
361/* Set encoder DTX mode. */
362
Helen Zeng4e531942011-12-17 21:14:40 -0800363#define MODULE_ID_VOICE_MODULE_FENS 0x00010EEB
Helen Zengbb49c702011-09-06 14:09:13 -0700364#define MODULE_ID_VOICE_MODULE_ST 0x00010EE3
365#define VOICE_PARAM_MOD_ENABLE 0x00010E00
366#define MOD_ENABLE_PARAM_LEN 4
367
Helen Zeng0705a5f2011-10-14 15:29:52 -0700368#define VSS_ISTREAM_CMD_START_PLAYBACK 0x00011238
369/* Start in-call music delivery on the Tx voice path. */
370
371#define VSS_ISTREAM_CMD_STOP_PLAYBACK 0x00011239
372/* Stop the in-call music delivery on the Tx voice path. */
373
Helen Zenge3d716a2011-10-14 16:32:16 -0700374#define VSS_ISTREAM_CMD_START_RECORD 0x00011236
375/* Start in-call conversation recording. */
376#define VSS_ISTREAM_CMD_STOP_RECORD 0x00011237
377/* Stop in-call conversation recording. */
378
379#define VSS_TAP_POINT_NONE 0x00010F78
380/* Indicates no tapping for specified path. */
381
382#define VSS_TAP_POINT_STREAM_END 0x00010F79
383/* Indicates that specified path should be tapped at the end of the stream. */
384
385struct vss_istream_cmd_start_record_t {
386 uint32_t rx_tap_point;
387 /* Tap point to use on the Rx path. Supported values are:
388 * VSS_TAP_POINT_NONE : Do not record Rx path.
389 * VSS_TAP_POINT_STREAM_END : Rx tap point is at the end of the stream.
390 */
391 uint32_t tx_tap_point;
392 /* Tap point to use on the Tx path. Supported values are:
393 * VSS_TAP_POINT_NONE : Do not record tx path.
394 * VSS_TAP_POINT_STREAM_END : Tx tap point is at the end of the stream.
395 */
396} __packed;
397
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700398struct vss_istream_cmd_create_passive_control_session_t {
Helen Zeng69b00962011-07-08 11:38:36 -0700399 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700400 /**<
401 * A variable-sized stream name.
402 *
403 * The stream name size is the payload size minus the size of the other
404 * fields.
405 */
406} __packed;
407
408struct vss_istream_cmd_set_mute_t {
409 uint16_t direction;
410 /**<
411 * 0 : TX only
412 * 1 : RX only
413 * 2 : TX and Rx
414 */
415 uint16_t mute_flag;
416 /**<
417 * Mute, un-mute.
418 *
419 * 0 : Silence disable
420 * 1 : Silence enable
421 * 2 : CNG enable. Applicable to TX only. If set on RX behavior
422 * will be the same as 1
423 */
424} __packed;
425
426struct vss_istream_cmd_create_full_control_session_t {
427 uint16_t direction;
428 /*
429 * Stream direction.
430 *
431 * 0 : TX only
432 * 1 : RX only
433 * 2 : TX and RX
434 * 3 : TX and RX loopback
435 */
436 uint32_t enc_media_type;
437 /* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
438 uint32_t dec_media_type;
439 /* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
440 uint32_t network_id;
441 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
Helen Zeng69b00962011-07-08 11:38:36 -0700442 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700443 /*
444 * A variable-sized stream name.
445 *
446 * The stream name size is the payload size minus the size of the other
447 * fields.
448 */
449} __packed;
450
451struct vss_istream_cmd_set_media_type_t {
452 uint32_t rx_media_id;
453 /* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
454 uint32_t tx_media_id;
455 /* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
456} __packed;
457
458struct vss_istream_evt_send_enc_buffer_t {
459 uint32_t media_id;
460 /* Media ID of the packet. */
461 uint8_t packet_data[MAX_VOC_PKT_SIZE];
462 /* Packet data buffer. */
463} __packed;
464
465struct vss_istream_evt_send_dec_buffer_t {
466 uint32_t media_id;
467 /* Media ID of the packet. */
468 uint8_t packet_data[MAX_VOC_PKT_SIZE];
469 /* Packet data. */
470} __packed;
471
472struct vss_istream_cmd_voc_amr_set_enc_rate_t {
473 uint32_t mode;
474 /* Set the AMR encoder rate.
475 *
476 * 0x00000000 : 4.75 kbps
477 * 0x00000001 : 5.15 kbps
478 * 0x00000002 : 5.90 kbps
479 * 0x00000003 : 6.70 kbps
480 * 0x00000004 : 7.40 kbps
481 * 0x00000005 : 7.95 kbps
482 * 0x00000006 : 10.2 kbps
483 * 0x00000007 : 12.2 kbps
484 */
485} __packed;
486
487struct vss_istream_cmd_voc_amrwb_set_enc_rate_t {
488 uint32_t mode;
489 /* Set the AMR-WB encoder rate.
490 *
491 * 0x00000000 : 6.60 kbps
492 * 0x00000001 : 8.85 kbps
493 * 0x00000002 : 12.65 kbps
494 * 0x00000003 : 14.25 kbps
495 * 0x00000004 : 15.85 kbps
496 * 0x00000005 : 18.25 kbps
497 * 0x00000006 : 19.85 kbps
498 * 0x00000007 : 23.05 kbps
499 * 0x00000008 : 23.85 kbps
500 */
501} __packed;
502
503struct vss_istream_cmd_cdma_set_enc_minmax_rate_t {
504 uint16_t min_rate;
505 /* Set the lower bound encoder rate.
506 *
507 * 0x0000 : Blank frame
508 * 0x0001 : Eighth rate
509 * 0x0002 : Quarter rate
510 * 0x0003 : Half rate
511 * 0x0004 : Full rate
512 */
513 uint16_t max_rate;
514 /* Set the upper bound encoder rate.
515 *
516 * 0x0000 : Blank frame
517 * 0x0001 : Eighth rate
518 * 0x0002 : Quarter rate
519 * 0x0003 : Half rate
520 * 0x0004 : Full rate
521 */
522} __packed;
523
524struct vss_istream_cmd_set_enc_dtx_mode_t {
525 uint32_t enable;
526 /* Toggle DTX on or off.
527 *
528 * 0 : Disables DTX
529 * 1 : Enables DTX
530 */
531} __packed;
532
Helen Zeng29eb7442011-06-20 11:06:29 -0700533struct vss_istream_cmd_register_calibration_data_t {
534 uint32_t phys_addr;
535 /* Phsical address to be registered with stream. The calibration data
536 * is stored at this address.
537 */
538 uint32_t mem_size;
539 /* Size of the calibration data in bytes. */
540};
541
Helen Zeng4e531942011-12-17 21:14:40 -0800542struct vss_icommon_cmd_set_ui_property_enable_t {
Helen Zengbb49c702011-09-06 14:09:13 -0700543 uint32_t module_id;
544 /* Unique ID of the module. */
545 uint32_t param_id;
546 /* Unique ID of the parameter. */
547 uint16_t param_size;
548 /* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */
549 uint16_t reserved;
550 /* Reserved; set to 0. */
551 uint16_t enable;
552 uint16_t reserved_field;
553 /* Reserved, set to 0. */
554};
555
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700556struct cvs_create_passive_ctl_session_cmd {
557 struct apr_hdr hdr;
558 struct vss_istream_cmd_create_passive_control_session_t cvs_session;
559} __packed;
560
561struct cvs_create_full_ctl_session_cmd {
562 struct apr_hdr hdr;
563 struct vss_istream_cmd_create_full_control_session_t cvs_session;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700564} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700565
566struct cvs_destroy_session_cmd {
567 struct apr_hdr hdr;
568} __packed;
569
570struct cvs_set_mute_cmd {
571 struct apr_hdr hdr;
572 struct vss_istream_cmd_set_mute_t cvs_set_mute;
573} __packed;
574
575struct cvs_set_media_type_cmd {
576 struct apr_hdr hdr;
577 struct vss_istream_cmd_set_media_type_t media_type;
578} __packed;
579
580struct cvs_send_dec_buf_cmd {
581 struct apr_hdr hdr;
582 struct vss_istream_evt_send_dec_buffer_t dec_buf;
583} __packed;
584
585struct cvs_set_amr_enc_rate_cmd {
586 struct apr_hdr hdr;
587 struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate;
588} __packed;
589
590struct cvs_set_amrwb_enc_rate_cmd {
591 struct apr_hdr hdr;
592 struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate;
593} __packed;
594
595struct cvs_set_cdma_enc_minmax_rate_cmd {
596 struct apr_hdr hdr;
597 struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate;
598} __packed;
599
600struct cvs_set_enc_dtx_mode_cmd {
601 struct apr_hdr hdr;
602 struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode;
603} __packed;
604
Helen Zeng29eb7442011-06-20 11:06:29 -0700605struct cvs_register_cal_data_cmd {
606 struct apr_hdr hdr;
607 struct vss_istream_cmd_register_calibration_data_t cvs_cal_data;
608} __packed;
609
610struct cvs_deregister_cal_data_cmd {
611 struct apr_hdr hdr;
612} __packed;
613
Helen Zeng4e531942011-12-17 21:14:40 -0800614struct cvs_set_pp_enable_cmd {
Helen Zengbb49c702011-09-06 14:09:13 -0700615 struct apr_hdr hdr;
Helen Zeng4e531942011-12-17 21:14:40 -0800616 struct vss_icommon_cmd_set_ui_property_enable_t vss_set_pp;
Helen Zengbb49c702011-09-06 14:09:13 -0700617} __packed;
Helen Zenge3d716a2011-10-14 16:32:16 -0700618struct cvs_start_record_cmd {
619 struct apr_hdr hdr;
620 struct vss_istream_cmd_start_record_t rec_mode;
621} __packed;
Helen Zengbb49c702011-09-06 14:09:13 -0700622
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700623/* TO CVP commands */
624
625#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION 0x000100C3
626/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
627
628#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
629
630#define VSS_IVOCPROC_CMD_SET_DEVICE 0x000100C4
631
632#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB
633
634#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE
635
636#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6
637/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
638
639#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1
640/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
641
Helen Zeng29eb7442011-06-20 11:06:29 -0700642#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA 0x00011275
643#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276
644
645#define VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE 0x00011277
646#define VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE 0x00011278
647
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700648#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70
649#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71
650#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72
651
652#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77
653
654/* Newtwork IDs */
655#define VSS_NETWORK_ID_DEFAULT 0x00010037
656#define VSS_NETWORK_ID_VOIP_NB 0x00011240
657#define VSS_NETWORK_ID_VOIP_WB 0x00011241
658#define VSS_NETWORK_ID_VOIP_WV 0x00011242
659
660/* Media types */
661#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2
662/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */
663#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6
664/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */
665#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7
666/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */
667#define VSS_MEDIA_ID_PCM_NB 0x00010FCB
668#define VSS_MEDIA_ID_PCM_WB 0x00010FCC
669/* Linear PCM (16-bit, little-endian). */
670#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD
671/* G.711 a-law (contains two 10ms vocoder frames). */
672#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE
673/* G.711 mu-law (contains two 10ms vocoder frames). */
674#define VSS_MEDIA_ID_G729 0x00010FD0
675/* G.729AB (contains two 10ms vocoder frames. */
Laxminath Kasam481d4982012-04-04 20:54:30 +0530676#define VSS_MEDIA_ID_4GV_NB_MODEM 0x00010FC3
677/*CDMA EVRC-B vocoder modem format */
678#define VSS_MEDIA_ID_4GV_WB_MODEM 0x00010FC4
679/*CDMA EVRC-WB vocoder modem format */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700680
Helen Zeng68656932011-11-02 18:08:23 -0700681#define VSS_IVOCPROC_CMD_SET_MUTE 0x000110EF
682
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700683#define VOICE_CMD_SET_PARAM 0x00011006
684#define VOICE_CMD_GET_PARAM 0x00011007
685#define VOICE_EVT_GET_PARAM_ACK 0x00011008
686
687struct vss_ivocproc_cmd_create_full_control_session_t {
688 uint16_t direction;
689 /*
690 * stream direction.
691 * 0 : TX only
692 * 1 : RX only
693 * 2 : TX and RX
694 */
695 uint32_t tx_port_id;
696 /*
697 * TX device port ID which vocproc will connect to. If not supplying a
698 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
699 */
700 uint32_t tx_topology_id;
701 /*
702 * Tx leg topology ID. If not supplying a topology ID set to
703 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
704 */
705 uint32_t rx_port_id;
706 /*
707 * RX device port ID which vocproc will connect to. If not supplying a
708 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
709 */
710 uint32_t rx_topology_id;
711 /*
712 * Rx leg topology ID. If not supplying a topology ID set to
713 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
714 */
715 int32_t network_id;
716 /*
717 * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network
718 * ID set to VSS_NETWORK_ID_DEFAULT.
719 */
720} __packed;
721
722struct vss_ivocproc_cmd_set_volume_index_t {
723 uint16_t vol_index;
724 /**<
725 * Volume index utilized by the vocproc to index into the volume table
726 * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set
727 * volume on the VDSP.
728 */
729} __packed;
730
731struct vss_ivocproc_cmd_set_device_t {
732 uint32_t tx_port_id;
733 /**<
734 * TX device port ID which vocproc will connect to.
735 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
736 */
737 uint32_t tx_topology_id;
738 /**<
739 * TX leg topology ID.
740 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
741 * pre/post-processing blocks and is pass-through.
742 */
743 int32_t rx_port_id;
744 /**<
745 * RX device port ID which vocproc will connect to.
746 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
747 */
748 uint32_t rx_topology_id;
749 /**<
750 * RX leg topology ID.
751 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
752 * pre/post-processing blocks and is pass-through.
753 */
754} __packed;
755
Helen Zeng29eb7442011-06-20 11:06:29 -0700756struct vss_ivocproc_cmd_register_calibration_data_t {
757 uint32_t phys_addr;
758 /* Phsical address to be registered with vocproc. Calibration data
759 * is stored at this address.
760 */
761 uint32_t mem_size;
762 /* Size of the calibration data in bytes. */
763} __packed;
764
765struct vss_ivocproc_cmd_register_volume_cal_table_t {
766 uint32_t phys_addr;
767 /* Phsical address to be registered with the vocproc. The volume
768 * calibration table is stored at this location.
769 */
770
771 uint32_t mem_size;
772 /* Size of the volume calibration table in bytes. */
773} __packed;
774
Helen Zeng68656932011-11-02 18:08:23 -0700775struct vss_ivocproc_cmd_set_mute_t {
776 uint16_t direction;
777 /*
778 * 0 : TX only.
779 * 1 : RX only.
780 * 2 : TX and Rx.
781 */
782 uint16_t mute_flag;
783 /*
784 * Mute, un-mute.
785 *
786 * 0 : Disable.
787 * 1 : Enable.
788 */
789} __packed;
790
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700791struct cvp_create_full_ctl_session_cmd {
792 struct apr_hdr hdr;
793 struct vss_ivocproc_cmd_create_full_control_session_t cvp_session;
794} __packed;
795
796struct cvp_command {
797 struct apr_hdr hdr;
798} __packed;
799
800struct cvp_set_device_cmd {
801 struct apr_hdr hdr;
802 struct vss_ivocproc_cmd_set_device_t cvp_set_device;
803} __packed;
804
805struct cvp_set_vp3_data_cmd {
806 struct apr_hdr hdr;
807} __packed;
808
809struct cvp_set_rx_volume_index_cmd {
810 struct apr_hdr hdr;
811 struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx;
812} __packed;
813
Helen Zeng29eb7442011-06-20 11:06:29 -0700814struct cvp_register_cal_data_cmd {
815 struct apr_hdr hdr;
816 struct vss_ivocproc_cmd_register_calibration_data_t cvp_cal_data;
817} __packed;
818
819struct cvp_deregister_cal_data_cmd {
820 struct apr_hdr hdr;
821} __packed;
822
823struct cvp_register_vol_cal_table_cmd {
824 struct apr_hdr hdr;
825 struct vss_ivocproc_cmd_register_volume_cal_table_t cvp_vol_cal_tbl;
826} __packed;
827
828struct cvp_deregister_vol_cal_table_cmd {
829 struct apr_hdr hdr;
830} __packed;
831
Helen Zeng68656932011-11-02 18:08:23 -0700832struct cvp_set_mute_cmd {
833 struct apr_hdr hdr;
834 struct vss_ivocproc_cmd_set_mute_t cvp_set_mute;
835} __packed;
836
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700837/* CB for up-link packets. */
838typedef void (*ul_cb_fn)(uint8_t *voc_pkt,
839 uint32_t pkt_len,
840 void *private_data);
841
842/* CB for down-link packets. */
843typedef void (*dl_cb_fn)(uint8_t *voc_pkt,
844 uint32_t *pkt_len,
845 void *private_data);
846
847
848struct mvs_driver_info {
849 uint32_t media_type;
850 uint32_t rate;
851 uint32_t network_type;
Helen Zengff97bec2012-02-20 14:30:50 -0800852 uint32_t dtx_mode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700853 ul_cb_fn ul_cb;
854 dl_cb_fn dl_cb;
855 void *private_data;
856};
857
858struct incall_rec_info {
Helen Zenge3d716a2011-10-14 16:32:16 -0700859 uint32_t rec_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700860 uint32_t rec_mode;
Helen Zenge3d716a2011-10-14 16:32:16 -0700861 uint32_t recording;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700862};
863
864struct incall_music_info {
Helen Zeng0705a5f2011-10-14 15:29:52 -0700865 uint32_t play_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700866 uint32_t playing;
Helen Zeng0705a5f2011-10-14 15:29:52 -0700867 int count;
868 int force;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700869};
870
871struct voice_data {
872 int voc_state;/*INIT, CHANGE, RELEASE, RUN */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700873
874 wait_queue_head_t mvm_wait;
875 wait_queue_head_t cvs_wait;
876 wait_queue_head_t cvp_wait;
877
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700878 /* cache the values related to Rx and Tx */
879 struct device_data dev_rx;
880 struct device_data dev_tx;
881
Neema Shetty2c07eb52011-08-21 20:33:52 -0700882 u32 mvm_state;
883 u32 cvs_state;
884 u32 cvp_state;
885
886 /* Handle to MVM in the Q6 */
887 u16 mvm_handle;
888 /* Handle to CVS in the Q6 */
889 u16 cvs_handle;
890 /* Handle to CVP in the Q6 */
891 u16 cvp_handle;
892
893 struct mutex lock;
894
895 uint16_t sidetone_gain;
896 uint8_t tty_mode;
897 /* widevoice enable value */
898 uint8_t wv_enable;
Helen Zengbb49c702011-09-06 14:09:13 -0700899 /* slowtalk enable value */
900 uint32_t st_enable;
Helen Zeng4e531942011-12-17 21:14:40 -0800901 /* FENC enable value */
902 uint32_t fens_enable;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700903
904 struct voice_dev_route_state voc_route_state;
905
906 u16 session_id;
Helen Zenge3d716a2011-10-14 16:32:16 -0700907
908 struct incall_rec_info rec_info;
909
Helen Zeng0705a5f2011-10-14 15:29:52 -0700910 struct incall_music_info music_info;
Helen Zenge3d716a2011-10-14 16:32:16 -0700911
912 struct voice_rec_route_state rec_route_state;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700913};
914
Helen Zeng6e64dba2012-03-08 18:30:11 -0800915struct cal_mem {
916 struct ion_handle *handle;
917 uint32_t phy;
918 void *buf;
919};
920
Satish Babu Patakokila75645ce2012-06-20 15:01:02 +0530921#define MAX_VOC_SESSIONS 4
Neema Shetty2c07eb52011-08-21 20:33:52 -0700922#define SESSION_ID_BASE 0xFFF0
923
924struct common_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700925 /* these default values are for all devices */
926 uint32_t default_mute_val;
927 uint32_t default_vol_val;
928 uint32_t default_sample_val;
929
930 /* APR to MVM in the Q6 */
931 void *apr_q6_mvm;
932 /* APR to CVS in the Q6 */
933 void *apr_q6_cvs;
934 /* APR to CVP in the Q6 */
935 void *apr_q6_cvp;
936
Helen Zeng6e64dba2012-03-08 18:30:11 -0800937 struct ion_client *client;
938 struct cal_mem cvp_cal;
939 struct cal_mem cvs_cal;
940
Neema Shetty2c07eb52011-08-21 20:33:52 -0700941 struct mutex common_lock;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700942
943 struct mvs_driver_info mvs_info;
944
Neema Shetty2c07eb52011-08-21 20:33:52 -0700945 struct voice_data voice[MAX_VOC_SESSIONS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700946};
947
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700948void voc_register_mvs_cb(ul_cb_fn ul_cb,
949 dl_cb_fn dl_cb,
950 void *private_data);
951
952void voc_config_vocoder(uint32_t media_type,
953 uint32_t rate,
Helen Zengff97bec2012-02-20 14:30:50 -0800954 uint32_t network_type,
955 uint32_t dtx_mode);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700956
957enum {
958 DEV_RX = 0,
959 DEV_TX,
960};
961
962enum {
963 RX_PATH = 0,
964 TX_PATH,
965};
966
967/* called by alsa driver */
Helen Zeng4e531942011-12-17 21:14:40 -0800968int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable);
969int voc_get_pp_enable(uint16_t session_id, uint32_t module_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700970int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable);
971uint32_t voc_get_widevoice_enable(uint16_t session_id);
972uint8_t voc_get_tty_mode(uint16_t session_id);
973int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode);
974int voc_start_voice_call(uint16_t session_id);
Venkat Sudhire65fa412012-05-15 01:42:31 -0700975int voc_standby_voice_call(uint16_t session_id);
976int voc_resume_voice_call(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700977int voc_end_voice_call(uint16_t session_id);
978int voc_set_rxtx_port(uint16_t session_id,
979 uint32_t dev_port_id,
980 uint32_t dev_type);
981int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t voc_idx);
982int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute);
Helen Zeng68656932011-11-02 18:08:23 -0700983int voc_set_rx_device_mute(uint16_t session_id, uint32_t mute);
984int voc_get_rx_device_mute(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700985int voc_disable_cvp(uint16_t session_id);
986int voc_enable_cvp(uint16_t session_id);
987int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set);
988uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir);
989
990#define VOICE_SESSION_NAME "Voice session"
991#define VOIP_SESSION_NAME "VoIP session"
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700992#define VOLTE_SESSION_NAME "VoLTE session"
Satish Babu Patakokila75645ce2012-06-20 15:01:02 +0530993#define SGLTE_SESSION_NAME "SGLTE session"
Neema Shetty2c07eb52011-08-21 20:33:52 -0700994uint16_t voc_get_session_id(char *name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700995
Helen Zeng0705a5f2011-10-14 15:29:52 -0700996int voc_start_playback(uint32_t set);
Helen Zenge3d716a2011-10-14 16:32:16 -0700997int voc_start_record(uint32_t port_id, uint32_t set);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700998#endif