1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | /* |
3 | * tascam-proc.h - a part of driver for TASCAM FireWire series |
4 | * |
5 | * Copyright (c) 2015 Takashi Sakamoto |
6 | */ |
7 | |
8 | #include "./tascam.h" |
9 | |
10 | static void proc_read_firmware(struct snd_info_entry *entry, |
11 | struct snd_info_buffer *buffer) |
12 | { |
13 | struct snd_tscm *tscm = entry->private_data; |
14 | __be32 data; |
15 | unsigned int reg, fpga, arm, hw; |
16 | int err; |
17 | |
18 | err = snd_fw_transaction(unit: tscm->unit, TCODE_READ_QUADLET_REQUEST, |
19 | TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_REGISTER, |
20 | buffer: &data, length: sizeof(data), flags: 0); |
21 | if (err < 0) |
22 | return; |
23 | reg = be32_to_cpu(data); |
24 | |
25 | err = snd_fw_transaction(unit: tscm->unit, TCODE_READ_QUADLET_REQUEST, |
26 | TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_FPGA, |
27 | buffer: &data, length: sizeof(data), flags: 0); |
28 | if (err < 0) |
29 | return; |
30 | fpga = be32_to_cpu(data); |
31 | |
32 | err = snd_fw_transaction(unit: tscm->unit, TCODE_READ_QUADLET_REQUEST, |
33 | TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_ARM, |
34 | buffer: &data, length: sizeof(data), flags: 0); |
35 | if (err < 0) |
36 | return; |
37 | arm = be32_to_cpu(data); |
38 | |
39 | err = snd_fw_transaction(unit: tscm->unit, TCODE_READ_QUADLET_REQUEST, |
40 | TSCM_ADDR_BASE + TSCM_OFFSET_FIRMWARE_HW, |
41 | buffer: &data, length: sizeof(data), flags: 0); |
42 | if (err < 0) |
43 | return; |
44 | hw = be32_to_cpu(data); |
45 | |
46 | snd_iprintf(buffer, "Register: %d (0x%08x)\n" , reg & 0xffff, reg); |
47 | snd_iprintf(buffer, "FPGA: %d (0x%08x)\n" , fpga & 0xffff, fpga); |
48 | snd_iprintf(buffer, "ARM: %d (0x%08x)\n" , arm & 0xffff, arm); |
49 | snd_iprintf(buffer, "Hardware: %d (0x%08x)\n" , hw >> 16, hw); |
50 | } |
51 | |
52 | static void add_node(struct snd_tscm *tscm, struct snd_info_entry *root, |
53 | const char *name, |
54 | void (*op)(struct snd_info_entry *e, |
55 | struct snd_info_buffer *b)) |
56 | { |
57 | struct snd_info_entry *entry; |
58 | |
59 | entry = snd_info_create_card_entry(card: tscm->card, name, parent: root); |
60 | if (entry) |
61 | snd_info_set_text_ops(entry, private_data: tscm, read: op); |
62 | } |
63 | |
64 | void snd_tscm_proc_init(struct snd_tscm *tscm) |
65 | { |
66 | struct snd_info_entry *root; |
67 | |
68 | /* |
69 | * All nodes are automatically removed at snd_card_disconnect(), |
70 | * by following to link list. |
71 | */ |
72 | root = snd_info_create_card_entry(card: tscm->card, name: "firewire" , |
73 | parent: tscm->card->proc_root); |
74 | if (root == NULL) |
75 | return; |
76 | root->mode = S_IFDIR | 0555; |
77 | |
78 | add_node(tscm, root, name: "firmware" , op: proc_read_firmware); |
79 | } |
80 | |