Commit 0534ab42 authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] Clean up pcm-oss plugins

Modules: ALSA<-OSS emulation

Clean up pcm-oss plugin codes.
Removed dead codes, and simplified route/rate plugins.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9d83911a
......@@ -106,7 +106,7 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
return frames;
}
int conv_index(int src_format, int dst_format)
static int conv_index(int src_format, int dst_format)
{
int src_endian, dst_endian, sign, src_width, dst_width;
......
......@@ -265,6 +265,25 @@ static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin,
return frames;
}
static int getput_index(int format)
{
int sign, width, endian;
sign = !snd_pcm_format_signed(format);
width = snd_pcm_format_width(format) / 8 - 1;
if (width < 0 || width > 3) {
snd_printk(KERN_ERR "snd-pcm-oss: invalid format %d\n", format);
width = 0;
}
#ifdef SNDRV_LITTLE_ENDIAN
endian = snd_pcm_format_big_endian(format);
#else
endian = snd_pcm_format_little_endian(format);
#endif
if (endian < 0)
endian = 0;
return width * 4 + endian * 2 + sign;
}
int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug,
struct snd_pcm_plugin_format *src_format,
struct snd_pcm_plugin_format *dst_format,
......
This diff is collapsed.
......@@ -24,13 +24,6 @@
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
#include <linux/bitmap.h>
static inline unsigned long *bitmap_alloc(unsigned int nbits)
{
return kmalloc(BITS_TO_LONGS(nbits), GFP_KERNEL);
}
#define snd_pcm_plug_stream(plug) ((plug)->stream)
enum snd_pcm_plugin_action {
......@@ -71,12 +64,6 @@ struct snd_pcm_plugin {
snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin,
snd_pcm_uframes_t frames,
struct snd_pcm_plugin_channel **channels);
int (*src_channels_mask)(struct snd_pcm_plugin *plugin,
unsigned long *dst_vmask,
unsigned long **src_vmask);
int (*dst_channels_mask)(struct snd_pcm_plugin *plugin,
unsigned long *src_vmask,
unsigned long **dst_vmask);
snd_pcm_sframes_t (*transfer)(struct snd_pcm_plugin *plugin,
const struct snd_pcm_plugin_channel *src_channels,
struct snd_pcm_plugin_channel *dst_channels,
......@@ -92,8 +79,6 @@ struct snd_pcm_plugin {
char *buf;
snd_pcm_uframes_t buf_frames;
struct snd_pcm_plugin_channel *buf_channels;
unsigned long *src_vmask;
unsigned long *dst_vmask;
char extra_data[0];
};
......@@ -130,7 +115,6 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *handle,
int snd_pcm_plugin_build_route(struct snd_pcm_substream *handle,
struct snd_pcm_plugin_format *src_format,
struct snd_pcm_plugin_format *dst_format,
int *ttable,
struct snd_pcm_plugin **r_plugin);
int snd_pcm_plugin_build_copy(struct snd_pcm_substream *handle,
struct snd_pcm_plugin_format *src_format,
......@@ -183,16 +167,6 @@ snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream,
void **bufs, snd_pcm_uframes_t frames,
int in_kernel);
#define ROUTE_PLUGIN_RESOLUTION 16
int getput_index(int format);
int copy_index(int format);
int conv_index(int src_format, int dst_format);
void zero_channel(struct snd_pcm_plugin *plugin,
const struct snd_pcm_plugin_channel *dst_channel,
size_t samples);
#else
static inline snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size) { return drv_size; }
......
......@@ -362,172 +362,6 @@ put_s16_xx12_0029: as_u32(dst) = (u_int32_t)swab16(sample) ^ 0x80; goto PUT_S16_
}
#endif
#if 0
#ifdef GET32_LABELS
/* src_wid src_endswap unsigned */
static void *get32_labels[4 * 2 * 2] = {
&&get32_xxx1_1000, /* 8h -> 32h */
&&get32_xxx1_9000, /* 8h ^> 32h */
&&get32_xxx1_1000, /* 8s -> 32h */
&&get32_xxx1_9000, /* 8s ^> 32h */
&&get32_xx12_1200, /* 16h -> 32h */
&&get32_xx12_9200, /* 16h ^> 32h */
&&get32_xx12_2100, /* 16s -> 32h */
&&get32_xx12_A100, /* 16s ^> 32h */
&&get32_x123_1230, /* 24h -> 32h */
&&get32_x123_9230, /* 24h ^> 32h */
&&get32_123x_3210, /* 24s -> 32h */
&&get32_123x_B210, /* 24s ^> 32h */
&&get32_1234_1234, /* 32h -> 32h */
&&get32_1234_9234, /* 32h ^> 32h */
&&get32_1234_4321, /* 32s -> 32h */
&&get32_1234_C321, /* 32s ^> 32h */
};
#endif
#ifdef GET32_END
while (0) {
get32_xxx1_1000: sample = (u_int32_t)as_u8(src) << 24; goto GET32_END;
get32_xxx1_9000: sample = (u_int32_t)(as_u8(src) ^ 0x80) << 24; goto GET32_END;
get32_xx12_1200: sample = (u_int32_t)as_u16(src) << 16; goto GET32_END;
get32_xx12_9200: sample = (u_int32_t)(as_u16(src) ^ 0x8000) << 16; goto GET32_END;
get32_xx12_2100: sample = (u_int32_t)swab16(as_u16(src)) << 16; goto GET32_END;
get32_xx12_A100: sample = (u_int32_t)swab16(as_u16(src) ^ 0x80) << 16; goto GET32_END;
get32_x123_1230: sample = as_u32(src) << 8; goto GET32_END;
get32_x123_9230: sample = (as_u32(src) << 8) ^ 0x80000000; goto GET32_END;
get32_123x_3210: sample = swab32(as_u32(src) >> 8); goto GET32_END;
get32_123x_B210: sample = swab32((as_u32(src) >> 8) ^ 0x80); goto GET32_END;
get32_1234_1234: sample = as_u32(src); goto GET32_END;
get32_1234_9234: sample = as_u32(src) ^ 0x80000000; goto GET32_END;
get32_1234_4321: sample = swab32(as_u32(src)); goto GET32_END;
get32_1234_C321: sample = swab32(as_u32(src) ^ 0x80); goto GET32_END;
}
#endif
#endif
#ifdef PUT_U32_LABELS
/* dst_wid dst_endswap unsigned */
static void *put_u32_labels[4 * 2 * 2] = {
&&put_u32_1234_xxx9, /* u32h -> s8h */
&&put_u32_1234_xxx1, /* u32h -> u8h */
&&put_u32_1234_xxx9, /* u32h -> s8s */
&&put_u32_1234_xxx1, /* u32h -> u8s */
&&put_u32_1234_xx92, /* u32h -> s16h */
&&put_u32_1234_xx12, /* u32h -> u16h */
&&put_u32_1234_xx29, /* u32h -> s16s */
&&put_u32_1234_xx21, /* u32h -> u16s */
&&put_u32_1234_x923, /* u32h -> s24h */
&&put_u32_1234_x123, /* u32h -> u24h */
&&put_u32_1234_329x, /* u32h -> s24s */
&&put_u32_1234_321x, /* u32h -> u24s */
&&put_u32_1234_9234, /* u32h -> s32h */
&&put_u32_1234_1234, /* u32h -> u32h */
&&put_u32_1234_4329, /* u32h -> s32s */
&&put_u32_1234_4321, /* u32h -> u32s */
};
#endif
#ifdef PUT_U32_END
while (0) {
put_u32_1234_xxx1: as_u8(dst) = sample >> 24; goto PUT_U32_END;
put_u32_1234_xxx9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT_U32_END;
put_u32_1234_xx12: as_u16(dst) = sample >> 16; goto PUT_U32_END;
put_u32_1234_xx92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT_U32_END;
put_u32_1234_xx21: as_u16(dst) = swab16(sample >> 16); goto PUT_U32_END;
put_u32_1234_xx29: as_u16(dst) = swab16(sample >> 16) ^ 0x80; goto PUT_U32_END;
put_u32_1234_x123: as_u32(dst) = sample >> 8; goto PUT_U32_END;
put_u32_1234_x923: as_u32(dst) = (sample >> 8) ^ 0x800000; goto PUT_U32_END;
put_u32_1234_321x: as_u32(dst) = swab32(sample) << 8; goto PUT_U32_END;
put_u32_1234_329x: as_u32(dst) = (swab32(sample) ^ 0x80) << 8; goto PUT_U32_END;
put_u32_1234_1234: as_u32(dst) = sample; goto PUT_U32_END;
put_u32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_U32_END;
put_u32_1234_4321: as_u32(dst) = swab32(sample); goto PUT_U32_END;
put_u32_1234_4329: as_u32(dst) = swab32(sample) ^ 0x80; goto PUT_U32_END;
}
#endif
#ifdef GET_U_LABELS
/* width endswap unsigned*/
static void *get_u_labels[4 * 2 * 2] = {
&&get_u_s8, /* s8 -> u8 */
&&get_u_u8, /* u8 -> u8 */
&&get_u_s8, /* s8 -> u8 */
&&get_u_u8, /* u8 -> u8 */
&&get_u_s16h, /* s16h -> u16h */
&&get_u_u16h, /* u16h -> u16h */
&&get_u_s16s, /* s16s -> u16h */
&&get_u_u16s, /* u16s -> u16h */
&&get_u_s24h, /* s24h -> u32h */
&&get_u_u24h, /* u24h -> u32h */
&&get_u_s24s, /* s24s -> u32h */
&&get_u_u24s, /* u24s -> u32h */
&&get_u_s32h, /* s32h -> u32h */
&&get_u_u32h, /* u32h -> u32h */
&&get_u_s32s, /* s32s -> u32h */
&&get_u_u32s, /* u32s -> u32h */
};
#endif
#ifdef GET_U_END
while (0) {
get_u_s8: sample = as_u8(src) ^ 0x80; goto GET_U_END;
get_u_u8: sample = as_u8(src); goto GET_U_END;
get_u_s16h: sample = as_u16(src) ^ 0x8000; goto GET_U_END;
get_u_u16h: sample = as_u16(src); goto GET_U_END;
get_u_s16s: sample = swab16(as_u16(src) ^ 0x80); goto GET_U_END;
get_u_u16s: sample = swab16(as_u16(src)); goto GET_U_END;
get_u_s24h: sample = (as_u32(src) ^ 0x800000); goto GET_U_END;
get_u_u24h: sample = as_u32(src); goto GET_U_END;
get_u_s24s: sample = swab32(as_u32(src) ^ 0x800000); goto GET_U_END;
get_u_u24s: sample = swab32(as_u32(src)); goto GET_U_END;
get_u_s32h: sample = as_u32(src) ^ 0x80000000; goto GET_U_END;
get_u_u32h: sample = as_u32(src); goto GET_U_END;
get_u_s32s: sample = swab32(as_u32(src) ^ 0x80); goto GET_U_END;
get_u_u32s: sample = swab32(as_u32(src)); goto GET_U_END;
}
#endif
#if 0
#ifdef PUT_LABELS
/* width endswap unsigned */
static void *put_labels[4 * 2 * 2] = {
&&put_s8, /* s8 -> s8 */
&&put_u8, /* u8 -> s8 */
&&put_s8, /* s8 -> s8 */
&&put_u8, /* u8 -> s8 */
&&put_s16h, /* s16h -> s16h */
&&put_u16h, /* u16h -> s16h */
&&put_s16s, /* s16s -> s16h */
&&put_u16s, /* u16s -> s16h */
&&put_s24h, /* s24h -> s32h */
&&put_u24h, /* u24h -> s32h */
&&put_s24s, /* s24s -> s32h */
&&put_u24s, /* u24s -> s32h */
&&put_s32h, /* s32h -> s32h */
&&put_u32h, /* u32h -> s32h */
&&put_s32s, /* s32s -> s32h */
&&put_u32s, /* u32s -> s32h */
};
#endif
#ifdef PUT_END
put_s8: as_s8(dst) = sample; goto PUT_END;
put_u8: as_u8(dst) = sample ^ 0x80; goto PUT_END;
put_s16h: as_s16(dst) = sample; goto PUT_END;
put_u16h: as_u16(dst) = sample ^ 0x8000; goto PUT_END;
put_s16s: as_s16(dst) = swab16(sample); goto PUT_END;
put_u16s: as_u16(dst) = swab16(sample ^ 0x80); goto PUT_END;
put_s24h: as_s24(dst) = sample & 0xffffff; goto PUT_END;
put_u24h: as_u24(dst) = sample ^ 0x80000000; goto PUT_END;
put_s24s: as_s24(dst) = swab32(sample & 0xffffff); goto PUT_END;
put_u24s: as_u24(dst) = swab32(sample ^ 0x80); goto PUT_END;
put_s32h: as_s32(dst) = sample; goto PUT_END;
put_u32h: as_u32(dst) = sample ^ 0x80000000; goto PUT_END;
put_s32s: as_s32(dst) = swab32(sample); goto PUT_END;
put_u32s: as_u32(dst) = swab32(sample ^ 0x80); goto PUT_END;
#endif
#endif
#undef as_u8
#undef as_u16
#undef as_u32
......
......@@ -50,7 +50,6 @@ struct rate_priv {
unsigned int pitch;
unsigned int pos;
rate_f func;
int get, put;
snd_pcm_sframes_t old_src_frames, old_dst_frames;
struct rate_channel channels[0];
};
......@@ -74,21 +73,12 @@ static void resample_expand(struct snd_pcm_plugin *plugin,
unsigned int pos = 0;
signed int val;
signed short S1, S2;
char *src, *dst;
signed short *src, *dst;
unsigned int channel;
int src_step, dst_step;
int src_frames1, dst_frames1;
struct rate_priv *data = (struct rate_priv *)plugin->extra_data;
struct rate_channel *rchannels = data->channels;
#define GET_S16_LABELS
#define PUT_S16_LABELS
#include "plugin_ops.h"
#undef GET_S16_LABELS
#undef PUT_S16_LABELS
void *get = get_s16_labels[data->get];
void *put = put_s16_labels[data->put];
signed short sample = 0;
for (channel = 0; channel < plugin->src_format.channels; channel++) {
pos = data->pos;
......@@ -101,10 +91,12 @@ static void resample_expand(struct snd_pcm_plugin *plugin,
continue;
}
dst_channels[channel].enabled = 1;
src = (char *)src_channels[channel].area.addr + src_channels[channel].area.first / 8;
dst = (char *)dst_channels[channel].area.addr + dst_channels[channel].area.first / 8;
src_step = src_channels[channel].area.step / 8;
dst_step = dst_channels[channel].area.step / 8;
src = (signed short *)src_channels[channel].area.addr +
src_channels[channel].area.first / 8 / 2;
dst = (signed short *)dst_channels[channel].area.addr +
dst_channels[channel].area.first / 8 / 2;
src_step = src_channels[channel].area.step / 8 / 2;
dst_step = dst_channels[channel].area.step / 8 / 2;
src_frames1 = src_frames;
dst_frames1 = dst_frames;
while (dst_frames1-- > 0) {
......@@ -112,12 +104,7 @@ static void resample_expand(struct snd_pcm_plugin *plugin,
pos &= R_MASK;
S1 = S2;
if (src_frames1-- > 0) {
goto *get;
#define GET_S16_END after_get
#include "plugin_ops.h"
#undef GET_S16_END
after_get:
S2 = sample;
S2 = *src;
src += src_step;
}
}
......@@ -126,12 +113,7 @@ static void resample_expand(struct snd_pcm_plugin *plugin,
val = -32768;
else if (val > 32767)
val = 32767;
sample = val;
goto *put;
#define PUT_S16_END after_put
#include "plugin_ops.h"
#undef PUT_S16_END
after_put:
*dst = val;
dst += dst_step;
pos += data->pitch;
}
......@@ -150,21 +132,12 @@ static void resample_shrink(struct snd_pcm_plugin *plugin,
unsigned int pos = 0;
signed int val;
signed short S1, S2;
char *src, *dst;
signed short *src, *dst;
unsigned int channel;
int src_step, dst_step;
int src_frames1, dst_frames1;
struct rate_priv *data = (struct rate_priv *)plugin->extra_data;
struct rate_channel *rchannels = data->channels;
#define GET_S16_LABELS
#define PUT_S16_LABELS
#include "plugin_ops.h"
#undef GET_S16_LABELS
#undef PUT_S16_LABELS
void *get = get_s16_labels[data->get];
void *put = put_s16_labels[data->put];
signed short sample = 0;
for (channel = 0; channel < plugin->src_format.channels; ++channel) {
pos = data->pos;
......@@ -177,21 +150,18 @@ static void resample_shrink(struct snd_pcm_plugin *plugin,
continue;
}
dst_channels[channel].enabled = 1;
src = (char *)src_channels[channel].area.addr + src_channels[channel].area.first / 8;
dst = (char *)dst_channels[channel].area.addr + dst_channels[channel].area.first / 8;
src_step = src_channels[channel].area.step / 8;
dst_step = dst_channels[channel].area.step / 8;
src = (signed short *)src_channels[channel].area.addr +
src_channels[channel].area.first / 8 / 2;
dst = (signed short *)dst_channels[channel].area.addr +
dst_channels[channel].area.first / 8 / 2;
src_step = src_channels[channel].area.step / 8 / 2;
dst_step = dst_channels[channel].area.step / 8 / 2;
src_frames1 = src_frames;
dst_frames1 = dst_frames;
while (dst_frames1 > 0) {
S1 = S2;
if (src_frames1-- > 0) {
goto *get;
#define GET_S16_END after_get
#include "plugin_ops.h"
#undef GET_S16_END
after_get:
S2 = sample;
S1 = *src;
src += src_step;
}
if (pos & ~R_MASK) {
......@@ -201,12 +171,7 @@ static void resample_shrink(struct snd_pcm_plugin *plugin,
val = -32768;
else if (val > 32767)
val = 32767;
sample = val;
goto *put;
#define PUT_S16_END after_put
#include "plugin_ops.h"
#undef PUT_S16_END
after_put:
*dst = val;
dst += dst_step;
dst_frames1--;
}
......@@ -346,8 +311,8 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug,
snd_assert(src_format->channels == dst_format->channels, return -ENXIO);
snd_assert(src_format->channels > 0, return -ENXIO);
snd_assert(snd_pcm_format_linear(src_format->format) != 0, return -ENXIO);
snd_assert(snd_pcm_format_linear(dst_format->format) != 0, return -ENXIO);
snd_assert(src_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO);
snd_assert(dst_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO);
snd_assert(src_format->rate != dst_format->rate, return -ENXIO);
err = snd_pcm_plugin_build(plug, "rate conversion",
......@@ -358,11 +323,6 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug,
if (err < 0)
return err;
data = (struct rate_priv *)plugin->extra_data;
data->get = getput_index(src_format->format);
snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL);
data->put = getput_index(dst_format->format);
snd_assert(data->put >= 0 && data->put < 4*2*2, return -EINVAL);
if (src_format->rate < dst_format->rate) {
data->pitch = ((src_format->rate << SHIFT) + (dst_format->rate >> 1)) / dst_format->rate;
data->func = resample_expand;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment