128b208f6STakashi Sakamoto // SPDX-License-Identifier: GPL-2.0 228b208f6STakashi Sakamoto /* 328b208f6STakashi Sakamoto * dice-alesis.c - a part of driver for DICE based devices 428b208f6STakashi Sakamoto * 528b208f6STakashi Sakamoto * Copyright (c) 2018 Takashi Sakamoto 628b208f6STakashi Sakamoto */ 728b208f6STakashi Sakamoto 828b208f6STakashi Sakamoto #include "dice.h" 928b208f6STakashi Sakamoto 1028b208f6STakashi Sakamoto static const unsigned int 1128b208f6STakashi Sakamoto alesis_io14_tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT] = { 1228b208f6STakashi Sakamoto {6, 6, 4}, /* Tx0 = Analog + S/PDIF. */ 1328b208f6STakashi Sakamoto {8, 4, 0}, /* Tx1 = ADAT1. */ 1428b208f6STakashi Sakamoto }; 1528b208f6STakashi Sakamoto 1628b208f6STakashi Sakamoto static const unsigned int 1728b208f6STakashi Sakamoto alesis_io26_tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT] = { 183a9236e9STakashi Sakamoto {10, 10, 4}, /* Tx0 = Analog + S/PDIF. */ 19*1b660489STakashi Sakamoto {16, 4, 0}, /* Tx1 = ADAT1 + ADAT2 (available at low rate). */ 2028b208f6STakashi Sakamoto }; 2128b208f6STakashi Sakamoto 2228b208f6STakashi Sakamoto int snd_dice_detect_alesis_formats(struct snd_dice *dice) 2328b208f6STakashi Sakamoto { 2428b208f6STakashi Sakamoto __be32 reg; 2528b208f6STakashi Sakamoto u32 data; 2628b208f6STakashi Sakamoto int i; 2728b208f6STakashi Sakamoto int err; 2828b208f6STakashi Sakamoto 2928b208f6STakashi Sakamoto err = snd_dice_transaction_read_tx(dice, TX_NUMBER_AUDIO, ®, 3028b208f6STakashi Sakamoto sizeof(reg)); 3128b208f6STakashi Sakamoto if (err < 0) 3228b208f6STakashi Sakamoto return err; 3328b208f6STakashi Sakamoto data = be32_to_cpu(reg); 3428b208f6STakashi Sakamoto 3528b208f6STakashi Sakamoto if (data == 4 || data == 6) { 3628b208f6STakashi Sakamoto memcpy(dice->tx_pcm_chs, alesis_io14_tx_pcm_chs, 3728b208f6STakashi Sakamoto MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * 3828b208f6STakashi Sakamoto sizeof(unsigned int)); 3928b208f6STakashi Sakamoto } else { 40627661ceSTakashi Sakamoto memcpy(dice->tx_pcm_chs, alesis_io26_tx_pcm_chs, 4128b208f6STakashi Sakamoto MAX_STREAMS * SND_DICE_RATE_MODE_COUNT * 4228b208f6STakashi Sakamoto sizeof(unsigned int)); 4328b208f6STakashi Sakamoto } 4428b208f6STakashi Sakamoto 4528b208f6STakashi Sakamoto for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i) 4628b208f6STakashi Sakamoto dice->rx_pcm_chs[0][i] = 8; 4728b208f6STakashi Sakamoto 4828b208f6STakashi Sakamoto dice->tx_midi_ports[0] = 1; 4928b208f6STakashi Sakamoto dice->rx_midi_ports[0] = 1; 5028b208f6STakashi Sakamoto 5128b208f6STakashi Sakamoto return 0; 5228b208f6STakashi Sakamoto } 53791a485fSTakashi Sakamoto 54791a485fSTakashi Sakamoto int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice) 55791a485fSTakashi Sakamoto { 56791a485fSTakashi Sakamoto int i; 57791a485fSTakashi Sakamoto 58791a485fSTakashi Sakamoto dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_LOW] = 16; 59791a485fSTakashi Sakamoto dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_LOW] = 12; 60791a485fSTakashi Sakamoto dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_MIDDLE] = 12; 61791a485fSTakashi Sakamoto dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_MIDDLE] = 4; 62791a485fSTakashi Sakamoto dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_HIGH] = 8; 63791a485fSTakashi Sakamoto dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_HIGH] = 0; 64791a485fSTakashi Sakamoto 65791a485fSTakashi Sakamoto for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i) { 66791a485fSTakashi Sakamoto dice->rx_pcm_chs[0][i] = 6; 67791a485fSTakashi Sakamoto dice->rx_pcm_chs[1][i] = 0; 68791a485fSTakashi Sakamoto } 69791a485fSTakashi Sakamoto 70791a485fSTakashi Sakamoto for (i = 0; i < MAX_STREAMS; ++i) { 71791a485fSTakashi Sakamoto dice->tx_midi_ports[i] = 2; 72791a485fSTakashi Sakamoto dice->rx_midi_ports[i] = 2; 73791a485fSTakashi Sakamoto } 74791a485fSTakashi Sakamoto 75791a485fSTakashi Sakamoto return 0; 76791a485fSTakashi Sakamoto } 77