Path: blob/master/sound/firewire/digi00x/digi00x-proc.c
26439 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* digi00x-proc.c - a part of driver for Digidesign Digi 002/003 family3*4* Copyright (c) 2014-2015 Takashi Sakamoto5*/67#include "digi00x.h"89static int get_optical_iface_mode(struct snd_dg00x *dg00x,10enum snd_dg00x_optical_mode *mode)11{12__be32 data;13int err;1415err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST,16DG00X_ADDR_BASE + DG00X_OFFSET_OPT_IFACE_MODE,17&data, sizeof(data), 0);18if (err >= 0)19*mode = be32_to_cpu(data) & 0x01;2021return err;22}2324static void proc_read_clock(struct snd_info_entry *entry,25struct snd_info_buffer *buf)26{27static const char *const source_name[] = {28[SND_DG00X_CLOCK_INTERNAL] = "internal",29[SND_DG00X_CLOCK_SPDIF] = "s/pdif",30[SND_DG00X_CLOCK_ADAT] = "adat",31[SND_DG00X_CLOCK_WORD] = "word clock",32};33static const char *const optical_name[] = {34[SND_DG00X_OPT_IFACE_MODE_ADAT] = "adat",35[SND_DG00X_OPT_IFACE_MODE_SPDIF] = "s/pdif",36};37struct snd_dg00x *dg00x = entry->private_data;38enum snd_dg00x_optical_mode mode;39unsigned int rate;40enum snd_dg00x_clock clock;41bool detect;4243if (get_optical_iface_mode(dg00x, &mode) < 0)44return;45if (snd_dg00x_stream_get_local_rate(dg00x, &rate) < 0)46return;47if (snd_dg00x_stream_get_clock(dg00x, &clock) < 0)48return;4950snd_iprintf(buf, "Optical mode: %s\n", optical_name[mode]);51snd_iprintf(buf, "Sampling Rate: %d\n", rate);52snd_iprintf(buf, "Clock Source: %s\n", source_name[clock]);5354if (clock == SND_DG00X_CLOCK_INTERNAL)55return;5657if (snd_dg00x_stream_check_external_clock(dg00x, &detect) < 0)58return;59snd_iprintf(buf, "External source: %s\n", detect ? "detected" : "not");60if (!detect)61return;6263if (snd_dg00x_stream_get_external_rate(dg00x, &rate) >= 0)64snd_iprintf(buf, "External sampling rate: %d\n", rate);65}6667void snd_dg00x_proc_init(struct snd_dg00x *dg00x)68{69struct snd_info_entry *root, *entry;7071/*72* All nodes are automatically removed at snd_card_disconnect(),73* by following to link list.74*/75root = snd_info_create_card_entry(dg00x->card, "firewire",76dg00x->card->proc_root);77if (root == NULL)78return;7980root->mode = S_IFDIR | 0555;8182entry = snd_info_create_card_entry(dg00x->card, "clock", root);83if (entry)84snd_info_set_text_ops(entry, dg00x, proc_read_clock);85}868788