dice-weiss.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // SPDX-License-Identifier: GPL-2.0
  2. // dice-weiss.c - a part of driver for DICE based devices
  3. //
  4. // Copyright (c) 2023 Rolf Anderegg and Michele Perrone
  5. #include "dice.h"
  6. struct dice_weiss_spec {
  7. unsigned int tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT];
  8. unsigned int rx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT];
  9. };
  10. // Weiss DAC202: 192kHz 2-channel DAC
  11. static const struct dice_weiss_spec dac202 = {
  12. .tx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  13. .rx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  14. };
  15. // Weiss MAN301: 192kHz 2-channel music archive network player
  16. static const struct dice_weiss_spec man301 = {
  17. .tx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  18. .rx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  19. };
  20. // Weiss INT202: 192kHz unidirectional 2-channel digital Firewire nterface
  21. static const struct dice_weiss_spec int202 = {
  22. .tx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  23. .rx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  24. };
  25. // Weiss INT203: 192kHz bidirectional 2-channel digital Firewire nterface
  26. static const struct dice_weiss_spec int203 = {
  27. .tx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  28. .rx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  29. };
  30. // Weiss ADC2: 192kHz A/D converter with microphone preamps and line nputs
  31. static const struct dice_weiss_spec adc2 = {
  32. .tx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  33. .rx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  34. };
  35. // Weiss DAC2/Minerva: 192kHz 2-channel DAC
  36. static const struct dice_weiss_spec dac2_minerva = {
  37. .tx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  38. .rx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  39. };
  40. // Weiss Vesta: 192kHz 2-channel Firewire to AES/EBU interface
  41. static const struct dice_weiss_spec vesta = {
  42. .tx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  43. .rx_pcm_chs = {{2, 2, 2}, {0, 0, 0} },
  44. };
  45. // Weiss AFI1: 192kHz 24-channel Firewire to ADAT or AES/EBU interface
  46. static const struct dice_weiss_spec afi1 = {
  47. .tx_pcm_chs = {{24, 16, 8}, {0, 0, 0} },
  48. .rx_pcm_chs = {{24, 16, 8}, {0, 0, 0} },
  49. };
  50. int snd_dice_detect_weiss_formats(struct snd_dice *dice)
  51. {
  52. static const struct {
  53. u32 model_id;
  54. const struct dice_weiss_spec *spec;
  55. } *entry, entries[] = {
  56. {0x000007, &dac202},
  57. {0x000008, &dac202}, // Maya edition: same audio I/O as DAC202.
  58. {0x000006, &int202},
  59. {0x00000a, &int203},
  60. {0x00000b, &man301},
  61. {0x000001, &adc2},
  62. {0x000003, &dac2_minerva},
  63. {0x000002, &vesta},
  64. {0x000004, &afi1},
  65. };
  66. struct fw_csr_iterator it;
  67. int key, val, model_id;
  68. int i;
  69. model_id = 0;
  70. fw_csr_iterator_init(&it, dice->unit->directory);
  71. while (fw_csr_iterator_next(&it, &key, &val)) {
  72. if (key == CSR_MODEL) {
  73. model_id = val;
  74. break;
  75. }
  76. }
  77. for (i = 0; i < ARRAY_SIZE(entries); ++i) {
  78. entry = entries + i;
  79. if (entry->model_id == model_id)
  80. break;
  81. }
  82. if (i == ARRAY_SIZE(entries))
  83. return -ENODEV;
  84. memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,
  85. MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
  86. memcpy(dice->rx_pcm_chs, entry->spec->rx_pcm_chs,
  87. MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
  88. return 0;
  89. }