linux 输入子系统(2) platform device
2015-10-09 14:43
489 查看
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设置时区和自动同步时间
- Xenlism WildFire: Linux 桌面的极简风格图标主题
- Xenlism WildFire: Linux 桌面的极简风格图标主题
- Linux 小知识
- golang开发环境mac下编译linux环境文件
- linux下c程序进程地址空间分布
- 记录使用vmware workstation11安装CentOS-6.6-x86_64-minimal.iso过程中遇到的问题及解决办法
- linux openssh源码安装
- centos 7 安装注意事项
- 使用yum快速升级CentOS 6.5内核到 3.10.28
- centos6.6 安装pip
- windows下通过rsync备份AD域控文件到linux服务器
- linux杂记
- Linux Performance Tools
- linux下登录mysql
- linux的权限管理以及特殊权限SUID,SGID,Sticky
- Linux进程间通信(一) - 管道
- Linux进程间通信(IPC)机制总览
- CentOS 6 NFS的安装配置
- linux中mkdir创建多个同级或下级目录