X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=sound%2Fpci%2Fhda%2Fhda_intel.c;h=e821d65afa118bfaec97c5effe9730467dbe39a1;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=959953ca320a16a7904ecd016e9a66d798564001;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 959953ca3..e821d65af 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -37,35 +37,55 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include "hda_codec.h" -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; -static char *model[SNDRV_CARDS]; +static int index = SNDRV_DEFAULT_IDX1; +static char *id = SNDRV_DEFAULT_STR1; +static char *model; +static int position_fix; +static int probe_mask = -1; +static int single_cmd; -module_param_array(index, int, NULL, 0444); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for Intel HD audio interface."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); -module_param_array(model, charp, NULL, 0444); +module_param(model, charp, 0444); MODULE_PARM_DESC(model, "Use the given board model."); +module_param(position_fix, int, 0444); +MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)."); +module_param(probe_mask, int, 0444); +MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); +module_param(single_cmd, bool, 0444); +MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs (for debugging only)."); + + +/* just for backward compatibility */ +static int enable; +module_param(enable, bool, 0444); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," "{Intel, ICH6M}," "{Intel, ICH7}," - "{Intel, ESB2}}"); + "{Intel, ESB2}," + "{Intel, ICH8}," + "{ATI, SB450}," + "{ATI, SB600}," + "{VIA, VT8251}," + "{VIA, VT8237A}," + "{SiS, SIS966}," + "{ULI, M5461}}"); MODULE_DESCRIPTION("Intel HDA driver"); #define SFX "hda-intel: " @@ -135,13 +155,30 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; */ /* max number of SDs */ -#define MAX_ICH6_DEV 8 +/* ICH, ATI and VIA have 4 playback and 4 capture */ +#define ICH6_CAPTURE_INDEX 0 +#define ICH6_NUM_CAPTURE 4 +#define ICH6_PLAYBACK_INDEX 4 +#define ICH6_NUM_PLAYBACK 4 + +/* ULI has 6 playback and 5 capture */ +#define ULI_CAPTURE_INDEX 0 +#define ULI_NUM_CAPTURE 5 +#define ULI_PLAYBACK_INDEX 5 +#define ULI_NUM_PLAYBACK 6 + +/* this number is statically defined for simplicity */ +#define MAX_AZX_DEV 16 + /* max number of fragments - we may use more if allocating more pages for BDL */ -#define AZX_MAX_FRAG (PAGE_SIZE / (MAX_ICH6_DEV * 16)) +#define BDL_SIZE PAGE_ALIGN(8192) +#define AZX_MAX_FRAG (BDL_SIZE / (MAX_AZX_DEV * 16)) /* max buffer size - no h/w limit, you can increase as you like */ #define AZX_MAX_BUF_SIZE (1024*1024*1024) /* max number of PCM devics per card */ -#define AZX_MAX_PCMS 8 +#define AZX_MAX_AUDIO_PCMS 6 +#define AZX_MAX_MODEM_PCMS 2 +#define AZX_MAX_PCMS (AZX_MAX_AUDIO_PCMS + AZX_MAX_MODEM_PCMS) /* RIRB int mask: overrun[2], response[0] */ #define RIRB_INT_RESPONSE 0x01 @@ -150,7 +187,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; /* STATESTS int mask: SD2,SD1,SD0 */ #define STATESTS_INT_MASK 0x07 -#define AZX_MAX_CODECS 3 +#define AZX_MAX_CODECS 4 /* SD_CTL bits */ #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ @@ -172,6 +209,9 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; #define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ #define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ +/* GCTL unsolicited response enable bit */ +#define ICH6_GCTL_UREN (1<<8) + /* GCTL reset bit */ #define ICH6_GCTL_RESET (1<<0) @@ -183,27 +223,26 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 }; #define ICH6_MAX_CORB_ENTRIES 256 #define ICH6_MAX_RIRB_ENTRIES 256 +/* position fix mode */ +enum { + POS_FIX_AUTO, + POS_FIX_NONE, + POS_FIX_POSBUF, + POS_FIX_FIFO, +}; -/* - * Use CORB/RIRB for communication from/to codecs. - * This is the way recommended by Intel (see below). - */ -#define USE_CORB_RIRB +/* Defines for ATI HD Audio support in SB450 south bridge */ +#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42 +#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02 -/* - * Define this if use the position buffer instead of reading SD_LPIB - * It's not used as default since SD_LPIB seems to give more accurate position - */ -/* #define USE_POSBUF */ +/* Defines for Nvidia HDA support */ +#define NVIDIA_HDA_TRANSREG_ADDR 0x4e +#define NVIDIA_HDA_ENABLE_COHBITS 0x0f /* */ -typedef struct snd_azx azx_t; -typedef struct snd_azx_rb azx_rb_t; -typedef struct snd_azx_dev azx_dev_t; - -struct snd_azx_dev { +struct azx_dev { u32 *bdl; /* virtual address of the BDL */ dma_addr_t bdl_addr; /* physical address of the BDL */ volatile u32 *posbuf; /* position buffer pointer */ @@ -218,17 +257,19 @@ struct snd_azx_dev { u32 sd_int_sta_mask; /* stream int status mask */ /* pcm support */ - snd_pcm_substream_t *substream; /* assigned substream, set in PCM open */ + struct snd_pcm_substream *substream; /* assigned substream, set in PCM open */ unsigned int format_val; /* format value to be set in the controller and the codec */ unsigned char stream_tag; /* assigned stream */ unsigned char index; /* stream index */ + /* for sanity check of position buffer */ + unsigned int period_intr; unsigned int opened: 1; unsigned int running: 1; }; /* CORB/RIRB */ -struct snd_azx_rb { +struct azx_rb { u32 *buf; /* CORB/RIRB buffer * Each CORB entry is 4byte, RIRB is 8byte */ @@ -239,10 +280,18 @@ struct snd_azx_rb { u32 res; /* last read value */ }; -struct snd_azx { - snd_card_t *card; +struct azx { + struct snd_card *card; struct pci_dev *pci; + /* chip type specific */ + int driver_type; + int playback_streams; + int playback_index_offset; + int capture_streams; + int capture_index_offset; + int num_streams; + /* pci resources */ unsigned long addr; void __iomem *remap_addr; @@ -250,27 +299,51 @@ struct snd_azx { /* locks */ spinlock_t reg_lock; - struct semaphore open_mutex; + struct mutex open_mutex; - /* streams */ - azx_dev_t azx_dev[MAX_ICH6_DEV]; + /* streams (x num_streams) */ + struct azx_dev *azx_dev; /* PCM */ unsigned int pcm_devs; - snd_pcm_t *pcm[AZX_MAX_PCMS]; + struct snd_pcm *pcm[AZX_MAX_PCMS]; /* HD codec */ unsigned short codec_mask; struct hda_bus *bus; /* CORB/RIRB */ - azx_rb_t corb; - azx_rb_t rirb; + struct azx_rb corb; + struct azx_rb rirb; /* BDL, CORB/RIRB and position buffers */ struct snd_dma_buffer bdl; struct snd_dma_buffer rb; struct snd_dma_buffer posbuf; + + /* flags */ + int position_fix; + unsigned int initialized: 1; + unsigned int single_cmd: 1; +}; + +/* driver types */ +enum { + AZX_DRIVER_ICH, + AZX_DRIVER_ATI, + AZX_DRIVER_VIA, + AZX_DRIVER_SIS, + AZX_DRIVER_ULI, + AZX_DRIVER_NVIDIA, +}; + +static char *driver_short_names[] __devinitdata = { + [AZX_DRIVER_ICH] = "HDA Intel", + [AZX_DRIVER_ATI] = "HDA ATI SB", + [AZX_DRIVER_VIA] = "HDA VIA VT82xx", + [AZX_DRIVER_SIS] = "HDA SIS966", + [AZX_DRIVER_ULI] = "HDA ULI M5461", + [AZX_DRIVER_NVIDIA] = "HDA NVidia", }; /* @@ -303,7 +376,7 @@ struct snd_azx { readb((dev)->sd_addr + ICH6_REG_##reg) /* for pcm support */ -#define get_azx_dev(substream) (azx_dev_t*)(substream->runtime->private_data) +#define get_azx_dev(substream) (substream->runtime->private_data) /* Get the upper 32bit of the given dma_addr_t * Compiler should optimize and eliminate the code if dma_addr_t is 32bit @@ -315,11 +388,10 @@ struct snd_azx { * Interface for HD codec */ -#ifdef USE_CORB_RIRB /* * CORB / RIRB interface */ -static int azx_alloc_cmd_io(azx_t *chip) +static int azx_alloc_cmd_io(struct azx *chip) { int err; @@ -333,7 +405,7 @@ static int azx_alloc_cmd_io(azx_t *chip) return 0; } -static void azx_init_cmd_io(azx_t *chip) +static void azx_init_cmd_io(struct azx *chip) { /* CORB set up */ chip->corb.addr = chip->rb.addr; @@ -341,6 +413,8 @@ static void azx_init_cmd_io(azx_t *chip) azx_writel(chip, CORBLBASE, (u32)chip->corb.addr); azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr)); + /* set the corb size to 256 entries (ULI requires explicitly) */ + azx_writeb(chip, CORBSIZE, 0x02); /* set the corb write pointer to 0 */ azx_writew(chip, CORBWP, 0); /* reset the corb hw read pointer */ @@ -354,20 +428,18 @@ static void azx_init_cmd_io(azx_t *chip) azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr)); + /* set the rirb size to 256 entries (ULI requires explicitly) */ + azx_writeb(chip, RIRBSIZE, 0x02); /* reset the rirb hw write pointer */ azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR); /* set N=1, get RIRB response interrupt for new entry */ azx_writew(chip, RINTCNT, 1); /* enable rirb dma and response irq */ -#ifdef USE_CORB_RIRB azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); -#else - azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN); -#endif chip->rirb.rp = chip->rirb.cmds = 0; } -static void azx_free_cmd_io(azx_t *chip) +static void azx_free_cmd_io(struct azx *chip) { /* disable ringbuffer DMAs */ azx_writeb(chip, RIRBCTL, 0); @@ -375,10 +447,10 @@ static void azx_free_cmd_io(azx_t *chip) } /* send a command */ -static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, - unsigned int verb, unsigned int para) +static int azx_corb_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, + unsigned int verb, unsigned int para) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; unsigned int wp; u32 val; @@ -405,7 +477,7 @@ static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, #define ICH6_RIRB_EX_UNSOL_EV (1<<4) /* retrieve RIRB entry - called from interrupt handler */ -static void azx_update_rirb(azx_t *chip) +static void azx_update_rirb(struct azx *chip) { unsigned int rp, wp; u32 res, res_ex; @@ -432,16 +504,21 @@ static void azx_update_rirb(azx_t *chip) } /* receive a response */ -static unsigned int azx_get_response(struct hda_codec *codec) +static unsigned int azx_rirb_get_response(struct hda_codec *codec) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; int timeout = 50; while (chip->rirb.cmds) { if (! --timeout) { - snd_printk(KERN_ERR "azx_get_response timeout\n"); + snd_printk(KERN_ERR + "hda_intel: azx_get_response timeout, " + "switching to single_cmd mode...\n"); chip->rirb.rp = azx_readb(chip, RIRBWP); chip->rirb.cmds = 0; + /* switch to single_cmd mode */ + chip->single_cmd = 1; + azx_free_cmd_io(chip); return -1; } msleep(1); @@ -449,7 +526,6 @@ static unsigned int azx_get_response(struct hda_codec *codec) return chip->rirb.res; /* the last value */ } -#else /* * Use the single immediate command instead of CORB/RIRB for simplicity * @@ -460,15 +536,12 @@ static unsigned int azx_get_response(struct hda_codec *codec) * I left the codes, however, for debugging/testing purposes. */ -#define azx_alloc_cmd_io(chip) 0 -#define azx_init_cmd_io(chip) -#define azx_free_cmd_io(chip) - /* send a command */ -static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, - unsigned int verb, unsigned int para) +static int azx_single_send_cmd(struct hda_codec *codec, hda_nid_t nid, + int direct, unsigned int verb, + unsigned int para) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; u32 val; int timeout = 50; @@ -494,9 +567,9 @@ static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, } /* receive a response */ -static unsigned int azx_get_response(struct hda_codec *codec) +static unsigned int azx_single_get_response(struct hda_codec *codec) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; int timeout = 50; while (timeout--) { @@ -509,12 +582,38 @@ static unsigned int azx_get_response(struct hda_codec *codec) return (unsigned int)-1; } -#define azx_update_rirb(chip) +/* + * The below are the main callbacks from hda_codec. + * + * They are just the skeleton to call sub-callbacks according to the + * current setting of chip->single_cmd. + */ + +/* send a command */ +static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, + int direct, unsigned int verb, + unsigned int para) +{ + struct azx *chip = codec->bus->private_data; + if (chip->single_cmd) + return azx_single_send_cmd(codec, nid, direct, verb, para); + else + return azx_corb_send_cmd(codec, nid, direct, verb, para); +} + +/* get a response */ +static unsigned int azx_get_response(struct hda_codec *codec) +{ + struct azx *chip = codec->bus->private_data; + if (chip->single_cmd) + return azx_single_get_response(codec); + else + return azx_rirb_get_response(codec); +} -#endif /* USE_CORB_RIRB */ /* reset codec link */ -static int azx_reset(azx_t *chip) +static int azx_reset(struct azx *chip) { int count; @@ -546,6 +645,9 @@ static int azx_reset(azx_t *chip) return -EBUSY; } + /* Accept unsolicited responses */ + azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UREN); + /* detect codecs */ if (! chip->codec_mask) { chip->codec_mask = azx_readw(chip, STATESTS); @@ -561,7 +663,7 @@ static int azx_reset(azx_t *chip) */ /* enable interrupts */ -static void azx_int_enable(azx_t *chip) +static void azx_int_enable(struct azx *chip) { /* enable controller CIE and GIE */ azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) | @@ -569,13 +671,13 @@ static void azx_int_enable(azx_t *chip) } /* disable interrupts */ -static void azx_int_disable(azx_t *chip) +static void azx_int_disable(struct azx *chip) { int i; /* disable interrupts in stream descriptor */ - for (i = 0; i < MAX_ICH6_DEV; i++) { - azx_dev_t *azx_dev = &chip->azx_dev[i]; + for (i = 0; i < chip->num_streams; i++) { + struct azx_dev *azx_dev = &chip->azx_dev[i]; azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK); } @@ -589,13 +691,13 @@ static void azx_int_disable(azx_t *chip) } /* clear interrupts */ -static void azx_int_clear(azx_t *chip) +static void azx_int_clear(struct azx *chip) { int i; /* clear stream status */ - for (i = 0; i < MAX_ICH6_DEV; i++) { - azx_dev_t *azx_dev = &chip->azx_dev[i]; + for (i = 0; i < chip->num_streams; i++) { + struct azx_dev *azx_dev = &chip->azx_dev[i]; azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); } @@ -610,7 +712,7 @@ static void azx_int_clear(azx_t *chip) } /* start a stream */ -static void azx_stream_start(azx_t *chip, azx_dev_t *azx_dev) +static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev) { /* enable SIE */ azx_writeb(chip, INTCTL, @@ -621,7 +723,7 @@ static void azx_stream_start(azx_t *chip, azx_dev_t *azx_dev) } /* stop a stream */ -static void azx_stream_stop(azx_t *chip, azx_dev_t *azx_dev) +static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev) { /* stop DMA */ azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & @@ -636,16 +738,16 @@ static void azx_stream_stop(azx_t *chip, azx_dev_t *azx_dev) /* * initialize the chip */ -static void azx_init_chip(azx_t *chip) +static void azx_init_chip(struct azx *chip) { - unsigned char tcsel_reg; + unsigned char reg; /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) * TCSEL == Traffic Class Select Register, which sets PCI express QOS * Ensuring these bits are 0 clears playback static on some HD Audio codecs */ - pci_read_config_byte (chip->pci, ICH6_PCIREG_TCSEL, &tcsel_reg); - pci_write_config_byte(chip->pci, ICH6_PCIREG_TCSEL, tcsel_reg & 0xf8); + pci_read_config_byte (chip->pci, ICH6_PCIREG_TCSEL, ®); + pci_write_config_byte(chip->pci, ICH6_PCIREG_TCSEL, reg & 0xf8); /* reset controller */ azx_reset(chip); @@ -655,13 +757,28 @@ static void azx_init_chip(azx_t *chip) azx_int_enable(chip); /* initialize the codec command I/O */ - azx_init_cmd_io(chip); + if (! chip->single_cmd) + azx_init_cmd_io(chip); -#ifdef USE_POSBUF /* program the position buffer */ azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); -#endif + + switch (chip->driver_type) { + case AZX_DRIVER_ATI: + /* For ATI SB450 azalia HD audio, we need to enable snoop */ + pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, + ®); + pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, + (reg & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP); + break; + case AZX_DRIVER_NVIDIA: + /* For NVIDIA HDA, enable snoop */ + pci_read_config_byte(chip->pci,NVIDIA_HDA_TRANSREG_ADDR, ®); + pci_write_config_byte(chip->pci,NVIDIA_HDA_TRANSREG_ADDR, + (reg & 0xf0) | NVIDIA_HDA_ENABLE_COHBITS); + break; + } } @@ -670,8 +787,8 @@ static void azx_init_chip(azx_t *chip) */ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) { - azx_t *chip = dev_id; - azx_dev_t *azx_dev; + struct azx *chip = dev_id; + struct azx_dev *azx_dev; u32 status; int i; @@ -683,11 +800,12 @@ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) return IRQ_NONE; } - for (i = 0; i < MAX_ICH6_DEV; i++) { + for (i = 0; i < chip->num_streams; i++) { azx_dev = &chip->azx_dev[i]; if (status & azx_dev->sd_int_sta_mask) { azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); if (azx_dev->substream && azx_dev->running) { + azx_dev->period_intr++; spin_unlock(&chip->reg_lock); snd_pcm_period_elapsed(azx_dev->substream); spin_lock(&chip->reg_lock); @@ -698,7 +816,7 @@ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) /* clear rirb int */ status = azx_readb(chip, RIRBSTS); if (status & RIRB_INT_MASK) { - if (status & RIRB_INT_RESPONSE) + if (! chip->single_cmd && (status & RIRB_INT_RESPONSE)) azx_update_rirb(chip); azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); } @@ -717,7 +835,7 @@ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) /* * set up BDL entries */ -static void azx_setup_periods(azx_dev_t *azx_dev) +static void azx_setup_periods(struct azx_dev *azx_dev) { u32 *bdl = azx_dev->bdl; dma_addr_t dma_addr = azx_dev->substream->runtime->dma_addr; @@ -746,7 +864,7 @@ static void azx_setup_periods(azx_dev_t *azx_dev) /* * set up the SD for streaming */ -static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev) +static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev) { unsigned char val; int timeout; @@ -791,11 +909,10 @@ static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev) /* upper BDL address */ azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); -#ifdef USE_POSBUF /* enable the position buffer */ if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); -#endif + /* set the interrupt enable bits in the descriptor control register */ azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); @@ -807,7 +924,7 @@ static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev) * Codec initialization */ -static int __devinit azx_codec_create(azx_t *chip, const char *model) +static int __devinit azx_codec_create(struct azx *chip, const char *model) { struct hda_bus_template bus_temp; int c, codecs, err; @@ -824,7 +941,7 @@ static int __devinit azx_codec_create(azx_t *chip, const char *model) codecs = 0; for (c = 0; c < AZX_MAX_CODECS; c++) { - if (chip->codec_mask & (1 << c)) { + if ((chip->codec_mask & (1 << c)) & probe_mask) { err = snd_hda_codec_new(chip->bus, c, NULL); if (err < 0) continue; @@ -845,11 +962,17 @@ static int __devinit azx_codec_create(azx_t *chip, const char *model) */ /* assign a stream for the PCM */ -static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream) +static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream) { - int dev, i; - dev = stream == SNDRV_PCM_STREAM_PLAYBACK ? 4 : 0; - for (i = 0; i < 4; i++, dev++) + int dev, i, nums; + if (stream == SNDRV_PCM_STREAM_PLAYBACK) { + dev = chip->playback_index_offset; + nums = chip->playback_streams; + } else { + dev = chip->capture_index_offset; + nums = chip->capture_streams; + } + for (i = 0; i < nums; i++, dev++) if (! chip->azx_dev[dev].opened) { chip->azx_dev[dev].opened = 1; return &chip->azx_dev[dev]; @@ -858,17 +981,17 @@ static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream) } /* release the assigned stream */ -static inline void azx_release_device(azx_dev_t *azx_dev) +static inline void azx_release_device(struct azx_dev *azx_dev) { azx_dev->opened = 0; } -static snd_pcm_hardware_t azx_pcm_hw = { +static struct snd_pcm_hardware azx_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_RESUME), + SNDRV_PCM_INFO_PAUSE /*|*/ + /*SNDRV_PCM_INFO_RESUME*/), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, .rate_min = 48000, @@ -884,25 +1007,25 @@ static snd_pcm_hardware_t azx_pcm_hw = { }; struct azx_pcm { - azx_t *chip; + struct azx *chip; struct hda_codec *codec; struct hda_pcm_stream *hinfo[2]; }; -static int azx_pcm_open(snd_pcm_substream_t *substream) +static int azx_pcm_open(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; - azx_t *chip = apcm->chip; - azx_dev_t *azx_dev; - snd_pcm_runtime_t *runtime = substream->runtime; + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; int err; - down(&chip->open_mutex); + mutex_lock(&chip->open_mutex); azx_dev = azx_assign_device(chip, substream->stream); if (azx_dev == NULL) { - up(&chip->open_mutex); + mutex_unlock(&chip->open_mutex); return -EBUSY; } runtime->hw = azx_pcm_hw; @@ -914,7 +1037,7 @@ static int azx_pcm_open(snd_pcm_substream_t *substream) snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if ((err = hinfo->ops.open(hinfo, apcm->codec, substream)) < 0) { azx_release_device(azx_dev); - up(&chip->open_mutex); + mutex_unlock(&chip->open_mutex); return err; } spin_lock_irqsave(&chip->reg_lock, flags); @@ -923,38 +1046,38 @@ static int azx_pcm_open(snd_pcm_substream_t *substream) spin_unlock_irqrestore(&chip->reg_lock, flags); runtime->private_data = azx_dev; - up(&chip->open_mutex); + mutex_unlock(&chip->open_mutex); return 0; } -static int azx_pcm_close(snd_pcm_substream_t *substream) +static int azx_pcm_close(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; - azx_t *chip = apcm->chip; - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); unsigned long flags; - down(&chip->open_mutex); + mutex_lock(&chip->open_mutex); spin_lock_irqsave(&chip->reg_lock, flags); azx_dev->substream = NULL; azx_dev->running = 0; spin_unlock_irqrestore(&chip->reg_lock, flags); azx_release_device(azx_dev); hinfo->ops.close(hinfo, apcm->codec, substream); - up(&chip->open_mutex); + mutex_unlock(&chip->open_mutex); return 0; } -static int azx_pcm_hw_params(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *hw_params) +static int azx_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int azx_pcm_hw_free(snd_pcm_substream_t *substream) +static int azx_pcm_hw_free(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; /* reset BDL address */ @@ -967,13 +1090,13 @@ static int azx_pcm_hw_free(snd_pcm_substream_t *substream) return snd_pcm_lib_free_pages(substream); } -static int azx_pcm_prepare(snd_pcm_substream_t *substream) +static int azx_pcm_prepare(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); - azx_t *chip = apcm->chip; - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream); azx_dev->fragsize = snd_pcm_lib_period_bytes(substream); @@ -1001,11 +1124,11 @@ static int azx_pcm_prepare(snd_pcm_substream_t *substream) azx_dev->format_val, substream); } -static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); - azx_dev_t *azx_dev = get_azx_dev(substream); - azx_t *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); + struct azx *chip = apcm->chip; int err = 0; spin_lock(&chip->reg_lock); @@ -1017,6 +1140,7 @@ static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) azx_dev->running = 1; break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: azx_stream_stop(chip, azx_dev); azx_dev->running = 0; @@ -1026,6 +1150,7 @@ static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) } spin_unlock(&chip->reg_lock); if (cmd == SNDRV_PCM_TRIGGER_PAUSE_PUSH || + cmd == SNDRV_PCM_TRIGGER_SUSPEND || cmd == SNDRV_PCM_TRIGGER_STOP) { int timeout = 5000; while (azx_sd_readb(azx_dev, SD_CTL) & SD_CTL_DMA_START && --timeout) @@ -1034,24 +1159,38 @@ static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) return err; } -static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) { - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx_pcm *apcm = snd_pcm_substream_chip(substream); + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); unsigned int pos; -#ifdef USE_POSBUF - /* use the position buffer */ - pos = *azx_dev->posbuf; -#else - /* read LPIB */ - pos = azx_sd_readl(azx_dev, SD_LPIB) + azx_dev->fifo_size; -#endif + if (chip->position_fix == POS_FIX_POSBUF || + chip->position_fix == POS_FIX_AUTO) { + /* use the position buffer */ + pos = *azx_dev->posbuf; + if (chip->position_fix == POS_FIX_AUTO && + azx_dev->period_intr == 1 && ! pos) { + printk(KERN_WARNING + "hda-intel: Invalid position buffer, " + "using LPIB read method instead.\n"); + chip->position_fix = POS_FIX_NONE; + goto read_lpib; + } + } else { + read_lpib: + /* read LPIB */ + pos = azx_sd_readl(azx_dev, SD_LPIB); + if (chip->position_fix == POS_FIX_FIFO) + pos += azx_dev->fifo_size; + } if (pos >= azx_dev->bufsize) pos = 0; return bytes_to_frames(substream->runtime, pos); } -static snd_pcm_ops_t azx_pcm_ops = { +static struct snd_pcm_ops azx_pcm_ops = { .open = azx_pcm_open, .close = azx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -1062,16 +1201,16 @@ static snd_pcm_ops_t azx_pcm_ops = { .pointer = azx_pcm_pointer, }; -static void azx_pcm_free(snd_pcm_t *pcm) +static void azx_pcm_free(struct snd_pcm *pcm) { kfree(pcm->private_data); } -static int __devinit create_codec_pcm(azx_t *chip, struct hda_codec *codec, +static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec, struct hda_pcm *cpcm, int pcm_dev) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; struct azx_pcm *apcm; snd_assert(cpcm->stream[0].substreams || cpcm->stream[1].substreams, return -EINVAL); @@ -1100,11 +1239,12 @@ static int __devinit create_codec_pcm(azx_t *chip, struct hda_codec *codec, snd_dma_pci_data(chip->pci), 1024 * 64, 1024 * 128); chip->pcm[pcm_dev] = pcm; + chip->pcm_devs = pcm_dev + 1; return 0; } -static int __devinit azx_pcm_create(azx_t *chip) +static int __devinit azx_pcm_create(struct azx *chip) { struct list_head *p; struct hda_codec *codec; @@ -1114,17 +1254,39 @@ static int __devinit azx_pcm_create(azx_t *chip) if ((err = snd_hda_build_pcms(chip->bus)) < 0) return err; + /* create audio PCMs */ pcm_dev = 0; list_for_each(p, &chip->bus->codec_list) { codec = list_entry(p, struct hda_codec, list); for (c = 0; c < codec->num_pcms; c++) { + if (codec->pcm_info[c].is_modem) + continue; /* create later */ + if (pcm_dev >= AZX_MAX_AUDIO_PCMS) { + snd_printk(KERN_ERR SFX "Too many audio PCMs\n"); + return -EINVAL; + } + err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); + if (err < 0) + return err; + pcm_dev++; + } + } + + /* create modem PCMs */ + pcm_dev = AZX_MAX_AUDIO_PCMS; + list_for_each(p, &chip->bus->codec_list) { + codec = list_entry(p, struct hda_codec, list); + for (c = 0; c < codec->num_pcms; c++) { + if (! codec->pcm_info[c].is_modem) + continue; /* already created */ if (pcm_dev >= AZX_MAX_PCMS) { - snd_printk(KERN_ERR SFX "Too many PCMs\n"); + snd_printk(KERN_ERR SFX "Too many modem PCMs\n"); return -EINVAL; } err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); if (err < 0) return err; + chip->pcm[pcm_dev]->dev_class = SNDRV_PCM_CLASS_MODEM; pcm_dev++; } } @@ -1134,7 +1296,7 @@ static int __devinit azx_pcm_create(azx_t *chip) /* * mixer creation - all stuff is implemented in hda module */ -static int __devinit azx_mixer_create(azx_t *chip) +static int __devinit azx_mixer_create(struct azx *chip) { return snd_hda_build_controls(chip->bus); } @@ -1143,21 +1305,19 @@ static int __devinit azx_mixer_create(azx_t *chip) /* * initialize SD streams */ -static int __devinit azx_init_stream(azx_t *chip) +static int __devinit azx_init_stream(struct azx *chip) { int i; /* initialize each stream (aka device) * assign the starting bdl address to each stream (device) and initialize */ - for (i = 0; i < MAX_ICH6_DEV; i++) { + for (i = 0; i < chip->num_streams; i++) { unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4); - azx_dev_t *azx_dev = &chip->azx_dev[i]; + struct azx_dev *azx_dev = &chip->azx_dev[i]; azx_dev->bdl = (u32 *)(chip->bdl.area + off); azx_dev->bdl_addr = chip->bdl.addr + off; -#ifdef USE_POSBUF azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); -#endif /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ @@ -1175,28 +1335,33 @@ static int __devinit azx_init_stream(azx_t *chip) /* * power management */ -static int azx_suspend(snd_card_t *card, pm_message_t state) +static int azx_suspend(struct pci_dev *pci, pm_message_t state) { - azx_t *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct azx *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < chip->pcm_devs; i++) - if (chip->pcm[i]) - snd_pcm_suspend_all(chip->pcm[i]); + snd_pcm_suspend_all(chip->pcm[i]); snd_hda_suspend(chip->bus, state); azx_free_cmd_io(chip); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int azx_resume(snd_card_t *card) +static int azx_resume(struct pci_dev *pci) { - azx_t *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct azx *chip = card->private_data; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); azx_init_chip(chip); snd_hda_resume(chip->bus); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1205,12 +1370,12 @@ static int azx_resume(snd_card_t *card) /* * destructor */ -static int azx_free(azx_t *chip) +static int azx_free(struct azx *chip) { - if (chip->remap_addr) { + if (chip->initialized) { int i; - for (i = 0; i < MAX_ICH6_DEV; i++) + for (i = 0; i < chip->num_streams; i++) azx_stream_stop(chip, &chip->azx_dev[i]); /* disable interrupts */ @@ -1226,10 +1391,10 @@ static int azx_free(azx_t *chip) /* wait a little for interrupts to finish */ msleep(1); - - iounmap(chip->remap_addr); } + if (chip->remap_addr) + iounmap(chip->remap_addr); if (chip->irq >= 0) free_irq(chip->irq, (void*)chip); @@ -1237,18 +1402,17 @@ static int azx_free(azx_t *chip) snd_dma_free_pages(&chip->bdl); if (chip->rb.area) snd_dma_free_pages(&chip->rb); -#ifdef USE_POSBUF if (chip->posbuf.area) snd_dma_free_pages(&chip->posbuf); -#endif pci_release_regions(chip->pci); pci_disable_device(chip->pci); + kfree(chip->azx_dev); kfree(chip); return 0; } -static int azx_dev_free(snd_device_t *device) +static int azx_dev_free(struct snd_device *device) { return azx_free(device->device_data); } @@ -1256,11 +1420,13 @@ static int azx_dev_free(snd_device_t *device) /* * constructor */ -static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **rchip) +static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, + int driver_type, + struct azx **rchip) { - azx_t *chip; + struct azx *chip; int err = 0; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = azx_dev_free, }; @@ -1269,7 +1435,7 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r if ((err = pci_enable_device(pci)) < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (NULL == chip) { snd_printk(KERN_ERR SFX "cannot allocate chip\n"); @@ -1278,10 +1444,24 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r } spin_lock_init(&chip->reg_lock); - init_MUTEX(&chip->open_mutex); + mutex_init(&chip->open_mutex); chip->card = card; chip->pci = pci; chip->irq = -1; + chip->driver_type = driver_type; + + chip->position_fix = position_fix; + chip->single_cmd = single_cmd; + +#if BITS_PER_LONG != 64 + /* Fix up base address on ULI M5461 */ + if (chip->driver_type == AZX_DRIVER_ULI) { + u16 tmp3; + pci_read_config_word(pci, 0x40, &tmp3); + pci_write_config_word(pci, 0x40, tmp3 | 0x10); + pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0); + } +#endif if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) { kfree(chip); @@ -1308,23 +1488,43 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r pci_set_master(pci); synchronize_irq(chip->irq); + switch (chip->driver_type) { + case AZX_DRIVER_ULI: + chip->playback_streams = ULI_NUM_PLAYBACK; + chip->capture_streams = ULI_NUM_CAPTURE; + chip->playback_index_offset = ULI_PLAYBACK_INDEX; + chip->capture_index_offset = ULI_CAPTURE_INDEX; + break; + default: + chip->playback_streams = ICH6_NUM_PLAYBACK; + chip->capture_streams = ICH6_NUM_CAPTURE; + chip->playback_index_offset = ICH6_PLAYBACK_INDEX; + chip->capture_index_offset = ICH6_CAPTURE_INDEX; + break; + } + chip->num_streams = chip->playback_streams + chip->capture_streams; + chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), GFP_KERNEL); + if (! chip->azx_dev) { + snd_printk(KERN_ERR "cannot malloc azx_dev\n"); + goto errout; + } + /* allocate memory for the BDL for each stream */ if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), - PAGE_SIZE, &chip->bdl)) < 0) { + BDL_SIZE, &chip->bdl)) < 0) { snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); goto errout; } -#ifdef USE_POSBUF /* allocate memory for the position buffer */ if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), - MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) { + chip->num_streams * 8, &chip->posbuf)) < 0) { snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); goto errout; } -#endif /* allocate CORB/RIRB */ - if ((err = azx_alloc_cmd_io(chip)) < 0) - goto errout; + if (! chip->single_cmd) + if ((err = azx_alloc_cmd_io(chip)) < 0) + goto errout; /* initialize streams */ azx_init_stream(chip); @@ -1332,6 +1532,8 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r /* initialize chip */ azx_init_chip(chip); + chip->initialized = 1; + /* codec detection */ if (! chip->codec_mask) { snd_printk(KERN_ERR SFX "no codecs found!\n"); @@ -1344,6 +1546,10 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r goto errout; } + strcpy(card->driver, "HDA-Intel"); + strcpy(card->shortname, driver_short_names[chip->driver_type]); + sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq); + *rchip = chip; return 0; @@ -1354,35 +1560,25 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, azx_t **r static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; - snd_card_t *card; - azx_t *chip; + struct snd_card *card; + struct azx *chip; int err = 0; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (! enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (NULL == card) { snd_printk(KERN_ERR SFX "Error creating card!\n"); return -ENOMEM; } - if ((err = azx_create(card, pci, &chip)) < 0) { + if ((err = azx_create(card, pci, pci_id->driver_data, + &chip)) < 0) { snd_card_free(card); return err; } - - strcpy(card->driver, "HDA-Intel"); - strcpy(card->shortname, "HDA Intel"); - sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq); + card->private_data = chip; /* create codec instances */ - if ((err = azx_codec_create(chip, model[dev])) < 0) { + if ((err = azx_codec_create(chip, model)) < 0) { snd_card_free(card); return err; } @@ -1399,7 +1595,6 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id * return err; } - snd_card_set_pm_callback(card, azx_suspend, azx_resume, chip); snd_card_set_dev(card, &pci->dev); if ((err = snd_card_register(card)) < 0) { @@ -1408,7 +1603,6 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id * } pci_set_drvdata(pci, card); - dev++; return err; } @@ -1420,10 +1614,18 @@ static void __devexit azx_remove(struct pci_dev *pci) } /* PCI IDs */ -static struct pci_device_id azx_ids[] = { - { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */ - { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */ - { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */ +static struct pci_device_id azx_ids[] __devinitdata = { + { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */ + { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */ + { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */ + { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */ + { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ + { 0x1002, 0x4383, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB600 */ + { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ + { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ + { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ + { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 026c */ + { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 0371 */ { 0, } }; MODULE_DEVICE_TABLE(pci, azx_ids); @@ -1434,12 +1636,15 @@ static struct pci_driver driver = { .id_table = azx_ids, .probe = azx_probe, .remove = __devexit_p(azx_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = azx_suspend, + .resume = azx_resume, +#endif }; static int __init alsa_card_azx_init(void) { - return pci_module_init(&driver); + return pci_register_driver(&driver); } static void __exit alsa_card_azx_exit(void)