diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m68k/amiga/amisound.c |
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/m68k/amiga/amisound.c')
-rw-r--r-- | arch/m68k/amiga/amisound.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c new file mode 100644 index 000000000000..cb5d93630467 --- /dev/null +++ b/arch/m68k/amiga/amisound.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * linux/arch/m68k/amiga/amisound.c | ||
3 | * | ||
4 | * amiga sound driver for Linux/m68k | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/config.h> | ||
12 | #include <linux/jiffies.h> | ||
13 | #include <linux/timer.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/string.h> | ||
16 | |||
17 | #include <asm/system.h> | ||
18 | #include <asm/amigahw.h> | ||
19 | |||
20 | static unsigned short *snd_data; | ||
21 | static const signed char sine_data[] = { | ||
22 | 0, 39, 75, 103, 121, 127, 121, 103, 75, 39, | ||
23 | 0, -39, -75, -103, -121, -127, -121, -103, -75, -39 | ||
24 | }; | ||
25 | #define DATA_SIZE (sizeof(sine_data)/sizeof(sine_data[0])) | ||
26 | |||
27 | /* | ||
28 | * The minimum period for audio may be modified by the frame buffer | ||
29 | * device since it depends on htotal (for OCS/ECS/AGA) | ||
30 | */ | ||
31 | |||
32 | volatile unsigned short amiga_audio_min_period = 124; /* Default for pre-OCS */ | ||
33 | |||
34 | #define MAX_PERIOD (65535) | ||
35 | |||
36 | |||
37 | /* | ||
38 | * Current period (set by dmasound.c) | ||
39 | */ | ||
40 | |||
41 | unsigned short amiga_audio_period = MAX_PERIOD; | ||
42 | |||
43 | static unsigned long clock_constant; | ||
44 | |||
45 | void __init amiga_init_sound(void) | ||
46 | { | ||
47 | static struct resource beep_res = { .name = "Beep" }; | ||
48 | |||
49 | snd_data = amiga_chip_alloc_res(sizeof(sine_data), &beep_res); | ||
50 | if (!snd_data) { | ||
51 | printk (KERN_CRIT "amiga init_sound: failed to allocate chipmem\n"); | ||
52 | return; | ||
53 | } | ||
54 | memcpy (snd_data, sine_data, sizeof(sine_data)); | ||
55 | |||
56 | /* setup divisor */ | ||
57 | clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE; | ||
58 | |||
59 | /* without amifb, turn video off and enable high quality sound */ | ||
60 | #ifndef CONFIG_FB_AMIGA | ||
61 | amifb_video_off(); | ||
62 | #endif | ||
63 | } | ||
64 | |||
65 | static void nosound( unsigned long ignored ); | ||
66 | static struct timer_list sound_timer = TIMER_INITIALIZER(nosound, 0, 0); | ||
67 | |||
68 | void amiga_mksound( unsigned int hz, unsigned int ticks ) | ||
69 | { | ||
70 | unsigned long flags; | ||
71 | |||
72 | if (!snd_data) | ||
73 | return; | ||
74 | |||
75 | local_irq_save(flags); | ||
76 | del_timer( &sound_timer ); | ||
77 | |||
78 | if (hz > 20 && hz < 32767) { | ||
79 | unsigned long period = (clock_constant / hz); | ||
80 | |||
81 | if (period < amiga_audio_min_period) | ||
82 | period = amiga_audio_min_period; | ||
83 | if (period > MAX_PERIOD) | ||
84 | period = MAX_PERIOD; | ||
85 | |||
86 | /* setup pointer to data, period, length and volume */ | ||
87 | custom.aud[2].audlc = snd_data; | ||
88 | custom.aud[2].audlen = sizeof(sine_data)/2; | ||
89 | custom.aud[2].audper = (unsigned short)period; | ||
90 | custom.aud[2].audvol = 32; /* 50% of maxvol */ | ||
91 | |||
92 | if (ticks) { | ||
93 | sound_timer.expires = jiffies + ticks; | ||
94 | add_timer( &sound_timer ); | ||
95 | } | ||
96 | |||
97 | /* turn on DMA for audio channel 2 */ | ||
98 | custom.dmacon = DMAF_SETCLR | DMAF_AUD2; | ||
99 | |||
100 | } else | ||
101 | nosound( 0 ); | ||
102 | |||
103 | local_irq_restore(flags); | ||
104 | } | ||
105 | |||
106 | |||
107 | static void nosound( unsigned long ignored ) | ||
108 | { | ||
109 | /* turn off DMA for audio channel 2 */ | ||
110 | custom.dmacon = DMAF_AUD2; | ||
111 | /* restore period to previous value after beeping */ | ||
112 | custom.aud[2].audper = amiga_audio_period; | ||
113 | } | ||