您好,欢迎访问三七文档
当前位置:首页 > 办公文档 > 工作范文 > ALSPS原理以及mtk平台代码走读
ALSPS原理以及代码走读2016年11月18日环境光传感器通过光敏电阻,光敏二极管,光敏三极管,硅光电池等光敏元件可以感知周围光线,stk3x1x–光敏二极管HWDESIGNAddaNewALSPSsensorStep1/device/lava/${project}/Projectconfig.mkCUSTOM_KERNEL_ALSPS=yesStep2/kernel-3.18/arch/arm64/configs/${project}_debug_defconfig/kernel-3.18/arch/arm64/configs/${project}_defconfigCONFIG_MTK_STK3X1X_NEW=yStep3/kernel-3.18/drivers/misc/mediatek/alsps/Makefileobj-$(CONFIG_MTK_STK3X1X_NEW)+=stk3x1x-new/Step4/kernel-3.18\drivers\misc\mediatek\alsps\Kconfigsourcedrivers/misc/mediatek/alsps/stk3x1x-new/KconfigStep5kernel-3.18/drivers/misc/mediatek/alsps/inc/cust_alsps.h#ifdefined(CONFIG_MTK_STK3X1X_NEW)structalsps_hw{inti2c_num;intpower_id;intpower_vol;//intpolling_mode;intpolling_mode_ps;intpolling_mode_als;unsignedchari2c_addr[C_CUST_I2C_ADDR_NUM];unsignedintals_level[C_CUST_ALS_LEVEL-1];unsignedintals_value[C_CUST_ALS_LEVEL];//unsignedintps_threshold;unsignedintstate_val;unsignedintpsctrl_val;unsignedintalsctrl_val;unsignedintledctrl_val;unsignedintwait_val;unsignedintals_window_loss;unsignedintps_threshold_high;unsignedintps_threshold_low;boolis_batch_supported_ps;boolis_batch_supported_als;};#else......#endifStep6kernel-3.18/drivers/misc/mediatek/hwmon/sensor_dts/sensor_dts.c#ifdefined(CONFIG_MTK_STK3X1X_NEW)structalsps_hw*get_alsps_dts_func(constchar*name,structalsps_hw*hw){inti,ret;u32i2c_num[]={0};u32i2c_addr[C_CUST_I2C_ADDR_NUM]={0};u32power_id[]={0};u32power_vol[]={0};u32polling_mode_ps[]={0};u32polling_mode_als[]={0};u32ps_threshold_high[]={0};u32ps_threshold_low[]={0};u32als_level[C_CUST_ALS_LEVEL-1]={0};u32als_value[C_CUST_ALS_LEVEL]={0};u32state_val[]={0};u32psctrl_val[]={0};u32alsctrl_val[]={0};u32ledctrl_val[]={0};u32wait_val[]={0};u32is_batch_supported_ps[]={0};u32is_batch_supported_als[]={0};structdevice_node*node=NULL;……#else……#endifStep7/kernel-3.18/drivers/misc/mediatek/alsps/stk3x1x-newKconfigMakefilestk3x1x.cstk3x1x.hStep8/kernel-3.18/arch/arm64/boot/dts/${project}.dtscust_alsps@0{compatible=mediatek,stk3x1x;i2c_num=2;i2c_addr=0x48000;polling_mode_ps=0;polling_mode_als=1;power_id=0xffff;power_vol=0;als_level=5936598213220527350084511361545236446556982;als_value=06585851051051452254509301250170026005120768010240;state_val=0x0;psctrl_val=0x31;alsctrl_val=0x39;/*linhuimodify20160930*/ledctrl_val=0xFF;wait_val=0x7;ps_threshold_high=1700;ps_threshold_low=1500;is_batch_supported_ps=0;is_batch_supported_als=0;};&pio{alsps_intpin_cfg:alspspincfg{pins_cmd_dat{pins=PINMUX_GPIO65__FUNC_GPIO65;slew-rate=0;bias-pull-up=00;};};alsps_intpin_default:alspsdefaultcfg{};&alsps{pinctrl-names=pin_default,pin_cfg;pinctrl-0=&alsps_intpin_default;pinctrl-1=&alsps_intpin_cfg;status=okay;};Step9Step10ALSPS兼容Step1/device/lava/${project}/Projectconfig.mkMTK_AUTO_DETECT_ALSPS=yesStep2/kernel-3.18/arch/arm64/configs/${project}_debug_defconfig/kernel-3.18/arch/arm64/configs/${project}_defconfigCONFIG_MTK_AUTO_DETECT_ALSPS=yStep3I2Caddressstk3x1x_i2c_probe添加client-addr=obj-hw-i2c_addr[0];//dts0x48ltr559_i2c_probe添加client-addr=obj-hw-i2c_addr[0];//dts0x23代码分析stk3x1xstaticintstk3x1x_i2c_probe(structi2c_client*client,conststructi2c_device_id*id)驱动加载函数,读取DTS配置,对IC进行初始化设置。staticintstk3x1x_enable_ps(structi2c_client*client,intenable,intvalidate_reg)ps启动函数,enable=1为启动,0为关闭staticintstk3x1x_enable_als(structi2c_client*client,intenable)Als启动函数enable=1为启动,0为关闭staticintstk3x1x_i2c_suspend(structi2c_client*client,pm_message_tmsg)IC睡眠函数staticintstk3x1x_i2c_resume(structi2c_client*client)IC唤醒函数staticlongstk3x1x_unlocked_ioctl(structfile*file,unsignedintcmd,unsignedlongarg)有一些对ALSPS的操作,在37没调用ALSPS_IOCTL_SET_CALI开机有调用(80,37),把校准参数重写,写成DTS里面的设置,需要注释掉。ALSPS_IOCTL_GET_CALI偶现调用(37n),校准参数重写,写成DTS里面的设置,需要注释掉intstk3x1x_read_ps(structi2c_client*client,u16*data)从0x11读取ps值intstk3x1x_read_als(structi2c_client*client,u16*data)从0x13读取als值staticintstk3x1x_get_ps_value_only(structstk3x1x_priv*obj,u16ps)读取ps是接近还是远离,0接近,1远离stk3x1x_get_als_value根据als_level得到als_value。als_level=5936598213220527350084511361545236446556982;als_value=0104065901452253005509301250170026005120768010240;atomic_read(&obj-ps_threshold_high),读取ps高门限值atomic_read(&obj-ps_threshold_low)读取ps低门限值intstk3x1x_write_ps_high_thd(structi2c_client*client,u16thd)把ps高门限值写入0x06高8bit把ps高门限值写入0x07低8bitintstk3x1x_write_ps_low_thd(structi2c_client*client,u16thd)把ps低门限值写入0x08高8bit把ps低门限值写入0x09低8bitintps_report_interrupt_data(intvalue)上报PS的状态给软件上层,0为接近,1为远离。PS门限值校准stk3x1xintstk3x1x_read_ps(structi2c_client*client,u16*data)从0x11读取ps值intstk3x1x_read_als(structi2c_client*client,u16*data)从0x13读取als值staticintstk3x1x_get_ps_value(structstk3x1x_priv*obj,u16ps)读取ps是接近还是远离,0接近,1远离stk3x1x_get_als_value根据als_level得到als_value。als_level=5936598213220527350084511361545236446556982;als_value=0104065901452253005509301250170026005120768010240;校准参数设置灰卡灭屏距离:3-5cm黑卡灭屏距离:=1.5cm#defineSTK_MAX_MIN_DIFF85#defineSTK_LT_N_CT70#defineSTK_HT_N_CT80PS灭屏距离调试常见问题分析stk3x1x启动ps,黑卡从远到近接近光感口,手机先灭屏再亮屏黑卡吸光,黑卡从远到近接近光感口时,ps值先变大再变小。Ps值大于高门限值时,灭屏,Ps值小于低门限值时,亮屏。根本原因,黑卡0公分ps值与底噪值
本文标题:ALSPS原理以及mtk平台代码走读
链接地址:https://www.777doc.com/doc-5734976 .html