diff options
author | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 12:17:53 -0700 |
---|---|---|
committer | Yunhong Jiang <yunhong.jiang@intel.com> | 2015-08-04 15:44:42 -0700 |
commit | 9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (patch) | |
tree | 1c9cafbcd35f783a87880a10f85d1a060db1a563 /kernel/arch/m68k/amiga/amisound.c | |
parent | 98260f3884f4a202f9ca5eabed40b1354c489b29 (diff) |
Add the rt linux 4.1.3-rt3 as base
Import the rt linux 4.1.3-rt3 as OPNFV kvm base.
It's from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-4.1.y-rt and
the base is:
commit 0917f823c59692d751951bf5ea699a2d1e2f26a2
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Sat Jul 25 12:13:34 2015 +0200
Prepare v4.1.3-rt3
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
We lose all the git history this way and it's not good. We
should apply another opnfv project repo in future.
Change-Id: I87543d81c9df70d99c5001fbdf646b202c19f423
Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Diffstat (limited to 'kernel/arch/m68k/amiga/amisound.c')
-rw-r--r-- | kernel/arch/m68k/amiga/amisound.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/kernel/arch/m68k/amiga/amisound.c b/kernel/arch/m68k/amiga/amisound.c new file mode 100644 index 000000000..90a60d758 --- /dev/null +++ b/kernel/arch/m68k/amiga/amisound.c @@ -0,0 +1,116 @@ +/* + * linux/arch/m68k/amiga/amisound.c + * + * amiga sound driver for Linux/m68k + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + */ + +#include <linux/jiffies.h> +#include <linux/timer.h> +#include <linux/init.h> +#include <linux/string.h> +#include <linux/module.h> + +#include <asm/amigahw.h> + +static unsigned short *snd_data; +static const signed char sine_data[] = { + 0, 39, 75, 103, 121, 127, 121, 103, 75, 39, + 0, -39, -75, -103, -121, -127, -121, -103, -75, -39 +}; +#define DATA_SIZE ARRAY_SIZE(sine_data) + +#define custom amiga_custom + + /* + * The minimum period for audio may be modified by the frame buffer + * device since it depends on htotal (for OCS/ECS/AGA) + */ + +volatile unsigned short amiga_audio_min_period = 124; /* Default for pre-OCS */ +EXPORT_SYMBOL(amiga_audio_min_period); + +#define MAX_PERIOD (65535) + + + /* + * Current period (set by dmasound.c) + */ + +unsigned short amiga_audio_period = MAX_PERIOD; +EXPORT_SYMBOL(amiga_audio_period); + +static unsigned long clock_constant; + +void __init amiga_init_sound(void) +{ + static struct resource beep_res = { .name = "Beep" }; + + snd_data = amiga_chip_alloc_res(sizeof(sine_data), &beep_res); + if (!snd_data) { + pr_crit("amiga init_sound: failed to allocate chipmem\n"); + return; + } + memcpy (snd_data, sine_data, sizeof(sine_data)); + + /* setup divisor */ + clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE; + + /* without amifb, turn video off and enable high quality sound */ +#ifndef CONFIG_FB_AMIGA + amifb_video_off(); +#endif +} + +static void nosound( unsigned long ignored ); +static DEFINE_TIMER(sound_timer, nosound, 0, 0); + +void amiga_mksound( unsigned int hz, unsigned int ticks ) +{ + unsigned long flags; + + if (!snd_data) + return; + + local_irq_save(flags); + del_timer( &sound_timer ); + + if (hz > 20 && hz < 32767) { + unsigned long period = (clock_constant / hz); + + if (period < amiga_audio_min_period) + period = amiga_audio_min_period; + if (period > MAX_PERIOD) + period = MAX_PERIOD; + + /* setup pointer to data, period, length and volume */ + custom.aud[2].audlc = snd_data; + custom.aud[2].audlen = sizeof(sine_data)/2; + custom.aud[2].audper = (unsigned short)period; + custom.aud[2].audvol = 32; /* 50% of maxvol */ + + if (ticks) { + sound_timer.expires = jiffies + ticks; + add_timer( &sound_timer ); + } + + /* turn on DMA for audio channel 2 */ + custom.dmacon = DMAF_SETCLR | DMAF_AUD2; + + } else + nosound( 0 ); + + local_irq_restore(flags); +} + + +static void nosound( unsigned long ignored ) +{ + /* turn off DMA for audio channel 2 */ + custom.dmacon = DMAF_AUD2; + /* restore period to previous value after beeping */ + custom.aud[2].audper = amiga_audio_period; +} |