Ignore:
Timestamp:
Mar 18, 2021, 8:57:36 PM (4 years ago)
Author:
David Azarewicz
Message:

Merge changes from Paul's uniaud32next branch.

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/intel8x0.c

    r598 r679  
     1// SPDX-License-Identifier: GPL-2.0-or-later
    12/*
    23 *   ALSA driver for Intel ICH (i8x0) chipsets
     
    45 *      Copyright (c) 2000 Jaroslav Kysela <perex@perex.cz>
    56 *
    6  *
    77 *   This code also contains alpha support for SiS 735 chipsets provided
    88 *   by Mike Pieper <mptei@users.sourceforge.net>. We have no datasheet
    99 *   for SiS735, so the code is not fully functional.
    1010 *
    11  *
    12  *   This program is free software; you can redistribute it and/or modify
    13  *   it under the terms of the GNU General Public License as published by
    14  *   the Free Software Foundation; either version 2 of the License, or
    15  *   (at your option) any later version.
    16  *
    17  *   This program is distributed in the hope that it will be useful,
    18  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    19  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20  *   GNU General Public License for more details.
    21  *
    22  *   You should have received a copy of the GNU General Public License
    23  *   along with this program; if not, write to the Free Software
    24  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    25 
    26  *
    27  */
    28 
    29 #include <asm/io.h>
     11 */     
     12
     13#ifdef TARGET_OS2
     14#define KBUILD_MODNAME "intel8x0"
     15#endif
     16
     17#include <linux/io.h>
    3018#include <linux/delay.h>
    3119#include <linux/interrupt.h>
     
    3321#include <linux/pci.h>
    3422#include <linux/slab.h>
    35 #include <linux/moduleparam.h>
     23#include <linux/module.h>
    3624#include <sound/core.h>
    3725#include <sound/pcm.h>
     
    3927#include <sound/info.h>
    4028#include <sound/initval.h>
    41 /* for 440MX workaround */
    42 #include <asm/pgtable.h>
    43 #include <asm/cacheflush.h>
    4429
    4530MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
     
    7459static int ac97_clock;
    7560static char *ac97_quirk;
    76 static int buggy_semaphore;
     61static bool buggy_semaphore;
    7762static int buggy_irq = -1; /* auto-check */
    78 static int xbox;
     63static bool xbox;
    7964static int spdif_aclink = -1;
     65static int inside_vm = -1;
    8066
    8167module_param(index, int, 0444);
     
    8470MODULE_PARM_DESC(id, "ID string for Intel i8x0 soundcard.");
    8571module_param(ac97_clock, int, 0444);
    86 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = whitelist + auto-detect, 1 = force autodetect).");
     72MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = allowlist + auto-detect, 1 = force autodetect).");
    8773module_param(ac97_quirk, charp, 0444);
    8874MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
    8975module_param(buggy_semaphore, bool, 0444);
    9076MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores.");
    91 module_param(buggy_irq, bool, 0444);
     77module_param(buggy_irq, bint, 0444);
    9278MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards.");
    9379module_param(xbox, bool, 0444);
     
    9581module_param(spdif_aclink, int, 0444);
    9682MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
     83module_param(inside_vm, bint, 0444);
     84MODULE_PARM_DESC(inside_vm, "KVM/Parallels optimization.");
    9785
    9886/* just for backward compatibility */
    99 //static int enable;
     87//static bool enable;
    10088module_param(enable, bool, 0444);
    10189//static int joystick;
     
    269257
    270258/* interrupts for the whole chip by interrupt status register finish */
    271 
     259 
    272260#define ALI_INT_MICIN2          (1<<26)
    273261#define ALI_INT_PCMIN2          (1<<25)
     
    313301
    314302/*
    315  *
     303 * 
    316304 */
    317305
     
    347335        unsigned int ichd;                      /* ich device number */
    348336        unsigned long reg_offset;               /* offset to bmaddr */
    349         u32 *bdbar;                             /* CPU address (32bit) */
     337        __le32 *bdbar;                          /* CPU address (32bit) */
    350338        unsigned int bdbar_addr;                /* PCI bus address (32bit) */
    351339        struct snd_pcm_substream *substream;
     
    370358        struct ac97_pcm *pcm;
    371359        int pcm_open_flag;
    372         unsigned int page_attr_changed: 1;
    373360        unsigned int suspended: 1;
    374361};
     
    401388        unsigned xbox: 1;               /* workaround for Xbox AC'97 detection */
    402389        unsigned buggy_semaphore: 1;    /* workaround for buggy codec semaphore */
     390        unsigned inside_vm: 1;          /* enable VM optimization */
    403391
    404392        int spdif_idx;  /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */
     
    409397        unsigned int ac97_sdin[3];
    410398        unsigned int max_codecs, ncodecs;
    411         unsigned int *codec_bit;
     399        const unsigned int *codec_bit;
    412400        unsigned int codec_isr_bits;
    413401        unsigned int codec_ready_bits;
     
    421409};
    422410
    423 static DEFINE_PCI_DEVICE_TABLE(snd_intel8x0_ids) = {
     411static const struct pci_device_id snd_intel8x0_ids[] = {
    424412        { PCI_VDEVICE(INTEL, 0x2415), DEVICE_INTEL },   /* 82801AA */
    425413        { PCI_VDEVICE(INTEL, 0x2425), DEVICE_INTEL },   /* 82901AB */
     
    535523        } while (time--);
    536524
    537         /* access to some forbidden (non existant) ac97 registers will not
     525        /* access to some forbidden (non existent) ac97 registers will not
    538526         * reset the semaphore. So even if you don't get the semaphore, still
    539527         * continue the access. We don't need the semaphore anyway. */
    540         snd_printk(KERN_ERR "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
     528        dev_err(chip->card->dev,
     529                "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
    541530                        igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
    542531        iagetword(chip, 0);     /* clear semaphore flag */
     
    553542        if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
    554543                if (! chip->in_ac97_init)
    555                         snd_printk(KERN_ERR "codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
     544                        dev_err(chip->card->dev,
     545                                "codec_write %d: semaphore is not ready for register 0x%x\n",
     546                                ac97->num, reg);
    556547        }
    557548        iaputword(chip, reg + ac97->num * 0x80, val);
     
    567558        if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
    568559                if (! chip->in_ac97_init)
    569                         snd_printk(KERN_ERR "codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
     560                        dev_err(chip->card->dev,
     561                                "codec_read %d: semaphore is not ready for register 0x%x\n",
     562                                ac97->num, reg);
    570563                res = 0xffff;
    571564        } else {
     
    576569                                  ~(chip->codec_ready_bits | ICH_GSCI));
    577570                        if (! chip->in_ac97_init)
    578                                 snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg);
     571                                dev_err(chip->card->dev,
     572                                        "codec_read %d: read timeout for register 0x%x\n",
     573                                        ac97->num, reg);
    579574                        res = 0xffff;
    580575                }
     
    583578}
    584579
    585 static void __devinit snd_intel8x0_codec_read_test(struct intel8x0 *chip,
    586                                                   unsigned int codec)
     580static void snd_intel8x0_codec_read_test(struct intel8x0 *chip,
     581                                        unsigned int codec)
    587582{
    588583        unsigned int tmp;
     
    610605        }
    611606        if (! chip->in_ac97_init)
    612                 snd_printd(KERN_WARNING "intel8x0: AC97 codec ready timeout.\n");
     607                dev_warn(chip->card->dev, "AC97 codec ready timeout.\n");
    613608        return -EBUSY;
    614609}
     
    622617                udelay(1);
    623618        if (! time && ! chip->in_ac97_init)
    624                 snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n");
     619                dev_warn(chip->card->dev, "ali_codec_semaphore timeout\n");
    625620        return snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_CODEC_READY);
    626621}
     
    662657 * DMA I/O
    663658 */
    664 static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev)
     659static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev) 
    665660{
    666661        int idx;
    667         u32 *bdbar = ichdev->bdbar;
     662        __le32 *bdbar = ichdev->bdbar;
    668663        unsigned long port = ichdev->reg_offset;
    669664
     
    691686                                                     ichdev->fragsize >> ichdev->pos_shift);
    692687#if 0
    693                         printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n",
     688                        dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n",
    694689                               idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
    695690#endif
     
    703698        ichdev->position = 0;
    704699#if 0
    705         printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, "
    706                "period_size1 = 0x%x\n",
     700        dev_dbg(chip->card->dev,
     701                "lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
    707702               ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
    708703               ichdev->fragsize1);
     
    711706        iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI);
    712707}
    713 
    714 #ifdef __i386__
    715 /*
    716  * Intel 82443MX running a 100MHz processor system bus has a hardware bug,
    717  * which aborts PCI busmaster for audio transfer.  A workaround is to set
    718  * the pages as non-cached.  For details, see the errata in
    719  *      http://download.intel.com/design/chipsets/specupdt/24505108.pdf
    720  */
    721 static void fill_nocache(void *buf, int size, int nocache)
    722 {
    723         size = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
    724         if (nocache)
    725                 set_pages_uc(virt_to_page(buf), size);
    726         else
    727                 set_pages_wb(virt_to_page(buf), size);
    728 }
    729 #else
    730 #define fill_nocache(buf, size, nocache) do { ; } while (0)
    731 #endif
    732708
    733709/*
     
    772748                ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
    773749#if 0
    774         printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, "
    775                "all = 0x%x, 0x%x\n",
     750        dev_dbg(chip->card->dev,
     751                "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
    776752               ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
    777753               ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
     
    838814        case SNDRV_PCM_TRIGGER_RESUME:
    839815                ichdev->suspended = 0;
    840                 /* fallthru */
     816                fallthrough;
    841817        case SNDRV_PCM_TRIGGER_START:
    842818        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
     
    846822        case SNDRV_PCM_TRIGGER_SUSPEND:
    847823                ichdev->suspended = 1;
    848                 /* fallthru */
     824                fallthrough;
    849825        case SNDRV_PCM_TRIGGER_STOP:
    850826                val = 0;
     
    871847        struct ichdev *ichdev = get_ichdev(substream);
    872848        unsigned long port = ichdev->reg_offset;
    873         static int fiforeg[] = {
     849        static const int fiforeg[] = {
    874850                ICHREG(ALI_FIFOCR1), ICHREG(ALI_FIFOCR2), ICHREG(ALI_FIFOCR3)
    875851        };
     
    880856        case SNDRV_PCM_TRIGGER_RESUME:
    881857                ichdev->suspended = 0;
    882                 /* fallthru */
     858                fallthrough;
    883859        case SNDRV_PCM_TRIGGER_START:
    884860        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
     
    886862                        /* clear FIFO for synchronization of channels */
    887863                        fifo = igetdword(chip, fiforeg[ichdev->ali_slot / 4]);
    888                         fifo &= ~(0xff << (ichdev->ali_slot % 4));
    889                         fifo |= 0x83 << (ichdev->ali_slot % 4);
     864                        fifo &= ~(0xff << (ichdev->ali_slot % 4)); 
     865                        fifo |= 0x83 << (ichdev->ali_slot % 4); 
    890866                        iputdword(chip, fiforeg[ichdev->ali_slot / 4], fifo);
    891867                }
     
    897873        case SNDRV_PCM_TRIGGER_SUSPEND:
    898874                ichdev->suspended = 1;
    899                 /* fallthru */
     875                fallthrough;
    900876        case SNDRV_PCM_TRIGGER_STOP:
    901877        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
     
    926902        struct intel8x0 *chip = snd_pcm_substream_chip(substream);
    927903        struct ichdev *ichdev = get_ichdev(substream);
    928         struct snd_pcm_runtime *runtime = substream->runtime;
    929904        int dbl = params_rate(hw_params) > 48000;
    930905        int err;
    931906
    932         if (chip->fix_nocache && ichdev->page_attr_changed) {
    933                 fill_nocache(runtime->dma_area, runtime->dma_bytes, 0); /* clear */
    934                 ichdev->page_attr_changed = 0;
    935         }
    936         err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    937         if (err < 0)
    938                 return err;
    939         if (chip->fix_nocache) {
    940                 if (runtime->dma_area && ! ichdev->page_attr_changed) {
    941                         fill_nocache(runtime->dma_area, runtime->dma_bytes, 1);
    942                         ichdev->page_attr_changed = 1;
    943                 }
    944         }
    945907        if (ichdev->pcm_open_flag) {
    946908                snd_ac97_pcm_close(ichdev->pcm);
     
    962924static int snd_intel8x0_hw_free(struct snd_pcm_substream *substream)
    963925{
    964         struct intel8x0 *chip = snd_pcm_substream_chip(substream);
    965926        struct ichdev *ichdev = get_ichdev(substream);
    966927
     
    969930                ichdev->pcm_open_flag = 0;
    970931        }
    971         if (chip->fix_nocache && ichdev->page_attr_changed) {
    972                 fill_nocache(substream->runtime->dma_area, substream->runtime->dma_bytes, 0);
    973                 ichdev->page_attr_changed = 0;
    974         }
    975         return snd_pcm_lib_free_pages(substream);
     932        return 0;
    976933}
    977934
     
    10661023                        continue;
    10671024                }
    1068                 if (civ == igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV) &&
    1069                     ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
     1025                if (civ != igetbyte(chip, ichdev->reg_offset + ICH_REG_OFF_CIV))
     1026                        continue;
     1027
     1028                /* IO read operation is very expensive inside virtual machine
     1029                 * as it is emulated. The probability that subsequent PICB read
     1030                 * will return different result is high enough to loop till
     1031                 * timeout here.
     1032                 * Same CIV is strict enough condition to be sure that PICB
     1033                 * is valid inside VM on emulated card. */
     1034                if (chip->inside_vm)
     1035                        break;
     1036                if (ptr1 == igetword(chip, ichdev->reg_offset + ichdev->roff_picb))
    10701037                        break;
    10711038        } while (timeout--);
     
    10931060}
    10941061
    1095 static struct snd_pcm_hardware snd_intel8x0_stream =
     1062static const struct snd_pcm_hardware snd_intel8x0_stream =
    10961063{
    10971064        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     
    11141081};
    11151082
    1116 static unsigned int channels4[] = {
     1083static const unsigned int channels4[] = {
    11171084        2, 4,
    11181085};
    11191086
    1120 static struct snd_pcm_hw_constraint_list hw_constraints_channels4 = {
     1087static const struct snd_pcm_hw_constraint_list hw_constraints_channels4 = {
    11211088        .count = ARRAY_SIZE(channels4),
    11221089        .list = channels4,
     
    11241091};
    11251092
    1126 static unsigned int channels6[] = {
     1093static const unsigned int channels6[] = {
    11271094        2, 4, 6,
    11281095};
    11291096
    1130 static struct snd_pcm_hw_constraint_list hw_constraints_channels6 = {
     1097static const struct snd_pcm_hw_constraint_list hw_constraints_channels6 = {
    11311098        .count = ARRAY_SIZE(channels6),
    11321099        .list = channels6,
     
    11341101};
    11351102
    1136 static unsigned int channels8[] = {
     1103static const unsigned int channels8[] = {
    11371104        2, 4, 6, 8,
    11381105};
    11391106
    1140 static struct snd_pcm_hw_constraint_list hw_constraints_channels8 = {
     1107static const struct snd_pcm_hw_constraint_list hw_constraints_channels8 = {
    11411108        .count = ARRAY_SIZE(channels8),
    11421109        .list = channels8,
     
    13451312#endif
    13461313
    1347 static struct snd_pcm_ops snd_intel8x0_playback_ops = {
     1314static const struct snd_pcm_ops snd_intel8x0_playback_ops = {
    13481315        .open =         snd_intel8x0_playback_open,
    13491316        .close =        snd_intel8x0_playback_close,
    1350         .ioctl =        snd_pcm_lib_ioctl,
    13511317        .hw_params =    snd_intel8x0_hw_params,
    13521318        .hw_free =      snd_intel8x0_hw_free,
     
    13561322};
    13571323
    1358 static struct snd_pcm_ops snd_intel8x0_capture_ops = {
     1324static const struct snd_pcm_ops snd_intel8x0_capture_ops = {
    13591325        .open =         snd_intel8x0_capture_open,
    13601326        .close =        snd_intel8x0_capture_close,
    1361         .ioctl =        snd_pcm_lib_ioctl,
    13621327        .hw_params =    snd_intel8x0_hw_params,
    13631328        .hw_free =      snd_intel8x0_hw_free,
     
    13671332};
    13681333
    1369 static struct snd_pcm_ops snd_intel8x0_capture_mic_ops = {
     1334static const struct snd_pcm_ops snd_intel8x0_capture_mic_ops = {
    13701335        .open =         snd_intel8x0_mic_open,
    13711336        .close =        snd_intel8x0_mic_close,
    1372         .ioctl =        snd_pcm_lib_ioctl,
    13731337        .hw_params =    snd_intel8x0_hw_params,
    13741338        .hw_free =      snd_intel8x0_hw_free,
     
    13781342};
    13791343
    1380 static struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = {
     1344static const struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = {
    13811345        .open =         snd_intel8x0_mic2_open,
    13821346        .close =        snd_intel8x0_mic2_close,
    1383         .ioctl =        snd_pcm_lib_ioctl,
    13841347        .hw_params =    snd_intel8x0_hw_params,
    13851348        .hw_free =      snd_intel8x0_hw_free,
     
    13891352};
    13901353
    1391 static struct snd_pcm_ops snd_intel8x0_capture2_ops = {
     1354static const struct snd_pcm_ops snd_intel8x0_capture2_ops = {
    13921355        .open =         snd_intel8x0_capture2_open,
    13931356        .close =        snd_intel8x0_capture2_close,
    1394         .ioctl =        snd_pcm_lib_ioctl,
    13951357        .hw_params =    snd_intel8x0_hw_params,
    13961358        .hw_free =      snd_intel8x0_hw_free,
     
    14001362};
    14011363
    1402 static struct snd_pcm_ops snd_intel8x0_spdif_ops = {
     1364static const struct snd_pcm_ops snd_intel8x0_spdif_ops = {
    14031365        .open =         snd_intel8x0_spdif_open,
    14041366        .close =        snd_intel8x0_spdif_close,
    1405         .ioctl =        snd_pcm_lib_ioctl,
    14061367        .hw_params =    snd_intel8x0_hw_params,
    14071368        .hw_free =      snd_intel8x0_hw_free,
     
    14111372};
    14121373
    1413 static struct snd_pcm_ops snd_intel8x0_ali_playback_ops = {
     1374static const struct snd_pcm_ops snd_intel8x0_ali_playback_ops = {
    14141375        .open =         snd_intel8x0_playback_open,
    14151376        .close =        snd_intel8x0_playback_close,
    1416         .ioctl =        snd_pcm_lib_ioctl,
    14171377        .hw_params =    snd_intel8x0_hw_params,
    14181378        .hw_free =      snd_intel8x0_hw_free,
     
    14221382};
    14231383
    1424 static struct snd_pcm_ops snd_intel8x0_ali_capture_ops = {
     1384static const struct snd_pcm_ops snd_intel8x0_ali_capture_ops = {
    14251385        .open =         snd_intel8x0_capture_open,
    14261386        .close =        snd_intel8x0_capture_close,
    1427         .ioctl =        snd_pcm_lib_ioctl,
    14281387        .hw_params =    snd_intel8x0_hw_params,
    14291388        .hw_free =      snd_intel8x0_hw_free,
     
    14331392};
    14341393
    1435 static struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = {
     1394static const struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = {
    14361395        .open =         snd_intel8x0_mic_open,
    14371396        .close =        snd_intel8x0_mic_close,
    1438         .ioctl =        snd_pcm_lib_ioctl,
    14391397        .hw_params =    snd_intel8x0_hw_params,
    14401398        .hw_free =      snd_intel8x0_hw_free,
     
    14441402};
    14451403
    1446 static struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = {
     1404static const struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = {
    14471405        .open =         snd_intel8x0_ali_ac97spdifout_open,
    14481406        .close =        snd_intel8x0_ali_ac97spdifout_close,
    1449         .ioctl =        snd_pcm_lib_ioctl,
    14501407        .hw_params =    snd_intel8x0_hw_params,
    14511408        .hw_free =      snd_intel8x0_hw_free,
     
    14591416        .open =         snd_intel8x0_ali_spdifin_open,
    14601417        .close =        snd_intel8x0_ali_spdifin_close,
    1461         .ioctl =        snd_pcm_lib_ioctl,
    14621418        .hw_params =    snd_intel8x0_hw_params,
    14631419        .hw_free =      snd_intel8x0_hw_free,
     
    14701426        .open =         snd_intel8x0_ali_spdifout_open,
    14711427        .close =        snd_intel8x0_ali_spdifout_close,
    1472         .ioctl =        snd_pcm_lib_ioctl,
    14731428        .hw_params =    snd_intel8x0_hw_params,
    14741429        .hw_free =      snd_intel8x0_hw_free,
     
    14811436struct ich_pcm_table {
    14821437        char *suffix;
    1483         struct snd_pcm_ops *playback_ops;
    1484         struct snd_pcm_ops *capture_ops;
     1438        const struct snd_pcm_ops *playback_ops;
     1439        const struct snd_pcm_ops *capture_ops;
    14851440        size_t prealloc_size;
    14861441        size_t prealloc_max_size;
     
    14881443};
    14891444
    1490 static int __devinit snd_intel8x0_pcm1(struct intel8x0 *chip, int device,
    1491                                        struct ich_pcm_table *rec)
     1445#define intel8x0_dma_type(chip) \
     1446        ((chip)->fix_nocache ? SNDRV_DMA_TYPE_DEV_UC : SNDRV_DMA_TYPE_DEV)
     1447
     1448static int snd_intel8x0_pcm1(struct intel8x0 *chip, int device,
     1449                             const struct ich_pcm_table *rec)
    14921450{
    14931451        struct snd_pcm *pcm;
     
    15181476        chip->pcm[device] = pcm;
    15191477
    1520         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1521                                               snd_dma_pci_data(chip->pci),
    1522                                               rec->prealloc_size, rec->prealloc_max_size);
     1478        snd_pcm_set_managed_buffer_all(pcm, intel8x0_dma_type(chip),
     1479                                       &chip->pci->dev,
     1480                                       rec->prealloc_size, rec->prealloc_max_size);
     1481
     1482        if (rec->playback_ops &&
     1483            rec->playback_ops->open == snd_intel8x0_playback_open) {
     1484                struct snd_pcm_chmap *chmap;
     1485                int chs = 2;
     1486                if (chip->multi8)
     1487                        chs = 8;
     1488                else if (chip->multi6)
     1489                        chs = 6;
     1490                else if (chip->multi4)
     1491                        chs = 4;
     1492                err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK,
     1493                                             snd_pcm_alt_chmaps, chs, 0,
     1494                                             &chmap);
     1495                if (err < 0)
     1496                        return err;
     1497                chmap->channel_mask = SND_PCM_CHMAP_MASK_2468;
     1498                chip->ac97[0]->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap;
     1499        }
    15231500
    15241501        return 0;
    15251502}
    15261503
    1527 static struct ich_pcm_table intel_pcms[] __devinitdata = {
     1504static const struct ich_pcm_table intel_pcms[] = {
    15281505        {
    15291506                .playback_ops = &snd_intel8x0_playback_ops,
     
    15621539};
    15631540
    1564 static struct ich_pcm_table nforce_pcms[] __devinitdata = {
     1541static const struct ich_pcm_table nforce_pcms[] = {
    15651542        {
    15661543                .playback_ops = &snd_intel8x0_playback_ops,
     
    15851562};
    15861563
    1587 static struct ich_pcm_table ali_pcms[] __devinitdata = {
     1564static const struct ich_pcm_table ali_pcms[] = {
    15881565        {
    15891566                .playback_ops = &snd_intel8x0_ali_playback_ops,
     
    16171594};
    16181595
    1619 static int __devinit snd_intel8x0_pcm(struct intel8x0 *chip)
     1596static int snd_intel8x0_pcm(struct intel8x0 *chip)
    16201597{
    16211598        int i, tblsize, device, err;
    1622         struct ich_pcm_table *tbl, *rec;
     1599        const struct ich_pcm_table *tbl, *rec;
    16231600
    16241601        switch (chip->device_type) {
     
    16801657}
    16811658
    1682 static struct ac97_pcm ac97_pcm_defs[] __devinitdata = {
     1659static const struct ac97_pcm ac97_pcm_defs[] = {
    16831660        /* front PCM */
    16841661        {
    16851662                .exclusive = 1,
    1686                 .r =
    1687                  {     
    1688                         {
     1663                .r = {  {
    16891664                                .slots = (1 << AC97_SLOT_PCM_LEFT) |
    16901665                                         (1 << AC97_SLOT_PCM_RIGHT) |
     
    17521727};
    17531728
    1754 static struct ac97_quirk ac97_quirks[] __devinitdata = {
    1755     {
     1729static const struct ac97_quirk ac97_quirks[] = {
     1730        {
    17561731                .subvendor = 0x0e11,
    17571732                .subdevice = 0x000e,
    17581733                .name = "Compaq Deskpro EN",    /* AD1885 */
    17591734                .type = AC97_TUNE_HP_ONLY
    1760     },
     1735        },
    17611736        {
    17621737                .subvendor = 0x0e11,
     
    17711746                .type = AC97_TUNE_HP_ONLY
    17721747        },
    1773     {
     1748        {
    17741749                .subvendor = 0x0e11,
    17751750                .subdevice = 0x0860,
    17761751                .name = "HP/Compaq nx7010",
    17771752                .type = AC97_TUNE_MUTE_LED
    1778     },
     1753        },
    17791754        {
    17801755                .subvendor = 0x1014,
     
    18841859                .name = "Dell Inspiron 6000",
    18851860                .type = AC97_TUNE_HP_MUTE_LED /* cf. Malone #41015 */
     1861        },
     1862        {
     1863                .subvendor = 0x1028,
     1864                .subdevice = 0x0189,
     1865                .name = "Dell Inspiron 9300",
     1866                .type = AC97_TUNE_HP_MUTE_LED
    18861867        },
    18871868        {
     
    20792060        {
    20802061                .subvendor = 0x161f,
     2062                .subdevice = 0x202f,
     2063                .name = "Gateway M520",
     2064                .type = AC97_TUNE_INV_EAPD
     2065        },
     2066        {
     2067                .subvendor = 0x161f,
    20812068                .subdevice = 0x203a,
    20822069                .name = "Gateway 4525GZ",               /* AD1981B */
     
    20872074                .subdevice = 0x0088,
    20882075                .name = "Fujitsu-Siemens D1522",        /* AD1981 */
    2089                 .type = AC97_TUNE_HP_ONLY
    2090         },
    2091         {
    2092                 .subvendor = 0x107B,
    2093                 .subdevice = 0x0111,
    2094                 .name = "Gateway 2000 ICH2/AD1885",
    20952076                .type = AC97_TUNE_HP_ONLY
    20962077        },
     
    21532134};
    21542135
    2155 static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
    2156                                         const char *quirk_override)
     2136static int snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
     2137                              const char *quirk_override)
    21572138{
    21582139        struct snd_ac97_bus *pbus;
     
    21612142        unsigned int i, codecs;
    21622143        unsigned int glob_sta = 0;
    2163         struct snd_ac97_bus_ops *ops;
    2164         static struct snd_ac97_bus_ops standard_bus_ops = {
     2144        const struct snd_ac97_bus_ops *ops;
     2145        static const struct snd_ac97_bus_ops standard_bus_ops = {
    21652146                .write = snd_intel8x0_codec_write,
    21662147                .read = snd_intel8x0_codec_read,
    21672148        };
    2168         static struct snd_ac97_bus_ops ali_bus_ops = {
     2149        static const struct snd_ac97_bus_ops ali_bus_ops = {
    21692150                .write = snd_intel8x0_ali_codec_write,
    21702151                .read = snd_intel8x0_ali_codec_read,
     
    21832164                        chip->spdif_idx = ICHD_SPBAR;
    21842165                        break;
    2185                 };
     2166                }
    21862167        }
    21872168
     
    22472228                if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
    22482229                        if (err != -EACCES)
    2249                                 snd_printk(KERN_ERR "Unable to initialize codec #%d\n", i);
     2230                                dev_err(chip->card->dev,
     2231                                        "Unable to initialize codec #%d\n", i);
    22502232                        if (i == 0)
    22512233                                goto __err;
     
    23502332
    23512333#ifdef CONFIG_SND_AC97_POWER_SAVE
    2352 static struct snd_pci_quirk ich_chip_reset_mode[] = {
     2334static const struct snd_pci_quirk ich_chip_reset_mode[] = {
    23532335        SND_PCI_QUIRK(0x1014, 0x051f, "Thinkpad R32", 1),
    2354         { } /* end */
     2336        {0} /* end */
    23552337};
    23562338
     
    23992381                schedule_timeout_uninterruptible(1);
    24002382        } while (time_after_eq(end_time, jiffies));
    2401         snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n",
     2383        dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n",
    24022384                   igetdword(chip, ICHREG(GLOB_CNT)));
    24032385        return -EIO;
     
    24432425                if (! status) {
    24442426                        /* no codec is found */
    2445                         snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n",
     2427                        dev_err(chip->card->dev,
     2428                                "codec_ready: codec is not ready [0x%x]\n",
    24462429                                   igetdword(chip, ICHREG(GLOB_STA)));
    24472430                        return -EIO;
     
    25072490                schedule_timeout_uninterruptible(1);
    25082491        }
    2509         snd_printk(KERN_ERR "AC'97 reset failed.\n");
     2492        dev_err(chip->card->dev, "AC'97 reset failed.\n");
    25102493        if (probing)
    25112494                return -EIO;
     
    25512534                }
    25522535                if (timeout == 0)
    2553                         printk(KERN_ERR "intel8x0: reset of registers failed?\n");
     2536                        dev_err(chip->card->dev, "reset of registers failed?\n");
    25542537        }
    25552538        /* initialize Buffer Descriptor Lists */
     
    25842567        if (chip->irq >= 0)
    25852568                free_irq(chip->irq, chip);
    2586         if (chip->bdbars.area) {
    2587                 if (chip->fix_nocache)
    2588                         fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 0);
     2569        if (chip->bdbars.area)
    25892570                snd_dma_free_pages(&chip->bdbars);
    2590         }
    25912571        if (chip->addr)
    25922572                pci_iounmap(chip->pci, chip->addr);
     
    25992579}
    26002580
    2601 #ifdef CONFIG_PM
     2581#ifdef CONFIG_PM_SLEEP
    26022582/*
    26032583 * power management
    26042584 */
    2605 static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state)
    2606 {
    2607         struct snd_card *card = pci_get_drvdata(pci);
     2585static int intel8x0_suspend(struct device *dev)
     2586{
     2587        struct snd_card *card = dev_get_drvdata(dev);
    26082588        struct intel8x0 *chip = card->private_data;
    26092589        int i;
    26102590
    26112591        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
    2612         for (i = 0; i < chip->pcm_devs; i++)
    2613                 snd_pcm_suspend_all(chip->pcm[i]);
    2614         /* clear nocache */
    2615         if (chip->fix_nocache) {
    2616                 for (i = 0; i < chip->bdbars_count; i++) {
    2617                         struct ichdev *ichdev = &chip->ichd[i];
    2618                         if (ichdev->substream && ichdev->page_attr_changed) {
    2619                                 struct snd_pcm_runtime *runtime = ichdev->substream->runtime;
    2620                                 if (runtime->dma_area)
    2621                                         fill_nocache(runtime->dma_area, runtime->dma_bytes, 0);
    2622                         }
    2623                 }
    2624         }
    26252592        for (i = 0; i < chip->ncodecs; i++)
    26262593                snd_ac97_suspend(chip->ac97[i]);
     
    26312598                free_irq(chip->irq, chip);
    26322599                chip->irq = -1;
    2633         }
    2634         pci_disable_device(pci);
    2635         pci_save_state(pci);
    2636         /* The call below may disable built-in speaker on some laptops
    2637          * after S2RAM.  So, don't touch it.
    2638          */
    2639         /* pci_set_power_state(pci, pci_choose_state(pci, state)); */
     2600                card->sync_irq = -1;
     2601        }
    26402602        return 0;
    26412603}
    26422604
    2643 static int intel8x0_resume(struct pci_dev *pci)
    2644 {
    2645         struct snd_card *card = pci_get_drvdata(pci);
     2605static int intel8x0_resume(struct device *dev)
     2606{
     2607        struct pci_dev *pci = to_pci_dev(dev);
     2608        struct snd_card *card = dev_get_drvdata(dev);
    26462609        struct intel8x0 *chip = card->private_data;
    26472610        int i;
    26482611
    2649         pci_set_power_state(pci, PCI_D0);
    2650         pci_restore_state(pci);
    2651         if (pci_enable_device(pci) < 0) {
    2652                 printk(KERN_ERR "intel8x0: pci_enable_device failed, "
    2653                        "disabling device\n");
     2612        snd_intel8x0_chip_init(chip, 0);
     2613        if (request_irq(pci->irq, snd_intel8x0_interrupt,
     2614                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
     2615                dev_err(dev, "unable to grab IRQ %d, disabling device\n",
     2616                        pci->irq);
    26542617                snd_card_disconnect(card);
    26552618                return -EIO;
    26562619        }
    2657         pci_set_master(pci);
    2658         snd_intel8x0_chip_init(chip, 0);
    2659         if (request_irq(pci->irq, snd_intel8x0_interrupt,
    2660                         IRQF_SHARED, card->shortname, chip)) {
    2661                 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, "
    2662                        "disabling device\n", pci->irq);
    2663                 snd_card_disconnect(card);
    2664                 return -EIO;
    2665         }
    26662620        chip->irq = pci->irq;
    2667         synchronize_irq(chip->irq);
     2621        card->sync_irq = chip->irq;
    26682622
    26692623        /* re-initialize mixer stuff */
     
    26772631        }
    26782632
    2679         /* refill nocache */
    2680         if (chip->fix_nocache)
    2681                 fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 1);
    2682 
    26832633        for (i = 0; i < chip->ncodecs; i++)
    26842634                snd_ac97_resume(chip->ac97[i]);
    2685 
    2686         /* refill nocache */
    2687         if (chip->fix_nocache) {
    2688                 for (i = 0; i < chip->bdbars_count; i++) {
    2689                         struct ichdev *ichdev = &chip->ichd[i];
    2690                         if (ichdev->substream && ichdev->page_attr_changed) {
    2691                                 struct snd_pcm_runtime *runtime = ichdev->substream->runtime;
    2692                                 if (runtime->dma_area)
    2693                                         fill_nocache(runtime->dma_area, runtime->dma_bytes, 1);
    2694                         }
    2695                 }
    2696         }
    26972635
    26982636        /* resume status */
     
    27132651        return 0;
    27142652}
    2715 #endif /* CONFIG_PM */
     2653
     2654static SIMPLE_DEV_PM_OPS(intel8x0_pm, intel8x0_suspend, intel8x0_resume);
     2655#define INTEL8X0_PM_OPS &intel8x0_pm
     2656#else
     2657#define INTEL8X0_PM_OPS NULL
     2658#endif /* CONFIG_PM_SLEEP */
    27162659
    27172660#define INTEL8X0_TESTBUF_SIZE   32768   /* enough large for one shot */
    27182661
    2719 static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip)
     2662static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
    27202663{
    27212664        struct snd_pcm_substream *subs;
     
    27242667        unsigned long pos, pos1, t;
    27252668        int civ, timeout = 1000, attempt = 1;
     2669#ifndef TARGET_OS2
     2670        ktime_t start_time, stop_time;
     2671#else
    27262672        struct timespec start_time, stop_time;
     2673#endif
    27272674
    27282675        if (chip->ac97_bus->clock != 48000)
     
    27322679        subs = chip->pcm[0]->streams[0].substream;
    27332680        if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) {
    2734                 snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n");
     2681                dev_warn(chip->card->dev,
     2682                         "no playback buffer allocated - aborting measure ac97 clock\n");
    27352683                return;
    27362684        }
     
    27422690        /* set rate */
    27432691        if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) {
    2744                 snd_printk(KERN_ERR "cannot set ac97 rate: clock = %d\n", chip->ac97_bus->clock);
     2692                dev_err(chip->card->dev, "cannot set ac97 rate: clock = %d\n",
     2693                        chip->ac97_bus->clock);
    27452694                return;
    27462695        }
     
    27562705                iputdword(chip, ICHREG(ALI_DMACR), 1 << ichdev->ali_slot);
    27572706        }
     2707#ifndef TARGET_OS2
     2708        start_time = ktime_get();
     2709#else
    27582710        do_posix_clock_monotonic_gettime(&start_time);
     2711#endif
    27592712        spin_unlock_irq(&chip->reg_lock);
    27602713        msleep(50);
     
    27802733        }
    27812734        chip->in_measurement = 0;
     2735#ifndef TARGET_OS2
     2736        stop_time = ktime_get();
     2737#else
    27822738        do_posix_clock_monotonic_gettime(&stop_time);
     2739#endif
    27832740        /* stop */
    27842741        if (chip->device_type == DEVICE_ALI) {
     
    27962753
    27972754        if (pos == 0) {
    2798                 snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n");
     2755                dev_err(chip->card->dev,
     2756                        "measure - unreliable DMA position..\n");
    27992757              __retry:
    28002758                if (attempt < 3) {
     
    28072765
    28082766        pos /= 4;
     2767#ifndef TARGET_OS2
     2768        t = ktime_us_delta(stop_time, start_time);
     2769#else
    28092770        t = stop_time.tv_sec - start_time.tv_sec;
    28102771        t *= 1000000;
    28112772        t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000;
    28122773        dprintf(("%s: measured %lu usecs (%lu samples)\n", __func__, t, pos));
     2774#endif
     2775        dev_info(chip->card->dev,
     2776                 "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
    28132777        if (t == 0) {
    2814                 snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n");
     2778                dev_err(chip->card->dev, "?? calculation error..\n");
    28152779                goto __retry;
    28162780        }
     
    28192783        if (pos < 40000 || pos >= 60000) {
    28202784                /* abnormal value. hw problem? */
    2821                 printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos);
     2785                dev_info(chip->card->dev, "measured clock %ld rejected\n", pos);
    28222786                goto __retry;
    28232787        } else if (pos > 40500 && pos < 41500)
     
    28312795                chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
    28322796      __end:
    2833         dprintf(("intel8x0: clocking to %d\n", chip->ac97_bus->clock));
     2797        dev_info(chip->card->dev, "clocking to %d\n", chip->ac97_bus->clock);
    28342798        snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
    28352799}
    28362800
    2837 static struct snd_pci_quirk intel8x0_clock_list[] __devinitdata = {
     2801static const struct snd_pci_quirk intel8x0_clock_list[] = {
    28382802        SND_PCI_QUIRK(0x0e11, 0x008a, "AD1885", 41000),
     2803        SND_PCI_QUIRK(0x1014, 0x0581, "AD1981B", 48000),
    28392804        SND_PCI_QUIRK(0x1028, 0x00be, "AD1885", 44100),
    28402805        SND_PCI_QUIRK(0x1028, 0x0177, "AD1980", 48000),
     
    28442809};
    28452810
    2846 static int __devinit intel8x0_in_clock_list(struct intel8x0 *chip)
     2811static int intel8x0_in_clock_list(struct intel8x0 *chip)
    28472812{
    28482813        struct pci_dev *pci = chip->pci;
     
    28522817        if (!wl)
    28532818                return 0;
    2854         printk(KERN_INFO "intel8x0: white list rate for %04x:%04x is %i\n",
     2819        dev_info(chip->card->dev, "allow list rate for %04x:%04x is %i\n",
    28552820               pci->subsystem_vendor, pci->subsystem_device, wl->value);
    28562821        chip->ac97_bus->clock = wl->value;
     
    28582823}
    28592824
    2860 #ifdef CONFIG_PROC_FS
    28612825static void snd_intel8x0_proc_read(struct snd_info_entry * entry,
    28622826                                   struct snd_info_buffer *buffer)
     
    28932857}
    28942858
    2895 static void __devinit snd_intel8x0_proc_init(struct intel8x0 * chip)
    2896 {
    2897         struct snd_info_entry *entry;
    2898 
    2899         if (! snd_card_proc_new(chip->card, "intel8x0", &entry))
    2900                 snd_info_set_text_ops(entry, chip, snd_intel8x0_proc_read);
    2901 }
    2902 #else
    2903 #define snd_intel8x0_proc_init(x)
    2904 #endif
     2859static void snd_intel8x0_proc_init(struct intel8x0 *chip)
     2860{
     2861        snd_card_ro_proc_new(chip->card, "intel8x0", chip,
     2862                             snd_intel8x0_proc_read);
     2863}
    29052864
    29062865static int snd_intel8x0_dev_free(struct snd_device *device)
     
    29152874};
    29162875
    2917 static unsigned int ich_codec_bits[3] = {
     2876static const unsigned int ich_codec_bits[3] = {
    29182877        ICH_PCR, ICH_SCR, ICH_TCR
    29192878};
    2920 static unsigned int sis_codec_bits[3] = {
     2879static const unsigned int sis_codec_bits[3] = {
    29212880        ICH_PCR, ICH_SCR, ICH_SIS_TCR
    29222881};
    29232882
    2924 static int __devinit snd_intel8x0_create(struct snd_card *card,
    2925                                          struct pci_dev *pci,
    2926                                          unsigned long device_type,
    2927                                          struct intel8x0 ** r_intel8x0)
     2883static int snd_intel8x0_inside_vm(struct pci_dev *pci)
     2884{
     2885        int result  = inside_vm;
     2886        char *msg   = NULL;
     2887
     2888        /* check module parameter first (override detection) */
     2889        if (result >= 0) {
     2890                msg = result ? "enable (forced) VM" : "disable (forced) VM";
     2891                goto fini;
     2892        }
     2893
     2894        /* check for known (emulated) devices */
     2895        result = 0;
     2896        if (pci->subsystem_vendor == PCI_SUBVENDOR_ID_REDHAT_QUMRANET &&
     2897            pci->subsystem_device == PCI_SUBDEVICE_ID_QEMU) {
     2898                /* KVM emulated sound, PCI SSID: 1af4:1100 */
     2899                msg = "enable KVM";
     2900                result = 1;
     2901        } else if (pci->subsystem_vendor == 0x1ab8) {
     2902                /* Parallels VM emulated sound, PCI SSID: 1ab8:xxxx */
     2903                msg = "enable Parallels VM";
     2904                result = 1;
     2905        }
     2906
     2907fini:
     2908        if (msg != NULL)
     2909                dev_info(&pci->dev, "%s optimization\n", msg);
     2910
     2911        return result;
     2912}
     2913
     2914static int snd_intel8x0_create(struct snd_card *card,
     2915                               struct pci_dev *pci,
     2916                               unsigned long device_type,
     2917                               struct intel8x0 **r_intel8x0)
    29282918{
    29292919        struct intel8x0 *chip;
     
    29322922        unsigned int int_sta_masks;
    29332923        struct ichdev *ichdev;
    2934         static struct snd_device_ops ops = {
     2924        static const struct snd_device_ops ops = {
    29352925                .dev_free =     snd_intel8x0_dev_free,
    29362926        };
    29372927
    2938         static unsigned int bdbars[] = {
     2928        static const unsigned int bdbars[] = {
    29392929                3, /* DEVICE_INTEL */
    29402930                6, /* DEVICE_INTEL_ICH4 */
     
    29432933                4, /* DEVICE_NFORCE */
    29442934        };
    2945         static struct ich_reg_info intel_regs[6] = {
     2935        static const struct ich_reg_info intel_regs[6] = {
    29462936                { ICH_PIINT, 0 },
    29472937                { ICH_POINT, 0x10 },
     
    29512941                { ICH_SPINT, 0x60 },
    29522942        };
    2953         static struct ich_reg_info nforce_regs[4] = {
     2943        static const struct ich_reg_info nforce_regs[4] = {
    29542944                { ICH_PIINT, 0 },
    29552945                { ICH_POINT, 0x10 },
     
    29572947                { ICH_NVSPINT, 0x70 },
    29582948        };
    2959         static struct ich_reg_info ali_regs[6] = {
     2949        static const struct ich_reg_info ali_regs[6] = {
    29602950                { ALI_INT_PCMIN, 0x40 },
    29612951                { ALI_INT_PCMOUT, 0x50 },
     
    29652955                { ALI_INT_SPDIFOUT, 0xb0 },
    29662956        };
    2967         struct ich_reg_info *tbl;
     2957        const struct ich_reg_info *tbl;
    29682958
    29692959        *r_intel8x0 = NULL;
     
    29892979                chip->xbox = 1;
    29902980
     2981        chip->inside_vm = snd_intel8x0_inside_vm(pci);
     2982
     2983        /*
     2984         * Intel 82443MX running a 100MHz processor system bus has a hardware
     2985         * bug, which aborts PCI busmaster for audio transfer.  A workaround
     2986         * is to set the pages as non-cached.  For details, see the errata in
     2987         *     http://download.intel.com/design/chipsets/specupdt/24505108.pdf
     2988         */
    29912989        if (pci->vendor == PCI_VENDOR_ID_INTEL &&
    29922990            pci->device == PCI_DEVICE_ID_INTEL_440MX)
     
    30103008                chip->addr = pci_iomap(pci, 0, 0);
    30113009        if (!chip->addr) {
    3012                 snd_printk(KERN_ERR "AC'97 space ioremap problem\n");
     3010                dev_err(card->dev, "AC'97 space ioremap problem\n");
    30133011                snd_intel8x0_free(chip);
    30143012                return -EIO;
     
    30183016        else
    30193017                chip->bmaddr = pci_iomap(pci, 1, 0);
     3018
     3019 port_inited:
    30203020        if (!chip->bmaddr) {
    3021                 snd_printk(KERN_ERR "Controller space ioremap problem\n");
     3021                dev_err(card->dev, "Controller space ioremap problem\n");
    30223022                snd_intel8x0_free(chip);
    30233023                return -EIO;
    30243024        }
    3025 
    3026  port_inited:
    30273025        chip->bdbars_count = bdbars[device_type];
    30283026
     
    30603058        /* allocate buffer descriptor lists */
    30613059        /* the start of each lists must be aligned to 8 bytes */
    3062         if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
     3060        if (snd_dma_alloc_pages(intel8x0_dma_type(chip), &pci->dev,
    30633061                                chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2,
    30643062                                &chip->bdbars) < 0) {
    30653063                snd_intel8x0_free(chip);
    3066                 snd_printk(KERN_ERR "intel8x0: cannot allocate buffer descriptors\n");
     3064                dev_err(card->dev, "cannot allocate buffer descriptors\n");
    30673065                return -ENOMEM;
    30683066        }
    30693067        /* tables must be aligned to 8 bytes here, but the kernel pages
    30703068           are much bigger, so we don't care (on i386) */
    3071         /* workaround for 440MX */
    3072         if (chip->fix_nocache)
    3073                 fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 1);
    30743069        int_sta_masks = 0;
    30753070        for (i = 0; i < chip->bdbars_count; i++) {
    30763071                ichdev = &chip->ichd[i];
    3077                 ichdev->bdbar = ((u32 *)chip->bdbars.area) +
     3072                ichdev->bdbar = ((__le32 *)chip->bdbars.area) +
    30783073                        (i * ICH_MAX_FRAGS * 2);
    30793074                ichdev->bdbar_addr = chip->bdbars.addr +
     
    31173112        /* request irq after initializaing int_sta_mask, etc */
    31183113        if (request_irq(pci->irq, snd_intel8x0_interrupt,
    3119                         IRQF_SHARED, card->shortname, chip)) {
    3120                 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
     3114                        IRQF_SHARED, KBUILD_MODNAME, chip)) {
     3115                dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
    31213116                snd_intel8x0_free(chip);
    31223117                return -EBUSY;
    31233118        }
    31243119        chip->irq = pci->irq;
     3120        card->sync_irq = chip->irq;
    31253121
    31263122        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
     
    31293125        }
    31303126
    3131         snd_card_set_dev(card, &pci->dev);
    3132 
    31333127        *r_intel8x0 = chip;
    31343128        return 0;
     
    31383132        unsigned int id;
    31393133        const char *s;
    3140 } shortnames[] __devinitdata = {
     3134} shortnames[] = {
    31413135        { PCI_DEVICE_ID_INTEL_82801AA_5, "Intel 82801AA-ICH" },
    31423136        { PCI_DEVICE_ID_INTEL_82801AB_5, "Intel 82901AB-ICH0" },
     
    31643158};
    31653159
    3166 #ifdef NOT_USED
    3167 static struct snd_pci_quirk spdif_aclink_defaults[] __devinitdata = {
     3160static const struct snd_pci_quirk spdif_aclink_defaults[] = {
    31683161        SND_PCI_QUIRK(0x147b, 0x1c1a, "ASUS KN8", 1),
    31693162        {0} /* end */
    31703163};
    3171 #endif
    3172 
    3173 /* look up white/black list for SPDIF over ac-link */
    3174 static int __devinit check_default_spdif_aclink(struct pci_dev *pci)
    3175 {
    3176 #ifndef TARGET_OS2
     3164
     3165/* look up allow/deny list for SPDIF over ac-link */
     3166static int check_default_spdif_aclink(struct pci_dev *pci)
     3167{
    31773168        const struct snd_pci_quirk *w;
    31783169
     
    31803171        if (w) {
    31813172                if (w->value)
    3182                         snd_printdd(KERN_INFO "intel8x0: Using SPDIF over "
    3183                                     "AC-Link for %s\n", w->name);
     3173                        dev_dbg(&pci->dev,
     3174                                "Using SPDIF over AC-Link for %s\n",
     3175                                    snd_pci_quirk_name(w));
    31843176                else
    3185                         snd_printdd(KERN_INFO "intel8x0: Using integrated "
    3186                                     "SPDIF DMA for %s\n", w->name);
     3177                        dev_dbg(&pci->dev,
     3178                                "Using integrated SPDIF DMA for %s\n",
     3179                                    snd_pci_quirk_name(w));
    31873180                return w->value;
    31883181        }
    3189 #endif
    31903182        return 0;
    31913183}
    31923184
    3193 static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
    3194                                         const struct pci_device_id *pci_id)
     3185static int snd_intel8x0_probe(struct pci_dev *pci,
     3186                              const struct pci_device_id *pci_id)
    31953187{
    31963188        struct snd_card *card;
     
    31993191        struct shortname_table *name;
    32003192
    3201         err = snd_card_create(index, id, THIS_MODULE, 0, &card);
     3193        err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
    32023194        if (err < 0)
    32033195                return err;
     
    32743266}
    32753267
    3276 static void __devexit snd_intel8x0_remove(struct pci_dev *pci)
     3268static void snd_intel8x0_remove(struct pci_dev *pci)
    32773269{
    32783270        snd_card_free(pci_get_drvdata(pci));
    3279         pci_set_drvdata(pci, NULL);
    3280 }
    3281 
    3282 static struct pci_driver driver = {
    3283         .name = "Intel ICH",
     3271}
     3272
     3273static struct pci_driver intel8x0_driver = {
     3274        .name = KBUILD_MODNAME,
    32843275        .id_table = snd_intel8x0_ids,
    32853276        .probe = snd_intel8x0_probe,
    3286         .remove = __devexit_p(snd_intel8x0_remove),
    3287 #ifdef CONFIG_PM
    3288         .suspend = intel8x0_suspend,
    3289         .resume = intel8x0_resume,
    3290 #endif
    3291 };
    3292 
    3293 
    3294 static int __init alsa_card_intel8x0_init(void)
    3295 {
    3296         return pci_register_driver(&driver);
    3297 }
    3298 
    3299 static void __exit alsa_card_intel8x0_exit(void)
    3300 {
    3301         pci_unregister_driver(&driver);
    3302 }
    3303 
    3304 module_init(alsa_card_intel8x0_init)
    3305 module_exit(alsa_card_intel8x0_exit)
     3277        .remove = snd_intel8x0_remove,
     3278        .driver = {
     3279                .pm = INTEL8X0_PM_OPS,
     3280        },
     3281};
     3282
     3283module_pci_driver(intel8x0_driver);
Note: See TracChangeset for help on using the changeset viewer.