Commit 9560868d authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update - Takashi Iwai <tiwai@suse.de>

PCM Midlevel,Intel8x0 driver
- added snd_pcm_limit_hw_rates() to determine the min/max rates from
  rates bits.
parent 8b341be4
...@@ -889,6 +889,9 @@ snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, ...@@ -889,6 +889,9 @@ snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream,
snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream,
void **bufs, snd_pcm_uframes_t frames); void **bufs, snd_pcm_uframes_t frames);
int snd_pcm_limit_hw_rates(snd_pcm_runtime_t *runtime);
/* /*
* Timer interface * Timer interface
*/ */
......
...@@ -1061,3 +1061,4 @@ EXPORT_SYMBOL(snd_pcm_format_size); ...@@ -1061,3 +1061,4 @@ EXPORT_SYMBOL(snd_pcm_format_size);
EXPORT_SYMBOL(snd_pcm_format_silence_64); EXPORT_SYMBOL(snd_pcm_format_silence_64);
EXPORT_SYMBOL(snd_pcm_format_set_silence); EXPORT_SYMBOL(snd_pcm_format_set_silence);
EXPORT_SYMBOL(snd_pcm_build_linear_format); EXPORT_SYMBOL(snd_pcm_build_linear_format);
EXPORT_SYMBOL(snd_pcm_limit_hw_rates);
...@@ -654,3 +654,35 @@ snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_end ...@@ -654,3 +654,35 @@ snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_end
} }
return snd_int_to_enum(((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian]); return snd_int_to_enum(((int(*)[2][2])linear_formats)[width][!!unsignd][!!big_endian]);
} }
/**
* snd_pcm_limit_hw_rates - determine rate_min/rate_max fields
* @runtime: the runtime instance
*
* Determines the rate_min and rate_max fields from the rates bits of
* the given runtime->hw.
*
* Returns zero if successful.
*/
int snd_pcm_limit_hw_rates(snd_pcm_runtime_t *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++) {
if (runtime->hw.rates & (1 << i)) {
runtime->hw.rate_min = rates[i];
break;
}
}
for (i = (int)ARRAY_SIZE(rates) - 1; i >= 0; i--) {
if (runtime->hw.rates & (1 << i)) {
runtime->hw.rate_max = rates[i];
break;
}
}
return 0;
}
...@@ -1095,21 +1095,12 @@ static int snd_intel8x0_pcm_open(snd_pcm_substream_t * substream, ichdev_t *ichd ...@@ -1095,21 +1095,12 @@ static int snd_intel8x0_pcm_open(snd_pcm_substream_t * substream, ichdev_t *ichd
{ {
intel8x0_t *chip = snd_pcm_substream_chip(substream); intel8x0_t *chip = snd_pcm_substream_chip(substream);
snd_pcm_runtime_t *runtime = substream->runtime; snd_pcm_runtime_t *runtime = substream->runtime;
static unsigned int i, rates[] = {
/* ATTENTION: these values depend on the definition in pcm.h! */
5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000
};
int err; int err;
ichdev->substream = substream; ichdev->substream = substream;
runtime->hw = snd_intel8x0_stream; runtime->hw = snd_intel8x0_stream;
runtime->hw.rates = ichdev->pcm->rates; runtime->hw.rates = ichdev->pcm->rates;
for (i = 0; i < ARRAY_SIZE(rates); i++) { snd_pcm_limit_hw_rates(runtime);
if (runtime->hw.rates & (1 << i)) {
runtime->hw.rate_min = rates[i];
break;
}
}
if (chip->device_type == DEVICE_SIS) { if (chip->device_type == DEVICE_SIS) {
runtime->hw.buffer_bytes_max = 64*1024; runtime->hw.buffer_bytes_max = 64*1024;
runtime->hw.period_bytes_max = 64*1024; runtime->hw.period_bytes_max = 64*1024;
......
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