~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/firewire/motu/motu-pcm.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/firewire/motu/motu-pcm.c (Version linux-6.11-rc3) and /sound/firewire/motu/motu-pcm.c (Version linux-4.20.17)


  1 // SPDX-License-Identifier: GPL-2.0-only       << 
  2 /*                                                  1 /*
  3  * motu-pcm.c - a part of driver for MOTU Fire      2  * motu-pcm.c - a part of driver for MOTU FireWire series
  4  *                                                  3  *
  5  * Copyright (c) 2015-2017 Takashi Sakamoto <o      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.
  6  */                                                 7  */
  7                                                     8 
  8 #include <sound/pcm_params.h>                       9 #include <sound/pcm_params.h>
  9 #include "motu.h"                                  10 #include "motu.h"
 10                                                    11 
 11 static int motu_rate_constraint(struct snd_pcm     12 static int motu_rate_constraint(struct snd_pcm_hw_params *params,
 12                                 struct snd_pcm     13                                 struct snd_pcm_hw_rule *rule)
 13 {                                                  14 {
 14         struct snd_motu_packet_format *formats     15         struct snd_motu_packet_format *formats = rule->private;
 15                                                    16 
 16         const struct snd_interval *c =             17         const struct snd_interval *c =
 17                 hw_param_interval_c(params, SN     18                 hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_CHANNELS);
 18         struct snd_interval *r =                   19         struct snd_interval *r =
 19                 hw_param_interval(params, SNDR     20                 hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
 20         struct snd_interval rates = {              21         struct snd_interval rates = {
 21                 .min = UINT_MAX, .max = 0, .in     22                 .min = UINT_MAX, .max = 0, .integer = 1
 22         };                                         23         };
 23         unsigned int i, pcm_channels, rate, mo     24         unsigned int i, pcm_channels, rate, mode;
 24                                                    25 
 25         for (i = 0; i < ARRAY_SIZE(snd_motu_cl     26         for (i = 0; i < ARRAY_SIZE(snd_motu_clock_rates); ++i) {
 26                 rate = snd_motu_clock_rates[i]     27                 rate = snd_motu_clock_rates[i];
 27                 mode = i / 2;                      28                 mode = i / 2;
 28                                                    29 
 29                 pcm_channels = formats->pcm_ch !!  30                 pcm_channels = formats->fixed_part_pcm_chunks[mode] +
                                                   >>  31                                formats->differed_part_pcm_chunks[mode];
 30                 if (!snd_interval_test(c, pcm_     32                 if (!snd_interval_test(c, pcm_channels))
 31                         continue;                  33                         continue;
 32                                                    34 
 33                 rates.min = min(rates.min, rat     35                 rates.min = min(rates.min, rate);
 34                 rates.max = max(rates.max, rat     36                 rates.max = max(rates.max, rate);
 35         }                                          37         }
 36                                                    38 
 37         return snd_interval_refine(r, &rates);     39         return snd_interval_refine(r, &rates);
 38 }                                                  40 }
 39                                                    41 
 40 static int motu_channels_constraint(struct snd     42 static int motu_channels_constraint(struct snd_pcm_hw_params *params,
 41                                     struct snd     43                                     struct snd_pcm_hw_rule *rule)
 42 {                                                  44 {
 43         struct snd_motu_packet_format *formats     45         struct snd_motu_packet_format *formats = rule->private;
 44                                                    46 
 45         const struct snd_interval *r =             47         const struct snd_interval *r =
 46                 hw_param_interval_c(params, SN     48                 hw_param_interval_c(params, SNDRV_PCM_HW_PARAM_RATE);
 47         struct snd_interval *c =                   49         struct snd_interval *c =
 48                 hw_param_interval(params, SNDR     50                 hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
 49         struct snd_interval channels = {           51         struct snd_interval channels = {
 50                 .min = UINT_MAX, .max = 0, .in     52                 .min = UINT_MAX, .max = 0, .integer = 1
 51         };                                         53         };
 52         unsigned int i, pcm_channels, rate, mo     54         unsigned int i, pcm_channels, rate, mode;
 53                                                    55 
 54         for (i = 0; i < ARRAY_SIZE(snd_motu_cl     56         for (i = 0; i < ARRAY_SIZE(snd_motu_clock_rates); ++i) {
 55                 rate = snd_motu_clock_rates[i]     57                 rate = snd_motu_clock_rates[i];
 56                 mode = i / 2;                      58                 mode = i / 2;
 57                                                    59 
 58                 if (!snd_interval_test(r, rate     60                 if (!snd_interval_test(r, rate))
 59                         continue;                  61                         continue;
 60                                                    62 
 61                 pcm_channels = formats->pcm_ch !!  63                 pcm_channels = formats->fixed_part_pcm_chunks[mode] +
                                                   >>  64                                formats->differed_part_pcm_chunks[mode];
 62                 channels.min = min(channels.mi     65                 channels.min = min(channels.min, pcm_channels);
 63                 channels.max = max(channels.ma     66                 channels.max = max(channels.max, pcm_channels);
 64         }                                          67         }
 65                                                    68 
 66         return snd_interval_refine(c, &channel     69         return snd_interval_refine(c, &channels);
 67 }                                                  70 }
 68                                                    71 
 69 static void limit_channels_and_rates(struct sn     72 static void limit_channels_and_rates(struct snd_motu *motu,
 70                                      struct sn     73                                      struct snd_pcm_runtime *runtime,
 71                                      struct sn     74                                      struct snd_motu_packet_format *formats)
 72 {                                                  75 {
 73         struct snd_pcm_hardware *hw = &runtime     76         struct snd_pcm_hardware *hw = &runtime->hw;
 74         unsigned int i, pcm_channels, rate, mo     77         unsigned int i, pcm_channels, rate, mode;
 75                                                    78 
 76         hw->channels_min = UINT_MAX;               79         hw->channels_min = UINT_MAX;
 77         hw->channels_max = 0;                      80         hw->channels_max = 0;
 78                                                    81 
 79         for (i = 0; i < ARRAY_SIZE(snd_motu_cl     82         for (i = 0; i < ARRAY_SIZE(snd_motu_clock_rates); ++i) {
 80                 rate = snd_motu_clock_rates[i]     83                 rate = snd_motu_clock_rates[i];
 81                 mode = i / 2;                      84                 mode = i / 2;
 82                                                    85 
 83                 pcm_channels = formats->pcm_ch !!  86                 pcm_channels = formats->fixed_part_pcm_chunks[mode] +
                                                   >>  87                                formats->differed_part_pcm_chunks[mode];
 84                 if (pcm_channels == 0)             88                 if (pcm_channels == 0)
 85                         continue;                  89                         continue;
 86                                                    90 
 87                 hw->rates |= snd_pcm_rate_to_r     91                 hw->rates |= snd_pcm_rate_to_rate_bit(rate);
 88                 hw->channels_min = min(hw->cha     92                 hw->channels_min = min(hw->channels_min, pcm_channels);
 89                 hw->channels_max = max(hw->cha     93                 hw->channels_max = max(hw->channels_max, pcm_channels);
 90         }                                          94         }
 91                                                    95 
 92         snd_pcm_limit_hw_rates(runtime);           96         snd_pcm_limit_hw_rates(runtime);
 93 }                                                  97 }
 94                                                    98 
 95 static int init_hw_info(struct snd_motu *motu,     99 static int init_hw_info(struct snd_motu *motu,
 96                         struct snd_pcm_substre    100                         struct snd_pcm_substream *substream)
 97 {                                                 101 {
 98         struct snd_pcm_runtime *runtime = subs    102         struct snd_pcm_runtime *runtime = substream->runtime;
 99         struct snd_pcm_hardware *hw = &runtime    103         struct snd_pcm_hardware *hw = &runtime->hw;
100         struct amdtp_stream *stream;              104         struct amdtp_stream *stream;
101         struct snd_motu_packet_format *formats    105         struct snd_motu_packet_format *formats;
102         int err;                                  106         int err;
103                                                   107 
104         if (substream->stream == SNDRV_PCM_STR    108         if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
105                 hw->formats = SNDRV_PCM_FMTBIT    109                 hw->formats = SNDRV_PCM_FMTBIT_S32;
106                 stream = &motu->tx_stream;        110                 stream = &motu->tx_stream;
107                 formats = &motu->tx_packet_for    111                 formats = &motu->tx_packet_formats;
108         } else {                                  112         } else {
109                 hw->formats = SNDRV_PCM_FMTBIT    113                 hw->formats = SNDRV_PCM_FMTBIT_S32;
110                 stream = &motu->rx_stream;        114                 stream = &motu->rx_stream;
111                 formats = &motu->rx_packet_for    115                 formats = &motu->rx_packet_formats;
112         }                                         116         }
113                                                   117 
114         limit_channels_and_rates(motu, runtime    118         limit_channels_and_rates(motu, runtime, formats);
115                                                   119 
116         err = snd_pcm_hw_rule_add(runtime, 0,     120         err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
117                                   motu_rate_co    121                                   motu_rate_constraint, formats,
118                                   SNDRV_PCM_HW    122                                   SNDRV_PCM_HW_PARAM_CHANNELS, -1);
119         if (err < 0)                              123         if (err < 0)
120                 return err;                       124                 return err;
121         err = snd_pcm_hw_rule_add(runtime, 0,     125         err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
122                                   motu_channel    126                                   motu_channels_constraint, formats,
123                                   SNDRV_PCM_HW    127                                   SNDRV_PCM_HW_PARAM_RATE, -1);
124         if (err < 0)                              128         if (err < 0)
125                 return err;                       129                 return err;
126                                                   130 
127         return amdtp_motu_add_pcm_hw_constrain    131         return amdtp_motu_add_pcm_hw_constraints(stream, runtime);
128 }                                                 132 }
129                                                   133 
130 static int pcm_open(struct snd_pcm_substream *    134 static int pcm_open(struct snd_pcm_substream *substream)
131 {                                                 135 {
132         struct snd_motu *motu = substream->pri    136         struct snd_motu *motu = substream->private_data;
133         struct amdtp_domain *d = &motu->domain !! 137         const struct snd_motu_protocol *const protocol = motu->spec->protocol;
134         enum snd_motu_clock_source src;           138         enum snd_motu_clock_source src;
                                                   >> 139         unsigned int rate;
135         int err;                                  140         int err;
136                                                   141 
137         err = snd_motu_stream_lock_try(motu);     142         err = snd_motu_stream_lock_try(motu);
138         if (err < 0)                              143         if (err < 0)
139                 return err;                       144                 return err;
140                                                   145 
141         mutex_lock(&motu->mutex);                 146         mutex_lock(&motu->mutex);
142                                                   147 
143         err = snd_motu_stream_cache_packet_for    148         err = snd_motu_stream_cache_packet_formats(motu);
144         if (err < 0)                              149         if (err < 0)
145                 goto err_locked;                  150                 goto err_locked;
146                                                   151 
147         err = init_hw_info(motu, substream);      152         err = init_hw_info(motu, substream);
148         if (err < 0)                              153         if (err < 0)
149                 goto err_locked;                  154                 goto err_locked;
150                                                   155 
151         err = snd_motu_protocol_get_clock_sour !! 156         /*
                                                   >> 157          * When source of clock is not internal or any PCM streams are running,
                                                   >> 158          * available sampling rate is limited at current sampling rate.
                                                   >> 159          */
                                                   >> 160         err = protocol->get_clock_source(motu, &src);
152         if (err < 0)                              161         if (err < 0)
153                 goto err_locked;                  162                 goto err_locked;
154                                                !! 163         if (src != SND_MOTU_CLOCK_SOURCE_INTERNAL ||
155         // When source of clock is not interna !! 164             amdtp_stream_pcm_running(&motu->tx_stream) ||
156         // transmission of PCM frames, the ava !! 165             amdtp_stream_pcm_running(&motu->rx_stream)) {
157         // at current one.                     !! 166                 err = protocol->get_clock_rate(motu, &rate);
158         if ((src != SND_MOTU_CLOCK_SOURCE_INTE << 
159              src != SND_MOTU_CLOCK_SOURCE_SPH) << 
160             (motu->substreams_counter > 0 && d << 
161                 unsigned int frames_per_period << 
162                 unsigned int frames_per_buffer << 
163                 unsigned int rate;             << 
164                                                << 
165                 err = snd_motu_protocol_get_cl << 
166                 if (err < 0)                      167                 if (err < 0)
167                         goto err_locked;          168                         goto err_locked;
168                                                << 
169                 substream->runtime->hw.rate_mi    169                 substream->runtime->hw.rate_min = rate;
170                 substream->runtime->hw.rate_ma    170                 substream->runtime->hw.rate_max = rate;
171                                                << 
172                 if (frames_per_period > 0) {   << 
173                         err = snd_pcm_hw_const << 
174                                         SNDRV_ << 
175                                         frames << 
176                         if (err < 0)           << 
177                                 goto err_locke << 
178                                                << 
179                         err = snd_pcm_hw_const << 
180                                         SNDRV_ << 
181                                         frames << 
182                         if (err < 0)           << 
183                                 goto err_locke << 
184                 }                              << 
185         }                                         171         }
186                                                   172 
187         snd_pcm_set_sync(substream);              173         snd_pcm_set_sync(substream);
188                                                   174 
189         mutex_unlock(&motu->mutex);               175         mutex_unlock(&motu->mutex);
190                                                   176 
191         return 0;                              !! 177         return err;
192 err_locked:                                       178 err_locked:
193         mutex_unlock(&motu->mutex);               179         mutex_unlock(&motu->mutex);
194         snd_motu_stream_lock_release(motu);       180         snd_motu_stream_lock_release(motu);
195         return err;                               181         return err;
196 }                                                 182 }
197                                                   183 
198 static int pcm_close(struct snd_pcm_substream     184 static int pcm_close(struct snd_pcm_substream *substream)
199 {                                                 185 {
200         struct snd_motu *motu = substream->pri    186         struct snd_motu *motu = substream->private_data;
201                                                   187 
202         snd_motu_stream_lock_release(motu);       188         snd_motu_stream_lock_release(motu);
203                                                   189 
204         return 0;                                 190         return 0;
205 }                                                 191 }
206                                                   192 
207 static int pcm_hw_params(struct snd_pcm_substr !! 193 static int capture_hw_params(struct snd_pcm_substream *substream,
208                          struct snd_pcm_hw_par !! 194                              struct snd_pcm_hw_params *hw_params)
209 {                                                 195 {
210         struct snd_motu *motu = substream->pri    196         struct snd_motu *motu = substream->private_data;
211         int err = 0;                           !! 197         int err;
212                                                   198 
213         if (substream->runtime->state == SNDRV !! 199         err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
214                 unsigned int rate = params_rat !! 200                                                params_buffer_bytes(hw_params));
215                 unsigned int frames_per_period !! 201         if (err < 0)
216                 unsigned int frames_per_buffer !! 202                 return err;
217                                                   203 
                                                   >> 204         if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
218                 mutex_lock(&motu->mutex);         205                 mutex_lock(&motu->mutex);
219                 err = snd_motu_stream_reserve_ !! 206                 motu->capture_substreams++;
220                                         frames << 
221                 if (err >= 0)                  << 
222                         ++motu->substreams_cou << 
223                 mutex_unlock(&motu->mutex);       207                 mutex_unlock(&motu->mutex);
224         }                                         208         }
225                                                   209 
226         return err;                            !! 210         return 0;
                                                   >> 211 }
                                                   >> 212 static int playback_hw_params(struct snd_pcm_substream *substream,
                                                   >> 213                               struct snd_pcm_hw_params *hw_params)
                                                   >> 214 {
                                                   >> 215         struct snd_motu *motu = substream->private_data;
                                                   >> 216         int err;
                                                   >> 217 
                                                   >> 218         err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
                                                   >> 219                                                params_buffer_bytes(hw_params));
                                                   >> 220         if (err < 0)
                                                   >> 221                 return err;
                                                   >> 222 
                                                   >> 223         if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
                                                   >> 224                 mutex_lock(&motu->mutex);
                                                   >> 225                 motu->playback_substreams++;
                                                   >> 226                 mutex_unlock(&motu->mutex);
                                                   >> 227         }
                                                   >> 228 
                                                   >> 229         return 0;
227 }                                                 230 }
228                                                   231 
229 static int pcm_hw_free(struct snd_pcm_substrea !! 232 static int capture_hw_free(struct snd_pcm_substream *substream)
230 {                                                 233 {
231         struct snd_motu *motu = substream->pri    234         struct snd_motu *motu = substream->private_data;
232                                                   235 
233         mutex_lock(&motu->mutex);                 236         mutex_lock(&motu->mutex);
234                                                   237 
235         if (substream->runtime->state != SNDRV !! 238         if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
236                 --motu->substreams_counter;    !! 239                 motu->capture_substreams--;
237                                                   240 
238         snd_motu_stream_stop_duplex(motu);        241         snd_motu_stream_stop_duplex(motu);
239                                                   242 
240         mutex_unlock(&motu->mutex);               243         mutex_unlock(&motu->mutex);
241                                                   244 
242         return 0;                              !! 245         return snd_pcm_lib_free_vmalloc_buffer(substream);
                                                   >> 246 }
                                                   >> 247 
                                                   >> 248 static int playback_hw_free(struct snd_pcm_substream *substream)
                                                   >> 249 {
                                                   >> 250         struct snd_motu *motu = substream->private_data;
                                                   >> 251 
                                                   >> 252         mutex_lock(&motu->mutex);
                                                   >> 253 
                                                   >> 254         if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN)
                                                   >> 255                 motu->playback_substreams--;
                                                   >> 256 
                                                   >> 257         snd_motu_stream_stop_duplex(motu);
                                                   >> 258 
                                                   >> 259         mutex_unlock(&motu->mutex);
                                                   >> 260 
                                                   >> 261         return snd_pcm_lib_free_vmalloc_buffer(substream);
243 }                                                 262 }
244                                                   263 
245 static int capture_prepare(struct snd_pcm_subs    264 static int capture_prepare(struct snd_pcm_substream *substream)
246 {                                                 265 {
247         struct snd_motu *motu = substream->pri    266         struct snd_motu *motu = substream->private_data;
248         int err;                                  267         int err;
249                                                   268 
250         mutex_lock(&motu->mutex);                 269         mutex_lock(&motu->mutex);
251         err = snd_motu_stream_start_duplex(mot !! 270         err = snd_motu_stream_start_duplex(motu, substream->runtime->rate);
252         mutex_unlock(&motu->mutex);               271         mutex_unlock(&motu->mutex);
253         if (err >= 0)                             272         if (err >= 0)
254                 amdtp_stream_pcm_prepare(&motu    273                 amdtp_stream_pcm_prepare(&motu->tx_stream);
255                                                   274 
256         return 0;                                 275         return 0;
257 }                                                 276 }
258 static int playback_prepare(struct snd_pcm_sub    277 static int playback_prepare(struct snd_pcm_substream *substream)
259 {                                                 278 {
260         struct snd_motu *motu = substream->pri    279         struct snd_motu *motu = substream->private_data;
261         int err;                                  280         int err;
262                                                   281 
263         mutex_lock(&motu->mutex);                 282         mutex_lock(&motu->mutex);
264         err = snd_motu_stream_start_duplex(mot !! 283         err = snd_motu_stream_start_duplex(motu, substream->runtime->rate);
265         mutex_unlock(&motu->mutex);               284         mutex_unlock(&motu->mutex);
266         if (err >= 0)                             285         if (err >= 0)
267                 amdtp_stream_pcm_prepare(&motu    286                 amdtp_stream_pcm_prepare(&motu->rx_stream);
268                                                   287 
269         return err;                               288         return err;
270 }                                                 289 }
271                                                   290 
272 static int capture_trigger(struct snd_pcm_subs    291 static int capture_trigger(struct snd_pcm_substream *substream, int cmd)
273 {                                                 292 {
274         struct snd_motu *motu = substream->pri    293         struct snd_motu *motu = substream->private_data;
275                                                   294 
276         switch (cmd) {                            295         switch (cmd) {
277         case SNDRV_PCM_TRIGGER_START:             296         case SNDRV_PCM_TRIGGER_START:
278                 amdtp_stream_pcm_trigger(&motu    297                 amdtp_stream_pcm_trigger(&motu->tx_stream, substream);
279                 break;                            298                 break;
280         case SNDRV_PCM_TRIGGER_STOP:              299         case SNDRV_PCM_TRIGGER_STOP:
281                 amdtp_stream_pcm_trigger(&motu    300                 amdtp_stream_pcm_trigger(&motu->tx_stream, NULL);
282                 break;                            301                 break;
283         default:                                  302         default:
284                 return -EINVAL;                   303                 return -EINVAL;
285         }                                         304         }
286                                                   305 
287         return 0;                                 306         return 0;
288 }                                                 307 }
289 static int playback_trigger(struct snd_pcm_sub    308 static int playback_trigger(struct snd_pcm_substream *substream, int cmd)
290 {                                                 309 {
291         struct snd_motu *motu = substream->pri    310         struct snd_motu *motu = substream->private_data;
292                                                   311 
293         switch (cmd) {                            312         switch (cmd) {
294         case SNDRV_PCM_TRIGGER_START:             313         case SNDRV_PCM_TRIGGER_START:
295                 amdtp_stream_pcm_trigger(&motu    314                 amdtp_stream_pcm_trigger(&motu->rx_stream, substream);
296                 break;                            315                 break;
297         case SNDRV_PCM_TRIGGER_STOP:              316         case SNDRV_PCM_TRIGGER_STOP:
298                 amdtp_stream_pcm_trigger(&motu    317                 amdtp_stream_pcm_trigger(&motu->rx_stream, NULL);
299                 break;                            318                 break;
300         default:                                  319         default:
301                 return -EINVAL;                   320                 return -EINVAL;
302         }                                         321         }
303                                                   322 
304         return 0;                                 323         return 0;
305 }                                                 324 }
306                                                   325 
307 static snd_pcm_uframes_t capture_pointer(struc    326 static snd_pcm_uframes_t capture_pointer(struct snd_pcm_substream *substream)
308 {                                                 327 {
309         struct snd_motu *motu = substream->pri    328         struct snd_motu *motu = substream->private_data;
310                                                   329 
311         return amdtp_domain_stream_pcm_pointer !! 330         return amdtp_stream_pcm_pointer(&motu->tx_stream);
312 }                                                 331 }
313 static snd_pcm_uframes_t playback_pointer(stru    332 static snd_pcm_uframes_t playback_pointer(struct snd_pcm_substream *substream)
314 {                                                 333 {
315         struct snd_motu *motu = substream->pri    334         struct snd_motu *motu = substream->private_data;
316                                                   335 
317         return amdtp_domain_stream_pcm_pointer !! 336         return amdtp_stream_pcm_pointer(&motu->rx_stream);
318 }                                                 337 }
319                                                   338 
320 static int capture_ack(struct snd_pcm_substrea    339 static int capture_ack(struct snd_pcm_substream *substream)
321 {                                                 340 {
322         struct snd_motu *motu = substream->pri    341         struct snd_motu *motu = substream->private_data;
323                                                   342 
324         return amdtp_domain_stream_pcm_ack(&mo !! 343         return amdtp_stream_pcm_ack(&motu->tx_stream);
325 }                                                 344 }
326                                                   345 
327 static int playback_ack(struct snd_pcm_substre    346 static int playback_ack(struct snd_pcm_substream *substream)
328 {                                                 347 {
329         struct snd_motu *motu = substream->pri    348         struct snd_motu *motu = substream->private_data;
330                                                   349 
331         return amdtp_domain_stream_pcm_ack(&mo !! 350         return amdtp_stream_pcm_ack(&motu->rx_stream);
332 }                                                 351 }
333                                                   352 
334 int snd_motu_create_pcm_devices(struct snd_mot    353 int snd_motu_create_pcm_devices(struct snd_motu *motu)
335 {                                                 354 {
336         static const struct snd_pcm_ops captur    355         static const struct snd_pcm_ops capture_ops = {
337                 .open      = pcm_open,            356                 .open      = pcm_open,
338                 .close     = pcm_close,           357                 .close     = pcm_close,
339                 .hw_params = pcm_hw_params,    !! 358                 .ioctl     = snd_pcm_lib_ioctl,
340                 .hw_free   = pcm_hw_free,      !! 359                 .hw_params = capture_hw_params,
                                                   >> 360                 .hw_free   = capture_hw_free,
341                 .prepare   = capture_prepare,     361                 .prepare   = capture_prepare,
342                 .trigger   = capture_trigger,     362                 .trigger   = capture_trigger,
343                 .pointer   = capture_pointer,     363                 .pointer   = capture_pointer,
344                 .ack       = capture_ack,         364                 .ack       = capture_ack,
                                                   >> 365                 .page      = snd_pcm_lib_get_vmalloc_page,
345         };                                        366         };
346         static const struct snd_pcm_ops playba    367         static const struct snd_pcm_ops playback_ops = {
347                 .open      = pcm_open,            368                 .open      = pcm_open,
348                 .close     = pcm_close,           369                 .close     = pcm_close,
349                 .hw_params = pcm_hw_params,    !! 370                 .ioctl     = snd_pcm_lib_ioctl,
350                 .hw_free   = pcm_hw_free,      !! 371                 .hw_params = playback_hw_params,
                                                   >> 372                 .hw_free   = playback_hw_free,
351                 .prepare   = playback_prepare,    373                 .prepare   = playback_prepare,
352                 .trigger   = playback_trigger,    374                 .trigger   = playback_trigger,
353                 .pointer   = playback_pointer,    375                 .pointer   = playback_pointer,
354                 .ack       = playback_ack,        376                 .ack       = playback_ack,
                                                   >> 377                 .page      = snd_pcm_lib_get_vmalloc_page,
355         };                                        378         };
356         struct snd_pcm *pcm;                      379         struct snd_pcm *pcm;
357         int err;                                  380         int err;
358                                                   381 
359         err = snd_pcm_new(motu->card, motu->ca    382         err = snd_pcm_new(motu->card, motu->card->driver, 0, 1, 1, &pcm);
360         if (err < 0)                              383         if (err < 0)
361                 return err;                       384                 return err;
362         pcm->private_data = motu;                 385         pcm->private_data = motu;
363         strcpy(pcm->name, motu->card->shortnam    386         strcpy(pcm->name, motu->card->shortname);
364                                                   387 
365         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_    388         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
366         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_    389         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
367         snd_pcm_set_managed_buffer_all(pcm, SN << 
368                                                   390 
369         return 0;                                 391         return 0;
370 }                                                 392 }
371                                                   393 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php