2 * bebob_proc.c - a part of driver for BeBoB based devices
4 * Copyright (c) 2013-2014 Takashi Sakamoto
6 * Licensed under the terms of the GNU General Public License, version 2.
11 /* contents of information register */
27 /* may not used in product
36 proc_read_hw_info(struct snd_info_entry *entry,
37 struct snd_info_buffer *buffer)
39 struct snd_bebob *bebob = entry->private_data;
42 info = kzalloc(sizeof(struct hw_info), GFP_KERNEL);
46 if (snd_bebob_read_block(bebob->unit, 0,
47 info, sizeof(struct hw_info)) < 0)
50 snd_iprintf(buffer, "Manufacturer:\t%.8s\n",
51 (char *)&info->manufacturer);
52 snd_iprintf(buffer, "Protocol Ver:\t%d\n", info->protocol_ver);
53 snd_iprintf(buffer, "Build Ver:\t%d\n", info->bld_ver);
54 snd_iprintf(buffer, "GUID:\t\t0x%.8X%.8X\n",
55 info->guid[0], info->guid[1]);
56 snd_iprintf(buffer, "Model ID:\t0x%02X\n", info->model_id);
57 snd_iprintf(buffer, "Model Rev:\t%d\n", info->model_rev);
58 snd_iprintf(buffer, "Firmware Date:\t%.8s\n", (char *)&info->fw_date);
59 snd_iprintf(buffer, "Firmware Time:\t%.8s\n", (char *)&info->fw_time);
60 snd_iprintf(buffer, "Firmware ID:\t0x%X\n", info->fw_id);
61 snd_iprintf(buffer, "Firmware Ver:\t%d\n", info->fw_ver);
62 snd_iprintf(buffer, "Base Addr:\t0x%X\n", info->base_addr);
63 snd_iprintf(buffer, "Max Size:\t%d\n", info->max_size);
64 snd_iprintf(buffer, "Loader Date:\t%.8s\n", (char *)&info->bld_date);
65 snd_iprintf(buffer, "Loader Time:\t%.8s\n", (char *)&info->bld_time);
72 proc_read_formation(struct snd_info_entry *entry,
73 struct snd_info_buffer *buffer)
75 struct snd_bebob *bebob = entry->private_data;
76 struct snd_bebob_stream_formation *formation;
79 snd_iprintf(buffer, "Output Stream from device:\n");
80 snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
81 formation = bebob->tx_stream_formations;
82 for (i = 0; i < SND_BEBOB_STRM_FMT_ENTRIES; i++) {
84 "\t%d\t%d\t%d\n", snd_bebob_rate_table[i],
85 formation[i].pcm, formation[i].midi);
88 snd_iprintf(buffer, "Input Stream to device:\n");
89 snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
90 formation = bebob->rx_stream_formations;
91 for (i = 0; i < SND_BEBOB_STRM_FMT_ENTRIES; i++) {
93 "\t%d\t%d\t%d\n", snd_bebob_rate_table[i],
94 formation[i].pcm, formation[i].midi);
99 proc_read_clock(struct snd_info_entry *entry,
100 struct snd_info_buffer *buffer)
102 struct snd_bebob *bebob = entry->private_data;
106 if (snd_bebob_stream_get_rate(bebob, &rate) >= 0)
107 snd_iprintf(buffer, "Sampling rate: %d\n", rate);
109 if (snd_bebob_stream_check_internal_clock(bebob, &internal) >= 0)
110 snd_iprintf(buffer, "Clock Source: %s (MSU-dest: %d)",
111 (internal) ? "Internal" : "External",
112 bebob->sync_input_plug);
116 add_node(struct snd_bebob *bebob, struct snd_info_entry *root, const char *name,
117 void (*op)(struct snd_info_entry *e, struct snd_info_buffer *b))
119 struct snd_info_entry *entry;
121 entry = snd_info_create_card_entry(bebob->card, name, root);
125 snd_info_set_text_ops(entry, bebob, op);
126 if (snd_info_register(entry) < 0)
127 snd_info_free_entry(entry);
130 void snd_bebob_proc_init(struct snd_bebob *bebob)
132 struct snd_info_entry *root;
135 * All nodes are automatically removed at snd_card_disconnect(),
136 * by following to link list.
138 root = snd_info_create_card_entry(bebob->card, "firewire",
139 bebob->card->proc_root);
142 root->mode = S_IFDIR | S_IRUGO | S_IXUGO;
143 if (snd_info_register(root) < 0) {
144 snd_info_free_entry(root);
148 add_node(bebob, root, "clock", proc_read_clock);
149 add_node(bebob, root, "firmware", proc_read_hw_info);
150 add_node(bebob, root, "formation", proc_read_formation);