From patchwork Wed May 17 08:15:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sekhar Nori X-Patchwork-Id: 99907 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp99458obb; Wed, 17 May 2017 01:15:41 -0700 (PDT) X-Received: by 10.99.126.20 with SMTP id z20mr2355153pgc.158.1495008941520; Wed, 17 May 2017 01:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495008941; cv=none; d=google.com; s=arc-20160816; b=IIErTWKMSZupp7sWKAsl8wDTGLCMVMxjD/ZWF3QzovUoPwqHUjLFbb/TiOfBd87+TC ms0zK/1D9dlC+dObSHLGqkqeUpMHtSClbL0IgeyQ7V/hDFEBOHcY9s4D0Jcel8ARRN2m fxobFLjsUx7VizL5Pgaubw7XUhY9DxBVeGct/gFMzx8skLL4bfXsE9xCkeA1x6KsWmbj LDZS7MRAoXr8dJ2vcWoCh9JBDaw45F1Q9bE0DGN/70k/QJUgWj96qlaWGbya6IPj3CQb y1E9vWmPFglf3DZoFjn6v5r9Ei8JbDo6VICoW6PRgRNLsHNRMYeoWLNkQ7+XTL7bat22 E04Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=7ArQjMRRIqjVLzoWIb82hDD4pSG9fkIoRFKW77irBA0=; b=KktRllGJFd7/h6YHRaRXQQtErBmWXgIPJqGyGBgSRxmU4GyA9ZjfpxjVX4uBc4j34k WBzv6hDc4zTNdk+LOj8qCiqviEFmkJUhBXf321nAz7LUV94rSDJoyp0+1eC6pYh9WtG1 Xz3Zyonv3WCigEr5ArbmJkZkTuemTiWkbbOtnyZnnrZuhhJ78e0EJP+0ogIq8gHCcbhu wBXP2keUqKr4Jvea4rM1hUntlaHGlDhnfEIydx0G1Rq5pQcPAp7kZ+Xpvgt+9rx+mXFt p16aXlhIgoC9MUCuAQO9D3rfH98TSXOs+mwVoRCChSkIq8CPHUIEXqyQTqUqrfUV/dqP 47UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p124si1418028pfp.15.2017.05.17.01.15.41; Wed, 17 May 2017 01:15:41 -0700 (PDT) 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 header.i=@ti.com; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753916AbdEQIP1 (ORCPT + 25 others); Wed, 17 May 2017 04:15:27 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:20571 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752300AbdEQIPX (ORCPT ); Wed, 17 May 2017 04:15:23 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v4H8FLpi009959; Wed, 17 May 2017 03:15:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1495008921; bh=uzqM449ykEkaPDoRDO+NCMEOJPwNmTP4XlqLXbyRHAA=; h=From:To:CC:Subject:Date; b=NcsbJW6zAzcOXInOBCQUZnhj5AIbYJ4cy37W1IVmJUW1/zpDaEG9fgpgFcE5VO/2Q pJ30TadZ1FaYlx0jNiJEUoiWNUY5YgjwawwJrYz0vVrziDB3RuHGmoqQuyOzucxneW yaBTqZJd/VLdomjjByQbqiJXfqCLeigQ823z5xzM= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4H8FLUO013812; Wed, 17 May 2017 03:15:21 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Wed, 17 May 2017 03:15:21 -0500 Received: from psplinux063.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4H8FIe6031582; Wed, 17 May 2017 03:15:18 -0500 From: Sekhar Nori To: Felipe Balbi , Greg Kroah-Hartman CC: Bin Liu , Roger Quadros , , , Sekhar Nori Subject: [PATCH] usb: gadget: f_uac2: calculate wMaxPacketSize before endpoint match Date: Wed, 17 May 2017 13:45:17 +0530 Message-ID: <09d1259f224a2427a326d3589765dc149e577c75.1495008408.git.nsekhar@ti.com> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Calculate wMaxPacketSize before endpoint matching the descriptor is found. This allows audio gadget to be used with controllers which have a shortage or unavailability of endpoints that can handle max packet size of 1023 (FS) or 1024 (HS). With this audio gadget can be used on TI's OMAP-L138 SoC which has a MUSB HS controller with endpoints having max packet size much less than 1023 or 1024. See mode_2_cfg in drivers/usb/musb/musb_core.c Signed-off-by: Sekhar Nori --- drivers/usb/gadget/function/f_uac2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.9.0 Acked-by: Roger Quadros diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index f6a0d3a1311b..5a7ba058d947 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -1065,6 +1065,12 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) agdev->as_in_intf = ret; agdev->as_in_alt = 0; + /* Calculate wMaxPacketSize according to audio bandwidth */ + set_ep_max_packet_size(uac2_opts, &fs_epin_desc, 1000, true); + set_ep_max_packet_size(uac2_opts, &fs_epout_desc, 1000, false); + set_ep_max_packet_size(uac2_opts, &hs_epin_desc, 8000, true); + set_ep_max_packet_size(uac2_opts, &hs_epout_desc, 8000, false); + agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc); if (!agdev->out_ep) { dev_err(dev, "%s:%d Error!\n", __func__, __LINE__); @@ -1080,12 +1086,6 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) uac2->p_prm.uac2 = uac2; uac2->c_prm.uac2 = uac2; - /* Calculate wMaxPacketSize according to audio bandwidth */ - set_ep_max_packet_size(uac2_opts, &fs_epin_desc, 1000, true); - set_ep_max_packet_size(uac2_opts, &fs_epout_desc, 1000, false); - set_ep_max_packet_size(uac2_opts, &hs_epin_desc, 8000, true); - set_ep_max_packet_size(uac2_opts, &hs_epout_desc, 8000, false); - hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;