1 // SPDX-License-Identifier: GPL-2.0-only 1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 2 /* 3 * digi00x-proc.c - a part of driver for Digid 3 * digi00x-proc.c - a part of driver for Digidesign Digi 002/003 family 4 * 4 * 5 * Copyright (c) 2014-2015 Takashi Sakamoto 5 * Copyright (c) 2014-2015 Takashi Sakamoto 6 */ 6 */ 7 7 8 #include "digi00x.h" 8 #include "digi00x.h" 9 9 10 static int get_optical_iface_mode(struct snd_d 10 static int get_optical_iface_mode(struct snd_dg00x *dg00x, 11 enum snd_dg0 11 enum snd_dg00x_optical_mode *mode) 12 { 12 { 13 __be32 data; 13 __be32 data; 14 int err; 14 int err; 15 15 16 err = snd_fw_transaction(dg00x->unit, 16 err = snd_fw_transaction(dg00x->unit, TCODE_READ_QUADLET_REQUEST, 17 DG00X_ADDR_BA 17 DG00X_ADDR_BASE + DG00X_OFFSET_OPT_IFACE_MODE, 18 &data, sizeof 18 &data, sizeof(data), 0); 19 if (err >= 0) 19 if (err >= 0) 20 *mode = be32_to_cpu(data) & 0x 20 *mode = be32_to_cpu(data) & 0x01; 21 21 22 return err; 22 return err; 23 } 23 } 24 24 25 static void proc_read_clock(struct snd_info_en 25 static void proc_read_clock(struct snd_info_entry *entry, 26 struct snd_info_bu 26 struct snd_info_buffer *buf) 27 { 27 { 28 static const char *const source_name[] 28 static const char *const source_name[] = { 29 [SND_DG00X_CLOCK_INTERNAL] = " 29 [SND_DG00X_CLOCK_INTERNAL] = "internal", 30 [SND_DG00X_CLOCK_SPDIF] = "s/p 30 [SND_DG00X_CLOCK_SPDIF] = "s/pdif", 31 [SND_DG00X_CLOCK_ADAT] = "adat 31 [SND_DG00X_CLOCK_ADAT] = "adat", 32 [SND_DG00X_CLOCK_WORD] = "word 32 [SND_DG00X_CLOCK_WORD] = "word clock", 33 }; 33 }; 34 static const char *const optical_name[ 34 static const char *const optical_name[] = { 35 [SND_DG00X_OPT_IFACE_MODE_ADAT 35 [SND_DG00X_OPT_IFACE_MODE_ADAT] = "adat", 36 [SND_DG00X_OPT_IFACE_MODE_SPDI 36 [SND_DG00X_OPT_IFACE_MODE_SPDIF] = "s/pdif", 37 }; 37 }; 38 struct snd_dg00x *dg00x = entry->priva 38 struct snd_dg00x *dg00x = entry->private_data; 39 enum snd_dg00x_optical_mode mode; 39 enum snd_dg00x_optical_mode mode; 40 unsigned int rate; 40 unsigned int rate; 41 enum snd_dg00x_clock clock; 41 enum snd_dg00x_clock clock; 42 bool detect; 42 bool detect; 43 43 44 if (get_optical_iface_mode(dg00x, &mod 44 if (get_optical_iface_mode(dg00x, &mode) < 0) 45 return; 45 return; 46 if (snd_dg00x_stream_get_local_rate(dg 46 if (snd_dg00x_stream_get_local_rate(dg00x, &rate) < 0) 47 return; 47 return; 48 if (snd_dg00x_stream_get_clock(dg00x, 48 if (snd_dg00x_stream_get_clock(dg00x, &clock) < 0) 49 return; 49 return; 50 50 51 snd_iprintf(buf, "Optical mode: %s\n", 51 snd_iprintf(buf, "Optical mode: %s\n", optical_name[mode]); 52 snd_iprintf(buf, "Sampling Rate: %d\n" 52 snd_iprintf(buf, "Sampling Rate: %d\n", rate); 53 snd_iprintf(buf, "Clock Source: %s\n", 53 snd_iprintf(buf, "Clock Source: %s\n", source_name[clock]); 54 54 55 if (clock == SND_DG00X_CLOCK_INTERNAL) 55 if (clock == SND_DG00X_CLOCK_INTERNAL) 56 return; 56 return; 57 57 58 if (snd_dg00x_stream_check_external_cl 58 if (snd_dg00x_stream_check_external_clock(dg00x, &detect) < 0) 59 return; 59 return; 60 snd_iprintf(buf, "External source: %s\ 60 snd_iprintf(buf, "External source: %s\n", detect ? "detected" : "not"); 61 if (!detect) 61 if (!detect) 62 return; 62 return; 63 63 64 if (snd_dg00x_stream_get_external_rate 64 if (snd_dg00x_stream_get_external_rate(dg00x, &rate) >= 0) 65 snd_iprintf(buf, "External sam 65 snd_iprintf(buf, "External sampling rate: %d\n", rate); 66 } 66 } 67 67 68 void snd_dg00x_proc_init(struct snd_dg00x *dg0 68 void snd_dg00x_proc_init(struct snd_dg00x *dg00x) 69 { 69 { 70 struct snd_info_entry *root, *entry; 70 struct snd_info_entry *root, *entry; 71 71 72 /* 72 /* 73 * All nodes are automatically removed 73 * All nodes are automatically removed at snd_card_disconnect(), 74 * by following to link list. 74 * by following to link list. 75 */ 75 */ 76 root = snd_info_create_card_entry(dg00 76 root = snd_info_create_card_entry(dg00x->card, "firewire", 77 dg00 77 dg00x->card->proc_root); 78 if (root == NULL) 78 if (root == NULL) 79 return; 79 return; 80 80 81 root->mode = S_IFDIR | 0555; 81 root->mode = S_IFDIR | 0555; 82 82 83 entry = snd_info_create_card_entry(dg0 83 entry = snd_info_create_card_entry(dg00x->card, "clock", root); 84 if (entry) 84 if (entry) 85 snd_info_set_text_ops(entry, d 85 snd_info_set_text_ops(entry, dg00x, proc_read_clock); 86 } 86 } 87 87
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.