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