oxfw-proc.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * oxfw_proc.c - a part of driver for OXFW970/971 based devices
  3. *
  4. * Copyright (c) 2014 Takashi Sakamoto
  5. *
  6. * Licensed under the terms of the GNU General Public License, version 2.
  7. */
  8. #include "./oxfw.h"
  9. static void proc_read_formation(struct snd_info_entry *entry,
  10. struct snd_info_buffer *buffer)
  11. {
  12. struct snd_oxfw *oxfw = entry->private_data;
  13. struct snd_oxfw_stream_formation formation, curr;
  14. u8 *format;
  15. char flag;
  16. int i, err;
  17. /* Show input. */
  18. err = snd_oxfw_stream_get_current_formation(oxfw,
  19. AVC_GENERAL_PLUG_DIR_IN,
  20. &curr);
  21. if (err < 0)
  22. return;
  23. snd_iprintf(buffer, "Input Stream to device:\n");
  24. snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
  25. for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
  26. format = oxfw->rx_stream_formats[i];
  27. if (format == NULL)
  28. continue;
  29. err = snd_oxfw_stream_parse_format(format, &formation);
  30. if (err < 0)
  31. continue;
  32. if (memcmp(&formation, &curr, sizeof(curr)) == 0)
  33. flag = '*';
  34. else
  35. flag = ' ';
  36. snd_iprintf(buffer, "%c\t%d\t%d\t%d\n", flag,
  37. formation.rate, formation.pcm, formation.midi);
  38. }
  39. if (!oxfw->has_output)
  40. return;
  41. /* Show output. */
  42. err = snd_oxfw_stream_get_current_formation(oxfw,
  43. AVC_GENERAL_PLUG_DIR_OUT,
  44. &curr);
  45. if (err < 0)
  46. return;
  47. snd_iprintf(buffer, "Output Stream from device:\n");
  48. snd_iprintf(buffer, "\tRate\tPCM\tMIDI\n");
  49. for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; i++) {
  50. format = oxfw->tx_stream_formats[i];
  51. if (format == NULL)
  52. continue;
  53. err = snd_oxfw_stream_parse_format(format, &formation);
  54. if (err < 0)
  55. continue;
  56. if (memcmp(&formation, &curr, sizeof(curr)) == 0)
  57. flag = '*';
  58. else
  59. flag = ' ';
  60. snd_iprintf(buffer, "%c\t%d\t%d\t%d\n", flag,
  61. formation.rate, formation.pcm, formation.midi);
  62. }
  63. }
  64. static void add_node(struct snd_oxfw *oxfw, struct snd_info_entry *root,
  65. const char *name,
  66. void (*op)(struct snd_info_entry *e,
  67. struct snd_info_buffer *b))
  68. {
  69. struct snd_info_entry *entry;
  70. entry = snd_info_create_card_entry(oxfw->card, name, root);
  71. if (entry == NULL)
  72. return;
  73. snd_info_set_text_ops(entry, oxfw, op);
  74. if (snd_info_register(entry) < 0)
  75. snd_info_free_entry(entry);
  76. }
  77. void snd_oxfw_proc_init(struct snd_oxfw *oxfw)
  78. {
  79. struct snd_info_entry *root;
  80. /*
  81. * All nodes are automatically removed at snd_card_disconnect(),
  82. * by following to link list.
  83. */
  84. root = snd_info_create_card_entry(oxfw->card, "firewire",
  85. oxfw->card->proc_root);
  86. if (root == NULL)
  87. return;
  88. root->mode = S_IFDIR | S_IRUGO | S_IXUGO;
  89. if (snd_info_register(root) < 0) {
  90. snd_info_free_entry(root);
  91. return;
  92. }
  93. add_node(oxfw, root, "formation", proc_read_formation);
  94. }