usb: dwc3: unregister extcon notify if probe fail
[firefly-linux-kernel-4.4.55.git] / drivers / misc / modem_sound.c
index b767cb964617f54830189674c137121a37a3d3dd..800405deefe8fe9376b0dd98044dca53acf685e0 100755 (executable)
@@ -14,7 +14,7 @@
 #include <asm/uaccess.h>\r
 #include <linux/wait.h>\r
 #include "modem_sound.h"\r
-#if 1\r
+#if 0\r
 #define DBG(x...)      printk(KERN_INFO x)\r
 #else\r
 #define DBG(x...)\r
 #define DISABLE            0\r
 \r
 static struct modem_sound_data *modem_sound;\r
-#ifdef CONFIG_SND_RK_SOC_RK2928\r
-extern void call_set_spk(bool on);\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_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
 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
@@ -78,33 +86,49 @@ static long modem_sound_ioctl(struct file *filp, unsigned int cmd, unsigned long
        switch (cmd){\r
                case IOCTL_MODEM_EAR_PHOEN:\r
                        DBG("modem_sound_ioctl: MODEM_EAR_PHONE\n");\r
-                       call_set_spk(0);\r
-                       modem_sound_spkctl(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
-                       call_set_spk(0);\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_PHONE:\r
-                       DBG("modem_sound_ioctl: MODEM_HP_PHONE\n");\r
-                       call_set_spk(0);\r
+               case IOCTL_MODEM_HP_WITHMIC_PHONE:\r
+                       DBG("modem_sound_ioctl: MODEM_HP_WITHMIC_PHONE\n");\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
-                       \r
                case IOCTL_MODEM_BT_PHONE:\r
-                       call_set_spk(0);\r
-                       modem_sound_spkctl(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
-                       call_set_spk(1);\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
+                       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
-                       up(&pdata->power_sem);\r
                        ret = -EINVAL;\r
                        break;\r
        }\r
@@ -142,7 +166,7 @@ static int modem_sound_probe(struct platform_device *pdev)
        struct modem_sound_data *pdata = pdev->dev.platform_data;\r
        if(!pdata)\r
                return -1;\r
-               \r
+\r
        ret = misc_register(&modem_sound_dev);\r
        if (ret < 0){\r
                printk("modem register err!\n");\r
@@ -153,6 +177,13 @@ static int modem_sound_probe(struct platform_device *pdev)
        pdata->wq = create_freezable_workqueue("modem_sound");\r
        INIT_WORK(&pdata->work, modem_sound_delay_power_downup);\r
        modem_sound = pdata;\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