Ignore:
Timestamp:
Jan 14, 2006, 6:38:48 PM (20 years ago)
Author:
vladest
Message:

Ensonic/Maestro3/VIA/ATI power management fixes
Intel ICH SI7012 fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/alsa-kernel/pci/atiixp.c

    r32 r70  
    2727#include <linux/pci.h>
    2828#include <linux/slab.h>
     29#include <linux/moduleparam.h>
    2930#include <sound/core.h>
    3031#include <sound/pcm.h>
     
    3940MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250/300/400}}");
    4041
    41 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;      /* Index 0-MAX */
    42 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;       /* ID for this card */
    43 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;      /* Enable this card */
    44 static int ac97_clock[SNDRV_CARDS] = {48000,0,0,0,0,0,0,0};
    45 static char *ac97_quirk[SNDRV_CARDS];
    46 static int spdif_aclink[SNDRV_CARDS] = {1,1,1,1,1,1,1,1};
    47 
    48 //module_param_array(index, int, NULL, 0444);
     42static int index = SNDRV_DEFAULT_IDX1;  /* Index 0-MAX */
     43static char *id = SNDRV_DEFAULT_STR1;   /* ID for this card */
     44static int ac97_clock = 48000;
     45static char *ac97_quirk;
     46static int spdif_aclink = 1;
     47
     48//module_param(index, int, 0444);
    4949MODULE_PARM_DESC(index, "Index value for ATI IXP controller.");
    50 //module_param_array(id, charp, NULL, 0444);
     50//module_param(id, charp, 0444);
    5151MODULE_PARM_DESC(id, "ID string for ATI IXP controller.");
    52 //module_param_array(enable, bool, NULL, 0444);
    53 MODULE_PARM_DESC(enable, "Enable audio part of ATI IXP controller.");
    54 //module_param_array(ac97_clock, int, NULL, 0444);
     52//module_param(ac97_clock, int, 0444);
    5553MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
    56 //module_param_array(ac97_quirk, charp, NULL, 0444);
     54//module_param(ac97_quirk, charp, 0444);
    5755MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
    58 //module_param_array(spdif_aclink, bool, NULL, 0444);
     56//module_param(spdif_aclink, bool, 0444);
    5957MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link.");
     58
     59/* just for backward compatibility */
     60static int enable;
     61//module_param(enable, bool, 0444);
    6062
    6163
     
    196198
    197199
    198 /*
    199  */
    200 
    201 typedef struct snd_atiixp atiixp_t;
    202 typedef struct snd_atiixp_dma atiixp_dma_t;
    203 typedef struct snd_atiixp_dma_ops atiixp_dma_ops_t;
    204 
     200struct atiixp;
    205201
    206202/*
     
    208204 */
    209205
    210 typedef struct atiixp_dma_desc {
     206struct atiixp_dma_desc {
    211207        u32 addr;       /* DMA buffer address */
    212208        u16 status;     /* status bits */
    213209        u16 size;       /* size of the packet in dwords */
    214210        u32 next;       /* address of the next packet descriptor */
    215 } atiixp_dma_desc_t;
     211};
    216212
    217213/*
     
    228224 * constants and callbacks for each DMA type
    229225 */
    230 struct snd_atiixp_dma_ops {
     226struct atiixp_dma_ops {
    231227        int type;                       /* ATI_DMA_XXX */
    232228        unsigned int llp_offset;        /* LINKPTR offset */
    233229        unsigned int dt_cur;            /* DT_CUR offset */
    234         void (*enable_dma)(atiixp_t *chip, int on);     /* called from open callback */
    235         void (*enable_transfer)(atiixp_t *chip, int on); /* called from trigger (START/STOP) */
    236         void (*flush_dma)(atiixp_t *chip);              /* called from trigger (STOP only) */
     230        /* called from open callback */
     231        void (*enable_dma)(struct atiixp *chip, int on);
     232        /* called from trigger (START/STOP) */
     233        void (*enable_transfer)(struct atiixp *chip, int on);
     234        /* called from trigger (STOP only) */
     235        void (*flush_dma)(struct atiixp *chip);
    237236};
    238237
     
    240239 * DMA stream
    241240 */
    242 struct snd_atiixp_dma {
    243         const atiixp_dma_ops_t *ops;
     241struct atiixp_dma {
     242        const struct atiixp_dma_ops *ops;
    244243        struct snd_dma_buffer desc_buf;
    245         snd_pcm_substream_t *substream; /* assigned PCM substream */
     244        struct snd_pcm_substream *substream;    /* assigned PCM substream */
    246245        unsigned int buf_addr, buf_bytes;       /* DMA buffer address, bytes */
    247246        unsigned int period_bytes, periods;
    248247        int opened;
    249         int running;
    250         int suspended;
     248        int running;
     249        int suspended;
    251250        int pcm_open_flag;
    252         int ac97_pcm_type;      /* index # of ac97_pcm to access, -1 = not used */
    253         unsigned int saved_curptr;
     251        int ac97_pcm_type;      /* index # of ac97_pcm to access, -1 = not used */
     252        unsigned int saved_curptr;
    254253};
    255254
     
    257256 * ATI IXP chip
    258257 */
    259 struct snd_atiixp {
    260         snd_card_t *card;
     258struct atiixp {
     259        struct snd_card *card;
    261260        struct pci_dev *pci;
    262261
     
    264263        void __iomem *remap_addr;
    265264        int irq;
    266 
    267         ac97_bus_t *ac97_bus;
    268         ac97_t *ac97[NUM_ATI_CODECS];
     265       
     266        struct snd_ac97_bus *ac97_bus;
     267        struct snd_ac97 *ac97[NUM_ATI_CODECS];
    269268
    270269        spinlock_t reg_lock;
    271270
    272         atiixp_dma_t dmas[NUM_ATI_DMAS];
     271        struct atiixp_dma dmas[NUM_ATI_DMAS];
    273272        struct ac97_pcm *pcms[NUM_ATI_PCMS];
    274         snd_pcm_t *pcmdevs[NUM_ATI_PCMDEVS];
     273        struct snd_pcm *pcmdevs[NUM_ATI_PCMDEVS];
    275274
    276275        int max_channels;               /* max. channels for PCM out */
     
    303302 * return 1 if the bits changed.
    304303 */
    305 static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg,
     304static int snd_atiixp_update_bits(struct atiixp *chip, unsigned int reg,
    306305                                 unsigned int mask, unsigned int value)
    307306{
    308         void __iomem *addr = (char *)chip->remap_addr + reg;
     307        void __iomem *addr = (char*)chip->remap_addr + reg;
    309308        unsigned int data, old_data;
    310309        old_data = data = readl(addr);
     
    321320 */
    322321#define atiixp_write(chip,reg,value) \
    323         writel(value, (char *)chip->remap_addr + ATI_REG_##reg)
     322        writel(value, (char*)chip->remap_addr + ATI_REG_##reg)
    324323#define atiixp_read(chip,reg) \
    325         readl((char *)chip->remap_addr + ATI_REG_##reg)
     324        readl((char*)chip->remap_addr + ATI_REG_##reg)
    326325#define atiixp_update(chip,reg,mask,val) \
    327326        snd_atiixp_update_bits(chip, ATI_REG_##reg, mask, val)
     
    335334
    336335#define ATI_DESC_LIST_SIZE \
    337         PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof(atiixp_dma_desc_t))
     336        PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof(struct atiixp_dma_desc))
    338337
    339338/*
     
    344343 * a static RING of buffer descriptors is used.
    345344 *
    346  * the ring is built in this function, and is set up to the hardware.
    347  */
    348 static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma,
    349                                    snd_pcm_substream_t *substream,
    350                                    unsigned int periods,
    351                                    unsigned int period_bytes)
     345 * the ring is built in this function, and is set up to the hardware. 
     346 */
     347static int atiixp_build_dma_packets(struct atiixp *chip, struct atiixp_dma *dma,
     348                                    struct snd_pcm_substream *substream,
     349                                    unsigned int periods,
     350                                    unsigned int period_bytes)
    352351{
    353352        unsigned int i;
     
    359358
    360359        if (dma->desc_buf.area == NULL) {
    361                 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
    362                                         ATI_DESC_LIST_SIZE, &dma->desc_buf) < 0)
     360                if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
     361                                        snd_dma_pci_data(chip->pci),
     362                                        ATI_DESC_LIST_SIZE,
     363                                        &dma->desc_buf) < 0)
    363364                        return -ENOMEM;
    364365                dma->period_bytes = dma->periods = 0; /* clear */
     
    370371        /* reset DMA before changing the descriptor table */
    371372        spin_lock_irqsave(&chip->reg_lock, flags);
    372         writel(0, (char *)chip->remap_addr + dma->ops->llp_offset);
     373        writel(0, (char*)chip->remap_addr + dma->ops->llp_offset);
    373374        dma->ops->enable_dma(chip, 0);
    374375        dma->ops->enable_dma(chip, 1);
     
    379380        desc_addr = (u32)dma->desc_buf.addr;
    380381        for (i = 0; i < periods; i++) {
    381                 atiixp_dma_desc_t *desc = &((atiixp_dma_desc_t *)dma->desc_buf.area)[i];
     382                struct atiixp_dma_desc *desc;
     383                desc = &((struct atiixp_dma_desc *)dma->desc_buf.area)[i];
    382384                desc->addr = cpu_to_le32(addr);
    383385                desc->status = 0;
    384386                desc->size = period_bytes >> 2; /* in dwords */
    385                 desc_addr += sizeof(atiixp_dma_desc_t);
     387                desc_addr += sizeof(struct atiixp_dma_desc);
    386388                if (i == periods - 1)
    387389                        desc->next = cpu_to_le32((u32)dma->desc_buf.addr);
     
    392394
    393395        writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN,
    394                (char *)chip->remap_addr + dma->ops->llp_offset);
     396               (char*)chip->remap_addr + dma->ops->llp_offset);
    395397
    396398        dma->period_bytes = period_bytes;
     
    403405 * remove the ring buffer and release it if assigned
    404406 */
    405 static void atiixp_clear_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, snd_pcm_substream_t *substream)
     407static void atiixp_clear_dma_packets(struct atiixp *chip, struct atiixp_dma *dma,
     408                                     struct snd_pcm_substream *substream)
    406409{
    407410        if (dma->desc_buf.area) {
    408                 writel(0, (char *)chip->remap_addr + dma->ops->llp_offset);
     411                writel(0, (char*)chip->remap_addr + dma->ops->llp_offset);
    409412                snd_dma_free_pages(&dma->desc_buf);
    410413                dma->desc_buf.area = NULL;
     
    415418 * AC97 interface
    416419 */
    417 static int snd_atiixp_acquire_codec(atiixp_t *chip)
     420static int snd_atiixp_acquire_codec(struct atiixp *chip)
    418421{
    419422        int timeout = 1000;
     
    429432}
    430433
    431 static unsigned short snd_atiixp_codec_read(atiixp_t *chip, unsigned short codec, unsigned short reg)
     434static unsigned short snd_atiixp_codec_read(struct atiixp *chip, unsigned short codec, unsigned short reg)
    432435{
    433436        unsigned int data;
     
    457460
    458461
    459 static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigned short reg, unsigned short val)
     462static void snd_atiixp_codec_write(struct atiixp *chip, unsigned short codec,
     463                                   unsigned short reg, unsigned short val)
    460464{
    461465        unsigned int data;
    462 
     466   
    463467        if (snd_atiixp_acquire_codec(chip) < 0)
    464468                return;
     
    470474
    471475
    472 static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg)
    473 {
    474     atiixp_t *chip = ac97->private_data;
    475     return snd_atiixp_codec_read(chip, ac97->num, reg);
    476 }
    477 
    478 static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
    479 {
    480         atiixp_t *chip = ac97->private_data;
     476static unsigned short snd_atiixp_ac97_read(struct snd_ac97 *ac97,
     477                                           unsigned short reg)
     478{
     479        struct atiixp *chip = ac97->private_data;
     480        return snd_atiixp_codec_read(chip, ac97->num, reg);
     481   
     482}
     483
     484static void snd_atiixp_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
     485                                  unsigned short val)
     486{
     487        struct atiixp *chip = ac97->private_data;
    481488        snd_atiixp_codec_write(chip, ac97->num, reg, val);
    482489}
     
    485492 * reset AC link
    486493 */
    487 static int snd_atiixp_aclink_reset(atiixp_t *chip)
     494static int snd_atiixp_aclink_reset(struct atiixp *chip)
    488495{
    489496        int timeout;
     
    498505        udelay(10);
    499506        atiixp_update(chip, CMD, ATI_REG_CMD_AC_SOFT_RESET, 0);
    500 
     507   
    501508        timeout = 10;
    502509        while (! (atiixp_read(chip, CMD) & ATI_REG_CMD_ACLINK_ACTIVE)) {
     
    505512                              ATI_REG_CMD_AC_SYNC);
    506513                atiixp_read(chip, CMD);
    507                 msleep(1);
     514                mdelay(1);
    508515                atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
    509516                if (--timeout) {
     
    521528
    522529#ifdef CONFIG_PM
    523 static int snd_atiixp_aclink_down(atiixp_t *chip)
     530static int snd_atiixp_aclink_down(struct atiixp *chip)
    524531{
    525532        // if (atiixp_read(chip, MODEM_MIRROR) & 0x1) /* modem running, too? */
     
    546553#define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME)
    547554
    548 static int snd_atiixp_codec_detect(atiixp_t *chip)
     555static int snd_atiixp_codec_detect(struct atiixp *chip)
    549556{
    550557        int timeout;
     
    555562        timeout = 50;
    556563        while (timeout-- > 0) {
    557                 msleep(1);
     564                mdelay(1);
    558565                if (chip->codec_not_ready_bits)
    559566                        break;
     
    572579 * enable DMA and irqs
    573580 */
    574 static int snd_atiixp_chip_start(atiixp_t *chip)
     581static int snd_atiixp_chip_start(struct atiixp *chip)
    575582{
    576583        unsigned int reg;
     
    602609 * disable DMA and IRQs
    603610 */
    604 static int snd_atiixp_chip_stop(atiixp_t *chip)
     611static int snd_atiixp_chip_stop(struct atiixp *chip)
    605612{
    606613        /* clear interrupt source */
     
    621628 * correctly...
    622629 */
    623 static snd_pcm_uframes_t snd_atiixp_pcm_pointer(snd_pcm_substream_t *substream)
    624 {
    625         atiixp_t *chip = snd_pcm_substream_chip(substream);
    626         snd_pcm_runtime_t *runtime = substream->runtime;
    627         atiixp_dma_t *dma = (atiixp_dma_t *)runtime->private_data;
    628         unsigned int curptr;
    629         int timeout = 1000;
    630 
    631         while (timeout--) {
    632             curptr = readl((char *)chip->remap_addr + dma->ops->dt_cur);
    633             if (curptr < dma->buf_addr)
    634                 continue;
    635             curptr -= dma->buf_addr;
    636             if (curptr >= dma->buf_bytes)
    637                 continue;
    638             return bytes_to_frames(runtime, curptr);
    639         }
    640         snd_printd("atiixp: invalid DMA pointer read 0x%x (buf=%x)\n",
    641                    readl((char*)chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);
    642         return 0;
     630static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substream)
     631{
     632        struct atiixp *chip = snd_pcm_substream_chip(substream);
     633        struct snd_pcm_runtime *runtime = substream->runtime;
     634        struct atiixp_dma *dma = runtime->private_data;
     635        unsigned int curptr;
     636        int timeout = 1000;
     637
     638        while (timeout--) {
     639                curptr = readl((char*)chip->remap_addr + dma->ops->dt_cur);
     640                if (curptr < dma->buf_addr)
     641                        continue;
     642                curptr -= dma->buf_addr;
     643                if (curptr >= dma->buf_bytes)
     644                        continue;
     645                return bytes_to_frames(runtime, curptr);
     646        }
     647        snd_printd("atiixp: invalid DMA pointer read 0x%x (buf=%x)\n",
     648                   readl((char*)chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);
     649        return 0;
    643650}
    644651
     
    646653 * XRUN detected, and stop the PCM substream
    647654 */
    648 static void snd_atiixp_xrun_dma(atiixp_t *chip, atiixp_dma_t *dma)
     655static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma)
    649656{
    650657        if (! dma->substream || ! dma->running)
     
    657664 * the period ack.  update the substream.
    658665 */
    659 static void snd_atiixp_update_dma(atiixp_t *chip, atiixp_dma_t *dma)
     666static void snd_atiixp_update_dma(struct atiixp *chip, struct atiixp_dma *dma)
    660667{
    661668        if (! dma->substream || ! dma->running)
     
    666673/* set BUS_BUSY interrupt bit if any DMA is running */
    667674/* call with spinlock held */
    668 static void snd_atiixp_check_bus_busy(atiixp_t *chip)
     675static void snd_atiixp_check_bus_busy(struct atiixp *chip)
    669676{
    670677        unsigned int bus_busy;
     
    681688 * calling the lowlevel callbacks in it
    682689 */
    683 static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
    684 {
    685         atiixp_t *chip = snd_pcm_substream_chip(substream);
    686         atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;
     690static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
     691{
     692        struct atiixp *chip = snd_pcm_substream_chip(substream);
     693        struct atiixp_dma *dma = substream->runtime->private_data;
    687694        int err = 0;
    688695
     
    691698        spin_lock(&chip->reg_lock);
    692699        switch (cmd) {
    693         case SNDRV_PCM_TRIGGER_START:
    694         case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
    695         case SNDRV_PCM_TRIGGER_RESUME:
     700        case SNDRV_PCM_TRIGGER_START:
     701        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
     702        case SNDRV_PCM_TRIGGER_RESUME:
    696703                dma->ops->enable_transfer(chip, 1);
    697                 dma->running = 1;
    698                 dma->suspended = 0;
     704                dma->running = 1;
     705                dma->suspended = 0;
    699706                break;
    700         case SNDRV_PCM_TRIGGER_STOP:
    701         case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
    702         case SNDRV_PCM_TRIGGER_SUSPEND:
     707        case SNDRV_PCM_TRIGGER_STOP:
     708        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
     709        case SNDRV_PCM_TRIGGER_SUSPEND:
    703710                dma->ops->enable_transfer(chip, 0);
    704                 dma->running = 0;
    705                 dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND;
     711                dma->running = 0;
     712                dma->suspended = cmd == SNDRV_PCM_TRIGGER_SUSPEND;
    706713                break;
    707714        default:
     
    728735
    729736/* flush FIFO of analog OUT DMA */
    730 static void atiixp_out_flush_dma(atiixp_t *chip)
     737static void atiixp_out_flush_dma(struct atiixp *chip)
    731738{
    732739        atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_OUT_FLUSH);
     
    734741
    735742/* enable/disable analog OUT DMA */
    736 static void atiixp_out_enable_dma(atiixp_t *chip, int on)
     743static void atiixp_out_enable_dma(struct atiixp *chip, int on)
    737744{
    738745        unsigned int data;
     
    749756
    750757/* start/stop transfer over OUT DMA */
    751 static void atiixp_out_enable_transfer(atiixp_t *chip, int on)
     758static void atiixp_out_enable_transfer(struct atiixp *chip, int on)
    752759{
    753760        atiixp_update(chip, CMD, ATI_REG_CMD_SEND_EN,
     
    756763
    757764/* enable/disable analog IN DMA */
    758 static void atiixp_in_enable_dma(atiixp_t *chip, int on)
     765static void atiixp_in_enable_dma(struct atiixp *chip, int on)
    759766{
    760767        atiixp_update(chip, CMD, ATI_REG_CMD_IN_DMA_EN,
     
    763770
    764771/* start/stop analog IN DMA */
    765 static void atiixp_in_enable_transfer(atiixp_t *chip, int on)
     772static void atiixp_in_enable_transfer(struct atiixp *chip, int on)
    766773{
    767774        if (on) {
     
    782789
    783790/* flush FIFO of analog IN DMA */
    784 static void atiixp_in_flush_dma(atiixp_t *chip)
     791static void atiixp_in_flush_dma(struct atiixp *chip)
    785792{
    786793        atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_IN_FLUSH);
     
    788795
    789796/* enable/disable SPDIF OUT DMA */
    790 static void atiixp_spdif_enable_dma(atiixp_t *chip, int on)
     797static void atiixp_spdif_enable_dma(struct atiixp *chip, int on)
    791798{
    792799        atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_DMA_EN,
     
    795802
    796803/* start/stop SPDIF OUT DMA */
    797 static void atiixp_spdif_enable_transfer(atiixp_t *chip, int on)
     804static void atiixp_spdif_enable_transfer(struct atiixp *chip, int on)
    798805{
    799806        unsigned int data;
     
    807814
    808815/* flush FIFO of SPDIF OUT DMA */
    809 static void atiixp_spdif_flush_dma(atiixp_t *chip)
     816static void atiixp_spdif_flush_dma(struct atiixp *chip)
    810817{
    811818        int timeout;
     
    814821        atiixp_spdif_enable_dma(chip, 0);
    815822        atiixp_spdif_enable_transfer(chip, 1);
    816 
     823       
    817824        timeout = 100;
    818825        do {
     
    826833
    827834/* set up slots and formats for SPDIF OUT */
    828 static int snd_atiixp_spdif_prepare(snd_pcm_substream_t *substream)
    829 {
    830         atiixp_t *chip = snd_pcm_substream_chip(substream);
     835static int snd_atiixp_spdif_prepare(struct snd_pcm_substream *substream)
     836{
     837        struct atiixp *chip = snd_pcm_substream_chip(substream);
    831838
    832839        spin_lock_irq(&chip->reg_lock);
     
    853860
    854861/* set up slots and formats for analog OUT */
    855 static int snd_atiixp_playback_prepare(snd_pcm_substream_t *substream)
    856 {
    857         atiixp_t *chip = snd_pcm_substream_chip(substream);
     862static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream)
     863{
     864        struct atiixp *chip = snd_pcm_substream_chip(substream);
    858865        unsigned int data;
    859866
     
    892899        atiixp_update(chip, 6CH_REORDER, ATI_REG_6CH_REORDER_EN,
    893900                      substream->runtime->channels >= 6 ? ATI_REG_6CH_REORDER_EN: 0);
    894 
     901   
    895902        spin_unlock_irq(&chip->reg_lock);
    896903        return 0;
     
    898905
    899906/* set up slots and formats for analog IN */
    900 static int snd_atiixp_capture_prepare(snd_pcm_substream_t *substream)
    901 {
    902         atiixp_t *chip = snd_pcm_substream_chip(substream);
     907static int snd_atiixp_capture_prepare(struct snd_pcm_substream *substream)
     908{
     909        struct atiixp *chip = snd_pcm_substream_chip(substream);
    903910
    904911        spin_lock_irq(&chip->reg_lock);
     
    913920 * hw_params - allocate the buffer and set up buffer descriptors
    914921 */
    915 static int snd_atiixp_pcm_hw_params(snd_pcm_substream_t *substream,
    916                                    snd_pcm_hw_params_t *hw_params)
    917 {
    918         atiixp_t *chip = snd_pcm_substream_chip(substream);
    919         atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;
     922static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream,
     923                                    struct snd_pcm_hw_params *hw_params)
     924{
     925        struct atiixp *chip = snd_pcm_substream_chip(substream);
     926        struct atiixp_dma *dma = substream->runtime->private_data;
    920927        int err;
    921928
     
    951958}
    952959
    953 static int snd_atiixp_pcm_hw_free(snd_pcm_substream_t * substream)
    954 {
    955         atiixp_t *chip = snd_pcm_substream_chip(substream);
    956         atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;
     960static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream)
     961{
     962        struct atiixp *chip = snd_pcm_substream_chip(substream);
     963        struct atiixp_dma *dma = substream->runtime->private_data;
    957964
    958965        if (dma->pcm_open_flag) {
     
    970977 * pcm hardware definition, identical for all DMA types
    971978 */
    972 static snd_pcm_hardware_t snd_atiixp_pcm_hw =
    973 {
    974         /*.info =               */ (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
    975                                     SNDRV_PCM_INFO_BLOCK_TRANSFER |
    976                                     SNDRV_PCM_INFO_PAUSE |
     979static struct snd_pcm_hardware snd_atiixp_pcm_hw =
     980{
     981        .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
     982                                SNDRV_PCM_INFO_BLOCK_TRANSFER |
     983                                SNDRV_PCM_INFO_PAUSE |
    977984                                 SNDRV_PCM_INFO_RESUME |
    978985                                 SNDRV_PCM_INFO_MMAP_VALID),
    979         /*.formats =            */SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
    980         /*.rates =              */SNDRV_PCM_RATE_48000,
    981         /*.rate_min =           */48000,
    982         /*.rate_max =           */48000,
    983         /*.channels_min =       */      2,
    984         /*.channels_max =       */      2,
    985         /*.buffer_bytes_max =   */256 * 1024,
    986         /*.period_bytes_min =   */32,
    987         /*.period_bytes_max =   */128 * 1024,
    988         /*.periods_min =        */      2,
    989          /*.periods_max =       */      ATI_MAX_DESCRIPTORS,
    990           0
     986        .formats =              SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
     987        .rates =                SNDRV_PCM_RATE_48000,
     988        .rate_min =             48000,
     989        .rate_max =             48000,
     990        .channels_min =         2,
     991        .channels_max =         2,
     992        .buffer_bytes_max =     256 * 1024,
     993        .period_bytes_min =     32,
     994        .period_bytes_max =     128 * 1024,
     995        .periods_min =          2,
     996        .periods_max =          ATI_MAX_DESCRIPTORS,
    991997};
    992998
    993 static int snd_atiixp_pcm_open(snd_pcm_substream_t *substream, atiixp_dma_t *dma, int pcm_type)
    994 {
    995         atiixp_t *chip = snd_pcm_substream_chip(substream);
    996         snd_pcm_runtime_t *runtime = substream->runtime;
     999static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream,
     1000                               struct atiixp_dma *dma, int pcm_type)
     1001{
     1002        struct atiixp *chip = snd_pcm_substream_chip(substream);
     1003        struct snd_pcm_runtime *runtime = substream->runtime;
    9971004        int err;
    9981005
     
    10241031}
    10251032
    1026 static int snd_atiixp_pcm_close(snd_pcm_substream_t *substream, atiixp_dma_t *dma)
    1027 {
    1028         atiixp_t *chip = snd_pcm_substream_chip(substream);
     1033static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream,
     1034                                struct atiixp_dma *dma)
     1035{
     1036        struct atiixp *chip = snd_pcm_substream_chip(substream);
    10291037        /* disable DMA bits */
    10301038        snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL);
     
    10391047/*
    10401048 */
    1041 static int snd_atiixp_playback_open(snd_pcm_substream_t *substream)
    1042 {
    1043         atiixp_t *chip = snd_pcm_substream_chip(substream);
     1049static int snd_atiixp_playback_open(struct snd_pcm_substream *substream)
     1050{
     1051        struct atiixp *chip = snd_pcm_substream_chip(substream);
    10441052        int err;
    10451053
     
    10571065}
    10581066
    1059 static int snd_atiixp_playback_close(snd_pcm_substream_t *substream)
    1060 {
    1061         atiixp_t *chip = snd_pcm_substream_chip(substream);
     1067static int snd_atiixp_playback_close(struct snd_pcm_substream *substream)
     1068{
     1069        struct atiixp *chip = snd_pcm_substream_chip(substream);
    10621070        int err;
    10631071        down(&chip->open_mutex);
     
    10671075}
    10681076
    1069 static int snd_atiixp_capture_open(snd_pcm_substream_t *substream)
    1070 {
    1071         atiixp_t *chip = snd_pcm_substream_chip(substream);
     1077static int snd_atiixp_capture_open(struct snd_pcm_substream *substream)
     1078{
     1079        struct atiixp *chip = snd_pcm_substream_chip(substream);
    10721080        return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_CAPTURE], 1);
    10731081}
    10741082
    1075 static int snd_atiixp_capture_close(snd_pcm_substream_t *substream)
    1076 {
    1077         atiixp_t *chip = snd_pcm_substream_chip(substream);
     1083static int snd_atiixp_capture_close(struct snd_pcm_substream *substream)
     1084{
     1085        struct atiixp *chip = snd_pcm_substream_chip(substream);
    10781086        return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_CAPTURE]);
    10791087}
    10801088
    1081 static int snd_atiixp_spdif_open(snd_pcm_substream_t *substream)
    1082 {
    1083         atiixp_t *chip = snd_pcm_substream_chip(substream);
     1089static int snd_atiixp_spdif_open(struct snd_pcm_substream *substream)
     1090{
     1091        struct atiixp *chip = snd_pcm_substream_chip(substream);
    10841092        int err;
    10851093        down(&chip->open_mutex);
     
    10921100}
    10931101
    1094 static int snd_atiixp_spdif_close(snd_pcm_substream_t *substream)
    1095 {
    1096         atiixp_t *chip = snd_pcm_substream_chip(substream);
     1102static int snd_atiixp_spdif_close(struct snd_pcm_substream *substream)
     1103{
     1104        struct atiixp *chip = snd_pcm_substream_chip(substream);
    10971105        int err;
    10981106        down(&chip->open_mutex);
     
    11061114
    11071115/* AC97 playback */
    1108 static snd_pcm_ops_t snd_atiixp_playback_ops = {
    1109         /*.open =      */ snd_atiixp_playback_open,
    1110         /*.close =     */ snd_atiixp_playback_close,
    1111         /*.ioctl =     */ snd_pcm_lib_ioctl,
    1112         /*.hw_params = */ snd_atiixp_pcm_hw_params,
    1113         /*.hw_free =   */ snd_atiixp_pcm_hw_free,
    1114         /*.prepare =   */ snd_atiixp_playback_prepare,
    1115         /*.trigger =   */ snd_atiixp_pcm_trigger,
    1116         /*.pointer =   */ snd_atiixp_pcm_pointer,
    1117         0,0,0,0
     1116static struct snd_pcm_ops snd_atiixp_playback_ops = {
     1117        .open =         snd_atiixp_playback_open,
     1118        .close =        snd_atiixp_playback_close,
     1119        .ioctl =        snd_pcm_lib_ioctl,
     1120        .hw_params =    snd_atiixp_pcm_hw_params,
     1121        .hw_free =      snd_atiixp_pcm_hw_free,
     1122        .prepare =      snd_atiixp_playback_prepare,
     1123        .trigger =      snd_atiixp_pcm_trigger,
     1124        .pointer =      snd_atiixp_pcm_pointer,
    11181125};
    11191126
    11201127/* AC97 capture */
    1121 static snd_pcm_ops_t snd_atiixp_capture_ops = {
    1122         /*.open =      */ snd_atiixp_capture_open,
    1123         /*.close =     */ snd_atiixp_capture_close,
    1124         /*.ioctl =     */ snd_pcm_lib_ioctl,
    1125         /*.hw_params = */ snd_atiixp_pcm_hw_params,
    1126         /*.hw_free =   */ snd_atiixp_pcm_hw_free,
    1127         /*.prepare =   */ snd_atiixp_capture_prepare,
    1128         /*.trigger =   */ snd_atiixp_pcm_trigger,
    1129         /*.pointer =   */ snd_atiixp_pcm_pointer,
    1130         0,0,0,0
     1128static struct snd_pcm_ops snd_atiixp_capture_ops = {
     1129        .open =         snd_atiixp_capture_open,
     1130        .close =        snd_atiixp_capture_close,
     1131        .ioctl =        snd_pcm_lib_ioctl,
     1132        .hw_params =    snd_atiixp_pcm_hw_params,
     1133        .hw_free =      snd_atiixp_pcm_hw_free,
     1134        .prepare =      snd_atiixp_capture_prepare,
     1135        .trigger =      snd_atiixp_pcm_trigger,
     1136        .pointer =      snd_atiixp_pcm_pointer,
    11311137};
    11321138
    11331139/* SPDIF playback */
    1134 static snd_pcm_ops_t snd_atiixp_spdif_ops = {
    1135         /*.open =      */       snd_atiixp_spdif_open,
    1136         /*.close =     */ snd_atiixp_spdif_close,
    1137         /*.ioctl =     */ snd_pcm_lib_ioctl,
    1138         /*.hw_params = */ snd_atiixp_pcm_hw_params,
    1139         /*.hw_free =   */ snd_atiixp_pcm_hw_free,
    1140         /*.prepare =   */ snd_atiixp_spdif_prepare,
    1141         /*.trigger =   */ snd_atiixp_pcm_trigger,
    1142         /*.pointer =   */ snd_atiixp_pcm_pointer,
    1143         0,0,0,0
     1140static struct snd_pcm_ops snd_atiixp_spdif_ops = {
     1141        .open =         snd_atiixp_spdif_open,
     1142        .close =        snd_atiixp_spdif_close,
     1143        .ioctl =        snd_pcm_lib_ioctl,
     1144        .hw_params =    snd_atiixp_pcm_hw_params,
     1145        .hw_free =      snd_atiixp_pcm_hw_free,
     1146        .prepare =      snd_atiixp_spdif_prepare,
     1147        .trigger =      snd_atiixp_pcm_trigger,
     1148        .pointer =      snd_atiixp_pcm_pointer,
    11441149};
    11451150
    11461151static struct ac97_pcm atiixp_pcm_defs[] __devinitdata = {
    1147     /* front PCM */
    1148     {
    1149         0,0,
    1150         /*.exclusive = */1,
    1151         0,0,0,0,
    1152         /*.r = */{{
    1153                     /*.slots = */(1 << AC97_SLOT_PCM_LEFT) |
    1154                         (1 << AC97_SLOT_PCM_RIGHT) |
    1155                         (1 << AC97_SLOT_PCM_CENTER) |
    1156                         (1 << AC97_SLOT_PCM_SLEFT) |
    1157                         (1 << AC97_SLOT_PCM_SRIGHT) |
    1158                         (1 << AC97_SLOT_LFE),
    1159                     {0},
    1160                     {0},
    1161                     0
    1162         }, {0}
    1163         },
    1164         0
    1165     },
    1166     /* PCM IN #1 */
    1167     {
    1168         0,
    1169         /*.stream = */1,
    1170         /*.exclusive = */1,
    1171         0,0,0,0,
    1172         /*.r = */{      {
    1173             /*.slots =*/ (1 << AC97_SLOT_PCM_LEFT) |
    1174                 (1 << AC97_SLOT_PCM_RIGHT),
    1175                 {0},
    1176                 {0},
    1177                 0
    1178         },{0}
    1179         }, 0
    1180     },
    1181     /* S/PDIF OUT (optional) */
    1182     {
    1183         0, 0,
    1184         /*.exclusive = */1,
    1185         0,
    1186         /*.spdif = */1,
    1187         0,0,
    1188         /*.r = */{      {
    1189             /*.slots =*/ (1 << AC97_SLOT_SPDIF_LEFT2) |
    1190                 (1 << AC97_SLOT_SPDIF_RIGHT2),
    1191                 {0},
    1192                 {0},
    1193                 0
    1194 
    1195         }, {0}
    1196         }, 0
    1197     },
     1152        /* front PCM */
     1153        {
     1154                .exclusive = 1,
     1155                .r = {  {
     1156                                .slots = (1 << AC97_SLOT_PCM_LEFT) |
     1157                                         (1 << AC97_SLOT_PCM_RIGHT) |
     1158                                         (1 << AC97_SLOT_PCM_CENTER) |
     1159                                         (1 << AC97_SLOT_PCM_SLEFT) |
     1160                                         (1 << AC97_SLOT_PCM_SRIGHT) |
     1161                                         (1 << AC97_SLOT_LFE)
     1162                        }
     1163                }
     1164        },
     1165        /* PCM IN #1 */
     1166        {
     1167                .stream = 1,
     1168                .exclusive = 1,
     1169                .r = {  {
     1170                                .slots = (1 << AC97_SLOT_PCM_LEFT) |
     1171                                         (1 << AC97_SLOT_PCM_RIGHT)
     1172                        }
     1173                }
     1174        },
     1175        /* S/PDIF OUT (optional) */
     1176        {
     1177                .exclusive = 1,
     1178                .spdif = 1,
     1179                .r = {  {
     1180                                .slots = (1 << AC97_SLOT_SPDIF_LEFT2) |
     1181                                         (1 << AC97_SLOT_SPDIF_RIGHT2)
     1182                        }
     1183                }
     1184        },
    11981185};
    11991186
    1200 static atiixp_dma_ops_t snd_atiixp_playback_dma_ops = {
    1201         /*.type = */ATI_DMA_PLAYBACK,
    1202         /*.llp_offset = */ATI_REG_OUT_DMA_LINKPTR,
    1203         /*.dt_cur = */ATI_REG_OUT_DMA_DT_CUR,
    1204         /*.enable_dma = */atiixp_out_enable_dma,
    1205         /*.enable_transfer = */atiixp_out_enable_transfer,
    1206         /*.flush_dma = */atiixp_out_flush_dma,
     1187static struct atiixp_dma_ops snd_atiixp_playback_dma_ops = {
     1188        .type = ATI_DMA_PLAYBACK,
     1189        .llp_offset = ATI_REG_OUT_DMA_LINKPTR,
     1190        .dt_cur = ATI_REG_OUT_DMA_DT_CUR,
     1191        .enable_dma = atiixp_out_enable_dma,
     1192        .enable_transfer = atiixp_out_enable_transfer,
     1193        .flush_dma = atiixp_out_flush_dma,
    12071194};
    1208 
    1209 static atiixp_dma_ops_t snd_atiixp_capture_dma_ops = {
    1210         /*.type = */ATI_DMA_CAPTURE,
    1211         /*.llp_offset = */ATI_REG_IN_DMA_LINKPTR,
    1212         /*.dt_cur = */ATI_REG_IN_DMA_DT_CUR,
    1213         /*.enable_dma = */atiixp_in_enable_dma,
    1214         /*.enable_transfer = */atiixp_in_enable_transfer,
    1215         /*.flush_dma = */atiixp_in_flush_dma,
     1195       
     1196static struct atiixp_dma_ops snd_atiixp_capture_dma_ops = {
     1197        .type = ATI_DMA_CAPTURE,
     1198        .llp_offset = ATI_REG_IN_DMA_LINKPTR,
     1199        .dt_cur = ATI_REG_IN_DMA_DT_CUR,
     1200        .enable_dma = atiixp_in_enable_dma,
     1201        .enable_transfer = atiixp_in_enable_transfer,
     1202        .flush_dma = atiixp_in_flush_dma,
    12161203};
    1217 
    1218 static atiixp_dma_ops_t snd_atiixp_spdif_dma_ops = {
    1219         /*.type = */ATI_DMA_SPDIF,
    1220         /*.llp_offset = */ATI_REG_SPDF_DMA_LINKPTR,
    1221         /*.dt_cur = */ATI_REG_SPDF_DMA_DT_CUR,
    1222         /*.enable_dma = */atiixp_spdif_enable_dma,
    1223         /*.enable_transfer = */atiixp_spdif_enable_transfer,
    1224         /*.flush_dma = */atiixp_spdif_flush_dma,
     1204       
     1205static struct atiixp_dma_ops snd_atiixp_spdif_dma_ops = {
     1206        .type = ATI_DMA_SPDIF,
     1207        .llp_offset = ATI_REG_SPDF_DMA_LINKPTR,
     1208        .dt_cur = ATI_REG_SPDF_DMA_DT_CUR,
     1209        .enable_dma = atiixp_spdif_enable_dma,
     1210        .enable_transfer = atiixp_spdif_enable_transfer,
     1211        .flush_dma = atiixp_spdif_flush_dma,
    12251212};
    1226 
    1227 
    1228 static int __devinit snd_atiixp_pcm_new(atiixp_t *chip)
    1229 {
    1230         snd_pcm_t *pcm;
    1231         ac97_bus_t *pbus = chip->ac97_bus;
     1213       
     1214
     1215static int __devinit snd_atiixp_pcm_new(struct atiixp *chip)
     1216{
     1217        struct snd_pcm *pcm;
     1218        struct snd_ac97_bus *pbus = chip->ac97_bus;
    12321219        int err, i, num_pcms;
    12331220
     
    12581245
    12591246        /* PCM #0: analog I/O */
    1260         err = snd_pcm_new(chip->card, "ATI IXP AC97", ATI_PCMDEV_ANALOG, 1, 1, &pcm);
     1247        err = snd_pcm_new(chip->card, "ATI IXP AC97",
     1248                          ATI_PCMDEV_ANALOG, 1, 1, &pcm);
    12611249        if (err < 0)
    12621250                return err;
     
    12681256
    12691257        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1270                                               snd_dma_pci_data(chip->pci), 64*1024, 128*1024);
     1258                                              snd_dma_pci_data(chip->pci),
     1259                                              64*1024, 128*1024);
    12711260
    12721261        /* no SPDIF support on codec? */
    12731262        if (chip->pcms[ATI_PCM_SPDIF] && ! chip->pcms[ATI_PCM_SPDIF]->rates)
    12741263                return 0;
    1275 
     1264               
    12761265        /* FIXME: non-48k sample rate doesn't work on my test machine with AD1888 */
    12771266        if (chip->pcms[ATI_PCM_SPDIF])
     
    12791268
    12801269        /* PCM #1: spdif playback */
    1281         err = snd_pcm_new(chip->card, "ATI IXP IEC958", ATI_PCMDEV_DIGITAL, 1, 0, &pcm);
     1270        err = snd_pcm_new(chip->card, "ATI IXP IEC958",
     1271                          ATI_PCMDEV_DIGITAL, 1, 0, &pcm);
    12821272        if (err < 0)
    12831273                return err;
     
    12911281
    12921282        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
    1293                                               snd_dma_pci_data(chip->pci), 64*1024, 128*1024);
     1283                                              snd_dma_pci_data(chip->pci),
     1284                                              64*1024, 128*1024);
    12941285
    12951286        /* pre-select AC97 SPDIF slots 10/11 */
    12961287        for (i = 0; i < NUM_ATI_CODECS; i++) {
    12971288                if (chip->ac97[i])
    1298                         snd_ac97_update_bits(chip->ac97[i], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4);
     1289                        snd_ac97_update_bits(chip->ac97[i],
     1290                                             AC97_EXTENDED_STATUS,
     1291                                             0x03 << 4, 0x03 << 4);
    12991292        }
    13001293
     
    13091302static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
    13101303{
    1311         atiixp_t *chip = dev_id;
    1312         unsigned int status;
     1304        struct atiixp *chip = dev_id;
     1305        unsigned int status;
    13131306
    13141307        status = atiixp_read(chip, ISR);
     
    13461339        atiixp_write(chip, ISR, status);
    13471340
    1348 #ifdef TARGET_OS2
    1349         eoi_irq(irq);
    1350 #endif //TARGET_OS2
    1351 
    13521341        return IRQ_HANDLED;
    13531342}
     
    13591348
    13601349static struct ac97_quirk ac97_quirks[] __devinitdata = {
    1361     {
    1362         0x103c,
    1363         0x006b,0,0,
    1364         "HP Pavilion ZV5030US",
    1365         AC97_TUNE_MUTE_LED
    1366     },
    1367     {0} /* terminator */
     1350        {
     1351                .subvendor = 0x103c,
     1352                .subdevice = 0x006b,
     1353                .name = "HP Pavilion ZV5030US",
     1354                .type = AC97_TUNE_MUTE_LED
     1355        },
     1356        {
     1357                .subvendor = 0x103c,
     1358                .subdevice = 0x308b,
     1359                .name = "HP nx6125",
     1360                .type = AC97_TUNE_MUTE_LED
     1361        },
     1362        {0} /* terminator */
    13681363};
    13691364
    1370 static int __devinit snd_atiixp_mixer_new(atiixp_t *chip, int clock, const char *quirk_override)
    1371 {
    1372         ac97_bus_t *pbus;
    1373         ac97_template_t ac97;
     1365static int __devinit snd_atiixp_mixer_new(struct atiixp *chip, int clock,
     1366                                          const char *quirk_override)
     1367{
     1368        struct snd_ac97_bus *pbus;
     1369        struct snd_ac97_template ac97;
    13741370        int i, err;
    13751371        int codec_count;
    1376         static ac97_bus_ops_t ops = {
    1377             0,
    1378             /*.write = */snd_atiixp_ac97_write,
    1379             /*.read = */snd_atiixp_ac97_read, 0,0
     1372        static struct snd_ac97_bus_ops ops = {
     1373                .write = snd_atiixp_ac97_write,
     1374                .read = snd_atiixp_ac97_read,
    13801375        };
    13811376        static unsigned int codec_skip[NUM_ATI_CODECS] = {
     
    13911386                return err;
    13921387        pbus->clock = clock;
    1393         pbus->shared_type = AC97_SHARED_TYPE_ATIIXP;    /* shared with modem driver */
    13941388        chip->ac97_bus = pbus;
    13951389
     
    14031397                ac97.num = i;
    14041398                ac97.scaps = AC97_SCAP_SKIP_MODEM;
     1399                if (! chip->spdif_over_aclink)
     1400                        ac97.scaps |= AC97_SCAP_NO_SPDIF;
    14051401                if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
    14061402                        chip->ac97[i] = NULL; /* to be sure */
     
    14161412        }
    14171413
    1418         snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, quirk_override);
     1414        snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, quirk_override);
    14191415
    14201416        return 0;
     
    14261422 * power management
    14271423 */
    1428 static int snd_atiixp_suspend(snd_card_t *card, unsigned int state)
    1429 {
    1430         atiixp_t *chip = card->pm_private_data;
     1424static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state)
     1425{
     1426        struct snd_card *card = pci_get_drvdata(pci);
     1427        struct atiixp *chip = card->private_data;
    14311428        int i;
    14321429
    1433         for (i = 0; i < NUM_ATI_PCMDEVS; i++)
    1434             if (chip->pcmdevs[i]) {
    1435                 atiixp_dma_t *dma = &chip->dmas[i];
    1436                 if (dma->substream && dma->running)
    1437                     dma->saved_curptr = readl((char*)chip->remap_addr + dma->ops->dt_cur);
    1438                 snd_pcm_suspend_all(chip->pcmdevs[i]);
    1439             }
     1430        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
     1431        for (i = 0; i < NUM_ATI_PCMDEVS; i++)
     1432                if (chip->pcmdevs[i]) {
     1433                        struct atiixp_dma *dma = &chip->dmas[i];
     1434                        if (dma->substream && dma->running)
     1435                                dma->saved_curptr = readl((char*)chip->remap_addr +
     1436                                                          dma->ops->dt_cur);
     1437                        snd_pcm_suspend_all(chip->pcmdevs[i]);
     1438                }
    14401439        for (i = 0; i < NUM_ATI_CODECS; i++)
    1441                 if (chip->ac97[i])
    1442                         snd_ac97_suspend(chip->ac97[i]);
     1440                snd_ac97_suspend(chip->ac97[i]);
    14431441        snd_atiixp_aclink_down(chip);
    14441442        snd_atiixp_chip_stop(chip);
    14451443
    1446         pci_set_power_state(chip->pci, 3);
    1447         pci_disable_device(chip->pci);
    1448         return 0;
    1449 }
    1450 
    1451 static int snd_atiixp_resume(snd_card_t *card, unsigned int state)
    1452 {
    1453         atiixp_t *chip = card->pm_private_data;
     1444        pci_set_power_state(pci, PCI_D3hot);
     1445        pci_disable_device(pci);
     1446        pci_save_state(pci);
     1447        return 0;
     1448}
     1449
     1450static int snd_atiixp_resume(struct pci_dev *pci)
     1451{
     1452        struct snd_card *card = pci_get_drvdata(pci);
     1453        struct atiixp *chip = card->private_data;
    14541454        int i;
    14551455
    1456         pci_enable_device(chip->pci);
    1457         pci_set_power_state(chip->pci, 0);
    1458         pci_set_master(chip->pci);
     1456        pci_restore_state(pci);
     1457        pci_enable_device(pci);
     1458        pci_set_power_state(pci, PCI_D0);
     1459        pci_set_master(pci);
    14591460
    14601461        snd_atiixp_aclink_reset(chip);
     
    14621463
    14631464        for (i = 0; i < NUM_ATI_CODECS; i++)
    1464                 if (chip->ac97[i])
    1465                     snd_ac97_resume(chip->ac97[i]);
    1466         for (i = 0; i < NUM_ATI_PCMDEVS; i++)
    1467             if (chip->pcmdevs[i]) {
    1468                 atiixp_dma_t *dma = &chip->dmas[i];
    1469                 if (dma->substream && dma->suspended) {
    1470                     dma->ops->enable_dma(chip, 1);
    1471                     dma->substream->ops->prepare(dma->substream);
    1472                     writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN,
    1473                            (char*)chip->remap_addr + dma->ops->llp_offset);
    1474                     writel(dma->saved_curptr, (char*)chip->remap_addr + dma->ops->dt_cur);
    1475                 }
    1476             }
    1477 
    1478         return 0;
     1465                snd_ac97_resume(chip->ac97[i]);
     1466
     1467        for (i = 0; i < NUM_ATI_PCMDEVS; i++)
     1468                if (chip->pcmdevs[i]) {
     1469                        struct atiixp_dma *dma = &chip->dmas[i];
     1470                        if (dma->substream && dma->suspended) {
     1471                                dma->ops->enable_dma(chip, 1);
     1472                                dma->substream->ops->prepare(dma->substream);
     1473                                writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN,
     1474                                       (char*)chip->remap_addr + dma->ops->llp_offset);
     1475                                writel(dma->saved_curptr, (char*)chip->remap_addr +
     1476                                       dma->ops->dt_cur);
     1477                        }
     1478                }
     1479
     1480        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
     1481        return 0;
    14791482}
    14801483#endif /* CONFIG_PM */
    14811484
    14821485
     1486#ifdef CONFIG_PROC_FS
    14831487/*
    14841488 * proc interface for register dump
    14851489 */
    14861490
    1487 static void snd_atiixp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer)
    1488 {
    1489         atiixp_t *chip = entry->private_data;
     1491static void snd_atiixp_proc_read(struct snd_info_entry *entry,
     1492                                 struct snd_info_buffer *buffer)
     1493{
     1494        struct atiixp *chip = entry->private_data;
    14901495        int i;
    14911496
     
    14941499}
    14951500
    1496 static void __devinit snd_atiixp_proc_init(atiixp_t *chip)
    1497 {
    1498         snd_info_entry_t *entry;
     1501static void __devinit snd_atiixp_proc_init(struct atiixp *chip)
     1502{
     1503        struct snd_info_entry *entry;
    14991504
    15001505        if (! snd_card_proc_new(chip->card, "atiixp", &entry))
    15011506                snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read);
    15021507}
    1503 
     1508#else /* !CONFIG_PROC_FS */
     1509#define snd_atiixp_proc_init(chip)
     1510#endif
    15041511
    15051512
     
    15081515 */
    15091516
    1510 static int snd_atiixp_free(atiixp_t *chip)
     1517static int snd_atiixp_free(struct atiixp *chip)
    15111518{
    15121519        if (chip->irq < 0)
     
    15161523      __hw_end:
    15171524        if (chip->irq >= 0)
    1518                 free_irq(chip->irq, (void *)chip);
     1525                free_irq(chip->irq, chip);
    15191526        if (chip->remap_addr)
    15201527                iounmap(chip->remap_addr);
     
    15251532}
    15261533
    1527 static int snd_atiixp_dev_free(snd_device_t *device)
    1528 {
    1529         atiixp_t *chip = device->device_data;
     1534static int snd_atiixp_dev_free(struct snd_device *device)
     1535{
     1536        struct atiixp *chip = device->device_data;
    15301537        return snd_atiixp_free(chip);
    15311538}
     
    15341541 * constructor for chip instance
    15351542 */
    1536 static int __devinit snd_atiixp_create(snd_card_t *card,
     1543static int __devinit snd_atiixp_create(struct snd_card *card,
    15371544                                      struct pci_dev *pci,
    1538                                       atiixp_t **r_chip)
    1539 {
    1540         static snd_device_ops_t ops = {
    1541                 snd_atiixp_dev_free,0,0,0
     1545                                      struct atiixp **r_chip)
     1546{
     1547        static struct snd_device_ops ops = {
     1548                .dev_free =     snd_atiixp_dev_free,
    15421549        };
    1543         atiixp_t *chip;
     1550        struct atiixp *chip;
    15441551        int err;
    15451552
     
    15471554                return err;
    15481555
    1549         chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
     1556        chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    15501557        if (chip == NULL) {
    15511558                pci_disable_device(pci);
     
    15711578        }
    15721579
    1573         if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip)) {
     1580        if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ,
     1581                        card->shortname, chip)) {
    15741582                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
    15751583                snd_atiixp_free(chip);
     
    15951603                                     const struct pci_device_id *pci_id)
    15961604{
    1597         static int dev;
    1598         snd_card_t *card;
    1599         atiixp_t *chip;
     1605        struct snd_card *card;
     1606        struct atiixp *chip;
    16001607        unsigned char revision;
    16011608        int err;
    16021609
    1603         if (dev >= SNDRV_CARDS)
    1604                 return -ENODEV;
    1605         if (!enable[dev]) {
    1606                 dev++;
    1607                 return -ENOENT;
    1608         }
    1609 
    1610         card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
     1610        card = snd_card_new(index, id, THIS_MODULE, 0);
    16111611        if (card == NULL)
    16121612                return -ENOMEM;
     
    16141614        pci_read_config_byte(pci, PCI_REVISION_ID, &revision);
    16151615
    1616         strcpy(card->driver, spdif_aclink[dev] ? "ATIIXP" : "ATIIXP-SPDMA");
     1616        strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA");
    16171617        strcpy(card->shortname, "ATI IXP");
    16181618        if ((err = snd_atiixp_create(card, pci, &chip)) < 0)
    16191619                goto __error;
     1620        card->private_data = chip;
    16201621
    16211622        if ((err = snd_atiixp_aclink_reset(chip)) < 0)
    16221623                goto __error;
    16231624
    1624         chip->spdif_over_aclink = spdif_aclink[dev];
    1625 
    1626         if ((err = snd_atiixp_mixer_new(chip, ac97_clock[dev], ac97_quirk[dev])) < 0)
     1625        chip->spdif_over_aclink = spdif_aclink;
     1626
     1627        if ((err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk)) < 0)
    16271628                goto __error;
    16281629
    16291630        if ((err = snd_atiixp_pcm_new(chip)) < 0)
    16301631                goto __error;
    1631 
     1632       
    16321633        snd_atiixp_proc_init(chip);
    16331634
     
    16391640                 chip->addr, chip->irq);
    16401641
    1641         snd_card_set_pm_callback(card, snd_atiixp_suspend, snd_atiixp_resume, chip);
    1642 
    16431642        if ((err = snd_card_register(card)) < 0)
    16441643                goto __error;
    16451644
    16461645        pci_set_drvdata(pci, card);
    1647         dev++;
    16481646        return 0;
    16491647
     
    16601658
    16611659static struct pci_driver driver = {
    1662     0,0,0,
    1663     "ATI IXP AC97 controller",
    1664     snd_atiixp_ids,
    1665     snd_atiixp_probe,
    1666     snd_atiixp_remove,
    1667     SND_PCI_PM_CALLBACKS
     1660        .name = "ATI IXP AC97 controller",
     1661        .id_table = snd_atiixp_ids,
     1662        .probe = snd_atiixp_probe,
     1663        .remove = __devexit_p(snd_atiixp_remove),
     1664#ifdef CONFIG_PM
     1665        .suspend = snd_atiixp_suspend,
     1666        .resume = snd_atiixp_resume,
     1667#endif
    16681668};
    16691669
     
    16711671static int __init alsa_card_atiixp_init(void)
    16721672{
    1673         return pci_module_init(&driver);
     1673        return pci_register_driver(&driver);
    16741674}
    16751675
Note: See TracChangeset for help on using the changeset viewer.