bebob_terratec.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * bebob_terratec.c - a part of driver for BeBoB based devices
  3. *
  4. * Copyright (c) 2013-2014 Takashi Sakamoto
  5. *
  6. * Licensed under the terms of the GNU General Public License, version 2.
  7. */
  8. #include "./bebob.h"
  9. static enum snd_bebob_clock_type phase88_rack_clk_src_types[] = {
  10. SND_BEBOB_CLOCK_TYPE_INTERNAL,
  11. SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */
  12. SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */
  13. };
  14. static int
  15. phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
  16. {
  17. unsigned int enable_ext, enable_word;
  18. int err;
  19. err = avc_audio_get_selector(bebob->unit, 0, 9, &enable_ext);
  20. if (err < 0)
  21. goto end;
  22. err = avc_audio_get_selector(bebob->unit, 0, 8, &enable_word);
  23. if (err < 0)
  24. goto end;
  25. if (enable_ext == 0)
  26. *id = 0;
  27. else if (enable_word == 0)
  28. *id = 1;
  29. else
  30. *id = 2;
  31. end:
  32. return err;
  33. }
  34. static enum snd_bebob_clock_type phase24_series_clk_src_types[] = {
  35. SND_BEBOB_CLOCK_TYPE_INTERNAL,
  36. SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */
  37. };
  38. static int
  39. phase24_series_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
  40. {
  41. int err;
  42. err = avc_audio_get_selector(bebob->unit, 0, 4, id);
  43. if (err < 0)
  44. return err;
  45. if (*id >= ARRAY_SIZE(phase24_series_clk_src_types))
  46. return -EIO;
  47. return 0;
  48. }
  49. static const struct snd_bebob_rate_spec phase_series_rate_spec = {
  50. .get = &snd_bebob_stream_get_rate,
  51. .set = &snd_bebob_stream_set_rate,
  52. };
  53. /* PHASE 88 Rack FW */
  54. static const struct snd_bebob_clock_spec phase88_rack_clk = {
  55. .num = ARRAY_SIZE(phase88_rack_clk_src_types),
  56. .types = phase88_rack_clk_src_types,
  57. .get = &phase88_rack_clk_src_get,
  58. };
  59. const struct snd_bebob_spec phase88_rack_spec = {
  60. .clock = &phase88_rack_clk,
  61. .rate = &phase_series_rate_spec,
  62. .meter = NULL
  63. };
  64. /* 'PHASE 24 FW' and 'PHASE X24 FW' */
  65. static const struct snd_bebob_clock_spec phase24_series_clk = {
  66. .num = ARRAY_SIZE(phase24_series_clk_src_types),
  67. .types = phase24_series_clk_src_types,
  68. .get = &phase24_series_clk_src_get,
  69. };
  70. const struct snd_bebob_spec phase24_series_spec = {
  71. .clock = &phase24_series_clk,
  72. .rate = &phase_series_rate_spec,
  73. .meter = NULL
  74. };