nuttx: Support for the mouse ioctl interface

Signed-off-by: liuhongchao <liuhongchao@xiaomi.com>
This commit is contained in:
liuhongchao
2024-10-29 10:45:01 +08:00
committed by Xiang Xiao
parent c15b900a88
commit 6dbd355c1f
3 changed files with 66 additions and 1 deletions
+33 -1
View File
@@ -68,6 +68,8 @@ static int mouse_open(FAR struct file *filep);
static int mouse_close(FAR struct file *filep);
static ssize_t mouse_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static int mouse_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
static int mouse_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
@@ -82,7 +84,7 @@ static const struct file_operations g_mouse_fops =
mouse_read, /* read */
NULL, /* write */
NULL, /* seek */
NULL, /* ioctl */
mouse_ioctl, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
mouse_poll /* poll */
@@ -217,6 +219,36 @@ out:
return ret;
}
/****************************************************************************
* Name: mouse_ioctl
****************************************************************************/
static int mouse_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct inode *inode = filep->f_inode;
FAR struct mouse_upperhalf_s *upper = inode->i_private;
FAR struct mouse_lowerhalf_s *lower = upper->lower;
int ret;
ret = nxmutex_lock(&upper->lock);
if (ret < 0)
{
return ret;
}
if (lower->control)
{
ret = lower->control(lower, cmd, arg);
}
else
{
ret = -ENOTTY;
}
nxmutex_unlock(&upper->lock);
return ret;
}
/****************************************************************************
* Name: mouse_poll
****************************************************************************/