Skip to content

Commit

Permalink
audio: remove lsbindex/popcount in favour of host-utils's ctz32
Browse files Browse the repository at this point in the history
Signed-off-by: malc <[email protected]>
  • Loading branch information
malc committed Sep 11, 2009
1 parent 8b438ba commit 057fa65
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
17 changes: 0 additions & 17 deletions audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,6 @@ struct mixeng_volume nominal_volume = {
#endif
};

/* http://www.df.lth.se/~john_e/gems/gem002d.html */
/* http://www.multi-platforms.com/Tips/PopCount.htm */
uint32_t popcount (uint32_t u)
{
u = ((u&0x55555555) + ((u>>1)&0x55555555));
u = ((u&0x33333333) + ((u>>2)&0x33333333));
u = ((u&0x0f0f0f0f) + ((u>>4)&0x0f0f0f0f));
u = ((u&0x00ff00ff) + ((u>>8)&0x00ff00ff));
u = ( u&0x0000ffff) + (u>>16);
return u;
}

inline uint32_t lsbindex (uint32_t u)
{
return popcount ((u&-u)-1);
}

#ifdef AUDIO_IS_FLAWLESS_AND_NO_CHECKS_ARE_REQURIED
#error No its not
#else
Expand Down
3 changes: 0 additions & 3 deletions audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ static inline void *advance (void *p, int incr)
return (d + incr);
}

uint32_t popcount (uint32_t u);
uint32_t lsbindex (uint32_t u);

#ifdef __GNUC__
#define audio_MIN(a, b) ( __extension__ ({ \
__typeof (a) ta = a; \
Expand Down
3 changes: 2 additions & 1 deletion audio/ossaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <sys/soundcard.h>
#endif
#include "qemu-common.h"
#include "host-utils.h"
#include "qemu-char.h"
#include "audio.h"

Expand Down Expand Up @@ -273,7 +274,7 @@ static int oss_open (int in, struct oss_params *req,
goto err;
}

mmmmssss = (req->nfrags << 16) | lsbindex (req->fragsize);
mmmmssss = (req->nfrags << 16) | ctz32 (req->fragsize);
if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) {
oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n",
req->nfrags, req->fragsize);
Expand Down
5 changes: 3 additions & 2 deletions hw/sb16.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "isa.h"
#include "qdev.h"
#include "qemu-timer.h"
#include "host-utils.h"

#define dolog(...) AUD_log ("sb16", __VA_ARGS__)

Expand Down Expand Up @@ -1092,8 +1093,8 @@ static IO_WRITE_PROTO (mixer_write_datab)
{
int dma, hdma;

dma = lsbindex (val & 0xf);
hdma = lsbindex (val & 0xf0);
dma = ctz32 (val & 0xf);
hdma = ctz32 (val & 0xf0);
if (dma != s->dma || hdma != s->hdma) {
dolog (
"attempt to change DMA "
Expand Down

0 comments on commit 057fa65

Please sign in to comment.