From patchwork Thu Jan 12 12:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13097883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 16D76C54EBC for ; Thu, 12 Jan 2023 12:11:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 84C6E8CFA; Thu, 12 Jan 2023 13:10:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 84C6E8CFA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673525462; bh=12gFNVXFOBEGicvHrOxgnFPcN3AYQ6+uQof+i2KEWt0=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=abWHVfFhXb5z0zg4IZOLK2+9gKrQTqy+DoUrEW18feX/4QzkFWt1IXBtkrn4qVWyh 29zBaap+E+tcdh9VZ0NXe2+LUPpjVUVocu5g5CCNQulTcuG0Rol+yPNlYLtJlIaEVo 7xItZdo9RZqeehhICNGbn8PQt437H6qg2Qoo0Z5Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3A514F804CA; Thu, 12 Jan 2023 13:10:12 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EEE57F804D9; Thu, 12 Jan 2023 13:10:10 +0100 (CET) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C9F5BF804BD for ; Thu, 12 Jan 2023 13:10:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C9F5BF804BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=QAT1Y1Oc; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=cdlhPHT6 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 2D63A3200754; Thu, 12 Jan 2023 07:10:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 12 Jan 2023 07:10:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673525402; x= 1673611802; bh=w4c8aheRlcwEZ6gclG5PADACq+h0SqePde2fZNUGaiY=; b=Q AT1Y1OcCLc0jG3cNplQXY3t14LPEiW+DL74c2htW3hF/JSCsKit3FZma4JbyhgAL o70UIKS8e2giE1JssxoCiTtPuah8TD315VWsOrtiOYAbWsCWJz1N2ZifZ071uE9H TVFoumAjQQlZM7tEuF54hP5+O+NGAgx8DeVjimo63K5Y/HTDf3ab2TNLyIH0k9il f7NAVqQZahuTjDmV6hmC2Wo+p+899PVAM7omoxvlPYP9A2ots52g8Beoh596Rznv CiXnBJWVQ3oIukV7sKoxTGcD9q9HVP6rKPa7FQWtjQ7g329zGako2LcXYM5DrXwG yI2Ln5pk4g8sWDclLTlgg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673525402; x=1673611802; bh=w4c8aheRlcwEZ 6gclG5PADACq+h0SqePde2fZNUGaiY=; b=cdlhPHT652W84ukzdDKDK4GBkBLI2 JoN+rffU/r3CKAm7SLT4Ubet7ZKQifx4cH4O2s8zmBj/bQ7xjkIcosLueym0HrL0 Q37yKai89H72jBq4QI+pD7KA982k/dGiOKXWlVJ0CCuycKJPJe1efxJPQSLfsP+O t4COawKloHXGdYbObq+B8qjRVodkuom+ADNyLLeHJqnxdRE/0PEPAIlnl9Q1F9zW hoybJ8bhhKITI2Y3DWQM9iusOJEspTXw7UPKubQlYYxsgOcxlvGPfa3kb/hnGqle qASPW5ZYL+dIs4CjHix4hTHmsCUBlHNA24RWy4+8Bctv5YhFnv9Kdf+sg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 07:10:00 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 1/6] ALSA: fireface: rename callback functions Date: Thu, 12 Jan 2023 21:09:49 +0900 Message-Id: <20230112120954.500692-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112120954.500692-1-o-takashi@sakamocchi.jp> References: <20230112120954.500692-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" It's cleared that Fireface 400 transmits quadlet message for two purposes at least; received MIDI messages and notification of knob control operation. Nevertheless current implementation uses callback function name just for MIDI messages. This commit renames the callback functions. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-protocol-former.c | 12 ++++++------ sound/firewire/fireface/ff-protocol-latter.c | 6 +++--- sound/firewire/fireface/ff-transaction.c | 12 +++++------- sound/firewire/fireface/ff.h | 4 ++-- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-former.c b/sound/firewire/fireface/ff-protocol-former.c index 8900ffe517ed..16afcb334e3c 100644 --- a/sound/firewire/fireface/ff-protocol-former.c +++ b/sound/firewire/fireface/ff-protocol-former.c @@ -402,8 +402,8 @@ static void ff800_finish_session(struct snd_ff *ff) // address. // A write transaction to clear registered higher 4 bytes of destination address // has an effect to suppress asynchronous transaction from device. -static void ff800_handle_midi_msg(struct snd_ff *ff, unsigned int offset, - __le32 *buf, size_t length) +static void ff800_handle_midi_msg(struct snd_ff *ff, unsigned int offset, const __le32 *buf, + size_t length) { int i; @@ -418,7 +418,7 @@ static void ff800_handle_midi_msg(struct snd_ff *ff, unsigned int offset, } const struct snd_ff_protocol snd_ff_protocol_ff800 = { - .handle_midi_msg = ff800_handle_midi_msg, + .handle_msg = ff800_handle_midi_msg, .fill_midi_msg = former_fill_midi_msg, .get_clock = former_get_clock, .switch_fetching_mode = former_switch_fetching_mode, @@ -553,8 +553,8 @@ static void ff400_finish_session(struct snd_ff *ff) // input attenuation. This driver allocates destination address with '0000'0000 // in its lower offset and expects userspace application to configure the // register for it. -static void ff400_handle_midi_msg(struct snd_ff *ff, unsigned int offset, - __le32 *buf, size_t length) +static void ff400_handle_msg(struct snd_ff *ff, unsigned int offset, const __le32 *buf, + size_t length) { int i; @@ -592,7 +592,7 @@ static void ff400_handle_midi_msg(struct snd_ff *ff, unsigned int offset, } const struct snd_ff_protocol snd_ff_protocol_ff400 = { - .handle_midi_msg = ff400_handle_midi_msg, + .handle_msg = ff400_handle_msg, .fill_midi_msg = former_fill_midi_msg, .get_clock = former_get_clock, .switch_fetching_mode = former_switch_fetching_mode, diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c index 76c3eab36d4e..e7a066fb1ead 100644 --- a/sound/firewire/fireface/ff-protocol-latter.c +++ b/sound/firewire/fireface/ff-protocol-latter.c @@ -393,8 +393,8 @@ static void latter_dump_status(struct snd_ff *ff, struct snd_info_buffer *buffer // input attenuation. This driver allocates for the first option // (0x'....'....'0000'0000) and expects userspace application to configure the // register for it. -static void latter_handle_midi_msg(struct snd_ff *ff, unsigned int offset, - __le32 *buf, size_t length) +static void latter_handle_midi_msg(struct snd_ff *ff, unsigned int offset, const __le32 *buf, + size_t length) { u32 data = le32_to_cpu(*buf); unsigned int index = (data & 0x000000f0) >> 4; @@ -529,7 +529,7 @@ static int latter_fill_midi_msg(struct snd_ff *ff, } const struct snd_ff_protocol snd_ff_protocol_latter = { - .handle_midi_msg = latter_handle_midi_msg, + .handle_msg = latter_handle_midi_msg, .fill_midi_msg = latter_fill_midi_msg, .get_clock = latter_get_clock, .switch_fetching_mode = latter_switch_fetching_mode, diff --git a/sound/firewire/fireface/ff-transaction.c b/sound/firewire/fireface/ff-transaction.c index ee7122c461d4..764c772a0b1e 100644 --- a/sound/firewire/fireface/ff-transaction.c +++ b/sound/firewire/fireface/ff-transaction.c @@ -125,10 +125,9 @@ static void transmit_midi1_msg(struct work_struct *work) transmit_midi_msg(ff, 1); } -static void handle_midi_msg(struct fw_card *card, struct fw_request *request, - int tcode, int destination, int source, - int generation, unsigned long long offset, - void *data, size_t length, void *callback_data) +static void handle_msg(struct fw_card *card, struct fw_request *request, int tcode, + int destination, int source, int generation, unsigned long long offset, + void *data, size_t length, void *callback_data) { struct snd_ff *ff = callback_data; __le32 *buf = data; @@ -136,8 +135,7 @@ static void handle_midi_msg(struct fw_card *card, struct fw_request *request, fw_send_response(card, request, RCODE_COMPLETE); offset -= ff->async_handler.offset; - ff->spec->protocol->handle_midi_msg(ff, (unsigned int)offset, buf, - length); + ff->spec->protocol->handle_msg(ff, (unsigned int)offset, buf, length); } static int allocate_own_address(struct snd_ff *ff, int i) @@ -146,7 +144,7 @@ static int allocate_own_address(struct snd_ff *ff, int i) int err; ff->async_handler.length = ff->spec->midi_addr_range; - ff->async_handler.address_callback = handle_midi_msg; + ff->async_handler.address_callback = handle_msg; ff->async_handler.callback_data = ff; midi_msg_region.start = 0x000100000000ull * i; diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index 0535f0b58b67..0358b444bd01 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -110,8 +110,8 @@ enum snd_ff_clock_src { }; struct snd_ff_protocol { - void (*handle_midi_msg)(struct snd_ff *ff, unsigned int offset, - __le32 *buf, size_t length); + void (*handle_msg)(struct snd_ff *ff, unsigned int offset, const __le32 *buf, + size_t length); int (*fill_midi_msg)(struct snd_ff *ff, struct snd_rawmidi_substream *substream, unsigned int port); From patchwork Thu Jan 12 12:09:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13097884 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AD659C54EBC for ; Thu, 12 Jan 2023 12:11:30 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E82EC2E0C; Thu, 12 Jan 2023 13:10:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E82EC2E0C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673525489; bh=xDfhK1WRu59UWNh13PlTKWQ8FnAXYBs0RZSQlMDLADw=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=FYtyTYDBF79Dvenna0oxjIkRjJanqzlAQHex5DKWXoy8vnPRh019FlG+c3zyI17ZG JnL/t4dkPOM+T9FymODA93TBy80mCe76dPXbepNiOPGEq9UPslNVb0fr6sLA+8Z+DO 14RfXDlVNBcC4xNyqxzftYQWw4gs896vLsltEj+w= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 41625F804E4; Thu, 12 Jan 2023 13:10:13 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A1FFCF804C1; Thu, 12 Jan 2023 13:10:11 +0100 (CET) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C7F02F804C1 for ; Thu, 12 Jan 2023 13:10:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C7F02F804C1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=N61/H9AK; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=M8njHdX7 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 657BF320092C; Thu, 12 Jan 2023 07:10:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 12 Jan 2023 07:10:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673525405; x= 1673611805; bh=QROKRqY2nM/HtDqTFwv3PBfv2g4ED2lHTZ9dBipP8Qc=; b=N 61/H9AKK3GcodcN3f5XBvBeO8D8kv1YpmD7ACoIV7r4fDgkMgeerDKD1OMxoejS2 sQ/DIDT1AsH1vMbBLH5jxADowmvEv2jM3GLvgS+EEueEzbVrRG+2fwgQ8basd14z LZAMs6zeVYRpOoOZ7Dhgf2aoBnBzXswv23DAnzBwWUudRd9kV6CbI+qsastXqc4a t4o3aG6mLZRUpTcZc40K7fC6ibKL6McSi7OISwPMHisEIelZ5BTTFKHR2Z4FphXj 6ttDQY65Wn9VSVibup1Z6AdFmypODKp7nJ2FQLucuye80Lfmuqy4HcrFBS/MtpkH YzfInIvBJDpiCyXKRHHYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673525405; x=1673611805; bh=QROKRqY2nM/Ht DqTFwv3PBfv2g4ED2lHTZ9dBipP8Qc=; b=M8njHdX7OoG14TwO9JCB6blODUGPh CPr/QnlZ2qLdHjeqC5eA3kg7L2jeez/Jcy+oalEYqZcnEE26k9TbJ2SZWJdf+s39 Hm+VRSeY/9qESIOGthngu4CrzQlP9YNLxRVXuRJgLkXUwwO+6hXySCGY3fj9qeHp 11947QY3KfrY/s26dXg8d9IfFQrGXvFkSo60Rcp/6ehMojTDCT1vQgHlnXWcDoWe NwoFWo8PJbK/Kw0VdyfwtT1IpLsxx+vVDCTNCHNFK43TVXuXcK3phQEIUvzNt5Bw jbpR+n7Jgyq3T9k/VP3J4uzm6mtnRLK0w3o1E1aAnPR53jMPZJAhirqxA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 07:10:03 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 2/6] ALSA: fireface: pick up time stamp for request subaction of asynchronous transaction Date: Thu, 12 Jan 2023 21:09:50 +0900 Message-Id: <20230112120954.500692-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112120954.500692-1-o-takashi@sakamocchi.jp> References: <20230112120954.500692-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The time stamp of isochronous cycle at which asynchronous transaction is sent is perhaps useful somehow. A commit b2405aa948b9 ("firewire: add kernel API to access packet structure in request structure for AR context") adds kernel API to retrieve the time stamp in inner structure of request subaction. This commit changes local framework to handle message delivered by the asynchronous transaction so that time stamp is picked up by the kernel API. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-protocol-former.c | 4 ++-- sound/firewire/fireface/ff-protocol-latter.c | 2 +- sound/firewire/fireface/ff-transaction.c | 3 ++- sound/firewire/fireface/ff.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-former.c b/sound/firewire/fireface/ff-protocol-former.c index 16afcb334e3c..22d6aee52de3 100644 --- a/sound/firewire/fireface/ff-protocol-former.c +++ b/sound/firewire/fireface/ff-protocol-former.c @@ -403,7 +403,7 @@ static void ff800_finish_session(struct snd_ff *ff) // A write transaction to clear registered higher 4 bytes of destination address // has an effect to suppress asynchronous transaction from device. static void ff800_handle_midi_msg(struct snd_ff *ff, unsigned int offset, const __le32 *buf, - size_t length) + size_t length, u32 tstamp) { int i; @@ -554,7 +554,7 @@ static void ff400_finish_session(struct snd_ff *ff) // in its lower offset and expects userspace application to configure the // register for it. static void ff400_handle_msg(struct snd_ff *ff, unsigned int offset, const __le32 *buf, - size_t length) + size_t length, u32 tstamp) { int i; diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c index e7a066fb1ead..9947e0c2e0aa 100644 --- a/sound/firewire/fireface/ff-protocol-latter.c +++ b/sound/firewire/fireface/ff-protocol-latter.c @@ -394,7 +394,7 @@ static void latter_dump_status(struct snd_ff *ff, struct snd_info_buffer *buffer // (0x'....'....'0000'0000) and expects userspace application to configure the // register for it. static void latter_handle_midi_msg(struct snd_ff *ff, unsigned int offset, const __le32 *buf, - size_t length) + size_t length, u32 tstamp) { u32 data = le32_to_cpu(*buf); unsigned int index = (data & 0x000000f0) >> 4; diff --git a/sound/firewire/fireface/ff-transaction.c b/sound/firewire/fireface/ff-transaction.c index 764c772a0b1e..79f733d8c98b 100644 --- a/sound/firewire/fireface/ff-transaction.c +++ b/sound/firewire/fireface/ff-transaction.c @@ -131,11 +131,12 @@ static void handle_msg(struct fw_card *card, struct fw_request *request, int tco { struct snd_ff *ff = callback_data; __le32 *buf = data; + u32 tstamp = fw_request_get_timestamp(request); fw_send_response(card, request, RCODE_COMPLETE); offset -= ff->async_handler.offset; - ff->spec->protocol->handle_msg(ff, (unsigned int)offset, buf, length); + ff->spec->protocol->handle_msg(ff, (unsigned int)offset, buf, length, tstamp); } static int allocate_own_address(struct snd_ff *ff, int i) diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index 0358b444bd01..f430ebe157b3 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -111,7 +111,7 @@ enum snd_ff_clock_src { struct snd_ff_protocol { void (*handle_msg)(struct snd_ff *ff, unsigned int offset, const __le32 *buf, - size_t length); + size_t length, u32 tstamp); int (*fill_midi_msg)(struct snd_ff *ff, struct snd_rawmidi_substream *substream, unsigned int port); From patchwork Thu Jan 12 12:09:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13097886 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7E787C61DB3 for ; Thu, 12 Jan 2023 12:12:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7D33440A7; Thu, 12 Jan 2023 13:11:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7D33440A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673525519; bh=zBNM/2odBr4WHyDRLVW6VEDNXNPP4Am3+8hHM96bDBI=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=RO51lxO0ST1tVCEFchK9uFPf/tY0aGoJEXZCTxE3/IeE4hqfEmvX2fieRzIvxpPHh ED+ynL05sTzK25uWLvZg9PaRal3m3NGz1O71VMY3bhpru3ZhZhhYLvUidf4pReVIZD c/taOHYJcmL9gwS348hLkmYTHvbTCNISuTAEAbAk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 89564F8053A; Thu, 12 Jan 2023 13:10:16 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4B619F80539; Thu, 12 Jan 2023 13:10:13 +0100 (CET) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 09764F804BD for ; Thu, 12 Jan 2023 13:10:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 09764F804BD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=NqR4SatO; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=XRrCoxej Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id A58BB320030E; Thu, 12 Jan 2023 07:10:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 12 Jan 2023 07:10:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673525407; x= 1673611807; bh=/E74PMlIi85CDPZBsXXevIugzm1ADatDBmvAN+5Y2S0=; b=N qR4SatOgYvmkd0WiF07ROBDR/28MAC+k2ZhJibhU4SXvQHdvOtJmjacPeMUHrq95 dKKYJ5B+aW3cEbH1d4XbMdfap7b+0QEPpzCUQxeaJQi26kHA0aIxglOGV9EKQz+7 W6b/7euFmibpuw0Cgxk0kz3+BJ+vhIntwrs4Ti+C8n/r7VoxXo9Aanac8B3RUxyv QwqAKYB7+QRqSfahN7xDiVCGIPxGsoQJV5iybnsOtOIN4PwCLeCHiAPVkTzWO6+8 0qKKbetGaA6TWOss1+jziG2eSjHuyNztZWebiGbfpPWPA1XJjRk3oFuyx14i50gh RUwEKWZklh79+RjYHKA6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673525407; x=1673611807; bh=/E74PMlIi85CD PZBsXXevIugzm1ADatDBmvAN+5Y2S0=; b=XRrCoxejfmJy1sBZKmYenLgX0WNlk pzNvOsozUCB2L6Fth7bhlWB0HAzrbtkgEuJPzMTMDj18nc/VjySufSRrfhuCUoN8 rlzKGJSlQDeZhT39MToFlkJCtdml+eK794X97F3kksBFro6TfH9aHEjt6/aPhK72 14Ow2Rfc1OIek4675svkMg8GoSM57ZBTiBo0nKjwHl3OF/nNdCM/YpiRfL7N/Hez lXNu4kLEJMPuK/W5XnbK7TYxQlbNdZUVXXtqO3LBaJORji19KSoWPsSnJjttVH+I AJ2ouRuBTG42CXMAPmei10TzsFXRy9tOwAlnJ5/idefwzSkeo/TcxzNcw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 07:10:05 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 3/6] ALSA: fireface: add helper function to parse MIDI messages transmitted by Fireface 400 Date: Thu, 12 Jan 2023 21:09:51 +0900 Message-Id: <20230112120954.500692-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112120954.500692-1-o-takashi@sakamocchi.jp> References: <20230112120954.500692-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This is minor code refactoring to add helper function to parse MIDI message bytes in quadlet message. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-protocol-former.c | 47 +++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-former.c b/sound/firewire/fireface/ff-protocol-former.c index 22d6aee52de3..d2cc9961b973 100644 --- a/sound/firewire/fireface/ff-protocol-former.c +++ b/sound/firewire/fireface/ff-protocol-former.c @@ -534,6 +534,22 @@ static void ff400_finish_session(struct snd_ff *ff) FF400_ISOC_COMM_STOP, ®, sizeof(reg), 0); } +static void parse_midi_msg(struct snd_ff *ff, u32 quad, unsigned int port) +{ + struct snd_rawmidi_substream *substream = READ_ONCE(ff->tx_midi_substreams[port]); + + if (substream != NULL) { + u8 byte = (quad >> (16 * port)) & 0x000000ff; + + snd_rawmidi_receive(substream, &byte, 1); + } +} + +#define FF400_MSG_FLAG_IS_MIDI_PORT_0 0x00000100 +#define FF400_MSG_MASK_MIDI_PORT_0 0x000000ff +#define FF400_MSG_FLAG_IS_MIDI_PORT_1 0x01000000 +#define FF400_MSG_MASK_MIDI_PORT_1 0x00ff0000 + // For Fireface 400, lower 4 bytes of destination address is configured by bit // flag in quadlet register (little endian) at 0x'0000'801'0051c. Drivers can // select one of 4 options: @@ -560,34 +576,11 @@ static void ff400_handle_msg(struct snd_ff *ff, unsigned int offset, const __le3 for (i = 0; i < length / 4; i++) { u32 quad = le32_to_cpu(buf[i]); - u8 byte; - unsigned int index; - struct snd_rawmidi_substream *substream; - /* Message in first port. */ - /* - * This value may represent the index of this unit when the same - * units are on the same IEEE 1394 bus. This driver doesn't use - * it. - */ - index = (quad >> 8) & 0xff; - if (index > 0) { - substream = READ_ONCE(ff->tx_midi_substreams[0]); - if (substream != NULL) { - byte = quad & 0xff; - snd_rawmidi_receive(substream, &byte, 1); - } - } - - /* Message in second port. */ - index = (quad >> 24) & 0xff; - if (index > 0) { - substream = READ_ONCE(ff->tx_midi_substreams[1]); - if (substream != NULL) { - byte = (quad >> 16) & 0xff; - snd_rawmidi_receive(substream, &byte, 1); - } - } + if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_0) + parse_midi_msg(ff, quad, 0); + else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_1) + parse_midi_msg(ff, quad, 1); } } From patchwork Thu Jan 12 12:09:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13097887 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B5FCBC54EBD for ; Thu, 12 Jan 2023 12:12:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BD32B50C4; Thu, 12 Jan 2023 13:11:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BD32B50C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673525545; bh=c5u44GiTWkFZotG8x/UdUgo4YmgY68gGCQU0CbxS5ws=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=BMr4YLnXw56iZCVOgw+9E92nA8oHv1BKW2Zxc2IMDIUlnHPXqIiThvIpGB6CWrHgv N5eWwrqND1pq6siW1mcGlOWwZqgXewZY3YOv39imkw2HNhgbE2CYRkT7SneIR1jvqt eiW2+0mrgiqH0zjM+CP9bP/xd6PBJ/A0dgwTBPhs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BFCC7F80558; Thu, 12 Jan 2023 13:10:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F1C5CF80543; Thu, 12 Jan 2023 13:10:15 +0100 (CET) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A82AAF804C1 for ; Thu, 12 Jan 2023 13:10:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A82AAF804C1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=lOZ6P59N; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=beDhYvfS Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id F0AE33200930; Thu, 12 Jan 2023 07:10:09 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 12 Jan 2023 07:10:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673525409; x= 1673611809; bh=UNlHD8gW0ngNuYF/LW1sYgMPqPGbma3iF/sGBB13x6Y=; b=l OZ6P59NE580QSkk3qo7SiF+v04RAdPRj4lfnDi3ZBHSuUpvFZFDNTe5c2D9VVjNE TGW5j3i9SCJfYmGjqi/rwMZvtGmQ8SPrfVksLUguinUtgKJ1LkRm1XbHrQWbH153 tIydYVWknSlW8shmsI7Hq2Ru2zFpIRh6aV5S/MUgECdWG0WpB2gjP+9GPqXdivhr DxACvwL3ImcQamVNGK3ElvLyF0oZGF404NYt5y8JQYwK9UzJkhQjNJ1m4nBrXXfc iGCmWHB9pdSV3QezBTe/iLEz5t8isgTZKxh08tow2xJirRNkE490tKrzfe+mmkBG uUD2AfghXjFvkt/5MNbzA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673525409; x=1673611809; bh=UNlHD8gW0ngNu YF/LW1sYgMPqPGbma3iF/sGBB13x6Y=; b=beDhYvfSzon+ihqr49DdrzfpIaTAP lQZolt77+eG3z8n96EhNPlmkq7DeYFDqf4CbXb1tggMhqf4uNLGaNw9mhgeQn4LC oQbiybINyexQWFfyOwYllMVH1JXObY4CprIe43z10A+nn0mJhZ4W32o1SnTP6IGW pp4vczfawq7K/oWsXiRncESr4oMlduUMtDbgdJcVQPe3vKbLFy4f2rujNCvVwIMO eO3/dT0bj37OvmIe1wUPaqwWIbDXGR0RIRWDRoByQtf6VXIX7sE08j8CWyyJhlgX MyWmNiHx/AzO4klJs0i3WgCpcUmFex9XrwSECjy/6MqBdj4OEKBJyD3OA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 07:10:08 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 4/6] ALSA: fireface: update UAPI for data of knob control Date: Thu, 12 Jan 2023 21:09:52 +0900 Message-Id: <20230112120954.500692-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112120954.500692-1-o-takashi@sakamocchi.jp> References: <20230112120954.500692-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit adds a new event of knob control specific to RME Fireface 400. Signed-off-by: Takashi Sakamoto --- include/uapi/sound/firewire.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/uapi/sound/firewire.h b/include/uapi/sound/firewire.h index 3532ac7046d7..50917581dd2b 100644 --- a/include/uapi/sound/firewire.h +++ b/include/uapi/sound/firewire.h @@ -14,6 +14,7 @@ #define SNDRV_FIREWIRE_EVENT_MOTU_NOTIFICATION 0x64776479 #define SNDRV_FIREWIRE_EVENT_TASCAM_CONTROL 0x7473636d #define SNDRV_FIREWIRE_EVENT_MOTU_REGISTER_DSP_CHANGE 0x4d545244 +#define SNDRV_FIREWIRE_EVENT_FF400_MESSAGE 0x4f6c6761 struct snd_firewire_event_common { unsigned int type; /* SNDRV_FIREWIRE_EVENT_xxx */ @@ -72,6 +73,28 @@ struct snd_firewire_event_motu_register_dsp_change { __u32 changes[]; /* Encoded event for change of register DSP. */ }; +/** + * struct snd_firewire_event_ff400_message - the container for message from Fireface 400 when + * operating hardware knob. + * + * @type: Fixed to SNDRV_FIREWIRE_EVENT_FF400_MESSAGE. + * @messages.message: The messages expressing hardware knob operation. + * @messages.tstamp: The isochronous cycle at which the request subaction of asynchronous + * transaction was sent to deliver the message. It has 16 bit unsigned integer + * value. The higher 3 bits of value expresses the lower three bits of second + * field in the format of CYCLE_TIME, up to 7. The rest 13 bits expresses cycle + * field up to 7999. + * + * The structure expresses message transmitted by Fireface 400 when operating hardware knob. + */ +struct snd_firewire_event_ff400_message { + unsigned int type; + struct { + __u32 message; + __u32 tstamp; + } messages[]; +}; + union snd_firewire_event { struct snd_firewire_event_common common; struct snd_firewire_event_lock_status lock_status; @@ -81,6 +104,7 @@ union snd_firewire_event { struct snd_firewire_event_tascam_control tascam_control; struct snd_firewire_event_motu_notification motu_notification; struct snd_firewire_event_motu_register_dsp_change motu_register_dsp_change; + struct snd_firewire_event_ff400_message ff400_message; }; From patchwork Thu Jan 12 12:09:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13097888 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F2C66C54EBC for ; Thu, 12 Jan 2023 12:12:38 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0BBEE5576; Thu, 12 Jan 2023 13:11:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0BBEE5576 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673525557; bh=bom6iDovjPR8h43XjUic+WoachRYoYeHoW3CUJ6aYy4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=WFdHqMSRShgb8O9wpO5GbU0oj8r6ocanNW5ujvczxO3Z3V7UsaD7cA4zLrSjvOj6y kFB1ayOs9KhBNpDpy1Xu/WFaoXqAIQddhBPzlQftmvmM7eIpnysU1DndN8csdr2z7F 8RK29xzzYsYLhp1hoXtoY2AaV7pUdTrz17n2To/A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AFF8CF80567; Thu, 12 Jan 2023 13:10:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 14C63F80563; Thu, 12 Jan 2023 13:10:18 +0100 (CET) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 356A9F80539 for ; Thu, 12 Jan 2023 13:10:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 356A9F80539 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=Cr65VU+o; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=KlwGexP3 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 3892932005D8; Thu, 12 Jan 2023 07:10:12 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 12 Jan 2023 07:10:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673525411; x= 1673611811; bh=jIjQLxPzQp9KlPrtd/2Ool6fxDwQOyxeMj0J+DUzA0o=; b=C r65VU+oQGWzDJSWXV9bO5PXEC/EuQ6++W31QQ7P0UPP1sovzUF2pzXmjt4oemy8F Vrhm+FiNRIlcI3uy0raJy9nr6p4n4WYqZMZ2vXN0kRm0aMpZdIf59NgI0D92FvTD pOc3EaxrIwsblrLQ9MD6I9qljjAOraMe399bCv65dieR0A1cQAU04a8dKZ+CgvoK ZUqnnatapPrRooLkD4wYIXozWnWr8KY8d/ty0pqqV6eS1rYmCrGMeNVfFrg8o8fe RyughNsHmFE1GYVGYihAiDaHdgP6ZD1QY86VoUf8HjHvUEXA/zl7UoDTyvoic14v jBK31EJUpGYnUlZ/CwdfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673525411; x=1673611811; bh=jIjQLxPzQp9Kl Prtd/2Ool6fxDwQOyxeMj0J+DUzA0o=; b=KlwGexP3QiYf/QJ0MTQ8fJayv0OIU epQY2nw5z0MFK6EoBbcEDhGWSKRUnViQcIf5T09QOtLuyItEJTSYnP2Tnf7urY0x 2ImLa+H82FbqRacpElOZ4nQChGHB8JIeK6f41yKHH7rFezvAbe70Ko69e2PbiIJg v+jEryWDCWGGyIJ7GbEl7Vhk4CxsB9Txs8JtcJf6S+1cwhkHbYT6sYSGz5ljy86B iFBoEjjOZIFv7OxlMiV5JmEizJ3M8vvox0BaXJ+VByRbO9khVejVfFN8iWqCDlmf 7U3SSyaS7O5oO/6kBNz5pPHwVTekaPtul2asvAFO8u4RSwpMi0nl8dHWg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 07:10:10 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 5/6] ALSA: fireface: add local framework to message parser Date: Thu, 12 Jan 2023 21:09:53 +0900 Message-Id: <20230112120954.500692-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112120954.500692-1-o-takashi@sakamocchi.jp> References: <20230112120954.500692-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit adds local framework to message parser. This is preparation for future work to pass event of knob control for Fireface 400 to user space. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-hwdep.c | 41 +++++++++++++++++------- sound/firewire/fireface/ff-transaction.c | 4 +++ sound/firewire/fireface/ff.c | 10 ++++++ sound/firewire/fireface/ff.h | 5 +++ 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/sound/firewire/fireface/ff-hwdep.c b/sound/firewire/fireface/ff-hwdep.c index ea64a2a41eea..8a741b3b0436 100644 --- a/sound/firewire/fireface/ff-hwdep.c +++ b/sound/firewire/fireface/ff-hwdep.c @@ -15,16 +15,23 @@ #include "ff.h" +static bool has_msg(struct snd_ff *ff) +{ + if (ff->spec->protocol->has_msg) + return ff->spec->protocol->has_msg(ff); + else + return 0; +} + static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, loff_t *offset) { struct snd_ff *ff = hwdep->private_data; DEFINE_WAIT(wait); - union snd_firewire_event event; spin_lock_irq(&ff->lock); - while (!ff->dev_lock_changed) { + while (!ff->dev_lock_changed && !has_msg(ff)) { prepare_to_wait(&ff->hwdep_wait, &wait, TASK_INTERRUPTIBLE); spin_unlock_irq(&ff->lock); schedule(); @@ -34,17 +41,29 @@ static long hwdep_read(struct snd_hwdep *hwdep, char __user *buf, long count, spin_lock_irq(&ff->lock); } - memset(&event, 0, sizeof(event)); - event.lock_status.type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS; - event.lock_status.status = (ff->dev_lock_count > 0); - ff->dev_lock_changed = false; + if (ff->dev_lock_changed && count >= sizeof(struct snd_firewire_event_lock_status)) { + struct snd_firewire_event_lock_status ev = { + .type = SNDRV_FIREWIRE_EVENT_LOCK_STATUS, + .status = (ff->dev_lock_count > 0), + }; - count = min_t(long, count, sizeof(event.lock_status)); + ff->dev_lock_changed = false; - spin_unlock_irq(&ff->lock); + spin_unlock_irq(&ff->lock); - if (copy_to_user(buf, &event, count)) - return -EFAULT; + if (copy_to_user(buf, &ev, sizeof(ev))) + return -EFAULT; + count = sizeof(ev); + } else if (has_msg(ff)) { + // NOTE: Acquired spin lock should be released before accessing to user space in the + // callback since the access can cause page fault. + count = ff->spec->protocol->copy_msg_to_user(ff, buf, count); + spin_unlock_irq(&ff->lock); + } else { + spin_unlock_irq(&ff->lock); + + count = 0; + } return count; } @@ -58,7 +77,7 @@ static __poll_t hwdep_poll(struct snd_hwdep *hwdep, struct file *file, poll_wait(file, &ff->hwdep_wait, wait); spin_lock_irq(&ff->lock); - if (ff->dev_lock_changed) + if (ff->dev_lock_changed || has_msg(ff)) events = EPOLLIN | EPOLLRDNORM; else events = 0; diff --git a/sound/firewire/fireface/ff-transaction.c b/sound/firewire/fireface/ff-transaction.c index 79f733d8c98b..6b89e39f4a43 100644 --- a/sound/firewire/fireface/ff-transaction.c +++ b/sound/firewire/fireface/ff-transaction.c @@ -132,11 +132,15 @@ static void handle_msg(struct fw_card *card, struct fw_request *request, int tco struct snd_ff *ff = callback_data; __le32 *buf = data; u32 tstamp = fw_request_get_timestamp(request); + unsigned long flag; fw_send_response(card, request, RCODE_COMPLETE); offset -= ff->async_handler.offset; + + spin_lock_irqsave(&ff->lock, flag); ff->spec->protocol->handle_msg(ff, (unsigned int)offset, buf, length, tstamp); + spin_unlock_irqrestore(&ff->lock, flag); } static int allocate_own_address(struct snd_ff *ff, int i) diff --git a/sound/firewire/fireface/ff.c b/sound/firewire/fireface/ff.c index 7bf51d062021..448e972028d9 100644 --- a/sound/firewire/fireface/ff.c +++ b/sound/firewire/fireface/ff.c @@ -43,6 +43,8 @@ static void ff_card_free(struct snd_card *card) snd_ff_stream_destroy_duplex(ff); snd_ff_transaction_unregister(ff); + kfree(ff->msg_parser); + mutex_destroy(&ff->mutex); fw_unit_put(ff->unit); } @@ -94,6 +96,14 @@ static int snd_ff_probe(struct fw_unit *unit, const struct ieee1394_device_id *e if (err < 0) goto error; + if (ff->spec->protocol->msg_parser_size > 0) { + ff->msg_parser = kzalloc(ff->spec->protocol->msg_parser_size, GFP_KERNEL); + if (!ff->msg_parser) { + err = -ENOMEM; + goto error; + } + } + err = snd_card_register(card); if (err < 0) goto error; diff --git a/sound/firewire/fireface/ff.h b/sound/firewire/fireface/ff.h index f430ebe157b3..7e42f5778a8a 100644 --- a/sound/firewire/fireface/ff.h +++ b/sound/firewire/fireface/ff.h @@ -97,6 +97,8 @@ struct snd_ff { wait_queue_head_t hwdep_wait; struct amdtp_domain domain; + + void *msg_parser; }; enum snd_ff_clock_src { @@ -110,6 +112,9 @@ enum snd_ff_clock_src { }; struct snd_ff_protocol { + size_t msg_parser_size; + bool (*has_msg)(struct snd_ff *ff); + long (*copy_msg_to_user)(struct snd_ff *ff, char __user *buf, long count); void (*handle_msg)(struct snd_ff *ff, unsigned int offset, const __le32 *buf, size_t length, u32 tstamp); int (*fill_midi_msg)(struct snd_ff *ff, From patchwork Thu Jan 12 12:09:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 13097889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0C6E6C54EBD for ; Thu, 12 Jan 2023 12:12:54 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 38EFA5ECA; Thu, 12 Jan 2023 13:12:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 38EFA5ECA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673525572; bh=gK8/tkpYlxATkQsO9XNO4Z2bjpTVjR3SuXTh09/vKpo=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=qjNLg7FcIOz9qkb/TbyiAcoQDx7HOQoDiUrk/ldYUw8YMo3R26hCEi0bqePIOsN7T fXb8nv9EIfbra6EX8l8DIid9+1UJ7V0db52TyE0B4lRklBDjcMYql/9MHu2oGAdnTo b1fWCYsRob9pmofy3FPoG3gdqE+quR9CzMggnjwA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5CA20F80578; Thu, 12 Jan 2023 13:10:22 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0A944F8055C; Thu, 12 Jan 2023 13:10:19 +0100 (CET) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5A7F6F80558 for ; Thu, 12 Jan 2023 13:10:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5A7F6F80558 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.a=rsa-sha256 header.s=fm3 header.b=KfgTzzIC; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=INSlfodA Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 750403200926; Thu, 12 Jan 2023 07:10:14 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 12 Jan 2023 07:10:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1673525414; x= 1673611814; bh=RhyCQ9BUXc9pGETo5nJD3J62TbnHhvNRK59Kc5sZ+Gw=; b=K fgTzzICpPAT5Q5aFV5AgpbbHaEiohs+dCyxyE3Cwk1jtgvKhNgwhxHyb/92cRPEG 9qlrTcl/8ZzGg7DufzTDAuH0QB0X4AVGgjrpGCUEuiYeV2uJ8Q75bOXCYHoArVwg 8fkvo411vpXIIkI+yJOdjLHTLzlDFP0Y8xBavGJIIHuxUfzbyuywS35NHYZTnQA1 R8LP4kCP0yelDFy6/xvpQrn5N1Azq6t8TR582Ek5nwg0x8NoLNtFZwWIX7IDwjyG vIcCDpyq825pDcev7045XnJ/Pd/oc01e8xo00n7Z/jFpr0z2BqUnTafWFPXFC2wm LFNxueuiTJQ3RbM7S8Yyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1673525414; x=1673611814; bh=RhyCQ9BUXc9pG ETo5nJD3J62TbnHhvNRK59Kc5sZ+Gw=; b=INSlfodAQkBgdcblGDN6z7p+XWV9P snR9orze/4XQzi+wyMiYBATrG0eLDwukTdY2lex5XWOeJ0uHgemC2NPSZPypq3Rg OWzTaJ0nuQPi6J68R0mm/c3WwCqjottjj16/Y+AkKEVQlvJXCb1tdzp9b2THNlh7 Ix3izvkz8nB46ahfIE1s7hMJDEzB2PNFcjw/nk7TJm+r819PVB5jdXVi/CSls9wI atTjjXGN7xnhAIH6IUlm1otRwNO5v/Gzne8mXdCVH4aBfR2lGuuhCbNKsMFP8ULj odz933aNRA82NJRxZjR9AIMlANts/KiXHaQRaKFMpO48RVPTIXZuUcaNg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepvdejgfejue dvgfduudekleevtefgtdevhfdtffefiefgveeuteffiedvffekvddtnecuvehluhhsthgv rhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 07:10:12 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 6/6] ALSA: fireface: implement message parser for Fireface 400 Date: Thu, 12 Jan 2023 21:09:54 +0900 Message-Id: <20230112120954.500692-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230112120954.500692-1-o-takashi@sakamocchi.jp> References: <20230112120954.500692-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, clemens@ladisch.de Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This commit implements message parser for Fireface 400 to pass data of knob control to user space. The parser has FIFO which can store maximum 32 events without no overrun detection since it doesn't matter to lose the event. Signed-off-by: Takashi Sakamoto --- sound/firewire/fireface/ff-protocol-former.c | 143 ++++++++++++++++++- 1 file changed, 137 insertions(+), 6 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-former.c b/sound/firewire/fireface/ff-protocol-former.c index d2cc9961b973..f58008762fe6 100644 --- a/sound/firewire/fireface/ff-protocol-former.c +++ b/sound/firewire/fireface/ff-protocol-former.c @@ -545,10 +545,23 @@ static void parse_midi_msg(struct snd_ff *ff, u32 quad, unsigned int port) } } -#define FF400_MSG_FLAG_IS_MIDI_PORT_0 0x00000100 -#define FF400_MSG_MASK_MIDI_PORT_0 0x000000ff -#define FF400_MSG_FLAG_IS_MIDI_PORT_1 0x01000000 -#define FF400_MSG_MASK_MIDI_PORT_1 0x00ff0000 +#define FF400_QUEUE_SIZE 32 + +struct ff400_msg_parser { + struct { + u32 msg; + u32 tstamp; + } msgs[FF400_QUEUE_SIZE]; + size_t push_pos; + size_t pull_pos; +}; + +static bool ff400_has_msg(struct snd_ff *ff) +{ + struct ff400_msg_parser *parser = ff->msg_parser; + + return (parser->push_pos != parser->pull_pos); +} // For Fireface 400, lower 4 bytes of destination address is configured by bit // flag in quadlet register (little endian) at 0x'0000'801'0051c. Drivers can @@ -569,22 +582,140 @@ static void parse_midi_msg(struct snd_ff *ff, u32 quad, unsigned int port) // input attenuation. This driver allocates destination address with '0000'0000 // in its lower offset and expects userspace application to configure the // register for it. + +// When the message is for signal level operation, the upper 4 bits in MSB expresses the pair of +// stereo physical port. +// - 0: Microphone input 0/1 +// - 1: Line input 0/1 +// - [2-4]: Line output 0-5 +// - 5: Headphone output 0/1 +// - 6: S/PDIF output 0/1 +// - [7-10]: ADAT output 0-7 +// +// The value of signal level can be detected by mask of 0x00fffc00. For signal level of microphone +// input: +// +// - 0: 0.0 dB +// - 10: +10.0 dB +// - 11: +11.0 dB +// - 12: +12.0 dB +// - ... +// - 63: +63.0 dB: +// - 64: +64.0 dB: +// - 65: +65.0 dB: +// +// For signal level of line input: +// +// - 0: 0.0 dB +// - 1: +0.5 dB +// - 2: +1.0 dB +// - 3: +1.5 dB +// - ... +// - 34: +17.0 dB: +// - 35: +17.5 dB: +// - 36: +18.0 dB: +// +// For signal level of any type of output: +// +// - 63: -infinite +// - 62: -58.0 dB +// - 61: -56.0 dB +// - 60: -54.0 dB +// - 59: -53.0 dB +// - 58: -52.0 dB +// - ... +// - 7: -1.0 dB +// - 6: 0.0 dB +// - 5: +1.0 dB +// - ... +// - 2: +4.0 dB +// - 1: +5.0 dB +// - 0: +6.0 dB +// +// When the message is not for signal level operation, it's for MIDI bytes. When matching to +// FF400_MSG_FLAG_IS_MIDI_PORT_0, one MIDI byte can be detected by mask of 0x000000ff. When +// matching to FF400_MSG_FLAG_IS_MIDI_PORT_1, one MIDI byte can be detected by mask of 0x00ff0000. +#define FF400_MSG_FLAG_IS_SIGNAL_LEVEL 0x04000000 +#define FF400_MSG_FLAG_IS_RIGHT_CHANNEL 0x08000000 +#define FF400_MSG_FLAG_IS_STEREO_PAIRED 0x02000000 +#define FF400_MSG_MASK_STEREO_PAIR 0xf0000000 +#define FF400_MSG_MASK_SIGNAL_LEVEL 0x00fffc00 +#define FF400_MSG_FLAG_IS_MIDI_PORT_0 0x00000100 +#define FF400_MSG_MASK_MIDI_PORT_0 0x000000ff +#define FF400_MSG_FLAG_IS_MIDI_PORT_1 0x01000000 +#define FF400_MSG_MASK_MIDI_PORT_1 0x00ff0000 + static void ff400_handle_msg(struct snd_ff *ff, unsigned int offset, const __le32 *buf, size_t length, u32 tstamp) { + bool need_hwdep_wake_up = false; int i; for (i = 0; i < length / 4; i++) { u32 quad = le32_to_cpu(buf[i]); - if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_0) + if (quad & FF400_MSG_FLAG_IS_SIGNAL_LEVEL) { + struct ff400_msg_parser *parser = ff->msg_parser; + + parser->msgs[parser->push_pos].msg = quad; + parser->msgs[parser->push_pos].tstamp = tstamp; + ++parser->push_pos; + if (parser->push_pos >= FF400_QUEUE_SIZE) + parser->push_pos = 0; + + need_hwdep_wake_up = true; + } else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_0) { parse_midi_msg(ff, quad, 0); - else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_1) + } else if (quad & FF400_MSG_FLAG_IS_MIDI_PORT_1) { parse_midi_msg(ff, quad, 1); + } } + + if (need_hwdep_wake_up) + wake_up(&ff->hwdep_wait); +} + +static long ff400_copy_msg_to_user(struct snd_ff *ff, char __user *buf, long count) +{ + struct ff400_msg_parser *parser = ff->msg_parser; + u32 type = SNDRV_FIREWIRE_EVENT_FF400_MESSAGE; + long consumed = 0; + + if (count < 8) + return 0; + + spin_unlock_irq(&ff->lock); + + if (copy_to_user(buf, &type, sizeof(type))) + return -EFAULT; + + spin_lock_irq(&ff->lock); + + count -= sizeof(type); + consumed += sizeof(type); + + while (count >= sizeof(*parser->msgs) && parser->pull_pos != parser->push_pos) { + spin_unlock_irq(&ff->lock); + + if (copy_to_user(buf + consumed, parser->msgs + parser->pull_pos, + sizeof(*parser->msgs))) + return -EFAULT; + + spin_lock_irq(&ff->lock); + ++parser->pull_pos; + if (parser->pull_pos >= FF400_QUEUE_SIZE) + parser->pull_pos = 0; + count -= sizeof(*parser->msgs); + consumed += sizeof(*parser->msgs); + } + + return consumed; } const struct snd_ff_protocol snd_ff_protocol_ff400 = { + .msg_parser_size = sizeof(struct ff400_msg_parser), + .has_msg = ff400_has_msg, + .copy_msg_to_user = ff400_copy_msg_to_user, .handle_msg = ff400_handle_msg, .fill_midi_msg = former_fill_midi_msg, .get_clock = former_get_clock,