aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2015-09-18 22:21:58 -0400
committerTakashi Iwai <tiwai@suse.de>2015-09-29 06:48:36 -0400
commitf65be911c0e13fab28919e17c9fa00c38dc4ff2f (patch)
treec525b5eea0fe8faf62e811d9fb4aa4e5147ae18f
parentbc8500da3e62cd6a896407a1b330a2eb21817c22 (diff)
ALSA: firewire-lib: add helper functions to set positions of data channels
In IEC 61883-6, several types of data are available in AM824 format. The data is transferred in each data channel. The position of data channel in data block differs depending on model. Current implementation has an array to map the index of data channel in an data block to the position of actual data channel. The implementation allows each driver to access the mapping directly. In later commit, the mapping is in specific structure pushed into an opaque pointer. Helper functions are required. This commit adds the helper functions for this purpose. In IEC 61883-6, AM824 format supports many data types, while this specification easily causes over-engineering. Current AM824 implementation is allowed to handle two types of data, Multi Bit Linear Audio data (=PCM samples) and MIDI conformant data (=MIDI messages). Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/amdtp-am824.c28
-rw-r--r--sound/firewire/amdtp-am824.h6
-rw-r--r--sound/firewire/bebob/bebob_stream.c5
-rw-r--r--sound/firewire/dice/dice-stream.c5
4 files changed, 40 insertions, 4 deletions
diff --git a/sound/firewire/amdtp-am824.c b/sound/firewire/amdtp-am824.c
index 7adaba356579..5d99a9921d50 100644
--- a/sound/firewire/amdtp-am824.c
+++ b/sound/firewire/amdtp-am824.c
@@ -53,6 +53,34 @@ int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
53EXPORT_SYMBOL_GPL(amdtp_am824_set_parameters); 53EXPORT_SYMBOL_GPL(amdtp_am824_set_parameters);
54 54
55/** 55/**
56 * amdtp_am824_set_pcm_position - set an index of data channel for a channel
57 * of PCM frame
58 * @s: the AMDTP stream
59 * @index: the index of data channel in an data block
60 * @position: the channel of PCM frame
61 */
62void amdtp_am824_set_pcm_position(struct amdtp_stream *s, unsigned int index,
63 unsigned int position)
64{
65 if (index < s->pcm_channels)
66 s->pcm_positions[index] = position;
67}
68EXPORT_SYMBOL_GPL(amdtp_am824_set_pcm_position);
69
70/**
71 * amdtp_am824_set_midi_position - set a index of data channel for MIDI
72 * conformant data channel
73 * @s: the AMDTP stream
74 * @position: the index of data channel in an data block
75 */
76void amdtp_am824_set_midi_position(struct amdtp_stream *s,
77 unsigned int position)
78{
79 s->midi_position = position;
80}
81EXPORT_SYMBOL_GPL(amdtp_am824_set_midi_position);
82
83/**
56 * amdtp_am824_add_pcm_hw_constraints - add hw constraints for PCM substream 84 * amdtp_am824_add_pcm_hw_constraints - add hw constraints for PCM substream
57 * @s: the AMDTP stream for AM824 data block, must be initialized. 85 * @s: the AMDTP stream for AM824 data block, must be initialized.
58 * @runtime: the PCM substream runtime 86 * @runtime: the PCM substream runtime
diff --git a/sound/firewire/amdtp-am824.h b/sound/firewire/amdtp-am824.h
index 4aaed9048d82..7c21e9972fad 100644
--- a/sound/firewire/amdtp-am824.h
+++ b/sound/firewire/amdtp-am824.h
@@ -10,6 +10,12 @@ int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
10 unsigned int midi_ports, 10 unsigned int midi_ports,
11 bool double_pcm_frames); 11 bool double_pcm_frames);
12 12
13void amdtp_am824_set_pcm_position(struct amdtp_stream *s, unsigned int index,
14 unsigned int position);
15
16void amdtp_am824_set_midi_position(struct amdtp_stream *s,
17 unsigned int position);
18
13int amdtp_am824_add_pcm_hw_constraints(struct amdtp_stream *s, 19int amdtp_am824_add_pcm_hw_constraints(struct amdtp_stream *s,
14 struct snd_pcm_runtime *runtime); 20 struct snd_pcm_runtime *runtime);
15 21
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index fa510f30cf8f..cf6402d371e7 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -338,7 +338,7 @@ map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
338 err = -ENOSYS; 338 err = -ENOSYS;
339 goto end; 339 goto end;
340 } 340 }
341 s->midi_position = stm_pos; 341 amdtp_am824_set_midi_position(s, stm_pos);
342 midi = stm_pos; 342 midi = stm_pos;
343 break; 343 break;
344 /* for PCM data channel */ 344 /* for PCM data channel */
@@ -358,7 +358,8 @@ map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
358 err = -ENOSYS; 358 err = -ENOSYS;
359 goto end; 359 goto end;
360 } 360 }
361 s->pcm_positions[location] = stm_pos; 361 amdtp_am824_set_pcm_position(s, location,
362 stm_pos);
362 break; 363 break;
363 } 364 }
364 } 365 }
diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c
index 89483818785e..2108f7f1a764 100644
--- a/sound/firewire/dice/dice-stream.c
+++ b/sound/firewire/dice/dice-stream.c
@@ -141,8 +141,9 @@ static int start_stream(struct snd_dice *dice, struct amdtp_stream *stream,
141 pcm_chs /= 2; 141 pcm_chs /= 2;
142 142
143 for (i = 0; i < pcm_chs; i++) { 143 for (i = 0; i < pcm_chs; i++) {
144 stream->pcm_positions[i] = i * 2; 144 amdtp_am824_set_pcm_position(stream, i, i * 2);
145 stream->pcm_positions[i + pcm_chs] = i * 2 + 1; 145 amdtp_am824_set_pcm_position(stream, i + pcm_chs,
146 i * 2 + 1);
146 } 147 }
147 } 148 }
148 149