root/arch/m68k/atari/atasound.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. atari_nosound
  2. atari_microwire_cmd
  3. atari_mksound

   1 /*
   2 linux/arch/m68k/atari/atasound.c
   3 
   4 ++Geert: Moved almost all stuff to linux/drivers/sound/
   5 
   6 The author of atari_nosound, atari_mksound and atari_microwire_cmd is
   7 unknown.
   8 (++roman: That's me... :-)
   9 
  10 This file is subject to the terms and conditions of the GNU General Public
  11 License.  See the file README.legal in the main directory of this archive
  12 for more details.
  13 
  14 */
  15 
  16 
  17 #include <linux/sched.h>
  18 #include <linux/timer.h>
  19 #include <linux/major.h>
  20 #include <linux/config.h>
  21 #include <linux/fcntl.h>
  22 #include <linux/errno.h>
  23 #include <linux/mm.h>
  24 
  25 #include <asm/atarihw.h>
  26 #include <asm/system.h>
  27 #include <asm/irq.h>
  28 #include <asm/pgtable.h>
  29 #include <asm/atariints.h>
  30 #include <asm/bootinfo.h>
  31 
  32 
  33 /*
  34  * stuff from the old atasound.c
  35  */
  36 
  37 
  38 static void atari_nosound (unsigned long ignored)
     /* [previous][next][first][last][top][bottom][index][help] */
  39 {
  40         unsigned char   tmp;
  41         unsigned long flags;
  42         
  43         /* turn off generator A in mixer control */
  44         save_flags(flags);
  45         cli();
  46         sound_ym.rd_data_reg_sel = 7;
  47         tmp = sound_ym.rd_data_reg_sel;
  48         sound_ym.wd_data = tmp | 0x39;
  49         restore_flags(flags);
  50 }       
  51                 
  52 
  53 void atari_microwire_cmd (int cmd)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55         tt_microwire.mask = 0x7ff;
  56         tt_microwire.data = MW_LM1992_ADDR | cmd;
  57 
  58         /* Busy wait for data being completely sent :-( */
  59         while( tt_microwire.mask != 0x7ff)
  60                 ;
  61 }
  62 
  63 
  64 #define PC_FREQ         1192180
  65 #define PSG_FREQ        125000
  66 
  67 
  68 void atari_mksound (unsigned int count, unsigned int ticks)
     /* [previous][next][first][last][top][bottom][index][help] */
  69 {
  70         static struct timer_list sound_timer = { NULL, NULL, 0, 0,
  71                                                      atari_nosound };
  72         /*
  73          * Generates sound of some count for some number of clock ticks
  74          * [count = 1193180 / frequency]
  75          */
  76         unsigned long flags;
  77         unsigned char tmp;
  78 
  79         save_flags(flags);
  80         cli();
  81 
  82         if (count == 750 && ticks == HZ/8) {
  83                 /* Special case: These values are used by console.c to
  84                  * generate the console bell. They are cached here and the
  85                  * sound actually generated is somehow special: it uses the
  86                  * generator B and an envelope. No timer is needed therefore
  87                  * and the bell doesn't disturb an other ongoing sound.
  88                  */
  89 
  90                 /* set envelope duration to 492 ms */
  91                 sound_ym.rd_data_reg_sel = 11;
  92                 sound_ym.wd_data = 0;
  93                 sound_ym.rd_data_reg_sel = 12;
  94                 sound_ym.wd_data = 15;
  95                 /* envelope form: max -> min single */
  96                 sound_ym.rd_data_reg_sel = 13;
  97                 sound_ym.wd_data = 9;
  98                 /* set generator B frequency to 2400 Hz */
  99                 sound_ym.rd_data_reg_sel = 2;
 100                 sound_ym.wd_data = 52;
 101                 sound_ym.rd_data_reg_sel = 3;
 102                 sound_ym.wd_data = 0;
 103                 /* set volume of generator B to envelope control */
 104                 sound_ym.rd_data_reg_sel = 9;
 105                 sound_ym.wd_data = 0x10;
 106                 /* enable generator B in the mixer control */
 107                 sound_ym.rd_data_reg_sel = 7;
 108                 tmp = sound_ym.rd_data_reg_sel;
 109                 sound_ym.wd_data = (tmp & ~0x02) | 0x38;
 110 
 111                 restore_flags(flags);
 112                 return;
 113         }
 114 
 115         del_timer( &sound_timer );
 116 
 117         if (!count) {
 118                 atari_nosound( 0 );
 119         }
 120         else {
 121 
 122                 /* convert from PC counter value (base frequency 1.193 MHz)
 123                  * to PSG period value (base frequency 125 kHz).
 124                  */
 125                 int period = (PSG_FREQ * count + PC_FREQ/2) / PC_FREQ;
 126 
 127                 if (period > 0xfff) period = 0xfff;
 128 
 129                 /* set generator A frequency to 0 */
 130                 sound_ym.rd_data_reg_sel = 0;
 131                 sound_ym.wd_data = period & 0xff;
 132                 sound_ym.rd_data_reg_sel = 1;
 133                 sound_ym.wd_data = (period >> 8) & 0xf;
 134                 /* turn on generator A in mixer control (but not noise
 135                  * generator!) */
 136                 sound_ym.rd_data_reg_sel = 7;
 137                 tmp = sound_ym.rd_data_reg_sel;
 138                 sound_ym.wd_data = (tmp & ~0x01) | 0x38;
 139                 /* set generator A level to maximum, no envelope */
 140                 sound_ym.rd_data_reg_sel = 8;
 141                 sound_ym.wd_data = 15;
 142                 
 143                 if (ticks) {
 144                         sound_timer.expires = jiffies + ticks;
 145                         add_timer( &sound_timer );
 146                 }
 147         }
 148 
 149         restore_flags(flags);
 150 }

/* [previous][next][first][last][top][bottom][index][help] */