Ben Romberger | b760323 | 2011-11-23 17:16:27 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 __Q6AFE_H__ |
| 13 | #define __Q6AFE_H__ |
| 14 | #include <sound/apr_audio.h> |
| 15 | |
Kuirong Wang | 274f21a | 2011-12-15 21:29:08 -0800 | [diff] [blame] | 16 | #define MSM_AFE_MONO 0 |
| 17 | #define MSM_AFE_MONO_RIGHT 1 |
| 18 | #define MSM_AFE_MONO_LEFT 2 |
| 19 | #define MSM_AFE_STEREO 3 |
| 20 | #define MSM_AFE_4CHANNELS 4 |
| 21 | #define MSM_AFE_6CHANNELS 6 |
| 22 | #define MSM_AFE_8CHANNELS 8 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 23 | |
Kuirong Wang | a36f288 | 2012-04-02 19:45:26 -0700 | [diff] [blame] | 24 | #define MSM_AFE_I2S_FORMAT_LPCM 0 |
| 25 | #define MSM_AFE_I2S_FORMAT_COMPR 1 |
| 26 | #define MSM_AFE_I2S_FORMAT_IEC60958_LPCM 2 |
| 27 | #define MSM_AFE_I2S_FORMAT_IEC60958_COMPR 3 |
| 28 | |
Neema Shetty | feea774 | 2011-09-11 12:30:36 -0700 | [diff] [blame] | 29 | #define MSM_AFE_PORT_TYPE_RX 0 |
| 30 | #define MSM_AFE_PORT_TYPE_TX 1 |
| 31 | |
Laxminath Kasam | 32657ec | 2011-08-01 19:26:57 +0530 | [diff] [blame] | 32 | #define RT_PROXY_DAI_001_RX 0xE0 |
| 33 | #define RT_PROXY_DAI_001_TX 0xF0 |
| 34 | #define RT_PROXY_DAI_002_RX 0xF1 |
| 35 | #define RT_PROXY_DAI_002_TX 0xE1 |
| 36 | #define VIRTUAL_ID_TO_PORTID(val) ((val & 0xF) | 0x2000) |
| 37 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 38 | enum { |
| 39 | IDX_PRIMARY_I2S_RX = 0, |
| 40 | IDX_PRIMARY_I2S_TX = 1, |
| 41 | IDX_PCM_RX = 2, |
| 42 | IDX_PCM_TX = 3, |
| 43 | IDX_SECONDARY_I2S_RX = 4, |
| 44 | IDX_SECONDARY_I2S_TX = 5, |
| 45 | IDX_MI2S_RX = 6, |
| 46 | IDX_MI2S_TX = 7, |
| 47 | IDX_HDMI_RX = 8, |
| 48 | IDX_RSVD_2 = 9, |
| 49 | IDX_RSVD_3 = 10, |
| 50 | IDX_DIGI_MIC_TX = 11, |
| 51 | IDX_VOICE_RECORD_RX = 12, |
| 52 | IDX_VOICE_RECORD_TX = 13, |
| 53 | IDX_VOICE_PLAYBACK_TX = 14, |
| 54 | IDX_SLIMBUS_0_RX = 15, |
| 55 | IDX_SLIMBUS_0_TX = 16, |
| 56 | IDX_SLIMBUS_1_RX = 17, |
| 57 | IDX_SLIMBUS_1_TX = 18, |
| 58 | IDX_SLIMBUS_2_RX = 19, |
| 59 | IDX_SLIMBUS_2_TX = 20, |
| 60 | IDX_SLIMBUS_3_RX = 21, |
| 61 | IDX_SLIMBUS_3_TX = 22, |
| 62 | IDX_SLIMBUS_4_RX = 23, |
| 63 | IDX_SLIMBUS_4_TX = 24, |
| 64 | IDX_INT_BT_SCO_RX = 25, |
| 65 | IDX_INT_BT_SCO_TX = 26, |
| 66 | IDX_INT_BT_A2DP_RX = 27, |
| 67 | IDX_INT_FM_RX = 28, |
| 68 | IDX_INT_FM_TX = 29, |
Laxminath Kasam | 32657ec | 2011-08-01 19:26:57 +0530 | [diff] [blame] | 69 | IDX_RT_PROXY_PORT_001_RX = 30, |
| 70 | IDX_RT_PROXY_PORT_001_TX = 31, |
Shiv Maliyappanahalli | a416ee2 | 2012-06-01 16:02:35 -0700 | [diff] [blame] | 71 | IDX_SECONDARY_PCM_RX = 32, |
| 72 | IDX_SECONDARY_PCM_TX = 33, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | AFE_MAX_PORTS |
| 74 | }; |
| 75 | |
| 76 | int afe_open(u16 port_id, union afe_port_config *afe_config, int rate); |
| 77 | int afe_close(int port_id); |
| 78 | int afe_loopback(u16 enable, u16 rx_port, u16 tx_port); |
Neema Shetty | 74131ac | 2012-05-09 13:35:26 -0700 | [diff] [blame] | 79 | int afe_loopback_cfg(u16 enable, u16 dst_port, u16 src_port, u16 mode); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 80 | int afe_sidetone(u16 tx_port_id, u16 rx_port_id, u16 enable, uint16_t gain); |
| 81 | int afe_loopback_gain(u16 port_id, u16 volume); |
| 82 | int afe_validate_port(u16 port_id); |
| 83 | int afe_get_port_index(u16 port_id); |
| 84 | int afe_start_pseudo_port(u16 port_id); |
| 85 | int afe_stop_pseudo_port(u16 port_id); |
Laxminath Kasam | 32657ec | 2011-08-01 19:26:57 +0530 | [diff] [blame] | 86 | int afe_cmd_memory_map(u32 dma_addr_p, u32 dma_buf_sz); |
Ben Romberger | b760323 | 2011-11-23 17:16:27 -0800 | [diff] [blame] | 87 | int afe_cmd_memory_map_nowait(u32 dma_addr_p, u32 dma_buf_sz); |
Laxminath Kasam | 32657ec | 2011-08-01 19:26:57 +0530 | [diff] [blame] | 88 | int afe_cmd_memory_unmap(u32 dma_addr_p); |
Ben Romberger | b760323 | 2011-11-23 17:16:27 -0800 | [diff] [blame] | 89 | int afe_cmd_memory_unmap_nowait(u32 dma_addr_p); |
Laxminath Kasam | 32657ec | 2011-08-01 19:26:57 +0530 | [diff] [blame] | 90 | |
| 91 | int afe_register_get_events(u16 port_id, |
| 92 | void (*cb) (uint32_t opcode, |
| 93 | uint32_t token, uint32_t *payload, void *priv), |
| 94 | void *private_data); |
| 95 | int afe_unregister_get_events(u16 port_id); |
| 96 | int afe_rt_proxy_port_write(u32 buf_addr_p, int bytes); |
| 97 | int afe_rt_proxy_port_read(u32 buf_addr_p, int bytes); |
Patrick Lai | bf97895 | 2012-06-29 09:20:42 -0700 | [diff] [blame] | 98 | int afe_port_start(u16 port_id, union afe_port_config *afe_config, u32 rate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 99 | int afe_port_stop_nowait(int port_id); |
Laxminath Kasam | 885f510 | 2011-07-14 10:20:21 +0530 | [diff] [blame] | 100 | int afe_apply_gain(u16 port_id, u16 gain); |
Jay Wang | 6a30543 | 2011-08-05 16:01:54 -0700 | [diff] [blame] | 101 | int afe_q6_interface_prepare(void); |
Neema Shetty | feea774 | 2011-09-11 12:30:36 -0700 | [diff] [blame] | 102 | int afe_get_port_type(u16 port_id); |
Laxminath Kasam | 32657ec | 2011-08-01 19:26:57 +0530 | [diff] [blame] | 103 | /* if port_id is virtual, convert to physical.. |
| 104 | * if port_id is already physical, return physical |
| 105 | */ |
| 106 | int afe_convert_virtual_to_portid(u16 port_id); |
Jay Wang | 6a30543 | 2011-08-05 16:01:54 -0700 | [diff] [blame] | 107 | |
Helen Zeng | 0705a5f | 2011-10-14 15:29:52 -0700 | [diff] [blame] | 108 | int afe_pseudo_port_start_nowait(u16 port_id); |
| 109 | int afe_pseudo_port_stop_nowait(u16 port_id); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 110 | #endif /* __Q6AFE_H__ */ |