OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [m68k/] [atari/] [atasound.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*
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.
8
(++roman: That's me... :-)
9
 
10
This file is subject to the terms and conditions of the GNU General Public
11
License.  See the file COPYING in the main directory of this archive
12
for more details.
13
 
14
*/
15
 
16
 
17
#include <linux/sched.h>
18
#include <linux/timer.h>
19
#include <linux/major.h>
20
#include <linux/fcntl.h>
21
#include <linux/errno.h>
22
#include <linux/mm.h>
23
 
24
#include <asm/atarihw.h>
25
#include <asm/system.h>
26
#include <asm/irq.h>
27
#include <asm/pgtable.h>
28
#include <asm/atariints.h>
29
#include <asm/bootinfo.h>
30
 
31
 
32
/*
33
 * stuff from the old atasound.c
34
 */
35
 
36
 
37
static void atari_nosound (unsigned long ignored)
38
{
39
        unsigned char   tmp;
40
        unsigned long flags;
41
 
42
        /* turn off generator A in mixer control */
43
        save_flags(flags);
44
        cli();
45
        sound_ym.rd_data_reg_sel = 7;
46
        tmp = sound_ym.rd_data_reg_sel;
47
        sound_ym.wd_data = tmp | 0x39;
48
        restore_flags(flags);
49
}
50
 
51
 
52
void atari_microwire_cmd (int cmd)
53
{
54
        tt_microwire.mask = 0x7ff;
55
        tt_microwire.data = MW_LM1992_ADDR | cmd;
56
 
57
        /* Busy wait for data being completely sent :-( */
58
        while( tt_microwire.mask != 0x7ff)
59
                ;
60
}
61
 
62
 
63
#define PC_FREQ         1192180
64
#define PSG_FREQ        125000
65
 
66
 
67
void atari_mksound (unsigned int count, unsigned int ticks)
68
{
69
        static struct timer_list sound_timer = { NULL, NULL, 0, 0,
70
                                                     atari_nosound };
71
        /*
72
         * Generates sound of some count for some number of clock ticks
73
         * [count = 1193180 / frequency]
74
         */
75
        unsigned long flags;
76
        unsigned char tmp;
77
 
78
        save_flags(flags);
79
        cli();
80
 
81
        if (count == 750 && ticks == HZ/8) {
82
                /* Special case: These values are used by console.c to
83
                 * generate the console bell. They are cached here and the
84
                 * sound actually generated is somehow special: it uses the
85
                 * generator B and an envelope. No timer is needed therefore
86
                 * and the bell doesn't disturb an other ongoing sound.
87
                 */
88
 
89
                /* set envelope duration to 492 ms */
90
                sound_ym.rd_data_reg_sel = 11;
91
                sound_ym.wd_data = 0;
92
                sound_ym.rd_data_reg_sel = 12;
93
                sound_ym.wd_data = 15;
94
                /* envelope form: max -> min single */
95
                sound_ym.rd_data_reg_sel = 13;
96
                sound_ym.wd_data = 9;
97
                /* set generator B frequency to 2400 Hz */
98
                sound_ym.rd_data_reg_sel = 2;
99
                sound_ym.wd_data = 52;
100
                sound_ym.rd_data_reg_sel = 3;
101
                sound_ym.wd_data = 0;
102
                /* set volume of generator B to envelope control */
103
                sound_ym.rd_data_reg_sel = 9;
104
                sound_ym.wd_data = 0x10;
105
                /* enable generator B in the mixer control */
106
                sound_ym.rd_data_reg_sel = 7;
107
                tmp = sound_ym.rd_data_reg_sel;
108
                sound_ym.wd_data = (tmp & ~0x02) | 0x38;
109
 
110
                restore_flags(flags);
111
                return;
112
        }
113
 
114
        del_timer( &sound_timer );
115
 
116
        if (!count) {
117
                atari_nosound( 0 );
118
        }
119
        else {
120
 
121
                /* convert from PC counter value (base frequency 1.193 MHz)
122
                 * to PSG period value (base frequency 125 kHz).
123
                 */
124
                int period = (PSG_FREQ * count + PC_FREQ/2) / PC_FREQ;
125
 
126
                if (period > 0xfff) period = 0xfff;
127
 
128
                /* set generator A frequency to 0 */
129
                sound_ym.rd_data_reg_sel = 0;
130
                sound_ym.wd_data = period & 0xff;
131
                sound_ym.rd_data_reg_sel = 1;
132
                sound_ym.wd_data = (period >> 8) & 0xf;
133
                /* turn on generator A in mixer control (but not noise
134
                 * generator!) */
135
                sound_ym.rd_data_reg_sel = 7;
136
                tmp = sound_ym.rd_data_reg_sel;
137
                sound_ym.wd_data = (tmp & ~0x01) | 0x38;
138
                /* set generator A level to maximum, no envelope */
139
                sound_ym.rd_data_reg_sel = 8;
140
                sound_ym.wd_data = 15;
141
 
142
                if (ticks) {
143
                        sound_timer.expires = jiffies + ticks;
144
                        add_timer( &sound_timer );
145
                }
146
        }
147
 
148
        restore_flags(flags);
149
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.