From patchwork Fri May 19 09:30:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 96323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1104237vqo; Fri, 19 May 2023 02:39:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4P0ehm7/RPcwm5+w6S51ilvuOF/9nOPZASSnycAFclylLRIIRVD4vs6CyHkVln2Rmlb2k4 X-Received: by 2002:a17:902:f809:b0:1ab:11c8:777a with SMTP id ix9-20020a170902f80900b001ab11c8777amr1831405plb.13.1684489184709; Fri, 19 May 2023 02:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684489184; cv=none; d=google.com; s=arc-20160816; b=fRw2Li8MC+8hxJ4AO0X/YI5AsUQopgojDzaLrfdmTt05OEYraJl9uKQMpTmLsZWuJe wclyInOvgvUQbqOvAUqFassWAYDpfpP1wQZnz61O8oIB3Nzw39TZ2HsHIQUN57EsEGJ/ roO5mUSnv1R6YBN8I5x4ch9ZuPjH6Bh5r9AWTYZsqurkULOFrlfqCOfaB2keWthOEmHK JxhuRTtXxtvrS8QPsBlD6nFzOGYlxwzkh5gmxd8RCPHd2Z0mxTciCh/X6sGSm2vTdbll amIdPFp9BzbBWKHUV7xcCYHOWK1dS9AylC7KEE9hIHQOHLUZORshIDDQxkhCdrnxJXpe 2SeA== 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=dimxiJwwtH3lX8qyHAdRD71WhexQ0+riv3hHhd98nB4=; b=cfxMG01I9juzxhfaPHuVLJRu7z2EoEe5Iz0R4E5ydEwPcLt2uBLT+zN5OixEHXugPi T6EqMuRZ5SD2u9Zrlki+KSmS1MhXFcK7BIkHFNdUbVxwYbqWapdvAK2tZmqJJvFv71uk oUGlWvPPbx/qbzYpINK4I6xDK128TanDBltIVDrlWaWzFALPiQwrIJl1l0X40lpl7CSA EemaopKGPvF599n5L9o4rxIRGHFHncL3bE4eCtNZEdEHDKfbheE8gdkyZOXUE3O4qt7x omm5r8FwrJC+PaXyNvze7f99S7TeD+Q23p2qkjFDoBd9SaWGOulPYtjFSfTZftsLdEzI a4aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vavSz7Dg; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 n4-20020a170903110400b001aaf8bcb03fsi3397226plh.431.2023.05.19.02.39.31; Fri, 19 May 2023 02:39:44 -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=vavSz7Dg; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 S231318AbjESJcV (ORCPT + 99 others); Fri, 19 May 2023 05:32:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbjESJbm (ORCPT ); Fri, 19 May 2023 05:31:42 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 967F3E47 for ; Fri, 19 May 2023 02:31:40 -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 2F5BE222AD; Fri, 19 May 2023 09:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684488699; 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=dimxiJwwtH3lX8qyHAdRD71WhexQ0+riv3hHhd98nB4=; b=vavSz7DgPDBtdH/do9LPB5JxEPPUyZWjMm5xYjkd0AfvZ2v2/2bpVC8ieQOTKwd99jLQBX bdT9J3ph7PpN7FPu+YncrX4VecLspUt7M9Z9x45u9W4mjWodoHvSzykJTbrBSKGbx0x5fh z1QMYzFzLK/9E74OvOdERjr9Ab37SFk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684488699; 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=dimxiJwwtH3lX8qyHAdRD71WhexQ0+riv3hHhd98nB4=; b=OkI7tgbEDRuHGqE/y5K774J9uPkVDuirJJLXSu2CHCTMEIplOJip1WQQyj0rfkCfdk8kie SaV6ibIy6AnESMDQ== 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 0FE8513A12; Fri, 19 May 2023 09:31:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sOcPA/tBZ2RXJAAAMHmgww (envelope-from ); Fri, 19 May 2023 09:31:39 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 15/36] ALSA: usb-audio: Inform inconsistent protocols in GTBs Date: Fri, 19 May 2023 11:30:53 +0200 Message-Id: <20230519093114.28813-16-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230519093114.28813-1-tiwai@suse.de> References: <20230519093114.28813-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,URIBL_BLOCKED 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?1766314931055671690?= X-GMAIL-MSGID: =?utf-8?q?1766314931055671690?= When parsing Group Terminal Blocks, we overwrote the preferred protocol and the protocol capabilities silently from the last parsed GTB. This patch adds the information print indicating the unexpected overrides instead of silent action. Signed-off-by: Takashi Iwai --- sound/usb/midi2.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/sound/usb/midi2.c b/sound/usb/midi2.c index f005de9f9b8a..14f023b4b414 100644 --- a/sound/usb/midi2.c +++ b/sound/usb/midi2.c @@ -581,6 +581,7 @@ static int parse_group_terminal_block(struct snd_usb_midi2_ump *rmidi, const struct usb_ms20_gr_trm_block_descriptor *desc) { struct snd_ump_endpoint *ump = rmidi->ump; + unsigned int protocol, protocol_caps; /* set default protocol */ switch (desc->bMIDIProtocol) { @@ -588,24 +589,40 @@ static int parse_group_terminal_block(struct snd_usb_midi2_ump *rmidi, case USB_MS_MIDI_PROTO_1_0_64_JRTS: case USB_MS_MIDI_PROTO_1_0_128: case USB_MS_MIDI_PROTO_1_0_128_JRTS: - ump->info.protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI1; + protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI1; break; case USB_MS_MIDI_PROTO_2_0: case USB_MS_MIDI_PROTO_2_0_JRTS: - ump->info.protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI2; + protocol = SNDRV_UMP_EP_INFO_PROTO_MIDI2; break; + default: + return 0; } - ump->info.protocol_caps = ump->info.protocol; + if (ump->info.protocol && ump->info.protocol != protocol) + usb_audio_info(rmidi->umidi->chip, + "Overriding preferred MIDI protocol in GTB %d: %x -> %x\n", + rmidi->usb_block_id, ump->info.protocol, + protocol); + ump->info.protocol = protocol; + + protocol_caps = protocol; switch (desc->bMIDIProtocol) { case USB_MS_MIDI_PROTO_1_0_64_JRTS: case USB_MS_MIDI_PROTO_1_0_128_JRTS: case USB_MS_MIDI_PROTO_2_0_JRTS: - ump->info.protocol_caps |= SNDRV_UMP_EP_INFO_PROTO_JRTS_TX | + protocol_caps |= SNDRV_UMP_EP_INFO_PROTO_JRTS_TX | SNDRV_UMP_EP_INFO_PROTO_JRTS_RX; break; } + if (ump->info.protocol_caps && ump->info.protocol_caps != protocol_caps) + usb_audio_info(rmidi->umidi->chip, + "Overriding MIDI protocol caps in GTB %d: %x -> %x\n", + rmidi->usb_block_id, ump->info.protocol_caps, + protocol_caps); + ump->info.protocol_caps = protocol_caps; + return 0; }