1 /*
2  *  linux/drivers/sound/dmasound/trans_16.c
3  *
4  *  16 bit translation routines.  Only used by Power mac at present.
5  *
6  *  See linux/drivers/sound/dmasound/dmasound_core.c for copyright and
7  *  history prior to 08/02/2001.
8  *
9  *  08/02/2001 Iain Sandoe
10  *		split from dmasound_awacs.c
11  */
12 
13 #include <linux/soundcard.h>
14 #include <asm/uaccess.h>
15 #include "dmasound.h"
16 
17 static short dmasound_alaw2dma16[] ;
18 static short dmasound_ulaw2dma16[] ;
19 
20 static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount,
21 			   u_char frame[], ssize_t *frameUsed,
22 			   ssize_t frameLeft);
23 static ssize_t pmac_ct_s8(const u_char *userPtr, size_t userCount,
24 			  u_char frame[], ssize_t *frameUsed,
25 			  ssize_t frameLeft);
26 static ssize_t pmac_ct_u8(const u_char *userPtr, size_t userCount,
27 			  u_char frame[], ssize_t *frameUsed,
28 			  ssize_t frameLeft);
29 static ssize_t pmac_ct_s16(const u_char *userPtr, size_t userCount,
30 			   u_char frame[], ssize_t *frameUsed,
31 			   ssize_t frameLeft);
32 static ssize_t pmac_ct_u16(const u_char *userPtr, size_t userCount,
33 			   u_char frame[], ssize_t *frameUsed,
34 			   ssize_t frameLeft);
35 
36 static ssize_t pmac_ctx_law(const u_char *userPtr, size_t userCount,
37 			    u_char frame[], ssize_t *frameUsed,
38 			    ssize_t frameLeft);
39 static ssize_t pmac_ctx_s8(const u_char *userPtr, size_t userCount,
40 			   u_char frame[], ssize_t *frameUsed,
41 			   ssize_t frameLeft);
42 static ssize_t pmac_ctx_u8(const u_char *userPtr, size_t userCount,
43 			   u_char frame[], ssize_t *frameUsed,
44 			   ssize_t frameLeft);
45 static ssize_t pmac_ctx_s16(const u_char *userPtr, size_t userCount,
46 			    u_char frame[], ssize_t *frameUsed,
47 			    ssize_t frameLeft);
48 static ssize_t pmac_ctx_u16(const u_char *userPtr, size_t userCount,
49 			    u_char frame[], ssize_t *frameUsed,
50 			    ssize_t frameLeft);
51 
52 static ssize_t pmac_ct_s16_read(const u_char *userPtr, size_t userCount,
53 			   u_char frame[], ssize_t *frameUsed,
54 			   ssize_t frameLeft);
55 static ssize_t pmac_ct_u16_read(const u_char *userPtr, size_t userCount,
56 			   u_char frame[], ssize_t *frameUsed,
57 			   ssize_t frameLeft);
58 
59 /*** Translations ************************************************************/
60 
61 extern int expand_bal;	/* Balance factor for expanding (not volume!) */
62 static int expand_data;	/* Data for expanding */
63 
pmac_ct_law(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)64 static ssize_t pmac_ct_law(const u_char *userPtr, size_t userCount,
65 			   u_char frame[], ssize_t *frameUsed,
66 			   ssize_t frameLeft)
67 {
68 	short *table = dmasound.soft.format == AFMT_MU_LAW
69 		? dmasound_ulaw2dma16 : dmasound_alaw2dma16;
70 	ssize_t count, used;
71 	short *p = (short *) &frame[*frameUsed];
72 	int val, stereo = dmasound.soft.stereo;
73 
74 	frameLeft >>= 2;
75 	if (stereo)
76 		userCount >>= 1;
77 	used = count = min_t(unsigned long, userCount, frameLeft);
78 	while (count > 0) {
79 		u_char data;
80 		if (get_user(data, userPtr++))
81 			return -EFAULT;
82 		val = table[data];
83 		*p++ = val;
84 		if (stereo) {
85 			if (get_user(data, userPtr++))
86 				return -EFAULT;
87 			val = table[data];
88 		}
89 		*p++ = val;
90 		count--;
91 	}
92 	*frameUsed += used * 4;
93 	return stereo? used * 2: used;
94 }
95 
96 
pmac_ct_s8(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)97 static ssize_t pmac_ct_s8(const u_char *userPtr, size_t userCount,
98 			  u_char frame[], ssize_t *frameUsed,
99 			  ssize_t frameLeft)
100 {
101 	ssize_t count, used;
102 	short *p = (short *) &frame[*frameUsed];
103 	int val, stereo = dmasound.soft.stereo;
104 
105 	frameLeft >>= 2;
106 	if (stereo)
107 		userCount >>= 1;
108 	used = count = min_t(unsigned long, userCount, frameLeft);
109 	while (count > 0) {
110 		u_char data;
111 		if (get_user(data, userPtr++))
112 			return -EFAULT;
113 		val = data << 8;
114 		*p++ = val;
115 		if (stereo) {
116 			if (get_user(data, userPtr++))
117 				return -EFAULT;
118 			val = data << 8;
119 		}
120 		*p++ = val;
121 		count--;
122 	}
123 	*frameUsed += used * 4;
124 	return stereo? used * 2: used;
125 }
126 
127 
pmac_ct_u8(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)128 static ssize_t pmac_ct_u8(const u_char *userPtr, size_t userCount,
129 			  u_char frame[], ssize_t *frameUsed,
130 			  ssize_t frameLeft)
131 {
132 	ssize_t count, used;
133 	short *p = (short *) &frame[*frameUsed];
134 	int val, stereo = dmasound.soft.stereo;
135 
136 	frameLeft >>= 2;
137 	if (stereo)
138 		userCount >>= 1;
139 	used = count = min_t(unsigned long, userCount, frameLeft);
140 	while (count > 0) {
141 		u_char data;
142 		if (get_user(data, userPtr++))
143 			return -EFAULT;
144 		val = (data ^ 0x80) << 8;
145 		*p++ = val;
146 		if (stereo) {
147 			if (get_user(data, userPtr++))
148 				return -EFAULT;
149 			val = (data ^ 0x80) << 8;
150 		}
151 		*p++ = val;
152 		count--;
153 	}
154 	*frameUsed += used * 4;
155 	return stereo? used * 2: used;
156 }
157 
158 
pmac_ct_s16(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)159 static ssize_t pmac_ct_s16(const u_char *userPtr, size_t userCount,
160 			   u_char frame[], ssize_t *frameUsed,
161 			   ssize_t frameLeft)
162 {
163 	ssize_t count, used;
164 	int stereo = dmasound.soft.stereo;
165 	short *fp = (short *) &frame[*frameUsed];
166 
167 	frameLeft >>= 2;
168 	userCount >>= (stereo? 2: 1);
169 	used = count = min_t(unsigned long, userCount, frameLeft);
170 	if (!stereo) {
171 		short *up = (short *) userPtr;
172 		while (count > 0) {
173 			short data;
174 			if (get_user(data, up++))
175 				return -EFAULT;
176 			*fp++ = data;
177 			*fp++ = data;
178 			count--;
179 		}
180 	} else {
181 		if (copy_from_user(fp, userPtr, count * 4))
182 			return -EFAULT;
183 	}
184 	*frameUsed += used * 4;
185 	return stereo? used * 4: used * 2;
186 }
187 
pmac_ct_u16(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)188 static ssize_t pmac_ct_u16(const u_char *userPtr, size_t userCount,
189 			   u_char frame[], ssize_t *frameUsed,
190 			   ssize_t frameLeft)
191 {
192 	ssize_t count, used;
193 	int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000);
194 	int stereo = dmasound.soft.stereo;
195 	short *fp = (short *) &frame[*frameUsed];
196 	short *up = (short *) userPtr;
197 
198 	frameLeft >>= 2;
199 	userCount >>= (stereo? 2: 1);
200 	used = count = min_t(unsigned long, userCount, frameLeft);
201 	while (count > 0) {
202 		short data;
203 		if (get_user(data, up++))
204 			return -EFAULT;
205 		data ^= mask;
206 		*fp++ = data;
207 		if (stereo) {
208 			if (get_user(data, up++))
209 				return -EFAULT;
210 			data ^= mask;
211 		}
212 		*fp++ = data;
213 		count--;
214 	}
215 	*frameUsed += used * 4;
216 	return stereo? used * 4: used * 2;
217 }
218 
219 
pmac_ctx_law(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)220 static ssize_t pmac_ctx_law(const u_char *userPtr, size_t userCount,
221 			    u_char frame[], ssize_t *frameUsed,
222 			    ssize_t frameLeft)
223 {
224 	unsigned short *table = (unsigned short *)
225 		(dmasound.soft.format == AFMT_MU_LAW
226 		 ? dmasound_ulaw2dma16 : dmasound_alaw2dma16);
227 	unsigned int data = expand_data;
228 	unsigned int *p = (unsigned int *) &frame[*frameUsed];
229 	int bal = expand_bal;
230 	int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
231 	int utotal, ftotal;
232 	int stereo = dmasound.soft.stereo;
233 
234 	frameLeft >>= 2;
235 	if (stereo)
236 		userCount >>= 1;
237 	ftotal = frameLeft;
238 	utotal = userCount;
239 	while (frameLeft) {
240 		u_char c;
241 		if (bal < 0) {
242 			if (userCount == 0)
243 				break;
244 			if (get_user(c, userPtr++))
245 				return -EFAULT;
246 			data = table[c];
247 			if (stereo) {
248 				if (get_user(c, userPtr++))
249 					return -EFAULT;
250 				data = (data << 16) + table[c];
251 			} else
252 				data = (data << 16) + data;
253 			userCount--;
254 			bal += hSpeed;
255 		}
256 		*p++ = data;
257 		frameLeft--;
258 		bal -= sSpeed;
259 	}
260 	expand_bal = bal;
261 	expand_data = data;
262 	*frameUsed += (ftotal - frameLeft) * 4;
263 	utotal -= userCount;
264 	return stereo? utotal * 2: utotal;
265 }
266 
pmac_ctx_s8(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)267 static ssize_t pmac_ctx_s8(const u_char *userPtr, size_t userCount,
268 			   u_char frame[], ssize_t *frameUsed,
269 			   ssize_t frameLeft)
270 {
271 	unsigned int *p = (unsigned int *) &frame[*frameUsed];
272 	unsigned int data = expand_data;
273 	int bal = expand_bal;
274 	int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
275 	int stereo = dmasound.soft.stereo;
276 	int utotal, ftotal;
277 
278 	frameLeft >>= 2;
279 	if (stereo)
280 		userCount >>= 1;
281 	ftotal = frameLeft;
282 	utotal = userCount;
283 	while (frameLeft) {
284 		u_char c;
285 		if (bal < 0) {
286 			if (userCount == 0)
287 				break;
288 			if (get_user(c, userPtr++))
289 				return -EFAULT;
290 			data = c << 8;
291 			if (stereo) {
292 				if (get_user(c, userPtr++))
293 					return -EFAULT;
294 				data = (data << 16) + (c << 8);
295 			} else
296 				data = (data << 16) + data;
297 			userCount--;
298 			bal += hSpeed;
299 		}
300 		*p++ = data;
301 		frameLeft--;
302 		bal -= sSpeed;
303 	}
304 	expand_bal = bal;
305 	expand_data = data;
306 	*frameUsed += (ftotal - frameLeft) * 4;
307 	utotal -= userCount;
308 	return stereo? utotal * 2: utotal;
309 }
310 
311 
pmac_ctx_u8(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)312 static ssize_t pmac_ctx_u8(const u_char *userPtr, size_t userCount,
313 			   u_char frame[], ssize_t *frameUsed,
314 			   ssize_t frameLeft)
315 {
316 	unsigned int *p = (unsigned int *) &frame[*frameUsed];
317 	unsigned int data = expand_data;
318 	int bal = expand_bal;
319 	int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
320 	int stereo = dmasound.soft.stereo;
321 	int utotal, ftotal;
322 
323 	frameLeft >>= 2;
324 	if (stereo)
325 		userCount >>= 1;
326 	ftotal = frameLeft;
327 	utotal = userCount;
328 	while (frameLeft) {
329 		u_char c;
330 		if (bal < 0) {
331 			if (userCount == 0)
332 				break;
333 			if (get_user(c, userPtr++))
334 				return -EFAULT;
335 			data = (c ^ 0x80) << 8;
336 			if (stereo) {
337 				if (get_user(c, userPtr++))
338 					return -EFAULT;
339 				data = (data << 16) + ((c ^ 0x80) << 8);
340 			} else
341 				data = (data << 16) + data;
342 			userCount--;
343 			bal += hSpeed;
344 		}
345 		*p++ = data;
346 		frameLeft--;
347 		bal -= sSpeed;
348 	}
349 	expand_bal = bal;
350 	expand_data = data;
351 	*frameUsed += (ftotal - frameLeft) * 4;
352 	utotal -= userCount;
353 	return stereo? utotal * 2: utotal;
354 }
355 
356 
pmac_ctx_s16(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)357 static ssize_t pmac_ctx_s16(const u_char *userPtr, size_t userCount,
358 			    u_char frame[], ssize_t *frameUsed,
359 			    ssize_t frameLeft)
360 {
361 	unsigned int *p = (unsigned int *) &frame[*frameUsed];
362 	unsigned int data = expand_data;
363 	unsigned short *up = (unsigned short *) userPtr;
364 	int bal = expand_bal;
365 	int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
366 	int stereo = dmasound.soft.stereo;
367 	int utotal, ftotal;
368 
369 	frameLeft >>= 2;
370 	userCount >>= (stereo? 2: 1);
371 	ftotal = frameLeft;
372 	utotal = userCount;
373 	while (frameLeft) {
374 		unsigned short c;
375 		if (bal < 0) {
376 			if (userCount == 0)
377 				break;
378 			if (get_user(data, up++))
379 				return -EFAULT;
380 			if (stereo) {
381 				if (get_user(c, up++))
382 					return -EFAULT;
383 				data = (data << 16) + c;
384 			} else
385 				data = (data << 16) + data;
386 			userCount--;
387 			bal += hSpeed;
388 		}
389 		*p++ = data;
390 		frameLeft--;
391 		bal -= sSpeed;
392 	}
393 	expand_bal = bal;
394 	expand_data = data;
395 	*frameUsed += (ftotal - frameLeft) * 4;
396 	utotal -= userCount;
397 	return stereo? utotal * 4: utotal * 2;
398 }
399 
400 
pmac_ctx_u16(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)401 static ssize_t pmac_ctx_u16(const u_char *userPtr, size_t userCount,
402 			    u_char frame[], ssize_t *frameUsed,
403 			    ssize_t frameLeft)
404 {
405 	int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000);
406 	unsigned int *p = (unsigned int *) &frame[*frameUsed];
407 	unsigned int data = expand_data;
408 	unsigned short *up = (unsigned short *) userPtr;
409 	int bal = expand_bal;
410 	int hSpeed = dmasound.hard.speed, sSpeed = dmasound.soft.speed;
411 	int stereo = dmasound.soft.stereo;
412 	int utotal, ftotal;
413 
414 	frameLeft >>= 2;
415 	userCount >>= (stereo? 2: 1);
416 	ftotal = frameLeft;
417 	utotal = userCount;
418 	while (frameLeft) {
419 		unsigned short c;
420 		if (bal < 0) {
421 			if (userCount == 0)
422 				break;
423 			if (get_user(data, up++))
424 				return -EFAULT;
425 			data ^= mask;
426 			if (stereo) {
427 				if (get_user(c, up++))
428 					return -EFAULT;
429 				data = (data << 16) + (c ^ mask);
430 			} else
431 				data = (data << 16) + data;
432 			userCount--;
433 			bal += hSpeed;
434 		}
435 		*p++ = data;
436 		frameLeft--;
437 		bal -= sSpeed;
438 	}
439 	expand_bal = bal;
440 	expand_data = data;
441 	*frameUsed += (ftotal - frameLeft) * 4;
442 	utotal -= userCount;
443 	return stereo? utotal * 4: utotal * 2;
444 }
445 
446 /* data in routines... */
447 
pmac_ct_s8_read(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)448 static ssize_t pmac_ct_s8_read(const u_char *userPtr, size_t userCount,
449 			  u_char frame[], ssize_t *frameUsed,
450 			  ssize_t frameLeft)
451 {
452 	ssize_t count, used;
453 	short *p = (short *) &frame[*frameUsed];
454 	int val, stereo = dmasound.soft.stereo;
455 
456 	frameLeft >>= 2;
457 	if (stereo)
458 		userCount >>= 1;
459 	used = count = min_t(unsigned long, userCount, frameLeft);
460 	while (count > 0) {
461 		u_char data;
462 
463 		val = *p++;
464 		data = val >> 8;
465 		if (put_user(data, (u_char *)userPtr++))
466 			return -EFAULT;
467 		if (stereo) {
468 			val = *p;
469 			data = val >> 8;
470 			if (put_user(data, (u_char *)userPtr++))
471 				return -EFAULT;
472 		}
473 		p++;
474 		count--;
475 	}
476 	*frameUsed += used * 4;
477 	return stereo? used * 2: used;
478 }
479 
480 
pmac_ct_u8_read(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)481 static ssize_t pmac_ct_u8_read(const u_char *userPtr, size_t userCount,
482 			  u_char frame[], ssize_t *frameUsed,
483 			  ssize_t frameLeft)
484 {
485 	ssize_t count, used;
486 	short *p = (short *) &frame[*frameUsed];
487 	int val, stereo = dmasound.soft.stereo;
488 
489 	frameLeft >>= 2;
490 	if (stereo)
491 		userCount >>= 1;
492 	used = count = min_t(unsigned long, userCount, frameLeft);
493 	while (count > 0) {
494 		u_char data;
495 
496 		val = *p++;
497 		data = (val >> 8) ^ 0x80;
498 		if (put_user(data, (u_char *)userPtr++))
499 			return -EFAULT;
500 		if (stereo) {
501 			val = *p;
502 			data = (val >> 8) ^ 0x80;
503 			if (put_user(data, (u_char *)userPtr++))
504 				return -EFAULT;
505 		}
506 		p++;
507 		count--;
508 	}
509 	*frameUsed += used * 4;
510 	return stereo? used * 2: used;
511 }
512 
pmac_ct_s16_read(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)513 static ssize_t pmac_ct_s16_read(const u_char *userPtr, size_t userCount,
514 			   u_char frame[], ssize_t *frameUsed,
515 			   ssize_t frameLeft)
516 {
517 	ssize_t count, used;
518 	int stereo = dmasound.soft.stereo;
519 	short *fp = (short *) &frame[*frameUsed];
520 
521 	frameLeft >>= 2;
522 	userCount >>= (stereo? 2: 1);
523 	used = count = min_t(unsigned long, userCount, frameLeft);
524 	if (!stereo) {
525 		short *up = (short *) userPtr;
526 		while (count > 0) {
527 			short data;
528 			data = *fp;
529 			if (put_user(data, up++))
530 				return -EFAULT;
531 			fp+=2;
532 			count--;
533 		}
534 	} else {
535 		if (copy_to_user((u_char *)userPtr, fp, count * 4))
536 			return -EFAULT;
537 	}
538 	*frameUsed += used * 4;
539 	return stereo? used * 4: used * 2;
540 }
541 
pmac_ct_u16_read(const u_char * userPtr,size_t userCount,u_char frame[],ssize_t * frameUsed,ssize_t frameLeft)542 static ssize_t pmac_ct_u16_read(const u_char *userPtr, size_t userCount,
543 			   u_char frame[], ssize_t *frameUsed,
544 			   ssize_t frameLeft)
545 {
546 	ssize_t count, used;
547 	int mask = (dmasound.soft.format == AFMT_U16_LE? 0x0080: 0x8000);
548 	int stereo = dmasound.soft.stereo;
549 	short *fp = (short *) &frame[*frameUsed];
550 	short *up = (short *) userPtr;
551 
552 	frameLeft >>= 2;
553 	userCount >>= (stereo? 2: 1);
554 	used = count = min_t(unsigned long, userCount, frameLeft);
555 	while (count > 0) {
556 		int data;
557 
558 		data = *fp++;
559 		data ^= mask;
560 		if (put_user(data, up++))
561 			return -EFAULT;
562 		if (stereo) {
563 			data = *fp;
564 			data ^= mask;
565 			if (put_user(data, up++))
566 				return -EFAULT;
567 		}
568 		fp++;
569 		count--;
570 	}
571 	*frameUsed += used * 4;
572 	return stereo? used * 4: used * 2;
573 }
574 
575 TRANS transAwacsNormal = {
576 	ct_ulaw:	pmac_ct_law,
577 	ct_alaw:	pmac_ct_law,
578 	ct_s8:		pmac_ct_s8,
579 	ct_u8:		pmac_ct_u8,
580 	ct_s16be:	pmac_ct_s16,
581 	ct_u16be:	pmac_ct_u16,
582 	ct_s16le:	pmac_ct_s16,
583 	ct_u16le:	pmac_ct_u16,
584 };
585 
586 TRANS transAwacsExpand = {
587 	ct_ulaw:	pmac_ctx_law,
588 	ct_alaw:	pmac_ctx_law,
589 	ct_s8:		pmac_ctx_s8,
590 	ct_u8:		pmac_ctx_u8,
591 	ct_s16be:	pmac_ctx_s16,
592 	ct_u16be:	pmac_ctx_u16,
593 	ct_s16le:	pmac_ctx_s16,
594 	ct_u16le:	pmac_ctx_u16,
595 };
596 
597 TRANS transAwacsNormalRead = {
598 	ct_s8:		pmac_ct_s8_read,
599 	ct_u8:		pmac_ct_u8_read,
600 	ct_s16be:	pmac_ct_s16_read,
601 	ct_u16be:	pmac_ct_u16_read,
602 	ct_s16le:	pmac_ct_s16_read,
603 	ct_u16le:	pmac_ct_u16_read,
604 };
605 
606 /* translation tables */
607 /* 16 bit mu-law */
608 
609 static short dmasound_ulaw2dma16[] = {
610 	-32124,	-31100,	-30076,	-29052,	-28028,	-27004,	-25980,	-24956,
611 	-23932,	-22908,	-21884,	-20860,	-19836,	-18812,	-17788,	-16764,
612 	-15996,	-15484,	-14972,	-14460,	-13948,	-13436,	-12924,	-12412,
613 	-11900,	-11388,	-10876,	-10364,	-9852,	-9340,	-8828,	-8316,
614 	-7932,	-7676,	-7420,	-7164,	-6908,	-6652,	-6396,	-6140,
615 	-5884,	-5628,	-5372,	-5116,	-4860,	-4604,	-4348,	-4092,
616 	-3900,	-3772,	-3644,	-3516,	-3388,	-3260,	-3132,	-3004,
617 	-2876,	-2748,	-2620,	-2492,	-2364,	-2236,	-2108,	-1980,
618 	-1884,	-1820,	-1756,	-1692,	-1628,	-1564,	-1500,	-1436,
619 	-1372,	-1308,	-1244,	-1180,	-1116,	-1052,	-988,	-924,
620 	-876,	-844,	-812,	-780,	-748,	-716,	-684,	-652,
621 	-620,	-588,	-556,	-524,	-492,	-460,	-428,	-396,
622 	-372,	-356,	-340,	-324,	-308,	-292,	-276,	-260,
623 	-244,	-228,	-212,	-196,	-180,	-164,	-148,	-132,
624 	-120,	-112,	-104,	-96,	-88,	-80,	-72,	-64,
625 	-56,	-48,	-40,	-32,	-24,	-16,	-8,	0,
626 	32124,	31100,	30076,	29052,	28028,	27004,	25980,	24956,
627 	23932,	22908,	21884,	20860,	19836,	18812,	17788,	16764,
628 	15996,	15484,	14972,	14460,	13948,	13436,	12924,	12412,
629 	11900,	11388,	10876,	10364,	9852,	9340,	8828,	8316,
630 	7932,	7676,	7420,	7164,	6908,	6652,	6396,	6140,
631 	5884,	5628,	5372,	5116,	4860,	4604,	4348,	4092,
632 	3900,	3772,	3644,	3516,	3388,	3260,	3132,	3004,
633 	2876,	2748,	2620,	2492,	2364,	2236,	2108,	1980,
634 	1884,	1820,	1756,	1692,	1628,	1564,	1500,	1436,
635 	1372,	1308,	1244,	1180,	1116,	1052,	988,	924,
636 	876,	844,	812,	780,	748,	716,	684,	652,
637 	620,	588,	556,	524,	492,	460,	428,	396,
638 	372,	356,	340,	324,	308,	292,	276,	260,
639 	244,	228,	212,	196,	180,	164,	148,	132,
640 	120,	112,	104,	96,	88,	80,	72,	64,
641 	56,	48,	40,	32,	24,	16,	8,	0,
642 };
643 
644 /* 16 bit A-law */
645 
646 static short dmasound_alaw2dma16[] = {
647 	-5504,	-5248,	-6016,	-5760,	-4480,	-4224,	-4992,	-4736,
648 	-7552,	-7296,	-8064,	-7808,	-6528,	-6272,	-7040,	-6784,
649 	-2752,	-2624,	-3008,	-2880,	-2240,	-2112,	-2496,	-2368,
650 	-3776,	-3648,	-4032,	-3904,	-3264,	-3136,	-3520,	-3392,
651 	-22016,	-20992,	-24064,	-23040,	-17920,	-16896,	-19968,	-18944,
652 	-30208,	-29184,	-32256,	-31232,	-26112,	-25088,	-28160,	-27136,
653 	-11008,	-10496,	-12032,	-11520,	-8960,	-8448,	-9984,	-9472,
654 	-15104,	-14592,	-16128,	-15616,	-13056,	-12544,	-14080,	-13568,
655 	-344,	-328,	-376,	-360,	-280,	-264,	-312,	-296,
656 	-472,	-456,	-504,	-488,	-408,	-392,	-440,	-424,
657 	-88,	-72,	-120,	-104,	-24,	-8,	-56,	-40,
658 	-216,	-200,	-248,	-232,	-152,	-136,	-184,	-168,
659 	-1376,	-1312,	-1504,	-1440,	-1120,	-1056,	-1248,	-1184,
660 	-1888,	-1824,	-2016,	-1952,	-1632,	-1568,	-1760,	-1696,
661 	-688,	-656,	-752,	-720,	-560,	-528,	-624,	-592,
662 	-944,	-912,	-1008,	-976,	-816,	-784,	-880,	-848,
663 	5504,	5248,	6016,	5760,	4480,	4224,	4992,	4736,
664 	7552,	7296,	8064,	7808,	6528,	6272,	7040,	6784,
665 	2752,	2624,	3008,	2880,	2240,	2112,	2496,	2368,
666 	3776,	3648,	4032,	3904,	3264,	3136,	3520,	3392,
667 	22016,	20992,	24064,	23040,	17920,	16896,	19968,	18944,
668 	30208,	29184,	32256,	31232,	26112,	25088,	28160,	27136,
669 	11008,	10496,	12032,	11520,	8960,	8448,	9984,	9472,
670 	15104,	14592,	16128,	15616,	13056,	12544,	14080,	13568,
671 	344,	328,	376,	360,	280,	264,	312,	296,
672 	472,	456,	504,	488,	408,	392,	440,	424,
673 	88,	72,	120,	104,	24,	8,	56,	40,
674 	216,	200,	248,	232,	152,	136,	184,	168,
675 	1376,	1312,	1504,	1440,	1120,	1056,	1248,	1184,
676 	1888,	1824,	2016,	1952,	1632,	1568,	1760,	1696,
677 	688,	656,	752,	720,	560,	528,	624,	592,
678 	944,	912,	1008,	976,	816,	784,	880,	848,
679 };
680