blob: 3310abd26c010eeecfb3229b2d7fb0de548c4126 [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
Helen Zeng69b00962011-07-08 11:38:36 -070019#define SESSION_NAME_LEN 20
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,
61};
62
Helen Zeng29eb7442011-06-20 11:06:29 -070063/* Common */
Helen Zengbb49c702011-09-06 14:09:13 -070064#define VSS_ICOMMON_CMD_SET_UI_PROPERTY 0x00011103
65/* Set a UI property */
Helen Zeng29eb7442011-06-20 11:06:29 -070066#define VSS_ICOMMON_CMD_MAP_MEMORY 0x00011025
67#define VSS_ICOMMON_CMD_UNMAP_MEMORY 0x00011026
68/* General shared memory; byte-accessible, 4 kB-aligned. */
69#define VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL 3
70
71struct vss_icommon_cmd_map_memory_t {
72 uint32_t phys_addr;
73 /* Physical address of a memory region; must be at least
74 * 4 kB aligned.
75 */
76
77 uint32_t mem_size;
78 /* Number of bytes in the region; should be a multiple of 32. */
79
80 uint16_t mem_pool_id;
81 /* Type of memory being provided. The memory ID implicitly defines
82 * the characteristics of the memory. The characteristics might include
83 * alignment type, permissions, etc.
84 * Memory pool ID. Possible values:
85 * 3 -- VSS_ICOMMON_MEM_TYPE_SHMEM8_4K_POOL.
86 */
87} __packed;
88
89struct vss_icommon_cmd_unmap_memory_t {
90 uint32_t phys_addr;
91 /* Physical address of a memory region; must be at least
92 * 4 kB aligned.
93 */
94} __packed;
95
96struct vss_map_memory_cmd {
97 struct apr_hdr hdr;
98 struct vss_icommon_cmd_map_memory_t vss_map_mem;
99} __packed;
100
101struct vss_unmap_memory_cmd {
102 struct apr_hdr hdr;
103 struct vss_icommon_cmd_unmap_memory_t vss_unmap_mem;
104} __packed;
105
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700106/* TO MVM commands */
107#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x000110FF
108/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
109
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700110#define VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL 0x00011327
111/*
112 * VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL
113 * Description: This command is required to let MVM know
114 * who is in control of session.
115 * Payload: Defined by vss_imvm_cmd_set_policy_dual_control_t.
116 * Result: Wait for APRV2_IBASIC_RSP_RESULT response.
117 */
118
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700119#define VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110FE
120/* Create a new full control MVM session. */
121
122#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
123/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
124
125#define VSS_IMVM_CMD_ATTACH_STREAM 0x0001123C
126/* Attach a stream to the MVM. */
127
128#define VSS_IMVM_CMD_DETACH_STREAM 0x0001123D
129/* Detach a stream from the MVM. */
130
Helen Zeng69b00962011-07-08 11:38:36 -0700131#define VSS_IMVM_CMD_ATTACH_VOCPROC 0x0001123E
132/* Attach a vocproc to the MVM. The MVM will symmetrically connect this vocproc
133 * to all the streams currently attached to it.
134 */
135
136#define VSS_IMVM_CMD_DETACH_VOCPROC 0x0001123F
137/* Detach a vocproc from the MVM. The MVM will symmetrically disconnect this
138 * vocproc from all the streams to which it is currently attached.
139*/
140
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700141#define VSS_IMVM_CMD_START_VOICE 0x00011190
142/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
143
144#define VSS_IMVM_CMD_STOP_VOICE 0x00011192
145/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
146
147#define VSS_ISTREAM_CMD_ATTACH_VOCPROC 0x000110F8
148/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
149
150#define VSS_ISTREAM_CMD_DETACH_VOCPROC 0x000110F9
151/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
152
153
154#define VSS_ISTREAM_CMD_SET_TTY_MODE 0x00011196
155/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
156
157#define VSS_ICOMMON_CMD_SET_NETWORK 0x0001119C
158/* Set the network type. */
159
160#define VSS_ICOMMON_CMD_SET_VOICE_TIMING 0x000111E0
161/* Set the voice timing parameters. */
162
Helen Zeng44d4d272011-08-10 14:49:20 -0700163#define VSS_IWIDEVOICE_CMD_SET_WIDEVOICE 0x00011243
164/* Enable/disable WideVoice */
165
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700166struct vss_istream_cmd_set_tty_mode_t {
167 uint32_t mode;
168 /**<
169 * TTY mode.
170 *
171 * 0 : TTY disabled
172 * 1 : HCO
173 * 2 : VCO
174 * 3 : FULL
175 */
176} __packed;
177
178struct vss_istream_cmd_attach_vocproc_t {
179 uint16_t handle;
180 /**< Handle of vocproc being attached. */
181} __packed;
182
183struct vss_istream_cmd_detach_vocproc_t {
184 uint16_t handle;
185 /**< Handle of vocproc being detached. */
186} __packed;
187
188struct vss_imvm_cmd_attach_stream_t {
189 uint16_t handle;
190 /* The stream handle to attach. */
191} __packed;
192
193struct vss_imvm_cmd_detach_stream_t {
194 uint16_t handle;
195 /* The stream handle to detach. */
196} __packed;
197
198struct vss_icommon_cmd_set_network_t {
199 uint32_t network_id;
200 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
201} __packed;
202
203struct vss_icommon_cmd_set_voice_timing_t {
204 uint16_t mode;
205 /*
206 * The vocoder frame synchronization mode.
207 *
208 * 0 : No frame sync.
209 * 1 : Hard VFR (20ms Vocoder Frame Reference interrupt).
210 */
211 uint16_t enc_offset;
212 /*
213 * The offset in microseconds from the VFR to deliver a Tx vocoder
214 * packet. The offset should be less than 20000us.
215 */
216 uint16_t dec_req_offset;
217 /*
218 * The offset in microseconds from the VFR to request for an Rx vocoder
219 * packet. The offset should be less than 20000us.
220 */
221 uint16_t dec_offset;
222 /*
223 * The offset in microseconds from the VFR to indicate the deadline to
224 * receive an Rx vocoder packet. The offset should be less than 20000us.
225 * Rx vocoder packets received after this deadline are not guaranteed to
226 * be processed.
227 */
228} __packed;
229
Helen Zeng69b00962011-07-08 11:38:36 -0700230struct vss_imvm_cmd_create_control_session_t {
231 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700232 /*
233 * A variable-sized stream name.
234 *
235 * The stream name size is the payload size minus the size of the other
236 * fields.
237 */
238} __packed;
239
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700240
241struct vss_imvm_cmd_set_policy_dual_control_t {
242 bool enable_flag;
243 /* Set to TRUE to enable modem state machine control */
244} __packed;
245
Helen Zeng44d4d272011-08-10 14:49:20 -0700246struct vss_iwidevoice_cmd_set_widevoice_t {
247 uint32_t enable;
248 /* WideVoice enable/disable; possible values:
249 * - 0 -- WideVoice disabled
250 * - 1 -- WideVoice enabled
251 */
252} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700253
254struct mvm_attach_vocproc_cmd {
255 struct apr_hdr hdr;
256 struct vss_istream_cmd_attach_vocproc_t mvm_attach_cvp_handle;
257} __packed;
258
259struct mvm_detach_vocproc_cmd {
260 struct apr_hdr hdr;
261 struct vss_istream_cmd_detach_vocproc_t mvm_detach_cvp_handle;
262} __packed;
263
Helen Zeng69b00962011-07-08 11:38:36 -0700264struct mvm_create_ctl_session_cmd {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700265 struct apr_hdr hdr;
Helen Zeng69b00962011-07-08 11:38:36 -0700266 struct vss_imvm_cmd_create_control_session_t mvm_session;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267} __packed;
268
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700269struct mvm_modem_dual_control_session_cmd {
270 struct apr_hdr hdr;
271 struct vss_imvm_cmd_set_policy_dual_control_t voice_ctl;
272} __packed;
273
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700274struct mvm_set_tty_mode_cmd {
275 struct apr_hdr hdr;
276 struct vss_istream_cmd_set_tty_mode_t tty_mode;
277} __packed;
278
279struct mvm_attach_stream_cmd {
280 struct apr_hdr hdr;
281 struct vss_imvm_cmd_attach_stream_t attach_stream;
282} __packed;
283
284struct mvm_detach_stream_cmd {
285 struct apr_hdr hdr;
286 struct vss_imvm_cmd_detach_stream_t detach_stream;
287} __packed;
288
289struct mvm_set_network_cmd {
290 struct apr_hdr hdr;
291 struct vss_icommon_cmd_set_network_t network;
292} __packed;
293
294struct mvm_set_voice_timing_cmd {
295 struct apr_hdr hdr;
296 struct vss_icommon_cmd_set_voice_timing_t timing;
297} __packed;
298
Helen Zeng44d4d272011-08-10 14:49:20 -0700299struct mvm_set_widevoice_enable_cmd {
300 struct apr_hdr hdr;
301 struct vss_iwidevoice_cmd_set_widevoice_t vss_set_wv;
302} __packed;
303
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700304/* TO CVS commands */
305#define VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x00011140
306/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
307
308#define VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110F7
309/* Create a new full control stream session. */
310
311#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
312
313#define VSS_ISTREAM_CMD_SET_MUTE 0x00011022
314
Helen Zeng29eb7442011-06-20 11:06:29 -0700315#define VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA 0x00011279
316
317#define VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA 0x0001127A
318
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700319#define VSS_ISTREAM_CMD_SET_MEDIA_TYPE 0x00011186
320/* Set media type on the stream. */
321
322#define VSS_ISTREAM_EVT_SEND_ENC_BUFFER 0x00011015
323/* Event sent by the stream to its client to provide an encoded packet. */
324
325#define VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER 0x00011017
326/* Event sent by the stream to its client requesting for a decoder packet.
327 * The client should respond with a VSS_ISTREAM_EVT_SEND_DEC_BUFFER event.
328 */
329
330#define VSS_ISTREAM_EVT_SEND_DEC_BUFFER 0x00011016
331/* Event sent by the client to the stream in response to a
332 * VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER event, providing a decoder packet.
333 */
334
335#define VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE 0x0001113E
336/* Set AMR encoder rate. */
337
338#define VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE 0x0001113F
339/* Set AMR-WB encoder rate. */
340
341#define VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE 0x00011019
342/* Set encoder minimum and maximum rate. */
343
344#define VSS_ISTREAM_CMD_SET_ENC_DTX_MODE 0x0001101D
345/* Set encoder DTX mode. */
346
Helen Zeng4e531942011-12-17 21:14:40 -0800347#define MODULE_ID_VOICE_MODULE_FENS 0x00010EEB
Helen Zengbb49c702011-09-06 14:09:13 -0700348#define MODULE_ID_VOICE_MODULE_ST 0x00010EE3
349#define VOICE_PARAM_MOD_ENABLE 0x00010E00
350#define MOD_ENABLE_PARAM_LEN 4
351
Helen Zeng0705a5f2011-10-14 15:29:52 -0700352#define VSS_ISTREAM_CMD_START_PLAYBACK 0x00011238
353/* Start in-call music delivery on the Tx voice path. */
354
355#define VSS_ISTREAM_CMD_STOP_PLAYBACK 0x00011239
356/* Stop the in-call music delivery on the Tx voice path. */
357
Helen Zenge3d716a2011-10-14 16:32:16 -0700358#define VSS_ISTREAM_CMD_START_RECORD 0x00011236
359/* Start in-call conversation recording. */
360#define VSS_ISTREAM_CMD_STOP_RECORD 0x00011237
361/* Stop in-call conversation recording. */
362
363#define VSS_TAP_POINT_NONE 0x00010F78
364/* Indicates no tapping for specified path. */
365
366#define VSS_TAP_POINT_STREAM_END 0x00010F79
367/* Indicates that specified path should be tapped at the end of the stream. */
368
369struct vss_istream_cmd_start_record_t {
370 uint32_t rx_tap_point;
371 /* Tap point to use on the Rx path. Supported values are:
372 * VSS_TAP_POINT_NONE : Do not record Rx path.
373 * VSS_TAP_POINT_STREAM_END : Rx tap point is at the end of the stream.
374 */
375 uint32_t tx_tap_point;
376 /* Tap point to use on the Tx path. Supported values are:
377 * VSS_TAP_POINT_NONE : Do not record tx path.
378 * VSS_TAP_POINT_STREAM_END : Tx tap point is at the end of the stream.
379 */
380} __packed;
381
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700382struct vss_istream_cmd_create_passive_control_session_t {
Helen Zeng69b00962011-07-08 11:38:36 -0700383 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700384 /**<
385 * A variable-sized stream name.
386 *
387 * The stream name size is the payload size minus the size of the other
388 * fields.
389 */
390} __packed;
391
392struct vss_istream_cmd_set_mute_t {
393 uint16_t direction;
394 /**<
395 * 0 : TX only
396 * 1 : RX only
397 * 2 : TX and Rx
398 */
399 uint16_t mute_flag;
400 /**<
401 * Mute, un-mute.
402 *
403 * 0 : Silence disable
404 * 1 : Silence enable
405 * 2 : CNG enable. Applicable to TX only. If set on RX behavior
406 * will be the same as 1
407 */
408} __packed;
409
410struct vss_istream_cmd_create_full_control_session_t {
411 uint16_t direction;
412 /*
413 * Stream direction.
414 *
415 * 0 : TX only
416 * 1 : RX only
417 * 2 : TX and RX
418 * 3 : TX and RX loopback
419 */
420 uint32_t enc_media_type;
421 /* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
422 uint32_t dec_media_type;
423 /* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
424 uint32_t network_id;
425 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
Helen Zeng69b00962011-07-08 11:38:36 -0700426 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700427 /*
428 * A variable-sized stream name.
429 *
430 * The stream name size is the payload size minus the size of the other
431 * fields.
432 */
433} __packed;
434
435struct vss_istream_cmd_set_media_type_t {
436 uint32_t rx_media_id;
437 /* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
438 uint32_t tx_media_id;
439 /* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
440} __packed;
441
442struct vss_istream_evt_send_enc_buffer_t {
443 uint32_t media_id;
444 /* Media ID of the packet. */
445 uint8_t packet_data[MAX_VOC_PKT_SIZE];
446 /* Packet data buffer. */
447} __packed;
448
449struct vss_istream_evt_send_dec_buffer_t {
450 uint32_t media_id;
451 /* Media ID of the packet. */
452 uint8_t packet_data[MAX_VOC_PKT_SIZE];
453 /* Packet data. */
454} __packed;
455
456struct vss_istream_cmd_voc_amr_set_enc_rate_t {
457 uint32_t mode;
458 /* Set the AMR encoder rate.
459 *
460 * 0x00000000 : 4.75 kbps
461 * 0x00000001 : 5.15 kbps
462 * 0x00000002 : 5.90 kbps
463 * 0x00000003 : 6.70 kbps
464 * 0x00000004 : 7.40 kbps
465 * 0x00000005 : 7.95 kbps
466 * 0x00000006 : 10.2 kbps
467 * 0x00000007 : 12.2 kbps
468 */
469} __packed;
470
471struct vss_istream_cmd_voc_amrwb_set_enc_rate_t {
472 uint32_t mode;
473 /* Set the AMR-WB encoder rate.
474 *
475 * 0x00000000 : 6.60 kbps
476 * 0x00000001 : 8.85 kbps
477 * 0x00000002 : 12.65 kbps
478 * 0x00000003 : 14.25 kbps
479 * 0x00000004 : 15.85 kbps
480 * 0x00000005 : 18.25 kbps
481 * 0x00000006 : 19.85 kbps
482 * 0x00000007 : 23.05 kbps
483 * 0x00000008 : 23.85 kbps
484 */
485} __packed;
486
487struct vss_istream_cmd_cdma_set_enc_minmax_rate_t {
488 uint16_t min_rate;
489 /* Set the lower bound encoder rate.
490 *
491 * 0x0000 : Blank frame
492 * 0x0001 : Eighth rate
493 * 0x0002 : Quarter rate
494 * 0x0003 : Half rate
495 * 0x0004 : Full rate
496 */
497 uint16_t max_rate;
498 /* Set the upper bound encoder rate.
499 *
500 * 0x0000 : Blank frame
501 * 0x0001 : Eighth rate
502 * 0x0002 : Quarter rate
503 * 0x0003 : Half rate
504 * 0x0004 : Full rate
505 */
506} __packed;
507
508struct vss_istream_cmd_set_enc_dtx_mode_t {
509 uint32_t enable;
510 /* Toggle DTX on or off.
511 *
512 * 0 : Disables DTX
513 * 1 : Enables DTX
514 */
515} __packed;
516
Helen Zeng29eb7442011-06-20 11:06:29 -0700517struct vss_istream_cmd_register_calibration_data_t {
518 uint32_t phys_addr;
519 /* Phsical address to be registered with stream. The calibration data
520 * is stored at this address.
521 */
522 uint32_t mem_size;
523 /* Size of the calibration data in bytes. */
524};
525
Helen Zeng4e531942011-12-17 21:14:40 -0800526struct vss_icommon_cmd_set_ui_property_enable_t {
Helen Zengbb49c702011-09-06 14:09:13 -0700527 uint32_t module_id;
528 /* Unique ID of the module. */
529 uint32_t param_id;
530 /* Unique ID of the parameter. */
531 uint16_t param_size;
532 /* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */
533 uint16_t reserved;
534 /* Reserved; set to 0. */
535 uint16_t enable;
536 uint16_t reserved_field;
537 /* Reserved, set to 0. */
538};
539
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700540struct cvs_create_passive_ctl_session_cmd {
541 struct apr_hdr hdr;
542 struct vss_istream_cmd_create_passive_control_session_t cvs_session;
543} __packed;
544
545struct cvs_create_full_ctl_session_cmd {
546 struct apr_hdr hdr;
547 struct vss_istream_cmd_create_full_control_session_t cvs_session;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700548} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700549
550struct cvs_destroy_session_cmd {
551 struct apr_hdr hdr;
552} __packed;
553
554struct cvs_set_mute_cmd {
555 struct apr_hdr hdr;
556 struct vss_istream_cmd_set_mute_t cvs_set_mute;
557} __packed;
558
559struct cvs_set_media_type_cmd {
560 struct apr_hdr hdr;
561 struct vss_istream_cmd_set_media_type_t media_type;
562} __packed;
563
564struct cvs_send_dec_buf_cmd {
565 struct apr_hdr hdr;
566 struct vss_istream_evt_send_dec_buffer_t dec_buf;
567} __packed;
568
569struct cvs_set_amr_enc_rate_cmd {
570 struct apr_hdr hdr;
571 struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate;
572} __packed;
573
574struct cvs_set_amrwb_enc_rate_cmd {
575 struct apr_hdr hdr;
576 struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate;
577} __packed;
578
579struct cvs_set_cdma_enc_minmax_rate_cmd {
580 struct apr_hdr hdr;
581 struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate;
582} __packed;
583
584struct cvs_set_enc_dtx_mode_cmd {
585 struct apr_hdr hdr;
586 struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode;
587} __packed;
588
Helen Zeng29eb7442011-06-20 11:06:29 -0700589struct cvs_register_cal_data_cmd {
590 struct apr_hdr hdr;
591 struct vss_istream_cmd_register_calibration_data_t cvs_cal_data;
592} __packed;
593
594struct cvs_deregister_cal_data_cmd {
595 struct apr_hdr hdr;
596} __packed;
597
Helen Zeng4e531942011-12-17 21:14:40 -0800598struct cvs_set_pp_enable_cmd {
Helen Zengbb49c702011-09-06 14:09:13 -0700599 struct apr_hdr hdr;
Helen Zeng4e531942011-12-17 21:14:40 -0800600 struct vss_icommon_cmd_set_ui_property_enable_t vss_set_pp;
Helen Zengbb49c702011-09-06 14:09:13 -0700601} __packed;
Helen Zenge3d716a2011-10-14 16:32:16 -0700602struct cvs_start_record_cmd {
603 struct apr_hdr hdr;
604 struct vss_istream_cmd_start_record_t rec_mode;
605} __packed;
Helen Zengbb49c702011-09-06 14:09:13 -0700606
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700607/* TO CVP commands */
608
609#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION 0x000100C3
610/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
611
612#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
613
614#define VSS_IVOCPROC_CMD_SET_DEVICE 0x000100C4
615
616#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB
617
618#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE
619
620#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6
621/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
622
623#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1
624/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
625
Helen Zeng29eb7442011-06-20 11:06:29 -0700626#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA 0x00011275
627#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276
628
629#define VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE 0x00011277
630#define VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE 0x00011278
631
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700632#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70
633#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71
634#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72
635
636#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77
637
638/* Newtwork IDs */
639#define VSS_NETWORK_ID_DEFAULT 0x00010037
640#define VSS_NETWORK_ID_VOIP_NB 0x00011240
641#define VSS_NETWORK_ID_VOIP_WB 0x00011241
642#define VSS_NETWORK_ID_VOIP_WV 0x00011242
643
644/* Media types */
645#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2
646/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */
647#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6
648/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */
649#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7
650/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */
651#define VSS_MEDIA_ID_PCM_NB 0x00010FCB
652#define VSS_MEDIA_ID_PCM_WB 0x00010FCC
653/* Linear PCM (16-bit, little-endian). */
654#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD
655/* G.711 a-law (contains two 10ms vocoder frames). */
656#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE
657/* G.711 mu-law (contains two 10ms vocoder frames). */
658#define VSS_MEDIA_ID_G729 0x00010FD0
659/* G.729AB (contains two 10ms vocoder frames. */
660
Helen Zeng68656932011-11-02 18:08:23 -0700661#define VSS_IVOCPROC_CMD_SET_MUTE 0x000110EF
662
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700663#define VOICE_CMD_SET_PARAM 0x00011006
664#define VOICE_CMD_GET_PARAM 0x00011007
665#define VOICE_EVT_GET_PARAM_ACK 0x00011008
666
667struct vss_ivocproc_cmd_create_full_control_session_t {
668 uint16_t direction;
669 /*
670 * stream direction.
671 * 0 : TX only
672 * 1 : RX only
673 * 2 : TX and RX
674 */
675 uint32_t tx_port_id;
676 /*
677 * TX device port ID which vocproc will connect to. If not supplying a
678 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
679 */
680 uint32_t tx_topology_id;
681 /*
682 * Tx leg topology ID. If not supplying a topology ID set to
683 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
684 */
685 uint32_t rx_port_id;
686 /*
687 * RX device port ID which vocproc will connect to. If not supplying a
688 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
689 */
690 uint32_t rx_topology_id;
691 /*
692 * Rx leg topology ID. If not supplying a topology ID set to
693 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
694 */
695 int32_t network_id;
696 /*
697 * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network
698 * ID set to VSS_NETWORK_ID_DEFAULT.
699 */
700} __packed;
701
702struct vss_ivocproc_cmd_set_volume_index_t {
703 uint16_t vol_index;
704 /**<
705 * Volume index utilized by the vocproc to index into the volume table
706 * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set
707 * volume on the VDSP.
708 */
709} __packed;
710
711struct vss_ivocproc_cmd_set_device_t {
712 uint32_t tx_port_id;
713 /**<
714 * TX device port ID which vocproc will connect to.
715 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
716 */
717 uint32_t tx_topology_id;
718 /**<
719 * TX leg topology ID.
720 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
721 * pre/post-processing blocks and is pass-through.
722 */
723 int32_t rx_port_id;
724 /**<
725 * RX device port ID which vocproc will connect to.
726 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
727 */
728 uint32_t rx_topology_id;
729 /**<
730 * RX leg topology ID.
731 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
732 * pre/post-processing blocks and is pass-through.
733 */
734} __packed;
735
Helen Zeng29eb7442011-06-20 11:06:29 -0700736struct vss_ivocproc_cmd_register_calibration_data_t {
737 uint32_t phys_addr;
738 /* Phsical address to be registered with vocproc. Calibration data
739 * is stored at this address.
740 */
741 uint32_t mem_size;
742 /* Size of the calibration data in bytes. */
743} __packed;
744
745struct vss_ivocproc_cmd_register_volume_cal_table_t {
746 uint32_t phys_addr;
747 /* Phsical address to be registered with the vocproc. The volume
748 * calibration table is stored at this location.
749 */
750
751 uint32_t mem_size;
752 /* Size of the volume calibration table in bytes. */
753} __packed;
754
Helen Zeng68656932011-11-02 18:08:23 -0700755struct vss_ivocproc_cmd_set_mute_t {
756 uint16_t direction;
757 /*
758 * 0 : TX only.
759 * 1 : RX only.
760 * 2 : TX and Rx.
761 */
762 uint16_t mute_flag;
763 /*
764 * Mute, un-mute.
765 *
766 * 0 : Disable.
767 * 1 : Enable.
768 */
769} __packed;
770
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700771struct cvp_create_full_ctl_session_cmd {
772 struct apr_hdr hdr;
773 struct vss_ivocproc_cmd_create_full_control_session_t cvp_session;
774} __packed;
775
776struct cvp_command {
777 struct apr_hdr hdr;
778} __packed;
779
780struct cvp_set_device_cmd {
781 struct apr_hdr hdr;
782 struct vss_ivocproc_cmd_set_device_t cvp_set_device;
783} __packed;
784
785struct cvp_set_vp3_data_cmd {
786 struct apr_hdr hdr;
787} __packed;
788
789struct cvp_set_rx_volume_index_cmd {
790 struct apr_hdr hdr;
791 struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx;
792} __packed;
793
Helen Zeng29eb7442011-06-20 11:06:29 -0700794struct cvp_register_cal_data_cmd {
795 struct apr_hdr hdr;
796 struct vss_ivocproc_cmd_register_calibration_data_t cvp_cal_data;
797} __packed;
798
799struct cvp_deregister_cal_data_cmd {
800 struct apr_hdr hdr;
801} __packed;
802
803struct cvp_register_vol_cal_table_cmd {
804 struct apr_hdr hdr;
805 struct vss_ivocproc_cmd_register_volume_cal_table_t cvp_vol_cal_tbl;
806} __packed;
807
808struct cvp_deregister_vol_cal_table_cmd {
809 struct apr_hdr hdr;
810} __packed;
811
Helen Zeng68656932011-11-02 18:08:23 -0700812struct cvp_set_mute_cmd {
813 struct apr_hdr hdr;
814 struct vss_ivocproc_cmd_set_mute_t cvp_set_mute;
815} __packed;
816
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700817/* CB for up-link packets. */
818typedef void (*ul_cb_fn)(uint8_t *voc_pkt,
819 uint32_t pkt_len,
820 void *private_data);
821
822/* CB for down-link packets. */
823typedef void (*dl_cb_fn)(uint8_t *voc_pkt,
824 uint32_t *pkt_len,
825 void *private_data);
826
827
828struct mvs_driver_info {
829 uint32_t media_type;
830 uint32_t rate;
831 uint32_t network_type;
Helen Zengff97bec2012-02-20 14:30:50 -0800832 uint32_t dtx_mode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700833 ul_cb_fn ul_cb;
834 dl_cb_fn dl_cb;
835 void *private_data;
836};
837
838struct incall_rec_info {
Helen Zenge3d716a2011-10-14 16:32:16 -0700839 uint32_t rec_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700840 uint32_t rec_mode;
Helen Zenge3d716a2011-10-14 16:32:16 -0700841 uint32_t recording;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700842};
843
844struct incall_music_info {
Helen Zeng0705a5f2011-10-14 15:29:52 -0700845 uint32_t play_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700846 uint32_t playing;
Helen Zeng0705a5f2011-10-14 15:29:52 -0700847 int count;
848 int force;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700849};
850
851struct voice_data {
852 int voc_state;/*INIT, CHANGE, RELEASE, RUN */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700853
854 wait_queue_head_t mvm_wait;
855 wait_queue_head_t cvs_wait;
856 wait_queue_head_t cvp_wait;
857
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700858 /* cache the values related to Rx and Tx */
859 struct device_data dev_rx;
860 struct device_data dev_tx;
861
Neema Shetty2c07eb52011-08-21 20:33:52 -0700862 u32 mvm_state;
863 u32 cvs_state;
864 u32 cvp_state;
865
866 /* Handle to MVM in the Q6 */
867 u16 mvm_handle;
868 /* Handle to CVS in the Q6 */
869 u16 cvs_handle;
870 /* Handle to CVP in the Q6 */
871 u16 cvp_handle;
872
873 struct mutex lock;
874
875 uint16_t sidetone_gain;
876 uint8_t tty_mode;
877 /* widevoice enable value */
878 uint8_t wv_enable;
Helen Zengbb49c702011-09-06 14:09:13 -0700879 /* slowtalk enable value */
880 uint32_t st_enable;
Helen Zeng4e531942011-12-17 21:14:40 -0800881 /* FENC enable value */
882 uint32_t fens_enable;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700883
884 struct voice_dev_route_state voc_route_state;
885
886 u16 session_id;
Helen Zenge3d716a2011-10-14 16:32:16 -0700887
888 struct incall_rec_info rec_info;
889
Helen Zeng0705a5f2011-10-14 15:29:52 -0700890 struct incall_music_info music_info;
Helen Zenge3d716a2011-10-14 16:32:16 -0700891
892 struct voice_rec_route_state rec_route_state;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700893};
894
Helen Zeng6e64dba2012-03-08 18:30:11 -0800895struct cal_mem {
896 struct ion_handle *handle;
897 uint32_t phy;
898 void *buf;
899};
900
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700901#define MAX_VOC_SESSIONS 3
Neema Shetty2c07eb52011-08-21 20:33:52 -0700902#define SESSION_ID_BASE 0xFFF0
903
904struct common_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700905 /* these default values are for all devices */
906 uint32_t default_mute_val;
907 uint32_t default_vol_val;
908 uint32_t default_sample_val;
909
910 /* APR to MVM in the Q6 */
911 void *apr_q6_mvm;
912 /* APR to CVS in the Q6 */
913 void *apr_q6_cvs;
914 /* APR to CVP in the Q6 */
915 void *apr_q6_cvp;
916
Helen Zeng6e64dba2012-03-08 18:30:11 -0800917 struct ion_client *client;
918 struct cal_mem cvp_cal;
919 struct cal_mem cvs_cal;
920
Neema Shetty2c07eb52011-08-21 20:33:52 -0700921 struct mutex common_lock;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700922
923 struct mvs_driver_info mvs_info;
924
Neema Shetty2c07eb52011-08-21 20:33:52 -0700925 struct voice_data voice[MAX_VOC_SESSIONS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700926};
927
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700928void voc_register_mvs_cb(ul_cb_fn ul_cb,
929 dl_cb_fn dl_cb,
930 void *private_data);
931
932void voc_config_vocoder(uint32_t media_type,
933 uint32_t rate,
Helen Zengff97bec2012-02-20 14:30:50 -0800934 uint32_t network_type,
935 uint32_t dtx_mode);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700936
937enum {
938 DEV_RX = 0,
939 DEV_TX,
940};
941
942enum {
943 RX_PATH = 0,
944 TX_PATH,
945};
946
947/* called by alsa driver */
Helen Zeng4e531942011-12-17 21:14:40 -0800948int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable);
949int voc_get_pp_enable(uint16_t session_id, uint32_t module_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700950int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable);
951uint32_t voc_get_widevoice_enable(uint16_t session_id);
952uint8_t voc_get_tty_mode(uint16_t session_id);
953int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode);
954int voc_start_voice_call(uint16_t session_id);
955int voc_end_voice_call(uint16_t session_id);
956int voc_set_rxtx_port(uint16_t session_id,
957 uint32_t dev_port_id,
958 uint32_t dev_type);
959int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t voc_idx);
960int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute);
Helen Zeng68656932011-11-02 18:08:23 -0700961int voc_set_rx_device_mute(uint16_t session_id, uint32_t mute);
962int voc_get_rx_device_mute(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700963int voc_disable_cvp(uint16_t session_id);
964int voc_enable_cvp(uint16_t session_id);
965int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set);
966uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir);
967
968#define VOICE_SESSION_NAME "Voice session"
969#define VOIP_SESSION_NAME "VoIP session"
Venkat Sudhir505bb4f2012-04-09 23:08:20 -0700970#define VOLTE_SESSION_NAME "VoLTE session"
Neema Shetty2c07eb52011-08-21 20:33:52 -0700971uint16_t voc_get_session_id(char *name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700972
Helen Zeng0705a5f2011-10-14 15:29:52 -0700973int voc_start_playback(uint32_t set);
Helen Zenge3d716a2011-10-14 16:32:16 -0700974int voc_start_record(uint32_t port_id, uint32_t set);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700975#endif