]> err.no Git - linux-2.6/blobdiff - sound/pci/intel8x0.c
[PATCH] mm: cleanup rmap
[linux-2.6] / sound / pci / intel8x0.c
index cc16f95f9ceff2b71cda1e227956cdc851b93daf..7b548416dcefc086295511b6845359975bb8dda8 100644 (file)
@@ -389,6 +389,7 @@ typedef struct {
        struct ac97_pcm *pcm;
        int pcm_open_flag;
        unsigned int page_attr_changed: 1;
+       unsigned int suspended: 1;
 } ichdev_t;
 
 typedef struct _snd_intel8x0 intel8x0_t;
@@ -424,6 +425,7 @@ struct _snd_intel8x0 {
        unsigned xbox: 1;               /* workaround for Xbox AC'97 detection */
 
        int spdif_idx;  /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
+       unsigned int sdm_saved; /* SDM reg value */
 
        ac97_bus_t *ac97_bus;
        ac97_t *ac97[3];
@@ -861,12 +863,16 @@ static int snd_intel8x0_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
        unsigned long port = ichdev->reg_offset;
 
        switch (cmd) {
-       case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
+               ichdev->suspended = 0;
+               /* fallthru */
+       case SNDRV_PCM_TRIGGER_START:
                val = ICH_IOCE | ICH_STARTBM;
                break;
-       case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
+               ichdev->suspended = 1;
+               /* fallthru */
+       case SNDRV_PCM_TRIGGER_STOP:
                val = 0;
                break;
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
@@ -898,9 +904,11 @@ static int snd_intel8x0_ali_trigger(snd_pcm_substream_t *substream, int cmd)
 
        val = igetdword(chip, ICHREG(ALI_DMACR));
        switch (cmd) {
+       case SNDRV_PCM_TRIGGER_RESUME:
+               ichdev->suspended = 0;
+               /* fallthru */
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
-       case SNDRV_PCM_TRIGGER_RESUME:
                if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                        /* clear FIFO for synchronization of channels */
                        fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]);
@@ -912,9 +920,11 @@ static int snd_intel8x0_ali_trigger(snd_pcm_substream_t *substream, int cmd)
                val &= ~(1 << (ichdev->ali_slot + 16)); /* clear PAUSE flag */
                iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot)); /* start DMA */
                break;
+       case SNDRV_PCM_TRIGGER_SUSPEND:
+               ichdev->suspended = 1;
+               /* fallthru */
        case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
-       case SNDRV_PCM_TRIGGER_SUSPEND:
                iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16))); /* pause */
                iputbyte(chip, port + ICH_REG_OFF_CR, 0);
                while (igetbyte(chip, port + ICH_REG_OFF_CR))
@@ -993,6 +1003,8 @@ static void snd_intel8x0_setup_pcm_out(intel8x0_t *chip,
 {
        unsigned int cnt;
        int dbl = runtime->rate > 48000;
+
+       spin_lock_irq(&chip->reg_lock);
        switch (chip->device_type) {
        case DEVICE_ALI:
                cnt = igetdword(chip, ICHREG(ALI_SCR));
@@ -1036,6 +1048,7 @@ static void snd_intel8x0_setup_pcm_out(intel8x0_t *chip,
                iputdword(chip, ICHREG(GLOB_CNT), cnt);
                break;
        }
+       spin_unlock_irq(&chip->reg_lock);
 }
 
 static int snd_intel8x0_pcm_prepare(snd_pcm_substream_t * substream)
@@ -1047,15 +1060,12 @@ static int snd_intel8x0_pcm_prepare(snd_pcm_substream_t * substream)
        ichdev->physbuf = runtime->dma_addr;
        ichdev->size = snd_pcm_lib_buffer_bytes(substream);
        ichdev->fragsize = snd_pcm_lib_period_bytes(substream);
-       spin_lock_irq(&chip->reg_lock);
        if (ichdev->ichd == ICHD_PCMOUT) {
                snd_intel8x0_setup_pcm_out(chip, runtime);
-               if (chip->device_type == DEVICE_INTEL_ICH4) {
+               if (chip->device_type == DEVICE_INTEL_ICH4)
                        ichdev->pos_shift = (runtime->sample_bits > 16) ? 2 : 1;
-               }
        }
        snd_intel8x0_setup_periods(chip, ichdev);
-       spin_unlock_irq(&chip->reg_lock);
        return 0;
 }
 
@@ -1814,6 +1824,18 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
                .name = "HP nc6000",
                .type = AC97_TUNE_MUTE_LED
        },
