diff options
author | NeilBrown <neilb@suse.de> | 2010-05-21 18:31:36 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-05-21 18:31:36 -0400 |
commit | 19fdb9eefb21b72edbc365b838502780c392bad6 (patch) | |
tree | deae04c48532d6eab64ed4b0396737bb854b5506 /sound/pci/asihpi/hpios.h | |
parent | be6800a73aa2f3dc14744c3b80e676d189789f04 (diff) | |
parent | 3ff195b011d7decf501a4d55aeed312731094796 (diff) |
Merge commit '3ff195b011d7decf501a4d55aeed312731094796' into for-linus
Conflicts:
drivers/md/md.c
- Resolved conflict in md_update_sb
- Added extra 'NULL' arg to new instance of sysfs_get_dirent.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'sound/pci/asihpi/hpios.h')
-rw-r--r-- | sound/pci/asihpi/hpios.h | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/sound/pci/asihpi/hpios.h b/sound/pci/asihpi/hpios.h new file mode 100644 index 000000000000..a62c3f1e5f09 --- /dev/null +++ b/sound/pci/asihpi/hpios.h | |||
@@ -0,0 +1,178 @@ | |||
1 | /****************************************************************************** | ||
2 | |||
3 | AudioScience HPI driver | ||
4 | Copyright (C) 1997-2010 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 Kernel driver | ||
20 | |||
21 | (C) Copyright AudioScience Inc. 1997-2003 | ||
22 | ******************************************************************************/ | ||
23 | #ifndef _HPIOS_H_ | ||
24 | #define _HPIOS_H_ | ||
25 | |||
26 | #undef HPI_OS_LINUX_KERNEL | ||
27 | #define HPI_OS_LINUX_KERNEL | ||
28 | |||
29 | #define HPI_OS_DEFINED | ||
30 | #define HPI_KERNEL_MODE | ||
31 | |||
32 | #define HPI_REASSIGN_DUPLICATE_ADAPTER_IDX | ||
33 | |||
34 | #include <linux/io.h> | ||
35 | #include <asm/system.h> | ||
36 | #include <linux/ioctl.h> | ||
37 | #include <linux/kernel.h> | ||
38 | #include <linux/string.h> | ||
39 | #include <linux/device.h> | ||
40 | #include <linux/firmware.h> | ||
41 | #include <linux/interrupt.h> | ||
42 | #include <linux/pci.h> | ||
43 | |||
44 | #define HPI_NO_OS_FILE_OPS | ||
45 | |||
46 | #ifdef CONFIG_64BIT | ||
47 | #define HPI64BIT | ||
48 | #endif | ||
49 | |||
50 | /** Details of a memory area allocated with pci_alloc_consistent | ||
51 | Need all info for parameters to pci_free_consistent | ||
52 | */ | ||
53 | struct consistent_dma_area { | ||
54 | struct device *pdev; | ||
55 | /* looks like dma-mapping dma_devres ?! */ | ||
56 | size_t size; | ||
57 | void *vaddr; | ||
58 | dma_addr_t dma_handle; | ||
59 | }; | ||
60 | |||
61 | static inline u16 hpios_locked_mem_get_phys_addr(struct consistent_dma_area | ||
62 | *locked_mem_handle, u32 *p_physical_addr) | ||
63 | { | ||
64 | *p_physical_addr = locked_mem_handle->dma_handle; | ||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static inline u16 hpios_locked_mem_get_virt_addr(struct consistent_dma_area | ||
69 | *locked_mem_handle, void **pp_virtual_addr) | ||
70 | { | ||
71 | *pp_virtual_addr = locked_mem_handle->vaddr; | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static inline u16 hpios_locked_mem_valid(struct consistent_dma_area | ||
76 | *locked_mem_handle) | ||
77 | { | ||
78 | return locked_mem_handle->size != 0; | ||
79 | } | ||
80 | |||
81 | struct hpi_ioctl_linux { | ||
82 | void __user *phm; | ||
83 | void __user *phr; | ||
84 | }; | ||
85 | |||
86 | /* Conflict?: H is already used by a number of drivers hid, bluetooth hci, | ||
87 | and some sound drivers sb16, hdsp, emu10k. AFAIK 0xFC is ununsed command | ||
88 | */ | ||
89 | #define HPI_IOCTL_LINUX _IOWR('H', 0xFC, struct hpi_ioctl_linux) | ||
90 | |||
91 | #define HPI_DEBUG_FLAG_ERROR KERN_ERR | ||
92 | #define HPI_DEBUG_FLAG_WARNING KERN_WARNING | ||
93 | #define HPI_DEBUG_FLAG_NOTICE KERN_NOTICE | ||
94 | #define HPI_DEBUG_FLAG_INFO KERN_INFO | ||
95 | #define HPI_DEBUG_FLAG_DEBUG KERN_DEBUG | ||
96 | #define HPI_DEBUG_FLAG_VERBOSE KERN_DEBUG /* kernel has no verbose */ | ||
97 | |||
98 | #include <linux/spinlock.h> | ||
99 | |||
100 | #define HPI_LOCKING | ||
101 | |||
102 | struct hpios_spinlock { | ||
103 | spinlock_t lock; /* SEE hpios_spinlock */ | ||
104 | int lock_context; | ||
105 | }; | ||
106 | |||
107 | /* The reason for all this evilness is that ALSA calls some of a drivers | ||
108 | * operators in atomic context, and some not. But all our functions channel | ||
109 | * through the HPI_Message conduit, so we can't handle the different context | ||
110 | * per function | ||
111 | */ | ||
112 | #define IN_LOCK_BH 1 | ||
113 | #define IN_LOCK_IRQ 0 | ||
114 | static inline void cond_lock(struct hpios_spinlock *l) | ||
115 | { | ||
116 | if (irqs_disabled()) { | ||
117 | /* NO bh or isr can execute on this processor, | ||
118 | so ordinary lock will do | ||
119 | */ | ||
120 | spin_lock(&((l)->lock)); | ||
121 | l->lock_context = IN_LOCK_IRQ; | ||
122 | } else { | ||
123 | spin_lock_bh(&((l)->lock)); | ||
124 | l->lock_context = IN_LOCK_BH; | ||
125 | } | ||
126 | } | ||
127 | |||
128 | static inline void cond_unlock(struct hpios_spinlock *l) | ||
129 | { | ||
130 | if (l->lock_context == IN_LOCK_BH) | ||
131 | spin_unlock_bh(&((l)->lock)); | ||
132 | else | ||
133 | spin_unlock(&((l)->lock)); | ||
134 | } | ||
135 | |||
136 | #define hpios_msgxlock_init(obj) spin_lock_init(&(obj)->lock) | ||
137 | #define hpios_msgxlock_lock(obj) cond_lock(obj) | ||
138 | #define hpios_msgxlock_un_lock(obj) cond_unlock(obj) | ||
139 | |||
140 | #define hpios_dsplock_init(obj) spin_lock_init(&(obj)->dsp_lock.lock) | ||
141 | #define hpios_dsplock_lock(obj) cond_lock(&(obj)->dsp_lock) | ||
142 | #define hpios_dsplock_unlock(obj) cond_unlock(&(obj)->dsp_lock) | ||
143 | |||
144 | #ifdef CONFIG_SND_DEBUG | ||
145 | #define HPI_DEBUG | ||
146 | #endif | ||
147 | |||
148 | #define HPI_ALIST_LOCKING | ||
149 | #define hpios_alistlock_init(obj) spin_lock_init(&((obj)->list_lock.lock)) | ||
150 | #define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock)) | ||
151 | #define hpios_alistlock_un_lock(obj) spin_unlock(&((obj)->list_lock.lock)) | ||
152 | |||
153 | struct hpi_adapter { | ||
154 | /* mutex prevents contention for one card | ||
155 | between multiple user programs (via ioctl) */ | ||
156 | struct mutex mutex; | ||
157 | u16 index; | ||
158 | u16 type; | ||
159 | |||
160 | /* ALSA card structure */ | ||
161 | void *snd_card_asihpi; | ||
162 | |||
163 | char *p_buffer; | ||
164 | size_t buffer_size; | ||
165 | struct pci_dev *pci; | ||
166 | void __iomem *ap_remapped_mem_base[HPI_MAX_ADAPTER_MEM_SPACES]; | ||
167 | }; | ||
168 | |||
169 | static inline void hpios_unmap_io(void __iomem *addr, | ||
170 | unsigned long size) | ||
171 | { | ||
172 | iounmap(addr); | ||
173 | } | ||
174 | |||
175 | void __iomem *hpios_map_io(struct pci_dev *pci_dev, int idx, | ||
176 | unsigned int length); | ||
177 | |||
178 | #endif | ||