Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 // dice-presonus.c - a part of driver for DICE based devices
0003 //
0004 // Copyright (c) 2019 Takashi Sakamoto
0005 //
0006 // Licensed under the terms of the GNU General Public License, version 2.
0007 
0008 #include "dice.h"
0009 
0010 struct dice_presonus_spec {
0011     unsigned int tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT];
0012     unsigned int rx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT];
0013     bool has_midi;
0014 };
0015 
0016 static const struct dice_presonus_spec dice_presonus_firesutio = {
0017     .tx_pcm_chs = {{16, 16, 0}, {10, 2, 0} },
0018     .rx_pcm_chs = {{16, 16, 0}, {10, 2, 0} },
0019     .has_midi = true,
0020 };
0021 
0022 int snd_dice_detect_presonus_formats(struct snd_dice *dice)
0023 {
0024     static const struct {
0025         u32 model_id;
0026         const struct dice_presonus_spec *spec;
0027     } *entry, entries[] = {
0028         {0x000008, &dice_presonus_firesutio},
0029     };
0030     struct fw_csr_iterator it;
0031     int key, val, model_id;
0032     int i;
0033 
0034     model_id = 0;
0035     fw_csr_iterator_init(&it, dice->unit->directory);
0036     while (fw_csr_iterator_next(&it, &key, &val)) {
0037         if (key == CSR_MODEL) {
0038             model_id = val;
0039             break;
0040         }
0041     }
0042 
0043     for (i = 0; i < ARRAY_SIZE(entries); ++i) {
0044         entry = entries + i;
0045         if (entry->model_id == model_id)
0046             break;
0047     }
0048     if (i == ARRAY_SIZE(entries))
0049         return -ENODEV;
0050 
0051     memcpy(dice->tx_pcm_chs, entry->spec->tx_pcm_chs,
0052            MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
0053     memcpy(dice->rx_pcm_chs, entry->spec->rx_pcm_chs,
0054            MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * sizeof(unsigned int));
0055 
0056     if (entry->spec->has_midi) {
0057         dice->tx_midi_ports[0] = 1;
0058         dice->rx_midi_ports[0] = 1;
0059     }
0060 
0061     return 0;
0062 }