From patchwork Tue Oct 30 23:15:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Giaraffa X-Patchwork-Id: 10661817 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 549F613A4 for ; Tue, 30 Oct 2018 23:16:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 458342A764 for ; Tue, 30 Oct 2018 23:16:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 384382A7A6; Tue, 30 Oct 2018 23:16:09 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 620B82A764 for ; Tue, 30 Oct 2018 23:16:08 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 12FC22677D0; Wed, 31 Oct 2018 00:16:06 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9E5ED2677D1; Wed, 31 Oct 2018 00:16:03 +0100 (CET) Received: from NAM05-DM3-obe.outbound.protection.outlook.com (mail-eopbgr730066.outbound.protection.outlook.com [40.107.73.66]) by alsa0.perex.cz (Postfix) with ESMTP id 41B5726770D for ; Wed, 31 Oct 2018 00:15:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector1-silabs-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TpVZQADQOQlV9bHhtmmvcxDrkRsnWTSXmXERXZXL5MQ=; b=B0S9FCJ651s+Z+HhxroNtHPdguOXJw4rhImnDV0H5EEWRgsPY0xTcvDin8CRNZXB8tPiGBSP5I4U6XFkOaI8GGG5LznWsEg0VVeVVn1AX9lmDoqcVHdE0DF9ES/SqySFMfejrx/Rm4dzMF9ti+p1hMN7OZL0d46XfpA5+W+irdM= Received: from BN7PR11MB2755.namprd11.prod.outlook.com (52.135.245.159) by BN7PR11MB2769.namprd11.prod.outlook.com (52.135.245.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1273.24; Tue, 30 Oct 2018 23:15:51 +0000 Received: from BN7PR11MB2755.namprd11.prod.outlook.com ([fe80::d38:5ee2:edfb:d8a5]) by BN7PR11MB2755.namprd11.prod.outlook.com ([fe80::d38:5ee2:edfb:d8a5%3]) with mapi id 15.20.1294.021; Tue, 30 Oct 2018 23:15:51 +0000 From: Robert Giaraffa To: "alsa-devel@alsa-project.org" Thread-Topic: Simultaneous play/record on implicit feedback device causes 'endpoint in use' error Thread-Index: AdRwpn75bcEgqorSS/2VklTNunQLqg== Date: Tue, 30 Oct 2018 23:15:51 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Robert.Giaraffa@silabs.com; x-originating-ip: [207.207.39.84] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; BN7PR11MB2769; 6:swYhaNyV3CHh5xwN3pEPm3N3+VM8E+GBVEYJxSsD5iHesYpzgGl8sIl7A6RVwfrIKYoluLFQq5MoLvqHtiQODKE01qh7XA0OyT76cZWVYpsGAsh1y741Mi1es/U5rkmSb/cjGfDT6r0XJKghEyDEs+dPu8pU/eN27i1zgjc4amUGe5ljVgloaX4LBOgW7PwAU0La1OmpcUghD2voKUSK6bvrL6IjY+NXaArG9/HJj/W+Pdv60gv2HVCkypmBVIsQikohG5zXNCGq8RNy2azyyq3jxLhq/NQPi/RFpZsJ0l2T1DicrZ0zzsbkn79I67n0//SclCV11wrnII3HrcJK9tgZYVrr7aSmMTUErRgXItslXeYjN82OSyVN1MHz03nf0+a+GHCWl7UpiwAdyxMOpnUkjbGcpTHBQUAxI6Y+0TKVXUBl6tQcGtVlv2EOTZ5OdW0ut/4ggEb4hgP3C5pO+w==; 5:JzVu273TJqhCoxHIlDj1hxbqNekB5sWIvO3d/L+lmx4XWQe30LXNkkR1wSL+wEEo+Bfme8glxt2zwDPGSruIJglRZk3QLuBs22KWEa3t8oNUMZSe1XMKsYMHDh5JCT4Etz0tF6me3alUn5EswLBhEIIzQES20FngSEOxp4RGdDU=; 7:fSg6KKRulAuSarWS6i0bSvDoALaqRVEM6ZsC89WtS1C/0i6xFMb5uet902pUik7FdcMW3PSk388+0J5M+Mm4hwf3XoL8KGAGZcPRWsNj6t5vuS1j4P2NaODShBZiBMKvOBgSrPpLj6YrJIqaH29wSA== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: e38766ad-71cb-4389-8744-08d63ebda28f x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BN7PR11MB2769; x-ms-traffictypediagnostic: BN7PR11MB2769: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(20558992708506)(21748063052155)(28532068793085)(190501279198761)(227612066756510); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231382)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:BN7PR11MB2769; BCL:0; PCL:0; RULEID:; SRVR:BN7PR11MB2769; x-forefront-prvs: 08417837C5 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(136003)(346002)(366004)(376002)(189003)(199004)(6116002)(256004)(790700001)(97736004)(486006)(14444005)(102836004)(2501003)(53936002)(6916009)(186003)(71200400001)(66066001)(6506007)(74316002)(5250100002)(2900100001)(478600001)(14454004)(7736002)(86362001)(3846002)(7696005)(99286004)(476003)(26005)(9686003)(72206003)(8676002)(81156014)(33656002)(5630700001)(316002)(2906002)(8936002)(25786009)(81166006)(2351001)(5640700003)(106356001)(68736007)(55016002)(6436002)(105586002)(6306002)(5660300001)(54896002)(71190400001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN7PR11MB2769; H:BN7PR11MB2755.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: ymLQd4NgU8Jq/PxE8l/GMocZWJ9mSiX/VjcDHzba7r9E1Gykyq7ogbgJNDmm6SfDMTHEUqQpJsDo+HyzTay9q1a1OOb6Otlq/pjeKi0GkLv22YHfPPzsdiJ9ZWM7v68uOiA51vf7uvBSfKZUbEIe5b3Oxl+A3nhXJ6+W0MPO6kd6Xxy8wIRPHFlBVoT/wMq1hwts19BzwjuN2CBlovZ/WdL6BYVTOMK38Z/Klr1sdGSbqZYfmasSc9ossn2UeDcflGb7UhXBmw/lVWXSDvsSR8B29daYGNGQw68zXZyAE6E1EPU5N/KC1FHaAG/4goWqJbjL0+0utRTKMO4QKe5iOPJ5jKaInx9alLk+RUkGtcI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: e38766ad-71cb-4389-8744-08d63ebda28f X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Oct 2018 23:15:51.5139 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR11MB2769 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Subject: [alsa-devel] Simultaneous play/record on implicit feedback device causes 'endpoint in use' error X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP My company (Silicon Labs) makes a CP2615 USB audio class 1.0 device which uses implicit feedback. I saw these two issues when testing with aplay/arecord/alsabat/alsaloop: * During playback-only operation, the implicit feedback (IN) endpoint was not active. * During play/record operation, the implicit feedback values were not acted on, i.e. the host always sent 192 bytes per OUT packet even if previous IN packets had been 188 or 196 bytes. This behavior was observed on these systems: RaspberryPi2: Raspbian 9 (stretch), kernel v4.14.72 x86-64: Ubuntu 18.04, kernel v4.15.0-36 I was able to get implicit feedback working properly in playback mode by adding a device-specific quirk to 'pcm.c' that is similar to existing quirks for implicit-feedback devices, e.g. M-Audio Fast Track Ultra. (Note: The following patch applies to kernel v4.14.72. In v4.18, the set_sync_ep_implicit_fb_quirk function was changed so that there is a single call to usb_ifnum_to_if(), rather than a call for each device-dependent quirk.) $ git diff pcm.c After adding the patch, I verified that implicit feedback worked properly for playback, i.e. the OUT samples per packet tracked previous IN values. However, when attempting to perform simultaneous play and record via alsabat, alsaloop, or separate aplay/arecord, the system reports the 'endpoint already in use' error when attempting to set the format for the IN endpoint that is already in use (note that this dmesg log has customized printk messages): [Oct23 10:13] snd_usb_hw_params->set_format() [ +0.000014] set_format(): dev:b3856c00 alts:b67e8824 ifnum: 3 [ +0.001654] set_format()->usb_set_interface 3:1 [ +0.000006] Creating new playback data endpoint 03 [ +0.000004] Creating new capture data endpoint 83 [ +0.000027] snd_usb_pcm_prepare->set_format() [ +0.000005] set_format(): dev:b3856c00 alts:b67e8824 ifnum: 3 [ +0.000755] Setting params for EP 03 (type 0, 12 urbs), ret=0 [ +0.000017] Setting params for EP 83 (type 0, 12 urbs), ret=0 [ +0.000004] Starting DATA_EP 03 @b9224000 [ +0.000004] snd_usb_endpoint_implicit_feedback_sink (03) is TRUE [ +0.001495] Starting SYNC_EP 83 @b9222000 [ +0.493035] snd_usb_hw_params->set_format() [ +0.000016] set_format(): dev:b3856c00 alts:b67e88a4 ifnum: 4 [ +0.001549] set_format()->usb_set_interface 4:1 [ +0.000005] Re-using EP 83 in iface 4:1 [ +0.000028] snd_usb_pcm_prepare->set_format() [ +0.000004] set_format(): dev:b3856c00 alts:b67e88a4 ifnum: 4 *** [ +0.003196] *** snd_usb_endpoint_set_params(): EP #83: already in use [ +0.000003] configure_endpoint->endpoint_set_params: err=FFFFFFF0 I bought a used Fast Track Ultra device for comparison testing, and found that it behaved the same way as the CP2615 does with the implicit feedback quirk: in playback-only mode implicit feedback works properly, but play/record causes the 'EP already in use' error. Are there any suggestions on how I can resolve this issue? Any help would be greatly appreciated! Thanks, Bob Giaraffa diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index b9c9a19f..6fb5567b 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -358,6 +358,21 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs, alts = &iface->altsetting[1]; goto add_sync_ep; + case USB_ID(0x10C4, 0xEAC1): // Silicon Labs CP2615 + // Ensure CP2615 is configured in Async Mode + if (attr != USB_ENDPOINT_SYNC_ASYNC) + return 0; + + // In P16R16 async mode, AudioIN EP (IF:4 EP:0x83) used for implicit feedback + ep = 0x83; + iface = usb_ifnum_to_if(dev, 4); + + if (!iface || iface->num_altsetting == 0) + return -EINVAL; + + alts = &iface->altsetting[1]; + goto add_sync_ep; + } if (attr == USB_ENDPOINT_SYNC_ASYNC && altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&