Lines Matching refs:cdev
135 struct snd_usb_caiaqdev *cdev = urb->context; in usb_ep1_command_reply_dispatch() local
138 if (urb->status || !cdev) { in usb_ep1_command_reply_dispatch()
145 memcpy(&cdev->spec, buf+1, sizeof(struct caiaq_device_spec)); in usb_ep1_command_reply_dispatch()
146 cdev->spec.fw_version = le16_to_cpu(cdev->spec.fw_version); in usb_ep1_command_reply_dispatch()
149 cdev->spec.fw_version, in usb_ep1_command_reply_dispatch()
150 cdev->spec.num_analog_audio_in, in usb_ep1_command_reply_dispatch()
151 cdev->spec.num_analog_audio_out, in usb_ep1_command_reply_dispatch()
152 cdev->spec.num_midi_in, in usb_ep1_command_reply_dispatch()
153 cdev->spec.num_midi_out, in usb_ep1_command_reply_dispatch()
154 cdev->spec.data_alignment); in usb_ep1_command_reply_dispatch()
156 cdev->spec_received++; in usb_ep1_command_reply_dispatch()
157 wake_up(&cdev->ep1_wait_queue); in usb_ep1_command_reply_dispatch()
160 cdev->audio_parm_answer = buf[1]; in usb_ep1_command_reply_dispatch()
161 wake_up(&cdev->ep1_wait_queue); in usb_ep1_command_reply_dispatch()
164 snd_usb_caiaq_midi_handle_input(cdev, buf[1], buf + 3, buf[2]); in usb_ep1_command_reply_dispatch()
167 if (cdev->chip.usb_id == in usb_ep1_command_reply_dispatch()
169 if (urb->actual_length > sizeof(cdev->control_state)) in usb_ep1_command_reply_dispatch()
170 urb->actual_length = sizeof(cdev->control_state); in usb_ep1_command_reply_dispatch()
171 memcpy(cdev->control_state, buf + 1, urb->actual_length); in usb_ep1_command_reply_dispatch()
172 wake_up(&cdev->ep1_wait_queue); in usb_ep1_command_reply_dispatch()
179 snd_usb_caiaq_input_dispatch(cdev, buf, urb->actual_length); in usb_ep1_command_reply_dispatch()
184 cdev->ep1_in_urb.actual_length = 0; in usb_ep1_command_reply_dispatch()
185 ret = usb_submit_urb(&cdev->ep1_in_urb, GFP_ATOMIC); in usb_ep1_command_reply_dispatch()
190 int snd_usb_caiaq_send_command(struct snd_usb_caiaqdev *cdev, in snd_usb_caiaq_send_command() argument
196 struct usb_device *usb_dev = cdev->chip.dev; in snd_usb_caiaq_send_command()
205 memcpy(cdev->ep1_out_buf+1, buffer, len); in snd_usb_caiaq_send_command()
207 cdev->ep1_out_buf[0] = command; in snd_usb_caiaq_send_command()
209 cdev->ep1_out_buf, len+1, &actual_len, 200); in snd_usb_caiaq_send_command()
212 int snd_usb_caiaq_send_command_bank(struct snd_usb_caiaqdev *cdev, in snd_usb_caiaq_send_command_bank() argument
219 struct usb_device *usb_dev = cdev->chip.dev; in snd_usb_caiaq_send_command_bank()
228 memcpy(cdev->ep1_out_buf+2, buffer, len); in snd_usb_caiaq_send_command_bank()
230 cdev->ep1_out_buf[0] = command; in snd_usb_caiaq_send_command_bank()
231 cdev->ep1_out_buf[1] = bank; in snd_usb_caiaq_send_command_bank()
234 cdev->ep1_out_buf, len+2, &actual_len, 200); in snd_usb_caiaq_send_command_bank()
237 int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *cdev, in snd_usb_caiaq_set_audio_params() argument
242 struct device *dev = caiaqdev_to_dev(cdev); in snd_usb_caiaq_set_audio_params()
266 cdev->audio_parm_answer = -1; in snd_usb_caiaq_set_audio_params()
267 ret = snd_usb_caiaq_send_command(cdev, EP1_CMD_AUDIO_PARAMS, in snd_usb_caiaq_set_audio_params()
273 if (!wait_event_timeout(cdev->ep1_wait_queue, in snd_usb_caiaq_set_audio_params()
274 cdev->audio_parm_answer >= 0, HZ)) in snd_usb_caiaq_set_audio_params()
277 if (cdev->audio_parm_answer != 1) in snd_usb_caiaq_set_audio_params()
280 cdev->bpp = bpp; in snd_usb_caiaq_set_audio_params()
282 return cdev->audio_parm_answer == 1 ? 0 : -EINVAL; in snd_usb_caiaq_set_audio_params()
285 int snd_usb_caiaq_set_auto_msg(struct snd_usb_caiaqdev *cdev, in snd_usb_caiaq_set_auto_msg() argument
289 return snd_usb_caiaq_send_command(cdev, EP1_CMD_AUTO_MSG, in snd_usb_caiaq_set_auto_msg()
293 static void setup_card(struct snd_usb_caiaqdev *cdev) in setup_card() argument
297 struct device *dev = caiaqdev_to_dev(cdev); in setup_card()
300 switch (cdev->chip.usb_id) { in setup_card()
306 snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 3); in setup_card()
314 snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 4); in setup_card()
319 snd_usb_caiaq_send_command(cdev, EP1_CMD_WRITE_IO, val, 1); in setup_card()
323 cdev->control_state[0] = 0xff; in setup_card()
324 snd_usb_caiaq_set_auto_msg(cdev, 1, 0, 0); in setup_card()
325 snd_usb_caiaq_send_command(cdev, EP1_CMD_READ_IO, NULL, 0); in setup_card()
327 if (!wait_event_timeout(cdev->ep1_wait_queue, in setup_card()
328 cdev->control_state[0] != 0xff, HZ)) in setup_card()
332 if ((cdev->control_state[1] != 2) || in setup_card()
333 (cdev->control_state[2] != 3) || in setup_card()
334 (cdev->control_state[4] != 2)) { in setup_card()
335 cdev->control_state[1] = 2; in setup_card()
336 cdev->control_state[2] = 3; in setup_card()
337 cdev->control_state[4] = 2; in setup_card()
338 snd_usb_caiaq_send_command(cdev, in setup_card()
339 EP1_CMD_WRITE_IO, cdev->control_state, 6); in setup_card()
345 if (cdev->spec.num_analog_audio_out + in setup_card()
346 cdev->spec.num_analog_audio_in + in setup_card()
347 cdev->spec.num_digital_audio_out + in setup_card()
348 cdev->spec.num_digital_audio_in > 0) { in setup_card()
349 ret = snd_usb_caiaq_audio_init(cdev); in setup_card()
354 if (cdev->spec.num_midi_in + in setup_card()
355 cdev->spec.num_midi_out > 0) { in setup_card()
356 ret = snd_usb_caiaq_midi_init(cdev); in setup_card()
362 ret = snd_usb_caiaq_input_init(cdev); in setup_card()
368 ret = snd_card_register(cdev->chip.card); in setup_card()
371 snd_card_free(cdev->chip.card); in setup_card()
374 ret = snd_usb_caiaq_control_init(cdev); in setup_card()
386 struct snd_usb_caiaqdev *cdev; in create_card() local
401 cdev = caiaqdev(card); in create_card()
402 cdev->chip.dev = usb_dev; in create_card()
403 cdev->chip.card = card; in create_card()
404 cdev->chip.usb_id = USB_ID(le16_to_cpu(usb_dev->descriptor.idVendor), in create_card()
406 spin_lock_init(&cdev->spinlock); in create_card()
412 static int init_card(struct snd_usb_caiaqdev *cdev) in init_card() argument
415 struct usb_device *usb_dev = cdev->chip.dev; in init_card()
416 struct snd_card *card = cdev->chip.card; in init_card()
417 struct device *dev = caiaqdev_to_dev(cdev); in init_card()
425 usb_init_urb(&cdev->ep1_in_urb); in init_card()
426 usb_init_urb(&cdev->midi_out_urb); in init_card()
428 usb_fill_bulk_urb(&cdev->ep1_in_urb, usb_dev, in init_card()
430 cdev->ep1_in_buf, EP1_BUFSIZE, in init_card()
431 usb_ep1_command_reply_dispatch, cdev); in init_card()
433 usb_fill_bulk_urb(&cdev->midi_out_urb, usb_dev, in init_card()
435 cdev->midi_out_buf, EP1_BUFSIZE, in init_card()
436 snd_usb_caiaq_midi_output_done, cdev); in init_card()
439 if (usb_urb_ep_type_check(&cdev->ep1_in_urb) || in init_card()
440 usb_urb_ep_type_check(&cdev->midi_out_urb)) { in init_card()
445 init_waitqueue_head(&cdev->ep1_wait_queue); in init_card()
446 init_waitqueue_head(&cdev->prepare_wait_queue); in init_card()
448 if (usb_submit_urb(&cdev->ep1_in_urb, GFP_KERNEL) != 0) in init_card()
451 err = snd_usb_caiaq_send_command(cdev, EP1_CMD_GET_DEVICE_INFO, NULL, 0); in init_card()
455 if (!wait_event_timeout(cdev->ep1_wait_queue, cdev->spec_received, HZ)) { in init_card()
461 cdev->vendor_name, CAIAQ_USB_STR_LEN); in init_card()
464 cdev->product_name, CAIAQ_USB_STR_LEN); in init_card()
467 strscpy(card->shortname, cdev->product_name, sizeof(card->shortname)); in init_card()
468 strscpy(card->mixername, cdev->product_name, sizeof(card->mixername)); in init_card()
489 cdev->vendor_name, cdev->product_name, usbpath); in init_card()
491 setup_card(cdev); in init_card()
495 usb_kill_urb(&cdev->ep1_in_urb); in init_card()
526 struct snd_usb_caiaqdev *cdev; in snd_disconnect() local
531 cdev = caiaqdev(card); in snd_disconnect()
537 snd_usb_caiaq_input_free(cdev); in snd_disconnect()
539 snd_usb_caiaq_audio_free(cdev); in snd_disconnect()
541 usb_kill_urb(&cdev->ep1_in_urb); in snd_disconnect()
542 usb_kill_urb(&cdev->midi_out_urb); in snd_disconnect()