~ubuntu-branches/ubuntu/maverick/linux-backports-modules-2.6.32/maverick

« back to all changes in this revision

Viewing changes to updates/alsa-driver/pci/asihpi/hpios_linux_kernel.h

  • Committer: Bazaar Package Importer
  • Author(s): Andy Whitcroft, Andy Whitcroft
  • Date: 2010-02-04 23:15:51 UTC
  • Revision ID: james.westby@ubuntu.com-20100204231551-vjz5pkvxclukjxm1
Tags: 2.6.32-12.1
[ Andy Whitcroft ]

* initial LBM for lucid
* drop generated files
* printchanges -- rebase tree does not have stable tags use changelog
* printenv -- add revisions to printenv output
* formally rename compat-wireless to linux-backports-modules-wireless
* Update to compat-wireless-2.6.33-rc5
* update nouveau to mainline 2.6.33-rc4
* add new LBM package for nouveau
* nouveau -- fix major numbers and proc entry names
* fix up firmware installs for -wireless
* clean up UPDATE-NOVEAU
* update Nouveau to v2.6.33-rc6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 
 
3
    AudioScience HPI driver
 
4
    Copyright (C) 1997-2003  AudioScience Inc. <support@audioscience.com>
 
5
 
 
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;
 
9
 
 
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.
 
14
 
 
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
 
18
 
 
19
HPI Operating System Specific macros for Linux
 
20
 
 
21
(C) Copyright AudioScience Inc. 1997-2003
 
22
******************************************************************************/
 
23
#define HPI_OS_DEFINED
 
24
#define HPI_KERNEL_MODE
 
25
 
 
26
#ifdef MODVERSIONS
 
27
#include <linux/modversions.h>
 
28
#endif
 
29
 
 
30
#include <asm/io.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>
 
40
 
 
41
#define INLINE inline
 
42
 
 
43
#if __GNUC__ >= 3
 
44
#define DEPRECATED __attribute__((deprecated))
 
45
#endif
 
46
 
 
47
#define __pack__ __attribute__ ((packed))
 
48
 
 
49
#ifndef __user
 
50
#define __user
 
51
#endif
 
52
#ifndef __iomem
 
53
#define __iomem
 
54
#endif
 
55
 
 
56
#define HPI_NO_OS_FILE_OPS
 
57
 
 
58
#ifdef CONFIG_64BIT
 
59
#define HPI64BIT
 
60
#endif
 
61
 
 
62
/** Details of a memory area allocated with  pci_alloc_consistent
 
63
Need all info for parameters to pci_free_consistent
 
64
*/
 
65
struct consistent_dma_area {
 
66
        struct device *pdev;
 
67
        /* looks like dma-mapping dma_devres ?! */
 
68
        size_t size;
 
69
        void *vaddr;
 
70
        dma_addr_t dma_handle;
 
71
};
 
72
 
 
73
static inline u16 HpiOs_LockedMem_GetPhysAddr(
 
74
        struct consistent_dma_area *LockedMemHandle,
 
75
        u32 *pPhysicalAddr
 
76
)
 
77
{
 
78
        *pPhysicalAddr = LockedMemHandle->dma_handle;
 
79
        return 0;
 
80
}
 
81
 
 
82
static inline u16 HpiOs_LockedMem_GetVirtAddr(
 
83
        struct consistent_dma_area *LockedMemHandle,
 
84
        void **ppVirtualAddr
 
85
)
 
86
{
 
87
        *ppVirtualAddr = LockedMemHandle->vaddr;
 
88
        return 0;
 
89
}
 
90
 
 
91
static inline u16 HpiOs_LockedMem_Valid(
 
92
        struct consistent_dma_area *LockedMemHandle
 
93
)
 
94
{
 
95
        return (LockedMemHandle->size != 0);
 
96
}
 
97
 
 
98
struct hpi_ioctl_linux {
 
99
        void __user *phm;
 
100
        void __user *phr;
 
101
};
 
102
 
 
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
 
105
*/
 
106
#define HPI_IOCTL_LINUX _IOWR('H', 0xFC, struct hpi_ioctl_linux)
 
107
 
 
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 */
 
114
 
 
115
#include <linux/spinlock.h>
 
116
 
 
117
#define HPI_LOCKING
 
118
 
 
119
struct hpios_spinlock {
 
120
        spinlock_t lock;        /* SEE hpios_spinlock */
 
121
        int lock_context;
 
122
};
 
123
 
 
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
 
127
 * per function
 
128
 */
 
129
#define IN_LOCK_BH 1
 
130
#define IN_LOCK_IRQ 0
 
131
static inline void cond_lock(
 
132
        struct hpios_spinlock *l
 
133
)
 
134
{
 
135
        if (irqs_disabled()) {
 
136
                /* NO bh or isr can execute on this processor,
 
137
                   so ordinary lock will do
 
138
                 */
 
139
                spin_lock(&((l)->lock));
 
140
                l->lock_context = IN_LOCK_IRQ;
 
141
        } else {
 
142
                spin_lock_bh(&((l)->lock));
 
143
                l->lock_context = IN_LOCK_BH;
 
144
        }
 
145
}
 
146
 
 
147
static inline void cond_unlock(
 
148
        struct hpios_spinlock *l
 
149
)
 
150
{
 
151
        if (l->lock_context == IN_LOCK_BH) {
 
152
                spin_unlock_bh(&((l)->lock));
 
153
        } else {
 
154
                spin_unlock(&((l)->lock));
 
155
        }
 
156
}
 
157
 
 
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)
 
161
 
 
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)
 
165
 
 
166
#ifdef CONFIG_SND_DEBUG
 
167
#define HPI_DEBUG
 
168
#endif
 
169
 
 
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))
 
174
 
 
175
struct hpi_adapter {
 
176
        /* mutex prevents contention for one card
 
177
           between multiple user programs (via ioctl) */
 
178
        struct mutex mutex;
 
179
        u16 index;
 
180
        u16 type;
 
181
 
 
182
        /* ALSA card structure */
 
183
        void *snd_card_asihpi;
 
184
 
 
185
        char *pBuffer;
 
186
        size_t buffer_size;
 
187
        struct pci_dev *pci;
 
188
        void __iomem *apRemappedMemBase[HPI_MAX_ADAPTER_MEM_SPACES];
 
189
};