aboutsummaryrefslogtreecommitdiffstats
path: root/sound/firewire/bebob
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-04-25 09:45:17 -0400
committerTakashi Iwai <tiwai@suse.de>2014-05-26 08:30:00 -0400
commitad9697bad78fab4665d93e61c702892e289e1764 (patch)
tree21f8395a9ab6f75643267ebd188c0ad4a5ba9b8b /sound/firewire/bebob
parentb6bc812327aa6961d783e81961273ebf2a304964 (diff)
ALSA: bebob: Add proc interface for debugging purpose
This commit adds proc interface to get these information for debugging: - firmware information - stream formation - current clock source and sampling rate Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob')
-rw-r--r--sound/firewire/bebob/Makefile2
-rw-r--r--sound/firewire/bebob/bebob.c2
-rw-r--r--sound/firewire/bebob/bebob.h3
-rw-r--r--sound/firewire/bebob/bebob_proc.c151
4 files changed, 157 insertions, 1 deletions
diff --git a/sound/firewire/bebob/Makefile b/sound/firewire/bebob/Makefile
index 5cece62e30c0..757c40ef94df 100644
--- a/sound/firewire/bebob/Makefile
+++ b/sound/firewire/bebob/Makefile
@@ -1,2 +1,2 @@
1snd-bebob-objs := bebob_command.o bebob_stream.o bebob.o 1snd-bebob-objs := bebob_command.o bebob_stream.o bebob_proc.o bebob.o
2obj-m += snd-bebob.o 2obj-m += snd-bebob.o
diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
index 180284db84c9..0c3f1f6ab670 100644
--- a/sound/firewire/bebob/bebob.c
+++ b/sound/firewire/bebob/bebob.c
@@ -162,6 +162,8 @@ bebob_probe(struct fw_unit *unit,
162 if (err < 0) 162 if (err < 0)
163 goto error; 163 goto error;
164 164
165 snd_bebob_proc_init(bebob);
166
165 err = snd_bebob_stream_init_duplex(bebob); 167 err = snd_bebob_stream_init_duplex(bebob);
166 if (err < 0) 168 if (err < 0)
167 goto error; 169 goto error;
diff --git a/sound/firewire/bebob/bebob.h b/sound/firewire/bebob/bebob.h
index 031ca78096d2..1247cca04f63 100644
--- a/sound/firewire/bebob/bebob.h
+++ b/sound/firewire/bebob/bebob.h
@@ -20,6 +20,7 @@
20 20
21#include <sound/core.h> 21#include <sound/core.h>
22#include <sound/initval.h> 22#include <sound/initval.h>
23#include <sound/info.h>
23 24
24#include "../lib.h" 25#include "../lib.h"
25#include "../fcp.h" 26#include "../fcp.h"
@@ -171,6 +172,8 @@ void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob);
171void snd_bebob_stream_update_duplex(struct snd_bebob *bebob); 172void snd_bebob_stream_update_duplex(struct snd_bebob *bebob);
172void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob); 173void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob);
173 174
175void snd_bebob_proc_init(struct snd_bebob *bebob);
176
174#define SND_BEBOB_DEV_ENTRY(vendor, model) \ 177#define SND_BEBOB_DEV_ENTRY(vendor, model) \
175{ \ 178{ \
176 .match_flags = IEEE1394_MATCH_VENDOR_ID | \ 179 .match_flags = IEEE1394_MATCH_VENDOR_ID | \
diff --git a/sound/firewire/bebob/bebob_proc.c b/sound/firewire/bebob/bebob_proc.c
new file mode 100644
index 000000000000..c31ca4f42a58
--- /dev/null
+++ b/sound/firewire/bebob/bebob_proc.c
@@ -0,0 +1,151 @@
1/*
2 * bebob_proc.c - a part of driver for BeBoB based devices
3 *
4 * Copyright (c) 2013-2014 Takashi Sakamoto
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#include "./bebob.h"
10
11/* contents of information register */
12struct hw_info {
13 u64 manufacturer;
14 u32 protocol_ver;
15 u32 bld_ver;
16 u32 guid[2];
17 u32 model_id;
18 u32 model_rev;
19 u64 fw_date;
20 u64 fw_time;
21 u32 fw_id;
22 u32 fw_ver;
23 u32 base_addr;
24 u32 max_size;
25 u64 bld_date;
26 u64 bld_time;
27/* may not used in product
28 u64 dbg_date;
29 u64 dbg_time;
30 u32 dbg_id;
31 u32 dbg_version;
32*/
33} __packed;
34
35static void
36proc_read_hw_info(struct snd_info_entry *entry,
37 struct snd_info_buffer *buffer)
38{
39 struct snd_bebob *bebob = entry->private_data;
40 struct hw_info *info;
41
42 info = kzalloc(sizeof(struct hw_info), GFP_KERNEL);
43 if (info == NULL)
44 return;
45
46 if (snd_bebob_read_block(bebob->unit, 0,
47 info, sizeof(struct hw_info)) < 0)
48 goto end;
49
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);
66
67end:
68 kfree(info);
69}
70
71static void
72proc_read_formation(struct snd_info_entry *entry,
73 struct snd_info_buffer *buffer)
74{
75 struct snd_bebob *bebob = entry->private_data;
76 struct snd_bebob_stream_formation *formation;
77 unsigned int i;
78
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++) {
83 snd_iprintf(buffer,
84 "\t%d\t%d\t%d\n", snd_bebob_rate_table[i],
85 formation[i].pcm, formation[i].midi);
86 }
87
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++) {
92 snd_iprintf(buffer,
93 "\t%d\t%d\t%d\n", snd_bebob_rate_table[i],
94 formation[i].pcm, formation[i].midi);
95 }
96}
97
98static void
99proc_read_clock(struct snd_info_entry *entry,
100 struct snd_info_buffer *buffer)
101{
102 struct snd_bebob *bebob = entry->private_data;
103 unsigned int rate;
104 bool internal;
105
106 if (snd_bebob_stream_get_rate(bebob, &rate) >= 0)
107 snd_iprintf(buffer, "Sampling rate: %d\n", rate);
108
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);
113}
114
115static void
116add_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))
118{
119 struct snd_info_entry *entry;
120
121 entry = snd_info_create_card_entry(bebob->card, name, root);
122 if (entry == NULL)
123 return;
124
125 snd_info_set_text_ops(entry, bebob, op);
126 if (snd_info_register(entry) < 0)
127 snd_info_free_entry(entry);
128}
129
130void snd_bebob_proc_init(struct snd_bebob *bebob)
131{
132 struct snd_info_entry *root;
133
134 /*
135 * All nodes are automatically removed at snd_card_disconnect(),
136 * by following to link list.
137 */
138 root = snd_info_create_card_entry(bebob->card, "firewire",
139 bebob->card->proc_root);
140 if (root == NULL)
141 return;
142 root->mode = S_IFDIR | S_IRUGO | S_IXUGO;
143 if (snd_info_register(root) < 0) {
144 snd_info_free_entry(root);
145 return;
146 }
147
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);
151}