1 /* 1 /* 2 * linux/arch/m68k/amiga/amisound.c 2 * linux/arch/m68k/amiga/amisound.c 3 * 3 * 4 * amiga sound driver for Linux/m68k 4 * amiga sound driver for Linux/m68k 5 * 5 * 6 * This file is subject to the terms and condi 6 * This file is subject to the terms and conditions of the GNU General Public 7 * License. See the file COPYING in the main 7 * License. See the file COPYING in the main directory of this archive 8 * for more details. 8 * for more details. 9 */ 9 */ 10 10 11 #include <linux/jiffies.h> 11 #include <linux/jiffies.h> 12 #include <linux/timer.h> 12 #include <linux/timer.h> 13 #include <linux/init.h> 13 #include <linux/init.h> 14 #include <linux/string.h> 14 #include <linux/string.h> 15 #include <linux/module.h> 15 #include <linux/module.h> 16 16 17 #include <asm/amigahw.h> 17 #include <asm/amigahw.h> 18 18 19 #include "amiga.h" << 20 << 21 static unsigned short *snd_data; 19 static unsigned short *snd_data; 22 static const signed char sine_data[] = { 20 static const signed char sine_data[] = { 23 0, 39, 75, 103, 121, 127, 121, 21 0, 39, 75, 103, 121, 127, 121, 103, 75, 39, 24 0, -39, -75, -103, -121, -127, -121, - 22 0, -39, -75, -103, -121, -127, -121, -103, -75, -39 25 }; 23 }; 26 #define DATA_SIZE ARRAY_SIZE(sine_data) 24 #define DATA_SIZE ARRAY_SIZE(sine_data) 27 25 28 #define custom amiga_custom 26 #define custom amiga_custom 29 27 30 /* 28 /* 31 * The minimum period for audio may be mod 29 * The minimum period for audio may be modified by the frame buffer 32 * device since it depends on htotal (for 30 * device since it depends on htotal (for OCS/ECS/AGA) 33 */ 31 */ 34 32 35 volatile unsigned short amiga_audio_min_period 33 volatile unsigned short amiga_audio_min_period = 124; /* Default for pre-OCS */ 36 EXPORT_SYMBOL(amiga_audio_min_period); 34 EXPORT_SYMBOL(amiga_audio_min_period); 37 35 38 #define MAX_PERIOD (65535) 36 #define MAX_PERIOD (65535) 39 37 40 38 41 /* 39 /* 42 * Current period (set by dmasound.c) 40 * Current period (set by dmasound.c) 43 */ 41 */ 44 42 45 unsigned short amiga_audio_period = MAX_PERIOD 43 unsigned short amiga_audio_period = MAX_PERIOD; 46 EXPORT_SYMBOL(amiga_audio_period); 44 EXPORT_SYMBOL(amiga_audio_period); 47 45 48 static unsigned long clock_constant; 46 static unsigned long clock_constant; 49 47 50 void __init amiga_init_sound(void) 48 void __init amiga_init_sound(void) 51 { 49 { 52 static struct resource beep_res = { .n 50 static struct resource beep_res = { .name = "Beep" }; 53 51 54 snd_data = amiga_chip_alloc_res(sizeof 52 snd_data = amiga_chip_alloc_res(sizeof(sine_data), &beep_res); 55 if (!snd_data) { 53 if (!snd_data) { 56 pr_crit("amiga init_sound: fai 54 pr_crit("amiga init_sound: failed to allocate chipmem\n"); 57 return; 55 return; 58 } 56 } 59 memcpy (snd_data, sine_data, sizeof(si 57 memcpy (snd_data, sine_data, sizeof(sine_data)); 60 58 61 /* setup divisor */ 59 /* setup divisor */ 62 clock_constant = (amiga_colorclock+DAT 60 clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE; 63 61 64 /* without amifb, turn video off and e 62 /* without amifb, turn video off and enable high quality sound */ 65 #ifndef CONFIG_FB_AMIGA 63 #ifndef CONFIG_FB_AMIGA 66 amifb_video_off(); 64 amifb_video_off(); 67 #endif 65 #endif 68 } 66 } 69 67 70 static void nosound(struct timer_list *unused) !! 68 static void nosound( unsigned long ignored ); 71 static DEFINE_TIMER(sound_timer, nosound); !! 69 static DEFINE_TIMER(sound_timer, nosound, 0, 0); 72 70 73 void amiga_mksound( unsigned int hz, unsigned 71 void amiga_mksound( unsigned int hz, unsigned int ticks ) 74 { 72 { 75 unsigned long flags; 73 unsigned long flags; 76 74 77 if (!snd_data) 75 if (!snd_data) 78 return; 76 return; 79 77 80 local_irq_save(flags); 78 local_irq_save(flags); 81 del_timer( &sound_timer ); 79 del_timer( &sound_timer ); 82 80 83 if (hz > 20 && hz < 32767) { 81 if (hz > 20 && hz < 32767) { 84 unsigned long period = (clock_ 82 unsigned long period = (clock_constant / hz); 85 83 86 if (period < amiga_audio_min_p 84 if (period < amiga_audio_min_period) 87 period = amiga_audio_m 85 period = amiga_audio_min_period; 88 if (period > MAX_PERIOD) 86 if (period > MAX_PERIOD) 89 period = MAX_PERIOD; 87 period = MAX_PERIOD; 90 88 91 /* setup pointer to data, peri 89 /* setup pointer to data, period, length and volume */ 92 custom.aud[2].audlc = snd_data 90 custom.aud[2].audlc = snd_data; 93 custom.aud[2].audlen = sizeof( 91 custom.aud[2].audlen = sizeof(sine_data)/2; 94 custom.aud[2].audper = (unsign 92 custom.aud[2].audper = (unsigned short)period; 95 custom.aud[2].audvol = 32; /* 93 custom.aud[2].audvol = 32; /* 50% of maxvol */ 96 94 97 if (ticks) { 95 if (ticks) { 98 sound_timer.expires = 96 sound_timer.expires = jiffies + ticks; 99 add_timer( &sound_time 97 add_timer( &sound_timer ); 100 } 98 } 101 99 102 /* turn on DMA for audio chann 100 /* turn on DMA for audio channel 2 */ 103 custom.dmacon = DMAF_SETCLR | 101 custom.dmacon = DMAF_SETCLR | DMAF_AUD2; 104 102 105 } else 103 } else 106 nosound( 0 ); 104 nosound( 0 ); 107 105 108 local_irq_restore(flags); 106 local_irq_restore(flags); 109 } 107 } 110 108 111 109 112 static void nosound(struct timer_list *unused) !! 110 static void nosound( unsigned long ignored ) 113 { 111 { 114 /* turn off DMA for audio channel 2 */ 112 /* turn off DMA for audio channel 2 */ 115 custom.dmacon = DMAF_AUD2; 113 custom.dmacon = DMAF_AUD2; 116 /* restore period to previous value af 114 /* restore period to previous value after beeping */ 117 custom.aud[2].audper = amiga_audio_per 115 custom.aud[2].audper = amiga_audio_period; 118 } 116 } 119 117
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.