~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/m68k/amiga/amisound.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/m68k/amiga/amisound.c (Architecture mips) and /arch/m68k/amiga/amisound.c (Architecture m68k)


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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php