You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2025/07/07 11:47:05 UTC
(nuttx) 01/06: driver/touchscreen: add custom open/close
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9f6666b75bb59ff7b1ca29585265860d8db0f065
Author: wangjianyu3 <wa...@xiaomi.com>
AuthorDate: Sun Jul 6 00:29:25 2025 +0800
driver/touchscreen: add custom open/close
Add custom open/close for lower to init/deinit device.
Signed-off-by: wangjianyu3 <wa...@xiaomi.com>
---
drivers/input/touchscreen_upper.c | 11 +++++++++++
include/nuttx/input/touchscreen.h | 30 ++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/drivers/input/touchscreen_upper.c b/drivers/input/touchscreen_upper.c
index 12f7d1f5ff..9afcfcc82f 100644
--- a/drivers/input/touchscreen_upper.c
+++ b/drivers/input/touchscreen_upper.c
@@ -149,6 +149,11 @@ static int touch_open(FAR struct file *filep)
filep->f_priv = openpriv;
nxmutex_unlock(&upper->lock);
+ if (lower->open)
+ {
+ return lower->open(lower);
+ }
+
return ret;
}
@@ -161,6 +166,7 @@ static int touch_close(FAR struct file *filep)
FAR struct touch_openpriv_s *openpriv = filep->f_priv;
FAR struct inode *inode = filep->f_inode;
FAR struct touch_upperhalf_s *upper = inode->i_private;
+ FAR struct touch_lowerhalf_s *lower = upper->lower;
int ret;
ret = nxmutex_lock(&upper->lock);
@@ -181,6 +187,11 @@ static int touch_close(FAR struct file *filep)
kmm_free(openpriv);
nxmutex_unlock(&upper->lock);
+ if (lower->close)
+ {
+ return lower->close(lower);
+ }
+
return ret;
}
diff --git a/include/nuttx/input/touchscreen.h b/include/nuttx/input/touchscreen.h
index 26a39d68db..0f4190e323 100644
--- a/include/nuttx/input/touchscreen.h
+++ b/include/nuttx/input/touchscreen.h
@@ -273,6 +273,36 @@ struct touch_lowerhalf_s
CODE ssize_t (*write)(FAR struct touch_lowerhalf_s *lower,
FAR const char *buffer, size_t buflen);
+
+ /**************************************************************************
+ * Name: open
+ *
+ * Description:
+ * Users can use this interface to implement custom open().
+ *
+ * Arguments:
+ * lower - The instance of lower half of touchscreen device.
+ *
+ * Return Value:
+ * Zero(OK) on success; a negated errno value on failure.
+ **************************************************************************/
+
+ CODE int (*open)(FAR struct touch_lowerhalf_s *lower);
+
+ /**************************************************************************
+ * Name: close
+ *
+ * Description:
+ * Users can use this interface to implement custom close().
+ *
+ * Arguments:
+ * lower - The instance of lower half of touchscreen device.
+ *
+ * Return Value:
+ * Zero(OK) on success; a negated errno value on failure.
+ **************************************************************************/
+
+ CODE int (*close)(FAR struct touch_lowerhalf_s *lower);
};
/****************************************************************************