From patchwork Fri Oct 4 13:49:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 2988761 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6B283BFF0B for ; Fri, 4 Oct 2013 13:50:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2FA0720340 for ; Fri, 4 Oct 2013 13:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0995620304 for ; Fri, 4 Oct 2013 13:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754357Ab3JDNuG (ORCPT ); Fri, 4 Oct 2013 09:50:06 -0400 Received: from mail-lb0-f181.google.com ([209.85.217.181]:61380 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754249Ab3JDNuF (ORCPT ); Fri, 4 Oct 2013 09:50:05 -0400 Received: by mail-lb0-f181.google.com with SMTP id u14so3326110lbd.12 for ; Fri, 04 Oct 2013 06:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=fvVQbhlAgu35/MtPNEJdKBAKVyLHDo/4828ryCUpU+s=; b=WY9XjneY3pIBi34sTal3TCzdeOyCM4+IGClLzhfTN96ydHqYztoe7wyEZjJK7SU4Sb ZXfFYUzcPo8uJJjW4fDVUr3dx0kOa8uwZWfuf+dBeJslcC9dYvb+i51QPg5nw1No49Ch fXtOAtgVQiZ3uMLSRwII0wQOia3alySzLaop07jPrggKcGaxYkz/PXfenGlZYO/GsIMa 5Vg+Zu+xmy0fWhHmPqs6hktxI/OwJg2InB9yBY929rV40Ho/Ah49YBE87a3fWlsLQqJT uWGgBvfr2oEDnIZLtAA6VCFVNaZX7WuJfDXBVaIHVdD5eISV8lBUxqFanvqwBVX0xPpU HH9g== X-Received: by 10.152.120.228 with SMTP id lf4mr1420244lab.44.1380894603392; Fri, 04 Oct 2013 06:50:03 -0700 (PDT) Received: from neopili.qtec.com (0x4dd4aed9.adsl.cybercity.dk. [77.212.174.217]) by mx.google.com with ESMTPSA id o1sm11212207lah.8.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 04 Oct 2013 06:50:02 -0700 (PDT) From: Ricardo Ribalda Delgado To: Pawel Osciak , Marek Szyprowski , Kyungmin Park , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH] vb2: Allow STREAMOFF for io emulator Date: Fri, 4 Oct 2013 15:49:58 +0200 Message-Id: <1380894598-11242-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 1.8.4.rc3 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A video device opened and streaming in io emulator mode can only stop streamming if its file descriptor is closed. There are some parameters that can only be changed if the device is not streaming. Also, the power consumption of a device streaming could be different than one not streaming. With this patch a video device opened in io emulator can be stopped on demand. Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/videobuf2-core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 9fc4bab..097fba8 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1686,6 +1686,7 @@ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) } EXPORT_SYMBOL_GPL(vb2_streamon); +static int __vb2_cleanup_fileio(struct vb2_queue *q); /** * vb2_streamoff - stop streaming @@ -1704,11 +1705,6 @@ EXPORT_SYMBOL_GPL(vb2_streamon); */ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) { - if (q->fileio) { - dprintk(1, "streamoff: file io in progress\n"); - return -EBUSY; - } - if (type != q->type) { dprintk(1, "streamoff: invalid stream type\n"); return -EINVAL; @@ -1719,6 +1715,11 @@ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) return -EINVAL; } + if (q->fileio) { + __vb2_cleanup_fileio(q); + return 0; + } + /* * Cancel will pause streaming and remove all buffers from the driver * and videobuf, effectively returning control over them to userspace.