ALSA: firewire-lib: move PCM substream constraint to AM824 layer
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 19 Sep 2015 02:21:57 +0000 (11:21 +0900)
committerTakashi Iwai <tiwai@suse.de>
Tue, 29 Sep 2015 10:48:19 +0000 (12:48 +0200)
In IEC 61883-6, PCM frames are transferred in Multi Bit Linear Audio data
channel. The data channel transfers 16/20/24 bit PCM samples. Thus, PCM
substream has a constrain about it.

This commit moves codes related to the constraint from packet streaming
layer to AM824 data block processing layer.

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/amdtp-stream.c
sound/firewire/bebob/bebob_pcm.c
sound/firewire/dice/dice-pcm.c
sound/firewire/fireworks/fireworks_pcm.c
sound/firewire/oxfw/oxfw-pcm.c

index f5edcbfa315788d0eae7a8cb5b32d5a37b88056d..7adaba3565794990e76dedaf3d60a693f17fd7ea 100644 (file)
@@ -52,6 +52,26 @@ int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
 }
 EXPORT_SYMBOL_GPL(amdtp_am824_set_parameters);
 
+/**
+ * amdtp_am824_add_pcm_hw_constraints - add hw constraints for PCM substream
+ * @s:         the AMDTP stream for AM824 data block, must be initialized.
+ * @runtime:   the PCM substream runtime
+ *
+ */
+int amdtp_am824_add_pcm_hw_constraints(struct amdtp_stream *s,
+                                      struct snd_pcm_runtime *runtime)
+{
+       int err;
+
+       err = amdtp_stream_add_pcm_hw_constraints(s, runtime);
+       if (err < 0)
+               return err;
+
+       /* AM824 in IEC 61883-6 can deliver 24bit data. */
+       return snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
+}
+EXPORT_SYMBOL_GPL(amdtp_am824_add_pcm_hw_constraints);
+
 /**
  * amdtp_am824_init - initialize an AMDTP stream structure to handle AM824
  *                   data block
index cfc0d61e0db40da10f4752a8af89b6b7030a07b7..4aaed9048d82199bebef15d65c1f2a455d4517ea 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef SOUND_FIREWIRE_AMDTP_AM824_H_INCLUDED
 #define SOUND_FIREWIRE_AMDTP_AM824_H_INCLUDED
 
+#include <sound/pcm.h>
+
 #include "amdtp-stream.h"
 
 int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
@@ -8,6 +10,9 @@ int amdtp_am824_set_parameters(struct amdtp_stream *s, unsigned int rate,
                               unsigned int midi_ports,
                               bool double_pcm_frames);
 
+int amdtp_am824_add_pcm_hw_constraints(struct amdtp_stream *s,
+                                      struct snd_pcm_runtime *runtime);
+
 int amdtp_am824_init(struct amdtp_stream *s, struct fw_unit *unit,
                     enum amdtp_stream_direction dir, enum cip_flags flags);
 #endif
index 53d84e9bf24194fc6fae68b7f4b8854f24883656..def4fb4b1cce84d2374050a6664bc36710ec4f88 100644 (file)
@@ -140,11 +140,6 @@ int amdtp_stream_add_pcm_hw_constraints(struct amdtp_stream *s,
 {
        int err;
 
-       /* AM824 in IEC 61883-6 can deliver 24bit data */
-       err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
-       if (err < 0)
-               goto end;
-
        /*
         * Currently firewire-lib processes 16 packets in one software
         * interrupt callback. This equals to 2msec but actually the
index c0f018a61fdc039b0e331a40d9bed4e305645320..50610ca4b4805df8447ab19854175d3ba46e83c3 100644 (file)
@@ -146,7 +146,7 @@ pcm_init_hw_params(struct snd_bebob *bebob,
        if (err < 0)
                goto end;
 
-       err = amdtp_stream_add_pcm_hw_constraints(s, runtime);
+       err = amdtp_am824_add_pcm_hw_constraints(s, runtime);
 end:
        return err;
 }
index 4e67b1da0fe6ffbe9350b0e17a71a87f2b03e73b..f5f30079311f60760558297047d052fb0766f678 100644 (file)
@@ -156,7 +156,7 @@ static int init_hw_info(struct snd_dice *dice,
        if (err < 0)
                goto end;
 
-       err = amdtp_stream_add_pcm_hw_constraints(stream, runtime);
+       err = amdtp_am824_add_pcm_hw_constraints(stream, runtime);
 end:
        return err;
 }
index c30b2ffa8dfb1db8354c25b4681938ac82627194..f186ab70f429792372648b0ce34e4c45287b21b3 100644 (file)
@@ -187,7 +187,7 @@ pcm_init_hw_params(struct snd_efw *efw,
        if (err < 0)
                goto end;
 
-       err = amdtp_stream_add_pcm_hw_constraints(s, runtime);
+       err = amdtp_am824_add_pcm_hw_constraints(s, runtime);
 end:
        return err;
 }
index 9c73930d0278820a11fd46a2db2fb877b6a61a88..bddd28743a653a2aa6e9853d22049e4870943c8a 100644 (file)
@@ -158,7 +158,7 @@ static int init_hw_params(struct snd_oxfw *oxfw,
        if (err < 0)
                goto end;
 
-       err = amdtp_stream_add_pcm_hw_constraints(stream, runtime);
+       err = amdtp_am824_add_pcm_hw_constraints(stream, runtime);
 end:
        return err;
 }