From: Clemens Ladisch <clemens@ladisch.de>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>,
tiwai@suse.de, perex@perex.cz
Cc: alsa-devel@alsa-project.org,
linux1394-devel@lists.sourceforge.net,
ffado-devel@lists.sourceforge.net
Subject: Re: [alsa-devel] [PATCH 05/17] firewire-lib: Add support for AMDTP transmit stream and PCM capture
Date: Mon, 25 Nov 2013 16:27:33 +0100 [thread overview]
Message-ID: <52936C65.9020602@ladisch.de> (raw)
In-Reply-To: <1385186884-8259-6-git-send-email-o-takashi@sakamocchi.jp>
Takashi Sakamoto wrote:
> For capturing PCM, this commit adds the functionality to handle transmitted
> stream. This is also applied for dual-wire mode.
> - if (s->dual_wire)
> + if (s->direction == AMDTP_TRANSMIT_STREAM) {
> + if (s->dual_wire)
> + s->transfer_samples = amdtp_read_s16_dualwire;
> + else
> + s->transfer_samples = amdtp_read_s16;
> + } else if (s->dual_wire)
> s->transfer_samples = amdtp_write_s16_dualwire;
> else
> s->transfer_samples = amdtp_write_s16;
It's inconsistent to have braces around the if branch but not around the
else branch.
> +static void amdtp_read_s16(struct amdtp_stream *s,
> + struct snd_pcm_substream *pcm,
> + __be32 *buffer, unsigned int frames)
> +{
> + *dst = be32_to_cpu(buffer[c]) << 8;
>> 8
(also in _dualwire)
It might be a good idea to completely drop S16 support.
> +static void amdtp_read_s32_dualwire(struct amdtp_stream *s,
> + struct snd_pcm_substream *pcm,
> + __be32 *buffer, unsigned int frames)
> +{
> + for (i = 0; i < frames; ++i) {
> + for (c = 0; c < channels; ++c) {
> + *dst =
> + be32_to_cpu(buffer[c]) << 8;
> + dst++;
> + }
> + buffer += 1;
> + for (c = 0; c < channels; ++c) {
> + *dst =
> + be32_to_cpu(buffer[c]) << 8;
> + dst++;
> + }
> + buffer += s->data_block_quadlets - 1;
This is not correct.
If we assume SYT_INTERVAL = 4, two channels at 192 kHz, and MIDI, the
samples L1 R1 L2 R2 L3 R3 ... L8 R8 would be arranged in the data
block's quadlets like four channels at 96 kHz, like this:
L1 L4 R1 R4 L2 L5 R2 R5 L3 L6 R3 R6 L4 L7 R4 R8 MIDI
> +static void handle_in_packet(struct amdtp_stream *s,
> + unsigned int payload_quadlets,
> + __be32 *buffer)
> + if (((cip_header[0] & CIP_EOH_MASK) == CIP_EOH) ||
> + ((cip_header[1] & CIP_EOH_MASK) != CIP_EOH) ||
> + ((cip_header[1] & CIP_FMT_MASK) != CIP_FMT_AM)) {
> + dev_info(&s->unit->device,
> + "Invalid CIP header for AMDTP: %08X:%08X\n",
> + cip_header[0], cip_header[1]);
If some device sends 'wrong' values for all packets, the log will
overflow with these messages. Please use printk_ratelimit().
> + if ((payload_quadlets < 3) ||
> + ((s->flags & CIP_BLOCKING) &&
> + ((cip_header[1] & CIP_SYT_MASK) == CIP_SYT_NO_INFO)))
In the general case, we do not know if the stream is blocking or non-
blocking, so the driver should always be able to handle (=ignore) no-
data packets.
> + data_block_counter = (cip_header[1] & AMDTP_DBC_MASK);
These parentheses are not needed.
> + s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff;
> + if (s->data_block_counter != data_block_counter) {
> + dev_err(&s->unit->device,
> + "Detect uncontinuity of CIP packets\n");
> + s->data_block_counter = data_block_counter;
> + return;
> + }
The correct thing to do would be to insert the missing samples, or to
stop the stream.
Regards,
Clemens
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
next prev parent reply other threads:[~2013-11-25 15:27 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-23 6:07 [RFC][PATCH 00/17] Enhancement for firewire-lib Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 01/17] firewire-lib: Rename functions, structure, member for both direction Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 02/17] firewire-lib: Add macros instead of fixed value for AMDTP Takashi Sakamoto
2013-11-25 15:27 ` Clemens Ladisch
2013-11-26 9:50 ` Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 03/17] firewire-lib: Add 'direction' member to 'amdtp_stream' structure Takashi Sakamoto
2013-11-25 15:27 ` [alsa-devel] " Clemens Ladisch
2013-11-26 10:01 ` Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 04/17] firewire-lib: Split some codes into functions to reuse in future Takashi Sakamoto
2013-11-25 15:27 ` [alsa-devel] " Clemens Ladisch
2013-11-26 10:52 ` Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 05/17] firewire-lib: Add support for AMDTP transmit stream and PCM capture Takashi Sakamoto
2013-11-25 15:27 ` Clemens Ladisch [this message]
2013-11-26 10:50 ` Takashi Sakamoto
2013-11-26 11:17 ` Takashi Sakamoto
2013-12-18 11:57 ` Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 06/17] firewire-lib: Add support for MIDI capture/playback Takashi Sakamoto
2013-11-25 15:27 ` [alsa-devel] " Clemens Ladisch
2013-11-26 12:04 ` Takashi Sakamoto
2013-11-26 13:02 ` Clemens Ladisch
2013-11-26 17:10 ` Takashi Sakamoto
2013-11-26 17:50 ` Clemens Ladisch
2013-11-27 8:33 ` Alan Horstmann
2013-11-27 16:12 ` Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 07/17] firewire-lib: give syt value to handle_out_packet() Takashi Sakamoto
2013-11-25 15:27 ` [alsa-devel] " Clemens Ladisch
2013-11-26 10:59 ` Takashi Sakamoto
2013-12-18 12:29 ` Takashi Sakamoto
2013-12-18 17:26 ` Clemens Ladisch
2013-11-23 6:07 ` [PATCH 08/17] firewire-lib: Add support for duplex streams with synchronization Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 09/17] firewire-lib: Add sort function for transmitted packet Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 10/17] firewire-lib: Add transfer delay to synchronized duplex streams Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 11/17] firewire-lib: Add support for channel mapping Takashi Sakamoto
2013-11-23 6:07 ` [PATCH 12/17] firewire-lib: Rename macros, variables and functions for CMP Takashi Sakamoto
2013-11-23 6:08 ` [PATCH 13/17] firewire-lib: Add 'direction' member to 'cmp_connection' structure Takashi Sakamoto
2013-11-23 6:08 ` [PATCH 14/17] firewire-lib: Add handling output connection by CMP Takashi Sakamoto
2013-11-23 6:08 ` [PATCH 15/17] firewire-lib: Add a new function to check others' connection Takashi Sakamoto
2013-11-23 6:08 ` [PATCH 16/17] firewire-lib: Add some AV/C general commands Takashi Sakamoto
2013-11-23 6:08 ` [PATCH 17/17] firewire-lib: Add quirks for Fireworks chipset Takashi Sakamoto
2013-11-25 3:13 ` Takashi Sakamoto
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=52936C65.9020602@ladisch.de \
--to=clemens@ladisch.de \
--cc=alsa-devel@alsa-project.org \
--cc=ffado-devel@lists.sourceforge.net \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=o-takashi@sakamocchi.jp \
--cc=perex@perex.cz \
--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.