All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sourceforge.net
Subject: [PATCH v3 11/13] ALSA: dice: use stream formats to add MIDI substreams
Date: Wed,  2 May 2018 19:16:49 +0900	[thread overview]
Message-ID: <20180502101651.26173-12-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20180502101651.26173-1-o-takashi@sakamocchi.jp>

In former commits, proxy structure gets members for cache of stream
formats. The cache can be used to count the number of MIDI substreams
to add.

This commit uses the cache for this purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/dice/dice-midi.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/sound/firewire/dice/dice-midi.c b/sound/firewire/dice/dice-midi.c
index 8ff6da3c51f7..84eca8a51a02 100644
--- a/sound/firewire/dice/dice-midi.c
+++ b/sound/firewire/dice/dice-midi.c
@@ -101,27 +101,18 @@ int snd_dice_create_midi(struct snd_dice *dice)
 		.close		= midi_close,
 		.trigger	= midi_playback_trigger,
 	};
-	__be32 reg;
 	struct snd_rawmidi *rmidi;
 	struct snd_rawmidi_str *str;
 	unsigned int midi_in_ports, midi_out_ports;
+	int i;
 	int err;
 
-	/*
-	 * Use the number of MIDI conformant data channel at current sampling
-	 * transfer frequency.
-	 */
-	err = snd_dice_transaction_read_tx(dice, TX_NUMBER_MIDI,
-					   &reg, sizeof(reg));
-	if (err < 0)
-		return err;
-	midi_in_ports = be32_to_cpu(reg);
-
-	err = snd_dice_transaction_read_rx(dice, RX_NUMBER_MIDI,
-					   &reg, sizeof(reg));
-	if (err < 0)
-		return err;
-	midi_out_ports = be32_to_cpu(reg);
+	midi_in_ports = 0;
+	midi_out_ports = 0;
+	for (i = 0; i < MAX_STREAMS; ++i) {
+		midi_in_ports = max(midi_in_ports, dice->tx_midi_ports[i]);
+		midi_out_ports = max(midi_out_ports, dice->rx_midi_ports[i]);
+	}
 
 	if (midi_in_ports + midi_out_ports == 0)
 		return 0;
-- 
2.14.1

  parent reply	other threads:[~2018-05-02 10:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 10:16 [PATCH v3 00/13] ALSA: dice: use cache of stream formats to generate PCM rules/constraints Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 01/13] ALSA: dice: add cache of stream formats Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 02/13] ALSA: dice: add 'firewire' directory for proc nodes Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 03/13] ALSA: dice: add proc node for stream formation Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 04/13] ALSA: dice: cache stream formats at current mode of sampling transmission frequency Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 05/13] ALSA: dice: add parameters of stream formats for models produced by TC Electronic Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 06/13] ALSA: dice: add parameters of stream formats for models produced by Alesis Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 07/13] ALSA: dice: use extended protocol to detect available stream formats Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 08/13] ALSA: dice: use cache of stream format to check running stream Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 09/13] ALSA: dice: add a helper function to restart all of available streams Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 10/13] ALSA: dice: enable to change current sampling transmission frequency Takashi Sakamoto
2018-05-02 10:16 ` Takashi Sakamoto [this message]
2018-05-02 10:16 ` [PATCH v3 12/13] ALSA: dice: use cache for PCM constraints and rules Takashi Sakamoto
2018-05-02 10:16 ` [PATCH v3 13/13] ALSA: dice: remove local frag of force_two_pcms Takashi Sakamoto
2018-05-02 14:05 ` [PATCH v3 00/13] ALSA: dice: use cache of stream formats to generate PCM rules/constraints Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180502101651.26173-12-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sourceforge.net \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.