Merge branch 'fix/pcm-jiffies-check' into for-linus
[safe/jmp/linux-2.6] / sound / pci / intel8x0.c
index 6962f94..173bebf 100644 (file)
@@ -1854,6 +1854,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
        },
        {
                .subvendor = 0x1028,
+               .subdevice = 0x016a,
+               .name = "Dell Inspiron 8600",   /* STAC9750/51 */
+               .type = AC97_TUNE_HP_ONLY
+       },
+       {
+               .subvendor = 0x1028,
                .subdevice = 0x0186,
                .name = "Dell Latitude D810", /* cf. Malone #41015 */
                .type = AC97_TUNE_HP_MUTE_LED
@@ -1896,12 +1902,6 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
        },
        {
                .subvendor = 0x103c,
-               .subdevice = 0x0934,
-               .name = "HP nx8220",
-               .type = AC97_TUNE_MUTE_LED
-       },
-       {
-               .subvendor = 0x103c,
                .subdevice = 0x129d,
                .name = "HP xw8000",
                .type = AC97_TUNE_HP_ONLY
@@ -2676,12 +2676,13 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
        struct ichdev *ichdev;
        unsigned long port;
        unsigned long pos, pos1, t;
-       int civ, timeout = 1000;
+       int civ, timeout = 1000, attempt = 1;
        struct timespec start_time, stop_time;
 
        if (chip->ac97_bus->clock != 48000)
                return; /* specified in module option */
 
+      __again:
        subs = chip->pcm[0]->streams[0].substream;
        if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) {
                snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n");
@@ -2689,7 +2690,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
        }
        ichdev = &chip->ichd[ICHD_PCMOUT];
        ichdev->physbuf = subs->dma_buffer.addr;
-       ichdev->size = chip->ichd[ICHD_PCMOUT].fragsize = INTEL8X0_TESTBUF_SIZE;
+       ichdev->size = ichdev->fragsize = INTEL8X0_TESTBUF_SIZE;
        ichdev->substream = NULL; /* don't process interrupts */
 
        /* set rate */
@@ -2749,7 +2750,13 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
 
        if (pos == 0) {
                snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n");
-               return;
+             __retry:
+               if (attempt < 3) {
+                       msleep(300);
+                       attempt++;
+                       goto __again;
+               }
+               goto __end;
        }
 
        pos /= 4;
@@ -2759,22 +2766,24 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
        printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
        if (t == 0) {
                snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n");
-               return;
+               goto __retry;
        }
        pos *= 1000;
        pos = (pos / t) * 1000 + ((pos % t) * 1000) / t;
-       if (pos < 40000 || pos >= 60000) 
+       if (pos < 40000 || pos >= 60000) {
                /* abnormal value. hw problem? */
                printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos);
-       else if (pos > 40500 || pos < 41500)
+               goto __retry;
+       } else if (pos > 40500 && pos < 41500)
                /* first exception - 41000Hz reference clock */
                chip->ac97_bus->clock = 41000;
-       else if (pos > 43600 || pos < 44600)
+       else if (pos > 43600 && pos < 44600)
                /* second exception - 44100HZ reference clock */
                chip->ac97_bus->clock = 44100;
        else if (pos < 47500 || pos > 48500)
                /* not 48000Hz, tuning the clock.. */
                chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
+      __end:
        printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock);
        snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
 }