public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Robin Gareus <robin@gareus.org>
Cc: tiwai@suse.de, damien@zamaudio.com, clemens@ladisch.de,
	alsa-devel@alsa-project.org, ffado-devel@lists.sf.net
Subject: Re: [PATCH 11/11] ALSA: digi00x: apply double-oh-three algorism to multiplex PCM samples
Date: Tue, 17 Mar 2015 01:25:45 +0900	[thread overview]
Message-ID: <55070409.8090107@sakamocchi.jp> (raw)
In-Reply-To: <5506E7EE.6060300@gareus.org>

Hi Robin,

Thanks for your comment. I have a necessity to understand your algorithm
for better implementation.

On Mar 16 2015 23:25, Robin Gareus wrote:
>> +void snd_dg00x_protocol_write_s32(struct amdtp_stream *s,
>> +				  struct snd_pcm_substream *pcm,
>> +				  __be32 *buffer, unsigned int frames)
>> +{
>> +	struct snd_pcm_runtime *runtime = pcm->runtime;
>> +	unsigned int channels, remaining_frames, i, c;
>> +	const u32 *src;
>> +	static struct dot_state state;
> 
> There's no need to declare this as static. The state is per frame.
> 
>> +	channels = s->pcm_channels;
>> +	src = (void *)runtime->dma_area +
>> +			frames_to_bytes(runtime, s->pcm_buffer_pointer);
>> +	remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer;
>> +
>> +	for (i = 0; i < frames; ++i) {
> 
> ..it is zeroed here, anyway:
> 
>> +		dot_state_reset(&state);

Here, I'm consider about the usage of kernel stack. But for this purpose
it may be better to use the stack because it's never nested calls.

>> +		for (c = 0; c < channels; ++c) {
>> +			buffer[s->pcm_positions[c]] =
>> +					cpu_to_be32((*src >> 8) | 0x40000000);
>> +			dot_encode_step(&state, &buffer[s->pcm_positions[c]]);
>> +			src++;
>> +		}
>> +
>> +		buffer += s->data_block_quadlets;
>> +		if (--remaining_frames == 0)
>> +			src = (void *)runtime->dma_area;
>> +	}
>> +}
> 
> 
> In any case, the algorithm to xor-encode the digidesign data is not yet
> 100% correct there. One will need to continue iterating after the last
> channel (feeding zero) until the state->carry (dot_scrt()) is 0x00.
> 
> The current code here only works only correctly for data on the first 4
> chanels (18 [total channels] - 14 [max xor-chain length]).

Hm. Actually, I can hear better sounds in 1/2 ch as long as I aplayback
to the first 4 ch. When 5 or later channels get PCM samples, I can hear
noisy sound in the 1 ch (maybe 2 or more).


This is an sample of CIP packet which Windows driver transmit to Digi
002 Rack, at 96.0 kHz. The first line shows CIP header. One of the other
line shows one data block.

I put 24 bit PCM samples into 7th Multi Bit Linear Audio (MBLA) data
channel (8th data channel). The other channels includes zero samples
except for MIDI conformant data channel (first data channel).

020B0090 9004E400
80000000 40005100 40003F00 40000000 40000000 40000000 40000000 4011C5E4
4000DB00 4000E400 40001C00
80000000 40002300 4000BD00 4000A200 40000E00 40006100 4000FF00 40116AFC
4000F500 40008B00 40007400
80000000 40005C00 40003300 40004D00 4000C200 4000DE00 4000E100 4011DDE1
4000E200 40001E00 40002100
80000000 4000BF00 40000000 40000000 40000000 40000000 40000000 4012DF19
40000000 40000000 40000000
80000000 40000000 40000000 40000000 40000000 40000000 40000000 40146531
4000FB00 40008400 40007C00
80000000 40005300 40003D00 40004200 4000CE00 4000D100 4000EF00 4015B003
40000000 40000000 40000000
80000000 40000000 40000000 40000000 40000000 40000000 40000000 40162CFB
4000B300 4000AD00 40000200
80000000 40006E00 4000F100 40008F00 40000000 40000000 40000000 4015C4F8
4000DC00 4000E300 40001D00
80000000 40002200 4000BE00 4000A100 40000F00 40000000 40000000 4014EC69
40001300 40002D00 4000B200
80000000 4000AE00 40000100 40006F00 40000000 40000000 40000000 40143EE8
40004100 4000CF00 40000000
80000000 40000000 40000000 40000000 40000000 40000000 40000000 401408D0
40006700 4000F900 40008600
80000000 40007A00 40005500 40003B00 40004400 4000CC00 4000D300 4014C0B6
40000000 40000000 40000000
80000000 40000000 40000000 40000000 40000000 40000000 40000000 40146A74
4000F500 40008B00 40007400
80000000 40005C00 40003300 40004D00 4000C200 4000DE00 4000E100 40148837
40007700 40005900 40003600
80000000 40004A00 4000C500 4000DB00 4000E400 40001C00 40002300 401414CA
40002C00 4000B300 4000AD00
80000000 40000200 40006E00 4000F100 40008F00 40000000 40000000 401493B0
40009D00 40009200 40009E00

