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-19 23:58:19 +08:00 committed by Petro Karashchenko
parent d19aa5aca4
commit 9b2c89fc0e
4 changed files with 42 additions and 35 deletions

View File

@ -121,11 +121,11 @@ void drivers_initialize(void)
#endif
#ifdef CONFIG_UINPUT_TOUCH
uinput_touch_initialize("utouch", 1, 4);
uinput_touch_initialize();
#endif
#ifdef CONFIG_UINPUT_BUTTONS
uinput_button_initialize("ubutton");
uinput_button_initialize();
#endif
#ifdef CONFIG_NET_LOOPBACK

View File

@ -72,6 +72,18 @@ config UINPUT_TOUCH
---help---
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
bool "Enable uinput buttons"
select INPUT_BUTTONS

View File

@ -41,8 +41,12 @@
* Pre-processor Definitions
****************************************************************************/
#define UINPUT_NAME_SIZE 16
#define RPMSG_UINPUT_NAME "rpmsg-uinput-%s"
#define UINPUT_NAME_SIZE 16
#define UINPUT_NAME_RPMSG "rpmsg-uinput-%s"
#define UINPUT_NAME_TOUCH "utouch"
#define UINPUT_NAME_KEYBOARD "ukeyboard"
#define UINPUT_NAME_BUTTON "ubutton"
/****************************************************************************
* Private Types
@ -206,7 +210,7 @@ static void uinput_rpmsg_device_created(FAR struct rpmsg_device *rdev,
ept->ept.priv = ctx;
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,
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
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
*
* Input Parameters:
* name: Touchscreen devices name
* maxpoint: Maximum number of touch points supported.
* buff_nums: Number of the touch points structure.
* None
*
* Returned Value:
* 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
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;
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.maxpoint = maxpoint;
utcs_lower->lower.maxpoint = CONFIG_UINPUT_TOUCH_MAXPOINT;
#ifdef CONFIG_UINPUT_RPMSG
utcs_lower->ctx.notify = uinput_touch_notify;
#endif
/* Regiest Touchscreen device */
snprintf(devname, sizeof(devname), "/dev/%s", name);
ret = touch_register(&utcs_lower->lower, devname, buffnums);
ret = touch_register(&utcs_lower->lower,
"/dev/" UINPUT_NAME_TOUCH,
CONFIG_UINPUT_TOUCH_BUFNUMBER);
if (ret < 0)
{
kmm_free(utcs_lower);
@ -494,7 +496,7 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums)
}
#ifdef CONFIG_UINPUT_RPMSG
uinput_rpmsg_initialize(&utcs_lower->ctx, name);
uinput_rpmsg_initialize(&utcs_lower->ctx, UINPUT_NAME_TOUCH);
#endif
return 0;
@ -509,7 +511,7 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint, int buffnums)
* Initialized the uinput button device
*
* Input Parameters:
* name: Button devices name
* None
*
* Returned Value:
* 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
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;
int ret;
@ -534,8 +535,7 @@ int uinput_button_initialize(FAR const char *name)
ubtn_lower->ctx.notify = uinput_button_notify;
#endif
snprintf(devname, sizeof(devname), "/dev/%s", name);
ret = btn_register(devname, &ubtn_lower->lower);
ret = btn_register("/dev/" UINPUT_NAME_BUTTON, &ubtn_lower->lower);
if (ret < 0)
{
kmm_free(ubtn_lower);
@ -544,7 +544,7 @@ int uinput_button_initialize(FAR const char *name)
}
#ifdef CONFIG_UINPUT_RPMSG
uinput_rpmsg_initialize(&ubtn_lower->ctx, name);
uinput_rpmsg_initialize(&ubtn_lower->ctx, UINPUT_NAME_BUTTON);
#endif
return 0;
@ -556,7 +556,7 @@ int uinput_button_initialize(FAR const char *name)
* Name: uinput_keyboard_initialize
*
* Description:
* Initialized the uinput keyboard device
* None
*
* Input Parameters:
* name: keyboard devices name
@ -569,9 +569,8 @@ int uinput_button_initialize(FAR const char *name)
#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;
int ret;
@ -589,8 +588,7 @@ int uinput_keyboard_initialize(FAR const char *name)
/* Regiest Touchscreen device */
snprintf(devname, sizeof(devname), "/dev/%s", name);
ret = keyboard_register(&ukbd_lower->lower, devname);
ret = keyboard_register(&ukbd_lower->lower, "/dev/" UINPUT_NAME_KEYBOARD);
if (ret < 0)
{
kmm_free(ukbd_lower);
@ -599,7 +597,7 @@ int uinput_keyboard_initialize(FAR const char *name)
}
#ifdef CONFIG_UINPUT_RPMSG
uinput_rpmsg_initialize(&ukbd_lower->ctx, name);
uinput_rpmsg_initialize(&ukbd_lower->ctx, UINPUT_NAME_KEYBOARD);
#endif
return 0;

View File

@ -36,9 +36,7 @@
* Initialized the uinput touchscreen device
*
* Input Parameters:
* name: Touchscreen devices name
* maxpoint: Maximum number of touch points supported.
* buff_nums: Number of the touch points structure.
* None
*
* Returned Value:
* Zero is returned on success. Otherwise, a negated errno value is
@ -47,8 +45,7 @@
****************************************************************************/
#ifdef CONFIG_UINPUT_TOUCH
int uinput_touch_initialize(FAR const char *name, int maxpoint,
int buffnums);
int uinput_touch_initialize(void);
#endif
/****************************************************************************
@ -58,7 +55,7 @@ int uinput_touch_initialize(FAR const char *name, int maxpoint,
* Initialized the uinput keyboard device
*
* Input Parameters:
* name: keyboard devices name
* None
*
* Returned Value:
* 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
int uinput_keyboard_initialize(FAR const char *name);
int uinput_keyboard_initialize(void);
#endif
/****************************************************************************
@ -77,7 +74,7 @@ int uinput_keyboard_initialize(FAR const char *name);
* Initialized the uinput button device
*
* Input Parameters:
* name: Button devices name
* None
*
* Returned Value:
* 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
int uinput_button_initialize(FAR const char *name);
int uinput_button_initialize(void);
#endif
#endif /* __INCLUDE_NUTTX_INPUT_UINPUT_H */