Lines Matching refs:ump
16 #define ump_err(ump, fmt, args...) dev_err((ump)->core.dev, fmt, ##args) argument
17 #define ump_warn(ump, fmt, args...) dev_warn((ump)->core.dev, fmt, ##args) argument
18 #define ump_info(ump, fmt, args...) dev_info((ump)->core.dev, fmt, ##args) argument
19 #define ump_dbg(ump, fmt, args...) dev_dbg((ump)->core.dev, fmt, ##args) argument
33 static void ump_handle_stream_msg(struct snd_ump_endpoint *ump,
36 static int process_legacy_output(struct snd_ump_endpoint *ump,
38 static void process_legacy_input(struct snd_ump_endpoint *ump, const u32 *src,
41 static inline int process_legacy_output(struct snd_ump_endpoint *ump, in process_legacy_output() argument
46 static inline void process_legacy_input(struct snd_ump_endpoint *ump, in process_legacy_input() argument
74 struct snd_ump_endpoint *ump = rawmidi_to_ump(rmidi); in snd_ump_endpoint_free() local
77 while (!list_empty(&ump->block_list)) { in snd_ump_endpoint_free()
78 fb = list_first_entry(&ump->block_list, struct snd_ump_block, in snd_ump_endpoint_free()
86 if (ump->private_free) in snd_ump_endpoint_free()
87 ump->private_free(ump); in snd_ump_endpoint_free()
90 kfree(ump->out_cvts); in snd_ump_endpoint_free()
123 struct snd_ump_endpoint *ump; in snd_ump_endpoint_new() local
133 ump = kzalloc(sizeof(*ump), GFP_KERNEL); in snd_ump_endpoint_new()
134 if (!ump) in snd_ump_endpoint_new()
136 INIT_LIST_HEAD(&ump->block_list); in snd_ump_endpoint_new()
137 mutex_init(&ump->open_mutex); in snd_ump_endpoint_new()
138 init_waitqueue_head(&ump->stream_wait); in snd_ump_endpoint_new()
140 spin_lock_init(&ump->legacy_locks[0]); in snd_ump_endpoint_new()
141 spin_lock_init(&ump->legacy_locks[1]); in snd_ump_endpoint_new()
143 err = snd_rawmidi_init(&ump->core, card, id, device, in snd_ump_endpoint_new()
146 snd_rawmidi_free(&ump->core); in snd_ump_endpoint_new()
150 ump->info.card = card->number; in snd_ump_endpoint_new()
151 ump->info.device = device; in snd_ump_endpoint_new()
153 ump->core.private_free = snd_ump_endpoint_free; in snd_ump_endpoint_new()
154 ump->core.ops = &snd_ump_rawmidi_ops; in snd_ump_endpoint_new()
156 snd_rawmidi_set_ops(&ump->core, SNDRV_RAWMIDI_STREAM_INPUT, in snd_ump_endpoint_new()
159 snd_rawmidi_set_ops(&ump->core, SNDRV_RAWMIDI_STREAM_OUTPUT, in snd_ump_endpoint_new()
162 ump_dbg(ump, "Created a UMP EP #%d (%s)\n", device, id); in snd_ump_endpoint_new()
163 *ump_ret = ump; in snd_ump_endpoint_new()
176 struct snd_ump_endpoint *ump = device->private_data; in snd_ump_dev_seq_free() local
178 ump->seq_dev = NULL; in snd_ump_dev_seq_free()
185 struct snd_ump_endpoint *ump = rawmidi_to_ump(rmidi); in snd_ump_dev_register() local
188 err = snd_seq_device_new(ump->core.card, ump->core.device, in snd_ump_dev_register()
189 SNDRV_SEQ_DEV_ID_UMP, 0, &ump->seq_dev); in snd_ump_dev_register()
192 ump->seq_dev->private_data = ump; in snd_ump_dev_register()
193 ump->seq_dev->private_free = snd_ump_dev_seq_free; in snd_ump_dev_register()
194 snd_device_register(ump->core.card, ump->seq_dev); in snd_ump_dev_register()
205 snd_ump_get_block(struct snd_ump_endpoint *ump, unsigned char id) in snd_ump_get_block() argument
209 list_for_each_entry(fb, &ump->block_list, list) { in snd_ump_get_block()
221 struct snd_ump_endpoint *ump = rawmidi_to_ump(substream->rmidi); in snd_ump_rawmidi_open() local
225 if (ump->substreams[dir]) in snd_ump_rawmidi_open()
227 err = ump->ops->open(ump, dir); in snd_ump_rawmidi_open()
230 ump->substreams[dir] = substream; in snd_ump_rawmidi_open()
236 struct snd_ump_endpoint *ump = rawmidi_to_ump(substream->rmidi); in snd_ump_rawmidi_close() local
239 ump->substreams[dir] = NULL; in snd_ump_rawmidi_close()
240 ump->ops->close(ump, dir); in snd_ump_rawmidi_close()
247 struct snd_ump_endpoint *ump = rawmidi_to_ump(substream->rmidi); in snd_ump_rawmidi_trigger() local
250 ump->ops->trigger(ump, dir, up); in snd_ump_rawmidi_trigger()
255 struct snd_ump_endpoint *ump = rawmidi_to_ump(substream->rmidi); in snd_ump_rawmidi_drain() local
257 if (ump->ops->drain) in snd_ump_rawmidi_drain()
258 ump->ops->drain(ump, SNDRV_RAWMIDI_STREAM_OUTPUT); in snd_ump_rawmidi_drain()
275 int snd_ump_receive_ump_val(struct snd_ump_endpoint *ump, u32 val) in snd_ump_receive_ump_val() argument
279 if (!ump->input_pending) in snd_ump_receive_ump_val()
280 ump->input_pending = ump_packet_words[ump_message_type(val)]; in snd_ump_receive_ump_val()
282 ump->input_buf[ump->input_buf_head++] = val; in snd_ump_receive_ump_val()
283 ump->input_pending--; in snd_ump_receive_ump_val()
284 if (!ump->input_pending) { in snd_ump_receive_ump_val()
285 words = ump->input_buf_head; in snd_ump_receive_ump_val()
286 ump->input_buf_head = 0; in snd_ump_receive_ump_val()
303 int snd_ump_receive(struct snd_ump_endpoint *ump, const u32 *buffer, int count) in snd_ump_receive() argument
310 n = snd_ump_receive_ump_val(ump, *p++); in snd_ump_receive()
313 ump_handle_stream_msg(ump, ump->input_buf, n); in snd_ump_receive()
315 if (ump->seq_ops) in snd_ump_receive()
316 ump->seq_ops->input_receive(ump, ump->input_buf, n); in snd_ump_receive()
318 process_legacy_input(ump, ump->input_buf, n); in snd_ump_receive()
321 substream = ump->substreams[SNDRV_RAWMIDI_STREAM_INPUT]; in snd_ump_receive()
338 int snd_ump_transmit(struct snd_ump_endpoint *ump, u32 *buffer, int count) in snd_ump_transmit() argument
341 ump->substreams[SNDRV_RAWMIDI_STREAM_OUTPUT]; in snd_ump_transmit()
350 return process_legacy_output(ump, buffer, count); in snd_ump_transmit()
363 int snd_ump_block_new(struct snd_ump_endpoint *ump, unsigned int blk, in snd_ump_block_new() argument
372 if (snd_ump_get_block(ump, blk)) in snd_ump_block_new()
379 fb->ump = ump; in snd_ump_block_new()
380 fb->info.card = ump->info.card; in snd_ump_block_new()
381 fb->info.device = ump->info.device; in snd_ump_block_new()
383 if (blk >= ump->info.num_blocks) in snd_ump_block_new()
384 ump->info.num_blocks = blk + 1; in snd_ump_block_new()
394 list_for_each_entry(p, &ump->block_list, list) { in snd_ump_block_new()
400 list_add_tail(&fb->list, &ump->block_list); in snd_ump_block_new()
403 ump_dbg(ump, "Created a UMP Block #%d (%s)\n", blk, fb->info.name); in snd_ump_block_new()
409 static int snd_ump_ioctl_block(struct snd_ump_endpoint *ump, in snd_ump_ioctl_block() argument
417 fb = snd_ump_get_block(ump, id); in snd_ump_ioctl_block()
431 struct snd_ump_endpoint *ump = rawmidi_to_ump(rmidi); in snd_ump_ioctl() local
435 if (copy_to_user(argp, &ump->info, sizeof(ump->info))) in snd_ump_ioctl()
439 return snd_ump_ioctl_block(ump, argp); in snd_ump_ioctl()
441 ump_dbg(ump, "rawmidi: unknown command = 0x%x\n", cmd); in snd_ump_ioctl()
479 struct snd_ump_endpoint *ump = rawmidi_to_ump(rmidi); in snd_ump_proc_read() local
482 snd_iprintf(buffer, "EP Name: %s\n", ump->info.name); in snd_ump_proc_read()
483 snd_iprintf(buffer, "EP Product ID: %s\n", ump->info.product_id); in snd_ump_proc_read()
484 snd_iprintf(buffer, "UMP Version: 0x%04x\n", ump->info.version); in snd_ump_proc_read()
485 snd_iprintf(buffer, "Protocol Caps: 0x%08x\n", ump->info.protocol_caps); in snd_ump_proc_read()
486 snd_iprintf(buffer, "Protocol: 0x%08x\n", ump->info.protocol); in snd_ump_proc_read()
487 if (ump->info.version) { in snd_ump_proc_read()
489 ump->info.manufacturer_id); in snd_ump_proc_read()
490 snd_iprintf(buffer, "Family ID: 0x%04x\n", ump->info.family_id); in snd_ump_proc_read()
491 snd_iprintf(buffer, "Model ID: 0x%04x\n", ump->info.model_id); in snd_ump_proc_read()
492 snd_iprintf(buffer, "SW Revision: 0x%4phN\n", ump->info.sw_revision); in snd_ump_proc_read()
495 (ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS) ? "Yes" : "No"); in snd_ump_proc_read()
496 snd_iprintf(buffer, "Num Blocks: %d\n\n", ump->info.num_blocks); in snd_ump_proc_read()
498 list_for_each_entry(fb, &ump->block_list, list) { in snd_ump_proc_read()
511 if (ump->info.version) { in snd_ump_proc_read()
524 void snd_ump_update_group_attrs(struct snd_ump_endpoint *ump) in snd_ump_update_group_attrs() argument
531 group = &ump->groups[i]; in snd_ump_update_group_attrs()
540 list_for_each_entry(fb, &ump->block_list, list) { in snd_ump_update_group_attrs()
543 group = &ump->groups[fb->info.first_group]; in snd_ump_update_group_attrs()
584 static int ump_request_open(struct snd_ump_endpoint *ump) in ump_request_open() argument
586 return snd_rawmidi_kernel_open(&ump->core, 0, in ump_request_open()
588 &ump->stream_rfile); in ump_request_open()
591 static void ump_request_close(struct snd_ump_endpoint *ump) in ump_request_close() argument
593 snd_rawmidi_kernel_release(&ump->stream_rfile); in ump_request_close()
600 static int ump_req_msg(struct snd_ump_endpoint *ump, u32 req1, u32 req2, in ump_req_msg() argument
605 ump_dbg(ump, "%s: request %08x %08x, wait-for %08x\n", in ump_req_msg()
610 ump->stream_finished = 0; in ump_req_msg()
611 ump->stream_wait_for = reply; in ump_req_msg()
612 snd_rawmidi_kernel_write(ump->stream_rfile.output, in ump_req_msg()
614 wait_event_timeout(ump->stream_wait, ump->stream_finished, in ump_req_msg()
616 if (!READ_ONCE(ump->stream_finished)) { in ump_req_msg()
617 ump_dbg(ump, "%s: request timed out\n", __func__); in ump_req_msg()
620 ump->stream_finished = 0; in ump_req_msg()
621 ump_dbg(ump, "%s: reply: %08x %08x %08x %08x\n", in ump_req_msg()
629 static int ump_append_string(struct snd_ump_endpoint *ump, char *dest, in ump_append_string() argument
658 static void choose_default_protocol(struct snd_ump_endpoint *ump) in choose_default_protocol() argument
660 if (ump->info.protocol & SNDRV_UMP_EP_INFO_PROTO_MIDI_MASK) in choose_default_protocol()
662 if (ump->info.protocol_caps & SNDRV_UMP_EP_INFO_PROTO_MIDI2) in choose_default_protocol()
663 ump->info.protocol |= SNDRV_UMP_EP_INFO_PROTO_MIDI2; in choose_default_protocol()
665 ump->info.protocol |= SNDRV_UMP_EP_INFO_PROTO_MIDI1; in choose_default_protocol()
669 static int ump_handle_ep_info_msg(struct snd_ump_endpoint *ump, in ump_handle_ep_info_msg() argument
672 ump->info.version = (buf->ep_info.ump_version_major << 8) | in ump_handle_ep_info_msg()
674 ump->info.num_blocks = buf->ep_info.num_function_blocks; in ump_handle_ep_info_msg()
675 if (ump->info.num_blocks > SNDRV_UMP_MAX_BLOCKS) { in ump_handle_ep_info_msg()
676 ump_info(ump, "Invalid function blocks %d, fallback to 1\n", in ump_handle_ep_info_msg()
677 ump->info.num_blocks); in ump_handle_ep_info_msg()
678 ump->info.num_blocks = 1; in ump_handle_ep_info_msg()
682 ump->info.flags |= SNDRV_UMP_EP_INFO_STATIC_BLOCKS; in ump_handle_ep_info_msg()
684 ump->info.protocol_caps = (buf->ep_info.protocol << 8) | in ump_handle_ep_info_msg()
687 ump_dbg(ump, "EP info: version=%x, num_blocks=%x, proto_caps=%x\n", in ump_handle_ep_info_msg()
688 ump->info.version, ump->info.num_blocks, ump->info.protocol_caps); in ump_handle_ep_info_msg()
690 ump->info.protocol &= ump->info.protocol_caps; in ump_handle_ep_info_msg()
691 choose_default_protocol(ump); in ump_handle_ep_info_msg()
697 static int ump_handle_device_info_msg(struct snd_ump_endpoint *ump, in ump_handle_device_info_msg() argument
700 ump->info.manufacturer_id = buf->device_info.manufacture_id & 0x7f7f7f; in ump_handle_device_info_msg()
701 ump->info.family_id = (buf->device_info.family_msb << 8) | in ump_handle_device_info_msg()
703 ump->info.model_id = (buf->device_info.model_msb << 8) | in ump_handle_device_info_msg()
705 ump->info.sw_revision[0] = (buf->device_info.sw_revision >> 24) & 0x7f; in ump_handle_device_info_msg()
706 ump->info.sw_revision[1] = (buf->device_info.sw_revision >> 16) & 0x7f; in ump_handle_device_info_msg()
707 ump->info.sw_revision[2] = (buf->device_info.sw_revision >> 8) & 0x7f; in ump_handle_device_info_msg()
708 ump->info.sw_revision[3] = buf->device_info.sw_revision & 0x7f; in ump_handle_device_info_msg()
709 ump_dbg(ump, "EP devinfo: manid=%08x, family=%04x, model=%04x, sw=%4phN\n", in ump_handle_device_info_msg()
710 ump->info.manufacturer_id, in ump_handle_device_info_msg()
711 ump->info.family_id, in ump_handle_device_info_msg()
712 ump->info.model_id, in ump_handle_device_info_msg()
713 ump->info.sw_revision); in ump_handle_device_info_msg()
718 static int ump_handle_ep_name_msg(struct snd_ump_endpoint *ump, in ump_handle_ep_name_msg() argument
721 return ump_append_string(ump, ump->info.name, sizeof(ump->info.name), in ump_handle_ep_name_msg()
726 static int ump_handle_product_id_msg(struct snd_ump_endpoint *ump, in ump_handle_product_id_msg() argument
729 return ump_append_string(ump, ump->info.product_id, in ump_handle_product_id_msg()
730 sizeof(ump->info.product_id), in ump_handle_product_id_msg()
735 static void seq_notify_protocol(struct snd_ump_endpoint *ump) in seq_notify_protocol() argument
738 if (ump->seq_ops && ump->seq_ops->switch_protocol) in seq_notify_protocol()
739 ump->seq_ops->switch_protocol(ump); in seq_notify_protocol()
750 int snd_ump_switch_protocol(struct snd_ump_endpoint *ump, unsigned int protocol) in snd_ump_switch_protocol() argument
754 protocol &= ump->info.protocol_caps; in snd_ump_switch_protocol()
755 if (protocol == ump->info.protocol) in snd_ump_switch_protocol()
763 ump->info.protocol = protocol; in snd_ump_switch_protocol()
764 ump_dbg(ump, "New protocol = %x (caps = %x)\n", in snd_ump_switch_protocol()
765 protocol, ump->info.protocol_caps); in snd_ump_switch_protocol()
766 seq_notify_protocol(ump); in snd_ump_switch_protocol()
772 static int ump_handle_stream_cfg_msg(struct snd_ump_endpoint *ump, in ump_handle_stream_cfg_msg() argument
778 snd_ump_switch_protocol(ump, protocol); in ump_handle_stream_cfg_msg()
783 static void fill_fb_info(struct snd_ump_endpoint *ump, in fill_fb_info() argument
796 …ump_dbg(ump, "FB %d: dir=%d, active=%d, first_gp=%d, num_gp=%d, midici=%d, sysex8=%d, flags=0x%x\n… in fill_fb_info()
803 ump_dbg(ump, "FB %d: corrected groups to 1 for MIDI1\n", in fill_fb_info()
809 static bool is_fb_info_updated(struct snd_ump_endpoint *ump, in is_fb_info_updated() argument
815 if (ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS) { in is_fb_info_updated()
816 ump_info(ump, "Skipping static FB info update (blk#%d)\n", in is_fb_info_updated()
822 fill_fb_info(ump, (struct snd_ump_block_info *)tmpbuf, buf); in is_fb_info_updated()
827 static void seq_notify_fb_change(struct snd_ump_endpoint *ump, in seq_notify_fb_change() argument
831 if (ump->seq_ops && ump->seq_ops->notify_fb_change) in seq_notify_fb_change()
832 ump->seq_ops->notify_fb_change(ump, fb); in seq_notify_fb_change()
837 static int ump_handle_fb_info_msg(struct snd_ump_endpoint *ump, in ump_handle_fb_info_msg() argument
844 fb = snd_ump_get_block(ump, blk); in ump_handle_fb_info_msg()
847 if (!fb && ump->parsed) { in ump_handle_fb_info_msg()
848 ump_info(ump, "Function Block Info Update for non-existing block %d\n", in ump_handle_fb_info_msg()
854 if (ump->parsed && !is_fb_info_updated(ump, fb, buf)) in ump_handle_fb_info_msg()
858 fill_fb_info(ump, &fb->info, buf); in ump_handle_fb_info_msg()
859 if (ump->parsed) { in ump_handle_fb_info_msg()
860 snd_ump_update_group_attrs(ump); in ump_handle_fb_info_msg()
861 seq_notify_fb_change(ump, fb); in ump_handle_fb_info_msg()
869 static int ump_handle_fb_name_msg(struct snd_ump_endpoint *ump, in ump_handle_fb_name_msg() argument
877 fb = snd_ump_get_block(ump, blk); in ump_handle_fb_name_msg()
881 if (ump->parsed && in ump_handle_fb_name_msg()
882 (ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS)) { in ump_handle_fb_name_msg()
883 ump_dbg(ump, "Skipping static FB name update (blk#%d)\n", in ump_handle_fb_name_msg()
888 ret = ump_append_string(ump, fb->info.name, sizeof(fb->info.name), in ump_handle_fb_name_msg()
891 if (ret > 0 && ump->parsed) { in ump_handle_fb_name_msg()
892 snd_ump_update_group_attrs(ump); in ump_handle_fb_name_msg()
893 seq_notify_fb_change(ump, fb); in ump_handle_fb_name_msg()
898 static int create_block_from_fb_info(struct snd_ump_endpoint *ump, int blk) in create_block_from_fb_info() argument
903 (const union snd_ump_stream_msg *)ump->input_buf; in create_block_from_fb_info()
910 err = ump_req_msg(ump, msg, 0, UMP_STREAM_MSG_STATUS_FB_INFO); in create_block_from_fb_info()
912 ump_dbg(ump, "Unable to get FB info for block %d\n", blk); in create_block_from_fb_info()
918 ump_dbg(ump, "Inconsistent input: 0x%x\n", *buf->raw); in create_block_from_fb_info()
926 err = snd_ump_block_new(ump, blk, direction, first_group, num_groups, in create_block_from_fb_info()
931 fill_fb_info(ump, &fb->info, buf); in create_block_from_fb_info()
935 err = ump_req_msg(ump, msg, 0, UMP_STREAM_MSG_STATUS_FB_NAME); in create_block_from_fb_info()
937 ump_dbg(ump, "Unable to get UMP FB name string #%d\n", blk); in create_block_from_fb_info()
943 static void ump_handle_stream_msg(struct snd_ump_endpoint *ump, in ump_handle_stream_msg() argument
951 if (ump->no_process_stream) in ump_handle_stream_msg()
955 ump_dbg(ump, "Stream msg: %08x %08x %08x %08x\n", in ump_handle_stream_msg()
965 ret = ump_handle_ep_info_msg(ump, msg); in ump_handle_stream_msg()
968 ret = ump_handle_device_info_msg(ump, msg); in ump_handle_stream_msg()
971 ret = ump_handle_ep_name_msg(ump, msg); in ump_handle_stream_msg()
974 ret = ump_handle_product_id_msg(ump, msg); in ump_handle_stream_msg()
977 ret = ump_handle_stream_cfg_msg(ump, msg); in ump_handle_stream_msg()
980 ret = ump_handle_fb_info_msg(ump, msg); in ump_handle_stream_msg()
983 ret = ump_handle_fb_name_msg(ump, msg); in ump_handle_stream_msg()
990 if (ret > 0 && ump->stream_wait_for == status) { in ump_handle_stream_msg()
991 WRITE_ONCE(ump->stream_finished, 1); in ump_handle_stream_msg()
992 wake_up(&ump->stream_wait); in ump_handle_stream_msg()
1003 int snd_ump_parse_endpoint(struct snd_ump_endpoint *ump) in snd_ump_parse_endpoint() argument
1008 if (!(ump->core.info_flags & SNDRV_RAWMIDI_INFO_DUPLEX)) in snd_ump_parse_endpoint()
1011 err = ump_request_open(ump); in snd_ump_parse_endpoint()
1013 ump_dbg(ump, "Unable to open rawmidi device: %d\n", err); in snd_ump_parse_endpoint()
1020 err = ump_req_msg(ump, msg, UMP_STREAM_MSG_REQUEST_EP_INFO, in snd_ump_parse_endpoint()
1023 ump_dbg(ump, "Unable to get UMP EP info\n"); in snd_ump_parse_endpoint()
1028 err = ump_req_msg(ump, msg, UMP_STREAM_MSG_REQUEST_DEVICE_INFO, in snd_ump_parse_endpoint()
1031 ump_dbg(ump, "Unable to get UMP EP device info\n"); in snd_ump_parse_endpoint()
1034 err = ump_req_msg(ump, msg, UMP_STREAM_MSG_REQUEST_EP_NAME, in snd_ump_parse_endpoint()
1037 ump_dbg(ump, "Unable to get UMP EP name string\n"); in snd_ump_parse_endpoint()
1040 err = ump_req_msg(ump, msg, UMP_STREAM_MSG_REQUEST_PRODUCT_ID, in snd_ump_parse_endpoint()
1043 ump_dbg(ump, "Unable to get UMP EP product ID string\n"); in snd_ump_parse_endpoint()
1046 err = ump_req_msg(ump, msg, UMP_STREAM_MSG_REQUEST_STREAM_CFG, in snd_ump_parse_endpoint()
1049 ump_dbg(ump, "Unable to get UMP EP stream config\n"); in snd_ump_parse_endpoint()
1052 choose_default_protocol(ump); in snd_ump_parse_endpoint()
1055 for (blk = 0; blk < ump->info.num_blocks; blk++) { in snd_ump_parse_endpoint()
1056 err = create_block_from_fb_info(ump, blk); in snd_ump_parse_endpoint()
1062 snd_ump_update_group_attrs(ump); in snd_ump_parse_endpoint()
1065 ump->parsed = true; in snd_ump_parse_endpoint()
1066 ump_request_close(ump); in snd_ump_parse_endpoint()
1079 struct snd_ump_endpoint *ump = substream->rmidi->private_data; in snd_ump_legacy_open() local
1081 int group = ump->legacy_mapping[substream->number]; in snd_ump_legacy_open()
1084 guard(mutex)(&ump->open_mutex); in snd_ump_legacy_open()
1085 if (ump->legacy_substreams[dir][group]) in snd_ump_legacy_open()
1088 if (!ump->legacy_out_opens) { in snd_ump_legacy_open()
1089 err = snd_rawmidi_kernel_open(&ump->core, 0, in snd_ump_legacy_open()
1092 &ump->legacy_out_rfile); in snd_ump_legacy_open()
1096 ump->legacy_out_opens++; in snd_ump_legacy_open()
1097 snd_ump_convert_reset(&ump->out_cvts[group]); in snd_ump_legacy_open()
1099 guard(spinlock_irq)(&ump->legacy_locks[dir]); in snd_ump_legacy_open()
1100 ump->legacy_substreams[dir][group] = substream; in snd_ump_legacy_open()
1106 struct snd_ump_endpoint *ump = substream->rmidi->private_data; in snd_ump_legacy_close() local
1108 int group = ump->legacy_mapping[substream->number]; in snd_ump_legacy_close()
1110 guard(mutex)(&ump->open_mutex); in snd_ump_legacy_close()
1111 scoped_guard(spinlock_irq, &ump->legacy_locks[dir]) in snd_ump_legacy_close()
1112 ump->legacy_substreams[dir][group] = NULL; in snd_ump_legacy_close()
1114 if (!--ump->legacy_out_opens) in snd_ump_legacy_close()
1115 snd_rawmidi_kernel_release(&ump->legacy_out_rfile); in snd_ump_legacy_close()
1123 struct snd_ump_endpoint *ump = substream->rmidi->private_data; in snd_ump_legacy_trigger() local
1126 ump->ops->trigger(ump, dir, up); in snd_ump_legacy_trigger()
1131 struct snd_ump_endpoint *ump = substream->rmidi->private_data; in snd_ump_legacy_drain() local
1133 if (ump->ops->drain) in snd_ump_legacy_drain()
1134 ump->ops->drain(ump, SNDRV_RAWMIDI_STREAM_OUTPUT); in snd_ump_legacy_drain()
1160 static int process_legacy_output(struct snd_ump_endpoint *ump, in process_legacy_output() argument
1170 if (!ump->out_cvts || !ump->legacy_out_opens) in process_legacy_output()
1173 guard(spinlock_irqsave)(&ump->legacy_locks[dir]); in process_legacy_output()
1175 substream = ump->legacy_substreams[dir][group]; in process_legacy_output()
1178 ctx = &ump->out_cvts[group]; in process_legacy_output()
1179 protocol = ump->info.protocol; in process_legacy_output()
1181 ump->groups[group].is_midi1) in process_legacy_output()
1188 memcpy(buffer, ctx->ump, size); in process_legacy_output()
1196 static void process_legacy_input(struct snd_ump_endpoint *ump, const u32 *src, in process_legacy_input() argument
1208 guard(spinlock_irqsave)(&ump->legacy_locks[dir]); in process_legacy_input()
1209 substream = ump->legacy_substreams[dir][group]; in process_legacy_input()
1215 static int fill_legacy_mapping(struct snd_ump_endpoint *ump) in fill_legacy_mapping() argument
1221 if (ump->info.flags & SNDRV_UMP_EP_INFO_STATIC_BLOCKS) { in fill_legacy_mapping()
1222 list_for_each_entry(fb, &ump->block_list, list) { in fill_legacy_mapping()
1227 ump_info(ump, "No UMP Group is found in FB\n"); in fill_legacy_mapping()
1236 if ((group_maps & (1U << i)) && ump->groups[i].valid) in fill_legacy_mapping()
1237 ump->legacy_mapping[num++] = i; in fill_legacy_mapping()
1242 static void fill_substream_names(struct snd_ump_endpoint *ump, in fill_substream_names() argument
1250 idx = ump->legacy_mapping[s->number]; in fill_substream_names()
1251 name = ump->groups[idx].name; in fill_substream_names()
1253 name = ump->info.name; in fill_substream_names()
1259 int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump, in snd_ump_attach_legacy_rawmidi() argument
1266 ump->out_cvts = kcalloc(SNDRV_UMP_MAX_GROUPS, in snd_ump_attach_legacy_rawmidi()
1267 sizeof(*ump->out_cvts), GFP_KERNEL); in snd_ump_attach_legacy_rawmidi()
1268 if (!ump->out_cvts) in snd_ump_attach_legacy_rawmidi()
1271 num = fill_legacy_mapping(ump); in snd_ump_attach_legacy_rawmidi()
1273 input = ump->core.info_flags & SNDRV_RAWMIDI_INFO_INPUT; in snd_ump_attach_legacy_rawmidi()
1274 output = ump->core.info_flags & SNDRV_RAWMIDI_INFO_OUTPUT; in snd_ump_attach_legacy_rawmidi()
1275 err = snd_rawmidi_new(ump->core.card, id, device, in snd_ump_attach_legacy_rawmidi()
1279 kfree(ump->out_cvts); in snd_ump_attach_legacy_rawmidi()
1290 ump->info.name); in snd_ump_attach_legacy_rawmidi()
1291 rmidi->info_flags = ump->core.info_flags & ~SNDRV_RAWMIDI_INFO_UMP; in snd_ump_attach_legacy_rawmidi()
1293 rmidi->private_data = ump; in snd_ump_attach_legacy_rawmidi()
1294 ump->legacy_rmidi = rmidi; in snd_ump_attach_legacy_rawmidi()
1296 fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_INPUT); in snd_ump_attach_legacy_rawmidi()
1298 fill_substream_names(ump, rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT); in snd_ump_attach_legacy_rawmidi()
1300 ump_dbg(ump, "Created a legacy rawmidi #%d (%s)\n", device, id); in snd_ump_attach_legacy_rawmidi()