这篇文章主要介绍了linux
触摸屏驱动编写,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
早在诺基亚手机还比较流行的时候,那时候触摸屏用的还不多。但是随着触摸屏手机、即智能手机的流行,触摸屏基本成了手机的标配。所以,今天可以看看触摸屏驱动在linux上是如何进行的。
1、驱动目录
drivers/input
2、看看这个目录的Makefile如何设计
obj-(CONFIGINPUT)+=inputcore.oinputcorey:=input.oinputcompat.oinputmt.offcore.oobj
(CONFIG_INPUT) += input-core.o input-core-y := input.o
input-compat.o input-mt.o ff-core.o obj-" role="presentation"
style="box-sizing: border-box; outline: 0px; margin: 0px; padding:
0px; font-family: KaTeX_Main, "Times New Roman", serif; display:
inline; line-height: normal; font-size: 19.36px; word-spacing:
normal; word-wrap: break-word; white-space: nowrap; float: none;
direction: ltr; max-width: none; max-height: none; min-width: 0px;
min-height: 0px; border: 0px; position:
relative;">(CONFIGINPUT)+=input−core.oinput−core−y:=input.oinput−compat.oinput−mt.off−core.oobj−(CONFIG_INPUT) += input-core.o input-core-y := input.o
input-compat.o input-mt.o ff-core.o
obj-(CONFIGINPUT)+=input−core.oinput−core−y:=input.oinput−compat.oinput−mt.off−core.oobj−(CONFIG_INPUT_TOUCHSCREEN)
+= touchscreen/
3、除了input-core.o这个文件外,只需要看touchscreen目录就可以了
config TOUCHSCREEN_S3C2410 tristate “Samsung S3C2410/generic
touchscreen input driver” depends on ARCH_S3C24XX || SAMSUNG_DEV_TS
depends on S3C_ADC help Say Y here if you have the s3c2410
touchscreen. If unsure, say N. To compile this driver as a module,
choose M here: the module will be called s3c2410_ts.
4、看懂了Kconfig之后,再阅读Makefile,注意S3C_ADC宏可以参考arch/arm/plat-samsung/adc.c
obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o
5、继续阅读s3c2410_ts.c文件
static const struct platform_device_id s3cts_driver_ids[] = { {
“s3c2410-ts”, 0 }, { “s3c2440-ts”, 0 }, { “s3c64xx-ts”,
FEAT_PEN_IRQ }, { } }; MODULE_DEVICE_TABLE(platform,
s3cts_driver_ids); static struct platform_driver s3c_ts_driver = {
.driver = { .name = “samsung-ts”, #ifdef CONFIG_PM .pm =
&s3c_ts_pmops, #endif }, .id_table = s3cts_driver_ids, .probe =
s3c2410ts_probe, .remove = s3c2410ts_remove, };
module_platform_driver(s3c_ts_driver);
6、根据probe函数,看看有什么需要注意的内容搜索引擎大全
ts.client = s3c_adc_register(pdev, s3c24xx_ts_select,
s3c24xx_ts_conversion, 1); if (IS_ERR(ts.client)) { dev_err(dev,
“failed to register adc client\n”); ret = PTR_ERR(ts.client); goto
err_iomap; }
7、接着,查看是否有中断函数被注册
ret =
request_irq(ts.irq_tc, stylus_irq, 0, “s3c2410_ts_pen”,
ts.input);
8、最后
很明显,触摸屏驱动本质上还是由TOUCHSCREEN_S3C2410和S3C_ADC两个macro一起完成的。