From patchwork Tue Jun 7 15:05:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 857342 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p57F5e6R010205 for ; Tue, 7 Jun 2011 15:05:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755522Ab1FGPFq (ORCPT ); Tue, 7 Jun 2011 11:05:46 -0400 Received: from smtp-vbr1.xs4all.nl ([194.109.24.21]:1868 "EHLO smtp-vbr1.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755403Ab1FGPFk (ORCPT ); Tue, 7 Jun 2011 11:05:40 -0400 Received: from tschai.lan (215.80-203-102.nextgentel.com [80.203.102.215]) (authenticated bits=0) by smtp-vbr1.xs4all.nl (8.13.8/8.13.8) with ESMTP id p57F5Qqb037616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Jun 2011 17:05:38 +0200 (CEST) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [RFCv3 PATCH 17/18] ivtv: add control event support. Date: Tue, 7 Jun 2011 17:05:22 +0200 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: <1307459123-17810-1-git-send-email-hverkuil@xs4all.nl> References: <1307459123-17810-1-git-send-email-hverkuil@xs4all.nl> In-Reply-To: References: X-Virus-Scanned: by XS4ALL Virus Scanner Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Jun 2011 15:05:54 +0000 (UTC) From: Hans Verkuil Signed-off-by: Hans Verkuil --- drivers/media/video/ivtv/ivtv-fileops.c | 34 +++++++++++++----------------- drivers/media/video/ivtv/ivtv-ioctl.c | 2 + 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index a7f54b0..75c0354 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c @@ -750,31 +750,27 @@ unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait) struct ivtv *itv = id->itv; struct ivtv_stream *s = &itv->streams[id->type]; int eof = test_bit(IVTV_F_S_STREAMOFF, &s->s_flags); + unsigned res = 0; - /* Start a capture if there is none */ - if (!eof && !test_bit(IVTV_F_S_STREAMING, &s->s_flags)) { - int rc; + IVTV_DEBUG_HI_FILE("Encoder poll\n"); - mutex_lock(&itv->serialize_lock); - rc = ivtv_start_capture(id); - mutex_unlock(&itv->serialize_lock); - if (rc) { - IVTV_DEBUG_INFO("Could not start capture for %s (%d)\n", - s->name, rc); - return POLLERR; - } - IVTV_DEBUG_FILE("Encoder poll started capture\n"); - } + /* Start a capture if there is none */ + if (!eof && !test_bit(IVTV_F_S_STREAMING, &s->s_flags)) + res = POLLIN | POLLRDNORM; - /* add stream's waitq to the poll list */ - IVTV_DEBUG_HI_FILE("Encoder poll\n"); - poll_wait(filp, &s->waitq, wait); + if (v4l2_event_pending(&id->fh)) + res |= POLLPRI; + else + poll_wait(filp, &id->fh.events->wait, wait); if (s->q_full.length || s->q_io.length) - return POLLIN | POLLRDNORM; + return res | POLLIN | POLLRDNORM; if (eof) - return POLLHUP; - return 0; + return res | POLLHUP; + + /* add stream's waitq to the poll list */ + poll_wait(filp, &s->waitq, wait); + return res; } void ivtv_stop_capture(struct ivtv_open_id *id, int gop_end) diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 1689783..a81b4be 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c @@ -1445,6 +1445,8 @@ static int ivtv_subscribe_event(struct v4l2_fh *fh, struct v4l2_event_subscripti case V4L2_EVENT_VSYNC: case V4L2_EVENT_EOS: break; + case V4L2_EVENT_CTRL: + return v4l2_ctrl_subscribe_fh(fh, sub, 0); default: return -EINVAL; }