ff-proc.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * ff-proc.c - a part of driver for RME Fireface series
  4. *
  5. * Copyright (c) 2015-2017 Takashi Sakamoto
  6. */
  7. #include "./ff.h"
  8. const char *snd_ff_proc_get_clk_label(enum snd_ff_clock_src src)
  9. {
  10. static const char *const labels[] = {
  11. "Internal",
  12. "S/PDIF",
  13. "ADAT1",
  14. "ADAT2",
  15. "Word",
  16. "LTC",
  17. };
  18. if (src >= ARRAY_SIZE(labels))
  19. return NULL;
  20. return labels[src];
  21. }
  22. static void proc_dump_status(struct snd_info_entry *entry,
  23. struct snd_info_buffer *buffer)
  24. {
  25. struct snd_ff *ff = entry->private_data;
  26. ff->spec->protocol->dump_status(ff, buffer);
  27. }
  28. static void add_node(struct snd_ff *ff, struct snd_info_entry *root,
  29. const char *name,
  30. void (*op)(struct snd_info_entry *e,
  31. struct snd_info_buffer *b))
  32. {
  33. struct snd_info_entry *entry;
  34. entry = snd_info_create_card_entry(ff->card, name, root);
  35. if (entry)
  36. snd_info_set_text_ops(entry, ff, op);
  37. }
  38. void snd_ff_proc_init(struct snd_ff *ff)
  39. {
  40. struct snd_info_entry *root;
  41. /*
  42. * All nodes are automatically removed at snd_card_disconnect(),
  43. * by following to link list.
  44. */
  45. root = snd_info_create_card_entry(ff->card, "firewire",
  46. ff->card->proc_root);
  47. if (root == NULL)
  48. return;
  49. root->mode = S_IFDIR | 0555;
  50. add_node(ff, root, "status", proc_dump_status);
  51. }