aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/oss/pcm_plugin.h
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 04:18:00 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:16:33 -0500
commit47eaebfd31610d2a55fbaccd1e7c37690d42ce30 (patch)
treed86d90a3741e09cf660aef3dda96566ff68778eb /sound/core/oss/pcm_plugin.h
parent230b5c1a612ae903c560b55a15df287b0ff437ea (diff)
[ALSA] Use standard bitmap functions
Modules: ALSA<-OSS emulation Use standard bitmap functions instead of in-house ones. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/oss/pcm_plugin.h')
-rw-r--r--sound/core/oss/pcm_plugin.h78
1 files changed, 9 insertions, 69 deletions
diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h
index 0f86ce477490..69a43172142c 100644
--- a/sound/core/oss/pcm_plugin.h
+++ b/sound/core/oss/pcm_plugin.h
@@ -22,71 +22,11 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef ATTRIBUTE_UNUSED 25#include <linux/bitmap.h>
26#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
27#endif
28
29typedef unsigned int bitset_t;
30
31static inline size_t bitset_size(int nbits)
32{
33 return (nbits + sizeof(bitset_t) * 8 - 1) / (sizeof(bitset_t) * 8);
34}
35
36static inline bitset_t *bitset_alloc(int nbits)
37{
38 return kcalloc(bitset_size(nbits), sizeof(bitset_t), GFP_KERNEL);
39}
40
41static inline void bitset_set(bitset_t *bitmap, unsigned int pos)
42{
43 size_t bits = sizeof(*bitmap) * 8;
44 bitmap[pos / bits] |= 1 << (pos % bits);
45}
46
47static inline void bitset_reset(bitset_t *bitmap, unsigned int pos)
48{
49 size_t bits = sizeof(*bitmap) * 8;
50 bitmap[pos / bits] &= ~(1 << (pos % bits));
51}
52
53static inline int bitset_get(bitset_t *bitmap, unsigned int pos)
54{
55 size_t bits = sizeof(*bitmap) * 8;
56 return !!(bitmap[pos / bits] & (1 << (pos % bits)));
57}
58
59static inline void bitset_copy(bitset_t *dst, bitset_t *src, unsigned int nbits)
60{
61 memcpy(dst, src, bitset_size(nbits) * sizeof(bitset_t));
62}
63
64static inline void bitset_and(bitset_t *dst, bitset_t *bs, unsigned int nbits)
65{
66 bitset_t *end = dst + bitset_size(nbits);
67 while (dst < end)
68 *dst++ &= *bs++;
69}
70
71static inline void bitset_or(bitset_t *dst, bitset_t *bs, unsigned int nbits)
72{
73 bitset_t *end = dst + bitset_size(nbits);
74 while (dst < end)
75 *dst++ |= *bs++;
76}
77
78static inline void bitset_zero(bitset_t *dst, unsigned int nbits)
79{
80 bitset_t *end = dst + bitset_size(nbits);
81 while (dst < end)
82 *dst++ = 0;
83}
84 26
85static inline void bitset_one(bitset_t *dst, unsigned int nbits) 27static inline unsigned long *bitmap_alloc(unsigned int nbits)
86{ 28{
87 bitset_t *end = dst + bitset_size(nbits); 29 return kmalloc(BITS_TO_LONGS(nbits), GFP_KERNEL);
88 while (dst < end)
89 *dst++ = ~(bitset_t)0;
90} 30}
91 31
92#define snd_pcm_plug_t snd_pcm_substream_t 32#define snd_pcm_plug_t snd_pcm_substream_t
@@ -131,11 +71,11 @@ struct _snd_pcm_plugin {
131 snd_pcm_uframes_t frames, 71 snd_pcm_uframes_t frames,
132 snd_pcm_plugin_channel_t **channels); 72 snd_pcm_plugin_channel_t **channels);
133 int (*src_channels_mask)(snd_pcm_plugin_t *plugin, 73 int (*src_channels_mask)(snd_pcm_plugin_t *plugin,
134 bitset_t *dst_vmask, 74 unsigned long *dst_vmask,
135 bitset_t **src_vmask); 75 unsigned long **src_vmask);
136 int (*dst_channels_mask)(snd_pcm_plugin_t *plugin, 76 int (*dst_channels_mask)(snd_pcm_plugin_t *plugin,
137 bitset_t *src_vmask, 77 unsigned long *src_vmask,
138 bitset_t **dst_vmask); 78 unsigned long **dst_vmask);
139 snd_pcm_sframes_t (*transfer)(snd_pcm_plugin_t *plugin, 79 snd_pcm_sframes_t (*transfer)(snd_pcm_plugin_t *plugin,
140 const snd_pcm_plugin_channel_t *src_channels, 80 const snd_pcm_plugin_channel_t *src_channels,
141 snd_pcm_plugin_channel_t *dst_channels, 81 snd_pcm_plugin_channel_t *dst_channels,
@@ -151,8 +91,8 @@ struct _snd_pcm_plugin {
151 char *buf; 91 char *buf;
152 snd_pcm_uframes_t buf_frames; 92 snd_pcm_uframes_t buf_frames;
153 snd_pcm_plugin_channel_t *buf_channels; 93 snd_pcm_plugin_channel_t *buf_channels;
154 bitset_t *src_vmask; 94 unsigned long *src_vmask;
155 bitset_t *dst_vmask; 95 unsigned long *dst_vmask;
156 char extra_data[0]; 96 char extra_data[0];
157}; 97};
158 98