static struct modem_sound_data *modem_sound;\r
int (*set_codec_for_pcm_modem)(int cmd) = NULL; /* Set the codec used only for PCM modem */\r
void (*set_codec_spk)(int on) = NULL;\r
-#if defined(CONFIG_SND_RK_SOC_RK2928)|| defined(CONFIG_SND_RK29_SOC_RK610)\r
+#if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610_PHONEPAD)\r
extern void call_set_spk(int on);\r
#endif\r
#ifdef CONFIG_SND_SOC_ES8323_PCM\r
extern int set_es8323(int cmd);\r
#endif\r
\r
-#define HP_MIC 0\r
-#define MAIN_MIC 1\r
-#if defined(CONFIG_MODEM_MIC_SWITCH)\r
-extern void Modem_Mic_switch(int value);\r
-extern void Modem_Mic_release(void);\r
-void Modem_Sound_Mic_switch(int value)\r
-{\r
- Modem_Mic_switch(value);\r
-}\r
-void Modem_Sound_Mic_release()\r
-{\r
- Modem_Mic_release();\r
-}\r
-#else\r
-void Modem_Sound_Mic_switch(int value)\r
-{\r
-}\r
-void Modem_Sound_Mic_release()\r
-{\r
-}\r
-#endif\r
-\r
int modem_sound_spkctl(int status)\r
{\r
+ if(modem_sound->spkctl_io == INVALID_GPIO)\r
+ return 0;\r
if(status == ENABLE)\r
gpio_direction_output(modem_sound->spkctl_io,GPIO_HIGH);//modem_sound->spkctl_io? GPIO_HIGH:GPIO_LOW);\r
else \r
\r
static long modem_sound_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)\r
{\r
- int ret = 0, codec_pcm_cmd = -1, codec_cmd = -1, modem_spk_enable = -1;\r
+ long ret = 0;\r
struct modem_sound_data *pdata = modem_sound;\r
\r
DBG("modem_sound_ioctl: cmd = %d arg = %ld\n",cmd, arg);\r
\r
ret = down_interruptible(&pdata->power_sem);\r
if (ret < 0) {\r
- printk("%s: down power_sem error ret = %d\n", __func__, ret);\r
+ printk("%s: down power_sem error ret = %ld\n", __func__, ret);\r
return ret;\r
}\r
\r
switch (cmd){\r
case IOCTL_MODEM_EAR_PHOEN:\r
DBG("modem_sound_ioctl: MODEM_EAR_PHONE\n");\r
- Modem_Sound_Mic_switch(MAIN_MIC);\r
- codec_cmd = 3;\r
- codec_pcm_cmd = RCV;\r
- modem_spk_enable = DISABLE;\r
+ if (set_codec_for_pcm_modem)\r
+ set_codec_for_pcm_modem(RCV);\r
break;\r
case IOCTL_MODEM_SPK_PHONE:\r
DBG("modem_sound_ioctl: MODEM_SPK_PHONE\n");\r
- Modem_Sound_Mic_switch(MAIN_MIC);\r
- codec_cmd = 1;\r
- codec_pcm_cmd = SPK_PATH;\r
- modem_spk_enable = ENABLE;\r
+ if (set_codec_for_pcm_modem)\r
+ set_codec_for_pcm_modem(SPK_PATH);\r
+ if(set_codec_spk)\r
+ set_codec_spk(1);\r
+ modem_sound_spkctl(ENABLE);\r
break;\r
case IOCTL_MODEM_HP_WITHMIC_PHONE:\r
DBG("modem_sound_ioctl: MODEM_HP_WITHMIC_PHONE\n");\r
- Modem_Sound_Mic_switch(HP_MIC);\r
- codec_cmd = 2;\r
- codec_pcm_cmd = HP_PATH;\r
- modem_spk_enable = DISABLE;\r
+ if (set_codec_for_pcm_modem)\r
+ set_codec_for_pcm_modem(HP_PATH);\r
+ if(set_codec_spk)\r
+ set_codec_spk(2);\r
+ modem_sound_spkctl(DISABLE);\r
break;\r
case IOCTL_MODEM_BT_PHONE:\r
- codec_cmd = 3;\r
- codec_pcm_cmd = BT;\r
- modem_spk_enable = DISABLE;\r
+ if (set_codec_for_pcm_modem)\r
+ set_codec_for_pcm_modem(BT);\r
DBG("modem_sound_ioctl: MODEM_BT_PHONE\n");\r
break;\r
case IOCTL_MODEM_STOP_PHONE:\r
DBG("modem_sound_ioctl: MODEM_STOP_PHONE\n");\r
- Modem_Sound_Mic_release();\r
- codec_cmd = 0;\r
- codec_pcm_cmd = OFF;\r
- modem_spk_enable = ENABLE;\r
+ if(set_codec_spk)\r
+ set_codec_spk(0);\r
+ if (set_codec_for_pcm_modem)\r
+ set_codec_for_pcm_modem(OFF);\r
break;\r
case IOCTL_MODEM_HP_NOMIC_PHONE:\r
- DBG("modem_sound_ioctl: MODEM_HP_NOMIC_PHONE\n");\r
- Modem_Sound_Mic_switch(MAIN_MIC);\r
- codec_cmd = 2;\r
- codec_pcm_cmd = HP_NO_MIC;\r
- modem_spk_enable = DISABLE;\r
- break;\r
+ DBG("modem_sound_ioctl: MODEM_HP_NOMIC_PHONE\n");\r
+ if (set_codec_for_pcm_modem)\r
+ set_codec_for_pcm_modem(HP_NO_MIC);\r
+ if(set_codec_spk)\r
+ set_codec_spk(2);\r
+ modem_sound_spkctl(DISABLE);\r
+ break;\r
+\r
+\r
default:\r
printk("unknown ioctl cmd!\n");\r
ret = -EINVAL;\r
break;\r
}\r
\r
- if (set_codec_spk == NULL || set_codec_for_pcm_modem == NULL)\r
- printk("modem_sound_ioctl(), %s %s\n",\r
- set_codec_for_pcm_modem ? "" : "set_codec_for_pcm_modem is NULL",\r
- set_codec_spk ? "" : "set_codec_spk is NULL");\r
-\r
- if (ret >= 0) {\r
- // close codec firstly for pop noise\r
- if (codec_cmd == 0 && set_codec_spk)\r
- set_codec_spk(codec_cmd);\r
-\r
- if (set_codec_for_pcm_modem)\r
- set_codec_for_pcm_modem(codec_pcm_cmd);\r
-\r
- modem_sound_spkctl(modem_spk_enable);\r
-\r
- // open codec lastly for pop noise\r
- if (codec_cmd != 0 && set_codec_spk)\r
- set_codec_spk(codec_cmd);\r
- }\r
-\r
up(&pdata->power_sem);\r
\r
return ret;\r
pdata->wq = create_freezable_workqueue("modem_sound");\r
INIT_WORK(&pdata->work, modem_sound_delay_power_downup);\r
modem_sound = pdata;\r
- printk("%s:modem sound initialized\n",__FUNCTION__);\r
-\r
-#if defined(CONFIG_SND_RK_SOC_RK2928)|| defined(CONFIG_SND_RK29_SOC_RK610)\r
- set_codec_spk = call_set_spk;\r
+#if defined(CONFIG_SND_RK_SOC_RK2928)|| defined(CONFIG_SND_RK29_SOC_RK610_PHONEPAD)\r
+ set_codec_spk = call_set_spk;\r
#endif\r
#ifdef CONFIG_SND_SOC_ES8323_PCM\r
set_codec_for_pcm_modem = set_es8323;\r
#endif\r
\r
+ printk("%s:modem sound initialized\n",__FUNCTION__);\r
+\r
return ret;\r
}\r
\r