From patchwork Mon Jun 12 08:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 106316 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2433903vqr; Mon, 12 Jun 2023 01:28:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7oQI4n3P5AkAKiV9mrDlvIDoH9N5MpyxgwUHE5PhoHXkKK48wz2/qXEboK84tWQKOOZU2g X-Received: by 2002:a05:6808:144c:b0:39c:7240:b4e4 with SMTP id x12-20020a056808144c00b0039c7240b4e4mr4152894oiv.26.1686558490975; Mon, 12 Jun 2023 01:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686558490; cv=none; d=google.com; s=arc-20160816; b=Rcc4YBA9PxxMcghVZCbwpjRL+jmOsD/96OqHU+s19Qo5qGUMlnqp0w3A/d8QriZQZt 8Fr1ByV9pBdouGDbvpK7JivoZ3a2iN8/fK9/NrTQM4GEOragrN/iXbhKhRHh6wnzEw9W XU/an+zPLEfvBJzicxMsw8FnUHMQ4KQx7ov/STsSzgXJXBHtB+ME730htrejraroSuXk 2yHzr55HpuNLq1BF2E3t/Q/BMYYCP+pK7nj0tFYFeJXqkac82P58DammyzSDnEkWFOdF V5C3TBrrWmUIJQ88tfY6agNeL2GHQMoMjMOGf77n3ZW4yBDvfAfohCVg2BzIJWe8gzFg pvCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=I6KYr/u9celHNicMRls6ca6HBb8F6AOw22BA86mBwCE=; b=l1cGREZ3eXSymZVTssx4Lg3MX68oRhfPdvF6FNvqo5tmP9NZIHlEk+CjagN2b4I3gc +HXYIxjKXS9XGlYZAIdbifwtyH6QTsLQgm0Nvwp9viRM0t44xQM85hjDVUDr00AxqA9k zPI5eNCYfXcIut0+lqlhSECe/Kgh5pp8hN5SUslvizE1mdEerZwo+m4bgmy5gJvw2izE II1ff4yQUoJJzfeYvfWs57u7QhyXGC+yyVk+YUTjUcauz5YMH1ygP4nPWzv0VoP0RnlC HgC510R5oWIVjeeusxD2wJytgGdCyRwLu95Y3drDJibkl1AovdPWh64pG/BibYWrdlVl iB1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CIHSVh8e; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=S0kG8c+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i189-20020a6387c6000000b0054289df2d2csi6615592pge.437.2023.06.12.01.27.58; Mon, 12 Jun 2023 01:28:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CIHSVh8e; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=S0kG8c+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231418AbjFLIMQ (ORCPT + 99 others); Mon, 12 Jun 2023 04:12:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbjFLILz (ORCPT ); Mon, 12 Jun 2023 04:11:55 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3879127 for ; Mon, 12 Jun 2023 01:11:28 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A9E7D2285A; Mon, 12 Jun 2023 08:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686557466; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I6KYr/u9celHNicMRls6ca6HBb8F6AOw22BA86mBwCE=; b=CIHSVh8eZSkkMgg/EriCJCFO5abJAhOwEGYM24ucaA7/QgOBsUke7cPisM+oeg0lzDmXxN 9EMDjU2grtLIbzx2VWBHfxEEpeQ9kru71nV0CjD6dCdtpqCX3RNBp0KN3AZlgy5vlqT9uf 7zxfLDqLroiBPcU+fAgAVPTamHfyTs0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686557466; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I6KYr/u9celHNicMRls6ca6HBb8F6AOw22BA86mBwCE=; b=S0kG8c+MftfduGRlYuAOEIZcg+PFxz+IWxwx5TPoWI1fnkDVbF32kX3JcFavZ3jRWK36zb qRSWQ4vAGEF7dpDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8A82A138EC; Mon, 12 Jun 2023 08:11:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wDdqIBrThmSLcAAAMHmgww (envelope-from ); Mon, 12 Jun 2023 08:11:06 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 05/10] ALSA: seq: ump: Handle groupless messages Date: Mon, 12 Jun 2023 10:10:49 +0200 Message-Id: <20230612081054.17200-6-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230612081054.17200-1-tiwai@suse.de> References: <20230612081054.17200-1-tiwai@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768484755962862708?= X-GMAIL-MSGID: =?utf-8?q?1768484755962862708?= The UMP Utility and Stream messages are "groupless", i.e. an incoming groupless packet should be sent only to the UMP EP port, and the event with the groupless message is sent to UMP EP as is without the group translation per port. Also, the former reserved bit 0 for the client group filter is now used for groupless events. When the bit 0 is set, the groupless events are filtered out and skipped. Signed-off-by: Takashi Iwai --- include/sound/ump.h | 3 +++ include/uapi/sound/asequencer.h | 5 ++++- sound/core/seq/seq_ump_client.c | 5 ++++- sound/core/seq/seq_ump_convert.c | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/sound/ump.h b/include/sound/ump.h index aef4748842d0..5b50a2fc0d79 100644 --- a/include/sound/ump.h +++ b/include/sound/ump.h @@ -255,4 +255,7 @@ static inline u32 ump_stream_compose(unsigned char status, unsigned short form) ((u32)status << 16); } +#define ump_is_groupless_msg(type) \ + ((type) == UMP_MSG_TYPE_UTILITY || (type) == UMP_MSG_TYPE_STREAM) + #endif /* __SOUND_UMP_H */ diff --git a/include/uapi/sound/asequencer.h b/include/uapi/sound/asequencer.h index 5e91243665d8..b5bc8604efe8 100644 --- a/include/uapi/sound/asequencer.h +++ b/include/uapi/sound/asequencer.h @@ -362,7 +362,10 @@ struct snd_seq_client_info { int card; /* RO: card number[kernel] */ int pid; /* RO: pid[user] */ unsigned int midi_version; /* MIDI version */ - unsigned int group_filter; /* UMP group filter bitmap (for 1-based Group indices) */ + unsigned int group_filter; /* UMP group filter bitmap + * (bit 0 = groupless messages, + * bit 1-16 = messages for groups 1-16) + */ char reserved[48]; /* for future use */ }; diff --git a/sound/core/seq/seq_ump_client.c b/sound/core/seq/seq_ump_client.c index e24833804094..7739fb3ebf34 100644 --- a/sound/core/seq/seq_ump_client.c +++ b/sound/core/seq/seq_ump_client.c @@ -73,7 +73,10 @@ static void seq_ump_input_receive(struct snd_ump_endpoint *ump, if (!client->opened[STR_IN]) return; - ev.source.port = ump_group_to_seq_port(ump_message_group(*val)); + if (ump_is_groupless_msg(ump_message_type(*val))) + ev.source.port = 0; /* UMP EP port */ + else + ev.source.port = ump_group_to_seq_port(ump_message_group(*val)); ev.dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS; ev.flags = SNDRV_SEQ_EVENT_UMP; memcpy(ev.ump, val, words << 2); diff --git a/sound/core/seq/seq_ump_convert.c b/sound/core/seq/seq_ump_convert.c index 14ba6fed9dd1..eb1d86ff6166 100644 --- a/sound/core/seq/seq_ump_convert.c +++ b/sound/core/seq/seq_ump_convert.c @@ -534,6 +534,8 @@ static bool ump_event_filtered(struct snd_seq_client *dest, unsigned char group; group = ump_message_group(ev->ump[0]); + if (ump_is_groupless_msg(ump_message_type(ev->ump[0]))) + return dest->group_filter & (1U << 0); /* check the bitmap for 1-based group number */ return dest->group_filter & (1U << (group + 1)); } @@ -565,6 +567,7 @@ int snd_seq_deliver_from_ump(struct snd_seq_client *source, event, atomic, hop); /* non-EP port and different group is set? */ if (dest_port->ump_group && + !ump_is_groupless_msg(type) && ump_message_group(*ump_ev->ump) + 1 != dest_port->ump_group) return deliver_with_group_convert(dest, dest_port, ump_ev, atomic, hop);