diff options
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/caiaq/audio.c | 459 | ||||
-rw-r--r-- | sound/usb/caiaq/audio.h | 4 | ||||
-rw-r--r-- | sound/usb/caiaq/control.c | 67 | ||||
-rw-r--r-- | sound/usb/caiaq/control.h | 2 | ||||
-rw-r--r-- | sound/usb/caiaq/device.c | 248 | ||||
-rw-r--r-- | sound/usb/caiaq/device.h | 18 | ||||
-rw-r--r-- | sound/usb/caiaq/input.c | 328 | ||||
-rw-r--r-- | sound/usb/caiaq/input.h | 6 | ||||
-rw-r--r-- | sound/usb/caiaq/midi.c | 63 | ||||
-rw-r--r-- | sound/usb/caiaq/midi.h | 5 | ||||
-rw-r--r-- | sound/usb/format.c | 20 | ||||
-rw-r--r-- | sound/usb/format.h | 2 | ||||
-rw-r--r-- | sound/usb/pcm.c | 7 | ||||
-rw-r--r-- | sound/usb/quirks-table.h | 43 | ||||
-rw-r--r-- | sound/usb/quirks.c | 21 | ||||
-rw-r--r-- | sound/usb/stream.c | 2 |
16 files changed, 690 insertions, 605 deletions
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index fde9a7a29cb6..67330af21b0e 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/device.h> | ||
19 | #include <linux/spinlock.h> | 20 | #include <linux/spinlock.h> |
20 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
21 | #include <linux/init.h> | 22 | #include <linux/init.h> |
@@ -39,8 +40,8 @@ | |||
39 | #define ENDPOINT_CAPTURE 2 | 40 | #define ENDPOINT_CAPTURE 2 |
40 | #define ENDPOINT_PLAYBACK 6 | 41 | #define ENDPOINT_PLAYBACK 6 |
41 | 42 | ||
42 | #define MAKE_CHECKBYTE(dev,stream,i) \ | 43 | #define MAKE_CHECKBYTE(cdev,stream,i) \ |
43 | (stream << 1) | (~(i / (dev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) | 44 | (stream << 1) | (~(i / (cdev->n_streams * BYTES_PER_SAMPLE_USB)) & 1) |
44 | 45 | ||
45 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { | 46 | static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { |
46 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 47 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
@@ -60,32 +61,32 @@ static struct snd_pcm_hardware snd_usb_caiaq_pcm_hardware = { | |||
60 | }; | 61 | }; |
61 | 62 | ||
62 | static void | 63 | static void |
63 | activate_substream(struct snd_usb_caiaqdev *dev, | 64 | activate_substream(struct snd_usb_caiaqdev *cdev, |
64 | struct snd_pcm_substream *sub) | 65 | struct snd_pcm_substream *sub) |
65 | { | 66 | { |
66 | spin_lock(&dev->spinlock); | 67 | spin_lock(&cdev->spinlock); |
67 | 68 | ||
68 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 69 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
69 | dev->sub_playback[sub->number] = sub; | 70 | cdev->sub_playback[sub->number] = sub; |
70 | else | 71 | else |
71 | dev->sub_capture[sub->number] = sub; | 72 | cdev->sub_capture[sub->number] = sub; |
72 | 73 | ||
73 | spin_unlock(&dev->spinlock); | 74 | spin_unlock(&cdev->spinlock); |
74 | } | 75 | } |
75 | 76 | ||
76 | static void | 77 | static void |
77 | deactivate_substream(struct snd_usb_caiaqdev *dev, | 78 | deactivate_substream(struct snd_usb_caiaqdev *cdev, |
78 | struct snd_pcm_substream *sub) | 79 | struct snd_pcm_substream *sub) |
79 | { | 80 | { |
80 | unsigned long flags; | 81 | unsigned long flags; |
81 | spin_lock_irqsave(&dev->spinlock, flags); | 82 | spin_lock_irqsave(&cdev->spinlock, flags); |
82 | 83 | ||
83 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 84 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
84 | dev->sub_playback[sub->number] = NULL; | 85 | cdev->sub_playback[sub->number] = NULL; |
85 | else | 86 | else |
86 | dev->sub_capture[sub->number] = NULL; | 87 | cdev->sub_capture[sub->number] = NULL; |
87 | 88 | ||
88 | spin_unlock_irqrestore(&dev->spinlock, flags); | 89 | spin_unlock_irqrestore(&cdev->spinlock, flags); |
89 | } | 90 | } |
90 | 91 | ||
91 | static int | 92 | static int |
@@ -98,28 +99,30 @@ all_substreams_zero(struct snd_pcm_substream **subs) | |||
98 | return 1; | 99 | return 1; |
99 | } | 100 | } |
100 | 101 | ||
101 | static int stream_start(struct snd_usb_caiaqdev *dev) | 102 | static int stream_start(struct snd_usb_caiaqdev *cdev) |
102 | { | 103 | { |
103 | int i, ret; | 104 | int i, ret; |
105 | struct device *dev = caiaqdev_to_dev(cdev); | ||
104 | 106 | ||
105 | debug("%s(%p)\n", __func__, dev); | 107 | dev_dbg(dev, "%s(%p)\n", __func__, cdev); |
106 | 108 | ||
107 | if (dev->streaming) | 109 | if (cdev->streaming) |
108 | return -EINVAL; | 110 | return -EINVAL; |
109 | 111 | ||
110 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); | 112 | memset(cdev->sub_playback, 0, sizeof(cdev->sub_playback)); |
111 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); | 113 | memset(cdev->sub_capture, 0, sizeof(cdev->sub_capture)); |
112 | dev->input_panic = 0; | 114 | cdev->input_panic = 0; |
113 | dev->output_panic = 0; | 115 | cdev->output_panic = 0; |
114 | dev->first_packet = 4; | 116 | cdev->first_packet = 4; |
115 | dev->streaming = 1; | 117 | cdev->streaming = 1; |
116 | dev->warned = 0; | 118 | cdev->warned = 0; |
117 | 119 | ||
118 | for (i = 0; i < N_URBS; i++) { | 120 | for (i = 0; i < N_URBS; i++) { |
119 | ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC); | 121 | ret = usb_submit_urb(cdev->data_urbs_in[i], GFP_ATOMIC); |
120 | if (ret) { | 122 | if (ret) { |
121 | log("unable to trigger read #%d! (ret %d)\n", i, ret); | 123 | dev_err(dev, "unable to trigger read #%d! (ret %d)\n", |
122 | dev->streaming = 0; | 124 | i, ret); |
125 | cdev->streaming = 0; | ||
123 | return -EPIPE; | 126 | return -EPIPE; |
124 | } | 127 | } |
125 | } | 128 | } |
@@ -127,46 +130,51 @@ static int stream_start(struct snd_usb_caiaqdev *dev) | |||
127 | return 0; | 130 | return 0; |
128 | } | 131 | } |
129 | 132 | ||
130 | static void stream_stop(struct snd_usb_caiaqdev *dev) | 133 | static void stream_stop(struct snd_usb_caiaqdev *cdev) |
131 | { | 134 | { |
132 | int i; | 135 | int i; |
136 | struct device *dev = caiaqdev_to_dev(cdev); | ||
133 | 137 | ||
134 | debug("%s(%p)\n", __func__, dev); | 138 | dev_dbg(dev, "%s(%p)\n", __func__, cdev); |
135 | if (!dev->streaming) | 139 | if (!cdev->streaming) |
136 | return; | 140 | return; |
137 | 141 | ||
138 | dev->streaming = 0; | 142 | cdev->streaming = 0; |
139 | 143 | ||
140 | for (i = 0; i < N_URBS; i++) { | 144 | for (i = 0; i < N_URBS; i++) { |
141 | usb_kill_urb(dev->data_urbs_in[i]); | 145 | usb_kill_urb(cdev->data_urbs_in[i]); |
142 | 146 | ||
143 | if (test_bit(i, &dev->outurb_active_mask)) | 147 | if (test_bit(i, &cdev->outurb_active_mask)) |
144 | usb_kill_urb(dev->data_urbs_out[i]); | 148 | usb_kill_urb(cdev->data_urbs_out[i]); |
145 | } | 149 | } |
146 | 150 | ||
147 | dev->outurb_active_mask = 0; | 151 | cdev->outurb_active_mask = 0; |
148 | } | 152 | } |
149 | 153 | ||
150 | static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream) | 154 | static int snd_usb_caiaq_substream_open(struct snd_pcm_substream *substream) |
151 | { | 155 | { |
152 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); | 156 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); |
153 | debug("%s(%p)\n", __func__, substream); | 157 | struct device *dev = caiaqdev_to_dev(cdev); |
154 | substream->runtime->hw = dev->pcm_info; | 158 | |
159 | dev_dbg(dev, "%s(%p)\n", __func__, substream); | ||
160 | substream->runtime->hw = cdev->pcm_info; | ||
155 | snd_pcm_limit_hw_rates(substream->runtime); | 161 | snd_pcm_limit_hw_rates(substream->runtime); |
162 | |||
156 | return 0; | 163 | return 0; |
157 | } | 164 | } |
158 | 165 | ||
159 | static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) | 166 | static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) |
160 | { | 167 | { |
161 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); | 168 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); |
169 | struct device *dev = caiaqdev_to_dev(cdev); | ||
162 | 170 | ||
163 | debug("%s(%p)\n", __func__, substream); | 171 | dev_dbg(dev, "%s(%p)\n", __func__, substream); |
164 | if (all_substreams_zero(dev->sub_playback) && | 172 | if (all_substreams_zero(cdev->sub_playback) && |
165 | all_substreams_zero(dev->sub_capture)) { | 173 | all_substreams_zero(cdev->sub_capture)) { |
166 | /* when the last client has stopped streaming, | 174 | /* when the last client has stopped streaming, |
167 | * all sample rates are allowed again */ | 175 | * all sample rates are allowed again */ |
168 | stream_stop(dev); | 176 | stream_stop(cdev); |
169 | dev->pcm_info.rates = dev->samplerates; | 177 | cdev->pcm_info.rates = cdev->samplerates; |
170 | } | 178 | } |
171 | 179 | ||
172 | return 0; | 180 | return 0; |
@@ -175,15 +183,13 @@ static int snd_usb_caiaq_substream_close(struct snd_pcm_substream *substream) | |||
175 | static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, | 183 | static int snd_usb_caiaq_pcm_hw_params(struct snd_pcm_substream *sub, |
176 | struct snd_pcm_hw_params *hw_params) | 184 | struct snd_pcm_hw_params *hw_params) |
177 | { | 185 | { |
178 | debug("%s(%p)\n", __func__, sub); | ||
179 | return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); | 186 | return snd_pcm_lib_malloc_pages(sub, params_buffer_bytes(hw_params)); |
180 | } | 187 | } |
181 | 188 | ||
182 | static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) | 189 | static int snd_usb_caiaq_pcm_hw_free(struct snd_pcm_substream *sub) |
183 | { | 190 | { |
184 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); | 191 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); |
185 | debug("%s(%p)\n", __func__, sub); | 192 | deactivate_substream(cdev, sub); |
186 | deactivate_substream(dev, sub); | ||
187 | return snd_pcm_lib_free_pages(sub); | 193 | return snd_pcm_lib_free_pages(sub); |
188 | } | 194 | } |
189 | 195 | ||
@@ -199,15 +205,16 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
199 | { | 205 | { |
200 | int bytes_per_sample, bpp, ret, i; | 206 | int bytes_per_sample, bpp, ret, i; |
201 | int index = substream->number; | 207 | int index = substream->number; |
202 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(substream); | 208 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(substream); |
203 | struct snd_pcm_runtime *runtime = substream->runtime; | 209 | struct snd_pcm_runtime *runtime = substream->runtime; |
210 | struct device *dev = caiaqdev_to_dev(cdev); | ||
204 | 211 | ||
205 | debug("%s(%p)\n", __func__, substream); | 212 | dev_dbg(dev, "%s(%p)\n", __func__, substream); |
206 | 213 | ||
207 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 214 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
208 | int out_pos; | 215 | int out_pos; |
209 | 216 | ||
210 | switch (dev->spec.data_alignment) { | 217 | switch (cdev->spec.data_alignment) { |
211 | case 0: | 218 | case 0: |
212 | case 2: | 219 | case 2: |
213 | out_pos = BYTES_PER_SAMPLE + 1; | 220 | out_pos = BYTES_PER_SAMPLE + 1; |
@@ -218,12 +225,12 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
218 | break; | 225 | break; |
219 | } | 226 | } |
220 | 227 | ||
221 | dev->period_out_count[index] = out_pos; | 228 | cdev->period_out_count[index] = out_pos; |
222 | dev->audio_out_buf_pos[index] = out_pos; | 229 | cdev->audio_out_buf_pos[index] = out_pos; |
223 | } else { | 230 | } else { |
224 | int in_pos; | 231 | int in_pos; |
225 | 232 | ||
226 | switch (dev->spec.data_alignment) { | 233 | switch (cdev->spec.data_alignment) { |
227 | case 0: | 234 | case 0: |
228 | in_pos = BYTES_PER_SAMPLE + 2; | 235 | in_pos = BYTES_PER_SAMPLE + 2; |
229 | break; | 236 | break; |
@@ -236,44 +243,44 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
236 | break; | 243 | break; |
237 | } | 244 | } |
238 | 245 | ||
239 | dev->period_in_count[index] = in_pos; | 246 | cdev->period_in_count[index] = in_pos; |
240 | dev->audio_in_buf_pos[index] = in_pos; | 247 | cdev->audio_in_buf_pos[index] = in_pos; |
241 | } | 248 | } |
242 | 249 | ||
243 | if (dev->streaming) | 250 | if (cdev->streaming) |
244 | return 0; | 251 | return 0; |
245 | 252 | ||
246 | /* the first client that opens a stream defines the sample rate | 253 | /* the first client that opens a stream defines the sample rate |
247 | * setting for all subsequent calls, until the last client closed. */ | 254 | * setting for all subsequent calls, until the last client closed. */ |
248 | for (i=0; i < ARRAY_SIZE(rates); i++) | 255 | for (i=0; i < ARRAY_SIZE(rates); i++) |
249 | if (runtime->rate == rates[i]) | 256 | if (runtime->rate == rates[i]) |
250 | dev->pcm_info.rates = 1 << i; | 257 | cdev->pcm_info.rates = 1 << i; |
251 | 258 | ||
252 | snd_pcm_limit_hw_rates(runtime); | 259 | snd_pcm_limit_hw_rates(runtime); |
253 | 260 | ||
254 | bytes_per_sample = BYTES_PER_SAMPLE; | 261 | bytes_per_sample = BYTES_PER_SAMPLE; |
255 | if (dev->spec.data_alignment >= 2) | 262 | if (cdev->spec.data_alignment >= 2) |
256 | bytes_per_sample++; | 263 | bytes_per_sample++; |
257 | 264 | ||
258 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) | 265 | bpp = ((runtime->rate / 8000) + CLOCK_DRIFT_TOLERANCE) |
259 | * bytes_per_sample * CHANNELS_PER_STREAM * dev->n_streams; | 266 | * bytes_per_sample * CHANNELS_PER_STREAM * cdev->n_streams; |
260 | 267 | ||
261 | if (bpp > MAX_ENDPOINT_SIZE) | 268 | if (bpp > MAX_ENDPOINT_SIZE) |
262 | bpp = MAX_ENDPOINT_SIZE; | 269 | bpp = MAX_ENDPOINT_SIZE; |
263 | 270 | ||
264 | ret = snd_usb_caiaq_set_audio_params(dev, runtime->rate, | 271 | ret = snd_usb_caiaq_set_audio_params(cdev, runtime->rate, |
265 | runtime->sample_bits, bpp); | 272 | runtime->sample_bits, bpp); |
266 | if (ret) | 273 | if (ret) |
267 | return ret; | 274 | return ret; |
268 | 275 | ||
269 | ret = stream_start(dev); | 276 | ret = stream_start(cdev); |
270 | if (ret) | 277 | if (ret) |
271 | return ret; | 278 | return ret; |
272 | 279 | ||
273 | dev->output_running = 0; | 280 | cdev->output_running = 0; |
274 | wait_event_timeout(dev->prepare_wait_queue, dev->output_running, HZ); | 281 | wait_event_timeout(cdev->prepare_wait_queue, cdev->output_running, HZ); |
275 | if (!dev->output_running) { | 282 | if (!cdev->output_running) { |
276 | stream_stop(dev); | 283 | stream_stop(cdev); |
277 | return -EPIPE; | 284 | return -EPIPE; |
278 | } | 285 | } |
279 | 286 | ||
@@ -282,18 +289,19 @@ static int snd_usb_caiaq_pcm_prepare(struct snd_pcm_substream *substream) | |||
282 | 289 | ||
283 | static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd) | 290 | static int snd_usb_caiaq_pcm_trigger(struct snd_pcm_substream *sub, int cmd) |
284 | { | 291 | { |
285 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); | 292 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); |
293 | struct device *dev = caiaqdev_to_dev(cdev); | ||
286 | 294 | ||
287 | debug("%s(%p) cmd %d\n", __func__, sub, cmd); | 295 | dev_dbg(dev, "%s(%p) cmd %d\n", __func__, sub, cmd); |
288 | 296 | ||
289 | switch (cmd) { | 297 | switch (cmd) { |
290 | case SNDRV_PCM_TRIGGER_START: | 298 | case SNDRV_PCM_TRIGGER_START: |
291 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 299 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
292 | activate_substream(dev, sub); | 300 | activate_substream(cdev, sub); |
293 | break; | 301 | break; |
294 | case SNDRV_PCM_TRIGGER_STOP: | 302 | case SNDRV_PCM_TRIGGER_STOP: |
295 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 303 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
296 | deactivate_substream(dev, sub); | 304 | deactivate_substream(cdev, sub); |
297 | break; | 305 | break; |
298 | default: | 306 | default: |
299 | return -EINVAL; | 307 | return -EINVAL; |
@@ -306,25 +314,25 @@ static snd_pcm_uframes_t | |||
306 | snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) | 314 | snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) |
307 | { | 315 | { |
308 | int index = sub->number; | 316 | int index = sub->number; |
309 | struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); | 317 | struct snd_usb_caiaqdev *cdev = snd_pcm_substream_chip(sub); |
310 | snd_pcm_uframes_t ptr; | 318 | snd_pcm_uframes_t ptr; |
311 | 319 | ||
312 | spin_lock(&dev->spinlock); | 320 | spin_lock(&cdev->spinlock); |
313 | 321 | ||
314 | if (dev->input_panic || dev->output_panic) { | 322 | if (cdev->input_panic || cdev->output_panic) { |
315 | ptr = SNDRV_PCM_POS_XRUN; | 323 | ptr = SNDRV_PCM_POS_XRUN; |
316 | goto unlock; | 324 | goto unlock; |
317 | } | 325 | } |
318 | 326 | ||
319 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) | 327 | if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) |
320 | ptr = bytes_to_frames(sub->runtime, | 328 | ptr = bytes_to_frames(sub->runtime, |
321 | dev->audio_out_buf_pos[index]); | 329 | cdev->audio_out_buf_pos[index]); |
322 | else | 330 | else |
323 | ptr = bytes_to_frames(sub->runtime, | 331 | ptr = bytes_to_frames(sub->runtime, |
324 | dev->audio_in_buf_pos[index]); | 332 | cdev->audio_in_buf_pos[index]); |
325 | 333 | ||
326 | unlock: | 334 | unlock: |
327 | spin_unlock(&dev->spinlock); | 335 | spin_unlock(&cdev->spinlock); |
328 | return ptr; | 336 | return ptr; |
329 | } | 337 | } |
330 | 338 | ||
@@ -340,21 +348,21 @@ static struct snd_pcm_ops snd_usb_caiaq_ops = { | |||
340 | .pointer = snd_usb_caiaq_pcm_pointer | 348 | .pointer = snd_usb_caiaq_pcm_pointer |
341 | }; | 349 | }; |
342 | 350 | ||
343 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, | 351 | static void check_for_elapsed_periods(struct snd_usb_caiaqdev *cdev, |
344 | struct snd_pcm_substream **subs) | 352 | struct snd_pcm_substream **subs) |
345 | { | 353 | { |
346 | int stream, pb, *cnt; | 354 | int stream, pb, *cnt; |
347 | struct snd_pcm_substream *sub; | 355 | struct snd_pcm_substream *sub; |
348 | 356 | ||
349 | for (stream = 0; stream < dev->n_streams; stream++) { | 357 | for (stream = 0; stream < cdev->n_streams; stream++) { |
350 | sub = subs[stream]; | 358 | sub = subs[stream]; |
351 | if (!sub) | 359 | if (!sub) |
352 | continue; | 360 | continue; |
353 | 361 | ||
354 | pb = snd_pcm_lib_period_bytes(sub); | 362 | pb = snd_pcm_lib_period_bytes(sub); |
355 | cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? | 363 | cnt = (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) ? |
356 | &dev->period_out_count[stream] : | 364 | &cdev->period_out_count[stream] : |
357 | &dev->period_in_count[stream]; | 365 | &cdev->period_in_count[stream]; |
358 | 366 | ||
359 | if (*cnt >= pb) { | 367 | if (*cnt >= pb) { |
360 | snd_pcm_period_elapsed(sub); | 368 | snd_pcm_period_elapsed(sub); |
@@ -363,7 +371,7 @@ static void check_for_elapsed_periods(struct snd_usb_caiaqdev *dev, | |||
363 | } | 371 | } |
364 | } | 372 | } |
365 | 373 | ||
366 | static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, | 374 | static void read_in_urb_mode0(struct snd_usb_caiaqdev *cdev, |
367 | const struct urb *urb, | 375 | const struct urb *urb, |
368 | const struct usb_iso_packet_descriptor *iso) | 376 | const struct usb_iso_packet_descriptor *iso) |
369 | { | 377 | { |
@@ -371,27 +379,27 @@ static void read_in_urb_mode0(struct snd_usb_caiaqdev *dev, | |||
371 | struct snd_pcm_substream *sub; | 379 | struct snd_pcm_substream *sub; |
372 | int stream, i; | 380 | int stream, i; |
373 | 381 | ||
374 | if (all_substreams_zero(dev->sub_capture)) | 382 | if (all_substreams_zero(cdev->sub_capture)) |
375 | return; | 383 | return; |
376 | 384 | ||
377 | for (i = 0; i < iso->actual_length;) { | 385 | for (i = 0; i < iso->actual_length;) { |
378 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 386 | for (stream = 0; stream < cdev->n_streams; stream++, i++) { |
379 | sub = dev->sub_capture[stream]; | 387 | sub = cdev->sub_capture[stream]; |
380 | if (sub) { | 388 | if (sub) { |
381 | struct snd_pcm_runtime *rt = sub->runtime; | 389 | struct snd_pcm_runtime *rt = sub->runtime; |
382 | char *audio_buf = rt->dma_area; | 390 | char *audio_buf = rt->dma_area; |
383 | int sz = frames_to_bytes(rt, rt->buffer_size); | 391 | int sz = frames_to_bytes(rt, rt->buffer_size); |
384 | audio_buf[dev->audio_in_buf_pos[stream]++] | 392 | audio_buf[cdev->audio_in_buf_pos[stream]++] |
385 | = usb_buf[i]; | 393 | = usb_buf[i]; |
386 | dev->period_in_count[stream]++; | 394 | cdev->period_in_count[stream]++; |
387 | if (dev->audio_in_buf_pos[stream] == sz) | 395 | if (cdev->audio_in_buf_pos[stream] == sz) |
388 | dev->audio_in_buf_pos[stream] = 0; | 396 | cdev->audio_in_buf_pos[stream] = 0; |
389 | } | 397 | } |
390 | } | 398 | } |
391 | } | 399 | } |
392 | } | 400 | } |
393 | 401 | ||
394 | static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, | 402 | static void read_in_urb_mode2(struct snd_usb_caiaqdev *cdev, |
395 | const struct urb *urb, | 403 | const struct urb *urb, |
396 | const struct usb_iso_packet_descriptor *iso) | 404 | const struct usb_iso_packet_descriptor *iso) |
397 | { | 405 | { |
@@ -401,48 +409,49 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev, | |||
401 | int stream, i; | 409 | int stream, i; |
402 | 410 | ||
403 | for (i = 0; i < iso->actual_length;) { | 411 | for (i = 0; i < iso->actual_length;) { |
404 | if (i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { | 412 | if (i % (cdev->n_streams * BYTES_PER_SAMPLE_USB) == 0) { |
405 | for (stream = 0; | 413 | for (stream = 0; |
406 | stream < dev->n_streams; | 414 | stream < cdev->n_streams; |
407 | stream++, i++) { | 415 | stream++, i++) { |
408 | if (dev->first_packet) | 416 | if (cdev->first_packet) |
409 | continue; | 417 | continue; |
410 | 418 | ||
411 | check_byte = MAKE_CHECKBYTE(dev, stream, i); | 419 | check_byte = MAKE_CHECKBYTE(cdev, stream, i); |
412 | 420 | ||
413 | if ((usb_buf[i] & 0x3f) != check_byte) | 421 | if ((usb_buf[i] & 0x3f) != check_byte) |
414 | dev->input_panic = 1; | 422 | cdev->input_panic = 1; |
415 | 423 | ||
416 | if (usb_buf[i] & 0x80) | 424 | if (usb_buf[i] & 0x80) |
417 | dev->output_panic = 1; | 425 | cdev->output_panic = 1; |
418 | } | 426 | } |
419 | } | 427 | } |
420 | dev->first_packet = 0; | 428 | cdev->first_packet = 0; |
421 | 429 | ||
422 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 430 | for (stream = 0; stream < cdev->n_streams; stream++, i++) { |
423 | sub = dev->sub_capture[stream]; | 431 | sub = cdev->sub_capture[stream]; |
424 | if (dev->input_panic) | 432 | if (cdev->input_panic) |
425 | usb_buf[i] = 0; | 433 | usb_buf[i] = 0; |
426 | 434 | ||
427 | if (sub) { | 435 | if (sub) { |
428 | struct snd_pcm_runtime *rt = sub->runtime; | 436 | struct snd_pcm_runtime *rt = sub->runtime; |
429 | char *audio_buf = rt->dma_area; | 437 | char *audio_buf = rt->dma_area; |
430 | int sz = frames_to_bytes(rt, rt->buffer_size); | 438 | int sz = frames_to_bytes(rt, rt->buffer_size); |
431 | audio_buf[dev->audio_in_buf_pos[stream]++] = | 439 | audio_buf[cdev->audio_in_buf_pos[stream]++] = |
432 | usb_buf[i]; | 440 | usb_buf[i]; |
433 | dev->period_in_count[stream]++; | 441 | cdev->period_in_count[stream]++; |
434 | if (dev->audio_in_buf_pos[stream] == sz) | 442 | if (cdev->audio_in_buf_pos[stream] == sz) |
435 | dev->audio_in_buf_pos[stream] = 0; | 443 | cdev->audio_in_buf_pos[stream] = 0; |
436 | } | 444 | } |
437 | } | 445 | } |
438 | } | 446 | } |
439 | } | 447 | } |
440 | 448 | ||
441 | static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | 449 | static void read_in_urb_mode3(struct snd_usb_caiaqdev *cdev, |
442 | const struct urb *urb, | 450 | const struct urb *urb, |
443 | const struct usb_iso_packet_descriptor *iso) | 451 | const struct usb_iso_packet_descriptor *iso) |
444 | { | 452 | { |
445 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; | 453 | unsigned char *usb_buf = urb->transfer_buffer + iso->offset; |
454 | struct device *dev = caiaqdev_to_dev(cdev); | ||
446 | int stream, i; | 455 | int stream, i; |
447 | 456 | ||
448 | /* paranoia check */ | 457 | /* paranoia check */ |
@@ -450,12 +459,12 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | |||
450 | return; | 459 | return; |
451 | 460 | ||
452 | for (i = 0; i < iso->actual_length;) { | 461 | for (i = 0; i < iso->actual_length;) { |
453 | for (stream = 0; stream < dev->n_streams; stream++) { | 462 | for (stream = 0; stream < cdev->n_streams; stream++) { |
454 | struct snd_pcm_substream *sub = dev->sub_capture[stream]; | 463 | struct snd_pcm_substream *sub = cdev->sub_capture[stream]; |
455 | char *audio_buf = NULL; | 464 | char *audio_buf = NULL; |
456 | int c, n, sz = 0; | 465 | int c, n, sz = 0; |
457 | 466 | ||
458 | if (sub && !dev->input_panic) { | 467 | if (sub && !cdev->input_panic) { |
459 | struct snd_pcm_runtime *rt = sub->runtime; | 468 | struct snd_pcm_runtime *rt = sub->runtime; |
460 | audio_buf = rt->dma_area; | 469 | audio_buf = rt->dma_area; |
461 | sz = frames_to_bytes(rt, rt->buffer_size); | 470 | sz = frames_to_bytes(rt, rt->buffer_size); |
@@ -465,23 +474,23 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | |||
465 | /* 3 audio data bytes, followed by 1 check byte */ | 474 | /* 3 audio data bytes, followed by 1 check byte */ |
466 | if (audio_buf) { | 475 | if (audio_buf) { |
467 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { | 476 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { |
468 | audio_buf[dev->audio_in_buf_pos[stream]++] = usb_buf[i+n]; | 477 | audio_buf[cdev->audio_in_buf_pos[stream]++] = usb_buf[i+n]; |
469 | 478 | ||
470 | if (dev->audio_in_buf_pos[stream] == sz) | 479 | if (cdev->audio_in_buf_pos[stream] == sz) |
471 | dev->audio_in_buf_pos[stream] = 0; | 480 | cdev->audio_in_buf_pos[stream] = 0; |
472 | } | 481 | } |
473 | 482 | ||
474 | dev->period_in_count[stream] += BYTES_PER_SAMPLE; | 483 | cdev->period_in_count[stream] += BYTES_PER_SAMPLE; |
475 | } | 484 | } |
476 | 485 | ||
477 | i += BYTES_PER_SAMPLE; | 486 | i += BYTES_PER_SAMPLE; |
478 | 487 | ||
479 | if (usb_buf[i] != ((stream << 1) | c) && | 488 | if (usb_buf[i] != ((stream << 1) | c) && |
480 | !dev->first_packet) { | 489 | !cdev->first_packet) { |
481 | if (!dev->input_panic) | 490 | if (!cdev->input_panic) |
482 | printk(" EXPECTED: %02x got %02x, c %d, stream %d, i %d\n", | 491 | dev_warn(dev, " EXPECTED: %02x got %02x, c %d, stream %d, i %d\n", |
483 | ((stream << 1) | c), usb_buf[i], c, stream, i); | 492 | ((stream << 1) | c), usb_buf[i], c, stream, i); |
484 | dev->input_panic = 1; | 493 | cdev->input_panic = 1; |
485 | } | 494 | } |
486 | 495 | ||
487 | i++; | 496 | i++; |
@@ -489,41 +498,43 @@ static void read_in_urb_mode3(struct snd_usb_caiaqdev *dev, | |||
489 | } | 498 | } |
490 | } | 499 | } |
491 | 500 | ||
492 | if (dev->first_packet > 0) | 501 | if (cdev->first_packet > 0) |
493 | dev->first_packet--; | 502 | cdev->first_packet--; |
494 | } | 503 | } |
495 | 504 | ||
496 | static void read_in_urb(struct snd_usb_caiaqdev *dev, | 505 | static void read_in_urb(struct snd_usb_caiaqdev *cdev, |
497 | const struct urb *urb, | 506 | const struct urb *urb, |
498 | const struct usb_iso_packet_descriptor *iso) | 507 | const struct usb_iso_packet_descriptor *iso) |
499 | { | 508 | { |
500 | if (!dev->streaming) | 509 | struct device *dev = caiaqdev_to_dev(cdev); |
510 | |||
511 | if (!cdev->streaming) | ||
501 | return; | 512 | return; |
502 | 513 | ||
503 | if (iso->actual_length < dev->bpp) | 514 | if (iso->actual_length < cdev->bpp) |
504 | return; | 515 | return; |
505 | 516 | ||
506 | switch (dev->spec.data_alignment) { | 517 | switch (cdev->spec.data_alignment) { |
507 | case 0: | 518 | case 0: |
508 | read_in_urb_mode0(dev, urb, iso); | 519 | read_in_urb_mode0(cdev, urb, iso); |
509 | break; | 520 | break; |
510 | case 2: | 521 | case 2: |
511 | read_in_urb_mode2(dev, urb, iso); | 522 | read_in_urb_mode2(cdev, urb, iso); |
512 | break; | 523 | break; |
513 | case 3: | 524 | case 3: |
514 | read_in_urb_mode3(dev, urb, iso); | 525 | read_in_urb_mode3(cdev, urb, iso); |
515 | break; | 526 | break; |
516 | } | 527 | } |
517 | 528 | ||
518 | if ((dev->input_panic || dev->output_panic) && !dev->warned) { | 529 | if ((cdev->input_panic || cdev->output_panic) && !cdev->warned) { |
519 | debug("streaming error detected %s %s\n", | 530 | dev_warn(dev, "streaming error detected %s %s\n", |
520 | dev->input_panic ? "(input)" : "", | 531 | cdev->input_panic ? "(input)" : "", |
521 | dev->output_panic ? "(output)" : ""); | 532 | cdev->output_panic ? "(output)" : ""); |
522 | dev->warned = 1; | 533 | cdev->warned = 1; |
523 | } | 534 | } |
524 | } | 535 | } |
525 | 536 | ||
526 | static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *dev, | 537 | static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *cdev, |
527 | struct urb *urb, | 538 | struct urb *urb, |
528 | const struct usb_iso_packet_descriptor *iso) | 539 | const struct usb_iso_packet_descriptor *iso) |
529 | { | 540 | { |
@@ -532,32 +543,32 @@ static void fill_out_urb_mode_0(struct snd_usb_caiaqdev *dev, | |||
532 | int stream, i; | 543 | int stream, i; |
533 | 544 | ||
534 | for (i = 0; i < iso->length;) { | 545 | for (i = 0; i < iso->length;) { |
535 | for (stream = 0; stream < dev->n_streams; stream++, i++) { | 546 | for (stream = 0; stream < cdev->n_streams; stream++, i++) { |
536 | sub = dev->sub_playback[stream]; | 547 | sub = cdev->sub_playback[stream]; |
537 | if (sub) { | 548 | if (sub) { |
538 | struct snd_pcm_runtime *rt = sub->runtime; | 549 | struct snd_pcm_runtime *rt = sub->runtime; |
539 | char *audio_buf = rt->dma_area; | 550 | char *audio_buf = rt->dma_area; |
540 | int sz = frames_to_bytes(rt, rt->buffer_size); | 551 | int sz = frames_to_bytes(rt, rt->buffer_size); |
541 | usb_buf[i] = | 552 | usb_buf[i] = |
542 | audio_buf[dev->audio_out_buf_pos[stream]]; | 553 | audio_buf[cdev->audio_out_buf_pos[stream]]; |
543 | dev->period_out_count[stream]++; | 554 | cdev->period_out_count[stream]++; |
544 | dev->audio_out_buf_pos[stream]++; | 555 | cdev->audio_out_buf_pos[stream]++; |
545 | if (dev->audio_out_buf_pos[stream] == sz) | 556 | if (cdev->audio_out_buf_pos[stream] == sz) |
546 | dev->audio_out_buf_pos[stream] = 0; | 557 | cdev->audio_out_buf_pos[stream] = 0; |
547 | } else | 558 | } else |
548 | usb_buf[i] = 0; | 559 | usb_buf[i] = 0; |
549 | } | 560 | } |
550 | 561 | ||
551 | /* fill in the check bytes */ | 562 | /* fill in the check bytes */ |
552 | if (dev->spec.data_alignment == 2 && | 563 | if (cdev->spec.data_alignment == 2 && |
553 | i % (dev->n_streams * BYTES_PER_SAMPLE_USB) == | 564 | i % (cdev->n_streams * BYTES_PER_SAMPLE_USB) == |
554 | (dev->n_streams * CHANNELS_PER_STREAM)) | 565 | (cdev->n_streams * CHANNELS_PER_STREAM)) |
555 | for (stream = 0; stream < dev->n_streams; stream++, i++) | 566 | for (stream = 0; stream < cdev->n_streams; stream++, i++) |
556 | usb_buf[i] = MAKE_CHECKBYTE(dev, stream, i); | 567 | usb_buf[i] = MAKE_CHECKBYTE(cdev, stream, i); |
557 | } | 568 | } |
558 | } | 569 | } |
559 | 570 | ||
560 | static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | 571 | static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *cdev, |
561 | struct urb *urb, | 572 | struct urb *urb, |
562 | const struct usb_iso_packet_descriptor *iso) | 573 | const struct usb_iso_packet_descriptor *iso) |
563 | { | 574 | { |
@@ -565,8 +576,8 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | |||
565 | int stream, i; | 576 | int stream, i; |
566 | 577 | ||
567 | for (i = 0; i < iso->length;) { | 578 | for (i = 0; i < iso->length;) { |
568 | for (stream = 0; stream < dev->n_streams; stream++) { | 579 | for (stream = 0; stream < cdev->n_streams; stream++) { |
569 | struct snd_pcm_substream *sub = dev->sub_playback[stream]; | 580 | struct snd_pcm_substream *sub = cdev->sub_playback[stream]; |
570 | char *audio_buf = NULL; | 581 | char *audio_buf = NULL; |
571 | int c, n, sz = 0; | 582 | int c, n, sz = 0; |
572 | 583 | ||
@@ -579,17 +590,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | |||
579 | for (c = 0; c < CHANNELS_PER_STREAM; c++) { | 590 | for (c = 0; c < CHANNELS_PER_STREAM; c++) { |
580 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { | 591 | for (n = 0; n < BYTES_PER_SAMPLE; n++) { |
581 | if (audio_buf) { | 592 | if (audio_buf) { |
582 | usb_buf[i+n] = audio_buf[dev->audio_out_buf_pos[stream]++]; | 593 | usb_buf[i+n] = audio_buf[cdev->audio_out_buf_pos[stream]++]; |
583 | 594 | ||
584 | if (dev->audio_out_buf_pos[stream] == sz) | 595 | if (cdev->audio_out_buf_pos[stream] == sz) |
585 | dev->audio_out_buf_pos[stream] = 0; | 596 | cdev->audio_out_buf_pos[stream] = 0; |
586 | } else { | 597 | } else { |
587 | usb_buf[i+n] = 0; | 598 | usb_buf[i+n] = 0; |
588 | } | 599 | } |
589 | } | 600 | } |
590 | 601 | ||
591 | if (audio_buf) | 602 | if (audio_buf) |
592 | dev->period_out_count[stream] += BYTES_PER_SAMPLE; | 603 | cdev->period_out_count[stream] += BYTES_PER_SAMPLE; |
593 | 604 | ||
594 | i += BYTES_PER_SAMPLE; | 605 | i += BYTES_PER_SAMPLE; |
595 | 606 | ||
@@ -600,17 +611,17 @@ static void fill_out_urb_mode_3(struct snd_usb_caiaqdev *dev, | |||
600 | } | 611 | } |
601 | } | 612 | } |
602 | 613 | ||
603 | static inline void fill_out_urb(struct snd_usb_caiaqdev *dev, | 614 | static inline void fill_out_urb(struct snd_usb_caiaqdev *cdev, |
604 | struct urb *urb, | 615 | struct urb *urb, |
605 | const struct usb_iso_packet_descriptor *iso) | 616 | const struct usb_iso_packet_descriptor *iso) |
606 | { | 617 | { |
607 | switch (dev->spec.data_alignment) { | 618 | switch (cdev->spec.data_alignment) { |
608 | case 0: | 619 | case 0: |
609 | case 2: | 620 | case 2: |
610 | fill_out_urb_mode_0(dev, urb, iso); | 621 | fill_out_urb_mode_0(cdev, urb, iso); |
611 | break; | 622 | break; |
612 | case 3: | 623 | case 3: |
613 | fill_out_urb_mode_3(dev, urb, iso); | 624 | fill_out_urb_mode_3(cdev, urb, iso); |
614 | break; | 625 | break; |
615 | } | 626 | } |
616 | } | 627 | } |
@@ -618,7 +629,8 @@ static inline void fill_out_urb(struct snd_usb_caiaqdev *dev, | |||
618 | static void read_completed(struct urb *urb) | 629 | static void read_completed(struct urb *urb) |
619 | { | 630 | { |
620 | struct snd_usb_caiaq_cb_info *info = urb->context; | 631 | struct snd_usb_caiaq_cb_info *info = urb->context; |
621 | struct snd_usb_caiaqdev *dev; | 632 | struct snd_usb_caiaqdev *cdev; |
633 | struct device *dev; | ||
622 | struct urb *out = NULL; | 634 | struct urb *out = NULL; |
623 | int i, frame, len, send_it = 0, outframe = 0; | 635 | int i, frame, len, send_it = 0, outframe = 0; |
624 | size_t offset = 0; | 636 | size_t offset = 0; |
@@ -626,20 +638,21 @@ static void read_completed(struct urb *urb) | |||
626 | if (urb->status || !info) | 638 | if (urb->status || !info) |
627 | return; | 639 | return; |
628 | 640 | ||
629 | dev = info->dev; | 641 | cdev = info->cdev; |
642 | dev = caiaqdev_to_dev(cdev); | ||
630 | 643 | ||
631 | if (!dev->streaming) | 644 | if (!cdev->streaming) |
632 | return; | 645 | return; |
633 | 646 | ||
634 | /* find an unused output urb that is unused */ | 647 | /* find an unused output urb that is unused */ |
635 | for (i = 0; i < N_URBS; i++) | 648 | for (i = 0; i < N_URBS; i++) |
636 | if (test_and_set_bit(i, &dev->outurb_active_mask) == 0) { | 649 | if (test_and_set_bit(i, &cdev->outurb_active_mask) == 0) { |
637 | out = dev->data_urbs_out[i]; | 650 | out = cdev->data_urbs_out[i]; |
638 | break; | 651 | break; |
639 | } | 652 | } |
640 | 653 | ||
641 | if (!out) { | 654 | if (!out) { |
642 | log("Unable to find an output urb to use\n"); | 655 | dev_err(dev, "Unable to find an output urb to use\n"); |
643 | goto requeue; | 656 | goto requeue; |
644 | } | 657 | } |
645 | 658 | ||
@@ -656,12 +669,12 @@ static void read_completed(struct urb *urb) | |||
656 | offset += len; | 669 | offset += len; |
657 | 670 | ||
658 | if (len > 0) { | 671 | if (len > 0) { |
659 | spin_lock(&dev->spinlock); | 672 | spin_lock(&cdev->spinlock); |
660 | fill_out_urb(dev, out, &out->iso_frame_desc[outframe]); | 673 | fill_out_urb(cdev, out, &out->iso_frame_desc[outframe]); |
661 | read_in_urb(dev, urb, &urb->iso_frame_desc[frame]); | 674 | read_in_urb(cdev, urb, &urb->iso_frame_desc[frame]); |
662 | spin_unlock(&dev->spinlock); | 675 | spin_unlock(&cdev->spinlock); |
663 | check_for_elapsed_periods(dev, dev->sub_playback); | 676 | check_for_elapsed_periods(cdev, cdev->sub_playback); |
664 | check_for_elapsed_periods(dev, dev->sub_capture); | 677 | check_for_elapsed_periods(cdev, cdev->sub_capture); |
665 | send_it = 1; | 678 | send_it = 1; |
666 | } | 679 | } |
667 | 680 | ||
@@ -674,7 +687,7 @@ static void read_completed(struct urb *urb) | |||
674 | usb_submit_urb(out, GFP_ATOMIC); | 687 | usb_submit_urb(out, GFP_ATOMIC); |
675 | } else { | 688 | } else { |
676 | struct snd_usb_caiaq_cb_info *oinfo = out->context; | 689 | struct snd_usb_caiaq_cb_info *oinfo = out->context; |
677 | clear_bit(oinfo->index, &dev->outurb_active_mask); | 690 | clear_bit(oinfo->index, &cdev->outurb_active_mask); |
678 | } | 691 | } |
679 | 692 | ||
680 | requeue: | 693 | requeue: |
@@ -693,21 +706,22 @@ requeue: | |||
693 | static void write_completed(struct urb *urb) | 706 | static void write_completed(struct urb *urb) |
694 | { | 707 | { |
695 | struct snd_usb_caiaq_cb_info *info = urb->context; | 708 | struct snd_usb_caiaq_cb_info *info = urb->context; |
696 | struct snd_usb_caiaqdev *dev = info->dev; | 709 | struct snd_usb_caiaqdev *cdev = info->cdev; |
697 | 710 | ||
698 | if (!dev->output_running) { | 711 | if (!cdev->output_running) { |
699 | dev->output_running = 1; | 712 | cdev->output_running = 1; |
700 | wake_up(&dev->prepare_wait_queue); | 713 | wake_up(&cdev->prepare_wait_queue); |
701 | } | 714 | } |
702 | 715 | ||
703 | clear_bit(info->index, &dev->outurb_active_mask); | 716 | clear_bit(info->index, &cdev->outurb_active_mask); |
704 | } | 717 | } |
705 | 718 | ||
706 | static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | 719 | static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) |
707 | { | 720 | { |
708 | int i, frame; | 721 | int i, frame; |
709 | struct urb **urbs; | 722 | struct urb **urbs; |
710 | struct usb_device *usb_dev = dev->chip.dev; | 723 | struct usb_device *usb_dev = cdev->chip.dev; |
724 | struct device *dev = caiaqdev_to_dev(cdev); | ||
711 | unsigned int pipe; | 725 | unsigned int pipe; |
712 | 726 | ||
713 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? | 727 | pipe = (dir == SNDRV_PCM_STREAM_PLAYBACK) ? |
@@ -716,7 +730,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
716 | 730 | ||
717 | urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL); | 731 | urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL); |
718 | if (!urbs) { | 732 | if (!urbs) { |
719 | log("unable to kmalloc() urbs, OOM!?\n"); | 733 | dev_err(dev, "unable to kmalloc() urbs, OOM!?\n"); |
720 | *ret = -ENOMEM; | 734 | *ret = -ENOMEM; |
721 | return NULL; | 735 | return NULL; |
722 | } | 736 | } |
@@ -724,7 +738,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
724 | for (i = 0; i < N_URBS; i++) { | 738 | for (i = 0; i < N_URBS; i++) { |
725 | urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL); | 739 | urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL); |
726 | if (!urbs[i]) { | 740 | if (!urbs[i]) { |
727 | log("unable to usb_alloc_urb(), OOM!?\n"); | 741 | dev_err(dev, "unable to usb_alloc_urb(), OOM!?\n"); |
728 | *ret = -ENOMEM; | 742 | *ret = -ENOMEM; |
729 | return urbs; | 743 | return urbs; |
730 | } | 744 | } |
@@ -732,7 +746,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
732 | urbs[i]->transfer_buffer = | 746 | urbs[i]->transfer_buffer = |
733 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); | 747 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); |
734 | if (!urbs[i]->transfer_buffer) { | 748 | if (!urbs[i]->transfer_buffer) { |
735 | log("unable to kmalloc() transfer buffer, OOM!?\n"); | 749 | dev_err(dev, "unable to kmalloc() transfer buffer, OOM!?\n"); |
736 | *ret = -ENOMEM; | 750 | *ret = -ENOMEM; |
737 | return urbs; | 751 | return urbs; |
738 | } | 752 | } |
@@ -749,7 +763,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret) | |||
749 | urbs[i]->pipe = pipe; | 763 | urbs[i]->pipe = pipe; |
750 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB | 764 | urbs[i]->transfer_buffer_length = FRAMES_PER_URB |
751 | * BYTES_PER_FRAME; | 765 | * BYTES_PER_FRAME; |
752 | urbs[i]->context = &dev->data_cb_info[i]; | 766 | urbs[i]->context = &cdev->data_cb_info[i]; |
753 | urbs[i]->interval = 1; | 767 | urbs[i]->interval = 1; |
754 | urbs[i]->transfer_flags = URB_ISO_ASAP; | 768 | urbs[i]->transfer_flags = URB_ISO_ASAP; |
755 | urbs[i]->number_of_packets = FRAMES_PER_URB; | 769 | urbs[i]->number_of_packets = FRAMES_PER_URB; |
@@ -780,110 +794,113 @@ static void free_urbs(struct urb **urbs) | |||
780 | kfree(urbs); | 794 | kfree(urbs); |
781 | } | 795 | } |
782 | 796 | ||
783 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev) | 797 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) |
784 | { | 798 | { |
785 | int i, ret; | 799 | int i, ret; |
800 | struct device *dev = caiaqdev_to_dev(cdev); | ||
786 | 801 | ||
787 | dev->n_audio_in = max(dev->spec.num_analog_audio_in, | 802 | cdev->n_audio_in = max(cdev->spec.num_analog_audio_in, |
788 | dev->spec.num_digital_audio_in) / | 803 | cdev->spec.num_digital_audio_in) / |
789 | CHANNELS_PER_STREAM; | 804 | CHANNELS_PER_STREAM; |
790 | dev->n_audio_out = max(dev->spec.num_analog_audio_out, | 805 | cdev->n_audio_out = max(cdev->spec.num_analog_audio_out, |
791 | dev->spec.num_digital_audio_out) / | 806 | cdev->spec.num_digital_audio_out) / |
792 | CHANNELS_PER_STREAM; | 807 | CHANNELS_PER_STREAM; |
793 | dev->n_streams = max(dev->n_audio_in, dev->n_audio_out); | 808 | cdev->n_streams = max(cdev->n_audio_in, cdev->n_audio_out); |
794 | 809 | ||
795 | debug("dev->n_audio_in = %d\n", dev->n_audio_in); | 810 | dev_dbg(dev, "cdev->n_audio_in = %d\n", cdev->n_audio_in); |
796 | debug("dev->n_audio_out = %d\n", dev->n_audio_out); | 811 | dev_dbg(dev, "cdev->n_audio_out = %d\n", cdev->n_audio_out); |
797 | debug("dev->n_streams = %d\n", dev->n_streams); | 812 | dev_dbg(dev, "cdev->n_streams = %d\n", cdev->n_streams); |
798 | 813 | ||
799 | if (dev->n_streams > MAX_STREAMS) { | 814 | if (cdev->n_streams > MAX_STREAMS) { |
800 | log("unable to initialize device, too many streams.\n"); | 815 | dev_err(dev, "unable to initialize device, too many streams.\n"); |
801 | return -EINVAL; | 816 | return -EINVAL; |
802 | } | 817 | } |
803 | 818 | ||
804 | ret = snd_pcm_new(dev->chip.card, dev->product_name, 0, | 819 | ret = snd_pcm_new(cdev->chip.card, cdev->product_name, 0, |
805 | dev->n_audio_out, dev->n_audio_in, &dev->pcm); | 820 | cdev->n_audio_out, cdev->n_audio_in, &cdev->pcm); |
806 | 821 | ||
807 | if (ret < 0) { | 822 | if (ret < 0) { |
808 | log("snd_pcm_new() returned %d\n", ret); | 823 | dev_err(dev, "snd_pcm_new() returned %d\n", ret); |
809 | return ret; | 824 | return ret; |
810 | } | 825 | } |
811 | 826 | ||
812 | dev->pcm->private_data = dev; | 827 | cdev->pcm->private_data = cdev; |
813 | strlcpy(dev->pcm->name, dev->product_name, sizeof(dev->pcm->name)); | 828 | strlcpy(cdev->pcm->name, cdev->product_name, sizeof(cdev->pcm->name)); |
814 | 829 | ||
815 | memset(dev->sub_playback, 0, sizeof(dev->sub_playback)); | 830 | memset(cdev->sub_playback, 0, sizeof(cdev->sub_playback)); |
816 | memset(dev->sub_capture, 0, sizeof(dev->sub_capture)); | 831 | memset(cdev->sub_capture, 0, sizeof(cdev->sub_capture)); |
817 | 832 | ||
818 | memcpy(&dev->pcm_info, &snd_usb_caiaq_pcm_hardware, | 833 | memcpy(&cdev->pcm_info, &snd_usb_caiaq_pcm_hardware, |
819 | sizeof(snd_usb_caiaq_pcm_hardware)); | 834 | sizeof(snd_usb_caiaq_pcm_hardware)); |
820 | 835 | ||
821 | /* setup samplerates */ | 836 | /* setup samplerates */ |
822 | dev->samplerates = dev->pcm_info.rates; | 837 | cdev->samplerates = cdev->pcm_info.rates; |
823 | switch (dev->chip.usb_id) { | 838 | switch (cdev->chip.usb_id) { |
824 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 839 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
825 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 840 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
826 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): | 841 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_SESSIONIO): |
827 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): | 842 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_GUITARRIGMOBILE): |
828 | dev->samplerates |= SNDRV_PCM_RATE_192000; | 843 | cdev->samplerates |= SNDRV_PCM_RATE_192000; |
829 | /* fall thru */ | 844 | /* fall thru */ |
830 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ): | 845 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO2DJ): |
831 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | 846 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): |
832 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 847 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
833 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORAUDIO2): | 848 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORAUDIO2): |
834 | dev->samplerates |= SNDRV_PCM_RATE_88200; | 849 | cdev->samplerates |= SNDRV_PCM_RATE_88200; |
835 | break; | 850 | break; |
836 | } | 851 | } |
837 | 852 | ||
838 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_PLAYBACK, | 853 | snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_PLAYBACK, |
839 | &snd_usb_caiaq_ops); | 854 | &snd_usb_caiaq_ops); |
840 | snd_pcm_set_ops(dev->pcm, SNDRV_PCM_STREAM_CAPTURE, | 855 | snd_pcm_set_ops(cdev->pcm, SNDRV_PCM_STREAM_CAPTURE, |
841 | &snd_usb_caiaq_ops); | 856 | &snd_usb_caiaq_ops); |
842 | 857 | ||
843 | snd_pcm_lib_preallocate_pages_for_all(dev->pcm, | 858 | snd_pcm_lib_preallocate_pages_for_all(cdev->pcm, |
844 | SNDRV_DMA_TYPE_CONTINUOUS, | 859 | SNDRV_DMA_TYPE_CONTINUOUS, |
845 | snd_dma_continuous_data(GFP_KERNEL), | 860 | snd_dma_continuous_data(GFP_KERNEL), |
846 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); | 861 | MAX_BUFFER_SIZE, MAX_BUFFER_SIZE); |
847 | 862 | ||
848 | dev->data_cb_info = | 863 | cdev->data_cb_info = |
849 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, | 864 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, |
850 | GFP_KERNEL); | 865 | GFP_KERNEL); |
851 | 866 | ||
852 | if (!dev->data_cb_info) | 867 | if (!cdev->data_cb_info) |
853 | return -ENOMEM; | 868 | return -ENOMEM; |
854 | 869 | ||
855 | dev->outurb_active_mask = 0; | 870 | cdev->outurb_active_mask = 0; |
856 | BUILD_BUG_ON(N_URBS > (sizeof(dev->outurb_active_mask) * 8)); | 871 | BUILD_BUG_ON(N_URBS > (sizeof(cdev->outurb_active_mask) * 8)); |
857 | 872 | ||
858 | for (i = 0; i < N_URBS; i++) { | 873 | for (i = 0; i < N_URBS; i++) { |
859 | dev->data_cb_info[i].dev = dev; | 874 | cdev->data_cb_info[i].cdev = cdev; |
860 | dev->data_cb_info[i].index = i; | 875 | cdev->data_cb_info[i].index = i; |
861 | } | 876 | } |
862 | 877 | ||
863 | dev->data_urbs_in = alloc_urbs(dev, SNDRV_PCM_STREAM_CAPTURE, &ret); | 878 | cdev->data_urbs_in = alloc_urbs(cdev, SNDRV_PCM_STREAM_CAPTURE, &ret); |
864 | if (ret < 0) { | 879 | if (ret < 0) { |
865 | kfree(dev->data_cb_info); | 880 | kfree(cdev->data_cb_info); |
866 | free_urbs(dev->data_urbs_in); | 881 | free_urbs(cdev->data_urbs_in); |
867 | return ret; | 882 | return ret; |
868 | } | 883 | } |
869 | 884 | ||
870 | dev->data_urbs_out = alloc_urbs(dev, SNDRV_PCM_STREAM_PLAYBACK, &ret); | 885 | cdev->data_urbs_out = alloc_urbs(cdev, SNDRV_PCM_STREAM_PLAYBACK, &ret); |
871 | if (ret < 0) { | 886 | if (ret < 0) { |
872 | kfree(dev->data_cb_info); | 887 | kfree(cdev->data_cb_info); |
873 | free_urbs(dev->data_urbs_in); | 888 | free_urbs(cdev->data_urbs_in); |
874 | free_urbs(dev->data_urbs_out); | 889 | free_urbs(cdev->data_urbs_out); |
875 | return ret; | 890 | return ret; |
876 | } | 891 | } |
877 | 892 | ||
878 | return 0; | 893 | return 0; |
879 | } | 894 | } |
880 | 895 | ||
881 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev) | 896 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev) |
882 | { | 897 | { |
883 | debug("%s(%p)\n", __func__, dev); | 898 | struct device *dev = caiaqdev_to_dev(cdev); |
884 | stream_stop(dev); | 899 | |
885 | free_urbs(dev->data_urbs_in); | 900 | dev_dbg(dev, "%s(%p)\n", __func__, cdev); |
886 | free_urbs(dev->data_urbs_out); | 901 | stream_stop(cdev); |
887 | kfree(dev->data_cb_info); | 902 | free_urbs(cdev->data_urbs_in); |
903 | free_urbs(cdev->data_urbs_out); | ||
904 | kfree(cdev->data_cb_info); | ||
888 | } | 905 | } |
889 | 906 | ||
diff --git a/sound/usb/caiaq/audio.h b/sound/usb/caiaq/audio.h index 8ab1f8d9529e..bdf155300a8a 100644 --- a/sound/usb/caiaq/audio.h +++ b/sound/usb/caiaq/audio.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef CAIAQ_AUDIO_H | 1 | #ifndef CAIAQ_AUDIO_H |
2 | #define CAIAQ_AUDIO_H | 2 | #define CAIAQ_AUDIO_H |
3 | 3 | ||
4 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *dev); | 4 | int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev); |
5 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *dev); | 5 | void snd_usb_caiaq_audio_free(struct snd_usb_caiaqdev *cdev); |
6 | 6 | ||
7 | #endif /* CAIAQ_AUDIO_H */ | 7 | #endif /* CAIAQ_AUDIO_H */ |
diff --git a/sound/usb/caiaq/control.c b/sound/usb/caiaq/control.c index adb8d03267a0..ae6b50f9ed56 100644 --- a/sound/usb/caiaq/control.c +++ b/sound/usb/caiaq/control.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/device.h> | ||
20 | #include <linux/init.h> | 21 | #include <linux/init.h> |
21 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
22 | #include <sound/control.h> | 23 | #include <sound/control.h> |
@@ -32,7 +33,7 @@ static int control_info(struct snd_kcontrol *kcontrol, | |||
32 | struct snd_ctl_elem_info *uinfo) | 33 | struct snd_ctl_elem_info *uinfo) |
33 | { | 34 | { |
34 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); | 35 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); |
35 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 36 | struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card); |
36 | int pos = kcontrol->private_value; | 37 | int pos = kcontrol->private_value; |
37 | int is_intval = pos & CNT_INTVAL; | 38 | int is_intval = pos & CNT_INTVAL; |
38 | int maxval = 63; | 39 | int maxval = 63; |
@@ -40,7 +41,7 @@ static int control_info(struct snd_kcontrol *kcontrol, | |||
40 | uinfo->count = 1; | 41 | uinfo->count = 1; |
41 | pos &= ~CNT_INTVAL; | 42 | pos &= ~CNT_INTVAL; |
42 | 43 | ||
43 | switch (dev->chip.usb_id) { | 44 | switch (cdev->chip.usb_id) { |
44 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 45 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
45 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | 46 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): |
46 | if (pos == 0) { | 47 | if (pos == 0) { |
@@ -78,15 +79,15 @@ static int control_get(struct snd_kcontrol *kcontrol, | |||
78 | struct snd_ctl_elem_value *ucontrol) | 79 | struct snd_ctl_elem_value *ucontrol) |
79 | { | 80 | { |
80 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); | 81 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); |
81 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 82 | struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card); |
82 | int pos = kcontrol->private_value; | 83 | int pos = kcontrol->private_value; |
83 | 84 | ||
84 | if (pos & CNT_INTVAL) | 85 | if (pos & CNT_INTVAL) |
85 | ucontrol->value.integer.value[0] | 86 | ucontrol->value.integer.value[0] |
86 | = dev->control_state[pos & ~CNT_INTVAL]; | 87 | = cdev->control_state[pos & ~CNT_INTVAL]; |
87 | else | 88 | else |
88 | ucontrol->value.integer.value[0] | 89 | ucontrol->value.integer.value[0] |
89 | = !!(dev->control_state[pos / 8] & (1 << pos % 8)); | 90 | = !!(cdev->control_state[pos / 8] & (1 << pos % 8)); |
90 | 91 | ||
91 | return 0; | 92 | return 0; |
92 | } | 93 | } |
@@ -95,43 +96,43 @@ static int control_put(struct snd_kcontrol *kcontrol, | |||
95 | struct snd_ctl_elem_value *ucontrol) | 96 | struct snd_ctl_elem_value *ucontrol) |
96 | { | 97 | { |
97 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); | 98 | struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol); |
98 | struct snd_usb_caiaqdev *dev = caiaqdev(chip->card); | 99 | struct snd_usb_caiaqdev *cdev = caiaqdev(chip->card); |
99 | int pos = kcontrol->private_value; | 100 | int pos = kcontrol->private_value; |
100 | int v = ucontrol->value.integer.value[0]; | 101 | int v = ucontrol->value.integer.value[0]; |
101 | unsigned char cmd = EP1_CMD_WRITE_IO; | 102 | unsigned char cmd = EP1_CMD_WRITE_IO; |
102 | 103 | ||
103 | if (dev->chip.usb_id == | 104 | if (cdev->chip.usb_id == |
104 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) | 105 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1)) |
105 | cmd = EP1_CMD_DIMM_LEDS; | 106 | cmd = EP1_CMD_DIMM_LEDS; |
106 | 107 | ||
107 | if (pos & CNT_INTVAL) { | 108 | if (pos & CNT_INTVAL) { |
108 | int i = pos & ~CNT_INTVAL; | 109 | int i = pos & ~CNT_INTVAL; |
109 | 110 | ||
110 | dev->control_state[i] = v; | 111 | cdev->control_state[i] = v; |
111 | 112 | ||
112 | if (dev->chip.usb_id == | 113 | if (cdev->chip.usb_id == |
113 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4)) { | 114 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4)) { |
114 | int actual_len; | 115 | int actual_len; |
115 | 116 | ||
116 | dev->ep8_out_buf[0] = i; | 117 | cdev->ep8_out_buf[0] = i; |
117 | dev->ep8_out_buf[1] = v; | 118 | cdev->ep8_out_buf[1] = v; |
118 | 119 | ||
119 | usb_bulk_msg(dev->chip.dev, | 120 | usb_bulk_msg(cdev->chip.dev, |
120 | usb_sndbulkpipe(dev->chip.dev, 8), | 121 | usb_sndbulkpipe(cdev->chip.dev, 8), |
121 | dev->ep8_out_buf, sizeof(dev->ep8_out_buf), | 122 | cdev->ep8_out_buf, sizeof(cdev->ep8_out_buf), |
122 | &actual_len, 200); | 123 | &actual_len, 200); |
123 | } else { | 124 | } else { |
124 | snd_usb_caiaq_send_command(dev, cmd, | 125 | snd_usb_caiaq_send_command(cdev, cmd, |
125 | dev->control_state, sizeof(dev->control_state)); | 126 | cdev->control_state, sizeof(cdev->control_state)); |
126 | } | 127 | } |
127 | } else { | 128 | } else { |
128 | if (v) | 129 | if (v) |
129 | dev->control_state[pos / 8] |= 1 << (pos % 8); | 130 | cdev->control_state[pos / 8] |= 1 << (pos % 8); |
130 | else | 131 | else |
131 | dev->control_state[pos / 8] &= ~(1 << (pos % 8)); | 132 | cdev->control_state[pos / 8] &= ~(1 << (pos % 8)); |
132 | 133 | ||
133 | snd_usb_caiaq_send_command(dev, cmd, | 134 | snd_usb_caiaq_send_command(cdev, cmd, |
134 | dev->control_state, sizeof(dev->control_state)); | 135 | cdev->control_state, sizeof(cdev->control_state)); |
135 | } | 136 | } |
136 | 137 | ||
137 | return 1; | 138 | return 1; |
@@ -490,7 +491,7 @@ static struct caiaq_controller kontrols4_controller[] = { | |||
490 | }; | 491 | }; |
491 | 492 | ||
492 | static int add_controls(struct caiaq_controller *c, int num, | 493 | static int add_controls(struct caiaq_controller *c, int num, |
493 | struct snd_usb_caiaqdev *dev) | 494 | struct snd_usb_caiaqdev *cdev) |
494 | { | 495 | { |
495 | int i, ret; | 496 | int i, ret; |
496 | struct snd_kcontrol *kc; | 497 | struct snd_kcontrol *kc; |
@@ -498,8 +499,8 @@ static int add_controls(struct caiaq_controller *c, int num, | |||
498 | for (i = 0; i < num; i++, c++) { | 499 | for (i = 0; i < num; i++, c++) { |
499 | kcontrol_template.name = c->name; | 500 | kcontrol_template.name = c->name; |
500 | kcontrol_template.private_value = c->index; | 501 | kcontrol_template.private_value = c->index; |
501 | kc = snd_ctl_new1(&kcontrol_template, dev); | 502 | kc = snd_ctl_new1(&kcontrol_template, cdev); |
502 | ret = snd_ctl_add(dev->chip.card, kc); | 503 | ret = snd_ctl_add(cdev->chip.card, kc); |
503 | if (ret < 0) | 504 | if (ret < 0) |
504 | return ret; | 505 | return ret; |
505 | } | 506 | } |
@@ -507,50 +508,50 @@ static int add_controls(struct caiaq_controller *c, int num, | |||
507 | return 0; | 508 | return 0; |
508 | } | 509 | } |
509 | 510 | ||
510 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev) | 511 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev) |
511 | { | 512 | { |
512 | int ret = 0; | 513 | int ret = 0; |
513 | 514 | ||
514 | switch (dev->chip.usb_id) { | 515 | switch (cdev->chip.usb_id) { |
515 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 516 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
516 | ret = add_controls(ak1_controller, | 517 | ret = add_controls(ak1_controller, |
517 | ARRAY_SIZE(ak1_controller), dev); | 518 | ARRAY_SIZE(ak1_controller), cdev); |
518 | break; | 519 | break; |
519 | 520 | ||
520 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 521 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
521 | ret = add_controls(rk2_controller, | 522 | ret = add_controls(rk2_controller, |
522 | ARRAY_SIZE(rk2_controller), dev); | 523 | ARRAY_SIZE(rk2_controller), cdev); |
523 | break; | 524 | break; |
524 | 525 | ||
525 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 526 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
526 | ret = add_controls(rk3_controller, | 527 | ret = add_controls(rk3_controller, |
527 | ARRAY_SIZE(rk3_controller), dev); | 528 | ARRAY_SIZE(rk3_controller), cdev); |
528 | break; | 529 | break; |
529 | 530 | ||
530 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 531 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
531 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 532 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
532 | ret = add_controls(kore_controller, | 533 | ret = add_controls(kore_controller, |
533 | ARRAY_SIZE(kore_controller), dev); | 534 | ARRAY_SIZE(kore_controller), cdev); |
534 | break; | 535 | break; |
535 | 536 | ||
536 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 537 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
537 | ret = add_controls(a8dj_controller, | 538 | ret = add_controls(a8dj_controller, |
538 | ARRAY_SIZE(a8dj_controller), dev); | 539 | ARRAY_SIZE(a8dj_controller), cdev); |
539 | break; | 540 | break; |
540 | 541 | ||
541 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): | 542 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): |
542 | ret = add_controls(a4dj_controller, | 543 | ret = add_controls(a4dj_controller, |
543 | ARRAY_SIZE(a4dj_controller), dev); | 544 | ARRAY_SIZE(a4dj_controller), cdev); |
544 | break; | 545 | break; |
545 | 546 | ||
546 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 547 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
547 | ret = add_controls(kontrolx1_controller, | 548 | ret = add_controls(kontrolx1_controller, |
548 | ARRAY_SIZE(kontrolx1_controller), dev); | 549 | ARRAY_SIZE(kontrolx1_controller), cdev); |
549 | break; | 550 | break; |
550 | 551 | ||
551 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 552 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
552 | ret = add_controls(kontrols4_controller, | 553 | ret = add_controls(kontrols4_controller, |
553 | ARRAY_SIZE(kontrols4_controller), dev); | 554 | ARRAY_SIZE(kontrols4_controller), cdev); |
554 | break; | 555 | break; |
555 | } | 556 | } |
556 | 557 | ||
diff --git a/sound/usb/caiaq/control.h b/sound/usb/caiaq/control.h index 2e7ab1aa4fb3..501c4883aef6 100644 --- a/sound/usb/caiaq/control.h +++ b/sound/usb/caiaq/control.h | |||
@@ -1,6 +1,6 @@ | |||
1 | #ifndef CAIAQ_CONTROL_H | 1 | #ifndef CAIAQ_CONTROL_H |
2 | #define CAIAQ_CONTROL_H | 2 | #define CAIAQ_CONTROL_H |
3 | 3 | ||
4 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev); | 4 | int snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *cdev); |
5 | 5 | ||
6 | #endif /* CAIAQ_CONTROL_H */ | 6 | #endif /* CAIAQ_CONTROL_H */ |
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c index e4d6dbb0342d..48b63ccc78c7 100644 --- a/sound/usb/caiaq/device.c +++ b/sound/usb/caiaq/device.c | |||
@@ -20,6 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/moduleparam.h> | 22 | #include <linux/moduleparam.h> |
23 | #include <linux/device.h> | ||
23 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -158,67 +159,68 @@ static struct usb_device_id snd_usb_id_table[] = { | |||
158 | static void usb_ep1_command_reply_dispatch (struct urb* urb) | 159 | static void usb_ep1_command_reply_dispatch (struct urb* urb) |
159 | { | 160 | { |
160 | int ret; | 161 | int ret; |
161 | struct snd_usb_caiaqdev *dev = urb->context; | 162 | struct device *dev = &urb->dev->dev; |
163 | struct snd_usb_caiaqdev *cdev = urb->context; | ||
162 | unsigned char *buf = urb->transfer_buffer; | 164 | unsigned char *buf = urb->transfer_buffer; |
163 | 165 | ||
164 | if (urb->status || !dev) { | 166 | if (urb->status || !cdev) { |
165 | log("received EP1 urb->status = %i\n", urb->status); | 167 | dev_warn(dev, "received EP1 urb->status = %i\n", urb->status); |
166 | return; | 168 | return; |
167 | } | 169 | } |
168 | 170 | ||
169 | switch(buf[0]) { | 171 | switch(buf[0]) { |
170 | case EP1_CMD_GET_DEVICE_INFO: | 172 | case EP1_CMD_GET_DEVICE_INFO: |
171 | memcpy(&dev->spec, buf+1, sizeof(struct caiaq_device_spec)); | 173 | memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec)); |
172 | dev->spec.fw_version = le16_to_cpu(dev->spec.fw_version); | 174 | cdev->spec.fw_version = le16_to_cpu(cdev->spec.fw_version); |
173 | debug("device spec (firmware %d): audio: %d in, %d out, " | 175 | dev_dbg(dev, "device spec (firmware %d): audio: %d in, %d out, " |
174 | "MIDI: %d in, %d out, data alignment %d\n", | 176 | "MIDI: %d in, %d out, data alignment %d\n", |
175 | dev->spec.fw_version, | 177 | cdev->spec.fw_version, |
176 | dev->spec.num_analog_audio_in, | 178 | cdev->spec.num_analog_audio_in, |
177 | dev->spec.num_analog_audio_out, | 179 | cdev->spec.num_analog_audio_out, |
178 | dev->spec.num_midi_in, | 180 | cdev->spec.num_midi_in, |
179 | dev->spec.num_midi_out, | 181 | cdev->spec.num_midi_out, |
180 | dev->spec.data_alignment); | 182 | cdev->spec.data_alignment); |
181 | 183 | ||
182 | dev->spec_received++; | 184 | cdev->spec_received++; |
183 | wake_up(&dev->ep1_wait_queue); | 185 | wake_up(&cdev->ep1_wait_queue); |
184 | break; | 186 | break; |
185 | case EP1_CMD_AUDIO_PARAMS: | 187 | case EP1_CMD_AUDIO_PARAMS: |
186 | dev->audio_parm_answer = buf[1]; | 188 | cdev->audio_parm_answer = buf[1]; |
187 | wake_up(&dev->ep1_wait_queue); | 189 | wake_up(&cdev->ep1_wait_queue); |
188 | break; | 190 | break; |
189 | case EP1_CMD_MIDI_READ: | 191 | case EP1_CMD_MIDI_READ: |
190 | snd_usb_caiaq_midi_handle_input(dev, buf[1], buf + 3, buf[2]); | 192 | snd_usb_caiaq_midi_handle_input(cdev, buf[1], buf + 3, buf[2]); |
191 | break; | 193 | break; |
192 | case EP1_CMD_READ_IO: | 194 | case EP1_CMD_READ_IO: |
193 | if (dev->chip.usb_id == | 195 | if (cdev->chip.usb_id == |
194 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) { | 196 | USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ)) { |
195 | if (urb->actual_length > sizeof(dev->control_state)) | 197 | if (urb->actual_length > sizeof(cdev->control_state)) |
196 | urb->actual_length = sizeof(dev->control_state); | 198 | urb->actual_length = sizeof(cdev->control_state); |
197 | memcpy(dev->control_state, buf + 1, urb->actual_length); | 199 | memcpy(cdev->control_state, buf + 1, urb->actual_length); |
198 | wake_up(&dev->ep1_wait_queue); | 200 | wake_up(&cdev->ep1_wait_queue); |
199 | break; | 201 | break; |
200 | } | 202 | } |
201 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 203 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
202 | case EP1_CMD_READ_ERP: | 204 | case EP1_CMD_READ_ERP: |
203 | case EP1_CMD_READ_ANALOG: | 205 | case EP1_CMD_READ_ANALOG: |
204 | snd_usb_caiaq_input_dispatch(dev, buf, urb->actual_length); | 206 | snd_usb_caiaq_input_dispatch(cdev, buf, urb->actual_length); |
205 | #endif | 207 | #endif |
206 | break; | 208 | break; |
207 | } | 209 | } |
208 | 210 | ||
209 | dev->ep1_in_urb.actual_length = 0; | 211 | cdev->ep1_in_urb.actual_length = 0; |
210 | ret = usb_submit_urb(&dev->ep1_in_urb, GFP_ATOMIC); | 212 | ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC); |
211 | if (ret < 0) | 213 | if (ret < 0) |
212 | log("unable to submit urb. OOM!?\n"); | 214 | dev_err(dev, "unable to submit urb. OOM!?\n"); |
213 | } | 215 | } |
214 | 216 | ||
215 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | 217 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, |
216 | unsigned char command, | 218 | unsigned char command, |
217 | const unsigned char *buffer, | 219 | const unsigned char *buffer, |
218 | int len) | 220 | int len) |
219 | { | 221 | { |
220 | int actual_len; | 222 | int actual_len; |
221 | struct usb_device *usb_dev = dev->chip.dev; | 223 | struct usb_device *usb_dev = cdev->chip.dev; |
222 | 224 | ||
223 | if (!usb_dev) | 225 | if (!usb_dev) |
224 | return -EIO; | 226 | return -EIO; |
@@ -227,18 +229,19 @@ int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | |||
227 | len = EP1_BUFSIZE - 1; | 229 | len = EP1_BUFSIZE - 1; |
228 | 230 | ||
229 | if (buffer && len > 0) | 231 | if (buffer && len > 0) |
230 | memcpy(dev->ep1_out_buf+1, buffer, len); | 232 | memcpy(cdev->ep1_out_buf+1, buffer, len); |
231 | 233 | ||
232 | dev->ep1_out_buf[0] = command; | 234 | cdev->ep1_out_buf[0] = command; |
233 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), | 235 | return usb_bulk_msg(usb_dev, usb_sndbulkpipe(usb_dev, 1), |
234 | dev->ep1_out_buf, len+1, &actual_len, 200); | 236 | cdev->ep1_out_buf, len+1, &actual_len, 200); |
235 | } | 237 | } |
236 | 238 | ||
237 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | 239 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, |
238 | int rate, int depth, int bpp) | 240 | int rate, int depth, int bpp) |
239 | { | 241 | { |
240 | int ret; | 242 | int ret; |
241 | char tmp[5]; | 243 | char tmp[5]; |
244 | struct device *dev = caiaqdev_to_dev(cdev); | ||
242 | 245 | ||
243 | switch (rate) { | 246 | switch (rate) { |
244 | case 44100: tmp[0] = SAMPLERATE_44100; break; | 247 | case 44100: tmp[0] = SAMPLERATE_44100; break; |
@@ -259,49 +262,50 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, | |||
259 | tmp[3] = bpp >> 8; | 262 | tmp[3] = bpp >> 8; |
260 | tmp[4] = 1; /* packets per microframe */ | 263 | tmp[4] = 1; /* packets per microframe */ |
261 | 264 | ||
262 | debug("setting audio params: %d Hz, %d bits, %d bpp\n", | 265 | dev_dbg(dev, "setting audio params: %d Hz, %d bits, %d bpp\n", |
263 | rate, depth, bpp); | 266 | rate, depth, bpp); |
264 | 267 | ||
265 | dev->audio_parm_answer = -1; | 268 | cdev->audio_parm_answer = -1; |
266 | ret = snd_usb_caiaq_send_command(dev, EP1_CMD_AUDIO_PARAMS, | 269 | ret = snd_usb_caiaq_send_command(cdev, EP1_CMD_AUDIO_PARAMS, |
267 | tmp, sizeof(tmp)); | 270 | tmp, sizeof(tmp)); |
268 | 271 | ||
269 | if (ret) | 272 | if (ret) |
270 | return ret; | 273 | return ret; |
271 | 274 | ||
272 | if (!wait_event_timeout(dev->ep1_wait_queue, | 275 | if (!wait_event_timeout(cdev->ep1_wait_queue, |
273 | dev->audio_parm_answer >= 0, HZ)) | 276 | cdev->audio_parm_answer >= 0, HZ)) |
274 | return -EPIPE; | 277 | return -EPIPE; |
275 | 278 | ||
276 | if (dev->audio_parm_answer != 1) | 279 | if (cdev->audio_parm_answer != 1) |
277 | debug("unable to set the device's audio params\n"); | 280 | dev_dbg(dev, "unable to set the device's audio params\n"); |
278 | else | 281 | else |
279 | dev->bpp = bpp; | 282 | cdev->bpp = bpp; |
280 | 283 | ||
281 | return dev->audio_parm_answer == 1 ? 0 : -EINVAL; | 284 | return cdev->audio_parm_answer == 1 ? 0 : -EINVAL; |
282 | } | 285 | } |
283 | 286 | ||
284 | int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *dev, | 287 | int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *cdev, |
285 | int digital, int analog, int erp) | 288 | int digital, int analog, int erp) |
286 | { | 289 | { |
287 | char tmp[3] = { digital, analog, erp }; | 290 | char tmp[3] = { digital, analog, erp }; |
288 | return snd_usb_caiaq_send_command(dev, EP1_CMD_AUTO_MSG, | 291 | return snd_usb_caiaq_send_command(cdev, EP1_CMD_AUTO_MSG, |
289 | tmp, sizeof(tmp)); | 292 | tmp, sizeof(tmp)); |
290 | } | 293 | } |
291 | 294 | ||
292 | static void setup_card(struct snd_usb_caiaqdev *dev) | 295 | static void setup_card(struct snd_usb_caiaqdev *cdev) |
293 | { | 296 | { |
294 | int ret; | 297 | int ret; |
295 | char val[4]; | 298 | char val[4]; |
299 | struct device *dev = caiaqdev_to_dev(cdev); | ||
296 | 300 | ||
297 | /* device-specific startup specials */ | 301 | /* device-specific startup specials */ |
298 | switch (dev->chip.usb_id) { | 302 | switch (cdev->chip.usb_id) { |
299 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 303 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
300 | /* RigKontrol2 - display centered dash ('-') */ | 304 | /* RigKontrol2 - display centered dash ('-') */ |
301 | val[0] = 0x00; | 305 | val[0] = 0x00; |
302 | val[1] = 0x00; | 306 | val[1] = 0x00; |
303 | val[2] = 0x01; | 307 | val[2] = 0x01; |
304 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 3); | 308 | snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 3); |
305 | break; | 309 | break; |
306 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 310 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
307 | /* RigKontrol2 - display two centered dashes ('--') */ | 311 | /* RigKontrol2 - display two centered dashes ('--') */ |
@@ -309,69 +313,69 @@ static void setup_card(struct snd_usb_caiaqdev *dev) | |||
309 | val[1] = 0x40; | 313 | val[1] = 0x40; |
310 | val[2] = 0x40; | 314 | val[2] = 0x40; |
311 | val[3] = 0x00; | 315 | val[3] = 0x00; |
312 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 4); | 316 | snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 4); |
313 | break; | 317 | break; |
314 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 318 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
315 | /* Audio Kontrol 1 - make USB-LED stop blinking */ | 319 | /* Audio Kontrol 1 - make USB-LED stop blinking */ |
316 | val[0] = 0x00; | 320 | val[0] = 0x00; |
317 | snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO, val, 1); | 321 | snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 1); |
318 | break; | 322 | break; |
319 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): | 323 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ): |
320 | /* Audio 8 DJ - trigger read of current settings */ | 324 | /* Audio 8 DJ - trigger read of current settings */ |
321 | dev->control_state[0] = 0xff; | 325 | cdev->control_state[0] = 0xff; |
322 | snd_usb_caiaq_set_auto_msg(dev, 1, 0, 0); | 326 | snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 0); |
323 | snd_usb_caiaq_send_command(dev, EP1_CMD_READ_IO, NULL, 0); | 327 | snd_usb_caiaq_send_command(cdev, EP1_CMD_READ_IO, NULL, 0); |
324 | 328 | ||
325 | if (!wait_event_timeout(dev->ep1_wait_queue, | 329 | if (!wait_event_timeout(cdev->ep1_wait_queue, |
326 | dev->control_state[0] != 0xff, HZ)) | 330 | cdev->control_state[0] != 0xff, HZ)) |
327 | return; | 331 | return; |
328 | 332 | ||
329 | /* fix up some defaults */ | 333 | /* fix up some defaults */ |
330 | if ((dev->control_state[1] != 2) || | 334 | if ((cdev->control_state[1] != 2) || |
331 | (dev->control_state[2] != 3) || | 335 | (cdev->control_state[2] != 3) || |
332 | (dev->control_state[4] != 2)) { | 336 | (cdev->control_state[4] != 2)) { |
333 | dev->control_state[1] = 2; | 337 | cdev->control_state[1] = 2; |
334 | dev->control_state[2] = 3; | 338 | cdev->control_state[2] = 3; |
335 | dev->control_state[4] = 2; | 339 | cdev->control_state[4] = 2; |
336 | snd_usb_caiaq_send_command(dev, | 340 | snd_usb_caiaq_send_command(cdev, |
337 | EP1_CMD_WRITE_IO, dev->control_state, 6); | 341 | EP1_CMD_WRITE_IO, cdev->control_state, 6); |
338 | } | 342 | } |
339 | 343 | ||
340 | break; | 344 | break; |
341 | } | 345 | } |
342 | 346 | ||
343 | if (dev->spec.num_analog_audio_out + | 347 | if (cdev->spec.num_analog_audio_out + |
344 | dev->spec.num_analog_audio_in + | 348 | cdev->spec.num_analog_audio_in + |
345 | dev->spec.num_digital_audio_out + | 349 | cdev->spec.num_digital_audio_out + |
346 | dev->spec.num_digital_audio_in > 0) { | 350 | cdev->spec.num_digital_audio_in > 0) { |
347 | ret = snd_usb_caiaq_audio_init(dev); | 351 | ret = snd_usb_caiaq_audio_init(cdev); |
348 | if (ret < 0) | 352 | if (ret < 0) |
349 | log("Unable to set up audio system (ret=%d)\n", ret); | 353 | dev_err(dev, "Unable to set up audio system (ret=%d)\n", ret); |
350 | } | 354 | } |
351 | 355 | ||
352 | if (dev->spec.num_midi_in + | 356 | if (cdev->spec.num_midi_in + |
353 | dev->spec.num_midi_out > 0) { | 357 | cdev->spec.num_midi_out > 0) { |
354 | ret = snd_usb_caiaq_midi_init(dev); | 358 | ret = snd_usb_caiaq_midi_init(cdev); |
355 | if (ret < 0) | 359 | if (ret < 0) |
356 | log("Unable to set up MIDI system (ret=%d)\n", ret); | 360 | dev_err(dev, "Unable to set up MIDI system (ret=%d)\n", ret); |
357 | } | 361 | } |
358 | 362 | ||
359 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 363 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
360 | ret = snd_usb_caiaq_input_init(dev); | 364 | ret = snd_usb_caiaq_input_init(cdev); |
361 | if (ret < 0) | 365 | if (ret < 0) |
362 | log("Unable to set up input system (ret=%d)\n", ret); | 366 | dev_err(dev, "Unable to set up input system (ret=%d)\n", ret); |
363 | #endif | 367 | #endif |
364 | 368 | ||
365 | /* finally, register the card and all its sub-instances */ | 369 | /* finally, register the card and all its sub-instances */ |
366 | ret = snd_card_register(dev->chip.card); | 370 | ret = snd_card_register(cdev->chip.card); |
367 | if (ret < 0) { | 371 | if (ret < 0) { |
368 | log("snd_card_register() returned %d\n", ret); | 372 | dev_err(dev, "snd_card_register() returned %d\n", ret); |
369 | snd_card_free(dev->chip.card); | 373 | snd_card_free(cdev->chip.card); |
370 | } | 374 | } |
371 | 375 | ||
372 | ret = snd_usb_caiaq_control_init(dev); | 376 | ret = snd_usb_caiaq_control_init(cdev); |
373 | if (ret < 0) | 377 | if (ret < 0) |
374 | log("Unable to set up control system (ret=%d)\n", ret); | 378 | dev_err(dev, "Unable to set up control system (ret=%d)\n", ret); |
375 | } | 379 | } |
376 | 380 | ||
377 | static int create_card(struct usb_device *usb_dev, | 381 | static int create_card(struct usb_device *usb_dev, |
@@ -381,7 +385,7 @@ static int create_card(struct usb_device *usb_dev, | |||
381 | int devnum; | 385 | int devnum; |
382 | int err; | 386 | int err; |
383 | struct snd_card *card; | 387 | struct snd_card *card; |
384 | struct snd_usb_caiaqdev *dev; | 388 | struct snd_usb_caiaqdev *cdev; |
385 | 389 | ||
386 | for (devnum = 0; devnum < SNDRV_CARDS; devnum++) | 390 | for (devnum = 0; devnum < SNDRV_CARDS; devnum++) |
387 | if (enable[devnum] && !snd_card_used[devnum]) | 391 | if (enable[devnum] && !snd_card_used[devnum]) |
@@ -395,65 +399,66 @@ static int create_card(struct usb_device *usb_dev, | |||
395 | if (err < 0) | 399 | if (err < 0) |
396 | return err; | 400 | return err; |
397 | 401 | ||
398 | dev = caiaqdev(card); | 402 | cdev = caiaqdev(card); |
399 | dev->chip.dev = usb_dev; | 403 | cdev->chip.dev = usb_dev; |
400 | dev->chip.card = card; | 404 | cdev->chip.card = card; |
401 | dev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), | 405 | cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), |
402 | le16_to_cpu(usb_dev->descriptor.idProduct)); | 406 | le16_to_cpu(usb_dev->descriptor.idProduct)); |
403 | spin_lock_init(&dev->spinlock); | 407 | spin_lock_init(&cdev->spinlock); |
404 | snd_card_set_dev(card, &intf->dev); | 408 | snd_card_set_dev(card, &intf->dev); |
405 | 409 | ||
406 | *cardp = card; | 410 | *cardp = card; |
407 | return 0; | 411 | return 0; |
408 | } | 412 | } |
409 | 413 | ||
410 | static int init_card(struct snd_usb_caiaqdev *dev) | 414 | static int init_card(struct snd_usb_caiaqdev *cdev) |
411 | { | 415 | { |
412 | char *c, usbpath[32]; | 416 | char *c, usbpath[32]; |
413 | struct usb_device *usb_dev = dev->chip.dev; | 417 | struct usb_device *usb_dev = cdev->chip.dev; |
414 | struct snd_card *card = dev->chip.card; | 418 | struct snd_card *card = cdev->chip.card; |
419 | struct device *dev = caiaqdev_to_dev(cdev); | ||
415 | int err, len; | 420 | int err, len; |
416 | 421 | ||
417 | if (usb_set_interface(usb_dev, 0, 1) != 0) { | 422 | if (usb_set_interface(usb_dev, 0, 1) != 0) { |
418 | log("can't set alt interface.\n"); | 423 | dev_err(dev, "can't set alt interface.\n"); |
419 | return -EIO; | 424 | return -EIO; |
420 | } | 425 | } |
421 | 426 | ||
422 | usb_init_urb(&dev->ep1_in_urb); | 427 | usb_init_urb(&cdev->ep1_in_urb); |
423 | usb_init_urb(&dev->midi_out_urb); | 428 | usb_init_urb(&cdev->midi_out_urb); |
424 | 429 | ||
425 | usb_fill_bulk_urb(&dev->ep1_in_urb, usb_dev, | 430 | usb_fill_bulk_urb(&cdev->ep1_in_urb, usb_dev, |
426 | usb_rcvbulkpipe(usb_dev, 0x1), | 431 | usb_rcvbulkpipe(usb_dev, 0x1), |
427 | dev->ep1_in_buf, EP1_BUFSIZE, | 432 | cdev->ep1_in_buf, EP1_BUFSIZE, |
428 | usb_ep1_command_reply_dispatch, dev); | 433 | usb_ep1_command_reply_dispatch, cdev); |
429 | 434 | ||
430 | usb_fill_bulk_urb(&dev->midi_out_urb, usb_dev, | 435 | usb_fill_bulk_urb(&cdev->midi_out_urb, usb_dev, |
431 | usb_sndbulkpipe(usb_dev, 0x1), | 436 | usb_sndbulkpipe(usb_dev, 0x1), |
432 | dev->midi_out_buf, EP1_BUFSIZE, | 437 | cdev->midi_out_buf, EP1_BUFSIZE, |
433 | snd_usb_caiaq_midi_output_done, dev); | 438 | snd_usb_caiaq_midi_output_done, cdev); |
434 | 439 | ||
435 | init_waitqueue_head(&dev->ep1_wait_queue); | 440 | init_waitqueue_head(&cdev->ep1_wait_queue); |
436 | init_waitqueue_head(&dev->prepare_wait_queue); | 441 | init_waitqueue_head(&cdev->prepare_wait_queue); |
437 | 442 | ||
438 | if (usb_submit_urb(&dev->ep1_in_urb, GFP_KERNEL) != 0) | 443 | if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0) |
439 | return -EIO; | 444 | return -EIO; |
440 | 445 | ||
441 | err = snd_usb_caiaq_send_command(dev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); | 446 | err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); |
442 | if (err) | 447 | if (err) |
443 | return err; | 448 | return err; |
444 | 449 | ||
445 | if (!wait_event_timeout(dev->ep1_wait_queue, dev->spec_received, HZ)) | 450 | if (!wait_event_timeout(cdev->ep1_wait_queue, cdev->spec_received, HZ)) |
446 | return -ENODEV; | 451 | return -ENODEV; |
447 | 452 | ||
448 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, | 453 | usb_string(usb_dev, usb_dev->descriptor.iManufacturer, |
449 | dev->vendor_name, CAIAQ_USB_STR_LEN); | 454 | cdev->vendor_name, CAIAQ_USB_STR_LEN); |
450 | 455 | ||
451 | usb_string(usb_dev, usb_dev->descriptor.iProduct, | 456 | usb_string(usb_dev, usb_dev->descriptor.iProduct, |
452 | dev->product_name, CAIAQ_USB_STR_LEN); | 457 | cdev->product_name, CAIAQ_USB_STR_LEN); |
453 | 458 | ||
454 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); | 459 | strlcpy(card->driver, MODNAME, sizeof(card->driver)); |
455 | strlcpy(card->shortname, dev->product_name, sizeof(card->shortname)); | 460 | strlcpy(card->shortname, cdev->product_name, sizeof(card->shortname)); |
456 | strlcpy(card->mixername, dev->product_name, sizeof(card->mixername)); | 461 | strlcpy(card->mixername, cdev->product_name, sizeof(card->mixername)); |
457 | 462 | ||
458 | /* if the id was not passed as module option, fill it with a shortened | 463 | /* if the id was not passed as module option, fill it with a shortened |
459 | * version of the product string which does not contain any | 464 | * version of the product string which does not contain any |
@@ -473,11 +478,10 @@ static int init_card(struct snd_usb_caiaqdev *dev) | |||
473 | } | 478 | } |
474 | 479 | ||
475 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); | 480 | usb_make_path(usb_dev, usbpath, sizeof(usbpath)); |
476 | snprintf(card->longname, sizeof(card->longname), | 481 | snprintf(card->longname, sizeof(card->longname), "%s %s (%s)", |
477 | "%s %s (%s)", | 482 | cdev->vendor_name, cdev->product_name, usbpath); |
478 | dev->vendor_name, dev->product_name, usbpath); | ||
479 | 483 | ||
480 | setup_card(dev); | 484 | setup_card(cdev); |
481 | return 0; | 485 | return 0; |
482 | } | 486 | } |
483 | 487 | ||
@@ -486,9 +490,9 @@ static int snd_probe(struct usb_interface *intf, | |||
486 | { | 490 | { |
487 | int ret; | 491 | int ret; |
488 | struct snd_card *card = NULL; | 492 | struct snd_card *card = NULL; |
489 | struct usb_device *device = interface_to_usbdev(intf); | 493 | struct usb_device *usb_dev = interface_to_usbdev(intf); |
490 | 494 | ||
491 | ret = create_card(device, intf, &card); | 495 | ret = create_card(usb_dev, intf, &card); |
492 | 496 | ||
493 | if (ret < 0) | 497 | if (ret < 0) |
494 | return ret; | 498 | return ret; |
@@ -496,7 +500,7 @@ static int snd_probe(struct usb_interface *intf, | |||
496 | usb_set_intfdata(intf, card); | 500 | usb_set_intfdata(intf, card); |
497 | ret = init_card(caiaqdev(card)); | 501 | ret = init_card(caiaqdev(card)); |
498 | if (ret < 0) { | 502 | if (ret < 0) { |
499 | log("unable to init card! (ret=%d)\n", ret); | 503 | dev_err(&usb_dev->dev, "unable to init card! (ret=%d)\n", ret); |
500 | snd_card_free(card); | 504 | snd_card_free(card); |
501 | return ret; | 505 | return ret; |
502 | } | 506 | } |
@@ -506,24 +510,25 @@ static int snd_probe(struct usb_interface *intf, | |||
506 | 510 | ||
507 | static void snd_disconnect(struct usb_interface *intf) | 511 | static void snd_disconnect(struct usb_interface *intf) |
508 | { | 512 | { |
509 | struct snd_usb_caiaqdev *dev; | ||
510 | struct snd_card *card = usb_get_intfdata(intf); | 513 | struct snd_card *card = usb_get_intfdata(intf); |
511 | 514 | struct device *dev = intf->usb_dev; | |
512 | debug("%s(%p)\n", __func__, intf); | 515 | struct snd_usb_caiaqdev *cdev; |
513 | 516 | ||
514 | if (!card) | 517 | if (!card) |
515 | return; | 518 | return; |
516 | 519 | ||
517 | dev = caiaqdev(card); | 520 | cdev = caiaqdev(card); |
521 | dev_dbg(dev, "%s(%p)\n", __func__, intf); | ||
522 | |||
518 | snd_card_disconnect(card); | 523 | snd_card_disconnect(card); |
519 | 524 | ||
520 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT | 525 | #ifdef CONFIG_SND_USB_CAIAQ_INPUT |
521 | snd_usb_caiaq_input_free(dev); | 526 | snd_usb_caiaq_input_free(cdev); |
522 | #endif | 527 | #endif |
523 | snd_usb_caiaq_audio_free(dev); | 528 | snd_usb_caiaq_audio_free(cdev); |
524 | 529 | ||
525 | usb_kill_urb(&dev->ep1_in_urb); | 530 | usb_kill_urb(&cdev->ep1_in_urb); |
526 | usb_kill_urb(&dev->midi_out_urb); | 531 | usb_kill_urb(&cdev->midi_out_urb); |
527 | 532 | ||
528 | snd_card_free(card); | 533 | snd_card_free(card); |
529 | usb_reset_device(interface_to_usbdev(intf)); | 534 | usb_reset_device(interface_to_usbdev(intf)); |
@@ -539,4 +544,3 @@ static struct usb_driver snd_usb_driver = { | |||
539 | }; | 544 | }; |
540 | 545 | ||
541 | module_usb_driver(snd_usb_driver); | 546 | module_usb_driver(snd_usb_driver); |
542 | |||
diff --git a/sound/usb/caiaq/device.h b/sound/usb/caiaq/device.h index 562b0bff9c41..ad102fac6942 100644 --- a/sound/usb/caiaq/device.h +++ b/sound/usb/caiaq/device.h | |||
@@ -25,16 +25,7 @@ | |||
25 | #define CAIAQ_USB_STR_LEN 0xff | 25 | #define CAIAQ_USB_STR_LEN 0xff |
26 | #define MAX_STREAMS 32 | 26 | #define MAX_STREAMS 32 |
27 | 27 | ||
28 | //#define SND_USB_CAIAQ_DEBUG | ||
29 | |||
30 | #define MODNAME "snd-usb-caiaq" | 28 | #define MODNAME "snd-usb-caiaq" |
31 | #define log(x...) snd_printk(KERN_WARNING MODNAME" log: " x) | ||
32 | |||
33 | #ifdef SND_USB_CAIAQ_DEBUG | ||
34 | #define debug(x...) snd_printk(KERN_WARNING MODNAME " debug: " x) | ||
35 | #else | ||
36 | #define debug(x...) do { } while(0) | ||
37 | #endif | ||
38 | 29 | ||
39 | #define EP1_CMD_GET_DEVICE_INFO 0x1 | 30 | #define EP1_CMD_GET_DEVICE_INFO 0x1 |
40 | #define EP1_CMD_READ_ERP 0x2 | 31 | #define EP1_CMD_READ_ERP 0x2 |
@@ -124,15 +115,16 @@ struct snd_usb_caiaqdev { | |||
124 | }; | 115 | }; |
125 | 116 | ||
126 | struct snd_usb_caiaq_cb_info { | 117 | struct snd_usb_caiaq_cb_info { |
127 | struct snd_usb_caiaqdev *dev; | 118 | struct snd_usb_caiaqdev *cdev; |
128 | int index; | 119 | int index; |
129 | }; | 120 | }; |
130 | 121 | ||
131 | #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data) | 122 | #define caiaqdev(c) ((struct snd_usb_caiaqdev*)(c)->private_data) |
123 | #define caiaqdev_to_dev(d) (d->chip.card->dev) | ||
132 | 124 | ||
133 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev, int rate, int depth, int bbp); | 125 | int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, int rate, int depth, int bbp); |
134 | int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *dev, int digital, int analog, int erp); | 126 | int snd_usb_caiaq_set_auto_msg (struct snd_usb_caiaqdev *cdev, int digital, int analog, int erp); |
135 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *dev, | 127 | int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, |
136 | unsigned char command, | 128 | unsigned char command, |
137 | const unsigned char *buffer, | 129 | const unsigned char *buffer, |
138 | int len); | 130 | int len); |
diff --git a/sound/usb/caiaq/input.c b/sound/usb/caiaq/input.c index 26a121b42c3c..efc70ae915c5 100644 --- a/sound/usb/caiaq/input.c +++ b/sound/usb/caiaq/input.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/device.h> | ||
19 | #include <linux/gfp.h> | 20 | #include <linux/gfp.h> |
20 | #include <linux/init.h> | 21 | #include <linux/init.h> |
21 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
@@ -199,55 +200,55 @@ static unsigned int decode_erp(unsigned char a, unsigned char b) | |||
199 | #undef HIGH_PEAK | 200 | #undef HIGH_PEAK |
200 | #undef LOW_PEAK | 201 | #undef LOW_PEAK |
201 | 202 | ||
202 | static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *dev, | 203 | static inline void snd_caiaq_input_report_abs(struct snd_usb_caiaqdev *cdev, |
203 | int axis, const unsigned char *buf, | 204 | int axis, const unsigned char *buf, |
204 | int offset) | 205 | int offset) |
205 | { | 206 | { |
206 | input_report_abs(dev->input_dev, axis, | 207 | input_report_abs(cdev->input_dev, axis, |
207 | (buf[offset * 2] << 8) | buf[offset * 2 + 1]); | 208 | (buf[offset * 2] << 8) | buf[offset * 2 + 1]); |
208 | } | 209 | } |
209 | 210 | ||
210 | static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *dev, | 211 | static void snd_caiaq_input_read_analog(struct snd_usb_caiaqdev *cdev, |
211 | const unsigned char *buf, | 212 | const unsigned char *buf, |
212 | unsigned int len) | 213 | unsigned int len) |
213 | { | 214 | { |
214 | struct input_dev *input_dev = dev->input_dev; | 215 | struct input_dev *input_dev = cdev->input_dev; |
215 | 216 | ||
216 | switch (dev->chip.usb_id) { | 217 | switch (cdev->chip.usb_id) { |
217 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 218 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
218 | snd_caiaq_input_report_abs(dev, ABS_X, buf, 2); | 219 | snd_caiaq_input_report_abs(cdev, ABS_X, buf, 2); |
219 | snd_caiaq_input_report_abs(dev, ABS_Y, buf, 0); | 220 | snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 0); |
220 | snd_caiaq_input_report_abs(dev, ABS_Z, buf, 1); | 221 | snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 1); |
221 | break; | 222 | break; |
222 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 223 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
223 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 224 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
224 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 225 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
225 | snd_caiaq_input_report_abs(dev, ABS_X, buf, 0); | 226 | snd_caiaq_input_report_abs(cdev, ABS_X, buf, 0); |
226 | snd_caiaq_input_report_abs(dev, ABS_Y, buf, 1); | 227 | snd_caiaq_input_report_abs(cdev, ABS_Y, buf, 1); |
227 | snd_caiaq_input_report_abs(dev, ABS_Z, buf, 2); | 228 | snd_caiaq_input_report_abs(cdev, ABS_Z, buf, 2); |
228 | break; | 229 | break; |
229 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 230 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
230 | snd_caiaq_input_report_abs(dev, ABS_HAT0X, buf, 4); | 231 | snd_caiaq_input_report_abs(cdev, ABS_HAT0X, buf, 4); |
231 | snd_caiaq_input_report_abs(dev, ABS_HAT0Y, buf, 2); | 232 | snd_caiaq_input_report_abs(cdev, ABS_HAT0Y, buf, 2); |
232 | snd_caiaq_input_report_abs(dev, ABS_HAT1X, buf, 6); | 233 | snd_caiaq_input_report_abs(cdev, ABS_HAT1X, buf, 6); |
233 | snd_caiaq_input_report_abs(dev, ABS_HAT1Y, buf, 1); | 234 | snd_caiaq_input_report_abs(cdev, ABS_HAT1Y, buf, 1); |
234 | snd_caiaq_input_report_abs(dev, ABS_HAT2X, buf, 7); | 235 | snd_caiaq_input_report_abs(cdev, ABS_HAT2X, buf, 7); |
235 | snd_caiaq_input_report_abs(dev, ABS_HAT2Y, buf, 0); | 236 | snd_caiaq_input_report_abs(cdev, ABS_HAT2Y, buf, 0); |
236 | snd_caiaq_input_report_abs(dev, ABS_HAT3X, buf, 5); | 237 | snd_caiaq_input_report_abs(cdev, ABS_HAT3X, buf, 5); |
237 | snd_caiaq_input_report_abs(dev, ABS_HAT3Y, buf, 3); | 238 | snd_caiaq_input_report_abs(cdev, ABS_HAT3Y, buf, 3); |
238 | break; | 239 | break; |
239 | } | 240 | } |
240 | 241 | ||
241 | input_sync(input_dev); | 242 | input_sync(input_dev); |
242 | } | 243 | } |
243 | 244 | ||
244 | static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, | 245 | static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *cdev, |
245 | const char *buf, unsigned int len) | 246 | const char *buf, unsigned int len) |
246 | { | 247 | { |
247 | struct input_dev *input_dev = dev->input_dev; | 248 | struct input_dev *input_dev = cdev->input_dev; |
248 | int i; | 249 | int i; |
249 | 250 | ||
250 | switch (dev->chip.usb_id) { | 251 | switch (cdev->chip.usb_id) { |
251 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 252 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
252 | i = decode_erp(buf[0], buf[1]); | 253 | i = decode_erp(buf[0], buf[1]); |
253 | input_report_abs(input_dev, ABS_X, i); | 254 | input_report_abs(input_dev, ABS_X, i); |
@@ -299,10 +300,10 @@ static void snd_caiaq_input_read_erp(struct snd_usb_caiaqdev *dev, | |||
299 | } | 300 | } |
300 | } | 301 | } |
301 | 302 | ||
302 | static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, | 303 | static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *cdev, |
303 | unsigned char *buf, unsigned int len) | 304 | unsigned char *buf, unsigned int len) |
304 | { | 305 | { |
305 | struct input_dev *input_dev = dev->input_dev; | 306 | struct input_dev *input_dev = cdev->input_dev; |
306 | unsigned short *keycode = input_dev->keycode; | 307 | unsigned short *keycode = input_dev->keycode; |
307 | int i; | 308 | int i; |
308 | 309 | ||
@@ -317,17 +318,17 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, | |||
317 | input_report_key(input_dev, keycode[i], | 318 | input_report_key(input_dev, keycode[i], |
318 | buf[i / 8] & (1 << (i % 8))); | 319 | buf[i / 8] & (1 << (i % 8))); |
319 | 320 | ||
320 | switch (dev->chip.usb_id) { | 321 | switch (cdev->chip.usb_id) { |
321 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 322 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
322 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 323 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
323 | input_report_abs(dev->input_dev, ABS_MISC, 255 - buf[4]); | 324 | input_report_abs(cdev->input_dev, ABS_MISC, 255 - buf[4]); |
324 | break; | 325 | break; |
325 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 326 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
326 | /* rotary encoders */ | 327 | /* rotary encoders */ |
327 | input_report_abs(dev->input_dev, ABS_X, buf[5] & 0xf); | 328 | input_report_abs(cdev->input_dev, ABS_X, buf[5] & 0xf); |
328 | input_report_abs(dev->input_dev, ABS_Y, buf[5] >> 4); | 329 | input_report_abs(cdev->input_dev, ABS_Y, buf[5] >> 4); |
329 | input_report_abs(dev->input_dev, ABS_Z, buf[6] & 0xf); | 330 | input_report_abs(cdev->input_dev, ABS_Z, buf[6] & 0xf); |
330 | input_report_abs(dev->input_dev, ABS_MISC, buf[6] >> 4); | 331 | input_report_abs(cdev->input_dev, ABS_MISC, buf[6] >> 4); |
331 | break; | 332 | break; |
332 | } | 333 | } |
333 | 334 | ||
@@ -336,10 +337,12 @@ static void snd_caiaq_input_read_io(struct snd_usb_caiaqdev *dev, | |||
336 | 337 | ||
337 | #define TKS4_MSGBLOCK_SIZE 16 | 338 | #define TKS4_MSGBLOCK_SIZE 16 |
338 | 339 | ||
339 | static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, | 340 | static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *cdev, |
340 | const unsigned char *buf, | 341 | const unsigned char *buf, |
341 | unsigned int len) | 342 | unsigned int len) |
342 | { | 343 | { |
344 | struct device *dev = caiaqdev_to_dev(cdev); | ||
345 | |||
343 | while (len) { | 346 | while (len) { |
344 | unsigned int i, block_id = (buf[0] << 8) | buf[1]; | 347 | unsigned int i, block_id = (buf[0] << 8) | buf[1]; |
345 | 348 | ||
@@ -347,126 +350,126 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, | |||
347 | case 0: | 350 | case 0: |
348 | /* buttons */ | 351 | /* buttons */ |
349 | for (i = 0; i < KONTROLS4_BUTTONS; i++) | 352 | for (i = 0; i < KONTROLS4_BUTTONS; i++) |
350 | input_report_key(dev->input_dev, KONTROLS4_BUTTON(i), | 353 | input_report_key(cdev->input_dev, KONTROLS4_BUTTON(i), |
351 | (buf[4 + (i / 8)] >> (i % 8)) & 1); | 354 | (buf[4 + (i / 8)] >> (i % 8)) & 1); |
352 | break; | 355 | break; |
353 | 356 | ||
354 | case 1: | 357 | case 1: |
355 | /* left wheel */ | 358 | /* left wheel */ |
356 | input_report_abs(dev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8)); | 359 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(36), buf[9] | ((buf[8] & 0x3) << 8)); |
357 | /* right wheel */ | 360 | /* right wheel */ |
358 | input_report_abs(dev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8)); | 361 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(37), buf[13] | ((buf[12] & 0x3) << 8)); |
359 | 362 | ||
360 | /* rotary encoders */ | 363 | /* rotary encoders */ |
361 | input_report_abs(dev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf); | 364 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(38), buf[3] & 0xf); |
362 | input_report_abs(dev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4); | 365 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(39), buf[4] >> 4); |
363 | input_report_abs(dev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf); | 366 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(40), buf[4] & 0xf); |
364 | input_report_abs(dev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4); | 367 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(41), buf[5] >> 4); |
365 | input_report_abs(dev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf); | 368 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(42), buf[5] & 0xf); |
366 | input_report_abs(dev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4); | 369 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(43), buf[6] >> 4); |
367 | input_report_abs(dev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf); | 370 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(44), buf[6] & 0xf); |
368 | input_report_abs(dev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4); | 371 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(45), buf[7] >> 4); |
369 | input_report_abs(dev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf); | 372 | input_report_abs(cdev->input_dev, KONTROLS4_ABS(46), buf[7] & 0xf); |
370 | 373 | ||
371 | break; | 374 | break; |
372 | case 2: | 375 | case 2: |
373 | /* Volume Fader Channel D */ | 376 | /* Volume Fader Channel D */ |
374 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(0), buf, 1); | 377 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(0), buf, 1); |
375 | /* Volume Fader Channel B */ | 378 | /* Volume Fader Channel B */ |
376 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(1), buf, 2); | 379 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(1), buf, 2); |
377 | /* Volume Fader Channel A */ | 380 | /* Volume Fader Channel A */ |
378 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(2), buf, 3); | 381 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(2), buf, 3); |
379 | /* Volume Fader Channel C */ | 382 | /* Volume Fader Channel C */ |
380 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(3), buf, 4); | 383 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(3), buf, 4); |
381 | /* Loop Volume */ | 384 | /* Loop Volume */ |
382 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(4), buf, 6); | 385 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(4), buf, 6); |
383 | /* Crossfader */ | 386 | /* Crossfader */ |
384 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(7), buf, 7); | 387 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(7), buf, 7); |
385 | 388 | ||
386 | break; | 389 | break; |
387 | 390 | ||
388 | case 3: | 391 | case 3: |
389 | /* Tempo Fader R */ | 392 | /* Tempo Fader R */ |
390 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(6), buf, 3); | 393 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(6), buf, 3); |
391 | /* Tempo Fader L */ | 394 | /* Tempo Fader L */ |
392 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(5), buf, 4); | 395 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(5), buf, 4); |
393 | /* Mic Volume */ | 396 | /* Mic Volume */ |
394 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(8), buf, 6); | 397 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(8), buf, 6); |
395 | /* Cue Mix */ | 398 | /* Cue Mix */ |
396 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(9), buf, 7); | 399 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(9), buf, 7); |
397 | 400 | ||
398 | break; | 401 | break; |
399 | 402 | ||
400 | case 4: | 403 | case 4: |
401 | /* Wheel distance sensor L */ | 404 | /* Wheel distance sensor L */ |
402 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(10), buf, 1); | 405 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(10), buf, 1); |
403 | /* Wheel distance sensor R */ | 406 | /* Wheel distance sensor R */ |
404 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(11), buf, 2); | 407 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(11), buf, 2); |
405 | /* Channel D EQ - Filter */ | 408 | /* Channel D EQ - Filter */ |
406 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(12), buf, 3); | 409 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(12), buf, 3); |
407 | /* Channel D EQ - Low */ | 410 | /* Channel D EQ - Low */ |
408 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(13), buf, 4); | 411 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(13), buf, 4); |
409 | /* Channel D EQ - Mid */ | 412 | /* Channel D EQ - Mid */ |
410 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(14), buf, 5); | 413 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(14), buf, 5); |
411 | /* Channel D EQ - Hi */ | 414 | /* Channel D EQ - Hi */ |
412 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(15), buf, 6); | 415 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(15), buf, 6); |
413 | /* FX2 - dry/wet */ | 416 | /* FX2 - dry/wet */ |
414 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(16), buf, 7); | 417 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(16), buf, 7); |
415 | 418 | ||
416 | break; | 419 | break; |
417 | 420 | ||
418 | case 5: | 421 | case 5: |
419 | /* FX2 - 1 */ | 422 | /* FX2 - 1 */ |
420 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(17), buf, 1); | 423 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(17), buf, 1); |
421 | /* FX2 - 2 */ | 424 | /* FX2 - 2 */ |
422 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(18), buf, 2); | 425 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(18), buf, 2); |
423 | /* FX2 - 3 */ | 426 | /* FX2 - 3 */ |
424 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(19), buf, 3); | 427 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(19), buf, 3); |
425 | /* Channel B EQ - Filter */ | 428 | /* Channel B EQ - Filter */ |
426 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(20), buf, 4); | 429 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(20), buf, 4); |
427 | /* Channel B EQ - Low */ | 430 | /* Channel B EQ - Low */ |
428 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(21), buf, 5); | 431 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(21), buf, 5); |
429 | /* Channel B EQ - Mid */ | 432 | /* Channel B EQ - Mid */ |
430 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(22), buf, 6); | 433 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(22), buf, 6); |
431 | /* Channel B EQ - Hi */ | 434 | /* Channel B EQ - Hi */ |
432 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(23), buf, 7); | 435 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(23), buf, 7); |
433 | 436 | ||
434 | break; | 437 | break; |
435 | 438 | ||
436 | case 6: | 439 | case 6: |
437 | /* Channel A EQ - Filter */ | 440 | /* Channel A EQ - Filter */ |
438 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(24), buf, 1); | 441 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(24), buf, 1); |
439 | /* Channel A EQ - Low */ | 442 | /* Channel A EQ - Low */ |
440 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(25), buf, 2); | 443 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(25), buf, 2); |
441 | /* Channel A EQ - Mid */ | 444 | /* Channel A EQ - Mid */ |
442 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(26), buf, 3); | 445 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(26), buf, 3); |
443 | /* Channel A EQ - Hi */ | 446 | /* Channel A EQ - Hi */ |
444 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(27), buf, 4); | 447 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(27), buf, 4); |
445 | /* Channel C EQ - Filter */ | 448 | /* Channel C EQ - Filter */ |
446 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(28), buf, 5); | 449 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(28), buf, 5); |
447 | /* Channel C EQ - Low */ | 450 | /* Channel C EQ - Low */ |
448 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(29), buf, 6); | 451 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(29), buf, 6); |
449 | /* Channel C EQ - Mid */ | 452 | /* Channel C EQ - Mid */ |
450 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(30), buf, 7); | 453 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(30), buf, 7); |
451 | 454 | ||
452 | break; | 455 | break; |
453 | 456 | ||
454 | case 7: | 457 | case 7: |
455 | /* Channel C EQ - Hi */ | 458 | /* Channel C EQ - Hi */ |
456 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(31), buf, 1); | 459 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(31), buf, 1); |
457 | /* FX1 - wet/dry */ | 460 | /* FX1 - wet/dry */ |
458 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(32), buf, 2); | 461 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(32), buf, 2); |
459 | /* FX1 - 1 */ | 462 | /* FX1 - 1 */ |
460 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(33), buf, 3); | 463 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(33), buf, 3); |
461 | /* FX1 - 2 */ | 464 | /* FX1 - 2 */ |
462 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(34), buf, 4); | 465 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(34), buf, 4); |
463 | /* FX1 - 3 */ | 466 | /* FX1 - 3 */ |
464 | snd_caiaq_input_report_abs(dev, KONTROLS4_ABS(35), buf, 5); | 467 | snd_caiaq_input_report_abs(cdev, KONTROLS4_ABS(35), buf, 5); |
465 | 468 | ||
466 | break; | 469 | break; |
467 | 470 | ||
468 | default: | 471 | default: |
469 | debug("%s(): bogus block (id %d)\n", | 472 | dev_dbg(dev, "%s(): bogus block (id %d)\n", |
470 | __func__, block_id); | 473 | __func__, block_id); |
471 | return; | 474 | return; |
472 | } | 475 | } |
@@ -475,12 +478,12 @@ static void snd_usb_caiaq_tks4_dispatch(struct snd_usb_caiaqdev *dev, | |||
475 | buf += TKS4_MSGBLOCK_SIZE; | 478 | buf += TKS4_MSGBLOCK_SIZE; |
476 | } | 479 | } |
477 | 480 | ||
478 | input_sync(dev->input_dev); | 481 | input_sync(cdev->input_dev); |
479 | } | 482 | } |
480 | 483 | ||
481 | #define MASCHINE_MSGBLOCK_SIZE 2 | 484 | #define MASCHINE_MSGBLOCK_SIZE 2 |
482 | 485 | ||
483 | static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev, | 486 | static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *cdev, |
484 | const unsigned char *buf, | 487 | const unsigned char *buf, |
485 | unsigned int len) | 488 | unsigned int len) |
486 | { | 489 | { |
@@ -491,65 +494,66 @@ static void snd_usb_caiaq_maschine_dispatch(struct snd_usb_caiaqdev *dev, | |||
491 | pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); | 494 | pressure = be16_to_cpu(buf[i * 2] << 8 | buf[(i * 2) + 1]); |
492 | pad_id = pressure >> 12; | 495 | pad_id = pressure >> 12; |
493 | 496 | ||
494 | input_report_abs(dev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); | 497 | input_report_abs(cdev->input_dev, MASCHINE_PAD(pad_id), pressure & 0xfff); |
495 | } | 498 | } |
496 | 499 | ||
497 | input_sync(dev->input_dev); | 500 | input_sync(cdev->input_dev); |
498 | } | 501 | } |
499 | 502 | ||
500 | static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) | 503 | static void snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) |
501 | { | 504 | { |
502 | struct snd_usb_caiaqdev *dev = urb->context; | 505 | struct snd_usb_caiaqdev *cdev = urb->context; |
503 | unsigned char *buf = urb->transfer_buffer; | 506 | unsigned char *buf = urb->transfer_buffer; |
507 | struct device *dev = &urb->dev->dev; | ||
504 | int ret; | 508 | int ret; |
505 | 509 | ||
506 | if (urb->status || !dev || urb != dev->ep4_in_urb) | 510 | if (urb->status || !cdev || urb != cdev->ep4_in_urb) |
507 | return; | 511 | return; |
508 | 512 | ||
509 | switch (dev->chip.usb_id) { | 513 | switch (cdev->chip.usb_id) { |
510 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 514 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
511 | if (urb->actual_length < 24) | 515 | if (urb->actual_length < 24) |
512 | goto requeue; | 516 | goto requeue; |
513 | 517 | ||
514 | if (buf[0] & 0x3) | 518 | if (buf[0] & 0x3) |
515 | snd_caiaq_input_read_io(dev, buf + 1, 7); | 519 | snd_caiaq_input_read_io(cdev, buf + 1, 7); |
516 | 520 | ||
517 | if (buf[0] & 0x4) | 521 | if (buf[0] & 0x4) |
518 | snd_caiaq_input_read_analog(dev, buf + 8, 16); | 522 | snd_caiaq_input_read_analog(cdev, buf + 8, 16); |
519 | 523 | ||
520 | break; | 524 | break; |
521 | 525 | ||
522 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 526 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
523 | snd_usb_caiaq_tks4_dispatch(dev, buf, urb->actual_length); | 527 | snd_usb_caiaq_tks4_dispatch(cdev, buf, urb->actual_length); |
524 | break; | 528 | break; |
525 | 529 | ||
526 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): | 530 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): |
527 | if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE)) | 531 | if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE)) |
528 | goto requeue; | 532 | goto requeue; |
529 | 533 | ||
530 | snd_usb_caiaq_maschine_dispatch(dev, buf, urb->actual_length); | 534 | snd_usb_caiaq_maschine_dispatch(cdev, buf, urb->actual_length); |
531 | break; | 535 | break; |
532 | } | 536 | } |
533 | 537 | ||
534 | requeue: | 538 | requeue: |
535 | dev->ep4_in_urb->actual_length = 0; | 539 | cdev->ep4_in_urb->actual_length = 0; |
536 | ret = usb_submit_urb(dev->ep4_in_urb, GFP_ATOMIC); | 540 | ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC); |
537 | if (ret < 0) | 541 | if (ret < 0) |
538 | log("unable to submit urb. OOM!?\n"); | 542 | dev_err(dev, "unable to submit urb. OOM!?\n"); |
539 | } | 543 | } |
540 | 544 | ||
541 | static int snd_usb_caiaq_input_open(struct input_dev *idev) | 545 | static int snd_usb_caiaq_input_open(struct input_dev *idev) |
542 | { | 546 | { |
543 | struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); | 547 | struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev); |
544 | 548 | ||
545 | if (!dev) | 549 | if (!cdev) |
546 | return -EINVAL; | 550 | return -EINVAL; |
547 | 551 | ||
548 | switch (dev->chip.usb_id) { | 552 | switch (cdev->chip.usb_id) { |
549 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 553 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
550 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 554 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
551 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): | 555 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): |
552 | if (usb_submit_urb(dev->ep4_in_urb, GFP_KERNEL) != 0) | 556 | if (usb_submit_urb(cdev->ep4_in_urb, GFP_KERNEL) != 0) |
553 | return -EIO; | 557 | return -EIO; |
554 | break; | 558 | break; |
555 | } | 559 | } |
@@ -559,43 +563,43 @@ static int snd_usb_caiaq_input_open(struct input_dev *idev) | |||
559 | 563 | ||
560 | static void snd_usb_caiaq_input_close(struct input_dev *idev) | 564 | static void snd_usb_caiaq_input_close(struct input_dev *idev) |
561 | { | 565 | { |
562 | struct snd_usb_caiaqdev *dev = input_get_drvdata(idev); | 566 | struct snd_usb_caiaqdev *cdev = input_get_drvdata(idev); |
563 | 567 | ||
564 | if (!dev) | 568 | if (!cdev) |
565 | return; | 569 | return; |
566 | 570 | ||
567 | switch (dev->chip.usb_id) { | 571 | switch (cdev->chip.usb_id) { |
568 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 572 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
569 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 573 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
570 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): | 574 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): |
571 | usb_kill_urb(dev->ep4_in_urb); | 575 | usb_kill_urb(cdev->ep4_in_urb); |
572 | break; | 576 | break; |
573 | } | 577 | } |
574 | } | 578 | } |
575 | 579 | ||
576 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, | 580 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev, |
577 | char *buf, | 581 | char *buf, |
578 | unsigned int len) | 582 | unsigned int len) |
579 | { | 583 | { |
580 | if (!dev->input_dev || len < 1) | 584 | if (!cdev->input_dev || len < 1) |
581 | return; | 585 | return; |
582 | 586 | ||
583 | switch (buf[0]) { | 587 | switch (buf[0]) { |
584 | case EP1_CMD_READ_ANALOG: | 588 | case EP1_CMD_READ_ANALOG: |
585 | snd_caiaq_input_read_analog(dev, buf + 1, len - 1); | 589 | snd_caiaq_input_read_analog(cdev, buf + 1, len - 1); |
586 | break; | 590 | break; |
587 | case EP1_CMD_READ_ERP: | 591 | case EP1_CMD_READ_ERP: |
588 | snd_caiaq_input_read_erp(dev, buf + 1, len - 1); | 592 | snd_caiaq_input_read_erp(cdev, buf + 1, len - 1); |
589 | break; | 593 | break; |
590 | case EP1_CMD_READ_IO: | 594 | case EP1_CMD_READ_IO: |
591 | snd_caiaq_input_read_io(dev, buf + 1, len - 1); | 595 | snd_caiaq_input_read_io(cdev, buf + 1, len - 1); |
592 | break; | 596 | break; |
593 | } | 597 | } |
594 | } | 598 | } |
595 | 599 | ||
596 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | 600 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev) |
597 | { | 601 | { |
598 | struct usb_device *usb_dev = dev->chip.dev; | 602 | struct usb_device *usb_dev = cdev->chip.dev; |
599 | struct input_dev *input; | 603 | struct input_dev *input; |
600 | int i, ret = 0; | 604 | int i, ret = 0; |
601 | 605 | ||
@@ -603,49 +607,49 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
603 | if (!input) | 607 | if (!input) |
604 | return -ENOMEM; | 608 | return -ENOMEM; |
605 | 609 | ||
606 | usb_make_path(usb_dev, dev->phys, sizeof(dev->phys)); | 610 | usb_make_path(usb_dev, cdev->phys, sizeof(cdev->phys)); |
607 | strlcat(dev->phys, "/input0", sizeof(dev->phys)); | 611 | strlcat(cdev->phys, "/input0", sizeof(cdev->phys)); |
608 | 612 | ||
609 | input->name = dev->product_name; | 613 | input->name = cdev->product_name; |
610 | input->phys = dev->phys; | 614 | input->phys = cdev->phys; |
611 | usb_to_input_id(usb_dev, &input->id); | 615 | usb_to_input_id(usb_dev, &input->id); |
612 | input->dev.parent = &usb_dev->dev; | 616 | input->dev.parent = &usb_dev->dev; |
613 | 617 | ||
614 | input_set_drvdata(input, dev); | 618 | input_set_drvdata(input, cdev); |
615 | 619 | ||
616 | switch (dev->chip.usb_id) { | 620 | switch (cdev->chip.usb_id) { |
617 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): | 621 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2): |
618 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 622 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
619 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 623 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
620 | BIT_MASK(ABS_Z); | 624 | BIT_MASK(ABS_Z); |
621 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk2)); | 625 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk2)); |
622 | memcpy(dev->keycode, keycode_rk2, sizeof(keycode_rk2)); | 626 | memcpy(cdev->keycode, keycode_rk2, sizeof(keycode_rk2)); |
623 | input->keycodemax = ARRAY_SIZE(keycode_rk2); | 627 | input->keycodemax = ARRAY_SIZE(keycode_rk2); |
624 | input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); | 628 | input_set_abs_params(input, ABS_X, 0, 4096, 0, 10); |
625 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); | 629 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); |
626 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); | 630 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); |
627 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); | 631 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0); |
628 | break; | 632 | break; |
629 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): | 633 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3): |
630 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 634 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
631 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 635 | input->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
632 | BIT_MASK(ABS_Z); | 636 | BIT_MASK(ABS_Z); |
633 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_rk3)); | 637 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_rk3)); |
634 | memcpy(dev->keycode, keycode_rk3, sizeof(keycode_rk3)); | 638 | memcpy(cdev->keycode, keycode_rk3, sizeof(keycode_rk3)); |
635 | input->keycodemax = ARRAY_SIZE(keycode_rk3); | 639 | input->keycodemax = ARRAY_SIZE(keycode_rk3); |
636 | input_set_abs_params(input, ABS_X, 0, 1024, 0, 10); | 640 | input_set_abs_params(input, ABS_X, 0, 1024, 0, 10); |
637 | input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10); | 641 | input_set_abs_params(input, ABS_Y, 0, 1024, 0, 10); |
638 | input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10); | 642 | input_set_abs_params(input, ABS_Z, 0, 1024, 0, 10); |
639 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 0); | 643 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 0); |
640 | break; | 644 | break; |
641 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): | 645 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1): |
642 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 646 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
643 | input->absbit[0] = BIT_MASK(ABS_X); | 647 | input->absbit[0] = BIT_MASK(ABS_X); |
644 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_ak1)); | 648 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_ak1)); |
645 | memcpy(dev->keycode, keycode_ak1, sizeof(keycode_ak1)); | 649 | memcpy(cdev->keycode, keycode_ak1, sizeof(keycode_ak1)); |
646 | input->keycodemax = ARRAY_SIZE(keycode_ak1); | 650 | input->keycodemax = ARRAY_SIZE(keycode_ak1); |
647 | input_set_abs_params(input, ABS_X, 0, 999, 0, 10); | 651 | input_set_abs_params(input, ABS_X, 0, 999, 0, 10); |
648 | snd_usb_caiaq_set_auto_msg(dev, 1, 0, 5); | 652 | snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 5); |
649 | break; | 653 | break; |
650 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): | 654 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER): |
651 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): | 655 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2): |
@@ -657,8 +661,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
657 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 661 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
658 | BIT_MASK(ABS_Z); | 662 | BIT_MASK(ABS_Z); |
659 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); | 663 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); |
660 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_kore)); | 664 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_kore)); |
661 | memcpy(dev->keycode, keycode_kore, sizeof(keycode_kore)); | 665 | memcpy(cdev->keycode, keycode_kore, sizeof(keycode_kore)); |
662 | input->keycodemax = ARRAY_SIZE(keycode_kore); | 666 | input->keycodemax = ARRAY_SIZE(keycode_kore); |
663 | input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10); | 667 | input_set_abs_params(input, ABS_HAT0X, 0, 999, 0, 10); |
664 | input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10); | 668 | input_set_abs_params(input, ABS_HAT0Y, 0, 999, 0, 10); |
@@ -672,7 +676,7 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
672 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); | 676 | input_set_abs_params(input, ABS_Y, 0, 4096, 0, 10); |
673 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); | 677 | input_set_abs_params(input, ABS_Z, 0, 4096, 0, 10); |
674 | input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1); | 678 | input_set_abs_params(input, ABS_MISC, 0, 255, 0, 1); |
675 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 679 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
676 | break; | 680 | break; |
677 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): | 681 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): |
678 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 682 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
@@ -683,9 +687,9 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
683 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | | 687 | BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | |
684 | BIT_MASK(ABS_Z); | 688 | BIT_MASK(ABS_Z); |
685 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); | 689 | input->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC); |
686 | BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLX1_INPUTS); | 690 | BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLX1_INPUTS); |
687 | for (i = 0; i < KONTROLX1_INPUTS; i++) | 691 | for (i = 0; i < KONTROLX1_INPUTS; i++) |
688 | dev->keycode[i] = BTN_MISC + i; | 692 | cdev->keycode[i] = BTN_MISC + i; |
689 | input->keycodemax = KONTROLX1_INPUTS; | 693 | input->keycodemax = KONTROLX1_INPUTS; |
690 | 694 | ||
691 | /* analog potentiometers */ | 695 | /* analog potentiometers */ |
@@ -704,26 +708,26 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
704 | input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1); | 708 | input_set_abs_params(input, ABS_Z, 0, 0xf, 0, 1); |
705 | input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1); | 709 | input_set_abs_params(input, ABS_MISC, 0, 0xf, 0, 1); |
706 | 710 | ||
707 | dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 711 | cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
708 | if (!dev->ep4_in_urb) { | 712 | if (!cdev->ep4_in_urb) { |
709 | ret = -ENOMEM; | 713 | ret = -ENOMEM; |
710 | goto exit_free_idev; | 714 | goto exit_free_idev; |
711 | } | 715 | } |
712 | 716 | ||
713 | usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, | 717 | usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev, |
714 | usb_rcvbulkpipe(usb_dev, 0x4), | 718 | usb_rcvbulkpipe(usb_dev, 0x4), |
715 | dev->ep4_in_buf, EP4_BUFSIZE, | 719 | cdev->ep4_in_buf, EP4_BUFSIZE, |
716 | snd_usb_caiaq_ep4_reply_dispatch, dev); | 720 | snd_usb_caiaq_ep4_reply_dispatch, cdev); |
717 | 721 | ||
718 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 722 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
719 | 723 | ||
720 | break; | 724 | break; |
721 | 725 | ||
722 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): | 726 | case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): |
723 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 727 | input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
724 | BUILD_BUG_ON(sizeof(dev->keycode) < KONTROLS4_BUTTONS); | 728 | BUILD_BUG_ON(sizeof(cdev->keycode) < KONTROLS4_BUTTONS); |
725 | for (i = 0; i < KONTROLS4_BUTTONS; i++) | 729 | for (i = 0; i < KONTROLS4_BUTTONS; i++) |
726 | dev->keycode[i] = KONTROLS4_BUTTON(i); | 730 | cdev->keycode[i] = KONTROLS4_BUTTON(i); |
727 | input->keycodemax = KONTROLS4_BUTTONS; | 731 | input->keycodemax = KONTROLS4_BUTTONS; |
728 | 732 | ||
729 | for (i = 0; i < KONTROLS4_AXIS; i++) { | 733 | for (i = 0; i < KONTROLS4_AXIS; i++) { |
@@ -743,18 +747,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
743 | for (i = 0; i < 9; i++) | 747 | for (i = 0; i < 9; i++) |
744 | input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1); | 748 | input_set_abs_params(input, KONTROLS4_ABS(38+i), 0, 0xf, 0, 1); |
745 | 749 | ||
746 | dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 750 | cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
747 | if (!dev->ep4_in_urb) { | 751 | if (!cdev->ep4_in_urb) { |
748 | ret = -ENOMEM; | 752 | ret = -ENOMEM; |
749 | goto exit_free_idev; | 753 | goto exit_free_idev; |
750 | } | 754 | } |
751 | 755 | ||
752 | usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, | 756 | usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev, |
753 | usb_rcvbulkpipe(usb_dev, 0x4), | 757 | usb_rcvbulkpipe(usb_dev, 0x4), |
754 | dev->ep4_in_buf, EP4_BUFSIZE, | 758 | cdev->ep4_in_buf, EP4_BUFSIZE, |
755 | snd_usb_caiaq_ep4_reply_dispatch, dev); | 759 | snd_usb_caiaq_ep4_reply_dispatch, cdev); |
756 | 760 | ||
757 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 761 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
758 | 762 | ||
759 | break; | 763 | break; |
760 | 764 | ||
@@ -767,8 +771,8 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
767 | BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) | | 771 | BIT_MASK(ABS_RX) | BIT_MASK(ABS_RY) | |
768 | BIT_MASK(ABS_RZ); | 772 | BIT_MASK(ABS_RZ); |
769 | 773 | ||
770 | BUILD_BUG_ON(sizeof(dev->keycode) < sizeof(keycode_maschine)); | 774 | BUILD_BUG_ON(sizeof(cdev->keycode) < sizeof(keycode_maschine)); |
771 | memcpy(dev->keycode, keycode_maschine, sizeof(keycode_maschine)); | 775 | memcpy(cdev->keycode, keycode_maschine, sizeof(keycode_maschine)); |
772 | input->keycodemax = ARRAY_SIZE(keycode_maschine); | 776 | input->keycodemax = ARRAY_SIZE(keycode_maschine); |
773 | 777 | ||
774 | for (i = 0; i < MASCHINE_PADS; i++) { | 778 | for (i = 0; i < MASCHINE_PADS; i++) { |
@@ -788,18 +792,18 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
788 | input_set_abs_params(input, ABS_RY, 0, 999, 0, 10); | 792 | input_set_abs_params(input, ABS_RY, 0, 999, 0, 10); |
789 | input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10); | 793 | input_set_abs_params(input, ABS_RZ, 0, 999, 0, 10); |
790 | 794 | ||
791 | dev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); | 795 | cdev->ep4_in_urb = usb_alloc_urb(0, GFP_KERNEL); |
792 | if (!dev->ep4_in_urb) { | 796 | if (!cdev->ep4_in_urb) { |
793 | ret = -ENOMEM; | 797 | ret = -ENOMEM; |
794 | goto exit_free_idev; | 798 | goto exit_free_idev; |
795 | } | 799 | } |
796 | 800 | ||
797 | usb_fill_bulk_urb(dev->ep4_in_urb, usb_dev, | 801 | usb_fill_bulk_urb(cdev->ep4_in_urb, usb_dev, |
798 | usb_rcvbulkpipe(usb_dev, 0x4), | 802 | usb_rcvbulkpipe(usb_dev, 0x4), |
799 | dev->ep4_in_buf, EP4_BUFSIZE, | 803 | cdev->ep4_in_buf, EP4_BUFSIZE, |
800 | snd_usb_caiaq_ep4_reply_dispatch, dev); | 804 | snd_usb_caiaq_ep4_reply_dispatch, cdev); |
801 | 805 | ||
802 | snd_usb_caiaq_set_auto_msg(dev, 1, 10, 5); | 806 | snd_usb_caiaq_set_auto_msg(cdev, 1, 10, 5); |
803 | break; | 807 | break; |
804 | 808 | ||
805 | default: | 809 | default: |
@@ -809,12 +813,12 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
809 | 813 | ||
810 | input->open = snd_usb_caiaq_input_open; | 814 | input->open = snd_usb_caiaq_input_open; |
811 | input->close = snd_usb_caiaq_input_close; | 815 | input->close = snd_usb_caiaq_input_close; |
812 | input->keycode = dev->keycode; | 816 | input->keycode = cdev->keycode; |
813 | input->keycodesize = sizeof(unsigned short); | 817 | input->keycodesize = sizeof(unsigned short); |
814 | for (i = 0; i < input->keycodemax; i++) | 818 | for (i = 0; i < input->keycodemax; i++) |
815 | __set_bit(dev->keycode[i], input->keybit); | 819 | __set_bit(cdev->keycode[i], input->keybit); |
816 | 820 | ||
817 | dev->input_dev = input; | 821 | cdev->input_dev = input; |
818 | 822 | ||
819 | ret = input_register_device(input); | 823 | ret = input_register_device(input); |
820 | if (ret < 0) | 824 | if (ret < 0) |
@@ -824,19 +828,19 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev) | |||
824 | 828 | ||
825 | exit_free_idev: | 829 | exit_free_idev: |
826 | input_free_device(input); | 830 | input_free_device(input); |
827 | dev->input_dev = NULL; | 831 | cdev->input_dev = NULL; |
828 | return ret; | 832 | return ret; |
829 | } | 833 | } |
830 | 834 | ||
831 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev) | 835 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev) |
832 | { | 836 | { |
833 | if (!dev || !dev->input_dev) | 837 | if (!cdev || !cdev->input_dev) |
834 | return; | 838 | return; |
835 | 839 | ||
836 | usb_kill_urb(dev->ep4_in_urb); | 840 | usb_kill_urb(cdev->ep4_in_urb); |
837 | usb_free_urb(dev->ep4_in_urb); | 841 | usb_free_urb(cdev->ep4_in_urb); |
838 | dev->ep4_in_urb = NULL; | 842 | cdev->ep4_in_urb = NULL; |
839 | 843 | ||
840 | input_unregister_device(dev->input_dev); | 844 | input_unregister_device(cdev->input_dev); |
841 | dev->input_dev = NULL; | 845 | cdev->input_dev = NULL; |
842 | } | 846 | } |
diff --git a/sound/usb/caiaq/input.h b/sound/usb/caiaq/input.h index ced535577864..6014e2713a60 100644 --- a/sound/usb/caiaq/input.h +++ b/sound/usb/caiaq/input.h | |||
@@ -1,8 +1,8 @@ | |||
1 | #ifndef CAIAQ_INPUT_H | 1 | #ifndef CAIAQ_INPUT_H |
2 | #define CAIAQ_INPUT_H | 2 | #define CAIAQ_INPUT_H |
3 | 3 | ||
4 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *dev, char *buf, unsigned int len); | 4 | void snd_usb_caiaq_input_dispatch(struct snd_usb_caiaqdev *cdev, char *buf, unsigned int len); |
5 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *dev); | 5 | int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev); |
6 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *dev); | 6 | void snd_usb_caiaq_input_free(struct snd_usb_caiaqdev *cdev); |
7 | 7 | ||
8 | #endif | 8 | #endif |
diff --git a/sound/usb/caiaq/midi.c b/sound/usb/caiaq/midi.c index a1a47088fd0c..2d7588461b33 100644 --- a/sound/usb/caiaq/midi.c +++ b/sound/usb/caiaq/midi.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/device.h> | ||
19 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
20 | #include <linux/gfp.h> | 21 | #include <linux/gfp.h> |
21 | #include <sound/rawmidi.h> | 22 | #include <sound/rawmidi.h> |
@@ -37,12 +38,12 @@ static int snd_usb_caiaq_midi_input_close(struct snd_rawmidi_substream *substrea | |||
37 | 38 | ||
38 | static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) | 39 | static void snd_usb_caiaq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) |
39 | { | 40 | { |
40 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 41 | struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data; |
41 | 42 | ||
42 | if (!dev) | 43 | if (!cdev) |
43 | return; | 44 | return; |
44 | 45 | ||
45 | dev->midi_receive_substream = up ? substream : NULL; | 46 | cdev->midi_receive_substream = up ? substream : NULL; |
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
@@ -53,49 +54,50 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea | |||
53 | 54 | ||
54 | static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream) | 55 | static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream) |
55 | { | 56 | { |
56 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 57 | struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data; |
57 | if (dev->midi_out_active) { | 58 | if (cdev->midi_out_active) { |
58 | usb_kill_urb(&dev->midi_out_urb); | 59 | usb_kill_urb(&cdev->midi_out_urb); |
59 | dev->midi_out_active = 0; | 60 | cdev->midi_out_active = 0; |
60 | } | 61 | } |
61 | return 0; | 62 | return 0; |
62 | } | 63 | } |
63 | 64 | ||
64 | static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev, | 65 | static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *cdev, |
65 | struct snd_rawmidi_substream *substream) | 66 | struct snd_rawmidi_substream *substream) |
66 | { | 67 | { |
67 | int len, ret; | 68 | int len, ret; |
69 | struct device *dev = caiaqdev_to_dev(cdev); | ||
68 | 70 | ||
69 | dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; | 71 | cdev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE; |
70 | dev->midi_out_buf[1] = 0; /* port */ | 72 | cdev->midi_out_buf[1] = 0; /* port */ |
71 | len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3, | 73 | len = snd_rawmidi_transmit(substream, cdev->midi_out_buf + 3, |
72 | EP1_BUFSIZE - 3); | 74 | EP1_BUFSIZE - 3); |
73 | 75 | ||
74 | if (len <= 0) | 76 | if (len <= 0) |
75 | return; | 77 | return; |
76 | 78 | ||
77 | dev->midi_out_buf[2] = len; | 79 | cdev->midi_out_buf[2] = len; |
78 | dev->midi_out_urb.transfer_buffer_length = len+3; | 80 | cdev->midi_out_urb.transfer_buffer_length = len+3; |
79 | 81 | ||
80 | ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC); | 82 | ret = usb_submit_urb(&cdev->midi_out_urb, GFP_ATOMIC); |
81 | if (ret < 0) | 83 | if (ret < 0) |
82 | log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," | 84 | dev_err(dev, |
83 | "ret=%d, len=%d\n", | 85 | "snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed," |
84 | substream, ret, len); | 86 | "ret=%d, len=%d\n", substream, ret, len); |
85 | else | 87 | else |
86 | dev->midi_out_active = 1; | 88 | cdev->midi_out_active = 1; |
87 | } | 89 | } |
88 | 90 | ||
89 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) | 91 | static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) |
90 | { | 92 | { |
91 | struct snd_usb_caiaqdev *dev = substream->rmidi->private_data; | 93 | struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data; |
92 | 94 | ||
93 | if (up) { | 95 | if (up) { |
94 | dev->midi_out_substream = substream; | 96 | cdev->midi_out_substream = substream; |
95 | if (!dev->midi_out_active) | 97 | if (!cdev->midi_out_active) |
96 | snd_usb_caiaq_midi_send(dev, substream); | 98 | snd_usb_caiaq_midi_send(cdev, substream); |
97 | } else { | 99 | } else { |
98 | dev->midi_out_substream = NULL; | 100 | cdev->midi_out_substream = NULL; |
99 | } | 101 | } |
100 | } | 102 | } |
101 | 103 | ||
@@ -114,13 +116,13 @@ static struct snd_rawmidi_ops snd_usb_caiaq_midi_input = | |||
114 | .trigger = snd_usb_caiaq_midi_input_trigger, | 116 | .trigger = snd_usb_caiaq_midi_input_trigger, |
115 | }; | 117 | }; |
116 | 118 | ||
117 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, | 119 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *cdev, |
118 | int port, const char *buf, int len) | 120 | int port, const char *buf, int len) |
119 | { | 121 | { |
120 | if (!dev->midi_receive_substream) | 122 | if (!cdev->midi_receive_substream) |
121 | return; | 123 | return; |
122 | 124 | ||
123 | snd_rawmidi_receive(dev->midi_receive_substream, buf, len); | 125 | snd_rawmidi_receive(cdev->midi_receive_substream, buf, len); |
124 | } | 126 | } |
125 | 127 | ||
126 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | 128 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) |
@@ -160,15 +162,14 @@ int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *device) | |||
160 | 162 | ||
161 | void snd_usb_caiaq_midi_output_done(struct urb* urb) | 163 | void snd_usb_caiaq_midi_output_done(struct urb* urb) |
162 | { | 164 | { |
163 | struct snd_usb_caiaqdev *dev = urb->context; | 165 | struct snd_usb_caiaqdev *cdev = urb->context; |
164 | 166 | ||
165 | dev->midi_out_active = 0; | 167 | cdev->midi_out_active = 0; |
166 | if (urb->status != 0) | 168 | if (urb->status != 0) |
167 | return; | 169 | return; |
168 | 170 | ||
169 | if (!dev->midi_out_substream) | 171 | if (!cdev->midi_out_substream) |
170 | return; | 172 | return; |
171 | 173 | ||
172 | snd_usb_caiaq_midi_send(dev, dev->midi_out_substream); | 174 | snd_usb_caiaq_midi_send(cdev, cdev->midi_out_substream); |
173 | } | 175 | } |
174 | |||
diff --git a/sound/usb/caiaq/midi.h b/sound/usb/caiaq/midi.h index 380f984babc9..60bf3442b283 100644 --- a/sound/usb/caiaq/midi.h +++ b/sound/usb/caiaq/midi.h | |||
@@ -1,8 +1,9 @@ | |||
1 | #ifndef CAIAQ_MIDI_H | 1 | #ifndef CAIAQ_MIDI_H |
2 | #define CAIAQ_MIDI_H | 2 | #define CAIAQ_MIDI_H |
3 | 3 | ||
4 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *dev); | 4 | int snd_usb_caiaq_midi_init(struct snd_usb_caiaqdev *cdev); |
5 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *dev, int port, const char *buf, int len); | 5 | void snd_usb_caiaq_midi_handle_input(struct snd_usb_caiaqdev *cdev, |
6 | int port, const char *buf, int len); | ||
6 | void snd_usb_caiaq_midi_output_done(struct urb *urb); | 7 | void snd_usb_caiaq_midi_output_done(struct urb *urb); |
7 | 8 | ||
8 | #endif /* CAIAQ_MIDI_H */ | 9 | #endif /* CAIAQ_MIDI_H */ |
diff --git a/sound/usb/format.c b/sound/usb/format.c index e831ee4238bb..a695cafc0599 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c | |||
@@ -43,11 +43,11 @@ | |||
43 | */ | 43 | */ |
44 | static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, | 44 | static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, |
45 | struct audioformat *fp, | 45 | struct audioformat *fp, |
46 | int format, void *_fmt, | 46 | unsigned int format, void *_fmt, |
47 | int protocol) | 47 | int protocol) |
48 | { | 48 | { |
49 | int sample_width, sample_bytes; | 49 | int sample_width, sample_bytes; |
50 | u64 pcm_formats; | 50 | u64 pcm_formats = 0; |
51 | 51 | ||
52 | switch (protocol) { | 52 | switch (protocol) { |
53 | case UAC_VERSION_1: | 53 | case UAC_VERSION_1: |
@@ -63,14 +63,17 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip, | |||
63 | struct uac_format_type_i_ext_descriptor *fmt = _fmt; | 63 | struct uac_format_type_i_ext_descriptor *fmt = _fmt; |
64 | sample_width = fmt->bBitResolution; | 64 | sample_width = fmt->bBitResolution; |
65 | sample_bytes = fmt->bSubslotSize; | 65 | sample_bytes = fmt->bSubslotSize; |
66 | |||
67 | if (format & UAC2_FORMAT_TYPE_I_RAW_DATA) | ||
68 | pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL; | ||
69 | |||
66 | format <<= 1; | 70 | format <<= 1; |
67 | break; | 71 | break; |
68 | } | 72 | } |
69 | } | 73 | } |
70 | 74 | ||
71 | pcm_formats = 0; | 75 | if ((pcm_formats == 0) && |
72 | 76 | (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED))) { | |
73 | if (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED)) { | ||
74 | /* some devices don't define this correctly... */ | 77 | /* some devices don't define this correctly... */ |
75 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", | 78 | snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n", |
76 | chip->dev->devnum, fp->iface, fp->altsetting); | 79 | chip->dev->devnum, fp->iface, fp->altsetting); |
@@ -353,7 +356,7 @@ err: | |||
353 | * parse the format type I and III descriptors | 356 | * parse the format type I and III descriptors |
354 | */ | 357 | */ |
355 | static int parse_audio_format_i(struct snd_usb_audio *chip, | 358 | static int parse_audio_format_i(struct snd_usb_audio *chip, |
356 | struct audioformat *fp, int format, | 359 | struct audioformat *fp, unsigned int format, |
357 | struct uac_format_type_i_continuous_descriptor *fmt, | 360 | struct uac_format_type_i_continuous_descriptor *fmt, |
358 | struct usb_host_interface *iface) | 361 | struct usb_host_interface *iface) |
359 | { | 362 | { |
@@ -473,8 +476,9 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip, | |||
473 | return ret; | 476 | return ret; |
474 | } | 477 | } |
475 | 478 | ||
476 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, | 479 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, |
477 | int format, struct uac_format_type_i_continuous_descriptor *fmt, | 480 | struct audioformat *fp, unsigned int format, |
481 | struct uac_format_type_i_continuous_descriptor *fmt, | ||
478 | int stream, struct usb_host_interface *iface) | 482 | int stream, struct usb_host_interface *iface) |
479 | { | 483 | { |
480 | int err; | 484 | int err; |
diff --git a/sound/usb/format.h b/sound/usb/format.h index 387924f0af85..6f315226f320 100644 --- a/sound/usb/format.h +++ b/sound/usb/format.h | |||
@@ -2,7 +2,7 @@ | |||
2 | #define __USBAUDIO_FORMAT_H | 2 | #define __USBAUDIO_FORMAT_H |
3 | 3 | ||
4 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, | 4 | int snd_usb_parse_audio_format(struct snd_usb_audio *chip, |
5 | struct audioformat *fp, int format, | 5 | struct audioformat *fp, unsigned int format, |
6 | struct uac_format_type_i_continuous_descriptor *fmt, | 6 | struct uac_format_type_i_continuous_descriptor *fmt, |
7 | int stream, struct usb_host_interface *iface); | 7 | int stream, struct usb_host_interface *iface); |
8 | 8 | ||
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index f94397b42aa5..c263991b3b9d 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -350,6 +350,13 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
350 | fmt->iface, fmt->altsetting); | 350 | fmt->iface, fmt->altsetting); |
351 | subs->interface = fmt->iface; | 351 | subs->interface = fmt->iface; |
352 | subs->altset_idx = fmt->altset_idx; | 352 | subs->altset_idx = fmt->altset_idx; |
353 | |||
354 | /* | ||
355 | * "Playback Design" products need a 50ms delay after setting the | ||
356 | * USB interface. | ||
357 | */ | ||
358 | if (le16_to_cpu(dev->descriptor.idVendor) == 0x23ba) | ||
359 | mdelay(50); | ||
353 | } | 360 | } |
354 | 361 | ||
355 | subs->data_endpoint = snd_usb_add_endpoint(subs->stream->chip, | 362 | subs->data_endpoint = snd_usb_add_endpoint(subs->stream->chip, |
diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h index c39f898b15d2..86e4b8c17dad 100644 --- a/sound/usb/quirks-table.h +++ b/sound/usb/quirks-table.h | |||
@@ -2748,6 +2748,46 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2748 | } | 2748 | } |
2749 | }, | 2749 | }, |
2750 | { | 2750 | { |
2751 | USB_DEVICE(0x1235, 0x0018), | ||
2752 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | ||
2753 | .vendor_name = "Novation", | ||
2754 | .product_name = "Twitch", | ||
2755 | .ifnum = QUIRK_ANY_INTERFACE, | ||
2756 | .type = QUIRK_COMPOSITE, | ||
2757 | .data = (const struct snd_usb_audio_quirk[]) { | ||
2758 | { | ||
2759 | .ifnum = 0, | ||
2760 | .type = QUIRK_AUDIO_FIXED_ENDPOINT, | ||
2761 | .data = & (const struct audioformat) { | ||
2762 | .formats = SNDRV_PCM_FMTBIT_S24_3LE, | ||
2763 | .channels = 4, | ||
2764 | .iface = 0, | ||
2765 | .altsetting = 1, | ||
2766 | .altset_idx = 1, | ||
2767 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, | ||
2768 | .endpoint = 0x01, | ||
2769 | .ep_attr = USB_ENDPOINT_XFER_ISOC, | ||
2770 | .rates = SNDRV_PCM_RATE_44100 | | ||
2771 | SNDRV_PCM_RATE_48000, | ||
2772 | .rate_min = 44100, | ||
2773 | .rate_max = 48000, | ||
2774 | .nr_rates = 2, | ||
2775 | .rate_table = (unsigned int[]) { | ||
2776 | 44100, 48000 | ||
2777 | } | ||
2778 | } | ||
2779 | }, | ||
2780 | { | ||
2781 | .ifnum = 1, | ||
2782 | .type = QUIRK_MIDI_RAW_BYTES | ||
2783 | }, | ||
2784 | { | ||
2785 | .ifnum = -1 | ||
2786 | } | ||
2787 | } | ||
2788 | } | ||
2789 | }, | ||
2790 | { | ||
2751 | USB_DEVICE_VENDOR_SPEC(0x1235, 0x4661), | 2791 | USB_DEVICE_VENDOR_SPEC(0x1235, 0x4661), |
2752 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { | 2792 | .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { |
2753 | .vendor_name = "Novation", | 2793 | .vendor_name = "Novation", |
@@ -2996,7 +3036,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
2996 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, | 3036 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, |
2997 | .endpoint = 0x02, | 3037 | .endpoint = 0x02, |
2998 | .ep_attr = 0x01, | 3038 | .ep_attr = 0x01, |
2999 | .maxpacksize = 0x130, | ||
3000 | .rates = SNDRV_PCM_RATE_44100 | | 3039 | .rates = SNDRV_PCM_RATE_44100 | |
3001 | SNDRV_PCM_RATE_48000, | 3040 | SNDRV_PCM_RATE_48000, |
3002 | .rate_min = 44100, | 3041 | .rate_min = 44100, |
@@ -3044,7 +3083,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
3044 | .attributes = 0x00, | 3083 | .attributes = 0x00, |
3045 | .endpoint = 0x03, | 3084 | .endpoint = 0x03, |
3046 | .ep_attr = USB_ENDPOINT_SYNC_ASYNC, | 3085 | .ep_attr = USB_ENDPOINT_SYNC_ASYNC, |
3047 | .maxpacksize = 0x128, | ||
3048 | .rates = SNDRV_PCM_RATE_48000, | 3086 | .rates = SNDRV_PCM_RATE_48000, |
3049 | .rate_min = 48000, | 3087 | .rate_min = 48000, |
3050 | .rate_max = 48000, | 3088 | .rate_max = 48000, |
@@ -3070,7 +3108,6 @@ YAMAHA_DEVICE(0x7010, "UB99"), | |||
3070 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, | 3108 | .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE, |
3071 | .endpoint = 0x85, | 3109 | .endpoint = 0x85, |
3072 | .ep_attr = USB_ENDPOINT_SYNC_SYNC, | 3110 | .ep_attr = USB_ENDPOINT_SYNC_SYNC, |
3073 | .maxpacksize = 0x128, | ||
3074 | .rates = SNDRV_PCM_RATE_48000, | 3111 | .rates = SNDRV_PCM_RATE_48000, |
3075 | .rate_min = 48000, | 3112 | .rate_min = 48000, |
3076 | .rate_max = 48000, | 3113 | .rate_max = 48000, |
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 5325a3869bb7..a2ac004bbd9a 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c | |||
@@ -165,8 +165,10 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, | |||
165 | return -EINVAL; | 165 | return -EINVAL; |
166 | } | 166 | } |
167 | alts = &iface->altsetting[fp->altset_idx]; | 167 | alts = &iface->altsetting[fp->altset_idx]; |
168 | fp->datainterval = snd_usb_parse_datainterval(chip, alts); | 168 | if (fp->datainterval == 0) |
169 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 169 | fp->datainterval = snd_usb_parse_datainterval(chip, alts); |
170 | if (fp->maxpacksize == 0) | ||
171 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | ||
170 | usb_set_interface(chip->dev, fp->iface, 0); | 172 | usb_set_interface(chip->dev, fp->iface, 0); |
171 | snd_usb_init_pitch(chip, fp->iface, alts, fp); | 173 | snd_usb_init_pitch(chip, fp->iface, alts, fp); |
172 | snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max); | 174 | snd_usb_init_sample_rate(chip, fp->iface, alts, fp, fp->rate_max); |
@@ -446,6 +448,17 @@ static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) | |||
446 | } | 448 | } |
447 | 449 | ||
448 | /* | 450 | /* |
451 | * Novation Twitch DJ controller | ||
452 | */ | ||
453 | static int snd_usb_twitch_boot_quirk(struct usb_device *dev) | ||
454 | { | ||
455 | /* preemptively set up the device because otherwise the | ||
456 | * raw MIDI endpoints are not active */ | ||
457 | usb_set_interface(dev, 0, 1); | ||
458 | return 0; | ||
459 | } | ||
460 | |||
461 | /* | ||
449 | * This call will put the synth in "USB send" mode, i.e it will send MIDI | 462 | * This call will put the synth in "USB send" mode, i.e it will send MIDI |
450 | * messages through USB (this is disabled at startup). The synth will | 463 | * messages through USB (this is disabled at startup). The synth will |
451 | * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB | 464 | * acknowledge by sending a sysex on endpoint 0x85 and by displaying a USB |
@@ -746,6 +759,10 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev, | |||
746 | /* Digidesign Mbox 2 */ | 759 | /* Digidesign Mbox 2 */ |
747 | return snd_usb_mbox2_boot_quirk(dev); | 760 | return snd_usb_mbox2_boot_quirk(dev); |
748 | 761 | ||
762 | case USB_ID(0x1235, 0x0018): | ||
763 | /* Focusrite Novation Twitch */ | ||
764 | return snd_usb_twitch_boot_quirk(dev); | ||
765 | |||
749 | case USB_ID(0x133e, 0x0815): | 766 | case USB_ID(0x133e, 0x0815): |
750 | /* Access Music VirusTI Desktop */ | 767 | /* Access Music VirusTI Desktop */ |
751 | return snd_usb_accessmusic_boot_quirk(dev); | 768 | return snd_usb_accessmusic_boot_quirk(dev); |
diff --git a/sound/usb/stream.c b/sound/usb/stream.c index ad181d538bd9..ad0704656fe5 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c | |||
@@ -463,7 +463,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) | |||
463 | struct usb_host_interface *alts; | 463 | struct usb_host_interface *alts; |
464 | struct usb_interface_descriptor *altsd; | 464 | struct usb_interface_descriptor *altsd; |
465 | int i, altno, err, stream; | 465 | int i, altno, err, stream; |
466 | int format = 0, num_channels = 0; | 466 | unsigned int format = 0, num_channels = 0; |
467 | struct audioformat *fp = NULL; | 467 | struct audioformat *fp = NULL; |
468 | int num, protocol, clock = 0; | 468 | int num, protocol, clock = 0; |
469 | struct uac_format_type_i_continuous_descriptor *fmt; | 469 | struct uac_format_type_i_continuous_descriptor *fmt; |