From patchwork Sat May 20 07:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13249115 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 A9F0CC77B7F for ; Sat, 20 May 2023 07:04:31 +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 BEDEC741; Sat, 20 May 2023 09:03:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BEDEC741 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1684566269; bh=7g5lgg8K6ULr4rCfFJMUM9g1W70gZv1L9Jtq0z+f3xA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=k9dMiiaxvTyTzD81fMFhamGRzcQ2ni7IsLMnCOln/mceAJyiNciabaxCVi2WSKabg Bp1+E8girlqZSZBshnWlVlpy7MNbIprpUFfXyNItivoPrX6gH+P3gKuzo6hzadUKwH MMED9FtiT6+WmW7rXHLeb7kLYg8ULQTeB7FG030E= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A406AF80544; Sat, 20 May 2023 09:02:39 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6154BF802E8; Sat, 20 May 2023 09:02:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B9112F80549; Sat, 20 May 2023 09:00:40 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3E5AEF8025A for ; Sat, 20 May 2023 09:00:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3E5AEF8025A Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=vUIpOhkx; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=XGeiQVvq 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-out2.suse.de (Postfix) with ESMTPS id AEA511FD6C; Sat, 20 May 2023 07:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684566025; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1GqwfBOie39jVzprd95QeelYmlNjzR/oK6v665L/0rc=; b=vUIpOhkxGWV6O7mdocsZJRzaYywGwPSMjwpAb+B50Hjv6nnealdEVOeVXgG8SePJmH55uE wzzC73dESrsCcxdfBeetiIlFokSZMC51RzZtoXP45wTUTrkla+Ywk/pRIbV0TIMu1gZp3s 4RSKrHPrYlGwQibsQTTxN0MEZ9jHl0Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684566025; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1GqwfBOie39jVzprd95QeelYmlNjzR/oK6v665L/0rc=; b=XGeiQVvqg+lo4Cvkwd68SMuCSviTo+WyK0b7n09d3PVdf+qdOfbCBbXpBanquMZAHGQSRC FtxHXOZ5h+FjLiDw== 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 8A09E134F5; Sat, 20 May 2023 07:00:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CPLGIAlwaGTwGwAAMHmgww (envelope-from ); Sat, 20 May 2023 07:00:25 +0000 From: Takashi Iwai To: alsa-devel@alsa-project.org Subject: [PATCH alsa-lib 2/8] rawmidi: Add UMP ioctl support Date: Sat, 20 May 2023 09:00:15 +0200 Message-Id: <20230520070021.1301-3-tiwai@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230520070021.1301-1-tiwai@suse.de> References: <20230520070021.1301-1-tiwai@suse.de> MIME-Version: 1.0 Message-ID-Hash: UXCKXHWFUM4IY5LEZRA47NWV33RO6IGC X-Message-ID-Hash: UXCKXHWFUM4IY5LEZRA47NWV33RO6IGC X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Just implement internal callbacks for two new ioctls for UMP (ump_endpoint_info and ump_block_info). No public API functions are added yet here. Signed-off-by: Takashi Iwai --- src/rawmidi/rawmidi.c | 19 +++++++++++++++++++ src/rawmidi/rawmidi_hw.c | 26 +++++++++++++++++++++++++- src/rawmidi/rawmidi_local.h | 5 +++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c index 570e06755456..8dca9312c6d9 100644 --- a/src/rawmidi/rawmidi.c +++ b/src/rawmidi/rawmidi.c @@ -1120,3 +1120,22 @@ ssize_t snd_rawmidi_tread(snd_rawmidi_t *rawmidi, struct timespec *tstamp, void return -ENOTSUP; return (rawmidi->ops->tread)(rawmidi, tstamp, buffer, size); } + +#ifndef DOXYGEN +/* + * internal API functions for obtaining UMP info from rawmidi instance + */ +int _snd_rawmidi_ump_endpoint_info(snd_rawmidi_t *rmidi, void *info) +{ + if (!rmidi->ops->ump_endpoint_info) + return -ENXIO; + return rmidi->ops->ump_endpoint_info(rmidi, info); +} + +int _snd_rawmidi_ump_block_info(snd_rawmidi_t *rmidi, void *info) +{ + if (!rmidi->ops->ump_block_info) + return -ENXIO; + return rmidi->ops->ump_block_info(rmidi, info); +} +#endif /* DOXYGEN */ diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c index e5bb3ee3b31c..69e5e02f1d6a 100644 --- a/src/rawmidi/rawmidi_hw.c +++ b/src/rawmidi/rawmidi_hw.c @@ -272,6 +272,28 @@ static ssize_t snd_rawmidi_hw_tread(snd_rawmidi_t *rmidi, struct timespec *tstam return ret + result; } +static int snd_rawmidi_hw_ump_endpoint_info(snd_rawmidi_t *rmidi, void *buf) +{ + snd_rawmidi_hw_t *hw = rmidi->private_data; + + if (rmidi->version < SNDRV_PROTOCOL_VERSION(2, 0, 3)) + return -ENXIO; + if (ioctl(hw->fd, SNDRV_UMP_IOCTL_ENDPOINT_INFO, buf) < 0) + return -errno; + return 0; +} + +static int snd_rawmidi_hw_ump_block_info(snd_rawmidi_t *rmidi, void *buf) +{ + snd_rawmidi_hw_t *hw = rmidi->private_data; + + if (rmidi->version < SNDRV_PROTOCOL_VERSION(2, 0, 3)) + return -ENXIO; + if (ioctl(hw->fd, SNDRV_UMP_IOCTL_BLOCK_INFO, buf) < 0) + return -errno; + return 0; +} + static const snd_rawmidi_ops_t snd_rawmidi_hw_ops = { .close = snd_rawmidi_hw_close, .nonblock = snd_rawmidi_hw_nonblock, @@ -282,7 +304,9 @@ static const snd_rawmidi_ops_t snd_rawmidi_hw_ops = { .drain = snd_rawmidi_hw_drain, .write = snd_rawmidi_hw_write, .read = snd_rawmidi_hw_read, - .tread = snd_rawmidi_hw_tread + .tread = snd_rawmidi_hw_tread, + .ump_endpoint_info = snd_rawmidi_hw_ump_endpoint_info, + .ump_block_info = snd_rawmidi_hw_ump_block_info, }; diff --git a/src/rawmidi/rawmidi_local.h b/src/rawmidi/rawmidi_local.h index 4a88e7e4a5ba..7025542f6774 100644 --- a/src/rawmidi/rawmidi_local.h +++ b/src/rawmidi/rawmidi_local.h @@ -35,6 +35,8 @@ typedef struct { ssize_t (*write)(snd_rawmidi_t *rawmidi, const void *buffer, size_t size); ssize_t (*read)(snd_rawmidi_t *rawmidi, void *buffer, size_t size); ssize_t (*tread)(snd_rawmidi_t *rawmidi, struct timespec *tstamp, void *buffer, size_t size); + int (*ump_endpoint_info)(snd_rawmidi_t *rmidi, void *buf); + int (*ump_block_info)(snd_rawmidi_t *rmidi, void *buf); } snd_rawmidi_ops_t; struct _snd_rawmidi { @@ -62,3 +64,6 @@ int snd_rawmidi_virtual_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp, int merge, int mode); #define snd_rawmidi_conf_generic_id(id) _snd_conf_generic_id(id) + +int _snd_rawmidi_ump_endpoint_info(snd_rawmidi_t *rmidi, void *info); +int _snd_rawmidi_ump_block_info(snd_rawmidi_t *rmidi, void *info);