From patchwork Fri Jun 8 19:12:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 10455053 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 93ACA60159 for ; Fri, 8 Jun 2018 19:12:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EB8029494 for ; Fri, 8 Jun 2018 19:12:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63969294EA; Fri, 8 Jun 2018 19:12:52 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 DDF7C29494 for ; Fri, 8 Jun 2018 19:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752775AbeFHTMo (ORCPT ); Fri, 8 Jun 2018 15:12:44 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:32862 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751719AbeFHTMn (ORCPT ); Fri, 8 Jun 2018 15:12:43 -0400 Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 76F3157; Fri, 8 Jun 2018 21:12:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1528485161; bh=PXPCi8N+Ia83mPUsN5CEsjWVlQ7rRglybdORAMUVC/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1ZBF2pfETfsA8bx6cbQ0+iSeCdMJL15nLXmPe6qBgkDhb0GC8A6maQJrHQjgmEy+ 8xCQiom7n73Gzn9Vjk0R4Lcd0f3yVm1jdEKIB1QKs29Pjfcsd7OxBfiXikA59IabwA xvUnJ1P25E3yx9B4mLvCgAmKLnG+Swzq/vjiPueU= From: Laurent Pinchart To: linux-usb@vger.kernel.org Cc: Joel Pepper , Felipe Balbi , Paul Elder Subject: [PATCH 2/2] usb: gadget: uvc: configfs: Add bFrameIndex attributes Date: Fri, 8 Jun 2018 22:12:56 +0300 Message-Id: <20180608191256.739-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <1819956.5cdldLK3cV@avalon> References: <1819956.5cdldLK3cV@avalon> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paul Elder The UVC frame descriptions are numbered using the descriptor's bFrameIndex field. The index is used in UVC requests, and is thus needed to handle requests in userspace. Make it dynamically discoverable by exposing it in a bFrameIndex configfs attribute of the frame config item. However, the bFrameIndex value is never set to begin with. Set these values when linking the stream class header in the configfs hierarchy, and store it in the config item private data. Signed-off-by: Paul Elder --- drivers/usb/gadget/function/uvc_configfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index 0ad6ea57d0b7..882d9963b244 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c @@ -1152,6 +1152,8 @@ UVC_ATTR(uvcg_frame_, cname, aname); #define noop_conversion(x) (x) +UVCG_FRAME_ATTR_RO(b_frame_index, bFrameIndex, noop_conversion, + noop_conversion, 8); UVCG_FRAME_ATTR(bm_capabilities, bmCapabilities, noop_conversion, noop_conversion, 8); UVCG_FRAME_ATTR(w_width, wWidth, le16_to_cpu, cpu_to_le16, 16); @@ -1298,6 +1300,7 @@ static ssize_t uvcg_frame_dw_frame_interval_store(struct config_item *item, UVC_ATTR(uvcg_frame_, dw_frame_interval, dwFrameInterval); static struct configfs_attribute *uvcg_frame_attrs[] = { + &uvcg_frame_attr_b_frame_index, &uvcg_frame_attr_bm_capabilities, &uvcg_frame_attr_w_width, &uvcg_frame_attr_w_height, @@ -2130,12 +2133,15 @@ static int __uvcg_fill_strm(void *priv1, void *priv2, void *priv3, int n, sizeof(*frm->dw_frame_interval); memcpy(*dest, frm->dw_frame_interval, sz); *dest += sz; - if (frm->fmt_type == UVCG_UNCOMPRESSED) + if (frm->fmt_type == UVCG_UNCOMPRESSED) { h->bLength = UVC_DT_FRAME_UNCOMPRESSED_SIZE( frm->frame.b_frame_interval_type); - else if (frm->fmt_type == UVCG_MJPEG) + frm->frame.b_frame_index = n + 1; + } else if (frm->fmt_type == UVCG_MJPEG) { h->bLength = UVC_DT_FRAME_MJPEG_SIZE( frm->frame.b_frame_interval_type); + frm->frame.b_frame_index = n + 1; + } } break; }