mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-17 20:54:10 +00:00
[ALSA] This simplifies and fixes waiting loops of the mce_down()
function after Trent Piepho's patch for AD1848. It also makes busy_wait() function call not atomic. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
0895e91d60
commit
9823adf632
1 changed files with 19 additions and 40 deletions
|
@ -400,65 +400,44 @@ static void snd_cs4231_mce_up(struct snd_cs4231 *chip)
|
||||||
|
|
||||||
static void snd_cs4231_mce_down(struct snd_cs4231 *chip)
|
static void snd_cs4231_mce_down(struct snd_cs4231 *chip)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags, timeout;
|
||||||
unsigned long end_time;
|
int reg;
|
||||||
int timeout;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&chip->lock, flags);
|
|
||||||
snd_cs4231_busy_wait(chip);
|
snd_cs4231_busy_wait(chip);
|
||||||
|
spin_lock_irqsave(&chip->lock, flags);
|
||||||
#ifdef CONFIG_SND_DEBUG
|
#ifdef CONFIG_SND_DEBUG
|
||||||
if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT)
|
if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT)
|
||||||
snd_printdd("mce_down [%p] - auto calibration time out (0)\n",
|
snd_printdd("mce_down [%p] - auto calibration time out (0)\n",
|
||||||
CS4231U(chip, REGSEL));
|
CS4231U(chip, REGSEL));
|
||||||
#endif
|
#endif
|
||||||
chip->mce_bit &= ~CS4231_MCE;
|
chip->mce_bit &= ~CS4231_MCE;
|
||||||
timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL));
|
reg = __cs4231_readb(chip, CS4231U(chip, REGSEL));
|
||||||
__cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f),
|
__cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f),
|
||||||
CS4231U(chip, REGSEL));
|
CS4231U(chip, REGSEL));
|
||||||
if (timeout == 0x80)
|
if (reg == 0x80)
|
||||||
snd_printdd("mce_down [%p]: serious init problem - "
|
snd_printdd("mce_down [%p]: serious init problem "
|
||||||
"codec still busy\n",
|
"- codec still busy\n", chip->port);
|
||||||
chip->port);
|
if ((reg & CS4231_MCE) == 0) {
|
||||||
if ((timeout & CS4231_MCE) == 0) {
|
|
||||||
spin_unlock_irqrestore(&chip->lock, flags);
|
spin_unlock_irqrestore(&chip->lock, flags);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for (possible -- during init auto-calibration may not be set)
|
* Wait for auto-calibration (AC) process to finish, i.e. ACI to go low.
|
||||||
* calibration process to start. Needs upto 5 sample periods on AD1848
|
|
||||||
* which at the slowest possible rate of 5.5125 kHz means 907 us.
|
|
||||||
*/
|
*/
|
||||||
msleep(1);
|
timeout = jiffies + msecs_to_jiffies(250);
|
||||||
|
do {
|
||||||
/* check condition up to 250ms */
|
|
||||||
end_time = jiffies + msecs_to_jiffies(250);
|
|
||||||
while (snd_cs4231_in(chip, CS4231_TEST_INIT) &
|
|
||||||
CS4231_CALIB_IN_PROGRESS) {
|
|
||||||
|
|
||||||
spin_unlock_irqrestore(&chip->lock, flags);
|
spin_unlock_irqrestore(&chip->lock, flags);
|
||||||
if (time_after(jiffies, end_time)) {
|
|
||||||
snd_printk("mce_down - "
|
|
||||||
"auto calibration time out (2)\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
msleep(1);
|
msleep(1);
|
||||||
spin_lock_irqsave(&chip->lock, flags);
|
spin_lock_irqsave(&chip->lock, flags);
|
||||||
}
|
reg = snd_cs4231_in(chip, CS4231_TEST_INIT);
|
||||||
|
reg &= CS4231_CALIB_IN_PROGRESS;
|
||||||
/* check condition up to 100ms */
|
} while (reg && time_before(jiffies, timeout));
|
||||||
end_time = jiffies + msecs_to_jiffies(100);
|
|
||||||
while (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) {
|
|
||||||
spin_unlock_irqrestore(&chip->lock, flags);
|
|
||||||
if (time_after(jiffies, end_time)) {
|
|
||||||
snd_printk("mce_down - "
|
|
||||||
"auto calibration time out (3)\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
msleep(1);
|
|
||||||
spin_lock_irqsave(&chip->lock, flags);
|
|
||||||
}
|
|
||||||
spin_unlock_irqrestore(&chip->lock, flags);
|
spin_unlock_irqrestore(&chip->lock, flags);
|
||||||
|
|
||||||
|
if (reg)
|
||||||
|
snd_printk(KERN_ERR
|
||||||
|
"mce_down - auto calibration time out (2)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,
|
static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,
|
||||||
|
|
Loading…
Add table
Reference in a new issue