aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-03-31 06:16:31 -0400
committerTakashi Iwai <tiwai@suse.de>2014-03-31 06:16:31 -0400
commit9ddd84f872898373c51469f9c931d5aa89fdc807 (patch)
treed81f9e396801f04d55924c0d3bbd903fe60ebcda /sound/pci
parent749d32237bf39e6576dd95bfdf24e4378e51716c (diff)
parenta4b7f21d7b42b33609df3f86992a8deff80abfaf (diff)
Merge branch 'for-next' into for-linus
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/Kconfig9
-rw-r--r--sound/pci/ac97/ac97_codec.c45
-rw-r--r--sound/pci/ac97/ac97_patch.c3
-rw-r--r--sound/pci/ac97/ac97_pcm.c15
-rw-r--r--sound/pci/ad1889.c37
-rw-r--r--sound/pci/ali5451/ali5451.c152
-rw-r--r--sound/pci/als300.c57
-rw-r--r--sound/pci/als4000.c22
-rw-r--r--sound/pci/asihpi/asihpi.c25
-rw-r--r--sound/pci/atiixp.c33
-rw-r--r--sound/pci/atiixp_modem.c28
-rw-r--r--sound/pci/au88x0/au88x0.c5
-rw-r--r--sound/pci/aw2/aw2-alsa.c46
-rw-r--r--sound/pci/aw2/aw2-saa7146.c6
-rw-r--r--sound/pci/azt3328.c351
-rw-r--r--sound/pci/bt87x.c41
-rw-r--r--sound/pci/ca0106/ca0106_main.c89
-rw-r--r--sound/pci/ca0106/ca_midi.c4
-rw-r--r--sound/pci/cmipci.c41
-rw-r--r--sound/pci/cs4281.c49
-rw-r--r--sound/pci/cs46xx/cs46xx.c3
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c145
-rw-r--r--sound/pci/cs46xx/dsp_spos.c126
-rw-r--r--sound/pci/cs46xx/dsp_spos_scb_lib.c57
-rw-r--r--sound/pci/cs5530.c27
-rw-r--r--sound/pci/cs5535audio/cs5535audio.c31
-rw-r--r--sound/pci/cs5535audio/cs5535audio_olpc.c7
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pcm.c6
-rw-r--r--sound/pci/cs5535audio/cs5535audio_pm.c7
-rw-r--r--sound/pci/ctxfi/ctatc.c2
-rw-r--r--sound/pci/ctxfi/xfi.c3
-rw-r--r--sound/pci/echoaudio/echoaudio.c26
-rw-r--r--sound/pci/echoaudio/echoaudio_dsp.c9
-rw-r--r--sound/pci/echoaudio/midi.c3
-rw-r--r--sound/pci/emu10k1/emu10k1.c9
-rw-r--r--sound/pci/emu10k1/emu10k1_callback.c4
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c74
-rw-r--r--sound/pci/emu10k1/emu10k1_patch.c6
-rw-r--r--sound/pci/emu10k1/emu10k1x.c32
-rw-r--r--sound/pci/emu10k1/emufx.c12
-rw-r--r--sound/pci/emu10k1/emumixer.c6
-rw-r--r--sound/pci/emu10k1/emumpu401.c7
-rw-r--r--sound/pci/emu10k1/emupcm.c22
-rw-r--r--sound/pci/emu10k1/io.c13
-rw-r--r--sound/pci/emu10k1/irq.c21
-rw-r--r--sound/pci/emu10k1/memory.c12
-rw-r--r--sound/pci/emu10k1/p16v.c45
-rw-r--r--sound/pci/emu10k1/voice.c6
-rw-r--r--sound/pci/ens1370.c44
-rw-r--r--sound/pci/es1938.c79
-rw-r--r--sound/pci/es1968.c54
-rw-r--r--sound/pci/fm801.c31
-rw-r--r--sound/pci/hda/Kconfig45
-rw-r--r--sound/pci/hda/Makefile8
-rw-r--r--sound/pci/hda/hda_auto_parser.c65
-rw-r--r--sound/pci/hda/hda_beep.c36
-rw-r--r--sound/pci/hda/hda_beep.h6
-rw-r--r--sound/pci/hda/hda_codec.c238
-rw-r--r--sound/pci/hda/hda_codec.h8
-rw-r--r--sound/pci/hda/hda_controller.c2031
-rw-r--r--sound/pci/hda/hda_controller.h53
-rw-r--r--sound/pci/hda/hda_eld.c17
-rw-r--r--sound/pci/hda/hda_generic.c49
-rw-r--r--sound/pci/hda/hda_generic.h1
-rw-r--r--sound/pci/hda/hda_hwdep.c769
-rw-r--r--sound/pci/hda/hda_i915.c6
-rw-r--r--sound/pci/hda/hda_intel.c2710
-rw-r--r--sound/pci/hda/hda_local.h26
-rw-r--r--sound/pci/hda/hda_priv.h463
-rw-r--r--sound/pci/hda/hda_sysfs.c780
-rw-r--r--sound/pci/hda/patch_analog.c1
-rw-r--r--sound/pci/hda/patch_ca0110.c1
-rw-r--r--sound/pci/hda/patch_ca0132.c209
-rw-r--r--sound/pci/hda/patch_cirrus.c1
-rw-r--r--sound/pci/hda/patch_cmedia.c34
-rw-r--r--sound/pci/hda/patch_conexant.c847
-rw-r--r--sound/pci/hda/patch_hdmi.c109
-rw-r--r--sound/pci/hda/patch_realtek.c442
-rw-r--r--sound/pci/hda/patch_si3054.c5
-rw-r--r--sound/pci/hda/patch_sigmatel.c15
-rw-r--r--sound/pci/hda/patch_via.c8
-rw-r--r--sound/pci/hda/thinkpad_helper.c6
-rw-r--r--sound/pci/ice1712/aureon.c7
-rw-r--r--sound/pci/ice1712/delta.c5
-rw-r--r--sound/pci/ice1712/ews.c12
-rw-r--r--sound/pci/ice1712/ice1712.c38
-rw-r--r--sound/pci/ice1712/ice1724.c50
-rw-r--r--sound/pci/ice1712/juli.c14
-rw-r--r--sound/pci/ice1712/prodigy192.c13
-rw-r--r--sound/pci/ice1712/quartet.c6
-rw-r--r--sound/pci/intel8x0.c90
-rw-r--r--sound/pci/intel8x0m.c50
-rw-r--r--sound/pci/korg1212/korg1212.c5
-rw-r--r--sound/pci/lola/lola.c46
-rw-r--r--sound/pci/lola/lola_clock.c14
-rw-r--r--sound/pci/lola/lola_mixer.c22
-rw-r--r--sound/pci/lola/lola_pcm.c26
-rw-r--r--sound/pci/lx6464es/lx6464es.c162
-rw-r--r--sound/pci/lx6464es/lx_core.c173
-rw-r--r--sound/pci/maestro3.c42
-rw-r--r--sound/pci/mixart/mixart.c123
-rw-r--r--sound/pci/mixart/mixart_core.c49
-rw-r--r--sound/pci/mixart/mixart_hwdep.c65
-rw-r--r--sound/pci/mixart/mixart_mixer.c16
-rw-r--r--sound/pci/nm256/nm256.c79
-rw-r--r--sound/pci/oxygen/oxygen_io.c8
-rw-r--r--sound/pci/oxygen/oxygen_lib.c14
-rw-r--r--sound/pci/oxygen/xonar_hdmi.c2
-rw-r--r--sound/pci/oxygen/xonar_lib.c4
-rw-r--r--sound/pci/pcxhr/pcxhr.c58
-rw-r--r--sound/pci/pcxhr/pcxhr_core.c108
-rw-r--r--sound/pci/pcxhr/pcxhr_hwdep.c31
-rw-r--r--sound/pci/pcxhr/pcxhr_mix22.c23
-rw-r--r--sound/pci/pcxhr/pcxhr_mixer.c13
-rw-r--r--sound/pci/riptide/riptide.c5
-rw-r--r--sound/pci/rme32.c10
-rw-r--r--sound/pci/rme96.c51
-rw-r--r--sound/pci/rme9652/hdsp.c133
-rw-r--r--sound/pci/rme9652/hdspm.c131
-rw-r--r--sound/pci/rme9652/rme9652.c24
-rw-r--r--sound/pci/sis7019.c5
-rw-r--r--sound/pci/sonicvibes.c240
-rw-r--r--sound/pci/trident/trident.c3
-rw-r--r--sound/pci/trident/trident_main.c90
-rw-r--r--sound/pci/via82xx.c73
-rw-r--r--sound/pci/via82xx_modem.c49
-rw-r--r--sound/pci/vx222/vx222.c12
-rw-r--r--sound/pci/vx222/vx222_ops.c19
-rw-r--r--sound/pci/ymfpci/ymfpci.c25
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c28
130 files changed, 7072 insertions, 6170 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 8756c8e32922..0b0c0cf13f74 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -276,7 +276,7 @@ config SND_CS46XX_NEW_DSP
276 276
277config SND_CS5530 277config SND_CS5530
278 tristate "CS5530 Audio" 278 tristate "CS5530 Audio"
279 depends on ISA_DMA_API 279 depends on ISA_DMA_API && (X86_32 || COMPILE_TEST)
280 select SND_SB16_DSP 280 select SND_SB16_DSP
281 help 281 help
282 Say Y here to include support for audio on Cyrix/NatSemi CS5530 chips. 282 Say Y here to include support for audio on Cyrix/NatSemi CS5530 chips.
@@ -286,6 +286,7 @@ config SND_CS5530
286 286
287config SND_CS5535AUDIO 287config SND_CS5535AUDIO
288 tristate "CS5535/CS5536 Audio" 288 tristate "CS5535/CS5536 Audio"
289 depends on X86_32 || MIPS || COMPILE_TEST
289 select SND_PCM 290 select SND_PCM
290 select SND_AC97_CODEC 291 select SND_AC97_CODEC
291 help 292 help
@@ -578,8 +579,6 @@ config SND_FM801_TEA575X_BOOL
578 FM801 chip with a TEA5757 tuner (MediaForte SF256-PCS, SF256-PCP and 579 FM801 chip with a TEA5757 tuner (MediaForte SF256-PCS, SF256-PCP and
579 SF64-PCR) into the snd-fm801 driver. 580 SF64-PCR) into the snd-fm801 driver.
580 581
581source "sound/pci/hda/Kconfig"
582
583config SND_HDSP 582config SND_HDSP
584 tristate "RME Hammerfall DSP Audio" 583 tristate "RME Hammerfall DSP Audio"
585 select FW_LOADER 584 select FW_LOADER
@@ -796,7 +795,7 @@ config SND_RME9652
796 795
797config SND_SIS7019 796config SND_SIS7019
798 tristate "SiS 7019 Audio Accelerator" 797 tristate "SiS 7019 Audio Accelerator"
799 depends on X86 && !X86_64 798 depends on X86_32
800 select SND_AC97_CODEC 799 select SND_AC97_CODEC
801 select ZONE_DMA 800 select ZONE_DMA
802 help 801 help
@@ -889,3 +888,5 @@ config SND_YMFPCI
889 will be called snd-ymfpci. 888 will be called snd-ymfpci.
890 889
891endif # SND_PCI 890endif # SND_PCI
891
892source "sound/pci/hda/Kconfig"
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index bf578ba2677e..14ad54b7928c 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -214,6 +214,12 @@ static void update_power_regs(struct snd_ac97 *ac97);
214#define ac97_is_power_save_mode(ac97) 0 214#define ac97_is_power_save_mode(ac97) 0
215#endif 215#endif
216 216
217#define ac97_err(ac97, fmt, args...) \
218 dev_err((ac97)->bus->card->dev, fmt, ##args)
219#define ac97_warn(ac97, fmt, args...) \
220 dev_warn((ac97)->bus->card->dev, fmt, ##args)
221#define ac97_dbg(ac97, fmt, args...) \
222 dev_dbg((ac97)->bus->card->dev, fmt, ##args)
217 223
218/* 224/*
219 * I/O routines 225 * I/O routines
@@ -1673,7 +1679,7 @@ static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97)
1673 int err, idx; 1679 int err, idx;
1674 1680
1675 /* 1681 /*
1676 printk(KERN_DEBUG "AC97_GPIO_CFG = %x\n", 1682 ac97_dbg(ac97, "AC97_GPIO_CFG = %x\n",
1677 snd_ac97_read(ac97,AC97_GPIO_CFG)); 1683 snd_ac97_read(ac97,AC97_GPIO_CFG));
1678 */ 1684 */
1679 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH)); 1685 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH));
@@ -1963,7 +1969,7 @@ static int snd_ac97_dev_register(struct snd_device *device)
1963 ac97->bus->card->number, ac97->num, 1969 ac97->bus->card->number, ac97->num,
1964 snd_ac97_get_short_name(ac97)); 1970 snd_ac97_get_short_name(ac97));
1965 if ((err = device_register(&ac97->dev)) < 0) { 1971 if ((err = device_register(&ac97->dev)) < 0) {
1966 snd_printk(KERN_ERR "Can't register ac97 bus\n"); 1972 ac97_err(ac97, "Can't register ac97 bus\n");
1967 ac97->dev.bus = NULL; 1973 ac97->dev.bus = NULL;
1968 return err; 1974 return err;
1969 } 1975 }
@@ -2089,7 +2095,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
2089 msecs_to_jiffies(500), 1); 2095 msecs_to_jiffies(500), 1);
2090 } 2096 }
2091 if (err < 0) { 2097 if (err < 0) {
2092 snd_printk(KERN_WARNING "AC'97 %d does not respond - RESET\n", ac97->num); 2098 ac97_warn(ac97, "AC'97 %d does not respond - RESET\n",
2099 ac97->num);
2093 /* proceed anyway - it's often non-critical */ 2100 /* proceed anyway - it's often non-critical */
2094 } 2101 }
2095 } 2102 }
@@ -2098,7 +2105,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
2098 ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2); 2105 ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2);
2099 if (! (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) && 2106 if (! (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) &&
2100 (ac97->id == 0x00000000 || ac97->id == 0xffffffff)) { 2107 (ac97->id == 0x00000000 || ac97->id == 0xffffffff)) {
2101 snd_printk(KERN_ERR "AC'97 %d access is not valid [0x%x], removing mixer.\n", ac97->num, ac97->id); 2108 ac97_err(ac97,
2109 "AC'97 %d access is not valid [0x%x], removing mixer.\n",
2110 ac97->num, ac97->id);
2102 snd_ac97_free(ac97); 2111 snd_ac97_free(ac97);
2103 return -EIO; 2112 return -EIO;
2104 } 2113 }
@@ -2131,7 +2140,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
2131 2140
2132 if (!ac97_is_audio(ac97) && !ac97_is_modem(ac97)) { 2141 if (!ac97_is_audio(ac97) && !ac97_is_modem(ac97)) {
2133 if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM))) 2142 if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM)))
2134 snd_printk(KERN_ERR "AC'97 %d access error (not audio or modem codec)\n", ac97->num); 2143 ac97_err(ac97,
2144 "AC'97 %d access error (not audio or modem codec)\n",
2145 ac97->num);
2135 snd_ac97_free(ac97); 2146 snd_ac97_free(ac97);
2136 return -EACCES; 2147 return -EACCES;
2137 } 2148 }
@@ -2156,7 +2167,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
2156 goto __ready_ok; 2167 goto __ready_ok;
2157 schedule_timeout_uninterruptible(1); 2168 schedule_timeout_uninterruptible(1);
2158 } while (time_after_eq(end_time, jiffies)); 2169 } while (time_after_eq(end_time, jiffies));
2159 snd_printk(KERN_WARNING "AC'97 %d analog subsections not ready\n", ac97->num); 2170 ac97_warn(ac97,
2171 "AC'97 %d analog subsections not ready\n", ac97->num);
2160 } 2172 }
2161 2173
2162 /* FIXME: add powerdown control */ 2174 /* FIXME: add powerdown control */
@@ -2188,7 +2200,10 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
2188 goto __ready_ok; 2200 goto __ready_ok;
2189 schedule_timeout_uninterruptible(1); 2201 schedule_timeout_uninterruptible(1);
2190 } while (time_after_eq(end_time, jiffies)); 2202 } while (time_after_eq(end_time, jiffies));
2191 snd_printk(KERN_WARNING "MC'97 %d converters and GPIO not ready (0x%x)\n", ac97->num, snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS)); 2203 ac97_warn(ac97,
2204 "MC'97 %d converters and GPIO not ready (0x%x)\n",
2205 ac97->num,
2206 snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS));
2192 } 2207 }
2193 2208
2194 __ready_ok: 2209 __ready_ok:
@@ -2723,7 +2738,7 @@ static int tune_ad_sharing(struct snd_ac97 *ac97)
2723{ 2738{
2724 unsigned short scfg; 2739 unsigned short scfg;
2725 if ((ac97->id & 0xffffff00) != 0x41445300) { 2740 if ((ac97->id & 0xffffff00) != 0x41445300) {
2726 snd_printk(KERN_ERR "ac97_quirk AD_SHARING is only for AD codecs\n"); 2741 ac97_err(ac97, "ac97_quirk AD_SHARING is only for AD codecs\n");
2727 return -EINVAL; 2742 return -EINVAL;
2728 } 2743 }
2729 /* Turn on OMS bit to route microphone to back panel */ 2744 /* Turn on OMS bit to route microphone to back panel */
@@ -2739,7 +2754,8 @@ AC97_SINGLE("Jack Detect", AC97_ALC650_CLOCK, 5, 1, 0);
2739static int tune_alc_jack(struct snd_ac97 *ac97) 2754static int tune_alc_jack(struct snd_ac97 *ac97)
2740{ 2755{
2741 if ((ac97->id & 0xffffff00) != 0x414c4700) { 2756 if ((ac97->id & 0xffffff00) != 0x414c4700) {
2742 snd_printk(KERN_ERR "ac97_quirk ALC_JACK is only for Realtek codecs\n"); 2757 ac97_err(ac97,
2758 "ac97_quirk ALC_JACK is only for Realtek codecs\n");
2743 return -EINVAL; 2759 return -EINVAL;
2744 } 2760 }
2745 snd_ac97_update_bits(ac97, 0x7a, 0x20, 0x20); /* select jack detect function */ 2761 snd_ac97_update_bits(ac97, 0x7a, 0x20, 0x20); /* select jack detect function */
@@ -2899,7 +2915,8 @@ int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, cons
2899 if (override && strcmp(override, "-1") && strcmp(override, "default")) { 2915 if (override && strcmp(override, "-1") && strcmp(override, "default")) {
2900 result = apply_quirk_str(ac97, override); 2916 result = apply_quirk_str(ac97, override);
2901 if (result < 0) 2917 if (result < 0)
2902 snd_printk(KERN_ERR "applying quirk type %s failed (%d)\n", override, result); 2918 ac97_err(ac97, "applying quirk type %s failed (%d)\n",
2919 override, result);
2903 return result; 2920 return result;
2904 } 2921 }
2905 2922
@@ -2913,10 +2930,14 @@ int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, cons
2913 quirk->subdevice == (quirk->mask & ac97->subsystem_device)) { 2930 quirk->subdevice == (quirk->mask & ac97->subsystem_device)) {
2914 if (quirk->codec_id && quirk->codec_id != ac97->id) 2931 if (quirk->codec_id && quirk->codec_id != ac97->id)
2915 continue; 2932 continue;
2916 snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device); 2933 ac97_dbg(ac97, "ac97 quirk for %s (%04x:%04x)\n",
2934 quirk->name, ac97->subsystem_vendor,
2935 ac97->subsystem_device);
2917 result = apply_quirk(ac97, quirk->type); 2936 result = apply_quirk(ac97, quirk->type);
2918 if (result < 0) 2937 if (result < 0)
2919 snd_printk(KERN_ERR "applying quirk type %d for %s failed (%d)\n", quirk->type, quirk->name, result); 2938 ac97_err(ac97,
2939 "applying quirk type %d for %s failed (%d)\n",
2940 quirk->type, quirk->name, result);
2920 return result; 2941 return result;
2921 } 2942 }
2922 } 2943 }
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 66a3bc95fb84..991762215417 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -3477,7 +3477,8 @@ static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3477 3477
3478 sctl = snd_ac97_find_mixer_ctl(ac97, *s); 3478 sctl = snd_ac97_find_mixer_ctl(ac97, *s);
3479 if (!sctl) { 3479 if (!sctl) {
3480 snd_printdd("Cannot find slave %s, skipped\n", *s); 3480 dev_dbg(ac97->bus->card->dev,
3481 "Cannot find slave %s, skipped\n", *s);
3481 continue; 3482 continue;
3482 } 3483 }
3483 err = snd_ctl_add_slave(kctl, sctl); 3484 err = snd_ctl_add_slave(kctl, sctl);
diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c
index eab0fc9ff2e0..d15297a68801 100644
--- a/sound/pci/ac97/ac97_pcm.c
+++ b/sound/pci/ac97/ac97_pcm.c
@@ -604,7 +604,9 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
604 } 604 }
605 if (!ok_flag) { 605 if (!ok_flag) {
606 spin_unlock_irq(&pcm->bus->bus_lock); 606 spin_unlock_irq(&pcm->bus->bus_lock);
607 snd_printk(KERN_ERR "cannot find configuration for AC97 slot %i\n", i); 607 dev_err(bus->card->dev,
608 "cannot find configuration for AC97 slot %i\n",
609 i);
608 err = -EAGAIN; 610 err = -EAGAIN;
609 goto error; 611 goto error;
610 } 612 }
@@ -618,15 +620,20 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
618 if (pcm->r[r].rslots[cidx] & (1 << i)) { 620 if (pcm->r[r].rslots[cidx] & (1 << i)) {
619 reg = get_slot_reg(pcm, cidx, i, r); 621 reg = get_slot_reg(pcm, cidx, i, r);
620 if (reg == 0xff) { 622 if (reg == 0xff) {
621 snd_printk(KERN_ERR "invalid AC97 slot %i?\n", i); 623 dev_err(bus->card->dev,
624 "invalid AC97 slot %i?\n", i);
622 continue; 625 continue;
623 } 626 }
624 if (reg_ok[cidx] & (1 << (reg - AC97_PCM_FRONT_DAC_RATE))) 627 if (reg_ok[cidx] & (1 << (reg - AC97_PCM_FRONT_DAC_RATE)))
625 continue; 628 continue;
626 //printk(KERN_DEBUG "setting ac97 reg 0x%x to rate %d\n", reg, rate); 629 dev_dbg(bus->card->dev,
630 "setting ac97 reg 0x%x to rate %d\n",
631 reg, rate);
627 err = snd_ac97_set_rate(pcm->r[r].codec[cidx], reg, rate); 632 err = snd_ac97_set_rate(pcm->r[r].codec[cidx], reg, rate);
628 if (err < 0) 633 if (err < 0)
629 snd_printk(KERN_ERR "error in snd_ac97_set_rate: cidx=%d, reg=0x%x, rate=%d, err=%d\n", cidx, reg, rate, err); 634 dev_err(bus->card->dev,
635 "error in snd_ac97_set_rate: cidx=%d, reg=0x%x, rate=%d, err=%d\n",
636 cidx, reg, rate, err);
630 else 637 else
631 reg_ok[cidx] |= (1 << (reg - AC97_PCM_FRONT_DAC_RATE)); 638 reg_ok[cidx] |= (1 << (reg - AC97_PCM_FRONT_DAC_RATE));
632 } 639 }
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index b680d03e2419..488f966adde3 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -77,9 +77,6 @@ MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
77#define DEVNAME "ad1889" 77#define DEVNAME "ad1889"
78#define PFX DEVNAME ": " 78#define PFX DEVNAME ": "
79 79
80/* let's use the global sound debug interfaces */
81#define ad1889_debug(fmt, arg...) snd_printd(KERN_DEBUG fmt, ## arg)
82
83/* keep track of some hw registers */ 80/* keep track of some hw registers */
84struct ad1889_register_state { 81struct ad1889_register_state {
85 u16 reg; /* reg setup */ 82 u16 reg; /* reg setup */
@@ -264,11 +261,11 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip)
264 && --retry) 261 && --retry)
265 mdelay(1); 262 mdelay(1);
266 if (!retry) { 263 if (!retry) {
267 snd_printk(KERN_ERR PFX "[%s] Link is not ready.\n", 264 dev_err(chip->card->dev, "[%s] Link is not ready.\n",
268 __func__); 265 __func__);
269 return -EIO; 266 return -EIO;
270 } 267 }
271 ad1889_debug("[%s] ready after %d ms\n", __func__, 400 - retry); 268 dev_dbg(chip->card->dev, "[%s] ready after %d ms\n", __func__, 400 - retry);
272 269
273 return 0; 270 return 0;
274} 271}
@@ -405,9 +402,9 @@ snd_ad1889_playback_prepare(struct snd_pcm_substream *ss)
405 402
406 spin_unlock_irq(&chip->lock); 403 spin_unlock_irq(&chip->lock);
407 404
408 ad1889_debug("prepare playback: addr = 0x%x, count = %u, " 405 dev_dbg(chip->card->dev,
409 "size = %u, reg = 0x%x, rate = %u\n", chip->wave.addr, 406 "prepare playback: addr = 0x%x, count = %u, size = %u, reg = 0x%x, rate = %u\n",
410 count, size, reg, rt->rate); 407 chip->wave.addr, count, size, reg, rt->rate);
411 return 0; 408 return 0;
412} 409}
413 410
@@ -452,9 +449,9 @@ snd_ad1889_capture_prepare(struct snd_pcm_substream *ss)
452 449
453 spin_unlock_irq(&chip->lock); 450 spin_unlock_irq(&chip->lock);
454 451
455 ad1889_debug("prepare capture: addr = 0x%x, count = %u, " 452 dev_dbg(chip->card->dev,
456 "size = %u, reg = 0x%x, rate = %u\n", chip->ramc.addr, 453 "prepare capture: addr = 0x%x, count = %u, size = %u, reg = 0x%x, rate = %u\n",
457 count, size, reg, rt->rate); 454 chip->ramc.addr, count, size, reg, rt->rate);
458 return 0; 455 return 0;
459} 456}
460 457
@@ -614,7 +611,8 @@ snd_ad1889_interrupt(int irq, void *dev_id)
614 return IRQ_NONE; 611 return IRQ_NONE;
615 612
616 if (st & (AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI)) 613 if (st & (AD_DMA_DISR_PMAI|AD_DMA_DISR_PTAI))
617 ad1889_debug("Unexpected master or target abort interrupt!\n"); 614 dev_dbg(chip->card->dev,
615 "Unexpected master or target abort interrupt!\n");
618 616
619 if ((st & AD_DMA_DISR_WAVI) && chip->psubs) 617 if ((st & AD_DMA_DISR_WAVI) && chip->psubs)
620 snd_pcm_period_elapsed(chip->psubs); 618 snd_pcm_period_elapsed(chip->psubs);
@@ -656,7 +654,7 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, struct snd_pcm **rpcm)
656 BUFFER_BYTES_MAX); 654 BUFFER_BYTES_MAX);
657 655
658 if (err < 0) { 656 if (err < 0) {
659 snd_printk(KERN_ERR PFX "buffer allocation error: %d\n", err); 657 dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
660 return err; 658 return err;
661 } 659 }
662 660
@@ -912,7 +910,7 @@ snd_ad1889_create(struct snd_card *card,
912 /* check PCI availability (32bit DMA) */ 910 /* check PCI availability (32bit DMA) */
913 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 || 911 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
914 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) { 912 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
915 printk(KERN_ERR PFX "error setting 32-bit DMA mask.\n"); 913 dev_err(card->dev, "error setting 32-bit DMA mask.\n");
916 pci_disable_device(pci); 914 pci_disable_device(pci);
917 return -ENXIO; 915 return -ENXIO;
918 } 916 }
@@ -935,7 +933,7 @@ snd_ad1889_create(struct snd_card *card,
935 chip->bar = pci_resource_start(pci, 0); 933 chip->bar = pci_resource_start(pci, 0);
936 chip->iobase = pci_ioremap_bar(pci, 0); 934 chip->iobase = pci_ioremap_bar(pci, 0);
937 if (chip->iobase == NULL) { 935 if (chip->iobase == NULL) {
938 printk(KERN_ERR PFX "unable to reserve region.\n"); 936 dev_err(card->dev, "unable to reserve region.\n");
939 err = -EBUSY; 937 err = -EBUSY;
940 goto free_and_ret; 938 goto free_and_ret;
941 } 939 }
@@ -946,7 +944,7 @@ snd_ad1889_create(struct snd_card *card,
946 944
947 if (request_irq(pci->irq, snd_ad1889_interrupt, 945 if (request_irq(pci->irq, snd_ad1889_interrupt,
948 IRQF_SHARED, KBUILD_MODNAME, chip)) { 946 IRQF_SHARED, KBUILD_MODNAME, chip)) {
949 printk(KERN_ERR PFX "cannot obtain IRQ %d\n", pci->irq); 947 dev_err(card->dev, "cannot obtain IRQ %d\n", pci->irq);
950 snd_ad1889_free(chip); 948 snd_ad1889_free(chip);
951 return -EBUSY; 949 return -EBUSY;
952 } 950 }
@@ -965,8 +963,6 @@ snd_ad1889_create(struct snd_card *card,
965 return err; 963 return err;
966 } 964 }
967 965
968 snd_card_set_dev(card, &pci->dev);
969
970 *rchip = chip; 966 *rchip = chip;
971 967
972 return 0; 968 return 0;
@@ -996,7 +992,8 @@ snd_ad1889_probe(struct pci_dev *pci,
996 } 992 }
997 993
998 /* (2) */ 994 /* (2) */
999 err = snd_card_create(index[devno], id[devno], THIS_MODULE, 0, &card); 995 err = snd_card_new(&pci->dev, index[devno], id[devno], THIS_MODULE,
996 0, &card);
1000 /* XXX REVISIT: we can probably allocate chip in this call */ 997 /* XXX REVISIT: we can probably allocate chip in this call */
1001 if (err < 0) 998 if (err < 0)
1002 return err; 999 return err;
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index c6835a3d64fb..feb29c24cab1 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -65,18 +65,6 @@ module_param(enable, bool, 0444);
65 65
66 66
67/* 67/*
68 * Debug part definitions
69 */
70
71/* #define ALI_DEBUG */
72
73#ifdef ALI_DEBUG
74#define snd_ali_printk(format, args...) printk(KERN_DEBUG format, ##args);
75#else
76#define snd_ali_printk(format, args...)
77#endif
78
79/*
80 * Constants definition 68 * Constants definition
81 */ 69 */
82 70
@@ -321,7 +309,7 @@ static int snd_ali_codec_ready(struct snd_ali *codec,
321 } 309 }
322 310
323 snd_ali_5451_poke(codec, port, res & ~0x8000); 311 snd_ali_5451_poke(codec, port, res & ~0x8000);
324 snd_printdd("ali_codec_ready: codec is not ready.\n "); 312 dev_dbg(codec->card->dev, "ali_codec_ready: codec is not ready.\n ");
325 return -EIO; 313 return -EIO;
326} 314}
327 315
@@ -342,7 +330,7 @@ static int snd_ali_stimer_ready(struct snd_ali *codec)
342 schedule_timeout_uninterruptible(1); 330 schedule_timeout_uninterruptible(1);
343 } 331 }
344 332
345 snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n"); 333 dev_err(codec->card->dev, "ali_stimer_read: stimer is not ready.\n");
346 return -EIO; 334 return -EIO;
347} 335}
348 336
@@ -354,7 +342,8 @@ static void snd_ali_codec_poke(struct snd_ali *codec,int secondary,
354 unsigned int port; 342 unsigned int port;
355 343
356 if (reg >= 0x80) { 344 if (reg >= 0x80) {
357 snd_printk(KERN_ERR "ali_codec_poke: reg(%xh) invalid.\n", reg); 345 dev_err(codec->card->dev,
346 "ali_codec_poke: reg(%xh) invalid.\n", reg);
358 return; 347 return;
359 } 348 }
360 349
@@ -385,7 +374,8 @@ static unsigned short snd_ali_codec_peek(struct snd_ali *codec,
385 unsigned int port; 374 unsigned int port;
386 375
387 if (reg >= 0x80) { 376 if (reg >= 0x80) {
388 snd_printk(KERN_ERR "ali_codec_peek: reg(%xh) invalid.\n", reg); 377 dev_err(codec->card->dev,
378 "ali_codec_peek: reg(%xh) invalid.\n", reg);
389 return ~0; 379 return ~0;
390 } 380 }
391 381
@@ -417,7 +407,7 @@ static void snd_ali_codec_write(struct snd_ac97 *ac97,
417{ 407{
418 struct snd_ali *codec = ac97->private_data; 408 struct snd_ali *codec = ac97->private_data;
419 409
420 snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); 410 dev_dbg(codec->card->dev, "codec_write: reg=%xh data=%xh.\n", reg, val);
421 if (reg == AC97_GPIO_STATUS) { 411 if (reg == AC97_GPIO_STATUS) {
422 outl((val << ALI_AC97_GPIO_DATA_SHIFT) | ALI_AC97_GPIO_ENABLE, 412 outl((val << ALI_AC97_GPIO_DATA_SHIFT) | ALI_AC97_GPIO_ENABLE,
423 ALI_REG(codec, ALI_AC97_GPIO)); 413 ALI_REG(codec, ALI_AC97_GPIO));
@@ -433,7 +423,7 @@ static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97,
433{ 423{
434 struct snd_ali *codec = ac97->private_data; 424 struct snd_ali *codec = ac97->private_data;
435 425
436 snd_ali_printk("codec_read reg=%xh.\n", reg); 426 dev_dbg(codec->card->dev, "codec_read reg=%xh.\n", reg);
437 return snd_ali_codec_peek(codec, ac97->num, reg); 427 return snd_ali_codec_peek(codec, ac97->num, reg);
438} 428}
439 429
@@ -474,7 +464,7 @@ static int snd_ali_reset_5451(struct snd_ali *codec)
474 } 464 }
475 465
476 /* non-fatal if you have a non PM capable codec */ 466 /* non-fatal if you have a non PM capable codec */
477 /* snd_printk(KERN_WARNING "ali5451: reset time out\n"); */ 467 /* dev_warn(codec->card->dev, "ali5451: reset time out\n"); */
478 return 0; 468 return 0;
479} 469}
480 470
@@ -528,7 +518,7 @@ static void snd_ali_disable_voice_irq(struct snd_ali *codec,
528 unsigned int mask; 518 unsigned int mask;
529 struct snd_ali_channel_control *pchregs = &(codec->chregs); 519 struct snd_ali_channel_control *pchregs = &(codec->chregs);
530 520
531 snd_ali_printk("disable_voice_irq channel=%d\n",channel); 521 dev_dbg(codec->card->dev, "disable_voice_irq channel=%d\n", channel);
532 522
533 mask = 1 << (channel & 0x1f); 523 mask = 1 << (channel & 0x1f);
534 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten)); 524 pchregs->data.ainten = inl(ALI_REG(codec, pchregs->regs.ainten));
@@ -541,7 +531,7 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
541 unsigned int idx = channel & 0x1f; 531 unsigned int idx = channel & 0x1f;
542 532
543 if (codec->synth.chcnt >= ALI_CHANNELS){ 533 if (codec->synth.chcnt >= ALI_CHANNELS){
544 snd_printk(KERN_ERR 534 dev_err(codec->card->dev,
545 "ali_alloc_pcm_channel: no free channels.\n"); 535 "ali_alloc_pcm_channel: no free channels.\n");
546 return -1; 536 return -1;
547 } 537 }
@@ -549,7 +539,7 @@ static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel)
549 if (!(codec->synth.chmap & (1 << idx))) { 539 if (!(codec->synth.chmap & (1 << idx))) {
550 codec->synth.chmap |= 1 << idx; 540 codec->synth.chmap |= 1 << idx;
551 codec->synth.chcnt++; 541 codec->synth.chcnt++;
552 snd_ali_printk("alloc_pcm_channel no. %d.\n",idx); 542 dev_dbg(codec->card->dev, "alloc_pcm_channel no. %d.\n", idx);
553 return idx; 543 return idx;
554 } 544 }
555 return -1; 545 return -1;
@@ -560,7 +550,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
560 int idx; 550 int idx;
561 int result = -1; 551 int result = -1;
562 552
563 snd_ali_printk("find_free_channel: for %s\n",rec ? "rec" : "pcm"); 553 dev_dbg(codec->card->dev,
554 "find_free_channel: for %s\n", rec ? "rec" : "pcm");
564 555
565 /* recording */ 556 /* recording */
566 if (rec) { 557 if (rec) {
@@ -575,8 +566,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
575 if (result >= 0) 566 if (result >= 0)
576 return result; 567 return result;
577 else { 568 else {
578 snd_printk(KERN_ERR "ali_find_free_channel: " 569 dev_err(codec->card->dev,
579 "record channel is busy now.\n"); 570 "ali_find_free_channel: record channel is busy now.\n");
580 return -1; 571 return -1;
581 } 572 }
582 } 573 }
@@ -590,8 +581,8 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
590 if (result >= 0) 581 if (result >= 0)
591 return result; 582 return result;
592 else 583 else
593 snd_printk(KERN_ERR "ali_find_free_channel: " 584 dev_err(codec->card->dev,
594 "S/PDIF out channel is in busy now.\n"); 585 "ali_find_free_channel: S/PDIF out channel is in busy now.\n");
595 } 586 }
596 587
597 for (idx = 0; idx < ALI_CHANNELS; idx++) { 588 for (idx = 0; idx < ALI_CHANNELS; idx++) {
@@ -599,7 +590,7 @@ static int snd_ali_find_free_channel(struct snd_ali * codec, int rec)
599 if (result >= 0) 590 if (result >= 0)
600 return result; 591 return result;
601 } 592 }
602 snd_printk(KERN_ERR "ali_find_free_channel: no free channels.\n"); 593 dev_err(codec->card->dev, "ali_find_free_channel: no free channels.\n");
603 return -1; 594 return -1;
604} 595}
605 596
@@ -607,14 +598,15 @@ static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel)
607{ 598{
608 unsigned int idx = channel & 0x0000001f; 599 unsigned int idx = channel & 0x0000001f;
609 600
610 snd_ali_printk("free_channel_pcm channel=%d\n",channel); 601 dev_dbg(codec->card->dev, "free_channel_pcm channel=%d\n", channel);
611 602
612 if (channel < 0 || channel >= ALI_CHANNELS) 603 if (channel < 0 || channel >= ALI_CHANNELS)
613 return; 604 return;
614 605
615 if (!(codec->synth.chmap & (1 << idx))) { 606 if (!(codec->synth.chmap & (1 << idx))) {
616 snd_printk(KERN_ERR "ali_free_channel_pcm: " 607 dev_err(codec->card->dev,
617 "channel %d is not in use.\n", channel); 608 "ali_free_channel_pcm: channel %d is not in use.\n",
609 channel);
618 return; 610 return;
619 } else { 611 } else {
620 codec->synth.chmap &= ~(1 << idx); 612 codec->synth.chmap &= ~(1 << idx);
@@ -626,7 +618,7 @@ static void snd_ali_stop_voice(struct snd_ali *codec, unsigned int channel)
626{ 618{
627 unsigned int mask = 1 << (channel & 0x1f); 619 unsigned int mask = 1 << (channel & 0x1f);
628 620
629 snd_ali_printk("stop_voice: channel=%d\n",channel); 621 dev_dbg(codec->card->dev, "stop_voice: channel=%d\n", channel);
630 outl(mask, ALI_REG(codec, codec->chregs.regs.stop)); 622 outl(mask, ALI_REG(codec, codec->chregs.regs.stop));
631} 623}
632 624
@@ -667,7 +659,7 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
667 } 659 }
668 660
669 if (count > 50000) { 661 if (count > 50000) {
670 snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n"); 662 dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
671 return; 663 return;
672 } 664 }
673 665
@@ -682,7 +674,7 @@ static void snd_ali_detect_spdif_rate(struct snd_ali *codec)
682 } 674 }
683 675
684 if (count > 50000) { 676 if (count > 50000) {
685 snd_printk(KERN_ERR "ali_detect_spdif_rate: timeout!\n"); 677 dev_err(codec->card->dev, "ali_detect_spdif_rate: timeout!\n");
686 return; 678 return;
687 } 679 }
688 680
@@ -857,9 +849,6 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
857 struct snd_ali_voice *pvoice; 849 struct snd_ali_voice *pvoice;
858 struct snd_ali_channel_control *pchregs; 850 struct snd_ali_channel_control *pchregs;
859 unsigned int old, mask; 851 unsigned int old, mask;
860#ifdef ALI_DEBUG
861 unsigned int temp, cspf;
862#endif
863 852
864 pchregs = &(codec->chregs); 853 pchregs = &(codec->chregs);
865 854
@@ -877,14 +866,11 @@ static void snd_ali_update_ptr(struct snd_ali *codec, int channel)
877 866
878 if (pvoice->pcm && pvoice->substream) { 867 if (pvoice->pcm && pvoice->substream) {
879 /* pcm interrupt */ 868 /* pcm interrupt */
880#ifdef ALI_DEBUG
881 outb((u8)(pvoice->number), ALI_REG(codec, ALI_GC_CIR));
882 temp = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
883 cspf = (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask;
884#endif
885 if (pvoice->running) { 869 if (pvoice->running) {
886 snd_ali_printk("update_ptr: cso=%4.4x cspf=%d.\n", 870 dev_dbg(codec->card->dev,
887 (u16)temp, cspf); 871 "update_ptr: cso=%4.4x cspf=%d.\n",
872 inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)),
873 (inl(ALI_REG(codec, ALI_CSPF)) & mask) == mask);
888 spin_unlock(&codec->reg_lock); 874 spin_unlock(&codec->reg_lock);
889 snd_pcm_period_elapsed(pvoice->substream); 875 snd_pcm_period_elapsed(pvoice->substream);
890 spin_lock(&codec->reg_lock); 876 spin_lock(&codec->reg_lock);
@@ -940,14 +926,14 @@ static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec,
940 struct snd_ali_voice *pvoice; 926 struct snd_ali_voice *pvoice;
941 int idx; 927 int idx;
942 928
943 snd_ali_printk("alloc_voice: type=%d rec=%d\n", type, rec); 929 dev_dbg(codec->card->dev, "alloc_voice: type=%d rec=%d\n", type, rec);
944 930
945 spin_lock_irq(&codec->voice_alloc); 931 spin_lock_irq(&codec->voice_alloc);
946 if (type == SNDRV_ALI_VOICE_TYPE_PCM) { 932 if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
947 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : 933 idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
948 snd_ali_find_free_channel(codec,rec); 934 snd_ali_find_free_channel(codec,rec);
949 if (idx < 0) { 935 if (idx < 0) {
950 snd_printk(KERN_ERR "ali_alloc_voice: err.\n"); 936 dev_err(codec->card->dev, "ali_alloc_voice: err.\n");
951 spin_unlock_irq(&codec->voice_alloc); 937 spin_unlock_irq(&codec->voice_alloc);
952 return NULL; 938 return NULL;
953 } 939 }
@@ -970,7 +956,7 @@ static void snd_ali_free_voice(struct snd_ali * codec,
970 void (*private_free)(void *); 956 void (*private_free)(void *);
971 void *private_data; 957 void *private_data;
972 958
973 snd_ali_printk("free_voice: channel=%d\n",pvoice->number); 959 dev_dbg(codec->card->dev, "free_voice: channel=%d\n", pvoice->number);
974 if (!pvoice->use) 960 if (!pvoice->use)
975 return; 961 return;
976 snd_ali_clear_voices(codec, pvoice->number, pvoice->number); 962 snd_ali_clear_voices(codec, pvoice->number, pvoice->number);
@@ -1153,7 +1139,7 @@ static int snd_ali_trigger(struct snd_pcm_substream *substream,
1153 outl(val, ALI_REG(codec, ALI_AINTEN)); 1139 outl(val, ALI_REG(codec, ALI_AINTEN));
1154 if (do_start) 1140 if (do_start)
1155 outl(what, ALI_REG(codec, ALI_START)); 1141 outl(what, ALI_REG(codec, ALI_START));
1156 snd_ali_printk("trigger: what=%xh whati=%xh\n", what, whati); 1142 dev_dbg(codec->card->dev, "trigger: what=%xh whati=%xh\n", what, whati);
1157 spin_unlock(&codec->reg_lock); 1143 spin_unlock(&codec->reg_lock);
1158 1144
1159 return 0; 1145 return 0;
@@ -1239,7 +1225,7 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1239 unsigned int VOL; 1225 unsigned int VOL;
1240 unsigned int EC; 1226 unsigned int EC;
1241 1227
1242 snd_ali_printk("playback_prepare ...\n"); 1228 dev_dbg(codec->card->dev, "playback_prepare ...\n");
1243 1229
1244 spin_lock_irq(&codec->reg_lock); 1230 spin_lock_irq(&codec->reg_lock);
1245 1231
@@ -1266,7 +1252,7 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1266 /* set target ESO for channel */ 1252 /* set target ESO for channel */
1267 pvoice->eso = runtime->buffer_size; 1253 pvoice->eso = runtime->buffer_size;
1268 1254
1269 snd_ali_printk("playback_prepare: eso=%xh count=%xh\n", 1255 dev_dbg(codec->card->dev, "playback_prepare: eso=%xh count=%xh\n",
1270 pvoice->eso, pvoice->count); 1256 pvoice->eso, pvoice->count);
1271 1257
1272 /* set ESO to capture first MIDLP interrupt */ 1258 /* set ESO to capture first MIDLP interrupt */
@@ -1278,8 +1264,9 @@ static int snd_ali_playback_prepare(struct snd_pcm_substream *substream)
1278 PAN = 0; 1264 PAN = 0;
1279 VOL = 0; 1265 VOL = 0;
1280 EC = 0; 1266 EC = 0;
1281 snd_ali_printk("playback_prepare:\n"); 1267 dev_dbg(codec->card->dev, "playback_prepare:\n");
1282 snd_ali_printk("ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n", 1268 dev_dbg(codec->card->dev,
1269 "ch=%d, Rate=%d Delta=%xh,GVSEL=%xh,PAN=%xh,CTRL=%xh\n",
1283 pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL); 1270 pvoice->number,runtime->rate,Delta,GVSEL,PAN,CTRL);
1284 snd_ali_write_voice_regs(codec, 1271 snd_ali_write_voice_regs(codec,
1285 pvoice->number, 1272 pvoice->number,
@@ -1332,7 +1319,7 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1332 1319
1333 spin_lock_irq(&codec->reg_lock); 1320 spin_lock_irq(&codec->reg_lock);
1334 1321
1335 snd_ali_printk("ali_prepare...\n"); 1322 dev_dbg(codec->card->dev, "ali_prepare...\n");
1336 1323
1337 snd_ali_enable_special_channel(codec,pvoice->number); 1324 snd_ali_enable_special_channel(codec,pvoice->number);
1338 1325
@@ -1351,15 +1338,16 @@ static int snd_ali_prepare(struct snd_pcm_substream *substream)
1351 1338
1352 rate = snd_ali_get_spdif_in_rate(codec); 1339 rate = snd_ali_get_spdif_in_rate(codec);
1353 if (rate == 0) { 1340 if (rate == 0) {
1354 snd_printk(KERN_WARNING "ali_capture_preapre: " 1341 dev_warn(codec->card->dev,
1355 "spdif rate detect err!\n"); 1342 "ali_capture_preapre: spdif rate detect err!\n");
1356 rate = 48000; 1343 rate = 48000;
1357 } 1344 }
1358 spin_lock_irq(&codec->reg_lock); 1345 spin_lock_irq(&codec->reg_lock);
1359 bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); 1346 bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL));
1360 if (bValue & 0x10) { 1347 if (bValue & 0x10) {
1361 outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL)); 1348 outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL));
1362 printk(KERN_WARNING "clear SPDIF parity error flag.\n"); 1349 dev_warn(codec->card->dev,
1350 "clear SPDIF parity error flag.\n");
1363 } 1351 }
1364 1352
1365 if (rate != 48000) 1353 if (rate != 48000)
@@ -1418,7 +1406,7 @@ snd_ali_playback_pointer(struct snd_pcm_substream *substream)
1418 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR)); 1406 outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
1419 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)); 1407 cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
1420 spin_unlock(&codec->reg_lock); 1408 spin_unlock(&codec->reg_lock);
1421 snd_ali_printk("playback pointer returned cso=%xh.\n", cso); 1409 dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso);
1422 1410
1423 return cso; 1411 return cso;
1424} 1412}
@@ -1685,7 +1673,8 @@ static int snd_ali_pcm(struct snd_ali *codec, int device,
1685 err = snd_pcm_new(codec->card, desc->name, device, 1673 err = snd_pcm_new(codec->card, desc->name, device,
1686 desc->playback_num, desc->capture_num, &pcm); 1674 desc->playback_num, desc->capture_num, &pcm);
1687 if (err < 0) { 1675 if (err < 0) {
1688 snd_printk(KERN_ERR "snd_ali_pcm: err called snd_pcm_new.\n"); 1676 dev_err(codec->card->dev,
1677 "snd_ali_pcm: err called snd_pcm_new.\n");
1689 return err; 1678 return err;
1690 } 1679 }
1691 pcm->private_data = codec; 1680 pcm->private_data = codec;
@@ -1861,7 +1850,7 @@ static int snd_ali_mixer(struct snd_ali *codec)
1861 ac97.num = i; 1850 ac97.num = i;
1862 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]); 1851 err = snd_ac97_mixer(codec->ac97_bus, &ac97, &codec->ac97[i]);
1863 if (err < 0) { 1852 if (err < 0) {
1864 snd_printk(KERN_ERR 1853 dev_err(codec->card->dev,
1865 "ali mixer %d creating error.\n", i); 1854 "ali mixer %d creating error.\n", i);
1866 if (i == 0) 1855 if (i == 0)
1867 return err; 1856 return err;
@@ -1947,8 +1936,7 @@ static int ali_resume(struct device *dev)
1947 pci_set_power_state(pci, PCI_D0); 1936 pci_set_power_state(pci, PCI_D0);
1948 pci_restore_state(pci); 1937 pci_restore_state(pci);
1949 if (pci_enable_device(pci) < 0) { 1938 if (pci_enable_device(pci) < 0) {
1950 printk(KERN_ERR "ali5451: pci_enable_device failed, " 1939 dev_err(dev, "pci_enable_device failed, disabling device\n");
1951 "disabling device\n");
1952 snd_card_disconnect(card); 1940 snd_card_disconnect(card);
1953 return -EIO; 1941 return -EIO;
1954 } 1942 }
@@ -2013,10 +2001,10 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2013 unsigned char temp; 2001 unsigned char temp;
2014 struct pci_dev *pci_dev; 2002 struct pci_dev *pci_dev;
2015 2003
2016 snd_ali_printk("chip initializing ... \n"); 2004 dev_dbg(codec->card->dev, "chip initializing ...\n");
2017 2005
2018 if (snd_ali_reset_5451(codec)) { 2006 if (snd_ali_reset_5451(codec)) {
2019 snd_printk(KERN_ERR "ali_chip_init: reset 5451 error.\n"); 2007 dev_err(codec->card->dev, "ali_chip_init: reset 5451 error.\n");
2020 return -1; 2008 return -1;
2021 } 2009 }
2022 2010
@@ -2062,7 +2050,7 @@ static int snd_ali_chip_init(struct snd_ali *codec)
2062 ALI_REG(codec, ALI_SCTRL)); 2050 ALI_REG(codec, ALI_SCTRL));
2063 } 2051 }
2064 2052
2065 snd_ali_printk("chip initialize succeed.\n"); 2053 dev_dbg(codec->card->dev, "chip initialize succeed.\n");
2066 return 0; 2054 return 0;
2067 2055
2068} 2056}
@@ -2088,7 +2076,7 @@ static int snd_ali_resources(struct snd_ali *codec)
2088{ 2076{
2089 int err; 2077 int err;
2090 2078
2091 snd_ali_printk("resources allocation ...\n"); 2079 dev_dbg(codec->card->dev, "resources allocation ...\n");
2092 err = pci_request_regions(codec->pci, "ALI 5451"); 2080 err = pci_request_regions(codec->pci, "ALI 5451");
2093 if (err < 0) 2081 if (err < 0)
2094 return err; 2082 return err;
@@ -2096,11 +2084,11 @@ static int snd_ali_resources(struct snd_ali *codec)
2096 2084
2097 if (request_irq(codec->pci->irq, snd_ali_card_interrupt, 2085 if (request_irq(codec->pci->irq, snd_ali_card_interrupt,
2098 IRQF_SHARED, KBUILD_MODNAME, codec)) { 2086 IRQF_SHARED, KBUILD_MODNAME, codec)) {
2099 snd_printk(KERN_ERR "Unable to request irq.\n"); 2087 dev_err(codec->card->dev, "Unable to request irq.\n");
2100 return -EBUSY; 2088 return -EBUSY;
2101 } 2089 }
2102 codec->irq = codec->pci->irq; 2090 codec->irq = codec->pci->irq;
2103 snd_ali_printk("resources allocated.\n"); 2091 dev_dbg(codec->card->dev, "resources allocated.\n");
2104 return 0; 2092 return 0;
2105} 2093}
2106static int snd_ali_dev_free(struct snd_device *device) 2094static int snd_ali_dev_free(struct snd_device *device)
@@ -2125,7 +2113,7 @@ static int snd_ali_create(struct snd_card *card,
2125 2113
2126 *r_ali = NULL; 2114 *r_ali = NULL;
2127 2115
2128 snd_ali_printk("creating ...\n"); 2116 dev_dbg(card->dev, "creating ...\n");
2129 2117
2130 /* enable PCI device */ 2118 /* enable PCI device */
2131 err = pci_enable_device(pci); 2119 err = pci_enable_device(pci);
@@ -2134,8 +2122,8 @@ static int snd_ali_create(struct snd_card *card,
2134 /* check, if we can restrict PCI DMA transfers to 31 bits */ 2122 /* check, if we can restrict PCI DMA transfers to 31 bits */
2135 if (pci_set_dma_mask(pci, DMA_BIT_MASK(31)) < 0 || 2123 if (pci_set_dma_mask(pci, DMA_BIT_MASK(31)) < 0 ||
2136 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(31)) < 0) { 2124 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(31)) < 0) {
2137 snd_printk(KERN_ERR "architecture does not support " 2125 dev_err(card->dev,
2138 "31bit PCI busmaster DMA\n"); 2126 "architecture does not support 31bit PCI busmaster DMA\n");
2139 pci_disable_device(pci); 2127 pci_disable_device(pci);
2140 return -ENXIO; 2128 return -ENXIO;
2141 } 2129 }
@@ -2199,48 +2187,46 @@ static int snd_ali_create(struct snd_card *card,
2199 /* M1533: southbridge */ 2187 /* M1533: southbridge */
2200 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); 2188 codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL);
2201 if (!codec->pci_m1533) { 2189 if (!codec->pci_m1533) {
2202 snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); 2190 dev_err(card->dev, "cannot find ALi 1533 chip.\n");
2203 snd_ali_free(codec); 2191 snd_ali_free(codec);
2204 return -ENODEV; 2192 return -ENODEV;
2205 } 2193 }
2206 /* M7101: power management */ 2194 /* M7101: power management */
2207 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); 2195 codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL);
2208 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) { 2196 if (!codec->pci_m7101 && codec->revision == ALI_5451_V02) {
2209 snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); 2197 dev_err(card->dev, "cannot find ALi 7101 chip.\n");
2210 snd_ali_free(codec); 2198 snd_ali_free(codec);
2211 return -ENODEV; 2199 return -ENODEV;
2212 } 2200 }
2213 2201
2214 snd_ali_printk("snd_device_new is called.\n"); 2202 dev_dbg(card->dev, "snd_device_new is called.\n");
2215 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops); 2203 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, codec, &ops);
2216 if (err < 0) { 2204 if (err < 0) {
2217 snd_ali_free(codec); 2205 snd_ali_free(codec);
2218 return err; 2206 return err;
2219 } 2207 }
2220 2208
2221 snd_card_set_dev(card, &pci->dev);
2222
2223 /* initialise synth voices*/ 2209 /* initialise synth voices*/
2224 for (i = 0; i < ALI_CHANNELS; i++) 2210 for (i = 0; i < ALI_CHANNELS; i++)
2225 codec->synth.voices[i].number = i; 2211 codec->synth.voices[i].number = i;
2226 2212
2227 err = snd_ali_chip_init(codec); 2213 err = snd_ali_chip_init(codec);
2228 if (err < 0) { 2214 if (err < 0) {
2229 snd_printk(KERN_ERR "ali create: chip init error.\n"); 2215 dev_err(card->dev, "ali create: chip init error.\n");
2230 return err; 2216 return err;
2231 } 2217 }
2232 2218
2233#ifdef CONFIG_PM_SLEEP 2219#ifdef CONFIG_PM_SLEEP
2234 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); 2220 codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL);
2235 if (!codec->image) 2221 if (!codec->image)
2236 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2222 dev_warn(card->dev, "can't allocate apm buffer\n");
2237#endif 2223#endif
2238 2224
2239 snd_ali_enable_address_interrupt(codec); 2225 snd_ali_enable_address_interrupt(codec);
2240 codec->hw_initialized = 1; 2226 codec->hw_initialized = 1;
2241 2227
2242 *r_ali = codec; 2228 *r_ali = codec;
2243 snd_ali_printk("created.\n"); 2229 dev_dbg(card->dev, "created.\n");
2244 return 0; 2230 return 0;
2245} 2231}
2246 2232
@@ -2251,9 +2237,9 @@ static int snd_ali_probe(struct pci_dev *pci,
2251 struct snd_ali *codec; 2237 struct snd_ali *codec;
2252 int err; 2238 int err;
2253 2239
2254 snd_ali_printk("probe ...\n"); 2240 dev_dbg(&pci->dev, "probe ...\n");
2255 2241
2256 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 2242 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
2257 if (err < 0) 2243 if (err < 0)
2258 return err; 2244 return err;
2259 2245
@@ -2262,12 +2248,12 @@ static int snd_ali_probe(struct pci_dev *pci,
2262 goto error; 2248 goto error;
2263 card->private_data = codec; 2249 card->private_data = codec;
2264 2250
2265 snd_ali_printk("mixer building ...\n"); 2251 dev_dbg(&pci->dev, "mixer building ...\n");
2266 err = snd_ali_mixer(codec); 2252 err = snd_ali_mixer(codec);
2267 if (err < 0) 2253 if (err < 0)
2268 goto error; 2254 goto error;
2269 2255
2270 snd_ali_printk("pcm building ...\n"); 2256 dev_dbg(&pci->dev, "pcm building ...\n");
2271 err = snd_ali_build_pcms(codec); 2257 err = snd_ali_build_pcms(codec);
2272 if (err < 0) 2258 if (err < 0)
2273 goto error; 2259 goto error;
@@ -2280,7 +2266,7 @@ static int snd_ali_probe(struct pci_dev *pci,
2280 sprintf(card->longname, "%s at 0x%lx, irq %i", 2266 sprintf(card->longname, "%s at 0x%lx, irq %i",
2281 card->shortname, codec->port, codec->irq); 2267 card->shortname, codec->port, codec->irq);
2282 2268
2283 snd_ali_printk("register card.\n"); 2269 dev_dbg(&pci->dev, "register card.\n");
2284 err = snd_card_register(card); 2270 err = snd_card_register(card);
2285 if (err < 0) 2271 if (err < 0)
2286 goto error; 2272 goto error;
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 591efb6eef05..cc9a15a1304b 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -87,19 +87,8 @@
87#define PLAYBACK_BLOCK_COUNTER 0x9A 87#define PLAYBACK_BLOCK_COUNTER 0x9A
88#define RECORD_BLOCK_COUNTER 0x9B 88#define RECORD_BLOCK_COUNTER 0x9B
89 89
90#define DEBUG_CALLS 0
91#define DEBUG_PLAY_REC 0 90#define DEBUG_PLAY_REC 0
92 91
93#if DEBUG_CALLS
94#define snd_als300_dbgcalls(format, args...) printk(KERN_DEBUG format, ##args)
95#define snd_als300_dbgcallenter() printk(KERN_ERR "--> %s\n", __func__)
96#define snd_als300_dbgcallleave() printk(KERN_ERR "<-- %s\n", __func__)
97#else
98#define snd_als300_dbgcalls(format, args...)
99#define snd_als300_dbgcallenter()
100#define snd_als300_dbgcallleave()
101#endif
102
103#if DEBUG_PLAY_REC 92#if DEBUG_PLAY_REC
104#define snd_als300_dbgplay(format, args...) printk(KERN_ERR format, ##args) 93#define snd_als300_dbgplay(format, args...) printk(KERN_ERR format, ##args)
105#else 94#else
@@ -177,7 +166,6 @@ static inline void snd_als300_gcr_write(unsigned long port,
177static void snd_als300_set_irq_flag(struct snd_als300 *chip, int cmd) 166static void snd_als300_set_irq_flag(struct snd_als300 *chip, int cmd)
178{ 167{
179 u32 tmp = snd_als300_gcr_read(chip->port, MISC_CONTROL); 168 u32 tmp = snd_als300_gcr_read(chip->port, MISC_CONTROL);
180 snd_als300_dbgcallenter();
181 169
182 /* boolean XOR check, since old vs. new hardware have 170 /* boolean XOR check, since old vs. new hardware have
183 directly reversed bit setting for ENABLE and DISABLE. 171 directly reversed bit setting for ENABLE and DISABLE.
@@ -188,19 +176,16 @@ static void snd_als300_set_irq_flag(struct snd_als300 *chip, int cmd)
188 else 176 else
189 tmp &= ~IRQ_SET_BIT; 177 tmp &= ~IRQ_SET_BIT;
190 snd_als300_gcr_write(chip->port, MISC_CONTROL, tmp); 178 snd_als300_gcr_write(chip->port, MISC_CONTROL, tmp);
191 snd_als300_dbgcallleave();
192} 179}
193 180
194static int snd_als300_free(struct snd_als300 *chip) 181static int snd_als300_free(struct snd_als300 *chip)
195{ 182{
196 snd_als300_dbgcallenter();
197 snd_als300_set_irq_flag(chip, IRQ_DISABLE); 183 snd_als300_set_irq_flag(chip, IRQ_DISABLE);
198 if (chip->irq >= 0) 184 if (chip->irq >= 0)
199 free_irq(chip->irq, chip); 185 free_irq(chip->irq, chip);
200 pci_release_regions(chip->pci); 186 pci_release_regions(chip->pci);
201 pci_disable_device(chip->pci); 187 pci_disable_device(chip->pci);
202 kfree(chip); 188 kfree(chip);
203 snd_als300_dbgcallleave();
204 return 0; 189 return 0;
205} 190}
206 191
@@ -280,9 +265,7 @@ static irqreturn_t snd_als300plus_interrupt(int irq, void *dev_id)
280 265
281static void snd_als300_remove(struct pci_dev *pci) 266static void snd_als300_remove(struct pci_dev *pci)
282{ 267{
283 snd_als300_dbgcallenter();
284 snd_card_free(pci_get_drvdata(pci)); 268 snd_card_free(pci_get_drvdata(pci));
285 snd_als300_dbgcallleave();
286} 269}
287 270
288static unsigned short snd_als300_ac97_read(struct snd_ac97 *ac97, 271static unsigned short snd_als300_ac97_read(struct snd_ac97 *ac97,
@@ -330,14 +313,12 @@ static int snd_als300_ac97(struct snd_als300 *chip)
330 .read = snd_als300_ac97_read, 313 .read = snd_als300_ac97_read,
331 }; 314 };
332 315
333 snd_als300_dbgcallenter();
334 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &bus)) < 0) 316 if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &bus)) < 0)
335 return err; 317 return err;
336 318
337 memset(&ac97, 0, sizeof(ac97)); 319 memset(&ac97, 0, sizeof(ac97));
338 ac97.private_data = chip; 320 ac97.private_data = chip;
339 321
340 snd_als300_dbgcallleave();
341 return snd_ac97_mixer(bus, &ac97, &chip->ac97); 322 return snd_ac97_mixer(bus, &ac97, &chip->ac97);
342} 323}
343 324
@@ -395,13 +376,11 @@ static int snd_als300_playback_open(struct snd_pcm_substream *substream)
395 376
396 if (!data) 377 if (!data)
397 return -ENOMEM; 378 return -ENOMEM;
398 snd_als300_dbgcallenter();
399 chip->playback_substream = substream; 379 chip->playback_substream = substream;
400 runtime->hw = snd_als300_playback_hw; 380 runtime->hw = snd_als300_playback_hw;
401 runtime->private_data = data; 381 runtime->private_data = data;
402 data->control_register = PLAYBACK_CONTROL; 382 data->control_register = PLAYBACK_CONTROL;
403 data->block_counter_register = PLAYBACK_BLOCK_COUNTER; 383 data->block_counter_register = PLAYBACK_BLOCK_COUNTER;
404 snd_als300_dbgcallleave();
405 return 0; 384 return 0;
406} 385}
407 386
@@ -411,11 +390,9 @@ static int snd_als300_playback_close(struct snd_pcm_substream *substream)
411 struct snd_als300_substream_data *data; 390 struct snd_als300_substream_data *data;
412 391
413 data = substream->runtime->private_data; 392 data = substream->runtime->private_data;
414 snd_als300_dbgcallenter();
415 kfree(data); 393 kfree(data);
416 chip->playback_substream = NULL; 394 chip->playback_substream = NULL;
417 snd_pcm_lib_free_pages(substream); 395 snd_pcm_lib_free_pages(substream);
418 snd_als300_dbgcallleave();
419 return 0; 396 return 0;
420} 397}
421 398
@@ -428,13 +405,11 @@ static int snd_als300_capture_open(struct snd_pcm_substream *substream)
428 405
429 if (!data) 406 if (!data)
430 return -ENOMEM; 407 return -ENOMEM;
431 snd_als300_dbgcallenter();
432 chip->capture_substream = substream; 408 chip->capture_substream = substream;
433 runtime->hw = snd_als300_capture_hw; 409 runtime->hw = snd_als300_capture_hw;
434 runtime->private_data = data; 410 runtime->private_data = data;
435 data->control_register = RECORD_CONTROL; 411 data->control_register = RECORD_CONTROL;
436 data->block_counter_register = RECORD_BLOCK_COUNTER; 412 data->block_counter_register = RECORD_BLOCK_COUNTER;
437 snd_als300_dbgcallleave();
438 return 0; 413 return 0;
439} 414}
440 415
@@ -444,11 +419,9 @@ static int snd_als300_capture_close(struct snd_pcm_substream *substream)
444 struct snd_als300_substream_data *data; 419 struct snd_als300_substream_data *data;
445 420
446 data = substream->runtime->private_data; 421 data = substream->runtime->private_data;
447 snd_als300_dbgcallenter();
448 kfree(data); 422 kfree(data);
449 chip->capture_substream = NULL; 423 chip->capture_substream = NULL;
450 snd_pcm_lib_free_pages(substream); 424 snd_pcm_lib_free_pages(substream);
451 snd_als300_dbgcallleave();
452 return 0; 425 return 0;
453} 426}
454 427
@@ -472,7 +445,6 @@ static int snd_als300_playback_prepare(struct snd_pcm_substream *substream)
472 unsigned short period_bytes = snd_pcm_lib_period_bytes(substream); 445 unsigned short period_bytes = snd_pcm_lib_period_bytes(substream);
473 unsigned short buffer_bytes = snd_pcm_lib_buffer_bytes(substream); 446 unsigned short buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
474 447
475 snd_als300_dbgcallenter();
476 spin_lock_irq(&chip->reg_lock); 448 spin_lock_irq(&chip->reg_lock);
477 tmp = snd_als300_gcr_read(chip->port, PLAYBACK_CONTROL); 449 tmp = snd_als300_gcr_read(chip->port, PLAYBACK_CONTROL);
478 tmp &= ~TRANSFER_START; 450 tmp &= ~TRANSFER_START;
@@ -491,7 +463,6 @@ static int snd_als300_playback_prepare(struct snd_pcm_substream *substream)
491 snd_als300_gcr_write(chip->port, PLAYBACK_END, 463 snd_als300_gcr_write(chip->port, PLAYBACK_END,
492 runtime->dma_addr + buffer_bytes - 1); 464 runtime->dma_addr + buffer_bytes - 1);
493 spin_unlock_irq(&chip->reg_lock); 465 spin_unlock_irq(&chip->reg_lock);
494 snd_als300_dbgcallleave();
495 return 0; 466 return 0;
496} 467}
497 468
@@ -503,7 +474,6 @@ static int snd_als300_capture_prepare(struct snd_pcm_substream *substream)
503 unsigned short period_bytes = snd_pcm_lib_period_bytes(substream); 474 unsigned short period_bytes = snd_pcm_lib_period_bytes(substream);
504 unsigned short buffer_bytes = snd_pcm_lib_buffer_bytes(substream); 475 unsigned short buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
505 476
506 snd_als300_dbgcallenter();
507 spin_lock_irq(&chip->reg_lock); 477 spin_lock_irq(&chip->reg_lock);
508 tmp = snd_als300_gcr_read(chip->port, RECORD_CONTROL); 478 tmp = snd_als300_gcr_read(chip->port, RECORD_CONTROL);
509 tmp &= ~TRANSFER_START; 479 tmp &= ~TRANSFER_START;
@@ -522,7 +492,6 @@ static int snd_als300_capture_prepare(struct snd_pcm_substream *substream)
522 snd_als300_gcr_write(chip->port, RECORD_END, 492 snd_als300_gcr_write(chip->port, RECORD_END,
523 runtime->dma_addr + buffer_bytes - 1); 493 runtime->dma_addr + buffer_bytes - 1);
524 spin_unlock_irq(&chip->reg_lock); 494 spin_unlock_irq(&chip->reg_lock);
525 snd_als300_dbgcallleave();
526 return 0; 495 return 0;
527} 496}
528 497
@@ -537,7 +506,6 @@ static int snd_als300_trigger(struct snd_pcm_substream *substream, int cmd)
537 data = substream->runtime->private_data; 506 data = substream->runtime->private_data;
538 reg = data->control_register; 507 reg = data->control_register;
539 508
540 snd_als300_dbgcallenter();
541 spin_lock(&chip->reg_lock); 509 spin_lock(&chip->reg_lock);
542 switch (cmd) { 510 switch (cmd) {
543 case SNDRV_PCM_TRIGGER_START: 511 case SNDRV_PCM_TRIGGER_START:
@@ -568,7 +536,6 @@ static int snd_als300_trigger(struct snd_pcm_substream *substream, int cmd)
568 ret = -EINVAL; 536 ret = -EINVAL;
569 } 537 }
570 spin_unlock(&chip->reg_lock); 538 spin_unlock(&chip->reg_lock);
571 snd_als300_dbgcallleave();
572 return ret; 539 return ret;
573} 540}
574 541
@@ -582,7 +549,6 @@ static snd_pcm_uframes_t snd_als300_pointer(struct snd_pcm_substream *substream)
582 data = substream->runtime->private_data; 549 data = substream->runtime->private_data;
583 period_bytes = snd_pcm_lib_period_bytes(substream); 550 period_bytes = snd_pcm_lib_period_bytes(substream);
584 551
585 snd_als300_dbgcallenter();
586 spin_lock(&chip->reg_lock); 552 spin_lock(&chip->reg_lock);
587 current_ptr = (u16) snd_als300_gcr_read(chip->port, 553 current_ptr = (u16) snd_als300_gcr_read(chip->port,
588 data->block_counter_register) + 4; 554 data->block_counter_register) + 4;
@@ -595,7 +561,6 @@ static snd_pcm_uframes_t snd_als300_pointer(struct snd_pcm_substream *substream)
595 if (data->period_flipflop == 0) 561 if (data->period_flipflop == 0)
596 current_ptr += period_bytes; 562 current_ptr += period_bytes;
597 snd_als300_dbgplay("Pointer (bytes): %d\n", current_ptr); 563 snd_als300_dbgplay("Pointer (bytes): %d\n", current_ptr);
598 snd_als300_dbgcallleave();
599 return bytes_to_frames(substream->runtime, current_ptr); 564 return bytes_to_frames(substream->runtime, current_ptr);
600} 565}
601 566
@@ -626,7 +591,6 @@ static int snd_als300_new_pcm(struct snd_als300 *chip)
626 struct snd_pcm *pcm; 591 struct snd_pcm *pcm;
627 int err; 592 int err;
628 593
629 snd_als300_dbgcallenter();
630 err = snd_pcm_new(chip->card, "ALS300", 0, 1, 1, &pcm); 594 err = snd_pcm_new(chip->card, "ALS300", 0, 1, 1, &pcm);
631 if (err < 0) 595 if (err < 0)
632 return err; 596 return err;
@@ -643,7 +607,6 @@ static int snd_als300_new_pcm(struct snd_als300 *chip)
643 /* pre-allocation of buffers */ 607 /* pre-allocation of buffers */
644 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 608 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
645 snd_dma_pci_data(chip->pci), 64*1024, 64*1024); 609 snd_dma_pci_data(chip->pci), 64*1024, 64*1024);
646 snd_als300_dbgcallleave();
647 return 0; 610 return 0;
648} 611}
649 612
@@ -652,7 +615,6 @@ static void snd_als300_init(struct snd_als300 *chip)
652 unsigned long flags; 615 unsigned long flags;
653 u32 tmp; 616 u32 tmp;
654 617
655 snd_als300_dbgcallenter();
656 spin_lock_irqsave(&chip->reg_lock, flags); 618 spin_lock_irqsave(&chip->reg_lock, flags);
657 chip->revision = (snd_als300_gcr_read(chip->port, MISC_CONTROL) >> 16) 619 chip->revision = (snd_als300_gcr_read(chip->port, MISC_CONTROL) >> 16)
658 & 0x0000000F; 620 & 0x0000000F;
@@ -679,7 +641,6 @@ static void snd_als300_init(struct snd_als300 *chip)
679 snd_als300_gcr_write(chip->port, PLAYBACK_CONTROL, 641 snd_als300_gcr_write(chip->port, PLAYBACK_CONTROL,
680 tmp & ~TRANSFER_START); 642 tmp & ~TRANSFER_START);
681 spin_unlock_irqrestore(&chip->reg_lock, flags); 643 spin_unlock_irqrestore(&chip->reg_lock, flags);
682 snd_als300_dbgcallleave();
683} 644}
684 645
685static int snd_als300_create(struct snd_card *card, 646static int snd_als300_create(struct snd_card *card,
@@ -695,13 +656,12 @@ static int snd_als300_create(struct snd_card *card,
695 }; 656 };
696 *rchip = NULL; 657 *rchip = NULL;
697 658
698 snd_als300_dbgcallenter();
699 if ((err = pci_enable_device(pci)) < 0) 659 if ((err = pci_enable_device(pci)) < 0)
700 return err; 660 return err;
701 661
702 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 662 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
703 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 663 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
704 printk(KERN_ERR "error setting 28bit DMA mask\n"); 664 dev_err(card->dev, "error setting 28bit DMA mask\n");
705 pci_disable_device(pci); 665 pci_disable_device(pci);
706 return -ENXIO; 666 return -ENXIO;
707 } 667 }
@@ -733,7 +693,7 @@ static int snd_als300_create(struct snd_card *card,
733 693
734 if (request_irq(pci->irq, irq_handler, IRQF_SHARED, 694 if (request_irq(pci->irq, irq_handler, IRQF_SHARED,
735 KBUILD_MODNAME, chip)) { 695 KBUILD_MODNAME, chip)) {
736 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 696 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
737 snd_als300_free(chip); 697 snd_als300_free(chip);
738 return -EBUSY; 698 return -EBUSY;
739 } 699 }
@@ -744,13 +704,13 @@ static int snd_als300_create(struct snd_card *card,
744 704
745 err = snd_als300_ac97(chip); 705 err = snd_als300_ac97(chip);
746 if (err < 0) { 706 if (err < 0) {
747 snd_printk(KERN_WARNING "Could not create ac97\n"); 707 dev_err(card->dev, "Could not create ac97\n");
748 snd_als300_free(chip); 708 snd_als300_free(chip);
749 return err; 709 return err;
750 } 710 }
751 711
752 if ((err = snd_als300_new_pcm(chip)) < 0) { 712 if ((err = snd_als300_new_pcm(chip)) < 0) {
753 snd_printk(KERN_WARNING "Could not create PCM\n"); 713 dev_err(card->dev, "Could not create PCM\n");
754 snd_als300_free(chip); 714 snd_als300_free(chip);
755 return err; 715 return err;
756 } 716 }
@@ -761,10 +721,7 @@ static int snd_als300_create(struct snd_card *card,
761 return err; 721 return err;
762 } 722 }
763 723
764 snd_card_set_dev(card, &pci->dev);
765
766 *rchip = chip; 724 *rchip = chip;
767 snd_als300_dbgcallleave();
768 return 0; 725 return 0;
769} 726}
770 727
@@ -794,8 +751,7 @@ static int snd_als300_resume(struct device *dev)
794 pci_set_power_state(pci, PCI_D0); 751 pci_set_power_state(pci, PCI_D0);
795 pci_restore_state(pci); 752 pci_restore_state(pci);
796 if (pci_enable_device(pci) < 0) { 753 if (pci_enable_device(pci) < 0) {
797 printk(KERN_ERR "als300: pci_enable_device failed, " 754 dev_err(dev, "pci_enable_device failed, disabling device\n");
798 "disabling device\n");
799 snd_card_disconnect(card); 755 snd_card_disconnect(card);
800 return -EIO; 756 return -EIO;
801 } 757 }
@@ -829,7 +785,8 @@ static int snd_als300_probe(struct pci_dev *pci,
829 return -ENOENT; 785 return -ENOENT;
830 } 786 }
831 787
832 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 788 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
789 0, &card);
833 790
834 if (err < 0) 791 if (err < 0)
835 return err; 792 return err;
diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c
index ffc821b0139e..b751c381d25e 100644
--- a/sound/pci/als4000.c
+++ b/sound/pci/als4000.c
@@ -578,7 +578,7 @@ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id)
578 snd_als4k_iobase_readb(chip->alt_port, 578 snd_als4k_iobase_readb(chip->alt_port,
579 ALS4K_IOB_16_ACK_FOR_CR1E); 579 ALS4K_IOB_16_ACK_FOR_CR1E);
580 580
581 /* printk(KERN_INFO "als4000: irq 0x%04x 0x%04x\n", 581 /* dev_dbg(chip->card->dev, "als4000: irq 0x%04x 0x%04x\n",
582 pci_irqstatus, sb_irqstatus); */ 582 pci_irqstatus, sb_irqstatus); */
583 583
584 /* only ack the things we actually handled above */ 584 /* only ack the things we actually handled above */
@@ -791,13 +791,13 @@ static int snd_als4000_create_gameport(struct snd_card_als4000 *acard, int dev)
791 } 791 }
792 792
793 if (!r) { 793 if (!r) {
794 printk(KERN_WARNING "als4000: cannot reserve joystick ports\n"); 794 dev_warn(&acard->pci->dev, "cannot reserve joystick ports\n");
795 return -EBUSY; 795 return -EBUSY;
796 } 796 }
797 797
798 acard->gameport = gp = gameport_allocate_port(); 798 acard->gameport = gp = gameport_allocate_port();
799 if (!gp) { 799 if (!gp) {
800 printk(KERN_ERR "als4000: cannot allocate memory for gameport\n"); 800 dev_err(&acard->pci->dev, "cannot allocate memory for gameport\n");
801 release_and_free_resource(r); 801 release_and_free_resource(r);
802 return -ENOMEM; 802 return -ENOMEM;
803 } 803 }
@@ -873,7 +873,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
873 /* check, if we can restrict PCI DMA transfers to 24 bits */ 873 /* check, if we can restrict PCI DMA transfers to 24 bits */
874 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 || 874 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
875 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) { 875 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
876 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n"); 876 dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
877 pci_disable_device(pci); 877 pci_disable_device(pci);
878 return -ENXIO; 878 return -ENXIO;
879 } 879 }
@@ -888,9 +888,9 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
888 pci_write_config_word(pci, PCI_COMMAND, word | PCI_COMMAND_IO); 888 pci_write_config_word(pci, PCI_COMMAND, word | PCI_COMMAND_IO);
889 pci_set_master(pci); 889 pci_set_master(pci);
890 890
891 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 891 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
892 sizeof(*acard) /* private_data: acard */, 892 sizeof(*acard) /* private_data: acard */,
893 &card); 893 &card);
894 if (err < 0) { 894 if (err < 0) {
895 pci_release_regions(pci); 895 pci_release_regions(pci);
896 pci_disable_device(pci); 896 pci_disable_device(pci);
@@ -920,7 +920,6 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
920 920
921 chip->pci = pci; 921 chip->pci = pci;
922 chip->alt_port = iobase; 922 chip->alt_port = iobase;
923 snd_card_set_dev(card, &pci->dev);
924 923
925 snd_als4000_configure(chip); 924 snd_als4000_configure(chip);
926 925
@@ -934,7 +933,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
934 MPU401_INFO_INTEGRATED | 933 MPU401_INFO_INTEGRATED |
935 MPU401_INFO_IRQ_HOOK, 934 MPU401_INFO_IRQ_HOOK,
936 -1, &chip->rmidi)) < 0) { 935 -1, &chip->rmidi)) < 0) {
937 printk(KERN_ERR "als4000: no MPU-401 device at 0x%lx?\n", 936 dev_err(&pci->dev, "no MPU-401 device at 0x%lx?\n",
938 iobase + ALS4K_IOB_30_MIDI_DATA); 937 iobase + ALS4K_IOB_30_MIDI_DATA);
939 goto out_err; 938 goto out_err;
940 } 939 }
@@ -955,7 +954,7 @@ static int snd_card_als4000_probe(struct pci_dev *pci,
955 iobase + ALS4K_IOB_10_ADLIB_ADDR0, 954 iobase + ALS4K_IOB_10_ADLIB_ADDR0,
956 iobase + ALS4K_IOB_12_ADLIB_ADDR2, 955 iobase + ALS4K_IOB_12_ADLIB_ADDR2,
957 OPL3_HW_AUTO, 1, &opl3) < 0) { 956 OPL3_HW_AUTO, 1, &opl3) < 0) {
958 printk(KERN_ERR "als4000: no OPL device at 0x%lx-0x%lx?\n", 957 dev_err(&pci->dev, "no OPL device at 0x%lx-0x%lx?\n",
959 iobase + ALS4K_IOB_10_ADLIB_ADDR0, 958 iobase + ALS4K_IOB_10_ADLIB_ADDR0,
960 iobase + ALS4K_IOB_12_ADLIB_ADDR2); 959 iobase + ALS4K_IOB_12_ADLIB_ADDR2);
961 } else { 960 } else {
@@ -1015,8 +1014,7 @@ static int snd_als4000_resume(struct device *dev)
1015 pci_set_power_state(pci, PCI_D0); 1014 pci_set_power_state(pci, PCI_D0);
1016 pci_restore_state(pci); 1015 pci_restore_state(pci);
1017 if (pci_enable_device(pci) < 0) { 1016 if (pci_enable_device(pci) < 0) {
1018 printk(KERN_ERR "als4000: pci_enable_device failed, " 1017 dev_err(dev, "pci_enable_device failed, disabling device\n");
1019 "disabling device\n");
1020 snd_card_disconnect(card); 1018 snd_card_disconnect(card);
1021 return -EIO; 1019 return -EIO;
1022 } 1020 }
diff --git a/sound/pci/asihpi/asihpi.c b/sound/pci/asihpi/asihpi.c
index 5f2acd35dcb9..901c9490398a 100644
--- a/sound/pci/asihpi/asihpi.c
+++ b/sound/pci/asihpi/asihpi.c
@@ -1253,11 +1253,12 @@ static int snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, int device)
1253 num_outstreams, num_instreams, &pcm); 1253 num_outstreams, num_instreams, &pcm);
1254 if (err < 0) 1254 if (err < 0)
1255 return err; 1255 return err;
1256
1256 /* pointer to ops struct is stored, dont change ops afterwards! */ 1257 /* pointer to ops struct is stored, dont change ops afterwards! */
1257 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, 1258 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
1258 &snd_card_asihpi_playback_mmap_ops); 1259 &snd_card_asihpi_playback_mmap_ops);
1259 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, 1260 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
1260 &snd_card_asihpi_capture_mmap_ops); 1261 &snd_card_asihpi_capture_mmap_ops);
1261 1262
1262 pcm->private_data = asihpi; 1263 pcm->private_data = asihpi;
1263 pcm->info_flags = 0; 1264 pcm->info_flags = 0;
@@ -2827,17 +2828,13 @@ static int snd_asihpi_probe(struct pci_dev *pci_dev,
2827 hpi = pci_get_drvdata(pci_dev); 2828 hpi = pci_get_drvdata(pci_dev);
2828 adapter_index = hpi->adapter->index; 2829 adapter_index = hpi->adapter->index;
2829 /* first try to give the card the same index as its hardware index */ 2830 /* first try to give the card the same index as its hardware index */
2830 err = snd_card_create(adapter_index, 2831 err = snd_card_new(&pci_dev->dev, adapter_index, id[adapter_index],
2831 id[adapter_index], THIS_MODULE, 2832 THIS_MODULE, sizeof(struct snd_card_asihpi), &card);
2832 sizeof(struct snd_card_asihpi),
2833 &card);
2834 if (err < 0) { 2833 if (err < 0) {
2835 /* if that fails, try the default index==next available */ 2834 /* if that fails, try the default index==next available */
2836 err = 2835 err = snd_card_new(&pci_dev->dev, index[dev], id[dev],
2837 snd_card_create(index[dev], id[dev], 2836 THIS_MODULE, sizeof(struct snd_card_asihpi),
2838 THIS_MODULE, 2837 &card);
2839 sizeof(struct snd_card_asihpi),
2840 &card);
2841 if (err < 0) 2838 if (err < 0)
2842 return err; 2839 return err;
2843 snd_printk(KERN_WARNING 2840 snd_printk(KERN_WARNING
@@ -2845,8 +2842,6 @@ static int snd_asihpi_probe(struct pci_dev *pci_dev,
2845 adapter_index, card->number); 2842 adapter_index, card->number);
2846 } 2843 }
2847 2844
2848 snd_card_set_dev(card, &pci_dev->dev);
2849
2850 asihpi = card->private_data; 2845 asihpi = card->private_data;
2851 asihpi->card = card; 2846 asihpi->card = card;
2852 asihpi->pci = pci_dev; 2847 asihpi->pci = pci_dev;
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c
index f6dec3ea371f..ae07b4926dc2 100644
--- a/sound/pci/atiixp.c
+++ b/sound/pci/atiixp.c
@@ -432,7 +432,7 @@ static int snd_atiixp_acquire_codec(struct atiixp *chip)
432 432
433 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) { 433 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) {
434 if (! timeout--) { 434 if (! timeout--) {
435 snd_printk(KERN_WARNING "atiixp: codec acquire timeout\n"); 435 dev_warn(chip->card->dev, "codec acquire timeout\n");
436 return -EBUSY; 436 return -EBUSY;
437 } 437 }
438 udelay(1); 438 udelay(1);
@@ -463,7 +463,7 @@ static unsigned short snd_atiixp_codec_read(struct atiixp *chip, unsigned short
463 } while (--timeout); 463 } while (--timeout);
464 /* time out may happen during reset */ 464 /* time out may happen during reset */
465 if (reg < 0x7c) 465 if (reg < 0x7c)
466 snd_printk(KERN_WARNING "atiixp: codec read timeout (reg %x)\n", reg); 466 dev_warn(chip->card->dev, "codec read timeout (reg %x)\n", reg);
467 return 0xffff; 467 return 0xffff;
468} 468}
469 469
@@ -523,7 +523,7 @@ static int snd_atiixp_aclink_reset(struct atiixp *chip)
523 mdelay(1); 523 mdelay(1);
524 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); 524 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
525 if (!--timeout) { 525 if (!--timeout) {
526 snd_printk(KERN_ERR "atiixp: codec reset timeout\n"); 526 dev_err(chip->card->dev, "codec reset timeout\n");
527 break; 527 break;
528 } 528 }
529 } 529 }
@@ -567,9 +567,8 @@ static int ac97_probing_bugs(struct pci_dev *pci)
567 567
568 q = snd_pci_quirk_lookup(pci, atiixp_quirks); 568 q = snd_pci_quirk_lookup(pci, atiixp_quirks);
569 if (q) { 569 if (q) {
570 snd_printdd(KERN_INFO 570 dev_dbg(&pci->dev, "atiixp quirk for %s. Forcing codec %d\n",
571 "Atiixp quirk for %s. Forcing codec %d\n", 571 snd_pci_quirk_name(q), q->value);
572 snd_pci_quirk_name(q), q->value);
573 return q->value; 572 return q->value;
574 } 573 }
575 /* this hardware doesn't need workarounds. Probe for codec */ 574 /* this hardware doesn't need workarounds. Probe for codec */
@@ -600,7 +599,7 @@ static int snd_atiixp_codec_detect(struct atiixp *chip)
600 atiixp_write(chip, IER, 0); /* disable irqs */ 599 atiixp_write(chip, IER, 0); /* disable irqs */
601 600
602 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) { 601 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) {
603 snd_printk(KERN_ERR "atiixp: no codec detected!\n"); 602 dev_err(chip->card->dev, "no codec detected!\n");
604 return -ENXIO; 603 return -ENXIO;
605 } 604 }
606 return 0; 605 return 0;
@@ -676,7 +675,7 @@ static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substr
676 continue; 675 continue;
677 return bytes_to_frames(runtime, curptr); 676 return bytes_to_frames(runtime, curptr);
678 } 677 }
679 snd_printd("atiixp: invalid DMA pointer read 0x%x (buf=%x)\n", 678 dev_dbg(chip->card->dev, "invalid DMA pointer read 0x%x (buf=%x)\n",
680 readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr); 679 readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);
681 return 0; 680 return 0;
682} 681}
@@ -688,7 +687,7 @@ static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma)
688{ 687{
689 if (! dma->substream || ! dma->running) 688 if (! dma->substream || ! dma->running)
690 return; 689 return;
691 snd_printdd("atiixp: XRUN detected (DMA %d)\n", dma->ops->type); 690 dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type);
692 snd_pcm_stream_lock(dma->substream); 691 snd_pcm_stream_lock(dma->substream);
693 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); 692 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
694 snd_pcm_stream_unlock(dma->substream); 693 snd_pcm_stream_unlock(dma->substream);
@@ -1453,14 +1452,15 @@ static int snd_atiixp_mixer_new(struct atiixp *chip, int clock,
1453 ac97.scaps |= AC97_SCAP_NO_SPDIF; 1452 ac97.scaps |= AC97_SCAP_NO_SPDIF;
1454 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { 1453 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
1455 chip->ac97[i] = NULL; /* to be sure */ 1454 chip->ac97[i] = NULL; /* to be sure */
1456 snd_printdd("atiixp: codec %d not available for audio\n", i); 1455 dev_dbg(chip->card->dev,
1456 "codec %d not available for audio\n", i);
1457 continue; 1457 continue;
1458 } 1458 }
1459 codec_count++; 1459 codec_count++;
1460 } 1460 }
1461 1461
1462 if (! codec_count) { 1462 if (! codec_count) {
1463 snd_printk(KERN_ERR "atiixp: no codec available\n"); 1463 dev_err(chip->card->dev, "no codec available\n");
1464 return -ENODEV; 1464 return -ENODEV;
1465 } 1465 }
1466 1466
@@ -1511,8 +1511,7 @@ static int snd_atiixp_resume(struct device *dev)
1511 pci_set_power_state(pci, PCI_D0); 1511 pci_set_power_state(pci, PCI_D0);
1512 pci_restore_state(pci); 1512 pci_restore_state(pci);
1513 if (pci_enable_device(pci) < 0) { 1513 if (pci_enable_device(pci) < 0) {
1514 printk(KERN_ERR "atiixp: pci_enable_device failed, " 1514 dev_err(dev, "pci_enable_device failed, disabling device\n");
1515 "disabling device\n");
1516 snd_card_disconnect(card); 1515 snd_card_disconnect(card);
1517 return -EIO; 1516 return -EIO;
1518 } 1517 }
@@ -1637,14 +1636,14 @@ static int snd_atiixp_create(struct snd_card *card,
1637 chip->addr = pci_resource_start(pci, 0); 1636 chip->addr = pci_resource_start(pci, 0);
1638 chip->remap_addr = pci_ioremap_bar(pci, 0); 1637 chip->remap_addr = pci_ioremap_bar(pci, 0);
1639 if (chip->remap_addr == NULL) { 1638 if (chip->remap_addr == NULL) {
1640 snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); 1639 dev_err(card->dev, "AC'97 space ioremap problem\n");
1641 snd_atiixp_free(chip); 1640 snd_atiixp_free(chip);
1642 return -EIO; 1641 return -EIO;
1643 } 1642 }
1644 1643
1645 if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED, 1644 if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED,
1646 KBUILD_MODNAME, chip)) { 1645 KBUILD_MODNAME, chip)) {
1647 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1646 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1648 snd_atiixp_free(chip); 1647 snd_atiixp_free(chip);
1649 return -EBUSY; 1648 return -EBUSY;
1650 } 1649 }
@@ -1657,8 +1656,6 @@ static int snd_atiixp_create(struct snd_card *card,
1657 return err; 1656 return err;
1658 } 1657 }
1659 1658
1660 snd_card_set_dev(card, &pci->dev);
1661
1662 *r_chip = chip; 1659 *r_chip = chip;
1663 return 0; 1660 return 0;
1664} 1661}
@@ -1671,7 +1668,7 @@ static int snd_atiixp_probe(struct pci_dev *pci,
1671 struct atiixp *chip; 1668 struct atiixp *chip;
1672 int err; 1669 int err;
1673 1670
1674 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 1671 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
1675 if (err < 0) 1672 if (err < 0)
1676 return err; 1673 return err;
1677 1674
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c
index 289563ecb6dd..b9dc96c5d21e 100644
--- a/sound/pci/atiixp_modem.c
+++ b/sound/pci/atiixp_modem.c
@@ -400,7 +400,7 @@ static int snd_atiixp_acquire_codec(struct atiixp_modem *chip)
400 400
401 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) { 401 while (atiixp_read(chip, PHYS_OUT_ADDR) & ATI_REG_PHYS_OUT_ADDR_EN) {
402 if (! timeout--) { 402 if (! timeout--) {
403 snd_printk(KERN_WARNING "atiixp-modem: codec acquire timeout\n"); 403 dev_warn(chip->card->dev, "codec acquire timeout\n");
404 return -EBUSY; 404 return -EBUSY;
405 } 405 }
406 udelay(1); 406 udelay(1);
@@ -433,7 +433,7 @@ static unsigned short snd_atiixp_codec_read(struct atiixp_modem *chip,
433 } while (--timeout); 433 } while (--timeout);
434 /* time out may happen during reset */ 434 /* time out may happen during reset */
435 if (reg < 0x7c) 435 if (reg < 0x7c)
436 snd_printk(KERN_WARNING "atiixp-modem: codec read timeout (reg %x)\n", reg); 436 dev_warn(chip->card->dev, "codec read timeout (reg %x)\n", reg);
437 return 0xffff; 437 return 0xffff;
438} 438}
439 439
@@ -499,7 +499,7 @@ static int snd_atiixp_aclink_reset(struct atiixp_modem *chip)
499 msleep(1); 499 msleep(1);
500 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); 500 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
501 if (!--timeout) { 501 if (!--timeout) {
502 snd_printk(KERN_ERR "atiixp-modem: codec reset timeout\n"); 502 dev_err(chip->card->dev, "codec reset timeout\n");
503 break; 503 break;
504 } 504 }
505 } 505 }
@@ -553,7 +553,7 @@ static int snd_atiixp_codec_detect(struct atiixp_modem *chip)
553 atiixp_write(chip, IER, 0); /* disable irqs */ 553 atiixp_write(chip, IER, 0); /* disable irqs */
554 554
555 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) { 555 if ((chip->codec_not_ready_bits & ALL_CODEC_NOT_READY) == ALL_CODEC_NOT_READY) {
556 snd_printk(KERN_ERR "atiixp-modem: no codec detected!\n"); 556 dev_err(chip->card->dev, "no codec detected!\n");
557 return -ENXIO; 557 return -ENXIO;
558 } 558 }
559 return 0; 559 return 0;
@@ -624,7 +624,7 @@ static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substr
624 continue; 624 continue;
625 return bytes_to_frames(runtime, curptr); 625 return bytes_to_frames(runtime, curptr);
626 } 626 }
627 snd_printd("atiixp-modem: invalid DMA pointer read 0x%x (buf=%x)\n", 627 dev_dbg(chip->card->dev, "invalid DMA pointer read 0x%x (buf=%x)\n",
628 readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr); 628 readl(chip->remap_addr + dma->ops->dt_cur), dma->buf_addr);
629 return 0; 629 return 0;
630} 630}
@@ -637,7 +637,7 @@ static void snd_atiixp_xrun_dma(struct atiixp_modem *chip,
637{ 637{
638 if (! dma->substream || ! dma->running) 638 if (! dma->substream || ! dma->running)
639 return; 639 return;
640 snd_printdd("atiixp-modem: XRUN detected (DMA %d)\n", dma->ops->type); 640 dev_dbg(chip->card->dev, "XRUN detected (DMA %d)\n", dma->ops->type);
641 snd_pcm_stream_lock(dma->substream); 641 snd_pcm_stream_lock(dma->substream);
642 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN); 642 snd_pcm_stop(dma->substream, SNDRV_PCM_STATE_XRUN);
643 snd_pcm_stream_unlock(dma->substream); 643 snd_pcm_stream_unlock(dma->substream);
@@ -1098,14 +1098,15 @@ static int snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock)
1098 ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE; 1098 ac97.scaps = AC97_SCAP_SKIP_AUDIO | AC97_SCAP_POWER_SAVE;
1099 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { 1099 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
1100 chip->ac97[i] = NULL; /* to be sure */ 1100 chip->ac97[i] = NULL; /* to be sure */
1101 snd_printdd("atiixp-modem: codec %d not available for modem\n", i); 1101 dev_dbg(chip->card->dev,
1102 "codec %d not available for modem\n", i);
1102 continue; 1103 continue;
1103 } 1104 }
1104 codec_count++; 1105 codec_count++;
1105 } 1106 }
1106 1107
1107 if (! codec_count) { 1108 if (! codec_count) {
1108 snd_printk(KERN_ERR "atiixp-modem: no codec available\n"); 1109 dev_err(chip->card->dev, "no codec available\n");
1109 return -ENODEV; 1110 return -ENODEV;
1110 } 1111 }
1111 1112
@@ -1150,8 +1151,7 @@ static int snd_atiixp_resume(struct device *dev)
1150 pci_set_power_state(pci, PCI_D0); 1151 pci_set_power_state(pci, PCI_D0);
1151 pci_restore_state(pci); 1152 pci_restore_state(pci);
1152 if (pci_enable_device(pci) < 0) { 1153 if (pci_enable_device(pci) < 0) {
1153 printk(KERN_ERR "atiixp-modem: pci_enable_device failed, " 1154 dev_err(dev, "pci_enable_device failed, disabling device\n");
1154 "disabling device\n");
1155 snd_card_disconnect(card); 1155 snd_card_disconnect(card);
1156 return -EIO; 1156 return -EIO;
1157 } 1157 }
@@ -1262,14 +1262,14 @@ static int snd_atiixp_create(struct snd_card *card,
1262 chip->addr = pci_resource_start(pci, 0); 1262 chip->addr = pci_resource_start(pci, 0);
1263 chip->remap_addr = pci_ioremap_bar(pci, 0); 1263 chip->remap_addr = pci_ioremap_bar(pci, 0);
1264 if (chip->remap_addr == NULL) { 1264 if (chip->remap_addr == NULL) {
1265 snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); 1265 dev_err(card->dev, "AC'97 space ioremap problem\n");
1266 snd_atiixp_free(chip); 1266 snd_atiixp_free(chip);
1267 return -EIO; 1267 return -EIO;
1268 } 1268 }
1269 1269
1270 if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED, 1270 if (request_irq(pci->irq, snd_atiixp_interrupt, IRQF_SHARED,
1271 KBUILD_MODNAME, chip)) { 1271 KBUILD_MODNAME, chip)) {
1272 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1272 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1273 snd_atiixp_free(chip); 1273 snd_atiixp_free(chip);
1274 return -EBUSY; 1274 return -EBUSY;
1275 } 1275 }
@@ -1282,8 +1282,6 @@ static int snd_atiixp_create(struct snd_card *card,
1282 return err; 1282 return err;
1283 } 1283 }
1284 1284
1285 snd_card_set_dev(card, &pci->dev);
1286
1287 *r_chip = chip; 1285 *r_chip = chip;
1288 return 0; 1286 return 0;
1289} 1287}
@@ -1296,7 +1294,7 @@ static int snd_atiixp_probe(struct pci_dev *pci,
1296 struct atiixp_modem *chip; 1294 struct atiixp_modem *chip;
1297 int err; 1295 int err;
1298 1296
1299 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 1297 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
1300 if (err < 0) 1298 if (err < 0)
1301 return err; 1299 return err;
1302 1300
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 7059dd69e5e6..afb1b44b741e 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -211,8 +211,6 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
211 goto alloc_out; 211 goto alloc_out;
212 } 212 }
213 213
214 snd_card_set_dev(card, &pci->dev);
215
216 *rchip = chip; 214 *rchip = chip;
217 215
218 return 0; 216 return 0;
@@ -250,7 +248,8 @@ snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
250 return -ENOENT; 248 return -ENOENT;
251 } 249 }
252 // (2) 250 // (2)
253 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 251 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
252 0, &card);
254 if (err < 0) 253 if (err < 0)
255 return err; 254 return err;
256 255
diff --git a/sound/pci/aw2/aw2-alsa.c b/sound/pci/aw2/aw2-alsa.c
index 2925220d3fcf..120d0d320a60 100644
--- a/sound/pci/aw2/aw2-alsa.c
+++ b/sound/pci/aw2/aw2-alsa.c
@@ -262,7 +262,7 @@ static int snd_aw2_create(struct snd_card *card,
262 /* check PCI availability (32bit DMA) */ 262 /* check PCI availability (32bit DMA) */
263 if ((pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) || 263 if ((pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) ||
264 (pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0)) { 264 (pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0)) {
265 printk(KERN_ERR "aw2: Impossible to set 32bit mask DMA\n"); 265 dev_err(card->dev, "Impossible to set 32bit mask DMA\n");
266 pci_disable_device(pci); 266 pci_disable_device(pci);
267 return -ENXIO; 267 return -ENXIO;
268 } 268 }
@@ -290,7 +290,7 @@ static int snd_aw2_create(struct snd_card *card,
290 pci_resource_len(pci, 0)); 290 pci_resource_len(pci, 0));
291 291
292 if (chip->iobase_virt == NULL) { 292 if (chip->iobase_virt == NULL) {
293 printk(KERN_ERR "aw2: unable to remap memory region"); 293 dev_err(card->dev, "unable to remap memory region");
294 pci_release_regions(pci); 294 pci_release_regions(pci);
295 pci_disable_device(pci); 295 pci_disable_device(pci);
296 kfree(chip); 296 kfree(chip);
@@ -302,7 +302,7 @@ static int snd_aw2_create(struct snd_card *card,
302 302
303 if (request_irq(pci->irq, snd_aw2_saa7146_interrupt, 303 if (request_irq(pci->irq, snd_aw2_saa7146_interrupt,
304 IRQF_SHARED, KBUILD_MODNAME, chip)) { 304 IRQF_SHARED, KBUILD_MODNAME, chip)) {
305 printk(KERN_ERR "aw2: Cannot grab irq %d\n", pci->irq); 305 dev_err(card->dev, "Cannot grab irq %d\n", pci->irq);
306 306
307 iounmap(chip->iobase_virt); 307 iounmap(chip->iobase_virt);
308 pci_release_regions(chip->pci); 308 pci_release_regions(chip->pci);
@@ -322,12 +322,10 @@ static int snd_aw2_create(struct snd_card *card,
322 return err; 322 return err;
323 } 323 }
324 324
325 snd_card_set_dev(card, &pci->dev);
326 *rchip = chip; 325 *rchip = chip;
327 326
328 printk(KERN_INFO 327 dev_info(card->dev,
329 "Audiowerk 2 sound card (saa7146 chipset) detected and " 328 "Audiowerk 2 sound card (saa7146 chipset) detected and managed\n");
330 "managed\n");
331 return 0; 329 return 0;
332} 330}
333 331
@@ -349,7 +347,8 @@ static int snd_aw2_probe(struct pci_dev *pci,
349 } 347 }
350 348
351 /* (2) Create card instance */ 349 /* (2) Create card instance */
352 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 350 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
351 0, &card);
353 if (err < 0) 352 if (err < 0)
354 return err; 353 return err;
355 354
@@ -399,7 +398,7 @@ static int snd_aw2_pcm_playback_open(struct snd_pcm_substream *substream)
399{ 398{
400 struct snd_pcm_runtime *runtime = substream->runtime; 399 struct snd_pcm_runtime *runtime = substream->runtime;
401 400
402 snd_printdd(KERN_DEBUG "aw2: Playback_open\n"); 401 dev_dbg(substream->pcm->card->dev, "Playback_open\n");
403 runtime->hw = snd_aw2_playback_hw; 402 runtime->hw = snd_aw2_playback_hw;
404 return 0; 403 return 0;
405} 404}
@@ -415,7 +414,7 @@ static int snd_aw2_pcm_capture_open(struct snd_pcm_substream *substream)
415{ 414{
416 struct snd_pcm_runtime *runtime = substream->runtime; 415 struct snd_pcm_runtime *runtime = substream->runtime;
417 416
418 snd_printdd(KERN_DEBUG "aw2: Capture_open\n"); 417 dev_dbg(substream->pcm->card->dev, "Capture_open\n");
419 runtime->hw = snd_aw2_capture_hw; 418 runtime->hw = snd_aw2_capture_hw;
420 return 0; 419 return 0;
421} 420}
@@ -603,7 +602,7 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
603 err = snd_pcm_new(chip->card, "Audiowerk2 analog playback", 0, 1, 0, 602 err = snd_pcm_new(chip->card, "Audiowerk2 analog playback", 0, 1, 0,
604 &pcm_playback_ana); 603 &pcm_playback_ana);
605 if (err < 0) { 604 if (err < 0) {
606 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err); 605 dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
607 return err; 606 return err;
608 } 607 }
609 608
@@ -633,14 +632,15 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
633 (chip->pci), 632 (chip->pci),
634 64 * 1024, 64 * 1024); 633 64 * 1024, 64 * 1024);
635 if (err) 634 if (err)
636 printk(KERN_ERR "aw2: snd_pcm_lib_preallocate_pages_for_all " 635 dev_err(chip->card->dev,
637 "error (0x%X)\n", err); 636 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
637 err);
638 638
639 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0, 639 err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0,
640 &pcm_playback_num); 640 &pcm_playback_num);
641 641
642 if (err < 0) { 642 if (err < 0) {
643 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err); 643 dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
644 return err; 644 return err;
645 } 645 }
646 /* Creation ok */ 646 /* Creation ok */
@@ -669,17 +669,15 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
669 (chip->pci), 669 (chip->pci),
670 64 * 1024, 64 * 1024); 670 64 * 1024, 64 * 1024);
671 if (err) 671 if (err)
672 printk(KERN_ERR 672 dev_err(chip->card->dev,
673 "aw2: snd_pcm_lib_preallocate_pages_for_all error " 673 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
674 "(0x%X)\n", err); 674 err);
675
676
677 675
678 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1, 676 err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1,
679 &pcm_capture); 677 &pcm_capture);
680 678
681 if (err < 0) { 679 if (err < 0) {
682 printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err); 680 dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err);
683 return err; 681 return err;
684 } 682 }
685 683
@@ -709,15 +707,15 @@ static int snd_aw2_new_pcm(struct aw2 *chip)
709 (chip->pci), 707 (chip->pci),
710 64 * 1024, 64 * 1024); 708 64 * 1024, 64 * 1024);
711 if (err) 709 if (err)
712 printk(KERN_ERR 710 dev_err(chip->card->dev,
713 "aw2: snd_pcm_lib_preallocate_pages_for_all error " 711 "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n",
714 "(0x%X)\n", err); 712 err);
715 713
716 714
717 /* Create control */ 715 /* Create control */
718 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip)); 716 err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip));
719 if (err < 0) { 717 if (err < 0) {
720 printk(KERN_ERR "aw2: snd_ctl_add error (0x%X)\n", err); 718 dev_err(chip->card->dev, "snd_ctl_add error (0x%X)\n", err);
721 return err; 719 return err;
722 } 720 }
723 721
diff --git a/sound/pci/aw2/aw2-saa7146.c b/sound/pci/aw2/aw2-saa7146.c
index 4439636971eb..6d24e9536777 100644
--- a/sound/pci/aw2/aw2-saa7146.c
+++ b/sound/pci/aw2/aw2-saa7146.c
@@ -204,8 +204,7 @@ void snd_aw2_saa7146_pcm_init_playback(struct snd_aw2_saa7146 *chip,
204 /* Define upper limit for DMA access */ 204 /* Define upper limit for DMA access */
205 WRITEREG(dma_addr + buffer_size, ProtA1_out); 205 WRITEREG(dma_addr + buffer_size, ProtA1_out);
206 } else { 206 } else {
207 printk(KERN_ERR 207 pr_err("aw2: snd_aw2_saa7146_pcm_init_playback: "
208 "aw2: snd_aw2_saa7146_pcm_init_playback: "
209 "Substream number is not 0 or 1 -> not managed\n"); 208 "Substream number is not 0 or 1 -> not managed\n");
210 } 209 }
211} 210}
@@ -251,8 +250,7 @@ void snd_aw2_saa7146_pcm_init_capture(struct snd_aw2_saa7146 *chip,
251 /* Define upper limit for DMA access */ 250 /* Define upper limit for DMA access */
252 WRITEREG(dma_addr + buffer_size, ProtA1_in); 251 WRITEREG(dma_addr + buffer_size, ProtA1_in);
253 } else { 252 } else {
254 printk(KERN_ERR 253 pr_err("aw2: snd_aw2_saa7146_pcm_init_capture: "
255 "aw2: snd_aw2_saa7146_pcm_init_capture: "
256 "Substream number is not 0 -> not managed\n"); 254 "Substream number is not 0 -> not managed\n");
257 } 255 }
258} 256}
diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c
index 1aef7128f7ca..c9216c0a9c8b 100644
--- a/sound/pci/azt3328.c
+++ b/sound/pci/azt3328.c
@@ -238,61 +238,6 @@ MODULE_SUPPORTED_DEVICE("{{Aztech,AZF3328}}");
238 2>/dev/null 238 2>/dev/null
239*/ 239*/
240 240
241#define DEBUG_MISC 0
242#define DEBUG_CALLS 0
243#define DEBUG_MIXER 0
244#define DEBUG_CODEC 0
245#define DEBUG_TIMER 0
246#define DEBUG_GAME 0
247#define DEBUG_PM 0
248#define MIXER_TESTING 0
249
250#if DEBUG_MISC
251#define snd_azf3328_dbgmisc(format, args...) printk(KERN_DEBUG format, ##args)
252#else
253#define snd_azf3328_dbgmisc(format, args...)
254#endif
255
256#if DEBUG_CALLS
257#define snd_azf3328_dbgcalls(format, args...) printk(format, ##args)
258#define snd_azf3328_dbgcallenter() printk(KERN_DEBUG "--> %s\n", __func__)
259#define snd_azf3328_dbgcallleave() printk(KERN_DEBUG "<-- %s\n", __func__)
260#else
261#define snd_azf3328_dbgcalls(format, args...)
262#define snd_azf3328_dbgcallenter()
263#define snd_azf3328_dbgcallleave()
264#endif
265
266#if DEBUG_MIXER
267#define snd_azf3328_dbgmixer(format, args...) printk(KERN_DEBUG format, ##args)
268#else
269#define snd_azf3328_dbgmixer(format, args...)
270#endif
271
272#if DEBUG_CODEC
273#define snd_azf3328_dbgcodec(format, args...) printk(KERN_DEBUG format, ##args)
274#else
275#define snd_azf3328_dbgcodec(format, args...)
276#endif
277
278#if DEBUG_MISC
279#define snd_azf3328_dbgtimer(format, args...) printk(KERN_DEBUG format, ##args)
280#else
281#define snd_azf3328_dbgtimer(format, args...)
282#endif
283
284#if DEBUG_GAME
285#define snd_azf3328_dbggame(format, args...) printk(KERN_DEBUG format, ##args)
286#else
287#define snd_azf3328_dbggame(format, args...)
288#endif
289
290#if DEBUG_PM
291#define snd_azf3328_dbgpm(format, args...) printk(KERN_DEBUG format, ##args)
292#else
293#define snd_azf3328_dbgpm(format, args...)
294#endif
295
296static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 241static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
297module_param_array(index, int, NULL, 0444); 242module_param_array(index, int, NULL, 0444);
298MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard."); 243MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard.");
@@ -475,6 +420,12 @@ snd_azf3328_ctrl_inb(const struct snd_azf3328 *chip, unsigned reg)
475 return inb(chip->ctrl_io + reg); 420 return inb(chip->ctrl_io + reg);
476} 421}
477 422
423static inline u16
424snd_azf3328_ctrl_inw(const struct snd_azf3328 *chip, unsigned reg)
425{
426 return inw(chip->ctrl_io + reg);
427}
428
478static inline void 429static inline void
479snd_azf3328_ctrl_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value) 430snd_azf3328_ctrl_outw(const struct snd_azf3328 *chip, unsigned reg, u16 value)
480{ 431{
@@ -578,11 +529,12 @@ snd_azf3328_mixer_reset(const struct snd_azf3328 *chip)
578#ifdef AZF_USE_AC97_LAYER 529#ifdef AZF_USE_AC97_LAYER
579 530
580static inline void 531static inline void
581snd_azf3328_mixer_ac97_map_unsupported(unsigned short reg, const char *mode) 532snd_azf3328_mixer_ac97_map_unsupported(const struct snd_azf3328 *chip,
533 unsigned short reg, const char *mode)
582{ 534{
583 /* need to add some more or less clever emulation? */ 535 /* need to add some more or less clever emulation? */
584 printk(KERN_WARNING 536 dev_warn(chip->card->dev,
585 "azt3328: missing %s emulation for AC97 register 0x%02x!\n", 537 "missing %s emulation for AC97 register 0x%02x!\n",
586 mode, reg); 538 mode, reg);
587} 539}
588 540
@@ -717,10 +669,8 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97)
717 unsigned short reg_val = 0; 669 unsigned short reg_val = 0;
718 bool unsupported = false; 670 bool unsupported = false;
719 671
720 snd_azf3328_dbgmixer( 672 dev_dbg(chip->card->dev, "snd_azf3328_mixer_ac97_read reg_ac97 %u\n",
721 "snd_azf3328_mixer_ac97_read reg_ac97 %u\n", 673 reg_ac97);
722 reg_ac97
723 );
724 if (reg_azf & AZF_AC97_REG_UNSUPPORTED) 674 if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
725 unsupported = true; 675 unsupported = true;
726 else { 676 else {
@@ -765,7 +715,7 @@ snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97)
765 } 715 }
766 } 716 }
767 if (unsupported) 717 if (unsupported)
768 snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "read"); 718 snd_azf3328_mixer_ac97_map_unsupported(chip, reg_ac97, "read");
769 719
770 return reg_val; 720 return reg_val;
771} 721}
@@ -778,10 +728,9 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97,
778 unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97); 728 unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97);
779 bool unsupported = false; 729 bool unsupported = false;
780 730
781 snd_azf3328_dbgmixer( 731 dev_dbg(chip->card->dev,
782 "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n", 732 "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n",
783 reg_ac97, val 733 reg_ac97, val);
784 );
785 if (reg_azf & AZF_AC97_REG_UNSUPPORTED) 734 if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
786 unsupported = true; 735 unsupported = true;
787 else { 736 else {
@@ -814,7 +763,7 @@ snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97,
814 } 763 }
815 } 764 }
816 if (unsupported) 765 if (unsupported)
817 snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "write"); 766 snd_azf3328_mixer_ac97_map_unsupported(chip, reg_ac97, "write");
818} 767}
819 768
820static int 769static int
@@ -850,7 +799,7 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
850 * due to this card being a very quirky AC97 "lookalike". 799 * due to this card being a very quirky AC97 "lookalike".
851 */ 800 */
852 if (rc) 801 if (rc)
853 printk(KERN_ERR "azt3328: AC97 init failed, err %d!\n", rc); 802 dev_err(chip->card->dev, "AC97 init failed, err %d!\n", rc);
854 803
855 /* If we return an error here, then snd_card_free() should 804 /* If we return an error here, then snd_card_free() should
856 * free up any ac97 codecs that got created, as well as the bus. 805 * free up any ac97 codecs that got created, as well as the bus.
@@ -870,8 +819,6 @@ snd_azf3328_mixer_write_volume_gradually(const struct snd_azf3328 *chip,
870 unsigned char curr_vol_left = 0, curr_vol_right = 0; 819 unsigned char curr_vol_left = 0, curr_vol_right = 0;
871 int left_change = 0, right_change = 0; 820 int left_change = 0, right_change = 0;
872 821
873 snd_azf3328_dbgcallenter();
874
875 if (chan_sel & SET_CHAN_LEFT) { 822 if (chan_sel & SET_CHAN_LEFT) {
876 curr_vol_left = inb(portbase + 1); 823 curr_vol_left = inb(portbase + 1);
877 824
@@ -912,7 +859,6 @@ snd_azf3328_mixer_write_volume_gradually(const struct snd_azf3328 *chip,
912 if (delay) 859 if (delay)
913 mdelay(delay); 860 mdelay(delay);
914 } while ((left_change) || (right_change)); 861 } while ((left_change) || (right_change));
915 snd_azf3328_dbgcallleave();
916} 862}
917 863
918/* 864/*
@@ -990,14 +936,12 @@ snd_azf3328_info_mixer(struct snd_kcontrol *kcontrol,
990{ 936{
991 struct azf3328_mixer_reg reg; 937 struct azf3328_mixer_reg reg;
992 938
993 snd_azf3328_dbgcallenter();
994 snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value); 939 snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value);
995 uinfo->type = reg.mask == 1 ? 940 uinfo->type = reg.mask == 1 ?
996 SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; 941 SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
997 uinfo->count = reg.stereo + 1; 942 uinfo->count = reg.stereo + 1;
998 uinfo->value.integer.min = 0; 943 uinfo->value.integer.min = 0;
999 uinfo->value.integer.max = reg.mask; 944 uinfo->value.integer.max = reg.mask;
1000 snd_azf3328_dbgcallleave();
1001 return 0; 945 return 0;
1002} 946}
1003 947
@@ -1009,7 +953,6 @@ snd_azf3328_get_mixer(struct snd_kcontrol *kcontrol,
1009 struct azf3328_mixer_reg reg; 953 struct azf3328_mixer_reg reg;
1010 u16 oreg, val; 954 u16 oreg, val;
1011 955
1012 snd_azf3328_dbgcallenter();
1013 snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value); 956 snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value);
1014 957
1015 oreg = snd_azf3328_mixer_inw(chip, reg.reg); 958 oreg = snd_azf3328_mixer_inw(chip, reg.reg);
@@ -1023,12 +966,11 @@ snd_azf3328_get_mixer(struct snd_kcontrol *kcontrol,
1023 val = reg.mask - val; 966 val = reg.mask - val;
1024 ucontrol->value.integer.value[1] = val; 967 ucontrol->value.integer.value[1] = val;
1025 } 968 }
1026 snd_azf3328_dbgmixer("get: %02x is %04x -> vol %02lx|%02lx " 969 dev_dbg(chip->card->dev,
1027 "(shift %02d|%02d, mask %02x, inv. %d, stereo %d)\n", 970 "get: %02x is %04x -> vol %02lx|%02lx (shift %02d|%02d, mask %02x, inv. %d, stereo %d)\n",
1028 reg.reg, oreg, 971 reg.reg, oreg,
1029 ucontrol->value.integer.value[0], ucontrol->value.integer.value[1], 972 ucontrol->value.integer.value[0], ucontrol->value.integer.value[1],
1030 reg.lchan_shift, reg.rchan_shift, reg.mask, reg.invert, reg.stereo); 973 reg.lchan_shift, reg.rchan_shift, reg.mask, reg.invert, reg.stereo);
1031 snd_azf3328_dbgcallleave();
1032 return 0; 974 return 0;
1033} 975}
1034 976
@@ -1040,7 +982,6 @@ snd_azf3328_put_mixer(struct snd_kcontrol *kcontrol,
1040 struct azf3328_mixer_reg reg; 982 struct azf3328_mixer_reg reg;
1041 u16 oreg, nreg, val; 983 u16 oreg, nreg, val;
1042 984
1043 snd_azf3328_dbgcallenter();
1044 snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value); 985 snd_azf3328_mixer_reg_decode(&reg, kcontrol->private_value);
1045 oreg = snd_azf3328_mixer_inw(chip, reg.reg); 986 oreg = snd_azf3328_mixer_inw(chip, reg.reg);
1046 val = ucontrol->value.integer.value[0] & reg.mask; 987 val = ucontrol->value.integer.value[0] & reg.mask;
@@ -1064,12 +1005,11 @@ snd_azf3328_put_mixer(struct snd_kcontrol *kcontrol,
1064 else 1005 else
1065 snd_azf3328_mixer_outw(chip, reg.reg, nreg); 1006 snd_azf3328_mixer_outw(chip, reg.reg, nreg);
1066 1007
1067 snd_azf3328_dbgmixer("put: %02x to %02lx|%02lx, " 1008 dev_dbg(chip->card->dev,
1068 "oreg %04x; shift %02d|%02d -> nreg %04x; after: %04x\n", 1009 "put: %02x to %02lx|%02lx, oreg %04x; shift %02d|%02d -> nreg %04x; after: %04x\n",
1069 reg.reg, ucontrol->value.integer.value[0], ucontrol->value.integer.value[1], 1010 reg.reg, ucontrol->value.integer.value[0], ucontrol->value.integer.value[1],
1070 oreg, reg.lchan_shift, reg.rchan_shift, 1011 oreg, reg.lchan_shift, reg.rchan_shift,
1071 nreg, snd_azf3328_mixer_inw(chip, reg.reg)); 1012 nreg, snd_azf3328_mixer_inw(chip, reg.reg));
1072 snd_azf3328_dbgcallleave();
1073 return (nreg != oreg); 1013 return (nreg != oreg);
1074} 1014}
1075 1015
@@ -1135,7 +1075,8 @@ snd_azf3328_get_mixer_enum(struct snd_kcontrol *kcontrol,
1135 } else 1075 } else
1136 ucontrol->value.enumerated.item[0] = (val >> reg.lchan_shift) & (reg.enum_c - 1); 1076 ucontrol->value.enumerated.item[0] = (val >> reg.lchan_shift) & (reg.enum_c - 1);
1137 1077
1138 snd_azf3328_dbgmixer("get_enum: %02x is %04x -> %d|%d (shift %02d, enum_c %d)\n", 1078 dev_dbg(chip->card->dev,
1079 "get_enum: %02x is %04x -> %d|%d (shift %02d, enum_c %d)\n",
1139 reg.reg, val, ucontrol->value.enumerated.item[0], ucontrol->value.enumerated.item[1], 1080 reg.reg, val, ucontrol->value.enumerated.item[0], ucontrol->value.enumerated.item[1],
1140 reg.lchan_shift, reg.enum_c); 1081 reg.lchan_shift, reg.enum_c);
1141 return 0; 1082 return 0;
@@ -1167,7 +1108,8 @@ snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol,
1167 snd_azf3328_mixer_outw(chip, reg.reg, val); 1108 snd_azf3328_mixer_outw(chip, reg.reg, val);
1168 nreg = val; 1109 nreg = val;
1169 1110
1170 snd_azf3328_dbgmixer("put_enum: %02x to %04x, oreg %04x\n", reg.reg, val, oreg); 1111 dev_dbg(chip->card->dev,
1112 "put_enum: %02x to %04x, oreg %04x\n", reg.reg, val, oreg);
1171 return (nreg != oreg); 1113 return (nreg != oreg);
1172} 1114}
1173 1115
@@ -1253,7 +1195,6 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
1253 unsigned int idx; 1195 unsigned int idx;
1254 int err; 1196 int err;
1255 1197
1256 snd_azf3328_dbgcallenter();
1257 if (snd_BUG_ON(!chip || !chip->card)) 1198 if (snd_BUG_ON(!chip || !chip->card))
1258 return -EINVAL; 1199 return -EINVAL;
1259 1200
@@ -1279,7 +1220,6 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip)
1279 snd_component_add(card, "AZF3328 mixer"); 1220 snd_component_add(card, "AZF3328 mixer");
1280 strcpy(card->mixername, "AZF3328 mixer"); 1221 strcpy(card->mixername, "AZF3328 mixer");
1281 1222
1282 snd_azf3328_dbgcallleave();
1283 return 0; 1223 return 0;
1284} 1224}
1285#endif /* AZF_USE_AC97_LAYER */ 1225#endif /* AZF_USE_AC97_LAYER */
@@ -1288,19 +1228,13 @@ static int
1288snd_azf3328_hw_params(struct snd_pcm_substream *substream, 1228snd_azf3328_hw_params(struct snd_pcm_substream *substream,
1289 struct snd_pcm_hw_params *hw_params) 1229 struct snd_pcm_hw_params *hw_params)
1290{ 1230{
1291 int res; 1231 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
1292 snd_azf3328_dbgcallenter();
1293 res = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
1294 snd_azf3328_dbgcallleave();
1295 return res;
1296} 1232}
1297 1233
1298static int 1234static int
1299snd_azf3328_hw_free(struct snd_pcm_substream *substream) 1235snd_azf3328_hw_free(struct snd_pcm_substream *substream)
1300{ 1236{
1301 snd_azf3328_dbgcallenter();
1302 snd_pcm_lib_free_pages(substream); 1237 snd_pcm_lib_free_pages(substream);
1303 snd_azf3328_dbgcallleave();
1304 return 0; 1238 return 0;
1305} 1239}
1306 1240
@@ -1315,7 +1249,6 @@ snd_azf3328_codec_setfmt(struct snd_azf3328_codec_data *codec,
1315 u16 val = 0xff00; 1249 u16 val = 0xff00;
1316 u8 freq = 0; 1250 u8 freq = 0;
1317 1251
1318 snd_azf3328_dbgcallenter();
1319 switch (bitrate) { 1252 switch (bitrate) {
1320 case AZF_FREQ_4000: freq = SOUNDFORMAT_FREQ_SUSPECTED_4000; break; 1253 case AZF_FREQ_4000: freq = SOUNDFORMAT_FREQ_SUSPECTED_4000; break;
1321 case AZF_FREQ_4800: freq = SOUNDFORMAT_FREQ_SUSPECTED_4800; break; 1254 case AZF_FREQ_4800: freq = SOUNDFORMAT_FREQ_SUSPECTED_4800; break;
@@ -1379,7 +1312,6 @@ snd_azf3328_codec_setfmt(struct snd_azf3328_codec_data *codec,
1379 ); 1312 );
1380 1313
1381 spin_unlock_irqrestore(codec->lock, flags); 1314 spin_unlock_irqrestore(codec->lock, flags);
1382 snd_azf3328_dbgcallleave();
1383} 1315}
1384 1316
1385static inline void 1317static inline void
@@ -1404,15 +1336,16 @@ snd_azf3328_ctrl_reg_6AH_update(struct snd_azf3328 *chip,
1404 chip->shadow_reg_ctrl_6AH |= bitmask; 1336 chip->shadow_reg_ctrl_6AH |= bitmask;
1405 else 1337 else
1406 chip->shadow_reg_ctrl_6AH &= ~bitmask; 1338 chip->shadow_reg_ctrl_6AH &= ~bitmask;
1407 snd_azf3328_dbgcodec("6AH_update mask 0x%04x do_mask %d: val 0x%04x\n", 1339 dev_dbg(chip->card->dev,
1408 bitmask, do_mask, chip->shadow_reg_ctrl_6AH); 1340 "6AH_update mask 0x%04x do_mask %d: val 0x%04x\n",
1341 bitmask, do_mask, chip->shadow_reg_ctrl_6AH);
1409 snd_azf3328_ctrl_outw(chip, IDX_IO_6AH, chip->shadow_reg_ctrl_6AH); 1342 snd_azf3328_ctrl_outw(chip, IDX_IO_6AH, chip->shadow_reg_ctrl_6AH);
1410} 1343}
1411 1344
1412static inline void 1345static inline void
1413snd_azf3328_ctrl_enable_codecs(struct snd_azf3328 *chip, bool enable) 1346snd_azf3328_ctrl_enable_codecs(struct snd_azf3328 *chip, bool enable)
1414{ 1347{
1415 snd_azf3328_dbgcodec("codec_enable %d\n", enable); 1348 dev_dbg(chip->card->dev, "codec_enable %d\n", enable);
1416 /* no idea what exactly is being done here, but I strongly assume it's 1349 /* no idea what exactly is being done here, but I strongly assume it's
1417 * PM related */ 1350 * PM related */
1418 snd_azf3328_ctrl_reg_6AH_update( 1351 snd_azf3328_ctrl_reg_6AH_update(
@@ -1429,7 +1362,7 @@ snd_azf3328_ctrl_codec_activity(struct snd_azf3328 *chip,
1429 struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; 1362 struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type];
1430 bool need_change = (codec->running != enable); 1363 bool need_change = (codec->running != enable);
1431 1364
1432 snd_azf3328_dbgcodec( 1365 dev_dbg(chip->card->dev,
1433 "codec_activity: %s codec, enable %d, need_change %d\n", 1366 "codec_activity: %s codec, enable %d, need_change %d\n",
1434 codec->name, enable, need_change 1367 codec->name, enable, need_change
1435 ); 1368 );
@@ -1470,13 +1403,13 @@ snd_azf3328_ctrl_codec_activity(struct snd_azf3328 *chip,
1470} 1403}
1471 1404
1472static void 1405static void
1473snd_azf3328_codec_setdmaa(struct snd_azf3328_codec_data *codec, 1406snd_azf3328_codec_setdmaa(struct snd_azf3328 *chip,
1474 unsigned long addr, 1407 struct snd_azf3328_codec_data *codec,
1475 unsigned int period_bytes, 1408 unsigned long addr,
1476 unsigned int buffer_bytes 1409 unsigned int period_bytes,
1410 unsigned int buffer_bytes
1477) 1411)
1478{ 1412{
1479 snd_azf3328_dbgcallenter();
1480 WARN_ONCE(period_bytes & 1, "odd period length!?\n"); 1413 WARN_ONCE(period_bytes & 1, "odd period length!?\n");
1481 WARN_ONCE(buffer_bytes != 2 * period_bytes, 1414 WARN_ONCE(buffer_bytes != 2 * period_bytes,
1482 "missed our input expectations! %u vs. %u\n", 1415 "missed our input expectations! %u vs. %u\n",
@@ -1499,7 +1432,7 @@ snd_azf3328_codec_setdmaa(struct snd_azf3328_codec_data *codec,
1499 setup_io.dma_start_1 = addr; 1432 setup_io.dma_start_1 = addr;
1500 setup_io.dma_start_2 = addr+area_length; 1433 setup_io.dma_start_2 = addr+area_length;
1501 1434
1502 snd_azf3328_dbgcodec( 1435 dev_dbg(chip->card->dev,
1503 "setdma: buffers %08x[%u] / %08x[%u], %u, %u\n", 1436 "setdma: buffers %08x[%u] / %08x[%u], %u, %u\n",
1504 setup_io.dma_start_1, area_length, 1437 setup_io.dma_start_1, area_length,
1505 setup_io.dma_start_2, area_length, 1438 setup_io.dma_start_2, area_length,
@@ -1522,7 +1455,6 @@ snd_azf3328_codec_setdmaa(struct snd_azf3328_codec_data *codec,
1522 ); 1455 );
1523 spin_unlock_irqrestore(codec->lock, flags); 1456 spin_unlock_irqrestore(codec->lock, flags);
1524 } 1457 }
1525 snd_azf3328_dbgcallleave();
1526} 1458}
1527 1459
1528static int 1460static int
@@ -1535,8 +1467,6 @@ snd_azf3328_pcm_prepare(struct snd_pcm_substream *substream)
1535 unsigned int count = snd_pcm_lib_period_bytes(substream); 1467 unsigned int count = snd_pcm_lib_period_bytes(substream);
1536#endif 1468#endif
1537 1469
1538 snd_azf3328_dbgcallenter();
1539
1540 codec->dma_base = runtime->dma_addr; 1470 codec->dma_base = runtime->dma_addr;
1541 1471
1542#if 0 1472#if 0
@@ -1544,10 +1474,9 @@ snd_azf3328_pcm_prepare(struct snd_pcm_substream *substream)
1544 runtime->rate, 1474 runtime->rate,
1545 snd_pcm_format_width(runtime->format), 1475 snd_pcm_format_width(runtime->format),
1546 runtime->channels); 1476 runtime->channels);
1547 snd_azf3328_codec_setdmaa(codec, 1477 snd_azf3328_codec_setdmaa(chip, codec,
1548 runtime->dma_addr, count, size); 1478 runtime->dma_addr, count, size);
1549#endif 1479#endif
1550 snd_azf3328_dbgcallleave();
1551 return 0; 1480 return 0;
1552} 1481}
1553 1482
@@ -1562,11 +1491,9 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1562 bool previously_muted = false; 1491 bool previously_muted = false;
1563 bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type); 1492 bool is_main_mixer_playback_codec = (AZF_CODEC_PLAYBACK == codec->type);
1564 1493
1565 snd_azf3328_dbgcalls("snd_azf3328_pcm_trigger cmd %d\n", cmd);
1566
1567 switch (cmd) { 1494 switch (cmd) {
1568 case SNDRV_PCM_TRIGGER_START: 1495 case SNDRV_PCM_TRIGGER_START:
1569 snd_azf3328_dbgcodec("START %s\n", codec->name); 1496 dev_dbg(chip->card->dev, "START PCM %s\n", codec->name);
1570 1497
1571 if (is_main_mixer_playback_codec) { 1498 if (is_main_mixer_playback_codec) {
1572 /* mute WaveOut (avoid clicking during setup) */ 1499 /* mute WaveOut (avoid clicking during setup) */
@@ -1593,7 +1520,7 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1593 snd_azf3328_codec_outw(codec, IDX_IO_CODEC_IRQTYPE, 0xffff); 1520 snd_azf3328_codec_outw(codec, IDX_IO_CODEC_IRQTYPE, 0xffff);
1594 spin_unlock(codec->lock); 1521 spin_unlock(codec->lock);
1595 1522
1596 snd_azf3328_codec_setdmaa(codec, runtime->dma_addr, 1523 snd_azf3328_codec_setdmaa(chip, codec, runtime->dma_addr,
1597 snd_pcm_lib_period_bytes(substream), 1524 snd_pcm_lib_period_bytes(substream),
1598 snd_pcm_lib_buffer_bytes(substream) 1525 snd_pcm_lib_buffer_bytes(substream)
1599 ); 1526 );
@@ -1633,10 +1560,10 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1633 ); 1560 );
1634 } 1561 }
1635 1562
1636 snd_azf3328_dbgcodec("STARTED %s\n", codec->name); 1563 dev_dbg(chip->card->dev, "PCM STARTED %s\n", codec->name);
1637 break; 1564 break;
1638 case SNDRV_PCM_TRIGGER_RESUME: 1565 case SNDRV_PCM_TRIGGER_RESUME:
1639 snd_azf3328_dbgcodec("RESUME %s\n", codec->name); 1566 dev_dbg(chip->card->dev, "PCM RESUME %s\n", codec->name);
1640 /* resume codec if we were active */ 1567 /* resume codec if we were active */
1641 spin_lock(codec->lock); 1568 spin_lock(codec->lock);
1642 if (codec->running) 1569 if (codec->running)
@@ -1648,7 +1575,7 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1648 spin_unlock(codec->lock); 1575 spin_unlock(codec->lock);
1649 break; 1576 break;
1650 case SNDRV_PCM_TRIGGER_STOP: 1577 case SNDRV_PCM_TRIGGER_STOP:
1651 snd_azf3328_dbgcodec("STOP %s\n", codec->name); 1578 dev_dbg(chip->card->dev, "PCM STOP %s\n", codec->name);
1652 1579
1653 if (is_main_mixer_playback_codec) { 1580 if (is_main_mixer_playback_codec) {
1654 /* mute WaveOut (avoid clicking during setup) */ 1581 /* mute WaveOut (avoid clicking during setup) */
@@ -1684,10 +1611,10 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1684 ); 1611 );
1685 } 1612 }
1686 1613
1687 snd_azf3328_dbgcodec("STOPPED %s\n", codec->name); 1614 dev_dbg(chip->card->dev, "PCM STOPPED %s\n", codec->name);
1688 break; 1615 break;
1689 case SNDRV_PCM_TRIGGER_SUSPEND: 1616 case SNDRV_PCM_TRIGGER_SUSPEND:
1690 snd_azf3328_dbgcodec("SUSPEND %s\n", codec->name); 1617 dev_dbg(chip->card->dev, "PCM SUSPEND %s\n", codec->name);
1691 /* make sure codec is stopped */ 1618 /* make sure codec is stopped */
1692 snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS, 1619 snd_azf3328_codec_outw(codec, IDX_IO_CODEC_DMA_FLAGS,
1693 snd_azf3328_codec_inw( 1620 snd_azf3328_codec_inw(
@@ -1696,17 +1623,16 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
1696 ); 1623 );
1697 break; 1624 break;
1698 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1625 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
1699 snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n"); 1626 WARN(1, "FIXME: SNDRV_PCM_TRIGGER_PAUSE_PUSH NIY!\n");
1700 break; 1627 break;
1701 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 1628 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
1702 snd_printk(KERN_ERR "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n"); 1629 WARN(1, "FIXME: SNDRV_PCM_TRIGGER_PAUSE_RELEASE NIY!\n");
1703 break; 1630 break;
1704 default: 1631 default:
1705 snd_printk(KERN_ERR "FIXME: unknown trigger mode!\n"); 1632 WARN(1, "FIXME: unknown trigger mode!\n");
1706 return -EINVAL; 1633 return -EINVAL;
1707 } 1634 }
1708 1635
1709 snd_azf3328_dbgcallleave();
1710 return result; 1636 return result;
1711} 1637}
1712 1638
@@ -1728,8 +1654,8 @@ snd_azf3328_pcm_pointer(struct snd_pcm_substream *substream
1728 result -= codec->dma_base; 1654 result -= codec->dma_base;
1729#endif 1655#endif
1730 frmres = bytes_to_frames( substream->runtime, result); 1656 frmres = bytes_to_frames( substream->runtime, result);
1731 snd_azf3328_dbgcodec("%08li %s @ 0x%8lx, frames %8ld\n", 1657 dev_dbg(substream->pcm->card->dev, "%08li %s @ 0x%8lx, frames %8ld\n",
1732 jiffies, codec->name, result, frmres); 1658 jiffies, codec->name, result, frmres);
1733 return frmres; 1659 return frmres;
1734} 1660}
1735 1661
@@ -1792,7 +1718,7 @@ snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip)
1792 * skeleton handler only 1718 * skeleton handler only
1793 * (we do not want axis reading in interrupt handler - too much load!) 1719 * (we do not want axis reading in interrupt handler - too much load!)
1794 */ 1720 */
1795 snd_azf3328_dbggame("gameport irq\n"); 1721 dev_dbg(chip->card->dev, "gameport irq\n");
1796 1722
1797 /* this should ACK the gameport IRQ properly, hopefully. */ 1723 /* this should ACK the gameport IRQ properly, hopefully. */
1798 snd_azf3328_game_inw(chip, IDX_GAME_AXIS_VALUE); 1724 snd_azf3328_game_inw(chip, IDX_GAME_AXIS_VALUE);
@@ -1804,7 +1730,7 @@ snd_azf3328_gameport_open(struct gameport *gameport, int mode)
1804 struct snd_azf3328 *chip = gameport_get_port_data(gameport); 1730 struct snd_azf3328 *chip = gameport_get_port_data(gameport);
1805 int res; 1731 int res;
1806 1732
1807 snd_azf3328_dbggame("gameport_open, mode %d\n", mode); 1733 dev_dbg(chip->card->dev, "gameport_open, mode %d\n", mode);
1808 switch (mode) { 1734 switch (mode) {
1809 case GAMEPORT_MODE_COOKED: 1735 case GAMEPORT_MODE_COOKED:
1810 case GAMEPORT_MODE_RAW: 1736 case GAMEPORT_MODE_RAW:
@@ -1827,7 +1753,7 @@ snd_azf3328_gameport_close(struct gameport *gameport)
1827{ 1753{
1828 struct snd_azf3328 *chip = gameport_get_port_data(gameport); 1754 struct snd_azf3328 *chip = gameport_get_port_data(gameport);
1829 1755
1830 snd_azf3328_dbggame("gameport_close\n"); 1756 dev_dbg(chip->card->dev, "gameport_close\n");
1831 snd_azf3328_gameport_set_counter_frequency(chip, 1757 snd_azf3328_gameport_set_counter_frequency(chip,
1832 GAME_HWCFG_ADC_COUNTER_FREQ_1_200); 1758 GAME_HWCFG_ADC_COUNTER_FREQ_1_200);
1833 snd_azf3328_gameport_axis_circuit_enable(chip, 0); 1759 snd_azf3328_gameport_axis_circuit_enable(chip, 0);
@@ -1892,9 +1818,8 @@ snd_azf3328_gameport_cooked_read(struct gameport *gameport,
1892 axes[i] = -1; 1818 axes[i] = -1;
1893 } 1819 }
1894 1820
1895 snd_azf3328_dbggame("cooked_read: axes %d %d %d %d buttons %d\n", 1821 dev_dbg(chip->card->dev, "cooked_read: axes %d %d %d %d buttons %d\n",
1896 axes[0], axes[1], axes[2], axes[3], *buttons 1822 axes[0], axes[1], axes[2], axes[3], *buttons);
1897 );
1898 1823
1899 return 0; 1824 return 0;
1900} 1825}
@@ -1906,7 +1831,7 @@ snd_azf3328_gameport(struct snd_azf3328 *chip, int dev)
1906 1831
1907 chip->gameport = gp = gameport_allocate_port(); 1832 chip->gameport = gp = gameport_allocate_port();
1908 if (!gp) { 1833 if (!gp) {
1909 printk(KERN_ERR "azt3328: cannot alloc memory for gameport\n"); 1834 dev_err(chip->card->dev, "cannot alloc memory for gameport\n");
1910 return -ENOMEM; 1835 return -ENOMEM;
1911 } 1836 }
1912 1837
@@ -1950,23 +1875,23 @@ snd_azf3328_gameport_free(struct snd_azf3328 *chip) { }
1950static inline void 1875static inline void
1951snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip) 1876snd_azf3328_gameport_interrupt(struct snd_azf3328 *chip)
1952{ 1877{
1953 printk(KERN_WARNING "huh, game port IRQ occurred!?\n"); 1878 dev_warn(chip->card->dev, "huh, game port IRQ occurred!?\n");
1954} 1879}
1955#endif /* SUPPORT_GAMEPORT */ 1880#endif /* SUPPORT_GAMEPORT */
1956 1881
1957/******************************************************************/ 1882/******************************************************************/
1958 1883
1959static inline void 1884static inline void
1960snd_azf3328_irq_log_unknown_type(u8 which) 1885snd_azf3328_irq_log_unknown_type(struct snd_azf3328 *chip, u8 which)
1961{ 1886{
1962 snd_azf3328_dbgcodec( 1887 dev_dbg(chip->card->dev,
1963 "azt3328: unknown IRQ type (%x) occurred, please report!\n", 1888 "unknown IRQ type (%x) occurred, please report!\n",
1964 which 1889 which);
1965 );
1966} 1890}
1967 1891
1968static inline void 1892static inline void
1969snd_azf3328_pcm_interrupt(const struct snd_azf3328_codec_data *first_codec, 1893snd_azf3328_pcm_interrupt(struct snd_azf3328 *chip,
1894 const struct snd_azf3328_codec_data *first_codec,
1970 u8 status 1895 u8 status
1971) 1896)
1972{ 1897{
@@ -1990,17 +1915,15 @@ snd_azf3328_pcm_interrupt(const struct snd_azf3328_codec_data *first_codec,
1990 1915
1991 if (codec->substream) { 1916 if (codec->substream) {
1992 snd_pcm_period_elapsed(codec->substream); 1917 snd_pcm_period_elapsed(codec->substream);
1993 snd_azf3328_dbgcodec("%s period done (#%x), @ %x\n", 1918 dev_dbg(chip->card->dev, "%s period done (#%x), @ %x\n",
1994 codec->name, 1919 codec->name,
1995 which, 1920 which,
1996 snd_azf3328_codec_inl( 1921 snd_azf3328_codec_inl(
1997 codec, IDX_IO_CODEC_DMA_CURRPOS 1922 codec, IDX_IO_CODEC_DMA_CURRPOS));
1998 )
1999 );
2000 } else 1923 } else
2001 printk(KERN_WARNING "azt3328: irq handler problem!\n"); 1924 dev_warn(chip->card->dev, "irq handler problem!\n");
2002 if (which & IRQ_SOMETHING) 1925 if (which & IRQ_SOMETHING)
2003 snd_azf3328_irq_log_unknown_type(which); 1926 snd_azf3328_irq_log_unknown_type(chip, which);
2004 } 1927 }
2005} 1928}
2006 1929
@@ -2009,9 +1932,7 @@ snd_azf3328_interrupt(int irq, void *dev_id)
2009{ 1932{
2010 struct snd_azf3328 *chip = dev_id; 1933 struct snd_azf3328 *chip = dev_id;
2011 u8 status; 1934 u8 status;
2012#if DEBUG_CODEC
2013 static unsigned long irq_count; 1935 static unsigned long irq_count;
2014#endif
2015 1936
2016 status = snd_azf3328_ctrl_inb(chip, IDX_IO_IRQSTATUS); 1937 status = snd_azf3328_ctrl_inb(chip, IDX_IO_IRQSTATUS);
2017 1938
@@ -2022,14 +1943,13 @@ snd_azf3328_interrupt(int irq, void *dev_id)
2022 )) 1943 ))
2023 return IRQ_NONE; /* must be interrupt for another device */ 1944 return IRQ_NONE; /* must be interrupt for another device */
2024 1945
2025 snd_azf3328_dbgcodec( 1946 dev_dbg(chip->card->dev,
2026 "irq_count %ld! IDX_IO_IRQSTATUS %04x\n", 1947 "irq_count %ld! IDX_IO_IRQSTATUS %04x\n",
2027 irq_count++ /* debug-only */, 1948 irq_count++ /* debug-only */,
2028 status 1949 status);
2029 );
2030 1950
2031 if (status & IRQ_TIMER) { 1951 if (status & IRQ_TIMER) {
2032 /* snd_azf3328_dbgcodec("timer %ld\n", 1952 /* dev_dbg(chip->card->dev, "timer %ld\n",
2033 snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE) 1953 snd_azf3328_codec_inl(chip, IDX_IO_TIMER_VALUE)
2034 & TIMER_VALUE_MASK 1954 & TIMER_VALUE_MASK
2035 ); */ 1955 ); */
@@ -2039,11 +1959,11 @@ snd_azf3328_interrupt(int irq, void *dev_id)
2039 spin_lock(&chip->reg_lock); 1959 spin_lock(&chip->reg_lock);
2040 snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07); 1960 snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x07);
2041 spin_unlock(&chip->reg_lock); 1961 spin_unlock(&chip->reg_lock);
2042 snd_azf3328_dbgcodec("azt3328: timer IRQ\n"); 1962 dev_dbg(chip->card->dev, "timer IRQ\n");
2043 } 1963 }
2044 1964
2045 if (status & (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT)) 1965 if (status & (IRQ_PLAYBACK|IRQ_RECORDING|IRQ_I2S_OUT))
2046 snd_azf3328_pcm_interrupt(chip->codecs, status); 1966 snd_azf3328_pcm_interrupt(chip, chip->codecs, status);
2047 1967
2048 if (status & IRQ_GAMEPORT) 1968 if (status & IRQ_GAMEPORT)
2049 snd_azf3328_gameport_interrupt(chip); 1969 snd_azf3328_gameport_interrupt(chip);
@@ -2055,7 +1975,7 @@ snd_azf3328_interrupt(int irq, void *dev_id)
2055 1975
2056 /* hmm, do we have to ack the IRQ here somehow? 1976 /* hmm, do we have to ack the IRQ here somehow?
2057 * If so, then I don't know how yet... */ 1977 * If so, then I don't know how yet... */
2058 snd_azf3328_dbgcodec("azt3328: MPU401 IRQ\n"); 1978 dev_dbg(chip->card->dev, "MPU401 IRQ\n");
2059 } 1979 }
2060 return IRQ_HANDLED; 1980 return IRQ_HANDLED;
2061} 1981}
@@ -2133,7 +2053,6 @@ snd_azf3328_pcm_open(struct snd_pcm_substream *substream,
2133 struct snd_pcm_runtime *runtime = substream->runtime; 2053 struct snd_pcm_runtime *runtime = substream->runtime;
2134 struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type]; 2054 struct snd_azf3328_codec_data *codec = &chip->codecs[codec_type];
2135 2055
2136 snd_azf3328_dbgcallenter();
2137 codec->substream = substream; 2056 codec->substream = substream;
2138 2057
2139 /* same parameters for all our codecs - at least we think so... */ 2058 /* same parameters for all our codecs - at least we think so... */
@@ -2142,7 +2061,6 @@ snd_azf3328_pcm_open(struct snd_pcm_substream *substream,
2142 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, 2061 snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
2143 &snd_azf3328_hw_constraints_rates); 2062 &snd_azf3328_hw_constraints_rates);
2144 runtime->private_data = codec; 2063 runtime->private_data = codec;
2145 snd_azf3328_dbgcallleave();
2146 return 0; 2064 return 0;
2147} 2065}
2148 2066
@@ -2171,9 +2089,7 @@ snd_azf3328_pcm_close(struct snd_pcm_substream *substream
2171 struct snd_azf3328_codec_data *codec = 2089 struct snd_azf3328_codec_data *codec =
2172 substream->runtime->private_data; 2090 substream->runtime->private_data;
2173 2091
2174 snd_azf3328_dbgcallenter();
2175 codec->substream = NULL; 2092 codec->substream = NULL;
2176 snd_azf3328_dbgcallleave();
2177 return 0; 2093 return 0;
2178} 2094}
2179 2095
@@ -2220,8 +2136,6 @@ enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; /* pcm devices */
2220 struct snd_pcm *pcm; 2136 struct snd_pcm *pcm;
2221 int err; 2137 int err;
2222 2138
2223 snd_azf3328_dbgcallenter();
2224
2225 err = snd_pcm_new(chip->card, "AZF3328 DSP", AZF_PCMDEV_STD, 2139 err = snd_pcm_new(chip->card, "AZF3328 DSP", AZF_PCMDEV_STD,
2226 1, 1, &pcm); 2140 1, 1, &pcm);
2227 if (err < 0) 2141 if (err < 0)
@@ -2258,7 +2172,6 @@ enum { AZF_PCMDEV_STD, AZF_PCMDEV_I2S_OUT, NUM_AZF_PCMDEVS }; /* pcm devices */
2258 snd_dma_pci_data(chip->pci), 2172 snd_dma_pci_data(chip->pci),
2259 64*1024, 64*1024); 2173 64*1024, 64*1024);
2260 2174
2261 snd_azf3328_dbgcallleave();
2262 return 0; 2175 return 0;
2263} 2176}
2264 2177
@@ -2281,7 +2194,6 @@ snd_azf3328_timer_start(struct snd_timer *timer)
2281 unsigned long flags; 2194 unsigned long flags;
2282 unsigned int delay; 2195 unsigned int delay;
2283 2196
2284 snd_azf3328_dbgcallenter();
2285 chip = snd_timer_chip(timer); 2197 chip = snd_timer_chip(timer);
2286 delay = ((timer->sticks * seqtimer_scaling) - 1) & TIMER_VALUE_MASK; 2198 delay = ((timer->sticks * seqtimer_scaling) - 1) & TIMER_VALUE_MASK;
2287 if (delay < 49) { 2199 if (delay < 49) {
@@ -2289,15 +2201,14 @@ snd_azf3328_timer_start(struct snd_timer *timer)
2289 * this timing tweak 2201 * this timing tweak
2290 * (we need to do it to avoid a lockup, though) */ 2202 * (we need to do it to avoid a lockup, though) */
2291 2203
2292 snd_azf3328_dbgtimer("delay was too low (%d)!\n", delay); 2204 dev_dbg(chip->card->dev, "delay was too low (%d)!\n", delay);
2293 delay = 49; /* minimum time is 49 ticks */ 2205 delay = 49; /* minimum time is 49 ticks */
2294 } 2206 }
2295 snd_azf3328_dbgtimer("setting timer countdown value %d\n", delay); 2207 dev_dbg(chip->card->dev, "setting timer countdown value %d\n", delay);
2296 delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE; 2208 delay |= TIMER_COUNTDOWN_ENABLE | TIMER_IRQ_ENABLE;
2297 spin_lock_irqsave(&chip->reg_lock, flags); 2209 spin_lock_irqsave(&chip->reg_lock, flags);
2298 snd_azf3328_ctrl_outl(chip, IDX_IO_TIMER_VALUE, delay); 2210 snd_azf3328_ctrl_outl(chip, IDX_IO_TIMER_VALUE, delay);
2299 spin_unlock_irqrestore(&chip->reg_lock, flags); 2211 spin_unlock_irqrestore(&chip->reg_lock, flags);
2300 snd_azf3328_dbgcallleave();
2301 return 0; 2212 return 0;
2302} 2213}
2303 2214
@@ -2307,7 +2218,6 @@ snd_azf3328_timer_stop(struct snd_timer *timer)
2307 struct snd_azf3328 *chip; 2218 struct snd_azf3328 *chip;
2308 unsigned long flags; 2219 unsigned long flags;
2309 2220
2310 snd_azf3328_dbgcallenter();
2311 chip = snd_timer_chip(timer); 2221 chip = snd_timer_chip(timer);
2312 spin_lock_irqsave(&chip->reg_lock, flags); 2222 spin_lock_irqsave(&chip->reg_lock, flags);
2313 /* disable timer countdown and interrupt */ 2223 /* disable timer countdown and interrupt */
@@ -2319,7 +2229,6 @@ snd_azf3328_timer_stop(struct snd_timer *timer)
2319 the hardware/ALSA interrupt activity. */ 2229 the hardware/ALSA interrupt activity. */
2320 snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x04); 2230 snd_azf3328_ctrl_outb(chip, IDX_IO_TIMER_VALUE + 3, 0x04);
2321 spin_unlock_irqrestore(&chip->reg_lock, flags); 2231 spin_unlock_irqrestore(&chip->reg_lock, flags);
2322 snd_azf3328_dbgcallleave();
2323 return 0; 2232 return 0;
2324} 2233}
2325 2234
@@ -2328,10 +2237,8 @@ static int
2328snd_azf3328_timer_precise_resolution(struct snd_timer *timer, 2237snd_azf3328_timer_precise_resolution(struct snd_timer *timer,
2329 unsigned long *num, unsigned long *den) 2238 unsigned long *num, unsigned long *den)
2330{ 2239{
2331 snd_azf3328_dbgcallenter();
2332 *num = 1; 2240 *num = 1;
2333 *den = 1024000 / seqtimer_scaling; 2241 *den = 1024000 / seqtimer_scaling;
2334 snd_azf3328_dbgcallleave();
2335 return 0; 2242 return 0;
2336} 2243}
2337 2244
@@ -2351,7 +2258,6 @@ snd_azf3328_timer(struct snd_azf3328 *chip, int device)
2351 struct snd_timer_id tid; 2258 struct snd_timer_id tid;
2352 int err; 2259 int err;
2353 2260
2354 snd_azf3328_dbgcallenter();
2355 tid.dev_class = SNDRV_TIMER_CLASS_CARD; 2261 tid.dev_class = SNDRV_TIMER_CLASS_CARD;
2356 tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE; 2262 tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE;
2357 tid.card = chip->card->number; 2263 tid.card = chip->card->number;
@@ -2376,7 +2282,6 @@ snd_azf3328_timer(struct snd_azf3328 *chip, int device)
2376 err = 0; 2282 err = 0;
2377 2283
2378out: 2284out:
2379 snd_azf3328_dbgcallleave();
2380 return err; 2285 return err;
2381} 2286}
2382 2287
@@ -2438,34 +2343,34 @@ snd_azf3328_test_bit(unsigned unsigned reg, int bit)
2438static inline void 2343static inline void
2439snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) 2344snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
2440{ 2345{
2441#if DEBUG_MISC
2442 u16 tmp; 2346 u16 tmp;
2443 2347
2444 snd_azf3328_dbgmisc( 2348 dev_dbg(chip->card->dev,
2445 "ctrl_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, " 2349 "ctrl_io 0x%lx, game_io 0x%lx, mpu_io 0x%lx, "
2446 "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n", 2350 "opl3_io 0x%lx, mixer_io 0x%lx, irq %d\n",
2447 chip->ctrl_io, chip->game_io, chip->mpu_io, 2351 chip->ctrl_io, chip->game_io, chip->mpu_io,
2448 chip->opl3_io, chip->mixer_io, chip->irq 2352 chip->opl3_io, chip->mixer_io, chip->irq);
2449 );
2450 2353
2451 snd_azf3328_dbgmisc("game %02x %02x %02x %02x %02x %02x\n", 2354 dev_dbg(chip->card->dev,
2355 "game %02x %02x %02x %02x %02x %02x\n",
2452 snd_azf3328_game_inb(chip, 0), 2356 snd_azf3328_game_inb(chip, 0),
2453 snd_azf3328_game_inb(chip, 1), 2357 snd_azf3328_game_inb(chip, 1),
2454 snd_azf3328_game_inb(chip, 2), 2358 snd_azf3328_game_inb(chip, 2),
2455 snd_azf3328_game_inb(chip, 3), 2359 snd_azf3328_game_inb(chip, 3),
2456 snd_azf3328_game_inb(chip, 4), 2360 snd_azf3328_game_inb(chip, 4),
2457 snd_azf3328_game_inb(chip, 5) 2361 snd_azf3328_game_inb(chip, 5));
2458 );
2459 2362
2460 for (tmp = 0; tmp < 0x07; tmp += 1) 2363 for (tmp = 0; tmp < 0x07; tmp += 1)
2461 snd_azf3328_dbgmisc("mpu_io 0x%04x\n", inb(chip->mpu_io + tmp)); 2364 dev_dbg(chip->card->dev,
2365 "mpu_io 0x%04x\n", inb(chip->mpu_io + tmp));
2462 2366
2463 for (tmp = 0; tmp <= 0x07; tmp += 1) 2367 for (tmp = 0; tmp <= 0x07; tmp += 1)
2464 snd_azf3328_dbgmisc("0x%02x: game200 0x%04x, game208 0x%04x\n", 2368 dev_dbg(chip->card->dev,
2369 "0x%02x: game200 0x%04x, game208 0x%04x\n",
2465 tmp, inb(0x200 + tmp), inb(0x208 + tmp)); 2370 tmp, inb(0x200 + tmp), inb(0x208 + tmp));
2466 2371
2467 for (tmp = 0; tmp <= 0x01; tmp += 1) 2372 for (tmp = 0; tmp <= 0x01; tmp += 1)
2468 snd_azf3328_dbgmisc( 2373 dev_dbg(chip->card->dev,
2469 "0x%02x: mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, " 2374 "0x%02x: mpu300 0x%04x, mpu310 0x%04x, mpu320 0x%04x, "
2470 "mpu330 0x%04x opl388 0x%04x opl38c 0x%04x\n", 2375 "mpu330 0x%04x opl388 0x%04x opl38c 0x%04x\n",
2471 tmp, 2376 tmp,
@@ -2474,19 +2379,17 @@ snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip)
2474 inb(0x320 + tmp), 2379 inb(0x320 + tmp),
2475 inb(0x330 + tmp), 2380 inb(0x330 + tmp),
2476 inb(0x388 + tmp), 2381 inb(0x388 + tmp),
2477 inb(0x38c + tmp) 2382 inb(0x38c + tmp));
2478 );
2479 2383
2480 for (tmp = 0; tmp < AZF_IO_SIZE_CTRL; tmp += 2) 2384 for (tmp = 0; tmp < AZF_IO_SIZE_CTRL; tmp += 2)
2481 snd_azf3328_dbgmisc("ctrl 0x%02x: 0x%04x\n", 2385 dev_dbg(chip->card->dev,
2482 tmp, snd_azf3328_ctrl_inw(chip, tmp) 2386 "ctrl 0x%02x: 0x%04x\n",
2483 ); 2387 tmp, snd_azf3328_ctrl_inw(chip, tmp));
2484 2388
2485 for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2) 2389 for (tmp = 0; tmp < AZF_IO_SIZE_MIXER; tmp += 2)
2486 snd_azf3328_dbgmisc("mixer 0x%02x: 0x%04x\n", 2390 dev_dbg(chip->card->dev,
2487 tmp, snd_azf3328_mixer_inw(chip, tmp) 2391 "mixer 0x%02x: 0x%04x\n",
2488 ); 2392 tmp, snd_azf3328_mixer_inw(chip, tmp));
2489#endif /* DEBUG_MISC */
2490} 2393}
2491 2394
2492static int 2395static int
@@ -2523,8 +2426,8 @@ snd_azf3328_create(struct snd_card *card,
2523 /* check if we can restrict PCI DMA transfers to 24 bits */ 2426 /* check if we can restrict PCI DMA transfers to 24 bits */
2524 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 || 2427 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
2525 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) { 2428 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
2526 snd_printk(KERN_ERR "architecture does not support " 2429 dev_err(card->dev,
2527 "24bit PCI busmaster DMA\n" 2430 "architecture does not support 24bit PCI busmaster DMA\n"
2528 ); 2431 );
2529 err = -ENXIO; 2432 err = -ENXIO;
2530 goto out_err; 2433 goto out_err;
@@ -2560,7 +2463,7 @@ snd_azf3328_create(struct snd_card *card,
2560 2463
2561 if (request_irq(pci->irq, snd_azf3328_interrupt, 2464 if (request_irq(pci->irq, snd_azf3328_interrupt,
2562 IRQF_SHARED, KBUILD_MODNAME, chip)) { 2465 IRQF_SHARED, KBUILD_MODNAME, chip)) {
2563 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2466 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2564 err = -EBUSY; 2467 err = -EBUSY;
2565 goto out_err; 2468 goto out_err;
2566 } 2469 }
@@ -2599,8 +2502,6 @@ snd_azf3328_create(struct snd_card *card,
2599 spin_unlock_irq(codec->lock); 2502 spin_unlock_irq(codec->lock);
2600 } 2503 }
2601 2504
2602 snd_card_set_dev(card, &pci->dev);
2603
2604 *rchip = chip; 2505 *rchip = chip;
2605 2506
2606 err = 0; 2507 err = 0;
@@ -2624,7 +2525,6 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2624 struct snd_opl3 *opl3; 2525 struct snd_opl3 *opl3;
2625 int err; 2526 int err;
2626 2527
2627 snd_azf3328_dbgcallenter();
2628 if (dev >= SNDRV_CARDS) { 2528 if (dev >= SNDRV_CARDS) {
2629 err = -ENODEV; 2529 err = -ENODEV;
2630 goto out; 2530 goto out;
@@ -2635,7 +2535,8 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2635 goto out; 2535 goto out;
2636 } 2536 }
2637 2537
2638 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2538 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2539 0, &card);
2639 if (err < 0) 2540 if (err < 0)
2640 goto out; 2541 goto out;
2641 2542
@@ -2657,7 +2558,7 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2657 -1, &chip->rmidi 2558 -1, &chip->rmidi
2658 ); 2559 );
2659 if (err < 0) { 2560 if (err < 0) {
2660 snd_printk(KERN_ERR "azf3328: no MPU-401 device at 0x%lx?\n", 2561 dev_err(card->dev, "no MPU-401 device at 0x%lx?\n",
2661 chip->mpu_io 2562 chip->mpu_io
2662 ); 2563 );
2663 goto out_err; 2564 goto out_err;
@@ -2673,7 +2574,7 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2673 2574
2674 if (snd_opl3_create(card, chip->opl3_io, chip->opl3_io+2, 2575 if (snd_opl3_create(card, chip->opl3_io, chip->opl3_io+2,
2675 OPL3_HW_AUTO, 1, &opl3) < 0) { 2576 OPL3_HW_AUTO, 1, &opl3) < 0) {
2676 snd_printk(KERN_ERR "azf3328: no OPL3 device at 0x%lx-0x%lx?\n", 2577 dev_err(card->dev, "no OPL3 device at 0x%lx-0x%lx?\n",
2677 chip->opl3_io, chip->opl3_io+2 2578 chip->opl3_io, chip->opl3_io+2
2678 ); 2579 );
2679 } else { 2580 } else {
@@ -2695,12 +2596,15 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2695 goto out_err; 2596 goto out_err;
2696 2597
2697#ifdef MODULE 2598#ifdef MODULE
2698 printk(KERN_INFO 2599 dev_info(card->dev,
2699"azt3328: Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n" 2600 "Sound driver for Aztech AZF3328-based soundcards such as PCI168.\n");
2700"azt3328: Hardware was completely undocumented, unfortunately.\n" 2601 dev_info(card->dev,
2701"azt3328: Feel free to contact andi AT lisas.de for bug reports etc.!\n" 2602 "Hardware was completely undocumented, unfortunately.\n");
2702"azt3328: User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n", 2603 dev_info(card->dev,
2703 1024000 / seqtimer_scaling, seqtimer_scaling); 2604 "Feel free to contact andi AT lisas.de for bug reports etc.!\n");
2605 dev_info(card->dev,
2606 "User-scalable sequencer timer set to %dHz (1024000Hz / %d).\n",
2607 1024000 / seqtimer_scaling, seqtimer_scaling);
2704#endif 2608#endif
2705 2609
2706 snd_azf3328_gameport(chip, dev); 2610 snd_azf3328_gameport(chip, dev);
@@ -2712,31 +2616,29 @@ snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2712 goto out; 2616 goto out;
2713 2617
2714out_err: 2618out_err:
2715 snd_printk(KERN_ERR "azf3328: something failed, exiting\n"); 2619 dev_err(card->dev, "something failed, exiting\n");
2716 snd_card_free(card); 2620 snd_card_free(card);
2717 2621
2718out: 2622out:
2719 snd_azf3328_dbgcallleave();
2720 return err; 2623 return err;
2721} 2624}
2722 2625
2723static void 2626static void
2724snd_azf3328_remove(struct pci_dev *pci) 2627snd_azf3328_remove(struct pci_dev *pci)
2725{ 2628{
2726 snd_azf3328_dbgcallenter();
2727 snd_card_free(pci_get_drvdata(pci)); 2629 snd_card_free(pci_get_drvdata(pci));
2728 snd_azf3328_dbgcallleave();
2729} 2630}
2730 2631
2731#ifdef CONFIG_PM_SLEEP 2632#ifdef CONFIG_PM_SLEEP
2732static inline void 2633static inline void
2733snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs) 2634snd_azf3328_suspend_regs(const struct snd_azf3328 *chip,
2635 unsigned long io_addr, unsigned count, u32 *saved_regs)
2734{ 2636{
2735 unsigned reg; 2637 unsigned reg;
2736 2638
2737 for (reg = 0; reg < count; ++reg) { 2639 for (reg = 0; reg < count; ++reg) {
2738 *saved_regs = inl(io_addr); 2640 *saved_regs = inl(io_addr);
2739 snd_azf3328_dbgpm("suspend: io 0x%04lx: 0x%08x\n", 2641 dev_dbg(chip->card->dev, "suspend: io 0x%04lx: 0x%08x\n",
2740 io_addr, *saved_regs); 2642 io_addr, *saved_regs);
2741 ++saved_regs; 2643 ++saved_regs;
2742 io_addr += sizeof(*saved_regs); 2644 io_addr += sizeof(*saved_regs);
@@ -2744,7 +2646,8 @@ snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs)
2744} 2646}
2745 2647
2746static inline void 2648static inline void
2747snd_azf3328_resume_regs(const u32 *saved_regs, 2649snd_azf3328_resume_regs(const struct snd_azf3328 *chip,
2650 const u32 *saved_regs,
2748 unsigned long io_addr, 2651 unsigned long io_addr,
2749 unsigned count 2652 unsigned count
2750) 2653)
@@ -2753,7 +2656,8 @@ snd_azf3328_resume_regs(const u32 *saved_regs,
2753 2656
2754 for (reg = 0; reg < count; ++reg) { 2657 for (reg = 0; reg < count; ++reg) {
2755 outl(*saved_regs, io_addr); 2658 outl(*saved_regs, io_addr);
2756 snd_azf3328_dbgpm("resume: io 0x%04lx: 0x%08x --> 0x%08x\n", 2659 dev_dbg(chip->card->dev,
2660 "resume: io 0x%04lx: 0x%08x --> 0x%08x\n",
2757 io_addr, *saved_regs, inl(io_addr)); 2661 io_addr, *saved_regs, inl(io_addr));
2758 ++saved_regs; 2662 ++saved_regs;
2759 io_addr += sizeof(*saved_regs); 2663 io_addr += sizeof(*saved_regs);
@@ -2766,7 +2670,7 @@ snd_azf3328_suspend_ac97(struct snd_azf3328 *chip)
2766#ifdef AZF_USE_AC97_LAYER 2670#ifdef AZF_USE_AC97_LAYER
2767 snd_ac97_suspend(chip->ac97); 2671 snd_ac97_suspend(chip->ac97);
2768#else 2672#else
2769 snd_azf3328_suspend_regs(chip->mixer_io, 2673 snd_azf3328_suspend_regs(chip, chip->mixer_io,
2770 ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer); 2674 ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer);
2771 2675
2772 /* make sure to disable master volume etc. to prevent looping sound */ 2676 /* make sure to disable master volume etc. to prevent looping sound */
@@ -2781,7 +2685,7 @@ snd_azf3328_resume_ac97(const struct snd_azf3328 *chip)
2781#ifdef AZF_USE_AC97_LAYER 2685#ifdef AZF_USE_AC97_LAYER
2782 snd_ac97_resume(chip->ac97); 2686 snd_ac97_resume(chip->ac97);
2783#else 2687#else
2784 snd_azf3328_resume_regs(chip->saved_regs_mixer, chip->mixer_io, 2688 snd_azf3328_resume_regs(chip, chip->saved_regs_mixer, chip->mixer_io,
2785 ARRAY_SIZE(chip->saved_regs_mixer)); 2689 ARRAY_SIZE(chip->saved_regs_mixer));
2786 2690
2787 /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02) 2691 /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02)
@@ -2808,18 +2712,18 @@ snd_azf3328_suspend(struct device *dev)
2808 2712
2809 snd_azf3328_suspend_ac97(chip); 2713 snd_azf3328_suspend_ac97(chip);
2810 2714
2811 snd_azf3328_suspend_regs(chip->ctrl_io, 2715 snd_azf3328_suspend_regs(chip, chip->ctrl_io,
2812 ARRAY_SIZE(chip->saved_regs_ctrl), chip->saved_regs_ctrl); 2716 ARRAY_SIZE(chip->saved_regs_ctrl), chip->saved_regs_ctrl);
2813 2717
2814 /* manually store the one currently relevant write-only reg, too */ 2718 /* manually store the one currently relevant write-only reg, too */
2815 saved_regs_ctrl_u16 = (u16 *)chip->saved_regs_ctrl; 2719 saved_regs_ctrl_u16 = (u16 *)chip->saved_regs_ctrl;
2816 saved_regs_ctrl_u16[IDX_IO_6AH / 2] = chip->shadow_reg_ctrl_6AH; 2720 saved_regs_ctrl_u16[IDX_IO_6AH / 2] = chip->shadow_reg_ctrl_6AH;
2817 2721
2818 snd_azf3328_suspend_regs(chip->game_io, 2722 snd_azf3328_suspend_regs(chip, chip->game_io,
2819 ARRAY_SIZE(chip->saved_regs_game), chip->saved_regs_game); 2723 ARRAY_SIZE(chip->saved_regs_game), chip->saved_regs_game);
2820 snd_azf3328_suspend_regs(chip->mpu_io, 2724 snd_azf3328_suspend_regs(chip, chip->mpu_io,
2821 ARRAY_SIZE(chip->saved_regs_mpu), chip->saved_regs_mpu); 2725 ARRAY_SIZE(chip->saved_regs_mpu), chip->saved_regs_mpu);
2822 snd_azf3328_suspend_regs(chip->opl3_io, 2726 snd_azf3328_suspend_regs(chip, chip->opl3_io,
2823 ARRAY_SIZE(chip->saved_regs_opl3), chip->saved_regs_opl3); 2727 ARRAY_SIZE(chip->saved_regs_opl3), chip->saved_regs_opl3);
2824 2728
2825 pci_disable_device(pci); 2729 pci_disable_device(pci);
@@ -2838,23 +2742,22 @@ snd_azf3328_resume(struct device *dev)
2838 pci_set_power_state(pci, PCI_D0); 2742 pci_set_power_state(pci, PCI_D0);
2839 pci_restore_state(pci); 2743 pci_restore_state(pci);
2840 if (pci_enable_device(pci) < 0) { 2744 if (pci_enable_device(pci) < 0) {
2841 printk(KERN_ERR "azt3328: pci_enable_device failed, " 2745 dev_err(dev, "pci_enable_device failed, disabling device\n");
2842 "disabling device\n");
2843 snd_card_disconnect(card); 2746 snd_card_disconnect(card);
2844 return -EIO; 2747 return -EIO;
2845 } 2748 }
2846 pci_set_master(pci); 2749 pci_set_master(pci);
2847 2750
2848 snd_azf3328_resume_regs(chip->saved_regs_game, chip->game_io, 2751 snd_azf3328_resume_regs(chip, chip->saved_regs_game, chip->game_io,
2849 ARRAY_SIZE(chip->saved_regs_game)); 2752 ARRAY_SIZE(chip->saved_regs_game));
2850 snd_azf3328_resume_regs(chip->saved_regs_mpu, chip->mpu_io, 2753 snd_azf3328_resume_regs(chip, chip->saved_regs_mpu, chip->mpu_io,
2851 ARRAY_SIZE(chip->saved_regs_mpu)); 2754 ARRAY_SIZE(chip->saved_regs_mpu));
2852 snd_azf3328_resume_regs(chip->saved_regs_opl3, chip->opl3_io, 2755 snd_azf3328_resume_regs(chip, chip->saved_regs_opl3, chip->opl3_io,
2853 ARRAY_SIZE(chip->saved_regs_opl3)); 2756 ARRAY_SIZE(chip->saved_regs_opl3));
2854 2757
2855 snd_azf3328_resume_ac97(chip); 2758 snd_azf3328_resume_ac97(chip);
2856 2759
2857 snd_azf3328_resume_regs(chip->saved_regs_ctrl, chip->ctrl_io, 2760 snd_azf3328_resume_regs(chip, chip->saved_regs_ctrl, chip->ctrl_io,
2858 ARRAY_SIZE(chip->saved_regs_ctrl)); 2761 ARRAY_SIZE(chip->saved_regs_ctrl));
2859 2762
2860 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2763 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index 18802039497a..8546711d12f9 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -293,17 +293,23 @@ static void snd_bt87x_pci_error(struct snd_bt87x *chip, unsigned int status)
293 PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY; 293 PCI_STATUS_SIG_SYSTEM_ERROR | PCI_STATUS_DETECTED_PARITY;
294 pci_write_config_word(chip->pci, PCI_STATUS, pci_status); 294 pci_write_config_word(chip->pci, PCI_STATUS, pci_status);
295 if (pci_status != PCI_STATUS_DETECTED_PARITY) 295 if (pci_status != PCI_STATUS_DETECTED_PARITY)
296 snd_printk(KERN_ERR "Aieee - PCI error! status %#08x, PCI status %#04x\n", 296 dev_err(chip->card->dev,
297 "Aieee - PCI error! status %#08x, PCI status %#04x\n",
297 status & ERROR_INTERRUPTS, pci_status); 298 status & ERROR_INTERRUPTS, pci_status);
298 else { 299 else {
299 snd_printk(KERN_ERR "Aieee - PCI parity error detected!\n"); 300 dev_err(chip->card->dev,
301 "Aieee - PCI parity error detected!\n");
300 /* error 'handling' similar to aic7xxx_pci.c: */ 302 /* error 'handling' similar to aic7xxx_pci.c: */
301 chip->pci_parity_errors++; 303 chip->pci_parity_errors++;
302 if (chip->pci_parity_errors > 20) { 304 if (chip->pci_parity_errors > 20) {
303 snd_printk(KERN_ERR "Too many PCI parity errors observed.\n"); 305 dev_err(chip->card->dev,
304 snd_printk(KERN_ERR "Some device on this bus is generating bad parity.\n"); 306 "Too many PCI parity errors observed.\n");
305 snd_printk(KERN_ERR "This is an error *observed by*, not *generated by*, this card.\n"); 307 dev_err(chip->card->dev,
306 snd_printk(KERN_ERR "PCI parity error checking has been disabled.\n"); 308 "Some device on this bus is generating bad parity.\n");
309 dev_err(chip->card->dev,
310 "This is an error *observed by*, not *generated by*, this card.\n");
311 dev_err(chip->card->dev,
312 "PCI parity error checking has been disabled.\n");
307 chip->interrupt_mask &= ~(INT_PPERR | INT_RIPERR); 313 chip->interrupt_mask &= ~(INT_PPERR | INT_RIPERR);
308 snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask); 314 snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask);
309 } 315 }
@@ -323,9 +329,11 @@ static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id)
323 329
324 if (irq_status & ERROR_INTERRUPTS) { 330 if (irq_status & ERROR_INTERRUPTS) {
325 if (irq_status & (INT_FBUS | INT_FTRGT)) 331 if (irq_status & (INT_FBUS | INT_FTRGT))
326 snd_printk(KERN_WARNING "FIFO overrun, status %#08x\n", status); 332 dev_warn(chip->card->dev,
333 "FIFO overrun, status %#08x\n", status);
327 if (irq_status & INT_OCERR) 334 if (irq_status & INT_OCERR)
328 snd_printk(KERN_ERR "internal RISC error, status %#08x\n", status); 335 dev_err(chip->card->dev,
336 "internal RISC error, status %#08x\n", status);
329 if (irq_status & (INT_PPERR | INT_RIPERR | INT_PABORT)) 337 if (irq_status & (INT_PPERR | INT_RIPERR | INT_PABORT))
330 snd_bt87x_pci_error(chip, irq_status); 338 snd_bt87x_pci_error(chip, irq_status);
331 } 339 }
@@ -747,7 +755,7 @@ static int snd_bt87x_create(struct snd_card *card,
747 } 755 }
748 chip->mmio = pci_ioremap_bar(pci, 0); 756 chip->mmio = pci_ioremap_bar(pci, 0);
749 if (!chip->mmio) { 757 if (!chip->mmio) {
750 snd_printk(KERN_ERR "cannot remap io memory\n"); 758 dev_err(card->dev, "cannot remap io memory\n");
751 err = -ENOMEM; 759 err = -ENOMEM;
752 goto fail; 760 goto fail;
753 } 761 }
@@ -762,7 +770,7 @@ static int snd_bt87x_create(struct snd_card *card,
762 err = request_irq(pci->irq, snd_bt87x_interrupt, IRQF_SHARED, 770 err = request_irq(pci->irq, snd_bt87x_interrupt, IRQF_SHARED,
763 KBUILD_MODNAME, chip); 771 KBUILD_MODNAME, chip);
764 if (err < 0) { 772 if (err < 0) {
765 snd_printk(KERN_ERR "cannot grab irq %d\n", pci->irq); 773 dev_err(card->dev, "cannot grab irq %d\n", pci->irq);
766 goto fail; 774 goto fail;
767 } 775 }
768 chip->irq = pci->irq; 776 chip->irq = pci->irq;
@@ -773,7 +781,6 @@ static int snd_bt87x_create(struct snd_card *card,
773 if (err < 0) 781 if (err < 0)
774 goto fail; 782 goto fail;
775 783
776 snd_card_set_dev(card, &pci->dev);
777 *rchip = chip; 784 *rchip = chip;
778 return 0; 785 return 0;
779 786
@@ -851,14 +858,15 @@ static int snd_bt87x_detect_card(struct pci_dev *pci)
851 for (i = 0; i < ARRAY_SIZE(blacklist); ++i) 858 for (i = 0; i < ARRAY_SIZE(blacklist); ++i)
852 if (blacklist[i].subvendor == pci->subsystem_vendor && 859 if (blacklist[i].subvendor == pci->subsystem_vendor &&
853 blacklist[i].subdevice == pci->subsystem_device) { 860 blacklist[i].subdevice == pci->subsystem_device) {
854 snd_printdd(KERN_INFO "card %#04x-%#04x:%#04x has no audio\n", 861 dev_dbg(&pci->dev,
862 "card %#04x-%#04x:%#04x has no audio\n",
855 pci->device, pci->subsystem_vendor, pci->subsystem_device); 863 pci->device, pci->subsystem_vendor, pci->subsystem_device);
856 return -EBUSY; 864 return -EBUSY;
857 } 865 }
858 866
859 snd_printk(KERN_INFO "unknown card %#04x-%#04x:%#04x\n", 867 dev_info(&pci->dev, "unknown card %#04x-%#04x:%#04x\n",
860 pci->device, pci->subsystem_vendor, pci->subsystem_device); 868 pci->device, pci->subsystem_vendor, pci->subsystem_device);
861 snd_printk(KERN_DEBUG "please mail id, board name, and, " 869 dev_info(&pci->dev, "please mail id, board name, and, "
862 "if it works, the correct digital_rate option to " 870 "if it works, the correct digital_rate option to "
863 "<alsa-devel@alsa-project.org>\n"); 871 "<alsa-devel@alsa-project.org>\n");
864 return SND_BT87X_BOARD_UNKNOWN; 872 return SND_BT87X_BOARD_UNKNOWN;
@@ -888,7 +896,8 @@ static int snd_bt87x_probe(struct pci_dev *pci,
888 return -ENOENT; 896 return -ENOENT;
889 } 897 }
890 898
891 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 899 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
900 0, &card);
892 if (err < 0) 901 if (err < 0)
893 return err; 902 return err;
894 903
@@ -925,7 +934,7 @@ static int snd_bt87x_probe(struct pci_dev *pci,
925 if (err < 0) 934 if (err < 0)
926 goto _error; 935 goto _error;
927 } 936 }
928 snd_printk(KERN_INFO "bt87x%d: Using board %d, %sanalog, %sdigital " 937 dev_info(card->dev, "bt87x%d: Using board %d, %sanalog, %sdigital "
929 "(rate %d Hz)\n", dev, boardid, 938 "(rate %d Hz)\n", dev, boardid,
930 chip->board.no_analog ? "no " : "", 939 chip->board.no_analog ? "no " : "",
931 chip->board.no_digital ? "no " : "", chip->board.dig_rate); 940 chip->board.no_digital ? "no " : "", chip->board.dig_rate);
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index f4db5587e86e..f94cc6e97d4a 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -417,13 +417,13 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
417 int status; 417 int status;
418 int retry; 418 int retry;
419 if ((reg > 0x7f) || (value > 0x1ff)) { 419 if ((reg > 0x7f) || (value > 0x1ff)) {
420 snd_printk(KERN_ERR "i2c_write: invalid values.\n"); 420 dev_err(emu->card->dev, "i2c_write: invalid values.\n");
421 return -EINVAL; 421 return -EINVAL;
422 } 422 }
423 423
424 tmp = reg << 25 | value << 16; 424 tmp = reg << 25 | value << 16;
425 /* 425 /*
426 snd_printk(KERN_DEBUG "I2C-write:reg=0x%x, value=0x%x\n", reg, value); 426 dev_dbg(emu->card->dev, "I2C-write:reg=0x%x, value=0x%x\n", reg, value);
427 */ 427 */
428 /* Not sure what this I2C channel controls. */ 428 /* Not sure what this I2C channel controls. */
429 /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */ 429 /* snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); */
@@ -442,7 +442,7 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
442 /* Wait till the transaction ends */ 442 /* Wait till the transaction ends */
443 while (1) { 443 while (1) {
444 status = snd_ca0106_ptr_read(emu, I2C_A, 0); 444 status = snd_ca0106_ptr_read(emu, I2C_A, 0);
445 /*snd_printk(KERN_DEBUG "I2C:status=0x%x\n", status);*/ 445 /*dev_dbg(emu->card->dev, "I2C:status=0x%x\n", status);*/
446 timeout++; 446 timeout++;
447 if ((status & I2C_A_ADC_START) == 0) 447 if ((status & I2C_A_ADC_START) == 0)
448 break; 448 break;
@@ -456,7 +456,7 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
456 } 456 }
457 457
458 if (retry == 10) { 458 if (retry == 10) {
459 snd_printk(KERN_ERR "Writing to ADC failed!\n"); 459 dev_err(emu->card->dev, "Writing to ADC failed!\n");
460 return -EINVAL; 460 return -EINVAL;
461 } 461 }
462 462
@@ -516,7 +516,8 @@ static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
516 } 516 }
517} 517}
518 518
519static int snd_ca0106_channel_dac(struct snd_ca0106_details *details, 519static int snd_ca0106_channel_dac(struct snd_ca0106 *chip,
520 struct snd_ca0106_details *details,
520 int channel_id) 521 int channel_id)
521{ 522{
522 switch (channel_id) { 523 switch (channel_id) {
@@ -529,7 +530,7 @@ static int snd_ca0106_channel_dac(struct snd_ca0106_details *details,
529 case PCM_UNKNOWN_CHANNEL: 530 case PCM_UNKNOWN_CHANNEL:
530 return (details->spi_dac & 0x000f) >> (4 * 0); 531 return (details->spi_dac & 0x000f) >> (4 * 0);
531 default: 532 default:
532 snd_printk(KERN_DEBUG "ca0106: unknown channel_id %d\n", 533 dev_dbg(chip->card->dev, "ca0106: unknown channel_id %d\n",
533 channel_id); 534 channel_id);
534 } 535 }
535 return 0; 536 return 0;
@@ -539,7 +540,7 @@ static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id,
539 int power) 540 int power)
540{ 541{
541 if (chip->details->spi_dac) { 542 if (chip->details->spi_dac) {
542 const int dac = snd_ca0106_channel_dac(chip->details, 543 const int dac = snd_ca0106_channel_dac(chip, chip->details,
543 channel_id); 544 channel_id);
544 const int reg = spi_dacd_reg[dac]; 545 const int reg = spi_dacd_reg[dac];
545 const int bit = spi_dacd_bit[dac]; 546 const int bit = spi_dacd_bit[dac];
@@ -583,7 +584,7 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
583 584
584 channel->use = 1; 585 channel->use = 1;
585 /* 586 /*
586 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n", 587 dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
587 channel_id, chip, channel); 588 channel_id, chip, channel);
588 */ 589 */
589 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; 590 //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
@@ -660,7 +661,8 @@ static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substre
660 661
661 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 662 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
662 if (epcm == NULL) { 663 if (epcm == NULL) {
663 snd_printk(KERN_ERR "open_capture_channel: failed epcm alloc\n"); 664 dev_err(chip->card->dev,
665 "open_capture_channel: failed epcm alloc\n");
664 return -ENOMEM; 666 return -ENOMEM;
665 } 667 }
666 epcm->emu = chip; 668 epcm->emu = chip;
@@ -677,7 +679,7 @@ static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substre
677 679
678 channel->use = 1; 680 channel->use = 1;
679 /* 681 /*
680 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n", 682 dev_dbg(chip->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
681 channel_id, chip, channel); 683 channel_id, chip, channel);
682 */ 684 */
683 //channel->interrupt = snd_ca0106_pcm_channel_interrupt; 685 //channel->interrupt = snd_ca0106_pcm_channel_interrupt;
@@ -771,7 +773,7 @@ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream)
771 int i; 773 int i;
772 774
773#if 0 /* debug */ 775#if 0 /* debug */
774 snd_printk(KERN_DEBUG 776 dev_dbg(emu->card->dev,
775 "prepare:channel_number=%d, rate=%d, format=0x%x, " 777 "prepare:channel_number=%d, rate=%d, format=0x%x, "
776 "channels=%d, buffer_size=%ld, period_size=%ld, " 778 "channels=%d, buffer_size=%ld, period_size=%ld, "
777 "periods=%u, frames_to_bytes=%d\n", 779 "periods=%u, frames_to_bytes=%d\n",
@@ -779,9 +781,11 @@ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream)
779 runtime->channels, runtime->buffer_size, 781 runtime->channels, runtime->buffer_size,
780 runtime->period_size, runtime->periods, 782 runtime->period_size, runtime->periods,
781 frames_to_bytes(runtime, 1)); 783 frames_to_bytes(runtime, 1));
782 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n", 784 dev_dbg(emu->card->dev,
785 "dma_addr=%x, dma_area=%p, table_base=%p\n",
783 runtime->dma_addr, runtime->dma_area, table_base); 786 runtime->dma_addr, runtime->dma_area, table_base);
784 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 787 dev_dbg(emu->card->dev,
788 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
785 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); 789 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
786#endif /* debug */ 790#endif /* debug */
787 /* Rate can be set per channel. */ 791 /* Rate can be set per channel. */
@@ -876,7 +880,7 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
876 u32 reg71; 880 u32 reg71;
877 881
878#if 0 /* debug */ 882#if 0 /* debug */
879 snd_printk(KERN_DEBUG 883 dev_dbg(emu->card->dev,
880 "prepare:channel_number=%d, rate=%d, format=0x%x, " 884 "prepare:channel_number=%d, rate=%d, format=0x%x, "
881 "channels=%d, buffer_size=%ld, period_size=%ld, " 885 "channels=%d, buffer_size=%ld, period_size=%ld, "
882 "periods=%u, frames_to_bytes=%d\n", 886 "periods=%u, frames_to_bytes=%d\n",
@@ -884,9 +888,11 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
884 runtime->channels, runtime->buffer_size, 888 runtime->channels, runtime->buffer_size,
885 runtime->period_size, runtime->periods, 889 runtime->period_size, runtime->periods,
886 frames_to_bytes(runtime, 1)); 890 frames_to_bytes(runtime, 1));
887 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n", 891 dev_dbg(emu->card->dev,
892 "dma_addr=%x, dma_area=%p, table_base=%p\n",
888 runtime->dma_addr, runtime->dma_area, table_base); 893 runtime->dma_addr, runtime->dma_area, table_base);
889 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 894 dev_dbg(emu->card->dev,
895 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
890 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); 896 emu->buffer.addr, emu->buffer.area, emu->buffer.bytes);
891#endif /* debug */ 897#endif /* debug */
892 /* reg71 controls ADC rate. */ 898 /* reg71 controls ADC rate. */
@@ -934,7 +940,7 @@ static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream)
934 940
935 941
936 /* 942 /*
937 printk(KERN_DEBUG 943 dev_dbg(emu->card->dev,
938 "prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, " 944 "prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, "
939 "buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n", 945 "buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",
940 channel, runtime->rate, runtime->format, runtime->channels, 946 channel, runtime->rate, runtime->format, runtime->channels,
@@ -982,13 +988,13 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
982 runtime = s->runtime; 988 runtime = s->runtime;
983 epcm = runtime->private_data; 989 epcm = runtime->private_data;
984 channel = epcm->channel_id; 990 channel = epcm->channel_id;
985 /* snd_printk(KERN_DEBUG "channel=%d\n", channel); */ 991 /* dev_dbg(emu->card->dev, "channel=%d\n", channel); */
986 epcm->running = running; 992 epcm->running = running;
987 basic |= (0x1 << channel); 993 basic |= (0x1 << channel);
988 extended |= (0x10 << channel); 994 extended |= (0x10 << channel);
989 snd_pcm_trigger_done(s, substream); 995 snd_pcm_trigger_done(s, substream);
990 } 996 }
991 /* snd_printk(KERN_DEBUG "basic=0x%x, extended=0x%x\n",basic, extended); */ 997 /* dev_dbg(emu->card->dev, "basic=0x%x, extended=0x%x\n",basic, extended); */
992 998
993 switch (cmd) { 999 switch (cmd) {
994 case SNDRV_PCM_TRIGGER_START: 1000 case SNDRV_PCM_TRIGGER_START:
@@ -1070,7 +1076,7 @@ snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream)
1070 return ptr; 1076 return ptr;
1071 prev_ptr = ptr; 1077 prev_ptr = ptr;
1072 } while (--timeout); 1078 } while (--timeout);
1073 snd_printk(KERN_WARNING "ca0106: unstable DMA pointer!\n"); 1079 dev_warn(emu->card->dev, "ca0106: unstable DMA pointer!\n");
1074 return 0; 1080 return 0;
1075} 1081}
1076 1082
@@ -1093,7 +1099,7 @@ snd_ca0106_pcm_pointer_capture(struct snd_pcm_substream *substream)
1093 if (ptr >= runtime->buffer_size) 1099 if (ptr >= runtime->buffer_size)
1094 ptr -= runtime->buffer_size; 1100 ptr -= runtime->buffer_size;
1095 /* 1101 /*
1096 printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " 1102 dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
1097 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", 1103 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
1098 ptr1, ptr2, ptr, (int)runtime->buffer_size, 1104 ptr1, ptr2, ptr, (int)runtime->buffer_size,
1099 (int)runtime->period_size, (int)runtime->frame_bits, 1105 (int)runtime->period_size, (int)runtime->frame_bits,
@@ -1284,9 +1290,9 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id)
1284 1290
1285 stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0); 1291 stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0);
1286 /* 1292 /*
1287 snd_printk(KERN_DEBUG "interrupt status = 0x%08x, stat76=0x%08x\n", 1293 dev_dbg(emu->card->dev, "interrupt status = 0x%08x, stat76=0x%08x\n",
1288 status, stat76); 1294 status, stat76);
1289 snd_printk(KERN_DEBUG "ptr=0x%08x\n", 1295 dev_dbg(emu->card->dev, "ptr=0x%08x\n",
1290 snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0)); 1296 snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0));
1291 */ 1297 */
1292 mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */ 1298 mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */
@@ -1296,11 +1302,13 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id)
1296/* FIXME: Select the correct substream for period elapsed */ 1302/* FIXME: Select the correct substream for period elapsed */
1297 if(pchannel->use) { 1303 if(pchannel->use) {
1298 snd_pcm_period_elapsed(pchannel->epcm->substream); 1304 snd_pcm_period_elapsed(pchannel->epcm->substream);
1299 //printk(KERN_INFO "interrupt [%d] used\n", i); 1305 /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */
1300 } 1306 }
1301 } 1307 }
1302 //printk(KERN_INFO "channel=%p\n",pchannel); 1308 /*
1303 //printk(KERN_INFO "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number); 1309 dev_dbg(emu->card->dev, "channel=%p\n", pchannel);
1310 dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number);
1311 */
1304 mask <<= 1; 1312 mask <<= 1;
1305 } 1313 }
1306 mask = 0x110000; /* 0x1 for one half, 0x10 for the other half period. */ 1314 mask = 0x110000; /* 0x1 for one half, 0x10 for the other half period. */
@@ -1310,11 +1318,13 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id)
1310/* FIXME: Select the correct substream for period elapsed */ 1318/* FIXME: Select the correct substream for period elapsed */
1311 if(pchannel->use) { 1319 if(pchannel->use) {
1312 snd_pcm_period_elapsed(pchannel->epcm->substream); 1320 snd_pcm_period_elapsed(pchannel->epcm->substream);
1313 //printk(KERN_INFO "interrupt [%d] used\n", i); 1321 /* dev_dbg(emu->card->dev, "interrupt [%d] used\n", i); */
1314 } 1322 }
1315 } 1323 }
1316 //printk(KERN_INFO "channel=%p\n",pchannel); 1324 /*
1317 //printk(KERN_INFO "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number); 1325 dev_dbg(emu->card->dev, "channel=%p\n", pchannel);
1326 dev_dbg(emu->card->dev, "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number);
1327 */
1318 mask <<= 1; 1328 mask <<= 1;
1319 } 1329 }
1320 1330
@@ -1603,7 +1613,7 @@ static void ca0106_init_chip(struct snd_ca0106 *chip, int resume)
1603 int size, n; 1613 int size, n;
1604 1614
1605 size = ARRAY_SIZE(i2c_adc_init); 1615 size = ARRAY_SIZE(i2c_adc_init);
1606 /* snd_printk(KERN_DEBUG "I2C:array size=0x%x\n", size); */ 1616 /* dev_dbg(emu->card->dev, "I2C:array size=0x%x\n", size); */
1607 for (n = 0; n < size; n++) 1617 for (n = 0; n < size; n++)
1608 snd_ca0106_i2c_write(chip, i2c_adc_init[n][0], 1618 snd_ca0106_i2c_write(chip, i2c_adc_init[n][0],
1609 i2c_adc_init[n][1]); 1619 i2c_adc_init[n][1]);
@@ -1668,7 +1678,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
1668 return err; 1678 return err;
1669 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 || 1679 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
1670 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) { 1680 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
1671 printk(KERN_ERR "error to set 32bit mask DMA\n"); 1681 dev_err(card->dev, "error to set 32bit mask DMA\n");
1672 pci_disable_device(pci); 1682 pci_disable_device(pci);
1673 return -ENXIO; 1683 return -ENXIO;
1674 } 1684 }
@@ -1689,14 +1699,14 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
1689 chip->res_port = request_region(chip->port, 0x20, "snd_ca0106"); 1699 chip->res_port = request_region(chip->port, 0x20, "snd_ca0106");
1690 if (!chip->res_port) { 1700 if (!chip->res_port) {
1691 snd_ca0106_free(chip); 1701 snd_ca0106_free(chip);
1692 printk(KERN_ERR "cannot allocate the port\n"); 1702 dev_err(card->dev, "cannot allocate the port\n");
1693 return -EBUSY; 1703 return -EBUSY;
1694 } 1704 }
1695 1705
1696 if (request_irq(pci->irq, snd_ca0106_interrupt, 1706 if (request_irq(pci->irq, snd_ca0106_interrupt,
1697 IRQF_SHARED, KBUILD_MODNAME, chip)) { 1707 IRQF_SHARED, KBUILD_MODNAME, chip)) {
1698 snd_ca0106_free(chip); 1708 snd_ca0106_free(chip);
1699 printk(KERN_ERR "cannot grab irq\n"); 1709 dev_err(card->dev, "cannot grab irq\n");
1700 return -EBUSY; 1710 return -EBUSY;
1701 } 1711 }
1702 chip->irq = pci->irq; 1712 chip->irq = pci->irq;
@@ -1712,7 +1722,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
1712 /* read serial */ 1722 /* read serial */
1713 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 1723 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
1714 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 1724 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
1715 printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", 1725 dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n",
1716 chip->model, pci->revision, chip->serial); 1726 chip->model, pci->revision, chip->serial);
1717 strcpy(card->driver, "CA0106"); 1727 strcpy(card->driver, "CA0106");
1718 strcpy(card->shortname, "CA0106"); 1728 strcpy(card->shortname, "CA0106");
@@ -1726,7 +1736,7 @@ static int snd_ca0106_create(int dev, struct snd_card *card,
1726 } 1736 }
1727 chip->details = c; 1737 chip->details = c;
1728 if (subsystem[dev]) { 1738 if (subsystem[dev]) {
1729 printk(KERN_INFO "snd-ca0106: Sound card name=%s, " 1739 dev_info(card->dev, "Sound card name=%s, "
1730 "subsystem=0x%x. Forced to subsystem=0x%x\n", 1740 "subsystem=0x%x. Forced to subsystem=0x%x\n",
1731 c->name, chip->serial, subsystem[dev]); 1741 c->name, chip->serial, subsystem[dev]);
1732 } 1742 }
@@ -1843,7 +1853,8 @@ static int snd_ca0106_probe(struct pci_dev *pci,
1843 return -ENOENT; 1853 return -ENOENT;
1844 } 1854 }
1845 1855
1846 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1856 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1857 0, &card);
1847 if (err < 0) 1858 if (err < 0)
1848 return err; 1859 return err;
1849 1860
@@ -1868,18 +1879,16 @@ static int snd_ca0106_probe(struct pci_dev *pci,
1868 if (err < 0) 1879 if (err < 0)
1869 goto error; 1880 goto error;
1870 1881
1871 snd_printdd("ca0106: probe for MIDI channel A ..."); 1882 dev_dbg(card->dev, "probe for MIDI channel A ...");
1872 err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A); 1883 err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A);
1873 if (err < 0) 1884 if (err < 0)
1874 goto error; 1885 goto error;
1875 snd_printdd(" done.\n"); 1886 dev_dbg(card->dev, " done.\n");
1876 1887
1877#ifdef CONFIG_PROC_FS 1888#ifdef CONFIG_PROC_FS
1878 snd_ca0106_proc_init(chip); 1889 snd_ca0106_proc_init(chip);
1879#endif 1890#endif
1880 1891
1881 snd_card_set_dev(card, &pci->dev);
1882
1883 err = snd_card_register(card); 1892 err = snd_card_register(card);
1884 if (err < 0) 1893 if (err < 0)
1885 goto error; 1894 goto error;
diff --git a/sound/pci/ca0106/ca_midi.c b/sound/pci/ca0106/ca_midi.c
index 8bbdf265d11d..b91c7f6d19f9 100644
--- a/sound/pci/ca0106/ca_midi.c
+++ b/sound/pci/ca0106/ca_midi.c
@@ -46,7 +46,7 @@ static void ca_midi_clear_rx(struct snd_ca_midi *midi)
46 ca_midi_read_data(midi); 46 ca_midi_read_data(midi);
47#ifdef CONFIG_SND_DEBUG 47#ifdef CONFIG_SND_DEBUG
48 if (timeout <= 0) 48 if (timeout <= 0)
49 snd_printk(KERN_ERR "ca_midi_clear_rx: timeout (status = 0x%x)\n", 49 pr_err("ca_midi_clear_rx: timeout (status = 0x%x)\n",
50 ca_midi_read_stat(midi)); 50 ca_midi_read_stat(midi));
51#endif 51#endif
52} 52}
@@ -113,7 +113,7 @@ static void ca_midi_cmd(struct snd_ca_midi *midi, unsigned char cmd, int ack)
113 } 113 }
114 spin_unlock_irqrestore(&midi->input_lock, flags); 114 spin_unlock_irqrestore(&midi->input_lock, flags);
115 if (!ok) 115 if (!ok)
116 snd_printk(KERN_ERR "ca_midi_cmd: 0x%x failed at 0x%x (status = 0x%x, data = 0x%x)!!!\n", 116 pr_err("ca_midi_cmd: 0x%x failed at 0x%x (status = 0x%x, data = 0x%x)!!!\n",
117 cmd, 117 cmd,
118 midi->get_dev_id_port(midi->dev_id), 118 midi->get_dev_id_port(midi->dev_id),
119 ca_midi_read_stat(midi), 119 ca_midi_read_stat(midi),
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 2755ec5bcc25..12c318e175f4 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -796,7 +796,7 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
796 if (runtime->channels > 1) 796 if (runtime->channels > 1)
797 rec->fmt |= 0x01; 797 rec->fmt |= 0x01;
798 if (rec->is_dac && set_dac_channels(cm, rec, runtime->channels) < 0) { 798 if (rec->is_dac && set_dac_channels(cm, rec, runtime->channels) < 0) {
799 snd_printd("cannot set dac channels\n"); 799 dev_dbg(cm->card->dev, "cannot set dac channels\n");
800 return -EINVAL; 800 return -EINVAL;
801 } 801 }
802 802
@@ -827,7 +827,7 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
827 else 827 else
828 cm->ctrl |= val; 828 cm->ctrl |= val;
829 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); 829 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
830 //snd_printd("cmipci: functrl0 = %08x\n", cm->ctrl); 830 /* dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl); */
831 831
832 /* set sample rate */ 832 /* set sample rate */
833 freq = 0; 833 freq = 0;
@@ -850,7 +850,7 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
850 val |= (freq << CM_ASFC_SHIFT) & CM_ASFC_MASK; 850 val |= (freq << CM_ASFC_SHIFT) & CM_ASFC_MASK;
851 } 851 }
852 snd_cmipci_write(cm, CM_REG_FUNCTRL1, val); 852 snd_cmipci_write(cm, CM_REG_FUNCTRL1, val);
853 //snd_printd("cmipci: functrl1 = %08x\n", val); 853 dev_dbg(cm->card->dev, "functrl1 = %08x\n", val);
854 854
855 /* set format */ 855 /* set format */
856 val = snd_cmipci_read(cm, CM_REG_CHFORMAT); 856 val = snd_cmipci_read(cm, CM_REG_CHFORMAT);
@@ -866,7 +866,7 @@ static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec,
866 val |= freq_ext << (rec->ch * 2); 866 val |= freq_ext << (rec->ch * 2);
867 } 867 }
868 snd_cmipci_write(cm, CM_REG_CHFORMAT, val); 868 snd_cmipci_write(cm, CM_REG_CHFORMAT, val);
869 //snd_printd("cmipci: chformat = %08x\n", val); 869 dev_dbg(cm->card->dev, "chformat = %08x\n", val);
870 870
871 if (!rec->is_dac && cm->chip_version) { 871 if (!rec->is_dac && cm->chip_version) {
872 if (runtime->rate > 44100) 872 if (runtime->rate > 44100)
@@ -904,7 +904,7 @@ static int snd_cmipci_pcm_trigger(struct cmipci *cm, struct cmipci_pcm *rec,
904 cm->ctrl |= chen; 904 cm->ctrl |= chen;
905 /* enable channel */ 905 /* enable channel */
906 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); 906 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl);
907 //snd_printd("cmipci: functrl0 = %08x\n", cm->ctrl); 907 dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl);
908 break; 908 break;
909 case SNDRV_PCM_TRIGGER_STOP: 909 case SNDRV_PCM_TRIGGER_STOP:
910 rec->running = 0; 910 rec->running = 0;
@@ -952,7 +952,7 @@ static snd_pcm_uframes_t snd_cmipci_pcm_pointer(struct cmipci *cm, struct cmipci
952 if (rem < rec->dma_size) 952 if (rem < rec->dma_size)
953 goto ok; 953 goto ok;
954 } 954 }
955 printk(KERN_ERR "cmipci: invalid PCM pointer: %#x\n", rem); 955 dev_err(cm->card->dev, "invalid PCM pointer: %#x\n", rem);
956 return SNDRV_PCM_POS_XRUN; 956 return SNDRV_PCM_POS_XRUN;
957ok: 957ok:
958 ptr = (rec->dma_size - (rem + 1)) >> rec->shift; 958 ptr = (rec->dma_size - (rem + 1)) >> rec->shift;
@@ -2889,13 +2889,13 @@ static int snd_cmipci_create_gameport(struct cmipci *cm, int dev)
2889 } 2889 }
2890 2890
2891 if (!r) { 2891 if (!r) {
2892 printk(KERN_WARNING "cmipci: cannot reserve joystick ports\n"); 2892 dev_warn(cm->card->dev, "cannot reserve joystick ports\n");
2893 return -EBUSY; 2893 return -EBUSY;
2894 } 2894 }
2895 2895
2896 cm->gameport = gp = gameport_allocate_port(); 2896 cm->gameport = gp = gameport_allocate_port();
2897 if (!gp) { 2897 if (!gp) {
2898 printk(KERN_ERR "cmipci: cannot allocate memory for gameport\n"); 2898 dev_err(cm->card->dev, "cannot allocate memory for gameport\n");
2899 release_and_free_resource(r); 2899 release_and_free_resource(r);
2900 return -ENOMEM; 2900 return -ENOMEM;
2901 } 2901 }
@@ -2995,13 +2995,14 @@ static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port)
2995 2995
2996 if (snd_opl3_create(cm->card, iosynth, iosynth + 2, 2996 if (snd_opl3_create(cm->card, iosynth, iosynth + 2,
2997 OPL3_HW_OPL3, 0, &opl3) < 0) { 2997 OPL3_HW_OPL3, 0, &opl3) < 0) {
2998 printk(KERN_ERR "cmipci: no OPL device at %#lx, " 2998 dev_err(cm->card->dev,
2999 "skipping...\n", iosynth); 2999 "no OPL device at %#lx, skipping...\n",
3000 iosynth);
3000 goto disable_fm; 3001 goto disable_fm;
3001 } 3002 }
3002 } 3003 }
3003 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 3004 if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
3004 printk(KERN_ERR "cmipci: cannot create OPL3 hwdep\n"); 3005 dev_err(cm->card->dev, "cannot create OPL3 hwdep\n");
3005 return err; 3006 return err;
3006 } 3007 }
3007 return 0; 3008 return 0;
@@ -3060,7 +3061,7 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
3060 3061
3061 if (request_irq(pci->irq, snd_cmipci_interrupt, 3062 if (request_irq(pci->irq, snd_cmipci_interrupt,
3062 IRQF_SHARED, KBUILD_MODNAME, cm)) { 3063 IRQF_SHARED, KBUILD_MODNAME, cm)) {
3063 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 3064 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
3064 snd_cmipci_free(cm); 3065 snd_cmipci_free(cm);
3065 return -EBUSY; 3066 return -EBUSY;
3066 } 3067 }
@@ -3192,8 +3193,9 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
3192 /* enable UART */ 3193 /* enable UART */
3193 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_UART_EN); 3194 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_UART_EN);
3194 if (inb(iomidi + 1) == 0xff) { 3195 if (inb(iomidi + 1) == 0xff) {
3195 snd_printk(KERN_ERR "cannot enable MPU-401 port" 3196 dev_err(cm->card->dev,
3196 " at %#lx\n", iomidi); 3197 "cannot enable MPU-401 port at %#lx\n",
3198 iomidi);
3197 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, 3199 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1,
3198 CM_UART_EN); 3200 CM_UART_EN);
3199 iomidi = 0; 3201 iomidi = 0;
@@ -3237,7 +3239,8 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
3237 MPU401_INFO_INTEGRATED : 0) | 3239 MPU401_INFO_INTEGRATED : 0) |
3238 MPU401_INFO_IRQ_HOOK, 3240 MPU401_INFO_IRQ_HOOK,
3239 -1, &cm->rmidi)) < 0) { 3241 -1, &cm->rmidi)) < 0) {
3240 printk(KERN_ERR "cmipci: no UART401 device at 0x%lx\n", iomidi); 3242 dev_err(cm->card->dev,
3243 "no UART401 device at 0x%lx\n", iomidi);
3241 } 3244 }
3242 } 3245 }
3243 3246
@@ -3254,8 +3257,6 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
3254 if (snd_cmipci_create_gameport(cm, dev) < 0) 3257 if (snd_cmipci_create_gameport(cm, dev) < 0)
3255 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); 3258 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
3256 3259
3257 snd_card_set_dev(card, &pci->dev);
3258
3259 *rcmipci = cm; 3260 *rcmipci = cm;
3260 return 0; 3261 return 0;
3261} 3262}
@@ -3280,7 +3281,8 @@ static int snd_cmipci_probe(struct pci_dev *pci,
3280 return -ENOENT; 3281 return -ENOENT;
3281 } 3282 }
3282 3283
3283 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 3284 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
3285 0, &card);
3284 if (err < 0) 3286 if (err < 0)
3285 return err; 3287 return err;
3286 3288
@@ -3381,8 +3383,7 @@ static int snd_cmipci_resume(struct device *dev)
3381 pci_set_power_state(pci, PCI_D0); 3383 pci_set_power_state(pci, PCI_D0);
3382 pci_restore_state(pci); 3384 pci_restore_state(pci);
3383 if (pci_enable_device(pci) < 0) { 3385 if (pci_enable_device(pci) < 0) {
3384 printk(KERN_ERR "cmipci: pci_enable_device failed, " 3386 dev_err(dev, "pci_enable_device failed, disabling device\n");
3385 "disabling device\n");
3386 snd_card_disconnect(card); 3387 snd_card_disconnect(card);
3387 return -EIO; 3388 return -EIO;
3388 } 3389 }
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index 1dc793e742d7..43d1f912c641 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -564,7 +564,8 @@ static void snd_cs4281_ac97_write(struct snd_ac97 *ac97,
564 return; 564 return;
565 } 565 }
566 } 566 }
567 snd_printk(KERN_ERR "AC'97 write problem, reg = 0x%x, val = 0x%x\n", reg, val); 567 dev_err(chip->card->dev,
568 "AC'97 write problem, reg = 0x%x, val = 0x%x\n", reg, val);
568} 569}
569 570
570static unsigned short snd_cs4281_ac97_read(struct snd_ac97 *ac97, 571static unsigned short snd_cs4281_ac97_read(struct snd_ac97 *ac97,
@@ -624,7 +625,8 @@ static unsigned short snd_cs4281_ac97_read(struct snd_ac97 *ac97,
624 goto __ok1; 625 goto __ok1;
625 } 626 }
626 627
627 snd_printk(KERN_ERR "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg); 628 dev_err(chip->card->dev,
629 "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
628 result = 0xffff; 630 result = 0xffff;
629 goto __end; 631 goto __end;
630 632
@@ -643,7 +645,8 @@ static unsigned short snd_cs4281_ac97_read(struct snd_ac97 *ac97,
643 udelay(10); 645 udelay(10);
644 } 646 }
645 647
646 snd_printk(KERN_ERR "AC'97 read problem (ACSTS_VSTS), reg = 0x%x\n", reg); 648 dev_err(chip->card->dev,
649 "AC'97 read problem (ACSTS_VSTS), reg = 0x%x\n", reg);
647 result = 0xffff; 650 result = 0xffff;
648 goto __end; 651 goto __end;
649 652
@@ -835,8 +838,9 @@ static snd_pcm_uframes_t snd_cs4281_pointer(struct snd_pcm_substream *substream)
835 struct cs4281 *chip = snd_pcm_substream_chip(substream); 838 struct cs4281 *chip = snd_pcm_substream_chip(substream);
836 839
837 /* 840 /*
838 printk(KERN_DEBUG "DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n", 841 dev_dbg(chip->card->dev,
839 snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size, 842 "DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n",
843 snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size,
840 jiffies); 844 jiffies);
841 */ 845 */
842 return runtime->buffer_size - 846 return runtime->buffer_size -
@@ -1265,7 +1269,8 @@ static int snd_cs4281_create_gameport(struct cs4281 *chip)
1265 1269
1266 chip->gameport = gp = gameport_allocate_port(); 1270 chip->gameport = gp = gameport_allocate_port();
1267 if (!gp) { 1271 if (!gp) {
1268 printk(KERN_ERR "cs4281: cannot allocate memory for gameport\n"); 1272 dev_err(chip->card->dev,
1273 "cannot allocate memory for gameport\n");
1269 return -ENOMEM; 1274 return -ENOMEM;
1270 } 1275 }
1271 1276
@@ -1361,7 +1366,7 @@ static int snd_cs4281_create(struct snd_card *card,
1361 chip->irq = -1; 1366 chip->irq = -1;
1362 pci_set_master(pci); 1367 pci_set_master(pci);
1363 if (dual_codec < 0 || dual_codec > 3) { 1368 if (dual_codec < 0 || dual_codec > 3) {
1364 snd_printk(KERN_ERR "invalid dual_codec option %d\n", dual_codec); 1369 dev_err(card->dev, "invalid dual_codec option %d\n", dual_codec);
1365 dual_codec = 0; 1370 dual_codec = 0;
1366 } 1371 }
1367 chip->dual_codec = dual_codec; 1372 chip->dual_codec = dual_codec;
@@ -1383,7 +1388,7 @@ static int snd_cs4281_create(struct snd_card *card,
1383 1388
1384 if (request_irq(pci->irq, snd_cs4281_interrupt, IRQF_SHARED, 1389 if (request_irq(pci->irq, snd_cs4281_interrupt, IRQF_SHARED,
1385 KBUILD_MODNAME, chip)) { 1390 KBUILD_MODNAME, chip)) {
1386 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1391 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1387 snd_cs4281_free(chip); 1392 snd_cs4281_free(chip);
1388 return -ENOMEM; 1393 return -ENOMEM;
1389 } 1394 }
@@ -1402,8 +1407,6 @@ static int snd_cs4281_create(struct snd_card *card,
1402 1407
1403 snd_cs4281_proc_init(chip); 1408 snd_cs4281_proc_init(chip);
1404 1409
1405 snd_card_set_dev(card, &pci->dev);
1406
1407 *rchip = chip; 1410 *rchip = chip;
1408 return 0; 1411 return 0;
1409} 1412}
@@ -1425,7 +1428,8 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
1425 snd_cs4281_pokeBA0(chip, BA0_CFLR, BA0_CFLR_DEFAULT); 1428 snd_cs4281_pokeBA0(chip, BA0_CFLR, BA0_CFLR_DEFAULT);
1426 tmp = snd_cs4281_peekBA0(chip, BA0_CFLR); 1429 tmp = snd_cs4281_peekBA0(chip, BA0_CFLR);
1427 if (tmp != BA0_CFLR_DEFAULT) { 1430 if (tmp != BA0_CFLR_DEFAULT) {
1428 snd_printk(KERN_ERR "CFLR setup failed (0x%x)\n", tmp); 1431 dev_err(chip->card->dev,
1432 "CFLR setup failed (0x%x)\n", tmp);
1429 return -EIO; 1433 return -EIO;
1430 } 1434 }
1431 } 1435 }
@@ -1436,11 +1440,13 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
1436 snd_cs4281_pokeBA0(chip, BA0_CWPR, 0x4281); 1440 snd_cs4281_pokeBA0(chip, BA0_CWPR, 0x4281);
1437 1441
1438 if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC1)) != (BA0_SERC1_SO1EN | BA0_SERC1_AC97)) { 1442 if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC1)) != (BA0_SERC1_SO1EN | BA0_SERC1_AC97)) {
1439 snd_printk(KERN_ERR "SERC1 AC'97 check failed (0x%x)\n", tmp); 1443 dev_err(chip->card->dev,
1444 "SERC1 AC'97 check failed (0x%x)\n", tmp);
1440 return -EIO; 1445 return -EIO;
1441 } 1446 }
1442 if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC2)) != (BA0_SERC2_SI1EN | BA0_SERC2_AC97)) { 1447 if ((tmp = snd_cs4281_peekBA0(chip, BA0_SERC2)) != (BA0_SERC2_SI1EN | BA0_SERC2_AC97)) {
1443 snd_printk(KERN_ERR "SERC2 AC'97 check failed (0x%x)\n", tmp); 1448 dev_err(chip->card->dev,
1449 "SERC2 AC'97 check failed (0x%x)\n", tmp);
1444 return -EIO; 1450 return -EIO;
1445 } 1451 }
1446 1452
@@ -1502,7 +1508,7 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
1502 schedule_timeout_uninterruptible(1); 1508 schedule_timeout_uninterruptible(1);
1503 } while (time_after_eq(end_time, jiffies)); 1509 } while (time_after_eq(end_time, jiffies));
1504 1510
1505 snd_printk(KERN_ERR "DLLRDY not seen\n"); 1511 dev_err(chip->card->dev, "DLLRDY not seen\n");
1506 return -EIO; 1512 return -EIO;
1507 1513
1508 __ok0: 1514 __ok0:
@@ -1528,7 +1534,9 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
1528 schedule_timeout_uninterruptible(1); 1534 schedule_timeout_uninterruptible(1);
1529 } while (time_after_eq(end_time, jiffies)); 1535 } while (time_after_eq(end_time, jiffies));
1530 1536
1531 snd_printk(KERN_ERR "never read codec ready from AC'97 (0x%x)\n", snd_cs4281_peekBA0(chip, BA0_ACSTS)); 1537 dev_err(chip->card->dev,
1538 "never read codec ready from AC'97 (0x%x)\n",
1539 snd_cs4281_peekBA0(chip, BA0_ACSTS));
1532 return -EIO; 1540 return -EIO;
1533 1541
1534 __ok1: 1542 __ok1:
@@ -1539,7 +1547,8 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
1539 goto __codec2_ok; 1547 goto __codec2_ok;
1540 schedule_timeout_uninterruptible(1); 1548 schedule_timeout_uninterruptible(1);
1541 } while (time_after_eq(end_time, jiffies)); 1549 } while (time_after_eq(end_time, jiffies));
1542 snd_printk(KERN_INFO "secondary codec doesn't respond. disable it...\n"); 1550 dev_info(chip->card->dev,
1551 "secondary codec doesn't respond. disable it...\n");
1543 chip->dual_codec = 0; 1552 chip->dual_codec = 0;
1544 __codec2_ok: ; 1553 __codec2_ok: ;
1545 } 1554 }
@@ -1569,7 +1578,7 @@ static int snd_cs4281_chip_init(struct cs4281 *chip)
1569 1578
1570 if (--retry_count > 0) 1579 if (--retry_count > 0)
1571 goto __retry; 1580 goto __retry;
1572 snd_printk(KERN_ERR "never read ISV3 and ISV4 from AC'97\n"); 1581 dev_err(chip->card->dev, "never read ISV3 and ISV4 from AC'97\n");
1573 return -EIO; 1582 return -EIO;
1574 1583
1575 __ok2: 1584 __ok2:
@@ -1917,7 +1926,8 @@ static int snd_cs4281_probe(struct pci_dev *pci,
1917 return -ENOENT; 1926 return -ENOENT;
1918 } 1927 }
1919 1928
1920 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1929 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1930 0, &card);
1921 if (err < 0) 1931 if (err < 0)
1922 return err; 1932 return err;
1923 1933
@@ -2055,8 +2065,7 @@ static int cs4281_resume(struct device *dev)
2055 pci_set_power_state(pci, PCI_D0); 2065 pci_set_power_state(pci, PCI_D0);
2056 pci_restore_state(pci); 2066 pci_restore_state(pci);
2057 if (pci_enable_device(pci) < 0) { 2067 if (pci_enable_device(pci) < 0) {
2058 printk(KERN_ERR "cs4281: pci_enable_device failed, " 2068 dev_err(dev, "pci_enable_device failed, disabling device\n");
2059 "disabling device\n");
2060 snd_card_disconnect(card); 2069 snd_card_disconnect(card);
2061 return -EIO; 2070 return -EIO;
2062 } 2071 }
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
index b03498325d66..af0eacbc8bd2 100644
--- a/sound/pci/cs46xx/cs46xx.c
+++ b/sound/pci/cs46xx/cs46xx.c
@@ -88,7 +88,8 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci,
88 return -ENOENT; 88 return -ENOENT;
89 } 89 }
90 90
91 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 91 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
92 0, &card);
92 if (err < 0) 93 if (err < 0)
93 return err; 94 return err;
94 if ((err = snd_cs46xx_create(card, pci, 95 if ((err = snd_cs46xx_create(card, pci,
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index 062398ec5335..32b44f25b5c8 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -116,7 +116,7 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
116 116
117 tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL); 117 tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL);
118 if ((tmp & ACCTL_VFRM) == 0) { 118 if ((tmp & ACCTL_VFRM) == 0) {
119 snd_printk(KERN_WARNING "cs46xx: ACCTL_VFRM not set 0x%x\n",tmp); 119 dev_warn(chip->card->dev, "ACCTL_VFRM not set 0x%x\n", tmp);
120 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, (tmp & (~ACCTL_ESYN)) | ACCTL_VFRM ); 120 snd_cs46xx_pokeBA0(chip, BA0_ACCTL, (tmp & (~ACCTL_ESYN)) | ACCTL_VFRM );
121 msleep(50); 121 msleep(50);
122 tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL + offset); 122 tmp = snd_cs46xx_peekBA0(chip, BA0_ACCTL + offset);
@@ -168,7 +168,8 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
168 goto ok1; 168 goto ok1;
169 } 169 }
170 170
171 snd_printk(KERN_ERR "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg); 171 dev_err(chip->card->dev,
172 "AC'97 read problem (ACCTL_DCV), reg = 0x%x\n", reg);
172 result = 0xffff; 173 result = 0xffff;
173 goto end; 174 goto end;
174 175
@@ -187,7 +188,9 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
187 udelay(10); 188 udelay(10);
188 } 189 }
189 190
190 snd_printk(KERN_ERR "AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n", codec_index, reg); 191 dev_err(chip->card->dev,
192 "AC'97 read problem (ACSTS_VSTS), codec_index %d, reg = 0x%x\n",
193 codec_index, reg);
191 result = 0xffff; 194 result = 0xffff;
192 goto end; 195 goto end;
193 196
@@ -197,7 +200,8 @@ static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip,
197 * ACSDA = Status Data Register = 474h 200 * ACSDA = Status Data Register = 474h
198 */ 201 */
199#if 0 202#if 0
200 printk(KERN_DEBUG "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg, 203 dev_dbg(chip->card->dev,
204 "e) reg = 0x%x, val = 0x%x, BA0_ACCAD = 0x%x\n", reg,
201 snd_cs46xx_peekBA0(chip, BA0_ACSDA), 205 snd_cs46xx_peekBA0(chip, BA0_ACSDA),
202 snd_cs46xx_peekBA0(chip, BA0_ACCAD)); 206 snd_cs46xx_peekBA0(chip, BA0_ACCAD));
203#endif 207#endif
@@ -286,7 +290,9 @@ static void snd_cs46xx_codec_write(struct snd_cs46xx *chip,
286 goto end; 290 goto end;
287 } 291 }
288 } 292 }
289 snd_printk(KERN_ERR "AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n", codec_index, reg, val); 293 dev_err(chip->card->dev,
294 "AC'97 write problem, codec_index = %d, reg = 0x%x, val = 0x%x\n",
295 codec_index, reg, val);
290 end: 296 end:
291 chip->active_ctrl(chip, -1); 297 chip->active_ctrl(chip, -1);
292} 298}
@@ -608,8 +614,8 @@ static int cs46xx_wait_for_fifo(struct snd_cs46xx * chip,int retry_timeout)
608 } 614 }
609 615
610 if(status & SERBST_WBSY) { 616 if(status & SERBST_WBSY) {
611 snd_printk(KERN_ERR "cs46xx: failure waiting for " 617 dev_err(chip->card->dev,
612 "FIFO command to complete\n"); 618 "failure waiting for FIFO command to complete\n");
613 return -EINVAL; 619 return -EINVAL;
614 } 620 }
615 621
@@ -646,7 +652,9 @@ static void snd_cs46xx_clear_serial_FIFOs(struct snd_cs46xx *chip)
646 * Make sure the previous FIFO write operation has completed. 652 * Make sure the previous FIFO write operation has completed.
647 */ 653 */
648 if (cs46xx_wait_for_fifo(chip,1)) { 654 if (cs46xx_wait_for_fifo(chip,1)) {
649 snd_printdd ("failed waiting for FIFO at addr (%02X)\n",idx); 655 dev_dbg(chip->card->dev,
656 "failed waiting for FIFO at addr (%02X)\n",
657 idx);
650 658
651 if (powerdown) 659 if (powerdown)
652 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); 660 snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp);
@@ -694,7 +702,7 @@ static void snd_cs46xx_proc_start(struct snd_cs46xx *chip)
694 } 702 }
695 703
696 if (snd_cs46xx_peek(chip, BA1_SPCR) & SPCR_RUNFR) 704 if (snd_cs46xx_peek(chip, BA1_SPCR) & SPCR_RUNFR)
697 snd_printk(KERN_ERR "SPCR_RUNFR never reset\n"); 705 dev_err(chip->card->dev, "SPCR_RUNFR never reset\n");
698} 706}
699 707
700static void snd_cs46xx_proc_stop(struct snd_cs46xx *chip) 708static void snd_cs46xx_proc_stop(struct snd_cs46xx *chip)
@@ -1054,7 +1062,8 @@ static int _cs46xx_adjust_sample_rate (struct snd_cs46xx *chip, struct snd_cs46x
1054 cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, 1062 cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate,
1055 cpcm, cpcm->hw_buf.addr,cpcm->pcm_channel_id); 1063 cpcm, cpcm->hw_buf.addr,cpcm->pcm_channel_id);
1056 if (cpcm->pcm_channel == NULL) { 1064 if (cpcm->pcm_channel == NULL) {
1057 snd_printk(KERN_ERR "cs46xx: failed to create virtual PCM channel\n"); 1065 dev_err(chip->card->dev,
1066 "failed to create virtual PCM channel\n");
1058 return -ENOMEM; 1067 return -ENOMEM;
1059 } 1068 }
1060 cpcm->pcm_channel->sample_rate = sample_rate; 1069 cpcm->pcm_channel->sample_rate = sample_rate;
@@ -1067,7 +1076,8 @@ static int _cs46xx_adjust_sample_rate (struct snd_cs46xx *chip, struct snd_cs46x
1067 if ( (cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, cpcm, 1076 if ( (cpcm->pcm_channel = cs46xx_dsp_create_pcm_channel (chip, sample_rate, cpcm,
1068 cpcm->hw_buf.addr, 1077 cpcm->hw_buf.addr,
1069 cpcm->pcm_channel_id)) == NULL) { 1078 cpcm->pcm_channel_id)) == NULL) {
1070 snd_printk(KERN_ERR "cs46xx: failed to re-create virtual PCM channel\n"); 1079 dev_err(chip->card->dev,
1080 "failed to re-create virtual PCM channel\n");
1071 return -ENOMEM; 1081 return -ENOMEM;
1072 } 1082 }
1073 1083
@@ -1116,7 +1126,8 @@ static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream,
1116 return -EINVAL; 1126 return -EINVAL;
1117 } 1127 }
1118 1128
1119 snd_printdd ("period_size (%d), periods (%d) buffer_size(%d)\n", 1129 dev_dbg(chip->card->dev,
1130 "period_size (%d), periods (%d) buffer_size(%d)\n",
1120 period_size, params_periods(hw_params), 1131 period_size, params_periods(hw_params),
1121 params_buffer_bytes(hw_params)); 1132 params_buffer_bytes(hw_params));
1122#endif 1133#endif
@@ -1531,22 +1542,20 @@ static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,in
1531 1542
1532static int snd_cs46xx_playback_open(struct snd_pcm_substream *substream) 1543static int snd_cs46xx_playback_open(struct snd_pcm_substream *substream)
1533{ 1544{
1534 snd_printdd("open front channel\n"); 1545 dev_dbg(substream->pcm->card->dev, "open front channel\n");
1535 return _cs46xx_playback_open_channel(substream,DSP_PCM_MAIN_CHANNEL); 1546 return _cs46xx_playback_open_channel(substream,DSP_PCM_MAIN_CHANNEL);
1536} 1547}
1537 1548
1538#ifdef CONFIG_SND_CS46XX_NEW_DSP 1549#ifdef CONFIG_SND_CS46XX_NEW_DSP
1539static int snd_cs46xx_playback_open_rear(struct snd_pcm_substream *substream) 1550static int snd_cs46xx_playback_open_rear(struct snd_pcm_substream *substream)
1540{ 1551{
1541 snd_printdd("open rear channel\n"); 1552 dev_dbg(substream->pcm->card->dev, "open rear channel\n");
1542
1543 return _cs46xx_playback_open_channel(substream,DSP_PCM_REAR_CHANNEL); 1553 return _cs46xx_playback_open_channel(substream,DSP_PCM_REAR_CHANNEL);
1544} 1554}
1545 1555
1546static int snd_cs46xx_playback_open_clfe(struct snd_pcm_substream *substream) 1556static int snd_cs46xx_playback_open_clfe(struct snd_pcm_substream *substream)
1547{ 1557{
1548 snd_printdd("open center - LFE channel\n"); 1558 dev_dbg(substream->pcm->card->dev, "open center - LFE channel\n");
1549
1550 return _cs46xx_playback_open_channel(substream,DSP_PCM_CENTER_LFE_CHANNEL); 1559 return _cs46xx_playback_open_channel(substream,DSP_PCM_CENTER_LFE_CHANNEL);
1551} 1560}
1552 1561
@@ -1554,7 +1563,7 @@ static int snd_cs46xx_playback_open_iec958(struct snd_pcm_substream *substream)
1554{ 1563{
1555 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); 1564 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
1556 1565
1557 snd_printdd("open raw iec958 channel\n"); 1566 dev_dbg(chip->card->dev, "open raw iec958 channel\n");
1558 1567
1559 mutex_lock(&chip->spos_mutex); 1568 mutex_lock(&chip->spos_mutex);
1560 cs46xx_iec958_pre_open (chip); 1569 cs46xx_iec958_pre_open (chip);
@@ -1570,7 +1579,7 @@ static int snd_cs46xx_playback_close_iec958(struct snd_pcm_substream *substream)
1570 int err; 1579 int err;
1571 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); 1580 struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);
1572 1581
1573 snd_printdd("close raw iec958 channel\n"); 1582 dev_dbg(chip->card->dev, "close raw iec958 channel\n");
1574 1583
1575 err = snd_cs46xx_playback_close(substream); 1584 err = snd_cs46xx_playback_close(substream);
1576 1585
@@ -2421,10 +2430,10 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
2421 2430
2422 /* set the desired CODEC mode */ 2431 /* set the desired CODEC mode */
2423 if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) { 2432 if (ac97->num == CS46XX_PRIMARY_CODEC_INDEX) {
2424 snd_printdd("cs46xx: CODEC1 mode %04x\n", 0x0); 2433 dev_dbg(ac97->bus->card->dev, "CODEC1 mode %04x\n", 0x0);
2425 snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x0); 2434 snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x0);
2426 } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) { 2435 } else if (ac97->num == CS46XX_SECONDARY_CODEC_INDEX) {
2427 snd_printdd("cs46xx: CODEC2 mode %04x\n", 0x3); 2436 dev_dbg(ac97->bus->card->dev, "CODEC2 mode %04x\n", 0x3);
2428 snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x3); 2437 snd_cs46xx_ac97_write(ac97, AC97_CSR_ACMODE, 0x3);
2429 } else { 2438 } else {
2430 snd_BUG(); /* should never happen ... */ 2439 snd_BUG(); /* should never happen ... */
@@ -2456,7 +2465,8 @@ static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97)
2456 msleep(10); 2465 msleep(10);
2457 } while (time_after_eq(end_time, jiffies)); 2466 } while (time_after_eq(end_time, jiffies));
2458 2467
2459 snd_printk(KERN_ERR "CS46xx secondary codec doesn't respond!\n"); 2468 dev_err(ac97->bus->card->dev,
2469 "CS46xx secondary codec doesn't respond!\n");
2460} 2470}
2461#endif 2471#endif
2462 2472
@@ -2476,7 +2486,8 @@ static int cs46xx_detect_codec(struct snd_cs46xx *chip, int codec)
2476 snd_cs46xx_codec_write(chip, AC97_RESET, 0, codec); 2486 snd_cs46xx_codec_write(chip, AC97_RESET, 0, codec);
2477 udelay(10); 2487 udelay(10);
2478 if (snd_cs46xx_codec_read(chip, AC97_RESET, codec) & 0x8000) { 2488 if (snd_cs46xx_codec_read(chip, AC97_RESET, codec) & 0x8000) {
2479 snd_printdd("snd_cs46xx: seconadry codec not present\n"); 2489 dev_dbg(chip->card->dev,
2490 "seconadry codec not present\n");
2480 return -ENXIO; 2491 return -ENXIO;
2481 } 2492 }
2482 } 2493 }
@@ -2489,7 +2500,7 @@ static int cs46xx_detect_codec(struct snd_cs46xx *chip, int codec)
2489 } 2500 }
2490 msleep(10); 2501 msleep(10);
2491 } 2502 }
2492 snd_printdd("snd_cs46xx: codec %d detection timeout\n", codec); 2503 dev_dbg(chip->card->dev, "codec %d detection timeout\n", codec);
2493 return -ENXIO; 2504 return -ENXIO;
2494} 2505}
2495 2506
@@ -2509,7 +2520,7 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device)
2509 2520
2510 /* detect primary codec */ 2521 /* detect primary codec */
2511 chip->nr_ac97_codecs = 0; 2522 chip->nr_ac97_codecs = 0;
2512 snd_printdd("snd_cs46xx: detecting primary codec\n"); 2523 dev_dbg(chip->card->dev, "detecting primary codec\n");
2513 if ((err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus)) < 0) 2524 if ((err = snd_ac97_bus(card, 0, &ops, chip, &chip->ac97_bus)) < 0)
2514 return err; 2525 return err;
2515 chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus; 2526 chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus;
@@ -2519,7 +2530,7 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device)
2519 chip->nr_ac97_codecs = 1; 2530 chip->nr_ac97_codecs = 1;
2520 2531
2521#ifdef CONFIG_SND_CS46XX_NEW_DSP 2532#ifdef CONFIG_SND_CS46XX_NEW_DSP
2522 snd_printdd("snd_cs46xx: detecting seconadry codec\n"); 2533 dev_dbg(chip->card->dev, "detecting seconadry codec\n");
2523 /* try detect a secondary codec */ 2534 /* try detect a secondary codec */
2524 if (! cs46xx_detect_codec(chip, CS46XX_SECONDARY_CODEC_INDEX)) 2535 if (! cs46xx_detect_codec(chip, CS46XX_SECONDARY_CODEC_INDEX))
2525 chip->nr_ac97_codecs = 2; 2536 chip->nr_ac97_codecs = 2;
@@ -2554,7 +2565,7 @@ int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device)
2554 } 2565 }
2555 /* do soundcard specific mixer setup */ 2566 /* do soundcard specific mixer setup */
2556 if (chip->mixer_init) { 2567 if (chip->mixer_init) {
2557 snd_printdd ("calling chip->mixer_init(chip);\n"); 2568 dev_dbg(chip->card->dev, "calling chip->mixer_init(chip);\n");
2558 chip->mixer_init(chip); 2569 chip->mixer_init(chip);
2559 } 2570 }
2560#endif 2571#endif
@@ -2801,7 +2812,8 @@ int snd_cs46xx_gameport(struct snd_cs46xx *chip)
2801 2812
2802 chip->gameport = gp = gameport_allocate_port(); 2813 chip->gameport = gp = gameport_allocate_port();
2803 if (!gp) { 2814 if (!gp) {
2804 printk(KERN_ERR "cs46xx: cannot allocate memory for gameport\n"); 2815 dev_err(chip->card->dev,
2816 "cannot allocate memory for gameport\n");
2805 return -ENOMEM; 2817 return -ENOMEM;
2806 } 2818 }
2807 2819
@@ -3138,8 +3150,10 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3138 } 3150 }
3139 3151
3140 3152
3141 snd_printk(KERN_ERR "create - never read codec ready from AC'97\n"); 3153 dev_err(chip->card->dev,
3142 snd_printk(KERN_ERR "it is not probably bug, try to use CS4236 driver\n"); 3154 "create - never read codec ready from AC'97\n");
3155 dev_err(chip->card->dev,
3156 "it is not probably bug, try to use CS4236 driver\n");
3143 return -EIO; 3157 return -EIO;
3144 ok1: 3158 ok1:
3145#ifdef CONFIG_SND_CS46XX_NEW_DSP 3159#ifdef CONFIG_SND_CS46XX_NEW_DSP
@@ -3157,7 +3171,8 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3157 * Make sure CODEC is READY. 3171 * Make sure CODEC is READY.
3158 */ 3172 */
3159 if (!(snd_cs46xx_peekBA0(chip, BA0_ACSTS2) & ACSTS_CRDY)) 3173 if (!(snd_cs46xx_peekBA0(chip, BA0_ACSTS2) & ACSTS_CRDY))
3160 snd_printdd("cs46xx: never read card ready from secondary AC'97\n"); 3174 dev_dbg(chip->card->dev,
3175 "never read card ready from secondary AC'97\n");
3161 } 3176 }
3162#endif 3177#endif
3163 3178
@@ -3187,17 +3202,21 @@ static int snd_cs46xx_chip_init(struct snd_cs46xx *chip)
3187 } 3202 }
3188 3203
3189#ifndef CONFIG_SND_CS46XX_NEW_DSP 3204#ifndef CONFIG_SND_CS46XX_NEW_DSP
3190 snd_printk(KERN_ERR "create - never read ISV3 & ISV4 from AC'97\n"); 3205 dev_err(chip->card->dev,
3206 "create - never read ISV3 & ISV4 from AC'97\n");
3191 return -EIO; 3207 return -EIO;
3192#else 3208#else
3193 /* This may happen on a cold boot with a Terratec SiXPack 5.1. 3209 /* This may happen on a cold boot with a Terratec SiXPack 5.1.
3194 Reloading the driver may help, if there's other soundcards 3210 Reloading the driver may help, if there's other soundcards
3195 with the same problem I would like to know. (Benny) */ 3211 with the same problem I would like to know. (Benny) */
3196 3212
3197 snd_printk(KERN_ERR "ERROR: snd-cs46xx: never read ISV3 & ISV4 from AC'97\n"); 3213 dev_err(chip->card->dev, "never read ISV3 & ISV4 from AC'97\n");
3198 snd_printk(KERN_ERR " Try reloading the ALSA driver, if you find something\n"); 3214 dev_err(chip->card->dev,
3199 snd_printk(KERN_ERR " broken or not working on your soundcard upon\n"); 3215 "Try reloading the ALSA driver, if you find something\n");
3200 snd_printk(KERN_ERR " this message please report to alsa-devel@alsa-project.org\n"); 3216 dev_err(chip->card->dev,
3217 "broken or not working on your soundcard upon\n");
3218 dev_err(chip->card->dev,
3219 "this message please report to alsa-devel@alsa-project.org\n");
3201 3220
3202 return -EIO; 3221 return -EIO;
3203#endif 3222#endif
@@ -3266,13 +3285,13 @@ int snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
3266 for (i = 0; i < CS46XX_DSP_MODULES; i++) { 3285 for (i = 0; i < CS46XX_DSP_MODULES; i++) {
3267 err = load_firmware(chip, &chip->modules[i], module_names[i]); 3286 err = load_firmware(chip, &chip->modules[i], module_names[i]);
3268 if (err < 0) { 3287 if (err < 0) {
3269 snd_printk(KERN_ERR "firmware load error [%s]\n", 3288 dev_err(chip->card->dev, "firmware load error [%s]\n",
3270 module_names[i]); 3289 module_names[i]);
3271 return err; 3290 return err;
3272 } 3291 }
3273 err = cs46xx_dsp_load_module(chip, chip->modules[i]); 3292 err = cs46xx_dsp_load_module(chip, chip->modules[i]);
3274 if (err < 0) { 3293 if (err < 0) {
3275 snd_printk(KERN_ERR "image download error [%s]\n", 3294 dev_err(chip->card->dev, "image download error [%s]\n",
3276 module_names[i]); 3295 module_names[i]);
3277 return err; 3296 return err;
3278 } 3297 }
@@ -3288,7 +3307,7 @@ int snd_cs46xx_start_dsp(struct snd_cs46xx *chip)
3288 /* old image */ 3307 /* old image */
3289 err = snd_cs46xx_download_image(chip); 3308 err = snd_cs46xx_download_image(chip);
3290 if (err < 0) { 3309 if (err < 0) {
3291 snd_printk(KERN_ERR "image download error\n"); 3310 dev_err(chip->card->dev, "image download error\n");
3292 return err; 3311 return err;
3293 } 3312 }
3294 3313
@@ -3341,7 +3360,7 @@ static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip)
3341 u32 idx, valid_slots,tmp,powerdown = 0; 3360 u32 idx, valid_slots,tmp,powerdown = 0;
3342 u16 modem_power,pin_config,logic_type; 3361 u16 modem_power,pin_config,logic_type;
3343 3362
3344 snd_printdd ("cs46xx: cs46xx_setup_eapd_slot()+\n"); 3363 dev_dbg(chip->card->dev, "cs46xx_setup_eapd_slot()+\n");
3345 3364
3346 /* 3365 /*
3347 * See if the devices are powered down. If so, we must power them up first 3366 * See if the devices are powered down. If so, we must power them up first
@@ -3359,7 +3378,8 @@ static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip)
3359 * stuff. 3378 * stuff.
3360 */ 3379 */
3361 if(chip->nr_ac97_codecs != 2) { 3380 if(chip->nr_ac97_codecs != 2) {
3362 snd_printk (KERN_ERR "cs46xx: cs46xx_setup_eapd_slot() - no secondary codec configured\n"); 3381 dev_err(chip->card->dev,
3382 "cs46xx_setup_eapd_slot() - no secondary codec configured\n");
3363 return -EINVAL; 3383 return -EINVAL;
3364 } 3384 }
3365 3385
@@ -3400,7 +3420,7 @@ static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip)
3400 snd_cs46xx_pokeBA0(chip, BA0_ACOSV, valid_slots); 3420 snd_cs46xx_pokeBA0(chip, BA0_ACOSV, valid_slots);
3401 3421
3402 if ( cs46xx_wait_for_fifo(chip,1) ) { 3422 if ( cs46xx_wait_for_fifo(chip,1) ) {
3403 snd_printdd("FIFO is busy\n"); 3423 dev_dbg(chip->card->dev, "FIFO is busy\n");
3404 3424
3405 return -EINVAL; 3425 return -EINVAL;
3406 } 3426 }
@@ -3421,7 +3441,9 @@ static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip)
3421 * Wait for command to complete 3441 * Wait for command to complete
3422 */ 3442 */
3423 if ( cs46xx_wait_for_fifo(chip,200) ) { 3443 if ( cs46xx_wait_for_fifo(chip,200) ) {
3424 snd_printdd("failed waiting for FIFO at addr (%02X)\n",idx); 3444 dev_dbg(chip->card->dev,
3445 "failed waiting for FIFO at addr (%02X)\n",
3446 idx);
3425 3447
3426 return -EINVAL; 3448 return -EINVAL;
3427 } 3449 }
@@ -3510,14 +3532,14 @@ static void amp_hercules(struct snd_cs46xx *chip, int change)
3510 3532
3511 chip->amplifier += change; 3533 chip->amplifier += change;
3512 if (chip->amplifier && !old) { 3534 if (chip->amplifier && !old) {
3513 snd_printdd ("Hercules amplifier ON\n"); 3535 dev_dbg(chip->card->dev, "Hercules amplifier ON\n");
3514 3536
3515 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, 3537 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR,
3516 EGPIODR_GPOE2 | val1); /* enable EGPIO2 output */ 3538 EGPIODR_GPOE2 | val1); /* enable EGPIO2 output */
3517 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, 3539 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR,
3518 EGPIOPTR_GPPT2 | val2); /* open-drain on output */ 3540 EGPIOPTR_GPPT2 | val2); /* open-drain on output */
3519 } else if (old && !chip->amplifier) { 3541 } else if (old && !chip->amplifier) {
3520 snd_printdd ("Hercules amplifier OFF\n"); 3542 dev_dbg(chip->card->dev, "Hercules amplifier OFF\n");
3521 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, val1 & ~EGPIODR_GPOE2); /* disable */ 3543 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, val1 & ~EGPIODR_GPOE2); /* disable */
3522 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, val2 & ~EGPIOPTR_GPPT2); /* disable */ 3544 snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, val2 & ~EGPIOPTR_GPPT2); /* disable */
3523 } 3545 }
@@ -3525,7 +3547,7 @@ static void amp_hercules(struct snd_cs46xx *chip, int change)
3525 3547
3526static void voyetra_mixer_init (struct snd_cs46xx *chip) 3548static void voyetra_mixer_init (struct snd_cs46xx *chip)
3527{ 3549{
3528 snd_printdd ("initializing Voyetra mixer\n"); 3550 dev_dbg(chip->card->dev, "initializing Voyetra mixer\n");
3529 3551
3530 /* Enable SPDIF out */ 3552 /* Enable SPDIF out */
3531 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, EGPIODR_GPOE0); 3553 snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, EGPIODR_GPOE0);
@@ -3543,7 +3565,7 @@ static void hercules_mixer_init (struct snd_cs46xx *chip)
3543 /* set EGPIO to default */ 3565 /* set EGPIO to default */
3544 hercules_init(chip); 3566 hercules_init(chip);
3545 3567
3546 snd_printdd ("initializing Hercules mixer\n"); 3568 dev_dbg(chip->card->dev, "initializing Hercules mixer\n");
3547 3569
3548#ifdef CONFIG_SND_CS46XX_NEW_DSP 3570#ifdef CONFIG_SND_CS46XX_NEW_DSP
3549 if (chip->in_suspend) 3571 if (chip->in_suspend)
@@ -3554,7 +3576,9 @@ static void hercules_mixer_init (struct snd_cs46xx *chip)
3554 3576
3555 kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip); 3577 kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip);
3556 if ((err = snd_ctl_add(card, kctl)) < 0) { 3578 if ((err = snd_ctl_add(card, kctl)) < 0) {
3557 printk (KERN_ERR "cs46xx: failed to initialize Hercules mixer (%d)\n",err); 3579 dev_err(card->dev,
3580 "failed to initialize Hercules mixer (%d)\n",
3581 err);
3558 break; 3582 break;
3559 } 3583 }
3560 } 3584 }
@@ -3826,8 +3850,7 @@ static int snd_cs46xx_resume(struct device *dev)
3826 pci_set_power_state(pci, PCI_D0); 3850 pci_set_power_state(pci, PCI_D0);
3827 pci_restore_state(pci); 3851 pci_restore_state(pci);
3828 if (pci_enable_device(pci) < 0) { 3852 if (pci_enable_device(pci) < 0) {
3829 printk(KERN_ERR "cs46xx: pci_enable_device failed, " 3853 dev_err(dev, "pci_enable_device failed, disabling device\n");
3830 "disabling device\n");
3831 snd_card_disconnect(card); 3854 snd_card_disconnect(card);
3832 return -EIO; 3855 return -EIO;
3833 } 3856 }
@@ -3932,7 +3955,8 @@ int snd_cs46xx_create(struct snd_card *card,
3932 chip->ba1_addr = pci_resource_start(pci, 1); 3955 chip->ba1_addr = pci_resource_start(pci, 1);
3933 if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 || 3956 if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 ||
3934 chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) { 3957 chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) {
3935 snd_printk(KERN_ERR "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", 3958 dev_err(chip->card->dev,
3959 "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n",
3936 chip->ba0_addr, chip->ba1_addr); 3960 chip->ba0_addr, chip->ba1_addr);
3937 snd_cs46xx_free(chip); 3961 snd_cs46xx_free(chip);
3938 return -ENOMEM; 3962 return -ENOMEM;
@@ -3969,7 +3993,8 @@ int snd_cs46xx_create(struct snd_card *card,
3969 3993
3970 for (cp = &cards[0]; cp->name; cp++) { 3994 for (cp = &cards[0]; cp->name; cp++) {
3971 if (cp->vendor == ss_vendor && cp->id == ss_card) { 3995 if (cp->vendor == ss_vendor && cp->id == ss_card) {
3972 snd_printdd ("hack for %s enabled\n", cp->name); 3996 dev_dbg(chip->card->dev, "hack for %s enabled\n",
3997 cp->name);
3973 3998
3974 chip->amplifier_ctrl = cp->amp; 3999 chip->amplifier_ctrl = cp->amp;
3975 chip->active_ctrl = cp->active; 4000 chip->active_ctrl = cp->active;
@@ -3982,12 +4007,14 @@ int snd_cs46xx_create(struct snd_card *card,
3982 } 4007 }
3983 4008
3984 if (external_amp) { 4009 if (external_amp) {
3985 snd_printk(KERN_INFO "Crystal EAPD support forced on.\n"); 4010 dev_info(chip->card->dev,
4011 "Crystal EAPD support forced on.\n");
3986 chip->amplifier_ctrl = amp_voyetra; 4012 chip->amplifier_ctrl = amp_voyetra;
3987 } 4013 }
3988 4014
3989 if (thinkpad) { 4015 if (thinkpad) {
3990 snd_printk(KERN_INFO "Activating CLKRUN hack for Thinkpad.\n"); 4016 dev_info(chip->card->dev,
4017 "Activating CLKRUN hack for Thinkpad.\n");
3991 chip->active_ctrl = clkrun_hack; 4018 chip->active_ctrl = clkrun_hack;
3992 clkrun_init(chip); 4019 clkrun_init(chip);
3993 } 4020 }
@@ -4005,14 +4032,16 @@ int snd_cs46xx_create(struct snd_card *card,
4005 region = &chip->region.idx[idx]; 4032 region = &chip->region.idx[idx];
4006 if ((region->resource = request_mem_region(region->base, region->size, 4033 if ((region->resource = request_mem_region(region->base, region->size,
4007 region->name)) == NULL) { 4034 region->name)) == NULL) {
4008 snd_printk(KERN_ERR "unable to request memory region 0x%lx-0x%lx\n", 4035 dev_err(chip->card->dev,
4036 "unable to request memory region 0x%lx-0x%lx\n",
4009 region->base, region->base + region->size - 1); 4037 region->base, region->base + region->size - 1);
4010 snd_cs46xx_free(chip); 4038 snd_cs46xx_free(chip);
4011 return -EBUSY; 4039 return -EBUSY;
4012 } 4040 }
4013 region->remap_addr = ioremap_nocache(region->base, region->size); 4041 region->remap_addr = ioremap_nocache(region->base, region->size);
4014 if (region->remap_addr == NULL) { 4042 if (region->remap_addr == NULL) {
4015 snd_printk(KERN_ERR "%s ioremap problem\n", region->name); 4043 dev_err(chip->card->dev,
4044 "%s ioremap problem\n", region->name);
4016 snd_cs46xx_free(chip); 4045 snd_cs46xx_free(chip);
4017 return -ENOMEM; 4046 return -ENOMEM;
4018 } 4047 }
@@ -4020,7 +4049,7 @@ int snd_cs46xx_create(struct snd_card *card,
4020 4049
4021 if (request_irq(pci->irq, snd_cs46xx_interrupt, IRQF_SHARED, 4050 if (request_irq(pci->irq, snd_cs46xx_interrupt, IRQF_SHARED,
4022 KBUILD_MODNAME, chip)) { 4051 KBUILD_MODNAME, chip)) {
4023 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 4052 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
4024 snd_cs46xx_free(chip); 4053 snd_cs46xx_free(chip);
4025 return -EBUSY; 4054 return -EBUSY;
4026 } 4055 }
@@ -4058,8 +4087,6 @@ int snd_cs46xx_create(struct snd_card *card,
4058 4087
4059 chip->active_ctrl(chip, -1); /* disable CLKRUN */ 4088 chip->active_ctrl(chip, -1); /* disable CLKRUN */
4060 4089
4061 snd_card_set_dev(card, &pci->dev);
4062
4063 *rchip = chip; 4090 *rchip = chip;
4064 return 0; 4091 return 0;
4065} 4092}
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 1686b4f4c44f..1c4a0fb3ffef 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -85,12 +85,15 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
85 address = (hival & 0x00FFF) << 5; 85 address = (hival & 0x00FFF) << 5;
86 address |= loval >> 15; 86 address |= loval >> 15;
87 87
88 snd_printdd("handle_wideop[1]: %05x:%05x addr %04x\n",hival,loval,address); 88 dev_dbg(chip->card->dev,
89 "handle_wideop[1]: %05x:%05x addr %04x\n",
90 hival, loval, address);
89 91
90 if ( !(address & 0x8000) ) { 92 if ( !(address & 0x8000) ) {
91 address += (ins->code.offset / 2) - overlay_begin_address; 93 address += (ins->code.offset / 2) - overlay_begin_address;
92 } else { 94 } else {
93 snd_printdd("handle_wideop[1]: ROM symbol not reallocated\n"); 95 dev_dbg(chip->card->dev,
96 "handle_wideop[1]: ROM symbol not reallocated\n");
94 } 97 }
95 98
96 hival &= 0xFF000; 99 hival &= 0xFF000;
@@ -102,8 +105,9 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
102 address = (hival & 0x00FFF) << 5; 105 address = (hival & 0x00FFF) << 5;
103 address |= loval >> 15; 106 address |= loval >> 15;
104 107
105 snd_printdd("handle_wideop:[2] %05x:%05x addr %04x\n",hival,loval,address); 108 dev_dbg(chip->card->dev,
106 nreallocated ++; 109 "handle_wideop:[2] %05x:%05x addr %04x\n",
110 hival, loval, address); nreallocated++;
107 } /* wide_opcodes[j] == wide_op */ 111 } /* wide_opcodes[j] == wide_op */
108 } /* for */ 112 } /* for */
109 } /* mod_type == 0 ... */ 113 } /* mod_type == 0 ... */
@@ -113,7 +117,8 @@ static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32
113 ins->code.data[ins->code.size++] = hival; 117 ins->code.data[ins->code.size++] = hival;
114 } 118 }
115 119
116 snd_printdd("dsp_spos: %d instructions reallocated\n",nreallocated); 120 dev_dbg(chip->card->dev,
121 "dsp_spos: %d instructions reallocated\n", nreallocated);
117 return nreallocated; 122 return nreallocated;
118} 123}
119 124
@@ -157,7 +162,8 @@ static int add_symbols (struct snd_cs46xx * chip, struct dsp_module_desc * modul
157 162
158 for (i = 0;i < module->symbol_table.nsymbols; ++i) { 163 for (i = 0;i < module->symbol_table.nsymbols; ++i) {
159 if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) { 164 if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) {
160 snd_printk(KERN_ERR "dsp_spos: symbol table is full\n"); 165 dev_err(chip->card->dev,
166 "dsp_spos: symbol table is full\n");
161 return -ENOMEM; 167 return -ENOMEM;
162 } 168 }
163 169
@@ -176,8 +182,11 @@ static int add_symbols (struct snd_cs46xx * chip, struct dsp_module_desc * modul
176 182
177 ins->symbol_table.nsymbols++; 183 ins->symbol_table.nsymbols++;
178 } else { 184 } else {
179 /* if (0) printk ("dsp_spos: symbol <%s> duplicated, probably nothing wrong with that (Cirrus?)\n", 185#if 0
180 module->symbol_table.symbols[i].symbol_name); */ 186 dev_dbg(chip->card->dev,
187 "dsp_spos: symbol <%s> duplicated, probably nothing wrong with that (Cirrus?)\n",
188 module->symbol_table.symbols[i].symbol_name); */
189#endif
181 } 190 }
182 } 191 }
183 192
@@ -192,14 +201,15 @@ add_symbol (struct snd_cs46xx * chip, char * symbol_name, u32 address, int type)
192 int index; 201 int index;
193 202
194 if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) { 203 if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) {
195 snd_printk(KERN_ERR "dsp_spos: symbol table is full\n"); 204 dev_err(chip->card->dev, "dsp_spos: symbol table is full\n");
196 return NULL; 205 return NULL;
197 } 206 }
198 207
199 if (cs46xx_dsp_lookup_symbol(chip, 208 if (cs46xx_dsp_lookup_symbol(chip,
200 symbol_name, 209 symbol_name,
201 type) != NULL) { 210 type) != NULL) {
202 snd_printk(KERN_ERR "dsp_spos: symbol <%s> duplicated\n", symbol_name); 211 dev_err(chip->card->dev,
212 "dsp_spos: symbol <%s> duplicated\n", symbol_name);
203 return NULL; 213 return NULL;
204 } 214 }
205 215
@@ -305,19 +315,20 @@ static int dsp_load_parameter(struct snd_cs46xx *chip,
305 u32 doffset, dsize; 315 u32 doffset, dsize;
306 316
307 if (!parameter) { 317 if (!parameter) {
308 snd_printdd("dsp_spos: module got no parameter segment\n"); 318 dev_dbg(chip->card->dev,
319 "dsp_spos: module got no parameter segment\n");
309 return 0; 320 return 0;
310 } 321 }
311 322
312 doffset = (parameter->offset * 4 + DSP_PARAMETER_BYTE_OFFSET); 323 doffset = (parameter->offset * 4 + DSP_PARAMETER_BYTE_OFFSET);
313 dsize = parameter->size * 4; 324 dsize = parameter->size * 4;
314 325
315 snd_printdd("dsp_spos: " 326 dev_dbg(chip->card->dev,
316 "downloading parameter data to chip (%08x-%08x)\n", 327 "dsp_spos: downloading parameter data to chip (%08x-%08x)\n",
317 doffset,doffset + dsize); 328 doffset,doffset + dsize);
318 if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) { 329 if (snd_cs46xx_download (chip, parameter->data, doffset, dsize)) {
319 snd_printk(KERN_ERR "dsp_spos: " 330 dev_err(chip->card->dev,
320 "failed to download parameter data to DSP\n"); 331 "dsp_spos: failed to download parameter data to DSP\n");
321 return -EINVAL; 332 return -EINVAL;
322 } 333 }
323 return 0; 334 return 0;
@@ -329,18 +340,21 @@ static int dsp_load_sample(struct snd_cs46xx *chip,
329 u32 doffset, dsize; 340 u32 doffset, dsize;
330 341
331 if (!sample) { 342 if (!sample) {
332 snd_printdd("dsp_spos: module got no sample segment\n"); 343 dev_dbg(chip->card->dev,
344 "dsp_spos: module got no sample segment\n");
333 return 0; 345 return 0;
334 } 346 }
335 347
336 doffset = (sample->offset * 4 + DSP_SAMPLE_BYTE_OFFSET); 348 doffset = (sample->offset * 4 + DSP_SAMPLE_BYTE_OFFSET);
337 dsize = sample->size * 4; 349 dsize = sample->size * 4;
338 350
339 snd_printdd("dsp_spos: downloading sample data to chip (%08x-%08x)\n", 351 dev_dbg(chip->card->dev,
352 "dsp_spos: downloading sample data to chip (%08x-%08x)\n",
340 doffset,doffset + dsize); 353 doffset,doffset + dsize);
341 354
342 if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) { 355 if (snd_cs46xx_download (chip,sample->data,doffset,dsize)) {
343 snd_printk(KERN_ERR "dsp_spos: failed to sample data to DSP\n"); 356 dev_err(chip->card->dev,
357 "dsp_spos: failed to sample data to DSP\n");
344 return -EINVAL; 358 return -EINVAL;
345 } 359 }
346 return 0; 360 return 0;
@@ -354,14 +368,16 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
354 int err; 368 int err;
355 369
356 if (ins->nmodules == DSP_MAX_MODULES - 1) { 370 if (ins->nmodules == DSP_MAX_MODULES - 1) {
357 snd_printk(KERN_ERR "dsp_spos: to many modules loaded into DSP\n"); 371 dev_err(chip->card->dev,
372 "dsp_spos: to many modules loaded into DSP\n");
358 return -ENOMEM; 373 return -ENOMEM;
359 } 374 }
360 375
361 snd_printdd("dsp_spos: loading module %s into DSP\n", module->module_name); 376 dev_dbg(chip->card->dev,
377 "dsp_spos: loading module %s into DSP\n", module->module_name);
362 378
363 if (ins->nmodules == 0) { 379 if (ins->nmodules == 0) {
364 snd_printdd("dsp_spos: clearing parameter area\n"); 380 dev_dbg(chip->card->dev, "dsp_spos: clearing parameter area\n");
365 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE); 381 snd_cs46xx_clear_BA1(chip, DSP_PARAMETER_BYTE_OFFSET, DSP_PARAMETER_BYTE_SIZE);
366 } 382 }
367 383
@@ -371,7 +387,7 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
371 return err; 387 return err;
372 388
373 if (ins->nmodules == 0) { 389 if (ins->nmodules == 0) {
374 snd_printdd("dsp_spos: clearing sample area\n"); 390 dev_dbg(chip->card->dev, "dsp_spos: clearing sample area\n");
375 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE); 391 snd_cs46xx_clear_BA1(chip, DSP_SAMPLE_BYTE_OFFSET, DSP_SAMPLE_BYTE_SIZE);
376 } 392 }
377 393
@@ -381,15 +397,17 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
381 return err; 397 return err;
382 398
383 if (ins->nmodules == 0) { 399 if (ins->nmodules == 0) {
384 snd_printdd("dsp_spos: clearing code area\n"); 400 dev_dbg(chip->card->dev, "dsp_spos: clearing code area\n");
385 snd_cs46xx_clear_BA1(chip, DSP_CODE_BYTE_OFFSET, DSP_CODE_BYTE_SIZE); 401 snd_cs46xx_clear_BA1(chip, DSP_CODE_BYTE_OFFSET, DSP_CODE_BYTE_SIZE);
386 } 402 }
387 403
388 if (code == NULL) { 404 if (code == NULL) {
389 snd_printdd("dsp_spos: module got no code segment\n"); 405 dev_dbg(chip->card->dev,
406 "dsp_spos: module got no code segment\n");
390 } else { 407 } else {
391 if (ins->code.offset + code->size > DSP_CODE_BYTE_SIZE) { 408 if (ins->code.offset + code->size > DSP_CODE_BYTE_SIZE) {
392 snd_printk(KERN_ERR "dsp_spos: no space available in DSP\n"); 409 dev_err(chip->card->dev,
410 "dsp_spos: no space available in DSP\n");
393 return -ENOMEM; 411 return -ENOMEM;
394 } 412 }
395 413
@@ -401,19 +419,22 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * m
401 if (snd_BUG_ON(!module->symbol_table.symbols)) 419 if (snd_BUG_ON(!module->symbol_table.symbols))
402 return -ENOMEM; 420 return -ENOMEM;
403 if (add_symbols(chip,module)) { 421 if (add_symbols(chip,module)) {
404 snd_printk(KERN_ERR "dsp_spos: failed to load symbol table\n"); 422 dev_err(chip->card->dev,
423 "dsp_spos: failed to load symbol table\n");
405 return -ENOMEM; 424 return -ENOMEM;
406 } 425 }
407 426
408 doffset = (code->offset * 4 + ins->code.offset * 4 + DSP_CODE_BYTE_OFFSET); 427 doffset = (code->offset * 4 + ins->code.offset * 4 + DSP_CODE_BYTE_OFFSET);
409 dsize = code->size * 4; 428 dsize = code->size * 4;
410 snd_printdd("dsp_spos: downloading code to chip (%08x-%08x)\n", 429 dev_dbg(chip->card->dev,
430 "dsp_spos: downloading code to chip (%08x-%08x)\n",
411 doffset,doffset + dsize); 431 doffset,doffset + dsize);
412 432
413 module->nfixups = shadow_and_reallocate_code(chip,code->data,code->size,module->overlay_begin_address); 433 module->nfixups = shadow_and_reallocate_code(chip,code->data,code->size,module->overlay_begin_address);
414 434
415 if (snd_cs46xx_download (chip,(ins->code.data + ins->code.offset),doffset,dsize)) { 435 if (snd_cs46xx_download (chip,(ins->code.data + ins->code.offset),doffset,dsize)) {
416 snd_printk(KERN_ERR "dsp_spos: failed to download code to DSP\n"); 436 dev_err(chip->card->dev,
437 "dsp_spos: failed to download code to DSP\n");
417 return -EINVAL; 438 return -EINVAL;
418 } 439 }
419 440
@@ -447,7 +468,7 @@ cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, int symb
447 } 468 }
448 469
449#if 0 470#if 0
450 printk ("dsp_spos: symbol <%s> type %02x not found\n", 471 dev_err(chip->card->dev, "dsp_spos: symbol <%s> type %02x not found\n",
451 symbol_name,symbol_type); 472 symbol_name,symbol_type);
452#endif 473#endif
453 474
@@ -910,7 +931,6 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip)
910} 931}
911#endif /* CONFIG_PROC_FS */ 932#endif /* CONFIG_PROC_FS */
912 933
913static int debug_tree;
914static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data, 934static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data,
915 u32 dest, int size) 935 u32 dest, int size)
916{ 936{
@@ -919,13 +939,13 @@ static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data,
919 int i; 939 int i;
920 940
921 for (i = 0; i < size; ++i) { 941 for (i = 0; i < size; ++i) {
922 if (debug_tree) printk ("addr %p, val %08x\n",spdst,task_data[i]); 942 dev_dbg(chip->card->dev, "addr %p, val %08x\n",
943 spdst, task_data[i]);
923 writel(task_data[i],spdst); 944 writel(task_data[i],spdst);
924 spdst += sizeof(u32); 945 spdst += sizeof(u32);
925 } 946 }
926} 947}
927 948
928static int debug_scb;
929static void _dsp_create_scb (struct snd_cs46xx *chip, u32 * scb_data, u32 dest) 949static void _dsp_create_scb (struct snd_cs46xx *chip, u32 * scb_data, u32 dest)
930{ 950{
931 void __iomem *spdst = chip->region.idx[1].remap_addr + 951 void __iomem *spdst = chip->region.idx[1].remap_addr +
@@ -933,7 +953,8 @@ static void _dsp_create_scb (struct snd_cs46xx *chip, u32 * scb_data, u32 dest)
933 int i; 953 int i;
934 954
935 for (i = 0; i < 0x10; ++i) { 955 for (i = 0; i < 0x10; ++i) {
936 if (debug_scb) printk ("addr %p, val %08x\n",spdst,scb_data[i]); 956 dev_dbg(chip->card->dev, "addr %p, val %08x\n",
957 spdst, scb_data[i]);
937 writel(scb_data[i],spdst); 958 writel(scb_data[i],spdst);
938 spdst += sizeof(u32); 959 spdst += sizeof(u32);
939 } 960 }
@@ -960,7 +981,8 @@ static struct dsp_scb_descriptor * _map_scb (struct snd_cs46xx *chip, char * nam
960 int index; 981 int index;
961 982
962 if (ins->nscb == DSP_MAX_SCB_DESC - 1) { 983 if (ins->nscb == DSP_MAX_SCB_DESC - 1) {
963 snd_printk(KERN_ERR "dsp_spos: got no place for other SCB\n"); 984 dev_err(chip->card->dev,
985 "dsp_spos: got no place for other SCB\n");
964 return NULL; 986 return NULL;
965 } 987 }
966 988
@@ -991,7 +1013,8 @@ _map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size)
991 struct dsp_task_descriptor * desc = NULL; 1013 struct dsp_task_descriptor * desc = NULL;
992 1014
993 if (ins->ntask == DSP_MAX_TASK_DESC - 1) { 1015 if (ins->ntask == DSP_MAX_TASK_DESC - 1) {
994 snd_printk(KERN_ERR "dsp_spos: got no place for other TASK\n"); 1016 dev_err(chip->card->dev,
1017 "dsp_spos: got no place for other TASK\n");
995 return NULL; 1018 return NULL;
996 } 1019 }
997 1020
@@ -1031,7 +1054,7 @@ cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32
1031 desc->data = scb_data; 1054 desc->data = scb_data;
1032 _dsp_create_scb(chip,scb_data,dest); 1055 _dsp_create_scb(chip,scb_data,dest);
1033 } else { 1056 } else {
1034 snd_printk(KERN_ERR "dsp_spos: failed to map SCB\n"); 1057 dev_err(chip->card->dev, "dsp_spos: failed to map SCB\n");
1035#ifdef CONFIG_PM_SLEEP 1058#ifdef CONFIG_PM_SLEEP
1036 kfree(scb_data); 1059 kfree(scb_data);
1037#endif 1060#endif
@@ -1052,7 +1075,7 @@ cs46xx_dsp_create_task_tree (struct snd_cs46xx *chip, char * name, u32 * task_da
1052 desc->data = task_data; 1075 desc->data = task_data;
1053 _dsp_create_task_tree(chip,task_data,dest,size); 1076 _dsp_create_task_tree(chip,task_data,dest,size);
1054 } else { 1077 } else {
1055 snd_printk(KERN_ERR "dsp_spos: failed to map TASK\n"); 1078 dev_err(chip->card->dev, "dsp_spos: failed to map TASK\n");
1056 } 1079 }
1057 1080
1058 return desc; 1081 return desc;
@@ -1105,31 +1128,36 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
1105 1128
1106 null_algorithm = cs46xx_dsp_lookup_symbol(chip, "NULLALGORITHM", SYMBOL_CODE); 1129 null_algorithm = cs46xx_dsp_lookup_symbol(chip, "NULLALGORITHM", SYMBOL_CODE);
1107 if (null_algorithm == NULL) { 1130 if (null_algorithm == NULL) {
1108 snd_printk(KERN_ERR "dsp_spos: symbol NULLALGORITHM not found\n"); 1131 dev_err(chip->card->dev,
1132 "dsp_spos: symbol NULLALGORITHM not found\n");
1109 return -EIO; 1133 return -EIO;
1110 } 1134 }
1111 1135
1112 fg_task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "FGTASKTREEHEADERCODE", SYMBOL_CODE); 1136 fg_task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "FGTASKTREEHEADERCODE", SYMBOL_CODE);
1113 if (fg_task_tree_header_code == NULL) { 1137 if (fg_task_tree_header_code == NULL) {
1114 snd_printk(KERN_ERR "dsp_spos: symbol FGTASKTREEHEADERCODE not found\n"); 1138 dev_err(chip->card->dev,
1139 "dsp_spos: symbol FGTASKTREEHEADERCODE not found\n");
1115 return -EIO; 1140 return -EIO;
1116 } 1141 }
1117 1142
1118 task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "TASKTREEHEADERCODE", SYMBOL_CODE); 1143 task_tree_header_code = cs46xx_dsp_lookup_symbol(chip, "TASKTREEHEADERCODE", SYMBOL_CODE);
1119 if (task_tree_header_code == NULL) { 1144 if (task_tree_header_code == NULL) {
1120 snd_printk(KERN_ERR "dsp_spos: symbol TASKTREEHEADERCODE not found\n"); 1145 dev_err(chip->card->dev,
1146 "dsp_spos: symbol TASKTREEHEADERCODE not found\n");
1121 return -EIO; 1147 return -EIO;
1122 } 1148 }
1123 1149
1124 task_tree_thread = cs46xx_dsp_lookup_symbol(chip, "TASKTREETHREAD", SYMBOL_CODE); 1150 task_tree_thread = cs46xx_dsp_lookup_symbol(chip, "TASKTREETHREAD", SYMBOL_CODE);
1125 if (task_tree_thread == NULL) { 1151 if (task_tree_thread == NULL) {
1126 snd_printk(KERN_ERR "dsp_spos: symbol TASKTREETHREAD not found\n"); 1152 dev_err(chip->card->dev,
1153 "dsp_spos: symbol TASKTREETHREAD not found\n");
1127 return -EIO; 1154 return -EIO;
1128 } 1155 }
1129 1156
1130 magic_snoop_task = cs46xx_dsp_lookup_symbol(chip, "MAGICSNOOPTASK", SYMBOL_CODE); 1157 magic_snoop_task = cs46xx_dsp_lookup_symbol(chip, "MAGICSNOOPTASK", SYMBOL_CODE);
1131 if (magic_snoop_task == NULL) { 1158 if (magic_snoop_task == NULL) {
1132 snd_printk(KERN_ERR "dsp_spos: symbol MAGICSNOOPTASK not found\n"); 1159 dev_err(chip->card->dev,
1160 "dsp_spos: symbol MAGICSNOOPTASK not found\n");
1133 return -EIO; 1161 return -EIO;
1134 } 1162 }
1135 1163
@@ -1476,7 +1504,7 @@ int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip)
1476 return 0; 1504 return 0;
1477 1505
1478 _fail_end: 1506 _fail_end:
1479 snd_printk(KERN_ERR "dsp_spos: failed to setup SCB's in DSP\n"); 1507 dev_err(chip->card->dev, "dsp_spos: failed to setup SCB's in DSP\n");
1480 return -EINVAL; 1508 return -EINVAL;
1481} 1509}
1482 1510
@@ -1491,18 +1519,21 @@ static int cs46xx_dsp_async_init (struct snd_cs46xx *chip,
1491 1519
1492 s16_async_codec_input_task = cs46xx_dsp_lookup_symbol(chip, "S16_ASYNCCODECINPUTTASK", SYMBOL_CODE); 1520 s16_async_codec_input_task = cs46xx_dsp_lookup_symbol(chip, "S16_ASYNCCODECINPUTTASK", SYMBOL_CODE);
1493 if (s16_async_codec_input_task == NULL) { 1521 if (s16_async_codec_input_task == NULL) {
1494 snd_printk(KERN_ERR "dsp_spos: symbol S16_ASYNCCODECINPUTTASK not found\n"); 1522 dev_err(chip->card->dev,
1523 "dsp_spos: symbol S16_ASYNCCODECINPUTTASK not found\n");
1495 return -EIO; 1524 return -EIO;
1496 } 1525 }
1497 spdifo_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFOTASK", SYMBOL_CODE); 1526 spdifo_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFOTASK", SYMBOL_CODE);
1498 if (spdifo_task == NULL) { 1527 if (spdifo_task == NULL) {
1499 snd_printk(KERN_ERR "dsp_spos: symbol SPDIFOTASK not found\n"); 1528 dev_err(chip->card->dev,
1529 "dsp_spos: symbol SPDIFOTASK not found\n");
1500 return -EIO; 1530 return -EIO;
1501 } 1531 }
1502 1532
1503 spdifi_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFITASK", SYMBOL_CODE); 1533 spdifi_task = cs46xx_dsp_lookup_symbol(chip, "SPDIFITASK", SYMBOL_CODE);
1504 if (spdifi_task == NULL) { 1534 if (spdifi_task == NULL) {
1505 snd_printk(KERN_ERR "dsp_spos: symbol SPDIFITASK not found\n"); 1535 dev_err(chip->card->dev,
1536 "dsp_spos: symbol SPDIFITASK not found\n");
1506 return -EIO; 1537 return -EIO;
1507 } 1538 }
1508 1539
@@ -1883,7 +1914,8 @@ int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data)
1883 } 1914 }
1884 1915
1885 if (i == 25) { 1916 if (i == 25) {
1886 snd_printk(KERN_ERR "dsp_spos: SPIOWriteTask not responding\n"); 1917 dev_err(chip->card->dev,
1918 "dsp_spos: SPIOWriteTask not responding\n");
1887 return -EBUSY; 1919 return -EBUSY;
1888 } 1920 }
1889 1921
diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
index 409e8764fbeb..8284bc9b5858 100644
--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
+++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
@@ -233,8 +233,11 @@ void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb)
233{ 233{
234 if (scb->proc_info) { 234 if (scb->proc_info) {
235 struct proc_scb_info * scb_info = scb->proc_info->private_data; 235 struct proc_scb_info * scb_info = scb->proc_info->private_data;
236 struct snd_cs46xx *chip = scb_info->chip;
236 237
237 snd_printdd("cs46xx_dsp_proc_free_scb_desc: freeing %s\n",scb->scb_name); 238 dev_dbg(chip->card->dev,
239 "cs46xx_dsp_proc_free_scb_desc: freeing %s\n",
240 scb->scb_name);
238 241
239 snd_info_free_entry(scb->proc_info); 242 snd_info_free_entry(scb->proc_info);
240 scb->proc_info = NULL; 243 scb->proc_info = NULL;
@@ -305,7 +308,7 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
305 scb_data[SCBfuncEntryPtr] &= 0xFFFF0000; 308 scb_data[SCBfuncEntryPtr] &= 0xFFFF0000;
306 scb_data[SCBfuncEntryPtr] |= task_entry->address; 309 scb_data[SCBfuncEntryPtr] |= task_entry->address;
307 310
308 snd_printdd("dsp_spos: creating SCB <%s>\n",name); 311 dev_dbg(chip->card->dev, "dsp_spos: creating SCB <%s>\n", name);
309 312
310 scb = cs46xx_dsp_create_scb(chip,name,scb_data,dest); 313 scb = cs46xx_dsp_create_scb(chip,name,scb_data,dest);
311 314
@@ -320,9 +323,15 @@ _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u
320 /* update parent SCB */ 323 /* update parent SCB */
321 if (scb->parent_scb_ptr) { 324 if (scb->parent_scb_ptr) {
322#if 0 325#if 0
323 printk ("scb->parent_scb_ptr = %s\n",scb->parent_scb_ptr->scb_name); 326 dev_dbg(chip->card->dev,
324 printk ("scb->parent_scb_ptr->next_scb_ptr = %s\n",scb->parent_scb_ptr->next_scb_ptr->scb_name); 327 "scb->parent_scb_ptr = %s\n",
325 printk ("scb->parent_scb_ptr->sub_list_ptr = %s\n",scb->parent_scb_ptr->sub_list_ptr->scb_name); 328 scb->parent_scb_ptr->scb_name);
329 dev_dbg(chip->card->dev,
330 "scb->parent_scb_ptr->next_scb_ptr = %s\n",
331 scb->parent_scb_ptr->next_scb_ptr->scb_name);
332 dev_dbg(chip->card->dev,
333 "scb->parent_scb_ptr->sub_list_ptr = %s\n",
334 scb->parent_scb_ptr->sub_list_ptr->scb_name);
326#endif 335#endif
327 /* link to parent SCB */ 336 /* link to parent SCB */
328 if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) { 337 if (scb_child_type == SCB_ON_PARENT_NEXT_SCB) {
@@ -368,7 +377,8 @@ cs46xx_dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_d
368 SYMBOL_CODE); 377 SYMBOL_CODE);
369 378
370 if (task_entry == NULL) { 379 if (task_entry == NULL) {
371 snd_printk (KERN_ERR "dsp_spos: symbol %s not found\n",task_entry_name); 380 dev_err(chip->card->dev,
381 "dsp_spos: symbol %s not found\n", task_entry_name);
372 return NULL; 382 return NULL;
373 } 383 }
374 384
@@ -582,7 +592,8 @@ cs46xx_dsp_create_pcm_reader_scb(struct snd_cs46xx * chip, char * scb_name,
582 SYMBOL_CODE); 592 SYMBOL_CODE);
583 593
584 if (ins->null_algorithm == NULL) { 594 if (ins->null_algorithm == NULL) {
585 snd_printk (KERN_ERR "dsp_spos: symbol NULLALGORITHM not found\n"); 595 dev_err(chip->card->dev,
596 "dsp_spos: symbol NULLALGORITHM not found\n");
586 return NULL; 597 return NULL;
587 } 598 }
588 } 599 }
@@ -612,7 +623,8 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
612 unsigned int phiIncr; 623 unsigned int phiIncr;
613 unsigned int correctionPerGOF, correctionPerSec; 624 unsigned int correctionPerGOF, correctionPerSec;
614 625
615 snd_printdd( "dsp_spos: setting %s rate to %u\n",scb_name,rate); 626 dev_dbg(chip->card->dev, "dsp_spos: setting %s rate to %u\n",
627 scb_name, rate);
616 628
617 /* 629 /*
618 * Compute the values used to drive the actual sample rate conversion. 630 * Compute the values used to drive the actual sample rate conversion.
@@ -670,7 +682,8 @@ cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name,
670 SYMBOL_CODE); 682 SYMBOL_CODE);
671 683
672 if (ins->s16_up == NULL) { 684 if (ins->s16_up == NULL) {
673 snd_printk (KERN_ERR "dsp_spos: symbol S16_UPSRC not found\n"); 685 dev_err(chip->card->dev,
686 "dsp_spos: symbol S16_UPSRC not found\n");
674 return NULL; 687 return NULL;
675 } 688 }
676 } 689 }
@@ -1265,7 +1278,7 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1265 the Sample Rate Converted (which could 1278 the Sample Rate Converted (which could
1266 alter the raw data stream ...) */ 1279 alter the raw data stream ...) */
1267 if (sample_rate == 48000) { 1280 if (sample_rate == 48000) {
1268 snd_printdd ("IEC958 pass through\n"); 1281 dev_dbg(chip->card->dev, "IEC958 pass through\n");
1269 /* Hack to bypass creating a new SRC */ 1282 /* Hack to bypass creating a new SRC */
1270 pass_through = 1; 1283 pass_through = 1;
1271 } 1284 }
@@ -1299,13 +1312,14 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1299 } 1312 }
1300 1313
1301 if (pcm_index == -1) { 1314 if (pcm_index == -1) {
1302 snd_printk (KERN_ERR "dsp_spos: no free PCM channel\n"); 1315 dev_err(chip->card->dev, "dsp_spos: no free PCM channel\n");
1303 return NULL; 1316 return NULL;
1304 } 1317 }
1305 1318
1306 if (src_scb == NULL) { 1319 if (src_scb == NULL) {
1307 if (ins->nsrc_scb >= DSP_MAX_SRC_NR) { 1320 if (ins->nsrc_scb >= DSP_MAX_SRC_NR) {
1308 snd_printk(KERN_ERR "dsp_spos: to many SRC instances\n!"); 1321 dev_err(chip->card->dev,
1322 "dsp_spos: to many SRC instances\n!");
1309 return NULL; 1323 return NULL;
1310 } 1324 }
1311 1325
@@ -1331,7 +1345,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1331 1345
1332 snprintf (scb_name,DSP_MAX_SCB_NAME,"SrcTask_SCB%d",src_index); 1346 snprintf (scb_name,DSP_MAX_SCB_NAME,"SrcTask_SCB%d",src_index);
1333 1347
1334 snd_printdd( "dsp_spos: creating SRC \"%s\"\n",scb_name); 1348 dev_dbg(chip->card->dev,
1349 "dsp_spos: creating SRC \"%s\"\n", scb_name);
1335 src_scb = cs46xx_dsp_create_src_task_scb(chip,scb_name, 1350 src_scb = cs46xx_dsp_create_src_task_scb(chip,scb_name,
1336 sample_rate, 1351 sample_rate,
1337 src_output_buffer_addr[src_index], 1352 src_output_buffer_addr[src_index],
@@ -1343,7 +1358,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1343 pass_through); 1358 pass_through);
1344 1359
1345 if (!src_scb) { 1360 if (!src_scb) {
1346 snd_printk (KERN_ERR "dsp_spos: failed to create SRCtaskSCB\n"); 1361 dev_err(chip->card->dev,
1362 "dsp_spos: failed to create SRCtaskSCB\n");
1347 return NULL; 1363 return NULL;
1348 } 1364 }
1349 1365
@@ -1355,8 +1371,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1355 1371
1356 snprintf (scb_name,DSP_MAX_SCB_NAME,"PCMReader_SCB%d",pcm_index); 1372 snprintf (scb_name,DSP_MAX_SCB_NAME,"PCMReader_SCB%d",pcm_index);
1357 1373
1358 snd_printdd( "dsp_spos: creating PCM \"%s\" (%d)\n",scb_name, 1374 dev_dbg(chip->card->dev, "dsp_spos: creating PCM \"%s\" (%d)\n",
1359 pcm_channel_id); 1375 scb_name, pcm_channel_id);
1360 1376
1361 pcm_scb = cs46xx_dsp_create_pcm_reader_scb(chip,scb_name, 1377 pcm_scb = cs46xx_dsp_create_pcm_reader_scb(chip,scb_name,
1362 pcm_reader_buffer_addr[pcm_index], 1378 pcm_reader_buffer_addr[pcm_index],
@@ -1369,7 +1385,8 @@ cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip,
1369 ); 1385 );
1370 1386
1371 if (!pcm_scb) { 1387 if (!pcm_scb) {
1372 snd_printk (KERN_ERR "dsp_spos: failed to create PCMreaderSCB\n"); 1388 dev_err(chip->card->dev,
1389 "dsp_spos: failed to create PCMreaderSCB\n");
1373 return NULL; 1390 return NULL;
1374 } 1391 }
1375 1392
@@ -1419,7 +1436,8 @@ int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip,
1419 temp |= DMA_RQ_C1_SOURCE_MOD16; 1436 temp |= DMA_RQ_C1_SOURCE_MOD16;
1420 break; 1437 break;
1421 default: 1438 default:
1422 snd_printdd ("period size (%d) not supported by HW\n", period_size); 1439 dev_dbg(chip->card->dev,
1440 "period size (%d) not supported by HW\n", period_size);
1423 return -EINVAL; 1441 return -EINVAL;
1424 } 1442 }
1425 1443
@@ -1457,7 +1475,8 @@ int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip,
1457 temp |= DMA_RQ_C1_DEST_MOD16; 1475 temp |= DMA_RQ_C1_DEST_MOD16;
1458 break; 1476 break;
1459 default: 1477 default:
1460 snd_printdd ("period size (%d) not supported by HW\n", period_size); 1478 dev_dbg(chip->card->dev,
1479 "period size (%d) not supported by HW\n", period_size);
1461 return -EINVAL; 1480 return -EINVAL;
1462 } 1481 }
1463 1482
diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c
index c6b82c85e044..b4e0ff6a99a3 100644
--- a/sound/pci/cs5530.c
+++ b/sound/pci/cs5530.c
@@ -160,17 +160,17 @@ static int snd_cs5530_create(struct snd_card *card,
160 sb_base = 0x220 + 0x20 * (map & 3); 160 sb_base = 0x220 + 0x20 * (map & 3);
161 161
162 if (map & (1<<2)) 162 if (map & (1<<2))
163 printk(KERN_INFO "CS5530: XpressAudio at 0x%lx\n", sb_base); 163 dev_info(card->dev, "XpressAudio at 0x%lx\n", sb_base);
164 else { 164 else {
165 printk(KERN_ERR "Could not find XpressAudio!\n"); 165 dev_err(card->dev, "Could not find XpressAudio!\n");
166 snd_cs5530_free(chip); 166 snd_cs5530_free(chip);
167 return -ENODEV; 167 return -ENODEV;
168 } 168 }
169 169
170 if (map & (1<<5)) 170 if (map & (1<<5))
171 printk(KERN_INFO "CS5530: MPU at 0x300\n"); 171 dev_info(card->dev, "MPU at 0x300\n");
172 else if (map & (1<<6)) 172 else if (map & (1<<6))
173 printk(KERN_INFO "CS5530: MPU at 0x330\n"); 173 dev_info(card->dev, "MPU at 0x330\n");
174 174
175 irq = snd_cs5530_mixer_read(sb_base, 0x80) & 0x0F; 175 irq = snd_cs5530_mixer_read(sb_base, 0x80) & 0x0F;
176 dma8 = snd_cs5530_mixer_read(sb_base, 0x81); 176 dma8 = snd_cs5530_mixer_read(sb_base, 0x81);
@@ -182,7 +182,7 @@ static int snd_cs5530_create(struct snd_card *card,
182 else if (dma8 & 0x80) 182 else if (dma8 & 0x80)
183 dma16 = 7; 183 dma16 = 7;
184 else { 184 else {
185 printk(KERN_ERR "CS5530: No 16bit DMA enabled\n"); 185 dev_err(card->dev, "No 16bit DMA enabled\n");
186 snd_cs5530_free(chip); 186 snd_cs5530_free(chip);
187 return -ENODEV; 187 return -ENODEV;
188 } 188 }
@@ -194,7 +194,7 @@ static int snd_cs5530_create(struct snd_card *card,
194 else if (dma8 & 0x08) 194 else if (dma8 & 0x08)
195 dma8 = 3; 195 dma8 = 3;
196 else { 196 else {
197 printk(KERN_ERR "CS5530: No 8bit DMA enabled\n"); 197 dev_err(card->dev, "No 8bit DMA enabled\n");
198 snd_cs5530_free(chip); 198 snd_cs5530_free(chip);
199 return -ENODEV; 199 return -ENODEV;
200 } 200 }
@@ -208,32 +208,31 @@ static int snd_cs5530_create(struct snd_card *card,
208 else if (irq & 8) 208 else if (irq & 8)
209 irq = 10; 209 irq = 10;
210 else { 210 else {
211 printk(KERN_ERR "CS5530: SoundBlaster IRQ not set\n"); 211 dev_err(card->dev, "SoundBlaster IRQ not set\n");
212 snd_cs5530_free(chip); 212 snd_cs5530_free(chip);
213 return -ENODEV; 213 return -ENODEV;
214 } 214 }
215 215
216 printk(KERN_INFO "CS5530: IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8, 216 dev_info(card->dev, "IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8, dma16);
217 dma16);
218 217
219 err = snd_sbdsp_create(card, sb_base, irq, snd_sb16dsp_interrupt, dma8, 218 err = snd_sbdsp_create(card, sb_base, irq, snd_sb16dsp_interrupt, dma8,
220 dma16, SB_HW_CS5530, &chip->sb); 219 dma16, SB_HW_CS5530, &chip->sb);
221 if (err < 0) { 220 if (err < 0) {
222 printk(KERN_ERR "CS5530: Could not create SoundBlaster\n"); 221 dev_err(card->dev, "Could not create SoundBlaster\n");
223 snd_cs5530_free(chip); 222 snd_cs5530_free(chip);
224 return err; 223 return err;
225 } 224 }
226 225
227 err = snd_sb16dsp_pcm(chip->sb, 0, &chip->sb->pcm); 226 err = snd_sb16dsp_pcm(chip->sb, 0, &chip->sb->pcm);
228 if (err < 0) { 227 if (err < 0) {
229 printk(KERN_ERR "CS5530: Could not create PCM\n"); 228 dev_err(card->dev, "Could not create PCM\n");
230 snd_cs5530_free(chip); 229 snd_cs5530_free(chip);
231 return err; 230 return err;
232 } 231 }
233 232
234 err = snd_sbmixer_new(chip->sb); 233 err = snd_sbmixer_new(chip->sb);
235 if (err < 0) { 234 if (err < 0) {
236 printk(KERN_ERR "CS5530: Could not create Mixer\n"); 235 dev_err(card->dev, "Could not create Mixer\n");
237 snd_cs5530_free(chip); 236 snd_cs5530_free(chip);
238 return err; 237 return err;
239 } 238 }
@@ -244,7 +243,6 @@ static int snd_cs5530_create(struct snd_card *card,
244 return err; 243 return err;
245 } 244 }
246 245
247 snd_card_set_dev(card, &pci->dev);
248 *rchip = chip; 246 *rchip = chip;
249 return 0; 247 return 0;
250} 248}
@@ -264,7 +262,8 @@ static int snd_cs5530_probe(struct pci_dev *pci,
264 return -ENOENT; 262 return -ENOENT;
265 } 263 }
266 264
267 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 265 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
266 0, &card);
268 267
269 if (err < 0) 268 if (err < 0)
270 return err; 269 return err;
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c
index c0d2835344da..edcbbda5c488 100644
--- a/sound/pci/cs5535audio/cs5535audio.c
+++ b/sound/pci/cs5535audio/cs5535audio.c
@@ -84,7 +84,8 @@ static void wait_till_cmd_acked(struct cs5535audio *cs5535au, unsigned long time
84 udelay(1); 84 udelay(1);
85 } while (--timeout); 85 } while (--timeout);
86 if (!timeout) 86 if (!timeout)
87 snd_printk(KERN_ERR "Failure writing to cs5535 codec\n"); 87 dev_err(cs5535au->card->dev,
88 "Failure writing to cs5535 codec\n");
88} 89}
89 90
90static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au, 91static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au,
@@ -109,8 +110,9 @@ static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au,
109 udelay(1); 110 udelay(1);
110 } while (--timeout); 111 } while (--timeout);
111 if (!timeout) 112 if (!timeout)
112 snd_printk(KERN_ERR "Failure reading codec reg 0x%x," 113 dev_err(cs5535au->card->dev,
113 "Last value=0x%x\n", reg, val); 114 "Failure reading codec reg 0x%x, Last value=0x%x\n",
115 reg, val);
114 116
115 return (unsigned short) val; 117 return (unsigned short) val;
116} 118}
@@ -168,7 +170,7 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
168 olpc_prequirks(card, &ac97); 170 olpc_prequirks(card, &ac97);
169 171
170 if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { 172 if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) {
171 snd_printk(KERN_ERR "mixer failed\n"); 173 dev_err(card->dev, "mixer failed\n");
172 return err; 174 return err;
173 } 175 }
174 176
@@ -176,7 +178,7 @@ static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au)
176 178
177 err = olpc_quirks(card, cs5535au->ac97); 179 err = olpc_quirks(card, cs5535au->ac97);
178 if (err < 0) { 180 if (err < 0) {
179 snd_printk(KERN_ERR "olpc quirks failed\n"); 181 dev_err(card->dev, "olpc quirks failed\n");
180 return err; 182 return err;
181 } 183 }
182 184
@@ -194,8 +196,9 @@ static void process_bm0_irq(struct cs5535audio *cs5535au)
194 dma = cs5535au->playback_substream->runtime->private_data; 196 dma = cs5535au->playback_substream->runtime->private_data;
195 snd_pcm_period_elapsed(cs5535au->playback_substream); 197 snd_pcm_period_elapsed(cs5535au->playback_substream);
196 } else { 198 } else {
197 snd_printk(KERN_ERR "unexpected bm0 irq src, bm_stat=%x\n", 199 dev_err(cs5535au->card->dev,
198 bm_stat); 200 "unexpected bm0 irq src, bm_stat=%x\n",
201 bm_stat);
199 } 202 }
200} 203}
201 204
@@ -241,8 +244,9 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id)
241 process_bm1_irq(cs5535au); 244 process_bm1_irq(cs5535au);
242 break; 245 break;
243 default: 246 default:
244 snd_printk(KERN_ERR "Unexpected irq src: " 247 dev_err(cs5535au->card->dev,
245 "0x%x\n", acc_irq_stat); 248 "Unexpected irq src: 0x%x\n",
249 acc_irq_stat);
246 break; 250 break;
247 } 251 }
248 } 252 }
@@ -287,7 +291,7 @@ static int snd_cs5535audio_create(struct snd_card *card,
287 291
288 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 || 292 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0 ||
289 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) { 293 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
290 printk(KERN_WARNING "unable to get 32bit dma\n"); 294 dev_warn(card->dev, "unable to get 32bit dma\n");
291 err = -ENXIO; 295 err = -ENXIO;
292 goto pcifail; 296 goto pcifail;
293 } 297 }
@@ -312,7 +316,7 @@ static int snd_cs5535audio_create(struct snd_card *card,
312 316
313 if (request_irq(pci->irq, snd_cs5535audio_interrupt, 317 if (request_irq(pci->irq, snd_cs5535audio_interrupt,
314 IRQF_SHARED, KBUILD_MODNAME, cs5535au)) { 318 IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {
315 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 319 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
316 err = -EBUSY; 320 err = -EBUSY;
317 goto sndfail; 321 goto sndfail;
318 } 322 }
@@ -324,8 +328,6 @@ static int snd_cs5535audio_create(struct snd_card *card,
324 cs5535au, &ops)) < 0) 328 cs5535au, &ops)) < 0)
325 goto sndfail; 329 goto sndfail;
326 330
327 snd_card_set_dev(card, &pci->dev);
328
329 *rcs5535au = cs5535au; 331 *rcs5535au = cs5535au;
330 return 0; 332 return 0;
331 333
@@ -353,7 +355,8 @@ static int snd_cs5535audio_probe(struct pci_dev *pci,
353 return -ENOENT; 355 return -ENOENT;
354 } 356 }
355 357
356 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 358 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
359 0, &card);
357 if (err < 0) 360 if (err < 0)
358 return err; 361 return err;
359 362
diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c
index e6a44507d557..3b0fdaca8dc7 100644
--- a/sound/pci/cs5535audio/cs5535audio_olpc.c
+++ b/sound/pci/cs5535audio/cs5535audio_olpc.c
@@ -36,7 +36,8 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on)
36 err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, 36 err = snd_ac97_update_bits(ac97, AC97_AD_TEST2,
37 1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT); 37 1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT);
38 if (err < 0) { 38 if (err < 0) {
39 snd_printk(KERN_ERR "setting High Pass Filter - %d\n", err); 39 dev_err(ac97->bus->card->dev,
40 "setting High Pass Filter - %d\n", err);
40 return; 41 return;
41 } 42 }
42 43
@@ -58,7 +59,7 @@ void olpc_mic_bias(struct snd_ac97 *ac97, int on)
58 err = snd_ac97_update_bits(ac97, AC97_AD_MISC, 59 err = snd_ac97_update_bits(ac97, AC97_AD_MISC,
59 1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT); 60 1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT);
60 if (err < 0) 61 if (err < 0)
61 snd_printk(KERN_ERR "setting MIC Bias - %d\n", err); 62 dev_err(ac97->bus->card->dev, "setting MIC Bias - %d\n", err);
62} 63}
63 64
64static int olpc_dc_info(struct snd_kcontrol *kctl, 65static int olpc_dc_info(struct snd_kcontrol *kctl,
@@ -153,7 +154,7 @@ int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
153 return 0; 154 return 0;
154 155
155 if (gpio_request(OLPC_GPIO_MIC_AC, DRV_NAME)) { 156 if (gpio_request(OLPC_GPIO_MIC_AC, DRV_NAME)) {
156 printk(KERN_ERR DRV_NAME ": unable to allocate MIC GPIO\n"); 157 dev_err(card->dev, "unable to allocate MIC GPIO\n");
157 return -EIO; 158 return -EIO;
158 } 159 }
159 gpio_direction_output(OLPC_GPIO_MIC_AC, 0); 160 gpio_direction_output(OLPC_GPIO_MIC_AC, 0);
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c
index 9ab01a7047cf..9c2dc911d8d7 100644
--- a/sound/pci/cs5535audio/cs5535audio_pcm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pcm.c
@@ -317,7 +317,7 @@ static int snd_cs5535audio_trigger(struct snd_pcm_substream *substream, int cmd)
317 dma->ops->disable_dma(cs5535au); 317 dma->ops->disable_dma(cs5535au);
318 break; 318 break;
319 default: 319 default:
320 snd_printk(KERN_ERR "unhandled trigger\n"); 320 dev_err(cs5535au->card->dev, "unhandled trigger\n");
321 err = -EINVAL; 321 err = -EINVAL;
322 break; 322 break;
323 } 323 }
@@ -335,13 +335,13 @@ static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(struct snd_pcm_substream
335 dma = substream->runtime->private_data; 335 dma = substream->runtime->private_data;
336 curdma = dma->ops->read_dma_pntr(cs5535au); 336 curdma = dma->ops->read_dma_pntr(cs5535au);
337 if (curdma < dma->buf_addr) { 337 if (curdma < dma->buf_addr) {
338 snd_printk(KERN_ERR "curdma=%x < %x bufaddr.\n", 338 dev_err(cs5535au->card->dev, "curdma=%x < %x bufaddr.\n",
339 curdma, dma->buf_addr); 339 curdma, dma->buf_addr);
340 return 0; 340 return 0;
341 } 341 }
342 curdma -= dma->buf_addr; 342 curdma -= dma->buf_addr;
343 if (curdma >= dma->buf_bytes) { 343 if (curdma >= dma->buf_bytes) {
344 snd_printk(KERN_ERR "diff=%x >= %x buf_bytes.\n", 344 dev_err(cs5535au->card->dev, "diff=%x >= %x buf_bytes.\n",
345 curdma, dma->buf_bytes); 345 curdma, dma->buf_bytes);
346 return 0; 346 return 0;
347 } 347 }
diff --git a/sound/pci/cs5535audio/cs5535audio_pm.c b/sound/pci/cs5535audio/cs5535audio_pm.c
index 6c34def5986d..34cc60057d0c 100644
--- a/sound/pci/cs5535audio/cs5535audio_pm.c
+++ b/sound/pci/cs5535audio/cs5535audio_pm.c
@@ -74,7 +74,7 @@ static int snd_cs5535audio_suspend(struct device *dev)
74 snd_cs5535audio_stop_hardware(cs5535au); 74 snd_cs5535audio_stop_hardware(cs5535au);
75 75
76 if (pci_save_state(pci)) { 76 if (pci_save_state(pci)) {
77 printk(KERN_ERR "cs5535audio: pci_save_state failed!\n"); 77 dev_err(dev, "pci_save_state failed!\n");
78 return -EIO; 78 return -EIO;
79 } 79 }
80 pci_disable_device(pci); 80 pci_disable_device(pci);
@@ -94,8 +94,7 @@ static int snd_cs5535audio_resume(struct device *dev)
94 pci_set_power_state(pci, PCI_D0); 94 pci_set_power_state(pci, PCI_D0);
95 pci_restore_state(pci); 95 pci_restore_state(pci);
96 if (pci_enable_device(pci) < 0) { 96 if (pci_enable_device(pci) < 0) {
97 printk(KERN_ERR "cs5535audio: pci_enable_device failed, " 97 dev_err(dev, "pci_enable_device failed, disabling device\n");
98 "disabling device\n");
99 snd_card_disconnect(card); 98 snd_card_disconnect(card);
100 return -EIO; 99 return -EIO;
101 } 100 }
@@ -113,7 +112,7 @@ static int snd_cs5535audio_resume(struct device *dev)
113 } while (--timeout); 112 } while (--timeout);
114 113
115 if (!timeout) 114 if (!timeout)
116 snd_printk(KERN_ERR "Failure getting AC Link ready\n"); 115 dev_err(cs5535au->card->dev, "Failure getting AC Link ready\n");
117 116
118 /* set up rate regs, dma. actual initiation is done in trig */ 117 /* set up rate regs, dma. actual initiation is done in trig */
119 for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) { 118 for (i = 0; i < NUM_CS5535AUDIO_DMAS; i++) {
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c
index eb86829529eb..af632bd08323 100644
--- a/sound/pci/ctxfi/ctatc.c
+++ b/sound/pci/ctxfi/ctatc.c
@@ -1739,8 +1739,6 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
1739 if (err < 0) 1739 if (err < 0)
1740 goto error1; 1740 goto error1;
1741 1741
1742 snd_card_set_dev(card, &pci->dev);
1743
1744 *ratc = atc; 1742 *ratc = atc;
1745 return 0; 1743 return 0;
1746 1744
diff --git a/sound/pci/ctxfi/xfi.c b/sound/pci/ctxfi/xfi.c
index d464ad2fc7b7..98426d09c8bd 100644
--- a/sound/pci/ctxfi/xfi.c
+++ b/sound/pci/ctxfi/xfi.c
@@ -71,7 +71,8 @@ ct_card_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
71 dev++; 71 dev++;
72 return -ENOENT; 72 return -ENOENT;
73 } 73 }
74 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 74 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
75 0, &card);
75 if (err) 76 if (err)
76 return err; 77 return err;
77 if ((reference_rate != 48000) && (reference_rate != 44100)) { 78 if ((reference_rate != 48000) && (reference_rate != 44100)) {
diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
index 05cfe551ce42..9f10c9e0df5e 100644
--- a/sound/pci/echoaudio/echoaudio.c
+++ b/sound/pci/echoaudio/echoaudio.c
@@ -58,7 +58,8 @@ static int get_firmware(const struct firmware **fw_entry,
58 snprintf(name, sizeof(name), "ea/%s", card_fw[fw_index].data); 58 snprintf(name, sizeof(name), "ea/%s", card_fw[fw_index].data);
59 err = request_firmware(fw_entry, name, pci_device(chip)); 59 err = request_firmware(fw_entry, name, pci_device(chip));
60 if (err < 0) 60 if (err < 0)
61 snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err); 61 dev_err(chip->card->dev,
62 "get_firmware(): Firmware not available (%d)\n", err);
62#ifdef CONFIG_PM_SLEEP 63#ifdef CONFIG_PM_SLEEP
63 else 64 else
64 chip->fw_cache[fw_index] = *fw_entry; 65 chip->fw_cache[fw_index] = *fw_entry;
@@ -563,7 +564,7 @@ static int init_engine(struct snd_pcm_substream *substream,
563 err = snd_pcm_lib_malloc_pages(substream, 564 err = snd_pcm_lib_malloc_pages(substream,
564 params_buffer_bytes(hw_params)); 565 params_buffer_bytes(hw_params));
565 if (err < 0) { 566 if (err < 0) {
566 snd_printk(KERN_ERR "malloc_pages err=%d\n", err); 567 dev_err(chip->card->dev, "malloc_pages err=%d\n", err);
567 spin_lock_irq(&chip->lock); 568 spin_lock_irq(&chip->lock);
568 free_pipes(chip, pipe); 569 free_pipes(chip, pipe);
569 spin_unlock_irq(&chip->lock); 570 spin_unlock_irq(&chip->lock);
@@ -1989,8 +1990,8 @@ static int snd_echo_create(struct snd_card *card,
1989 1990
1990 if ((chip->iores = request_mem_region(chip->dsp_registers_phys, sz, 1991 if ((chip->iores = request_mem_region(chip->dsp_registers_phys, sz,
1991 ECHOCARD_NAME)) == NULL) { 1992 ECHOCARD_NAME)) == NULL) {
1993 dev_err(chip->card->dev, "cannot get memory region\n");
1992 snd_echo_free(chip); 1994 snd_echo_free(chip);
1993 snd_printk(KERN_ERR "cannot get memory region\n");
1994 return -EBUSY; 1995 return -EBUSY;
1995 } 1996 }
1996 chip->dsp_registers = (volatile u32 __iomem *) 1997 chip->dsp_registers = (volatile u32 __iomem *)
@@ -1998,8 +1999,8 @@ static int snd_echo_create(struct snd_card *card,
1998 1999
1999 if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, 2000 if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED,
2000 KBUILD_MODNAME, chip)) { 2001 KBUILD_MODNAME, chip)) {
2002 dev_err(chip->card->dev, "cannot grab irq\n");
2001 snd_echo_free(chip); 2003 snd_echo_free(chip);
2002 snd_printk(KERN_ERR "cannot grab irq\n");
2003 return -EBUSY; 2004 return -EBUSY;
2004 } 2005 }
2005 chip->irq = pci->irq; 2006 chip->irq = pci->irq;
@@ -2011,8 +2012,8 @@ static int snd_echo_create(struct snd_card *card,
2011 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 2012 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
2012 sizeof(struct comm_page), 2013 sizeof(struct comm_page),
2013 &chip->commpage_dma_buf) < 0) { 2014 &chip->commpage_dma_buf) < 0) {
2015 dev_err(chip->card->dev, "cannot allocate the comm page\n");
2014 snd_echo_free(chip); 2016 snd_echo_free(chip);
2015 snd_printk(KERN_ERR "cannot allocate the comm page\n");
2016 return -ENOMEM; 2017 return -ENOMEM;
2017 } 2018 }
2018 chip->comm_page_phys = chip->commpage_dma_buf.addr; 2019 chip->comm_page_phys = chip->commpage_dma_buf.addr;
@@ -2058,12 +2059,11 @@ static int snd_echo_probe(struct pci_dev *pci,
2058 2059
2059 DE_INIT(("Echoaudio driver starting...\n")); 2060 DE_INIT(("Echoaudio driver starting...\n"));
2060 i = 0; 2061 i = 0;
2061 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2062 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2063 0, &card);
2062 if (err < 0) 2064 if (err < 0)
2063 return err; 2065 return err;
2064 2066
2065 snd_card_set_dev(card, &pci->dev);
2066
2067 chip = NULL; /* Tells snd_echo_create to allocate chip */ 2067 chip = NULL; /* Tells snd_echo_create to allocate chip */
2068 if ((err = snd_echo_create(card, pci, &chip)) < 0) { 2068 if ((err = snd_echo_create(card, pci, &chip)) < 0) {
2069 snd_card_free(card); 2069 snd_card_free(card);
@@ -2082,7 +2082,7 @@ static int snd_echo_probe(struct pci_dev *pci,
2082 chip->dsp_registers_phys, chip->irq); 2082 chip->dsp_registers_phys, chip->irq);
2083 2083
2084 if ((err = snd_echo_new_pcm(chip)) < 0) { 2084 if ((err = snd_echo_new_pcm(chip)) < 0) {
2085 snd_printk(KERN_ERR "new pcm error %d\n", err); 2085 dev_err(chip->card->dev, "new pcm error %d\n", err);
2086 snd_card_free(card); 2086 snd_card_free(card);
2087 return err; 2087 return err;
2088 } 2088 }
@@ -2090,7 +2090,7 @@ static int snd_echo_probe(struct pci_dev *pci,
2090#ifdef ECHOCARD_HAS_MIDI 2090#ifdef ECHOCARD_HAS_MIDI
2091 if (chip->has_midi) { /* Some Mia's do not have midi */ 2091 if (chip->has_midi) { /* Some Mia's do not have midi */
2092 if ((err = snd_echo_midi_create(card, chip)) < 0) { 2092 if ((err = snd_echo_midi_create(card, chip)) < 0) {
2093 snd_printk(KERN_ERR "new midi error %d\n", err); 2093 dev_err(chip->card->dev, "new midi error %d\n", err);
2094 snd_card_free(card); 2094 snd_card_free(card);
2095 return err; 2095 return err;
2096 } 2096 }
@@ -2189,14 +2189,14 @@ static int snd_echo_probe(struct pci_dev *pci,
2189 err = snd_card_register(card); 2189 err = snd_card_register(card);
2190 if (err < 0) 2190 if (err < 0)
2191 goto ctl_error; 2191 goto ctl_error;
2192 snd_printk(KERN_INFO "Card registered: %s\n", card->longname); 2192 dev_info(card->dev, "Card registered: %s\n", card->longname);
2193 2193
2194 pci_set_drvdata(pci, chip); 2194 pci_set_drvdata(pci, chip);
2195 dev++; 2195 dev++;
2196 return 0; 2196 return 0;
2197 2197
2198ctl_error: 2198ctl_error:
2199 snd_printk(KERN_ERR "new control error %d\n", err); 2199 dev_err(card->dev, "new control error %d\n", err);
2200 snd_card_free(card); 2200 snd_card_free(card);
2201 return err; 2201 return err;
2202} 2202}
@@ -2291,8 +2291,8 @@ static int snd_echo_resume(struct device *dev)
2291 2291
2292 if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED, 2292 if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED,
2293 KBUILD_MODNAME, chip)) { 2293 KBUILD_MODNAME, chip)) {
2294 dev_err(chip->card->dev, "cannot grab irq\n");
2294 snd_echo_free(chip); 2295 snd_echo_free(chip);
2295 snd_printk(KERN_ERR "cannot grab irq\n");
2296 return -EBUSY; 2296 return -EBUSY;
2297 } 2297 }
2298 chip->irq = pci->irq; 2298 chip->irq = pci->irq;
diff --git a/sound/pci/echoaudio/echoaudio_dsp.c b/sound/pci/echoaudio/echoaudio_dsp.c
index d8c670c9d62c..5a6a217b82e0 100644
--- a/sound/pci/echoaudio/echoaudio_dsp.c
+++ b/sound/pci/echoaudio/echoaudio_dsp.c
@@ -53,7 +53,7 @@ static int wait_handshake(struct echoaudio *chip)
53 udelay(1); 53 udelay(1);
54 } 54 }
55 55
56 snd_printk(KERN_ERR "wait_handshake(): Timeout waiting for DSP\n"); 56 dev_err(chip->card->dev, "wait_handshake(): Timeout waiting for DSP\n");
57 return -EBUSY; 57 return -EBUSY;
58} 58}
59 59
@@ -149,7 +149,8 @@ static int read_sn(struct echoaudio *chip)
149 149
150 for (i = 0; i < 5; i++) { 150 for (i = 0; i < 5; i++) {
151 if (read_dsp(chip, &sn[i])) { 151 if (read_dsp(chip, &sn[i])) {
152 snd_printk(KERN_ERR "Failed to read serial number\n"); 152 dev_err(chip->card->dev,
153 "Failed to read serial number\n");
153 return -EIO; 154 return -EIO;
154 } 155 }
155 } 156 }
@@ -184,7 +185,7 @@ static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic)
184 185
185 err = get_firmware(&fw, chip, asic); 186 err = get_firmware(&fw, chip, asic);
186 if (err < 0) { 187 if (err < 0) {
187 snd_printk(KERN_WARNING "Firmware not found !\n"); 188 dev_warn(chip->card->dev, "Firmware not found !\n");
188 return err; 189 return err;
189 } 190 }
190 191
@@ -247,7 +248,7 @@ static int install_resident_loader(struct echoaudio *chip)
247 248
248 i = get_firmware(&fw, chip, FW_361_LOADER); 249 i = get_firmware(&fw, chip, FW_361_LOADER);
249 if (i < 0) { 250 if (i < 0) {
250 snd_printk(KERN_WARNING "Firmware not found !\n"); 251 dev_warn(chip->card->dev, "Firmware not found !\n");
251 return i; 252 return i;
252 } 253 }
253 254
diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c
index abfd51c2530e..7f4dfae0323a 100644
--- a/sound/pci/echoaudio/midi.c
+++ b/sound/pci/echoaudio/midi.c
@@ -221,7 +221,8 @@ static void snd_echo_midi_output_write(unsigned long data)
221 DE_MID(("Try to send %d bytes...\n", bytes)); 221 DE_MID(("Try to send %d bytes...\n", bytes));
222 sent = write_midi(chip, buf, bytes); 222 sent = write_midi(chip, buf, bytes);
223 if (sent < 0) { 223 if (sent < 0) {
224 snd_printk(KERN_ERR "write_midi() error %d\n", sent); 224 dev_err(chip->card->dev,
225 "write_midi() error %d\n", sent);
225 /* retry later */ 226 /* retry later */
226 sent = 9000; 227 sent = 9000;
227 chip->midi_full = 1; 228 chip->midi_full = 1;
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index 9e1bd0c39a8c..ad9d9f8b48ed 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -117,7 +117,8 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
117 return -ENOENT; 117 return -ENOENT;
118 } 118 }
119 119
120 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 120 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
121 0, &card);
121 if (err < 0) 122 if (err < 0)
122 return err; 123 return err;
123 if (max_buffer_size[dev] < 32) 124 if (max_buffer_size[dev] < 32)
@@ -169,7 +170,8 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
169 if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, 170 if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH,
170 sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 || 171 sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 ||
171 wave == NULL) { 172 wave == NULL) {
172 snd_printk(KERN_WARNING "can't initialize Emu10k1 wavetable synth\n"); 173 dev_warn(emu->card->dev,
174 "can't initialize Emu10k1 wavetable synth\n");
173 } else { 175 } else {
174 struct snd_emu10k1_synth_arg *arg; 176 struct snd_emu10k1_synth_arg *arg;
175 arg = SNDRV_SEQ_DEVICE_ARGPTR(wave); 177 arg = SNDRV_SEQ_DEVICE_ARGPTR(wave);
@@ -246,8 +248,7 @@ static int snd_emu10k1_resume(struct device *dev)
246 pci_set_power_state(pci, PCI_D0); 248 pci_set_power_state(pci, PCI_D0);
247 pci_restore_state(pci); 249 pci_restore_state(pci);
248 if (pci_enable_device(pci) < 0) { 250 if (pci_enable_device(pci) < 0) {
249 printk(KERN_ERR "emu10k1: pci_enable_device failed, " 251 dev_err(dev, "pci_enable_device failed, disabling device\n");
250 "disabling device\n");
251 snd_card_disconnect(card); 252 snd_card_disconnect(card);
252 return -EIO; 253 return -EIO;
253 } 254 }
diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c
index cae36597aa71..3f3ef38d9b6e 100644
--- a/sound/pci/emu10k1/emu10k1_callback.c
+++ b/sound/pci/emu10k1/emu10k1_callback.c
@@ -105,7 +105,7 @@ snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw)
105 vp = &emu->voices[best[i].voice]; 105 vp = &emu->voices[best[i].voice];
106 if ((ch = vp->ch) < 0) { 106 if ((ch = vp->ch) < 0) {
107 /* 107 /*
108 printk(KERN_WARNING 108 dev_warn(emu->card->dev,
109 "synth_get_voice: ch < 0 (%d) ??", i); 109 "synth_get_voice: ch < 0 (%d) ??", i);
110 */ 110 */
111 continue; 111 continue;
@@ -339,7 +339,7 @@ start_voice(struct snd_emux_voice *vp)
339 return -EINVAL; 339 return -EINVAL;
340 emem->map_locked++; 340 emem->map_locked++;
341 if (snd_emu10k1_memblk_map(hw, emem) < 0) { 341 if (snd_emu10k1_memblk_map(hw, emem) < 0) {
342 /* printk(KERN_ERR "emu: cannot map!\n"); */ 342 /* dev_err(hw->card->devK, "emu: cannot map!\n"); */
343 return -ENOMEM; 343 return -ENOMEM;
344 } 344 }
345 mapped_offset = snd_emu10k1_memblk_offset(emem) >> 1; 345 mapped_offset = snd_emu10k1_memblk_offset(emem) >> 1;
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index bdd888ec9a84..229269788023 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -217,7 +217,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
217 } 217 }
218 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ 218 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */
219 /* Hacks for Alice3 to work independent of haP16V driver */ 219 /* Hacks for Alice3 to work independent of haP16V driver */
220 snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); 220 dev_info(emu->card->dev, "Audigy2 value: Special config.\n");
221 /* Setup SRCMulti_I2S SamplingRate */ 221 /* Setup SRCMulti_I2S SamplingRate */
222 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); 222 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
223 tmp &= 0xfffff1ff; 223 tmp &= 0xfffff1ff;
@@ -723,7 +723,8 @@ static int emu1010_firmware_thread(void *data)
723 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { 723 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) {
724 /* Audio Dock attached */ 724 /* Audio Dock attached */
725 /* Return to Audio Dock programming mode */ 725 /* Return to Audio Dock programming mode */
726 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 726 dev_info(emu->card->dev,
727 "emu1010: Loading Audio Dock Firmware\n");
727 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK); 728 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK);
728 729
729 if (!emu->dock_fw) { 730 if (!emu->dock_fw) {
@@ -756,19 +757,25 @@ static int emu1010_firmware_thread(void *data)
756 757
757 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0); 758 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0);
758 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg); 759 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg);
759 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", reg); 760 dev_info(emu->card->dev,
761 "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n",
762 reg);
760 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 763 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
761 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg); 764 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
762 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg); 765 dev_info(emu->card->dev,
766 "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg);
763 if ((reg & 0x1f) != 0x15) { 767 if ((reg & 0x1f) != 0x15) {
764 /* FPGA failed to be programmed */ 768 /* FPGA failed to be programmed */
765 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", reg); 769 dev_info(emu->card->dev,
770 "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n",
771 reg);
766 continue; 772 continue;
767 } 773 }
768 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); 774 dev_info(emu->card->dev,
775 "emu1010: Audio Dock Firmware loaded\n");
769 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp); 776 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp);
770 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2); 777 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2);
771 snd_printk(KERN_INFO "Audio Dock ver: %u.%u\n", 778 dev_info(emu->card->dev, "Audio Dock ver: %u.%u\n",
772 tmp, tmp2); 779 tmp, tmp2);
773 /* Sync clocking between 1010 and Dock */ 780 /* Sync clocking between 1010 and Dock */
774 /* Allow DLL to settle */ 781 /* Allow DLL to settle */
@@ -777,7 +784,7 @@ static int emu1010_firmware_thread(void *data)
777 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE); 784 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE);
778 } 785 }
779 } 786 }
780 snd_printk(KERN_INFO "emu1010: firmware thread stopping\n"); 787 dev_info(emu->card->dev, "emu1010: firmware thread stopping\n");
781 return 0; 788 return 0;
782} 789}
783 790
@@ -818,7 +825,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
818 u32 tmp, tmp2, reg; 825 u32 tmp, tmp2, reg;
819 int err; 826 int err;
820 827
821 snd_printk(KERN_INFO "emu1010: Special config.\n"); 828 dev_info(emu->card->dev, "emu1010: Special config.\n");
822 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 829 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
823 * Lock Sound Memory Cache, Lock Tank Memory Cache, 830 * Lock Sound Memory Cache, Lock Tank Memory Cache,
824 * Mute all codecs. 831 * Mute all codecs.
@@ -843,7 +850,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
843 850
844 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ 851 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
845 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg); 852 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
846 snd_printdd("reg1 = 0x%x\n", reg); 853 dev_dbg(emu->card->dev, "reg1 = 0x%x\n", reg);
847 if ((reg & 0x3f) == 0x15) { 854 if ((reg & 0x3f) == 0x15) {
848 /* FPGA netlist already present so clear it */ 855 /* FPGA netlist already present so clear it */
849 /* Return to programming mode */ 856 /* Return to programming mode */
@@ -851,13 +858,14 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
851 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02); 858 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02);
852 } 859 }
853 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg); 860 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
854 snd_printdd("reg2 = 0x%x\n", reg); 861 dev_dbg(emu->card->dev, "reg2 = 0x%x\n", reg);
855 if ((reg & 0x3f) == 0x15) { 862 if ((reg & 0x3f) == 0x15) {
856 /* FPGA failed to return to programming mode */ 863 /* FPGA failed to return to programming mode */
857 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n"); 864 dev_info(emu->card->dev,
865 "emu1010: FPGA failed to return to programming mode\n");
858 return -ENODEV; 866 return -ENODEV;
859 } 867 }
860 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID = 0x%x\n", reg); 868 dev_info(emu->card->dev, "emu1010: EMU_HANA_ID = 0x%x\n", reg);
861 869
862 if (!emu->firmware) { 870 if (!emu->firmware) {
863 const char *filename; 871 const char *filename;
@@ -880,16 +888,19 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
880 888
881 err = request_firmware(&emu->firmware, filename, &emu->pci->dev); 889 err = request_firmware(&emu->firmware, filename, &emu->pci->dev);
882 if (err != 0) { 890 if (err != 0) {
883 snd_printk(KERN_ERR "emu1010: firmware: %s not found. Err = %d\n", filename, err); 891 dev_info(emu->card->dev,
892 "emu1010: firmware: %s not found. Err = %d\n",
893 filename, err);
884 return err; 894 return err;
885 } 895 }
886 snd_printk(KERN_INFO "emu1010: firmware file = %s, size = 0x%zx\n", 896 dev_info(emu->card->dev,
897 "emu1010: firmware file = %s, size = 0x%zx\n",
887 filename, emu->firmware->size); 898 filename, emu->firmware->size);
888 } 899 }
889 900
890 err = snd_emu1010_load_firmware(emu, emu->firmware); 901 err = snd_emu1010_load_firmware(emu, emu->firmware);
891 if (err != 0) { 902 if (err != 0) {
892 snd_printk(KERN_INFO "emu1010: Loading Firmware failed\n"); 903 dev_info(emu->card->dev, "emu1010: Loading Firmware failed\n");
893 return err; 904 return err;
894 } 905 }
895 906
@@ -897,21 +908,23 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
897 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg); 908 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
898 if ((reg & 0x3f) != 0x15) { 909 if ((reg & 0x3f) != 0x15) {
899 /* FPGA failed to be programmed */ 910 /* FPGA failed to be programmed */
900 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", reg); 911 dev_info(emu->card->dev,
912 "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n",
913 reg);
901 return -ENODEV; 914 return -ENODEV;
902 } 915 }
903 916
904 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); 917 dev_info(emu->card->dev, "emu1010: Hana Firmware loaded\n");
905 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp); 918 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp);
906 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2); 919 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2);
907 snd_printk(KERN_INFO "emu1010: Hana version: %u.%u\n", tmp, tmp2); 920 dev_info(emu->card->dev, "emu1010: Hana version: %u.%u\n", tmp, tmp2);
908 /* Enable 48Volt power to Audio Dock */ 921 /* Enable 48Volt power to Audio Dock */
909 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON); 922 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON);
910 923
911 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg); 924 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
912 snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg); 925 dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg);
913 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg); 926 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
914 snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg); 927 dev_info(emu->card->dev, "emu1010: Card options = 0x%x\n", reg);
915 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp); 928 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp);
916 /* Optical -> ADAT I/O */ 929 /* Optical -> ADAT I/O */
917 /* 0 : SPDIF 930 /* 0 : SPDIF
@@ -950,7 +963,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
950 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00); 963 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00);
951 964
952 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg); 965 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
953 snd_printk(KERN_INFO "emu1010: Card options3 = 0x%x\n", reg); 966 dev_info(emu->card->dev, "emu1010: Card options3 = 0x%x\n", reg);
954 /* Default WCLK set to 48kHz. */ 967 /* Default WCLK set to 48kHz. */
955 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00); 968 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00);
956 /* Word Clock source, Internal 48kHz x1 */ 969 /* Word Clock source, Internal 48kHz x1 */
@@ -1808,7 +1821,9 @@ int snd_emu10k1_create(struct snd_card *card,
1808 emu->revision = pci->revision; 1821 emu->revision = pci->revision;
1809 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 1822 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
1810 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 1823 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
1811 snd_printdd("vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n", pci->vendor, pci->device, emu->serial, emu->model); 1824 dev_dbg(card->dev,
1825 "vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n",
1826 pci->vendor, pci->device, emu->serial, emu->model);
1812 1827
1813 for (c = emu_chip_details; c->vendor; c++) { 1828 for (c = emu_chip_details; c->vendor; c++) {
1814 if (c->vendor == pci->vendor && c->device == pci->device) { 1829 if (c->vendor == pci->vendor && c->device == pci->device) {
@@ -1827,21 +1842,21 @@ int snd_emu10k1_create(struct snd_card *card,
1827 } 1842 }
1828 } 1843 }
1829 if (c->vendor == 0) { 1844 if (c->vendor == 0) {
1830 snd_printk(KERN_ERR "emu10k1: Card not recognised\n"); 1845 dev_err(card->dev, "emu10k1: Card not recognised\n");
1831 kfree(emu); 1846 kfree(emu);
1832 pci_disable_device(pci); 1847 pci_disable_device(pci);
1833 return -ENOENT; 1848 return -ENOENT;
1834 } 1849 }
1835 emu->card_capabilities = c; 1850 emu->card_capabilities = c;
1836 if (c->subsystem && !subsystem) 1851 if (c->subsystem && !subsystem)
1837 snd_printdd("Sound card name = %s\n", c->name); 1852 dev_dbg(card->dev, "Sound card name = %s\n", c->name);
1838 else if (subsystem) 1853 else if (subsystem)
1839 snd_printdd("Sound card name = %s, " 1854 dev_dbg(card->dev, "Sound card name = %s, "
1840 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. " 1855 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. "
1841 "Forced to subsystem = 0x%x\n", c->name, 1856 "Forced to subsystem = 0x%x\n", c->name,
1842 pci->vendor, pci->device, emu->serial, c->subsystem); 1857 pci->vendor, pci->device, emu->serial, c->subsystem);
1843 else 1858 else
1844 snd_printdd("Sound card name = %s, " 1859 dev_dbg(card->dev, "Sound card name = %s, "
1845 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n", 1860 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n",
1846 c->name, pci->vendor, pci->device, 1861 c->name, pci->vendor, pci->device,
1847 emu->serial); 1862 emu->serial);
@@ -1869,7 +1884,9 @@ int snd_emu10k1_create(struct snd_card *card,
1869 emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK; 1884 emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
1870 if (pci_set_dma_mask(pci, emu->dma_mask) < 0 || 1885 if (pci_set_dma_mask(pci, emu->dma_mask) < 0 ||
1871 pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) { 1886 pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
1872 snd_printk(KERN_ERR "architecture does not support PCI busmaster DMA with mask 0x%lx\n", emu->dma_mask); 1887 dev_err(card->dev,
1888 "architecture does not support PCI busmaster DMA with mask 0x%lx\n",
1889 emu->dma_mask);
1873 kfree(emu); 1890 kfree(emu);
1874 pci_disable_device(pci); 1891 pci_disable_device(pci);
1875 return -ENXIO; 1892 return -ENXIO;
@@ -2021,7 +2038,6 @@ int snd_emu10k1_create(struct snd_card *card,
2021 snd_emu10k1_proc_init(emu); 2038 snd_emu10k1_proc_init(emu);
2022#endif 2039#endif
2023 2040
2024 snd_card_set_dev(card, &pci->dev);
2025 *remu = emu; 2041 *remu = emu;
2026 return 0; 2042 return 0;
2027 2043
diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c
index 662a45876a8b..0e069aeab86d 100644
--- a/sound/pci/emu10k1/emu10k1_patch.c
+++ b/sound/pci/emu10k1/emu10k1_patch.c
@@ -50,7 +50,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
50 return -EINVAL; 50 return -EINVAL;
51 51
52 if (sp->v.size == 0) { 52 if (sp->v.size == 0) {
53 snd_printd("emu: rom font for sample %d\n", sp->v.sample); 53 dev_dbg(emu->card->dev,
54 "emu: rom font for sample %d\n", sp->v.sample);
54 return 0; 55 return 0;
55 } 56 }
56 57
@@ -92,7 +93,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
92 blocksize *= 2; 93 blocksize *= 2;
93 sp->block = snd_emu10k1_synth_alloc(emu, blocksize); 94 sp->block = snd_emu10k1_synth_alloc(emu, blocksize);
94 if (sp->block == NULL) { 95 if (sp->block == NULL) {
95 snd_printd("emu10k1: synth malloc failed (size=%d)\n", blocksize); 96 dev_dbg(emu->card->dev,
97 "synth malloc failed (size=%d)\n", blocksize);
96 /* not ENOMEM (for compatibility with OSS) */ 98 /* not ENOMEM (for compatibility with OSS) */
97 return -ENOSPC; 99 return -ENOSPC;
98 } 100 }
diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c
index 56ad9d6f200d..efe017526977 100644
--- a/sound/pci/emu10k1/emu10k1x.c
+++ b/sound/pci/emu10k1/emu10k1x.c
@@ -369,7 +369,8 @@ static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voi
369 if (epcm->substream == NULL) 369 if (epcm->substream == NULL)
370 return; 370 return;
371#if 0 371#if 0
372 snd_printk(KERN_INFO "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 372 dev_info(emu->card->dev,
373 "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
373 epcm->substream->ops->pointer(epcm->substream), 374 epcm->substream->ops->pointer(epcm->substream),
374 snd_pcm_lib_period_bytes(epcm->substream), 375 snd_pcm_lib_period_bytes(epcm->substream),
375 snd_pcm_lib_buffer_bytes(epcm->substream)); 376 snd_pcm_lib_buffer_bytes(epcm->substream));
@@ -487,7 +488,11 @@ static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream,
487 int channel = epcm->voice->number; 488 int channel = epcm->voice->number;
488 int result = 0; 489 int result = 0;
489 490
490// snd_printk(KERN_INFO "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n", (int)emu, cmd, (int)substream->ops->pointer(substream)); 491 /*
492 dev_dbg(emu->card->dev,
493 "trigger - emu10k1x = 0x%x, cmd = %i, pointer = %d\n",
494 (int)emu, cmd, (int)substream->ops->pointer(substream));
495 */
491 496
492 switch (cmd) { 497 switch (cmd) {
493 case SNDRV_PCM_TRIGGER_START: 498 case SNDRV_PCM_TRIGGER_START:
@@ -826,7 +831,7 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id)
826 // acknowledge the interrupt if necessary 831 // acknowledge the interrupt if necessary
827 outl(status, chip->port + IPR); 832 outl(status, chip->port + IPR);
828 833
829 // snd_printk(KERN_INFO "interrupt %08x\n", status); 834 /* dev_dbg(chip->card->dev, "interrupt %08x\n", status); */
830 return IRQ_HANDLED; 835 return IRQ_HANDLED;
831} 836}
832 837
@@ -919,7 +924,7 @@ static int snd_emu10k1x_create(struct snd_card *card,
919 return err; 924 return err;
920 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 925 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
921 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 926 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
922 snd_printk(KERN_ERR "error to set 28bit mask DMA\n"); 927 dev_err(card->dev, "error to set 28bit mask DMA\n");
923 pci_disable_device(pci); 928 pci_disable_device(pci);
924 return -ENXIO; 929 return -ENXIO;
925 } 930 }
@@ -940,14 +945,15 @@ static int snd_emu10k1x_create(struct snd_card *card,
940 chip->port = pci_resource_start(pci, 0); 945 chip->port = pci_resource_start(pci, 0);
941 if ((chip->res_port = request_region(chip->port, 8, 946 if ((chip->res_port = request_region(chip->port, 8,
942 "EMU10K1X")) == NULL) { 947 "EMU10K1X")) == NULL) {
943 snd_printk(KERN_ERR "emu10k1x: cannot allocate the port 0x%lx\n", chip->port); 948 dev_err(card->dev, "cannot allocate the port 0x%lx\n",
949 chip->port);
944 snd_emu10k1x_free(chip); 950 snd_emu10k1x_free(chip);
945 return -EBUSY; 951 return -EBUSY;
946 } 952 }
947 953
948 if (request_irq(pci->irq, snd_emu10k1x_interrupt, 954 if (request_irq(pci->irq, snd_emu10k1x_interrupt,
949 IRQF_SHARED, KBUILD_MODNAME, chip)) { 955 IRQF_SHARED, KBUILD_MODNAME, chip)) {
950 snd_printk(KERN_ERR "emu10k1x: cannot grab irq %d\n", pci->irq); 956 dev_err(card->dev, "cannot grab irq %d\n", pci->irq);
951 snd_emu10k1x_free(chip); 957 snd_emu10k1x_free(chip);
952 return -EBUSY; 958 return -EBUSY;
953 } 959 }
@@ -964,7 +970,7 @@ static int snd_emu10k1x_create(struct snd_card *card,
964 chip->revision = pci->revision; 970 chip->revision = pci->revision;
965 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); 971 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
966 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); 972 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
967 snd_printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, 973 dev_info(card->dev, "Model %04x Rev %08x Serial %08x\n", chip->model,
968 chip->revision, chip->serial); 974 chip->revision, chip->serial);
969 975
970 outl(0, chip->port + INTE); 976 outl(0, chip->port + INTE);
@@ -1248,7 +1254,9 @@ static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu)
1248 mpu401_read_data(emu, mpu); 1254 mpu401_read_data(emu, mpu);
1249#ifdef CONFIG_SND_DEBUG 1255#ifdef CONFIG_SND_DEBUG
1250 if (timeout <= 0) 1256 if (timeout <= 0)
1251 snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu)); 1257 dev_err(emu->card->dev,
1258 "cmd: clear rx timeout (status = 0x%x)\n",
1259 mpu401_read_stat(emu, mpu));
1252#endif 1260#endif
1253} 1261}
1254 1262
@@ -1322,7 +1330,8 @@ static int snd_emu10k1x_midi_cmd(struct emu10k1x * emu,
1322 } 1330 }
1323 spin_unlock_irqrestore(&midi->input_lock, flags); 1331 spin_unlock_irqrestore(&midi->input_lock, flags);
1324 if (!ok) { 1332 if (!ok) {
1325 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 1333 dev_err(emu->card->dev,
1334 "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
1326 cmd, emu->port, 1335 cmd, emu->port,
1327 mpu401_read_stat(emu, midi), 1336 mpu401_read_stat(emu, midi),
1328 mpu401_read_data(emu, midi)); 1337 mpu401_read_data(emu, midi));
@@ -1564,7 +1573,8 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,
1564 return -ENOENT; 1573 return -ENOENT;
1565 } 1574 }
1566 1575
1567 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1576 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1577 0, &card);
1568 if (err < 0) 1578 if (err < 0)
1569 return err; 1579 return err;
1570 1580
@@ -1608,8 +1618,6 @@ static int snd_emu10k1x_probe(struct pci_dev *pci,
1608 sprintf(card->longname, "%s at 0x%lx irq %i", 1618 sprintf(card->longname, "%s at 0x%lx irq %i",
1609 card->shortname, chip->port, chip->irq); 1619 card->shortname, chip->port, chip->irq);
1610 1620
1611 snd_card_set_dev(card, &pci->dev);
1612
1613 if ((err = snd_card_register(card)) < 0) { 1621 if ((err = snd_card_register(card)) < 0) {
1614 snd_card_free(card); 1622 snd_card_free(card);
1615 return err; 1623 return err;
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 1f9c7c4bbcd8..745f0627c634 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1547,7 +1547,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1547 /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */ 1547 /* A_PUT_STEREO_OUTPUT(A_EXTOUT_FRONT_L, A_EXTOUT_FRONT_R, playback + SND_EMU10K1_PLAYBACK_CHANNELS); */
1548 if (emu->card_capabilities->emu_model) { 1548 if (emu->card_capabilities->emu_model) {
1549 /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */ 1549 /* EMU1010 Outputs from PCM Front, Rear, Center, LFE, Side */
1550 snd_printk(KERN_INFO "EMU outputs on\n"); 1550 dev_info(emu->card->dev, "EMU outputs on\n");
1551 for (z = 0; z < 8; z++) { 1551 for (z = 0; z < 8; z++) {
1552 if (emu->card_capabilities->ca0108_chip) { 1552 if (emu->card_capabilities->ca0108_chip) {
1553 A_OP(icode, &ptr, iACC3, A3_EMU32OUT(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000); 1553 A_OP(icode, &ptr, iACC3, A3_EMU32OUT(z), A_GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + z), A_C_00000000, A_C_00000000);
@@ -1571,7 +1571,9 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1571 A_SWITCH(icode, &ptr, tmp + 1, playback + SND_EMU10K1_PLAYBACK_CHANNELS + z, tmp + 1); 1571 A_SWITCH(icode, &ptr, tmp + 1, playback + SND_EMU10K1_PLAYBACK_CHANNELS + z, tmp + 1);
1572 if ((z==1) && (emu->card_capabilities->spdif_bug)) { 1572 if ((z==1) && (emu->card_capabilities->spdif_bug)) {
1573 /* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */ 1573 /* Due to a SPDIF output bug on some Audigy cards, this code delays the Right channel by 1 sample */
1574 snd_printk(KERN_INFO "Installing spdif_bug patch: %s\n", emu->card_capabilities->name); 1574 dev_info(emu->card->dev,
1575 "Installing spdif_bug patch: %s\n",
1576 emu->card_capabilities->name);
1575 A_OP(icode, &ptr, iACC3, A_EXTOUT(A_EXTOUT_FRONT_L + z), A_GPR(gpr - 3), A_C_00000000, A_C_00000000); 1577 A_OP(icode, &ptr, iACC3, A_EXTOUT(A_EXTOUT_FRONT_L + z), A_GPR(gpr - 3), A_C_00000000, A_C_00000000);
1576 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 3), A_GPR(tmp + 0), A_GPR(tmp + 1), A_C_00000000); 1578 A_OP(icode, &ptr, iACC3, A_GPR(gpr - 3), A_GPR(tmp + 0), A_GPR(tmp + 1), A_C_00000000);
1577 } else { 1579 } else {
@@ -1595,7 +1597,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1595 1597
1596 if (emu->card_capabilities->emu_model) { 1598 if (emu->card_capabilities->emu_model) {
1597 if (emu->card_capabilities->ca0108_chip) { 1599 if (emu->card_capabilities->ca0108_chip) {
1598 snd_printk(KERN_INFO "EMU2 inputs on\n"); 1600 dev_info(emu->card->dev, "EMU2 inputs on\n");
1599 for (z = 0; z < 0x10; z++) { 1601 for (z = 0; z < 0x10; z++) {
1600 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp, 1602 snd_emu10k1_audigy_dsp_convert_32_to_2x16( icode, &ptr, tmp,
1601 bit_shifter16, 1603 bit_shifter16,
@@ -1603,11 +1605,11 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1603 A_FXBUS2(z*2) ); 1605 A_FXBUS2(z*2) );
1604 } 1606 }
1605 } else { 1607 } else {
1606 snd_printk(KERN_INFO "EMU inputs on\n"); 1608 dev_info(emu->card->dev, "EMU inputs on\n");
1607 /* Capture 16 (originally 8) channels of S32_LE sound */ 1609 /* Capture 16 (originally 8) channels of S32_LE sound */
1608 1610
1609 /* 1611 /*
1610 printk(KERN_DEBUG "emufx.c: gpr=0x%x, tmp=0x%x\n", 1612 dev_dbg(emu->card->dev, "emufx.c: gpr=0x%x, tmp=0x%x\n",
1611 gpr, tmp); 1613 gpr, tmp);
1612 */ 1614 */
1613 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */ 1615 /* For the EMU1010: How to get 32bit values from the DSP. High 16bits into L, low 16bits into R. */
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index f6c3da0d377d..c5ae2a24d8a5 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -1853,8 +1853,10 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
1853 if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) { 1853 if ((err = snd_ac97_mixer(pbus, &ac97, &emu->ac97)) < 0) {
1854 if (emu->card_capabilities->ac97_chip == 1) 1854 if (emu->card_capabilities->ac97_chip == 1)
1855 return err; 1855 return err;
1856 snd_printd(KERN_INFO "emu10k1: AC97 is optional on this board\n"); 1856 dev_info(emu->card->dev,
1857 snd_printd(KERN_INFO" Proceeding without ac97 mixers...\n"); 1857 "AC97 is optional on this board\n");
1858 dev_info(emu->card->dev,
1859 "Proceeding without ac97 mixers...\n");
1858 snd_device_free(emu->card, pbus); 1860 snd_device_free(emu->card, pbus);
1859 goto no_ac97; /* FIXME: get rid of ugly gotos.. */ 1861 goto no_ac97; /* FIXME: get rid of ugly gotos.. */
1860 } 1862 }
diff --git a/sound/pci/emu10k1/emumpu401.c b/sound/pci/emu10k1/emumpu401.c
index 1ec91246dfee..fdf2b0ada489 100644
--- a/sound/pci/emu10k1/emumpu401.c
+++ b/sound/pci/emu10k1/emumpu401.c
@@ -64,7 +64,9 @@ static void mpu401_clear_rx(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mp
64 mpu401_read_data(emu, mpu); 64 mpu401_read_data(emu, mpu);
65#ifdef CONFIG_SND_DEBUG 65#ifdef CONFIG_SND_DEBUG
66 if (timeout <= 0) 66 if (timeout <= 0)
67 snd_printk(KERN_ERR "cmd: clear rx timeout (status = 0x%x)\n", mpu401_read_stat(emu, mpu)); 67 dev_err(emu->card->dev,
68 "cmd: clear rx timeout (status = 0x%x)\n",
69 mpu401_read_stat(emu, mpu));
68#endif 70#endif
69} 71}
70 72
@@ -141,7 +143,8 @@ static int snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_mid
141 } 143 }
142 spin_unlock_irqrestore(&midi->input_lock, flags); 144 spin_unlock_irqrestore(&midi->input_lock, flags);
143 if (!ok) { 145 if (!ok) {
144 snd_printk(KERN_ERR "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n", 146 dev_err(emu->card->dev,
147 "midi_cmd: 0x%x failed at 0x%lx (status = 0x%x, data = 0x%x)!!!\n",
145 cmd, emu->port, 148 cmd, emu->port,
146 mpu401_read_stat(emu, midi), 149 mpu401_read_stat(emu, midi),
147 mpu401_read_data(emu, midi)); 150 mpu401_read_data(emu, midi));
diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
index 5ae1d045bdcb..f82481bd2542 100644
--- a/sound/pci/emu10k1/emupcm.c
+++ b/sound/pci/emu10k1/emupcm.c
@@ -44,7 +44,8 @@ static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu,
44 if (epcm->substream == NULL) 44 if (epcm->substream == NULL)
45 return; 45 return;
46#if 0 46#if 0
47 printk(KERN_DEBUG "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n", 47 dev_dbg(emu->card->dev,
48 "IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
48 epcm->substream->runtime->hw->pointer(emu, epcm->substream), 49 epcm->substream->runtime->hw->pointer(emu, epcm->substream),
49 snd_pcm_lib_period_bytes(epcm->substream), 50 snd_pcm_lib_period_bytes(epcm->substream),
50 snd_pcm_lib_buffer_bytes(epcm->substream)); 51 snd_pcm_lib_buffer_bytes(epcm->substream));
@@ -147,7 +148,7 @@ static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voic
147 &epcm->extra); 148 &epcm->extra);
148 if (err < 0) { 149 if (err < 0) {
149 /* 150 /*
150 printk(KERN_DEBUG "pcm_channel_alloc: " 151 dev_dbg(emu->card->dev, "pcm_channel_alloc: "
151 "failed extra: voices=%d, frame=%d\n", 152 "failed extra: voices=%d, frame=%d\n",
152 voices, frame); 153 voices, frame);
153 */ 154 */
@@ -761,7 +762,8 @@ static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream,
761 int result = 0; 762 int result = 0;
762 763
763 /* 764 /*
764 printk(KERN_DEBUG "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", 765 dev_dbg(emu->card->dev,
766 "trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n",
765 (int)emu, cmd, substream->ops->pointer(substream)) 767 (int)emu, cmd, substream->ops->pointer(substream))
766 */ 768 */
767 spin_lock(&emu->reg_lock); 769 spin_lock(&emu->reg_lock);
@@ -815,7 +817,7 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream,
815 outl(epcm->capture_ipr, emu->port + IPR); 817 outl(epcm->capture_ipr, emu->port + IPR);
816 snd_emu10k1_intr_enable(emu, epcm->capture_inte); 818 snd_emu10k1_intr_enable(emu, epcm->capture_inte);
817 /* 819 /*
818 printk(KERN_DEBUG "adccr = 0x%x, adcbs = 0x%x\n", 820 dev_dbg(emu->card->dev, "adccr = 0x%x, adcbs = 0x%x\n",
819 epcm->adccr, epcm->adcbs); 821 epcm->adccr, epcm->adcbs);
820 */ 822 */
821 switch (epcm->type) { 823 switch (epcm->type) {
@@ -826,7 +828,10 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream,
826 if (emu->audigy) { 828 if (emu->audigy) {
827 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val); 829 snd_emu10k1_ptr_write(emu, A_FXWC1, 0, epcm->capture_cr_val);
828 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2); 830 snd_emu10k1_ptr_write(emu, A_FXWC2, 0, epcm->capture_cr_val2);
829 snd_printdd("cr_val=0x%x, cr_val2=0x%x\n", epcm->capture_cr_val, epcm->capture_cr_val2); 831 dev_dbg(emu->card->dev,
832 "cr_val=0x%x, cr_val2=0x%x\n",
833 epcm->capture_cr_val,
834 epcm->capture_cr_val2);
830 } else 835 } else
831 snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val); 836 snd_emu10k1_ptr_write(emu, FXWC, 0, epcm->capture_cr_val);
832 break; 837 break;
@@ -889,7 +894,7 @@ static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *
889 } 894 }
890#endif 895#endif
891 /* 896 /*
892 printk(KERN_DEBUG 897 dev_dbg(emu->card->dev,
893 "ptr = 0x%lx, buffer_size = 0x%lx, period_size = 0x%lx\n", 898 "ptr = 0x%lx, buffer_size = 0x%lx, period_size = 0x%lx\n",
894 (long)ptr, (long)runtime->buffer_size, 899 (long)ptr, (long)runtime->buffer_size,
895 (long)runtime->period_size); 900 (long)runtime->period_size);
@@ -1594,7 +1599,8 @@ static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left,
1594 unsigned int tram_shift) 1599 unsigned int tram_shift)
1595{ 1600{
1596 /* 1601 /*
1597 printk(KERN_DEBUG "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, " 1602 dev_dbg(emu->card->dev,
1603 "tram_poke1: dst_left = 0x%p, dst_right = 0x%p, "
1598 "src = 0x%p, count = 0x%x\n", 1604 "src = 0x%p, count = 0x%x\n",
1599 dst_left, dst_right, src, count); 1605 dst_left, dst_right, src, count);
1600 */ 1606 */
@@ -1675,7 +1681,7 @@ static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substre
1675 unsigned int i; 1681 unsigned int i;
1676 1682
1677 /* 1683 /*
1678 printk(KERN_DEBUG "prepare: etram_pages = 0x%p, dma_area = 0x%x, " 1684 dev_dbg(emu->card->dev, "prepare: etram_pages = 0x%p, dma_area = 0x%x, "
1679 "buffer_size = 0x%x (0x%x)\n", 1685 "buffer_size = 0x%x (0x%x)\n",
1680 emu->fx8010.etram_pages, runtime->dma_area, 1686 emu->fx8010.etram_pages, runtime->dma_area,
1681 runtime->buffer_size, runtime->buffer_size << 2); 1687 runtime->buffer_size, runtime->buffer_size << 2);
diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c
index e4fba49fee4a..706b4f0c6806 100644
--- a/sound/pci/emu10k1/io.c
+++ b/sound/pci/emu10k1/io.c
@@ -71,11 +71,8 @@ void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned i
71 unsigned long flags; 71 unsigned long flags;
72 unsigned int mask; 72 unsigned int mask;
73 73
74 if (!emu) { 74 if (snd_BUG_ON(!emu))
75 snd_printk(KERN_ERR "ptr_write: emu is null!\n");
76 dump_stack();
77 return; 75 return;
78 }
79 mask = emu->audigy ? A_PTR_ADDRESS_MASK : PTR_ADDRESS_MASK; 76 mask = emu->audigy ? A_PTR_ADDRESS_MASK : PTR_ADDRESS_MASK;
80 regptr = ((reg << 16) & mask) | (chn & PTR_CHANNELNUM_MASK); 77 regptr = ((reg << 16) & mask) | (chn & PTR_CHANNELNUM_MASK);
81 78
@@ -199,7 +196,7 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
199 int err = 0; 196 int err = 0;
200 197
201 if ((reg > 0x7f) || (value > 0x1ff)) { 198 if ((reg > 0x7f) || (value > 0x1ff)) {
202 snd_printk(KERN_ERR "i2c_write: invalid values.\n"); 199 dev_err(emu->card->dev, "i2c_write: invalid values.\n");
203 return -EINVAL; 200 return -EINVAL;
204 } 201 }
205 202
@@ -227,7 +224,7 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
227 break; 224 break;
228 225
229 if (timeout > 1000) { 226 if (timeout > 1000) {
230 snd_printk(KERN_WARNING 227 dev_warn(emu->card->dev,
231 "emu10k1:I2C:timeout status=0x%x\n", 228 "emu10k1:I2C:timeout status=0x%x\n",
232 status); 229 status);
233 break; 230 break;
@@ -239,8 +236,8 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
239 } 236 }
240 237
241 if (retry == 10) { 238 if (retry == 10) {
242 snd_printk(KERN_ERR "Writing to ADC failed!\n"); 239 dev_err(emu->card->dev, "Writing to ADC failed!\n");
243 snd_printk(KERN_ERR "status=0x%x, reg=%d, value=%d\n", 240 dev_err(emu->card->dev, "status=0x%x, reg=%d, value=%d\n",
244 status, reg, value); 241 status, reg, value);
245 /* dump_stack(); */ 242 /* dump_stack(); */
246 err = -EINVAL; 243 err = -EINVAL;
diff --git a/sound/pci/emu10k1/irq.c b/sound/pci/emu10k1/irq.c
index 30bfed6f8339..3c5c5e3dc2d9 100644
--- a/sound/pci/emu10k1/irq.c
+++ b/sound/pci/emu10k1/irq.c
@@ -41,11 +41,12 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
41 orig_status = status; 41 orig_status = status;
42 handled = 1; 42 handled = 1;
43 if ((status & 0xffffffff) == 0xffffffff) { 43 if ((status & 0xffffffff) == 0xffffffff) {
44 snd_printk(KERN_INFO "snd-emu10k1: Suspected sound card removal\n"); 44 dev_info(emu->card->dev,
45 "Suspected sound card removal\n");
45 break; 46 break;
46 } 47 }
47 if (status & IPR_PCIERROR) { 48 if (status & IPR_PCIERROR) {
48 snd_printk(KERN_ERR "interrupt: PCI error\n"); 49 dev_err(emu->card->dev, "interrupt: PCI error\n");
49 snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE); 50 snd_emu10k1_intr_disable(emu, INTE_PCIERRORENABLE);
50 status &= ~IPR_PCIERROR; 51 status &= ~IPR_PCIERROR;
51 } 52 }
@@ -157,19 +158,22 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
157 struct snd_emu10k1_voice *pvoice = &(emu->p16v_voices[0]); 158 struct snd_emu10k1_voice *pvoice = &(emu->p16v_voices[0]);
158 struct snd_emu10k1_voice *cvoice = &(emu->p16v_capture_voice); 159 struct snd_emu10k1_voice *cvoice = &(emu->p16v_capture_voice);
159 160
160 //printk(KERN_INFO "status2=0x%x\n", status2); 161 /* dev_dbg(emu->card->dev, "status2=0x%x\n", status2); */
161 orig_status2 = status2; 162 orig_status2 = status2;
162 if(status2 & mask) { 163 if(status2 & mask) {
163 if(pvoice->use) { 164 if(pvoice->use) {
164 snd_pcm_period_elapsed(pvoice->epcm->substream); 165 snd_pcm_period_elapsed(pvoice->epcm->substream);
165 } else { 166 } else {
166 snd_printk(KERN_ERR "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n", status2, mask, pvoice, pvoice->use); 167 dev_err(emu->card->dev,
168 "p16v: status: 0x%08x, mask=0x%08x, pvoice=%p, use=%d\n",
169 status2, mask, pvoice,
170 pvoice->use);
167 } 171 }
168 } 172 }
169 if(status2 & 0x110000) { 173 if(status2 & 0x110000) {
170 //printk(KERN_INFO "capture int found\n"); 174 /* dev_info(emu->card->dev, "capture int found\n"); */
171 if(cvoice->use) { 175 if(cvoice->use) {
172 //printk(KERN_INFO "capture period_elapsed\n"); 176 /* dev_info(emu->card->dev, "capture period_elapsed\n"); */
173 snd_pcm_period_elapsed(cvoice->epcm->substream); 177 snd_pcm_period_elapsed(cvoice->epcm->substream);
174 } 178 }
175 } 179 }
@@ -180,7 +184,8 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
180 184
181 if (status) { 185 if (status) {
182 unsigned int bits; 186 unsigned int bits;
183 snd_printk(KERN_ERR "emu10k1: unhandled interrupt: 0x%08x\n", status); 187 dev_err(emu->card->dev,
188 "unhandled interrupt: 0x%08x\n", status);
184 //make sure any interrupts we don't handle are disabled: 189 //make sure any interrupts we don't handle are disabled:
185 bits = INTE_FXDSPENABLE | 190 bits = INTE_FXDSPENABLE |
186 INTE_PCIERRORENABLE | 191 INTE_PCIERRORENABLE |
@@ -202,7 +207,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id)
202 outl(orig_status, emu->port + IPR); /* ack all */ 207 outl(orig_status, emu->port + IPR); /* ack all */
203 } 208 }
204 if (timeout == 1000) 209 if (timeout == 1000)
205 snd_printk(KERN_INFO "emu10k1 irq routine failure\n"); 210 dev_info(emu->card->dev, "emu10k1 irq routine failure\n");
206 211
207 return IRQ_RETVAL(handled); 212 return IRQ_RETVAL(handled);
208} 213}
diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
index ae709c1ab3a8..c68e6dd2fa67 100644
--- a/sound/pci/emu10k1/memory.c
+++ b/sound/pci/emu10k1/memory.c
@@ -236,11 +236,13 @@ __found_pages:
236static int is_valid_page(struct snd_emu10k1 *emu, dma_addr_t addr) 236static int is_valid_page(struct snd_emu10k1 *emu, dma_addr_t addr)
237{ 237{
238 if (addr & ~emu->dma_mask) { 238 if (addr & ~emu->dma_mask) {
239 snd_printk(KERN_ERR "max memory size is 0x%lx (addr = 0x%lx)!!\n", emu->dma_mask, (unsigned long)addr); 239 dev_err(emu->card->dev,
240 "max memory size is 0x%lx (addr = 0x%lx)!!\n",
241 emu->dma_mask, (unsigned long)addr);
240 return 0; 242 return 0;
241 } 243 }
242 if (addr & (EMUPAGESIZE-1)) { 244 if (addr & (EMUPAGESIZE-1)) {
243 snd_printk(KERN_ERR "page is not aligned\n"); 245 dev_err(emu->card->dev, "page is not aligned\n");
244 return 0; 246 return 0;
245 } 247 }
246 return 1; 248 return 1;
@@ -331,7 +333,8 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
331 else 333 else
332 addr = snd_pcm_sgbuf_get_addr(substream, ofs); 334 addr = snd_pcm_sgbuf_get_addr(substream, ofs);
333 if (! is_valid_page(emu, addr)) { 335 if (! is_valid_page(emu, addr)) {
334 printk(KERN_ERR "emu: failure page = %d\n", idx); 336 dev_err(emu->card->dev,
337 "emu: failure page = %d\n", idx);
335 mutex_unlock(&hdr->block_mutex); 338 mutex_unlock(&hdr->block_mutex);
336 return NULL; 339 return NULL;
337 } 340 }
@@ -507,7 +510,8 @@ static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset)
507 return NULL; 510 return NULL;
508 ptr = emu->page_ptr_table[page]; 511 ptr = emu->page_ptr_table[page];
509 if (! ptr) { 512 if (! ptr) {
510 printk(KERN_ERR "emu10k1: access to NULL ptr: page = %d\n", page); 513 dev_err(emu->card->dev,
514 "access to NULL ptr: page = %d\n", page);
511 return NULL; 515 return NULL;
512 } 516 }
513 ptr += offset & (PAGE_SIZE - 1); 517 ptr += offset & (PAGE_SIZE - 1);
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index 7e2025cd6d9c..a4fe7f0c9458 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -168,7 +168,7 @@ static void snd_p16v_pcm_free_substream(struct snd_pcm_runtime *runtime)
168 struct snd_emu10k1_pcm *epcm = runtime->private_data; 168 struct snd_emu10k1_pcm *epcm = runtime->private_data;
169 169
170 if (epcm) { 170 if (epcm) {
171 /* snd_printk(KERN_DEBUG "epcm free: %p\n", epcm); */ 171 /* dev_dbg(emu->card->dev, "epcm free: %p\n", epcm); */
172 kfree(epcm); 172 kfree(epcm);
173 } 173 }
174} 174}
@@ -183,14 +183,14 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea
183 int err; 183 int err;
184 184
185 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 185 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
186 /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */ 186 /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */
187 187
188 if (epcm == NULL) 188 if (epcm == NULL)
189 return -ENOMEM; 189 return -ENOMEM;
190 epcm->emu = emu; 190 epcm->emu = emu;
191 epcm->substream = substream; 191 epcm->substream = substream;
192 /* 192 /*
193 snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n", 193 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n",
194 substream->pcm->device, channel_id); 194 substream->pcm->device, channel_id);
195 */ 195 */
196 runtime->private_data = epcm; 196 runtime->private_data = epcm;
@@ -203,10 +203,10 @@ static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substrea
203 203
204 channel->use=1; 204 channel->use=1;
205#if 0 /* debug */ 205#if 0 /* debug */
206 snd_printk(KERN_DEBUG 206 dev_dbg(emu->card->dev,
207 "p16v: open channel_id=%d, channel=%p, use=0x%x\n", 207 "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
208 channel_id, channel, channel->use); 208 channel_id, channel, channel->use);
209 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n", 209 dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
210 channel_id, chip, channel); 210 channel_id, chip, channel);
211#endif /* debug */ 211#endif /* debug */
212 /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */ 212 /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
@@ -231,14 +231,14 @@ static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream
231 int err; 231 int err;
232 232
233 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); 233 epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
234 /* snd_printk(KERN_DEBUG "epcm kcalloc: %p\n", epcm); */ 234 /* dev_dbg(emu->card->dev, "epcm kcalloc: %p\n", epcm); */
235 235
236 if (epcm == NULL) 236 if (epcm == NULL)
237 return -ENOMEM; 237 return -ENOMEM;
238 epcm->emu = emu; 238 epcm->emu = emu;
239 epcm->substream = substream; 239 epcm->substream = substream;
240 /* 240 /*
241 snd_printk(KERN_DEBUG "epcm device=%d, channel_id=%d\n", 241 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n",
242 substream->pcm->device, channel_id); 242 substream->pcm->device, channel_id);
243 */ 243 */
244 runtime->private_data = epcm; 244 runtime->private_data = epcm;
@@ -251,10 +251,10 @@ static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream
251 251
252 channel->use=1; 252 channel->use=1;
253#if 0 /* debug */ 253#if 0 /* debug */
254 snd_printk(KERN_DEBUG 254 dev_dbg(emu->card->dev,
255 "p16v: open channel_id=%d, channel=%p, use=0x%x\n", 255 "p16v: open channel_id=%d, channel=%p, use=0x%x\n",
256 channel_id, channel, channel->use); 256 channel_id, channel, channel->use);
257 printk(KERN_DEBUG "open:channel_id=%d, chip=%p, channel=%p\n", 257 dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
258 channel_id, chip, channel); 258 channel_id, chip, channel);
259#endif /* debug */ 259#endif /* debug */
260 /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */ 260 /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
@@ -349,15 +349,18 @@ static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream)
349 u32 tmp; 349 u32 tmp;
350 350
351#if 0 /* debug */ 351#if 0 /* debug */
352 snd_printk(KERN_DEBUG "prepare:channel_number=%d, rate=%d, " 352 dev_dbg(emu->card->dev,
353 "prepare:channel_number=%d, rate=%d, "
353 "format=0x%x, channels=%d, buffer_size=%ld, " 354 "format=0x%x, channels=%d, buffer_size=%ld, "
354 "period_size=%ld, periods=%u, frames_to_bytes=%d\n", 355 "period_size=%ld, periods=%u, frames_to_bytes=%d\n",
355 channel, runtime->rate, runtime->format, runtime->channels, 356 channel, runtime->rate, runtime->format, runtime->channels,
356 runtime->buffer_size, runtime->period_size, 357 runtime->buffer_size, runtime->period_size,
357 runtime->periods, frames_to_bytes(runtime, 1)); 358 runtime->periods, frames_to_bytes(runtime, 1));
358 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, table_base=%p\n", 359 dev_dbg(emu->card->dev,
360 "dma_addr=%x, dma_area=%p, table_base=%p\n",
359 runtime->dma_addr, runtime->dma_area, table_base); 361 runtime->dma_addr, runtime->dma_area, table_base);
360 snd_printk(KERN_DEBUG "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n", 362 dev_dbg(emu->card->dev,
363 "dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",
361 emu->p16v_buffer.addr, emu->p16v_buffer.area, 364 emu->p16v_buffer.addr, emu->p16v_buffer.area,
362 emu->p16v_buffer.bytes); 365 emu->p16v_buffer.bytes);
363#endif /* debug */ 366#endif /* debug */
@@ -405,7 +408,7 @@ static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream)
405 u32 tmp; 408 u32 tmp;
406 409
407 /* 410 /*
408 printk(KERN_DEBUG "prepare capture:channel_number=%d, rate=%d, " 411 dev_dbg(emu->card->dev, "prepare capture:channel_number=%d, rate=%d, "
409 "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, " 412 "format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, "
410 "frames_to_bytes=%d\n", 413 "frames_to_bytes=%d\n",
411 channel, runtime->rate, runtime->format, runtime->channels, 414 channel, runtime->rate, runtime->format, runtime->channels,
@@ -491,13 +494,13 @@ static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream,
491 runtime = s->runtime; 494 runtime = s->runtime;
492 epcm = runtime->private_data; 495 epcm = runtime->private_data;
493 channel = substream->pcm->device-emu->p16v_device_offset; 496 channel = substream->pcm->device-emu->p16v_device_offset;
494 /* snd_printk(KERN_DEBUG "p16v channel=%d\n", channel); */ 497 /* dev_dbg(emu->card->dev, "p16v channel=%d\n", channel); */
495 epcm->running = running; 498 epcm->running = running;
496 basic |= (0x1<<channel); 499 basic |= (0x1<<channel);
497 inte |= (INTE2_PLAYBACK_CH_0_LOOP<<channel); 500 inte |= (INTE2_PLAYBACK_CH_0_LOOP<<channel);
498 snd_pcm_trigger_done(s, substream); 501 snd_pcm_trigger_done(s, substream);
499 } 502 }
500 /* snd_printk(KERN_DEBUG "basic=0x%x, inte=0x%x\n", basic, inte); */ 503 /* dev_dbg(emu->card->dev, "basic=0x%x, inte=0x%x\n", basic, inte); */
501 504
502 switch (cmd) { 505 switch (cmd) {
503 case SNDRV_PCM_TRIGGER_START: 506 case SNDRV_PCM_TRIGGER_START:
@@ -588,10 +591,10 @@ snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream)
588 ptr=ptr2; 591 ptr=ptr2;
589 if (ptr >= runtime->buffer_size) { 592 if (ptr >= runtime->buffer_size) {
590 ptr -= runtime->buffer_size; 593 ptr -= runtime->buffer_size;
591 printk(KERN_WARNING "buffer capture limited!\n"); 594 dev_warn(emu->card->dev, "buffer capture limited!\n");
592 } 595 }
593 /* 596 /*
594 printk(KERN_DEBUG "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, " 597 dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
595 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", 598 "buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n",
596 ptr1, ptr2, ptr, (int)runtime->buffer_size, 599 ptr1, ptr2, ptr, (int)runtime->buffer_size,
597 (int)runtime->period_size, (int)runtime->frame_bits, 600 (int)runtime->period_size, (int)runtime->frame_bits,
@@ -630,7 +633,7 @@ int snd_p16v_free(struct snd_emu10k1 *chip)
630 if (chip->p16v_buffer.area) { 633 if (chip->p16v_buffer.area) {
631 snd_dma_free_pages(&chip->p16v_buffer); 634 snd_dma_free_pages(&chip->p16v_buffer);
632 /* 635 /*
633 snd_printk(KERN_DEBUG "period lables free: %p\n", 636 dev_dbg(chip->card->dev, "period lables free: %p\n",
634 &chip->p16v_buffer); 637 &chip->p16v_buffer);
635 */ 638 */
636 } 639 }
@@ -644,7 +647,7 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)
644 int err; 647 int err;
645 int capture=1; 648 int capture=1;
646 649
647 /* snd_printk(KERN_DEBUG "snd_p16v_pcm called. device=%d\n", device); */ 650 /* dev_dbg(emu->card->dev, "snd_p16v_pcm called. device=%d\n", device); */
648 emu->p16v_device_offset = device; 651 emu->p16v_device_offset = device;
649 if (rpcm) 652 if (rpcm)
650 *rpcm = NULL; 653 *rpcm = NULL;
@@ -672,7 +675,7 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)
672 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0) 675 ((65536 - 64) * 8), ((65536 - 64) * 8))) < 0)
673 return err; 676 return err;
674 /* 677 /*
675 snd_printk(KERN_DEBUG 678 dev_dbg(emu->card->dev,
676 "preallocate playback substream: err=%d\n", err); 679 "preallocate playback substream: err=%d\n", err);
677 */ 680 */
678 } 681 }
@@ -686,7 +689,7 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm)
686 65536 - 64, 65536 - 64)) < 0) 689 65536 - 64, 65536 - 64)) < 0)
687 return err; 690 return err;
688 /* 691 /*
689 snd_printk(KERN_DEBUG 692 dev_dbg(emu->card->dev,
690 "preallocate capture substream: err=%d\n", err); 693 "preallocate capture substream: err=%d\n", err);
691 */ 694 */
692 } 695 }
diff --git a/sound/pci/emu10k1/voice.c b/sound/pci/emu10k1/voice.c
index 101e7cb79cb2..f16fd5cfb7cd 100644
--- a/sound/pci/emu10k1/voice.c
+++ b/sound/pci/emu10k1/voice.c
@@ -55,7 +55,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
55 first_voice = last_voice = 0; 55 first_voice = last_voice = 0;
56 for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) { 56 for (i = emu->next_free_voice, j = 0; j < NUM_G ; i += number, j += number) {
57 /* 57 /*
58 printk(KERN_DEBUG "i %d j %d next free %d!\n", 58 dev_dbg(emu->card->dev, "i %d j %d next free %d!\n",
59 i, j, emu->next_free_voice); 59 i, j, emu->next_free_voice);
60 */ 60 */
61 i %= NUM_G; 61 i %= NUM_G;
@@ -75,7 +75,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
75 } 75 }
76 } 76 }
77 if (!skip) { 77 if (!skip) {
78 /* printk(KERN_DEBUG "allocated voice %d\n", i); */ 78 /* dev_dbg(emu->card->dev, "allocated voice %d\n", i); */
79 first_voice = i; 79 first_voice = i;
80 last_voice = (i + number) % NUM_G; 80 last_voice = (i + number) % NUM_G;
81 emu->next_free_voice = last_voice; 81 emu->next_free_voice = last_voice;
@@ -89,7 +89,7 @@ static int voice_alloc(struct snd_emu10k1 *emu, int type, int number,
89 for (i = 0; i < number; i++) { 89 for (i = 0; i < number; i++) {
90 voice = &emu->voices[(first_voice + i) % NUM_G]; 90 voice = &emu->voices[(first_voice + i) % NUM_G];
91 /* 91 /*
92 printk(kERN_DEBUG "voice alloc - %i, %i of %i\n", 92 dev_dbg(emu->card->dev, "voice alloc - %i, %i of %i\n",
93 voice->number, idx-first_voice+1, number); 93 voice->number, idx-first_voice+1, number);
94 */ 94 */
95 voice->use = 1; 95 voice->use = 1;
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 61262f396004..29cd339ffc37 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -525,7 +525,7 @@ static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq)
525 return r; 525 return r;
526 cond_resched(); 526 cond_resched();
527 } 527 }
528 snd_printk(KERN_ERR "wait src ready timeout 0x%lx [0x%x]\n", 528 dev_err(ensoniq->card->dev, "wait src ready timeout 0x%lx [0x%x]\n",
529 ES_REG(ensoniq, 1371_SMPRATE), r); 529 ES_REG(ensoniq, 1371_SMPRATE), r);
530 return 0; 530 return 0;
531} 531}
@@ -587,7 +587,7 @@ static void snd_es1370_codec_write(struct snd_ak4531 *ak4531,
587 unsigned long end_time = jiffies + HZ / 10; 587 unsigned long end_time = jiffies + HZ / 10;
588 588
589#if 0 589#if 0
590 printk(KERN_DEBUG 590 dev_dbg(ensoniq->card->dev,
591 "CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", 591 "CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n",
592 reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); 592 reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC));
593#endif 593#endif
@@ -598,7 +598,7 @@ static void snd_es1370_codec_write(struct snd_ak4531 *ak4531,
598 } 598 }
599 schedule_timeout_uninterruptible(1); 599 schedule_timeout_uninterruptible(1);
600 } while (time_after(end_time, jiffies)); 600 } while (time_after(end_time, jiffies));
601 snd_printk(KERN_ERR "codec write timeout, status = 0x%x\n", 601 dev_err(ensoniq->card->dev, "codec write timeout, status = 0x%x\n",
602 inl(ES_REG(ensoniq, STATUS))); 602 inl(ES_REG(ensoniq, STATUS)));
603} 603}
604 604
@@ -649,7 +649,7 @@ static void snd_es1371_codec_write(struct snd_ac97 *ac97,
649 } 649 }
650 } 650 }
651 mutex_unlock(&ensoniq->src_mutex); 651 mutex_unlock(&ensoniq->src_mutex);
652 snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n", 652 dev_err(ensoniq->card->dev, "codec write timeout at 0x%lx [0x%x]\n",
653 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); 653 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
654} 654}
655 655
@@ -706,8 +706,8 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
706 } 706 }
707 mutex_unlock(&ensoniq->src_mutex); 707 mutex_unlock(&ensoniq->src_mutex);
708 if (++fail > 10) { 708 if (++fail > 10) {
709 snd_printk(KERN_ERR "codec read timeout (final) " 709 dev_err(ensoniq->card->dev,
710 "at 0x%lx, reg = 0x%x [0x%x]\n", 710 "codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n",
711 ES_REG(ensoniq, 1371_CODEC), reg, 711 ES_REG(ensoniq, 1371_CODEC), reg,
712 inl(ES_REG(ensoniq, 1371_CODEC))); 712 inl(ES_REG(ensoniq, 1371_CODEC)));
713 return 0; 713 return 0;
@@ -716,7 +716,7 @@ static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
716 } 716 }
717 } 717 }
718 mutex_unlock(&ensoniq->src_mutex); 718 mutex_unlock(&ensoniq->src_mutex);
719 snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n", 719 dev_err(ensoniq->card->dev, "codec read timeout at 0x%lx [0x%x]\n",
720 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); 720 ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
721 return 0; 721 return 0;
722} 722}
@@ -1796,7 +1796,7 @@ static int snd_ensoniq_1370_mixer(struct ensoniq *ensoniq)
1796#ifdef SUPPORT_JOYSTICK 1796#ifdef SUPPORT_JOYSTICK
1797 1797
1798#ifdef CHIP1371 1798#ifdef CHIP1371
1799static int snd_ensoniq_get_joystick_port(int dev) 1799static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev)
1800{ 1800{
1801 switch (joystick_port[dev]) { 1801 switch (joystick_port[dev]) {
1802 case 0: /* disabled */ 1802 case 0: /* disabled */
@@ -1808,12 +1808,13 @@ static int snd_ensoniq_get_joystick_port(int dev)
1808 return joystick_port[dev]; 1808 return joystick_port[dev];
1809 1809
1810 default: 1810 default:
1811 printk(KERN_ERR "ens1371: invalid joystick port %#x", joystick_port[dev]); 1811 dev_err(ensoniq->card->dev,
1812 "invalid joystick port %#x", joystick_port[dev]);
1812 return 0; 1813 return 0;
1813 } 1814 }
1814} 1815}
1815#else 1816#else
1816static inline int snd_ensoniq_get_joystick_port(int dev) 1817static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev)
1817{ 1818{
1818 return joystick[dev] ? 0x200 : 0; 1819 return joystick[dev] ? 0x200 : 0;
1819} 1820}
@@ -1824,7 +1825,7 @@ static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev)
1824 struct gameport *gp; 1825 struct gameport *gp;
1825 int io_port; 1826 int io_port;
1826 1827
1827 io_port = snd_ensoniq_get_joystick_port(dev); 1828 io_port = snd_ensoniq_get_joystick_port(ensoniq, dev);
1828 1829
1829 switch (io_port) { 1830 switch (io_port) {
1830 case 0: 1831 case 0:
@@ -1835,14 +1836,16 @@ static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev)
1835 if (request_region(io_port, 8, "ens137x: gameport")) 1836 if (request_region(io_port, 8, "ens137x: gameport"))
1836 break; 1837 break;
1837 if (io_port > 0x218) { 1838 if (io_port > 0x218) {
1838 printk(KERN_WARNING "ens137x: no gameport ports available\n"); 1839 dev_warn(ensoniq->card->dev,
1840 "no gameport ports available\n");
1839 return -EBUSY; 1841 return -EBUSY;
1840 } 1842 }
1841 break; 1843 break;
1842 1844
1843 default: 1845 default:
1844 if (!request_region(io_port, 8, "ens137x: gameport")) { 1846 if (!request_region(io_port, 8, "ens137x: gameport")) {
1845 printk(KERN_WARNING "ens137x: gameport io port %#x in use\n", 1847 dev_warn(ensoniq->card->dev,
1848 "gameport io port %#x in use\n",
1846 io_port); 1849 io_port);
1847 return -EBUSY; 1850 return -EBUSY;
1848 } 1851 }
@@ -1851,7 +1854,8 @@ static int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev)
1851 1854
1852 ensoniq->gameport = gp = gameport_allocate_port(); 1855 ensoniq->gameport = gp = gameport_allocate_port();
1853 if (!gp) { 1856 if (!gp) {
1854 printk(KERN_ERR "ens137x: cannot allocate memory for gameport\n"); 1857 dev_err(ensoniq->card->dev,
1858 "cannot allocate memory for gameport\n");
1855 release_region(io_port, 8); 1859 release_region(io_port, 8);
1856 return -ENOMEM; 1860 return -ENOMEM;
1857 } 1861 }
@@ -2082,8 +2086,7 @@ static int snd_ensoniq_resume(struct device *dev)
2082 pci_set_power_state(pci, PCI_D0); 2086 pci_set_power_state(pci, PCI_D0);
2083 pci_restore_state(pci); 2087 pci_restore_state(pci);
2084 if (pci_enable_device(pci) < 0) { 2088 if (pci_enable_device(pci) < 0) {
2085 printk(KERN_ERR DRIVER_NAME ": pci_enable_device failed, " 2089 dev_err(dev, "pci_enable_device failed, disabling device\n");
2086 "disabling device\n");
2087 snd_card_disconnect(card); 2090 snd_card_disconnect(card);
2088 return -EIO; 2091 return -EIO;
2089 } 2092 }
@@ -2137,7 +2140,7 @@ static int snd_ensoniq_create(struct snd_card *card,
2137 ensoniq->port = pci_resource_start(pci, 0); 2140 ensoniq->port = pci_resource_start(pci, 0);
2138 if (request_irq(pci->irq, snd_audiopci_interrupt, IRQF_SHARED, 2141 if (request_irq(pci->irq, snd_audiopci_interrupt, IRQF_SHARED,
2139 KBUILD_MODNAME, ensoniq)) { 2142 KBUILD_MODNAME, ensoniq)) {
2140 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2143 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2141 snd_ensoniq_free(ensoniq); 2144 snd_ensoniq_free(ensoniq);
2142 return -EBUSY; 2145 return -EBUSY;
2143 } 2146 }
@@ -2145,7 +2148,7 @@ static int snd_ensoniq_create(struct snd_card *card,
2145#ifdef CHIP1370 2148#ifdef CHIP1370
2146 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 2149 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
2147 16, &ensoniq->dma_bug) < 0) { 2150 16, &ensoniq->dma_bug) < 0) {
2148 snd_printk(KERN_ERR "unable to allocate space for phantom area - dma_bug\n"); 2151 dev_err(card->dev, "unable to allocate space for phantom area - dma_bug\n");
2149 snd_ensoniq_free(ensoniq); 2152 snd_ensoniq_free(ensoniq);
2150 return -EBUSY; 2153 return -EBUSY;
2151 } 2154 }
@@ -2180,8 +2183,6 @@ static int snd_ensoniq_create(struct snd_card *card,
2180 2183
2181 snd_ensoniq_proc_init(ensoniq); 2184 snd_ensoniq_proc_init(ensoniq);
2182 2185
2183 snd_card_set_dev(card, &pci->dev);
2184
2185 *rensoniq = ensoniq; 2186 *rensoniq = ensoniq;
2186 return 0; 2187 return 0;
2187} 2188}
@@ -2437,7 +2438,8 @@ static int snd_audiopci_probe(struct pci_dev *pci,
2437 return -ENOENT; 2438 return -ENOENT;
2438 } 2439 }
2439 2440
2440 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2441 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2442 0, &card);
2441 if (err < 0) 2443 if (err < 0)
2442 return err; 2444 return err;
2443 2445
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c
index 9213fb38921c..34d95bf916b5 100644
--- a/sound/pci/es1938.c
+++ b/sound/pci/es1938.c
@@ -254,7 +254,6 @@ MODULE_DEVICE_TABLE(pci, snd_es1938_ids);
254#define WRITE_LOOP_TIMEOUT 0x10000 254#define WRITE_LOOP_TIMEOUT 0x10000
255#define GET_LOOP_TIMEOUT 0x01000 255#define GET_LOOP_TIMEOUT 0x01000
256 256
257#undef REG_DEBUG
258/* ----------------------------------------------------------------- 257/* -----------------------------------------------------------------
259 * Write to a mixer register 258 * Write to a mixer register
260 * -----------------------------------------------------------------*/ 259 * -----------------------------------------------------------------*/
@@ -265,9 +264,7 @@ static void snd_es1938_mixer_write(struct es1938 *chip, unsigned char reg, unsig
265 outb(reg, SLSB_REG(chip, MIXERADDR)); 264 outb(reg, SLSB_REG(chip, MIXERADDR));
266 outb(val, SLSB_REG(chip, MIXERDATA)); 265 outb(val, SLSB_REG(chip, MIXERDATA));
267 spin_unlock_irqrestore(&chip->mixer_lock, flags); 266 spin_unlock_irqrestore(&chip->mixer_lock, flags);
268#ifdef REG_DEBUG 267 dev_dbg(chip->card->dev, "Mixer reg %02x set to %02x\n", reg, val);
269 snd_printk(KERN_DEBUG "Mixer reg %02x set to %02x\n", reg, val);
270#endif
271} 268}
272 269
273/* ----------------------------------------------------------------- 270/* -----------------------------------------------------------------
@@ -281,9 +278,7 @@ static int snd_es1938_mixer_read(struct es1938 *chip, unsigned char reg)
281 outb(reg, SLSB_REG(chip, MIXERADDR)); 278 outb(reg, SLSB_REG(chip, MIXERADDR));
282 data = inb(SLSB_REG(chip, MIXERDATA)); 279 data = inb(SLSB_REG(chip, MIXERDATA));
283 spin_unlock_irqrestore(&chip->mixer_lock, flags); 280 spin_unlock_irqrestore(&chip->mixer_lock, flags);
284#ifdef REG_DEBUG 281 dev_dbg(chip->card->dev, "Mixer reg %02x now is %02x\n", reg, data);
285 snd_printk(KERN_DEBUG "Mixer reg %02x now is %02x\n", reg, data);
286#endif
287 return data; 282 return data;
288} 283}
289 284
@@ -302,10 +297,9 @@ static int snd_es1938_mixer_bits(struct es1938 *chip, unsigned char reg,
302 if (val != oval) { 297 if (val != oval) {
303 new = (old & ~mask) | (val & mask); 298 new = (old & ~mask) | (val & mask);
304 outb(new, SLSB_REG(chip, MIXERDATA)); 299 outb(new, SLSB_REG(chip, MIXERDATA));
305#ifdef REG_DEBUG 300 dev_dbg(chip->card->dev,
306 snd_printk(KERN_DEBUG "Mixer reg %02x was %02x, set to %02x\n", 301 "Mixer reg %02x was %02x, set to %02x\n",
307 reg, old, new); 302 reg, old, new);
308#endif
309 } 303 }
310 spin_unlock_irqrestore(&chip->mixer_lock, flags); 304 spin_unlock_irqrestore(&chip->mixer_lock, flags);
311 return oval; 305 return oval;
@@ -324,7 +318,8 @@ static void snd_es1938_write_cmd(struct es1938 *chip, unsigned char cmd)
324 return; 318 return;
325 } 319 }
326 } 320 }
327 printk(KERN_ERR "snd_es1938_write_cmd timeout (0x02%x/0x02%x)\n", cmd, v); 321 dev_err(chip->card->dev,
322 "snd_es1938_write_cmd timeout (0x02%x/0x02%x)\n", cmd, v);
328} 323}
329 324
330/* ----------------------------------------------------------------- 325/* -----------------------------------------------------------------
@@ -337,7 +332,7 @@ static int snd_es1938_get_byte(struct es1938 *chip)
337 for (i = GET_LOOP_TIMEOUT; i; i--) 332 for (i = GET_LOOP_TIMEOUT; i; i--)
338 if ((v = inb(SLSB_REG(chip, STATUS))) & 0x80) 333 if ((v = inb(SLSB_REG(chip, STATUS))) & 0x80)
339 return inb(SLSB_REG(chip, READDATA)); 334 return inb(SLSB_REG(chip, READDATA));
340 snd_printk(KERN_ERR "get_byte timeout: status 0x02%x\n", v); 335 dev_err(chip->card->dev, "get_byte timeout: status 0x02%x\n", v);
341 return -ENODEV; 336 return -ENODEV;
342} 337}
343 338
@@ -351,9 +346,7 @@ static void snd_es1938_write(struct es1938 *chip, unsigned char reg, unsigned ch
351 snd_es1938_write_cmd(chip, reg); 346 snd_es1938_write_cmd(chip, reg);
352 snd_es1938_write_cmd(chip, val); 347 snd_es1938_write_cmd(chip, val);
353 spin_unlock_irqrestore(&chip->reg_lock, flags); 348 spin_unlock_irqrestore(&chip->reg_lock, flags);
354#ifdef REG_DEBUG 349 dev_dbg(chip->card->dev, "Reg %02x set to %02x\n", reg, val);
355 snd_printk(KERN_DEBUG "Reg %02x set to %02x\n", reg, val);
356#endif
357} 350}
358 351
359/* ----------------------------------------------------------------- 352/* -----------------------------------------------------------------
@@ -368,9 +361,7 @@ static unsigned char snd_es1938_read(struct es1938 *chip, unsigned char reg)
368 snd_es1938_write_cmd(chip, reg); 361 snd_es1938_write_cmd(chip, reg);
369 val = snd_es1938_get_byte(chip); 362 val = snd_es1938_get_byte(chip);
370 spin_unlock_irqrestore(&chip->reg_lock, flags); 363 spin_unlock_irqrestore(&chip->reg_lock, flags);
371#ifdef REG_DEBUG 364 dev_dbg(chip->card->dev, "Reg %02x now is %02x\n", reg, val);
372 snd_printk(KERN_DEBUG "Reg %02x now is %02x\n", reg, val);
373#endif
374 return val; 365 return val;
375} 366}
376 367
@@ -391,10 +382,8 @@ static int snd_es1938_bits(struct es1938 *chip, unsigned char reg, unsigned char
391 snd_es1938_write_cmd(chip, reg); 382 snd_es1938_write_cmd(chip, reg);
392 new = (old & ~mask) | (val & mask); 383 new = (old & ~mask) | (val & mask);
393 snd_es1938_write_cmd(chip, new); 384 snd_es1938_write_cmd(chip, new);
394#ifdef REG_DEBUG 385 dev_dbg(chip->card->dev, "Reg %02x was %02x, set to %02x\n",
395 snd_printk(KERN_DEBUG "Reg %02x was %02x, set to %02x\n",
396 reg, old, new); 386 reg, old, new);
397#endif
398 } 387 }
399 spin_unlock_irqrestore(&chip->reg_lock, flags); 388 spin_unlock_irqrestore(&chip->reg_lock, flags);
400 return oval; 389 return oval;
@@ -416,7 +405,7 @@ static void snd_es1938_reset(struct es1938 *chip)
416 goto __next; 405 goto __next;
417 } 406 }
418 } 407 }
419 snd_printk(KERN_ERR "ESS Solo-1 reset failed\n"); 408 dev_err(chip->card->dev, "ESS Solo-1 reset failed\n");
420 409
421 __next: 410 __next:
422 snd_es1938_write_cmd(chip, ESS_CMD_ENABLEEXT); 411 snd_es1938_write_cmd(chip, ESS_CMD_ENABLEEXT);
@@ -1504,16 +1493,15 @@ static int es1938_resume(struct device *dev)
1504 pci_set_power_state(pci, PCI_D0); 1493 pci_set_power_state(pci, PCI_D0);
1505 pci_restore_state(pci); 1494 pci_restore_state(pci);
1506 if (pci_enable_device(pci) < 0) { 1495 if (pci_enable_device(pci) < 0) {
1507 printk(KERN_ERR "es1938: pci_enable_device failed, " 1496 dev_err(dev, "pci_enable_device failed, disabling device\n");
1508 "disabling device\n");
1509 snd_card_disconnect(card); 1497 snd_card_disconnect(card);
1510 return -EIO; 1498 return -EIO;
1511 } 1499 }
1512 1500
1513 if (request_irq(pci->irq, snd_es1938_interrupt, 1501 if (request_irq(pci->irq, snd_es1938_interrupt,
1514 IRQF_SHARED, KBUILD_MODNAME, chip)) { 1502 IRQF_SHARED, KBUILD_MODNAME, chip)) {
1515 printk(KERN_ERR "es1938: unable to grab IRQ %d, " 1503 dev_err(dev, "unable to grab IRQ %d, disabling device\n",
1516 "disabling device\n", pci->irq); 1504 pci->irq);
1517 snd_card_disconnect(card); 1505 snd_card_disconnect(card);
1518 return -EIO; 1506 return -EIO;
1519 } 1507 }
@@ -1545,7 +1533,8 @@ static int snd_es1938_create_gameport(struct es1938 *chip)
1545 1533
1546 chip->gameport = gp = gameport_allocate_port(); 1534 chip->gameport = gp = gameport_allocate_port();
1547 if (!gp) { 1535 if (!gp) {
1548 printk(KERN_ERR "es1938: cannot allocate memory for gameport\n"); 1536 dev_err(chip->card->dev,
1537 "cannot allocate memory for gameport\n");
1549 return -ENOMEM; 1538 return -ENOMEM;
1550 } 1539 }
1551 1540
@@ -1612,7 +1601,8 @@ static int snd_es1938_create(struct snd_card *card,
1612 /* check, if we can restrict PCI DMA transfers to 24 bits */ 1601 /* check, if we can restrict PCI DMA transfers to 24 bits */
1613 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 || 1602 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
1614 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) { 1603 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
1615 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n"); 1604 dev_err(card->dev,
1605 "architecture does not support 24bit PCI busmaster DMA\n");
1616 pci_disable_device(pci); 1606 pci_disable_device(pci);
1617 return -ENXIO; 1607 return -ENXIO;
1618 } 1608 }
@@ -1639,15 +1629,14 @@ static int snd_es1938_create(struct snd_card *card,
1639 chip->game_port = pci_resource_start(pci, 4); 1629 chip->game_port = pci_resource_start(pci, 4);
1640 if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED, 1630 if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED,
1641 KBUILD_MODNAME, chip)) { 1631 KBUILD_MODNAME, chip)) {
1642 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1632 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1643 snd_es1938_free(chip); 1633 snd_es1938_free(chip);
1644 return -EBUSY; 1634 return -EBUSY;
1645 } 1635 }
1646 chip->irq = pci->irq; 1636 chip->irq = pci->irq;
1647#ifdef ES1938_DDEBUG 1637 dev_dbg(card->dev,
1648 snd_printk(KERN_DEBUG "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n", 1638 "create: io: 0x%lx, sb: 0x%lx, vc: 0x%lx, mpu: 0x%lx, game: 0x%lx\n",
1649 chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port); 1639 chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port);
1650#endif
1651 1640
1652 chip->ddma_port = chip->vc_port + 0x00; /* fix from Thomas Sailer */ 1641 chip->ddma_port = chip->vc_port + 0x00; /* fix from Thomas Sailer */
1653 1642
@@ -1658,8 +1647,6 @@ static int snd_es1938_create(struct snd_card *card,
1658 return err; 1647 return err;
1659 } 1648 }
1660 1649
1661 snd_card_set_dev(card, &pci->dev);
1662
1663 *rchip = chip; 1650 *rchip = chip;
1664 return 0; 1651 return 0;
1665} 1652}
@@ -1675,21 +1662,22 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id)
1675 1662
1676 status = inb(SLIO_REG(chip, IRQCONTROL)); 1663 status = inb(SLIO_REG(chip, IRQCONTROL));
1677#if 0 1664#if 0
1678 printk(KERN_DEBUG "Es1938debug - interrupt status: =0x%x\n", status); 1665 dev_dbg(chip->card->dev,
1666 "Es1938debug - interrupt status: =0x%x\n", status);
1679#endif 1667#endif
1680 1668
1681 /* AUDIO 1 */ 1669 /* AUDIO 1 */
1682 if (status & 0x10) { 1670 if (status & 0x10) {
1683#if 0 1671#if 0
1684 printk(KERN_DEBUG 1672 dev_dbg(chip->card->dev,
1685 "Es1938debug - AUDIO channel 1 interrupt\n"); 1673 "Es1938debug - AUDIO channel 1 interrupt\n");
1686 printk(KERN_DEBUG 1674 dev_dbg(chip->card->dev,
1687 "Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n", 1675 "Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n",
1688 inw(SLDM_REG(chip, DMACOUNT))); 1676 inw(SLDM_REG(chip, DMACOUNT)));
1689 printk(KERN_DEBUG 1677 dev_dbg(chip->card->dev,
1690 "Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n", 1678 "Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n",
1691 inl(SLDM_REG(chip, DMAADDR))); 1679 inl(SLDM_REG(chip, DMAADDR)));
1692 printk(KERN_DEBUG 1680 dev_dbg(chip->card->dev,
1693 "Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n", 1681 "Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n",
1694 inl(SLDM_REG(chip, DMASTATUS))); 1682 inl(SLDM_REG(chip, DMASTATUS)));
1695#endif 1683#endif
@@ -1705,12 +1693,12 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id)
1705 /* AUDIO 2 */ 1693 /* AUDIO 2 */
1706 if (status & 0x20) { 1694 if (status & 0x20) {
1707#if 0 1695#if 0
1708 printk(KERN_DEBUG 1696 dev_dbg(chip->card->dev,
1709 "Es1938debug - AUDIO channel 2 interrupt\n"); 1697 "Es1938debug - AUDIO channel 2 interrupt\n");
1710 printk(KERN_DEBUG 1698 dev_dbg(chip->card->dev,
1711 "Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n", 1699 "Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n",
1712 inw(SLIO_REG(chip, AUDIO2DMACOUNT))); 1700 inw(SLIO_REG(chip, AUDIO2DMACOUNT)));
1713 printk(KERN_DEBUG 1701 dev_dbg(chip->card->dev,
1714 "Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n", 1702 "Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n",
1715 inl(SLIO_REG(chip, AUDIO2DMAADDR))); 1703 inl(SLIO_REG(chip, AUDIO2DMAADDR)));
1716 1704
@@ -1808,7 +1796,8 @@ static int snd_es1938_probe(struct pci_dev *pci,
1808 return -ENOENT; 1796 return -ENOENT;
1809 } 1797 }
1810 1798
1811 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1799 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1800 0, &card);
1812 if (err < 0) 1801 if (err < 0)
1813 return err; 1802 return err;
1814 for (idx = 0; idx < 5; idx++) { 1803 for (idx = 0; idx < 5; idx++) {
@@ -1843,7 +1832,7 @@ static int snd_es1938_probe(struct pci_dev *pci,
1843 SLSB_REG(chip, FMLOWADDR), 1832 SLSB_REG(chip, FMLOWADDR),
1844 SLSB_REG(chip, FMHIGHADDR), 1833 SLSB_REG(chip, FMHIGHADDR),
1845 OPL3_HW_OPL3, 1, &opl3) < 0) { 1834 OPL3_HW_OPL3, 1, &opl3) < 0) {
1846 printk(KERN_ERR "es1938: OPL3 not detected at 0x%lx\n", 1835 dev_err(card->dev, "OPL3 not detected at 0x%lx\n",
1847 SLSB_REG(chip, FMLOWADDR)); 1836 SLSB_REG(chip, FMLOWADDR));
1848 } else { 1837 } else {
1849 if ((err = snd_opl3_timer_new(opl3, 0, 1)) < 0) { 1838 if ((err = snd_opl3_timer_new(opl3, 0, 1)) < 0) {
@@ -1859,7 +1848,7 @@ static int snd_es1938_probe(struct pci_dev *pci,
1859 chip->mpu_port, 1848 chip->mpu_port,
1860 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK, 1849 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
1861 -1, &chip->rmidi) < 0) { 1850 -1, &chip->rmidi) < 0) {
1862 printk(KERN_ERR "es1938: unable to initialize MPU-401\n"); 1851 dev_err(card->dev, "unable to initialize MPU-401\n");
1863 } else { 1852 } else {
1864 // this line is vital for MIDI interrupt handling on ess-solo1 1853 // this line is vital for MIDI interrupt handling on ess-solo1
1865 // andreas@flying-snail.de 1854 // andreas@flying-snail.de
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 772cc36f951d..5bb1cf603301 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -632,7 +632,7 @@ static int snd_es1968_ac97_wait(struct es1968 *chip)
632 return 0; 632 return 0;
633 cond_resched(); 633 cond_resched();
634 } 634 }
635 snd_printd("es1968: ac97 timeout\n"); 635 dev_dbg(chip->card->dev, "ac97 timeout\n");
636 return 1; /* timeout */ 636 return 1; /* timeout */
637} 637}
638 638
@@ -644,7 +644,7 @@ static int snd_es1968_ac97_wait_poll(struct es1968 *chip)
644 if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1)) 644 if (!(inb(chip->io_port + ESM_AC97_INDEX) & 1))
645 return 0; 645 return 0;
646 } 646 }
647 snd_printd("es1968: ac97 timeout\n"); 647 dev_dbg(chip->card->dev, "ac97 timeout\n");
648 return 1; /* timeout */ 648 return 1; /* timeout */
649} 649}
650 650
@@ -687,7 +687,7 @@ static void apu_index_set(struct es1968 *chip, u16 index)
687 for (i = 0; i < 1000; i++) 687 for (i = 0; i < 1000; i++)
688 if (__maestro_read(chip, IDR1_CRAM_POINTER) == index) 688 if (__maestro_read(chip, IDR1_CRAM_POINTER) == index)
689 return; 689 return;
690 snd_printd("es1968: APU register select failed. (Timeout)\n"); 690 dev_dbg(chip->card->dev, "APU register select failed. (Timeout)\n");
691} 691}
692 692
693/* no spinlock */ 693/* no spinlock */
@@ -699,7 +699,7 @@ static void apu_data_set(struct es1968 *chip, u16 data)
699 return; 699 return;
700 __maestro_write(chip, IDR0_DATA_PORT, data); 700 __maestro_write(chip, IDR0_DATA_PORT, data);
701 } 701 }
702 snd_printd("es1968: APU register set probably failed (Timeout)!\n"); 702 dev_dbg(chip->card->dev, "APU register set probably failed (Timeout)!\n");
703} 703}
704 704
705/* no spinlock */ 705/* no spinlock */
@@ -1442,13 +1442,14 @@ snd_es1968_init_dmabuf(struct es1968 *chip)
1442 snd_dma_pci_data(chip->pci), 1442 snd_dma_pci_data(chip->pci),
1443 chip->total_bufsize, &chip->dma); 1443 chip->total_bufsize, &chip->dma);
1444 if (err < 0 || ! chip->dma.area) { 1444 if (err < 0 || ! chip->dma.area) {
1445 snd_printk(KERN_ERR "es1968: can't allocate dma pages for size %d\n", 1445 dev_err(chip->card->dev,
1446 "can't allocate dma pages for size %d\n",
1446 chip->total_bufsize); 1447 chip->total_bufsize);
1447 return -ENOMEM; 1448 return -ENOMEM;
1448 } 1449 }
1449 if ((chip->dma.addr + chip->dma.bytes - 1) & ~((1 << 28) - 1)) { 1450 if ((chip->dma.addr + chip->dma.bytes - 1) & ~((1 << 28) - 1)) {
1450 snd_dma_free_pages(&chip->dma); 1451 snd_dma_free_pages(&chip->dma);
1451 snd_printk(KERN_ERR "es1968: DMA buffer beyond 256MB.\n"); 1452 dev_err(chip->card->dev, "DMA buffer beyond 256MB.\n");
1452 return -ENOMEM; 1453 return -ENOMEM;
1453 } 1454 }
1454 1455
@@ -1489,7 +1490,8 @@ static int snd_es1968_hw_params(struct snd_pcm_substream *substream,
1489 } 1490 }
1490 chan->memory = snd_es1968_new_memory(chip, size); 1491 chan->memory = snd_es1968_new_memory(chip, size);
1491 if (chan->memory == NULL) { 1492 if (chan->memory == NULL) {
1492 // snd_printd("cannot allocate dma buffer: size = %d\n", size); 1493 dev_dbg(chip->card->dev,
1494 "cannot allocate dma buffer: size = %d\n", size);
1493 return -ENOMEM; 1495 return -ENOMEM;
1494 } 1496 }
1495 snd_pcm_set_runtime_buffer(substream, &chan->memory->buf); 1497 snd_pcm_set_runtime_buffer(substream, &chan->memory->buf);
@@ -1715,11 +1717,13 @@ static void es1968_measure_clock(struct es1968 *chip)
1715 1717
1716 /* search 2 APUs (although one apu is enough) */ 1718 /* search 2 APUs (although one apu is enough) */
1717 if ((apu = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY)) < 0) { 1719 if ((apu = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_PLAY)) < 0) {
1718 snd_printk(KERN_ERR "Hmm, cannot find empty APU pair!?\n"); 1720 dev_err(chip->card->dev, "Hmm, cannot find empty APU pair!?\n");
1719 return; 1721 return;
1720 } 1722 }
1721 if ((memory = snd_es1968_new_memory(chip, CLOCK_MEASURE_BUFSIZE)) == NULL) { 1723 if ((memory = snd_es1968_new_memory(chip, CLOCK_MEASURE_BUFSIZE)) == NULL) {
1722 snd_printk(KERN_ERR "cannot allocate dma buffer - using default clock %d\n", chip->clock); 1724 dev_warn(chip->card->dev,
1725 "cannot allocate dma buffer - using default clock %d\n",
1726 chip->clock);
1723 snd_es1968_free_apu_pair(chip, apu); 1727 snd_es1968_free_apu_pair(chip, apu);
1724 return; 1728 return;
1725 } 1729 }
@@ -1780,7 +1784,7 @@ static void es1968_measure_clock(struct es1968 *chip)
1780 else 1784 else
1781 t += stop_time.tv_usec - start_time.tv_usec; 1785 t += stop_time.tv_usec - start_time.tv_usec;
1782 if (t == 0) { 1786 if (t == 0) {
1783 snd_printk(KERN_ERR "?? calculation error..\n"); 1787 dev_err(chip->card->dev, "?? calculation error..\n");
1784 } else { 1788 } else {
1785 offset *= 1000; 1789 offset *= 1000;
1786 offset = (offset / t) * 1000 + ((offset % t) * 1000) / t; 1790 offset = (offset / t) * 1000 + ((offset % t) * 1000) / t;
@@ -1788,7 +1792,7 @@ static void es1968_measure_clock(struct es1968 *chip)
1788 if (offset >= 40000 && offset <= 50000) 1792 if (offset >= 40000 && offset <= 50000)
1789 chip->clock = (chip->clock * offset) / 48000; 1793 chip->clock = (chip->clock * offset) / 48000;
1790 } 1794 }
1791 printk(KERN_INFO "es1968: clocking to %d\n", chip->clock); 1795 dev_info(chip->card->dev, "clocking to %d\n", chip->clock);
1792 } 1796 }
1793 snd_es1968_free_memory(chip, memory); 1797 snd_es1968_free_memory(chip, memory);
1794 snd_es1968_free_apu_pair(chip, apu); 1798 snd_es1968_free_apu_pair(chip, apu);
@@ -2108,7 +2112,7 @@ static void snd_es1968_ac97_reset(struct es1968 *chip)
2108 outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c); 2112 outw(inw(ioaddr + 0x3c) & 0xfffc, ioaddr + 0x3c);
2109 2113
2110#if 0 /* the loop here needs to be much better if we want it.. */ 2114#if 0 /* the loop here needs to be much better if we want it.. */
2111 snd_printk(KERN_INFO "trying software reset\n"); 2115 dev_info(chip->card->dev, "trying software reset\n");
2112 /* try and do a software reset */ 2116 /* try and do a software reset */
2113 outb(0x80 | 0x7c, ioaddr + 0x30); 2117 outb(0x80 | 0x7c, ioaddr + 0x30);
2114 for (w = 0;; w++) { 2118 for (w = 0;; w++) {
@@ -2416,8 +2420,7 @@ static int es1968_resume(struct device *dev)
2416 pci_set_power_state(pci, PCI_D0); 2420 pci_set_power_state(pci, PCI_D0);
2417 pci_restore_state(pci); 2421 pci_restore_state(pci);
2418 if (pci_enable_device(pci) < 0) { 2422 if (pci_enable_device(pci) < 0) {
2419 printk(KERN_ERR "es1968: pci_enable_device failed, " 2423 dev_err(dev, "pci_enable_device failed, disabling device\n");
2420 "disabling device\n");
2421 snd_card_disconnect(card); 2424 snd_card_disconnect(card);
2422 return -EIO; 2425 return -EIO;
2423 } 2426 }
@@ -2479,7 +2482,8 @@ static int snd_es1968_create_gameport(struct es1968 *chip, int dev)
2479 2482
2480 chip->gameport = gp = gameport_allocate_port(); 2483 chip->gameport = gp = gameport_allocate_port();
2481 if (!gp) { 2484 if (!gp) {
2482 printk(KERN_ERR "es1968: cannot allocate memory for gameport\n"); 2485 dev_err(chip->card->dev,
2486 "cannot allocate memory for gameport\n");
2483 release_and_free_resource(r); 2487 release_and_free_resource(r);
2484 return -ENOMEM; 2488 return -ENOMEM;
2485 } 2489 }
@@ -2706,7 +2710,8 @@ static int snd_es1968_create(struct snd_card *card,
2706 /* check, if we can restrict PCI DMA transfers to 28 bits */ 2710 /* check, if we can restrict PCI DMA transfers to 28 bits */
2707 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 2711 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
2708 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 2712 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
2709 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); 2713 dev_err(card->dev,
2714 "architecture does not support 28bit PCI busmaster DMA\n");
2710 pci_disable_device(pci); 2715 pci_disable_device(pci);
2711 return -ENXIO; 2716 return -ENXIO;
2712 } 2717 }
@@ -2740,7 +2745,7 @@ static int snd_es1968_create(struct snd_card *card,
2740 chip->io_port = pci_resource_start(pci, 0); 2745 chip->io_port = pci_resource_start(pci, 0);
2741 if (request_irq(pci->irq, snd_es1968_interrupt, IRQF_SHARED, 2746 if (request_irq(pci->irq, snd_es1968_interrupt, IRQF_SHARED,
2742 KBUILD_MODNAME, chip)) { 2747 KBUILD_MODNAME, chip)) {
2743 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2748 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2744 snd_es1968_free(chip); 2749 snd_es1968_free(chip);
2745 return -EBUSY; 2750 return -EBUSY;
2746 } 2751 }
@@ -2770,7 +2775,7 @@ static int snd_es1968_create(struct snd_card *card,
2770 } 2775 }
2771 if (do_pm > 1) { 2776 if (do_pm > 1) {
2772 /* not matched; disabling pm */ 2777 /* not matched; disabling pm */
2773 printk(KERN_INFO "es1968: not attempting power management.\n"); 2778 dev_info(card->dev, "not attempting power management.\n");
2774 do_pm = 0; 2779 do_pm = 0;
2775 } 2780 }
2776 } 2781 }
@@ -2783,8 +2788,6 @@ static int snd_es1968_create(struct snd_card *card,
2783 return err; 2788 return err;
2784 } 2789 }
2785 2790
2786 snd_card_set_dev(card, &pci->dev);
2787
2788#ifdef CONFIG_SND_ES1968_RADIO 2791#ifdef CONFIG_SND_ES1968_RADIO
2789 /* don't play with GPIOs on laptops */ 2792 /* don't play with GPIOs on laptops */
2790 if (chip->pci->subsystem_vendor != 0x125d) 2793 if (chip->pci->subsystem_vendor != 0x125d)
@@ -2802,7 +2805,7 @@ static int snd_es1968_create(struct snd_card *card,
2802 for (i = 0; i < ARRAY_SIZE(snd_es1968_tea575x_gpios); i++) { 2805 for (i = 0; i < ARRAY_SIZE(snd_es1968_tea575x_gpios); i++) {
2803 chip->tea575x_tuner = i; 2806 chip->tea575x_tuner = i;
2804 if (!snd_tea575x_init(&chip->tea, THIS_MODULE)) { 2807 if (!snd_tea575x_init(&chip->tea, THIS_MODULE)) {
2805 snd_printk(KERN_INFO "es1968: detected TEA575x radio type %s\n", 2808 dev_info(card->dev, "detected TEA575x radio type %s\n",
2806 get_tea575x_gpio(chip)->name); 2809 get_tea575x_gpio(chip)->name);
2807 strlcpy(chip->tea.card, get_tea575x_gpio(chip)->name, 2810 strlcpy(chip->tea.card, get_tea575x_gpio(chip)->name,
2808 sizeof(chip->tea.card)); 2811 sizeof(chip->tea.card));
@@ -2836,7 +2839,8 @@ static int snd_es1968_probe(struct pci_dev *pci,
2836 return -ENOENT; 2839 return -ENOENT;
2837 } 2840 }
2838 2841
2839 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2842 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2843 0, &card);
2840 if (err < 0) 2844 if (err < 0)
2841 return err; 2845 return err;
2842 2846
@@ -2900,7 +2904,7 @@ static int snd_es1968_probe(struct pci_dev *pci,
2900 MPU401_INFO_INTEGRATED | 2904 MPU401_INFO_INTEGRATED |
2901 MPU401_INFO_IRQ_HOOK, 2905 MPU401_INFO_IRQ_HOOK,
2902 -1, &chip->rmidi)) < 0) { 2906 -1, &chip->rmidi)) < 0) {
2903 printk(KERN_WARNING "es1968: skipping MPU-401 MIDI support..\n"); 2907 dev_warn(card->dev, "skipping MPU-401 MIDI support..\n");
2904 } 2908 }
2905 } 2909 }
2906 2910
@@ -2909,8 +2913,8 @@ static int snd_es1968_probe(struct pci_dev *pci,
2909#ifdef CONFIG_SND_ES1968_INPUT 2913#ifdef CONFIG_SND_ES1968_INPUT
2910 err = snd_es1968_input_register(chip); 2914 err = snd_es1968_input_register(chip);
2911 if (err) 2915 if (err)
2912 snd_printk(KERN_WARNING "Input device registration " 2916 dev_warn(card->dev,
2913 "failed with error %i", err); 2917 "Input device registration failed with error %i", err);
2914#endif 2918#endif
2915 2919
2916 snd_es1968_start_irq(chip); 2920 snd_es1968_start_irq(chip);
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index 45bc8a95b7c4..db18ccabadd6 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -254,7 +254,7 @@ static void snd_fm801_codec_write(struct snd_ac97 *ac97,
254 goto ok1; 254 goto ok1;
255 udelay(10); 255 udelay(10);
256 } 256 }
257 snd_printk(KERN_ERR "AC'97 interface is busy (1)\n"); 257 dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
258 return; 258 return;
259 259
260 ok1: 260 ok1:
@@ -269,7 +269,7 @@ static void snd_fm801_codec_write(struct snd_ac97 *ac97,
269 return; 269 return;
270 udelay(10); 270 udelay(10);
271 } 271 }
272 snd_printk(KERN_ERR "AC'97 interface #%d is busy (2)\n", ac97->num); 272 dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n", ac97->num);
273} 273}
274 274
275static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short reg) 275static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short reg)
@@ -285,7 +285,7 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short
285 goto ok1; 285 goto ok1;
286 udelay(10); 286 udelay(10);
287 } 287 }
288 snd_printk(KERN_ERR "AC'97 interface is busy (1)\n"); 288 dev_err(chip->card->dev, "AC'97 interface is busy (1)\n");
289 return 0; 289 return 0;
290 290
291 ok1: 291 ok1:
@@ -297,7 +297,7 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short
297 goto ok2; 297 goto ok2;
298 udelay(10); 298 udelay(10);
299 } 299 }
300 snd_printk(KERN_ERR "AC'97 interface #%d is busy (2)\n", ac97->num); 300 dev_err(chip->card->dev, "AC'97 interface #%d is busy (2)\n", ac97->num);
301 return 0; 301 return 0;
302 302
303 ok2: 303 ok2:
@@ -306,7 +306,7 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short
306 goto ok3; 306 goto ok3;
307 udelay(10); 307 udelay(10);
308 } 308 }
309 snd_printk(KERN_ERR "AC'97 interface #%d is not valid (2)\n", ac97->num); 309 dev_err(chip->card->dev, "AC'97 interface #%d is not valid (2)\n", ac97->num);
310 return 0; 310 return 0;
311 311
312 ok3: 312 ok3:
@@ -1100,8 +1100,8 @@ static int snd_fm801_chip_init(struct fm801 *chip, int resume)
1100 1100
1101 if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0) 1101 if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0)
1102 if (!resume) { 1102 if (!resume) {
1103 snd_printk(KERN_INFO "Primary AC'97 codec not found, " 1103 dev_info(chip->card->dev,
1104 "assume SF64-PCR (tuner-only)\n"); 1104 "Primary AC'97 codec not found, assume SF64-PCR (tuner-only)\n");
1105 chip->tea575x_tuner = 3 | TUNER_ONLY; 1105 chip->tea575x_tuner = 3 | TUNER_ONLY;
1106 goto __ac97_ok; 1106 goto __ac97_ok;
1107 } 1107 }
@@ -1225,7 +1225,7 @@ static int snd_fm801_create(struct snd_card *card,
1225 if ((tea575x_tuner & TUNER_ONLY) == 0) { 1225 if ((tea575x_tuner & TUNER_ONLY) == 0) {
1226 if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED, 1226 if (request_irq(pci->irq, snd_fm801_interrupt, IRQF_SHARED,
1227 KBUILD_MODNAME, chip)) { 1227 KBUILD_MODNAME, chip)) {
1228 snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->irq); 1228 dev_err(card->dev, "unable to grab IRQ %d\n", chip->irq);
1229 snd_fm801_free(chip); 1229 snd_fm801_free(chip);
1230 return -EBUSY; 1230 return -EBUSY;
1231 } 1231 }
@@ -1251,8 +1251,6 @@ static int snd_fm801_create(struct snd_card *card,
1251 return err; 1251 return err;
1252 } 1252 }
1253 1253
1254 snd_card_set_dev(card, &pci->dev);
1255
1256#ifdef CONFIG_SND_FM801_TEA575X_BOOL 1254#ifdef CONFIG_SND_FM801_TEA575X_BOOL
1257 err = v4l2_device_register(&pci->dev, &chip->v4l2_dev); 1255 err = v4l2_device_register(&pci->dev, &chip->v4l2_dev);
1258 if (err < 0) { 1256 if (err < 0) {
@@ -1267,7 +1265,7 @@ static int snd_fm801_create(struct snd_card *card,
1267 if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 && 1265 if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
1268 (tea575x_tuner & TUNER_TYPE_MASK) < 4) { 1266 (tea575x_tuner & TUNER_TYPE_MASK) < 4) {
1269 if (snd_tea575x_init(&chip->tea, THIS_MODULE)) { 1267 if (snd_tea575x_init(&chip->tea, THIS_MODULE)) {
1270 snd_printk(KERN_ERR "TEA575x radio not found\n"); 1268 dev_err(card->dev, "TEA575x radio not found\n");
1271 snd_fm801_free(chip); 1269 snd_fm801_free(chip);
1272 return -ENODEV; 1270 return -ENODEV;
1273 } 1271 }
@@ -1276,13 +1274,14 @@ static int snd_fm801_create(struct snd_card *card,
1276 for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) { 1274 for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
1277 chip->tea575x_tuner = tea575x_tuner; 1275 chip->tea575x_tuner = tea575x_tuner;
1278 if (!snd_tea575x_init(&chip->tea, THIS_MODULE)) { 1276 if (!snd_tea575x_init(&chip->tea, THIS_MODULE)) {
1279 snd_printk(KERN_INFO "detected TEA575x radio type %s\n", 1277 dev_info(card->dev,
1278 "detected TEA575x radio type %s\n",
1280 get_tea575x_gpio(chip)->name); 1279 get_tea575x_gpio(chip)->name);
1281 break; 1280 break;
1282 } 1281 }
1283 } 1282 }
1284 if (tea575x_tuner == 4) { 1283 if (tea575x_tuner == 4) {
1285 snd_printk(KERN_ERR "TEA575x radio not found\n"); 1284 dev_err(card->dev, "TEA575x radio not found\n");
1286 chip->tea575x_tuner = TUNER_DISABLED; 1285 chip->tea575x_tuner = TUNER_DISABLED;
1287 } 1286 }
1288 } 1287 }
@@ -1312,7 +1311,8 @@ static int snd_card_fm801_probe(struct pci_dev *pci,
1312 return -ENOENT; 1311 return -ENOENT;
1313 } 1312 }
1314 1313
1315 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1314 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1315 0, &card);
1316 if (err < 0) 1316 if (err < 0)
1317 return err; 1317 return err;
1318 if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev], &chip)) < 0) { 1318 if ((err = snd_fm801_create(card, pci, tea575x_tuner[dev], radio_nr[dev], &chip)) < 0) {
@@ -1411,8 +1411,7 @@ static int snd_fm801_resume(struct device *dev)
1411 pci_set_power_state(pci, PCI_D0); 1411 pci_set_power_state(pci, PCI_D0);
1412 pci_restore_state(pci); 1412 pci_restore_state(pci);
1413 if (pci_enable_device(pci) < 0) { 1413 if (pci_enable_device(pci) < 0) {
1414 printk(KERN_ERR "fm801: pci_enable_device failed, " 1414 dev_err(dev, "pci_enable_device failed, disabling device\n");
1415 "disabling device\n");
1416 snd_card_disconnect(card); 1415 snd_card_disconnect(card);
1417 return -EIO; 1416 return -EIO;
1418 } 1417 }
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig
index 0e53634dbbd8..ac17c3fc9388 100644
--- a/sound/pci/hda/Kconfig
+++ b/sound/pci/hda/Kconfig
@@ -1,8 +1,15 @@
1menuconfig SND_HDA_INTEL 1menu "HD-Audio"
2 tristate "Intel HD Audio" 2
3config SND_HDA
4 tristate
3 select SND_PCM 5 select SND_PCM
4 select SND_VMASTER 6 select SND_VMASTER
5 select SND_KCTL_JACK 7 select SND_KCTL_JACK
8
9config SND_HDA_INTEL
10 tristate "HD Audio PCI"
11 depends on SND_PCI
12 select SND_HDA
6 help 13 help
7 Say Y here to include support for Intel "High Definition 14 Say Y here to include support for Intel "High Definition
8 Audio" (Azalia) and its compatible devices. 15 Audio" (Azalia) and its compatible devices.
@@ -13,7 +20,7 @@ menuconfig SND_HDA_INTEL
13 To compile this driver as a module, choose M here: the module 20 To compile this driver as a module, choose M here: the module
14 will be called snd-hda-intel. 21 will be called snd-hda-intel.
15 22
16if SND_HDA_INTEL 23if SND_HDA
17 24
18config SND_HDA_DSP_LOADER 25config SND_HDA_DSP_LOADER
19 bool 26 bool
@@ -41,7 +48,6 @@ config SND_HDA_HWDEP
41 48
42config SND_HDA_RECONFIG 49config SND_HDA_RECONFIG
43 bool "Allow dynamic codec reconfiguration" 50 bool "Allow dynamic codec reconfiguration"
44 depends on SND_HDA_HWDEP
45 help 51 help
46 Say Y here to enable the HD-audio codec re-configuration feature. 52 Say Y here to enable the HD-audio codec re-configuration feature.
47 This adds the sysfs interfaces to allow user to clear the whole 53 This adds the sysfs interfaces to allow user to clear the whole
@@ -50,7 +56,7 @@ config SND_HDA_RECONFIG
50 56
51config SND_HDA_INPUT_BEEP 57config SND_HDA_INPUT_BEEP
52 bool "Support digital beep via input layer" 58 bool "Support digital beep via input layer"
53 depends on INPUT=y || INPUT=SND_HDA_INTEL 59 depends on INPUT=y || INPUT=SND_HDA
54 help 60 help
55 Say Y here to build a digital beep interface for HD-audio 61 Say Y here to build a digital beep interface for HD-audio
56 driver. This interface is used to generate digital beeps. 62 driver. This interface is used to generate digital beeps.
@@ -76,7 +82,6 @@ config SND_HDA_INPUT_JACK
76config SND_HDA_PATCH_LOADER 82config SND_HDA_PATCH_LOADER
77 bool "Support initialization patch loading for HD-audio" 83 bool "Support initialization patch loading for HD-audio"
78 select FW_LOADER 84 select FW_LOADER
79 select SND_HDA_HWDEP
80 select SND_HDA_RECONFIG 85 select SND_HDA_RECONFIG
81 help 86 help
82 Say Y here to allow the HD-audio driver to load a pseudo 87 Say Y here to allow the HD-audio driver to load a pseudo
@@ -84,8 +89,6 @@ config SND_HDA_PATCH_LOADER
84 start up. The "patch" file can be specified via patch module 89 start up. The "patch" file can be specified via patch module
85 option, such as patch=hda-init. 90 option, such as patch=hda-init.
86 91
87 This option turns on hwdep and reconfig features automatically.
88
89config SND_HDA_CODEC_REALTEK 92config SND_HDA_CODEC_REALTEK
90 tristate "Build Realtek HD-audio codec support" 93 tristate "Build Realtek HD-audio codec support"
91 select SND_HDA_GENERIC 94 select SND_HDA_GENERIC
@@ -94,7 +97,7 @@ config SND_HDA_CODEC_REALTEK
94 snd-hda-intel driver, such as ALC880. 97 snd-hda-intel driver, such as ALC880.
95 98
96comment "Set to Y if you want auto-loading the codec driver" 99comment "Set to Y if you want auto-loading the codec driver"
97 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_REALTEK=m 100 depends on SND_HDA=y && SND_HDA_CODEC_REALTEK=m
98 101
99config SND_HDA_CODEC_ANALOG 102config SND_HDA_CODEC_ANALOG
100 tristate "Build Analog Device HD-audio codec support" 103 tristate "Build Analog Device HD-audio codec support"
@@ -104,7 +107,7 @@ config SND_HDA_CODEC_ANALOG
104 snd-hda-intel driver, such as AD1986A. 107 snd-hda-intel driver, such as AD1986A.
105 108
106comment "Set to Y if you want auto-loading the codec driver" 109comment "Set to Y if you want auto-loading the codec driver"
107 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_ANALOG=m 110 depends on SND_HDA=y && SND_HDA_CODEC_ANALOG=m
108 111
109config SND_HDA_CODEC_SIGMATEL 112config SND_HDA_CODEC_SIGMATEL
110 tristate "Build IDT/Sigmatel HD-audio codec support" 113 tristate "Build IDT/Sigmatel HD-audio codec support"
@@ -114,7 +117,7 @@ config SND_HDA_CODEC_SIGMATEL
114 snd-hda-intel driver, such as STAC9200. 117 snd-hda-intel driver, such as STAC9200.
115 118
116comment "Set to Y if you want auto-loading the codec driver" 119comment "Set to Y if you want auto-loading the codec driver"
117 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_SIGMATEL=m 120 depends on SND_HDA=y && SND_HDA_CODEC_SIGMATEL=m
118 121
119config SND_HDA_CODEC_VIA 122config SND_HDA_CODEC_VIA
120 tristate "Build VIA HD-audio codec support" 123 tristate "Build VIA HD-audio codec support"
@@ -124,7 +127,7 @@ config SND_HDA_CODEC_VIA
124 snd-hda-intel driver, such as VT1708. 127 snd-hda-intel driver, such as VT1708.
125 128
126comment "Set to Y if you want auto-loading the codec driver" 129comment "Set to Y if you want auto-loading the codec driver"
127 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_VIA=m 130 depends on SND_HDA=y && SND_HDA_CODEC_VIA=m
128 131
129config SND_HDA_CODEC_HDMI 132config SND_HDA_CODEC_HDMI
130 tristate "Build HDMI/DisplayPort HD-audio codec support" 133 tristate "Build HDMI/DisplayPort HD-audio codec support"
@@ -134,7 +137,7 @@ config SND_HDA_CODEC_HDMI
134 Intel and Nvidia HDMI/DisplayPort codecs. 137 Intel and Nvidia HDMI/DisplayPort codecs.
135 138
136comment "Set to Y if you want auto-loading the codec driver" 139comment "Set to Y if you want auto-loading the codec driver"
137 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_HDMI=m 140 depends on SND_HDA=y && SND_HDA_CODEC_HDMI=m
138 141
139config SND_HDA_I915 142config SND_HDA_I915
140 bool 143 bool
@@ -149,7 +152,7 @@ config SND_HDA_CODEC_CIRRUS
149 snd-hda-intel driver, such as CS4206. 152 snd-hda-intel driver, such as CS4206.
150 153
151comment "Set to Y if you want auto-loading the codec driver" 154comment "Set to Y if you want auto-loading the codec driver"
152 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CIRRUS=m 155 depends on SND_HDA=y && SND_HDA_CODEC_CIRRUS=m
153 156
154config SND_HDA_CODEC_CONEXANT 157config SND_HDA_CODEC_CONEXANT
155 tristate "Build Conexant HD-audio codec support" 158 tristate "Build Conexant HD-audio codec support"
@@ -159,7 +162,7 @@ config SND_HDA_CODEC_CONEXANT
159 snd-hda-intel driver, such as CX20549. 162 snd-hda-intel driver, such as CX20549.
160 163
161comment "Set to Y if you want auto-loading the codec driver" 164comment "Set to Y if you want auto-loading the codec driver"
162 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CONEXANT=m 165 depends on SND_HDA=y && SND_HDA_CODEC_CONEXANT=m
163 166
164config SND_HDA_CODEC_CA0110 167config SND_HDA_CODEC_CA0110
165 tristate "Build Creative CA0110-IBG codec support" 168 tristate "Build Creative CA0110-IBG codec support"
@@ -169,7 +172,7 @@ config SND_HDA_CODEC_CA0110
169 snd-hda-intel driver, found on some Creative X-Fi cards. 172 snd-hda-intel driver, found on some Creative X-Fi cards.
170 173
171comment "Set to Y if you want auto-loading the codec driver" 174comment "Set to Y if you want auto-loading the codec driver"
172 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CA0110=m 175 depends on SND_HDA=y && SND_HDA_CODEC_CA0110=m
173 176
174config SND_HDA_CODEC_CA0132 177config SND_HDA_CODEC_CA0132
175 tristate "Build Creative CA0132 codec support" 178 tristate "Build Creative CA0132 codec support"
@@ -178,7 +181,7 @@ config SND_HDA_CODEC_CA0132
178 snd-hda-intel driver. 181 snd-hda-intel driver.
179 182
180comment "Set to Y if you want auto-loading the codec driver" 183comment "Set to Y if you want auto-loading the codec driver"
181 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CA0132=m 184 depends on SND_HDA=y && SND_HDA_CODEC_CA0132=m
182 185
183config SND_HDA_CODEC_CA0132_DSP 186config SND_HDA_CODEC_CA0132_DSP
184 bool "Support new DSP code for CA0132 codec" 187 bool "Support new DSP code for CA0132 codec"
@@ -200,7 +203,7 @@ config SND_HDA_CODEC_CMEDIA
200 snd-hda-intel driver, such as CMI9880. 203 snd-hda-intel driver, such as CMI9880.
201 204
202comment "Set to Y if you want auto-loading the codec driver" 205comment "Set to Y if you want auto-loading the codec driver"
203 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_CMEDIA=m 206 depends on SND_HDA=y && SND_HDA_CODEC_CMEDIA=m
204 207
205config SND_HDA_CODEC_SI3054 208config SND_HDA_CODEC_SI3054
206 tristate "Build Silicon Labs 3054 HD-modem codec support" 209 tristate "Build Silicon Labs 3054 HD-modem codec support"
@@ -209,7 +212,7 @@ config SND_HDA_CODEC_SI3054
209 (and compatibles) support in snd-hda-intel driver. 212 (and compatibles) support in snd-hda-intel driver.
210 213
211comment "Set to Y if you want auto-loading the codec driver" 214comment "Set to Y if you want auto-loading the codec driver"
212 depends on SND_HDA_INTEL=y && SND_HDA_CODEC_SI3054=m 215 depends on SND_HDA=y && SND_HDA_CODEC_SI3054=m
213 216
214config SND_HDA_GENERIC 217config SND_HDA_GENERIC
215 tristate "Enable generic HD-audio codec parser" 218 tristate "Enable generic HD-audio codec parser"
@@ -218,7 +221,7 @@ config SND_HDA_GENERIC
218 in snd-hda-intel driver. 221 in snd-hda-intel driver.
219 222
220comment "Set to Y if you want auto-loading the codec driver" 223comment "Set to Y if you want auto-loading the codec driver"
221 depends on SND_HDA_INTEL=y && SND_HDA_GENERIC=m 224 depends on SND_HDA=y && SND_HDA_GENERIC=m
222 225
223config SND_HDA_POWER_SAVE_DEFAULT 226config SND_HDA_POWER_SAVE_DEFAULT
224 int "Default time-out for HD-audio power-save mode" 227 int "Default time-out for HD-audio power-save mode"
@@ -229,3 +232,5 @@ config SND_HDA_POWER_SAVE_DEFAULT
229 power-save mode. 0 means to disable the power-save mode. 232 power-save mode. 0 means to disable the power-save mode.
230 233
231endif 234endif
235
236endmenu
diff --git a/sound/pci/hda/Makefile b/sound/pci/hda/Makefile
index 1fcb118e480a..d0d0c19ddfc2 100644
--- a/sound/pci/hda/Makefile
+++ b/sound/pci/hda/Makefile
@@ -1,15 +1,16 @@
1snd-hda-intel-objs := hda_intel.o 1snd-hda-intel-objs := hda_intel.o
2snd-hda-controller-objs := hda_controller.o
2# for haswell power well 3# for haswell power well
3snd-hda-intel-$(CONFIG_SND_HDA_I915) += hda_i915.o 4snd-hda-intel-$(CONFIG_SND_HDA_I915) += hda_i915.o
4 5
5snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o 6snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o hda_sysfs.o
6snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o 7snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
7snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 8snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
8snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o 9snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
9 10
10# for trace-points 11# for trace-points
11CFLAGS_hda_codec.o := -I$(src) 12CFLAGS_hda_codec.o := -I$(src)
12CFLAGS_hda_intel.o := -I$(src) 13CFLAGS_hda_controller.o := -I$(src)
13 14
14snd-hda-codec-generic-objs := hda_generic.o 15snd-hda-codec-generic-objs := hda_generic.o
15snd-hda-codec-realtek-objs := patch_realtek.o 16snd-hda-codec-realtek-objs := patch_realtek.o
@@ -25,7 +26,8 @@ snd-hda-codec-via-objs := patch_via.o
25snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o 26snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o
26 27
27# common driver 28# common driver
28obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o 29obj-$(CONFIG_SND_HDA) := snd-hda-codec.o
30obj-$(CONFIG_SND_HDA) += snd-hda-controller.o
29 31
30# codec drivers 32# codec drivers
31obj-$(CONFIG_SND_HDA_GENERIC) += snd-hda-codec-generic.o 33obj-$(CONFIG_SND_HDA_GENERIC) += snd-hda-codec-generic.o
diff --git a/sound/pci/hda/hda_auto_parser.c b/sound/pci/hda/hda_auto_parser.c
index 47ad31c6aa70..90d2fda6c8f9 100644
--- a/sound/pci/hda/hda_auto_parser.c
+++ b/sound/pci/hda/hda_auto_parser.c
@@ -227,10 +227,18 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
227 continue; 227 continue;
228 if (!assoc_line_out) 228 if (!assoc_line_out)
229 assoc_line_out = assoc; 229 assoc_line_out = assoc;
230 else if (assoc_line_out != assoc) 230 else if (assoc_line_out != assoc) {
231 codec_info(codec,
232 "ignore pin 0x%x with mismatching assoc# 0x%x vs 0x%x\n",
233 nid, assoc, assoc_line_out);
231 continue; 234 continue;
232 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) 235 }
236 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) {
237 codec_info(codec,
238 "ignore pin 0x%x, too many assigned pins\n",
239 nid);
233 continue; 240 continue;
241 }
234 line_out[cfg->line_outs].pin = nid; 242 line_out[cfg->line_outs].pin = nid;
235 line_out[cfg->line_outs].seq = seq; 243 line_out[cfg->line_outs].seq = seq;
236 cfg->line_outs++; 244 cfg->line_outs++;
@@ -238,8 +246,12 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
238 case AC_JACK_SPEAKER: 246 case AC_JACK_SPEAKER:
239 seq = get_defcfg_sequence(def_conf); 247 seq = get_defcfg_sequence(def_conf);
240 assoc = get_defcfg_association(def_conf); 248 assoc = get_defcfg_association(def_conf);
241 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) 249 if (cfg->speaker_outs >= ARRAY_SIZE(cfg->speaker_pins)) {
250 codec_info(codec,
251 "ignore pin 0x%x, too many assigned pins\n",
252 nid);
242 continue; 253 continue;
254 }
243 speaker_out[cfg->speaker_outs].pin = nid; 255 speaker_out[cfg->speaker_outs].pin = nid;
244 speaker_out[cfg->speaker_outs].seq = (assoc << 4) | seq; 256 speaker_out[cfg->speaker_outs].seq = (assoc << 4) | seq;
245 cfg->speaker_outs++; 257 cfg->speaker_outs++;
@@ -247,8 +259,12 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
247 case AC_JACK_HP_OUT: 259 case AC_JACK_HP_OUT:
248 seq = get_defcfg_sequence(def_conf); 260 seq = get_defcfg_sequence(def_conf);
249 assoc = get_defcfg_association(def_conf); 261 assoc = get_defcfg_association(def_conf);
250 if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) 262 if (cfg->hp_outs >= ARRAY_SIZE(cfg->hp_pins)) {
263 codec_info(codec,
264 "ignore pin 0x%x, too many assigned pins\n",
265 nid);
251 continue; 266 continue;
267 }
252 hp_out[cfg->hp_outs].pin = nid; 268 hp_out[cfg->hp_outs].pin = nid;
253 hp_out[cfg->hp_outs].seq = (assoc << 4) | seq; 269 hp_out[cfg->hp_outs].seq = (assoc << 4) | seq;
254 cfg->hp_outs++; 270 cfg->hp_outs++;
@@ -267,8 +283,12 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
267 break; 283 break;
268 case AC_JACK_SPDIF_OUT: 284 case AC_JACK_SPDIF_OUT:
269 case AC_JACK_DIG_OTHER_OUT: 285 case AC_JACK_DIG_OTHER_OUT:
270 if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins)) 286 if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins)) {
287 codec_info(codec,
288 "ignore pin 0x%x, too many assigned pins\n",
289 nid);
271 continue; 290 continue;
291 }
272 cfg->dig_out_pins[cfg->dig_outs] = nid; 292 cfg->dig_out_pins[cfg->dig_outs] = nid;
273 cfg->dig_out_type[cfg->dig_outs] = 293 cfg->dig_out_type[cfg->dig_outs] =
274 (loc == AC_JACK_LOC_HDMI) ? 294 (loc == AC_JACK_LOC_HDMI) ?
@@ -313,9 +333,9 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
313 } 333 }
314 334
315 if (hsmic) 335 if (hsmic)
316 snd_printdd("Told to look for a headset mic, but didn't find any.\n"); 336 codec_dbg(codec, "Told to look for a headset mic, but didn't find any.\n");
317 if (hpmic) 337 if (hpmic)
318 snd_printdd("Told to look for a headphone mic, but didn't find any.\n"); 338 codec_dbg(codec, "Told to look for a headphone mic, but didn't find any.\n");
319 } 339 }
320 340
321 /* FIX-UP: 341 /* FIX-UP:
@@ -384,33 +404,33 @@ int snd_hda_parse_pin_defcfg(struct hda_codec *codec,
384 /* 404 /*
385 * debug prints of the parsed results 405 * debug prints of the parsed results
386 */ 406 */
387 snd_printd("autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n", 407 codec_info(codec, "autoconfig: line_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x) type:%s\n",
388 cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1], 408 cfg->line_outs, cfg->line_out_pins[0], cfg->line_out_pins[1],
389 cfg->line_out_pins[2], cfg->line_out_pins[3], 409 cfg->line_out_pins[2], cfg->line_out_pins[3],
390 cfg->line_out_pins[4], 410 cfg->line_out_pins[4],
391 cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" : 411 cfg->line_out_type == AUTO_PIN_HP_OUT ? "hp" :
392 (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ? 412 (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT ?
393 "speaker" : "line")); 413 "speaker" : "line"));
394 snd_printd(" speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", 414 codec_info(codec, " speaker_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
395 cfg->speaker_outs, cfg->speaker_pins[0], 415 cfg->speaker_outs, cfg->speaker_pins[0],
396 cfg->speaker_pins[1], cfg->speaker_pins[2], 416 cfg->speaker_pins[1], cfg->speaker_pins[2],
397 cfg->speaker_pins[3], cfg->speaker_pins[4]); 417 cfg->speaker_pins[3], cfg->speaker_pins[4]);
398 snd_printd(" hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", 418 codec_info(codec, " hp_outs=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
399 cfg->hp_outs, cfg->hp_pins[0], 419 cfg->hp_outs, cfg->hp_pins[0],
400 cfg->hp_pins[1], cfg->hp_pins[2], 420 cfg->hp_pins[1], cfg->hp_pins[2],
401 cfg->hp_pins[3], cfg->hp_pins[4]); 421 cfg->hp_pins[3], cfg->hp_pins[4]);
402 snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin); 422 codec_info(codec, " mono: mono_out=0x%x\n", cfg->mono_out_pin);
403 if (cfg->dig_outs) 423 if (cfg->dig_outs)
404 snd_printd(" dig-out=0x%x/0x%x\n", 424 codec_info(codec, " dig-out=0x%x/0x%x\n",
405 cfg->dig_out_pins[0], cfg->dig_out_pins[1]); 425 cfg->dig_out_pins[0], cfg->dig_out_pins[1]);
406 snd_printd(" inputs:\n"); 426 codec_info(codec, " inputs:\n");
407 for (i = 0; i < cfg->num_inputs; i++) { 427 for (i = 0; i < cfg->num_inputs; i++) {
408 snd_printd(" %s=0x%x\n", 428 codec_info(codec, " %s=0x%x\n",
409 hda_get_autocfg_input_label(codec, cfg, i), 429 hda_get_autocfg_input_label(codec, cfg, i),
410 cfg->inputs[i].pin); 430 cfg->inputs[i].pin);
411 } 431 }
412 if (cfg->dig_in_pin) 432 if (cfg->dig_in_pin)
413 snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin); 433 codec_info(codec, " dig-in=0x%x\n", cfg->dig_in_pin);
414 434
415 return 0; 435 return 0;
416} 436}
@@ -774,38 +794,33 @@ static void apply_fixup(struct hda_codec *codec, int id, int action, int depth)
774 case HDA_FIXUP_PINS: 794 case HDA_FIXUP_PINS:
775 if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins) 795 if (action != HDA_FIXUP_ACT_PRE_PROBE || !fix->v.pins)
776 break; 796 break;
777 snd_printdd(KERN_INFO SFX 797 codec_dbg(codec, "%s: Apply pincfg for %s\n",
778 "%s: Apply pincfg for %s\n",
779 codec->chip_name, modelname); 798 codec->chip_name, modelname);
780 snd_hda_apply_pincfgs(codec, fix->v.pins); 799 snd_hda_apply_pincfgs(codec, fix->v.pins);
781 break; 800 break;
782 case HDA_FIXUP_VERBS: 801 case HDA_FIXUP_VERBS:
783 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs) 802 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.verbs)
784 break; 803 break;
785 snd_printdd(KERN_INFO SFX 804 codec_dbg(codec, "%s: Apply fix-verbs for %s\n",
786 "%s: Apply fix-verbs for %s\n",
787 codec->chip_name, modelname); 805 codec->chip_name, modelname);
788 snd_hda_add_verbs(codec, fix->v.verbs); 806 snd_hda_add_verbs(codec, fix->v.verbs);
789 break; 807 break;
790 case HDA_FIXUP_FUNC: 808 case HDA_FIXUP_FUNC:
791 if (!fix->v.func) 809 if (!fix->v.func)
792 break; 810 break;
793 snd_printdd(KERN_INFO SFX 811 codec_dbg(codec, "%s: Apply fix-func for %s\n",
794 "%s: Apply fix-func for %s\n",
795 codec->chip_name, modelname); 812 codec->chip_name, modelname);
796 fix->v.func(codec, fix, action); 813 fix->v.func(codec, fix, action);
797 break; 814 break;
798 case HDA_FIXUP_PINCTLS: 815 case HDA_FIXUP_PINCTLS:
799 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins) 816 if (action != HDA_FIXUP_ACT_PROBE || !fix->v.pins)
800 break; 817 break;
801 snd_printdd(KERN_INFO SFX 818 codec_dbg(codec, "%s: Apply pinctl for %s\n",
802 "%s: Apply pinctl for %s\n",
803 codec->chip_name, modelname); 819 codec->chip_name, modelname);
804 set_pin_targets(codec, fix->v.pins); 820 set_pin_targets(codec, fix->v.pins);
805 break; 821 break;
806 default: 822 default:
807 snd_printk(KERN_ERR SFX 823 codec_err(codec, "%s: Invalid fixup type %d\n",
808 "%s: Invalid fixup type %d\n",
809 codec->chip_name, fix->type); 824 codec->chip_name, fix->type);
810 break; 825 break;
811 } 826 }
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 0589b39cda6e..8c6c50afc0b7 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/pci.h>
24#include <linux/slab.h> 23#include <linux/slab.h>
25#include <linux/workqueue.h> 24#include <linux/workqueue.h>
26#include <linux/export.h> 25#include <linux/export.h>
@@ -140,7 +139,10 @@ static void turn_off_beep(struct hda_beep *beep)
140 139
141static void snd_hda_do_detach(struct hda_beep *beep) 140static void snd_hda_do_detach(struct hda_beep *beep)
142{ 141{
143 input_unregister_device(beep->dev); 142 if (beep->registered)
143 input_unregister_device(beep->dev);
144 else
145 input_free_device(beep->dev);
144 beep->dev = NULL; 146 beep->dev = NULL;
145 turn_off_beep(beep); 147 turn_off_beep(beep);
146} 148}
@@ -149,7 +151,6 @@ static int snd_hda_do_attach(struct hda_beep *beep)
149{ 151{
150 struct input_dev *input_dev; 152 struct input_dev *input_dev;
151 struct hda_codec *codec = beep->codec; 153 struct hda_codec *codec = beep->codec;
152 int err;
153 154
154 input_dev = input_allocate_device(); 155 input_dev = input_allocate_device();
155 if (!input_dev) 156 if (!input_dev)
@@ -167,15 +168,9 @@ static int snd_hda_do_attach(struct hda_beep *beep)
167 input_dev->evbit[0] = BIT_MASK(EV_SND); 168 input_dev->evbit[0] = BIT_MASK(EV_SND);
168 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); 169 input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
169 input_dev->event = snd_hda_beep_event; 170 input_dev->event = snd_hda_beep_event;
170 input_dev->dev.parent = &codec->bus->pci->dev; 171 input_dev->dev.parent = &codec->dev;
171 input_set_drvdata(input_dev, beep); 172 input_set_drvdata(input_dev, beep);
172 173
173 err = input_register_device(input_dev);
174 if (err < 0) {
175 input_free_device(input_dev);
176 printk(KERN_INFO "hda_beep: unable to register input device\n");
177 return err;
178 }
179 beep->dev = input_dev; 174 beep->dev = input_dev;
180 return 0; 175 return 0;
181} 176}
@@ -245,6 +240,27 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
245} 240}
246EXPORT_SYMBOL_GPL(snd_hda_detach_beep_device); 241EXPORT_SYMBOL_GPL(snd_hda_detach_beep_device);
247 242
243int snd_hda_register_beep_device(struct hda_codec *codec)
244{
245 struct hda_beep *beep = codec->beep;
246 int err;
247
248 if (!beep || !beep->dev)
249 return 0;
250
251 err = input_register_device(beep->dev);
252 if (err < 0) {
253 codec_err(codec, "hda_beep: unable to register input device\n");
254 input_free_device(beep->dev);
255 codec->beep = NULL;
256 kfree(beep);
257 return err;
258 }
259 beep->registered = true;
260 return 0;
261}
262EXPORT_SYMBOL_GPL(snd_hda_register_beep_device);
263
248static bool ctl_has_mute(struct snd_kcontrol *kcontrol) 264static bool ctl_has_mute(struct snd_kcontrol *kcontrol)
249{ 265{
250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 266 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h
index cb88464676b6..a63b5e077332 100644
--- a/sound/pci/hda/hda_beep.h
+++ b/sound/pci/hda/hda_beep.h
@@ -34,6 +34,7 @@ struct hda_beep {
34 char phys[32]; 34 char phys[32];
35 int tone; 35 int tone;
36 hda_nid_t nid; 36 hda_nid_t nid;
37 unsigned int registered:1;
37 unsigned int enabled:1; 38 unsigned int enabled:1;
38 unsigned int linear_tone:1; /* linear tone for IDT/STAC codec */ 39 unsigned int linear_tone:1; /* linear tone for IDT/STAC codec */
39 unsigned int playing:1; 40 unsigned int playing:1;
@@ -45,6 +46,7 @@ struct hda_beep {
45int snd_hda_enable_beep_device(struct hda_codec *codec, int enable); 46int snd_hda_enable_beep_device(struct hda_codec *codec, int enable);
46int snd_hda_attach_beep_device(struct hda_codec *codec, int nid); 47int snd_hda_attach_beep_device(struct hda_codec *codec, int nid);
47void snd_hda_detach_beep_device(struct hda_codec *codec); 48void snd_hda_detach_beep_device(struct hda_codec *codec);
49int snd_hda_register_beep_device(struct hda_codec *codec);
48#else 50#else
49static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) 51static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
50{ 52{
@@ -53,5 +55,9 @@ static inline int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
53static inline void snd_hda_detach_beep_device(struct hda_codec *codec) 55static inline void snd_hda_detach_beep_device(struct hda_codec *codec)
54{ 56{
55} 57}
58static inline int snd_hda_register_beep_device(struct hda_codec *codec)
59{
60 return 0;
61}
56#endif 62#endif
57#endif 63#endif
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index dafcf82139e2..4c20277a6835 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -23,7 +23,6 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h>
27#include <linux/mutex.h> 26#include <linux/mutex.h>
28#include <linux/module.h> 27#include <linux/module.h>
29#include <linux/async.h> 28#include <linux/async.h>
@@ -68,6 +67,7 @@ static struct hda_vendor_id hda_vendor_ids[] = {
68 { 0x17e8, "Chrontel" }, 67 { 0x17e8, "Chrontel" },
69 { 0x1854, "LG" }, 68 { 0x1854, "LG" },
70 { 0x1aec, "Wolfson Microelectronics" }, 69 { 0x1aec, "Wolfson Microelectronics" },
70 { 0x1af4, "QEMU" },
71 { 0x434d, "C-Media" }, 71 { 0x434d, "C-Media" },
72 { 0x8086, "Intel" }, 72 { 0x8086, "Intel" },
73 { 0x8384, "SigmaTel" }, 73 { 0x8384, "SigmaTel" },
@@ -201,7 +201,7 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int flags,
201 201
202 if ((codec->addr & ~0xf) || (nid & ~0x7f) || 202 if ((codec->addr & ~0xf) || (nid & ~0x7f) ||
203 (verb & ~0xfff) || (parm & ~0xffff)) { 203 (verb & ~0xfff) || (parm & ~0xffff)) {
204 printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x\n", 204 codec_err(codec, "hda-codec: out of range cmd %x:%x:%x:%x\n",
205 codec->addr, nid, verb, parm); 205 codec->addr, nid, verb, parm);
206 return ~0; 206 return ~0;
207 } 207 }
@@ -249,8 +249,8 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
249 snd_hda_power_down(codec); 249 snd_hda_power_down(codec);
250 if (!codec_in_pm(codec) && res && *res == -1 && bus->rirb_error) { 250 if (!codec_in_pm(codec) && res && *res == -1 && bus->rirb_error) {
251 if (bus->response_reset) { 251 if (bus->response_reset) {
252 snd_printd("hda_codec: resetting BUS due to " 252 codec_dbg(codec,
253 "fatal communication error\n"); 253 "resetting BUS due to fatal communication error\n");
254 trace_hda_bus_reset(bus); 254 trace_hda_bus_reset(bus);
255 bus->ops.bus_reset(bus); 255 bus->ops.bus_reset(bus);
256 } 256 }
@@ -475,8 +475,7 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
475 475
476 if (len > 0 && conn_list) { 476 if (len > 0 && conn_list) {
477 if (len > max_conns) { 477 if (len > max_conns) {
478 snd_printk(KERN_ERR "hda_codec: " 478 codec_err(codec, "Too many connections %d for NID 0x%x\n",
479 "Too many connections %d for NID 0x%x\n",
480 len, nid); 479 len, nid);
481 return -EINVAL; 480 return -EINVAL;
482 } 481 }
@@ -574,8 +573,8 @@ int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid,
574 range_val = !!(parm & (1 << (shift-1))); /* ranges */ 573 range_val = !!(parm & (1 << (shift-1))); /* ranges */
575 val = parm & mask; 574 val = parm & mask;
576 if (val == 0 && null_count++) { /* no second chance */ 575 if (val == 0 && null_count++) { /* no second chance */
577 snd_printdd("hda_codec: " 576 codec_dbg(codec,
578 "invalid CONNECT_LIST verb %x[%i]:%x\n", 577 "invalid CONNECT_LIST verb %x[%i]:%x\n",
579 nid, i, parm); 578 nid, i, parm);
580 return 0; 579 return 0;
581 } 580 }
@@ -583,7 +582,7 @@ int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid,
583 if (range_val) { 582 if (range_val) {
584 /* ranges between the previous and this one */ 583 /* ranges between the previous and this one */
585 if (!prev_nid || prev_nid >= val) { 584 if (!prev_nid || prev_nid >= val) {
586 snd_printk(KERN_WARNING "hda_codec: " 585 codec_warn(codec,
587 "invalid dep_range_val %x:%x\n", 586 "invalid dep_range_val %x:%x\n",
588 prev_nid, val); 587 prev_nid, val);
589 continue; 588 continue;
@@ -660,7 +659,7 @@ int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
660 if (!recursive) 659 if (!recursive)
661 return -1; 660 return -1;
662 if (recursive > 10) { 661 if (recursive > 10) {
663 snd_printd("hda_codec: too deep connection for 0x%x\n", nid); 662 codec_dbg(codec, "too deep connection for 0x%x\n", nid);
664 return -1; 663 return -1;
665 } 664 }
666 recursive++; 665 recursive++;
@@ -808,8 +807,7 @@ static int init_unsol_queue(struct hda_bus *bus)
808 807
809 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); 808 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
810 if (!unsol) { 809 if (!unsol) {
811 snd_printk(KERN_ERR "hda_codec: " 810 dev_err(bus->card->dev, "can't allocate unsolicited queue\n");
812 "can't allocate unsolicited queue\n");
813 return -ENOMEM; 811 return -ENOMEM;
814 } 812 }
815 INIT_WORK(&unsol->work, process_unsol_events); 813 INIT_WORK(&unsol->work, process_unsol_events);
@@ -821,51 +819,36 @@ static int init_unsol_queue(struct hda_bus *bus)
821/* 819/*
822 * destructor 820 * destructor
823 */ 821 */
824static void snd_hda_codec_free(struct hda_codec *codec); 822static void snd_hda_bus_free(struct hda_bus *bus)
825
826static int snd_hda_bus_free(struct hda_bus *bus)
827{ 823{
828 struct hda_codec *codec, *n;
829
830 if (!bus) 824 if (!bus)
831 return 0; 825 return;
826
827 WARN_ON(!list_empty(&bus->codec_list));
832 if (bus->workq) 828 if (bus->workq)
833 flush_workqueue(bus->workq); 829 flush_workqueue(bus->workq);
834 if (bus->unsol) 830 if (bus->unsol)
835 kfree(bus->unsol); 831 kfree(bus->unsol);
836 list_for_each_entry_safe(codec, n, &bus->codec_list, list) {
837 snd_hda_codec_free(codec);
838 }
839 if (bus->ops.private_free) 832 if (bus->ops.private_free)
840 bus->ops.private_free(bus); 833 bus->ops.private_free(bus);
841 if (bus->workq) 834 if (bus->workq)
842 destroy_workqueue(bus->workq); 835 destroy_workqueue(bus->workq);
843 836
844 kfree(bus); 837 kfree(bus);
845 return 0;
846} 838}
847 839
848static int snd_hda_bus_dev_free(struct snd_device *device) 840static int snd_hda_bus_dev_free(struct snd_device *device)
849{ 841{
850 struct hda_bus *bus = device->device_data; 842 snd_hda_bus_free(device->device_data);
851 bus->shutdown = 1; 843 return 0;
852 return snd_hda_bus_free(bus);
853} 844}
854 845
855#ifdef CONFIG_SND_HDA_HWDEP 846static int snd_hda_bus_dev_disconnect(struct snd_device *device)
856static int snd_hda_bus_dev_register(struct snd_device *device)
857{ 847{
858 struct hda_bus *bus = device->device_data; 848 struct hda_bus *bus = device->device_data;
859 struct hda_codec *codec; 849 bus->shutdown = 1;
860 list_for_each_entry(codec, &bus->codec_list, list) {
861 snd_hda_hwdep_add_sysfs(codec);
862 snd_hda_hwdep_add_power_sysfs(codec);
863 }
864 return 0; 850 return 0;
865} 851}
866#else
867#define snd_hda_bus_dev_register NULL
868#endif
869 852
870/** 853/**
871 * snd_hda_bus_new - create a HDA bus 854 * snd_hda_bus_new - create a HDA bus
@@ -882,7 +865,7 @@ int snd_hda_bus_new(struct snd_card *card,
882 struct hda_bus *bus; 865 struct hda_bus *bus;
883 int err; 866 int err;
884 static struct snd_device_ops dev_ops = { 867 static struct snd_device_ops dev_ops = {
885 .dev_register = snd_hda_bus_dev_register, 868 .dev_disconnect = snd_hda_bus_dev_disconnect,
886 .dev_free = snd_hda_bus_dev_free, 869 .dev_free = snd_hda_bus_dev_free,
887 }; 870 };
888 871
@@ -896,7 +879,7 @@ int snd_hda_bus_new(struct snd_card *card,
896 879
897 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 880 bus = kzalloc(sizeof(*bus), GFP_KERNEL);
898 if (bus == NULL) { 881 if (bus == NULL) {
899 snd_printk(KERN_ERR "can't allocate struct hda_bus\n"); 882 dev_err(card->dev, "can't allocate struct hda_bus\n");
900 return -ENOMEM; 883 return -ENOMEM;
901 } 884 }
902 885
@@ -915,7 +898,7 @@ int snd_hda_bus_new(struct snd_card *card,
915 "hd-audio%d", card->number); 898 "hd-audio%d", card->number);
916 bus->workq = create_singlethread_workqueue(bus->workq_name); 899 bus->workq = create_singlethread_workqueue(bus->workq_name);
917 if (!bus->workq) { 900 if (!bus->workq) {
918 snd_printk(KERN_ERR "cannot create workqueue %s\n", 901 dev_err(card->dev, "cannot create workqueue %s\n",
919 bus->workq_name); 902 bus->workq_name);
920 kfree(bus); 903 kfree(bus);
921 return -ENOMEM; 904 return -ENOMEM;
@@ -959,7 +942,7 @@ find_codec_preset(struct hda_codec *codec)
959 mutex_lock(&preset_mutex); 942 mutex_lock(&preset_mutex);
960 list_for_each_entry(tbl, &hda_preset_tables, list) { 943 list_for_each_entry(tbl, &hda_preset_tables, list) {
961 if (!try_module_get(tbl->owner)) { 944 if (!try_module_get(tbl->owner)) {
962 snd_printk(KERN_ERR "hda_codec: cannot module_get\n"); 945 codec_err(codec, "cannot module_get\n");
963 continue; 946 continue;
964 } 947 }
965 for (preset = tbl->preset; preset->id; preset++) { 948 for (preset = tbl->preset; preset->id; preset++) {
@@ -1185,7 +1168,7 @@ unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid)
1185{ 1168{
1186 struct hda_pincfg *pin; 1169 struct hda_pincfg *pin;
1187 1170
1188#ifdef CONFIG_SND_HDA_HWDEP 1171#ifdef CONFIG_SND_HDA_RECONFIG
1189 { 1172 {
1190 unsigned int cfg = 0; 1173 unsigned int cfg = 0;
1191 mutex_lock(&codec->user_mutex); 1174 mutex_lock(&codec->user_mutex);
@@ -1300,7 +1283,7 @@ static void free_hda_cache(struct hda_cache_rec *cache);
1300static void free_init_pincfgs(struct hda_codec *codec) 1283static void free_init_pincfgs(struct hda_codec *codec)
1301{ 1284{
1302 snd_array_free(&codec->driver_pins); 1285 snd_array_free(&codec->driver_pins);
1303#ifdef CONFIG_SND_HDA_HWDEP 1286#ifdef CONFIG_SND_HDA_RECONFIG
1304 snd_array_free(&codec->user_pins); 1287 snd_array_free(&codec->user_pins);
1305#endif 1288#endif
1306 snd_array_free(&codec->init_pins); 1289 snd_array_free(&codec->init_pins);
@@ -1374,6 +1357,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
1374 if (codec->patch_ops.free) 1357 if (codec->patch_ops.free)
1375 codec->patch_ops.free(codec); 1358 codec->patch_ops.free(codec);
1376 hda_call_pm_notify(codec, false); /* cancel leftover refcounts */ 1359 hda_call_pm_notify(codec, false); /* cancel leftover refcounts */
1360 snd_hda_sysfs_clear(codec);
1377 unload_parser(codec); 1361 unload_parser(codec);
1378 module_put(codec->owner); 1362 module_put(codec->owner);
1379 free_hda_cache(&codec->amp_cache); 1363 free_hda_cache(&codec->amp_cache);
@@ -1383,7 +1367,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
1383 kfree(codec->modelname); 1367 kfree(codec->modelname);
1384 kfree(codec->wcaps); 1368 kfree(codec->wcaps);
1385 codec->bus->num_codecs--; 1369 codec->bus->num_codecs--;
1386 kfree(codec); 1370 put_device(&codec->dev);
1387} 1371}
1388 1372
1389static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec, 1373static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
@@ -1392,6 +1376,38 @@ static bool snd_hda_codec_get_supported_ps(struct hda_codec *codec,
1392static unsigned int hda_set_power_state(struct hda_codec *codec, 1376static unsigned int hda_set_power_state(struct hda_codec *codec,
1393 unsigned int power_state); 1377 unsigned int power_state);
1394 1378
1379static int snd_hda_codec_dev_register(struct snd_device *device)
1380{
1381 struct hda_codec *codec = device->device_data;
1382 int err = device_add(&codec->dev);
1383
1384 if (err < 0)
1385 return err;
1386 snd_hda_register_beep_device(codec);
1387 return 0;
1388}
1389
1390static int snd_hda_codec_dev_disconnect(struct snd_device *device)
1391{
1392 struct hda_codec *codec = device->device_data;
1393
1394 snd_hda_detach_beep_device(codec);
1395 device_del(&codec->dev);
1396 return 0;
1397}
1398
1399static int snd_hda_codec_dev_free(struct snd_device *device)
1400{
1401 snd_hda_codec_free(device->device_data);
1402 return 0;
1403}
1404
1405/* just free the container */
1406static void snd_hda_codec_dev_release(struct device *dev)
1407{
1408 kfree(container_of(dev, struct hda_codec, dev));
1409}
1410
1395/** 1411/**
1396 * snd_hda_codec_new - create a HDA codec 1412 * snd_hda_codec_new - create a HDA codec
1397 * @bus: the bus to assign 1413 * @bus: the bus to assign
@@ -1408,6 +1424,11 @@ int snd_hda_codec_new(struct hda_bus *bus,
1408 char component[31]; 1424 char component[31];
1409 hda_nid_t fg; 1425 hda_nid_t fg;
1410 int err; 1426 int err;
1427 static struct snd_device_ops dev_ops = {
1428 .dev_register = snd_hda_codec_dev_register,
1429 .dev_disconnect = snd_hda_codec_dev_disconnect,
1430 .dev_free = snd_hda_codec_dev_free,
1431 };
1411 1432
1412 if (snd_BUG_ON(!bus)) 1433 if (snd_BUG_ON(!bus))
1413 return -EINVAL; 1434 return -EINVAL;
@@ -1415,17 +1436,27 @@ int snd_hda_codec_new(struct hda_bus *bus,
1415 return -EINVAL; 1436 return -EINVAL;
1416 1437
1417 if (bus->caddr_tbl[codec_addr]) { 1438 if (bus->caddr_tbl[codec_addr]) {
1418 snd_printk(KERN_ERR "hda_codec: " 1439 dev_err(bus->card->dev,
1419 "address 0x%x is already occupied\n", codec_addr); 1440 "address 0x%x is already occupied\n",
1441 codec_addr);
1420 return -EBUSY; 1442 return -EBUSY;
1421 } 1443 }
1422 1444
1423 codec = kzalloc(sizeof(*codec), GFP_KERNEL); 1445 codec = kzalloc(sizeof(*codec), GFP_KERNEL);
1424 if (codec == NULL) { 1446 if (codec == NULL) {
1425 snd_printk(KERN_ERR "can't allocate struct hda_codec\n"); 1447 dev_err(bus->card->dev, "can't allocate struct hda_codec\n");
1426 return -ENOMEM; 1448 return -ENOMEM;
1427 } 1449 }
1428 1450
1451 device_initialize(&codec->dev);
1452 codec->dev.parent = &bus->card->card_dev;
1453 codec->dev.class = sound_class;
1454 codec->dev.release = snd_hda_codec_dev_release;
1455 codec->dev.groups = snd_hda_dev_attr_groups;
1456 dev_set_name(&codec->dev, "hdaudioC%dD%d", bus->card->number,
1457 codec_addr);
1458 dev_set_drvdata(&codec->dev, codec); /* for sysfs */
1459
1429 codec->bus = bus; 1460 codec->bus = bus;
1430 codec->addr = codec_addr; 1461 codec->addr = codec_addr;
1431 mutex_init(&codec->spdif_mutex); 1462 mutex_init(&codec->spdif_mutex);
@@ -1456,11 +1487,13 @@ int snd_hda_codec_new(struct hda_bus *bus,
1456 hda_keep_power_on(codec); 1487 hda_keep_power_on(codec);
1457#endif 1488#endif
1458 1489
1490 snd_hda_sysfs_init(codec);
1491
1459 if (codec->bus->modelname) { 1492 if (codec->bus->modelname) {
1460 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); 1493 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
1461 if (!codec->modelname) { 1494 if (!codec->modelname) {
1462 snd_hda_codec_free(codec); 1495 err = -ENODEV;
1463 return -ENODEV; 1496 goto error;
1464 } 1497 }
1465 } 1498 }
1466 1499
@@ -1484,7 +1517,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
1484 1517
1485 setup_fg_nodes(codec); 1518 setup_fg_nodes(codec);
1486 if (!codec->afg && !codec->mfg) { 1519 if (!codec->afg && !codec->mfg) {
1487 snd_printdd("hda_codec: no AFG or MFG node found\n"); 1520 dev_err(bus->card->dev, "no AFG or MFG node found\n");
1488 err = -ENODEV; 1521 err = -ENODEV;
1489 goto error; 1522 goto error;
1490 } 1523 }
@@ -1492,7 +1525,7 @@ int snd_hda_codec_new(struct hda_bus *bus,
1492 fg = codec->afg ? codec->afg : codec->mfg; 1525 fg = codec->afg ? codec->afg : codec->mfg;
1493 err = read_widget_caps(codec, fg); 1526 err = read_widget_caps(codec, fg);
1494 if (err < 0) { 1527 if (err < 0) {
1495 snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); 1528 dev_err(bus->card->dev, "cannot malloc\n");
1496 goto error; 1529 goto error;
1497 } 1530 }
1498 err = read_pin_defaults(codec); 1531 err = read_pin_defaults(codec);
@@ -1528,6 +1561,10 @@ int snd_hda_codec_new(struct hda_bus *bus,
1528 codec->subsystem_id, codec->revision_id); 1561 codec->subsystem_id, codec->revision_id);
1529 snd_component_add(codec->bus->card, component); 1562 snd_component_add(codec->bus->card, component);
1530 1563
1564 err = snd_device_new(bus->card, SNDRV_DEV_CODEC, codec, &dev_ops);
1565 if (err < 0)
1566 goto error;
1567
1531 if (codecp) 1568 if (codecp)
1532 *codecp = codec; 1569 *codecp = codec;
1533 return 0; 1570 return 0;
@@ -1550,7 +1587,7 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec)
1550 fg = codec->afg ? codec->afg : codec->mfg; 1587 fg = codec->afg ? codec->afg : codec->mfg;
1551 err = read_widget_caps(codec, fg); 1588 err = read_widget_caps(codec, fg);
1552 if (err < 0) { 1589 if (err < 0) {
1553 snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); 1590 codec_err(codec, "cannot malloc\n");
1554 return err; 1591 return err;
1555 } 1592 }
1556 1593
@@ -1627,7 +1664,7 @@ int snd_hda_codec_configure(struct hda_codec *codec)
1627#endif 1664#endif
1628 } 1665 }
1629 if (!patch) { 1666 if (!patch) {
1630 printk(KERN_ERR "hda-codec: No codec parser is available\n"); 1667 codec_err(codec, "No codec parser is available\n");
1631 return -ENODEV; 1668 return -ENODEV;
1632 } 1669 }
1633 } 1670 }
@@ -1711,9 +1748,9 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
1711 if (!nid) 1748 if (!nid)
1712 return; 1749 return;
1713 1750
1714 snd_printdd("hda_codec_setup_stream: " 1751 codec_dbg(codec,
1715 "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", 1752 "hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
1716 nid, stream_tag, channel_id, format); 1753 nid, stream_tag, channel_id, format);
1717 p = get_hda_cvt_setup(codec, nid); 1754 p = get_hda_cvt_setup(codec, nid);
1718 if (!p) 1755 if (!p)
1719 return; 1756 return;
@@ -1760,7 +1797,7 @@ void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
1760 if (codec->no_sticky_stream) 1797 if (codec->no_sticky_stream)
1761 do_now = 1; 1798 do_now = 1;
1762 1799
1763 snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); 1800 codec_dbg(codec, "hda_codec_cleanup_stream: NID=0x%x\n", nid);
1764 p = get_hda_cvt_setup(codec, nid); 1801 p = get_hda_cvt_setup(codec, nid);
1765 if (p) { 1802 if (p) {
1766 /* here we just clear the active flag when do_now isn't set; 1803 /* here we just clear the active flag when do_now isn't set;
@@ -2282,9 +2319,9 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
2282 uinfo->value.integer.min = 0; 2319 uinfo->value.integer.min = 0;
2283 uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs); 2320 uinfo->value.integer.max = get_amp_max_value(codec, nid, dir, ofs);
2284 if (!uinfo->value.integer.max) { 2321 if (!uinfo->value.integer.max) {
2285 printk(KERN_WARNING "hda_codec: " 2322 codec_warn(codec,
2286 "num_steps = 0 for NID=0x%x (ctl = %s)\n", nid, 2323 "num_steps = 0 for NID=0x%x (ctl = %s)\n",
2287 kcontrol->id.name); 2324 nid, kcontrol->id.name);
2288 return -EINVAL; 2325 return -EINVAL;
2289 } 2326 }
2290 return 0; 2327 return 0;
@@ -2558,8 +2595,8 @@ int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl,
2558 item->nid = nid; 2595 item->nid = nid;
2559 return 0; 2596 return 0;
2560 } 2597 }
2561 printk(KERN_ERR "hda-codec: no NID for mapping control %s:%d:%d\n", 2598 codec_err(codec, "no NID for mapping control %s:%d:%d\n",
2562 kctl->id.name, kctl->id.index, index); 2599 kctl->id.name, kctl->id.index, index);
2563 return -EINVAL; 2600 return -EINVAL;
2564} 2601}
2565EXPORT_SYMBOL_GPL(snd_hda_add_nid); 2602EXPORT_SYMBOL_GPL(snd_hda_add_nid);
@@ -2660,6 +2697,7 @@ int snd_hda_codec_reset(struct hda_codec *codec)
2660 bus->pcm_dev_bits); 2697 bus->pcm_dev_bits);
2661 } 2698 }
2662 } 2699 }
2700 snd_hda_detach_beep_device(codec);
2663 if (codec->patch_ops.free) 2701 if (codec->patch_ops.free)
2664 codec->patch_ops.free(codec); 2702 codec->patch_ops.free(codec);
2665 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops)); 2703 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
@@ -2751,7 +2789,7 @@ static int get_kctl_0dB_offset(struct snd_kcontrol *kctl, int *step_to_check)
2751 return -1; 2789 return -1;
2752 if (*step_to_check && *step_to_check != step) { 2790 if (*step_to_check && *step_to_check != step) {
2753 snd_printk(KERN_ERR "hda_codec: Mismatching dB step for vmaster slave (%d!=%d)\n", 2791 snd_printk(KERN_ERR "hda_codec: Mismatching dB step for vmaster slave (%d!=%d)\n",
2754 *step_to_check, step); 2792- *step_to_check, step);
2755 return -1; 2793 return -1;
2756 } 2794 }
2757 *step_to_check = step; 2795 *step_to_check = step;
@@ -2821,7 +2859,7 @@ int __snd_hda_add_vmaster(struct hda_codec *codec, char *name,
2821 2859
2822 err = map_slaves(codec, slaves, suffix, check_slave_present, NULL); 2860 err = map_slaves(codec, slaves, suffix, check_slave_present, NULL);
2823 if (err != 1) { 2861 if (err != 1) {
2824 snd_printdd("No slave found for %s\n", name); 2862 codec_dbg(codec, "No slave found for %s\n", name);
2825 return 0; 2863 return 0;
2826 } 2864 }
2827 kctl = snd_ctl_make_virtual_master(name, tlv); 2865 kctl = snd_ctl_make_virtual_master(name, tlv);
@@ -3487,7 +3525,7 @@ int snd_hda_create_dig_out_ctls(struct hda_codec *codec,
3487 3525
3488 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch", idx); 3526 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch", idx);
3489 if (idx < 0) { 3527 if (idx < 0) {
3490 printk(KERN_ERR "hda_codec: too many IEC958 outputs\n"); 3528 codec_err(codec, "too many IEC958 outputs\n");
3491 return -EBUSY; 3529 return -EBUSY;
3492 } 3530 }
3493 spdif = snd_array_new(&codec->spdif_out); 3531 spdif = snd_array_new(&codec->spdif_out);
@@ -3691,7 +3729,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
3691 3729
3692 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch", 0); 3730 idx = find_empty_mixer_ctl_idx(codec, "IEC958 Capture Switch", 0);
3693 if (idx < 0) { 3731 if (idx < 0) {
3694 printk(KERN_ERR "hda_codec: too many IEC958 inputs\n"); 3732 codec_err(codec, "too many IEC958 inputs\n");
3695 return -EBUSY; 3733 return -EBUSY;
3696 } 3734 }
3697 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 3735 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
@@ -4010,7 +4048,7 @@ static void sync_power_up_states(struct hda_codec *codec)
4010 } 4048 }
4011} 4049}
4012 4050
4013#ifdef CONFIG_SND_HDA_HWDEP 4051#ifdef CONFIG_SND_HDA_RECONFIG
4014/* execute additional init verbs */ 4052/* execute additional init verbs */
4015static void hda_exec_init_verbs(struct hda_codec *codec) 4053static void hda_exec_init_verbs(struct hda_codec *codec)
4016{ 4054{
@@ -4118,12 +4156,13 @@ int snd_hda_build_controls(struct hda_bus *bus)
4118 list_for_each_entry(codec, &bus->codec_list, list) { 4156 list_for_each_entry(codec, &bus->codec_list, list) {
4119 int err = snd_hda_codec_build_controls(codec); 4157 int err = snd_hda_codec_build_controls(codec);
4120 if (err < 0) { 4158 if (err < 0) {
4121 printk(KERN_ERR "hda_codec: cannot build controls " 4159 codec_err(codec,
4122 "for #%d (error %d)\n", codec->addr, err); 4160 "cannot build controls for #%d (error %d)\n",
4161 codec->addr, err);
4123 err = snd_hda_codec_reset(codec); 4162 err = snd_hda_codec_reset(codec);
4124 if (err < 0) { 4163 if (err < 0) {
4125 printk(KERN_ERR 4164 codec_err(codec,
4126 "hda_codec: cannot revert codec\n"); 4165 "cannot revert codec\n");
4127 return err; 4166 return err;
4128 } 4167 }
4129 } 4168 }
@@ -4294,7 +4333,7 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
4294 break; 4333 break;
4295 default: 4334 default:
4296 snd_printdd("invalid format width %d\n", 4335 snd_printdd("invalid format width %d\n",
4297 snd_pcm_format_width(format)); 4336 snd_pcm_format_width(format));
4298 return 0; 4337 return 0;
4299 } 4338 }
4300 4339
@@ -4370,10 +4409,10 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
4370 rates |= rate_bits[i].alsa_bits; 4409 rates |= rate_bits[i].alsa_bits;
4371 } 4410 }
4372 if (rates == 0) { 4411 if (rates == 0) {
4373 snd_printk(KERN_ERR "hda_codec: rates == 0 " 4412 codec_err(codec,
4374 "(nid=0x%x, val=0x%x, ovrd=%i)\n", 4413 "rates == 0 (nid=0x%x, val=0x%x, ovrd=%i)\n",
4375 nid, val, 4414 nid, val,
4376 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0); 4415 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0);
4377 return -EIO; 4416 return -EIO;
4378 } 4417 }
4379 *ratesp = rates; 4418 *ratesp = rates;
@@ -4433,12 +4472,11 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
4433 bps = 8; 4472 bps = 8;
4434 } 4473 }
4435 if (formats == 0) { 4474 if (formats == 0) {
4436 snd_printk(KERN_ERR "hda_codec: formats == 0 " 4475 codec_err(codec,
4437 "(nid=0x%x, val=0x%x, ovrd=%i, " 4476 "formats == 0 (nid=0x%x, val=0x%x, ovrd=%i, streams=0x%x)\n",
4438 "streams=0x%x)\n", 4477 nid, val,
4439 nid, val, 4478 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0,
4440 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0, 4479 streams);
4441 streams);
4442 return -EIO; 4480 return -EIO;
4443 } 4481 }
4444 if (formatsp) 4482 if (formatsp)
@@ -4629,7 +4667,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
4629 int i; 4667 int i;
4630 4668
4631 if (type >= HDA_PCM_NTYPES) { 4669 if (type >= HDA_PCM_NTYPES) {
4632 snd_printk(KERN_WARNING "Invalid PCM type %d\n", type); 4670 dev_err(bus->card->dev, "Invalid PCM type %d\n", type);
4633 return -EINVAL; 4671 return -EINVAL;
4634 } 4672 }
4635 4673
@@ -4650,10 +4688,11 @@ static int get_empty_pcm_device(struct hda_bus *bus, unsigned int type)
4650 } 4688 }
4651#endif 4689#endif
4652 4690
4653 snd_printk(KERN_WARNING "Too many %s devices\n", 4691 dev_warn(bus->card->dev, "Too many %s devices\n",
4654 snd_hda_pcm_type_name[type]); 4692 snd_hda_pcm_type_name[type]);
4655#ifndef CONFIG_SND_DYNAMIC_MINORS 4693#ifndef CONFIG_SND_DYNAMIC_MINORS
4656 snd_printk(KERN_WARNING "Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y\n"); 4694 dev_warn(bus->card->dev,
4695 "Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y\n");
4657#endif 4696#endif
4658 return -EAGAIN; 4697 return -EAGAIN;
4659} 4698}
@@ -4691,12 +4730,13 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
4691 return 0; 4730 return 0;
4692 err = codec->patch_ops.build_pcms(codec); 4731 err = codec->patch_ops.build_pcms(codec);
4693 if (err < 0) { 4732 if (err < 0) {
4694 printk(KERN_ERR "hda_codec: cannot build PCMs" 4733 codec_err(codec,
4695 "for #%d (error %d)\n", codec->addr, err); 4734 "cannot build PCMs for #%d (error %d)\n",
4735 codec->addr, err);
4696 err = snd_hda_codec_reset(codec); 4736 err = snd_hda_codec_reset(codec);
4697 if (err < 0) { 4737 if (err < 0) {
4698 printk(KERN_ERR 4738 codec_err(codec,
4699 "hda_codec: cannot revert codec\n"); 4739 "cannot revert codec\n");
4700 return err; 4740 return err;
4701 } 4741 }
4702 } 4742 }
@@ -4715,9 +4755,9 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
4715 cpcm->device = dev; 4755 cpcm->device = dev;
4716 err = snd_hda_attach_pcm(codec, cpcm); 4756 err = snd_hda_attach_pcm(codec, cpcm);
4717 if (err < 0) { 4757 if (err < 0) {
4718 printk(KERN_ERR "hda_codec: cannot attach " 4758 codec_err(codec,
4719 "PCM stream %d for codec #%d\n", 4759 "cannot attach PCM stream %d for codec #%d\n",
4720 dev, codec->addr); 4760 dev, codec->addr);
4721 continue; /* no fatal error */ 4761 continue; /* no fatal error */
4722 } 4762 }
4723 } 4763 }
@@ -4786,8 +4826,8 @@ int snd_hda_check_board_config(struct hda_codec *codec,
4786 for (i = 0; i < num_configs; i++) { 4826 for (i = 0; i < num_configs; i++) {
4787 if (models[i] && 4827 if (models[i] &&
4788 !strcmp(codec->modelname, models[i])) { 4828 !strcmp(codec->modelname, models[i])) {
4789 snd_printd(KERN_INFO "hda_codec: model '%s' is " 4829 codec_info(codec, "model '%s' is selected\n",
4790 "selected\n", models[i]); 4830 models[i]);
4791 return i; 4831 return i;
4792 } 4832 }
4793 } 4833 }
@@ -4809,10 +4849,9 @@ int snd_hda_check_board_config(struct hda_codec *codec,
4809 sprintf(tmp, "#%d", tbl->value); 4849 sprintf(tmp, "#%d", tbl->value);
4810 model = tmp; 4850 model = tmp;
4811 } 4851 }
4812 snd_printdd(KERN_INFO "hda_codec: model '%s' is selected " 4852 codec_info(codec, "model '%s' is selected for config %x:%x (%s)\n",
4813 "for config %x:%x (%s)\n", 4853 model, tbl->subvendor, tbl->subdevice,
4814 model, tbl->subvendor, tbl->subdevice, 4854 (tbl->name ? tbl->name : "Unknown device"));
4815 (tbl->name ? tbl->name : "Unknown device"));
4816#endif 4855#endif
4817 return tbl->value; 4856 return tbl->value;
4818 } 4857 }
@@ -4870,10 +4909,9 @@ int snd_hda_check_board_codec_sid_config(struct hda_codec *codec,
4870 sprintf(tmp, "#%d", tbl->value); 4909 sprintf(tmp, "#%d", tbl->value);
4871 model = tmp; 4910 model = tmp;
4872 } 4911 }
4873 snd_printdd(KERN_INFO "hda_codec: model '%s' is selected " 4912 codec_info(codec, "model '%s' is selected for config %x:%x (%s)\n",
4874 "for config %x:%x (%s)\n", 4913 model, tbl->subvendor, tbl->subdevice,
4875 model, tbl->subvendor, tbl->subdevice, 4914 (tbl->name ? tbl->name : "Unknown device"));
4876 (tbl->name ? tbl->name : "Unknown device"));
4877#endif 4915#endif
4878 return tbl->value; 4916 return tbl->value;
4879 } 4917 }
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index ab2a444ba501..a4233136cb93 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -271,6 +271,7 @@ struct hda_pcm {
271 271
272/* codec information */ 272/* codec information */
273struct hda_codec { 273struct hda_codec {
274 struct device dev;
274 struct hda_bus *bus; 275 struct hda_bus *bus;
275 unsigned int addr; /* codec addr*/ 276 unsigned int addr; /* codec addr*/
276 struct list_head list; /* list point */ 277 struct list_head list; /* list point */
@@ -332,14 +333,17 @@ struct hda_codec {
332 struct snd_array driver_pins; /* pin configs set by codec parser */ 333 struct snd_array driver_pins; /* pin configs set by codec parser */
333 struct snd_array cvt_setups; /* audio convert setups */ 334 struct snd_array cvt_setups; /* audio convert setups */
334 335
335#ifdef CONFIG_SND_HDA_HWDEP
336 struct mutex user_mutex; 336 struct mutex user_mutex;
337 struct snd_hwdep *hwdep; /* assigned hwdep device */ 337#ifdef CONFIG_SND_HDA_RECONFIG
338 struct snd_array init_verbs; /* additional init verbs */ 338 struct snd_array init_verbs; /* additional init verbs */
339 struct snd_array hints; /* additional hints */ 339 struct snd_array hints; /* additional hints */
340 struct snd_array user_pins; /* default pin configs to override */ 340 struct snd_array user_pins; /* default pin configs to override */
341#endif 341#endif
342 342
343#ifdef CONFIG_SND_HDA_HWDEP
344 struct snd_hwdep *hwdep; /* assigned hwdep device */
345#endif
346
343 /* misc flags */ 347 /* misc flags */
344 unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each 348 unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each
345 * status change 349 * status change
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
new file mode 100644
index 000000000000..97993e17f46a
--- /dev/null
+++ b/sound/pci/hda/hda_controller.c
@@ -0,0 +1,2031 @@
1/*
2 *
3 * Implementation of primary alsa driver code base for Intel HD Audio.
4 *
5 * Copyright(c) 2004 Intel Corporation. All rights reserved.
6 *
7 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
8 * PeiSen Hou <pshou@realtek.com.tw>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 *
21 */
22
23#include <linux/clocksource.h>
24#include <linux/delay.h>
25#include <linux/interrupt.h>
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/pm_runtime.h>
29#include <linux/slab.h>
30#include <sound/core.h>
31#include <sound/initval.h>
32#include "hda_priv.h"
33#include "hda_controller.h"
34
35#define CREATE_TRACE_POINTS
36#include "hda_intel_trace.h"
37
38/* DSP lock helpers */
39#ifdef CONFIG_SND_HDA_DSP_LOADER
40#define dsp_lock_init(dev) mutex_init(&(dev)->dsp_mutex)
41#define dsp_lock(dev) mutex_lock(&(dev)->dsp_mutex)
42#define dsp_unlock(dev) mutex_unlock(&(dev)->dsp_mutex)
43#define dsp_is_locked(dev) ((dev)->locked)
44#else
45#define dsp_lock_init(dev) do {} while (0)
46#define dsp_lock(dev) do {} while (0)
47#define dsp_unlock(dev) do {} while (0)
48#define dsp_is_locked(dev) 0
49#endif
50
51/*
52 * AZX stream operations.
53 */
54
55/* start a stream */
56static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev)
57{
58 /*
59 * Before stream start, initialize parameter
60 */
61 azx_dev->insufficient = 1;
62
63 /* enable SIE */
64 azx_writel(chip, INTCTL,
65 azx_readl(chip, INTCTL) | (1 << azx_dev->index));
66 /* set DMA start and interrupt mask */
67 azx_sd_writeb(chip, azx_dev, SD_CTL,
68 azx_sd_readb(chip, azx_dev, SD_CTL) |
69 SD_CTL_DMA_START | SD_INT_MASK);
70}
71
72/* stop DMA */
73static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev)
74{
75 azx_sd_writeb(chip, azx_dev, SD_CTL,
76 azx_sd_readb(chip, azx_dev, SD_CTL) &
77 ~(SD_CTL_DMA_START | SD_INT_MASK));
78 azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
79}
80
81/* stop a stream */
82void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
83{
84 azx_stream_clear(chip, azx_dev);
85 /* disable SIE */
86 azx_writel(chip, INTCTL,
87 azx_readl(chip, INTCTL) & ~(1 << azx_dev->index));
88}
89EXPORT_SYMBOL_GPL(azx_stream_stop);
90
91/* reset stream */
92static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
93{
94 unsigned char val;
95 int timeout;
96
97 azx_stream_clear(chip, azx_dev);
98
99 azx_sd_writeb(chip, azx_dev, SD_CTL,
100 azx_sd_readb(chip, azx_dev, SD_CTL) |
101 SD_CTL_STREAM_RESET);
102 udelay(3);
103 timeout = 300;
104 while (!((val = azx_sd_readb(chip, azx_dev, SD_CTL)) &
105 SD_CTL_STREAM_RESET) && --timeout)
106 ;
107 val &= ~SD_CTL_STREAM_RESET;
108 azx_sd_writeb(chip, azx_dev, SD_CTL, val);
109 udelay(3);
110
111 timeout = 300;
112 /* waiting for hardware to report that the stream is out of reset */
113 while (((val = azx_sd_readb(chip, azx_dev, SD_CTL)) &
114 SD_CTL_STREAM_RESET) && --timeout)
115 ;
116
117 /* reset first position - may not be synced with hw at this time */
118 *azx_dev->posbuf = 0;
119}
120
121/*
122 * set up the SD for streaming
123 */
124static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
125{
126 unsigned int val;
127 /* make sure the run bit is zero for SD */
128 azx_stream_clear(chip, azx_dev);
129 /* program the stream_tag */
130 val = azx_sd_readl(chip, azx_dev, SD_CTL);
131 val = (val & ~SD_CTL_STREAM_TAG_MASK) |
132 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT);
133 if (!azx_snoop(chip))
134 val |= SD_CTL_TRAFFIC_PRIO;
135 azx_sd_writel(chip, azx_dev, SD_CTL, val);
136
137 /* program the length of samples in cyclic buffer */
138 azx_sd_writel(chip, azx_dev, SD_CBL, azx_dev->bufsize);
139
140 /* program the stream format */
141 /* this value needs to be the same as the one programmed */
142 azx_sd_writew(chip, azx_dev, SD_FORMAT, azx_dev->format_val);
143
144 /* program the stream LVI (last valid index) of the BDL */
145 azx_sd_writew(chip, azx_dev, SD_LVI, azx_dev->frags - 1);
146
147 /* program the BDL address */
148 /* lower BDL address */
149 azx_sd_writel(chip, azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
150 /* upper BDL address */
151 azx_sd_writel(chip, azx_dev, SD_BDLPU,
152 upper_32_bits(azx_dev->bdl.addr));
153
154 /* enable the position buffer */
155 if (chip->position_fix[0] != POS_FIX_LPIB ||
156 chip->position_fix[1] != POS_FIX_LPIB) {
157 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
158 azx_writel(chip, DPLBASE,
159 (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
160 }
161
162 /* set the interrupt enable bits in the descriptor control register */
163 azx_sd_writel(chip, azx_dev, SD_CTL,
164 azx_sd_readl(chip, azx_dev, SD_CTL) | SD_INT_MASK);
165
166 return 0;
167}
168
169/* assign a stream for the PCM */
170static inline struct azx_dev *
171azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
172{
173 int dev, i, nums;
174 struct azx_dev *res = NULL;
175 /* make a non-zero unique key for the substream */
176 int key = (substream->pcm->device << 16) | (substream->number << 2) |
177 (substream->stream + 1);
178
179 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
180 dev = chip->playback_index_offset;
181 nums = chip->playback_streams;
182 } else {
183 dev = chip->capture_index_offset;
184 nums = chip->capture_streams;
185 }
186 for (i = 0; i < nums; i++, dev++) {
187 struct azx_dev *azx_dev = &chip->azx_dev[dev];
188 dsp_lock(azx_dev);
189 if (!azx_dev->opened && !dsp_is_locked(azx_dev)) {
190 res = azx_dev;
191 if (res->assigned_key == key) {
192 res->opened = 1;
193 res->assigned_key = key;
194 dsp_unlock(azx_dev);
195 return azx_dev;
196 }
197 }
198 dsp_unlock(azx_dev);
199 }
200 if (res) {
201 dsp_lock(res);
202 res->opened = 1;
203 res->assigned_key = key;
204 dsp_unlock(res);
205 }
206 return res;
207}
208
209/* release the assigned stream */
210static inline void azx_release_device(struct azx_dev *azx_dev)
211{
212 azx_dev->opened = 0;
213}
214
215static cycle_t azx_cc_read(const struct cyclecounter *cc)
216{
217 struct azx_dev *azx_dev = container_of(cc, struct azx_dev, azx_cc);
218 struct snd_pcm_substream *substream = azx_dev->substream;
219 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
220 struct azx *chip = apcm->chip;
221
222 return azx_readl(chip, WALLCLK);
223}
224
225static void azx_timecounter_init(struct snd_pcm_substream *substream,
226 bool force, cycle_t last)
227{
228 struct azx_dev *azx_dev = get_azx_dev(substream);
229 struct timecounter *tc = &azx_dev->azx_tc;
230 struct cyclecounter *cc = &azx_dev->azx_cc;
231 u64 nsec;
232
233 cc->read = azx_cc_read;
234 cc->mask = CLOCKSOURCE_MASK(32);
235
236 /*
237 * Converting from 24 MHz to ns means applying a 125/3 factor.
238 * To avoid any saturation issues in intermediate operations,
239 * the 125 factor is applied first. The division is applied
240 * last after reading the timecounter value.
241 * Applying the 1/3 factor as part of the multiplication
242 * requires at least 20 bits for a decent precision, however
243 * overflows occur after about 4 hours or less, not a option.
244 */
245
246 cc->mult = 125; /* saturation after 195 years */
247 cc->shift = 0;
248
249 nsec = 0; /* audio time is elapsed time since trigger */
250 timecounter_init(tc, cc, nsec);
251 if (force)
252 /*
253 * force timecounter to use predefined value,
254 * used for synchronized starts
255 */
256 tc->cycle_last = last;
257}
258
259static u64 azx_adjust_codec_delay(struct snd_pcm_substream *substream,
260 u64 nsec)
261{
262 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
263 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
264 u64 codec_frames, codec_nsecs;
265
266 if (!hinfo->ops.get_delay)
267 return nsec;
268
269 codec_frames = hinfo->ops.get_delay(hinfo, apcm->codec, substream);
270 codec_nsecs = div_u64(codec_frames * 1000000000LL,
271 substream->runtime->rate);
272
273 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
274 return nsec + codec_nsecs;
275
276 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
277}
278
279/*
280 * set up a BDL entry
281 */
282static int setup_bdle(struct azx *chip,
283 struct snd_dma_buffer *dmab,
284 struct azx_dev *azx_dev, u32 **bdlp,
285 int ofs, int size, int with_ioc)
286{
287 u32 *bdl = *bdlp;
288
289 while (size > 0) {
290 dma_addr_t addr;
291 int chunk;
292
293 if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES)
294 return -EINVAL;
295
296 addr = snd_sgbuf_get_addr(dmab, ofs);
297 /* program the address field of the BDL entry */
298 bdl[0] = cpu_to_le32((u32)addr);
299 bdl[1] = cpu_to_le32(upper_32_bits(addr));
300 /* program the size field of the BDL entry */
301 chunk = snd_sgbuf_get_chunk_size(dmab, ofs, size);
302 /* one BDLE cannot cross 4K boundary on CTHDA chips */
303 if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY) {
304 u32 remain = 0x1000 - (ofs & 0xfff);
305 if (chunk > remain)
306 chunk = remain;
307 }
308 bdl[2] = cpu_to_le32(chunk);
309 /* program the IOC to enable interrupt
310 * only when the whole fragment is processed
311 */
312 size -= chunk;
313 bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01);
314 bdl += 4;
315 azx_dev->frags++;
316 ofs += chunk;
317 }
318 *bdlp = bdl;
319 return ofs;
320}
321
322/*
323 * set up BDL entries
324 */
325static int azx_setup_periods(struct azx *chip,
326 struct snd_pcm_substream *substream,
327 struct azx_dev *azx_dev)
328{
329 u32 *bdl;
330 int i, ofs, periods, period_bytes;
331 int pos_adj = 0;
332
333 /* reset BDL address */
334 azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
335 azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
336
337 period_bytes = azx_dev->period_bytes;
338 periods = azx_dev->bufsize / period_bytes;
339
340 /* program the initial BDL entries */
341 bdl = (u32 *)azx_dev->bdl.area;
342 ofs = 0;
343 azx_dev->frags = 0;
344
345 if (chip->bdl_pos_adj)
346 pos_adj = chip->bdl_pos_adj[chip->dev_index];
347 if (!azx_dev->no_period_wakeup && pos_adj > 0) {
348 struct snd_pcm_runtime *runtime = substream->runtime;
349 int pos_align = pos_adj;
350 pos_adj = (pos_adj * runtime->rate + 47999) / 48000;
351 if (!pos_adj)
352 pos_adj = pos_align;
353 else
354 pos_adj = ((pos_adj + pos_align - 1) / pos_align) *
355 pos_align;
356 pos_adj = frames_to_bytes(runtime, pos_adj);
357 if (pos_adj >= period_bytes) {
358 dev_warn(chip->card->dev,"Too big adjustment %d\n",
359 pos_adj);
360 pos_adj = 0;
361 } else {
362 ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
363 azx_dev,
364 &bdl, ofs, pos_adj, true);
365 if (ofs < 0)
366 goto error;
367 }
368 } else
369 pos_adj = 0;
370
371 for (i = 0; i < periods; i++) {
372 if (i == periods - 1 && pos_adj)
373 ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
374 azx_dev, &bdl, ofs,
375 period_bytes - pos_adj, 0);
376 else
377 ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
378 azx_dev, &bdl, ofs,
379 period_bytes,
380 !azx_dev->no_period_wakeup);
381 if (ofs < 0)
382 goto error;
383 }
384 return 0;
385
386 error:
387 dev_err(chip->card->dev, "Too many BDL entries: buffer=%d, period=%d\n",
388 azx_dev->bufsize, period_bytes);
389 return -EINVAL;
390}
391
392/*
393 * PCM ops
394 */
395
396static int azx_pcm_close(struct snd_pcm_substream *substream)
397{
398 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
399 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
400 struct azx *chip = apcm->chip;
401 struct azx_dev *azx_dev = get_azx_dev(substream);
402 unsigned long flags;
403
404 mutex_lock(&chip->open_mutex);
405 spin_lock_irqsave(&chip->reg_lock, flags);
406 azx_dev->substream = NULL;
407 azx_dev->running = 0;
408 spin_unlock_irqrestore(&chip->reg_lock, flags);
409 azx_release_device(azx_dev);
410 hinfo->ops.close(hinfo, apcm->codec, substream);
411 snd_hda_power_down(apcm->codec);
412 mutex_unlock(&chip->open_mutex);
413 return 0;
414}
415
416static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
417 struct snd_pcm_hw_params *hw_params)
418{
419 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
420 struct azx *chip = apcm->chip;
421 int ret;
422
423 dsp_lock(get_azx_dev(substream));
424 if (dsp_is_locked(get_azx_dev(substream))) {
425 ret = -EBUSY;
426 goto unlock;
427 }
428
429 ret = chip->ops->substream_alloc_pages(chip, substream,
430 params_buffer_bytes(hw_params));
431unlock:
432 dsp_unlock(get_azx_dev(substream));
433 return ret;
434}
435
436static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
437{
438 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
439 struct azx_dev *azx_dev = get_azx_dev(substream);
440 struct azx *chip = apcm->chip;
441 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
442 int err;
443
444 /* reset BDL address */
445 dsp_lock(azx_dev);
446 if (!dsp_is_locked(azx_dev)) {
447 azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
448 azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
449 azx_sd_writel(chip, azx_dev, SD_CTL, 0);
450 azx_dev->bufsize = 0;
451 azx_dev->period_bytes = 0;
452 azx_dev->format_val = 0;
453 }
454
455 snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
456
457 err = chip->ops->substream_free_pages(chip, substream);
458 azx_dev->prepared = 0;
459 dsp_unlock(azx_dev);
460 return err;
461}
462
463static int azx_pcm_prepare(struct snd_pcm_substream *substream)
464{
465 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
466 struct azx *chip = apcm->chip;
467 struct azx_dev *azx_dev = get_azx_dev(substream);
468 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
469 struct snd_pcm_runtime *runtime = substream->runtime;
470 unsigned int bufsize, period_bytes, format_val, stream_tag;
471 int err;
472 struct hda_spdif_out *spdif =
473 snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid);
474 unsigned short ctls = spdif ? spdif->ctls : 0;
475
476 dsp_lock(azx_dev);
477 if (dsp_is_locked(azx_dev)) {
478 err = -EBUSY;
479 goto unlock;
480 }
481
482 azx_stream_reset(chip, azx_dev);
483 format_val = snd_hda_calc_stream_format(runtime->rate,
484 runtime->channels,
485 runtime->format,
486 hinfo->maxbps,
487 ctls);
488 if (!format_val) {
489 dev_err(chip->card->dev,
490 "invalid format_val, rate=%d, ch=%d, format=%d\n",
491 runtime->rate, runtime->channels, runtime->format);
492 err = -EINVAL;
493 goto unlock;
494 }
495
496 bufsize = snd_pcm_lib_buffer_bytes(substream);
497 period_bytes = snd_pcm_lib_period_bytes(substream);
498
499 dev_dbg(chip->card->dev, "azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
500 bufsize, format_val);
501
502 if (bufsize != azx_dev->bufsize ||
503 period_bytes != azx_dev->period_bytes ||
504 format_val != azx_dev->format_val ||
505 runtime->no_period_wakeup != azx_dev->no_period_wakeup) {
506 azx_dev->bufsize = bufsize;
507 azx_dev->period_bytes = period_bytes;
508 azx_dev->format_val = format_val;
509 azx_dev->no_period_wakeup = runtime->no_period_wakeup;
510 err = azx_setup_periods(chip, substream, azx_dev);
511 if (err < 0)
512 goto unlock;
513 }
514
515 /* when LPIB delay correction gives a small negative value,
516 * we ignore it; currently set the threshold statically to
517 * 64 frames
518 */
519 if (runtime->period_size > 64)
520 azx_dev->delay_negative_threshold = -frames_to_bytes(runtime, 64);
521 else
522 azx_dev->delay_negative_threshold = 0;
523
524 /* wallclk has 24Mhz clock source */
525 azx_dev->period_wallclk = (((runtime->period_size * 24000) /
526 runtime->rate) * 1000);
527 azx_setup_controller(chip, azx_dev);
528 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
529 azx_dev->fifo_size =
530 azx_sd_readw(chip, azx_dev, SD_FIFOSIZE) + 1;
531 else
532 azx_dev->fifo_size = 0;
533
534 stream_tag = azx_dev->stream_tag;
535 /* CA-IBG chips need the playback stream starting from 1 */
536 if ((chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) &&
537 stream_tag > chip->capture_streams)
538 stream_tag -= chip->capture_streams;
539 err = snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag,
540 azx_dev->format_val, substream);
541
542 unlock:
543 if (!err)
544 azx_dev->prepared = 1;
545 dsp_unlock(azx_dev);
546 return err;
547}
548
549static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
550{
551 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
552 struct azx *chip = apcm->chip;
553 struct azx_dev *azx_dev;
554 struct snd_pcm_substream *s;
555 int rstart = 0, start, nsync = 0, sbits = 0;
556 int nwait, timeout;
557
558 azx_dev = get_azx_dev(substream);
559 trace_azx_pcm_trigger(chip, azx_dev, cmd);
560
561 if (dsp_is_locked(azx_dev) || !azx_dev->prepared)
562 return -EPIPE;
563
564 switch (cmd) {
565 case SNDRV_PCM_TRIGGER_START:
566 rstart = 1;
567 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
568 case SNDRV_PCM_TRIGGER_RESUME:
569 start = 1;
570 break;
571 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
572 case SNDRV_PCM_TRIGGER_SUSPEND:
573 case SNDRV_PCM_TRIGGER_STOP:
574 start = 0;
575 break;
576 default:
577 return -EINVAL;
578 }
579
580 snd_pcm_group_for_each_entry(s, substream) {
581 if (s->pcm->card != substream->pcm->card)
582 continue;
583 azx_dev = get_azx_dev(s);
584 sbits |= 1 << azx_dev->index;
585 nsync++;
586 snd_pcm_trigger_done(s, substream);
587 }
588
589 spin_lock(&chip->reg_lock);
590
591 /* first, set SYNC bits of corresponding streams */
592 if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
593 azx_writel(chip, OLD_SSYNC,
594 azx_readl(chip, OLD_SSYNC) | sbits);
595 else
596 azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) | sbits);
597
598 snd_pcm_group_for_each_entry(s, substream) {
599 if (s->pcm->card != substream->pcm->card)
600 continue;
601 azx_dev = get_azx_dev(s);
602 if (start) {
603 azx_dev->start_wallclk = azx_readl(chip, WALLCLK);
604 if (!rstart)
605 azx_dev->start_wallclk -=
606 azx_dev->period_wallclk;
607 azx_stream_start(chip, azx_dev);
608 } else {
609 azx_stream_stop(chip, azx_dev);
610 }
611 azx_dev->running = start;
612 }
613 spin_unlock(&chip->reg_lock);
614 if (start) {
615 /* wait until all FIFOs get ready */
616 for (timeout = 5000; timeout; timeout--) {
617 nwait = 0;
618 snd_pcm_group_for_each_entry(s, substream) {
619 if (s->pcm->card != substream->pcm->card)
620 continue;
621 azx_dev = get_azx_dev(s);
622 if (!(azx_sd_readb(chip, azx_dev, SD_STS) &
623 SD_STS_FIFO_READY))
624 nwait++;
625 }
626 if (!nwait)
627 break;
628 cpu_relax();
629 }
630 } else {
631 /* wait until all RUN bits are cleared */
632 for (timeout = 5000; timeout; timeout--) {
633 nwait = 0;
634 snd_pcm_group_for_each_entry(s, substream) {
635 if (s->pcm->card != substream->pcm->card)
636 continue;
637 azx_dev = get_azx_dev(s);
638 if (azx_sd_readb(chip, azx_dev, SD_CTL) &
639 SD_CTL_DMA_START)
640 nwait++;
641 }
642 if (!nwait)
643 break;
644 cpu_relax();
645 }
646 }
647 spin_lock(&chip->reg_lock);
648 /* reset SYNC bits */
649 if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
650 azx_writel(chip, OLD_SSYNC,
651 azx_readl(chip, OLD_SSYNC) & ~sbits);
652 else
653 azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits);
654 if (start) {
655 azx_timecounter_init(substream, 0, 0);
656 if (nsync > 1) {
657 cycle_t cycle_last;
658
659 /* same start cycle for master and group */
660 azx_dev = get_azx_dev(substream);
661 cycle_last = azx_dev->azx_tc.cycle_last;
662
663 snd_pcm_group_for_each_entry(s, substream) {
664 if (s->pcm->card != substream->pcm->card)
665 continue;
666 azx_timecounter_init(s, 1, cycle_last);
667 }
668 }
669 }
670 spin_unlock(&chip->reg_lock);
671 return 0;
672}
673
674/* get the current DMA position with correction on VIA chips */
675static unsigned int azx_via_get_position(struct azx *chip,
676 struct azx_dev *azx_dev)
677{
678 unsigned int link_pos, mini_pos, bound_pos;
679 unsigned int mod_link_pos, mod_dma_pos, mod_mini_pos;
680 unsigned int fifo_size;
681
682 link_pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
683 if (azx_dev->substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
684 /* Playback, no problem using link position */
685 return link_pos;
686 }
687
688 /* Capture */
689 /* For new chipset,
690 * use mod to get the DMA position just like old chipset
691 */
692 mod_dma_pos = le32_to_cpu(*azx_dev->posbuf);
693 mod_dma_pos %= azx_dev->period_bytes;
694
695 /* azx_dev->fifo_size can't get FIFO size of in stream.
696 * Get from base address + offset.
697 */
698 fifo_size = readw(chip->remap_addr + VIA_IN_STREAM0_FIFO_SIZE_OFFSET);
699
700 if (azx_dev->insufficient) {
701 /* Link position never gather than FIFO size */
702 if (link_pos <= fifo_size)
703 return 0;
704
705 azx_dev->insufficient = 0;
706 }
707
708 if (link_pos <= fifo_size)
709 mini_pos = azx_dev->bufsize + link_pos - fifo_size;
710 else
711 mini_pos = link_pos - fifo_size;
712
713 /* Find nearest previous boudary */
714 mod_mini_pos = mini_pos % azx_dev->period_bytes;
715 mod_link_pos = link_pos % azx_dev->period_bytes;
716 if (mod_link_pos >= fifo_size)
717 bound_pos = link_pos - mod_link_pos;
718 else if (mod_dma_pos >= mod_mini_pos)
719 bound_pos = mini_pos - mod_mini_pos;
720 else {
721 bound_pos = mini_pos - mod_mini_pos + azx_dev->period_bytes;
722 if (bound_pos >= azx_dev->bufsize)
723 bound_pos = 0;
724 }
725
726 /* Calculate real DMA position we want */
727 return bound_pos + mod_dma_pos;
728}
729
730unsigned int azx_get_position(struct azx *chip,
731 struct azx_dev *azx_dev,
732 bool with_check)
733{
734 struct snd_pcm_substream *substream = azx_dev->substream;
735 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
736 unsigned int pos;
737 int stream = substream->stream;
738 struct hda_pcm_stream *hinfo = apcm->hinfo[stream];
739 int delay = 0;
740
741 switch (chip->position_fix[stream]) {
742 case POS_FIX_LPIB:
743 /* read LPIB */
744 pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
745 break;
746 case POS_FIX_VIACOMBO:
747 pos = azx_via_get_position(chip, azx_dev);
748 break;
749 default:
750 /* use the position buffer */
751 pos = le32_to_cpu(*azx_dev->posbuf);
752 if (with_check && chip->position_fix[stream] == POS_FIX_AUTO) {
753 if (!pos || pos == (u32)-1) {
754 dev_info(chip->card->dev,
755 "Invalid position buffer, using LPIB read method instead.\n");
756 chip->position_fix[stream] = POS_FIX_LPIB;
757 pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
758 } else
759 chip->position_fix[stream] = POS_FIX_POSBUF;
760 }
761 break;
762 }
763
764 if (pos >= azx_dev->bufsize)
765 pos = 0;
766
767 /* calculate runtime delay from LPIB */
768 if (substream->runtime &&
769 chip->position_fix[stream] == POS_FIX_POSBUF &&
770 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) {
771 unsigned int lpib_pos = azx_sd_readl(chip, azx_dev, SD_LPIB);
772 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
773 delay = pos - lpib_pos;
774 else
775 delay = lpib_pos - pos;
776 if (delay < 0) {
777 if (delay >= azx_dev->delay_negative_threshold)
778 delay = 0;
779 else
780 delay += azx_dev->bufsize;
781 }
782 if (delay >= azx_dev->period_bytes) {
783 dev_info(chip->card->dev,
784 "Unstable LPIB (%d >= %d); disabling LPIB delay counting\n",
785 delay, azx_dev->period_bytes);
786 delay = 0;
787 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY;
788 }
789 delay = bytes_to_frames(substream->runtime, delay);
790 }
791
792 if (substream->runtime) {
793 if (hinfo->ops.get_delay)
794 delay += hinfo->ops.get_delay(hinfo, apcm->codec,
795 substream);
796 substream->runtime->delay = delay;
797 }
798
799 trace_azx_get_position(chip, azx_dev, pos, delay);
800 return pos;
801}
802EXPORT_SYMBOL_GPL(azx_get_position);
803
804static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
805{
806 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
807 struct azx *chip = apcm->chip;
808 struct azx_dev *azx_dev = get_azx_dev(substream);
809 return bytes_to_frames(substream->runtime,
810 azx_get_position(chip, azx_dev, false));
811}
812
813static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream,
814 struct timespec *ts)
815{
816 struct azx_dev *azx_dev = get_azx_dev(substream);
817 u64 nsec;
818
819 nsec = timecounter_read(&azx_dev->azx_tc);
820 nsec = div_u64(nsec, 3); /* can be optimized */
821 nsec = azx_adjust_codec_delay(substream, nsec);
822
823 *ts = ns_to_timespec(nsec);
824
825 return 0;
826}
827
828static struct snd_pcm_hardware azx_pcm_hw = {
829 .info = (SNDRV_PCM_INFO_MMAP |
830 SNDRV_PCM_INFO_INTERLEAVED |
831 SNDRV_PCM_INFO_BLOCK_TRANSFER |
832 SNDRV_PCM_INFO_MMAP_VALID |
833 /* No full-resume yet implemented */
834 /* SNDRV_PCM_INFO_RESUME |*/
835 SNDRV_PCM_INFO_PAUSE |
836 SNDRV_PCM_INFO_SYNC_START |
837 SNDRV_PCM_INFO_HAS_WALL_CLOCK |
838 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
839 .formats = SNDRV_PCM_FMTBIT_S16_LE,
840 .rates = SNDRV_PCM_RATE_48000,
841 .rate_min = 48000,
842 .rate_max = 48000,
843 .channels_min = 2,
844 .channels_max = 2,
845 .buffer_bytes_max = AZX_MAX_BUF_SIZE,
846 .period_bytes_min = 128,
847 .period_bytes_max = AZX_MAX_BUF_SIZE / 2,
848 .periods_min = 2,
849 .periods_max = AZX_MAX_FRAG,
850 .fifo_size = 0,
851};
852
853static int azx_pcm_open(struct snd_pcm_substream *substream)
854{
855 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
856 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
857 struct azx *chip = apcm->chip;
858 struct azx_dev *azx_dev;
859 struct snd_pcm_runtime *runtime = substream->runtime;
860 unsigned long flags;
861 int err;
862 int buff_step;
863
864 mutex_lock(&chip->open_mutex);
865 azx_dev = azx_assign_device(chip, substream);
866 if (azx_dev == NULL) {
867 mutex_unlock(&chip->open_mutex);
868 return -EBUSY;
869 }
870 runtime->hw = azx_pcm_hw;
871 runtime->hw.channels_min = hinfo->channels_min;
872 runtime->hw.channels_max = hinfo->channels_max;
873 runtime->hw.formats = hinfo->formats;
874 runtime->hw.rates = hinfo->rates;
875 snd_pcm_limit_hw_rates(runtime);
876 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
877
878 /* avoid wrap-around with wall-clock */
879 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
880 20,
881 178000000);
882
883 if (chip->align_buffer_size)
884 /* constrain buffer sizes to be multiple of 128
885 bytes. This is more efficient in terms of memory
886 access but isn't required by the HDA spec and
887 prevents users from specifying exact period/buffer
888 sizes. For example for 44.1kHz, a period size set
889 to 20ms will be rounded to 19.59ms. */
890 buff_step = 128;
891 else
892 /* Don't enforce steps on buffer sizes, still need to
893 be multiple of 4 bytes (HDA spec). Tested on Intel
894 HDA controllers, may not work on all devices where
895 option needs to be disabled */
896 buff_step = 4;
897
898 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
899 buff_step);
900 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
901 buff_step);
902 snd_hda_power_up_d3wait(apcm->codec);
903 err = hinfo->ops.open(hinfo, apcm->codec, substream);
904 if (err < 0) {
905 azx_release_device(azx_dev);
906 snd_hda_power_down(apcm->codec);
907 mutex_unlock(&chip->open_mutex);
908 return err;
909 }
910 snd_pcm_limit_hw_rates(runtime);
911 /* sanity check */
912 if (snd_BUG_ON(!runtime->hw.channels_min) ||
913 snd_BUG_ON(!runtime->hw.channels_max) ||
914 snd_BUG_ON(!runtime->hw.formats) ||
915 snd_BUG_ON(!runtime->hw.rates)) {
916 azx_release_device(azx_dev);
917 hinfo->ops.close(hinfo, apcm->codec, substream);
918 snd_hda_power_down(apcm->codec);
919 mutex_unlock(&chip->open_mutex);
920 return -EINVAL;
921 }
922
923 /* disable WALLCLOCK timestamps for capture streams
924 until we figure out how to handle digital inputs */
925 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
926 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK;
927
928 spin_lock_irqsave(&chip->reg_lock, flags);
929 azx_dev->substream = substream;
930 azx_dev->running = 0;
931 spin_unlock_irqrestore(&chip->reg_lock, flags);
932
933 runtime->private_data = azx_dev;
934 snd_pcm_set_sync(substream);
935 mutex_unlock(&chip->open_mutex);
936 return 0;
937}
938
939static int azx_pcm_mmap(struct snd_pcm_substream *substream,
940 struct vm_area_struct *area)
941{
942 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
943 struct azx *chip = apcm->chip;
944 if (chip->ops->pcm_mmap_prepare)
945 chip->ops->pcm_mmap_prepare(substream, area);
946 return snd_pcm_lib_default_mmap(substream, area);
947}
948
949static struct snd_pcm_ops azx_pcm_ops = {
950 .open = azx_pcm_open,
951 .close = azx_pcm_close,
952 .ioctl = snd_pcm_lib_ioctl,
953 .hw_params = azx_pcm_hw_params,
954 .hw_free = azx_pcm_hw_free,
955 .prepare = azx_pcm_prepare,
956 .trigger = azx_pcm_trigger,
957 .pointer = azx_pcm_pointer,
958 .wall_clock = azx_get_wallclock_tstamp,
959 .mmap = azx_pcm_mmap,
960 .page = snd_pcm_sgbuf_ops_page,
961};
962
963static void azx_pcm_free(struct snd_pcm *pcm)
964{
965 struct azx_pcm *apcm = pcm->private_data;
966 if (apcm) {
967 list_del(&apcm->list);
968 kfree(apcm);
969 }
970}
971
972#define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
973
974static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
975 struct hda_pcm *cpcm)
976{
977 struct azx *chip = bus->private_data;
978 struct snd_pcm *pcm;
979 struct azx_pcm *apcm;
980 int pcm_dev = cpcm->device;
981 unsigned int size;
982 int s, err;
983
984 list_for_each_entry(apcm, &chip->pcm_list, list) {
985 if (apcm->pcm->device == pcm_dev) {
986 dev_err(chip->card->dev, "PCM %d already exists\n",
987 pcm_dev);
988 return -EBUSY;
989 }
990 }
991 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
992 cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
993 cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams,
994 &pcm);
995 if (err < 0)
996 return err;
997 strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
998 apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
999 if (apcm == NULL)
1000 return -ENOMEM;
1001 apcm->chip = chip;
1002 apcm->pcm = pcm;
1003 apcm->codec = codec;
1004 pcm->private_data = apcm;
1005 pcm->private_free = azx_pcm_free;
1006 if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
1007 pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
1008 list_add_tail(&apcm->list, &chip->pcm_list);
1009 cpcm->pcm = pcm;
1010 for (s = 0; s < 2; s++) {
1011 apcm->hinfo[s] = &cpcm->stream[s];
1012 if (cpcm->stream[s].substreams)
1013 snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
1014 }
1015 /* buffer pre-allocation */
1016 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
1017 if (size > MAX_PREALLOC_SIZE)
1018 size = MAX_PREALLOC_SIZE;
1019 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
1020 chip->card->dev,
1021 size, MAX_PREALLOC_SIZE);
1022 /* link to codec */
1023 pcm->dev = &codec->dev;
1024 return 0;
1025}
1026
1027/*
1028 * CORB / RIRB interface
1029 */
1030static int azx_alloc_cmd_io(struct azx *chip)
1031{
1032 int err;
1033
1034 /* single page (at least 4096 bytes) must suffice for both ringbuffes */
1035 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
1036 PAGE_SIZE, &chip->rb);
1037 if (err < 0)
1038 dev_err(chip->card->dev, "cannot allocate CORB/RIRB\n");
1039 return err;
1040}
1041EXPORT_SYMBOL_GPL(azx_alloc_cmd_io);
1042
1043static void azx_init_cmd_io(struct azx *chip)
1044{
1045 int timeout;
1046
1047 spin_lock_irq(&chip->reg_lock);
1048 /* CORB set up */
1049 chip->corb.addr = chip->rb.addr;
1050 chip->corb.buf = (u32 *)chip->rb.area;
1051 azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
1052 azx_writel(chip, CORBUBASE, upper_32_bits(chip->corb.addr));
1053
1054 /* set the corb size to 256 entries (ULI requires explicitly) */
1055 azx_writeb(chip, CORBSIZE, 0x02);
1056 /* set the corb write pointer to 0 */
1057 azx_writew(chip, CORBWP, 0);
1058
1059 /* reset the corb hw read pointer */
1060 azx_writew(chip, CORBRP, ICH6_CORBRP_RST);
1061 for (timeout = 1000; timeout > 0; timeout--) {
1062 if ((azx_readw(chip, CORBRP) & ICH6_CORBRP_RST) == ICH6_CORBRP_RST)
1063 break;
1064 udelay(1);
1065 }
1066 if (timeout <= 0)
1067 dev_err(chip->card->dev, "CORB reset timeout#1, CORBRP = %d\n",
1068 azx_readw(chip, CORBRP));
1069
1070 azx_writew(chip, CORBRP, 0);
1071 for (timeout = 1000; timeout > 0; timeout--) {
1072 if (azx_readw(chip, CORBRP) == 0)
1073 break;
1074 udelay(1);
1075 }
1076 if (timeout <= 0)
1077 dev_err(chip->card->dev, "CORB reset timeout#2, CORBRP = %d\n",
1078 azx_readw(chip, CORBRP));
1079
1080 /* enable corb dma */
1081 azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN);
1082
1083 /* RIRB set up */
1084 chip->rirb.addr = chip->rb.addr + 2048;
1085 chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
1086 chip->rirb.wp = chip->rirb.rp = 0;
1087 memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds));
1088 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
1089 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr));
1090
1091 /* set the rirb size to 256 entries (ULI requires explicitly) */
1092 azx_writeb(chip, RIRBSIZE, 0x02);
1093 /* reset the rirb hw write pointer */
1094 azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST);
1095 /* set N=1, get RIRB response interrupt for new entry */
1096 if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
1097 azx_writew(chip, RINTCNT, 0xc0);
1098 else
1099 azx_writew(chip, RINTCNT, 1);
1100 /* enable rirb dma and response irq */
1101 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN);
1102 spin_unlock_irq(&chip->reg_lock);
1103}
1104EXPORT_SYMBOL_GPL(azx_init_cmd_io);
1105
1106static void azx_free_cmd_io(struct azx *chip)
1107{
1108 spin_lock_irq(&chip->reg_lock);
1109 /* disable ringbuffer DMAs */
1110 azx_writeb(chip, RIRBCTL, 0);
1111 azx_writeb(chip, CORBCTL, 0);
1112 spin_unlock_irq(&chip->reg_lock);
1113}
1114EXPORT_SYMBOL_GPL(azx_free_cmd_io);
1115
1116static unsigned int azx_command_addr(u32 cmd)
1117{
1118 unsigned int addr = cmd >> 28;
1119
1120 if (addr >= AZX_MAX_CODECS) {
1121 snd_BUG();
1122 addr = 0;
1123 }
1124
1125 return addr;
1126}
1127
1128/* send a command */
1129static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
1130{
1131 struct azx *chip = bus->private_data;
1132 unsigned int addr = azx_command_addr(val);
1133 unsigned int wp, rp;
1134
1135 spin_lock_irq(&chip->reg_lock);
1136
1137 /* add command to corb */
1138 wp = azx_readw(chip, CORBWP);
1139 if (wp == 0xffff) {
1140 /* something wrong, controller likely turned to D3 */
1141 spin_unlock_irq(&chip->reg_lock);
1142 return -EIO;
1143 }
1144 wp++;
1145 wp %= ICH6_MAX_CORB_ENTRIES;
1146
1147 rp = azx_readw(chip, CORBRP);
1148 if (wp == rp) {
1149 /* oops, it's full */
1150 spin_unlock_irq(&chip->reg_lock);
1151 return -EAGAIN;
1152 }
1153
1154 chip->rirb.cmds[addr]++;
1155 chip->corb.buf[wp] = cpu_to_le32(val);
1156 azx_writew(chip, CORBWP, wp);
1157
1158 spin_unlock_irq(&chip->reg_lock);
1159
1160 return 0;
1161}
1162
1163#define ICH6_RIRB_EX_UNSOL_EV (1<<4)
1164
1165/* retrieve RIRB entry - called from interrupt handler */
1166static void azx_update_rirb(struct azx *chip)
1167{
1168 unsigned int rp, wp;
1169 unsigned int addr;
1170 u32 res, res_ex;
1171
1172 wp = azx_readw(chip, RIRBWP);
1173 if (wp == 0xffff) {
1174 /* something wrong, controller likely turned to D3 */
1175 return;
1176 }
1177
1178 if (wp == chip->rirb.wp)
1179 return;
1180 chip->rirb.wp = wp;
1181
1182 while (chip->rirb.rp != wp) {
1183 chip->rirb.rp++;
1184 chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES;
1185
1186 rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */
1187 res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]);
1188 res = le32_to_cpu(chip->rirb.buf[rp]);
1189 addr = res_ex & 0xf;
1190 if ((addr >= AZX_MAX_CODECS) || !(chip->codec_mask & (1 << addr))) {
1191 dev_err(chip->card->dev, "spurious response %#x:%#x, rp = %d, wp = %d",
1192 res, res_ex,
1193 chip->rirb.rp, wp);
1194 snd_BUG();
1195 }
1196 else if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
1197 snd_hda_queue_unsol_event(chip->bus, res, res_ex);
1198 else if (chip->rirb.cmds[addr]) {
1199 chip->rirb.res[addr] = res;
1200 smp_wmb();
1201 chip->rirb.cmds[addr]--;
1202 } else if (printk_ratelimit()) {
1203 dev_err(chip->card->dev, "spurious response %#x:%#x, last cmd=%#08x\n",
1204 res, res_ex,
1205 chip->last_cmd[addr]);
1206 }
1207 }
1208}
1209
1210/* receive a response */
1211static unsigned int azx_rirb_get_response(struct hda_bus *bus,
1212 unsigned int addr)
1213{
1214 struct azx *chip = bus->private_data;
1215 unsigned long timeout;
1216 unsigned long loopcounter;
1217 int do_poll = 0;
1218
1219 again:
1220 timeout = jiffies + msecs_to_jiffies(1000);
1221
1222 for (loopcounter = 0;; loopcounter++) {
1223 if (chip->polling_mode || do_poll) {
1224 spin_lock_irq(&chip->reg_lock);
1225 azx_update_rirb(chip);
1226 spin_unlock_irq(&chip->reg_lock);
1227 }
1228 if (!chip->rirb.cmds[addr]) {
1229 smp_rmb();
1230 bus->rirb_error = 0;
1231
1232 if (!do_poll)
1233 chip->poll_count = 0;
1234 return chip->rirb.res[addr]; /* the last value */
1235 }
1236 if (time_after(jiffies, timeout))
1237 break;
1238 if (bus->needs_damn_long_delay || loopcounter > 3000)
1239 msleep(2); /* temporary workaround */
1240 else {
1241 udelay(10);
1242 cond_resched();
1243 }
1244 }
1245
1246 if (!bus->no_response_fallback)
1247 return -1;
1248
1249 if (!chip->polling_mode && chip->poll_count < 2) {
1250 dev_dbg(chip->card->dev,
1251 "azx_get_response timeout, polling the codec once: last cmd=0x%08x\n",
1252 chip->last_cmd[addr]);
1253 do_poll = 1;
1254 chip->poll_count++;
1255 goto again;
1256 }
1257
1258
1259 if (!chip->polling_mode) {
1260 dev_warn(chip->card->dev,
1261 "azx_get_response timeout, switching to polling mode: last cmd=0x%08x\n",
1262 chip->last_cmd[addr]);
1263 chip->polling_mode = 1;
1264 goto again;
1265 }
1266
1267 if (chip->msi) {
1268 dev_warn(chip->card->dev,
1269 "No response from codec, disabling MSI: last cmd=0x%08x\n",
1270 chip->last_cmd[addr]);
1271 if (chip->ops->disable_msi_reset_irq(chip) &&
1272 chip->ops->disable_msi_reset_irq(chip) < 0) {
1273 bus->rirb_error = 1;
1274 return -1;
1275 }
1276 goto again;
1277 }
1278
1279 if (chip->probing) {
1280 /* If this critical timeout happens during the codec probing
1281 * phase, this is likely an access to a non-existing codec
1282 * slot. Better to return an error and reset the system.
1283 */
1284 return -1;
1285 }
1286
1287 /* a fatal communication error; need either to reset or to fallback
1288 * to the single_cmd mode
1289 */
1290 bus->rirb_error = 1;
1291 if (bus->allow_bus_reset && !bus->response_reset && !bus->in_reset) {
1292 bus->response_reset = 1;
1293 return -1; /* give a chance to retry */
1294 }
1295
1296 dev_err(chip->card->dev,
1297 "azx_get_response timeout, switching to single_cmd mode: last cmd=0x%08x\n",
1298 chip->last_cmd[addr]);
1299 chip->single_cmd = 1;
1300 bus->response_reset = 0;
1301 /* release CORB/RIRB */
1302 azx_free_cmd_io(chip);
1303 /* disable unsolicited responses */
1304 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_UNSOL);
1305 return -1;
1306}
1307
1308/*
1309 * Use the single immediate command instead of CORB/RIRB for simplicity
1310 *
1311 * Note: according to Intel, this is not preferred use. The command was
1312 * intended for the BIOS only, and may get confused with unsolicited
1313 * responses. So, we shouldn't use it for normal operation from the
1314 * driver.
1315 * I left the codes, however, for debugging/testing purposes.
1316 */
1317
1318/* receive a response */
1319static int azx_single_wait_for_response(struct azx *chip, unsigned int addr)
1320{
1321 int timeout = 50;
1322
1323 while (timeout--) {
1324 /* check IRV busy bit */
1325 if (azx_readw(chip, IRS) & ICH6_IRS_VALID) {
1326 /* reuse rirb.res as the response return value */
1327 chip->rirb.res[addr] = azx_readl(chip, IR);
1328 return 0;
1329 }
1330 udelay(1);
1331 }
1332 if (printk_ratelimit())
1333 dev_dbg(chip->card->dev, "get_response timeout: IRS=0x%x\n",
1334 azx_readw(chip, IRS));
1335 chip->rirb.res[addr] = -1;
1336 return -EIO;
1337}
1338
1339/* send a command */
1340static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
1341{
1342 struct azx *chip = bus->private_data;
1343 unsigned int addr = azx_command_addr(val);
1344 int timeout = 50;
1345
1346 bus->rirb_error = 0;
1347 while (timeout--) {
1348 /* check ICB busy bit */
1349 if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) {
1350 /* Clear IRV valid bit */
1351 azx_writew(chip, IRS, azx_readw(chip, IRS) |
1352 ICH6_IRS_VALID);
1353 azx_writel(chip, IC, val);
1354 azx_writew(chip, IRS, azx_readw(chip, IRS) |
1355 ICH6_IRS_BUSY);
1356 return azx_single_wait_for_response(chip, addr);
1357 }
1358 udelay(1);
1359 }
1360 if (printk_ratelimit())
1361 dev_dbg(chip->card->dev,
1362 "send_cmd timeout: IRS=0x%x, val=0x%x\n",
1363 azx_readw(chip, IRS), val);
1364 return -EIO;
1365}
1366
1367/* receive a response */
1368static unsigned int azx_single_get_response(struct hda_bus *bus,
1369 unsigned int addr)
1370{
1371 struct azx *chip = bus->private_data;
1372 return chip->rirb.res[addr];
1373}
1374
1375/*
1376 * The below are the main callbacks from hda_codec.
1377 *
1378 * They are just the skeleton to call sub-callbacks according to the
1379 * current setting of chip->single_cmd.
1380 */
1381
1382/* send a command */
1383static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
1384{
1385 struct azx *chip = bus->private_data;
1386
1387 if (chip->disabled)
1388 return 0;
1389 chip->last_cmd[azx_command_addr(val)] = val;
1390 if (chip->single_cmd)
1391 return azx_single_send_cmd(bus, val);
1392 else
1393 return azx_corb_send_cmd(bus, val);
1394}
1395EXPORT_SYMBOL_GPL(azx_send_cmd);
1396
1397/* get a response */
1398static unsigned int azx_get_response(struct hda_bus *bus,
1399 unsigned int addr)
1400{
1401 struct azx *chip = bus->private_data;
1402 if (chip->disabled)
1403 return 0;
1404 if (chip->single_cmd)
1405 return azx_single_get_response(bus, addr);
1406 else
1407 return azx_rirb_get_response(bus, addr);
1408}
1409EXPORT_SYMBOL_GPL(azx_get_response);
1410
1411#ifdef CONFIG_SND_HDA_DSP_LOADER
1412/*
1413 * DSP loading code (e.g. for CA0132)
1414 */
1415
1416/* use the first stream for loading DSP */
1417static struct azx_dev *
1418azx_get_dsp_loader_dev(struct azx *chip)
1419{
1420 return &chip->azx_dev[chip->playback_index_offset];
1421}
1422
1423static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
1424 unsigned int byte_size,
1425 struct snd_dma_buffer *bufp)
1426{
1427 u32 *bdl;
1428 struct azx *chip = bus->private_data;
1429 struct azx_dev *azx_dev;
1430 int err;
1431
1432 azx_dev = azx_get_dsp_loader_dev(chip);
1433
1434 dsp_lock(azx_dev);
1435 spin_lock_irq(&chip->reg_lock);
1436 if (azx_dev->running || azx_dev->locked) {
1437 spin_unlock_irq(&chip->reg_lock);
1438 err = -EBUSY;
1439 goto unlock;
1440 }
1441 azx_dev->prepared = 0;
1442 chip->saved_azx_dev = *azx_dev;
1443 azx_dev->locked = 1;
1444 spin_unlock_irq(&chip->reg_lock);
1445
1446 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV_SG,
1447 byte_size, bufp);
1448 if (err < 0)
1449 goto err_alloc;
1450
1451 azx_dev->bufsize = byte_size;
1452 azx_dev->period_bytes = byte_size;
1453 azx_dev->format_val = format;
1454
1455 azx_stream_reset(chip, azx_dev);
1456
1457 /* reset BDL address */
1458 azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
1459 azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
1460
1461 azx_dev->frags = 0;
1462 bdl = (u32 *)azx_dev->bdl.area;
1463 err = setup_bdle(chip, bufp, azx_dev, &bdl, 0, byte_size, 0);
1464 if (err < 0)
1465 goto error;
1466
1467 azx_setup_controller(chip, azx_dev);
1468 dsp_unlock(azx_dev);
1469 return azx_dev->stream_tag;
1470
1471 error:
1472 chip->ops->dma_free_pages(chip, bufp);
1473 err_alloc:
1474 spin_lock_irq(&chip->reg_lock);
1475 if (azx_dev->opened)
1476 *azx_dev = chip->saved_azx_dev;
1477 azx_dev->locked = 0;
1478 spin_unlock_irq(&chip->reg_lock);
1479 unlock:
1480 dsp_unlock(azx_dev);
1481 return err;
1482}
1483
1484static void azx_load_dsp_trigger(struct hda_bus *bus, bool start)
1485{
1486 struct azx *chip = bus->private_data;
1487 struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
1488
1489 if (start)
1490 azx_stream_start(chip, azx_dev);
1491 else
1492 azx_stream_stop(chip, azx_dev);
1493 azx_dev->running = start;
1494}
1495
1496static void azx_load_dsp_cleanup(struct hda_bus *bus,
1497 struct snd_dma_buffer *dmab)
1498{
1499 struct azx *chip = bus->private_data;
1500 struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
1501
1502 if (!dmab->area || !azx_dev->locked)
1503 return;
1504
1505 dsp_lock(azx_dev);
1506 /* reset BDL address */
1507 azx_sd_writel(chip, azx_dev, SD_BDLPL, 0);
1508 azx_sd_writel(chip, azx_dev, SD_BDLPU, 0);
1509 azx_sd_writel(chip, azx_dev, SD_CTL, 0);
1510 azx_dev->bufsize = 0;
1511 azx_dev->period_bytes = 0;
1512 azx_dev->format_val = 0;
1513
1514 chip->ops->dma_free_pages(chip, dmab);
1515 dmab->area = NULL;
1516
1517 spin_lock_irq(&chip->reg_lock);
1518 if (azx_dev->opened)
1519 *azx_dev = chip->saved_azx_dev;
1520 azx_dev->locked = 0;
1521 spin_unlock_irq(&chip->reg_lock);
1522 dsp_unlock(azx_dev);
1523}
1524#endif /* CONFIG_SND_HDA_DSP_LOADER */
1525
1526int azx_alloc_stream_pages(struct azx *chip)
1527{
1528 int i, err;
1529 struct snd_card *card = chip->card;
1530
1531 for (i = 0; i < chip->num_streams; i++) {
1532 dsp_lock_init(&chip->azx_dev[i]);
1533 /* allocate memory for the BDL for each stream */
1534 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
1535 BDL_SIZE,
1536 &chip->azx_dev[i].bdl);
1537 if (err < 0) {
1538 dev_err(card->dev, "cannot allocate BDL\n");
1539 return -ENOMEM;
1540 }
1541 }
1542 /* allocate memory for the position buffer */
1543 err = chip->ops->dma_alloc_pages(chip, SNDRV_DMA_TYPE_DEV,
1544 chip->num_streams * 8, &chip->posbuf);
1545 if (err < 0) {
1546 dev_err(card->dev, "cannot allocate posbuf\n");
1547 return -ENOMEM;
1548 }
1549
1550 /* allocate CORB/RIRB */
1551 err = azx_alloc_cmd_io(chip);
1552 if (err < 0)
1553 return err;
1554 return 0;
1555}
1556EXPORT_SYMBOL_GPL(azx_alloc_stream_pages);
1557
1558void azx_free_stream_pages(struct azx *chip)
1559{
1560 int i;
1561 if (chip->azx_dev) {
1562 for (i = 0; i < chip->num_streams; i++)
1563 if (chip->azx_dev[i].bdl.area)
1564 chip->ops->dma_free_pages(
1565 chip, &chip->azx_dev[i].bdl);
1566 }
1567 if (chip->rb.area)
1568 chip->ops->dma_free_pages(chip, &chip->rb);
1569 if (chip->posbuf.area)
1570 chip->ops->dma_free_pages(chip, &chip->posbuf);
1571}
1572EXPORT_SYMBOL_GPL(azx_free_stream_pages);
1573
1574/*
1575 * Lowlevel interface
1576 */
1577
1578/* enter link reset */
1579void azx_enter_link_reset(struct azx *chip)
1580{
1581 unsigned long timeout;
1582
1583 /* reset controller */
1584 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_RESET);
1585
1586 timeout = jiffies + msecs_to_jiffies(100);
1587 while ((azx_readb(chip, GCTL) & ICH6_GCTL_RESET) &&
1588 time_before(jiffies, timeout))
1589 usleep_range(500, 1000);
1590}
1591EXPORT_SYMBOL_GPL(azx_enter_link_reset);
1592
1593/* exit link reset */
1594static void azx_exit_link_reset(struct azx *chip)
1595{
1596 unsigned long timeout;
1597
1598 azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET);
1599
1600 timeout = jiffies + msecs_to_jiffies(100);
1601 while (!azx_readb(chip, GCTL) &&
1602 time_before(jiffies, timeout))
1603 usleep_range(500, 1000);
1604}
1605
1606/* reset codec link */
1607static int azx_reset(struct azx *chip, int full_reset)
1608{
1609 if (!full_reset)
1610 goto __skip;
1611
1612 /* clear STATESTS */
1613 azx_writew(chip, STATESTS, STATESTS_INT_MASK);
1614
1615 /* reset controller */
1616 azx_enter_link_reset(chip);
1617
1618 /* delay for >= 100us for codec PLL to settle per spec
1619 * Rev 0.9 section 5.5.1
1620 */
1621 usleep_range(500, 1000);
1622
1623 /* Bring controller out of reset */
1624 azx_exit_link_reset(chip);
1625
1626 /* Brent Chartrand said to wait >= 540us for codecs to initialize */
1627 usleep_range(1000, 1200);
1628
1629 __skip:
1630 /* check to see if controller is ready */
1631 if (!azx_readb(chip, GCTL)) {
1632 dev_dbg(chip->card->dev, "azx_reset: controller not ready!\n");
1633 return -EBUSY;
1634 }
1635
1636 /* Accept unsolicited responses */
1637 if (!chip->single_cmd)
1638 azx_writel(chip, GCTL, azx_readl(chip, GCTL) |
1639 ICH6_GCTL_UNSOL);
1640
1641 /* detect codecs */
1642 if (!chip->codec_mask) {
1643 chip->codec_mask = azx_readw(chip, STATESTS);
1644 dev_dbg(chip->card->dev, "codec_mask = 0x%x\n",
1645 chip->codec_mask);
1646 }
1647
1648 return 0;
1649}
1650
1651/* enable interrupts */
1652static void azx_int_enable(struct azx *chip)
1653{
1654 /* enable controller CIE and GIE */
1655 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) |
1656 ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN);
1657}
1658
1659/* disable interrupts */
1660static void azx_int_disable(struct azx *chip)
1661{
1662 int i;
1663
1664 /* disable interrupts in stream descriptor */
1665 for (i = 0; i < chip->num_streams; i++) {
1666 struct azx_dev *azx_dev = &chip->azx_dev[i];
1667 azx_sd_writeb(chip, azx_dev, SD_CTL,
1668 azx_sd_readb(chip, azx_dev, SD_CTL) &
1669 ~SD_INT_MASK);
1670 }
1671
1672 /* disable SIE for all streams */
1673 azx_writeb(chip, INTCTL, 0);
1674
1675 /* disable controller CIE and GIE */
1676 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) &
1677 ~(ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN));
1678}
1679
1680/* clear interrupts */
1681static void azx_int_clear(struct azx *chip)
1682{
1683 int i;
1684
1685 /* clear stream status */
1686 for (i = 0; i < chip->num_streams; i++) {
1687 struct azx_dev *azx_dev = &chip->azx_dev[i];
1688 azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK);
1689 }
1690
1691 /* clear STATESTS */
1692 azx_writew(chip, STATESTS, STATESTS_INT_MASK);
1693
1694 /* clear rirb status */
1695 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
1696
1697 /* clear int status */
1698 azx_writel(chip, INTSTS, ICH6_INT_CTRL_EN | ICH6_INT_ALL_STREAM);
1699}
1700
1701/*
1702 * reset and start the controller registers
1703 */
1704void azx_init_chip(struct azx *chip, int full_reset)
1705{
1706 if (chip->initialized)
1707 return;
1708
1709 /* reset controller */
1710 azx_reset(chip, full_reset);
1711
1712 /* initialize interrupts */
1713 azx_int_clear(chip);
1714 azx_int_enable(chip);
1715
1716 /* initialize the codec command I/O */
1717 if (!chip->single_cmd)
1718 azx_init_cmd_io(chip);
1719
1720 /* program the position buffer */
1721 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
1722 azx_writel(chip, DPUBASE, upper_32_bits(chip->posbuf.addr));
1723
1724 chip->initialized = 1;
1725}
1726EXPORT_SYMBOL_GPL(azx_init_chip);
1727
1728void azx_stop_chip(struct azx *chip)
1729{
1730 if (!chip->initialized)
1731 return;
1732
1733 /* disable interrupts */
1734 azx_int_disable(chip);
1735 azx_int_clear(chip);
1736
1737 /* disable CORB/RIRB */
1738 azx_free_cmd_io(chip);
1739
1740 /* disable position buffer */
1741 azx_writel(chip, DPLBASE, 0);
1742 azx_writel(chip, DPUBASE, 0);
1743
1744 chip->initialized = 0;
1745}
1746EXPORT_SYMBOL_GPL(azx_stop_chip);
1747
1748/*
1749 * interrupt handler
1750 */
1751irqreturn_t azx_interrupt(int irq, void *dev_id)
1752{
1753 struct azx *chip = dev_id;
1754 struct azx_dev *azx_dev;
1755 u32 status;
1756 u8 sd_status;
1757 int i;
1758
1759#ifdef CONFIG_PM_RUNTIME
1760 if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME)
1761 if (chip->card->dev->power.runtime_status != RPM_ACTIVE)
1762 return IRQ_NONE;
1763#endif
1764
1765 spin_lock(&chip->reg_lock);
1766
1767 if (chip->disabled) {
1768 spin_unlock(&chip->reg_lock);
1769 return IRQ_NONE;
1770 }
1771
1772 status = azx_readl(chip, INTSTS);
1773 if (status == 0 || status == 0xffffffff) {
1774 spin_unlock(&chip->reg_lock);
1775 return IRQ_NONE;
1776 }
1777
1778 for (i = 0; i < chip->num_streams; i++) {
1779 azx_dev = &chip->azx_dev[i];
1780 if (status & azx_dev->sd_int_sta_mask) {
1781 sd_status = azx_sd_readb(chip, azx_dev, SD_STS);
1782 azx_sd_writeb(chip, azx_dev, SD_STS, SD_INT_MASK);
1783 if (!azx_dev->substream || !azx_dev->running ||
1784 !(sd_status & SD_INT_COMPLETE))
1785 continue;
1786 /* check whether this IRQ is really acceptable */
1787 if (!chip->ops->position_check ||
1788 chip->ops->position_check(chip, azx_dev)) {
1789 spin_unlock(&chip->reg_lock);
1790 snd_pcm_period_elapsed(azx_dev->substream);
1791 spin_lock(&chip->reg_lock);
1792 }
1793 }
1794 }
1795
1796 /* clear rirb int */
1797 status = azx_readb(chip, RIRBSTS);
1798 if (status & RIRB_INT_MASK) {
1799 if (status & RIRB_INT_RESPONSE) {
1800 if (chip->driver_caps & AZX_DCAPS_RIRB_PRE_DELAY)
1801 udelay(80);
1802 azx_update_rirb(chip);
1803 }
1804 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
1805 }
1806
1807 spin_unlock(&chip->reg_lock);
1808
1809 return IRQ_HANDLED;
1810}
1811EXPORT_SYMBOL_GPL(azx_interrupt);
1812
1813/*
1814 * Codec initerface
1815 */
1816
1817/*
1818 * Probe the given codec address
1819 */
1820static int probe_codec(struct azx *chip, int addr)
1821{
1822 unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
1823 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
1824 unsigned int res;
1825
1826 mutex_lock(&chip->bus->cmd_mutex);
1827 chip->probing = 1;
1828 azx_send_cmd(chip->bus, cmd);
1829 res = azx_get_response(chip->bus, addr);
1830 chip->probing = 0;
1831 mutex_unlock(&chip->bus->cmd_mutex);
1832 if (res == -1)
1833 return -EIO;
1834 dev_dbg(chip->card->dev, "codec #%d probed OK\n", addr);
1835 return 0;
1836}
1837
1838static void azx_bus_reset(struct hda_bus *bus)
1839{
1840 struct azx *chip = bus->private_data;
1841
1842 bus->in_reset = 1;
1843 azx_stop_chip(chip);
1844 azx_init_chip(chip, 1);
1845#ifdef CONFIG_PM
1846 if (chip->initialized) {
1847 struct azx_pcm *p;
1848 list_for_each_entry(p, &chip->pcm_list, list)
1849 snd_pcm_suspend_all(p->pcm);
1850 snd_hda_suspend(chip->bus);
1851 snd_hda_resume(chip->bus);
1852 }
1853#endif
1854 bus->in_reset = 0;
1855}
1856
1857#ifdef CONFIG_PM
1858/* power-up/down the controller */
1859static void azx_power_notify(struct hda_bus *bus, bool power_up)
1860{
1861 struct azx *chip = bus->private_data;
1862
1863 if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
1864 return;
1865
1866 if (power_up)
1867 pm_runtime_get_sync(chip->card->dev);
1868 else
1869 pm_runtime_put_sync(chip->card->dev);
1870}
1871#endif
1872
1873static int get_jackpoll_interval(struct azx *chip)
1874{
1875 int i;
1876 unsigned int j;
1877
1878 if (!chip->jackpoll_ms)
1879 return 0;
1880
1881 i = chip->jackpoll_ms[chip->dev_index];
1882 if (i == 0)
1883 return 0;
1884 if (i < 50 || i > 60000)
1885 j = 0;
1886 else
1887 j = msecs_to_jiffies(i);
1888 if (j == 0)
1889 dev_warn(chip->card->dev,
1890 "jackpoll_ms value out of range: %d\n", i);
1891 return j;
1892}
1893
1894/* Codec initialization */
1895int azx_codec_create(struct azx *chip, const char *model,
1896 unsigned int max_slots,
1897 int *power_save_to)
1898{
1899 struct hda_bus_template bus_temp;
1900 int c, codecs, err;
1901
1902 memset(&bus_temp, 0, sizeof(bus_temp));
1903 bus_temp.private_data = chip;
1904 bus_temp.modelname = model;
1905 bus_temp.pci = chip->pci;
1906 bus_temp.ops.command = azx_send_cmd;
1907 bus_temp.ops.get_response = azx_get_response;
1908 bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
1909 bus_temp.ops.bus_reset = azx_bus_reset;
1910#ifdef CONFIG_PM
1911 bus_temp.power_save = power_save_to;
1912 bus_temp.ops.pm_notify = azx_power_notify;
1913#endif
1914#ifdef CONFIG_SND_HDA_DSP_LOADER
1915 bus_temp.ops.load_dsp_prepare = azx_load_dsp_prepare;
1916 bus_temp.ops.load_dsp_trigger = azx_load_dsp_trigger;
1917 bus_temp.ops.load_dsp_cleanup = azx_load_dsp_cleanup;
1918#endif
1919
1920 err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus);
1921 if (err < 0)
1922 return err;
1923
1924 if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) {
1925 dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");
1926 chip->bus->needs_damn_long_delay = 1;
1927 }
1928
1929 codecs = 0;
1930 if (!max_slots)
1931 max_slots = AZX_DEFAULT_CODECS;
1932
1933 /* First try to probe all given codec slots */
1934 for (c = 0; c < max_slots; c++) {
1935 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1936 if (probe_codec(chip, c) < 0) {
1937 /* Some BIOSen give you wrong codec addresses
1938 * that don't exist
1939 */
1940 dev_warn(chip->card->dev,
1941 "Codec #%d probe error; disabling it...\n", c);
1942 chip->codec_mask &= ~(1 << c);
1943 /* More badly, accessing to a non-existing
1944 * codec often screws up the controller chip,
1945 * and disturbs the further communications.
1946 * Thus if an error occurs during probing,
1947 * better to reset the controller chip to
1948 * get back to the sanity state.
1949 */
1950 azx_stop_chip(chip);
1951 azx_init_chip(chip, 1);
1952 }
1953 }
1954 }
1955
1956 /* AMD chipsets often cause the communication stalls upon certain
1957 * sequence like the pin-detection. It seems that forcing the synced
1958 * access works around the stall. Grrr...
1959 */
1960 if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
1961 dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n");
1962 chip->bus->sync_write = 1;
1963 chip->bus->allow_bus_reset = 1;
1964 }
1965
1966 /* Then create codec instances */
1967 for (c = 0; c < max_slots; c++) {
1968 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1969 struct hda_codec *codec;
1970 err = snd_hda_codec_new(chip->bus, c, &codec);
1971 if (err < 0)
1972 continue;
1973 codec->jackpoll_interval = get_jackpoll_interval(chip);
1974 codec->beep_mode = chip->beep_mode;
1975 codecs++;
1976 }
1977 }
1978 if (!codecs) {
1979 dev_err(chip->card->dev, "no codecs initialized\n");
1980 return -ENXIO;
1981 }
1982 return 0;
1983}
1984EXPORT_SYMBOL_GPL(azx_codec_create);
1985
1986/* configure each codec instance */
1987int azx_codec_configure(struct azx *chip)
1988{
1989 struct hda_codec *codec;
1990 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1991 snd_hda_codec_configure(codec);
1992 }
1993 return 0;
1994}
1995EXPORT_SYMBOL_GPL(azx_codec_configure);
1996
1997/* mixer creation - all stuff is implemented in hda module */
1998int azx_mixer_create(struct azx *chip)
1999{
2000 return snd_hda_build_controls(chip->bus);
2001}
2002EXPORT_SYMBOL_GPL(azx_mixer_create);
2003
2004
2005/* initialize SD streams */
2006int azx_init_stream(struct azx *chip)
2007{
2008 int i;
2009
2010 /* initialize each stream (aka device)
2011 * assign the starting bdl address to each stream (device)
2012 * and initialize
2013 */
2014 for (i = 0; i < chip->num_streams; i++) {
2015 struct azx_dev *azx_dev = &chip->azx_dev[i];
2016 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
2017 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
2018 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
2019 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
2020 azx_dev->sd_int_sta_mask = 1 << i;
2021 /* stream tag: must be non-zero and unique */
2022 azx_dev->index = i;
2023 azx_dev->stream_tag = i + 1;
2024 }
2025
2026 return 0;
2027}
2028EXPORT_SYMBOL_GPL(azx_init_stream);
2029
2030MODULE_LICENSE("GPL");
2031MODULE_DESCRIPTION("Common HDA driver funcitons");
diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
new file mode 100644
index 000000000000..1d2e3be2bae6
--- /dev/null
+++ b/sound/pci/hda/hda_controller.h
@@ -0,0 +1,53 @@
1/*
2 * Common functionality for the alsa driver code base for HD Audio.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */
14
15#ifndef __SOUND_HDA_CONTROLLER_H
16#define __SOUND_HDA_CONTROLLER_H
17
18#include <sound/core.h>
19#include <sound/initval.h>
20#include "hda_codec.h"
21#include "hda_priv.h"
22
23/* PCM setup */
24static inline struct azx_dev *get_azx_dev(struct snd_pcm_substream *substream)
25{
26 return substream->runtime->private_data;
27}
28unsigned int azx_get_position(struct azx *chip,
29 struct azx_dev *azx_dev,
30 bool with_check);
31
32/* Stream control. */
33void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev);
34
35/* Allocation functions. */
36int azx_alloc_stream_pages(struct azx *chip);
37void azx_free_stream_pages(struct azx *chip);
38
39/* Low level azx interface */
40void azx_init_chip(struct azx *chip, int full_reset);
41void azx_stop_chip(struct azx *chip);
42void azx_enter_link_reset(struct azx *chip);
43irqreturn_t azx_interrupt(int irq, void *dev_id);
44
45/* Codec interface */
46int azx_codec_create(struct azx *chip, const char *model,
47 unsigned int max_slots,
48 int *power_save_to);
49int azx_codec_configure(struct azx *chip);
50int azx_mixer_create(struct azx *chip);
51int azx_init_stream(struct azx *chip);
52
53#endif /* __SOUND_HDA_CONTROLLER_H */
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c
index 79ca80f6c77a..46690a7f48f6 100644
--- a/sound/pci/hda/hda_eld.c
+++ b/sound/pci/hda/hda_eld.c
@@ -153,7 +153,7 @@ static unsigned int hdmi_get_eld_data(struct hda_codec *codec, hda_nid_t nid,
153 val = snd_hda_codec_read(codec, nid, 0, 153 val = snd_hda_codec_read(codec, nid, 0,
154 AC_VERB_GET_HDMI_ELDD, byte_index); 154 AC_VERB_GET_HDMI_ELDD, byte_index);
155#ifdef BE_PARANOID 155#ifdef BE_PARANOID
156 printk(KERN_INFO "HDMI: ELD data byte %d: 0x%x\n", byte_index, val); 156 codec_info(codec, "HDMI: ELD data byte %d: 0x%x\n", byte_index, val);
157#endif 157#endif
158 return val; 158 return val;
159} 159}
@@ -332,11 +332,11 @@ int snd_hdmi_get_eld(struct hda_codec *codec, hda_nid_t nid,
332 size = snd_hdmi_get_eld_size(codec, nid); 332 size = snd_hdmi_get_eld_size(codec, nid);
333 if (size == 0) { 333 if (size == 0) {
334 /* wfg: workaround for ASUS P5E-VM HDMI board */ 334 /* wfg: workaround for ASUS P5E-VM HDMI board */
335 snd_printd(KERN_INFO "HDMI: ELD buf size is 0, force 128\n"); 335 codec_info(codec, "HDMI: ELD buf size is 0, force 128\n");
336 size = 128; 336 size = 128;
337 } 337 }
338 if (size < ELD_FIXED_BYTES || size > ELD_MAX_SIZE) { 338 if (size < ELD_FIXED_BYTES || size > ELD_MAX_SIZE) {
339 snd_printd(KERN_INFO "HDMI: invalid ELD buf size %d\n", size); 339 codec_info(codec, "HDMI: invalid ELD buf size %d\n", size);
340 return -ERANGE; 340 return -ERANGE;
341 } 341 }
342 342
@@ -348,8 +348,7 @@ int snd_hdmi_get_eld(struct hda_codec *codec, hda_nid_t nid,
348 * Just abort. The caller will repoll after a while. 348 * Just abort. The caller will repoll after a while.
349 */ 349 */
350 if (!(val & AC_ELDD_ELD_VALID)) { 350 if (!(val & AC_ELDD_ELD_VALID)) {
351 snd_printd(KERN_INFO 351 codec_info(codec, "HDMI: invalid ELD data byte %d\n", i);
352 "HDMI: invalid ELD data byte %d\n", i);
353 ret = -EINVAL; 352 ret = -EINVAL;
354 goto error; 353 goto error;
355 } 354 }
@@ -361,7 +360,7 @@ int snd_hdmi_get_eld(struct hda_codec *codec, hda_nid_t nid,
361 * correctly writes ELD content before setting ELD_valid bit. 360 * correctly writes ELD content before setting ELD_valid bit.
362 */ 361 */
363 if (!val && !i) { 362 if (!val && !i) {
364 snd_printdd(KERN_INFO "HDMI: 0 ELD data\n"); 363 codec_dbg(codec, "HDMI: 0 ELD data\n");
365 ret = -EINVAL; 364 ret = -EINVAL;
366 goto error; 365 goto error;
367 } 366 }
@@ -681,7 +680,7 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
681 spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0); 680 spkalloc = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SPEAKER_ALLOCATION, 0);
682 681
683 if (spkalloc <= 0) { 682 if (spkalloc <= 0) {
684 snd_printd(KERN_INFO "HDMI ATI/AMD: no speaker allocation for ELD\n"); 683 codec_info(codec, "HDMI ATI/AMD: no speaker allocation for ELD\n");
685 return -EINVAL; 684 return -EINVAL;
686 } 685 }
687 686
@@ -722,7 +721,7 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
722 sink_desc_len = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0); 721 sink_desc_len = snd_hda_codec_read(codec, nid, 0, ATI_VERB_GET_SINK_INFO_DATA, 0);
723 722
724 if (sink_desc_len > ELD_MAX_MNL) { 723 if (sink_desc_len > ELD_MAX_MNL) {
725 snd_printd(KERN_INFO "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n", 724 codec_info(codec, "HDMI ATI/AMD: Truncating HDMI sink description with length %d\n",
726 sink_desc_len); 725 sink_desc_len);
727 sink_desc_len = ELD_MAX_MNL; 726 sink_desc_len = ELD_MAX_MNL;
728 } 727 }
@@ -764,7 +763,7 @@ int snd_hdmi_get_eld_ati(struct hda_codec *codec, hda_nid_t nid,
764 } 763 }
765 764
766 if (pos == ELD_FIXED_BYTES + sink_desc_len) { 765 if (pos == ELD_FIXED_BYTES + sink_desc_len) {
767 snd_printd(KERN_INFO "HDMI ATI/AMD: no audio descriptors for ELD\n"); 766 codec_info(codec, "HDMI ATI/AMD: no audio descriptors for ELD\n");
768 return -EINVAL; 767 return -EINVAL;
769 } 768 }
770 769
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index d9a09bdd09db..16133881e967 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -79,7 +79,7 @@ static void free_kctls(struct hda_gen_spec *spec)
79 snd_array_free(&spec->kctls); 79 snd_array_free(&spec->kctls);
80} 80}
81 81
82void snd_hda_gen_spec_free(struct hda_gen_spec *spec) 82static void snd_hda_gen_spec_free(struct hda_gen_spec *spec)
83{ 83{
84 if (!spec) 84 if (!spec)
85 return; 85 return;
@@ -87,7 +87,6 @@ void snd_hda_gen_spec_free(struct hda_gen_spec *spec)
87 snd_array_free(&spec->paths); 87 snd_array_free(&spec->paths);
88 snd_array_free(&spec->loopback_list); 88 snd_array_free(&spec->loopback_list);
89} 89}
90EXPORT_SYMBOL_GPL(snd_hda_gen_spec_free);
91 90
92/* 91/*
93 * store user hints 92 * store user hints
@@ -347,7 +346,8 @@ static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid,
347 return is_ctl_used(codec, val, type); 346 return is_ctl_used(codec, val, type);
348} 347}
349 348
350static void print_nid_path(const char *pfx, struct nid_path *path) 349static void print_nid_path(struct hda_codec *codec,
350 const char *pfx, struct nid_path *path)
351{ 351{
352 char buf[40]; 352 char buf[40];
353 int i; 353 int i;
@@ -359,7 +359,7 @@ static void print_nid_path(const char *pfx, struct nid_path *path)
359 sprintf(tmp, ":%02x", path->path[i]); 359 sprintf(tmp, ":%02x", path->path[i]);
360 strlcat(buf, tmp, sizeof(buf)); 360 strlcat(buf, tmp, sizeof(buf));
361 } 361 }
362 snd_printdd("%s path: depth=%d %s\n", pfx, path->depth, buf); 362 codec_dbg(codec, "%s path: depth=%d %s\n", pfx, path->depth, buf);
363} 363}
364 364
365/* called recursively */ 365/* called recursively */
@@ -762,7 +762,7 @@ void snd_hda_activate_path(struct hda_codec *codec, struct nid_path *path,
762 AC_PWRST_D0); 762 AC_PWRST_D0);
763 } 763 }
764 if (enable && path->multi[i]) 764 if (enable && path->multi[i])
765 snd_hda_codec_write_cache(codec, nid, 0, 765 snd_hda_codec_update_cache(codec, nid, 0,
766 AC_VERB_SET_CONNECT_SEL, 766 AC_VERB_SET_CONNECT_SEL,
767 path->idx[i]); 767 path->idx[i]);
768 if (has_amp_in(codec, path, i)) 768 if (has_amp_in(codec, path, i))
@@ -1261,7 +1261,7 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
1261 dac = dacs[i] = 0; 1261 dac = dacs[i] = 0;
1262 badness += bad->no_dac; 1262 badness += bad->no_dac;
1263 } else { 1263 } else {
1264 /* print_nid_path("output", path); */ 1264 /* print_nid_path(codec, "output", path); */
1265 path->active = true; 1265 path->active = true;
1266 path_idx[i] = snd_hda_get_path_idx(codec, path); 1266 path_idx[i] = snd_hda_get_path_idx(codec, path);
1267 badness += assign_out_path_ctls(codec, path); 1267 badness += assign_out_path_ctls(codec, path);
@@ -1388,7 +1388,7 @@ static int fill_multi_ios(struct hda_codec *codec,
1388 badness++; 1388 badness++;
1389 continue; 1389 continue;
1390 } 1390 }
1391 /* print_nid_path("multiio", path); */ 1391 /* print_nid_path(codec, "multiio", path); */
1392 spec->multi_io[spec->multi_ios].pin = nid; 1392 spec->multi_io[spec->multi_ios].pin = nid;
1393 spec->multi_io[spec->multi_ios].dac = dac; 1393 spec->multi_io[spec->multi_ios].dac = dac;
1394 spec->out_paths[cfg->line_outs + spec->multi_ios] = 1394 spec->out_paths[cfg->line_outs + spec->multi_ios] =
@@ -1445,7 +1445,7 @@ static bool map_singles(struct hda_codec *codec, int outs,
1445 if (path) { 1445 if (path) {
1446 dacs[i] = dac; 1446 dacs[i] = dac;
1447 found = true; 1447 found = true;
1448 /* print_nid_path("output", path); */ 1448 /* print_nid_path(codec, "output", path); */
1449 path->active = true; 1449 path->active = true;
1450 path_idx[i] = snd_hda_get_path_idx(codec, path); 1450 path_idx[i] = snd_hda_get_path_idx(codec, path);
1451 } 1451 }
@@ -1483,7 +1483,7 @@ static int check_aamix_out_path(struct hda_codec *codec, int path_idx)
1483 } 1483 }
1484 if (!path) 1484 if (!path)
1485 return 0; 1485 return 0;
1486 /* print_nid_path("output-aamix", path); */ 1486 /* print_nid_path(codec, "output-aamix", path); */
1487 path->active = false; /* unused as default */ 1487 path->active = false; /* unused as default */
1488 return snd_hda_get_path_idx(codec, path); 1488 return snd_hda_get_path_idx(codec, path);
1489} 1489}
@@ -1700,7 +1700,7 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
1700#define DEBUG_BADNESS 1700#define DEBUG_BADNESS
1701 1701
1702#ifdef DEBUG_BADNESS 1702#ifdef DEBUG_BADNESS
1703#define debug_badness snd_printdd 1703#define debug_badness(fmt, args...) codec_dbg(codec, fmt, ##args)
1704#else 1704#else
1705#define debug_badness(...) 1705#define debug_badness(...)
1706#endif 1706#endif
@@ -1713,7 +1713,7 @@ static inline void print_nid_path_idx(struct hda_codec *codec,
1713 1713
1714 path = snd_hda_get_path_from_idx(codec, idx); 1714 path = snd_hda_get_path_from_idx(codec, idx);
1715 if (path) 1715 if (path)
1716 print_nid_path(pfx, path); 1716 print_nid_path(codec, pfx, path);
1717} 1717}
1718 1718
1719static void debug_show_configs(struct hda_codec *codec, 1719static void debug_show_configs(struct hda_codec *codec,
@@ -1781,7 +1781,7 @@ static void fill_all_dac_nids(struct hda_codec *codec)
1781 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) 1781 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT)
1782 continue; 1782 continue;
1783 if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { 1783 if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) {
1784 snd_printk(KERN_ERR "hda: Too many DACs!\n"); 1784 codec_err(codec, "Too many DACs!\n");
1785 break; 1785 break;
1786 } 1786 }
1787 spec->all_dacs[spec->num_all_dacs++] = nid; 1787 spec->all_dacs[spec->num_all_dacs++] = nid;
@@ -2430,7 +2430,7 @@ static int create_hp_mic(struct hda_codec *codec)
2430 spec->hp_mic_pin = nid; 2430 spec->hp_mic_pin = nid;
2431 /* we can't handle auto-mic together with HP-mic */ 2431 /* we can't handle auto-mic together with HP-mic */
2432 spec->suppress_auto_mic = 1; 2432 spec->suppress_auto_mic = 1;
2433 snd_printdd("hda-codec: Enable shared I/O jack on NID 0x%x\n", nid); 2433 codec_dbg(codec, "Enable shared I/O jack on NID 0x%x\n", nid);
2434 return 0; 2434 return 0;
2435} 2435}
2436 2436
@@ -2884,7 +2884,7 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
2884 path = snd_hda_add_new_path(codec, pin, mix_nid, 0); 2884 path = snd_hda_add_new_path(codec, pin, mix_nid, 0);
2885 if (!path) 2885 if (!path)
2886 return -EINVAL; 2886 return -EINVAL;
2887 print_nid_path("loopback", path); 2887 print_nid_path(codec, "loopback", path);
2888 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path); 2888 spec->loopback_paths[input_idx] = snd_hda_get_path_idx(codec, path);
2889 2889
2890 idx = path->idx[path->depth - 1]; 2890 idx = path->idx[path->depth - 1];
@@ -2912,7 +2912,7 @@ static int new_analog_input(struct hda_codec *codec, int input_idx,
2912 path = snd_hda_add_new_path(codec, spec->mixer_nid, 2912 path = snd_hda_add_new_path(codec, spec->mixer_nid,
2913 spec->mixer_merge_nid, 0); 2913 spec->mixer_merge_nid, 0);
2914 if (path) { 2914 if (path) {
2915 print_nid_path("loopback-merge", path); 2915 print_nid_path(codec, "loopback-merge", path);
2916 path->active = true; 2916 path->active = true;
2917 spec->loopback_merge_path = 2917 spec->loopback_merge_path =
2918 snd_hda_get_path_idx(codec, path); 2918 snd_hda_get_path_idx(codec, path);
@@ -2991,7 +2991,7 @@ static int check_dyn_adc_switch(struct hda_codec *codec)
2991 } 2991 }
2992 } 2992 }
2993 2993
2994 snd_printdd("hda-codec: enabling ADC switching\n"); 2994 codec_dbg(codec, "enabling ADC switching\n");
2995 spec->dyn_adc_switch = 1; 2995 spec->dyn_adc_switch = 1;
2996 } else if (nums != spec->num_adc_nids) { 2996 } else if (nums != spec->num_adc_nids) {
2997 /* shrink the invalid adcs and input paths */ 2997 /* shrink the invalid adcs and input paths */
@@ -3015,7 +3015,7 @@ static int check_dyn_adc_switch(struct hda_codec *codec)
3015 3015
3016 if (imux->num_items == 1 || 3016 if (imux->num_items == 1 ||
3017 (imux->num_items == 2 && spec->hp_mic)) { 3017 (imux->num_items == 2 && spec->hp_mic)) {
3018 snd_printdd("hda-codec: reducing to a single ADC\n"); 3018 codec_dbg(codec, "reducing to a single ADC\n");
3019 spec->num_adc_nids = 1; /* reduce to a single ADC */ 3019 spec->num_adc_nids = 1; /* reduce to a single ADC */
3020 } 3020 }
3021 3021
@@ -3046,7 +3046,7 @@ static int parse_capture_source(struct hda_codec *codec, hda_nid_t pin,
3046 path = snd_hda_add_new_path(codec, pin, adc, anchor); 3046 path = snd_hda_add_new_path(codec, pin, adc, anchor);
3047 if (!path) 3047 if (!path)
3048 continue; 3048 continue;
3049 print_nid_path("input", path); 3049 print_nid_path(codec, "input", path);
3050 spec->input_paths[imux_idx][c] = 3050 spec->input_paths[imux_idx][c] =
3051 snd_hda_get_path_idx(codec, path); 3051 snd_hda_get_path_idx(codec, path);
3052 3052
@@ -3712,7 +3712,7 @@ static void parse_digital(struct hda_codec *codec)
3712 path = snd_hda_add_new_path(codec, dig_nid, pin, 0); 3712 path = snd_hda_add_new_path(codec, dig_nid, pin, 0);
3713 if (!path) 3713 if (!path)
3714 continue; 3714 continue;
3715 print_nid_path("digout", path); 3715 print_nid_path(codec, "digout", path);
3716 path->active = true; 3716 path->active = true;
3717 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path); 3717 spec->digout_paths[i] = snd_hda_get_path_idx(codec, path);
3718 set_pin_target(codec, pin, PIN_OUT, false); 3718 set_pin_target(codec, pin, PIN_OUT, false);
@@ -3739,7 +3739,7 @@ static void parse_digital(struct hda_codec *codec)
3739 continue; 3739 continue;
3740 path = snd_hda_add_new_path(codec, pin, dig_nid, 0); 3740 path = snd_hda_add_new_path(codec, pin, dig_nid, 0);
3741 if (path) { 3741 if (path) {
3742 print_nid_path("digin", path); 3742 print_nid_path(codec, "digin", path);
3743 path->active = true; 3743 path->active = true;
3744 spec->dig_in_nid = dig_nid; 3744 spec->dig_in_nid = dig_nid;
3745 spec->digin_path = snd_hda_get_path_idx(codec, path); 3745 spec->digin_path = snd_hda_get_path_idx(codec, path);
@@ -4170,8 +4170,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
4170 hda_nid_t nid = cfg->hp_pins[i]; 4170 hda_nid_t nid = cfg->hp_pins[i];
4171 if (!is_jack_detectable(codec, nid)) 4171 if (!is_jack_detectable(codec, nid))
4172 continue; 4172 continue;
4173 snd_printdd("hda-codec: Enable HP auto-muting on NID 0x%x\n", 4173 codec_dbg(codec, "Enable HP auto-muting on NID 0x%x\n", nid);
4174 nid);
4175 snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT, 4174 snd_hda_jack_detect_enable_callback(codec, nid, HDA_GEN_HP_EVENT,
4176 call_hp_automute); 4175 call_hp_automute);
4177 spec->detect_hp = 1; 4176 spec->detect_hp = 1;
@@ -4183,7 +4182,7 @@ static int check_auto_mute_availability(struct hda_codec *codec)
4183 hda_nid_t nid = cfg->line_out_pins[i]; 4182 hda_nid_t nid = cfg->line_out_pins[i];
4184 if (!is_jack_detectable(codec, nid)) 4183 if (!is_jack_detectable(codec, nid))
4185 continue; 4184 continue;
4186 snd_printdd("hda-codec: Enable Line-Out auto-muting on NID 0x%x\n", nid); 4185 codec_dbg(codec, "Enable Line-Out auto-muting on NID 0x%x\n", nid);
4187 snd_hda_jack_detect_enable_callback(codec, nid, 4186 snd_hda_jack_detect_enable_callback(codec, nid,
4188 HDA_GEN_FRONT_EVENT, 4187 HDA_GEN_FRONT_EVENT,
4189 call_line_automute); 4188 call_line_automute);
@@ -4303,7 +4302,7 @@ static int check_auto_mic_availability(struct hda_codec *codec)
4303 spec->auto_mic = 1; 4302 spec->auto_mic = 1;
4304 spec->num_adc_nids = 1; 4303 spec->num_adc_nids = 1;
4305 spec->cur_mux[0] = spec->am_entry[0].idx; 4304 spec->cur_mux[0] = spec->am_entry[0].idx;
4306 snd_printdd("hda-codec: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", 4305 codec_dbg(codec, "Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n",
4307 spec->am_entry[0].pin, 4306 spec->am_entry[0].pin,
4308 spec->am_entry[1].pin, 4307 spec->am_entry[1].pin,
4309 spec->am_entry[2].pin); 4308 spec->am_entry[2].pin);
@@ -5350,7 +5349,7 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_init);
5350 */ 5349 */
5351void snd_hda_gen_free(struct hda_codec *codec) 5350void snd_hda_gen_free(struct hda_codec *codec)
5352{ 5351{
5353 snd_hda_detach_beep_device(codec); 5352 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
5354 snd_hda_gen_spec_free(codec->spec); 5353 snd_hda_gen_spec_free(codec->spec);
5355 kfree(codec->spec); 5354 kfree(codec->spec);
5356 codec->spec = NULL; 5355 codec->spec = NULL;
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
index c908afbe4d94..bb2dea743986 100644
--- a/sound/pci/hda/hda_generic.h
+++ b/sound/pci/hda/hda_generic.h
@@ -297,7 +297,6 @@ struct hda_gen_spec {
297}; 297};
298 298
299int snd_hda_gen_spec_init(struct hda_gen_spec *spec); 299int snd_hda_gen_spec_init(struct hda_gen_spec *spec);
300void snd_hda_gen_spec_free(struct hda_gen_spec *spec);
301 300
302int snd_hda_gen_init(struct hda_codec *codec); 301int snd_hda_gen_init(struct hda_codec *codec);
303void snd_hda_gen_free(struct hda_codec *codec); 302void snd_hda_gen_free(struct hda_codec *codec);
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index 72d8389fb399..014a7849e8fd 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -20,24 +20,13 @@
20 20
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/pci.h>
24#include <linux/compat.h> 23#include <linux/compat.h>
25#include <linux/mutex.h>
26#include <linux/ctype.h>
27#include <linux/string.h>
28#include <linux/export.h>
29#include <sound/core.h> 24#include <sound/core.h>
30#include "hda_codec.h" 25#include "hda_codec.h"
31#include "hda_local.h" 26#include "hda_local.h"
32#include <sound/hda_hwdep.h> 27#include <sound/hda_hwdep.h>
33#include <sound/minors.h> 28#include <sound/minors.h>
34 29
35/* hint string pair */
36struct hda_hint {
37 const char *key;
38 const char *val; /* contained in the same alloc as key */
39};
40
41/* 30/*
42 * write/read an out-of-bound verb 31 * write/read an out-of-bound verb
43 */ 32 */
@@ -105,26 +94,6 @@ static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
105 return 0; 94 return 0;
106} 95}
107 96
108static void clear_hwdep_elements(struct hda_codec *codec)
109{
110 int i;
111
112 /* clear init verbs */
113 snd_array_free(&codec->init_verbs);
114 /* clear hints */
115 for (i = 0; i < codec->hints.used; i++) {
116 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
117 kfree(hint->key); /* we don't need to free hint->val */
118 }
119 snd_array_free(&codec->hints);
120 snd_array_free(&codec->user_pins);
121}
122
123static void hwdep_free(struct snd_hwdep *hwdep)
124{
125 clear_hwdep_elements(hwdep->private_data);
126}
127
128int snd_hda_create_hwdep(struct hda_codec *codec) 97int snd_hda_create_hwdep(struct hda_codec *codec)
129{ 98{
130 char hwname[16]; 99 char hwname[16];
@@ -139,8 +108,8 @@ int snd_hda_create_hwdep(struct hda_codec *codec)
139 sprintf(hwdep->name, "HDA Codec %d", codec->addr); 108 sprintf(hwdep->name, "HDA Codec %d", codec->addr);
140 hwdep->iface = SNDRV_HWDEP_IFACE_HDA; 109 hwdep->iface = SNDRV_HWDEP_IFACE_HDA;
141 hwdep->private_data = codec; 110 hwdep->private_data = codec;
142 hwdep->private_free = hwdep_free;
143 hwdep->exclusive = 1; 111 hwdep->exclusive = 1;
112 hwdep->groups = snd_hda_dev_attr_groups;
144 113
145 hwdep->ops.open = hda_hwdep_open; 114 hwdep->ops.open = hda_hwdep_open;
146 hwdep->ops.ioctl = hda_hwdep_ioctl; 115 hwdep->ops.ioctl = hda_hwdep_ioctl;
@@ -148,740 +117,8 @@ int snd_hda_create_hwdep(struct hda_codec *codec)
148 hwdep->ops.ioctl_compat = hda_hwdep_ioctl_compat; 117 hwdep->ops.ioctl_compat = hda_hwdep_ioctl_compat;
149#endif 118#endif
150 119
151 mutex_init(&codec->user_mutex); 120 /* link to codec */
152 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32); 121 hwdep->dev = &codec->dev;
153 snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
154 snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
155
156 return 0;
157}
158
159#ifdef CONFIG_PM
160static ssize_t power_on_acct_show(struct device *dev,
161 struct device_attribute *attr,
162 char *buf)
163{
164 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
165 struct hda_codec *codec = hwdep->private_data;
166 snd_hda_update_power_acct(codec);
167 return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
168}
169
170static ssize_t power_off_acct_show(struct device *dev,
171 struct device_attribute *attr,
172 char *buf)
173{
174 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
175 struct hda_codec *codec = hwdep->private_data;
176 snd_hda_update_power_acct(codec);
177 return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
178}
179
180static struct device_attribute power_attrs[] = {
181 __ATTR_RO(power_on_acct),
182 __ATTR_RO(power_off_acct),
183};
184
185int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec)
186{
187 struct snd_hwdep *hwdep = codec->hwdep;
188 int i;
189
190 for (i = 0; i < ARRAY_SIZE(power_attrs); i++)
191 snd_add_device_sysfs_file(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card,
192 hwdep->device, &power_attrs[i]);
193 return 0;
194}
195#endif /* CONFIG_PM */
196
197#ifdef CONFIG_SND_HDA_RECONFIG
198
199/*
200 * sysfs interface
201 */
202
203static int clear_codec(struct hda_codec *codec)
204{
205 int err;
206
207 err = snd_hda_codec_reset(codec);
208 if (err < 0) {
209 snd_printk(KERN_ERR "The codec is being used, can't free.\n");
210 return err;
211 }
212 clear_hwdep_elements(codec);
213 return 0;
214}
215
216static int reconfig_codec(struct hda_codec *codec)
217{
218 int err;
219
220 snd_hda_power_up(codec);
221 snd_printk(KERN_INFO "hda-codec: reconfiguring\n");
222 err = snd_hda_codec_reset(codec);
223 if (err < 0) {
224 snd_printk(KERN_ERR
225 "The codec is being used, can't reconfigure.\n");
226 goto error;
227 }
228 err = snd_hda_codec_configure(codec);
229 if (err < 0)
230 goto error;
231 /* rebuild PCMs */
232 err = snd_hda_codec_build_pcms(codec);
233 if (err < 0)
234 goto error;
235 /* rebuild mixers */
236 err = snd_hda_codec_build_controls(codec);
237 if (err < 0)
238 goto error;
239 err = snd_card_register(codec->bus->card);
240 error:
241 snd_hda_power_down(codec);
242 return err;
243}
244
245/*
246 * allocate a string at most len chars, and remove the trailing EOL
247 */
248static char *kstrndup_noeol(const char *src, size_t len)
249{
250 char *s = kstrndup(src, len, GFP_KERNEL);
251 char *p;
252 if (!s)
253 return NULL;
254 p = strchr(s, '\n');
255 if (p)
256 *p = 0;
257 return s;
258}
259
260#define CODEC_INFO_SHOW(type) \
261static ssize_t type##_show(struct device *dev, \
262 struct device_attribute *attr, \
263 char *buf) \
264{ \
265 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
266 struct hda_codec *codec = hwdep->private_data; \
267 return sprintf(buf, "0x%x\n", codec->type); \
268}
269
270#define CODEC_INFO_STR_SHOW(type) \
271static ssize_t type##_show(struct device *dev, \
272 struct device_attribute *attr, \
273 char *buf) \
274{ \
275 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
276 struct hda_codec *codec = hwdep->private_data; \
277 return sprintf(buf, "%s\n", \
278 codec->type ? codec->type : ""); \
279}
280
281CODEC_INFO_SHOW(vendor_id);
282CODEC_INFO_SHOW(subsystem_id);
283CODEC_INFO_SHOW(revision_id);
284CODEC_INFO_SHOW(afg);
285CODEC_INFO_SHOW(mfg);
286CODEC_INFO_STR_SHOW(vendor_name);
287CODEC_INFO_STR_SHOW(chip_name);
288CODEC_INFO_STR_SHOW(modelname);
289
290#define CODEC_INFO_STORE(type) \
291static ssize_t type##_store(struct device *dev, \
292 struct device_attribute *attr, \
293 const char *buf, size_t count) \
294{ \
295 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
296 struct hda_codec *codec = hwdep->private_data; \
297 unsigned long val; \
298 int err = kstrtoul(buf, 0, &val); \
299 if (err < 0) \
300 return err; \
301 codec->type = val; \
302 return count; \
303}
304
305#define CODEC_INFO_STR_STORE(type) \
306static ssize_t type##_store(struct device *dev, \
307 struct device_attribute *attr, \
308 const char *buf, size_t count) \
309{ \
310 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
311 struct hda_codec *codec = hwdep->private_data; \
312 char *s = kstrndup_noeol(buf, 64); \
313 if (!s) \
314 return -ENOMEM; \
315 kfree(codec->type); \
316 codec->type = s; \
317 return count; \
318}
319
320CODEC_INFO_STORE(vendor_id);
321CODEC_INFO_STORE(subsystem_id);
322CODEC_INFO_STORE(revision_id);
323CODEC_INFO_STR_STORE(vendor_name);
324CODEC_INFO_STR_STORE(chip_name);
325CODEC_INFO_STR_STORE(modelname);
326
327#define CODEC_ACTION_STORE(type) \
328static ssize_t type##_store(struct device *dev, \
329 struct device_attribute *attr, \
330 const char *buf, size_t count) \
331{ \
332 struct snd_hwdep *hwdep = dev_get_drvdata(dev); \
333 struct hda_codec *codec = hwdep->private_data; \
334 int err = 0; \
335 if (*buf) \
336 err = type##_codec(codec); \
337 return err < 0 ? err : count; \
338}
339
340CODEC_ACTION_STORE(reconfig);
341CODEC_ACTION_STORE(clear);
342
343static ssize_t init_verbs_show(struct device *dev,
344 struct device_attribute *attr,
345 char *buf)
346{
347 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
348 struct hda_codec *codec = hwdep->private_data;
349 int i, len = 0;
350 mutex_lock(&codec->user_mutex);
351 for (i = 0; i < codec->init_verbs.used; i++) {
352 struct hda_verb *v = snd_array_elem(&codec->init_verbs, i);
353 len += snprintf(buf + len, PAGE_SIZE - len,
354 "0x%02x 0x%03x 0x%04x\n",
355 v->nid, v->verb, v->param);
356 }
357 mutex_unlock(&codec->user_mutex);
358 return len;
359}
360
361static int parse_init_verbs(struct hda_codec *codec, const char *buf)
362{
363 struct hda_verb *v;
364 int nid, verb, param;
365
366 if (sscanf(buf, "%i %i %i", &nid, &verb, &param) != 3)
367 return -EINVAL;
368 if (!nid || !verb)
369 return -EINVAL;
370 mutex_lock(&codec->user_mutex);
371 v = snd_array_new(&codec->init_verbs);
372 if (!v) {
373 mutex_unlock(&codec->user_mutex);
374 return -ENOMEM;
375 }
376 v->nid = nid;
377 v->verb = verb;
378 v->param = param;
379 mutex_unlock(&codec->user_mutex);
380 return 0;
381}
382
383static ssize_t init_verbs_store(struct device *dev,
384 struct device_attribute *attr,
385 const char *buf, size_t count)
386{
387 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
388 struct hda_codec *codec = hwdep->private_data;
389 int err = parse_init_verbs(codec, buf);
390 if (err < 0)
391 return err;
392 return count;
393}
394
395static ssize_t hints_show(struct device *dev,
396 struct device_attribute *attr,
397 char *buf)
398{
399 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
400 struct hda_codec *codec = hwdep->private_data;
401 int i, len = 0;
402 mutex_lock(&codec->user_mutex);
403 for (i = 0; i < codec->hints.used; i++) {
404 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
405 len += snprintf(buf + len, PAGE_SIZE - len,
406 "%s = %s\n", hint->key, hint->val);
407 }
408 mutex_unlock(&codec->user_mutex);
409 return len;
410}
411
412static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
413{
414 int i;
415
416 for (i = 0; i < codec->hints.used; i++) {
417 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
418 if (!strcmp(hint->key, key))
419 return hint;
420 }
421 return NULL;
422}
423
424static void remove_trail_spaces(char *str)
425{
426 char *p;
427 if (!*str)
428 return;
429 p = str + strlen(str) - 1;
430 for (; isspace(*p); p--) {
431 *p = 0;
432 if (p == str)
433 return;
434 }
435}
436
437#define MAX_HINTS 1024
438
439static int parse_hints(struct hda_codec *codec, const char *buf)
440{
441 char *key, *val;
442 struct hda_hint *hint;
443 int err = 0;
444
445 buf = skip_spaces(buf);
446 if (!*buf || *buf == '#' || *buf == '\n')
447 return 0;
448 if (*buf == '=')
449 return -EINVAL;
450 key = kstrndup_noeol(buf, 1024);
451 if (!key)
452 return -ENOMEM;
453 /* extract key and val */
454 val = strchr(key, '=');
455 if (!val) {
456 kfree(key);
457 return -EINVAL;
458 }
459 *val++ = 0;
460 val = skip_spaces(val);
461 remove_trail_spaces(key);
462 remove_trail_spaces(val);
463 mutex_lock(&codec->user_mutex);
464 hint = get_hint(codec, key);
465 if (hint) {
466 /* replace */
467 kfree(hint->key);
468 hint->key = key;
469 hint->val = val;
470 goto unlock;
471 }
472 /* allocate a new hint entry */
473 if (codec->hints.used >= MAX_HINTS)
474 hint = NULL;
475 else
476 hint = snd_array_new(&codec->hints);
477 if (hint) {
478 hint->key = key;
479 hint->val = val;
480 } else {
481 err = -ENOMEM;
482 }
483 unlock:
484 mutex_unlock(&codec->user_mutex);
485 if (err)
486 kfree(key);
487 return err;
488}
489
490static ssize_t hints_store(struct device *dev,
491 struct device_attribute *attr,
492 const char *buf, size_t count)
493{
494 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
495 struct hda_codec *codec = hwdep->private_data;
496 int err = parse_hints(codec, buf);
497 if (err < 0)
498 return err;
499 return count;
500}
501
502static ssize_t pin_configs_show(struct hda_codec *codec,
503 struct snd_array *list,
504 char *buf)
505{
506 int i, len = 0;
507 mutex_lock(&codec->user_mutex);
508 for (i = 0; i < list->used; i++) {
509 struct hda_pincfg *pin = snd_array_elem(list, i);
510 len += sprintf(buf + len, "0x%02x 0x%08x\n",
511 pin->nid, pin->cfg);
512 }
513 mutex_unlock(&codec->user_mutex);
514 return len;
515}
516
517static ssize_t init_pin_configs_show(struct device *dev,
518 struct device_attribute *attr,
519 char *buf)
520{
521 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
522 struct hda_codec *codec = hwdep->private_data;
523 return pin_configs_show(codec, &codec->init_pins, buf);
524}
525
526static ssize_t user_pin_configs_show(struct device *dev,
527 struct device_attribute *attr,
528 char *buf)
529{
530 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
531 struct hda_codec *codec = hwdep->private_data;
532 return pin_configs_show(codec, &codec->user_pins, buf);
533}
534
535static ssize_t driver_pin_configs_show(struct device *dev,
536 struct device_attribute *attr,
537 char *buf)
538{
539 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
540 struct hda_codec *codec = hwdep->private_data;
541 return pin_configs_show(codec, &codec->driver_pins, buf);
542}
543
544#define MAX_PIN_CONFIGS 32
545
546static int parse_user_pin_configs(struct hda_codec *codec, const char *buf)
547{
548 int nid, cfg, err;
549
550 if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
551 return -EINVAL;
552 if (!nid)
553 return -EINVAL;
554 mutex_lock(&codec->user_mutex);
555 err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
556 mutex_unlock(&codec->user_mutex);
557 return err;
558}
559
560static ssize_t user_pin_configs_store(struct device *dev,
561 struct device_attribute *attr,
562 const char *buf, size_t count)
563{
564 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
565 struct hda_codec *codec = hwdep->private_data;
566 int err = parse_user_pin_configs(codec, buf);
567 if (err < 0)
568 return err;
569 return count;
570}
571
572#define CODEC_ATTR_RW(type) \
573 __ATTR(type, 0644, type##_show, type##_store)
574#define CODEC_ATTR_RO(type) \
575 __ATTR_RO(type)
576#define CODEC_ATTR_WO(type) \
577 __ATTR(type, 0200, NULL, type##_store)
578
579static struct device_attribute codec_attrs[] = {
580 CODEC_ATTR_RW(vendor_id),
581 CODEC_ATTR_RW(subsystem_id),
582 CODEC_ATTR_RW(revision_id),
583 CODEC_ATTR_RO(afg),
584 CODEC_ATTR_RO(mfg),
585 CODEC_ATTR_RW(vendor_name),
586 CODEC_ATTR_RW(chip_name),
587 CODEC_ATTR_RW(modelname),
588 CODEC_ATTR_RW(init_verbs),
589 CODEC_ATTR_RW(hints),
590 CODEC_ATTR_RO(init_pin_configs),
591 CODEC_ATTR_RW(user_pin_configs),
592 CODEC_ATTR_RO(driver_pin_configs),
593 CODEC_ATTR_WO(reconfig),
594 CODEC_ATTR_WO(clear),
595};
596
597/*
598 * create sysfs files on hwdep directory
599 */
600int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
601{
602 struct snd_hwdep *hwdep = codec->hwdep;
603 int i;
604
605 for (i = 0; i < ARRAY_SIZE(codec_attrs); i++)
606 snd_add_device_sysfs_file(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card,
607 hwdep->device, &codec_attrs[i]);
608 return 0;
609}
610
611/*
612 * Look for hint string
613 */
614const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
615{
616 struct hda_hint *hint = get_hint(codec, key);
617 return hint ? hint->val : NULL;
618}
619EXPORT_SYMBOL_GPL(snd_hda_get_hint);
620
621int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
622{
623 const char *p;
624 int ret;
625
626 mutex_lock(&codec->user_mutex);
627 p = snd_hda_get_hint(codec, key);
628 if (!p || !*p)
629 ret = -ENOENT;
630 else {
631 switch (toupper(*p)) {
632 case 'T': /* true */
633 case 'Y': /* yes */
634 case '1':
635 ret = 1;
636 break;
637 default:
638 ret = 0;
639 break;
640 }
641 }
642 mutex_unlock(&codec->user_mutex);
643 return ret;
644}
645EXPORT_SYMBOL_GPL(snd_hda_get_bool_hint);
646
647int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp)
648{
649 const char *p;
650 unsigned long val;
651 int ret;
652
653 mutex_lock(&codec->user_mutex);
654 p = snd_hda_get_hint(codec, key);
655 if (!p)
656 ret = -ENOENT;
657 else if (kstrtoul(p, 0, &val))
658 ret = -EINVAL;
659 else {
660 *valp = val;
661 ret = 0;
662 }
663 mutex_unlock(&codec->user_mutex);
664 return ret;
665}
666EXPORT_SYMBOL_GPL(snd_hda_get_int_hint);
667#endif /* CONFIG_SND_HDA_RECONFIG */
668
669#ifdef CONFIG_SND_HDA_PATCH_LOADER
670 122
671/* parser mode */
672enum {
673 LINE_MODE_NONE,
674 LINE_MODE_CODEC,
675 LINE_MODE_MODEL,
676 LINE_MODE_PINCFG,
677 LINE_MODE_VERB,
678 LINE_MODE_HINT,
679 LINE_MODE_VENDOR_ID,
680 LINE_MODE_SUBSYSTEM_ID,
681 LINE_MODE_REVISION_ID,
682 LINE_MODE_CHIP_NAME,
683 NUM_LINE_MODES,
684};
685
686static inline int strmatch(const char *a, const char *b)
687{
688 return strnicmp(a, b, strlen(b)) == 0;
689}
690
691/* parse the contents after the line "[codec]"
692 * accept only the line with three numbers, and assign the current codec
693 */
694static void parse_codec_mode(char *buf, struct hda_bus *bus,
695 struct hda_codec **codecp)
696{
697 int vendorid, subid, caddr;
698 struct hda_codec *codec;
699
700 *codecp = NULL;
701 if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
702 list_for_each_entry(codec, &bus->codec_list, list) {
703 if ((vendorid <= 0 || codec->vendor_id == vendorid) &&
704 (subid <= 0 || codec->subsystem_id == subid) &&
705 codec->addr == caddr) {
706 *codecp = codec;
707 break;
708 }
709 }
710 }
711}
712
713/* parse the contents after the other command tags, [pincfg], [verb],
714 * [vendor_id], [subsystem_id], [revision_id], [chip_name], [hint] and [model]
715 * just pass to the sysfs helper (only when any codec was specified)
716 */
717static void parse_pincfg_mode(char *buf, struct hda_bus *bus,
718 struct hda_codec **codecp)
719{
720 parse_user_pin_configs(*codecp, buf);
721}
722
723static void parse_verb_mode(char *buf, struct hda_bus *bus,
724 struct hda_codec **codecp)
725{
726 parse_init_verbs(*codecp, buf);
727}
728
729static void parse_hint_mode(char *buf, struct hda_bus *bus,
730 struct hda_codec **codecp)
731{
732 parse_hints(*codecp, buf);
733}
734
735static void parse_model_mode(char *buf, struct hda_bus *bus,
736 struct hda_codec **codecp)
737{
738 kfree((*codecp)->modelname);
739 (*codecp)->modelname = kstrdup(buf, GFP_KERNEL);
740}
741
742static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
743 struct hda_codec **codecp)
744{
745 kfree((*codecp)->chip_name);
746 (*codecp)->chip_name = kstrdup(buf, GFP_KERNEL);
747}
748
749#define DEFINE_PARSE_ID_MODE(name) \
750static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
751 struct hda_codec **codecp) \
752{ \
753 unsigned long val; \
754 if (!kstrtoul(buf, 0, &val)) \
755 (*codecp)->name = val; \
756}
757
758DEFINE_PARSE_ID_MODE(vendor_id);
759DEFINE_PARSE_ID_MODE(subsystem_id);
760DEFINE_PARSE_ID_MODE(revision_id);
761
762
763struct hda_patch_item {
764 const char *tag;
765 const char *alias;
766 void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc);
767};
768
769static struct hda_patch_item patch_items[NUM_LINE_MODES] = {
770 [LINE_MODE_CODEC] = {
771 .tag = "[codec]",
772 .parser = parse_codec_mode,
773 },
774 [LINE_MODE_MODEL] = {
775 .tag = "[model]",
776 .parser = parse_model_mode,
777 },
778 [LINE_MODE_VERB] = {
779 .tag = "[verb]",
780 .alias = "[init_verbs]",
781 .parser = parse_verb_mode,
782 },
783 [LINE_MODE_PINCFG] = {
784 .tag = "[pincfg]",
785 .alias = "[user_pin_configs]",
786 .parser = parse_pincfg_mode,
787 },
788 [LINE_MODE_HINT] = {
789 .tag = "[hint]",
790 .alias = "[hints]",
791 .parser = parse_hint_mode
792 },
793 [LINE_MODE_VENDOR_ID] = {
794 .tag = "[vendor_id]",
795 .parser = parse_vendor_id_mode,
796 },
797 [LINE_MODE_SUBSYSTEM_ID] = {
798 .tag = "[subsystem_id]",
799 .parser = parse_subsystem_id_mode,
800 },
801 [LINE_MODE_REVISION_ID] = {
802 .tag = "[revision_id]",
803 .parser = parse_revision_id_mode,
804 },
805 [LINE_MODE_CHIP_NAME] = {
806 .tag = "[chip_name]",
807 .parser = parse_chip_name_mode,
808 },
809};
810
811/* check the line starting with '[' -- change the parser mode accodingly */
812static int parse_line_mode(char *buf, struct hda_bus *bus)
813{
814 int i;
815 for (i = 0; i < ARRAY_SIZE(patch_items); i++) {
816 if (!patch_items[i].tag)
817 continue;
818 if (strmatch(buf, patch_items[i].tag))
819 return i;
820 if (patch_items[i].alias && strmatch(buf, patch_items[i].alias))
821 return i;
822 }
823 return LINE_MODE_NONE;
824}
825
826/* copy one line from the buffer in fw, and update the fields in fw
827 * return zero if it reaches to the end of the buffer, or non-zero
828 * if successfully copied a line
829 *
830 * the spaces at the beginning and the end of the line are stripped
831 */
832static int get_line_from_fw(char *buf, int size, size_t *fw_size_p,
833 const void **fw_data_p)
834{
835 int len;
836 size_t fw_size = *fw_size_p;
837 const char *p = *fw_data_p;
838
839 while (isspace(*p) && fw_size) {
840 p++;
841 fw_size--;
842 }
843 if (!fw_size)
844 return 0;
845
846 for (len = 0; len < fw_size; len++) {
847 if (!*p)
848 break;
849 if (*p == '\n') {
850 p++;
851 len++;
852 break;
853 }
854 if (len < size)
855 *buf++ = *p++;
856 }
857 *buf = 0;
858 *fw_size_p = fw_size - len;
859 *fw_data_p = p;
860 remove_trail_spaces(buf);
861 return 1;
862}
863
864/*
865 * load a "patch" firmware file and parse it
866 */
867int snd_hda_load_patch(struct hda_bus *bus, size_t fw_size, const void *fw_buf)
868{
869 char buf[128];
870 struct hda_codec *codec;
871 int line_mode;
872
873 line_mode = LINE_MODE_NONE;
874 codec = NULL;
875 while (get_line_from_fw(buf, sizeof(buf) - 1, &fw_size, &fw_buf)) {
876 if (!*buf || *buf == '#' || *buf == '\n')
877 continue;
878 if (*buf == '[')
879 line_mode = parse_line_mode(buf, bus);
880 else if (patch_items[line_mode].parser &&
881 (codec || line_mode <= LINE_MODE_CODEC))
882 patch_items[line_mode].parser(buf, bus, &codec);
883 }
884 return 0; 123 return 0;
885} 124}
886EXPORT_SYMBOL_GPL(snd_hda_load_patch);
887#endif /* CONFIG_SND_HDA_PATCH_LOADER */
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 76c13d5b3ca0..9d07e4edacdb 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -30,7 +30,7 @@ void hda_display_power(bool enable)
30 if (!get_power || !put_power) 30 if (!get_power || !put_power)
31 return; 31 return;
32 32
33 snd_printdd("HDA display power %s \n", 33 pr_debug("HDA display power %s \n",
34 enable ? "Enable" : "Disable"); 34 enable ? "Enable" : "Disable");
35 if (enable) 35 if (enable)
36 get_power(); 36 get_power();
@@ -44,7 +44,7 @@ int hda_i915_init(void)
44 44
45 get_power = symbol_request(i915_request_power_well); 45 get_power = symbol_request(i915_request_power_well);
46 if (!get_power) { 46 if (!get_power) {
47 snd_printk(KERN_WARNING "hda-i915: get_power symbol get fail\n"); 47 pr_warn("hda-i915: get_power symbol get fail\n");
48 return -ENODEV; 48 return -ENODEV;
49 } 49 }
50 50
@@ -55,7 +55,7 @@ int hda_i915_init(void)
55 return -ENODEV; 55 return -ENODEV;
56 } 56 }
57 57
58 snd_printd("HDA driver get symbol successfully from i915 module\n"); 58 pr_debug("HDA driver get symbol successfully from i915 module\n");
59 59
60 return err; 60 return err;
61} 61}
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index e354ab1ec20f..77ca894f8284 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -63,6 +63,8 @@
63#include <linux/firmware.h> 63#include <linux/firmware.h>
64#include "hda_codec.h" 64#include "hda_codec.h"
65#include "hda_i915.h" 65#include "hda_i915.h"
66#include "hda_controller.h"
67#include "hda_priv.h"
66 68
67 69
68static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 70static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
@@ -127,6 +129,7 @@ static struct kernel_param_ops param_ops_xint = {
127#define param_check_xint param_check_int 129#define param_check_xint param_check_int
128 130
129static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; 131static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT;
132static int *power_save_addr = &power_save;
130module_param(power_save, xint, 0644); 133module_param(power_save, xint, 0644);
131MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " 134MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
132 "(in second, 0 = disable)."); 135 "(in second, 0 = disable).");
@@ -138,6 +141,8 @@ MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
138static bool power_save_controller = 1; 141static bool power_save_controller = 1;
139module_param(power_save_controller, bool, 0644); 142module_param(power_save_controller, bool, 0644);
140MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); 143MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode.");
144#else
145static int *power_save_addr;
141#endif /* CONFIG_PM */ 146#endif /* CONFIG_PM */
142 147
143static int align_buffer_size = -1; 148static int align_buffer_size = -1;
@@ -149,10 +154,8 @@ MODULE_PARM_DESC(align_buffer_size,
149static bool hda_snoop = true; 154static bool hda_snoop = true;
150module_param_named(snoop, hda_snoop, bool, 0444); 155module_param_named(snoop, hda_snoop, bool, 0444);
151MODULE_PARM_DESC(snoop, "Enable/disable snooping"); 156MODULE_PARM_DESC(snoop, "Enable/disable snooping");
152#define azx_snoop(chip) (chip)->snoop
153#else 157#else
154#define hda_snoop true 158#define hda_snoop true
155#define azx_snoop(chip) true
156#endif 159#endif
157 160
158 161
@@ -191,12 +194,6 @@ MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"
191 "{ULI, M5461}}"); 194 "{ULI, M5461}}");
192MODULE_DESCRIPTION("Intel HDA driver"); 195MODULE_DESCRIPTION("Intel HDA driver");
193 196
194#ifdef CONFIG_SND_VERBOSE_PRINTK
195#define SFX /* nop */
196#else
197#define SFX "hda-intel "
198#endif
199
200#if defined(CONFIG_PM) && defined(CONFIG_VGA_SWITCHEROO) 197#if defined(CONFIG_PM) && defined(CONFIG_VGA_SWITCHEROO)
201#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI) 198#if IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
202#define SUPPORT_VGA_SWITCHEROO 199#define SUPPORT_VGA_SWITCHEROO
@@ -205,365 +202,8 @@ MODULE_DESCRIPTION("Intel HDA driver");
205 202
206 203
207/* 204/*
208 * registers
209 */
210#define ICH6_REG_GCAP 0x00
211#define ICH6_GCAP_64OK (1 << 0) /* 64bit address support */
212#define ICH6_GCAP_NSDO (3 << 1) /* # of serial data out signals */
213#define ICH6_GCAP_BSS (31 << 3) /* # of bidirectional streams */
214#define ICH6_GCAP_ISS (15 << 8) /* # of input streams */
215#define ICH6_GCAP_OSS (15 << 12) /* # of output streams */
216#define ICH6_REG_VMIN 0x02
217#define ICH6_REG_VMAJ 0x03
218#define ICH6_REG_OUTPAY 0x04
219#define ICH6_REG_INPAY 0x06
220#define ICH6_REG_GCTL 0x08
221#define ICH6_GCTL_RESET (1 << 0) /* controller reset */
222#define ICH6_GCTL_FCNTRL (1 << 1) /* flush control */
223#define ICH6_GCTL_UNSOL (1 << 8) /* accept unsol. response enable */
224#define ICH6_REG_WAKEEN 0x0c
225#define ICH6_REG_STATESTS 0x0e
226#define ICH6_REG_GSTS 0x10
227#define ICH6_GSTS_FSTS (1 << 1) /* flush status */
228#define ICH6_REG_INTCTL 0x20
229#define ICH6_REG_INTSTS 0x24
230#define ICH6_REG_WALLCLK 0x30 /* 24Mhz source */
231#define ICH6_REG_OLD_SSYNC 0x34 /* SSYNC for old ICH */
232#define ICH6_REG_SSYNC 0x38
233#define ICH6_REG_CORBLBASE 0x40
234#define ICH6_REG_CORBUBASE 0x44
235#define ICH6_REG_CORBWP 0x48
236#define ICH6_REG_CORBRP 0x4a
237#define ICH6_CORBRP_RST (1 << 15) /* read pointer reset */
238#define ICH6_REG_CORBCTL 0x4c
239#define ICH6_CORBCTL_RUN (1 << 1) /* enable DMA */
240#define ICH6_CORBCTL_CMEIE (1 << 0) /* enable memory error irq */
241#define ICH6_REG_CORBSTS 0x4d
242#define ICH6_CORBSTS_CMEI (1 << 0) /* memory error indication */
243#define ICH6_REG_CORBSIZE 0x4e
244
245#define ICH6_REG_RIRBLBASE 0x50
246#define ICH6_REG_RIRBUBASE 0x54
247#define ICH6_REG_RIRBWP 0x58
248#define ICH6_RIRBWP_RST (1 << 15) /* write pointer reset */
249#define ICH6_REG_RINTCNT 0x5a
250#define ICH6_REG_RIRBCTL 0x5c
251#define ICH6_RBCTL_IRQ_EN (1 << 0) /* enable IRQ */
252#define ICH6_RBCTL_DMA_EN (1 << 1) /* enable DMA */
253#define ICH6_RBCTL_OVERRUN_EN (1 << 2) /* enable overrun irq */
254#define ICH6_REG_RIRBSTS 0x5d
255#define ICH6_RBSTS_IRQ (1 << 0) /* response irq */
256#define ICH6_RBSTS_OVERRUN (1 << 2) /* overrun irq */
257#define ICH6_REG_RIRBSIZE 0x5e
258
259#define ICH6_REG_IC 0x60
260#define ICH6_REG_IR 0x64
261#define ICH6_REG_IRS 0x68
262#define ICH6_IRS_VALID (1<<1)
263#define ICH6_IRS_BUSY (1<<0)
264
265#define ICH6_REG_DPLBASE 0x70
266#define ICH6_REG_DPUBASE 0x74
267#define ICH6_DPLBASE_ENABLE 0x1 /* Enable position buffer */
268
269/* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
270enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
271
272/* stream register offsets from stream base */
273#define ICH6_REG_SD_CTL 0x00
274#define ICH6_REG_SD_STS 0x03
275#define ICH6_REG_SD_LPIB 0x04
276#define ICH6_REG_SD_CBL 0x08
277#define ICH6_REG_SD_LVI 0x0c
278#define ICH6_REG_SD_FIFOW 0x0e
279#define ICH6_REG_SD_FIFOSIZE 0x10
280#define ICH6_REG_SD_FORMAT 0x12
281#define ICH6_REG_SD_BDLPL 0x18
282#define ICH6_REG_SD_BDLPU 0x1c
283
284/* PCI space */
285#define ICH6_PCIREG_TCSEL 0x44
286
287/*
288 * other constants
289 */ 205 */
290 206
291/* max number of SDs */
292/* ICH, ATI and VIA have 4 playback and 4 capture */
293#define ICH6_NUM_CAPTURE 4
294#define ICH6_NUM_PLAYBACK 4
295
296/* ULI has 6 playback and 5 capture */
297#define ULI_NUM_CAPTURE 5
298#define ULI_NUM_PLAYBACK 6
299
300/* ATI HDMI may have up to 8 playbacks and 0 capture */
301#define ATIHDMI_NUM_CAPTURE 0
302#define ATIHDMI_NUM_PLAYBACK 8
303
304/* TERA has 4 playback and 3 capture */
305#define TERA_NUM_CAPTURE 3
306#define TERA_NUM_PLAYBACK 4
307
308/* this number is statically defined for simplicity */
309#define MAX_AZX_DEV 16
310
311/* max number of fragments - we may use more if allocating more pages for BDL */
312#define BDL_SIZE 4096
313#define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16)
314#define AZX_MAX_FRAG 32
315/* max buffer size - no h/w limit, you can increase as you like */
316#define AZX_MAX_BUF_SIZE (1024*1024*1024)
317
318/* RIRB int mask: overrun[2], response[0] */
319#define RIRB_INT_RESPONSE 0x01
320#define RIRB_INT_OVERRUN 0x04
321#define RIRB_INT_MASK 0x05
322
323/* STATESTS int mask: S3,SD2,SD1,SD0 */
324#define AZX_MAX_CODECS 8
325#define AZX_DEFAULT_CODECS 4
326#define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1)
327
328/* SD_CTL bits */
329#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
330#define SD_CTL_DMA_START 0x02 /* stream DMA start bit */
331#define SD_CTL_STRIPE (3 << 16) /* stripe control */
332#define SD_CTL_TRAFFIC_PRIO (1 << 18) /* traffic priority */
333#define SD_CTL_DIR (1 << 19) /* bi-directional stream */
334#define SD_CTL_STREAM_TAG_MASK (0xf << 20)
335#define SD_CTL_STREAM_TAG_SHIFT 20
336
337/* SD_CTL and SD_STS */
338#define SD_INT_DESC_ERR 0x10 /* descriptor error interrupt */
339#define SD_INT_FIFO_ERR 0x08 /* FIFO error interrupt */
340#define SD_INT_COMPLETE 0x04 /* completion interrupt */
341#define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
342 SD_INT_COMPLETE)
343
344/* SD_STS */
345#define SD_STS_FIFO_READY 0x20 /* FIFO ready */
346
347/* INTCTL and INTSTS */
348#define ICH6_INT_ALL_STREAM 0xff /* all stream interrupts */
349#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */
350#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */
351
352/* below are so far hardcoded - should read registers in future */
353#define ICH6_MAX_CORB_ENTRIES 256
354#define ICH6_MAX_RIRB_ENTRIES 256
355
356/* position fix mode */
357enum {
358 POS_FIX_AUTO,
359 POS_FIX_LPIB,
360 POS_FIX_POSBUF,
361 POS_FIX_VIACOMBO,
362 POS_FIX_COMBO,
363};
364
365/* Defines for ATI HD Audio support in SB450 south bridge */
366#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42
367#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02
368
369/* Defines for Nvidia HDA support */
370#define NVIDIA_HDA_TRANSREG_ADDR 0x4e
371#define NVIDIA_HDA_ENABLE_COHBITS 0x0f
372#define NVIDIA_HDA_ISTRM_COH 0x4d
373#define NVIDIA_HDA_OSTRM_COH 0x4c
374#define NVIDIA_HDA_ENABLE_COHBIT 0x01
375
376/* Defines for Intel SCH HDA snoop control */
377#define INTEL_SCH_HDA_DEVC 0x78
378#define INTEL_SCH_HDA_DEVC_NOSNOOP (0x1<<11)
379
380/* Define IN stream 0 FIFO size offset in VIA controller */
381#define VIA_IN_STREAM0_FIFO_SIZE_OFFSET 0x90
382/* Define VIA HD Audio Device ID*/
383#define VIA_HDAC_DEVICE_ID 0x3288
384
385/* HD Audio class code */
386#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
387
388/*
389 */
390
391struct azx_dev {
392 struct snd_dma_buffer bdl; /* BDL buffer */
393 u32 *posbuf; /* position buffer pointer */
394
395 unsigned int bufsize; /* size of the play buffer in bytes */
396 unsigned int period_bytes; /* size of the period in bytes */
397 unsigned int frags; /* number for period in the play buffer */
398 unsigned int fifo_size; /* FIFO size */
399 unsigned long start_wallclk; /* start + minimum wallclk */
400 unsigned long period_wallclk; /* wallclk for period */
401
402 void __iomem *sd_addr; /* stream descriptor pointer */
403
404 u32 sd_int_sta_mask; /* stream int status mask */
405
406 /* pcm support */
407 struct snd_pcm_substream *substream; /* assigned substream,
408 * set in PCM open
409 */
410 unsigned int format_val; /* format value to be set in the
411 * controller and the codec
412 */
413 unsigned char stream_tag; /* assigned stream */
414 unsigned char index; /* stream index */
415 int assigned_key; /* last device# key assigned to */
416
417 unsigned int opened :1;
418 unsigned int running :1;
419 unsigned int irq_pending :1;
420 unsigned int prepared:1;
421 unsigned int locked:1;
422 /*
423 * For VIA:
424 * A flag to ensure DMA position is 0
425 * when link position is not greater than FIFO size
426 */
427 unsigned int insufficient :1;
428 unsigned int wc_marked:1;
429 unsigned int no_period_wakeup:1;
430
431 struct timecounter azx_tc;
432 struct cyclecounter azx_cc;
433
434 int delay_negative_threshold;
435
436#ifdef CONFIG_SND_HDA_DSP_LOADER
437 struct mutex dsp_mutex;
438#endif
439};
440
441/* DSP lock helpers */
442#ifdef CONFIG_SND_HDA_DSP_LOADER
443#define dsp_lock_init(dev) mutex_init(&(dev)->dsp_mutex)
444#define dsp_lock(dev) mutex_lock(&(dev)->dsp_mutex)
445#define dsp_unlock(dev) mutex_unlock(&(dev)->dsp_mutex)
446#define dsp_is_locked(dev) ((dev)->locked)
447#else
448#define dsp_lock_init(dev) do {} while (0)
449#define dsp_lock(dev) do {} while (0)
450#define dsp_unlock(dev) do {} while (0)
451#define dsp_is_locked(dev) 0
452#endif
453
454/* CORB/RIRB */
455struct azx_rb {
456 u32 *buf; /* CORB/RIRB buffer
457 * Each CORB entry is 4byte, RIRB is 8byte
458 */
459 dma_addr_t addr; /* physical address of CORB/RIRB buffer */
460 /* for RIRB */
461 unsigned short rp, wp; /* read/write pointers */
462 int cmds[AZX_MAX_CODECS]; /* number of pending requests */
463 u32 res[AZX_MAX_CODECS]; /* last read value */
464};
465
466struct azx_pcm {
467 struct azx *chip;
468 struct snd_pcm *pcm;
469 struct hda_codec *codec;
470 struct hda_pcm_stream *hinfo[2];
471 struct list_head list;
472};
473
474struct azx {
475 struct snd_card *card;
476 struct pci_dev *pci;
477 int dev_index;
478
479 /* chip type specific */
480 int driver_type;
481 unsigned int driver_caps;
482 int playback_streams;
483 int playback_index_offset;
484 int capture_streams;
485 int capture_index_offset;
486 int num_streams;
487
488 /* pci resources */
489 unsigned long addr;
490 void __iomem *remap_addr;
491 int irq;
492
493 /* locks */
494 spinlock_t reg_lock;
495 struct mutex open_mutex;
496 struct completion probe_wait;
497
498 /* streams (x num_streams) */
499 struct azx_dev *azx_dev;
500
501 /* PCM */
502 struct list_head pcm_list; /* azx_pcm list */
503
504 /* HD codec */
505 unsigned short codec_mask;
506 int codec_probe_mask; /* copied from probe_mask option */
507 struct hda_bus *bus;
508 unsigned int beep_mode;
509
510 /* CORB/RIRB */
511 struct azx_rb corb;
512 struct azx_rb rirb;
513
514 /* CORB/RIRB and position buffers */
515 struct snd_dma_buffer rb;
516 struct snd_dma_buffer posbuf;
517
518#ifdef CONFIG_SND_HDA_PATCH_LOADER
519 const struct firmware *fw;
520#endif
521
522 /* flags */
523 int position_fix[2]; /* for both playback/capture streams */
524 int poll_count;
525 unsigned int running :1;
526 unsigned int initialized :1;
527 unsigned int single_cmd :1;
528 unsigned int polling_mode :1;
529 unsigned int msi :1;
530 unsigned int irq_pending_warned :1;
531 unsigned int probing :1; /* codec probing phase */
532 unsigned int snoop:1;
533 unsigned int align_buffer_size:1;
534 unsigned int region_requested:1;
535
536 /* VGA-switcheroo setup */
537 unsigned int use_vga_switcheroo:1;
538 unsigned int vga_switcheroo_registered:1;
539 unsigned int init_failed:1; /* delayed init failed */
540 unsigned int disabled:1; /* disabled by VGA-switcher */
541
542 /* for debugging */
543 unsigned int last_cmd[AZX_MAX_CODECS];
544
545 /* for pending irqs */
546 struct work_struct irq_pending_work;
547
548 struct work_struct probe_work;
549
550 /* reboot notifier (for mysterious hangup problem at power-down) */
551 struct notifier_block reboot_notifier;
552
553 /* card list (for power_save trigger) */
554 struct list_head list;
555
556#ifdef CONFIG_SND_HDA_DSP_LOADER
557 struct azx_dev saved_azx_dev;
558#endif
559
560 /* secondary power domain for hdmi audio under vga device */
561 struct dev_pm_domain hdmi_pm_domain;
562};
563
564#define CREATE_TRACE_POINTS
565#include "hda_intel_trace.h"
566
567/* driver types */ 207/* driver types */
568enum { 208enum {
569 AZX_DRIVER_ICH, 209 AZX_DRIVER_ICH,
@@ -584,28 +224,6 @@ enum {
584 AZX_NUM_DRIVERS, /* keep this as last entry */ 224 AZX_NUM_DRIVERS, /* keep this as last entry */
585}; 225};
586 226
587/* driver quirks (capabilities) */
588/* bits 0-7 are used for indicating driver type */
589#define AZX_DCAPS_NO_TCSEL (1 << 8) /* No Intel TCSEL bit */
590#define AZX_DCAPS_NO_MSI (1 << 9) /* No MSI support */
591#define AZX_DCAPS_ATI_SNOOP (1 << 10) /* ATI snoop enable */
592#define AZX_DCAPS_NVIDIA_SNOOP (1 << 11) /* Nvidia snoop enable */
593#define AZX_DCAPS_SCH_SNOOP (1 << 12) /* SCH/PCH snoop enable */
594#define AZX_DCAPS_RIRB_DELAY (1 << 13) /* Long delay in read loop */
595#define AZX_DCAPS_RIRB_PRE_DELAY (1 << 14) /* Put a delay before read */
596#define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */
597#define AZX_DCAPS_POSFIX_LPIB (1 << 16) /* Use LPIB as default */
598#define AZX_DCAPS_POSFIX_VIA (1 << 17) /* Use VIACOMBO as default */
599#define AZX_DCAPS_NO_64BIT (1 << 18) /* No 64bit address */
600#define AZX_DCAPS_SYNC_WRITE (1 << 19) /* sync each cmd write */
601#define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */
602#define AZX_DCAPS_BUFSIZE (1 << 21) /* no buffer size alignment */
603#define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */
604#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */
605#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */
606#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */
607#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 power well support */
608
609/* quirks for Intel PCH */ 227/* quirks for Intel PCH */
610#define AZX_DCAPS_INTEL_PCH_NOPM \ 228#define AZX_DCAPS_INTEL_PCH_NOPM \
611 (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_BUFSIZE | \ 229 (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_BUFSIZE | \
@@ -663,38 +281,6 @@ static char *driver_short_names[] = {
663 [AZX_DRIVER_GENERIC] = "HD-Audio Generic", 281 [AZX_DRIVER_GENERIC] = "HD-Audio Generic",
664}; 282};
665 283
666/*
667 * macros for easy use
668 */
669#define azx_writel(chip,reg,value) \
670 writel(value, (chip)->remap_addr + ICH6_REG_##reg)
671#define azx_readl(chip,reg) \
672 readl((chip)->remap_addr + ICH6_REG_##reg)
673#define azx_writew(chip,reg,value) \
674 writew(value, (chip)->remap_addr + ICH6_REG_##reg)
675#define azx_readw(chip,reg) \
676 readw((chip)->remap_addr + ICH6_REG_##reg)
677#define azx_writeb(chip,reg,value) \
678 writeb(value, (chip)->remap_addr + ICH6_REG_##reg)
679#define azx_readb(chip,reg) \
680 readb((chip)->remap_addr + ICH6_REG_##reg)
681
682#define azx_sd_writel(dev,reg,value) \
683 writel(value, (dev)->sd_addr + ICH6_REG_##reg)
684#define azx_sd_readl(dev,reg) \
685 readl((dev)->sd_addr + ICH6_REG_##reg)
686#define azx_sd_writew(dev,reg,value) \
687 writew(value, (dev)->sd_addr + ICH6_REG_##reg)
688#define azx_sd_readw(dev,reg) \
689 readw((dev)->sd_addr + ICH6_REG_##reg)
690#define azx_sd_writeb(dev,reg,value) \
691 writeb(value, (dev)->sd_addr + ICH6_REG_##reg)
692#define azx_sd_readb(dev,reg) \
693 readb((dev)->sd_addr + ICH6_REG_##reg)
694
695/* for pcm support */
696#define get_azx_dev(substream) (substream->runtime->private_data)
697
698#ifdef CONFIG_X86 284#ifdef CONFIG_X86
699static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool on) 285static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool on)
700{ 286{
@@ -749,578 +335,6 @@ static inline void mark_runtime_wc(struct azx *chip, struct azx_dev *azx_dev,
749#endif 335#endif
750 336
751static int azx_acquire_irq(struct azx *chip, int do_disconnect); 337static int azx_acquire_irq(struct azx *chip, int do_disconnect);
752static int azx_send_cmd(struct hda_bus *bus, unsigned int val);
753/*
754 * Interface for HD codec
755 */
756
757/*
758 * CORB / RIRB interface
759 */
760static int azx_alloc_cmd_io(struct azx *chip)
761{
762 int err;
763
764 /* single page (at least 4096 bytes) must suffice for both ringbuffes */
765 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
766 snd_dma_pci_data(chip->pci),
767 PAGE_SIZE, &chip->rb);
768 if (err < 0) {
769 snd_printk(KERN_ERR SFX "%s: cannot allocate CORB/RIRB\n", pci_name(chip->pci));
770 return err;
771 }
772 mark_pages_wc(chip, &chip->rb, true);
773 return 0;
774}
775
776static void azx_init_cmd_io(struct azx *chip)
777{
778 spin_lock_irq(&chip->reg_lock);
779 /* CORB set up */
780 chip->corb.addr = chip->rb.addr;
781 chip->corb.buf = (u32 *)chip->rb.area;
782 azx_writel(chip, CORBLBASE, (u32)chip->corb.addr);
783 azx_writel(chip, CORBUBASE, upper_32_bits(chip->corb.addr));
784
785 /* set the corb size to 256 entries (ULI requires explicitly) */
786 azx_writeb(chip, CORBSIZE, 0x02);
787 /* set the corb write pointer to 0 */
788 azx_writew(chip, CORBWP, 0);
789 /* reset the corb hw read pointer */
790 azx_writew(chip, CORBRP, ICH6_CORBRP_RST);
791 /* enable corb dma */
792 azx_writeb(chip, CORBCTL, ICH6_CORBCTL_RUN);
793
794 /* RIRB set up */
795 chip->rirb.addr = chip->rb.addr + 2048;
796 chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
797 chip->rirb.wp = chip->rirb.rp = 0;
798 memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds));
799 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
800 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr));
801
802 /* set the rirb size to 256 entries (ULI requires explicitly) */
803 azx_writeb(chip, RIRBSIZE, 0x02);
804 /* reset the rirb hw write pointer */
805 azx_writew(chip, RIRBWP, ICH6_RIRBWP_RST);
806 /* set N=1, get RIRB response interrupt for new entry */
807 if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
808 azx_writew(chip, RINTCNT, 0xc0);
809 else
810 azx_writew(chip, RINTCNT, 1);
811 /* enable rirb dma and response irq */
812 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN);
813 spin_unlock_irq(&chip->reg_lock);
814}
815
816static void azx_free_cmd_io(struct azx *chip)
817{
818 spin_lock_irq(&chip->reg_lock);
819 /* disable ringbuffer DMAs */
820 azx_writeb(chip, RIRBCTL, 0);
821 azx_writeb(chip, CORBCTL, 0);
822 spin_unlock_irq(&chip->reg_lock);
823}
824
825static unsigned int azx_command_addr(u32 cmd)
826{
827 unsigned int addr = cmd >> 28;
828
829 if (addr >= AZX_MAX_CODECS) {
830 snd_BUG();
831 addr = 0;
832 }
833
834 return addr;
835}
836
837static unsigned int azx_response_addr(u32 res)
838{
839 unsigned int addr = res & 0xf;
840
841 if (addr >= AZX_MAX_CODECS) {
842 snd_BUG();
843 addr = 0;
844 }
845
846 return addr;
847}
848
849/* send a command */
850static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
851{
852 struct azx *chip = bus->private_data;
853 unsigned int addr = azx_command_addr(val);
854 unsigned int wp, rp;
855
856 spin_lock_irq(&chip->reg_lock);
857
858 /* add command to corb */
859 wp = azx_readw(chip, CORBWP);
860 if (wp == 0xffff) {
861 /* something wrong, controller likely turned to D3 */
862 spin_unlock_irq(&chip->reg_lock);
863 return -EIO;
864 }
865 wp++;
866 wp %= ICH6_MAX_CORB_ENTRIES;
867
868 rp = azx_readw(chip, CORBRP);
869 if (wp == rp) {
870 /* oops, it's full */
871 spin_unlock_irq(&chip->reg_lock);
872 return -EAGAIN;
873 }
874
875 chip->rirb.cmds[addr]++;
876 chip->corb.buf[wp] = cpu_to_le32(val);
877 azx_writel(chip, CORBWP, wp);
878
879 spin_unlock_irq(&chip->reg_lock);
880
881 return 0;
882}
883
884#define ICH6_RIRB_EX_UNSOL_EV (1<<4)
885
886/* retrieve RIRB entry - called from interrupt handler */
887static void azx_update_rirb(struct azx *chip)
888{
889 unsigned int rp, wp;
890 unsigned int addr;
891 u32 res, res_ex;
892
893 wp = azx_readw(chip, RIRBWP);
894 if (wp == 0xffff) {
895 /* something wrong, controller likely turned to D3 */
896 return;
897 }
898
899 if (wp == chip->rirb.wp)
900 return;
901 chip->rirb.wp = wp;
902
903 while (chip->rirb.rp != wp) {
904 chip->rirb.rp++;
905 chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES;
906
907 rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */
908 res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]);
909 res = le32_to_cpu(chip->rirb.buf[rp]);
910 addr = azx_response_addr(res_ex);
911 if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
912 snd_hda_queue_unsol_event(chip->bus, res, res_ex);
913 else if (chip->rirb.cmds[addr]) {
914 chip->rirb.res[addr] = res;
915 smp_wmb();
916 chip->rirb.cmds[addr]--;
917 } else if (printk_ratelimit()) {
918 snd_printk(KERN_ERR SFX "%s: spurious response %#x:%#x, last cmd=%#08x\n",
919 pci_name(chip->pci),
920 res, res_ex,
921 chip->last_cmd[addr]);
922 }
923 }
924}
925
926/* receive a response */
927static unsigned int azx_rirb_get_response(struct hda_bus *bus,
928 unsigned int addr)
929{
930 struct azx *chip = bus->private_data;
931 unsigned long timeout;
932 unsigned long loopcounter;
933 int do_poll = 0;
934
935 again:
936 timeout = jiffies + msecs_to_jiffies(1000);
937
938 for (loopcounter = 0;; loopcounter++) {
939 if (chip->polling_mode || do_poll) {
940 spin_lock_irq(&chip->reg_lock);
941 azx_update_rirb(chip);
942 spin_unlock_irq(&chip->reg_lock);
943 }
944 if (!chip->rirb.cmds[addr]) {
945 smp_rmb();
946 bus->rirb_error = 0;
947
948 if (!do_poll)
949 chip->poll_count = 0;
950 return chip->rirb.res[addr]; /* the last value */
951 }
952 if (time_after(jiffies, timeout))
953 break;
954 if (bus->needs_damn_long_delay || loopcounter > 3000)
955 msleep(2); /* temporary workaround */
956 else {
957 udelay(10);
958 cond_resched();
959 }
960 }
961
962 if (!bus->no_response_fallback)
963 return -1;
964
965 if (!chip->polling_mode && chip->poll_count < 2) {
966 snd_printdd(SFX "%s: azx_get_response timeout, "
967 "polling the codec once: last cmd=0x%08x\n",
968 pci_name(chip->pci), chip->last_cmd[addr]);
969 do_poll = 1;
970 chip->poll_count++;
971 goto again;
972 }
973
974
975 if (!chip->polling_mode) {
976 snd_printk(KERN_WARNING SFX "%s: azx_get_response timeout, "
977 "switching to polling mode: last cmd=0x%08x\n",
978 pci_name(chip->pci), chip->last_cmd[addr]);
979 chip->polling_mode = 1;
980 goto again;
981 }
982
983 if (chip->msi) {
984 snd_printk(KERN_WARNING SFX "%s: No response from codec, "
985 "disabling MSI: last cmd=0x%08x\n",
986 pci_name(chip->pci), chip->last_cmd[addr]);
987 free_irq(chip->irq, chip);
988 chip->irq = -1;
989 pci_disable_msi(chip->pci);
990 chip->msi = 0;
991 if (azx_acquire_irq(chip, 1) < 0) {
992 bus->rirb_error = 1;
993 return -1;
994 }
995 goto again;
996 }
997
998 if (chip->probing) {
999 /* If this critical timeout happens during the codec probing
1000 * phase, this is likely an access to a non-existing codec
1001 * slot. Better to return an error and reset the system.
1002 */
1003 return -1;
1004 }
1005
1006 /* a fatal communication error; need either to reset or to fallback
1007 * to the single_cmd mode
1008 */
1009 bus->rirb_error = 1;
1010 if (bus->allow_bus_reset && !bus->response_reset && !bus->in_reset) {
1011 bus->response_reset = 1;
1012 return -1; /* give a chance to retry */
1013 }
1014
1015 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
1016 "switching to single_cmd mode: last cmd=0x%08x\n",
1017 chip->last_cmd[addr]);
1018 chip->single_cmd = 1;
1019 bus->response_reset = 0;
1020 /* release CORB/RIRB */
1021 azx_free_cmd_io(chip);
1022 /* disable unsolicited responses */
1023 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_UNSOL);
1024 return -1;
1025}
1026
1027/*
1028 * Use the single immediate command instead of CORB/RIRB for simplicity
1029 *
1030 * Note: according to Intel, this is not preferred use. The command was
1031 * intended for the BIOS only, and may get confused with unsolicited
1032 * responses. So, we shouldn't use it for normal operation from the
1033 * driver.
1034 * I left the codes, however, for debugging/testing purposes.
1035 */
1036
1037/* receive a response */
1038static int azx_single_wait_for_response(struct azx *chip, unsigned int addr)
1039{
1040 int timeout = 50;
1041
1042 while (timeout--) {
1043 /* check IRV busy bit */
1044 if (azx_readw(chip, IRS) & ICH6_IRS_VALID) {
1045 /* reuse rirb.res as the response return value */
1046 chip->rirb.res[addr] = azx_readl(chip, IR);
1047 return 0;
1048 }
1049 udelay(1);
1050 }
1051 if (printk_ratelimit())
1052 snd_printd(SFX "%s: get_response timeout: IRS=0x%x\n",
1053 pci_name(chip->pci), azx_readw(chip, IRS));
1054 chip->rirb.res[addr] = -1;
1055 return -EIO;
1056}
1057
1058/* send a command */
1059static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
1060{
1061 struct azx *chip = bus->private_data;
1062 unsigned int addr = azx_command_addr(val);
1063 int timeout = 50;
1064
1065 bus->rirb_error = 0;
1066 while (timeout--) {
1067 /* check ICB busy bit */
1068 if (!((azx_readw(chip, IRS) & ICH6_IRS_BUSY))) {
1069 /* Clear IRV valid bit */
1070 azx_writew(chip, IRS, azx_readw(chip, IRS) |
1071 ICH6_IRS_VALID);
1072 azx_writel(chip, IC, val);
1073 azx_writew(chip, IRS, azx_readw(chip, IRS) |
1074 ICH6_IRS_BUSY);
1075 return azx_single_wait_for_response(chip, addr);
1076 }
1077 udelay(1);
1078 }
1079 if (printk_ratelimit())
1080 snd_printd(SFX "%s: send_cmd timeout: IRS=0x%x, val=0x%x\n",
1081 pci_name(chip->pci), azx_readw(chip, IRS), val);
1082 return -EIO;
1083}
1084
1085/* receive a response */
1086static unsigned int azx_single_get_response(struct hda_bus *bus,
1087 unsigned int addr)
1088{
1089 struct azx *chip = bus->private_data;
1090 return chip->rirb.res[addr];
1091}
1092
1093/*
1094 * The below are the main callbacks from hda_codec.
1095 *
1096 * They are just the skeleton to call sub-callbacks according to the
1097 * current setting of chip->single_cmd.
1098 */
1099
1100/* send a command */
1101static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
1102{
1103 struct azx *chip = bus->private_data;
1104
1105 if (chip->disabled)
1106 return 0;
1107 chip->last_cmd[azx_command_addr(val)] = val;
1108 if (chip->single_cmd)
1109 return azx_single_send_cmd(bus, val);
1110 else
1111 return azx_corb_send_cmd(bus, val);
1112}
1113
1114/* get a response */
1115static unsigned int azx_get_response(struct hda_bus *bus,
1116 unsigned int addr)
1117{
1118 struct azx *chip = bus->private_data;
1119 if (chip->disabled)
1120 return 0;
1121 if (chip->single_cmd)
1122 return azx_single_get_response(bus, addr);
1123 else
1124 return azx_rirb_get_response(bus, addr);
1125}
1126
1127#ifdef CONFIG_PM
1128static void azx_power_notify(struct hda_bus *bus, bool power_up);
1129#endif
1130
1131#ifdef CONFIG_SND_HDA_DSP_LOADER
1132static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
1133 unsigned int byte_size,
1134 struct snd_dma_buffer *bufp);
1135static void azx_load_dsp_trigger(struct hda_bus *bus, bool start);
1136static void azx_load_dsp_cleanup(struct hda_bus *bus,
1137 struct snd_dma_buffer *dmab);
1138#endif
1139
1140/* enter link reset */
1141static void azx_enter_link_reset(struct azx *chip)
1142{
1143 unsigned long timeout;
1144
1145 /* reset controller */
1146 azx_writel(chip, GCTL, azx_readl(chip, GCTL) & ~ICH6_GCTL_RESET);
1147
1148 timeout = jiffies + msecs_to_jiffies(100);
1149 while ((azx_readb(chip, GCTL) & ICH6_GCTL_RESET) &&
1150 time_before(jiffies, timeout))
1151 usleep_range(500, 1000);
1152}
1153
1154/* exit link reset */
1155static void azx_exit_link_reset(struct azx *chip)
1156{
1157 unsigned long timeout;
1158
1159 azx_writeb(chip, GCTL, azx_readb(chip, GCTL) | ICH6_GCTL_RESET);
1160
1161 timeout = jiffies + msecs_to_jiffies(100);
1162 while (!azx_readb(chip, GCTL) &&
1163 time_before(jiffies, timeout))
1164 usleep_range(500, 1000);
1165}
1166
1167/* reset codec link */
1168static int azx_reset(struct azx *chip, int full_reset)
1169{
1170 if (!full_reset)
1171 goto __skip;
1172
1173 /* clear STATESTS */
1174 azx_writew(chip, STATESTS, STATESTS_INT_MASK);
1175
1176 /* reset controller */
1177 azx_enter_link_reset(chip);
1178
1179 /* delay for >= 100us for codec PLL to settle per spec
1180 * Rev 0.9 section 5.5.1
1181 */
1182 usleep_range(500, 1000);
1183
1184 /* Bring controller out of reset */
1185 azx_exit_link_reset(chip);
1186
1187 /* Brent Chartrand said to wait >= 540us for codecs to initialize */
1188 usleep_range(1000, 1200);
1189
1190 __skip:
1191 /* check to see if controller is ready */
1192 if (!azx_readb(chip, GCTL)) {
1193 snd_printd(SFX "%s: azx_reset: controller not ready!\n", pci_name(chip->pci));
1194 return -EBUSY;
1195 }
1196
1197 /* Accept unsolicited responses */
1198 if (!chip->single_cmd)
1199 azx_writel(chip, GCTL, azx_readl(chip, GCTL) |
1200 ICH6_GCTL_UNSOL);
1201
1202 /* detect codecs */
1203 if (!chip->codec_mask) {
1204 chip->codec_mask = azx_readw(chip, STATESTS);
1205 snd_printdd(SFX "%s: codec_mask = 0x%x\n", pci_name(chip->pci), chip->codec_mask);
1206 }
1207
1208 return 0;
1209}
1210
1211
1212/*
1213 * Lowlevel interface
1214 */
1215
1216/* enable interrupts */
1217static void azx_int_enable(struct azx *chip)
1218{
1219 /* enable controller CIE and GIE */
1220 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) |
1221 ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN);
1222}
1223
1224/* disable interrupts */
1225static void azx_int_disable(struct azx *chip)
1226{
1227 int i;
1228
1229 /* disable interrupts in stream descriptor */
1230 for (i = 0; i < chip->num_streams; i++) {
1231 struct azx_dev *azx_dev = &chip->azx_dev[i];
1232 azx_sd_writeb(azx_dev, SD_CTL,
1233 azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK);
1234 }
1235
1236 /* disable SIE for all streams */
1237 azx_writeb(chip, INTCTL, 0);
1238
1239 /* disable controller CIE and GIE */
1240 azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) &
1241 ~(ICH6_INT_CTRL_EN | ICH6_INT_GLOBAL_EN));
1242}
1243
1244/* clear interrupts */
1245static void azx_int_clear(struct azx *chip)
1246{
1247 int i;
1248
1249 /* clear stream status */
1250 for (i = 0; i < chip->num_streams; i++) {
1251 struct azx_dev *azx_dev = &chip->azx_dev[i];
1252 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
1253 }
1254
1255 /* clear STATESTS */
1256 azx_writew(chip, STATESTS, STATESTS_INT_MASK);
1257
1258 /* clear rirb status */
1259 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
1260
1261 /* clear int status */
1262 azx_writel(chip, INTSTS, ICH6_INT_CTRL_EN | ICH6_INT_ALL_STREAM);
1263}
1264
1265/* start a stream */
1266static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev)
1267{
1268 /*
1269 * Before stream start, initialize parameter
1270 */
1271 azx_dev->insufficient = 1;
1272
1273 /* enable SIE */
1274 azx_writel(chip, INTCTL,
1275 azx_readl(chip, INTCTL) | (1 << azx_dev->index));
1276 /* set DMA start and interrupt mask */
1277 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
1278 SD_CTL_DMA_START | SD_INT_MASK);
1279}
1280
1281/* stop DMA */
1282static void azx_stream_clear(struct azx *chip, struct azx_dev *azx_dev)
1283{
1284 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) &
1285 ~(SD_CTL_DMA_START | SD_INT_MASK));
1286 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); /* to be sure */
1287}
1288
1289/* stop a stream */
1290static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
1291{
1292 azx_stream_clear(chip, azx_dev);
1293 /* disable SIE */
1294 azx_writel(chip, INTCTL,
1295 azx_readl(chip, INTCTL) & ~(1 << azx_dev->index));
1296}
1297
1298
1299/*
1300 * reset and start the controller registers
1301 */
1302static void azx_init_chip(struct azx *chip, int full_reset)
1303{
1304 if (chip->initialized)
1305 return;
1306
1307 /* reset controller */
1308 azx_reset(chip, full_reset);
1309
1310 /* initialize interrupts */
1311 azx_int_clear(chip);
1312 azx_int_enable(chip);
1313
1314 /* initialize the codec command I/O */
1315 if (!chip->single_cmd)
1316 azx_init_cmd_io(chip);
1317
1318 /* program the position buffer */
1319 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr);
1320 azx_writel(chip, DPUBASE, upper_32_bits(chip->posbuf.addr));
1321
1322 chip->initialized = 1;
1323}
1324 338
1325/* 339/*
1326 * initialize the PCI registers 340 * initialize the PCI registers
@@ -1346,7 +360,7 @@ static void azx_init_pci(struct azx *chip)
1346 * The PCI register TCSEL is defined in the Intel manuals. 360 * The PCI register TCSEL is defined in the Intel manuals.
1347 */ 361 */
1348 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) { 362 if (!(chip->driver_caps & AZX_DCAPS_NO_TCSEL)) {
1349 snd_printdd(SFX "%s: Clearing TCSEL\n", pci_name(chip->pci)); 363 dev_dbg(chip->card->dev, "Clearing TCSEL\n");
1350 update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0); 364 update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0);
1351 } 365 }
1352 366
@@ -1354,7 +368,8 @@ static void azx_init_pci(struct azx *chip)
1354 * we need to enable snoop. 368 * we need to enable snoop.
1355 */ 369 */
1356 if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) { 370 if (chip->driver_caps & AZX_DCAPS_ATI_SNOOP) {
1357 snd_printdd(SFX "%s: Setting ATI snoop: %d\n", pci_name(chip->pci), azx_snoop(chip)); 371 dev_dbg(chip->card->dev, "Setting ATI snoop: %d\n",
372 azx_snoop(chip));
1358 update_pci_byte(chip->pci, 373 update_pci_byte(chip->pci,
1359 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 0x07, 374 ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 0x07,
1360 azx_snoop(chip) ? ATI_SB450_HDAUDIO_ENABLE_SNOOP : 0); 375 azx_snoop(chip) ? ATI_SB450_HDAUDIO_ENABLE_SNOOP : 0);
@@ -1362,7 +377,8 @@ static void azx_init_pci(struct azx *chip)
1362 377
1363 /* For NVIDIA HDA, enable snoop */ 378 /* For NVIDIA HDA, enable snoop */
1364 if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) { 379 if (chip->driver_caps & AZX_DCAPS_NVIDIA_SNOOP) {
1365 snd_printdd(SFX "%s: Setting Nvidia snoop: %d\n", pci_name(chip->pci), azx_snoop(chip)); 380 dev_dbg(chip->card->dev, "Setting Nvidia snoop: %d\n",
381 azx_snoop(chip));
1366 update_pci_byte(chip->pci, 382 update_pci_byte(chip->pci,
1367 NVIDIA_HDA_TRANSREG_ADDR, 383 NVIDIA_HDA_TRANSREG_ADDR,
1368 0x0f, NVIDIA_HDA_ENABLE_COHBITS); 384 0x0f, NVIDIA_HDA_ENABLE_COHBITS);
@@ -1387,1114 +403,31 @@ static void azx_init_pci(struct azx *chip)
1387 pci_read_config_word(chip->pci, 403 pci_read_config_word(chip->pci,
1388 INTEL_SCH_HDA_DEVC, &snoop); 404 INTEL_SCH_HDA_DEVC, &snoop);
1389 } 405 }
1390 snd_printdd(SFX "%s: SCH snoop: %s\n", 406 dev_dbg(chip->card->dev, "SCH snoop: %s\n",
1391 pci_name(chip->pci), (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) 407 (snoop & INTEL_SCH_HDA_DEVC_NOSNOOP) ?
1392 ? "Disabled" : "Enabled"); 408 "Disabled" : "Enabled");
1393 } 409 }
1394} 410}
1395 411
1396
1397static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev); 412static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev);
1398 413
1399/* 414/* called from IRQ */
1400 * interrupt handler 415static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev)
1401 */
1402static irqreturn_t azx_interrupt(int irq, void *dev_id)
1403{
1404 struct azx *chip = dev_id;
1405 struct azx_dev *azx_dev;
1406 u32 status;
1407 u8 sd_status;
1408 int i, ok;
1409
1410#ifdef CONFIG_PM_RUNTIME
1411 if (chip->driver_caps & AZX_DCAPS_PM_RUNTIME)
1412 if (chip->pci->dev.power.runtime_status != RPM_ACTIVE)
1413 return IRQ_NONE;
1414#endif
1415
1416 spin_lock(&chip->reg_lock);
1417
1418 if (chip->disabled) {
1419 spin_unlock(&chip->reg_lock);
1420 return IRQ_NONE;
1421 }
1422
1423 status = azx_readl(chip, INTSTS);
1424 if (status == 0 || status == 0xffffffff) {
1425 spin_unlock(&chip->reg_lock);
1426 return IRQ_NONE;
1427 }
1428
1429 for (i = 0; i < chip->num_streams; i++) {
1430 azx_dev = &chip->azx_dev[i];
1431 if (status & azx_dev->sd_int_sta_mask) {
1432 sd_status = azx_sd_readb(azx_dev, SD_STS);
1433 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK);
1434 if (!azx_dev->substream || !azx_dev->running ||
1435 !(sd_status & SD_INT_COMPLETE))
1436 continue;
1437 /* check whether this IRQ is really acceptable */
1438 ok = azx_position_ok(chip, azx_dev);
1439 if (ok == 1) {
1440 azx_dev->irq_pending = 0;
1441 spin_unlock(&chip->reg_lock);
1442 snd_pcm_period_elapsed(azx_dev->substream);
1443 spin_lock(&chip->reg_lock);
1444 } else if (ok == 0 && chip->bus && chip->bus->workq) {
1445 /* bogus IRQ, process it later */
1446 azx_dev->irq_pending = 1;
1447 queue_work(chip->bus->workq,
1448 &chip->irq_pending_work);
1449 }
1450 }
1451 }
1452
1453 /* clear rirb int */
1454 status = azx_readb(chip, RIRBSTS);
1455 if (status & RIRB_INT_MASK) {
1456 if (status & RIRB_INT_RESPONSE) {
1457 if (chip->driver_caps & AZX_DCAPS_RIRB_PRE_DELAY)
1458 udelay(80);
1459 azx_update_rirb(chip);
1460 }
1461 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
1462 }
1463
1464#if 0
1465 /* clear state status int */
1466 if (azx_readw(chip, STATESTS) & 0x04)
1467 azx_writew(chip, STATESTS, 0x04);
1468#endif
1469 spin_unlock(&chip->reg_lock);
1470
1471 return IRQ_HANDLED;
1472}
1473
1474
1475/*
1476 * set up a BDL entry
1477 */
1478static int setup_bdle(struct azx *chip,
1479 struct snd_dma_buffer *dmab,
1480 struct azx_dev *azx_dev, u32 **bdlp,
1481 int ofs, int size, int with_ioc)
1482{
1483 u32 *bdl = *bdlp;
1484
1485 while (size > 0) {
1486 dma_addr_t addr;
1487 int chunk;
1488
1489 if (azx_dev->frags >= AZX_MAX_BDL_ENTRIES)
1490 return -EINVAL;
1491
1492 addr = snd_sgbuf_get_addr(dmab, ofs);
1493 /* program the address field of the BDL entry */
1494 bdl[0] = cpu_to_le32((u32)addr);
1495 bdl[1] = cpu_to_le32(upper_32_bits(addr));
1496 /* program the size field of the BDL entry */
1497 chunk = snd_sgbuf_get_chunk_size(dmab, ofs, size);
1498 /* one BDLE cannot cross 4K boundary on CTHDA chips */
1499 if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY) {
1500 u32 remain = 0x1000 - (ofs & 0xfff);
1501 if (chunk > remain)
1502 chunk = remain;
1503 }
1504 bdl[2] = cpu_to_le32(chunk);
1505 /* program the IOC to enable interrupt
1506 * only when the whole fragment is processed
1507 */
1508 size -= chunk;
1509 bdl[3] = (size || !with_ioc) ? 0 : cpu_to_le32(0x01);
1510 bdl += 4;
1511 azx_dev->frags++;
1512 ofs += chunk;
1513 }
1514 *bdlp = bdl;
1515 return ofs;
1516}
1517
1518/*
1519 * set up BDL entries
1520 */
1521static int azx_setup_periods(struct azx *chip,
1522 struct snd_pcm_substream *substream,
1523 struct azx_dev *azx_dev)
1524{
1525 u32 *bdl;
1526 int i, ofs, periods, period_bytes;
1527 int pos_adj;
1528
1529 /* reset BDL address */
1530 azx_sd_writel(azx_dev, SD_BDLPL, 0);
1531 azx_sd_writel(azx_dev, SD_BDLPU, 0);
1532
1533 period_bytes = azx_dev->period_bytes;
1534 periods = azx_dev->bufsize / period_bytes;
1535
1536 /* program the initial BDL entries */
1537 bdl = (u32 *)azx_dev->bdl.area;
1538 ofs = 0;
1539 azx_dev->frags = 0;
1540 pos_adj = bdl_pos_adj[chip->dev_index];
1541 if (!azx_dev->no_period_wakeup && pos_adj > 0) {
1542 struct snd_pcm_runtime *runtime = substream->runtime;
1543 int pos_align = pos_adj;
1544 pos_adj = (pos_adj * runtime->rate + 47999) / 48000;
1545 if (!pos_adj)
1546 pos_adj = pos_align;
1547 else
1548 pos_adj = ((pos_adj + pos_align - 1) / pos_align) *
1549 pos_align;
1550 pos_adj = frames_to_bytes(runtime, pos_adj);
1551 if (pos_adj >= period_bytes) {
1552 snd_printk(KERN_WARNING SFX "%s: Too big adjustment %d\n",
1553 pci_name(chip->pci), bdl_pos_adj[chip->dev_index]);
1554 pos_adj = 0;
1555 } else {
1556 ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
1557 azx_dev,
1558 &bdl, ofs, pos_adj, true);
1559 if (ofs < 0)
1560 goto error;
1561 }
1562 } else
1563 pos_adj = 0;
1564 for (i = 0; i < periods; i++) {
1565 if (i == periods - 1 && pos_adj)
1566 ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
1567 azx_dev, &bdl, ofs,
1568 period_bytes - pos_adj, 0);
1569 else
1570 ofs = setup_bdle(chip, snd_pcm_get_dma_buf(substream),
1571 azx_dev, &bdl, ofs,
1572 period_bytes,
1573 !azx_dev->no_period_wakeup);
1574 if (ofs < 0)
1575 goto error;
1576 }
1577 return 0;
1578
1579 error:
1580 snd_printk(KERN_ERR SFX "%s: Too many BDL entries: buffer=%d, period=%d\n",
1581 pci_name(chip->pci), azx_dev->bufsize, period_bytes);
1582 return -EINVAL;
1583}
1584
1585/* reset stream */
1586static void azx_stream_reset(struct azx *chip, struct azx_dev *azx_dev)
1587{
1588 unsigned char val;
1589 int timeout;
1590
1591 azx_stream_clear(chip, azx_dev);
1592
1593 azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) |
1594 SD_CTL_STREAM_RESET);
1595 udelay(3);
1596 timeout = 300;
1597 while (!((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
1598 --timeout)
1599 ;
1600 val &= ~SD_CTL_STREAM_RESET;
1601 azx_sd_writeb(azx_dev, SD_CTL, val);
1602 udelay(3);
1603
1604 timeout = 300;
1605 /* waiting for hardware to report that the stream is out of reset */
1606 while (((val = azx_sd_readb(azx_dev, SD_CTL)) & SD_CTL_STREAM_RESET) &&
1607 --timeout)
1608 ;
1609
1610 /* reset first position - may not be synced with hw at this time */
1611 *azx_dev->posbuf = 0;
1612}
1613
1614/*
1615 * set up the SD for streaming
1616 */
1617static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev)
1618{
1619 unsigned int val;
1620 /* make sure the run bit is zero for SD */
1621 azx_stream_clear(chip, azx_dev);
1622 /* program the stream_tag */
1623 val = azx_sd_readl(azx_dev, SD_CTL);
1624 val = (val & ~SD_CTL_STREAM_TAG_MASK) |
1625 (azx_dev->stream_tag << SD_CTL_STREAM_TAG_SHIFT);
1626 if (!azx_snoop(chip))
1627 val |= SD_CTL_TRAFFIC_PRIO;
1628 azx_sd_writel(azx_dev, SD_CTL, val);
1629
1630 /* program the length of samples in cyclic buffer */
1631 azx_sd_writel(azx_dev, SD_CBL, azx_dev->bufsize);
1632
1633 /* program the stream format */
1634 /* this value needs to be the same as the one programmed */
1635 azx_sd_writew(azx_dev, SD_FORMAT, azx_dev->format_val);
1636
1637 /* program the stream LVI (last valid index) of the BDL */
1638 azx_sd_writew(azx_dev, SD_LVI, azx_dev->frags - 1);
1639
1640 /* program the BDL address */
1641 /* lower BDL address */
1642 azx_sd_writel(azx_dev, SD_BDLPL, (u32)azx_dev->bdl.addr);
1643 /* upper BDL address */
1644 azx_sd_writel(azx_dev, SD_BDLPU, upper_32_bits(azx_dev->bdl.addr));
1645
1646 /* enable the position buffer */
1647 if (chip->position_fix[0] != POS_FIX_LPIB ||
1648 chip->position_fix[1] != POS_FIX_LPIB) {
1649 if (!(azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE))
1650 azx_writel(chip, DPLBASE,
1651 (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE);
1652 }
1653
1654 /* set the interrupt enable bits in the descriptor control register */
1655 azx_sd_writel(azx_dev, SD_CTL,
1656 azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK);
1657
1658 return 0;
1659}
1660
1661/*
1662 * Probe the given codec address
1663 */
1664static int probe_codec(struct azx *chip, int addr)
1665{
1666 unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
1667 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
1668 unsigned int res;
1669
1670 mutex_lock(&chip->bus->cmd_mutex);
1671 chip->probing = 1;
1672 azx_send_cmd(chip->bus, cmd);
1673 res = azx_get_response(chip->bus, addr);
1674 chip->probing = 0;
1675 mutex_unlock(&chip->bus->cmd_mutex);
1676 if (res == -1)
1677 return -EIO;
1678 snd_printdd(SFX "%s: codec #%d probed OK\n", pci_name(chip->pci), addr);
1679 return 0;
1680}
1681
1682static int azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
1683 struct hda_pcm *cpcm);
1684static void azx_stop_chip(struct azx *chip);
1685
1686static void azx_bus_reset(struct hda_bus *bus)
1687{
1688 struct azx *chip = bus->private_data;
1689
1690 bus->in_reset = 1;
1691 azx_stop_chip(chip);
1692 azx_init_chip(chip, 1);
1693#ifdef CONFIG_PM
1694 if (chip->initialized) {
1695 struct azx_pcm *p;
1696 list_for_each_entry(p, &chip->pcm_list, list)
1697 snd_pcm_suspend_all(p->pcm);
1698 snd_hda_suspend(chip->bus);
1699 snd_hda_resume(chip->bus);
1700 }
1701#endif
1702 bus->in_reset = 0;
1703}
1704
1705static int get_jackpoll_interval(struct azx *chip)
1706{
1707 int i = jackpoll_ms[chip->dev_index];
1708 unsigned int j;
1709 if (i == 0)
1710 return 0;
1711 if (i < 50 || i > 60000)
1712 j = 0;
1713 else
1714 j = msecs_to_jiffies(i);
1715 if (j == 0)
1716 snd_printk(KERN_WARNING SFX
1717 "jackpoll_ms value out of range: %d\n", i);
1718 return j;
1719}
1720
1721/*
1722 * Codec initialization
1723 */
1724
1725/* number of codec slots for each chipset: 0 = default slots (i.e. 4) */
1726static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = {
1727 [AZX_DRIVER_NVIDIA] = 8,
1728 [AZX_DRIVER_TERA] = 1,
1729};
1730
1731static int azx_codec_create(struct azx *chip, const char *model)
1732{
1733 struct hda_bus_template bus_temp;
1734 int c, codecs, err;
1735 int max_slots;
1736
1737 memset(&bus_temp, 0, sizeof(bus_temp));
1738 bus_temp.private_data = chip;
1739 bus_temp.modelname = model;
1740 bus_temp.pci = chip->pci;
1741 bus_temp.ops.command = azx_send_cmd;
1742 bus_temp.ops.get_response = azx_get_response;
1743 bus_temp.ops.attach_pcm = azx_attach_pcm_stream;
1744 bus_temp.ops.bus_reset = azx_bus_reset;
1745#ifdef CONFIG_PM
1746 bus_temp.power_save = &power_save;
1747 bus_temp.ops.pm_notify = azx_power_notify;
1748#endif
1749#ifdef CONFIG_SND_HDA_DSP_LOADER
1750 bus_temp.ops.load_dsp_prepare = azx_load_dsp_prepare;
1751 bus_temp.ops.load_dsp_trigger = azx_load_dsp_trigger;
1752 bus_temp.ops.load_dsp_cleanup = azx_load_dsp_cleanup;
1753#endif
1754
1755 err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus);
1756 if (err < 0)
1757 return err;
1758
1759 if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) {
1760 snd_printd(SFX "%s: Enable delay in RIRB handling\n", pci_name(chip->pci));
1761 chip->bus->needs_damn_long_delay = 1;
1762 }
1763
1764 codecs = 0;
1765 max_slots = azx_max_codecs[chip->driver_type];
1766 if (!max_slots)
1767 max_slots = AZX_DEFAULT_CODECS;
1768
1769 /* First try to probe all given codec slots */
1770 for (c = 0; c < max_slots; c++) {
1771 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1772 if (probe_codec(chip, c) < 0) {
1773 /* Some BIOSen give you wrong codec addresses
1774 * that don't exist
1775 */
1776 snd_printk(KERN_WARNING SFX
1777 "%s: Codec #%d probe error; "
1778 "disabling it...\n", pci_name(chip->pci), c);
1779 chip->codec_mask &= ~(1 << c);
1780 /* More badly, accessing to a non-existing
1781 * codec often screws up the controller chip,
1782 * and disturbs the further communications.
1783 * Thus if an error occurs during probing,
1784 * better to reset the controller chip to
1785 * get back to the sanity state.
1786 */
1787 azx_stop_chip(chip);
1788 azx_init_chip(chip, 1);
1789 }
1790 }
1791 }
1792
1793 /* AMD chipsets often cause the communication stalls upon certain
1794 * sequence like the pin-detection. It seems that forcing the synced
1795 * access works around the stall. Grrr...
1796 */
1797 if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) {
1798 snd_printd(SFX "%s: Enable sync_write for stable communication\n",
1799 pci_name(chip->pci));
1800 chip->bus->sync_write = 1;
1801 chip->bus->allow_bus_reset = 1;
1802 }
1803
1804 /* Then create codec instances */
1805 for (c = 0; c < max_slots; c++) {
1806 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1807 struct hda_codec *codec;
1808 err = snd_hda_codec_new(chip->bus, c, &codec);
1809 if (err < 0)
1810 continue;
1811 codec->jackpoll_interval = get_jackpoll_interval(chip);
1812 codec->beep_mode = chip->beep_mode;
1813 codecs++;
1814 }
1815 }
1816 if (!codecs) {
1817 snd_printk(KERN_ERR SFX "%s: no codecs initialized\n", pci_name(chip->pci));
1818 return -ENXIO;
1819 }
1820 return 0;
1821}
1822
1823/* configure each codec instance */
1824static int azx_codec_configure(struct azx *chip)
1825{
1826 struct hda_codec *codec;
1827 list_for_each_entry(codec, &chip->bus->codec_list, list) {
1828 snd_hda_codec_configure(codec);
1829 }
1830 return 0;
1831}
1832
1833
1834/*
1835 * PCM support
1836 */
1837
1838/* assign a stream for the PCM */
1839static inline struct azx_dev *
1840azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
1841{
1842 int dev, i, nums;
1843 struct azx_dev *res = NULL;
1844 /* make a non-zero unique key for the substream */
1845 int key = (substream->pcm->device << 16) | (substream->number << 2) |
1846 (substream->stream + 1);
1847
1848 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1849 dev = chip->playback_index_offset;
1850 nums = chip->playback_streams;
1851 } else {
1852 dev = chip->capture_index_offset;
1853 nums = chip->capture_streams;
1854 }
1855 for (i = 0; i < nums; i++, dev++) {
1856 struct azx_dev *azx_dev = &chip->azx_dev[dev];
1857 dsp_lock(azx_dev);
1858 if (!azx_dev->opened && !dsp_is_locked(azx_dev)) {
1859 res = azx_dev;
1860 if (res->assigned_key == key) {
1861 res->opened = 1;
1862 res->assigned_key = key;
1863 dsp_unlock(azx_dev);
1864 return azx_dev;
1865 }
1866 }
1867 dsp_unlock(azx_dev);
1868 }
1869 if (res) {
1870 dsp_lock(res);
1871 res->opened = 1;
1872 res->assigned_key = key;
1873 dsp_unlock(res);
1874 }
1875 return res;
1876}
1877
1878/* release the assigned stream */
1879static inline void azx_release_device(struct azx_dev *azx_dev)
1880{ 416{
1881 azx_dev->opened = 0; 417 int ok;
1882}
1883
1884static cycle_t azx_cc_read(const struct cyclecounter *cc)
1885{
1886 struct azx_dev *azx_dev = container_of(cc, struct azx_dev, azx_cc);
1887 struct snd_pcm_substream *substream = azx_dev->substream;
1888 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1889 struct azx *chip = apcm->chip;
1890
1891 return azx_readl(chip, WALLCLK);
1892}
1893
1894static void azx_timecounter_init(struct snd_pcm_substream *substream,
1895 bool force, cycle_t last)
1896{
1897 struct azx_dev *azx_dev = get_azx_dev(substream);
1898 struct timecounter *tc = &azx_dev->azx_tc;
1899 struct cyclecounter *cc = &azx_dev->azx_cc;
1900 u64 nsec;
1901
1902 cc->read = azx_cc_read;
1903 cc->mask = CLOCKSOURCE_MASK(32);
1904
1905 /*
1906 * Converting from 24 MHz to ns means applying a 125/3 factor.
1907 * To avoid any saturation issues in intermediate operations,
1908 * the 125 factor is applied first. The division is applied
1909 * last after reading the timecounter value.
1910 * Applying the 1/3 factor as part of the multiplication
1911 * requires at least 20 bits for a decent precision, however
1912 * overflows occur after about 4 hours or less, not a option.
1913 */
1914
1915 cc->mult = 125; /* saturation after 195 years */
1916 cc->shift = 0;
1917
1918 nsec = 0; /* audio time is elapsed time since trigger */
1919 timecounter_init(tc, cc, nsec);
1920 if (force)
1921 /*
1922 * force timecounter to use predefined value,
1923 * used for synchronized starts
1924 */
1925 tc->cycle_last = last;
1926}
1927
1928static u64 azx_adjust_codec_delay(struct snd_pcm_substream *substream,
1929 u64 nsec)
1930{
1931 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1932 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1933 u64 codec_frames, codec_nsecs;
1934
1935 if (!hinfo->ops.get_delay)
1936 return nsec;
1937
1938 codec_frames = hinfo->ops.get_delay(hinfo, apcm->codec, substream);
1939 codec_nsecs = div_u64(codec_frames * 1000000000LL,
1940 substream->runtime->rate);
1941
1942 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
1943 return nsec + codec_nsecs;
1944
1945 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
1946}
1947
1948static int azx_get_wallclock_tstamp(struct snd_pcm_substream *substream,
1949 struct timespec *ts)
1950{
1951 struct azx_dev *azx_dev = get_azx_dev(substream);
1952 u64 nsec;
1953
1954 nsec = timecounter_read(&azx_dev->azx_tc);
1955 nsec = div_u64(nsec, 3); /* can be optimized */
1956 nsec = azx_adjust_codec_delay(substream, nsec);
1957
1958 *ts = ns_to_timespec(nsec);
1959
1960 return 0;
1961}
1962
1963static struct snd_pcm_hardware azx_pcm_hw = {
1964 .info = (SNDRV_PCM_INFO_MMAP |
1965 SNDRV_PCM_INFO_INTERLEAVED |
1966 SNDRV_PCM_INFO_BLOCK_TRANSFER |
1967 SNDRV_PCM_INFO_MMAP_VALID |
1968 /* No full-resume yet implemented */
1969 /* SNDRV_PCM_INFO_RESUME |*/
1970 SNDRV_PCM_INFO_PAUSE |
1971 SNDRV_PCM_INFO_SYNC_START |
1972 SNDRV_PCM_INFO_HAS_WALL_CLOCK |
1973 SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
1974 .formats = SNDRV_PCM_FMTBIT_S16_LE,
1975 .rates = SNDRV_PCM_RATE_48000,
1976 .rate_min = 48000,
1977 .rate_max = 48000,
1978 .channels_min = 2,
1979 .channels_max = 2,
1980 .buffer_bytes_max = AZX_MAX_BUF_SIZE,
1981 .period_bytes_min = 128,
1982 .period_bytes_max = AZX_MAX_BUF_SIZE / 2,
1983 .periods_min = 2,
1984 .periods_max = AZX_MAX_FRAG,
1985 .fifo_size = 0,
1986};
1987
1988static int azx_pcm_open(struct snd_pcm_substream *substream)
1989{
1990 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1991 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
1992 struct azx *chip = apcm->chip;
1993 struct azx_dev *azx_dev;
1994 struct snd_pcm_runtime *runtime = substream->runtime;
1995 unsigned long flags;
1996 int err;
1997 int buff_step;
1998 418
1999 mutex_lock(&chip->open_mutex); 419 ok = azx_position_ok(chip, azx_dev);
2000 azx_dev = azx_assign_device(chip, substream); 420 if (ok == 1) {
2001 if (azx_dev == NULL) { 421 azx_dev->irq_pending = 0;
2002 mutex_unlock(&chip->open_mutex); 422 return ok;
2003 return -EBUSY; 423 } else if (ok == 0 && chip->bus && chip->bus->workq) {
2004 } 424 /* bogus IRQ, process it later */
2005 runtime->hw = azx_pcm_hw; 425 azx_dev->irq_pending = 1;
2006 runtime->hw.channels_min = hinfo->channels_min; 426 queue_work(chip->bus->workq, &chip->irq_pending_work);
2007 runtime->hw.channels_max = hinfo->channels_max;
2008 runtime->hw.formats = hinfo->formats;
2009 runtime->hw.rates = hinfo->rates;
2010 snd_pcm_limit_hw_rates(runtime);
2011 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
2012
2013 /* avoid wrap-around with wall-clock */
2014 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
2015 20,
2016 178000000);
2017
2018 if (chip->align_buffer_size)
2019 /* constrain buffer sizes to be multiple of 128
2020 bytes. This is more efficient in terms of memory
2021 access but isn't required by the HDA spec and
2022 prevents users from specifying exact period/buffer
2023 sizes. For example for 44.1kHz, a period size set
2024 to 20ms will be rounded to 19.59ms. */
2025 buff_step = 128;
2026 else
2027 /* Don't enforce steps on buffer sizes, still need to
2028 be multiple of 4 bytes (HDA spec). Tested on Intel
2029 HDA controllers, may not work on all devices where
2030 option needs to be disabled */
2031 buff_step = 4;
2032
2033 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
2034 buff_step);
2035 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
2036 buff_step);
2037 snd_hda_power_up_d3wait(apcm->codec);
2038 err = hinfo->ops.open(hinfo, apcm->codec, substream);
2039 if (err < 0) {
2040 azx_release_device(azx_dev);
2041 snd_hda_power_down(apcm->codec);
2042 mutex_unlock(&chip->open_mutex);
2043 return err;
2044 } 427 }
2045 snd_pcm_limit_hw_rates(runtime);
2046 /* sanity check */
2047 if (snd_BUG_ON(!runtime->hw.channels_min) ||
2048 snd_BUG_ON(!runtime->hw.channels_max) ||
2049 snd_BUG_ON(!runtime->hw.formats) ||
2050 snd_BUG_ON(!runtime->hw.rates)) {
2051 azx_release_device(azx_dev);
2052 hinfo->ops.close(hinfo, apcm->codec, substream);
2053 snd_hda_power_down(apcm->codec);
2054 mutex_unlock(&chip->open_mutex);
2055 return -EINVAL;
2056 }
2057
2058 /* disable WALLCLOCK timestamps for capture streams
2059 until we figure out how to handle digital inputs */
2060 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
2061 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK;
2062
2063 spin_lock_irqsave(&chip->reg_lock, flags);
2064 azx_dev->substream = substream;
2065 azx_dev->running = 0;
2066 spin_unlock_irqrestore(&chip->reg_lock, flags);
2067
2068 runtime->private_data = azx_dev;
2069 snd_pcm_set_sync(substream);
2070 mutex_unlock(&chip->open_mutex);
2071 return 0; 428 return 0;
2072} 429}
2073 430
2074static int azx_pcm_close(struct snd_pcm_substream *substream)
2075{
2076 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2077 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
2078 struct azx *chip = apcm->chip;
2079 struct azx_dev *azx_dev = get_azx_dev(substream);
2080 unsigned long flags;
2081
2082 mutex_lock(&chip->open_mutex);
2083 spin_lock_irqsave(&chip->reg_lock, flags);
2084 azx_dev->substream = NULL;
2085 azx_dev->running = 0;
2086 spin_unlock_irqrestore(&chip->reg_lock, flags);
2087 azx_release_device(azx_dev);
2088 hinfo->ops.close(hinfo, apcm->codec, substream);
2089 snd_hda_power_down(apcm->codec);
2090 mutex_unlock(&chip->open_mutex);
2091 return 0;
2092}
2093
2094static int azx_pcm_hw_params(struct snd_pcm_substream *substream,
2095 struct snd_pcm_hw_params *hw_params)
2096{
2097 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2098 struct azx *chip = apcm->chip;
2099 struct azx_dev *azx_dev = get_azx_dev(substream);
2100 int ret;
2101
2102 dsp_lock(azx_dev);
2103 if (dsp_is_locked(azx_dev)) {
2104 ret = -EBUSY;
2105 goto unlock;
2106 }
2107
2108 mark_runtime_wc(chip, azx_dev, substream, false);
2109 azx_dev->bufsize = 0;
2110 azx_dev->period_bytes = 0;
2111 azx_dev->format_val = 0;
2112 ret = snd_pcm_lib_malloc_pages(substream,
2113 params_buffer_bytes(hw_params));
2114 if (ret < 0)
2115 goto unlock;
2116 mark_runtime_wc(chip, azx_dev, substream, true);
2117 unlock:
2118 dsp_unlock(azx_dev);
2119 return ret;
2120}
2121
2122static int azx_pcm_hw_free(struct snd_pcm_substream *substream)
2123{
2124 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2125 struct azx_dev *azx_dev = get_azx_dev(substream);
2126 struct azx *chip = apcm->chip;
2127 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
2128
2129 /* reset BDL address */
2130 dsp_lock(azx_dev);
2131 if (!dsp_is_locked(azx_dev)) {
2132 azx_sd_writel(azx_dev, SD_BDLPL, 0);
2133 azx_sd_writel(azx_dev, SD_BDLPU, 0);
2134 azx_sd_writel(azx_dev, SD_CTL, 0);
2135 azx_dev->bufsize = 0;
2136 azx_dev->period_bytes = 0;
2137 azx_dev->format_val = 0;
2138 }
2139
2140 snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
2141
2142 mark_runtime_wc(chip, azx_dev, substream, false);
2143 azx_dev->prepared = 0;
2144 dsp_unlock(azx_dev);
2145 return snd_pcm_lib_free_pages(substream);
2146}
2147
2148static int azx_pcm_prepare(struct snd_pcm_substream *substream)
2149{
2150 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2151 struct azx *chip = apcm->chip;
2152 struct azx_dev *azx_dev = get_azx_dev(substream);
2153 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream];
2154 struct snd_pcm_runtime *runtime = substream->runtime;
2155 unsigned int bufsize, period_bytes, format_val, stream_tag;
2156 int err;
2157 struct hda_spdif_out *spdif =
2158 snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid);
2159 unsigned short ctls = spdif ? spdif->ctls : 0;
2160
2161 dsp_lock(azx_dev);
2162 if (dsp_is_locked(azx_dev)) {
2163 err = -EBUSY;
2164 goto unlock;
2165 }
2166
2167 azx_stream_reset(chip, azx_dev);
2168 format_val = snd_hda_calc_stream_format(runtime->rate,
2169 runtime->channels,
2170 runtime->format,
2171 hinfo->maxbps,
2172 ctls);
2173 if (!format_val) {
2174 snd_printk(KERN_ERR SFX
2175 "%s: invalid format_val, rate=%d, ch=%d, format=%d\n",
2176 pci_name(chip->pci), runtime->rate, runtime->channels, runtime->format);
2177 err = -EINVAL;
2178 goto unlock;
2179 }
2180
2181 bufsize = snd_pcm_lib_buffer_bytes(substream);
2182 period_bytes = snd_pcm_lib_period_bytes(substream);
2183
2184 snd_printdd(SFX "%s: azx_pcm_prepare: bufsize=0x%x, format=0x%x\n",
2185 pci_name(chip->pci), bufsize, format_val);
2186
2187 if (bufsize != azx_dev->bufsize ||
2188 period_bytes != azx_dev->period_bytes ||
2189 format_val != azx_dev->format_val ||
2190 runtime->no_period_wakeup != azx_dev->no_period_wakeup) {
2191 azx_dev->bufsize = bufsize;
2192 azx_dev->period_bytes = period_bytes;
2193 azx_dev->format_val = format_val;
2194 azx_dev->no_period_wakeup = runtime->no_period_wakeup;
2195 err = azx_setup_periods(chip, substream, azx_dev);
2196 if (err < 0)
2197 goto unlock;
2198 }
2199
2200 /* when LPIB delay correction gives a small negative value,
2201 * we ignore it; currently set the threshold statically to
2202 * 64 frames
2203 */
2204 if (runtime->period_size > 64)
2205 azx_dev->delay_negative_threshold = -frames_to_bytes(runtime, 64);
2206 else
2207 azx_dev->delay_negative_threshold = 0;
2208
2209 /* wallclk has 24Mhz clock source */
2210 azx_dev->period_wallclk = (((runtime->period_size * 24000) /
2211 runtime->rate) * 1000);
2212 azx_setup_controller(chip, azx_dev);
2213 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
2214 azx_dev->fifo_size = azx_sd_readw(azx_dev, SD_FIFOSIZE) + 1;
2215 else
2216 azx_dev->fifo_size = 0;
2217
2218 stream_tag = azx_dev->stream_tag;
2219 /* CA-IBG chips need the playback stream starting from 1 */
2220 if ((chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) &&
2221 stream_tag > chip->capture_streams)
2222 stream_tag -= chip->capture_streams;
2223 err = snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag,
2224 azx_dev->format_val, substream);
2225
2226 unlock:
2227 if (!err)
2228 azx_dev->prepared = 1;
2229 dsp_unlock(azx_dev);
2230 return err;
2231}
2232
2233static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
2234{
2235 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2236 struct azx *chip = apcm->chip;
2237 struct azx_dev *azx_dev;
2238 struct snd_pcm_substream *s;
2239 int rstart = 0, start, nsync = 0, sbits = 0;
2240 int nwait, timeout;
2241
2242 azx_dev = get_azx_dev(substream);
2243 trace_azx_pcm_trigger(chip, azx_dev, cmd);
2244
2245 if (dsp_is_locked(azx_dev) || !azx_dev->prepared)
2246 return -EPIPE;
2247
2248 switch (cmd) {
2249 case SNDRV_PCM_TRIGGER_START:
2250 rstart = 1;
2251 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
2252 case SNDRV_PCM_TRIGGER_RESUME:
2253 start = 1;
2254 break;
2255 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
2256 case SNDRV_PCM_TRIGGER_SUSPEND:
2257 case SNDRV_PCM_TRIGGER_STOP:
2258 start = 0;
2259 break;
2260 default:
2261 return -EINVAL;
2262 }
2263
2264 snd_pcm_group_for_each_entry(s, substream) {
2265 if (s->pcm->card != substream->pcm->card)
2266 continue;
2267 azx_dev = get_azx_dev(s);
2268 sbits |= 1 << azx_dev->index;
2269 nsync++;
2270 snd_pcm_trigger_done(s, substream);
2271 }
2272
2273 spin_lock(&chip->reg_lock);
2274
2275 /* first, set SYNC bits of corresponding streams */
2276 if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
2277 azx_writel(chip, OLD_SSYNC,
2278 azx_readl(chip, OLD_SSYNC) | sbits);
2279 else
2280 azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) | sbits);
2281
2282 snd_pcm_group_for_each_entry(s, substream) {
2283 if (s->pcm->card != substream->pcm->card)
2284 continue;
2285 azx_dev = get_azx_dev(s);
2286 if (start) {
2287 azx_dev->start_wallclk = azx_readl(chip, WALLCLK);
2288 if (!rstart)
2289 azx_dev->start_wallclk -=
2290 azx_dev->period_wallclk;
2291 azx_stream_start(chip, azx_dev);
2292 } else {
2293 azx_stream_stop(chip, azx_dev);
2294 }
2295 azx_dev->running = start;
2296 }
2297 spin_unlock(&chip->reg_lock);
2298 if (start) {
2299 /* wait until all FIFOs get ready */
2300 for (timeout = 5000; timeout; timeout--) {
2301 nwait = 0;
2302 snd_pcm_group_for_each_entry(s, substream) {
2303 if (s->pcm->card != substream->pcm->card)
2304 continue;
2305 azx_dev = get_azx_dev(s);
2306 if (!(azx_sd_readb(azx_dev, SD_STS) &
2307 SD_STS_FIFO_READY))
2308 nwait++;
2309 }
2310 if (!nwait)
2311 break;
2312 cpu_relax();
2313 }
2314 } else {
2315 /* wait until all RUN bits are cleared */
2316 for (timeout = 5000; timeout; timeout--) {
2317 nwait = 0;
2318 snd_pcm_group_for_each_entry(s, substream) {
2319 if (s->pcm->card != substream->pcm->card)
2320 continue;
2321 azx_dev = get_azx_dev(s);
2322 if (azx_sd_readb(azx_dev, SD_CTL) &
2323 SD_CTL_DMA_START)
2324 nwait++;
2325 }
2326 if (!nwait)
2327 break;
2328 cpu_relax();
2329 }
2330 }
2331 spin_lock(&chip->reg_lock);
2332 /* reset SYNC bits */
2333 if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
2334 azx_writel(chip, OLD_SSYNC,
2335 azx_readl(chip, OLD_SSYNC) & ~sbits);
2336 else
2337 azx_writel(chip, SSYNC, azx_readl(chip, SSYNC) & ~sbits);
2338 if (start) {
2339 azx_timecounter_init(substream, 0, 0);
2340 if (nsync > 1) {
2341 cycle_t cycle_last;
2342
2343 /* same start cycle for master and group */
2344 azx_dev = get_azx_dev(substream);
2345 cycle_last = azx_dev->azx_tc.cycle_last;
2346
2347 snd_pcm_group_for_each_entry(s, substream) {
2348 if (s->pcm->card != substream->pcm->card)
2349 continue;
2350 azx_timecounter_init(s, 1, cycle_last);
2351 }
2352 }
2353 }
2354 spin_unlock(&chip->reg_lock);
2355 return 0;
2356}
2357
2358/* get the current DMA position with correction on VIA chips */
2359static unsigned int azx_via_get_position(struct azx *chip,
2360 struct azx_dev *azx_dev)
2361{
2362 unsigned int link_pos, mini_pos, bound_pos;
2363 unsigned int mod_link_pos, mod_dma_pos, mod_mini_pos;
2364 unsigned int fifo_size;
2365
2366 link_pos = azx_sd_readl(azx_dev, SD_LPIB);
2367 if (azx_dev->substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
2368 /* Playback, no problem using link position */
2369 return link_pos;
2370 }
2371
2372 /* Capture */
2373 /* For new chipset,
2374 * use mod to get the DMA position just like old chipset
2375 */
2376 mod_dma_pos = le32_to_cpu(*azx_dev->posbuf);
2377 mod_dma_pos %= azx_dev->period_bytes;
2378
2379 /* azx_dev->fifo_size can't get FIFO size of in stream.
2380 * Get from base address + offset.
2381 */
2382 fifo_size = readw(chip->remap_addr + VIA_IN_STREAM0_FIFO_SIZE_OFFSET);
2383
2384 if (azx_dev->insufficient) {
2385 /* Link position never gather than FIFO size */
2386 if (link_pos <= fifo_size)
2387 return 0;
2388
2389 azx_dev->insufficient = 0;
2390 }
2391
2392 if (link_pos <= fifo_size)
2393 mini_pos = azx_dev->bufsize + link_pos - fifo_size;
2394 else
2395 mini_pos = link_pos - fifo_size;
2396
2397 /* Find nearest previous boudary */
2398 mod_mini_pos = mini_pos % azx_dev->period_bytes;
2399 mod_link_pos = link_pos % azx_dev->period_bytes;
2400 if (mod_link_pos >= fifo_size)
2401 bound_pos = link_pos - mod_link_pos;
2402 else if (mod_dma_pos >= mod_mini_pos)
2403 bound_pos = mini_pos - mod_mini_pos;
2404 else {
2405 bound_pos = mini_pos - mod_mini_pos + azx_dev->period_bytes;
2406 if (bound_pos >= azx_dev->bufsize)
2407 bound_pos = 0;
2408 }
2409
2410 /* Calculate real DMA position we want */
2411 return bound_pos + mod_dma_pos;
2412}
2413
2414static unsigned int azx_get_position(struct azx *chip,
2415 struct azx_dev *azx_dev,
2416 bool with_check)
2417{
2418 struct snd_pcm_substream *substream = azx_dev->substream;
2419 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2420 unsigned int pos;
2421 int stream = substream->stream;
2422 struct hda_pcm_stream *hinfo = apcm->hinfo[stream];
2423 int delay = 0;
2424
2425 switch (chip->position_fix[stream]) {
2426 case POS_FIX_LPIB:
2427 /* read LPIB */
2428 pos = azx_sd_readl(azx_dev, SD_LPIB);
2429 break;
2430 case POS_FIX_VIACOMBO:
2431 pos = azx_via_get_position(chip, azx_dev);
2432 break;
2433 default:
2434 /* use the position buffer */
2435 pos = le32_to_cpu(*azx_dev->posbuf);
2436 if (with_check && chip->position_fix[stream] == POS_FIX_AUTO) {
2437 if (!pos || pos == (u32)-1) {
2438 printk(KERN_WARNING
2439 "hda-intel: Invalid position buffer, "
2440 "using LPIB read method instead.\n");
2441 chip->position_fix[stream] = POS_FIX_LPIB;
2442 pos = azx_sd_readl(azx_dev, SD_LPIB);
2443 } else
2444 chip->position_fix[stream] = POS_FIX_POSBUF;
2445 }
2446 break;
2447 }
2448
2449 if (pos >= azx_dev->bufsize)
2450 pos = 0;
2451
2452 /* calculate runtime delay from LPIB */
2453 if (substream->runtime &&
2454 chip->position_fix[stream] == POS_FIX_POSBUF &&
2455 (chip->driver_caps & AZX_DCAPS_COUNT_LPIB_DELAY)) {
2456 unsigned int lpib_pos = azx_sd_readl(azx_dev, SD_LPIB);
2457 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
2458 delay = pos - lpib_pos;
2459 else
2460 delay = lpib_pos - pos;
2461 if (delay < 0) {
2462 if (delay >= azx_dev->delay_negative_threshold)
2463 delay = 0;
2464 else
2465 delay += azx_dev->bufsize;
2466 }
2467 if (delay >= azx_dev->period_bytes) {
2468 snd_printk(KERN_WARNING SFX
2469 "%s: Unstable LPIB (%d >= %d); "
2470 "disabling LPIB delay counting\n",
2471 pci_name(chip->pci), delay, azx_dev->period_bytes);
2472 delay = 0;
2473 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY;
2474 }
2475 delay = bytes_to_frames(substream->runtime, delay);
2476 }
2477
2478 if (substream->runtime) {
2479 if (hinfo->ops.get_delay)
2480 delay += hinfo->ops.get_delay(hinfo, apcm->codec,
2481 substream);
2482 substream->runtime->delay = delay;
2483 }
2484
2485 trace_azx_get_position(chip, azx_dev, pos, delay);
2486 return pos;
2487}
2488
2489static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream)
2490{
2491 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2492 struct azx *chip = apcm->chip;
2493 struct azx_dev *azx_dev = get_azx_dev(substream);
2494 return bytes_to_frames(substream->runtime,
2495 azx_get_position(chip, azx_dev, false));
2496}
2497
2498/* 431/*
2499 * Check whether the current DMA position is acceptable for updating 432 * Check whether the current DMA position is acceptable for updating
2500 * periods. Returns non-zero if it's OK. 433 * periods. Returns non-zero if it's OK.
@@ -2521,7 +454,7 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev)
2521 if (wallclk < (azx_dev->period_wallclk * 5) / 4 && 454 if (wallclk < (azx_dev->period_wallclk * 5) / 4 &&
2522 pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) 455 pos % azx_dev->period_bytes > azx_dev->period_bytes / 2)
2523 /* NG - it's below the first next period boundary */ 456 /* NG - it's below the first next period boundary */
2524 return bdl_pos_adj[chip->dev_index] ? 0 : -1; 457 return chip->bdl_pos_adj[chip->dev_index] ? 0 : -1;
2525 azx_dev->start_wallclk += wallclk; 458 azx_dev->start_wallclk += wallclk;
2526 return 1; /* OK, it's fine */ 459 return 1; /* OK, it's fine */
2527} 460}
@@ -2535,10 +468,9 @@ static void azx_irq_pending_work(struct work_struct *work)
2535 int i, pending, ok; 468 int i, pending, ok;
2536 469
2537 if (!chip->irq_pending_warned) { 470 if (!chip->irq_pending_warned) {
2538 printk(KERN_WARNING 471 dev_info(chip->card->dev,
2539 "hda-intel: IRQ timing workaround is activated " 472 "IRQ timing workaround is activated for card #%d. Suggest a bigger bdl_pos_adj.\n",
2540 "for card #%d. Suggest a bigger bdl_pos_adj.\n", 473 chip->card->number);
2541 chip->card->number);
2542 chip->irq_pending_warned = 1; 474 chip->irq_pending_warned = 1;
2543 } 475 }
2544 476
@@ -2580,139 +512,14 @@ static void azx_clear_irq_pending(struct azx *chip)
2580 spin_unlock_irq(&chip->reg_lock); 512 spin_unlock_irq(&chip->reg_lock);
2581} 513}
2582 514
2583#ifdef CONFIG_X86
2584static int azx_pcm_mmap(struct snd_pcm_substream *substream,
2585 struct vm_area_struct *area)
2586{
2587 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
2588 struct azx *chip = apcm->chip;
2589 if (!azx_snoop(chip))
2590 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
2591 return snd_pcm_lib_default_mmap(substream, area);
2592}
2593#else
2594#define azx_pcm_mmap NULL
2595#endif
2596
2597static struct snd_pcm_ops azx_pcm_ops = {
2598 .open = azx_pcm_open,
2599 .close = azx_pcm_close,
2600 .ioctl = snd_pcm_lib_ioctl,
2601 .hw_params = azx_pcm_hw_params,
2602 .hw_free = azx_pcm_hw_free,
2603 .prepare = azx_pcm_prepare,
2604 .trigger = azx_pcm_trigger,
2605 .pointer = azx_pcm_pointer,
2606 .wall_clock = azx_get_wallclock_tstamp,
2607 .mmap = azx_pcm_mmap,
2608 .page = snd_pcm_sgbuf_ops_page,
2609};
2610
2611static void azx_pcm_free(struct snd_pcm *pcm)
2612{
2613 struct azx_pcm *apcm = pcm->private_data;
2614 if (apcm) {
2615 list_del(&apcm->list);
2616 kfree(apcm);
2617 }
2618}
2619
2620#define MAX_PREALLOC_SIZE (32 * 1024 * 1024)
2621
2622static int
2623azx_attach_pcm_stream(struct hda_bus *bus, struct hda_codec *codec,
2624 struct hda_pcm *cpcm)
2625{
2626 struct azx *chip = bus->private_data;
2627 struct snd_pcm *pcm;
2628 struct azx_pcm *apcm;
2629 int pcm_dev = cpcm->device;
2630 unsigned int size;
2631 int s, err;
2632
2633 list_for_each_entry(apcm, &chip->pcm_list, list) {
2634 if (apcm->pcm->device == pcm_dev) {
2635 snd_printk(KERN_ERR SFX "%s: PCM %d already exists\n",
2636 pci_name(chip->pci), pcm_dev);
2637 return -EBUSY;
2638 }
2639 }
2640 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
2641 cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
2642 cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams,
2643 &pcm);
2644 if (err < 0)
2645 return err;
2646 strlcpy(pcm->name, cpcm->name, sizeof(pcm->name));
2647 apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
2648 if (apcm == NULL)
2649 return -ENOMEM;
2650 apcm->chip = chip;
2651 apcm->pcm = pcm;
2652 apcm->codec = codec;
2653 pcm->private_data = apcm;
2654 pcm->private_free = azx_pcm_free;
2655 if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
2656 pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
2657 list_add_tail(&apcm->list, &chip->pcm_list);
2658 cpcm->pcm = pcm;
2659 for (s = 0; s < 2; s++) {
2660 apcm->hinfo[s] = &cpcm->stream[s];
2661 if (cpcm->stream[s].substreams)
2662 snd_pcm_set_ops(pcm, s, &azx_pcm_ops);
2663 }
2664 /* buffer pre-allocation */
2665 size = CONFIG_SND_HDA_PREALLOC_SIZE * 1024;
2666 if (size > MAX_PREALLOC_SIZE)
2667 size = MAX_PREALLOC_SIZE;
2668 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
2669 snd_dma_pci_data(chip->pci),
2670 size, MAX_PREALLOC_SIZE);
2671 return 0;
2672}
2673
2674/*
2675 * mixer creation - all stuff is implemented in hda module
2676 */
2677static int azx_mixer_create(struct azx *chip)
2678{
2679 return snd_hda_build_controls(chip->bus);
2680}
2681
2682
2683/*
2684 * initialize SD streams
2685 */
2686static int azx_init_stream(struct azx *chip)
2687{
2688 int i;
2689
2690 /* initialize each stream (aka device)
2691 * assign the starting bdl address to each stream (device)
2692 * and initialize
2693 */
2694 for (i = 0; i < chip->num_streams; i++) {
2695 struct azx_dev *azx_dev = &chip->azx_dev[i];
2696 azx_dev->posbuf = (u32 __iomem *)(chip->posbuf.area + i * 8);
2697 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
2698 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80);
2699 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */
2700 azx_dev->sd_int_sta_mask = 1 << i;
2701 /* stream tag: must be non-zero and unique */
2702 azx_dev->index = i;
2703 azx_dev->stream_tag = i + 1;
2704 }
2705
2706 return 0;
2707}
2708
2709static int azx_acquire_irq(struct azx *chip, int do_disconnect) 515static int azx_acquire_irq(struct azx *chip, int do_disconnect)
2710{ 516{
2711 if (request_irq(chip->pci->irq, azx_interrupt, 517 if (request_irq(chip->pci->irq, azx_interrupt,
2712 chip->msi ? 0 : IRQF_SHARED, 518 chip->msi ? 0 : IRQF_SHARED,
2713 KBUILD_MODNAME, chip)) { 519 KBUILD_MODNAME, chip)) {
2714 printk(KERN_ERR "hda-intel: unable to grab IRQ %d, " 520 dev_err(chip->card->dev,
2715 "disabling device\n", chip->pci->irq); 521 "unable to grab IRQ %d, disabling device\n",
522 chip->pci->irq);
2716 if (do_disconnect) 523 if (do_disconnect)
2717 snd_card_disconnect(chip->card); 524 snd_card_disconnect(chip->card);
2718 return -1; 525 return -1;
@@ -2722,160 +529,7 @@ static int azx_acquire_irq(struct azx *chip, int do_disconnect)
2722 return 0; 529 return 0;
2723} 530}
2724 531
2725
2726static void azx_stop_chip(struct azx *chip)
2727{
2728 if (!chip->initialized)
2729 return;
2730
2731 /* disable interrupts */
2732 azx_int_disable(chip);
2733 azx_int_clear(chip);
2734
2735 /* disable CORB/RIRB */
2736 azx_free_cmd_io(chip);
2737
2738 /* disable position buffer */
2739 azx_writel(chip, DPLBASE, 0);
2740 azx_writel(chip, DPUBASE, 0);
2741
2742 chip->initialized = 0;
2743}
2744
2745#ifdef CONFIG_SND_HDA_DSP_LOADER
2746/*
2747 * DSP loading code (e.g. for CA0132)
2748 */
2749
2750/* use the first stream for loading DSP */
2751static struct azx_dev *
2752azx_get_dsp_loader_dev(struct azx *chip)
2753{
2754 return &chip->azx_dev[chip->playback_index_offset];
2755}
2756
2757static int azx_load_dsp_prepare(struct hda_bus *bus, unsigned int format,
2758 unsigned int byte_size,
2759 struct snd_dma_buffer *bufp)
2760{
2761 u32 *bdl;
2762 struct azx *chip = bus->private_data;
2763 struct azx_dev *azx_dev;
2764 int err;
2765
2766 azx_dev = azx_get_dsp_loader_dev(chip);
2767
2768 dsp_lock(azx_dev);
2769 spin_lock_irq(&chip->reg_lock);
2770 if (azx_dev->running || azx_dev->locked) {
2771 spin_unlock_irq(&chip->reg_lock);
2772 err = -EBUSY;
2773 goto unlock;
2774 }
2775 azx_dev->prepared = 0;
2776 chip->saved_azx_dev = *azx_dev;
2777 azx_dev->locked = 1;
2778 spin_unlock_irq(&chip->reg_lock);
2779
2780 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG,
2781 snd_dma_pci_data(chip->pci),
2782 byte_size, bufp);
2783 if (err < 0)
2784 goto err_alloc;
2785
2786 mark_pages_wc(chip, bufp, true);
2787 azx_dev->bufsize = byte_size;
2788 azx_dev->period_bytes = byte_size;
2789 azx_dev->format_val = format;
2790
2791 azx_stream_reset(chip, azx_dev);
2792
2793 /* reset BDL address */
2794 azx_sd_writel(azx_dev, SD_BDLPL, 0);
2795 azx_sd_writel(azx_dev, SD_BDLPU, 0);
2796
2797 azx_dev->frags = 0;
2798 bdl = (u32 *)azx_dev->bdl.area;
2799 err = setup_bdle(chip, bufp, azx_dev, &bdl, 0, byte_size, 0);
2800 if (err < 0)
2801 goto error;
2802
2803 azx_setup_controller(chip, azx_dev);
2804 dsp_unlock(azx_dev);
2805 return azx_dev->stream_tag;
2806
2807 error:
2808 mark_pages_wc(chip, bufp, false);
2809 snd_dma_free_pages(bufp);
2810 err_alloc:
2811 spin_lock_irq(&chip->reg_lock);
2812 if (azx_dev->opened)
2813 *azx_dev = chip->saved_azx_dev;
2814 azx_dev->locked = 0;
2815 spin_unlock_irq(&chip->reg_lock);
2816 unlock:
2817 dsp_unlock(azx_dev);
2818 return err;
2819}
2820
2821static void azx_load_dsp_trigger(struct hda_bus *bus, bool start)
2822{
2823 struct azx *chip = bus->private_data;
2824 struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
2825
2826 if (start)
2827 azx_stream_start(chip, azx_dev);
2828 else
2829 azx_stream_stop(chip, azx_dev);
2830 azx_dev->running = start;
2831}
2832
2833static void azx_load_dsp_cleanup(struct hda_bus *bus,
2834 struct snd_dma_buffer *dmab)
2835{
2836 struct azx *chip = bus->private_data;
2837 struct azx_dev *azx_dev = azx_get_dsp_loader_dev(chip);
2838
2839 if (!dmab->area || !azx_dev->locked)
2840 return;
2841
2842 dsp_lock(azx_dev);
2843 /* reset BDL address */
2844 azx_sd_writel(azx_dev, SD_BDLPL, 0);
2845 azx_sd_writel(azx_dev, SD_BDLPU, 0);
2846 azx_sd_writel(azx_dev, SD_CTL, 0);
2847 azx_dev->bufsize = 0;
2848 azx_dev->period_bytes = 0;
2849 azx_dev->format_val = 0;
2850
2851 mark_pages_wc(chip, dmab, false);
2852 snd_dma_free_pages(dmab);
2853 dmab->area = NULL;
2854
2855 spin_lock_irq(&chip->reg_lock);
2856 if (azx_dev->opened)
2857 *azx_dev = chip->saved_azx_dev;
2858 azx_dev->locked = 0;
2859 spin_unlock_irq(&chip->reg_lock);
2860 dsp_unlock(azx_dev);
2861}
2862#endif /* CONFIG_SND_HDA_DSP_LOADER */
2863
2864#ifdef CONFIG_PM 532#ifdef CONFIG_PM
2865/* power-up/down the controller */
2866static void azx_power_notify(struct hda_bus *bus, bool power_up)
2867{
2868 struct azx *chip = bus->private_data;
2869
2870 if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
2871 return;
2872
2873 if (power_up)
2874 pm_runtime_get_sync(&chip->pci->dev);
2875 else
2876 pm_runtime_put_sync(&chip->pci->dev);
2877}
2878
2879static DEFINE_MUTEX(card_list_lock); 533static DEFINE_MUTEX(card_list_lock);
2880static LIST_HEAD(card_list); 534static LIST_HEAD(card_list);
2881 535
@@ -2969,8 +623,8 @@ static int azx_resume(struct device *dev)
2969 pci_set_power_state(pci, PCI_D0); 623 pci_set_power_state(pci, PCI_D0);
2970 pci_restore_state(pci); 624 pci_restore_state(pci);
2971 if (pci_enable_device(pci) < 0) { 625 if (pci_enable_device(pci) < 0) {
2972 printk(KERN_ERR "hda-intel: pci_enable_device failed, " 626 dev_err(chip->card->dev,
2973 "disabling device\n"); 627 "pci_enable_device failed, disabling device\n");
2974 snd_card_disconnect(card); 628 snd_card_disconnect(card);
2975 return -EIO; 629 return -EIO;
2976 } 630 }
@@ -3127,36 +781,32 @@ static void azx_vs_set_state(struct pci_dev *pci,
3127 if (!chip->bus) { 781 if (!chip->bus) {
3128 chip->disabled = disabled; 782 chip->disabled = disabled;
3129 if (!disabled) { 783 if (!disabled) {
3130 snd_printk(KERN_INFO SFX 784 dev_info(chip->card->dev,
3131 "%s: Start delayed initialization\n", 785 "Start delayed initialization\n");
3132 pci_name(chip->pci));
3133 if (azx_probe_continue(chip) < 0) { 786 if (azx_probe_continue(chip) < 0) {
3134 snd_printk(KERN_ERR SFX 787 dev_err(chip->card->dev, "initialization error\n");
3135 "%s: initialization error\n",
3136 pci_name(chip->pci));
3137 chip->init_failed = true; 788 chip->init_failed = true;
3138 } 789 }
3139 } 790 }
3140 } else { 791 } else {
3141 snd_printk(KERN_INFO SFX 792 dev_info(chip->card->dev, "%s via VGA-switcheroo\n",
3142 "%s: %s via VGA-switcheroo\n", pci_name(chip->pci), 793 disabled ? "Disabling" : "Enabling");
3143 disabled ? "Disabling" : "Enabling");
3144 if (disabled) { 794 if (disabled) {
3145 pm_runtime_put_sync_suspend(&pci->dev); 795 pm_runtime_put_sync_suspend(card->dev);
3146 azx_suspend(&pci->dev); 796 azx_suspend(card->dev);
3147 /* when we get suspended by vga switcheroo we end up in D3cold, 797 /* when we get suspended by vga switcheroo we end up in D3cold,
3148 * however we have no ACPI handle, so pci/acpi can't put us there, 798 * however we have no ACPI handle, so pci/acpi can't put us there,
3149 * put ourselves there */ 799 * put ourselves there */
3150 pci->current_state = PCI_D3cold; 800 pci->current_state = PCI_D3cold;
3151 chip->disabled = true; 801 chip->disabled = true;
3152 if (snd_hda_lock_devices(chip->bus)) 802 if (snd_hda_lock_devices(chip->bus))
3153 snd_printk(KERN_WARNING SFX "%s: Cannot lock devices!\n", 803 dev_warn(chip->card->dev,
3154 pci_name(chip->pci)); 804 "Cannot lock devices!\n");
3155 } else { 805 } else {
3156 snd_hda_unlock_devices(chip->bus); 806 snd_hda_unlock_devices(chip->bus);
3157 pm_runtime_get_noresume(&pci->dev); 807 pm_runtime_get_noresume(card->dev);
3158 chip->disabled = false; 808 chip->disabled = false;
3159 azx_resume(&pci->dev); 809 azx_resume(card->dev);
3160 } 810 }
3161 } 811 }
3162} 812}
@@ -3181,9 +831,8 @@ static void init_vga_switcheroo(struct azx *chip)
3181{ 831{
3182 struct pci_dev *p = get_bound_vga(chip->pci); 832 struct pci_dev *p = get_bound_vga(chip->pci);
3183 if (p) { 833 if (p) {
3184 snd_printk(KERN_INFO SFX 834 dev_info(chip->card->dev,
3185 "%s: Handle VGA-switcheroo audio client\n", 835 "Handle VGA-switcheroo audio client\n");
3186 pci_name(chip->pci));
3187 chip->use_vga_switcheroo = 1; 836 chip->use_vga_switcheroo = 1;
3188 pci_dev_put(p); 837 pci_dev_put(p);
3189 } 838 }
@@ -3211,7 +860,8 @@ static int register_vga_switcheroo(struct azx *chip)
3211 chip->vga_switcheroo_registered = 1; 860 chip->vga_switcheroo_registered = 1;
3212 861
3213 /* register as an optimus hdmi audio power domain */ 862 /* register as an optimus hdmi audio power domain */
3214 vga_switcheroo_init_domain_pm_optimus_hdmi_audio(&chip->pci->dev, &chip->hdmi_pm_domain); 863 vga_switcheroo_init_domain_pm_optimus_hdmi_audio(chip->card->dev,
864 &chip->hdmi_pm_domain);
3215 return 0; 865 return 0;
3216} 866}
3217#else 867#else
@@ -3260,21 +910,7 @@ static int azx_free(struct azx *chip)
3260 if (chip->remap_addr) 910 if (chip->remap_addr)
3261 iounmap(chip->remap_addr); 911 iounmap(chip->remap_addr);
3262 912
3263 if (chip->azx_dev) { 913 azx_free_stream_pages(chip);
3264 for (i = 0; i < chip->num_streams; i++)
3265 if (chip->azx_dev[i].bdl.area) {
3266 mark_pages_wc(chip, &chip->azx_dev[i].bdl, false);
3267 snd_dma_free_pages(&chip->azx_dev[i].bdl);
3268 }
3269 }
3270 if (chip->rb.area) {
3271 mark_pages_wc(chip, &chip->rb, false);
3272 snd_dma_free_pages(&chip->rb);
3273 }
3274 if (chip->posbuf.area) {
3275 mark_pages_wc(chip, &chip->posbuf, false);
3276 snd_dma_free_pages(&chip->posbuf);
3277 }
3278 if (chip->region_requested) 914 if (chip->region_requested)
3279 pci_release_regions(chip->pci); 915 pci_release_regions(chip->pci);
3280 pci_disable_device(chip->pci); 916 pci_disable_device(chip->pci);
@@ -3374,20 +1010,19 @@ static int check_position_fix(struct azx *chip, int fix)
3374 1010
3375 q = snd_pci_quirk_lookup(chip->pci, position_fix_list); 1011 q = snd_pci_quirk_lookup(chip->pci, position_fix_list);
3376 if (q) { 1012 if (q) {
3377 printk(KERN_INFO 1013 dev_info(chip->card->dev,
3378 "hda_intel: position_fix set to %d " 1014 "position_fix set to %d for device %04x:%04x\n",
3379 "for device %04x:%04x\n", 1015 q->value, q->subvendor, q->subdevice);
3380 q->value, q->subvendor, q->subdevice);
3381 return q->value; 1016 return q->value;
3382 } 1017 }
3383 1018
3384 /* Check VIA/ATI HD Audio Controller exist */ 1019 /* Check VIA/ATI HD Audio Controller exist */
3385 if (chip->driver_caps & AZX_DCAPS_POSFIX_VIA) { 1020 if (chip->driver_caps & AZX_DCAPS_POSFIX_VIA) {
3386 snd_printd(SFX "%s: Using VIACOMBO position fix\n", pci_name(chip->pci)); 1021 dev_dbg(chip->card->dev, "Using VIACOMBO position fix\n");
3387 return POS_FIX_VIACOMBO; 1022 return POS_FIX_VIACOMBO;
3388 } 1023 }
3389 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) { 1024 if (chip->driver_caps & AZX_DCAPS_POSFIX_LPIB) {
3390 snd_printd(SFX "%s: Using LPIB position fix\n", pci_name(chip->pci)); 1025 dev_dbg(chip->card->dev, "Using LPIB position fix\n");
3391 return POS_FIX_LPIB; 1026 return POS_FIX_LPIB;
3392 } 1027 }
3393 return POS_FIX_AUTO; 1028 return POS_FIX_AUTO;
@@ -3425,10 +1060,9 @@ static void check_probe_mask(struct azx *chip, int dev)
3425 if (chip->codec_probe_mask == -1) { 1060 if (chip->codec_probe_mask == -1) {
3426 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); 1061 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
3427 if (q) { 1062 if (q) {
3428 printk(KERN_INFO 1063 dev_info(chip->card->dev,
3429 "hda_intel: probe_mask set to 0x%x " 1064 "probe_mask set to 0x%x for device %04x:%04x\n",
3430 "for device %04x:%04x\n", 1065 q->value, q->subvendor, q->subdevice);
3431 q->value, q->subvendor, q->subdevice);
3432 chip->codec_probe_mask = q->value; 1066 chip->codec_probe_mask = q->value;
3433 } 1067 }
3434 } 1068 }
@@ -3437,8 +1071,8 @@ static void check_probe_mask(struct azx *chip, int dev)
3437 if (chip->codec_probe_mask != -1 && 1071 if (chip->codec_probe_mask != -1 &&
3438 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) { 1072 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) {
3439 chip->codec_mask = chip->codec_probe_mask & 0xff; 1073 chip->codec_mask = chip->codec_probe_mask & 0xff;
3440 printk(KERN_INFO "hda_intel: codec_mask forced to 0x%x\n", 1074 dev_info(chip->card->dev, "codec_mask forced to 0x%x\n",
3441 chip->codec_mask); 1075 chip->codec_mask);
3442 } 1076 }
3443} 1077}
3444 1078
@@ -3470,16 +1104,16 @@ static void check_msi(struct azx *chip)
3470 chip->msi = 1; /* enable MSI as default */ 1104 chip->msi = 1; /* enable MSI as default */
3471 q = snd_pci_quirk_lookup(chip->pci, msi_black_list); 1105 q = snd_pci_quirk_lookup(chip->pci, msi_black_list);
3472 if (q) { 1106 if (q) {
3473 printk(KERN_INFO 1107 dev_info(chip->card->dev,
3474 "hda_intel: msi for device %04x:%04x set to %d\n", 1108 "msi for device %04x:%04x set to %d\n",
3475 q->subvendor, q->subdevice, q->value); 1109 q->subvendor, q->subdevice, q->value);
3476 chip->msi = q->value; 1110 chip->msi = q->value;
3477 return; 1111 return;
3478 } 1112 }
3479 1113
3480 /* NVidia chipsets seem to cause troubles with MSI */ 1114 /* NVidia chipsets seem to cause troubles with MSI */
3481 if (chip->driver_caps & AZX_DCAPS_NO_MSI) { 1115 if (chip->driver_caps & AZX_DCAPS_NO_MSI) {
3482 printk(KERN_INFO "hda_intel: Disabling MSI\n"); 1116 dev_info(chip->card->dev, "Disabling MSI\n");
3483 chip->msi = 0; 1117 chip->msi = 0;
3484 } 1118 }
3485} 1119}
@@ -3511,8 +1145,8 @@ static void azx_check_snoop_available(struct azx *chip)
3511 } 1145 }
3512 1146
3513 if (snoop != chip->snoop) { 1147 if (snoop != chip->snoop) {
3514 snd_printk(KERN_INFO SFX "%s: Force to %s mode\n", 1148 dev_info(chip->card->dev, "Force to %s mode\n",
3515 pci_name(chip->pci), snoop ? "snoop" : "non-snoop"); 1149 snoop ? "snoop" : "non-snoop");
3516 chip->snoop = snoop; 1150 chip->snoop = snoop;
3517 } 1151 }
3518} 1152}
@@ -3527,6 +1161,7 @@ static void azx_probe_work(struct work_struct *work)
3527 */ 1161 */
3528static int azx_create(struct snd_card *card, struct pci_dev *pci, 1162static int azx_create(struct snd_card *card, struct pci_dev *pci,
3529 int dev, unsigned int driver_caps, 1163 int dev, unsigned int driver_caps,
1164 const struct hda_controller_ops *hda_ops,
3530 struct azx **rchip) 1165 struct azx **rchip)
3531{ 1166{
3532 static struct snd_device_ops ops = { 1167 static struct snd_device_ops ops = {
@@ -3543,7 +1178,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
3543 1178
3544 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1179 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
3545 if (!chip) { 1180 if (!chip) {
3546 snd_printk(KERN_ERR SFX "%s: Cannot allocate chip\n", pci_name(pci)); 1181 dev_err(card->dev, "Cannot allocate chip\n");
3547 pci_disable_device(pci); 1182 pci_disable_device(pci);
3548 return -ENOMEM; 1183 return -ENOMEM;
3549 } 1184 }
@@ -3552,11 +1187,13 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
3552 mutex_init(&chip->open_mutex); 1187 mutex_init(&chip->open_mutex);
3553 chip->card = card; 1188 chip->card = card;
3554 chip->pci = pci; 1189 chip->pci = pci;
1190 chip->ops = hda_ops;
3555 chip->irq = -1; 1191 chip->irq = -1;
3556 chip->driver_caps = driver_caps; 1192 chip->driver_caps = driver_caps;
3557 chip->driver_type = driver_caps & 0xff; 1193 chip->driver_type = driver_caps & 0xff;
3558 check_msi(chip); 1194 check_msi(chip);
3559 chip->dev_index = dev; 1195 chip->dev_index = dev;
1196 chip->jackpoll_ms = jackpoll_ms;
3560 INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); 1197 INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work);
3561 INIT_LIST_HEAD(&chip->pcm_list); 1198 INIT_LIST_HEAD(&chip->pcm_list);
3562 INIT_LIST_HEAD(&chip->list); 1199 INIT_LIST_HEAD(&chip->list);
@@ -3588,11 +1225,11 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
3588 break; 1225 break;
3589 } 1226 }
3590 } 1227 }
1228 chip->bdl_pos_adj = bdl_pos_adj;
3591 1229
3592 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 1230 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
3593 if (err < 0) { 1231 if (err < 0) {
3594 snd_printk(KERN_ERR SFX "%s: Error creating device [card]!\n", 1232 dev_err(card->dev, "Error creating device [card]!\n");
3595 pci_name(chip->pci));
3596 azx_free(chip); 1233 azx_free(chip);
3597 return err; 1234 return err;
3598 } 1235 }
@@ -3610,7 +1247,7 @@ static int azx_first_init(struct azx *chip)
3610 int dev = chip->dev_index; 1247 int dev = chip->dev_index;
3611 struct pci_dev *pci = chip->pci; 1248 struct pci_dev *pci = chip->pci;
3612 struct snd_card *card = chip->card; 1249 struct snd_card *card = chip->card;
3613 int i, err; 1250 int err;
3614 unsigned short gcap; 1251 unsigned short gcap;
3615 1252
3616#if BITS_PER_LONG != 64 1253#if BITS_PER_LONG != 64
@@ -3631,7 +1268,7 @@ static int azx_first_init(struct azx *chip)
3631 chip->addr = pci_resource_start(pci, 0); 1268 chip->addr = pci_resource_start(pci, 0);
3632 chip->remap_addr = pci_ioremap_bar(pci, 0); 1269 chip->remap_addr = pci_ioremap_bar(pci, 0);
3633 if (chip->remap_addr == NULL) { 1270 if (chip->remap_addr == NULL) {
3634 snd_printk(KERN_ERR SFX "%s: ioremap error\n", pci_name(chip->pci)); 1271 dev_err(card->dev, "ioremap error\n");
3635 return -ENXIO; 1272 return -ENXIO;
3636 } 1273 }
3637 1274
@@ -3646,7 +1283,7 @@ static int azx_first_init(struct azx *chip)
3646 synchronize_irq(chip->irq); 1283 synchronize_irq(chip->irq);
3647 1284
3648 gcap = azx_readw(chip, GCAP); 1285 gcap = azx_readw(chip, GCAP);
3649 snd_printdd(SFX "%s: chipset global capabilities = 0x%x\n", pci_name(chip->pci), gcap); 1286 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap);
3650 1287
3651 /* disable SB600 64bit support for safety */ 1288 /* disable SB600 64bit support for safety */
3652 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) { 1289 if (chip->pci->vendor == PCI_VENDOR_ID_ATI) {
@@ -3663,7 +1300,7 @@ static int azx_first_init(struct azx *chip)
3663 1300
3664 /* disable 64bit DMA address on some devices */ 1301 /* disable 64bit DMA address on some devices */
3665 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) { 1302 if (chip->driver_caps & AZX_DCAPS_NO_64BIT) {
3666 snd_printd(SFX "%s: Disabling 64bit DMA\n", pci_name(chip->pci)); 1303 dev_dbg(card->dev, "Disabling 64bit DMA\n");
3667 gcap &= ~ICH6_GCAP_64OK; 1304 gcap &= ~ICH6_GCAP_64OK;
3668 } 1305 }
3669 1306
@@ -3718,33 +1355,11 @@ static int azx_first_init(struct azx *chip)
3718 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), 1355 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev),
3719 GFP_KERNEL); 1356 GFP_KERNEL);
3720 if (!chip->azx_dev) { 1357 if (!chip->azx_dev) {
3721 snd_printk(KERN_ERR SFX "%s: cannot malloc azx_dev\n", pci_name(chip->pci)); 1358 dev_err(card->dev, "cannot malloc azx_dev\n");
3722 return -ENOMEM; 1359 return -ENOMEM;
3723 } 1360 }
3724 1361
3725 for (i = 0; i < chip->num_streams; i++) { 1362 err = azx_alloc_stream_pages(chip);
3726 dsp_lock_init(&chip->azx_dev[i]);
3727 /* allocate memory for the BDL for each stream */
3728 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
3729 snd_dma_pci_data(chip->pci),
3730 BDL_SIZE, &chip->azx_dev[i].bdl);
3731 if (err < 0) {
3732 snd_printk(KERN_ERR SFX "%s: cannot allocate BDL\n", pci_name(chip->pci));
3733 return -ENOMEM;
3734 }
3735 mark_pages_wc(chip, &chip->azx_dev[i].bdl, true);
3736 }
3737 /* allocate memory for the position buffer */
3738 err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
3739 snd_dma_pci_data(chip->pci),
3740 chip->num_streams * 8, &chip->posbuf);
3741 if (err < 0) {
3742 snd_printk(KERN_ERR SFX "%s: cannot allocate posbuf\n", pci_name(chip->pci));
3743 return -ENOMEM;
3744 }
3745 mark_pages_wc(chip, &chip->posbuf, true);
3746 /* allocate CORB/RIRB */
3747 err = azx_alloc_cmd_io(chip);
3748 if (err < 0) 1363 if (err < 0)
3749 return err; 1364 return err;
3750 1365
@@ -3757,7 +1372,7 @@ static int azx_first_init(struct azx *chip)
3757 1372
3758 /* codec detection */ 1373 /* codec detection */
3759 if (!chip->codec_mask) { 1374 if (!chip->codec_mask) {
3760 snd_printk(KERN_ERR SFX "%s: no codecs found!\n", pci_name(chip->pci)); 1375 dev_err(card->dev, "no codecs found!\n");
3761 return -ENODEV; 1376 return -ENODEV;
3762 } 1377 }
3763 1378
@@ -3793,8 +1408,7 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
3793 struct pci_dev *pci = chip->pci; 1408 struct pci_dev *pci = chip->pci;
3794 1409
3795 if (!fw) { 1410 if (!fw) {
3796 snd_printk(KERN_ERR SFX "%s: Cannot load firmware, aborting\n", 1411 dev_err(card->dev, "Cannot load firmware, aborting\n");
3797 pci_name(chip->pci));
3798 goto error; 1412 goto error;
3799 } 1413 }
3800 1414
@@ -3812,6 +1426,132 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
3812} 1426}
3813#endif 1427#endif
3814 1428
1429/*
1430 * HDA controller ops.
1431 */
1432
1433/* PCI register access. */
1434static void pci_azx_writel(u32 value, u32 __iomem *addr)
1435{
1436 writel(value, addr);
1437}
1438
1439static u32 pci_azx_readl(u32 __iomem *addr)
1440{
1441 return readl(addr);
1442}
1443
1444static void pci_azx_writew(u16 value, u16 __iomem *addr)
1445{
1446 writew(value, addr);
1447}
1448
1449static u16 pci_azx_readw(u16 __iomem *addr)
1450{
1451 return readw(addr);
1452}
1453
1454static void pci_azx_writeb(u8 value, u8 __iomem *addr)
1455{
1456 writeb(value, addr);
1457}
1458
1459static u8 pci_azx_readb(u8 __iomem *addr)
1460{
1461 return readb(addr);
1462}
1463
1464static int disable_msi_reset_irq(struct azx *chip)
1465{
1466 int err;
1467
1468 free_irq(chip->irq, chip);
1469 chip->irq = -1;
1470 pci_disable_msi(chip->pci);
1471 chip->msi = 0;
1472 err = azx_acquire_irq(chip, 1);
1473 if (err < 0)
1474 return err;
1475
1476 return 0;
1477}
1478
1479/* DMA page allocation helpers. */
1480static int dma_alloc_pages(struct azx *chip,
1481 int type,
1482 size_t size,
1483 struct snd_dma_buffer *buf)
1484{
1485 int err;
1486
1487 err = snd_dma_alloc_pages(type,
1488 chip->card->dev,
1489 size, buf);
1490 if (err < 0)
1491 return err;
1492 mark_pages_wc(chip, buf, true);
1493 return 0;
1494}
1495
1496static void dma_free_pages(struct azx *chip, struct snd_dma_buffer *buf)
1497{
1498 mark_pages_wc(chip, buf, false);
1499 snd_dma_free_pages(buf);
1500}
1501
1502static int substream_alloc_pages(struct azx *chip,
1503 struct snd_pcm_substream *substream,
1504 size_t size)
1505{
1506 struct azx_dev *azx_dev = get_azx_dev(substream);
1507 int ret;
1508
1509 mark_runtime_wc(chip, azx_dev, substream, false);
1510 azx_dev->bufsize = 0;
1511 azx_dev->period_bytes = 0;
1512 azx_dev->format_val = 0;
1513 ret = snd_pcm_lib_malloc_pages(substream, size);
1514 if (ret < 0)
1515 return ret;
1516 mark_runtime_wc(chip, azx_dev, substream, true);
1517 return 0;
1518}
1519
1520static int substream_free_pages(struct azx *chip,
1521 struct snd_pcm_substream *substream)
1522{
1523 struct azx_dev *azx_dev = get_azx_dev(substream);
1524 mark_runtime_wc(chip, azx_dev, substream, false);
1525 return snd_pcm_lib_free_pages(substream);
1526}
1527
1528static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
1529 struct vm_area_struct *area)
1530{
1531#ifdef CONFIG_X86
1532 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1533 struct azx *chip = apcm->chip;
1534 if (!azx_snoop(chip))
1535 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
1536#endif
1537}
1538
1539static const struct hda_controller_ops pci_hda_ops = {
1540 .reg_writel = pci_azx_writel,
1541 .reg_readl = pci_azx_readl,
1542 .reg_writew = pci_azx_writew,
1543 .reg_readw = pci_azx_readw,
1544 .reg_writeb = pci_azx_writeb,
1545 .reg_readb = pci_azx_readb,
1546 .disable_msi_reset_irq = disable_msi_reset_irq,
1547 .dma_alloc_pages = dma_alloc_pages,
1548 .dma_free_pages = dma_free_pages,
1549 .substream_alloc_pages = substream_alloc_pages,
1550 .substream_free_pages = substream_free_pages,
1551 .pcm_mmap_prepare = pcm_mmap_prepare,
1552 .position_check = azx_position_check,
1553};
1554
3815static int azx_probe(struct pci_dev *pci, 1555static int azx_probe(struct pci_dev *pci,
3816 const struct pci_device_id *pci_id) 1556 const struct pci_device_id *pci_id)
3817{ 1557{
@@ -3828,15 +1568,15 @@ static int azx_probe(struct pci_dev *pci,
3828 return -ENOENT; 1568 return -ENOENT;
3829 } 1569 }
3830 1570
3831 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1571 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1572 0, &card);
3832 if (err < 0) { 1573 if (err < 0) {
3833 snd_printk(KERN_ERR "hda-intel: Error creating card!\n"); 1574 dev_err(&pci->dev, "Error creating card!\n");
3834 return err; 1575 return err;
3835 } 1576 }
3836 1577
3837 snd_card_set_dev(card, &pci->dev); 1578 err = azx_create(card, pci, dev, pci_id->driver_data,
3838 1579 &pci_hda_ops, &chip);
3839 err = azx_create(card, pci, dev, pci_id->driver_data, &chip);
3840 if (err < 0) 1580 if (err < 0)
3841 goto out_free; 1581 goto out_free;
3842 card->private_data = chip; 1582 card->private_data = chip;
@@ -3845,15 +1585,13 @@ static int azx_probe(struct pci_dev *pci,
3845 1585
3846 err = register_vga_switcheroo(chip); 1586 err = register_vga_switcheroo(chip);
3847 if (err < 0) { 1587 if (err < 0) {
3848 snd_printk(KERN_ERR SFX 1588 dev_err(card->dev, "Error registering VGA-switcheroo client\n");
3849 "%s: Error registering VGA-switcheroo client\n", pci_name(pci));
3850 goto out_free; 1589 goto out_free;
3851 } 1590 }
3852 1591
3853 if (check_hdmi_disabled(pci)) { 1592 if (check_hdmi_disabled(pci)) {
3854 snd_printk(KERN_INFO SFX "%s: VGA controller is disabled\n", 1593 dev_info(card->dev, "VGA controller is disabled\n");
3855 pci_name(pci)); 1594 dev_info(card->dev, "Delaying initialization\n");
3856 snd_printk(KERN_INFO SFX "%s: Delaying initialization\n", pci_name(pci));
3857 chip->disabled = true; 1595 chip->disabled = true;
3858 } 1596 }
3859 1597
@@ -3861,8 +1599,8 @@ static int azx_probe(struct pci_dev *pci,
3861 1599
3862#ifdef CONFIG_SND_HDA_PATCH_LOADER 1600#ifdef CONFIG_SND_HDA_PATCH_LOADER
3863 if (patch[dev] && *patch[dev]) { 1601 if (patch[dev] && *patch[dev]) {
3864 snd_printk(KERN_ERR SFX "%s: Applying patch firmware '%s'\n", 1602 dev_info(card->dev, "Applying patch firmware '%s'\n",
3865 pci_name(pci), patch[dev]); 1603 patch[dev]);
3866 err = request_firmware_nowait(THIS_MODULE, true, patch[dev], 1604 err = request_firmware_nowait(THIS_MODULE, true, patch[dev],
3867 &pci->dev, GFP_KERNEL, card, 1605 &pci->dev, GFP_KERNEL, card,
3868 azx_firmware_cb); 1606 azx_firmware_cb);
@@ -3874,7 +1612,7 @@ static int azx_probe(struct pci_dev *pci,
3874 1612
3875#ifndef CONFIG_SND_HDA_I915 1613#ifndef CONFIG_SND_HDA_I915
3876 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) 1614 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
3877 snd_printk(KERN_ERR SFX "Haswell must build in CONFIG_SND_HDA_I915\n"); 1615 dev_err(card->dev, "Haswell must build in CONFIG_SND_HDA_I915\n");
3878#endif 1616#endif
3879 1617
3880 if (schedule_probe) 1618 if (schedule_probe)
@@ -3890,6 +1628,12 @@ out_free:
3890 return err; 1628 return err;
3891} 1629}
3892 1630
1631/* number of codec slots for each chipset: 0 = default slots (i.e. 4) */
1632static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = {
1633 [AZX_DRIVER_NVIDIA] = 8,
1634 [AZX_DRIVER_TERA] = 1,
1635};
1636
3893static int azx_probe_continue(struct azx *chip) 1637static int azx_probe_continue(struct azx *chip)
3894{ 1638{
3895 struct pci_dev *pci = chip->pci; 1639 struct pci_dev *pci = chip->pci;
@@ -3901,7 +1645,8 @@ static int azx_probe_continue(struct azx *chip)
3901#ifdef CONFIG_SND_HDA_I915 1645#ifdef CONFIG_SND_HDA_I915
3902 err = hda_i915_init(); 1646 err = hda_i915_init();
3903 if (err < 0) { 1647 if (err < 0) {
3904 snd_printk(KERN_ERR SFX "Error request power-well from i915\n"); 1648 dev_err(chip->card->dev,
1649 "Error request power-well from i915\n");
3905 goto out_free; 1650 goto out_free;
3906 } 1651 }
3907#endif 1652#endif
@@ -3917,7 +1662,10 @@ static int azx_probe_continue(struct azx *chip)
3917#endif 1662#endif
3918 1663
3919 /* create codec instances */ 1664 /* create codec instances */
3920 err = azx_codec_create(chip, model[dev]); 1665 err = azx_codec_create(chip, model[dev],
1666 azx_max_codecs[chip->driver_type],
1667 power_save_addr);
1668
3921 if (err < 0) 1669 if (err < 0)
3922 goto out_free; 1670 goto out_free;
3923#ifdef CONFIG_SND_HDA_PATCH_LOADER 1671#ifdef CONFIG_SND_HDA_PATCH_LOADER
@@ -4142,7 +1890,7 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
4142 .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA }, 1890 .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA },
4143 { PCI_DEVICE(0x1102, 0x0012), 1891 { PCI_DEVICE(0x1102, 0x0012),
4144 .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA }, 1892 .driver_data = AZX_DRIVER_CTHDA | AZX_DCAPS_PRESET_CTHDA },
4145#if !defined(CONFIG_SND_CTXFI) && !defined(CONFIG_SND_CTXFI_MODULE) 1893#if !IS_ENABLED(CONFIG_SND_CTXFI)
4146 /* the following entry conflicts with snd-ctxfi driver, 1894 /* the following entry conflicts with snd-ctxfi driver,
4147 * as ctxfi driver mutates from HD-audio to native mode with 1895 * as ctxfi driver mutates from HD-audio to native mode with
4148 * a special command sequence. 1896 * a special command sequence.
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index da80c5bd7fd4..e51d15529215 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -597,23 +597,10 @@ int snd_hda_create_hwdep(struct hda_codec *codec);
597static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; } 597static inline int snd_hda_create_hwdep(struct hda_codec *codec) { return 0; }
598#endif 598#endif
599 599
600#if defined(CONFIG_PM) && defined(CONFIG_SND_HDA_HWDEP) 600void snd_hda_sysfs_init(struct hda_codec *codec);
601int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec); 601void snd_hda_sysfs_clear(struct hda_codec *codec);
602#else
603static inline int snd_hda_hwdep_add_power_sysfs(struct hda_codec *codec)
604{
605 return 0;
606}
607#endif
608 602
609#ifdef CONFIG_SND_HDA_RECONFIG 603extern const struct attribute_group *snd_hda_dev_attr_groups[];
610int snd_hda_hwdep_add_sysfs(struct hda_codec *codec);
611#else
612static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
613{
614 return 0;
615}
616#endif
617 604
618#ifdef CONFIG_SND_HDA_RECONFIG 605#ifdef CONFIG_SND_HDA_RECONFIG
619const char *snd_hda_get_hint(struct hda_codec *codec, const char *key); 606const char *snd_hda_get_hint(struct hda_codec *codec, const char *key);
@@ -771,4 +758,11 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld,
771#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80 758#define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
772void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen); 759void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
773 760
761/*
762 */
763#define codec_err(codec, fmt, args...) dev_err(&(codec)->dev, fmt, ##args)
764#define codec_warn(codec, fmt, args...) dev_warn(&(codec)->dev, fmt, ##args)
765#define codec_info(codec, fmt, args...) dev_info(&(codec)->dev, fmt, ##args)
766#define codec_dbg(codec, fmt, args...) dev_dbg(&(codec)->dev, fmt, ##args)
767
774#endif /* __SOUND_HDA_LOCAL_H */ 768#endif /* __SOUND_HDA_LOCAL_H */
diff --git a/sound/pci/hda/hda_priv.h b/sound/pci/hda/hda_priv.h
new file mode 100644
index 000000000000..ba38b819f984
--- /dev/null
+++ b/sound/pci/hda/hda_priv.h
@@ -0,0 +1,463 @@
1/*
2 * Common defines for the alsa driver code base for HD Audio.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */
14
15#ifndef __SOUND_HDA_PRIV_H
16#define __SOUND_HDA_PRIV_H
17
18#include <linux/clocksource.h>
19#include <sound/core.h>
20#include <sound/pcm.h>
21
22/*
23 * registers
24 */
25#define ICH6_REG_GCAP 0x00
26#define ICH6_GCAP_64OK (1 << 0) /* 64bit address support */
27#define ICH6_GCAP_NSDO (3 << 1) /* # of serial data out signals */
28#define ICH6_GCAP_BSS (31 << 3) /* # of bidirectional streams */
29#define ICH6_GCAP_ISS (15 << 8) /* # of input streams */
30#define ICH6_GCAP_OSS (15 << 12) /* # of output streams */
31#define ICH6_REG_VMIN 0x02
32#define ICH6_REG_VMAJ 0x03
33#define ICH6_REG_OUTPAY 0x04
34#define ICH6_REG_INPAY 0x06
35#define ICH6_REG_GCTL 0x08
36#define ICH6_GCTL_RESET (1 << 0) /* controller reset */
37#define ICH6_GCTL_FCNTRL (1 << 1) /* flush control */
38#define ICH6_GCTL_UNSOL (1 << 8) /* accept unsol. response enable */
39#define ICH6_REG_WAKEEN 0x0c
40#define ICH6_REG_STATESTS 0x0e
41#define ICH6_REG_GSTS 0x10
42#define ICH6_GSTS_FSTS (1 << 1) /* flush status */
43#define ICH6_REG_INTCTL 0x20
44#define ICH6_REG_INTSTS 0x24
45#define ICH6_REG_WALLCLK 0x30 /* 24Mhz source */
46#define ICH6_REG_OLD_SSYNC 0x34 /* SSYNC for old ICH */
47#define ICH6_REG_SSYNC 0x38
48#define ICH6_REG_CORBLBASE 0x40
49#define ICH6_REG_CORBUBASE 0x44
50#define ICH6_REG_CORBWP 0x48
51#define ICH6_REG_CORBRP 0x4a
52#define ICH6_CORBRP_RST (1 << 15) /* read pointer reset */
53#define ICH6_REG_CORBCTL 0x4c
54#define ICH6_CORBCTL_RUN (1 << 1) /* enable DMA */
55#define ICH6_CORBCTL_CMEIE (1 << 0) /* enable memory error irq */
56#define ICH6_REG_CORBSTS 0x4d
57#define ICH6_CORBSTS_CMEI (1 << 0) /* memory error indication */
58#define ICH6_REG_CORBSIZE 0x4e
59
60#define ICH6_REG_RIRBLBASE 0x50
61#define ICH6_REG_RIRBUBASE 0x54
62#define ICH6_REG_RIRBWP 0x58
63#define ICH6_RIRBWP_RST (1 << 15) /* write pointer reset */
64#define ICH6_REG_RINTCNT 0x5a
65#define ICH6_REG_RIRBCTL 0x5c
66#define ICH6_RBCTL_IRQ_EN (1 << 0) /* enable IRQ */
67#define ICH6_RBCTL_DMA_EN (1 << 1) /* enable DMA */
68#define ICH6_RBCTL_OVERRUN_EN (1 << 2) /* enable overrun irq */
69#define ICH6_REG_RIRBSTS 0x5d
70#define ICH6_RBSTS_IRQ (1 << 0) /* response irq */
71#define ICH6_RBSTS_OVERRUN (1 << 2) /* overrun irq */
72#define ICH6_REG_RIRBSIZE 0x5e
73
74#define ICH6_REG_IC 0x60
75#define ICH6_REG_IR 0x64
76#define ICH6_REG_IRS 0x68
77#define ICH6_IRS_VALID (1<<1)
78#define ICH6_IRS_BUSY (1<<0)
79
80#define ICH6_REG_DPLBASE 0x70
81#define ICH6_REG_DPUBASE 0x74
82#define ICH6_DPLBASE_ENABLE 0x1 /* Enable position buffer */
83
84/* SD offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */
85enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
86
87/* stream register offsets from stream base */
88#define ICH6_REG_SD_CTL 0x00
89#define ICH6_REG_SD_STS 0x03
90#define ICH6_REG_SD_LPIB 0x04
91#define ICH6_REG_SD_CBL 0x08
92#define ICH6_REG_SD_LVI 0x0c
93#define ICH6_REG_SD_FIFOW 0x0e
94#define ICH6_REG_SD_FIFOSIZE 0x10
95#define ICH6_REG_SD_FORMAT 0x12
96#define ICH6_REG_SD_BDLPL 0x18
97#define ICH6_REG_SD_BDLPU 0x1c
98
99/* PCI space */
100#define ICH6_PCIREG_TCSEL 0x44
101
102/*
103 * other constants
104 */
105
106/* max number of SDs */
107/* ICH, ATI and VIA have 4 playback and 4 capture */
108#define ICH6_NUM_CAPTURE 4
109#define ICH6_NUM_PLAYBACK 4
110
111/* ULI has 6 playback and 5 capture */
112#define ULI_NUM_CAPTURE 5
113#define ULI_NUM_PLAYBACK 6
114
115/* ATI HDMI may have up to 8 playbacks and 0 capture */
116#define ATIHDMI_NUM_CAPTURE 0
117#define ATIHDMI_NUM_PLAYBACK 8
118
119/* TERA has 4 playback and 3 capture */
120#define TERA_NUM_CAPTURE 3
121#define TERA_NUM_PLAYBACK 4
122
123/* this number is statically defined for simplicity */
124#define MAX_AZX_DEV 16
125
126/* max number of fragments - we may use more if allocating more pages for BDL */
127#define BDL_SIZE 4096
128#define AZX_MAX_BDL_ENTRIES (BDL_SIZE / 16)
129#define AZX_MAX_FRAG 32
130/* max buffer size - no h/w limit, you can increase as you like */
131#define AZX_MAX_BUF_SIZE (1024*1024*1024)
132
133/* RIRB int mask: overrun[2], response[0] */
134#define RIRB_INT_RESPONSE 0x01
135#define RIRB_INT_OVERRUN 0x04
136#define RIRB_INT_MASK 0x05
137
138/* STATESTS int mask: S3,SD2,SD1,SD0 */
139#define AZX_MAX_CODECS 8
140#define AZX_DEFAULT_CODECS 4
141#define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1)
142
143/* SD_CTL bits */
144#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
145#define SD_CTL_DMA_START 0x02 /* stream DMA start bit */
146#define SD_CTL_STRIPE (3 << 16) /* stripe control */
147#define SD_CTL_TRAFFIC_PRIO (1 << 18) /* traffic priority */
148#define SD_CTL_DIR (1 << 19) /* bi-directional stream */
149#define SD_CTL_STREAM_TAG_MASK (0xf << 20)
150#define SD_CTL_STREAM_TAG_SHIFT 20
151
152/* SD_CTL and SD_STS */
153#define SD_INT_DESC_ERR 0x10 /* descriptor error interrupt */
154#define SD_INT_FIFO_ERR 0x08 /* FIFO error interrupt */
155#define SD_INT_COMPLETE 0x04 /* completion interrupt */
156#define SD_INT_MASK (SD_INT_DESC_ERR|SD_INT_FIFO_ERR|\
157 SD_INT_COMPLETE)
158
159/* SD_STS */
160#define SD_STS_FIFO_READY 0x20 /* FIFO ready */
161
162/* INTCTL and INTSTS */
163#define ICH6_INT_ALL_STREAM 0xff /* all stream interrupts */
164#define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */
165#define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */
166
167/* below are so far hardcoded - should read registers in future */
168#define ICH6_MAX_CORB_ENTRIES 256
169#define ICH6_MAX_RIRB_ENTRIES 256
170
171/* driver quirks (capabilities) */
172/* bits 0-7 are used for indicating driver type */
173#define AZX_DCAPS_NO_TCSEL (1 << 8) /* No Intel TCSEL bit */
174#define AZX_DCAPS_NO_MSI (1 << 9) /* No MSI support */
175#define AZX_DCAPS_ATI_SNOOP (1 << 10) /* ATI snoop enable */
176#define AZX_DCAPS_NVIDIA_SNOOP (1 << 11) /* Nvidia snoop enable */
177#define AZX_DCAPS_SCH_SNOOP (1 << 12) /* SCH/PCH snoop enable */
178#define AZX_DCAPS_RIRB_DELAY (1 << 13) /* Long delay in read loop */
179#define AZX_DCAPS_RIRB_PRE_DELAY (1 << 14) /* Put a delay before read */
180#define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */
181#define AZX_DCAPS_POSFIX_LPIB (1 << 16) /* Use LPIB as default */
182#define AZX_DCAPS_POSFIX_VIA (1 << 17) /* Use VIACOMBO as default */
183#define AZX_DCAPS_NO_64BIT (1 << 18) /* No 64bit address */
184#define AZX_DCAPS_SYNC_WRITE (1 << 19) /* sync each cmd write */
185#define AZX_DCAPS_OLD_SSYNC (1 << 20) /* Old SSYNC reg for ICH */
186#define AZX_DCAPS_BUFSIZE (1 << 21) /* no buffer size alignment */
187#define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */
188#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */
189#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */
190#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */
191#define AZX_DCAPS_I915_POWERWELL (1 << 27) /* HSW i915 powerwell support */
192
193/* position fix mode */
194enum {
195 POS_FIX_AUTO,
196 POS_FIX_LPIB,
197 POS_FIX_POSBUF,
198 POS_FIX_VIACOMBO,
199 POS_FIX_COMBO,
200};
201
202/* Defines for ATI HD Audio support in SB450 south bridge */
203#define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42
204#define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02
205
206/* Defines for Nvidia HDA support */
207#define NVIDIA_HDA_TRANSREG_ADDR 0x4e
208#define NVIDIA_HDA_ENABLE_COHBITS 0x0f
209#define NVIDIA_HDA_ISTRM_COH 0x4d
210#define NVIDIA_HDA_OSTRM_COH 0x4c
211#define NVIDIA_HDA_ENABLE_COHBIT 0x01
212
213/* Defines for Intel SCH HDA snoop control */
214#define INTEL_SCH_HDA_DEVC 0x78
215#define INTEL_SCH_HDA_DEVC_NOSNOOP (0x1<<11)
216
217/* Define IN stream 0 FIFO size offset in VIA controller */
218#define VIA_IN_STREAM0_FIFO_SIZE_OFFSET 0x90
219/* Define VIA HD Audio Device ID*/
220#define VIA_HDAC_DEVICE_ID 0x3288
221
222/* HD Audio class code */
223#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
224
225struct azx_dev {
226 struct snd_dma_buffer bdl; /* BDL buffer */
227 u32 *posbuf; /* position buffer pointer */
228
229 unsigned int bufsize; /* size of the play buffer in bytes */
230 unsigned int period_bytes; /* size of the period in bytes */
231 unsigned int frags; /* number for period in the play buffer */
232 unsigned int fifo_size; /* FIFO size */
233 unsigned long start_wallclk; /* start + minimum wallclk */
234 unsigned long period_wallclk; /* wallclk for period */
235
236 void __iomem *sd_addr; /* stream descriptor pointer */
237
238 u32 sd_int_sta_mask; /* stream int status mask */
239
240 /* pcm support */
241 struct snd_pcm_substream *substream; /* assigned substream,
242 * set in PCM open
243 */
244 unsigned int format_val; /* format value to be set in the
245 * controller and the codec
246 */
247 unsigned char stream_tag; /* assigned stream */
248 unsigned char index; /* stream index */
249 int assigned_key; /* last device# key assigned to */
250
251 unsigned int opened:1;
252 unsigned int running:1;
253 unsigned int irq_pending:1;
254 unsigned int prepared:1;
255 unsigned int locked:1;
256 /*
257 * For VIA:
258 * A flag to ensure DMA position is 0
259 * when link position is not greater than FIFO size
260 */
261 unsigned int insufficient:1;
262 unsigned int wc_marked:1;
263 unsigned int no_period_wakeup:1;
264
265 struct timecounter azx_tc;
266 struct cyclecounter azx_cc;
267
268 int delay_negative_threshold;
269
270#ifdef CONFIG_SND_HDA_DSP_LOADER
271 /* Allows dsp load to have sole access to the playback stream. */
272 struct mutex dsp_mutex;
273#endif
274};
275
276/* CORB/RIRB */
277struct azx_rb {
278 u32 *buf; /* CORB/RIRB buffer
279 * Each CORB entry is 4byte, RIRB is 8byte
280 */
281 dma_addr_t addr; /* physical address of CORB/RIRB buffer */
282 /* for RIRB */
283 unsigned short rp, wp; /* read/write pointers */
284 int cmds[AZX_MAX_CODECS]; /* number of pending requests */
285 u32 res[AZX_MAX_CODECS]; /* last read value */
286};
287
288struct azx;
289
290/* Functions to read/write to hda registers. */
291struct hda_controller_ops {
292 /* Register Access */
293 void (*reg_writel)(u32 value, u32 __iomem *addr);
294 u32 (*reg_readl)(u32 __iomem *addr);
295 void (*reg_writew)(u16 value, u16 __iomem *addr);
296 u16 (*reg_readw)(u16 __iomem *addr);
297 void (*reg_writeb)(u8 value, u8 __iomem *addr);
298 u8 (*reg_readb)(u8 __iomem *addr);
299 /* Disable msi if supported, PCI only */
300 int (*disable_msi_reset_irq)(struct azx *);
301 /* Allocation ops */
302 int (*dma_alloc_pages)(struct azx *chip,
303 int type,
304 size_t size,
305 struct snd_dma_buffer *buf);
306 void (*dma_free_pages)(struct azx *chip, struct snd_dma_buffer *buf);
307 int (*substream_alloc_pages)(struct azx *chip,
308 struct snd_pcm_substream *substream,
309 size_t size);
310 int (*substream_free_pages)(struct azx *chip,
311 struct snd_pcm_substream *substream);
312 void (*pcm_mmap_prepare)(struct snd_pcm_substream *substream,
313 struct vm_area_struct *area);
314 /* Check if current position is acceptable */
315 int (*position_check)(struct azx *chip, struct azx_dev *azx_dev);
316};
317
318struct azx_pcm {
319 struct azx *chip;
320 struct snd_pcm *pcm;
321 struct hda_codec *codec;
322 struct hda_pcm_stream *hinfo[2];
323 struct list_head list;
324};
325
326struct azx {
327 struct snd_card *card;
328 struct pci_dev *pci;
329 int dev_index;
330
331 /* chip type specific */
332 int driver_type;
333 unsigned int driver_caps;
334 int playback_streams;
335 int playback_index_offset;
336 int capture_streams;
337 int capture_index_offset;
338 int num_streams;
339 const int *jackpoll_ms; /* per-card jack poll interval */
340
341 /* Register interaction. */
342 const struct hda_controller_ops *ops;
343
344 /* pci resources */
345 unsigned long addr;
346 void __iomem *remap_addr;
347 int irq;
348
349 /* locks */
350 spinlock_t reg_lock;
351 struct mutex open_mutex; /* Prevents concurrent open/close operations */
352 struct completion probe_wait;
353
354 /* streams (x num_streams) */
355 struct azx_dev *azx_dev;
356
357 /* PCM */
358 struct list_head pcm_list; /* azx_pcm list */
359
360 /* HD codec */
361 unsigned short codec_mask;
362 int codec_probe_mask; /* copied from probe_mask option */
363 struct hda_bus *bus;
364 unsigned int beep_mode;
365
366 /* CORB/RIRB */
367 struct azx_rb corb;
368 struct azx_rb rirb;
369
370 /* CORB/RIRB and position buffers */
371 struct snd_dma_buffer rb;
372 struct snd_dma_buffer posbuf;
373
374#ifdef CONFIG_SND_HDA_PATCH_LOADER
375 const struct firmware *fw;
376#endif
377
378 /* flags */
379 int position_fix[2]; /* for both playback/capture streams */
380 const int *bdl_pos_adj;
381 int poll_count;
382 unsigned int running:1;
383 unsigned int initialized:1;
384 unsigned int single_cmd:1;
385 unsigned int polling_mode:1;
386 unsigned int msi:1;
387 unsigned int irq_pending_warned:1;
388 unsigned int probing:1; /* codec probing phase */
389 unsigned int snoop:1;
390 unsigned int align_buffer_size:1;
391 unsigned int region_requested:1;
392
393 /* VGA-switcheroo setup */
394 unsigned int use_vga_switcheroo:1;
395 unsigned int vga_switcheroo_registered:1;
396 unsigned int init_failed:1; /* delayed init failed */
397 unsigned int disabled:1; /* disabled by VGA-switcher */
398
399 /* for debugging */
400 unsigned int last_cmd[AZX_MAX_CODECS];
401
402 /* for pending irqs */
403 struct work_struct irq_pending_work;
404
405 struct work_struct probe_work;
406
407 /* reboot notifier (for mysterious hangup problem at power-down) */
408 struct notifier_block reboot_notifier;
409
410 /* card list (for power_save trigger) */
411 struct list_head list;
412
413#ifdef CONFIG_SND_HDA_DSP_LOADER
414 struct azx_dev saved_azx_dev;
415#endif
416
417 /* secondary power domain for hdmi audio under vga device */
418 struct dev_pm_domain hdmi_pm_domain;
419};
420
421#ifdef CONFIG_SND_VERBOSE_PRINTK
422#define SFX /* nop */
423#else
424#define SFX "hda-intel "
425#endif
426
427#ifdef CONFIG_X86
428#define azx_snoop(chip) ((chip)->snoop)
429#else
430#define azx_snoop(chip) true
431#endif
432
433/*
434 * macros for easy use
435 */
436
437#define azx_writel(chip, reg, value) \
438 ((chip)->ops->reg_writel(value, (chip)->remap_addr + ICH6_REG_##reg))
439#define azx_readl(chip, reg) \
440 ((chip)->ops->reg_readl((chip)->remap_addr + ICH6_REG_##reg))
441#define azx_writew(chip, reg, value) \
442 ((chip)->ops->reg_writew(value, (chip)->remap_addr + ICH6_REG_##reg))
443#define azx_readw(chip, reg) \
444 ((chip)->ops->reg_readw((chip)->remap_addr + ICH6_REG_##reg))
445#define azx_writeb(chip, reg, value) \
446 ((chip)->ops->reg_writeb(value, (chip)->remap_addr + ICH6_REG_##reg))
447#define azx_readb(chip, reg) \
448 ((chip)->ops->reg_readb((chip)->remap_addr + ICH6_REG_##reg))
449
450#define azx_sd_writel(chip, dev, reg, value) \
451 ((chip)->ops->reg_writel(value, (dev)->sd_addr + ICH6_REG_##reg))
452#define azx_sd_readl(chip, dev, reg) \
453 ((chip)->ops->reg_readl((dev)->sd_addr + ICH6_REG_##reg))
454#define azx_sd_writew(chip, dev, reg, value) \
455 ((chip)->ops->reg_writew(value, (dev)->sd_addr + ICH6_REG_##reg))
456#define azx_sd_readw(chip, dev, reg) \
457 ((chip)->ops->reg_readw((dev)->sd_addr + ICH6_REG_##reg))
458#define azx_sd_writeb(chip, dev, reg, value) \
459 ((chip)->ops->reg_writeb(value, (dev)->sd_addr + ICH6_REG_##reg))
460#define azx_sd_readb(chip, dev, reg) \
461 ((chip)->ops->reg_readb((dev)->sd_addr + ICH6_REG_##reg))
462
463#endif /* __SOUND_HDA_PRIV_H */
diff --git a/sound/pci/hda/hda_sysfs.c b/sound/pci/hda/hda_sysfs.c
new file mode 100644
index 000000000000..e2079090ca6f
--- /dev/null
+++ b/sound/pci/hda/hda_sysfs.c
@@ -0,0 +1,780 @@
1/*
2 * sysfs interface for HD-audio codec
3 *
4 * Copyright (c) 2014 Takashi Iwai <tiwai@suse.de>
5 *
6 * split from hda_hwdep.c
7 */
8
9#include <linux/init.h>
10#include <linux/slab.h>
11#include <linux/compat.h>
12#include <linux/mutex.h>
13#include <linux/ctype.h>
14#include <linux/string.h>
15#include <linux/export.h>
16#include <sound/core.h>
17#include "hda_codec.h"
18#include "hda_local.h"
19#include <sound/hda_hwdep.h>
20#include <sound/minors.h>
21
22/* hint string pair */
23struct hda_hint {
24 const char *key;
25 const char *val; /* contained in the same alloc as key */
26};
27
28#ifdef CONFIG_PM
29static ssize_t power_on_acct_show(struct device *dev,
30 struct device_attribute *attr,
31 char *buf)
32{
33 struct hda_codec *codec = dev_get_drvdata(dev);
34 snd_hda_update_power_acct(codec);
35 return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
36}
37
38static ssize_t power_off_acct_show(struct device *dev,
39 struct device_attribute *attr,
40 char *buf)
41{
42 struct hda_codec *codec = dev_get_drvdata(dev);
43 snd_hda_update_power_acct(codec);
44 return sprintf(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
45}
46
47static DEVICE_ATTR_RO(power_on_acct);
48static DEVICE_ATTR_RO(power_off_acct);
49#endif /* CONFIG_PM */
50
51#define CODEC_INFO_SHOW(type) \
52static ssize_t type##_show(struct device *dev, \
53 struct device_attribute *attr, \
54 char *buf) \
55{ \
56 struct hda_codec *codec = dev_get_drvdata(dev); \
57 return sprintf(buf, "0x%x\n", codec->type); \
58}
59
60#define CODEC_INFO_STR_SHOW(type) \
61static ssize_t type##_show(struct device *dev, \
62 struct device_attribute *attr, \
63 char *buf) \
64{ \
65 struct hda_codec *codec = dev_get_drvdata(dev); \
66 return sprintf(buf, "%s\n", \
67 codec->type ? codec->type : ""); \
68}
69
70CODEC_INFO_SHOW(vendor_id);
71CODEC_INFO_SHOW(subsystem_id);
72CODEC_INFO_SHOW(revision_id);
73CODEC_INFO_SHOW(afg);
74CODEC_INFO_SHOW(mfg);
75CODEC_INFO_STR_SHOW(vendor_name);
76CODEC_INFO_STR_SHOW(chip_name);
77CODEC_INFO_STR_SHOW(modelname);
78
79static ssize_t pin_configs_show(struct hda_codec *codec,
80 struct snd_array *list,
81 char *buf)
82{
83 int i, len = 0;
84 mutex_lock(&codec->user_mutex);
85 for (i = 0; i < list->used; i++) {
86 struct hda_pincfg *pin = snd_array_elem(list, i);
87 len += sprintf(buf + len, "0x%02x 0x%08x\n",
88 pin->nid, pin->cfg);
89 }
90 mutex_unlock(&codec->user_mutex);
91 return len;
92}
93
94static ssize_t init_pin_configs_show(struct device *dev,
95 struct device_attribute *attr,
96 char *buf)
97{
98 struct hda_codec *codec = dev_get_drvdata(dev);
99 return pin_configs_show(codec, &codec->init_pins, buf);
100}
101
102static ssize_t driver_pin_configs_show(struct device *dev,
103 struct device_attribute *attr,
104 char *buf)
105{
106 struct hda_codec *codec = dev_get_drvdata(dev);
107 return pin_configs_show(codec, &codec->driver_pins, buf);
108}
109
110#ifdef CONFIG_SND_HDA_RECONFIG
111
112/*
113 * sysfs interface
114 */
115
116static int clear_codec(struct hda_codec *codec)
117{
118 int err;
119
120 err = snd_hda_codec_reset(codec);
121 if (err < 0) {
122 codec_err(codec, "The codec is being used, can't free.\n");
123 return err;
124 }
125 snd_hda_sysfs_clear(codec);
126 return 0;
127}
128
129static int reconfig_codec(struct hda_codec *codec)
130{
131 int err;
132
133 snd_hda_power_up(codec);
134 codec_info(codec, "hda-codec: reconfiguring\n");
135 err = snd_hda_codec_reset(codec);
136 if (err < 0) {
137 codec_err(codec,
138 "The codec is being used, can't reconfigure.\n");
139 goto error;
140 }
141 err = snd_hda_codec_configure(codec);
142 if (err < 0)
143 goto error;
144 /* rebuild PCMs */
145 err = snd_hda_codec_build_pcms(codec);
146 if (err < 0)
147 goto error;
148 /* rebuild mixers */
149 err = snd_hda_codec_build_controls(codec);
150 if (err < 0)
151 goto error;
152 err = snd_card_register(codec->bus->card);
153 error:
154 snd_hda_power_down(codec);
155 return err;
156}
157
158/*
159 * allocate a string at most len chars, and remove the trailing EOL
160 */
161static char *kstrndup_noeol(const char *src, size_t len)
162{
163 char *s = kstrndup(src, len, GFP_KERNEL);
164 char *p;
165 if (!s)
166 return NULL;
167 p = strchr(s, '\n');
168 if (p)
169 *p = 0;
170 return s;
171}
172
173#define CODEC_INFO_STORE(type) \
174static ssize_t type##_store(struct device *dev, \
175 struct device_attribute *attr, \
176 const char *buf, size_t count) \
177{ \
178 struct hda_codec *codec = dev_get_drvdata(dev); \
179 unsigned long val; \
180 int err = kstrtoul(buf, 0, &val); \
181 if (err < 0) \
182 return err; \
183 codec->type = val; \
184 return count; \
185}
186
187#define CODEC_INFO_STR_STORE(type) \
188static ssize_t type##_store(struct device *dev, \
189 struct device_attribute *attr, \
190 const char *buf, size_t count) \
191{ \
192 struct hda_codec *codec = dev_get_drvdata(dev); \
193 char *s = kstrndup_noeol(buf, 64); \
194 if (!s) \
195 return -ENOMEM; \
196 kfree(codec->type); \
197 codec->type = s; \
198 return count; \
199}
200
201CODEC_INFO_STORE(vendor_id);
202CODEC_INFO_STORE(subsystem_id);
203CODEC_INFO_STORE(revision_id);
204CODEC_INFO_STR_STORE(vendor_name);
205CODEC_INFO_STR_STORE(chip_name);
206CODEC_INFO_STR_STORE(modelname);
207
208#define CODEC_ACTION_STORE(type) \
209static ssize_t type##_store(struct device *dev, \
210 struct device_attribute *attr, \
211 const char *buf, size_t count) \
212{ \
213 struct hda_codec *codec = dev_get_drvdata(dev); \
214 int err = 0; \
215 if (*buf) \
216 err = type##_codec(codec); \
217 return err < 0 ? err : count; \
218}
219
220CODEC_ACTION_STORE(reconfig);
221CODEC_ACTION_STORE(clear);
222
223static ssize_t init_verbs_show(struct device *dev,
224 struct device_attribute *attr,
225 char *buf)
226{
227 struct hda_codec *codec = dev_get_drvdata(dev);
228 int i, len = 0;
229 mutex_lock(&codec->user_mutex);
230 for (i = 0; i < codec->init_verbs.used; i++) {
231 struct hda_verb *v = snd_array_elem(&codec->init_verbs, i);
232 len += snprintf(buf + len, PAGE_SIZE - len,
233 "0x%02x 0x%03x 0x%04x\n",
234 v->nid, v->verb, v->param);
235 }
236 mutex_unlock(&codec->user_mutex);
237 return len;
238}
239
240static int parse_init_verbs(struct hda_codec *codec, const char *buf)
241{
242 struct hda_verb *v;
243 int nid, verb, param;
244
245 if (sscanf(buf, "%i %i %i", &nid, &verb, &param) != 3)
246 return -EINVAL;
247 if (!nid || !verb)
248 return -EINVAL;
249 mutex_lock(&codec->user_mutex);
250 v = snd_array_new(&codec->init_verbs);
251 if (!v) {
252 mutex_unlock(&codec->user_mutex);
253 return -ENOMEM;
254 }
255 v->nid = nid;
256 v->verb = verb;
257 v->param = param;
258 mutex_unlock(&codec->user_mutex);
259 return 0;
260}
261
262static ssize_t init_verbs_store(struct device *dev,
263 struct device_attribute *attr,
264 const char *buf, size_t count)
265{
266 struct hda_codec *codec = dev_get_drvdata(dev);
267 int err = parse_init_verbs(codec, buf);
268 if (err < 0)
269 return err;
270 return count;
271}
272
273static ssize_t hints_show(struct device *dev,
274 struct device_attribute *attr,
275 char *buf)
276{
277 struct hda_codec *codec = dev_get_drvdata(dev);
278 int i, len = 0;
279 mutex_lock(&codec->user_mutex);
280 for (i = 0; i < codec->hints.used; i++) {
281 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
282 len += snprintf(buf + len, PAGE_SIZE - len,
283 "%s = %s\n", hint->key, hint->val);
284 }
285 mutex_unlock(&codec->user_mutex);
286 return len;
287}
288
289static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
290{
291 int i;
292
293 for (i = 0; i < codec->hints.used; i++) {
294 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
295 if (!strcmp(hint->key, key))
296 return hint;
297 }
298 return NULL;
299}
300
301static void remove_trail_spaces(char *str)
302{
303 char *p;
304 if (!*str)
305 return;
306 p = str + strlen(str) - 1;
307 for (; isspace(*p); p--) {
308 *p = 0;
309 if (p == str)
310 return;
311 }
312}
313
314#define MAX_HINTS 1024
315
316static int parse_hints(struct hda_codec *codec, const char *buf)
317{
318 char *key, *val;
319 struct hda_hint *hint;
320 int err = 0;
321
322 buf = skip_spaces(buf);
323 if (!*buf || *buf == '#' || *buf == '\n')
324 return 0;
325 if (*buf == '=')
326 return -EINVAL;
327 key = kstrndup_noeol(buf, 1024);
328 if (!key)
329 return -ENOMEM;
330 /* extract key and val */
331 val = strchr(key, '=');
332 if (!val) {
333 kfree(key);
334 return -EINVAL;
335 }
336 *val++ = 0;
337 val = skip_spaces(val);
338 remove_trail_spaces(key);
339 remove_trail_spaces(val);
340 mutex_lock(&codec->user_mutex);
341 hint = get_hint(codec, key);
342 if (hint) {
343 /* replace */
344 kfree(hint->key);
345 hint->key = key;
346 hint->val = val;
347 goto unlock;
348 }
349 /* allocate a new hint entry */
350 if (codec->hints.used >= MAX_HINTS)
351 hint = NULL;
352 else
353 hint = snd_array_new(&codec->hints);
354 if (hint) {
355 hint->key = key;
356 hint->val = val;
357 } else {
358 err = -ENOMEM;
359 }
360 unlock:
361 mutex_unlock(&codec->user_mutex);
362 if (err)
363 kfree(key);
364 return err;
365}
366
367static ssize_t hints_store(struct device *dev,
368 struct device_attribute *attr,
369 const char *buf, size_t count)
370{
371 struct hda_codec *codec = dev_get_drvdata(dev);
372 int err = parse_hints(codec, buf);
373 if (err < 0)
374 return err;
375 return count;
376}
377
378static ssize_t user_pin_configs_show(struct device *dev,
379 struct device_attribute *attr,
380 char *buf)
381{
382 struct hda_codec *codec = dev_get_drvdata(dev);
383 return pin_configs_show(codec, &codec->user_pins, buf);
384}
385
386#define MAX_PIN_CONFIGS 32
387
388static int parse_user_pin_configs(struct hda_codec *codec, const char *buf)
389{
390 int nid, cfg, err;
391
392 if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
393 return -EINVAL;
394 if (!nid)
395 return -EINVAL;
396 mutex_lock(&codec->user_mutex);
397 err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
398 mutex_unlock(&codec->user_mutex);
399 return err;
400}
401
402static ssize_t user_pin_configs_store(struct device *dev,
403 struct device_attribute *attr,
404 const char *buf, size_t count)
405{
406 struct hda_codec *codec = dev_get_drvdata(dev);
407 int err = parse_user_pin_configs(codec, buf);
408 if (err < 0)
409 return err;
410 return count;
411}
412
413/* sysfs attributes exposed only when CONFIG_SND_HDA_RECONFIG=y */
414static DEVICE_ATTR_RW(init_verbs);
415static DEVICE_ATTR_RW(hints);
416static DEVICE_ATTR_RW(user_pin_configs);
417static DEVICE_ATTR_WO(reconfig);
418static DEVICE_ATTR_WO(clear);
419
420/*
421 * Look for hint string
422 */
423const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
424{
425 struct hda_hint *hint = get_hint(codec, key);
426 return hint ? hint->val : NULL;
427}
428EXPORT_SYMBOL_GPL(snd_hda_get_hint);
429
430int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
431{
432 const char *p;
433 int ret;
434
435 mutex_lock(&codec->user_mutex);
436 p = snd_hda_get_hint(codec, key);
437 if (!p || !*p)
438 ret = -ENOENT;
439 else {
440 switch (toupper(*p)) {
441 case 'T': /* true */
442 case 'Y': /* yes */
443 case '1':
444 ret = 1;
445 break;
446 default:
447 ret = 0;
448 break;
449 }
450 }
451 mutex_unlock(&codec->user_mutex);
452 return ret;
453}
454EXPORT_SYMBOL_GPL(snd_hda_get_bool_hint);
455
456int snd_hda_get_int_hint(struct hda_codec *codec, const char *key, int *valp)
457{
458 const char *p;
459 unsigned long val;
460 int ret;
461
462 mutex_lock(&codec->user_mutex);
463 p = snd_hda_get_hint(codec, key);
464 if (!p)
465 ret = -ENOENT;
466 else if (kstrtoul(p, 0, &val))
467 ret = -EINVAL;
468 else {
469 *valp = val;
470 ret = 0;
471 }
472 mutex_unlock(&codec->user_mutex);
473 return ret;
474}
475EXPORT_SYMBOL_GPL(snd_hda_get_int_hint);
476#endif /* CONFIG_SND_HDA_RECONFIG */
477
478/*
479 * common sysfs attributes
480 */
481#ifdef CONFIG_SND_HDA_RECONFIG
482#define RECONFIG_DEVICE_ATTR(name) DEVICE_ATTR_RW(name)
483#else
484#define RECONFIG_DEVICE_ATTR(name) DEVICE_ATTR_RO(name)
485#endif
486static RECONFIG_DEVICE_ATTR(vendor_id);
487static RECONFIG_DEVICE_ATTR(subsystem_id);
488static RECONFIG_DEVICE_ATTR(revision_id);
489static DEVICE_ATTR_RO(afg);
490static DEVICE_ATTR_RO(mfg);
491static RECONFIG_DEVICE_ATTR(vendor_name);
492static RECONFIG_DEVICE_ATTR(chip_name);
493static RECONFIG_DEVICE_ATTR(modelname);
494static DEVICE_ATTR_RO(init_pin_configs);
495static DEVICE_ATTR_RO(driver_pin_configs);
496
497
498#ifdef CONFIG_SND_HDA_PATCH_LOADER
499
500/* parser mode */
501enum {
502 LINE_MODE_NONE,
503 LINE_MODE_CODEC,
504 LINE_MODE_MODEL,
505 LINE_MODE_PINCFG,
506 LINE_MODE_VERB,
507 LINE_MODE_HINT,
508 LINE_MODE_VENDOR_ID,
509 LINE_MODE_SUBSYSTEM_ID,
510 LINE_MODE_REVISION_ID,
511 LINE_MODE_CHIP_NAME,
512 NUM_LINE_MODES,
513};
514
515static inline int strmatch(const char *a, const char *b)
516{
517 return strnicmp(a, b, strlen(b)) == 0;
518}
519
520/* parse the contents after the line "[codec]"
521 * accept only the line with three numbers, and assign the current codec
522 */
523static void parse_codec_mode(char *buf, struct hda_bus *bus,
524 struct hda_codec **codecp)
525{
526 int vendorid, subid, caddr;
527 struct hda_codec *codec;
528
529 *codecp = NULL;
530 if (sscanf(buf, "%i %i %i", &vendorid, &subid, &caddr) == 3) {
531 list_for_each_entry(codec, &bus->codec_list, list) {
532 if ((vendorid <= 0 || codec->vendor_id == vendorid) &&
533 (subid <= 0 || codec->subsystem_id == subid) &&
534 codec->addr == caddr) {
535 *codecp = codec;
536 break;
537 }
538 }
539 }
540}
541
542/* parse the contents after the other command tags, [pincfg], [verb],
543 * [vendor_id], [subsystem_id], [revision_id], [chip_name], [hint] and [model]
544 * just pass to the sysfs helper (only when any codec was specified)
545 */
546static void parse_pincfg_mode(char *buf, struct hda_bus *bus,
547 struct hda_codec **codecp)
548{
549 parse_user_pin_configs(*codecp, buf);
550}
551
552static void parse_verb_mode(char *buf, struct hda_bus *bus,
553 struct hda_codec **codecp)
554{
555 parse_init_verbs(*codecp, buf);
556}
557
558static void parse_hint_mode(char *buf, struct hda_bus *bus,
559 struct hda_codec **codecp)
560{
561 parse_hints(*codecp, buf);
562}
563
564static void parse_model_mode(char *buf, struct hda_bus *bus,
565 struct hda_codec **codecp)
566{
567 kfree((*codecp)->modelname);
568 (*codecp)->modelname = kstrdup(buf, GFP_KERNEL);
569}
570
571static void parse_chip_name_mode(char *buf, struct hda_bus *bus,
572 struct hda_codec **codecp)
573{
574 kfree((*codecp)->chip_name);
575 (*codecp)->chip_name = kstrdup(buf, GFP_KERNEL);
576}
577
578#define DEFINE_PARSE_ID_MODE(name) \
579static void parse_##name##_mode(char *buf, struct hda_bus *bus, \
580 struct hda_codec **codecp) \
581{ \
582 unsigned long val; \
583 if (!kstrtoul(buf, 0, &val)) \
584 (*codecp)->name = val; \
585}
586
587DEFINE_PARSE_ID_MODE(vendor_id);
588DEFINE_PARSE_ID_MODE(subsystem_id);
589DEFINE_PARSE_ID_MODE(revision_id);
590
591
592struct hda_patch_item {
593 const char *tag;
594 const char *alias;
595 void (*parser)(char *buf, struct hda_bus *bus, struct hda_codec **retc);
596};
597
598static struct hda_patch_item patch_items[NUM_LINE_MODES] = {
599 [LINE_MODE_CODEC] = {
600 .tag = "[codec]",
601 .parser = parse_codec_mode,
602 },
603 [LINE_MODE_MODEL] = {
604 .tag = "[model]",
605 .parser = parse_model_mode,
606 },
607 [LINE_MODE_VERB] = {
608 .tag = "[verb]",
609 .alias = "[init_verbs]",
610 .parser = parse_verb_mode,
611 },
612 [LINE_MODE_PINCFG] = {
613 .tag = "[pincfg]",
614 .alias = "[user_pin_configs]",
615 .parser = parse_pincfg_mode,
616 },
617 [LINE_MODE_HINT] = {
618 .tag = "[hint]",
619 .alias = "[hints]",
620 .parser = parse_hint_mode
621 },
622 [LINE_MODE_VENDOR_ID] = {
623 .tag = "[vendor_id]",
624 .parser = parse_vendor_id_mode,
625 },
626 [LINE_MODE_SUBSYSTEM_ID] = {
627 .tag = "[subsystem_id]",
628 .parser = parse_subsystem_id_mode,
629 },
630 [LINE_MODE_REVISION_ID] = {
631 .tag = "[revision_id]",
632 .parser = parse_revision_id_mode,
633 },
634 [LINE_MODE_CHIP_NAME] = {
635 .tag = "[chip_name]",
636 .parser = parse_chip_name_mode,
637 },
638};
639
640/* check the line starting with '[' -- change the parser mode accodingly */
641static int parse_line_mode(char *buf, struct hda_bus *bus)
642{
643 int i;
644 for (i = 0; i < ARRAY_SIZE(patch_items); i++) {
645 if (!patch_items[i].tag)
646 continue;
647 if (strmatch(buf, patch_items[i].tag))
648 return i;
649 if (patch_items[i].alias && strmatch(buf, patch_items[i].alias))
650 return i;
651 }
652 return LINE_MODE_NONE;
653}
654
655/* copy one line from the buffer in fw, and update the fields in fw
656 * return zero if it reaches to the end of the buffer, or non-zero
657 * if successfully copied a line
658 *
659 * the spaces at the beginning and the end of the line are stripped
660 */
661static int get_line_from_fw(char *buf, int size, size_t *fw_size_p,
662 const void **fw_data_p)
663{
664 int len;
665 size_t fw_size = *fw_size_p;
666 const char *p = *fw_data_p;
667
668 while (isspace(*p) && fw_size) {
669 p++;
670 fw_size--;
671 }
672 if (!fw_size)
673 return 0;
674
675 for (len = 0; len < fw_size; len++) {
676 if (!*p)
677 break;
678 if (*p == '\n') {
679 p++;
680 len++;
681 break;
682 }
683 if (len < size)
684 *buf++ = *p++;
685 }
686 *buf = 0;
687 *fw_size_p = fw_size - len;
688 *fw_data_p = p;
689 remove_trail_spaces(buf);
690 return 1;
691}
692
693/*
694 * load a "patch" firmware file and parse it
695 */
696int snd_hda_load_patch(struct hda_bus *bus, size_t fw_size, const void *fw_buf)
697{
698 char buf[128];
699 struct hda_codec *codec;
700 int line_mode;
701
702 line_mode = LINE_MODE_NONE;
703 codec = NULL;
704 while (get_line_from_fw(buf, sizeof(buf) - 1, &fw_size, &fw_buf)) {
705 if (!*buf || *buf == '#' || *buf == '\n')
706 continue;
707 if (*buf == '[')
708 line_mode = parse_line_mode(buf, bus);
709 else if (patch_items[line_mode].parser &&
710 (codec || line_mode <= LINE_MODE_CODEC))
711 patch_items[line_mode].parser(buf, bus, &codec);
712 }
713 return 0;
714}
715EXPORT_SYMBOL_GPL(snd_hda_load_patch);
716#endif /* CONFIG_SND_HDA_PATCH_LOADER */
717
718/*
719 * sysfs entries
720 */
721static struct attribute *hda_dev_attrs[] = {
722 &dev_attr_vendor_id.attr,
723 &dev_attr_subsystem_id.attr,
724 &dev_attr_revision_id.attr,
725 &dev_attr_afg.attr,
726 &dev_attr_mfg.attr,
727 &dev_attr_vendor_name.attr,
728 &dev_attr_chip_name.attr,
729 &dev_attr_modelname.attr,
730 &dev_attr_init_pin_configs.attr,
731 &dev_attr_driver_pin_configs.attr,
732#ifdef CONFIG_PM
733 &dev_attr_power_on_acct.attr,
734 &dev_attr_power_off_acct.attr,
735#endif
736#ifdef CONFIG_SND_HDA_RECONFIG
737 &dev_attr_init_verbs.attr,
738 &dev_attr_hints.attr,
739 &dev_attr_user_pin_configs.attr,
740 &dev_attr_reconfig.attr,
741 &dev_attr_clear.attr,
742#endif
743 NULL
744};
745
746static struct attribute_group hda_dev_attr_group = {
747 .attrs = hda_dev_attrs,
748};
749
750const struct attribute_group *snd_hda_dev_attr_groups[] = {
751 &hda_dev_attr_group,
752 NULL
753};
754
755void snd_hda_sysfs_init(struct hda_codec *codec)
756{
757 mutex_init(&codec->user_mutex);
758#ifdef CONFIG_SND_HDA_RECONFIG
759 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
760 snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
761 snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
762#endif
763}
764
765void snd_hda_sysfs_clear(struct hda_codec *codec)
766{
767#ifdef CONFIG_SND_HDA_RECONFIG
768 int i;
769
770 /* clear init verbs */
771 snd_array_free(&codec->init_verbs);
772 /* clear hints */
773 for (i = 0; i < codec->hints.used; i++) {
774 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
775 kfree(hint->key); /* we don't need to free hint->val */
776 }
777 snd_array_free(&codec->hints);
778 snd_array_free(&codec->user_pins);
779#endif
780}
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 8ed0bcc01386..40ba06eb44af 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -21,7 +21,6 @@
21 21
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/pci.h>
25#include <linux/module.h> 24#include <linux/module.h>
26 25
27#include <sound/core.h> 26#include <sound/core.h>
diff --git a/sound/pci/hda/patch_ca0110.c b/sound/pci/hda/patch_ca0110.c
index 30b3a4bc06ee..5e65999e0d8e 100644
--- a/sound/pci/hda/patch_ca0110.c
+++ b/sound/pci/hda/patch_ca0110.c
@@ -20,7 +20,6 @@
20 20
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/pci.h>
24#include <linux/module.h> 23#include <linux/module.h>
25#include <sound/core.h> 24#include <sound/core.h>
26#include "hda_codec.h" 25#include "hda_codec.h"
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 46ecdbb9053f..092f2bd030bd 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -24,7 +24,6 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/pci.h>
28#include <linux/mutex.h> 27#include <linux/mutex.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/firmware.h> 29#include <linux/firmware.h>
@@ -868,7 +867,7 @@ static int chipio_write_data_multiple(struct hda_codec *codec,
868 int status = 0; 867 int status = 0;
869 868
870 if (data == NULL) { 869 if (data == NULL) {
871 snd_printdd(KERN_ERR "chipio_write_data null ptr\n"); 870 codec_dbg(codec, "chipio_write_data null ptr\n");
872 return -EINVAL; 871 return -EINVAL;
873 } 872 }
874 873
@@ -1407,12 +1406,12 @@ static int dspio_scp(struct hda_codec *codec,
1407 return -EINVAL; 1406 return -EINVAL;
1408 1407
1409 if (dir == SCP_GET && reply == NULL) { 1408 if (dir == SCP_GET && reply == NULL) {
1410 snd_printdd(KERN_ERR "dspio_scp get but has no buffer\n"); 1409 codec_dbg(codec, "dspio_scp get but has no buffer\n");
1411 return -EINVAL; 1410 return -EINVAL;
1412 } 1411 }
1413 1412
1414 if (reply != NULL && (reply_len == NULL || (*reply_len == 0))) { 1413 if (reply != NULL && (reply_len == NULL || (*reply_len == 0))) {
1415 snd_printdd(KERN_ERR "dspio_scp bad resp buf len parms\n"); 1414 codec_dbg(codec, "dspio_scp bad resp buf len parms\n");
1416 return -EINVAL; 1415 return -EINVAL;
1417 } 1416 }
1418 1417
@@ -1430,7 +1429,7 @@ static int dspio_scp(struct hda_codec *codec,
1430 sizeof(scp_reply), &ret_bytes); 1429 sizeof(scp_reply), &ret_bytes);
1431 1430
1432 if (status < 0) { 1431 if (status < 0) {
1433 snd_printdd(KERN_ERR "dspio_scp: send scp msg failed\n"); 1432 codec_dbg(codec, "dspio_scp: send scp msg failed\n");
1434 return status; 1433 return status;
1435 } 1434 }
1436 1435
@@ -1449,17 +1448,17 @@ static int dspio_scp(struct hda_codec *codec,
1449 / sizeof(unsigned int); 1448 / sizeof(unsigned int);
1450 1449
1451 if (*reply_len < ret_size*sizeof(unsigned int)) { 1450 if (*reply_len < ret_size*sizeof(unsigned int)) {
1452 snd_printdd(KERN_ERR "reply too long for buf\n"); 1451 codec_dbg(codec, "reply too long for buf\n");
1453 return -EINVAL; 1452 return -EINVAL;
1454 } else if (ret_size != reply_data_size) { 1453 } else if (ret_size != reply_data_size) {
1455 snd_printdd(KERN_ERR "RetLen and HdrLen .NE.\n"); 1454 codec_dbg(codec, "RetLen and HdrLen .NE.\n");
1456 return -EINVAL; 1455 return -EINVAL;
1457 } else { 1456 } else {
1458 *reply_len = ret_size*sizeof(unsigned int); 1457 *reply_len = ret_size*sizeof(unsigned int);
1459 memcpy(reply, scp_reply.data, *reply_len); 1458 memcpy(reply, scp_reply.data, *reply_len);
1460 } 1459 }
1461 } else { 1460 } else {
1462 snd_printdd(KERN_ERR "reply ill-formed or errflag set\n"); 1461 codec_dbg(codec, "reply ill-formed or errflag set\n");
1463 return -EIO; 1462 return -EIO;
1464 } 1463 }
1465 1464
@@ -1489,22 +1488,22 @@ static int dspio_alloc_dma_chan(struct hda_codec *codec, unsigned int *dma_chan)
1489 int status = 0; 1488 int status = 0;
1490 unsigned int size = sizeof(dma_chan); 1489 unsigned int size = sizeof(dma_chan);
1491 1490
1492 snd_printdd(KERN_INFO " dspio_alloc_dma_chan() -- begin\n"); 1491 codec_dbg(codec, " dspio_alloc_dma_chan() -- begin\n");
1493 status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN, 1492 status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN,
1494 SCP_GET, NULL, 0, dma_chan, &size); 1493 SCP_GET, NULL, 0, dma_chan, &size);
1495 1494
1496 if (status < 0) { 1495 if (status < 0) {
1497 snd_printdd(KERN_INFO "dspio_alloc_dma_chan: SCP Failed\n"); 1496 codec_dbg(codec, "dspio_alloc_dma_chan: SCP Failed\n");
1498 return status; 1497 return status;
1499 } 1498 }
1500 1499
1501 if ((*dma_chan + 1) == 0) { 1500 if ((*dma_chan + 1) == 0) {
1502 snd_printdd(KERN_INFO "no free dma channels to allocate\n"); 1501 codec_dbg(codec, "no free dma channels to allocate\n");
1503 return -EBUSY; 1502 return -EBUSY;
1504 } 1503 }
1505 1504
1506 snd_printdd("dspio_alloc_dma_chan: chan=%d\n", *dma_chan); 1505 codec_dbg(codec, "dspio_alloc_dma_chan: chan=%d\n", *dma_chan);
1507 snd_printdd(KERN_INFO " dspio_alloc_dma_chan() -- complete\n"); 1506 codec_dbg(codec, " dspio_alloc_dma_chan() -- complete\n");
1508 1507
1509 return status; 1508 return status;
1510} 1509}
@@ -1517,18 +1516,18 @@ static int dspio_free_dma_chan(struct hda_codec *codec, unsigned int dma_chan)
1517 int status = 0; 1516 int status = 0;
1518 unsigned int dummy = 0; 1517 unsigned int dummy = 0;
1519 1518
1520 snd_printdd(KERN_INFO " dspio_free_dma_chan() -- begin\n"); 1519 codec_dbg(codec, " dspio_free_dma_chan() -- begin\n");
1521 snd_printdd("dspio_free_dma_chan: chan=%d\n", dma_chan); 1520 codec_dbg(codec, "dspio_free_dma_chan: chan=%d\n", dma_chan);
1522 1521
1523 status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN, 1522 status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN,
1524 SCP_SET, &dma_chan, sizeof(dma_chan), NULL, &dummy); 1523 SCP_SET, &dma_chan, sizeof(dma_chan), NULL, &dummy);
1525 1524
1526 if (status < 0) { 1525 if (status < 0) {
1527 snd_printdd(KERN_INFO "dspio_free_dma_chan: SCP Failed\n"); 1526 codec_dbg(codec, "dspio_free_dma_chan: SCP Failed\n");
1528 return status; 1527 return status;
1529 } 1528 }
1530 1529
1531 snd_printdd(KERN_INFO " dspio_free_dma_chan() -- complete\n"); 1530 codec_dbg(codec, " dspio_free_dma_chan() -- complete\n");
1532 1531
1533 return status; 1532 return status;
1534} 1533}
@@ -1576,14 +1575,14 @@ static int dsp_reset(struct hda_codec *codec)
1576 unsigned int res; 1575 unsigned int res;
1577 int retry = 20; 1576 int retry = 20;
1578 1577
1579 snd_printdd("dsp_reset\n"); 1578 codec_dbg(codec, "dsp_reset\n");
1580 do { 1579 do {
1581 res = dspio_send(codec, VENDOR_DSPIO_DSP_INIT, 0); 1580 res = dspio_send(codec, VENDOR_DSPIO_DSP_INIT, 0);
1582 retry--; 1581 retry--;
1583 } while (res == -EIO && retry); 1582 } while (res == -EIO && retry);
1584 1583
1585 if (!retry) { 1584 if (!retry) {
1586 snd_printdd("dsp_reset timeout\n"); 1585 codec_dbg(codec, "dsp_reset timeout\n");
1587 return -EIO; 1586 return -EIO;
1588 } 1587 }
1589 1588
@@ -1636,39 +1635,39 @@ static int dsp_dma_setup_common(struct hda_codec *codec,
1636 unsigned int active; 1635 unsigned int active;
1637 bool code, yram; 1636 bool code, yram;
1638 1637
1639 snd_printdd(KERN_INFO "-- dsp_dma_setup_common() -- Begin ---------\n"); 1638 codec_dbg(codec, "-- dsp_dma_setup_common() -- Begin ---------\n");
1640 1639
1641 if (dma_chan >= DSPDMAC_DMA_CFG_CHANNEL_COUNT) { 1640 if (dma_chan >= DSPDMAC_DMA_CFG_CHANNEL_COUNT) {
1642 snd_printdd(KERN_ERR "dma chan num invalid\n"); 1641 codec_dbg(codec, "dma chan num invalid\n");
1643 return -EINVAL; 1642 return -EINVAL;
1644 } 1643 }
1645 1644
1646 if (dsp_is_dma_active(codec, dma_chan)) { 1645 if (dsp_is_dma_active(codec, dma_chan)) {
1647 snd_printdd(KERN_ERR "dma already active\n"); 1646 codec_dbg(codec, "dma already active\n");
1648 return -EBUSY; 1647 return -EBUSY;
1649 } 1648 }
1650 1649
1651 dsp_addx = dsp_chip_to_dsp_addx(chip_addx, &code, &yram); 1650 dsp_addx = dsp_chip_to_dsp_addx(chip_addx, &code, &yram);
1652 1651
1653 if (dsp_addx == INVALID_CHIP_ADDRESS) { 1652 if (dsp_addx == INVALID_CHIP_ADDRESS) {
1654 snd_printdd(KERN_ERR "invalid chip addr\n"); 1653 codec_dbg(codec, "invalid chip addr\n");
1655 return -ENXIO; 1654 return -ENXIO;
1656 } 1655 }
1657 1656
1658 chnl_prop = DSPDMAC_CHNLPROP_AC_MASK; 1657 chnl_prop = DSPDMAC_CHNLPROP_AC_MASK;
1659 active = 0; 1658 active = 0;
1660 1659
1661 snd_printdd(KERN_INFO " dsp_dma_setup_common() start reg pgm\n"); 1660 codec_dbg(codec, " dsp_dma_setup_common() start reg pgm\n");
1662 1661
1663 if (ovly) { 1662 if (ovly) {
1664 status = chipio_read(codec, DSPDMAC_CHNLPROP_INST_OFFSET, 1663 status = chipio_read(codec, DSPDMAC_CHNLPROP_INST_OFFSET,
1665 &chnl_prop); 1664 &chnl_prop);
1666 1665
1667 if (status < 0) { 1666 if (status < 0) {
1668 snd_printdd(KERN_ERR "read CHNLPROP Reg fail\n"); 1667 codec_dbg(codec, "read CHNLPROP Reg fail\n");
1669 return status; 1668 return status;
1670 } 1669 }
1671 snd_printdd(KERN_INFO "dsp_dma_setup_common() Read CHNLPROP\n"); 1670 codec_dbg(codec, "dsp_dma_setup_common() Read CHNLPROP\n");
1672 } 1671 }
1673 1672
1674 if (!code) 1673 if (!code)
@@ -1680,20 +1679,20 @@ static int dsp_dma_setup_common(struct hda_codec *codec,
1680 1679
1681 status = chipio_write(codec, DSPDMAC_CHNLPROP_INST_OFFSET, chnl_prop); 1680 status = chipio_write(codec, DSPDMAC_CHNLPROP_INST_OFFSET, chnl_prop);
1682 if (status < 0) { 1681 if (status < 0) {
1683 snd_printdd(KERN_ERR "write CHNLPROP Reg fail\n"); 1682 codec_dbg(codec, "write CHNLPROP Reg fail\n");
1684 return status; 1683 return status;
1685 } 1684 }
1686 snd_printdd(KERN_INFO " dsp_dma_setup_common() Write CHNLPROP\n"); 1685 codec_dbg(codec, " dsp_dma_setup_common() Write CHNLPROP\n");
1687 1686
1688 if (ovly) { 1687 if (ovly) {
1689 status = chipio_read(codec, DSPDMAC_ACTIVE_INST_OFFSET, 1688 status = chipio_read(codec, DSPDMAC_ACTIVE_INST_OFFSET,
1690 &active); 1689 &active);
1691 1690
1692 if (status < 0) { 1691 if (status < 0) {
1693 snd_printdd(KERN_ERR "read ACTIVE Reg fail\n"); 1692 codec_dbg(codec, "read ACTIVE Reg fail\n");
1694 return status; 1693 return status;
1695 } 1694 }
1696 snd_printdd(KERN_INFO "dsp_dma_setup_common() Read ACTIVE\n"); 1695 codec_dbg(codec, "dsp_dma_setup_common() Read ACTIVE\n");
1697 } 1696 }
1698 1697
1699 active &= (~(1 << (DSPDMAC_ACTIVE_AAR_LOBIT + dma_chan))) & 1698 active &= (~(1 << (DSPDMAC_ACTIVE_AAR_LOBIT + dma_chan))) &
@@ -1701,35 +1700,35 @@ static int dsp_dma_setup_common(struct hda_codec *codec,
1701 1700
1702 status = chipio_write(codec, DSPDMAC_ACTIVE_INST_OFFSET, active); 1701 status = chipio_write(codec, DSPDMAC_ACTIVE_INST_OFFSET, active);
1703 if (status < 0) { 1702 if (status < 0) {
1704 snd_printdd(KERN_ERR "write ACTIVE Reg fail\n"); 1703 codec_dbg(codec, "write ACTIVE Reg fail\n");
1705 return status; 1704 return status;
1706 } 1705 }
1707 1706
1708 snd_printdd(KERN_INFO " dsp_dma_setup_common() Write ACTIVE\n"); 1707 codec_dbg(codec, " dsp_dma_setup_common() Write ACTIVE\n");
1709 1708
1710 status = chipio_write(codec, DSPDMAC_AUDCHSEL_INST_OFFSET(dma_chan), 1709 status = chipio_write(codec, DSPDMAC_AUDCHSEL_INST_OFFSET(dma_chan),
1711 port_map_mask); 1710 port_map_mask);
1712 if (status < 0) { 1711 if (status < 0) {
1713 snd_printdd(KERN_ERR "write AUDCHSEL Reg fail\n"); 1712 codec_dbg(codec, "write AUDCHSEL Reg fail\n");
1714 return status; 1713 return status;
1715 } 1714 }
1716 snd_printdd(KERN_INFO " dsp_dma_setup_common() Write AUDCHSEL\n"); 1715 codec_dbg(codec, " dsp_dma_setup_common() Write AUDCHSEL\n");
1717 1716
1718 status = chipio_write(codec, DSPDMAC_IRQCNT_INST_OFFSET(dma_chan), 1717 status = chipio_write(codec, DSPDMAC_IRQCNT_INST_OFFSET(dma_chan),
1719 DSPDMAC_IRQCNT_BICNT_MASK | DSPDMAC_IRQCNT_CICNT_MASK); 1718 DSPDMAC_IRQCNT_BICNT_MASK | DSPDMAC_IRQCNT_CICNT_MASK);
1720 if (status < 0) { 1719 if (status < 0) {
1721 snd_printdd(KERN_ERR "write IRQCNT Reg fail\n"); 1720 codec_dbg(codec, "write IRQCNT Reg fail\n");
1722 return status; 1721 return status;
1723 } 1722 }
1724 snd_printdd(KERN_INFO " dsp_dma_setup_common() Write IRQCNT\n"); 1723 codec_dbg(codec, " dsp_dma_setup_common() Write IRQCNT\n");
1725 1724
1726 snd_printdd( 1725 codec_dbg(codec,
1727 "ChipA=0x%x,DspA=0x%x,dmaCh=%u, " 1726 "ChipA=0x%x,DspA=0x%x,dmaCh=%u, "
1728 "CHSEL=0x%x,CHPROP=0x%x,Active=0x%x\n", 1727 "CHSEL=0x%x,CHPROP=0x%x,Active=0x%x\n",
1729 chip_addx, dsp_addx, dma_chan, 1728 chip_addx, dsp_addx, dma_chan,
1730 port_map_mask, chnl_prop, active); 1729 port_map_mask, chnl_prop, active);
1731 1730
1732 snd_printdd(KERN_INFO "-- dsp_dma_setup_common() -- Complete ------\n"); 1731 codec_dbg(codec, "-- dsp_dma_setup_common() -- Complete ------\n");
1733 1732
1734 return 0; 1733 return 0;
1735} 1734}
@@ -1755,20 +1754,20 @@ static int dsp_dma_setup(struct hda_codec *codec,
1755 const unsigned int max_dma_count = 1 << (DSPDMAC_XFRCNT_BCNT_HIBIT - 1754 const unsigned int max_dma_count = 1 << (DSPDMAC_XFRCNT_BCNT_HIBIT -
1756 DSPDMAC_XFRCNT_BCNT_LOBIT + 1); 1755 DSPDMAC_XFRCNT_BCNT_LOBIT + 1);
1757 1756
1758 snd_printdd(KERN_INFO "-- dsp_dma_setup() -- Begin ---------\n"); 1757 codec_dbg(codec, "-- dsp_dma_setup() -- Begin ---------\n");
1759 1758
1760 if (count > max_dma_count) { 1759 if (count > max_dma_count) {
1761 snd_printdd(KERN_ERR "count too big\n"); 1760 codec_dbg(codec, "count too big\n");
1762 return -EINVAL; 1761 return -EINVAL;
1763 } 1762 }
1764 1763
1765 dsp_addx = dsp_chip_to_dsp_addx(chip_addx, &code, &yram); 1764 dsp_addx = dsp_chip_to_dsp_addx(chip_addx, &code, &yram);
1766 if (dsp_addx == INVALID_CHIP_ADDRESS) { 1765 if (dsp_addx == INVALID_CHIP_ADDRESS) {
1767 snd_printdd(KERN_ERR "invalid chip addr\n"); 1766 codec_dbg(codec, "invalid chip addr\n");
1768 return -ENXIO; 1767 return -ENXIO;
1769 } 1768 }
1770 1769
1771 snd_printdd(KERN_INFO " dsp_dma_setup() start reg pgm\n"); 1770 codec_dbg(codec, " dsp_dma_setup() start reg pgm\n");
1772 1771
1773 addr_field = dsp_addx << DSPDMAC_DMACFG_DBADR_LOBIT; 1772 addr_field = dsp_addx << DSPDMAC_DMACFG_DBADR_LOBIT;
1774 incr_field = 0; 1773 incr_field = 0;
@@ -1785,10 +1784,10 @@ static int dsp_dma_setup(struct hda_codec *codec,
1785 status = chipio_write(codec, DSPDMAC_DMACFG_INST_OFFSET(dma_chan), 1784 status = chipio_write(codec, DSPDMAC_DMACFG_INST_OFFSET(dma_chan),
1786 dma_cfg); 1785 dma_cfg);
1787 if (status < 0) { 1786 if (status < 0) {
1788 snd_printdd(KERN_ERR "write DMACFG Reg fail\n"); 1787 codec_dbg(codec, "write DMACFG Reg fail\n");
1789 return status; 1788 return status;
1790 } 1789 }
1791 snd_printdd(KERN_INFO " dsp_dma_setup() Write DMACFG\n"); 1790 codec_dbg(codec, " dsp_dma_setup() Write DMACFG\n");
1792 1791
1793 adr_ofs = (count - 1) << (DSPDMAC_DSPADROFS_BOFS_LOBIT + 1792 adr_ofs = (count - 1) << (DSPDMAC_DSPADROFS_BOFS_LOBIT +
1794 (code ? 0 : 1)); 1793 (code ? 0 : 1));
@@ -1796,10 +1795,10 @@ static int dsp_dma_setup(struct hda_codec *codec,
1796 status = chipio_write(codec, DSPDMAC_DSPADROFS_INST_OFFSET(dma_chan), 1795 status = chipio_write(codec, DSPDMAC_DSPADROFS_INST_OFFSET(dma_chan),
1797 adr_ofs); 1796 adr_ofs);
1798 if (status < 0) { 1797 if (status < 0) {
1799 snd_printdd(KERN_ERR "write DSPADROFS Reg fail\n"); 1798 codec_dbg(codec, "write DSPADROFS Reg fail\n");
1800 return status; 1799 return status;
1801 } 1800 }
1802 snd_printdd(KERN_INFO " dsp_dma_setup() Write DSPADROFS\n"); 1801 codec_dbg(codec, " dsp_dma_setup() Write DSPADROFS\n");
1803 1802
1804 base_cnt = (count - 1) << DSPDMAC_XFRCNT_BCNT_LOBIT; 1803 base_cnt = (count - 1) << DSPDMAC_XFRCNT_BCNT_LOBIT;
1805 1804
@@ -1810,17 +1809,17 @@ static int dsp_dma_setup(struct hda_codec *codec,
1810 status = chipio_write(codec, 1809 status = chipio_write(codec,
1811 DSPDMAC_XFRCNT_INST_OFFSET(dma_chan), xfr_cnt); 1810 DSPDMAC_XFRCNT_INST_OFFSET(dma_chan), xfr_cnt);
1812 if (status < 0) { 1811 if (status < 0) {
1813 snd_printdd(KERN_ERR "write XFRCNT Reg fail\n"); 1812 codec_dbg(codec, "write XFRCNT Reg fail\n");
1814 return status; 1813 return status;
1815 } 1814 }
1816 snd_printdd(KERN_INFO " dsp_dma_setup() Write XFRCNT\n"); 1815 codec_dbg(codec, " dsp_dma_setup() Write XFRCNT\n");
1817 1816
1818 snd_printdd( 1817 codec_dbg(codec,
1819 "ChipA=0x%x, cnt=0x%x, DMACFG=0x%x, " 1818 "ChipA=0x%x, cnt=0x%x, DMACFG=0x%x, "
1820 "ADROFS=0x%x, XFRCNT=0x%x\n", 1819 "ADROFS=0x%x, XFRCNT=0x%x\n",
1821 chip_addx, count, dma_cfg, adr_ofs, xfr_cnt); 1820 chip_addx, count, dma_cfg, adr_ofs, xfr_cnt);
1822 1821
1823 snd_printdd(KERN_INFO "-- dsp_dma_setup() -- Complete ---------\n"); 1822 codec_dbg(codec, "-- dsp_dma_setup() -- Complete ---------\n");
1824 1823
1825 return 0; 1824 return 0;
1826} 1825}
@@ -1834,17 +1833,17 @@ static int dsp_dma_start(struct hda_codec *codec,
1834 unsigned int reg = 0; 1833 unsigned int reg = 0;
1835 int status = 0; 1834 int status = 0;
1836 1835
1837 snd_printdd(KERN_INFO "-- dsp_dma_start() -- Begin ---------\n"); 1836 codec_dbg(codec, "-- dsp_dma_start() -- Begin ---------\n");
1838 1837
1839 if (ovly) { 1838 if (ovly) {
1840 status = chipio_read(codec, 1839 status = chipio_read(codec,
1841 DSPDMAC_CHNLSTART_INST_OFFSET, &reg); 1840 DSPDMAC_CHNLSTART_INST_OFFSET, &reg);
1842 1841
1843 if (status < 0) { 1842 if (status < 0) {
1844 snd_printdd(KERN_ERR "read CHNLSTART reg fail\n"); 1843 codec_dbg(codec, "read CHNLSTART reg fail\n");
1845 return status; 1844 return status;
1846 } 1845 }
1847 snd_printdd(KERN_INFO "-- dsp_dma_start() Read CHNLSTART\n"); 1846 codec_dbg(codec, "-- dsp_dma_start() Read CHNLSTART\n");
1848 1847
1849 reg &= ~(DSPDMAC_CHNLSTART_EN_MASK | 1848 reg &= ~(DSPDMAC_CHNLSTART_EN_MASK |
1850 DSPDMAC_CHNLSTART_DIS_MASK); 1849 DSPDMAC_CHNLSTART_DIS_MASK);
@@ -1853,10 +1852,10 @@ static int dsp_dma_start(struct hda_codec *codec,
1853 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET, 1852 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET,
1854 reg | (1 << (dma_chan + DSPDMAC_CHNLSTART_EN_LOBIT))); 1853 reg | (1 << (dma_chan + DSPDMAC_CHNLSTART_EN_LOBIT)));
1855 if (status < 0) { 1854 if (status < 0) {
1856 snd_printdd(KERN_ERR "write CHNLSTART reg fail\n"); 1855 codec_dbg(codec, "write CHNLSTART reg fail\n");
1857 return status; 1856 return status;
1858 } 1857 }
1859 snd_printdd(KERN_INFO "-- dsp_dma_start() -- Complete ---------\n"); 1858 codec_dbg(codec, "-- dsp_dma_start() -- Complete ---------\n");
1860 1859
1861 return status; 1860 return status;
1862} 1861}
@@ -1870,17 +1869,17 @@ static int dsp_dma_stop(struct hda_codec *codec,
1870 unsigned int reg = 0; 1869 unsigned int reg = 0;
1871 int status = 0; 1870 int status = 0;
1872 1871
1873 snd_printdd(KERN_INFO "-- dsp_dma_stop() -- Begin ---------\n"); 1872 codec_dbg(codec, "-- dsp_dma_stop() -- Begin ---------\n");
1874 1873
1875 if (ovly) { 1874 if (ovly) {
1876 status = chipio_read(codec, 1875 status = chipio_read(codec,
1877 DSPDMAC_CHNLSTART_INST_OFFSET, &reg); 1876 DSPDMAC_CHNLSTART_INST_OFFSET, &reg);
1878 1877
1879 if (status < 0) { 1878 if (status < 0) {
1880 snd_printdd(KERN_ERR "read CHNLSTART reg fail\n"); 1879 codec_dbg(codec, "read CHNLSTART reg fail\n");
1881 return status; 1880 return status;
1882 } 1881 }
1883 snd_printdd(KERN_INFO "-- dsp_dma_stop() Read CHNLSTART\n"); 1882 codec_dbg(codec, "-- dsp_dma_stop() Read CHNLSTART\n");
1884 reg &= ~(DSPDMAC_CHNLSTART_EN_MASK | 1883 reg &= ~(DSPDMAC_CHNLSTART_EN_MASK |
1885 DSPDMAC_CHNLSTART_DIS_MASK); 1884 DSPDMAC_CHNLSTART_DIS_MASK);
1886 } 1885 }
@@ -1888,10 +1887,10 @@ static int dsp_dma_stop(struct hda_codec *codec,
1888 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET, 1887 status = chipio_write(codec, DSPDMAC_CHNLSTART_INST_OFFSET,
1889 reg | (1 << (dma_chan + DSPDMAC_CHNLSTART_DIS_LOBIT))); 1888 reg | (1 << (dma_chan + DSPDMAC_CHNLSTART_DIS_LOBIT)));
1890 if (status < 0) { 1889 if (status < 0) {
1891 snd_printdd(KERN_ERR "write CHNLSTART reg fail\n"); 1890 codec_dbg(codec, "write CHNLSTART reg fail\n");
1892 return status; 1891 return status;
1893 } 1892 }
1894 snd_printdd(KERN_INFO "-- dsp_dma_stop() -- Complete ---------\n"); 1893 codec_dbg(codec, "-- dsp_dma_stop() -- Complete ---------\n");
1895 1894
1896 return status; 1895 return status;
1897} 1896}
@@ -1974,17 +1973,17 @@ static int dsp_allocate_ports(struct hda_codec *codec,
1974{ 1973{
1975 int status; 1974 int status;
1976 1975
1977 snd_printdd(KERN_INFO " dsp_allocate_ports() -- begin\n"); 1976 codec_dbg(codec, " dsp_allocate_ports() -- begin\n");
1978 1977
1979 if ((rate_multi != 1) && (rate_multi != 2) && (rate_multi != 4)) { 1978 if ((rate_multi != 1) && (rate_multi != 2) && (rate_multi != 4)) {
1980 snd_printdd(KERN_ERR "bad rate multiple\n"); 1979 codec_dbg(codec, "bad rate multiple\n");
1981 return -EINVAL; 1980 return -EINVAL;
1982 } 1981 }
1983 1982
1984 status = dsp_allocate_router_ports(codec, num_chans, 1983 status = dsp_allocate_router_ports(codec, num_chans,
1985 rate_multi, 0, port_map); 1984 rate_multi, 0, port_map);
1986 1985
1987 snd_printdd(KERN_INFO " dsp_allocate_ports() -- complete\n"); 1986 codec_dbg(codec, " dsp_allocate_ports() -- complete\n");
1988 1987
1989 return status; 1988 return status;
1990} 1989}
@@ -2001,7 +2000,7 @@ static int dsp_allocate_ports_format(struct hda_codec *codec,
2001 unsigned int rate_multi = sample_rate_mul / sample_rate_div; 2000 unsigned int rate_multi = sample_rate_mul / sample_rate_div;
2002 2001
2003 if ((rate_multi != 1) && (rate_multi != 2) && (rate_multi != 4)) { 2002 if ((rate_multi != 1) && (rate_multi != 2) && (rate_multi != 4)) {
2004 snd_printdd(KERN_ERR "bad rate multiple\n"); 2003 codec_dbg(codec, "bad rate multiple\n");
2005 return -EINVAL; 2004 return -EINVAL;
2006 } 2005 }
2007 2006
@@ -2019,14 +2018,14 @@ static int dsp_free_ports(struct hda_codec *codec)
2019{ 2018{
2020 int status; 2019 int status;
2021 2020
2022 snd_printdd(KERN_INFO " dsp_free_ports() -- begin\n"); 2021 codec_dbg(codec, " dsp_free_ports() -- begin\n");
2023 2022
2024 status = dsp_free_router_ports(codec); 2023 status = dsp_free_router_ports(codec);
2025 if (status < 0) { 2024 if (status < 0) {
2026 snd_printdd(KERN_ERR "free router ports fail\n"); 2025 codec_dbg(codec, "free router ports fail\n");
2027 return status; 2026 return status;
2028 } 2027 }
2029 snd_printdd(KERN_INFO " dsp_free_ports() -- complete\n"); 2028 codec_dbg(codec, " dsp_free_ports() -- complete\n");
2030 2029
2031 return status; 2030 return status;
2032} 2031}
@@ -2092,8 +2091,6 @@ static int dma_set_state(struct dma_engine *dma, enum dma_state state)
2092{ 2091{
2093 bool cmd; 2092 bool cmd;
2094 2093
2095 snd_printdd("dma_set_state state=%d\n", state);
2096
2097 switch (state) { 2094 switch (state) {
2098 case DMA_STATE_STOP: 2095 case DMA_STATE_STOP:
2099 cmd = false; 2096 cmd = false;
@@ -2196,7 +2193,7 @@ static int dspxfr_hci_write(struct hda_codec *codec,
2196 unsigned int count; 2193 unsigned int count;
2197 2194
2198 if (fls == NULL || fls->chip_addr != g_chip_addr_magic_value) { 2195 if (fls == NULL || fls->chip_addr != g_chip_addr_magic_value) {
2199 snd_printdd(KERN_ERR "hci_write invalid params\n"); 2196 codec_dbg(codec, "hci_write invalid params\n");
2200 return -EINVAL; 2197 return -EINVAL;
2201 } 2198 }
2202 2199
@@ -2205,7 +2202,7 @@ static int dspxfr_hci_write(struct hda_codec *codec,
2205 while (count >= 2) { 2202 while (count >= 2) {
2206 status = chipio_write(codec, data[0], data[1]); 2203 status = chipio_write(codec, data[0], data[1]);
2207 if (status < 0) { 2204 if (status < 0) {
2208 snd_printdd(KERN_ERR "hci_write chipio failed\n"); 2205 codec_dbg(codec, "hci_write chipio failed\n");
2209 return status; 2206 return status;
2210 } 2207 }
2211 count -= 2; 2208 count -= 2;
@@ -2265,12 +2262,12 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2265 } 2262 }
2266 2263
2267 if (hci_write && (!fls || is_last(fls))) { 2264 if (hci_write && (!fls || is_last(fls))) {
2268 snd_printdd("hci_write\n"); 2265 codec_dbg(codec, "hci_write\n");
2269 return dspxfr_hci_write(codec, hci_write); 2266 return dspxfr_hci_write(codec, hci_write);
2270 } 2267 }
2271 2268
2272 if (fls == NULL || dma_engine == NULL || port_map_mask == 0) { 2269 if (fls == NULL || dma_engine == NULL || port_map_mask == 0) {
2273 snd_printdd("Invalid Params\n"); 2270 codec_dbg(codec, "Invalid Params\n");
2274 return -EINVAL; 2271 return -EINVAL;
2275 } 2272 }
2276 2273
@@ -2286,7 +2283,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2286 if (!UC_RANGE(chip_addx, words_to_write) && 2283 if (!UC_RANGE(chip_addx, words_to_write) &&
2287 !X_RANGE_ALL(chip_addx, words_to_write) && 2284 !X_RANGE_ALL(chip_addx, words_to_write) &&
2288 !Y_RANGE_ALL(chip_addx, words_to_write)) { 2285 !Y_RANGE_ALL(chip_addx, words_to_write)) {
2289 snd_printdd("Invalid chip_addx Params\n"); 2286 codec_dbg(codec, "Invalid chip_addx Params\n");
2290 return -EINVAL; 2287 return -EINVAL;
2291 } 2288 }
2292 2289
@@ -2296,7 +2293,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2296 buffer_addx = dma_get_buffer_addr(dma_engine); 2293 buffer_addx = dma_get_buffer_addr(dma_engine);
2297 2294
2298 if (buffer_addx == NULL) { 2295 if (buffer_addx == NULL) {
2299 snd_printdd(KERN_ERR "dma_engine buffer NULL\n"); 2296 codec_dbg(codec, "dma_engine buffer NULL\n");
2300 return -EINVAL; 2297 return -EINVAL;
2301 } 2298 }
2302 2299
@@ -2309,7 +2306,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2309 (num_chans * sample_rate_mul / sample_rate_div)); 2306 (num_chans * sample_rate_mul / sample_rate_div));
2310 2307
2311 if (hda_frame_size_words == 0) { 2308 if (hda_frame_size_words == 0) {
2312 snd_printdd(KERN_ERR "frmsz zero\n"); 2309 codec_dbg(codec, "frmsz zero\n");
2313 return -EINVAL; 2310 return -EINVAL;
2314 } 2311 }
2315 2312
@@ -2317,14 +2314,14 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2317 (unsigned int)(UC_RANGE(chip_addx, 1) ? 2314 (unsigned int)(UC_RANGE(chip_addx, 1) ?
2318 65536 : 32768)); 2315 65536 : 32768));
2319 buffer_size_words -= buffer_size_words % hda_frame_size_words; 2316 buffer_size_words -= buffer_size_words % hda_frame_size_words;
2320 snd_printdd( 2317 codec_dbg(codec,
2321 "chpadr=0x%08x frmsz=%u nchan=%u " 2318 "chpadr=0x%08x frmsz=%u nchan=%u "
2322 "rate_mul=%u div=%u bufsz=%u\n", 2319 "rate_mul=%u div=%u bufsz=%u\n",
2323 chip_addx, hda_frame_size_words, num_chans, 2320 chip_addx, hda_frame_size_words, num_chans,
2324 sample_rate_mul, sample_rate_div, buffer_size_words); 2321 sample_rate_mul, sample_rate_div, buffer_size_words);
2325 2322
2326 if (buffer_size_words < hda_frame_size_words) { 2323 if (buffer_size_words < hda_frame_size_words) {
2327 snd_printdd(KERN_ERR "dspxfr_one_seg:failed\n"); 2324 codec_dbg(codec, "dspxfr_one_seg:failed\n");
2328 return -EINVAL; 2325 return -EINVAL;
2329 } 2326 }
2330 2327
@@ -2338,7 +2335,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2338 2335
2339 while (words_to_write != 0) { 2336 while (words_to_write != 0) {
2340 run_size_words = min(buffer_size_words, words_to_write); 2337 run_size_words = min(buffer_size_words, words_to_write);
2341 snd_printdd("dspxfr (seg loop)cnt=%u rs=%u remainder=%u\n", 2338 codec_dbg(codec, "dspxfr (seg loop)cnt=%u rs=%u remainder=%u\n",
2342 words_to_write, run_size_words, remainder_words); 2339 words_to_write, run_size_words, remainder_words);
2343 dma_xfer(dma_engine, data, run_size_words*sizeof(u32)); 2340 dma_xfer(dma_engine, data, run_size_words*sizeof(u32));
2344 if (!comm_dma_setup_done) { 2341 if (!comm_dma_setup_done) {
@@ -2360,7 +2357,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2360 if (status < 0) 2357 if (status < 0)
2361 return status; 2358 return status;
2362 if (!dsp_is_dma_active(codec, dma_chan)) { 2359 if (!dsp_is_dma_active(codec, dma_chan)) {
2363 snd_printdd(KERN_ERR "dspxfr:DMA did not start\n"); 2360 codec_dbg(codec, "dspxfr:DMA did not start\n");
2364 return -EIO; 2361 return -EIO;
2365 } 2362 }
2366 status = dma_set_state(dma_engine, DMA_STATE_RUN); 2363 status = dma_set_state(dma_engine, DMA_STATE_RUN);
@@ -2392,7 +2389,7 @@ static int dspxfr_one_seg(struct hda_codec *codec,
2392 if (dma_active) 2389 if (dma_active)
2393 break; 2390 break;
2394 2391
2395 snd_printdd(KERN_INFO "+++++ DMA complete\n"); 2392 codec_dbg(codec, "+++++ DMA complete\n");
2396 dma_set_state(dma_engine, DMA_STATE_STOP); 2393 dma_set_state(dma_engine, DMA_STATE_STOP);
2397 status = dma_reset(dma_engine); 2394 status = dma_reset(dma_engine);
2398 2395
@@ -2466,7 +2463,7 @@ static int dspxfr_image(struct hda_codec *codec,
2466 hda_format, &response); 2463 hda_format, &response);
2467 2464
2468 if (status < 0) { 2465 if (status < 0) {
2469 snd_printdd(KERN_ERR "set converter format fail\n"); 2466 codec_dbg(codec, "set converter format fail\n");
2470 goto exit; 2467 goto exit;
2471 } 2468 }
2472 2469
@@ -2481,7 +2478,7 @@ static int dspxfr_image(struct hda_codec *codec,
2481 if (ovly) { 2478 if (ovly) {
2482 status = dspio_alloc_dma_chan(codec, &dma_chan); 2479 status = dspio_alloc_dma_chan(codec, &dma_chan);
2483 if (status < 0) { 2480 if (status < 0) {
2484 snd_printdd(KERN_ERR "alloc dmachan fail\n"); 2481 codec_dbg(codec, "alloc dmachan fail\n");
2485 dma_chan = INVALID_DMA_CHANNEL; 2482 dma_chan = INVALID_DMA_CHANNEL;
2486 goto exit; 2483 goto exit;
2487 } 2484 }
@@ -2491,7 +2488,7 @@ static int dspxfr_image(struct hda_codec *codec,
2491 status = dsp_allocate_ports_format(codec, hda_format, 2488 status = dsp_allocate_ports_format(codec, hda_format,
2492 &port_map_mask); 2489 &port_map_mask);
2493 if (status < 0) { 2490 if (status < 0) {
2494 snd_printdd(KERN_ERR "alloc ports fail\n"); 2491 codec_dbg(codec, "alloc ports fail\n");
2495 goto exit; 2492 goto exit;
2496 } 2493 }
2497 2494
@@ -2499,13 +2496,13 @@ static int dspxfr_image(struct hda_codec *codec,
2499 status = codec_set_converter_stream_channel(codec, 2496 status = codec_set_converter_stream_channel(codec,
2500 WIDGET_CHIP_CTRL, stream_id, 0, &response); 2497 WIDGET_CHIP_CTRL, stream_id, 0, &response);
2501 if (status < 0) { 2498 if (status < 0) {
2502 snd_printdd(KERN_ERR "set stream chan fail\n"); 2499 codec_dbg(codec, "set stream chan fail\n");
2503 goto exit; 2500 goto exit;
2504 } 2501 }
2505 2502
2506 while ((fls_data != NULL) && !is_last(fls_data)) { 2503 while ((fls_data != NULL) && !is_last(fls_data)) {
2507 if (!is_valid(fls_data)) { 2504 if (!is_valid(fls_data)) {
2508 snd_printdd(KERN_ERR "FLS check fail\n"); 2505 codec_dbg(codec, "FLS check fail\n");
2509 status = -EINVAL; 2506 status = -EINVAL;
2510 goto exit; 2507 goto exit;
2511 } 2508 }
@@ -2548,7 +2545,7 @@ exit:
2548 */ 2545 */
2549static void dspload_post_setup(struct hda_codec *codec) 2546static void dspload_post_setup(struct hda_codec *codec)
2550{ 2547{
2551 snd_printdd(KERN_INFO "---- dspload_post_setup ------\n"); 2548 codec_dbg(codec, "---- dspload_post_setup ------\n");
2552 2549
2553 /*set DSP speaker to 2.0 configuration*/ 2550 /*set DSP speaker to 2.0 configuration*/
2554 chipio_write(codec, XRAM_XRAM_INST_OFFSET(0x18), 0x08080080); 2551 chipio_write(codec, XRAM_XRAM_INST_OFFSET(0x18), 0x08080080);
@@ -2586,7 +2583,7 @@ static int dspload_image(struct hda_codec *codec,
2586 unsigned int sample_rate; 2583 unsigned int sample_rate;
2587 unsigned short channels; 2584 unsigned short channels;
2588 2585
2589 snd_printdd(KERN_INFO "---- dspload_image begin ------\n"); 2586 codec_dbg(codec, "---- dspload_image begin ------\n");
2590 if (router_chans == 0) { 2587 if (router_chans == 0) {
2591 if (!ovly) 2588 if (!ovly)
2592 router_chans = DMA_TRANSFER_FRAME_SIZE_NWORDS; 2589 router_chans = DMA_TRANSFER_FRAME_SIZE_NWORDS;
@@ -2603,27 +2600,27 @@ static int dspload_image(struct hda_codec *codec,
2603 } 2600 }
2604 2601
2605 do { 2602 do {
2606 snd_printdd(KERN_INFO "Ready to program DMA\n"); 2603 codec_dbg(codec, "Ready to program DMA\n");
2607 if (!ovly) 2604 if (!ovly)
2608 status = dsp_reset(codec); 2605 status = dsp_reset(codec);
2609 2606
2610 if (status < 0) 2607 if (status < 0)
2611 break; 2608 break;
2612 2609
2613 snd_printdd(KERN_INFO "dsp_reset() complete\n"); 2610 codec_dbg(codec, "dsp_reset() complete\n");
2614 status = dspxfr_image(codec, fls, reloc, sample_rate, channels, 2611 status = dspxfr_image(codec, fls, reloc, sample_rate, channels,
2615 ovly); 2612 ovly);
2616 2613
2617 if (status < 0) 2614 if (status < 0)
2618 break; 2615 break;
2619 2616
2620 snd_printdd(KERN_INFO "dspxfr_image() complete\n"); 2617 codec_dbg(codec, "dspxfr_image() complete\n");
2621 if (autostart && !ovly) { 2618 if (autostart && !ovly) {
2622 dspload_post_setup(codec); 2619 dspload_post_setup(codec);
2623 status = dsp_set_run_state(codec); 2620 status = dsp_set_run_state(codec);
2624 } 2621 }
2625 2622
2626 snd_printdd(KERN_INFO "LOAD FINISHED\n"); 2623 codec_dbg(codec, "LOAD FINISHED\n");
2627 } while (0); 2624 } while (0);
2628 2625
2629 return status; 2626 return status;
@@ -3132,7 +3129,7 @@ static int ca0132_select_out(struct hda_codec *codec)
3132 unsigned int tmp; 3129 unsigned int tmp;
3133 int err; 3130 int err;
3134 3131
3135 snd_printdd(KERN_INFO "ca0132_select_out\n"); 3132 codec_dbg(codec, "ca0132_select_out\n");
3136 3133
3137 snd_hda_power_up(codec); 3134 snd_hda_power_up(codec);
3138 3135
@@ -3150,7 +3147,7 @@ static int ca0132_select_out(struct hda_codec *codec)
3150 spec->cur_out_type = SPEAKER_OUT; 3147 spec->cur_out_type = SPEAKER_OUT;
3151 3148
3152 if (spec->cur_out_type == SPEAKER_OUT) { 3149 if (spec->cur_out_type == SPEAKER_OUT) {
3153 snd_printdd(KERN_INFO "ca0132_select_out speaker\n"); 3150 codec_dbg(codec, "ca0132_select_out speaker\n");
3154 /*speaker out config*/ 3151 /*speaker out config*/
3155 tmp = FLOAT_ONE; 3152 tmp = FLOAT_ONE;
3156 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); 3153 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp);
@@ -3183,7 +3180,7 @@ static int ca0132_select_out(struct hda_codec *codec)
3183 snd_hda_set_pin_ctl(codec, spec->out_pins[0], 3180 snd_hda_set_pin_ctl(codec, spec->out_pins[0],
3184 pin_ctl | PIN_OUT); 3181 pin_ctl | PIN_OUT);
3185 } else { 3182 } else {
3186 snd_printdd(KERN_INFO "ca0132_select_out hp\n"); 3183 codec_dbg(codec, "ca0132_select_out hp\n");
3187 /*headphone out config*/ 3184 /*headphone out config*/
3188 tmp = FLOAT_ZERO; 3185 tmp = FLOAT_ZERO;
3189 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp); 3186 err = dspio_set_uint_param(codec, 0x80, 0x04, tmp);
@@ -3288,7 +3285,7 @@ static int ca0132_select_mic(struct hda_codec *codec)
3288 int jack_present; 3285 int jack_present;
3289 int auto_jack; 3286 int auto_jack;
3290 3287
3291 snd_printdd(KERN_INFO "ca0132_select_mic\n"); 3288 codec_dbg(codec, "ca0132_select_mic\n");
3292 3289
3293 snd_hda_power_up(codec); 3290 snd_hda_power_up(codec);
3294 3291
@@ -3410,7 +3407,7 @@ static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val)
3410 val = 0; 3407 val = 0;
3411 } 3408 }
3412 3409
3413 snd_printdd(KERN_INFO "ca0132_effect_set: nid=0x%x, val=%ld\n", 3410 codec_dbg(codec, "ca0132_effect_set: nid=0x%x, val=%ld\n",
3414 nid, val); 3411 nid, val);
3415 3412
3416 on = (val == 0) ? FLOAT_ZERO : FLOAT_ONE; 3413 on = (val == 0) ? FLOAT_ZERO : FLOAT_ONE;
@@ -3432,7 +3429,7 @@ static int ca0132_pe_switch_set(struct hda_codec *codec)
3432 hda_nid_t nid; 3429 hda_nid_t nid;
3433 int i, ret = 0; 3430 int i, ret = 0;
3434 3431
3435 snd_printdd(KERN_INFO "ca0132_pe_switch_set: val=%ld\n", 3432 codec_dbg(codec, "ca0132_pe_switch_set: val=%ld\n",
3436 spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]); 3433 spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]);
3437 3434
3438 i = OUT_EFFECT_START_NID - EFFECT_START_NID; 3435 i = OUT_EFFECT_START_NID - EFFECT_START_NID;
@@ -3478,7 +3475,7 @@ static int ca0132_cvoice_switch_set(struct hda_codec *codec)
3478 int i, ret = 0; 3475 int i, ret = 0;
3479 unsigned int oldval; 3476 unsigned int oldval;
3480 3477
3481 snd_printdd(KERN_INFO "ca0132_cvoice_switch_set: val=%ld\n", 3478 codec_dbg(codec, "ca0132_cvoice_switch_set: val=%ld\n",
3482 spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID]); 3479 spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID]);
3483 3480
3484 i = IN_EFFECT_START_NID - EFFECT_START_NID; 3481 i = IN_EFFECT_START_NID - EFFECT_START_NID;
@@ -3608,7 +3605,7 @@ static int ca0132_voicefx_put(struct snd_kcontrol *kcontrol,
3608 if (sel >= items) 3605 if (sel >= items)
3609 return 0; 3606 return 0;
3610 3607
3611 snd_printdd(KERN_INFO "ca0132_voicefx_put: sel=%d, preset=%s\n", 3608 codec_dbg(codec, "ca0132_voicefx_put: sel=%d, preset=%s\n",
3612 sel, ca0132_voicefx_presets[sel].name); 3609 sel, ca0132_voicefx_presets[sel].name);
3613 3610
3614 /* 3611 /*
@@ -3679,7 +3676,7 @@ static int ca0132_switch_put(struct snd_kcontrol *kcontrol,
3679 long *valp = ucontrol->value.integer.value; 3676 long *valp = ucontrol->value.integer.value;
3680 int changed = 1; 3677 int changed = 1;
3681 3678
3682 snd_printdd(KERN_INFO "ca0132_switch_put: nid=0x%x, val=%ld\n", 3679 codec_dbg(codec, "ca0132_switch_put: nid=0x%x, val=%ld\n",
3683 nid, *valp); 3680 nid, *valp);
3684 3681
3685 snd_hda_power_up(codec); 3682 snd_hda_power_up(codec);
@@ -4142,7 +4139,7 @@ static void ca0132_set_dmic(struct hda_codec *codec, int enable)
4142 u8 val; 4139 u8 val;
4143 unsigned int oldval; 4140 unsigned int oldval;
4144 4141
4145 snd_printdd(KERN_INFO "ca0132_set_dmic: enable=%d\n", enable); 4142 codec_dbg(codec, "ca0132_set_dmic: enable=%d\n", enable);
4146 4143
4147 oldval = stop_mic1(codec); 4144 oldval = stop_mic1(codec);
4148 ca0132_set_vipsource(codec, 0); 4145 ca0132_set_vipsource(codec, 0);
@@ -4250,7 +4247,7 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec)
4250 int i; 4247 int i;
4251 hda_nid_t nid; 4248 hda_nid_t nid;
4252 4249
4253 snd_printdd(KERN_INFO "ca0132_refresh_widget_caps.\n"); 4250 codec_dbg(codec, "ca0132_refresh_widget_caps.\n");
4254 nid = codec->start_nid; 4251 nid = codec->start_nid;
4255 for (i = 0; i < codec->num_nodes; i++, nid++) 4252 for (i = 0; i < codec->num_nodes; i++, nid++)
4256 codec->wcaps[i] = snd_hda_param_read(codec, nid, 4253 codec->wcaps[i] = snd_hda_param_read(codec, nid,
@@ -4394,7 +4391,7 @@ static void ca0132_process_dsp_response(struct hda_codec *codec)
4394{ 4391{
4395 struct ca0132_spec *spec = codec->spec; 4392 struct ca0132_spec *spec = codec->spec;
4396 4393
4397 snd_printdd(KERN_INFO "ca0132_process_dsp_response\n"); 4394 codec_dbg(codec, "ca0132_process_dsp_response\n");
4398 if (spec->wait_scp) { 4395 if (spec->wait_scp) {
4399 if (dspio_get_response_data(codec) >= 0) 4396 if (dspio_get_response_data(codec) >= 0)
4400 spec->wait_scp = 0; 4397 spec->wait_scp = 0;
@@ -4413,7 +4410,7 @@ static void ca0132_unsol_event(struct hda_codec *codec, unsigned int res)
4413 res = snd_hda_jack_get_action(codec, 4410 res = snd_hda_jack_get_action(codec,
4414 (res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f); 4411 (res >> AC_UNSOL_RES_TAG_SHIFT) & 0x3f);
4415 4412
4416 snd_printdd(KERN_INFO "snd_hda_jack_get_action: 0x%x\n", res); 4413 codec_dbg(codec, "snd_hda_jack_get_action: 0x%x\n", res);
4417 4414
4418 switch (res) { 4415 switch (res) {
4419 case UNSOL_TAG_HP: 4416 case UNSOL_TAG_HP:
@@ -4658,7 +4655,7 @@ static int patch_ca0132(struct hda_codec *codec)
4658 struct ca0132_spec *spec; 4655 struct ca0132_spec *spec;
4659 int err; 4656 int err;
4660 4657
4661 snd_printdd("patch_ca0132\n"); 4658 codec_dbg(codec, "patch_ca0132\n");
4662 4659
4663 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4660 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4664 if (!spec) 4661 if (!spec)
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index fc492ac24caa..387f0b551889 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -20,7 +20,6 @@
20 20
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/pci.h>
24#include <linux/module.h> 23#include <linux/module.h>
25#include <sound/core.h> 24#include <sound/core.h>
26#include <sound/tlv.h> 25#include <sound/tlv.h>
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index 9c6ce73b03c5..061ea5965dd5 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -23,7 +23,6 @@
23 23
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <sound/core.h> 27#include <sound/core.h>
29#include "hda_codec.h" 28#include "hda_codec.h"
@@ -32,6 +31,9 @@
32#include "hda_jack.h" 31#include "hda_jack.h"
33#include "hda_generic.h" 32#include "hda_generic.h"
34 33
34#undef ENABLE_CMI_STATIC_QUIRKS
35
36#ifdef ENABLE_CMI_STATIC_QUIRKS
35#define NUM_PINS 11 37#define NUM_PINS 11
36 38
37 39
@@ -45,10 +47,12 @@ enum {
45 CMI_AUTO, /* let driver guess it */ 47 CMI_AUTO, /* let driver guess it */
46 CMI_MODELS 48 CMI_MODELS
47}; 49};
50#endif /* ENABLE_CMI_STATIC_QUIRKS */
48 51
49struct cmi_spec { 52struct cmi_spec {
50 struct hda_gen_spec gen; 53 struct hda_gen_spec gen;
51 54
55#ifdef ENABLE_CMI_STATIC_QUIRKS
52 /* below are only for static models */ 56 /* below are only for static models */
53 57
54 int board_config; 58 int board_config;
@@ -81,8 +85,10 @@ struct cmi_spec {
81 85
82 /* multichannel pins */ 86 /* multichannel pins */
83 struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */ 87 struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */
88#endif /* ENABLE_CMI_STATIC_QUIRKS */
84}; 89};
85 90
91#ifdef ENABLE_CMI_STATIC_QUIRKS
86/* 92/*
87 * input MUX 93 * input MUX
88 */ 94 */
@@ -566,6 +572,7 @@ static const struct hda_codec_ops cmi9880_patch_ops = {
566 .init = cmi9880_init, 572 .init = cmi9880_init,
567 .free = cmi9880_free, 573 .free = cmi9880_free,
568}; 574};
575#endif /* ENABLE_CMI_STATIC_QUIRKS */
569 576
570/* 577/*
571 * stuff for auto-parser 578 * stuff for auto-parser
@@ -588,15 +595,20 @@ static int cmi_parse_auto_config(struct hda_codec *codec)
588 595
589 err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0); 596 err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
590 if (err < 0) 597 if (err < 0)
591 return err; 598 goto error;
592 err = snd_hda_gen_parse_auto_config(codec, cfg); 599 err = snd_hda_gen_parse_auto_config(codec, cfg);
593 if (err < 0) 600 if (err < 0)
594 return err; 601 goto error;
595 602
596 codec->patch_ops = cmi_auto_patch_ops; 603 codec->patch_ops = cmi_auto_patch_ops;
597 return 0; 604 return 0;
605
606 error:
607 snd_hda_gen_free(codec);
608 return err;
598} 609}
599 610
611
600static int patch_cmi9880(struct hda_codec *codec) 612static int patch_cmi9880(struct hda_codec *codec)
601{ 613{
602 struct cmi_spec *spec; 614 struct cmi_spec *spec;
@@ -606,23 +618,18 @@ static int patch_cmi9880(struct hda_codec *codec)
606 return -ENOMEM; 618 return -ENOMEM;
607 619
608 codec->spec = spec; 620 codec->spec = spec;
621#ifdef ENABLE_CMI_STATIC_QUIRKS
609 spec->board_config = snd_hda_check_board_config(codec, CMI_MODELS, 622 spec->board_config = snd_hda_check_board_config(codec, CMI_MODELS,
610 cmi9880_models, 623 cmi9880_models,
611 cmi9880_cfg_tbl); 624 cmi9880_cfg_tbl);
612 if (spec->board_config < 0) { 625 if (spec->board_config < 0) {
613 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 626 codec_dbg(codec, "%s: BIOS auto-probing.\n",
614 codec->chip_name); 627 codec->chip_name);
615 spec->board_config = CMI_AUTO; /* try everything */ 628 spec->board_config = CMI_AUTO; /* try everything */
616 } 629 }
617 630
618 if (spec->board_config == CMI_AUTO) { 631 if (spec->board_config == CMI_AUTO)
619 int err = cmi_parse_auto_config(codec); 632 return cmi_parse_auto_config(codec);
620 if (err < 0) {
621 snd_hda_gen_free(codec);
622 return err;
623 }
624 return 0;
625 }
626 633
627 /* copy default DAC NIDs */ 634 /* copy default DAC NIDs */
628 memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids)); 635 memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids));
@@ -669,6 +676,9 @@ static int patch_cmi9880(struct hda_codec *codec)
669 codec->patch_ops = cmi9880_patch_ops; 676 codec->patch_ops = cmi9880_patch_ops;
670 677
671 return 0; 678 return 0;
679#else
680 return cmi_parse_auto_config(codec);
681#endif
672} 682}
673 683
674/* 684/*
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index bcf91bea3317..1dc7e974f3b1 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -23,7 +23,6 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/pci.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <sound/core.h> 27#include <sound/core.h>
29#include <sound/jack.h> 28#include <sound/jack.h>
@@ -35,7 +34,7 @@
35#include "hda_jack.h" 34#include "hda_jack.h"
36#include "hda_generic.h" 35#include "hda_generic.h"
37 36
38#define ENABLE_CXT_STATIC_QUIRKS 37#undef ENABLE_CXT_STATIC_QUIRKS
39 38
40#define CXT_PIN_DIR_IN 0x00 39#define CXT_PIN_DIR_IN 0x00
41#define CXT_PIN_DIR_OUT 0x01 40#define CXT_PIN_DIR_OUT 0x01
@@ -68,6 +67,12 @@ struct conexant_spec {
68 67
69 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */ 68 unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
70 69
70 /* OPLC XO specific */
71 bool recording;
72 bool dc_enable;
73 unsigned int dc_input_bias; /* offset into olpc_xo_dc_bias */
74 struct nid_path *dc_mode_path;
75
71#ifdef ENABLE_CXT_STATIC_QUIRKS 76#ifdef ENABLE_CXT_STATIC_QUIRKS
72 const struct snd_kcontrol_new *mixers[5]; 77 const struct snd_kcontrol_new *mixers[5];
73 int num_mixers; 78 int num_mixers;
@@ -123,19 +128,6 @@ struct conexant_spec {
123 unsigned int hp_laptop:1; 128 unsigned int hp_laptop:1;
124 unsigned int asus:1; 129 unsigned int asus:1;
125 130
126 unsigned int ext_mic_present;
127 unsigned int recording;
128 void (*capture_prepare)(struct hda_codec *codec);
129 void (*capture_cleanup)(struct hda_codec *codec);
130
131 /* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
132 * through the microphone jack.
133 * When the user enables this through a mixer switch, both internal and
134 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
135 * we also allow the bias to be configured through a separate mixer
136 * control. */
137 unsigned int dc_enable;
138 unsigned int dc_input_bias; /* offset into cxt5066_olpc_dc_bias */
139 unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */ 131 unsigned int mic_boost; /* offset into cxt5066_analog_mic_boost */
140#endif /* ENABLE_CXT_STATIC_QUIRKS */ 132#endif /* ENABLE_CXT_STATIC_QUIRKS */
141}; 133};
@@ -253,8 +245,6 @@ static int conexant_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
253 struct snd_pcm_substream *substream) 245 struct snd_pcm_substream *substream)
254{ 246{
255 struct conexant_spec *spec = codec->spec; 247 struct conexant_spec *spec = codec->spec;
256 if (spec->capture_prepare)
257 spec->capture_prepare(codec);
258 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 248 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
259 stream_tag, 0, format); 249 stream_tag, 0, format);
260 return 0; 250 return 0;
@@ -266,8 +256,6 @@ static int conexant_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
266{ 256{
267 struct conexant_spec *spec = codec->spec; 257 struct conexant_spec *spec = codec->spec;
268 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]); 258 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
269 if (spec->capture_cleanup)
270 spec->capture_cleanup(codec);
271 return 0; 259 return 0;
272} 260}
273 261
@@ -457,9 +445,7 @@ static int conexant_init(struct hda_codec *codec)
457 445
458static void conexant_free(struct hda_codec *codec) 446static void conexant_free(struct hda_codec *codec)
459{ 447{
460 struct conexant_spec *spec = codec->spec; 448 kfree(codec->spec);
461 snd_hda_detach_beep_device(codec);
462 kfree(spec);
463} 449}
464 450
465static const struct snd_kcontrol_new cxt_capture_mixers[] = { 451static const struct snd_kcontrol_new cxt_capture_mixers[] = {
@@ -673,14 +659,6 @@ static const struct hda_input_mux cxt5045_capture_source_benq = {
673 } 659 }
674}; 660};
675 661
676static const struct hda_input_mux cxt5045_capture_source_hp530 = {
677 .num_items = 2,
678 .items = {
679 { "Mic", 0x1 },
680 { "Internal Mic", 0x2 },
681 }
682};
683
684/* turn on/off EAPD (+ mute HP) as a master switch */ 662/* turn on/off EAPD (+ mute HP) as a master switch */
685static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol, 663static int cxt5045_hp_master_sw_put(struct snd_kcontrol *kcontrol,
686 struct snd_ctl_elem_value *ucontrol) 664 struct snd_ctl_elem_value *ucontrol)
@@ -796,28 +774,6 @@ static const struct snd_kcontrol_new cxt5045_benq_mixers[] = {
796 {} 774 {}
797}; 775};
798 776
799static const struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
800 HDA_CODEC_VOLUME("Capture Volume", 0x1a, 0x00, HDA_INPUT),
801 HDA_CODEC_MUTE("Capture Switch", 0x1a, 0x0, HDA_INPUT),
802 HDA_CODEC_VOLUME("PCM Playback Volume", 0x17, 0x0, HDA_INPUT),
803 HDA_CODEC_MUTE("PCM Playback Switch", 0x17, 0x0, HDA_INPUT),
804 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0x2, HDA_INPUT),
805 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0x2, HDA_INPUT),
806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x17, 0x1, HDA_INPUT),
807 HDA_CODEC_MUTE("Mic Playback Switch", 0x17, 0x1, HDA_INPUT),
808 HDA_BIND_VOL("Master Playback Volume", &cxt5045_hp_bind_master_vol),
809 {
810 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
811 .name = "Master Playback Switch",
812 .info = cxt_eapd_info,
813 .get = cxt_eapd_get,
814 .put = cxt5045_hp_master_sw_put,
815 .private_value = 0x10,
816 },
817
818 {}
819};
820
821static const struct hda_verb cxt5045_init_verbs[] = { 777static const struct hda_verb cxt5045_init_verbs[] = {
822 /* Line in, Mic */ 778 /* Line in, Mic */
823 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 }, 779 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_80 },
@@ -1000,7 +956,6 @@ enum {
1000 CXT5045_LAPTOP_MICSENSE, 956 CXT5045_LAPTOP_MICSENSE,
1001 CXT5045_LAPTOP_HPMICSENSE, 957 CXT5045_LAPTOP_HPMICSENSE,
1002 CXT5045_BENQ, 958 CXT5045_BENQ,
1003 CXT5045_LAPTOP_HP530,
1004#ifdef CONFIG_SND_DEBUG 959#ifdef CONFIG_SND_DEBUG
1005 CXT5045_TEST, 960 CXT5045_TEST,
1006#endif 961#endif
@@ -1013,7 +968,6 @@ static const char * const cxt5045_models[CXT5045_MODELS] = {
1013 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense", 968 [CXT5045_LAPTOP_MICSENSE] = "laptop-micsense",
1014 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense", 969 [CXT5045_LAPTOP_HPMICSENSE] = "laptop-hpmicsense",
1015 [CXT5045_BENQ] = "benq", 970 [CXT5045_BENQ] = "benq",
1016 [CXT5045_LAPTOP_HP530] = "laptop-hp530",
1017#ifdef CONFIG_SND_DEBUG 971#ifdef CONFIG_SND_DEBUG
1018 [CXT5045_TEST] = "test", 972 [CXT5045_TEST] = "test",
1019#endif 973#endif
@@ -1021,8 +975,6 @@ static const char * const cxt5045_models[CXT5045_MODELS] = {
1021}; 975};
1022 976
1023static const struct snd_pci_quirk cxt5045_cfg_tbl[] = { 977static const struct snd_pci_quirk cxt5045_cfg_tbl[] = {
1024 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
1025 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
1026 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 978 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
1027 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 979 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
1028 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE), 980 SND_PCI_QUIRK(0x1734, 0x10cb, "Fujitsu Si3515", CXT5045_LAPTOP_HPMICSENSE),
@@ -1113,14 +1065,6 @@ static int patch_cxt5045(struct hda_codec *codec)
1113 spec->num_mixers = 2; 1065 spec->num_mixers = 2;
1114 codec->patch_ops.init = cxt5045_init; 1066 codec->patch_ops.init = cxt5045_init;
1115 break; 1067 break;
1116 case CXT5045_LAPTOP_HP530:
1117 codec->patch_ops.unsol_event = cxt5045_hp_unsol_event;
1118 spec->input_mux = &cxt5045_capture_source_hp530;
1119 spec->num_init_verbs = 2;
1120 spec->init_verbs[1] = cxt5045_hp_sense_init_verbs;
1121 spec->mixers[0] = cxt5045_mixers_hp530;
1122 codec->patch_ops.init = cxt5045_init;
1123 break;
1124#ifdef CONFIG_SND_DEBUG 1068#ifdef CONFIG_SND_DEBUG
1125 case CXT5045_TEST: 1069 case CXT5045_TEST:
1126 spec->input_mux = &cxt5045_test_capture_source; 1070 spec->input_mux = &cxt5045_test_capture_source;
@@ -1940,11 +1884,6 @@ static const hda_nid_t cxt5066_adc_nids[3] = { 0x14, 0x15, 0x16 };
1940static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 }; 1884static const hda_nid_t cxt5066_capsrc_nids[1] = { 0x17 };
1941static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 }; 1885static const hda_nid_t cxt5066_digout_pin_nids[2] = { 0x20, 0x22 };
1942 1886
1943/* OLPC's microphone port is DC coupled for use with external sensors,
1944 * therefore we use a 50% mic bias in order to center the input signal with
1945 * the DC input range of the codec. */
1946#define CXT5066_OLPC_EXT_MIC_BIAS PIN_VREF50
1947
1948static const struct hda_channel_mode cxt5066_modes[1] = { 1887static const struct hda_channel_mode cxt5066_modes[1] = {
1949 { 2, NULL }, 1888 { 2, NULL },
1950}; 1889};
@@ -1959,7 +1898,8 @@ static void cxt5066_update_speaker(struct hda_codec *codec)
1959 struct conexant_spec *spec = codec->spec; 1898 struct conexant_spec *spec = codec->spec;
1960 unsigned int pinctl; 1899 unsigned int pinctl;
1961 1900
1962 snd_printdd("CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n", 1901 codec_dbg(codec,
1902 "CXT5066: update speaker, hp_present=%d, cur_eapd=%d\n",
1963 spec->hp_present, spec->cur_eapd); 1903 spec->hp_present, spec->cur_eapd);
1964 1904
1965 /* Port A (HP) */ 1905 /* Port A (HP) */
@@ -1997,88 +1937,6 @@ static int cxt5066_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1997 return 1; 1937 return 1;
1998} 1938}
1999 1939
2000static const struct hda_input_mux cxt5066_olpc_dc_bias = {
2001 .num_items = 3,
2002 .items = {
2003 { "Off", PIN_IN },
2004 { "50%", PIN_VREF50 },
2005 { "80%", PIN_VREF80 },
2006 },
2007};
2008
2009static int cxt5066_set_olpc_dc_bias(struct hda_codec *codec)
2010{
2011 struct conexant_spec *spec = codec->spec;
2012 /* Even though port F is the DC input, the bias is controlled on port B.
2013 * we also leave that port as an active input (but unselected) in DC mode
2014 * just in case that is necessary to make the bias setting take effect. */
2015 return snd_hda_set_pin_ctl_cache(codec, 0x1a,
2016 cxt5066_olpc_dc_bias.items[spec->dc_input_bias].index);
2017}
2018
2019/* OLPC defers mic widget control until when capture is started because the
2020 * microphone LED comes on as soon as these settings are put in place. if we
2021 * did this before recording, it would give the false indication that recording
2022 * is happening when it is not. */
2023static void cxt5066_olpc_select_mic(struct hda_codec *codec)
2024{
2025 struct conexant_spec *spec = codec->spec;
2026 if (!spec->recording)
2027 return;
2028
2029 if (spec->dc_enable) {
2030 /* in DC mode we ignore presence detection and just use the jack
2031 * through our special DC port */
2032 const struct hda_verb enable_dc_mode[] = {
2033 /* disble internal mic, port C */
2034 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2035
2036 /* enable DC capture, port F */
2037 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2038 {},
2039 };
2040
2041 snd_hda_sequence_write(codec, enable_dc_mode);
2042 /* port B input disabled (and bias set) through the following call */
2043 cxt5066_set_olpc_dc_bias(codec);
2044 return;
2045 }
2046
2047 /* disable DC (port F) */
2048 snd_hda_set_pin_ctl(codec, 0x1e, 0);
2049
2050 /* external mic, port B */
2051 snd_hda_set_pin_ctl(codec, 0x1a,
2052 spec->ext_mic_present ? CXT5066_OLPC_EXT_MIC_BIAS : 0);
2053
2054 /* internal mic, port C */
2055 snd_hda_set_pin_ctl(codec, 0x1b,
2056 spec->ext_mic_present ? 0 : PIN_VREF80);
2057}
2058
2059/* toggle input of built-in and mic jack appropriately */
2060static void cxt5066_olpc_automic(struct hda_codec *codec)
2061{
2062 struct conexant_spec *spec = codec->spec;
2063 unsigned int present;
2064
2065 if (spec->dc_enable) /* don't do presence detection in DC mode */
2066 return;
2067
2068 present = snd_hda_codec_read(codec, 0x1a, 0,
2069 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
2070 if (present)
2071 snd_printdd("CXT5066: external microphone detected\n");
2072 else
2073 snd_printdd("CXT5066: external microphone absent\n");
2074
2075 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
2076 present ? 0 : 1);
2077 spec->ext_mic_present = !!present;
2078
2079 cxt5066_olpc_select_mic(codec);
2080}
2081
2082/* toggle input of built-in digital mic and mic jack appropriately */ 1940/* toggle input of built-in digital mic and mic jack appropriately */
2083static void cxt5066_vostro_automic(struct hda_codec *codec) 1941static void cxt5066_vostro_automic(struct hda_codec *codec)
2084{ 1942{
@@ -2110,10 +1968,10 @@ static void cxt5066_vostro_automic(struct hda_codec *codec)
2110 1968
2111 present = snd_hda_jack_detect(codec, 0x1a); 1969 present = snd_hda_jack_detect(codec, 0x1a);
2112 if (present) { 1970 if (present) {
2113 snd_printdd("CXT5066: external microphone detected\n"); 1971 codec_dbg(codec, "CXT5066: external microphone detected\n");
2114 snd_hda_sequence_write(codec, ext_mic_present); 1972 snd_hda_sequence_write(codec, ext_mic_present);
2115 } else { 1973 } else {
2116 snd_printdd("CXT5066: external microphone absent\n"); 1974 codec_dbg(codec, "CXT5066: external microphone absent\n");
2117 snd_hda_sequence_write(codec, ext_mic_absent); 1975 snd_hda_sequence_write(codec, ext_mic_absent);
2118 } 1976 }
2119} 1977}
@@ -2138,10 +1996,10 @@ static void cxt5066_ideapad_automic(struct hda_codec *codec)
2138 1996
2139 present = snd_hda_jack_detect(codec, 0x1b); 1997 present = snd_hda_jack_detect(codec, 0x1b);
2140 if (present) { 1998 if (present) {
2141 snd_printdd("CXT5066: external microphone detected\n"); 1999 codec_dbg(codec, "CXT5066: external microphone detected\n");
2142 snd_hda_sequence_write(codec, ext_mic_present); 2000 snd_hda_sequence_write(codec, ext_mic_present);
2143 } else { 2001 } else {
2144 snd_printdd("CXT5066: external microphone absent\n"); 2002 codec_dbg(codec, "CXT5066: external microphone absent\n");
2145 snd_hda_sequence_write(codec, ext_mic_absent); 2003 snd_hda_sequence_write(codec, ext_mic_absent);
2146 } 2004 }
2147} 2005}
@@ -2153,7 +2011,7 @@ static void cxt5066_asus_automic(struct hda_codec *codec)
2153 unsigned int present; 2011 unsigned int present;
2154 2012
2155 present = snd_hda_jack_detect(codec, 0x1b); 2013 present = snd_hda_jack_detect(codec, 0x1b);
2156 snd_printdd("CXT5066: external microphone present=%d\n", present); 2014 codec_dbg(codec, "CXT5066: external microphone present=%d\n", present);
2157 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2015 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
2158 present ? 1 : 0); 2016 present ? 1 : 0);
2159} 2017}
@@ -2165,7 +2023,7 @@ static void cxt5066_hp_laptop_automic(struct hda_codec *codec)
2165 unsigned int present; 2023 unsigned int present;
2166 2024
2167 present = snd_hda_jack_detect(codec, 0x1b); 2025 present = snd_hda_jack_detect(codec, 0x1b);
2168 snd_printdd("CXT5066: external microphone present=%d\n", present); 2026 codec_dbg(codec, "CXT5066: external microphone present=%d\n", present);
2169 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL, 2027 snd_hda_codec_write(codec, 0x17, 0, AC_VERB_SET_CONNECT_SEL,
2170 present ? 1 : 3); 2028 present ? 1 : 3);
2171} 2029}
@@ -2204,13 +2062,13 @@ static void cxt5066_thinkpad_automic(struct hda_codec *codec)
2204 ext_present = snd_hda_jack_detect(codec, 0x1b); 2062 ext_present = snd_hda_jack_detect(codec, 0x1b);
2205 dock_present = snd_hda_jack_detect(codec, 0x1a); 2063 dock_present = snd_hda_jack_detect(codec, 0x1a);
2206 if (ext_present) { 2064 if (ext_present) {
2207 snd_printdd("CXT5066: external microphone detected\n"); 2065 codec_dbg(codec, "CXT5066: external microphone detected\n");
2208 snd_hda_sequence_write(codec, ext_mic_present); 2066 snd_hda_sequence_write(codec, ext_mic_present);
2209 } else if (dock_present) { 2067 } else if (dock_present) {
2210 snd_printdd("CXT5066: dock microphone detected\n"); 2068 codec_dbg(codec, "CXT5066: dock microphone detected\n");
2211 snd_hda_sequence_write(codec, dock_mic_present); 2069 snd_hda_sequence_write(codec, dock_mic_present);
2212 } else { 2070 } else {
2213 snd_printdd("CXT5066: external microphone absent\n"); 2071 codec_dbg(codec, "CXT5066: external microphone absent\n");
2214 snd_hda_sequence_write(codec, ext_mic_absent); 2072 snd_hda_sequence_write(codec, ext_mic_absent);
2215 } 2073 }
2216} 2074}
@@ -2229,7 +2087,7 @@ static void cxt5066_hp_automute(struct hda_codec *codec)
2229 2087
2230 spec->hp_present = portA ? HP_PRESENT_PORT_A : 0; 2088 spec->hp_present = portA ? HP_PRESENT_PORT_A : 0;
2231 spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0; 2089 spec->hp_present |= portD ? HP_PRESENT_PORT_D : 0;
2232 snd_printdd("CXT5066: hp automute portA=%x portD=%x present=%d\n", 2090 codec_dbg(codec, "CXT5066: hp automute portA=%x portD=%x present=%d\n",
2233 portA, portD, spec->hp_present); 2091 portA, portD, spec->hp_present);
2234 cxt5066_update_speaker(codec); 2092 cxt5066_update_speaker(codec);
2235} 2093}
@@ -2252,26 +2110,9 @@ static void cxt5066_automic(struct hda_codec *codec)
2252} 2110}
2253 2111
2254/* unsolicited event for jack sensing */ 2112/* unsolicited event for jack sensing */
2255static void cxt5066_olpc_unsol_event(struct hda_codec *codec, unsigned int res)
2256{
2257 struct conexant_spec *spec = codec->spec;
2258 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26);
2259 switch (res >> 26) {
2260 case CONEXANT_HP_EVENT:
2261 cxt5066_hp_automute(codec);
2262 break;
2263 case CONEXANT_MIC_EVENT:
2264 /* ignore mic events in DC mode; we're always using the jack */
2265 if (!spec->dc_enable)
2266 cxt5066_olpc_automic(codec);
2267 break;
2268 }
2269}
2270
2271/* unsolicited event for jack sensing */
2272static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res) 2113static void cxt5066_unsol_event(struct hda_codec *codec, unsigned int res)
2273{ 2114{
2274 snd_printdd("CXT5066: unsol event %x (%x)\n", res, res >> 26); 2115 codec_dbg(codec, "CXT5066: unsol event %x (%x)\n", res, res >> 26);
2275 switch (res >> 26) { 2116 switch (res >> 26) {
2276 case CONEXANT_HP_EVENT: 2117 case CONEXANT_HP_EVENT:
2277 cxt5066_hp_automute(codec); 2118 cxt5066_hp_automute(codec);
@@ -2338,124 +2179,10 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol,
2338 idx = imux->num_items - 1; 2179 idx = imux->num_items - 1;
2339 2180
2340 spec->mic_boost = idx; 2181 spec->mic_boost = idx;
2341 if (!spec->dc_enable)
2342 cxt5066_set_mic_boost(codec);
2343 return 1;
2344}
2345
2346static void cxt5066_enable_dc(struct hda_codec *codec)
2347{
2348 const struct hda_verb enable_dc_mode[] = {
2349 /* disable gain */
2350 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2351
2352 /* switch to DC input */
2353 {0x17, AC_VERB_SET_CONNECT_SEL, 3},
2354 {}
2355 };
2356
2357 /* configure as input source */
2358 snd_hda_sequence_write(codec, enable_dc_mode);
2359 cxt5066_olpc_select_mic(codec); /* also sets configured bias */
2360}
2361
2362static void cxt5066_disable_dc(struct hda_codec *codec)
2363{
2364 /* reconfigure input source */
2365 cxt5066_set_mic_boost(codec); 2182 cxt5066_set_mic_boost(codec);
2366 /* automic also selects the right mic if we're recording */
2367 cxt5066_olpc_automic(codec);
2368}
2369
2370static int cxt5066_olpc_dc_get(struct snd_kcontrol *kcontrol,
2371 struct snd_ctl_elem_value *ucontrol)
2372{
2373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2374 struct conexant_spec *spec = codec->spec;
2375 ucontrol->value.integer.value[0] = spec->dc_enable;
2376 return 0;
2377}
2378
2379static int cxt5066_olpc_dc_put(struct snd_kcontrol *kcontrol,
2380 struct snd_ctl_elem_value *ucontrol)
2381{
2382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2383 struct conexant_spec *spec = codec->spec;
2384 int dc_enable = !!ucontrol->value.integer.value[0];
2385
2386 if (dc_enable == spec->dc_enable)
2387 return 0;
2388
2389 spec->dc_enable = dc_enable;
2390 if (dc_enable)
2391 cxt5066_enable_dc(codec);
2392 else
2393 cxt5066_disable_dc(codec);
2394
2395 return 1;
2396}
2397
2398static int cxt5066_olpc_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
2399 struct snd_ctl_elem_info *uinfo)
2400{
2401 return snd_hda_input_mux_info(&cxt5066_olpc_dc_bias, uinfo);
2402}
2403
2404static int cxt5066_olpc_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
2405 struct snd_ctl_elem_value *ucontrol)
2406{
2407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2408 struct conexant_spec *spec = codec->spec;
2409 ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
2410 return 0;
2411}
2412
2413static int cxt5066_olpc_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
2414 struct snd_ctl_elem_value *ucontrol)
2415{
2416 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2417 struct conexant_spec *spec = codec->spec;
2418 const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
2419 unsigned int idx;
2420
2421 idx = ucontrol->value.enumerated.item[0];
2422 if (idx >= imux->num_items)
2423 idx = imux->num_items - 1;
2424
2425 spec->dc_input_bias = idx;
2426 if (spec->dc_enable)
2427 cxt5066_set_olpc_dc_bias(codec);
2428 return 1; 2183 return 1;
2429} 2184}
2430 2185
2431static void cxt5066_olpc_capture_prepare(struct hda_codec *codec)
2432{
2433 struct conexant_spec *spec = codec->spec;
2434 /* mark as recording and configure the microphone widget so that the
2435 * recording LED comes on. */
2436 spec->recording = 1;
2437 cxt5066_olpc_select_mic(codec);
2438}
2439
2440static void cxt5066_olpc_capture_cleanup(struct hda_codec *codec)
2441{
2442 struct conexant_spec *spec = codec->spec;
2443 const struct hda_verb disable_mics[] = {
2444 /* disable external mic, port B */
2445 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2446
2447 /* disble internal mic, port C */
2448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2449
2450 /* disable DC capture, port F */
2451 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2452 {},
2453 };
2454
2455 snd_hda_sequence_write(codec, disable_mics);
2456 spec->recording = 0;
2457}
2458
2459static void conexant_check_dig_outs(struct hda_codec *codec, 2186static void conexant_check_dig_outs(struct hda_codec *codec,
2460 const hda_nid_t *dig_pins, 2187 const hda_nid_t *dig_pins,
2461 int num_pins) 2188 int num_pins)
@@ -2506,43 +2233,6 @@ static const struct snd_kcontrol_new cxt5066_mixer_master[] = {
2506 {} 2233 {}
2507}; 2234};
2508 2235
2509static const struct snd_kcontrol_new cxt5066_mixer_master_olpc[] = {
2510 {
2511 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2512 .name = "Master Playback Volume",
2513 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
2514 SNDRV_CTL_ELEM_ACCESS_TLV_READ |
2515 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK,
2516 .subdevice = HDA_SUBDEV_AMP_FLAG,
2517 .info = snd_hda_mixer_amp_volume_info,
2518 .get = snd_hda_mixer_amp_volume_get,
2519 .put = snd_hda_mixer_amp_volume_put,
2520 .tlv = { .c = snd_hda_mixer_amp_tlv },
2521 /* offset by 28 volume steps to limit minimum gain to -46dB */
2522 .private_value =
2523 HDA_COMPOSE_AMP_VAL_OFS(0x10, 3, 0, HDA_OUTPUT, 28),
2524 },
2525 {}
2526};
2527
2528static const struct snd_kcontrol_new cxt5066_mixer_olpc_dc[] = {
2529 {
2530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2531 .name = "DC Mode Enable Switch",
2532 .info = snd_ctl_boolean_mono_info,
2533 .get = cxt5066_olpc_dc_get,
2534 .put = cxt5066_olpc_dc_put,
2535 },
2536 {
2537 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2538 .name = "DC Input Bias Enum",
2539 .info = cxt5066_olpc_dc_bias_enum_info,
2540 .get = cxt5066_olpc_dc_bias_enum_get,
2541 .put = cxt5066_olpc_dc_bias_enum_put,
2542 },
2543 {}
2544};
2545
2546static const struct snd_kcontrol_new cxt5066_mixers[] = { 2236static const struct snd_kcontrol_new cxt5066_mixers[] = {
2547 { 2237 {
2548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2238 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -2633,67 +2323,6 @@ static const struct hda_verb cxt5066_init_verbs[] = {
2633 { } /* end */ 2323 { } /* end */
2634}; 2324};
2635 2325
2636static const struct hda_verb cxt5066_init_verbs_olpc[] = {
2637 /* Port A: headphones */
2638 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2639 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2640
2641 /* Port B: external microphone */
2642 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2643
2644 /* Port C: internal microphone */
2645 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2646
2647 /* Port D: unused */
2648 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2649
2650 /* Port E: unused, but has primary EAPD */
2651 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2652 {0x1d, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
2653
2654 /* Port F: external DC input through microphone port */
2655 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2656
2657 /* Port G: internal speakers */
2658 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2659 {0x1f, AC_VERB_SET_CONNECT_SEL, 0x00}, /* DAC1 */
2660
2661 /* DAC1 */
2662 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2663
2664 /* DAC2: unused */
2665 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2666
2667 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x50},
2668 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2669 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2671 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2675 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2676 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2679
2680 /* Disable digital microphone port */
2681 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2682
2683 /* Audio input selectors */
2684 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x3},
2685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2686
2687 /* Disable SPDIF */
2688 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2689 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
2690
2691 /* enable unsolicited events for Port A and B */
2692 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
2693 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
2694 { } /* end */
2695};
2696
2697static const struct hda_verb cxt5066_init_verbs_vostro[] = { 2326static const struct hda_verb cxt5066_init_verbs_vostro[] = {
2698 /* Port A: headphones */ 2327 /* Port A: headphones */
2699 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2328 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
@@ -2879,7 +2508,7 @@ static const struct hda_verb cxt5066_init_verbs_hp_laptop[] = {
2879/* initialize jack-sensing, too */ 2508/* initialize jack-sensing, too */
2880static int cxt5066_init(struct hda_codec *codec) 2509static int cxt5066_init(struct hda_codec *codec)
2881{ 2510{
2882 snd_printdd("CXT5066: init\n"); 2511 codec_dbg(codec, "CXT5066: init\n");
2883 conexant_init(codec); 2512 conexant_init(codec);
2884 if (codec->patch_ops.unsol_event) { 2513 if (codec->patch_ops.unsol_event) {
2885 cxt5066_hp_automute(codec); 2514 cxt5066_hp_automute(codec);
@@ -2889,25 +2518,9 @@ static int cxt5066_init(struct hda_codec *codec)
2889 return 0; 2518 return 0;
2890} 2519}
2891 2520
2892static int cxt5066_olpc_init(struct hda_codec *codec)
2893{
2894 struct conexant_spec *spec = codec->spec;
2895 snd_printdd("CXT5066: init\n");
2896 conexant_init(codec);
2897 cxt5066_hp_automute(codec);
2898 if (!spec->dc_enable) {
2899 cxt5066_set_mic_boost(codec);
2900 cxt5066_olpc_automic(codec);
2901 } else {
2902 cxt5066_enable_dc(codec);
2903 }
2904 return 0;
2905}
2906
2907enum { 2521enum {
2908 CXT5066_LAPTOP, /* Laptops w/ EAPD support */ 2522 CXT5066_LAPTOP, /* Laptops w/ EAPD support */
2909 CXT5066_DELL_LAPTOP, /* Dell Laptop */ 2523 CXT5066_DELL_LAPTOP, /* Dell Laptop */
2910 CXT5066_OLPC_XO_1_5, /* OLPC XO 1.5 */
2911 CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */ 2524 CXT5066_DELL_VOSTRO, /* Dell Vostro 1015i */
2912 CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */ 2525 CXT5066_IDEAPAD, /* Lenovo IdeaPad U150 */
2913 CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */ 2526 CXT5066_THINKPAD, /* Lenovo ThinkPad T410s, others? */
@@ -2920,7 +2533,6 @@ enum {
2920static const char * const cxt5066_models[CXT5066_MODELS] = { 2533static const char * const cxt5066_models[CXT5066_MODELS] = {
2921 [CXT5066_LAPTOP] = "laptop", 2534 [CXT5066_LAPTOP] = "laptop",
2922 [CXT5066_DELL_LAPTOP] = "dell-laptop", 2535 [CXT5066_DELL_LAPTOP] = "dell-laptop",
2923 [CXT5066_OLPC_XO_1_5] = "olpc-xo-1_5",
2924 [CXT5066_DELL_VOSTRO] = "dell-vostro", 2536 [CXT5066_DELL_VOSTRO] = "dell-vostro",
2925 [CXT5066_IDEAPAD] = "ideapad", 2537 [CXT5066_IDEAPAD] = "ideapad",
2926 [CXT5066_THINKPAD] = "thinkpad", 2538 [CXT5066_THINKPAD] = "thinkpad",
@@ -2941,10 +2553,8 @@ static const struct snd_pci_quirk cxt5066_cfg_tbl[] = {
2941 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), 2553 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS),
2942 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS), 2554 SND_PCI_QUIRK(0x1043, 0x1993, "Asus U50F", CXT5066_ASUS),
2943 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD), 2555 SND_PCI_QUIRK(0x1179, 0xff1e, "Toshiba Satellite C650D", CXT5066_IDEAPAD),
2944 SND_PCI_QUIRK(0x1179, 0xff50, "Toshiba Satellite P500-PSPGSC-01800T", CXT5066_OLPC_XO_1_5),
2945 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 2556 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
2946 CXT5066_LAPTOP), 2557 CXT5066_LAPTOP),
2947 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT5066_OLPC_XO_1_5),
2948 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD), 2558 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400s", CXT5066_THINKPAD),
2949 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD), 2559 SND_PCI_QUIRK(0x17aa, 0x21c5, "Thinkpad Edge 13", CXT5066_THINKPAD),
2950 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS), 2560 SND_PCI_QUIRK(0x17aa, 0x21c6, "Thinkpad Edge 13", CXT5066_ASUS),
@@ -3030,32 +2640,11 @@ static int patch_cxt5066(struct hda_codec *codec)
3030 spec->mic_boost = 3; /* default 30dB gain */ 2640 spec->mic_boost = 3; /* default 30dB gain */
3031 break; 2641 break;
3032 2642
3033 case CXT5066_OLPC_XO_1_5:
3034 codec->patch_ops.init = cxt5066_olpc_init;
3035 codec->patch_ops.unsol_event = cxt5066_olpc_unsol_event;
3036 spec->init_verbs[0] = cxt5066_init_verbs_olpc;
3037 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
3038 spec->mixers[spec->num_mixers++] = cxt5066_mixer_olpc_dc;
3039 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3040 spec->port_d_mode = 0;
3041 spec->mic_boost = 3; /* default 30dB gain */
3042
3043 /* no S/PDIF out */
3044 spec->multiout.dig_out_nid = 0;
3045
3046 /* input source automatically selected */
3047 spec->input_mux = NULL;
3048
3049 /* our capture hooks which allow us to turn on the microphone LED
3050 * at the right time */
3051 spec->capture_prepare = cxt5066_olpc_capture_prepare;
3052 spec->capture_cleanup = cxt5066_olpc_capture_cleanup;
3053 break;
3054 case CXT5066_DELL_VOSTRO: 2643 case CXT5066_DELL_VOSTRO:
3055 codec->patch_ops.init = cxt5066_init; 2644 codec->patch_ops.init = cxt5066_init;
3056 codec->patch_ops.unsol_event = cxt5066_unsol_event; 2645 codec->patch_ops.unsol_event = cxt5066_unsol_event;
3057 spec->init_verbs[0] = cxt5066_init_verbs_vostro; 2646 spec->init_verbs[0] = cxt5066_init_verbs_vostro;
3058 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc; 2647 spec->mixers[spec->num_mixers++] = cxt5066_mixer_master;
3059 spec->mixers[spec->num_mixers++] = cxt5066_mixers; 2648 spec->mixers[spec->num_mixers++] = cxt5066_mixers;
3060 spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers; 2649 spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers;
3061 spec->port_d_mode = 0; 2650 spec->port_d_mode = 0;
@@ -3207,11 +2796,7 @@ static int cx_auto_init(struct hda_codec *codec)
3207 return 0; 2796 return 0;
3208} 2797}
3209 2798
3210static void cx_auto_free(struct hda_codec *codec) 2799#define cx_auto_free snd_hda_gen_free
3211{
3212 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
3213 snd_hda_gen_free(codec);
3214}
3215 2800
3216static const struct hda_codec_ops cx_auto_patch_ops = { 2801static const struct hda_codec_ops cx_auto_patch_ops = {
3217 .build_controls = cx_auto_build_controls, 2802 .build_controls = cx_auto_build_controls,
@@ -3238,6 +2823,11 @@ enum {
3238 CXT_FIXUP_HEADPHONE_MIC, 2823 CXT_FIXUP_HEADPHONE_MIC,
3239 CXT_FIXUP_GPIO1, 2824 CXT_FIXUP_GPIO1,
3240 CXT_FIXUP_THINKPAD_ACPI, 2825 CXT_FIXUP_THINKPAD_ACPI,
2826 CXT_FIXUP_OLPC_XO,
2827 CXT_FIXUP_CAP_MIX_AMP,
2828 CXT_FIXUP_TOSHIBA_P105,
2829 CXT_FIXUP_HP_530,
2830 CXT_FIXUP_CAP_MIX_AMP_5047,
3241}; 2831};
3242 2832
3243/* for hda_fixup_thinkpad_acpi() */ 2833/* for hda_fixup_thinkpad_acpi() */
@@ -3316,6 +2906,288 @@ static void cxt_fixup_headphone_mic(struct hda_codec *codec,
3316 } 2906 }
3317} 2907}
3318 2908
2909/* OPLC XO 1.5 fixup */
2910
2911/* OLPC XO-1.5 supports DC input mode (e.g. for use with analog sensors)
2912 * through the microphone jack.
2913 * When the user enables this through a mixer switch, both internal and
2914 * external microphones are disabled. Gain is fixed at 0dB. In this mode,
2915 * we also allow the bias to be configured through a separate mixer
2916 * control. */
2917
2918#define update_mic_pin(codec, nid, val) \
2919 snd_hda_codec_update_cache(codec, nid, 0, \
2920 AC_VERB_SET_PIN_WIDGET_CONTROL, val)
2921
2922static const struct hda_input_mux olpc_xo_dc_bias = {
2923 .num_items = 3,
2924 .items = {
2925 { "Off", PIN_IN },
2926 { "50%", PIN_VREF50 },
2927 { "80%", PIN_VREF80 },
2928 },
2929};
2930
2931static void olpc_xo_update_mic_boost(struct hda_codec *codec)
2932{
2933 struct conexant_spec *spec = codec->spec;
2934 int ch, val;
2935
2936 for (ch = 0; ch < 2; ch++) {
2937 val = AC_AMP_SET_OUTPUT |
2938 (ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT);
2939 if (!spec->dc_enable)
2940 val |= snd_hda_codec_amp_read(codec, 0x17, ch, HDA_OUTPUT, 0);
2941 snd_hda_codec_write(codec, 0x17, 0,
2942 AC_VERB_SET_AMP_GAIN_MUTE, val);
2943 }
2944}
2945
2946static void olpc_xo_update_mic_pins(struct hda_codec *codec)
2947{
2948 struct conexant_spec *spec = codec->spec;
2949 int cur_input, val;
2950 struct nid_path *path;
2951
2952 cur_input = spec->gen.input_paths[0][spec->gen.cur_mux[0]];
2953
2954 /* Set up mic pins for port-B, C and F dynamically as the recording
2955 * LED is turned on/off by these pin controls
2956 */
2957 if (!spec->dc_enable) {
2958 /* disable DC bias path and pin for port F */
2959 update_mic_pin(codec, 0x1e, 0);
2960 snd_hda_activate_path(codec, spec->dc_mode_path, false, false);
2961
2962 /* update port B (ext mic) and C (int mic) */
2963 /* OLPC defers mic widget control until when capture is
2964 * started because the microphone LED comes on as soon as
2965 * these settings are put in place. if we did this before
2966 * recording, it would give the false indication that
2967 * recording is happening when it is not.
2968 */
2969 update_mic_pin(codec, 0x1a, spec->recording ?
2970 snd_hda_codec_get_pin_target(codec, 0x1a) : 0);
2971 update_mic_pin(codec, 0x1b, spec->recording ?
2972 snd_hda_codec_get_pin_target(codec, 0x1b) : 0);
2973 /* enable normal mic path */
2974 path = snd_hda_get_path_from_idx(codec, cur_input);
2975 if (path)
2976 snd_hda_activate_path(codec, path, true, false);
2977 } else {
2978 /* disable normal mic path */
2979 path = snd_hda_get_path_from_idx(codec, cur_input);
2980 if (path)
2981 snd_hda_activate_path(codec, path, false, false);
2982
2983 /* Even though port F is the DC input, the bias is controlled
2984 * on port B. We also leave that port as an active input (but
2985 * unselected) in DC mode just in case that is necessary to
2986 * make the bias setting take effect.
2987 */
2988 if (spec->recording)
2989 val = olpc_xo_dc_bias.items[spec->dc_input_bias].index;
2990 else
2991 val = 0;
2992 update_mic_pin(codec, 0x1a, val);
2993 update_mic_pin(codec, 0x1b, 0);
2994 /* enable DC bias path and pin */
2995 update_mic_pin(codec, 0x1e, spec->recording ? PIN_IN : 0);
2996 snd_hda_activate_path(codec, spec->dc_mode_path, true, false);
2997 }
2998}
2999
3000/* mic_autoswitch hook */
3001static void olpc_xo_automic(struct hda_codec *codec, struct hda_jack_tbl *jack)
3002{
3003 struct conexant_spec *spec = codec->spec;
3004 int saved_cached_write = codec->cached_write;
3005
3006 codec->cached_write = 1;
3007 /* in DC mode, we don't handle automic */
3008 if (!spec->dc_enable)
3009 snd_hda_gen_mic_autoswitch(codec, jack);
3010 olpc_xo_update_mic_pins(codec);
3011 snd_hda_codec_flush_cache(codec);
3012 codec->cached_write = saved_cached_write;
3013 if (spec->dc_enable)
3014 olpc_xo_update_mic_boost(codec);
3015}
3016
3017/* pcm_capture hook */
3018static void olpc_xo_capture_hook(struct hda_pcm_stream *hinfo,
3019 struct hda_codec *codec,
3020 struct snd_pcm_substream *substream,
3021 int action)
3022{
3023 struct conexant_spec *spec = codec->spec;
3024
3025 /* toggle spec->recording flag and update mic pins accordingly
3026 * for turning on/off LED
3027 */
3028 switch (action) {
3029 case HDA_GEN_PCM_ACT_PREPARE:
3030 spec->recording = 1;
3031 olpc_xo_update_mic_pins(codec);
3032 break;
3033 case HDA_GEN_PCM_ACT_CLEANUP:
3034 spec->recording = 0;
3035 olpc_xo_update_mic_pins(codec);
3036 break;
3037 }
3038}
3039
3040static int olpc_xo_dc_mode_get(struct snd_kcontrol *kcontrol,
3041 struct snd_ctl_elem_value *ucontrol)
3042{
3043 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3044 struct conexant_spec *spec = codec->spec;
3045 ucontrol->value.integer.value[0] = spec->dc_enable;
3046 return 0;
3047}
3048
3049static int olpc_xo_dc_mode_put(struct snd_kcontrol *kcontrol,
3050 struct snd_ctl_elem_value *ucontrol)
3051{
3052 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3053 struct conexant_spec *spec = codec->spec;
3054 int dc_enable = !!ucontrol->value.integer.value[0];
3055
3056 if (dc_enable == spec->dc_enable)
3057 return 0;
3058
3059 spec->dc_enable = dc_enable;
3060 olpc_xo_update_mic_pins(codec);
3061 olpc_xo_update_mic_boost(codec);
3062 return 1;
3063}
3064
3065static int olpc_xo_dc_bias_enum_get(struct snd_kcontrol *kcontrol,
3066 struct snd_ctl_elem_value *ucontrol)
3067{
3068 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3069 struct conexant_spec *spec = codec->spec;
3070 ucontrol->value.enumerated.item[0] = spec->dc_input_bias;
3071 return 0;
3072}
3073
3074static int olpc_xo_dc_bias_enum_info(struct snd_kcontrol *kcontrol,
3075 struct snd_ctl_elem_info *uinfo)
3076{
3077 return snd_hda_input_mux_info(&olpc_xo_dc_bias, uinfo);
3078}
3079
3080static int olpc_xo_dc_bias_enum_put(struct snd_kcontrol *kcontrol,
3081 struct snd_ctl_elem_value *ucontrol)
3082{
3083 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3084 struct conexant_spec *spec = codec->spec;
3085 const struct hda_input_mux *imux = &olpc_xo_dc_bias;
3086 unsigned int idx;
3087
3088 idx = ucontrol->value.enumerated.item[0];
3089 if (idx >= imux->num_items)
3090 idx = imux->num_items - 1;
3091 if (spec->dc_input_bias == idx)
3092 return 0;
3093
3094 spec->dc_input_bias = idx;
3095 if (spec->dc_enable)
3096 olpc_xo_update_mic_pins(codec);
3097 return 1;
3098}
3099
3100static const struct snd_kcontrol_new olpc_xo_mixers[] = {
3101 {
3102 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3103 .name = "DC Mode Enable Switch",
3104 .info = snd_ctl_boolean_mono_info,
3105 .get = olpc_xo_dc_mode_get,
3106 .put = olpc_xo_dc_mode_put,
3107 },
3108 {
3109 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3110 .name = "DC Input Bias Enum",
3111 .info = olpc_xo_dc_bias_enum_info,
3112 .get = olpc_xo_dc_bias_enum_get,
3113 .put = olpc_xo_dc_bias_enum_put,
3114 },
3115 {}
3116};
3117
3118/* overriding mic boost put callback; update mic boost volume only when
3119 * DC mode is disabled
3120 */
3121static int olpc_xo_mic_boost_put(struct snd_kcontrol *kcontrol,
3122 struct snd_ctl_elem_value *ucontrol)
3123{
3124 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3125 struct conexant_spec *spec = codec->spec;
3126 int ret = snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
3127 if (ret > 0 && spec->dc_enable)
3128 olpc_xo_update_mic_boost(codec);
3129 return ret;
3130}
3131
3132static void cxt_fixup_olpc_xo(struct hda_codec *codec,
3133 const struct hda_fixup *fix, int action)
3134{
3135 struct conexant_spec *spec = codec->spec;
3136 int i;
3137
3138 if (action != HDA_FIXUP_ACT_PROBE)
3139 return;
3140
3141 spec->gen.mic_autoswitch_hook = olpc_xo_automic;
3142 spec->gen.pcm_capture_hook = olpc_xo_capture_hook;
3143 spec->dc_mode_path = snd_hda_add_new_path(codec, 0x1e, 0x14, 0);
3144
3145 snd_hda_add_new_ctls(codec, olpc_xo_mixers);
3146
3147 /* OLPC's microphone port is DC coupled for use with external sensors,
3148 * therefore we use a 50% mic bias in order to center the input signal
3149 * with the DC input range of the codec.
3150 */
3151 snd_hda_codec_set_pin_target(codec, 0x1a, PIN_VREF50);
3152
3153 /* override mic boost control */
3154 for (i = 0; i < spec->gen.kctls.used; i++) {
3155 struct snd_kcontrol_new *kctl =
3156 snd_array_elem(&spec->gen.kctls, i);
3157 if (!strcmp(kctl->name, "Mic Boost Volume")) {
3158 kctl->put = olpc_xo_mic_boost_put;
3159 break;
3160 }
3161 }
3162}
3163
3164/*
3165 * Fix max input level on mixer widget to 0dB
3166 * (originally it has 0x2b steps with 0dB offset 0x14)
3167 */
3168static void cxt_fixup_cap_mix_amp(struct hda_codec *codec,
3169 const struct hda_fixup *fix, int action)
3170{
3171 snd_hda_override_amp_caps(codec, 0x17, HDA_INPUT,
3172 (0x14 << AC_AMPCAP_OFFSET_SHIFT) |
3173 (0x14 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3174 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3175 (1 << AC_AMPCAP_MUTE_SHIFT));
3176}
3177
3178/*
3179 * Fix max input level on mixer widget to 0dB
3180 * (originally it has 0x1e steps with 0 dB offset 0x17)
3181 */
3182static void cxt_fixup_cap_mix_amp_5047(struct hda_codec *codec,
3183 const struct hda_fixup *fix, int action)
3184{
3185 snd_hda_override_amp_caps(codec, 0x10, HDA_INPUT,
3186 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
3187 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3188 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3189 (1 << AC_AMPCAP_MUTE_SHIFT));
3190}
3319 3191
3320/* ThinkPad X200 & co with cxt5051 */ 3192/* ThinkPad X200 & co with cxt5051 */
3321static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = { 3193static const struct hda_pintbl cxt_pincfg_lenovo_x200[] = {
@@ -3401,6 +3273,68 @@ static const struct hda_fixup cxt_fixups[] = {
3401 .type = HDA_FIXUP_FUNC, 3273 .type = HDA_FIXUP_FUNC,
3402 .v.func = hda_fixup_thinkpad_acpi, 3274 .v.func = hda_fixup_thinkpad_acpi,
3403 }, 3275 },
3276 [CXT_FIXUP_OLPC_XO] = {
3277 .type = HDA_FIXUP_FUNC,
3278 .v.func = cxt_fixup_olpc_xo,
3279 },
3280 [CXT_FIXUP_CAP_MIX_AMP] = {
3281 .type = HDA_FIXUP_FUNC,
3282 .v.func = cxt_fixup_cap_mix_amp,
3283 },
3284 [CXT_FIXUP_TOSHIBA_P105] = {
3285 .type = HDA_FIXUP_PINS,
3286 .v.pins = (const struct hda_pintbl[]) {
3287 { 0x10, 0x961701f0 }, /* speaker/hp */
3288 { 0x12, 0x02a1901e }, /* ext mic */
3289 { 0x14, 0x95a70110 }, /* int mic */
3290 {}
3291 },
3292 },
3293 [CXT_FIXUP_HP_530] = {
3294 .type = HDA_FIXUP_PINS,
3295 .v.pins = (const struct hda_pintbl[]) {
3296 { 0x12, 0x90a60160 }, /* int mic */
3297 {}
3298 },
3299 .chained = true,
3300 .chain_id = CXT_FIXUP_CAP_MIX_AMP,
3301 },
3302 [CXT_FIXUP_CAP_MIX_AMP_5047] = {
3303 .type = HDA_FIXUP_FUNC,
3304 .v.func = cxt_fixup_cap_mix_amp_5047,
3305 },
3306};
3307
3308static const struct snd_pci_quirk cxt5045_fixups[] = {
3309 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT_FIXUP_HP_530),
3310 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT_FIXUP_TOSHIBA_P105),
3311 /* HP, Packard Bell, Fujitsu-Siemens & Lenovo laptops have
3312 * really bad sound over 0dB on NID 0x17.
3313 */
3314 SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP),
3315 SND_PCI_QUIRK_VENDOR(0x1631, "Packard Bell", CXT_FIXUP_CAP_MIX_AMP),
3316 SND_PCI_QUIRK_VENDOR(0x1734, "Fujitsu", CXT_FIXUP_CAP_MIX_AMP),
3317 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", CXT_FIXUP_CAP_MIX_AMP),
3318 {}
3319};
3320
3321static const struct hda_model_fixup cxt5045_fixup_models[] = {
3322 { .id = CXT_FIXUP_CAP_MIX_AMP, .name = "cap-mix-amp" },
3323 { .id = CXT_FIXUP_TOSHIBA_P105, .name = "toshiba-p105" },
3324 { .id = CXT_FIXUP_HP_530, .name = "hp-530" },
3325 {}
3326};
3327
3328static const struct snd_pci_quirk cxt5047_fixups[] = {
3329 /* HP laptops have really bad sound over 0 dB on NID 0x10.
3330 */
3331 SND_PCI_QUIRK_VENDOR(0x103c, "HP", CXT_FIXUP_CAP_MIX_AMP_5047),
3332 {}
3333};
3334
3335static const struct hda_model_fixup cxt5047_fixup_models[] = {
3336 { .id = CXT_FIXUP_CAP_MIX_AMP_5047, .name = "cap-mix-amp" },
3337 {}
3404}; 3338};
3405 3339
3406static const struct snd_pci_quirk cxt5051_fixups[] = { 3340static const struct snd_pci_quirk cxt5051_fixups[] = {
@@ -3408,10 +3342,16 @@ static const struct snd_pci_quirk cxt5051_fixups[] = {
3408 {} 3342 {}
3409}; 3343};
3410 3344
3345static const struct hda_model_fixup cxt5051_fixup_models[] = {
3346 { .id = CXT_PINCFG_LENOVO_X200, .name = "lenovo-x200" },
3347 {}
3348};
3349
3411static const struct snd_pci_quirk cxt5066_fixups[] = { 3350static const struct snd_pci_quirk cxt5066_fixups[] = {
3412 SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC), 3351 SND_PCI_QUIRK(0x1025, 0x0543, "Acer Aspire One 522", CXT_FIXUP_STEREO_DMIC),
3413 SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1), 3352 SND_PCI_QUIRK(0x1025, 0x054c, "Acer Aspire 3830TG", CXT_FIXUP_GPIO1),
3414 SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN), 3353 SND_PCI_QUIRK(0x1043, 0x138d, "Asus", CXT_FIXUP_HEADPHONE_MIC_PIN),
3354 SND_PCI_QUIRK(0x152d, 0x0833, "OLPC XO-1.5", CXT_FIXUP_OLPC_XO),
3415 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410), 3355 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo T400", CXT_PINCFG_LENOVO_TP410),
3416 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410), 3356 SND_PCI_QUIRK(0x17aa, 0x215e, "Lenovo T410", CXT_PINCFG_LENOVO_TP410),
3417 SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410), 3357 SND_PCI_QUIRK(0x17aa, 0x215f, "Lenovo T510", CXT_PINCFG_LENOVO_TP410),
@@ -3428,6 +3368,17 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
3428 {} 3368 {}
3429}; 3369};
3430 3370
3371static const struct hda_model_fixup cxt5066_fixup_models[] = {
3372 { .id = CXT_FIXUP_STEREO_DMIC, .name = "stereo-dmic" },
3373 { .id = CXT_FIXUP_GPIO1, .name = "gpio1" },
3374 { .id = CXT_FIXUP_HEADPHONE_MIC_PIN, .name = "headphone-mic-pin" },
3375 { .id = CXT_PINCFG_LENOVO_TP410, .name = "tp410" },
3376 { .id = CXT_FIXUP_THINKPAD_ACPI, .name = "thinkpad" },
3377 { .id = CXT_PINCFG_LEMOTE_A1004, .name = "lemote-a1004" },
3378 { .id = CXT_FIXUP_OLPC_XO, .name = "olpc-xo" },
3379 {}
3380};
3381
3431/* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches 3382/* add "fake" mute amp-caps to DACs on cx5051 so that mixer mute switches
3432 * can be created (bko#42825) 3383 * can be created (bko#42825)
3433 */ 3384 */
@@ -3449,8 +3400,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
3449 struct conexant_spec *spec; 3400 struct conexant_spec *spec;
3450 int err; 3401 int err;
3451 3402
3452 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n", 3403 codec_info(codec, "%s: BIOS auto-probing.\n", codec->chip_name);
3453 codec->chip_name);
3454 3404
3455 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3405 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3456 if (!spec) 3406 if (!spec)
@@ -3467,19 +3417,28 @@ static int patch_conexant_auto(struct hda_codec *codec)
3467 switch (codec->vendor_id) { 3417 switch (codec->vendor_id) {
3468 case 0x14f15045: 3418 case 0x14f15045:
3469 codec->single_adc_amp = 1; 3419 codec->single_adc_amp = 1;
3420 spec->gen.mixer_nid = 0x17;
3421 spec->gen.add_stereo_mix_input = 1;
3422 snd_hda_pick_fixup(codec, cxt5045_fixup_models,
3423 cxt5045_fixups, cxt_fixups);
3470 break; 3424 break;
3471 case 0x14f15047: 3425 case 0x14f15047:
3472 codec->pin_amp_workaround = 1; 3426 codec->pin_amp_workaround = 1;
3473 spec->gen.mixer_nid = 0x19; 3427 spec->gen.mixer_nid = 0x19;
3428 spec->gen.add_stereo_mix_input = 1;
3429 snd_hda_pick_fixup(codec, cxt5047_fixup_models,
3430 cxt5047_fixups, cxt_fixups);
3474 break; 3431 break;
3475 case 0x14f15051: 3432 case 0x14f15051:
3476 add_cx5051_fake_mutes(codec); 3433 add_cx5051_fake_mutes(codec);
3477 codec->pin_amp_workaround = 1; 3434 codec->pin_amp_workaround = 1;
3478 snd_hda_pick_fixup(codec, NULL, cxt5051_fixups, cxt_fixups); 3435 snd_hda_pick_fixup(codec, cxt5051_fixup_models,
3436 cxt5051_fixups, cxt_fixups);
3479 break; 3437 break;
3480 default: 3438 default:
3481 codec->pin_amp_workaround = 1; 3439 codec->pin_amp_workaround = 1;
3482 snd_hda_pick_fixup(codec, NULL, cxt5066_fixups, cxt_fixups); 3440 snd_hda_pick_fixup(codec, cxt5066_fixup_models,
3441 cxt5066_fixups, cxt_fixups);
3483 break; 3442 break;
3484 } 3443 }
3485 3444
@@ -3513,7 +3472,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
3513 * Better to make reset, then. 3472 * Better to make reset, then.
3514 */ 3473 */
3515 if (!codec->bus->sync_write) { 3474 if (!codec->bus->sync_write) {
3516 snd_printd("hda_codec: " 3475 codec_info(codec,
3517 "Enable sync_write for stable communication\n"); 3476 "Enable sync_write for stable communication\n");
3518 codec->bus->sync_write = 1; 3477 codec->bus->sync_write = 1;
3519 codec->bus->allow_bus_reset = 1; 3478 codec->bus->allow_bus_reset = 1;
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 5ef95034d041..0cb5b89cd0c8 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -68,6 +68,7 @@ struct hdmi_spec_per_pin {
68 hda_nid_t pin_nid; 68 hda_nid_t pin_nid;
69 int num_mux_nids; 69 int num_mux_nids;
70 hda_nid_t mux_nids[HDA_MAX_CONNECTIONS]; 70 hda_nid_t mux_nids[HDA_MAX_CONNECTIONS];
71 int mux_idx;
71 hda_nid_t cvt_nid; 72 hda_nid_t cvt_nid;
72 73
73 struct hda_codec *codec; 74 struct hda_codec *codec;
@@ -353,40 +354,43 @@ static struct cea_channel_speaker_allocation channel_allocations[] = {
353#define get_pcm_rec(spec, idx) \ 354#define get_pcm_rec(spec, idx) \
354 ((struct hda_pcm *)snd_array_elem(&spec->pcm_rec, idx)) 355 ((struct hda_pcm *)snd_array_elem(&spec->pcm_rec, idx))
355 356
356static int pin_nid_to_pin_index(struct hdmi_spec *spec, hda_nid_t pin_nid) 357static int pin_nid_to_pin_index(struct hda_codec *codec, hda_nid_t pin_nid)
357{ 358{
359 struct hdmi_spec *spec = codec->spec;
358 int pin_idx; 360 int pin_idx;
359 361
360 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) 362 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
361 if (get_pin(spec, pin_idx)->pin_nid == pin_nid) 363 if (get_pin(spec, pin_idx)->pin_nid == pin_nid)
362 return pin_idx; 364 return pin_idx;
363 365
364 snd_printk(KERN_WARNING "HDMI: pin nid %d not registered\n", pin_nid); 366 codec_warn(codec, "HDMI: pin nid %d not registered\n", pin_nid);
365 return -EINVAL; 367 return -EINVAL;
366} 368}
367 369
368static int hinfo_to_pin_index(struct hdmi_spec *spec, 370static int hinfo_to_pin_index(struct hda_codec *codec,
369 struct hda_pcm_stream *hinfo) 371 struct hda_pcm_stream *hinfo)
370{ 372{
373 struct hdmi_spec *spec = codec->spec;
371 int pin_idx; 374 int pin_idx;
372 375
373 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) 376 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
374 if (get_pcm_rec(spec, pin_idx)->stream == hinfo) 377 if (get_pcm_rec(spec, pin_idx)->stream == hinfo)
375 return pin_idx; 378 return pin_idx;
376 379
377 snd_printk(KERN_WARNING "HDMI: hinfo %p not registered\n", hinfo); 380 codec_warn(codec, "HDMI: hinfo %p not registered\n", hinfo);
378 return -EINVAL; 381 return -EINVAL;
379} 382}
380 383
381static int cvt_nid_to_cvt_index(struct hdmi_spec *spec, hda_nid_t cvt_nid) 384static int cvt_nid_to_cvt_index(struct hda_codec *codec, hda_nid_t cvt_nid)
382{ 385{
386 struct hdmi_spec *spec = codec->spec;
383 int cvt_idx; 387 int cvt_idx;
384 388
385 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) 389 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++)
386 if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid) 390 if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid)
387 return cvt_idx; 391 return cvt_idx;
388 392
389 snd_printk(KERN_WARNING "HDMI: cvt nid %d not registered\n", cvt_nid); 393 codec_warn(codec, "HDMI: cvt nid %d not registered\n", cvt_nid);
390 return -EINVAL; 394 return -EINVAL;
391} 395}
392 396
@@ -706,7 +710,7 @@ static void hdmi_debug_channel_mapping(struct hda_codec *codec,
706 710
707 for (i = 0; i < 8; i++) { 711 for (i = 0; i < 8; i++) {
708 channel = spec->ops.pin_get_slot_channel(codec, pin_nid, i); 712 channel = spec->ops.pin_get_slot_channel(codec, pin_nid, i);
709 printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", 713 codec_dbg(codec, "HDMI: ASP channel %d => slot %d\n",
710 channel, i); 714 channel, i);
711 } 715 }
712#endif 716#endif
@@ -755,8 +759,7 @@ static void hdmi_std_setup_channel_mapping(struct hda_codec *codec,
755 int channel = (slotsetup & 0xf0) >> 4; 759 int channel = (slotsetup & 0xf0) >> 4;
756 err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, channel); 760 err = spec->ops.pin_set_slot_channel(codec, pin_nid, hdmi_slot, channel);
757 if (err) { 761 if (err) {
758 snd_printdd(KERN_NOTICE 762 codec_dbg(codec, "HDMI: channel mapping failed\n");
759 "HDMI: channel mapping failed\n");
760 break; 763 break;
761 } 764 }
762 } 765 }
@@ -967,12 +970,12 @@ static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid)
967 int size; 970 int size;
968 971
969 size = snd_hdmi_get_eld_size(codec, pin_nid); 972 size = snd_hdmi_get_eld_size(codec, pin_nid);
970 printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); 973 codec_dbg(codec, "HDMI: ELD buf size is %d\n", size);
971 974
972 for (i = 0; i < 8; i++) { 975 for (i = 0; i < 8; i++) {
973 size = snd_hda_codec_read(codec, pin_nid, 0, 976 size = snd_hda_codec_read(codec, pin_nid, 0,
974 AC_VERB_GET_HDMI_DIP_SIZE, i); 977 AC_VERB_GET_HDMI_DIP_SIZE, i);
975 printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); 978 codec_dbg(codec, "HDMI: DIP GP[%d] buf size is %d\n", i, size);
976 } 979 }
977#endif 980#endif
978} 981}
@@ -994,12 +997,12 @@ static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
994 hdmi_write_dip_byte(codec, pin_nid, 0x0); 997 hdmi_write_dip_byte(codec, pin_nid, 0x0);
995 hdmi_get_dip_index(codec, pin_nid, &pi, &bi); 998 hdmi_get_dip_index(codec, pin_nid, &pi, &bi);
996 if (pi != i) 999 if (pi != i)
997 snd_printd(KERN_INFO "dip index %d: %d != %d\n", 1000 codec_dbg(codec, "dip index %d: %d != %d\n",
998 bi, pi, i); 1001 bi, pi, i);
999 if (bi == 0) /* byte index wrapped around */ 1002 if (bi == 0) /* byte index wrapped around */
1000 break; 1003 break;
1001 } 1004 }
1002 snd_printd(KERN_INFO 1005 codec_dbg(codec,
1003 "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n", 1006 "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
1004 i, size, j); 1007 i, size, j);
1005 } 1008 }
@@ -1062,6 +1065,7 @@ static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
1062{ 1065{
1063 union audio_infoframe ai; 1066 union audio_infoframe ai;
1064 1067
1068 memset(&ai, 0, sizeof(ai));
1065 if (conn_type == 0) { /* HDMI */ 1069 if (conn_type == 0) { /* HDMI */
1066 struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi; 1070 struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
1067 1071
@@ -1080,7 +1084,7 @@ static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
1080 dp_ai->CC02_CT47 = active_channels - 1; 1084 dp_ai->CC02_CT47 = active_channels - 1;
1081 dp_ai->CA = ca; 1085 dp_ai->CA = ca;
1082 } else { 1086 } else {
1083 snd_printd("HDMI: unknown connection type at pin %d\n", 1087 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n",
1084 pin_nid); 1088 pin_nid);
1085 return; 1089 return;
1086 } 1090 }
@@ -1092,8 +1096,8 @@ static void hdmi_pin_setup_infoframe(struct hda_codec *codec,
1092 */ 1096 */
1093 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, 1097 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
1094 sizeof(ai))) { 1098 sizeof(ai))) {
1095 snd_printdd("hdmi_pin_setup_infoframe: " 1099 codec_dbg(codec,
1096 "pin=%d channels=%d ca=0x%02x\n", 1100 "hdmi_pin_setup_infoframe: pin=%d channels=%d ca=0x%02x\n",
1097 pin_nid, 1101 pin_nid,
1098 active_channels, ca); 1102 active_channels, ca);
1099 hdmi_stop_infoframe_trans(codec, pin_nid); 1103 hdmi_stop_infoframe_trans(codec, pin_nid);
@@ -1161,7 +1165,7 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
1161static void jack_callback(struct hda_codec *codec, struct hda_jack_tbl *jack) 1165static void jack_callback(struct hda_codec *codec, struct hda_jack_tbl *jack)
1162{ 1166{
1163 struct hdmi_spec *spec = codec->spec; 1167 struct hdmi_spec *spec = codec->spec;
1164 int pin_idx = pin_nid_to_pin_index(spec, jack->nid); 1168 int pin_idx = pin_nid_to_pin_index(codec, jack->nid);
1165 if (pin_idx < 0) 1169 if (pin_idx < 0)
1166 return; 1170 return;
1167 1171
@@ -1180,7 +1184,7 @@ static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
1180 return; 1184 return;
1181 jack->jack_dirty = 1; 1185 jack->jack_dirty = 1;
1182 1186
1183 _snd_printd(SND_PR_VERBOSE, 1187 codec_dbg(codec,
1184 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", 1188 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n",
1185 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA), 1189 codec->addr, jack->nid, dev_entry, !!(res & AC_UNSOL_RES_IA),
1186 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV)); 1190 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
@@ -1195,7 +1199,7 @@ static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
1195 int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); 1199 int cp_state = !!(res & AC_UNSOL_RES_CP_STATE);
1196 int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); 1200 int cp_ready = !!(res & AC_UNSOL_RES_CP_READY);
1197 1201
1198 printk(KERN_INFO 1202 codec_info(codec,
1199 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", 1203 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
1200 codec->addr, 1204 codec->addr,
1201 tag, 1205 tag,
@@ -1217,7 +1221,7 @@ static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
1217 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; 1221 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
1218 1222
1219 if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) { 1223 if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) {
1220 snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); 1224 codec_dbg(codec, "Unexpected HDMI event tag 0x%x\n", tag);
1221 return; 1225 return;
1222 } 1226 }
1223 1227
@@ -1244,7 +1248,7 @@ static void haswell_verify_D0(struct hda_codec *codec,
1244 msleep(40); 1248 msleep(40);
1245 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); 1249 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0);
1246 pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT; 1250 pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT;
1247 snd_printd("Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr); 1251 codec_dbg(codec, "Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr);
1248 } 1252 }
1249} 1253}
1250 1254
@@ -1274,8 +1278,8 @@ static int hdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
1274 else 1278 else
1275 new_pinctl |= AC_PINCTL_EPT_NATIVE; 1279 new_pinctl |= AC_PINCTL_EPT_NATIVE;
1276 1280
1277 snd_printdd("hdmi_pin_hbr_setup: " 1281 codec_dbg(codec,
1278 "NID=0x%x, %spinctl=0x%x\n", 1282 "hdmi_pin_hbr_setup: NID=0x%x, %spinctl=0x%x\n",
1279 pin_nid, 1283 pin_nid,
1280 pinctl == new_pinctl ? "" : "new-", 1284 pinctl == new_pinctl ? "" : "new-",
1281 new_pinctl); 1285 new_pinctl);
@@ -1302,7 +1306,7 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
1302 err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format)); 1306 err = spec->ops.pin_hbr_setup(codec, pin_nid, is_hbr_format(format));
1303 1307
1304 if (err) { 1308 if (err) {
1305 snd_printdd("hdmi_setup_stream: HBR is not supported\n"); 1309 codec_dbg(codec, "hdmi_setup_stream: HBR is not supported\n");
1306 return err; 1310 return err;
1307 } 1311 }
1308 1312
@@ -1341,6 +1345,8 @@ static int hdmi_choose_cvt(struct hda_codec *codec,
1341 if (cvt_idx == spec->num_cvts) 1345 if (cvt_idx == spec->num_cvts)
1342 return -ENODEV; 1346 return -ENODEV;
1343 1347
1348 per_pin->mux_idx = mux_idx;
1349
1344 if (cvt_id) 1350 if (cvt_id)
1345 *cvt_id = cvt_idx; 1351 *cvt_id = cvt_idx;
1346 if (mux_id) 1352 if (mux_id)
@@ -1349,6 +1355,22 @@ static int hdmi_choose_cvt(struct hda_codec *codec,
1349 return 0; 1355 return 0;
1350} 1356}
1351 1357
1358/* Assure the pin select the right convetor */
1359static void intel_verify_pin_cvt_connect(struct hda_codec *codec,
1360 struct hdmi_spec_per_pin *per_pin)
1361{
1362 hda_nid_t pin_nid = per_pin->pin_nid;
1363 int mux_idx, curr;
1364
1365 mux_idx = per_pin->mux_idx;
1366 curr = snd_hda_codec_read(codec, pin_nid, 0,
1367 AC_VERB_GET_CONNECT_SEL, 0);
1368 if (curr != mux_idx)
1369 snd_hda_codec_write_cache(codec, pin_nid, 0,
1370 AC_VERB_SET_CONNECT_SEL,
1371 mux_idx);
1372}
1373
1352/* Intel HDMI workaround to fix audio routing issue: 1374/* Intel HDMI workaround to fix audio routing issue:
1353 * For some Intel display codecs, pins share the same connection list. 1375 * For some Intel display codecs, pins share the same connection list.
1354 * So a conveter can be selected by multiple pins and playback on any of these 1376 * So a conveter can be selected by multiple pins and playback on any of these
@@ -1389,7 +1411,8 @@ static void intel_not_share_assigned_cvt(struct hda_codec *codec,
1389 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) { 1411 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) {
1390 per_cvt = get_cvt(spec, cvt_idx); 1412 per_cvt = get_cvt(spec, cvt_idx);
1391 if (!per_cvt->assigned) { 1413 if (!per_cvt->assigned) {
1392 snd_printdd("choose cvt %d for pin nid %d\n", 1414 codec_dbg(codec,
1415 "choose cvt %d for pin nid %d\n",
1393 cvt_idx, nid); 1416 cvt_idx, nid);
1394 snd_hda_codec_write_cache(codec, nid, 0, 1417 snd_hda_codec_write_cache(codec, nid, 0,
1395 AC_VERB_SET_CONNECT_SEL, 1418 AC_VERB_SET_CONNECT_SEL,
@@ -1416,7 +1439,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
1416 int err; 1439 int err;
1417 1440
1418 /* Validate hinfo */ 1441 /* Validate hinfo */
1419 pin_idx = hinfo_to_pin_index(spec, hinfo); 1442 pin_idx = hinfo_to_pin_index(codec, hinfo);
1420 if (snd_BUG_ON(pin_idx < 0)) 1443 if (snd_BUG_ON(pin_idx < 0))
1421 return -EINVAL; 1444 return -EINVAL;
1422 per_pin = get_pin(spec, pin_idx); 1445 per_pin = get_pin(spec, pin_idx);
@@ -1482,9 +1505,8 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
1482 hda_nid_t pin_nid = per_pin->pin_nid; 1505 hda_nid_t pin_nid = per_pin->pin_nid;
1483 1506
1484 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { 1507 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
1485 snd_printk(KERN_WARNING 1508 codec_warn(codec,
1486 "HDMI: pin %d wcaps %#x " 1509 "HDMI: pin %d wcaps %#x does not support connection list\n",
1487 "does not support connection list\n",
1488 pin_nid, get_wcaps(codec, pin_nid)); 1510 pin_nid, get_wcaps(codec, pin_nid));
1489 return -EINVAL; 1511 return -EINVAL;
1490 } 1512 }
@@ -1527,7 +1549,7 @@ static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
1527 else 1549 else
1528 eld->eld_valid = false; 1550 eld->eld_valid = false;
1529 1551
1530 _snd_printd(SND_PR_VERBOSE, 1552 codec_dbg(codec,
1531 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 1553 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
1532 codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid); 1554 codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid);
1533 1555
@@ -1690,7 +1712,7 @@ static int hdmi_parse_codec(struct hda_codec *codec)
1690 1712
1691 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); 1713 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
1692 if (!nid || nodes < 0) { 1714 if (!nid || nodes < 0) {
1693 snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n"); 1715 codec_warn(codec, "HDMI: failed to get afg sub nodes\n");
1694 return -EINVAL; 1716 return -EINVAL;
1695 } 1717 }
1696 1718
@@ -1744,12 +1766,25 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1744{ 1766{
1745 hda_nid_t cvt_nid = hinfo->nid; 1767 hda_nid_t cvt_nid = hinfo->nid;
1746 struct hdmi_spec *spec = codec->spec; 1768 struct hdmi_spec *spec = codec->spec;
1747 int pin_idx = hinfo_to_pin_index(spec, hinfo); 1769 int pin_idx = hinfo_to_pin_index(codec, hinfo);
1748 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); 1770 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1749 hda_nid_t pin_nid = per_pin->pin_nid; 1771 hda_nid_t pin_nid = per_pin->pin_nid;
1750 bool non_pcm; 1772 bool non_pcm;
1751 int pinctl; 1773 int pinctl;
1752 1774
1775 if (is_haswell_plus(codec) || is_valleyview(codec)) {
1776 /* Verify pin:cvt selections to avoid silent audio after S3.
1777 * After S3, the audio driver restores pin:cvt selections
1778 * but this can happen before gfx is ready and such selection
1779 * is overlooked by HW. Thus multiple pins can share a same
1780 * default convertor and mute control will affect each other,
1781 * which can cause a resumed audio playback become silent
1782 * after S3.
1783 */
1784 intel_verify_pin_cvt_connect(codec, per_pin);
1785 intel_not_share_assigned_cvt(codec, pin_nid, per_pin->mux_idx);
1786 }
1787
1753 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid); 1788 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
1754 mutex_lock(&per_pin->lock); 1789 mutex_lock(&per_pin->lock);
1755 per_pin->channels = substream->runtime->channels; 1790 per_pin->channels = substream->runtime->channels;
@@ -1788,7 +1823,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
1788 int pinctl; 1823 int pinctl;
1789 1824
1790 if (hinfo->nid) { 1825 if (hinfo->nid) {
1791 cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid); 1826 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid);
1792 if (snd_BUG_ON(cvt_idx < 0)) 1827 if (snd_BUG_ON(cvt_idx < 0))
1793 return -EINVAL; 1828 return -EINVAL;
1794 per_cvt = get_cvt(spec, cvt_idx); 1829 per_cvt = get_cvt(spec, cvt_idx);
@@ -1797,7 +1832,7 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
1797 per_cvt->assigned = 0; 1832 per_cvt->assigned = 0;
1798 hinfo->nid = 0; 1833 hinfo->nid = 0;
1799 1834
1800 pin_idx = hinfo_to_pin_index(spec, hinfo); 1835 pin_idx = hinfo_to_pin_index(codec, hinfo);
1801 if (snd_BUG_ON(pin_idx < 0)) 1836 if (snd_BUG_ON(pin_idx < 0))
1802 return -EINVAL; 1837 return -EINVAL;
1803 per_pin = get_pin(spec, pin_idx); 1838 per_pin = get_pin(spec, pin_idx);
@@ -2211,7 +2246,7 @@ static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
2211 return; 2246 return;
2212 2247
2213 /* override pins connection list */ 2248 /* override pins connection list */
2214 snd_printdd("hdmi: haswell: override pin connection 0x%x\n", nid); 2249 codec_dbg(codec, "hdmi: haswell: override pin connection 0x%x\n", nid);
2215 snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids); 2250 snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids);
2216} 2251}
2217 2252
@@ -3132,8 +3167,8 @@ static int atihdmi_pin_hbr_setup(struct hda_codec *codec, hda_nid_t pin_nid,
3132 else 3167 else
3133 hbr_ctl_new = hbr_ctl & ~ATI_HBR_ENABLE; 3168 hbr_ctl_new = hbr_ctl & ~ATI_HBR_ENABLE;
3134 3169
3135 snd_printdd("atihdmi_pin_hbr_setup: " 3170 codec_dbg(codec,
3136 "NID=0x%x, %shbr-ctl=0x%x\n", 3171 "atihdmi_pin_hbr_setup: NID=0x%x, %shbr-ctl=0x%x\n",
3137 pin_nid, 3172 pin_nid,
3138 hbr_ctl == hbr_ctl_new ? "" : "new-", 3173 hbr_ctl == hbr_ctl_new ? "" : "new-",
3139 hbr_ctl_new); 3174 hbr_ctl_new);
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 8d0a84436674..ea2351d119f0 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -395,6 +395,8 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec)
395 goto do_sku; 395 goto do_sku;
396 } 396 }
397 397
398 if (!codec->bus->pci)
399 return -1;
398 ass = codec->subsystem_id & 0xffff; 400 ass = codec->subsystem_id & 0xffff;
399 if (ass != codec->bus->pci->subsystem_device && (ass & 1)) 401 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
400 goto do_sku; 402 goto do_sku;
@@ -405,8 +407,8 @@ static int alc_auto_parse_customize_define(struct hda_codec *codec)
405 ass = snd_hda_codec_get_pincfg(codec, nid); 407 ass = snd_hda_codec_get_pincfg(codec, nid);
406 408
407 if (!(ass & 1)) { 409 if (!(ass & 1)) {
408 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", 410 codec_info(codec, "%s: SKU not ready 0x%08x\n",
409 codec->chip_name, ass); 411 codec->chip_name, ass);
410 return -1; 412 return -1;
411 } 413 }
412 414
@@ -430,17 +432,17 @@ do_sku:
430 spec->cdefine.swap = (ass & 0x2) >> 1; 432 spec->cdefine.swap = (ass & 0x2) >> 1;
431 spec->cdefine.override = ass & 0x1; 433 spec->cdefine.override = ass & 0x1;
432 434
433 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", 435 codec_dbg(codec, "SKU: Nid=0x%x sku_cfg=0x%08x\n",
434 nid, spec->cdefine.sku_cfg); 436 nid, spec->cdefine.sku_cfg);
435 snd_printd("SKU: port_connectivity=0x%x\n", 437 codec_dbg(codec, "SKU: port_connectivity=0x%x\n",
436 spec->cdefine.port_connectivity); 438 spec->cdefine.port_connectivity);
437 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); 439 codec_dbg(codec, "SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
438 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); 440 codec_dbg(codec, "SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
439 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); 441 codec_dbg(codec, "SKU: customization=0x%08x\n", spec->cdefine.customization);
440 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); 442 codec_dbg(codec, "SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
441 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); 443 codec_dbg(codec, "SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
442 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); 444 codec_dbg(codec, "SKU: swap=0x%x\n", spec->cdefine.swap);
443 snd_printd("SKU: override=0x%x\n", spec->cdefine.override); 445 codec_dbg(codec, "SKU: override=0x%x\n", spec->cdefine.override);
444 446
445 return 0; 447 return 0;
446} 448}
@@ -483,7 +485,8 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
483 } 485 }
484 486
485 ass = codec->subsystem_id & 0xffff; 487 ass = codec->subsystem_id & 0xffff;
486 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) 488 if (codec->bus->pci &&
489 ass != codec->bus->pci->subsystem_device && (ass & 1))
487 goto do_sku; 490 goto do_sku;
488 491
489 /* invalid SSID, check the special NID pin defcfg instead */ 492 /* invalid SSID, check the special NID pin defcfg instead */
@@ -499,8 +502,8 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
499 if (codec->vendor_id == 0x10ec0260) 502 if (codec->vendor_id == 0x10ec0260)
500 nid = 0x17; 503 nid = 0x17;
501 ass = snd_hda_codec_get_pincfg(codec, nid); 504 ass = snd_hda_codec_get_pincfg(codec, nid);
502 snd_printd("realtek: No valid SSID, " 505 codec_dbg(codec,
503 "checking pincfg 0x%08x for NID 0x%x\n", 506 "realtek: No valid SSID, checking pincfg 0x%08x for NID 0x%x\n",
504 ass, nid); 507 ass, nid);
505 if (!(ass & 1)) 508 if (!(ass & 1))
506 return 0; 509 return 0;
@@ -516,7 +519,7 @@ static int alc_subsystem_id(struct hda_codec *codec, const hda_nid_t *ports)
516 if (((ass >> 16) & 0xf) != tmp) 519 if (((ass >> 16) & 0xf) != tmp)
517 return 0; 520 return 0;
518do_sku: 521do_sku:
519 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", 522 codec_dbg(codec, "realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
520 ass & 0xffff, codec->vendor_id); 523 ass & 0xffff, codec->vendor_id);
521 /* 524 /*
522 * 0 : override 525 * 0 : override
@@ -574,8 +577,8 @@ static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
574{ 577{
575 if (!alc_subsystem_id(codec, ports)) { 578 if (!alc_subsystem_id(codec, ports)) {
576 struct alc_spec *spec = codec->spec; 579 struct alc_spec *spec = codec->spec;
577 snd_printd("realtek: " 580 codec_dbg(codec,
578 "Enable default setup for auto mode as fallback\n"); 581 "realtek: Enable default setup for auto mode as fallback\n");
579 spec->init_amp = ALC_INIT_DEFAULT; 582 spec->init_amp = ALC_INIT_DEFAULT;
580 } 583 }
581} 584}
@@ -845,11 +848,7 @@ static inline void alc_shutup(struct hda_codec *codec)
845 snd_hda_shutup_pins(codec); 848 snd_hda_shutup_pins(codec);
846} 849}
847 850
848static void alc_free(struct hda_codec *codec) 851#define alc_free snd_hda_gen_free
849{
850 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
851 snd_hda_gen_free(codec);
852}
853 852
854#ifdef CONFIG_PM 853#ifdef CONFIG_PM
855static void alc_power_eapd(struct hda_codec *codec) 854static void alc_power_eapd(struct hda_codec *codec)
@@ -970,6 +969,8 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
970 return alc_codec_rename(codec, p->name); 969 return alc_codec_rename(codec, p->name);
971 } 970 }
972 971
972 if (!codec->bus->pci)
973 return 0;
973 for (q = rename_pci_tbl; q->codec_vendor_id; q++) { 974 for (q = rename_pci_tbl; q->codec_vendor_id; q++) {
974 if (q->codec_vendor_id != codec->vendor_id) 975 if (q->codec_vendor_id != codec->vendor_id)
975 continue; 976 continue;
@@ -993,6 +994,7 @@ static int alc_codec_rename_from_preset(struct hda_codec *codec)
993 994
994static const struct snd_pci_quirk beep_white_list[] = { 995static const struct snd_pci_quirk beep_white_list[] = {
995 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), 996 SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
997 SND_PCI_QUIRK(0x1043, 0x115d, "ASUS", 1),
996 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), 998 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
997 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1), 999 SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
998 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), 1000 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
@@ -2786,6 +2788,237 @@ static void alc269_shutup(struct hda_codec *codec)
2786 snd_hda_shutup_pins(codec); 2788 snd_hda_shutup_pins(codec);
2787} 2789}
2788 2790
2791static void alc282_restore_default_value(struct hda_codec *codec)
2792{
2793 int val;
2794
2795 /* Power Down Control */
2796 alc_write_coef_idx(codec, 0x03, 0x0002);
2797 /* FIFO and filter clock */
2798 alc_write_coef_idx(codec, 0x05, 0x0700);
2799 /* DMIC control */
2800 alc_write_coef_idx(codec, 0x07, 0x0200);
2801 /* Analog clock */
2802 val = alc_read_coef_idx(codec, 0x06);
2803 alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0);
2804 /* JD */
2805 val = alc_read_coef_idx(codec, 0x08);
2806 alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c);
2807 /* JD offset1 */
2808 alc_write_coef_idx(codec, 0x0a, 0xcccc);
2809 /* JD offset2 */
2810 alc_write_coef_idx(codec, 0x0b, 0xcccc);
2811 /* LDO1/2/3, DAC/ADC */
2812 alc_write_coef_idx(codec, 0x0e, 0x6e00);
2813 /* JD */
2814 val = alc_read_coef_idx(codec, 0x0f);
2815 alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000);
2816 /* Capless */
2817 val = alc_read_coef_idx(codec, 0x10);
2818 alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00);
2819 /* Class D test 4 */
2820 alc_write_coef_idx(codec, 0x6f, 0x0);
2821 /* IO power down directly */
2822 val = alc_read_coef_idx(codec, 0x0c);
2823 alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0);
2824 /* ANC */
2825 alc_write_coef_idx(codec, 0x34, 0xa0c0);
2826 /* AGC MUX */
2827 val = alc_read_coef_idx(codec, 0x16);
2828 alc_write_coef_idx(codec, 0x16, (val & ~0x0008) | 0x0);
2829 /* DAC simple content protection */
2830 val = alc_read_coef_idx(codec, 0x1d);
2831 alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0);
2832 /* ADC simple content protection */
2833 val = alc_read_coef_idx(codec, 0x1f);
2834 alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0);
2835 /* DAC ADC Zero Detection */
2836 alc_write_coef_idx(codec, 0x21, 0x8804);
2837 /* PLL */
2838 alc_write_coef_idx(codec, 0x63, 0x2902);
2839 /* capless control 2 */
2840 alc_write_coef_idx(codec, 0x68, 0xa080);
2841 /* capless control 3 */
2842 alc_write_coef_idx(codec, 0x69, 0x3400);
2843 /* capless control 4 */
2844 alc_write_coef_idx(codec, 0x6a, 0x2f3e);
2845 /* capless control 5 */
2846 alc_write_coef_idx(codec, 0x6b, 0x0);
2847 /* class D test 2 */
2848 val = alc_read_coef_idx(codec, 0x6d);
2849 alc_write_coef_idx(codec, 0x6d, (val & ~0x0fff) | 0x0900);
2850 /* class D test 3 */
2851 alc_write_coef_idx(codec, 0x6e, 0x110a);
2852 /* class D test 5 */
2853 val = alc_read_coef_idx(codec, 0x70);
2854 alc_write_coef_idx(codec, 0x70, (val & ~0x00f8) | 0x00d8);
2855 /* class D test 6 */
2856 alc_write_coef_idx(codec, 0x71, 0x0014);
2857 /* classD OCP */
2858 alc_write_coef_idx(codec, 0x72, 0xc2ba);
2859 /* classD pure DC test */
2860 val = alc_read_coef_idx(codec, 0x77);
2861 alc_write_coef_idx(codec, 0x77, (val & ~0x0f80) | 0x0);
2862 /* Class D amp control */
2863 alc_write_coef_idx(codec, 0x6c, 0xfc06);
2864}
2865
2866static void alc282_init(struct hda_codec *codec)
2867{
2868 struct alc_spec *spec = codec->spec;
2869 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2870 bool hp_pin_sense;
2871 int coef78;
2872
2873 alc282_restore_default_value(codec);
2874
2875 if (!hp_pin)
2876 return;
2877 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2878 coef78 = alc_read_coef_idx(codec, 0x78);
2879
2880 /* Index 0x78 Direct Drive HP AMP LPM Control 1 */
2881 /* Headphone capless set to high power mode */
2882 alc_write_coef_idx(codec, 0x78, 0x9004);
2883
2884 if (hp_pin_sense)
2885 msleep(2);
2886
2887 snd_hda_codec_write(codec, hp_pin, 0,
2888 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2889
2890 if (hp_pin_sense)
2891 msleep(85);
2892
2893 snd_hda_codec_write(codec, hp_pin, 0,
2894 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2895
2896 if (hp_pin_sense)
2897 msleep(100);
2898
2899 /* Headphone capless set to normal mode */
2900 alc_write_coef_idx(codec, 0x78, coef78);
2901}
2902
2903static void alc282_shutup(struct hda_codec *codec)
2904{
2905 struct alc_spec *spec = codec->spec;
2906 hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
2907 bool hp_pin_sense;
2908 int coef78;
2909
2910 if (!hp_pin) {
2911 alc269_shutup(codec);
2912 return;
2913 }
2914
2915 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2916 coef78 = alc_read_coef_idx(codec, 0x78);
2917 alc_write_coef_idx(codec, 0x78, 0x9004);
2918
2919 if (hp_pin_sense)
2920 msleep(2);
2921
2922 snd_hda_codec_write(codec, hp_pin, 0,
2923 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
2924
2925 if (hp_pin_sense)
2926 msleep(85);
2927
2928 snd_hda_codec_write(codec, hp_pin, 0,
2929 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
2930
2931 if (hp_pin_sense)
2932 msleep(100);
2933
2934 alc_auto_setup_eapd(codec, false);
2935 snd_hda_shutup_pins(codec);
2936 alc_write_coef_idx(codec, 0x78, coef78);
2937}
2938
2939static void alc283_restore_default_value(struct hda_codec *codec)
2940{
2941 int val;
2942
2943 /* Power Down Control */
2944 alc_write_coef_idx(codec, 0x03, 0x0002);
2945 /* FIFO and filter clock */
2946 alc_write_coef_idx(codec, 0x05, 0x0700);
2947 /* DMIC control */
2948 alc_write_coef_idx(codec, 0x07, 0x0200);
2949 /* Analog clock */
2950 val = alc_read_coef_idx(codec, 0x06);
2951 alc_write_coef_idx(codec, 0x06, (val & ~0x00f0) | 0x0);
2952 /* JD */
2953 val = alc_read_coef_idx(codec, 0x08);
2954 alc_write_coef_idx(codec, 0x08, (val & ~0xfffc) | 0x0c2c);
2955 /* JD offset1 */
2956 alc_write_coef_idx(codec, 0x0a, 0xcccc);
2957 /* JD offset2 */
2958 alc_write_coef_idx(codec, 0x0b, 0xcccc);
2959 /* LDO1/2/3, DAC/ADC */
2960 alc_write_coef_idx(codec, 0x0e, 0x6fc0);
2961 /* JD */
2962 val = alc_read_coef_idx(codec, 0x0f);
2963 alc_write_coef_idx(codec, 0x0f, (val & ~0xf800) | 0x1000);
2964 /* Capless */
2965 val = alc_read_coef_idx(codec, 0x10);
2966 alc_write_coef_idx(codec, 0x10, (val & ~0xfc00) | 0x0c00);
2967 /* Class D test 4 */
2968 alc_write_coef_idx(codec, 0x3a, 0x0);
2969 /* IO power down directly */
2970 val = alc_read_coef_idx(codec, 0x0c);
2971 alc_write_coef_idx(codec, 0x0c, (val & ~0xfe00) | 0x0);
2972 /* ANC */
2973 alc_write_coef_idx(codec, 0x22, 0xa0c0);
2974 /* AGC MUX */
2975 val = alc_read_coefex_idx(codec, 0x53, 0x01);
2976 alc_write_coefex_idx(codec, 0x53, 0x01, (val & ~0x000f) | 0x0008);
2977 /* DAC simple content protection */
2978 val = alc_read_coef_idx(codec, 0x1d);
2979 alc_write_coef_idx(codec, 0x1d, (val & ~0x00e0) | 0x0);
2980 /* ADC simple content protection */
2981 val = alc_read_coef_idx(codec, 0x1f);
2982 alc_write_coef_idx(codec, 0x1f, (val & ~0x00e0) | 0x0);
2983 /* DAC ADC Zero Detection */
2984 alc_write_coef_idx(codec, 0x21, 0x8804);
2985 /* PLL */
2986 alc_write_coef_idx(codec, 0x2e, 0x2902);
2987 /* capless control 2 */
2988 alc_write_coef_idx(codec, 0x33, 0xa080);
2989 /* capless control 3 */
2990 alc_write_coef_idx(codec, 0x34, 0x3400);
2991 /* capless control 4 */
2992 alc_write_coef_idx(codec, 0x35, 0x2f3e);
2993 /* capless control 5 */
2994 alc_write_coef_idx(codec, 0x36, 0x0);
2995 /* class D test 2 */
2996 val = alc_read_coef_idx(codec, 0x38);
2997 alc_write_coef_idx(codec, 0x38, (val & ~0x0fff) | 0x0900);
2998 /* class D test 3 */
2999 alc_write_coef_idx(codec, 0x39, 0x110a);
3000 /* class D test 5 */
3001 val = alc_read_coef_idx(codec, 0x3b);
3002 alc_write_coef_idx(codec, 0x3b, (val & ~0x00f8) | 0x00d8);
3003 /* class D test 6 */
3004 alc_write_coef_idx(codec, 0x3c, 0x0014);
3005 /* classD OCP */
3006 alc_write_coef_idx(codec, 0x3d, 0xc2ba);
3007 /* classD pure DC test */
3008 val = alc_read_coef_idx(codec, 0x42);
3009 alc_write_coef_idx(codec, 0x42, (val & ~0x0f80) | 0x0);
3010 /* test mode */
3011 alc_write_coef_idx(codec, 0x49, 0x0);
3012 /* Class D DC enable */
3013 val = alc_read_coef_idx(codec, 0x40);
3014 alc_write_coef_idx(codec, 0x40, (val & ~0xf800) | 0x9800);
3015 /* DC offset */
3016 val = alc_read_coef_idx(codec, 0x42);
3017 alc_write_coef_idx(codec, 0x42, (val & ~0xf000) | 0x2000);
3018 /* Class D amp control */
3019 alc_write_coef_idx(codec, 0x37, 0xfc06);
3020}
3021
2789static void alc283_init(struct hda_codec *codec) 3022static void alc283_init(struct hda_codec *codec)
2790{ 3023{
2791 struct alc_spec *spec = codec->spec; 3024 struct alc_spec *spec = codec->spec;
@@ -2793,6 +3026,8 @@ static void alc283_init(struct hda_codec *codec)
2793 bool hp_pin_sense; 3026 bool hp_pin_sense;
2794 int val; 3027 int val;
2795 3028
3029 alc283_restore_default_value(codec);
3030
2796 if (!hp_pin) 3031 if (!hp_pin)
2797 return; 3032 return;
2798 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); 3033 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
@@ -3169,7 +3404,8 @@ static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
3169 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook; 3404 spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
3170 spec->gen.vmaster_mute_enum = 1; 3405 spec->gen.vmaster_mute_enum = 1;
3171 codec->power_filter = led_power_filter; 3406 codec->power_filter = led_power_filter;
3172 snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid, 3407 codec_dbg(codec,
3408 "Detected mute LED for %x:%d\n", spec->mute_led_nid,
3173 spec->mute_led_polarity); 3409 spec->mute_led_polarity);
3174 break; 3410 break;
3175 } 3411 }
@@ -3295,7 +3531,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
3295 alc_write_coef_idx(codec, 0xb7, 0x802b); 3531 alc_write_coef_idx(codec, 0xb7, 0x802b);
3296 break; 3532 break;
3297 } 3533 }
3298 snd_printdd("Headset jack set to unplugged mode.\n"); 3534 codec_dbg(codec, "Headset jack set to unplugged mode.\n");
3299} 3535}
3300 3536
3301 3537
@@ -3338,7 +3574,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3338 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50); 3574 snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
3339 break; 3575 break;
3340 } 3576 }
3341 snd_printdd("Headset jack set to mic-in mode.\n"); 3577 codec_dbg(codec, "Headset jack set to mic-in mode.\n");
3342} 3578}
3343 3579
3344static void alc_headset_mode_default(struct hda_codec *codec) 3580static void alc_headset_mode_default(struct hda_codec *codec)
@@ -3366,7 +3602,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
3366 alc_write_coef_idx(codec, 0xb7, 0x802b); 3602 alc_write_coef_idx(codec, 0xb7, 0x802b);
3367 break; 3603 break;
3368 } 3604 }
3369 snd_printdd("Headset jack set to headphone (default) mode.\n"); 3605 codec_dbg(codec, "Headset jack set to headphone (default) mode.\n");
3370} 3606}
3371 3607
3372/* Iphone type */ 3608/* Iphone type */
@@ -3395,7 +3631,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
3395 alc_write_coef_idx(codec, 0xc3, 0x0000); 3631 alc_write_coef_idx(codec, 0xc3, 0x0000);
3396 break; 3632 break;
3397 } 3633 }
3398 snd_printdd("Headset jack set to iPhone-style headset mode.\n"); 3634 codec_dbg(codec, "Headset jack set to iPhone-style headset mode.\n");
3399} 3635}
3400 3636
3401/* Nokia type */ 3637/* Nokia type */
@@ -3424,7 +3660,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
3424 alc_write_coef_idx(codec, 0xc3, 0x0000); 3660 alc_write_coef_idx(codec, 0xc3, 0x0000);
3425 break; 3661 break;
3426 } 3662 }
3427 snd_printdd("Headset jack set to Nokia-style headset mode.\n"); 3663 codec_dbg(codec, "Headset jack set to Nokia-style headset mode.\n");
3428} 3664}
3429 3665
3430static void alc_determine_headset_type(struct hda_codec *codec) 3666static void alc_determine_headset_type(struct hda_codec *codec)
@@ -3466,7 +3702,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
3466 break; 3702 break;
3467 } 3703 }
3468 3704
3469 snd_printdd("Headset jack detected iPhone-style headset: %s\n", 3705 codec_dbg(codec, "Headset jack detected iPhone-style headset: %s\n",
3470 is_ctia ? "yes" : "no"); 3706 is_ctia ? "yes" : "no");
3471 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP; 3707 spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
3472} 3708}
@@ -3592,21 +3828,38 @@ static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
3592 alc_fixup_headset_mode(codec, fix, action); 3828 alc_fixup_headset_mode(codec, fix, action);
3593} 3829}
3594 3830
3831static void alc255_set_default_jack_type(struct hda_codec *codec)
3832{
3833 /* Set to iphone type */
3834 alc_write_coef_idx(codec, 0x1b, 0x880b);
3835 alc_write_coef_idx(codec, 0x45, 0xd089);
3836 alc_write_coef_idx(codec, 0x1b, 0x080b);
3837 alc_write_coef_idx(codec, 0x46, 0x0004);
3838 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3839 msleep(30);
3840}
3841
3595static void alc_fixup_headset_mode_alc255(struct hda_codec *codec, 3842static void alc_fixup_headset_mode_alc255(struct hda_codec *codec,
3596 const struct hda_fixup *fix, int action) 3843 const struct hda_fixup *fix, int action)
3597{ 3844{
3598 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 3845 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3599 /* Set to iphone type */ 3846 alc255_set_default_jack_type(codec);
3600 alc_write_coef_idx(codec, 0x1b, 0x880b);
3601 alc_write_coef_idx(codec, 0x45, 0xd089);
3602 alc_write_coef_idx(codec, 0x1b, 0x080b);
3603 alc_write_coef_idx(codec, 0x46, 0x0004);
3604 alc_write_coef_idx(codec, 0x1b, 0x0c0b);
3605 msleep(30);
3606 } 3847 }
3607 alc_fixup_headset_mode(codec, fix, action); 3848 alc_fixup_headset_mode(codec, fix, action);
3608} 3849}
3609 3850
3851static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,
3852 const struct hda_fixup *fix, int action)
3853{
3854 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
3855 struct alc_spec *spec = codec->spec;
3856 spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
3857 alc255_set_default_jack_type(codec);
3858 }
3859 else
3860 alc_fixup_headset_mode(codec, fix, action);
3861}
3862
3610static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec, 3863static void alc_fixup_auto_mute_via_amp(struct hda_codec *codec,
3611 const struct hda_fixup *fix, int action) 3864 const struct hda_fixup *fix, int action)
3612{ 3865{
@@ -3887,7 +4140,9 @@ enum {
3887 ALC290_FIXUP_SUBWOOFER_HSJACK, 4140 ALC290_FIXUP_SUBWOOFER_HSJACK,
3888 ALC269_FIXUP_THINKPAD_ACPI, 4141 ALC269_FIXUP_THINKPAD_ACPI,
3889 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, 4142 ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
4143 ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
3890 ALC255_FIXUP_HEADSET_MODE, 4144 ALC255_FIXUP_HEADSET_MODE,
4145 ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC,
3891}; 4146};
3892 4147
3893static const struct hda_fixup alc269_fixups[] = { 4148static const struct hda_fixup alc269_fixups[] = {
@@ -4264,10 +4519,23 @@ static const struct hda_fixup alc269_fixups[] = {
4264 .chained = true, 4519 .chained = true,
4265 .chain_id = ALC255_FIXUP_HEADSET_MODE 4520 .chain_id = ALC255_FIXUP_HEADSET_MODE
4266 }, 4521 },
4522 [ALC255_FIXUP_DELL2_MIC_NO_PRESENCE] = {
4523 .type = HDA_FIXUP_PINS,
4524 .v.pins = (const struct hda_pintbl[]) {
4525 { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
4526 { }
4527 },
4528 .chained = true,
4529 .chain_id = ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC
4530 },
4267 [ALC255_FIXUP_HEADSET_MODE] = { 4531 [ALC255_FIXUP_HEADSET_MODE] = {
4268 .type = HDA_FIXUP_FUNC, 4532 .type = HDA_FIXUP_FUNC,
4269 .v.func = alc_fixup_headset_mode_alc255, 4533 .v.func = alc_fixup_headset_mode_alc255,
4270 }, 4534 },
4535 [ALC255_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
4536 .type = HDA_FIXUP_FUNC,
4537 .v.func = alc_fixup_headset_mode_alc255_no_hp_mic,
4538 },
4271}; 4539};
4272 4540
4273static const struct snd_pci_quirk alc269_fixup_tbl[] = { 4541static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -4319,6 +4587,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4319 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK), 4587 SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_SUBWOOFER_HSJACK),
4320 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4588 SND_PCI_QUIRK(0x1028, 0x061f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4321 SND_PCI_QUIRK(0x1028, 0x0629, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4589 SND_PCI_QUIRK(0x1028, 0x0629, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4590 SND_PCI_QUIRK(0x1028, 0x062c, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4591 SND_PCI_QUIRK(0x1028, 0x062e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4592 SND_PCI_QUIRK(0x1028, 0x0632, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4322 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK), 4593 SND_PCI_QUIRK(0x1028, 0x0638, "Dell Inspiron 5439", ALC290_FIXUP_MONO_SPEAKERS_HSJACK),
4323 SND_PCI_QUIRK(0x1028, 0x063e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4594 SND_PCI_QUIRK(0x1028, 0x063e, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4324 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4595 SND_PCI_QUIRK(0x1028, 0x063f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
@@ -4331,6 +4602,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4331 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4602 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4332 SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4603 SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4333 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4604 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4605 SND_PCI_QUIRK(0x1028, 0x0668, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4606 SND_PCI_QUIRK(0x1028, 0x0669, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE),
4334 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4607 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4335 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4608 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4336 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), 4609 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
@@ -4573,13 +4846,15 @@ static int patch_alc269(struct hda_codec *codec)
4573 spec->codec_variant = ALC269_TYPE_ALC269VA; 4846 spec->codec_variant = ALC269_TYPE_ALC269VA;
4574 switch (alc_get_coef0(codec) & 0x00f0) { 4847 switch (alc_get_coef0(codec) & 0x00f0) {
4575 case 0x0010: 4848 case 0x0010:
4576 if (codec->bus->pci->subsystem_vendor == 0x1025 && 4849 if (codec->bus->pci &&
4850 codec->bus->pci->subsystem_vendor == 0x1025 &&
4577 spec->cdefine.platform_type == 1) 4851 spec->cdefine.platform_type == 1)
4578 err = alc_codec_rename(codec, "ALC271X"); 4852 err = alc_codec_rename(codec, "ALC271X");
4579 spec->codec_variant = ALC269_TYPE_ALC269VB; 4853 spec->codec_variant = ALC269_TYPE_ALC269VB;
4580 break; 4854 break;
4581 case 0x0020: 4855 case 0x0020:
4582 if (codec->bus->pci->subsystem_vendor == 0x17aa && 4856 if (codec->bus->pci &&
4857 codec->bus->pci->subsystem_vendor == 0x17aa &&
4583 codec->bus->pci->subsystem_device == 0x21f3) 4858 codec->bus->pci->subsystem_device == 0x21f3)
4584 err = alc_codec_rename(codec, "ALC3202"); 4859 err = alc_codec_rename(codec, "ALC3202");
4585 spec->codec_variant = ALC269_TYPE_ALC269VC; 4860 spec->codec_variant = ALC269_TYPE_ALC269VC;
@@ -4602,6 +4877,8 @@ static int patch_alc269(struct hda_codec *codec)
4602 break; 4877 break;
4603 case 0x10ec0282: 4878 case 0x10ec0282:
4604 spec->codec_variant = ALC269_TYPE_ALC282; 4879 spec->codec_variant = ALC269_TYPE_ALC282;
4880 spec->shutup = alc282_shutup;
4881 spec->init_hook = alc282_init;
4605 break; 4882 break;
4606 case 0x10ec0233: 4883 case 0x10ec0233:
4607 case 0x10ec0283: 4884 case 0x10ec0283:
@@ -4919,8 +5196,7 @@ static void alc272_fixup_mario(struct hda_codec *codec,
4919 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | 5196 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
4920 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | 5197 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4921 (0 << AC_AMPCAP_MUTE_SHIFT))) 5198 (0 << AC_AMPCAP_MUTE_SHIFT)))
4922 printk(KERN_WARNING 5199 codec_warn(codec, "failed to override amp caps for NID 0x2\n");
4923 "hda_codec: failed to override amp caps for NID 0x2\n");
4924} 5200}
4925 5201
4926static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = { 5202static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
@@ -4942,8 +5218,54 @@ static void alc_fixup_bass_chmap(struct hda_codec *codec,
4942 } 5218 }
4943} 5219}
4944 5220
5221/* turn on/off mute LED per vmaster hook */
5222static void alc662_led_gpio1_mute_hook(void *private_data, int enabled)
5223{
5224 struct hda_codec *codec = private_data;
5225 struct alc_spec *spec = codec->spec;
5226 unsigned int oldval = spec->gpio_led;
5227
5228 if (enabled)
5229 spec->gpio_led &= ~0x01;
5230 else
5231 spec->gpio_led |= 0x01;
5232 if (spec->gpio_led != oldval)
5233 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
5234 spec->gpio_led);
5235}
5236
5237/* avoid D3 for keeping GPIO up */
5238static unsigned int gpio_led_power_filter(struct hda_codec *codec,
5239 hda_nid_t nid,
5240 unsigned int power_state)
5241{
5242 struct alc_spec *spec = codec->spec;
5243 if (nid == codec->afg && power_state == AC_PWRST_D3 && spec->gpio_led)
5244 return AC_PWRST_D0;
5245 return power_state;
5246}
5247
5248static void alc662_fixup_led_gpio1(struct hda_codec *codec,
5249 const struct hda_fixup *fix, int action)
5250{
5251 struct alc_spec *spec = codec->spec;
5252 static const struct hda_verb gpio_init[] = {
5253 { 0x01, AC_VERB_SET_GPIO_MASK, 0x01 },
5254 { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01 },
5255 {}
5256 };
5257
5258 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
5259 spec->gen.vmaster_mute.hook = alc662_led_gpio1_mute_hook;
5260 spec->gpio_led = 0;
5261 snd_hda_add_verbs(codec, gpio_init);
5262 codec->power_filter = gpio_led_power_filter;
5263 }
5264}
5265
4945enum { 5266enum {
4946 ALC662_FIXUP_ASPIRE, 5267 ALC662_FIXUP_ASPIRE,
5268 ALC662_FIXUP_LED_GPIO1,
4947 ALC662_FIXUP_IDEAPAD, 5269 ALC662_FIXUP_IDEAPAD,
4948 ALC272_FIXUP_MARIO, 5270 ALC272_FIXUP_MARIO,
4949 ALC662_FIXUP_CZC_P10T, 5271 ALC662_FIXUP_CZC_P10T,
@@ -4962,9 +5284,10 @@ enum {
4962 ALC662_FIXUP_INV_DMIC, 5284 ALC662_FIXUP_INV_DMIC,
4963 ALC668_FIXUP_DELL_MIC_NO_PRESENCE, 5285 ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
4964 ALC668_FIXUP_HEADSET_MODE, 5286 ALC668_FIXUP_HEADSET_MODE,
4965 ALC662_FIXUP_BASS_CHMAP, 5287 ALC662_FIXUP_BASS_MODE4_CHMAP,
5288 ALC662_FIXUP_BASS_16,
4966 ALC662_FIXUP_BASS_1A, 5289 ALC662_FIXUP_BASS_1A,
4967 ALC662_FIXUP_BASS_1A_CHMAP, 5290 ALC662_FIXUP_BASS_CHMAP,
4968 ALC668_FIXUP_AUTO_MUTE, 5291 ALC668_FIXUP_AUTO_MUTE,
4969}; 5292};
4970 5293
@@ -4976,12 +5299,18 @@ static const struct hda_fixup alc662_fixups[] = {
4976 { } 5299 { }
4977 } 5300 }
4978 }, 5301 },
5302 [ALC662_FIXUP_LED_GPIO1] = {
5303 .type = HDA_FIXUP_FUNC,
5304 .v.func = alc662_fixup_led_gpio1,
5305 },
4979 [ALC662_FIXUP_IDEAPAD] = { 5306 [ALC662_FIXUP_IDEAPAD] = {
4980 .type = HDA_FIXUP_PINS, 5307 .type = HDA_FIXUP_PINS,
4981 .v.pins = (const struct hda_pintbl[]) { 5308 .v.pins = (const struct hda_pintbl[]) {
4982 { 0x17, 0x99130112 }, /* subwoofer */ 5309 { 0x17, 0x99130112 }, /* subwoofer */
4983 { } 5310 { }
4984 } 5311 },
5312 .chained = true,
5313 .chain_id = ALC662_FIXUP_LED_GPIO1,
4985 }, 5314 },
4986 [ALC272_FIXUP_MARIO] = { 5315 [ALC272_FIXUP_MARIO] = {
4987 .type = HDA_FIXUP_FUNC, 5316 .type = HDA_FIXUP_FUNC,
@@ -5146,24 +5475,33 @@ static const struct hda_fixup alc662_fixups[] = {
5146 .type = HDA_FIXUP_FUNC, 5475 .type = HDA_FIXUP_FUNC,
5147 .v.func = alc_fixup_headset_mode_alc668, 5476 .v.func = alc_fixup_headset_mode_alc668,
5148 }, 5477 },
5149 [ALC662_FIXUP_BASS_CHMAP] = { 5478 [ALC662_FIXUP_BASS_MODE4_CHMAP] = {
5150 .type = HDA_FIXUP_FUNC, 5479 .type = HDA_FIXUP_FUNC,
5151 .v.func = alc_fixup_bass_chmap, 5480 .v.func = alc_fixup_bass_chmap,
5152 .chained = true, 5481 .chained = true,
5153 .chain_id = ALC662_FIXUP_ASUS_MODE4 5482 .chain_id = ALC662_FIXUP_ASUS_MODE4
5154 }, 5483 },
5484 [ALC662_FIXUP_BASS_16] = {
5485 .type = HDA_FIXUP_PINS,
5486 .v.pins = (const struct hda_pintbl[]) {
5487 {0x16, 0x80106111}, /* bass speaker */
5488 {}
5489 },
5490 .chained = true,
5491 .chain_id = ALC662_FIXUP_BASS_CHMAP,
5492 },
5155 [ALC662_FIXUP_BASS_1A] = { 5493 [ALC662_FIXUP_BASS_1A] = {
5156 .type = HDA_FIXUP_PINS, 5494 .type = HDA_FIXUP_PINS,
5157 .v.pins = (const struct hda_pintbl[]) { 5495 .v.pins = (const struct hda_pintbl[]) {
5158 {0x1a, 0x80106111}, /* bass speaker */ 5496 {0x1a, 0x80106111}, /* bass speaker */
5159 {} 5497 {}
5160 }, 5498 },
5499 .chained = true,
5500 .chain_id = ALC662_FIXUP_BASS_CHMAP,
5161 }, 5501 },
5162 [ALC662_FIXUP_BASS_1A_CHMAP] = { 5502 [ALC662_FIXUP_BASS_CHMAP] = {
5163 .type = HDA_FIXUP_FUNC, 5503 .type = HDA_FIXUP_FUNC,
5164 .v.func = alc_fixup_bass_chmap, 5504 .v.func = alc_fixup_bass_chmap,
5165 .chained = true,
5166 .chain_id = ALC662_FIXUP_BASS_1A,
5167 }, 5505 },
5168}; 5506};
5169 5507
@@ -5185,9 +5523,11 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
5185 SND_PCI_QUIRK(0x1028, 0x0628, "Dell", ALC668_FIXUP_AUTO_MUTE), 5523 SND_PCI_QUIRK(0x1028, 0x0628, "Dell", ALC668_FIXUP_AUTO_MUTE),
5186 SND_PCI_QUIRK(0x1028, 0x064e, "Dell", ALC668_FIXUP_AUTO_MUTE), 5524 SND_PCI_QUIRK(0x1028, 0x064e, "Dell", ALC668_FIXUP_AUTO_MUTE),
5187 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 5525 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
5188 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A_CHMAP), 5526 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
5189 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP), 5527 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
5190 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_CHMAP), 5528 SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
5529 SND_PCI_QUIRK(0x1043, 0x1b73, "ASUS N55SF", ALC662_FIXUP_BASS_16),
5530 SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
5191 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), 5531 SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
5192 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), 5532 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
5193 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), 5533 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
@@ -5328,7 +5668,7 @@ static int patch_alc662(struct hda_codec *codec)
5328 spec->gen.beep_nid = 0x01; 5668 spec->gen.beep_nid = 0x01;
5329 5669
5330 if ((alc_get_coef0(codec) & (1 << 14)) && 5670 if ((alc_get_coef0(codec) & (1 << 14)) &&
5331 codec->bus->pci->subsystem_vendor == 0x1025 && 5671 codec->bus->pci && codec->bus->pci->subsystem_vendor == 0x1025 &&
5332 spec->cdefine.platform_type == 1) { 5672 spec->cdefine.platform_type == 1) {
5333 err = alc_codec_rename(codec, "ALC272X"); 5673 err = alc_codec_rename(codec, "ALC272X");
5334 if (err < 0) 5674 if (err < 0)
diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c
index 6679a5095e55..3208ad69583e 100644
--- a/sound/pci/hda/patch_si3054.c
+++ b/sound/pci/hda/patch_si3054.c
@@ -236,7 +236,7 @@ static int si3054_init(struct hda_codec *codec)
236 } while ((val & SI3054_MEI_READY) != SI3054_MEI_READY && wait_count--); 236 } while ((val & SI3054_MEI_READY) != SI3054_MEI_READY && wait_count--);
237 237
238 if((val&SI3054_MEI_READY) != SI3054_MEI_READY) { 238 if((val&SI3054_MEI_READY) != SI3054_MEI_READY) {
239 snd_printk(KERN_ERR "si3054: cannot initialize. EXT MID = %04x\n", val); 239 codec_err(codec, "si3054: cannot initialize. EXT MID = %04x\n", val);
240 /* let's pray that this is no fatal error */ 240 /* let's pray that this is no fatal error */
241 /* return -EACCES; */ 241 /* return -EACCES; */
242 } 242 }
@@ -247,7 +247,8 @@ static int si3054_init(struct hda_codec *codec)
247 SET_REG(codec, SI3054_LINE_CFG1,0x200); 247 SET_REG(codec, SI3054_LINE_CFG1,0x200);
248 248
249 if((GET_REG(codec,SI3054_LINE_STATUS) & (1<<6)) == 0) { 249 if((GET_REG(codec,SI3054_LINE_STATUS) & (1<<6)) == 0) {
250 snd_printd("Link Frame Detect(FDT) is not ready (line status: %04x)\n", 250 codec_dbg(codec,
251 "Link Frame Detect(FDT) is not ready (line status: %04x)\n",
251 GET_REG(codec,SI3054_LINE_STATUS)); 252 GET_REG(codec,SI3054_LINE_STATUS));
252 } 253 }
253 254
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 3bc29c9b2529..75515b494034 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -296,7 +296,7 @@ static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
296{ 296{
297 unsigned int gpiostate, gpiomask, gpiodir; 297 unsigned int gpiostate, gpiomask, gpiodir;
298 298
299 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data); 299 codec_dbg(codec, "%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
300 300
301 gpiostate = snd_hda_codec_read(codec, codec->afg, 0, 301 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
302 AC_VERB_GET_GPIO_DATA, 0); 302 AC_VERB_GET_GPIO_DATA, 0);
@@ -359,7 +359,7 @@ static int stac_vrefout_set(struct hda_codec *codec,
359{ 359{
360 int error, pinctl; 360 int error, pinctl;
361 361
362 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref); 362 codec_dbg(codec, "%s, nid %x ctl %x\n", __func__, nid, new_vref);
363 pinctl = snd_hda_codec_read(codec, nid, 0, 363 pinctl = snd_hda_codec_read(codec, nid, 0,
364 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 364 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
365 365
@@ -2086,9 +2086,12 @@ static void stac92hd83xxx_fixup_hp(struct hda_codec *codec,
2086 } 2086 }
2087 2087
2088 if (find_mute_led_cfg(codec, spec->default_polarity)) 2088 if (find_mute_led_cfg(codec, spec->default_polarity))
2089 snd_printd("mute LED gpio %d polarity %d\n", 2089 codec_dbg(codec, "mute LED gpio %d polarity %d\n",
2090 spec->gpio_led, 2090 spec->gpio_led,
2091 spec->gpio_led_polarity); 2091 spec->gpio_led_polarity);
2092
2093 /* allow auto-switching of dock line-in */
2094 spec->gen.line_in_auto_switch = true;
2092} 2095}
2093 2096
2094static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec, 2097static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec,
@@ -3077,7 +3080,7 @@ static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
3077 } 3080 }
3078 3081
3079 if (find_mute_led_cfg(codec, 1)) 3082 if (find_mute_led_cfg(codec, 1))
3080 snd_printd("mute LED gpio %d polarity %d\n", 3083 codec_dbg(codec, "mute LED gpio %d polarity %d\n",
3081 spec->gpio_led, 3084 spec->gpio_led,
3082 spec->gpio_led_polarity); 3085 spec->gpio_led_polarity);
3083 3086
@@ -4422,8 +4425,8 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
4422 4425
4423 num_dacs = snd_hda_get_num_conns(codec, 0x0a) - 1; 4426 num_dacs = snd_hda_get_num_conns(codec, 0x0a) - 1;
4424 if (num_dacs < 3 || num_dacs > 5) { 4427 if (num_dacs < 3 || num_dacs > 5) {
4425 printk(KERN_WARNING "hda_codec: Could not determine " 4428 codec_warn(codec,
4426 "number of channels defaulting to DAC count\n"); 4429 "Could not determine number of channels defaulting to DAC count\n");
4427 num_dacs = 5; 4430 num_dacs = 5;
4428 } 4431 }
4429 4432
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index f84195f3ea31..778166259b3e 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -465,14 +465,8 @@ static void via_playback_pcm_hook(struct hda_pcm_stream *hinfo,
465 465
466static void via_free(struct hda_codec *codec) 466static void via_free(struct hda_codec *codec)
467{ 467{
468 struct via_spec *spec = codec->spec;
469
470 if (!spec)
471 return;
472
473 vt1708_stop_hp_work(codec); 468 vt1708_stop_hp_work(codec);
474 snd_hda_gen_spec_free(&spec->gen); 469 snd_hda_gen_free(codec);
475 kfree(spec);
476} 470}
477 471
478#ifdef CONFIG_PM 472#ifdef CONFIG_PM
diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c
index 8fe3b8c18ed4..6ba0b5517c40 100644
--- a/sound/pci/hda/thinkpad_helper.c
+++ b/sound/pci/hda/thinkpad_helper.c
@@ -63,7 +63,8 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
63 if (!led_set_func) 63 if (!led_set_func)
64 led_set_func = symbol_request(tpacpi_led_set); 64 led_set_func = symbol_request(tpacpi_led_set);
65 if (!led_set_func) { 65 if (!led_set_func) {
66 snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n"); 66 codec_warn(codec,
67 "Failed to find thinkpad-acpi symbol tpacpi_led_set\n");
67 return; 68 return;
68 } 69 }
69 70
@@ -75,7 +76,8 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
75 } 76 }
76 if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) { 77 if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
77 if (spec->num_adc_nids > 1) 78 if (spec->num_adc_nids > 1)
78 snd_printdd("Skipping micmute LED control due to several ADCs"); 79 codec_dbg(codec,
80 "Skipping micmute LED control due to several ADCs");
79 else { 81 else {
80 spec->cap_sync_hook = update_tpacpi_micmute_led; 82 spec->cap_sync_hook = update_tpacpi_micmute_led;
81 removefunc = false; 83 removefunc = false;
diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c
index 55902ec40344..3b3cf4ac9060 100644
--- a/sound/pci/ice1712/aureon.c
+++ b/sound/pci/ice1712/aureon.c
@@ -1937,9 +1937,12 @@ static int aureon_add_controls(struct snd_ice1712 *ice)
1937 snd_ice1712_save_gpio_status(ice); 1937 snd_ice1712_save_gpio_status(ice);
1938 id = aureon_cs8415_get(ice, CS8415_ID); 1938 id = aureon_cs8415_get(ice, CS8415_ID);
1939 if (id != 0x41) 1939 if (id != 0x41)
1940 snd_printk(KERN_INFO "No CS8415 chip. Skipping CS8415 controls.\n"); 1940 dev_info(ice->card->dev,
1941 "No CS8415 chip. Skipping CS8415 controls.\n");
1941 else if ((id & 0x0F) != 0x01) 1942 else if ((id & 0x0F) != 0x01)
1942 snd_printk(KERN_INFO "Detected unsupported CS8415 rev. (%c)\n", (char)((id & 0x0F) + 'A' - 1)); 1943 dev_info(ice->card->dev,
1944 "Detected unsupported CS8415 rev. (%c)\n",
1945 (char)((id & 0x0F) + 'A' - 1));
1943 else { 1946 else {
1944 for (i = 0; i < ARRAY_SIZE(cs8415_controls); i++) { 1947 for (i = 0; i < ARRAY_SIZE(cs8415_controls); i++) {
1945 struct snd_kcontrol *kctl; 1948 struct snd_kcontrol *kctl;
diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c
index 9e28cc12969b..98e5e955261e 100644
--- a/sound/pci/ice1712/delta.c
+++ b/sound/pci/ice1712/delta.c
@@ -425,7 +425,8 @@ static int snd_ice1712_delta1010lt_wordclock_status_get(struct snd_kcontrol *kco
425 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 425 struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);
426 426
427 if (snd_i2c_sendbytes(ice->cs8427, &reg, 1) != 1) 427 if (snd_i2c_sendbytes(ice->cs8427, &reg, 1) != 1)
428 snd_printk(KERN_ERR "unable to send register 0x%x byte to CS8427\n", reg); 428 dev_err(ice->card->dev,
429 "unable to send register 0x%x byte to CS8427\n", reg);
429 snd_i2c_readbytes(ice->cs8427, &reg, 1); 430 snd_i2c_readbytes(ice->cs8427, &reg, 1);
430 ucontrol->value.integer.value[0] = (reg & CS8427_UNLOCK) ? 1 : 0; 431 ucontrol->value.integer.value[0] = (reg & CS8427_UNLOCK) ? 1 : 0;
431 return 0; 432 return 0;
@@ -637,7 +638,7 @@ static int snd_ice1712_delta_init(struct snd_ice1712 *ice)
637 case ICE1712_SUBDEVICE_VX442: 638 case ICE1712_SUBDEVICE_VX442:
638 case ICE1712_SUBDEVICE_DELTA66E: 639 case ICE1712_SUBDEVICE_DELTA66E:
639 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) { 640 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
640 snd_printk(KERN_ERR "unable to create I2C bus\n"); 641 dev_err(ice->card->dev, "unable to create I2C bus\n");
641 return err; 642 return err;
642 } 643 }
643 ice->i2c->private_data = ice; 644 ice->i2c->private_data = ice;
diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c
index bc2e7011c55d..817a1bc50a60 100644
--- a/sound/pci/ice1712/ews.c
+++ b/sound/pci/ice1712/ews.c
@@ -163,7 +163,8 @@ static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mas
163 163
164 __error: 164 __error:
165 snd_i2c_unlock(ice->i2c); 165 snd_i2c_unlock(ice->i2c);
166 snd_printk(KERN_ERR "AK4524 chip select failed, check cable to the front module\n"); 166 dev_err(ice->card->dev,
167 "AK4524 chip select failed, check cable to the front module\n");
167 return -EIO; 168 return -EIO;
168} 169}
169 170
@@ -174,7 +175,7 @@ static void ews88mt_ak4524_lock(struct snd_akm4xxx *ak, int chip)
174 unsigned char tmp; 175 unsigned char tmp;
175 /* assert AK4524 CS */ 176 /* assert AK4524 CS */
176 if (snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f) < 0) 177 if (snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f) < 0)
177 snd_printk(KERN_ERR "fatal error (ews88mt chip select)\n"); 178 dev_err(ice->card->dev, "fatal error (ews88mt chip select)\n");
178 snd_ice1712_save_gpio_status(ice); 179 snd_ice1712_save_gpio_status(ice);
179 tmp = ICE1712_EWS88_SERIAL_DATA | 180 tmp = ICE1712_EWS88_SERIAL_DATA |
180 ICE1712_EWS88_SERIAL_CLOCK | 181 ICE1712_EWS88_SERIAL_CLOCK |
@@ -456,7 +457,7 @@ static int snd_ice1712_ews_init(struct snd_ice1712 *ice)
456 457
457 /* create i2c */ 458 /* create i2c */
458 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) { 459 if ((err = snd_i2c_bus_create(ice->card, "ICE1712 GPIO 1", NULL, &ice->i2c)) < 0) {
459 snd_printk(KERN_ERR "unable to create I2C bus\n"); 460 dev_err(ice->card->dev, "unable to create I2C bus\n");
460 return err; 461 return err;
461 } 462 }
462 ice->i2c->private_data = ice; 463 ice->i2c->private_data = ice;
@@ -469,7 +470,8 @@ static int snd_ice1712_ews_init(struct snd_ice1712 *ice)
469 ICE1712_6FIRE_PCF9554_ADDR, 470 ICE1712_6FIRE_PCF9554_ADDR,
470 &spec->i2cdevs[EWS_I2C_6FIRE]); 471 &spec->i2cdevs[EWS_I2C_6FIRE]);
471 if (err < 0) { 472 if (err < 0) {
472 snd_printk(KERN_ERR "PCF9554 initialization failed\n"); 473 dev_err(ice->card->dev,
474 "PCF9554 initialization failed\n");
473 return err; 475 return err;
474 } 476 }
475 snd_ice1712_6fire_write_pca(ice, PCF9554_REG_CONFIG, 0x80); 477 snd_ice1712_6fire_write_pca(ice, PCF9554_REG_CONFIG, 0x80);
@@ -834,7 +836,7 @@ static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg
834 byte = 0; 836 byte = 0;
835 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) { 837 if (snd_i2c_readbytes(spec->i2cdevs[EWS_I2C_6FIRE], &byte, 1) != 1) {
836 snd_i2c_unlock(ice->i2c); 838 snd_i2c_unlock(ice->i2c);
837 printk(KERN_ERR "cannot read pca\n"); 839 dev_err(ice->card->dev, "cannot read pca\n");
838 return -EIO; 840 return -EIO;
839 } 841 }
840 snd_i2c_unlock(ice->i2c); 842 snd_i2c_unlock(ice->i2c);
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 28ec872e54c0..0710ec7e69d3 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -394,7 +394,7 @@ int snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr)
394 err = snd_cs8427_create(ice->i2c, addr, 394 err = snd_cs8427_create(ice->i2c, addr,
395 (ice->cs8427_timeout * HZ) / 1000, &ice->cs8427); 395 (ice->cs8427_timeout * HZ) / 1000, &ice->cs8427);
396 if (err < 0) { 396 if (err < 0) {
397 snd_printk(KERN_ERR "CS8427 initialization failed\n"); 397 dev_err(ice->card->dev, "CS8427 initialization failed\n");
398 return err; 398 return err;
399 } 399 }
400 ice->spdif.ops.open = open_cs8427; 400 ice->spdif.ops.open = open_cs8427;
@@ -467,7 +467,7 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id)
467 u16 pbkstatus; 467 u16 pbkstatus;
468 struct snd_pcm_substream *substream; 468 struct snd_pcm_substream *substream;
469 pbkstatus = inw(ICEDS(ice, INTSTAT)); 469 pbkstatus = inw(ICEDS(ice, INTSTAT));
470 /* printk(KERN_DEBUG "pbkstatus = 0x%x\n", pbkstatus); */ 470 /* dev_dbg(ice->card->dev, "pbkstatus = 0x%x\n", pbkstatus); */
471 for (idx = 0; idx < 6; idx++) { 471 for (idx = 0; idx < 6; idx++) {
472 if ((pbkstatus & (3 << (idx * 2))) == 0) 472 if ((pbkstatus & (3 << (idx * 2))) == 0)
473 continue; 473 continue;
@@ -903,7 +903,8 @@ static int snd_ice1712_pcm(struct snd_ice1712 *ice, int device, struct snd_pcm *
903 if (rpcm) 903 if (rpcm)
904 *rpcm = pcm; 904 *rpcm = pcm;
905 905
906 printk(KERN_WARNING "Consumer PCM code does not work well at the moment --jk\n"); 906 dev_warn(ice->card->dev,
907 "Consumer PCM code does not work well at the moment --jk\n");
907 908
908 return 0; 909 return 0;
909} 910}
@@ -1534,7 +1535,8 @@ static int snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
1534 ac97.private_free = snd_ice1712_mixer_free_ac97; 1535 ac97.private_free = snd_ice1712_mixer_free_ac97;
1535 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); 1536 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
1536 if (err < 0) 1537 if (err < 0)
1537 printk(KERN_WARNING "ice1712: cannot initialize ac97 for consumer, skipped\n"); 1538 dev_warn(ice->card->dev,
1539 "cannot initialize ac97 for consumer, skipped\n");
1538 else { 1540 else {
1539 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice)); 1541 err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice));
1540 if (err < 0) 1542 if (err < 0)
@@ -1552,7 +1554,8 @@ static int snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
1552 ac97.private_free = snd_ice1712_mixer_free_ac97; 1554 ac97.private_free = snd_ice1712_mixer_free_ac97;
1553 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); 1555 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
1554 if (err < 0) 1556 if (err < 0)
1555 printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n"); 1557 dev_warn(ice->card->dev,
1558 "cannot initialize pro ac97, skipped\n");
1556 else 1559 else
1557 return 0; 1560 return 0;
1558 } 1561 }
@@ -2332,7 +2335,8 @@ static int snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2332 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device); 2335 pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device);
2333 ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device); 2336 ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device);
2334 if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) { 2337 if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) {
2335 printk(KERN_ERR "ice1712: No valid ID is found\n"); 2338 dev_err(ice->card->dev,
2339 "No valid ID is found\n");
2336 return -ENXIO; 2340 return -ENXIO;
2337 } 2341 }
2338 } 2342 }
@@ -2340,21 +2344,22 @@ static int snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2340 for (tbl = card_tables; *tbl; tbl++) { 2344 for (tbl = card_tables; *tbl; tbl++) {
2341 for (c = *tbl; c->subvendor; c++) { 2345 for (c = *tbl; c->subvendor; c++) {
2342 if (modelname && c->model && !strcmp(modelname, c->model)) { 2346 if (modelname && c->model && !strcmp(modelname, c->model)) {
2343 printk(KERN_INFO "ice1712: Using board model %s\n", c->name); 2347 dev_info(ice->card->dev,
2348 "Using board model %s\n", c->name);
2344 ice->eeprom.subvendor = c->subvendor; 2349 ice->eeprom.subvendor = c->subvendor;
2345 } else if (c->subvendor != ice->eeprom.subvendor) 2350 } else if (c->subvendor != ice->eeprom.subvendor)
2346 continue; 2351 continue;
2347 if (!c->eeprom_size || !c->eeprom_data) 2352 if (!c->eeprom_size || !c->eeprom_data)
2348 goto found; 2353 goto found;
2349 /* if the EEPROM is given by the driver, use it */ 2354 /* if the EEPROM is given by the driver, use it */
2350 snd_printdd("using the defined eeprom..\n"); 2355 dev_dbg(ice->card->dev, "using the defined eeprom..\n");
2351 ice->eeprom.version = 1; 2356 ice->eeprom.version = 1;
2352 ice->eeprom.size = c->eeprom_size + 6; 2357 ice->eeprom.size = c->eeprom_size + 6;
2353 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size); 2358 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
2354 goto read_skipped; 2359 goto read_skipped;
2355 } 2360 }
2356 } 2361 }
2357 printk(KERN_WARNING "ice1712: No matching model found for ID 0x%x\n", 2362 dev_warn(ice->card->dev, "No matching model found for ID 0x%x\n",
2358 ice->eeprom.subvendor); 2363 ice->eeprom.subvendor);
2359 2364
2360 found: 2365 found:
@@ -2362,12 +2367,13 @@ static int snd_ice1712_read_eeprom(struct snd_ice1712 *ice,
2362 if (ice->eeprom.size < 6) 2367 if (ice->eeprom.size < 6)
2363 ice->eeprom.size = 32; /* FIXME: any cards without the correct size? */ 2368 ice->eeprom.size = 32; /* FIXME: any cards without the correct size? */
2364 else if (ice->eeprom.size > 32) { 2369 else if (ice->eeprom.size > 32) {
2365 snd_printk(KERN_ERR "invalid EEPROM (size = %i)\n", ice->eeprom.size); 2370 dev_err(ice->card->dev,
2371 "invalid EEPROM (size = %i)\n", ice->eeprom.size);
2366 return -EIO; 2372 return -EIO;
2367 } 2373 }
2368 ice->eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05); 2374 ice->eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05);
2369 if (ice->eeprom.version != 1) { 2375 if (ice->eeprom.version != 1) {
2370 snd_printk(KERN_ERR "invalid EEPROM version %i\n", 2376 dev_err(ice->card->dev, "invalid EEPROM version %i\n",
2371 ice->eeprom.version); 2377 ice->eeprom.version);
2372 /* return -EIO; */ 2378 /* return -EIO; */
2373 } 2379 }
@@ -2553,7 +2559,8 @@ static int snd_ice1712_create(struct snd_card *card,
2553 /* check, if we can restrict PCI DMA transfers to 28 bits */ 2559 /* check, if we can restrict PCI DMA transfers to 28 bits */
2554 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 2560 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
2555 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 2561 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
2556 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); 2562 dev_err(card->dev,
2563 "architecture does not support 28bit PCI busmaster DMA\n");
2557 pci_disable_device(pci); 2564 pci_disable_device(pci);
2558 return -ENXIO; 2565 return -ENXIO;
2559 } 2566 }
@@ -2609,7 +2616,7 @@ static int snd_ice1712_create(struct snd_card *card,
2609 2616
2610 if (request_irq(pci->irq, snd_ice1712_interrupt, IRQF_SHARED, 2617 if (request_irq(pci->irq, snd_ice1712_interrupt, IRQF_SHARED,
2611 KBUILD_MODNAME, ice)) { 2618 KBUILD_MODNAME, ice)) {
2612 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2619 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2613 snd_ice1712_free(ice); 2620 snd_ice1712_free(ice);
2614 return -EIO; 2621 return -EIO;
2615 } 2622 }
@@ -2639,8 +2646,6 @@ static int snd_ice1712_create(struct snd_card *card,
2639 return err; 2646 return err;
2640 } 2647 }
2641 2648
2642 snd_card_set_dev(card, &pci->dev);
2643
2644 *r_ice1712 = ice; 2649 *r_ice1712 = ice;
2645 return 0; 2650 return 0;
2646} 2651}
@@ -2670,7 +2675,8 @@ static int snd_ice1712_probe(struct pci_dev *pci,
2670 return -ENOENT; 2675 return -ENOENT;
2671 } 2676 }
2672 2677
2673 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2678 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2679 0, &card);
2674 if (err < 0) 2680 if (err < 0)
2675 return err; 2681 return err;
2676 2682
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 500471778291..5e7948f3efe9 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -146,7 +146,7 @@ static unsigned char snd_vt1724_ac97_ready(struct snd_ice1712 *ice)
146 continue; 146 continue;
147 return old_cmd; 147 return old_cmd;
148 } 148 }
149 snd_printd(KERN_ERR "snd_vt1724_ac97_ready: timeout\n"); 149 dev_dbg(ice->card->dev, "snd_vt1724_ac97_ready: timeout\n");
150 return old_cmd; 150 return old_cmd;
151} 151}
152 152
@@ -156,7 +156,7 @@ static int snd_vt1724_ac97_wait_bit(struct snd_ice1712 *ice, unsigned char bit)
156 for (tm = 0; tm < 0x10000; tm++) 156 for (tm = 0; tm < 0x10000; tm++)
157 if ((inb(ICEMT1724(ice, AC97_CMD)) & bit) == 0) 157 if ((inb(ICEMT1724(ice, AC97_CMD)) & bit) == 0)
158 return 0; 158 return 0;
159 snd_printd(KERN_ERR "snd_vt1724_ac97_wait_bit: timeout\n"); 159 dev_dbg(ice->card->dev, "snd_vt1724_ac97_wait_bit: timeout\n");
160 return -EIO; 160 return -EIO;
161} 161}
162 162
@@ -430,10 +430,10 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
430 spin_lock(&ice->reg_lock); 430 spin_lock(&ice->reg_lock);
431 if (++timeout > 10) { 431 if (++timeout > 10) {
432 status = inb(ICEREG1724(ice, IRQSTAT)); 432 status = inb(ICEREG1724(ice, IRQSTAT));
433 printk(KERN_ERR "ice1724: Too long irq loop, " 433 dev_err(ice->card->dev,
434 "status = 0x%x\n", status); 434 "Too long irq loop, status = 0x%x\n", status);
435 if (status & VT1724_IRQ_MPU_TX) { 435 if (status & VT1724_IRQ_MPU_TX) {
436 printk(KERN_ERR "ice1724: Disabling MPU_TX\n"); 436 dev_err(ice->card->dev, "Disabling MPU_TX\n");
437 enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0); 437 enable_midi_irq(ice, VT1724_IRQ_MPU_TX, 0);
438 } 438 }
439 spin_unlock(&ice->reg_lock); 439 spin_unlock(&ice->reg_lock);
@@ -801,7 +801,7 @@ static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream)
801 spin_unlock_irq(&ice->reg_lock); 801 spin_unlock_irq(&ice->reg_lock);
802 802
803 /* 803 /*
804 printk(KERN_DEBUG "pro prepare: ch = %d, addr = 0x%x, " 804 dev_dbg(ice->card->dev, "pro prepare: ch = %d, addr = 0x%x, "
805 "buffer = 0x%x, period = 0x%x\n", 805 "buffer = 0x%x, period = 0x%x\n",
806 substream->runtime->channels, 806 substream->runtime->channels,
807 (unsigned int)substream->runtime->dma_addr, 807 (unsigned int)substream->runtime->dma_addr,
@@ -821,13 +821,13 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substrea
821#if 0 /* read PLAYBACK_ADDR */ 821#if 0 /* read PLAYBACK_ADDR */
822 ptr = inl(ICEMT1724(ice, PLAYBACK_ADDR)); 822 ptr = inl(ICEMT1724(ice, PLAYBACK_ADDR));
823 if (ptr < substream->runtime->dma_addr) { 823 if (ptr < substream->runtime->dma_addr) {
824 snd_printd("ice1724: invalid negative ptr\n"); 824 dev_dbg(ice->card->dev, "invalid negative ptr\n");
825 return 0; 825 return 0;
826 } 826 }
827 ptr -= substream->runtime->dma_addr; 827 ptr -= substream->runtime->dma_addr;
828 ptr = bytes_to_frames(substream->runtime, ptr); 828 ptr = bytes_to_frames(substream->runtime, ptr);
829 if (ptr >= substream->runtime->buffer_size) { 829 if (ptr >= substream->runtime->buffer_size) {
830 snd_printd("ice1724: invalid ptr %d (size=%d)\n", 830 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
831 (int)ptr, (int)substream->runtime->period_size); 831 (int)ptr, (int)substream->runtime->period_size);
832 return 0; 832 return 0;
833 } 833 }
@@ -840,7 +840,7 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substrea
840 else if (ptr <= substream->runtime->buffer_size) 840 else if (ptr <= substream->runtime->buffer_size)
841 ptr = substream->runtime->buffer_size - ptr; 841 ptr = substream->runtime->buffer_size - ptr;
842 else { 842 else {
843 snd_printd("ice1724: invalid ptr %d (size=%d)\n", 843 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
844 (int)ptr, (int)substream->runtime->buffer_size); 844 (int)ptr, (int)substream->runtime->buffer_size);
845 ptr = 0; 845 ptr = 0;
846 } 846 }
@@ -884,7 +884,7 @@ static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substr
884 else if (ptr <= substream->runtime->buffer_size) 884 else if (ptr <= substream->runtime->buffer_size)
885 ptr = substream->runtime->buffer_size - ptr; 885 ptr = substream->runtime->buffer_size - ptr;
886 else { 886 else {
887 snd_printd("ice1724: invalid ptr %d (size=%d)\n", 887 dev_dbg(ice->card->dev, "invalid ptr %d (size=%d)\n",
888 (int)ptr, (int)substream->runtime->buffer_size); 888 (int)ptr, (int)substream->runtime->buffer_size);
889 ptr = 0; 889 ptr = 0;
890 } 890 }
@@ -1508,7 +1508,8 @@ static int snd_vt1724_ac97_mixer(struct snd_ice1712 *ice)
1508 ac97.private_data = ice; 1508 ac97.private_data = ice;
1509 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97); 1509 err = snd_ac97_mixer(pbus, &ac97, &ice->ac97);
1510 if (err < 0) 1510 if (err < 0)
1511 printk(KERN_WARNING "ice1712: cannot initialize pro ac97, skipped\n"); 1511 dev_warn(ice->card->dev,
1512 "cannot initialize pro ac97, skipped\n");
1512 else 1513 else
1513 return 0; 1514 return 0;
1514 } 1515 }
@@ -2271,7 +2272,7 @@ static void wait_i2c_busy(struct snd_ice1712 *ice)
2271 while ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_BUSY) && t--) 2272 while ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_BUSY) && t--)
2272 ; 2273 ;
2273 if (t == -1) 2274 if (t == -1)
2274 printk(KERN_ERR "ice1724: i2c busy timeout\n"); 2275 dev_err(ice->card->dev, "i2c busy timeout\n");
2275} 2276}
2276 2277
2277unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice, 2278unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
@@ -2287,7 +2288,7 @@ unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice,
2287 val = inb(ICEREG1724(ice, I2C_DATA)); 2288 val = inb(ICEREG1724(ice, I2C_DATA));
2288 mutex_unlock(&ice->i2c_mutex); 2289 mutex_unlock(&ice->i2c_mutex);
2289 /* 2290 /*
2290 printk(KERN_DEBUG "i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val); 2291 dev_dbg(ice->card->dev, "i2c_read: [0x%x,0x%x] = 0x%x\n", dev, addr, val);
2291 */ 2292 */
2292 return val; 2293 return val;
2293} 2294}
@@ -2298,7 +2299,7 @@ void snd_vt1724_write_i2c(struct snd_ice1712 *ice,
2298 mutex_lock(&ice->i2c_mutex); 2299 mutex_lock(&ice->i2c_mutex);
2299 wait_i2c_busy(ice); 2300 wait_i2c_busy(ice);
2300 /* 2301 /*
2301 printk(KERN_DEBUG "i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data); 2302 dev_dbg(ice->card->dev, "i2c_write: [0x%x,0x%x] = 0x%x\n", dev, addr, data);
2302 */ 2303 */
2303 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR)); 2304 outb(addr, ICEREG1724(ice, I2C_BYTE_ADDR));
2304 outb(data, ICEREG1724(ice, I2C_DATA)); 2305 outb(data, ICEREG1724(ice, I2C_DATA));
@@ -2335,7 +2336,8 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2335 ((unsigned int)swab16(vendor) << 16) | swab16(device); 2336 ((unsigned int)swab16(vendor) << 16) | swab16(device);
2336 if (ice->eeprom.subvendor == 0 || 2337 if (ice->eeprom.subvendor == 0 ||
2337 ice->eeprom.subvendor == (unsigned int)-1) { 2338 ice->eeprom.subvendor == (unsigned int)-1) {
2338 printk(KERN_ERR "ice1724: No valid ID is found\n"); 2339 dev_err(ice->card->dev,
2340 "No valid ID is found\n");
2339 return -ENXIO; 2341 return -ENXIO;
2340 } 2342 }
2341 } 2343 }
@@ -2344,7 +2346,8 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2344 for (c = *tbl; c->name; c++) { 2346 for (c = *tbl; c->name; c++) {
2345 if (modelname && c->model && 2347 if (modelname && c->model &&
2346 !strcmp(modelname, c->model)) { 2348 !strcmp(modelname, c->model)) {
2347 printk(KERN_INFO "ice1724: Using board model %s\n", 2349 dev_info(ice->card->dev,
2350 "Using board model %s\n",
2348 c->name); 2351 c->name);
2349 ice->eeprom.subvendor = c->subvendor; 2352 ice->eeprom.subvendor = c->subvendor;
2350 } else if (c->subvendor != ice->eeprom.subvendor) 2353 } else if (c->subvendor != ice->eeprom.subvendor)
@@ -2353,14 +2356,14 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2353 if (!c->eeprom_size || !c->eeprom_data) 2356 if (!c->eeprom_size || !c->eeprom_data)
2354 goto found; 2357 goto found;
2355 /* if the EEPROM is given by the driver, use it */ 2358 /* if the EEPROM is given by the driver, use it */
2356 snd_printdd("using the defined eeprom..\n"); 2359 dev_dbg(ice->card->dev, "using the defined eeprom..\n");
2357 ice->eeprom.version = 2; 2360 ice->eeprom.version = 2;
2358 ice->eeprom.size = c->eeprom_size + 6; 2361 ice->eeprom.size = c->eeprom_size + 6;
2359 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size); 2362 memcpy(ice->eeprom.data, c->eeprom_data, c->eeprom_size);
2360 goto read_skipped; 2363 goto read_skipped;
2361 } 2364 }
2362 } 2365 }
2363 printk(KERN_WARNING "ice1724: No matching model found for ID 0x%x\n", 2366 dev_warn(ice->card->dev, "No matching model found for ID 0x%x\n",
2364 ice->eeprom.subvendor); 2367 ice->eeprom.subvendor);
2365#ifdef CONFIG_PM_SLEEP 2368#ifdef CONFIG_PM_SLEEP
2366 /* assume AC97-only card which can suspend without additional code */ 2369 /* assume AC97-only card which can suspend without additional code */
@@ -2372,13 +2375,13 @@ static int snd_vt1724_read_eeprom(struct snd_ice1712 *ice,
2372 if (ice->eeprom.size < 6) 2375 if (ice->eeprom.size < 6)
2373 ice->eeprom.size = 32; 2376 ice->eeprom.size = 32;
2374 else if (ice->eeprom.size > 32) { 2377 else if (ice->eeprom.size > 32) {
2375 printk(KERN_ERR "ice1724: Invalid EEPROM (size = %i)\n", 2378 dev_err(ice->card->dev, "Invalid EEPROM (size = %i)\n",
2376 ice->eeprom.size); 2379 ice->eeprom.size);
2377 return -EIO; 2380 return -EIO;
2378 } 2381 }
2379 ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05); 2382 ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05);
2380 if (ice->eeprom.version != 1 && ice->eeprom.version != 2) 2383 if (ice->eeprom.version != 1 && ice->eeprom.version != 2)
2381 printk(KERN_WARNING "ice1724: Invalid EEPROM version %i\n", 2384 dev_warn(ice->card->dev, "Invalid EEPROM version %i\n",
2382 ice->eeprom.version); 2385 ice->eeprom.version);
2383 size = ice->eeprom.size - 6; 2386 size = ice->eeprom.size - 6;
2384 for (i = 0; i < size; i++) 2387 for (i = 0; i < size; i++)
@@ -2586,7 +2589,7 @@ static int snd_vt1724_create(struct snd_card *card,
2586 2589
2587 if (request_irq(pci->irq, snd_vt1724_interrupt, 2590 if (request_irq(pci->irq, snd_vt1724_interrupt,
2588 IRQF_SHARED, KBUILD_MODNAME, ice)) { 2591 IRQF_SHARED, KBUILD_MODNAME, ice)) {
2589 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2592 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2590 snd_vt1724_free(ice); 2593 snd_vt1724_free(ice);
2591 return -EIO; 2594 return -EIO;
2592 } 2595 }
@@ -2609,8 +2612,6 @@ static int snd_vt1724_create(struct snd_card *card,
2609 return err; 2612 return err;
2610 } 2613 }
2611 2614
2612 snd_card_set_dev(card, &pci->dev);
2613
2614 *r_ice1712 = ice; 2615 *r_ice1712 = ice;
2615 return 0; 2616 return 0;
2616} 2617}
@@ -2638,7 +2639,8 @@ static int snd_vt1724_probe(struct pci_dev *pci,
2638 return -ENOENT; 2639 return -ENOENT;
2639 } 2640 }
2640 2641
2641 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2642 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2643 0, &card);
2642 if (err < 0) 2644 if (err < 0)
2643 return err; 2645 return err;
2644 2646
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index 8855933e710d..7a6c0786c55c 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -244,7 +244,7 @@ static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
244 /* AK5385 first, since it requires cold reset affecting both codecs */ 244 /* AK5385 first, since it requires cold reset affecting both codecs */
245 old_gpio = ice->gpio.get_data(ice); 245 old_gpio = ice->gpio.get_data(ice);
246 new_gpio = (old_gpio & ~GPIO_AK5385A_MASK) | ak5385_pins; 246 new_gpio = (old_gpio & ~GPIO_AK5385A_MASK) | ak5385_pins;
247 /* printk(KERN_DEBUG "JULI - ak5385 set_rate_val: new gpio 0x%x\n", 247 /* dev_dbg(ice->card->dev, "JULI - ak5385 set_rate_val: new gpio 0x%x\n",
248 new_gpio); */ 248 new_gpio); */
249 ice->gpio.set_data(ice, new_gpio); 249 ice->gpio.set_data(ice, new_gpio);
250 250
@@ -344,7 +344,7 @@ static int juli_mute_put(struct snd_kcontrol *kcontrol,
344 new_gpio = old_gpio & 344 new_gpio = old_gpio &
345 ~((unsigned int) kcontrol->private_value); 345 ~((unsigned int) kcontrol->private_value);
346 } 346 }
347 /* printk(KERN_DEBUG 347 /* dev_dbg(ice->card->dev,
348 "JULI - mute/unmute: control_value: 0x%x, old_gpio: 0x%x, " 348 "JULI - mute/unmute: control_value: 0x%x, old_gpio: 0x%x, "
349 "new_gpio 0x%x\n", 349 "new_gpio 0x%x\n",
350 (unsigned int)ucontrol->value.integer.value[0], old_gpio, 350 (unsigned int)ucontrol->value.integer.value[0], old_gpio,
@@ -439,9 +439,9 @@ static void add_slaves(struct snd_card *card,
439{ 439{
440 for (; *list; list++) { 440 for (; *list; list++) {
441 struct snd_kcontrol *slave = ctl_find(card, *list); 441 struct snd_kcontrol *slave = ctl_find(card, *list);
442 /* printk(KERN_DEBUG "add_slaves - %s\n", *list); */ 442 /* dev_dbg(card->dev, "add_slaves - %s\n", *list); */
443 if (slave) { 443 if (slave) {
444 /* printk(KERN_DEBUG "slave %s found\n", *list); */ 444 /* dev_dbg(card->dev, "slave %s found\n", *list); */
445 snd_ctl_add_slave(master, slave); 445 snd_ctl_add_slave(master, slave);
446 } 446 }
447 } 447 }
@@ -536,7 +536,7 @@ static void juli_set_rate(struct snd_ice1712 *ice, unsigned int rate)
536 536
537 old = ice->gpio.get_data(ice); 537 old = ice->gpio.get_data(ice);
538 new = (old & ~GPIO_RATE_MASK) | get_gpio_val(rate); 538 new = (old & ~GPIO_RATE_MASK) | get_gpio_val(rate);
539 /* printk(KERN_DEBUG "JULI - set_rate: old %x, new %x\n", 539 /* dev_dbg(ice->card->dev, "JULI - set_rate: old %x, new %x\n",
540 old & GPIO_RATE_MASK, 540 old & GPIO_RATE_MASK,
541 new & GPIO_RATE_MASK); */ 541 new & GPIO_RATE_MASK); */
542 542
@@ -573,7 +573,7 @@ static void juli_ak4114_change(struct ak4114 *ak4114, unsigned char c0,
573 if (ice->is_spdif_master(ice) && c1) { 573 if (ice->is_spdif_master(ice) && c1) {
574 /* only for SPDIF master mode, rate was changed */ 574 /* only for SPDIF master mode, rate was changed */
575 rate = snd_ak4114_external_rate(ak4114); 575 rate = snd_ak4114_external_rate(ak4114);
576 /* printk(KERN_DEBUG "ak4114 - input rate changed to %d\n", 576 /* dev_dbg(ice->card->dev, "ak4114 - input rate changed to %d\n",
577 rate); */ 577 rate); */
578 juli_akm_set_rate_val(ice->akm, rate); 578 juli_akm_set_rate_val(ice->akm, rate);
579 } 579 }
@@ -628,7 +628,7 @@ static int juli_init(struct snd_ice1712 *ice)
628#endif 628#endif
629 629
630 if (spec->analog) { 630 if (spec->analog) {
631 printk(KERN_INFO "juli@: analog I/O detected\n"); 631 dev_info(ice->card->dev, "juli@: analog I/O detected\n");
632 ice->num_total_dacs = 2; 632 ice->num_total_dacs = 2;
633 ice->num_total_adcs = 2; 633 ice->num_total_adcs = 2;
634 634
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index e610339f7601..f3b491aa3e22 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -98,7 +98,7 @@ static int stac9460_dac_mute(struct snd_ice1712 *ice, int idx,
98 new = (~mute << 7 & 0x80) | (old & ~0x80); 98 new = (~mute << 7 & 0x80) | (old & ~0x80);
99 change = (new != old); 99 change = (new != old);
100 if (change) 100 if (change)
101 /*printk ("Volume register 0x%02x: 0x%02x\n", idx, new);*/ 101 /* dev_dbg(ice->card->dev, "Volume register 0x%02x: 0x%02x\n", idx, new);*/
102 stac9460_put(ice, idx, new); 102 stac9460_put(ice, idx, new);
103 return change; 103 return change;
104} 104}
@@ -133,7 +133,7 @@ static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
133 /* due to possible conflicts with stac9460_set_rate_val, mutexing */ 133 /* due to possible conflicts with stac9460_set_rate_val, mutexing */
134 mutex_lock(&spec->mute_mutex); 134 mutex_lock(&spec->mute_mutex);
135 /* 135 /*
136 printk(KERN_DEBUG "Mute put: reg 0x%02x, ctrl value: 0x%02x\n", idx, 136 dev_dbg(ice->card->dev, "Mute put: reg 0x%02x, ctrl value: 0x%02x\n", idx,
137 ucontrol->value.integer.value[0]); 137 ucontrol->value.integer.value[0]);
138 */ 138 */
139 change = stac9460_dac_mute(ice, idx, ucontrol->value.integer.value[0]); 139 change = stac9460_dac_mute(ice, idx, ucontrol->value.integer.value[0]);
@@ -187,7 +187,7 @@ static int stac9460_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_el
187 if (change) { 187 if (change) {
188 ovol = (0x7f - nvol) | (tmp & 0x80); 188 ovol = (0x7f - nvol) | (tmp & 0x80);
189 /* 189 /*
190 printk(KERN_DEBUG "DAC Volume: reg 0x%02x: 0x%02x\n", 190 dev_dbg(ice->card->dev, "DAC Volume: reg 0x%02x: 0x%02x\n",
191 idx, ovol); 191 idx, ovol);
192 */ 192 */
193 stac9460_put(ice, idx, (0x7f - nvol) | (tmp & 0x80)); 193 stac9460_put(ice, idx, (0x7f - nvol) | (tmp & 0x80));
@@ -348,7 +348,7 @@ static void stac9460_set_rate_val(struct snd_ice1712 *ice, unsigned int rate)
348 for (idx = 0; idx < 7 ; ++idx) 348 for (idx = 0; idx < 7 ; ++idx)
349 changed[idx] = stac9460_dac_mute(ice, 349 changed[idx] = stac9460_dac_mute(ice,
350 STAC946X_MASTER_VOLUME + idx, 0); 350 STAC946X_MASTER_VOLUME + idx, 0);
351 /*printk(KERN_DEBUG "Rate change: %d, new MC: 0x%02x\n", rate, new);*/ 351 /*dev_dbg(ice->card->dev, "Rate change: %d, new MC: 0x%02x\n", rate, new);*/
352 stac9460_put(ice, STAC946X_MASTER_CLOCKING, new); 352 stac9460_put(ice, STAC946X_MASTER_CLOCKING, new);
353 udelay(10); 353 udelay(10);
354 /* unmuting - only originally unmuted dacs - 354 /* unmuting - only originally unmuted dacs -
@@ -768,9 +768,10 @@ static int prodigy192_init(struct snd_ice1712 *ice)
768 /* from this moment if err = 0 then 768 /* from this moment if err = 0 then
769 * spec->ak4114 should not be null 769 * spec->ak4114 should not be null
770 */ 770 */
771 snd_printdd("AK4114 initialized with status %d\n", err); 771 dev_dbg(ice->card->dev,
772 "AK4114 initialized with status %d\n", err);
772 } else 773 } else
773 snd_printdd("AK4114 not found\n"); 774 dev_dbg(ice->card->dev, "AK4114 not found\n");
774 if (err < 0) 775 if (err < 0)
775 return err; 776 return err;
776 777
diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c
index 71c6003ef338..2c2df4b74e01 100644
--- a/sound/pci/ice1712/quartet.c
+++ b/sound/pci/ice1712/quartet.c
@@ -280,7 +280,7 @@ static void qtet_akm_write(struct snd_akm4xxx *ak, int chip,
280 280
281 if (snd_BUG_ON(chip < 0 || chip >= 4)) 281 if (snd_BUG_ON(chip < 0 || chip >= 4))
282 return; 282 return;
283 /*printk(KERN_DEBUG "Writing to AK4620: chip=%d, addr=0x%x, 283 /*dev_dbg(ice->card->dev, "Writing to AK4620: chip=%d, addr=0x%x,
284 data=0x%x\n", chip, addr, data);*/ 284 data=0x%x\n", chip, addr, data);*/
285 orig_dir = ice->gpio.get_dir(ice); 285 orig_dir = ice->gpio.get_dir(ice);
286 ice->gpio.set_dir(ice, orig_dir | GPIO_SPI_ALL); 286 ice->gpio.set_dir(ice, orig_dir | GPIO_SPI_ALL);
@@ -898,7 +898,7 @@ static void qtet_set_rate(struct snd_ice1712 *ice, unsigned int rate)
898 new = (get_cpld(ice) & ~CPLD_CKS_MASK) | get_cks_val(rate); 898 new = (get_cpld(ice) & ~CPLD_CKS_MASK) | get_cks_val(rate);
899 /* switch to internal clock, drop CPLD_SYNC_SEL */ 899 /* switch to internal clock, drop CPLD_SYNC_SEL */
900 new &= ~CPLD_SYNC_SEL; 900 new &= ~CPLD_SYNC_SEL;
901 /* printk(KERN_DEBUG "QT - set_rate: old %x, new %x\n", 901 /* dev_dbg(ice->card->dev, "QT - set_rate: old %x, new %x\n",
902 get_cpld(ice), new); */ 902 get_cpld(ice), new); */
903 set_cpld(ice, new); 903 set_cpld(ice, new);
904} 904}
@@ -978,7 +978,7 @@ static void qtet_ak4113_change(struct ak4113 *ak4113, unsigned char c0,
978 c1) { 978 c1) {
979 /* only for SPDIF master mode, rate was changed */ 979 /* only for SPDIF master mode, rate was changed */
980 rate = snd_ak4113_external_rate(ak4113); 980 rate = snd_ak4113_external_rate(ak4113);
981 /* printk(KERN_DEBUG "ak4113 - input rate changed to %d\n", 981 /* dev_dbg(ice->card->dev, "ak4113 - input rate changed to %d\n",
982 rate); */ 982 rate); */
983 qtet_akm_set_rate_val(ice->akm, rate); 983 qtet_akm_set_rate_val(ice->akm, rate);
984 } 984 }
diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
index 08d8733604a2..68340d7df76d 100644
--- a/sound/pci/intel8x0.c
+++ b/sound/pci/intel8x0.c
@@ -547,7 +547,8 @@ static int snd_intel8x0_codec_semaphore(struct intel8x0 *chip, unsigned int code
547 /* access to some forbidden (non existent) ac97 registers will not 547 /* access to some forbidden (non existent) ac97 registers will not
548 * reset the semaphore. So even if you don't get the semaphore, still 548 * reset the semaphore. So even if you don't get the semaphore, still
549 * continue the access. We don't need the semaphore anyway. */ 549 * continue the access. We don't need the semaphore anyway. */
550 snd_printk(KERN_ERR "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n", 550 dev_err(chip->card->dev,
551 "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
551 igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA))); 552 igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
552 iagetword(chip, 0); /* clear semaphore flag */ 553 iagetword(chip, 0); /* clear semaphore flag */
553 /* I don't care about the semaphore */ 554 /* I don't care about the semaphore */
@@ -562,7 +563,9 @@ static void snd_intel8x0_codec_write(struct snd_ac97 *ac97,
562 563
563 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { 564 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
564 if (! chip->in_ac97_init) 565 if (! chip->in_ac97_init)
565 snd_printk(KERN_ERR "codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); 566 dev_err(chip->card->dev,
567 "codec_write %d: semaphore is not ready for register 0x%x\n",
568 ac97->num, reg);
566 } 569 }
567 iaputword(chip, reg + ac97->num * 0x80, val); 570 iaputword(chip, reg + ac97->num * 0x80, val);
568} 571}
@@ -576,7 +579,9 @@ static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97,
576 579
577 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { 580 if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
578 if (! chip->in_ac97_init) 581 if (! chip->in_ac97_init)
579 snd_printk(KERN_ERR "codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); 582 dev_err(chip->card->dev,
583 "codec_read %d: semaphore is not ready for register 0x%x\n",
584 ac97->num, reg);
580 res = 0xffff; 585 res = 0xffff;
581 } else { 586 } else {
582 res = iagetword(chip, reg + ac97->num * 0x80); 587 res = iagetword(chip, reg + ac97->num * 0x80);
@@ -585,7 +590,9 @@ static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97,
585 iputdword(chip, ICHREG(GLOB_STA), tmp & 590 iputdword(chip, ICHREG(GLOB_STA), tmp &
586 ~(chip->codec_ready_bits | ICH_GSCI)); 591 ~(chip->codec_ready_bits | ICH_GSCI));
587 if (! chip->in_ac97_init) 592 if (! chip->in_ac97_init)
588 snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg); 593 dev_err(chip->card->dev,
594 "codec_read %d: read timeout for register 0x%x\n",
595 ac97->num, reg);
589 res = 0xffff; 596 res = 0xffff;
590 } 597 }
591 } 598 }
@@ -619,7 +626,7 @@ static int snd_intel8x0_ali_codec_ready(struct intel8x0 *chip, int mask)
619 return 0; 626 return 0;
620 } 627 }
621 if (! chip->in_ac97_init) 628 if (! chip->in_ac97_init)
622 snd_printd(KERN_WARNING "intel8x0: AC97 codec ready timeout.\n"); 629 dev_warn(chip->card->dev, "AC97 codec ready timeout.\n");
623 return -EBUSY; 630 return -EBUSY;
624} 631}
625 632
@@ -631,7 +638,7 @@ static int snd_intel8x0_ali_codec_semaphore(struct intel8x0 *chip)
631 while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY)) 638 while (--time && (igetdword(chip, ICHREG(ALI_CAS)) & ALI_CAS_SEM_BUSY))
632 udelay(1); 639 udelay(1);
633 if (! time && ! chip->in_ac97_init) 640 if (! time && ! chip->in_ac97_init)
634 snd_printk(KERN_WARNING "ali_codec_semaphore timeout\n"); 641 dev_warn(chip->card->dev, "ali_codec_semaphore timeout\n");
635 return snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_CODEC_READY); 642 return snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_CODEC_READY);
636} 643}
637 644
@@ -700,7 +707,7 @@ static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ich
700 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ 707 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
701 ichdev->fragsize >> ichdev->pos_shift); 708 ichdev->fragsize >> ichdev->pos_shift);
702#if 0 709#if 0
703 printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n", 710 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n",
704 idx + 0, bdbar[idx + 0], bdbar[idx + 1]); 711 idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
705#endif 712#endif
706 } 713 }
@@ -712,8 +719,8 @@ static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ich
712 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; 719 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
713 ichdev->position = 0; 720 ichdev->position = 0;
714#if 0 721#if 0
715 printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, " 722 dev_dbg(chip->card->dev,
716 "period_size1 = 0x%x\n", 723 "lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
717 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, 724 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
718 ichdev->fragsize1); 725 ichdev->fragsize1);
719#endif 726#endif
@@ -781,8 +788,8 @@ static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ich
781 ichdev->lvi_frag %= ichdev->frags; 788 ichdev->lvi_frag %= ichdev->frags;
782 ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1); 789 ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1);
783#if 0 790#if 0
784 printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, " 791 dev_dbg(chip->card->dev,
785 "all = 0x%x, 0x%x\n", 792 "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
786 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], 793 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
787 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), 794 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
788 inl(port + 4), inb(port + ICH_REG_OFF_CR)); 795 inl(port + 4), inb(port + ICH_REG_OFF_CR));
@@ -2289,7 +2296,8 @@ static int snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock,
2289 ac97.num = i; 2296 ac97.num = i;
2290 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) { 2297 if ((err = snd_ac97_mixer(pbus, &ac97, &chip->ac97[i])) < 0) {
2291 if (err != -EACCES) 2298 if (err != -EACCES)
2292 snd_printk(KERN_ERR "Unable to initialize codec #%d\n", i); 2299 dev_err(chip->card->dev,
2300 "Unable to initialize codec #%d\n", i);
2293 if (i == 0) 2301 if (i == 0)
2294 goto __err; 2302 goto __err;
2295 } 2303 }
@@ -2441,7 +2449,7 @@ static int snd_intel8x0_ich_chip_reset(struct intel8x0 *chip)
2441 return 0; 2449 return 0;
2442 schedule_timeout_uninterruptible(1); 2450 schedule_timeout_uninterruptible(1);
2443 } while (time_after_eq(end_time, jiffies)); 2451 } while (time_after_eq(end_time, jiffies));
2444 snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", 2452 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n",
2445 igetdword(chip, ICHREG(GLOB_CNT))); 2453 igetdword(chip, ICHREG(GLOB_CNT)));
2446 return -EIO; 2454 return -EIO;
2447} 2455}
@@ -2483,7 +2491,8 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
2483 } while (time_after_eq(end_time, jiffies)); 2491 } while (time_after_eq(end_time, jiffies));
2484 if (! status) { 2492 if (! status) {
2485 /* no codec is found */ 2493 /* no codec is found */
2486 snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", 2494 dev_err(chip->card->dev,
2495 "codec_ready: codec is not ready [0x%x]\n",
2487 igetdword(chip, ICHREG(GLOB_STA))); 2496 igetdword(chip, ICHREG(GLOB_STA)));
2488 return -EIO; 2497 return -EIO;
2489 } 2498 }
@@ -2547,7 +2556,7 @@ static int snd_intel8x0_ali_chip_init(struct intel8x0 *chip, int probing)
2547 goto __ok; 2556 goto __ok;
2548 schedule_timeout_uninterruptible(1); 2557 schedule_timeout_uninterruptible(1);
2549 } 2558 }
2550 snd_printk(KERN_ERR "AC'97 reset failed.\n"); 2559 dev_err(chip->card->dev, "AC'97 reset failed.\n");
2551 if (probing) 2560 if (probing)
2552 return -EIO; 2561 return -EIO;
2553 2562
@@ -2591,7 +2600,7 @@ static int snd_intel8x0_chip_init(struct intel8x0 *chip, int probing)
2591 break; 2600 break;
2592 } 2601 }
2593 if (timeout == 0) 2602 if (timeout == 0)
2594 printk(KERN_ERR "intel8x0: reset of registers failed?\n"); 2603 dev_err(chip->card->dev, "reset of registers failed?\n");
2595 } 2604 }
2596 /* initialize Buffer Descriptor Lists */ 2605 /* initialize Buffer Descriptor Lists */
2597 for (i = 0; i < chip->bdbars_count; i++) 2606 for (i = 0; i < chip->bdbars_count; i++)
@@ -2692,8 +2701,7 @@ static int intel8x0_resume(struct device *dev)
2692 pci_set_power_state(pci, PCI_D0); 2701 pci_set_power_state(pci, PCI_D0);
2693 pci_restore_state(pci); 2702 pci_restore_state(pci);
2694 if (pci_enable_device(pci) < 0) { 2703 if (pci_enable_device(pci) < 0) {
2695 printk(KERN_ERR "intel8x0: pci_enable_device failed, " 2704 dev_err(dev, "pci_enable_device failed, disabling device\n");
2696 "disabling device\n");
2697 snd_card_disconnect(card); 2705 snd_card_disconnect(card);
2698 return -EIO; 2706 return -EIO;
2699 } 2707 }
@@ -2701,8 +2709,8 @@ static int intel8x0_resume(struct device *dev)
2701 snd_intel8x0_chip_init(chip, 0); 2709 snd_intel8x0_chip_init(chip, 0);
2702 if (request_irq(pci->irq, snd_intel8x0_interrupt, 2710 if (request_irq(pci->irq, snd_intel8x0_interrupt,
2703 IRQF_SHARED, KBUILD_MODNAME, chip)) { 2711 IRQF_SHARED, KBUILD_MODNAME, chip)) {
2704 printk(KERN_ERR "intel8x0: unable to grab IRQ %d, " 2712 dev_err(dev, "unable to grab IRQ %d, disabling device\n",
2705 "disabling device\n", pci->irq); 2713 pci->irq);
2706 snd_card_disconnect(card); 2714 snd_card_disconnect(card);
2707 return -EIO; 2715 return -EIO;
2708 } 2716 }
@@ -2779,7 +2787,8 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2779 __again: 2787 __again:
2780 subs = chip->pcm[0]->streams[0].substream; 2788 subs = chip->pcm[0]->streams[0].substream;
2781 if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) { 2789 if (! subs || subs->dma_buffer.bytes < INTEL8X0_TESTBUF_SIZE) {
2782 snd_printk(KERN_WARNING "no playback buffer allocated - aborting measure ac97 clock\n"); 2790 dev_warn(chip->card->dev,
2791 "no playback buffer allocated - aborting measure ac97 clock\n");
2783 return; 2792 return;
2784 } 2793 }
2785 ichdev = &chip->ichd[ICHD_PCMOUT]; 2794 ichdev = &chip->ichd[ICHD_PCMOUT];
@@ -2789,7 +2798,8 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2789 2798
2790 /* set rate */ 2799 /* set rate */
2791 if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) { 2800 if (snd_ac97_set_rate(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 48000) < 0) {
2792 snd_printk(KERN_ERR "cannot set ac97 rate: clock = %d\n", chip->ac97_bus->clock); 2801 dev_err(chip->card->dev, "cannot set ac97 rate: clock = %d\n",
2802 chip->ac97_bus->clock);
2793 return; 2803 return;
2794 } 2804 }
2795 snd_intel8x0_setup_periods(chip, ichdev); 2805 snd_intel8x0_setup_periods(chip, ichdev);
@@ -2843,7 +2853,8 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2843 spin_unlock_irq(&chip->reg_lock); 2853 spin_unlock_irq(&chip->reg_lock);
2844 2854
2845 if (pos == 0) { 2855 if (pos == 0) {
2846 snd_printk(KERN_ERR "intel8x0: measure - unreliable DMA position..\n"); 2856 dev_err(chip->card->dev,
2857 "measure - unreliable DMA position..\n");
2847 __retry: 2858 __retry:
2848 if (attempt < 3) { 2859 if (attempt < 3) {
2849 msleep(300); 2860 msleep(300);
@@ -2857,16 +2868,17 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2857 t = stop_time.tv_sec - start_time.tv_sec; 2868 t = stop_time.tv_sec - start_time.tv_sec;
2858 t *= 1000000; 2869 t *= 1000000;
2859 t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000; 2870 t += (stop_time.tv_nsec - start_time.tv_nsec) / 1000;
2860 printk(KERN_INFO "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos); 2871 dev_info(chip->card->dev,
2872 "%s: measured %lu usecs (%lu samples)\n", __func__, t, pos);
2861 if (t == 0) { 2873 if (t == 0) {
2862 snd_printk(KERN_ERR "intel8x0: ?? calculation error..\n"); 2874 dev_err(chip->card->dev, "?? calculation error..\n");
2863 goto __retry; 2875 goto __retry;
2864 } 2876 }
2865 pos *= 1000; 2877 pos *= 1000;
2866 pos = (pos / t) * 1000 + ((pos % t) * 1000) / t; 2878 pos = (pos / t) * 1000 + ((pos % t) * 1000) / t;
2867 if (pos < 40000 || pos >= 60000) { 2879 if (pos < 40000 || pos >= 60000) {
2868 /* abnormal value. hw problem? */ 2880 /* abnormal value. hw problem? */
2869 printk(KERN_INFO "intel8x0: measured clock %ld rejected\n", pos); 2881 dev_info(chip->card->dev, "measured clock %ld rejected\n", pos);
2870 goto __retry; 2882 goto __retry;
2871 } else if (pos > 40500 && pos < 41500) 2883 } else if (pos > 40500 && pos < 41500)
2872 /* first exception - 41000Hz reference clock */ 2884 /* first exception - 41000Hz reference clock */
@@ -2878,7 +2890,7 @@ static void intel8x0_measure_ac97_clock(struct intel8x0 *chip)
2878 /* not 48000Hz, tuning the clock.. */ 2890 /* not 48000Hz, tuning the clock.. */
2879 chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos; 2891 chip->ac97_bus->clock = (chip->ac97_bus->clock * 48000) / pos;
2880 __end: 2892 __end:
2881 printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock); 2893 dev_info(chip->card->dev, "clocking to %d\n", chip->ac97_bus->clock);
2882 snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0); 2894 snd_ac97_update_power(chip->ac97[0], AC97_PCM_FRONT_DAC_RATE, 0);
2883} 2895}
2884 2896
@@ -2899,7 +2911,7 @@ static int intel8x0_in_clock_list(struct intel8x0 *chip)
2899 wl = snd_pci_quirk_lookup(pci, intel8x0_clock_list); 2911 wl = snd_pci_quirk_lookup(pci, intel8x0_clock_list);
2900 if (!wl) 2912 if (!wl)
2901 return 0; 2913 return 0;
2902 printk(KERN_INFO "intel8x0: white list rate for %04x:%04x is %i\n", 2914 dev_info(chip->card->dev, "white list rate for %04x:%04x is %i\n",
2903 pci->subsystem_vendor, pci->subsystem_device, wl->value); 2915 pci->subsystem_vendor, pci->subsystem_device, wl->value);
2904 chip->ac97_bus->clock = wl->value; 2916 chip->ac97_bus->clock = wl->value;
2905 return 1; 2917 return 1;
@@ -3003,7 +3015,7 @@ static int snd_intel8x0_inside_vm(struct pci_dev *pci)
3003 3015
3004fini: 3016fini:
3005 if (msg != NULL) 3017 if (msg != NULL)
3006 printk(KERN_INFO "intel8x0: %s optimization\n", msg); 3018 dev_info(&pci->dev, "%s optimization\n", msg);
3007 3019
3008 return result; 3020 return result;
3009} 3021}
@@ -3098,7 +3110,7 @@ static int snd_intel8x0_create(struct snd_card *card,
3098 else 3110 else
3099 chip->addr = pci_iomap(pci, 0, 0); 3111 chip->addr = pci_iomap(pci, 0, 0);
3100 if (!chip->addr) { 3112 if (!chip->addr) {
3101 snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); 3113 dev_err(card->dev, "AC'97 space ioremap problem\n");
3102 snd_intel8x0_free(chip); 3114 snd_intel8x0_free(chip);
3103 return -EIO; 3115 return -EIO;
3104 } 3116 }
@@ -3107,7 +3119,7 @@ static int snd_intel8x0_create(struct snd_card *card,
3107 else 3119 else
3108 chip->bmaddr = pci_iomap(pci, 1, 0); 3120 chip->bmaddr = pci_iomap(pci, 1, 0);
3109 if (!chip->bmaddr) { 3121 if (!chip->bmaddr) {
3110 snd_printk(KERN_ERR "Controller space ioremap problem\n"); 3122 dev_err(card->dev, "Controller space ioremap problem\n");
3111 snd_intel8x0_free(chip); 3123 snd_intel8x0_free(chip);
3112 return -EIO; 3124 return -EIO;
3113 } 3125 }
@@ -3152,7 +3164,7 @@ static int snd_intel8x0_create(struct snd_card *card,
3152 chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2, 3164 chip->bdbars_count * sizeof(u32) * ICH_MAX_FRAGS * 2,
3153 &chip->bdbars) < 0) { 3165 &chip->bdbars) < 0) {
3154 snd_intel8x0_free(chip); 3166 snd_intel8x0_free(chip);
3155 snd_printk(KERN_ERR "intel8x0: cannot allocate buffer descriptors\n"); 3167 dev_err(card->dev, "cannot allocate buffer descriptors\n");
3156 return -ENOMEM; 3168 return -ENOMEM;
3157 } 3169 }
3158 /* tables must be aligned to 8 bytes here, but the kernel pages 3170 /* tables must be aligned to 8 bytes here, but the kernel pages
@@ -3206,7 +3218,7 @@ static int snd_intel8x0_create(struct snd_card *card,
3206 /* request irq after initializaing int_sta_mask, etc */ 3218 /* request irq after initializaing int_sta_mask, etc */
3207 if (request_irq(pci->irq, snd_intel8x0_interrupt, 3219 if (request_irq(pci->irq, snd_intel8x0_interrupt,
3208 IRQF_SHARED, KBUILD_MODNAME, chip)) { 3220 IRQF_SHARED, KBUILD_MODNAME, chip)) {
3209 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 3221 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
3210 snd_intel8x0_free(chip); 3222 snd_intel8x0_free(chip);
3211 return -EBUSY; 3223 return -EBUSY;
3212 } 3224 }
@@ -3217,8 +3229,6 @@ static int snd_intel8x0_create(struct snd_card *card,
3217 return err; 3229 return err;
3218 } 3230 }
3219 3231
3220 snd_card_set_dev(card, &pci->dev);
3221
3222 *r_intel8x0 = chip; 3232 *r_intel8x0 = chip;
3223 return 0; 3233 return 0;
3224} 3234}
@@ -3265,12 +3275,12 @@ static int check_default_spdif_aclink(struct pci_dev *pci)
3265 w = snd_pci_quirk_lookup(pci, spdif_aclink_defaults); 3275 w = snd_pci_quirk_lookup(pci, spdif_aclink_defaults);
3266 if (w) { 3276 if (w) {
3267 if (w->value) 3277 if (w->value)
3268 snd_printdd(KERN_INFO 3278 dev_dbg(&pci->dev,
3269 "intel8x0: Using SPDIF over AC-Link for %s\n", 3279 "Using SPDIF over AC-Link for %s\n",
3270 snd_pci_quirk_name(w)); 3280 snd_pci_quirk_name(w));
3271 else 3281 else
3272 snd_printdd(KERN_INFO 3282 dev_dbg(&pci->dev,
3273 "intel8x0: Using integrated SPDIF DMA for %s\n", 3283 "Using integrated SPDIF DMA for %s\n",
3274 snd_pci_quirk_name(w)); 3284 snd_pci_quirk_name(w));
3275 return w->value; 3285 return w->value;
3276 } 3286 }
@@ -3285,7 +3295,7 @@ static int snd_intel8x0_probe(struct pci_dev *pci,
3285 int err; 3295 int err;
3286 struct shortname_table *name; 3296 struct shortname_table *name;
3287 3297
3288 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 3298 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
3289 if (err < 0) 3299 if (err < 0)
3290 return err; 3300 return err;
3291 3301
diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c
index 3573c1193665..b54d3e93cab1 100644
--- a/sound/pci/intel8x0m.c
+++ b/sound/pci/intel8x0m.c
@@ -334,7 +334,8 @@ static int snd_intel8x0m_codec_semaphore(struct intel8x0m *chip, unsigned int co
334 /* access to some forbidden (non existent) ac97 registers will not 334 /* access to some forbidden (non existent) ac97 registers will not
335 * reset the semaphore. So even if you don't get the semaphore, still 335 * reset the semaphore. So even if you don't get the semaphore, still
336 * continue the access. We don't need the semaphore anyway. */ 336 * continue the access. We don't need the semaphore anyway. */
337 snd_printk(KERN_ERR "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n", 337 dev_err(chip->card->dev,
338 "codec_semaphore: semaphore is not ready [0x%x][0x%x]\n",
338 igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA))); 339 igetbyte(chip, ICHREG(ACC_SEMA)), igetdword(chip, ICHREG(GLOB_STA)));
339 iagetword(chip, 0); /* clear semaphore flag */ 340 iagetword(chip, 0); /* clear semaphore flag */
340 /* I don't care about the semaphore */ 341 /* I don't care about the semaphore */
@@ -349,7 +350,9 @@ static void snd_intel8x0m_codec_write(struct snd_ac97 *ac97,
349 350
350 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) { 351 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
351 if (! chip->in_ac97_init) 352 if (! chip->in_ac97_init)
352 snd_printk(KERN_ERR "codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); 353 dev_err(chip->card->dev,
354 "codec_write %d: semaphore is not ready for register 0x%x\n",
355 ac97->num, reg);
353 } 356 }
354 iaputword(chip, reg + ac97->num * 0x80, val); 357 iaputword(chip, reg + ac97->num * 0x80, val);
355} 358}
@@ -363,7 +366,9 @@ static unsigned short snd_intel8x0m_codec_read(struct snd_ac97 *ac97,
363 366
364 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) { 367 if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
365 if (! chip->in_ac97_init) 368 if (! chip->in_ac97_init)
366 snd_printk(KERN_ERR "codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); 369 dev_err(chip->card->dev,
370 "codec_read %d: semaphore is not ready for register 0x%x\n",
371 ac97->num, reg);
367 res = 0xffff; 372 res = 0xffff;
368 } else { 373 } else {
369 res = iagetword(chip, reg + ac97->num * 0x80); 374 res = iagetword(chip, reg + ac97->num * 0x80);
@@ -372,7 +377,9 @@ static unsigned short snd_intel8x0m_codec_read(struct snd_ac97 *ac97,
372 iputdword(chip, ICHREG(GLOB_STA), 377 iputdword(chip, ICHREG(GLOB_STA),
373 tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); 378 tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI));
374 if (! chip->in_ac97_init) 379 if (! chip->in_ac97_init)
375 snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg); 380 dev_err(chip->card->dev,
381 "codec_read %d: read timeout for register 0x%x\n",
382 ac97->num, reg);
376 res = 0xffff; 383 res = 0xffff;
377 } 384 }
378 } 385 }
@@ -412,7 +419,7 @@ static void snd_intel8x0m_setup_periods(struct intel8x0m *chip, struct ichdev *i
412 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ 419 bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */
413 ichdev->fragsize >> chip->pcm_pos_shift); 420 ichdev->fragsize >> chip->pcm_pos_shift);
414 /* 421 /*
415 printk(KERN_DEBUG "bdbar[%i] = 0x%x [0x%x]\n", 422 dev_dbg(chip->card->dev, "bdbar[%i] = 0x%x [0x%x]\n",
416 idx + 0, bdbar[idx + 0], bdbar[idx + 1]); 423 idx + 0, bdbar[idx + 0], bdbar[idx + 1]);
417 */ 424 */
418 } 425 }
@@ -424,8 +431,8 @@ static void snd_intel8x0m_setup_periods(struct intel8x0m *chip, struct ichdev *i
424 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags; 431 ichdev->lvi_frag = ICH_REG_LVI_MASK % ichdev->frags;
425 ichdev->position = 0; 432 ichdev->position = 0;
426#if 0 433#if 0
427 printk(KERN_DEBUG "lvi_frag = %i, frags = %i, period_size = 0x%x, " 434 dev_dbg(chip->card->dev,
428 "period_size1 = 0x%x\n", 435 "lvi_frag = %i, frags = %i, period_size = 0x%x, period_size1 = 0x%x\n",
429 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize, 436 ichdev->lvi_frag, ichdev->frags, ichdev->fragsize,
430 ichdev->fragsize1); 437 ichdev->fragsize1);
431#endif 438#endif
@@ -470,8 +477,8 @@ static inline void snd_intel8x0m_update(struct intel8x0m *chip, struct ichdev *i
470 ichdev->lvi_frag * 477 ichdev->lvi_frag *
471 ichdev->fragsize1); 478 ichdev->fragsize1);
472#if 0 479#if 0
473 printk(KERN_DEBUG "new: bdbar[%i] = 0x%x [0x%x], " 480 dev_dbg(chip->card->dev,
474 "prefetch = %i, all = 0x%x, 0x%x\n", 481 "new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n",
475 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], 482 ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2],
476 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), 483 ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port),
477 inl(port + 4), inb(port + ICH_REG_OFF_CR)); 484 inl(port + 4), inb(port + ICH_REG_OFF_CR));
@@ -850,7 +857,8 @@ static int snd_intel8x0m_mixer(struct intel8x0m *chip, int ac97_clock)
850 ac97.pci = chip->pci; 857 ac97.pci = chip->pci;
851 ac97.num = glob_sta & ICH_SCR ? 1 : 0; 858 ac97.num = glob_sta & ICH_SCR ? 1 : 0;
852 if ((err = snd_ac97_mixer(pbus, &ac97, &x97)) < 0) { 859 if ((err = snd_ac97_mixer(pbus, &ac97, &x97)) < 0) {
853 snd_printk(KERN_ERR "Unable to initialize codec #%d\n", ac97.num); 860 dev_err(chip->card->dev,
861 "Unable to initialize codec #%d\n", ac97.num);
854 if (ac97.num == 0) 862 if (ac97.num == 0)
855 goto __err; 863 goto __err;
856 return err; 864 return err;
@@ -901,7 +909,7 @@ static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing)
901 goto __ok; 909 goto __ok;
902 schedule_timeout_uninterruptible(1); 910 schedule_timeout_uninterruptible(1);
903 } while (time_after_eq(end_time, jiffies)); 911 } while (time_after_eq(end_time, jiffies));
904 snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", 912 dev_err(chip->card->dev, "AC'97 warm reset still in progress? [0x%x]\n",
905 igetdword(chip, ICHREG(GLOB_CNT))); 913 igetdword(chip, ICHREG(GLOB_CNT)));
906 return -EIO; 914 return -EIO;
907 915
@@ -921,7 +929,8 @@ static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing)
921 } while (time_after_eq(end_time, jiffies)); 929 } while (time_after_eq(end_time, jiffies));
922 if (! status) { 930 if (! status) {
923 /* no codec is found */ 931 /* no codec is found */
924 snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", 932 dev_err(chip->card->dev,
933 "codec_ready: codec is not ready [0x%x]\n",
925 igetdword(chip, ICHREG(GLOB_STA))); 934 igetdword(chip, ICHREG(GLOB_STA)));
926 return -EIO; 935 return -EIO;
927 } 936 }
@@ -1042,16 +1051,15 @@ static int intel8x0m_resume(struct device *dev)
1042 pci_set_power_state(pci, PCI_D0); 1051 pci_set_power_state(pci, PCI_D0);
1043 pci_restore_state(pci); 1052 pci_restore_state(pci);
1044 if (pci_enable_device(pci) < 0) { 1053 if (pci_enable_device(pci) < 0) {
1045 printk(KERN_ERR "intel8x0m: pci_enable_device failed, " 1054 dev_err(dev, "pci_enable_device failed, disabling device\n");
1046 "disabling device\n");
1047 snd_card_disconnect(card); 1055 snd_card_disconnect(card);
1048 return -EIO; 1056 return -EIO;
1049 } 1057 }
1050 pci_set_master(pci); 1058 pci_set_master(pci);
1051 if (request_irq(pci->irq, snd_intel8x0m_interrupt, 1059 if (request_irq(pci->irq, snd_intel8x0m_interrupt,
1052 IRQF_SHARED, KBUILD_MODNAME, chip)) { 1060 IRQF_SHARED, KBUILD_MODNAME, chip)) {
1053 printk(KERN_ERR "intel8x0m: unable to grab IRQ %d, " 1061 dev_err(dev, "unable to grab IRQ %d, disabling device\n",
1054 "disabling device\n", pci->irq); 1062 pci->irq);
1055 snd_card_disconnect(card); 1063 snd_card_disconnect(card);
1056 return -EIO; 1064 return -EIO;
1057 } 1065 }
@@ -1165,7 +1173,7 @@ static int snd_intel8x0m_create(struct snd_card *card,
1165 else 1173 else
1166 chip->addr = pci_iomap(pci, 0, 0); 1174 chip->addr = pci_iomap(pci, 0, 0);
1167 if (!chip->addr) { 1175 if (!chip->addr) {
1168 snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); 1176 dev_err(card->dev, "AC'97 space ioremap problem\n");
1169 snd_intel8x0m_free(chip); 1177 snd_intel8x0m_free(chip);
1170 return -EIO; 1178 return -EIO;
1171 } 1179 }
@@ -1174,7 +1182,7 @@ static int snd_intel8x0m_create(struct snd_card *card,
1174 else 1182 else
1175 chip->bmaddr = pci_iomap(pci, 1, 0); 1183 chip->bmaddr = pci_iomap(pci, 1, 0);
1176 if (!chip->bmaddr) { 1184 if (!chip->bmaddr) {
1177 snd_printk(KERN_ERR "Controller space ioremap problem\n"); 1185 dev_err(card->dev, "Controller space ioremap problem\n");
1178 snd_intel8x0m_free(chip); 1186 snd_intel8x0m_free(chip);
1179 return -EIO; 1187 return -EIO;
1180 } 1188 }
@@ -1182,7 +1190,7 @@ static int snd_intel8x0m_create(struct snd_card *card,
1182 port_inited: 1190 port_inited:
1183 if (request_irq(pci->irq, snd_intel8x0m_interrupt, IRQF_SHARED, 1191 if (request_irq(pci->irq, snd_intel8x0m_interrupt, IRQF_SHARED,
1184 KBUILD_MODNAME, chip)) { 1192 KBUILD_MODNAME, chip)) {
1185 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1193 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1186 snd_intel8x0m_free(chip); 1194 snd_intel8x0m_free(chip);
1187 return -EBUSY; 1195 return -EBUSY;
1188 } 1196 }
@@ -1243,8 +1251,6 @@ static int snd_intel8x0m_create(struct snd_card *card,
1243 return err; 1251 return err;
1244 } 1252 }
1245 1253
1246 snd_card_set_dev(card, &pci->dev);
1247
1248 *r_intel8x0m = chip; 1254 *r_intel8x0m = chip;
1249 return 0; 1255 return 0;
1250} 1256}
@@ -1283,7 +1289,7 @@ static int snd_intel8x0m_probe(struct pci_dev *pci,
1283 int err; 1289 int err;
1284 struct shortname_table *name; 1290 struct shortname_table *name;
1285 1291
1286 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 1292 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
1287 if (err < 0) 1293 if (err < 0)
1288 return err; 1294 return err;
1289 1295
diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c
index 9cf9829555d4..8f36d77f01e5 100644
--- a/sound/pci/korg1212/korg1212.c
+++ b/sound/pci/korg1212/korg1212.c
@@ -2418,8 +2418,6 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci,
2418 2418
2419 snd_korg1212_proc_init(korg1212); 2419 snd_korg1212_proc_init(korg1212);
2420 2420
2421 snd_card_set_dev(card, &pci->dev);
2422
2423 * rchip = korg1212; 2421 * rchip = korg1212;
2424 return 0; 2422 return 0;
2425 2423
@@ -2445,7 +2443,8 @@ snd_korg1212_probe(struct pci_dev *pci,
2445 dev++; 2443 dev++;
2446 return -ENOENT; 2444 return -ENOENT;
2447 } 2445 }
2448 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2446 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2447 0, &card);
2449 if (err < 0) 2448 if (err < 0)
2450 return err; 2449 return err;
2451 2450
diff --git a/sound/pci/lola/lola.c b/sound/pci/lola/lola.c
index 0568540dc8d3..68824cdd137d 100644
--- a/sound/pci/lola/lola.c
+++ b/sound/pci/lola/lola.c
@@ -75,7 +75,7 @@ MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>");
75static int debug; 75static int debug;
76module_param(debug, int, 0644); 76module_param(debug, int, 0644);
77#define verbose_debug(fmt, args...) \ 77#define verbose_debug(fmt, args...) \
78 do { if (debug > 1) printk(KERN_DEBUG SFX fmt, ##args); } while (0) 78 do { if (debug > 1) pr_debug(SFX fmt, ##args); } while (0)
79#else 79#else
80#define verbose_debug(fmt, args...) 80#define verbose_debug(fmt, args...)
81#endif 81#endif
@@ -168,7 +168,7 @@ static int rirb_get_response(struct lola *chip, unsigned int *val,
168 verbose_debug("get_response: %x, %x\n", 168 verbose_debug("get_response: %x, %x\n",
169 chip->res, chip->res_ex); 169 chip->res, chip->res_ex);
170 if (chip->res_ex & LOLA_RIRB_EX_ERROR) { 170 if (chip->res_ex & LOLA_RIRB_EX_ERROR) {
171 printk(KERN_WARNING SFX "RIRB ERROR: " 171 dev_warn(chip->card->dev, "RIRB ERROR: "
172 "NID=%x, verb=%x, data=%x, ext=%x\n", 172 "NID=%x, verb=%x, data=%x, ext=%x\n",
173 chip->last_cmd_nid, 173 chip->last_cmd_nid,
174 chip->last_verb, chip->last_data, 174 chip->last_verb, chip->last_data,
@@ -182,9 +182,9 @@ static int rirb_get_response(struct lola *chip, unsigned int *val,
182 udelay(20); 182 udelay(20);
183 cond_resched(); 183 cond_resched();
184 } 184 }
185 printk(KERN_WARNING SFX "RIRB response error\n"); 185 dev_warn(chip->card->dev, "RIRB response error\n");
186 if (!chip->polling_mode) { 186 if (!chip->polling_mode) {
187 printk(KERN_WARNING SFX "switching to polling mode\n"); 187 dev_warn(chip->card->dev, "switching to polling mode\n");
188 chip->polling_mode = 1; 188 chip->polling_mode = 1;
189 goto again; 189 goto again;
190 } 190 }
@@ -327,7 +327,7 @@ static int reset_controller(struct lola *chip)
327 break; 327 break;
328 } while (time_before(jiffies, end_time)); 328 } while (time_before(jiffies, end_time));
329 if (!gctl) { 329 if (!gctl) {
330 printk(KERN_ERR SFX "cannot reset controller\n"); 330 dev_err(chip->card->dev, "cannot reset controller\n");
331 return -EIO; 331 return -EIO;
332 } 332 }
333 return 0; 333 return 0;
@@ -452,40 +452,40 @@ static int lola_parse_tree(struct lola *chip)
452 452
453 err = lola_read_param(chip, 0, LOLA_PAR_VENDOR_ID, &val); 453 err = lola_read_param(chip, 0, LOLA_PAR_VENDOR_ID, &val);
454 if (err < 0) { 454 if (err < 0) {
455 printk(KERN_ERR SFX "Can't read VENDOR_ID\n"); 455 dev_err(chip->card->dev, "Can't read VENDOR_ID\n");
456 return err; 456 return err;
457 } 457 }
458 val >>= 16; 458 val >>= 16;
459 if (val != 0x1369) { 459 if (val != 0x1369) {
460 printk(KERN_ERR SFX "Unknown codec vendor 0x%x\n", val); 460 dev_err(chip->card->dev, "Unknown codec vendor 0x%x\n", val);
461 return -EINVAL; 461 return -EINVAL;
462 } 462 }
463 463
464 err = lola_read_param(chip, 1, LOLA_PAR_FUNCTION_TYPE, &val); 464 err = lola_read_param(chip, 1, LOLA_PAR_FUNCTION_TYPE, &val);
465 if (err < 0) { 465 if (err < 0) {
466 printk(KERN_ERR SFX "Can't read FUNCTION_TYPE\n"); 466 dev_err(chip->card->dev, "Can't read FUNCTION_TYPE\n");
467 return err; 467 return err;
468 } 468 }
469 if (val != 1) { 469 if (val != 1) {
470 printk(KERN_ERR SFX "Unknown function type %d\n", val); 470 dev_err(chip->card->dev, "Unknown function type %d\n", val);
471 return -EINVAL; 471 return -EINVAL;
472 } 472 }
473 473
474 err = lola_read_param(chip, 1, LOLA_PAR_SPECIFIC_CAPS, &val); 474 err = lola_read_param(chip, 1, LOLA_PAR_SPECIFIC_CAPS, &val);
475 if (err < 0) { 475 if (err < 0) {
476 printk(KERN_ERR SFX "Can't read SPECCAPS\n"); 476 dev_err(chip->card->dev, "Can't read SPECCAPS\n");
477 return err; 477 return err;
478 } 478 }
479 chip->lola_caps = val; 479 chip->lola_caps = val;
480 chip->pin[CAPT].num_pins = LOLA_AFG_INPUT_PIN_COUNT(chip->lola_caps); 480 chip->pin[CAPT].num_pins = LOLA_AFG_INPUT_PIN_COUNT(chip->lola_caps);
481 chip->pin[PLAY].num_pins = LOLA_AFG_OUTPUT_PIN_COUNT(chip->lola_caps); 481 chip->pin[PLAY].num_pins = LOLA_AFG_OUTPUT_PIN_COUNT(chip->lola_caps);
482 snd_printdd(SFX "speccaps=0x%x, pins in=%d, out=%d\n", 482 dev_dbg(chip->card->dev, "speccaps=0x%x, pins in=%d, out=%d\n",
483 chip->lola_caps, 483 chip->lola_caps,
484 chip->pin[CAPT].num_pins, chip->pin[PLAY].num_pins); 484 chip->pin[CAPT].num_pins, chip->pin[PLAY].num_pins);
485 485
486 if (chip->pin[CAPT].num_pins > MAX_AUDIO_INOUT_COUNT || 486 if (chip->pin[CAPT].num_pins > MAX_AUDIO_INOUT_COUNT ||
487 chip->pin[PLAY].num_pins > MAX_AUDIO_INOUT_COUNT) { 487 chip->pin[PLAY].num_pins > MAX_AUDIO_INOUT_COUNT) {
488 printk(KERN_ERR SFX "Invalid Lola-spec caps 0x%x\n", val); 488 dev_err(chip->card->dev, "Invalid Lola-spec caps 0x%x\n", val);
489 return -EINVAL; 489 return -EINVAL;
490 } 490 }
491 491
@@ -586,7 +586,6 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
586 586
587 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 587 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
588 if (!chip) { 588 if (!chip) {
589 snd_printk(KERN_ERR SFX "cannot allocate chip\n");
590 pci_disable_device(pci); 589 pci_disable_device(pci);
591 return -ENOMEM; 590 return -ENOMEM;
592 } 591 }
@@ -609,7 +608,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
609 chip->sample_rate_max = 192000; 608 chip->sample_rate_max = 192000;
610 break; 609 break;
611 default: 610 default:
612 snd_printk(KERN_WARNING SFX 611 dev_warn(chip->card->dev,
613 "Invalid granularity %d, reset to %d\n", 612 "Invalid granularity %d, reset to %d\n",
614 chip->granularity, LOLA_GRANULARITY_MAX); 613 chip->granularity, LOLA_GRANULARITY_MAX);
615 chip->granularity = LOLA_GRANULARITY_MAX; 614 chip->granularity = LOLA_GRANULARITY_MAX;
@@ -618,7 +617,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
618 } 617 }
619 chip->sample_rate_min = sample_rate_min[dev]; 618 chip->sample_rate_min = sample_rate_min[dev];
620 if (chip->sample_rate_min > chip->sample_rate_max) { 619 if (chip->sample_rate_min > chip->sample_rate_max) {
621 snd_printk(KERN_WARNING SFX 620 dev_warn(chip->card->dev,
622 "Invalid sample_rate_min %d, reset to 16000\n", 621 "Invalid sample_rate_min %d, reset to 16000\n",
623 chip->sample_rate_min); 622 chip->sample_rate_min);
624 chip->sample_rate_min = 16000; 623 chip->sample_rate_min = 16000;
@@ -636,7 +635,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
636 chip->bar[1].addr = pci_resource_start(pci, 2); 635 chip->bar[1].addr = pci_resource_start(pci, 2);
637 chip->bar[1].remap_addr = pci_ioremap_bar(pci, 2); 636 chip->bar[1].remap_addr = pci_ioremap_bar(pci, 2);
638 if (!chip->bar[0].remap_addr || !chip->bar[1].remap_addr) { 637 if (!chip->bar[0].remap_addr || !chip->bar[1].remap_addr) {
639 snd_printk(KERN_ERR SFX "ioremap error\n"); 638 dev_err(chip->card->dev, "ioremap error\n");
640 err = -ENXIO; 639 err = -ENXIO;
641 goto errout; 640 goto errout;
642 } 641 }
@@ -649,7 +648,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
649 648
650 if (request_irq(pci->irq, lola_interrupt, IRQF_SHARED, 649 if (request_irq(pci->irq, lola_interrupt, IRQF_SHARED,
651 KBUILD_MODNAME, chip)) { 650 KBUILD_MODNAME, chip)) {
652 printk(KERN_ERR SFX "unable to grab IRQ %d\n", pci->irq); 651 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
653 err = -EBUSY; 652 err = -EBUSY;
654 goto errout; 653 goto errout;
655 } 654 }
@@ -660,7 +659,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
660 chip->pcm[CAPT].num_streams = (dever >> 0) & 0x3ff; 659 chip->pcm[CAPT].num_streams = (dever >> 0) & 0x3ff;
661 chip->pcm[PLAY].num_streams = (dever >> 10) & 0x3ff; 660 chip->pcm[PLAY].num_streams = (dever >> 10) & 0x3ff;
662 chip->version = (dever >> 24) & 0xff; 661 chip->version = (dever >> 24) & 0xff;
663 snd_printdd(SFX "streams in=%d, out=%d, version=0x%x\n", 662 dev_dbg(chip->card->dev, "streams in=%d, out=%d, version=0x%x\n",
664 chip->pcm[CAPT].num_streams, chip->pcm[PLAY].num_streams, 663 chip->pcm[CAPT].num_streams, chip->pcm[PLAY].num_streams,
665 chip->version); 664 chip->version);
666 665
@@ -669,7 +668,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
669 chip->pcm[PLAY].num_streams > MAX_STREAM_OUT_COUNT || 668 chip->pcm[PLAY].num_streams > MAX_STREAM_OUT_COUNT ||
670 (!chip->pcm[CAPT].num_streams && 669 (!chip->pcm[CAPT].num_streams &&
671 !chip->pcm[PLAY].num_streams)) { 670 !chip->pcm[PLAY].num_streams)) {
672 printk(KERN_ERR SFX "invalid DEVER = %x\n", dever); 671 dev_err(chip->card->dev, "invalid DEVER = %x\n", dever);
673 err = -EINVAL; 672 err = -EINVAL;
674 goto errout; 673 goto errout;
675 } 674 }
@@ -680,7 +679,7 @@ static int lola_create(struct snd_card *card, struct pci_dev *pci,
680 679
681 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 680 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
682 if (err < 0) { 681 if (err < 0) {
683 snd_printk(KERN_ERR SFX "Error creating device [card]!\n"); 682 dev_err(chip->card->dev, "Error creating device [card]!\n");
684 goto errout; 683 goto errout;
685 } 684 }
686 685
@@ -717,14 +716,13 @@ static int lola_probe(struct pci_dev *pci,
717 return -ENOENT; 716 return -ENOENT;
718 } 717 }
719 718
720 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 719 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
720 0, &card);
721 if (err < 0) { 721 if (err < 0) {
722 snd_printk(KERN_ERR SFX "Error creating card!\n"); 722 dev_err(card->dev, "Error creating card!\n");
723 return err; 723 return err;
724 } 724 }
725 725
726 snd_card_set_dev(card, &pci->dev);
727
728 err = lola_create(card, pci, dev, &chip); 726 err = lola_create(card, pci, dev, &chip);
729 if (err < 0) 727 if (err < 0)
730 goto out_free; 728 goto out_free;
diff --git a/sound/pci/lola/lola_clock.c b/sound/pci/lola/lola_clock.c
index eb1d6b97df16..2bef6b412aee 100644
--- a/sound/pci/lola/lola_clock.c
+++ b/sound/pci/lola/lola_clock.c
@@ -128,21 +128,21 @@ int lola_init_clock_widget(struct lola *chip, int nid)
128 128
129 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val); 129 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
130 if (err < 0) { 130 if (err < 0) {
131 printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid); 131 dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
132 return err; 132 return err;
133 } 133 }
134 134
135 if ((val & 0xfff00000) != 0x01f00000) { /* test SubType and Type */ 135 if ((val & 0xfff00000) != 0x01f00000) { /* test SubType and Type */
136 snd_printdd("No valid clock widget\n"); 136 dev_dbg(chip->card->dev, "No valid clock widget\n");
137 return 0; 137 return 0;
138 } 138 }
139 139
140 chip->clock.nid = nid; 140 chip->clock.nid = nid;
141 chip->clock.items = val & 0xff; 141 chip->clock.items = val & 0xff;
142 snd_printdd("clock_list nid=%x, entries=%d\n", nid, 142 dev_dbg(chip->card->dev, "clock_list nid=%x, entries=%d\n", nid,
143 chip->clock.items); 143 chip->clock.items);
144 if (chip->clock.items > MAX_SAMPLE_CLOCK_COUNT) { 144 if (chip->clock.items > MAX_SAMPLE_CLOCK_COUNT) {
145 printk(KERN_ERR SFX "CLOCK_LIST too big: %d\n", 145 dev_err(chip->card->dev, "CLOCK_LIST too big: %d\n",
146 chip->clock.items); 146 chip->clock.items);
147 return -EINVAL; 147 return -EINVAL;
148 } 148 }
@@ -158,7 +158,7 @@ int lola_init_clock_widget(struct lola *chip, int nid)
158 err = lola_codec_read(chip, nid, LOLA_VERB_GET_CLOCK_LIST, 158 err = lola_codec_read(chip, nid, LOLA_VERB_GET_CLOCK_LIST,
159 idx, 0, &val, &res_ex); 159 idx, 0, &val, &res_ex);
160 if (err < 0) { 160 if (err < 0) {
161 printk(KERN_ERR SFX "Can't read CLOCK_LIST\n"); 161 dev_err(chip->card->dev, "Can't read CLOCK_LIST\n");
162 return -EINVAL; 162 return -EINVAL;
163 } 163 }
164 164
@@ -223,7 +223,7 @@ int lola_enable_clock_events(struct lola *chip)
223 if (err < 0) 223 if (err < 0)
224 return err; 224 return err;
225 if (res) { 225 if (res) {
226 printk(KERN_WARNING SFX "error in enable_clock_events %d\n", 226 dev_warn(chip->card->dev, "error in enable_clock_events %d\n",
227 res); 227 res);
228 return -EINVAL; 228 return -EINVAL;
229 } 229 }
@@ -242,7 +242,7 @@ int lola_set_clock_index(struct lola *chip, unsigned int idx)
242 if (err < 0) 242 if (err < 0)
243 return err; 243 return err;
244 if (res) { 244 if (res) {
245 printk(KERN_WARNING SFX "error in set_clock %d\n", res); 245 dev_warn(chip->card->dev, "error in set_clock %d\n", res);
246 return -EINVAL; 246 return -EINVAL;
247 } 247 }
248 return 0; 248 return 0;
diff --git a/sound/pci/lola/lola_mixer.c b/sound/pci/lola/lola_mixer.c
index 52c8d6b0f39b..782f4d8299ae 100644
--- a/sound/pci/lola/lola_mixer.c
+++ b/sound/pci/lola/lola_mixer.c
@@ -37,7 +37,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
37 pin->nid = nid; 37 pin->nid = nid;
38 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val); 38 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
39 if (err < 0) { 39 if (err < 0) {
40 printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid); 40 dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
41 return err; 41 return err;
42 } 42 }
43 val &= 0x00f00fff; /* test TYPE and bits 0..11 */ 43 val &= 0x00f00fff; /* test TYPE and bits 0..11 */
@@ -48,7 +48,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
48 else if (val == 0x0040000c && dir == PLAY) /* Dig=0, OutAmp/ovrd */ 48 else if (val == 0x0040000c && dir == PLAY) /* Dig=0, OutAmp/ovrd */
49 pin->is_analog = true; 49 pin->is_analog = true;
50 else { 50 else {
51 printk(KERN_ERR SFX "Invalid wcaps 0x%x for 0x%x\n", val, nid); 51 dev_err(chip->card->dev, "Invalid wcaps 0x%x for 0x%x\n", val, nid);
52 return -EINVAL; 52 return -EINVAL;
53 } 53 }
54 54
@@ -62,7 +62,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
62 else 62 else
63 err = lola_read_param(chip, nid, LOLA_PAR_AMP_IN_CAP, &val); 63 err = lola_read_param(chip, nid, LOLA_PAR_AMP_IN_CAP, &val);
64 if (err < 0) { 64 if (err < 0) {
65 printk(KERN_ERR SFX "Can't read AMP-caps for 0x%x\n", nid); 65 dev_err(chip->card->dev, "Can't read AMP-caps for 0x%x\n", nid);
66 return err; 66 return err;
67 } 67 }
68 68
@@ -79,7 +79,7 @@ static int lola_init_pin(struct lola *chip, struct lola_pin *pin,
79 err = lola_codec_read(chip, nid, LOLA_VERB_GET_MAX_LEVEL, 0, 0, &val, 79 err = lola_codec_read(chip, nid, LOLA_VERB_GET_MAX_LEVEL, 0, 0, &val,
80 NULL); 80 NULL);
81 if (err < 0) { 81 if (err < 0) {
82 printk(KERN_ERR SFX "Can't get MAX_LEVEL 0x%x\n", nid); 82 dev_err(chip->card->dev, "Can't get MAX_LEVEL 0x%x\n", nid);
83 return err; 83 return err;
84 } 84 }
85 pin->max_level = val & 0x3ff; /* 10 bits */ 85 pin->max_level = val & 0x3ff; /* 10 bits */
@@ -119,12 +119,12 @@ int lola_init_mixer_widget(struct lola *chip, int nid)
119 119
120 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val); 120 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
121 if (err < 0) { 121 if (err < 0) {
122 printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid); 122 dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
123 return err; 123 return err;
124 } 124 }
125 125
126 if ((val & 0xfff00000) != 0x02f00000) { /* test SubType and Type */ 126 if ((val & 0xfff00000) != 0x02f00000) { /* test SubType and Type */
127 snd_printdd("No valid mixer widget\n"); 127 dev_dbg(chip->card->dev, "No valid mixer widget\n");
128 return 0; 128 return 0;
129 } 129 }
130 130
@@ -202,7 +202,7 @@ int lola_init_mixer_widget(struct lola *chip, int nid)
202 */ 202 */
203 if (chip->mixer.src_stream_out_ofs > MAX_AUDIO_INOUT_COUNT || 203 if (chip->mixer.src_stream_out_ofs > MAX_AUDIO_INOUT_COUNT ||
204 chip->mixer.dest_phys_out_ofs > MAX_STREAM_IN_COUNT) { 204 chip->mixer.dest_phys_out_ofs > MAX_STREAM_IN_COUNT) {
205 printk(KERN_ERR SFX "Invalid mixer widget size\n"); 205 dev_err(chip->card->dev, "Invalid mixer widget size\n");
206 return -EINVAL; 206 return -EINVAL;
207 } 207 }
208 208
@@ -213,7 +213,7 @@ int lola_init_mixer_widget(struct lola *chip, int nid)
213 (((1U << chip->mixer.dest_phys_outs) - 1) 213 (((1U << chip->mixer.dest_phys_outs) - 1)
214 << chip->mixer.dest_phys_out_ofs); 214 << chip->mixer.dest_phys_out_ofs);
215 215
216 snd_printdd("Mixer src_mask=%x, dest_mask=%x\n", 216 dev_dbg(chip->card->dev, "Mixer src_mask=%x, dest_mask=%x\n",
217 chip->mixer.src_mask, chip->mixer.dest_mask); 217 chip->mixer.src_mask, chip->mixer.dest_mask);
218 218
219 return 0; 219 return 0;
@@ -236,7 +236,8 @@ static int lola_mixer_set_src_gain(struct lola *chip, unsigned int id,
236 (gain == readw(&chip->mixer.array->src_gain[id]))) 236 (gain == readw(&chip->mixer.array->src_gain[id])))
237 return 0; 237 return 0;
238 238
239 snd_printdd("lola_mixer_set_src_gain (id=%d, gain=%d) enable=%x\n", 239 dev_dbg(chip->card->dev,
240 "lola_mixer_set_src_gain (id=%d, gain=%d) enable=%x\n",
240 id, gain, val); 241 id, gain, val);
241 writew(gain, &chip->mixer.array->src_gain[id]); 242 writew(gain, &chip->mixer.array->src_gain[id]);
242 writel(val, &chip->mixer.array->src_gain_enable); 243 writel(val, &chip->mixer.array->src_gain_enable);
@@ -409,7 +410,8 @@ static int set_analog_volume(struct lola *chip, int dir,
409 return 0; 410 return 0;
410 if (external_call) 411 if (external_call)
411 lola_codec_flush(chip); 412 lola_codec_flush(chip);
412 snd_printdd("set_analog_volume (dir=%d idx=%d, volume=%d)\n", 413 dev_dbg(chip->card->dev,
414 "set_analog_volume (dir=%d idx=%d, volume=%d)\n",
413 dir, idx, val); 415 dir, idx, val);
414 err = lola_codec_write(chip, pin->nid, 416 err = lola_codec_write(chip, pin->nid,
415 LOLA_VERB_SET_AMP_GAIN_MUTE, val, 0); 417 LOLA_VERB_SET_AMP_GAIN_MUTE, val, 0);
diff --git a/sound/pci/lola/lola_pcm.c b/sound/pci/lola/lola_pcm.c
index 5ea85e8b83ab..3bd6985430e8 100644
--- a/sound/pci/lola/lola_pcm.c
+++ b/sound/pci/lola/lola_pcm.c
@@ -103,7 +103,7 @@ static void wait_for_srst_clear(struct lola *chip, struct lola_stream *str)
103 return; 103 return;
104 msleep(1); 104 msleep(1);
105 } 105 }
106 printk(KERN_WARNING SFX "SRST not clear (stream %d)\n", str->dsd); 106 dev_warn(chip->card->dev, "SRST not clear (stream %d)\n", str->dsd);
107} 107}
108 108
109static int lola_stream_wait_for_fifo(struct lola *chip, 109static int lola_stream_wait_for_fifo(struct lola *chip,
@@ -118,7 +118,7 @@ static int lola_stream_wait_for_fifo(struct lola *chip,
118 return 0; 118 return 0;
119 msleep(1); 119 msleep(1);
120 } 120 }
121 printk(KERN_WARNING SFX "FIFO not ready (stream %d)\n", str->dsd); 121 dev_warn(chip->card->dev, "FIFO not ready (stream %d)\n", str->dsd);
122 return -EIO; 122 return -EIO;
123} 123}
124 124
@@ -156,7 +156,7 @@ static int lola_sync_wait_for_fifo(struct lola *chip,
156 return 0; 156 return 0;
157 msleep(1); 157 msleep(1);
158 } 158 }
159 printk(KERN_WARNING SFX "FIFO not ready (pending %d)\n", pending - 1); 159 dev_warn(chip->card->dev, "FIFO not ready (pending %d)\n", pending - 1);
160 return -EIO; 160 return -EIO;
161} 161}
162 162
@@ -373,7 +373,7 @@ static int lola_setup_periods(struct lola *chip, struct lola_pcm *pcm,
373 return 0; 373 return 0;
374 374
375 error: 375 error:
376 snd_printk(KERN_ERR SFX "Too many BDL entries: buffer=%d, period=%d\n", 376 dev_err(chip->card->dev, "Too many BDL entries: buffer=%d, period=%d\n",
377 str->bufsize, period_bytes); 377 str->bufsize, period_bytes);
378 return -EINVAL; 378 return -EINVAL;
379} 379}
@@ -415,7 +415,7 @@ static int lola_set_stream_config(struct lola *chip,
415 err = lola_codec_read(chip, str->nid, LOLA_VERB_SET_STREAM_FORMAT, 415 err = lola_codec_read(chip, str->nid, LOLA_VERB_SET_STREAM_FORMAT,
416 str->format_verb, 0, &val, NULL); 416 str->format_verb, 0, &val, NULL);
417 if (err < 0) { 417 if (err < 0) {
418 printk(KERN_ERR SFX "Cannot set stream format 0x%x\n", 418 dev_err(chip->card->dev, "Cannot set stream format 0x%x\n",
419 str->format_verb); 419 str->format_verb);
420 return err; 420 return err;
421 } 421 }
@@ -427,7 +427,8 @@ static int lola_set_stream_config(struct lola *chip,
427 LOLA_VERB_SET_CHANNEL_STREAMID, 0, verb, 427 LOLA_VERB_SET_CHANNEL_STREAMID, 0, verb,
428 &val, NULL); 428 &val, NULL);
429 if (err < 0) { 429 if (err < 0) {
430 printk(KERN_ERR SFX "Cannot set stream channel %d\n", i); 430 dev_err(chip->card->dev,
431 "Cannot set stream channel %d\n", i);
431 return err; 432 return err;
432 } 433 }
433 } 434 }
@@ -651,13 +652,14 @@ static int lola_init_stream(struct lola *chip, struct lola_stream *str,
651 str->dsd += MAX_STREAM_IN_COUNT; 652 str->dsd += MAX_STREAM_IN_COUNT;
652 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val); 653 err = lola_read_param(chip, nid, LOLA_PAR_AUDIO_WIDGET_CAP, &val);
653 if (err < 0) { 654 if (err < 0) {
654 printk(KERN_ERR SFX "Can't read wcaps for 0x%x\n", nid); 655 dev_err(chip->card->dev, "Can't read wcaps for 0x%x\n", nid);
655 return err; 656 return err;
656 } 657 }
657 if (dir == PLAY) { 658 if (dir == PLAY) {
658 /* test TYPE and bits 0..11 (no test bit9 : Digital = 0/1) */ 659 /* test TYPE and bits 0..11 (no test bit9 : Digital = 0/1) */
659 if ((val & 0x00f00dff) != 0x00000010) { 660 if ((val & 0x00f00dff) != 0x00000010) {
660 printk(KERN_ERR SFX "Invalid wcaps 0x%x for 0x%x\n", 661 dev_err(chip->card->dev,
662 "Invalid wcaps 0x%x for 0x%x\n",
661 val, nid); 663 val, nid);
662 return -EINVAL; 664 return -EINVAL;
663 } 665 }
@@ -666,7 +668,8 @@ static int lola_init_stream(struct lola *chip, struct lola_stream *str,
666 * (bug : ignore bit8: Conn list = 0/1) 668 * (bug : ignore bit8: Conn list = 0/1)
667 */ 669 */
668 if ((val & 0x00f00cff) != 0x00100010) { 670 if ((val & 0x00f00cff) != 0x00100010) {
669 printk(KERN_ERR SFX "Invalid wcaps 0x%x for 0x%x\n", 671 dev_err(chip->card->dev,
672 "Invalid wcaps 0x%x for 0x%x\n",
670 val, nid); 673 val, nid);
671 return -EINVAL; 674 return -EINVAL;
672 } 675 }
@@ -677,14 +680,15 @@ static int lola_init_stream(struct lola *chip, struct lola_stream *str,
677 680
678 err = lola_read_param(chip, nid, LOLA_PAR_STREAM_FORMATS, &val); 681 err = lola_read_param(chip, nid, LOLA_PAR_STREAM_FORMATS, &val);
679 if (err < 0) { 682 if (err < 0) {
680 printk(KERN_ERR SFX "Can't read FORMATS 0x%x\n", nid); 683 dev_err(chip->card->dev, "Can't read FORMATS 0x%x\n", nid);
681 return err; 684 return err;
682 } 685 }
683 val &= 3; 686 val &= 3;
684 if (val == 3) 687 if (val == 3)
685 str->can_float = true; 688 str->can_float = true;
686 if (!(val & 1)) { 689 if (!(val & 1)) {
687 printk(KERN_ERR SFX "Invalid formats 0x%x for 0x%x", val, nid); 690 dev_err(chip->card->dev,
691 "Invalid formats 0x%x for 0x%x", val, nid);
688 return -EINVAL; 692 return -EINVAL;
689 } 693 }
690 return 0; 694 return 0;
diff --git a/sound/pci/lx6464es/lx6464es.c b/sound/pci/lx6464es/lx6464es.c
index 5fcaaa6da4a8..27f60ce8a55c 100644
--- a/sound/pci/lx6464es/lx6464es.c
+++ b/sound/pci/lx6464es/lx6464es.c
@@ -112,16 +112,16 @@ static int lx_hardware_open(struct lx6464es *chip,
112 112
113 snd_pcm_uframes_t period_size = runtime->period_size; 113 snd_pcm_uframes_t period_size = runtime->period_size;
114 114
115 snd_printd(LXP "allocating pipe for %d channels\n", channels); 115 dev_dbg(chip->card->dev, "allocating pipe for %d channels\n", channels);
116 err = lx_pipe_allocate(chip, 0, is_capture, channels); 116 err = lx_pipe_allocate(chip, 0, is_capture, channels);
117 if (err < 0) { 117 if (err < 0) {
118 snd_printk(KERN_ERR LXP "allocating pipe failed\n"); 118 dev_err(chip->card->dev, LXP "allocating pipe failed\n");
119 return err; 119 return err;
120 } 120 }
121 121
122 err = lx_set_granularity(chip, period_size); 122 err = lx_set_granularity(chip, period_size);
123 if (err < 0) { 123 if (err < 0) {
124 snd_printk(KERN_ERR LXP "setting granularity to %ld failed\n", 124 dev_err(chip->card->dev, "setting granularity to %ld failed\n",
125 period_size); 125 period_size);
126 return err; 126 return err;
127 } 127 }
@@ -136,24 +136,24 @@ static int lx_hardware_start(struct lx6464es *chip,
136 struct snd_pcm_runtime *runtime = substream->runtime; 136 struct snd_pcm_runtime *runtime = substream->runtime;
137 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); 137 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
138 138
139 snd_printd(LXP "setting stream format\n"); 139 dev_dbg(chip->card->dev, "setting stream format\n");
140 err = lx_stream_set_format(chip, runtime, 0, is_capture); 140 err = lx_stream_set_format(chip, runtime, 0, is_capture);
141 if (err < 0) { 141 if (err < 0) {
142 snd_printk(KERN_ERR LXP "setting stream format failed\n"); 142 dev_err(chip->card->dev, "setting stream format failed\n");
143 return err; 143 return err;
144 } 144 }
145 145
146 snd_printd(LXP "starting pipe\n"); 146 dev_dbg(chip->card->dev, "starting pipe\n");
147 err = lx_pipe_start(chip, 0, is_capture); 147 err = lx_pipe_start(chip, 0, is_capture);
148 if (err < 0) { 148 if (err < 0) {
149 snd_printk(KERN_ERR LXP "starting pipe failed\n"); 149 dev_err(chip->card->dev, "starting pipe failed\n");
150 return err; 150 return err;
151 } 151 }
152 152
153 snd_printd(LXP "waiting for pipe to start\n"); 153 dev_dbg(chip->card->dev, "waiting for pipe to start\n");
154 err = lx_pipe_wait_for_start(chip, 0, is_capture); 154 err = lx_pipe_wait_for_start(chip, 0, is_capture);
155 if (err < 0) { 155 if (err < 0) {
156 snd_printk(KERN_ERR LXP "waiting for pipe failed\n"); 156 dev_err(chip->card->dev, "waiting for pipe failed\n");
157 return err; 157 return err;
158 } 158 }
159 159
@@ -167,24 +167,24 @@ static int lx_hardware_stop(struct lx6464es *chip,
167 int err = 0; 167 int err = 0;
168 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); 168 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
169 169
170 snd_printd(LXP "pausing pipe\n"); 170 dev_dbg(chip->card->dev, "pausing pipe\n");
171 err = lx_pipe_pause(chip, 0, is_capture); 171 err = lx_pipe_pause(chip, 0, is_capture);
172 if (err < 0) { 172 if (err < 0) {
173 snd_printk(KERN_ERR LXP "pausing pipe failed\n"); 173 dev_err(chip->card->dev, "pausing pipe failed\n");
174 return err; 174 return err;
175 } 175 }
176 176
177 snd_printd(LXP "waiting for pipe to become idle\n"); 177 dev_dbg(chip->card->dev, "waiting for pipe to become idle\n");
178 err = lx_pipe_wait_for_idle(chip, 0, is_capture); 178 err = lx_pipe_wait_for_idle(chip, 0, is_capture);
179 if (err < 0) { 179 if (err < 0) {
180 snd_printk(KERN_ERR LXP "waiting for pipe failed\n"); 180 dev_err(chip->card->dev, "waiting for pipe failed\n");
181 return err; 181 return err;
182 } 182 }
183 183
184 snd_printd(LXP "stopping pipe\n"); 184 dev_dbg(chip->card->dev, "stopping pipe\n");
185 err = lx_pipe_stop(chip, 0, is_capture); 185 err = lx_pipe_stop(chip, 0, is_capture);
186 if (err < 0) { 186 if (err < 0) {
187 snd_printk(LXP "stopping pipe failed\n"); 187 dev_err(chip->card->dev, "stopping pipe failed\n");
188 return err; 188 return err;
189 } 189 }
190 190
@@ -198,10 +198,10 @@ static int lx_hardware_close(struct lx6464es *chip,
198 int err = 0; 198 int err = 0;
199 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); 199 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
200 200
201 snd_printd(LXP "releasing pipe\n"); 201 dev_dbg(chip->card->dev, "releasing pipe\n");
202 err = lx_pipe_release(chip, 0, is_capture); 202 err = lx_pipe_release(chip, 0, is_capture);
203 if (err < 0) { 203 if (err < 0) {
204 snd_printk(LXP "releasing pipe failed\n"); 204 dev_err(chip->card->dev, "releasing pipe failed\n");
205 return err; 205 return err;
206 } 206 }
207 207
@@ -216,7 +216,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
216 int err = 0; 216 int err = 0;
217 int board_rate; 217 int board_rate;
218 218
219 snd_printdd("->lx_pcm_open\n"); 219 dev_dbg(chip->card->dev, "->lx_pcm_open\n");
220 mutex_lock(&chip->setup_mutex); 220 mutex_lock(&chip->setup_mutex);
221 221
222 /* copy the struct snd_pcm_hardware struct */ 222 /* copy the struct snd_pcm_hardware struct */
@@ -227,7 +227,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
227 err = snd_pcm_hw_constraint_integer(runtime, 227 err = snd_pcm_hw_constraint_integer(runtime,
228 SNDRV_PCM_HW_PARAM_PERIODS); 228 SNDRV_PCM_HW_PARAM_PERIODS);
229 if (err < 0) { 229 if (err < 0) {
230 snd_printk(KERN_WARNING LXP "could not constrain periods\n"); 230 dev_warn(chip->card->dev, "could not constrain periods\n");
231 goto exit; 231 goto exit;
232 } 232 }
233#endif 233#endif
@@ -238,7 +238,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
238 board_rate, board_rate); 238 board_rate, board_rate);
239 239
240 if (err < 0) { 240 if (err < 0) {
241 snd_printk(KERN_WARNING LXP "could not constrain periods\n"); 241 dev_warn(chip->card->dev, "could not constrain periods\n");
242 goto exit; 242 goto exit;
243 } 243 }
244 244
@@ -248,7 +248,7 @@ static int lx_pcm_open(struct snd_pcm_substream *substream)
248 MICROBLAZE_IBL_MIN, 248 MICROBLAZE_IBL_MIN,
249 MICROBLAZE_IBL_MAX); 249 MICROBLAZE_IBL_MAX);
250 if (err < 0) { 250 if (err < 0) {
251 snd_printk(KERN_WARNING LXP 251 dev_warn(chip->card->dev,
252 "could not constrain period size\n"); 252 "could not constrain period size\n");
253 goto exit; 253 goto exit;
254 } 254 }
@@ -263,14 +263,14 @@ exit:
263 runtime->private_data = chip; 263 runtime->private_data = chip;
264 264
265 mutex_unlock(&chip->setup_mutex); 265 mutex_unlock(&chip->setup_mutex);
266 snd_printdd("<-lx_pcm_open, %d\n", err); 266 dev_dbg(chip->card->dev, "<-lx_pcm_open, %d\n", err);
267 return err; 267 return err;
268} 268}
269 269
270static int lx_pcm_close(struct snd_pcm_substream *substream) 270static int lx_pcm_close(struct snd_pcm_substream *substream)
271{ 271{
272 int err = 0; 272 int err = 0;
273 snd_printdd("->lx_pcm_close\n"); 273 dev_dbg(substream->pcm->card->dev, "->lx_pcm_close\n");
274 return err; 274 return err;
275} 275}
276 276
@@ -285,13 +285,13 @@ static snd_pcm_uframes_t lx_pcm_stream_pointer(struct snd_pcm_substream
285 struct lx_stream *lx_stream = is_capture ? &chip->capture_stream : 285 struct lx_stream *lx_stream = is_capture ? &chip->capture_stream :
286 &chip->playback_stream; 286 &chip->playback_stream;
287 287
288 snd_printdd("->lx_pcm_stream_pointer\n"); 288 dev_dbg(chip->card->dev, "->lx_pcm_stream_pointer\n");
289 289
290 spin_lock_irqsave(&chip->lock, flags); 290 spin_lock_irqsave(&chip->lock, flags);
291 pos = lx_stream->frame_pos * substream->runtime->period_size; 291 pos = lx_stream->frame_pos * substream->runtime->period_size;
292 spin_unlock_irqrestore(&chip->lock, flags); 292 spin_unlock_irqrestore(&chip->lock, flags);
293 293
294 snd_printdd(LXP "stream_pointer at %ld\n", pos); 294 dev_dbg(chip->card->dev, "stream_pointer at %ld\n", pos);
295 return pos; 295 return pos;
296} 296}
297 297
@@ -301,37 +301,37 @@ static int lx_pcm_prepare(struct snd_pcm_substream *substream)
301 int err = 0; 301 int err = 0;
302 const int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); 302 const int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
303 303
304 snd_printdd("->lx_pcm_prepare\n"); 304 dev_dbg(chip->card->dev, "->lx_pcm_prepare\n");
305 305
306 mutex_lock(&chip->setup_mutex); 306 mutex_lock(&chip->setup_mutex);
307 307
308 if (chip->hardware_running[is_capture]) { 308 if (chip->hardware_running[is_capture]) {
309 err = lx_hardware_stop(chip, substream); 309 err = lx_hardware_stop(chip, substream);
310 if (err < 0) { 310 if (err < 0) {
311 snd_printk(KERN_ERR LXP "failed to stop hardware. " 311 dev_err(chip->card->dev, "failed to stop hardware. "
312 "Error code %d\n", err); 312 "Error code %d\n", err);
313 goto exit; 313 goto exit;
314 } 314 }
315 315
316 err = lx_hardware_close(chip, substream); 316 err = lx_hardware_close(chip, substream);
317 if (err < 0) { 317 if (err < 0) {
318 snd_printk(KERN_ERR LXP "failed to close hardware. " 318 dev_err(chip->card->dev, "failed to close hardware. "
319 "Error code %d\n", err); 319 "Error code %d\n", err);
320 goto exit; 320 goto exit;
321 } 321 }
322 } 322 }
323 323
324 snd_printd(LXP "opening hardware\n"); 324 dev_dbg(chip->card->dev, "opening hardware\n");
325 err = lx_hardware_open(chip, substream); 325 err = lx_hardware_open(chip, substream);
326 if (err < 0) { 326 if (err < 0) {
327 snd_printk(KERN_ERR LXP "failed to open hardware. " 327 dev_err(chip->card->dev, "failed to open hardware. "
328 "Error code %d\n", err); 328 "Error code %d\n", err);
329 goto exit; 329 goto exit;
330 } 330 }
331 331
332 err = lx_hardware_start(chip, substream); 332 err = lx_hardware_start(chip, substream);
333 if (err < 0) { 333 if (err < 0) {
334 snd_printk(KERN_ERR LXP "failed to start hardware. " 334 dev_err(chip->card->dev, "failed to start hardware. "
335 "Error code %d\n", err); 335 "Error code %d\n", err);
336 goto exit; 336 goto exit;
337 } 337 }
@@ -354,7 +354,7 @@ static int lx_pcm_hw_params(struct snd_pcm_substream *substream,
354 struct lx6464es *chip = snd_pcm_substream_chip(substream); 354 struct lx6464es *chip = snd_pcm_substream_chip(substream);
355 int err = 0; 355 int err = 0;
356 356
357 snd_printdd("->lx_pcm_hw_params\n"); 357 dev_dbg(chip->card->dev, "->lx_pcm_hw_params\n");
358 358
359 mutex_lock(&chip->setup_mutex); 359 mutex_lock(&chip->setup_mutex);
360 360
@@ -389,20 +389,20 @@ static int lx_pcm_hw_free(struct snd_pcm_substream *substream)
389 int err = 0; 389 int err = 0;
390 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); 390 int is_capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
391 391
392 snd_printdd("->lx_pcm_hw_free\n"); 392 dev_dbg(chip->card->dev, "->lx_pcm_hw_free\n");
393 mutex_lock(&chip->setup_mutex); 393 mutex_lock(&chip->setup_mutex);
394 394
395 if (chip->hardware_running[is_capture]) { 395 if (chip->hardware_running[is_capture]) {
396 err = lx_hardware_stop(chip, substream); 396 err = lx_hardware_stop(chip, substream);
397 if (err < 0) { 397 if (err < 0) {
398 snd_printk(KERN_ERR LXP "failed to stop hardware. " 398 dev_err(chip->card->dev, "failed to stop hardware. "
399 "Error code %d\n", err); 399 "Error code %d\n", err);
400 goto exit; 400 goto exit;
401 } 401 }
402 402
403 err = lx_hardware_close(chip, substream); 403 err = lx_hardware_close(chip, substream);
404 if (err < 0) { 404 if (err < 0) {
405 snd_printk(KERN_ERR LXP "failed to close hardware. " 405 dev_err(chip->card->dev, "failed to close hardware. "
406 "Error code %d\n", err); 406 "Error code %d\n", err);
407 goto exit; 407 goto exit;
408 } 408 }
@@ -446,25 +446,25 @@ static void lx_trigger_start(struct lx6464es *chip, struct lx_stream *lx_stream)
446 446
447 err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, 447 err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed,
448 size_array); 448 size_array);
449 snd_printdd(LXP "starting: needed %d, freed %d\n", 449 dev_dbg(chip->card->dev, "starting: needed %d, freed %d\n",
450 needed, freed); 450 needed, freed);
451 451
452 err = lx_buffer_give(chip, 0, is_capture, period_bytes, 452 err = lx_buffer_give(chip, 0, is_capture, period_bytes,
453 lower_32_bits(buf), upper_32_bits(buf), 453 lower_32_bits(buf), upper_32_bits(buf),
454 &buffer_index); 454 &buffer_index);
455 455
456 snd_printdd(LXP "starting: buffer index %x on 0x%lx (%d bytes)\n", 456 dev_dbg(chip->card->dev, "starting: buffer index %x on 0x%lx (%d bytes)\n",
457 buffer_index, (unsigned long)buf, period_bytes); 457 buffer_index, (unsigned long)buf, period_bytes);
458 buf += period_bytes; 458 buf += period_bytes;
459 } 459 }
460 460
461 err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array); 461 err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array);
462 snd_printdd(LXP "starting: needed %d, freed %d\n", needed, freed); 462 dev_dbg(chip->card->dev, "starting: needed %d, freed %d\n", needed, freed);
463 463
464 snd_printd(LXP "starting: starting stream\n"); 464 dev_dbg(chip->card->dev, "starting: starting stream\n");
465 err = lx_stream_start(chip, 0, is_capture); 465 err = lx_stream_start(chip, 0, is_capture);
466 if (err < 0) 466 if (err < 0)
467 snd_printk(KERN_ERR LXP "couldn't start stream\n"); 467 dev_err(chip->card->dev, "couldn't start stream\n");
468 else 468 else
469 lx_stream->status = LX_STREAM_STATUS_RUNNING; 469 lx_stream->status = LX_STREAM_STATUS_RUNNING;
470 470
@@ -476,10 +476,10 @@ static void lx_trigger_stop(struct lx6464es *chip, struct lx_stream *lx_stream)
476 const unsigned int is_capture = lx_stream->is_capture; 476 const unsigned int is_capture = lx_stream->is_capture;
477 int err; 477 int err;
478 478
479 snd_printd(LXP "stopping: stopping stream\n"); 479 dev_dbg(chip->card->dev, "stopping: stopping stream\n");
480 err = lx_stream_stop(chip, 0, is_capture); 480 err = lx_stream_stop(chip, 0, is_capture);
481 if (err < 0) 481 if (err < 0)
482 snd_printk(KERN_ERR LXP "couldn't stop stream\n"); 482 dev_err(chip->card->dev, "couldn't stop stream\n");
483 else 483 else
484 lx_stream->status = LX_STREAM_STATUS_FREE; 484 lx_stream->status = LX_STREAM_STATUS_FREE;
485 485
@@ -507,7 +507,7 @@ static void lx_trigger_tasklet(unsigned long data)
507 struct lx6464es *chip = (struct lx6464es *)data; 507 struct lx6464es *chip = (struct lx6464es *)data;
508 unsigned long flags; 508 unsigned long flags;
509 509
510 snd_printdd("->lx_trigger_tasklet\n"); 510 dev_dbg(chip->card->dev, "->lx_trigger_tasklet\n");
511 511
512 spin_lock_irqsave(&chip->lock, flags); 512 spin_lock_irqsave(&chip->lock, flags);
513 lx_trigger_tasklet_dispatch_stream(chip, &chip->capture_stream); 513 lx_trigger_tasklet_dispatch_stream(chip, &chip->capture_stream);
@@ -547,14 +547,14 @@ static int lx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
547 struct lx_stream *stream = is_capture ? &chip->capture_stream : 547 struct lx_stream *stream = is_capture ? &chip->capture_stream :
548 &chip->playback_stream; 548 &chip->playback_stream;
549 549
550 snd_printdd("->lx_pcm_trigger\n"); 550 dev_dbg(chip->card->dev, "->lx_pcm_trigger\n");
551 551
552 return lx_pcm_trigger_dispatch(chip, stream, cmd); 552 return lx_pcm_trigger_dispatch(chip, stream, cmd);
553} 553}
554 554
555static int snd_lx6464es_free(struct lx6464es *chip) 555static int snd_lx6464es_free(struct lx6464es *chip)
556{ 556{
557 snd_printdd("->snd_lx6464es_free\n"); 557 dev_dbg(chip->card->dev, "->snd_lx6464es_free\n");
558 558
559 lx_irq_disable(chip); 559 lx_irq_disable(chip);
560 560
@@ -583,7 +583,7 @@ static int lx_init_xilinx_reset(struct lx6464es *chip)
583 int i; 583 int i;
584 u32 plx_reg = lx_plx_reg_read(chip, ePLX_CHIPSC); 584 u32 plx_reg = lx_plx_reg_read(chip, ePLX_CHIPSC);
585 585
586 snd_printdd("->lx_init_xilinx_reset\n"); 586 dev_dbg(chip->card->dev, "->lx_init_xilinx_reset\n");
587 587
588 /* activate reset of xilinx */ 588 /* activate reset of xilinx */
589 plx_reg &= ~CHIPSC_RESET_XILINX; 589 plx_reg &= ~CHIPSC_RESET_XILINX;
@@ -603,8 +603,8 @@ static int lx_init_xilinx_reset(struct lx6464es *chip)
603 msleep(10); 603 msleep(10);
604 reg_mbox3 = lx_plx_reg_read(chip, ePLX_MBOX3); 604 reg_mbox3 = lx_plx_reg_read(chip, ePLX_MBOX3);
605 if (reg_mbox3) { 605 if (reg_mbox3) {
606 snd_printd(LXP "xilinx reset done\n"); 606 dev_dbg(chip->card->dev, "xilinx reset done\n");
607 snd_printdd(LXP "xilinx took %d loops\n", i); 607 dev_dbg(chip->card->dev, "xilinx took %d loops\n", i);
608 break; 608 break;
609 } 609 }
610 } 610 }
@@ -624,7 +624,7 @@ static int lx_init_xilinx_test(struct lx6464es *chip)
624{ 624{
625 u32 reg; 625 u32 reg;
626 626
627 snd_printdd("->lx_init_xilinx_test\n"); 627 dev_dbg(chip->card->dev, "->lx_init_xilinx_test\n");
628 628
629 /* TEST if we have access to Xilinx/MicroBlaze */ 629 /* TEST if we have access to Xilinx/MicroBlaze */
630 lx_dsp_reg_write(chip, eReg_CSM, 0); 630 lx_dsp_reg_write(chip, eReg_CSM, 0);
@@ -632,19 +632,19 @@ static int lx_init_xilinx_test(struct lx6464es *chip)
632 reg = lx_dsp_reg_read(chip, eReg_CSM); 632 reg = lx_dsp_reg_read(chip, eReg_CSM);
633 633
634 if (reg) { 634 if (reg) {
635 snd_printk(KERN_ERR LXP "Problem: Reg_CSM %x.\n", reg); 635 dev_err(chip->card->dev, "Problem: Reg_CSM %x.\n", reg);
636 636
637 /* PCI9056_SPACE0_REMAP */ 637 /* PCI9056_SPACE0_REMAP */
638 lx_plx_reg_write(chip, ePLX_PCICR, 1); 638 lx_plx_reg_write(chip, ePLX_PCICR, 1);
639 639
640 reg = lx_dsp_reg_read(chip, eReg_CSM); 640 reg = lx_dsp_reg_read(chip, eReg_CSM);
641 if (reg) { 641 if (reg) {
642 snd_printk(KERN_ERR LXP "Error: Reg_CSM %x.\n", reg); 642 dev_err(chip->card->dev, "Error: Reg_CSM %x.\n", reg);
643 return -EAGAIN; /* seems to be appropriate */ 643 return -EAGAIN; /* seems to be appropriate */
644 } 644 }
645 } 645 }
646 646
647 snd_printd(LXP "Xilinx/MicroBlaze access test successful\n"); 647 dev_dbg(chip->card->dev, "Xilinx/MicroBlaze access test successful\n");
648 648
649 return 0; 649 return 0;
650} 650}
@@ -661,7 +661,7 @@ static int lx_init_ethersound_config(struct lx6464es *chip)
661 (64 << IOCR_OUTPUTS_OFFSET) | 661 (64 << IOCR_OUTPUTS_OFFSET) |
662 (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET); 662 (FREQ_RATIO_SINGLE_MODE << FREQ_RATIO_OFFSET);
663 663
664 snd_printdd("->lx_init_ethersound\n"); 664 dev_dbg(chip->card->dev, "->lx_init_ethersound\n");
665 665
666 chip->freq_ratio = FREQ_RATIO_SINGLE_MODE; 666 chip->freq_ratio = FREQ_RATIO_SINGLE_MODE;
667 667
@@ -675,18 +675,18 @@ static int lx_init_ethersound_config(struct lx6464es *chip)
675 675
676 for (i = 0; i != 1000; ++i) { 676 for (i = 0; i != 1000; ++i) {
677 if (lx_dsp_reg_read(chip, eReg_CSES) & 4) { 677 if (lx_dsp_reg_read(chip, eReg_CSES) & 4) {
678 snd_printd(LXP "ethersound initialized after %dms\n", 678 dev_dbg(chip->card->dev, "ethersound initialized after %dms\n",
679 i); 679 i);
680 goto ethersound_initialized; 680 goto ethersound_initialized;
681 } 681 }
682 msleep(1); 682 msleep(1);
683 } 683 }
684 snd_printk(KERN_WARNING LXP 684 dev_warn(chip->card->dev,
685 "ethersound could not be initialized after %dms\n", i); 685 "ethersound could not be initialized after %dms\n", i);
686 return -ETIMEDOUT; 686 return -ETIMEDOUT;
687 687
688 ethersound_initialized: 688 ethersound_initialized:
689 snd_printd(LXP "ethersound initialized\n"); 689 dev_dbg(chip->card->dev, "ethersound initialized\n");
690 return 0; 690 return 0;
691} 691}
692 692
@@ -696,14 +696,14 @@ static int lx_init_get_version_features(struct lx6464es *chip)
696 696
697 int err; 697 int err;
698 698
699 snd_printdd("->lx_init_get_version_features\n"); 699 dev_dbg(chip->card->dev, "->lx_init_get_version_features\n");
700 700
701 err = lx_dsp_get_version(chip, &dsp_version); 701 err = lx_dsp_get_version(chip, &dsp_version);
702 702
703 if (err == 0) { 703 if (err == 0) {
704 u32 freq; 704 u32 freq;
705 705
706 snd_printk(LXP "DSP version: V%02d.%02d #%d\n", 706 dev_info(chip->card->dev, "DSP version: V%02d.%02d #%d\n",
707 (dsp_version>>16) & 0xff, (dsp_version>>8) & 0xff, 707 (dsp_version>>16) & 0xff, (dsp_version>>8) & 0xff,
708 dsp_version & 0xff); 708 dsp_version & 0xff);
709 709
@@ -718,9 +718,9 @@ static int lx_init_get_version_features(struct lx6464es *chip)
718 err = lx_dsp_get_clock_frequency(chip, &freq); 718 err = lx_dsp_get_clock_frequency(chip, &freq);
719 if (err == 0) 719 if (err == 0)
720 chip->board_sample_rate = freq; 720 chip->board_sample_rate = freq;
721 snd_printd(LXP "actual clock frequency %d\n", freq); 721 dev_dbg(chip->card->dev, "actual clock frequency %d\n", freq);
722 } else { 722 } else {
723 snd_printk(KERN_ERR LXP "DSP corrupted \n"); 723 dev_err(chip->card->dev, "DSP corrupted \n");
724 err = -EAGAIN; 724 err = -EAGAIN;
725 } 725 }
726 726
@@ -732,7 +732,7 @@ static int lx_set_granularity(struct lx6464es *chip, u32 gran)
732 int err = 0; 732 int err = 0;
733 u32 snapped_gran = MICROBLAZE_IBL_MIN; 733 u32 snapped_gran = MICROBLAZE_IBL_MIN;
734 734
735 snd_printdd("->lx_set_granularity\n"); 735 dev_dbg(chip->card->dev, "->lx_set_granularity\n");
736 736
737 /* blocksize is a power of 2 */ 737 /* blocksize is a power of 2 */
738 while ((snapped_gran < gran) && 738 while ((snapped_gran < gran) &&
@@ -745,14 +745,14 @@ static int lx_set_granularity(struct lx6464es *chip, u32 gran)
745 745
746 err = lx_dsp_set_granularity(chip, snapped_gran); 746 err = lx_dsp_set_granularity(chip, snapped_gran);
747 if (err < 0) { 747 if (err < 0) {
748 snd_printk(KERN_WARNING LXP "could not set granularity\n"); 748 dev_warn(chip->card->dev, "could not set granularity\n");
749 err = -EAGAIN; 749 err = -EAGAIN;
750 } 750 }
751 751
752 if (snapped_gran != gran) 752 if (snapped_gran != gran)
753 snd_printk(LXP "snapped blocksize to %d\n", snapped_gran); 753 dev_err(chip->card->dev, "snapped blocksize to %d\n", snapped_gran);
754 754
755 snd_printd(LXP "set blocksize on board %d\n", snapped_gran); 755 dev_dbg(chip->card->dev, "set blocksize on board %d\n", snapped_gran);
756 chip->pcm_granularity = snapped_gran; 756 chip->pcm_granularity = snapped_gran;
757 757
758 return err; 758 return err;
@@ -764,19 +764,19 @@ static int lx_init_dsp(struct lx6464es *chip)
764 int err; 764 int err;
765 int i; 765 int i;
766 766
767 snd_printdd("->lx_init_dsp\n"); 767 dev_dbg(chip->card->dev, "->lx_init_dsp\n");
768 768
769 snd_printd(LXP "initialize board\n"); 769 dev_dbg(chip->card->dev, "initialize board\n");
770 err = lx_init_xilinx_reset(chip); 770 err = lx_init_xilinx_reset(chip);
771 if (err) 771 if (err)
772 return err; 772 return err;
773 773
774 snd_printd(LXP "testing board\n"); 774 dev_dbg(chip->card->dev, "testing board\n");
775 err = lx_init_xilinx_test(chip); 775 err = lx_init_xilinx_test(chip);
776 if (err) 776 if (err)
777 return err; 777 return err;
778 778
779 snd_printd(LXP "initialize ethersound configuration\n"); 779 dev_dbg(chip->card->dev, "initialize ethersound configuration\n");
780 err = lx_init_ethersound_config(chip); 780 err = lx_init_ethersound_config(chip);
781 if (err) 781 if (err)
782 return err; 782 return err;
@@ -797,8 +797,9 @@ static int lx_init_dsp(struct lx6464es *chip)
797 return -ETIMEDOUT; 797 return -ETIMEDOUT;
798 798
799mac_ready: 799mac_ready:
800 snd_printd(LXP "mac address ready read after: %dms\n", i); 800 dev_dbg(chip->card->dev, "mac address ready read after: %dms\n", i);
801 snd_printk(LXP "mac address: %02X.%02X.%02X.%02X.%02X.%02X\n", 801 dev_info(chip->card->dev,
802 "mac address: %02X.%02X.%02X.%02X.%02X.%02X\n",
802 chip->mac_address[0], chip->mac_address[1], chip->mac_address[2], 803 chip->mac_address[0], chip->mac_address[1], chip->mac_address[2],
803 chip->mac_address[3], chip->mac_address[4], chip->mac_address[5]); 804 chip->mac_address[3], chip->mac_address[4], chip->mac_address[5]);
804 805
@@ -977,7 +978,7 @@ static int snd_lx6464es_create(struct snd_card *card,
977 .dev_free = snd_lx6464es_dev_free, 978 .dev_free = snd_lx6464es_dev_free,
978 }; 979 };
979 980
980 snd_printdd("->snd_lx6464es_create\n"); 981 dev_dbg(card->dev, "->snd_lx6464es_create\n");
981 982
982 *rchip = NULL; 983 *rchip = NULL;
983 984
@@ -991,8 +992,8 @@ static int snd_lx6464es_create(struct snd_card *card,
991 /* check if we can restrict PCI DMA transfers to 32 bits */ 992 /* check if we can restrict PCI DMA transfers to 32 bits */
992 err = pci_set_dma_mask(pci, DMA_BIT_MASK(32)); 993 err = pci_set_dma_mask(pci, DMA_BIT_MASK(32));
993 if (err < 0) { 994 if (err < 0) {
994 snd_printk(KERN_ERR "architecture does not support " 995 dev_err(card->dev,
995 "32bit PCI busmaster DMA\n"); 996 "architecture does not support 32bit PCI busmaster DMA\n");
996 pci_disable_device(pci); 997 pci_disable_device(pci);
997 return -ENXIO; 998 return -ENXIO;
998 } 999 }
@@ -1034,7 +1035,7 @@ static int snd_lx6464es_create(struct snd_card *card,
1034 err = request_irq(pci->irq, lx_interrupt, IRQF_SHARED, 1035 err = request_irq(pci->irq, lx_interrupt, IRQF_SHARED,
1035 KBUILD_MODNAME, chip); 1036 KBUILD_MODNAME, chip);
1036 if (err) { 1037 if (err) {
1037 snd_printk(KERN_ERR LXP "unable to grab IRQ %d\n", pci->irq); 1038 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1038 goto request_irq_failed; 1039 goto request_irq_failed;
1039 } 1040 }
1040 chip->irq = pci->irq; 1041 chip->irq = pci->irq;
@@ -1045,7 +1046,7 @@ static int snd_lx6464es_create(struct snd_card *card,
1045 1046
1046 err = lx_init_dsp(chip); 1047 err = lx_init_dsp(chip);
1047 if (err < 0) { 1048 if (err < 0) {
1048 snd_printk(KERN_ERR LXP "error during DSP initialization\n"); 1049 dev_err(card->dev, "error during DSP initialization\n");
1049 return err; 1050 return err;
1050 } 1051 }
1051 1052
@@ -1062,8 +1063,6 @@ static int snd_lx6464es_create(struct snd_card *card,
1062 if (err < 0) 1063 if (err < 0)
1063 return err; 1064 return err;
1064 1065
1065 snd_card_set_dev(card, &pci->dev);
1066
1067 *rchip = chip; 1066 *rchip = chip;
1068 return 0; 1067 return 0;
1069 1068
@@ -1090,7 +1089,7 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
1090 struct lx6464es *chip; 1089 struct lx6464es *chip;
1091 int err; 1090 int err;
1092 1091
1093 snd_printdd("->snd_lx6464es_probe\n"); 1092 dev_dbg(&pci->dev, "->snd_lx6464es_probe\n");
1094 1093
1095 if (dev >= SNDRV_CARDS) 1094 if (dev >= SNDRV_CARDS)
1096 return -ENODEV; 1095 return -ENODEV;
@@ -1099,13 +1098,14 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
1099 return -ENOENT; 1098 return -ENOENT;
1100 } 1099 }
1101 1100
1102 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1101 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1102 0, &card);
1103 if (err < 0) 1103 if (err < 0)
1104 return err; 1104 return err;
1105 1105
1106 err = snd_lx6464es_create(card, pci, &chip); 1106 err = snd_lx6464es_create(card, pci, &chip);
1107 if (err < 0) { 1107 if (err < 0) {
1108 snd_printk(KERN_ERR LXP "error during snd_lx6464es_create\n"); 1108 dev_err(card->dev, "error during snd_lx6464es_create\n");
1109 goto out_free; 1109 goto out_free;
1110 } 1110 }
1111 1111
@@ -1125,7 +1125,7 @@ static int snd_lx6464es_probe(struct pci_dev *pci,
1125 if (err < 0) 1125 if (err < 0)
1126 goto out_free; 1126 goto out_free;
1127 1127
1128 snd_printdd(LXP "initialization successful\n"); 1128 dev_dbg(chip->card->dev, "initialization successful\n");
1129 pci_set_drvdata(pci, card); 1129 pci_set_drvdata(pci, card);
1130 dev++; 1130 dev++;
1131 return 0; 1131 return 0;
diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c
index 626ecad4dae7..2d8e95e9fbe5 100644
--- a/sound/pci/lx6464es/lx_core.c
+++ b/sound/pci/lx6464es/lx_core.c
@@ -141,63 +141,6 @@ void lx_plx_reg_write(struct lx6464es *chip, int port, u32 data)
141 iowrite32(data, address); 141 iowrite32(data, address);
142} 142}
143 143
144u32 lx_plx_mbox_read(struct lx6464es *chip, int mbox_nr)
145{
146 int index;
147
148 switch (mbox_nr) {
149 case 1:
150 index = ePLX_MBOX1; break;
151 case 2:
152 index = ePLX_MBOX2; break;
153 case 3:
154 index = ePLX_MBOX3; break;
155 case 4:
156 index = ePLX_MBOX4; break;
157 case 5:
158 index = ePLX_MBOX5; break;
159 case 6:
160 index = ePLX_MBOX6; break;
161 case 7:
162 index = ePLX_MBOX7; break;
163 case 0: /* reserved for HF flags */
164 snd_BUG();
165 default:
166 return 0xdeadbeef;
167 }
168
169 return lx_plx_reg_read(chip, index);
170}
171
172int lx_plx_mbox_write(struct lx6464es *chip, int mbox_nr, u32 value)
173{
174 int index = -1;
175
176 switch (mbox_nr) {
177 case 1:
178 index = ePLX_MBOX1; break;
179 case 3:
180 index = ePLX_MBOX3; break;
181 case 4:
182 index = ePLX_MBOX4; break;
183 case 5:
184 index = ePLX_MBOX5; break;
185 case 6:
186 index = ePLX_MBOX6; break;
187 case 7:
188 index = ePLX_MBOX7; break;
189 case 0: /* reserved for HF flags */
190 case 2: /* reserved for Pipe States
191 * the DSP keeps an image of it */
192 snd_BUG();
193 return -EBADRQC;
194 }
195
196 lx_plx_reg_write(chip, index, value);
197 return 0;
198}
199
200
201/* rmh */ 144/* rmh */
202 145
203#ifdef CONFIG_SND_DEBUG 146#ifdef CONFIG_SND_DEBUG
@@ -330,7 +273,7 @@ static int lx_message_send_atomic(struct lx6464es *chip, struct lx_rmh *rmh)
330 int dwloop; 273 int dwloop;
331 274
332 if (lx_dsp_reg_read(chip, eReg_CSM) & (Reg_CSM_MC | Reg_CSM_MR)) { 275 if (lx_dsp_reg_read(chip, eReg_CSM) & (Reg_CSM_MC | Reg_CSM_MR)) {
333 snd_printk(KERN_ERR LXP "PIOSendMessage eReg_CSM %x\n", reg); 276 dev_err(chip->card->dev, "PIOSendMessage eReg_CSM %x\n", reg);
334 return -EBUSY; 277 return -EBUSY;
335 } 278 }
336 279
@@ -351,7 +294,7 @@ static int lx_message_send_atomic(struct lx6464es *chip, struct lx_rmh *rmh)
351 } else 294 } else
352 udelay(1); 295 udelay(1);
353 } 296 }
354 snd_printk(KERN_WARNING LXP "TIMEOUT lx_message_send_atomic! " 297 dev_warn(chip->card->dev, "TIMEOUT lx_message_send_atomic! "
355 "polling failed\n"); 298 "polling failed\n");
356 299
357polling_successful: 300polling_successful:
@@ -363,18 +306,18 @@ polling_successful:
363 rmh->stat_len); 306 rmh->stat_len);
364 } 307 }
365 } else 308 } else
366 snd_printk(LXP "rmh error: %08x\n", reg); 309 dev_err(chip->card->dev, "rmh error: %08x\n", reg);
367 310
368 /* clear Reg_CSM_MR */ 311 /* clear Reg_CSM_MR */
369 lx_dsp_reg_write(chip, eReg_CSM, 0); 312 lx_dsp_reg_write(chip, eReg_CSM, 0);
370 313
371 switch (reg) { 314 switch (reg) {
372 case ED_DSP_TIMED_OUT: 315 case ED_DSP_TIMED_OUT:
373 snd_printk(KERN_WARNING LXP "lx_message_send: dsp timeout\n"); 316 dev_warn(chip->card->dev, "lx_message_send: dsp timeout\n");
374 return -ETIMEDOUT; 317 return -ETIMEDOUT;
375 318
376 case ED_DSP_CRASHED: 319 case ED_DSP_CRASHED:
377 snd_printk(KERN_WARNING LXP "lx_message_send: dsp crashed\n"); 320 dev_warn(chip->card->dev, "lx_message_send: dsp crashed\n");
378 return -EAGAIN; 321 return -EAGAIN;
379 } 322 }
380 323
@@ -491,33 +434,6 @@ int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data)
491#define CSES_BROADCAST 0x0002 434#define CSES_BROADCAST 0x0002
492#define CSES_UPDATE_LDSV 0x0004 435#define CSES_UPDATE_LDSV 0x0004
493 436
494int lx_dsp_es_check_pipeline(struct lx6464es *chip)
495{
496 int i;
497
498 for (i = 0; i != CSES_TIMEOUT; ++i) {
499 /*
500 * le bit CSES_UPDATE_LDSV est à 1 dés que le macprog
501 * est pret. il re-passe à 0 lorsque le premier read a
502 * été fait. pour l'instant on retire le test car ce bit
503 * passe a 1 environ 200 à 400 ms aprés que le registre
504 * confES à été écrit (kick du xilinx ES).
505 *
506 * On ne teste que le bit CE.
507 * */
508
509 u32 cses = lx_dsp_reg_read(chip, eReg_CSES);
510
511 if ((cses & CSES_CE) == 0)
512 return 0;
513
514 udelay(1);
515 }
516
517 return -ETIMEDOUT;
518}
519
520
521#define PIPE_INFO_TO_CMD(capture, pipe) \ 437#define PIPE_INFO_TO_CMD(capture, pipe) \
522 ((u32)((u32)(pipe) | ((capture) ? ID_IS_CAPTURE : 0L)) << ID_OFFSET) 438 ((u32)((u32)(pipe) | ((capture) ? ID_IS_CAPTURE : 0L)) << ID_OFFSET)
523 439
@@ -542,7 +458,7 @@ int lx_pipe_allocate(struct lx6464es *chip, u32 pipe, int is_capture,
542 spin_unlock_irqrestore(&chip->msg_lock, flags); 458 spin_unlock_irqrestore(&chip->msg_lock, flags);
543 459
544 if (err != 0) 460 if (err != 0)
545 snd_printk(KERN_ERR "lx6464es: could not allocate pipe\n"); 461 dev_err(chip->card->dev, "could not allocate pipe\n");
546 462
547 return err; 463 return err;
548} 464}
@@ -604,11 +520,13 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture,
604 } 520 }
605 521
606#if 0 522#if 0
607 snd_printdd(LXP "CMD_08_ASK_BUFFERS: needed %d, freed %d\n", 523 dev_dbg(chip->card->dev,
524 "CMD_08_ASK_BUFFERS: needed %d, freed %d\n",
608 *r_needed, *r_freed); 525 *r_needed, *r_freed);
609 for (i = 0; i < MAX_STREAM_BUFFER; ++i) { 526 for (i = 0; i < MAX_STREAM_BUFFER; ++i) {
610 for (i = 0; i != chip->rmh.stat_len; ++i) 527 for (i = 0; i != chip->rmh.stat_len; ++i)
611 snd_printdd(" stat[%d]: %x, %x\n", i, 528 dev_dbg(chip->card->dev,
529 " stat[%d]: %x, %x\n", i,
612 chip->rmh.stat[i], 530 chip->rmh.stat[i],
613 chip->rmh.stat[i] & MASK_DATA_SIZE); 531 chip->rmh.stat[i] & MASK_DATA_SIZE);
614 } 532 }
@@ -701,8 +619,8 @@ int lx_pipe_sample_count(struct lx6464es *chip, u32 pipe, int is_capture,
701 err = lx_message_send_atomic(chip, &chip->rmh); /* don't sleep! */ 619 err = lx_message_send_atomic(chip, &chip->rmh); /* don't sleep! */
702 620
703 if (err != 0) 621 if (err != 0)
704 snd_printk(KERN_ERR 622 dev_err(chip->card->dev,
705 "lx6464es: could not query pipe's sample count\n"); 623 "could not query pipe's sample count\n");
706 else { 624 else {
707 *rsample_count = ((u64)(chip->rmh.stat[0] & MASK_SPL_COUNT_HI) 625 *rsample_count = ((u64)(chip->rmh.stat[0] & MASK_SPL_COUNT_HI)
708 << 24) /* hi part */ 626 << 24) /* hi part */
@@ -728,7 +646,7 @@ int lx_pipe_state(struct lx6464es *chip, u32 pipe, int is_capture, u16 *rstate)
728 err = lx_message_send_atomic(chip, &chip->rmh); 646 err = lx_message_send_atomic(chip, &chip->rmh);
729 647
730 if (err != 0) 648 if (err != 0)
731 snd_printk(KERN_ERR "lx6464es: could not query pipe's state\n"); 649 dev_err(chip->card->dev, "could not query pipe's state\n");
732 else 650 else
733 *rstate = (chip->rmh.stat[0] >> PSTATE_OFFSET) & 0x0F; 651 *rstate = (chip->rmh.stat[0] >> PSTATE_OFFSET) & 0x0F;
734 652
@@ -801,7 +719,7 @@ int lx_stream_set_format(struct lx6464es *chip, struct snd_pcm_runtime *runtime,
801 u32 channels = runtime->channels; 719 u32 channels = runtime->channels;
802 720
803 if (runtime->channels != channels) 721 if (runtime->channels != channels)
804 snd_printk(KERN_ERR LXP "channel count mismatch: %d vs %d", 722 dev_err(chip->card->dev, "channel count mismatch: %d vs %d",
805 runtime->channels, channels); 723 runtime->channels, channels);
806 724
807 spin_lock_irqsave(&chip->msg_lock, flags); 725 spin_lock_irqsave(&chip->msg_lock, flags);
@@ -904,13 +822,16 @@ int lx_buffer_give(struct lx6464es *chip, u32 pipe, int is_capture,
904 } 822 }
905 823
906 if (err == EB_RBUFFERS_TABLE_OVERFLOW) 824 if (err == EB_RBUFFERS_TABLE_OVERFLOW)
907 snd_printk(LXP "lx_buffer_give EB_RBUFFERS_TABLE_OVERFLOW\n"); 825 dev_err(chip->card->dev,
826 "lx_buffer_give EB_RBUFFERS_TABLE_OVERFLOW\n");
908 827
909 if (err == EB_INVALID_STREAM) 828 if (err == EB_INVALID_STREAM)
910 snd_printk(LXP "lx_buffer_give EB_INVALID_STREAM\n"); 829 dev_err(chip->card->dev,
830 "lx_buffer_give EB_INVALID_STREAM\n");
911 831
912 if (err == EB_CMD_REFUSED) 832 if (err == EB_CMD_REFUSED)
913 snd_printk(LXP "lx_buffer_give EB_CMD_REFUSED\n"); 833 dev_err(chip->card->dev,
834 "lx_buffer_give EB_CMD_REFUSED\n");
914 835
915 done: 836 done:
916 spin_unlock_irqrestore(&chip->msg_lock, flags); 837 spin_unlock_irqrestore(&chip->msg_lock, flags);
@@ -983,7 +904,8 @@ int lx_level_unmute(struct lx6464es *chip, int is_capture, int unmute)
983 chip->rmh.cmd[1] = (u32)(mute_mask >> (u64)32); /* hi part */ 904 chip->rmh.cmd[1] = (u32)(mute_mask >> (u64)32); /* hi part */
984 chip->rmh.cmd[2] = (u32)(mute_mask & (u64)0xFFFFFFFF); /* lo part */ 905 chip->rmh.cmd[2] = (u32)(mute_mask & (u64)0xFFFFFFFF); /* lo part */
985 906
986 snd_printk("mute %x %x %x\n", chip->rmh.cmd[0], chip->rmh.cmd[1], 907 dev_dbg(chip->card->dev,
908 "mute %x %x %x\n", chip->rmh.cmd[0], chip->rmh.cmd[1],
987 chip->rmh.cmd[2]); 909 chip->rmh.cmd[2]);
988 910
989 err = lx_message_send_atomic(chip, &chip->rmh); 911 err = lx_message_send_atomic(chip, &chip->rmh);
@@ -1093,7 +1015,7 @@ static int lx_interrupt_ack(struct lx6464es *chip, u32 *r_irqsrc,
1093 } 1015 }
1094 1016
1095 if (irq_async) { 1017 if (irq_async) {
1096 /* snd_printd("interrupt: async event pending\n"); */ 1018 /* dev_dbg(chip->card->dev, "interrupt: async event pending\n"); */
1097 *r_async_pending = 1; 1019 *r_async_pending = 1;
1098 } 1020 }
1099 1021
@@ -1139,13 +1061,13 @@ static int lx_interrupt_handle_async_events(struct lx6464es *chip, u32 irqsrc,
1139 if (eb_pending_in) { 1061 if (eb_pending_in) {
1140 *r_notified_in_pipe_mask = ((u64)stat[3] << 32) 1062 *r_notified_in_pipe_mask = ((u64)stat[3] << 32)
1141 + stat[4]; 1063 + stat[4];
1142 snd_printdd(LXP "interrupt: EOBI pending %llx\n", 1064 dev_dbg(chip->card->dev, "interrupt: EOBI pending %llx\n",
1143 *r_notified_in_pipe_mask); 1065 *r_notified_in_pipe_mask);
1144 } 1066 }
1145 if (eb_pending_out) { 1067 if (eb_pending_out) {
1146 *r_notified_out_pipe_mask = ((u64)stat[1] << 32) 1068 *r_notified_out_pipe_mask = ((u64)stat[1] << 32)
1147 + stat[2]; 1069 + stat[2];
1148 snd_printdd(LXP "interrupt: EOBO pending %llx\n", 1070 dev_dbg(chip->card->dev, "interrupt: EOBO pending %llx\n",
1149 *r_notified_out_pipe_mask); 1071 *r_notified_out_pipe_mask);
1150 } 1072 }
1151 1073
@@ -1181,17 +1103,19 @@ static int lx_interrupt_request_new_buffer(struct lx6464es *chip,
1181 u32 needed, freed; 1103 u32 needed, freed;
1182 u32 size_array[MAX_STREAM_BUFFER]; 1104 u32 size_array[MAX_STREAM_BUFFER];
1183 1105
1184 snd_printdd("->lx_interrupt_request_new_buffer\n"); 1106 dev_dbg(chip->card->dev, "->lx_interrupt_request_new_buffer\n");
1185 1107
1186 spin_lock_irqsave(&chip->lock, flags); 1108 spin_lock_irqsave(&chip->lock, flags);
1187 1109
1188 err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array); 1110 err = lx_buffer_ask(chip, 0, is_capture, &needed, &freed, size_array);
1189 snd_printdd(LXP "interrupt: needed %d, freed %d\n", needed, freed); 1111 dev_dbg(chip->card->dev,
1112 "interrupt: needed %d, freed %d\n", needed, freed);
1190 1113
1191 unpack_pointer(buf, &buf_lo, &buf_hi); 1114 unpack_pointer(buf, &buf_lo, &buf_hi);
1192 err = lx_buffer_give(chip, 0, is_capture, period_bytes, buf_lo, buf_hi, 1115 err = lx_buffer_give(chip, 0, is_capture, period_bytes, buf_lo, buf_hi,
1193 &buffer_index); 1116 &buffer_index);
1194 snd_printdd(LXP "interrupt: gave buffer index %x on 0x%lx (%d bytes)\n", 1117 dev_dbg(chip->card->dev,
1118 "interrupt: gave buffer index %x on 0x%lx (%d bytes)\n",
1195 buffer_index, (unsigned long)buf, period_bytes); 1119 buffer_index, (unsigned long)buf, period_bytes);
1196 1120
1197 lx_stream->frame_pos = next_pos; 1121 lx_stream->frame_pos = next_pos;
@@ -1206,11 +1130,11 @@ void lx_tasklet_playback(unsigned long data)
1206 struct lx_stream *lx_stream = &chip->playback_stream; 1130 struct lx_stream *lx_stream = &chip->playback_stream;
1207 int err; 1131 int err;
1208 1132
1209 snd_printdd("->lx_tasklet_playback\n"); 1133 dev_dbg(chip->card->dev, "->lx_tasklet_playback\n");
1210 1134
1211 err = lx_interrupt_request_new_buffer(chip, lx_stream); 1135 err = lx_interrupt_request_new_buffer(chip, lx_stream);
1212 if (err < 0) 1136 if (err < 0)
1213 snd_printk(KERN_ERR LXP 1137 dev_err(chip->card->dev,
1214 "cannot request new buffer for playback\n"); 1138 "cannot request new buffer for playback\n");
1215 1139
1216 snd_pcm_period_elapsed(lx_stream->stream); 1140 snd_pcm_period_elapsed(lx_stream->stream);
@@ -1222,10 +1146,10 @@ void lx_tasklet_capture(unsigned long data)
1222 struct lx_stream *lx_stream = &chip->capture_stream; 1146 struct lx_stream *lx_stream = &chip->capture_stream;
1223 int err; 1147 int err;
1224 1148
1225 snd_printdd("->lx_tasklet_capture\n"); 1149 dev_dbg(chip->card->dev, "->lx_tasklet_capture\n");
1226 err = lx_interrupt_request_new_buffer(chip, lx_stream); 1150 err = lx_interrupt_request_new_buffer(chip, lx_stream);
1227 if (err < 0) 1151 if (err < 0)
1228 snd_printk(KERN_ERR LXP 1152 dev_err(chip->card->dev,
1229 "cannot request new buffer for capture\n"); 1153 "cannot request new buffer for capture\n");
1230 1154
1231 snd_pcm_period_elapsed(lx_stream->stream); 1155 snd_pcm_period_elapsed(lx_stream->stream);
@@ -1240,12 +1164,14 @@ static int lx_interrupt_handle_audio_transfer(struct lx6464es *chip,
1240 int err = 0; 1164 int err = 0;
1241 1165
1242 if (notified_in_pipe_mask) { 1166 if (notified_in_pipe_mask) {
1243 snd_printdd(LXP "requesting audio transfer for capture\n"); 1167 dev_dbg(chip->card->dev,
1168 "requesting audio transfer for capture\n");
1244 tasklet_hi_schedule(&chip->tasklet_capture); 1169 tasklet_hi_schedule(&chip->tasklet_capture);
1245 } 1170 }
1246 1171
1247 if (notified_out_pipe_mask) { 1172 if (notified_out_pipe_mask) {
1248 snd_printdd(LXP "requesting audio transfer for playback\n"); 1173 dev_dbg(chip->card->dev,
1174 "requesting audio transfer for playback\n");
1249 tasklet_hi_schedule(&chip->tasklet_playback); 1175 tasklet_hi_schedule(&chip->tasklet_playback);
1250 } 1176 }
1251 1177
@@ -1261,11 +1187,12 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
1261 1187
1262 spin_lock(&chip->lock); 1188 spin_lock(&chip->lock);
1263 1189
1264 snd_printdd("**************************************************\n"); 1190 dev_dbg(chip->card->dev,
1191 "**************************************************\n");
1265 1192
1266 if (!lx_interrupt_ack(chip, &irqsrc, &async_pending, &async_escmd)) { 1193 if (!lx_interrupt_ack(chip, &irqsrc, &async_pending, &async_escmd)) {
1267 spin_unlock(&chip->lock); 1194 spin_unlock(&chip->lock);
1268 snd_printdd("IRQ_NONE\n"); 1195 dev_dbg(chip->card->dev, "IRQ_NONE\n");
1269 return IRQ_NONE; /* this device did not cause the interrupt */ 1196 return IRQ_NONE; /* this device did not cause the interrupt */
1270 } 1197 }
1271 1198
@@ -1274,16 +1201,16 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
1274 1201
1275#if 0 1202#if 0
1276 if (irqsrc & MASK_SYS_STATUS_EOBI) 1203 if (irqsrc & MASK_SYS_STATUS_EOBI)
1277 snd_printdd(LXP "interrupt: EOBI\n"); 1204 dev_dgg(chip->card->dev, "interrupt: EOBI\n");
1278 1205
1279 if (irqsrc & MASK_SYS_STATUS_EOBO) 1206 if (irqsrc & MASK_SYS_STATUS_EOBO)
1280 snd_printdd(LXP "interrupt: EOBO\n"); 1207 dev_dbg(chip->card->dev, "interrupt: EOBO\n");
1281 1208
1282 if (irqsrc & MASK_SYS_STATUS_URUN) 1209 if (irqsrc & MASK_SYS_STATUS_URUN)
1283 snd_printdd(LXP "interrupt: URUN\n"); 1210 dev_dbg(chip->card->dev, "interrupt: URUN\n");
1284 1211
1285 if (irqsrc & MASK_SYS_STATUS_ORUN) 1212 if (irqsrc & MASK_SYS_STATUS_ORUN)
1286 snd_printdd(LXP "interrupt: ORUN\n"); 1213 dev_dbg(chip->card->dev, "interrupt: ORUN\n");
1287#endif 1214#endif
1288 1215
1289 if (async_pending) { 1216 if (async_pending) {
@@ -1298,7 +1225,7 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
1298 &notified_in_pipe_mask, 1225 &notified_in_pipe_mask,
1299 &notified_out_pipe_mask); 1226 &notified_out_pipe_mask);
1300 if (err) 1227 if (err)
1301 snd_printk(KERN_ERR LXP 1228 dev_err(chip->card->dev,
1302 "error handling async events\n"); 1229 "error handling async events\n");
1303 1230
1304 err = lx_interrupt_handle_audio_transfer(chip, 1231 err = lx_interrupt_handle_audio_transfer(chip,
@@ -1306,7 +1233,7 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
1306 notified_out_pipe_mask 1233 notified_out_pipe_mask
1307 ); 1234 );
1308 if (err) 1235 if (err)
1309 snd_printk(KERN_ERR LXP 1236 dev_err(chip->card->dev,
1310 "error during audio transfer\n"); 1237 "error during audio transfer\n");
1311 } 1238 }
1312 1239
@@ -1318,7 +1245,7 @@ irqreturn_t lx_interrupt(int irq, void *dev_id)
1318 * 1245 *
1319 * */ 1246 * */
1320 1247
1321 snd_printdd("lx6464es: interrupt requests escmd handling\n"); 1248 dev_dbg(chip->card->dev, "interrupt requests escmd handling\n");
1322#endif 1249#endif
1323 } 1250 }
1324 1251
@@ -1346,12 +1273,12 @@ static void lx_irq_set(struct lx6464es *chip, int enable)
1346 1273
1347void lx_irq_enable(struct lx6464es *chip) 1274void lx_irq_enable(struct lx6464es *chip)
1348{ 1275{
1349 snd_printdd("->lx_irq_enable\n"); 1276 dev_dbg(chip->card->dev, "->lx_irq_enable\n");
1350 lx_irq_set(chip, 1); 1277 lx_irq_set(chip, 1);
1351} 1278}
1352 1279
1353void lx_irq_disable(struct lx6464es *chip) 1280void lx_irq_disable(struct lx6464es *chip)
1354{ 1281{
1355 snd_printdd("->lx_irq_disable\n"); 1282 dev_dbg(chip->card->dev, "->lx_irq_disable\n");
1356 lx_irq_set(chip, 0); 1283 lx_irq_set(chip, 0);
1357} 1284}
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index d5417360f51f..0d3ea3e79952 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -1403,7 +1403,7 @@ static int snd_m3_pcm_hw_params(struct snd_pcm_substream *substream,
1403 /* set buffer address */ 1403 /* set buffer address */
1404 s->buffer_addr = substream->runtime->dma_addr; 1404 s->buffer_addr = substream->runtime->dma_addr;
1405 if (s->buffer_addr & 0x3) { 1405 if (s->buffer_addr & 0x3) {
1406 snd_printk(KERN_ERR "oh my, not aligned\n"); 1406 dev_err(substream->pcm->card->dev, "oh my, not aligned\n");
1407 s->buffer_addr = s->buffer_addr & ~0x3; 1407 s->buffer_addr = s->buffer_addr & ~0x3;
1408 } 1408 }
1409 return 0; 1409 return 0;
@@ -1900,7 +1900,7 @@ static int snd_m3_ac97_wait(struct snd_m3 *chip)
1900 cpu_relax(); 1900 cpu_relax();
1901 } while (i-- > 0); 1901 } while (i-- > 0);
1902 1902
1903 snd_printk(KERN_ERR "ac97 serial bus busy\n"); 1903 dev_err(chip->card->dev, "ac97 serial bus busy\n");
1904 return 1; 1904 return 1;
1905} 1905}
1906 1906
@@ -2015,7 +2015,8 @@ static void snd_m3_ac97_reset(struct snd_m3 *chip)
2015 delay1 += 10; 2015 delay1 += 10;
2016 delay2 += 100; 2016 delay2 += 100;
2017 2017
2018 snd_printd("maestro3: retrying codec reset with delays of %d and %d ms\n", 2018 dev_dbg(chip->card->dev,
2019 "retrying codec reset with delays of %d and %d ms\n",
2019 delay1, delay2); 2020 delay1, delay2);
2020 } 2021 }
2021 2022
@@ -2194,7 +2195,8 @@ static int snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma *s, int in
2194 address = 0x1100 + ((data_bytes/2) * index); 2195 address = 0x1100 + ((data_bytes/2) * index);
2195 2196
2196 if ((address + (data_bytes/2)) >= 0x1c00) { 2197 if ((address + (data_bytes/2)) >= 0x1c00) {
2197 snd_printk(KERN_ERR "no memory for %d bytes at ind %d (addr 0x%x)\n", 2198 dev_err(chip->card->dev,
2199 "no memory for %d bytes at ind %d (addr 0x%x)\n",
2198 data_bytes, index, address); 2200 data_bytes, index, address);
2199 return -ENOMEM; 2201 return -ENOMEM;
2200 } 2202 }
@@ -2439,8 +2441,7 @@ static int m3_resume(struct device *dev)
2439 pci_set_power_state(pci, PCI_D0); 2441 pci_set_power_state(pci, PCI_D0);
2440 pci_restore_state(pci); 2442 pci_restore_state(pci);
2441 if (pci_enable_device(pci) < 0) { 2443 if (pci_enable_device(pci) < 0) {
2442 printk(KERN_ERR "maestor3: pci_enable_device failed, " 2444 dev_err(dev, "pci_enable_device failed, disabling device\n");
2443 "disabling device\n");
2444 snd_card_disconnect(card); 2445 snd_card_disconnect(card);
2445 return -EIO; 2446 return -EIO;
2446 } 2447 }
@@ -2553,7 +2554,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2553 /* check, if we can restrict PCI DMA transfers to 28 bits */ 2554 /* check, if we can restrict PCI DMA transfers to 28 bits */
2554 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 || 2555 if (pci_set_dma_mask(pci, DMA_BIT_MASK(28)) < 0 ||
2555 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) { 2556 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(28)) < 0) {
2556 snd_printk(KERN_ERR "architecture does not support 28bit PCI busmaster DMA\n"); 2557 dev_err(card->dev,
2558 "architecture does not support 28bit PCI busmaster DMA\n");
2557 pci_disable_device(pci); 2559 pci_disable_device(pci);
2558 return -ENXIO; 2560 return -ENXIO;
2559 } 2561 }
@@ -2586,9 +2588,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2586 else { 2588 else {
2587 quirk = snd_pci_quirk_lookup(pci, m3_amp_quirk_list); 2589 quirk = snd_pci_quirk_lookup(pci, m3_amp_quirk_list);
2588 if (quirk) { 2590 if (quirk) {
2589 snd_printdd(KERN_INFO 2591 dev_info(card->dev, "set amp-gpio for '%s'\n",
2590 "maestro3: set amp-gpio for '%s'\n", 2592 snd_pci_quirk_name(quirk));
2591 snd_pci_quirk_name(quirk));
2592 chip->amp_gpio = quirk->value; 2593 chip->amp_gpio = quirk->value;
2593 } else if (chip->allegro_flag) 2594 } else if (chip->allegro_flag)
2594 chip->amp_gpio = GPO_EXT_AMP_ALLEGRO; 2595 chip->amp_gpio = GPO_EXT_AMP_ALLEGRO;
@@ -2598,9 +2599,8 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2598 2599
2599 quirk = snd_pci_quirk_lookup(pci, m3_irda_quirk_list); 2600 quirk = snd_pci_quirk_lookup(pci, m3_irda_quirk_list);
2600 if (quirk) { 2601 if (quirk) {
2601 snd_printdd(KERN_INFO 2602 dev_info(card->dev, "enabled irda workaround for '%s'\n",
2602 "maestro3: enabled irda workaround for '%s'\n", 2603 snd_pci_quirk_name(quirk));
2603 snd_pci_quirk_name(quirk));
2604 chip->irda_workaround = 1; 2604 chip->irda_workaround = 1;
2605 } 2605 }
2606 quirk = snd_pci_quirk_lookup(pci, m3_hv_quirk_list); 2606 quirk = snd_pci_quirk_lookup(pci, m3_hv_quirk_list);
@@ -2652,7 +2652,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2652 2652
2653 if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED, 2653 if (request_irq(pci->irq, snd_m3_interrupt, IRQF_SHARED,
2654 KBUILD_MODNAME, chip)) { 2654 KBUILD_MODNAME, chip)) {
2655 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2655 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2656 snd_m3_free(chip); 2656 snd_m3_free(chip);
2657 return -ENOMEM; 2657 return -ENOMEM;
2658 } 2658 }
@@ -2661,7 +2661,7 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2661#ifdef CONFIG_PM_SLEEP 2661#ifdef CONFIG_PM_SLEEP
2662 chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH)); 2662 chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH));
2663 if (chip->suspend_mem == NULL) 2663 if (chip->suspend_mem == NULL)
2664 snd_printk(KERN_WARNING "can't allocate apm buffer\n"); 2664 dev_warn(card->dev, "can't allocate apm buffer\n");
2665#endif 2665#endif
2666 2666
2667 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 2667 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
@@ -2685,16 +2685,15 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2685 if (chip->hv_config & HV_CTRL_ENABLE) { 2685 if (chip->hv_config & HV_CTRL_ENABLE) {
2686 err = snd_m3_input_register(chip); 2686 err = snd_m3_input_register(chip);
2687 if (err) 2687 if (err)
2688 snd_printk(KERN_WARNING "Input device registration " 2688 dev_warn(card->dev,
2689 "failed with error %i", err); 2689 "Input device registration failed with error %i",
2690 err);
2690 } 2691 }
2691#endif 2692#endif
2692 2693
2693 snd_m3_enable_ints(chip); 2694 snd_m3_enable_ints(chip);
2694 snd_m3_assp_continue(chip); 2695 snd_m3_assp_continue(chip);
2695 2696
2696 snd_card_set_dev(card, &pci->dev);
2697
2698 *chip_ret = chip; 2697 *chip_ret = chip;
2699 2698
2700 return 0; 2699 return 0;
@@ -2721,7 +2720,8 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2721 return -ENOENT; 2720 return -ENOENT;
2722 } 2721 }
2723 2722
2724 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2723 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2724 0, &card);
2725 if (err < 0) 2725 if (err < 0)
2726 return err; 2726 return err;
2727 2727
@@ -2764,7 +2764,7 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2764 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK, 2764 MPU401_INFO_INTEGRATED | MPU401_INFO_IRQ_HOOK,
2765 -1, &chip->rmidi); 2765 -1, &chip->rmidi);
2766 if (err < 0) 2766 if (err < 0)
2767 printk(KERN_WARNING "maestro3: no MIDI support.\n"); 2767 dev_warn(card->dev, "no MIDI support.\n");
2768#endif 2768#endif
2769 2769
2770 pci_set_drvdata(pci, card); 2770 pci_set_drvdata(pci, card);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 1e0f6ee193f0..a93e7af51eed 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -87,7 +87,8 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
87 if(!start) return 0; /* already stopped */ 87 if(!start) return 0; /* already stopped */
88 break; 88 break;
89 default: 89 default:
90 snd_printk(KERN_ERR "error mixart_set_pipe_state called with wrong pipe->status!\n"); 90 dev_err(&mgr->pci->dev,
91 "error mixart_set_pipe_state called with wrong pipe->status!\n");
91 return -EINVAL; /* function called with wrong pipe status */ 92 return -EINVAL; /* function called with wrong pipe status */
92 } 93 }
93 94
@@ -102,7 +103,8 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
102 103
103 err = snd_mixart_send_msg_wait_notif(mgr, &request, system_msg_uid); 104 err = snd_mixart_send_msg_wait_notif(mgr, &request, system_msg_uid);
104 if(err) { 105 if(err) {
105 snd_printk(KERN_ERR "error : MSG_SYSTEM_WAIT_SYNCHRO_CMD was not notified !\n"); 106 dev_err(&mgr->pci->dev,
107 "error : MSG_SYSTEM_WAIT_SYNCHRO_CMD was not notified !\n");
106 return err; 108 return err;
107 } 109 }
108 110
@@ -123,7 +125,9 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
123 125
124 err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp); 126 err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp);
125 if (err < 0 || group_state_resp.txx_status != 0) { 127 if (err < 0 || group_state_resp.txx_status != 0) {
126 snd_printk(KERN_ERR "error MSG_STREAM_ST***_STREAM_GRP_PACKET err=%x stat=%x !\n", err, group_state_resp.txx_status); 128 dev_err(&mgr->pci->dev,
129 "error MSG_STREAM_ST***_STREAM_GRP_PACKET err=%x stat=%x !\n",
130 err, group_state_resp.txx_status);
127 return -EINVAL; 131 return -EINVAL;
128 } 132 }
129 133
@@ -134,7 +138,9 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
134 138
135 err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp); 139 err = snd_mixart_send_msg(mgr, &request, sizeof(group_state_resp), &group_state_resp);
136 if (err < 0 || group_state_resp.txx_status != 0) { 140 if (err < 0 || group_state_resp.txx_status != 0) {
137 snd_printk(KERN_ERR "error MSG_STREAM_START_STREAM_GRP_PACKET err=%x stat=%x !\n", err, group_state_resp.txx_status); 141 dev_err(&mgr->pci->dev,
142 "error MSG_STREAM_START_STREAM_GRP_PACKET err=%x stat=%x !\n",
143 err, group_state_resp.txx_status);
138 return -EINVAL; 144 return -EINVAL;
139 } 145 }
140 146
@@ -147,7 +153,9 @@ static int mixart_set_pipe_state(struct mixart_mgr *mgr,
147 153
148 err = snd_mixart_send_msg(mgr, &request, sizeof(stat), &stat); 154 err = snd_mixart_send_msg(mgr, &request, sizeof(stat), &stat);
149 if (err < 0 || stat != 0) { 155 if (err < 0 || stat != 0) {
150 snd_printk(KERN_ERR "error MSG_SYSTEM_SEND_SYNCHRO_CMD err=%x stat=%x !\n", err, stat); 156 dev_err(&mgr->pci->dev,
157 "error MSG_SYSTEM_SEND_SYNCHRO_CMD err=%x stat=%x !\n",
158 err, stat);
151 return -EINVAL; 159 return -EINVAL;
152 } 160 }
153 161
@@ -178,7 +186,9 @@ static int mixart_set_clock(struct mixart_mgr *mgr,
178 if(rate == 0) 186 if(rate == 0)
179 return 0; /* nothing to do */ 187 return 0; /* nothing to do */
180 else { 188 else {
181 snd_printk(KERN_ERR "error mixart_set_clock(%d) called with wrong pipe->status !\n", rate); 189 dev_err(&mgr->pci->dev,
190 "error mixart_set_clock(%d) called with wrong pipe->status !\n",
191 rate);
182 return -EINVAL; 192 return -EINVAL;
183 } 193 }
184 } 194 }
@@ -190,7 +200,7 @@ static int mixart_set_clock(struct mixart_mgr *mgr,
190 clock_properties.nb_callers = 1; /* only one entry in uid_caller ! */ 200 clock_properties.nb_callers = 1; /* only one entry in uid_caller ! */
191 clock_properties.uid_caller[0] = pipe->group_uid; 201 clock_properties.uid_caller[0] = pipe->group_uid;
192 202
193 snd_printdd("mixart_set_clock to %d kHz\n", rate); 203 dev_dbg(&mgr->pci->dev, "mixart_set_clock to %d kHz\n", rate);
194 204
195 request.message_id = MSG_CLOCK_SET_PROPERTIES; 205 request.message_id = MSG_CLOCK_SET_PROPERTIES;
196 request.uid = mgr->uid_console_manager; 206 request.uid = mgr->uid_console_manager;
@@ -199,7 +209,9 @@ static int mixart_set_clock(struct mixart_mgr *mgr,
199 209
200 err = snd_mixart_send_msg(mgr, &request, sizeof(clock_prop_resp), &clock_prop_resp); 210 err = snd_mixart_send_msg(mgr, &request, sizeof(clock_prop_resp), &clock_prop_resp);
201 if (err < 0 || clock_prop_resp.status != 0 || clock_prop_resp.clock_mode != CM_STANDALONE) { 211 if (err < 0 || clock_prop_resp.status != 0 || clock_prop_resp.clock_mode != CM_STANDALONE) {
202 snd_printk(KERN_ERR "error MSG_CLOCK_SET_PROPERTIES err=%x stat=%x mod=%x !\n", err, clock_prop_resp.status, clock_prop_resp.clock_mode); 212 dev_err(&mgr->pci->dev,
213 "error MSG_CLOCK_SET_PROPERTIES err=%x stat=%x mod=%x !\n",
214 err, clock_prop_resp.status, clock_prop_resp.clock_mode);
203 return -EINVAL; 215 return -EINVAL;
204 } 216 }
205 217
@@ -252,7 +264,9 @@ snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture,
252 struct mixart_streaming_group sgroup_resp; 264 struct mixart_streaming_group sgroup_resp;
253 } *buf; 265 } *buf;
254 266
255 snd_printdd("add_ref_pipe audio chip(%d) pcm(%d)\n", chip->chip_idx, pcm_number); 267 dev_dbg(chip->card->dev,
268 "add_ref_pipe audio chip(%d) pcm(%d)\n",
269 chip->chip_idx, pcm_number);
256 270
257 buf = kmalloc(sizeof(*buf), GFP_KERNEL); 271 buf = kmalloc(sizeof(*buf), GFP_KERNEL);
258 if (!buf) 272 if (!buf)
@@ -302,7 +316,9 @@ snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture,
302 316
303 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(buf->sgroup_resp), &buf->sgroup_resp); 317 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(buf->sgroup_resp), &buf->sgroup_resp);
304 if((err < 0) || (buf->sgroup_resp.status != 0)) { 318 if((err < 0) || (buf->sgroup_resp.status != 0)) {
305 snd_printk(KERN_ERR "error MSG_STREAM_ADD_**PUT_GROUP err=%x stat=%x !\n", err, buf->sgroup_resp.status); 319 dev_err(chip->card->dev,
320 "error MSG_STREAM_ADD_**PUT_GROUP err=%x stat=%x !\n",
321 err, buf->sgroup_resp.status);
306 kfree(buf); 322 kfree(buf);
307 return NULL; 323 return NULL;
308 } 324 }
@@ -343,13 +359,14 @@ int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr,
343 /* release the clock */ 359 /* release the clock */
344 err = mixart_set_clock( mgr, pipe, 0); 360 err = mixart_set_clock( mgr, pipe, 0);
345 if( err < 0 ) { 361 if( err < 0 ) {
346 snd_printk(KERN_ERR "mixart_set_clock(0) return error!\n"); 362 dev_err(&mgr->pci->dev,
363 "mixart_set_clock(0) return error!\n");
347 } 364 }
348 365
349 /* stop the pipe */ 366 /* stop the pipe */
350 err = mixart_set_pipe_state(mgr, pipe, 0); 367 err = mixart_set_pipe_state(mgr, pipe, 0);
351 if( err < 0 ) { 368 if( err < 0 ) {
352 snd_printk(KERN_ERR "error stopping pipe!\n"); 369 dev_err(&mgr->pci->dev, "error stopping pipe!\n");
353 } 370 }
354 371
355 request.message_id = MSG_STREAM_DELETE_GROUP; 372 request.message_id = MSG_STREAM_DELETE_GROUP;
@@ -360,7 +377,9 @@ int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr,
360 /* delete the pipe */ 377 /* delete the pipe */
361 err = snd_mixart_send_msg(mgr, &request, sizeof(delete_resp), &delete_resp); 378 err = snd_mixart_send_msg(mgr, &request, sizeof(delete_resp), &delete_resp);
362 if ((err < 0) || (delete_resp.status != 0)) { 379 if ((err < 0) || (delete_resp.status != 0)) {
363 snd_printk(KERN_ERR "error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n", err, delete_resp.status); 380 dev_err(&mgr->pci->dev,
381 "error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n",
382 err, delete_resp.status);
364 } 383 }
365 384
366 pipe->group_uid = (struct mixart_uid){0,0}; 385 pipe->group_uid = (struct mixart_uid){0,0};
@@ -414,7 +433,7 @@ static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd)
414 switch (cmd) { 433 switch (cmd) {
415 case SNDRV_PCM_TRIGGER_START: 434 case SNDRV_PCM_TRIGGER_START:
416 435
417 snd_printdd("SNDRV_PCM_TRIGGER_START\n"); 436 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_START\n");
418 437
419 /* START_STREAM */ 438 /* START_STREAM */
420 if( mixart_set_stream_state(stream, 1) ) 439 if( mixart_set_stream_state(stream, 1) )
@@ -431,19 +450,19 @@ static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd)
431 450
432 stream->status = MIXART_STREAM_STATUS_OPEN; 451 stream->status = MIXART_STREAM_STATUS_OPEN;
433 452
434 snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); 453 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_TRIGGER_STOP\n");
435 454
436 break; 455 break;
437 456
438 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 457 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
439 /* TODO */ 458 /* TODO */
440 stream->status = MIXART_STREAM_STATUS_PAUSE; 459 stream->status = MIXART_STREAM_STATUS_PAUSE;
441 snd_printdd("SNDRV_PCM_PAUSE_PUSH\n"); 460 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_PUSH\n");
442 break; 461 break;
443 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 462 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
444 /* TODO */ 463 /* TODO */
445 stream->status = MIXART_STREAM_STATUS_RUNNING; 464 stream->status = MIXART_STREAM_STATUS_RUNNING;
446 snd_printdd("SNDRV_PCM_PAUSE_RELEASE\n"); 465 dev_dbg(subs->pcm->card->dev, "SNDRV_PCM_PAUSE_RELEASE\n");
447 break; 466 break;
448 default: 467 default:
449 return -EINVAL; 468 return -EINVAL;
@@ -456,7 +475,8 @@ static int mixart_sync_nonblock_events(struct mixart_mgr *mgr)
456 unsigned long timeout = jiffies + HZ; 475 unsigned long timeout = jiffies + HZ;
457 while (atomic_read(&mgr->msg_processed) > 0) { 476 while (atomic_read(&mgr->msg_processed) > 0) {
458 if (time_after(jiffies, timeout)) { 477 if (time_after(jiffies, timeout)) {
459 snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n"); 478 dev_err(&mgr->pci->dev,
479 "mixart: cannot process nonblock events!\n");
460 return -EBUSY; 480 return -EBUSY;
461 } 481 }
462 schedule_timeout_uninterruptible(1); 482 schedule_timeout_uninterruptible(1);
@@ -474,7 +494,7 @@ static int snd_mixart_prepare(struct snd_pcm_substream *subs)
474 494
475 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */ 495 /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
476 496
477 snd_printdd("snd_mixart_prepare\n"); 497 dev_dbg(chip->card->dev, "snd_mixart_prepare\n");
478 498
479 mixart_sync_nonblock_events(chip->mgr); 499 mixart_sync_nonblock_events(chip->mgr);
480 500
@@ -542,11 +562,13 @@ static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t form
542 stream_param.sample_size = 32; 562 stream_param.sample_size = 32;
543 break; 563 break;
544 default: 564 default:
545 snd_printk(KERN_ERR "error mixart_set_format() : unknown format\n"); 565 dev_err(chip->card->dev,
566 "error mixart_set_format() : unknown format\n");
546 return -EINVAL; 567 return -EINVAL;
547 } 568 }
548 569
549 snd_printdd("set SNDRV_PCM_FORMAT sample_type(%d) sample_size(%d) freq(%d) channels(%d)\n", 570 dev_dbg(chip->card->dev,
571 "set SNDRV_PCM_FORMAT sample_type(%d) sample_size(%d) freq(%d) channels(%d)\n",
550 stream_param.sample_type, stream_param.sample_size, stream_param.sampling_freq, stream->channels); 572 stream_param.sample_type, stream_param.sample_size, stream_param.sampling_freq, stream->channels);
551 573
552 /* TODO: what else to configure ? */ 574 /* TODO: what else to configure ? */
@@ -566,7 +588,9 @@ static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t form
566 588
567 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp); 589 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
568 if((err < 0) || resp.error_code) { 590 if((err < 0) || resp.error_code) {
569 snd_printk(KERN_ERR "MSG_STREAM_SET_INPUT_STAGE_PARAM err=%x; resp=%x\n", err, resp.error_code); 591 dev_err(chip->card->dev,
592 "MSG_STREAM_SET_INPUT_STAGE_PARAM err=%x; resp=%x\n",
593 err, resp.error_code);
570 return -EINVAL; 594 return -EINVAL;
571 } 595 }
572 return 0; 596 return 0;
@@ -627,8 +651,9 @@ static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
627 bufferinfo[i].available_length = subs->runtime->dma_bytes; 651 bufferinfo[i].available_length = subs->runtime->dma_bytes;
628 /* bufferinfo[i].buffer_id is already defined */ 652 /* bufferinfo[i].buffer_id is already defined */
629 653
630 snd_printdd("snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n", i, 654 dev_dbg(chip->card->dev,
631 bufferinfo[i].buffer_address, 655 "snd_mixart_hw_params(pcm %d) : dma_addr(%x) dma_bytes(%x) subs-number(%d)\n",
656 i, bufferinfo[i].buffer_address,
632 bufferinfo[i].available_length, 657 bufferinfo[i].available_length,
633 subs->number); 658 subs->number);
634 } 659 }
@@ -714,14 +739,18 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
714 pcm_number = MIXART_PCM_DIGITAL; 739 pcm_number = MIXART_PCM_DIGITAL;
715 runtime->hw = snd_mixart_digital_caps; 740 runtime->hw = snd_mixart_digital_caps;
716 } 741 }
717 snd_printdd("snd_mixart_playback_open C%d/P%d/Sub%d\n", chip->chip_idx, pcm_number, subs->number); 742 dev_dbg(chip->card->dev,
743 "snd_mixart_playback_open C%d/P%d/Sub%d\n",
744 chip->chip_idx, pcm_number, subs->number);
718 745
719 /* get stream info */ 746 /* get stream info */
720 stream = &(chip->playback_stream[pcm_number][subs->number]); 747 stream = &(chip->playback_stream[pcm_number][subs->number]);
721 748
722 if (stream->status != MIXART_STREAM_STATUS_FREE){ 749 if (stream->status != MIXART_STREAM_STATUS_FREE){
723 /* streams in use */ 750 /* streams in use */
724 snd_printk(KERN_ERR "snd_mixart_playback_open C%d/P%d/Sub%d in use\n", chip->chip_idx, pcm_number, subs->number); 751 dev_err(chip->card->dev,
752 "snd_mixart_playback_open C%d/P%d/Sub%d in use\n",
753 chip->chip_idx, pcm_number, subs->number);
725 err = -EBUSY; 754 err = -EBUSY;
726 goto _exit_open; 755 goto _exit_open;
727 } 756 }
@@ -737,7 +766,7 @@ static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
737 /* start the pipe if necessary */ 766 /* start the pipe if necessary */
738 err = mixart_set_pipe_state(chip->mgr, pipe, 1); 767 err = mixart_set_pipe_state(chip->mgr, pipe, 1);
739 if( err < 0 ) { 768 if( err < 0 ) {
740 snd_printk(KERN_ERR "error starting pipe!\n"); 769 dev_err(chip->card->dev, "error starting pipe!\n");
741 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0); 770 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0);
742 err = -EINVAL; 771 err = -EINVAL;
743 goto _exit_open; 772 goto _exit_open;
@@ -792,14 +821,17 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
792 821
793 runtime->hw.channels_min = 2; /* for instance, no mono */ 822 runtime->hw.channels_min = 2; /* for instance, no mono */
794 823
795 snd_printdd("snd_mixart_capture_open C%d/P%d/Sub%d\n", chip->chip_idx, pcm_number, subs->number); 824 dev_dbg(chip->card->dev, "snd_mixart_capture_open C%d/P%d/Sub%d\n",
825 chip->chip_idx, pcm_number, subs->number);
796 826
797 /* get stream info */ 827 /* get stream info */
798 stream = &(chip->capture_stream[pcm_number]); 828 stream = &(chip->capture_stream[pcm_number]);
799 829
800 if (stream->status != MIXART_STREAM_STATUS_FREE){ 830 if (stream->status != MIXART_STREAM_STATUS_FREE){
801 /* streams in use */ 831 /* streams in use */
802 snd_printk(KERN_ERR "snd_mixart_capture_open C%d/P%d/Sub%d in use\n", chip->chip_idx, pcm_number, subs->number); 832 dev_err(chip->card->dev,
833 "snd_mixart_capture_open C%d/P%d/Sub%d in use\n",
834 chip->chip_idx, pcm_number, subs->number);
803 err = -EBUSY; 835 err = -EBUSY;
804 goto _exit_open; 836 goto _exit_open;
805 } 837 }
@@ -815,7 +847,7 @@ static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
815 /* start the pipe if necessary */ 847 /* start the pipe if necessary */
816 err = mixart_set_pipe_state(chip->mgr, pipe, 1); 848 err = mixart_set_pipe_state(chip->mgr, pipe, 1);
817 if( err < 0 ) { 849 if( err < 0 ) {
818 snd_printk(KERN_ERR "error starting pipe!\n"); 850 dev_err(chip->card->dev, "error starting pipe!\n");
819 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0); 851 snd_mixart_kill_ref_pipe(chip->mgr, pipe, 0);
820 err = -EINVAL; 852 err = -EINVAL;
821 goto _exit_open; 853 goto _exit_open;
@@ -855,7 +887,8 @@ static int snd_mixart_close(struct snd_pcm_substream *subs)
855 887
856 mutex_lock(&mgr->setup_mutex); 888 mutex_lock(&mgr->setup_mutex);
857 889
858 snd_printdd("snd_mixart_close C%d/P%d/Sub%d\n", chip->chip_idx, stream->pcm_number, subs->number); 890 dev_dbg(chip->card->dev, "snd_mixart_close C%d/P%d/Sub%d\n",
891 chip->chip_idx, stream->pcm_number, subs->number);
859 892
860 /* sample rate released */ 893 /* sample rate released */
861 if(--mgr->ref_count_rate == 0) { 894 if(--mgr->ref_count_rate == 0) {
@@ -865,7 +898,9 @@ static int snd_mixart_close(struct snd_pcm_substream *subs)
865 /* delete pipe */ 898 /* delete pipe */
866 if (snd_mixart_kill_ref_pipe(mgr, stream->pipe, 0 ) < 0) { 899 if (snd_mixart_kill_ref_pipe(mgr, stream->pipe, 0 ) < 0) {
867 900
868 snd_printk(KERN_ERR "error snd_mixart_kill_ref_pipe C%dP%d\n", chip->chip_idx, stream->pcm_number); 901 dev_err(chip->card->dev,
902 "error snd_mixart_kill_ref_pipe C%dP%d\n",
903 chip->chip_idx, stream->pcm_number);
869 } 904 }
870 905
871 stream->pipe = NULL; 906 stream->pipe = NULL;
@@ -940,7 +975,8 @@ static int snd_mixart_pcm_analog(struct snd_mixart *chip)
940 if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG, 975 if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_ANALOG,
941 MIXART_PLAYBACK_STREAMS, 976 MIXART_PLAYBACK_STREAMS,
942 MIXART_CAPTURE_STREAMS, &pcm)) < 0) { 977 MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
943 snd_printk(KERN_ERR "cannot create the analog pcm %d\n", chip->chip_idx); 978 dev_err(chip->card->dev,
979 "cannot create the analog pcm %d\n", chip->chip_idx);
944 return err; 980 return err;
945 } 981 }
946 982
@@ -971,7 +1007,8 @@ static int snd_mixart_pcm_digital(struct snd_mixart *chip)
971 if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL, 1007 if ((err = snd_pcm_new(chip->card, name, MIXART_PCM_DIGITAL,
972 MIXART_PLAYBACK_STREAMS, 1008 MIXART_PLAYBACK_STREAMS,
973 MIXART_CAPTURE_STREAMS, &pcm)) < 0) { 1009 MIXART_CAPTURE_STREAMS, &pcm)) < 0) {
974 snd_printk(KERN_ERR "cannot create the digital pcm %d\n", chip->chip_idx); 1010 dev_err(chip->card->dev,
1011 "cannot create the digital pcm %d\n", chip->chip_idx);
975 return err; 1012 return err;
976 } 1013 }
977 1014
@@ -1014,7 +1051,7 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int
1014 1051
1015 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1052 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1016 if (! chip) { 1053 if (! chip) {
1017 snd_printk(KERN_ERR "cannot allocate chip\n"); 1054 dev_err(card->dev, "cannot allocate chip\n");
1018 return -ENOMEM; 1055 return -ENOMEM;
1019 } 1056 }
1020 1057
@@ -1028,8 +1065,6 @@ static int snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int
1028 } 1065 }
1029 1066
1030 mgr->chip[idx] = chip; 1067 mgr->chip[idx] = chip;
1031 snd_card_set_dev(card, &mgr->pci->dev);
1032
1033 return 0; 1068 return 0;
1034} 1069}
1035 1070
@@ -1073,7 +1108,7 @@ static int snd_mixart_free(struct mixart_mgr *mgr)
1073 /* reset board if some firmware was loaded */ 1108 /* reset board if some firmware was loaded */
1074 if(mgr->dsp_loaded) { 1109 if(mgr->dsp_loaded) {
1075 snd_mixart_reset_board(mgr); 1110 snd_mixart_reset_board(mgr);
1076 snd_printdd("reset miXart !\n"); 1111 dev_dbg(&mgr->pci->dev, "reset miXart !\n");
1077 } 1112 }
1078 1113
1079 /* release the i/o ports */ 1114 /* release the i/o ports */
@@ -1234,7 +1269,8 @@ static int snd_mixart_probe(struct pci_dev *pci,
1234 1269
1235 /* check if we can restrict PCI DMA transfers to 32 bits */ 1270 /* check if we can restrict PCI DMA transfers to 32 bits */
1236 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) { 1271 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
1237 snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n"); 1272 dev_err(&pci->dev,
1273 "architecture does not support 32bit PCI busmaster DMA\n");
1238 pci_disable_device(pci); 1274 pci_disable_device(pci);
1239 return -ENXIO; 1275 return -ENXIO;
1240 } 1276 }
@@ -1260,7 +1296,7 @@ static int snd_mixart_probe(struct pci_dev *pci,
1260 mgr->mem[i].phys = pci_resource_start(pci, i); 1296 mgr->mem[i].phys = pci_resource_start(pci, i);
1261 mgr->mem[i].virt = pci_ioremap_bar(pci, i); 1297 mgr->mem[i].virt = pci_ioremap_bar(pci, i);
1262 if (!mgr->mem[i].virt) { 1298 if (!mgr->mem[i].virt) {
1263 printk(KERN_ERR "unable to remap resource 0x%lx\n", 1299 dev_err(&pci->dev, "unable to remap resource 0x%lx\n",
1264 mgr->mem[i].phys); 1300 mgr->mem[i].phys);
1265 snd_mixart_free(mgr); 1301 snd_mixart_free(mgr);
1266 return -EBUSY; 1302 return -EBUSY;
@@ -1269,7 +1305,7 @@ static int snd_mixart_probe(struct pci_dev *pci,
1269 1305
1270 if (request_irq(pci->irq, snd_mixart_interrupt, IRQF_SHARED, 1306 if (request_irq(pci->irq, snd_mixart_interrupt, IRQF_SHARED,
1271 KBUILD_MODNAME, mgr)) { 1307 KBUILD_MODNAME, mgr)) {
1272 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1308 dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq);
1273 snd_mixart_free(mgr); 1309 snd_mixart_free(mgr);
1274 return -EBUSY; 1310 return -EBUSY;
1275 } 1311 }
@@ -1308,10 +1344,11 @@ static int snd_mixart_probe(struct pci_dev *pci,
1308 else 1344 else
1309 idx = index[dev] + i; 1345 idx = index[dev] + i;
1310 snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i); 1346 snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
1311 err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card); 1347 err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
1348 0, &card);
1312 1349
1313 if (err < 0) { 1350 if (err < 0) {
1314 snd_printk(KERN_ERR "cannot allocate the card %d\n", i); 1351 dev_err(&pci->dev, "cannot allocate the card %d\n", i);
1315 snd_mixart_free(mgr); 1352 snd_mixart_free(mgr);
1316 return err; 1353 return err;
1317 } 1354 }
diff --git a/sound/pci/mixart/mixart_core.c b/sound/pci/mixart/mixart_core.c
index 3df0f530f67c..71f4bdcc4055 100644
--- a/sound/pci/mixart/mixart_core.c
+++ b/sound/pci/mixart/mixart_core.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/pci.h>
25 26
26#include <asm/io.h> 27#include <asm/io.h>
27#include <sound/core.h> 28#include <sound/core.h>
@@ -94,7 +95,8 @@ static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp,
94 95
95 if( (size < MSG_DESCRIPTOR_SIZE) || (resp->size < (size - MSG_DESCRIPTOR_SIZE))) { 96 if( (size < MSG_DESCRIPTOR_SIZE) || (resp->size < (size - MSG_DESCRIPTOR_SIZE))) {
96 err = -EINVAL; 97 err = -EINVAL;
97 snd_printk(KERN_ERR "problem with response size = %d\n", size); 98 dev_err(&mgr->pci->dev,
99 "problem with response size = %d\n", size);
98 goto _clean_exit; 100 goto _clean_exit;
99 } 101 }
100 size -= MSG_DESCRIPTOR_SIZE; 102 size -= MSG_DESCRIPTOR_SIZE;
@@ -161,7 +163,7 @@ static int send_msg( struct mixart_mgr *mgr,
161 headptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_FREE_HEAD)); 163 headptr = readl_be(MIXART_MEM(mgr, MSG_INBOUND_FREE_HEAD));
162 164
163 if (tailptr == headptr) { 165 if (tailptr == headptr) {
164 snd_printk(KERN_ERR "error: no message frame available\n"); 166 dev_err(&mgr->pci->dev, "error: no message frame available\n");
165 return -EBUSY; 167 return -EBUSY;
166 } 168 }
167 169
@@ -265,7 +267,8 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
265 if (! timeout) { 267 if (! timeout) {
266 /* error - no ack */ 268 /* error - no ack */
267 mutex_unlock(&mgr->msg_mutex); 269 mutex_unlock(&mgr->msg_mutex);
268 snd_printk(KERN_ERR "error: no response on msg %x\n", msg_frame); 270 dev_err(&mgr->pci->dev,
271 "error: no response on msg %x\n", msg_frame);
269 return -EIO; 272 return -EIO;
270 } 273 }
271 274
@@ -278,7 +281,7 @@ int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int
278 err = get_msg(mgr, &resp, msg_frame); 281 err = get_msg(mgr, &resp, msg_frame);
279 282
280 if( request->message_id != resp.message_id ) 283 if( request->message_id != resp.message_id )
281 snd_printk(KERN_ERR "RESPONSE ERROR!\n"); 284 dev_err(&mgr->pci->dev, "RESPONSE ERROR!\n");
282 285
283 mutex_unlock(&mgr->msg_mutex); 286 mutex_unlock(&mgr->msg_mutex);
284 return err; 287 return err;
@@ -321,7 +324,8 @@ int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr,
321 if (! timeout) { 324 if (! timeout) {
322 /* error - no ack */ 325 /* error - no ack */
323 mutex_unlock(&mgr->msg_mutex); 326 mutex_unlock(&mgr->msg_mutex);
324 snd_printk(KERN_ERR "error: notification %x not received\n", notif_event); 327 dev_err(&mgr->pci->dev,
328 "error: notification %x not received\n", notif_event);
325 return -EIO; 329 return -EIO;
326 } 330 }
327 331
@@ -378,7 +382,9 @@ void snd_mixart_msg_tasklet(unsigned long arg)
378 resp.size = sizeof(mixart_msg_data); 382 resp.size = sizeof(mixart_msg_data);
379 err = get_msg(mgr, &resp, addr); 383 err = get_msg(mgr, &resp, addr);
380 if( err < 0 ) { 384 if( err < 0 ) {
381 snd_printk(KERN_ERR "tasklet: error(%d) reading mf %x\n", err, msg); 385 dev_err(&mgr->pci->dev,
386 "tasklet: error(%d) reading mf %x\n",
387 err, msg);
382 break; 388 break;
383 } 389 }
384 390
@@ -388,10 +394,13 @@ void snd_mixart_msg_tasklet(unsigned long arg)
388 case MSG_STREAM_STOP_INPUT_STAGE_PACKET: 394 case MSG_STREAM_STOP_INPUT_STAGE_PACKET:
389 case MSG_STREAM_STOP_OUTPUT_STAGE_PACKET: 395 case MSG_STREAM_STOP_OUTPUT_STAGE_PACKET:
390 if(mixart_msg_data[0]) 396 if(mixart_msg_data[0])
391 snd_printk(KERN_ERR "tasklet : error MSG_STREAM_ST***_***PUT_STAGE_PACKET status=%x\n", mixart_msg_data[0]); 397 dev_err(&mgr->pci->dev,
398 "tasklet : error MSG_STREAM_ST***_***PUT_STAGE_PACKET status=%x\n",
399 mixart_msg_data[0]);
392 break; 400 break;
393 default: 401 default:
394 snd_printdd("tasklet received mf(%x) : msg_id(%x) uid(%x, %x) size(%zd)\n", 402 dev_dbg(&mgr->pci->dev,
403 "tasklet received mf(%x) : msg_id(%x) uid(%x, %x) size(%zd)\n",
395 msg, resp.message_id, resp.uid.object_id, resp.uid.desc, resp.size); 404 msg, resp.message_id, resp.uid.object_id, resp.uid.desc, resp.size);
396 break; 405 break;
397 } 406 }
@@ -401,7 +410,9 @@ void snd_mixart_msg_tasklet(unsigned long arg)
401 case MSG_TYPE_COMMAND: 410 case MSG_TYPE_COMMAND:
402 /* get_msg() necessary */ 411 /* get_msg() necessary */
403 default: 412 default:
404 snd_printk(KERN_ERR "tasklet doesn't know what to do with message %x\n", msg); 413 dev_err(&mgr->pci->dev,
414 "tasklet doesn't know what to do with message %x\n",
415 msg);
405 } /* switch type */ 416 } /* switch type */
406 417
407 /* decrement counter */ 418 /* decrement counter */
@@ -451,7 +462,9 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
451 resp.size = sizeof(mixart_msg_data); 462 resp.size = sizeof(mixart_msg_data);
452 err = get_msg(mgr, &resp, msg & ~MSG_TYPE_MASK); 463 err = get_msg(mgr, &resp, msg & ~MSG_TYPE_MASK);
453 if( err < 0 ) { 464 if( err < 0 ) {
454 snd_printk(KERN_ERR "interrupt: error(%d) reading mf %x\n", err, msg); 465 dev_err(&mgr->pci->dev,
466 "interrupt: error(%d) reading mf %x\n",
467 err, msg);
455 break; 468 break;
456 } 469 }
457 470
@@ -472,7 +485,8 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
472 struct mixart_stream *stream; 485 struct mixart_stream *stream;
473 486
474 if ((chip_number >= mgr->num_cards) || (pcm_number >= MIXART_PCM_TOTAL) || (sub_number >= MIXART_PLAYBACK_STREAMS)) { 487 if ((chip_number >= mgr->num_cards) || (pcm_number >= MIXART_PCM_TOTAL) || (sub_number >= MIXART_PLAYBACK_STREAMS)) {
475 snd_printk(KERN_ERR "error MSG_SERVICES_TIMER_NOTIFY buffer_id (%x) pos(%d)\n", 488 dev_err(&mgr->pci->dev,
489 "error MSG_SERVICES_TIMER_NOTIFY buffer_id (%x) pos(%d)\n",
476 buffer_id, notify->streams[i].sample_pos_low_part); 490 buffer_id, notify->streams[i].sample_pos_low_part);
477 break; 491 break;
478 } 492 }
@@ -524,18 +538,22 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
524 } 538 }
525#endif 539#endif
526 ((char*)mixart_msg_data)[resp.size - 1] = 0; 540 ((char*)mixart_msg_data)[resp.size - 1] = 0;
527 snd_printdd("MIXART TRACE : %s\n", (char*)mixart_msg_data); 541 dev_dbg(&mgr->pci->dev,
542 "MIXART TRACE : %s\n",
543 (char *)mixart_msg_data);
528 } 544 }
529 break; 545 break;
530 } 546 }
531 547
532 snd_printdd("command %x not handled\n", resp.message_id); 548 dev_dbg(&mgr->pci->dev, "command %x not handled\n",
549 resp.message_id);
533 break; 550 break;
534 551
535 case MSG_TYPE_NOTIFY: 552 case MSG_TYPE_NOTIFY:
536 if(msg & MSG_CANCEL_NOTIFY_MASK) { 553 if(msg & MSG_CANCEL_NOTIFY_MASK) {
537 msg &= ~MSG_CANCEL_NOTIFY_MASK; 554 msg &= ~MSG_CANCEL_NOTIFY_MASK;
538 snd_printk(KERN_ERR "canceled notification %x !\n", msg); 555 dev_err(&mgr->pci->dev,
556 "canceled notification %x !\n", msg);
539 } 557 }
540 /* no break, continue ! */ 558 /* no break, continue ! */
541 case MSG_TYPE_ANSWER: 559 case MSG_TYPE_ANSWER:
@@ -556,7 +574,8 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id)
556 break; 574 break;
557 case MSG_TYPE_REQUEST: 575 case MSG_TYPE_REQUEST:
558 default: 576 default:
559 snd_printdd("interrupt received request %x\n", msg); 577 dev_dbg(&mgr->pci->dev,
578 "interrupt received request %x\n", msg);
560 /* TODO : are there things to do here ? */ 579 /* TODO : are there things to do here ? */
561 break; 580 break;
562 } /* switch on msg type */ 581 } /* switch on msg type */
diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c
index ece1f831c16a..581e1e74863c 100644
--- a/sound/pci/mixart/mixart_hwdep.c
+++ b/sound/pci/mixart/mixart_hwdep.c
@@ -165,7 +165,8 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
165 165
166 err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector); 166 err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector);
167 if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) { 167 if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) {
168 snd_printk(KERN_ERR "error MSG_SYSTEM_ENUM_PLAY_CONNECTOR\n"); 168 dev_err(&mgr->pci->dev,
169 "error MSG_SYSTEM_ENUM_PLAY_CONNECTOR\n");
169 err = -EINVAL; 170 err = -EINVAL;
170 goto __error; 171 goto __error;
171 } 172 }
@@ -184,7 +185,7 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
184 pipe->uid_left_connector = connector->uid[k]; /* even */ 185 pipe->uid_left_connector = connector->uid[k]; /* even */
185 } 186 }
186 187
187 /* snd_printk(KERN_DEBUG "playback connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */ 188 /* dev_dbg(&mgr->pci->dev, "playback connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
188 189
189 /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */ 190 /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */
190 request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO; 191 request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO;
@@ -194,10 +195,11 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
194 195
195 err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info); 196 err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info);
196 if( err < 0 ) { 197 if( err < 0 ) {
197 snd_printk(KERN_ERR "error MSG_CONNECTOR_GET_AUDIO_INFO\n"); 198 dev_err(&mgr->pci->dev,
199 "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
198 goto __error; 200 goto __error;
199 } 201 }
200 /*snd_printk(KERN_DEBUG "play analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/ 202 /*dev_dbg(&mgr->pci->dev, "play analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
201 } 203 }
202 204
203 request.message_id = MSG_SYSTEM_ENUM_RECORD_CONNECTOR; 205 request.message_id = MSG_SYSTEM_ENUM_RECORD_CONNECTOR;
@@ -207,7 +209,8 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
207 209
208 err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector); 210 err = snd_mixart_send_msg(mgr, &request, sizeof(*connector), connector);
209 if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) { 211 if((err < 0) || (connector->error_code) || (connector->uid_count > MIXART_MAX_PHYS_CONNECTORS)) {
210 snd_printk(KERN_ERR "error MSG_SYSTEM_ENUM_RECORD_CONNECTOR\n"); 212 dev_err(&mgr->pci->dev,
213 "error MSG_SYSTEM_ENUM_RECORD_CONNECTOR\n");
211 err = -EINVAL; 214 err = -EINVAL;
212 goto __error; 215 goto __error;
213 } 216 }
@@ -226,7 +229,7 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
226 pipe->uid_left_connector = connector->uid[k]; /* even */ 229 pipe->uid_left_connector = connector->uid[k]; /* even */
227 } 230 }
228 231
229 /* snd_printk(KERN_DEBUG "capture connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */ 232 /* dev_dbg(&mgr->pci->dev, "capture connector[%d].object_id = %x\n", k, connector->uid[k].object_id); */
230 233
231 /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */ 234 /* TODO: really need send_msg MSG_CONNECTOR_GET_AUDIO_INFO for each connector ? perhaps for analog level caps ? */
232 request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO; 235 request.message_id = MSG_CONNECTOR_GET_AUDIO_INFO;
@@ -236,10 +239,11 @@ static int mixart_enum_connectors(struct mixart_mgr *mgr)
236 239
237 err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info); 240 err = snd_mixart_send_msg(mgr, &request, sizeof(*audio_info), audio_info);
238 if( err < 0 ) { 241 if( err < 0 ) {
239 snd_printk(KERN_ERR "error MSG_CONNECTOR_GET_AUDIO_INFO\n"); 242 dev_err(&mgr->pci->dev,
243 "error MSG_CONNECTOR_GET_AUDIO_INFO\n");
240 goto __error; 244 goto __error;
241 } 245 }
242 /*snd_printk(KERN_DEBUG "rec analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/ 246 /*dev_dbg(&mgr->pci->dev, "rec analog_info.analog_level_present = %x\n", audio_info->info.analog_info.analog_level_present);*/
243 } 247 }
244 err = 0; 248 err = 0;
245 249
@@ -272,7 +276,9 @@ static int mixart_enum_physio(struct mixart_mgr *mgr)
272 err = snd_mixart_send_msg(mgr, &request, sizeof(console_mgr), &console_mgr); 276 err = snd_mixart_send_msg(mgr, &request, sizeof(console_mgr), &console_mgr);
273 277
274 if( (err < 0) || (console_mgr.error_code != 0) ) { 278 if( (err < 0) || (console_mgr.error_code != 0) ) {
275 snd_printk(KERN_DEBUG "error MSG_CONSOLE_GET_CLOCK_UID : err=%x\n", console_mgr.error_code); 279 dev_dbg(&mgr->pci->dev,
280 "error MSG_CONSOLE_GET_CLOCK_UID : err=%x\n",
281 console_mgr.error_code);
276 return -EINVAL; 282 return -EINVAL;
277 } 283 }
278 284
@@ -286,7 +292,9 @@ static int mixart_enum_physio(struct mixart_mgr *mgr)
286 292
287 err = snd_mixart_send_msg(mgr, &request, sizeof(phys_io), &phys_io); 293 err = snd_mixart_send_msg(mgr, &request, sizeof(phys_io), &phys_io);
288 if( (err < 0) || ( phys_io.error_code != 0 ) ) { 294 if( (err < 0) || ( phys_io.error_code != 0 ) ) {
289 snd_printk(KERN_ERR "error MSG_SYSTEM_ENUM_PHYSICAL_IO err(%x) error_code(%x)\n", err, phys_io.error_code ); 295 dev_err(&mgr->pci->dev,
296 "error MSG_SYSTEM_ENUM_PHYSICAL_IO err(%x) error_code(%x)\n",
297 err, phys_io.error_code);
290 return -EINVAL; 298 return -EINVAL;
291 } 299 }
292 300
@@ -322,7 +330,7 @@ static int mixart_first_init(struct mixart_mgr *mgr)
322 /* this command has no data. response is a 32 bit status */ 330 /* this command has no data. response is a 32 bit status */
323 err = snd_mixart_send_msg(mgr, &request, sizeof(k), &k); 331 err = snd_mixart_send_msg(mgr, &request, sizeof(k), &k);
324 if( (err < 0) || (k != 0) ) { 332 if( (err < 0) || (k != 0) ) {
325 snd_printk(KERN_ERR "error MSG_SYSTEM_SEND_SYNCHRO_CMD\n"); 333 dev_err(&mgr->pci->dev, "error MSG_SYSTEM_SEND_SYNCHRO_CMD\n");
326 return err == 0 ? -EINVAL : err; 334 return err == 0 ? -EINVAL : err;
327 } 335 }
328 336
@@ -348,7 +356,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
348 356
349 /* motherboard xilinx status 5 will say that the board is performing a reset */ 357 /* motherboard xilinx status 5 will say that the board is performing a reset */
350 if (status_xilinx == 5) { 358 if (status_xilinx == 5) {
351 snd_printk(KERN_ERR "miXart is resetting !\n"); 359 dev_err(&mgr->pci->dev, "miXart is resetting !\n");
352 return -EAGAIN; /* try again later */ 360 return -EAGAIN; /* try again later */
353 } 361 }
354 362
@@ -357,12 +365,13 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
357 365
358 /* xilinx already loaded ? */ 366 /* xilinx already loaded ? */
359 if (status_xilinx == 4) { 367 if (status_xilinx == 4) {
360 snd_printk(KERN_DEBUG "xilinx is already loaded !\n"); 368 dev_dbg(&mgr->pci->dev, "xilinx is already loaded !\n");
361 return 0; 369 return 0;
362 } 370 }
363 /* the status should be 0 == "idle" */ 371 /* the status should be 0 == "idle" */
364 if (status_xilinx != 0) { 372 if (status_xilinx != 0) {
365 snd_printk(KERN_ERR "xilinx load error ! status = %d\n", 373 dev_err(&mgr->pci->dev,
374 "xilinx load error ! status = %d\n",
366 status_xilinx); 375 status_xilinx);
367 return -EIO; /* modprob -r may help ? */ 376 return -EIO; /* modprob -r may help ? */
368 } 377 }
@@ -393,13 +402,14 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
393 case MIXART_MOTHERBOARD_ELF_INDEX: 402 case MIXART_MOTHERBOARD_ELF_INDEX:
394 403
395 if (status_elf == 4) { 404 if (status_elf == 4) {
396 snd_printk(KERN_DEBUG "elf file already loaded !\n"); 405 dev_dbg(&mgr->pci->dev, "elf file already loaded !\n");
397 return 0; 406 return 0;
398 } 407 }
399 408
400 /* the status should be 0 == "idle" */ 409 /* the status should be 0 == "idle" */
401 if (status_elf != 0) { 410 if (status_elf != 0) {
402 snd_printk(KERN_ERR "elf load error ! status = %d\n", 411 dev_err(&mgr->pci->dev,
412 "elf load error ! status = %d\n",
403 status_elf); 413 status_elf);
404 return -EIO; /* modprob -r may help ? */ 414 return -EIO; /* modprob -r may help ? */
405 } 415 }
@@ -407,7 +417,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
407 /* wait for xilinx status == 4 */ 417 /* wait for xilinx status == 4 */
408 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET, 1, 4, 500); /* 5sec */ 418 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET, 1, 4, 500); /* 5sec */
409 if (err < 0) { 419 if (err < 0) {
410 snd_printk(KERN_ERR "xilinx was not loaded or " 420 dev_err(&mgr->pci->dev, "xilinx was not loaded or "
411 "could not be started\n"); 421 "could not be started\n");
412 return err; 422 return err;
413 } 423 }
@@ -429,7 +439,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
429 /* wait for elf status == 4 */ 439 /* wait for elf status == 4 */
430 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET, 1, 4, 300); /* 3sec */ 440 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET, 1, 4, 300); /* 3sec */
431 if (err < 0) { 441 if (err < 0) {
432 snd_printk(KERN_ERR "elf could not be started\n"); 442 dev_err(&mgr->pci->dev, "elf could not be started\n");
433 return err; 443 return err;
434 } 444 }
435 445
@@ -443,7 +453,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
443 453
444 /* elf and xilinx should be loaded */ 454 /* elf and xilinx should be loaded */
445 if (status_elf != 4 || status_xilinx != 4) { 455 if (status_elf != 4 || status_xilinx != 4) {
446 printk(KERN_ERR "xilinx or elf not " 456 dev_err(&mgr->pci->dev, "xilinx or elf not "
447 "successfully loaded\n"); 457 "successfully loaded\n");
448 return -EIO; /* modprob -r may help ? */ 458 return -EIO; /* modprob -r may help ? */
449 } 459 }
@@ -451,7 +461,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
451 /* wait for daughter detection != 0 */ 461 /* wait for daughter detection != 0 */
452 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET, 0, 0, 30); /* 300msec */ 462 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET, 0, 0, 30); /* 300msec */
453 if (err < 0) { 463 if (err < 0) {
454 snd_printk(KERN_ERR "error starting elf file\n"); 464 dev_err(&mgr->pci->dev, "error starting elf file\n");
455 return err; 465 return err;
456 } 466 }
457 467
@@ -467,7 +477,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
467 477
468 /* daughter should be idle */ 478 /* daughter should be idle */
469 if (status_daught != 0) { 479 if (status_daught != 0) {
470 printk(KERN_ERR "daughter load error ! status = %d\n", 480 dev_err(&mgr->pci->dev,
481 "daughter load error ! status = %d\n",
471 status_daught); 482 status_daught);
472 return -EIO; /* modprob -r may help ? */ 483 return -EIO; /* modprob -r may help ? */
473 } 484 }
@@ -487,7 +498,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
487 /* wait for status == 2 */ 498 /* wait for status == 2 */
488 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 2, 30); /* 300msec */ 499 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 2, 30); /* 300msec */
489 if (err < 0) { 500 if (err < 0) {
490 snd_printk(KERN_ERR "daughter board load error\n"); 501 dev_err(&mgr->pci->dev, "daughter board load error\n");
491 return err; 502 return err;
492 } 503 }
493 504
@@ -509,7 +520,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
509 /* wait for daughter status == 3 */ 520 /* wait for daughter status == 3 */
510 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 3, 300); /* 3sec */ 521 err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 3, 300); /* 3sec */
511 if (err < 0) { 522 if (err < 0) {
512 snd_printk(KERN_ERR 523 dev_err(&mgr->pci->dev,
513 "daughter board could not be initialised\n"); 524 "daughter board could not be initialised\n");
514 return err; 525 return err;
515 } 526 }
@@ -520,7 +531,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
520 /* first communication with embedded */ 531 /* first communication with embedded */
521 err = mixart_first_init(mgr); 532 err = mixart_first_init(mgr);
522 if (err < 0) { 533 if (err < 0) {
523 snd_printk(KERN_ERR "miXart could not be set up\n"); 534 dev_err(&mgr->pci->dev, "miXart could not be set up\n");
524 return err; 535 return err;
525 } 536 }
526 537
@@ -540,7 +551,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
540 return err; 551 return err;
541 } 552 }
542 553
543 snd_printdd("miXart firmware downloaded and successfully set up\n"); 554 dev_dbg(&mgr->pci->dev,
555 "miXart firmware downloaded and successfully set up\n");
544 556
545 return 0; 557 return 0;
546} 558}
@@ -559,7 +571,8 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
559 for (i = 0; i < 3; i++) { 571 for (i = 0; i < 3; i++) {
560 sprintf(path, "mixart/%s", fw_files[i]); 572 sprintf(path, "mixart/%s", fw_files[i]);
561 if (request_firmware(&fw_entry, path, &mgr->pci->dev)) { 573 if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
562 snd_printk(KERN_ERR "miXart: can't load firmware %s\n", path); 574 dev_err(&mgr->pci->dev,
575 "miXart: can't load firmware %s\n", path);
563 return -ENOENT; 576 return -ENOENT;
564 } 577 }
565 /* fake hwdep dsp record */ 578 /* fake hwdep dsp record */
diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c
index 3ba6174c3df1..24a1955b8c29 100644
--- a/sound/pci/mixart/mixart_mixer.c
+++ b/sound/pci/mixart/mixart_mixer.c
@@ -329,7 +329,9 @@ static int mixart_update_analog_audio_level(struct snd_mixart* chip, int is_capt
329 329
330 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp); 330 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
331 if((err<0) || (resp.error_code)) { 331 if((err<0) || (resp.error_code)) {
332 snd_printk(KERN_DEBUG "error MSG_PHYSICALIO_SET_LEVEL card(%d) is_capture(%d) error_code(%x)\n", chip->chip_idx, is_capture, resp.error_code); 332 dev_dbg(chip->card->dev,
333 "error MSG_PHYSICALIO_SET_LEVEL card(%d) is_capture(%d) error_code(%x)\n",
334 chip->chip_idx, is_capture, resp.error_code);
333 return -EINVAL; 335 return -EINVAL;
334 } 336 }
335 return 0; 337 return 0;
@@ -762,7 +764,9 @@ int mixart_update_playback_stream_level(struct snd_mixart* chip, int is_aes, int
762 764
763 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status); 765 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
764 if((err<0) || status) { 766 if((err<0) || status) {
765 snd_printk(KERN_DEBUG "error MSG_STREAM_SET_OUT_STREAM_LEVEL card(%d) status(%x)\n", chip->chip_idx, status); 767 dev_dbg(chip->card->dev,
768 "error MSG_STREAM_SET_OUT_STREAM_LEVEL card(%d) status(%x)\n",
769 chip->chip_idx, status);
766 return -EINVAL; 770 return -EINVAL;
767 } 771 }
768 return 0; 772 return 0;
@@ -805,7 +809,9 @@ int mixart_update_capture_stream_level(struct snd_mixart* chip, int is_aes)
805 809
806 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status); 810 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
807 if((err<0) || status) { 811 if((err<0) || status) {
808 snd_printk(KERN_DEBUG "error MSG_STREAM_SET_IN_AUDIO_LEVEL card(%d) status(%x)\n", chip->chip_idx, status); 812 dev_dbg(chip->card->dev,
813 "error MSG_STREAM_SET_IN_AUDIO_LEVEL card(%d) status(%x)\n",
814 chip->chip_idx, status);
809 return -EINVAL; 815 return -EINVAL;
810 } 816 }
811 return 0; 817 return 0;
@@ -977,7 +983,9 @@ static int mixart_update_monitoring(struct snd_mixart* chip, int channel)
977 983
978 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp); 984 err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
979 if((err<0) || resp) { 985 if((err<0) || resp) {
980 snd_printk(KERN_DEBUG "error MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL card(%d) resp(%x)\n", chip->chip_idx, resp); 986 dev_dbg(chip->card->dev,
987 "error MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL card(%d) resp(%x)\n",
988 chip->chip_idx, resp);
981 return -EINVAL; 989 return -EINVAL;
982 } 990 }
983 return 0; 991 return 0;
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index fe79fff4c6dc..ddc60215cc10 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -318,7 +318,8 @@ snd_nm256_write_buffer(struct nm256 *chip, void *src, int offset, int size)
318 offset -= chip->buffer_start; 318 offset -= chip->buffer_start;
319#ifdef CONFIG_SND_DEBUG 319#ifdef CONFIG_SND_DEBUG
320 if (offset < 0 || offset >= chip->buffer_size) { 320 if (offset < 0 || offset >= chip->buffer_size) {
321 snd_printk(KERN_ERR "write_buffer invalid offset = %d size = %d\n", 321 dev_err(chip->card->dev,
322 "write_buffer invalid offset = %d size = %d\n",
322 offset, size); 323 offset, size);
323 return; 324 return;
324 } 325 }
@@ -366,7 +367,8 @@ snd_nm256_load_coefficient(struct nm256 *chip, int stream, int number)
366 NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET); 367 NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET);
367 368
368 if (snd_nm256_readb(chip, poffset) & 1) { 369 if (snd_nm256_readb(chip, poffset) & 1) {
369 snd_printd("NM256: Engine was enabled while loading coefficients!\n"); 370 dev_dbg(chip->card->dev,
371 "NM256: Engine was enabled while loading coefficients!\n");
370 return; 372 return;
371 } 373 }
372 374
@@ -466,7 +468,8 @@ static int snd_nm256_acquire_irq(struct nm256 *chip)
466 if (chip->irq < 0) { 468 if (chip->irq < 0) {
467 if (request_irq(chip->pci->irq, chip->interrupt, IRQF_SHARED, 469 if (request_irq(chip->pci->irq, chip->interrupt, IRQF_SHARED,
468 KBUILD_MODNAME, chip)) { 470 KBUILD_MODNAME, chip)) {
469 snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->pci->irq); 471 dev_err(chip->card->dev,
472 "unable to grab IRQ %d\n", chip->pci->irq);
470 mutex_unlock(&chip->irq_mutex); 473 mutex_unlock(&chip->irq_mutex);
471 return -EBUSY; 474 return -EBUSY;
472 } 475 }
@@ -1039,7 +1042,7 @@ snd_nm256_interrupt(int irq, void *dev_id)
1039 if (status & NM_MISC_INT_1) { 1042 if (status & NM_MISC_INT_1) {
1040 status &= ~NM_MISC_INT_1; 1043 status &= ~NM_MISC_INT_1;
1041 NM_ACK_INT(chip, NM_MISC_INT_1); 1044 NM_ACK_INT(chip, NM_MISC_INT_1);
1042 snd_printd("NM256: Got misc interrupt #1\n"); 1045 dev_dbg(chip->card->dev, "NM256: Got misc interrupt #1\n");
1043 snd_nm256_writew(chip, NM_INT_REG, 0x8000); 1046 snd_nm256_writew(chip, NM_INT_REG, 0x8000);
1044 cbyte = snd_nm256_readb(chip, 0x400); 1047 cbyte = snd_nm256_readb(chip, 0x400);
1045 snd_nm256_writeb(chip, 0x400, cbyte | 2); 1048 snd_nm256_writeb(chip, 0x400, cbyte | 2);
@@ -1048,14 +1051,15 @@ snd_nm256_interrupt(int irq, void *dev_id)
1048 if (status & NM_MISC_INT_2) { 1051 if (status & NM_MISC_INT_2) {
1049 status &= ~NM_MISC_INT_2; 1052 status &= ~NM_MISC_INT_2;
1050 NM_ACK_INT(chip, NM_MISC_INT_2); 1053 NM_ACK_INT(chip, NM_MISC_INT_2);
1051 snd_printd("NM256: Got misc interrupt #2\n"); 1054 dev_dbg(chip->card->dev, "NM256: Got misc interrupt #2\n");
1052 cbyte = snd_nm256_readb(chip, 0x400); 1055 cbyte = snd_nm256_readb(chip, 0x400);
1053 snd_nm256_writeb(chip, 0x400, cbyte & ~2); 1056 snd_nm256_writeb(chip, 0x400, cbyte & ~2);
1054 } 1057 }
1055 1058
1056 /* Unknown interrupt. */ 1059 /* Unknown interrupt. */
1057 if (status) { 1060 if (status) {
1058 snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", 1061 dev_dbg(chip->card->dev,
1062 "NM256: Fire in the hole! Unknown status 0x%x\n",
1059 status); 1063 status);
1060 /* Pray. */ 1064 /* Pray. */
1061 NM_ACK_INT(chip, status); 1065 NM_ACK_INT(chip, status);
@@ -1104,7 +1108,7 @@ snd_nm256_interrupt_zx(int irq, void *dev_id)
1104 if (status & NM2_MISC_INT_1) { 1108 if (status & NM2_MISC_INT_1) {
1105 status &= ~NM2_MISC_INT_1; 1109 status &= ~NM2_MISC_INT_1;
1106 NM2_ACK_INT(chip, NM2_MISC_INT_1); 1110 NM2_ACK_INT(chip, NM2_MISC_INT_1);
1107 snd_printd("NM256: Got misc interrupt #1\n"); 1111 dev_dbg(chip->card->dev, "NM256: Got misc interrupt #1\n");
1108 cbyte = snd_nm256_readb(chip, 0x400); 1112 cbyte = snd_nm256_readb(chip, 0x400);
1109 snd_nm256_writeb(chip, 0x400, cbyte | 2); 1113 snd_nm256_writeb(chip, 0x400, cbyte | 2);
1110 } 1114 }
@@ -1112,14 +1116,15 @@ snd_nm256_interrupt_zx(int irq, void *dev_id)
1112 if (status & NM2_MISC_INT_2) { 1116 if (status & NM2_MISC_INT_2) {
1113 status &= ~NM2_MISC_INT_2; 1117 status &= ~NM2_MISC_INT_2;
1114 NM2_ACK_INT(chip, NM2_MISC_INT_2); 1118 NM2_ACK_INT(chip, NM2_MISC_INT_2);
1115 snd_printd("NM256: Got misc interrupt #2\n"); 1119 dev_dbg(chip->card->dev, "NM256: Got misc interrupt #2\n");
1116 cbyte = snd_nm256_readb(chip, 0x400); 1120 cbyte = snd_nm256_readb(chip, 0x400);
1117 snd_nm256_writeb(chip, 0x400, cbyte & ~2); 1121 snd_nm256_writeb(chip, 0x400, cbyte & ~2);
1118 } 1122 }
1119 1123
1120 /* Unknown interrupt. */ 1124 /* Unknown interrupt. */
1121 if (status) { 1125 if (status) {
1122 snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", 1126 dev_dbg(chip->card->dev,
1127 "NM256: Fire in the hole! Unknown status 0x%x\n",
1123 status); 1128 status);
1124 /* Pray. */ 1129 /* Pray. */
1125 NM2_ACK_INT(chip, status); 1130 NM2_ACK_INT(chip, status);
@@ -1245,7 +1250,7 @@ snd_nm256_ac97_write(struct snd_ac97 *ac97,
1245 return; 1250 return;
1246 } 1251 }
1247 } 1252 }
1248 snd_printd("nm256: ac97 codec not ready..\n"); 1253 dev_dbg(chip->card->dev, "nm256: ac97 codec not ready..\n");
1249} 1254}
1250 1255
1251/* static resolution table */ 1256/* static resolution table */
@@ -1347,7 +1352,8 @@ snd_nm256_peek_for_sig(struct nm256 *chip)
1347 1352
1348 temp = ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16); 1353 temp = ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16);
1349 if (temp == NULL) { 1354 if (temp == NULL) {
1350 snd_printk(KERN_ERR "Unable to scan for card signature in video RAM\n"); 1355 dev_err(chip->card->dev,
1356 "Unable to scan for card signature in video RAM\n");
1351 return -EBUSY; 1357 return -EBUSY;
1352 } 1358 }
1353 1359
@@ -1361,12 +1367,14 @@ snd_nm256_peek_for_sig(struct nm256 *chip)
1361 if (pointer == 0xffffffff || 1367 if (pointer == 0xffffffff ||
1362 pointer < chip->buffer_size || 1368 pointer < chip->buffer_size ||
1363 pointer > chip->buffer_end) { 1369 pointer > chip->buffer_end) {
1364 snd_printk(KERN_ERR "invalid signature found: 0x%x\n", pointer); 1370 dev_err(chip->card->dev,
1371 "invalid signature found: 0x%x\n", pointer);
1365 iounmap(temp); 1372 iounmap(temp);
1366 return -ENODEV; 1373 return -ENODEV;
1367 } else { 1374 } else {
1368 pointer_found = pointer; 1375 pointer_found = pointer;
1369 printk(KERN_INFO "nm256: found card signature in video RAM: 0x%x\n", 1376 dev_info(chip->card->dev,
1377 "found card signature in video RAM: 0x%x\n",
1370 pointer); 1378 pointer);
1371 } 1379 }
1372 } 1380 }
@@ -1411,8 +1419,7 @@ static int nm256_resume(struct device *dev)
1411 pci_set_power_state(pci, PCI_D0); 1419 pci_set_power_state(pci, PCI_D0);
1412 pci_restore_state(pci); 1420 pci_restore_state(pci);
1413 if (pci_enable_device(pci) < 0) { 1421 if (pci_enable_device(pci) < 0) {
1414 printk(KERN_ERR "nm256: pci_enable_device failed, " 1422 dev_err(dev, "pci_enable_device failed, disabling device\n");
1415 "disabling device\n");
1416 snd_card_disconnect(card); 1423 snd_card_disconnect(card);
1417 return -EIO; 1424 return -EIO;
1418 } 1425 }
@@ -1520,14 +1527,15 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1520 chip->res_cport = request_mem_region(chip->cport_addr, NM_PORT2_SIZE, 1527 chip->res_cport = request_mem_region(chip->cport_addr, NM_PORT2_SIZE,
1521 card->driver); 1528 card->driver);
1522 if (chip->res_cport == NULL) { 1529 if (chip->res_cport == NULL) {
1523 snd_printk(KERN_ERR "memory region 0x%lx (size 0x%x) busy\n", 1530 dev_err(card->dev, "memory region 0x%lx (size 0x%x) busy\n",
1524 chip->cport_addr, NM_PORT2_SIZE); 1531 chip->cport_addr, NM_PORT2_SIZE);
1525 err = -EBUSY; 1532 err = -EBUSY;
1526 goto __error; 1533 goto __error;
1527 } 1534 }
1528 chip->cport = ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE); 1535 chip->cport = ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE);
1529 if (chip->cport == NULL) { 1536 if (chip->cport == NULL) {
1530 snd_printk(KERN_ERR "unable to map control port %lx\n", chip->cport_addr); 1537 dev_err(card->dev, "unable to map control port %lx\n",
1538 chip->cport_addr);
1531 err = -ENOMEM; 1539 err = -ENOMEM;
1532 goto __error; 1540 goto __error;
1533 } 1541 }
@@ -1537,12 +1545,14 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1537 pval = snd_nm256_readw(chip, NM_MIXER_PRESENCE); 1545 pval = snd_nm256_readw(chip, NM_MIXER_PRESENCE);
1538 if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { 1546 if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) {
1539 if (! force_ac97) { 1547 if (! force_ac97) {
1540 printk(KERN_ERR "nm256: no ac97 is found!\n"); 1548 dev_err(card->dev,
1541 printk(KERN_ERR " force the driver to load by " 1549 "no ac97 is found!\n");
1542 "passing in the module parameter\n"); 1550 dev_err(card->dev,
1543 printk(KERN_ERR " force_ac97=1\n"); 1551 "force the driver to load by passing in the module parameter\n");
1544 printk(KERN_ERR " or try sb16, opl3sa2, or " 1552 dev_err(card->dev,
1545 "cs423x drivers instead.\n"); 1553 " force_ac97=1\n");
1554 dev_err(card->dev,
1555 "or try sb16, opl3sa2, or cs423x drivers instead.\n");
1546 err = -ENXIO; 1556 err = -ENXIO;
1547 goto __error; 1557 goto __error;
1548 } 1558 }
@@ -1581,14 +1591,14 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1581 chip->buffer_start = chip->buffer_end - chip->buffer_size; 1591 chip->buffer_start = chip->buffer_end - chip->buffer_size;
1582 chip->buffer_addr += chip->buffer_start; 1592 chip->buffer_addr += chip->buffer_start;
1583 1593
1584 printk(KERN_INFO "nm256: Mapping port 1 from 0x%x - 0x%x\n", 1594 dev_info(card->dev, "Mapping port 1 from 0x%x - 0x%x\n",
1585 chip->buffer_start, chip->buffer_end); 1595 chip->buffer_start, chip->buffer_end);
1586 1596
1587 chip->res_buffer = request_mem_region(chip->buffer_addr, 1597 chip->res_buffer = request_mem_region(chip->buffer_addr,
1588 chip->buffer_size, 1598 chip->buffer_size,
1589 card->driver); 1599 card->driver);
1590 if (chip->res_buffer == NULL) { 1600 if (chip->res_buffer == NULL) {
1591 snd_printk(KERN_ERR "nm256: buffer 0x%lx (size 0x%x) busy\n", 1601 dev_err(card->dev, "buffer 0x%lx (size 0x%x) busy\n",
1592 chip->buffer_addr, chip->buffer_size); 1602 chip->buffer_addr, chip->buffer_size);
1593 err = -EBUSY; 1603 err = -EBUSY;
1594 goto __error; 1604 goto __error;
@@ -1596,7 +1606,8 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1596 chip->buffer = ioremap_nocache(chip->buffer_addr, chip->buffer_size); 1606 chip->buffer = ioremap_nocache(chip->buffer_addr, chip->buffer_size);
1597 if (chip->buffer == NULL) { 1607 if (chip->buffer == NULL) {
1598 err = -ENOMEM; 1608 err = -ENOMEM;
1599 snd_printk(KERN_ERR "unable to map ring buffer at %lx\n", chip->buffer_addr); 1609 dev_err(card->dev, "unable to map ring buffer at %lx\n",
1610 chip->buffer_addr);
1600 goto __error; 1611 goto __error;
1601 } 1612 }
1602 1613
@@ -1626,8 +1637,6 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci,
1626 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) 1637 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
1627 goto __error; 1638 goto __error;
1628 1639
1629 snd_card_set_dev(card, &pci->dev);
1630
1631 *chip_ret = chip; 1640 *chip_ret = chip;
1632 return 0; 1641 return 0;
1633 1642
@@ -1660,12 +1669,12 @@ static int snd_nm256_probe(struct pci_dev *pci,
1660 1669
1661 q = snd_pci_quirk_lookup(pci, nm256_quirks); 1670 q = snd_pci_quirk_lookup(pci, nm256_quirks);
1662 if (q) { 1671 if (q) {
1663 snd_printdd(KERN_INFO "nm256: Enabled quirk for %s.\n", 1672 dev_dbg(&pci->dev, "Enabled quirk for %s.\n",
1664 snd_pci_quirk_name(q)); 1673 snd_pci_quirk_name(q));
1665 switch (q->value) { 1674 switch (q->value) {
1666 case NM_BLACKLISTED: 1675 case NM_BLACKLISTED:
1667 printk(KERN_INFO "nm256: The device is blacklisted. " 1676 dev_info(&pci->dev,
1668 "Loading stopped\n"); 1677 "The device is blacklisted. Loading stopped\n");
1669 return -ENODEV; 1678 return -ENODEV;
1670 case NM_RESET_WORKAROUND_2: 1679 case NM_RESET_WORKAROUND_2:
1671 reset_workaround_2 = 1; 1680 reset_workaround_2 = 1;
@@ -1676,7 +1685,7 @@ static int snd_nm256_probe(struct pci_dev *pci,
1676 } 1685 }
1677 } 1686 }
1678 1687
1679 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 1688 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
1680 if (err < 0) 1689 if (err < 0)
1681 return err; 1690 return err;
1682 1691
@@ -1691,7 +1700,7 @@ static int snd_nm256_probe(struct pci_dev *pci,
1691 strcpy(card->driver, "NM256XL+"); 1700 strcpy(card->driver, "NM256XL+");
1692 break; 1701 break;
1693 default: 1702 default:
1694 snd_printk(KERN_ERR "invalid device id 0x%x\n", pci->device); 1703 dev_err(&pci->dev, "invalid device id 0x%x\n", pci->device);
1695 snd_card_free(card); 1704 snd_card_free(card);
1696 return -EINVAL; 1705 return -EINVAL;
1697 } 1706 }
@@ -1714,12 +1723,12 @@ static int snd_nm256_probe(struct pci_dev *pci,
1714 card->private_data = chip; 1723 card->private_data = chip;
1715 1724
1716 if (reset_workaround) { 1725 if (reset_workaround) {
1717 snd_printdd(KERN_INFO "nm256: reset_workaround activated\n"); 1726 dev_dbg(&pci->dev, "reset_workaround activated\n");
1718 chip->reset_workaround = 1; 1727 chip->reset_workaround = 1;
1719 } 1728 }
1720 1729
1721 if (reset_workaround_2) { 1730 if (reset_workaround_2) {
1722 snd_printdd(KERN_INFO "nm256: reset_workaround_2 activated\n"); 1731 dev_dbg(&pci->dev, "reset_workaround_2 activated\n");
1723 chip->reset_workaround_2 = 1; 1732 chip->reset_workaround_2 = 1;
1724 } 1733 }
1725 1734
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c
index 3274907189fe..4b8a32c37e31 100644
--- a/sound/pci/oxygen/oxygen_io.c
+++ b/sound/pci/oxygen/oxygen_io.c
@@ -147,7 +147,7 @@ void oxygen_write_ac97(struct oxygen *chip, unsigned int codec,
147 return; 147 return;
148 } 148 }
149 } 149 }
150 snd_printk(KERN_ERR "AC'97 write timeout\n"); 150 dev_err(chip->card->dev, "AC'97 write timeout\n");
151} 151}
152EXPORT_SYMBOL(oxygen_write_ac97); 152EXPORT_SYMBOL(oxygen_write_ac97);
153 153
@@ -179,7 +179,7 @@ u16 oxygen_read_ac97(struct oxygen *chip, unsigned int codec,
179 reg ^= 0xffff; 179 reg ^= 0xffff;
180 } 180 }
181 } 181 }
182 snd_printk(KERN_ERR "AC'97 read timeout on codec %u\n", codec); 182 dev_err(chip->card->dev, "AC'97 read timeout on codec %u\n", codec);
183 return 0; 183 return 0;
184} 184}
185EXPORT_SYMBOL(oxygen_read_ac97); 185EXPORT_SYMBOL(oxygen_read_ac97);
@@ -208,7 +208,7 @@ static int oxygen_wait_spi(struct oxygen *chip)
208 OXYGEN_SPI_BUSY) == 0) 208 OXYGEN_SPI_BUSY) == 0)
209 return 0; 209 return 0;
210 } 210 }
211 snd_printk(KERN_ERR "oxygen: SPI wait timeout\n"); 211 dev_err(chip->card->dev, "oxygen: SPI wait timeout\n");
212 return -EIO; 212 return -EIO;
213} 213}
214 214
@@ -288,5 +288,5 @@ void oxygen_write_eeprom(struct oxygen *chip, unsigned int index, u16 value)
288 & OXYGEN_EEPROM_BUSY)) 288 & OXYGEN_EEPROM_BUSY))
289 return; 289 return;
290 } 290 }
291 snd_printk(KERN_ERR "EEPROM write timeout\n"); 291 dev_err(chip->card->dev, "EEPROM write timeout\n");
292} 292}
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c
index b0cb48adddc7..b67e30602473 100644
--- a/sound/pci/oxygen/oxygen_lib.c
+++ b/sound/pci/oxygen/oxygen_lib.c
@@ -313,7 +313,7 @@ static void oxygen_restore_eeprom(struct oxygen *chip,
313 oxygen_clear_bits8(chip, OXYGEN_MISC, 313 oxygen_clear_bits8(chip, OXYGEN_MISC,
314 OXYGEN_MISC_WRITE_PCI_SUBID); 314 OXYGEN_MISC_WRITE_PCI_SUBID);
315 315
316 snd_printk(KERN_INFO "EEPROM ID restored\n"); 316 dev_info(chip->card->dev, "EEPROM ID restored\n");
317 } 317 }
318} 318}
319 319
@@ -595,7 +595,8 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
595 const struct pci_device_id *pci_id; 595 const struct pci_device_id *pci_id;
596 int err; 596 int err;
597 597
598 err = snd_card_create(index, id, owner, sizeof(*chip), &card); 598 err = snd_card_new(&pci->dev, index, id, owner,
599 sizeof(*chip), &card);
599 if (err < 0) 600 if (err < 0)
600 return err; 601 return err;
601 602
@@ -616,13 +617,13 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
616 617
617 err = pci_request_regions(pci, DRIVER); 618 err = pci_request_regions(pci, DRIVER);
618 if (err < 0) { 619 if (err < 0) {
619 snd_printk(KERN_ERR "cannot reserve PCI resources\n"); 620 dev_err(card->dev, "cannot reserve PCI resources\n");
620 goto err_pci_enable; 621 goto err_pci_enable;
621 } 622 }
622 623
623 if (!(pci_resource_flags(pci, 0) & IORESOURCE_IO) || 624 if (!(pci_resource_flags(pci, 0) & IORESOURCE_IO) ||
624 pci_resource_len(pci, 0) < OXYGEN_IO_SIZE) { 625 pci_resource_len(pci, 0) < OXYGEN_IO_SIZE) {
625 snd_printk(KERN_ERR "invalid PCI I/O range\n"); 626 dev_err(card->dev, "invalid PCI I/O range\n");
626 err = -ENXIO; 627 err = -ENXIO;
627 goto err_pci_regions; 628 goto err_pci_regions;
628 } 629 }
@@ -648,7 +649,6 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
648 } 649 }
649 650
650 pci_set_master(pci); 651 pci_set_master(pci);
651 snd_card_set_dev(card, &pci->dev);
652 card->private_free = oxygen_card_free; 652 card->private_free = oxygen_card_free;
653 653
654 configure_pcie_bridge(pci); 654 configure_pcie_bridge(pci);
@@ -658,7 +658,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
658 err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED, 658 err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED,
659 KBUILD_MODNAME, chip); 659 KBUILD_MODNAME, chip);
660 if (err < 0) { 660 if (err < 0) {
661 snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq); 661 dev_err(card->dev, "cannot grab interrupt %d\n", pci->irq);
662 goto err_card; 662 goto err_card;
663 } 663 }
664 chip->irq = pci->irq; 664 chip->irq = pci->irq;
@@ -796,7 +796,7 @@ static int oxygen_pci_resume(struct device *dev)
796 pci_set_power_state(pci, PCI_D0); 796 pci_set_power_state(pci, PCI_D0);
797 pci_restore_state(pci); 797 pci_restore_state(pci);
798 if (pci_enable_device(pci) < 0) { 798 if (pci_enable_device(pci) < 0) {
799 snd_printk(KERN_ERR "cannot reenable device"); 799 dev_err(dev, "cannot reenable device");
800 snd_card_disconnect(card); 800 snd_card_disconnect(card);
801 return -EIO; 801 return -EIO;
802 } 802 }
diff --git a/sound/pci/oxygen/xonar_hdmi.c b/sound/pci/oxygen/xonar_hdmi.c
index 136dac6a3964..91d92bc32b75 100644
--- a/sound/pci/oxygen/xonar_hdmi.c
+++ b/sound/pci/oxygen/xonar_hdmi.c
@@ -120,7 +120,7 @@ void xonar_hdmi_uart_input(struct oxygen *chip)
120 if (chip->uart_input_count >= 2 && 120 if (chip->uart_input_count >= 2 &&
121 chip->uart_input[chip->uart_input_count - 2] == 'O' && 121 chip->uart_input[chip->uart_input_count - 2] == 'O' &&
122 chip->uart_input[chip->uart_input_count - 1] == 'K') { 122 chip->uart_input[chip->uart_input_count - 1] == 'K') {
123 printk(KERN_DEBUG "message from HDMI chip received:\n"); 123 dev_dbg(chip->card->dev, "message from HDMI chip received:\n");
124 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 124 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
125 chip->uart_input, chip->uart_input_count); 125 chip->uart_input, chip->uart_input_count);
126 chip->uart_input_count = 0; 126 chip->uart_input_count = 0;
diff --git a/sound/pci/oxygen/xonar_lib.c b/sound/pci/oxygen/xonar_lib.c
index 0ebe7f5916f9..706b1a42163f 100644
--- a/sound/pci/oxygen/xonar_lib.c
+++ b/sound/pci/oxygen/xonar_lib.c
@@ -56,9 +56,9 @@ static void xonar_ext_power_gpio_changed(struct oxygen *chip)
56 if (has_power != data->has_power) { 56 if (has_power != data->has_power) {
57 data->has_power = has_power; 57 data->has_power = has_power;
58 if (has_power) { 58 if (has_power) {
59 snd_printk(KERN_NOTICE "power restored\n"); 59 dev_notice(chip->card->dev, "power restored\n");
60 } else { 60 } else {
61 snd_printk(KERN_CRIT 61 dev_crit(chip->card->dev,
62 "Hey! Don't unplug the power cable!\n"); 62 "Hey! Don't unplug the power cable!\n");
63 /* TODO: stop PCMs */ 63 /* TODO: stop PCMs */
64 } 64 }
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index d379b284955b..8d09444ff88b 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -284,7 +284,7 @@ static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate,
284 rmh.cmd_len = 3; 284 rmh.cmd_len = 3;
285 err = pcxhr_send_msg(mgr, &rmh); 285 err = pcxhr_send_msg(mgr, &rmh);
286 if (err < 0) { 286 if (err < 0) {
287 snd_printk(KERN_ERR 287 dev_err(&mgr->pci->dev,
288 "error CMD_ACCESS_IO_WRITE " 288 "error CMD_ACCESS_IO_WRITE "
289 "for PLL register : %x!\n", err); 289 "for PLL register : %x!\n", err);
290 return err; 290 return err;
@@ -357,7 +357,7 @@ static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr,
357 return err; 357 return err;
358 } 358 }
359 /* set the new frequency */ 359 /* set the new frequency */
360 snd_printdd("clock register : set %x\n", val); 360 dev_dbg(&mgr->pci->dev, "clock register : set %x\n", val);
361 err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, 361 err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK,
362 val, changed); 362 val, changed);
363 if (err) 363 if (err)
@@ -380,7 +380,7 @@ static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr,
380 mgr->codec_speed = speed; /* save new codec speed */ 380 mgr->codec_speed = speed; /* save new codec speed */
381 } 381 }
382 382
383 snd_printdd("pcxhr_sub_set_clock to %dHz (realfreq=%d)\n", 383 dev_dbg(&mgr->pci->dev, "pcxhr_sub_set_clock to %dHz (realfreq=%d)\n",
384 rate, realfreq); 384 rate, realfreq);
385 return 0; 385 return 0;
386} 386}
@@ -480,7 +480,7 @@ static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr,
480 case REG_STATUS_SYNC_192000 : rate = 192000; break; 480 case REG_STATUS_SYNC_192000 : rate = 192000; break;
481 default: rate = 0; 481 default: rate = 0;
482 } 482 }
483 snd_printdd("External clock is at %d Hz\n", rate); 483 dev_dbg(&mgr->pci->dev, "External clock is at %d Hz\n", rate);
484 *sample_rate = rate; 484 *sample_rate = rate;
485 return 0; 485 return 0;
486} 486}
@@ -537,8 +537,8 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream)
537 537
538 err = pcxhr_send_msg(chip->mgr, &rmh); 538 err = pcxhr_send_msg(chip->mgr, &rmh);
539 if (err) 539 if (err)
540 snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state err=%x;\n", 540 dev_err(chip->card->dev,
541 err); 541 "ERROR pcxhr_set_stream_state err=%x;\n", err);
542 stream->status = 542 stream->status =
543 start ? PCXHR_STREAM_STATUS_STARTED : PCXHR_STREAM_STATUS_STOPPED; 543 start ? PCXHR_STREAM_STATUS_STARTED : PCXHR_STREAM_STATUS_STOPPED;
544 return err; 544 return err;
@@ -628,7 +628,8 @@ static int pcxhr_set_format(struct pcxhr_stream *stream)
628 rmh.cmd[rmh.cmd_len++] = (header & 0xff) << 16; 628 rmh.cmd[rmh.cmd_len++] = (header & 0xff) << 16;
629 err = pcxhr_send_msg(chip->mgr, &rmh); 629 err = pcxhr_send_msg(chip->mgr, &rmh);
630 if (err) 630 if (err)
631 snd_printk(KERN_ERR "ERROR pcxhr_set_format err=%x;\n", err); 631 dev_err(chip->card->dev,
632 "ERROR pcxhr_set_format err=%x;\n", err);
632 return err; 633 return err;
633} 634}
634 635
@@ -665,7 +666,7 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
665 rmh.cmd_len = 4; 666 rmh.cmd_len = 4;
666 err = pcxhr_send_msg(chip->mgr, &rmh); 667 err = pcxhr_send_msg(chip->mgr, &rmh);
667 if (err) 668 if (err)
668 snd_printk(KERN_ERR 669 dev_err(chip->card->dev,
669 "ERROR CMD_UPDATE_R_BUFFERS err=%x;\n", err); 670 "ERROR CMD_UPDATE_R_BUFFERS err=%x;\n", err);
670 return err; 671 return err;
671} 672}
@@ -735,11 +736,11 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
735 } 736 }
736 if (capture_mask == 0 && playback_mask == 0) { 737 if (capture_mask == 0 && playback_mask == 0) {
737 mutex_unlock(&mgr->setup_mutex); 738 mutex_unlock(&mgr->setup_mutex);
738 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : no pipes\n"); 739 dev_err(&mgr->pci->dev, "pcxhr_trigger_tasklet : no pipes\n");
739 return; 740 return;
740 } 741 }
741 742
742 snd_printdd("pcxhr_trigger_tasklet : " 743 dev_dbg(&mgr->pci->dev, "pcxhr_trigger_tasklet : "
743 "playback_mask=%x capture_mask=%x\n", 744 "playback_mask=%x capture_mask=%x\n",
744 playback_mask, capture_mask); 745 playback_mask, capture_mask);
745 746
@@ -747,7 +748,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
747 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); 748 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
748 if (err) { 749 if (err) {
749 mutex_unlock(&mgr->setup_mutex); 750 mutex_unlock(&mgr->setup_mutex);
750 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : " 751 dev_err(&mgr->pci->dev, "pcxhr_trigger_tasklet : "
751 "error stop pipes (P%x C%x)\n", 752 "error stop pipes (P%x C%x)\n",
752 playback_mask, capture_mask); 753 playback_mask, capture_mask);
753 return; 754 return;
@@ -792,7 +793,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
792 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); 793 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1);
793 if (err) { 794 if (err) {
794 mutex_unlock(&mgr->setup_mutex); 795 mutex_unlock(&mgr->setup_mutex);
795 snd_printk(KERN_ERR "pcxhr_trigger_tasklet : " 796 dev_err(&mgr->pci->dev, "pcxhr_trigger_tasklet : "
796 "error start pipes (P%x C%x)\n", 797 "error start pipes (P%x C%x)\n",
797 playback_mask, capture_mask); 798 playback_mask, capture_mask);
798 return; 799 return;
@@ -825,7 +826,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg)
825 826
826#ifdef CONFIG_SND_DEBUG_VERBOSE 827#ifdef CONFIG_SND_DEBUG_VERBOSE
827 do_gettimeofday(&my_tv2); 828 do_gettimeofday(&my_tv2);
828 snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n", 829 dev_dbg(&mgr->pci->dev, "***TRIGGER TASKLET*** TIME = %ld (err = %x)\n",
829 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err); 830 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
830#endif 831#endif
831} 832}
@@ -902,7 +903,7 @@ static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start)
902 } 903 }
903 err = pcxhr_send_msg(mgr, &rmh); 904 err = pcxhr_send_msg(mgr, &rmh);
904 if (err < 0) 905 if (err < 0)
905 snd_printk(KERN_ERR "error pcxhr_hardware_timer err(%x)\n", 906 dev_err(&mgr->pci->dev, "error pcxhr_hardware_timer err(%x)\n",
906 err); 907 err);
907 return err; 908 return err;
908} 909}
@@ -916,7 +917,8 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs)
916 struct pcxhr_mgr *mgr = chip->mgr; 917 struct pcxhr_mgr *mgr = chip->mgr;
917 int err = 0; 918 int err = 0;
918 919
919 snd_printdd("pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n", 920 dev_dbg(chip->card->dev,
921 "pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n",
920 subs->runtime->period_size, subs->runtime->periods, 922 subs->runtime->period_size, subs->runtime->periods,
921 subs->runtime->buffer_size); 923 subs->runtime->buffer_size);
922 924
@@ -1025,11 +1027,11 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
1025 runtime->hw = pcxhr_caps; 1027 runtime->hw = pcxhr_caps;
1026 1028
1027 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) { 1029 if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) {
1028 snd_printdd("pcxhr_open playback chip%d subs%d\n", 1030 dev_dbg(chip->card->dev, "pcxhr_open playback chip%d subs%d\n",
1029 chip->chip_idx, subs->number); 1031 chip->chip_idx, subs->number);
1030 stream = &chip->playback_stream[subs->number]; 1032 stream = &chip->playback_stream[subs->number];
1031 } else { 1033 } else {
1032 snd_printdd("pcxhr_open capture chip%d subs%d\n", 1034 dev_dbg(chip->card->dev, "pcxhr_open capture chip%d subs%d\n",
1033 chip->chip_idx, subs->number); 1035 chip->chip_idx, subs->number);
1034 if (mgr->mono_capture) 1036 if (mgr->mono_capture)
1035 runtime->hw.channels_max = 1; 1037 runtime->hw.channels_max = 1;
@@ -1039,7 +1041,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs)
1039 } 1041 }
1040 if (stream->status != PCXHR_STREAM_STATUS_FREE){ 1042 if (stream->status != PCXHR_STREAM_STATUS_FREE){
1041 /* streams in use */ 1043 /* streams in use */
1042 snd_printk(KERN_ERR "pcxhr_open chip%d subs%d in use\n", 1044 dev_err(chip->card->dev, "pcxhr_open chip%d subs%d in use\n",
1043 chip->chip_idx, subs->number); 1045 chip->chip_idx, subs->number);
1044 mutex_unlock(&mgr->setup_mutex); 1046 mutex_unlock(&mgr->setup_mutex);
1045 return -EBUSY; 1047 return -EBUSY;
@@ -1105,7 +1107,7 @@ static int pcxhr_close(struct snd_pcm_substream *subs)
1105 1107
1106 mutex_lock(&mgr->setup_mutex); 1108 mutex_lock(&mgr->setup_mutex);
1107 1109
1108 snd_printdd("pcxhr_close chip%d subs%d\n", 1110 dev_dbg(chip->card->dev, "pcxhr_close chip%d subs%d\n",
1109 chip->chip_idx, subs->number); 1111 chip->chip_idx, subs->number);
1110 1112
1111 /* sample rate released */ 1113 /* sample rate released */
@@ -1168,7 +1170,7 @@ int pcxhr_create_pcm(struct snd_pcxhr *chip)
1168 if ((err = snd_pcm_new(chip->card, name, 0, 1170 if ((err = snd_pcm_new(chip->card, name, 0,
1169 chip->nb_streams_play, 1171 chip->nb_streams_play,
1170 chip->nb_streams_capt, &pcm)) < 0) { 1172 chip->nb_streams_capt, &pcm)) < 0) {
1171 snd_printk(KERN_ERR "cannot create pcm %s\n", name); 1173 dev_err(chip->card->dev, "cannot create pcm %s\n", name);
1172 return err; 1174 return err;
1173 } 1175 }
1174 pcm->private_data = chip; 1176 pcm->private_data = chip;
@@ -1214,7 +1216,7 @@ static int pcxhr_create(struct pcxhr_mgr *mgr,
1214 1216
1215 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1217 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1216 if (! chip) { 1218 if (! chip) {
1217 snd_printk(KERN_ERR "cannot allocate chip\n"); 1219 dev_err(card->dev, "cannot allocate chip\n");
1218 return -ENOMEM; 1220 return -ENOMEM;
1219 } 1221 }
1220 1222
@@ -1239,7 +1241,6 @@ static int pcxhr_create(struct pcxhr_mgr *mgr,
1239 } 1241 }
1240 1242
1241 mgr->chip[idx] = chip; 1243 mgr->chip[idx] = chip;
1242 snd_card_set_dev(card, &mgr->pci->dev);
1243 1244
1244 return 0; 1245 return 0;
1245} 1246}
@@ -1488,7 +1489,7 @@ static int pcxhr_free(struct pcxhr_mgr *mgr)
1488 /* reset board if some firmware was loaded */ 1489 /* reset board if some firmware was loaded */
1489 if(mgr->dsp_loaded) { 1490 if(mgr->dsp_loaded) {
1490 pcxhr_reset_board(mgr); 1491 pcxhr_reset_board(mgr);
1491 snd_printdd("reset pcxhr !\n"); 1492 dev_dbg(&mgr->pci->dev, "reset pcxhr !\n");
1492 } 1493 }
1493 1494
1494 /* release irq */ 1495 /* release irq */
@@ -1537,8 +1538,8 @@ static int pcxhr_probe(struct pci_dev *pci,
1537 1538
1538 /* check if we can restrict PCI DMA transfers to 32 bits */ 1539 /* check if we can restrict PCI DMA transfers to 32 bits */
1539 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) { 1540 if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
1540 snd_printk(KERN_ERR "architecture does not support " 1541 dev_err(&pci->dev,
1541 "32bit PCI busmaster DMA\n"); 1542 "architecture does not support 32bit PCI busmaster DMA\n");
1542 pci_disable_device(pci); 1543 pci_disable_device(pci);
1543 return -ENXIO; 1544 return -ENXIO;
1544 } 1545 }
@@ -1589,7 +1590,7 @@ static int pcxhr_probe(struct pci_dev *pci,
1589 1590
1590 if (request_irq(pci->irq, pcxhr_interrupt, IRQF_SHARED, 1591 if (request_irq(pci->irq, pcxhr_interrupt, IRQF_SHARED,
1591 KBUILD_MODNAME, mgr)) { 1592 KBUILD_MODNAME, mgr)) {
1592 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1593 dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq);
1593 pcxhr_free(mgr); 1594 pcxhr_free(mgr);
1594 return -EBUSY; 1595 return -EBUSY;
1595 } 1596 }
@@ -1638,10 +1639,11 @@ static int pcxhr_probe(struct pci_dev *pci,
1638 1639
1639 snprintf(tmpid, sizeof(tmpid), "%s-%d", 1640 snprintf(tmpid, sizeof(tmpid), "%s-%d",
1640 id[dev] ? id[dev] : card_name, i); 1641 id[dev] ? id[dev] : card_name, i);
1641 err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card); 1642 err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
1643 0, &card);
1642 1644
1643 if (err < 0) { 1645 if (err < 0) {
1644 snd_printk(KERN_ERR "cannot allocate the card %d\n", i); 1646 dev_err(card->dev, "cannot allocate the card %d\n", i);
1645 pcxhr_free(mgr); 1647 pcxhr_free(mgr);
1646 return err; 1648 return err;
1647 } 1649 }
diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c
index 37b431b9b69d..df9371918601 100644
--- a/sound/pci/pcxhr/pcxhr_core.c
+++ b/sound/pci/pcxhr/pcxhr_core.c
@@ -23,6 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/pci.h>
26#include <asm/io.h> 27#include <asm/io.h>
27#include <sound/core.h> 28#include <sound/core.h>
28#include "pcxhr.h" 29#include "pcxhr.h"
@@ -132,14 +133,14 @@ static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int reg,
132 *read = PCXHR_INPB(mgr, reg); 133 *read = PCXHR_INPB(mgr, reg);
133 if ((*read & mask) == bit) { 134 if ((*read & mask) == bit) {
134 if (i > 100) 135 if (i > 100)
135 snd_printdd("ATTENTION! check_reg(%x) " 136 dev_dbg(&mgr->pci->dev,
136 "loopcount=%d\n", 137 "ATTENTION! check_reg(%x) loopcount=%d\n",
137 reg, i); 138 reg, i);
138 return 0; 139 return 0;
139 } 140 }
140 i++; 141 i++;
141 } while (time_after_eq(end_time, jiffies)); 142 } while (time_after_eq(end_time, jiffies));
142 snd_printk(KERN_ERR 143 dev_err(&mgr->pci->dev,
143 "pcxhr_check_reg_bit: timeout, reg=%x, mask=0x%x, val=%x\n", 144 "pcxhr_check_reg_bit: timeout, reg=%x, mask=0x%x, val=%x\n",
144 reg, mask, *read); 145 reg, mask, *read);
145 return -EIO; 146 return -EIO;
@@ -216,7 +217,7 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr,
216 err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_CVR, PCXHR_CVR_HI08_HC, 0, 217 err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_CVR, PCXHR_CVR_HI08_HC, 0,
217 PCXHR_TIMEOUT_DSP, &reg); 218 PCXHR_TIMEOUT_DSP, &reg);
218 if (err) { 219 if (err) {
219 snd_printk(KERN_ERR "pcxhr_send_it_dsp : TIMEOUT CVR\n"); 220 dev_err(&mgr->pci->dev, "pcxhr_send_it_dsp : TIMEOUT CVR\n");
220 return err; 221 return err;
221 } 222 }
222 if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) { 223 if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) {
@@ -227,7 +228,7 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr,
227 PCXHR_TIMEOUT_DSP, 228 PCXHR_TIMEOUT_DSP,
228 &reg); 229 &reg);
229 if (err) { 230 if (err) {
230 snd_printk(KERN_ERR 231 dev_err(&mgr->pci->dev,
231 "pcxhr_send_it_dsp : TIMEOUT HF5\n"); 232 "pcxhr_send_it_dsp : TIMEOUT HF5\n");
232 return err; 233 return err;
233 } 234 }
@@ -294,7 +295,7 @@ int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr,
294 */ 295 */
295 if(second) { 296 if(second) {
296 if ((chipsc & PCXHR_CHIPSC_GPI_USERI) == 0) { 297 if ((chipsc & PCXHR_CHIPSC_GPI_USERI) == 0) {
297 snd_printk(KERN_ERR "error loading first xilinx\n"); 298 dev_err(&mgr->pci->dev, "error loading first xilinx\n");
298 return -EINVAL; 299 return -EINVAL;
299 } 300 }
300 /* activate second xilinx */ 301 /* activate second xilinx */
@@ -360,7 +361,7 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp)
360 PCXHR_ISR_HI08_TRDY, 361 PCXHR_ISR_HI08_TRDY,
361 PCXHR_TIMEOUT_DSP, &dummy); 362 PCXHR_TIMEOUT_DSP, &dummy);
362 if (err) { 363 if (err) {
363 snd_printk(KERN_ERR 364 dev_err(&mgr->pci->dev,
364 "dsp loading error at position %d\n", i); 365 "dsp loading error at position %d\n", i);
365 return err; 366 return err;
366 } 367 }
@@ -396,7 +397,7 @@ int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr,
396 msleep(PCXHR_WAIT_DEFAULT); 397 msleep(PCXHR_WAIT_DEFAULT);
397 PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); 398 PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg);
398 msleep(PCXHR_WAIT_DEFAULT); 399 msleep(PCXHR_WAIT_DEFAULT);
399 snd_printdd("no need to load eeprom boot\n"); 400 dev_dbg(&mgr->pci->dev, "no need to load eeprom boot\n");
400 return 0; 401 return 0;
401 } 402 }
402 PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); 403 PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg);
@@ -561,9 +562,9 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
561 PCXHR_ISR_HI08_RXDF, 562 PCXHR_ISR_HI08_RXDF,
562 PCXHR_TIMEOUT_DSP, &reg); 563 PCXHR_TIMEOUT_DSP, &reg);
563 if (err) { 564 if (err) {
564 snd_printk(KERN_ERR "ERROR RMH stat: " 565 dev_err(&mgr->pci->dev,
565 "ISR:RXDF=1 (ISR = %x; i=%d )\n", 566 "ERROR RMH stat: ISR:RXDF=1 (ISR = %x; i=%d )\n",
566 reg, i); 567 reg, i);
567 return err; 568 return err;
568 } 569 }
569 /* read data */ 570 /* read data */
@@ -591,13 +592,13 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
591 } 592 }
592#ifdef CONFIG_SND_DEBUG_VERBOSE 593#ifdef CONFIG_SND_DEBUG_VERBOSE
593 if (rmh->cmd_idx < CMD_LAST_INDEX) 594 if (rmh->cmd_idx < CMD_LAST_INDEX)
594 snd_printdd(" stat[%d]=%x\n", i, data); 595 dev_dbg(&mgr->pci->dev, " stat[%d]=%x\n", i, data);
595#endif 596#endif
596 if (i < max_stat_len) 597 if (i < max_stat_len)
597 rmh->stat[i] = data; 598 rmh->stat[i] = data;
598 } 599 }
599 if (rmh->stat_len > max_stat_len) { 600 if (rmh->stat_len > max_stat_len) {
600 snd_printdd("PCXHR : rmh->stat_len=%x too big\n", 601 dev_dbg(&mgr->pci->dev, "PCXHR : rmh->stat_len=%x too big\n",
601 rmh->stat_len); 602 rmh->stat_len);
602 rmh->stat_len = max_stat_len; 603 rmh->stat_len = max_stat_len;
603 } 604 }
@@ -615,7 +616,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
615 return -EINVAL; 616 return -EINVAL;
616 err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1); 617 err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1);
617 if (err) { 618 if (err) {
618 snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n"); 619 dev_err(&mgr->pci->dev,
620 "pcxhr_send_message : ED_DSP_CRASHED\n");
619 return err; 621 return err;
620 } 622 }
621 /* wait for chk bit */ 623 /* wait for chk bit */
@@ -641,7 +643,7 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
641 data &= 0xff7fff; /* MASK_1_WORD_COMMAND */ 643 data &= 0xff7fff; /* MASK_1_WORD_COMMAND */
642#ifdef CONFIG_SND_DEBUG_VERBOSE 644#ifdef CONFIG_SND_DEBUG_VERBOSE
643 if (rmh->cmd_idx < CMD_LAST_INDEX) 645 if (rmh->cmd_idx < CMD_LAST_INDEX)
644 snd_printdd("MSG cmd[0]=%x (%s)\n", 646 dev_dbg(&mgr->pci->dev, "MSG cmd[0]=%x (%s)\n",
645 data, cmd_names[rmh->cmd_idx]); 647 data, cmd_names[rmh->cmd_idx]);
646#endif 648#endif
647 649
@@ -671,7 +673,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
671 data = rmh->cmd[i]; 673 data = rmh->cmd[i];
672#ifdef CONFIG_SND_DEBUG_VERBOSE 674#ifdef CONFIG_SND_DEBUG_VERBOSE
673 if (rmh->cmd_idx < CMD_LAST_INDEX) 675 if (rmh->cmd_idx < CMD_LAST_INDEX)
674 snd_printdd(" cmd[%d]=%x\n", i, data); 676 dev_dbg(&mgr->pci->dev,
677 " cmd[%d]=%x\n", i, data);
675#endif 678#endif
676 err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, 679 err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR,
677 PCXHR_ISR_HI08_TRDY, 680 PCXHR_ISR_HI08_TRDY,
@@ -697,14 +700,15 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh)
697 PCXHR_ISR_HI08_RXDF, 700 PCXHR_ISR_HI08_RXDF,
698 PCXHR_TIMEOUT_DSP, &reg); 701 PCXHR_TIMEOUT_DSP, &reg);
699 if (err) { 702 if (err) {
700 snd_printk(KERN_ERR "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg); 703 dev_err(&mgr->pci->dev,
704 "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg);
701 return err; 705 return err;
702 } 706 }
703 /* read error code */ 707 /* read error code */
704 data = PCXHR_INPB(mgr, PCXHR_DSP_TXH) << 16; 708 data = PCXHR_INPB(mgr, PCXHR_DSP_TXH) << 16;
705 data |= PCXHR_INPB(mgr, PCXHR_DSP_TXM) << 8; 709 data |= PCXHR_INPB(mgr, PCXHR_DSP_TXM) << 8;
706 data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL); 710 data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL);
707 snd_printk(KERN_ERR "ERROR RMH(%d): 0x%x\n", 711 dev_err(&mgr->pci->dev, "ERROR RMH(%d): 0x%x\n",
708 rmh->cmd_idx, data); 712 rmh->cmd_idx, data);
709 err = -EINVAL; 713 err = -EINVAL;
710 } else { 714 } else {
@@ -780,7 +784,7 @@ static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr)
780 * (PCXHR_PIPE_STATE_CAPTURE_OFFSET) 784 * (PCXHR_PIPE_STATE_CAPTURE_OFFSET)
781 */ 785 */
782 start_mask &= 0xffffff; 786 start_mask &= 0xffffff;
783 snd_printdd("CMD_PIPE_STATE MBOX2=0x%06x\n", start_mask); 787 dev_dbg(&mgr->pci->dev, "CMD_PIPE_STATE MBOX2=0x%06x\n", start_mask);
784 return start_mask; 788 return start_mask;
785} 789}
786 790
@@ -809,7 +813,7 @@ static int pcxhr_prepair_pipe_start(struct pcxhr_mgr *mgr,
809 } 813 }
810 err = pcxhr_send_msg(mgr, &rmh); 814 err = pcxhr_send_msg(mgr, &rmh);
811 if (err) { 815 if (err) {
812 snd_printk(KERN_ERR 816 dev_err(&mgr->pci->dev,
813 "error pipe start " 817 "error pipe start "
814 "(CMD_CAN_START_PIPE) err=%x!\n", 818 "(CMD_CAN_START_PIPE) err=%x!\n",
815 err); 819 err);
@@ -847,7 +851,7 @@ static int pcxhr_stop_pipes(struct pcxhr_mgr *mgr, int audio_mask)
847 } 851 }
848 err = pcxhr_send_msg(mgr, &rmh); 852 err = pcxhr_send_msg(mgr, &rmh);
849 if (err) { 853 if (err) {
850 snd_printk(KERN_ERR 854 dev_err(&mgr->pci->dev,
851 "error pipe stop " 855 "error pipe stop "
852 "(CMD_STOP_PIPE) err=%x!\n", err); 856 "(CMD_STOP_PIPE) err=%x!\n", err);
853 return err; 857 return err;
@@ -876,7 +880,7 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask)
876 1 << (audio - PCXHR_PIPE_STATE_CAPTURE_OFFSET)); 880 1 << (audio - PCXHR_PIPE_STATE_CAPTURE_OFFSET));
877 err = pcxhr_send_msg(mgr, &rmh); 881 err = pcxhr_send_msg(mgr, &rmh);
878 if (err) { 882 if (err) {
879 snd_printk(KERN_ERR 883 dev_err(&mgr->pci->dev,
880 "error pipe start " 884 "error pipe start "
881 "(CMD_CONF_PIPE) err=%x!\n", err); 885 "(CMD_CONF_PIPE) err=%x!\n", err);
882 return err; 886 return err;
@@ -889,7 +893,7 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask)
889 pcxhr_init_rmh(&rmh, CMD_SEND_IRQA); 893 pcxhr_init_rmh(&rmh, CMD_SEND_IRQA);
890 err = pcxhr_send_msg(mgr, &rmh); 894 err = pcxhr_send_msg(mgr, &rmh);
891 if (err) { 895 if (err) {
892 snd_printk(KERN_ERR 896 dev_err(&mgr->pci->dev,
893 "error pipe start (CMD_SEND_IRQA) err=%x!\n", 897 "error pipe start (CMD_SEND_IRQA) err=%x!\n",
894 err); 898 err);
895 return err; 899 return err;
@@ -913,7 +917,8 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
913 (capture_mask << PCXHR_PIPE_STATE_CAPTURE_OFFSET)); 917 (capture_mask << PCXHR_PIPE_STATE_CAPTURE_OFFSET));
914 /* current pipe state (playback + record) */ 918 /* current pipe state (playback + record) */
915 state = pcxhr_pipes_running(mgr); 919 state = pcxhr_pipes_running(mgr);
916 snd_printdd("pcxhr_set_pipe_state %s (mask %x current %x)\n", 920 dev_dbg(&mgr->pci->dev,
921 "pcxhr_set_pipe_state %s (mask %x current %x)\n",
917 start ? "START" : "STOP", audio_mask, state); 922 start ? "START" : "STOP", audio_mask, state);
918 if (start) { 923 if (start) {
919 /* start only pipes that are not yet started */ 924 /* start only pipes that are not yet started */
@@ -944,7 +949,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
944 if ((state & audio_mask) == (start ? audio_mask : 0)) 949 if ((state & audio_mask) == (start ? audio_mask : 0))
945 break; 950 break;
946 if (++i >= MAX_WAIT_FOR_DSP * 100) { 951 if (++i >= MAX_WAIT_FOR_DSP * 100) {
947 snd_printk(KERN_ERR "error pipe start/stop\n"); 952 dev_err(&mgr->pci->dev, "error pipe start/stop\n");
948 return -EBUSY; 953 return -EBUSY;
949 } 954 }
950 udelay(10); /* wait 10 microseconds */ 955 udelay(10); /* wait 10 microseconds */
@@ -956,7 +961,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask,
956 } 961 }
957#ifdef CONFIG_SND_DEBUG_VERBOSE 962#ifdef CONFIG_SND_DEBUG_VERBOSE
958 do_gettimeofday(&my_tv2); 963 do_gettimeofday(&my_tv2);
959 snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n", 964 dev_dbg(&mgr->pci->dev, "***SET PIPE STATE*** TIME = %ld (err = %x)\n",
960 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err); 965 (long)(my_tv2.tv_usec - my_tv1.tv_usec), err);
961#endif 966#endif
962 return 0; 967 return 0;
@@ -971,7 +976,8 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask,
971 976
972 spin_lock_irqsave(&mgr->msg_lock, flags); 977 spin_lock_irqsave(&mgr->msg_lock, flags);
973 if ((mgr->io_num_reg_cont & mask) == value) { 978 if ((mgr->io_num_reg_cont & mask) == value) {
974 snd_printdd("IO_NUM_REG_CONT mask %x already is set to %x\n", 979 dev_dbg(&mgr->pci->dev,
980 "IO_NUM_REG_CONT mask %x already is set to %x\n",
975 mask, value); 981 mask, value);
976 if (changed) 982 if (changed)
977 *changed = 0; 983 *changed = 0;
@@ -1024,7 +1030,7 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err,
1024 err = ((err >> 12) & 0xfff); 1030 err = ((err >> 12) & 0xfff);
1025 if (!err) 1031 if (!err)
1026 return 0; 1032 return 0;
1027 snd_printdd("CMD_ASYNC : Error %s %s Pipe %d err=%x\n", 1033 dev_dbg(&mgr->pci->dev, "CMD_ASYNC : Error %s %s Pipe %d err=%x\n",
1028 err_src_name[err_src], 1034 err_src_name[err_src],
1029 is_capture ? "Record" : "Play", pipe, err); 1035 is_capture ? "Record" : "Play", pipe, err);
1030 if (err == 0xe01) 1036 if (err == 0xe01)
@@ -1045,20 +1051,24 @@ void pcxhr_msg_tasklet(unsigned long arg)
1045 int i, j; 1051 int i, j;
1046 1052
1047 if (mgr->src_it_dsp & PCXHR_IRQ_FREQ_CHANGE) 1053 if (mgr->src_it_dsp & PCXHR_IRQ_FREQ_CHANGE)
1048 snd_printdd("TASKLET : PCXHR_IRQ_FREQ_CHANGE event occurred\n"); 1054 dev_dbg(&mgr->pci->dev,
1055 "TASKLET : PCXHR_IRQ_FREQ_CHANGE event occurred\n");
1049 if (mgr->src_it_dsp & PCXHR_IRQ_TIME_CODE) 1056 if (mgr->src_it_dsp & PCXHR_IRQ_TIME_CODE)
1050 snd_printdd("TASKLET : PCXHR_IRQ_TIME_CODE event occurred\n"); 1057 dev_dbg(&mgr->pci->dev,
1058 "TASKLET : PCXHR_IRQ_TIME_CODE event occurred\n");
1051 if (mgr->src_it_dsp & PCXHR_IRQ_NOTIFY) 1059 if (mgr->src_it_dsp & PCXHR_IRQ_NOTIFY)
1052 snd_printdd("TASKLET : PCXHR_IRQ_NOTIFY event occurred\n"); 1060 dev_dbg(&mgr->pci->dev,
1061 "TASKLET : PCXHR_IRQ_NOTIFY event occurred\n");
1053 if (mgr->src_it_dsp & (PCXHR_IRQ_FREQ_CHANGE | PCXHR_IRQ_TIME_CODE)) { 1062 if (mgr->src_it_dsp & (PCXHR_IRQ_FREQ_CHANGE | PCXHR_IRQ_TIME_CODE)) {
1054 /* clear events FREQ_CHANGE and TIME_CODE */ 1063 /* clear events FREQ_CHANGE and TIME_CODE */
1055 pcxhr_init_rmh(prmh, CMD_TEST_IT); 1064 pcxhr_init_rmh(prmh, CMD_TEST_IT);
1056 err = pcxhr_send_msg(mgr, prmh); 1065 err = pcxhr_send_msg(mgr, prmh);
1057 snd_printdd("CMD_TEST_IT : err=%x, stat=%x\n", 1066 dev_dbg(&mgr->pci->dev, "CMD_TEST_IT : err=%x, stat=%x\n",
1058 err, prmh->stat[0]); 1067 err, prmh->stat[0]);
1059 } 1068 }
1060 if (mgr->src_it_dsp & PCXHR_IRQ_ASYNC) { 1069 if (mgr->src_it_dsp & PCXHR_IRQ_ASYNC) {
1061 snd_printdd("TASKLET : PCXHR_IRQ_ASYNC event occurred\n"); 1070 dev_dbg(&mgr->pci->dev,
1071 "TASKLET : PCXHR_IRQ_ASYNC event occurred\n");
1062 1072
1063 pcxhr_init_rmh(prmh, CMD_ASYNC); 1073 pcxhr_init_rmh(prmh, CMD_ASYNC);
1064 prmh->cmd[0] |= 1; /* add SEL_ASYNC_EVENTS */ 1074 prmh->cmd[0] |= 1; /* add SEL_ASYNC_EVENTS */
@@ -1066,7 +1076,7 @@ void pcxhr_msg_tasklet(unsigned long arg)
1066 prmh->stat_len = PCXHR_SIZE_MAX_LONG_STATUS; 1076 prmh->stat_len = PCXHR_SIZE_MAX_LONG_STATUS;
1067 err = pcxhr_send_msg(mgr, prmh); 1077 err = pcxhr_send_msg(mgr, prmh);
1068 if (err) 1078 if (err)
1069 snd_printk(KERN_ERR "ERROR pcxhr_msg_tasklet=%x;\n", 1079 dev_err(&mgr->pci->dev, "ERROR pcxhr_msg_tasklet=%x;\n",
1070 err); 1080 err);
1071 i = 1; 1081 i = 1;
1072 while (i < prmh->stat_len) { 1082 while (i < prmh->stat_len) {
@@ -1079,7 +1089,8 @@ void pcxhr_msg_tasklet(unsigned long arg)
1079 u32 err2; 1089 u32 err2;
1080 1090
1081 if (prmh->stat[i] & 0x800000) { /* if BIT_END */ 1091 if (prmh->stat[i] & 0x800000) { /* if BIT_END */
1082 snd_printdd("TASKLET : End%sPipe %d\n", 1092 dev_dbg(&mgr->pci->dev,
1093 "TASKLET : End%sPipe %d\n",
1083 is_capture ? "Record" : "Play", 1094 is_capture ? "Record" : "Play",
1084 pipe); 1095 pipe);
1085 } 1096 }
@@ -1136,7 +1147,8 @@ static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr,
1136 hw_sample_count = ((u_int64_t)rmh.stat[0]) << 24; 1147 hw_sample_count = ((u_int64_t)rmh.stat[0]) << 24;
1137 hw_sample_count += (u_int64_t)rmh.stat[1]; 1148 hw_sample_count += (u_int64_t)rmh.stat[1];
1138 1149
1139 snd_printdd("stream %c%d : abs samples real(%llu) timer(%llu)\n", 1150 dev_dbg(&mgr->pci->dev,
1151 "stream %c%d : abs samples real(%llu) timer(%llu)\n",
1140 stream->pipe->is_capture ? 'C' : 'P', 1152 stream->pipe->is_capture ? 'C' : 'P',
1141 stream->substream->number, 1153 stream->substream->number,
1142 hw_sample_count, 1154 hw_sample_count,
@@ -1202,7 +1214,7 @@ static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr,
1202 (u_int32_t)(new_sample_count - 1214 (u_int32_t)(new_sample_count -
1203 stream->timer_abs_periods); 1215 stream->timer_abs_periods);
1204 } else { 1216 } else {
1205 snd_printk(KERN_ERR 1217 dev_err(&mgr->pci->dev,
1206 "ERROR new_sample_count too small ??? %ld\n", 1218 "ERROR new_sample_count too small ??? %ld\n",
1207 (long unsigned int)new_sample_count); 1219 (long unsigned int)new_sample_count);
1208 } 1220 }
@@ -1247,33 +1259,39 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
1247 (mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID)) { 1259 (mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID)) {
1248 /* handle dsp counter wraparound without resync */ 1260 /* handle dsp counter wraparound without resync */
1249 int tmp_diff = dsp_time_diff + PCXHR_DSP_TIME_MASK + 1; 1261 int tmp_diff = dsp_time_diff + PCXHR_DSP_TIME_MASK + 1;
1250 snd_printdd("WARNING DSP timestamp old(%d) new(%d)", 1262 dev_dbg(&mgr->pci->dev,
1263 "WARNING DSP timestamp old(%d) new(%d)",
1251 mgr->dsp_time_last, dsp_time_new); 1264 mgr->dsp_time_last, dsp_time_new);
1252 if (tmp_diff > 0 && tmp_diff <= (2*mgr->granularity)) { 1265 if (tmp_diff > 0 && tmp_diff <= (2*mgr->granularity)) {
1253 snd_printdd("-> timestamp wraparound OK: " 1266 dev_dbg(&mgr->pci->dev,
1267 "-> timestamp wraparound OK: "
1254 "diff=%d\n", tmp_diff); 1268 "diff=%d\n", tmp_diff);
1255 dsp_time_diff = tmp_diff; 1269 dsp_time_diff = tmp_diff;
1256 } else { 1270 } else {
1257 snd_printdd("-> resynchronize all streams\n"); 1271 dev_dbg(&mgr->pci->dev,
1272 "-> resynchronize all streams\n");
1258 mgr->dsp_time_err++; 1273 mgr->dsp_time_err++;
1259 } 1274 }
1260 } 1275 }
1261#ifdef CONFIG_SND_DEBUG_VERBOSE 1276#ifdef CONFIG_SND_DEBUG_VERBOSE
1262 if (dsp_time_diff == 0) 1277 if (dsp_time_diff == 0)
1263 snd_printdd("ERROR DSP TIME NO DIFF time(%d)\n", 1278 dev_dbg(&mgr->pci->dev,
1279 "ERROR DSP TIME NO DIFF time(%d)\n",
1264 dsp_time_new); 1280 dsp_time_new);
1265 else if (dsp_time_diff >= (2*mgr->granularity)) 1281 else if (dsp_time_diff >= (2*mgr->granularity))
1266 snd_printdd("ERROR DSP TIME TOO BIG old(%d) add(%d)\n", 1282 dev_dbg(&mgr->pci->dev,
1283 "ERROR DSP TIME TOO BIG old(%d) add(%d)\n",
1267 mgr->dsp_time_last, 1284 mgr->dsp_time_last,
1268 dsp_time_new - mgr->dsp_time_last); 1285 dsp_time_new - mgr->dsp_time_last);
1269 else if (dsp_time_diff % mgr->granularity) 1286 else if (dsp_time_diff % mgr->granularity)
1270 snd_printdd("ERROR DSP TIME increased by %d\n", 1287 dev_dbg(&mgr->pci->dev,
1288 "ERROR DSP TIME increased by %d\n",
1271 dsp_time_diff); 1289 dsp_time_diff);
1272#endif 1290#endif
1273 mgr->dsp_time_last = dsp_time_new; 1291 mgr->dsp_time_last = dsp_time_new;
1274 1292
1275 if (timer_toggle == mgr->timer_toggle) { 1293 if (timer_toggle == mgr->timer_toggle) {
1276 snd_printdd("ERROR TIMER TOGGLE\n"); 1294 dev_dbg(&mgr->pci->dev, "ERROR TIMER TOGGLE\n");
1277 mgr->dsp_time_err++; 1295 mgr->dsp_time_err++;
1278 } 1296 }
1279 mgr->timer_toggle = timer_toggle; 1297 mgr->timer_toggle = timer_toggle;
@@ -1308,7 +1326,7 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id)
1308 } 1326 }
1309#ifdef CONFIG_SND_DEBUG_VERBOSE 1327#ifdef CONFIG_SND_DEBUG_VERBOSE
1310 if (reg & PCXHR_FATAL_DSP_ERR) 1328 if (reg & PCXHR_FATAL_DSP_ERR)
1311 snd_printdd("FATAL DSP ERROR : %x\n", reg); 1329 dev_dbg(&mgr->pci->dev, "FATAL DSP ERROR : %x\n", reg);
1312#endif 1330#endif
1313 spin_unlock(&mgr->lock); 1331 spin_unlock(&mgr->lock);
1314 return IRQ_HANDLED; /* this device caused the interrupt */ 1332 return IRQ_HANDLED; /* this device caused the interrupt */
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c
index d995175c1c48..15a8ce5f1f48 100644
--- a/sound/pci/pcxhr/pcxhr_hwdep.c
+++ b/sound/pci/pcxhr/pcxhr_hwdep.c
@@ -72,7 +72,8 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
72 /* test max nb substream per pipe */ 72 /* test max nb substream per pipe */
73 if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS) 73 if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS)
74 return -EINVAL; 74 return -EINVAL;
75 snd_printdd("supported formats : playback=%x capture=%x\n", 75 dev_dbg(&mgr->pci->dev,
76 "supported formats : playback=%x capture=%x\n",
76 rmh.stat[2], rmh.stat[3]); 77 rmh.stat[2], rmh.stat[3]);
77 78
78 pcxhr_init_rmh(&rmh, CMD_VERSION); 79 pcxhr_init_rmh(&rmh, CMD_VERSION);
@@ -84,7 +85,8 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr)
84 err = pcxhr_send_msg(mgr, &rmh); 85 err = pcxhr_send_msg(mgr, &rmh);
85 if (err) 86 if (err)
86 return err; 87 return err;
87 snd_printdd("PCXHR DSP version is %d.%d.%d\n", (rmh.stat[0]>>16)&0xff, 88 dev_dbg(&mgr->pci->dev,
89 "PCXHR DSP version is %d.%d.%d\n", (rmh.stat[0]>>16)&0xff,
88 (rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff); 90 (rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff);
89 mgr->dsp_version = rmh.stat[0]; 91 mgr->dsp_version = rmh.stat[0];
90 92
@@ -179,7 +181,7 @@ static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr,
179 stream_count = PCXHR_PLAYBACK_STREAMS; 181 stream_count = PCXHR_PLAYBACK_STREAMS;
180 audio_count = 2; /* always stereo */ 182 audio_count = 2; /* always stereo */
181 } 183 }
182 snd_printdd("snd_add_ref_pipe pin(%d) pcm%c0\n", 184 dev_dbg(&mgr->pci->dev, "snd_add_ref_pipe pin(%d) pcm%c0\n",
183 pin, is_capture ? 'c' : 'p'); 185 pin, is_capture ? 'c' : 'p');
184 pipe->is_capture = is_capture; 186 pipe->is_capture = is_capture;
185 pipe->first_audio = pin; 187 pipe->first_audio = pin;
@@ -194,7 +196,7 @@ static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr,
194 } 196 }
195 err = pcxhr_send_msg(mgr, &rmh); 197 err = pcxhr_send_msg(mgr, &rmh);
196 if (err < 0) { 198 if (err < 0) {
197 snd_printk(KERN_ERR "error pipe allocation " 199 dev_err(&mgr->pci->dev, "error pipe allocation "
198 "(CMD_RES_PIPE) err=%x!\n", err); 200 "(CMD_RES_PIPE) err=%x!\n", err);
199 return err; 201 return err;
200 } 202 }
@@ -222,14 +224,14 @@ static int pcxhr_dsp_free_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe)
222 /* stop one pipe */ 224 /* stop one pipe */
223 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); 225 err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0);
224 if (err < 0) 226 if (err < 0)
225 snd_printk(KERN_ERR "error stopping pipe!\n"); 227 dev_err(&mgr->pci->dev, "error stopping pipe!\n");
226 /* release the pipe */ 228 /* release the pipe */
227 pcxhr_init_rmh(&rmh, CMD_FREE_PIPE); 229 pcxhr_init_rmh(&rmh, CMD_FREE_PIPE);
228 pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio, 230 pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio,
229 0, 0); 231 0, 0);
230 err = pcxhr_send_msg(mgr, &rmh); 232 err = pcxhr_send_msg(mgr, &rmh);
231 if (err < 0) 233 if (err < 0)
232 snd_printk(KERN_ERR "error pipe release " 234 dev_err(&mgr->pci->dev, "error pipe release "
233 "(CMD_FREE_PIPE) err(%x)\n", err); 235 "(CMD_FREE_PIPE) err(%x)\n", err);
234 pipe->status = PCXHR_PIPE_UNDEFINED; 236 pipe->status = PCXHR_PIPE_UNDEFINED;
235 return err; 237 return err;
@@ -289,7 +291,8 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
289{ 291{
290 int err, card_index; 292 int err, card_index;
291 293
292 snd_printdd("loading dsp [%d] size = %Zd\n", index, dsp->size); 294 dev_dbg(&mgr->pci->dev,
295 "loading dsp [%d] size = %Zd\n", index, dsp->size);
293 296
294 switch (index) { 297 switch (index) {
295 case PCXHR_FIRMWARE_XLX_INT_INDEX: 298 case PCXHR_FIRMWARE_XLX_INT_INDEX:
@@ -313,19 +316,19 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
313 return err; 316 return err;
314 break; /* continue with first init */ 317 break; /* continue with first init */
315 default: 318 default:
316 snd_printk(KERN_ERR "wrong file index\n"); 319 dev_err(&mgr->pci->dev, "wrong file index\n");
317 return -EFAULT; 320 return -EFAULT;
318 } /* end of switch file index*/ 321 } /* end of switch file index*/
319 322
320 /* first communication with embedded */ 323 /* first communication with embedded */
321 err = pcxhr_init_board(mgr); 324 err = pcxhr_init_board(mgr);
322 if (err < 0) { 325 if (err < 0) {
323 snd_printk(KERN_ERR "pcxhr could not be set up\n"); 326 dev_err(&mgr->pci->dev, "pcxhr could not be set up\n");
324 return err; 327 return err;
325 } 328 }
326 err = pcxhr_config_pipes(mgr); 329 err = pcxhr_config_pipes(mgr);
327 if (err < 0) { 330 if (err < 0) {
328 snd_printk(KERN_ERR "pcxhr pipes could not be set up\n"); 331 dev_err(&mgr->pci->dev, "pcxhr pipes could not be set up\n");
329 return err; 332 return err;
330 } 333 }
331 /* create devices and mixer in accordance with HW options*/ 334 /* create devices and mixer in accordance with HW options*/
@@ -344,10 +347,11 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index,
344 } 347 }
345 err = pcxhr_start_pipes(mgr); 348 err = pcxhr_start_pipes(mgr);
346 if (err < 0) { 349 if (err < 0) {
347 snd_printk(KERN_ERR "pcxhr pipes could not be started\n"); 350 dev_err(&mgr->pci->dev, "pcxhr pipes could not be started\n");
348 return err; 351 return err;
349 } 352 }
350 snd_printdd("pcxhr firmware downloaded and successfully set up\n"); 353 dev_dbg(&mgr->pci->dev,
354 "pcxhr firmware downloaded and successfully set up\n");
351 355
352 return 0; 356 return 0;
353} 357}
@@ -382,7 +386,8 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr)
382 continue; 386 continue;
383 sprintf(path, "pcxhr/%s", fw_files[fw_set][i]); 387 sprintf(path, "pcxhr/%s", fw_files[fw_set][i]);
384 if (request_firmware(&fw_entry, path, &mgr->pci->dev)) { 388 if (request_firmware(&fw_entry, path, &mgr->pci->dev)) {
385 snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n", 389 dev_err(&mgr->pci->dev,
390 "pcxhr: can't load firmware %s\n",
386 path); 391 path);
387 return -ENOENT; 392 return -ENOENT;
388 } 393 }
diff --git a/sound/pci/pcxhr/pcxhr_mix22.c b/sound/pci/pcxhr/pcxhr_mix22.c
index 84fe57626eba..6a56e5306a65 100644
--- a/sound/pci/pcxhr/pcxhr_mix22.c
+++ b/sound/pci/pcxhr/pcxhr_mix22.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/pci.h>
25#include <sound/core.h> 26#include <sound/core.h>
26#include <sound/control.h> 27#include <sound/control.h>
27#include <sound/tlv.h> 28#include <sound/tlv.h>
@@ -290,7 +291,8 @@ int hr222_sub_init(struct pcxhr_mgr *mgr)
290 reg = PCXHR_INPB(mgr, PCXHR_XLX_STATUS); 291 reg = PCXHR_INPB(mgr, PCXHR_XLX_STATUS);
291 if (reg & PCXHR_STAT_MIC_CAPS) 292 if (reg & PCXHR_STAT_MIC_CAPS)
292 mgr->board_has_mic = 1; /* microphone available */ 293 mgr->board_has_mic = 1; /* microphone available */
293 snd_printdd("MIC input available = %d\n", mgr->board_has_mic); 294 dev_dbg(&mgr->pci->dev,
295 "MIC input available = %d\n", mgr->board_has_mic);
294 296
295 /* reset codec */ 297 /* reset codec */
296 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, 298 PCXHR_OUTPB(mgr, PCXHR_DSP_RESET,
@@ -405,7 +407,7 @@ int hr222_sub_set_clock(struct pcxhr_mgr *mgr,
405 407
406 hr222_config_akm(mgr, AKM_UNMUTE_CMD); 408 hr222_config_akm(mgr, AKM_UNMUTE_CMD);
407 409
408 snd_printdd("set_clock to %dHz (realfreq=%d pllreg=%x)\n", 410 dev_dbg(&mgr->pci->dev, "set_clock to %dHz (realfreq=%d pllreg=%x)\n",
409 rate, realfreq, pllreg); 411 rate, realfreq, pllreg);
410 return 0; 412 return 0;
411} 413}
@@ -431,13 +433,15 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
431 reg = PCXHR_STAT_FREQ_UER1_MASK; 433 reg = PCXHR_STAT_FREQ_UER1_MASK;
432 434
433 } else { 435 } else {
434 snd_printdd("get_external_clock : type %d not supported\n", 436 dev_dbg(&mgr->pci->dev,
437 "get_external_clock : type %d not supported\n",
435 clock_type); 438 clock_type);
436 return -EINVAL; /* other clocks not supported */ 439 return -EINVAL; /* other clocks not supported */
437 } 440 }
438 441
439 if ((PCXHR_INPB(mgr, PCXHR_XLX_CSUER) & mask) != mask) { 442 if ((PCXHR_INPB(mgr, PCXHR_XLX_CSUER) & mask) != mask) {
440 snd_printdd("get_external_clock(%d) = 0 Hz\n", clock_type); 443 dev_dbg(&mgr->pci->dev,
444 "get_external_clock(%d) = 0 Hz\n", clock_type);
441 *sample_rate = 0; 445 *sample_rate = 0;
442 return 0; /* no external clock locked */ 446 return 0; /* no external clock locked */
443 } 447 }
@@ -495,7 +499,7 @@ int hr222_get_external_clock(struct pcxhr_mgr *mgr,
495 else 499 else
496 rate = 0; 500 rate = 0;
497 501
498 snd_printdd("External clock is at %d Hz (measured %d Hz)\n", 502 dev_dbg(&mgr->pci->dev, "External clock is at %d Hz (measured %d Hz)\n",
499 rate, calc_rate); 503 rate, calc_rate);
500 *sample_rate = rate; 504 *sample_rate = rate;
501 return 0; 505 return 0;
@@ -542,7 +546,8 @@ int hr222_manage_timecode(struct pcxhr_mgr *mgr, int enable)
542int hr222_update_analog_audio_level(struct snd_pcxhr *chip, 546int hr222_update_analog_audio_level(struct snd_pcxhr *chip,
543 int is_capture, int channel) 547 int is_capture, int channel)
544{ 548{
545 snd_printdd("hr222_update_analog_audio_level(%s chan=%d)\n", 549 dev_dbg(chip->card->dev,
550 "hr222_update_analog_audio_level(%s chan=%d)\n",
546 is_capture ? "capture" : "playback", channel); 551 is_capture ? "capture" : "playback", channel);
547 if (is_capture) { 552 if (is_capture) {
548 int level_l, level_r, level_mic; 553 int level_l, level_r, level_mic;
@@ -642,7 +647,7 @@ int hr222_iec958_capture_byte(struct snd_pcxhr *chip,
642 if (PCXHR_INPB(chip->mgr, PCXHR_XLX_CSUER) & mask) 647 if (PCXHR_INPB(chip->mgr, PCXHR_XLX_CSUER) & mask)
643 temp |= 1; 648 temp |= 1;
644 } 649 }
645 snd_printdd("read iec958 AES %d byte %d = 0x%x\n", 650 dev_dbg(chip->card->dev, "read iec958 AES %d byte %d = 0x%x\n",
646 chip->chip_idx, aes_idx, temp); 651 chip->chip_idx, aes_idx, temp);
647 *aes_bits = temp; 652 *aes_bits = temp;
648 return 0; 653 return 0;
@@ -684,7 +689,7 @@ static void hr222_micro_boost(struct pcxhr_mgr *mgr, int level)
684 689
685 PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic); 690 PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic);
686 691
687 snd_printdd("hr222_micro_boost : set %x\n", boost_mask); 692 dev_dbg(&mgr->pci->dev, "hr222_micro_boost : set %x\n", boost_mask);
688} 693}
689 694
690static void hr222_phantom_power(struct pcxhr_mgr *mgr, int power) 695static void hr222_phantom_power(struct pcxhr_mgr *mgr, int power)
@@ -696,7 +701,7 @@ static void hr222_phantom_power(struct pcxhr_mgr *mgr, int power)
696 701
697 PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic); 702 PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic);
698 703
699 snd_printdd("hr222_phantom_power : set %d\n", power); 704 dev_dbg(&mgr->pci->dev, "hr222_phantom_power : set %d\n", power);
700} 705}
701 706
702 707
diff --git a/sound/pci/pcxhr/pcxhr_mixer.c b/sound/pci/pcxhr/pcxhr_mixer.c
index fec049344621..95c9571780d8 100644
--- a/sound/pci/pcxhr/pcxhr_mixer.c
+++ b/sound/pci/pcxhr/pcxhr_mixer.c
@@ -72,7 +72,8 @@ static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip,
72 rmh.cmd_len = 3; 72 rmh.cmd_len = 3;
73 err = pcxhr_send_msg(chip->mgr, &rmh); 73 err = pcxhr_send_msg(chip->mgr, &rmh);
74 if (err < 0) { 74 if (err < 0) {
75 snd_printk(KERN_DEBUG "error update_analog_audio_level card(%d)" 75 dev_dbg(chip->card->dev,
76 "error update_analog_audio_level card(%d)"
76 " is_capture(%d) err(%x)\n", 77 " is_capture(%d) err(%x)\n",
77 chip->chip_idx, is_capture, err); 78 chip->chip_idx, is_capture, err);
78 return -EINVAL; 79 return -EINVAL;
@@ -284,7 +285,7 @@ static int pcxhr_update_playback_stream_level(struct snd_pcxhr* chip, int idx)
284 285
285 err = pcxhr_send_msg(chip->mgr, &rmh); 286 err = pcxhr_send_msg(chip->mgr, &rmh);
286 if (err < 0) { 287 if (err < 0) {
287 snd_printk(KERN_DEBUG "error update_playback_stream_level " 288 dev_dbg(chip->card->dev, "error update_playback_stream_level "
288 "card(%d) err(%x)\n", chip->chip_idx, err); 289 "card(%d) err(%x)\n", chip->chip_idx, err);
289 return -EINVAL; 290 return -EINVAL;
290 } 291 }
@@ -335,7 +336,8 @@ static int pcxhr_update_audio_pipe_level(struct snd_pcxhr *chip,
335 336
336 err = pcxhr_send_msg(chip->mgr, &rmh); 337 err = pcxhr_send_msg(chip->mgr, &rmh);
337 if (err < 0) { 338 if (err < 0) {
338 snd_printk(KERN_DEBUG "error update_audio_level(%d) err=%x\n", 339 dev_dbg(chip->card->dev,
340 "error update_audio_level(%d) err=%x\n",
339 chip->chip_idx, err); 341 chip->chip_idx, err);
340 return -EINVAL; 342 return -EINVAL;
341 } 343 }
@@ -930,7 +932,7 @@ static int pcxhr_iec958_capture_byte(struct snd_pcxhr *chip,
930 temp |= 1; 932 temp |= 1;
931 } 933 }
932 } 934 }
933 snd_printdd("read iec958 AES %d byte %d = 0x%x\n", 935 dev_dbg(chip->card->dev, "read iec958 AES %d byte %d = 0x%x\n",
934 chip->chip_idx, aes_idx, temp); 936 chip->chip_idx, aes_idx, temp);
935 *aes_bits = temp; 937 *aes_bits = temp;
936 return 0; 938 return 0;
@@ -992,7 +994,8 @@ static int pcxhr_iec958_update_byte(struct snd_pcxhr *chip,
992 rmh.cmd[0] |= IO_NUM_REG_CUER; 994 rmh.cmd[0] |= IO_NUM_REG_CUER;
993 rmh.cmd[1] = cmd; 995 rmh.cmd[1] = cmd;
994 rmh.cmd_len = 2; 996 rmh.cmd_len = 2;
995 snd_printdd("write iec958 AES %d byte %d bit %d (cmd %x)\n", 997 dev_dbg(chip->card->dev,
998 "write iec958 AES %d byte %d bit %d (cmd %x)\n",
996 chip->chip_idx, aes_idx, i, cmd); 999 chip->chip_idx, aes_idx, i, cmd);
997 err = pcxhr_send_msg(chip->mgr, &rmh); 1000 err = pcxhr_send_msg(chip->mgr, &rmh);
998 if (err) 1001 if (err)
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 56cc891e395e..b4a8278241b1 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -1916,8 +1916,6 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
1916 return err; 1916 return err;
1917 } 1917 }
1918 1918
1919 snd_card_set_dev(card, &pci->dev);
1920
1921 *rchip = chip; 1919 *rchip = chip;
1922 return 0; 1920 return 0;
1923} 1921}
@@ -2086,7 +2084,8 @@ snd_card_riptide_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
2086 return -ENOENT; 2084 return -ENOENT;
2087 } 2085 }
2088 2086
2089 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 2087 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2088 0, &card);
2090 if (err < 0) 2089 if (err < 0)
2091 return err; 2090 return err;
2092 err = snd_riptide_create(card, pci, &chip); 2091 err = snd_riptide_create(card, pci, &chip);
diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c
index cc26346ae66b..cc2f0c1b6484 100644
--- a/sound/pci/rme32.c
+++ b/sound/pci/rme32.c
@@ -1349,14 +1349,15 @@ static int snd_rme32_create(struct rme32 *rme32)
1349 1349
1350 rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE); 1350 rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE);
1351 if (!rme32->iobase) { 1351 if (!rme32->iobase) {
1352 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", 1352 dev_err(rme32->card->dev,
1353 "unable to remap memory region 0x%lx-0x%lx\n",
1353 rme32->port, rme32->port + RME32_IO_SIZE - 1); 1354 rme32->port, rme32->port + RME32_IO_SIZE - 1);
1354 return -ENOMEM; 1355 return -ENOMEM;
1355 } 1356 }
1356 1357
1357 if (request_irq(pci->irq, snd_rme32_interrupt, IRQF_SHARED, 1358 if (request_irq(pci->irq, snd_rme32_interrupt, IRQF_SHARED,
1358 KBUILD_MODNAME, rme32)) { 1359 KBUILD_MODNAME, rme32)) {
1359 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1360 dev_err(rme32->card->dev, "unable to grab IRQ %d\n", pci->irq);
1360 return -EBUSY; 1361 return -EBUSY;
1361 } 1362 }
1362 rme32->irq = pci->irq; 1363 rme32->irq = pci->irq;
@@ -1938,15 +1939,14 @@ snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
1938 return -ENOENT; 1939 return -ENOENT;
1939 } 1940 }
1940 1941
1941 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 1942 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1942 sizeof(struct rme32), &card); 1943 sizeof(struct rme32), &card);
1943 if (err < 0) 1944 if (err < 0)
1944 return err; 1945 return err;
1945 card->private_free = snd_rme32_card_free; 1946 card->private_free = snd_rme32_card_free;
1946 rme32 = (struct rme32 *) card->private_data; 1947 rme32 = (struct rme32 *) card->private_data;
1947 rme32->card = card; 1948 rme32->card = card;
1948 rme32->pci = pci; 1949 rme32->pci = pci;
1949 snd_card_set_dev(card, &pci->dev);
1950 if (fullduplex[dev]) 1950 if (fullduplex[dev])
1951 rme32->fullduplex_mode = 1; 1951 rme32->fullduplex_mode = 1;
1952 if ((err = snd_rme32_create(rme32)) < 0) { 1952 if ((err = snd_rme32_create(rme32)) < 0) {
diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c
index 0236363c301f..76169929770d 100644
--- a/sound/pci/rme96.c
+++ b/sound/pci/rme96.c
@@ -240,7 +240,7 @@ struct rme96 {
240 240
241 u8 rev; /* card revision number */ 241 u8 rev; /* card revision number */
242 242
243#ifdef CONFIG_PM 243#ifdef CONFIG_PM_SLEEP
244 u32 playback_pointer; 244 u32 playback_pointer;
245 u32 capture_pointer; 245 u32 capture_pointer;
246 void *playback_suspend_buffer; 246 void *playback_suspend_buffer;
@@ -1570,7 +1570,7 @@ snd_rme96_free(void *private_data)
1570 pci_release_regions(rme96->pci); 1570 pci_release_regions(rme96->pci);
1571 rme96->port = 0; 1571 rme96->port = 0;
1572 } 1572 }
1573#ifdef CONFIG_PM 1573#ifdef CONFIG_PM_SLEEP
1574 vfree(rme96->playback_suspend_buffer); 1574 vfree(rme96->playback_suspend_buffer);
1575 vfree(rme96->capture_suspend_buffer); 1575 vfree(rme96->capture_suspend_buffer);
1576#endif 1576#endif
@@ -1609,13 +1609,15 @@ snd_rme96_create(struct rme96 *rme96)
1609 1609
1610 rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE); 1610 rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE);
1611 if (!rme96->iobase) { 1611 if (!rme96->iobase) {
1612 snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1); 1612 dev_err(rme96->card->dev,
1613 "unable to remap memory region 0x%lx-0x%lx\n",
1614 rme96->port, rme96->port + RME96_IO_SIZE - 1);
1613 return -ENOMEM; 1615 return -ENOMEM;
1614 } 1616 }
1615 1617
1616 if (request_irq(pci->irq, snd_rme96_interrupt, IRQF_SHARED, 1618 if (request_irq(pci->irq, snd_rme96_interrupt, IRQF_SHARED,
1617 KBUILD_MODNAME, rme96)) { 1619 KBUILD_MODNAME, rme96)) {
1618 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1620 dev_err(rme96->card->dev, "unable to grab IRQ %d\n", pci->irq);
1619 return -EBUSY; 1621 return -EBUSY;
1620 } 1622 }
1621 rme96->irq = pci->irq; 1623 rme96->irq = pci->irq;
@@ -2372,13 +2374,12 @@ snd_rme96_create_switches(struct snd_card *card,
2372 * Card initialisation 2374 * Card initialisation
2373 */ 2375 */
2374 2376
2375#ifdef CONFIG_PM 2377#ifdef CONFIG_PM_SLEEP
2376 2378
2377static int 2379static int rme96_suspend(struct device *dev)
2378snd_rme96_suspend(struct pci_dev *pci,
2379 pm_message_t state)
2380{ 2380{
2381 struct snd_card *card = pci_get_drvdata(pci); 2381 struct pci_dev *pci = to_pci_dev(dev);
2382 struct snd_card *card = dev_get_drvdata(dev);
2382 struct rme96 *rme96 = card->private_data; 2383 struct rme96 *rme96 = card->private_data;
2383 2384
2384 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 2385 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
@@ -2407,15 +2408,15 @@ snd_rme96_suspend(struct pci_dev *pci,
2407 return 0; 2408 return 0;
2408} 2409}
2409 2410
2410static int 2411static int rme96_resume(struct device *dev)
2411snd_rme96_resume(struct pci_dev *pci)
2412{ 2412{
2413 struct snd_card *card = pci_get_drvdata(pci); 2413 struct pci_dev *pci = to_pci_dev(dev);
2414 struct snd_card *card = dev_get_drvdata(dev);
2414 struct rme96 *rme96 = card->private_data; 2415 struct rme96 *rme96 = card->private_data;
2415 2416
2416 pci_restore_state(pci); 2417 pci_restore_state(pci);
2417 if (pci_enable_device(pci) < 0) { 2418 if (pci_enable_device(pci) < 0) {
2418 printk(KERN_ERR "rme96: pci_enable_device failed, disabling device\n"); 2419 dev_err(dev, "pci_enable_device failed, disabling device\n");
2419 snd_card_disconnect(card); 2420 snd_card_disconnect(card);
2420 return -EIO; 2421 return -EIO;
2421 } 2422 }
@@ -2451,7 +2452,11 @@ snd_rme96_resume(struct pci_dev *pci)
2451 return 0; 2452 return 0;
2452} 2453}
2453 2454
2454#endif 2455static SIMPLE_DEV_PM_OPS(rme96_pm, rme96_suspend, rme96_resume);
2456#define RME96_PM_OPS &rme96_pm
2457#else
2458#define RME96_PM_OPS NULL
2459#endif /* CONFIG_PM_SLEEP */
2455 2460
2456static void snd_rme96_card_free(struct snd_card *card) 2461static void snd_rme96_card_free(struct snd_card *card)
2457{ 2462{
@@ -2475,31 +2480,30 @@ snd_rme96_probe(struct pci_dev *pci,
2475 dev++; 2480 dev++;
2476 return -ENOENT; 2481 return -ENOENT;
2477 } 2482 }
2478 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 2483 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2479 sizeof(struct rme96), &card); 2484 sizeof(struct rme96), &card);
2480 if (err < 0) 2485 if (err < 0)
2481 return err; 2486 return err;
2482 card->private_free = snd_rme96_card_free; 2487 card->private_free = snd_rme96_card_free;
2483 rme96 = card->private_data; 2488 rme96 = card->private_data;
2484 rme96->card = card; 2489 rme96->card = card;
2485 rme96->pci = pci; 2490 rme96->pci = pci;
2486 snd_card_set_dev(card, &pci->dev);
2487 if ((err = snd_rme96_create(rme96)) < 0) { 2491 if ((err = snd_rme96_create(rme96)) < 0) {
2488 snd_card_free(card); 2492 snd_card_free(card);
2489 return err; 2493 return err;
2490 } 2494 }
2491 2495
2492#ifdef CONFIG_PM 2496#ifdef CONFIG_PM_SLEEP
2493 rme96->playback_suspend_buffer = vmalloc(RME96_BUFFER_SIZE); 2497 rme96->playback_suspend_buffer = vmalloc(RME96_BUFFER_SIZE);
2494 if (!rme96->playback_suspend_buffer) { 2498 if (!rme96->playback_suspend_buffer) {
2495 snd_printk(KERN_ERR 2499 dev_err(card->dev,
2496 "Failed to allocate playback suspend buffer!\n"); 2500 "Failed to allocate playback suspend buffer!\n");
2497 snd_card_free(card); 2501 snd_card_free(card);
2498 return -ENOMEM; 2502 return -ENOMEM;
2499 } 2503 }
2500 rme96->capture_suspend_buffer = vmalloc(RME96_BUFFER_SIZE); 2504 rme96->capture_suspend_buffer = vmalloc(RME96_BUFFER_SIZE);
2501 if (!rme96->capture_suspend_buffer) { 2505 if (!rme96->capture_suspend_buffer) {
2502 snd_printk(KERN_ERR 2506 dev_err(card->dev,
2503 "Failed to allocate capture suspend buffer!\n"); 2507 "Failed to allocate capture suspend buffer!\n");
2504 snd_card_free(card); 2508 snd_card_free(card);
2505 return -ENOMEM; 2509 return -ENOMEM;
@@ -2548,10 +2552,9 @@ static struct pci_driver rme96_driver = {
2548 .id_table = snd_rme96_ids, 2552 .id_table = snd_rme96_ids,
2549 .probe = snd_rme96_probe, 2553 .probe = snd_rme96_probe,
2550 .remove = snd_rme96_remove, 2554 .remove = snd_rme96_remove,
2551#ifdef CONFIG_PM 2555 .driver = {
2552 .suspend = snd_rme96_suspend, 2556 .pm = RME96_PM_OPS,
2553 .resume = snd_rme96_resume, 2557 },
2554#endif
2555}; 2558};
2556 2559
2557module_pci_driver(rme96_driver); 2560module_pci_driver(rme96_driver);
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index bd90c80bb494..4c6f5d1c9882 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -675,14 +675,15 @@ static int hdsp_check_for_iobox (struct hdsp *hdsp)
675 if (0 == (hdsp_read(hdsp, HDSP_statusRegister) & 675 if (0 == (hdsp_read(hdsp, HDSP_statusRegister) &
676 HDSP_ConfigError)) { 676 HDSP_ConfigError)) {
677 if (i) { 677 if (i) {
678 snd_printd("Hammerfall-DSP: IO box found after %d ms\n", 678 dev_dbg(hdsp->card->dev,
679 "IO box found after %d ms\n",
679 (20 * i)); 680 (20 * i));
680 } 681 }
681 return 0; 682 return 0;
682 } 683 }
683 msleep(20); 684 msleep(20);
684 } 685 }
685 snd_printk(KERN_ERR "Hammerfall-DSP: no IO box connected!\n"); 686 dev_err(hdsp->card->dev, "no IO box connected!\n");
686 hdsp->state &= ~HDSP_FirmwareLoaded; 687 hdsp->state &= ~HDSP_FirmwareLoaded;
687 return -EIO; 688 return -EIO;
688} 689}
@@ -699,13 +700,13 @@ static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops,
699 if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError) 700 if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError)
700 msleep(delay); 701 msleep(delay);
701 else { 702 else {
702 snd_printd("Hammerfall-DSP: iobox found after %ums!\n", 703 dev_dbg(hdsp->card->dev, "iobox found after %ums!\n",
703 i * delay); 704 i * delay);
704 return 0; 705 return 0;
705 } 706 }
706 } 707 }
707 708
708 snd_printk("Hammerfall-DSP: no IO box connected!\n"); 709 dev_info(hdsp->card->dev, "no IO box connected!\n");
709 hdsp->state &= ~HDSP_FirmwareLoaded; 710 hdsp->state &= ~HDSP_FirmwareLoaded;
710 return -EIO; 711 return -EIO;
711} 712}
@@ -728,13 +729,14 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
728 729
729 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { 730 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) {
730 731
731 snd_printk ("Hammerfall-DSP: loading firmware\n"); 732 dev_info(hdsp->card->dev, "loading firmware\n");
732 733
733 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM); 734 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM);
734 hdsp_write (hdsp, HDSP_fifoData, 0); 735 hdsp_write (hdsp, HDSP_fifoData, 0);
735 736
736 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { 737 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) {
737 snd_printk ("Hammerfall-DSP: timeout waiting for download preparation\n"); 738 dev_info(hdsp->card->dev,
739 "timeout waiting for download preparation\n");
738 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); 740 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200);
739 return -EIO; 741 return -EIO;
740 } 742 }
@@ -744,7 +746,8 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
744 for (i = 0; i < HDSP_FIRMWARE_SIZE / 4; ++i) { 746 for (i = 0; i < HDSP_FIRMWARE_SIZE / 4; ++i) {
745 hdsp_write(hdsp, HDSP_fifoData, cache[i]); 747 hdsp_write(hdsp, HDSP_fifoData, cache[i]);
746 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { 748 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) {
747 snd_printk ("Hammerfall-DSP: timeout during firmware loading\n"); 749 dev_info(hdsp->card->dev,
750 "timeout during firmware loading\n");
748 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); 751 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200);
749 return -EIO; 752 return -EIO;
750 } 753 }
@@ -760,11 +763,12 @@ static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) {
760 hdsp->control2_register = 0; 763 hdsp->control2_register = 0;
761#endif 764#endif
762 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); 765 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register);
763 snd_printk ("Hammerfall-DSP: finished firmware loading\n"); 766 dev_info(hdsp->card->dev, "finished firmware loading\n");
764 767
765 } 768 }
766 if (hdsp->state & HDSP_InitializationComplete) { 769 if (hdsp->state & HDSP_InitializationComplete) {
767 snd_printk(KERN_INFO "Hammerfall-DSP: firmware loaded from cache, restoring defaults\n"); 770 dev_info(hdsp->card->dev,
771 "firmware loaded from cache, restoring defaults\n");
768 spin_lock_irqsave(&hdsp->lock, flags); 772 spin_lock_irqsave(&hdsp->lock, flags);
769 snd_hdsp_set_defaults(hdsp); 773 snd_hdsp_set_defaults(hdsp);
770 spin_unlock_irqrestore(&hdsp->lock, flags); 774 spin_unlock_irqrestore(&hdsp->lock, flags);
@@ -791,7 +795,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
791 hdsp_write (hdsp, HDSP_fifoData, 0); 795 hdsp_write (hdsp, HDSP_fifoData, 0);
792 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) { 796 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) {
793 hdsp->io_type = Multiface; 797 hdsp->io_type = Multiface;
794 snd_printk("Hammerfall-DSP: Multiface found\n"); 798 dev_info(hdsp->card->dev, "Multiface found\n");
795 return 0; 799 return 0;
796 } 800 }
797 801
@@ -799,7 +803,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
799 hdsp_write(hdsp, HDSP_fifoData, 0); 803 hdsp_write(hdsp, HDSP_fifoData, 0);
800 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) { 804 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) {
801 hdsp->io_type = Digiface; 805 hdsp->io_type = Digiface;
802 snd_printk("Hammerfall-DSP: Digiface found\n"); 806 dev_info(hdsp->card->dev, "Digiface found\n");
803 return 0; 807 return 0;
804 } 808 }
805 809
@@ -808,7 +812,7 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
808 hdsp_write(hdsp, HDSP_fifoData, 0); 812 hdsp_write(hdsp, HDSP_fifoData, 0);
809 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) { 813 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) {
810 hdsp->io_type = Multiface; 814 hdsp->io_type = Multiface;
811 snd_printk("Hammerfall-DSP: Multiface found\n"); 815 dev_info(hdsp->card->dev, "Multiface found\n");
812 return 0; 816 return 0;
813 } 817 }
814 818
@@ -817,12 +821,12 @@ static int hdsp_get_iobox_version (struct hdsp *hdsp)
817 hdsp_write(hdsp, HDSP_fifoData, 0); 821 hdsp_write(hdsp, HDSP_fifoData, 0);
818 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) { 822 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) {
819 hdsp->io_type = Multiface; 823 hdsp->io_type = Multiface;
820 snd_printk("Hammerfall-DSP: Multiface found\n"); 824 dev_info(hdsp->card->dev, "Multiface found\n");
821 return 0; 825 return 0;
822 } 826 }
823 827
824 hdsp->io_type = RPM; 828 hdsp->io_type = RPM;
825 snd_printk("Hammerfall-DSP: RPM found\n"); 829 dev_info(hdsp->card->dev, "RPM found\n");
826 return 0; 830 return 0;
827 } else { 831 } else {
828 /* firmware was already loaded, get iobox type */ 832 /* firmware was already loaded, get iobox type */
@@ -847,20 +851,18 @@ static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand)
847 hdsp->state &= ~HDSP_FirmwareLoaded; 851 hdsp->state &= ~HDSP_FirmwareLoaded;
848 if (! load_on_demand) 852 if (! load_on_demand)
849 return -EIO; 853 return -EIO;
850 snd_printk(KERN_ERR "Hammerfall-DSP: firmware not present.\n"); 854 dev_err(hdsp->card->dev, "firmware not present.\n");
851 /* try to load firmware */ 855 /* try to load firmware */
852 if (! (hdsp->state & HDSP_FirmwareCached)) { 856 if (! (hdsp->state & HDSP_FirmwareCached)) {
853 if (! hdsp_request_fw_loader(hdsp)) 857 if (! hdsp_request_fw_loader(hdsp))
854 return 0; 858 return 0;
855 snd_printk(KERN_ERR 859 dev_err(hdsp->card->dev,
856 "Hammerfall-DSP: No firmware loaded nor " 860 "No firmware loaded nor cached, please upload firmware.\n");
857 "cached, please upload firmware.\n");
858 return -EIO; 861 return -EIO;
859 } 862 }
860 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { 863 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {
861 snd_printk(KERN_ERR 864 dev_err(hdsp->card->dev,
862 "Hammerfall-DSP: Firmware loading from " 865 "Firmware loading from cache failed, please upload manually.\n");
863 "cache failed, please upload manually.\n");
864 return -EIO; 866 return -EIO;
865 } 867 }
866 } 868 }
@@ -888,7 +890,8 @@ static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout)
888 udelay (100); 890 udelay (100);
889 } 891 }
890 892
891 snd_printk ("Hammerfall-DSP: wait for FIFO status <= %d failed after %d iterations\n", 893 dev_warn(hdsp->card->dev,
894 "wait for FIFO status <= %d failed after %d iterations\n",
892 count, timeout); 895 count, timeout);
893 return -1; 896 return -1;
894} 897}
@@ -1005,7 +1008,9 @@ static int hdsp_spdif_sample_rate(struct hdsp *hdsp)
1005 default: 1008 default:
1006 break; 1009 break;
1007 } 1010 }
1008 snd_printk ("Hammerfall-DSP: unknown spdif frequency status; bits = 0x%x, status = 0x%x\n", rate_bits, status); 1011 dev_warn(hdsp->card->dev,
1012 "unknown spdif frequency status; bits = 0x%x, status = 0x%x\n",
1013 rate_bits, status);
1009 return 0; 1014 return 0;
1010} 1015}
1011 1016
@@ -1139,7 +1144,8 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1139 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { 1144 if (!(hdsp->control_register & HDSP_ClockModeMaster)) {
1140 if (called_internally) { 1145 if (called_internally) {
1141 /* request from ctl or card initialization */ 1146 /* request from ctl or card initialization */
1142 snd_printk(KERN_ERR "Hammerfall-DSP: device is not running as a clock master: cannot set sample rate.\n"); 1147 dev_err(hdsp->card->dev,
1148 "device is not running as a clock master: cannot set sample rate.\n");
1143 return -1; 1149 return -1;
1144 } else { 1150 } else {
1145 /* hw_param request while in AutoSync mode */ 1151 /* hw_param request while in AutoSync mode */
@@ -1147,11 +1153,14 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1147 int spdif_freq = hdsp_spdif_sample_rate(hdsp); 1153 int spdif_freq = hdsp_spdif_sample_rate(hdsp);
1148 1154
1149 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) 1155 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
1150 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in double speed mode\n"); 1156 dev_info(hdsp->card->dev,
1157 "Detected ADAT in double speed mode\n");
1151 else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) 1158 else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1))
1152 snd_printk(KERN_INFO "Hammerfall-DSP: Detected ADAT in quad speed mode\n"); 1159 dev_info(hdsp->card->dev,
1160 "Detected ADAT in quad speed mode\n");
1153 else if (rate != external_freq) { 1161 else if (rate != external_freq) {
1154 snd_printk(KERN_INFO "Hammerfall-DSP: No AutoSync source for requested rate\n"); 1162 dev_info(hdsp->card->dev,
1163 "No AutoSync source for requested rate\n");
1155 return -1; 1164 return -1;
1156 } 1165 }
1157 } 1166 }
@@ -1223,7 +1232,8 @@ static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally)
1223 } 1232 }
1224 1233
1225 if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) { 1234 if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) {
1226 snd_printk ("Hammerfall-DSP: cannot change speed mode (capture PID = %d, playback PID = %d)\n", 1235 dev_warn(hdsp->card->dev,
1236 "cannot change speed mode (capture PID = %d, playback PID = %d)\n",
1227 hdsp->capture_pid, 1237 hdsp->capture_pid,
1228 hdsp->playback_pid); 1238 hdsp->playback_pid);
1229 return -EBUSY; 1239 return -EBUSY;
@@ -3785,7 +3795,8 @@ static int snd_hdsp_initialize_memory(struct hdsp *hdsp)
3785 snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) { 3795 snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) {
3786 if (hdsp->capture_dma_buf.area) 3796 if (hdsp->capture_dma_buf.area)
3787 snd_dma_free_pages(&hdsp->capture_dma_buf); 3797 snd_dma_free_pages(&hdsp->capture_dma_buf);
3788 printk(KERN_ERR "%s: no buffers available\n", hdsp->card_name); 3798 dev_err(hdsp->card->dev,
3799 "%s: no buffers available\n", hdsp->card_name);
3789 return -ENOMEM; 3800 return -ENOMEM;
3790 } 3801 }
3791 3802
@@ -4747,7 +4758,8 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4747 return err; 4758 return err;
4748 4759
4749 if (!(hdsp->state & HDSP_FirmwareLoaded)) { 4760 if (!(hdsp->state & HDSP_FirmwareLoaded)) {
4750 snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n"); 4761 dev_err(hdsp->card->dev,
4762 "firmware needs to be uploaded to the card.\n");
4751 return -EINVAL; 4763 return -EINVAL;
4752 } 4764 }
4753 4765
@@ -4858,7 +4870,8 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4858 if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded)) 4870 if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded))
4859 return -EBUSY; 4871 return -EBUSY;
4860 4872
4861 snd_printk(KERN_INFO "Hammerfall-DSP: initializing firmware upload\n"); 4873 dev_info(hdsp->card->dev,
4874 "initializing firmware upload\n");
4862 firmware = (struct hdsp_firmware __user *)argp; 4875 firmware = (struct hdsp_firmware __user *)argp;
4863 4876
4864 if (get_user(firmware_data, &firmware->firmware_data)) 4877 if (get_user(firmware_data, &firmware->firmware_data))
@@ -4893,7 +4906,8 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne
4893 snd_hdsp_initialize_midi_flush(hdsp); 4906 snd_hdsp_initialize_midi_flush(hdsp);
4894 4907
4895 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { 4908 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
4896 snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n"); 4909 dev_err(hdsp->card->dev,
4910 "error creating alsa devices\n");
4897 return err; 4911 return err;
4898 } 4912 }
4899 } 4913 }
@@ -4983,7 +4997,8 @@ static int snd_hdsp_enable_io (struct hdsp *hdsp)
4983 int i; 4997 int i;
4984 4998
4985 if (hdsp_fifo_wait (hdsp, 0, 100)) { 4999 if (hdsp_fifo_wait (hdsp, 0, 100)) {
4986 snd_printk(KERN_ERR "Hammerfall-DSP: enable_io fifo_wait failed\n"); 5000 dev_err(hdsp->card->dev,
5001 "enable_io fifo_wait failed\n");
4987 return -EIO; 5002 return -EIO;
4988 } 5003 }
4989 5004
@@ -5057,25 +5072,29 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
5057 int err; 5072 int err;
5058 5073
5059 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { 5074 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) {
5060 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating pcm interface\n"); 5075 dev_err(card->dev,
5076 "Error creating pcm interface\n");
5061 return err; 5077 return err;
5062 } 5078 }
5063 5079
5064 5080
5065 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { 5081 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) {
5066 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating first midi interface\n"); 5082 dev_err(card->dev,
5083 "Error creating first midi interface\n");
5067 return err; 5084 return err;
5068 } 5085 }
5069 5086
5070 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { 5087 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) {
5071 if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) { 5088 if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) {
5072 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating second midi interface\n"); 5089 dev_err(card->dev,
5090 "Error creating second midi interface\n");
5073 return err; 5091 return err;
5074 } 5092 }
5075 } 5093 }
5076 5094
5077 if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) { 5095 if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) {
5078 snd_printk(KERN_ERR "Hammerfall-DSP: Error creating ctl interface\n"); 5096 dev_err(card->dev,
5097 "Error creating ctl interface\n");
5079 return err; 5098 return err;
5080 } 5099 }
5081 5100
@@ -5088,7 +5107,8 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
5088 hdsp->playback_substream = NULL; 5107 hdsp->playback_substream = NULL;
5089 5108
5090 if ((err = snd_hdsp_set_defaults(hdsp)) < 0) { 5109 if ((err = snd_hdsp_set_defaults(hdsp)) < 0) {
5091 snd_printk(KERN_ERR "Hammerfall-DSP: Error setting default values\n"); 5110 dev_err(card->dev,
5111 "Error setting default values\n");
5092 return err; 5112 return err;
5093 } 5113 }
5094 5114
@@ -5098,7 +5118,8 @@ static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp
5098 hdsp->port, hdsp->irq); 5118 hdsp->port, hdsp->irq);
5099 5119
5100 if ((err = snd_card_register(card)) < 0) { 5120 if ((err = snd_card_register(card)) < 0) {
5101 snd_printk(KERN_ERR "Hammerfall-DSP: error registering card\n"); 5121 dev_err(card->dev,
5122 "error registering card\n");
5102 return err; 5123 return err;
5103 } 5124 }
5104 hdsp->state |= HDSP_InitializationComplete; 5125 hdsp->state |= HDSP_InitializationComplete;
@@ -5141,16 +5162,19 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
5141 fwfile = "digiface_firmware_rev11.bin"; 5162 fwfile = "digiface_firmware_rev11.bin";
5142 break; 5163 break;
5143 default: 5164 default:
5144 snd_printk(KERN_ERR "Hammerfall-DSP: invalid io_type %d\n", hdsp->io_type); 5165 dev_err(hdsp->card->dev,
5166 "invalid io_type %d\n", hdsp->io_type);
5145 return -EINVAL; 5167 return -EINVAL;
5146 } 5168 }
5147 5169
5148 if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) { 5170 if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) {
5149 snd_printk(KERN_ERR "Hammerfall-DSP: cannot load firmware %s\n", fwfile); 5171 dev_err(hdsp->card->dev,
5172 "cannot load firmware %s\n", fwfile);
5150 return -ENOENT; 5173 return -ENOENT;
5151 } 5174 }
5152 if (fw->size < HDSP_FIRMWARE_SIZE) { 5175 if (fw->size < HDSP_FIRMWARE_SIZE) {
5153 snd_printk(KERN_ERR "Hammerfall-DSP: too short firmware size %d (expected %d)\n", 5176 dev_err(hdsp->card->dev,
5177 "too short firmware size %d (expected %d)\n",
5154 (int)fw->size, HDSP_FIRMWARE_SIZE); 5178 (int)fw->size, HDSP_FIRMWARE_SIZE);
5155 return -EINVAL; 5179 return -EINVAL;
5156 } 5180 }
@@ -5167,13 +5191,15 @@ static int hdsp_request_fw_loader(struct hdsp *hdsp)
5167 return err; 5191 return err;
5168 5192
5169 if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) { 5193 if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) {
5170 snd_printk(KERN_ERR "Hammerfall-DSP: error creating hwdep device\n"); 5194 dev_err(hdsp->card->dev,
5195 "error creating hwdep device\n");
5171 return err; 5196 return err;
5172 } 5197 }
5173 snd_hdsp_initialize_channels(hdsp); 5198 snd_hdsp_initialize_channels(hdsp);
5174 snd_hdsp_initialize_midi_flush(hdsp); 5199 snd_hdsp_initialize_midi_flush(hdsp);
5175 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { 5200 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) {
5176 snd_printk(KERN_ERR "Hammerfall-DSP: error creating alsa devices\n"); 5201 dev_err(hdsp->card->dev,
5202 "error creating alsa devices\n");
5177 return err; 5203 return err;
5178 } 5204 }
5179 } 5205 }
@@ -5249,13 +5275,14 @@ static int snd_hdsp_create(struct snd_card *card,
5249 return err; 5275 return err;
5250 hdsp->port = pci_resource_start(pci, 0); 5276 hdsp->port = pci_resource_start(pci, 0);
5251 if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) { 5277 if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) {
5252 snd_printk(KERN_ERR "Hammerfall-DSP: unable to remap region 0x%lx-0x%lx\n", hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1); 5278 dev_err(hdsp->card->dev, "unable to remap region 0x%lx-0x%lx\n",
5279 hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1);
5253 return -EBUSY; 5280 return -EBUSY;
5254 } 5281 }
5255 5282
5256 if (request_irq(pci->irq, snd_hdsp_interrupt, IRQF_SHARED, 5283 if (request_irq(pci->irq, snd_hdsp_interrupt, IRQF_SHARED,
5257 KBUILD_MODNAME, hdsp)) { 5284 KBUILD_MODNAME, hdsp)) {
5258 snd_printk(KERN_ERR "Hammerfall-DSP: unable to use IRQ %d\n", pci->irq); 5285 dev_err(hdsp->card->dev, "unable to use IRQ %d\n", pci->irq);
5259 return -EBUSY; 5286 return -EBUSY;
5260 } 5287 }
5261 5288
@@ -5281,17 +5308,20 @@ static int snd_hdsp_create(struct snd_card *card,
5281 if userspace is not ready for 5308 if userspace is not ready for
5282 firmware upload 5309 firmware upload
5283 */ 5310 */
5284 snd_printk(KERN_ERR "Hammerfall-DSP: couldn't get firmware from userspace. try using hdsploader\n"); 5311 dev_err(hdsp->card->dev,
5312 "couldn't get firmware from userspace. try using hdsploader\n");
5285 else 5313 else
5286 /* init is complete, we return */ 5314 /* init is complete, we return */
5287 return 0; 5315 return 0;
5288 /* we defer initialization */ 5316 /* we defer initialization */
5289 snd_printk(KERN_INFO "Hammerfall-DSP: card initialization pending : waiting for firmware\n"); 5317 dev_info(hdsp->card->dev,
5318 "card initialization pending : waiting for firmware\n");
5290 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) 5319 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0)
5291 return err; 5320 return err;
5292 return 0; 5321 return 0;
5293 } else { 5322 } else {
5294 snd_printk(KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n"); 5323 dev_info(hdsp->card->dev,
5324 "Firmware already present, initializing card.\n");
5295 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) 5325 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2)
5296 hdsp->io_type = RPM; 5326 hdsp->io_type = RPM;
5297 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) 5327 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1)
@@ -5375,8 +5405,8 @@ static int snd_hdsp_probe(struct pci_dev *pci,
5375 return -ENOENT; 5405 return -ENOENT;
5376 } 5406 }
5377 5407
5378 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 5408 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
5379 sizeof(struct hdsp), &card); 5409 sizeof(struct hdsp), &card);
5380 if (err < 0) 5410 if (err < 0)
5381 return err; 5411 return err;
5382 5412
@@ -5384,7 +5414,6 @@ static int snd_hdsp_probe(struct pci_dev *pci,
5384 card->private_free = snd_hdsp_card_free; 5414 card->private_free = snd_hdsp_card_free;
5385 hdsp->dev = dev; 5415 hdsp->dev = dev;
5386 hdsp->pci = pci; 5416 hdsp->pci = pci;
5387 snd_card_set_dev(card, &pci->dev);
5388 5417
5389 if ((err = snd_hdsp_create(card, hdsp)) < 0) { 5418 if ((err = snd_hdsp_create(card, hdsp)) < 0) {
5390 snd_card_free(card); 5419 snd_card_free(card);
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index e98dc008de0b..cb82b593473a 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -1651,9 +1651,8 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
1651 just make a warning an remember setting 1651 just make a warning an remember setting
1652 for future master mode switching */ 1652 for future master mode switching */
1653 1653
1654 snd_printk(KERN_WARNING "HDSPM: " 1654 dev_warn(hdspm->card->dev,
1655 "Warning: device is not running " 1655 "Warning: device is not running as a clock master.\n");
1656 "as a clock master.\n");
1657 not_set = 1; 1656 not_set = 1;
1658 } else { 1657 } else {
1659 1658
@@ -1664,15 +1663,14 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
1664 if (hdspm_autosync_ref(hdspm) == 1663 if (hdspm_autosync_ref(hdspm) ==
1665 HDSPM_AUTOSYNC_FROM_NONE) { 1664 HDSPM_AUTOSYNC_FROM_NONE) {
1666 1665
1667 snd_printk(KERN_WARNING "HDSPM: " 1666 dev_warn(hdspm->card->dev,
1668 "Detected no Externel Sync \n"); 1667 "Detected no Externel Sync\n");
1669 not_set = 1; 1668 not_set = 1;
1670 1669
1671 } else if (rate != external_freq) { 1670 } else if (rate != external_freq) {
1672 1671
1673 snd_printk(KERN_WARNING "HDSPM: " 1672 dev_warn(hdspm->card->dev,
1674 "Warning: No AutoSync source for " 1673 "Warning: No AutoSync source for requested rate\n");
1675 "requested rate\n");
1676 not_set = 1; 1674 not_set = 1;
1677 } 1675 }
1678 } 1676 }
@@ -1738,13 +1736,11 @@ static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally)
1738 1736
1739 if (current_speed != target_speed 1737 if (current_speed != target_speed
1740 && (hdspm->capture_pid >= 0 || hdspm->playback_pid >= 0)) { 1738 && (hdspm->capture_pid >= 0 || hdspm->playback_pid >= 0)) {
1741 snd_printk 1739 dev_err(hdspm->card->dev,
1742 (KERN_ERR "HDSPM: " 1740 "cannot change from %s speed to %s speed mode (capture PID = %d, playback PID = %d)\n",
1743 "cannot change from %s speed to %s speed mode " 1741 hdspm_speed_names[current_speed],
1744 "(capture PID = %d, playback PID = %d)\n", 1742 hdspm_speed_names[target_speed],
1745 hdspm_speed_names[current_speed], 1743 hdspm->capture_pid, hdspm->playback_pid);
1746 hdspm_speed_names[target_speed],
1747 hdspm->capture_pid, hdspm->playback_pid);
1748 return -EBUSY; 1744 return -EBUSY;
1749 } 1745 }
1750 1746
@@ -5446,7 +5442,7 @@ static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id)
5446 * 0 64 ~3998231 ~8191558 5442 * 0 64 ~3998231 ~8191558
5447 **/ 5443 **/
5448 /* 5444 /*
5449 snd_printk(KERN_INFO "snd_hdspm_interrupt %llu @ %llx\n", 5445 dev_info(hdspm->card->dev, "snd_hdspm_interrupt %llu @ %llx\n",
5450 now-hdspm->last_interrupt, status & 0xFFC0); 5446 now-hdspm->last_interrupt, status & 0xFFC0);
5451 hdspm->last_interrupt = now; 5447 hdspm->last_interrupt = now;
5452 */ 5448 */
@@ -5583,7 +5579,7 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
5583 spin_lock_irq(&hdspm->lock); 5579 spin_lock_irq(&hdspm->lock);
5584 err = hdspm_set_rate(hdspm, params_rate(params), 0); 5580 err = hdspm_set_rate(hdspm, params_rate(params), 0);
5585 if (err < 0) { 5581 if (err < 0) {
5586 snd_printk(KERN_INFO "err on hdspm_set_rate: %d\n", err); 5582 dev_info(hdspm->card->dev, "err on hdspm_set_rate: %d\n", err);
5587 spin_unlock_irq(&hdspm->lock); 5583 spin_unlock_irq(&hdspm->lock);
5588 _snd_pcm_hw_param_setempty(params, 5584 _snd_pcm_hw_param_setempty(params,
5589 SNDRV_PCM_HW_PARAM_RATE); 5585 SNDRV_PCM_HW_PARAM_RATE);
@@ -5594,7 +5590,8 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
5594 err = hdspm_set_interrupt_interval(hdspm, 5590 err = hdspm_set_interrupt_interval(hdspm,
5595 params_period_size(params)); 5591 params_period_size(params));
5596 if (err < 0) { 5592 if (err < 0) {
5597 snd_printk(KERN_INFO "err on hdspm_set_interrupt_interval: %d\n", err); 5593 dev_info(hdspm->card->dev,
5594 "err on hdspm_set_interrupt_interval: %d\n", err);
5598 _snd_pcm_hw_param_setempty(params, 5595 _snd_pcm_hw_param_setempty(params,
5599 SNDRV_PCM_HW_PARAM_PERIOD_SIZE); 5596 SNDRV_PCM_HW_PARAM_PERIOD_SIZE);
5600 return err; 5597 return err;
@@ -5610,7 +5607,8 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
5610 err = 5607 err =
5611 snd_pcm_lib_malloc_pages(substream, HDSPM_DMA_AREA_BYTES); 5608 snd_pcm_lib_malloc_pages(substream, HDSPM_DMA_AREA_BYTES);
5612 if (err < 0) { 5609 if (err < 0) {
5613 snd_printk(KERN_INFO "err on snd_pcm_lib_malloc_pages: %d\n", err); 5610 dev_info(hdspm->card->dev,
5611 "err on snd_pcm_lib_malloc_pages: %d\n", err);
5614 return err; 5612 return err;
5615 } 5613 }
5616 5614
@@ -5624,7 +5622,8 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
5624 5622
5625 hdspm->playback_buffer = 5623 hdspm->playback_buffer =
5626 (unsigned char *) substream->runtime->dma_area; 5624 (unsigned char *) substream->runtime->dma_area;
5627 snd_printdd("Allocated sample buffer for playback at %p\n", 5625 dev_dbg(hdspm->card->dev,
5626 "Allocated sample buffer for playback at %p\n",
5628 hdspm->playback_buffer); 5627 hdspm->playback_buffer);
5629 } else { 5628 } else {
5630 hdspm_set_sgbuf(hdspm, substream, HDSPM_pageAddressBufferIn, 5629 hdspm_set_sgbuf(hdspm, substream, HDSPM_pageAddressBufferIn,
@@ -5635,18 +5634,21 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
5635 5634
5636 hdspm->capture_buffer = 5635 hdspm->capture_buffer =
5637 (unsigned char *) substream->runtime->dma_area; 5636 (unsigned char *) substream->runtime->dma_area;
5638 snd_printdd("Allocated sample buffer for capture at %p\n", 5637 dev_dbg(hdspm->card->dev,
5638 "Allocated sample buffer for capture at %p\n",
5639 hdspm->capture_buffer); 5639 hdspm->capture_buffer);
5640 } 5640 }
5641 5641
5642 /* 5642 /*
5643 snd_printdd("Allocated sample buffer for %s at 0x%08X\n", 5643 dev_dbg(hdspm->card->dev,
5644 "Allocated sample buffer for %s at 0x%08X\n",
5644 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 5645 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
5645 "playback" : "capture", 5646 "playback" : "capture",
5646 snd_pcm_sgbuf_get_addr(substream, 0)); 5647 snd_pcm_sgbuf_get_addr(substream, 0));
5647 */ 5648 */
5648 /* 5649 /*
5649 snd_printdd("set_hwparams: %s %d Hz, %d channels, bs = %d\n", 5650 dev_dbg(hdspm->card->dev,
5651 "set_hwparams: %s %d Hz, %d channels, bs = %d\n",
5650 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 5652 substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
5651 "playback" : "capture", 5653 "playback" : "capture",
5652 params_rate(params), params_channels(params), 5654 params_rate(params), params_channels(params),
@@ -5667,12 +5669,14 @@ static int snd_hdspm_hw_params(struct snd_pcm_substream *substream,
5667 /* Switch to native float format if requested */ 5669 /* Switch to native float format if requested */
5668 if (SNDRV_PCM_FORMAT_FLOAT_LE == params_format(params)) { 5670 if (SNDRV_PCM_FORMAT_FLOAT_LE == params_format(params)) {
5669 if (!(hdspm->control_register & HDSPe_FLOAT_FORMAT)) 5671 if (!(hdspm->control_register & HDSPe_FLOAT_FORMAT))
5670 snd_printk(KERN_INFO "hdspm: Switching to native 32bit LE float format.\n"); 5672 dev_info(hdspm->card->dev,
5673 "Switching to native 32bit LE float format.\n");
5671 5674
5672 hdspm->control_register |= HDSPe_FLOAT_FORMAT; 5675 hdspm->control_register |= HDSPe_FLOAT_FORMAT;
5673 } else if (SNDRV_PCM_FORMAT_S32_LE == params_format(params)) { 5676 } else if (SNDRV_PCM_FORMAT_S32_LE == params_format(params)) {
5674 if (hdspm->control_register & HDSPe_FLOAT_FORMAT) 5677 if (hdspm->control_register & HDSPe_FLOAT_FORMAT)
5675 snd_printk(KERN_INFO "hdspm: Switching to native 32bit LE integer format.\n"); 5678 dev_info(hdspm->card->dev,
5679 "Switching to native 32bit LE integer format.\n");
5676 5680
5677 hdspm->control_register &= ~HDSPe_FLOAT_FORMAT; 5681 hdspm->control_register &= ~HDSPe_FLOAT_FORMAT;
5678 } 5682 }
@@ -5715,12 +5719,16 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
5715 5719
5716 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 5720 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
5717 if (snd_BUG_ON(info->channel >= hdspm->max_channels_out)) { 5721 if (snd_BUG_ON(info->channel >= hdspm->max_channels_out)) {
5718 snd_printk(KERN_INFO "snd_hdspm_channel_info: output channel out of range (%d)\n", info->channel); 5722 dev_info(hdspm->card->dev,
5723 "snd_hdspm_channel_info: output channel out of range (%d)\n",
5724 info->channel);
5719 return -EINVAL; 5725 return -EINVAL;
5720 } 5726 }
5721 5727
5722 if (hdspm->channel_map_out[info->channel] < 0) { 5728 if (hdspm->channel_map_out[info->channel] < 0) {
5723 snd_printk(KERN_INFO "snd_hdspm_channel_info: output channel %d mapped out\n", info->channel); 5729 dev_info(hdspm->card->dev,
5730 "snd_hdspm_channel_info: output channel %d mapped out\n",
5731 info->channel);
5724 return -EINVAL; 5732 return -EINVAL;
5725 } 5733 }
5726 5734
@@ -5728,12 +5736,16 @@ static int snd_hdspm_channel_info(struct snd_pcm_substream *substream,
5728 HDSPM_CHANNEL_BUFFER_BYTES; 5736 HDSPM_CHANNEL_BUFFER_BYTES;
5729 } else { 5737 } else {
5730 if (snd_BUG_ON(info->channel >= hdspm->max_channels_in)) { 5738 if (snd_BUG_ON(info->channel >= hdspm->max_channels_in)) {
5731 snd_printk(KERN_INFO "snd_hdspm_channel_info: input channel out of range (%d)\n", info->channel); 5739 dev_info(hdspm->card->dev,
5740 "snd_hdspm_channel_info: input channel out of range (%d)\n",
5741 info->channel);
5732 return -EINVAL; 5742 return -EINVAL;
5733 } 5743 }
5734 5744
5735 if (hdspm->channel_map_in[info->channel] < 0) { 5745 if (hdspm->channel_map_in[info->channel] < 0) {
5736 snd_printk(KERN_INFO "snd_hdspm_channel_info: input channel %d mapped out\n", info->channel); 5746 dev_info(hdspm->card->dev,
5747 "snd_hdspm_channel_info: input channel %d mapped out\n",
5748 info->channel);
5737 return -EINVAL; 5749 return -EINVAL;
5738 } 5750 }
5739 5751
@@ -6283,7 +6295,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6283 6295
6284 s = copy_to_user(argp, levels, sizeof(struct hdspm_peak_rms)); 6296 s = copy_to_user(argp, levels, sizeof(struct hdspm_peak_rms));
6285 if (0 != s) { 6297 if (0 != s) {
6286 /* snd_printk(KERN_ERR "copy_to_user(.., .., %lu): %lu 6298 /* dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu
6287 [Levels]\n", sizeof(struct hdspm_peak_rms), s); 6299 [Levels]\n", sizeof(struct hdspm_peak_rms), s);
6288 */ 6300 */
6289 return -EFAULT; 6301 return -EFAULT;
@@ -6329,7 +6341,7 @@ static int snd_hdspm_hwdep_ioctl(struct snd_hwdep *hw, struct file *file,
6329 s = copy_to_user(argp, &ltc, sizeof(struct hdspm_ltc)); 6341 s = copy_to_user(argp, &ltc, sizeof(struct hdspm_ltc));
6330 if (0 != s) { 6342 if (0 != s) {
6331 /* 6343 /*
6332 snd_printk(KERN_ERR "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); */ 6344 dev_err(hdspm->card->dev, "copy_to_user(.., .., %lu): %lu [LTC]\n", sizeof(struct hdspm_ltc), s); */
6333 return -EFAULT; 6345 return -EFAULT;
6334 } 6346 }
6335 6347
@@ -6494,11 +6506,13 @@ static int snd_hdspm_preallocate_memory(struct hdspm *hdspm)
6494 wanted, 6506 wanted,
6495 wanted); 6507 wanted);
6496 if (err < 0) { 6508 if (err < 0) {
6497 snd_printdd("Could not preallocate %zd Bytes\n", wanted); 6509 dev_dbg(hdspm->card->dev,
6510 "Could not preallocate %zd Bytes\n", wanted);
6498 6511
6499 return err; 6512 return err;
6500 } else 6513 } else
6501 snd_printdd(" Preallocated %zd Bytes\n", wanted); 6514 dev_dbg(hdspm->card->dev,
6515 " Preallocated %zd Bytes\n", wanted);
6502 6516
6503 return 0; 6517 return 0;
6504} 6518}
@@ -6559,7 +6573,7 @@ static int snd_hdspm_create_alsa_devices(struct snd_card *card,
6559{ 6573{
6560 int err, i; 6574 int err, i;
6561 6575
6562 snd_printdd("Create card...\n"); 6576 dev_dbg(card->dev, "Create card...\n");
6563 err = snd_hdspm_create_pcm(card, hdspm); 6577 err = snd_hdspm_create_pcm(card, hdspm);
6564 if (err < 0) 6578 if (err < 0)
6565 return err; 6579 return err;
@@ -6581,7 +6595,7 @@ static int snd_hdspm_create_alsa_devices(struct snd_card *card,
6581 if (err < 0) 6595 if (err < 0)
6582 return err; 6596 return err;
6583 6597
6584 snd_printdd("proc init...\n"); 6598 dev_dbg(card->dev, "proc init...\n");
6585 snd_hdspm_proc_init(hdspm); 6599 snd_hdspm_proc_init(hdspm);
6586 6600
6587 hdspm->system_sample_rate = -1; 6601 hdspm->system_sample_rate = -1;
@@ -6592,23 +6606,23 @@ static int snd_hdspm_create_alsa_devices(struct snd_card *card,
6592 hdspm->capture_substream = NULL; 6606 hdspm->capture_substream = NULL;
6593 hdspm->playback_substream = NULL; 6607 hdspm->playback_substream = NULL;
6594 6608
6595 snd_printdd("Set defaults...\n"); 6609 dev_dbg(card->dev, "Set defaults...\n");
6596 err = snd_hdspm_set_defaults(hdspm); 6610 err = snd_hdspm_set_defaults(hdspm);
6597 if (err < 0) 6611 if (err < 0)
6598 return err; 6612 return err;
6599 6613
6600 snd_printdd("Update mixer controls...\n"); 6614 dev_dbg(card->dev, "Update mixer controls...\n");
6601 hdspm_update_simple_mixer_controls(hdspm); 6615 hdspm_update_simple_mixer_controls(hdspm);
6602 6616
6603 snd_printdd("Initializeing complete ???\n"); 6617 dev_dbg(card->dev, "Initializeing complete ???\n");
6604 6618
6605 err = snd_card_register(card); 6619 err = snd_card_register(card);
6606 if (err < 0) { 6620 if (err < 0) {
6607 snd_printk(KERN_ERR "HDSPM: error registering card\n"); 6621 dev_err(card->dev, "error registering card\n");
6608 return err; 6622 return err;
6609 } 6623 }
6610 6624
6611 snd_printdd("... yes now\n"); 6625 dev_dbg(card->dev, "... yes now\n");
6612 6626
6613 return 0; 6627 return 0;
6614} 6628}
@@ -6662,8 +6676,8 @@ static int snd_hdspm_create(struct snd_card *card,
6662 hdspm->card_name = "RME MADI"; 6676 hdspm->card_name = "RME MADI";
6663 hdspm->midiPorts = 3; 6677 hdspm->midiPorts = 3;
6664 } else { 6678 } else {
6665 snd_printk(KERN_ERR 6679 dev_err(card->dev,
6666 "HDSPM: unknown firmware revision %x\n", 6680 "unknown firmware revision %x\n",
6667 hdspm->firmware_rev); 6681 hdspm->firmware_rev);
6668 return -ENODEV; 6682 return -ENODEV;
6669 } 6683 }
@@ -6682,36 +6696,35 @@ static int snd_hdspm_create(struct snd_card *card,
6682 hdspm->port = pci_resource_start(pci, 0); 6696 hdspm->port = pci_resource_start(pci, 0);
6683 io_extent = pci_resource_len(pci, 0); 6697 io_extent = pci_resource_len(pci, 0);
6684 6698
6685 snd_printdd("grabbed memory region 0x%lx-0x%lx\n", 6699 dev_dbg(card->dev, "grabbed memory region 0x%lx-0x%lx\n",
6686 hdspm->port, hdspm->port + io_extent - 1); 6700 hdspm->port, hdspm->port + io_extent - 1);
6687 6701
6688 hdspm->iobase = ioremap_nocache(hdspm->port, io_extent); 6702 hdspm->iobase = ioremap_nocache(hdspm->port, io_extent);
6689 if (!hdspm->iobase) { 6703 if (!hdspm->iobase) {
6690 snd_printk(KERN_ERR "HDSPM: " 6704 dev_err(card->dev, "unable to remap region 0x%lx-0x%lx\n",
6691 "unable to remap region 0x%lx-0x%lx\n",
6692 hdspm->port, hdspm->port + io_extent - 1); 6705 hdspm->port, hdspm->port + io_extent - 1);
6693 return -EBUSY; 6706 return -EBUSY;
6694 } 6707 }
6695 snd_printdd("remapped region (0x%lx) 0x%lx-0x%lx\n", 6708 dev_dbg(card->dev, "remapped region (0x%lx) 0x%lx-0x%lx\n",
6696 (unsigned long)hdspm->iobase, hdspm->port, 6709 (unsigned long)hdspm->iobase, hdspm->port,
6697 hdspm->port + io_extent - 1); 6710 hdspm->port + io_extent - 1);
6698 6711
6699 if (request_irq(pci->irq, snd_hdspm_interrupt, 6712 if (request_irq(pci->irq, snd_hdspm_interrupt,
6700 IRQF_SHARED, KBUILD_MODNAME, hdspm)) { 6713 IRQF_SHARED, KBUILD_MODNAME, hdspm)) {
6701 snd_printk(KERN_ERR "HDSPM: unable to use IRQ %d\n", pci->irq); 6714 dev_err(card->dev, "unable to use IRQ %d\n", pci->irq);
6702 return -EBUSY; 6715 return -EBUSY;
6703 } 6716 }
6704 6717
6705 snd_printdd("use IRQ %d\n", pci->irq); 6718 dev_dbg(card->dev, "use IRQ %d\n", pci->irq);
6706 6719
6707 hdspm->irq = pci->irq; 6720 hdspm->irq = pci->irq;
6708 6721
6709 snd_printdd("kmalloc Mixer memory of %zd Bytes\n", 6722 dev_dbg(card->dev, "kmalloc Mixer memory of %zd Bytes\n",
6710 sizeof(struct hdspm_mixer)); 6723 sizeof(struct hdspm_mixer));
6711 hdspm->mixer = kzalloc(sizeof(struct hdspm_mixer), GFP_KERNEL); 6724 hdspm->mixer = kzalloc(sizeof(struct hdspm_mixer), GFP_KERNEL);
6712 if (!hdspm->mixer) { 6725 if (!hdspm->mixer) {
6713 snd_printk(KERN_ERR "HDSPM: " 6726 dev_err(card->dev,
6714 "unable to kmalloc Mixer memory of %d Bytes\n", 6727 "unable to kmalloc Mixer memory of %d Bytes\n",
6715 (int)sizeof(struct hdspm_mixer)); 6728 (int)sizeof(struct hdspm_mixer));
6716 return -ENOMEM; 6729 return -ENOMEM;
6717 } 6730 }
@@ -6780,14 +6793,14 @@ static int snd_hdspm_create(struct snd_card *card,
6780 hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS; 6793 hdspm->qs_out_channels = AIO_OUT_QS_CHANNELS;
6781 6794
6782 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBI_D)) { 6795 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBI_D)) {
6783 snd_printk(KERN_INFO "HDSPM: AEB input board found\n"); 6796 dev_info(card->dev, "AEB input board found\n");
6784 hdspm->ss_in_channels += 4; 6797 hdspm->ss_in_channels += 4;
6785 hdspm->ds_in_channels += 4; 6798 hdspm->ds_in_channels += 4;
6786 hdspm->qs_in_channels += 4; 6799 hdspm->qs_in_channels += 4;
6787 } 6800 }
6788 6801
6789 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBO_D)) { 6802 if (0 == (hdspm_read(hdspm, HDSPM_statusRegister2) & HDSPM_s2_AEBO_D)) {
6790 snd_printk(KERN_INFO "HDSPM: AEB output board found\n"); 6803 dev_info(card->dev, "AEB output board found\n");
6791 hdspm->ss_out_channels += 4; 6804 hdspm->ss_out_channels += 4;
6792 hdspm->ds_out_channels += 4; 6805 hdspm->ds_out_channels += 4;
6793 hdspm->qs_out_channels += 4; 6806 hdspm->qs_out_channels += 4;
@@ -6854,7 +6867,7 @@ static int snd_hdspm_create(struct snd_card *card,
6854 if (NULL != hdspm->tco) { 6867 if (NULL != hdspm->tco) {
6855 hdspm_tco_write(hdspm); 6868 hdspm_tco_write(hdspm);
6856 } 6869 }
6857 snd_printk(KERN_INFO "HDSPM: AIO/RayDAT TCO module found\n"); 6870 dev_info(card->dev, "AIO/RayDAT TCO module found\n");
6858 } else { 6871 } else {
6859 hdspm->tco = NULL; 6872 hdspm->tco = NULL;
6860 } 6873 }
@@ -6869,7 +6882,7 @@ static int snd_hdspm_create(struct snd_card *card,
6869 if (NULL != hdspm->tco) { 6882 if (NULL != hdspm->tco) {
6870 hdspm_tco_write(hdspm); 6883 hdspm_tco_write(hdspm);
6871 } 6884 }
6872 snd_printk(KERN_INFO "HDSPM: MADI/AES TCO module found\n"); 6885 dev_info(card->dev, "MADI/AES TCO module found\n");
6873 } else { 6886 } else {
6874 hdspm->tco = NULL; 6887 hdspm->tco = NULL;
6875 } 6888 }
@@ -6951,7 +6964,7 @@ static int snd_hdspm_create(struct snd_card *card,
6951 } 6964 }
6952 } 6965 }
6953 6966
6954 snd_printdd("create alsa devices.\n"); 6967 dev_dbg(card->dev, "create alsa devices.\n");
6955 err = snd_hdspm_create_alsa_devices(card, hdspm); 6968 err = snd_hdspm_create_alsa_devices(card, hdspm);
6956 if (err < 0) 6969 if (err < 0)
6957 return err; 6970 return err;
@@ -7016,8 +7029,8 @@ static int snd_hdspm_probe(struct pci_dev *pci,
7016 return -ENOENT; 7029 return -ENOENT;
7017 } 7030 }
7018 7031
7019 err = snd_card_create(index[dev], id[dev], 7032 err = snd_card_new(&pci->dev, index[dev], id[dev],
7020 THIS_MODULE, sizeof(struct hdspm), &card); 7033 THIS_MODULE, sizeof(struct hdspm), &card);
7021 if (err < 0) 7034 if (err < 0)
7022 return err; 7035 return err;
7023 7036
@@ -7026,8 +7039,6 @@ static int snd_hdspm_probe(struct pci_dev *pci,
7026 hdspm->dev = dev; 7039 hdspm->dev = dev;
7027 hdspm->pci = pci; 7040 hdspm->pci = pci;
7028 7041
7029 snd_card_set_dev(card, &pci->dev);
7030
7031 err = snd_hdspm_create(card, hdspm); 7042 err = snd_hdspm_create(card, hdspm);
7032 if (err < 0) { 7043 if (err < 0) {
7033 snd_card_free(card); 7044 snd_card_free(card);
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index 1503ee3585fd..1d9be90f7748 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -394,7 +394,9 @@ static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652)
394 if (offset < period_size) { 394 if (offset < period_size) {
395 if (offset > rme9652->max_jitter) { 395 if (offset > rme9652->max_jitter) {
396 if (frag) 396 if (frag)
397 printk(KERN_ERR "Unexpected hw_pointer position (bufid == 0): status: %x offset: %d\n", status, offset); 397 dev_err(rme9652->card->dev,
398 "Unexpected hw_pointer position (bufid == 0): status: %x offset: %d\n",
399 status, offset);
398 } else if (!frag) 400 } else if (!frag)
399 return 0; 401 return 0;
400 offset -= rme9652->max_jitter; 402 offset -= rme9652->max_jitter;
@@ -403,7 +405,9 @@ static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652)
403 } else { 405 } else {
404 if (offset > period_size + rme9652->max_jitter) { 406 if (offset > period_size + rme9652->max_jitter) {
405 if (!frag) 407 if (!frag)
406 printk(KERN_ERR "Unexpected hw_pointer position (bufid == 1): status: %x offset: %d\n", status, offset); 408 dev_err(rme9652->card->dev,
409 "Unexpected hw_pointer position (bufid == 1): status: %x offset: %d\n",
410 status, offset);
407 } else if (frag) 411 } else if (frag)
408 return period_size; 412 return period_size;
409 offset -= rme9652->max_jitter; 413 offset -= rme9652->max_jitter;
@@ -769,7 +773,8 @@ static inline int rme9652_spdif_sample_rate(struct snd_rme9652 *s)
769 break; 773 break;
770 774
771 default: 775 default:
772 snd_printk(KERN_ERR "%s: unknown S/PDIF input rate (bits = 0x%x)\n", 776 dev_err(s->card->dev,
777 "%s: unknown S/PDIF input rate (bits = 0x%x)\n",
773 s->card_name, rate_bits); 778 s->card_name, rate_bits);
774 return 0; 779 return 0;
775 break; 780 break;
@@ -1790,7 +1795,8 @@ static int snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652)
1790 snd_hammerfall_get_buffer(rme9652->pci, &rme9652->playback_dma_buf, RME9652_DMA_AREA_BYTES) < 0) { 1795 snd_hammerfall_get_buffer(rme9652->pci, &rme9652->playback_dma_buf, RME9652_DMA_AREA_BYTES) < 0) {
1791 if (rme9652->capture_dma_buf.area) 1796 if (rme9652->capture_dma_buf.area)
1792 snd_dma_free_pages(&rme9652->capture_dma_buf); 1797 snd_dma_free_pages(&rme9652->capture_dma_buf);
1793 printk(KERN_ERR "%s: no buffers available\n", rme9652->card_name); 1798 dev_err(rme9652->card->dev,
1799 "%s: no buffers available\n", rme9652->card_name);
1794 return -ENOMEM; 1800 return -ENOMEM;
1795 } 1801 }
1796 1802
@@ -2468,13 +2474,14 @@ static int snd_rme9652_create(struct snd_card *card,
2468 rme9652->port = pci_resource_start(pci, 0); 2474 rme9652->port = pci_resource_start(pci, 0);
2469 rme9652->iobase = ioremap_nocache(rme9652->port, RME9652_IO_EXTENT); 2475 rme9652->iobase = ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
2470 if (rme9652->iobase == NULL) { 2476 if (rme9652->iobase == NULL) {
2471 snd_printk(KERN_ERR "unable to remap region 0x%lx-0x%lx\n", rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1); 2477 dev_err(card->dev, "unable to remap region 0x%lx-0x%lx\n",
2478 rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
2472 return -EBUSY; 2479 return -EBUSY;
2473 } 2480 }
2474 2481
2475 if (request_irq(pci->irq, snd_rme9652_interrupt, IRQF_SHARED, 2482 if (request_irq(pci->irq, snd_rme9652_interrupt, IRQF_SHARED,
2476 KBUILD_MODNAME, rme9652)) { 2483 KBUILD_MODNAME, rme9652)) {
2477 snd_printk(KERN_ERR "unable to request IRQ %d\n", pci->irq); 2484 dev_err(card->dev, "unable to request IRQ %d\n", pci->irq);
2478 return -EBUSY; 2485 return -EBUSY;
2479 } 2486 }
2480 rme9652->irq = pci->irq; 2487 rme9652->irq = pci->irq;
@@ -2587,8 +2594,8 @@ static int snd_rme9652_probe(struct pci_dev *pci,
2587 return -ENOENT; 2594 return -ENOENT;
2588 } 2595 }
2589 2596
2590 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 2597 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
2591 sizeof(struct snd_rme9652), &card); 2598 sizeof(struct snd_rme9652), &card);
2592 2599
2593 if (err < 0) 2600 if (err < 0)
2594 return err; 2601 return err;
@@ -2597,7 +2604,6 @@ static int snd_rme9652_probe(struct pci_dev *pci,
2597 card->private_free = snd_rme9652_card_free; 2604 card->private_free = snd_rme9652_card_free;
2598 rme9652->dev = dev; 2605 rme9652->dev = dev;
2599 rme9652->pci = pci; 2606 rme9652->pci = pci;
2600 snd_card_set_dev(card, &pci->dev);
2601 2607
2602 if ((err = snd_rme9652_create(card, rme9652, precise_ptr[dev])) < 0) { 2608 if ((err = snd_rme9652_create(card, rme9652, precise_ptr[dev])) < 0) {
2603 snd_card_free(card); 2609 snd_card_free(card);
diff --git a/sound/pci/sis7019.c b/sound/pci/sis7019.c
index e413b4e2c819..6b26b93e001d 100644
--- a/sound/pci/sis7019.c
+++ b/sound/pci/sis7019.c
@@ -1404,8 +1404,6 @@ static int sis_chip_create(struct snd_card *card,
1404 if (rc) 1404 if (rc)
1405 goto error_out_cleanup; 1405 goto error_out_cleanup;
1406 1406
1407 snd_card_set_dev(card, &pci->dev);
1408
1409 return 0; 1407 return 0;
1410 1408
1411error_out_cleanup: 1409error_out_cleanup:
@@ -1440,7 +1438,8 @@ static int snd_sis7019_probe(struct pci_dev *pci,
1440 if (!codecs) 1438 if (!codecs)
1441 codecs = SIS_PRIMARY_CODEC_PRESENT; 1439 codecs = SIS_PRIMARY_CODEC_PRESENT;
1442 1440
1443 rc = snd_card_create(index, id, THIS_MODULE, sizeof(*sis), &card); 1441 rc = snd_card_new(&pci->dev, index, id, THIS_MODULE,
1442 sizeof(*sis), &card);
1444 if (rc < 0) 1443 if (rc < 0)
1445 goto error_out; 1444 goto error_out;
1446 1445
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c
index 2a46bf98af30..2044dc742071 100644
--- a/sound/pci/sonicvibes.c
+++ b/sound/pci/sonicvibes.c
@@ -273,7 +273,7 @@ static inline void snd_sonicvibes_setdmaa(struct sonicvibes * sonic,
273 outl(count, sonic->dmaa_port + SV_DMA_COUNT0); 273 outl(count, sonic->dmaa_port + SV_DMA_COUNT0);
274 outb(0x18, sonic->dmaa_port + SV_DMA_MODE); 274 outb(0x18, sonic->dmaa_port + SV_DMA_MODE);
275#if 0 275#if 0
276 printk(KERN_DEBUG "program dmaa: addr = 0x%x, paddr = 0x%x\n", 276 dev_dbg(sonic->card->dev, "program dmaa: addr = 0x%x, paddr = 0x%x\n",
277 addr, inl(sonic->dmaa_port + SV_DMA_ADDR0)); 277 addr, inl(sonic->dmaa_port + SV_DMA_ADDR0));
278#endif 278#endif
279} 279}
@@ -289,7 +289,7 @@ static inline void snd_sonicvibes_setdmac(struct sonicvibes * sonic,
289 outl(count, sonic->dmac_port + SV_DMA_COUNT0); 289 outl(count, sonic->dmac_port + SV_DMA_COUNT0);
290 outb(0x14, sonic->dmac_port + SV_DMA_MODE); 290 outb(0x14, sonic->dmac_port + SV_DMA_MODE);
291#if 0 291#if 0
292 printk(KERN_DEBUG "program dmac: addr = 0x%x, paddr = 0x%x\n", 292 dev_dbg(sonic->card->dev, "program dmac: addr = 0x%x, paddr = 0x%x\n",
293 addr, inl(sonic->dmac_port + SV_DMA_ADDR0)); 293 addr, inl(sonic->dmac_port + SV_DMA_ADDR0));
294#endif 294#endif
295} 295}
@@ -357,105 +357,105 @@ static unsigned char snd_sonicvibes_in(struct sonicvibes * sonic, unsigned char
357#if 0 357#if 0
358static void snd_sonicvibes_debug(struct sonicvibes * sonic) 358static void snd_sonicvibes_debug(struct sonicvibes * sonic)
359{ 359{
360 printk(KERN_DEBUG 360 dev_dbg(sonic->card->dev,
361 "SV REGS: INDEX = 0x%02x ", inb(SV_REG(sonic, INDEX))); 361 "SV REGS: INDEX = 0x%02x STATUS = 0x%02x\n",
362 printk(" STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS))); 362 inb(SV_REG(sonic, INDEX)), inb(SV_REG(sonic, STATUS)));
363 printk(KERN_DEBUG 363 dev_dbg(sonic->card->dev,
364 " 0x00: left input = 0x%02x ", snd_sonicvibes_in(sonic, 0x00)); 364 " 0x00: left input = 0x%02x 0x20: synth rate low = 0x%02x\n",
365 printk(" 0x20: synth rate low = 0x%02x\n", snd_sonicvibes_in(sonic, 0x20)); 365 snd_sonicvibes_in(sonic, 0x00), snd_sonicvibes_in(sonic, 0x20));
366 printk(KERN_DEBUG 366 dev_dbg(sonic->card->dev,
367 " 0x01: right input = 0x%02x ", snd_sonicvibes_in(sonic, 0x01)); 367 " 0x01: right input = 0x%02x 0x21: synth rate high = 0x%02x\n",
368 printk(" 0x21: synth rate high = 0x%02x\n", snd_sonicvibes_in(sonic, 0x21)); 368 snd_sonicvibes_in(sonic, 0x01), snd_sonicvibes_in(sonic, 0x21));
369 printk(KERN_DEBUG 369 dev_dbg(sonic->card->dev,
370 " 0x02: left AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x02)); 370 " 0x02: left AUX1 = 0x%02x 0x22: ADC clock = 0x%02x\n",
371 printk(" 0x22: ADC clock = 0x%02x\n", snd_sonicvibes_in(sonic, 0x22)); 371 snd_sonicvibes_in(sonic, 0x02), snd_sonicvibes_in(sonic, 0x22));
372 printk(KERN_DEBUG 372 dev_dbg(sonic->card->dev,
373 " 0x03: right AUX1 = 0x%02x ", snd_sonicvibes_in(sonic, 0x03)); 373 " 0x03: right AUX1 = 0x%02x 0x23: ADC alt rate = 0x%02x\n",
374 printk(" 0x23: ADC alt rate = 0x%02x\n", snd_sonicvibes_in(sonic, 0x23)); 374 snd_sonicvibes_in(sonic, 0x03), snd_sonicvibes_in(sonic, 0x23));
375 printk(KERN_DEBUG 375 dev_dbg(sonic->card->dev,
376 " 0x04: left CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x04)); 376 " 0x04: left CD = 0x%02x 0x24: ADC pll M = 0x%02x\n",
377 printk(" 0x24: ADC pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x24)); 377 snd_sonicvibes_in(sonic, 0x04), snd_sonicvibes_in(sonic, 0x24));
378 printk(KERN_DEBUG 378 dev_dbg(sonic->card->dev,
379 " 0x05: right CD = 0x%02x ", snd_sonicvibes_in(sonic, 0x05)); 379 " 0x05: right CD = 0x%02x 0x25: ADC pll N = 0x%02x\n",
380 printk(" 0x25: ADC pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x25)); 380 snd_sonicvibes_in(sonic, 0x05), snd_sonicvibes_in(sonic, 0x25));
381 printk(KERN_DEBUG 381 dev_dbg(sonic->card->dev,
382 " 0x06: left line = 0x%02x ", snd_sonicvibes_in(sonic, 0x06)); 382 " 0x06: left line = 0x%02x 0x26: Synth pll M = 0x%02x\n",
383 printk(" 0x26: Synth pll M = 0x%02x\n", snd_sonicvibes_in(sonic, 0x26)); 383 snd_sonicvibes_in(sonic, 0x06), snd_sonicvibes_in(sonic, 0x26));
384 printk(KERN_DEBUG 384 dev_dbg(sonic->card->dev,
385 " 0x07: right line = 0x%02x ", snd_sonicvibes_in(sonic, 0x07)); 385 " 0x07: right line = 0x%02x 0x27: Synth pll N = 0x%02x\n",
386 printk(" 0x27: Synth pll N = 0x%02x\n", snd_sonicvibes_in(sonic, 0x27)); 386 snd_sonicvibes_in(sonic, 0x07), snd_sonicvibes_in(sonic, 0x27));
387 printk(KERN_DEBUG 387 dev_dbg(sonic->card->dev,
388 " 0x08: MIC = 0x%02x ", snd_sonicvibes_in(sonic, 0x08)); 388 " 0x08: MIC = 0x%02x 0x28: --- = 0x%02x\n",
389 printk(" 0x28: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x28)); 389 snd_sonicvibes_in(sonic, 0x08), snd_sonicvibes_in(sonic, 0x28));
390 printk(KERN_DEBUG 390 dev_dbg(sonic->card->dev,
391 " 0x09: Game port = 0x%02x ", snd_sonicvibes_in(sonic, 0x09)); 391 " 0x09: Game port = 0x%02x 0x29: --- = 0x%02x\n",
392 printk(" 0x29: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x29)); 392 snd_sonicvibes_in(sonic, 0x09), snd_sonicvibes_in(sonic, 0x29));
393 printk(KERN_DEBUG 393 dev_dbg(sonic->card->dev,
394 " 0x0a: left synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0a)); 394 " 0x0a: left synth = 0x%02x 0x2a: MPU401 = 0x%02x\n",
395 printk(" 0x2a: MPU401 = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2a)); 395 snd_sonicvibes_in(sonic, 0x0a), snd_sonicvibes_in(sonic, 0x2a));
396 printk(KERN_DEBUG 396 dev_dbg(sonic->card->dev,
397 " 0x0b: right synth = 0x%02x ", snd_sonicvibes_in(sonic, 0x0b)); 397 " 0x0b: right synth = 0x%02x 0x2b: drive ctrl = 0x%02x\n",
398 printk(" 0x2b: drive ctrl = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2b)); 398 snd_sonicvibes_in(sonic, 0x0b), snd_sonicvibes_in(sonic, 0x2b));
399 printk(KERN_DEBUG 399 dev_dbg(sonic->card->dev,
400 " 0x0c: left AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0c)); 400 " 0x0c: left AUX2 = 0x%02x 0x2c: SRS space = 0x%02x\n",
401 printk(" 0x2c: SRS space = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2c)); 401 snd_sonicvibes_in(sonic, 0x0c), snd_sonicvibes_in(sonic, 0x2c));
402 printk(KERN_DEBUG 402 dev_dbg(sonic->card->dev,
403 " 0x0d: right AUX2 = 0x%02x ", snd_sonicvibes_in(sonic, 0x0d)); 403 " 0x0d: right AUX2 = 0x%02x 0x2d: SRS center = 0x%02x\n",
404 printk(" 0x2d: SRS center = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2d)); 404 snd_sonicvibes_in(sonic, 0x0d), snd_sonicvibes_in(sonic, 0x2d));
405 printk(KERN_DEBUG 405 dev_dbg(sonic->card->dev,
406 " 0x0e: left analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0e)); 406 " 0x0e: left analog = 0x%02x 0x2e: wave source = 0x%02x\n",
407 printk(" 0x2e: wave source = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2e)); 407 snd_sonicvibes_in(sonic, 0x0e), snd_sonicvibes_in(sonic, 0x2e));
408 printk(KERN_DEBUG 408 dev_dbg(sonic->card->dev,
409 " 0x0f: right analog = 0x%02x ", snd_sonicvibes_in(sonic, 0x0f)); 409 " 0x0f: right analog = 0x%02x 0x2f: --- = 0x%02x\n",
410 printk(" 0x2f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x2f)); 410 snd_sonicvibes_in(sonic, 0x0f), snd_sonicvibes_in(sonic, 0x2f));
411 printk(KERN_DEBUG 411 dev_dbg(sonic->card->dev,
412 " 0x10: left PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x10)); 412 " 0x10: left PCM = 0x%02x 0x30: analog power = 0x%02x\n",
413 printk(" 0x30: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x30)); 413 snd_sonicvibes_in(sonic, 0x10), snd_sonicvibes_in(sonic, 0x30));
414 printk(KERN_DEBUG 414 dev_dbg(sonic->card->dev,
415 " 0x11: right PCM = 0x%02x ", snd_sonicvibes_in(sonic, 0x11)); 415 " 0x11: right PCM = 0x%02x 0x31: analog power = 0x%02x\n",
416 printk(" 0x31: analog power = 0x%02x\n", snd_sonicvibes_in(sonic, 0x31)); 416 snd_sonicvibes_in(sonic, 0x11), snd_sonicvibes_in(sonic, 0x31));
417 printk(KERN_DEBUG 417 dev_dbg(sonic->card->dev,
418 " 0x12: DMA data format = 0x%02x ", snd_sonicvibes_in(sonic, 0x12)); 418 " 0x12: DMA data format = 0x%02x 0x32: --- = 0x%02x\n",
419 printk(" 0x32: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x32)); 419 snd_sonicvibes_in(sonic, 0x12), snd_sonicvibes_in(sonic, 0x32));
420 printk(KERN_DEBUG 420 dev_dbg(sonic->card->dev,
421 " 0x13: P/C enable = 0x%02x ", snd_sonicvibes_in(sonic, 0x13)); 421 " 0x13: P/C enable = 0x%02x 0x33: --- = 0x%02x\n",
422 printk(" 0x33: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x33)); 422 snd_sonicvibes_in(sonic, 0x13), snd_sonicvibes_in(sonic, 0x33));
423 printk(KERN_DEBUG 423 dev_dbg(sonic->card->dev,
424 " 0x14: U/D button = 0x%02x ", snd_sonicvibes_in(sonic, 0x14)); 424 " 0x14: U/D button = 0x%02x 0x34: --- = 0x%02x\n",
425 printk(" 0x34: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x34)); 425 snd_sonicvibes_in(sonic, 0x14), snd_sonicvibes_in(sonic, 0x34));
426 printk(KERN_DEBUG 426 dev_dbg(sonic->card->dev,
427 " 0x15: revision = 0x%02x ", snd_sonicvibes_in(sonic, 0x15)); 427 " 0x15: revision = 0x%02x 0x35: --- = 0x%02x\n",
428 printk(" 0x35: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x35)); 428 snd_sonicvibes_in(sonic, 0x15), snd_sonicvibes_in(sonic, 0x35));
429 printk(KERN_DEBUG 429 dev_dbg(sonic->card->dev,
430 " 0x16: ADC output ctrl = 0x%02x ", snd_sonicvibes_in(sonic, 0x16)); 430 " 0x16: ADC output ctrl = 0x%02x 0x36: --- = 0x%02x\n",
431 printk(" 0x36: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x36)); 431 snd_sonicvibes_in(sonic, 0x16), snd_sonicvibes_in(sonic, 0x36));
432 printk(KERN_DEBUG 432 dev_dbg(sonic->card->dev,
433 " 0x17: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x17)); 433 " 0x17: --- = 0x%02x 0x37: --- = 0x%02x\n",
434 printk(" 0x37: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x37)); 434 snd_sonicvibes_in(sonic, 0x17), snd_sonicvibes_in(sonic, 0x37));
435 printk(KERN_DEBUG 435 dev_dbg(sonic->card->dev,
436 " 0x18: DMA A upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x18)); 436 " 0x18: DMA A upper cnt = 0x%02x 0x38: --- = 0x%02x\n",
437 printk(" 0x38: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x38)); 437 snd_sonicvibes_in(sonic, 0x18), snd_sonicvibes_in(sonic, 0x38));
438 printk(KERN_DEBUG 438 dev_dbg(sonic->card->dev,
439 " 0x19: DMA A lower cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x19)); 439 " 0x19: DMA A lower cnt = 0x%02x 0x39: --- = 0x%02x\n",
440 printk(" 0x39: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x39)); 440 snd_sonicvibes_in(sonic, 0x19), snd_sonicvibes_in(sonic, 0x39));
441 printk(KERN_DEBUG 441 dev_dbg(sonic->card->dev,
442 " 0x1a: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1a)); 442 " 0x1a: --- = 0x%02x 0x3a: --- = 0x%02x\n",
443 printk(" 0x3a: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3a)); 443 snd_sonicvibes_in(sonic, 0x1a), snd_sonicvibes_in(sonic, 0x3a));
444 printk(KERN_DEBUG 444 dev_dbg(sonic->card->dev,
445 " 0x1b: --- = 0x%02x ", snd_sonicvibes_in(sonic, 0x1b)); 445 " 0x1b: --- = 0x%02x 0x3b: --- = 0x%02x\n",
446 printk(" 0x3b: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3b)); 446 snd_sonicvibes_in(sonic, 0x1b), snd_sonicvibes_in(sonic, 0x3b));
447 printk(KERN_DEBUG 447 dev_dbg(sonic->card->dev,
448 " 0x1c: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1c)); 448 " 0x1c: DMA C upper cnt = 0x%02x 0x3c: --- = 0x%02x\n",
449 printk(" 0x3c: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3c)); 449 snd_sonicvibes_in(sonic, 0x1c), snd_sonicvibes_in(sonic, 0x3c));
450 printk(KERN_DEBUG 450 dev_dbg(sonic->card->dev,
451 " 0x1d: DMA C upper cnt = 0x%02x ", snd_sonicvibes_in(sonic, 0x1d)); 451 " 0x1d: DMA C upper cnt = 0x%02x 0x3d: --- = 0x%02x\n",
452 printk(" 0x3d: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3d)); 452 snd_sonicvibes_in(sonic, 0x1d), snd_sonicvibes_in(sonic, 0x3d));
453 printk(KERN_DEBUG 453 dev_dbg(sonic->card->dev,
454 " 0x1e: PCM rate low = 0x%02x ", snd_sonicvibes_in(sonic, 0x1e)); 454 " 0x1e: PCM rate low = 0x%02x 0x3e: --- = 0x%02x\n",
455 printk(" 0x3e: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3e)); 455 snd_sonicvibes_in(sonic, 0x1e), snd_sonicvibes_in(sonic, 0x3e));
456 printk(KERN_DEBUG 456 dev_dbg(sonic->card->dev,
457 " 0x1f: PCM rate high = 0x%02x ", snd_sonicvibes_in(sonic, 0x1f)); 457 " 0x1f: PCM rate high = 0x%02x 0x3f: --- = 0x%02x\n",
458 printk(" 0x3f: --- = 0x%02x\n", snd_sonicvibes_in(sonic, 0x3f)); 458 snd_sonicvibes_in(sonic, 0x1f), snd_sonicvibes_in(sonic, 0x3f));
459} 459}
460 460
461#endif 461#endif
@@ -511,8 +511,10 @@ static void snd_sonicvibes_pll(unsigned int rate,
511 *res_m = m; 511 *res_m = m;
512 *res_n = n; 512 *res_n = n;
513#if 0 513#if 0
514 printk(KERN_DEBUG "metric = %i, xm = %i, xn = %i\n", metric, xm, xn); 514 dev_dbg(sonic->card->dev,
515 printk(KERN_DEBUG "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n); 515 "metric = %i, xm = %i, xn = %i\n", metric, xm, xn);
516 dev_dbg(sonic->card->dev,
517 "pll: m = 0x%x, r = 0x%x, n = 0x%x\n", reg, m, r, n);
516#endif 518#endif
517} 519}
518 520
@@ -624,7 +626,8 @@ static irqreturn_t snd_sonicvibes_interrupt(int irq, void *dev_id)
624 return IRQ_NONE; 626 return IRQ_NONE;
625 if (status == 0xff) { /* failure */ 627 if (status == 0xff) { /* failure */
626 outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK)); 628 outb(sonic->irqmask = ~0, SV_REG(sonic, IRQMASK));
627 snd_printk(KERN_ERR "IRQ failure - interrupts disabled!!\n"); 629 dev_err(sonic->card->dev,
630 "IRQ failure - interrupts disabled!!\n");
628 return IRQ_HANDLED; 631 return IRQ_HANDLED;
629 } 632 }
630 if (sonic->pcm) { 633 if (sonic->pcm) {
@@ -1198,7 +1201,8 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
1198 1201
1199 sonic->gameport = gp = gameport_allocate_port(); 1202 sonic->gameport = gp = gameport_allocate_port();
1200 if (!gp) { 1203 if (!gp) {
1201 printk(KERN_ERR "sonicvibes: cannot allocate memory for gameport\n"); 1204 dev_err(sonic->card->dev,
1205 "sonicvibes: cannot allocate memory for gameport\n");
1202 return -ENOMEM; 1206 return -ENOMEM;
1203 } 1207 }
1204 1208
@@ -1267,7 +1271,8 @@ static int snd_sonicvibes_create(struct snd_card *card,
1267 /* check, if we can restrict PCI DMA transfers to 24 bits */ 1271 /* check, if we can restrict PCI DMA transfers to 24 bits */
1268 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 || 1272 if (pci_set_dma_mask(pci, DMA_BIT_MASK(24)) < 0 ||
1269 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) { 1273 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(24)) < 0) {
1270 snd_printk(KERN_ERR "architecture does not support 24bit PCI busmaster DMA\n"); 1274 dev_err(card->dev,
1275 "architecture does not support 24bit PCI busmaster DMA\n");
1271 pci_disable_device(pci); 1276 pci_disable_device(pci);
1272 return -ENXIO; 1277 return -ENXIO;
1273 } 1278 }
@@ -1296,7 +1301,7 @@ static int snd_sonicvibes_create(struct snd_card *card,
1296 1301
1297 if (request_irq(pci->irq, snd_sonicvibes_interrupt, IRQF_SHARED, 1302 if (request_irq(pci->irq, snd_sonicvibes_interrupt, IRQF_SHARED,
1298 KBUILD_MODNAME, sonic)) { 1303 KBUILD_MODNAME, sonic)) {
1299 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1304 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1300 snd_sonicvibes_free(sonic); 1305 snd_sonicvibes_free(sonic);
1301 return -EBUSY; 1306 return -EBUSY;
1302 } 1307 }
@@ -1310,24 +1315,32 @@ static int snd_sonicvibes_create(struct snd_card *card,
1310 if (!dmaa) { 1315 if (!dmaa) {
1311 dmaa = dmaio; 1316 dmaa = dmaio;
1312 dmaio += 0x10; 1317 dmaio += 0x10;
1313 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n", dmaa); 1318 dev_info(card->dev,
1319 "BIOS did not allocate DDMA channel A i/o, allocated at 0x%x\n",
1320 dmaa);
1314 } 1321 }
1315 if (!dmac) { 1322 if (!dmac) {
1316 dmac = dmaio; 1323 dmac = dmaio;
1317 dmaio += 0x10; 1324 dmaio += 0x10;
1318 snd_printk(KERN_INFO "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n", dmac); 1325 dev_info(card->dev,
1326 "BIOS did not allocate DDMA channel C i/o, allocated at 0x%x\n",
1327 dmac);
1319 } 1328 }
1320 pci_write_config_dword(pci, 0x40, dmaa); 1329 pci_write_config_dword(pci, 0x40, dmaa);
1321 pci_write_config_dword(pci, 0x48, dmac); 1330 pci_write_config_dword(pci, 0x48, dmac);
1322 1331
1323 if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) { 1332 if ((sonic->res_dmaa = request_region(dmaa, 0x10, "S3 SonicVibes DDMA-A")) == NULL) {
1324 snd_sonicvibes_free(sonic); 1333 snd_sonicvibes_free(sonic);
1325 snd_printk(KERN_ERR "unable to grab DDMA-A port at 0x%x-0x%x\n", dmaa, dmaa + 0x10 - 1); 1334 dev_err(card->dev,
1335 "unable to grab DDMA-A port at 0x%x-0x%x\n",
1336 dmaa, dmaa + 0x10 - 1);
1326 return -EBUSY; 1337 return -EBUSY;
1327 } 1338 }
1328 if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) { 1339 if ((sonic->res_dmac = request_region(dmac, 0x10, "S3 SonicVibes DDMA-C")) == NULL) {
1329 snd_sonicvibes_free(sonic); 1340 snd_sonicvibes_free(sonic);
1330 snd_printk(KERN_ERR "unable to grab DDMA-C port at 0x%x-0x%x\n", dmac, dmac + 0x10 - 1); 1341 dev_err(card->dev,
1342 "unable to grab DDMA-C port at 0x%x-0x%x\n",
1343 dmac, dmac + 0x10 - 1);
1331 return -EBUSY; 1344 return -EBUSY;
1332 } 1345 }
1333 1346
@@ -1392,8 +1405,6 @@ static int snd_sonicvibes_create(struct snd_card *card,
1392 1405
1393 snd_sonicvibes_proc_init(sonic); 1406 snd_sonicvibes_proc_init(sonic);
1394 1407
1395 snd_card_set_dev(card, &pci->dev);
1396
1397 *rsonic = sonic; 1408 *rsonic = sonic;
1398 return 0; 1409 return 0;
1399} 1410}
@@ -1459,7 +1470,8 @@ static int snd_sonic_probe(struct pci_dev *pci,
1459 return -ENOENT; 1470 return -ENOENT;
1460 } 1471 }
1461 1472
1462 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 1473 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
1474 0, &card);
1463 if (err < 0) 1475 if (err < 0)
1464 return err; 1476 return err;
1465 for (idx = 0; idx < 5; idx++) { 1477 for (idx = 0; idx < 5; idx++) {
diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c
index b3b588bc94c3..d852458caf38 100644
--- a/sound/pci/trident/trident.c
+++ b/sound/pci/trident/trident.c
@@ -89,7 +89,8 @@ static int snd_trident_probe(struct pci_dev *pci,
89 return -ENOENT; 89 return -ENOENT;
90 } 90 }
91 91
92 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 92 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
93 0, &card);
93 if (err < 0) 94 if (err < 0)
94 return err; 95 return err;
95 96
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index fb0e1586a6f8..1272c18a2544 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -69,40 +69,40 @@ static void snd_trident_print_voice_regs(struct snd_trident *trident, int voice)
69{ 69{
70 unsigned int val, tmp; 70 unsigned int val, tmp;
71 71
72 printk(KERN_DEBUG "Trident voice %i:\n", voice); 72 dev_dbg(trident->card->dev, "Trident voice %i:\n", voice);
73 outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR)); 73 outb(voice, TRID_REG(trident, T4D_LFO_GC_CIR));
74 val = inl(TRID_REG(trident, CH_LBA)); 74 val = inl(TRID_REG(trident, CH_LBA));
75 printk(KERN_DEBUG "LBA: 0x%x\n", val); 75 dev_dbg(trident->card->dev, "LBA: 0x%x\n", val);
76 val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); 76 val = inl(TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
77 printk(KERN_DEBUG "GVSel: %i\n", val >> 31); 77 dev_dbg(trident->card->dev, "GVSel: %i\n", val >> 31);
78 printk(KERN_DEBUG "Pan: 0x%x\n", (val >> 24) & 0x7f); 78 dev_dbg(trident->card->dev, "Pan: 0x%x\n", (val >> 24) & 0x7f);
79 printk(KERN_DEBUG "Vol: 0x%x\n", (val >> 16) & 0xff); 79 dev_dbg(trident->card->dev, "Vol: 0x%x\n", (val >> 16) & 0xff);
80 printk(KERN_DEBUG "CTRL: 0x%x\n", (val >> 12) & 0x0f); 80 dev_dbg(trident->card->dev, "CTRL: 0x%x\n", (val >> 12) & 0x0f);
81 printk(KERN_DEBUG "EC: 0x%x\n", val & 0x0fff); 81 dev_dbg(trident->card->dev, "EC: 0x%x\n", val & 0x0fff);
82 if (trident->device != TRIDENT_DEVICE_ID_NX) { 82 if (trident->device != TRIDENT_DEVICE_ID_NX) {
83 val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS)); 83 val = inl(TRID_REG(trident, CH_DX_CSO_ALPHA_FMS));
84 printk(KERN_DEBUG "CSO: 0x%x\n", val >> 16); 84 dev_dbg(trident->card->dev, "CSO: 0x%x\n", val >> 16);
85 printk("Alpha: 0x%x\n", (val >> 4) & 0x0fff); 85 dev_dbg(trident->card->dev, "Alpha: 0x%x\n", (val >> 4) & 0x0fff);
86 printk(KERN_DEBUG "FMS: 0x%x\n", val & 0x0f); 86 dev_dbg(trident->card->dev, "FMS: 0x%x\n", val & 0x0f);
87 val = inl(TRID_REG(trident, CH_DX_ESO_DELTA)); 87 val = inl(TRID_REG(trident, CH_DX_ESO_DELTA));
88 printk(KERN_DEBUG "ESO: 0x%x\n", val >> 16); 88 dev_dbg(trident->card->dev, "ESO: 0x%x\n", val >> 16);
89 printk(KERN_DEBUG "Delta: 0x%x\n", val & 0xffff); 89 dev_dbg(trident->card->dev, "Delta: 0x%x\n", val & 0xffff);
90 val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL)); 90 val = inl(TRID_REG(trident, CH_DX_FMC_RVOL_CVOL));
91 } else { // TRIDENT_DEVICE_ID_NX 91 } else { // TRIDENT_DEVICE_ID_NX
92 val = inl(TRID_REG(trident, CH_NX_DELTA_CSO)); 92 val = inl(TRID_REG(trident, CH_NX_DELTA_CSO));
93 tmp = (val >> 24) & 0xff; 93 tmp = (val >> 24) & 0xff;
94 printk(KERN_DEBUG "CSO: 0x%x\n", val & 0x00ffffff); 94 dev_dbg(trident->card->dev, "CSO: 0x%x\n", val & 0x00ffffff);
95 val = inl(TRID_REG(trident, CH_NX_DELTA_ESO)); 95 val = inl(TRID_REG(trident, CH_NX_DELTA_ESO));
96 tmp |= (val >> 16) & 0xff00; 96 tmp |= (val >> 16) & 0xff00;
97 printk(KERN_DEBUG "Delta: 0x%x\n", tmp); 97 dev_dbg(trident->card->dev, "Delta: 0x%x\n", tmp);
98 printk(KERN_DEBUG "ESO: 0x%x\n", val & 0x00ffffff); 98 dev_dbg(trident->card->dev, "ESO: 0x%x\n", val & 0x00ffffff);
99 val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL)); 99 val = inl(TRID_REG(trident, CH_NX_ALPHA_FMS_FMC_RVOL_CVOL));
100 printk(KERN_DEBUG "Alpha: 0x%x\n", val >> 20); 100 dev_dbg(trident->card->dev, "Alpha: 0x%x\n", val >> 20);
101 printk(KERN_DEBUG "FMS: 0x%x\n", (val >> 16) & 0x0f); 101 dev_dbg(trident->card->dev, "FMS: 0x%x\n", (val >> 16) & 0x0f);
102 } 102 }
103 printk(KERN_DEBUG "FMC: 0x%x\n", (val >> 14) & 3); 103 dev_dbg(trident->card->dev, "FMC: 0x%x\n", (val >> 14) & 3);
104 printk(KERN_DEBUG "RVol: 0x%x\n", (val >> 7) & 0x7f); 104 dev_dbg(trident->card->dev, "RVol: 0x%x\n", (val >> 7) & 0x7f);
105 printk(KERN_DEBUG "CVol: 0x%x\n", val & 0x7f); 105 dev_dbg(trident->card->dev, "CVol: 0x%x\n", val & 0x7f);
106} 106}
107#endif 107#endif
108 108
@@ -156,7 +156,8 @@ static unsigned short snd_trident_codec_read(struct snd_ac97 *ac97, unsigned sho
156 } 156 }
157 157
158 if (count == 0 && !trident->ac97_detect) { 158 if (count == 0 && !trident->ac97_detect) {
159 snd_printk(KERN_ERR "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n", 159 dev_err(trident->card->dev,
160 "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n",
160 reg, data); 161 reg, data);
161 data = 0; 162 data = 0;
162 } 163 }
@@ -497,16 +498,16 @@ void snd_trident_write_voice_regs(struct snd_trident * trident,
497 outl(regs[4], TRID_REG(trident, CH_START + 16)); 498 outl(regs[4], TRID_REG(trident, CH_START + 16));
498 499
499#if 0 500#if 0
500 printk(KERN_DEBUG "written %i channel:\n", voice->number); 501 dev_dbg(trident->card->dev, "written %i channel:\n", voice->number);
501 printk(KERN_DEBUG " regs[0] = 0x%x/0x%x\n", 502 dev_dbg(trident->card->dev, " regs[0] = 0x%x/0x%x\n",
502 regs[0], inl(TRID_REG(trident, CH_START + 0))); 503 regs[0], inl(TRID_REG(trident, CH_START + 0)));
503 printk(KERN_DEBUG " regs[1] = 0x%x/0x%x\n", 504 dev_dbg(trident->card->dev, " regs[1] = 0x%x/0x%x\n",
504 regs[1], inl(TRID_REG(trident, CH_START + 4))); 505 regs[1], inl(TRID_REG(trident, CH_START + 4)));
505 printk(KERN_DEBUG " regs[2] = 0x%x/0x%x\n", 506 dev_dbg(trident->card->dev, " regs[2] = 0x%x/0x%x\n",
506 regs[2], inl(TRID_REG(trident, CH_START + 8))); 507 regs[2], inl(TRID_REG(trident, CH_START + 8)));
507 printk(KERN_DEBUG " regs[3] = 0x%x/0x%x\n", 508 dev_dbg(trident->card->dev, " regs[3] = 0x%x/0x%x\n",
508 regs[3], inl(TRID_REG(trident, CH_START + 12))); 509 regs[3], inl(TRID_REG(trident, CH_START + 12)));
509 printk(KERN_DEBUG " regs[4] = 0x%x/0x%x\n", 510 dev_dbg(trident->card->dev, " regs[4] = 0x%x/0x%x\n",
510 regs[4], inl(TRID_REG(trident, CH_START + 16))); 511 regs[4], inl(TRID_REG(trident, CH_START + 16)));
511#endif 512#endif
512} 513}
@@ -589,7 +590,7 @@ static void snd_trident_write_vol_reg(struct snd_trident * trident,
589 outb(voice->Vol >> 2, TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 2)); 590 outb(voice->Vol >> 2, TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 2));
590 break; 591 break;
591 case TRIDENT_DEVICE_ID_SI7018: 592 case TRIDENT_DEVICE_ID_SI7018:
592 /* printk(KERN_DEBUG "voice->Vol = 0x%x\n", voice->Vol); */ 593 /* dev_dbg(trident->card->dev, "voice->Vol = 0x%x\n", voice->Vol); */
593 outw((voice->CTRL << 12) | voice->Vol, 594 outw((voice->CTRL << 12) | voice->Vol,
594 TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); 595 TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC));
595 break; 596 break;
@@ -3013,13 +3014,15 @@ static int snd_trident_mixer(struct snd_trident *trident, int pcm_spdif_device)
3013 _ac97.num = 1; 3014 _ac97.num = 1;
3014 err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97_sec); 3015 err = snd_ac97_mixer(trident->ac97_bus, &_ac97, &trident->ac97_sec);
3015 if (err < 0) 3016 if (err < 0)
3016 snd_printk(KERN_ERR "SI7018: the secondary codec - invalid access\n"); 3017 dev_err(trident->card->dev,
3018 "SI7018: the secondary codec - invalid access\n");
3017#if 0 // only for my testing purpose --jk 3019#if 0 // only for my testing purpose --jk
3018 { 3020 {
3019 struct snd_ac97 *mc97; 3021 struct snd_ac97 *mc97;
3020 err = snd_ac97_modem(trident->card, &_ac97, &mc97); 3022 err = snd_ac97_modem(trident->card, &_ac97, &mc97);
3021 if (err < 0) 3023 if (err < 0)
3022 snd_printk(KERN_ERR "snd_ac97_modem returned error %i\n", err); 3024 dev_err(trident->card->dev,
3025 "snd_ac97_modem returned error %i\n", err);
3023 } 3026 }
3024#endif 3027#endif
3025 } 3028 }
@@ -3197,7 +3200,8 @@ int snd_trident_create_gameport(struct snd_trident *chip)
3197 3200
3198 chip->gameport = gp = gameport_allocate_port(); 3201 chip->gameport = gp = gameport_allocate_port();
3199 if (!gp) { 3202 if (!gp) {
3200 printk(KERN_ERR "trident: cannot allocate memory for gameport\n"); 3203 dev_err(chip->card->dev,
3204 "cannot allocate memory for gameport\n");
3201 return -ENOMEM; 3205 return -ENOMEM;
3202 } 3206 }
3203 3207
@@ -3270,7 +3274,8 @@ static int snd_trident_sis_reset(struct snd_trident *trident)
3270 goto __si7018_ok; 3274 goto __si7018_ok;
3271 do_delay(trident); 3275 do_delay(trident);
3272 } while (time_after_eq(end_time, jiffies)); 3276 } while (time_after_eq(end_time, jiffies));
3273 snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL))); 3277 dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n",
3278 inl(TRID_REG(trident, SI_SERIAL_INTF_CTRL)));
3274 if (r-- > 0) { 3279 if (r-- > 0) {
3275 end_time = jiffies + HZ; 3280 end_time = jiffies + HZ;
3276 do { 3281 do {
@@ -3367,7 +3372,7 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident)
3367 3372
3368 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 3373 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
3369 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) { 3374 2 * SNDRV_TRIDENT_MAX_PAGES * 4, &trident->tlb.buffer) < 0) {
3370 snd_printk(KERN_ERR "trident: unable to allocate TLB buffer\n"); 3375 dev_err(trident->card->dev, "unable to allocate TLB buffer\n");
3371 return -ENOMEM; 3376 return -ENOMEM;
3372 } 3377 }
3373 trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4); 3378 trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
@@ -3375,13 +3380,14 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident)
3375 /* allocate shadow TLB page table (virtual addresses) */ 3380 /* allocate shadow TLB page table (virtual addresses) */
3376 trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); 3381 trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long));
3377 if (trident->tlb.shadow_entries == NULL) { 3382 if (trident->tlb.shadow_entries == NULL) {
3378 snd_printk(KERN_ERR "trident: unable to allocate shadow TLB entries\n"); 3383 dev_err(trident->card->dev,
3384 "unable to allocate shadow TLB entries\n");
3379 return -ENOMEM; 3385 return -ENOMEM;
3380 } 3386 }
3381 /* allocate and setup silent page and initialise TLB entries */ 3387 /* allocate and setup silent page and initialise TLB entries */
3382 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci), 3388 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(trident->pci),
3383 SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) { 3389 SNDRV_TRIDENT_PAGE_SIZE, &trident->tlb.silent_page) < 0) {
3384 snd_printk(KERN_ERR "trident: unable to allocate silent page\n"); 3390 dev_err(trident->card->dev, "unable to allocate silent page\n");
3385 return -ENOMEM; 3391 return -ENOMEM;
3386 } 3392 }
3387 memset(trident->tlb.silent_page.area, 0, SNDRV_TRIDENT_PAGE_SIZE); 3393 memset(trident->tlb.silent_page.area, 0, SNDRV_TRIDENT_PAGE_SIZE);
@@ -3439,7 +3445,7 @@ static int snd_trident_4d_dx_init(struct snd_trident *trident)
3439 goto __dx_ok; 3445 goto __dx_ok;
3440 do_delay(trident); 3446 do_delay(trident);
3441 } while (time_after_eq(end_time, jiffies)); 3447 } while (time_after_eq(end_time, jiffies));
3442 snd_printk(KERN_ERR "AC'97 codec ready error\n"); 3448 dev_err(trident->card->dev, "AC'97 codec ready error\n");
3443 return -EIO; 3449 return -EIO;
3444 3450
3445 __dx_ok: 3451 __dx_ok:
@@ -3477,7 +3483,8 @@ static int snd_trident_4d_nx_init(struct snd_trident *trident)
3477 goto __nx_ok; 3483 goto __nx_ok;
3478 do_delay(trident); 3484 do_delay(trident);
3479 } while (time_after_eq(end_time, jiffies)); 3485 } while (time_after_eq(end_time, jiffies));
3480 snd_printk(KERN_ERR "AC'97 codec ready error [0x%x]\n", inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT))); 3486 dev_err(trident->card->dev, "AC'97 codec ready error [0x%x]\n",
3487 inl(TRID_REG(trident, NX_ACR0_AC97_COM_STAT)));
3481 return -EIO; 3488 return -EIO;
3482 3489
3483 __nx_ok: 3490 __nx_ok:
@@ -3562,7 +3569,8 @@ int snd_trident_create(struct snd_card *card,
3562 /* check, if we can restrict PCI DMA transfers to 30 bits */ 3569 /* check, if we can restrict PCI DMA transfers to 30 bits */
3563 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 || 3570 if (pci_set_dma_mask(pci, DMA_BIT_MASK(30)) < 0 ||
3564 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) { 3571 pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(30)) < 0) {
3565 snd_printk(KERN_ERR "architecture does not support 30bit PCI busmaster DMA\n"); 3572 dev_err(card->dev,
3573 "architecture does not support 30bit PCI busmaster DMA\n");
3566 pci_disable_device(pci); 3574 pci_disable_device(pci);
3567 return -ENXIO; 3575 return -ENXIO;
3568 } 3576 }
@@ -3600,7 +3608,7 @@ int snd_trident_create(struct snd_card *card,
3600 3608
3601 if (request_irq(pci->irq, snd_trident_interrupt, IRQF_SHARED, 3609 if (request_irq(pci->irq, snd_trident_interrupt, IRQF_SHARED,
3602 KBUILD_MODNAME, trident)) { 3610 KBUILD_MODNAME, trident)) {
3603 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 3611 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
3604 snd_trident_free(trident); 3612 snd_trident_free(trident);
3605 return -EBUSY; 3613 return -EBUSY;
3606 } 3614 }
@@ -3664,7 +3672,6 @@ int snd_trident_create(struct snd_card *card,
3664 snd_trident_enable_eso(trident); 3672 snd_trident_enable_eso(trident);
3665 3673
3666 snd_trident_proc_init(trident); 3674 snd_trident_proc_init(trident);
3667 snd_card_set_dev(card, &pci->dev);
3668 *rtrident = trident; 3675 *rtrident = trident;
3669 return 0; 3676 return 0;
3670} 3677}
@@ -3950,8 +3957,7 @@ static int snd_trident_resume(struct device *dev)
3950 pci_set_power_state(pci, PCI_D0); 3957 pci_set_power_state(pci, PCI_D0);
3951 pci_restore_state(pci); 3958 pci_restore_state(pci);
3952 if (pci_enable_device(pci) < 0) { 3959 if (pci_enable_device(pci) < 0) {
3953 printk(KERN_ERR "trident: pci_enable_device failed, " 3960 dev_err(dev, "pci_enable_device failed, disabling device\n");
3954 "disabling device\n");
3955 snd_card_disconnect(card); 3961 snd_card_disconnect(card);
3956 return -EIO; 3962 return -EIO;
3957 } 3963 }
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c
index 5ae6f042c586..95b98f537b67 100644
--- a/sound/pci/via82xx.c
+++ b/sound/pci/via82xx.c
@@ -459,7 +459,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
459 unsigned int addr; 459 unsigned int addr;
460 460
461 if (idx >= VIA_TABLE_SIZE) { 461 if (idx >= VIA_TABLE_SIZE) {
462 snd_printk(KERN_ERR "via82xx: too much table size!\n"); 462 dev_err(&pci->dev, "too much table size!\n");
463 return -EINVAL; 463 return -EINVAL;
464 } 464 }
465 addr = snd_pcm_sgbuf_get_addr(substream, ofs); 465 addr = snd_pcm_sgbuf_get_addr(substream, ofs);
@@ -474,8 +474,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
474 } else 474 } else
475 flag = 0; /* period continues to the next */ 475 flag = 0; /* period continues to the next */
476 /* 476 /*
477 printk(KERN_DEBUG "via: tbl %d: at %d size %d " 477 dev_dbg(&pci->dev,
478 "(rest %d)\n", idx, ofs, r, rest); 478 "tbl %d: at %d size %d (rest %d)\n",
479 idx, ofs, r, rest);
479 */ 480 */
480 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); 481 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
481 dev->idx_table[idx].offset = ofs; 482 dev->idx_table[idx].offset = ofs;
@@ -528,7 +529,7 @@ static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary)
528 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) 529 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY))
529 return val & 0xffff; 530 return val & 0xffff;
530 } 531 }
531 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", 532 dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n",
532 secondary, snd_via82xx_codec_xread(chip)); 533 secondary, snd_via82xx_codec_xread(chip));
533 return -EIO; 534 return -EIO;
534} 535}
@@ -587,7 +588,8 @@ static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned sho
587 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; 588 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
588 while (1) { 589 while (1) {
589 if (again++ > 3) { 590 if (again++ > 3) {
590 snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", 591 dev_err(chip->card->dev,
592 "codec_read: codec %i is not valid [0x%x]\n",
591 ac97->num, snd_via82xx_codec_xread(chip)); 593 ac97->num, snd_via82xx_codec_xread(chip));
592 return 0xffff; 594 return 0xffff;
593 } 595 }
@@ -777,7 +779,9 @@ static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
777 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\ 779 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
778 viadev->lastpos < viadev->bufsize2)) 780 viadev->lastpos < viadev->bufsize2))
779 781
780static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx, 782static inline unsigned int calc_linear_pos(struct via82xx *chip,
783 struct viadev *viadev,
784 unsigned int idx,
781 unsigned int count) 785 unsigned int count)
782{ 786{
783 unsigned int size, base, res; 787 unsigned int size, base, res;
@@ -790,7 +794,8 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
790 794
791 /* check the validity of the calculated position */ 795 /* check the validity of the calculated position */
792 if (size < count) { 796 if (size < count) {
793 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", 797 dev_dbg(chip->card->dev,
798 "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
794 (int)size, (int)count); 799 (int)size, (int)count);
795 res = viadev->lastpos; 800 res = viadev->lastpos;
796 } else { 801 } else {
@@ -807,9 +812,9 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
807 } 812 }
808 if (check_invalid_pos(viadev, res)) { 813 if (check_invalid_pos(viadev, res)) {
809#ifdef POINTER_DEBUG 814#ifdef POINTER_DEBUG
810 printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, " 815 dev_dbg(chip->card->dev,
811 "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, " 816 "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n",
812 "count = 0x%x\n", idx, viadev->tbl_entries, 817 idx, viadev->tbl_entries,
813 viadev->lastpos, viadev->bufsize2, 818 viadev->lastpos, viadev->bufsize2,
814 viadev->idx_table[idx].offset, 819 viadev->idx_table[idx].offset,
815 viadev->idx_table[idx].size, count); 820 viadev->idx_table[idx].size, count);
@@ -817,8 +822,8 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
817 /* count register returns full size when end of buffer is reached */ 822 /* count register returns full size when end of buffer is reached */
818 res = base + size; 823 res = base + size;
819 if (check_invalid_pos(viadev, res)) { 824 if (check_invalid_pos(viadev, res)) {
820 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), " 825 dev_dbg(chip->card->dev,
821 "using last valid pointer\n"); 826 "invalid via82xx_cur_ptr (2), using last valid pointer\n");
822 res = viadev->lastpos; 827 res = viadev->lastpos;
823 } 828 }
824 } 829 }
@@ -850,7 +855,7 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
850 idx = 0; 855 idx = 0;
851 else /* CURR_PTR holds the address + 8 */ 856 else /* CURR_PTR holds the address + 8 */
852 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries; 857 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries;
853 res = calc_linear_pos(viadev, idx, count); 858 res = calc_linear_pos(chip, viadev, idx, count);
854 viadev->lastpos = res; /* remember the last position */ 859 viadev->lastpos = res; /* remember the last position */
855 spin_unlock(&chip->reg_lock); 860 spin_unlock(&chip->reg_lock);
856 861
@@ -889,13 +894,14 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *subst
889 idx = count >> 24; 894 idx = count >> 24;
890 if (idx >= viadev->tbl_entries) { 895 if (idx >= viadev->tbl_entries) {
891#ifdef POINTER_DEBUG 896#ifdef POINTER_DEBUG
892 printk(KERN_DEBUG "fail: invalid idx = %i/%i\n", idx, 897 dev_dbg(chip->card->dev,
898 "fail: invalid idx = %i/%i\n", idx,
893 viadev->tbl_entries); 899 viadev->tbl_entries);
894#endif 900#endif
895 res = viadev->lastpos; 901 res = viadev->lastpos;
896 } else { 902 } else {
897 count &= 0xffffff; 903 count &= 0xffffff;
898 res = calc_linear_pos(viadev, idx, count); 904 res = calc_linear_pos(chip, viadev, idx, count);
899 } 905 }
900 } else { 906 } else {
901 res = viadev->hwptr_done; 907 res = viadev->hwptr_done;
@@ -1940,14 +1946,15 @@ static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legac
1940 1946
1941 r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport"); 1947 r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport");
1942 if (!r) { 1948 if (!r) {
1943 printk(KERN_WARNING "via82xx: cannot reserve joystick port %#x\n", 1949 dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n",
1944 JOYSTICK_ADDR); 1950 JOYSTICK_ADDR);
1945 return -EBUSY; 1951 return -EBUSY;
1946 } 1952 }
1947 1953
1948 chip->gameport = gp = gameport_allocate_port(); 1954 chip->gameport = gp = gameport_allocate_port();
1949 if (!gp) { 1955 if (!gp) {
1950 printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n"); 1956 dev_err(chip->card->dev,
1957 "cannot allocate memory for gameport\n");
1951 release_and_free_resource(r); 1958 release_and_free_resource(r);
1952 return -ENOMEM; 1959 return -ENOMEM;
1953 } 1960 }
@@ -2016,7 +2023,8 @@ static int snd_via8233_init_misc(struct via82xx *chip)
2016 strcpy(sid.name, "PCM Playback Volume"); 2023 strcpy(sid.name, "PCM Playback Volume");
2017 sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 2024 sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
2018 if (! snd_ctl_find_id(chip->card, &sid)) { 2025 if (! snd_ctl_find_id(chip->card, &sid)) {
2019 snd_printd(KERN_INFO "Using DXS as PCM Playback\n"); 2026 dev_info(chip->card->dev,
2027 "Using DXS as PCM Playback\n");
2020 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_pcmdxs_volume_control, chip)); 2028 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_pcmdxs_volume_control, chip));
2021 if (err < 0) 2029 if (err < 0)
2022 return err; 2030 return err;
@@ -2102,8 +2110,9 @@ static int snd_via686_init_misc(struct via82xx *chip)
2102 mpu_port, MPU401_INFO_INTEGRATED | 2110 mpu_port, MPU401_INFO_INTEGRATED |
2103 MPU401_INFO_IRQ_HOOK, -1, 2111 MPU401_INFO_IRQ_HOOK, -1,
2104 &chip->rmidi) < 0) { 2112 &chip->rmidi) < 0) {
2105 printk(KERN_WARNING "unable to initialize MPU-401" 2113 dev_warn(chip->card->dev,
2106 " at 0x%lx, skipping\n", mpu_port); 2114 "unable to initialize MPU-401 at 0x%lx, skipping\n",
2115 mpu_port);
2107 legacy &= ~VIA_FUNC_ENABLE_MIDI; 2116 legacy &= ~VIA_FUNC_ENABLE_MIDI;
2108 } else { 2117 } else {
2109 legacy &= ~VIA_FUNC_MIDI_IRQMASK; /* enable MIDI interrupt */ 2118 legacy &= ~VIA_FUNC_MIDI_IRQMASK; /* enable MIDI interrupt */
@@ -2203,7 +2212,8 @@ static int snd_via82xx_chip_init(struct via82xx *chip)
2203 } while (time_before(jiffies, end_time)); 2212 } while (time_before(jiffies, end_time));
2204 2213
2205 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 2214 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
2206 snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x]\n", val); 2215 dev_err(chip->card->dev,
2216 "AC'97 codec is not ready [0x%x]\n", val);
2207 2217
2208#if 0 /* FIXME: we don't support the second codec yet so skip the detection now.. */ 2218#if 0 /* FIXME: we don't support the second codec yet so skip the detection now.. */
2209 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | 2219 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
@@ -2303,8 +2313,7 @@ static int snd_via82xx_resume(struct device *dev)
2303 pci_set_power_state(pci, PCI_D0); 2313 pci_set_power_state(pci, PCI_D0);
2304 pci_restore_state(pci); 2314 pci_restore_state(pci);
2305 if (pci_enable_device(pci) < 0) { 2315 if (pci_enable_device(pci) < 0) {
2306 printk(KERN_ERR "via82xx: pci_enable_device failed, " 2316 dev_err(dev, "pci_enable_device failed, disabling device\n");
2307 "disabling device\n");
2308 snd_card_disconnect(card); 2317 snd_card_disconnect(card);
2309 return -EIO; 2318 return -EIO;
2310 } 2319 }
@@ -2417,7 +2426,7 @@ static int snd_via82xx_create(struct snd_card *card,
2417 snd_via8233_interrupt : snd_via686_interrupt, 2426 snd_via8233_interrupt : snd_via686_interrupt,
2418 IRQF_SHARED, 2427 IRQF_SHARED,
2419 KBUILD_MODNAME, chip)) { 2428 KBUILD_MODNAME, chip)) {
2420 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2429 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
2421 snd_via82xx_free(chip); 2430 snd_via82xx_free(chip);
2422 return -EBUSY; 2431 return -EBUSY;
2423 } 2432 }
@@ -2441,8 +2450,6 @@ static int snd_via82xx_create(struct snd_card *card,
2441 * We call pci_set_master here because it does not hurt. */ 2450 * We call pci_set_master here because it does not hurt. */
2442 pci_set_master(pci); 2451 pci_set_master(pci);
2443 2452
2444 snd_card_set_dev(card, &pci->dev);
2445
2446 *r_via = chip; 2453 *r_via = chip;
2447 return 0; 2454 return 0;
2448} 2455}
@@ -2516,7 +2523,7 @@ static int check_dxs_list(struct pci_dev *pci, int revision)
2516 2523
2517 w = snd_pci_quirk_lookup(pci, dxs_whitelist); 2524 w = snd_pci_quirk_lookup(pci, dxs_whitelist);
2518 if (w) { 2525 if (w) {
2519 snd_printdd(KERN_INFO "via82xx: DXS white list for %s found\n", 2526 dev_dbg(&pci->dev, "DXS white list for %s found\n",
2520 snd_pci_quirk_name(w)); 2527 snd_pci_quirk_name(w));
2521 return w->value; 2528 return w->value;
2522 } 2529 }
@@ -2528,10 +2535,10 @@ static int check_dxs_list(struct pci_dev *pci, int revision)
2528 /* 2535 /*
2529 * not detected, try 48k rate only to be sure. 2536 * not detected, try 48k rate only to be sure.
2530 */ 2537 */
2531 printk(KERN_INFO "via82xx: Assuming DXS channels with 48k fixed sample rate.\n"); 2538 dev_info(&pci->dev, "Assuming DXS channels with 48k fixed sample rate.\n");
2532 printk(KERN_INFO " Please try dxs_support=5 option\n"); 2539 dev_info(&pci->dev, " Please try dxs_support=5 option\n");
2533 printk(KERN_INFO " and report if it works on your machine.\n"); 2540 dev_info(&pci->dev, " and report if it works on your machine.\n");
2534 printk(KERN_INFO " For more details, read ALSA-Configuration.txt.\n"); 2541 dev_info(&pci->dev, " For more details, read ALSA-Configuration.txt.\n");
2535 return VIA_DXS_48K; 2542 return VIA_DXS_48K;
2536}; 2543};
2537 2544
@@ -2544,7 +2551,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
2544 unsigned int i; 2551 unsigned int i;
2545 int err; 2552 int err;
2546 2553
2547 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 2554 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
2548 if (err < 0) 2555 if (err < 0)
2549 return err; 2556 return err;
2550 2557
@@ -2584,7 +2591,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
2584 strcpy(card->driver, "VIA8233"); 2591 strcpy(card->driver, "VIA8233");
2585 break; 2592 break;
2586 default: 2593 default:
2587 snd_printk(KERN_ERR "invalid card type %d\n", card_type); 2594 dev_err(card->dev, "invalid card type %d\n", card_type);
2588 err = -EINVAL; 2595 err = -EINVAL;
2589 goto __error; 2596 goto __error;
2590 } 2597 }
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
index ca190283cbd7..46a0526b1d79 100644
--- a/sound/pci/via82xx_modem.c
+++ b/sound/pci/via82xx_modem.c
@@ -312,7 +312,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
312 unsigned int addr; 312 unsigned int addr;
313 313
314 if (idx >= VIA_TABLE_SIZE) { 314 if (idx >= VIA_TABLE_SIZE) {
315 snd_printk(KERN_ERR "via82xx: too much table size!\n"); 315 dev_err(&pci->dev, "too much table size!\n");
316 return -EINVAL; 316 return -EINVAL;
317 } 317 }
318 addr = snd_pcm_sgbuf_get_addr(substream, ofs); 318 addr = snd_pcm_sgbuf_get_addr(substream, ofs);
@@ -329,8 +329,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
329 } else 329 } else
330 flag = 0; /* period continues to the next */ 330 flag = 0; /* period continues to the next */
331 /* 331 /*
332 printk(KERN_DEBUG "via: tbl %d: at %d size %d " 332 dev_dbg(&pci->dev,
333 "(rest %d)\n", idx, ofs, r, rest); 333 "tbl %d: at %d size %d (rest %d)\n",
334 idx, ofs, r, rest);
334 */ 335 */
335 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag); 336 ((u32 *)dev->table.area)[(idx<<1) + 1] = cpu_to_le32(r | flag);
336 dev->idx_table[idx].offset = ofs; 337 dev->idx_table[idx].offset = ofs;
@@ -382,7 +383,7 @@ static int snd_via82xx_codec_ready(struct via82xx_modem *chip, int secondary)
382 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) 383 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY))
383 return val & 0xffff; 384 return val & 0xffff;
384 } 385 }
385 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", 386 dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n",
386 secondary, snd_via82xx_codec_xread(chip)); 387 secondary, snd_via82xx_codec_xread(chip));
387 return -EIO; 388 return -EIO;
388} 389}
@@ -443,7 +444,8 @@ static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned sho
443 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; 444 xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
444 while (1) { 445 while (1) {
445 if (again++ > 3) { 446 if (again++ > 3) {
446 snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", 447 dev_err(chip->card->dev,
448 "codec_read: codec %i is not valid [0x%x]\n",
447 ac97->num, snd_via82xx_codec_xread(chip)); 449 ac97->num, snd_via82xx_codec_xread(chip));
448 return 0xffff; 450 return 0xffff;
449 } 451 }
@@ -560,7 +562,9 @@ static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
560 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\ 562 ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\
561 viadev->lastpos < viadev->bufsize2)) 563 viadev->lastpos < viadev->bufsize2))
562 564
563static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx, 565static inline unsigned int calc_linear_pos(struct via82xx_modem *chip,
566 struct viadev *viadev,
567 unsigned int idx,
564 unsigned int count) 568 unsigned int count)
565{ 569{
566 unsigned int size, res; 570 unsigned int size, res;
@@ -570,20 +574,21 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
570 574
571 /* check the validity of the calculated position */ 575 /* check the validity of the calculated position */
572 if (size < count) { 576 if (size < count) {
573 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", 577 dev_err(chip->card->dev,
578 "invalid via82xx_cur_ptr (size = %d, count = %d)\n",
574 (int)size, (int)count); 579 (int)size, (int)count);
575 res = viadev->lastpos; 580 res = viadev->lastpos;
576 } else if (check_invalid_pos(viadev, res)) { 581 } else if (check_invalid_pos(viadev, res)) {
577#ifdef POINTER_DEBUG 582#ifdef POINTER_DEBUG
578 printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, " 583 dev_dbg(chip->card->dev,
579 "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, " 584 "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n",
580 "count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, 585 idx, viadev->tbl_entries, viadev->lastpos,
581 viadev->bufsize2, viadev->idx_table[idx].offset, 586 viadev->bufsize2, viadev->idx_table[idx].offset,
582 viadev->idx_table[idx].size, count); 587 viadev->idx_table[idx].size, count);
583#endif 588#endif
584 if (count && size < count) { 589 if (count && size < count) {
585 snd_printd(KERN_ERR "invalid via82xx_cur_ptr, " 590 dev_dbg(chip->card->dev,
586 "using last valid pointer\n"); 591 "invalid via82xx_cur_ptr, using last valid pointer\n");
587 res = viadev->lastpos; 592 res = viadev->lastpos;
588 } else { 593 } else {
589 if (! count) 594 if (! count)
@@ -595,8 +600,8 @@ static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int i
595 */ 600 */
596 res = viadev->idx_table[idx].offset + size; 601 res = viadev->idx_table[idx].offset + size;
597 if (check_invalid_pos(viadev, res)) { 602 if (check_invalid_pos(viadev, res)) {
598 snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), " 603 dev_dbg(chip->card->dev,
599 "using last valid pointer\n"); 604 "invalid via82xx_cur_ptr (2), using last valid pointer\n");
600 res = viadev->lastpos; 605 res = viadev->lastpos;
601 } 606 }
602 } 607 }
@@ -632,7 +637,7 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substr
632 else /* CURR_PTR holds the address + 8 */ 637 else /* CURR_PTR holds the address + 8 */
633 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % 638 idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) %
634 viadev->tbl_entries; 639 viadev->tbl_entries;
635 res = calc_linear_pos(viadev, idx, count); 640 res = calc_linear_pos(chip, viadev, idx, count);
636 spin_unlock(&chip->reg_lock); 641 spin_unlock(&chip->reg_lock);
637 642
638 return bytes_to_frames(substream->runtime, res); 643 return bytes_to_frames(substream->runtime, res);
@@ -991,7 +996,8 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip)
991 } while (time_before(jiffies, end_time)); 996 } while (time_before(jiffies, end_time));
992 997
993 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) 998 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)
994 snd_printk(KERN_ERR "AC'97 codec is not ready [0x%x]\n", val); 999 dev_err(chip->card->dev,
1000 "AC'97 codec is not ready [0x%x]\n", val);
995 1001
996 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | 1002 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ |
997 VIA_REG_AC97_SECONDARY_VALID | 1003 VIA_REG_AC97_SECONDARY_VALID |
@@ -1054,8 +1060,7 @@ static int snd_via82xx_resume(struct device *dev)
1054 pci_set_power_state(pci, PCI_D0); 1060 pci_set_power_state(pci, PCI_D0);
1055 pci_restore_state(pci); 1061 pci_restore_state(pci);
1056 if (pci_enable_device(pci) < 0) { 1062 if (pci_enable_device(pci) < 0) {
1057 printk(KERN_ERR "via82xx-modem: pci_enable_device failed, " 1063 dev_err(dev, "pci_enable_device failed, disabling device\n");
1058 "disabling device\n");
1059 snd_card_disconnect(card); 1064 snd_card_disconnect(card);
1060 return -EIO; 1065 return -EIO;
1061 } 1066 }
@@ -1137,7 +1142,7 @@ static int snd_via82xx_create(struct snd_card *card,
1137 chip->port = pci_resource_start(pci, 0); 1142 chip->port = pci_resource_start(pci, 0);
1138 if (request_irq(pci->irq, snd_via82xx_interrupt, IRQF_SHARED, 1143 if (request_irq(pci->irq, snd_via82xx_interrupt, IRQF_SHARED,
1139 KBUILD_MODNAME, chip)) { 1144 KBUILD_MODNAME, chip)) {
1140 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 1145 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
1141 snd_via82xx_free(chip); 1146 snd_via82xx_free(chip);
1142 return -EBUSY; 1147 return -EBUSY;
1143 } 1148 }
@@ -1161,8 +1166,6 @@ static int snd_via82xx_create(struct snd_card *card,
1161 * We call pci_set_master here because it does not hurt. */ 1166 * We call pci_set_master here because it does not hurt. */
1162 pci_set_master(pci); 1167 pci_set_master(pci);
1163 1168
1164 snd_card_set_dev(card, &pci->dev);
1165
1166 *r_via = chip; 1169 *r_via = chip;
1167 return 0; 1170 return 0;
1168} 1171}
@@ -1177,7 +1180,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
1177 unsigned int i; 1180 unsigned int i;
1178 int err; 1181 int err;
1179 1182
1180 err = snd_card_create(index, id, THIS_MODULE, 0, &card); 1183 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card);
1181 if (err < 0) 1184 if (err < 0)
1182 return err; 1185 return err;
1183 1186
@@ -1188,7 +1191,7 @@ static int snd_via82xx_probe(struct pci_dev *pci,
1188 sprintf(card->shortname, "VIA 82XX modem"); 1191 sprintf(card->shortname, "VIA 82XX modem");
1189 break; 1192 break;
1190 default: 1193 default:
1191 snd_printk(KERN_ERR "invalid card type %d\n", card_type); 1194 dev_err(card->dev, "invalid card type %d\n", card_type);
1192 err = -EINVAL; 1195 err = -EINVAL;
1193 goto __error; 1196 goto __error;
1194 } 1197 }
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c
index ab8a9b1bfb8e..ff9074d22607 100644
--- a/sound/pci/vx222/vx222.c
+++ b/sound/pci/vx222/vx222.c
@@ -170,7 +170,7 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
170 170
171 if (request_irq(pci->irq, snd_vx_irq_handler, IRQF_SHARED, 171 if (request_irq(pci->irq, snd_vx_irq_handler, IRQF_SHARED,
172 KBUILD_MODNAME, chip)) { 172 KBUILD_MODNAME, chip)) {
173 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 173 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
174 snd_vx222_free(chip); 174 snd_vx222_free(chip);
175 return -EBUSY; 175 return -EBUSY;
176 } 176 }
@@ -181,8 +181,6 @@ static int snd_vx222_create(struct snd_card *card, struct pci_dev *pci,
181 return err; 181 return err;
182 } 182 }
183 183
184 snd_card_set_dev(card, &pci->dev);
185
186 *rchip = vx; 184 *rchip = vx;
187 return 0; 185 return 0;
188} 186}
@@ -204,7 +202,8 @@ static int snd_vx222_probe(struct pci_dev *pci,
204 return -ENOENT; 202 return -ENOENT;
205 } 203 }
206 204
207 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 205 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
206 0, &card);
208 if (err < 0) 207 if (err < 0)
209 return err; 208 return err;
210 209
@@ -229,7 +228,7 @@ static int snd_vx222_probe(struct pci_dev *pci,
229 228
230 sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i", 229 sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i",
231 card->shortname, vx->port[0], vx->port[1], vx->core.irq); 230 card->shortname, vx->port[0], vx->port[1], vx->core.irq);
232 snd_printdd("%s at 0x%lx & 0x%lx, irq %i\n", 231 dev_dbg(card->dev, "%s at 0x%lx & 0x%lx, irq %i\n",
233 card->shortname, vx->port[0], vx->port[1], vx->core.irq); 232 card->shortname, vx->port[0], vx->port[1], vx->core.irq);
234 233
235#ifdef SND_VX_FW_LOADER 234#ifdef SND_VX_FW_LOADER
@@ -280,8 +279,7 @@ static int snd_vx222_resume(struct device *dev)
280 pci_set_power_state(pci, PCI_D0); 279 pci_set_power_state(pci, PCI_D0);
281 pci_restore_state(pci); 280 pci_restore_state(pci);
282 if (pci_enable_device(pci) < 0) { 281 if (pci_enable_device(pci) < 0) {
283 printk(KERN_ERR "vx222: pci_enable_device failed, " 282 dev_err(dev, "pci_enable_device failed, disabling device\n");
284 "disabling device\n");
285 snd_card_disconnect(card); 283 snd_card_disconnect(card);
286 return -EIO; 284 return -EIO;
287 } 285 }
diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c
index a69e774d0b13..2d1570273e99 100644
--- a/sound/pci/vx222/vx222_ops.c
+++ b/sound/pci/vx222/vx222_ops.c
@@ -108,7 +108,7 @@ static void vx2_outb(struct vx_core *chip, int offset, unsigned char val)
108{ 108{
109 outb(val, vx2_reg_addr(chip, offset)); 109 outb(val, vx2_reg_addr(chip, offset));
110 /* 110 /*
111 printk(KERN_DEBUG "outb: %x -> %x\n", val, vx2_reg_addr(chip, offset)); 111 dev_dbg(chip->card->dev, "outb: %x -> %x\n", val, vx2_reg_addr(chip, offset));
112 */ 112 */
113} 113}
114 114
@@ -129,7 +129,7 @@ static unsigned int vx2_inl(struct vx_core *chip, int offset)
129static void vx2_outl(struct vx_core *chip, int offset, unsigned int val) 129static void vx2_outl(struct vx_core *chip, int offset, unsigned int val)
130{ 130{
131 /* 131 /*
132 printk(KERN_DEBUG "outl: %x -> %x\n", val, vx2_reg_addr(chip, offset)); 132 dev_dbg(chip->card->dev, "outl: %x -> %x\n", val, vx2_reg_addr(chip, offset));
133 */ 133 */
134 outl(val, vx2_reg_addr(chip, offset)); 134 outl(val, vx2_reg_addr(chip, offset));
135} 135}
@@ -173,7 +173,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
173 struct snd_vx222 *chip = (struct snd_vx222 *)_chip; 173 struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
174 unsigned int data; 174 unsigned int data;
175 175
176 snd_printdd("testing xilinx...\n"); 176 dev_dbg(_chip->card->dev, "testing xilinx...\n");
177 /* This test uses several write/read sequences on TEST0 and TEST1 bits 177 /* This test uses several write/read sequences on TEST0 and TEST1 bits
178 * to figure out whever or not the xilinx was correctly loaded 178 * to figure out whever or not the xilinx was correctly loaded
179 */ 179 */
@@ -183,7 +183,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
183 vx_inl(chip, ISR); 183 vx_inl(chip, ISR);
184 data = vx_inl(chip, STATUS); 184 data = vx_inl(chip, STATUS);
185 if ((data & VX_STATUS_VAL_TEST0_MASK) == VX_STATUS_VAL_TEST0_MASK) { 185 if ((data & VX_STATUS_VAL_TEST0_MASK) == VX_STATUS_VAL_TEST0_MASK) {
186 snd_printdd("bad!\n"); 186 dev_dbg(_chip->card->dev, "bad!\n");
187 return -ENODEV; 187 return -ENODEV;
188 } 188 }
189 189
@@ -192,7 +192,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
192 vx_inl(chip, ISR); 192 vx_inl(chip, ISR);
193 data = vx_inl(chip, STATUS); 193 data = vx_inl(chip, STATUS);
194 if (! (data & VX_STATUS_VAL_TEST0_MASK)) { 194 if (! (data & VX_STATUS_VAL_TEST0_MASK)) {
195 snd_printdd("bad! #2\n"); 195 dev_dbg(_chip->card->dev, "bad! #2\n");
196 return -ENODEV; 196 return -ENODEV;
197 } 197 }
198 198
@@ -203,7 +203,7 @@ static int vx2_test_xilinx(struct vx_core *_chip)
203 vx_inl(chip, ISR); 203 vx_inl(chip, ISR);
204 data = vx_inl(chip, STATUS); 204 data = vx_inl(chip, STATUS);
205 if ((data & VX_STATUS_VAL_TEST1_MASK) == VX_STATUS_VAL_TEST1_MASK) { 205 if ((data & VX_STATUS_VAL_TEST1_MASK) == VX_STATUS_VAL_TEST1_MASK) {
206 snd_printdd("bad! #3\n"); 206 dev_dbg(_chip->card->dev, "bad! #3\n");
207 return -ENODEV; 207 return -ENODEV;
208 } 208 }
209 209
@@ -212,11 +212,11 @@ static int vx2_test_xilinx(struct vx_core *_chip)
212 vx_inl(chip, ISR); 212 vx_inl(chip, ISR);
213 data = vx_inl(chip, STATUS); 213 data = vx_inl(chip, STATUS);
214 if (! (data & VX_STATUS_VAL_TEST1_MASK)) { 214 if (! (data & VX_STATUS_VAL_TEST1_MASK)) {
215 snd_printdd("bad! #4\n"); 215 dev_dbg(_chip->card->dev, "bad! #4\n");
216 return -ENODEV; 216 return -ENODEV;
217 } 217 }
218 } 218 }
219 snd_printdd("ok, xilinx fine.\n"); 219 dev_dbg(_chip->card->dev, "ok, xilinx fine.\n");
220 return 0; 220 return 0;
221} 221}
222 222
@@ -397,7 +397,8 @@ static int vx2_load_xilinx_binary(struct vx_core *chip, const struct firmware *x
397 i = vx_inl(chip, GPIOC); 397 i = vx_inl(chip, GPIOC);
398 if (i & 0x0100) 398 if (i & 0x0100)
399 return 0; 399 return 0;
400 snd_printk(KERN_ERR "vx222: xilinx test failed after load, GPIOC=0x%x\n", i); 400 dev_err(chip->card->dev,
401 "xilinx test failed after load, GPIOC=0x%x\n", i);
401 return -EINVAL; 402 return -EINVAL;
402 } 403 }
403 404
diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index e8932b2e4a5d..82eed164b275 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -106,7 +106,8 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,
106 break; 106 break;
107 } 107 }
108 if (!r) { 108 if (!r) {
109 printk(KERN_ERR "ymfpci: no gameport ports available\n"); 109 dev_err(chip->card->dev,
110 "no gameport ports available\n");
110 return -EBUSY; 111 return -EBUSY;
111 } 112 }
112 } 113 }
@@ -116,19 +117,22 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,
116 case 0x204: legacy_ctrl2 |= 2 << 6; break; 117 case 0x204: legacy_ctrl2 |= 2 << 6; break;
117 case 0x205: legacy_ctrl2 |= 3 << 6; break; 118 case 0x205: legacy_ctrl2 |= 3 << 6; break;
118 default: 119 default:
119 printk(KERN_ERR "ymfpci: invalid joystick port %#x", io_port); 120 dev_err(chip->card->dev,
121 "invalid joystick port %#x", io_port);
120 return -EINVAL; 122 return -EINVAL;
121 } 123 }
122 } 124 }
123 125
124 if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) { 126 if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) {
125 printk(KERN_ERR "ymfpci: joystick port %#x is in use.\n", io_port); 127 dev_err(chip->card->dev,
128 "joystick port %#x is in use.\n", io_port);
126 return -EBUSY; 129 return -EBUSY;
127 } 130 }
128 131
129 chip->gameport = gp = gameport_allocate_port(); 132 chip->gameport = gp = gameport_allocate_port();
130 if (!gp) { 133 if (!gp) {
131 printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n"); 134 dev_err(chip->card->dev,
135 "cannot allocate memory for gameport\n");
132 release_and_free_resource(r); 136 release_and_free_resource(r);
133 return -ENOMEM; 137 return -ENOMEM;
134 } 138 }
@@ -187,7 +191,8 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
187 return -ENOENT; 191 return -ENOENT;
188 } 192 }
189 193
190 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); 194 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
195 0, &card);
191 if (err < 0) 196 if (err < 0)
192 return err; 197 return err;
193 198
@@ -313,7 +318,9 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
313 MPU401_INFO_INTEGRATED | 318 MPU401_INFO_INTEGRATED |
314 MPU401_INFO_IRQ_HOOK, 319 MPU401_INFO_IRQ_HOOK,
315 -1, &chip->rawmidi)) < 0) { 320 -1, &chip->rawmidi)) < 0) {
316 printk(KERN_WARNING "ymfpci: cannot initialize MPU401 at 0x%lx, skipping...\n", mpu_port[dev]); 321 dev_warn(card->dev,
322 "cannot initialize MPU401 at 0x%lx, skipping...\n",
323 mpu_port[dev]);
317 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */ 324 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */
318 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); 325 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
319 } 326 }
@@ -323,12 +330,14 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
323 fm_port[dev], 330 fm_port[dev],
324 fm_port[dev] + 2, 331 fm_port[dev] + 2,
325 OPL3_HW_OPL3, 1, &opl3)) < 0) { 332 OPL3_HW_OPL3, 1, &opl3)) < 0) {
326 printk(KERN_WARNING "ymfpci: cannot initialize FM OPL3 at 0x%lx, skipping...\n", fm_port[dev]); 333 dev_warn(card->dev,
334 "cannot initialize FM OPL3 at 0x%lx, skipping...\n",
335 fm_port[dev]);
327 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN; 336 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN;
328 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl); 337 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
329 } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { 338 } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
330 snd_card_free(card); 339 snd_card_free(card);
331 snd_printk(KERN_ERR "cannot create opl3 hwdep\n"); 340 dev_err(card->dev, "cannot create opl3 hwdep\n");
332 return err; 341 return err;
333 } 342 }
334 } 343 }
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index d591c154fc58..81c916a5eb96 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -86,7 +86,9 @@ static int snd_ymfpci_codec_ready(struct snd_ymfpci *chip, int secondary)
86 return 0; 86 return 0;
87 schedule_timeout_uninterruptible(1); 87 schedule_timeout_uninterruptible(1);
88 } while (time_before(jiffies, end_time)); 88 } while (time_before(jiffies, end_time));
89 snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_ymfpci_readw(chip, reg)); 89 dev_err(chip->card->dev,
90 "codec_ready: codec %i is not ready [0x%x]\n",
91 secondary, snd_ymfpci_readw(chip, reg));
90 return -EBUSY; 92 return -EBUSY;
91} 93}
92 94
@@ -319,7 +321,7 @@ static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_
319 ypcm->last_pos = pos; 321 ypcm->last_pos = pos;
320 if (ypcm->period_pos >= ypcm->period_size) { 322 if (ypcm->period_pos >= ypcm->period_size) {
321 /* 323 /*
322 printk(KERN_DEBUG 324 dev_dbg(chip->card->dev,
323 "done - active_bank = 0x%x, start = 0x%x\n", 325 "done - active_bank = 0x%x, start = 0x%x\n",
324 chip->active_bank, 326 chip->active_bank,
325 voice->bank[chip->active_bank].start); 327 voice->bank[chip->active_bank].start);
@@ -372,7 +374,7 @@ static void snd_ymfpci_pcm_capture_interrupt(struct snd_pcm_substream *substream
372 if (ypcm->period_pos >= ypcm->period_size) { 374 if (ypcm->period_pos >= ypcm->period_size) {
373 ypcm->period_pos %= ypcm->period_size; 375 ypcm->period_pos %= ypcm->period_size;
374 /* 376 /*
375 printk(KERN_DEBUG 377 dev_dbg(chip->card->dev,
376 "done - active_bank = 0x%x, start = 0x%x\n", 378 "done - active_bank = 0x%x, start = 0x%x\n",
377 chip->active_bank, 379 chip->active_bank,
378 voice->bank[chip->active_bank].start); 380 voice->bank[chip->active_bank].start);
@@ -2067,7 +2069,8 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2067 &chip->pci->dev); 2069 &chip->pci->dev);
2068 if (err >= 0) { 2070 if (err >= 0) {
2069 if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) { 2071 if (chip->dsp_microcode->size != YDSXG_DSPLENGTH) {
2070 snd_printk(KERN_ERR "DSP microcode has wrong size\n"); 2072 dev_err(chip->card->dev,
2073 "DSP microcode has wrong size\n");
2071 err = -EINVAL; 2074 err = -EINVAL;
2072 } 2075 }
2073 } 2076 }
@@ -2082,8 +2085,8 @@ static int snd_ymfpci_request_firmware(struct snd_ymfpci *chip)
2082 &chip->pci->dev); 2085 &chip->pci->dev);
2083 if (err >= 0) { 2086 if (err >= 0) {
2084 if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) { 2087 if (chip->controller_microcode->size != YDSXG_CTRLLENGTH) {
2085 snd_printk(KERN_ERR "controller microcode" 2088 dev_err(chip->card->dev,
2086 " has wrong size\n"); 2089 "controller microcode has wrong size\n");
2087 err = -EINVAL; 2090 err = -EINVAL;
2088 } 2091 }
2089 } 2092 }
@@ -2360,8 +2363,7 @@ static int snd_ymfpci_resume(struct device *dev)
2360 pci_set_power_state(pci, PCI_D0); 2363 pci_set_power_state(pci, PCI_D0);
2361 pci_restore_state(pci); 2364 pci_restore_state(pci);
2362 if (pci_enable_device(pci) < 0) { 2365 if (pci_enable_device(pci) < 0) {
2363 printk(KERN_ERR "ymfpci: pci_enable_device failed, " 2366 dev_err(dev, "pci_enable_device failed, disabling device\n");
2364 "disabling device\n");
2365 snd_card_disconnect(card); 2367 snd_card_disconnect(card);
2366 return -EIO; 2368 return -EIO;
2367 } 2369 }
@@ -2433,13 +2435,15 @@ int snd_ymfpci_create(struct snd_card *card,
2433 chip->src441_used = -1; 2435 chip->src441_used = -1;
2434 2436
2435 if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) { 2437 if ((chip->res_reg_area = request_mem_region(chip->reg_area_phys, 0x8000, "YMFPCI")) == NULL) {
2436 snd_printk(KERN_ERR "unable to grab memory region 0x%lx-0x%lx\n", chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1); 2438 dev_err(chip->card->dev,
2439 "unable to grab memory region 0x%lx-0x%lx\n",
2440 chip->reg_area_phys, chip->reg_area_phys + 0x8000 - 1);
2437 snd_ymfpci_free(chip); 2441 snd_ymfpci_free(chip);
2438 return -EBUSY; 2442 return -EBUSY;
2439 } 2443 }
2440 if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED, 2444 if (request_irq(pci->irq, snd_ymfpci_interrupt, IRQF_SHARED,
2441 KBUILD_MODNAME, chip)) { 2445 KBUILD_MODNAME, chip)) {
2442 snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); 2446 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
2443 snd_ymfpci_free(chip); 2447 snd_ymfpci_free(chip);
2444 return -EBUSY; 2448 return -EBUSY;
2445 } 2449 }
@@ -2453,7 +2457,7 @@ int snd_ymfpci_create(struct snd_card *card,
2453 2457
2454 err = snd_ymfpci_request_firmware(chip); 2458 err = snd_ymfpci_request_firmware(chip);
2455 if (err < 0) { 2459 if (err < 0) {
2456 snd_printk(KERN_ERR "firmware request failed: %d\n", err); 2460 dev_err(chip->card->dev, "firmware request failed: %d\n", err);
2457 snd_ymfpci_free(chip); 2461 snd_ymfpci_free(chip);
2458 return err; 2462 return err;
2459 } 2463 }
@@ -2487,8 +2491,6 @@ int snd_ymfpci_create(struct snd_card *card,
2487 2491
2488 snd_ymfpci_proc_init(card, chip); 2492 snd_ymfpci_proc_init(card, chip);
2489 2493
2490 snd_card_set_dev(card, &pci->dev);
2491
2492 *rchip = chip; 2494 *rchip = chip;
2493 return 0; 2495 return 0;
2494} 2496}