From patchwork Fri Jan 4 20:59:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 1934801 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6F976402E1 for ; Fri, 4 Jan 2013 21:00:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755097Ab3ADVAG (ORCPT ); Fri, 4 Jan 2013 16:00:06 -0500 Received: from mail-vb0-f45.google.com ([209.85.212.45]:34833 "EHLO mail-vb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754865Ab3ADVAB (ORCPT ); Fri, 4 Jan 2013 16:00:01 -0500 Received: by mail-vb0-f45.google.com with SMTP id p1so17128666vbi.32 for ; Fri, 04 Jan 2013 13:00:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=IcAQKtxGSkZ3IDe4hvQCf8BaTnsx/nUj086/MyzhrhU=; b=E3lYrtNwspK/6NsNhdGsQc1jp8xvQO2aDc9nGeGwQp2KoKHIyexLbZTM2+ihqS9scp Yt/BWD7ndy9fcOASraxNAihVkqo9Fj1Fw1C/gwhq3N415GNP2EsMWHyXk8e2JhOOVF27 1pOerMoaOE4N252A4CiH6drsS8RsaNiHUdNSKaPMAmRsZtj+SHC1tzysmDZDOzileLWP WoVatJbRgKgID04tZ9s7/TV/k4YMI4t7tcVhEKWkK3Jy0MHJFNcqNvUpxXY4q12aRr8z bSUjnBiMp9aJb58XO49yIoeZ2cy10xVzzDtHGlIlwKexyCOvhyTSMDVd5f8iUI05uHf2 mdRQ== X-Received: by 10.220.8.138 with SMTP id h10mr76126045vch.35.1357333200456; Fri, 04 Jan 2013 13:00:00 -0800 (PST) Received: from devin-ubuntu2.home (pool-108-54-72-165.nycmny.fios.verizon.net. [108.54.72.165]) by mx.google.com with ESMTPS id z20sm47278440vds.12.2013.01.04.12.59.59 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Jan 2013 13:00:00 -0800 (PST) From: Devin Heitmueller To: linux-media@vger.kernel.org Cc: Devin Heitmueller , Hans Verkuil Subject: [PATCH 08/15] em28xx: add support for control events. Date: Fri, 4 Jan 2013 15:59:38 -0500 Message-Id: <1357333186-8466-9-git-send-email-dheitmueller@kernellabs.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357333186-8466-1-git-send-email-dheitmueller@kernellabs.com> References: <1357333186-8466-1-git-send-email-dheitmueller@kernellabs.com> X-Gm-Message-State: ALoCoQm/hl468ShXQ8RNeSF740yf94WPjBOImOLDoyPaabxHEP/5mDz+3YnJXBnwxLV5DNpVOGwm Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Signed-off-by: Hans Verkuil Signed-off-by: Devin Heitmueller --- drivers/media/usb/em28xx/em28xx-video.c | 38 +++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index c67ff8d..acdb434 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -40,6 +40,7 @@ #include "em28xx.h" #include #include +#include #include #include #include @@ -1927,24 +1928,33 @@ em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count, static unsigned int em28xx_poll(struct file *filp, poll_table *wait) { struct em28xx_fh *fh = filp->private_data; + unsigned long req_events = poll_requested_events(wait); struct em28xx *dev = fh->dev; + unsigned int res = 0; int rc; rc = check_dev(dev); if (rc < 0) - return rc; - - if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { - if (!res_get(fh, EM28XX_RESOURCE_VIDEO)) - return POLLERR; - return videobuf_poll_stream(filp, &fh->vb_vidq, wait); - } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { - if (!res_get(fh, EM28XX_RESOURCE_VBI)) - return POLLERR; - return videobuf_poll_stream(filp, &fh->vb_vbiq, wait); - } else { - return POLLERR; + return DEFAULT_POLLMASK; + + if (v4l2_event_pending(&fh->fh)) + res = POLLPRI; + else if (req_events & POLLPRI) + poll_wait(filp, &fh->fh.wait, wait); + + if (req_events & (POLLIN | POLLRDNORM)) { + if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { + if (!res_get(fh, EM28XX_RESOURCE_VIDEO)) + return res | POLLERR; + return videobuf_poll_stream(filp, &fh->vb_vidq, wait); + } + if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { + if (!res_get(fh, EM28XX_RESOURCE_VBI)) + return res | POLLERR; + return res | videobuf_poll_stream(filp, &fh->vb_vbiq, wait); + } } + return res; } static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table *wait) @@ -2032,6 +2042,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { .vidioc_s_tuner = vidioc_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register, @@ -2061,6 +2073,8 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = { .vidioc_s_tuner = radio_s_tuner, .vidioc_g_frequency = vidioc_g_frequency, .vidioc_s_frequency = vidioc_s_frequency, + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, #ifdef CONFIG_VIDEO_ADV_DEBUG .vidioc_g_register = vidioc_g_register, .vidioc_s_register = vidioc_s_register,