diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-18 12:48:35 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-12-18 14:28:43 -0500 |
commit | 6ca867c827c84d21316e9dc4035abe9480f8347c (patch) | |
tree | c495856269edd99a74e262dcceda15cea8efd3b9 /sound/arm/aaci.c | |
parent | d49464318a7c51676c44cbd1e2480f651cc43807 (diff) |
ALSA: AACI: simplify codec rate information
There's no need for a specific rule; ALSA's generic AC'97 support
calculates the necessary rate constraint information itself, and
we can use this directly.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/arm/aaci.c')
-rw-r--r-- | sound/arm/aaci.c | 75 |
1 files changed, 3 insertions, 72 deletions
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index ae38f2c342cc..ea3be874c84f 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c | |||
@@ -330,63 +330,6 @@ static irqreturn_t aaci_irq(int irq, void *devid) | |||
330 | /* | 330 | /* |
331 | * ALSA support. | 331 | * ALSA support. |
332 | */ | 332 | */ |
333 | |||
334 | struct aaci_stream { | ||
335 | unsigned char codec_idx; | ||
336 | unsigned char rate_idx; | ||
337 | }; | ||
338 | |||
339 | static struct aaci_stream aaci_streams[] = { | ||
340 | [ACSTREAM_FRONT] = { | ||
341 | .codec_idx = 0, | ||
342 | .rate_idx = AC97_RATES_FRONT_DAC, | ||
343 | }, | ||
344 | [ACSTREAM_SURROUND] = { | ||
345 | .codec_idx = 0, | ||
346 | .rate_idx = AC97_RATES_SURR_DAC, | ||
347 | }, | ||
348 | [ACSTREAM_LFE] = { | ||
349 | .codec_idx = 0, | ||
350 | .rate_idx = AC97_RATES_LFE_DAC, | ||
351 | }, | ||
352 | }; | ||
353 | |||
354 | static inline unsigned int aaci_rate_mask(struct aaci *aaci, int streamid) | ||
355 | { | ||
356 | struct aaci_stream *s = aaci_streams + streamid; | ||
357 | return aaci->ac97_bus->codec[s->codec_idx]->rates[s->rate_idx]; | ||
358 | } | ||
359 | |||
360 | static unsigned int rate_list[] = { | ||
361 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, | ||
362 | 48000, 64000, 88200, 96000, 176400, 192000 | ||
363 | }; | ||
364 | |||
365 | /* | ||
366 | * Double-rate rule: we can support double rate iff channels == 2 | ||
367 | * (unimplemented) | ||
368 | */ | ||
369 | static int | ||
370 | aaci_rule_rate_by_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule) | ||
371 | { | ||
372 | struct aaci *aaci = rule->private; | ||
373 | unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512; | ||
374 | struct snd_interval *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
375 | |||
376 | switch (c->max) { | ||
377 | case 6: | ||
378 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE); | ||
379 | case 4: | ||
380 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND); | ||
381 | case 2: | ||
382 | rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT); | ||
383 | } | ||
384 | |||
385 | return snd_interval_list(hw_param_interval(p, rule->var), | ||
386 | ARRAY_SIZE(rate_list), rate_list, | ||
387 | rate_mask); | ||
388 | } | ||
389 | |||
390 | static struct snd_pcm_hardware aaci_hw_info = { | 333 | static struct snd_pcm_hardware aaci_hw_info = { |
391 | .info = SNDRV_PCM_INFO_MMAP | | 334 | .info = SNDRV_PCM_INFO_MMAP | |
392 | SNDRV_PCM_INFO_MMAP_VALID | | 335 | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -400,10 +343,7 @@ static struct snd_pcm_hardware aaci_hw_info = { | |||
400 | */ | 343 | */ |
401 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 344 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
402 | 345 | ||
403 | /* should this be continuous or knot? */ | 346 | /* rates are setup from the AC'97 codec */ |
404 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
405 | .rate_max = 48000, | ||
406 | .rate_min = 4000, | ||
407 | .channels_min = 2, | 347 | .channels_min = 2, |
408 | .channels_max = 6, | 348 | .channels_max = 6, |
409 | .buffer_bytes_max = 64 * 1024, | 349 | .buffer_bytes_max = 64 * 1024, |
@@ -423,6 +363,8 @@ static int __aaci_pcm_open(struct aaci *aaci, | |||
423 | aacirun->substream = substream; | 363 | aacirun->substream = substream; |
424 | runtime->private_data = aacirun; | 364 | runtime->private_data = aacirun; |
425 | runtime->hw = aaci_hw_info; | 365 | runtime->hw = aaci_hw_info; |
366 | runtime->hw.rates = aacirun->pcm->rates; | ||
367 | snd_pcm_limit_hw_rates(runtime); | ||
426 | 368 | ||
427 | /* | 369 | /* |
428 | * FIXME: ALSA specifies fifo_size in bytes. If we're in normal | 370 | * FIXME: ALSA specifies fifo_size in bytes. If we're in normal |
@@ -433,17 +375,6 @@ static int __aaci_pcm_open(struct aaci *aaci, | |||
433 | */ | 375 | */ |
434 | runtime->hw.fifo_size = aaci->fifosize * 2; | 376 | runtime->hw.fifo_size = aaci->fifosize * 2; |
435 | 377 | ||
436 | /* | ||
437 | * Add rule describing hardware rate dependency | ||
438 | * on the number of channels. | ||
439 | */ | ||
440 | ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | ||
441 | aaci_rule_rate_by_channels, aaci, | ||
442 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
443 | SNDRV_PCM_HW_PARAM_RATE, -1); | ||
444 | if (ret) | ||
445 | goto out; | ||
446 | |||
447 | ret = request_irq(aaci->dev->irq[0], aaci_irq, IRQF_SHARED|IRQF_DISABLED, | 378 | ret = request_irq(aaci->dev->irq[0], aaci_irq, IRQF_SHARED|IRQF_DISABLED, |
448 | DRIVER_NAME, aaci); | 379 | DRIVER_NAME, aaci); |
449 | if (ret) | 380 | if (ret) |