From patchwork Fri Nov 9 17:05:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10676349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 319F814BD for ; Fri, 9 Nov 2018 17:05:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D2AC2F018 for ; Fri, 9 Nov 2018 17:05:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 113702E4D1; Fri, 9 Nov 2018 17:05:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 8E9FB2A804 for ; Fri, 9 Nov 2018 17:05:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728547AbeKJCrN (ORCPT ); Fri, 9 Nov 2018 21:47:13 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:38886 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728198AbeKJCrM (ORCPT ); Fri, 9 Nov 2018 21:47:12 -0500 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A91D819E0; Fri, 9 Nov 2018 18:05:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1541783143; bh=N+CFOYOF3BLEVZsof5L9a2pVTALOadUwQ7AvsiBy2GE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=NRwyHA4bXos+LsGqVDnfUWGdDndg5QWJFATZgDZO0W6JE7xxWsWjC/pLnqCf+Rm6U vsP++SLeSbPOv+XKhRj0GDO3yCkXZyByz9YBfLjXBQHMXsrePgCPgfmRvyZmQaMQUN flBWSpbHbD5OYlYrRmyYPEUvaBsVrYiip6oNedfU= From: Kieran Bingham To: Laurent Pinchart , linux-media@vger.kernel.org Cc: Guennadi Liakhovetski , Olivier BRAUN , Troy Kisky , Randy Dunlap , Philipp Zabel , Ezequiel Garcia , Kieran Bingham , Tomasz Figa , Keiichi Watanabe Subject: [PATCH v6 08/10] media: uvcvideo: Split uvc_video_enable into two Date: Fri, 9 Nov 2018 17:05:31 +0000 Message-Id: <19c64dd691a1da00056545ea5bf19378f3d7ecfb.1541782862.git-series.kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 uvc_video_enable() is used both to start and stop the video stream object, however the single function entry point shares no code between the two operations. Split the function into two distinct calls, and rename to uvc_video_start_streaming() and uvc_video_stop_streaming() as appropriate. Signed-off-by: Kieran Bingham --- drivers/media/usb/uvc/uvc_queue.c | 4 +- drivers/media/usb/uvc/uvc_video.c | 56 +++++++++++++++----------------- drivers/media/usb/uvc/uvcvideo.h | 3 +- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index 2752e386f1e8..d09b0c882938 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c @@ -176,7 +176,7 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) queue->buf_used = 0; - ret = uvc_video_enable(stream, 1); + ret = uvc_video_start_streaming(stream); if (ret == 0) return 0; @@ -194,7 +194,7 @@ static void uvc_stop_streaming(struct vb2_queue *vq) lockdep_assert_irqs_enabled(); if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) - uvc_video_enable(uvc_queue_to_stream(queue), 0); + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); spin_lock_irq(&queue->irqlock); uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index e19bdf089cc4..cd67506dc696 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -2076,38 +2076,10 @@ int uvc_video_init(struct uvc_streaming *stream) return 0; } -/* - * Enable or disable the video stream. - */ -int uvc_video_enable(struct uvc_streaming *stream, int enable) +int uvc_video_start_streaming(struct uvc_streaming *stream) { int ret; - if (!enable) { - uvc_uninit_video(stream, 1); - if (stream->intf->num_altsetting > 1) { - usb_set_interface(stream->dev->udev, - stream->intfnum, 0); - } else { - /* UVC doesn't specify how to inform a bulk-based device - * when the video stream is stopped. Windows sends a - * CLEAR_FEATURE(HALT) request to the video streaming - * bulk endpoint, mimic the same behaviour. - */ - unsigned int epnum = stream->header.bEndpointAddress - & USB_ENDPOINT_NUMBER_MASK; - unsigned int dir = stream->header.bEndpointAddress - & USB_ENDPOINT_DIR_MASK; - unsigned int pipe; - - pipe = usb_sndbulkpipe(stream->dev->udev, epnum) | dir; - usb_clear_halt(stream->dev->udev, pipe); - } - - uvc_video_clock_cleanup(stream); - return 0; - } - ret = uvc_video_clock_init(stream); if (ret < 0) return ret; @@ -2130,3 +2102,29 @@ int uvc_video_enable(struct uvc_streaming *stream, int enable) return ret; } + +int uvc_video_stop_streaming(struct uvc_streaming *stream) +{ + uvc_uninit_video(stream, 1); + if (stream->intf->num_altsetting > 1) { + usb_set_interface(stream->dev->udev, + stream->intfnum, 0); + } else { + /* UVC doesn't specify how to inform a bulk-based device + * when the video stream is stopped. Windows sends a + * CLEAR_FEATURE(HALT) request to the video streaming + * bulk endpoint, mimic the same behaviour. + */ + unsigned int epnum = stream->header.bEndpointAddress + & USB_ENDPOINT_NUMBER_MASK; + unsigned int dir = stream->header.bEndpointAddress + & USB_ENDPOINT_DIR_MASK; + unsigned int pipe; + + pipe = usb_sndbulkpipe(stream->dev->udev, epnum) | dir; + usb_clear_halt(stream->dev->udev, pipe); + } + + uvc_video_clock_cleanup(stream); + return 0; +} diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 94accfa3c009..b1b895c67122 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -786,7 +786,8 @@ void uvc_mc_cleanup_entity(struct uvc_entity *entity); int uvc_video_init(struct uvc_streaming *stream); int uvc_video_suspend(struct uvc_streaming *stream); int uvc_video_resume(struct uvc_streaming *stream, int reset); -int uvc_video_enable(struct uvc_streaming *stream, int enable); +int uvc_video_start_streaming(struct uvc_streaming *stream); +int uvc_video_stop_streaming(struct uvc_streaming *stream); int uvc_probe_video(struct uvc_streaming *stream, struct uvc_streaming_control *probe); int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,