ALSA: firewire-lib: add helper functions to set positions of data channels
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 19 Sep 2015 02:21:58 +0000 (11:21 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 29 Sep 2015 10:48:36 +0000 (12:48 +0200)
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>
sound/firewire/amdtp-am824.c
sound/firewire/amdtp-am824.h
sound/firewire/bebob/bebob_stream.c
sound/firewire/dice/dice-stream.c

index 7adaba3565794990e76dedaf3d60a693f17fd7ea..5d99a9921d5011e82a77ec0be1a7b704975ed113 100644 (file)
@@ -52,6 +52,34 @@ int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
 }
 EXPORT_SYMBOL_GPL(amdtp_am824_set_parameters);
 
+/**
+ * amdtp_am824_set_pcm_position - set an index of data channel for a channel
+ *                               of PCM frame
+ * @s: the AMDTP stream
+ * @index: the index of data channel in an data block
+ * @position: the channel of PCM frame
+ */
+void amdtp_am824_set_pcm_position(struct amdtp_stream *s, unsigned int index,
+                                unsigned int position)
+{
+       if (index < s->pcm_channels)
+               s->pcm_positions[index] = position;
+}
+EXPORT_SYMBOL_GPL(amdtp_am824_set_pcm_position);
+
+/**
+ * amdtp_am824_set_midi_position - set a index of data channel for MIDI
+ *                                conformant data channel
+ * @s: the AMDTP stream
+ * @position: the index of data channel in an data block
+ */
+void amdtp_am824_set_midi_position(struct amdtp_stream *s,
+                                  unsigned int position)
+{
+       s->midi_position = position;
+}
+EXPORT_SYMBOL_GPL(amdtp_am824_set_midi_position);
+
 /**
  * amdtp_am824_add_pcm_hw_constraints - add hw constraints for PCM substream
  * @s:         the AMDTP stream for AM824 data block, must be initialized.
index 4aaed9048d82199bebef15d65c1f2a455d4517ea..7c21e9972fad1bc3998e6e5dbe42a5e340944775 100644 (file)
@@ -10,6 +10,12 @@ int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
                               unsigned int midi_ports,
                               bool double_pcm_frames);
 
+void amdtp_am824_set_pcm_position(struct amdtp_stream *s, unsigned int index,
+                                unsigned int position);
+
+void amdtp_am824_set_midi_position(struct amdtp_stream *s,
+                                  unsigned int position);
+
 int amdtp_am824_add_pcm_hw_constraints(struct amdtp_stream *s,
                                       struct snd_pcm_runtime *runtime);
 
index fa510f30cf8f1645fb71ada341210a1537531e50..cf6402d371e7737b6a06f17b623faf08c8bd9231 100644 (file)
@@ -338,7 +338,7 @@ map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
                                        err = -ENOSYS;
                                        goto end;
                                }
-                               s->midi_position = stm_pos;
+                               amdtp_am824_set_midi_position(s, stm_pos);
                                midi = stm_pos;
                                break;
                        /* for PCM data channel */
@@ -358,7 +358,8 @@ map_data_channels(struct snd_bebob *bebob, struct amdtp_stream *s)
                                        err = -ENOSYS;
                                        goto end;
                                }
-                               s->pcm_positions[location] = stm_pos;
+                               amdtp_am824_set_pcm_position(s, location,
+                                                            stm_pos);
                                break;
                        }
                }
index 89483818785e97200621fe6d5e8e7d3d8bfae47c..2108f7f1a7642f4fc19be6d3f9423aa282a01eb5 100644 (file)
@@ -141,8 +141,9 @@ static int start_stream(struct snd_dice *dice, struct amdtp_stream *stream,
                pcm_chs /= 2;
 
                for (i = 0; i < pcm_chs; i++) {
-                       stream->pcm_positions[i] = i * 2;
-                       stream->pcm_positions[i + pcm_chs] = i * 2 + 1;
+                       amdtp_am824_set_pcm_position(stream, i, i * 2);
+                       amdtp_am824_set_pcm_position(stream, i + pcm_chs,
+                                                    i * 2 + 1);
                }
        }