From patchwork Sun Feb 25 17:06:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scheller X-Patchwork-Id: 10240987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2C15F603B4 for ; Sun, 25 Feb 2018 17:07:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0868F29A65 for ; Sun, 25 Feb 2018 17:07:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F08F029CEC; Sun, 25 Feb 2018 17:07:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84A3E29A65 for ; Sun, 25 Feb 2018 17:07:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751805AbeBYRHB (ORCPT ); Sun, 25 Feb 2018 12:07:01 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53760 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbeBYRHB (ORCPT ); Sun, 25 Feb 2018 12:07:01 -0500 Received: by mail-wm0-f68.google.com with SMTP id t74so13277005wme.3 for ; Sun, 25 Feb 2018 09:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=LDN2qqcQRRUCDXHUifaSVZgHcUYudYVCXITWZ2XXX7Y=; b=hPBtuHsqlGDWGalQfx3i+fekmee8+QHQVRR9mqpcgcCDPpN7w082s/sFZMBV4QrFHj j3yN9dYRljS7bJsqB0NL49j94mSQOciidcSnYCO2oMrolqGkQ87oX/ky9zmoX+0wHBT2 Cy/ftH8O3Rnh7c5Lvyd2tMu6bWNQY2NOGam0BHIpv69DucZFiqkPj49ViVDk9x4gY0c8 bn+el4wdWnQB6yQemXQuh8rLwtIvvg2y6Ftrmm28uwjhuAmGKPSKCrDQ6jhV0QgFR2ej XyLte2grm7h6z/BbJ8NDV1kWnNH4k7WiobUQJSzmtsLYVfOvJ7SJcolrSA8yNr+zfSCM nC5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=LDN2qqcQRRUCDXHUifaSVZgHcUYudYVCXITWZ2XXX7Y=; b=gG/da9189Y7rDOG4mdunCUPUkyMe2QmJ7aTUDzmgBJedrKJPbE2IKaZrw10pSMX7QT YEHYS8CWydxylApcmyuB4z1fpyaOx80xu7oTbbhMLqEb+FlghJgdUpGdR/pnjxHEaf32 jTiaGzwKElNtuA2tGNc+fswwMWRDSH5DaFsfu+A2JZYR60RM/jBppXXLXpNrbGHyFxTi o0ZwM5XPfkiNMXC8oufNBasJEnNn0FuQ/CRIXA8IlgWouwmPqTCoGNa/h1p0gQqk+Yyf 7035+Bgha7un/ovTgqnNjcrnAB/fPMDk1n9g5z2GbClDxdxuUodEfpT2DPaGPW+yjPGf hDlg== X-Gm-Message-State: APf1xPCDg7sXeChBzW9ybLaqaf96H8fpJeHbhrFQ+nUI/QWSfUnAjWzA H84dfoohEvJh++DdY8B7pAWG6g== X-Google-Smtp-Source: AG47ELv840aYpbwGluULOzmpYukky98bajjIYNZVTuzSyX+m7ldP7d8yQCrofrcmI9UcFeKCBKuZHQ== X-Received: by 10.28.39.67 with SMTP id n64mr6168631wmn.71.1519578419595; Sun, 25 Feb 2018 09:06:59 -0800 (PST) Received: from dvbdev.wuest.de (ip-84-118-193-200.unity-media.net. [84.118.193.200]) by smtp.gmail.com with ESMTPSA id j132sm6967452wmd.27.2018.02.25.09.06.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Feb 2018 09:06:58 -0800 (PST) From: Daniel Scheller To: linux-media@vger.kernel.org, mchehab@kernel.org, mchehab@s-opensource.com Subject: [PATCH] [media] ngene: add proper polling to the dvbdev_ci file ops Date: Sun, 25 Feb 2018 18:06:56 +0100 Message-Id: <20180225170656.10358-1-d.scheller.oss@gmail.com> X-Mailer: git-send-email 2.16.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Scheller 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 --- 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, };