X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=drivers%2Fmisc%2Fmodem_sound.c;h=800405deefe8fe9376b0dd98044dca53acf685e0;hb=e0958c306679d65070c65bf82893dd51eca1b944;hp=b767cb964617f54830189674c137121a37a3d3dd;hpb=ef62b5225e727baf228e18e0ee70fd1d9020f00c;p=firefly-linux-kernel-4.4.55.git diff --git a/drivers/misc/modem_sound.c b/drivers/misc/modem_sound.c index b767cb964617..800405deefe8 100755 --- a/drivers/misc/modem_sound.c +++ b/drivers/misc/modem_sound.c @@ -14,7 +14,7 @@ #include #include #include "modem_sound.h" -#if 1 +#if 0 #define DBG(x...) printk(KERN_INFO x) #else #define DBG(x...) @@ -23,11 +23,19 @@ #define DISABLE 0 static struct modem_sound_data *modem_sound; -#ifdef CONFIG_SND_RK_SOC_RK2928 -extern void call_set_spk(bool on); +int (*set_codec_for_pcm_modem)(int cmd) = NULL; /* Set the codec used only for PCM modem */ +void (*set_codec_spk)(int on) = NULL; +#if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610_PHONEPAD) +extern void call_set_spk(int on); #endif +#ifdef CONFIG_SND_SOC_ES8323_PCM +extern int set_es8323(int cmd); +#endif + int modem_sound_spkctl(int status) { + if(modem_sound->spkctl_io == INVALID_GPIO) + return 0; if(status == ENABLE) gpio_direction_output(modem_sound->spkctl_io,GPIO_HIGH);//modem_sound->spkctl_io? GPIO_HIGH:GPIO_LOW); else @@ -78,33 +86,49 @@ static long modem_sound_ioctl(struct file *filp, unsigned int cmd, unsigned long switch (cmd){ case IOCTL_MODEM_EAR_PHOEN: DBG("modem_sound_ioctl: MODEM_EAR_PHONE\n"); - call_set_spk(0); - modem_sound_spkctl(DISABLE); + if (set_codec_for_pcm_modem) + set_codec_for_pcm_modem(RCV); break; case IOCTL_MODEM_SPK_PHONE: DBG("modem_sound_ioctl: MODEM_SPK_PHONE\n"); - call_set_spk(0); + if (set_codec_for_pcm_modem) + set_codec_for_pcm_modem(SPK_PATH); + if(set_codec_spk) + set_codec_spk(1); modem_sound_spkctl(ENABLE); break; - case IOCTL_MODEM_HP_PHONE: - DBG("modem_sound_ioctl: MODEM_HP_PHONE\n"); - call_set_spk(0); + case IOCTL_MODEM_HP_WITHMIC_PHONE: + DBG("modem_sound_ioctl: MODEM_HP_WITHMIC_PHONE\n"); + if (set_codec_for_pcm_modem) + set_codec_for_pcm_modem(HP_PATH); + if(set_codec_spk) + set_codec_spk(2); modem_sound_spkctl(DISABLE); break; - case IOCTL_MODEM_BT_PHONE: - call_set_spk(0); - modem_sound_spkctl(DISABLE); + if (set_codec_for_pcm_modem) + set_codec_for_pcm_modem(BT); DBG("modem_sound_ioctl: MODEM_BT_PHONE\n"); break; case IOCTL_MODEM_STOP_PHONE: DBG("modem_sound_ioctl: MODEM_STOP_PHONE\n"); - call_set_spk(1); + if(set_codec_spk) + set_codec_spk(0); + if (set_codec_for_pcm_modem) + set_codec_for_pcm_modem(OFF); + break; + case IOCTL_MODEM_HP_NOMIC_PHONE: + DBG("modem_sound_ioctl: MODEM_HP_NOMIC_PHONE\n"); + if (set_codec_for_pcm_modem) + set_codec_for_pcm_modem(HP_NO_MIC); + if(set_codec_spk) + set_codec_spk(2); + modem_sound_spkctl(DISABLE); break; + default: printk("unknown ioctl cmd!\n"); - up(&pdata->power_sem); ret = -EINVAL; break; } @@ -142,7 +166,7 @@ static int modem_sound_probe(struct platform_device *pdev) struct modem_sound_data *pdata = pdev->dev.platform_data; if(!pdata) return -1; - + ret = misc_register(&modem_sound_dev); if (ret < 0){ printk("modem register err!\n"); @@ -153,6 +177,13 @@ static int modem_sound_probe(struct platform_device *pdev) pdata->wq = create_freezable_workqueue("modem_sound"); INIT_WORK(&pdata->work, modem_sound_delay_power_downup); modem_sound = pdata; +#if defined(CONFIG_SND_RK_SOC_RK2928)|| defined(CONFIG_SND_RK29_SOC_RK610_PHONEPAD) + set_codec_spk = call_set_spk; +#endif +#ifdef CONFIG_SND_SOC_ES8323_PCM + set_codec_for_pcm_modem = set_es8323; +#endif + printk("%s:modem sound initialized\n",__FUNCTION__); return ret;