From patchwork Fri Jun 16 07:39:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9790805 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 8784360326 for ; Fri, 16 Jun 2017 07:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C871280B0 for ; Fri, 16 Jun 2017 07:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 712B02857E; Fri, 16 Jun 2017 07:39:59 +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=-6.9 required=2.0 tests=BAYES_00,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 EEB74280B0 for ; Fri, 16 Jun 2017 07:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752687AbdFPHj5 (ORCPT ); Fri, 16 Jun 2017 03:39:57 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33854 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752779AbdFPHj4 (ORCPT ); Fri, 16 Jun 2017 03:39:56 -0400 Received: by mail-pg0-f66.google.com with SMTP id j186so4551180pge.1 for ; Fri, 16 Jun 2017 00:39:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LlOSlFUmkEFkbBD17Ys6pGkx+XVaW8kmjQncLsHw418=; b=TrmtgvgtRYnJOK8MNYlR8ym6OGhgL7SwAhmUQuN86BFe+Ns/vJLPiflNVXAiqMJHwQ 9u2j8he+iOfMK7V2W90puh6JpYPmtfm8ExGicKPOPlwJU6wPEf2Z0uOLws005NrmbpeH NlEew7z0SOa9ZcSGYEj1A24ToN8GIghh8MXTCh3QeUDixguFJjKkmkdMYlQWcKN1ulL6 Do9XbYEybWQcxTEqLhQPOZI/rwHTI0bxobrCpAfSU6nmPSoYZ5/5xk1/cNCFMatAtFhx IfBR/rDDQus3/BMXn2yILLNVKblkc7+oSsp1TkSP/Sam4yNBCbESUsiT0KByPQr/dNGf 0QeA== X-Gm-Message-State: AKS2vOw/fo6t0p9Zuvvrc0pBVlIxGrtI7wycxQUDX5S0shmjOFXdJJjd e0Rl3HX7ESRqgOUszHE= X-Received: by 10.101.91.7 with SMTP id y7mr9739242pgq.226.1497598780934; Fri, 16 Jun 2017 00:39:40 -0700 (PDT) Received: from jade.nodan1.kt.home.ne.jp (202-72-64-244.koalanet.ne.jp. [202.72.64.244]) by smtp.gmail.com with ESMTPSA id a2sm2760568pfj.8.2017.06.16.00.39.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 00:39:40 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Javier Martinez Canillas , Mauro Carvalho Chehab , Shuah Khan , Gustavo Padovan Subject: [PATCH 07/12] [media] v4l: add support to BUF_QUEUED event Date: Fri, 16 Jun 2017 16:39:10 +0900 Message-Id: <20170616073915.5027-8-gustavo@padovan.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170616073915.5027-1-gustavo@padovan.org> References: <20170616073915.5027-1-gustavo@padovan.org> 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: Gustavo Padovan Implement the needed pieces to let userspace subscribe for V4L2_EVENT_BUF_QUEUED events. Videobuf2 will queue the event for the DQEVENT ioctl. Signed-off-by: Gustavo Padovan --- drivers/media/v4l2-core/v4l2-ctrls.c | 6 +++++- drivers/media/v4l2-core/videobuf2-core.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index 5aed7bd..f55b5da 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -3435,8 +3435,12 @@ EXPORT_SYMBOL(v4l2_ctrl_log_status); int v4l2_ctrl_subscribe_event(struct v4l2_fh *fh, const struct v4l2_event_subscription *sub) { - if (sub->type == V4L2_EVENT_CTRL) + switch (sub->type) { + case V4L2_EVENT_CTRL: return v4l2_event_subscribe(fh, sub, 0, &v4l2_ctrl_sub_ev_ops); + case V4L2_EVENT_BUF_QUEUED: + return v4l2_event_subscribe(fh, sub, 0, NULL); + } return -EINVAL; } EXPORT_SYMBOL(v4l2_ctrl_subscribe_event); diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 29aa9d4..00d9c35 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -1221,6 +1222,18 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb) return ret; } +static void vb2_buffer_queued_event(struct vb2_buffer *vb) +{ + struct video_device *vdev = to_video_device(vb->vb2_queue->dev); + struct v4l2_event event; + + memset(&event, 0, sizeof(event)); + event.type = V4L2_EVENT_BUF_QUEUED; + event.u.buf_queued.index = vb->index; + + v4l2_event_queue(vdev, &event); +} + /** * __enqueue_in_driver() - enqueue a vb2_buffer in driver for processing */ @@ -1234,6 +1247,8 @@ static void __enqueue_in_driver(struct vb2_buffer *vb) trace_vb2_buf_queue(q, vb); call_void_vb_qop(vb, buf_queue, vb); + + vb2_buffer_queued_event(vb); } static int __buf_prepare(struct vb2_buffer *vb, const void *pb)