Path: blob/master/sound/firewire/fireworks/fireworks_proc.c
26442 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* fireworks_proc.c - a part of driver for Fireworks based devices3*4* Copyright (c) 2009-2010 Clemens Ladisch5* Copyright (c) 2013-2014 Takashi Sakamoto6*/78#include "./fireworks.h"910static inline const char*11get_phys_name(struct snd_efw_phys_grp *grp, bool input)12{13static const char *const ch_type[] = {14"Analog", "S/PDIF", "ADAT", "S/PDIF or ADAT", "Mirroring",15"Headphones", "I2S", "Guitar", "Pirzo Guitar", "Guitar String",16};1718if (grp->type < ARRAY_SIZE(ch_type))19return ch_type[grp->type];20else if (input)21return "Input";22else23return "Output";24}2526static void27proc_read_hwinfo(struct snd_info_entry *entry, struct snd_info_buffer *buffer)28{29struct snd_efw *efw = entry->private_data;30unsigned short i;31struct snd_efw_hwinfo *hwinfo;3233hwinfo = kmalloc(sizeof(struct snd_efw_hwinfo), GFP_KERNEL);34if (hwinfo == NULL)35return;3637if (snd_efw_command_get_hwinfo(efw, hwinfo) < 0)38goto end;3940snd_iprintf(buffer, "guid_hi: 0x%X\n", hwinfo->guid_hi);41snd_iprintf(buffer, "guid_lo: 0x%X\n", hwinfo->guid_lo);42snd_iprintf(buffer, "type: 0x%X\n", hwinfo->type);43snd_iprintf(buffer, "version: 0x%X\n", hwinfo->version);44snd_iprintf(buffer, "vendor_name: %s\n", hwinfo->vendor_name);45snd_iprintf(buffer, "model_name: %s\n", hwinfo->model_name);4647snd_iprintf(buffer, "dsp_version: 0x%X\n", hwinfo->dsp_version);48snd_iprintf(buffer, "arm_version: 0x%X\n", hwinfo->arm_version);49snd_iprintf(buffer, "fpga_version: 0x%X\n", hwinfo->fpga_version);5051snd_iprintf(buffer, "flags: 0x%X\n", hwinfo->flags);5253snd_iprintf(buffer, "max_sample_rate: 0x%X\n", hwinfo->max_sample_rate);54snd_iprintf(buffer, "min_sample_rate: 0x%X\n", hwinfo->min_sample_rate);55snd_iprintf(buffer, "supported_clock: 0x%X\n",56hwinfo->supported_clocks);5758snd_iprintf(buffer, "phys out: 0x%X\n", hwinfo->phys_out);59snd_iprintf(buffer, "phys in: 0x%X\n", hwinfo->phys_in);6061snd_iprintf(buffer, "phys in grps: 0x%X\n",62hwinfo->phys_in_grp_count);63for (i = 0; i < hwinfo->phys_in_grp_count; i++) {64snd_iprintf(buffer,65"phys in grp[%d]: type 0x%X, count 0x%X\n",66i, hwinfo->phys_out_grps[i].type,67hwinfo->phys_out_grps[i].count);68}6970snd_iprintf(buffer, "phys out grps: 0x%X\n",71hwinfo->phys_out_grp_count);72for (i = 0; i < hwinfo->phys_out_grp_count; i++) {73snd_iprintf(buffer,74"phys out grps[%d]: type 0x%X, count 0x%X\n",75i, hwinfo->phys_out_grps[i].type,76hwinfo->phys_out_grps[i].count);77}7879snd_iprintf(buffer, "amdtp rx pcm channels 1x: 0x%X\n",80hwinfo->amdtp_rx_pcm_channels);81snd_iprintf(buffer, "amdtp tx pcm channels 1x: 0x%X\n",82hwinfo->amdtp_tx_pcm_channels);83snd_iprintf(buffer, "amdtp rx pcm channels 2x: 0x%X\n",84hwinfo->amdtp_rx_pcm_channels_2x);85snd_iprintf(buffer, "amdtp tx pcm channels 2x: 0x%X\n",86hwinfo->amdtp_tx_pcm_channels_2x);87snd_iprintf(buffer, "amdtp rx pcm channels 4x: 0x%X\n",88hwinfo->amdtp_rx_pcm_channels_4x);89snd_iprintf(buffer, "amdtp tx pcm channels 4x: 0x%X\n",90hwinfo->amdtp_tx_pcm_channels_4x);9192snd_iprintf(buffer, "midi out ports: 0x%X\n", hwinfo->midi_out_ports);93snd_iprintf(buffer, "midi in ports: 0x%X\n", hwinfo->midi_in_ports);9495snd_iprintf(buffer, "mixer playback channels: 0x%X\n",96hwinfo->mixer_playback_channels);97snd_iprintf(buffer, "mixer capture channels: 0x%X\n",98hwinfo->mixer_capture_channels);99end:100kfree(hwinfo);101}102103static void104proc_read_clock(struct snd_info_entry *entry, struct snd_info_buffer *buffer)105{106struct snd_efw *efw = entry->private_data;107enum snd_efw_clock_source clock_source;108unsigned int sampling_rate;109110if (snd_efw_command_get_clock_source(efw, &clock_source) < 0)111return;112113if (snd_efw_command_get_sampling_rate(efw, &sampling_rate) < 0)114return;115116snd_iprintf(buffer, "Clock Source: %d\n", clock_source);117snd_iprintf(buffer, "Sampling Rate: %d\n", sampling_rate);118}119120/*121* NOTE:122* dB = 20 * log10(linear / 0x01000000)123* -144.0 dB when linear is 0124*/125static void126proc_read_phys_meters(struct snd_info_entry *entry,127struct snd_info_buffer *buffer)128{129struct snd_efw *efw = entry->private_data;130struct snd_efw_phys_meters *meters;131unsigned int g, c, m, max, size;132const char *name;133u32 *linear;134int err;135136size = sizeof(struct snd_efw_phys_meters) +137(efw->phys_in + efw->phys_out) * sizeof(u32);138meters = kzalloc(size, GFP_KERNEL);139if (meters == NULL)140return;141142err = snd_efw_command_get_phys_meters(efw, meters, size);143if (err < 0)144goto end;145146snd_iprintf(buffer, "Physical Meters:\n");147148m = 0;149max = min(efw->phys_out, meters->out_meters);150linear = meters->values;151snd_iprintf(buffer, " %d Outputs:\n", max);152for (g = 0; g < efw->phys_out_grp_count; g++) {153name = get_phys_name(&efw->phys_out_grps[g], false);154for (c = 0; c < efw->phys_out_grps[g].count; c++) {155if (m < max)156snd_iprintf(buffer, "\t%s [%d]: %d\n",157name, c, linear[m++]);158}159}160161m = 0;162max = min(efw->phys_in, meters->in_meters);163linear = meters->values + meters->out_meters;164snd_iprintf(buffer, " %d Inputs:\n", max);165for (g = 0; g < efw->phys_in_grp_count; g++) {166name = get_phys_name(&efw->phys_in_grps[g], true);167for (c = 0; c < efw->phys_in_grps[g].count; c++)168if (m < max)169snd_iprintf(buffer, "\t%s [%d]: %d\n",170name, c, linear[m++]);171}172end:173kfree(meters);174}175176static void177proc_read_queues_state(struct snd_info_entry *entry,178struct snd_info_buffer *buffer)179{180struct snd_efw *efw = entry->private_data;181unsigned int consumed;182183if (efw->pull_ptr > efw->push_ptr)184consumed = snd_efw_resp_buf_size -185(unsigned int)(efw->pull_ptr - efw->push_ptr);186else187consumed = (unsigned int)(efw->push_ptr - efw->pull_ptr);188189snd_iprintf(buffer, "%d/%d\n",190consumed, snd_efw_resp_buf_size);191}192193static void194add_node(struct snd_efw *efw, struct snd_info_entry *root, const char *name,195void (*op)(struct snd_info_entry *e, struct snd_info_buffer *b))196{197struct snd_info_entry *entry;198199entry = snd_info_create_card_entry(efw->card, name, root);200if (entry)201snd_info_set_text_ops(entry, efw, op);202}203204void snd_efw_proc_init(struct snd_efw *efw)205{206struct snd_info_entry *root;207208/*209* All nodes are automatically removed at snd_card_disconnect(),210* by following to link list.211*/212root = snd_info_create_card_entry(efw->card, "firewire",213efw->card->proc_root);214if (root == NULL)215return;216root->mode = S_IFDIR | 0555;217218add_node(efw, root, "clock", proc_read_clock);219add_node(efw, root, "firmware", proc_read_hwinfo);220add_node(efw, root, "meters", proc_read_phys_meters);221add_node(efw, root, "queues", proc_read_queues_state);222}223224225