aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-12-08 10:10:37 -0500
committerTakashi Iwai <tiwai@suse.de>2014-12-10 04:45:28 -0500
commit8fc01fc0674e3ea7fdd13bd3d138793619227f89 (patch)
tree2098bbdcc0248276ca589c35bd2f8bd1aa929a48 /sound
parent9a02843caefbc370ef6d5895881101f9436f98da (diff)
ALSA: dice: Support for non SYT-Match sampling clock source mode
This commit allows this driver to handle devices with non SYT-Match sampling clock source. When sampling clock source is SYT-Match mode, devices handle 'presentation timestamp' in received packets and generates sampling clock according to the information. In this case, driver is synchronization master and must transfer correct value in SYT field of each packets in outgoing stream, then the outgoing stream is a master stream. On the other hand, non SYT-Match mode, devices do this. So drivers must pick up the value in SYT field of incoming packets and use the value for outgoing stream. Currently firewire-lib module achieve this work. Furthermore, without SYT-Match and internal clock source, the sampling rate should be fixed for the other devices connected to the handled device. This commit add a restriction of sampling rate at this situation. With these implementations, this driver has no need to set clock source. This commit remove set function. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Acked-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/firewire/dice/dice-pcm.c35
-rw-r--r--sound/firewire/dice/dice-stream.c35
-rw-r--r--sound/firewire/dice/dice-transaction.c5
-rw-r--r--sound/firewire/dice/dice.h2
4 files changed, 58 insertions, 19 deletions
diff --git a/sound/firewire/dice/dice-pcm.c b/sound/firewire/dice/dice-pcm.c
index b9ce0264a2d9..062b7a3b7fd0 100644
--- a/sound/firewire/dice/dice-pcm.c
+++ b/sound/firewire/dice/dice-pcm.c
@@ -140,6 +140,8 @@ end:
140static int pcm_open(struct snd_pcm_substream *substream) 140static int pcm_open(struct snd_pcm_substream *substream)
141{ 141{
142 struct snd_dice *dice = substream->private_data; 142 struct snd_dice *dice = substream->private_data;
143 unsigned int source, rate;
144 bool internal;
143 int err; 145 int err;
144 146
145 err = snd_dice_stream_lock_try(dice); 147 err = snd_dice_stream_lock_try(dice);
@@ -149,6 +151,39 @@ static int pcm_open(struct snd_pcm_substream *substream)
149 err = init_hw_info(dice, substream); 151 err = init_hw_info(dice, substream);
150 if (err < 0) 152 if (err < 0)
151 goto err_locked; 153 goto err_locked;
154
155 err = snd_dice_transaction_get_clock_source(dice, &source);
156 if (err < 0)
157 goto err_locked;
158 switch (source) {
159 case CLOCK_SOURCE_AES1:
160 case CLOCK_SOURCE_AES2:
161 case CLOCK_SOURCE_AES3:
162 case CLOCK_SOURCE_AES4:
163 case CLOCK_SOURCE_AES_ANY:
164 case CLOCK_SOURCE_ADAT:
165 case CLOCK_SOURCE_TDIF:
166 case CLOCK_SOURCE_WC:
167 internal = false;
168 break;
169 default:
170 internal = true;
171 break;
172 }
173
174 /*
175 * When source of clock is not internal, available sampling rate is
176 * limited at current sampling rate.
177 */
178 if (!internal) {
179 err = snd_dice_transaction_get_rate(dice, &rate);
180 if (err < 0)
181 goto err_locked;
182 substream->runtime->hw.rate_min = rate;
183 substream->runtime->hw.rate_max = rate;
184 }
185
186 snd_pcm_set_sync(substream);
152end: 187end:
153 return err; 188 return err;
154err_locked: 189err_locked:
diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c
index e60b84d7a0f6..20765a05d294 100644
--- a/sound/firewire/dice/dice-stream.c
+++ b/sound/firewire/dice/dice-stream.c
@@ -161,9 +161,29 @@ end:
161 161
162static int get_sync_mode(struct snd_dice *dice, enum cip_flags *sync_mode) 162static int get_sync_mode(struct snd_dice *dice, enum cip_flags *sync_mode)
163{ 163{
164 /* Currently, clock source is fixed at SYT-Match mode. */ 164 u32 source;
165 *sync_mode = 0; 165 int err;
166 return 0; 166
167 err = snd_dice_transaction_get_clock_source(dice, &source);
168 if (err < 0)
169 goto end;
170
171 switch (source) {
172 /* So-called 'SYT Match' modes, sync_to_syt value of packets received */
173 case CLOCK_SOURCE_ARX4: /* in 4th stream */
174 case CLOCK_SOURCE_ARX3: /* in 3rd stream */
175 case CLOCK_SOURCE_ARX2: /* in 2nd stream */
176 err = -ENOSYS;
177 break;
178 case CLOCK_SOURCE_ARX1: /* in 1st stream, which this driver uses */
179 *sync_mode = 0;
180 break;
181 default:
182 *sync_mode = CIP_SYNC_TO_DEVICE;
183 break;
184 }
185end:
186 return err;
167} 187}
168 188
169int snd_dice_stream_start_duplex(struct snd_dice *dice, unsigned int rate) 189int snd_dice_stream_start_duplex(struct snd_dice *dice, unsigned int rate)
@@ -310,15 +330,6 @@ int snd_dice_stream_init_duplex(struct snd_dice *dice)
310 goto end; 330 goto end;
311 331
312 err = init_stream(dice, &dice->rx_stream); 332 err = init_stream(dice, &dice->rx_stream);
313 if (err < 0)
314 goto end;
315
316 /* Currently, clock source is fixed at SYT-Match mode. */
317 err = snd_dice_transaction_set_clock_source(dice, CLOCK_SOURCE_ARX1);
318 if (err < 0) {
319 destroy_stream(dice, &dice->rx_stream);
320 destroy_stream(dice, &dice->tx_stream);
321 }
322end: 333end:
323 return err; 334 return err;
324} 335}
diff --git a/sound/firewire/dice/dice-transaction.c b/sound/firewire/dice/dice-transaction.c
index 1fe304c0a044..aee746187665 100644
--- a/sound/firewire/dice/dice-transaction.c
+++ b/sound/firewire/dice/dice-transaction.c
@@ -137,11 +137,6 @@ int snd_dice_transaction_get_clock_source(struct snd_dice *dice,
137 137
138 return err; 138 return err;
139} 139}
140int snd_dice_transaction_set_clock_source(struct snd_dice *dice,
141 unsigned int source)
142{
143 return set_clock_info(dice, UINT_MAX, source);
144}
145 140
146int snd_dice_transaction_get_rate(struct snd_dice *dice, unsigned int *rate) 141int snd_dice_transaction_get_rate(struct snd_dice *dice, unsigned int *rate)
147{ 142{
diff --git a/sound/firewire/dice/dice.h b/sound/firewire/dice/dice.h
index a62ee22da5cc..f30326e22288 100644
--- a/sound/firewire/dice/dice.h
+++ b/sound/firewire/dice/dice.h
@@ -152,8 +152,6 @@ static inline int snd_dice_transaction_read_sync(struct snd_dice *dice,
152 buf, len); 152 buf, len);
153} 153}
154 154
155int snd_dice_transaction_set_clock_source(struct snd_dice *dice,
156 unsigned int source);
157int snd_dice_transaction_get_clock_source(struct snd_dice *dice, 155int snd_dice_transaction_get_clock_source(struct snd_dice *dice,
158 unsigned int *source); 156 unsigned int *source);
159int snd_dice_transaction_set_rate(struct snd_dice *dice, unsigned int rate); 157int snd_dice_transaction_set_rate(struct snd_dice *dice, unsigned int rate);