blob: 34b1b52c845eb911835fe4cd023b38f208c87dc1 [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>
Mitchel Humpherys76a84982012-09-06 10:22:31 -070016#include <linux/msm_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
Ben Romberger047be782012-04-20 16:11:32 -070025/* Needed for VOIP & VOLTE support */
26/* Due to Q6 memory map issue */
27enum {
28 VOIP_CAL,
29 VOLTE_CAL,
30 NUM_VOICE_CAL_BUFFERS
31};
32
33enum {
34 CVP_CAL,
35 CVS_CAL,
36 NUM_VOICE_CAL_TYPES
37};
38
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070039struct voice_header {
40 uint32_t id;
41 uint32_t data_len;
42};
43
44struct voice_init {
45 struct voice_header hdr;
46 void *cb_handle;
47};
48
49/* Device information payload structure */
50
51struct device_data {
52 uint32_t volume; /* in index */
53 uint32_t mute;
54 uint32_t sample;
55 uint32_t enabled;
56 uint32_t dev_id;
57 uint32_t port_id;
58};
59
60struct voice_dev_route_state {
61 u16 rx_route_flag;
62 u16 tx_route_flag;
63};
64
Helen Zenge3d716a2011-10-14 16:32:16 -070065struct voice_rec_route_state {
66 u16 ul_flag;
67 u16 dl_flag;
68};
69
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070enum {
71 VOC_INIT = 0,
72 VOC_RUN,
73 VOC_CHANGE,
74 VOC_RELEASE,
Venkat Sudhire65fa412012-05-15 01:42:31 -070075 VOC_STANDBY,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076};
77
Helen Zeng29eb7442011-06-20 11:06:29 -070078/* Common */
Helen Zengbb49c702011-09-06 14:09:13 -070079#define VSS_ICOMMON_CMD_SET_UI_PROPERTY 0x00011103
80/* Set a UI property */
Helen Zeng29eb7442011-06-20 11:06:29 -070081#define VSS_ICOMMON_CMD_MAP_MEMORY 0x00011025
82#define VSS_ICOMMON_CMD_UNMAP_MEMORY 0x00011026
83/* General shared memory; byte-accessible, 4 kB-aligned. */
84#define VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL 3
85
86struct vss_icommon_cmd_map_memory_t {
87 uint32_t phys_addr;
88 /* Physical address of a memory region; must be at least
89 * 4 kB aligned.
90 */
91
92 uint32_t mem_size;
93 /* Number of bytes in the region; should be a multiple of 32. */
94
95 uint16_t mem_pool_id;
96 /* Type of memory being provided. The memory ID implicitly defines
97 * the characteristics of the memory. The characteristics might include
98 * alignment type, permissions, etc.
99 * Memory pool ID. Possible values:
100 * 3 -- VSS_ICOMMON_MEM_TYPE_SHMEM8_4K_POOL.
101 */
102} __packed;
103
104struct vss_icommon_cmd_unmap_memory_t {
105 uint32_t phys_addr;
106 /* Physical address of a memory region; must be at least
107 * 4 kB aligned.
108 */
109} __packed;
110
111struct vss_map_memory_cmd {
112 struct apr_hdr hdr;
113 struct vss_icommon_cmd_map_memory_t vss_map_mem;
114} __packed;
115
116struct vss_unmap_memory_cmd {
117 struct apr_hdr hdr;
118 struct vss_icommon_cmd_unmap_memory_t vss_unmap_mem;
119} __packed;
120
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700121/* TO MVM commands */
122#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x000110FF
123/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
124
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700125#define VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL 0x00011327
126/*
127 * VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL
128 * Description: This command is required to let MVM know
129 * who is in control of session.
130 * Payload: Defined by vss_imvm_cmd_set_policy_dual_control_t.
131 * Result: Wait for APRV2_IBASIC_RSP_RESULT response.
132 */
133
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700134#define VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110FE
135/* Create a new full control MVM session. */
136
137#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
138/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
139
140#define VSS_IMVM_CMD_ATTACH_STREAM 0x0001123C
141/* Attach a stream to the MVM. */
142
143#define VSS_IMVM_CMD_DETACH_STREAM 0x0001123D
144/* Detach a stream from the MVM. */
145
Helen Zeng69b00962011-07-08 11:38:36 -0700146#define VSS_IMVM_CMD_ATTACH_VOCPROC 0x0001123E
147/* Attach a vocproc to the MVM. The MVM will symmetrically connect this vocproc
148 * to all the streams currently attached to it.
149 */
150
151#define VSS_IMVM_CMD_DETACH_VOCPROC 0x0001123F
152/* Detach a vocproc from the MVM. The MVM will symmetrically disconnect this
153 * vocproc from all the streams to which it is currently attached.
154*/
155
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156#define VSS_IMVM_CMD_START_VOICE 0x00011190
Venkat Sudhire65fa412012-05-15 01:42:31 -0700157/*
158 * Start Voice call command.
159 * Wait for APRV2_IBASIC_RSP_RESULT response.
160 * No pay load.
161 */
162
163#define VSS_IMVM_CMD_STANDBY_VOICE 0x00011191
164/* No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700165
166#define VSS_IMVM_CMD_STOP_VOICE 0x00011192
167/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
168
169#define VSS_ISTREAM_CMD_ATTACH_VOCPROC 0x000110F8
170/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
171
172#define VSS_ISTREAM_CMD_DETACH_VOCPROC 0x000110F9
173/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
174
175
176#define VSS_ISTREAM_CMD_SET_TTY_MODE 0x00011196
177/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
178
179#define VSS_ICOMMON_CMD_SET_NETWORK 0x0001119C
180/* Set the network type. */
181
182#define VSS_ICOMMON_CMD_SET_VOICE_TIMING 0x000111E0
183/* Set the voice timing parameters. */
184
Helen Zeng44d4d272011-08-10 14:49:20 -0700185#define VSS_IWIDEVOICE_CMD_SET_WIDEVOICE 0x00011243
186/* Enable/disable WideVoice */
187
Laxminath Kasam481d4982012-04-04 20:54:30 +0530188enum msm_audio_voc_rate {
189 VOC_0_RATE, /* Blank frame */
190 VOC_8_RATE, /* 1/8 rate */
191 VOC_4_RATE, /* 1/4 rate */
192 VOC_2_RATE, /* 1/2 rate */
193 VOC_1_RATE /* Full rate */
194};
195
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700196struct vss_istream_cmd_set_tty_mode_t {
197 uint32_t mode;
198 /**<
199 * TTY mode.
200 *
201 * 0 : TTY disabled
202 * 1 : HCO
203 * 2 : VCO
204 * 3 : FULL
205 */
206} __packed;
207
208struct vss_istream_cmd_attach_vocproc_t {
209 uint16_t handle;
210 /**< Handle of vocproc being attached. */
211} __packed;
212
213struct vss_istream_cmd_detach_vocproc_t {
214 uint16_t handle;
215 /**< Handle of vocproc being detached. */
216} __packed;
217
218struct vss_imvm_cmd_attach_stream_t {
219 uint16_t handle;
220 /* The stream handle to attach. */
221} __packed;
222
223struct vss_imvm_cmd_detach_stream_t {
224 uint16_t handle;
225 /* The stream handle to detach. */
226} __packed;
227
228struct vss_icommon_cmd_set_network_t {
229 uint32_t network_id;
230 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
231} __packed;
232
233struct vss_icommon_cmd_set_voice_timing_t {
234 uint16_t mode;
235 /*
236 * The vocoder frame synchronization mode.
237 *
238 * 0 : No frame sync.
239 * 1 : Hard VFR (20ms Vocoder Frame Reference interrupt).
240 */
241 uint16_t enc_offset;
242 /*
243 * The offset in microseconds from the VFR to deliver a Tx vocoder
244 * packet. The offset should be less than 20000us.
245 */
246 uint16_t dec_req_offset;
247 /*
248 * The offset in microseconds from the VFR to request for an Rx vocoder
249 * packet. The offset should be less than 20000us.
250 */
251 uint16_t dec_offset;
252 /*
253 * The offset in microseconds from the VFR to indicate the deadline to
254 * receive an Rx vocoder packet. The offset should be less than 20000us.
255 * Rx vocoder packets received after this deadline are not guaranteed to
256 * be processed.
257 */
258} __packed;
259
Helen Zeng69b00962011-07-08 11:38:36 -0700260struct vss_imvm_cmd_create_control_session_t {
261 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700262 /*
263 * A variable-sized stream name.
264 *
265 * The stream name size is the payload size minus the size of the other
266 * fields.
267 */
268} __packed;
269
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700270
271struct vss_imvm_cmd_set_policy_dual_control_t {
272 bool enable_flag;
273 /* Set to TRUE to enable modem state machine control */
274} __packed;
275
Helen Zeng44d4d272011-08-10 14:49:20 -0700276struct vss_iwidevoice_cmd_set_widevoice_t {
277 uint32_t enable;
278 /* WideVoice enable/disable; possible values:
279 * - 0 -- WideVoice disabled
280 * - 1 -- WideVoice enabled
281 */
282} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283
284struct mvm_attach_vocproc_cmd {
285 struct apr_hdr hdr;
286 struct vss_istream_cmd_attach_vocproc_t mvm_attach_cvp_handle;
287} __packed;
288
289struct mvm_detach_vocproc_cmd {
290 struct apr_hdr hdr;
291 struct vss_istream_cmd_detach_vocproc_t mvm_detach_cvp_handle;
292} __packed;
293
Helen Zeng69b00962011-07-08 11:38:36 -0700294struct mvm_create_ctl_session_cmd {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700295 struct apr_hdr hdr;
Helen Zeng69b00962011-07-08 11:38:36 -0700296 struct vss_imvm_cmd_create_control_session_t mvm_session;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700297} __packed;
298
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700299struct mvm_modem_dual_control_session_cmd {
300 struct apr_hdr hdr;
301 struct vss_imvm_cmd_set_policy_dual_control_t voice_ctl;
302} __packed;
303
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700304struct mvm_set_tty_mode_cmd {
305 struct apr_hdr hdr;
306 struct vss_istream_cmd_set_tty_mode_t tty_mode;
307} __packed;
308
309struct mvm_attach_stream_cmd {
310 struct apr_hdr hdr;
311 struct vss_imvm_cmd_attach_stream_t attach_stream;
312} __packed;
313
314struct mvm_detach_stream_cmd {
315 struct apr_hdr hdr;
316 struct vss_imvm_cmd_detach_stream_t detach_stream;
317} __packed;
318
319struct mvm_set_network_cmd {
320 struct apr_hdr hdr;
321 struct vss_icommon_cmd_set_network_t network;
322} __packed;
323
324struct mvm_set_voice_timing_cmd {
325 struct apr_hdr hdr;
326 struct vss_icommon_cmd_set_voice_timing_t timing;
327} __packed;
328
Helen Zeng44d4d272011-08-10 14:49:20 -0700329struct mvm_set_widevoice_enable_cmd {
330 struct apr_hdr hdr;
331 struct vss_iwidevoice_cmd_set_widevoice_t vss_set_wv;
332} __packed;
333
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700334/* TO CVS commands */
335#define VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x00011140
336/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
337
338#define VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110F7
339/* Create a new full control stream session. */
340
341#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
342
343#define VSS_ISTREAM_CMD_SET_MUTE 0x00011022
344
Helen Zeng29eb7442011-06-20 11:06:29 -0700345#define VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA 0x00011279
346
347#define VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA 0x0001127A
348
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700349#define VSS_ISTREAM_CMD_SET_MEDIA_TYPE 0x00011186
350/* Set media type on the stream. */
351
352#define VSS_ISTREAM_EVT_SEND_ENC_BUFFER 0x00011015
353/* Event sent by the stream to its client to provide an encoded packet. */
354
355#define VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER 0x00011017
356/* Event sent by the stream to its client requesting for a decoder packet.
357 * The client should respond with a VSS_ISTREAM_EVT_SEND_DEC_BUFFER event.
358 */
359
360#define VSS_ISTREAM_EVT_SEND_DEC_BUFFER 0x00011016
361/* Event sent by the client to the stream in response to a
362 * VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER event, providing a decoder packet.
363 */
364
365#define VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE 0x0001113E
366/* Set AMR encoder rate. */
367
368#define VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE 0x0001113F
369/* Set AMR-WB encoder rate. */
370
371#define VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE 0x00011019
372/* Set encoder minimum and maximum rate. */
373
374#define VSS_ISTREAM_CMD_SET_ENC_DTX_MODE 0x0001101D
375/* Set encoder DTX mode. */
376
Helen Zeng4e531942011-12-17 21:14:40 -0800377#define MODULE_ID_VOICE_MODULE_FENS 0x00010EEB
Helen Zengbb49c702011-09-06 14:09:13 -0700378#define MODULE_ID_VOICE_MODULE_ST 0x00010EE3
379#define VOICE_PARAM_MOD_ENABLE 0x00010E00
380#define MOD_ENABLE_PARAM_LEN 4
381
Helen Zeng0705a5f2011-10-14 15:29:52 -0700382#define VSS_ISTREAM_CMD_START_PLAYBACK 0x00011238
383/* Start in-call music delivery on the Tx voice path. */
384
385#define VSS_ISTREAM_CMD_STOP_PLAYBACK 0x00011239
386/* Stop the in-call music delivery on the Tx voice path. */
387
Helen Zenge3d716a2011-10-14 16:32:16 -0700388#define VSS_ISTREAM_CMD_START_RECORD 0x00011236
389/* Start in-call conversation recording. */
390#define VSS_ISTREAM_CMD_STOP_RECORD 0x00011237
391/* Stop in-call conversation recording. */
392
393#define VSS_TAP_POINT_NONE 0x00010F78
394/* Indicates no tapping for specified path. */
395
396#define VSS_TAP_POINT_STREAM_END 0x00010F79
397/* Indicates that specified path should be tapped at the end of the stream. */
398
399struct vss_istream_cmd_start_record_t {
400 uint32_t rx_tap_point;
401 /* Tap point to use on the Rx path. Supported values are:
402 * VSS_TAP_POINT_NONE : Do not record Rx path.
403 * VSS_TAP_POINT_STREAM_END : Rx tap point is at the end of the stream.
404 */
405 uint32_t tx_tap_point;
406 /* Tap point to use on the Tx path. Supported values are:
407 * VSS_TAP_POINT_NONE : Do not record tx path.
408 * VSS_TAP_POINT_STREAM_END : Tx tap point is at the end of the stream.
409 */
410} __packed;
411
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700412struct vss_istream_cmd_create_passive_control_session_t {
Helen Zeng69b00962011-07-08 11:38:36 -0700413 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700414 /**<
415 * A variable-sized stream name.
416 *
417 * The stream name size is the payload size minus the size of the other
418 * fields.
419 */
420} __packed;
421
422struct vss_istream_cmd_set_mute_t {
423 uint16_t direction;
424 /**<
425 * 0 : TX only
426 * 1 : RX only
427 * 2 : TX and Rx
428 */
429 uint16_t mute_flag;
430 /**<
431 * Mute, un-mute.
432 *
433 * 0 : Silence disable
434 * 1 : Silence enable
435 * 2 : CNG enable. Applicable to TX only. If set on RX behavior
436 * will be the same as 1
437 */
438} __packed;
439
440struct vss_istream_cmd_create_full_control_session_t {
441 uint16_t direction;
442 /*
443 * Stream direction.
444 *
445 * 0 : TX only
446 * 1 : RX only
447 * 2 : TX and RX
448 * 3 : TX and RX loopback
449 */
450 uint32_t enc_media_type;
451 /* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
452 uint32_t dec_media_type;
453 /* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
454 uint32_t network_id;
455 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
Helen Zeng69b00962011-07-08 11:38:36 -0700456 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700457 /*
458 * A variable-sized stream name.
459 *
460 * The stream name size is the payload size minus the size of the other
461 * fields.
462 */
463} __packed;
464
465struct vss_istream_cmd_set_media_type_t {
466 uint32_t rx_media_id;
467 /* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
468 uint32_t tx_media_id;
469 /* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
470} __packed;
471
472struct vss_istream_evt_send_enc_buffer_t {
473 uint32_t media_id;
474 /* Media ID of the packet. */
475 uint8_t packet_data[MAX_VOC_PKT_SIZE];
476 /* Packet data buffer. */
477} __packed;
478
479struct vss_istream_evt_send_dec_buffer_t {
480 uint32_t media_id;
481 /* Media ID of the packet. */
482 uint8_t packet_data[MAX_VOC_PKT_SIZE];
483 /* Packet data. */
484} __packed;
485
486struct vss_istream_cmd_voc_amr_set_enc_rate_t {
487 uint32_t mode;
488 /* Set the AMR encoder rate.
489 *
490 * 0x00000000 : 4.75 kbps
491 * 0x00000001 : 5.15 kbps
492 * 0x00000002 : 5.90 kbps
493 * 0x00000003 : 6.70 kbps
494 * 0x00000004 : 7.40 kbps
495 * 0x00000005 : 7.95 kbps
496 * 0x00000006 : 10.2 kbps
497 * 0x00000007 : 12.2 kbps
498 */
499} __packed;
500
501struct vss_istream_cmd_voc_amrwb_set_enc_rate_t {
502 uint32_t mode;
503 /* Set the AMR-WB encoder rate.
504 *
505 * 0x00000000 : 6.60 kbps
506 * 0x00000001 : 8.85 kbps
507 * 0x00000002 : 12.65 kbps
508 * 0x00000003 : 14.25 kbps
509 * 0x00000004 : 15.85 kbps
510 * 0x00000005 : 18.25 kbps
511 * 0x00000006 : 19.85 kbps
512 * 0x00000007 : 23.05 kbps
513 * 0x00000008 : 23.85 kbps
514 */
515} __packed;
516
517struct vss_istream_cmd_cdma_set_enc_minmax_rate_t {
518 uint16_t min_rate;
519 /* Set the lower bound encoder rate.
520 *
521 * 0x0000 : Blank frame
522 * 0x0001 : Eighth rate
523 * 0x0002 : Quarter rate
524 * 0x0003 : Half rate
525 * 0x0004 : Full rate
526 */
527 uint16_t max_rate;
528 /* Set the upper bound encoder rate.
529 *
530 * 0x0000 : Blank frame
531 * 0x0001 : Eighth rate
532 * 0x0002 : Quarter rate
533 * 0x0003 : Half rate
534 * 0x0004 : Full rate
535 */
536} __packed;
537
538struct vss_istream_cmd_set_enc_dtx_mode_t {
539 uint32_t enable;
540 /* Toggle DTX on or off.
541 *
542 * 0 : Disables DTX
543 * 1 : Enables DTX
544 */
545} __packed;
546
Helen Zeng29eb7442011-06-20 11:06:29 -0700547struct vss_istream_cmd_register_calibration_data_t {
548 uint32_t phys_addr;
549 /* Phsical address to be registered with stream. The calibration data
550 * is stored at this address.
551 */
552 uint32_t mem_size;
553 /* Size of the calibration data in bytes. */
554};
555
Helen Zeng4e531942011-12-17 21:14:40 -0800556struct vss_icommon_cmd_set_ui_property_enable_t {
Helen Zengbb49c702011-09-06 14:09:13 -0700557 uint32_t module_id;
558 /* Unique ID of the module. */
559 uint32_t param_id;
560 /* Unique ID of the parameter. */
561 uint16_t param_size;
562 /* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */
563 uint16_t reserved;
564 /* Reserved; set to 0. */
565 uint16_t enable;
566 uint16_t reserved_field;
567 /* Reserved, set to 0. */
568};
569
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700570struct cvs_create_passive_ctl_session_cmd {
571 struct apr_hdr hdr;
572 struct vss_istream_cmd_create_passive_control_session_t cvs_session;
573} __packed;
574
575struct cvs_create_full_ctl_session_cmd {
576 struct apr_hdr hdr;
577 struct vss_istream_cmd_create_full_control_session_t cvs_session;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700578} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700579
580struct cvs_destroy_session_cmd {
581 struct apr_hdr hdr;
582} __packed;
583
584struct cvs_set_mute_cmd {
585 struct apr_hdr hdr;
586 struct vss_istream_cmd_set_mute_t cvs_set_mute;
587} __packed;
588
589struct cvs_set_media_type_cmd {
590 struct apr_hdr hdr;
591 struct vss_istream_cmd_set_media_type_t media_type;
592} __packed;
593
594struct cvs_send_dec_buf_cmd {
595 struct apr_hdr hdr;
596 struct vss_istream_evt_send_dec_buffer_t dec_buf;
597} __packed;
598
599struct cvs_set_amr_enc_rate_cmd {
600 struct apr_hdr hdr;
601 struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate;
602} __packed;
603
604struct cvs_set_amrwb_enc_rate_cmd {
605 struct apr_hdr hdr;
606 struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate;
607} __packed;
608
609struct cvs_set_cdma_enc_minmax_rate_cmd {
610 struct apr_hdr hdr;
611 struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate;
612} __packed;
613
614struct cvs_set_enc_dtx_mode_cmd {
615 struct apr_hdr hdr;
616 struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode;
617} __packed;
618
Helen Zeng29eb7442011-06-20 11:06:29 -0700619struct cvs_register_cal_data_cmd {
620 struct apr_hdr hdr;
621 struct vss_istream_cmd_register_calibration_data_t cvs_cal_data;
622} __packed;
623
624struct cvs_deregister_cal_data_cmd {
625 struct apr_hdr hdr;
626} __packed;
627
Helen Zeng4e531942011-12-17 21:14:40 -0800628struct cvs_set_pp_enable_cmd {
Helen Zengbb49c702011-09-06 14:09:13 -0700629 struct apr_hdr hdr;
Helen Zeng4e531942011-12-17 21:14:40 -0800630 struct vss_icommon_cmd_set_ui_property_enable_t vss_set_pp;
Helen Zengbb49c702011-09-06 14:09:13 -0700631} __packed;
Helen Zenge3d716a2011-10-14 16:32:16 -0700632struct cvs_start_record_cmd {
633 struct apr_hdr hdr;
634 struct vss_istream_cmd_start_record_t rec_mode;
635} __packed;
Helen Zengbb49c702011-09-06 14:09:13 -0700636
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700637/* TO CVP commands */
638
639#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION 0x000100C3
640/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
641
642#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
643
644#define VSS_IVOCPROC_CMD_SET_DEVICE 0x000100C4
645
646#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB
647
648#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE
649
650#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6
651/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
652
653#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1
654/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
655
Helen Zeng29eb7442011-06-20 11:06:29 -0700656#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA 0x00011275
657#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276
658
659#define VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE 0x00011277
660#define VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE 0x00011278
661
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700662#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70
663#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71
664#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72
665
666#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77
667
668/* Newtwork IDs */
669#define VSS_NETWORK_ID_DEFAULT 0x00010037
670#define VSS_NETWORK_ID_VOIP_NB 0x00011240
671#define VSS_NETWORK_ID_VOIP_WB 0x00011241
672#define VSS_NETWORK_ID_VOIP_WV 0x00011242
673
674/* Media types */
675#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2
676/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */
677#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6
678/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */
679#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7
680/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */
681#define VSS_MEDIA_ID_PCM_NB 0x00010FCB
682#define VSS_MEDIA_ID_PCM_WB 0x00010FCC
683/* Linear PCM (16-bit, little-endian). */
684#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD
685/* G.711 a-law (contains two 10ms vocoder frames). */
686#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE
687/* G.711 mu-law (contains two 10ms vocoder frames). */
688#define VSS_MEDIA_ID_G729 0x00010FD0
689/* G.729AB (contains two 10ms vocoder frames. */
Laxminath Kasam481d4982012-04-04 20:54:30 +0530690#define VSS_MEDIA_ID_4GV_NB_MODEM 0x00010FC3
691/*CDMA EVRC-B vocoder modem format */
692#define VSS_MEDIA_ID_4GV_WB_MODEM 0x00010FC4
693/*CDMA EVRC-WB vocoder modem format */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700694
Helen Zeng68656932011-11-02 18:08:23 -0700695#define VSS_IVOCPROC_CMD_SET_MUTE 0x000110EF
696
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700697#define VOICE_CMD_SET_PARAM 0x00011006
698#define VOICE_CMD_GET_PARAM 0x00011007
699#define VOICE_EVT_GET_PARAM_ACK 0x00011008
700
701struct vss_ivocproc_cmd_create_full_control_session_t {
702 uint16_t direction;
703 /*
704 * stream direction.
705 * 0 : TX only
706 * 1 : RX only
707 * 2 : TX and RX
708 */
709 uint32_t tx_port_id;
710 /*
711 * TX device port ID which vocproc will connect to. If not supplying a
712 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
713 */
714 uint32_t tx_topology_id;
715 /*
716 * Tx leg topology ID. If not supplying a topology ID set to
717 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
718 */
719 uint32_t rx_port_id;
720 /*
721 * RX device port ID which vocproc will connect to. If not supplying a
722 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
723 */
724 uint32_t rx_topology_id;
725 /*
726 * Rx leg topology ID. If not supplying a topology ID set to
727 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
728 */
729 int32_t network_id;
730 /*
731 * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network
732 * ID set to VSS_NETWORK_ID_DEFAULT.
733 */
734} __packed;
735
736struct vss_ivocproc_cmd_set_volume_index_t {
737 uint16_t vol_index;
738 /**<
739 * Volume index utilized by the vocproc to index into the volume table
740 * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set
741 * volume on the VDSP.
742 */
743} __packed;
744
745struct vss_ivocproc_cmd_set_device_t {
746 uint32_t tx_port_id;
747 /**<
748 * TX device port ID which vocproc will connect to.
749 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
750 */
751 uint32_t tx_topology_id;
752 /**<
753 * TX leg topology ID.
754 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
755 * pre/post-processing blocks and is pass-through.
756 */
757 int32_t rx_port_id;
758 /**<
759 * RX device port ID which vocproc will connect to.
760 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
761 */
762 uint32_t rx_topology_id;
763 /**<
764 * RX leg topology ID.
765 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
766 * pre/post-processing blocks and is pass-through.
767 */
768} __packed;
769
Helen Zeng29eb7442011-06-20 11:06:29 -0700770struct vss_ivocproc_cmd_register_calibration_data_t {
771 uint32_t phys_addr;
772 /* Phsical address to be registered with vocproc. Calibration data
773 * is stored at this address.
774 */
775 uint32_t mem_size;
776 /* Size of the calibration data in bytes. */
777} __packed;
778
779struct vss_ivocproc_cmd_register_volume_cal_table_t {
780 uint32_t phys_addr;
781 /* Phsical address to be registered with the vocproc. The volume
782 * calibration table is stored at this location.
783 */
784
785 uint32_t mem_size;
786 /* Size of the volume calibration table in bytes. */
787} __packed;
788
Helen Zeng68656932011-11-02 18:08:23 -0700789struct vss_ivocproc_cmd_set_mute_t {
790 uint16_t direction;
791 /*
792 * 0 : TX only.
793 * 1 : RX only.
794 * 2 : TX and Rx.
795 */
796 uint16_t mute_flag;
797 /*
798 * Mute, un-mute.
799 *
800 * 0 : Disable.
801 * 1 : Enable.
802 */
803} __packed;
804
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700805struct cvp_create_full_ctl_session_cmd {
806 struct apr_hdr hdr;
807 struct vss_ivocproc_cmd_create_full_control_session_t cvp_session;
808} __packed;
809
810struct cvp_command {
811 struct apr_hdr hdr;
812} __packed;
813
814struct cvp_set_device_cmd {
815 struct apr_hdr hdr;
816 struct vss_ivocproc_cmd_set_device_t cvp_set_device;
817} __packed;
818
819struct cvp_set_vp3_data_cmd {
820 struct apr_hdr hdr;
821} __packed;
822
823struct cvp_set_rx_volume_index_cmd {
824 struct apr_hdr hdr;
825 struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx;
826} __packed;
827
Helen Zeng29eb7442011-06-20 11:06:29 -0700828struct cvp_register_cal_data_cmd {
829 struct apr_hdr hdr;
830 struct vss_ivocproc_cmd_register_calibration_data_t cvp_cal_data;
831} __packed;
832
833struct cvp_deregister_cal_data_cmd {
834 struct apr_hdr hdr;
835} __packed;
836
837struct cvp_register_vol_cal_table_cmd {
838 struct apr_hdr hdr;
839 struct vss_ivocproc_cmd_register_volume_cal_table_t cvp_vol_cal_tbl;
840} __packed;
841
842struct cvp_deregister_vol_cal_table_cmd {
843 struct apr_hdr hdr;
844} __packed;
845
Helen Zeng68656932011-11-02 18:08:23 -0700846struct cvp_set_mute_cmd {
847 struct apr_hdr hdr;
848 struct vss_ivocproc_cmd_set_mute_t cvp_set_mute;
849} __packed;
850
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700851/* CB for up-link packets. */
852typedef void (*ul_cb_fn)(uint8_t *voc_pkt,
853 uint32_t pkt_len,
854 void *private_data);
855
856/* CB for down-link packets. */
857typedef void (*dl_cb_fn)(uint8_t *voc_pkt,
858 uint32_t *pkt_len,
859 void *private_data);
860
861
862struct mvs_driver_info {
863 uint32_t media_type;
864 uint32_t rate;
865 uint32_t network_type;
Helen Zengff97bec2012-02-20 14:30:50 -0800866 uint32_t dtx_mode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700867 ul_cb_fn ul_cb;
868 dl_cb_fn dl_cb;
869 void *private_data;
870};
871
872struct incall_rec_info {
Helen Zenge3d716a2011-10-14 16:32:16 -0700873 uint32_t rec_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700874 uint32_t rec_mode;
Helen Zenge3d716a2011-10-14 16:32:16 -0700875 uint32_t recording;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700876};
877
878struct incall_music_info {
Helen Zeng0705a5f2011-10-14 15:29:52 -0700879 uint32_t play_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700880 uint32_t playing;
Helen Zeng0705a5f2011-10-14 15:29:52 -0700881 int count;
882 int force;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700883};
884
885struct voice_data {
886 int voc_state;/*INIT, CHANGE, RELEASE, RUN */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700887
888 wait_queue_head_t mvm_wait;
889 wait_queue_head_t cvs_wait;
890 wait_queue_head_t cvp_wait;
891
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700892 /* cache the values related to Rx and Tx */
893 struct device_data dev_rx;
894 struct device_data dev_tx;
895
Neema Shetty2c07eb52011-08-21 20:33:52 -0700896 u32 mvm_state;
897 u32 cvs_state;
898 u32 cvp_state;
899
900 /* Handle to MVM in the Q6 */
901 u16 mvm_handle;
902 /* Handle to CVS in the Q6 */
903 u16 cvs_handle;
904 /* Handle to CVP in the Q6 */
905 u16 cvp_handle;
906
907 struct mutex lock;
908
909 uint16_t sidetone_gain;
910 uint8_t tty_mode;
911 /* widevoice enable value */
912 uint8_t wv_enable;
Helen Zengbb49c702011-09-06 14:09:13 -0700913 /* slowtalk enable value */
914 uint32_t st_enable;
Helen Zeng4e531942011-12-17 21:14:40 -0800915 /* FENC enable value */
916 uint32_t fens_enable;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700917
918 struct voice_dev_route_state voc_route_state;
919
920 u16 session_id;
Helen Zenge3d716a2011-10-14 16:32:16 -0700921
922 struct incall_rec_info rec_info;
923
Helen Zeng0705a5f2011-10-14 15:29:52 -0700924 struct incall_music_info music_info;
Helen Zenge3d716a2011-10-14 16:32:16 -0700925
926 struct voice_rec_route_state rec_route_state;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700927};
928
Helen Zeng6e64dba2012-03-08 18:30:11 -0800929struct cal_mem {
Ben Romberger047be782012-04-20 16:11:32 -0700930 /* Physical Address */
931 uint32_t paddr;
932 /* Kernel Virtual Address */
933 uint32_t kvaddr;
934};
935
936struct cal_data {
937 struct cal_mem cal_data[NUM_VOICE_CAL_TYPES];
Helen Zeng6e64dba2012-03-08 18:30:11 -0800938};
939
Satish Babu Patakokila75645ce2012-06-20 15:01:02 +0530940#define MAX_VOC_SESSIONS 4
Neema Shetty2c07eb52011-08-21 20:33:52 -0700941#define SESSION_ID_BASE 0xFFF0
942
943struct common_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700944 /* these default values are for all devices */
945 uint32_t default_mute_val;
946 uint32_t default_vol_val;
947 uint32_t default_sample_val;
948
949 /* APR to MVM in the Q6 */
950 void *apr_q6_mvm;
951 /* APR to CVS in the Q6 */
952 void *apr_q6_cvs;
953 /* APR to CVP in the Q6 */
954 void *apr_q6_cvp;
955
Ben Romberger047be782012-04-20 16:11:32 -0700956 struct ion_client *ion_client;
957 struct ion_handle *ion_handle;
958 struct cal_data voice_cal[NUM_VOICE_CAL_BUFFERS];
Helen Zeng6e64dba2012-03-08 18:30:11 -0800959
Neema Shetty2c07eb52011-08-21 20:33:52 -0700960 struct mutex common_lock;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700961
962 struct mvs_driver_info mvs_info;
963
Neema Shetty2c07eb52011-08-21 20:33:52 -0700964 struct voice_data voice[MAX_VOC_SESSIONS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700965};
966
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700967void voc_register_mvs_cb(ul_cb_fn ul_cb,
968 dl_cb_fn dl_cb,
969 void *private_data);
970
971void voc_config_vocoder(uint32_t media_type,
972 uint32_t rate,
Helen Zengff97bec2012-02-20 14:30:50 -0800973 uint32_t network_type,
974 uint32_t dtx_mode);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700975
976enum {
977 DEV_RX = 0,
978 DEV_TX,
979};
980
981enum {
982 RX_PATH = 0,
983 TX_PATH,
984};
985
986/* called by alsa driver */
Helen Zeng4e531942011-12-17 21:14:40 -0800987int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable);
988int voc_get_pp_enable(uint16_t session_id, uint32_t module_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700989int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable);
990uint32_t voc_get_widevoice_enable(uint16_t session_id);
991uint8_t voc_get_tty_mode(uint16_t session_id);
992int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode);
993int voc_start_voice_call(uint16_t session_id);
Venkat Sudhire65fa412012-05-15 01:42:31 -0700994int voc_standby_voice_call(uint16_t session_id);
995int voc_resume_voice_call(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700996int voc_end_voice_call(uint16_t session_id);
997int voc_set_rxtx_port(uint16_t session_id,
998 uint32_t dev_port_id,
999 uint32_t dev_type);
1000int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t voc_idx);
1001int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute);
Helen Zeng68656932011-11-02 18:08:23 -07001002int voc_set_rx_device_mute(uint16_t session_id, uint32_t mute);
1003int voc_get_rx_device_mute(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -07001004int voc_disable_cvp(uint16_t session_id);
1005int voc_enable_cvp(uint16_t session_id);
1006int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set);
1007uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir);
1008
1009#define VOICE_SESSION_NAME "Voice session"
1010#define VOIP_SESSION_NAME "VoIP session"
Venkat Sudhir505bb4f2012-04-09 23:08:20 -07001011#define VOLTE_SESSION_NAME "VoLTE session"
Satish Babu Patakokila75645ce2012-06-20 15:01:02 +05301012#define SGLTE_SESSION_NAME "SGLTE session"
Neema Shetty2c07eb52011-08-21 20:33:52 -07001013uint16_t voc_get_session_id(char *name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001014
Helen Zeng0705a5f2011-10-14 15:29:52 -07001015int voc_start_playback(uint32_t set);
Helen Zenge3d716a2011-10-14 16:32:16 -07001016int voc_start_record(uint32_t port_id, uint32_t set);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001017#endif