aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_intel.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/hda_intel.c')
-rw-r--r--sound/pci/hda/hda_intel.c198
1 files changed, 134 insertions, 64 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 21e99cfa8c49..4e9ea7080270 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -128,21 +128,33 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
128 "{ULI, M5461}}"); 128 "{ULI, M5461}}");
129MODULE_DESCRIPTION("Intel HDA driver"); 129MODULE_DESCRIPTION("Intel HDA driver");
130 130
131#ifdef CONFIG_SND_VERBOSE_PRINTK
132#define SFX /* nop */
133#else
131#define SFX "hda-intel: " 134#define SFX "hda-intel: "
132 135#endif
133 136
134/* 137/*
135 * registers 138 * registers
136 */ 139 */
137#define ICH6_REG_GCAP 0x00 140#define ICH6_REG_GCAP 0x00
141#define ICH6_GCAP_64OK (1 << 0) /* 64bit address support */
142#define ICH6_GCAP_NSDO (3 << 1) /* # of serial data out signals */
143#define ICH6_GCAP_BSS (31 << 3) /* # of bidirectional streams */
144#define ICH6_GCAP_ISS (15 << 8) /* # of input streams */
145#define ICH6_GCAP_OSS (15 << 12) /* # of output streams */
138#define ICH6_REG_VMIN 0x02 146#define ICH6_REG_VMIN 0x02
139#define ICH6_REG_VMAJ 0x03 147#define ICH6_REG_VMAJ 0x03
140#define ICH6_REG_OUTPAY 0x04 148#define ICH6_REG_OUTPAY 0x04
141#define ICH6_REG_INPAY 0x06 149#define ICH6_REG_INPAY 0x06
142#define ICH6_REG_GCTL 0x08 150#define ICH6_REG_GCTL 0x08
151#define ICH6_GCTL_RESET (1 << 0) /* controller reset */
152#define ICH6_GCTL_FCNTRL (1 << 1) /* flush control */
153#define ICH6_GCTL_UNSOL (1 << 8) /* accept unsol. response enable */
143#define ICH6_REG_WAKEEN 0x0c 154#define ICH6_REG_WAKEEN 0x0c
144#define ICH6_REG_STATESTS 0x0e 155#define ICH6_REG_STATESTS 0x0e
145#define ICH6_REG_GSTS 0x10 156#define ICH6_REG_GSTS 0x10
157#define ICH6_GSTS_FSTS (1 << 1) /* flush status */
146#define ICH6_REG_INTCTL 0x20 158#define ICH6_REG_INTCTL 0x20
147#define ICH6_REG_INTSTS 0x24 159#define ICH6_REG_INTSTS 0x24
148#define ICH6_REG_WALCLK 0x30 160#define ICH6_REG_WALCLK 0x30
@@ -150,17 +162,27 @@ MODULE_DESCRIPTION("Intel HDA driver");
150#define ICH6_REG_CORBLBASE 0x40 162#define ICH6_REG_CORBLBASE 0x40
151#define ICH6_REG_CORBUBASE 0x44 163#define ICH6_REG_CORBUBASE 0x44
152#define ICH6_REG_CORBWP 0x48 164#define ICH6_REG_CORBWP 0x48
153#define ICH6_REG_CORBRP 0x4A 165#define ICH6_REG_CORBRP 0x4a
166#define ICH6_CORBRP_RST (1 << 15) /* read pointer reset */
154#define ICH6_REG_CORBCTL 0x4c 167#define ICH6_REG_CORBCTL 0x4c
168#define ICH6_CORBCTL_RUN (1 << 1) /* enable DMA */
169#define ICH6_CORBCTL_CMEIE (1 << 0) /* enable memory error irq */
155#define ICH6_REG_CORBSTS 0x4d 170#define ICH6_REG_CORBSTS 0x4d
171#define ICH6_CORBSTS_CMEI (1 << 0) /* memory error indication */
156#define ICH6_REG_CORBSIZE 0x4e 172#define ICH6_REG_CORBSIZE 0x4e
157 173
158#define ICH6_REG_RIRBLBASE 0x50 174#define ICH6_REG_RIRBLBASE 0x50
159#define ICH6_REG_RIRBUBASE 0x54 175#define ICH6_REG_RIRBUBASE 0x54
160#define ICH6_REG_RIRBWP 0x58 176#define ICH6_REG_RIRBWP 0x58
177#define ICH6_RIRBWP_RST (1 << 15) /* write pointer reset */
161#define ICH6_REG_RINTCNT 0x5a 178#define ICH6_REG_RINTCNT 0x5a
162#define ICH6_REG_RIRBCTL 0x5c 179#define ICH6_REG_RIRBCTL 0x5c
180#define ICH6_RBCTL_IRQ_EN (1 << 0) /* enable IRQ */
181#define ICH6_RBCTL_DMA_EN (1 << 1) /* enable DMA */
182#define ICH6_RBCTL_OVERRUN_EN (1 << 2) /* enable overrun irq */
163#define ICH6_REG_RIRBSTS 0x5d 183#define ICH6_REG_RIRBSTS 0x5d
184#define ICH6_RBSTS_IRQ (1 << 0) /* response irq */
185#define ICH6_RBSTS_OVERRUN (1 << 2) /* overrun irq */
164#define ICH6_REG_RIRBSIZE 0x5e 186#define ICH6_REG_RIRBSIZE 0x5e
165 187
166#define ICH6_REG_IC 0x60 188#define ICH6_REG_IC 0x60
@@ -257,16 +279,6 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
257#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ 279#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */
258#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ 280#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */
259 281
260/* GCTL unsolicited response enable bit */
261#define ICH6_GCTL_UREN (1<<8)
262
263/* GCTL reset bit */
264#define ICH6_GCTL_RESET (1<<0)
265
266/* CORB/RIRB control, read/write pointer */
267#define ICH6_RBCTL_DMA_EN 0x02 /* enable DMA */
268#define ICH6_RBCTL_IRQ_EN 0x01 /* enable IRQ */
269#define ICH6_RBRWP_CLR 0x8000 /* read/write pointer clear */
270/* below are so far hardcoded - should read registers in future */ 282/* below are so far hardcoded - should read registers in future */
271#define ICH6_MAX_CORB_ENTRIES 256 283#define ICH6_MAX_CORB_ENTRIES 256
272#define ICH6_MAX_RIRB_ENTRIES 256 284#define ICH6_MAX_RIRB_ENTRIES 256
@@ -512,25 +524,25 @@ static void azx_init_cmd_io(struct azx *chip)
512 /* set the corb write pointer to 0 */ 524 /* set the corb write pointer to 0 */
513 azx_writew(chip, CORBWP, 0); 525 azx_writew(chip, CORBWP, 0);
514 /* reset the corb hw read pointer */ 526 /* reset the corb hw read pointer */
515 azx_writew(chip, CORBRP, ICH6_RBRWP_CLR); 527 azx_writew(chip, CORBRP, ICH6_CORBRP_RST);
516 /* enable corb dma */ 528 /* enable corb dma */
517 azx_writeb(chip, CORBCTL, ICH6_RBCTL_DMA_EN); 529 azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN);
518 530
519 /* RIRB set up */ 531 /* RIRB set up */
520 chip->rirb.addr = chip->rb.addr + 2048; 532 chip->rirb.addr = chip->rb.addr + 2048;
521 chip->rirb.buf = (u32 *)(chip->rb.area + 2048); 533 chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
534 chip->rirb.wp = chip->rirb.rp = chip->rirb.cmds = 0;
522 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); 535 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
523 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); 536 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr));
524 537
525 /* set the rirb size to 256 entries (ULI requires explicitly) */ 538 /* set the rirb size to 256 entries (ULI requires explicitly) */
526 azx_writeb(chip, RIRBSIZE, 0x02); 539 azx_writeb(chip, RIRBSIZE, 0x02);
527 /* reset the rirb hw write pointer */ 540 /* reset the rirb hw write pointer */
528 azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR); 541 azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST);
529 /* set N=1, get RIRB response interrupt for new entry */ 542 /* set N=1, get RIRB response interrupt for new entry */
530 azx_writew(chip, RINTCNT, 1); 543 azx_writew(chip, RINTCNT, 1);
531 /* enable rirb dma and response irq */ 544 /* enable rirb dma and response irq */
532 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); 545 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN);
533 chip->rirb.rp = chip->rirb.cmds = 0;
534} 546}
535 547
536static void azx_free_cmd_io(struct azx *chip) 548static void azx_free_cmd_io(struct azx *chip)
@@ -606,6 +618,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
606 } 618 }
607 if (!chip->rirb.cmds) { 619 if (!chip->rirb.cmds) {
608 smp_rmb(); 620 smp_rmb();
621 bus->rirb_error = 0;
609 return chip->rirb.res; /* the last value */ 622 return chip->rirb.res; /* the last value */
610 } 623 }
611 if (time_after(jiffies, timeout)) 624 if (time_after(jiffies, timeout))
@@ -619,19 +632,21 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
619 } 632 }
620 633
621 if (chip->msi) { 634 if (chip->msi) {
622 snd_printk(KERN_WARNING "hda_intel: No response from codec, " 635 snd_printk(KERN_WARNING SFX "No response from codec, "
623 "disabling MSI: last cmd=0x%08x\n", chip->last_cmd); 636 "disabling MSI: last cmd=0x%08x\n", chip->last_cmd);
624 free_irq(chip->irq, chip); 637 free_irq(chip->irq, chip);
625 chip->irq = -1; 638 chip->irq = -1;
626 pci_disable_msi(chip->pci); 639 pci_disable_msi(chip->pci);
627 chip->msi = 0; 640 chip->msi = 0;
628 if (azx_acquire_irq(chip, 1) < 0) 641 if (azx_acquire_irq(chip, 1) < 0) {
642 bus->rirb_error = 1;
629 return -1; 643 return -1;
644 }
630 goto again; 645 goto again;
631 } 646 }
632 647
633 if (!chip->polling_mode) { 648 if (!chip->polling_mode) {
634 snd_printk(KERN_WARNING "hda_intel: azx_get_response timeout, " 649 snd_printk(KERN_WARNING SFX "azx_get_response timeout, "
635 "switching to polling mode: last cmd=0x%08x\n", 650 "switching to polling mode: last cmd=0x%08x\n",
636 chip->last_cmd); 651 chip->last_cmd);
637 chip->polling_mode = 1; 652 chip->polling_mode = 1;
@@ -646,14 +661,23 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
646 return -1; 661 return -1;
647 } 662 }
648 663
664 /* a fatal communication error; need either to reset or to fallback
665 * to the single_cmd mode
666 */
667 bus->rirb_error = 1;
668 if (bus->allow_bus_reset && !bus->response_reset && !bus->in_reset) {
669 bus->response_reset = 1;
670 return -1; /* give a chance to retry */
671 }
672
649 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " 673 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
650 "switching to single_cmd mode: last cmd=0x%08x\n", 674 "switching to single_cmd mode: last cmd=0x%08x\n",
651 chip->last_cmd); 675 chip->last_cmd);
652 chip->rirb.rp = azx_readb(chip, RIRBWP);
653 chip->rirb.cmds = 0;
654 /* switch to single_cmd mode */
655 chip->single_cmd = 1; 676 chip->single_cmd = 1;
677 bus->response_reset = 0;
678 /* re-initialize CORB/RIRB */
656 azx_free_cmd_io(chip); 679 azx_free_cmd_io(chip);
680 azx_init_cmd_io(chip);
657 return -1; 681 return -1;
658} 682}
659 683
@@ -667,12 +691,34 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
667 * I left the codes, however, for debugging/testing purposes. 691 * I left the codes, however, for debugging/testing purposes.
668 */ 692 */
669 693
694/* receive a response */
695static int azx_single_wait_for_response(struct azx *chip)
696{
697 int timeout = 50;
698
699 while (timeout--) {
700 /* check IRV busy bit */
701 if (azx_readw(chip, IRS) & ICH6_IRS_VALID) {
702 /* reuse rirb.res as the response return value */
703 chip->rirb.res = azx_readl(chip, IR);
704 return 0;
705 }
706 udelay(1);
707 }
708 if (printk_ratelimit())
709 snd_printd(SFX "get_response timeout: IRS=0x%x\n",
710 azx_readw(chip, IRS));
711 chip->rirb.res = -1;
712 return -EIO;
713}
714
670/* send a command */ 715/* send a command */
671static int azx_single_send_cmd(struct hda_bus *bus, u32 val) 716static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
672{ 717{
673 struct azx *chip = bus->private_data; 718 struct azx *chip = bus->private_data;
674 int timeout = 50; 719 int timeout = 50;
675 720
721 bus->rirb_error = 0;
676 while (timeout--) { 722 while (timeout--) {
677 /* check ICB busy bit */ 723 /* check ICB busy bit */
678 if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) { 724 if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) {
@@ -682,7 +728,7 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
682 azx_writel(chip, IC, val); 728 azx_writel(chip, IC, val);
683 azx_writew(chip, IRS, azx_readw(chip, IRS) | 729 azx_writew(chip, IRS, azx_readw(chip, IRS) |
684 ICH6_IRS_BUSY); 730 ICH6_IRS_BUSY);
685 return 0; 731 return azx_single_wait_for_response(chip);
686 } 732 }
687 udelay(1); 733 udelay(1);
688 } 734 }
@@ -696,18 +742,7 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
696static unsigned int azx_single_get_response(struct hda_bus *bus) 742static unsigned int azx_single_get_response(struct hda_bus *bus)
697{ 743{
698 struct azx *chip = bus->private_data; 744 struct azx *chip = bus->private_data;
699 int timeout = 50; 745 return chip->rirb.res;
700
701 while (timeout--) {
702 /* check IRV busy bit */
703 if (azx_readw(chip, IRS) & ICH6_IRS_VALID)
704 return azx_readl(chip, IR);
705 udelay(1);
706 }
707 if (printk_ratelimit())
708 snd_printd(SFX "get_response timeout: IRS=0x%x\n",
709 azx_readw(chip, IRS));
710 return (unsigned int)-1;
711} 746}
712 747
713/* 748/*
@@ -775,17 +810,17 @@ static int azx_reset(struct azx *chip)
775 810
776 /* check to see if controller is ready */ 811 /* check to see if controller is ready */
777 if (!azx_readb(chip, GCTL)) { 812 if (!azx_readb(chip, GCTL)) {
778 snd_printd("azx_reset: controller not ready!\n"); 813 snd_printd(SFX "azx_reset: controller not ready!\n");
779 return -EBUSY; 814 return -EBUSY;
780 } 815 }
781 816
782 /* Accept unsolicited responses */ 817 /* Accept unsolicited responses */
783 azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UREN); 818 azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UNSOL);
784 819
785 /* detect codecs */ 820 /* detect codecs */
786 if (!chip->codec_mask) { 821 if (!chip->codec_mask) {
787 chip->codec_mask = azx_readw(chip, STATESTS); 822 chip->codec_mask = azx_readw(chip, STATESTS);
788 snd_printdd("codec_mask = 0x%x\n", chip->codec_mask); 823 snd_printdd(SFX "codec_mask = 0x%x\n", chip->codec_mask);
789 } 824 }
790 825
791 return 0; 826 return 0;
@@ -895,8 +930,7 @@ static void azx_init_chip(struct azx *chip)
895 azx_int_enable(chip); 930 azx_int_enable(chip);
896 931
897 /* initialize the codec command I/O */ 932 /* initialize the codec command I/O */
898 if (!chip->single_cmd) 933 azx_init_cmd_io(chip);
899 azx_init_cmd_io(chip);
900 934
901 /* program the position buffer */ 935 /* program the position buffer */
902 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); 936 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
@@ -953,12 +987,12 @@ static void azx_init_pci(struct azx *chip)
953 case AZX_DRIVER_SCH: 987 case AZX_DRIVER_SCH:
954 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop); 988 pci_read_config_word(chip->pci, INTEL_SCH_HDA_DEVC, &snoop);
955 if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) { 989 if (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) {
956 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC, \ 990 pci_write_config_word(chip->pci, INTEL_SCH_HDA_DEVC,
957 snoop & (~INTEL_SCH_HDA_DEVC_NOSNOOP)); 991 snoop & (~INTEL_SCH_HDA_DEVC_NOSNOOP));
958 pci_read_config_word(chip->pci, 992 pci_read_config_word(chip->pci,
959 INTEL_SCH_HDA_DEVC, &snoop); 993 INTEL_SCH_HDA_DEVC, &snoop);
960 snd_printdd("HDA snoop disabled, enabling ... %s\n",\ 994 snd_printdd(SFX "HDA snoop disabled, enabling ... %s\n",
961 (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) \ 995 (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP)
962 ? "Failed" : "OK"); 996 ? "Failed" : "OK");
963 } 997 }
964 break; 998 break;
@@ -1012,7 +1046,7 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id)
1012 /* clear rirb int */ 1046 /* clear rirb int */
1013 status = azx_readb(chip, RIRBSTS); 1047 status = azx_readb(chip, RIRBSTS);
1014 if (status & RIRB_INT_MASK) { 1048 if (status & RIRB_INT_MASK) {
1015 if (!chip->single_cmd && (status & RIRB_INT_RESPONSE)) 1049 if (status & RIRB_INT_RESPONSE)
1016 azx_update_rirb(chip); 1050 azx_update_rirb(chip);
1017 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); 1051 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
1018 } 1052 }
@@ -1098,7 +1132,7 @@ static int azx_setup_periods(struct azx *chip,
1098 pos_align; 1132 pos_align;
1099 pos_adj = frames_to_bytes(runtime, pos_adj); 1133 pos_adj = frames_to_bytes(runtime, pos_adj);
1100 if (pos_adj >= period_bytes) { 1134 if (pos_adj >= period_bytes) {
1101 snd_printk(KERN_WARNING "Too big adjustment %d\n", 1135 snd_printk(KERN_WARNING SFX "Too big adjustment %d\n",
1102 bdl_pos_adj[chip->dev_index]); 1136 bdl_pos_adj[chip->dev_index]);
1103 pos_adj = 0; 1137 pos_adj = 0;
1104 } else { 1138 } else {
@@ -1122,7 +1156,7 @@ static int azx_setup_periods(struct azx *chip,
1122 return 0; 1156 return 0;
1123 1157
1124 error: 1158 error:
1125 snd_printk(KERN_ERR "Too many BDL entries: buffer=%d, period=%d\n", 1159 snd_printk(KERN_ERR SFX "Too many BDL entries: buffer=%d, period=%d\n",
1126 azx_dev->bufsize, period_bytes); 1160 azx_dev->bufsize, period_bytes);
1127 return -EINVAL; 1161 return -EINVAL;
1128} 1162}
@@ -1215,7 +1249,7 @@ static int probe_codec(struct azx *chip, int addr)
1215 chip->probing = 0; 1249 chip->probing = 0;
1216 if (res == -1) 1250 if (res == -1)
1217 return -EIO; 1251 return -EIO;
1218 snd_printdd("hda_intel: codec #%d probed OK\n", addr); 1252 snd_printdd(SFX "codec #%d probed OK\n", addr);
1219 return 0; 1253 return 0;
1220} 1254}
1221 1255
@@ -1223,6 +1257,26 @@ static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
1223 struct hda_pcm *cpcm); 1257 struct hda_pcm *cpcm);
1224static void azx_stop_chip(struct azx *chip); 1258static void azx_stop_chip(struct azx *chip);
1225 1259
1260static void azx_bus_reset(struct hda_bus *bus)
1261{
1262 struct azx *chip = bus->private_data;
1263
1264 bus->in_reset = 1;
1265 azx_stop_chip(chip);
1266 azx_init_chip(chip);
1267#ifdef CONFIG_PM
1268 if (chip->initialized) {
1269 int i;
1270
1271 for (i = 0; i < AZX_MAX_PCMS; i++)
1272 snd_pcm_suspend_all(chip->pcm[i]);
1273 snd_hda_suspend(chip->bus);
1274 snd_hda_resume(chip->bus);
1275 }
1276#endif
1277 bus->in_reset = 0;
1278}
1279
1226/* 1280/*
1227 * Codec initialization 1281 * Codec initialization
1228 */ 1282 */
@@ -1246,6 +1300,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1246 bus_temp.ops.command = azx_send_cmd; 1300 bus_temp.ops.command = azx_send_cmd;
1247 bus_temp.ops.get_response = azx_get_response; 1301 bus_temp.ops.get_response = azx_get_response;
1248 bus_temp.ops.attach_pcm = azx_attach_pcm_stream; 1302 bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
1303 bus_temp.ops.bus_reset = azx_bus_reset;
1249#ifdef CONFIG_SND_HDA_POWER_SAVE 1304#ifdef CONFIG_SND_HDA_POWER_SAVE
1250 bus_temp.power_save = &power_save; 1305 bus_temp.power_save = &power_save;
1251 bus_temp.ops.pm_notify = azx_power_notify; 1306 bus_temp.ops.pm_notify = azx_power_notify;
@@ -1270,8 +1325,8 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1270 /* Some BIOSen give you wrong codec addresses 1325 /* Some BIOSen give you wrong codec addresses
1271 * that don't exist 1326 * that don't exist
1272 */ 1327 */
1273 snd_printk(KERN_WARNING 1328 snd_printk(KERN_WARNING SFX
1274 "hda_intel: Codec #%d probe error; " 1329 "Codec #%d probe error; "
1275 "disabling it...\n", c); 1330 "disabling it...\n", c);
1276 chip->codec_mask &= ~(1 << c); 1331 chip->codec_mask &= ~(1 << c);
1277 /* More badly, accessing to a non-existing 1332 /* More badly, accessing to a non-existing
@@ -1487,7 +1542,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
1487 bufsize = snd_pcm_lib_buffer_bytes(substream); 1542 bufsize = snd_pcm_lib_buffer_bytes(substream);
1488 period_bytes = snd_pcm_lib_period_bytes(substream); 1543 period_bytes = snd_pcm_lib_period_bytes(substream);
1489 1544
1490 snd_printdd("azx_pcm_prepare: bufsize=0x%x, format=0x%x\n", 1545 snd_printdd(SFX "azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
1491 bufsize, format_val); 1546 bufsize, format_val);
1492 1547
1493 if (bufsize != azx_dev->bufsize || 1548 if (bufsize != azx_dev->bufsize ||
@@ -1830,7 +1885,7 @@ azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
1830 &pcm); 1885 &pcm);
1831 if (err < 0) 1886 if (err < 0)
1832 return err; 1887 return err;
1833 strcpy(pcm->name, cpcm->name); 1888 strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
1834 apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); 1889 apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
1835 if (apcm == NULL) 1890 if (apcm == NULL)
1836 return -ENOMEM; 1891 return -ENOMEM;
@@ -1973,7 +2028,7 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state)
1973 for (i = 0; i < AZX_MAX_PCMS; i++) 2028 for (i = 0; i < AZX_MAX_PCMS; i++)
1974 snd_pcm_suspend_all(chip->pcm[i]); 2029 snd_pcm_suspend_all(chip->pcm[i]);
1975 if (chip->initialized) 2030 if (chip->initialized)
1976 snd_hda_suspend(chip->bus, state); 2031 snd_hda_suspend(chip->bus);
1977 azx_stop_chip(chip); 2032 azx_stop_chip(chip);
1978 if (chip->irq >= 0) { 2033 if (chip->irq >= 0) {
1979 free_irq(chip->irq, chip); 2034 free_irq(chip->irq, chip);
@@ -2141,6 +2196,7 @@ static struct snd_pci_quirk probe_mask_list[] __devinitdata = {
2141 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */ 2196 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */
2142 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01), 2197 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01),
2143 /* forced codec slots */ 2198 /* forced codec slots */
2199 SND_PCI_QUIRK(0x1043, 0x1262, "ASUS W5Fm", 0x103),
2144 SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103), 2200 SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103),
2145 {} 2201 {}
2146}; 2202};
@@ -2264,14 +2320,14 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2264 synchronize_irq(chip->irq); 2320 synchronize_irq(chip->irq);
2265 2321
2266 gcap = azx_readw(chip, GCAP); 2322 gcap = azx_readw(chip, GCAP);
2267 snd_printdd("chipset global capabilities = 0x%x\n", gcap); 2323 snd_printdd(SFX "chipset global capabilities = 0x%x\n", gcap);
2268 2324
2269 /* ATI chips seems buggy about 64bit DMA addresses */ 2325 /* ATI chips seems buggy about 64bit DMA addresses */
2270 if (chip->driver_type == AZX_DRIVER_ATI) 2326 if (chip->driver_type == AZX_DRIVER_ATI)
2271 gcap &= ~0x01; 2327 gcap &= ~ICH6_GCAP_64OK;
2272 2328
2273 /* allow 64bit DMA address if supported by H/W */ 2329 /* allow 64bit DMA address if supported by H/W */
2274 if ((gcap & 0x01) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64))) 2330 if ((gcap & ICH6_GCAP_64OK) && !pci_set_dma_mask(pci, DMA_BIT_MASK(64)))
2275 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64)); 2331 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(64));
2276 else { 2332 else {
2277 pci_set_dma_mask(pci, DMA_BIT_MASK(32)); 2333 pci_set_dma_mask(pci, DMA_BIT_MASK(32));
@@ -2308,7 +2364,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2308 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), 2364 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
2309 GFP_KERNEL); 2365 GFP_KERNEL);
2310 if (!chip->azx_dev) { 2366 if (!chip->azx_dev) {
2311 snd_printk(KERN_ERR "cannot malloc azx_dev\n"); 2367 snd_printk(KERN_ERR SFX "cannot malloc azx_dev\n");
2312 goto errout; 2368 goto errout;
2313 } 2369 }
2314 2370
@@ -2331,11 +2387,9 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2331 goto errout; 2387 goto errout;
2332 } 2388 }
2333 /* allocate CORB/RIRB */ 2389 /* allocate CORB/RIRB */
2334 if (!chip->single_cmd) { 2390 err = azx_alloc_cmd_io(chip);
2335 err = azx_alloc_cmd_io(chip); 2391 if (err < 0)
2336 if (err < 0) 2392 goto errout;
2337 goto errout;
2338 }
2339 2393
2340 /* initialize streams */ 2394 /* initialize streams */
2341 azx_init_stream(chip); 2395 azx_init_stream(chip);
@@ -2358,9 +2412,11 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2358 } 2412 }
2359 2413
2360 strcpy(card->driver, "HDA-Intel"); 2414 strcpy(card->driver, "HDA-Intel");
2361 strcpy(card->shortname, driver_short_names[chip->driver_type]); 2415 strlcpy(card->shortname, driver_short_names[chip->driver_type],
2362 sprintf(card->longname, "%s at 0x%lx irq %i", 2416 sizeof(card->shortname));
2363 card->shortname, chip->addr, chip->irq); 2417 snprintf(card->longname, sizeof(card->longname),
2418 "%s at 0x%lx irq %i",
2419 card->shortname, chip->addr, chip->irq);
2364 2420
2365 *rchip = chip; 2421 *rchip = chip;
2366 return 0; 2422 return 0;
@@ -2513,6 +2569,20 @@ static struct pci_device_id azx_ids[] = {
2513 { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA }, 2569 { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA },
2514 /* Teradici */ 2570 /* Teradici */
2515 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2571 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
2572 /* Creative X-Fi (CA0110-IBG) */
2573#if !defined(CONFIG_SND_CTXFI) && !defined(CONFIG_SND_CTXFI_MODULE)
2574 /* the following entry conflicts with snd-ctxfi driver,
2575 * as ctxfi driver mutates from HD-audio to native mode with
2576 * a special command sequence.
2577 */
2578 { PCI_DEVICE(PCI_VENDOR_ID_CREATIVE, PCI_ANY_ID),
2579 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,
2580 .class_mask = 0xffffff,
2581 .driver_data = AZX_DRIVER_GENERIC },
2582#else
2583 /* this entry seems still valid -- i.e. without emu20kx chip */
2584 { PCI_DEVICE(0x1102, 0x0009), .driver_data = AZX_DRIVER_GENERIC },
2585#endif
2516 /* AMD Generic, PCI class code and Vendor ID for HD Audio */ 2586 /* AMD Generic, PCI class code and Vendor ID for HD Audio */
2517 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID), 2587 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_ANY_ID),
2518 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8, 2588 .class = PCI_CLASS_MULTIMEDIA_HD_AUDIO << 8,