^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * oxfw_proc.c - a part of driver for OXFW970/971 based devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2014 Takashi Sakamoto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "./oxfw.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static void proc_read_formation(struct snd_info_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct snd_info_buffer *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct snd_oxfw *oxfw = entry->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct snd_oxfw_stream_formation formation, curr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) u8 *format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) char flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) int i, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /* Show input. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) err = snd_oxfw_stream_get_current_formation(oxfw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) AVC_GENERAL_PLUG_DIR_IN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) &curr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) snd_iprintf(buffer, "Input Stream to device:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) format = oxfw->rx_stream_formats[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if (format == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) err = snd_oxfw_stream_parse_format(format, &formation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) if (memcmp(&formation, &curr, sizeof(curr)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) flag = '*';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) flag = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) snd_iprintf(buffer, "%c\t%d\t%d\t%d\n", flag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) formation.rate, formation.pcm, formation.midi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if (!oxfw->has_output)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* Show output. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) err = snd_oxfw_stream_get_current_formation(oxfw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) AVC_GENERAL_PLUG_DIR_OUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) &curr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) snd_iprintf(buffer, "Output Stream from device:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) format = oxfw->tx_stream_formats[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) if (format == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) err = snd_oxfw_stream_parse_format(format, &formation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (memcmp(&formation, &curr, sizeof(curr)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) flag = '*';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) flag = ' ';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) snd_iprintf(buffer, "%c\t%d\t%d\t%d\n", flag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) formation.rate, formation.pcm, formation.midi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) static void add_node(struct snd_oxfw *oxfw, struct snd_info_entry *root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) void (*op)(struct snd_info_entry *e,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct snd_info_buffer *b))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct snd_info_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) entry = snd_info_create_card_entry(oxfw->card, name, root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) snd_info_set_text_ops(entry, oxfw, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) void snd_oxfw_proc_init(struct snd_oxfw *oxfw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct snd_info_entry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * All nodes are automatically removed at snd_card_disconnect(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * by following to link list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) root = snd_info_create_card_entry(oxfw->card, "firewire",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) oxfw->card->proc_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (root == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) root->mode = S_IFDIR | 0555;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) add_node(oxfw, root, "formation", proc_read_formation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }