Merge tag 'v3.10.55' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-mt8127 / tcl8127_tb_c_l / sound / yusu_android_speaker.c
CommitLineData
6fa3eb70
S
1/*****************************************************************************
2* E X T E R N A L R E F E R E N C E S
3******************************************************************************
4*/
5
6#include <linux/kernel.h>
7#include <linux/module.h>
8#include <linux/init.h>
9#include <linux/device.h>
10#include <linux/slab.h>
11#include <linux/fs.h>
12#include <linux/mm.h>
13#include <linux/interrupt.h>
14#include <linux/vmalloc.h>
15#include <linux/platform_device.h>
16#include <linux/miscdevice.h>
17#include <linux/wait.h>
18#include <linux/spinlock.h>
19#include <linux/semaphore.h>
20#include <asm/uaccess.h>
21#include <linux/delay.h>
22#include "yusu_android_speaker.h"
23
24/*****************************************************************************
25* C O M P I L E R F L A G S
26******************************************************************************
27*/
28//#define CONFIG_DEBUG_MSG
29#ifdef CONFIG_DEBUG_MSG
30#define PRINTK(format, args...) printk( KERN_EMERG format,##args )
31#else
32#define PRINTK(format, args...)
33#endif
34
35#define AMP_CLASS_AB
36//#define AMP_CLASS_D
37//#define ENABLE_2_IN_1_SPK
38
39#if !defined(AMP_CLASS_AB) && !defined(AMP_CLASS_D)
40#error "MT6323 SPK AMP TYPE does not be defined!!!"
41#endif
42/*****************************************************************************
43* C O N S T A N T S
44******************************************************************************
45*/
46
47#define SPK_WARM_UP_TIME (55) //unit is ms
48#define SPK_AMP_GAIN (4) //4:15dB
49#define RCV_AMP_GAIN (1) //1:-3dB
50#define SPK_R_ENABLE (1)
51#define SPK_L_ENABLE (1)
52/*****************************************************************************
53* D A T A T Y P E S
54******************************************************************************
55*/
56static int Speaker_Volume=0;
57static bool gsk_on=false; // speaker is open?
58static bool gsk_resume=false;
59static bool gsk_forceon=false;
60/*****************************************************************************
61* F U N C T I O N D E F I N I T I O N
62******************************************************************************
63*/
64extern void Yusu_Sound_AMP_Switch(BOOL enable);
65
66bool Speaker_Init(void)
67{
68 PRINTK("+Speaker_Init Success");
69#if defined(AMP_CLASS_AB)
70
71#elif defined(AMP_CLASS_D)
72
73#endif
74
75 PRINTK("-Speaker_Init Success");
76 return true;
77}
78
79bool Speaker_Register(void)
80{
81 return false;
82}
83
84int ExternalAmp(void)
85{
86 return 0;
87}
88
89bool Speaker_DeInit(void)
90{
91 return false;
92}
93
94void Sound_SpeakerL_SetVolLevel(int level)
95{
96 PRINTK(" Sound_SpeakerL_SetVolLevel level=%d\n",level);
97}
98
99void Sound_SpeakerR_SetVolLevel(int level)
100{
101 PRINTK(" Sound_SpeakerR_SetVolLevel level=%d\n",level);
102}
103
104void Sound_Speaker_Turnon(int channel)
105{
106 PRINTK("Sound_Speaker_Turnon channel = %d\n",channel);
107 if(gsk_on)
108 return;
109#if defined(ENABLE_2_IN_1_SPK)
110#if defined(AMP_CLASS_D)
111
112#endif
113#endif
114#if defined(AMP_CLASS_AB)
115
116#elif defined(AMP_CLASS_D)
117
118#endif
119 //msleep(SPK_WARM_UP_TIME);
120 gsk_on = true;
121}
122
123void Sound_Speaker_Turnoff(int channel)
124{
125 PRINTK("Sound_Speaker_Turnoff channel = %d\n",channel);
126 if(!gsk_on)
127 return;
128#if defined(AMP_CLASS_AB)
129
130#elif defined(AMP_CLASS_D)
131
132#endif
133 gsk_on = false;
134}
135
136void Sound_Speaker_SetVolLevel(int level)
137{
138 Speaker_Volume =level;
139}
140
141void Sound_Headset_Turnon(void)
142{
143}
144
145void Sound_Headset_Turnoff(void)
146{
147}
148
149void Sound_Earpiece_Turnon(void)
150{
151#if defined(ENABLE_2_IN_1_SPK)
152
153#if defined(AMP_CLASS_D)
154
155#endif
156
157#endif
158}
159
160void Sound_Earpiece_Turnoff(void)
161{
162#if defined(ENABLE_2_IN_1_SPK)
163
164#if defined(AMP_CLASS_D)
165
166#endif
167
168#endif
169}
170
171//kernal use
172void AudioAMPDevice_Suspend(void)
173{
174 PRINTK("AudioDevice_Suspend\n");
175 if(gsk_on)
176 {
177 Sound_Speaker_Turnoff(Channel_Stereo);
178 gsk_resume = true;
179 }
180
181}
182void AudioAMPDevice_Resume(void)
183{
184 PRINTK("AudioDevice_Resume\n");
185 if(gsk_resume)
186 Sound_Speaker_Turnon(Channel_Stereo);
187 gsk_resume = false;
188}
189void AudioAMPDevice_SpeakerLouderOpen(void)
190{
191 PRINTK("AudioDevice_SpeakerLouderOpen\n");
192 gsk_forceon = false;
193 if(gsk_on)
194 return;
195 Sound_Speaker_Turnon(Channel_Stereo);
196 gsk_forceon = true;
197 return ;
198
199}
200void AudioAMPDevice_SpeakerLouderClose(void)
201{
202 PRINTK("AudioDevice_SpeakerLouderClose\n");
203
204 if(gsk_forceon)
205 Sound_Speaker_Turnoff(Channel_Stereo);
206 gsk_forceon = false;
207
208}
209void AudioAMPDevice_mute(void)
210{
211 PRINTK("AudioDevice_mute\n");
212 if(gsk_on)
213 Sound_Speaker_Turnoff(Channel_Stereo);
214}
215
216int Audio_eamp_command(unsigned int type, unsigned long args, unsigned int count)
217{
218 return 0;
219}
220static char *ExtFunArray[] =
221{
222 "InfoMATVAudioStart",
223 "InfoMATVAudioStop",
224 "End",
225};
226
227kal_int32 Sound_ExtFunction(const char* name, void* param, int param_size)
228{
229 int i = 0;
230 int funNum = -1;
231
232 //Search the supported function defined in ExtFunArray
233 while(strcmp("End",ExtFunArray[i]) != 0 ) { //while function not equal to "End"
234
235 if (strcmp(name,ExtFunArray[i]) == 0 ) { //When function name equal to table, break
236 funNum = i;
237 break;
238 }
239 i++;
240 }
241
242 switch (funNum) {
243 case 0: //InfoMATVAudioStart
244 printk("RunExtFunction InfoMATVAudioStart \n");
245 break;
246
247 case 1: //InfoMATVAudioStop
248 printk("RunExtFunction InfoMATVAudioStop \n");
249 break;
250
251 default:
252 break;
253 }
254
255 return 1;
256}
257
258