blob: d330adade8ebd31d1b40c6b6a1181c3bddae5376 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
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 Zengbb49c702011-09-06 14:09:13 -0700326#define MODULE_ID_VOICE_MODULE_ST 0x00010EE3
327#define VOICE_PARAM_MOD_ENABLE 0x00010E00
328#define MOD_ENABLE_PARAM_LEN 4
329
Helen Zeng0705a5f2011-10-14 15:29:52 -0700330#define VSS_ISTREAM_CMD_START_PLAYBACK 0x00011238
331/* Start in-call music delivery on the Tx voice path. */
332
333#define VSS_ISTREAM_CMD_STOP_PLAYBACK 0x00011239
334/* Stop the in-call music delivery on the Tx voice path. */
335
Helen Zenge3d716a2011-10-14 16:32:16 -0700336#define VSS_ISTREAM_CMD_START_RECORD 0x00011236
337/* Start in-call conversation recording. */
338#define VSS_ISTREAM_CMD_STOP_RECORD 0x00011237
339/* Stop in-call conversation recording. */
340
341#define VSS_TAP_POINT_NONE 0x00010F78
342/* Indicates no tapping for specified path. */
343
344#define VSS_TAP_POINT_STREAM_END 0x00010F79
345/* Indicates that specified path should be tapped at the end of the stream. */
346
347struct vss_istream_cmd_start_record_t {
348 uint32_t rx_tap_point;
349 /* Tap point to use on the Rx path. Supported values are:
350 * VSS_TAP_POINT_NONE : Do not record Rx path.
351 * VSS_TAP_POINT_STREAM_END : Rx tap point is at the end of the stream.
352 */
353 uint32_t tx_tap_point;
354 /* Tap point to use on the Tx path. Supported values are:
355 * VSS_TAP_POINT_NONE : Do not record tx path.
356 * VSS_TAP_POINT_STREAM_END : Tx tap point is at the end of the stream.
357 */
358} __packed;
359
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700360struct vss_istream_cmd_create_passive_control_session_t {
Helen Zeng69b00962011-07-08 11:38:36 -0700361 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700362 /**<
363 * A variable-sized stream name.
364 *
365 * The stream name size is the payload size minus the size of the other
366 * fields.
367 */
368} __packed;
369
370struct vss_istream_cmd_set_mute_t {
371 uint16_t direction;
372 /**<
373 * 0 : TX only
374 * 1 : RX only
375 * 2 : TX and Rx
376 */
377 uint16_t mute_flag;
378 /**<
379 * Mute, un-mute.
380 *
381 * 0 : Silence disable
382 * 1 : Silence enable
383 * 2 : CNG enable. Applicable to TX only. If set on RX behavior
384 * will be the same as 1
385 */
386} __packed;
387
388struct vss_istream_cmd_create_full_control_session_t {
389 uint16_t direction;
390 /*
391 * Stream direction.
392 *
393 * 0 : TX only
394 * 1 : RX only
395 * 2 : TX and RX
396 * 3 : TX and RX loopback
397 */
398 uint32_t enc_media_type;
399 /* Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
400 uint32_t dec_media_type;
401 /* Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
402 uint32_t network_id;
403 /* Network ID. (Refer to VSS_NETWORK_ID_XXX). */
Helen Zeng69b00962011-07-08 11:38:36 -0700404 char name[SESSION_NAME_LEN];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700405 /*
406 * A variable-sized stream name.
407 *
408 * The stream name size is the payload size minus the size of the other
409 * fields.
410 */
411} __packed;
412
413struct vss_istream_cmd_set_media_type_t {
414 uint32_t rx_media_id;
415 /* Set the Rx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
416 uint32_t tx_media_id;
417 /* Set the Tx vocoder type. (Refer to VSS_MEDIA_ID_XXX). */
418} __packed;
419
420struct vss_istream_evt_send_enc_buffer_t {
421 uint32_t media_id;
422 /* Media ID of the packet. */
423 uint8_t packet_data[MAX_VOC_PKT_SIZE];
424 /* Packet data buffer. */
425} __packed;
426
427struct vss_istream_evt_send_dec_buffer_t {
428 uint32_t media_id;
429 /* Media ID of the packet. */
430 uint8_t packet_data[MAX_VOC_PKT_SIZE];
431 /* Packet data. */
432} __packed;
433
434struct vss_istream_cmd_voc_amr_set_enc_rate_t {
435 uint32_t mode;
436 /* Set the AMR encoder rate.
437 *
438 * 0x00000000 : 4.75 kbps
439 * 0x00000001 : 5.15 kbps
440 * 0x00000002 : 5.90 kbps
441 * 0x00000003 : 6.70 kbps
442 * 0x00000004 : 7.40 kbps
443 * 0x00000005 : 7.95 kbps
444 * 0x00000006 : 10.2 kbps
445 * 0x00000007 : 12.2 kbps
446 */
447} __packed;
448
449struct vss_istream_cmd_voc_amrwb_set_enc_rate_t {
450 uint32_t mode;
451 /* Set the AMR-WB encoder rate.
452 *
453 * 0x00000000 : 6.60 kbps
454 * 0x00000001 : 8.85 kbps
455 * 0x00000002 : 12.65 kbps
456 * 0x00000003 : 14.25 kbps
457 * 0x00000004 : 15.85 kbps
458 * 0x00000005 : 18.25 kbps
459 * 0x00000006 : 19.85 kbps
460 * 0x00000007 : 23.05 kbps
461 * 0x00000008 : 23.85 kbps
462 */
463} __packed;
464
465struct vss_istream_cmd_cdma_set_enc_minmax_rate_t {
466 uint16_t min_rate;
467 /* Set the lower bound encoder rate.
468 *
469 * 0x0000 : Blank frame
470 * 0x0001 : Eighth rate
471 * 0x0002 : Quarter rate
472 * 0x0003 : Half rate
473 * 0x0004 : Full rate
474 */
475 uint16_t max_rate;
476 /* Set the upper bound encoder rate.
477 *
478 * 0x0000 : Blank frame
479 * 0x0001 : Eighth rate
480 * 0x0002 : Quarter rate
481 * 0x0003 : Half rate
482 * 0x0004 : Full rate
483 */
484} __packed;
485
486struct vss_istream_cmd_set_enc_dtx_mode_t {
487 uint32_t enable;
488 /* Toggle DTX on or off.
489 *
490 * 0 : Disables DTX
491 * 1 : Enables DTX
492 */
493} __packed;
494
Helen Zeng29eb7442011-06-20 11:06:29 -0700495struct vss_istream_cmd_register_calibration_data_t {
496 uint32_t phys_addr;
497 /* Phsical address to be registered with stream. The calibration data
498 * is stored at this address.
499 */
500 uint32_t mem_size;
501 /* Size of the calibration data in bytes. */
502};
503
Helen Zengbb49c702011-09-06 14:09:13 -0700504struct vss_icommon_cmd_set_ui_property_st_enable_t {
505 uint32_t module_id;
506 /* Unique ID of the module. */
507 uint32_t param_id;
508 /* Unique ID of the parameter. */
509 uint16_t param_size;
510 /* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */
511 uint16_t reserved;
512 /* Reserved; set to 0. */
513 uint16_t enable;
514 uint16_t reserved_field;
515 /* Reserved, set to 0. */
516};
517
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700518struct cvs_create_passive_ctl_session_cmd {
519 struct apr_hdr hdr;
520 struct vss_istream_cmd_create_passive_control_session_t cvs_session;
521} __packed;
522
523struct cvs_create_full_ctl_session_cmd {
524 struct apr_hdr hdr;
525 struct vss_istream_cmd_create_full_control_session_t cvs_session;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700526} __packed;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700527
528struct cvs_destroy_session_cmd {
529 struct apr_hdr hdr;
530} __packed;
531
532struct cvs_set_mute_cmd {
533 struct apr_hdr hdr;
534 struct vss_istream_cmd_set_mute_t cvs_set_mute;
535} __packed;
536
537struct cvs_set_media_type_cmd {
538 struct apr_hdr hdr;
539 struct vss_istream_cmd_set_media_type_t media_type;
540} __packed;
541
542struct cvs_send_dec_buf_cmd {
543 struct apr_hdr hdr;
544 struct vss_istream_evt_send_dec_buffer_t dec_buf;
545} __packed;
546
547struct cvs_set_amr_enc_rate_cmd {
548 struct apr_hdr hdr;
549 struct vss_istream_cmd_voc_amr_set_enc_rate_t amr_rate;
550} __packed;
551
552struct cvs_set_amrwb_enc_rate_cmd {
553 struct apr_hdr hdr;
554 struct vss_istream_cmd_voc_amrwb_set_enc_rate_t amrwb_rate;
555} __packed;
556
557struct cvs_set_cdma_enc_minmax_rate_cmd {
558 struct apr_hdr hdr;
559 struct vss_istream_cmd_cdma_set_enc_minmax_rate_t cdma_rate;
560} __packed;
561
562struct cvs_set_enc_dtx_mode_cmd {
563 struct apr_hdr hdr;
564 struct vss_istream_cmd_set_enc_dtx_mode_t dtx_mode;
565} __packed;
566
Helen Zeng29eb7442011-06-20 11:06:29 -0700567struct cvs_register_cal_data_cmd {
568 struct apr_hdr hdr;
569 struct vss_istream_cmd_register_calibration_data_t cvs_cal_data;
570} __packed;
571
572struct cvs_deregister_cal_data_cmd {
573 struct apr_hdr hdr;
574} __packed;
575
Helen Zengbb49c702011-09-06 14:09:13 -0700576struct cvs_set_slowtalk_enable_cmd {
577 struct apr_hdr hdr;
578 struct vss_icommon_cmd_set_ui_property_st_enable_t vss_set_st;
579} __packed;
Helen Zenge3d716a2011-10-14 16:32:16 -0700580struct cvs_start_record_cmd {
581 struct apr_hdr hdr;
582 struct vss_istream_cmd_start_record_t rec_mode;
583} __packed;
Helen Zengbb49c702011-09-06 14:09:13 -0700584
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700585/* TO CVP commands */
586
587#define VSS_IVOCPROC_CMD_CREATE_FULL_CONTROL_SESSION 0x000100C3
588/**< Wait for APRV2_IBASIC_RSP_RESULT response. */
589
590#define APRV2_IBASIC_CMD_DESTROY_SESSION 0x0001003C
591
592#define VSS_IVOCPROC_CMD_SET_DEVICE 0x000100C4
593
594#define VSS_IVOCPROC_CMD_SET_VP3_DATA 0x000110EB
595
596#define VSS_IVOCPROC_CMD_SET_RX_VOLUME_INDEX 0x000110EE
597
598#define VSS_IVOCPROC_CMD_ENABLE 0x000100C6
599/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
600
601#define VSS_IVOCPROC_CMD_DISABLE 0x000110E1
602/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
603
Helen Zeng29eb7442011-06-20 11:06:29 -0700604#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA 0x00011275
605#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276
606
607#define VSS_IVOCPROC_CMD_REGISTER_VOLUME_CAL_TABLE 0x00011277
608#define VSS_IVOCPROC_CMD_DEREGISTER_VOLUME_CAL_TABLE 0x00011278
609
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700610#define VSS_IVOCPROC_TOPOLOGY_ID_NONE 0x00010F70
611#define VSS_IVOCPROC_TOPOLOGY_ID_TX_SM_ECNS 0x00010F71
612#define VSS_IVOCPROC_TOPOLOGY_ID_TX_DM_FLUENCE 0x00010F72
613
614#define VSS_IVOCPROC_TOPOLOGY_ID_RX_DEFAULT 0x00010F77
615
616/* Newtwork IDs */
617#define VSS_NETWORK_ID_DEFAULT 0x00010037
618#define VSS_NETWORK_ID_VOIP_NB 0x00011240
619#define VSS_NETWORK_ID_VOIP_WB 0x00011241
620#define VSS_NETWORK_ID_VOIP_WV 0x00011242
621
622/* Media types */
623#define VSS_MEDIA_ID_EVRC_MODEM 0x00010FC2
624/* 80-VF690-47 CDMA enhanced variable rate vocoder modem format. */
625#define VSS_MEDIA_ID_AMR_NB_MODEM 0x00010FC6
626/* 80-VF690-47 UMTS AMR-NB vocoder modem format. */
627#define VSS_MEDIA_ID_AMR_WB_MODEM 0x00010FC7
628/* 80-VF690-47 UMTS AMR-WB vocoder modem format. */
629#define VSS_MEDIA_ID_PCM_NB 0x00010FCB
630#define VSS_MEDIA_ID_PCM_WB 0x00010FCC
631/* Linear PCM (16-bit, little-endian). */
632#define VSS_MEDIA_ID_G711_ALAW 0x00010FCD
633/* G.711 a-law (contains two 10ms vocoder frames). */
634#define VSS_MEDIA_ID_G711_MULAW 0x00010FCE
635/* G.711 mu-law (contains two 10ms vocoder frames). */
636#define VSS_MEDIA_ID_G729 0x00010FD0
637/* G.729AB (contains two 10ms vocoder frames. */
638
639#define VOICE_CMD_SET_PARAM 0x00011006
640#define VOICE_CMD_GET_PARAM 0x00011007
641#define VOICE_EVT_GET_PARAM_ACK 0x00011008
642
643struct vss_ivocproc_cmd_create_full_control_session_t {
644 uint16_t direction;
645 /*
646 * stream direction.
647 * 0 : TX only
648 * 1 : RX only
649 * 2 : TX and RX
650 */
651 uint32_t tx_port_id;
652 /*
653 * TX device port ID which vocproc will connect to. If not supplying a
654 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
655 */
656 uint32_t tx_topology_id;
657 /*
658 * Tx leg topology ID. If not supplying a topology ID set to
659 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
660 */
661 uint32_t rx_port_id;
662 /*
663 * RX device port ID which vocproc will connect to. If not supplying a
664 * port ID set to VSS_IVOCPROC_PORT_ID_NONE.
665 */
666 uint32_t rx_topology_id;
667 /*
668 * Rx leg topology ID. If not supplying a topology ID set to
669 * VSS_IVOCPROC_TOPOLOGY_ID_NONE.
670 */
671 int32_t network_id;
672 /*
673 * Network ID. (Refer to VSS_NETWORK_ID_XXX). If not supplying a network
674 * ID set to VSS_NETWORK_ID_DEFAULT.
675 */
676} __packed;
677
678struct vss_ivocproc_cmd_set_volume_index_t {
679 uint16_t vol_index;
680 /**<
681 * Volume index utilized by the vocproc to index into the volume table
682 * provided in VSS_IVOCPROC_CMD_CACHE_VOLUME_CALIBRATION_TABLE and set
683 * volume on the VDSP.
684 */
685} __packed;
686
687struct vss_ivocproc_cmd_set_device_t {
688 uint32_t tx_port_id;
689 /**<
690 * TX device port ID which vocproc will connect to.
691 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
692 */
693 uint32_t tx_topology_id;
694 /**<
695 * TX leg topology ID.
696 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
697 * pre/post-processing blocks and is pass-through.
698 */
699 int32_t rx_port_id;
700 /**<
701 * RX device port ID which vocproc will connect to.
702 * VSS_IVOCPROC_PORT_ID_NONE means vocproc will not connect to any port.
703 */
704 uint32_t rx_topology_id;
705 /**<
706 * RX leg topology ID.
707 * VSS_IVOCPROC_TOPOLOGY_ID_NONE means vocproc does not contain any
708 * pre/post-processing blocks and is pass-through.
709 */
710} __packed;
711
Helen Zeng29eb7442011-06-20 11:06:29 -0700712struct vss_ivocproc_cmd_register_calibration_data_t {
713 uint32_t phys_addr;
714 /* Phsical address to be registered with vocproc. Calibration data
715 * is stored at this address.
716 */
717 uint32_t mem_size;
718 /* Size of the calibration data in bytes. */
719} __packed;
720
721struct vss_ivocproc_cmd_register_volume_cal_table_t {
722 uint32_t phys_addr;
723 /* Phsical address to be registered with the vocproc. The volume
724 * calibration table is stored at this location.
725 */
726
727 uint32_t mem_size;
728 /* Size of the volume calibration table in bytes. */
729} __packed;
730
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700731struct cvp_create_full_ctl_session_cmd {
732 struct apr_hdr hdr;
733 struct vss_ivocproc_cmd_create_full_control_session_t cvp_session;
734} __packed;
735
736struct cvp_command {
737 struct apr_hdr hdr;
738} __packed;
739
740struct cvp_set_device_cmd {
741 struct apr_hdr hdr;
742 struct vss_ivocproc_cmd_set_device_t cvp_set_device;
743} __packed;
744
745struct cvp_set_vp3_data_cmd {
746 struct apr_hdr hdr;
747} __packed;
748
749struct cvp_set_rx_volume_index_cmd {
750 struct apr_hdr hdr;
751 struct vss_ivocproc_cmd_set_volume_index_t cvp_set_vol_idx;
752} __packed;
753
Helen Zeng29eb7442011-06-20 11:06:29 -0700754struct cvp_register_cal_data_cmd {
755 struct apr_hdr hdr;
756 struct vss_ivocproc_cmd_register_calibration_data_t cvp_cal_data;
757} __packed;
758
759struct cvp_deregister_cal_data_cmd {
760 struct apr_hdr hdr;
761} __packed;
762
763struct cvp_register_vol_cal_table_cmd {
764 struct apr_hdr hdr;
765 struct vss_ivocproc_cmd_register_volume_cal_table_t cvp_vol_cal_tbl;
766} __packed;
767
768struct cvp_deregister_vol_cal_table_cmd {
769 struct apr_hdr hdr;
770} __packed;
771
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700772/* CB for up-link packets. */
773typedef void (*ul_cb_fn)(uint8_t *voc_pkt,
774 uint32_t pkt_len,
775 void *private_data);
776
777/* CB for down-link packets. */
778typedef void (*dl_cb_fn)(uint8_t *voc_pkt,
779 uint32_t *pkt_len,
780 void *private_data);
781
782
783struct mvs_driver_info {
784 uint32_t media_type;
785 uint32_t rate;
786 uint32_t network_type;
787 ul_cb_fn ul_cb;
788 dl_cb_fn dl_cb;
789 void *private_data;
790};
791
792struct incall_rec_info {
Helen Zenge3d716a2011-10-14 16:32:16 -0700793 uint32_t rec_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700794 uint32_t rec_mode;
Helen Zenge3d716a2011-10-14 16:32:16 -0700795 uint32_t recording;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700796};
797
798struct incall_music_info {
Helen Zeng0705a5f2011-10-14 15:29:52 -0700799 uint32_t play_enable;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700800 uint32_t playing;
Helen Zeng0705a5f2011-10-14 15:29:52 -0700801 int count;
802 int force;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700803};
804
805struct voice_data {
806 int voc_state;/*INIT, CHANGE, RELEASE, RUN */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700807
808 wait_queue_head_t mvm_wait;
809 wait_queue_head_t cvs_wait;
810 wait_queue_head_t cvp_wait;
811
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700812 /* cache the values related to Rx and Tx */
813 struct device_data dev_rx;
814 struct device_data dev_tx;
815
Neema Shetty2c07eb52011-08-21 20:33:52 -0700816 u32 mvm_state;
817 u32 cvs_state;
818 u32 cvp_state;
819
820 /* Handle to MVM in the Q6 */
821 u16 mvm_handle;
822 /* Handle to CVS in the Q6 */
823 u16 cvs_handle;
824 /* Handle to CVP in the Q6 */
825 u16 cvp_handle;
826
827 struct mutex lock;
828
829 uint16_t sidetone_gain;
830 uint8_t tty_mode;
831 /* widevoice enable value */
832 uint8_t wv_enable;
Helen Zengbb49c702011-09-06 14:09:13 -0700833 /* slowtalk enable value */
834 uint32_t st_enable;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700835
836 struct voice_dev_route_state voc_route_state;
837
838 u16 session_id;
Helen Zenge3d716a2011-10-14 16:32:16 -0700839
840 struct incall_rec_info rec_info;
841
Helen Zeng0705a5f2011-10-14 15:29:52 -0700842 struct incall_music_info music_info;
Helen Zenge3d716a2011-10-14 16:32:16 -0700843
844 struct voice_rec_route_state rec_route_state;
Neema Shetty2c07eb52011-08-21 20:33:52 -0700845};
846
847#define MAX_VOC_SESSIONS 2
848#define SESSION_ID_BASE 0xFFF0
849
850struct common_data {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700851 /* these default values are for all devices */
852 uint32_t default_mute_val;
853 uint32_t default_vol_val;
854 uint32_t default_sample_val;
855
856 /* APR to MVM in the Q6 */
857 void *apr_q6_mvm;
858 /* APR to CVS in the Q6 */
859 void *apr_q6_cvs;
860 /* APR to CVP in the Q6 */
861 void *apr_q6_cvp;
862
Neema Shetty2c07eb52011-08-21 20:33:52 -0700863 struct mutex common_lock;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700864
865 struct mvs_driver_info mvs_info;
866
Neema Shetty2c07eb52011-08-21 20:33:52 -0700867 struct voice_data voice[MAX_VOC_SESSIONS];
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700868};
869
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700870void voc_register_mvs_cb(ul_cb_fn ul_cb,
871 dl_cb_fn dl_cb,
872 void *private_data);
873
874void voc_config_vocoder(uint32_t media_type,
875 uint32_t rate,
876 uint32_t network_type);
877
878enum {
879 DEV_RX = 0,
880 DEV_TX,
881};
882
883enum {
884 RX_PATH = 0,
885 TX_PATH,
886};
887
888/* called by alsa driver */
Helen Zengbb49c702011-09-06 14:09:13 -0700889int voc_set_slowtalk_enable(uint16_t session_id, uint32_t st_enable);
890uint32_t voc_get_slowtalk_enable(uint16_t session_id);
Neema Shetty2c07eb52011-08-21 20:33:52 -0700891int voc_set_widevoice_enable(uint16_t session_id, uint32_t wv_enable);
892uint32_t voc_get_widevoice_enable(uint16_t session_id);
893uint8_t voc_get_tty_mode(uint16_t session_id);
894int voc_set_tty_mode(uint16_t session_id, uint8_t tty_mode);
895int voc_start_voice_call(uint16_t session_id);
896int voc_end_voice_call(uint16_t session_id);
897int voc_set_rxtx_port(uint16_t session_id,
898 uint32_t dev_port_id,
899 uint32_t dev_type);
900int voc_set_rx_vol_index(uint16_t session_id, uint32_t dir, uint32_t voc_idx);
901int voc_set_tx_mute(uint16_t session_id, uint32_t dir, uint32_t mute);
902int voc_disable_cvp(uint16_t session_id);
903int voc_enable_cvp(uint16_t session_id);
904int voc_set_route_flag(uint16_t session_id, uint8_t path_dir, uint8_t set);
905uint8_t voc_get_route_flag(uint16_t session_id, uint8_t path_dir);
906
907#define VOICE_SESSION_NAME "Voice session"
908#define VOIP_SESSION_NAME "VoIP session"
909uint16_t voc_get_session_id(char *name);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700910
Helen Zeng0705a5f2011-10-14 15:29:52 -0700911int voc_start_playback(uint32_t set);
Helen Zenge3d716a2011-10-14 16:32:16 -0700912int voc_start_record(uint32_t port_id, uint32_t set);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700913#endif