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_meters(struct snd_info_entry
*entry
,
73 struct snd_info_buffer
*buffer
)
75 struct snd_bebob
*bebob
= entry
->private_data
;
76 const struct snd_bebob_meter_spec
*spec
= bebob
->spec
->meter
;
78 unsigned int i
, c
, channels
, size
;
83 channels
= spec
->num
* 2;
84 size
= channels
* sizeof(u32
);
85 buf
= kmalloc(size
, GFP_KERNEL
);
89 if (spec
->get(bebob
, buf
, size
) < 0)
92 for (i
= 0, c
= 1; i
< channels
; i
++) {
93 snd_iprintf(buffer
, "%s %d:\t%d\n",
94 spec
->labels
[i
/ 2], c
++, buf
[i
]);
95 if ((i
+ 1 < channels
- 1) &&
96 (strcmp(spec
->labels
[i
/ 2],
97 spec
->labels
[(i
+ 1) / 2]) != 0))
105 proc_read_formation(struct snd_info_entry
*entry
,
106 struct snd_info_buffer
*buffer
)
108 struct snd_bebob
*bebob
= entry
->private_data
;
109 struct snd_bebob_stream_formation
*formation
;
112 snd_iprintf(buffer
, "Output Stream from device:\n");
113 snd_iprintf(buffer
, "\tRate\tPCM\tMIDI\n");
114 formation
= bebob
->tx_stream_formations
;
115 for (i
= 0; i
< SND_BEBOB_STRM_FMT_ENTRIES
; i
++) {
117 "\t%d\t%d\t%d\n", snd_bebob_rate_table
[i
],
118 formation
[i
].pcm
, formation
[i
].midi
);
121 snd_iprintf(buffer
, "Input Stream to device:\n");
122 snd_iprintf(buffer
, "\tRate\tPCM\tMIDI\n");
123 formation
= bebob
->rx_stream_formations
;
124 for (i
= 0; i
< SND_BEBOB_STRM_FMT_ENTRIES
; i
++) {
126 "\t%d\t%d\t%d\n", snd_bebob_rate_table
[i
],
127 formation
[i
].pcm
, formation
[i
].midi
);
132 proc_read_clock(struct snd_info_entry
*entry
,
133 struct snd_info_buffer
*buffer
)
135 static const char *const clk_labels
[] = {
140 struct snd_bebob
*bebob
= entry
->private_data
;
141 const struct snd_bebob_rate_spec
*rate_spec
= bebob
->spec
->rate
;
142 const struct snd_bebob_clock_spec
*clk_spec
= bebob
->spec
->clock
;
143 enum snd_bebob_clock_type src
;
146 if (rate_spec
->get(bebob
, &rate
) >= 0)
147 snd_iprintf(buffer
, "Sampling rate: %d\n", rate
);
149 if (snd_bebob_stream_get_clock_src(bebob
, &src
) >= 0) {
151 snd_iprintf(buffer
, "Clock Source: %s\n",
154 snd_iprintf(buffer
, "Clock Source: %s (MSU-dest: %d)\n",
155 clk_labels
[src
], bebob
->sync_input_plug
);
160 add_node(struct snd_bebob
*bebob
, struct snd_info_entry
*root
, const char *name
,
161 void (*op
)(struct snd_info_entry
*e
, struct snd_info_buffer
*b
))
163 struct snd_info_entry
*entry
;
165 entry
= snd_info_create_card_entry(bebob
->card
, name
, root
);
169 snd_info_set_text_ops(entry
, bebob
, op
);
170 if (snd_info_register(entry
) < 0)
171 snd_info_free_entry(entry
);
174 void snd_bebob_proc_init(struct snd_bebob
*bebob
)
176 struct snd_info_entry
*root
;
179 * All nodes are automatically removed at snd_card_disconnect(),
180 * by following to link list.
182 root
= snd_info_create_card_entry(bebob
->card
, "firewire",
183 bebob
->card
->proc_root
);
186 root
->mode
= S_IFDIR
| S_IRUGO
| S_IXUGO
;
187 if (snd_info_register(root
) < 0) {
188 snd_info_free_entry(root
);
192 add_node(bebob
, root
, "clock", proc_read_clock
);
193 add_node(bebob
, root
, "firmware", proc_read_hw_info
);
194 add_node(bebob
, root
, "formation", proc_read_formation
);
196 if (bebob
->spec
->meter
!= NULL
)
197 add_node(bebob
, root
, "meter", proc_read_meters
);