blob: 91cd3b24c5bdeee8f2d596ca56801c96bd93a336 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2* All Rights Reserved
3*
4* MARVELL CONFIDENTIAL
5* Copyright 2012 Marvell International Ltd All Rights Reserved.
6* The source code contained or described herein and all documents related to
7* the source code ("Material") are owned by Marvell International Ltd or its
8* suppliers or licensors. Title to the Material remains with Marvell International Ltd
9* or its suppliers and licensors. The Material contains trade secrets and
10* proprietary and confidential information of Marvell or its suppliers and
11* licensors. The Material is protected by worldwide copyright and trade secret
12* laws and treaty provisions. No part of the Material may be used, copied,
13* reproduced, modified, published, uploaded, posted, transmitted, distributed,
14* or disclosed in any way without Marvell's prior express written permission.
15*
16* No license under any patent, copyright, trade secret or other intellectual
17* property right is granted to or conferred upon you by disclosure or delivery
18* of the Materials, either expressly, by implication, inducement, estoppel or
19* otherwise. Any license under such intellectual property rights must be
20* express and approved by Marvell in writing.
21*
22*/
23
24#ifndef __AUDIO_PATH_MRVL_H__
25#define __AUDIO_PATH_MRVL_H__
26
27#ifdef PXA1826_AUDIO
28/* from acm: */
29#include "audio_protocol.h"
30#define COUPLING_DC 0x00200000
31#define COUPLING_AC 0x00100000
32#define COUPLING_UNKNOWN 0x00000000
33#define CONNECT_SINGLE_ENDED 0x00080000
34#define CONNECT_QUASI_DIFF 0x00040000
35#define CONNECT_DIFF 0x00020000
36#define CONNECT_UNKNOWN 0x00000000
37#endif
38
39///////////////////////////////////////////////////////////
40// definition of Audio Path info for ACM
41///////////////////////////////////////////////////////////
42#define PATH_NAME(e) #e
43
44// Audio path operation methods
45#define INVALID_METHOD_ID 0xFFFFFFFF
46#define METHOD_ENABLE 0x00000001
47#define METHOD_DISABLE 0x00000002
48#define METHOD_MUTE 0x00000003
49#define METHOD_VOLUME_SET 0x00000004
50#define METHOD_SWITCH 0x00000005
51
52// Audio Hardware devices, relative with APU and codec paths
53// Output Device must be defined by order, 1 bit 1 step
54#define HWDEV_INVALID 0xFFFFFFFF
55#define HWDEV_OUT_BASE 0x00000001
56#define HWDEV_EARPIECE (HWDEV_OUT_BASE << 0)
57#define HWDEV_SPEAKER (HWDEV_OUT_BASE << 1)
58#define HWDEV_STEREOSPEAKER (HWDEV_OUT_BASE << 2)
59#define HWDEV_HEADPHONE (HWDEV_OUT_BASE << 3)
60#define HWDEV_BLUETOOTH_NB (HWDEV_OUT_BASE << 4)
61#define HWDEV_BT_NREC_OFF_NB (HWDEV_OUT_BASE << 5)
62#define HWDEV_BLUETOOTH_WB (HWDEV_OUT_BASE << 6)
63#define HWDEV_BT_NREC_OFF_WB (HWDEV_OUT_BASE << 7)
64#define HWDEV_OUT_TTY (HWDEV_OUT_BASE << 8)
65#define HWDEV_OUT_TTY_HCO_SPEAKER (HWDEV_OUT_BASE << 9)
66#define HWDEV_OUT_TTY_HCO_STEREOSPEAKER (HWDEV_OUT_BASE << 10)
67
68
69// Input Device must be defined by order, 1 bit 1 step
70#define HWDEV_BIT_IN 0x80000000
71#define HWDEV_IN_BASE 0x00000001
72#define HWDEV_AMIC1 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 0))
73#define HWDEV_AMIC2 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 1))
74#define HWDEV_DMIC1 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 2))
75#define HWDEV_DMIC2 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 3))
76#define HWDEV_AMIC1_SPK_MODE (HWDEV_BIT_IN | (HWDEV_IN_BASE << 4))
77#define HWDEV_AMIC2_SPK_MODE (HWDEV_BIT_IN | (HWDEV_IN_BASE << 5))
78#define HWDEV_DUAL_DMIC1 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 6))
79#define HWDEV_HSMIC (HWDEV_BIT_IN | (HWDEV_IN_BASE << 7))
80#define HWDEV_BTMIC_NB (HWDEV_BIT_IN | (HWDEV_IN_BASE << 8))
81#define HWDEV_BTMIC_NREC_OFF_NB (HWDEV_BIT_IN | (HWDEV_IN_BASE << 9))
82#define HWDEV_BTMIC_WB (HWDEV_BIT_IN | (HWDEV_IN_BASE << 10))
83#define HWDEV_BTMIC_NREC_OFF_WB (HWDEV_BIT_IN | (HWDEV_IN_BASE << 11))
84#define HWDEV_DUAL_AMIC (HWDEV_BIT_IN | (HWDEV_IN_BASE << 12))
85#define HWDEV_DUAL_AMIC_SPK_MODE (HWDEV_BIT_IN | (HWDEV_IN_BASE << 13))
86#define HWDEV_IN_TTY (HWDEV_BIT_IN | (HWDEV_IN_BASE << 14))
87#define HWDEV_IN_TTY_VCO (HWDEV_BIT_IN | (HWDEV_IN_BASE << 15))
88#define HWDEV_IN_TTY_VCO_AMIC1 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 16))
89#define HWDEV_IN_TTY_VCO_AMIC2 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 17))
90#define HWDEV_IN_TTY_VCO_DUAL_AMIC (HWDEV_BIT_IN | (HWDEV_IN_BASE << 18))
91#define HWDEV_IN_TTY_VCO_DUAL_AMIC_SPK_MODE (HWDEV_BIT_IN | (HWDEV_IN_BASE << 19))
92#define HWDEV_IN_TTY_VCO_DUAL_DMIC1 (HWDEV_BIT_IN | (HWDEV_IN_BASE << 20))
93
94// Mic Name, used to parse platform config xml
95static char *input_devname[] = {
96 "AMIC1",
97 "AMIC2",
98 "DMIC1",
99 "DMIC2",
100 "AMIC1_SPK_MODE",
101 "AMIC2_SPK_MODE",
102 "DUAL_DMIC1",
103 "HSMIC",
104 "BTMIC_NB",
105 "BTMIC_NREC_OFF_NB",
106 "BTMIC_WB",
107 "BTMIC_NREC_OFF_WB",
108 "DUAL_AMIC",
109 "DUAL_AMIC_SPK_MODE"
110};
111
112/* mic mode in marvell settings */
113enum mic_modes {
114 MIC_MODE_NONE = 0,
115 MIC_MODE_MIC1,
116 MIC_MODE_MIC2,
117 MIC_MODE_DUALMIC
118};
119
120/* mic mode to dev name conversion table */
121static const char* mic_mode_to_dev_name[] = {
122 "\0", /*MIC_MODE_NONE=0*/
123 "AMIC1", /*MIC_MODE_MIC1=1*/
124 "AMIC2", /*MIC_MODE_MIC2=2*/
125 "DUAL_AMIC" /*MIC_MODE_DUALMIC=3*/
126};
127
128#ifdef PXA1826_AUDIO
129/* RECOGNITION defined in acm/audio_protocol.h */
130#else
131#define RECOGNITION 0x00010000
132#endif
133
134#define MSA_GAIN_DEFAULT 0
135
136// path type definition
137typedef enum ID_AUDIO_PATH_TYPE{
138 ID_PTYPE_INVALID,
139 ID_PTYPE_INTERFACE = 1, // Playback input path and Record output path
140 ID_PTYPE_DEVICE, // Playback output path and Record input path
141 ID_PTYPE_VIRTUAL, // Virtual path
142 ID_PTYPE_MAX
143}path_type_t;
144
145// define both playback input path and record output path
146typedef enum ID_INTERFACE_PATH{
147 ID_IPATH_INVALID = -1,
148 ID_IPATH_RX_MIN,
149 ID_IPATH_RX_HIFI_LL = ID_IPATH_RX_MIN, // low latency
150 ID_IPATH_RX_HIFI_DB, // deep buffer
151 ID_IPATH_RX_VC, // voice call
152 ID_IPATH_RX_VC_ST, // sidetone
153 ID_IPATH_RX_HFP, // HFP
154 ID_IPATH_RX_FM, // FM
155 ID_IPATH_RX_MAX = ID_IPATH_RX_FM,
156 ID_IPATH_TX_MIN,
157 ID_IPATH_TX_HIFI = ID_IPATH_TX_MIN, // hifi recording
158 ID_IPATH_TX_VC, // voice call
159 ID_IPATH_TX_HFP, // HFP
160 ID_IPATH_TX_FM, // FM recording
161 ID_IPATH_TX_MAX = ID_IPATH_TX_FM,
162}path_interface_t;
163
164// virtual mode definition, only used for virtual path
165typedef enum ID_VIRTUAL_MODE{
166 V_MODE_INVALID = 0,
167 V_MODE_HIFI_LL, // both input and output
168 V_MODE_HIFI_DB, // only have one direction, output
169 V_MODE_VC, // phone mode in AUDIO_MODE_IN_CALL
170 V_MODE_VOIP, // AUDIO_MODE_IN_COMMUNICATION
171 V_MODE_VT, // AUDIO_MODE_IN_VT_CALL
172 V_MODE_HFP, // HFP mode in AUDIO_MODE_IN_CALL
173 V_MODE_FM, // when FM_STATUS=on
174 V_MODE_DEF // add for default config to choose HW device
175}virtual_mode_t;
176
177// the priorities of modes configuration
178struct vtrl_mode_priority_cfg {
179 path_interface_t path_interface;
180 audio_mode_t audio_mode;
181 virtual_mode_t v_mode;
182};
183
184// used to parse config xml, must align with ID_VIRTUAL_MODE
185// add a new type Default, will be used when nothing matched
186static char *vtrl_mode_name[] = {
187 "INVALID",
188 "HIFI_LL",
189 "HIFI_DB",
190 "VoiceCall",
191 "VoIP",
192 "VT",
193 "HFP",
194 "FM",
195 "Default"
196};
197
198
199///////////////////////////////////////////////////////////
200// definition of Audio Platform config interface
201///////////////////////////////////////////////////////////
202unsigned int get_mic_hw_flag(unsigned int hw_dev);
203unsigned int get_mic_dev(virtual_mode_t v_mode, unsigned int android_dev);
204unsigned int get_speaker_dev(virtual_mode_t v_mode, unsigned int android_dev);
205int init_platform_config();
206void deinit_platform_config();
207uint32_t get_mic_mode(void);
208
209
210///////////////////////////////////////////////////////////
211// definition of Audio path interface
212///////////////////////////////////////////////////////////
213#ifdef PXA1826_AUDIO ////Enable virtual path
214char *get_vrtl_path(virtual_mode_t mode, unsigned int device, unsigned int value);
215#else
216char *get_device_path(unsigned int device, unsigned int value);
217#endif
218#ifdef PXA1826_AUDIO ////Enable virtual path
219void route_vrtl_path(virtual_mode_t v_mode, int hw_dev, int enable, unsigned int flag,
220 unsigned int value);
221#endif
222void route_hw_device(unsigned int hw_dev, int enable, unsigned int value);
223#ifdef PXA1826_AUDIO ////Enable virtual path
224void set_hw_volume(virtual_mode_t v_mode, int hw_dev, unsigned int value);
225#else
226void set_hw_volume_by_device(int hw_dev, unsigned int value);
227#endif
228
229void get_msa_gain(unsigned int out_hw_dev, unsigned int hw_dev, unsigned char volume,
230 signed char *msa_gain, signed char *msa_gain_wb, signed char *sidetone_gain, signed char *sidetone_gain_wb, bool use_extra_vol);
231#endif