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/atari/atasound.c |
Linux-2.6.12-rc2v2.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/atari/atasound.c')
-rw-r--r-- | arch/m68k/atari/atasound.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/arch/m68k/atari/atasound.c b/arch/m68k/atari/atasound.c new file mode 100644 index 000000000000..ee04250eb56b --- /dev/null +++ b/arch/m68k/atari/atasound.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | * linux/arch/m68k/atari/atasound.c | ||
3 | * | ||
4 | * ++Geert: Moved almost all stuff to linux/drivers/sound/ | ||
5 | * | ||
6 | * The author of atari_nosound, atari_mksound and atari_microwire_cmd is | ||
7 | * unknown. (++roman: That's me... :-) | ||
8 | * | ||
9 | * This file is subject to the terms and conditions of the GNU General Public | ||
10 | * License. See the file COPYING in the main directory of this archive | ||
11 | * for more details. | ||
12 | * | ||
13 | * 1998-05-31 ++andreas: atari_mksound rewritten to always use the envelope, | ||
14 | * no timer, atari_nosound removed. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | |||
19 | #include <linux/sched.h> | ||
20 | #include <linux/timer.h> | ||
21 | #include <linux/major.h> | ||
22 | #include <linux/fcntl.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/mm.h> | ||
25 | |||
26 | #include <asm/atarihw.h> | ||
27 | #include <asm/system.h> | ||
28 | #include <asm/irq.h> | ||
29 | #include <asm/pgtable.h> | ||
30 | #include <asm/atariints.h> | ||
31 | |||
32 | |||
33 | /* | ||
34 | * stuff from the old atasound.c | ||
35 | */ | ||
36 | |||
37 | void atari_microwire_cmd (int cmd) | ||
38 | { | ||
39 | tt_microwire.mask = 0x7ff; | ||
40 | tt_microwire.data = MW_LM1992_ADDR | cmd; | ||
41 | |||
42 | /* Busy wait for data being completely sent :-( */ | ||
43 | while( tt_microwire.mask != 0x7ff) | ||
44 | ; | ||
45 | } | ||
46 | |||
47 | |||
48 | /* PSG base frequency */ | ||
49 | #define PSG_FREQ 125000 | ||
50 | /* PSG envelope base frequency times 10 */ | ||
51 | #define PSG_ENV_FREQ_10 78125 | ||
52 | |||
53 | void atari_mksound (unsigned int hz, unsigned int ticks) | ||
54 | { | ||
55 | /* Generates sound of some frequency for some number of clock | ||
56 | ticks. */ | ||
57 | unsigned long flags; | ||
58 | unsigned char tmp; | ||
59 | int period; | ||
60 | |||
61 | local_irq_save(flags); | ||
62 | |||
63 | |||
64 | /* Disable generator A in mixer control. */ | ||
65 | sound_ym.rd_data_reg_sel = 7; | ||
66 | tmp = sound_ym.rd_data_reg_sel; | ||
67 | tmp |= 011; | ||
68 | sound_ym.wd_data = tmp; | ||
69 | |||
70 | if (hz) { | ||
71 | /* Convert from frequency value to PSG period value (base | ||
72 | frequency 125 kHz). */ | ||
73 | |||
74 | period = PSG_FREQ / hz; | ||
75 | |||
76 | if (period > 0xfff) period = 0xfff; | ||
77 | |||
78 | /* Set generator A frequency to hz. */ | ||
79 | sound_ym.rd_data_reg_sel = 0; | ||
80 | sound_ym.wd_data = period & 0xff; | ||
81 | sound_ym.rd_data_reg_sel = 1; | ||
82 | sound_ym.wd_data = (period >> 8) & 0xf; | ||
83 | if (ticks) { | ||
84 | /* Set length of envelope (max 8 sec). */ | ||
85 | int length = (ticks * PSG_ENV_FREQ_10) / HZ / 10; | ||
86 | |||
87 | if (length > 0xffff) length = 0xffff; | ||
88 | sound_ym.rd_data_reg_sel = 11; | ||
89 | sound_ym.wd_data = length & 0xff; | ||
90 | sound_ym.rd_data_reg_sel = 12; | ||
91 | sound_ym.wd_data = length >> 8; | ||
92 | /* Envelope form: max -> min single. */ | ||
93 | sound_ym.rd_data_reg_sel = 13; | ||
94 | sound_ym.wd_data = 0; | ||
95 | /* Use envelope for generator A. */ | ||
96 | sound_ym.rd_data_reg_sel = 8; | ||
97 | sound_ym.wd_data = 0x10; | ||
98 | } else { | ||
99 | /* Set generator A level to maximum, no envelope. */ | ||
100 | sound_ym.rd_data_reg_sel = 8; | ||
101 | sound_ym.wd_data = 15; | ||
102 | } | ||
103 | /* Turn on generator A in mixer control. */ | ||
104 | sound_ym.rd_data_reg_sel = 7; | ||
105 | tmp &= ~1; | ||
106 | sound_ym.wd_data = tmp; | ||
107 | } | ||
108 | local_irq_restore(flags); | ||
109 | } | ||