dice-presonus.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0
  2. // dice-presonus.c - a part of driver for DICE based devices
  3. //
  4. // Copyright (c) 2019 Takashi Sakamoto
  5. #include "dice.h"
  6. struct dice_presonus_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. bool has_midi;
  10. };
  11. static const struct dice_presonus_spec dice_presonus_firesutio = {
  12. .tx_pcm_chs = {{16, 16, 0}, {10, 2, 0} },
  13. .rx_pcm_chs = {{16, 16, 0}, {10, 2, 0} },
  14. .has_midi = true,
  15. };
  16. int snd_dice_detect_presonus_formats(struct snd_dice *dice)
  17. {
  18. static const struct {
  19. u32 model_id;
  20. const struct dice_presonus_spec *spec;
  21. } *entry, entries[] = {
  22. {0x000008, &dice_presonus_firesutio},
  23. };
  24. struct fw_csr_iterator it;
  25. int key, val, model_id;
  26. int i;
  27. model_id = 0;
  28. fw_csr_iterator_init(&it, dice->unit->directory);
  29. while (fw_csr_iterator_next(&it, &key, &val)) {
  30. if (key == CSR_MODEL) {
  31. model_id = val;
  32. break;
  33. }
  34. }
  35. for (i = 0; i < ARRAY_SIZE(entries); ++i) {
  36. entry = entries + i;
  37. if (entry->model_id == model_id)
  38. break;
  39. }
  40. if (i == ARRAY_SIZE(entries))
  41. return -ENODEV;
  42. memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,
  43. MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
  44. memcpy(dice->rx_pcm_chs, entry->spec->rx_pcm_chs,
  45. MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
  46. if (entry->spec->has_midi) {
  47. dice->tx_midi_ports[0] = 1;
  48. dice->rx_midi_ports[0] = 1;
  49. }
  50. return 0;
  51. }