xref: /linux/sound/firewire/dice/dice-alesis.c (revision 791a485f2da392df00341ed4c0c14780fd320d92)
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. */
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 {
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 }
53*791a485fSTakashi Sakamoto 
54*791a485fSTakashi Sakamoto int snd_dice_detect_alesis_mastercontrol_formats(struct snd_dice *dice)
55*791a485fSTakashi Sakamoto {
56*791a485fSTakashi Sakamoto 	int i;
57*791a485fSTakashi Sakamoto 
58*791a485fSTakashi Sakamoto 	dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_LOW]	= 16;
59*791a485fSTakashi Sakamoto 	dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_LOW]	= 12;
60*791a485fSTakashi Sakamoto 	dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_MIDDLE]	= 12;
61*791a485fSTakashi Sakamoto 	dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_MIDDLE]	= 4;
62*791a485fSTakashi Sakamoto 	dice->tx_pcm_chs[0][SND_DICE_RATE_MODE_HIGH]	= 8;
63*791a485fSTakashi Sakamoto 	dice->tx_pcm_chs[1][SND_DICE_RATE_MODE_HIGH]	= 0;
64*791a485fSTakashi Sakamoto 
65*791a485fSTakashi Sakamoto 	for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i) {
66*791a485fSTakashi Sakamoto 		dice->rx_pcm_chs[0][i] = 6;
67*791a485fSTakashi Sakamoto 		dice->rx_pcm_chs[1][i] = 0;
68*791a485fSTakashi Sakamoto 	}
69*791a485fSTakashi Sakamoto 
70*791a485fSTakashi Sakamoto 	for (i = 0; i < MAX_STREAMS; ++i) {
71*791a485fSTakashi Sakamoto 		dice->tx_midi_ports[i] = 2;
72*791a485fSTakashi Sakamoto 		dice->rx_midi_ports[i] = 2;
73*791a485fSTakashi Sakamoto 	}
74*791a485fSTakashi Sakamoto 
75*791a485fSTakashi Sakamoto 	return 0;
76*791a485fSTakashi Sakamoto }
77