Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * motu-proc.c - a part of driver for MOTU FireWire series
0004  *
0005  * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
0006  */
0007 
0008 #include "./motu.h"
0009 
0010 static const char *const clock_names[] = {
0011     [SND_MOTU_CLOCK_SOURCE_INTERNAL] = "Internal",
0012     [SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB] = "ADAT on Dsub-9pin interface",
0013     [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT] = "ADAT on optical interface",
0014     [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_A] = "ADAT on optical interface A",
0015     [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_B] = "ADAT on optical interface B",
0016     [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT] = "S/PDIF on optical interface",
0017     [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_A] = "S/PDIF on optical interface A",
0018     [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_B] = "S/PDIF on optical interface B",
0019     [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX] = "S/PDIF on coaxial interface",
0020     [SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR] = "AESEBU on XLR interface",
0021     [SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC] = "Word clock on BNC interface",
0022     [SND_MOTU_CLOCK_SOURCE_SPH] = "Source packet header",
0023     [SND_MOTU_CLOCK_SOURCE_UNKNOWN] = "Unknown",
0024 };
0025 
0026 static void proc_read_clock(struct snd_info_entry *entry,
0027                 struct snd_info_buffer *buffer)
0028 {
0029 
0030     struct snd_motu *motu = entry->private_data;
0031     unsigned int rate;
0032     enum snd_motu_clock_source source;
0033 
0034     if (snd_motu_protocol_get_clock_rate(motu, &rate) < 0)
0035         return;
0036     if (snd_motu_protocol_get_clock_source(motu, &source) < 0)
0037         return;
0038 
0039     snd_iprintf(buffer, "Rate:\t%d\n", rate);
0040     snd_iprintf(buffer, "Source:\t%s\n", clock_names[source]);
0041 }
0042 
0043 static void proc_read_format(struct snd_info_entry *entry,
0044                  struct snd_info_buffer *buffer)
0045 {
0046     struct snd_motu *motu = entry->private_data;
0047     unsigned int mode;
0048     struct snd_motu_packet_format *formats;
0049     int i;
0050 
0051     if (snd_motu_protocol_cache_packet_formats(motu) < 0)
0052         return;
0053 
0054     snd_iprintf(buffer, "tx:\tmsg\tfixed\ttotal\n");
0055     for (i = 0; i < SND_MOTU_CLOCK_RATE_COUNT; ++i) {
0056         mode = i >> 1;
0057 
0058         formats = &motu->tx_packet_formats;
0059         snd_iprintf(buffer,
0060                 "%u:\t%u\t%u\t%u\n",
0061                 snd_motu_clock_rates[i],
0062                 formats->msg_chunks,
0063                 motu->spec->tx_fixed_pcm_chunks[mode],
0064                 formats->pcm_chunks[mode]);
0065     }
0066 
0067     snd_iprintf(buffer, "rx:\tmsg\tfixed\ttotal\n");
0068     for (i = 0; i < SND_MOTU_CLOCK_RATE_COUNT; ++i) {
0069         mode = i >> 1;
0070 
0071         formats = &motu->rx_packet_formats;
0072         snd_iprintf(buffer,
0073                 "%u:\t%u\t%u\t%u\n",
0074                 snd_motu_clock_rates[i],
0075                 formats->msg_chunks,
0076                 motu->spec->rx_fixed_pcm_chunks[mode],
0077                 formats->pcm_chunks[mode]);
0078     }
0079 }
0080 
0081 static void add_node(struct snd_motu *motu, struct snd_info_entry *root,
0082              const char *name,
0083              void (*op)(struct snd_info_entry *e,
0084                 struct snd_info_buffer *b))
0085 {
0086     struct snd_info_entry *entry;
0087 
0088     entry = snd_info_create_card_entry(motu->card, name, root);
0089     if (entry)
0090         snd_info_set_text_ops(entry, motu, op);
0091 }
0092 
0093 void snd_motu_proc_init(struct snd_motu *motu)
0094 {
0095     struct snd_info_entry *root;
0096 
0097     /*
0098      * All nodes are automatically removed at snd_card_disconnect(),
0099      * by following to link list.
0100      */
0101     root = snd_info_create_card_entry(motu->card, "firewire",
0102                       motu->card->proc_root);
0103     if (root == NULL)
0104         return;
0105     root->mode = S_IFDIR | 0555;
0106 
0107     add_node(motu, root, "clock", proc_read_clock);
0108     add_node(motu, root, "format", proc_read_format);
0109 }