All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] ngene: add proper polling to the dvbdev_ci file ops
@ 2018-02-25 17:06 Daniel Scheller
  0 siblings, 0 replies; only message in thread
From: Daniel Scheller @ 2018-02-25 17:06 UTC (permalink / raw)
  To: linux-media, mchehab, mchehab

From: Daniel Scheller <d.scheller@gmx.net>

Implement the poll callback for the dvbdev_ci file ops. The ts_poll()
function queries the DVB ring buffers for available data and space, and
reports this as appropriate. Also, set the dvb_device readers, writers
and users to proper values (one reader, one writer, two users).

This fixes the raw CI TS transport in conjunction with TVheadend's
DDCI functionality.

Signed-off-by: Daniel Scheller <d.scheller@gmx.net>
---
This patch was committed ontop of the ngene hardware/tsfix series, so it
might conflict if that series isn't applied beforehand (I honestly didn't
test that).

 drivers/media/pci/ngene/ngene-dvb.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/ngene/ngene-dvb.c b/drivers/media/pci/ngene/ngene-dvb.c
index 0f9759a4d124..2df641e05fca 100644
--- a/drivers/media/pci/ngene/ngene-dvb.c
+++ b/drivers/media/pci/ngene/ngene-dvb.c
@@ -87,18 +87,41 @@ static ssize_t ts_read(struct file *file, char __user *buf,
 	return count;
 }
 
+static __poll_t ts_poll(struct file *file, poll_table *wait)
+{
+	struct dvb_device *dvbdev = file->private_data;
+	struct ngene_channel *chan = dvbdev->priv;
+	struct ngene *dev = chan->dev;
+	struct dvb_ringbuffer *rbuf = &dev->tsin_rbuf;
+	struct dvb_ringbuffer *wbuf = &dev->tsout_rbuf;
+	__poll_t mask = 0;
+
+	poll_wait(file, &rbuf->queue, wait);
+	poll_wait(file, &wbuf->queue, wait);
+
+	if (!dvb_ringbuffer_empty(rbuf))
+		mask |= EPOLLIN | EPOLLRDNORM;
+	if (dvb_ringbuffer_free(wbuf) >= 188)
+		mask |= EPOLLOUT | EPOLLWRNORM;
+
+	return mask;
+}
+
 static const struct file_operations ci_fops = {
 	.owner   = THIS_MODULE,
 	.read    = ts_read,
 	.write   = ts_write,
 	.open    = dvb_generic_open,
 	.release = dvb_generic_release,
+	.poll    = ts_poll,
+	.mmap    = NULL,
 };
 
 struct dvb_device ngene_dvbdev_ci = {
-	.readers = -1,
-	.writers = -1,
-	.users   = -1,
+	.priv    = NULL,
+	.readers = 1,
+	.writers = 1,
+	.users   = 2,
 	.fops    = &ci_fops,
 };
 
-- 
2.16.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-25 17:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-25 17:06 [PATCH] [media] ngene: add proper polling to the dvbdev_ci file ops Daniel Scheller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.