OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [sound/] [gus_card.c] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/*
2
 * sound/gus_card.c
3
 *
4
 * Detection routine for the Gravis Ultrasound.
5
 */
6
/*
7
 * Copyright (C) by Hannu Savolainen 1993-1996
8
 *
9
 * USS/Lite for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
10
 * Version 2 (June 1991). See the "COPYING" file distributed with this software
11
 * for more info.
12
 */
13
#include <linux/config.h>
14
 
15
 
16
#include "sound_config.h"
17
 
18
#if defined(CONFIG_GUS)
19
 
20
#include "gus_hw.h"
21
 
22
void            gusintr (int irq, void *dev_id, struct pt_regs *dummy);
23
 
24
int             gus_base, gus_irq, gus_dma;
25
extern int      gus_wave_volume;
26
extern int      gus_pcm_volume;
27
extern int      have_gus_max;
28
int             gus_pnp_flag = 0;
29
 
30
int            *gus_osp;
31
 
32
void
33
attach_gus_card (struct address_info *hw_config)
34
{
35
  int             io_addr;
36
 
37
  gus_osp = hw_config->osp;
38
  snd_set_irq_handler (hw_config->irq, gusintr, "Gravis Ultrasound", hw_config->osp);
39
 
40
  if (gus_wave_detect (hw_config->io_base))     /*
41
                                                 * Try first the default
42
                                                 */
43
    {
44
      gus_wave_init (hw_config);
45
 
46
      request_region (hw_config->io_base, 16, "GUS");
47
      request_region (hw_config->io_base + 0x100, 12, "GUS");   /* 0x10c-> is MAX */
48
 
49
      if (sound_alloc_dma (hw_config->dma, "GUS"))
50
        printk ("gus_card.c: Can't allocate DMA channel\n");
51
      if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
52
        if (sound_alloc_dma (hw_config->dma2, "GUS(2)"))
53
          printk ("gus_card.c: Can't allocate DMA channel2\n");
54
#ifdef CONFIG_MIDI
55
      gus_midi_init ();
56
#endif
57
      return;
58
    }
59
 
60
#ifndef EXCLUDE_GUS_IODETECT
61
 
62
  /*
63
   * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
64
   */
65
 
66
  for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
67
    if (io_addr != hw_config->io_base)  /*
68
                                         * Already tested
69
                                         */
70
      if (gus_wave_detect (io_addr))
71
        {
72
          hw_config->io_base = io_addr;
73
 
74
          printk (" WARNING! GUS found at %x, config was %x ", io_addr, hw_config->io_base);
75
          gus_wave_init (hw_config);
76
          request_region (io_addr, 16, "GUS");
77
          request_region (io_addr + 0x100, 12, "GUS");  /* 0x10c-> is MAX */
78
          if (sound_alloc_dma (hw_config->dma, "GUS"))
79
            printk ("gus_card.c: Can't allocate DMA channel\n");
80
          if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
81
            if (sound_alloc_dma (hw_config->dma2, "GUS"))
82
              printk ("gus_card.c: Can't allocate DMA channel2\n");
83
#ifdef CONFIG_MIDI
84
          gus_midi_init ();
85
#endif
86
          return;
87
        }
88
 
89
#endif
90
 
91
}
92
 
93
int
94
probe_gus (struct address_info *hw_config)
95
{
96
  int             io_addr, irq;
97
 
98
  gus_osp = hw_config->osp;
99
 
100
  if (hw_config->card_subtype == 1)
101
    gus_pnp_flag = 1;
102
 
103
  irq = hw_config->irq;
104
 
105
  if (hw_config->card_subtype == 0)      /* GUS/MAX/ACE */
106
    if (irq != 3 && irq != 5 && irq != 7 && irq != 9 &&
107
        irq != 11 && irq != 12 && irq != 15)
108
      {
109
        printk ("GUS: Unsupported IRQ %d\n", irq);
110
        return 0;
111
      }
112
 
113
  if (check_region (hw_config->io_base, 16))
114
    printk ("GUS: I/O range conflict (1)\n");
115
  else if (check_region (hw_config->io_base + 0x100, 16))
116
    printk ("GUS: I/O range conflict (2)\n");
117
  else if (gus_wave_detect (hw_config->io_base))
118
    return 1;
119
 
120
#ifndef EXCLUDE_GUS_IODETECT
121
 
122
  /*
123
   * Look at the possible base addresses (0x2X0, X=1, 2, 3, 4, 5, 6)
124
   */
125
 
126
  for (io_addr = 0x210; io_addr <= 0x260; io_addr += 0x10)
127
    if (io_addr != hw_config->io_base)  /*
128
                                         * Already tested
129
                                         */
130
      if (!check_region (io_addr, 16))
131
        if (!check_region (io_addr + 0x100, 16))
132
          if (gus_wave_detect (io_addr))
133
            {
134
              hw_config->io_base = io_addr;
135
              return 1;
136
            }
137
 
138
#endif
139
 
140
  return 0;
141
}
142
 
