1 /*****************************************************************************
2 * E X T E R N A L R E F E R E N C E S
3 ******************************************************************************
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>
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"
24 /*****************************************************************************
25 * C O M P I L E R F L A G S
26 ******************************************************************************
28 //#define CONFIG_DEBUG_MSG
29 #ifdef CONFIG_DEBUG_MSG
30 #define PRINTK(format, args...) printk( KERN_EMERG format,##args )
32 #define PRINTK(format, args...)
37 //#define ENABLE_2_IN_1_SPK
39 #if !defined(AMP_CLASS_AB) && !defined(AMP_CLASS_D)
40 #error "MT6323 SPK AMP TYPE does not be defined!!!"
42 /*****************************************************************************
44 ******************************************************************************
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 /*****************************************************************************
54 ******************************************************************************
56 static int Speaker_Volume
=0;
57 static bool gsk_on
=false; // speaker is open?
58 static bool gsk_resume
=false;
59 static 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 ******************************************************************************
64 extern void Yusu_Sound_AMP_Switch(BOOL enable
);
66 bool Speaker_Init(void)
68 PRINTK("+Speaker_Init Success");
69 #if defined(AMP_CLASS_AB)
71 #elif defined(AMP_CLASS_D)
75 PRINTK("-Speaker_Init Success");
79 bool Speaker_Register(void)
89 bool Speaker_DeInit(void)
94 void Sound_SpeakerL_SetVolLevel(int level
)
96 PRINTK(" Sound_SpeakerL_SetVolLevel level=%d\n",level
);
99 void Sound_SpeakerR_SetVolLevel(int level
)
101 PRINTK(" Sound_SpeakerR_SetVolLevel level=%d\n",level
);
104 void Sound_Speaker_Turnon(int channel
)
106 PRINTK("Sound_Speaker_Turnon channel = %d\n",channel
);
109 #if defined(ENABLE_2_IN_1_SPK)
110 #if defined(AMP_CLASS_D)
114 #if defined(AMP_CLASS_AB)
116 #elif defined(AMP_CLASS_D)
119 //msleep(SPK_WARM_UP_TIME);
123 void Sound_Speaker_Turnoff(int channel
)
125 PRINTK("Sound_Speaker_Turnoff channel = %d\n",channel
);
128 #if defined(AMP_CLASS_AB)
130 #elif defined(AMP_CLASS_D)
136 void Sound_Speaker_SetVolLevel(int level
)
138 Speaker_Volume
=level
;
141 void Sound_Headset_Turnon(void)
145 void Sound_Headset_Turnoff(void)
149 void Sound_Earpiece_Turnon(void)
151 #if defined(ENABLE_2_IN_1_SPK)
153 #if defined(AMP_CLASS_D)
160 void Sound_Earpiece_Turnoff(void)
162 #if defined(ENABLE_2_IN_1_SPK)
164 #if defined(AMP_CLASS_D)
172 void AudioAMPDevice_Suspend(void)
174 PRINTK("AudioDevice_Suspend\n");
177 Sound_Speaker_Turnoff(Channel_Stereo
);
182 void AudioAMPDevice_Resume(void)
184 PRINTK("AudioDevice_Resume\n");
186 Sound_Speaker_Turnon(Channel_Stereo
);
189 void AudioAMPDevice_SpeakerLouderOpen(void)
191 PRINTK("AudioDevice_SpeakerLouderOpen\n");
195 Sound_Speaker_Turnon(Channel_Stereo
);
200 void AudioAMPDevice_SpeakerLouderClose(void)
202 PRINTK("AudioDevice_SpeakerLouderClose\n");
205 Sound_Speaker_Turnoff(Channel_Stereo
);
209 void AudioAMPDevice_mute(void)
211 PRINTK("AudioDevice_mute\n");
213 Sound_Speaker_Turnoff(Channel_Stereo
);
216 int Audio_eamp_command(unsigned int type
, unsigned long args
, unsigned int count
)
220 static char *ExtFunArray
[] =
222 "InfoMATVAudioStart",
227 kal_int32
Sound_ExtFunction(const char* name
, void* param
, int param_size
)
232 //Search the supported function defined in ExtFunArray
233 while(strcmp("End",ExtFunArray
[i
]) != 0 ) { //while function not equal to "End"
235 if (strcmp(name
,ExtFunArray
[i
]) == 0 ) { //When function name equal to table, break
243 case 0: //InfoMATVAudioStart
244 printk("RunExtFunction InfoMATVAudioStart \n");
247 case 1: //InfoMATVAudioStop
248 printk("RunExtFunction InfoMATVAudioStop \n");