diff options
author | Gary King <gking@nvidia.com> | 2010-02-18 15:25:15 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit2@git-master-01.nvidia.com> | 2010-02-18 15:25:15 -0800 |
commit | ddf7bbf798bd6661f33b694c1ce3c4caa78cd030 (patch) | |
tree | 8e03cc708c9da7687956453fb2ad23763c668b87 | |
parent | 67709d7a21cb927f317ad6b35289d1b0ca3d324e (diff) | |
parent | 98b44d09775f5b84a798294bd36666f0e5fb7b82 (diff) |
Merge "Supporting all sample rates and formats in ALSA" into android-tegra-2.6.29
-rw-r--r-- | sound/soc/tegra/tegra_codec_rpc.c | 18 | ||||
-rw-r--r-- | sound/soc/tegra/tegra_i2s.c | 28 | ||||
-rw-r--r-- | sound/soc/tegra/tegra_pcm_rpc.c | 47 | ||||
-rw-r--r-- | sound/soc/tegra/tegra_transport.h | 5 |
4 files changed, 54 insertions, 44 deletions
diff --git a/sound/soc/tegra/tegra_codec_rpc.c b/sound/soc/tegra/tegra_codec_rpc.c index 0e9535bd7d26..c8ee46de89db 100644 --- a/sound/soc/tegra/tegra_codec_rpc.c +++ b/sound/soc/tegra/tegra_codec_rpc.c @@ -26,15 +26,7 @@ #include <sound/pcm.h> #include <sound/initval.h> - -#define CODEC_SAMPLE_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ - SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ - SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\ - SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000) - -#define CODEC_SAMPLE_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ - SNDRV_PCM_FMTBIT_S20_3LE |\ - SNDRV_PCM_FMTBIT_S24_LE) +#include "tegra_transport.h" static int tegra_generic_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, @@ -78,15 +70,15 @@ struct snd_soc_dai dit_stub_dai = { .stream_name = "Playback", .channels_min = 1, .channels_max = 2, - .rates = CODEC_SAMPLE_RATES, - .formats = CODEC_SAMPLE_FORMATS, + .rates = TEGRA_SAMPLE_RATES, + .formats = TEGRA_SAMPLE_FORMATS, }, .capture = { .stream_name = "Capture", .channels_min = 1, .channels_max = 2, - .rates = CODEC_SAMPLE_RATES, - .formats = CODEC_SAMPLE_FORMATS, + .rates = TEGRA_SAMPLE_RATES, + .formats = TEGRA_SAMPLE_FORMATS, }, .ops = { .hw_params = tegra_generic_codec_hw_params, diff --git a/sound/soc/tegra/tegra_i2s.c b/sound/soc/tegra/tegra_i2s.c index 6e672347ae5e..ff3f0619caba 100644 --- a/sound/soc/tegra/tegra_i2s.c +++ b/sound/soc/tegra/tegra_i2s.c @@ -37,7 +37,6 @@ #include "mach/nvrm_linux.h" #include "nvrm_memmgr.h" #include "nvassert.h" - #include "tegra_transport.h" extern struct snd_soc_dai tegra_i2s_rpc_dai; @@ -48,6 +47,10 @@ static int tegra_i2s_rpc_hw_params(struct snd_pcm_substream *substream, { switch (params_rate(params)) { case 8000: + case 11025: + case 16000: + case 22050: + case 24000: case 32000: case 44100: case 48000: @@ -65,25 +68,22 @@ static int tegra_i2s_rpc_probe(struct platform_device *pdev, return 0; } -#define TEGRA_I2S_RATES (SNDRV_PCM_RATE_8000_96000) - struct snd_soc_dai tegra_i2s_rpc_dai = { .name = "tegra-i2s-rpc", .id = 0, .probe = tegra_i2s_rpc_probe, .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = TEGRA_I2S_RATES, - .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | \ - SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ - SNDRV_PCM_FMTBIT_S32_LE,}, + .channels_min = 1, + .channels_max = 2, + .rates = TEGRA_SAMPLE_RATES, + .formats = TEGRA_SAMPLE_FORMATS, + }, .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = TEGRA_I2S_RATES, - .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |\ - SNDRV_PCM_FMTBIT_S32_LE,}, + .channels_min = 1, + .channels_max = 2, + .rates = TEGRA_SAMPLE_RATES, + .formats = TEGRA_SAMPLE_FORMATS, + }, .ops = { .hw_params = tegra_i2s_rpc_hw_params, }, diff --git a/sound/soc/tegra/tegra_pcm_rpc.c b/sound/soc/tegra/tegra_pcm_rpc.c index a913bbf9c12c..e82143b8d717 100644 --- a/sound/soc/tegra/tegra_pcm_rpc.c +++ b/sound/soc/tegra/tegra_pcm_rpc.c @@ -21,21 +21,22 @@ */ #include "tegra_transport.h" + static struct tegra_audio_data* tegra_snd_cx = NULL; static const struct snd_pcm_hardware tegra_pcm_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | + .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE |\ SNDRV_PCM_INFO_RESUME, - .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | - SNDRV_PCM_FMTBIT_S32_LE, - .channels_min = 2, + .rates = TEGRA_SAMPLE_RATES, + .formats = TEGRA_SAMPLE_FORMATS, + .channels_min = 1, .channels_max = 2, - .buffer_bytes_max = 16*1024, - .period_bytes_min = 4*1024, - .period_bytes_max = 4*1024, + .buffer_bytes_max = 32*1024, + .period_bytes_min = TEGRA_DEFAULT_BUFFER_SIZE, + .period_bytes_max = TEGRA_DEFAULT_BUFFER_SIZE, .periods_min = 4, - .periods_max = 4, - .fifo_size = 4, + .periods_max = 8, + .fifo_size = 8, }; @@ -137,16 +138,23 @@ static int play_thread( void *arg) if (buffer_to_prime == buffer_in_queue) { e = NvOsSemaphoreWaitTimeout(prtd->play_sema, - prtd->timeout); + prtd->timeout); if (e != NvSuccess) { snd_printk(KERN_ERR "sema wait Fail\n"); - return -ETIMEDOUT; + goto EXIT; } buffer_in_queue--; - prtd->cur_pos += bytes_to_frames(runtime, - TEGRA_DEFAULT_BUFFER_SIZE); + if ((frames_to_bytes(runtime, prtd->cur_pos) + + TEGRA_DEFAULT_BUFFER_SIZE) > rtbuffersize) { + size = rtbuffersize - + frames_to_bytes(runtime, prtd->cur_pos); + } else { + size = TEGRA_DEFAULT_BUFFER_SIZE; + } + + prtd->cur_pos += bytes_to_frames(runtime, size); if (prtd->cur_pos < prtd->last_pos) { period_offset = (runtime->buffer_size + @@ -159,6 +167,7 @@ static int play_thread( void *arg) if (period_offset >= runtime->period_size) { prtd->last_pos = prtd->cur_pos; snd_pcm_period_elapsed(substream); + } if (prtd->cur_pos >= runtime->buffer_size) { @@ -286,9 +295,15 @@ static int rec_thread( void *arg ) buffer_in_queue--; - prtd->cur_pos += bytes_to_frames( - runtime, - TEGRA_DEFAULT_BUFFER_SIZE); + if ((frames_to_bytes(runtime, prtd->cur_pos) + + TEGRA_DEFAULT_BUFFER_SIZE) > rtbuffersize) { + size = rtbuffersize - + frames_to_bytes(runtime, prtd->cur_pos); + } else { + size = TEGRA_DEFAULT_BUFFER_SIZE; + } + + prtd->cur_pos += bytes_to_frames(runtime, size); if (prtd->cur_pos < prtd->last_pos) { period_offset = (runtime->buffer_size + diff --git a/sound/soc/tegra/tegra_transport.h b/sound/soc/tegra/tegra_transport.h index 8af6ac30424c..d3306f0f1496 100644 --- a/sound/soc/tegra/tegra_transport.h +++ b/sound/soc/tegra/tegra_transport.h @@ -40,7 +40,6 @@ #include "nvrm_memmgr.h" #include "nvassert.h" #include "nvrm_transport.h" - #include "tegra_sndfx.h" @@ -52,6 +51,10 @@ #define NVALSA_BUFFER_COUNT 1 #define TEGRA_DEFAULT_BUFFER_SIZE 4096 #define NVALSA_INVALID_STATE -1 +#define TEGRA_SAMPLE_RATES (SNDRV_PCM_RATE_8000_48000) +#define TEGRA_SAMPLE_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |\ + SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE |\ + SNDRV_PCM_FMTBIT_S32_LE) #define TEGRA_TRANSPORT_SEND_TIMEOUT 5000 #define TEGRA_TRANSPORT_CONNECT_TIMEOUT 60000 |