]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ALSA: firewire-digi00x: add proc node to show clock status
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 30 Sep 2015 00:39:19 +0000 (09:39 +0900)
committerTakashi Iwai <tiwai@suse.de>
Wed, 30 Sep 2015 13:35:31 +0000 (15:35 +0200)
This commit adds proc node to show current clock status for debugging.

As long as testing Digi 002 rack, registers can show local clock rate,
local clock source. When external clock input such as S/PDIF is
connected, the registers show the detection and external clock rate.

Additionally, the registers show the mode of optical digital input
interface. Although, a tester with Digi 003 rack reports this makes no
sense. Further investigation is required for Digi 003 series.

Besides, in Digi 002 rack, the S/PDIF format must be IEC 60958-4,
so-called professional.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/digi00x/Makefile
sound/firewire/digi00x/digi00x-proc.c [new file with mode: 0644]
sound/firewire/digi00x/digi00x.c
sound/firewire/digi00x/digi00x.h

index 32d8ebe7ce6b75a33cd5a728354fb4ed84c24dbf..3e0f028d6b6bb7704a428e384901d607cc7c3eba 100644 (file)
@@ -1,2 +1,3 @@
-snd-firewire-digi00x-objs := amdtp-dot.o digi00x-stream.o digi00x.o
+snd-firewire-digi00x-objs := amdtp-dot.o digi00x-stream.o digi00x-proc.o \
+                            digi00x.o
 obj-$(CONFIG_SND_FIREWIRE_DIGI00X) += snd-firewire-digi00x.o
diff --git a/sound/firewire/digi00x/digi00x-proc.c b/sound/firewire/digi00x/digi00x-proc.c
new file mode 100644 (file)
index 0000000..a1d601f
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * digi00x-proc.c - a part of driver for Digidesign Digi 002/003 family
+ *
+ * Copyright (c) 2014-2015 Takashi Sakamoto
+ *
+ * Licensed under the terms of the GNU General Public License, version 2.
+ */
+
+#include "digi00x.h"
+
+static int get_optical_iface_mode(struct snd_dg00x *dg00x,
+                                 enum snd_dg00x_optical_mode *mode)
+{
+       __be32 data;
+       int err;
+
+       err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST,
+                                DG00X_ADDR_BASE + DG00X_OFFSET_OPT_IFACE_MODE,
+                                &data, sizeof(data), 0);
+       if (err >= 0)
+               *mode = be32_to_cpu(data) & 0x01;
+
+       return err;
+}
+
+static void proc_read_clock(struct snd_info_entry *entry,
+                           struct snd_info_buffer *buf)
+{
+       static const char *const source_name[] = {
+               [SND_DG00X_CLOCK_INTERNAL] = "internal",
+               [SND_DG00X_CLOCK_SPDIF] = "s/pdif",
+               [SND_DG00X_CLOCK_ADAT] = "adat",
+               [SND_DG00X_CLOCK_WORD] = "word clock",
+       };
+       static const char *const optical_name[] = {
+               [SND_DG00X_OPT_IFACE_MODE_ADAT] = "adat",
+               [SND_DG00X_OPT_IFACE_MODE_SPDIF] = "s/pdif",
+       };
+       struct snd_dg00x *dg00x = entry->private_data;
+       enum snd_dg00x_optical_mode mode;
+       unsigned int rate;
+       enum snd_dg00x_clock clock;
+       bool detect;
+
+       if (get_optical_iface_mode(dg00x, &mode) < 0)
+               return;
+       if (snd_dg00x_stream_get_local_rate(dg00x, &rate) < 0)
+               return;
+       if (snd_dg00x_stream_get_clock(dg00x, &clock) < 0)
+               return;
+
+       snd_iprintf(buf, "Optical mode: %s\n", optical_name[mode]);
+       snd_iprintf(buf, "Sampling Rate: %d\n", rate);
+       snd_iprintf(buf, "Clock Source: %s\n", source_name[clock]);
+
+       if (clock == SND_DG00X_CLOCK_INTERNAL)
+               return;
+
+       if (snd_dg00x_stream_check_external_clock(dg00x, &detect) < 0)
+               return;
+       snd_iprintf(buf, "External source: %s\n", detect ? "detected" : "not");
+       if (!detect)
+               return;
+
+       if (snd_dg00x_stream_get_external_rate(dg00x, &rate) >= 0)
+               snd_iprintf(buf, "External sampling rate: %d\n", rate);
+}
+
+void snd_dg00x_proc_init(struct snd_dg00x *dg00x)
+{
+       struct snd_info_entry *root, *entry;
+
+       /*
+        * All nodes are automatically removed at snd_card_disconnect(),
+        * by following to link list.
+        */
+       root = snd_info_create_card_entry(dg00x->card, "firewire",
+                                         dg00x->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;
+       }
+
+       entry = snd_info_create_card_entry(dg00x->card, "clock", root);
+       if (entry == NULL) {
+               snd_info_free_entry(root);
+               return;
+       }
+
+       snd_info_set_text_ops(entry, dg00x, proc_read_clock);
+       if (snd_info_register(entry) < 0) {
+               snd_info_free_entry(entry);
+               snd_info_free_entry(root);
+       }
+}
index 5bda4c4c87f087dd1ef8000852ebe4c83efb8718..a5f66fd1fb189d61b88a6e56002dfd5d3d9611a0 100644 (file)
@@ -81,6 +81,8 @@ static int snd_dg00x_probe(struct fw_unit *unit,
        if (err < 0)
                goto error;
 
+       snd_dg00x_proc_init(dg00x);
+
        err = snd_card_register(card);
        if (err < 0)
                goto error;
index 685d5f01ee0dc54faf87527ffd7b4ebbf237431e..9ee259f8daa710bc37ba5ffc0c1080c94ff396e2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <sound/core.h>
 #include <sound/initval.h>
+#include <sound/info.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 
@@ -84,6 +85,12 @@ enum snd_dg00x_clock {
        SND_DG00X_CLOCK_COUNT,
 };
 
+enum snd_dg00x_optical_mode {
+       SND_DG00X_OPT_IFACE_MODE_ADAT = 0,
+       SND_DG00X_OPT_IFACE_MODE_SPDIF,
+       SND_DG00X_OPT_IFACE_MODE_COUNT,
+};
+
 int amdtp_dot_init(struct amdtp_stream *s, struct fw_unit *unit,
                   enum amdtp_stream_direction dir);
 int amdtp_dot_set_parameters(struct amdtp_stream *s, unsigned int rate,
@@ -111,4 +118,5 @@ void snd_dg00x_stream_stop_duplex(struct snd_dg00x *dg00x);
 void snd_dg00x_stream_update_duplex(struct snd_dg00x *dg00x);
 void snd_dg00x_stream_destroy_duplex(struct snd_dg00x *dg00x);
 
+void snd_dg00x_proc_init(struct snd_dg00x *dg00x);
 #endif