]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * pas2_pcm.c Audio routines for PAS16 | |
3 | * | |
4 | * | |
5 | * Copyright (C) by Hannu Savolainen 1993-1997 | |
6 | * | |
7 | * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL) | |
8 | * Version 2 (June 1991). See the "COPYING" file distributed with this software | |
9 | * for more info. | |
10 | * | |
11 | * | |
12 | * Thomas Sailer : ioctl code reworked (vmalloc/vfree removed) | |
13 | * Alan Cox : Swatted a double allocation of device bug. Made a few | |
14 | * more things module options. | |
15 | * Bartlomiej Zolnierkiewicz : Added __init to pas_pcm_init() | |
16 | */ | |
17 | ||
18 | #include <linux/init.h> | |
19 | #include <linux/spinlock.h> | |
20 | #include <asm/timex.h> | |
21 | #include "sound_config.h" | |
22 | ||
23 | #include "pas2.h" | |
24 | ||
25 | #ifndef DEB | |
26 | #define DEB(WHAT) | |
27 | #endif | |
28 | ||
29 | #define PAS_PCM_INTRBITS (0x08) | |
30 | /* | |
31 | * Sample buffer timer interrupt enable | |
32 | */ | |
33 | ||
34 | #define PCM_NON 0 | |
35 | #define PCM_DAC 1 | |
36 | #define PCM_ADC 2 | |
37 | ||
38 | static unsigned long pcm_speed; /* sampling rate */ | |
39 | static unsigned char pcm_channels = 1; /* channels (1 or 2) */ | |
40 | static unsigned char pcm_bits = 8; /* bits/sample (8 or 16) */ | |
41 | static unsigned char pcm_filter; /* filter FLAG */ | |
42 | static unsigned char pcm_mode = PCM_NON; | |
43 | static unsigned long pcm_count; | |
44 | static unsigned short pcm_bitsok = 8; /* mask of OK bits */ | |
45 | static int pcm_busy; | |
46 | int pas_audiodev = -1; | |
47 | static int open_mode; | |
48 | ||
49 | extern spinlock_t pas_lock; | |
50 | ||
51 | static int pcm_set_speed(int arg) | |
52 | { | |
53 | int foo, tmp; | |
54 | unsigned long flags; | |
55 | ||
56 | if (arg == 0) | |
57 | return pcm_speed; | |
58 | ||
59 | if (arg > 44100) | |
60 | arg = 44100; | |
61 | if (arg < 5000) | |
62 | arg = 5000; | |
63 | ||
64 | if (pcm_channels & 2) | |
65 | { | |
66 | foo = ((CLOCK_TICK_RATE / 2) + (arg / 2)) / arg; | |
67 | arg = ((CLOCK_TICK_RATE / 2) + (foo / 2)) / foo; | |
68 | } | |
69 | else | |
70 | { | |
71 | foo = (CLOCK_TICK_RATE + (arg / 2)) / arg; | |
72 | arg = (CLOCK_TICK_RATE + (foo / 2)) / foo; | |
73 | } | |
74 | ||
75 | pcm_speed = arg; | |
76 | ||
77 | tmp = pas_read(0x0B8A); | |
78 | ||
79 | /* | |
80 | * Set anti-aliasing filters according to sample rate. You really *NEED* | |
81 | * to enable this feature for all normal recording unless you want to | |
82 | * experiment with aliasing effects. | |
83 | * These filters apply to the selected "recording" source. | |
84 | * I (pfw) don't know the encoding of these 5 bits. The values shown | |
85 | * come from the SDK found on ftp.uwp.edu:/pub/msdos/proaudio/. | |
86 | * | |
87 | * I cleared bit 5 of these values, since that bit controls the master | |
88 |