~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/firewire/motu/motu-proc.c

Version: ~ [ linux-5.11 ] ~ [ linux-5.10.17 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.99 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.176 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.221 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.257 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.257 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * motu-proc.c - a part of driver for MOTU FireWire series
  3  *
  4  * Copyright (c) 2015-2017 Takashi Sakamoto <o-takashi@sakamocchi.jp>
  5  *
  6  * Licensed under the terms of the GNU General Public License, version 2.
  7  */
  8 
  9 #include "./motu.h"
 10 
 11 static const char *const clock_names[] = {
 12         [SND_MOTU_CLOCK_SOURCE_INTERNAL] = "Internal",
 13         [SND_MOTU_CLOCK_SOURCE_ADAT_ON_DSUB] = "ADAT on Dsub-9pin interface",
 14         [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT] = "ADAT on optical interface",
 15         [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_A] = "ADAT on optical interface A",
 16         [SND_MOTU_CLOCK_SOURCE_ADAT_ON_OPT_B] = "ADAT on optical interface B",
 17         [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT] = "S/PDIF on optical interface",
 18         [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_A] = "S/PDIF on optical interface A",
 19         [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_OPT_B] = "S/PDIF on optical interface B",
 20         [SND_MOTU_CLOCK_SOURCE_SPDIF_ON_COAX] = "S/PCIF on coaxial interface",
 21         [SND_MOTU_CLOCK_SOURCE_AESEBU_ON_XLR] = "AESEBU on XLR interface",
 22         [SND_MOTU_CLOCK_SOURCE_WORD_ON_BNC] = "Word clock on BNC interface",
 23 };
 24 
 25 static void proc_read_clock(struct snd_info_entry *entry,
 26                             struct snd_info_buffer *buffer)
 27 {
 28 
 29         struct snd_motu *motu = entry->private_data;
 30         const struct snd_motu_protocol *const protocol = motu->spec->protocol;
 31         unsigned int rate;
 32         enum snd_motu_clock_source source;
 33 
 34         if (protocol->get_clock_rate(motu, &rate) < 0)
 35                 return;
 36         if (protocol->get_clock_source(motu, &source) < 0)
 37                 return;
 38 
 39         snd_iprintf(buffer, "Rate:\t%d\n", rate);
 40         snd_iprintf(buffer, "Source:\t%s\n", clock_names[source]);
 41 }
 42 
 43 static void proc_read_format(struct snd_info_entry *entry,
 44                              struct snd_info_buffer *buffer)
 45 {
 46         struct snd_motu *motu = entry->private_data;
 47         const struct snd_motu_protocol *const protocol = motu->spec->protocol;
 48         unsigned int mode;
 49         struct snd_motu_packet_format *formats;
 50         int i;
 51 
 52         if (protocol->cache_packet_formats(motu) < 0)
 53                 return;
 54 
 55         snd_iprintf(buffer, "tx:\tmsg\tfixed\tdiffered\n");
 56         for (i = 0; i < SND_MOTU_CLOCK_RATE_COUNT; ++i) {
 57                 mode = i >> 1;
 58 
 59                 formats = &motu->tx_packet_formats;
 60                 snd_iprintf(buffer,
 61                             "%u:\t%u\t%u\t%u\n",
 62                             snd_motu_clock_rates[i],
 63                             formats->msg_chunks,
 64                             formats->fixed_part_pcm_chunks[mode],
 65                             formats->differed_part_pcm_chunks[mode]);
 66         }
 67 
 68         snd_iprintf(buffer, "rx:\tmsg\tfixed\tdiffered\n");
 69         for (i = 0; i < SND_MOTU_CLOCK_RATE_COUNT; ++i) {
 70                 mode = i >> 1;
 71 
 72                 formats = &motu->rx_packet_formats;
 73                 snd_iprintf(buffer,
 74                             "%u:\t%u\t%u\t%u\n",
 75                             snd_motu_clock_rates[i],
 76                             formats->msg_chunks,
 77                             formats->fixed_part_pcm_chunks[mode],
 78                             formats->differed_part_pcm_chunks[mode]);
 79         }
 80 }
 81 
 82 static void add_node(struct snd_motu *motu, struct snd_info_entry *root,
 83                      const char *name,
 84                      void (*op)(struct snd_info_entry *e,
 85                                 struct snd_info_buffer *b))
 86 {
 87         struct snd_info_entry *entry;
 88 
 89         entry = snd_info_create_card_entry(motu->card, name, root);
 90         if (entry == NULL)
 91                 return;
 92 
 93         snd_info_set_text_ops(entry, motu, op);
 94         if (snd_info_register(entry) < 0)
 95                 snd_info_free_entry(entry);
 96 }
 97 
 98 void snd_motu_proc_init(struct snd_motu *motu)
 99 {
100         struct snd_info_entry *root;
101 
102         /*
103          * All nodes are automatically removed at snd_card_disconnect(),
104          * by following to link list.
105          */
106         root = snd_info_create_card_entry(motu->card, "firewire",
107                                           motu->card->proc_root);
108         if (root == NULL)
109                 return;
110         root->mode = S_IFDIR | S_IRUGO | S_IXUGO;
111         if (snd_info_register(root) < 0) {
112                 snd_info_free_entry(root);
113                 return;
114         }
115 
116         add_node(motu, root, "clock", proc_read_clock);
117         add_node(motu, root, "format", proc_read_format);
118 }
119 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp