msm8909耳机孔状态标记

添加msm8909
添加耳机线是否插入的标记,用于上层读写,cat /sys/module/msm8916_wcd_irq/parameters/msm8x16_line_status 为1表示接入 0表示未接

Index: android/kernel/msm-3.18/sound/soc/codecs/msm8916-wcd-irq.c
===================================================================
--- android/kernel/msm-3.18/sound/soc/codecs/msm8916-wcd-irq.c 
+++ android/kernel/msm-3.18/sound/soc/codecs/msm8916-wcd-irq.c 
@@ -36,7 +36,8 @@
 #define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE)
 
 static irqreturn_t wcd9xxx_spmi_irq_handler(int linux_irq, void *data);
-
+static unsigned int msm8x16_line_status = 0;
+module_param(msm8x16_line_status, uint, S_IRUGO | S_IWUSR);
 char *irq_names[MAX_NUM_IRQS] = {
        "spk_cnp_int",
        "spk_clip_int",
@@ -105,6 +106,8 @@
                snd_soc_update_bits(map.codec,
                                MSM8X16_WCD_A_DIGITAL_INT_EN_SET,
                                (0x01 << irq), (0x01 << irq));
+               if (irq == 6)
+                       msm8x16_line_status = 1;
        }
        if ((irq > 7) && (irq <= 15)) {
                snd_soc_update_bits(map.codec,
@@ -134,6 +137,8 @@
                snd_soc_update_bits(map.codec,
                                MSM8X16_WCD_A_DIGITAL_INT_EN_CLR,
                                (0x01 << irq), (0x01 << irq));
+               if (irq == 6) 
+                       msm8x16_line_status = 0;
        }
 
        if ((irq > 7) && (irq <= 15)) {

应用层检测方法:

FILE *fp_line_status;
char line_status = 0;
int temp = 0;
char cmd_line_status[64] = {"cat /sys/module/msm8916_wcd_irq/parameters/msm8x16_line_status"};
char tmpBuff[64];

fp_line_status=popen(cmd_line_status, "r");
   	if(fp_line_status == NULL)
	{
		if (!params)
		sleep(30);
		else
		sleep(params->duration);
	}else {
	 while(1) {
	 		if(fgets(tmpBuff, 64, fp_line_status)!=NULL)
			{
				
				//temp = sscanf(tmpBuff,"%d\n",&val);
				printf("%s %d zhongyukang tmpBuff %d %d\n",__func__,__LINE__,tmpBuff[0],tmpBuff[1]);
				if(tmpBuff[0] == '0'){
					pclose(fp_line_status);
					break;
				}
				 sleep(1);
				memset(tmpBuff,0,sizeof(tmpBuff));
				pclose(fp_line_status);
				fp_line_status=popen(cmd_line_status, "r");
				
			}else 
				printf("%s %d else zhongyukang tmpBuff %d %d\n",__func__,__LINE__);

			
	 	}
	}
	pclose(fp_line_status);

你可能感兴趣的:(Linux驱动,LINUX内核,msm8909耳机孔状态标记)