From patchwork Sun Mar 21 03:28:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12152867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (unknown [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4658C433DB for ; Sun, 21 Mar 2021 03:31:15 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0DD066195F for ; Sun, 21 Mar 2021 03:31:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DD066195F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9B6EC166C; Sun, 21 Mar 2021 04:30:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9B6EC166C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616297464; bh=WElzBxNbI/8LU4TkUxks8/wD1EVg0/93SLYCX+she1o=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ZQBhKbjWVYBtq9G6FErlwezZ1H2Jue8hXy2LleFsynZjY9OO2/4by5fMx1gOK5Ucs O56VGYDPECfk4DMHoA3xVlle8l85LY2vYrMo9DGzplBO7D4v2p2nqhOMwsmi18FB6X EuGuzY0rNT/FWJ4ZecQGeu/C7r38wZUix6dF5WC4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EB3D6F8026D; Sun, 21 Mar 2021 04:29:24 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9E2FCF80254; Sun, 21 Mar 2021 04:29:03 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4899BF8012F for ; Sun, 21 Mar 2021 04:28:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4899BF8012F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="UdqIIrqr"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="C0gQL57B" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id EA1691844; Sat, 20 Mar 2021 23:28:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 20 Mar 2021 23:28:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=opk5iVXDnSiFd tePBipGpfN085CAYMu8qBwrorUIKsE=; b=UdqIIrqrrga4LQAXGgbR+ZVukrbO8 wZ1uB1U87HJtBZxvl7Ovqt54Oi2Gy4euvQxPFUG0YO1Fq7Ff4W5jrqIS8cn4UDZM oRkRw2m63s5chKa5Npexz/y5+e2tWMoYZ8LLWn6L+450yoHXtJOxuQA66DM+kYuI crTdUnjB+Ini+ypFyFxWnlxDKhkO3jWzWYFqU3sMAoDOoUcvpUWnGFRYbktd8Bp7 quBq+OqqWHUzZH48b0a9cfJJyjq04NMXKgREXfYhvZiz+4T9IwasZ2F4hXP9273W u2f/lVY1gbZS86NH0zzRimCp/NZQv2sG54CS2UTHApDOXrRX0+Wy9yfHA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=opk5iVXDnSiFdtePBipGpfN085CAYMu8qBwrorUIKsE=; b=C0gQL57B cJ7dPVQkel43K7mC1Kt5DIHvitTGd5jFu44PywkGlHT9daQAwRuBUhxzCyuR/1iq 4lLnU2ner6UEfFNV6GtvfRPHz9dWIs/HPD9nwGvYk86cYQAET+YZfE+4fnuqqjtL 02BcP0OIFeOqGIxapHEAsfF9sr7Bu0DAHKy4W//N1lXb600oTFUD1cZST3C2a3pq 7ukvFHnr9fxOegLuAwhmOakAS2LNcu84tMQ1URmC8BTeHy+TrrylpKfRv6QsCUPX joGnxCHgZSAvlyG/T3GrEPVOWAkyVebWyKhcF/DcYQ+RMYcwje+tP70xqFUzekri 5cqnXJ3aEOI1cA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeguddgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 995F42403E0; Sat, 20 Mar 2021 23:28:35 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 1/3] ALSA: bebob: code refactoring for stream format detection Date: Sun, 21 Mar 2021 12:28:29 +0900 Message-Id: <20210321032831.340278-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210321032831.340278-1-o-takashi@sakamocchi.jp> References: <20210321032831.340278-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" ALSA bebob driver scans supported formats of packet for each direction when probing the target device. Some helper functions are used for the scanning, however its implementation is not necessarily irredundant. This commit refactors the helper functions to remove redundant codes. Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob_stream.c | 68 ++++++++++------------------- 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index bbae04793c50..d96d2feb15a8 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -796,42 +796,42 @@ parse_stream_formation(u8 *buf, unsigned int len, return 0; } -static int -fill_stream_formations(struct snd_bebob *bebob, enum avc_bridgeco_plug_dir dir, - unsigned short pid) +static int fill_stream_formations(struct snd_bebob *bebob, u8 addr[AVC_BRIDGECO_ADDR_BYTES], + enum avc_bridgeco_plug_dir plug_dir, unsigned int plug_id, + struct snd_bebob_stream_formation *formations) { + enum avc_bridgeco_plug_type plug_type; u8 *buf; - struct snd_bebob_stream_formation *formations; unsigned int len, eid; - u8 addr[AVC_BRIDGECO_ADDR_BYTES]; int err; + avc_bridgeco_fill_unit_addr(addr, plug_dir, AVC_BRIDGECO_PLUG_UNIT_ISOC, plug_id); + + err = avc_bridgeco_get_plug_type(bebob->unit, addr, &plug_type); + if (err < 0) { + dev_err(&bebob->unit->device, + "Fail to get type for isoc %d plug 0: %d\n", plug_dir, err); + return err; + } else if (plug_type != AVC_BRIDGECO_PLUG_TYPE_ISOC) + return -ENXIO; + buf = kmalloc(FORMAT_MAXIMUM_LENGTH, GFP_KERNEL); if (buf == NULL) return -ENOMEM; - if (dir == AVC_BRIDGECO_PLUG_DIR_IN) - formations = bebob->rx_stream_formations; - else - formations = bebob->tx_stream_formations; + for (eid = 0; eid < SND_BEBOB_STRM_FMT_ENTRIES; ++eid) { + avc_bridgeco_fill_unit_addr(addr, plug_dir, AVC_BRIDGECO_PLUG_UNIT_ISOC, plug_id); - for (eid = 0; eid < SND_BEBOB_STRM_FMT_ENTRIES; eid++) { len = FORMAT_MAXIMUM_LENGTH; - avc_bridgeco_fill_unit_addr(addr, dir, - AVC_BRIDGECO_PLUG_UNIT_ISOC, pid); - err = avc_bridgeco_get_plug_strm_fmt(bebob->unit, addr, buf, - &len, eid); - /* No entries remained. */ + err = avc_bridgeco_get_plug_strm_fmt(bebob->unit, addr, buf, &len, eid); + // No entries remained. if (err == -EINVAL && eid > 0) { err = 0; break; } else if (err < 0) { dev_err(&bebob->unit->device, - "fail to get stream format %d for isoc %s plug %d:%d\n", - eid, - (dir == AVC_BRIDGECO_PLUG_DIR_IN) ? "in" : - "out", - pid, err); + "fail to get stream format %d for isoc %d plug %d:%d\n", + eid, plug_dir, plug_id, err); break; } @@ -908,33 +908,13 @@ int snd_bebob_stream_discover(struct snd_bebob *bebob) goto end; } - avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_IN, - AVC_BRIDGECO_PLUG_UNIT_ISOC, 0); - err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); - if (err < 0) { - dev_err(&bebob->unit->device, - "fail to get type for isoc in plug 0: %d\n", err); - goto end; - } else if (type != AVC_BRIDGECO_PLUG_TYPE_ISOC) { - err = -ENOSYS; - goto end; - } - err = fill_stream_formations(bebob, AVC_BRIDGECO_PLUG_DIR_IN, 0); + err = fill_stream_formations(bebob, addr, AVC_BRIDGECO_PLUG_DIR_IN, 0, + bebob->rx_stream_formations); if (err < 0) goto end; - avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_OUT, - AVC_BRIDGECO_PLUG_UNIT_ISOC, 0); - err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); - if (err < 0) { - dev_err(&bebob->unit->device, - "fail to get type for isoc out plug 0: %d\n", err); - goto end; - } else if (type != AVC_BRIDGECO_PLUG_TYPE_ISOC) { - err = -ENOSYS; - goto end; - } - err = fill_stream_formations(bebob, AVC_BRIDGECO_PLUG_DIR_OUT, 0); + err = fill_stream_formations(bebob, addr, AVC_BRIDGECO_PLUG_DIR_OUT, 0, + bebob->tx_stream_formations); if (err < 0) goto end; From patchwork Sun Mar 21 03:28:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12152865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (unknown [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2ABEC433C1 for ; Sun, 21 Mar 2021 03:30:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C6E56195F for ; Sun, 21 Mar 2021 03:30:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C6E56195F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E722A1614; Sun, 21 Mar 2021 04:29:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E722A1614 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616297414; bh=und5HXyX3vi4NCAtWJ4cmJvGkjk1HSl2lT0txczmS2Y=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=co/Lcof8HNH5PnfZYu2/SG50bmVJJ532ySXpXXgM/1gZzksOm6bEuKVWlVJwWqYW1 RuH/e7Y2SgAq9fZO5ochbRB0V1No5dtThfKG6jRZeuP6ApAvG+rTiIsdLX9aNuKfeZ wft7YVhoEnW7sYXmaEs3BC24W/o0fuJQ+TdOTLzk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3FAAEF80240; Sun, 21 Mar 2021 04:29:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C97A5F8028D; Sun, 21 Mar 2021 04:29:03 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 481F7F80254 for ; Sun, 21 Mar 2021 04:28:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 481F7F80254 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="ca5rDmvu"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="W6eCJjTg" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 280941838; Sat, 20 Mar 2021 23:28:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 20 Mar 2021 23:28:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=JLS48iijp/ilD vv0NrqwrL7p2U/48keqMNug2tHfJoU=; b=ca5rDmvuRmxXlmM6GL5IXVUr0QZf6 MjWkNCuvljODIvSQth63ycEJkKOHffd5h/d/L6h8nv5DD69jINyrVdpkGdoy+S8/ AU+EzI5p9YkMvElKr062K6g/UDQ0jLkMSvkiW72fYimUXdYelXtMWZpb370d6J+f 2xoJcqD8YFfTwQsnClUVNAzM+r5iVpuNtzqEO6ED8KAFxOdTgaO/K/VeOuOBeIkt ea5XnsAamCjH1/kcEZxhifqnvMEgYEKQZVwZI0badzcBkg00V8PEsBFNfNFnV1uO v8cBV7OJku11l9mCsqt2b9L0FFyT9Ygk99y72fzTcuNm/6VPnZzFocVCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=JLS48iijp/ilDvv0NrqwrL7p2U/48keqMNug2tHfJoU=; b=W6eCJjTg VGxzdTsRAoVrq7OYArF2fcDlMFWdxVGRCIfbpDIRLxu/M0enSBS3UfWGcsR68Hm+ tcDdoaMal6urYzO3yA6g4uoiAevL6w7xw6W9sw2CD3c0dss0nRNHwb1kWijLyfrH iEUB+x/NKmNHNqRTX0CR/W0X8/CXZ9eFKvlL7Nhl+hI+ZLDp+dpx3OENA2/ijQkG tUvXeluVH6GD4u9iWqA5MRgLoxj9NSx70tKVITN3QcqVv710UVjf9MlRv0pzK92X BS6qiBguzhptVqcL1NxxyIthe+jyVPo1jR2Cbc5lEvcgWD9TJqnv8vUikXxlpYV8 JtQCIcv9HTtcxg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeguddgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id C735724040B; Sat, 20 Mar 2021 23:28:36 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 2/3] ALSA: bebob: detect the number of available MIDI ports Date: Sun, 21 Mar 2021 12:28:30 +0900 Message-Id: <20210321032831.340278-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210321032831.340278-1-o-takashi@sakamocchi.jp> References: <20210321032831.340278-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" Current implementation counts the number of input/output plugs for MIDI type and uses the count as the number of physical MIDI ports. However, the number of channels of the port represents the count. This commit fixes the bug by additional vendor-specific AVC command extension. Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob.h | 2 + sound/firewire/bebob/bebob_command.c | 36 ++++++++++++ sound/firewire/bebob/bebob_stream.c | 83 +++++++++++++++++----------- 3 files changed, 89 insertions(+), 32 deletions(-) diff --git a/sound/firewire/bebob/bebob.h b/sound/firewire/bebob/bebob.h index d1ad9a8451bc..4e0ed84adbee 100644 --- a/sound/firewire/bebob/bebob.h +++ b/sound/firewire/bebob/bebob.h @@ -200,6 +200,8 @@ int avc_bridgeco_get_plug_ch_pos(struct fw_unit *unit, int avc_bridgeco_get_plug_type(struct fw_unit *unit, u8 addr[AVC_BRIDGECO_ADDR_BYTES], enum avc_bridgeco_plug_type *type); +int avc_bridgeco_get_plug_ch_count(struct fw_unit *unit, u8 addr[AVC_BRIDGECO_ADDR_BYTES], + unsigned int *ch_count); int avc_bridgeco_get_plug_section_type(struct fw_unit *unit, u8 addr[AVC_BRIDGECO_ADDR_BYTES], unsigned int id, u8 *type); diff --git a/sound/firewire/bebob/bebob_command.c b/sound/firewire/bebob/bebob_command.c index e276ab8f9006..022df09c68ff 100644 --- a/sound/firewire/bebob/bebob_command.c +++ b/sound/firewire/bebob/bebob_command.c @@ -143,6 +143,42 @@ int avc_bridgeco_get_plug_type(struct fw_unit *unit, return err; } +int avc_bridgeco_get_plug_ch_count(struct fw_unit *unit, u8 addr[AVC_BRIDGECO_ADDR_BYTES], + unsigned int *ch_count) +{ + u8 *buf; + int err; + + buf = kzalloc(12, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + + // Info type is 'plug type'. + avc_bridgeco_fill_plug_info_extension_command(buf, addr, 0x02); + + err = fcp_avc_transaction(unit, buf, 12, buf, 12, + BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | + BIT(6) | BIT(7) | BIT(9)); + if (err < 0) + ; + else if (err < 11) + err = -EIO; + else if (buf[0] == 0x08) // NOT IMPLEMENTED + err = -ENOSYS; + else if (buf[0] == 0x0a) // REJECTED + err = -EINVAL; + else if (buf[0] == 0x0b) // IN TRANSITION + err = -EAGAIN; + if (err < 0) + goto end; + + *ch_count = buf[10]; + err = 0; +end: + kfree(buf); + return err; +} + int avc_bridgeco_get_plug_ch_pos(struct fw_unit *unit, u8 addr[AVC_BRIDGECO_ADDR_BYTES], u8 *buf, unsigned int len) diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index d96d2feb15a8..23579a73e038 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -844,6 +844,49 @@ static int fill_stream_formations(struct snd_bebob *bebob, u8 addr[AVC_BRIDGECO_ return err; } +static int detect_midi_ports(struct snd_bebob *bebob, + const struct snd_bebob_stream_formation *formats, + u8 addr[AVC_BRIDGECO_ADDR_BYTES], enum avc_bridgeco_plug_dir plug_dir, + unsigned int plug_count, unsigned int *midi_ports) +{ + int i; + int err = 0; + + *midi_ports = 0; + + /// Detect the number of available MIDI ports when packet has MIDI conformant data channel. + for (i = 0; i < SND_BEBOB_STRM_FMT_ENTRIES; ++i) { + if (formats[i].midi > 0) + break; + } + if (i >= SND_BEBOB_STRM_FMT_ENTRIES) + return 0; + + for (i = 0; i < plug_count; ++i) { + enum avc_bridgeco_plug_type plug_type; + unsigned int ch_count; + + avc_bridgeco_fill_unit_addr(addr, plug_dir, AVC_BRIDGECO_PLUG_UNIT_EXT, i); + + err = avc_bridgeco_get_plug_type(bebob->unit, addr, &plug_type); + if (err < 0) { + dev_err(&bebob->unit->device, + "fail to get type for external %d plug %d: %d\n", + plug_dir, i, err); + break; + } else if (plug_type != AVC_BRIDGECO_PLUG_TYPE_MIDI) { + continue; + } + + err = avc_bridgeco_get_plug_ch_count(bebob->unit, addr, &ch_count); + if (err < 0) + break; + *midi_ports += ch_count; + } + + return err; +} + static int seek_msu_sync_input_plug(struct snd_bebob *bebob) { @@ -886,8 +929,6 @@ int snd_bebob_stream_discover(struct snd_bebob *bebob) { const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock; u8 plugs[AVC_PLUG_INFO_BUF_BYTES], addr[AVC_BRIDGECO_ADDR_BYTES]; - enum avc_bridgeco_plug_type type; - unsigned int i; int err; /* the number of plugs for isoc in/out, ext in/out */ @@ -918,37 +959,15 @@ int snd_bebob_stream_discover(struct snd_bebob *bebob) if (err < 0) goto end; - /* count external input plugs for MIDI */ - bebob->midi_input_ports = 0; - for (i = 0; i < plugs[2]; i++) { - avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_IN, - AVC_BRIDGECO_PLUG_UNIT_EXT, i); - err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); - if (err < 0) { - dev_err(&bebob->unit->device, - "fail to get type for external in plug %d: %d\n", - i, err); - goto end; - } else if (type == AVC_BRIDGECO_PLUG_TYPE_MIDI) { - bebob->midi_input_ports++; - } - } + err = detect_midi_ports(bebob, bebob->rx_stream_formations, addr, AVC_BRIDGECO_PLUG_DIR_IN, + plugs[2], &bebob->midi_input_ports); + if (err < 0) + goto end; - /* count external output plugs for MIDI */ - bebob->midi_output_ports = 0; - for (i = 0; i < plugs[3]; i++) { - avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_OUT, - AVC_BRIDGECO_PLUG_UNIT_EXT, i); - err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); - if (err < 0) { - dev_err(&bebob->unit->device, - "fail to get type for external out plug %d: %d\n", - i, err); - goto end; - } else if (type == AVC_BRIDGECO_PLUG_TYPE_MIDI) { - bebob->midi_output_ports++; - } - } + err = detect_midi_ports(bebob, bebob->tx_stream_formations, addr, AVC_BRIDGECO_PLUG_DIR_OUT, + plugs[3], &bebob->midi_output_ports); + if (err < 0) + goto end; /* for check source of clock later */ if (!clk_spec) From patchwork Sun Mar 21 03:28:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12152871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (unknown [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49DCFC433DB for ; Sun, 21 Mar 2021 03:31:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7CAC601FF for ; Sun, 21 Mar 2021 03:31:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7CAC601FF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 502421685; Sun, 21 Mar 2021 04:30:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 502421685 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1616297507; bh=pVUGynMoMIEuhBA/1TWMsGFgxpH/KJYjf2NCP5EjJCA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=GZG/rII/36xbD9VMcUEUAs4s0OOp28HhnY313/rajiizIY25gzufJdE6LP3yl6/4V 48uQm/DMVE8qlYM4A41ImDZkaoGVMqgXIlBR5vgv24rUhVtWzDuM6bIhtdbnQan4EN wIeQrcNqLmewEZiCwdL9MqMVThCXCadzBsNifuvo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4CDB7F8032D; Sun, 21 Mar 2021 04:29:59 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 27AC7F80268; Sun, 21 Mar 2021 04:29:07 +0100 (CET) Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 42C86F80240 for ; Sun, 21 Mar 2021 04:28:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 42C86F80240 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="C3H8sSFq"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Tr8u+c5q" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 505A6184F; Sat, 20 Mar 2021 23:28:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 20 Mar 2021 23:28:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=LXUjgIizDuHrF EGsIif3/h6poA60pmXgx3X16FGvO5Q=; b=C3H8sSFqkfxaDAhk2rIWKDVqB/8D2 Zc1P8PEc4ba/RgMeja43fzDYBl8YfFyO/sS6GVTjtlASIiYn15FSL2By471Rvt4c w6eOxBx/T25iYa907C9Z4JHqtG9PJdy/6zhEHVlBJdB9ozCrcCF7mvMqlmLn9X7u wfwzrAJrE/aCoGNivy9LkhH60cnhVxFql7Wz4mIpctMgM+xG6zlumYqDKsL4dklm 18V/cMLnBaXC0rfYqRhHKSObgNo1jrdw7ZGnHcmRnF1qZGJumtqLK+einneFHkDU UoVVuabSOjwbMWAq0UHobihjDpP/038rqgK8V6jqcgJgFdJbne5K448Bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=LXUjgIizDuHrFEGsIif3/h6poA60pmXgx3X16FGvO5Q=; b=Tr8u+c5q hcZGWZfpNcHksEa71gIOh4R16mo4NZURBNZ4i5mV9BFPorsMKCK31i6pVnTXmmHO Sx22B+qJF792y9vkq3EB6g4WpyTX/Mn1QHAEzYyqdM3rIPmoshojN5Y9OBCKTmfQ DF+DrXNRsdN00r4nGr17HBFE8T/3vTD95fPUxgkBknr4nmvtUreBqlqeMxW8eLIr W2UpGdO61r/g57838tdwbfUvPjFJfU2T8tNNHe+iRK71N9kszVyJKP6+06N9xC2r vyV2YzpAdt9PaTP3xJvSYXRpkLMZQNLoF7fb3CkARtb13UPJnls5eloFxmfsEZ5B mwbHdw/uq/niYA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudeguddgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 008492403E0; Sat, 20 Mar 2021 23:28:37 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 3/3] ALSA: bebob: enable to deliver MIDI messages for multiple ports Date: Sun, 21 Mar 2021 12:28:31 +0900 Message-Id: <20210321032831.340278-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210321032831.340278-1-o-takashi@sakamocchi.jp> References: <20210321032831.340278-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" Current implementation of bebob driver doesn't correctly handle the case that the device has multiple MIDI ports. The cause is the number of MIDI conformant data channels is passed to AM824 data block processing layer. This commit fixes the bug. Signed-off-by: Takashi Sakamoto --- sound/firewire/bebob/bebob_stream.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index 23579a73e038..b612ee3e33b6 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c @@ -517,20 +517,22 @@ int snd_bebob_stream_init_duplex(struct snd_bebob *bebob) static int keep_resources(struct snd_bebob *bebob, struct amdtp_stream *stream, unsigned int rate, unsigned int index) { - struct snd_bebob_stream_formation *formation; + unsigned int pcm_channels; + unsigned int midi_ports; struct cmp_connection *conn; int err; if (stream == &bebob->tx_stream) { - formation = bebob->tx_stream_formations + index; + pcm_channels = bebob->tx_stream_formations[index].pcm; + midi_ports = bebob->midi_input_ports; conn = &bebob->out_conn; } else { - formation = bebob->rx_stream_formations + index; + pcm_channels = bebob->rx_stream_formations[index].pcm; + midi_ports = bebob->midi_output_ports; conn = &bebob->in_conn; } - err = amdtp_am824_set_parameters(stream, rate, formation->pcm, - formation->midi, false); + err = amdtp_am824_set_parameters(stream, rate, pcm_channels, midi_ports, false); if (err < 0) return err;