Merge branch 'topic/intel8x0' into for-linus
authorTakashi Iwai <tiwai@suse.de>
Mon, 23 Mar 2009 23:36:13 +0000 (00:36 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 23 Mar 2009 23:36:13 +0000 (00:36 +0100)
1  2 
sound/pci/ac97/ac97_codec.c
sound/pci/intel8x0.c
sound/pci/intel8x0m.c

@@@ -143,7 -143,6 +143,7 @@@ static const struct ac97_codec_id snd_a
  { 0x43525970, 0xfffffff8, "CS4202",           NULL,           NULL },
  { 0x43585421, 0xffffffff, "HSD11246",         NULL,           NULL }, // SmartMC II
  { 0x43585428, 0xfffffff8, "Cx20468",          patch_conexant, NULL }, // SmartAMC fixme: the mask might be different
 +{ 0x43585430, 0xffffffff, "Cx20468-31",               patch_conexant, NULL },
  { 0x43585431, 0xffffffff, "Cx20551",           patch_cx20551,  NULL },
  { 0x44543031, 0xfffffff0, "DT0398",           NULL,           NULL },
  { 0x454d4328, 0xffffffff, "EM28028",          NULL,           NULL },  // same as TR28028?
@@@ -384,7 -383,7 +384,7 @@@ int snd_ac97_update_bits(struct snd_ac9
  
  EXPORT_SYMBOL(snd_ac97_update_bits);
  
- /* no lock version - see snd_ac97_updat_bits() */
+ /* no lock version - see snd_ac97_update_bits() */
  int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg,
                                unsigned short mask, unsigned short value)
  {
@@@ -1644,10 -1643,7 +1644,10 @@@ static int snd_ac97_modem_build(struct 
  {
        int err, idx;
  
 -      //printk("AC97_GPIO_CFG = %x\n",snd_ac97_read(ac97,AC97_GPIO_CFG));
 +      /*
 +      printk(KERN_DEBUG "AC97_GPIO_CFG = %x\n",
 +             snd_ac97_read(ac97,AC97_GPIO_CFG));
 +      */
        snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH));
        snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH));
        snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff);
diff --combined sound/pci/intel8x0.c
@@@ -617,7 -617,7 +617,7 @@@ static int snd_intel8x0_ali_codec_semap
        int time = 100;
        if (chip->buggy_semaphore)
                return 0; /* just ignore ... */
 -      while (time-- && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
 +      while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
                udelay(1);
        if (! time && ! chip->in_ac97_init)
                snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n");
@@@ -689,7 -689,7 +689,7 @@@ static void snd_intel8x0_setup_periods(
                        bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
                                                     ichdev->fragsize >> ichdev->pos_shift);
  #if 0
-                       printk("bdbar[%i] = 0x%x [0x%x]\n",
+                       printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
                               idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
  #endif
                }
        ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
        ichdev->position = 0;
  #if 0
-       printk("lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
-                       ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1);
+       printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
+              "period_size1 = 0x%x\n",
+              ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
+              ichdev->fragsize1);
  #endif
        /* clear interrupts */
        iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
@@@ -768,7 -770,8 +770,8 @@@ static inline void snd_intel8x0_update(
                ichdev->lvi_frag %= ichdev->frags;
                ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
  #if 0
-       printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
+       printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, "
+              "all = 0x%x, 0x%x\n",
               ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
               ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
               inl(port + 4), inb(port + ICH_REG_OFF_CR));
@@@ -2287,23 -2290,23 +2290,23 @@@ static void do_ali_reset(struct intel8x
        iputdword(chip, ICHREG(ALI_INTERRUPTSR), 0x00000000);
  }
  
