All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de, perex@perex.cz
Cc: alsa-devel@alsa-project.org,
	linux1394-devel@lists.sourceforge.net, ffado-devel@lists.sf.net
Subject: [PATCH 23/44] fireworks: Add proc interface for debugging purpose
Date: Fri, 21 Mar 2014 20:10:08 +0900	[thread overview]
Message-ID: <1395400229-22957-24-git-send-email-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <1395400229-22957-1-git-send-email-o-takashi@sakamocchi.jp>

This commit adds proc interface to output infomation for debugging.
 - firmware information
 - sampling rate and clock source
 - physical metering (linear value)

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/fireworks/Makefile         |   2 +-
 sound/firewire/fireworks/fireworks.c      |  12 ++
 sound/firewire/fireworks/fireworks.h      |  11 ++
 sound/firewire/fireworks/fireworks_proc.c | 215 ++++++++++++++++++++++++++++++
 4 files changed, 239 insertions(+), 1 deletion(-)
 create mode 100644 sound/firewire/fireworks/fireworks_proc.c

diff --git a/sound/firewire/fireworks/Makefile b/sound/firewire/fireworks/Makefile
index 1bccb65..52bd15e 100644
--- a/sound/firewire/fireworks/Makefile
+++ b/sound/firewire/fireworks/Makefile
@@ -1,3 +1,3 @@
 snd-fireworks-objs := fireworks_transaction.o fireworks_command.o \
-		      fireworks_stream.o fireworks.o
+		      fireworks_stream.o fireworks_proc.o fireworks.o
 obj-m += snd-fireworks.o
diff --git a/sound/firewire/fireworks/fireworks.c b/sound/firewire/fireworks/fireworks.c
index f7bce25..f2dc12e 100644
--- a/sound/firewire/fireworks/fireworks.c
+++ b/sound/firewire/fireworks/fireworks.c
@@ -133,6 +133,16 @@ get_hardware_info(struct snd_efw *efw)
 	efw->pcm_playback_channels[0] = hwinfo->amdtp_rx_pcm_channels;
 	efw->pcm_playback_channels[1] = hwinfo->amdtp_rx_pcm_channels_2x;
 	efw->pcm_playback_channels[2] = hwinfo->amdtp_rx_pcm_channels_4x;
+
+	/* hardware metering */
+	efw->phys_out = hwinfo->phys_out;
+	efw->phys_in = hwinfo->phys_in;
+	efw->phys_out_grp_count = hwinfo->phys_out_grp_count;
+	efw->phys_in_grp_count = hwinfo->phys_in_grp_count;
+	memcpy(&efw->phys_out_grps, hwinfo->phys_out_grps,
+	       sizeof(struct snd_efw_phys_grp) * HWINFO_MAX_CAPS_GROUPS);
+	memcpy(&efw->phys_in_grps, hwinfo->phys_in_grps,
+	       sizeof(struct snd_efw_phys_grp) * HWINFO_MAX_CAPS_GROUPS);
 end:
 	kfree(hwinfo);
 	return err;
