1
/******************************************************************************
3
AudioScience HPI driver
4
Copyright (C) 1997-2003 AudioScience Inc. <support@audioscience.com>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of version 2 of the GNU General Public License as
8
published by the Free Software Foundation;
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
HPI Operating System Specific macros for Linux
21
(C) Copyright AudioScience Inc. 1997-2003
22
******************************************************************************/
23
#define HPI_OS_DEFINED
24
#define HPI_KERNEL_MODE
27
#include <linux/modversions.h>
31
#include <asm/system.h>
32
#include <linux/ioctl.h>
33
#include <linux/kernel.h>
34
#include <linux/string.h>
35
#include <linux/version.h>
36
#include <linux/device.h>
37
#include <linux/firmware.h>
38
#include <linux/interrupt.h>
39
#include <linux/pci.h>
44
#define DEPRECATED __attribute__((deprecated))
47
#define __pack__ __attribute__ ((packed))
56
#define HPI_NO_OS_FILE_OPS
62
/** Details of a memory area allocated with pci_alloc_consistent
63
Need all info for parameters to pci_free_consistent
65
struct consistent_dma_area {
67
/* looks like dma-mapping dma_devres ?! */
70
dma_addr_t dma_handle;
73
static inline u16 HpiOs_LockedMem_GetPhysAddr(
74
struct consistent_dma_area *LockedMemHandle,
78
*pPhysicalAddr = LockedMemHandle->dma_handle;
82
static inline u16 HpiOs_LockedMem_GetVirtAddr(
83
struct consistent_dma_area *LockedMemHandle,
87
*ppVirtualAddr = LockedMemHandle->vaddr;
91
static inline u16 HpiOs_LockedMem_Valid(
92
struct consistent_dma_area *LockedMemHandle
95
return (LockedMemHandle->size != 0);
98
struct hpi_ioctl_linux {
103
/* Conflict?: H is already used by a number of drivers hid, bluetooth hci,
104
and some sound drivers sb16, hdsp, emu10k. AFAIK 0xFC is ununsed command
106
#define HPI_IOCTL_LINUX _IOWR('H', 0xFC, struct hpi_ioctl_linux)
108
#define HPI_DEBUG_FLAG_ERROR KERN_ERR
109
#define HPI_DEBUG_FLAG_WARNING KERN_WARNING
110
#define HPI_DEBUG_FLAG_NOTICE KERN_NOTICE
111
#define HPI_DEBUG_FLAG_INFO KERN_INFO
112
#define HPI_DEBUG_FLAG_DEBUG KERN_DEBUG
113
#define HPI_DEBUG_FLAG_VERBOSE KERN_DEBUG /* kernel has no verbose */
115
#include <linux/spinlock.h>
119
struct hpios_spinlock {
120
spinlock_t lock; /* SEE hpios_spinlock */
124
/* The reason for all this evilness is that ALSA calls some of a drivers
125
* operators in atomic context, and some not. But all our functions channel
126
* through the HPI_Message conduit, so we can't handle the different context
130
#define IN_LOCK_IRQ 0
131
static inline void cond_lock(
132
struct hpios_spinlock *l
135
if (irqs_disabled()) {
136
/* NO bh or isr can execute on this processor,
137
so ordinary lock will do
139
spin_lock(&((l)->lock));
140
l->lock_context = IN_LOCK_IRQ;
142
spin_lock_bh(&((l)->lock));
143
l->lock_context = IN_LOCK_BH;
147
static inline void cond_unlock(
148
struct hpios_spinlock *l
151
if (l->lock_context == IN_LOCK_BH) {
152
spin_unlock_bh(&((l)->lock));
154
spin_unlock(&((l)->lock));
158
#define HpiOs_Msgxlock_Init(obj) spin_lock_init(&(obj)->lock)
159
#define HpiOs_Msgxlock_Lock(obj) cond_lock(obj)
160
#define HpiOs_Msgxlock_UnLock(obj) cond_unlock(obj)
162
#define HpiOs_Dsplock_Init(obj) spin_lock_init(&(obj)->dspLock.lock)
163
#define HpiOs_Dsplock_Lock(obj) cond_lock(&(obj)->dspLock)
164
#define HpiOs_Dsplock_UnLock(obj) cond_unlock(&(obj)->dspLock)
166
#ifdef CONFIG_SND_DEBUG
170
#define HPI_ALIST_LOCKING
171
#define HpiOs_Alistlock_Init(obj) spin_lock_init(&((obj)->aListLock.lock))
172
#define HpiOs_Alistlock_Lock(obj) spin_lock(&((obj)->aListLock.lock))
173
#define HpiOs_Alistlock_UnLock(obj) spin_unlock(&((obj)->aListLock.lock))
176
/* mutex prevents contention for one card
177
between multiple user programs (via ioctl) */
182
/* ALSA card structure */
183
void *snd_card_asihpi;
188
void __iomem *apRemappedMemBase[HPI_MAX_ADAPTER_MEM_SPACES];