summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 10:18:00 +0100
committerJaroslav Kysela <perex@suse.cz>2006-01-03 12:16:33 +0100
commit47eaebfd31610d2a55fbaccd1e7c37690d42ce30 (patch)
treed86d90a3741e09cf660aef3dda96566ff68778eb /sound/core
parent230b5c1a612ae903c560b55a15df287b0ff437ea (diff)
downloadblackbird-op-linux-47eaebfd31610d2a55fbaccd1e7c37690d42ce30.tar.gz
blackbird-op-linux-47eaebfd31610d2a55fbaccd1e7c37690d42ce30.zip
[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')
-rw-r--r--sound/core/oss/io.c4
-rw-r--r--sound/core/oss/pcm_plugin.c54
-rw-r--r--sound/core/oss/pcm_plugin.h78
-rw-r--r--sound/core/oss/rate.c2
-rw-r--r--sound/core/oss/route.c28
5 files changed, 53 insertions, 113 deletions
diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c
index bb1c99a5b734..63eca9aec961 100644
--- a/sound/core/oss/io.c
+++ b/sound/core/oss/io.c
@@ -37,7 +37,7 @@
static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_channel_t *src_channels,
- snd_pcm_plugin_channel_t *dst_channels ATTRIBUTE_UNUSED,
+ snd_pcm_plugin_channel_t *dst_channels,
snd_pcm_uframes_t frames)
{
snd_assert(plugin != NULL, return -ENXIO);
@@ -59,7 +59,7 @@ static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin,
}
static snd_pcm_sframes_t io_capture_transfer(snd_pcm_plugin_t *plugin,
- const snd_pcm_plugin_channel_t *src_channels ATTRIBUTE_UNUSED,
+ const snd_pcm_plugin_channel_t *src_channels,
snd_pcm_plugin_channel_t *dst_channels,
snd_pcm_uframes_t frames)
{
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index fc23373c000d..312ae1f2bfc3 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -37,21 +37,21 @@
#define snd_pcm_plug_last(plug) ((plug)->runtime->oss.plugin_last)
static int snd_pcm_plugin_src_channels_mask(snd_pcm_plugin_t *plugin,
- bitset_t *dst_vmask,
- bitset_t **src_vmask)
+ unsigned long *dst_vmask,
+ unsigned long **src_vmask)
{
- bitset_t *vmask = plugin->src_vmask;
- bitset_copy(vmask, dst_vmask, plugin->src_format.channels);
+ unsigned long *vmask = plugin->src_vmask;
+ bitmap_copy(vmask, dst_vmask, plugin->src_format.channels);
*src_vmask = vmask;
return 0;
}
static int snd_pcm_plugin_dst_channels_mask(snd_pcm_plugin_t *plugin,
- bitset_t *src_vmask,
- bitset_t **dst_vmask)
+ unsigned long *src_vmask,
+ unsigned long **dst_vmask)
{
- bitset_t *vmask = plugin->dst_vmask;
- bitset_copy(vmask, src_vmask, plugin->dst_format.channels);
+ unsigned long *vmask = plugin->dst_vmask;
+ bitmap_copy(vmask, src_vmask, plugin->dst_format.channels);
*dst_vmask = vmask;
return 0;
}
@@ -193,12 +193,12 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug,
snd_pcm_plugin_free(plugin);
return -ENOMEM;
}
- plugin->src_vmask = bitset_alloc(src_format->channels);
+ plugin->src_vmask = bitmap_alloc(src_format->channels);
if (plugin->src_vmask == NULL) {
snd_pcm_plugin_free(plugin);
return -ENOMEM;
}
- plugin->dst_vmask = bitset_alloc(dst_format->channels);
+ plugin->dst_vmask = bitmap_alloc(dst_format->channels);
if (plugin->dst_vmask == NULL) {
snd_pcm_plugin_free(plugin);
return -ENOMEM;
@@ -651,18 +651,18 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(snd_pcm_plug_t *plug,
}
static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug,
- bitset_t *client_vmask)
+ unsigned long *client_vmask)
{
snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug);
if (plugin == NULL) {
return 0;
} else {
int schannels = plugin->dst_format.channels;
- bitset_t bs[bitset_size(schannels)];
- bitset_t *srcmask;
- bitset_t *dstmask = bs;
+ DECLARE_BITMAP(bs, schannels);
+ unsigned long *srcmask;
+ unsigned long *dstmask = bs;
int err;
- bitset_one(dstmask, schannels);
+ bitmap_fill(dstmask, schannels);
while (1) {
err = plugin->src_channels_mask(plugin, dstmask, &srcmask);
@@ -673,7 +673,7 @@ static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug,
break;
plugin = plugin->prev;
}
- bitset_and(client_vmask, dstmask, plugin->src_format.channels);
+ bitmap_and(client_vmask, client_vmask, dstmask, plugin->src_format.channels);
return 0;
}
}
@@ -683,21 +683,21 @@ static int snd_pcm_plug_playback_disable_useless_channels(snd_pcm_plug_t *plug,
{
snd_pcm_plugin_t *plugin = snd_pcm_plug_first(plug);
unsigned int nchannels = plugin->src_format.channels;
- bitset_t bs[bitset_size(nchannels)];
- bitset_t *srcmask = bs;
+ DECLARE_BITMAP(bs, nchannels);
+ unsigned long *srcmask = bs;
int err;
unsigned int channel;
for (channel = 0; channel < nchannels; channel++) {
if (src_channels[channel].enabled)
- bitset_set(srcmask, channel);
+ set_bit(channel, srcmask);
else
- bitset_reset(srcmask, channel);
+ clear_bit(channel, srcmask);
}
err = snd_pcm_plug_playback_channels_mask(plug, srcmask);
if (err < 0)
return err;
for (channel = 0; channel < nchannels; channel++) {
- if (!bitset_get(srcmask, channel))
+ if (!test_bit(channel, srcmask))
src_channels[channel].enabled = 0;
}
return 0;
@@ -709,16 +709,16 @@ static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug,
{
snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug);
unsigned int nchannels = plugin->dst_format.channels;
- bitset_t bs[bitset_size(nchannels)];
- bitset_t *dstmask = bs;
- bitset_t *srcmask;
+ DECLARE_BITMAP(bs, nchannels);
+ unsigned long *dstmask = bs;
+ unsigned long *srcmask;
int err;
unsigned int channel;
for (channel = 0; channel < nchannels; channel++) {
if (client_channels[channel].enabled)
- bitset_set(dstmask, channel);
+ set_bit(channel, dstmask);
else
- bitset_reset(dstmask, channel);
+ clear_bit(channel, dstmask);
}
while (plugin) {
err = plugin->src_channels_mask(plugin, dstmask, &srcmask);
@@ -730,7 +730,7 @@ static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug,
plugin = snd_pcm_plug_first(plug);
nchannels = plugin->src_format.channels;
for (channel = 0; channel < nchannels; channel++) {
- if (!bitset_get(dstmask, channel))
+ if (!test_bit(channel, dstmask))
src_channels[channel].enabled = 0;
}
return 0;
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 @@
*
*/
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
-#endif
-
-typedef unsigned int bitset_t;
-
-static inline size_t bitset_size(int nbits)
-{
- return (nbits + sizeof(bitset_t) * 8 - 1) / (sizeof(bitset_t) * 8);
-}
-
-static inline bitset_t *bitset_alloc(int nbits)
-{
- return kcalloc(bitset_size(nbits), sizeof(bitset_t), GFP_KERNEL);
-}
-
-static inline void bitset_set(bitset_t *bitmap, unsigned int pos)
-{
- size_t bits = sizeof(*bitmap) * 8;
- bitmap[pos / bits] |= 1 << (pos % bits);
-}
-
-static inline void bitset_reset(bitset_t *bitmap, unsigned int pos)
-{
- size_t bits = sizeof(*bitmap) * 8;
- bitmap[pos / bits] &= ~(1 << (pos % bits));
-}
-
-static inline int bitset_get(bitset_t *bitmap, unsigned int pos)
-{
- size_t bits = sizeof(*bitmap) * 8;
- return !!(bitmap[pos / bits] & (1 << (pos % bits)));
-}
-
-static inline void bitset_copy(bitset_t *dst, bitset_t *src, unsigned int nbits)
-{
- memcpy(dst, src, bitset_size(nbits) * sizeof(bitset_t));
-}
-
-static inline void bitset_and(bitset_t *dst, bitset_t *bs, unsigned int nbits)
-{
- bitset_t *end = dst + bitset_size(nbits);
- while (dst < end)
- *dst++ &= *bs++;
-}
-
-static inline void bitset_or(bitset_t *dst, bitset_t *bs, unsigned int nbits)
-{
- bitset_t *end = dst + bitset_size(nbits);
- while (dst < end)
- *dst++ |= *bs++;
-}
-
-static inline void bitset_zero(bitset_t *dst, unsigned int nbits)
-{
- bitset_t *end = dst + bitset_size(nbits);
- while (dst < end)
- *dst++ = 0;
-}
+#include <linux/bitmap.h>
-static inline void bitset_one(bitset_t *dst, unsigned int nbits)
+static inline unsigned long *bitmap_alloc(unsigned int nbits)
{
- bitset_t *end = dst + bitset_size(nbits);
- while (dst < end)
- *dst++ = ~(bitset_t)0;
+ return kmalloc(BITS_TO_LONGS(nbits), GFP_KERNEL);
}
#define snd_pcm_plug_t snd_pcm_substream_t
@@ -131,11 +71,11 @@ struct _snd_pcm_plugin {
snd_pcm_uframes_t frames,
snd_pcm_plugin_channel_t **channels);
int (*src_channels_mask)(snd_pcm_plugin_t *plugin,
- bitset_t *dst_vmask,
- bitset_t **src_vmask);
+ unsigned long *dst_vmask,
+ unsigned long **src_vmask);
int (*dst_channels_mask)(snd_pcm_plugin_t *plugin,
- bitset_t *src_vmask,
- bitset_t **dst_vmask);
+ unsigned long *src_vmask,
+ unsigned long **dst_vmask);
snd_pcm_sframes_t (*transfer)(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_channel_t *src_channels,
snd_pcm_plugin_channel_t *dst_channels,
@@ -151,8 +91,8 @@ struct _snd_pcm_plugin {
char *buf;
snd_pcm_uframes_t buf_frames;
snd_pcm_plugin_channel_t *buf_channels;
- bitset_t *src_vmask;
- bitset_t *dst_vmask;
+ unsigned long *src_vmask;
+ unsigned long *dst_vmask;
char extra_data[0];
};
diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c
index 1096ec186714..7e325ca58706 100644
--- a/sound/core/oss/rate.c
+++ b/sound/core/oss/rate.c
@@ -315,7 +315,7 @@ static snd_pcm_sframes_t rate_transfer(snd_pcm_plugin_t *plugin,
static int rate_action(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_action_t action,
- unsigned long udata ATTRIBUTE_UNUSED)
+ unsigned long udata)
{
snd_assert(plugin != NULL, return -ENXIO);
switch (action) {
diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c
index c955b7dfdb30..7519aed757cd 100644
--- a/sound/core/oss/route.c
+++ b/sound/core/oss/route.c
@@ -70,9 +70,9 @@ typedef union {
static void route_to_channel_from_zero(snd_pcm_plugin_t *plugin,
- const snd_pcm_plugin_channel_t *src_channels ATTRIBUTE_UNUSED,
+ const snd_pcm_plugin_channel_t *src_channels,
snd_pcm_plugin_channel_t *dst_channel,
- ttable_dst_t* ttable ATTRIBUTE_UNUSED, snd_pcm_uframes_t frames)
+ ttable_dst_t* ttable, snd_pcm_uframes_t frames)
{
if (dst_channel->wanted)
snd_pcm_area_silence(&dst_channel->area, 0, frames, plugin->dst_format.format);
@@ -298,46 +298,46 @@ static void route_to_channel(snd_pcm_plugin_t *plugin,
}
static int route_src_channels_mask(snd_pcm_plugin_t *plugin,
- bitset_t *dst_vmask,
- bitset_t **src_vmask)
+ unsigned long *dst_vmask,
+ unsigned long **src_vmask)
{
route_t *data = (route_t *)plugin->extra_data;
int schannels = plugin->src_format.channels;
int dchannels = plugin->dst_format.channels;
- bitset_t *vmask = plugin->src_vmask;
+ unsigned long *vmask = plugin->src_vmask;
int channel;
ttable_dst_t *dp = data->ttable;
- bitset_zero(vmask, schannels);
+ bitmap_zero(vmask, schannels);
for (channel = 0; channel < dchannels; channel++, dp++) {
unsigned int src;
ttable_src_t *sp;
- if (!bitset_get(dst_vmask, channel))
+ if (!test_bit(channel, dst_vmask))
continue;
sp = dp->srcs;
for (src = 0; src < dp->nsrcs; src++, sp++)
- bitset_set(vmask, sp->channel);
+ set_bit(sp->channel, vmask);
}
*src_vmask = vmask;
return 0;
}
static int route_dst_channels_mask(snd_pcm_plugin_t *plugin,
- bitset_t *src_vmask,
- bitset_t **dst_vmask)
+ unsigned long *src_vmask,
+ unsigned long **dst_vmask)
{
route_t *data = (route_t *)plugin->extra_data;
int dchannels = plugin->dst_format.channels;
- bitset_t *vmask = plugin->dst_vmask;
+ unsigned long *vmask = plugin->dst_vmask;
int channel;
ttable_dst_t *dp = data->ttable;
- bitset_zero(vmask, dchannels);
+ bitmap_zero(vmask, dchannels);
for (channel = 0; channel < dchannels; channel++, dp++) {
unsigned int src;
ttable_src_t *sp;
sp = dp->srcs;
for (src = 0; src < dp->nsrcs; src++, sp++) {
- if (bitset_get(src_vmask, sp->channel)) {
- bitset_set(vmask, channel);
+ if (test_bit(sp->channel, src_vmask)) {
+ set_bit(channel, vmask);
break;
}
}
OpenPOWER on IntegriCloud