diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-05-03 16:51:56 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-05-03 16:51:56 +0200 |
commit | 8bd172dc96fba8ba5a7560afdc1ff7461c278e86 (patch) | |
tree | 3e116afc5055bd0b54b4e0ae065c33c1f3e97e47 /sound/pci/lola | |
parent | 972505ccde9a3bdc8455f4cf3d3f37d17f8f10a3 (diff) | |
download | linux-8bd172dc96fba8ba5a7560afdc1ff7461c278e86.tar.bz2 |
ALSA: lola - Allow granularity changes
Add some sanity checks.
Change PCM parameters appropriately per granularity.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/lola')
-rw-r--r-- | sound/pci/lola/lola.c | 27 | ||||
-rw-r--r-- | sound/pci/lola/lola.h | 1 | ||||
-rw-r--r-- | sound/pci/lola/lola_pcm.c | 6 |
3 files changed, 27 insertions, 7 deletions
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c index 3d2516b11f22..8ee22bee10c9 100644 --- a/sound/pci/lola/lola.c +++ b/sound/pci/lola/lola.c @@ -587,14 +587,31 @@ static int __devinit lola_create(struct snd_card *card, struct pci_dev *pci, chip->pci = pci; chip->irq = -1; - chip->sample_rate_min = sample_rate_min[dev]; chip->granularity = granularity[dev]; - /* FIXME */ - if (chip->granularity != LOLA_GRANULARITY_MAX) { + switch (chip->granularity) { + case 8: + chip->sample_rate_max = 48000; + break; + case 16: + chip->sample_rate_max = 96000; + break; + case 32: + chip->sample_rate_max = 192000; + break; + default: snd_printk(KERN_WARNING SFX - "Only %d granularity is supported for now\n", - LOLA_GRANULARITY_MAX); + "Invalid granularity %d, reset to %d\n", + chip->granularity, LOLA_GRANULARITY_MAX); chip->granularity = LOLA_GRANULARITY_MAX; + chip->sample_rate_max = 192000; + break; + } + chip->sample_rate_min = sample_rate_min[dev]; + if (chip->sample_rate_min > chip->sample_rate_max) { + snd_printk(KERN_WARNING SFX + "Invalid sample_rate_min %d, reset to 16000\n", + chip->sample_rate_min); + chip->sample_rate_min = 16000; } err = pci_request_regions(pci, DRVNAME); diff --git a/sound/pci/lola/lola.h b/sound/pci/lola/lola.h index 839779dc32f9..bc8110ff6b46 100644 --- a/sound/pci/lola/lola.h +++ b/sound/pci/lola/lola.h @@ -367,6 +367,7 @@ struct lola { /* parameters */ unsigned int granularity; unsigned int sample_rate_min; + unsigned int sample_rate_max; /* flags */ unsigned int running :1; diff --git a/sound/pci/lola/lola_pcm.c b/sound/pci/lola/lola_pcm.c index dc2e811dcb3c..4bb5b5bd6371 100644 --- a/sound/pci/lola/lola_pcm.c +++ b/sound/pci/lola/lola_pcm.c @@ -178,14 +178,16 @@ static int lola_pcm_open(struct snd_pcm_substream *substream) str->opened = 1; runtime->hw = lola_pcm_hw; runtime->hw.channels_max = pcm->num_streams - str->index; + runtime->hw.rate_min = chip->sample_rate_min; + runtime->hw.rate_max = chip->sample_rate_max; snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); /* period size = multiple of chip->granularity (8, 16 or 32 frames) * use LOLA_GRANULARITY_MAX = 32 for instance */ snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, - LOLA_GRANULARITY_MAX); + chip->granularity); snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, - LOLA_GRANULARITY_MAX); + chip->granularity); mutex_unlock(&chip->open_mutex); return 0; } |