143
void
144
unload_gus (struct address_info *hw_config)
145
{
146
  DDB (printk ("unload_gus(%x)\n", hw_config->io_base));
147
 
148
  gus_wave_unload ();
149
 
150
  release_region (hw_config->io_base, 16);
151
  release_region (hw_config->io_base + 0x100, 12);      /* 0x10c-> is MAX */
152
  snd_release_irq (hw_config->irq);
153
 
154
  sound_free_dma (hw_config->dma);
155
 
156
  if (hw_config->dma2 != -1 && hw_config->dma2 != hw_config->dma)
157
    sound_free_dma (hw_config->dma2);
158
}
159
 
160
void
161
gusintr (int irq, void *dev_id, struct pt_regs *dummy)
162
{
163
  unsigned char   src;
164
  extern int      gus_timer_enabled;
165
 
166
  sti ();
167
 
168
#ifdef CONFIG_GUSMAX
169
  if (have_gus_max)
170
    ad1848_interrupt (irq, NULL, NULL);
171
#endif
172
 
173
  while (1)
174
    {
175
      if (!(src = inb (u_IrqStatus)))
176
        return;
177
 
178
      if (src & DMA_TC_IRQ)
179
        {
180
          guswave_dma_irq ();
181
        }
182
 
183
      if (src & (MIDI_TX_IRQ | MIDI_RX_IRQ))
184
        {
185
#ifdef CONFIG_MIDI
186
          gus_midi_interrupt (0);
187
#endif
188
        }
189
 
190
      if (src & (GF1_TIMER1_IRQ | GF1_TIMER2_IRQ))
191
        {
192
#ifdef CONFIG_SEQUENCER
193
          if (gus_timer_enabled)
194
            {
195
              sound_timer_interrupt ();
196
            }
197
 
198
          gus_write8 (0x45, 0);  /* Ack IRQ */
199
          gus_timer_command (4, 0x80);  /* Reset IRQ flags */
200
 
201
#else
202
          gus_write8 (0x45, 0);  /* Stop timers */
203
#endif
204
        }
205
 
206
      if (src & (WAVETABLE_IRQ | ENVELOPE_IRQ))
207
        {
208
          gus_voice_irq ();
209
        }
210
    }
211
}
212
 
213
#endif
214
 
215
/*
216
 * Some extra code for the 16 bit sampling option
217
 */
218
#if defined(CONFIG_GUS16)
219
 
220
int
221
probe_gus_db16 (struct address_info *hw_config)
222
{
223
  return ad1848_detect (hw_config->io_base, NULL, hw_config->osp);
224
}
225
 
226
void
227
attach_gus_db16 (struct address_info *hw_config)
228
{
229
#ifdef CONFIG_GUS
230
  gus_pcm_volume = 100;
231
  gus_wave_volume = 90;
232
#endif
233
 
234
  ad1848_init ("GUS 16 bit sampling", hw_config->io_base,
235
               hw_config->irq,
236
               hw_config->dma,
237
               hw_config->dma, 0,
238
               hw_config->osp);
239
}
240
 
241
void
242
unload_gus_db16 (struct address_info *hw_config)
243
{
244
 
245
  ad1848_unload (hw_config->io_base,
246
                 hw_config->irq,
247
                 hw_config->dma,
248
                 hw_config->dma, 0);
249
}
250
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.