We can see the data in 7th MBLA data channel influences data in next
data block (data block is represented as 'frame' in driver code). The
pattern is what you discovered. In my understanding, this is the lack of
my implementation.

Do you mean this issue?


Thanks

Takashi Sakamoto

  reply	other threads:[~2015-03-16 16:25 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-15 16:00 [RFC][PATCH 00/11] digi00x: new driver for Digidesign 002/003 family Takashi Sakamoto
2015-03-15 16:00 ` [PATCH 01/11] ALSA: digi00x: add skelton for Digi 002/003 device driver Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 02/11] ALSA: digi00x: add streaming functionality Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 03/11] ALSA: digi00x: add proc node for clock status Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 04/11] ALSA: digi00x: add PCM functionality Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 05/11] ALSA: digi00x: add MIDI functionality Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 06/11] ALSA: digi00x: add hwdep interface Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 07/11] ALSA: digi00x: support unknown asynchronous message Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 08/11] ALSA: digi00x: support MIDI ports for device control Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 09/11] ALSA: firewire-lib: allows to implement external MIDI callback function Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 10/11] digi00x: improve MIDI capture/playback Takashi Sakamoto
2015-03-15 16:01 ` [PATCH 11/11] ALSA: digi00x: apply double-oh-three algorism to multiplex PCM samples Takashi Sakamoto
2015-03-16 11:39   ` Damien Zammit
2015-03-16 13:24     ` Takashi Sakamoto
2015-03-16 14:25   ` Robin Gareus
2015-03-16 16:25     ` Takashi Sakamoto [this message]
2015-03-16 17:13       ` Robin Gareus
2015-03-16 22:47         ` Takashi Sakamoto
2015-03-17 13:37           ` Robin Gareus
2015-03-17 13:49             ` Damien Zammit
2015-03-18  1:06               ` Takashi Sakamoto
2015-03-19  5:18                 ` Damien Zammit
2015-03-19 13:59                 ` Robin Gareus
2015-03-19 22:46                   ` Takashi Sakamoto
2015-03-19 22:51                     ` Takashi Sakamoto
2015-03-20 12:05                     ` firewire mixer interface -- was " Robin Gareus
2015-03-20 13:00                       ` Clemens Ladisch
2015-03-20 13:25                       ` Takashi Sakamoto
2015-03-20 13:35                         ` Takashi Iwai
2015-03-20 13:51                           ` Takashi Sakamoto
2015-03-20 14:13                             ` Takashi Iwai
2015-03-20 14:45                               ` Takashi Sakamoto
2015-03-20 15:01                                 ` Takashi Iwai
2015-03-21  5:59                                   ` Damien Zammit
2015-03-22  2:55                                     ` Takashi Sakamoto
2015-03-22  5:56                                       ` [FFADO-devel] " Jonathan Woithe
2015-03-24  3:15                                       ` Robin Gareus
2015-03-20 13:55                         ` Damien Zammit
2015-03-20 14:07                           ` Clemens Ladisch
2015-03-22  6:11                       ` [FFADO-devel] " Jonathan Woithe

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=55070409.8090107@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=damien@zamaudio.com \
    --cc=ffado-devel@lists.sf.net \
    --cc=robin@gareus.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox