Input  platform  device 一般是在板级bsp注册了的资源。

以gpio-keys为例:

#####################gpio_key.h##############################

#ifndef _GPIO_KEYS_H
#define _GPIO_KEYS_H

struct gpio_keys_button {
    /* Configuration parameters */
    unsigned int code;    /* input event code (KEY_*, SW_*) */   //上报事件的code
    int gpio;                   /* gpio num*/
    int active_low;         //是否低电平有效
    const char *desc;     /* 功能描述 */
    unsigned int type;    /* input event type (EV_KEY, EV_SW, EV_ABS) */
    int wakeup;        /* configure the button as a wake-up source */
    int debounce_interval;    /* debounce ticks interval in msecs *//* 去抖动间隔,单位微秒*/
    int lock_interval;    /* pause for a moment when the key is pressed */
    bool can_disable;
    int value;        /* axis value for EV_ABS */
};

struct gpio_keys_platform_data {
    struct gpio_keys_button *buttons;
    int nbuttons;
    unsigned int poll_interval;    /* polling interval in msecs -
                       for polling driver only */
    unsigned int rep:1;        /* enable input subsystem auto repeat */
    int (*enable)(struct device *dev);
    void (*disable)(struct device *dev);
    const char *name;        /* input device name */
};

#endif

######################################################################

#ifdef CONFIG_KEYBOARD_GPIO

/*以下表明即将注册五个gpio button信息*/
static struct gpio_keys_button board_buttons[] = {
#ifdef GPIO_RECORD
    {
        .gpio        = GPIO_RECORD,
        .code        = KEY_RECORD,
        .desc        = "record key",
        .active_low    = 1,
    },
#endif
#ifdef GPIO_AP_STA
    {
        .gpio        = GPIO_AP_STA,
        .code        = KEY_MODE,
        .desc        = "ap/sta shift",
        .active_low    = 1,
    },
#endif
#ifdef GPIO_POWER
    {
        .gpio        = GPIO_POWER,
        .code        = KEY_POWER,
        .desc        = "power wakeup",
        .active_low    = 1,
        .wakeup        = 1,
    },
#endif
#ifdef GPIO_VOLUMEDOWN
    {
        .gpio        = GPIO_VOLUMEDOWN,
        .code        = KEY_VOLUMEDOWN,
        .desc        = "volum down key",
        .active_low    = 1,
    },
#endif
#ifdef GPIO_VOLUMEUP
    {
        .gpio        = GPIO_VOLUMEUP,
        .code        = KEY_VOLUMEUP,
        .desc        = "volum up key",
        .active_low    = 1,
    },
#endif
};

static struct gpio_keys_platform_data board_button_data = {
    .buttons    = board_buttons,
    .nbuttons    = ARRAY_SIZE(board_buttons),
};

static struct platform_device button_device = {
    .name        = "gpio-keys",
    .id        = -1,
    .num_resources    = 0,
    .dev        = {
        .platform_data    = &board_button_data,
    }
};
#endif/* CONFIG_KEYBOARD_GPIO */

 

 

//注册platform button device

#ifdef CONFIG_KEYBOARD_GPIO
    platform_device_register(&button_device);
#endif

linux 输入子系统(2) platform device的更多相关文章

  1. Linux输入子系统详解

    input输入子系统框架  linux输入子系统(linux input subsystem)从上到下由三层实现,分别为:输入子系统事件处理层(EventHandler).输入子系统核心层(Input ...

  2. linux输入子系统

    linux输入子系统(linux input subsystem)从上到下由三层实现,分别为:输入子系统事件处理层(EventHandler).输入子系统核心层(InputCore)和输入子系统设备驱 ...

  3. linux输入子系统(input subsystem)之evdev.c事件处理过程

    1.代码 input_subsys.drv.c 在linux输入子系统(input subsystem)之按键输入和LED控制的基础上有小改动,input_subsys_test.c不变. input ...

  4. Linux输入子系统(转)

    Linux输入子系统(Input Subsystem) 1.1.input子系统概述 输入设备(如按键,键盘,触摸屏,鼠标等)是典型的字符设备,其一般的工作机制是低层在按键,触摸等动作发生时产生一个中 ...

  5. Linux输入子系统(Input Subsystem)

    Linux输入子系统(Input Subsystem) http://blog.csdn.net/lbmygf/article/details/7360084 input子系统分析  http://b ...

  6. Linux输入子系统框架分析(1)

    在Linux下的输入设备键盘.触摸屏.鼠标等都能够用输入子系统来实现驱动.输入子系统分为三层,核心层和设备驱动层.事件层.核心层和事件层由Linux输入子系统本身实现,设备驱动层由我们实现.我们在设备 ...

  7. linux输入子系统概念介绍

    在此文章之前,我们讲解的都是简单的字符驱动,涉及的内容有字符驱动的框架.自动创建设备节点.linux中断.poll机制.异步通知.同步互斥.非阻塞.定时器去抖动. 上一节文章链接:http://blo ...

  8. linux输入子系统简述【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/7678035 1,linux输入子系统简述 其实驱动这部分大多还是转载别人的,linux ...

  9. 7.Linux 输入子系统分析

    为什么要引入输入子系统? 在前面我们写了一些简单的字符设备的驱动程序,我们是怎么样打开一个设备并操作的呢? 一般都是在执行应用程序时,open一个特定的设备文件,如:/dev/buttons .... ...

随机推荐

  1. ASP.NET上传大文件404报错

    报错信息: Failed to load resource: the server responded with a status of 404 (Not Found) 尝试1: 仅修改Web.con ...

  2. window.location.href跳转问题

    任务中遇到这样一个问题,用window.location.href跳转一到个网址,但是每次都出错,显示网址前面加上了文件所在文件夹的路径 示例如下: window.location.href=&quo ...

  3. python 向MySQL里插入中文数据

    用python向MySQL中插入中文数据出错,原代码片段: 1 db = MySQLdb.connect("localhost","root","12 ...

  4. 最小的图灵完备语言——BrainFuck

    最小的图灵完备语言--BrainFuck 图灵完备性(Turing completness) 在可计算性理论(computability theory)中,图灵等价指的是:对于两个计算机A和B,如果A ...

  5. 使用HttpClient实现对第三方服务器的请求并接受返回数据

    /* * 创建日期 2017-4-7 * * TODO 要更改此生成的文件的模板,请转至 * 窗口 - 首选项 - Java - 代码样式 - 代码模板 */ package com.enfo.int ...

  6. 2013年EI收录的中国期刊

    ISSN 刊名 0567-7718 Acta Mechanica Sinica 1006-7191 Acta Metallurgica Sinica (English Letters) 0253-48 ...

  7. http 400报错

    http 400报错---springmvc相关: 1.使用了json入参,传递给了对象,如果对象里的属性,如这里的Bonus是int类型,你传入了非int类型,这里就会报400 2.使用了@Requ ...

  8. python虚拟环境使用

    Window 下创建python的虚拟环境 下载工具 pip install virtualenv 创建虚拟环境目录 # 注意此命令创建的虚拟环境目录是在当前目录下 virtualenv testen ...

  9. Yii 之控制器响应

    public function actionIndex(){ //控制器响应处理 $res = \Yii::$app->response; //设置状态码 // $res->statusC ...

  10. Netty和Akka有什么不同?

    摘要: Akka is a concurrency framework built around the notion of actors and composable futures, Akka w ...