Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 143362
b: refs/heads/master
c: 2ec775e
h: refs/heads/master
v: v3
  • Loading branch information
Jaroslav Kysela committed Apr 15, 2009
1 parent d89d78a commit 95bbda9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 29dab4fd3176e25dfab6cd763beb02d87973c288
refs/heads/master: 2ec775e7053c82bc90858ede011b35aeb416995b
15 changes: 11 additions & 4 deletions trunk/sound/pci/intel8x0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -2749,6 +2750,11 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)

if (pos == 0) {
snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n");
__retry:
if (attempt < 2) {
attempt++;
goto __again;
}
return;
}

Expand All @@ -2759,14 +2765,15 @@ 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)
Expand Down

0 comments on commit 95bbda9

Please sign in to comment.