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)
45 		snd_info_set_text_ops(entry, ff, op);
46 }
47 
48 void snd_ff_proc_init(struct snd_ff *ff)
49 {
50 	struct snd_info_entry *root;
51 
52 	/*
53 	 * All nodes are automatically removed at snd_card_disconnect(),
54 	 * by following to link list.
55 	 */
56 	root = snd_info_create_card_entry(ff->card, "firewire",
57 					  ff->card->proc_root);
58 	if (root == NULL)
59 		return;
60 	root->mode = S_IFDIR | 0555;
61 
62 	add_node(ff, root, "status", proc_dump_status);
63 }
64