xref: /openbmc/linux/sound/usb/mixer_maps.c (revision 0e17c50f)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *   Additional mixer mapping
4  *
5  *   Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
6  */
7 
8 struct usbmix_dB_map {
9 	u32 min;
10 	u32 max;
11 };
12 
13 struct usbmix_name_map {
14 	int id;
15 	const char *name;
16 	int control;
17 	const struct usbmix_dB_map *dB;
18 };
19 
20 struct usbmix_selector_map {
21 	int id;
22 	int count;
23 	const char **names;
24 };
25 
26 struct usbmix_ctl_map {
27 	u32 id;
28 	const struct usbmix_name_map *map;
29 	const struct usbmix_selector_map *selector_map;
30 	int ignore_ctl_error;
31 };
32 
33 /*
34  * USB control mappers for SB Exitigy
35  */
36 
37 /*
38  * Topology of SB Extigy (see on the wide screen :)
39 
40 USB_IN[1] --->FU[2]------------------------------+->MU[16]-->PU[17]-+->FU[18]--+->EU[27]--+->EU[21]-->FU[22]--+->FU[23] > Dig_OUT[24]
41                                                  ^                  |          |          |                   |
42 USB_IN[3] -+->SU[5]-->FU[6]--+->MU[14] ->PU[15]->+                  |          |          |                   +->FU[25] > Dig_OUT[26]
43            ^                 ^                   |                  |          |          |
44 Dig_IN[4] -+                 |                   |                  |          |          +->FU[28]---------------------> Spk_OUT[19]
45                              |                   |                  |          |
46 Lin-IN[7] -+-->FU[8]---------+                   |                  |          +----------------------------------------> Hph_OUT[20]
47            |                                     |                  |
48 Mic-IN[9] --+->FU[10]----------------------------+                  |
49            ||                                                       |
50            ||  +----------------------------------------------------+
51            VV  V
52            ++--+->SU[11]-->FU[12] --------------------------------------------------------------------------------------> USB_OUT[13]
53 */
54 
55 static const struct usbmix_name_map extigy_map[] = {
56 	/* 1: IT pcm */
57 	{ 2, "PCM Playback" }, /* FU */
58 	/* 3: IT pcm */
59 	/* 4: IT digital in */
60 	{ 5, NULL }, /* DISABLED: this seems to be bogus on some firmware */
61 	{ 6, "Digital In" }, /* FU */
62 	/* 7: IT line */
63 	{ 8, "Line Playback" }, /* FU */
64 	/* 9: IT mic */
65 	{ 10, "Mic Playback" }, /* FU */
66 	{ 11, "Capture Source" }, /* SU */
67 	{ 12, "Capture" }, /* FU */
68 	/* 13: OT pcm capture */
69 	/* 14: MU (w/o controls) */
70 	/* 15: PU (3D enh) */
71 	/* 16: MU (w/o controls) */
72 	{ 17, NULL, 1 }, /* DISABLED: PU-switch (any effect?) */
73 	{ 17, "Channel Routing", 2 },	/* PU: mode select */
74 	{ 18, "Tone Control - Bass", UAC_FU_BASS }, /* FU */
75 	{ 18, "Tone Control - Treble", UAC_FU_TREBLE }, /* FU */
76 	{ 18, "Master Playback" }, /* FU; others */
77 	/* 19: OT speaker */
78 	/* 20: OT headphone */
79 	{ 21, NULL }, /* DISABLED: EU (for what?) */
80 	{ 22, "Digital Out Playback" }, /* FU */
81 	{ 23, "Digital Out1 Playback" }, /* FU */  /* FIXME: corresponds to 24 */
82 	/* 24: OT digital out */
83 	{ 25, "IEC958 Optical Playback" }, /* FU */
84 	{ 26, "IEC958 Optical Playback" }, /* OT */
85 	{ 27, NULL }, /* DISABLED: EU (for what?) */
86 	/* 28: FU speaker (mute) */
87 	{ 29, NULL }, /* Digital Input Playback Source? */
88 	{ 0 } /* terminator */
89 };
90 
91 /* Sound Blaster MP3+ controls mapping
92  * The default mixer channels have totally misleading names,
93  * e.g. no Master and fake PCM volume
94  *			Pavel Mihaylov <bin@bash.info>
95  */
96 static const struct usbmix_dB_map mp3plus_dB_1 = {.min = -4781, .max = 0};
97 						/* just guess */
98 static const struct usbmix_dB_map mp3plus_dB_2 = {.min = -1781, .max = 618};
99 						/* just guess */
100 
101 static const struct usbmix_name_map mp3plus_map[] = {
102 	/* 1: IT pcm */
103 	/* 2: IT mic */
104 	/* 3: IT line */
105 	/* 4: IT digital in */
106 	/* 5: OT digital out */
107 	/* 6: OT speaker */
108 	/* 7: OT pcm capture */
109 	{ 8, "Capture Source" }, /* FU, default PCM Capture Source */
110 		/* (Mic, Input 1 = Line input, Input 2 = Optical input) */
111 	{ 9, "Master Playback" }, /* FU, default Speaker 1 */
112 	/* { 10, "Mic Capture", 1 }, */ /* FU, Mic Capture */
113 	{ 10, /* "Mic Capture", */ NULL, 2, .dB = &mp3plus_dB_2 },
114 		/* FU, Mic Capture */
115 	{ 10, "Mic Boost", 7 }, /* FU, default Auto Gain Input */
116 	{ 11, "Line Capture", .dB = &mp3plus_dB_2 },
117 		/* FU, default PCM Capture */
118 	{ 12, "Digital In Playback" }, /* FU, default PCM 1 */
119 	{ 13, /* "Mic Playback", */ .dB = &mp3plus_dB_1 },
120 		/* FU, default Mic Playback */
121 	{ 14, "Line Playback", .dB = &mp3plus_dB_1 }, /* FU, default Speaker */
122 	/* 15: MU */
123 	{ 0 } /* terminator */
124 };
125 
126 /* Topology of SB Audigy 2 NX
127 
128           +----------------------------->EU[27]--+
129           |                                      v
130           | +----------------------------------->SU[29]---->FU[22]-->Dig_OUT[24]
131           | |                                    ^
132 USB_IN[1]-+------------+              +->EU[17]->+->FU[11]-+
133             |          v              |          v         |
134 Dig_IN[4]---+->FU[6]-->MU[16]->FU[18]-+->EU[21]->SU[31]----->FU[30]->Hph_OUT[20]
135             |          ^              |                    |
136 Lin_IN[7]-+--->FU[8]---+              +->EU[23]->FU[28]------------->Spk_OUT[19]
137           | |                                              v
138           +--->FU[12]------------------------------------->SU[14]--->USB_OUT[15]
139             |                                              ^
140             +->FU[13]--------------------------------------+
141 */
142 static const struct usbmix_name_map audigy2nx_map[] = {
143 	/* 1: IT pcm playback */
144 	/* 4: IT digital in */
145 	{ 6, "Digital In Playback" }, /* FU */
146 	/* 7: IT line in */
147 	{ 8, "Line Playback" }, /* FU */
148 	{ 11, "What-U-Hear Capture" }, /* FU */
149 	{ 12, "Line Capture" }, /* FU */
150 	{ 13, "Digital In Capture" }, /* FU */
151 	{ 14, "Capture Source" }, /* SU */
152 	/* 15: OT pcm capture */
153 	/* 16: MU w/o controls */
154 	{ 17, NULL }, /* DISABLED: EU (for what?) */
155 	{ 18, "Master Playback" }, /* FU */
156 	/* 19: OT speaker */
157 	/* 20: OT headphone */
158 	{ 21, NULL }, /* DISABLED: EU (for what?) */
159 	{ 22, "Digital Out Playback" }, /* FU */
160 	{ 23, NULL }, /* DISABLED: EU (for what?) */
161 	/* 24: OT digital out */
162 	{ 27, NULL }, /* DISABLED: EU (for what?) */
163 	{ 28, "Speaker Playback" }, /* FU */
164 	{ 29, "Digital Out Source" }, /* SU */
165 	{ 30, "Headphone Playback" }, /* FU */
166 	{ 31, "Headphone Source" }, /* SU */
167 	{ 0 } /* terminator */
168 };
169 
170 static const struct usbmix_name_map mbox1_map[] = {
171 	{ 1, "Clock" },
172 	{ 0 } /* terminator */
173 };
174 
175 static const struct usbmix_selector_map c400_selectors[] = {
176 	{
177 		.id = 0x80,
178 		.count = 2,
179 		.names = (const char*[]) {"Internal", "SPDIF"}
180 	},
181 	{ 0 } /* terminator */
182 };
183 
184 static const struct usbmix_selector_map audigy2nx_selectors[] = {
185 	{
186 		.id = 14, /* Capture Source */
187 		.count = 3,
188 		.names = (const char*[]) {"Line", "Digital In", "What-U-Hear"}
189 	},
190 	{
191 		.id = 29, /* Digital Out Source */
192 		.count = 3,
193 		.names = (const char*[]) {"Front", "PCM", "Digital In"}
194 	},
195 	{
196 		.id = 31, /* Headphone Source */
197 		.count = 2,
198 		.names = (const char*[]) {"Front", "Side"}
199 	},
200 	{ 0 } /* terminator */
201 };
202 
203 /* Creative SoundBlaster Live! 24-bit External */
204 static const struct usbmix_name_map live24ext_map[] = {
205 	/* 2: PCM Playback Volume */
206 	{ 5, "Mic Capture" }, /* FU, default PCM Capture Volume */
207 	{ 0 } /* terminator */
208 };
209 
210 /* LineX FM Transmitter entry - needed to bypass controls bug */
211 static const struct usbmix_name_map linex_map[] = {
212 	/* 1: IT pcm */
213 	/* 2: OT Speaker */
214 	{ 3, "Master" }, /* FU: master volume - left / right / mute */
215 	{ 0 } /* terminator */
216 };
217 
218 static const struct usbmix_name_map maya44_map[] = {
219 	/* 1: IT line */
220 	{ 2, "Line Playback" }, /* FU */
221 	/* 3: IT line */
222 	{ 4, "Line Playback" }, /* FU */
223 	/* 5: IT pcm playback */
224 	/* 6: MU */
225 	{ 7, "Master Playback" }, /* FU */
226 	/* 8: OT speaker */
227 	/* 9: IT line */
228 	{ 10, "Line Capture" }, /* FU */
229 	/* 11: MU */
230 	/* 12: OT pcm capture */
231 	{ }
232 };
233 
234 /* Section "justlink_map" below added by James Courtier-Dutton <James@superbug.demon.co.uk>
235  * sourced from Maplin Electronics (http://www.maplin.co.uk), part number A56AK
236  * Part has 2 connectors that act as a single output. (TOSLINK Optical for digital out, and 3.5mm Jack for Analogue out.)
237  * The USB Mixer publishes a Microphone and extra Volume controls for it, but none exist on the device,
238  * so this map removes all unwanted sliders from alsamixer
239  */
240 
241 static const struct usbmix_name_map justlink_map[] = {
242 	/* 1: IT pcm playback */
243 	/* 2: Not present */
244 	{ 3, NULL}, /* IT mic (No mic input on device) */
245 	/* 4: Not present */
246 	/* 5: OT speacker */
247 	/* 6: OT pcm capture */
248 	{ 7, "Master Playback" }, /* Mute/volume for speaker */
249 	{ 8, NULL }, /* Capture Switch (No capture inputs on device) */
250 	{ 9, NULL }, /* Capture Mute/volume (No capture inputs on device */
251 	/* 0xa: Not present */
252 	/* 0xb: MU (w/o controls) */
253 	{ 0xc, NULL }, /* Mic feedback Mute/volume (No capture inputs on device) */
254 	{ 0 } /* terminator */
255 };
256 
257 /* TerraTec Aureon 5.1 MkII USB */
258 static const struct usbmix_name_map aureon_51_2_map[] = {
259 	/* 1: IT USB */
260 	/* 2: IT Mic */
261 	/* 3: IT Line */
262 	/* 4: IT SPDIF */
263 	/* 5: OT SPDIF */
264 	/* 6: OT Speaker */
265 	/* 7: OT USB */
266 	{ 8, "Capture Source" }, /* SU */
267 	{ 9, "Master Playback" }, /* FU */
268 	{ 10, "Mic Capture" }, /* FU */
269 	{ 11, "Line Capture" }, /* FU */
270 	{ 12, "IEC958 In Capture" }, /* FU */
271 	{ 13, "Mic Playback" }, /* FU */
272 	{ 14, "Line Playback" }, /* FU */
273 	/* 15: MU */
274 	{} /* terminator */
275 };
276 
277 static const struct usbmix_name_map scratch_live_map[] = {
278 	/* 1: IT Line 1 (USB streaming) */
279 	/* 2: OT Line 1 (Speaker) */
280 	/* 3: IT Line 1 (Line connector) */
281 	{ 4, "Line 1 In" }, /* FU */
282 	/* 5: OT Line 1 (USB streaming) */
283 	/* 6: IT Line 2 (USB streaming) */
284 	/* 7: OT Line 2 (Speaker) */
285 	/* 8: IT Line 2 (Line connector) */
286 	{ 9, "Line 2 In" }, /* FU */
287 	/* 10: OT Line 2 (USB streaming) */
288 	/* 11: IT Mic (Line connector) */
289 	/* 12: OT Mic (USB streaming) */
290 	{ 0 } /* terminator */
291 };
292 
293 static const struct usbmix_name_map ebox44_map[] = {
294 	{ 4, NULL }, /* FU */
295 	{ 6, NULL }, /* MU */
296 	{ 7, NULL }, /* FU */
297 	{ 10, NULL }, /* FU */
298 	{ 11, NULL }, /* MU */
299 	{ 0 }
300 };
301 
302 /* "Gamesurround Muse Pocket LT" looks same like "Sound Blaster MP3+"
303  *  most importand difference is SU[8], it should be set to "Capture Source"
304  *  to make alsamixer and PA working properly.
305  *  FIXME: or mp3plus_map should use "Capture Source" too,
306  *  so this maps can be merget
307  */
308 static const struct usbmix_name_map hercules_usb51_map[] = {
309 	{ 8, "Capture Source" },	/* SU, default "PCM Capture Source" */
310 	{ 9, "Master Playback" },	/* FU, default "Speaker Playback" */
311 	{ 10, "Mic Boost", 7 },		/* FU, default "Auto Gain Input" */
312 	{ 11, "Line Capture" },		/* FU, default "PCM Capture" */
313 	{ 13, "Mic Bypass Playback" },	/* FU, default "Mic Playback" */
314 	{ 14, "Line Bypass Playback" },	/* FU, default "Line Playback" */
315 	{ 0 }				/* terminator */
316 };
317 
318 /* Plantronics Gamecom 780 has a broken volume control, better to disable it */
319 static const struct usbmix_name_map gamecom780_map[] = {
320 	{ 9, NULL }, /* FU, speaker out */
321 	{}
322 };
323 
324 /* some (all?) SCMS USB3318 devices are affected by a firmware lock up
325  * when anything attempts to access FU 10 (control)
326  */
327 static const struct usbmix_name_map scms_usb3318_map[] = {
328 	{ 10, NULL },
329 	{ 0 }
330 };
331 
332 /* Bose companion 5, the dB conversion factor is 16 instead of 256 */
333 static const struct usbmix_dB_map bose_companion5_dB = {-5006, -6};
334 static const struct usbmix_name_map bose_companion5_map[] = {
335 	{ 3, NULL, .dB = &bose_companion5_dB },
336 	{ 0 }	/* terminator */
337 };
338 
339 /*
340  * Dell usb dock with ALC4020 codec had a firmware problem where it got
341  * screwed up when zero volume is passed; just skip it as a workaround
342  *
343  * Also the extension unit gives an access error, so skip it as well.
344  */
345 static const struct usbmix_name_map dell_alc4020_map[] = {
346 	{ 4, NULL },	/* extension unit */
347 	{ 16, NULL },
348 	{ 19, NULL },
349 	{ 0 }
350 };
351 
352 /*
353  * Corsair Virtuoso calls everything "Headset" without this, leading to
354  * applications moving the sidetone control instead of the main one.
355  */
356 static const struct usbmix_name_map corsair_virtuoso_map[] = {
357 	{ 3, "Mic Capture" },
358 	{ 6, "Sidetone Playback" },
359 	{ 0 }
360 };
361 
362 /*
363  * Control map entries
364  */
365 
366 static const struct usbmix_ctl_map usbmix_ctl_maps[] = {
367 	{
368 		.id = USB_ID(0x041e, 0x3000),
369 		.map = extigy_map,
370 		.ignore_ctl_error = 1,
371 	},
372 	{
373 		.id = USB_ID(0x041e, 0x3010),
374 		.map = mp3plus_map,
375 	},
376 	{
377 		.id = USB_ID(0x041e, 0x3020),
378 		.map = audigy2nx_map,
379 		.selector_map = audigy2nx_selectors,
380 	},
381  	{
382 		.id = USB_ID(0x041e, 0x3040),
383 		.map = live24ext_map,
384 	},
385 	{
386 		.id = USB_ID(0x041e, 0x3048),
387 		.map = audigy2nx_map,
388 		.selector_map = audigy2nx_selectors,
389 	},
390 	{	/* Logitech, Inc. QuickCam Pro for Notebooks */
391 		.id = USB_ID(0x046d, 0x0991),
392 		.ignore_ctl_error = 1,
393 	},
394 	{	/* Logitech, Inc. QuickCam E 3500 */
395 		.id = USB_ID(0x046d, 0x09a4),
396 		.ignore_ctl_error = 1,
397 	},
398 	{	/* Plantronics GameCom 780 */
399 		.id = USB_ID(0x047f, 0xc010),
400 		.map = gamecom780_map,
401 	},
402 	{
403 		/* Hercules DJ Console (Windows Edition) */
404 		.id = USB_ID(0x06f8, 0xb000),
405 		.ignore_ctl_error = 1,
406 	},
407 	{
408 		/* Hercules DJ Console (Macintosh Edition) */
409 		.id = USB_ID(0x06f8, 0xd002),
410 		.ignore_ctl_error = 1,
411 	},
412 	{
413 		/* Hercules Gamesurround Muse Pocket LT
414 		 * (USB 5.1 Channel Audio Adapter)
415 		 */
416 		.id = USB_ID(0x06f8, 0xc000),
417 		.map = hercules_usb51_map,
418 	},
419 	{
420 		.id = USB_ID(0x0763, 0x2030),
421 		.selector_map = c400_selectors,
422 	},
423 	{
424 		.id = USB_ID(0x0763, 0x2031),
425 		.selector_map = c400_selectors,
426 	},
427 	{
428 		.id = USB_ID(0x08bb, 0x2702),
429 		.map = linex_map,
430 		.ignore_ctl_error = 1,
431 	},
432 	{
433 		.id = USB_ID(0x0a92, 0x0091),
434 		.map = maya44_map,
435 	},
436 	{
437 		.id = USB_ID(0x0c45, 0x1158),
438 		.map = justlink_map,
439 	},
440 	{
441 		.id = USB_ID(0x0ccd, 0x0028),
442 		.map = aureon_51_2_map,
443 	},
444 	{
445 		.id = USB_ID(0x0bda, 0x4014),
446 		.map = dell_alc4020_map,
447 	},
448 	{
449 		.id = USB_ID(0x0dba, 0x1000),
450 		.map = mbox1_map,
451 	},
452 	{
453 		.id = USB_ID(0x13e5, 0x0001),
454 		.map = scratch_live_map,
455 		.ignore_ctl_error = 1,
456 	},
457 	{
458 		.id = USB_ID(0x200c, 0x1018),
459 		.map = ebox44_map,
460 	},
461 	{
462 		/* MAYA44 USB+ */
463 		.id = USB_ID(0x2573, 0x0008),
464 		.map = maya44_map,
465 	},
466 	{
467 		/* KEF X300A */
468 		.id = USB_ID(0x27ac, 0x1000),
469 		.map = scms_usb3318_map,
470 	},
471 	{
472 		/* Arcam rPAC */
473 		.id = USB_ID(0x25c4, 0x0003),
474 		.map = scms_usb3318_map,
475 	},
476 	{
477 		/* Bose Companion 5 */
478 		.id = USB_ID(0x05a7, 0x1020),
479 		.map = bose_companion5_map,
480 	},
481 	{
482 		/* Corsair Virtuoso (wired mode) */
483 		.id = USB_ID(0x1b1c, 0x0a41),
484 		.map = corsair_virtuoso_map,
485 	},
486 	{
487 		/* Corsair Virtuoso (wireless mode) */
488 		.id = USB_ID(0x1b1c, 0x0a42),
489 		.map = corsair_virtuoso_map,
490 	},
491 	{ 0 } /* terminator */
492 };
493 
494 /*
495  * Control map entries for UAC3 BADD profiles
496  */
497 
498 static const struct usbmix_name_map uac3_badd_generic_io_map[] = {
499 	{ UAC3_BADD_FU_ID2, "Generic Out Playback" },
500 	{ UAC3_BADD_FU_ID5, "Generic In Capture" },
501 	{ 0 }					/* terminator */
502 };
503 static const struct usbmix_name_map uac3_badd_headphone_map[] = {
504 	{ UAC3_BADD_FU_ID2, "Headphone Playback" },
505 	{ 0 }					/* terminator */
506 };
507 static const struct usbmix_name_map uac3_badd_speaker_map[] = {
508 	{ UAC3_BADD_FU_ID2, "Speaker Playback" },
509 	{ 0 }					/* terminator */
510 };
511 static const struct usbmix_name_map uac3_badd_microphone_map[] = {
512 	{ UAC3_BADD_FU_ID5, "Mic Capture" },
513 	{ 0 }					/* terminator */
514 };
515 /* Covers also 'headset adapter' profile */
516 static const struct usbmix_name_map uac3_badd_headset_map[] = {
517 	{ UAC3_BADD_FU_ID2, "Headset Playback" },
518 	{ UAC3_BADD_FU_ID5, "Headset Capture" },
519 	{ UAC3_BADD_FU_ID7, "Sidetone Mixing" },
520 	{ 0 }					/* terminator */
521 };
522 static const struct usbmix_name_map uac3_badd_speakerphone_map[] = {
523 	{ UAC3_BADD_FU_ID2, "Speaker Playback" },
524 	{ UAC3_BADD_FU_ID5, "Mic Capture" },
525 	{ 0 }					/* terminator */
526 };
527 
528 static const struct usbmix_ctl_map uac3_badd_usbmix_ctl_maps[] = {
529 	{
530 		.id = UAC3_FUNCTION_SUBCLASS_GENERIC_IO,
531 		.map = uac3_badd_generic_io_map,
532 	},
533 	{
534 		.id = UAC3_FUNCTION_SUBCLASS_HEADPHONE,
535 		.map = uac3_badd_headphone_map,
536 	},
537 	{
538 		.id = UAC3_FUNCTION_SUBCLASS_SPEAKER,
539 		.map = uac3_badd_speaker_map,
540 	},
541 	{
542 		.id = UAC3_FUNCTION_SUBCLASS_MICROPHONE,
543 		.map = uac3_badd_microphone_map,
544 	},
545 	{
546 		.id = UAC3_FUNCTION_SUBCLASS_HEADSET,
547 		.map = uac3_badd_headset_map,
548 	},
549 	{
550 		.id = UAC3_FUNCTION_SUBCLASS_HEADSET_ADAPTER,
551 		.map = uac3_badd_headset_map,
552 	},
553 	{
554 		.id = UAC3_FUNCTION_SUBCLASS_SPEAKERPHONE,
555 		.map = uac3_badd_speakerphone_map,
556 	},
557 	{ 0 } /* terminator */
558 };
559