]> err.no Git - linux-2.6/commitdiff
[ALSA] ad1816a - Add clockfreq module option
authorTakashi Iwai <tiwai@suse.de>
Wed, 3 Aug 2005 12:02:47 +0000 (14:02 +0200)
committerJaroslav Kysela <perex@suse.cz>
Tue, 30 Aug 2005 06:43:43 +0000 (08:43 +0200)
Documentation,AD1816A driver
Added clockfreq module option for the card with a different clock frequency
than 33kHz.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/ad1816a.h
sound/isa/ad1816a/ad1816a.c
sound/isa/ad1816a/ad1816a_lib.c

index 395978e375cf7caa870b106b9a0b53287a7002a2..ca2e0e4fa9375d866f3fb4866c515aa0481a173d 100644 (file)
@@ -138,6 +138,7 @@ struct _snd_ad1816a {
        spinlock_t lock;
 
        unsigned short mode;
+       unsigned int clock_freq;
 
        snd_card_t *card;
        snd_pcm_t *pcm;
index 563296d028941b53e211956fff89b54459640dce..0eb442ca23d6471e7abf63a730e1548c84dabfa9 100644 (file)
@@ -53,6 +53,7 @@ static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;      /* Pnp setup */
 static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;   /* Pnp setup */
 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;      /* PnP setup */
 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;      /* PnP setup */
+static int clockfreq[SNDRV_CARDS];
 
 module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for ad1816a based soundcard.");
@@ -74,6 +75,8 @@ module_param_array(dma1, int, NULL, 0444);
 MODULE_PARM_DESC(dma1, "1st DMA # for ad1816a driver.");
 module_param_array(dma2, int, NULL, 0444);
 MODULE_PARM_DESC(dma2, "2nd DMA # for ad1816a driver.");
+module_param_array(clockfreq, int, NULL, 0444);
+MODULE_PARM_DESC(clockfreq, "Clock frequency for ad1816a driver (default = 0).");
 
 struct snd_card_ad1816a {
        struct pnp_dev *dev;
@@ -209,6 +212,8 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard
                snd_card_free(card);
                return error;
        }
+       if (clockfreq[dev] >= 5000 && clockfreq[dev] <= 100000)
+               chip->clock_freq = clockfreq[dev];
 
        strcpy(card->driver, "AD1816A");
        strcpy(card->shortname, "ADI SoundPort AD1816A");
index 625b2eff14a14d03f39c17902a448b974b3b8f13..ae860360ecf963a3620357e505b2d6025eb57800 100644 (file)
@@ -234,7 +234,7 @@ static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream)
        ad1816a_t *chip = snd_pcm_substream_chip(substream);
        unsigned long flags;
        snd_pcm_runtime_t *runtime = substream->runtime;
-       unsigned int size;
+       unsigned int size, rate;
 
        spin_lock_irqsave(&chip->lock, flags);
 
@@ -245,7 +245,10 @@ static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream)
        snd_dma_program(chip->dma1, runtime->dma_addr, size,
                        DMA_MODE_WRITE | DMA_AUTOINIT);
 
-       snd_ad1816a_write(chip, AD1816A_PLAYBACK_SAMPLE_RATE, runtime->rate);
+       rate = runtime->rate;
+       if (chip->clock_freq)
+               rate = (rate * 33000) / chip->clock_freq;
+       snd_ad1816a_write(chip, AD1816A_PLAYBACK_SAMPLE_RATE, rate);
        snd_ad1816a_out_mask(chip, AD1816A_PLAYBACK_CONFIG,
                AD1816A_FMT_ALL | AD1816A_FMT_STEREO,
                snd_ad1816a_get_format(chip, runtime->format,
@@ -263,7 +266,7 @@ static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream)
        ad1816a_t *chip = snd_pcm_substream_chip(substream);
        unsigned long flags;
        snd_pcm_runtime_t *runtime = substream->runtime;
-       unsigned int size;
+       unsigned int size, rate;
 
        spin_lock_irqsave(&chip->lock, flags);
 
@@ -274,7 +277,10 @@ static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream)
        snd_dma_program(chip->dma2, runtime->dma_addr, size,
                        DMA_MODE_READ | DMA_AUTOINIT);
 
-       snd_ad1816a_write(chip, AD1816A_CAPTURE_SAMPLE_RATE, runtime->rate);
+       rate = runtime->rate;
+       if (chip->clock_freq)
+               rate = (rate * 33000) / chip->clock_freq;
+       snd_ad1816a_write(chip, AD1816A_CAPTURE_SAMPLE_RATE, rate);
        snd_ad1816a_out_mask(chip, AD1816A_CAPTURE_CONFIG,
                AD1816A_FMT_ALL | AD1816A_FMT_STEREO,
                snd_ad1816a_get_format(chip, runtime->format,