xref: /linux/sound/firewire/dice/dice-alesis.c (revision 28b208f600a36f99365b7fcda2d425a2851c0c15)
1*28b208f6STakashi Sakamoto // SPDX-License-Identifier: GPL-2.0
2*28b208f6STakashi Sakamoto /*
3*28b208f6STakashi Sakamoto  * dice-alesis.c - a part of driver for DICE based devices
4*28b208f6STakashi Sakamoto  *
5*28b208f6STakashi Sakamoto  * Copyright (c) 2018 Takashi Sakamoto
6*28b208f6STakashi Sakamoto  */
7*28b208f6STakashi Sakamoto 
8*28b208f6STakashi Sakamoto #include "dice.h"
9*28b208f6STakashi Sakamoto 
10*28b208f6STakashi Sakamoto static const unsigned int
11*28b208f6STakashi Sakamoto alesis_io14_tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT] = {
12*28b208f6STakashi Sakamoto 	{6, 6, 4},	/* Tx0 = Analog + S/PDIF. */
13*28b208f6STakashi Sakamoto 	{8, 4, 0},	/* Tx1 = ADAT1. */
14*28b208f6STakashi Sakamoto };
15*28b208f6STakashi Sakamoto 
16*28b208f6STakashi Sakamoto static const unsigned int
17*28b208f6STakashi Sakamoto alesis_io26_tx_pcm_chs[MAX_STREAMS][SND_DICE_RATE_MODE_COUNT] = {
18*28b208f6STakashi Sakamoto 	{10, 10, 8},	/* Tx0 = Analog + S/PDIF. */
19*28b208f6STakashi Sakamoto 	{16, 8, 0},	/* Tx1 = ADAT1 + ADAT2. */
20*28b208f6STakashi Sakamoto };
21*28b208f6STakashi Sakamoto 
22*28b208f6STakashi Sakamoto int snd_dice_detect_alesis_formats(struct snd_dice *dice)
23*28b208f6STakashi Sakamoto {
24*28b208f6STakashi Sakamoto 	__be32 reg;
25*28b208f6STakashi Sakamoto 	u32 data;
26*28b208f6STakashi Sakamoto 	int i;
27*28b208f6STakashi Sakamoto 	int err;
28*28b208f6STakashi Sakamoto 
29*28b208f6STakashi Sakamoto 	err = snd_dice_transaction_read_tx(dice, TX_NUMBER_AUDIO, &reg,
30*28b208f6STakashi Sakamoto 					   sizeof(reg));
31*28b208f6STakashi Sakamoto 	if (err < 0)
32*28b208f6STakashi Sakamoto 		return err;
33*28b208f6STakashi Sakamoto 	data = be32_to_cpu(reg);
34*28b208f6STakashi Sakamoto 
35*28b208f6STakashi Sakamoto 	if (data == 4 || data == 6) {
36*28b208f6STakashi Sakamoto 		memcpy(dice->tx_pcm_chs, alesis_io14_tx_pcm_chs,
37*28b208f6STakashi Sakamoto 				MAX_STREAMS * SND_DICE_RATE_MODE_COUNT *
38*28b208f6STakashi Sakamoto 				sizeof(unsigned int));
39*28b208f6STakashi Sakamoto 	} else {
40*28b208f6STakashi Sakamoto 		memcpy(dice->rx_pcm_chs, alesis_io26_tx_pcm_chs,
41*28b208f6STakashi Sakamoto 				MAX_STREAMS * SND_DICE_RATE_MODE_COUNT *
42*28b208f6STakashi Sakamoto 				sizeof(unsigned int));
43*28b208f6STakashi Sakamoto 	}
44*28b208f6STakashi Sakamoto 
45*28b208f6STakashi Sakamoto 	for (i = 0; i < SND_DICE_RATE_MODE_COUNT; ++i)
46*28b208f6STakashi Sakamoto 		dice->rx_pcm_chs[0][i] = 8;
47*28b208f6STakashi Sakamoto 
48*28b208f6STakashi Sakamoto 	dice->tx_midi_ports[0] = 1;
49*28b208f6STakashi Sakamoto 	dice->rx_midi_ports[0] = 1;
50*28b208f6STakashi Sakamoto 
51*28b208f6STakashi Sakamoto 	return 0;
52*28b208f6STakashi Sakamoto }
53