H A D | bcd2000.c | 101 struct bcd2000 *bcd2k = substream->rmidi->private_data; bcd2000_midi_input_trigger() local 102 bcd2k->midi_receive_substream = up ? substream : NULL; bcd2000_midi_input_trigger() 105 static void bcd2000_midi_handle_input(struct bcd2000 *bcd2k, bcd2000_midi_handle_input() argument 111 midi_receive_substream = ACCESS_ONCE(bcd2k->midi_receive_substream); bcd2000_midi_handle_input() 135 static void bcd2000_midi_send(struct bcd2000 *bcd2k) bcd2000_midi_send() argument 142 midi_out_substream = ACCESS_ONCE(bcd2k->midi_out_substream); bcd2000_midi_send() 147 memcpy(bcd2k->midi_out_buf, device_cmd_prefix, bcd2000_midi_send() 155 bcd2k->midi_out_buf + 3, BUFSIZE - 3); bcd2000_midi_send() 158 dev_err(&bcd2k->dev->dev, "%s: snd_rawmidi_transmit error %d\n", bcd2000_midi_send() 165 bcd2k->midi_out_buf[2] = len; bcd2000_midi_send() 166 bcd2k->midi_out_urb->transfer_buffer_length = BUFSIZE; bcd2000_midi_send() 169 bcd2k->midi_out_buf, len+3); bcd2000_midi_send() 172 ret = usb_submit_urb(bcd2k->midi_out_urb, GFP_ATOMIC); bcd2000_midi_send() 174 dev_err(&bcd2k->dev->dev, PREFIX bcd2000_midi_send() 178 bcd2k->midi_out_active = 1; bcd2000_midi_send() 188 struct bcd2000 *bcd2k = substream->rmidi->private_data; bcd2000_midi_output_close() local 190 if (bcd2k->midi_out_active) { bcd2000_midi_output_close() 191 usb_kill_urb(bcd2k->midi_out_urb); bcd2000_midi_output_close() 192 bcd2k->midi_out_active = 0; bcd2000_midi_output_close() 202 struct bcd2000 *bcd2k = substream->rmidi->private_data; bcd2000_midi_output_trigger() local 205 bcd2k->midi_out_substream = substream; bcd2000_midi_output_trigger() 207 if (!bcd2k->midi_out_active) bcd2000_midi_output_trigger() 208 bcd2000_midi_send(bcd2k); bcd2000_midi_output_trigger() 210 bcd2k->midi_out_substream = NULL; bcd2000_midi_output_trigger() 216 struct bcd2000 *bcd2k = urb->context; bcd2000_output_complete() local 218 bcd2k->midi_out_active = 0; bcd2000_output_complete() 228 bcd2000_midi_send(bcd2k); bcd2000_output_complete() 234 struct bcd2000 *bcd2k = urb->context; bcd2000_input_complete() local 240 if (!bcd2k || urb->status == -ESHUTDOWN) bcd2000_input_complete() 244 bcd2000_midi_handle_input(bcd2k, urb->transfer_buffer, bcd2000_input_complete() 248 ret = usb_submit_urb(bcd2k->midi_in_urb, GFP_ATOMIC); bcd2000_input_complete() 250 dev_err(&bcd2k->dev->dev, PREFIX bcd2000_input_complete() 267 static void bcd2000_init_device(struct bcd2000 *bcd2k) bcd2000_init_device() argument 271 init_usb_anchor(&bcd2k->anchor); bcd2000_init_device() 272 usb_anchor_urb(bcd2k->midi_out_urb, &bcd2k->anchor); bcd2000_init_device() 273 usb_anchor_urb(bcd2k->midi_in_urb, &bcd2k->anchor); bcd2000_init_device() 276 memcpy(bcd2k->midi_out_buf, bcd2000_init_sequence, 52); bcd2000_init_device() 277 bcd2k->midi_out_urb->transfer_buffer_length = 52; bcd2000_init_device() 280 ret = usb_submit_urb(bcd2k->midi_out_urb, GFP_KERNEL); bcd2000_init_device() 282 dev_err(&bcd2k->dev->dev, PREFIX bcd2000_init_device() 286 bcd2k->midi_out_active = 1; bcd2000_init_device() 289 ret = usb_submit_urb(bcd2k->midi_in_urb, GFP_KERNEL); bcd2000_init_device() 291 dev_err(&bcd2k->dev->dev, PREFIX bcd2000_init_device() 296 usb_wait_anchor_empty_timeout(&bcd2k->anchor, 1000); bcd2000_init_device() 299 static int bcd2000_init_midi(struct bcd2000 *bcd2k) bcd2000_init_midi() argument 304 ret = snd_rawmidi_new(bcd2k->card, bcd2k->card->shortname, 0, bcd2000_init_midi() 312 strlcpy(rmidi->name, bcd2k->card->shortname, sizeof(rmidi->name)); bcd2000_init_midi() 315 rmidi->private_data = bcd2k; bcd2000_init_midi() 325 bcd2k->rmidi = rmidi; bcd2000_init_midi() 327 bcd2k->midi_in_urb = usb_alloc_urb(0, GFP_KERNEL); bcd2000_init_midi() 328 bcd2k->midi_out_urb = usb_alloc_urb(0, GFP_KERNEL); bcd2000_init_midi() 330 if (!bcd2k->midi_in_urb || !bcd2k->midi_out_urb) { bcd2000_init_midi() 331 dev_err(&bcd2k->dev->dev, PREFIX "usb_alloc_urb failed\n"); bcd2000_init_midi() 335 usb_fill_int_urb(bcd2k->midi_in_urb, bcd2k->dev, bcd2000_init_midi() 336 usb_rcvintpipe(bcd2k->dev, 0x81), bcd2000_init_midi() 337 bcd2k->midi_in_buf, BUFSIZE, bcd2000_init_midi() 338 bcd2000_input_complete, bcd2k, 1); bcd2000_init_midi() 340 usb_fill_int_urb(bcd2k->midi_out_urb, bcd2k->dev, bcd2000_init_midi() 341 usb_sndintpipe(bcd2k->dev, 0x1), bcd2000_init_midi() 342 bcd2k->midi_out_buf, BUFSIZE, bcd2000_init_midi() 343 bcd2000_output_complete, bcd2k, 1); bcd2000_init_midi() 345 bcd2000_init_device(bcd2k); bcd2000_init_midi() 350 static void bcd2000_free_usb_related_resources(struct bcd2000 *bcd2k, bcd2000_free_usb_related_resources() argument 355 usb_free_urb(bcd2k->midi_out_urb); bcd2000_free_usb_related_resources() 356 usb_free_urb(bcd2k->midi_in_urb); bcd2000_free_usb_related_resources() 358 if (bcd2k->intf) { bcd2000_free_usb_related_resources() 359 usb_set_intfdata(bcd2k->intf, NULL); bcd2000_free_usb_related_resources() 360 bcd2k->intf = NULL; bcd2000_free_usb_related_resources() 368 struct bcd2000 *bcd2k; bcd2000_probe() local 385 THIS_MODULE, sizeof(*bcd2k), &card); bcd2000_probe() 391 bcd2k = card->private_data; bcd2000_probe() 392 bcd2k->dev = interface_to_usbdev(interface); bcd2000_probe() 393 bcd2k->card = card; bcd2000_probe() 394 bcd2k->card_index = card_index; bcd2000_probe() 395 bcd2k->intf = interface; bcd2000_probe() 401 usb_make_path(bcd2k->dev, usb_path, sizeof(usb_path)); bcd2000_probe() 402 snprintf(bcd2k->card->longname, sizeof(bcd2k->card->longname), bcd2000_probe() 406 err = bcd2000_init_midi(bcd2k); bcd2000_probe() 414 usb_set_intfdata(interface, bcd2k); bcd2000_probe() 421 dev_info(&bcd2k->dev->dev, PREFIX "error during probing"); bcd2000_probe() 422 bcd2000_free_usb_related_resources(bcd2k, interface); bcd2000_probe() 430 struct bcd2000 *bcd2k = usb_get_intfdata(interface); bcd2000_disconnect() local 432 if (!bcd2k) bcd2000_disconnect() 438 snd_card_disconnect(bcd2k->card); bcd2000_disconnect() 440 bcd2000_free_usb_related_resources(bcd2k, interface); bcd2000_disconnect() 442 clear_bit(bcd2k->card_index, devices_used); bcd2000_disconnect() 444 snd_card_free_when_closed(bcd2k->card); bcd2000_disconnect()
|