1 // SPDX-License-Identifier: GPL-2.0-only
3 * motu-proc.c - a part of driver for MOTU FireWire series
5 * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
10 static const char *const clock_names[] = {
11 [SND_MOTU_CLOCK_SOURCE_INTERNAL] = "Internal",
12 [SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB] = "ADAT on Dsub-9pin interface",
13 [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT] = "ADAT on optical interface",
14 [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_A] = "ADAT on optical interface A",
15 [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_B] = "ADAT on optical interface B",
16 [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT] = "S/PDIF on optical interface",
17 [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_A] = "S/PDIF on optical interface A",
18 [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_B] = "S/PDIF on optical interface B",
19 [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX] = "S/PCIF on coaxial interface",
20 [SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR] = "AESEBU on XLR interface",
21 [SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC] = "Word clock on BNC interface",
24 static void proc_read_clock(struct snd_info_entry *entry,
25 struct snd_info_buffer *buffer)
28 struct snd_motu *motu = entry->private_data;
29 const struct snd_motu_protocol *const protocol = motu->spec->protocol;
31 enum snd_motu_clock_source source;
33 if (protocol->get_clock_rate(motu, &rate) < 0)
35 if (protocol->get_clock_source(motu, &source) < 0)
38 snd_iprintf(buffer, "Rate:\t%d\n", rate);
39 snd_iprintf(buffer, "Source:\t%s\n", clock_names[source]);
42 static void proc_read_format(struct snd_info_entry *entry,
43 struct snd_info_buffer *buffer)
45 struct snd_motu *motu = entry->private_data;
46 const struct snd_motu_protocol *const protocol = motu->spec->protocol;
48 struct snd_motu_packet_format *formats;
51 if (protocol->cache_packet_formats(motu) < 0)
54 snd_iprintf(buffer, "tx:\tmsg\tfixed\tdiffered\n");
55 for (i = 0; i < SND_MOTU_CLOCK_RATE_COUNT; ++i) {
58 formats = &motu->tx_packet_formats;
61 snd_motu_clock_rates[i],
63 formats->fixed_part_pcm_chunks[mode],
64 formats->differed_part_pcm_chunks[mode]);
67 snd_iprintf(buffer, "rx:\tmsg\tfixed\tdiffered\n");
68 for (i = 0; i < SND_MOTU_CLOCK_RATE_COUNT; ++i) {
71 formats = &motu->rx_packet_formats;
74 snd_motu_clock_rates[i],
76 formats->fixed_part_pcm_chunks[mode],
77 formats->differed_part_pcm_chunks[mode]);
81 static void add_node(struct snd_motu *motu, struct snd_info_entry *root,
83 void (*op)(struct snd_info_entry *e,
84 struct snd_info_buffer *b))
86 struct snd_info_entry *entry;
88 entry = snd_info_create_card_entry(motu->card, name, root);
90 snd_info_set_text_ops(entry, motu, op);
93 void snd_motu_proc_init(struct snd_motu *motu)
95 struct snd_info_entry *root;
98 * All nodes are automatically removed at snd_card_disconnect(),
99 * by following to link list.
101 root = snd_info_create_card_entry(motu->card, "firewire",
102 motu->card->proc_root);
105 root->mode = S_IFDIR | 0555;
107 add_node(motu, root, "clock", proc_read_clock);
108 add_node(motu, root, "format", proc_read_format);