blob: a90e1645d2f192d6cf6d2da102ad6f9a8a7b9e8b [file] [log] [blame]
Helen Zeng47ca0072013-03-06 10:37:52 -08001/* Copyright (c) 2011-2013, The Linux Foundation. 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
Venkat Sudhirf0228272013-03-04 10:32:59 -0800646#define VSS_IVOCPROC_CMD_SET_DEVICE_V2 0x000112C6
647
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700648#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB
649
650#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE
651
652#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6
653/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
654
655#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1
656/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
657
Helen Zeng29eb7442011-06-20 11:06:29 -0700658#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA 0x00011275
659#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276
660
661#define VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE 0x00011277
662#define VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE 0x00011278
663
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700664#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70
665#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71
666#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72
667
668#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77
669
670/* Newtwork IDs */
671#define VSS_NETWORK_ID_DEFAULT 0x00010037
672#define VSS_NETWORK_ID_VOIP_NB 0x00011240
673#define VSS_NETWORK_ID_VOIP_WB 0x00011241
674#define VSS_NETWORK_ID_VOIP_WV 0x00011242
675
676/* Media types */
677#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2
678/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */
679#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6
680/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */
681#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7
682/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */
683#define VSS_MEDIA_ID_PCM_NB 0x00010FCB
684#define VSS_MEDIA_ID_PCM_WB 0x00010FCC
685/* Linear PCM (16-bit, little-endian). */
686#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD
687/* G.711 a-law (contains two 10ms vocoder frames). */
688#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE
689/* G.711 mu-law (contains two 10ms vocoder frames). */
690#define VSS_MEDIA_ID_G729 0x00010FD0
691/* G.729AB (contains two 10ms vocoder frames. */
Laxminath Kasam481d4982012-04-04 20:54:30 +0530692#define VSS_MEDIA_ID_4GV_NB_MODEM 0x00010FC3
693/*CDMA EVRC-B vocoder modem format */
694#define VSS_MEDIA_ID_4GV_WB_MODEM 0x00010FC4
695/*CDMA EVRC-WB vocoder modem format */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700696
Helen Zeng68656932011-11-02 18:08:23 -0700697#define VSS_IVOCPROC_CMD_SET_MUTE 0x000110EF
698
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700699#define VOICE_CMD_SET_PARAM 0x00011006
700#define VOICE_CMD_GET_PARAM 0x00011007
701#define VOICE_EVT_GET_PARAM_ACK 0x00011008
702
Venkat Sudhirf0228272013-03-04 10:32:59 -0800703/* Default AFE port ID. Applicable to Tx and Rx. */
704#define VSS_IVOCPROC_PORT_ID_NONE 0xFFFF
705
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700706struct vss_ivocproc_cmd_create_full_control_session_t {
707 uint16_t direction;
708 /*
709 * stream direction.
710 * 0 : TX only
711 * 1 : RX only
712 * 2 : TX and RX
713 */
714 uint32_t tx_port_id;
715 /*
716 * TX device port ID which vocproc will connect to. If not supplying a
717 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
718 */
719 uint32_t tx_topology_id;
720 /*
721 * Tx leg topology ID. If not supplying a topology ID set to
722 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
723 */
724 uint32_t rx_port_id;
725 /*
726 * RX device port ID which vocproc will connect to. If not supplying a
727 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
728 */
729 uint32_t rx_topology_id;
730 /*
731 * Rx leg topology ID. If not supplying a topology ID set to
732 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
733 */
734 int32_t network_id;
735 /*
736 * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network
737 * ID set to VSS_NETWORK_ID_DEFAULT.
738 */
739} __packed;
740
741struct vss_ivocproc_cmd_set_volume_index_t {
742 uint16_t vol_index;
743 /**<
744 * Volume index utilized by the vocproc to index into the volume table
745 * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set
746 * volume on the VDSP.
747 */
748} __packed;
749
750struct vss_ivocproc_cmd_set_device_t {
751 uint32_t tx_port_id;
752 /**<
753 * TX device port ID which vocproc will connect to.
754 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
755 */
756 uint32_t tx_topology_id;
757 /**<
758 * TX leg topology ID.
759 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
760 * pre/post-processing blocks and is pass-through.
761 */
762 int32_t rx_port_id;
763 /**<
764 * RX device port ID which vocproc will connect to.
765 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
766 */
767 uint32_t rx_topology_id;
768 /**<
769 * RX leg topology ID.
770 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
771 * pre/post-processing blocks and is pass-through.
772 */
773} __packed;
774
Venkat Sudhirf0228272013-03-04 10:32:59 -0800775/* Internal EC */
776#define VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING 0x00010F7C
777
778/* External EC */
779#define VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING 0x00010F7D
780
781struct vss_ivocproc_cmd_set_device_v2_t {
782 uint16_t tx_port_id;
783 /* Tx device port ID to which the vocproc connects. */
784 uint32_t tx_topology_id;
785 /* Tx path topology ID. */
786 uint16_t rx_port_id;
787 /* Rx device port ID to which the vocproc connects. */
788 uint32_t rx_topology_id;
789 /* Rx path topology ID. */
790 uint32_t vocproc_mode;
791 /* Vocproc mode. The supported values:
792 * VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING - 0x00010F7C
793 * VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING - 0x00010F7D
794 */
795 uint16_t ec_ref_port_id;
796 /* Port ID to which the vocproc connects for receiving
797 * echo cancellation reference signal.
798 */
799} __packed;
800
Helen Zeng29eb7442011-06-20 11:06:29 -0700801struct vss_ivocproc_cmd_register_calibration_data_t {
802 uint32_t phys_addr;
803 /* Phsical address to be registered with vocproc. Calibration data
804 * is stored at this address.
805 */
806 uint32_t mem_size;
807 /* Size of the calibration data in bytes. */
808} __packed;
809
810struct vss_ivocproc_cmd_register_volume_cal_table_t {
811 uint32_t phys_addr;
812 /* Phsical address to be registered with the vocproc. The volume
813 * calibration table is stored at this location.
814 */
815
816 uint32_t mem_size;
817 /* Size of the volume calibration table in bytes. */
818} __packed;
819
Helen Zeng68656932011-11-02 18:08:23 -0700820struct vss_ivocproc_cmd_set_mute_t {
821 uint16_t direction;
822 /*
823 * 0 : TX only.
824 * 1 : RX only.
825 * 2 : TX and Rx.
826 */
827 uint16_t mute_flag;
828 /*
829 * Mute, un-mute.
830 *
831 * 0 : Disable.
832 * 1 : Enable.
833 */
834} __packed;
835
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700836struct cvp_create_full_ctl_session_cmd {
837 struct apr_hdr hdr;
838 struct vss_ivocproc_cmd_create_full_control_session_t cvp_session;
839} __packed;
840
841struct cvp_command {
842 struct apr_hdr hdr;
843} __packed;
844
845struct cvp_set_device_cmd {
846 struct apr_hdr hdr;
847 struct vss_ivocproc_cmd_set_device_t cvp_set_device;
848} __packed;
849
Venkat Sudhirf0228272013-03-04 10:32:59 -0800850struct cvp_set_device_cmd_v2 {
851 struct apr_hdr hdr;
852 struct vss_ivocproc_cmd_set_device_v2_t cvp_set_device_v2;
853} __packed;
854
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700855struct cvp_set_vp3_data_cmd {
856 struct apr_hdr hdr;
857} __packed;
858
859struct cvp_set_rx_volume_index_cmd {
860 struct apr_hdr hdr;
861 struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx;
862} __packed;
863
Helen Zeng29eb7442011-06-20 11:06:29 -0700864struct cvp_register_cal_data_cmd {
865 struct apr_hdr hdr;
866 struct vss_ivocproc_cmd_register_calibration_data_t cvp_cal_data;
867} __packed;
868
869struct cvp_deregister_cal_data_cmd {
870 struct apr_hdr hdr;
871} __packed;
872
873struct cvp_register_vol_cal_table_cmd {
874 struct apr_hdr hdr;
875 struct vss_ivocproc_cmd_register_volume_cal_table_t cvp_vol_cal_tbl;
876} __packed;
877
878struct cvp_deregister_vol_cal_table_cmd {
879 struct apr_hdr hdr;
880} __packed;
881
Helen Zeng68656932011-11-02 18:08:23 -0700882struct cvp_set_mute_cmd {
883 struct apr_hdr hdr;
884 struct vss_ivocproc_cmd_set_mute_t cvp_set_mute;
885} __packed;
886
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700887/* CB for up-link packets. */
888typedef void (*ul_cb_fn)(uint8_t *voc_pkt,
889 uint32_t pkt_len,
890 void *private_data);
891
892/* CB for down-link packets. */
893typedef void (*dl_cb_fn)(uint8_t *voc_pkt,
894 uint32_t *pkt_len,
895 void *private_data);
896
897
898struct mvs_driver_info {
899 uint32_t media_type;
900 uint32_t rate;
901 uint32_t network_type;
Helen Zengff97bec2012-02-20 14:30:50 -0800902 uint32_t dtx_mode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700903 ul_cb_fn ul_cb;
904 dl_cb_fn dl_cb;
905 void *private_data;
906};
907
908struct incall_rec_info {
Helen Zenge3d716a2011-10-14 16:32:16 -0700909 uint32_t rec_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700910 uint32_t rec_mode;
Helen Zenge3d716a2011-10-14 16:32:16 -0700911 uint32_t recording;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700912};
913
914struct incall_music_info {
Helen Zeng0705a5f2011-10-14 15:29:52 -0700915 uint32_t play_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700916 uint32_t playing;
Helen Zeng0705a5f2011-10-14 15:29:52 -0700917 int count;
918 int force;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700919};
920
921struct voice_data {
922 int voc_state;/*INIT, CHANGE, RELEASE, RUN */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700923
924 wait_queue_head_t mvm_wait;
925 wait_queue_head_t cvs_wait;
926 wait_queue_head_t cvp_wait;
927
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700928 /* cache the values related to Rx and Tx */
929 struct device_data dev_rx;
930 struct device_data dev_tx;
931
Neema Shetty2c07eb52011-08-21 20:33:52 -0700932 u32 mvm_state;
933 u32 cvs_state;
934 u32 cvp_state;
935
936 /* Handle to MVM in the Q6 */
937 u16 mvm_handle;
938 /* Handle to CVS in the Q6 */
939 u16 cvs_handle;
940 /* Handle to CVP in the Q6 */
941 u16 cvp_handle;
942
943 struct mutex lock;
944
945 uint16_t sidetone_gain;
946 uint8_t tty_mode;
947 /* widevoice enable value */
948 uint8_t wv_enable;
Helen Zengbb49c702011-09-06 14:09:13 -0700949 /* slowtalk enable value */
950 uint32_t st_enable;
Helen Zeng4e531942011-12-17 21:14:40 -0800951 /* FENC enable value */
952 uint32_t fens_enable;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700953
954 struct voice_dev_route_state voc_route_state;
955
956 u16 session_id;
Helen Zenge3d716a2011-10-14 16:32:16 -0700957
958 struct incall_rec_info rec_info;
959
Helen Zeng0705a5f2011-10-14 15:29:52 -0700960 struct incall_music_info music_info;
Helen Zenge3d716a2011-10-14 16:32:16 -0700961
962 struct voice_rec_route_state rec_route_state;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700963};
964
Helen Zeng6e64dba2012-03-08 18:30:11 -0800965struct cal_mem {
Ben Romberger047be782012-04-20 16:11:32 -0700966 /* Physical Address */
967 uint32_t paddr;
968 /* Kernel Virtual Address */
969 uint32_t kvaddr;
970};
971
972struct cal_data {
973 struct cal_mem cal_data[NUM_VOICE_CAL_TYPES];
Helen Zeng6e64dba2012-03-08 18:30:11 -0800974};
975
Satish Babu Patakokila75645ce2012-06-20 15:01:02 +0530976#define MAX_VOC_SESSIONS 4
Neema Shetty2c07eb52011-08-21 20:33:52 -0700977#define SESSION_ID_BASE 0xFFF0
978
979struct common_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700980 /* these default values are for all devices */
981 uint32_t default_mute_val;
982 uint32_t default_vol_val;
983 uint32_t default_sample_val;
Venkat Sudhirf0228272013-03-04 10:32:59 -0800984 bool ec_ref_ext;
985 uint16_t ec_port_id;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700986
987 /* APR to MVM in the Q6 */
988 void *apr_q6_mvm;
989 /* APR to CVS in the Q6 */
990 void *apr_q6_cvs;
991 /* APR to CVP in the Q6 */
992 void *apr_q6_cvp;
993
Ben Romberger047be782012-04-20 16:11:32 -0700994 struct ion_client *ion_client;
995 struct ion_handle *ion_handle;
996 struct cal_data voice_cal[NUM_VOICE_CAL_BUFFERS];
Helen Zeng6e64dba2012-03-08 18:30:11 -0800997
Neema Shetty2c07eb52011-08-21 20:33:52 -0700998 struct mutex common_lock;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700999
1000 struct mvs_driver_info mvs_info;
1001
Neema Shetty2c07eb52011-08-21 20:33:52 -07001002 struct voice_data voice[MAX_VOC_SESSIONS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001003};
1004
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001005void voc_register_mvs_cb(ul_cb_fn ul_cb,
1006 dl_cb_fn dl_cb,
1007 void *private_data);
1008
1009void voc_config_vocoder(uint32_t media_type,
1010 uint32_t rate,
Helen Zengff97bec2012-02-20 14:30:50 -08001011 uint32_t network_type,
1012 uint32_t dtx_mode);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001013
1014enum {
1015 DEV_RX = 0,
1016 DEV_TX,
1017};
1018
1019enum {
1020 RX_PATH = 0,
1021 TX_PATH,
1022};
1023
1024/* called by alsa driver */
Helen Zeng4e531942011-12-17 21:14:40 -08001025int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable);
1026int voc_get_pp_enable(uint16_t session_id, uint32_t module_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -07001027int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable);
1028uint32_t voc_get_widevoice_enable(uint16_t session_id);
1029uint8_t voc_get_tty_mode(uint16_t session_id);
1030int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode);
1031int voc_start_voice_call(uint16_t session_id);
Venkat Sudhire65fa412012-05-15 01:42:31 -07001032int voc_standby_voice_call(uint16_t session_id);
1033int voc_resume_voice_call(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -07001034int voc_end_voice_call(uint16_t session_id);
1035int voc_set_rxtx_port(uint16_t session_id,
1036 uint32_t dev_port_id,
1037 uint32_t dev_type);
1038int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t voc_idx);
1039int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute);
Helen Zeng68656932011-11-02 18:08:23 -07001040int voc_set_rx_device_mute(uint16_t session_id, uint32_t mute);
1041int voc_get_rx_device_mute(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -07001042int voc_disable_cvp(uint16_t session_id);
1043int voc_enable_cvp(uint16_t session_id);
1044int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set);
1045uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir);
1046
1047#define VOICE_SESSION_NAME "Voice session"
1048#define VOIP_SESSION_NAME "VoIP session"
Venkat Sudhir505bb4f2012-04-09 23:08:20 -07001049#define VOLTE_SESSION_NAME "VoLTE session"
Helen Zeng47ca0072013-03-06 10:37:52 -08001050#define VOICE2_SESSION_NAME "Voice2 session"
1051
1052#define VOC_PATH_PASSIVE 0
1053#define VOC_PATH_FULL 1
1054#define VOC_PATH_VOLTE_PASSIVE 2
1055#define VOC_PATH_VOICE2_PASSIVE 3
1056
Neema Shetty2c07eb52011-08-21 20:33:52 -07001057uint16_t voc_get_session_id(char *name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001058
Helen Zeng0705a5f2011-10-14 15:29:52 -07001059int voc_start_playback(uint32_t set);
Helen Zenge3d716a2011-10-14 16:32:16 -07001060int voc_start_record(uint32_t port_id, uint32_t set);
Venkat Sudhirf0228272013-03-04 10:32:59 -08001061int voc_set_ext_ec_ref(uint16_t port_id, bool state);
1062
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001063#endif