1 /* 2 * ff-proc.c - a part of driver for RME Fireface series 3 * 4 * Copyright (c) 2015-2017 Takashi Sakamoto 5 * 6 * Licensed under the terms of the GNU General Public License, version 2. 7 */ 8 9 #include "./ff.h" 10 11 const char *snd_ff_proc_get_clk_label(enum snd_ff_clock_src src) 12 { 13 static const char *const labels[] = { 14 "Internal", 15 "S/PDIF", 16 "ADAT1", 17 "ADAT2", 18 "Word", 19 "LTC", 20 }; 21 22 if (src >= ARRAY_SIZE(labels)) 23 return NULL; 24 25 return labels[src]; 26 } 27 28 static void proc_dump_status(struct snd_info_entry *entry, 29 struct snd_info_buffer *buffer) 30 { 31 struct snd_ff *ff = entry->private_data; 32 33 ff->spec->protocol->dump_status(ff, buffer); 34 } 35 36 static void add_node(struct snd_ff *ff, struct snd_info_entry *root, 37 const char *name, 38 void (*op)(struct snd_info_entry *e, 39 struct snd_info_buffer *b)) 40 { 41 struct snd_info_entry *entry; 42 43 entry = snd_info_create_card_entry(ff->card, name, root); 44 if (entry == NULL) 45 return; 46 47 snd_info_set_text_ops(entry, ff, op); 48 if (snd_info_register(entry) < 0) 49 snd_info_free_entry(entry); 50 } 51 52 void snd_ff_proc_init(struct snd_ff *ff) 53 { 54 struct snd_info_entry *root; 55 56 /* 57 * All nodes are automatically removed at snd_card_disconnect(), 58 * by following to link list. 59 */ 60 root = snd_info_create_card_entry(ff->card, "firewire", 61 ff->card->proc_root); 62 if (root == NULL) 63 return; 64 root->mode = S_IFDIR | 0555; 65 if (snd_info_register(root) < 0) { 66 snd_info_free_entry(root); 67 return; 68 } 69 70 add_node(ff, root, "status", proc_dump_status); 71 } 72