0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "./fireworks.h"
0010
0011 static inline const char*
0012 get_phys_name(struct snd_efw_phys_grp *grp, bool input)
0013 {
0014 static const char *const ch_type[] = {
0015 "Analog", "S/PDIF", "ADAT", "S/PDIF or ADAT", "Mirroring",
0016 "Headphones", "I2S", "Guitar", "Pirzo Guitar", "Guitar String",
0017 };
0018
0019 if (grp->type < ARRAY_SIZE(ch_type))
0020 return ch_type[grp->type];
0021 else if (input)
0022 return "Input";
0023 else
0024 return "Output";
0025 }
0026
0027 static void
0028 proc_read_hwinfo(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
0029 {
0030 struct snd_efw *efw = entry->private_data;
0031 unsigned short i;
0032 struct snd_efw_hwinfo *hwinfo;
0033
0034 hwinfo = kmalloc(sizeof(struct snd_efw_hwinfo), GFP_KERNEL);
0035 if (hwinfo == NULL)
0036 return;
0037
0038 if (snd_efw_command_get_hwinfo(efw, hwinfo) < 0)
0039 goto end;
0040
0041 snd_iprintf(buffer, "guid_hi: 0x%X\n", hwinfo->guid_hi);
0042 snd_iprintf(buffer, "guid_lo: 0x%X\n", hwinfo->guid_lo);
0043 snd_iprintf(buffer, "type: 0x%X\n", hwinfo->type);
0044 snd_iprintf(buffer, "version: 0x%X\n", hwinfo->version);
0045 snd_iprintf(buffer, "vendor_name: %s\n", hwinfo->vendor_name);
0046 snd_iprintf(buffer, "model_name: %s\n", hwinfo->model_name);
0047
0048 snd_iprintf(buffer, "dsp_version: 0x%X\n", hwinfo->dsp_version);
0049 snd_iprintf(buffer, "arm_version: 0x%X\n", hwinfo->arm_version);
0050 snd_iprintf(buffer, "fpga_version: 0x%X\n", hwinfo->fpga_version);
0051
0052 snd_iprintf(buffer, "flags: 0x%X\n", hwinfo->flags);
0053
0054 snd_iprintf(buffer, "max_sample_rate: 0x%X\n", hwinfo->max_sample_rate);
0055 snd_iprintf(buffer, "min_sample_rate: 0x%X\n", hwinfo->min_sample_rate);
0056 snd_iprintf(buffer, "supported_clock: 0x%X\n",
0057 hwinfo->supported_clocks);
0058
0059 snd_iprintf(buffer, "phys out: 0x%X\n", hwinfo->phys_out);
0060 snd_iprintf(buffer, "phys in: 0x%X\n", hwinfo->phys_in);
0061
0062 snd_iprintf(buffer, "phys in grps: 0x%X\n",
0063 hwinfo->phys_in_grp_count);
0064 for (i = 0; i < hwinfo->phys_in_grp_count; i++) {
0065 snd_iprintf(buffer,
0066 "phys in grp[%d]: type 0x%X, count 0x%X\n",
0067 i, hwinfo->phys_out_grps[i].type,
0068 hwinfo->phys_out_grps[i].count);
0069 }
0070
0071 snd_iprintf(buffer, "phys out grps: 0x%X\n",
0072 hwinfo->phys_out_grp_count);
0073 for (i = 0; i < hwinfo->phys_out_grp_count; i++) {
0074 snd_iprintf(buffer,
0075 "phys out grps[%d]: type 0x%X, count 0x%X\n",
0076 i, hwinfo->phys_out_grps[i].type,
0077 hwinfo->phys_out_grps[i].count);
0078 }
0079
0080 snd_iprintf(buffer, "amdtp rx pcm channels 1x: 0x%X\n",
0081 hwinfo->amdtp_rx_pcm_channels);
0082 snd_iprintf(buffer, "amdtp tx pcm channels 1x: 0x%X\n",
0083 hwinfo->amdtp_tx_pcm_channels);
0084 snd_iprintf(buffer, "amdtp rx pcm channels 2x: 0x%X\n",
0085 hwinfo->amdtp_rx_pcm_channels_2x);
0086 snd_iprintf(buffer, "amdtp tx pcm channels 2x: 0x%X\n",
0087 hwinfo->amdtp_tx_pcm_channels_2x);
0088 snd_iprintf(buffer, "amdtp rx pcm channels 4x: 0x%X\n",
0089 hwinfo->amdtp_rx_pcm_channels_4x);
0090 snd_iprintf(buffer, "amdtp tx pcm channels 4x: 0x%X\n",
0091 hwinfo->amdtp_tx_pcm_channels_4x);
0092
0093 snd_iprintf(buffer, "midi out ports: 0x%X\n", hwinfo->midi_out_ports);
0094 snd_iprintf(buffer, "midi in ports: 0x%X\n", hwinfo->midi_in_ports);
0095
0096 snd_iprintf(buffer, "mixer playback channels: 0x%X\n",
0097 hwinfo->mixer_playback_channels);
0098 snd_iprintf(buffer, "mixer capture channels: 0x%X\n",
0099 hwinfo->mixer_capture_channels);
0100 end:
0101 kfree(hwinfo);
0102 }
0103
0104 static void
0105 proc_read_clock(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
0106 {
0107 struct snd_efw *efw = entry->private_data;
0108 enum snd_efw_clock_source clock_source;
0109 unsigned int sampling_rate;
0110
0111 if (snd_efw_command_get_clock_source(efw, &clock_source) < 0)
0112 return;
0113
0114 if (snd_efw_command_get_sampling_rate(efw, &sampling_rate) < 0)
0115 return;
0116
0117 snd_iprintf(buffer, "Clock Source: %d\n", clock_source);
0118 snd_iprintf(buffer, "Sampling Rate: %d\n", sampling_rate);
0119 }
0120
0121
0122
0123
0124
0125
0126 static void
0127 proc_read_phys_meters(struct snd_info_entry *entry,
0128 struct snd_info_buffer *buffer)
0129 {
0130 struct snd_efw *efw = entry->private_data;
0131 struct snd_efw_phys_meters *meters;
0132 unsigned int g, c, m, max, size;
0133 const char *name;
0134 u32 *linear;
0135 int err;
0136
0137 size = sizeof(struct snd_efw_phys_meters) +
0138 (efw->phys_in + efw->phys_out) * sizeof(u32);
0139 meters = kzalloc(size, GFP_KERNEL);
0140 if (meters == NULL)
0141 return;
0142
0143 err = snd_efw_command_get_phys_meters(efw, meters, size);
0144 if (err < 0)
0145 goto end;
0146
0147 snd_iprintf(buffer, "Physical Meters:\n");
0148
0149 m = 0;
0150 max = min(efw->phys_out, meters->out_meters);
0151 linear = meters->values;
0152 snd_iprintf(buffer, " %d Outputs:\n", max);
0153 for (g = 0; g < efw->phys_out_grp_count; g++) {
0154 name = get_phys_name(&efw->phys_out_grps[g], false);
0155 for (c = 0; c < efw->phys_out_grps[g].count; c++) {
0156 if (m < max)
0157 snd_iprintf(buffer, "\t%s [%d]: %d\n",
0158 name, c, linear[m++]);
0159 }
0160 }
0161
0162 m = 0;
0163 max = min(efw->phys_in, meters->in_meters);
0164 linear = meters->values + meters->out_meters;
0165 snd_iprintf(buffer, " %d Inputs:\n", max);
0166 for (g = 0; g < efw->phys_in_grp_count; g++) {
0167 name = get_phys_name(&efw->phys_in_grps[g], true);
0168 for (c = 0; c < efw->phys_in_grps[g].count; c++)
0169 if (m < max)
0170 snd_iprintf(buffer, "\t%s [%d]: %d\n",
0171 name, c, linear[m++]);
0172 }
0173 end:
0174 kfree(meters);
0175 }
0176
0177 static void
0178 proc_read_queues_state(struct snd_info_entry *entry,
0179 struct snd_info_buffer *buffer)
0180 {
0181 struct snd_efw *efw = entry->private_data;
0182 unsigned int consumed;
0183
0184 if (efw->pull_ptr > efw->push_ptr)
0185 consumed = snd_efw_resp_buf_size -
0186 (unsigned int)(efw->pull_ptr - efw->push_ptr);
0187 else
0188 consumed = (unsigned int)(efw->push_ptr - efw->pull_ptr);
0189
0190 snd_iprintf(buffer, "%d/%d\n",
0191 consumed, snd_efw_resp_buf_size);
0192 }
0193
0194 static void
0195 add_node(struct snd_efw *efw, struct snd_info_entry *root, const char *name,
0196 void (*op)(struct snd_info_entry *e, struct snd_info_buffer *b))
0197 {
0198 struct snd_info_entry *entry;
0199
0200 entry = snd_info_create_card_entry(efw->card, name, root);
0201 if (entry)
0202 snd_info_set_text_ops(entry, efw, op);
0203 }
0204
0205 void snd_efw_proc_init(struct snd_efw *efw)
0206 {
0207 struct snd_info_entry *root;
0208
0209
0210
0211
0212
0213 root = snd_info_create_card_entry(efw->card, "firewire",
0214 efw->card->proc_root);
0215 if (root == NULL)
0216 return;
0217 root->mode = S_IFDIR | 0555;
0218
0219 add_node(efw, root, "clock", proc_read_clock);
0220 add_node(efw, root, "firmware", proc_read_hwinfo);
0221 add_node(efw, root, "meters", proc_read_phys_meters);
0222 add_node(efw, root, "queues", proc_read_queues_state);
0223 }