From 64d27f96cb719cf8b5dae634c4c548049d4ae6bf Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 8 Aug 2007 16:49:08 +0200 Subject: [ALSA] Support 3-bytes 24bit format in PCM OSS emulation Add the support of 3-bytes 24bit formats in PCM OSS emulation. Also removed snd_pcm_build_linear_format() function. It's exported just for OSS emulation, and now the code was changed without calling this function. Signed-off-by: Takashi Iwai Signed-off-by: Jaroslav Kysela --- sound/core/pcm_misc.c | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'sound/core/pcm_misc.c') diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 0019c59a779..9142fce4dda 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -422,38 +422,6 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int EXPORT_SYMBOL(snd_pcm_format_set_silence); -/* [width][unsigned][bigendian] */ -static int linear_formats[4][2][2] = { - {{ SNDRV_PCM_FORMAT_S8, SNDRV_PCM_FORMAT_S8}, - { SNDRV_PCM_FORMAT_U8, SNDRV_PCM_FORMAT_U8}}, - {{SNDRV_PCM_FORMAT_S16_LE, SNDRV_PCM_FORMAT_S16_BE}, - {SNDRV_PCM_FORMAT_U16_LE, SNDRV_PCM_FORMAT_U16_BE}}, - {{SNDRV_PCM_FORMAT_S24_LE, SNDRV_PCM_FORMAT_S24_BE}, - {SNDRV_PCM_FORMAT_U24_LE, SNDRV_PCM_FORMAT_U24_BE}}, - {{SNDRV_PCM_FORMAT_S32_LE, SNDRV_PCM_FORMAT_S32_BE}, - {SNDRV_PCM_FORMAT_U32_LE, SNDRV_PCM_FORMAT_U32_BE}} -}; - -/** - * snd_pcm_build_linear_format - return the suitable linear format for the given condition - * @width: the bit-width - * @unsignd: 1 if unsigned, 0 if signed. - * @big_endian: 1 if big-endian, 0 if little-endian - * - * Returns the suitable linear format for the given condition. - */ -snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian) -{ - if (width & 7) - return SND_PCM_FORMAT_UNKNOWN; - width = (width / 8) - 1; - if (width < 0 || width >= 4) - return SND_PCM_FORMAT_UNKNOWN; - return linear_formats[width][!!unsignd][!!big_endian]; -} - -EXPORT_SYMBOL(snd_pcm_build_linear_format); - /** * snd_pcm_limit_hw_rates - determine rate_min/rate_max fields * @runtime: the runtime instance -- cgit v1.2.3 From 7653d557606c7cae921557a6a0ebb7c510e458eb Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 13 Aug 2007 17:38:54 +0200 Subject: [ALSA] pcm: merge rates[] from pcm_misc.c and pcm_native.c Merge the rates[] arrays from pcm_misc.c and pcm_native.c because they are both the same. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela --- sound/core/pcm_misc.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'sound/core/pcm_misc.c') diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 9142fce4dda..afd1e492975 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -433,21 +433,16 @@ EXPORT_SYMBOL(snd_pcm_format_set_silence); */ int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) { - static unsigned rates[] = { - /* ATTENTION: these values depend on the definition in pcm.h! */ - 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, - 64000, 88200, 96000, 176400, 192000 - }; int i; - for (i = 0; i < (int)ARRAY_SIZE(rates); i++) { + for (i = 0; i < (int)snd_pcm_known_rates.count; i++) { if (runtime->hw.rates & (1 << i)) { - runtime->hw.rate_min = rates[i]; + runtime->hw.rate_min = snd_pcm_known_rates.list[i]; break; } } - for (i = (int)ARRAY_SIZE(rates) - 1; i >= 0; i--) { + for (i = (int)snd_pcm_known_rates.count - 1; i >= 0; i--) { if (runtime->hw.rates & (1 << i)) { - runtime->hw.rate_max = rates[i]; + runtime->hw.rate_max = snd_pcm_known_rates.list[i]; break; } } -- cgit v1.2.3 From 918f3a0e8cf67b5db966516f255eaf24d814fac0 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 13 Aug 2007 17:40:54 +0200 Subject: [ALSA] pcm: add snd_pcm_rate_to_rate_bit() helper Add a snd_pcm_rate_to_rate_bit() function to factor out common code used by several drivers. Signed-off-by: Clemens Ladisch Signed-off-by: Jaroslav Kysela --- sound/core/pcm_misc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sound/core/pcm_misc.c') diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index afd1e492975..e5f25ae73ee 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -450,3 +450,21 @@ int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) } EXPORT_SYMBOL(snd_pcm_limit_hw_rates); + +/** + * snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit + * @rate: the sample rate to convert + * + * Returns the SNDRV_PCM_RATE_xxx flag that corresponds to the given rate, or + * SNDRV_PCM_RATE_KNOT for an unknown rate. + */ +unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate) +{ + unsigned int i; + + for (i = 0; i < snd_pcm_known_rates.count; i++) + if (snd_pcm_known_rates.list[i] == rate) + return 1u << i; + return SNDRV_PCM_RATE_KNOT; +} +EXPORT_SYMBOL(snd_pcm_rate_to_rate_bit); -- cgit v1.2.3 From c1017a4cdb68ae5368fbc9ee42c77f1f5dca8916 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 15 Oct 2007 09:50:19 +0200 Subject: [ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz Signed-off-by: Jaroslav Kysela --- sound/core/pcm_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/core/pcm_misc.c') diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index e5f25ae73ee..dd9aa51d8c8 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -1,6 +1,6 @@ /* * PCM Interface - misc routines - * Copyright (c) 1998 by Jaroslav Kysela + * Copyright (c) 1998 by Jaroslav Kysela * * * This library is free software; you can redistribute it and/or modify -- cgit v1.2.3