12 #include <linux/sched.h>
18 static int mac_asc_inited;
22 static __u8 mac_asc_wave_tab[ 0x800 ];
28 static const signed char sine_data[] = {
29 0, 39, 75, 103, 121, 127, 121, 103, 75, 39,
30 0, -39, -75, -103, -121, -127, -121, -103, -75, -39
36 static volatile __u8* mac_asc_regs = (
void* )0x50F14000;
41 static unsigned long mac_asc_samplespersec = 11050;
42 static int mac_bell_duration;
43 static unsigned long mac_bell_phase;
44 static unsigned long mac_bell_phasepersample;
49 static void mac_init_asc(
void );
50 static void mac_nosound(
unsigned long );
51 static void mac_quadra_start_bell(
unsigned int,
unsigned int,
unsigned int );
52 static void mac_quadra_ring_bell(
unsigned long );
53 static void mac_av_start_bell(
unsigned int,
unsigned int,
unsigned int );
54 static void ( *mac_special_bell )(
unsigned int,
unsigned int,
unsigned int );
65 static void mac_init_asc(
void )
83 mac_asc_regs = (
void* )0x50010000;
91 mac_special_bell = mac_quadra_start_bell;
92 mac_asc_samplespersec = 22150;
122 mac_special_bell = mac_av_start_bell;
132 mac_special_bell =
NULL;
138 mac_special_bell =
NULL;
146 for ( i = 0; i < 0x400; i++ )
148 mac_asc_wave_tab[
i ] = i / 4;
149 mac_asc_wave_tab[ i + 0x400 ] = 0xFF - i / 4;
165 __u32 cfreq = ( freq << 5 ) / 468;
169 if ( mac_special_bell ==
NULL )
175 if ( !mac_asc_inited )
178 if ( mac_special_bell )
180 mac_special_bell( freq, length, 128 );
184 if ( freq < 20 || freq > 20000 || length == 0 )
194 for ( i = 0; i < 0x800; i++ )
195 mac_asc_regs[ i ] = 0;
196 for ( i = 0; i < 0x800; i++ )
197 mac_asc_regs[ i ] = mac_asc_wave_tab[ i ];
199 for ( i = 0; i < 8; i++ )
202 mac_asc_regs[ 0x807 ] = 0;
204 mac_asc_regs[ 0x805 ] = 0;
205 mac_asc_regs[ 0x80F ] = 0;
218 static void mac_nosound(
unsigned long ignored )
226 static void mac_quadra_start_bell(
unsigned int freq,
unsigned int length,
unsigned int volume )
231 if ( mac_bell_duration > 0 )
233 mac_bell_duration +=
length;
237 mac_bell_duration =
length;
239 mac_bell_phasepersample = ( freq *
sizeof( mac_asc_wave_tab ) ) / mac_asc_samplespersec;
245 mac_asc_regs[ 0x806 ] =
volume;
248 if ( mac_asc_regs[ 0x801 ] != 1 )
251 mac_asc_regs[ 0x807 ] = 0;
253 mac_asc_regs[ 0x802 ] = 0;
255 mac_asc_regs[ 0x801 ] = 1;
256 mac_asc_regs[ 0x803 ] |= 0x80;
257 mac_asc_regs[ 0x803 ] &= 0x7F;
260 mac_sound_timer.function = mac_quadra_ring_bell;
261 mac_sound_timer.expires =
jiffies + 1;
272 static void mac_quadra_ring_bell(
unsigned long ignored )
274 int i,
count = mac_asc_samplespersec /
HZ;
288 if ( mac_bell_duration-- > 0 )
290 for ( i = 0; i <
count; i++ )
292 mac_bell_phase += mac_bell_phasepersample;
293 mac_asc_regs[ 0 ] = mac_asc_wave_tab[ mac_bell_phase & (
sizeof( mac_asc_wave_tab ) - 1 ) ];
295 mac_sound_timer.expires =
jiffies + 1;
299 mac_asc_regs[ 0x801 ] = 0;
307 static void mac_av_start_bell(
unsigned int freq,
unsigned int length,
unsigned int volume )