On Mon, 07 Mar 2016 14:35:43 +0100, Takashi Sakamoto wrote: > > This commit enables ALSA dice driver to handle whole available streams. > > In Dice, certain registers represent the number of available streams at > current sampling transfer frequency for both directions. The parameters > of each stream are represented in a block of register. This block is > aligned sequentially. These streams start simultaneously by writing > enable bit to a register. > > This commit operates these registers when starting/stopping streams. > > Signed-off-by: Takashi Sakamoto <o-takashi@xxxxxxxxxxxxx> > --- > sound/firewire/dice/dice-stream.c | 398 ++++++++++++++++++++++++-------------- > 1 file changed, 255 insertions(+), 143 deletions(-) > > diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c > index 15d581d..2077f18 100644 > --- a/sound/firewire/dice/dice-stream.c > +++ b/sound/firewire/dice/dice-stream.c > @@ -65,85 +65,84 @@ static int ensure_phase_lock(struct snd_dice *dice) > return 0; > } > > -static void release_resources(struct snd_dice *dice, > - struct fw_iso_resources *resources) > +static int get_register_params(struct snd_dice *dice, unsigned int params[4]) > { > - __be32 channel; > - > - /* Reset channel number */ > - channel = cpu_to_be32((u32)-1); > - if (resources == &dice->tx_resources[0]) > - snd_dice_transaction_write_tx(dice, TX_ISOCHRONOUS, > - &channel, sizeof(channel)); > - else > - snd_dice_transaction_write_rx(dice, RX_ISOCHRONOUS, > - &channel, sizeof(channel)); > - > - fw_iso_resources_free(resources); > -} > - > -static int keep_resources(struct snd_dice *dice, > - struct fw_iso_resources *resources, > - unsigned int max_payload_bytes) > -{ > - __be32 channel; > + __be32 reg[2]; > int err; > > - err = fw_iso_resources_allocate(resources, max_payload_bytes, > - fw_parent_device(dice->unit)->max_speed); > + err = snd_dice_transaction_read_tx(dice, TX_NUMBER, reg, sizeof(reg)); > if (err < 0) > - goto end; > + return err; > + params[0] = min_t(unsigned int, be32_to_cpu(reg[0]), MAX_STREAMS); > + params[1] = be32_to_cpu(reg[1]) * 4; > > - /* Set channel number */ > - channel = cpu_to_be32(resources->channel); > - if (resources == &dice->tx_resources[0]) > - err = snd_dice_transaction_write_tx(dice, TX_ISOCHRONOUS, > - &channel, sizeof(channel)); > - else > - err = snd_dice_transaction_write_rx(dice, RX_ISOCHRONOUS, > - &channel, sizeof(channel)); > + err = snd_dice_transaction_read_rx(dice, RX_NUMBER, reg, sizeof(reg)); > if (err < 0) > - release_resources(dice, resources); > -end: > - return err; > + return err; > + params[2] = min_t(unsigned int, be32_to_cpu(reg[0]), MAX_STREAMS); > + params[3] = be32_to_cpu(reg[1]) * 4; These "parameters" are not necessarily an array since each field has a strict definition. A more readable code would be to define a struct instead. thanks, Takashi _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel