Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2283015imu; Sun, 16 Dec 2018 22:05:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/UBCAAgCp8KBG9/blgc8Szg9J1lL9/ik/wCa8hBOrzJVEX2RZ+5+h5uZ4mEhagvBylry6V3 X-Received: by 2002:a62:5486:: with SMTP id i128mr11430554pfb.215.1545026739486; Sun, 16 Dec 2018 22:05:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545026739; cv=none; d=google.com; s=arc-20160816; b=mQwatcq98+FLDa+UBjcOeOq1BWoFnX05uE6APIcRsF/BNoraHQ51LGLx3PP8Cjg9E1 T51hSs9tTZV+iqOTZ7KdR/FNRcnKmpMfH+AcEOaSJ/5UXI+gYXgsOk/MbZE/lopOZDrv rkU0M4xHK3tDwaCu4FBPJn1s8luS1cb41dEmDgBiNLsbISbBIz6o0dRKv7sTkPmp0k25 MHWpONs4ffVBkv3a7lVe2Gzjuf528xr4TSbclSNNmcqT58R3KriEfk0gKp7Dz9vlF1Zf PzcYfxqBbayNrkS4mbl0J2NpEEaGmksVKHbsfpbFh8qzVxXcxDQPzwOKzTvXYziELBL7 qifw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gcX/7atJLq7xMaKDTOWQOLjm/qm2P4MIm92+P8D8Apc=; b=vnGIG0DAmoXGi2O5GfXAU3efzuj7aCKR9ErDVnrgppU/DQBMfsg92AwOhQ3uJaLh8h kTjQGma0KAnNQZsinfLdgl8UguqGOv8IZ/cHDFdDUjzCmv5SZwTVAAqRkrlBB8Y8tTjA E29qn6H8WITwmj1CUxyC0ID0gdUg+7LfVrOK59/7u51sDUDuoME9cEdNiXzNA5iEBbYF QmQpU0z35cK8xppdzM5IFdu6cAr5OR+aTu588N+vhi2A4BUeV5kYiKS/lNgTWqrNOylA LSNvfTGCnVUSakzwM4Tt3git+2JGuS6iVH41j/Od5aRua7VYBclT95G0CFxDpSlrKcBq s3og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=cbVAYCHG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si9912188pgr.67.2018.12.16.22.05.24; Sun, 16 Dec 2018 22:05:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=cbVAYCHG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731564AbeLQGDE (ORCPT + 99 others); Mon, 17 Dec 2018 01:03:04 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:53890 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731529AbeLQGC7 (ORCPT ); Mon, 17 Dec 2018 01:02:59 -0500 Received: from localhost.localdomain (unknown [96.44.9.229]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 538BCE5C; Mon, 17 Dec 2018 07:02:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1545026577; bh=IFKKX+mirCGTL05HfK0wK6Mbk0XG4VRYk0eeVau3ypM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cbVAYCHG1tkApVfObg+dV9Pnf9ngJgbQmTILsoFNg8bzdhteDKp0coQ5w5I6AOCXO sLPcuGGBuS6pnPg4VctdFoOvqgz86mRC2NCW5rR+NOx5p40DfBGDWwvqY0grAUGLXa xCPlwRUNVLQSh/EgskRwkCYofFBdDEA+ma9uPBvo= From: Paul Elder To: laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Cc: Paul Elder , b-liu@ti.com, stern@rowland.harvard.edu, rogerq@ti.com, balbi@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] usb: gadget: uvc: allow ioctl to send response in status stage Date: Mon, 17 Dec 2018 01:02:16 -0500 Message-Id: <20181217060216.26368-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181217060216.26368-1-paul.elder@ideasonboard.com> References: <20181217060216.26368-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We now have a mechanism to signal the UDC driver to reply to a control OUT request with STALL or ACK, and we have packaged the setup stage data and the data stage data of a control OUT request into a single UVC_EVENT_DATA for userspace to consume. The ioctl UVCIOC_SEND_RESPONSE in the case of a control OUT request sends a response to the data stage, and so the ioctl now notifies the UDC driver to reply with STALL or ACK. In the case of a control IN request, the ioctl sends the UVC data as before. Also tell the UDC to delay the status stage for this to work. Signed-off-by: Paul Elder --- Changes from v1: - remove usb_ep_delay_status call from the old proposed API - changed portions of uvc_send_response to match v2 API - remove UDC warning that send_response is not implemented drivers/usb/gadget/function/f_uvc.c | 4 ++-- drivers/usb/gadget/function/uvc_v4l2.c | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index d08957124e42..91388bb647e0 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -209,14 +209,13 @@ uvc_function_ep0_complete(struct usb_ep *ep, struct usb_request *req) struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; if (uvc->event_setup_out) { - uvc->event_setup_out = 0; - memset(&v4l2_event, 0, sizeof(v4l2_event)); v4l2_event.type = UVC_EVENT_DATA; uvc_event->data.length = req->actual; memcpy(&uvc_event->data.data, req->buf, req->actual); memcpy(&uvc_event->data.setup, &uvc->control_setup, sizeof(uvc_event->data.setup)); + v4l2_event_queue(&uvc->vdev, &v4l2_event); } } @@ -251,6 +250,7 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) */ req->length = uvc->event_length; req->zero = 0; + req->explicit_status = 1; usb_ep_queue(f->config->cdev->gadget->ep0, req, GFP_KERNEL); } else { struct v4l2_event v4l2_event; diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c index 35353ffdf3b4..f09aa92a1b01 100644 --- a/drivers/usb/gadget/function/uvc_v4l2.c +++ b/drivers/usb/gadget/function/uvc_v4l2.c @@ -37,10 +37,23 @@ uvc_send_response(struct uvc_device *uvc, struct uvc_request_data *data) /* * For control OUT transfers the request has been enqueued synchronously - * by the setup handler, there's nothing to be done here. + * by the setup handler, we just need to tell the UDC whether to ACK or + * STALL the control transfer. */ - if (uvc->event_setup_out) - return 0; + if (uvc->event_setup_out) { + /* + * The length field carries the control request status. + * Negative values signal a STALL and zero values an ACK. + * Positive values are not valid as there is no data to send + * back in the status stage. + */ + if (data->length > 0) + return -EINVAL; + + req->zero = !data->length; + req->explicit_status = 1; + return usb_ep_queue(cdev->gadget->ep0, req, GFP_KERNEL); + } if (data->length < 0) return usb_ep_set_halt(cdev->gadget->ep0); -- 2.19.2