video: tegra: Implement fops->poll() for control device
Robert Morell [Tue, 1 Mar 2011 23:33:15 +0000 (15:33 -0800)]
This is necessary for select() and poll() to work properly when clients
are waiting for events.

bug 818525

Original-Change-Id: If98b3e0706495884834813c9a352b946352cc2f5
Signed-off-by: Robert Morell <rmorell@nvidia.com>
Reviewed-on: http://git-master/r/40521
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

Rebase-Id: Rc8813923838bada46d87d71ef852960316eda2f7

drivers/video/tegra/dc/ext/control.c
drivers/video/tegra/dc/ext/events.c
drivers/video/tegra/dc/ext/tegra_dc_ext_priv.h

index 6cc2f9a..65d302f 100644 (file)
@@ -188,6 +188,7 @@ static const struct file_operations tegra_dc_ext_event_devops = {
        .open =                 tegra_dc_ext_control_open,
        .release =              tegra_dc_ext_control_release,
        .read =                 tegra_dc_ext_event_read,
+       .poll =                 tegra_dc_ext_event_poll,
        .unlocked_ioctl =       tegra_dc_ext_control_ioctl,
 };
 
index 226571e..150a150 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/err.h>
 #include <linux/fs.h>
 #include <linux/list.h>
+#include <linux/poll.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 
 static DECLARE_WAIT_QUEUE_HEAD(event_wait);
 
+unsigned int tegra_dc_ext_event_poll(struct file *filp, poll_table *wait)
+{
+       struct tegra_dc_ext_control_user *user = filp->private_data;
+       unsigned int mask = 0;
+
+       poll_wait(filp, &event_wait, wait);
+
+       if (atomic_read(&user->num_events))
+               mask |= POLLIN;
+
+       return mask;
+}
+
 static int get_next_event(struct tegra_dc_ext_control_user *user,
                          struct tegra_dc_ext_event_list *event,
                          bool block)
index a1cd883..6f0d0e4 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/cdev.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
+#include <linux/poll.h>
 
 #include <mach/dc.h>
 #include <mach/nvmap.h>
@@ -126,6 +127,7 @@ extern int tegra_dc_ext_queue_hotplug(struct tegra_dc_ext_control *,
                                      int output);
 extern ssize_t tegra_dc_ext_event_read(struct file *filp, char __user *buf,
                                       size_t size, loff_t *ppos);
+extern unsigned int tegra_dc_ext_event_poll(struct file *, poll_table *);
 
 extern int tegra_dc_ext_get_num_outputs(void);