motu-pcm.c (dd49b2d1f04af9b1f44e9fe82c85f374f662c61b) | motu-pcm.c (71c3797779d3cd8378767f5b2d8cfd3b2f88c5c1) |
---|---|
1/* 2 * motu-pcm.c - a part of driver for MOTU FireWire series 3 * 4 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp> 5 * 6 * Licensed under the terms of the GNU General Public License, version 2. 7 */ 8 --- 145 unchanged lines hidden (view full) --- 154static int pcm_open(struct snd_pcm_substream *substream) 155{ 156 struct snd_motu *motu = substream->private_data; 157 const struct snd_motu_protocol *const protocol = motu->spec->protocol; 158 enum snd_motu_clock_source src; 159 unsigned int rate; 160 int err; 161 | 1/* 2 * motu-pcm.c - a part of driver for MOTU FireWire series 3 * 4 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp> 5 * 6 * Licensed under the terms of the GNU General Public License, version 2. 7 */ 8 --- 145 unchanged lines hidden (view full) --- 154static int pcm_open(struct snd_pcm_substream *substream) 155{ 156 struct snd_motu *motu = substream->private_data; 157 const struct snd_motu_protocol *const protocol = motu->spec->protocol; 158 enum snd_motu_clock_source src; 159 unsigned int rate; 160 int err; 161 |
162 err = snd_motu_stream_lock_try(motu); 163 if (err < 0) 164 return err; 165 |
|
162 mutex_lock(&motu->mutex); 163 164 err = protocol->cache_packet_formats(motu); 165 if (err < 0) | 166 mutex_lock(&motu->mutex); 167 168 err = protocol->cache_packet_formats(motu); 169 if (err < 0) |
166 return err; | 170 goto err_locked; |
167 168 err = init_hw_info(motu, substream); 169 if (err < 0) | 171 172 err = init_hw_info(motu, substream); 173 if (err < 0) |
170 return err; | 174 goto err_locked; |
171 172 /* 173 * When source of clock is not internal or any PCM streams are running, 174 * available sampling rate is limited at current sampling rate. 175 */ 176 err = protocol->get_clock_source(motu, &src); 177 if (err < 0) | 175 176 /* 177 * When source of clock is not internal or any PCM streams are running, 178 * available sampling rate is limited at current sampling rate. 179 */ 180 err = protocol->get_clock_source(motu, &src); 181 if (err < 0) |
178 return err; | 182 goto err_locked; |
179 if (src != SND_MOTU_CLOCK_SOURCE_INTERNAL || 180 amdtp_stream_pcm_running(&motu->tx_stream) || 181 amdtp_stream_pcm_running(&motu->rx_stream)) { 182 err = protocol->get_clock_rate(motu, &rate); 183 if (err < 0) | 183 if (src != SND_MOTU_CLOCK_SOURCE_INTERNAL || 184 amdtp_stream_pcm_running(&motu->tx_stream) || 185 amdtp_stream_pcm_running(&motu->rx_stream)) { 186 err = protocol->get_clock_rate(motu, &rate); 187 if (err < 0) |
184 return err; | 188 goto err_locked; |
185 substream->runtime->hw.rate_min = rate; 186 substream->runtime->hw.rate_max = rate; 187 } 188 189 snd_pcm_set_sync(substream); 190 191 mutex_unlock(&motu->mutex); 192 193 return err; | 189 substream->runtime->hw.rate_min = rate; 190 substream->runtime->hw.rate_max = rate; 191 } 192 193 snd_pcm_set_sync(substream); 194 195 mutex_unlock(&motu->mutex); 196 197 return err; |
198err_locked: 199 mutex_unlock(&motu->mutex); 200 snd_motu_stream_lock_release(motu); 201 return err; |
|
194} 195 196static int pcm_close(struct snd_pcm_substream *substream) 197{ | 202} 203 204static int pcm_close(struct snd_pcm_substream *substream) 205{ |
206 struct snd_motu *motu = substream->private_data; 207 208 snd_motu_stream_lock_release(motu); 209 |
|
198 return 0; 199} 200 201static int capture_hw_params(struct snd_pcm_substream *substream, 202 struct snd_pcm_hw_params *hw_params) 203{ 204 struct snd_motu *motu = substream->private_data; 205 int err; --- 181 unchanged lines hidden --- | 210 return 0; 211} 212 213static int capture_hw_params(struct snd_pcm_substream *substream, 214 struct snd_pcm_hw_params *hw_params) 215{ 216 struct snd_motu *motu = substream->private_data; 217 int err; --- 181 unchanged lines hidden --- |