dice-tcelectronic.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * dice-tc_electronic.c - a part of driver for DICE based devices
  4. *
  5. * Copyright (c) 2018 Takashi Sakamoto
  6. */
  7. #include "dice.h"
  8. struct dice_tc_spec {
  9. unsigned int tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT];
  10. unsigned int rx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT];
  11. bool has_midi;
  12. };
  13. static const struct dice_tc_spec desktop_konnekt6 = {
  14. .tx_pcm_chs = {{6, 6, 2}, {0, 0, 0} },
  15. .rx_pcm_chs = {{6, 6, 4}, {0, 0, 0} },
  16. .has_midi = false,
  17. };
  18. static const struct dice_tc_spec impact_twin = {
  19. .tx_pcm_chs = {{14, 10, 6}, {0, 0, 0} },
  20. .rx_pcm_chs = {{14, 10, 6}, {0, 0, 0} },
  21. .has_midi = true,
  22. };
  23. static const struct dice_tc_spec konnekt_8 = {
  24. .tx_pcm_chs = {{4, 4, 3}, {0, 0, 0} },
  25. .rx_pcm_chs = {{4, 4, 3}, {0, 0, 0} },
  26. .has_midi = true,
  27. };
  28. static const struct dice_tc_spec konnekt_24d = {
  29. .tx_pcm_chs = {{16, 16, 6}, {0, 0, 0} },
  30. .rx_pcm_chs = {{16, 16, 6}, {0, 0, 0} },
  31. .has_midi = true,
  32. };
  33. static const struct dice_tc_spec konnekt_live = {
  34. .tx_pcm_chs = {{16, 16, 6}, {0, 0, 0} },
  35. .rx_pcm_chs = {{16, 16, 6}, {0, 0, 0} },
  36. .has_midi = true,
  37. };
  38. static const struct dice_tc_spec studio_konnekt_48 = {
  39. .tx_pcm_chs = {{16, 16, 8}, {16, 16, 7} },
  40. .rx_pcm_chs = {{16, 16, 8}, {14, 14, 7} },
  41. .has_midi = true,
  42. };
  43. static const struct dice_tc_spec digital_konnekt_x32 = {
  44. .tx_pcm_chs = {{16, 16, 4}, {0, 0, 0} },
  45. .rx_pcm_chs = {{16, 16, 4}, {0, 0, 0} },
  46. .has_midi = false,
  47. };
  48. int snd_dice_detect_tcelectronic_formats(struct snd_dice *dice)
  49. {
  50. static const struct {
  51. u32 model_id;
  52. const struct dice_tc_spec *spec;
  53. } *entry, entries[] = {
  54. {0x00000020, &konnekt_24d},
  55. {0x00000021, &konnekt_8},
  56. {0x00000022, &studio_konnekt_48},
  57. {0x00000023, &konnekt_live},
  58. {0x00000024, &desktop_konnekt6},
  59. {0x00000027, &impact_twin},
  60. {0x00000030, &digital_konnekt_x32},
  61. };
  62. struct fw_csr_iterator it;
  63. int key, val, model_id;
  64. int i;
  65. model_id = 0;
  66. fw_csr_iterator_init(&it, dice->unit->directory);
  67. while (fw_csr_iterator_next(&it, &key, &val)) {
  68. if (key == CSR_MODEL) {
  69. model_id = val;
  70. break;
  71. }
  72. }
  73. for (i = 0; i < ARRAY_SIZE(entries); ++i) {
  74. entry = entries + i;
  75. if (entry->model_id == model_id)
  76. break;
  77. }
  78. if (i == ARRAY_SIZE(entries))
  79. return -ENODEV;
  80. memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,
  81. MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
  82. memcpy(dice->rx_pcm_chs, entry->spec->rx_pcm_chs,
  83. MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
  84. if (entry->spec->has_midi) {
  85. dice->tx_midi_ports[0] = 1;
  86. dice->rx_midi_ports[0] = 1;
  87. }
  88. return 0;
  89. }