Linux input Subsystem (2) Platform device

Source: Internet
Author: User

The Input platform device is typically a resource registered in the board-level BSP.

Take Gpio-keys as an example:

#################### #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_*) *//Escalation event code
int Gpio; /* Gpio num*/
int active_low; is low-level active
const char *DESC; /* Function Description */
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 *//* jitter interval, in microseconds per unit */
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

/* below indicates that five Gpio button information will be registered */
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 */

Registering Platform button device

#ifdef Config_keyboard_gpio
Platform_device_register (&button_device);
#endif

Linux input Subsystem (2) platform device

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.