xref: /freebsd/sys/dev/sound/pcm/matrix.h (revision af0a81b6470aba4af4a24ae9804053722846ded4)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2007-2009 Ariff Abdullah <ariff@FreeBSD.org>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 
29 #ifndef _SND_MATRIX_H_
30 #define _SND_MATRIX_H_
31 
32 #undef SND_MULTICHANNEL
33 #ifndef SND_OLDSTEREO
34 #define SND_MULTICHANNEL	1
35 #endif
36 
37 /*
38  * XXX = unused, but part of the definition (will be used someday, maybe).
39  */
40 #define SND_CHN_T_FL		0	/* Front Left         */
41 #define SND_CHN_T_FR		1	/* Front Right        */
42 #define SND_CHN_T_FC		2	/* Front Center       */
43 #define SND_CHN_T_LF		3	/* Low Frequency      */
44 #define SND_CHN_T_BL		4	/* Back Left          */
45 #define SND_CHN_T_BR		5	/* Back Right         */
46 #define SND_CHN_T_FLC		6	/* Front Left Center  XXX */
47 #define SND_CHN_T_FRC		7	/* Front Right Center XXX */
48 #define SND_CHN_T_BC		8	/* Back Center        */
49 #define SND_CHN_T_SL		9	/* Side Left          */
50 #define SND_CHN_T_SR		10	/* Side Right         */
51 #define SND_CHN_T_TC		11	/* Top Center         XXX */
52 #define SND_CHN_T_TFL		12	/* Top Front Left     XXX */
53 #define SND_CHN_T_TFC		13	/* Top Front Center   XXX */
54 #define SND_CHN_T_TFR		14	/* Top Front Right    XXX */
55 #define SND_CHN_T_TBL		15	/* Top Back Left      XXX */
56 #define SND_CHN_T_TBC		16	/* Top Back Center    XXX */
57 #define SND_CHN_T_TBR		17	/* Top Back Right     XXX */
58 #define SND_CHN_T_MAX		18	/* Maximum channels   */
59 
60 #define SND_CHN_T_ZERO		(SND_CHN_T_MAX + 1)	/* Zero samples */
61 
62 #define SND_CHN_T_LABELS	{					\
63 	 "fl",  "fr",  "fc",  "lf",  "bl",  "br",			\
64 	"flc", "frc",  "bc",  "sl",  "sr",  "tc",			\
65 	"tfl", "tfc", "tfr", "tbl", "tbc", "tbr"			\
66 }
67 
68 #define SND_CHN_T_NAMES	{						\
69 	"Front Left", "Front Right", "Front Center",			\
70 	"Low Frequency Effects",					\
71 	"Back Left", "Back Right",					\
72 	"Front Left Center", "Front Right Center",			\
73 	"Back Center",							\
74 	"Side Left", "Side Right",					\
75 	"Top Center",							\
76 	"Top Front Left", "Top Front Center", "Top Front Right",	\
77 	"Top Back Left", "Top Back Center", "Top Back Right"		\
78 }
79 
80 #define SND_CHN_T_MASK_FL	(1 << SND_CHN_T_FL)
81 #define SND_CHN_T_MASK_FR	(1 << SND_CHN_T_FR)
82 #define SND_CHN_T_MASK_FC	(1 << SND_CHN_T_FC)
83 #define SND_CHN_T_MASK_LF	(1 << SND_CHN_T_LF)
84 #define SND_CHN_T_MASK_BL	(1 << SND_CHN_T_BL)
85 #define SND_CHN_T_MASK_BR	(1 << SND_CHN_T_BR)
86 #define SND_CHN_T_MASK_FLC	(1 << SND_CHN_T_FLC)
87 #define SND_CHN_T_MASK_FRC	(1 << SND_CHN_T_FRC)
88 #define SND_CHN_T_MASK_BC	(1 << SND_CHN_T_BC)
89 #define SND_CHN_T_MASK_SL	(1 << SND_CHN_T_SL)
90 #define SND_CHN_T_MASK_SR	(1 << SND_CHN_T_SR)
91 #define SND_CHN_T_MASK_TC	(1 << SND_CHN_T_TC)
92 #define SND_CHN_T_MASK_TFL	(1 << SND_CHN_T_TFL)
93 #define SND_CHN_T_MASK_TFC	(1 << SND_CHN_T_TFC)
94 #define SND_CHN_T_MASK_TFR	(1 << SND_CHN_T_TFR)
95 #define SND_CHN_T_MASK_TBL	(1 << SND_CHN_T_TBL)
96 #define SND_CHN_T_MASK_TBC	(1 << SND_CHN_T_TBC)
97 #define SND_CHN_T_MASK_TBR	(1 << SND_CHN_T_TBR)
98 
99 #define SND_CHN_LEFT_MASK	(SND_CHN_T_MASK_FL  |			\
100 				 SND_CHN_T_MASK_BL  |			\
101 				 SND_CHN_T_MASK_FLC |			\
102 				 SND_CHN_T_MASK_SL  |			\
103 				 SND_CHN_T_MASK_TFL |			\
104 				 SND_CHN_T_MASK_TBL)
105 
106 #define SND_CHN_RIGHT_MASK	(SND_CHN_T_MASK_FR  |			\
107 				 SND_CHN_T_MASK_BR  |			\
108 				 SND_CHN_T_MASK_FRC |			\
109 				 SND_CHN_T_MASK_SR  |			\
110 				 SND_CHN_T_MASK_TFR |			\
111 				 SND_CHN_T_MASK_TBR)
112 
113 #define SND_CHN_CENTER_MASK	(SND_CHN_T_MASK_FC  |			\
114 				 SND_CHN_T_MASK_BC  |			\
115 				 SND_CHN_T_MASK_TC  |			\
116 				 SND_CHN_T_MASK_TFC |			\
117 				 SND_CHN_T_MASK_TBC |			\
118 				 SND_CHN_T_MASK_LF)	/* XXX what?!? */
119 
120 /*
121  * Matrix identity.
122  */
123 
124 /* 1 @ Mono 1.0 */
125 #define SND_CHN_MATRIX_1_0	0
126 #define SND_CHN_MATRIX_1	SND_CHN_MATRIX_1_0
127 
128 /* 2 @ Stereo 2.0 */
129 #define SND_CHN_MATRIX_2_0	1
130 #define SND_CHN_MATRIX_2	SND_CHN_MATRIX_2_0
131 
132 /* 3 @ 2.1 (lfe), 3.0 (rear center, DEFAULT) */
133 #define SND_CHN_MATRIX_2_1	2
134 #define SND_CHN_MATRIX_3_0	3
135 #define SND_CHN_MATRIX_3	SND_CHN_MATRIX_3_0
136 
137 /* 4 @ 3.1 (lfe), 4.0 (Quadraphonic, DEFAULT) */
138 #define SND_CHN_MATRIX_3_1	4
139 #define SND_CHN_MATRIX_4_0	5
140 #define SND_CHN_MATRIX_4	SND_CHN_MATRIX_4_0
141 
142 /* 5 @ 4.1 (lfe), 5.0 (center, DEFAULT) */
143 #define SND_CHN_MATRIX_4_1	6
144 #define SND_CHN_MATRIX_5_0	7
145 #define SND_CHN_MATRIX_5	SND_CHN_MATRIX_5_0
146 
147 /* 6 @ 5.1 (lfe, DEFAULT), 6.0 (rear center) */
148 #define SND_CHN_MATRIX_5_1	8
149 #define SND_CHN_MATRIX_6_0	9
150 #define SND_CHN_MATRIX_6	SND_CHN_MATRIX_5_1
151 
152 /* 7 @ 6.1 (lfe, DEFAULT), 7.0 */
153 #define SND_CHN_MATRIX_6_1	10
154 #define SND_CHN_MATRIX_7_0	11
155 #define SND_CHN_MATRIX_7	SND_CHN_MATRIX_6_1
156 
157 /* 8 @ 7.1 (lfe) */
158 #define SND_CHN_MATRIX_7_1	12
159 #define SND_CHN_MATRIX_8	SND_CHN_MATRIX_7_1
160 
161 #define SND_CHN_MATRIX_MAX	13
162 
163 #define SND_CHN_MATRIX_BEGIN	SND_CHN_MATRIX_1_0
164 #define SND_CHN_MATRIX_END	SND_CHN_MATRIX_7_1
165 
166 /* Custom matrix identity */
167 #define SND_CHN_MATRIX_DRV		-4	/* driver own identity   */
168 #define SND_CHN_MATRIX_PCMCHANNEL	-3	/* PCM channel identity  */
169 #define SND_CHN_MATRIX_MISC		-2	/* misc, custom defined  */
170 #define SND_CHN_MATRIX_UNKNOWN		-1	/* unknown               */
171 
172 #define SND_CHN_T_VOL_0DB	SND_CHN_T_MAX
173 #define SND_CHN_T_VOL_MAX	(SND_CHN_T_VOL_0DB + 1)
174 
175 #define SND_CHN_T_BEGIN		SND_CHN_T_FL
176 #define SND_CHN_T_END		SND_CHN_T_TBR
177 #define SND_CHN_T_STEP		1
178 #define SND_CHN_MIN		1
179 
180 #ifdef SND_MULTICHANNEL
181 #define SND_CHN_MAX		8
182 #else
183 #define SND_CHN_MAX		2
184 #endif
185 
186 /*
187  * Multichannel interleaved volume matrix. Each calculated value relative
188  * to master and 0db will be stored in each CLASS + 1 as long as
189  * chn_setvolume_matrix() or the equivalent CHN_SETVOLUME() macros is
190  * used (see channel.c).
191  */
192 #define SND_VOL_C_MASTER	0
193 #define SND_VOL_C_PCM		1
194 #define SND_VOL_C_PCM_VAL	2
195 #define SND_VOL_C_MAX		3
196 
197 #define SND_VOL_C_BEGIN		SND_VOL_C_PCM
198 #define SND_VOL_C_END		SND_VOL_C_PCM
199 #define SND_VOL_C_STEP		2
200 
201 #define SND_VOL_C_VAL(x)	((x) + 1)
202 
203 #define SND_VOL_0DB_MIN		1
204 #define SND_VOL_0DB_MAX		100
205 
206 #define SND_VOL_0DB_MASTER	100
207 #define SND_VOL_0DB_PCM		45
208 
209 #define SND_VOL_RESOLUTION	8
210 #define SND_VOL_FLAT		(1 << SND_VOL_RESOLUTION)
211 
212 #define SND_VOL_CALC_SAMPLE(x, y)	(((x) * (y)) >> SND_VOL_RESOLUTION)
213 
214 #define SND_VOL_CALC_VAL(x, y, z)					\
215 			(((((x)[y][z] << SND_VOL_RESOLUTION) /		\
216 			 (x)[y][SND_CHN_T_VOL_0DB]) *			\
217 			 (x)[SND_VOL_C_MASTER][z]) /			\
218 			 (x)[SND_VOL_C_MASTER][SND_CHN_T_VOL_0DB])	\
219 
220 /*
221  * Standard matrix maps:
222  *
223  * struct pcmchan_matrix {
224  * 	.id = Matrix identity (see matrix.h). Custom defined should use
225  * 	      one of SND_CHN_MATRIX_MISC (for whatever purposes) or
226  * 	      SND_CHN_MATRIX_DRV (hardware driver).
227  * 	.channels = Total number of channels, including whatever 'extended'
228  * 		    (the X.ext notions, mostly LFE).
229  * 	.ext = Total number of extended channels (LFE).
230  * 	.map = {
231  * 		Sequences of channel type and interleave structure.
232  * 		[interleave offset] = {
233  * 			.type = channel type (see matrix.h).
234  * 			.members = Masks of channels that is acceptable as a
235  * 				   member of this channel type.
236  * 		},
237  * 		[total channels] = {
238  * 			.type = Maximum channels marker (SND_CHN_T_MAX).
239  * 			.members = 0 (no channels allowed here).
240  * 		},
241  * 	},
242  * 	.mask = Mask of channels that exist in this map.
243  * 	.offset = {
244  * 		channel offset that directly translate to the above interleave
245  * 		offset according to SND_CHN_T_* definitions.
246  * 	}
247  * };
248  *
249  * Rule of thumb: Avoid using SND_CHN_T_* that is marked with XXX (matrix.h),
250  *                or be prepared for the horror to come.
251  *
252  */
253 
254 #define SND_CHN_MATRIX_MAP_1_0	{					\
255 	.id = SND_CHN_MATRIX_1_0,					\
256 	.channels = 1,							\
257 	.ext = 0,							\
258 	.map = {							\
259 		/* Mono, center, etc. */				\
260 		[0] = {							\
261 			.type = SND_CHN_T_FL,				\
262 			.members =					\
263 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |	\
264 			    SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF |	\
265 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |	\
266 			    SND_CHN_T_MASK_BC | SND_CHN_T_MASK_SL |	\
267 			    SND_CHN_T_MASK_SR				\
268 		},							\
269 		[1] = {							\
270 			.type = SND_CHN_T_MAX,				\
271 			.members = 0					\
272 		}							\
273 	},								\
274 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
275 		SND_CHN_T_MASK_FC,					\
276 	.offset = {  0,  0,  0,  0,  0,  0, -1, -1,  0,			\
277 		     0,  0, -1, -1, -1, -1, -1, -1, -1  }		\
278 }
279 
280 #define SND_CHN_MATRIX_MAP_2_0	{					\
281 	.id = SND_CHN_MATRIX_2_0,					\
282 	.channels = 2,							\
283 	.ext = 0,							\
284 	.map = {							\
285 		/* Left */						\
286 		[0] = {							\
287 			.type = SND_CHN_T_FL,				\
288 			.members =					\
289 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FC |	\
290 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BL |	\
291 			    SND_CHN_T_MASK_BC | SND_CHN_T_MASK_SL	\
292 		},							\
293 		/* Right */						\
294 		[1] = {							\
295 			.type = SND_CHN_T_FR,				\
296 			.members =					\
297 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_FC |	\
298 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BR |	\
299 			    SND_CHN_T_MASK_BC | SND_CHN_T_MASK_SR	\
300 		},							\
301 		[2] = {							\
302 			.type = SND_CHN_T_MAX,				\
303 			.members = 0					\
304 		}							\
305 	},								\
306 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR,			\
307 	.offset = {  0,  1, -1, -1, -1, -1, -1, -1, -1,			\
308 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
309 }
310 
311 #define SND_CHN_MATRIX_MAP_2_1	{					\
312 	.id = SND_CHN_MATRIX_2_1,					\
313 	.channels = 3,							\
314 	.ext = 1,							\
315 	.map = {							\
316 		/* Left */						\
317 		[0] = {							\
318 			.type = SND_CHN_T_FL,				\
319 			.members =					\
320 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FC |	\
321 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BC |	\
322 			    SND_CHN_T_MASK_SL				\
323 		},							\
324 		/* Right */						\
325 		[1] = {							\
326 			.type = SND_CHN_T_FR,				\
327 			.members =					\
328 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_FC |	\
329 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_BC |	\
330 			    SND_CHN_T_MASK_SR				\
331 		},							\
332 		/* LFE */						\
333 		[2] = {							\
334 			.type = SND_CHN_T_LF,				\
335 			.members = SND_CHN_T_MASK_LF			\
336 		},							\
337 		[3] = {							\
338 			.type = SND_CHN_T_MAX,				\
339 			.members = 0					\
340 		}							\
341 	},								\
342 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
343 		SND_CHN_T_MASK_LF,					\
344 	.offset = {  0,  1, -1,  2, -1, -1, -1, -1, -1,			\
345 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
346 }
347 
348 #define SND_CHN_MATRIX_MAP_3_0	{	/* 3 channels default */	\
349 	.id = SND_CHN_MATRIX_3_0,					\
350 	.channels = 3,							\
351 	.ext = 0,							\
352 	.map = {							\
353 		/* Left */						\
354 		[0] = {							\
355 			.type = SND_CHN_T_FL,				\
356 			.members =					\
357 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FC |	\
358 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_SL	\
359 		},							\
360 		/* Right */						\
361 		[1] = {							\
362 			.type = SND_CHN_T_FR,				\
363 			.members =					\
364 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_FC |	\
365 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_SR	\
366 		},							\
367 		/* Rear Center */					\
368 		[2] = {							\
369 			.type = SND_CHN_T_BC,				\
370 			.members =					\
371 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BL |	\
372 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_BC |	\
373 			    SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR	\
374 		},							\
375 		[3] = {							\
376 			.type = SND_CHN_T_MAX,				\
377 			.members = 0					\
378 		}							\
379 	},								\
380 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
381 		SND_CHN_T_MASK_BC,					\
382 	.offset = {  0,  1, -1, -1, -1, -1, -1, -1,  2,			\
383 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
384 }
385 
386 #define SND_CHN_MATRIX_MAP_3_1	{					\
387 	.id = SND_CHN_MATRIX_3_1,					\
388 	.channels = 4,							\
389 	.ext = 1,							\
390 	.map = {							\
391 		/* Left */						\
392 		[0] = {							\
393 			.type = SND_CHN_T_FL,				\
394 			.members =					\
395 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FC |	\
396 			    SND_CHN_T_MASK_SL				\
397 		},							\
398 		/* Right */						\
399 		[1] = {							\
400 			.type = SND_CHN_T_FR,				\
401 			.members =					\
402 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_FC |	\
403 			    SND_CHN_T_MASK_SR				\
404 		},							\
405 		/* LFE */						\
406 		[2] = {							\
407 			.type = SND_CHN_T_LF,				\
408 			.members = SND_CHN_T_MASK_LF			\
409 		},							\
410 		/* Rear Center */					\
411 		[3] = {							\
412 			.type = SND_CHN_T_BC,				\
413 			.members =					\
414 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |	\
415 			    SND_CHN_T_MASK_BC |				\
416 			    SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR	\
417 		},							\
418 		[4] = {							\
419 			.type = SND_CHN_T_MAX,				\
420 			.members = 0					\
421 		}							\
422 	},								\
423 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
424 		SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BC,			\
425 	.offset = {  0,  1, -1,  2, -1, -1, -1, -1,  3,			\
426 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
427 }
428 
429 #define SND_CHN_MATRIX_MAP_4_0	{					\
430 	.id = SND_CHN_MATRIX_4_0,					\
431 	.channels = 4,							\
432 	.ext = 0,							\
433 	.map = {							\
434 		/* Left */						\
435 		[0] = {							\
436 			.type = SND_CHN_T_FL,				\
437 			.members =					\
438 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FC |	\
439 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_SL	\
440 		},							\
441 		/* Right */						\
442 		[1] = {							\
443 			.type = SND_CHN_T_FR,				\
444 			.members =					\
445 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_FC |	\
446 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_SR	\
447 		},							\
448 		/* Rear Left */						\
449 		[2] = {							\
450 			.type = SND_CHN_T_BL,				\
451 			.members =					\
452 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BL |	\
453 			    SND_CHN_T_MASK_BC | SND_CHN_T_MASK_SL	\
454 		},							\
455 		/* Rear Right */					\
456 		[3] = {							\
457 			.type = SND_CHN_T_BR,				\
458 			.members =					\
459 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BR |	\
460 			    SND_CHN_T_MASK_BC | SND_CHN_T_MASK_SR	\
461 		},							\
462 		[4] = {							\
463 			.type = SND_CHN_T_MAX,				\
464 			.members = 0					\
465 		}							\
466 	},								\
467 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
468 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR,			\
469 	.offset = {  0,  1, -1, -1,  2,  3, -1, -1, -1,			\
470 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
471 }
472 
473 #define SND_CHN_MATRIX_MAP_4_1	{					\
474 	.id = SND_CHN_MATRIX_4_1,					\
475 	.channels = 5,							\
476 	.ext = 1,							\
477 	.map = {							\
478 		/* Left */						\
479 		[0] = {							\
480 			.type = SND_CHN_T_FL,				\
481 			.members =					\
482 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FC |	\
483 			    SND_CHN_T_MASK_SL				\
484 		},							\
485 		/* Right */						\
486 		[1] = {							\
487 			.type = SND_CHN_T_FR,				\
488 			.members =					\
489 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_FC |	\
490 			    SND_CHN_T_MASK_SR				\
491 		},							\
492 		/* Rear Left */						\
493 		[2] = {							\
494 			.type = SND_CHN_T_BL,				\
495 			.members =					\
496 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BC |	\
497 			    SND_CHN_T_MASK_SL				\
498 		},							\
499 		/* Rear Right */					\
500 		[3] = {							\
501 			.type = SND_CHN_T_BR,				\
502 			.members =					\
503 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_BC |	\
504 			    SND_CHN_T_MASK_SR				\
505 		},							\
506 		/* LFE */						\
507 		[4] = {							\
508 			.type = SND_CHN_T_LF,				\
509 			.members = SND_CHN_T_MASK_LF			\
510 		},							\
511 		[5] = {							\
512 			.type = SND_CHN_T_MAX,				\
513 			.members = 0					\
514 		}							\
515 	},								\
516 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
517 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
518 		SND_CHN_T_MASK_LF,					\
519 	.offset = {  0,  1, -1,  4,  2,  3, -1, -1, -1,			\
520 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
521 }
522 
523 #define SND_CHN_MATRIX_MAP_5_0	{	/* 5 channels default */	\
524 	.id = SND_CHN_MATRIX_5_0,					\
525 	.channels = 5,							\
526 	.ext = 0,							\
527 	.map = {							\
528 		/* Left */						\
529 		[0] = {							\
530 			.type = SND_CHN_T_FL,				\
531 			.members =					\
532 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_LF |	\
533 			    SND_CHN_T_MASK_SL				\
534 		},							\
535 		/* Right */						\
536 		[1] = {							\
537 			.type = SND_CHN_T_FR,				\
538 			.members =					\
539 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_LF |	\
540 			    SND_CHN_T_MASK_SR				\
541 		},							\
542 		/* Rear Left */						\
543 		[2] = {							\
544 			.type = SND_CHN_T_BL,				\
545 			.members =					\
546 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BL |	\
547 			    SND_CHN_T_MASK_BC | SND_CHN_T_MASK_SL	\
548 		},							\
549 		/* Rear Right */					\
550 		[3] = {							\
551 			.type = SND_CHN_T_BR,				\
552 			.members =					\
553 			    SND_CHN_T_MASK_LF | SND_CHN_T_MASK_BR |	\
554 			    SND_CHN_T_MASK_BC | SND_CHN_T_MASK_SR	\
555 		},							\
556 		/* Center */						\
557 		[4] = {							\
558 			.type = SND_CHN_T_FC,				\
559 			.members = SND_CHN_T_MASK_FC			\
560 		},							\
561 		[5] = {							\
562 			.type = SND_CHN_T_MAX,				\
563 			.members = 0					\
564 		}							\
565 	},								\
566 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
567 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
568 		SND_CHN_T_MASK_FC,					\
569 	.offset = {  0,  1,  4, -1,  2,  3, -1, -1, -1,			\
570 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
571 }
572 
573 #define SND_CHN_MATRIX_MAP_5_1	{	/* 6 channels default */	\
574 	.id = SND_CHN_MATRIX_5_1,					\
575 	.channels = 6,							\
576 	.ext = 1,							\
577 	.map = {							\
578 		/* Left */						\
579 		[0] = {							\
580 			.type = SND_CHN_T_FL,				\
581 			.members =					\
582 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_SL	\
583 		},							\
584 		/* Right */						\
585 		[1] = {							\
586 			.type = SND_CHN_T_FR,				\
587 			.members =					\
588 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_SR	\
589 		},							\
590 		/* Rear Left */						\
591 		[2] = {							\
592 			.type = SND_CHN_T_BL,				\
593 			.members =					\
594 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BC |	\
595 			    SND_CHN_T_MASK_SL				\
596 		},							\
597 		/* Rear Right */					\
598 		[3] = {							\
599 			.type = SND_CHN_T_BR,				\
600 			.members =					\
601 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_BC |	\
602 			    SND_CHN_T_MASK_SR				\
603 		},							\
604 		/* Center */						\
605 		[4] = {							\
606 			.type = SND_CHN_T_FC,				\
607 			.members = SND_CHN_T_MASK_FC			\
608 		},							\
609 		/* LFE */						\
610 		[5] = {							\
611 			.type = SND_CHN_T_LF,				\
612 			.members = SND_CHN_T_MASK_LF			\
613 		},							\
614 		[6] = {							\
615 			.type = SND_CHN_T_MAX,				\
616 			.members = 0					\
617 		}							\
618 	},								\
619 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
620 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
621 		SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF,			\
622 	.offset = {  0,  1,  4,  5,  2,  3, -1, -1, -1,			\
623 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
624 }
625 
626 #define SND_CHN_MATRIX_MAP_6_0	{					\
627 	.id = SND_CHN_MATRIX_6_0,					\
628 	.channels = 6,							\
629 	.ext = 0,							\
630 	.map  = {							\
631 		/* Left */						\
632 		[0] = {							\
633 			.type = SND_CHN_T_FL,				\
634 			.members =					\
635 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_LF |	\
636 			    SND_CHN_T_MASK_SL				\
637 		},							\
638 		/* Right */						\
639 		[1] = {							\
640 			.type = SND_CHN_T_FR,				\
641 			.members =					\
642 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_LF |	\
643 			    SND_CHN_T_MASK_SR				\
644 		},							\
645 		/* Rear Left */						\
646 		[2] = {							\
647 			.type = SND_CHN_T_BL,				\
648 			.members =					\
649 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_LF |	\
650 			    SND_CHN_T_MASK_SL				\
651 		},							\
652 		/* Rear Right */					\
653 		[3] = {							\
654 			.type = SND_CHN_T_BR,				\
655 			.members =					\
656 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_LF |	\
657 			    SND_CHN_T_MASK_SR				\
658 		},							\
659 		/* Center */						\
660 		[4] = {							\
661 			.type = SND_CHN_T_FC,				\
662 			.members = SND_CHN_T_MASK_FC			\
663 		},							\
664 		/* Rear Center */					\
665 		[5] = {							\
666 			.type = SND_CHN_T_BC,				\
667 			.members = SND_CHN_T_MASK_BC			\
668 		},							\
669 		[6] = {							\
670 			.type = SND_CHN_T_MAX,				\
671 			.members = 0					\
672 		}							\
673 	},								\
674 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
675 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
676 		SND_CHN_T_MASK_FC | SND_CHN_T_MASK_BC,			\
677 	.offset = {  0,  1,  4, -1,  2,  3, -1, -1,  5,			\
678 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
679 }
680 
681 #define SND_CHN_MATRIX_MAP_6_1	{					\
682 	.id = SND_CHN_MATRIX_6_1,					\
683 	.channels = 7,							\
684 	.ext = 1,							\
685 	.map = {							\
686 		/* Left */						\
687 		[0] = {							\
688 			.type = SND_CHN_T_FL,				\
689 			.members =					\
690 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_SL	\
691 		},							\
692 		/* Right */						\
693 		[1] = {							\
694 			.type = SND_CHN_T_FR,				\
695 			.members =					\
696 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_SR	\
697 		},							\
698 		/* Rear Left */						\
699 		[2] = {							\
700 			.type = SND_CHN_T_BL,				\
701 			.members =					\
702 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_SL	\
703 		},							\
704 		/* Rear Right */					\
705 		[3] = {							\
706 			.type = SND_CHN_T_BR,				\
707 			.members =					\
708 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_SR	\
709 		},							\
710 		/* Center */						\
711 		[4] = {							\
712 			.type = SND_CHN_T_FC,				\
713 			.members = SND_CHN_T_MASK_FC			\
714 		},							\
715 		/* LFE */						\
716 		[5] = {							\
717 			.type = SND_CHN_T_LF,				\
718 			.members = SND_CHN_T_MASK_LF			\
719 		},							\
720 		/* Rear Center */					\
721 		[6] = {							\
722 			.type = SND_CHN_T_BC,				\
723 			.members = SND_CHN_T_MASK_BC			\
724 		},							\
725 		[7] = {							\
726 			.type = SND_CHN_T_MAX,				\
727 			.members = 0					\
728 		}							\
729 	},								\
730 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
731 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
732 		SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF |			\
733 		SND_CHN_T_MASK_BC,					\
734 	.offset = {  0,  1,  4,  5,  2,  3, -1, -1,  6,			\
735 		    -1, -1, -1, -1, -1, -1, -1, -1, -1  }		\
736 }
737 
738 #define SND_CHN_MATRIX_MAP_7_0	{					\
739 	.id = SND_CHN_MATRIX_7_0,					\
740 	.channels = 7,							\
741 	.ext = 0,							\
742 	.map = {							\
743 		/* Left */						\
744 		[0] = {							\
745 			.type = SND_CHN_T_FL,				\
746 			.members =					\
747 			    SND_CHN_T_MASK_FL | SND_CHN_T_MASK_LF	\
748 		},							\
749 		/* Right */						\
750 		[1] = {							\
751 			.type = SND_CHN_T_FR,				\
752 			.members =					\
753 			    SND_CHN_T_MASK_FR | SND_CHN_T_MASK_LF	\
754 		},							\
755 		/* Rear Left */						\
756 		[2] = {							\
757 			.type = SND_CHN_T_BL,				\
758 			.members =					\
759 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BC |	\
760 			    SND_CHN_T_MASK_LF				\
761 		},							\
762 		/* Rear Right */					\
763 		[3] = {							\
764 			.type = SND_CHN_T_BR,				\
765 			.members =					\
766 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_BC |	\
767 			    SND_CHN_T_MASK_LF				\
768 		},							\
769 		/* Center */						\
770 		[4] = {							\
771 			.type = SND_CHN_T_FC,				\
772 			.members =					\
773 			    SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF	\
774 		},							\
775 		/* Side Left */						\
776 		[5] = {							\
777 			.type = SND_CHN_T_SL,				\
778 			.members =					\
779 			    SND_CHN_T_MASK_SL | SND_CHN_T_MASK_LF	\
780 		},							\
781 		/* Side Right */					\
782 		[6] = {							\
783 			.type = SND_CHN_T_SR,				\
784 			.members =					\
785 			    SND_CHN_T_MASK_SR | SND_CHN_T_MASK_LF	\
786 		},							\
787 		[7] = {							\
788 			.type = SND_CHN_T_MAX,				\
789 			.members = 0					\
790 		}							\
791 	},								\
792 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
793 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
794 		SND_CHN_T_MASK_FC |					\
795 		SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR,			\
796 	.offset = {  0,  1,  4, -1,  2,  3, -1, -1, -1,			\
797 		     5,  6, -1, -1, -1, -1, -1, -1, -1  }		\
798 }
799 
800 #define SND_CHN_MATRIX_MAP_7_1	{					\
801 	.id = SND_CHN_MATRIX_7_1,					\
802 	.channels = 8,							\
803 	.ext = 1,							\
804 	.map = {							\
805 		/* Left */						\
806 		[0] = {							\
807 			.type = SND_CHN_T_FL,				\
808 			.members = SND_CHN_T_MASK_FL			\
809 		},							\
810 		/* Right */						\
811 		[1] = {							\
812 			.type = SND_CHN_T_FR,				\
813 			.members = SND_CHN_T_MASK_FR			\
814 		},							\
815 		/* Rear Left */						\
816 		[2] = {							\
817 			.type = SND_CHN_T_BL,				\
818 			.members =					\
819 			    SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BC	\
820 		},							\
821 		/* Rear Right */					\
822 		[3] = {							\
823 			.type = SND_CHN_T_BR,				\
824 			.members =					\
825 			    SND_CHN_T_MASK_BR | SND_CHN_T_MASK_BC	\
826 		},							\
827 		/* Center */						\
828 		[4] = {							\
829 			.type = SND_CHN_T_FC,				\
830 			.members = SND_CHN_T_MASK_FC			\
831 		},							\
832 		/* LFE */						\
833 		[5] = {							\
834 			.type = SND_CHN_T_LF,				\
835 			.members = SND_CHN_T_MASK_LF			\
836 		},							\
837 		/* Side Left */						\
838 		[6] = {							\
839 			.type = SND_CHN_T_SL,				\
840 			.members = SND_CHN_T_MASK_SL			\
841 		},							\
842 		/* Side Right */					\
843 		[7] = {							\
844 			.type = SND_CHN_T_SR,				\
845 			.members = SND_CHN_T_MASK_SR			\
846 		},							\
847 		[8] = {							\
848 			.type = SND_CHN_T_MAX,				\
849 			.members = 0					\
850 		}							\
851 	},								\
852 	.mask = SND_CHN_T_MASK_FL | SND_CHN_T_MASK_FR |			\
853 		SND_CHN_T_MASK_BL | SND_CHN_T_MASK_BR |			\
854 		SND_CHN_T_MASK_FC | SND_CHN_T_MASK_LF |			\
855 		SND_CHN_T_MASK_SL | SND_CHN_T_MASK_SR,			\
856 	.offset = {  0,  1,  4,  5,  2,  3, -1, -1, -1,			\
857 		     6,  7, -1, -1, -1, -1, -1, -1, -1  }		\
858 }
859 
860 #endif	/* !_SND_MATRIX_H_ */
861