- static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
- {
-       unsigned long end_time;
-       unsigned int cnt, status, nstatus;
-       
-       /* put logic to right state */
-       /* first clear status bits */
-       status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
-       if (chip->device_type == DEVICE_NFORCE)
-               status |= ICH_NVSPINT;
-       cnt = igetdword(chip, ICHREG(GLOB_STA));
-       iputdword(chip, ICHREG(GLOB_STA), cnt & status);
+ #ifdef CONFIG_SND_AC97_POWER_SAVE
+ static struct snd_pci_quirk ich_chip_reset_mode[] = {
+       SND_PCI_QUIRK(0x1014, 0x051f, "Thinkpad R32", 1),
+       { } /* end */
+ };
  
+ static int snd_intel8x0_ich_chip_cold_reset(struct intel8x0 *chip)
+ {
+       unsigned int cnt;
        /* ACLink on, 2 channels */
+       if (snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
+               return -EIO;
        cnt = igetdword(chip, ICHREG(GLOB_CNT));
        cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
- #ifdef CONFIG_SND_AC97_POWER_SAVE
        /* do cold reset - the full ac97 powerdown may leave the controller
         * in a warm state but actually it cannot communicate with the codec.
         */
        udelay(10);
        iputdword(chip, ICHREG(GLOB_CNT), cnt | ICH_AC97COLD);
        msleep(1);
+       return 0;
+ }
+ #define snd_intel8x0_ich_chip_can_cold_reset(chip) \
+       (!snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
  #else
+ #define snd_intel8x0_ich_chip_cold_reset(chip)        0
+ #define snd_intel8x0_ich_chip_can_cold_reset(chip) (0)
+ #endif
+ static int snd_intel8x0_ich_chip_reset(struct intel8x0 *chip)
+ {
+       unsigned long end_time;
+       unsigned int cnt;
+       /* ACLink on, 2 channels */
+       cnt = igetdword(chip, ICHREG(GLOB_CNT));
+       cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
        /* finish cold or do warm reset */
        cnt |= (cnt & ICH_AC97COLD) == 0 ? ICH_AC97COLD : ICH_AC97WARM;
        iputdword(chip, ICHREG(GLOB_CNT), cnt);
        end_time = (jiffies + (HZ / 4)) + 1;
        do {
                if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0)
-                       goto __ok;
+                       return 0;
                schedule_timeout_uninterruptible(1);
        } while (time_after_eq(end_time, jiffies));
        snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n",
                   igetdword(chip, ICHREG(GLOB_CNT)));
        return -EIO;
+ }
+ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
+ {
+       unsigned long end_time;
+       unsigned int status, nstatus;
+       unsigned int cnt;
+       int err;
+       /* put logic to right state */
+       /* first clear status bits */
+       status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
+       if (chip->device_type == DEVICE_NFORCE)
+               status |= ICH_NVSPINT;
+       cnt = igetdword(chip, ICHREG(GLOB_STA));
+       iputdword(chip, ICHREG(GLOB_STA), cnt & status);
+       if (snd_intel8x0_ich_chip_can_cold_reset(chip))
+               err = snd_intel8x0_ich_chip_cold_reset(chip);
+       else
+               err = snd_intel8x0_ich_chip_reset(chip);
+       if (err < 0)
+               return err;
  
-       __ok:
- #endif
        if (probing) {
                /* wait for any codec ready status.
                 * Once it becomes ready it should remain ready
@@@ -3058,9 -3097,9 +3097,9 @@@ static int __devinit snd_intel8x0_probe
        int err;
        struct shortname_table *name;
  
 -      card = snd_card_new(index, id, THIS_MODULE, 0);
 -      if (card == NULL)
 -              return -ENOMEM;
 +      err = snd_card_create(index, id, THIS_MODULE, 0, &card);
 +      if (err < 0)
 +              return err;
  
        if (spdif_aclink < 0)
                spdif_aclink = check_default_spdif_aclink(pci);
diff --combined sound/pci/intel8x0m.c
@@@ -411,7 -411,10 +411,10 @@@ static void snd_intel8x0_setup_periods(
                        bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + (((idx >> 1) * ichdev->fragsize) % ichdev->size));
                        bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
                                                     ichdev->fragsize >> chip->pcm_pos_shift);
-                       // printk("bdbar[%i] = 0x%x [0x%x]\n", idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
+                       /*
+                       printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
+                              idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
+                       */
                }
                ichdev->frags = ichdev->size / ichdev->fragsize;
        }
        ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
        ichdev->position = 0;
  #if 0
-       printk("lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
-                       ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, ichdev->fragsize1);
+       printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
+              "period_size1 = 0x%x\n",
+              ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
+              ichdev->fragsize1);
  #endif
        /* clear interrupts */
        iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
@@@ -465,7 -470,8 +470,8 @@@ static inline void snd_intel8x0_update(
                                                             ichdev->lvi_frag *
                                                             ichdev->fragsize1);
  #if 0
-               printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
+               printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], "
+                      "prefetch = %i, all = 0x%x, 0x%x\n",
                       ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
                       ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
                       inl(port + 4), inb(port + ICH_REG_OFF_CR));
@@@ -1269,9 -1275,9 +1275,9 @@@ static int __devinit snd_intel8x0m_prob
        int err;
        struct shortname_table *name;
  
 -      card = snd_card_new(index, id, THIS_MODULE, 0);
 -      if (card == NULL)
 -              return -ENOMEM;
 +      err = snd_card_create(index, id, THIS_MODULE, 0, &card);
 +      if (err < 0)
 +              return err;
  
        strcpy(card->driver, "ICH-MODEM");
        strcpy(card->shortname, "Intel ICH");