3 * hda_intel.c - Implementation of primary alsa driver code base
6 * Copyright(c) 2004 Intel Corporation. All rights reserved.
8 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
9 * PeiSen Hou <pshou@realtek.com.tw>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 * You should have received a copy of the GNU General Public License along with
22 * this program; if not, write to the Free Software Foundation, Inc., 59
23 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * Matt Jared matt.jared@intel.com
28 * Andy Kopp andy.kopp@intel.com
29 * Dan Kogan dan.d.kogan@intel.com
33 * 2004.12.01 Major rewrite by tiwai, merged the work of pshou
38 #include <linux/delay.h>
39 #include <linux/interrupt.h>
40 #include <linux/kernel.h>
41 #include <linux/module.h>
42 #include <linux/dma-mapping.h>
43 #include <linux/moduleparam.h>
44 #include <linux/init.h>
45 #include <linux/slab.h>
46 #include <linux/pci.h>
47 #include <linux/mutex.h>
48 #include <sound/core.h>
49 #include <sound/initval.h>
50 #include "hda_codec.h"
53 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
54 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
55 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
56 static char *model[SNDRV_CARDS];
57 static int position_fix[SNDRV_CARDS];
58 static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1};
59 static int single_cmd;
60 static int enable_msi;
62 module_param_array(index, int, NULL, 0444);
63 MODULE_PARM_DESC(index, "Index value for Intel HD audio interface.");
64 module_param_array(id, charp, NULL, 0444);
65 MODULE_PARM_DESC(id, "ID string for Intel HD audio interface.");
66 module_param_array(enable, bool, NULL, 0444);
67 MODULE_PARM_DESC(enable, "Enable Intel HD audio interface.");
68 module_param_array(model, charp, NULL, 0444);
69 MODULE_PARM_DESC(model, "Use the given board model.");
70 module_param_array(position_fix, int, NULL, 0444);
71 MODULE_PARM_DESC(position_fix, "Fix DMA pointer "
72 "(0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size).");
73 module_param_array(probe_mask, int, NULL, 0444);
74 MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
75 module_param(single_cmd, bool, 0444);
76 MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs "
77 "(for debugging only).");
78 module_param(enable_msi, int, 0444);
79 MODULE_PARM_DESC(enable_msi, "Enable Message Signaled Interrupt (MSI)");
81 #ifdef CONFIG_SND_HDA_POWER_SAVE
82 /* power_save option is defined in hda_codec.c */
84 /* reset the HD-audio controller in power save mode.
85 * this may give more power-saving, but will take longer time to
88 static int power_save_controller = 1;
89 module_param(power_save_controller, bool, 0644);
90 MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
93 MODULE_LICENSE("GPL");
94 MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
118 MODULE_DESCRIPTION("Intel HDA driver");
120 #define SFX "hda-intel: "
126 #define ICH6_REG_GCAP 0x00
127 #define ICH6_REG_VMIN 0x02
128 #define ICH6_REG_VMAJ 0x03
129 #define ICH6_REG_OUTPAY 0x04
130 #define ICH6_REG_INPAY 0x06
131 #define ICH6_REG_GCTL 0x08
132 #define ICH6_REG_WAKEEN 0x0c
133 #define ICH6_REG_STATESTS 0x0e
134 #define ICH6_REG_GSTS 0x10
135 #define ICH6_REG_INTCTL 0x20
136 #define ICH6_REG_INTSTS 0x24
137 #define ICH6_REG_WALCLK 0x30
138 #define ICH6_REG_SYNC 0x34
139 #define ICH6_REG_CORBLBASE 0x40
140 #define ICH6_REG_CORBUBASE 0x44
141 #define ICH6_REG_CORBWP 0x48
142 #define ICH6_REG_CORBRP 0x4A
143 #define ICH6_REG_CORBCTL 0x4c
144 #define ICH6_REG_CORBSTS 0x4d
145 #define ICH6_REG_CORBSIZE 0x4e
147 #define ICH6_REG_RIRBLBASE 0x50
148 #define ICH6_REG_RIRBUBASE 0x54
149 #define ICH6_REG_RIRBWP 0x58
150 #define ICH6_REG_RINTCNT 0x5a
151 #define ICH6_REG_RIRBCTL 0x5c
152 #define ICH6_REG_RIRBSTS 0x5d
153 #define ICH6_REG_RIRBSIZE 0x5e
155 #define ICH6_REG_IC 0x60
156 #define ICH6_REG_IR 0x64
157 #define ICH6_REG_IRS 0x68
158 #define ICH6_IRS_VALID (1<<1)
159 #define ICH6_IRS_BUSY (1<<0)
161 #define ICH6_REG_DPLBASE 0x70
162 #define ICH6_REG_DPUBASE 0x74
163 #define ICH6_DPLBASE_ENABLE 0x1 /* Enable position buffer */
165 /* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
166 enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
168 /* stream register offsets from stream base */
169 #define ICH6_REG_SD_CTL 0x00
170 #define ICH6_REG_SD_STS 0x03
171 #define ICH6_REG_SD_LPIB 0x04
172 #define ICH6_REG_SD_CBL 0x08
173 #define ICH6_REG_SD_LVI 0x0c
174 #define ICH6_REG_SD_FIFOW 0x0e
175 #define ICH6_REG_SD_FIFOSIZE 0x10
176 #define ICH6_REG_SD_FORMAT 0x12
177 #define ICH6_REG_SD_BDLPL 0x18
178 #define ICH6_REG_SD_BDLPU 0x1c
181 #define ICH6_PCIREG_TCSEL 0x44
187 /* max number of SDs */
188 /* ICH, ATI and VIA have 4 playback and 4 capture */
189 #define ICH6_NUM_CAPTURE 4
190 #define ICH6_NUM_PLAYBACK 4
192 /* ULI has 6 playback and 5 capture */
193 #define ULI_NUM_CAPTURE 5
194 #define ULI_NUM_PLAYBACK 6
196 /* ATI HDMI has 1 playback and 0 capture */
197 #define ATIHDMI_NUM_CAPTURE 0
198 #define ATIHDMI_NUM_PLAYBACK 1
200 /* this number is statically defined for simplicity */
201 #define MAX_AZX_DEV 16
203 /* max number of fragments - we may use more if allocating more pages for BDL */
204 #define BDL_SIZE 4096
205 #define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16)
206 #define AZX_MAX_FRAG 32
207 /* max buffer size - no h/w limit, you can increase as you like */
208 #define AZX_MAX_BUF_SIZE (1024*1024*1024)
209 /* max number of PCM devics per card */
210 #define AZX_MAX_PCMS 8
212 /* RIRB int mask: overrun[2], response[0] */
213 #define RIRB_INT_RESPONSE 0x01
214 #define RIRB_INT_OVERRUN 0x04
215 #define RIRB_INT_MASK 0x05
217 /* STATESTS int mask: SD2,SD1,SD0 */
218 #define AZX_MAX_CODECS 3
219 #define STATESTS_INT_MASK 0x07
222 #define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
223 #define SD_CTL_DMA_START 0x02 /* stream DMA start bit */
224 #define SD_CTL_STRIPE (3 << 16) /* stripe control */
225 #define SD_CTL_TRAFFIC_PRIO (1 << 18) /* traffic priority */
226 #define SD_CTL_DIR (1 << 19) /* bi-directional stream */
227 #define SD_CTL_STREAM_TAG_MASK (0xf << 20)
228 #define SD_CTL_STREAM_TAG_SHIFT 20
230 /* SD_CTL and SD_STS */
231 #define SD_INT_DESC_ERR 0x10 /* descriptor error interrupt */
232 #define SD_INT_FIFO_ERR 0x08 /* FIFO error interrupt */
233 #define SD_INT_COMPLETE 0x04 /* completion interrupt */
234 #define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
238 #define SD_STS_FIFO_READY 0x20 /* FIFO ready */
240 /* INTCTL and INTSTS */
241 #define ICH6_INT_ALL_STREAM 0xff /* all stream interrupts */
242 #define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */
243 #define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */
245 /* GCTL unsolicited response enable bit */
246 #define ICH6_GCTL_UREN (1<<8)
249 #define ICH6_GCTL_RESET (1<<0)
251 /* CORB/RIRB control, read/write pointer */
252 #define ICH6_RBCTL_DMA_EN 0x02 /* enable DMA */
253 #define ICH6_RBCTL_IRQ_EN 0x01 /* enable IRQ */
254 #define ICH6_RBRWP_CLR 0x8000 /* read/write pointer clear */
255 /* below are so far hardcoded - should read registers in future */
256 #define ICH6_MAX_CORB_ENTRIES 256
257 #define ICH6_MAX_RIRB_ENTRIES 256
259 /* position fix mode */
267 /* Defines for ATI HD Audio support in SB450 south bridge */
268 #define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42
269 #define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02
271 /* Defines for Nvidia HDA support */
272 #define NVIDIA_HDA_TRANSREG_ADDR 0x4e
273 #define NVIDIA_HDA_ENABLE_COHBITS 0x0f
275 /* Defines for Intel SCH HDA snoop control */
276 #define INTEL_SCH_HDA_DEVC 0x78
277 #define INTEL_SCH_HDA_DEVC_NOSNOOP (0x1<<11)
284 struct snd_dma_buffer bdl; /* BDL buffer */
285 u32 *posbuf; /* position buffer pointer */
287 unsigned int bufsize; /* size of the play buffer in bytes */
288 unsigned int period_bytes; /* size of the period in bytes */
289 unsigned int frags; /* number for period in the play buffer */
290 unsigned int fifo_size; /* FIFO size */
292 void __iomem *sd_addr; /* stream descriptor pointer */
294 u32 sd_int_sta_mask; /* stream int status mask */
297 struct snd_pcm_substream *substream; /* assigned substream,
300 unsigned int format_val; /* format value to be set in the
301 * controller and the codec
303 unsigned char stream_tag; /* assigned stream */
304 unsigned char index; /* stream index */
306 unsigned int opened :1;
307 unsigned int running :1;
308 unsigned int irq_pending: 1;
313 u32 *buf; /* CORB/RIRB buffer
314 * Each CORB entry is 4byte, RIRB is 8byte
316 dma_addr_t addr; /* physical address of CORB/RIRB buffer */
318 unsigned short rp, wp; /* read/write pointers */
319 int cmds; /* number of pending requests */
320 u32 res; /* last read value */
324 struct snd_card *card;
327 /* chip type specific */
329 int playback_streams;
330 int playback_index_offset;
332 int capture_index_offset;
337 void __iomem *remap_addr;
342 struct mutex open_mutex;
344 /* streams (x num_streams) */
345 struct azx_dev *azx_dev;
348 struct snd_pcm *pcm[AZX_MAX_PCMS];
351 unsigned short codec_mask;
358 /* CORB/RIRB and position buffers */
359 struct snd_dma_buffer rb;
360 struct snd_dma_buffer posbuf;
364 unsigned int running :1;
365 unsigned int initialized :1;
366 unsigned int single_cmd :1;
367 unsigned int polling_mode :1;
371 unsigned int last_cmd; /* last issued command (to sync) */
373 /* for pending irqs */
374 struct work_struct irq_pending_work;
389 static char *driver_short_names[] __devinitdata = {
390 [AZX_DRIVER_ICH] = "HDA Intel",
391 [AZX_DRIVER_SCH] = "HDA Intel MID",
392 [AZX_DRIVER_ATI] = "HDA ATI SB",
393 [AZX_DRIVER_ATIHDMI] = "HDA ATI HDMI",
394 [AZX_DRIVER_VIA] = "HDA VIA VT82xx",
395 [AZX_DRIVER_SIS] = "HDA SIS966",
396 [AZX_DRIVER_ULI] = "HDA ULI M5461",
397 [AZX_DRIVER_NVIDIA] = "HDA NVidia",
401 * macros for easy use
403 #define azx_writel(chip,reg,value) \
404 writel(value, (chip)->remap_addr + ICH6_REG_##reg)
405 #define azx_readl(chip,reg) \
406 readl((chip)->remap_addr + ICH6_REG_##reg)
407 #define azx_writew(chip,reg,value) \
408 writew(value, (chip)->remap_addr + ICH6_REG_##reg)
409 #define azx_readw(chip,reg) \
410 readw((chip)->remap_addr + ICH6_REG_##reg)
411 #define azx_writeb(chip,reg,value) \
412 writeb(value, (chip)->remap_addr + ICH6_REG_##reg)
413 #define azx_readb(chip,reg) \
414 readb((chip)->remap_addr + ICH6_REG_##reg)
416 #define azx_sd_writel(dev,reg,value) \
417 writel(value, (dev)->sd_addr + ICH6_REG_##reg)
418 #define azx_sd_readl(dev,reg) \
419 readl((dev)->sd_addr + ICH6_REG_##reg)
420 #define azx_sd_writew(dev,reg,value) \
421 writew(value, (dev)->sd_addr + ICH6_REG_##reg)
422 #define azx_sd_readw(dev,reg) \
423 readw((dev)->sd_addr + ICH6_REG_##reg)
424 #define azx_sd_writeb(dev,reg,value) \
425 writeb(value, (dev)->sd_addr + ICH6_REG_##reg)
426 #define azx_sd_readb(dev,reg) \
427 readb((dev)->sd_addr + ICH6_REG_##reg)
429 /* for pcm support */
430 #define get_azx_dev(substream) (substream->runtime->private_data)
432 /* Get the upper 32bit of the given dma_addr_t
433 * Compiler should optimize and eliminate the code if dma_addr_t is 32bit
435 #define upper_32bit(addr) (sizeof(addr) > 4 ? (u32)((addr) >> 32) : (u32)0)
437 static int azx_acquire_irq(struct azx *chip, int do_disconnect);
440 * Interface for HD codec
444 * CORB / RIRB interface
446 static int azx_alloc_cmd_io(struct azx *chip)
450 /* single page (at least 4096 bytes) must suffice for both ringbuffes */
451 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
452 snd_dma_pci_data(chip->pci),
453 PAGE_SIZE, &chip->rb);
455 snd_printk(KERN_ERR SFX "cannot allocate CORB/RIRB\n");
461 static void azx_init_cmd_io(struct azx *chip)
464 chip->corb.addr = chip->rb.addr;
465 chip->corb.buf = (u32 *)chip->rb.area;
466 azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
467 azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr));
469 /* set the corb size to 256 entries (ULI requires explicitly) */
470 azx_writeb(chip, CORBSIZE, 0x02);
471 /* set the corb write pointer to 0 */
472 azx_writew(chip, CORBWP, 0);
473 /* reset the corb hw read pointer */
474 azx_writew(chip, CORBRP, ICH6_RBRWP_CLR);
475 /* enable corb dma */
476 azx_writeb(chip, CORBCTL, ICH6_RBCTL_DMA_EN);
479 chip->rirb.addr = chip->rb.addr + 2048;
480 chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
481 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
482 azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr));
484 /* set the rirb size to 256 entries (ULI requires explicitly) */
485 azx_writeb(chip, RIRBSIZE, 0x02);
486 /* reset the rirb hw write pointer */
487 azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR);
488 /* set N=1, get RIRB response interrupt for new entry */
489 azx_writew(chip, RINTCNT, 1);
490 /* enable rirb dma and response irq */
491 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN);
492 chip->rirb.rp = chip->rirb.cmds = 0;
495 static void azx_free_cmd_io(struct azx *chip)
497 /* disable ringbuffer DMAs */
498 azx_writeb(chip, RIRBCTL, 0);
499 azx_writeb(chip, CORBCTL, 0);
503 static int azx_corb_send_cmd(struct hda_codec *codec, u32 val)
505 struct azx *chip = codec->bus->private_data;
508 /* add command to corb */
509 wp = azx_readb(chip, CORBWP);
511 wp %= ICH6_MAX_CORB_ENTRIES;
513 spin_lock_irq(&chip->reg_lock);
515 chip->corb.buf[wp] = cpu_to_le32(val);
516 azx_writel(chip, CORBWP, wp);
517 spin_unlock_irq(&chip->reg_lock);
522 #define ICH6_RIRB_EX_UNSOL_EV (1<<4)
524 /* retrieve RIRB entry - called from interrupt handler */
525 static void azx_update_rirb(struct azx *chip)
530 wp = azx_readb(chip, RIRBWP);
531 if (wp == chip->rirb.wp)
535 while (chip->rirb.rp != wp) {
537 chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES;
539 rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */
540 res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]);
541 res = le32_to_cpu(chip->rirb.buf[rp]);
542 if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
543 snd_hda_queue_unsol_event(chip->bus, res, res_ex);
544 else if (chip->rirb.cmds) {
545 chip->rirb.res = res;
552 /* receive a response */
553 static unsigned int azx_rirb_get_response(struct hda_codec *codec)
555 struct azx *chip = codec->bus->private_data;
556 unsigned long timeout;
559 timeout = jiffies + msecs_to_jiffies(1000);
561 if (chip->polling_mode) {
562 spin_lock_irq(&chip->reg_lock);
563 azx_update_rirb(chip);
564 spin_unlock_irq(&chip->reg_lock);
566 if (!chip->rirb.cmds) {
568 return chip->rirb.res; /* the last value */
570 if (time_after(jiffies, timeout))
572 if (codec->bus->needs_damn_long_delay)
573 msleep(2); /* temporary workaround */
581 snd_printk(KERN_WARNING "hda_intel: No response from codec, "
582 "disabling MSI: last cmd=0x%08x\n", chip->last_cmd);
583 free_irq(chip->irq, chip);
585 pci_disable_msi(chip->pci);
587 if (azx_acquire_irq(chip, 1) < 0)
592 if (!chip->polling_mode) {
593 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, "
594 "switching to polling mode: last cmd=0x%08x\n",
596 chip->polling_mode = 1;
600 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
601 "switching to single_cmd mode: last cmd=0x%08x\n",
603 chip->rirb.rp = azx_readb(chip, RIRBWP);
605 /* switch to single_cmd mode */
606 chip->single_cmd = 1;
607 azx_free_cmd_io(chip);
612 * Use the single immediate command instead of CORB/RIRB for simplicity
614 * Note: according to Intel, this is not preferred use. The command was
615 * intended for the BIOS only, and may get confused with unsolicited
616 * responses. So, we shouldn't use it for normal operation from the
618 * I left the codes, however, for debugging/testing purposes.
622 static int azx_single_send_cmd(struct hda_codec *codec, u32 val)
624 struct azx *chip = codec->bus->private_data;
628 /* check ICB busy bit */
629 if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) {
630 /* Clear IRV valid bit */
631 azx_writew(chip, IRS, azx_readw(chip, IRS) |
633 azx_writel(chip, IC, val);
634 azx_writew(chip, IRS, azx_readw(chip, IRS) |
640 if (printk_ratelimit())
641 snd_printd(SFX "send_cmd timeout: IRS=0x%x, val=0x%x\n",
642 azx_readw(chip, IRS), val);
646 /* receive a response */
647 static unsigned int azx_single_get_response(struct hda_codec *codec)
649 struct azx *chip = codec->bus->private_data;
653 /* check IRV busy bit */
654 if (azx_readw(chip, IRS) & ICH6_IRS_VALID)
655 return azx_readl(chip, IR);
658 if (printk_ratelimit())
659 snd_printd(SFX "get_response timeout: IRS=0x%x\n",
660 azx_readw(chip, IRS));
661 return (unsigned int)-1;
665 * The below are the main callbacks from hda_codec.
667 * They are just the skeleton to call sub-callbacks according to the
668 * current setting of chip->single_cmd.
672 static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid,
673 int direct, unsigned int verb,
676 struct azx *chip = codec->bus->private_data;
679 val = (u32)(codec->addr & 0x0f) << 28;
680 val |= (u32)direct << 27;
681 val |= (u32)nid << 20;
684 chip->last_cmd = val;
686 if (chip->single_cmd)
687 return azx_single_send_cmd(codec, val);
689 return azx_corb_send_cmd(codec, val);
693 static unsigned int azx_get_response(struct hda_codec *codec)
695 struct azx *chip = codec->bus->private_data;
696 if (chip->single_cmd)
697 return azx_single_get_response(codec);
699 return azx_rirb_get_response(codec);
702 #ifdef CONFIG_SND_HDA_POWER_SAVE
703 static void azx_power_notify(struct hda_codec *codec);
706 /* reset codec link */
707 static int azx_reset(struct azx *chip)
712 azx_writeb(chip, STATESTS, STATESTS_INT_MASK);
714 /* reset controller */
715 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_RESET);
718 while (azx_readb(chip, GCTL) && --count)
721 /* delay for >= 100us for codec PLL to settle per spec
722 * Rev 0.9 section 5.5.1
726 /* Bring controller out of reset */
727 azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET);
730 while (!azx_readb(chip, GCTL) && --count)
733 /* Brent Chartrand said to wait >= 540us for codecs to initialize */
736 /* check to see if controller is ready */
737 if (!azx_readb(chip, GCTL)) {
738 snd_printd("azx_reset: controller not ready!\n");
742 /* Accept unsolicited responses */
743 azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UREN);
746 if (!chip->codec_mask) {
747 chip->codec_mask = azx_readw(chip, STATESTS);
748 snd_printdd("codec_mask = 0x%x\n", chip->codec_mask);
759 /* enable interrupts */
760 static void azx_int_enable(struct azx *chip)
762 /* enable controller CIE and GIE */
763 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) |
764 ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN);
767 /* disable interrupts */
768 static void azx_int_disable(struct azx *chip)
772 /* disable interrupts in stream descriptor */
773 for (i = 0; i < chip->num_streams; i++) {
774 struct azx_dev *azx_dev = &chip->azx_dev[i];
775 azx_sd_writeb(azx_dev, SD_CTL,
776 azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK);
779 /* disable SIE for all streams */
780 azx_writeb(chip, INTCTL, 0);
782 /* disable controller CIE and GIE */
783 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) &
784 ~(ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN));
787 /* clear interrupts */
788 static void azx_int_clear(struct azx *chip)
792 /* clear stream status */
793 for (i = 0; i < chip->num_streams; i++) {
794 struct azx_dev *azx_dev = &chip->azx_dev[i];
795 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
799 azx_writeb(chip, STATESTS, STATESTS_INT_MASK);
801 /* clear rirb status */
802 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
804 /* clear int status */
805 azx_writel(chip, INTSTS, ICH6_INT_CTRL_EN | ICH6_INT_ALL_STREAM);
809 static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev)
812 azx_writeb(chip, INTCTL,
813 azx_readb(chip, INTCTL) | (1 << azx_dev->index));
814 /* set DMA start and interrupt mask */
815 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
816 SD_CTL_DMA_START | SD_INT_MASK);
820 static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
823 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
824 ~(SD_CTL_DMA_START | SD_INT_MASK));
825 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
827 azx_writeb(chip, INTCTL,
828 azx_readb(chip, INTCTL) & ~(1 << azx_dev->index));
833 * reset and start the controller registers
835 static void azx_init_chip(struct azx *chip)
837 if (chip->initialized)
840 /* reset controller */
843 /* initialize interrupts */
845 azx_int_enable(chip);
847 /* initialize the codec command I/O */
848 if (!chip->single_cmd)
849 azx_init_cmd_io(chip);
851 /* program the position buffer */
852 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
853 azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr));
855 chip->initialized = 1;
859 * initialize the PCI registers
861 /* update bits in a PCI register byte */
862 static void update_pci_byte(struct pci_dev *pci, unsigned int reg,
863 unsigned char mask, unsigned char val)
867 pci_read_config_byte(pci, reg, &data);
869 data |= (val & mask);
870 pci_write_config_byte(pci, reg, data);
873 static void azx_init_pci(struct azx *chip)
875 unsigned short snoop;
877 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
878 * TCSEL == Traffic Class Select Register, which sets PCI express QOS
879 * Ensuring these bits are 0 clears playback static on some HD Audio
882 update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0);
884 switch (chip->driver_type) {
886 /* For ATI SB450 azalia HD audio, we need to enable snoop */
887 update_pci_byte(chip->pci,
888 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR,
889 0x07, ATI_SB450_HDAUDIO_ENABLE_SNOOP);
891 case AZX_DRIVER_NVIDIA:
892 /* For NVIDIA HDA, enable snoop */
893 update_pci_byte(chip->pci,
894 NVIDIA_HDA_TRANSREG_ADDR,
895 0x0f, NVIDIA_HDA_ENABLE_COHBITS);
898 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
899 if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) {
900 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, \
901 snoop & (~INTEL_SCH_HDA_DEVC_NOSNOOP));
902 pci_read_config_word(chip->pci,
903 INTEL_SCH_HDA_DEVC, &snoop);
904 snd_printdd("HDA snoop disabled, enabling ... %s\n",\
905 (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) \
914 static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev);
919 static irqreturn_t azx_interrupt(int irq, void *dev_id)
921 struct azx *chip = dev_id;
922 struct azx_dev *azx_dev;
926 spin_lock(&chip->reg_lock);
928 status = azx_readl(chip, INTSTS);
930 spin_unlock(&chip->reg_lock);
934 for (i = 0; i < chip->num_streams; i++) {
935 azx_dev = &chip->azx_dev[i];
936 if (status & azx_dev->sd_int_sta_mask) {
937 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
938 if (!azx_dev->substream || !azx_dev->running)
940 /* check whether this IRQ is really acceptable */
941 if (azx_position_ok(chip, azx_dev)) {
942 azx_dev->irq_pending = 0;
943 spin_unlock(&chip->reg_lock);
944 snd_pcm_period_elapsed(azx_dev->substream);
945 spin_lock(&chip->reg_lock);
947 /* bogus IRQ, process it later */
948 azx_dev->irq_pending = 1;
949 schedule_work(&chip->irq_pending_work);
955 status = azx_readb(chip, RIRBSTS);
956 if (status & RIRB_INT_MASK) {
957 if (!chip->single_cmd && (status & RIRB_INT_RESPONSE))
958 azx_update_rirb(chip);
959 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
963 /* clear state status int */
964 if (azx_readb(chip, STATESTS) & 0x04)
965 azx_writeb(chip, STATESTS, 0x04);
967 spin_unlock(&chip->reg_lock);
976 static int azx_setup_periods(struct snd_pcm_substream *substream,
977 struct azx_dev *azx_dev)
979 struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream);
981 int i, ofs, periods, period_bytes;
983 /* reset BDL address */
984 azx_sd_writel(azx_dev, SD_BDLPL, 0);
985 azx_sd_writel(azx_dev, SD_BDLPU, 0);
987 period_bytes = snd_pcm_lib_period_bytes(substream);
988 azx_dev->period_bytes = period_bytes;
989 periods = azx_dev->bufsize / period_bytes;
991 /* program the initial BDL entries */
992 bdl = (u32 *)azx_dev->bdl.area;
995 for (i = 0; i < periods; i++) {
997 if (i >= AZX_MAX_BDL_ENTRIES) {
998 snd_printk(KERN_ERR "Too many BDL entries: "
999 "buffer=%d, period=%d\n",
1000 azx_dev->bufsize, period_bytes);
1002 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1003 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1006 rest = period_bytes;
1008 dma_addr_t addr = snd_pcm_sgbuf_get_addr(sgbuf, ofs);
1009 /* program the address field of the BDL entry */
1010 bdl[0] = cpu_to_le32((u32)addr);
1011 bdl[1] = cpu_to_le32(upper_32bit(addr));
1012 /* program the size field of the BDL entry */
1013 size = PAGE_SIZE - (ofs % PAGE_SIZE);
1016 bdl[2] = cpu_to_le32(size);
1017 /* program the IOC to enable interrupt
1018 * only when the whole fragment is processed
1021 bdl[3] = rest ? 0 : cpu_to_le32(0x01);
1031 * set up the SD for streaming
1033 static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1038 /* make sure the run bit is zero for SD */
1039 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
1042 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
1043 SD_CTL_STREAM_RESET);
1046 while (!((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
1049 val &= ~SD_CTL_STREAM_RESET;
1050 azx_sd_writeb(azx_dev, SD_CTL, val);
1054 /* waiting for hardware to report that the stream is out of reset */
1055 while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
1059 /* program the stream_tag */
1060 azx_sd_writel(azx_dev, SD_CTL,
1061 (azx_sd_readl(azx_dev, SD_CTL) & ~SD_CTL_STREAM_TAG_MASK)|
1062 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT));
1064 /* program the length of samples in cyclic buffer */
1065 azx_sd_writel(azx_dev, SD_CBL, azx_dev->bufsize);
1067 /* program the stream format */
1068 /* this value needs to be the same as the one programmed */
1069 azx_sd_writew(azx_dev, SD_FORMAT, azx_dev->format_val);
1071 /* program the stream LVI (last valid index) of the BDL */
1072 azx_sd_writew(azx_dev, SD_LVI, azx_dev->frags - 1);
1074 /* program the BDL address */
1075 /* lower BDL address */
1076 azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
1077 /* upper BDL address */
1078 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl.addr));
1080 /* enable the position buffer */
1081 if (chip->position_fix == POS_FIX_POSBUF ||
1082 chip->position_fix == POS_FIX_AUTO) {
1083 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
1084 azx_writel(chip, DPLBASE,
1085 (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
1088 /* set the interrupt enable bits in the descriptor control register */
1089 azx_sd_writel(azx_dev, SD_CTL,
1090 azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK);
1097 * Codec initialization
1100 static unsigned int azx_max_codecs[] __devinitdata = {
1101 [AZX_DRIVER_ICH] = 3,
1102 [AZX_DRIVER_SCH] = 3,
1103 [AZX_DRIVER_ATI] = 4,
1104 [AZX_DRIVER_ATIHDMI] = 4,
1105 [AZX_DRIVER_VIA] = 3, /* FIXME: correct? */
1106 [AZX_DRIVER_SIS] = 3, /* FIXME: correct? */
1107 [AZX_DRIVER_ULI] = 3, /* FIXME: correct? */
1108 [AZX_DRIVER_NVIDIA] = 3, /* FIXME: correct? */
1111 static int __devinit azx_codec_create(struct azx *chip, const char *model,
1112 unsigned int codec_probe_mask)
1114 struct hda_bus_template bus_temp;
1115 int c, codecs, audio_codecs, err;
1117 memset(&bus_temp, 0, sizeof(bus_temp));
1118 bus_temp.private_data = chip;
1119 bus_temp.modelname = model;
1120 bus_temp.pci = chip->pci;
1121 bus_temp.ops.command = azx_send_cmd;
1122 bus_temp.ops.get_response = azx_get_response;
1123 #ifdef CONFIG_SND_HDA_POWER_SAVE
1124 bus_temp.ops.pm_notify = azx_power_notify;
1127 err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus);
1131 codecs = audio_codecs = 0;
1132 for (c = 0; c < AZX_MAX_CODECS; c++) {
1133 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
1134 struct hda_codec *codec;
1135 err = snd_hda_codec_new(chip->bus, c, &codec);
1143 if (!audio_codecs) {
1144 /* probe additional slots if no codec is found */
1145 for (; c < azx_max_codecs[chip->driver_type]; c++) {
1146 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) {
1147 err = snd_hda_codec_new(chip->bus, c, NULL);
1155 snd_printk(KERN_ERR SFX "no codecs initialized\n");
1167 /* assign a stream for the PCM */
1168 static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream)
1171 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
1172 dev = chip->playback_index_offset;
1173 nums = chip->playback_streams;
1175 dev = chip->capture_index_offset;
1176 nums = chip->capture_streams;
1178 for (i = 0; i < nums; i++, dev++)
1179 if (!chip->azx_dev[dev].opened) {
1180 chip->azx_dev[dev].opened = 1;
1181 return &chip->azx_dev[dev];
1186 /* release the assigned stream */
1187 static inline void azx_release_device(struct azx_dev *azx_dev)
1189 azx_dev->opened = 0;
1192 static struct snd_pcm_hardware azx_pcm_hw = {
1193 .info = (SNDRV_PCM_INFO_MMAP |
1194 SNDRV_PCM_INFO_INTERLEAVED |
1195 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1196 SNDRV_PCM_INFO_MMAP_VALID |
1197 /* No full-resume yet implemented */
1198 /* SNDRV_PCM_INFO_RESUME |*/
1199 SNDRV_PCM_INFO_PAUSE |
1200 SNDRV_PCM_INFO_SYNC_START),
1201 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1202 .rates = SNDRV_PCM_RATE_48000,
1207 .buffer_bytes_max = AZX_MAX_BUF_SIZE,
1208 .period_bytes_min = 128,
1209 .period_bytes_max = AZX_MAX_BUF_SIZE / 2,
1211 .periods_max = AZX_MAX_FRAG,
1217 struct hda_codec *codec;
1218 struct hda_pcm_stream *hinfo[2];
1221 static int azx_pcm_open(struct snd_pcm_substream *substream)
1223 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1224 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1225 struct azx *chip = apcm->chip;
1226 struct azx_dev *azx_dev;
1227 struct snd_pcm_runtime *runtime = substream->runtime;
1228 unsigned long flags;
1231 mutex_lock(&chip->open_mutex);
1232 azx_dev = azx_assign_device(chip, substream->stream);
1233 if (azx_dev == NULL) {
1234 mutex_unlock(&chip->open_mutex);
1237 runtime->hw = azx_pcm_hw;
1238 runtime->hw.channels_min = hinfo->channels_min;
1239 runtime->hw.channels_max = hinfo->channels_max;
1240 runtime->hw.formats = hinfo->formats;
1241 runtime->hw.rates = hinfo->rates;
1242 snd_pcm_limit_hw_rates(runtime);
1243 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
1244 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
1246 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
1248 snd_hda_power_up(apcm->codec);
1249 err = hinfo->ops.open(hinfo, apcm->codec, substream);
1251 azx_release_device(azx_dev);
1252 snd_hda_power_down(apcm->codec);
1253 mutex_unlock(&chip->open_mutex);
1256 spin_lock_irqsave(&chip->reg_lock, flags);
1257 azx_dev->substream = substream;
1258 azx_dev->running = 0;
1259 spin_unlock_irqrestore(&chip->reg_lock, flags);
1261 runtime->private_data = azx_dev;
1262 snd_pcm_set_sync(substream);
1263 mutex_unlock(&chip->open_mutex);
1267 static int azx_pcm_close(struct snd_pcm_substream *substream)
1269 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1270 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1271 struct azx *chip = apcm->chip;
1272 struct azx_dev *azx_dev = get_azx_dev(substream);
1273 unsigned long flags;
1275 mutex_lock(&chip->open_mutex);
1276 spin_lock_irqsave(&chip->reg_lock, flags);
1277 azx_dev->substream = NULL;
1278 azx_dev->running = 0;
1279 spin_unlock_irqrestore(&chip->reg_lock, flags);
1280 azx_release_device(azx_dev);
1281 hinfo->ops.close(hinfo, apcm->codec, substream);
1282 snd_hda_power_down(apcm->codec);
1283 mutex_unlock(&chip->open_mutex);
1287 static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
1288 struct snd_pcm_hw_params *hw_params)
1290 return snd_pcm_lib_malloc_pages(substream,
1291 params_buffer_bytes(hw_params));
1294 static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
1296 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1297 struct azx_dev *azx_dev = get_azx_dev(substream);
1298 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1300 /* reset BDL address */
1301 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1302 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1303 azx_sd_writel(azx_dev, SD_CTL, 0);
1305 hinfo->ops.cleanup(hinfo, apcm->codec, substream);
1307 return snd_pcm_lib_free_pages(substream);
1310 static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1312 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1313 struct azx *chip = apcm->chip;
1314 struct azx_dev *azx_dev = get_azx_dev(substream);
1315 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1316 struct snd_pcm_runtime *runtime = substream->runtime;
1318 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream);
1319 azx_dev->format_val = snd_hda_calc_stream_format(runtime->rate,
1323 if (!azx_dev->format_val) {
1324 snd_printk(KERN_ERR SFX
1325 "invalid format_val, rate=%d, ch=%d, format=%d\n",
1326 runtime->rate, runtime->channels, runtime->format);
1330 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
1331 azx_dev->bufsize, azx_dev->format_val);
1332 if (azx_setup_periods(substream, azx_dev) < 0)
1334 azx_setup_controller(chip, azx_dev);
1335 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1336 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
1338 azx_dev->fifo_size = 0;
1340 return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag,
1341 azx_dev->format_val, substream);
1344 static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1346 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1347 struct azx *chip = apcm->chip;
1348 struct azx_dev *azx_dev;
1349 struct snd_pcm_substream *s;
1350 int start, nsync = 0, sbits = 0;
1354 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1355 case SNDRV_PCM_TRIGGER_RESUME:
1356 case SNDRV_PCM_TRIGGER_START:
1359 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1360 case SNDRV_PCM_TRIGGER_SUSPEND:
1361 case SNDRV_PCM_TRIGGER_STOP:
1368 snd_pcm_group_for_each_entry(s, substream) {
1369 if (s->pcm->card != substream->pcm->card)
1371 azx_dev = get_azx_dev(s);
1372 sbits |= 1 << azx_dev->index;
1374 snd_pcm_trigger_done(s, substream);
1377 spin_lock(&chip->reg_lock);
1379 /* first, set SYNC bits of corresponding streams */
1380 azx_writel(chip, SYNC, azx_readl(chip, SYNC) | sbits);
1382 snd_pcm_group_for_each_entry(s, substream) {
1383 if (s->pcm->card != substream->pcm->card)
1385 azx_dev = get_azx_dev(s);
1387 azx_stream_start(chip, azx_dev);
1389 azx_stream_stop(chip, azx_dev);
1390 azx_dev->running = start;
1392 spin_unlock(&chip->reg_lock);
1396 /* wait until all FIFOs get ready */
1397 for (timeout = 5000; timeout; timeout--) {
1399 snd_pcm_group_for_each_entry(s, substream) {
1400 if (s->pcm->card != substream->pcm->card)
1402 azx_dev = get_azx_dev(s);
1403 if (!(azx_sd_readb(azx_dev, SD_STS) &
1412 /* wait until all RUN bits are cleared */
1413 for (timeout = 5000; timeout; timeout--) {
1415 snd_pcm_group_for_each_entry(s, substream) {
1416 if (s->pcm->card != substream->pcm->card)
1418 azx_dev = get_azx_dev(s);
1419 if (azx_sd_readb(azx_dev, SD_CTL) &
1429 spin_lock(&chip->reg_lock);
1430 /* reset SYNC bits */
1431 azx_writel(chip, SYNC, azx_readl(chip, SYNC) & ~sbits);
1432 spin_unlock(&chip->reg_lock);
1437 static unsigned int azx_get_position(struct azx *chip,
1438 struct azx_dev *azx_dev)
1442 if (chip->position_fix == POS_FIX_POSBUF ||
1443 chip->position_fix == POS_FIX_AUTO) {
1444 /* use the position buffer */
1445 pos = le32_to_cpu(*azx_dev->posbuf);
1448 pos = azx_sd_readl(azx_dev, SD_LPIB);
1449 if (chip->position_fix == POS_FIX_FIFO)
1450 pos += azx_dev->fifo_size;
1452 if (pos >= azx_dev->bufsize)
1457 static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
1459 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1460 struct azx *chip = apcm->chip;
1461 struct azx_dev *azx_dev = get_azx_dev(substream);
1462 return bytes_to_frames(substream->runtime,
1463 azx_get_position(chip, azx_dev));
1467 * Check whether the current DMA position is acceptable for updating
1468 * periods. Returns non-zero if it's OK.
1470 * Many HD-audio controllers appear pretty inaccurate about
1471 * the update-IRQ timing. The IRQ is issued before actually the
1472 * data is processed. So, we need to process it afterwords in a
1475 static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
1479 pos = azx_get_position(chip, azx_dev);
1480 if (chip->position_fix == POS_FIX_AUTO) {
1483 "hda-intel: Invalid position buffer, "
1484 "using LPIB read method instead.\n");
1485 chip->position_fix = POS_FIX_NONE;
1486 pos = azx_get_position(chip, azx_dev);
1488 chip->position_fix = POS_FIX_POSBUF;
1491 if (pos % azx_dev->period_bytes > azx_dev->period_bytes / 2)
1492 return 0; /* NG - it's below the period boundary */
1493 return 1; /* OK, it's fine */
1497 * The work for pending PCM period updates.
1499 static void azx_irq_pending_work(struct work_struct *work)
1501 struct azx *chip = container_of(work, struct azx, irq_pending_work);
1506 spin_lock_irq(&chip->reg_lock);
1507 for (i = 0; i < chip->num_streams; i++) {
1508 struct azx_dev *azx_dev = &chip->azx_dev[i];
1509 if (!azx_dev->irq_pending ||
1510 !azx_dev->substream ||
1513 if (azx_position_ok(chip, azx_dev)) {
1514 azx_dev->irq_pending = 0;
1515 spin_unlock(&chip->reg_lock);
1516 snd_pcm_period_elapsed(azx_dev->substream);
1517 spin_lock(&chip->reg_lock);
1521 spin_unlock_irq(&chip->reg_lock);
1528 /* clear irq_pending flags and assure no on-going workq */
1529 static void azx_clear_irq_pending(struct azx *chip)
1533 spin_lock_irq(&chip->reg_lock);
1534 for (i = 0; i < chip->num_streams; i++)
1535 chip->azx_dev[i].irq_pending = 0;
1536 spin_unlock_irq(&chip->reg_lock);
1537 flush_scheduled_work();
1540 static struct snd_pcm_ops azx_pcm_ops = {
1541 .open = azx_pcm_open,
1542 .close = azx_pcm_close,
1543 .ioctl = snd_pcm_lib_ioctl,
1544 .hw_params = azx_pcm_hw_params,
1545 .hw_free = azx_pcm_hw_free,
1546 .prepare = azx_pcm_prepare,
1547 .trigger = azx_pcm_trigger,
1548 .pointer = azx_pcm_pointer,
1549 .page = snd_pcm_sgbuf_ops_page,
1552 static void azx_pcm_free(struct snd_pcm *pcm)
1554 kfree(pcm->private_data);
1557 static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec,
1558 struct hda_pcm *cpcm)
1561 struct snd_pcm *pcm;
1562 struct azx_pcm *apcm;
1564 /* if no substreams are defined for both playback and capture,
1565 * it's just a placeholder. ignore it.
1567 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
1570 snd_assert(cpcm->name, return -EINVAL);
1572 err = snd_pcm_new(chip->card, cpcm->name, cpcm->device,
1573 cpcm->stream[0].substreams,
1574 cpcm->stream[1].substreams,
1578 strcpy(pcm->name, cpcm->name);
1579 apcm = kmalloc(sizeof(*apcm), GFP_KERNEL);
1583 apcm->codec = codec;
1584 apcm->hinfo[0] = &cpcm->stream[0];
1585 apcm->hinfo[1] = &cpcm->stream[1];
1586 pcm->private_data = apcm;
1587 pcm->private_free = azx_pcm_free;
1588 if (cpcm->stream[0].substreams)
1589 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &azx_pcm_ops);
1590 if (cpcm->stream[1].substreams)
1591 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &azx_pcm_ops);
1592 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1593 snd_dma_pci_data(chip->pci),
1594 1024 * 64, 1024 * 1024);
1595 chip->pcm[cpcm->device] = pcm;
1599 static int __devinit azx_pcm_create(struct azx *chip)
1601 static const char *dev_name[HDA_PCM_NTYPES] = {
1602 "Audio", "SPDIF", "HDMI", "Modem"
1604 /* starting device index for each PCM type */
1605 static int dev_idx[HDA_PCM_NTYPES] = {
1606 [HDA_PCM_TYPE_AUDIO] = 0,
1607 [HDA_PCM_TYPE_SPDIF] = 1,
1608 [HDA_PCM_TYPE_HDMI] = 3,
1609 [HDA_PCM_TYPE_MODEM] = 6
1611 /* normal audio device indices; not linear to keep compatibility */
1612 static int audio_idx[4] = { 0, 2, 4, 5 };
1613 struct hda_codec *codec;
1615 int num_devs[HDA_PCM_NTYPES];
1617 err = snd_hda_build_pcms(chip->bus);
1621 /* create audio PCMs */
1622 memset(num_devs, 0, sizeof(num_devs));
1623 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1624 for (c = 0; c < codec->num_pcms; c++) {
1625 struct hda_pcm *cpcm = &codec->pcm_info[c];
1626 int type = cpcm->pcm_type;
1628 case HDA_PCM_TYPE_AUDIO:
1629 if (num_devs[type] >= ARRAY_SIZE(audio_idx)) {
1630 snd_printk(KERN_WARNING
1631 "Too many audio devices\n");
1634 cpcm->device = audio_idx[num_devs[type]];
1636 case HDA_PCM_TYPE_SPDIF:
1637 case HDA_PCM_TYPE_HDMI:
1638 case HDA_PCM_TYPE_MODEM:
1639 if (num_devs[type]) {
1640 snd_printk(KERN_WARNING
1641 "%s already defined\n",
1645 cpcm->device = dev_idx[type];
1648 snd_printk(KERN_WARNING
1649 "Invalid PCM type %d\n", type);
1653 err = create_codec_pcm(chip, codec, cpcm);
1662 * mixer creation - all stuff is implemented in hda module
1664 static int __devinit azx_mixer_create(struct azx *chip)
1666 return snd_hda_build_controls(chip->bus);
1671 * initialize SD streams
1673 static int __devinit azx_init_stream(struct azx *chip)
1677 /* initialize each stream (aka device)
1678 * assign the starting bdl address to each stream (device)
1681 for (i = 0; i < chip->num_streams; i++) {
1682 struct azx_dev *azx_dev = &chip->azx_dev[i];
1683 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
1684 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
1685 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
1686 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
1687 azx_dev->sd_int_sta_mask = 1 << i;
1688 /* stream tag: must be non-zero and unique */
1690 azx_dev->stream_tag = i + 1;
1696 static int azx_acquire_irq(struct azx *chip, int do_disconnect)
1698 if (request_irq(chip->pci->irq, azx_interrupt,
1699 chip->msi ? 0 : IRQF_SHARED,
1700 "HDA Intel", chip)) {
1701 printk(KERN_ERR "hda-intel: unable to grab IRQ %d, "
1702 "disabling device\n", chip->pci->irq);
1704 snd_card_disconnect(chip->card);
1707 chip->irq = chip->pci->irq;
1708 pci_intx(chip->pci, !chip->msi);
1713 static void azx_stop_chip(struct azx *chip)
1715 if (!chip->initialized)
1718 /* disable interrupts */
1719 azx_int_disable(chip);
1720 azx_int_clear(chip);
1722 /* disable CORB/RIRB */
1723 azx_free_cmd_io(chip);
1725 /* disable position buffer */
1726 azx_writel(chip, DPLBASE, 0);
1727 azx_writel(chip, DPUBASE, 0);
1729 chip->initialized = 0;
1732 #ifdef CONFIG_SND_HDA_POWER_SAVE
1733 /* power-up/down the controller */
1734 static void azx_power_notify(struct hda_codec *codec)
1736 struct azx *chip = codec->bus->private_data;
1737 struct hda_codec *c;
1740 list_for_each_entry(c, &codec->bus->codec_list, list) {
1747 azx_init_chip(chip);
1748 else if (chip->running && power_save_controller)
1749 azx_stop_chip(chip);
1751 #endif /* CONFIG_SND_HDA_POWER_SAVE */
1757 static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1759 struct snd_card *card = pci_get_drvdata(pci);
1760 struct azx *chip = card->private_data;
1763 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1764 azx_clear_irq_pending(chip);
1765 for (i = 0; i < AZX_MAX_PCMS; i++)
1766 snd_pcm_suspend_all(chip->pcm[i]);
1767 if (chip->initialized)
1768 snd_hda_suspend(chip->bus, state);
1769 azx_stop_chip(chip);
1770 if (chip->irq >= 0) {
1771 free_irq(chip->irq, chip);
1775 pci_disable_msi(chip->pci);
1776 pci_disable_device(pci);
1777 pci_save_state(pci);
1778 pci_set_power_state(pci, pci_choose_state(pci, state));
1782 static int azx_resume(struct pci_dev *pci)
1784 struct snd_card *card = pci_get_drvdata(pci);
1785 struct azx *chip = card->private_data;
1787 pci_set_power_state(pci, PCI_D0);
1788 pci_restore_state(pci);
1789 if (pci_enable_device(pci) < 0) {
1790 printk(KERN_ERR "hda-intel: pci_enable_device failed, "
1791 "disabling device\n");
1792 snd_card_disconnect(card);
1795 pci_set_master(pci);
1797 if (pci_enable_msi(pci) < 0)
1799 if (azx_acquire_irq(chip, 1) < 0)
1803 if (snd_hda_codecs_inuse(chip->bus))
1804 azx_init_chip(chip);
1806 snd_hda_resume(chip->bus);
1807 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
1810 #endif /* CONFIG_PM */
1816 static int azx_free(struct azx *chip)
1820 if (chip->initialized) {
1821 azx_clear_irq_pending(chip);
1822 for (i = 0; i < chip->num_streams; i++)
1823 azx_stream_stop(chip, &chip->azx_dev[i]);
1824 azx_stop_chip(chip);
1828 free_irq(chip->irq, (void*)chip);
1830 pci_disable_msi(chip->pci);
1831 if (chip->remap_addr)
1832 iounmap(chip->remap_addr);
1834 if (chip->azx_dev) {
1835 for (i = 0; i < chip->num_streams; i++)
1836 if (chip->azx_dev[i].bdl.area)
1837 snd_dma_free_pages(&chip->azx_dev[i].bdl);
1840 snd_dma_free_pages(&chip->rb);
1841 if (chip->posbuf.area)
1842 snd_dma_free_pages(&chip->posbuf);
1843 pci_release_regions(chip->pci);
1844 pci_disable_device(chip->pci);
1845 kfree(chip->azx_dev);
1851 static int azx_dev_free(struct snd_device *device)
1853 return azx_free(device->device_data);
1857 * white/black-listing for position_fix
1859 static struct snd_pci_quirk position_fix_list[] __devinitdata = {
1860 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_NONE),
1861 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_NONE),
1862 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_NONE),
1866 static int __devinit check_position_fix(struct azx *chip, int fix)
1868 const struct snd_pci_quirk *q;
1870 if (fix == POS_FIX_AUTO) {
1871 q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
1874 "hda_intel: position_fix set to %d "
1875 "for device %04x:%04x\n",
1876 q->value, q->subvendor, q->subdevice);
1884 * black-lists for probe_mask
1886 static struct snd_pci_quirk probe_mask_list[] __devinitdata = {
1887 /* Thinkpad often breaks the controller communication when accessing
1888 * to the non-working (or non-existing) modem codec slot.
1890 SND_PCI_QUIRK(0x1014, 0x05b7, "Thinkpad Z60", 0x01),
1891 SND_PCI_QUIRK(0x17aa, 0x2010, "Thinkpad X/T/R60", 0x01),
1892 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X/T/R61", 0x01),
1896 static void __devinit check_probe_mask(struct azx *chip, int dev)
1898 const struct snd_pci_quirk *q;
1900 if (probe_mask[dev] == -1) {
1901 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
1904 "hda_intel: probe_mask set to 0x%x "
1905 "for device %04x:%04x\n",
1906 q->value, q->subvendor, q->subdevice);
1907 probe_mask[dev] = q->value;
1916 static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
1917 int dev, int driver_type,
1922 unsigned short gcap;
1923 static struct snd_device_ops ops = {
1924 .dev_free = azx_dev_free,
1929 err = pci_enable_device(pci);
1933 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1935 snd_printk(KERN_ERR SFX "cannot allocate chip\n");
1936 pci_disable_device(pci);
1940 spin_lock_init(&chip->reg_lock);
1941 mutex_init(&chip->open_mutex);
1945 chip->driver_type = driver_type;
1946 chip->msi = enable_msi;
1947 INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work);
1949 chip->position_fix = check_position_fix(chip, position_fix[dev]);
1950 check_probe_mask(chip, dev);
1952 chip->single_cmd = single_cmd;
1954 #if BITS_PER_LONG != 64
1955 /* Fix up base address on ULI M5461 */
1956 if (chip->driver_type == AZX_DRIVER_ULI) {
1958 pci_read_config_word(pci, 0x40, &tmp3);
1959 pci_write_config_word(pci, 0x40, tmp3 | 0x10);
1960 pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0);
1964 err = pci_request_regions(pci, "ICH HD audio");
1967 pci_disable_device(pci);
1971 chip->addr = pci_resource_start(pci, 0);
1972 chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci,0));
1973 if (chip->remap_addr == NULL) {
1974 snd_printk(KERN_ERR SFX "ioremap error\n");
1980 if (pci_enable_msi(pci) < 0)
1983 if (azx_acquire_irq(chip, 0) < 0) {
1988 pci_set_master(pci);
1989 synchronize_irq(chip->irq);
1991 gcap = azx_readw(chip, GCAP);
1992 snd_printdd("chipset global capabilities = 0x%x\n", gcap);
1994 /* allow 64bit DMA address if supported by H/W */
1995 if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_64BIT_MASK))
1996 pci_set_consistent_dma_mask(pci, DMA_64BIT_MASK);
1998 /* read number of streams from GCAP register instead of using
2001 chip->capture_streams = (gcap >> 8) & 0x0f;
2002 chip->playback_streams = (gcap >> 12) & 0x0f;
2003 if (!chip->playback_streams && !chip->capture_streams) {
2004 /* gcap didn't give any info, switching to old method */
2006 switch (chip->driver_type) {
2007 case AZX_DRIVER_ULI:
2008 chip->playback_streams = ULI_NUM_PLAYBACK;
2009 chip->capture_streams = ULI_NUM_CAPTURE;
2011 case AZX_DRIVER_ATIHDMI:
2012 chip->playback_streams = ATIHDMI_NUM_PLAYBACK;
2013 chip->capture_streams = ATIHDMI_NUM_CAPTURE;
2016 chip->playback_streams = ICH6_NUM_PLAYBACK;
2017 chip->capture_streams = ICH6_NUM_CAPTURE;
2021 chip->capture_index_offset = 0;
2022 chip->playback_index_offset = chip->capture_streams;
2023 chip->num_streams = chip->playback_streams + chip->capture_streams;
2024 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
2026 if (!chip->azx_dev) {
2027 snd_printk(KERN_ERR "cannot malloc azx_dev\n");
2031 for (i = 0; i < chip->num_streams; i++) {
2032 /* allocate memory for the BDL for each stream */
2033 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
2034 snd_dma_pci_data(chip->pci),
2035 BDL_SIZE, &chip->azx_dev[i].bdl);
2037 snd_printk(KERN_ERR SFX "cannot allocate BDL\n");
2041 /* allocate memory for the position buffer */
2042 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
2043 snd_dma_pci_data(chip->pci),
2044 chip->num_streams * 8, &chip->posbuf);
2046 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n");
2049 /* allocate CORB/RIRB */
2050 if (!chip->single_cmd) {
2051 err = azx_alloc_cmd_io(chip);
2056 /* initialize streams */
2057 azx_init_stream(chip);
2059 /* initialize chip */
2061 azx_init_chip(chip);
2063 /* codec detection */
2064 if (!chip->codec_mask) {
2065 snd_printk(KERN_ERR SFX "no codecs found!\n");
2070 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
2072 snd_printk(KERN_ERR SFX "Error creating device [card]!\n");
2076 strcpy(card->driver, "HDA-Intel");
2077 strcpy(card->shortname, driver_short_names[chip->driver_type]);
2078 sprintf(card->longname, "%s at 0x%lx irq %i",
2079 card->shortname, chip->addr, chip->irq);
2089 static void power_down_all_codecs(struct azx *chip)
2091 #ifdef CONFIG_SND_HDA_POWER_SAVE
2092 /* The codecs were powered up in snd_hda_codec_new().
2093 * Now all initialization done, so turn them down if possible
2095 struct hda_codec *codec;
2096 list_for_each_entry(codec, &chip->bus->codec_list, list) {
2097 snd_hda_power_down(codec);
2102 static int __devinit azx_probe(struct pci_dev *pci,
2103 const struct pci_device_id *pci_id)
2106 struct snd_card *card;
2110 if (dev >= SNDRV_CARDS)
2117 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
2119 snd_printk(KERN_ERR SFX "Error creating card!\n");
2123 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
2125 snd_card_free(card);
2128 card->private_data = chip;
2130 /* create codec instances */
2131 err = azx_codec_create(chip, model[dev], probe_mask[dev]);
2133 snd_card_free(card);
2137 /* create PCM streams */
2138 err = azx_pcm_create(chip);
2140 snd_card_free(card);
2144 /* create mixer controls */
2145 err = azx_mixer_create(chip);
2147 snd_card_free(card);
2151 snd_card_set_dev(card, &pci->dev);
2153 err = snd_card_register(card);
2155 snd_card_free(card);
2159 pci_set_drvdata(pci, card);
2161 power_down_all_codecs(chip);
2167 static void __devexit azx_remove(struct pci_dev *pci)
2169 snd_card_free(pci_get_drvdata(pci));
2170 pci_set_drvdata(pci, NULL);
2174 static struct pci_device_id azx_ids[] = {
2176 { PCI_DEVICE(0x8086, 0x2668), .driver_data = AZX_DRIVER_ICH },
2177 { PCI_DEVICE(0x8086, 0x27d8), .driver_data = AZX_DRIVER_ICH },
2178 { PCI_DEVICE(0x8086, 0x269a), .driver_data = AZX_DRIVER_ICH },
2179 { PCI_DEVICE(0x8086, 0x284b), .driver_data = AZX_DRIVER_ICH },
2180 { PCI_DEVICE(0x8086, 0x293e), .driver_data = AZX_DRIVER_ICH },
2181 { PCI_DEVICE(0x8086, 0x293f), .driver_data = AZX_DRIVER_ICH },
2182 { PCI_DEVICE(0x8086, 0x3a3e), .driver_data = AZX_DRIVER_ICH },
2183 { PCI_DEVICE(0x8086, 0x3a6e), .driver_data = AZX_DRIVER_ICH },
2185 { PCI_DEVICE(0x8086, 0x811b), .driver_data = AZX_DRIVER_SCH },
2186 /* ATI SB 450/600 */
2187 { PCI_DEVICE(0x1002, 0x437b), .driver_data = AZX_DRIVER_ATI },
2188 { PCI_DEVICE(0x1002, 0x4383), .driver_data = AZX_DRIVER_ATI },
2190 { PCI_DEVICE(0x1002, 0x793b), .driver_data = AZX_DRIVER_ATIHDMI },
2191 { PCI_DEVICE(0x1002, 0x7919), .driver_data = AZX_DRIVER_ATIHDMI },
2192 { PCI_DEVICE(0x1002, 0x960f), .driver_data = AZX_DRIVER_ATIHDMI },
2193 { PCI_DEVICE(0x1002, 0xaa00), .driver_data = AZX_DRIVER_ATIHDMI },
2194 { PCI_DEVICE(0x1002, 0xaa08), .driver_data = AZX_DRIVER_ATIHDMI },
2195 { PCI_DEVICE(0x1002, 0xaa10), .driver_data = AZX_DRIVER_ATIHDMI },
2196 { PCI_DEVICE(0x1002, 0xaa18), .driver_data = AZX_DRIVER_ATIHDMI },
2197 { PCI_DEVICE(0x1002, 0xaa20), .driver_data = AZX_DRIVER_ATIHDMI },
2198 { PCI_DEVICE(0x1002, 0xaa28), .driver_data = AZX_DRIVER_ATIHDMI },
2199 { PCI_DEVICE(0x1002, 0xaa30), .driver_data = AZX_DRIVER_ATIHDMI },
2200 { PCI_DEVICE(0x1002, 0xaa38), .driver_data = AZX_DRIVER_ATIHDMI },
2201 { PCI_DEVICE(0x1002, 0xaa40), .driver_data = AZX_DRIVER_ATIHDMI },
2202 { PCI_DEVICE(0x1002, 0xaa48), .driver_data = AZX_DRIVER_ATIHDMI },
2203 /* VIA VT8251/VT8237A */
2204 { PCI_DEVICE(0x1106, 0x3288), .driver_data = AZX_DRIVER_VIA },
2206 { PCI_DEVICE(0x1039, 0x7502), .driver_data = AZX_DRIVER_SIS },
2208 { PCI_DEVICE(0x10b9, 0x5461), .driver_data = AZX_DRIVER_ULI },
2210 { PCI_DEVICE(0x10de, 0x026c), .driver_data = AZX_DRIVER_NVIDIA },
2211 { PCI_DEVICE(0x10de, 0x0371), .driver_data = AZX_DRIVER_NVIDIA },
2212 { PCI_DEVICE(0x10de, 0x03e4), .driver_data = AZX_DRIVER_NVIDIA },
2213 { PCI_DEVICE(0x10de, 0x03f0), .driver_data = AZX_DRIVER_NVIDIA },
2214 { PCI_DEVICE(0x10de, 0x044a), .driver_data = AZX_DRIVER_NVIDIA },
2215 { PCI_DEVICE(0x10de, 0x044b), .driver_data = AZX_DRIVER_NVIDIA },
2216 { PCI_DEVICE(0x10de, 0x055c), .driver_data = AZX_DRIVER_NVIDIA },
2217 { PCI_DEVICE(0x10de, 0x055d), .driver_data = AZX_DRIVER_NVIDIA },
2218 { PCI_DEVICE(0x10de, 0x0774), .driver_data = AZX_DRIVER_NVIDIA },
2219 { PCI_DEVICE(0x10de, 0x0775), .driver_data = AZX_DRIVER_NVIDIA },
2220 { PCI_DEVICE(0x10de, 0x0776), .driver_data = AZX_DRIVER_NVIDIA },
2221 { PCI_DEVICE(0x10de, 0x0777), .driver_data = AZX_DRIVER_NVIDIA },
2222 { PCI_DEVICE(0x10de, 0x07fc), .driver_data = AZX_DRIVER_NVIDIA },
2223 { PCI_DEVICE(0x10de, 0x07fd), .driver_data = AZX_DRIVER_NVIDIA },
2224 { PCI_DEVICE(0x10de, 0x0ac0), .driver_data = AZX_DRIVER_NVIDIA },
2225 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
2226 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
2227 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
2228 { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA },
2229 { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA },
2230 { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA },
2231 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA },
2234 MODULE_DEVICE_TABLE(pci, azx_ids);
2236 /* pci_driver definition */
2237 static struct pci_driver driver = {
2238 .name = "HDA Intel",
2239 .id_table = azx_ids,
2241 .remove = __devexit_p(azx_remove),
2243 .suspend = azx_suspend,
2244 .resume = azx_resume,
2248 static int __init alsa_card_azx_init(void)
2250 return pci_register_driver(&driver);
2253 static void __exit alsa_card_azx_exit(void)
2255 pci_unregister_driver(&driver);
2258 module_init(alsa_card_azx_init)
2259 module_exit(alsa_card_azx_exit)