^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * dice_proc.c - a part of driver for Dice based devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) Clemens Ladisch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (c) 2014 Takashi Sakamoto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "dice.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) static int dice_proc_read_mem(struct snd_dice *dice, void *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) unsigned int offset_q, unsigned int quadlets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) DICE_PRIVATE_SPACE + 4 * offset_q,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) buffer, 4 * quadlets, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) for (i = 0; i < quadlets; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) be32_to_cpus(&((u32 *)buffer)[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static const char *str_from_array(const char *const strs[], unsigned int count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if (i < count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return strs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return "(unknown)";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static void dice_proc_fixup_string(char *s, unsigned int size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) for (i = 0; i < size; i += 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) cpu_to_le32s((u32 *)(s + i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) for (i = 0; i < size - 2; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if (s[i] == '\0')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) if (s[i] == '\\' && s[i + 1] == '\\') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) s[i + 2] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) s[size - 1] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static void dice_proc_read(struct snd_info_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct snd_info_buffer *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static const char *const section_names[5] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) "global", "tx", "rx", "ext_sync", "unused2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static const char *const clock_sources[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) "aes1", "aes2", "aes3", "aes4", "aes", "adat", "tdif",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) "wc", "arx1", "arx2", "arx3", "arx4", "internal"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static const char *const rates[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) "32000", "44100", "48000", "88200", "96000", "176400", "192000",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) "any low", "any mid", "any high", "none"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct snd_dice *dice = entry->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u32 sections[ARRAY_SIZE(section_names) * 2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u32 number;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u32 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) } tx_rx_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) u32 owner_hi, owner_lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) u32 notification;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) char nick_name[NICK_NAME_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u32 clock_select;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u32 enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) u32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u32 extended_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) u32 sample_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) u32 clock_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) char clock_source_names[CLOCK_SOURCE_NAMES_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) } global;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) u32 iso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) u32 number_audio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) u32 number_midi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) u32 speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) char names[TX_NAMES_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) u32 ac3_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u32 ac3_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) } tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) u32 iso;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) u32 seq_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u32 number_audio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) u32 number_midi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) char names[RX_NAMES_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u32 ac3_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) u32 ac3_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) } rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) u32 clock_source;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) u32 locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u32 rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) u32 adat_user_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) } ext_sync;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) } buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) unsigned int quadlets, stream, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (dice_proc_read_mem(dice, sections, 0, ARRAY_SIZE(sections)) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) snd_iprintf(buffer, "sections:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) for (i = 0; i < ARRAY_SIZE(section_names); ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) snd_iprintf(buffer, " %s: offset %u, size %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) section_names[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) sections[i * 2], sections[i * 2 + 1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) quadlets = min_t(u32, sections[1], sizeof(buf.global) / 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (dice_proc_read_mem(dice, &buf.global, sections[0], quadlets) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) snd_iprintf(buffer, "global:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) snd_iprintf(buffer, " owner: %04x:%04x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) buf.global.owner_hi >> 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) buf.global.owner_hi & 0xffff, buf.global.owner_lo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) snd_iprintf(buffer, " notification: %08x\n", buf.global.notification);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) dice_proc_fixup_string(buf.global.nick_name, NICK_NAME_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) snd_iprintf(buffer, " nick name: %s\n", buf.global.nick_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) snd_iprintf(buffer, " clock select: %s %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) str_from_array(clock_sources, ARRAY_SIZE(clock_sources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) buf.global.clock_select & CLOCK_SOURCE_MASK),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) str_from_array(rates, ARRAY_SIZE(rates),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) (buf.global.clock_select & CLOCK_RATE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) >> CLOCK_RATE_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) snd_iprintf(buffer, " enable: %u\n", buf.global.enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) snd_iprintf(buffer, " status: %slocked %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) buf.global.status & STATUS_SOURCE_LOCKED ? "" : "un",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) str_from_array(rates, ARRAY_SIZE(rates),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) (buf.global.status &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) STATUS_NOMINAL_RATE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) >> CLOCK_RATE_SHIFT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) snd_iprintf(buffer, " ext status: %08x\n", buf.global.extended_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) snd_iprintf(buffer, " sample rate: %u\n", buf.global.sample_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (quadlets >= 90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) snd_iprintf(buffer, " version: %u.%u.%u.%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) (buf.global.version >> 24) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) (buf.global.version >> 16) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) (buf.global.version >> 8) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) (buf.global.version >> 0) & 0xff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) snd_iprintf(buffer, " clock caps:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) for (i = 0; i <= 6; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (buf.global.clock_caps & (1 << i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) snd_iprintf(buffer, " %s", rates[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) for (i = 0; i <= 12; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (buf.global.clock_caps & (1 << (16 + i)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) snd_iprintf(buffer, " %s", clock_sources[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) snd_iprintf(buffer, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) dice_proc_fixup_string(buf.global.clock_source_names,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) CLOCK_SOURCE_NAMES_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) snd_iprintf(buffer, " clock source names: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) buf.global.clock_source_names);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (dice_proc_read_mem(dice, &tx_rx_header, sections[2], 2) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.tx) / 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) for (stream = 0; stream < tx_rx_header.number; ++stream) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (dice_proc_read_mem(dice, &buf.tx, sections[2] + 2 +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) stream * tx_rx_header.size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) quadlets) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) snd_iprintf(buffer, "tx %u:\n", stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) snd_iprintf(buffer, " iso channel: %d\n", (int)buf.tx.iso);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) snd_iprintf(buffer, " audio channels: %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) buf.tx.number_audio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) snd_iprintf(buffer, " midi ports: %u\n", buf.tx.number_midi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) snd_iprintf(buffer, " speed: S%u\n", 100u << buf.tx.speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (quadlets >= 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) dice_proc_fixup_string(buf.tx.names, TX_NAMES_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) snd_iprintf(buffer, " names: %s\n", buf.tx.names);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (quadlets >= 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) snd_iprintf(buffer, " ac3 caps: %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) buf.tx.ac3_caps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) snd_iprintf(buffer, " ac3 enable: %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) buf.tx.ac3_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (dice_proc_read_mem(dice, &tx_rx_header, sections[4], 2) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) quadlets = min_t(u32, tx_rx_header.size, sizeof(buf.rx) / 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) for (stream = 0; stream < tx_rx_header.number; ++stream) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (dice_proc_read_mem(dice, &buf.rx, sections[4] + 2 +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) stream * tx_rx_header.size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) quadlets) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) snd_iprintf(buffer, "rx %u:\n", stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) snd_iprintf(buffer, " iso channel: %d\n", (int)buf.rx.iso);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) snd_iprintf(buffer, " sequence start: %u\n", buf.rx.seq_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) snd_iprintf(buffer, " audio channels: %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) buf.rx.number_audio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) snd_iprintf(buffer, " midi ports: %u\n", buf.rx.number_midi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (quadlets >= 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) dice_proc_fixup_string(buf.rx.names, RX_NAMES_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) snd_iprintf(buffer, " names: %s\n", buf.rx.names);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (quadlets >= 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) snd_iprintf(buffer, " ac3 caps: %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) buf.rx.ac3_caps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) snd_iprintf(buffer, " ac3 enable: %08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) buf.rx.ac3_enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) quadlets = min_t(u32, sections[7], sizeof(buf.ext_sync) / 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (quadlets >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (dice_proc_read_mem(dice, &buf.ext_sync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) sections[6], 4) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) snd_iprintf(buffer, "ext status:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) snd_iprintf(buffer, " clock source: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) str_from_array(clock_sources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) ARRAY_SIZE(clock_sources),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) buf.ext_sync.clock_source));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) snd_iprintf(buffer, " locked: %u\n", buf.ext_sync.locked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) snd_iprintf(buffer, " rate: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) str_from_array(rates, ARRAY_SIZE(rates),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) buf.ext_sync.rate));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) snd_iprintf(buffer, " adat user data: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (buf.ext_sync.adat_user_data & ADAT_USER_DATA_NO_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) snd_iprintf(buffer, "-\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) snd_iprintf(buffer, "%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) buf.ext_sync.adat_user_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static void dice_proc_read_formation(struct snd_info_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct snd_info_buffer *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static const char *const rate_labels[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) [SND_DICE_RATE_MODE_LOW] = "low",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) [SND_DICE_RATE_MODE_MIDDLE] = "middle",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) [SND_DICE_RATE_MODE_HIGH] = "high",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct snd_dice *dice = entry->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) snd_iprintf(buffer, "Output stream from unit:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) snd_iprintf(buffer, "\t%s", rate_labels[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) snd_iprintf(buffer, "\tMIDI\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) for (i = 0; i < MAX_STREAMS; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) snd_iprintf(buffer, "Tx %u:", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) for (j = 0; j < SND_DICE_RATE_MODE_COUNT; ++j)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) snd_iprintf(buffer, "\t%u", dice->tx_pcm_chs[i][j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) snd_iprintf(buffer, "\t%u\n", dice->tx_midi_ports[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) snd_iprintf(buffer, "Input stream to unit:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) snd_iprintf(buffer, "\t%s", rate_labels[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) snd_iprintf(buffer, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) for (i = 0; i < MAX_STREAMS; ++i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) snd_iprintf(buffer, "Rx %u:", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) for (j = 0; j < SND_DICE_RATE_MODE_COUNT; ++j)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) snd_iprintf(buffer, "\t%u", dice->rx_pcm_chs[i][j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) snd_iprintf(buffer, "\t%u\n", dice->rx_midi_ports[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static void add_node(struct snd_dice *dice, struct snd_info_entry *root,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) void (*op)(struct snd_info_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct snd_info_buffer *buffer))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) struct snd_info_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) entry = snd_info_create_card_entry(dice->card, name, root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) if (entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) snd_info_set_text_ops(entry, dice, op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) void snd_dice_create_proc(struct snd_dice *dice)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct snd_info_entry *root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * All nodes are automatically removed at snd_card_disconnect(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * by following to link list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) root = snd_info_create_card_entry(dice->card, "firewire",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) dice->card->proc_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (!root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) root->mode = S_IFDIR | 0555;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) add_node(dice, root, "dice", dice_proc_read);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) add_node(dice, root, "formation", dice_proc_read_formation);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }