linux 触摸屏驱动编写

Gretel ·
更新时间:2024-09-21
· 748 次阅读

早在诺基亚手机还比较流行的时候,那时候触摸屏用的还不多。但是随着触摸屏手机、即智能手机的流行,触摸屏基本成了手机的标配。所以,今天可以看看触摸屏驱动在linux上是如何进行的。

1、驱动目录

drivers/input

2、看看这个目录的Makefile如何设计

obj-$(CONFIG_INPUT) += input-core.o input-core-y := input.o input-compat.o input-mt.o ff-core.o obj-$(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一起完成的。

您可能感兴趣的文章:详解linux lcd驱动编写详解linux pwm驱动编写linux 驱动之Kconfig文件和Makefile文件实例Linux 字符设备驱动框架详细介绍Linux安装PHP MongoDB驱动Linux下如何安装Run文件格式NVIDIA显卡驱动如何编写Linux设备驱动程序Linux内核模块和驱动的编写详解linux dma驱动编写



触摸屏 Linux

需要 登录 后方可回复, 如果你还没有账号请 注册新账号