Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5925248imu; Sun, 20 Jan 2019 23:34:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN5DPGqLFLg8ujKiM5DNA6tb0nS1RrKffgVfZ7xMj4eLAKcOVkRyPUJhDH8n0bknWBOaNQGn X-Received: by 2002:a63:8ac4:: with SMTP id y187mr27384855pgd.446.1548056050561; Sun, 20 Jan 2019 23:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548056050; cv=none; d=google.com; s=arc-20160816; b=AOxRdrV30d97jsgafpyz1O/yA0vYWWlbe5CdvvlP2aECT/Y+Tmn2yLY/bCpcfm7/u7 9eBhghASE0vB4DDNCywXYqGJkR5oeOkD5Y3qMx1f3aT66bRl/If968jVZP27O53B2voh RSB+SE9dA88gTrVw8nc6y0cnVn/KR7HaI3lxPzl4B98GjzCgqPSOeZu+wUimbVU/xYPK gHGM/dSme6e0A8McDiUD6dR0wgz+xuvXb+PsY2KqhZoQQHna+YlDn0cpMY0ixjJsz8Rz X5ZPSofV8mMQ7wRa8KWwGZI2gl3p9/0XUN2x/QIvQns5xcM7PoTSufnU/pGvi9omhwbu UJkw== 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=9tjTwDE1MX5xrNOlUG3blUaXfk6mx8SgSfOUX8Up81I=; b=LPQKKIczad/8mpiKgQ3XkkSFmE+AagXUKTi5ckRrIBJUCQRLTLkJTx+LLH6G4tUhDo AJz5WX/rGZJfaD8QiZHr9baFZHd4xFgZvLPgEW3U7LLq8Zrl/I5MkB4/pXm0Z12L6Mh9 KEjgZQozAd4v0u1ugwkmDqVkMgtXSc3w3cGjJ873mClRvtulT+Q3oyn5h0vzP9zB8uov ANzfELX8p9ujBVL333C8iqPlE4z5bdSYc+Oas2kelrrccHlKtg60Njap9qMSLWu4IvZm lfPvR+a+kuTo/llHVqJeapddHHx9IDN3SounCiovt8Rs2h6WH5sQzpw4fDGx6W2eLCL4 4Diw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=NnHYHzOQ; 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 h20si12101456pgm.366.2019.01.20.23.33.55; Sun, 20 Jan 2019 23:34:10 -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=NnHYHzOQ; 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 S1728530AbfAUHbe (ORCPT + 99 others); Mon, 21 Jan 2019 02:31:34 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:45902 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728486AbfAUHbc (ORCPT ); Mon, 21 Jan 2019 02:31:32 -0500 Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 92004E81; Sun, 20 Jan 2019 20:41:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1548013320; bh=YnbaPsFlCSsBt3uBy9C5XLZC4Iv1Yah6zatFOWt4DKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NnHYHzOQ2jPfSiL9pkmacENgXHYT3VMeqeh77ir/HarZa7o+gtwNF2iOA8mpwM7vK g6/Gfyn8z65ZlO3hcb9f3vA8HRXy9j66OevkHNoryn/cGyw5QQIR95DvbsWeZOT08c AIp/lMfW3m7lP897o9RsLV6Hbojh0UoHmI8FQdSk= 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 v6 3/6] usb: gadget: uvc: package setup and data for control OUT requests Date: Sun, 20 Jan 2019 14:41:33 -0500 Message-Id: <20190120194136.21870-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190120194136.21870-1-paul.elder@ideasonboard.com> References: <20190120194136.21870-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 Since "usb: gadget: uvc: enqueue uvc_request_data in setup handler for control OUT requests" it is no longer necessary for userspace to call ioctl UVCIOC_SEND_RESPONSE in response to receiving a UVC_EVENT_SETUP from the uvc function driver for a control OUT request. This change means that for control OUT userspace will receive a UVC_EVENT_SETUP and not do anything with it. This is a waste of a pair of context switches, so we put the setup and data stage data into a single UVC_EVENT_DATA to give to userspace. Previously struct uvc_request_data had 60 bytes allocated for data, and since uvc data at most is 34 bytes in UVC 1.1 and 48 bytes in UVC 1.5, we can afford to cut out 8 bytes to store the setup control. Since the setup control is discarded after the handling of the setup stage, it must be saved in struct uvc_device during the setup handler in order for the data stage handler to be able to read it and send it to userspace. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- No change from v5 No change from v4 No change from v3 No change from v2 No change from v1 drivers/usb/gadget/function/f_uvc.c | 3 +++ drivers/usb/gadget/function/uvc.h | 1 + include/uapi/linux/usb/g_uvc.h | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index f571623cc6e4..6303ed346af9 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -215,6 +215,8 @@ uvc_function_ep0_complete(struct usb_ep *ep, struct usb_request *req) 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); } } @@ -238,6 +240,7 @@ uvc_function_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl) */ uvc->event_setup_out = !(ctrl->bRequestType & USB_DIR_IN); uvc->event_length = le16_to_cpu(ctrl->wLength); + memcpy(&uvc->control_setup, ctrl, sizeof(uvc->control_setup)); if (uvc->event_setup_out) { struct usb_request *req = uvc->control_req; diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h index 671020c8a836..1d89b1df4ba0 100644 --- a/drivers/usb/gadget/function/uvc.h +++ b/drivers/usb/gadget/function/uvc.h @@ -163,6 +163,7 @@ struct uvc_device { unsigned int control_intf; struct usb_ep *control_ep; struct usb_request *control_req; + struct usb_ctrlrequest control_setup; void *control_buf; unsigned int streaming_intf; diff --git a/include/uapi/linux/usb/g_uvc.h b/include/uapi/linux/usb/g_uvc.h index 6698c3263ae8..10fbb4382925 100644 --- a/include/uapi/linux/usb/g_uvc.h +++ b/include/uapi/linux/usb/g_uvc.h @@ -24,7 +24,8 @@ struct uvc_request_data { __s32 length; - __u8 data[60]; + struct usb_ctrlrequest setup; + __u8 data[52]; }; struct uvc_event { -- 2.20.1