@@ -196,6 +206,8 @@ efw_probe(struct fw_unit *unit,
 	if (err < 0)
 		goto error;
 
+	snd_efw_proc_init(efw);
+
 	err = snd_card_register(card);
 	if (err < 0)
 		goto error;
diff --git a/sound/firewire/fireworks/fireworks.h b/sound/firewire/fireworks/fireworks.h
index 49547b9..d32724f 100644
--- a/sound/firewire/fireworks/fireworks.h
+++ b/sound/firewire/fireworks/fireworks.h
@@ -21,6 +21,7 @@
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/pcm.h>
+#include <sound/info.h>
 
 #include "../packets-buffer.h"
 #include "../iso-resources.h"
@@ -69,6 +70,14 @@ struct snd_efw {
 	struct cmp_connection in_conn;
 	unsigned int capture_substreams;
 	unsigned int playback_substreams;
+
+	/* hardware metering parameters */
+	unsigned int phys_out;
+	unsigned int phys_in;
+	unsigned int phys_out_grp_count;
+	unsigned int phys_in_grp_count;
+	struct snd_efw_phys_grp phys_out_grps[HWINFO_MAX_CAPS_GROUPS];
+	struct snd_efw_phys_grp phys_in_grps[HWINFO_MAX_CAPS_GROUPS];
 };
 
 struct snd_efw_transaction {
@@ -182,6 +191,8 @@ int snd_efw_stream_stop_duplex(struct snd_efw *efw);
 void snd_efw_stream_update_duplex(struct snd_efw *efw);
 void snd_efw_stream_destroy_duplex(struct snd_efw *efw);
 
+void snd_efw_proc_init(struct snd_efw *efw);
+
 #define SND_EFW_DEV_ENTRY(vendor, model) \
 { \
 	.match_flags	= IEEE1394_MATCH_VENDOR_ID | \
diff --git a/sound/firewire/fireworks/fireworks_proc.c b/sound/firewire/fireworks/fireworks_proc.c
new file mode 100644
index 0000000..54b2ee0
--- /dev/null
+++ b/sound/firewire/fireworks/fireworks_proc.c
@@ -0,0 +1,215 @@
+/*
+ * fireworks_proc.c - a part of driver for Fireworks based devices
+ *
+ * Copyright (c) 2009-2010 Clemens Ladisch
+ * Copyright (c) 2013 Takashi Sakamoto
+ *
+ * Licensed under the terms of the GNU General Public License, version 2.
+ */
+
+#include "./fireworks.h"
+
+static inline const char*
+get_phys_name(struct snd_efw_phys_grp *grp)
+{
+	const char *ch_type[] = {
+		"Analog", "S/PDIF", "ADAT", "S/PDIF or ADAT",
+		"Mirroring", "Headphones", "I2S", "Guitar",
+		"Pirzo Guitar", "Guitar String", "Virtual", "Dummy"
+	};
+
+	if (grp->type < 10)
+		return ch_type[grp->type];
+	else if (grp->type == 0x10000)
+		return ch_type[10];
+	else
+		return ch_type[11];
+}
+
+static void
+proc_read_hwinfo(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
+{
+	struct snd_efw *efw = entry->private_data;
+	unsigned short i;
+	struct snd_efw_hwinfo *hwinfo;
+
+	hwinfo = kmalloc(sizeof(struct snd_efw_hwinfo), GFP_KERNEL);
+	if (hwinfo == NULL)
+		return;
+
+	if (snd_efw_command_get_hwinfo(efw, hwinfo) < 0)
+		goto end;
+
+	snd_iprintf(buffer, "guid_hi: 0x%X\n", hwinfo->guid_hi);
+	snd_iprintf(buffer, "guid_lo: 0x%X\n", hwinfo->guid_lo);
+	snd_iprintf(buffer, "type: 0x%X\n", hwinfo->type);
+	snd_iprintf(buffer, "version: 0x%X\n", hwinfo->version);
+	snd_iprintf(buffer, "vendor_name: %s\n", hwinfo->vendor_name);
+	snd_iprintf(buffer, "model_name: %s\n", hwinfo->model_name);
+
+	snd_iprintf(buffer, "dsp_version: 0x%X\n", hwinfo->dsp_version);
+	snd_iprintf(buffer, "arm_version: 0x%X\n", hwinfo->arm_version);
+	snd_iprintf(buffer, "fpga_version: 0x%X\n", hwinfo->fpga_version);
+
+	snd_iprintf(buffer, "flags: 0x%X\n", hwinfo->flags);
+
+	snd_iprintf(buffer, "max_sample_rate: 0x%X\n", hwinfo->max_sample_rate);
+	snd_iprintf(buffer, "min_sample_rate: 0x%X\n", hwinfo->min_sample_rate);
+	snd_iprintf(buffer, "supported_clock: 0x%X\n",
+		    hwinfo->supported_clocks);
+
+	snd_iprintf(buffer, "phys out: 0x%X\n", hwinfo->phys_out);
+	snd_iprintf(buffer, "phys in: 0x%X\n", hwinfo->phys_in);
+
+	snd_iprintf(buffer, "phys in grps: 0x%X\n",
+		    hwinfo->phys_in_grp_count);
+	for (i = 0; i < hwinfo->phys_in_grp_count; i++) {
+		snd_iprintf(buffer,
+			    "phys in grp[0x%d]: type 0x%d, count 0x%d\n",
+			    i, hwinfo->phys_out_grps[i].type,
+			    hwinfo->phys_out_grps[i].count);
+	}
+
+	snd_iprintf(buffer, "phys out grps: 0x%X\n",
+		    hwinfo->phys_out_grp_count);
+	for (i = 0; i < hwinfo->phys_out_grp_count; i++) {
+		snd_iprintf(buffer,
+			    "phys out grps[0x%d]: type 0x%d, count 0x%d\n",
+			    i, hwinfo->phys_out_grps[i].type,
+			    hwinfo->phys_out_grps[i].count);
+	}
+
+	snd_iprintf(buffer, "amdtp rx pcm channels 1x: 0x%X\n",
+		    hwinfo->amdtp_rx_pcm_channels);
+	snd_iprintf(buffer, "amdtp tx pcm channels 1x: 0x%X\n",
+		    hwinfo->amdtp_tx_pcm_channels);
+	snd_iprintf(buffer, "amdtp rx pcm channels 2x: 0x%X\n",
+		    hwinfo->amdtp_rx_pcm_channels_2x);
+	snd_iprintf(buffer, "amdtp tx pcm channels 2x: 0x%X\n",
+		    hwinfo->amdtp_tx_pcm_channels_2x);
+	snd_iprintf(buffer, "amdtp rx pcm channels 4x: 0x%X\n",
+		    hwinfo->amdtp_rx_pcm_channels_4x);
+	snd_iprintf(buffer, "amdtp tx pcm channels 4x: 0x%X\n",
+		    hwinfo->amdtp_tx_pcm_channels_4x);
+
+	snd_iprintf(buffer, "midi out ports: 0x%X\n", hwinfo->midi_out_ports);
+	snd_iprintf(buffer, "midi in ports: 0x%X\n", hwinfo->midi_in_ports);
+
+	snd_iprintf(buffer, "mixer playback channels: 0x%X\n",
+		    hwinfo->mixer_playback_channels);
+	snd_iprintf(buffer, "mixer capture channels: 0x%X\n",
+		    hwinfo->mixer_capture_channels);
+end:
+	kfree(hwinfo);
+}
+
+static void
+proc_read_clock(struct snd_info_entry *entry, struct snd_info_buffer *buffer)
+{
+	struct snd_efw *efw = entry->private_data;
+	enum snd_efw_clock_source clock_source;
+	unsigned int sampling_rate;
+
+	if (snd_efw_command_get_clock_source(efw, &clock_source) < 0)
+		return;
+
+	if (snd_efw_command_get_sampling_rate(efw, &sampling_rate) < 0)
+		return;
+
+	snd_iprintf(buffer, "Clock Source: %d\n", clock_source);
+	snd_iprintf(buffer, "Sampling Rate: %d\n", sampling_rate);
+}
+
+/*
+ * NOTE:
+ *  dB = 20 * log10(linear / 0x01000000)
+ *  -144.0 dB when linear is 0
+ */
+static void
+proc_read_phys_meters(struct snd_info_entry *entry,
+		      struct snd_info_buffer *buffer)
+{
+	struct snd_efw *efw = entry->private_data;
+	struct snd_efw_phys_meters *meters;
+	unsigned int g, c, m, max, size;
+	const char *name;
+	u32 *linear;
+	int err;
+
+	size = sizeof(struct snd_efw_phys_meters) +
+	       (efw->phys_in + efw->phys_out) * sizeof(u32);
+	meters = kzalloc(size, GFP_KERNEL);
+	if (meters == NULL)
+		return;
+
+	err = snd_efw_command_get_phys_meters(efw, meters, size);
+	if (err < 0)
+		goto end;
+
+	snd_iprintf(buffer, "Physical Meters:\n");
+
+	m = 0;
+	max = min(efw->phys_out, meters->out_meters);
+	linear = meters->values;
+	snd_iprintf(buffer, " %d Outputs:\n", max);
+	for (g = 0; g < efw->phys_out_grp_count; g++) {
+		name = get_phys_name(&efw->phys_out_grps[g]);
+		for (c = 0; c < efw->phys_out_grps[g].count; c++) {
+			if (m < max)
+				snd_iprintf(buffer, "\t%s [%d]: %d\n",
+					    name, c, linear[m++]);
+		}
+	}
+
+	m = 0;
+	max = min(efw->phys_in, meters->in_meters);
+	linear = meters->values + meters->out_meters;
+	snd_iprintf(buffer, " %d Inputs:\n", max);
+	for (g = 0; g < efw->phys_in_grp_count; g++) {
+		name = get_phys_name(&efw->phys_in_grps[g]);
+		for (c = 0; c < efw->phys_in_grps[g].count; c++)
+			if (m < max)
+				snd_iprintf(buffer, "\t%s [%d]: %d\n",
+					    name, c, linear[m++]);
+	}
+end:
+	kfree(meters);
+}
+
+static void
+add_node(struct snd_efw *efw, struct snd_info_entry *root, const char *name,
+	 void (*op)(struct snd_info_entry *e, struct snd_info_buffer *b))
+{
+	struct snd_info_entry *entry;
+
+	entry = snd_info_create_card_entry(efw->card, name, root);
+	if (entry == NULL)
+		return;
+
+	snd_info_set_text_ops(entry, efw, op);
+	if (snd_info_register(entry) < 0)
+		snd_info_free_entry(entry);
+}
+
+void snd_efw_proc_init(struct snd_efw *efw)
+{
+	struct snd_info_entry *root;
+
+	/*
+	 * All nodes are automatically removed at snd_card_disconnect(),
+	 * by following to link list.
+	 */
+	root = snd_info_create_card_entry(efw->card, "firewire",
+					  efw->card->proc_root);
+	if (root == NULL)
+		return;
+	root->mode = S_IFDIR | S_IRUGO | S_IXUGO;
+	if (snd_info_register(root) < 0) {
+		snd_info_free_entry(root);
+		return;
+	}
+
+	add_node(efw, root, "clock", proc_read_clock);
+	add_node(efw, root, "firmware", proc_read_hwinfo);
+	add_node(efw, root, "meters", proc_read_phys_meters);
+}
-- 
1.8.3.2


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech

  parent reply	other threads:[~2014-03-21 11:10 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-21 11:09 [PATCH 00/44 v3] Enhancement of support for Firewire devices Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 01/44] firewire-lib: Add macros instead of fixed value for AMDTP Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 02/44] firewire-lib: Add 'direction' member to 'amdtp_stream' structure Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 03/44] firewire-lib: Split some codes into functions to reuse for both streams Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 04/44] firewire-lib: Add support for AMDTP in-stream and PCM capture Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 05/44] firewire-lib: Add support for MIDI capture/playback Takashi Sakamoto
