blob: 0edf1c9b1a51276435c34496ff7524841b817838 [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>
16
Helen Zeng2095e572011-08-15 18:30:43 -070017#define MAX_VOC_PKT_SIZE 642
Helen Zeng69b00962011-07-08 11:38:36 -070018#define SESSION_NAME_LEN 20
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070019
Helen Zenge3d716a2011-10-14 16:32:16 -070020#define VOC_REC_UPLINK 0x00
21#define VOC_REC_DOWNLINK 0x01
22#define VOC_REC_BOTH 0x02
23
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024struct voice_header {
25 uint32_t id;
26 uint32_t data_len;
27};
28
29struct voice_init {
30 struct voice_header hdr;
31 void *cb_handle;
32};
33
34/* Device information payload structure */
35
36struct device_data {
37 uint32_t volume; /* in index */
38 uint32_t mute;
39 uint32_t sample;
40 uint32_t enabled;
41 uint32_t dev_id;
42 uint32_t port_id;
43};
44
45struct voice_dev_route_state {
46 u16 rx_route_flag;
47 u16 tx_route_flag;
48};
49
Helen Zenge3d716a2011-10-14 16:32:16 -070050struct voice_rec_route_state {
51 u16 ul_flag;
52 u16 dl_flag;
53};
54
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070055enum {
56 VOC_INIT = 0,
57 VOC_RUN,
58 VOC_CHANGE,
59 VOC_RELEASE,
60};
61
Helen Zeng29eb7442011-06-20 11:06:29 -070062/* Common */
Helen Zengbb49c702011-09-06 14:09:13 -070063#define VSS_ICOMMON_CMD_SET_UI_PROPERTY 0x00011103
64/* Set a UI property */
Helen Zeng29eb7442011-06-20 11:06:29 -070065#define VSS_ICOMMON_CMD_MAP_MEMORY 0x00011025
66#define VSS_ICOMMON_CMD_UNMAP_MEMORY 0x00011026
67/* General shared memory; byte-accessible, 4 kB-aligned. */
68#define VSS_ICOMMON_MAP_MEMORY_SHMEM8_4K_POOL 3
69
70struct vss_icommon_cmd_map_memory_t {
71 uint32_t phys_addr;
72 /* Physical address of a memory region; must be at least
73 * 4 kB aligned.
74 */
75
76 uint32_t mem_size;
77 /* Number of bytes in the region; should be a multiple of 32. */
78
79 uint16_t mem_pool_id;
80 /* Type of memory being provided. The memory ID implicitly defines
81 * the characteristics of the memory. The characteristics might include
82 * alignment type, permissions, etc.
83 * Memory pool ID. Possible values:
84 * 3 -- VSS_ICOMMON_MEM_TYPE_SHMEM8_4K_POOL.
85 */
86} __packed;
87
88struct vss_icommon_cmd_unmap_memory_t {
89 uint32_t phys_addr;
90 /* Physical address of a memory region; must be at least
91 * 4 kB aligned.
92 */
93} __packed;
94
95struct vss_map_memory_cmd {
96 struct apr_hdr hdr;
97 struct vss_icommon_cmd_map_memory_t vss_map_mem;
98} __packed;
99
100struct vss_unmap_memory_cmd {
101 struct apr_hdr hdr;
102 struct vss_icommon_cmd_unmap_memory_t vss_unmap_mem;
103} __packed;
104
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105/* TO MVM commands */
106#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x000110FF
107/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
108
109#define VSS_IMVM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110FE
110/* Create a new full control MVM session. */
111
112#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
113/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
114
115#define VSS_IMVM_CMD_ATTACH_STREAM 0x0001123C
116/* Attach a stream to the MVM. */
117
118#define VSS_IMVM_CMD_DETACH_STREAM 0x0001123D
119/* Detach a stream from the MVM. */
120
Helen Zeng69b00962011-07-08 11:38:36 -0700121#define VSS_IMVM_CMD_ATTACH_VOCPROC 0x0001123E
122/* Attach a vocproc to the MVM. The MVM will symmetrically connect this vocproc
123 * to all the streams currently attached to it.
124 */
125
126#define VSS_IMVM_CMD_DETACH_VOCPROC 0x0001123F
127/* Detach a vocproc from the MVM. The MVM will symmetrically disconnect this
128 * vocproc from all the streams to which it is currently attached.
129*/
130
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700131#define VSS_IMVM_CMD_START_VOICE 0x00011190
132/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
133
134#define VSS_IMVM_CMD_STOP_VOICE 0x00011192
135/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
136
137#define VSS_ISTREAM_CMD_ATTACH_VOCPROC 0x000110F8
138/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
139
140#define VSS_ISTREAM_CMD_DETACH_VOCPROC 0x000110F9
141/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
142
143
144#define VSS_ISTREAM_CMD_SET_TTY_MODE 0x00011196
145/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
146
147#define VSS_ICOMMON_CMD_SET_NETWORK 0x0001119C
148/* Set the network type. */
149
150#define VSS_ICOMMON_CMD_SET_VOICE_TIMING 0x000111E0
151/* Set the voice timing parameters. */
152
Helen Zeng44d4d272011-08-10 14:49:20 -0700153#define VSS_IWIDEVOICE_CMD_SET_WIDEVOICE 0x00011243
154/* Enable/disable WideVoice */
155
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700156struct vss_istream_cmd_set_tty_mode_t {
157 uint32_t mode;
158 /**<
159 * TTY mode.
160 *
161 * 0 : TTY disabled
162 * 1 : HCO
163 * 2 : VCO
164 * 3 : FULL
165 */
166} __packed;
167
168struct vss_istream_cmd_attach_vocproc_t {
169 uint16_t handle;
170 /**< Handle of vocproc being attached. */
171} __packed;
172
173struct vss_istream_cmd_detach_vocproc_t {
174 uint16_t handle;
175 /**< Handle of vocproc being detached. */
176} __packed;
177
178struct vss_imvm_cmd_attach_stream_t {
179 uint16_t handle;
180 /* The stream handle to attach. */
181} __packed;
182
183struct vss_imvm_cmd_detach_stream_t {
184 uint16_t handle;
185 /* The stream handle to detach. */
186} __packed;
187
188struct vss_icommon_cmd_set_network_t {
189 uint32_t network_id;
190 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
191} __packed;
192
193struct vss_icommon_cmd_set_voice_timing_t {
194 uint16_t mode;
195 /*
196 * The vocoder frame synchronization mode.
197 *
198 * 0 : No frame sync.
199 * 1 : Hard VFR (20ms Vocoder Frame Reference interrupt).
200 */
201 uint16_t enc_offset;
202 /*
203 * The offset in microseconds from the VFR to deliver a Tx vocoder
204 * packet. The offset should be less than 20000us.
205 */
206 uint16_t dec_req_offset;
207 /*
208 * The offset in microseconds from the VFR to request for an Rx vocoder
209 * packet. The offset should be less than 20000us.
210 */
211 uint16_t dec_offset;
212 /*
213 * The offset in microseconds from the VFR to indicate the deadline to
214 * receive an Rx vocoder packet. The offset should be less than 20000us.
215 * Rx vocoder packets received after this deadline are not guaranteed to
216 * be processed.
217 */
218} __packed;
219
Helen Zeng69b00962011-07-08 11:38:36 -0700220struct vss_imvm_cmd_create_control_session_t {
221 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700222 /*
223 * A variable-sized stream name.
224 *
225 * The stream name size is the payload size minus the size of the other
226 * fields.
227 */
228} __packed;
229
Helen Zeng44d4d272011-08-10 14:49:20 -0700230struct vss_iwidevoice_cmd_set_widevoice_t {
231 uint32_t enable;
232 /* WideVoice enable/disable; possible values:
233 * - 0 -- WideVoice disabled
234 * - 1 -- WideVoice enabled
235 */
236} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700237
238struct mvm_attach_vocproc_cmd {
239 struct apr_hdr hdr;
240 struct vss_istream_cmd_attach_vocproc_t mvm_attach_cvp_handle;
241} __packed;
242
243struct mvm_detach_vocproc_cmd {
244 struct apr_hdr hdr;
245 struct vss_istream_cmd_detach_vocproc_t mvm_detach_cvp_handle;
246} __packed;
247
Helen Zeng69b00962011-07-08 11:38:36 -0700248struct mvm_create_ctl_session_cmd {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700249 struct apr_hdr hdr;
Helen Zeng69b00962011-07-08 11:38:36 -0700250 struct vss_imvm_cmd_create_control_session_t mvm_session;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700251} __packed;
252
253struct mvm_set_tty_mode_cmd {
254 struct apr_hdr hdr;
255 struct vss_istream_cmd_set_tty_mode_t tty_mode;
256} __packed;
257
258struct mvm_attach_stream_cmd {
259 struct apr_hdr hdr;
260 struct vss_imvm_cmd_attach_stream_t attach_stream;
261} __packed;
262
263struct mvm_detach_stream_cmd {
264 struct apr_hdr hdr;
265 struct vss_imvm_cmd_detach_stream_t detach_stream;
266} __packed;
267
268struct mvm_set_network_cmd {
269 struct apr_hdr hdr;
270 struct vss_icommon_cmd_set_network_t network;
271} __packed;
272
273struct mvm_set_voice_timing_cmd {
274 struct apr_hdr hdr;
275 struct vss_icommon_cmd_set_voice_timing_t timing;
276} __packed;
277
Helen Zeng44d4d272011-08-10 14:49:20 -0700278struct mvm_set_widevoice_enable_cmd {
279 struct apr_hdr hdr;
280 struct vss_iwidevoice_cmd_set_widevoice_t vss_set_wv;
281} __packed;
282
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700283/* TO CVS commands */
284#define VSS_ISTREAM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x00011140
285/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
286
287#define VSS_ISTREAM_CMD_CREATE_FULL_CONTROL_SESSION 0x000110F7
288/* Create a new full control stream session. */
289
290#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
291
292#define VSS_ISTREAM_CMD_SET_MUTE 0x00011022
293
Helen Zeng29eb7442011-06-20 11:06:29 -0700294#define VSS_ISTREAM_CMD_REGISTER_CALIBRATION_DATA 0x00011279
295
296#define VSS_ISTREAM_CMD_DEREGISTER_CALIBRATION_DATA 0x0001127A
297
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700298#define VSS_ISTREAM_CMD_SET_MEDIA_TYPE 0x00011186
299/* Set media type on the stream. */
300
301#define VSS_ISTREAM_EVT_SEND_ENC_BUFFER 0x00011015
302/* Event sent by the stream to its client to provide an encoded packet. */
303
304#define VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER 0x00011017
305/* Event sent by the stream to its client requesting for a decoder packet.
306 * The client should respond with a VSS_ISTREAM_EVT_SEND_DEC_BUFFER event.
307 */
308
309#define VSS_ISTREAM_EVT_SEND_DEC_BUFFER 0x00011016
310/* Event sent by the client to the stream in response to a
311 * VSS_ISTREAM_EVT_REQUEST_DEC_BUFFER event, providing a decoder packet.
312 */
313
314#define VSS_ISTREAM_CMD_VOC_AMR_SET_ENC_RATE 0x0001113E
315/* Set AMR encoder rate. */
316
317#define VSS_ISTREAM_CMD_VOC_AMRWB_SET_ENC_RATE 0x0001113F
318/* Set AMR-WB encoder rate. */
319
320#define VSS_ISTREAM_CMD_CDMA_SET_ENC_MINMAX_RATE 0x00011019
321/* Set encoder minimum and maximum rate. */
322
323#define VSS_ISTREAM_CMD_SET_ENC_DTX_MODE 0x0001101D
324/* Set encoder DTX mode. */
325
Helen Zeng4e531942011-12-17 21:14:40 -0800326#define MODULE_ID_VOICE_MODULE_FENS 0x00010EEB
Helen Zengbb49c702011-09-06 14:09:13 -0700327#define MODULE_ID_VOICE_MODULE_ST 0x00010EE3
328#define VOICE_PARAM_MOD_ENABLE 0x00010E00
329#define MOD_ENABLE_PARAM_LEN 4
330
Helen Zeng0705a5f2011-10-14 15:29:52 -0700331#define VSS_ISTREAM_CMD_START_PLAYBACK 0x00011238
332/* Start in-call music delivery on the Tx voice path. */
333
334#define VSS_ISTREAM_CMD_STOP_PLAYBACK 0x00011239
335/* Stop the in-call music delivery on the Tx voice path. */
336
Helen Zenge3d716a2011-10-14 16:32:16 -0700337#define VSS_ISTREAM_CMD_START_RECORD 0x00011236
338/* Start in-call conversation recording. */
339#define VSS_ISTREAM_CMD_STOP_RECORD 0x00011237
340/* Stop in-call conversation recording. */
341
342#define VSS_TAP_POINT_NONE 0x00010F78
343/* Indicates no tapping for specified path. */
344
345#define VSS_TAP_POINT_STREAM_END 0x00010F79
346/* Indicates that specified path should be tapped at the end of the stream. */
347
348struct vss_istream_cmd_start_record_t {
349 uint32_t rx_tap_point;
350 /* Tap point to use on the Rx path. Supported values are:
351 * VSS_TAP_POINT_NONE : Do not record Rx path.
352 * VSS_TAP_POINT_STREAM_END : Rx tap point is at the end of the stream.
353 */
354 uint32_t tx_tap_point;
355 /* Tap point to use on the Tx path. Supported values are:
356 * VSS_TAP_POINT_NONE : Do not record tx path.
357 * VSS_TAP_POINT_STREAM_END : Tx tap point is at the end of the stream.
358 */
359} __packed;
360
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700361struct vss_istream_cmd_create_passive_control_session_t {
Helen Zeng69b00962011-07-08 11:38:36 -0700362 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700363 /**<
364 * A variable-sized stream name.
365 *
366 * The stream name size is the payload size minus the size of the other
367 * fields.
368 */
369} __packed;
370
371struct vss_istream_cmd_set_mute_t {
372 uint16_t direction;
373 /**<
374 * 0 : TX only
375 * 1 : RX only
376 * 2 : TX and Rx
377 */
378 uint16_t mute_flag;
379 /**<
380 * Mute, un-mute.
381 *
382 * 0 : Silence disable
383 * 1 : Silence enable
384 * 2 : CNG enable. Applicable to TX only. If set on RX behavior
385 * will be the same as 1
386 */
387} __packed;
388
389struct vss_istream_cmd_create_full_control_session_t {
390 uint16_t direction;
391 /*
392 * Stream direction.
393 *
394 * 0 : TX only
395 * 1 : RX only
396 * 2 : TX and RX
397 * 3 : TX and RX loopback
398 */
399 uint32_t enc_media_type;
400 /* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
401 uint32_t dec_media_type;
402 /* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
403 uint32_t network_id;
404 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
Helen Zeng69b00962011-07-08 11:38:36 -0700405 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700406 /*
407 * A variable-sized stream name.
408 *
409 * The stream name size is the payload size minus the size of the other
410 * fields.
411 */
412} __packed;
413
414struct vss_istream_cmd_set_media_type_t {
415 uint32_t rx_media_id;
416 /* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
417 uint32_t tx_media_id;
418 /* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
419} __packed;
420
421struct vss_istream_evt_send_enc_buffer_t {
422 uint32_t media_id;
423 /* Media ID of the packet. */
424 uint8_t packet_data[MAX_VOC_PKT_SIZE];
425 /* Packet data buffer. */
426} __packed;
427
428struct vss_istream_evt_send_dec_buffer_t {
429 uint32_t media_id;
430 /* Media ID of the packet. */
431 uint8_t packet_data[MAX_VOC_PKT_SIZE];
432 /* Packet data. */
433} __packed;
434
435struct vss_istream_cmd_voc_amr_set_enc_rate_t {
436 uint32_t mode;
437 /* Set the AMR encoder rate.
438 *
439 * 0x00000000 : 4.75 kbps
440 * 0x00000001 : 5.15 kbps
441 * 0x00000002 : 5.90 kbps
442 * 0x00000003 : 6.70 kbps
443 * 0x00000004 : 7.40 kbps
444 * 0x00000005 : 7.95 kbps
445 * 0x00000006 : 10.2 kbps
446 * 0x00000007 : 12.2 kbps
447 */
448} __packed;
449
450struct vss_istream_cmd_voc_amrwb_set_enc_rate_t {
451 uint32_t mode;
452 /* Set the AMR-WB encoder rate.
453 *
454 * 0x00000000 : 6.60 kbps
455 * 0x00000001 : 8.85 kbps
456 * 0x00000002 : 12.65 kbps
457 * 0x00000003 : 14.25 kbps
458 * 0x00000004 : 15.85 kbps
459 * 0x00000005 : 18.25 kbps
460 * 0x00000006 : 19.85 kbps
461 * 0x00000007 : 23.05 kbps
462 * 0x00000008 : 23.85 kbps
463 */
464} __packed;
465
466struct vss_istream_cmd_cdma_set_enc_minmax_rate_t {
467 uint16_t min_rate;
468 /* Set the lower bound encoder rate.
469 *
470 * 0x0000 : Blank frame
471 * 0x0001 : Eighth rate
472 * 0x0002 : Quarter rate
473 * 0x0003 : Half rate
474 * 0x0004 : Full rate
475 */
476 uint16_t max_rate;
477 /* Set the upper bound encoder rate.
478 *
479 * 0x0000 : Blank frame
480 * 0x0001 : Eighth rate
481 * 0x0002 : Quarter rate
482 * 0x0003 : Half rate
483 * 0x0004 : Full rate
484 */
485} __packed;
486
487struct vss_istream_cmd_set_enc_dtx_mode_t {
488 uint32_t enable;
489 /* Toggle DTX on or off.
490 *
491 * 0 : Disables DTX
492 * 1 : Enables DTX
493 */
494} __packed;
495
Helen Zeng29eb7442011-06-20 11:06:29 -0700496struct vss_istream_cmd_register_calibration_data_t {
497 uint32_t phys_addr;
498 /* Phsical address to be registered with stream. The calibration data
499 * is stored at this address.
500 */
501 uint32_t mem_size;
502 /* Size of the calibration data in bytes. */
503};
504
Helen Zeng4e531942011-12-17 21:14:40 -0800505struct vss_icommon_cmd_set_ui_property_enable_t {
Helen Zengbb49c702011-09-06 14:09:13 -0700506 uint32_t module_id;
507 /* Unique ID of the module. */
508 uint32_t param_id;
509 /* Unique ID of the parameter. */
510 uint16_t param_size;
511 /* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */
512 uint16_t reserved;
513 /* Reserved; set to 0. */
514 uint16_t enable;
515 uint16_t reserved_field;
516 /* Reserved, set to 0. */
517};
518
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700519struct cvs_create_passive_ctl_session_cmd {
520 struct apr_hdr hdr;
521 struct vss_istream_cmd_create_passive_control_session_t cvs_session;
522} __packed;
523
524struct cvs_create_full_ctl_session_cmd {
525 struct apr_hdr hdr;
526 struct vss_istream_cmd_create_full_control_session_t cvs_session;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700527} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700528
529struct cvs_destroy_session_cmd {
530 struct apr_hdr hdr;
531} __packed;
532
533struct cvs_set_mute_cmd {
534 struct apr_hdr hdr;
535 struct vss_istream_cmd_set_mute_t cvs_set_mute;
536} __packed;
537
538struct cvs_set_media_type_cmd {
539 struct apr_hdr hdr;
540 struct vss_istream_cmd_set_media_type_t media_type;
541} __packed;
542
543struct cvs_send_dec_buf_cmd {
544 struct apr_hdr hdr;
545 struct vss_istream_evt_send_dec_buffer_t dec_buf;
546} __packed;
547
548struct cvs_set_amr_enc_rate_cmd {
549 struct apr_hdr hdr;
550 struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate;
551} __packed;
552
553struct cvs_set_amrwb_enc_rate_cmd {
554 struct apr_hdr hdr;
555 struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate;
556} __packed;
557
558struct cvs_set_cdma_enc_minmax_rate_cmd {
559 struct apr_hdr hdr;
560 struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate;
561} __packed;
562
563struct cvs_set_enc_dtx_mode_cmd {
564 struct apr_hdr hdr;
565 struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode;
566} __packed;
567
Helen Zeng29eb7442011-06-20 11:06:29 -0700568struct cvs_register_cal_data_cmd {
569 struct apr_hdr hdr;
570 struct vss_istream_cmd_register_calibration_data_t cvs_cal_data;
571} __packed;
572
573struct cvs_deregister_cal_data_cmd {
574 struct apr_hdr hdr;
575} __packed;
576
Helen Zeng4e531942011-12-17 21:14:40 -0800577struct cvs_set_pp_enable_cmd {
Helen Zengbb49c702011-09-06 14:09:13 -0700578 struct apr_hdr hdr;
Helen Zeng4e531942011-12-17 21:14:40 -0800579 struct vss_icommon_cmd_set_ui_property_enable_t vss_set_pp;
Helen Zengbb49c702011-09-06 14:09:13 -0700580} __packed;
Helen Zenge3d716a2011-10-14 16:32:16 -0700581struct cvs_start_record_cmd {
582 struct apr_hdr hdr;
583 struct vss_istream_cmd_start_record_t rec_mode;
584} __packed;
Helen Zengbb49c702011-09-06 14:09:13 -0700585
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700586/* TO CVP commands */
587
588#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION 0x000100C3
589/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
590
591#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
592
593#define VSS_IVOCPROC_CMD_SET_DEVICE 0x000100C4
594
595#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB
596
597#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE
598
599#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6
600/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
601
602#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1
603/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
604
Helen Zeng29eb7442011-06-20 11:06:29 -0700605#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA 0x00011275
606#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276
607
608#define VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE 0x00011277
609#define VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE 0x00011278
610
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700611#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70
612#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71
613#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72
614
615#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77
616
617/* Newtwork IDs */
618#define VSS_NETWORK_ID_DEFAULT 0x00010037
619#define VSS_NETWORK_ID_VOIP_NB 0x00011240
620#define VSS_NETWORK_ID_VOIP_WB 0x00011241
621#define VSS_NETWORK_ID_VOIP_WV 0x00011242
622
623/* Media types */
624#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2
625/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */
626#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6
627/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */
628#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7
629/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */
630#define VSS_MEDIA_ID_PCM_NB 0x00010FCB
631#define VSS_MEDIA_ID_PCM_WB 0x00010FCC
632/* Linear PCM (16-bit, little-endian). */
633#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD
634/* G.711 a-law (contains two 10ms vocoder frames). */
635#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE
636/* G.711 mu-law (contains two 10ms vocoder frames). */
637#define VSS_MEDIA_ID_G729 0x00010FD0
638/* G.729AB (contains two 10ms vocoder frames. */
639
Helen Zeng68656932011-11-02 18:08:23 -0700640#define VSS_IVOCPROC_CMD_SET_MUTE 0x000110EF
641
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700642#define VOICE_CMD_SET_PARAM 0x00011006
643#define VOICE_CMD_GET_PARAM 0x00011007
644#define VOICE_EVT_GET_PARAM_ACK 0x00011008
645
646struct vss_ivocproc_cmd_create_full_control_session_t {
647 uint16_t direction;
648 /*
649 * stream direction.
650 * 0 : TX only
651 * 1 : RX only
652 * 2 : TX and RX
653 */
654 uint32_t tx_port_id;
655 /*
656 * TX device port ID which vocproc will connect to. If not supplying a
657 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
658 */
659 uint32_t tx_topology_id;
660 /*
661 * Tx leg topology ID. If not supplying a topology ID set to
662 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
663 */
664 uint32_t rx_port_id;
665 /*
666 * RX device port ID which vocproc will connect to. If not supplying a
667 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
668 */
669 uint32_t rx_topology_id;
670 /*
671 * Rx leg topology ID. If not supplying a topology ID set to
672 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
673 */
674 int32_t network_id;
675 /*
676 * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network
677 * ID set to VSS_NETWORK_ID_DEFAULT.
678 */
679} __packed;
680
681struct vss_ivocproc_cmd_set_volume_index_t {
682 uint16_t vol_index;
683 /**<
684 * Volume index utilized by the vocproc to index into the volume table
685 * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set
686 * volume on the VDSP.
687 */
688} __packed;
689
690struct vss_ivocproc_cmd_set_device_t {
691 uint32_t tx_port_id;
692 /**<
693 * TX device port ID which vocproc will connect to.
694 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
695 */
696 uint32_t tx_topology_id;
697 /**<
698 * TX leg topology ID.
699 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
700 * pre/post-processing blocks and is pass-through.
701 */
702 int32_t rx_port_id;
703 /**<
704 * RX device port ID which vocproc will connect to.
705 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
706 */
707 uint32_t rx_topology_id;
708 /**<
709 * RX leg topology ID.
710 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
711 * pre/post-processing blocks and is pass-through.
712 */
713} __packed;
714
Helen Zeng29eb7442011-06-20 11:06:29 -0700715struct vss_ivocproc_cmd_register_calibration_data_t {
716 uint32_t phys_addr;
717 /* Phsical address to be registered with vocproc. Calibration data
718 * is stored at this address.
719 */
720 uint32_t mem_size;
721 /* Size of the calibration data in bytes. */
722} __packed;
723
724struct vss_ivocproc_cmd_register_volume_cal_table_t {
725 uint32_t phys_addr;
726 /* Phsical address to be registered with the vocproc. The volume
727 * calibration table is stored at this location.
728 */
729
730 uint32_t mem_size;
731 /* Size of the volume calibration table in bytes. */
732} __packed;
733
Helen Zeng68656932011-11-02 18:08:23 -0700734struct vss_ivocproc_cmd_set_mute_t {
735 uint16_t direction;
736 /*
737 * 0 : TX only.
738 * 1 : RX only.
739 * 2 : TX and Rx.
740 */
741 uint16_t mute_flag;
742 /*
743 * Mute, un-mute.
744 *
745 * 0 : Disable.
746 * 1 : Enable.
747 */
748} __packed;
749
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700750struct cvp_create_full_ctl_session_cmd {
751 struct apr_hdr hdr;
752 struct vss_ivocproc_cmd_create_full_control_session_t cvp_session;
753} __packed;
754
755struct cvp_command {
756 struct apr_hdr hdr;
757} __packed;
758
759struct cvp_set_device_cmd {
760 struct apr_hdr hdr;
761 struct vss_ivocproc_cmd_set_device_t cvp_set_device;
762} __packed;
763
764struct cvp_set_vp3_data_cmd {
765 struct apr_hdr hdr;
766} __packed;
767
768struct cvp_set_rx_volume_index_cmd {
769 struct apr_hdr hdr;
770 struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx;
771} __packed;
772
Helen Zeng29eb7442011-06-20 11:06:29 -0700773struct cvp_register_cal_data_cmd {
774 struct apr_hdr hdr;
775 struct vss_ivocproc_cmd_register_calibration_data_t cvp_cal_data;
776} __packed;
777
778struct cvp_deregister_cal_data_cmd {
779 struct apr_hdr hdr;
780} __packed;
781
782struct cvp_register_vol_cal_table_cmd {
783 struct apr_hdr hdr;
784 struct vss_ivocproc_cmd_register_volume_cal_table_t cvp_vol_cal_tbl;
785} __packed;
786
787struct cvp_deregister_vol_cal_table_cmd {
788 struct apr_hdr hdr;
789} __packed;
790
Helen Zeng68656932011-11-02 18:08:23 -0700791struct cvp_set_mute_cmd {
792 struct apr_hdr hdr;
793 struct vss_ivocproc_cmd_set_mute_t cvp_set_mute;
794} __packed;
795
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700796/* CB for up-link packets. */
797typedef void (*ul_cb_fn)(uint8_t *voc_pkt,
798 uint32_t pkt_len,
799 void *private_data);
800
801/* CB for down-link packets. */
802typedef void (*dl_cb_fn)(uint8_t *voc_pkt,
803 uint32_t *pkt_len,
804 void *private_data);
805
806
807struct mvs_driver_info {
808 uint32_t media_type;
809 uint32_t rate;
810 uint32_t network_type;
Helen Zengff97bec2012-02-20 14:30:50 -0800811 uint32_t dtx_mode;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700812 ul_cb_fn ul_cb;
813 dl_cb_fn dl_cb;
814 void *private_data;
815};
816
817struct incall_rec_info {
Helen Zenge3d716a2011-10-14 16:32:16 -0700818 uint32_t rec_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700819 uint32_t rec_mode;
Helen Zenge3d716a2011-10-14 16:32:16 -0700820 uint32_t recording;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700821};
822
823struct incall_music_info {
Helen Zeng0705a5f2011-10-14 15:29:52 -0700824 uint32_t play_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700825 uint32_t playing;
Helen Zeng0705a5f2011-10-14 15:29:52 -0700826 int count;
827 int force;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700828};
829
830struct voice_data {
831 int voc_state;/*INIT, CHANGE, RELEASE, RUN */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700832
833 wait_queue_head_t mvm_wait;
834 wait_queue_head_t cvs_wait;
835 wait_queue_head_t cvp_wait;
836
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700837 /* cache the values related to Rx and Tx */
838 struct device_data dev_rx;
839 struct device_data dev_tx;
840
Neema Shetty2c07eb52011-08-21 20:33:52 -0700841 u32 mvm_state;
842 u32 cvs_state;
843 u32 cvp_state;
844
845 /* Handle to MVM in the Q6 */
846 u16 mvm_handle;
847 /* Handle to CVS in the Q6 */
848 u16 cvs_handle;
849 /* Handle to CVP in the Q6 */
850 u16 cvp_handle;
851
852 struct mutex lock;
853
854 uint16_t sidetone_gain;
855 uint8_t tty_mode;
856 /* widevoice enable value */
857 uint8_t wv_enable;
Helen Zengbb49c702011-09-06 14:09:13 -0700858 /* slowtalk enable value */
859 uint32_t st_enable;
Helen Zeng4e531942011-12-17 21:14:40 -0800860 /* FENC enable value */
861 uint32_t fens_enable;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700862
863 struct voice_dev_route_state voc_route_state;
864
865 u16 session_id;
Helen Zenge3d716a2011-10-14 16:32:16 -0700866
867 struct incall_rec_info rec_info;
868
Helen Zeng0705a5f2011-10-14 15:29:52 -0700869 struct incall_music_info music_info;
Helen Zenge3d716a2011-10-14 16:32:16 -0700870
871 struct voice_rec_route_state rec_route_state;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700872};
873
874#define MAX_VOC_SESSIONS 2
875#define SESSION_ID_BASE 0xFFF0
876
877struct common_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700878 /* these default values are for all devices */
879 uint32_t default_mute_val;
880 uint32_t default_vol_val;
881 uint32_t default_sample_val;
882
883 /* APR to MVM in the Q6 */
884 void *apr_q6_mvm;
885 /* APR to CVS in the Q6 */
886 void *apr_q6_cvs;
887 /* APR to CVP in the Q6 */
888 void *apr_q6_cvp;
889
Neema Shetty2c07eb52011-08-21 20:33:52 -0700890 struct mutex common_lock;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700891
892 struct mvs_driver_info mvs_info;
893
Neema Shetty2c07eb52011-08-21 20:33:52 -0700894 struct voice_data voice[MAX_VOC_SESSIONS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700895};
896
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700897void voc_register_mvs_cb(ul_cb_fn ul_cb,
898 dl_cb_fn dl_cb,
899 void *private_data);
900
901void voc_config_vocoder(uint32_t media_type,
902 uint32_t rate,
Helen Zengff97bec2012-02-20 14:30:50 -0800903 uint32_t network_type,
904 uint32_t dtx_mode);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700905
906enum {
907 DEV_RX = 0,
908 DEV_TX,
909};
910
911enum {
912 RX_PATH = 0,
913 TX_PATH,
914};
915
916/* called by alsa driver */
Helen Zeng4e531942011-12-17 21:14:40 -0800917int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable);
918int voc_get_pp_enable(uint16_t session_id, uint32_t module_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700919int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable);
920uint32_t voc_get_widevoice_enable(uint16_t session_id);
921uint8_t voc_get_tty_mode(uint16_t session_id);
922int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode);
923int voc_start_voice_call(uint16_t session_id);
924int voc_end_voice_call(uint16_t session_id);
925int voc_set_rxtx_port(uint16_t session_id,
926 uint32_t dev_port_id,
927 uint32_t dev_type);
928int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t voc_idx);
929int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute);
Helen Zeng68656932011-11-02 18:08:23 -0700930int voc_set_rx_device_mute(uint16_t session_id, uint32_t mute);
931int voc_get_rx_device_mute(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700932int voc_disable_cvp(uint16_t session_id);
933int voc_enable_cvp(uint16_t session_id);
934int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set);
935uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir);
936
937#define VOICE_SESSION_NAME "Voice session"
938#define VOIP_SESSION_NAME "VoIP session"
939uint16_t voc_get_session_id(char *name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700940
Helen Zeng0705a5f2011-10-14 15:29:52 -0700941int voc_start_playback(uint32_t set);
Helen Zenge3d716a2011-10-14 16:32:16 -0700942int voc_start_record(uint32_t port_id, uint32_t set);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700943#endif