|
发表于 2015-2-7 14:27:16
|
显示全部楼层
本帖最后由 jiangdou 于 2015-2-7 14:43 编辑
需要驱动,suxi-ts.ko- /*
- * author by jiangdou
- * you have anything,plese to QQ:344283973
- * time at: 2012-0801
- *
- */
- //////////////////add by jiangdou/////////////
- #if 1
- #define print_dou(format,args...) printk(KERN_ERR "[spi-err] "format,##args)
- #endif
- //////////////////add by jiangdou/////////////
- #include <linux/interrupt.h>
- #include <linux/errno.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/slab.h>
- #include <linux/input.h>
- #include <linux/device.h>
- #include <linux/platform_device.h>
- #include <linux/init.h>
- #include <linux/delay.h>
- #include <linux/ioport.h>
- #include <asm/irq.h>
- #include <asm/io.h>
- #include <linux/fs.h>
- #include <asm/uaccess.h>
- #include <linux/mm.h>
- #include <linux/slab.h>
- #include <linux/timer.h>
- #include <linux/jiffies.h>
- #include <linux/tick.h>
- #include <asm-generic/cputime.h>
- #include <mach/system.h>
- #include <mach/hardware.h>
- #include <mach/sys_config.h>
- #ifdef CONFIG_HAS_EARLYSUSPEND
- #include <linux/earlysuspend.h>
- #endif
- #if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_PM)
- #include <linux/pm.h>
- #endif
- static int tp_flag = 0;
- /* tp status value */
- #define TP_INITIAL (-1)
- #define TP_DOWN (0)
- #define TP_UP (1)
- #define TP_DATA_VA (2)
- #define DUAL_TOUCH (dual_touch_distance)
- #define TOUCH_CHANGE (3)
- #define TP_DATA_AV_NO (0x3)
- //#define FIX_ORIENTATION
- #define ORIENTATION_DEFAULT_VAL (-1)
- //#define TP_INT_PERIOD_TEST
- //#define TP_TEMP_DEBUG
- //#define TP_FREQ_DEBUG
- #define TP_FIX_CENTER
- #define IRQ_TP (29)
- #define TP_BASSADDRESS (0xf1c25000)
- #define TP_CTRL0 (0x00)
- #define TP_CTRL1 (0x04)
- #define TP_CTRL2 (0x08)
- #define TP_CTRL3 (0x0c)
- #define TP_INT_FIFOC (0x10)
- #define TP_INT_FIFOS (0x14)
- #define TP_TPR (0x18)
- #define TP_CDAT (0x1c)
- #define TEMP_DATA (0x20)
- #define TP_DATA (0x24)
- #define ADC_FIRST_DLY (0x1<<24)
- #define ADC_FIRST_DLY_MODE (0x1<<23)
- #define ADC_CLK_SELECT (0x0<<22)
- #define ADC_CLK_DIVIDER (0x2<<20)
- //#define CLK (6)
- #define CLK (7)
- #define FS_DIV (CLK<<16)
- #define ACQ (0x3f)
- #define T_ACQ (ACQ)
- .............................(略)
- static void report_single_point_implement(struct sunxi_ts_data *ts_data, struct ts_sample_data *sample_data)
- {
- //print_dou("jiangdou_tp__________________________x1:%d_____y1:%d\n", sample_data->x, sample_data->y);
- input_report_abs(ts_data->input, ABS_MT_TOUCH_MAJOR,800);
-
- sample_data->x = (106458*((4096 - sample_data->x) - 180))/100000;//x轴正反向后左移180到0,同时等比例放大到最大坐标
- //input_report_abs(ts_data->input, ABS_MT_POSITION_X, sample_data->x);
- //sample_data->y = 4096 - sample_data->y;
- sample_data->y = (107758*(sample_data->y - 165))/100000; //107658,,y左移165到0,同时等比例放大到最大坐标
- //为什么107758/100000 =1.07758(放大倍数),内核不支持浮点
-
- //print_dou("\njiangdou_tp__________________________x2:%d_____y2:%d\n", sample_data->x, sample_data->y);
- input_report_abs(ts_data->input, ABS_MT_POSITION_X, sample_data->x);
- input_report_abs(ts_data->input, ABS_MT_POSITION_Y, sample_data->y);
-
- input_mt_sync(ts_data->input);
- input_sync(ts_data->input);
- return;
- }
- //report_double_point(ts_data, sample_data);//注释掉2点上报,,因为2点不精准,无意义
- ...................(略)
-
- static void __exit sunxi_ts_exit(void)
- {
- platform_driver_unregister(&sunxi_ts_driver);
- platform_device_unregister(&sunxi_ts_device);
- }
- module_init(sunxi_ts_init);
- module_exit(sunxi_ts_exit);
- MODULE_AUTHOR("jiangdou");
- MODULE_DESCRIPTION("sunxi touchscreen driver");
- MODULE_LICENSE("GPL");
复制代码 vvvv,,,
附带我项目的图片:4线电阻屏:
坐标误差1-2mm以内,小图标点击,效果比电容屏好
抱歉字数限制,代码只是重点片段
|
|