input/uinput: Remove the argument from initialization function

since each type of uinput just need Instantiate one instance

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2022-03-21 09:03:05 +02:00
committed by Petro Karashchenko
parent d19aa5aca4
commit 9b2c89fc0e
4 changed files with 42 additions and 35 deletions
+2 -2
View File
@@ -121,11 +121,11 @@ void drivers_initialize(void)
#endif #endif
#ifdef CONFIG_UINPUT_TOUCH #ifdef CONFIG_UINPUT_TOUCH
uinput_touch_initialize("utouch", 1, 4); uinput_touch_initialize();
#endif #endif
#ifdef CONFIG_UINPUT_BUTTONS #ifdef CONFIG_UINPUT_BUTTONS
uinput_button_initialize("ubutton"); uinput_button_initialize();
#endif #endif
#ifdef CONFIG_NET_LOOPBACK #ifdef CONFIG_NET_LOOPBACK
+12
View File
@@ -72,6 +72,18 @@ config UINPUT_TOUCH
---help--- ---help---
Enable support virtual input touch device driver Enable support virtual input touch device driver
if UINPUT_TOUCH
config UINPUT_TOUCH_MAXPOINT
int "Maximum number of touch points supported"
default 1
config UINPUT_TOUCH_BUFNUMBER
int "Number of touch data buffer"
default 8
endif
config UINPUT_BUTTONS config UINPUT_BUTTONS
bool "Enable uinput buttons" bool "Enable uinput buttons"
select INPUT_BUTTONS select INPUT_BUTTONS
+22 -24
View File
@@ -41,8 +41,12 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define UINPUT_NAME_SIZE 16 #define UINPUT_NAME_SIZE 16
#define RPMSG_UINPUT_NAME "rpmsg-uinput-%s" #define UINPUT_NAME_RPMSG "rpmsg-uinput-%s"
#define UINPUT_NAME_TOUCH "utouch"
#define UINPUT_NAME_KEYBOARD "ukeyboard"
#define UINPUT_NAME_BUTTON "ubutton"
/**************************************************************************** /****************************************************************************
* Private Types * Private Types
@@ -206,7 +210,7 @@ static void uinput_rpmsg_device_created(FAR struct rpmsg_device *rdev,
ept->ept.priv = ctx; ept->ept.priv = ctx;
snprintf(rpmsg_ept_name, sizeof(rpmsg_ept_name), snprintf(rpmsg_ept_name, sizeof(rpmsg_ept_name),
RPMSG_UINPUT_NAME, ctx->name); UINPUT_NAME_RPMSG, ctx->name);
ret = rpmsg_create_ept(&ept->ept, rdev, rpmsg_ept_name, ret = rpmsg_create_ept(&ept->ept, rdev, rpmsg_ept_name,
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
uinput_rpmsg_ept_cb, NULL); uinput_rpmsg_ept_cb, NULL);
@@ -453,9 +457,7 @@ static ssize_t uinput_keyboard_write(FAR struct keyboard_lowerhalf_s *lower,
* Initialized the uinput touchscreen device * Initialized the uinput touchscreen device
* *
* Input Parameters: * Input Parameters:
* name: Touchscreen devices name * None
* maxpoint: Maximum number of touch points supported.
* buff_nums: Number of the touch points structure.
* *
* Returned Value: * Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is * Zero is returned on success. Otherwise, a negated errno value is
@@ -465,9 +467,8 @@ static ssize_t uinput_keyboard_write(FAR struct keyboard_lowerhalf_s *lower,
#ifdef CONFIG_UINPUT_TOUCH #ifdef CONFIG_UINPUT_TOUCH
int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums) int uinput_touch_initialize(void)
{ {
char devname[UINPUT_NAME_SIZE];
FAR struct uinput_touch_lowerhalf_s *utcs_lower; FAR struct uinput_touch_lowerhalf_s *utcs_lower;
int ret; int ret;
@@ -478,15 +479,16 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums)
} }
utcs_lower->lower.write = uinput_touch_write; utcs_lower->lower.write = uinput_touch_write;
utcs_lower->lower.maxpoint = maxpoint; utcs_lower->lower.maxpoint = CONFIG_UINPUT_TOUCH_MAXPOINT;
#ifdef CONFIG_UINPUT_RPMSG #ifdef CONFIG_UINPUT_RPMSG
utcs_lower->ctx.notify = uinput_touch_notify; utcs_lower->ctx.notify = uinput_touch_notify;
#endif #endif
/* Regiest Touchscreen device */ /* Regiest Touchscreen device */
snprintf(devname, sizeof(devname), "/dev/%s", name); ret = touch_register(&utcs_lower->lower,
ret = touch_register(&utcs_lower->lower, devname, buffnums); "/dev/" UINPUT_NAME_TOUCH,
CONFIG_UINPUT_TOUCH_BUFNUMBER);
if (ret < 0) if (ret < 0)
{ {
kmm_free(utcs_lower); kmm_free(utcs_lower);
@@ -494,7 +496,7 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums)
} }
#ifdef CONFIG_UINPUT_RPMSG #ifdef CONFIG_UINPUT_RPMSG
uinput_rpmsg_initialize(&utcs_lower->ctx, name); uinput_rpmsg_initialize(&utcs_lower->ctx, UINPUT_NAME_TOUCH);
#endif #endif
return 0; return 0;
@@ -509,7 +511,7 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums)
* Initialized the uinput button device * Initialized the uinput button device
* *
* Input Parameters: * Input Parameters:
* name: Button devices name * None
* *
* Returned Value: * Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is * Zero is returned on success. Otherwise, a negated errno value is
@@ -519,9 +521,8 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums)
#ifdef CONFIG_UINPUT_BUTTONS #ifdef CONFIG_UINPUT_BUTTONS
int uinput_button_initialize(FAR const char *name) int uinput_button_initialize(void)
{ {
char devname[UINPUT_NAME_SIZE];
FAR struct uinput_button_lowerhalf_s *ubtn_lower; FAR struct uinput_button_lowerhalf_s *ubtn_lower;
int ret; int ret;
@@ -534,8 +535,7 @@ int uinput_button_initialize(FAR const char *name)
ubtn_lower->ctx.notify = uinput_button_notify; ubtn_lower->ctx.notify = uinput_button_notify;
#endif #endif
snprintf(devname, sizeof(devname), "/dev/%s", name); ret = btn_register("/dev/" UINPUT_NAME_BUTTON, &ubtn_lower->lower);
ret = btn_register(devname, &ubtn_lower->lower);
if (ret < 0) if (ret < 0)
{ {
kmm_free(ubtn_lower); kmm_free(ubtn_lower);
@@ -544,7 +544,7 @@ int uinput_button_initialize(FAR const char *name)
} }
#ifdef CONFIG_UINPUT_RPMSG #ifdef CONFIG_UINPUT_RPMSG
uinput_rpmsg_initialize(&ubtn_lower->ctx, name); uinput_rpmsg_initialize(&ubtn_lower->ctx, UINPUT_NAME_BUTTON);
#endif #endif
return 0; return 0;
@@ -556,7 +556,7 @@ int uinput_button_initialize(FAR const char *name)
* Name: uinput_keyboard_initialize * Name: uinput_keyboard_initialize
* *
* Description: * Description:
* Initialized the uinput keyboard device * None
* *
* Input Parameters: * Input Parameters:
* name: keyboard devices name * name: keyboard devices name
@@ -569,9 +569,8 @@ int uinput_button_initialize(FAR const char *name)
#ifdef CONFIG_UINPUT_KEYBOARD #ifdef CONFIG_UINPUT_KEYBOARD
int uinput_keyboard_initialize(FAR const char *name) int uinput_keyboard_initialize(void)
{ {
char devname[UINPUT_NAME_SIZE];
FAR struct uinput_keyboard_lowerhalf_s *ukbd_lower; FAR struct uinput_keyboard_lowerhalf_s *ukbd_lower;
int ret; int ret;
@@ -589,8 +588,7 @@ int uinput_keyboard_initialize(FAR const char *name)
/* Regiest Touchscreen device */ /* Regiest Touchscreen device */
snprintf(devname, sizeof(devname), "/dev/%s", name); ret = keyboard_register(&ukbd_lower->lower, "/dev/" UINPUT_NAME_KEYBOARD);
ret = keyboard_register(&ukbd_lower->lower, devname);
if (ret < 0) if (ret < 0)
{ {
kmm_free(ukbd_lower); kmm_free(ukbd_lower);
@@ -599,7 +597,7 @@ int uinput_keyboard_initialize(FAR const char *name)
} }
#ifdef CONFIG_UINPUT_RPMSG #ifdef CONFIG_UINPUT_RPMSG
uinput_rpmsg_initialize(&ukbd_lower->ctx, name); uinput_rpmsg_initialize(&ukbd_lower->ctx, UINPUT_NAME_KEYBOARD);
#endif #endif
return 0; return 0;
+6 -9
View File
@@ -36,9 +36,7 @@
* Initialized the uinput touchscreen device * Initialized the uinput touchscreen device
* *
* Input Parameters: * Input Parameters:
* name: Touchscreen devices name * None
* maxpoint: Maximum number of touch points supported.
* buff_nums: Number of the touch points structure.
* *
* Returned Value: * Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is * Zero is returned on success. Otherwise, a negated errno value is
@@ -47,8 +45,7 @@
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_UINPUT_TOUCH #ifdef CONFIG_UINPUT_TOUCH
int uinput_touch_initialize(FAR const char *name, int maxpoint, int uinput_touch_initialize(void);
int buffnums);
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -58,7 +55,7 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint,
* Initialized the uinput keyboard device * Initialized the uinput keyboard device
* *
* Input Parameters: * Input Parameters:
* name: keyboard devices name * None
* *
* Returned Value: * Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is * Zero is returned on success. Otherwise, a negated errno value is
@@ -67,7 +64,7 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint,
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_UINPUT_KEYBOARD #ifdef CONFIG_UINPUT_KEYBOARD
int uinput_keyboard_initialize(FAR const char *name); int uinput_keyboard_initialize(void);
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -77,7 +74,7 @@ int uinput_keyboard_initialize(FAR const char *name);
* Initialized the uinput button device * Initialized the uinput button device
* *
* Input Parameters: * Input Parameters:
* name: Button devices name * None
* *
* Returned Value: * Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is * Zero is returned on success. Otherwise, a negated errno value is
@@ -86,7 +83,7 @@ int uinput_keyboard_initialize(FAR const char *name);
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_UINPUT_BUTTONS #ifdef CONFIG_UINPUT_BUTTONS
int uinput_button_initialize(FAR const char *name); int uinput_button_initialize(void);
#endif #endif
#endif /* __INCLUDE_NUTTX_INPUT_UINPUT_H */ #endif /* __INCLUDE_NUTTX_INPUT_UINPUT_H */