xref: /linux/sound/firewire/dice/dice-alesis.c (revision 627661ced8246c8e833f3bc3817070e934cd79ba)
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] = {
1828b208f6STakashi Sakamoto 	{10, 10, 8},	/* Tx0 = Analog + S/PDIF. */
1928b208f6STakashi Sakamoto 	{16, 8, 0},	/* Tx1 = ADAT1 + ADAT2. */
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, &reg,
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 {
40*627661ceSTakashi 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 }
53