【1.input子系统框架(drivers\input)】

如何得出某个驱动所遵循的框架?
    1) 通过网络搜索
    2) 自己想办法跟内核代码!
         2.1 定位此驱动是属于哪种类型的(触摸屏驱动为字符设备)
         2.2 搜索register_chrdev得到,input.c
         2.3 分析input.c文件

, "input", &input_fops);
  
  static const struct file_operations input_fops = {
   .owner = THIS_MODULE,
   .open  = input_open_file,
  };

2.4 分析如何来用input子系统

   ];   //2
      /*2.取出input_handler里面的操作方法*/
      if (handler)
       new_fops = fops_get(handler->fops);      //evdev_fops
      old_fops = file->f_op;
      file->f_op = new_fops;       //file中的f_op覆盖了
      /*3.执行底层的open函数*/
      new_fops->open(inode, file);   //事件处理层的操作方法里面的open函数evdev_open
      evdev_open

2.5 根据handler = input_table[iminor(inode) >> 5];
            猜测,有某段代码将input_handler放入了input_table[iminor(inode) >> 5]
            搜索input_table,看在哪里放了

   module_init(evdev_init);
   evdev_init    ] = handler;
   static struct input_handler evdev_handler = {
    .event   = evdev_event,
    .connect  = evdev_connect,
    .disconnect  = evdev_disconnect,
    .fops   = &evdev_fops,
    .minor   = EVDEV_MINOR_BASE,
    .name   = "evdev",
    .id_table   = evdev_ids,
   };

【input子系统框架讲解】

1.input子系统的核心层(input.c)
    功能:1)给用户提供接口(register_chrdev,cdev,file_operations结构体)
         2)给用input子系统内部组件提供接口,建立三者之间的联系

, "input", &input_fops);
 
 static const struct file_operations input_fops = {
  .owner = THIS_MODULE,
  .open = input_open_file,
 };

2.input子系统的事件处理层(evdev.c)
    功能:专门用来为设备驱动层上报事件的

] = handler;   //64/32 =2
static struct input_handler evdev_handler = {  //表示事件处理句柄
 .event   = evdev_event,     //上报事件的时候,会调用此函数
 .connect  = evdev_connect,    //建立连接的时候,会调用此函数
 .disconnect  = evdev_disconnect,
 .fops   = &evdev_fops,     //事件处理方法(xxx_read)
 .minor   = EVDEV_MINOR_BASE,    //64
 .name   = "evdev",
 .id_table  = evdev_ids,
};
static const struct file_operations evdev_fops = {
 .owner   = THIS_MODULE,
 .read   = evdev_read,      //当应用程序来读数据的时候,便会调用此函数
 .write   = evdev_write,
 .poll   = evdev_poll,
 .open   = evdev_open,
 .release  = evdev_release,
 .unlocked_ioctl = evdev_ioctl,
 .fasync   = evdev_fasync,
 .flush   = evdev_flush
};

3.input子系统的设备驱动层(s3c2410_ts.c为例子)(是驱动工作人员的主要任务)
    功能:1)跟硬件交互,操作硬件,获取硬件的外部事件
         2)提交事件给事件处理层

);
 );
 /*1.5 映射*/
 ts.io = ioremap(res->start, resource_size(res));
 /*1.6 注册中断*/
 ret = request_irq(ts.irq_tc, stylus_irq, IRQF_DISABLED,
     "s3c2410_ts_pen", ts.input);
 /*2. 申请ADC服务*/
 /*3. 初始化硬件(初始化触摸屏控制器)*/
 /*4. 构建一个struct input_dev结构体*/
 struct input_dev *input_dev;                //表示一个输入设备
 /*4.1 设置input_dev*/
 /*4.2 注册input_dev,注册到子系统(input子系统中)*/
 input_register_device(ts.input);

【input子系统里面涉及的几个重要结构体】

struct input_dev     //用来表示一个输入设备
{
 unsigned long evbit[BITS_TO_LONGS(EV_CNT)];   //事件类型
 unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];  //按键类当中什么按键
 unsigned long relbit[BITS_TO_LONGS(REL_CNT)];  //相对位移的什么事件
 unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];  //绝对位移的什么事件
 ...
};

struct input_handler   //用来表示一个事件处理句柄
{
 /*上报事件*/
 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
 /*建立连接的*/
 int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
 const struct file_operations *fops;
 ...
}

struct input_handle    //用来建立input_dev与input_handler的连接的
{
 ...
 struct input_dev *dev;
 struct input_handler *handler;
 struct list_head d_node;
 struct list_head h_node;
}

struct input_event    //用来表示一个输入事件
{
 struct timeval time;  //事件产生的时间
 __u16 type;     //事件类型 EV_KEY
 __u16 code;     //事件码   KEY_A KEY_B
 __s32 value;    //事件值   1-按下 0-松开
}

【input子系统中涉及的重要函数:(input.c)】

] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
方法二:set_bit
例如:
set_bit(EV_KEY,ts.input->evbit);
set_bit(EV_ABS,ts.input->evbit);
set_bit(BIN_TOUCH,ts.input->keybit);

【input子系统框架】

【input子系统框架完整版】

@成鹏致远

(email:wwwlllll@126.com)

(qq:552158509)

 

【Linux高级驱动】input子系统框架的更多相关文章

  1. 【Linux高级驱动】input子系统框架【转】

    转自:http://www.cnblogs.com/lcw/p/3802617.html [1.input子系统框架(drivers\input)] 如何得出某个驱动所遵循的框架?    1) 通过网 ...

  2. Linux 驱动框架---input子系统框架

    前面从具体(Linux 驱动框架---input子系统)的工作过程学习了Linux的input子系统相关的架构知识,但是前面的学习比较实际缺少总结,所以今天就来总结一下输入子系统的架构分层,站到远处来 ...

  3. input子系统框架

    废话不多说,直接进入主题.在驱动insmod后,我们应用层对input设备如何操作?以下以全志a64为实例. 在/dev/input/eventX下(X的形成为后续会分析),是内核把接口暴露给应用层, ...

  4. 网络驱动移植之解析Linux网络驱动的基本框架

    内核源码:linux-2.6.38.8.tar.bz2 概括而言,编写Linux网络驱动其实只要完成两件事即可,一是分配并初始化网络设备,二是注册网络设备. 1.分配并初始化网络设备 动态分配网络设备 ...

  5. 【Linux高级驱动】rtc驱动开发

    [1.分层思想] 1.1 rtc-dev.c   //设备接口层,功能:给用户提供接口 subsys_initcall(rtc_init);   , RTC_DEV_MAX, "rtc&qu ...

  6. 【Linux高级驱动】linux设备驱动模型之平台设备驱动机制

    [1:引言: linux字符设备驱动的基本编程流程] 1.实现模块加载函数  a.申请主设备号    register_chrdev(major,name,file_operations);  b.创 ...

  7. ARM Linux 驱动Input子系统之按键驱动测试

    上一篇已经谈过,在现内核的中引入设备树之后对于内核驱动的编写,主要集中在硬件接口的配置上了即xxxx.dts文件的编写. 在自己的开发板上移植按键驱动: 1.根据开发板的原理图 确定按键的硬件接口为: ...

  8. 【Linux高级驱动】I2C驱动框架分析

    1.i2c-dev.c(i2c设备驱动组件层) 功能:1)给用户提供接口 i2c_dev_init  //入口函数 /*申请主设备号*/ register_chrdev(I2C_MAJOR(), &q ...

  9. 【Linux高级驱动】LCD驱动框架分析

    1.framebuffer接口层(fbmem.c) 功能:给用户提供接口 fbmem_init  ),"fb",&fb_fops)  /*2.创建一个设备类*/ fb_cl ...

随机推荐

  1. fmod()函数 (对浮点数取模)

    头文件:#include <math.h> fmod() 用来对浮点数进行取模(求余),其原型为:    double fmod (double x); 设返回值为 ret,那么 x = ...

  2. python在使用MySQLdb模块时报Can't extract file(s) to egg cacheThe following error occurred while trying to extract file(s) to the Python eggcache的错误。

    这个是因为python使用MySQLdb模块与mysql数据库交互时需要一个地方作为cache放置暂存的数据,但是调用python解释器的用户(常常是服务器如apache的www用户)对于cache所 ...

  3. 洛谷 P1114 “非常男女”计划

    To 洛谷.1114 “非常男女”计划 题目描述 近来,初一年的XXX小朋友致力于研究班上同学的配对问题(别想太多,仅是舞伴),通过各种推理和实验,他掌握了大量的实战经验.例如,据他观察,身高相近的人 ...

  4. [JSOI2004]平衡点/[BZOJ3680]吊打XXX

    [JSOI2004]平衡点/[BZOJ3680]吊打XXX 题目大意: 有\(n(n\le10000)\)个重物,每个重物系在一条足够长的绳子上.每条绳子自上而下穿过桌面上的洞,然后系在一起.假设绳子 ...

  5. webstorm安装教程

    之前有些一些破解的,但是独独忘记了安装的这个教程,现在补上:见下: 先来一官方的解释:WebStorm是JetBrains 推出的一款强大的HTML5编辑工具,拥有丰富的代码快速编辑,可以智能的补全代 ...

  6. UIView的层次结构–code

    转:http://blog.dongliwei.cn/archives/uiview-tree-code // Recursively travel down the view tree, incre ...

  7. Go语言之高级篇beego框架之view

    1.基本语法 go统一使用了{{ 和 }}作为左右标签,没有其它的标签符号. 如果你想要修改为其它符号,可以修改配置文件. 使用.来访问当前位置的上下文 使用$来引用当前模板根级的上下文 2.使用方法 ...

  8. 4、搭建Python环境

    搭建Python环境 Linux环境 大多Linux发行版均默认安装了Pthon环境.如想下载不同的版本,可到www.python.org下载.软件安装方法参照Linux软件安装. 输入Python可 ...

  9. 【ZH奶酪】为什么Python不需要函数重载?

    函数重载的作用是什么? 函数重载主要是为了解决两个问题 可变参数类型 可变参数个数 另外,一个基本的设计原则是,仅仅当两个函数除了参数类型和参数个数不同以外,其功能是完全相同的,此时才使用函数重载,如 ...

  10. eclipse:报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    JavaWeb: 报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bui ...