Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *	Mac bong noise generator. Note - we ought to put a boingy noise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *	here 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *	----------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *	16.11.98:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *	rewrote some functions, added support for Enhanced ASC (Quadras)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *	after the NetBSD asc.c console bell patch by Colin Wood/Frederick Bruck
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *	Juergen Mellinger (juergen.mellinger@t-online.de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/macintosh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/mac_asc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static int mac_asc_inited;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * dumb triangular wave table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static __u8 mac_asc_wave_tab[ 0x800 ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * Alan's original sine table; needs interpolating to 0x800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * (hint: interpolate or hardwire [0 -> Pi/2[, it's symmetric)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static const signed char sine_data[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	0,  39,  75,  103,  121,  127,  121,  103,  75,  39,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	0, -39, -75, -103, -121, -127, -121, -103, -75, -39
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * where the ASC hides ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) static volatile __u8* mac_asc_regs = ( void* )0x50F14000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * sample rate; is this a good default value?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static unsigned long mac_asc_samplespersec = 11050;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static int mac_bell_duration;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static unsigned long mac_bell_phase; /* 0..2*Pi -> 0..0x800 (wavetable size) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static unsigned long mac_bell_phasepersample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * some function protos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static void mac_init_asc( void );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) static void mac_nosound(struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static void mac_quadra_start_bell( unsigned int, unsigned int, unsigned int );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static void mac_quadra_ring_bell(struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) static void mac_av_start_bell( unsigned int, unsigned int, unsigned int );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static void ( *mac_special_bell )( unsigned int, unsigned int, unsigned int );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  * our timer to start/continue/stop the bell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static DEFINE_TIMER(mac_sound_timer, mac_nosound);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * Sort of initialize the sound chip (called from mac_mksound on the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  * beep).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static void mac_init_asc( void )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 * do some machine specific initialization
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	 * BTW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	 * the NetBSD Quadra patch identifies the Enhanced Apple Sound Chip via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	 *	mac_asc_regs[ 0x800 ] & 0xF0 != 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	 * this makes no sense here, because we have to set the default sample
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	 * rate anyway if we want correct frequencies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	switch ( macintosh_config->ident )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		case MAC_MODEL_IIFX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			 * The IIfx is always special ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			mac_asc_regs = ( void* )0x50010000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 			 * not sure about how correct this list is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			 * machines with the EASC enhanced apple sound chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		case MAC_MODEL_Q630:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		case MAC_MODEL_P475:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			mac_special_bell = mac_quadra_start_bell;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			mac_asc_samplespersec = 22150;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		case MAC_MODEL_C660:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		case MAC_MODEL_Q840:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			 * The Quadra 660AV and 840AV use the "Singer" custom ASIC for sound I/O.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			 * It appears to be similar to the "AWACS" custom ASIC in the Power Mac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			 * [678]100.  Because Singer and AWACS may have a similar hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			 * interface, this would imply that the code in drivers/sound/dmasound.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			 * for AWACS could be used as a basis for Singer support.  All we have to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			 * do is figure out how to do DMA on the 660AV/840AV through the PSC and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 			 * figure out where the Singer hardware sits in memory. (I'd look in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			 * vicinity of the AWACS location in a Power Mac [678]100 first, or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			 * current location of the Apple Sound Chip--ASC--in other Macs.)  The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			 * Power Mac [678]100 info can be found in MkLinux Mach kernel sources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			 * Quoted from Apple's Tech Info Library, article number 16405:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			 *   "Among desktop Macintosh computers, only the 660AV, 840AV, and Power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			 *   Macintosh models have 16-bit audio input and output capability
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			 *   because of the AT&T DSP3210 hardware circuitry and the 16-bit Singer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			 *   codec circuitry in the AVs.  The Audio Waveform Amplifier and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			 *   Converter (AWAC) chip in the Power Macintosh performs the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 			 *   16-bit I/O functionality.  The PowerBook 500 series computers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			 *   support 16-bit stereo output, but only mono input."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			 *   Technical Information Library (TIL) article number 16405. 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			 *   https://support.apple.com/kb/TA32601
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			 * --David Kilzer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			mac_special_bell = mac_av_start_bell;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		case MAC_MODEL_Q650:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		case MAC_MODEL_Q700:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		case MAC_MODEL_Q800:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		case MAC_MODEL_Q900:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		case MAC_MODEL_Q950:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			 * Currently not implemented!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			mac_special_bell = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			 * Every switch needs a default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			mac_special_bell = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	 * init the wave table with a simple triangular wave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	 * A sine wave would sure be nicer here ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	for ( i = 0; i < 0x400; i++ )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		mac_asc_wave_tab[ i ] = i / 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		mac_asc_wave_tab[ i + 0x400 ] = 0xFF - i / 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	mac_asc_inited = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)  * Called to make noise; current single entry to the boing driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  * Does the job for simple ASC, calls other routines else.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  * XXX Fixme:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * Should be split into asc_mksound, easc_mksound, av_mksound and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * function pointer set in mac_init_asc which would be called at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * init time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  * _This_ is rather ugly ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) void mac_mksound( unsigned int freq, unsigned int length )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	__u32 cfreq = ( freq << 5 ) / 468;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if ( mac_special_bell == NULL )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		/* Do nothing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	if ( !mac_asc_inited )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		mac_init_asc();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if ( mac_special_bell )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		mac_special_bell( freq, length, 128 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	if ( freq < 20 || freq > 20000 || length == 0 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		mac_nosound( 0 );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	del_timer( &mac_sound_timer );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	for ( i = 0; i < 0x800; i++ )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		mac_asc_regs[ i ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	for ( i = 0; i < 0x800; i++ )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		mac_asc_regs[ i ] = mac_asc_wave_tab[ i ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	for ( i = 0; i < 8; i++ )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		*( __u32* )( ( __u32 )mac_asc_regs + ASC_CONTROL + 0x814 + 8 * i ) = cfreq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	mac_asc_regs[ 0x807 ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	mac_asc_regs[ ASC_VOLUME ] = 128;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	mac_asc_regs[ 0x805 ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	mac_asc_regs[ 0x80F ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	mac_asc_regs[ ASC_MODE ] = ASC_MODE_SAMPLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	mac_asc_regs[ ASC_ENABLE ] = ASC_ENABLE_SAMPLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	mac_sound_timer.expires = jiffies + length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	add_timer( &mac_sound_timer );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * regular ASC: stop whining ..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static void mac_nosound(struct timer_list *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	mac_asc_regs[ ASC_ENABLE ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  * EASC entry; init EASC, don't load wavetable, schedule 'start whining'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static void mac_quadra_start_bell( unsigned int freq, unsigned int length, unsigned int volume )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	/* if the bell is already ringing, ring longer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	if ( mac_bell_duration > 0 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		mac_bell_duration += length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	mac_bell_duration = length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	mac_bell_phase = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	mac_bell_phasepersample = ( freq * sizeof( mac_asc_wave_tab ) ) / mac_asc_samplespersec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	/* this is reasonably big for small frequencies */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	/* set the volume */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	mac_asc_regs[ 0x806 ] = volume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	/* set up the ASC registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	if ( mac_asc_regs[ 0x801 ] != 1 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		/* select mono mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		mac_asc_regs[ 0x807 ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		/* select sampled sound mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		mac_asc_regs[ 0x802 ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		/* ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		mac_asc_regs[ 0x801 ] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		mac_asc_regs[ 0x803 ] |= 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		mac_asc_regs[ 0x803 ] &= 0x7F;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	mac_sound_timer.function = mac_quadra_ring_bell;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	mac_sound_timer.expires = jiffies + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	add_timer( &mac_sound_timer );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * EASC 'start/continue whining'; I'm not sure why the above function didn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  * already load the wave table, or at least call this one...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  * This piece keeps reloading the wave table until done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static void mac_quadra_ring_bell(struct timer_list *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	int	i, count = mac_asc_samplespersec / HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	 * we neither want a sound buffer overflow nor underflow, so we need to match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	 * the number of samples per timer interrupt as exactly as possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	 * using the asc interrupt will give better results in the future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	 * ...and the possibility to use a real sample (a boingy noise, maybe...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	local_irq_save(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	del_timer( &mac_sound_timer );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	if ( mac_bell_duration-- > 0 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		for ( i = 0; i < count; i++ )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			mac_bell_phase += mac_bell_phasepersample;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 			mac_asc_regs[ 0 ] = mac_asc_wave_tab[ mac_bell_phase & ( sizeof( mac_asc_wave_tab ) - 1 ) ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		mac_sound_timer.expires = jiffies + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		add_timer( &mac_sound_timer );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		mac_asc_regs[ 0x801 ] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	local_irq_restore(flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)  * AV code - please fill in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) static void mac_av_start_bell( unsigned int freq, unsigned int length, unsigned int volume )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }