You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/11/30 17:37:19 UTC
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #7738: drivers/video/fb: add poll support
xiaoxiang781216 commented on code in PR #7738:
URL: https://github.com/apache/nuttx/pull/7738#discussion_r1036263563
##########
drivers/video/fb.c:
##########
@@ -544,6 +548,78 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
return ret;
}
+/****************************************************************************
+ * Name: fb_poll
+ *
+ * Description:
+ * Wait for framebuffer to be writable.
+ *
+ ****************************************************************************/
+
+static int fb_poll(FAR struct file *filep, struct pollfd *fds, bool setup)
+{
+ FAR struct inode *inode;
+ FAR struct fb_chardev_s *fb;
+
+ /* Get the framebuffer instance */
+
+ DEBUGASSERT(filep != NULL && filep->f_inode != NULL);
+ inode = filep->f_inode;
+ fb = (FAR struct fb_chardev_s *)inode->i_private;
+
+ if (setup)
+ {
+ if (fb->fds == NULL)
+ {
+ fb->vtable->chardev = fb;
+ fb->fds = fds;
+ fds->priv = &fb->fds;
+ }
+ else
+ {
+ return -EBUSY;
+ }
+ }
+ else if (fds->priv)
+ {
+ fb->fds = NULL;
+ fds->priv = NULL;
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: fb_pollnotify
+ *
+ * Description:
+ * Notify the waiting thread that the framebuffer can be written.
+ *
+ * Input Parameters:
+ * vtable - Pointer to framebuffer's virtual table.
+ *
+ * Returned Value:
+ * Zero (OK) is returned success; a negated errno value is returned on any
+ * failure.
+ *
+ ****************************************************************************/
+
+int fb_pollnotify(FAR struct fb_vtable_s *vtable)
Review Comment:
int->void
##########
drivers/video/fb.c:
##########
@@ -544,6 +548,78 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
return ret;
}
+/****************************************************************************
+ * Name: fb_poll
+ *
+ * Description:
+ * Wait for framebuffer to be writable.
+ *
+ ****************************************************************************/
+
+static int fb_poll(FAR struct file *filep, struct pollfd *fds, bool setup)
+{
+ FAR struct inode *inode;
+ FAR struct fb_chardev_s *fb;
+
+ /* Get the framebuffer instance */
+
+ DEBUGASSERT(filep != NULL && filep->f_inode != NULL);
+ inode = filep->f_inode;
+ fb = (FAR struct fb_chardev_s *)inode->i_private;
+
+ if (setup)
+ {
+ if (fb->fds == NULL)
+ {
+ fb->vtable->chardev = fb;
+ fb->fds = fds;
+ fds->priv = &fb->fds;
+ }
+ else
+ {
+ return -EBUSY;
+ }
+ }
+ else if (fds->priv)
+ {
+ fb->fds = NULL;
+ fds->priv = NULL;
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: fb_pollnotify
+ *
+ * Description:
+ * Notify the waiting thread that the framebuffer can be written.
+ *
+ * Input Parameters:
+ * vtable - Pointer to framebuffer's virtual table.
+ *
+ * Returned Value:
+ * Zero (OK) is returned success; a negated errno value is returned on any
+ * failure.
+ *
+ ****************************************************************************/
+
+int fb_pollnotify(FAR struct fb_vtable_s *vtable)
+{
+ DEBUGASSERT(vtable != NULL);
+
+ if (vtable->chardev == NULL || vtable->chardev->fds == NULL)
Review Comment:
remove the check don't need
##########
include/nuttx/video/fb.h:
##########
@@ -613,6 +615,10 @@ struct fb_vtable_s
/* Enable/disable panel power (0: full off). */
int (*setpower)(FAR struct fb_vtable_s *vtable, int power);
+
+ /* Pointer to framebuffer device private data. */
+
+ FAR struct fb_chardev_s *chardev;
Review Comment:
```suggestion
FAR struct void *priv;
```
and remove line 299
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org