+       {
+               .subvendor = 0x103c,
+               .subdevice = 0x0934,
+               .name = "HP nx8220",
+               .type = AC97_TUNE_MUTE_LED
+       },
+       {
+               .subvendor = 0x103c,
+               .subdevice = 0x099c,
+               .name = "HP nx6110",    /* AD1981B */
+               .type = AC97_TUNE_HP_ONLY
+       },
        {
                .subvendor = 0x103c,
                .subdevice = 0x129d,
@@ -1868,6 +1890,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
                .name = "Fujitsu S6210",        /* STAC9750/51 */
                .type = AC97_TUNE_HP_ONLY
        },
+       {
+               .subvendor = 0x10cf,
+               .subdevice = 0x12ec,
+               .name = "Fujitsu-Siemens 4010",
+               .type = AC97_TUNE_HP_ONLY
+       },
        {
                .subvendor = 0x10f1,
                .subdevice = 0x2665,
@@ -2373,6 +2401,11 @@ static int intel8x0_suspend(snd_card_t *card, pm_message_t state)
        for (i = 0; i < 3; i++)
                if (chip->ac97[i])
                        snd_ac97_suspend(chip->ac97[i]);
+       if (chip->device_type == DEVICE_INTEL_ICH4)
+               chip->sdm_saved = igetbyte(chip, ICHREG(SDM));
+
+       if (chip->irq >= 0)
+               free_irq(chip->irq, (void *)chip);
        pci_disable_device(chip->pci);
        return 0;
 }
@@ -2384,7 +2417,19 @@ static int intel8x0_resume(snd_card_t *card)
 
        pci_enable_device(chip->pci);
        pci_set_master(chip->pci);
-       snd_intel8x0_chip_init(chip, 0);
+       request_irq(chip->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip);
+       synchronize_irq(chip->irq);
+       snd_intel8x0_chip_init(chip, 1);
+
+       /* re-initialize mixer stuff */
+       if (chip->device_type == DEVICE_INTEL_ICH4) {
+               /* enable separate SDINs for ICH4 */
+               iputbyte(chip, ICHREG(SDM), chip->sdm_saved);
+               /* use slot 10/11 for SPDIF */
+               iputdword(chip, ICHREG(GLOB_CNT),
+                         (igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_PCM_SPDIF_MASK) |
+                         ICH_PCM_SPDIF_1011);
+       }
 
        /* refill nocache */
        if (chip->fix_nocache)
@@ -2406,6 +2451,20 @@ static int intel8x0_resume(snd_card_t *card)
                }
        }
 
+       /* resume status */
+       for (i = 0; i < chip->bdbars_count; i++) {
+               ichdev_t *ichdev = &chip->ichd[i];
+               unsigned long port = ichdev->reg_offset;
+               if (! ichdev->substream || ! ichdev->suspended)
+                       continue;
+               if (ichdev->ichd == ICHD_PCMOUT)
+                       snd_intel8x0_setup_pcm_out(chip, ichdev->substream->runtime);
+               iputdword(chip, port + ICH_REG_OFF_BDBAR, ichdev->bdbar_addr);
+               iputbyte(chip, port + ICH_REG_OFF_LVI, ichdev->lvi);
+               iputbyte(chip, port + ICH_REG_OFF_CIV, ichdev->civ);
+               iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
+       }
+
        return 0;
 }
 #endif /* CONFIG_PM */
@@ -2451,8 +2510,7 @@ static void __devinit intel8x0_measure_ac97_clock(intel8x0_t *chip)
        }
        do_gettimeofday(&start_time);
        spin_unlock_irq(&chip->reg_lock);
-       set_current_state(TASK_UNINTERRUPTIBLE);
-       schedule_timeout(HZ / 20);
+       msleep(50);
        spin_lock_irq(&chip->reg_lock);
        /* check the position */
        pos = ichdev->fragsize1;