From 5e8838fd115879174567c4c2db8ad25331619994 Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Wed, 13 Oct 2004 16:40:53 +0000 Subject: [PATCH] Add a poll function that alternates between zero and normal poll return to bring DRM into conformance with normal poll(). --- linux-core/drmP.h | 1 + linux-core/drm_fops.c | 16 ++++++++++++++++ linux-core/ffb_drv.c | 1 + linux-core/i810_drv.c | 1 + linux-core/i830_drv.c | 1 + linux-core/i915_drv.c | 1 + linux-core/mach64_drv.c | 1 + linux-core/mga_drv.c | 1 + linux-core/r128_drv.c | 1 + linux-core/radeon_drv.c | 1 + linux-core/savage_drv.c | 1 + linux-core/sis_drv.c | 1 + linux-core/tdfx_drv.c | 1 + 13 files changed, 28 insertions(+) diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 583ead0f..8af9f359 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -749,6 +749,7 @@ extern int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t * dev); extern int drm_fasync(int fd, struct file *filp, int on); extern int drm_release(struct inode *inode, struct file *filp); +unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); /* Mapping support (drm_vm.h) */ extern void drm_vm_open(struct vm_area_struct *vma); diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index 0c62a1d0..54cebbcb 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -451,3 +451,19 @@ int drm_release(struct inode *inode, struct file *filp) return retcode; } EXPORT_SYMBOL(drm_release); + +/** No-op. */ +/* This is to deal with older X servers that believe 0 means data is + * available which is not the correct return for a poll function. + * By alternating returns both interfaces are happy. This is fixed + * in newer X servers. + */ +unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait) +{ + static int flip; + if ((flip = !flip)) + return (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM); + return 0; +} +EXPORT_SYMBOL(drm_poll); + diff --git a/linux-core/ffb_drv.c b/linux-core/ffb_drv.c index c4a1a9fa..8122e95e 100644 --- a/linux-core/ffb_drv.c +++ b/linux-core/ffb_drv.c @@ -324,6 +324,7 @@ static struct drm_driver ffb_driver = { .ioctl = drm_ioctl, .mmap = drm_mmap, .fasync = drm_fasync, + .poll = drm_poll, .get_unmapped_area = ffb_get_unmapped_area, }, }; diff --git a/linux-core/i810_drv.c b/linux-core/i810_drv.c index bfeb35a8..6ffa167d 100644 --- a/linux-core/i810_drv.c +++ b/linux-core/i810_drv.c @@ -114,6 +114,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = i810_mmap_buffers, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/i830_drv.c b/linux-core/i830_drv.c index e7c00a80..0846da6c 100644 --- a/linux-core/i830_drv.c +++ b/linux-core/i830_drv.c @@ -124,6 +124,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = i830_mmap_buffers, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/i915_drv.c b/linux-core/i915_drv.c index 6cb27743..f0298e17 100644 --- a/linux-core/i915_drv.c +++ b/linux-core/i915_drv.c @@ -89,6 +89,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/mach64_drv.c b/linux-core/mach64_drv.c index e1be1fa8..3f736aa3 100644 --- a/linux-core/mach64_drv.c +++ b/linux-core/mach64_drv.c @@ -106,6 +106,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/mga_drv.c b/linux-core/mga_drv.c index 6e90e5dc..65e9d9c1 100644 --- a/linux-core/mga_drv.c +++ b/linux-core/mga_drv.c @@ -111,6 +111,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/r128_drv.c b/linux-core/r128_drv.c index 31ee1aaa..0a34625a 100644 --- a/linux-core/r128_drv.c +++ b/linux-core/r128_drv.c @@ -121,6 +121,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/radeon_drv.c b/linux-core/radeon_drv.c index dbf530f6..fbf6b23a 100644 --- a/linux-core/radeon_drv.c +++ b/linux-core/radeon_drv.c @@ -161,6 +161,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/savage_drv.c b/linux-core/savage_drv.c index ffec6e73..e8591689 100644 --- a/linux-core/savage_drv.c +++ b/linux-core/savage_drv.c @@ -299,6 +299,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/sis_drv.c b/linux-core/sis_drv.c index f5168473..a6300509 100644 --- a/linux-core/sis_drv.c +++ b/linux-core/sis_drv.c @@ -88,6 +88,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = { diff --git a/linux-core/tdfx_drv.c b/linux-core/tdfx_drv.c index 66d57284..9062cb0a 100644 --- a/linux-core/tdfx_drv.c +++ b/linux-core/tdfx_drv.c @@ -79,6 +79,7 @@ static struct drm_driver driver = { .release = drm_release, .ioctl = drm_ioctl, .mmap = drm_mmap, + .poll = drm_poll, .fasync = drm_fasync, }, .pci_driver = {