tascam-proc.c 2.3 KB

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