xref: /linux/sound/usb/caiaq/control.c (revision 6da7a2aa899f75116e1a62cef78c358ada9878b7)
1936e7d03SDaniel Mack /*
2936e7d03SDaniel Mack  *   Copyright (c) 2007 Daniel Mack
3936e7d03SDaniel Mack  *   friendly supported by NI.
4936e7d03SDaniel Mack  *
5936e7d03SDaniel Mack  *   This program is free software; you can redistribute it and/or modify
6936e7d03SDaniel Mack  *   it under the terms of the GNU General Public License as published by
7936e7d03SDaniel Mack  *   the Free Software Foundation; either version 2 of the License, or
8936e7d03SDaniel Mack  *   (at your option) any later version.
9936e7d03SDaniel Mack  *
10936e7d03SDaniel Mack  *   This program is distributed in the hope that it will be useful,
11936e7d03SDaniel Mack  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12936e7d03SDaniel Mack  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13936e7d03SDaniel Mack  *   GNU General Public License for more details.
14936e7d03SDaniel Mack  *
15936e7d03SDaniel Mack  *   You should have received a copy of the GNU General Public License
16936e7d03SDaniel Mack  *   along with this program; if not, write to the Free Software
17936e7d03SDaniel Mack  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18936e7d03SDaniel Mack  */
19936e7d03SDaniel Mack 
20936e7d03SDaniel Mack #include <linux/init.h>
21936e7d03SDaniel Mack #include <linux/usb.h>
22936e7d03SDaniel Mack #include <sound/control.h>
23936e7d03SDaniel Mack #include <sound/core.h>
24936e7d03SDaniel Mack #include <sound/pcm.h>
25936e7d03SDaniel Mack 
26936e7d03SDaniel Mack #include "device.h"
27936e7d03SDaniel Mack #include "control.h"
28936e7d03SDaniel Mack 
29936e7d03SDaniel Mack #define CNT_INTVAL 0x10000
30936e7d03SDaniel Mack 
31936e7d03SDaniel Mack static int control_info(struct snd_kcontrol *kcontrol,
32936e7d03SDaniel Mack 			struct snd_ctl_elem_info *uinfo)
33936e7d03SDaniel Mack {
34936e7d03SDaniel Mack 	struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
35936e7d03SDaniel Mack 	struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
36936e7d03SDaniel Mack 	int pos = kcontrol->private_value;
37936e7d03SDaniel Mack 	int is_intval = pos & CNT_INTVAL;
38*6da7a2aaSDaniel Mack 	int maxval = 63;
39936e7d03SDaniel Mack 
40936e7d03SDaniel Mack 	uinfo->count = 1;
41936e7d03SDaniel Mack 	pos &= ~CNT_INTVAL;
42936e7d03SDaniel Mack 
43*6da7a2aaSDaniel Mack 	switch (dev->chip.usb_id) {
44*6da7a2aaSDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
45*6da7a2aaSDaniel Mack 		if (pos == 0) {
46936e7d03SDaniel Mack 			/* current input mode of A8DJ */
47936e7d03SDaniel Mack 			uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
48936e7d03SDaniel Mack 			uinfo->value.integer.min = 0;
49936e7d03SDaniel Mack 			uinfo->value.integer.max = 2;
50936e7d03SDaniel Mack 			return 0;
51936e7d03SDaniel Mack 		}
52*6da7a2aaSDaniel Mack 		break;
53936e7d03SDaniel Mack 
54*6da7a2aaSDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
55*6da7a2aaSDaniel Mack 		if (pos == 0) {
56936e7d03SDaniel Mack 			/* current input mode of A4DJ */
57936e7d03SDaniel Mack 			uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
58936e7d03SDaniel Mack 			uinfo->value.integer.min = 0;
59936e7d03SDaniel Mack 			uinfo->value.integer.max = 1;
60936e7d03SDaniel Mack 			return 0;
61936e7d03SDaniel Mack 		}
62*6da7a2aaSDaniel Mack 		break;
63*6da7a2aaSDaniel Mack 
64*6da7a2aaSDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
65*6da7a2aaSDaniel Mack 		maxval = 127;
66*6da7a2aaSDaniel Mack 		break;
67*6da7a2aaSDaniel Mack 	}
68936e7d03SDaniel Mack 
69936e7d03SDaniel Mack 	if (is_intval) {
70936e7d03SDaniel Mack 		uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
71936e7d03SDaniel Mack 		uinfo->value.integer.min = 0;
72*6da7a2aaSDaniel Mack 		uinfo->value.integer.max = maxval;
73936e7d03SDaniel Mack 	} else {
74936e7d03SDaniel Mack 		uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
75936e7d03SDaniel Mack 		uinfo->value.integer.min = 0;
76936e7d03SDaniel Mack 		uinfo->value.integer.max = 1;
77936e7d03SDaniel Mack 	}
78936e7d03SDaniel Mack 
79936e7d03SDaniel Mack 	return 0;
80936e7d03SDaniel Mack }
81936e7d03SDaniel Mack 
82936e7d03SDaniel Mack static int control_get(struct snd_kcontrol *kcontrol,
83936e7d03SDaniel Mack 		       struct snd_ctl_elem_value *ucontrol)
84936e7d03SDaniel Mack {
85936e7d03SDaniel Mack 	struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
86936e7d03SDaniel Mack 	struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
87936e7d03SDaniel Mack 	int pos = kcontrol->private_value;
88936e7d03SDaniel Mack 
89936e7d03SDaniel Mack 	if (dev->chip.usb_id ==
90936e7d03SDaniel Mack 		USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ)) {
91936e7d03SDaniel Mack 		/* A4DJ has only one control */
92936e7d03SDaniel Mack 		/* do not expose hardware input mode 0 */
93936e7d03SDaniel Mack 		ucontrol->value.integer.value[0] = dev->control_state[0] - 1;
94936e7d03SDaniel Mack 		return 0;
95936e7d03SDaniel Mack 	}
96936e7d03SDaniel Mack 
97936e7d03SDaniel Mack 	if (pos & CNT_INTVAL)
98936e7d03SDaniel Mack 		ucontrol->value.integer.value[0]
99936e7d03SDaniel Mack 			= dev->control_state[pos & ~CNT_INTVAL];
100936e7d03SDaniel Mack 	else
101936e7d03SDaniel Mack 		ucontrol->value.integer.value[0]
102936e7d03SDaniel Mack 			= !!(dev->control_state[pos / 8] & (1 << pos % 8));
103936e7d03SDaniel Mack 
104936e7d03SDaniel Mack 	return 0;
105936e7d03SDaniel Mack }
106936e7d03SDaniel Mack 
107936e7d03SDaniel Mack static int control_put(struct snd_kcontrol *kcontrol,
108936e7d03SDaniel Mack 		       struct snd_ctl_elem_value *ucontrol)
109936e7d03SDaniel Mack {
110936e7d03SDaniel Mack 	struct snd_usb_audio *chip = snd_kcontrol_chip(kcontrol);
111936e7d03SDaniel Mack 	struct snd_usb_caiaqdev *dev = caiaqdev(chip->card);
112936e7d03SDaniel Mack 	int pos = kcontrol->private_value;
113*6da7a2aaSDaniel Mack 	unsigned char cmd = EP1_CMD_WRITE_IO;
114936e7d03SDaniel Mack 
115*6da7a2aaSDaniel Mack 	switch (dev->chip.usb_id) {
116*6da7a2aaSDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ): {
117936e7d03SDaniel Mack 		/* A4DJ has only one control */
118936e7d03SDaniel Mack 		/* do not expose hardware input mode 0 */
119936e7d03SDaniel Mack 		dev->control_state[0] = ucontrol->value.integer.value[0] + 1;
120936e7d03SDaniel Mack 		snd_usb_caiaq_send_command(dev, EP1_CMD_WRITE_IO,
121936e7d03SDaniel Mack 				dev->control_state, sizeof(dev->control_state));
122936e7d03SDaniel Mack 		return 1;
123936e7d03SDaniel Mack 	}
124936e7d03SDaniel Mack 
125*6da7a2aaSDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
126*6da7a2aaSDaniel Mack 		cmd = EP1_CMD_DIMM_LEDS;
127*6da7a2aaSDaniel Mack 		break;
128*6da7a2aaSDaniel Mack 	}
129*6da7a2aaSDaniel Mack 
130936e7d03SDaniel Mack 	if (pos & CNT_INTVAL) {
131936e7d03SDaniel Mack 		dev->control_state[pos & ~CNT_INTVAL]
132936e7d03SDaniel Mack 			= ucontrol->value.integer.value[0];
133*6da7a2aaSDaniel Mack 		snd_usb_caiaq_send_command(dev, cmd,
134936e7d03SDaniel Mack 				dev->control_state, sizeof(dev->control_state));
135936e7d03SDaniel Mack 	} else {
136936e7d03SDaniel Mack 		if (ucontrol->value.integer.value[0])
137936e7d03SDaniel Mack 			dev->control_state[pos / 8] |= 1 << (pos % 8);
138936e7d03SDaniel Mack 		else
139936e7d03SDaniel Mack 			dev->control_state[pos / 8] &= ~(1 << (pos % 8));
140936e7d03SDaniel Mack 
141*6da7a2aaSDaniel Mack 		snd_usb_caiaq_send_command(dev, cmd,
142936e7d03SDaniel Mack 				dev->control_state, sizeof(dev->control_state));
143936e7d03SDaniel Mack 	}
144936e7d03SDaniel Mack 
145936e7d03SDaniel Mack 	return 1;
146936e7d03SDaniel Mack }
147936e7d03SDaniel Mack 
148936e7d03SDaniel Mack static struct snd_kcontrol_new kcontrol_template __devinitdata = {
149936e7d03SDaniel Mack 	.iface = SNDRV_CTL_ELEM_IFACE_HWDEP,
150936e7d03SDaniel Mack 	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
151936e7d03SDaniel Mack 	.index = 0,
152936e7d03SDaniel Mack 	.info = control_info,
153936e7d03SDaniel Mack 	.get  = control_get,
154936e7d03SDaniel Mack 	.put  = control_put,
155936e7d03SDaniel Mack 	/* name and private_value filled later */
156936e7d03SDaniel Mack };
157936e7d03SDaniel Mack 
158936e7d03SDaniel Mack struct caiaq_controller {
159936e7d03SDaniel Mack 	char *name;
160936e7d03SDaniel Mack 	int index;
161936e7d03SDaniel Mack };
162936e7d03SDaniel Mack 
163936e7d03SDaniel Mack static struct caiaq_controller ak1_controller[] = {
164936e7d03SDaniel Mack 	{ "LED left", 	2 },
165936e7d03SDaniel Mack 	{ "LED middle", 1 },
166936e7d03SDaniel Mack 	{ "LED right", 	0 },
167936e7d03SDaniel Mack 	{ "LED ring", 	3 }
168936e7d03SDaniel Mack };
169936e7d03SDaniel Mack 
170936e7d03SDaniel Mack static struct caiaq_controller rk2_controller[] = {
171936e7d03SDaniel Mack 	{ "LED 1",		5  },
172936e7d03SDaniel Mack 	{ "LED 2",		4  },
173936e7d03SDaniel Mack 	{ "LED 3",		3  },
174936e7d03SDaniel Mack 	{ "LED 4",		2  },
175936e7d03SDaniel Mack 	{ "LED 5",		1  },
176936e7d03SDaniel Mack 	{ "LED 6",		0  },
177936e7d03SDaniel Mack 	{ "LED pedal",		6  },
178936e7d03SDaniel Mack 	{ "LED 7seg_1b",	8  },
179936e7d03SDaniel Mack 	{ "LED 7seg_1c",	9  },
180936e7d03SDaniel Mack 	{ "LED 7seg_2a",	10 },
181936e7d03SDaniel Mack 	{ "LED 7seg_2b",	11 },
182936e7d03SDaniel Mack 	{ "LED 7seg_2c",	12 },
183936e7d03SDaniel Mack 	{ "LED 7seg_2d",	13 },
184936e7d03SDaniel Mack 	{ "LED 7seg_2e",	14 },
185936e7d03SDaniel Mack 	{ "LED 7seg_2f",	15 },
186936e7d03SDaniel Mack 	{ "LED 7seg_2g",	16 },
187936e7d03SDaniel Mack 	{ "LED 7seg_3a",	17 },
188936e7d03SDaniel Mack 	{ "LED 7seg_3b",	18 },
189936e7d03SDaniel Mack 	{ "LED 7seg_3c",	19 },
190936e7d03SDaniel Mack 	{ "LED 7seg_3d",	20 },
191936e7d03SDaniel Mack 	{ "LED 7seg_3e",	21 },
192936e7d03SDaniel Mack 	{ "LED 7seg_3f",	22 },
193936e7d03SDaniel Mack 	{ "LED 7seg_3g",	23 }
194936e7d03SDaniel Mack };
195936e7d03SDaniel Mack 
196936e7d03SDaniel Mack static struct caiaq_controller rk3_controller[] = {
197936e7d03SDaniel Mack 	{ "LED 7seg_1a",        0 + 0 },
198936e7d03SDaniel Mack 	{ "LED 7seg_1b",        0 + 1 },
199936e7d03SDaniel Mack 	{ "LED 7seg_1c",        0 + 2 },
200936e7d03SDaniel Mack 	{ "LED 7seg_1d",        0 + 3 },
201936e7d03SDaniel Mack 	{ "LED 7seg_1e",        0 + 4 },
202936e7d03SDaniel Mack 	{ "LED 7seg_1f",        0 + 5 },
203936e7d03SDaniel Mack 	{ "LED 7seg_1g",        0 + 6 },
204936e7d03SDaniel Mack 	{ "LED 7seg_1p",        0 + 7 },
205936e7d03SDaniel Mack 
206936e7d03SDaniel Mack 	{ "LED 7seg_2a",        8 + 0 },
207936e7d03SDaniel Mack 	{ "LED 7seg_2b",        8 + 1 },
208936e7d03SDaniel Mack 	{ "LED 7seg_2c",        8 + 2 },
209936e7d03SDaniel Mack 	{ "LED 7seg_2d",        8 + 3 },
210936e7d03SDaniel Mack 	{ "LED 7seg_2e",        8 + 4 },
211936e7d03SDaniel Mack 	{ "LED 7seg_2f",        8 + 5 },
212936e7d03SDaniel Mack 	{ "LED 7seg_2g",        8 + 6 },
213936e7d03SDaniel Mack 	{ "LED 7seg_2p",        8 + 7 },
214936e7d03SDaniel Mack 
215936e7d03SDaniel Mack 	{ "LED 7seg_3a",        16 + 0 },
216936e7d03SDaniel Mack 	{ "LED 7seg_3b",        16 + 1 },
217936e7d03SDaniel Mack 	{ "LED 7seg_3c",        16 + 2 },
218936e7d03SDaniel Mack 	{ "LED 7seg_3d",        16 + 3 },
219936e7d03SDaniel Mack 	{ "LED 7seg_3e",        16 + 4 },
220936e7d03SDaniel Mack 	{ "LED 7seg_3f",        16 + 5 },
221936e7d03SDaniel Mack 	{ "LED 7seg_3g",        16 + 6 },
222936e7d03SDaniel Mack 	{ "LED 7seg_3p",        16 + 7 },
223936e7d03SDaniel Mack 
224936e7d03SDaniel Mack 	{ "LED 7seg_4a",        24 + 0 },
225936e7d03SDaniel Mack 	{ "LED 7seg_4b",        24 + 1 },
226936e7d03SDaniel Mack 	{ "LED 7seg_4c",        24 + 2 },
227936e7d03SDaniel Mack 	{ "LED 7seg_4d",        24 + 3 },
228936e7d03SDaniel Mack 	{ "LED 7seg_4e",        24 + 4 },
229936e7d03SDaniel Mack 	{ "LED 7seg_4f",        24 + 5 },
230936e7d03SDaniel Mack 	{ "LED 7seg_4g",        24 + 6 },
231936e7d03SDaniel Mack 	{ "LED 7seg_4p",        24 + 7 },
232936e7d03SDaniel Mack 
233936e7d03SDaniel Mack 	{ "LED 1",		32 + 0 },
234936e7d03SDaniel Mack 	{ "LED 2",		32 + 1 },
235936e7d03SDaniel Mack 	{ "LED 3",		32 + 2 },
236936e7d03SDaniel Mack 	{ "LED 4",		32 + 3 },
237936e7d03SDaniel Mack 	{ "LED 5",		32 + 4 },
238936e7d03SDaniel Mack 	{ "LED 6",		32 + 5 },
239936e7d03SDaniel Mack 	{ "LED 7",		32 + 6 },
240936e7d03SDaniel Mack 	{ "LED 8",		32 + 7 },
241936e7d03SDaniel Mack 	{ "LED pedal",		32 + 8 }
242936e7d03SDaniel Mack };
243936e7d03SDaniel Mack 
244936e7d03SDaniel Mack static struct caiaq_controller kore_controller[] = {
245936e7d03SDaniel Mack 	{ "LED F1",		8   | CNT_INTVAL },
246936e7d03SDaniel Mack 	{ "LED F2",		12  | CNT_INTVAL },
247936e7d03SDaniel Mack 	{ "LED F3",		0   | CNT_INTVAL },
248936e7d03SDaniel Mack 	{ "LED F4",		4   | CNT_INTVAL },
249936e7d03SDaniel Mack 	{ "LED F5",		11  | CNT_INTVAL },
250936e7d03SDaniel Mack 	{ "LED F6",		15  | CNT_INTVAL },
251936e7d03SDaniel Mack 	{ "LED F7",		3   | CNT_INTVAL },
252936e7d03SDaniel Mack 	{ "LED F8",		7   | CNT_INTVAL },
253936e7d03SDaniel Mack 	{ "LED touch1",	     	10  | CNT_INTVAL },
254936e7d03SDaniel Mack 	{ "LED touch2",	     	14  | CNT_INTVAL },
255936e7d03SDaniel Mack 	{ "LED touch3",	     	2   | CNT_INTVAL },
256936e7d03SDaniel Mack 	{ "LED touch4",	     	6   | CNT_INTVAL },
257936e7d03SDaniel Mack 	{ "LED touch5",	     	9   | CNT_INTVAL },
258936e7d03SDaniel Mack 	{ "LED touch6",	     	13  | CNT_INTVAL },
259936e7d03SDaniel Mack 	{ "LED touch7",	     	1   | CNT_INTVAL },
260936e7d03SDaniel Mack 	{ "LED touch8",	     	5   | CNT_INTVAL },
261936e7d03SDaniel Mack 	{ "LED left",	       	18  | CNT_INTVAL },
262936e7d03SDaniel Mack 	{ "LED right",	     	22  | CNT_INTVAL },
263936e7d03SDaniel Mack 	{ "LED up",		16  | CNT_INTVAL },
264936e7d03SDaniel Mack 	{ "LED down",	       	20  | CNT_INTVAL },
265936e7d03SDaniel Mack 	{ "LED stop",	       	23  | CNT_INTVAL },
266936e7d03SDaniel Mack 	{ "LED play",	       	21  | CNT_INTVAL },
267936e7d03SDaniel Mack 	{ "LED record",	     	19  | CNT_INTVAL },
268936e7d03SDaniel Mack 	{ "LED listen",		17  | CNT_INTVAL },
269936e7d03SDaniel Mack 	{ "LED lcd",		30  | CNT_INTVAL },
270936e7d03SDaniel Mack 	{ "LED menu",		28  | CNT_INTVAL },
271936e7d03SDaniel Mack 	{ "LED sound",	 	31  | CNT_INTVAL },
272936e7d03SDaniel Mack 	{ "LED esc",		29  | CNT_INTVAL },
273936e7d03SDaniel Mack 	{ "LED view",		27  | CNT_INTVAL },
274936e7d03SDaniel Mack 	{ "LED enter",		24  | CNT_INTVAL },
275936e7d03SDaniel Mack 	{ "LED control",	26  | CNT_INTVAL }
276936e7d03SDaniel Mack };
277936e7d03SDaniel Mack 
278936e7d03SDaniel Mack static struct caiaq_controller a8dj_controller[] = {
279936e7d03SDaniel Mack 	{ "Current input mode",			0 | CNT_INTVAL 	},
280936e7d03SDaniel Mack 	{ "GND lift for TC Vinyl mode", 	24 + 0 		},
281936e7d03SDaniel Mack 	{ "GND lift for TC CD/Line mode", 	24 + 1 		},
282936e7d03SDaniel Mack 	{ "GND lift for phono mode", 		24 + 2 		},
283936e7d03SDaniel Mack 	{ "Software lock", 			40 		}
284936e7d03SDaniel Mack };
285936e7d03SDaniel Mack 
286936e7d03SDaniel Mack static struct caiaq_controller a4dj_controller[] = {
287936e7d03SDaniel Mack 	{ "Current input mode",	0 | CNT_INTVAL 	}
288936e7d03SDaniel Mack };
289936e7d03SDaniel Mack 
290*6da7a2aaSDaniel Mack static struct caiaq_controller kontrolx1_controller[] = {
291*6da7a2aaSDaniel Mack 	{ "LED FX A: ON",		7 | CNT_INTVAL	},
292*6da7a2aaSDaniel Mack 	{ "LED FX A: 1",		6 | CNT_INTVAL	},
293*6da7a2aaSDaniel Mack 	{ "LED FX A: 2",		5 | CNT_INTVAL	},
294*6da7a2aaSDaniel Mack 	{ "LED FX A: 3",		4 | CNT_INTVAL	},
295*6da7a2aaSDaniel Mack 	{ "LED FX B: ON",		3 | CNT_INTVAL	},
296*6da7a2aaSDaniel Mack 	{ "LED FX B: 1",		2 | CNT_INTVAL	},
297*6da7a2aaSDaniel Mack 	{ "LED FX B: 2",		1 | CNT_INTVAL	},
298*6da7a2aaSDaniel Mack 	{ "LED FX B: 3",		0 | CNT_INTVAL	},
299*6da7a2aaSDaniel Mack 
300*6da7a2aaSDaniel Mack 	{ "LED Hotcue",			28 | CNT_INTVAL	},
301*6da7a2aaSDaniel Mack 	{ "LED Shift (white)",		29 | CNT_INTVAL	},
302*6da7a2aaSDaniel Mack 	{ "LED Shift (green)",		30 | CNT_INTVAL	},
303*6da7a2aaSDaniel Mack 
304*6da7a2aaSDaniel Mack 	{ "LED Deck A: FX1",		24 | CNT_INTVAL	},
305*6da7a2aaSDaniel Mack 	{ "LED Deck A: FX2",		25 | CNT_INTVAL	},
306*6da7a2aaSDaniel Mack 	{ "LED Deck A: IN",		17 | CNT_INTVAL	},
307*6da7a2aaSDaniel Mack 	{ "LED Deck A: OUT",		16 | CNT_INTVAL	},
308*6da7a2aaSDaniel Mack 	{ "LED Deck A: < BEAT",		19 | CNT_INTVAL	},
309*6da7a2aaSDaniel Mack 	{ "LED Deck A: BEAT >",		18 | CNT_INTVAL	},
310*6da7a2aaSDaniel Mack 	{ "LED Deck A: CUE/ABS",	21 | CNT_INTVAL	},
311*6da7a2aaSDaniel Mack 	{ "LED Deck A: CUP/REL",	20 | CNT_INTVAL	},
312*6da7a2aaSDaniel Mack 	{ "LED Deck A: PLAY",		23 | CNT_INTVAL	},
313*6da7a2aaSDaniel Mack 	{ "LED Deck A: SYNC",		22 | CNT_INTVAL	},
314*6da7a2aaSDaniel Mack 
315*6da7a2aaSDaniel Mack 	{ "LED Deck B: FX1",		26 | CNT_INTVAL	},
316*6da7a2aaSDaniel Mack 	{ "LED Deck B: FX2",		27 | CNT_INTVAL	},
317*6da7a2aaSDaniel Mack 	{ "LED Deck B: IN",		15 | CNT_INTVAL	},
318*6da7a2aaSDaniel Mack 	{ "LED Deck B: OUT",		14 | CNT_INTVAL	},
319*6da7a2aaSDaniel Mack 	{ "LED Deck B: < BEAT",		13 | CNT_INTVAL	},
320*6da7a2aaSDaniel Mack 	{ "LED Deck B: BEAT >",		12 | CNT_INTVAL	},
321*6da7a2aaSDaniel Mack 	{ "LED Deck B: CUE/ABS",	11 | CNT_INTVAL	},
322*6da7a2aaSDaniel Mack 	{ "LED Deck B: CUP/REL",	10 | CNT_INTVAL	},
323*6da7a2aaSDaniel Mack 	{ "LED Deck B: PLAY",		9  | CNT_INTVAL	},
324*6da7a2aaSDaniel Mack 	{ "LED Deck B: SYNC",		8  | CNT_INTVAL	},
325*6da7a2aaSDaniel Mack };
326*6da7a2aaSDaniel Mack 
327936e7d03SDaniel Mack static int __devinit add_controls(struct caiaq_controller *c, int num,
328936e7d03SDaniel Mack 				  struct snd_usb_caiaqdev *dev)
329936e7d03SDaniel Mack {
330936e7d03SDaniel Mack 	int i, ret;
331936e7d03SDaniel Mack 	struct snd_kcontrol *kc;
332936e7d03SDaniel Mack 
333936e7d03SDaniel Mack 	for (i = 0; i < num; i++, c++) {
334936e7d03SDaniel Mack 		kcontrol_template.name = c->name;
335936e7d03SDaniel Mack 		kcontrol_template.private_value = c->index;
336936e7d03SDaniel Mack 		kc = snd_ctl_new1(&kcontrol_template, dev);
337936e7d03SDaniel Mack 		ret = snd_ctl_add(dev->chip.card, kc);
338936e7d03SDaniel Mack 		if (ret < 0)
339936e7d03SDaniel Mack 			return ret;
340936e7d03SDaniel Mack 	}
341936e7d03SDaniel Mack 
342936e7d03SDaniel Mack 	return 0;
343936e7d03SDaniel Mack }
344936e7d03SDaniel Mack 
345936e7d03SDaniel Mack int __devinit snd_usb_caiaq_control_init(struct snd_usb_caiaqdev *dev)
346936e7d03SDaniel Mack {
347936e7d03SDaniel Mack 	int ret = 0;
348936e7d03SDaniel Mack 
349936e7d03SDaniel Mack 	switch (dev->chip.usb_id) {
350936e7d03SDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AK1):
351936e7d03SDaniel Mack 		ret = add_controls(ak1_controller,
352936e7d03SDaniel Mack 			ARRAY_SIZE(ak1_controller), dev);
353936e7d03SDaniel Mack 		break;
354936e7d03SDaniel Mack 
355936e7d03SDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL2):
356936e7d03SDaniel Mack 		ret = add_controls(rk2_controller,
357936e7d03SDaniel Mack 			ARRAY_SIZE(rk2_controller), dev);
358936e7d03SDaniel Mack 		break;
359936e7d03SDaniel Mack 
360936e7d03SDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_RIGKONTROL3):
361936e7d03SDaniel Mack 		ret = add_controls(rk3_controller,
362936e7d03SDaniel Mack 			ARRAY_SIZE(rk3_controller), dev);
363936e7d03SDaniel Mack 		break;
364936e7d03SDaniel Mack 
365936e7d03SDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER):
366936e7d03SDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_KORECONTROLLER2):
367936e7d03SDaniel Mack 		ret = add_controls(kore_controller,
368936e7d03SDaniel Mack 			ARRAY_SIZE(kore_controller), dev);
369936e7d03SDaniel Mack 		break;
370936e7d03SDaniel Mack 
371936e7d03SDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO8DJ):
372936e7d03SDaniel Mack 		ret = add_controls(a8dj_controller,
373936e7d03SDaniel Mack 			ARRAY_SIZE(a8dj_controller), dev);
374936e7d03SDaniel Mack 		break;
375*6da7a2aaSDaniel Mack 
376936e7d03SDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_AUDIO4DJ):
377936e7d03SDaniel Mack 		ret = add_controls(a4dj_controller,
378936e7d03SDaniel Mack 			ARRAY_SIZE(a4dj_controller), dev);
379936e7d03SDaniel Mack 		break;
380*6da7a2aaSDaniel Mack 
381*6da7a2aaSDaniel Mack 	case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1):
382*6da7a2aaSDaniel Mack 		ret = add_controls(kontrolx1_controller,
383*6da7a2aaSDaniel Mack 			ARRAY_SIZE(kontrolx1_controller), dev);
384*6da7a2aaSDaniel Mack 		break;
385936e7d03SDaniel Mack 	}
386936e7d03SDaniel Mack 
387936e7d03SDaniel Mack 	return ret;
388936e7d03SDaniel Mack }
389936e7d03SDaniel Mack 
390