source: sbliveos2/trunk/sblive/hwaccess.h@ 144

Last change on this file since 144 was 142, checked in by ktk, 25 years ago

Import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
1/* $Id: hwaccess.h 142 2000-04-23 14:55:46Z ktk $ */
2
3/*
4 **********************************************************************
5 * hwaccess.h
6 * Copyright 1999, 2000 Creative Labs, Inc.
7 *
8 **********************************************************************
9 *
10 * Date Author Summary of changes
11 * ---- ------ ------------------
12 * October 20, 1999 Bertrand Lee base code release
13 *
14 **********************************************************************
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public
27 * License along with this program; if not, write to the Free
28 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
29 * USA.
30 *
31 **********************************************************************
32 */
33
34#ifndef _HWACCESS_H
35#define _HWACCESS_H
36
37#include <linux/version.h>
38#include <linux/kernel.h>
39#include <linux/fs.h>
40#include <linux/ioport.h>
41#include <linux/sound.h>
42#include <linux/malloc.h>
43#include <linux/soundcard.h>
44#include <linux/pci.h>
45#include <linux/interrupt.h>
46
47#include <asm/io.h>
48#include <asm/dma.h>
49
50#include <emu_wrapper.h>
51
52enum GlobalErrorCode
53{
54 CTSTATUS_SUCCESS = 0x0000,
55 CTSTATUS_ERROR,
56 CTSTATUS_NOMEMORY,
57 CTSTATUS_INUSE,
58};
59
60#define FLAGS_AVAILABLE 0x0001
61#define FLAGS_READY 0x0002
62
63#define min(x,y) ((x) < (y)) ? (x) : (y)
64
65struct memhandle
66{
67 unsigned long busaddx;
68 void *virtaddx;
69 u32 order;
70};
71
72struct memhandle *emu10k1_alloc_memphysical(u32);
73void emu10k1_free_memphysical(struct memhandle *);
74
75int emu10k1_list_attach(struct sblive_list **head, struct sblive_list *new);
76int emu10k1_list_remove(struct sblive_list **head, struct sblive_list *pDead);
77struct sblive_list *list_getnext(struct sblive_list *head, struct sblive_list *curr);
78
79#define DEBUG_LEVEL 2
80
81#ifdef TARGET_OS2
82#ifdef DEBUG
83#ifdef __cplusplus
84extern "C" {
85#endif
86void _cdecl DPD(int level, char *x, ...) ; /* not debugging: nothing */
87#ifdef __cplusplus
88}
89#endif
90
91#define ERROR() DebugInt3()
92#else
93#define DPD 1 ? (void)0 : (void)((int (*)(int, char *, ...)) NULL)
94#define ERROR()
95#endif
96#define DPF(level, x)
97#define __attribute(a)
98#else
99#ifdef EMU10K1_DEBUG
100# define DPD(level,x,y...) do {if(level <= DEBUG_LEVEL) printk( KERN_NOTICE "emu10k1: %s: %d: " x , __FILE__ , __LINE__ , y );} while(0)
101# define DPF(level,x) do {if(level <= DEBUG_LEVEL) printk( KERN_NOTICE "emu10k1: %s: %d: " x , __FILE__ , __LINE__ );} while(0)
102#define ERROR() DPF(1,"error\n");
103#else
104# define DPD(level,x,y...) /* not debugging: nothing */
105# define DPF(level,x)
106#define ERROR()
107#endif /* EMU10K1_DEBUG */
108#endif //TARGET_OS2
109
110#include "8010.h"
111#include "voicemgr.h"
112
113int emu10k1_addxmgr_alloc(u32, struct emu10k1_card *);
114void emu10k1_addxmgr_free(struct emu10k1_card *, int);
115
116#include "timer.h"
117#include "irqmgr.h"
118
119/* DATA STRUCTURES */
120
121struct emu10k1_card
122{
123 struct list_head list;
124
125 struct memhandle *virtualpagetable;
126
127 struct memhandle *tankmem;
128 u32 tmemsize;
129 struct memhandle *silentpage;
130
131 spinlock_t lock;
132
133 struct voice_manager voicemgr;
134 u16 emupagetable[MAXPAGES];
135
136 struct list_head timers;
137 unsigned timer_delay;
138 spinlock_t timer_lock;
139
140 struct pci_dev *pci_dev;
141 unsigned long iobase;
142 unsigned long mixeraddx;
143 u32 irq;
144
145 unsigned long audio1_num;
146 unsigned long audio2_num;
147 unsigned long mixer_num;
148 unsigned long midi_num;
149
150 struct emu10k1_waveout *waveout;
151 struct emu10k1_wavein *wavein;
152 struct emu10k1_mpuout *mpuout;
153 struct emu10k1_mpuin *mpuin;
154
155 u16 arrwVol[SOUND_MIXER_NRDEVICES + 1];
156 /* array is used from the member 1 to save (-1) operation */
157 u32 digmix[9 * 6 * 2];
158 unsigned int modcnt;
159 struct semaphore open_sem;
160 mode_t open_mode;
161 wait_queue_head_t open_wait;
162
163 u32 mpuacqcount; // Mpu acquire count
164 u32 has_toslink; // TOSLink detection
165
166 u8 chiprev; /* Chip revision */
167};
168
169#ifdef PRIVATE_PCM_VOLUME
170
171#define MAX_PCM_CHANNELS NUM_G
172struct sblive_pcm_volume_rec {
173 struct files_struct *files; // identification of the same thread
174 u8 attn_l; // attenuation for left channel
175 u8 attn_r; // attenuation for right channel
176 u16 mixer; // saved mixer value for return
177 u8 channel_l; // idx of left channel
178 u8 channel_r; // idx of right channel
179 int opened; // counter - locks element
180};
181extern struct sblive_pcm_volume_rec sblive_pcm_volume[];
182
183#endif
184
185
186#define ENABLE 0xffffffff
187#define DISABLE 0x00000000
188
189#define ENV_ON 0x80
190#define ENV_OFF 0x00
191
192#define TIMEOUT 16384
193
194u32 srToPitch(u32);
195u8 sumVolumeToAttenuation(u32);
196
197extern struct list_head emu10k1_devs;
198
199/* Hardware Abstraction Layer access functions */
200
201#define WRITE_FN0(a,b,c) sblive_wrtmskfn0((a),(u8)(b), ((1 << (((b) >> 24) & 0x3f)) - 1) << (((b) >> 16) & 0x1f), (c) << (((b) >> 16) & 0x1f))
202
203#define READ_FN0(a,b) sblive_rdmskfn0((a),(u8)(b),((1 << (((b) >> 24) & 0x3f)) - 1) << (((b) >> 16) & 0x1f)) >> (((b) >> 16) & 0x1f)
204
205void sblive_writefn0(struct emu10k1_card *, u8 , u32 );
206void sblive_wrtmskfn0(struct emu10k1_card *, u8 , u32 , u32 );
207
208u32 sblive_readfn0(struct emu10k1_card *, u8 );
209u32 sblive_rdmskfn0(struct emu10k1_card *, u8, u32 );
210
211void sblive_writeptr(struct emu10k1_card *, u32 , u32 , u32 );
212u32 sblive_readptr(struct emu10k1_card *, u32 , u32 );
213
214void emu10k1_set_stop_on_loop(struct emu10k1_card *, u32);
215void emu10k1_clear_stop_on_loop(struct emu10k1_card *, u32);
216
217/* AC97 Mixer access function */
218int sblive_readac97(struct emu10k1_card *, u8, u16 *);
219int sblive_writeac97(struct emu10k1_card *, u8, u16);
220int sblive_rmwac97(struct emu10k1_card *, u8, u16, u16);
221
222/* MPU access function*/
223int emu10k1_mpu_write_data(struct emu10k1_card *, u8);
224int emu10k1_mpu_read_data(struct emu10k1_card *, u8 *);
225int emu10k1_mpu_reset(struct emu10k1_card *);
226int emu10k1_mpu_acquire(struct emu10k1_card *);
227int emu10k1_mpu_release(struct emu10k1_card *);
228
229#endif /* _HWACCESS_H */
Note: See TracBrowser for help on using the repository browser.