2014-04-02 19:29   ` Clemens Ladisch
2014-04-02 19:42     ` [FFADO-devel] " Adrian Knoth
2014-04-02 19:58       ` Clemens Ladisch
2014-04-02 20:37         ` [FFADO-devel] [alsa-devel] " Jano Svitok
2014-04-03  8:33     ` Takashi Sakamoto
2014-04-03  8:54       ` Clemens Ladisch
2014-04-03 10:08         ` Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 06/44] firewire-lib: Give syt value as parameter to handle_out_packet() Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 07/44] firewire-lib: Add support for duplex streams synchronization in blocking mode Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 08/44] firewire-lib: Add support for channel mapping Takashi Sakamoto
2014-04-02 20:18   ` Clemens Ladisch
2014-04-03  8:37     ` Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 09/44] firewire-lib: Restrict calling flush_context_completion() when context exists Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 10/44] firewire-lib: Rename macros, variables and functions for CMP Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 11/44] firewire-lib: Add 'direction' member to 'cmp_connection' structure Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 12/44] firewire-lib: Add handling output connection by CMP Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 13/44] firewire-lib: Add a new function to check others' connection Takashi Sakamoto
2014-03-21 11:09 ` [PATCH 14/44] firewire-lib: Add support for deferred transaction Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 15/44] firewire-lib: Add some AV/C general commands Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 16/44] fireworks: Add skelton for Fireworks based devices Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 17/44] fireworks: Add transaction and some commands Takashi Sakamoto
2014-04-03 20:15   ` Clemens Ladisch
2014-04-04  4:08     ` Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 18/44] fireworks: Add connection and stream management Takashi Sakamoto
2014-04-03 20:56   ` Clemens Ladisch
2014-04-04 14:22     ` Takashi Sakamoto
2014-04-04 15:05       ` [alsa-devel] " Clemens Ladisch
2014-04-06 13:20         ` Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 19/44] fireworks/firewire-lib: Add a quirk for empty packet with TAG0 Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 20/44] fireworks/firewire-lib: Add a quirk for the meaning of dbc Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 21/44] fireworks/firewire-lib: Add a quirk for wrong dbs in tx packets Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 22/44] fireworks/firewire-libs: Add a quirk for fixed interval of reported dbc Takashi Sakamoto
2014-03-21 11:10 ` Takashi Sakamoto [this message]
2014-04-03 21:16   ` [alsa-devel] [PATCH 23/44] fireworks: Add proc interface for debugging purpose Clemens Ladisch
2014-04-04 11:16     ` Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 24/44] fireworks: Add MIDI interface Takashi Sakamoto
2014-04-03 21:20   ` [alsa-devel] " Clemens Ladisch
2014-04-06 12:03     ` Takashi Sakamoto
2014-04-06 14:52       ` Clemens Ladisch
2014-04-07 12:59         ` Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 25/44] fireworks/firewire-lib: Add a quirk for data blocks for MIDI in out-stream Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 26/44] fireworks: Add PCM interface Takashi Sakamoto
2014-04-04  8:48   ` Clemens Ladisch
2014-04-06 12:44     ` Takashi Sakamoto
2014-04-06 14:52       ` [alsa-devel] " Clemens Ladisch
2014-04-07  7:20         ` Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 27/44] fireworks: Add hwdep interface Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 28/44] fireworks: Add command/response functionality into " Takashi Sakamoto
2014-04-04  9:31   ` Clemens Ladisch
2014-04-04 11:11     ` Takashi Sakamoto
2014-04-04 12:15       ` [alsa-devel] " Clemens Ladisch
2014-04-08  2:45         ` Takashi Sakamoto
2014-04-04 15:13   ` Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 29/44] bebob: Add skelton for BeBoB based devices Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 30/44] bebob: Add commands and connections/streams management Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 31/44] bebob/firewire-lib: Add a quirk for discontinuity at bus reset Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 32/44] bebob: Add proc interface for debugging purpose Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 33/44] bebob: Add MIDI interface Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 34/44] bebob: Add PCM interface Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 35/44] bebob: Add hwdep interface Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 36/44] bebob: Prepare for device specific operations Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 37/44] bebob: Add support for Terratec PHASE, EWS series and Aureon Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 38/44] bebob: Add support for Yamaha GO series Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 39/44] bebob: Add support for Focusrite Saffire/SaffirePro series Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 40/44] bebob: Add support for M-Audio usual Firewire series Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 41/44] bebob: Add support for M-Audio special " Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 42/44] bebob/firewire-lib: Add a quirk of wrong dbc in empty packet " Takashi Sakamoto
2014-03-23  2:16   ` Takashi Sakamoto
2014-03-24  1:41     ` [FFADO-devel] " Euan de Kock
2014-03-24  2:52       ` Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 43/44] bebob: Send a cue to load firmware for M-Audio " Takashi Sakamoto
2014-03-21 11:10 ` [PATCH 44/44] firewire/bebob: Add a workaround for M-Audio special " Takashi Sakamoto
2014-04-02 11:15 ` [PATCH 00/44 v3] Enhancement of support for Firewire devices Takashi Sakamoto
2014-04-03 19:17 ` David Henningsson
2014-04-04  7:04   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395400229-22957-24-git-send-email-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sf.net \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.