oxfw-proc.c 2.4 KB

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