Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 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 | |
| 9 | #include "./bebob.h" |
| 10 | |
Takashi Sakamoto | ba51771 | 2015-06-14 12:49:29 +0900 | [diff] [blame] | 11 | static enum snd_bebob_clock_type phase88_rack_clk_src_types[] = { |
| 12 | SND_BEBOB_CLOCK_TYPE_INTERNAL, |
| 13 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ |
| 14 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* Word Clock */ |
| 15 | }; |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 16 | static int |
| 17 | phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id) |
| 18 | { |
| 19 | unsigned int enable_ext, enable_word; |
| 20 | int err; |
| 21 | |
Takashi Sakamoto | 3f40328 | 2014-10-10 23:32:49 +0900 | [diff] [blame] | 22 | err = avc_audio_get_selector(bebob->unit, 0, 9, &enable_ext); |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 23 | if (err < 0) |
| 24 | goto end; |
Takashi Sakamoto | 3f40328 | 2014-10-10 23:32:49 +0900 | [diff] [blame] | 25 | err = avc_audio_get_selector(bebob->unit, 0, 8, &enable_word); |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 26 | if (err < 0) |
| 27 | goto end; |
| 28 | |
Takashi Sakamoto | 7ce5c92 | 2014-10-26 22:49:45 +0900 | [diff] [blame] | 29 | if (enable_ext == 0) |
| 30 | *id = 0; |
| 31 | else if (enable_word == 0) |
| 32 | *id = 1; |
| 33 | else |
| 34 | *id = 2; |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 35 | end: |
| 36 | return err; |
| 37 | } |
| 38 | |
Takashi Sakamoto | ba51771 | 2015-06-14 12:49:29 +0900 | [diff] [blame] | 39 | static enum snd_bebob_clock_type phase24_series_clk_src_types[] = { |
| 40 | SND_BEBOB_CLOCK_TYPE_INTERNAL, |
| 41 | SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */ |
| 42 | }; |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 43 | static int |
| 44 | phase24_series_clk_src_get(struct snd_bebob *bebob, unsigned int *id) |
| 45 | { |
Takashi Sakamoto | ba51771 | 2015-06-14 12:49:29 +0900 | [diff] [blame] | 46 | int err; |
| 47 | |
| 48 | err = avc_audio_get_selector(bebob->unit, 0, 4, id); |
| 49 | if (err < 0) |
| 50 | return err; |
| 51 | |
| 52 | if (*id >= ARRAY_SIZE(phase24_series_clk_src_types)) |
| 53 | return -EIO; |
| 54 | |
| 55 | return 0; |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 56 | } |
| 57 | |
Julia Lawall | 6b9866c | 2015-10-11 08:10:55 +0200 | [diff] [blame^] | 58 | static const struct snd_bebob_rate_spec phase_series_rate_spec = { |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 59 | .get = &snd_bebob_stream_get_rate, |
| 60 | .set = &snd_bebob_stream_set_rate, |
| 61 | }; |
| 62 | |
| 63 | /* PHASE 88 Rack FW */ |
Julia Lawall | 6b9866c | 2015-10-11 08:10:55 +0200 | [diff] [blame^] | 64 | static const struct snd_bebob_clock_spec phase88_rack_clk = { |
Takashi Sakamoto | ba51771 | 2015-06-14 12:49:29 +0900 | [diff] [blame] | 65 | .num = ARRAY_SIZE(phase88_rack_clk_src_types), |
Takashi Sakamoto | ba51771 | 2015-06-14 12:49:29 +0900 | [diff] [blame] | 66 | .types = phase88_rack_clk_src_types, |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 67 | .get = &phase88_rack_clk_src_get, |
| 68 | }; |
Julia Lawall | 6b9866c | 2015-10-11 08:10:55 +0200 | [diff] [blame^] | 69 | const struct snd_bebob_spec phase88_rack_spec = { |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 70 | .clock = &phase88_rack_clk, |
| 71 | .rate = &phase_series_rate_spec, |
| 72 | .meter = NULL |
| 73 | }; |
| 74 | |
| 75 | /* 'PHASE 24 FW' and 'PHASE X24 FW' */ |
Julia Lawall | 6b9866c | 2015-10-11 08:10:55 +0200 | [diff] [blame^] | 76 | static const struct snd_bebob_clock_spec phase24_series_clk = { |
Takashi Sakamoto | ba51771 | 2015-06-14 12:49:29 +0900 | [diff] [blame] | 77 | .num = ARRAY_SIZE(phase24_series_clk_src_types), |
Takashi Sakamoto | ba51771 | 2015-06-14 12:49:29 +0900 | [diff] [blame] | 78 | .types = phase24_series_clk_src_types, |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 79 | .get = &phase24_series_clk_src_get, |
| 80 | }; |
Julia Lawall | 6b9866c | 2015-10-11 08:10:55 +0200 | [diff] [blame^] | 81 | const struct snd_bebob_spec phase24_series_spec = { |
Takashi Sakamoto | 326b9ca | 2014-04-25 22:45:22 +0900 | [diff] [blame] | 82 | .clock = &phase24_series_clk, |
| 83 | .rate = &phase_series_rate_spec, |
| 84 | .meter = NULL |
| 85 | }; |